mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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.
This commit is contained in:
parent
52748d266d
commit
06fd32b8ff
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user