diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-08-03 07:09:59 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-08-03 07:09:59 -0700 |
commit | 70a9ef01f022982241f80fe1eac19930aa597507 (patch) | |
tree | 67b38122140ef47de335564e6815770e3fa033be | |
parent | d4d626c256dd5147d308e609a9b6c341d8e0a02b (diff) | |
download | txr-70a9ef01f022982241f80fe1eac19930aa597507.tar.gz txr-70a9ef01f022982241f80fe1eac19930aa597507.tar.bz2 txr-70a9ef01f022982241f80fe1eac19930aa597507.zip |
listener: print prompts in plain mode if stdin is tty.
* linenoise/linenoise.c (linenoise): Force the printing of prompts
if the input file descriptor is a tty.
* txr.1: Documentation updated.
-rw-r--r-- | linenoise/linenoise.c | 7 | ||||
-rw-r--r-- | txr.1 | 13 |
2 files changed, 9 insertions, 11 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index 266542c1..256553d4 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -2533,12 +2533,13 @@ wchar_t *linenoise(lino_t *ls, const wchar_t *prompt) int count; int ifd = lino_os.fileno_fn(ls->tty_ifs); - if ( ls->noninteractive || !isatty(ifd)) { + if (ls->noninteractive || !isatty(ifd)) { wchar_t *ret = 0; size_t len = 0, i; const wchar_t *condensed_prompt = prompt + wcslen(prompt); + int show_prompt = ls->show_prompt || (ls->noninteractive && isatty(ifd)); - if (ls->show_prompt) { + if (show_prompt) { while (condensed_prompt > prompt && (*condensed_prompt == 0 || *condensed_prompt == ' ')) { @@ -2549,7 +2550,7 @@ wchar_t *linenoise(lino_t *ls, const wchar_t *prompt) for (;;) { size_t nlen; - if (ls->show_prompt) + if (show_prompt) lino_os.puts_fn(ls->tty_ofs, ret ? condensed_prompt : prompt); /* Not a tty: read from file / pipe. */ @@ -82533,16 +82533,12 @@ incrementing the prompt number. The command prints just the current prompt number, followed by a newline, without incrementing the number. -The +In plain mode, the .code :prompt-on command enables the printing of prompts. The full prompt is printed before reading each new expression. An abbreviated prompt is printed before reading -the continuation lines of an incomplete expression. - -These commands are useful in plain mode, in which no prompts are -printed by default. See Plain Mode below. The -.code :prompt-on -command only has an effect in plain mode. +the continuation lines of an incomplete expression. The printing of prompts +is automatically enabled if the input device is an interactive terminal. None of these prompt-related commands are entered into the history. @@ -82558,7 +82554,8 @@ the listener operates in It reads input without providing any editing features: no completion, history recall, selection, or copy and paste. Only the line editing features provided by the operating system are available. -No prompts appear; however, there is still an incrementing counter, +Prompts appear if standard input is an interactive terminal, or +if explicitly enabled. There is still an incrementing counter, and the numbered variables .codn *1 , .codn *2 , |