mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-11 09:50:12 +00:00
Fixes assorted problems with the history edit functions in libedit. This
affects sh, ftp (and others?). Submitted by: Max Euston <meuston@jmrodgers.com> PR: 6516
This commit is contained in:
parent
431e760b94
commit
10d9142685
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=37199
@ -153,11 +153,26 @@ 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);
|
||||
}
|
||||
|
@ -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)));
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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>]
|
||||
|
Loading…
Reference in New Issue
Block a user