diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2024-02-20 17:25:57 +0100 |
---|---|---|
committer | Luuk van Baal <luukvbaal@gmail.com> | 2024-11-08 13:21:35 +0100 |
commit | 5cfa7a72f8c40cdcc0fa93693689915e913806f1 (patch) | |
tree | 2c482565d5667dc0ec9caca6e893da7d5a37359a /src/nvim/cmdexpand.c | |
parent | 5a86360400691e55fae66d60485b61360a1d3d6c (diff) | |
download | rneovim-5cfa7a72f8c40cdcc0fa93693689915e913806f1.tar.gz rneovim-5cfa7a72f8c40cdcc0fa93693689915e913806f1.tar.bz2 rneovim-5cfa7a72f8c40cdcc0fa93693689915e913806f1.zip |
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.
Diffstat (limited to 'src/nvim/cmdexpand.c')
-rw-r--r-- | src/nvim/cmdexpand.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/nvim/cmdexpand.c b/src/nvim/cmdexpand.c index 8d1f87cbcf..b64e4f3ab6 100644 --- a/src/nvim/cmdexpand.c +++ b/src/nvim/cmdexpand.c @@ -979,20 +979,19 @@ void ExpandCleanup(expand_T *xp) /// @param linenr line number of matches to display /// @param maxlen maximum number of characters in each line /// @param showtail display only the tail of the full path of a file name -/// @param dir_attr highlight attribute to use for directory names static void showmatches_oneline(expand_T *xp, char **matches, int numMatches, int lines, int linenr, - int maxlen, bool showtail, int dir_attr) + int maxlen, bool showtail) { char *p; int lastlen = 999; for (int j = linenr; j < numMatches; j += lines) { if (xp->xp_context == EXPAND_TAGS_LISTFILES) { - msg_outtrans(matches[j], HL_ATTR(HLF_D)); + msg_outtrans(matches[j], HLF_D + 1, false); p = matches[j] + strlen(matches[j]) + 1; msg_advance(maxlen + 1); msg_puts(p); msg_advance(maxlen + 3); - msg_outtrans_long(p + 2, HL_ATTR(HLF_D)); + msg_outtrans_long(p + 2, HLF_D + 1); break; } for (int i = maxlen - lastlen; --i >= 0;) { @@ -1029,7 +1028,7 @@ static void showmatches_oneline(expand_T *xp, char **matches, int numMatches, in isdir = false; p = SHOW_MATCH(j); } - lastlen = msg_outtrans(p, isdir ? dir_attr : 0); + lastlen = msg_outtrans(p, isdir ? HLF_D + 1 : 0, false); } if (msg_col > 0) { // when not wrapped around msg_clr_eos(); @@ -1119,18 +1118,16 @@ int showmatches(expand_T *xp, bool wildmenu) lines = (numMatches + columns - 1) / columns; } - int attr = HL_ATTR(HLF_D); // find out highlighting for directories - if (xp->xp_context == EXPAND_TAGS_LISTFILES) { - msg_puts_attr(_("tagname"), HL_ATTR(HLF_T)); + msg_puts_hl(_("tagname"), HLF_T + 1, false); msg_clr_eos(); msg_advance(maxlen - 3); - msg_puts_attr(_(" kind file\n"), HL_ATTR(HLF_T)); + msg_puts_hl(_(" kind file\n"), HLF_T + 1, false); } // list the files line by line for (int i = 0; i < lines; i++) { - showmatches_oneline(xp, matches, numMatches, lines, i, maxlen, showtail, attr); + showmatches_oneline(xp, matches, numMatches, lines, i, maxlen, showtail); if (got_int) { got_int = false; break; |