summaryrefslogtreecommitdiffstats
path: root/linenoise/linenoise.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-10-02 07:05:40 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-10-02 07:05:40 -0700
commitb75a472f44d05977c00c7b3be4f3c3d203c38979 (patch)
tree0ccb3928ae48e2e37f66842234adc8bd75123580 /linenoise/linenoise.c
parentc4a66ad7ed5c74cda3a16b191c6763c1a5cedc6d (diff)
downloadtxr-b75a472f44d05977c00c7b3be4f3c3d203c38979.tar.gz
txr-b75a472f44d05977c00c7b3be4f3c3d203c38979.tar.bz2
txr-b75a472f44d05977c00c7b3be4f3c3d203c38979.zip
linenoise: Ctrl-X/Ctrl-[AWR] relative to hist pos.
* linenoise/linenoise.c (edit): The recall previous word, atom and line features now offset relative to the current navigation position in the history. Previous line means the line before the currently showing history line, not the line most recently entered into the history. * txr.1: Documented.
Diffstat (limited to 'linenoise/linenoise.c')
-rw-r--r--linenoise/linenoise.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c
index b5b9908f..973acce5 100644
--- a/linenoise/linenoise.c
+++ b/linenoise/linenoise.c
@@ -1733,8 +1733,9 @@ static int edit(lino_t *l, const char *prompt)
break;
case CTL('W'): case 'w':
extended = 0;
- if (l->history_len > 1 && extend_num != 0) {
- char *prev_line = l->history[l->history_len - 2];
+ if (l->history_len > 1 + l->history_index && extend_num != 0) {
+ char *prev_line = l->history[l->history_len - 2
+ - l->history_index];
char *word_end = prev_line + strlen(prev_line);
char *word_start = word_end;
@@ -1764,9 +1765,10 @@ static int edit(lino_t *l, const char *prompt)
extended = 0;
if (extend_num < 0)
extend_num = 1;
- if (l->history_len > 1 && l->atom_callback)
+ if (l->history_len > 1 + l->history_index && l->atom_callback)
{
- char *prev_line = l->history[l->history_len - 2];
+ char *prev_line = l->history[l->history_len - 2
+ - l->history_index];
char *word = l->atom_callback(l, prev_line,
extend_num, l->ca_ctx);
int res = 0;
@@ -1786,9 +1788,10 @@ static int edit(lino_t *l, const char *prompt)
extended = 0;
if (extend_num < 0)
extend_num = 1;
- if (l->history_len > extend_num) {
+ if (l->history_len > extend_num + l->history_index) {
char *prev_line = l->history[l->history_len - 1
- - extend_num];
+ - extend_num
+ - l->history_index];
int res = edit_insert_str(l, prev_line, strlen(prev_line));
if (res) {
l->error = lino_ioerr;