refactor(message): propagate highlight id instead of attrs

Problem:  Highlight group id is not propagated to the end of the message call
          stack, where ext_messages are emitted.
Solution: Refactor message functions to pass along highlight group id
          instead of attr id.
This commit is contained in:
Luuk van Baal
2024-02-20 17:25:57 +01:00
parent 5a86360400
commit 5cfa7a72f8
45 changed files with 441 additions and 473 deletions

View File

@@ -2937,7 +2937,7 @@ static void qf_jump_print_msg(qf_info_T *qi, int qf_index, qfline_T *qf_ptr, buf
msg_scroll = false;
}
msg_ext_set_kind("quickfix");
msg_attr_keep(gap->ga_data, 0, true, false);
msg_hl_keep(gap->ga_data, 0, true, false);
msg_scroll = (int)i;
qfga_clear();
@@ -3144,10 +3144,10 @@ theend:
decr_quickfix_busy();
}
// Highlight attributes used for displaying entries from the quickfix list.
static int qfFileAttr;
static int qfSepAttr;
static int qfLineAttr;
// Highlight ids used for displaying entries from the quickfix list.
static int qfFile_hl_id;
static int qfSep_hl_id;
static int qfLine_hl_id;
/// Display information about a single entry from the quickfix/location list.
/// Used by ":clist/:llist" commands.
@@ -3195,10 +3195,10 @@ static void qf_list_entry(qfline_T *qfp, int qf_idx, bool cursel)
}
msg_putchar('\n');
msg_outtrans(IObuff, cursel ? HL_ATTR(HLF_QFL) : qfFileAttr);
msg_outtrans(IObuff, cursel ? HLF_QFL + 1 : qfFile_hl_id, false);
if (qfp->qf_lnum != 0) {
msg_puts_attr(":", qfSepAttr);
msg_puts_hl(":", qfSep_hl_id, false);
}
garray_T *gap = qfga_get();
if (qfp->qf_lnum != 0) {
@@ -3206,14 +3206,14 @@ static void qf_list_entry(qfline_T *qfp, int qf_idx, bool cursel)
}
ga_concat(gap, qf_types(qfp->qf_type, qfp->qf_nr));
ga_append(gap, NUL);
msg_puts_attr(gap->ga_data, qfLineAttr);
msg_puts_attr(":", qfSepAttr);
msg_puts_hl(gap->ga_data, qfLine_hl_id, false);
msg_puts_hl(":", qfSep_hl_id, false);
if (qfp->qf_pattern != NULL) {
gap = qfga_get();
qf_fmt_text(gap, qfp->qf_pattern);
ga_append(gap, NUL);
msg_puts(gap->ga_data);
msg_puts_attr(":", qfSepAttr);
msg_puts_hl(":", qfSep_hl_id, false);
}
msg_puts(" ");
@@ -3275,17 +3275,17 @@ void qf_list(exarg_T *eap)
// Get the attributes for the different quickfix highlight items. Note
// that this depends on syntax items defined in the qf.vim syntax file
qfFileAttr = syn_name2attr("qfFileName");
if (qfFileAttr == 0) {
qfFileAttr = HL_ATTR(HLF_D);
qfFile_hl_id = syn_name2id("qfFileName");
if (qfFile_hl_id == 0) {
qfFile_hl_id = HLF_D + 1;
}
qfSepAttr = syn_name2attr("qfSeparator");
if (qfSepAttr == 0) {
qfSepAttr = HL_ATTR(HLF_D);
qfSep_hl_id = syn_name2id("qfSeparator");
if (qfSep_hl_id == 0) {
qfSep_hl_id = HLF_D + 1;
}
qfLineAttr = syn_name2attr("qfLineNr");
if (qfLineAttr == 0) {
qfLineAttr = HL_ATTR(HLF_N);
qfLine_hl_id = syn_name2id("qfLineNr");
if (qfLine_hl_id == 0) {
qfLine_hl_id = HLF_N + 1;
}
if (qfl->qf_nonevalid) {
@@ -4396,7 +4396,7 @@ static char *make_get_fullcmd(const char *makecmd, const char *fname)
}
msg_start();
msg_puts(":!");
msg_outtrans(cmd, 0); // show what we are doing
msg_outtrans(cmd, 0, false); // show what we are doing
return cmd;
}
@@ -5243,9 +5243,9 @@ static void vgr_display_fname(char *fname)
msg_start();
char *p = msg_strtrunc(fname, true);
if (p == NULL) {
msg_outtrans(fname, 0);
msg_outtrans(fname, 0, false);
} else {
msg_outtrans(p, 0);
msg_outtrans(p, 0, false);
xfree(p);
}
msg_clr_eos();