diff options
Diffstat (limited to 'src/nvim/drawscreen.c')
-rw-r--r-- | src/nvim/drawscreen.c | 103 |
1 files changed, 48 insertions, 55 deletions
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index 12f06e13cc..7f794a58d2 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -63,11 +63,13 @@ #include "nvim/api/private/defs.h" #include "nvim/ascii_defs.h" #include "nvim/autocmd.h" +#include "nvim/autocmd_defs.h" #include "nvim/buffer.h" #include "nvim/charset.h" #include "nvim/cmdexpand.h" #include "nvim/cursor.h" #include "nvim/decoration.h" +#include "nvim/decoration_defs.h" #include "nvim/decoration_provider.h" #include "nvim/diff.h" #include "nvim/digraph.h" @@ -76,11 +78,14 @@ #include "nvim/eval.h" #include "nvim/ex_getln.h" #include "nvim/fold.h" +#include "nvim/fold_defs.h" #include "nvim/getchar.h" -#include "nvim/gettext.h" +#include "nvim/gettext_defs.h" #include "nvim/globals.h" #include "nvim/grid.h" +#include "nvim/grid_defs.h" #include "nvim/highlight.h" +#include "nvim/highlight_defs.h" #include "nvim/highlight_group.h" #include "nvim/insexpand.h" #include "nvim/match.h" @@ -89,6 +94,7 @@ #include "nvim/message.h" #include "nvim/move.h" #include "nvim/normal.h" +#include "nvim/normal_defs.h" #include "nvim/option.h" #include "nvim/option_vars.h" #include "nvim/os/os_defs.h" @@ -100,6 +106,7 @@ #include "nvim/search.h" #include "nvim/spell.h" #include "nvim/state.h" +#include "nvim/state_defs.h" #include "nvim/statusline.h" #include "nvim/strings.h" #include "nvim/syntax.h" @@ -107,6 +114,7 @@ #include "nvim/types_defs.h" #include "nvim/ui.h" #include "nvim/ui_compositor.h" +#include "nvim/ui_defs.h" #include "nvim/version.h" #include "nvim/vim_defs.h" #include "nvim/window.h" @@ -1296,9 +1304,11 @@ static void draw_vsep_win(win_T *wp) } // draw the vertical separator right of this window - int hl = win_hl_attr(wp, HLF_C); - schar_T c = wp->w_p_fcs_chars.vert; - grid_fill(&default_grid, wp->w_winrow, W_ENDROW(wp), W_ENDCOL(wp), W_ENDCOL(wp) + 1, c, c, hl); + for (int row = wp->w_winrow; row < W_ENDROW(wp); row++) { + grid_line_start(&default_grid, row); + grid_line_put_schar(W_ENDCOL(wp), wp->w_p_fcs_chars.vert, win_hl_attr(wp, HLF_C)); + grid_line_flush(); + } } /// Draw the horizontal separator below window "wp" @@ -1309,9 +1319,9 @@ static void draw_hsep_win(win_T *wp) } // draw the horizontal separator below this window - int hl = win_hl_attr(wp, HLF_C); - schar_T c = wp->w_p_fcs_chars.horiz; - grid_fill(&default_grid, W_ENDROW(wp), W_ENDROW(wp) + 1, wp->w_wincol, W_ENDCOL(wp), c, c, hl); + grid_line_start(&default_grid, W_ENDROW(wp)); + grid_line_fill(wp->w_wincol, W_ENDCOL(wp), wp->w_p_fcs_chars.horiz, win_hl_attr(wp, HLF_C)); + grid_line_flush(); } /// Get the separator connector for specified window corner of window "wp" @@ -2395,7 +2405,7 @@ static void win_update(win_T *wp) set_empty_rows(wp, srow); wp->w_botline = lnum; } else { - win_draw_end(wp, wp->w_p_fcs_chars.lastline, schar_from_ascii(' '), true, srow, + win_draw_end(wp, wp->w_p_fcs_chars.lastline, true, srow, wp->w_grid.rows, HLF_AT); set_empty_rows(wp, srow); wp->w_botline = lnum; @@ -2429,7 +2439,7 @@ static void win_update(win_T *wp) lastline = 0; } - win_draw_end(wp, wp->w_p_fcs_chars.eob, schar_from_ascii(' '), false, MAX(lastline, row), + win_draw_end(wp, wp->w_p_fcs_chars.eob, false, MAX(lastline, row), wp->w_grid.rows, HLF_EOB); set_empty_rows(wp, row); @@ -2517,60 +2527,43 @@ void win_scroll_lines(win_T *wp, int row, int line_count) } } -/// Call grid_clear() with columns adjusted for 'rightleft' if needed. -/// Return the new offset. -static int win_clear_end(win_T *wp, int off, int width, int row, int endrow, int attr) -{ - int nn = off + width; - const int endcol = wp->w_grid.cols; - - if (nn > endcol) { - nn = endcol; - } - - if (wp->w_p_rl) { - grid_clear(&wp->w_grid, row, endrow, endcol - nn, endcol - off, attr); - } else { - grid_clear(&wp->w_grid, row, endrow, off, nn, attr); - } - - return nn; -} - /// Clear lines near the end of the window and mark the unused lines with "c1". -/// Use "c2" as filler character. /// When "draw_margin" is true, then draw the sign/fold/number columns. -void win_draw_end(win_T *wp, schar_T c1, schar_T c2, bool draw_margin, int row, int endrow, - hlf_T hl) +void win_draw_end(win_T *wp, schar_T c1, bool draw_margin, int startrow, int endrow, hlf_T hl) { assert(hl >= 0 && hl < HLF_COUNT); - int n = 0; - - if (draw_margin) { - // draw the fold column - int fdc = compute_foldcolumn(wp, 0); - if (fdc > 0) { - n = win_clear_end(wp, n, fdc, row, endrow, win_hl_attr(wp, HLF_FC)); - } - // draw the sign column - int count = wp->w_scwidth; - if (count > 0) { - n = win_clear_end(wp, n, SIGN_WIDTH * count, row, endrow, win_hl_attr(wp, HLF_SC)); + for (int row = startrow; row < endrow; row++) { + grid_line_start(&wp->w_grid, row); + + int n = 0; + if (draw_margin) { + // draw the fold column + int fdc = MAX(0, compute_foldcolumn(wp, 0)); + n = grid_line_fill(n, n + fdc, schar_from_ascii(' '), win_hl_attr(wp, HLF_FC)); + + // draw the sign column + n = grid_line_fill(n, n + wp->w_scwidth, schar_from_ascii(' '), win_hl_attr(wp, HLF_FC)); + + // draw the number column + if ((wp->w_p_nu || wp->w_p_rnu) && vim_strchr(p_cpo, CPO_NUMCOL) == NULL) { + int width = number_width(wp) + 1; + n = grid_line_fill(n, n + width, schar_from_ascii(' '), win_hl_attr(wp, HLF_N)); + } } - // draw the number column - if ((wp->w_p_nu || wp->w_p_rnu) && vim_strchr(p_cpo, CPO_NUMCOL) == NULL) { - n = win_clear_end(wp, n, number_width(wp) + 1, row, endrow, win_hl_attr(wp, HLF_N)); + + int attr = hl_combine_attr(win_bg_attr(wp), win_hl_attr(wp, (int)hl)); + + if (n < wp->w_grid.cols) { + grid_line_put_schar(n, c1, 0); // base attr is inherited from clear + n++; } - } - int attr = hl_combine_attr(win_bg_attr(wp), win_hl_attr(wp, (int)hl)); + grid_line_clear_end(n, wp->w_grid.cols, attr); - const int endcol = wp->w_grid.cols; - if (wp->w_p_rl) { - grid_fill(&wp->w_grid, row, endrow, 0, endcol - 1 - n, c2, c2, attr); - grid_fill(&wp->w_grid, row, endrow, endcol - 1 - n, endcol - n, c1, c2, attr); - } else { - grid_fill(&wp->w_grid, row, endrow, n, endcol, c1, c2, attr); + if (wp->w_p_rl) { + grid_line_mirror(); + } + grid_line_flush(); } } |