diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-10-02 06:48:26 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-10-02 06:48:26 -0700 |
commit | bfd251f813aee284d9cd3886a5aeffdb58497ea6 (patch) | |
tree | ddfeeffd6197f76e423e0ca75ef73cd6eaa23afa | |
parent | 19b8654f3cc6b51e8c22138b42bee7031bef151a (diff) | |
download | txr-bfd251f813aee284d9cd3886a5aeffdb58497ea6.tar.gz txr-bfd251f813aee284d9cd3886a5aeffdb58497ea6.tar.bz2 txr-bfd251f813aee284d9cd3886a5aeffdb58497ea6.zip |
linenoise: insert previous line command.
* linenoise/linenoise.c (edit): Extended Ctrl-X Ctrl-R/r
command added.
* txr.1: Documented.
-rw-r--r-- | linenoise/linenoise.c | 14 | ||||
-rw-r--r-- | txr.1 | 8 |
2 files changed, 22 insertions, 0 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index de12bdb4..b5b9908f 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -1782,6 +1782,20 @@ static int edit(lino_t *l, const char *prompt) } } break; + case CTL('R'): case 'r': + extended = 0; + if (extend_num < 0) + extend_num = 1; + if (l->history_len > extend_num) { + char *prev_line = l->history[l->history_len - 1 + - extend_num]; + int res = edit_insert_str(l, prev_line, strlen(prev_line)); + if (res) { + l->error = lino_ioerr; + goto out; + } + } + break; case CTL('Q'): extended = 0; { @@ -34227,6 +34227,14 @@ Only the most recent three decimal digits are retained, so the number can range from 0 to 999. A value of 0, or a value which exceeds the number of words causes the Ctrl-A or a to do nothing. +.NP* Insert Previous Line + +The command sequences Ctrl-X, Ctrl-R ("repeat") and Ctrl-X, r, which are +equivalent, insert an entire line of history into the current buffer. By +default, the previous line is inserted. A less recent line can be selected by +typing a numeric argument between the Ctrl-X and the Ctrl-R/r. The immediately +previous history line is numbered 1, the one before it 2 and so on. + .NP* Symbolic Completion If the Tab key is pressed while editing a line, it is interpreted as a |