diff options
Diffstat (limited to 'src/nvim/message.c')
-rw-r--r-- | src/nvim/message.c | 78 |
1 files changed, 38 insertions, 40 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index f4ef91d1b7..49549bcc26 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -24,7 +24,7 @@ #include "nvim/getchar.h" #include "nvim/highlight.h" #include "nvim/input.h" -#include "nvim/keymap.h" +#include "nvim/keycodes.h" #include "nvim/main.h" #include "nvim/mbyte.h" #include "nvim/memory.h" @@ -162,7 +162,7 @@ void msg_grid_validate(void) { grid_assign_handle(&msg_grid); bool should_alloc = msg_use_grid(); - if (should_alloc && (msg_grid.Rows != Rows || msg_grid.Columns != Columns + if (should_alloc && (msg_grid.rows != Rows || msg_grid.cols != Columns || !msg_grid.chars)) { // TODO(bfredl): eventually should be set to "invalid". I e all callers // will use the grid including clear to EOS if necessary. @@ -174,9 +174,9 @@ void msg_grid_validate(void) // Tricky: allow resize while pager is active int pos = msg_scrolled ? msg_grid_pos : Rows - p_ch; - ui_comp_put_grid(&msg_grid, pos, 0, msg_grid.Rows, msg_grid.Columns, + ui_comp_put_grid(&msg_grid, pos, 0, msg_grid.rows, msg_grid.cols, false, true); - ui_call_grid_resize(msg_grid.handle, msg_grid.Columns, msg_grid.Rows); + ui_call_grid_resize(msg_grid.handle, msg_grid.cols, msg_grid.rows); msg_grid.throttled = false; // don't throttle in 'cmdheight' area msg_scrolled_at_flush = msg_scrolled; @@ -586,7 +586,7 @@ void msg_source(int attr) if (sourcing_name == NULL) { last_sourcing_name = NULL; } else { - last_sourcing_name = vim_strsave(sourcing_name); + last_sourcing_name = vim_strsave((char_u *)sourcing_name); } } --no_wait_return; @@ -598,8 +598,8 @@ void msg_source(int attr) /// If "emsg_skip" is set: never do error messages. int emsg_not_now(void) { - if ((emsg_off > 0 && vim_strchr(p_debug, 'm') == NULL - && vim_strchr(p_debug, 't') == NULL) + if ((emsg_off > 0 && vim_strchr((char *)p_debug, 'm') == NULL + && vim_strchr((char *)p_debug, 't') == NULL) || emsg_skip > 0) { return TRUE; } @@ -623,14 +623,12 @@ static bool emsg_multiline(const char *s, bool multiline) bool severe = emsg_severe; emsg_severe = false; - if (!emsg_off || vim_strchr(p_debug, 't') != NULL) { - /* - * Cause a throw of an error exception if appropriate. Don't display - * the error message in this case. (If no matching catch clause will - * be found, the message will be displayed later on.) "ignore" is set - * when the message should be ignored completely (used for the - * interrupt message). - */ + if (!emsg_off || vim_strchr((char *)p_debug, 't') != NULL) { + // Cause a throw of an error exception if appropriate. Don't display + // the error message in this case. (If no matching catch clause will + // be found, the message will be displayed later on.) "ignore" is set + // when the message should be ignored completely (used for the + // interrupt message). if (cause_errthrow(s, severe, &ignore)) { if (!ignore) { did_emsg++; @@ -1125,7 +1123,7 @@ void wait_return(int redraw) // just changed. screenalloc(); - State = HITRETURN; + State = MODE_HITRETURN; setmouse(); cmdline_row = msg_row; // Avoid the sequence that the user types ":" at the hit-return prompt @@ -1212,7 +1210,7 @@ void wait_return(int redraw) if (c == K_LEFTMOUSE || c == K_MIDDLEMOUSE || c == K_RIGHTMOUSE || c == K_X1MOUSE || c == K_X2MOUSE) { (void)jump_to_mouse(MOUSE_SETPOS, NULL, 0); - } else if (vim_strchr((char_u *)"\r\n ", c) == NULL && c != Ctrl_C) { + } else if (vim_strchr("\r\n ", c) == NULL && c != Ctrl_C) { // Put the character back in the typeahead buffer. Don't use the // stuff buffer, because lmaps wouldn't work. ins_char_typebuf(vgetc_char, vgetc_mod_mask); @@ -1250,7 +1248,7 @@ void wait_return(int redraw) XFREE_CLEAR(keep_msg); // don't redisplay message, it's too long } - if (tmpState == SETWSIZE) { // got resize event while in vgetc() + if (tmpState == MODE_SETWSIZE) { // got resize event while in vgetc() ui_refresh(); } else if (!skip_redraw) { if (redraw == true || (msg_scrolled != 0 && redraw != -1)) { @@ -2186,7 +2184,7 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs if (lines_left > 0) { --lines_left; } - if (p_more && lines_left == 0 && State != HITRETURN + if (p_more && lines_left == 0 && State != MODE_HITRETURN && !msg_no_more && !exmode_active) { if (do_more_prompt(NUL)) { s = confirm_msg_tail; @@ -2322,10 +2320,10 @@ void msg_scroll_up(bool may_throttle) if (msg_grid_pos > 0) { msg_grid_set_pos(msg_grid_pos - 1, true); } else { - grid_del_lines(&msg_grid, 0, 1, msg_grid.Rows, 0, msg_grid.Columns); + grid_del_lines(&msg_grid, 0, 1, msg_grid.rows, 0, msg_grid.cols); memmove(msg_grid.dirty_col, msg_grid.dirty_col + 1, - (msg_grid.Rows - 1) * sizeof(*msg_grid.dirty_col)); - msg_grid.dirty_col[msg_grid.Rows - 1] = 0; + (msg_grid.rows - 1) * sizeof(*msg_grid.dirty_col)); + msg_grid.dirty_col[msg_grid.rows - 1] = 0; } } else { grid_del_lines(&msg_grid_adj, 0, 1, Rows, 0, Columns); @@ -2358,7 +2356,7 @@ void msg_scroll_flush(void) msg_grid.throttled = false; int pos_delta = msg_grid_pos_at_flush - msg_grid_pos; assert(pos_delta >= 0); - int delta = MIN(msg_scrolled - msg_scrolled_at_flush, msg_grid.Rows); + int delta = MIN(msg_scrolled - msg_scrolled_at_flush, msg_grid.rows); if (pos_delta > 0) { ui_ext_msg_set_pos(msg_grid_pos, true); @@ -2376,7 +2374,7 @@ void msg_scroll_flush(void) for (int i = MAX(Rows - MAX(delta, 1), 0); i < Rows; i++) { int row = i - msg_grid_pos; assert(row >= 0); - ui_line(&msg_grid, row, 0, msg_grid.dirty_col[row], msg_grid.Columns, + ui_line(&msg_grid, row, 0, msg_grid.dirty_col[row], msg_grid.cols, HL_ATTR(HLF_MSG), false); msg_grid.dirty_col[row] = 0; } @@ -2402,9 +2400,9 @@ void msg_reset_scroll(void) clear_cmdline = true; if (msg_grid.chars) { // non-displayed part of msg_grid is considered invalid. - for (int i = 0; i < MIN(msg_scrollsize(), msg_grid.Rows); i++) { + for (int i = 0; i < MIN(msg_scrollsize(), msg_grid.rows); i++) { grid_clear_line(&msg_grid, msg_grid.line_offset[i], - msg_grid.Columns, false); + msg_grid.cols, false); } } } else { @@ -2418,7 +2416,7 @@ void msg_reset_scroll(void) static void inc_msg_scrolled(void) { if (*get_vim_var_str(VV_SCROLLSTART) == NUL) { - char *p = (char *)sourcing_name; + char *p = sourcing_name; char *tofree = NULL; // v:scrollstart is empty, set it to the script/function name and line @@ -2707,7 +2705,7 @@ static int do_more_prompt(int typed_char) // We get called recursively when a timer callback outputs a message. In // that case don't show another prompt. Also when at the hit-Enter prompt // and nothing was typed. - if (no_need_more || entered || (State == HITRETURN && typed_char == 0)) { + if (no_need_more || entered || (State == MODE_HITRETURN && typed_char == 0)) { return false; } entered = true; @@ -2721,7 +2719,7 @@ static int do_more_prompt(int typed_char) } } - State = ASKMORE; + State = MODE_ASKMORE; setmouse(); if (typed_char == NUL) { msg_moremsg(FALSE); @@ -2992,19 +2990,19 @@ void msg_moremsg(int full) } } -/// Repeat the message for the current mode: ASKMORE, EXTERNCMD, CONFIRM or -/// exmode_active. +/// Repeat the message for the current mode: MODE_ASKMORE, MODE_EXTERNCMD, +/// MODE_CONFIRM or exmode_active. void repeat_message(void) { - if (State == ASKMORE) { - msg_moremsg(TRUE); // display --more-- message again + if (State == MODE_ASKMORE) { + msg_moremsg(true); // display --more-- message again msg_row = Rows - 1; - } else if (State == CONFIRM) { + } else if (State == MODE_CONFIRM) { display_confirm_msg(); // display ":confirm" message again msg_row = Rows - 1; - } else if (State == EXTERNCMD) { + } else if (State == MODE_EXTERNCMD) { ui_cursor_goto(msg_row, msg_col); // put cursor back - } else if (State == HITRETURN || State == SETWSIZE) { + } else if (State == MODE_HITRETURN || State == MODE_SETWSIZE) { if (msg_row == Rows - 1) { // Avoid drawing the "hit-enter" prompt below the previous one, // overwrite it. Esp. useful when regaining focus and a @@ -3076,9 +3074,9 @@ int msg_end(void) * we have to redraw the window. * Do not do this if we are abandoning the file or editing the command line. */ - if (!exiting && need_wait_return && !(State & CMDLINE)) { - wait_return(FALSE); - return FALSE; + if (!exiting && need_wait_return && !(State & MODE_CMDLINE)) { + wait_return(false); + return false; } // NOTE: ui_flush() used to be called here. This had to be removed, as it @@ -3436,7 +3434,7 @@ int do_dialog(int type, char_u *title, char_u *message, char_u *buttons, int dfl int oldState = State; msg_silent = 0; // If dialog prompts for input, user needs to see it! #8788 - State = CONFIRM; + State = MODE_CONFIRM; setmouse(); /* |