aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/grid.c
Commit message (Collapse)AuthorAge
* refactor: move some constants out of vim_defs.h (#26298)zeertzjq2023-11-29
|
* refactor: fix headers with IWYUdundargoc2023-11-28
|
* feat(decoration): allow conceal_char to be a composing charbfredl2023-11-28
| | | | | | | | decor->text.str pointer must go. This removes it for conceal char, in preparation for a larger PR which will also handle the sign case. By actually allowing composing chars for a conceal chars, this becomes a feature and not just a refactor, as a bonus.
* refactor: rename types.h to types_defs.hdundargoc2023-11-27
|
* fix(grid): don't draw beyond max column (#26172)zeertzjq2023-11-24
|
* 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(grid): make screen rendering more multibyte than ever beforebfredl2023-11-17
| | | | | | | | | | | | | | | | | | Problem: buffer text with composing chars are converted from UTF-8 to an array of up to seven UTF-32 values and then converted back to UTF-8 strings. Solution: Convert buffer text directly to UTF-8 based schar_T values. The limit of the text size is now in schar_T bytes, which is currently 31+1 but easily could be raised as it no longer multiplies the size of the entire screen grid when not used, the full size is only required for temporary scratch buffers. Also does some general cleanup to win_line text handling, which was unnecessarily complicated due to multibyte rendering being an "opt-in" feature long ago. Nowadays, a char is just a char, regardless if it consists of one ASCII byte or multiple bytes.
* refactor: follow style guidedundargoc2023-11-13
| | | | | | - reduce variable scope - prefer initialization over declaration and assignment - use bool to represent boolean values
* 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.
* refactor(grid): reimplement 'rightleft' as a post-processing stepbfredl2023-11-05
| | | | | | | | | | | | | problem: checks for wp->w_p_rl are all over the place, making simple things like "advance column one cell" incredibly complicated. solution: always fill linebuf_char[] using an incrementing counter, and then mirror the buffer as a post-processing step This was "easier" that I first feared, because the stupid but simple workaround for things like keeping linenumbers still left-right, e.g. "mirror them and them mirror them once more" is more or less what vim did already. So let's just keep doing that.
* refactor(grid): implement rightleftcmd as a post-processing stepbfredl2023-11-03
| | | | | | | Previously, 'rightleftcmd' was implemented by having all code which would affect msg_col or output screen cells be conditional on `cmdmsg_rl`. This change removes all that and instead implements rightleft as a mirroring post-processing step.
* docs: small fixes (#25585)dundargoc2023-10-29
| | | | Co-authored-by: tmummert <doczook@gmx.de> Co-authored-by: parikshit adhikari <parikshitadhikari@gmail.com>
* vim-patch:8.1.0822: peeking and flushing output slows down execution (#25629)zeertzjq2023-10-14
| | | | | | | Problem: Peeking and flushing output slows down execution. Solution: Do not update the mode message when global_busy is set. Do not flush when only peeking for a character. (Ken Takata) https://github.com/vim/vim/commit/cb574f415486adff645ce384979bfecf27f5be8c
* fix(grid): add start column when getting char on line (#25627)zeertzjq2023-10-13
|
* 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)
* refactor(message): simplify msg_puts_display and use batched grid updatesbfredl2023-10-03
| | | | | | | | | msg_puts_display was more complex than necessary in nvim, as in nvim, it no longer talks directly with a terminal. In particular we don't need to scroll the grid before emiting the last char. The TUI already takes care of things like that, for terminals where it matters.
* 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
|
* 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.
* 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.
* 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.
* vim-patch:9.0.1742: wrong curswant when clicking on second cell of ↵zeertzjq2023-08-19
| | | | | | | | | | | double-width char (#24789) Problem: Wrong curswant when clicking and the second cell of a double-width char. Solution: Don't copy virtcol of the first char to the second one. closes: vim/vim#12842 https://github.com/vim/vim/commit/9994160bfe74501886bbbf5631aec8ea2ae05991
* refactor(grid.c): remove duplicate assignmentszeertzjq2023-08-18
| | | They were removed from Vim in patch 9.0.0638.
* vim-patch:9.0.1725: cursor pos wrong after concealed text with 'virtualedit'zeertzjq2023-08-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Wrong cursor position when clicking after concealed text with 'virtualedit'. Solution: Store virtual columns in ScreenCols[] instead of text columns, and always use coladvance() when clicking. This also fixes incorrect curswant when clicking on a TAB, so now Test_normal_click_on_ctrl_char() asserts the same results as the ones before patch 9.0.0048. closes: vim/vim#12808 https://github.com/vim/vim/commit/e500ae8e29ad921378085f5d70ee5c0c537be1ba Remove the mouse_adjust_click() function. There is a difference in behavior with the old mouse_adjust_click() approach: when clicking on the character immediately after concealed text that is completely hidden, cursor is put on the clicked character rather than at the start of the concealed text. The new behavior is better, but it causes unnecessary scrolling in a functional test (which is an existing issue unrelated to these patches), so adjust the test. Now fully merged: vim-patch:9.0.0177: cursor position wrong with 'virtualedit' and mouse click
* fix(folds): fix missing virt_lines above when fold is hidden (#24274)zeertzjq2023-07-07
|
* vim-patch:9.0.1626: Visual area not shown when using 'showbreak' (#23978)zeertzjq2023-06-11
| | | | | | | | | | Problem: Visual area not shown when using 'showbreak' and start of line is not visible. (Jaehwang Jung) Solution: Adjust "fromcol" for the space taken by 'showbreak'. (closes vim/vim#12514) https://github.com/vim/vim/commit/f578ca2c8f36b61ac3301fe8b59a8473c964cdc2 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:9.0.1602: stray character visible if marker on top of double-wide ↵zeertzjq2023-06-04
| | | | | | | | | | char (#23897) Problem: Stray character is visible if 'smoothscroll' marker is displayed on top of a double-wide character. Solution: When overwriting a double-width character with the 'smoothscroll' marker clear the second half. (closes vim/vim#12469) https://github.com/vim/vim/commit/ecb87dd7d3f7b9291092a7dd8fae1e59b9903252
* vim-patch:9.0.1598: screenchar() and others are wrong with DBCS 'encoding' ↵zeertzjq2023-06-02
| | | | | | | | | | (#23872) Problem: screenchar(), screenchars() and screenstring() do not work properly when 'encoding' is set to a double-byte encoding. Solution: Fix the way the bytes of the characters are obtained. (issue vim/vim#12469) https://github.com/vim/vim/commit/47eec6716b8621fd43bac8ecc9c19089df26705e
* fix(redraw): overwrite double-width char with virt_text properly (#23708)zeertzjq2023-05-22
|
* fix(ui): adjust 'smoothscroll' for inner dimensionsLuuk van Baal2023-05-02
|
* vim-patch:9.0.0758: "precedes" from 'listchars' overwritten by <<<Luuk van Baal2023-05-02
| | | | | | | | | Problem: "precedes" from 'listchars' overwritten by <<< for 'smoothscroll'. Solution: Keep the "precedes" character. https://github.com/vim/vim/commit/13cdde39520220bb856cba16626327c706752b51 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:9.0.0757: line number not visisble with 'smoothscroll', 'nu' and 'rnu'Luuk van Baal2023-05-02
| | | | | | | | | Problem: Line number not visisble with 'smoothscroll', 'nu' and 'rnu'. Solution: Put the ">>>" after the line number instead of on top. https://github.com/vim/vim/commit/eb4de629315f2682d8b314462d02422ec98d751a Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:9.0.0681: "<<<" shows for 'smoothscroll' even when 'showbreak is setLuuk van Baal2023-05-02
| | | | | | | | | Problem: "<<<" shows for 'smoothscroll' even when 'showbreak is set. Solution: When 'showbreak' is set do not display "<<<". https://github.com/vim/vim/commit/0937b9fb244949b7ce9bfcf8398d7495b9b6aa85 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:9.0.0649: no indication the first line is broken for 'smoothscroll'Luuk van Baal2023-05-02
| | | | | | | | | Problem: No indication when the first line is broken for 'smoothscroll'. Solution: Show "<<<" in the first line. https://github.com/vim/vim/commit/406b5d89e18742ac6e6256ffc72fb70a27f0148b Co-authored-by: Bram Moolenaar <Bram@vim.org>
* refactor: remove use of reserved c++ keywordsii142023-04-06
| | | | | | libnvim couldn't be easily used in C++ due to the use of reserved keywords. Additionally, add explicit casts to *alloc function calls used in inline functions, as C++ doesn't allow implicit casts from void pointers.
* refactor: add const and remove unnecessary casts (#22841)ii142023-04-01
|
* test: use a wider screen in the rightleft winhl test (#22641)zeertzjq2023-03-12
| | | With a wide screen this actually previously caused an overflow.
* fix(screen): correctly draw background and eob with 'rightleft' (#22640)zeertzjq2023-03-12
|
* fix(status): handle unprintable chars in the statuslineBjörn Linse2023-02-14
|
* refactor: reduce scope of locals as per the style guide 3 (#22221)dundargoc2023-02-12
| | | refactor: reduce scope of locals as per the style guide
* refactor: reduce scope of locals as per the style guide (#22211)dundargoc2023-02-11
|
* vim-patch:partial:9.0.1237: code is indented more than necessary (#21971)zeertzjq2023-01-24
| | | | | | | | | Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes vim/vim#11858) https://github.com/vim/vim/commit/6ec66660476562e643deceb7c325cd0e8c903663 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
* refactor: replace char_u with char 21 (#21779)dundargoc2023-01-14
| | | | | refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
* refactor: replace char_u with chardundargoc2023-01-09
| | | | Work on https://github.com/neovim/neovim/issues/459
* build: allow IWYU to fix includes for all .c filesdundargoc2022-11-15
| | | | | | | | | | Allow Include What You Use to remove unnecessary includes and only include what is necessary. This helps with reducing compilation times and makes it easier to visualise which dependencies are actually required. Work on https://github.com/neovim/neovim/issues/549, but doesn't close it since this only works fully for .c files and not headers.
* fix(redraw): make redrawdebug=nodelta handle all the casesbfredl2022-09-22
| | | | | | Before only win_line lines were considered. this applies nodelta to all screen elements. Causes some failures, which might indeed indicate excessive redraws.
* refactor: replace char_u with charDundar Göc2022-09-09
| | | | Work on https://github.com/neovim/neovim/issues/459