From 651405ff6f04de99a700781591eedcf0417e4761 Mon Sep 17 00:00:00 2001 From: james Date: Fri, 2 Dec 2016 23:39:07 -0500 Subject: [PATCH 1/5] Fix for character limited reads. This fixes things like read -e and yaourt. Also added a test because this is like the thrid time I've fixed this bug and we really needed one. --- athame.c | 16 +++++++--------- readline.patch | 14 ++++++++++++-- test/shell/expected5 | 2 ++ test/shell/inst5.sh | 6 ++++++ 4 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 test/shell/expected5 create mode 100644 test/shell/inst5.sh diff --git a/athame.c b/athame.c index ad8badb..6482c86 100644 --- a/athame.c +++ b/athame.c @@ -340,14 +340,12 @@ void athame_after_bypass() { // Redraw bottom stuff before handing off to a process that might block, // like python. void athame_char_handled() { - if (athame_is_set("ATHAME_ENABLED", 1) && !ap_needs_to_leave()) { - if(athame_failure) - { - athame_draw_failure(); - } - else - { - athame_bottom_mode(); - } + if(athame_failure) + { + athame_draw_failure(); + } + else + { + athame_bottom_mode(); } } diff --git a/readline.patch b/readline.patch index e7756a0..fff9402 100644 --- a/readline.patch +++ b/readline.patch @@ -138,12 +138,13 @@ diff -ru a/readline.c b/readline.c /* Restore the original of this history line, iff the line that we are editing was originally in the history, AND the line has changed. */ entry = current_history (); -@@ -561,7 +566,14 @@ +@@ -561,7 +566,16 @@ } RL_SETSTATE(RL_STATE_READCMD); - c = rl_read_key (); -+ if (athame_enabled()) ++ int use_athame = athame_enabled(); ++ if (use_athame) + { + c = athame_loop(fileno(rl_instream)); + } @@ -151,6 +152,7 @@ diff -ru a/readline.c b/readline.c + c = rl_read_key(); + athame_after_bypass(); + } ++ if (!use_athame || c) { RL_UNSETSTATE(RL_STATE_READCMD); /* look at input.c:rl_getc() for the circumstances under which this will @@ -162,6 +164,14 @@ diff -ru a/readline.c b/readline.c RL_CHECK_SIGNALS (); /* If there was no change in _rl_last_command_was_kill, then no kill +@@ -608,6 +623,7 @@ + if (rl_pending_input == 0 && lk == _rl_last_command_was_kill) + _rl_last_command_was_kill = 0; + ++} + _rl_internal_char_cleanup (); + + #if defined (READLINE_CALLBACKS) diff -ru a/shlib/Makefile.in b/shlib/Makefile.in --- a/shlib/Makefile.in 2015-07-15 00:03:32.898231038 -0400 +++ b/shlib/Makefile.in 2015-07-14 23:37:04.674826478 -0400 diff --git a/test/shell/expected5 b/test/shell/expected5 new file mode 100644 index 0000000..29159de --- /dev/null +++ b/test/shell/expected5 @@ -0,0 +1,2 @@ +good +yay diff --git a/test/shell/inst5.sh b/test/shell/inst5.sh new file mode 100644 index 0000000..bc3bd44 --- /dev/null +++ b/test/shell/inst5.sh @@ -0,0 +1,6 @@ +input=0 +read -e input +good +echo $input > out5 +read -en3 input +yayecho $input >> out5 From 4bbf658c213b66123495d2014191b83fcbb4afe0 Mon Sep 17 00:00:00 2001 From: james Date: Sat, 3 Dec 2016 04:21:02 -0500 Subject: [PATCH 2/5] Partial revert of last commit. This code is definitly still needed. --- athame.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/athame.c b/athame.c index 6482c86..ad8badb 100644 --- a/athame.c +++ b/athame.c @@ -340,12 +340,14 @@ void athame_after_bypass() { // Redraw bottom stuff before handing off to a process that might block, // like python. void athame_char_handled() { - if(athame_failure) - { - athame_draw_failure(); - } - else - { - athame_bottom_mode(); + if (athame_is_set("ATHAME_ENABLED", 1) && !ap_needs_to_leave()) { + if(athame_failure) + { + athame_draw_failure(); + } + else + { + athame_bottom_mode(); + } } } From 761dd1bc17ecf0e68ecf9bce612cf6463ace12c1 Mon Sep 17 00:00:00 2001 From: james Date: Sat, 3 Dec 2016 05:07:05 -0500 Subject: [PATCH 3/5] Updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b6e7265..770b0a2 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ This should include libreadline. If it doesn't, you need to build bash to use th Control-C usually sends a SIGNINT signal that is handled by zsh, readline, or the program that calls readline. For other keys: -- In readline, chars marked as rl_delete (usually Control-D), rl_newline (usually return), rl_complete (usually tab), and rl_clear_screen (usually Control-L) are sent to readline. All other keys are sent to vim. +- In readline, chars marked as rl_delete (usually Control-D), rl_newline (usually return), rl_complete (usually tab), and rl_clear_screen (usually Control-L) are sent to readline. All other keys are sent to vim. This means that if you use readline's built-in vi-mode, Control-L and Control-D probably won't be sent to the shell. - In zsh, Athame is hardcoded to send tab, Control-D, carriage return, new line, and Control-L to zsh. All other keys are sent to vim. This behavior will likely change in the future. ####I got the error "Couldn't load vim path" From a154cf9f268722ca1ae157313c149905ca518310 Mon Sep 17 00:00:00 2001 From: james Date: Sat, 3 Dec 2016 05:08:10 -0500 Subject: [PATCH 4/5] Update athamerc for vim 8.0 --- athamerc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/athamerc b/athamerc index ba72fd6..bb03217 100644 --- a/athamerc +++ b/athamerc @@ -18,7 +18,7 @@ set textwidth=0 "Don't try to wrap text startinsert "Start in insert mode. Most shell vi-modes do this. " These make arrows more shell like. Feel free to comment them out: -if has("patch928") +if v:version>=800 || has("patch928") " These maps can segfault in earlier vim versions. inoremap A inoremap A From 8a712798e3d061cb428960ded29005707e5a5368 Mon Sep 17 00:00:00 2001 From: james Date: Sat, 3 Dec 2016 05:41:03 -0500 Subject: [PATCH 5/5] Fix command mode display bug Command mode wasn't getting displayed on update. This wasn't obvious except in python because it was still changing from signals, which often happen in command mode. This was fixed by registering changes in command mode as changes. This was previously avoided because of out-of-sync meta/text but that is no longer a problem thanks to slices. --- athame_util.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/athame_util.h b/athame_util.h index e276678..3b47bd1 100644 --- a/athame_util.h +++ b/athame_util.h @@ -976,10 +976,12 @@ static int athame_get_vim_info_inner() } if (command) { - setenv("ATHAME_VIM_COMMAND", command, 1); - strcpy(athame_command, command); - command_cursor = cmd_pos; - // Don't record a change because the highlight for incsearch might not have changed yet. + if(strcmp(athame_command, command) !=0 || command_cursor != cmd_pos) { + setenv("ATHAME_VIM_COMMAND", command, 1); + strcpy(athame_command, command); + command_cursor = cmd_pos; + changed =1; + } } } else