aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/drawscreen.c
Commit message (Collapse)AuthorAge
* Merge remote-tracking branch 'upstream/master' into colorcolcharcolorcolcharJosh Rahm2023-11-29
|\
| * perf(column): only invalidate lines affected by added signLuuk van Baal2023-11-29
| |
| * refactor(IWYU): create normal_defs.h (#26293)zeertzjq2023-11-29
| |
| * refactor: fix headers with IWYUdundargoc2023-11-28
| |
| * refactor: rename types.h to types_defs.hdundargoc2023-11-27
| |
| * build(IWYU): fix includes for undo_defs.hdundargoc2023-11-27
| |
| * build(IWYU): fix includes for func_attr.hdundargoc2023-11-27
| |
| * refactor: move garray_T to garray_defs.h (#26227)zeertzjq2023-11-26
| |
| * build: rework IWYU mapping filesdundargoc2023-11-25
| | | | | | | | | | Create mapping to most of the C spec and some POSIX specific functions. This is more robust than relying files shipped with IWYU.
| * fix(column): reset decor state before starting from topLuuk van Baal2023-11-23
| |
| * refactor(sign): store 'signcolumn' width range when it is setLuuk van Baal2023-11-21
| | | | | | | | | | Problem: Minimum and maximum signcolumn width is determined each redraw. Solution: Determine and store 'signcolumn' range when option is set.
| * refactor: enable formatting for ternariesdundargoc2023-11-20
| | | | | | | | | | | | This requires removing the "Inner expression should be aligned" rule from clint as it prevents essentially any formatting regarding ternary operators.
| * refactor: follow style guidedundargoc2023-11-19
| | | | | | | | | | - reduce variable scope - prefer initialization over declaration and assignment
| * refactor(sign): move legacy signs to extmarksLuuk van Baal2023-11-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: The legacy signlist data structures and associated functions are redundant since the introduction of extmark signs. Solution: Store signs defined through the legacy commands in a hashmap, placed signs in the extmark tree. Replace signlist associated functions. Usage of the legacy sign commands should yield no change in behavior with the exception of: - "orphaned signs" are now always removed when the line it is placed on is deleted. This used to depend on the value of 'signcolumn'. - It is no longer possible to place multiple signs with the same identifier in a single group on multiple lines. This will now move the sign instead. Moreover, both signs placed through the legacy sign commands and through |nvim_buf_set_extmark()|: - Will show up in both |sign-place| and |nvim_buf_get_extmarks()|. - Are displayed by increasing sign identifier, left to right. Extmark signs used to be ordered decreasingly as opposed to legacy signs.
| * build: remove PVSdundargoc2023-11-12
| | | | | | | | | | | | | | We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable.
| * fix(float): apply 'winblend' to title/footer highlight (#25999)zeertzjq2023-11-12
| |
| * fix(float): win_get_bordertext_col returning negative column number (#25752)nwounkn2023-10-26
| | | | | | | | | | | | | | | | Problem: `win_get_bordertext_col` returns column < 1 for right or center aligned text, if its length is more than window width. Solution: Return max(resulting_column, 1)
| * refactor: allow not having a `default` case for enumFamiu Haque2023-10-10
| | | | | | | | | | | | Problem: The style guide states that all switch statements that are not conditional on an enum must have a `default` case, but does not give any explicit guideline for switch statements that are conditional on enums. As a result, a `default` case is added in many enum switch statements, even when the switch statement is exhaustive. This is not ideal because it removes the ability to have compiler errors to easily detect unchanged switch statements when a new possible value for an enum is added. Solution: Add explicit guidelines for switch statements that are conditional on an enum, clarifying that a `default` case is not necessary if the switch statement is exhaustive. Also refactor pre-existing code with unnecessary `default` cases.
| * refactor: the long goodbyedundargoc2023-10-09
| | | | | | | | | | | | long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types.
| * refactor(grid): do arabic shaping in one placebfredl2023-10-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'arabicshape' feature of vim is a transformation of unicode text to make arabic and some related scripts look better at display time. In particular the content of a cell will be adjusted depending on the (original) content of the cells just before and after it. This is implemented by the arabic_shape() function in nvim. Before this commit, shaping was invoked in four different contexts: - when rendering buffer text in win_line() - in line_putchar() for rendering virtual text - as part of grid_line_puts, used by messages and statuslines and similar - as part of draw_cmdline() for drawing the cmdline This replaces all these with a post-processing step in grid_put_linebuf(), which has become the entry point for all text rendering after recent refactors. An aim of this is to make the handling of multibyte text yet simpler. One of the main reasons multibyte chars needs to be "parsed" into codepoint arrays of composing chars is so that these could be inspected for the purpose of shaping. This can likely be vastly simplified in many contexts where only the total length (in bytes) and width of composed char is needed.
| * refactor(grid): get rid of unbatched grid_puts and grid_putcharbfredl2023-10-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This finalizes the long running refactor from the old TUI-focused grid implementation where text-drawing cursor was not separated from the visible cursor. Still, the pattern of setting cursor position together with updating a line was convenient. Introduce grid_line_cursor_goto() to still allow this but now being explicit about it. Only having batched drawing functions makes code involving drawing a bit longer. But it is better to be explicit, and this highlights cases where multiple small redraws can be grouped together. This was the case for most of the changed places (messages, lastline, and :intro)
| * fix(terminal): check terminal size at end of screen update (#25480)zeertzjq2023-10-03
| |
| * refactor: reorganize option header files (#25437)zeertzjq2023-09-30
| | | | | | | | | | | | - Move vimoption_T to option.h - option_defs.h is for option-related types - option_vars.h corresponds to Vim's option.h - option_defs.h and option_vars.h don't include each other
| * build(iwyu): add a few more _defs.h mappings (#25435)zeertzjq2023-09-30
| |
| * refactor(grid): unify the two put-text-on-the-screen code pathsbfredl2023-09-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The screen grid refactors will continue until morale improves. Jokes aside, this is quite a central installment in the series. Before this refactor, there were two fundamentally distinct codepaths for getting some text on the screen: - the win_line() -> grid_put_linebuf() -> ui_line() call chain used for buffer text, with linebuf_char as a temporary scratch buffer - the grid_line_start/grid_line_puts/grid_line_flush() -> ui_line() path used for every thing else: statuslines, messages and the command line. Here the grid->chars[] array itself doubles as a scratch buffer. With this refactor, the later family of functions still exist, however they now as well render to linebuf_char just like win_line() did, and grid_put_linebuf() is called in the end to calculate delta changes. This means we don't need any duplicate logic for delta calculations anymore. Later down the line, it will be possible to share more logic operating on this scratch buffer, like doing 'rightleft' reversal and arabic shaping as a post-processing step.
| * refactor(grid): use batched updates for statusline and rulerbfredl2023-09-27
| |
| * fix(ui): "resize -1" with cmdheight=0 #24758nwounkn2023-09-24
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Crash from: set cmdheight=0 redrawdebug=invalid resize -1 Solution: Do not invalidate first `p_ch` `msg_grid` rows in `update_screen` when scrolling the screen down after displaying a message, because they may be used later for drawing cmdline. Fixes #22154
| * refactor(grid): properly namespace and separate stateful grid functionsbfredl2023-09-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a step in an ongoing refactor where the "grid_puts" and "grid_put_linebuf" code paths will share more of the implementation (in particular for delta calculation, doublewidth and 'arabicshape' handling). But it also makes sense by its own as a cleanup, and is thus committed separately. Before this change many of the low level grid functions grid_puts, grid_fill etc could both be used in a standalone fashion but also as part of a batched line update which would be finally transmitted as a single grid_line call (via ui_line() ). This was initially useful to quickly refactor pre-existing vim code to use batched logic safely. However, this pattern is not really helpful for maintainable and newly written code, where the "grid" and "row" arguments are just needlessly repeated. This simplifies these calls to just use grid and row as specified in the initial grid_line_start(grid, row) call. This also makes the intent clear whether any grid_puts() call is actually part of a batch or not, which is better in the long run when more things get refactored to use effective (properly batched) updates.
| * fix(ui): handle virtual text with multiple hl in more cases (#25304)zeertzjq2023-09-22
| |
| * Merge pull request #25261 from bfredl/nolinewrapbfredl2023-09-20
| |\ | | | | | | refactor(grid): unused grid->line_wraps delenda est
| | * refactor(grid): unused grid->line_wraps delenda estbfredl2023-09-20
| | | | | | | | | | | | | | | | | | This is not used as part of the logic to actually implement TUI line wrapping In vim (especially gvim) it is used to emulate terminal-style text selection. But in nvim we don't do that, and have no plans to reintroduce it.
| * | fix: avoid ui_grid_cursor_goto when drawing window separatorsJędrzej Boczar2023-09-19
| |/
| * refactor(grid): change schar_T representation to be more compactbfredl2023-09-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, a screen cell would occupy 28+4=32 bytes per cell as we always made space for up to MAX_MCO+1 codepoints in a cell. As an example, even a pretty modest 50*80 screen would consume 50*80*2*32 = 256000, i e a quarter megabyte With the factor of two due to the TUI side buffer, and even more when using msg_grid and/or ext_multigrid. This instead stores a 4-byte union of either: - a valid UTF-8 sequence up to 4 bytes - an escape char which is invalid UTF-8 (0xFF) plus a 24-bit index to a glyph cache This avoids allocating space for huge composed glyphs _upfront_, while still keeping rendering such glyphs reasonably fast (1 hash table lookup + one plain index lookup). If the same large glyphs are using repeatedly on the screen, this is still a net reduction of memory/cache consumption. The only case which really gets worse is if you blast the screen full with crazy emojis and zalgo text and even this case only leads to 4 extra bytes per char. When only <= 4-byte glyphs are used, plus the 4-byte attribute code, i e 8 bytes in total there is a factor of four reduction of memory use. Memory which will be quite hot in cache as the screen buffer is scanned over in win_line() buffer text drawing A slight complication is that the representation depends on host byte order. I've tested this manually by compling and running this in qemu-s390x and it works fine. We might add a qemu based solution to CI at some point.
| * feat(float): implement footerEvgeni Chasnovski2023-08-26
| | | | | | | | | | | | | | | | Problem: Now way to show text at the bottom part of floating window border (a.k.a. "footer"). Solution: Allows `footer` and `footer_pos` config fields similar to `title` and `title_pos`.
| * refactor(float): extract "title" and "title_pos" handlingEvgeni Chasnovski2023-08-26
| |
| * fix(statuscolumn): force full redraw when signcolumn is invalid (#24859)luukvbaal2023-08-26
| | | | | | Fix #24655
| * refactor(change): do API changes to buffer without curbuf switchbfredl2023-08-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most of the messy things when changing a non-current buffer is not about the buffer, it is about windows. In particular, it is about `curwin`. When editing a non-current buffer which is displayed in some other window in the current tabpage, one such window will be "borrowed" as the curwin. But this means if two or more non-current windows displayed the buffers, one of them will be treated differenty. this is not desirable. In particular, with nvim_buf_set_text, cursor _column_ position was only corrected for one single window. Two new tests are added: the test with just one non-current window passes, but the one with two didn't. Two corresponding such tests were also added for nvim_buf_set_lines. This already worked correctly on master, but make sure this is well-tested for future refactors. Also, nvim_create_buf no longer invokes autocmds just because you happened to use `scratch=true`. No option value was changed, therefore OptionSet must not be fired.
| * refactor(memline): distinguish mutating uses of ml_get_buf()bfredl2023-08-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | ml_get_buf() takes a third parameters to indicate whether the caller wants to mutate the memline data in place. However the vast majority of the call sites is using this function just to specify a buffer but without any mutation. This makes it harder to grep for the places which actually perform mutation. Solution: Remove the bool param from ml_get_buf(). it now works like ml_get() except for a non-current buffer. Add a new ml_get_buf_mut() function for the mutating use-case, which can be grepped along with the other ml_replace() etc functions which can modify the memline.
| * vim-patch:9.0.1747: screenpos() may cause unnecessary redraw (#24792)zeertzjq2023-08-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: screenpos() may cause unnecessary redraw. Solution: Don't unnecessarily reset VALID_WROW flag. VALID_WROW flag is only used by two functions: validate_cursor() and cursor_valid(), and cursor_valid() is only used once in ex_sleep(). When adjust_plines_for_skipcol() was first added in patch 9.0.0640, it was called in two functions: comp_botline() and curs_rows(). - comp_botline() is called in two places: - onepage(), which resets VALID_WROW flag immediately afterwards. - validate_botline_win(), where resetting a VALID_ flag is strange. - curs_rows() is called in two places: - curs_columns(), which sets VALID_WROW flag afterwards. - validate_cline_row(), which is only used by GUI mouse focus. Therefore resetting VALID_WROW there doesn't seem to do anything useful. Also, a w_skipcol check (which resets VALID_WROW flag) was added to check_cursor_moved() in patch 9.0.0734, which seems to make more sense than resetting that flag in the middle of a computation. While at it make adjust_plines_for_skipcol() and textpos2screenpos() a bit less confusing: - Make adjust_plines_for_skipcol() return "off" instead of "n - off". - Use 0-based "row" in textpos2screenpos() until W_WINROW is added. closes: vim/vim#12832 https://github.com/vim/vim/commit/6235a109c48ff2559eca3b16578c429ffb61eadc
| * vim-patch:9.0.1729: screenpos() wrong when w_skipcol and cpoptions+=n (#24773)zeertzjq2023-08-18
| | | | | | | | | | | | | | | | | | Problem: screenpos() wrong result with w_skipcol and cpoptions+=n Solution: Use adjust_plines_for_skipcol() instead of subtracting w_skipcol. closes: vim/vim#12625 https://github.com/vim/vim/commit/bfe377b8f2d080e5f85c8cbecf3533456e1d6312
| * fix(window): prevent win_size_restore from changing cmdheightSean Dewar2023-07-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently it only skips if `Rows` changed, but it's possible for the height of the usable area for windows to change (e.g: via `&ch`, `&stal` or `&ls`), which can cause the value of `&cmdheight` to change when the sizes are restored. This is a Vim bug, so I've submitted a PR there too. No telling when it'll be merged though, given the current lack of activity there. `ROWS_AVAIL` is convenient here, but also subtracts the `global_stl_height()`. Not ideal, as we also care about the height of the last statusline for other values of `&ls`. Meh. Introduce `last_stl_height` for getting the height of the last statusline and use it in `win_size_save/restore` and `last_status` (means `last_status_rec`'s `statusline` argument will now be true if `&ls` is 3, but that does not change the behaviour). Also corrects the logic in `comp_col` to not assume there's a last statusline if `&ls` is 1 and the last window is floating.
| * feat(decoration_provider): log errors as error messagesThomas Vigouroux2023-07-19
| |
| * fix(folds): fix missing virt_lines above when fold is hidden (#24274)zeertzjq2023-07-07
| |
| * fix(statusline): redraw when VIsual_mode changes (#23933)zeertzjq2023-06-06
| |
| * fix(folds): allow overlay virtual text on folded line (#23892)zeertzjq2023-06-03
| | | | | | Also always check for fi_level before fi_lines.
| * refactor(drawscreen): avoid spell check on folded or filler lineszeertzjq2023-06-01
| |
| * vim-patch:9.0.1595: line pointer becomes invalid when using spell checkingLuuk van Baal2023-06-01
| | | | | | | | | | | | | | Problem: Line pointer becomes invalid when using spell checking. Solution: Call ml_get() at the right places. (Luuk van Baal, closes vim/vim#12456) https://github.com/vim/vim/commit/e84c773d42e8b6ef0f8ae9b6c7312e0fd47909af
| * vim-patch:9.0.1585: weird use of static variables for spell checkingLuuk van Baal2023-06-01
| | | | | | | | | | | | | | | | Problem: Weird use of static variables for spell checking. Solution: Move the variables to a structure and pass them from win_update() to win_line(). (Luuk van Baal, closes vim/vim#12448) https://github.com/vim/vim/commit/30805a1aba0067cf0087f9a0e5c184562433e2e7
| * vim-patch:9.0.1578: SpellCap highlight not always updated when needed (#23755)luukvbaal2023-05-26
| | | | | | | | | | | | | | | | Problem: SpellCap highlight not always updated when needed. Solution: Handle updating line below closed fold and other situations where only part of the window is redrawn. (Luuk van Baal, closes vim/vim#12428, closes vim/vim#12420) https://github.com/vim/vim/commit/2ac6497f0ef186f0e3ba67d7f0a485bfb612bb08
| * vim-patch:9.0.1512: inserting lines when scrolling with 'smoothscroll' setLuuk van Baal2023-05-07
| | | | | | | | | | | | | | | | Problem: Inserting lines when scrolling with 'smoothscroll' set. Solution: Adjust line height computation for w_skipcol. (Luuk van Baal, closes vim/vim#12350) https://github.com/vim/vim/commit/c8502f9b880b6d23baa4f9d28b60e1ceb442e35f