Home | History | Annotate | Line # | Download | only in libedit
common.c revision 1.10
      1  1.10  jdolecek /*	$NetBSD: common.c,v 1.10 2001/01/10 07:45:41 jdolecek Exp $	*/
      2   1.2     lukem 
      3   1.1       cgd /*-
      4   1.1       cgd  * Copyright (c) 1992, 1993
      5   1.1       cgd  *	The Regents of the University of California.  All rights reserved.
      6   1.1       cgd  *
      7   1.1       cgd  * This code is derived from software contributed to Berkeley by
      8   1.1       cgd  * Christos Zoulas of Cornell University.
      9   1.1       cgd  *
     10   1.1       cgd  * Redistribution and use in source and binary forms, with or without
     11   1.1       cgd  * modification, are permitted provided that the following conditions
     12   1.1       cgd  * are met:
     13   1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     14   1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     15   1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     17   1.1       cgd  *    documentation and/or other materials provided with the distribution.
     18   1.1       cgd  * 3. All advertising materials mentioning features or use of this software
     19   1.1       cgd  *    must display the following acknowledgement:
     20   1.1       cgd  *	This product includes software developed by the University of
     21   1.1       cgd  *	California, Berkeley and its contributors.
     22   1.1       cgd  * 4. Neither the name of the University nor the names of its contributors
     23   1.1       cgd  *    may be used to endorse or promote products derived from this software
     24   1.1       cgd  *    without specific prior written permission.
     25   1.1       cgd  *
     26   1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27   1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28   1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29   1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30   1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31   1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32   1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33   1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34   1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35   1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36   1.1       cgd  * SUCH DAMAGE.
     37   1.1       cgd  */
     38   1.1       cgd 
     39   1.4  christos #include <sys/cdefs.h>
     40   1.1       cgd #if !defined(lint) && !defined(SCCSID)
     41   1.2     lukem #if 0
     42   1.1       cgd static char sccsid[] = "@(#)common.c	8.1 (Berkeley) 6/4/93";
     43   1.2     lukem #else
     44  1.10  jdolecek __RCSID("$NetBSD: common.c,v 1.10 2001/01/10 07:45:41 jdolecek Exp $");
     45   1.2     lukem #endif
     46   1.1       cgd #endif /* not lint && not SCCSID */
     47   1.1       cgd 
     48   1.1       cgd /*
     49   1.1       cgd  * common.c: Common Editor functions
     50   1.1       cgd  */
     51   1.1       cgd #include "sys.h"
     52   1.1       cgd #include "el.h"
     53   1.1       cgd 
     54   1.8    simonb /* ed_end_of_file():
     55   1.1       cgd  *	Indicate end of file
     56   1.1       cgd  *	[^D]
     57   1.1       cgd  */
     58   1.1       cgd protected el_action_t
     59   1.1       cgd /*ARGSUSED*/
     60   1.9     lukem ed_end_of_file(EditLine *el, int c)
     61   1.9     lukem {
     62   1.9     lukem 
     63   1.9     lukem 	re_goto_bottom(el);
     64   1.9     lukem 	*el->el_line.lastchar = '\0';
     65   1.9     lukem 	return (CC_EOF);
     66   1.1       cgd }
     67   1.1       cgd 
     68   1.1       cgd 
     69   1.8    simonb /* ed_insert():
     70   1.1       cgd  *	Add character to the line
     71   1.1       cgd  *	Insert a character [bound to all insert keys]
     72   1.1       cgd  */
     73   1.1       cgd protected el_action_t
     74   1.9     lukem ed_insert(EditLine *el, int c)
     75   1.9     lukem {
     76   1.9     lukem 	int i;
     77   1.1       cgd 
     78   1.9     lukem 	if (c == '\0')
     79   1.9     lukem 		return (CC_ERROR);
     80   1.1       cgd 
     81   1.9     lukem 	if (el->el_line.lastchar + el->el_state.argument >=
     82  1.10  jdolecek 	    el->el_line.limit) {
     83  1.10  jdolecek 		/* end of buffer space, try to allocate more */
     84  1.10  jdolecek 		if (!ch_enlargebufs(el, (size_t) el->el_state.argument))
     85  1.10  jdolecek 			return CC_ERROR;	/* error allocating more */
     86  1.10  jdolecek 	}
     87   1.9     lukem 
     88   1.9     lukem 	if (el->el_state.argument == 1) {
     89   1.9     lukem 		if (el->el_state.inputmode != MODE_INSERT) {
     90   1.9     lukem 			el->el_chared.c_undo.buf[el->el_chared.c_undo.isize++] =
     91   1.9     lukem 			    *el->el_line.cursor;
     92   1.9     lukem 			el->el_chared.c_undo.buf[el->el_chared.c_undo.isize] =
     93   1.9     lukem 			    '\0';
     94   1.9     lukem 			c_delafter(el, 1);
     95   1.9     lukem 		}
     96   1.9     lukem 		c_insert(el, 1);
     97   1.9     lukem 
     98   1.9     lukem 		*el->el_line.cursor++ = c;
     99   1.9     lukem 		el->el_state.doingarg = 0;	/* just in case */
    100   1.9     lukem 		re_fastaddc(el);		/* fast refresh for one char. */
    101   1.9     lukem 	} else {
    102   1.9     lukem 		if (el->el_state.inputmode != MODE_INSERT) {
    103   1.9     lukem 			for (i = 0; i < el->el_state.argument; i++)
    104   1.9     lukem 				el->el_chared.c_undo.buf[el->el_chared.c_undo.isize++] =
    105   1.9     lukem 				    el->el_line.cursor[i];
    106   1.9     lukem 
    107   1.9     lukem 			el->el_chared.c_undo.buf[el->el_chared.c_undo.isize] =
    108   1.9     lukem 			    '\0';
    109   1.9     lukem 			c_delafter(el, el->el_state.argument);
    110   1.9     lukem 		}
    111   1.9     lukem 		c_insert(el, el->el_state.argument);
    112   1.9     lukem 
    113   1.9     lukem 		while (el->el_state.argument--)
    114   1.9     lukem 			*el->el_line.cursor++ = c;
    115   1.9     lukem 		re_refresh(el);
    116   1.9     lukem 	}
    117   1.1       cgd 
    118   1.9     lukem 	if (el->el_state.inputmode == MODE_REPLACE_1)
    119   1.9     lukem 		(void) vi_command_mode(el, 0);
    120   1.1       cgd 
    121   1.9     lukem 	return (CC_NORM);
    122   1.1       cgd }
    123   1.1       cgd 
    124   1.1       cgd 
    125   1.8    simonb /* ed_delete_prev_word():
    126   1.1       cgd  *	Delete from beginning of current word to cursor
    127   1.1       cgd  *	[M-^?] [^W]
    128   1.1       cgd  */
    129   1.1       cgd protected el_action_t
    130   1.1       cgd /*ARGSUSED*/
    131   1.9     lukem ed_delete_prev_word(EditLine *el, int c)
    132   1.9     lukem {
    133   1.9     lukem 	char *cp, *p, *kp;
    134   1.9     lukem 
    135   1.9     lukem 	if (el->el_line.cursor == el->el_line.buffer)
    136   1.9     lukem 		return (CC_ERROR);
    137   1.9     lukem 
    138   1.9     lukem 	cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
    139   1.9     lukem 	    el->el_state.argument, ce__isword);
    140   1.9     lukem 
    141   1.9     lukem 	for (p = cp, kp = el->el_chared.c_kill.buf; p < el->el_line.cursor; p++)
    142   1.9     lukem 		*kp++ = *p;
    143   1.9     lukem 	el->el_chared.c_kill.last = kp;
    144   1.9     lukem 
    145   1.9     lukem 	c_delbefore(el, el->el_line.cursor - cp);	/* delete before dot */
    146   1.9     lukem 	el->el_line.cursor = cp;
    147   1.9     lukem 	if (el->el_line.cursor < el->el_line.buffer)
    148   1.9     lukem 		el->el_line.cursor = el->el_line.buffer; /* bounds check */
    149   1.9     lukem 	return (CC_REFRESH);
    150   1.1       cgd }
    151   1.1       cgd 
    152   1.1       cgd 
    153   1.8    simonb /* ed_delete_next_char():
    154   1.1       cgd  *	Delete character under cursor
    155   1.1       cgd  *	[^D] [x]
    156   1.1       cgd  */
    157   1.1       cgd protected el_action_t
    158   1.1       cgd /*ARGSUSED*/
    159   1.9     lukem ed_delete_next_char(EditLine *el, int c)
    160   1.1       cgd {
    161   1.9     lukem #ifdef notdef			/* XXX */
    162   1.9     lukem #define	EL	el->el_line
    163   1.6  christos 	(void) fprintf(el->el_errlfile,
    164   1.8    simonb 	    "\nD(b: %x(%s)  c: %x(%s) last: %x(%s) limit: %x(%s)\n",
    165   1.6  christos 	    EL.buffer, EL.buffer, EL.cursor, EL.cursor, EL.lastchar,
    166   1.6  christos 	    EL.lastchar, EL.limit, EL.limit);
    167   1.1       cgd #endif
    168   1.9     lukem 	if (el->el_line.cursor == el->el_line.lastchar) {
    169   1.9     lukem 			/* if I'm at the end */
    170   1.9     lukem 		if (el->el_map.type == MAP_VI) {
    171   1.9     lukem 			if (el->el_line.cursor == el->el_line.buffer) {
    172   1.9     lukem 				/* if I'm also at the beginning */
    173   1.1       cgd #ifdef KSHVI
    174   1.9     lukem 				return (CC_ERROR);
    175   1.1       cgd #else
    176   1.9     lukem 				term_overwrite(el, STReof, 4);
    177   1.9     lukem 					/* then do a EOF */
    178   1.9     lukem 				term__flush();
    179   1.9     lukem 				return (CC_EOF);
    180   1.1       cgd #endif
    181   1.9     lukem 			} else {
    182   1.1       cgd #ifdef KSHVI
    183   1.9     lukem 				el->el_line.cursor--;
    184   1.1       cgd #else
    185   1.9     lukem 				return (CC_ERROR);
    186   1.1       cgd #endif
    187   1.9     lukem 			}
    188   1.9     lukem 		} else {
    189   1.9     lukem 			if (el->el_line.cursor != el->el_line.buffer)
    190   1.9     lukem 				el->el_line.cursor--;
    191   1.9     lukem 			else
    192   1.9     lukem 				return (CC_ERROR);
    193   1.9     lukem 		}
    194   1.1       cgd 	}
    195   1.9     lukem 	c_delafter(el, el->el_state.argument);	/* delete after dot */
    196   1.9     lukem 	if (el->el_line.cursor >= el->el_line.lastchar &&
    197   1.9     lukem 	    el->el_line.cursor > el->el_line.buffer)
    198   1.9     lukem 			/* bounds check */
    199   1.9     lukem 		el->el_line.cursor = el->el_line.lastchar - 1;
    200   1.9     lukem 	return (CC_REFRESH);
    201   1.1       cgd }
    202   1.1       cgd 
    203   1.1       cgd 
    204   1.8    simonb /* ed_kill_line():
    205   1.1       cgd  *	Cut to the end of line
    206   1.1       cgd  *	[^K] [^K]
    207   1.1       cgd  */
    208   1.1       cgd protected el_action_t
    209   1.1       cgd /*ARGSUSED*/
    210   1.9     lukem ed_kill_line(EditLine *el, int c)
    211   1.9     lukem {
    212   1.9     lukem 	char *kp, *cp;
    213   1.9     lukem 
    214   1.9     lukem 	cp = el->el_line.cursor;
    215   1.9     lukem 	kp = el->el_chared.c_kill.buf;
    216   1.9     lukem 	while (cp < el->el_line.lastchar)
    217   1.9     lukem 		*kp++ = *cp++;	/* copy it */
    218   1.9     lukem 	el->el_chared.c_kill.last = kp;
    219   1.9     lukem 			/* zap! -- delete to end */
    220   1.9     lukem 	el->el_line.lastchar = el->el_line.cursor;
    221   1.9     lukem 	return (CC_REFRESH);
    222   1.1       cgd }
    223   1.1       cgd 
    224   1.1       cgd 
    225   1.8    simonb /* ed_move_to_end():
    226   1.1       cgd  *	Move cursor to the end of line
    227   1.1       cgd  *	[^E] [^E]
    228   1.1       cgd  */
    229   1.1       cgd protected el_action_t
    230   1.1       cgd /*ARGSUSED*/
    231   1.9     lukem ed_move_to_end(EditLine *el, int c)
    232   1.1       cgd {
    233   1.9     lukem 
    234   1.9     lukem 	el->el_line.cursor = el->el_line.lastchar;
    235   1.9     lukem 	if (el->el_map.type == MAP_VI) {
    236   1.1       cgd #ifdef VI_MOVE
    237   1.9     lukem 		el->el_line.cursor--;
    238   1.1       cgd #endif
    239   1.9     lukem 		if (el->el_chared.c_vcmd.action & DELETE) {
    240   1.9     lukem 			cv_delfini(el);
    241   1.9     lukem 			return (CC_REFRESH);
    242   1.9     lukem 		}
    243   1.1       cgd 	}
    244   1.9     lukem 	return (CC_CURSOR);
    245   1.1       cgd }
    246   1.1       cgd 
    247   1.1       cgd 
    248   1.8    simonb /* ed_move_to_beg():
    249   1.1       cgd  *	Move cursor to the beginning of line
    250   1.1       cgd  *	[^A] [^A]
    251   1.1       cgd  */
    252   1.1       cgd protected el_action_t
    253   1.1       cgd /*ARGSUSED*/
    254   1.9     lukem ed_move_to_beg(EditLine *el, int c)
    255   1.9     lukem {
    256   1.9     lukem 
    257   1.9     lukem 	el->el_line.cursor = el->el_line.buffer;
    258   1.9     lukem 
    259   1.9     lukem 	if (el->el_map.type == MAP_VI) {
    260   1.9     lukem 			/* We want FIRST non space character */
    261   1.9     lukem 		while (isspace((unsigned char) *el->el_line.cursor))
    262   1.9     lukem 			el->el_line.cursor++;
    263   1.9     lukem 		if (el->el_chared.c_vcmd.action & DELETE) {
    264   1.9     lukem 			cv_delfini(el);
    265   1.9     lukem 			return (CC_REFRESH);
    266   1.9     lukem 		}
    267   1.1       cgd 	}
    268   1.9     lukem 	return (CC_CURSOR);
    269   1.1       cgd }
    270   1.1       cgd 
    271   1.1       cgd 
    272   1.8    simonb /* ed_transpose_chars():
    273   1.1       cgd  *	Exchange the character to the left of the cursor with the one under it
    274   1.1       cgd  *	[^T] [^T]
    275   1.1       cgd  */
    276   1.1       cgd protected el_action_t
    277   1.9     lukem ed_transpose_chars(EditLine *el, int c)
    278   1.9     lukem {
    279   1.9     lukem 
    280   1.9     lukem 	if (el->el_line.cursor < el->el_line.lastchar) {
    281   1.9     lukem 		if (el->el_line.lastchar <= &el->el_line.buffer[1])
    282   1.9     lukem 			return (CC_ERROR);
    283   1.9     lukem 		else
    284   1.9     lukem 			el->el_line.cursor++;
    285   1.9     lukem 	}
    286   1.9     lukem 	if (el->el_line.cursor > &el->el_line.buffer[1]) {
    287   1.9     lukem 		/* must have at least two chars entered */
    288   1.9     lukem 		c = el->el_line.cursor[-2];
    289   1.9     lukem 		el->el_line.cursor[-2] = el->el_line.cursor[-1];
    290   1.9     lukem 		el->el_line.cursor[-1] = c;
    291   1.9     lukem 		return (CC_REFRESH);
    292   1.9     lukem 	} else
    293   1.9     lukem 		return (CC_ERROR);
    294   1.1       cgd }
    295   1.1       cgd 
    296   1.1       cgd 
    297   1.8    simonb /* ed_next_char():
    298   1.1       cgd  *	Move to the right one character
    299   1.1       cgd  *	[^F] [^F]
    300   1.1       cgd  */
    301   1.1       cgd protected el_action_t
    302   1.1       cgd /*ARGSUSED*/
    303   1.9     lukem ed_next_char(EditLine *el, int c)
    304   1.1       cgd {
    305   1.1       cgd 
    306   1.9     lukem 	if (el->el_line.cursor >= el->el_line.lastchar)
    307   1.9     lukem 		return (CC_ERROR);
    308   1.1       cgd 
    309   1.9     lukem 	el->el_line.cursor += el->el_state.argument;
    310   1.9     lukem 	if (el->el_line.cursor > el->el_line.lastchar)
    311   1.9     lukem 		el->el_line.cursor = el->el_line.lastchar;
    312   1.1       cgd 
    313   1.9     lukem 	if (el->el_map.type == MAP_VI)
    314   1.9     lukem 		if (el->el_chared.c_vcmd.action & DELETE) {
    315   1.9     lukem 			cv_delfini(el);
    316   1.9     lukem 			return (CC_REFRESH);
    317   1.9     lukem 		}
    318   1.9     lukem 	return (CC_CURSOR);
    319   1.1       cgd }
    320   1.1       cgd 
    321   1.1       cgd 
    322   1.8    simonb /* ed_prev_word():
    323   1.1       cgd  *	Move to the beginning of the current word
    324   1.1       cgd  *	[M-b] [b]
    325   1.1       cgd  */
    326   1.1       cgd protected el_action_t
    327   1.1       cgd /*ARGSUSED*/
    328   1.9     lukem ed_prev_word(EditLine *el, int c)
    329   1.1       cgd {
    330   1.1       cgd 
    331   1.9     lukem 	if (el->el_line.cursor == el->el_line.buffer)
    332   1.9     lukem 		return (CC_ERROR);
    333   1.1       cgd 
    334   1.9     lukem 	el->el_line.cursor = c__prev_word(el->el_line.cursor,
    335   1.9     lukem 	    el->el_line.buffer,
    336   1.9     lukem 	    el->el_state.argument,
    337   1.9     lukem 	    ce__isword);
    338   1.1       cgd 
    339   1.9     lukem 	if (el->el_map.type == MAP_VI)
    340   1.9     lukem 		if (el->el_chared.c_vcmd.action & DELETE) {
    341   1.9     lukem 			cv_delfini(el);
    342   1.9     lukem 			return (CC_REFRESH);
    343   1.9     lukem 		}
    344   1.9     lukem 	return (CC_CURSOR);
    345   1.1       cgd }
    346   1.1       cgd 
    347   1.1       cgd 
    348   1.8    simonb /* ed_prev_char():
    349   1.1       cgd  *	Move to the left one character
    350   1.1       cgd  *	[^B] [^B]
    351   1.1       cgd  */
    352   1.1       cgd protected el_action_t
    353   1.1       cgd /*ARGSUSED*/
    354   1.9     lukem ed_prev_char(EditLine *el, int c)
    355   1.1       cgd {
    356   1.1       cgd 
    357   1.9     lukem 	if (el->el_line.cursor > el->el_line.buffer) {
    358   1.9     lukem 		el->el_line.cursor -= el->el_state.argument;
    359   1.9     lukem 		if (el->el_line.cursor < el->el_line.buffer)
    360   1.9     lukem 			el->el_line.cursor = el->el_line.buffer;
    361   1.9     lukem 
    362   1.9     lukem 		if (el->el_map.type == MAP_VI)
    363   1.9     lukem 			if (el->el_chared.c_vcmd.action & DELETE) {
    364   1.9     lukem 				cv_delfini(el);
    365   1.9     lukem 				return (CC_REFRESH);
    366   1.9     lukem 			}
    367   1.9     lukem 		return (CC_CURSOR);
    368   1.9     lukem 	} else
    369   1.9     lukem 		return (CC_ERROR);
    370   1.1       cgd }
    371   1.1       cgd 
    372   1.1       cgd 
    373   1.8    simonb /* ed_quoted_insert():
    374   1.1       cgd  *	Add the next character typed verbatim
    375   1.1       cgd  *	[^V] [^V]
    376   1.1       cgd  */
    377   1.1       cgd protected el_action_t
    378   1.9     lukem ed_quoted_insert(EditLine *el, int c)
    379   1.9     lukem {
    380   1.9     lukem 	int num;
    381   1.9     lukem 	char tc;
    382   1.9     lukem 
    383   1.9     lukem 	tty_quotemode(el);
    384   1.9     lukem 	num = el_getc(el, &tc);
    385   1.9     lukem 	c = (unsigned char) tc;
    386   1.9     lukem 	tty_noquotemode(el);
    387   1.9     lukem 	if (num == 1)
    388   1.9     lukem 		return (ed_insert(el, c));
    389   1.9     lukem 	else
    390   1.9     lukem 		return (ed_end_of_file(el, 0));
    391   1.1       cgd }
    392   1.1       cgd 
    393   1.1       cgd 
    394   1.8    simonb /* ed_digit():
    395   1.1       cgd  *	Adds to argument or enters a digit
    396   1.1       cgd  */
    397   1.1       cgd protected el_action_t
    398   1.9     lukem ed_digit(EditLine *el, int c)
    399   1.9     lukem {
    400   1.9     lukem 
    401   1.9     lukem 	if (!isdigit(c))
    402   1.9     lukem 		return (CC_ERROR);
    403   1.9     lukem 
    404   1.9     lukem 	if (el->el_state.doingarg) {
    405   1.9     lukem 			/* if doing an arg, add this in... */
    406   1.9     lukem 		if (el->el_state.lastcmd == EM_UNIVERSAL_ARGUMENT)
    407   1.9     lukem 			el->el_state.argument = c - '0';
    408   1.9     lukem 		else {
    409   1.9     lukem 			if (el->el_state.argument > 1000000)
    410   1.9     lukem 				return (CC_ERROR);
    411   1.9     lukem 			el->el_state.argument =
    412   1.9     lukem 			    (el->el_state.argument * 10) + (c - '0');
    413   1.9     lukem 		}
    414   1.9     lukem 		return (CC_ARGHACK);
    415   1.9     lukem 	} else {
    416  1.10  jdolecek 		if (el->el_line.lastchar + 1 >= el->el_line.limit) {
    417  1.10  jdolecek 			if (!ch_enlargebufs(el, 1))
    418  1.10  jdolecek 				return (CC_ERROR);
    419  1.10  jdolecek 		}
    420   1.9     lukem 
    421   1.9     lukem 		if (el->el_state.inputmode != MODE_INSERT) {
    422   1.9     lukem 			el->el_chared.c_undo.buf[el->el_chared.c_undo.isize++] =
    423   1.9     lukem 			    *el->el_line.cursor;
    424   1.9     lukem 			el->el_chared.c_undo.buf[el->el_chared.c_undo.isize] =
    425   1.9     lukem 			    '\0';
    426   1.9     lukem 			c_delafter(el, 1);
    427   1.9     lukem 		}
    428   1.9     lukem 		c_insert(el, 1);
    429   1.9     lukem 		*el->el_line.cursor++ = c;
    430   1.9     lukem 		el->el_state.doingarg = 0;
    431   1.9     lukem 		re_fastaddc(el);
    432   1.9     lukem 	}
    433   1.9     lukem 	return (CC_NORM);
    434   1.1       cgd }
    435   1.1       cgd 
    436   1.1       cgd 
    437   1.8    simonb /* ed_argument_digit():
    438   1.1       cgd  *	Digit that starts argument
    439   1.1       cgd  *	For ESC-n
    440   1.1       cgd  */
    441   1.1       cgd protected el_action_t
    442   1.9     lukem ed_argument_digit(EditLine *el, int c)
    443   1.9     lukem {
    444   1.9     lukem 
    445   1.9     lukem 	if (!isdigit(c))
    446   1.9     lukem 		return (CC_ERROR);
    447   1.9     lukem 
    448   1.9     lukem 	if (el->el_state.doingarg) {
    449   1.9     lukem 		if (el->el_state.argument > 1000000)
    450   1.9     lukem 			return (CC_ERROR);
    451   1.9     lukem 		el->el_state.argument = (el->el_state.argument * 10) +
    452   1.9     lukem 		    (c - '0');
    453   1.9     lukem 	} else {		/* else starting an argument */
    454   1.9     lukem 		el->el_state.argument = c - '0';
    455   1.9     lukem 		el->el_state.doingarg = 1;
    456   1.9     lukem 	}
    457   1.9     lukem 	return (CC_ARGHACK);
    458   1.1       cgd }
    459   1.1       cgd 
    460   1.1       cgd 
    461   1.8    simonb /* ed_unassigned():
    462   1.1       cgd  *	Indicates unbound character
    463   1.1       cgd  *	Bound to keys that are not assigned
    464   1.1       cgd  */
    465   1.1       cgd protected el_action_t
    466   1.1       cgd /*ARGSUSED*/
    467   1.9     lukem ed_unassigned(EditLine *el, int c)
    468   1.9     lukem {
    469   1.9     lukem 
    470   1.9     lukem 	term_beep(el);
    471   1.9     lukem 	term__flush();
    472   1.9     lukem 	return (CC_NORM);
    473   1.1       cgd }
    474   1.1       cgd 
    475   1.1       cgd 
    476   1.1       cgd /**
    477   1.1       cgd  ** TTY key handling.
    478   1.1       cgd  **/
    479   1.1       cgd 
    480   1.8    simonb /* ed_tty_sigint():
    481   1.1       cgd  *	Tty interrupt character
    482   1.1       cgd  *	[^C]
    483   1.1       cgd  */
    484   1.1       cgd protected el_action_t
    485   1.1       cgd /*ARGSUSED*/
    486   1.9     lukem ed_tty_sigint(EditLine *el, int c)
    487   1.8    simonb {
    488   1.9     lukem 
    489   1.9     lukem 	return (CC_NORM);
    490   1.1       cgd }
    491   1.1       cgd 
    492   1.1       cgd 
    493   1.8    simonb /* ed_tty_dsusp():
    494   1.1       cgd  *	Tty delayed suspend character
    495   1.1       cgd  *	[^Y]
    496   1.1       cgd  */
    497   1.1       cgd protected el_action_t
    498   1.1       cgd /*ARGSUSED*/
    499   1.9     lukem ed_tty_dsusp(EditLine *el, int c)
    500   1.1       cgd {
    501   1.9     lukem 
    502   1.9     lukem 	return (CC_NORM);
    503   1.1       cgd }
    504   1.1       cgd 
    505   1.1       cgd 
    506   1.8    simonb /* ed_tty_flush_output():
    507   1.1       cgd  *	Tty flush output characters
    508   1.1       cgd  *	[^O]
    509   1.1       cgd  */
    510   1.1       cgd protected el_action_t
    511   1.1       cgd /*ARGSUSED*/
    512   1.9     lukem ed_tty_flush_output(EditLine *el, int c)
    513   1.1       cgd {
    514   1.9     lukem 
    515   1.9     lukem 	return (CC_NORM);
    516   1.1       cgd }
    517   1.1       cgd 
    518   1.1       cgd 
    519   1.8    simonb /* ed_tty_sigquit():
    520   1.1       cgd  *	Tty quit character
    521   1.1       cgd  *	[^\]
    522   1.1       cgd  */
    523   1.1       cgd protected el_action_t
    524   1.1       cgd /*ARGSUSED*/
    525   1.9     lukem ed_tty_sigquit(EditLine *el, int c)
    526   1.1       cgd {
    527   1.9     lukem 
    528   1.9     lukem 	return (CC_NORM);
    529   1.1       cgd }
    530   1.1       cgd 
    531   1.1       cgd 
    532   1.8    simonb /* ed_tty_sigtstp():
    533   1.1       cgd  *	Tty suspend character
    534   1.1       cgd  *	[^Z]
    535   1.1       cgd  */
    536   1.1       cgd protected el_action_t
    537   1.1       cgd /*ARGSUSED*/
    538   1.9     lukem ed_tty_sigtstp(EditLine *el, int c)
    539   1.1       cgd {
    540   1.9     lukem 
    541   1.9     lukem 	return (CC_NORM);
    542   1.1       cgd }
    543   1.1       cgd 
    544   1.1       cgd 
    545   1.8    simonb /* ed_tty_stop_output():
    546   1.1       cgd  *	Tty disallow output characters
    547   1.1       cgd  *	[^S]
    548   1.1       cgd  */
    549   1.1       cgd protected el_action_t
    550   1.1       cgd /*ARGSUSED*/
    551   1.9     lukem ed_tty_stop_output(EditLine *el, int c)
    552   1.1       cgd {
    553   1.9     lukem 
    554   1.9     lukem 	return (CC_NORM);
    555   1.1       cgd }
    556   1.1       cgd 
    557   1.1       cgd 
    558   1.8    simonb /* ed_tty_start_output():
    559   1.1       cgd  *	Tty allow output characters
    560   1.1       cgd  *	[^Q]
    561   1.1       cgd  */
    562   1.1       cgd protected el_action_t
    563   1.1       cgd /*ARGSUSED*/
    564   1.9     lukem ed_tty_start_output(EditLine *el, int c)
    565   1.1       cgd {
    566   1.9     lukem 
    567   1.9     lukem 	return (CC_NORM);
    568   1.1       cgd }
    569   1.1       cgd 
    570   1.1       cgd 
    571   1.8    simonb /* ed_newline():
    572   1.1       cgd  *	Execute command
    573   1.1       cgd  *	[^J]
    574   1.1       cgd  */
    575   1.1       cgd protected el_action_t
    576   1.1       cgd /*ARGSUSED*/
    577   1.9     lukem ed_newline(EditLine *el, int c)
    578   1.9     lukem {
    579   1.9     lukem 
    580   1.9     lukem 	re_goto_bottom(el);
    581   1.9     lukem 	*el->el_line.lastchar++ = '\n';
    582   1.9     lukem 	*el->el_line.lastchar = '\0';
    583   1.9     lukem 	if (el->el_map.type == MAP_VI)
    584   1.9     lukem 		el->el_chared.c_vcmd.ins = el->el_line.buffer;
    585   1.9     lukem 	return (CC_NEWLINE);
    586   1.1       cgd }
    587   1.1       cgd 
    588   1.1       cgd 
    589   1.8    simonb /* ed_delete_prev_char():
    590   1.1       cgd  *	Delete the character to the left of the cursor
    591   1.1       cgd  *	[^?]
    592   1.1       cgd  */
    593   1.1       cgd protected el_action_t
    594   1.1       cgd /*ARGSUSED*/
    595   1.9     lukem ed_delete_prev_char(EditLine *el, int c)
    596   1.9     lukem {
    597   1.9     lukem 
    598   1.9     lukem 	if (el->el_line.cursor <= el->el_line.buffer)
    599   1.9     lukem 		return (CC_ERROR);
    600   1.9     lukem 
    601   1.9     lukem 	c_delbefore(el, el->el_state.argument);
    602   1.9     lukem 	el->el_line.cursor -= el->el_state.argument;
    603   1.9     lukem 	if (el->el_line.cursor < el->el_line.buffer)
    604   1.9     lukem 		el->el_line.cursor = el->el_line.buffer;
    605   1.9     lukem 	return (CC_REFRESH);
    606   1.1       cgd }
    607   1.1       cgd 
    608   1.1       cgd 
    609   1.8    simonb /* ed_clear_screen():
    610   1.1       cgd  *	Clear screen leaving current line at the top
    611   1.1       cgd  *	[^L]
    612   1.1       cgd  */
    613   1.1       cgd protected el_action_t
    614   1.1       cgd /*ARGSUSED*/
    615   1.9     lukem ed_clear_screen(EditLine *el, int c)
    616   1.9     lukem {
    617   1.9     lukem 
    618   1.9     lukem 	term_clear_screen(el);	/* clear the whole real screen */
    619   1.9     lukem 	re_clear_display(el);	/* reset everything */
    620   1.9     lukem 	return (CC_REFRESH);
    621   1.1       cgd }
    622   1.1       cgd 
    623   1.1       cgd 
    624   1.8    simonb /* ed_redisplay():
    625   1.1       cgd  *	Redisplay everything
    626   1.1       cgd  *	^R
    627   1.1       cgd  */
    628   1.1       cgd protected el_action_t
    629   1.1       cgd /*ARGSUSED*/
    630   1.9     lukem ed_redisplay(EditLine *el, int c)
    631   1.1       cgd {
    632   1.9     lukem 
    633   1.9     lukem 	return (CC_REDISPLAY);
    634   1.1       cgd }
    635   1.1       cgd 
    636   1.1       cgd 
    637   1.8    simonb /* ed_start_over():
    638   1.1       cgd  *	Erase current line and start from scratch
    639   1.1       cgd  *	[^G]
    640   1.1       cgd  */
    641   1.1       cgd protected el_action_t
    642   1.1       cgd /*ARGSUSED*/
    643   1.9     lukem ed_start_over(EditLine *el, int c)
    644   1.1       cgd {
    645   1.9     lukem 
    646   1.9     lukem 	ch_reset(el);
    647   1.9     lukem 	return (CC_REFRESH);
    648   1.1       cgd }
    649   1.1       cgd 
    650   1.1       cgd 
    651   1.8    simonb /* ed_sequence_lead_in():
    652   1.1       cgd  *	First character in a bound sequence
    653   1.1       cgd  *	Placeholder for external keys
    654   1.1       cgd  */
    655   1.1       cgd protected el_action_t
    656   1.1       cgd /*ARGSUSED*/
    657   1.9     lukem ed_sequence_lead_in(EditLine *el, int c)
    658   1.1       cgd {
    659   1.9     lukem 
    660   1.9     lukem 	return (CC_NORM);
    661   1.1       cgd }
    662   1.1       cgd 
    663   1.1       cgd 
    664   1.8    simonb /* ed_prev_history():
    665   1.1       cgd  *	Move to the previous history line
    666   1.1       cgd  *	[^P] [k]
    667   1.1       cgd  */
    668   1.1       cgd protected el_action_t
    669   1.1       cgd /*ARGSUSED*/
    670   1.9     lukem ed_prev_history(EditLine *el, int c)
    671   1.9     lukem {
    672   1.9     lukem 	char beep = 0;
    673   1.9     lukem 
    674   1.9     lukem 	el->el_chared.c_undo.action = NOP;
    675   1.9     lukem 	*el->el_line.lastchar = '\0';		/* just in case */
    676   1.9     lukem 
    677   1.9     lukem 	if (el->el_history.eventno == 0) {	/* save the current buffer
    678   1.9     lukem 						 * away */
    679   1.9     lukem 		(void) strncpy(el->el_history.buf, el->el_line.buffer,
    680   1.9     lukem 		    EL_BUFSIZ);
    681   1.9     lukem 		el->el_history.last = el->el_history.buf +
    682   1.9     lukem 		    (el->el_line.lastchar - el->el_line.buffer);
    683   1.9     lukem 	}
    684   1.9     lukem 	el->el_history.eventno += el->el_state.argument;
    685   1.9     lukem 
    686   1.9     lukem 	if (hist_get(el) == CC_ERROR) {
    687   1.9     lukem 		beep = 1;
    688   1.9     lukem 		/* el->el_history.eventno was fixed by first call */
    689   1.9     lukem 		(void) hist_get(el);
    690   1.9     lukem 	}
    691   1.9     lukem 	re_refresh(el);
    692   1.9     lukem 	if (beep)
    693   1.9     lukem 		return (CC_ERROR);
    694   1.9     lukem 	else
    695   1.9     lukem 		return (CC_NORM);	/* was CC_UP_HIST */
    696   1.1       cgd }
    697   1.1       cgd 
    698   1.1       cgd 
    699   1.8    simonb /* ed_next_history():
    700   1.1       cgd  *	Move to the next history line
    701   1.1       cgd  *	[^N] [j]
    702   1.1       cgd  */
    703   1.1       cgd protected el_action_t
    704   1.1       cgd /*ARGSUSED*/
    705   1.9     lukem ed_next_history(EditLine *el, int c)
    706   1.1       cgd {
    707   1.1       cgd 
    708   1.9     lukem 	el->el_chared.c_undo.action = NOP;
    709   1.9     lukem 	*el->el_line.lastchar = '\0';	/* just in case */
    710   1.1       cgd 
    711   1.9     lukem 	el->el_history.eventno -= el->el_state.argument;
    712   1.1       cgd 
    713   1.9     lukem 	if (el->el_history.eventno < 0) {
    714   1.9     lukem 		el->el_history.eventno = 0;
    715   1.9     lukem 		return (CC_ERROR);/* make it beep */
    716   1.9     lukem 	}
    717   1.9     lukem 	return (hist_get(el));
    718   1.1       cgd }
    719   1.1       cgd 
    720   1.1       cgd 
    721   1.8    simonb /* ed_search_prev_history():
    722   1.1       cgd  *	Search previous in history for a line matching the current
    723   1.1       cgd  *	next search history [M-P] [K]
    724   1.1       cgd  */
    725   1.1       cgd protected el_action_t
    726   1.1       cgd /*ARGSUSED*/
    727   1.9     lukem ed_search_prev_history(EditLine *el, int c)
    728   1.9     lukem {
    729   1.9     lukem 	const char *hp;
    730   1.9     lukem 	int h;
    731   1.9     lukem 	bool_t found = 0;
    732   1.9     lukem 
    733   1.9     lukem 	el->el_chared.c_vcmd.action = NOP;
    734   1.9     lukem 	el->el_chared.c_undo.action = NOP;
    735   1.9     lukem 	*el->el_line.lastchar = '\0';	/* just in case */
    736   1.9     lukem 	if (el->el_history.eventno < 0) {
    737   1.1       cgd #ifdef DEBUG_EDIT
    738   1.9     lukem 		(void) fprintf(el->el_errfile,
    739   1.9     lukem 		    "e_prev_search_hist(): eventno < 0;\n");
    740   1.1       cgd #endif
    741   1.9     lukem 		el->el_history.eventno = 0;
    742   1.9     lukem 		return (CC_ERROR);
    743   1.9     lukem 	}
    744   1.9     lukem 	if (el->el_history.eventno == 0) {
    745   1.9     lukem 		(void) strncpy(el->el_history.buf, el->el_line.buffer,
    746   1.9     lukem 		    EL_BUFSIZ);
    747   1.9     lukem 		el->el_history.last = el->el_history.buf +
    748   1.9     lukem 		    (el->el_line.lastchar - el->el_line.buffer);
    749   1.9     lukem 	}
    750   1.9     lukem 	if (el->el_history.ref == NULL)
    751   1.9     lukem 		return (CC_ERROR);
    752   1.1       cgd 
    753   1.9     lukem 	hp = HIST_FIRST(el);
    754   1.9     lukem 	if (hp == NULL)
    755   1.9     lukem 		return (CC_ERROR);
    756   1.1       cgd 
    757   1.9     lukem 	c_setpat(el);		/* Set search pattern !! */
    758   1.1       cgd 
    759   1.9     lukem 	for (h = 1; h <= el->el_history.eventno; h++)
    760   1.9     lukem 		hp = HIST_NEXT(el);
    761   1.1       cgd 
    762   1.9     lukem 	while (hp != NULL) {
    763   1.1       cgd #ifdef SDEBUG
    764   1.9     lukem 		(void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
    765   1.1       cgd #endif
    766   1.9     lukem 		if ((strncmp(hp, el->el_line.buffer, (size_t)
    767   1.9     lukem 			    (el->el_line.lastchar - el->el_line.buffer)) ||
    768   1.9     lukem 			hp[el->el_line.lastchar - el->el_line.buffer]) &&
    769   1.9     lukem 		    c_hmatch(el, hp)) {
    770   1.9     lukem 			found++;
    771   1.9     lukem 			break;
    772   1.9     lukem 		}
    773   1.9     lukem 		h++;
    774   1.9     lukem 		hp = HIST_NEXT(el);
    775   1.9     lukem 	}
    776   1.1       cgd 
    777   1.9     lukem 	if (!found) {
    778   1.1       cgd #ifdef SDEBUG
    779   1.9     lukem 		(void) fprintf(el->el_errfile, "not found\n");
    780   1.1       cgd #endif
    781   1.9     lukem 		return (CC_ERROR);
    782   1.9     lukem 	}
    783   1.9     lukem 	el->el_history.eventno = h;
    784   1.1       cgd 
    785   1.9     lukem 	return (hist_get(el));
    786   1.1       cgd }
    787   1.1       cgd 
    788   1.1       cgd 
    789   1.8    simonb /* ed_search_next_history():
    790   1.1       cgd  *	Search next in history for a line matching the current
    791   1.1       cgd  *	[M-N] [J]
    792   1.1       cgd  */
    793   1.1       cgd protected el_action_t
    794   1.1       cgd /*ARGSUSED*/
    795   1.9     lukem ed_search_next_history(EditLine *el, int c)
    796   1.1       cgd {
    797   1.9     lukem 	const char *hp;
    798   1.9     lukem 	int h;
    799   1.9     lukem 	bool_t found = 0;
    800   1.1       cgd 
    801   1.9     lukem 	el->el_chared.c_vcmd.action = NOP;
    802   1.9     lukem 	el->el_chared.c_undo.action = NOP;
    803   1.9     lukem 	*el->el_line.lastchar = '\0';	/* just in case */
    804   1.1       cgd 
    805   1.9     lukem 	if (el->el_history.eventno == 0)
    806   1.9     lukem 		return (CC_ERROR);
    807   1.1       cgd 
    808   1.9     lukem 	if (el->el_history.ref == NULL)
    809   1.9     lukem 		return (CC_ERROR);
    810   1.1       cgd 
    811   1.9     lukem 	hp = HIST_FIRST(el);
    812   1.9     lukem 	if (hp == NULL)
    813   1.9     lukem 		return (CC_ERROR);
    814   1.1       cgd 
    815   1.9     lukem 	c_setpat(el);		/* Set search pattern !! */
    816   1.1       cgd 
    817   1.9     lukem 	for (h = 1; h < el->el_history.eventno && hp; h++) {
    818   1.1       cgd #ifdef SDEBUG
    819   1.9     lukem 		(void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
    820   1.1       cgd #endif
    821   1.9     lukem 		if ((strncmp(hp, el->el_line.buffer, (size_t)
    822   1.9     lukem 			    (el->el_line.lastchar - el->el_line.buffer)) ||
    823   1.9     lukem 			hp[el->el_line.lastchar - el->el_line.buffer]) &&
    824   1.9     lukem 		    c_hmatch(el, hp))
    825   1.9     lukem 			found = h;
    826   1.9     lukem 		hp = HIST_NEXT(el);
    827   1.9     lukem 	}
    828   1.1       cgd 
    829   1.9     lukem 	if (!found) {		/* is it the current history number? */
    830   1.9     lukem 		if (!c_hmatch(el, el->el_history.buf)) {
    831   1.1       cgd #ifdef SDEBUG
    832   1.9     lukem 			(void) fprintf(el->el_errfile, "not found\n");
    833   1.1       cgd #endif
    834   1.9     lukem 			return (CC_ERROR);
    835   1.9     lukem 		}
    836   1.1       cgd 	}
    837   1.9     lukem 	el->el_history.eventno = found;
    838   1.1       cgd 
    839   1.9     lukem 	return (hist_get(el));
    840   1.1       cgd }
    841   1.1       cgd 
    842   1.1       cgd 
    843   1.1       cgd /* ed_prev_line():
    844   1.1       cgd  *	Move up one line
    845   1.1       cgd  *	Could be [k] [^p]
    846   1.1       cgd  */
    847   1.1       cgd protected el_action_t
    848   1.1       cgd /*ARGSUSED*/
    849   1.9     lukem ed_prev_line(EditLine *el, int c)
    850   1.9     lukem {
    851   1.9     lukem 	char *ptr;
    852   1.9     lukem 	int nchars = c_hpos(el);
    853   1.8    simonb 
    854   1.9     lukem 	/*
    855   1.9     lukem          * Move to the line requested
    856   1.9     lukem          */
    857   1.9     lukem 	if (*(ptr = el->el_line.cursor) == '\n')
    858   1.9     lukem 		ptr--;
    859   1.9     lukem 
    860   1.9     lukem 	for (; ptr >= el->el_line.buffer; ptr--)
    861   1.9     lukem 		if (*ptr == '\n' && --el->el_state.argument <= 0)
    862   1.9     lukem 			break;
    863   1.9     lukem 
    864   1.9     lukem 	if (el->el_state.argument > 0)
    865   1.9     lukem 		return (CC_ERROR);
    866   1.9     lukem 
    867   1.9     lukem 	/*
    868   1.9     lukem          * Move to the beginning of the line
    869   1.9     lukem          */
    870   1.9     lukem 	for (ptr--; ptr >= el->el_line.buffer && *ptr != '\n'; ptr--)
    871   1.9     lukem 		continue;
    872   1.9     lukem 
    873   1.9     lukem 	/*
    874   1.9     lukem          * Move to the character requested
    875   1.9     lukem          */
    876   1.9     lukem 	for (ptr++;
    877   1.9     lukem 	    nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
    878   1.9     lukem 	    ptr++)
    879   1.9     lukem 		continue;
    880   1.9     lukem 
    881   1.9     lukem 	el->el_line.cursor = ptr;
    882   1.9     lukem 	return (CC_CURSOR);
    883   1.1       cgd }
    884   1.1       cgd 
    885   1.1       cgd 
    886   1.1       cgd /* ed_next_line():
    887   1.1       cgd  *	Move down one line
    888   1.1       cgd  *	Could be [j] [^n]
    889   1.1       cgd  */
    890   1.1       cgd protected el_action_t
    891   1.1       cgd /*ARGSUSED*/
    892   1.9     lukem ed_next_line(EditLine *el, int c)
    893   1.9     lukem {
    894   1.9     lukem 	char *ptr;
    895   1.9     lukem 	int nchars = c_hpos(el);
    896   1.8    simonb 
    897   1.9     lukem 	/*
    898   1.9     lukem          * Move to the line requested
    899   1.9     lukem          */
    900   1.9     lukem 	for (ptr = el->el_line.cursor; ptr < el->el_line.lastchar; ptr++)
    901   1.9     lukem 		if (*ptr == '\n' && --el->el_state.argument <= 0)
    902   1.9     lukem 			break;
    903   1.9     lukem 
    904   1.9     lukem 	if (el->el_state.argument > 0)
    905   1.9     lukem 		return (CC_ERROR);
    906   1.9     lukem 
    907   1.9     lukem 	/*
    908   1.9     lukem          * Move to the character requested
    909   1.9     lukem          */
    910   1.9     lukem 	for (ptr++;
    911   1.9     lukem 	    nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
    912   1.9     lukem 	    ptr++)
    913   1.9     lukem 		continue;
    914   1.9     lukem 
    915   1.9     lukem 	el->el_line.cursor = ptr;
    916   1.9     lukem 	return (CC_CURSOR);
    917   1.1       cgd }
    918   1.1       cgd 
    919   1.1       cgd 
    920   1.8    simonb /* ed_command():
    921   1.1       cgd  *	Editline extended command
    922   1.1       cgd  *	[M-X] [:]
    923   1.1       cgd  */
    924   1.1       cgd protected el_action_t
    925   1.1       cgd /*ARGSUSED*/
    926   1.9     lukem ed_command(EditLine *el, int c)
    927   1.9     lukem {
    928   1.9     lukem 	char tmpbuf[EL_BUFSIZ];
    929   1.9     lukem 	int tmplen;
    930   1.9     lukem 
    931   1.9     lukem 	el->el_line.buffer[0] = '\0';
    932   1.9     lukem 	el->el_line.lastchar = el->el_line.buffer;
    933   1.9     lukem 	el->el_line.cursor = el->el_line.buffer;
    934   1.9     lukem 
    935   1.9     lukem 	c_insert(el, 3);	/* prompt + ": " */
    936   1.9     lukem 	*el->el_line.cursor++ = '\n';
    937   1.9     lukem 	*el->el_line.cursor++ = ':';
    938   1.9     lukem 	*el->el_line.cursor++ = ' ';
    939   1.9     lukem 	re_refresh(el);
    940   1.9     lukem 
    941   1.9     lukem 	tmplen = c_gets(el, tmpbuf);
    942   1.9     lukem 	tmpbuf[tmplen] = '\0';
    943   1.9     lukem 
    944   1.9     lukem 	el->el_line.buffer[0] = '\0';
    945   1.9     lukem 	el->el_line.lastchar = el->el_line.buffer;
    946   1.9     lukem 	el->el_line.cursor = el->el_line.buffer;
    947   1.9     lukem 
    948   1.9     lukem 	if (parse_line(el, tmpbuf) == -1)
    949   1.9     lukem 		return (CC_ERROR);
    950   1.9     lukem 	else
    951   1.9     lukem 		return (CC_REFRESH);
    952   1.1       cgd }
    953