aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/drawline.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-17 17:24:03 +0800
committerGitHub <noreply@github.com>2024-03-17 17:24:03 +0800
commit54db75e995f82a11f5d2a223d816d2ea0bd0467e (patch)
treeb6413e4394c5b96a380fd1860de09f71396bace2 /src/nvim/drawline.c
parentc52dfb6e840827a2de713e40ea8506491ec7ce0b (diff)
downloadrneovim-54db75e995f82a11f5d2a223d816d2ea0bd0467e.tar.gz
rneovim-54db75e995f82a11f5d2a223d816d2ea0bd0467e.tar.bz2
rneovim-54db75e995f82a11f5d2a223d816d2ea0bd0467e.zip
refactor(drawline): integrate terminal hl with eol loop (#27893)
There is no test for using 'cursorline' in Normal mode in a terminal buffer, so add a test and fix 'cursorcolumn' remaining when entering Terminal mode. Also move synIDattr() tests to ui/highlight_spec.lua.
Diffstat (limited to 'src/nvim/drawline.c')
-rw-r--r--src/nvim/drawline.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 816eb8a674..a6f3f0c4b3 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -2576,7 +2576,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
&& wp->w_virtcol < grid->cols * (ptrdiff_t)(wlv.row - startrow + 1) + start_col
&& lnum != wp->w_cursor.lnum)
|| wlv.color_cols || wlv.line_attr_lowprio || wlv.line_attr
- || wlv.diff_hlf != 0)) {
+ || wlv.diff_hlf != 0 || wp->w_buffer->terminal)) {
int rightmost_vcol = get_rightmost_vcol(wp, wlv.color_cols);
const int cuc_attr = win_hl_attr(wp, HLF_CUC);
const int mc_attr = win_hl_attr(wp, HLF_MC);
@@ -2590,7 +2590,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
: 0;
const int base_attr = hl_combine_attr(wlv.line_attr_lowprio, diff_attr);
- if (base_attr || wlv.line_attr) {
+ if (base_attr || wlv.line_attr || wp->w_buffer->terminal) {
rightmost_vcol = INT_MAX;
}
@@ -2609,6 +2609,10 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
col_attr = hl_combine_attr(col_attr, mc_attr);
}
+ if (wp->w_buffer->terminal && wlv.vcol < TERM_ATTRS_MAX) {
+ col_attr = hl_combine_attr(col_attr, term_attrs[wlv.vcol]);
+ }
+
col_attr = hl_combine_attr(col_attr, wlv.line_attr);
linebuf_attr[wlv.off] = col_attr;
@@ -2622,19 +2626,6 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
}
}
- // TODO(bfredl): integrate with the common beyond-the-end-loop
- if (wp->w_buffer->terminal) {
- // terminal buffers may need to highlight beyond the end of the logical line
- while (wlv.col >= 0 && wlv.col < grid->cols) {
- linebuf_char[wlv.off] = schar_from_ascii(' ');
- linebuf_attr[wlv.off] = wlv.vcol >= TERM_ATTRS_MAX ? 0 : term_attrs[wlv.vcol];
- linebuf_vcol[wlv.off] = wlv.vcol;
- wlv.off++;
- wlv.vcol++;
- wlv.col++;
- }
- }
-
if (kv_size(fold_vt) > 0) {
draw_virt_text_item(buf, win_col_offset, fold_vt, kHlModeCombine, grid->cols, 0);
}