From 014aafe23a4bb4e68c79627420c777c7bba2d8c6 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 4 Apr 2017 20:13:42 -0700 Subject: Connect -n option to linenoise noninteractive mode. * parser.c (repl): Set noninteractive mode from noninteractive option. * txr.c (help): Mention effect of -n upon listener. * txr.1: Documented effect of -n/--noninteractive on the listener. --- parser.c | 3 +++ txr.1 | 17 ++++++++++++++++- txr.c | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/parser.c b/parser.c index 20e5a094..bf80b2b7 100644 --- a/parser.c +++ b/parser.c @@ -55,6 +55,7 @@ #include "cadr.h" #include "struct.h" #include "parser.h" +#include "txr.h" #if HAVE_TERMIOS #include "linenoise/linenoise.h" #endif @@ -986,6 +987,8 @@ val repl(val bindings, val in_stream, val out_stream) if (histfile_u8) lino_hist_load(ls, histfile_u8); + lino_set_noninteractive(ls, opt_noninteractive); + while (!done) { val prompt = format(nil, lit("~d> "), counter, nao); val prev_counter = counter; diff --git a/txr.1 b/txr.1 index 31f3d468..60f3bc5f 100644 --- a/txr.1 +++ b/txr.1 @@ -458,7 +458,10 @@ Invoke the interactive \*(TX debugger. See the DEBUGGER section. .coIP --noninteractive This option affects behavior related to \*(TX's .code *std-input* -stream. Normally, if this stream is connected to a terminal device, it is +stream. It also has a another, unrelated effect, on the +behavior of the interactive listener; see below. + +Normally, if this stream is connected to a terminal device, it is automatically marked as having the real-time property when \*(TX starts up (see the functions .code stream-set-prop and .codn real-time-stream-p ). @@ -478,6 +481,18 @@ returned by that function has behaviors that are better suited for scanning interactive input. A more detailed explanation is given under the description of this function. +If the +.code -n +option is effect and \*(TX enters into the interactive listener, +the listener operates in +.IR "plain mode" . +The listener reads buffered lines +from the operating system without any character-based editing features +or history navigation. In plain mode, no prompts appear and no +terminal control escape sequences are generated. The only output is +the results of evaluation, related diagnostic messages, and any output +generated by the evaluated expressions themselves. + .coIP -v Verbose operation. Detailed logging is enabled. diff --git a/txr.c b/txr.c index afe07971..5b0ade21 100644 --- a/txr.c +++ b/txr.c @@ -125,6 +125,8 @@ static void help(void) "-d Debugger mode.\n" "-n Noninteractive input mode for standard input stream,\n" " even if its connected to a terminal device.\n" +" Also, forces the interactive listener into\n" +" 'plain mode' without editing features.\n" "-a N Generate array variables up to N dimensions.\n" " N is a decimal integer. The default value is 1.\n" " Additional dimensions beyond N are fudged\n" -- cgit v1.2.3