mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 06:16:08 +00:00
Merge pull request #27813 from luukvbaal/msgid
feat(ext_messages): add hl_id to ext_messages chunks
This commit is contained in:
@@ -811,7 +811,7 @@ static uint8_t *command_line_enter(int firstc, int count, int indent, bool clear
|
||||
if (!tl_ret && ERROR_SET(&err)) {
|
||||
msg_putchar('\n');
|
||||
msg_scroll = true;
|
||||
msg_puts_attr(err.msg, HL_ATTR(HLF_E)|MSG_HIST);
|
||||
msg_puts_hl(err.msg, HLF_E + 1, true);
|
||||
api_clear_error(&err);
|
||||
redrawcmd();
|
||||
}
|
||||
@@ -2660,7 +2660,7 @@ static void do_autocmd_cmdlinechanged(int firstc)
|
||||
if (!tl_ret && ERROR_SET(&err)) {
|
||||
msg_putchar('\n');
|
||||
msg_scroll = true;
|
||||
msg_puts_attr(err.msg, HL_ATTR(HLF_E)|MSG_HIST);
|
||||
msg_puts_hl(err.msg, HLF_E + 1, true);
|
||||
api_clear_error(&err);
|
||||
redrawcmd();
|
||||
}
|
||||
@@ -2758,13 +2758,13 @@ char *getcmdline(int firstc, int count, int indent, bool do_concat FUNC_ATTR_UNU
|
||||
///
|
||||
/// @param[in] firstc Prompt type: e.g. '@' for input(), '>' for debug.
|
||||
/// @param[in] prompt Prompt string: what is displayed before the user text.
|
||||
/// @param[in] attr Prompt highlighting.
|
||||
/// @param[in] hl_id Prompt highlight id.
|
||||
/// @param[in] xp_context Type of expansion.
|
||||
/// @param[in] xp_arg User-defined expansion argument.
|
||||
/// @param[in] highlight_callback Callback used for highlighting user input.
|
||||
///
|
||||
/// @return [allocated] Command line or NULL.
|
||||
char *getcmdline_prompt(const int firstc, const char *const prompt, const int attr,
|
||||
char *getcmdline_prompt(const int firstc, const char *const prompt, const int hl_id,
|
||||
const int xp_context, const char *const xp_arg,
|
||||
const Callback highlight_callback)
|
||||
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_MALLOC
|
||||
@@ -2782,7 +2782,7 @@ char *getcmdline_prompt(const int firstc, const char *const prompt, const int at
|
||||
}
|
||||
ccline.prompt_id = last_prompt_id++;
|
||||
ccline.cmdprompt = (char *)prompt;
|
||||
ccline.cmdattr = attr;
|
||||
ccline.hl_id = hl_id;
|
||||
ccline.xp_context = xp_context;
|
||||
ccline.xp_arg = (char *)xp_arg;
|
||||
ccline.input_fn = (firstc == '@');
|
||||
@@ -3098,15 +3098,13 @@ static void color_expr_cmdline(const CmdlineInfo *const colored_ccline,
|
||||
kv_push(ret_ccline_colors->colors, ((CmdlineColorChunk) {
|
||||
.start = (int)prev_end,
|
||||
.end = (int)chunk.start.col,
|
||||
.attr = 0,
|
||||
.hl_id = 0,
|
||||
}));
|
||||
}
|
||||
const int id = syn_name2id(chunk.group);
|
||||
const int attr = (id == 0 ? 0 : syn_id2attr(id));
|
||||
kv_push(ret_ccline_colors->colors, ((CmdlineColorChunk) {
|
||||
.start = (int)chunk.start.col,
|
||||
.end = (int)chunk.end_col,
|
||||
.attr = attr,
|
||||
.hl_id = syn_name2id(chunk.group),
|
||||
}));
|
||||
prev_end = chunk.end_col;
|
||||
}
|
||||
@@ -3114,7 +3112,7 @@ static void color_expr_cmdline(const CmdlineInfo *const colored_ccline,
|
||||
kv_push(ret_ccline_colors->colors, ((CmdlineColorChunk) {
|
||||
.start = (int)prev_end,
|
||||
.end = colored_ccline->cmdlen,
|
||||
.attr = 0,
|
||||
.hl_id = 0,
|
||||
}));
|
||||
}
|
||||
kvi_destroy(colors);
|
||||
@@ -3143,7 +3141,7 @@ static bool color_cmdline(CmdlineInfo *colored_ccline)
|
||||
#define PRINT_ERRMSG(...) \
|
||||
do { \
|
||||
msg_putchar('\n'); \
|
||||
msg_printf_attr(HL_ATTR(HLF_E)|MSG_HIST, __VA_ARGS__); \
|
||||
msg_printf_hl(HLF_E + 1, __VA_ARGS__); \
|
||||
printed_errmsg = true; \
|
||||
} while (0)
|
||||
bool ret = true;
|
||||
@@ -3278,7 +3276,7 @@ static bool color_cmdline(CmdlineInfo *colored_ccline)
|
||||
kv_push(ccline_colors->colors, ((CmdlineColorChunk) {
|
||||
.start = (int)prev_end,
|
||||
.end = (int)start,
|
||||
.attr = 0,
|
||||
.hl_id = 0,
|
||||
}));
|
||||
}
|
||||
const varnumber_T end =
|
||||
@@ -3302,12 +3300,10 @@ static bool color_cmdline(CmdlineInfo *colored_ccline)
|
||||
if (group == NULL) {
|
||||
goto color_cmdline_error;
|
||||
}
|
||||
const int id = syn_name2id(group);
|
||||
const int attr = (id == 0 ? 0 : syn_id2attr(id));
|
||||
kv_push(ccline_colors->colors, ((CmdlineColorChunk) {
|
||||
.start = (int)start,
|
||||
.end = (int)end,
|
||||
.attr = attr,
|
||||
.hl_id = syn_name2id(group),
|
||||
}));
|
||||
i++;
|
||||
});
|
||||
@@ -3315,7 +3311,7 @@ static bool color_cmdline(CmdlineInfo *colored_ccline)
|
||||
kv_push(ccline_colors->colors, ((CmdlineColorChunk) {
|
||||
.start = (int)prev_end,
|
||||
.end = colored_ccline->cmdlen,
|
||||
.attr = 0,
|
||||
.hl_id = 0,
|
||||
}));
|
||||
}
|
||||
prev_prompt_errors = 0;
|
||||
@@ -3377,10 +3373,10 @@ static void draw_cmdline(int start, int len)
|
||||
continue;
|
||||
}
|
||||
const int chunk_start = MAX(chunk.start, start);
|
||||
msg_outtrans_len(ccline.cmdbuff + chunk_start, chunk.end - chunk_start, chunk.attr);
|
||||
msg_outtrans_len(ccline.cmdbuff + chunk_start, chunk.end - chunk_start, chunk.hl_id, false);
|
||||
}
|
||||
} else {
|
||||
msg_outtrans_len(ccline.cmdbuff + start, len, 0);
|
||||
msg_outtrans_len(ccline.cmdbuff + start, len, 0, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3406,7 +3402,7 @@ static void ui_ext_cmdline_show(CmdlineInfo *line)
|
||||
for (size_t i = 0; i < kv_size(line->last_colors.colors); i++) {
|
||||
CmdlineColorChunk chunk = kv_A(line->last_colors.colors, i);
|
||||
Array item = arena_array(&arena, 2);
|
||||
ADD_C(item, INTEGER_OBJ(chunk.attr));
|
||||
ADD_C(item, INTEGER_OBJ(chunk.hl_id == 0 ? 0 : syn_id2attr(chunk.hl_id)));
|
||||
|
||||
assert(chunk.end >= chunk.start);
|
||||
ADD_C(item, STRING_OBJ(cbuf_as_string(line->cmdbuff + chunk.start,
|
||||
@@ -3792,7 +3788,7 @@ static void redrawcmdprompt(void)
|
||||
msg_putchar(ccline.cmdfirstc);
|
||||
}
|
||||
if (ccline.cmdprompt != NULL) {
|
||||
msg_puts_attr(ccline.cmdprompt, ccline.cmdattr);
|
||||
msg_puts_hl(ccline.cmdprompt, ccline.hl_id, false);
|
||||
ccline.cmdindent = msg_col + (msg_row - cmdline_row) * Columns;
|
||||
// do the reverse of cmd_startcol()
|
||||
if (ccline.cmdfirstc != NUL) {
|
||||
@@ -4780,7 +4776,7 @@ void get_user_input(const typval_T *const argvars, typval_T *const rettv, const
|
||||
p = lastnl + 1;
|
||||
msg_start();
|
||||
msg_clr_eos();
|
||||
msg_puts_len(prompt, p - prompt, get_echo_attr());
|
||||
msg_puts_len(prompt, p - prompt, get_echo_hl_id(), false);
|
||||
msg_didout = false;
|
||||
msg_starthere();
|
||||
}
|
||||
@@ -4791,7 +4787,7 @@ void get_user_input(const typval_T *const argvars, typval_T *const rettv, const
|
||||
|
||||
const int save_ex_normal_busy = ex_normal_busy;
|
||||
ex_normal_busy = 0;
|
||||
rettv->vval.v_string = getcmdline_prompt(secret ? NUL : '@', p, get_echo_attr(),
|
||||
rettv->vval.v_string = getcmdline_prompt(secret ? NUL : '@', p, get_echo_hl_id(),
|
||||
xp_type, xp_arg, input_callback);
|
||||
ex_normal_busy = save_ex_normal_busy;
|
||||
callback_free(&input_callback);
|
||||
|
Reference in New Issue
Block a user