rename ui_is_external to ui_has (#9576)

This commit is contained in:
Justin M. Keyes
2019-02-03 16:42:44 +01:00
committed by GitHub
parent 79a0ea2bec
commit 01b4efe9d9
8 changed files with 40 additions and 46 deletions

View File

@@ -2494,10 +2494,6 @@ static pumitem_T *compl_match_array = NULL;
static int compl_match_arraysize; static int compl_match_arraysize;
/*
* Update the screen and when there is any scrolling remove the popup menu.
*/
/* /*
* Remove any popup menu. * Remove any popup menu.
*/ */

View File

@@ -11265,7 +11265,7 @@ void get_user_input(const typval_T *const argvars,
// Only the part of the message after the last NL is considered as // Only the part of the message after the last NL is considered as
// prompt for the command line, unlsess cmdline is externalized // prompt for the command line, unlsess cmdline is externalized
const char *p = prompt; const char *p = prompt;
if (!ui_is_external(kUICmdline)) { if (!ui_has(kUICmdline)) {
const char *lastnl = strrchr(prompt, '\n'); const char *lastnl = strrchr(prompt, '\n');
if (lastnl != NULL) { if (lastnl != NULL) {
p = lastnl+1; p = lastnl+1;
@@ -19951,7 +19951,7 @@ void ex_function(exarg_T *eap)
goto errret_2; goto errret_2;
} }
if (KeyTyped && ui_is_external(kUICmdline)) { if (KeyTyped && ui_has(kUICmdline)) {
show_block = true; show_block = true;
ui_ext_cmdline_block_append(0, (const char *)eap->cmd); ui_ext_cmdline_block_append(0, (const char *)eap->cmd);
} }
@@ -20007,7 +20007,7 @@ void ex_function(exarg_T *eap)
if (!eap->skip && did_emsg) if (!eap->skip && did_emsg)
goto erret; goto erret;
if (!ui_is_external(kUICmdline)) { if (!ui_has(kUICmdline)) {
msg_putchar('\n'); // don't overwrite the function name msg_putchar('\n'); // don't overwrite the function name
} }
cmdline_row = msg_row; cmdline_row = msg_row;

View File

@@ -494,7 +494,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent)
char_u *p = ccline.cmdbuff; char_u *p = ccline.cmdbuff;
if (ui_is_external(kUICmdline)) { if (ui_has(kUICmdline)) {
ui_call_cmdline_hide(ccline.level); ui_call_cmdline_hide(ccline.level);
} }
@@ -614,7 +614,7 @@ static int command_line_execute(VimState *state, int key)
if (!(s->c == p_wc && KeyTyped) && s->c != p_wcm if (!(s->c == p_wc && KeyTyped) && s->c != p_wcm
&& s->c != Ctrl_N && s->c != Ctrl_P && s->c != Ctrl_A && s->c != Ctrl_N && s->c != Ctrl_P && s->c != Ctrl_A
&& s->c != Ctrl_L) { && s->c != Ctrl_L) {
if (ui_is_external(kUIWildmenu)) { if (ui_has(kUIWildmenu)) {
ui_call_wildmenu_hide(); ui_call_wildmenu_hide();
} }
if (s->xpc.xp_numfiles != -1) { if (s->xpc.xp_numfiles != -1) {
@@ -896,7 +896,7 @@ static int command_line_execute(VimState *state, int key)
} }
if (!cmd_silent) { if (!cmd_silent) {
if (!ui_is_external(kUICmdline)) { if (!ui_has(kUICmdline)) {
ui_cursor_goto(msg_row, 0); ui_cursor_goto(msg_row, 0);
} }
ui_flush(); ui_flush();
@@ -1254,7 +1254,7 @@ static int command_line_handle_key(CommandLineState *s)
xfree(ccline.cmdbuff); // no commandline to return xfree(ccline.cmdbuff); // no commandline to return
ccline.cmdbuff = NULL; ccline.cmdbuff = NULL;
if (!cmd_silent && !ui_is_external(kUICmdline)) { if (!cmd_silent && !ui_has(kUICmdline)) {
if (cmdmsg_rl) { if (cmdmsg_rl) {
msg_col = Columns; msg_col = Columns;
} else { } else {
@@ -1704,7 +1704,7 @@ static int command_line_handle_key(CommandLineState *s)
s->do_abbr = false; // don't do abbreviation now s->do_abbr = false; // don't do abbreviation now
// may need to remove ^ when composing char was typed // may need to remove ^ when composing char was typed
if (enc_utf8 && utf_iscomposing(s->c) && !cmd_silent) { if (enc_utf8 && utf_iscomposing(s->c) && !cmd_silent) {
if (ui_is_external(kUICmdline)) { if (ui_has(kUICmdline)) {
// TODO(bfredl): why not make unputcmdline also work with true? // TODO(bfredl): why not make unputcmdline also work with true?
unputcmdline(); unputcmdline();
} else { } else {
@@ -1968,7 +1968,7 @@ static int command_line_changed(CommandLineState *s)
// Do it only when there are no characters left to read // Do it only when there are no characters left to read
// to avoid useless intermediate redraws. // to avoid useless intermediate redraws.
// if cmdline is external the ui handles shaping, no redraw needed. // if cmdline is external the ui handles shaping, no redraw needed.
if (!ui_is_external(kUICmdline) && vpeekc() == NUL) { if (!ui_has(kUICmdline) && vpeekc() == NUL) {
redrawcmd(); redrawcmd();
} }
} }
@@ -2835,7 +2835,7 @@ static void draw_cmdline(int start, int len)
return; return;
} }
if (ui_is_external(kUICmdline)) { if (ui_has(kUICmdline)) {
ccline.special_char = NUL; ccline.special_char = NUL;
ccline.redraw_state = kCmdRedrawAll; ccline.redraw_state = kCmdRedrawAll;
return; return;
@@ -3028,7 +3028,7 @@ void ui_ext_cmdline_block_leave(void)
/// assumes "redrawcmdline()" will already be invoked /// assumes "redrawcmdline()" will already be invoked
void cmdline_screen_cleared(void) void cmdline_screen_cleared(void)
{ {
if (!ui_is_external(kUICmdline)) { if (!ui_has(kUICmdline)) {
return; return;
} }
@@ -3053,7 +3053,7 @@ void cmdline_screen_cleared(void)
/// called by ui_flush, do what redraws neccessary to keep cmdline updated. /// called by ui_flush, do what redraws neccessary to keep cmdline updated.
void cmdline_ui_flush(void) void cmdline_ui_flush(void)
{ {
if (!ui_is_external(kUICmdline)) { if (!ui_has(kUICmdline)) {
return; return;
} }
int level = ccline.level; int level = ccline.level;
@@ -3082,7 +3082,7 @@ void putcmdline(int c, int shift)
if (cmd_silent) { if (cmd_silent) {
return; return;
} }
if (!ui_is_external(kUICmdline)) { if (!ui_has(kUICmdline)) {
msg_no_more = true; msg_no_more = true;
msg_putchar(c); msg_putchar(c);
if (shift) { if (shift) {
@@ -3108,7 +3108,7 @@ void unputcmdline(void)
return; return;
} }
msg_no_more = true; msg_no_more = true;
if (ccline.cmdlen == ccline.cmdpos && !ui_is_external(kUICmdline)) { if (ccline.cmdlen == ccline.cmdpos && !ui_has(kUICmdline)) {
msg_putchar(' '); msg_putchar(' ');
} else { } else {
draw_cmdline(ccline.cmdpos, mb_ptr2len(ccline.cmdbuff + ccline.cmdpos)); draw_cmdline(ccline.cmdpos, mb_ptr2len(ccline.cmdbuff + ccline.cmdpos));
@@ -3423,7 +3423,7 @@ static void redrawcmdprompt(void)
if (cmd_silent) if (cmd_silent)
return; return;
if (ui_is_external(kUICmdline)) { if (ui_has(kUICmdline)) {
ccline.redraw_state = kCmdRedrawAll; ccline.redraw_state = kCmdRedrawAll;
return; return;
} }
@@ -3452,7 +3452,7 @@ void redrawcmd(void)
if (cmd_silent) if (cmd_silent)
return; return;
if (ui_is_external(kUICmdline)) { if (ui_has(kUICmdline)) {
draw_cmdline(0, ccline.cmdlen); draw_cmdline(0, ccline.cmdlen);
return; return;
} }
@@ -3500,7 +3500,7 @@ static void cursorcmd(void)
if (cmd_silent) if (cmd_silent)
return; return;
if (ui_is_external(kUICmdline)) { if (ui_has(kUICmdline)) {
if (ccline.redraw_state < kCmdRedrawPos) { if (ccline.redraw_state < kCmdRedrawPos) {
ccline.redraw_state = kCmdRedrawPos; ccline.redraw_state = kCmdRedrawPos;
} }
@@ -3525,7 +3525,7 @@ static void cursorcmd(void)
void gotocmdline(int clr) void gotocmdline(int clr)
{ {
if (ui_is_external(kUICmdline)) { if (ui_has(kUICmdline)) {
return; return;
} }
msg_start(); msg_start();
@@ -3613,7 +3613,7 @@ nextwild (
return FAIL; return FAIL;
} }
if (!ui_is_external(kUIWildmenu)) { if (!ui_has(kUIWildmenu)) {
MSG_PUTS("..."); // show that we are busy MSG_PUTS("..."); // show that we are busy
ui_flush(); ui_flush();
} }
@@ -3763,7 +3763,7 @@ ExpandOne (
findex = -1; findex = -1;
} }
if (p_wmnu) { if (p_wmnu) {
if (ui_is_external(kUIWildmenu)) { if (ui_has(kUIWildmenu)) {
ui_call_wildmenu_select(findex); ui_call_wildmenu_select(findex);
} else { } else {
win_redr_status_matches(xp, xp->xp_numfiles, xp->xp_files, win_redr_status_matches(xp, xp->xp_numfiles, xp->xp_files,
@@ -4118,7 +4118,7 @@ static int showmatches(expand_T *xp, int wildmenu)
showtail = cmd_showtail; showtail = cmd_showtail;
} }
if (ui_is_external(kUIWildmenu)) { if (ui_has(kUIWildmenu)) {
Array args = ARRAY_DICT_INIT; Array args = ARRAY_DICT_INIT;
for (i = 0; i < num_files; i++) { for (i = 0; i < num_files; i++) {
ADD(args, STRING_OBJ(cstr_to_string((char *)files_found[i]))); ADD(args, STRING_OBJ(cstr_to_string((char *)files_found[i])));
@@ -6124,7 +6124,7 @@ static int open_cmdwin(void)
curwin->w_cursor.col = ccline.cmdpos; curwin->w_cursor.col = ccline.cmdpos;
changed_line_abv_curs(); changed_line_abv_curs();
invalidate_botline(); invalidate_botline();
if (ui_is_external(kUICmdline)) { if (ui_has(kUICmdline)) {
ccline.redraw_state = kCmdRedrawNone; ccline.redraw_state = kCmdRedrawNone;
ui_call_cmdline_hide(ccline.level); ui_call_cmdline_hide(ccline.level);
} }

View File

@@ -82,7 +82,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed)
if (!pum_is_visible) { if (!pum_is_visible) {
// To keep the code simple, we only allow changing the // To keep the code simple, we only allow changing the
// draw mode when the popup menu is not being displayed // draw mode when the popup menu is not being displayed
pum_external = ui_is_external(kUIPopupmenu); pum_external = ui_has(kUIPopupmenu);
} }
do { do {
@@ -103,7 +103,7 @@ void pum_display(pumitem_T *array, int size, int selected, bool array_changed)
} }
int grid = (int)curwin->w_grid.handle; int grid = (int)curwin->w_grid.handle;
if (!ui_is_external(kUIMultigrid)) { if (!ui_has(kUIMultigrid)) {
grid = (int)default_grid.handle; grid = (int)default_grid.handle;
row += curwin->w_winrow; row += curwin->w_winrow;
col += curwin->w_wincol; col += curwin->w_wincol;

View File

@@ -4209,7 +4209,7 @@ win_line (
&& lcs_eol_one != -1 // Haven't printed the lcs_eol character. && lcs_eol_one != -1 // Haven't printed the lcs_eol character.
&& row != endrow - 1 // Not the last line being displayed. && row != endrow - 1 // Not the last line being displayed.
&& (grid->Columns == Columns // Window spans the width of the screen, && (grid->Columns == Columns // Window spans the width of the screen,
|| ui_is_external(kUIMultigrid)) // or has dedicated grid. || ui_has(kUIMultigrid)) // or has dedicated grid.
&& !wp->w_p_rl; // Not right-to-left. && !wp->w_p_rl; // Not right-to-left.
grid_put_linebuf(grid, row, 0, col - boguscols, grid->Columns, wp->w_p_rl, grid_put_linebuf(grid, row, 0, col - boguscols, grid->Columns, wp->w_p_rl,
wp, wp->w_hl_attr_normal, wrap); wp, wp->w_hl_attr_normal, wrap);
@@ -4816,8 +4816,6 @@ win_redr_status_matches (
/// Redraw the status line of window `wp`. /// Redraw the status line of window `wp`.
/// ///
/// If inversion is possible we use it. Else '=' characters are used. /// If inversion is possible we use it. Else '=' characters are used.
/// If "ignore_pum" is true, also redraw statusline when the popup menu is
/// displayed.
static void win_redr_status(win_T *wp) static void win_redr_status(win_T *wp)
{ {
int row; int row;
@@ -4832,7 +4830,7 @@ static void win_redr_status(win_T *wp)
// invokes ":redrawstatus". Simply ignore the call then. // invokes ":redrawstatus". Simply ignore the call then.
if (busy if (busy
// Also ignore if wildmenu is showing. // Also ignore if wildmenu is showing.
|| (wild_menu_showing != 0 && !ui_is_external(kUIWildmenu))) { || (wild_menu_showing != 0 && !ui_has(kUIWildmenu))) {
return; return;
} }
busy = true; busy = true;
@@ -5929,7 +5927,7 @@ void win_grid_alloc(win_T *wp)
int cols = wp->w_width_inner; int cols = wp->w_width_inner;
// TODO(bfredl): floating windows should force this to true // TODO(bfredl): floating windows should force this to true
bool want_allocation = ui_is_external(kUIMultigrid); bool want_allocation = ui_has(kUIMultigrid);
bool has_allocation = (grid->chars != NULL); bool has_allocation = (grid->chars != NULL);
if (want_allocation && has_allocation && highlights_invalid) { if (want_allocation && has_allocation && highlights_invalid) {
@@ -5965,7 +5963,7 @@ void win_grid_alloc(win_T *wp)
// - a grid was just resized // - a grid was just resized
// - screen_resize was called and all grid sizes must be sent // - screen_resize was called and all grid sizes must be sent
// - the UI wants multigrid event (necessary) // - the UI wants multigrid event (necessary)
if ((send_grid_resize || was_resized) && ui_is_external(kUIMultigrid)) { if ((send_grid_resize || was_resized) && ui_has(kUIMultigrid)) {
ui_call_grid_resize(grid->handle, grid->Columns, grid->Rows); ui_call_grid_resize(grid->handle, grid->Columns, grid->Rows);
} }
} }
@@ -6025,8 +6023,8 @@ retry:
*/ */
++RedrawingDisabled; ++RedrawingDisabled;
// win_new_shellsize will recompute floats posititon, but tell the // win_new_shellsize will recompute floats position, but tell the
// compositor to now redraw them yet // compositor to not redraw them yet
ui_comp_invalidate_screen(); ui_comp_invalidate_screen();
win_new_shellsize(); /* fit the windows in the new sized shell */ win_new_shellsize(); /* fit the windows in the new sized shell */
@@ -6672,7 +6670,7 @@ static void draw_tabline(void)
} }
redraw_tabline = false; redraw_tabline = false;
if (ui_is_external(kUITabline)) { if (ui_has(kUITabline)) {
ui_ext_tabline_update(); ui_ext_tabline_update();
return; return;
} }

View File

@@ -6893,7 +6893,7 @@ void do_highlight(const char *line, const bool forceit, const bool init)
// "fg", which have been changed now. // "fg", which have been changed now.
highlight_attr_set_all(); highlight_attr_set_all();
if (!ui_is_external(kUILinegrid) && starting == 0) { if (!ui_has(kUILinegrid) && starting == 0) {
// Older UIs assume that we clear the screen after normal group is // Older UIs assume that we clear the screen after normal group is
// changed // changed
ui_refresh(); ui_refresh();

View File

@@ -413,10 +413,10 @@ void ui_cursor_shape(void)
conceal_check_cursor_line(); conceal_check_cursor_line();
} }
/// Returns true if `widget` is externalized. /// Returns true if the given UI extension is enabled.
bool ui_is_external(UIExtension widget) bool ui_has(UIExtension ext)
{ {
return ui_ext[widget]; return ui_ext[ext];
} }
Array ui_array(void) Array ui_array(void)

View File

@@ -3120,7 +3120,7 @@ int win_new_tabpage(int after, char_u *filename)
redraw_all_later(NOT_VALID); redraw_all_later(NOT_VALID);
if (ui_is_external(kUIMultigrid)) { if (ui_has(kUIMultigrid)) {
tabpage_check_windows(tp); tabpage_check_windows(tp);
} }
@@ -3321,7 +3321,7 @@ static void enter_tabpage(tabpage_T *tp, buf_T *old_curbuf, int trigger_enter_au
lastwin = tp->tp_lastwin; lastwin = tp->tp_lastwin;
topframe = tp->tp_topframe; topframe = tp->tp_topframe;
if (old_curtab != curtab && ui_is_external(kUIMultigrid)) { if (old_curtab != curtab && ui_has(kUIMultigrid)) {
tabpage_check_windows(old_curtab); tabpage_check_windows(old_curtab);
} }
@@ -4011,7 +4011,7 @@ win_free (
void win_free_grid(win_T *wp, bool reinit) void win_free_grid(win_T *wp, bool reinit)
{ {
if (wp->w_grid.handle != 0 && ui_is_external(kUIMultigrid)) { if (wp->w_grid.handle != 0 && ui_has(kUIMultigrid)) {
ui_call_grid_destroy(wp->w_grid.handle); ui_call_grid_destroy(wp->w_grid.handle);
wp->w_grid.handle = 0; wp->w_grid.handle = 0;
} }
@@ -5349,7 +5349,7 @@ static void last_status_rec(frame_T *fr, int statusline)
*/ */
int tabline_height(void) int tabline_height(void)
{ {
if (ui_is_external(kUITabline)) { if (ui_has(kUITabline)) {
return 0; return 0;
} }
assert(first_tabpage); assert(first_tabpage);
@@ -6086,7 +6086,7 @@ void win_findbuf(typval_T *argvars, list_T *list)
void win_ui_flush(void) void win_ui_flush(void)
{ {
if (!ui_is_external(kUIMultigrid)) { if (!ui_has(kUIMultigrid)) {
return; return;
} }