about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorPaul Fertser <fercerpav@gmail.com>2022-04-12 11:40:48 +0300
committerPaul Fertser <fercerpav@gmail.com>2022-04-12 12:17:36 +0300
commitccede06a658bf609ba5cf5b536740d4983b02603 (patch)
tree268fe9f969b788d9c832ebd4fe5a4e15f2a136b8 /src/ui
parent026522534b0c70e36cb6d94b27515f7162d930a4 (diff)
downloadprofani-tty-ccede06a658bf609ba5cf5b536740d4983b02603.tar.gz
Handle input win redisplay via Readline hook
Allow Readline to control when to redisplay the input line. This makes
text entered via /editor visible after editor is closed.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/inputwin.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index de4a838b..60a0e36f 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -95,6 +95,7 @@ static int _inp_edited(const wint_t ch);
 static void _inp_win_handle_scroll(void);
 static int _inp_offset_to_col(char* str, int offset);
 static void _inp_write(char* line, int offset);
+static void _inp_redisplay(void);
 
 static void _inp_rl_addfuncs(void);
 static int _inp_rl_getc(FILE* stream);
@@ -149,6 +150,7 @@ create_input_window(void)
     rl_readline_name = "profanity";
     _inp_rl_addfuncs();
     rl_getc_function = _inp_rl_getc;
+    rl_redisplay_function = _inp_redisplay;
     rl_startup_hook = _inp_rl_startup_hook;
     rl_callback_handler_install(NULL, _inp_rl_linehandler);
 
@@ -190,9 +192,6 @@ inp_readline(void)
         }
 
         ui_reset_idle_time();
-        if (!get_password) {
-            _inp_write(rl_line_buffer, rl_point);
-        }
         inp_nonblocking(TRUE);
     } else {
         inp_nonblocking(FALSE);
@@ -585,6 +584,14 @@ _inp_rl_getc(FILE* stream)
     return ch;
 }
 
+static void
+_inp_redisplay(void)
+{
+    if (!get_password) {
+        _inp_write(rl_line_buffer, rl_point);
+    }
+}
+
 static int
 _inp_rl_win_clear_handler(int count, int key)
 {