Updated libedit to NetBSD upstream
Note: This unconditionally assumes wchar_t support. May need revision if some platforms prove problematic.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $NetBSD: common.c,v 1.24 2009/12/30 22:37:40 christos Exp $ */
|
||||
/* $NetBSD: common.c,v 1.47 2016/05/22 19:44:26 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@@ -37,27 +37,34 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: common.c,v 1.24 2009/12/30 22:37:40 christos Exp $");
|
||||
__RCSID("$NetBSD: common.c,v 1.47 2016/05/22 19:44:26 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* common.c: Common Editor functions
|
||||
*/
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "el.h"
|
||||
#include "common.h"
|
||||
#include "fcns.h"
|
||||
#include "parse.h"
|
||||
#include "vi.h"
|
||||
|
||||
/* ed_end_of_file():
|
||||
* Indicate end of file
|
||||
* [^D]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_end_of_file(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_end_of_file(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
re_goto_bottom(el);
|
||||
*el->el_line.lastchar = '\0';
|
||||
return (CC_EOF);
|
||||
return CC_EOF;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,13 +72,13 @@ ed_end_of_file(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Add character to the line
|
||||
* Insert a character [bound to all insert keys]
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_insert(EditLine *el, Int c)
|
||||
libedit_private el_action_t
|
||||
ed_insert(EditLine *el, wint_t c)
|
||||
{
|
||||
int count = el->el_state.argument;
|
||||
|
||||
if (c == '\0')
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
|
||||
if (el->el_line.lastchar + el->el_state.argument >=
|
||||
el->el_line.limit) {
|
||||
@@ -99,7 +106,7 @@ ed_insert(EditLine *el, Int c)
|
||||
if (el->el_state.inputmode == MODE_REPLACE_1)
|
||||
return vi_command_mode(el, 0);
|
||||
|
||||
return (CC_NORM);
|
||||
return CC_NORM;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,14 +114,14 @@ ed_insert(EditLine *el, Int c)
|
||||
* Delete from beginning of current word to cursor
|
||||
* [M-^?] [^W]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_delete_prev_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_delete_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *cp, *p, *kp;
|
||||
wchar_t *cp, *p, *kp;
|
||||
|
||||
if (el->el_line.cursor == el->el_line.buffer)
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
|
||||
cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
|
||||
el->el_state.argument, ce__isword);
|
||||
@@ -127,7 +134,7 @@ ed_delete_prev_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
el->el_line.cursor = cp;
|
||||
if (el->el_line.cursor < el->el_line.buffer)
|
||||
el->el_line.cursor = el->el_line.buffer; /* bounds check */
|
||||
return (CC_REFRESH);
|
||||
return CC_REFRESH;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,14 +142,14 @@ ed_delete_prev_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Delete character under cursor
|
||||
* [^D] [x]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_delete_next_char(EditLine *el, Int c)
|
||||
ed_delete_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
#ifdef notdef /* XXX */
|
||||
#ifdef DEBUG_EDIT
|
||||
#define EL el->el_line
|
||||
(void) fprintf(el->el_errlfile,
|
||||
"\nD(b: %x(%s) c: %x(%s) last: %x(%s) limit: %x(%s)\n",
|
||||
(void) fprintf(el->el_errfile,
|
||||
"\nD(b: %p(%ls) c: %p(%ls) last: %p(%ls) limit: %p(%ls)\n",
|
||||
EL.buffer, EL.buffer, EL.cursor, EL.cursor, EL.lastchar,
|
||||
EL.lastchar, EL.limit, EL.limit);
|
||||
#endif
|
||||
@@ -152,32 +159,29 @@ ed_delete_next_char(EditLine *el, Int c)
|
||||
if (el->el_line.cursor == el->el_line.buffer) {
|
||||
/* if I'm also at the beginning */
|
||||
#ifdef KSHVI
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
#else
|
||||
/* then do an EOF */
|
||||
term_writec(el, c);
|
||||
return (CC_EOF);
|
||||
terminal_writec(el, c);
|
||||
return CC_EOF;
|
||||
#endif
|
||||
} else {
|
||||
#ifdef KSHVI
|
||||
el->el_line.cursor--;
|
||||
#else
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
if (el->el_line.cursor != el->el_line.buffer)
|
||||
el->el_line.cursor--;
|
||||
else
|
||||
return (CC_ERROR);
|
||||
}
|
||||
} else
|
||||
return CC_ERROR;
|
||||
}
|
||||
c_delafter(el, el->el_state.argument); /* delete after dot */
|
||||
if (el->el_line.cursor >= el->el_line.lastchar &&
|
||||
if (el->el_map.type == MAP_VI &&
|
||||
el->el_line.cursor >= el->el_line.lastchar &&
|
||||
el->el_line.cursor > el->el_line.buffer)
|
||||
/* bounds check */
|
||||
el->el_line.cursor = el->el_line.lastchar - 1;
|
||||
return (CC_REFRESH);
|
||||
return CC_REFRESH;
|
||||
}
|
||||
|
||||
|
||||
@@ -185,11 +189,11 @@ ed_delete_next_char(EditLine *el, Int c)
|
||||
* Cut to the end of line
|
||||
* [^K] [^K]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_kill_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_kill_line(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *kp, *cp;
|
||||
wchar_t *kp, *cp;
|
||||
|
||||
cp = el->el_line.cursor;
|
||||
kp = el->el_chared.c_kill.buf;
|
||||
@@ -198,7 +202,7 @@ ed_kill_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
el->el_chared.c_kill.last = kp;
|
||||
/* zap! -- delete to end */
|
||||
el->el_line.lastchar = el->el_line.cursor;
|
||||
return (CC_REFRESH);
|
||||
return CC_REFRESH;
|
||||
}
|
||||
|
||||
|
||||
@@ -206,22 +210,22 @@ ed_kill_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Move cursor to the end of line
|
||||
* [^E] [^E]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_move_to_end(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_move_to_end(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
if (el->el_map.type == MAP_VI) {
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
return CC_REFRESH;
|
||||
}
|
||||
#ifdef VI_MOVE
|
||||
el->el_line.cursor--;
|
||||
#endif
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
return CC_CURSOR;
|
||||
}
|
||||
|
||||
|
||||
@@ -229,23 +233,23 @@ ed_move_to_end(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Move cursor to the beginning of line
|
||||
* [^A] [^A]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_move_to_beg(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_move_to_beg(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
|
||||
if (el->el_map.type == MAP_VI) {
|
||||
/* We want FIRST non space character */
|
||||
while (Isspace(*el->el_line.cursor))
|
||||
while (iswspace(*el->el_line.cursor))
|
||||
el->el_line.cursor++;
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
return CC_REFRESH;
|
||||
}
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
return CC_CURSOR;
|
||||
}
|
||||
|
||||
|
||||
@@ -253,13 +257,13 @@ ed_move_to_beg(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Exchange the character to the left of the cursor with the one under it
|
||||
* [^T] [^T]
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_transpose_chars(EditLine *el, Int c)
|
||||
libedit_private el_action_t
|
||||
ed_transpose_chars(EditLine *el, wint_t c)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor < el->el_line.lastchar) {
|
||||
if (el->el_line.lastchar <= &el->el_line.buffer[1])
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
else
|
||||
el->el_line.cursor++;
|
||||
}
|
||||
@@ -268,9 +272,9 @@ ed_transpose_chars(EditLine *el, Int c)
|
||||
c = el->el_line.cursor[-2];
|
||||
el->el_line.cursor[-2] = el->el_line.cursor[-1];
|
||||
el->el_line.cursor[-1] = c;
|
||||
return (CC_REFRESH);
|
||||
return CC_REFRESH;
|
||||
} else
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -278,17 +282,17 @@ ed_transpose_chars(EditLine *el, Int c)
|
||||
* Move to the right one character
|
||||
* [^F] [^F]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_next_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_next_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *lim = el->el_line.lastchar;
|
||||
wchar_t *lim = el->el_line.lastchar;
|
||||
|
||||
if (el->el_line.cursor >= lim ||
|
||||
(el->el_line.cursor == lim - 1 &&
|
||||
el->el_map.type == MAP_VI &&
|
||||
el->el_chared.c_vcmd.action == NOP))
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
|
||||
el->el_line.cursor += el->el_state.argument;
|
||||
if (el->el_line.cursor > lim)
|
||||
@@ -297,9 +301,9 @@ ed_next_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
if (el->el_map.type == MAP_VI)
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
return CC_REFRESH;
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
return CC_CURSOR;
|
||||
}
|
||||
|
||||
|
||||
@@ -307,13 +311,13 @@ ed_next_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Move to the beginning of the current word
|
||||
* [M-b] [b]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_prev_word(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor == el->el_line.buffer)
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
|
||||
el->el_line.cursor = c__prev_word(el->el_line.cursor,
|
||||
el->el_line.buffer,
|
||||
@@ -323,9 +327,9 @@ ed_prev_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
if (el->el_map.type == MAP_VI)
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
return CC_REFRESH;
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
return CC_CURSOR;
|
||||
}
|
||||
|
||||
|
||||
@@ -333,9 +337,9 @@ ed_prev_word(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Move to the left one character
|
||||
* [^B] [^B]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor > el->el_line.buffer) {
|
||||
@@ -346,11 +350,11 @@ ed_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
if (el->el_map.type == MAP_VI)
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
return CC_REFRESH;
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
return CC_CURSOR;
|
||||
} else
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -358,32 +362,30 @@ ed_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Add the next character typed verbatim
|
||||
* [^V] [^V]
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_quoted_insert(EditLine *el, Int c)
|
||||
libedit_private el_action_t
|
||||
ed_quoted_insert(EditLine *el, wint_t c)
|
||||
{
|
||||
int num;
|
||||
Char tc;
|
||||
|
||||
tty_quotemode(el);
|
||||
num = FUN(el,getc)(el, &tc);
|
||||
c = tc;
|
||||
num = el_wgetc(el, &c);
|
||||
tty_noquotemode(el);
|
||||
if (num == 1)
|
||||
return (ed_insert(el, c));
|
||||
return ed_insert(el, c);
|
||||
else
|
||||
return (ed_end_of_file(el, 0));
|
||||
return ed_end_of_file(el, 0);
|
||||
}
|
||||
|
||||
|
||||
/* ed_digit():
|
||||
* Adds to argument or enters a digit
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_digit(EditLine *el, Int c)
|
||||
libedit_private el_action_t
|
||||
ed_digit(EditLine *el, wint_t c)
|
||||
{
|
||||
|
||||
if (!Isdigit(c))
|
||||
return (CC_ERROR);
|
||||
if (!iswdigit(c))
|
||||
return CC_ERROR;
|
||||
|
||||
if (el->el_state.doingarg) {
|
||||
/* if doing an arg, add this in... */
|
||||
@@ -391,11 +393,11 @@ ed_digit(EditLine *el, Int c)
|
||||
el->el_state.argument = c - '0';
|
||||
else {
|
||||
if (el->el_state.argument > 1000000)
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
el->el_state.argument =
|
||||
(el->el_state.argument * 10) + (c - '0');
|
||||
}
|
||||
return (CC_ARGHACK);
|
||||
return CC_ARGHACK;
|
||||
}
|
||||
|
||||
return ed_insert(el, c);
|
||||
@@ -406,23 +408,23 @@ ed_digit(EditLine *el, Int c)
|
||||
* Digit that starts argument
|
||||
* For ESC-n
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_argument_digit(EditLine *el, Int c)
|
||||
libedit_private el_action_t
|
||||
ed_argument_digit(EditLine *el, wint_t c)
|
||||
{
|
||||
|
||||
if (!Isdigit(c))
|
||||
return (CC_ERROR);
|
||||
if (!iswdigit(c))
|
||||
return CC_ERROR;
|
||||
|
||||
if (el->el_state.doingarg) {
|
||||
if (el->el_state.argument > 1000000)
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
el->el_state.argument = (el->el_state.argument * 10) +
|
||||
(c - '0');
|
||||
} else { /* else starting an argument */
|
||||
el->el_state.argument = c - '0';
|
||||
el->el_state.doingarg = 1;
|
||||
}
|
||||
return (CC_ARGHACK);
|
||||
return CC_ARGHACK;
|
||||
}
|
||||
|
||||
|
||||
@@ -430,114 +432,27 @@ ed_argument_digit(EditLine *el, Int c)
|
||||
* Indicates unbound character
|
||||
* Bound to keys that are not assigned
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_unassigned(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_unassigned(EditLine *el __attribute__((__unused__)),
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
** TTY key handling.
|
||||
**/
|
||||
|
||||
/* ed_tty_sigint():
|
||||
* Tty interrupt character
|
||||
* [^C]
|
||||
/* ed_ignore():
|
||||
* Input characters that have no effect
|
||||
* [^C ^O ^Q ^S ^Z ^\ ^]] [^C ^O ^Q ^S ^\]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_sigint(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
ed_ignore(EditLine *el __attribute__((__unused__)),
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_dsusp():
|
||||
* Tty delayed suspend character
|
||||
* [^Y]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_flush_output():
|
||||
* Tty flush output characters
|
||||
* [^O]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_sigquit():
|
||||
* Tty quit character
|
||||
* [^\]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_sigtstp():
|
||||
* Tty suspend character
|
||||
* [^Z]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_stop_output():
|
||||
* Tty disallow output characters
|
||||
* [^S]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_start_output():
|
||||
* Tty allow output characters
|
||||
* [^Q]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_start_output(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
return CC_NORM;
|
||||
}
|
||||
|
||||
|
||||
@@ -545,15 +460,15 @@ ed_tty_start_output(EditLine *el __attribute__((__unused__)),
|
||||
* Execute command
|
||||
* [^J]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_newline(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_newline(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
re_goto_bottom(el);
|
||||
*el->el_line.lastchar++ = '\n';
|
||||
*el->el_line.lastchar = '\0';
|
||||
return (CC_NEWLINE);
|
||||
return CC_NEWLINE;
|
||||
}
|
||||
|
||||
|
||||
@@ -561,19 +476,19 @@ ed_newline(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Delete the character to the left of the cursor
|
||||
* [^?]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_delete_prev_char(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor <= el->el_line.buffer)
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
|
||||
c_delbefore(el, el->el_state.argument);
|
||||
el->el_line.cursor -= el->el_state.argument;
|
||||
if (el->el_line.cursor < el->el_line.buffer)
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
return (CC_REFRESH);
|
||||
return CC_REFRESH;
|
||||
}
|
||||
|
||||
|
||||
@@ -581,14 +496,14 @@ ed_delete_prev_char(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Clear screen leaving current line at the top
|
||||
* [^L]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_clear_screen(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_clear_screen(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
term_clear_screen(el); /* clear the whole real screen */
|
||||
terminal_clear_screen(el); /* clear the whole real screen */
|
||||
re_clear_display(el); /* reset everything */
|
||||
return (CC_REFRESH);
|
||||
return CC_REFRESH;
|
||||
}
|
||||
|
||||
|
||||
@@ -596,13 +511,13 @@ ed_clear_screen(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Redisplay everything
|
||||
* ^R
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_redisplay(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_REDISPLAY);
|
||||
return CC_REDISPLAY;
|
||||
}
|
||||
|
||||
|
||||
@@ -610,13 +525,13 @@ ed_redisplay(EditLine *el __attribute__((__unused__)),
|
||||
* Erase current line and start from scratch
|
||||
* [^G]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_start_over(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_start_over(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
ch_reset(el, 0);
|
||||
return (CC_REFRESH);
|
||||
ch_reset(el);
|
||||
return CC_REFRESH;
|
||||
}
|
||||
|
||||
|
||||
@@ -624,13 +539,13 @@ ed_start_over(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* First character in a bound sequence
|
||||
* Placeholder for external keys
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
|
||||
Int c __attribute__((__unused__)))
|
||||
wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
return CC_NORM;
|
||||
}
|
||||
|
||||
|
||||
@@ -638,9 +553,9 @@ ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
|
||||
* Move to the previous history line
|
||||
* [^P] [k]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
char beep = 0;
|
||||
int sv_event = el->el_history.eventno;
|
||||
@@ -650,7 +565,7 @@ ed_prev_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
|
||||
if (el->el_history.eventno == 0) { /* save the current buffer
|
||||
* away */
|
||||
(void) Strncpy(el->el_history.buf, el->el_line.buffer,
|
||||
(void) wcsncpy(el->el_history.buf, el->el_line.buffer,
|
||||
EL_BUFSIZ);
|
||||
el->el_history.last = el->el_history.buf +
|
||||
(el->el_line.lastchar - el->el_line.buffer);
|
||||
@@ -660,7 +575,6 @@ ed_prev_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
if (hist_get(el) == CC_ERROR) {
|
||||
if (el->el_map.type == MAP_VI) {
|
||||
el->el_history.eventno = sv_event;
|
||||
|
||||
}
|
||||
beep = 1;
|
||||
/* el->el_history.eventno was fixed by first call */
|
||||
@@ -676,9 +590,9 @@ ed_prev_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Move to the next history line
|
||||
* [^N] [j]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_next_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_next_history(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
el_action_t beep = CC_REFRESH, rval;
|
||||
|
||||
@@ -703,13 +617,13 @@ ed_next_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Search previous in history for a line matching the current
|
||||
* next search history [M-P] [K]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_search_prev_history(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
const Char *hp;
|
||||
const wchar_t *hp;
|
||||
int h;
|
||||
bool_t found = 0;
|
||||
int found = 0;
|
||||
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
el->el_chared.c_undo.len = -1;
|
||||
@@ -720,20 +634,20 @@ ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
"e_prev_search_hist(): eventno < 0;\n");
|
||||
#endif
|
||||
el->el_history.eventno = 0;
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
}
|
||||
if (el->el_history.eventno == 0) {
|
||||
(void) Strncpy(el->el_history.buf, el->el_line.buffer,
|
||||
(void) wcsncpy(el->el_history.buf, el->el_line.buffer,
|
||||
EL_BUFSIZ);
|
||||
el->el_history.last = el->el_history.buf +
|
||||
(el->el_line.lastchar - el->el_line.buffer);
|
||||
}
|
||||
if (el->el_history.ref == NULL)
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
|
||||
hp = HIST_FIRST(el);
|
||||
if (hp == NULL)
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
|
||||
c_setpat(el); /* Set search pattern !! */
|
||||
|
||||
@@ -744,11 +658,11 @@ ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
|
||||
#endif
|
||||
if ((Strncmp(hp, el->el_line.buffer, (size_t)
|
||||
if ((wcsncmp(hp, el->el_line.buffer, (size_t)
|
||||
(el->el_line.lastchar - el->el_line.buffer)) ||
|
||||
hp[el->el_line.lastchar - el->el_line.buffer]) &&
|
||||
c_hmatch(el, hp)) {
|
||||
found++;
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
h++;
|
||||
@@ -759,11 +673,11 @@ ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "not found\n");
|
||||
#endif
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
}
|
||||
el->el_history.eventno = h;
|
||||
|
||||
return (hist_get(el));
|
||||
return hist_get(el);
|
||||
}
|
||||
|
||||
|
||||
@@ -771,27 +685,27 @@ ed_search_prev_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Search next in history for a line matching the current
|
||||
* [M-N] [J]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_search_next_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_search_next_history(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
const Char *hp;
|
||||
const wchar_t *hp;
|
||||
int h;
|
||||
bool_t found = 0;
|
||||
int found = 0;
|
||||
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
el->el_chared.c_undo.len = -1;
|
||||
*el->el_line.lastchar = '\0'; /* just in case */
|
||||
|
||||
if (el->el_history.eventno == 0)
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
|
||||
if (el->el_history.ref == NULL)
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
|
||||
hp = HIST_FIRST(el);
|
||||
if (hp == NULL)
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
|
||||
c_setpat(el); /* Set search pattern !! */
|
||||
|
||||
@@ -799,7 +713,7 @@ ed_search_next_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
|
||||
#endif
|
||||
if ((Strncmp(hp, el->el_line.buffer, (size_t)
|
||||
if ((wcsncmp(hp, el->el_line.buffer, (size_t)
|
||||
(el->el_line.lastchar - el->el_line.buffer)) ||
|
||||
hp[el->el_line.lastchar - el->el_line.buffer]) &&
|
||||
c_hmatch(el, hp))
|
||||
@@ -812,12 +726,12 @@ ed_search_next_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "not found\n");
|
||||
#endif
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
}
|
||||
}
|
||||
el->el_history.eventno = found;
|
||||
|
||||
return (hist_get(el));
|
||||
return hist_get(el);
|
||||
}
|
||||
|
||||
|
||||
@@ -825,11 +739,11 @@ ed_search_next_history(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Move up one line
|
||||
* Could be [k] [^p]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_prev_line(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *ptr;
|
||||
wchar_t *ptr;
|
||||
int nchars = c_hpos(el);
|
||||
|
||||
/*
|
||||
@@ -843,7 +757,7 @@ ed_prev_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
break;
|
||||
|
||||
if (el->el_state.argument > 0)
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
|
||||
/*
|
||||
* Move to the beginning of the line
|
||||
@@ -860,7 +774,7 @@ ed_prev_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
continue;
|
||||
|
||||
el->el_line.cursor = ptr;
|
||||
return (CC_CURSOR);
|
||||
return CC_CURSOR;
|
||||
}
|
||||
|
||||
|
||||
@@ -868,11 +782,11 @@ ed_prev_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Move down one line
|
||||
* Could be [j] [^n]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_next_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_next_line(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char *ptr;
|
||||
wchar_t *ptr;
|
||||
int nchars = c_hpos(el);
|
||||
|
||||
/*
|
||||
@@ -883,7 +797,7 @@ ed_next_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
break;
|
||||
|
||||
if (el->el_state.argument > 0)
|
||||
return (CC_ERROR);
|
||||
return CC_ERROR;
|
||||
|
||||
/*
|
||||
* Move to the character requested
|
||||
@@ -894,7 +808,7 @@ ed_next_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
continue;
|
||||
|
||||
el->el_line.cursor = ptr;
|
||||
return (CC_CURSOR);
|
||||
return CC_CURSOR;
|
||||
}
|
||||
|
||||
|
||||
@@ -902,18 +816,18 @@ ed_next_line(EditLine *el, Int c __attribute__((__unused__)))
|
||||
* Editline extended command
|
||||
* [M-X] [:]
|
||||
*/
|
||||
protected el_action_t
|
||||
libedit_private el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_command(EditLine *el, Int c __attribute__((__unused__)))
|
||||
ed_command(EditLine *el, wint_t c __attribute__((__unused__)))
|
||||
{
|
||||
Char tmpbuf[EL_BUFSIZ];
|
||||
wchar_t tmpbuf[EL_BUFSIZ];
|
||||
int tmplen;
|
||||
|
||||
tmplen = c_gets(el, tmpbuf, STR("\n: "));
|
||||
term__putc(el, '\n');
|
||||
tmplen = c_gets(el, tmpbuf, L"\n: ");
|
||||
terminal__putc(el, '\n');
|
||||
|
||||
if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1)
|
||||
term_beep(el);
|
||||
terminal_beep(el);
|
||||
|
||||
el->el_map.current = el->el_map.key;
|
||||
re_clear_display(el);
|
||||
|
Reference in New Issue
Block a user