summaryrefslogtreecommitdiffstatshomepage
path: root/src/nvim/keycodes.c
AgeCommit message (Collapse)AuthorFiles
2026-04-12docs: miscJustin M. Keyes1
Close #38748 Close #38866 Co-authored-by: Mario Loriedo <mario.loriedo@gmail.com> Co-authored-by: Anakin Childerhose <anakin@childerhose.ca>
2025-08-14refactor(build): remove INCLUDE_GENERATED_DECLARATIONS guardsbfredl1
These are not needed after #35129 but making uncrustify still play nice with them was a bit tricky. Unfortunately `uncrustify --update-config-with-doc` breaks strings with backslashes. This issue has been reported upstream, and in the meanwhile auto-update on every single run has been disabled.
2025-05-23vim-patch:9.1.1402: multi-byte mappings not properly stored in session file ↵zeertzjq1
(#34131) Problem: multi-byte mappings not properly stored in session file Solution: unescape the mapping before writing out the mapping, prefer single-byte mapping name if possible (Miguel Barro) closes: vim/vim#17355 https://github.com/vim/vim/commit/5b07aff2f665f290f2ec4a5e6bcf9873a178149a Co-authored-by: GuyBrush <miguel.barro@live.com>
2025-03-28vim-patch:9.1.1247: fragile setup to get (preferred) keys from ↵zeertzjq1
key_name_entry (#33102) Problem: fragile setup to get (preferred) keys from key_name_entry (after v9.1.1179) Solution: refactor the code further, fix a bug with "pref_name" key entry introduced in v9.1.1180 (Yee Cheng Chin) The optimization introduced for using bsearch() with key_name_entry in vim/vim#16788 was fragile as it required synchronizing a non-obvious index (e.g. IDX_KEYNAME_SWU) with the array that could be accidentally changed by any one adding a key to it. Furthermore, the "pref_name" that was introduced in that change was unnecessary, and in fact introduced a bug, as we don't always want to use the canonical name. The bug is triggered when the user triggers auto-complete using a keycode, such as `:set <Scroll<Tab>`. The bug would end up showing two copies of `<ScrollWheelUp>` because both entries end up using the canonical name. In this change, remove `pref_name`, and simply use a boolean to track whether an entry is an alt name or not and modify logic to respect that. Add test to make sure auto-complete works with alt names closes: vim/vim#16987 https://github.com/vim/vim/commit/7d8e7df55190e8e4e5a66f443e4440b52edf2fdb In Nvim there is no `enabled` field, so put `is_alt` before `name` to reduce the size of the struct. Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2025-03-08perf(keycodes): use hashy for string lookupzeertzjq1
This is slightly faster than the binary search as per the benchmark, and allows handling the vim/vim#16821 situation in generator code.
2025-03-08vim-patch:partial:9.1.1179: too many strlen() calls in misc2.czeertzjq1
Problem: too many strlen() calls in misc2.c Solution: refactor misc2.c and use bsearch() instead of a linear search to find matches in the key_names_table array (John Marriott). This commit changes misc2.c to use bsearch() to perform string searches of the key_names_table array. Implementation detail: - Some entries in this array have alternate names. Add field alt_name to point to the alternate name. - Some entries in this array are only available if a given feature is defined. Keep them in the array, but add a boolean field enabled to indicate if the record can be used or not. If the feature is not available, the corresponding enabled field is set to FALSE. In my measurements running the test suite on a huge non-gui build on linux, the number of string comparisons in get_special_key_code(): Before (linear search): 2,214,957 After (binary search): 297,770 A side effect of this is 1477 calls to STRLEN() in get_special_key_name() for the same test run are no longer necessary. closes: vim/vim#16788 https://github.com/vim/vim/commit/4a1e6dacbb2cc833353983bea7eac38191c9d3b4 Skip the mouse shape changes. Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-03-08refactor(keycodes): generate key_names_table[] using Luazeertzjq1
This allows easier refactoring.
2025-02-20fix(keycodes): recognize <Find>, <Select> #28431Mantas Mikulėnas1
PuTTY sets TERM=xterm, but sends ESC[1~ and ESC[4~ for Home/End keys, which does not match what the 'xterm' terminfo has for khome/kend, so libtermkeys instead reports them as the original DEC VT220 names. The VT220 came with a DEC LK201 keyboard which had the following keys in the area above arrow keys (where PCs now have Ins/Del/Home/End/etc): ┌────────┬────────┬────────┐ │ Find │ Insert │ Re- │ │ │ Here │ move │ ├────────┼────────┼────────┤ │ Select │ Prev │ Next │ │ │ Screen │ Screen │ └────────┴────────┴────────┘ These would send ESC[x~ sequences in the expected order: ┌────────┬────────┬────────┐ │ ESC[1~ │ ESC[2~ │ ESC[3~ │ ├────────┼────────┼────────┤ │ ESC[4~ │ ESC[5~ │ ESC[6~ │ └────────┴────────┴────────┘ Modern terminals continue to use the same sequences for Ins/Del as well as PageUp/PageDn. But the VT220 keyboard apparently had no Home/End, and PuTTY apparently chose to re-purpose the Find/Select key sequences for Home/End (even though it claims to emulate Xterm and this doesn't match what actual Xterm does). So when Home/End are used in Neovim through PuTTY with TERM=xterm (the default setting), libtermkey finds no match for the received sequences in the terminfo database and defaults to reporting them as <Find> and <Select> respectively. PuTTY is not unique here -- tmux *also* sends ESC[1~ and ESC[4~ after its internal translation -- but the difference is that 'tmux' terminfo correctly maps them to Home/End so Neovim recognizes them as such, while PuTTY defaults to using 'xterm' which uses a different mapping. This initial patch only allows Neovim to recognize <Find> and <Select> key codes as themselves, so that the user could manually map them e.g. using ":imap <Find> <Home>". Alternatives: - Using TERM=putty(-256color) would of course be the most correct solution, but in practice it leads to other minor issues, e.g. the need to have different PuTTY config profiles for older or non-Linux systems that lack that terminfo, or tmux's insistence on rendering italics as reverse. - Using Neovim through tmux avoids the problem (as tmux recognizes ESC[1~ on input), but is something that needs to be manually run every time. The keycodes.h constants are slightly misnamed because K_SELECT was already taken for a different purpose.
2025-02-03vim-patch:9.1.1063: too many strlen() calls in userfunc.czeertzjq1
Problem: too many strlen() calls in userfunc.c Solution: refactor userfunc.c and remove calls to strlen(), drop set_ufunc_name() and roll it into alloc_ufunc(), check for out-of-memory condition in trans_function_name_ext() (John Marriott) closes: vim/vim#16537 https://github.com/vim/vim/commit/b32800f7c51c866dc0e87244eb4902540982309d Add missing change to call_user_func() from patch 8.1.1007. Consistently use PRIdSCID instead of PRId64 for script IDs. Co-authored-by: John Marriott <basilisk@internode.on.net>
2024-06-14revert: "refactor: use S_LEN macro" (#29319)Lewis Russell1
revert: "refactor: use S_LEN(s) instead of s, n (#29219)" This reverts commit c37695a5d5f2e8914fff86f3581bed70b4c85d3c.
2024-06-11refactor: use S_LEN(s) instead of s, n (#29219)James1
2024-06-01refactor: move shared messages to errors.h #26214Justin M. Keyes1
2024-02-04vim-patch:9.1.0073: Looping over modifier_keys_table unnecessarilyzeertzjq1
Problem: Looping over modifier_keys_table[] unnecessarily with only MOD_MASK_ALT or MOD_MASK_CMD, as modifier_keys_table[] only contains MOD_MASK_SHIFT and MOD_MASK_CTRL, and the loop won't do anything. Solution: Remove MOD_MASK_ALT and MOD_MASK_CMD from the condition. (zeertzjq) closes: vim/vim#13963 https://github.com/vim/vim/commit/0c989e4a3ae50085aa8c6bed5d6701760191bc1d
2024-02-03fix(keycodes): simplify S- properly when D- is present (#27316)zeertzjq1
2024-01-11refactor(IWYU): fix headersdundargoc1
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.
2023-12-24refactor: follow style guidedundargoc1
2023-12-23refactor: remove CPO_TO_CPO_FLAGS() (#26718)zeertzjq1
Just pass p_cpo to replace_termcodes() directly. This allows removing option_vars.h from keycodes.h, and also avoids the mistake of passing 0 as cpo_flags.
2023-12-21refactor: run IWYU on entire repodundargoc1
Reference: https://github.com/neovim/neovim/issues/6371.
2023-12-18docs: add style rule regarding initializationdundargoc1
Specifically, specify that each initialization should be done on a separate line.
2023-11-30build: don't define FUNC_ATTR_* as empty in headers (#26317)zeertzjq1
FUNC_ATTR_* should only be used in .c files with generated headers. Defining FUNC_ATTR_* as empty in headers causes misuses of them to be silently ignored. Instead don't define them by default, and only define them as empty after a .c file has included its generated header.
2023-11-29refactor: move function macros out of vim_defs.h (#26300)zeertzjq1
2023-11-28refactor: fix headers with IWYUdundargoc1
2023-11-27build(IWYU): fix includes for func_attr.hdundargoc1
2023-11-27build: enable IWYU on macdundargoc1
2023-11-19refactor: follow style guidedundargoc1
- reduce variable scope - prefer initialization over declaration and assignment
2023-11-13refactor: follow style guidedundargoc1
- reduce variable scope - prefer initialization over declaration and assignment - use bool to represent boolean values
2023-11-12build: remove PVSdundargoc1
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.
2023-10-29docs: small fixes (#25585)dundargoc1
Co-authored-by: tmummert <doczook@gmx.de> Co-authored-by: parikshit adhikari <parikshitadhikari@gmail.com>
2023-09-30build(iwyu): add a few more _defs.h mappings (#25435)zeertzjq1
2023-09-09vim-patch:partial:9.0.1886: Various Typoszeertzjq1
Problem: Various Typos Solution: Fix Typos This is a collection of typo related commits. closes: vim/vim#12753 closes: vim/vim#13016 https://github.com/vim/vim/commit/ee17b6f70d382ec6c5d8d27b56c4e84106ac8c55 Co-authored-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Adri Verhoef <a3@a3.xs4all.nl> Co-authored-by: Viktor Szépe <viktor@szepe.net> Co-authored-by: nuid64 <lvkuzvesov@proton.me> Co-authored-by: Meng Xiangzhuo <aumo@foxmail.com> Co-authored-by: Dominique Pellé <dominique.pelle@gmail.com>
2023-08-13fix(keycodes): recognize <t_xx> as a key (#24700)zeertzjq1
Problem: The result of keytrans() sometimes can't be translated back. Solution: Recognize <t_xx> as a key.
2023-08-12vim-patch:9.0.1687: mapset() not properly handling script ID (#24666)zeertzjq1
Problem: mapset() not properly handling script ID Solution: replace_termcodes() may accept a script ID closes: vim/vim#12699 closes: vim/vim#12697 https://github.com/vim/vim/commit/7e0bae024d4c1673cff31763227ad52b936fa56f
2023-04-26refactor: uncrustifydundargoc1
Notable changes: replace all infinite loops to `while(true)` and remove `int` from `unsigned int`.
2023-04-08refactor(mappings)!: remove #n as a notation for a function key (#17318)zeertzjq1
This notation is hardly used and makes the behavior of the from_part argument of nvim_replace_termcodes confusing.
2023-04-07refactor: remove redundant castsii141
2023-04-02refactor: remove char_u (#22829)dundargoc1
Closes https://github.com/neovim/neovim/issues/459
2023-03-05vim-patch:9.0.1380: CTRL-X on 2**64 subtracts two (#22530)zeertzjq1
Problem: CTRL-X on 2**64 subtracts two. (James McCoy) Solution: Correct computation for large number. (closes vim/vim#12103) https://github.com/vim/vim/commit/5fb78c3fa5c996c08a65431d698bd2c251eef5c7 Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-03-04refactor(log): reduce compile time LOG_LEVEL granularitybfredl1
2023-03-04refactor: replace char_u with char or uint8_t (#22400)dundargoc1
Work on https://github.com/neovim/neovim/issues/459
2023-02-12refactor: reduce scope of locals as per the style guide 3 (#22221)dundargoc1
refactor: reduce scope of locals as per the style guide
2023-02-11refactor: replace char_u with char (#21901)dundargoc1
refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
2023-01-19refactor: replace char_u with char 25 (#21838)dundargoc1
refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
2023-01-18refactor: replace char_u with char 24 (#21823)dundargoc1
refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
2023-01-14vim-patch:partial:9.0.1196: code is indented more than necessary (#21796)zeertzjq1
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes vim/vim#11813) https://github.com/vim/vim/commit/e8575988969579f9e1439181ae338b2ff74054a8 Partial port as this depends on some previous eval and 'smoothscroll' patches. Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-01-13refactor: replace char_u with char 20 (#21714)dundargoc1
refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
2023-01-09refactor: replace char_u with chardundargoc1
Work on https://github.com/neovim/neovim/issues/459
2022-12-21refactor: replace char_u with char 16 - remove STRNCMP (#21208)dundargoc1
refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
2022-11-26refactor: replace char_u with charDundar Göc1
Work on https://github.com/neovim/neovim/issues/459
2022-11-15build: allow IWYU to fix includes for all .c filesdundargoc1
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.
2022-11-01build(lint): remove clint.py rules for braces #20880dundargoc1
Uncrustify is the source of truth where possible. Remove any redundant checks from clint.py. See also https://github.com/neovim/neovim/pull/18563