diff options
Diffstat (limited to 'lib/libedit')
-rw-r--r-- | lib/libedit/chared.c | 17 | ||||
-rw-r--r-- | lib/libedit/chared.h | 1 | ||||
-rw-r--r-- | lib/libedit/common.c | 5 | ||||
-rw-r--r-- | lib/libedit/map.c | 2 | ||||
-rw-r--r-- | lib/libedit/read.c | 4 | ||||
-rw-r--r-- | lib/libedit/vi.c | 34 |
6 files changed, 49 insertions, 14 deletions
diff --git a/lib/libedit/chared.c b/lib/libedit/chared.c index dcd189c..ed6a7c7 100644 --- a/lib/libedit/chared.c +++ b/lib/libedit/chared.c @@ -153,12 +153,27 @@ ce__isword(p) /* cv__isword(): - * Return if p is part of a word according to vi + * Return type of word for p according to vi */ protected int cv__isword(p) int p; { + if (isspace((unsigned char) p)) + return 0; + if ((unsigned char) p == '_' || isalnum((unsigned char) p)) + return 1; + return 2; +} + + +/* c___isword(): + * Return if p is part of a space-delimited word (!isspace) + */ +protected int +c___isword(p) + int p; +{ return !isspace((unsigned char) p); } diff --git a/lib/libedit/chared.h b/lib/libedit/chared.h index 22d07f0..f979b93 100644 --- a/lib/libedit/chared.h +++ b/lib/libedit/chared.h @@ -138,6 +138,7 @@ protected int cv__isword __P((int)); protected void cv_delfini __P((EditLine *)); protected char *cv__endword __P((char *, char *, int)); protected int ce__isword __P((int)); +protected int c___isword __P((int)); protected void cv_undo __P((EditLine *, int, int, char *)); protected char *cv_next_word __P((EditLine*, char *, char *, int, int (*)(int))); diff --git a/lib/libedit/common.c b/lib/libedit/common.c index 6908819..66b7c90 100644 --- a/lib/libedit/common.c +++ b/lib/libedit/common.c @@ -110,8 +110,11 @@ ed_insert(el, c) re_refresh(el); } + if (el->el_state.inputmode == MODE_REPLACE_1 || el->el_state.inputmode == MODE_REPLACE) + el->el_chared.c_undo.action=CHANGE; + if (el->el_state.inputmode == MODE_REPLACE_1) - (void) vi_command_mode(el, 0); + return vi_command_mode(el, 0); return CC_NORM; } diff --git a/lib/libedit/map.c b/lib/libedit/map.c index 3b282cc..5719827 100644 --- a/lib/libedit/map.c +++ b/lib/libedit/map.c @@ -701,7 +701,7 @@ private el_action_t el_map_vi_command[] = { /* 82 */ VI_REPLACE_MODE, /* R */ /* 83 */ VI_SUBSTITUTE_LINE, /* S */ /* 84 */ VI_TO_PREV_CHAR, /* T */ - /* 85 */ ED_UNASSIGNED, /* U */ + /* 85 */ VI_UNDO_LINE, /* U */ /* 86 */ ED_UNASSIGNED, /* V */ /* 87 */ VI_NEXT_SPACE_WORD, /* W */ /* 88 */ ED_DELETE_PREV_CHAR, /* X */ diff --git a/lib/libedit/read.c b/lib/libedit/read.c index 6475a25..d8d6628 100644 --- a/lib/libedit/read.c +++ b/lib/libedit/read.c @@ -196,10 +196,10 @@ read_getcmd(el, cmdnum, ch) el_action_t *cmdnum; char *ch; { - el_action_t cmd = 0; + el_action_t cmd = ED_UNASSIGNED; int num; - while (cmd == 0 || cmd == ED_SEQUENCE_LEAD_IN) { + while (cmd == ED_UNASSIGNED || cmd == ED_SEQUENCE_LEAD_IN) { if ((num = el_getc(el, ch)) != 1) /* if EOF or error */ return num; diff --git a/lib/libedit/vi.c b/lib/libedit/vi.c index 3a8ef05..5099757 100644 --- a/lib/libedit/vi.c +++ b/lib/libedit/vi.c @@ -173,7 +173,7 @@ vi_prev_space_word(el, c) el->el_line.cursor = cv_prev_word(el, el->el_line.cursor, el->el_line.buffer, el->el_state.argument, - cv__isword); + c___isword); if (el->el_chared.c_vcmd.action & DELETE) { cv_delfini(el); @@ -186,7 +186,7 @@ vi_prev_space_word(el, c) /* vi_prev_word(): * Vi move to the previous word - * [B] + * [b] */ protected el_action_t /*ARGSUSED*/ @@ -200,7 +200,7 @@ vi_prev_word(el, c) el->el_line.cursor = cv_prev_word(el, el->el_line.cursor, el->el_line.buffer, el->el_state.argument, - ce__isword); + cv__isword); if (el->el_chared.c_vcmd.action & DELETE) { cv_delfini(el); @@ -227,7 +227,7 @@ vi_next_space_word(el, c) el->el_line.cursor = cv_next_word(el, el->el_line.cursor, el->el_line.lastchar, el->el_state.argument, - cv__isword); + c___isword); if (el->el_map.type == MAP_VI) if (el->el_chared.c_vcmd.action & DELETE) { @@ -254,7 +254,7 @@ vi_next_word(el, c) el->el_line.cursor = cv_next_word(el, el->el_line.cursor, el->el_line.lastchar, el->el_state.argument, - ce__isword); + cv__isword); if (el->el_map.type == MAP_VI) if (el->el_chared.c_vcmd.action & DELETE) { @@ -346,7 +346,7 @@ vi_replace_char(el, c) el->el_chared.c_undo.ptr = el->el_line.cursor; el->el_chared.c_undo.isize = 0; el->el_chared.c_undo.dsize = 0; - return CC_NORM; + return CC_ARGHACK; } @@ -366,13 +366,13 @@ vi_replace_mode(el, c) el->el_chared.c_undo.ptr = el->el_line.cursor; el->el_chared.c_undo.isize = 0; el->el_chared.c_undo.dsize = 0; - return CC_NORM; + return CC_ARGHACK; } /* vi_substitute_char(): * Vi replace character under the cursor and enter insert mode - * [r] + * [s] */ protected el_action_t /*ARGSUSED*/ @@ -448,7 +448,8 @@ vi_add(el, c) EditLine *el; int c; { - int ret; + el_action_t ret; + el->el_map.current = el->el_map.key; if (el->el_line.cursor < el->el_line.lastchar) { el->el_line.cursor++; @@ -664,6 +665,21 @@ vi_undo(el, c) } +/* vi_undo_line(): + * Vi undo all changes + * [U] + */ +protected el_action_t +/*ARGSUSED*/ +vi_undo_line(el, c) + EditLine *el; + int c; +{ + + return hist_get(el); +} + + /* vi_command_mode(): * Vi enter command mode (use alternative key bindings) * [<ESC>] |