* Copyright (c) 1991,1990 Carnegie Mellon University
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
* Carnegie Mellon requests users of this software to return to
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
* Revision 1.1 1992/03/25 21:45:10 pace
* Revision 2.4 91/02/14 14:41:53 mrt
* Add input line editing.
* Revision 2.3 91/02/05 17:06:32 mrt
* Changed to new Mach copyright
* [91/01/31 16:18:13 mrt]
* Revision 2.2 90/08/27 21:51:03 dbg
* Author: David B. Golub, Carnegie Mellon University
#include <ddb/db_output.h>
* Character input and editing.
* We don't track output position while editing input,
* since input always ends with a new-line. We just
* reset the line position at the end.
char * db_lbuf_start
; /* start of input line buffer */
char * db_lbuf_end
; /* end of input line buffer */
char * db_lc
; /* current character */
char * db_le
; /* one past last character */
#define CTRL(c) ((c) & 0x1f)
#define isspace(c) ((c) == ' ' || (c) == '\t')
* Delete N characters, forward or backward
for (p
= db_lc
; p
< db_le
-n
; p
++) {
db_putnchars(BACKUP
, db_le
- db_lc
);
/* returns TRUE at end-of-line */
/* back up one character */
if (db_lc
> db_lbuf_start
) {
/* forward one character */
while (db_lc
> db_lbuf_start
) {
/* erase previous character */
if (db_lc
> db_lbuf_start
)
/* erase next character */
/* delete to end of line */
db_delete(db_le
- db_lc
, DEL_FWD
);
/* twiddle last 2 characters */
if (db_lc
>= db_lbuf_start
+ 2) {
if (db_le
> db_lbuf_start
) {
db_putstring(db_lbuf_start
, db_le
- db_lbuf_start
);
db_putnchars(BACKUP
, db_le
- db_lc
);
if (db_le
== db_lbuf_end
) {
else if (c
>= ' ' && c
<= '~') {
for (p
= db_le
; p
> db_lc
; p
--)
db_putstring(db_lc
, db_le
- db_lc
);
db_putnchars(BACKUP
, db_le
- db_lc
);
db_readline(lstart
, lsize
)
db_force_whitespace(); /* synch output position */
db_lbuf_end
= lstart
+ lsize
;
while (!db_inputchar(cngetc()))
db_putchar('\n'); /* synch output position */
return (db_le
- db_lbuf_start
);
case -1: /* no character */
} while (c
!= CTRL('q'));
/* called from kdb_trap in db_interface.c */