diff options
author | Michael Vetter <jubalh@iodoru.org> | 2019-10-23 12:00:34 +0200 |
---|---|---|
committer | Michael Vetter <jubalh@iodoru.org> | 2019-11-05 17:18:42 +0100 |
commit | 330ef3bcf3f78b0e3844c042b480c8484e22f777 (patch) | |
tree | 02a79b627d6918cbbb7197e3719fc739fb49dc93 /src/ui | |
parent | 643d12af445bc7bbda4d9f90acf63bd2b77b5098 (diff) | |
download | profani-tty-330ef3bcf3f78b0e3844c042b480c8484e22f777.tar.gz |
Store current input line in history
Regards https://github.com/profanity-im/profanity/issues/200 This doesn't work yet. And I have no idea why. Weird behaviour: - start profanity - type 'ASDF' - ctrl+arrow down -> text vanishes (like intended) - arrow up -> nothing happens (intended is that the last history item [ASDF] appears) - type 'ABC' - press enter - arrow up -> ABC appears - enter - type 'UUU' - ctrl+arrow down - type 'ZZZ' - enter - arrow up - ZZZ appears - arrow up - UUU appears So in the latter case we added to history and deleted from the input line and then immediately entered new text and pressed enter, to add this to the history too. When we do this the not sent text succesfully was stored in history.
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/inputwin.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 44d0091e..db42c5a8 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -127,6 +127,7 @@ static int _inp_rl_win_pagedown_handler(int count, int key); static int _inp_rl_subwin_pageup_handler(int count, int key); static int _inp_rl_subwin_pagedown_handler(int count, int key); static int _inp_rl_startup_hook(void); +static int _inp_rl_down_arrow_handler(int count, int key); void create_input_window(void) @@ -476,6 +477,8 @@ _inp_rl_startup_hook(void) rl_bind_key('\t', _inp_rl_tab_handler); rl_bind_keyseq("\\e[Z", _inp_rl_shift_tab_handler); + rl_bind_keyseq("\\e[1;5B", _inp_rl_down_arrow_handler); // ctrl+arrow down + // unbind unwanted mappings rl_bind_keyseq("\\e=", NULL); @@ -814,3 +817,16 @@ _inp_rl_subwin_pagedown_handler(int count, int key) win_sub_page_down(current); return 0; } + +static int +_inp_rl_down_arrow_handler(int count, int key) +{ + add_history(rl_line_buffer); + //also tried: add_history(rl_copy_text(0, rl_end)); + //also tried: add_history("Hello"); + rl_replace_line("", 0); + rl_redisplay(); + rl_end = 0; // why is this neeed? shouln't replace_line do this? + rl_point = 0; // why is this neeed? shouln't replace_line do this? + return 0; +} |