jart / bestline

ANSI Standard X3.64 Teletypewriter Command Session Library
Other
443 stars 29 forks source link

interest in vi mode? #15

Open andychu opened 2 years ago

andychu commented 2 years ago

I'm looking for a GNU readline alternative, mostly to make sure https://www.oilshell.org/ doesn't become too tied to that interface (which is very hairy).

https://github.com/oilshell/oil/issues/460

I did some research and it seems like the only line editors that support vi mode (set -o vi) are GNU readline and libedit (derived from NetBSD with few docs). It looks like it is a few thousand lines of logic in each.

I wonder if this is in scope for bestline? I looked at the code a little and maybe it can be done with an alternative bestlineEdit()? The main difference is that vi is modal and hitting escape brings you into edit mode, but I think that could be handled in such a wrapper.

~/src/readline-8.1$ wc -l vi*.c
  875 vi_keymap.c
 2408 vi_mode.c
 3283 total
~/src/libedit-20210910-3.1/src$ wc -l vi*.c
 1160 vi.c
  774 vis.c
 1934 total

minimal docs on vi mode: https://tiswww.case.edu/php/chet/readline/rluserman.html#SEC22

cassepipe commented 1 year ago

...or at least an option to open the command line in $EDITOR ?