diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-09-16 06:22:42 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-09-16 06:22:42 -0700 |
commit | 70c93c1c95138d5c97bfabf25d83b79487f19f51 (patch) | |
tree | a43016b40c6c8f44bf7cfee8486db6e906a66d53 /txr.1 | |
parent | 3733d13790f3ec3da3f1396d01f57d08710982f9 (diff) | |
download | txr-70c93c1c95138d5c97bfabf25d83b79487f19f51.tar.gz txr-70c93c1c95138d5c97bfabf25d83b79487f19f51.tar.bz2 txr-70c93c1c95138d5c97bfabf25d83b79487f19f51.zip |
linenoise: enhanced multi-line mode with line breaks.
The linenoise multi-line mode is just a glorified line
wrapper, and not actualy a multi-line editor, like in GNU
Readline and others. This commit fixes it. The edit buffer can
now contain line breaks, separated by carriage return
characters. (In single-line mode, these characters continue
to be displayed as ^M). The row and column calculations in the
multi-line refresh follow this data representation.
* linenoise/linenoise.c (sync_data_to_buf): This function
now takes an extra argument telling it whether multi-line mode
is in effect for the rendering. In multi-line mode, the prompt
is now added to the display data, so that multi-line refresh
is simplified by not having to account for the prompt length
in various calculations. Also, in multi-line mode, carriage
returns are rendered to display as CR-LF pairs, since they
denote embedded line breaks.
(complete_line): Pass mlmode to sync_data_to_buf.
(struct row_values): New struct, for returning multiple
row values out of a function.
(screen_rows, col_offset_in_str): New static functions.
(refresh_multiline): Modified to use screen_rows and
col_offset_in_str for its calculations, and not to deal with
the prompt at all, since the prompt is rolled into the display
data.
(refresh_line, edit_insert): Pass mlmode to sync_data_to_buf.
* txr.1: Documented multi-line mode.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 36 |
1 files changed, 33 insertions, 3 deletions
@@ -33630,11 +33630,41 @@ and return to editing the original uncompleted line. Any other input character c the listener to keep the currently shown completion, and return to edit mode, where that that character is processed again as a command. +.SS* Multi-Line Mode + +The listener operates in one of two modes: line mode and multi-line mode. The +default operation on start-up is line mode. It is possible to toggle between +line mode and multi-line mode using the Ctrl-J command. + +In line mode, all input given to a single prompt appears to be on a single +line. When the line becomes longer than the screen width, it scrolls +horizontally. In line mode, carriage return characters embedded in a line +are displayed as +.codn ^M . + +In multi-line mode, when the input exceeds the screen width, it simply wraps to +take up additional lines rather than scrolling horizontally. Furthermore, +multi-line mode not only wraps long lines of input onto multiple lines of +the display, but also supports true multi-line input. In multi-line +mode, carriage return characters embedded in input are treated as line +breaks rather than being rendered as +.codn ^M . + +To insert a line break character, use the sequence: Ctrl-V, Ctrl-M. +Or, equivalently: Ctrl-V, Enter. + +Note that the Ctrl-K and Ctrl-U commands regard the entire input to be one +logical line, ignoring the line breaks. + +Because carriage returns are not line terminators in text files, +lines which contain embedded carriage returns are correctly saved +into and retrieved from the persistent history file. + .SS* Reading Forms Directly from the Terminal -The listener is currently line oriented. There is, however, support for -accepting input which may span multiple lines and come in a large -quantity. +In addition to multi-line mode, the listener provides support +for directly parsing input from the terminal, suitable for processing +large amounts of pasted material. If the .code :read |