* editline, rc & win
@ 1995-10-15 18:15 Icarus Sparry
0 siblings, 0 replies; 2+ messages in thread
From: Icarus Sparry @ 1995-10-15 18:15 UTC (permalink / raw)
To: wilyfans, rc
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 }
};
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: editline, rc & win
@ 1995-10-16 12:37 Rich Salz
0 siblings, 0 replies; 2+ messages in thread
From: Rich Salz @ 1995-10-16 12:37 UTC (permalink / raw)
To: I.Sparry, wilyfans, rc
That's a lot of icky little code scattered throughout.
You want no editing, no echo if not a tty? I don't understand the
problem space. editline being called to read a pipe?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1995-10-16 12:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-10-15 18:15 editline, rc & win Icarus Sparry
1995-10-16 12:37 Rich Salz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).