diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-03-13 22:05:05 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-04-26 19:17:16 -0400 |
commit | 64b61d49c2c3350833ca490c9fdf8540298cd01a (patch) | |
tree | af2b4047fd193d5fb9748a374775099b6a1f6e5d /src/nvim/screen.c | |
parent | 5f41717838f4cd9d1087e452640ba554500279ab (diff) | |
download | rneovim-64b61d49c2c3350833ca490c9fdf8540298cd01a.tar.gz rneovim-64b61d49c2c3350833ca490c9fdf8540298cd01a.tar.bz2 rneovim-64b61d49c2c3350833ca490c9fdf8540298cd01a.zip |
vim-patch:8.0.1123: cannot define a toolbar for a window
Problem: Cannot define a toolbar for a window.
Solution: Add a window-local toolbar.
https://github.com/vim/vim/commit/1b9645de3c05f37b5c30e78f999351b0cf486ade
"WinBar" code in "screen.c" was not ported.
Fix https://github.com/neovim/neovim/issues/11513#issuecomment-562012827
Diffstat (limited to 'src/nvim/screen.c')
-rw-r--r-- | src/nvim/screen.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 9c590efdbc..45c56549c5 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1741,6 +1741,31 @@ static int advance_color_col(int vcol, int **color_cols) return **color_cols >= 0; } +// Returns the next grid column. +static int text_to_screenline(win_T *wp, char_u *text, int col, int off) + FUNC_ATTR_NONNULL_ALL +{ + int idx = wp->w_p_rl ? off : off + col; + LineState s = LINE_STATE(text); + + while (*s.p != NUL) { + // TODO(bfredl): cargo-culted from the old Vim code: + // if(col + cells > wp->w_width - (wp->w_p_rl ? col : 0)) { break; } + // This is obvious wrong. If Vim ever fixes this, solve for "cells" again + // in the correct condition. + const int maxcells = wp->w_grid.Columns - col - (wp->w_p_rl ? col : 0); + const int cells = line_putchar(&s, &linebuf_char[idx], maxcells, + wp->w_p_rl); + if (cells == -1) { + break; + } + col += cells; + idx += cells; + } + + return col; +} + // Compute the width of the foldcolumn. Based on 'foldcolumn' and how much // space is available for window "wp", minus "col". static int compute_foldcolumn(win_T *wp, int col) @@ -1942,29 +1967,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T // 5. move the text to linebuf_char[off]. Fill up with "fold". // Right-left text is put in columns 0 - number-col, normal text is put // in columns number-col - window-width. - int idx; - - if (wp->w_p_rl) { - idx = off; - } else { - idx = off + col; - } - - LineState s = LINE_STATE(text); - - while (*s.p != NUL) { - // TODO(bfredl): cargo-culted from the old Vim code: - // if(col + cells > wp->w_width - (wp->w_p_rl ? col : 0)) { break; } - // This is obvious wrong. If Vim ever fixes this, solve for "cells" again - // in the correct condition. - int maxcells = wp->w_grid.Columns - col - (wp->w_p_rl ? col : 0); - int cells = line_putchar(&s, &linebuf_char[idx], maxcells, wp->w_p_rl); - if (cells == -1) { - break; - } - col += cells; - idx += cells; - } + col = text_to_screenline(wp, text, col, off); /* Fill the rest of the line with the fold filler */ if (wp->w_p_rl) |