diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2024-12-22 16:06:46 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-22 16:06:46 -0800 |
commit | 7e1c1ff7fcf2cbc564c90a656124b70ad8bb4d5f (patch) | |
tree | a7f30855c9ef3304b0d7664413fcfebccc6b638b /src | |
parent | 665a0e85c4788cb2847e270c333c0aee306f07ad (diff) | |
parent | a10636fbe7bb4dba45c42c64548e5e32fe8f8d12 (diff) | |
download | rneovim-7e1c1ff7fcf2cbc564c90a656124b70ad8bb4d5f.tar.gz rneovim-7e1c1ff7fcf2cbc564c90a656124b70ad8bb4d5f.tar.bz2 rneovim-7e1c1ff7fcf2cbc564c90a656124b70ad8bb4d5f.zip |
Merge #31661 cmdline_show/hide events
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/api/ui_events.in.h | 6 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 7 | ||||
-rw-r--r-- | src/nvim/message.c | 12 |
3 files changed, 14 insertions, 11 deletions
diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h index 0ed208fc1a..74718e7ac5 100644 --- a/src/nvim/api/ui_events.in.h +++ b/src/nvim/api/ui_events.in.h @@ -136,13 +136,13 @@ void tabline_update(Tabpage current, Array tabs, Buffer current_buffer, Array bu FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void cmdline_show(Array content, Integer pos, String firstc, String prompt, Integer indent, - Integer level) + Integer level, Integer hl_id) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void cmdline_pos(Integer pos, Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void cmdline_special_char(String c, Boolean shift, Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; -void cmdline_hide(Integer level) +void cmdline_hide(Integer level, Boolean abort) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void cmdline_block_show(Array lines) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; @@ -158,7 +158,7 @@ void wildmenu_select(Integer selected) void wildmenu_hide(void) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; -void msg_show(String kind, Array content, Boolean replace_last) +void msg_show(String kind, Array content, Boolean replace_last, Boolean history) FUNC_API_SINCE(6) FUNC_API_FAST FUNC_API_REMOTE_ONLY; void msg_clear(void) FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 09d4c88dcd..ff752fb489 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -956,7 +956,7 @@ theend: char *p = ccline.cmdbuff; if (ui_has(kUICmdline)) { - ui_call_cmdline_hide(ccline.level); + ui_call_cmdline_hide(ccline.level, s->gotesc); msg_ext_clear_later(); } if (!cmd_silent) { @@ -3423,8 +3423,7 @@ static void ui_ext_cmdline_show(CmdlineInfo *line) ui_call_cmdline_show(content, line->cmdpos, cstr_as_string(charbuf), cstr_as_string((line->cmdprompt)), - line->cmdindent, - line->level); + line->cmdindent, line->level, line->hl_id); if (line->special_char) { charbuf[0] = line->special_char; ui_call_cmdline_special_char(cstr_as_string(charbuf), @@ -4478,7 +4477,7 @@ static int open_cmdwin(void) invalidate_botline(curwin); if (ui_has(kUICmdline)) { ccline.redraw_state = kCmdRedrawNone; - ui_call_cmdline_hide(ccline.level); + ui_call_cmdline_hide(ccline.level, false); } redraw_later(curwin, UPD_SOME_VALID); diff --git a/src/nvim/message.c b/src/nvim/message.c index a654395455..125f602c6c 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -153,6 +153,7 @@ static sattr_T msg_ext_last_attr = -1; static int msg_ext_last_hl_id; static size_t msg_ext_cur_len = 0; +static bool msg_ext_history = false; ///< message was added to history static bool msg_ext_overwrite = false; ///< will overwrite last message static int msg_ext_visible = 0; ///< number of messages currently visible @@ -988,7 +989,7 @@ static void add_msg_hist(const char *s, int len, int hl_id, bool multiline) static void add_msg_hist_multihl(const char *s, int len, int hl_id, bool multiline, HlMessage multihl) { - if (msg_hist_off || msg_silent != 0) { + if (msg_hist_off || msg_silent != 0 || (s != NULL && *s == NUL)) { hl_msg_free(multihl); return; } @@ -999,12 +1000,13 @@ static void add_msg_hist_multihl(const char *s, int len, int hl_id, bool multili if (len < 0) { len = (int)strlen(s); } + assert(len > 0); // remove leading and trailing newlines - while (len > 0 && *s == '\n') { + while (*s == '\n') { s++; len--; } - while (len > 0 && s[len - 1] == '\n') { + while (s[len - 1] == '\n') { len--; } p->msg = xmemdupz(s, (size_t)len); @@ -1024,6 +1026,7 @@ static void add_msg_hist_multihl(const char *s, int len, int hl_id, bool multili first_msg_hist = last_msg_hist; } msg_hist_len++; + msg_ext_history = true; check_msg_hist(); } @@ -3138,13 +3141,14 @@ void msg_ext_ui_flush(void) msg_ext_emit_chunk(); if (msg_ext_chunks->size > 0) { Array *tofree = msg_ext_init_chunks(); - ui_call_msg_show(cstr_as_string(msg_ext_kind), *tofree, msg_ext_overwrite); + ui_call_msg_show(cstr_as_string(msg_ext_kind), *tofree, msg_ext_overwrite, msg_ext_history); api_free_array(*tofree); xfree(tofree); if (!msg_ext_overwrite) { msg_ext_visible++; } msg_ext_overwrite = false; + msg_ext_history = false; msg_ext_kind = NULL; } } |