[asterisk-commits] tilghman: branch tilghman/libedit2 r50211 - in
/team/tilghman/libedit2/main/e...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Jan 9 12:01:14 MST 2007
Author: tilghman
Date: Tue Jan 9 13:01:12 2007
New Revision: 50211
URL: http://svn.digium.com/view/asterisk?view=rev&rev=50211
Log:
Add libedit2 files
Added:
team/tilghman/libedit2/main/editline/common.h (with props)
team/tilghman/libedit2/main/editline/config.h (with props)
team/tilghman/libedit2/main/editline/emacs.h (with props)
team/tilghman/libedit2/main/editline/fcns.h (with props)
team/tilghman/libedit2/main/editline/filecomplete.h (with props)
team/tilghman/libedit2/main/editline/help.h (with props)
team/tilghman/libedit2/main/editline/vi.h (with props)
Removed:
team/tilghman/libedit2/main/editline/CHANGES
team/tilghman/libedit2/main/editline/README
team/tilghman/libedit2/main/editline/TEST/
Modified:
team/tilghman/libedit2/main/editline/chared.c
team/tilghman/libedit2/main/editline/chared.h
team/tilghman/libedit2/main/editline/common.c
team/tilghman/libedit2/main/editline/configure
team/tilghman/libedit2/main/editline/configure.in
team/tilghman/libedit2/main/editline/editline.3
team/tilghman/libedit2/main/editline/editrc.5
team/tilghman/libedit2/main/editline/el.c
team/tilghman/libedit2/main/editline/el.h
team/tilghman/libedit2/main/editline/emacs.c
team/tilghman/libedit2/main/editline/hist.c
team/tilghman/libedit2/main/editline/hist.h
team/tilghman/libedit2/main/editline/histedit.h
team/tilghman/libedit2/main/editline/history.c
team/tilghman/libedit2/main/editline/key.c
team/tilghman/libedit2/main/editline/key.h
team/tilghman/libedit2/main/editline/makelist
team/tilghman/libedit2/main/editline/map.c
team/tilghman/libedit2/main/editline/map.h
team/tilghman/libedit2/main/editline/parse.c
team/tilghman/libedit2/main/editline/parse.h
team/tilghman/libedit2/main/editline/prompt.c
team/tilghman/libedit2/main/editline/prompt.h
team/tilghman/libedit2/main/editline/read.c
team/tilghman/libedit2/main/editline/read.h
team/tilghman/libedit2/main/editline/readline.c
team/tilghman/libedit2/main/editline/readline/readline.h
team/tilghman/libedit2/main/editline/refresh.c
team/tilghman/libedit2/main/editline/refresh.h
team/tilghman/libedit2/main/editline/search.c
team/tilghman/libedit2/main/editline/search.h
team/tilghman/libedit2/main/editline/sig.c
team/tilghman/libedit2/main/editline/sig.h
team/tilghman/libedit2/main/editline/sys.h
team/tilghman/libedit2/main/editline/term.c
team/tilghman/libedit2/main/editline/term.h
team/tilghman/libedit2/main/editline/tokenizer.c
team/tilghman/libedit2/main/editline/tty.c
team/tilghman/libedit2/main/editline/tty.h
team/tilghman/libedit2/main/editline/vi.c
Modified: team/tilghman/libedit2/main/editline/chared.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/libedit2/main/editline/chared.c?view=diff&rev=50211&r1=50210&r2=50211
==============================================================================
--- team/tilghman/libedit2/main/editline/chared.c (original)
+++ team/tilghman/libedit2/main/editline/chared.c Tue Jan 9 13:01:12 2007
@@ -1,4 +1,4 @@
-/* $NetBSD: chared.c,v 1.15 2002/03/18 16:00:50 christos Exp $ */
+/* $NetBSD: chared.c,v 1.22 2004/08/13 12:10:38 mycroft Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +15,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -41,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: chared.c,v 1.15 2002/03/18 16:00:50 christos Exp $");
+__RCSID("$NetBSD: chared.c,v 1.22 2004/08/13 12:10:38 mycroft Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -58,17 +54,36 @@
* Handle state for the vi undo command
*/
protected void
-cv_undo(EditLine *el,int action, size_t size, char *ptr)
+cv_undo(EditLine *el)
{
c_undo_t *vu = &el->el_chared.c_undo;
- vu->action = action;
- vu->ptr = ptr;
- vu->isize = size;
- (void) memcpy(vu->buf, vu->ptr, size);
-#ifdef DEBUG_UNDO
- (void) fprintf(el->el_errfile, "Undo buffer \"%s\" size = +%d -%d\n",
- vu->ptr, vu->isize, vu->dsize);
-#endif
+ c_redo_t *r = &el->el_chared.c_redo;
+ uint size;
+
+ /* Save entire line for undo */
+ size = el->el_line.lastchar - el->el_line.buffer;
+ vu->len = size;
+ vu->cursor = el->el_line.cursor - el->el_line.buffer;
+ memcpy(vu->buf, el->el_line.buffer, size);
+
+ /* save command info for redo */
+ r->count = el->el_state.doingarg ? el->el_state.argument : 0;
+ r->action = el->el_chared.c_vcmd.action;
+ r->pos = r->buf;
+ r->cmd = el->el_state.thiscmd;
+ r->ch = el->el_state.thisch;
+}
+
+/* cv_yank():
+ * Save yank/delete data for paste
+ */
+protected void
+cv_yank(EditLine *el, const char *ptr, int size)
+{
+ c_kill_t *k = &el->el_chared.c_kill;
+
+ memcpy(k->buf, ptr, size +0u);
+ k->last = k->buf + size;
}
@@ -80,8 +95,10 @@
{
char *cp;
- if (el->el_line.lastchar + num >= el->el_line.limit)
- return; /* can't go past end of buffer */
+ if (el->el_line.lastchar + num >= el->el_line.limit) {
+ if (!ch_enlargebufs(el, num +0u))
+ return; /* can't go past end of buffer */
+ }
if (el->el_line.cursor < el->el_line.lastchar) {
/* if I must move chars */
@@ -102,12 +119,14 @@
if (el->el_line.cursor + num > el->el_line.lastchar)
num = el->el_line.lastchar - el->el_line.cursor;
+ if (el->el_map.current != el->el_map.emacs) {
+ cv_undo(el);
+ cv_yank(el, el->el_line.cursor, num);
+ }
+
if (num > 0) {
char *cp;
- if (el->el_map.current != el->el_map.emacs)
- cv_undo(el, INSERT, (size_t)num, el->el_line.cursor);
-
for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
*cp = cp[num];
@@ -116,6 +135,21 @@
}
+/* c_delafter1():
+ * Delete the character after the cursor, do not yank
+ */
+protected void
+c_delafter1(EditLine *el)
+{
+ char *cp;
+
+ for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
+ *cp = cp[1];
+
+ el->el_line.lastchar--;
+}
+
+
/* c_delbefore():
* Delete num characters before the cursor
*/
@@ -126,12 +160,13 @@
if (el->el_line.cursor - num < el->el_line.buffer)
num = el->el_line.cursor - el->el_line.buffer;
+ if (el->el_map.current != el->el_map.emacs) {
+ cv_undo(el);
+ cv_yank(el, el->el_line.cursor - num, num);
+ }
+
if (num > 0) {
char *cp;
-
- if (el->el_map.current != el->el_map.emacs)
- cv_undo(el, INSERT, (size_t)num,
- el->el_line.cursor - num);
for (cp = el->el_line.cursor - num;
cp <= el->el_line.lastchar;
@@ -143,13 +178,28 @@
}
+/* c_delbefore1():
+ * Delete the character before the cursor, do not yank
+ */
+protected void
+c_delbefore1(EditLine *el)
+{
+ char *cp;
+
+ for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++)
+ *cp = cp[1];
+
+ el->el_line.lastchar--;
+}
+
+
/* ce__isword():
* Return if p is part of a word according to emacs
*/
protected int
ce__isword(int p)
{
- return (isalpha(p) || isdigit(p) || strchr("*?_-.[]~=", p) != NULL);
+ return (isalnum(p) || strchr("*?_-.[]~=", p) != NULL);
}
@@ -158,6 +208,20 @@
*/
protected int
cv__isword(int p)
+{
+ if (isalnum(p) || p == '_')
+ return 1;
+ if (isgraph(p))
+ return 2;
+ return 0;
+}
+
+
+/* cv__isWord():
+ * Return if p is part of a big word according to vi
+ */
+protected int
+cv__isWord(int p)
{
return (!isspace(p));
}
@@ -221,7 +285,7 @@
* vi historically deletes with cw only the word preserving the
* trailing whitespace! This is not what 'w' does..
*/
- if (el->el_chared.c_vcmd.action != (DELETE|INSERT))
+ if (n || el->el_chared.c_vcmd.action != (DELETE|INSERT))
while ((p < high) && isspace((unsigned char) *p))
p++;
}
@@ -238,26 +302,19 @@
* Find the previous word vi style
*/
protected char *
-cv_prev_word(EditLine *el, char *p, char *low, int n, int (*wtest)(int))
+cv_prev_word(char *p, char *low, int n, int (*wtest)(int))
{
int test;
+ p--;
while (n--) {
- p--;
- /*
- * vi historically deletes with cb only the word preserving the
- * leading whitespace! This is not what 'b' does..
- */
- if (el->el_chared.c_vcmd.action != (DELETE|INSERT))
- while ((p > low) && isspace((unsigned char) *p))
- p--;
+ while ((p > low) && isspace((unsigned char) *p))
+ p--;
test = (*wtest)((unsigned char) *p);
while ((p >= low) && (*wtest)((unsigned char) *p) == test)
p--;
- p++;
- while (isspace((unsigned char) *p))
- p++;
- }
+ }
+ p++;
/* p now points where we want it */
if (p < low)
@@ -308,47 +365,34 @@
cv_delfini(EditLine *el)
{
int size;
- int oaction;
-
- if (el->el_chared.c_vcmd.action & INSERT)
+ int action = el->el_chared.c_vcmd.action;
+
+ if (action & INSERT)
el->el_map.current = el->el_map.key;
- oaction = el->el_chared.c_vcmd.action;
+ if (el->el_chared.c_vcmd.pos == 0)
+ /* sanity */
+ return;
+
+ size = el->el_line.cursor - el->el_chared.c_vcmd.pos;
+ if (size == 0)
+ size = 1;
+ el->el_line.cursor = el->el_chared.c_vcmd.pos;
+ if (action & YANK) {
+ if (size > 0)
+ cv_yank(el, el->el_line.cursor, size);
+ else
+ cv_yank(el, el->el_line.cursor + size, -size);
+ } else {
+ if (size > 0) {
+ c_delafter(el, size);
+ re_refresh_cursor(el);
+ } else {
+ c_delbefore(el, -size);
+ el->el_line.cursor += size;
+ }
+ }
el->el_chared.c_vcmd.action = NOP;
-
- if (el->el_chared.c_vcmd.pos == 0)
- return;
-
-
- if (el->el_line.cursor > el->el_chared.c_vcmd.pos) {
- size = (int) (el->el_line.cursor - el->el_chared.c_vcmd.pos);
- c_delbefore(el, size);
- el->el_line.cursor = el->el_chared.c_vcmd.pos;
- re_refresh_cursor(el);
- } else if (el->el_line.cursor < el->el_chared.c_vcmd.pos) {
- size = (int)(el->el_chared.c_vcmd.pos - el->el_line.cursor);
- c_delafter(el, size);
- } else {
- size = 1;
- c_delafter(el, size);
- }
- switch (oaction) {
- case DELETE|INSERT:
- el->el_chared.c_undo.action = DELETE|INSERT;
- break;
- case DELETE:
- el->el_chared.c_undo.action = INSERT;
- break;
- case NOP:
- case INSERT:
- default:
- EL_ABORT((el->el_errfile, "Bad oaction %d\n", oaction));
- break;
- }
-
-
- el->el_chared.c_undo.ptr = el->el_line.cursor;
- el->el_chared.c_undo.dsize = size;
}
@@ -378,21 +422,19 @@
* Go to the end of this word according to vi
*/
protected char *
-cv__endword(char *p, char *high, int n)
-{
+cv__endword(char *p, char *high, int n, int (*wtest)(int))
+{
+ int test;
+
p++;
while (n--) {
while ((p < high) && isspace((unsigned char) *p))
p++;
- if (isalnum((unsigned char) *p))
- while ((p < high) && isalnum((unsigned char) *p))
- p++;
- else
- while ((p < high) && !(isspace((unsigned char) *p) ||
- isalnum((unsigned char) *p)))
- p++;
+ test = (*wtest)((unsigned char) *p);
+ while ((p < high) && (*wtest)((unsigned char) *p) == test)
+ p++;
}
p--;
return (p);
@@ -411,20 +453,23 @@
(void) memset(el->el_line.buffer, 0, EL_BUFSIZ);
el->el_line.cursor = el->el_line.buffer;
el->el_line.lastchar = el->el_line.buffer;
- el->el_line.limit = &el->el_line.buffer[EL_BUFSIZ - 2];
+ el->el_line.limit = &el->el_line.buffer[EL_BUFSIZ - EL_LEAVE];
el->el_chared.c_undo.buf = (char *) el_malloc(EL_BUFSIZ);
if (el->el_chared.c_undo.buf == NULL)
return (-1);
(void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ);
- el->el_chared.c_undo.action = NOP;
- el->el_chared.c_undo.isize = 0;
- el->el_chared.c_undo.dsize = 0;
- el->el_chared.c_undo.ptr = el->el_line.buffer;
+ el->el_chared.c_undo.len = -1;
+ el->el_chared.c_undo.cursor = 0;
+ el->el_chared.c_redo.buf = (char *) el_malloc(EL_BUFSIZ);
+ if (el->el_chared.c_redo.buf == NULL)
+ return (-1);
+ el->el_chared.c_redo.pos = el->el_chared.c_redo.buf;
+ el->el_chared.c_redo.lim = el->el_chared.c_redo.buf + EL_BUFSIZ;
+ el->el_chared.c_redo.cmd = ED_UNASSIGNED;
el->el_chared.c_vcmd.action = NOP;
el->el_chared.c_vcmd.pos = el->el_line.buffer;
- el->el_chared.c_vcmd.ins = el->el_line.buffer;
el->el_chared.c_kill.buf = (char *) el_malloc(EL_BUFSIZ);
if (el->el_chared.c_kill.buf == NULL)
@@ -441,8 +486,8 @@
el->el_state.argument = 1;
el->el_state.lastcmd = ED_UNASSIGNED;
- el->el_chared.c_macro.nline = NULL;
el->el_chared.c_macro.level = -1;
+ el->el_chared.c_macro.offset = 0;
el->el_chared.c_macro.macro = (char **) el_malloc(EL_MAXMACRO *
sizeof(char *));
if (el->el_chared.c_macro.macro == NULL)
@@ -459,14 +504,11 @@
el->el_line.cursor = el->el_line.buffer;
el->el_line.lastchar = el->el_line.buffer;
- el->el_chared.c_undo.action = NOP;
- el->el_chared.c_undo.isize = 0;
- el->el_chared.c_undo.dsize = 0;
- el->el_chared.c_undo.ptr = el->el_line.buffer;
+ el->el_chared.c_undo.len = -1;
+ el->el_chared.c_undo.cursor = 0;
el->el_chared.c_vcmd.action = NOP;
el->el_chared.c_vcmd.pos = el->el_line.buffer;
- el->el_chared.c_vcmd.ins = el->el_line.buffer;
el->el_chared.c_kill.mark = el->el_line.buffer;
@@ -521,7 +563,8 @@
el->el_line.buffer = newbuffer;
el->el_line.cursor = newbuffer + (el->el_line.cursor - oldbuf);
el->el_line.lastchar = newbuffer + (el->el_line.lastchar - oldbuf);
- el->el_line.limit = &newbuffer[newsz - EL_LEAVE];
+ /* don't set new size until all buffers are enlarged */
+ el->el_line.limit = &newbuffer[sz - EL_LEAVE];
/*
* Reallocate kill buffer.
@@ -550,14 +593,22 @@
/* zero the newly added memory, leave old data in */
(void) memset(&newbuffer[sz], 0, newsz - sz);
-
- el->el_chared.c_undo.ptr = el->el_line.buffer +
- (el->el_chared.c_undo.ptr - oldbuf);
el->el_chared.c_undo.buf = newbuffer;
+
+ newbuffer = el_realloc(el->el_chared.c_redo.buf, newsz);
+ if (!newbuffer)
+ return 0;
+ el->el_chared.c_redo.pos = newbuffer +
+ (el->el_chared.c_redo.pos - el->el_chared.c_redo.buf);
+ el->el_chared.c_redo.lim = newbuffer +
+ (el->el_chared.c_redo.lim - el->el_chared.c_redo.buf);
+ el->el_chared.c_redo.buf = newbuffer;
if (!hist_enlargebuf(el, sz, newsz))
return 0;
+ /* Safe to set enlarged buffer size */
+ el->el_line.limit = &el->el_line.buffer[newsz - EL_LEAVE];
return 1;
}
@@ -572,6 +623,11 @@
el->el_line.limit = NULL;
el_free((ptr_t) el->el_chared.c_undo.buf);
el->el_chared.c_undo.buf = NULL;
+ el_free((ptr_t) el->el_chared.c_redo.buf);
+ el->el_chared.c_redo.buf = NULL;
+ el->el_chared.c_redo.pos = NULL;
+ el->el_chared.c_redo.lim = NULL;
+ el->el_chared.c_redo.cmd = ED_UNASSIGNED;
el_free((ptr_t) el->el_chared.c_kill.buf);
el->el_chared.c_kill.buf = NULL;
el_free((ptr_t) el->el_chared.c_macro.macro);
@@ -624,51 +680,64 @@
* Get a string
*/
protected int
-c_gets(EditLine *el, char *buf)
+c_gets(EditLine *el, char *buf, const char *prompt)
{
char ch;
- int len = 0;
-
- for (ch = 0; ch == 0;) {
- if (el_getc(el, &ch) != 1)
- return (ed_end_of_file(el, 0));
+ int len;
+ char *cp = el->el_line.buffer;
+
+ if (prompt) {
+ len = strlen(prompt);
+ memcpy(cp, prompt, len + 0u);
+ cp += len;
+ }
+ len = 0;
+
+ for (;;) {
+ el->el_line.cursor = cp;
+ *cp = ' ';
+ el->el_line.lastchar = cp + 1;
+ re_refresh(el);
+
+ if (el_getc(el, &ch) != 1) {
+ ed_end_of_file(el, 0);
+ len = -1;
+ break;
+ }
+
switch (ch) {
+
case 0010: /* Delete and backspace */
case 0177:
- if (len > 1) {
- *el->el_line.cursor-- = '\0';
- el->el_line.lastchar = el->el_line.cursor;
- buf[len--] = '\0';
- } else {
- el->el_line.buffer[0] = '\0';
- el->el_line.lastchar = el->el_line.buffer;
- el->el_line.cursor = el->el_line.buffer;
- return (CC_REFRESH);
+ if (len <= 0) {
+ len = -1;
+ break;
}
- re_refresh(el);
- ch = 0;
- break;
+ cp--;
+ continue;
case 0033: /* ESC */
case '\r': /* Newline */
case '\n':
+ buf[len] = ch;
break;
default:
- if (len >= EL_BUFSIZ)
+ if (len >= EL_BUFSIZ - 16)
term_beep(el);
else {
buf[len++] = ch;
- *el->el_line.cursor++ = ch;
- el->el_line.lastchar = el->el_line.cursor;
+ *cp++ = ch;
}
- re_refresh(el);
- ch = 0;
- break;
+ continue;
}
- }
- buf[len] = ch;
- return (len);
+ break;
+ }
+
+ el->el_line.buffer[0] = '\0';
+ el->el_line.lastchar = el->el_line.buffer;
+ el->el_line.cursor = el->el_line.buffer;
+ return len;
}
Modified: team/tilghman/libedit2/main/editline/chared.h
URL: http://svn.digium.com/view/asterisk/team/tilghman/libedit2/main/editline/chared.h?view=diff&rev=50211&r1=50210&r2=50211
==============================================================================
--- team/tilghman/libedit2/main/editline/chared.h (original)
+++ team/tilghman/libedit2/main/editline/chared.h Tue Jan 9 13:01:12 2007
@@ -1,4 +1,4 @@
-/* $NetBSD: chared.h,v 1.8 2002/03/18 16:00:51 christos Exp $ */
+/* $NetBSD: chared.h,v 1.14 2004/08/13 12:10:39 mycroft Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +15,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -66,20 +62,29 @@
typedef struct c_macro_t {
int level;
+ int offset;
char **macro;
- char *nline;
} c_macro_t;
/*
- * Undo information for both vi and emacs
+ * Undo information for vi - no undo in emacs (yet)
*/
typedef struct c_undo_t {
- int action;
- size_t isize;
- size_t dsize;
- char *ptr;
- char *buf;
+ int len; /* length of saved line */
+ int cursor; /* position of saved cursor */
+ char *buf; /* full saved text */
} c_undo_t;
+
+/* redo for vi */
+typedef struct c_redo_t {
+ char *buf; /* redo insert key sequence */
+ char *pos;
+ char *lim;
+ el_action_t cmd; /* command to redo */
+ char ch; /* char that invoked it */
+ int count;
+ int action; /* from cv_action() */
+} c_redo_t;
/*
* Current action information for vi
@@ -87,7 +92,6 @@
typedef struct c_vcmd_t {
int action;
char *pos;
- char *ins;
} c_vcmd_t;
/*
@@ -106,6 +110,7 @@
typedef struct el_chared_t {
c_undo_t c_undo;
c_kill_t c_kill;
+ c_redo_t c_redo;
c_vcmd_t c_vcmd;
c_macro_t c_macro;
} el_chared_t;
@@ -120,10 +125,10 @@
#define NOP 0x00
#define DELETE 0x01
#define INSERT 0x02
-#define CHANGE 0x04
+#define YANK 0x04
-#define CHAR_FWD 0
-#define CHAR_BACK 1
+#define CHAR_FWD (+1)
+#define CHAR_BACK (-1)
#define MODE_INSERT 0
#define MODE_REPLACE 1
@@ -137,18 +142,22 @@
protected int cv__isword(int);
+protected int cv__isWord(int);
protected void cv_delfini(EditLine *);
-protected char *cv__endword(char *, char *, int);
+protected char *cv__endword(char *, char *, int, int (*)(int));
protected int ce__isword(int);
-protected void cv_undo(EditLine *, int, size_t, char *);
+protected void cv_undo(EditLine *);
+protected void cv_yank(EditLine *, const char *, int);
protected char *cv_next_word(EditLine*, char *, char *, int, int (*)(int));
-protected char *cv_prev_word(EditLine*, char *, char *, int, int (*)(int));
+protected char *cv_prev_word(char *, char *, int, int (*)(int));
protected char *c__next_word(char *, char *, int, int (*)(int));
protected char *c__prev_word(char *, char *, int, int (*)(int));
protected void c_insert(EditLine *, int);
protected void c_delbefore(EditLine *, int);
+protected void c_delbefore1(EditLine *);
protected void c_delafter(EditLine *, int);
-protected int c_gets(EditLine *, char *);
+protected void c_delafter1(EditLine *);
+protected int c_gets(EditLine *, char *, const char *);
protected int c_hpos(EditLine *);
protected int ch_init(EditLine *);
Modified: team/tilghman/libedit2/main/editline/common.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/libedit2/main/editline/common.c?view=diff&rev=50211&r1=50210&r2=50211
==============================================================================
--- team/tilghman/libedit2/main/editline/common.c (original)
+++ team/tilghman/libedit2/main/editline/common.c Tue Jan 9 13:01:12 2007
@@ -1,4 +1,4 @@
-/* $NetBSD: common.c,v 1.11 2002/03/18 16:00:51 christos Exp $ */
+/* $NetBSD: common.c,v 1.16 2003/08/07 16:44:30 agc Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -15,11 +15,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -41,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: common.c,v 1.11 2002/03/18 16:00:51 christos Exp $");
+__RCSID("$NetBSD: common.c,v 1.16 2003/08/07 16:44:30 agc Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -56,7 +52,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_end_of_file(EditLine *el, int c)
+ed_end_of_file(EditLine *el, int c __attribute__((__unused__)))
{
re_goto_bottom(el);
@@ -72,7 +68,7 @@
protected el_action_t
ed_insert(EditLine *el, int c)
{
- int i;
+ int count = el->el_state.argument;
if (c == '\0')
return (CC_ERROR);
@@ -80,42 +76,28 @@
if (el->el_line.lastchar + el->el_state.argument >=
el->el_line.limit) {
/* end of buffer space, try to allocate more */
- if (!ch_enlargebufs(el, (size_t) el->el_state.argument))
+ if (!ch_enlargebufs(el, (size_t) count))
return CC_ERROR; /* error allocating more */
}
- if (el->el_state.argument == 1) {
- if (el->el_state.inputmode != MODE_INSERT) {
- el->el_chared.c_undo.buf[el->el_chared.c_undo.isize++] =
- *el->el_line.cursor;
- el->el_chared.c_undo.buf[el->el_chared.c_undo.isize] =
- '\0';
- c_delafter(el, 1);
- }
- c_insert(el, 1);
+ if (count == 1) {
+ if (el->el_state.inputmode == MODE_INSERT
+ || el->el_line.cursor >= el->el_line.lastchar)
+ c_insert(el, 1);
*el->el_line.cursor++ = c;
- el->el_state.doingarg = 0; /* just in case */
re_fastaddc(el); /* fast refresh for one char. */
} else {
- if (el->el_state.inputmode != MODE_INSERT) {
- for (i = 0; i < el->el_state.argument; i++)
- el->el_chared.c_undo.buf[el->el_chared.c_undo.isize++] =
- el->el_line.cursor[i];
-
- el->el_chared.c_undo.buf[el->el_chared.c_undo.isize] =
- '\0';
- c_delafter(el, el->el_state.argument);
- }
- c_insert(el, el->el_state.argument);
-
- while (el->el_state.argument--)
+ if (el->el_state.inputmode != MODE_REPLACE_1)
+ c_insert(el, el->el_state.argument);
+
+ while (count-- && el->el_line.cursor < el->el_line.lastchar)
*el->el_line.cursor++ = c;
re_refresh(el);
}
if (el->el_state.inputmode == MODE_REPLACE_1)
- (void) vi_command_mode(el, 0);
+ return vi_command_mode(el, 0);
return (CC_NORM);
}
@@ -127,7 +109,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_delete_prev_word(EditLine *el, int c)
+ed_delete_prev_word(EditLine *el, int c __attribute__((__unused__)))
{
char *cp, *p, *kp;
@@ -155,7 +137,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_delete_next_char(EditLine *el, int c)
+ed_delete_next_char(EditLine *el, int c __attribute__((__unused__)))
{
#ifdef notdef /* XXX */
#define EL el->el_line
@@ -206,7 +188,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_kill_line(EditLine *el, int c)
+ed_kill_line(EditLine *el, int c __attribute__((__unused__)))
{
char *kp, *cp;
@@ -227,7 +209,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_move_to_end(EditLine *el, int c)
+ed_move_to_end(EditLine *el, int c __attribute__((__unused__)))
{
el->el_line.cursor = el->el_line.lastchar;
@@ -235,7 +217,7 @@
#ifdef VI_MOVE
el->el_line.cursor--;
#endif
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
@@ -250,7 +232,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_move_to_beg(EditLine *el, int c)
+ed_move_to_beg(EditLine *el, int c __attribute__((__unused__)))
{
el->el_line.cursor = el->el_line.buffer;
@@ -259,7 +241,7 @@
/* We want FIRST non space character */
while (isspace((unsigned char) *el->el_line.cursor))
el->el_line.cursor++;
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
@@ -299,18 +281,22 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_next_char(EditLine *el, int c)
-{
-
- if (el->el_line.cursor >= el->el_line.lastchar)
+ed_next_char(EditLine *el, int c __attribute__((__unused__)))
+{
+ char *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);
el->el_line.cursor += el->el_state.argument;
- if (el->el_line.cursor > el->el_line.lastchar)
- el->el_line.cursor = el->el_line.lastchar;
+ if (el->el_line.cursor > lim)
+ el->el_line.cursor = lim;
if (el->el_map.type == MAP_VI)
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
@@ -324,7 +310,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_word(EditLine *el, int c)
+ed_prev_word(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_line.cursor == el->el_line.buffer)
@@ -336,7 +322,7 @@
ce__isword);
if (el->el_map.type == MAP_VI)
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
@@ -350,7 +336,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_char(EditLine *el, int c)
+ed_prev_char(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_line.cursor > el->el_line.buffer) {
@@ -359,7 +345,7 @@
el->el_line.cursor = el->el_line.buffer;
if (el->el_map.type == MAP_VI)
- if (el->el_chared.c_vcmd.action & DELETE) {
+ if (el->el_chared.c_vcmd.action != NOP) {
cv_delfini(el);
return (CC_REFRESH);
}
@@ -411,25 +397,9 @@
(el->el_state.argument * 10) + (c - '0');
}
return (CC_ARGHACK);
- } else {
- if (el->el_line.lastchar + 1 >= el->el_line.limit) {
- if (!ch_enlargebufs(el, 1))
- return (CC_ERROR);
- }
-
- if (el->el_state.inputmode != MODE_INSERT) {
- el->el_chared.c_undo.buf[el->el_chared.c_undo.isize++] =
- *el->el_line.cursor;
- el->el_chared.c_undo.buf[el->el_chared.c_undo.isize] =
- '\0';
- c_delafter(el, 1);
- }
- c_insert(el, 1);
- *el->el_line.cursor++ = c;
- el->el_state.doingarg = 0;
- re_fastaddc(el);
- }
- return (CC_NORM);
+ }
+
+ return ed_insert(el, c);
}
@@ -463,12 +433,10 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_unassigned(EditLine *el, int c)
-{
-
- term_beep(el);
- term__flush();
- return (CC_NORM);
+ed_unassigned(EditLine *el, int c __attribute__((__unused__)))
+{
+
+ return (CC_ERROR);
}
@@ -482,7 +450,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_sigint(EditLine *el, int c)
+ed_tty_sigint(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -495,7 +464,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_dsusp(EditLine *el, int c)
+ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -508,7 +478,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_flush_output(EditLine *el, int c)
+ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -521,7 +492,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_sigquit(EditLine *el, int c)
+ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -534,7 +506,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_sigtstp(EditLine *el, int c)
+ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -547,7 +520,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_stop_output(EditLine *el, int c)
+ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -560,7 +534,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_tty_start_output(EditLine *el, int c)
+ed_tty_start_output(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -573,14 +548,12 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_newline(EditLine *el, int c)
+ed_newline(EditLine *el, int c __attribute__((__unused__)))
{
re_goto_bottom(el);
*el->el_line.lastchar++ = '\n';
*el->el_line.lastchar = '\0';
- if (el->el_map.type == MAP_VI)
- el->el_chared.c_vcmd.ins = el->el_line.buffer;
return (CC_NEWLINE);
}
@@ -591,7 +564,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_delete_prev_char(EditLine *el, int c)
+ed_delete_prev_char(EditLine *el, int c __attribute__((__unused__)))
{
if (el->el_line.cursor <= el->el_line.buffer)
@@ -611,7 +584,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_clear_screen(EditLine *el, int c)
+ed_clear_screen(EditLine *el, int c __attribute__((__unused__)))
{
term_clear_screen(el); /* clear the whole real screen */
@@ -626,7 +599,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_redisplay(EditLine *el, int c)
+ed_redisplay(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_REDISPLAY);
@@ -639,7 +613,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_start_over(EditLine *el, int c)
+ed_start_over(EditLine *el, int c __attribute__((__unused__)))
{
ch_reset(el);
@@ -653,7 +627,8 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_sequence_lead_in(EditLine *el, int c)
+ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
+ int c __attribute__((__unused__)))
{
return (CC_NORM);
@@ -666,32 +641,35 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_history(EditLine *el, int c)
+ed_prev_history(EditLine *el, int c __attribute__((__unused__)))
{
char beep = 0;
-
- el->el_chared.c_undo.action = NOP;
+ int sv_event = el->el_history.eventno;
+
+ el->el_chared.c_undo.len = -1;
*el->el_line.lastchar = '\0'; /* just in case */
if (el->el_history.eventno == 0) { /* save the current buffer
* away */
(void) strncpy(el->el_history.buf, el->el_line.buffer,
- EL_BUFSIZ - 1);
+ EL_BUFSIZ);
el->el_history.last = el->el_history.buf +
(el->el_line.lastchar - el->el_line.buffer);
}
el->el_history.eventno += el->el_state.argument;
if (hist_get(el) == CC_ERROR) {
+ if (el->el_map.type == MAP_VI) {
+ el->el_history.eventno = sv_event;
+ return CC_ERROR;
+ }
beep = 1;
/* el->el_history.eventno was fixed by first call */
(void) hist_get(el);
}
- re_refresh(el);
if (beep)
- return (CC_ERROR);
- else
- return (CC_NORM); /* was CC_UP_HIST */
+ return CC_REFRESH_BEEP;
+ return CC_REFRESH;
}
@@ -701,19 +679,24 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_next_history(EditLine *el, int c)
-{
-
- el->el_chared.c_undo.action = NOP;
+ed_next_history(EditLine *el, int c __attribute__((__unused__)))
+{
+ el_action_t beep = CC_REFRESH, rval;
+
+ el->el_chared.c_undo.len = -1;
*el->el_line.lastchar = '\0'; /* just in case */
el->el_history.eventno -= el->el_state.argument;
if (el->el_history.eventno < 0) {
el->el_history.eventno = 0;
- return (CC_ERROR);/* make it beep */
- }
- return (hist_get(el));
+ beep = CC_REFRESH_BEEP;
+ }
+ rval = hist_get(el);
+ if (rval == CC_REFRESH)
+ return beep;
+ return rval;
+
}
@@ -723,14 +706,14 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_search_prev_history(EditLine *el, int c)
+ed_search_prev_history(EditLine *el, int c __attribute__((__unused__)))
{
const char *hp;
int h;
bool_t found = 0;
el->el_chared.c_vcmd.action = NOP;
- el->el_chared.c_undo.action = NOP;
+ el->el_chared.c_undo.len = -1;
*el->el_line.lastchar = '\0'; /* just in case */
if (el->el_history.eventno < 0) {
#ifdef DEBUG_EDIT
@@ -742,7 +725,7 @@
}
if (el->el_history.eventno == 0) {
(void) strncpy(el->el_history.buf, el->el_line.buffer,
- EL_BUFSIZ - 1);
+ EL_BUFSIZ);
el->el_history.last = el->el_history.buf +
(el->el_line.lastchar - el->el_line.buffer);
}
@@ -791,14 +774,14 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_search_next_history(EditLine *el, int c)
+ed_search_next_history(EditLine *el, int c __attribute__((__unused__)))
{
const char *hp;
int h;
bool_t found = 0;
el->el_chared.c_vcmd.action = NOP;
- el->el_chared.c_undo.action = NOP;
+ el->el_chared.c_undo.len = -1;
*el->el_line.lastchar = '\0'; /* just in case */
if (el->el_history.eventno == 0)
@@ -845,7 +828,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_prev_line(EditLine *el, int c)
+ed_prev_line(EditLine *el, int c __attribute__((__unused__)))
{
char *ptr;
int nchars = c_hpos(el);
@@ -888,7 +871,7 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_next_line(EditLine *el, int c)
+ed_next_line(EditLine *el, int c __attribute__((__unused__)))
{
char *ptr;
int nchars = c_hpos(el);
@@ -922,30 +905,18 @@
*/
protected el_action_t
/*ARGSUSED*/
-ed_command(EditLine *el, int c)
+ed_command(EditLine *el, int c __attribute__((__unused__)))
{
char tmpbuf[EL_BUFSIZ];
int tmplen;
- el->el_line.buffer[0] = '\0';
- el->el_line.lastchar = el->el_line.buffer;
- el->el_line.cursor = el->el_line.buffer;
-
- c_insert(el, 3); /* prompt + ": " */
- *el->el_line.cursor++ = '\n';
- *el->el_line.cursor++ = ':';
- *el->el_line.cursor++ = ' ';
- re_refresh(el);
-
- tmplen = c_gets(el, tmpbuf);
- tmpbuf[tmplen] = '\0';
-
- el->el_line.buffer[0] = '\0';
- el->el_line.lastchar = el->el_line.buffer;
- el->el_line.cursor = el->el_line.buffer;
-
- if (parse_line(el, tmpbuf) == -1)
- return (CC_ERROR);
- else
- return (CC_REFRESH);
-}
+ tmplen = c_gets(el, tmpbuf, "\n: ");
+ term__putc('\n');
+
+ if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1)
+ term_beep(el);
+
+ el->el_map.current = el->el_map.key;
+ re_clear_display(el);
+ return CC_REFRESH;
+}
Added: team/tilghman/libedit2/main/editline/common.h
URL: http://svn.digium.com/view/asterisk/team/tilghman/libedit2/main/editline/common.h?view=auto&rev=50211
==============================================================================
--- team/tilghman/libedit2/main/editline/common.h (added)
+++ team/tilghman/libedit2/main/editline/common.h Tue Jan 9 13:01:12 2007
@@ -1,0 +1,39 @@
+/* Automatically generated file, do not edit */
+#ifndef _h_common_c
+#define _h_common_c
+protected el_action_t ed_end_of_file (EditLine *, int);
+protected el_action_t ed_insert (EditLine *, int);
+protected el_action_t ed_delete_prev_word (EditLine *, int);
+protected el_action_t ed_delete_next_char (EditLine *, int);
+protected el_action_t ed_kill_line (EditLine *, int);
+protected el_action_t ed_move_to_end (EditLine *, int);
+protected el_action_t ed_move_to_beg (EditLine *, int);
+protected el_action_t ed_transpose_chars (EditLine *, int);
+protected el_action_t ed_next_char (EditLine *, int);
+protected el_action_t ed_prev_word (EditLine *, int);
+protected el_action_t ed_prev_char (EditLine *, int);
+protected el_action_t ed_quoted_insert (EditLine *, int);
+protected el_action_t ed_digit (EditLine *, int);
+protected el_action_t ed_argument_digit (EditLine *, int);
+protected el_action_t ed_unassigned (EditLine *, int);
+protected el_action_t ed_tty_sigint (EditLine *, int);
+protected el_action_t ed_tty_dsusp (EditLine *, int);
+protected el_action_t ed_tty_flush_output (EditLine *, int);
+protected el_action_t ed_tty_sigquit (EditLine *, int);
+protected el_action_t ed_tty_sigtstp (EditLine *, int);
+protected el_action_t ed_tty_stop_output (EditLine *, int);
+protected el_action_t ed_tty_start_output (EditLine *, int);
+protected el_action_t ed_newline (EditLine *, int);
+protected el_action_t ed_delete_prev_char (EditLine *, int);
+protected el_action_t ed_clear_screen (EditLine *, int);
+protected el_action_t ed_redisplay (EditLine *, int);
+protected el_action_t ed_start_over (EditLine *, int);
+protected el_action_t ed_sequence_lead_in (EditLine *, int);
+protected el_action_t ed_prev_history (EditLine *, int);
+protected el_action_t ed_next_history (EditLine *, int);
+protected el_action_t ed_search_prev_history (EditLine *, int);
+protected el_action_t ed_search_next_history (EditLine *, int);
+protected el_action_t ed_prev_line (EditLine *, int);
+protected el_action_t ed_next_line (EditLine *, int);
+protected el_action_t ed_command (EditLine *, int);
+#endif /* _h_common_c */
Propchange: team/tilghman/libedit2/main/editline/common.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/tilghman/libedit2/main/editline/common.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/tilghman/libedit2/main/editline/common.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: team/tilghman/libedit2/main/editline/config.h
URL: http://svn.digium.com/view/asterisk/team/tilghman/libedit2/main/editline/config.h?view=auto&rev=50211
==============================================================================
--- team/tilghman/libedit2/main/editline/config.h (added)
+++ team/tilghman/libedit2/main/editline/config.h Tue Jan 9 13:01:12 2007
@@ -1,0 +1,22 @@
+/* config.h. Generated automatically by configure. */
+/* #undef SUNOS */
+/* #undef CYGWIN */
+
+#define HAVE_SYS_CDEFS_H 1
+/* #undef HAVE_TERMCAP_H */
+#define HAVE_CURSES_H 1
+/* #undef HAVE_NCURSES_H */
+#define HAVE_TERM_H 1
+/* #undef HAVE_VIS_H */
+/* #undef HAVE_ISSETUGID */
+
+/* #undef HAVE_STRLCAT */
+/* #undef HAVE_STRLCPY */
+/* #undef HAVE_FGETLN */
+/* #undef HAVE_STRVIS */
+/* #undef HAVE_STRUNVIS */
+
+#include "sys.h"
+#ifdef CYGWIN
+# include "cygdef.h"
+#endif
Propchange: team/tilghman/libedit2/main/editline/config.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/tilghman/libedit2/main/editline/config.h
[... 8300 lines stripped ...]
More information about the asterisk-commits
mailing list