diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2017-11-07 18:53:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-07 18:53:42 +0100 |
commit | 06fd32b8ffc437d596a2d82a986220add4315869 (patch) | |
tree | c75ff6c7621879923d24632f0ce0bf06a5a60fb9 /src | |
parent | 52748d266ddbb73e0c759a5251ecbeda1c5fcade (diff) | |
download | rneovim-06fd32b8ffc437d596a2d82a986220add4315869.tar.gz rneovim-06fd32b8ffc437d596a2d82a986220add4315869.tar.bz2 rneovim-06fd32b8ffc437d596a2d82a986220add4315869.zip |
ui: remove ext_cmdline noise (#7486)
Only send cmdline contents once per ui_flush.
Don't send extra redraws due to 'arshape', it makes no difference to
external ui.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_getln.c | 51 | ||||
-rw-r--r-- | src/nvim/ui.c | 2 |
2 files changed, 46 insertions, 7 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 27883997e4..43e7cf457d 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -91,6 +91,13 @@ typedef struct { CmdlineColors colors; ///< Last colors. } ColoredCmdline; +/// Keeps track how much state must be sent to external ui. +typedef enum { + kCmdRedrawNone, + kCmdRedrawPos, + kCmdRedrawAll, +} CmdRedraw; + /* * Variables shared between getcmdline(), redrawcmdline() and others. * These need to be saved when using CTRL-R |, that's why they are in a @@ -120,6 +127,7 @@ struct cmdline_info { struct cmdline_info *prev_ccline; ///< pointer to saved cmdline state char special_char; ///< last putcmdline char (used for redraws) bool special_shift; ///< shift of last putcmdline char + CmdRedraw redraw_state; ///< needed redraw for external cmdline }; /// Last value of prompt_id, incremented when doing new prompt static unsigned last_prompt_id = 0; @@ -423,6 +431,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) ccline.cmdbuff = NULL; if (ui_is_external(kUICmdline)) { + ccline.redraw_state = kCmdRedrawNone; ui_call_cmdline_hide(ccline.level); } ccline.level--; @@ -1816,7 +1825,8 @@ static int command_line_changed(CommandLineState *s) // right-left typing. Not efficient, but it works. // Do it only when there are no characters left to read // to avoid useless intermediate redraws. - if (vpeekc() == NUL) { + // if cmdline is external the ui handles shaping, no redraw needed. + if (!ui_is_external(kUICmdline) && vpeekc() == NUL) { redrawcmd(); } } @@ -2614,7 +2624,7 @@ static void draw_cmdline(int start, int len) if (ui_is_external(kUICmdline)) { ccline.special_char = NUL; - ui_ext_cmdline_show(&ccline); + ccline.redraw_state = kCmdRedrawAll; return; } @@ -2826,7 +2836,7 @@ void cmdline_screen_cleared(void) if (prev_ccline->level == prev_level) { // don't redraw a cmdline already shown in the cmdline window if (prev_level != cmdwin_level) { - ui_ext_cmdline_show(prev_ccline); + prev_ccline->redraw_state = kCmdRedrawAll; } prev_level--; } @@ -2834,6 +2844,28 @@ void cmdline_screen_cleared(void) } } +/// called by ui_flush, do what redraws neccessary to keep cmdline updated. +void cmdline_ui_flush(void) +{ + if (!ui_is_external(kUICmdline)) { + return; + } + int level = ccline.level; + CmdlineInfo *line = &ccline; + while (level > 0 && line) { + if (line->level == level) { + if (line->redraw_state == kCmdRedrawAll) { + ui_ext_cmdline_show(line); + } else if (line->redraw_state == kCmdRedrawPos) { + ui_call_cmdline_pos(line->cmdpos, line->level); + } + line->redraw_state = kCmdRedrawNone; + level--; + } + line = line->prev_ccline; + } +} + /* * Put a character on the command line. Shifts the following text to the * right when "shift" is TRUE. Used for CTRL-V, CTRL-K, etc. @@ -2854,8 +2886,10 @@ void putcmdline(int c, int shift) } else { ccline.special_char = c; ccline.special_shift = shift; - ui_call_cmdline_special_char(cchar_to_string((char)(c)), shift, - ccline.level); + if (ccline.redraw_state != kCmdRedrawAll) { + ui_call_cmdline_special_char(cchar_to_string((char)(c)), shift, + ccline.level); + } } cursorcmd(); ui_cursor_shape(); @@ -3196,7 +3230,7 @@ static void redrawcmdprompt(void) if (cmd_silent) return; if (ui_is_external(kUICmdline)) { - ui_ext_cmdline_show(&ccline); + ccline.redraw_state = kCmdRedrawAll; return; } if (ccline.cmdfirstc != NUL) { @@ -3273,7 +3307,9 @@ static void cursorcmd(void) return; if (ui_is_external(kUICmdline)) { - ui_call_cmdline_pos(ccline.cmdpos, ccline.level); + if (ccline.redraw_state < kCmdRedrawPos) { + ccline.redraw_state = kCmdRedrawPos; + } return; } @@ -5867,6 +5903,7 @@ static int ex_window(void) changed_line_abv_curs(); invalidate_botline(); if (ui_is_external(kUICmdline)) { + ccline.redraw_state = kCmdRedrawNone; ui_call_cmdline_hide(ccline.level); } redraw_later(SOME_VALID); diff --git a/src/nvim/ui.c b/src/nvim/ui.c index afe7a51d43..3b8b3ac9a7 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -14,6 +14,7 @@ #include "nvim/cursor.h" #include "nvim/diff.h" #include "nvim/ex_cmds2.h" +#include "nvim/ex_getln.h" #include "nvim/fold.h" #include "nvim/main.h" #include "nvim/ascii.h" @@ -484,6 +485,7 @@ int ui_current_col(void) void ui_flush(void) { + cmdline_ui_flush(); ui_call_flush(); } |