From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from goggins.bath.ac.uk ([138.38.32.13]) by hawkwind.utcs.utoronto.ca with SMTP id <24189>; Mon, 16 Oct 1995 02:32:26 -0400 Received: from bath.ac.uk (actually host ss1.bath.ac.uk) by goggins.bath.ac.uk with SMTP (PP); Sun, 15 Oct 1995 19:16:00 +0100 To: wilyfans@jli.com, rc@hawkwind.utcs.toronto.edu Subject: editline, rc & win Reply-To: I.Sparry@bath.ac.uk Date: Sun, 15 Oct 1995 14:15:54 -0400 From: Icarus Sparry Message-ID: <9510151915.aa16726@ss1.bath.ac.uk> Here is a very lightly tested patch for editline so that if it doesn't think that it is talking to a terminal (i.e. isatty(0) is false) then it does not do any editing, and does not echo. I wanted a single binary for 'rc' that I could use (with editing) from a vt100 terminal and also use with 'wily' and 'win'. I repeat that it is very lightly tested - use at own risk. Icarus --- ../editline.orig/editline.c Sun Oct 15 17:05:14 1995 +++ editline.c Sun Oct 15 18:51:25 1995 @@ -84,6 +84,7 @@ STATIC int PushBack; STATIC int Pushed; STATIC int Signal; +FORWARD KEYMAP TinyMap[3]; /* Should be 2 */ FORWARD KEYMAP Map[33]; FORWARD KEYMAP MetaMap[17]; STATIC SIZE_T Length; @@ -92,6 +93,7 @@ STATIC char *backspace; STATIC int TTYwidth; STATIC int TTYrows; +STATIC int DoOwnEcho; /* Display print 8-bit chars as `M-x' or as the actual 8-bit char? */ int rl_meta_chars = 1; @@ -116,10 +118,10 @@ STATIC void TTYflush() { - if (ScreenCount) { + if (ScreenCount && DoOwnEcho) { (void)write(1, Screen, ScreenCount); - ScreenCount = 0; } + ScreenCount = 0; } STATIC void @@ -142,6 +144,17 @@ } STATIC void +TTYputsa(p) + STRING p; +{ + int l; + if (!DoOwnEcho) { + l = strlen(p); + write(1,p,l); + } else TTYputs(p); +} + +STATIC void TTYshow(c) CHAR c; { @@ -222,6 +235,8 @@ } init++; + DoOwnEcho = isatty(0); + TTYwidth = TTYrows = 0; #if defined(USE_TERMCAP) bp = &buff[0]; @@ -870,7 +885,7 @@ PushBack = UNMETA(c); return meta(); } - for (kp = Map; kp->Function; kp++) + for (kp = (DoOwnEcho?Map:TinyMap); kp->Function; kp++) if (kp->Key == c) break; s = kp->Function ? (*kp->Function)() : insert_char((int)c); @@ -884,9 +899,9 @@ TTYspecial(c) unsigned int c; { + if (!DoOwnEcho) return CSdispatch; if (ISMETA(c)) return CSdispatch; - if (c == rl_erase || c == DEL) return bk_del_char(); if (c == rl_kill) { @@ -1013,7 +1028,7 @@ ScreenSize = SCREEN_INC; Screen = NEW(char, ScreenSize); Prompt = prompt ? prompt : (char *)NIL; - TTYputs((STRING)Prompt); + TTYputsa((STRING)Prompt); if ((line = editinput()) != NULL) { line = (CHAR *)strdup((char *)line); TTYputs((STRING)NEWLINE); @@ -1402,6 +1417,11 @@ { CTL(']'), move_to_char }, { CTL('^'), ring_bell }, { CTL('_'), ring_bell }, + { 0, NULL } +}; + +STATIC KEYMAP TinyMap[3] = { + { CTL('J'), accept_line }, { 0, NULL } };