aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/statusline.c
Commit message (Collapse)AuthorAge
* fix(statusline): overwriting stl_items with nvim_eval_statusline() {-item #32265luukvbaal2025-02-02
| | | | | | | | | | Problem: When an evaluation {-item calls `nvim_eval_statusline()`, that nested call may overwrite the same memory used for `stl_items`. Solution: Make `curitem` static and use it to compute an offset to avoid overwriting `stl_items` in nested calls to `build_stl_str_hl()`. Move miscellaneous statusline tests into `describe()` block.
* fix(mouse): 'statuscolumn' fold and popopmenu handlingLuuk van Baal2025-01-23
| | | | | | | | | Problem: A right-click on the 'statuscolumn' does not open the popupmenu, even if a cell without a clickdef is clicked. Clicking the %C fold item does not open/close the fold. Solution: Open the popupmenu when there is no clickdef like right-clicking the sign/numbercolumn does. Fill "linebuf_vcol" when drawing the 'statuscolumn' to handle foldcolumn item clicks.
* feat(api): combined highlights in nvim_eval_statusline()Luuk van Baal2025-01-23
| | | | | | | | | | | Problem: Combined highlighting was not applied to nvim_eval_statusline(), and 'statuscolumn' sign segment/numhl highlights. Solution: Add an additional `groups` element to the return value of `nvim_eval_statusline()->highlights`. This is an array of stacked highlight groups (highest priority last). Also resolve combined highlights for the 'statuscolumn' sign segment/numhl highlights. Expose/synchronize some drawline.c logic that is now mimicked in three different places.
* vim-patch:9.1.1028: too many strlen() calls in screen.c (#32083)zeertzjq2025-01-18
| | | | | | | | | | | Problem: too many strlen() calls in screen.c Solution: refactor screen.c and remove calls to strlen(), verify that leadmultispace != NULL (John Marriott) closes: vim/vim#16460 https://github.com/vim/vim/commit/c15de972e8131def2f506bb9eb6b306ca089629c Co-authored-by: John Marriott <basilisk@internode.on.net>
* vim-patch:9.1.1021: string might be used without a trailing NUL (#32062)zeertzjq2025-01-17
| | | | | | | | | | Problem: string might be used without a trailing NUL (after v9.1.0997) Solution: Make sure that the buffer is NUL terminated closes: vim/vim#16457 https://github.com/vim/vim/commit/70dfc374ec72634a0a61aea8344178779675d516 Co-authored-by: John Marriott <basilisk@internode.on.net>
* vim-patch:9.1.0997: too many strlen() calls in drawscreen.c (#31927)zeertzjq2025-01-09
| | | | | | | | | | Problem: too many strlen() calls in drawscreen.c Solution: refactor drawscreen.c and remove calls to strlen(), make get_keymap_str() (in screen.c) return string length instead of TRUE/FALSE (John Marriott). https://github.com/vim/vim/commit/a21240b97debea2e087aee6ad1488b5f075d1259 Co-authored-by: John Marriott <basilisk@internode.on.net>
* refactor: iwyu #31637Justin M. Keyes2024-12-23
| | | Result of `make iwyu` (after some "fixups").
* feat(ui): don't show unfocusable windows in :tabs, 'tabline' #27984luukvbaal2024-11-16
| | | | | | | Problem: Floating windows with focusable set to false can reasonably be expected to be UI elements but are listed in some outputs that should contain only regular windows. Solution: Hide unfocusable floating windows from the default tabline and :tabs.
* refactor(highlight): make enum of builtin highlights start with 1bfredl2024-11-13
| | | | | This makes it possible to use HLF_ values directly as highlight id:s and avoids +1 adjustments especially around messages.
* feat(ext_messages): add hl_id to ext_messages chunksLuuk van Baal2024-11-09
| | | | | | | | Problem: Ext_messages chunks only contain the highlight attr id, which is not very useful for vim.ui_attach() consumers. Solotion: Add highlight group id to message chunks, which can easily be used to highlight text in the TUI through nvim_buf_set_extmark(): hl_group = synIDattr(id, "name").
* feat(ui): statusline text inherits highlights #29976Riley Bruins2024-10-12
| | | Changes apply to the winbar, statusline, and tabline text.
* fix(tabline): restore behavior of click after last tabpage (#30602)zeertzjq2024-10-01
| | | Also correct the comments about tabpage labels in custom tabline.
* refactor(api)!: rename Dictionary => DictJustin M. Keyes2024-09-23
| | | | | | | | | | | | | | In the api_info() output: :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val') ... {'return_type': 'ArrayOf(Integer, 2)', 'name': 'nvim_win_get_position', 'method': v:true, 'parameters': [['Window', 'window']], 'since': 1} The `ArrayOf(Integer, 2)` return type didn't break clients when we added it, which is evidence that clients don't use the `return_type` field, thus renaming Dictionary => Dict in api_info() is not (in practice) a breaking change.
* vim-patch:9.0.0634: evaluating "expr" options has more overhead than neededzeertzjq2024-08-02
| | | | | | | | | | | | | | | | | | Problem: Evaluating "expr" options has more overhead than needed. Solution: Use call_simple_func() for 'foldtext', 'includeexpr', 'printexpr', "expr" of 'spellsuggest', 'diffexpr', 'patchexpr', 'balloonexpr', 'formatexpr', 'indentexpr' and 'charconvert'. https://github.com/vim/vim/commit/a4e0b9785e409e9e660171cea76dfcc5fdafad9b vim-patch:9.0.0635: build error and compiler warnings Problem: Build error and compiler warnings. Solution: Add missing change. Add type casts. https://github.com/vim/vim/commit/3292a229402c9892f5ab90645fbfe2b1db342f5b Co-authored-by: Bram Moolenaar <Bram@vim.org>
* refactor: collapse statements in single assignmentsLewis Russell2024-07-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Variables are often assigned multiple places in common patterns. Solution: Replace these common patterns with different patterns that reduce the number of assignments. Use `MAX` and `MIN`: ```c if (x < y) { x = y; } // --> x = MAX(x, y); ``` ```c if (x > y) { x = y; } // --> x = MIN(x, y); ``` Use ternary: ```c int a; if (cond) { a = b; } els { a = c; } // --> int a = cond ? b : c; ```
* feat(column)!: rework 'statuscolumn' %r/l itemsLuuk van Baal2024-06-16
| | | | | | | Problem: A custom 'statuscolumn' needs to check a bunch of options and placed signs to replicate the default number column. Solution: Rework %l item to include the necessary logic to mimic the default number column. Remove now redundant %r item.
* refactor: remove redundant copy in statuscolumn itemsLuuk van Baal2024-06-16
| | | | | Immediately write to buf_tmp instead of to another temporary buffer that is later copied to buf_tmp. Misc cleanup.
* revert: "refactor: use S_LEN macro" (#29319)Lewis Russell2024-06-14
| | | | | revert: "refactor: use S_LEN(s) instead of s, n (#29219)" This reverts commit c37695a5d5f2e8914fff86f3581bed70b4c85d3c.
* refactor: use S_LEN(s) instead of s, n (#29219)James2024-06-11
|
* refactor(options): remove `set_string_option_direct()`Famiu Haque2024-03-21
| | | | | | Problem: `set_string_option_direct()` contains a separate codepath specifically for setting string options. Not only is that unnecessary code duplication, but it's also limited to only string options. Solution: Replace `set_string_option_direct()` with `set_option_direct()` which calls `set_option()` under the hood. This reduces code duplication and allows directly setting an option of any type.
* vim-patch:9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()zeertzjq2024-03-14
| | | | | | | | | | | | Problem: More code can use ml_get_buf_len() instead of STRLEN(). Solution: Change more STRLEN() calls to ml_get_buf_len(). Also do not set ml_line_textlen in ml_replace_len() if "has_props" is set, because "len_arg" also includes the size of text properties in that case. (zeertzjq) closes: vim/vim#14183 https://github.com/vim/vim/commit/94b7c3233ef534acc669b3083ed1fe59cf3a090b
* vim-patch:9.0.0245: mechanism to prevent recursive screen updating is ↵zeertzjq2024-02-13
| | | | | | | | | | | incomplete (#27448) Problem: Mechanism to prevent recursive screen updating is incomplete. Solution: Add "redraw_not_allowed" and set it in build_stl_str_hl(). (issue vim/vim#10952) https://github.com/vim/vim/commit/471c0fa3eed4f6207d1cb7636970547bfd2eee26 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* refactor(api): refactor more api functions to use arena returnbfredl2024-02-08
| | | | | | | | | | | | | | | Currently having two separate memory strategies for API return values is a bit unnecessary, and mostly a consequence of converting the hot spot cases which needed it first. But there is really no downside to using arena everywhere (which implies also directly using strings which are allocated earlier or even statically, without copy). There only restriction is we need to know the size of arrays in advance, but this info can often be passed on from some earlier stage if it is missing. This collects some "small" cases. The more complex stuff will get a PR each.
* refactor(api): use keydict and arena for more api return valuesbfredl2024-02-08
| | | | | | | Implement api_keydict_to_dict as the complement to api_dict_to_keydict Fix a conversion error when nvim_get_win_config gets called from lua, where Float values "x" and "y" didn't get converted to lua numbers.
* fix(statusline): missing offset when showing 'keymap' (#27270)zeertzjq2024-01-31
|
* refactor(IWYU): fix headersdundargoc2024-01-11
| | | | | | Remove `export` pramgas from defs headers as it causes IWYU to believe that the definitions from the defs headers comes from main header, which is not what we really want.
* refactor(options): remove `OPT_FREE` (#26963)Famiu Haque2024-01-10
| | | | | | Problem: `OPT_FREE` macro doesn't seem to do anything as `P_ALLOCED` already handles allocations. Solution: Remove `OPT_FREE`.
* refactor(options): use schar_T representation for fillchars and listcharsbfredl2024-01-08
| | | | | | | | | | | A bit big, but practically it was a lot simpler to change over all fillchars and all listchars at once, to not need to maintain two parallel implementations. This is mostly an internal refactor, but it also removes an arbitrary limitation: that 'fillchars' and 'listchars' values can only be single-codepoint characters. Now any character which fits into a single screen cell can be used.
* fix(column): fill 'statuscolumn' clickdefs with evaluated width (#26891)luukvbaal2024-01-05
|
* refactor(column): define and use maximum 'statuscolumn' widthLuuk van Baal2024-01-04
| | | | | Problem: The maximum 'statuscolumn' width and grow behavior is undocumented. Solution: Define, use and document the maximum 'statuscolumn' width and grow behavior.
* fix(drawline): consider position in linebuf for foldcolumn (#26803)luukvbaal2024-01-02
|
* refactor: follow style guidedundargoc2023-12-30
|
* refactor(drawline): remove maybe_wlv argument for foldcolumn (#26798)luukvbaal2023-12-30
| | | | Problem: fill_foldcolumn() has an optional winlinevars_T argument. Solution: Increment wlv->off at callsite.
* refactor(drawline): avoid writing foldopen before writing foldclosedLuuk van Baal2023-12-29
|
* refactor(drawline): avoid storing info to draw 'statuscolumn' (#26712)luukvbaal2023-12-23
| | | | | We no longer return to the main loop in win_line() to put column characters on the screen. Simplify and sync statuscolumn drawing logic with that of statusline.
* Merge pull request #26528 from bfredl/nodrawstatebfredl2023-12-22
|\ | | | | refactor(drawline): remove LineDrawState and wlv->saved_n_extra
| * refactor(drawline): remove LineDrawState and wlv->saved_n_extrabfredl2023-12-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We do not need an enum to keep track of what place in win_line() we currently are at. We already have a variable which keeps track where in the code we currently are (and thus what part of the line we are currently rendering), it is called the _program counter_. When we need non-linear or self-referential control-flow anyway for a laugh, we have a mechanism for that, it is called _function calls_. Do not "save" and "restore" the wlv->n_extra state every time the columns are to be drawn. This sort of thing needs to go away. Instead of setting the n_extra variables and then going to the outer while loop, the text in the columns can be rendered by just simply putting the text into the cells of the screen line, right away. Even in nvim this can be tricky sometimes, luckily we can use function calls to abstract this logic, which means that this handy data structure called the _call stack_ is handling saving away state temporarily, and restoring it back when we need it again. Lastly, but not least, as we now have direct control how signs are rendered, these can be stored as schar_T[2] and be directly put on screen as such.
* | refactor: run IWYU on entire repodundargoc2023-12-21
|/ | | | Reference: https://github.com/neovim/neovim/issues/6371.
* refactor(IWYU): move decor provider types to decoration_defs.h (#26692)zeertzjq2023-12-21
|
* refactor: eliminate cyclic includesdundargoc2023-12-20
|
* refactor: use `bool` to represent boolean valuesdundargoc2023-12-19
|
* refactor(options): use hashy for finding options (#26573)Famiu Haque2023-12-17
| | | | | | | | | | | Problem: `findoption()` searches through the options[] table linearly for option names, even though hashy can be used to generate a compile-time hash table for it. Solution: Use hashy to generate a compile time hash table for finding options. This also allows handling option aliases, so we don't need separate options[] table entries for things like 'viminfo'.
* refactor(options): convert `opt_idx` variables to `OptIndex`Famiu Haque2023-12-09
|
* refactor(options): reduce `findoption()` usageFamiu Haque2023-12-09
| | | | | | Problem: Many places in the code use `findoption()` to access an option using its name, even if the option index is available. This is very slow because it requires looping through the options array over and over. Solution: Use option index instead of name wherever possible. Also introduce an `OptIndex` enum which contains the index for every option as enum constants, this eliminates the need to pass static option names as strings.
* refactor: move function macros out of vim_defs.h (#26300)zeertzjq2023-11-29
|
* refactor: move some constants out of vim_defs.h (#26298)zeertzjq2023-11-29
|
* refactor: fix headers with IWYUdundargoc2023-11-28
|
* build(IWYU): fix includes for undo_defs.hdundargoc2023-11-27
|
* 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