Files
neovim/scripts
bfredl e656d7be2e perf(tui): faster implementation of terminfo
The processing of terminfo can be separated into two steps:

1. The initialization of terminfo, which includes trying to find $TERM
   in a terminfo database file. As a fallback, common terminfo
   definitions are compiled in. After this, we apply a lot of ad-hoc
   patching to cover over limitations of terminfo.

2. While processing updates from nvim, actually using terminfo strings
   and formatting them with runtime values. for this part, terminfo
   essentially is a hyper-enhanced version of snprintf(), including
   a sm0l stack based virtual machine which can manipulate the runtime
   parameters.

This PR completely replaces libuniblium for step 2, with code
vendored from NetBSD's libtermkey which has been adapted to use typesafe
input parameters and to write into an output buffer in place.

The most immedatiate effects is a performance enhancement of
update_attrs() which is a very hot function when profiling the
TUI-process part of screen updates. In a stupid microbenchmark
(essentially calling nvim__screenshot over and over in a loop) this
leads to a speedup of ca 1.5x for redrawing the screen on the TUI-side.
What this means in practise when using nvim as a text editor is probably
no noticible effect at all, and when reabusing nvim as idk a full screen
RGB ASCII art rendrer maybe an increase from 72 to 75 FPS LMAO.

As nice side-effect, reduce the usage of unibilium to initialization only..
which will make it easier to remove, replace or make unibilium optional,
adressing #31989. Specifically, the builtin fallback doesn't use
unibilium at all, so a unibilium-free build is in principle possible
if the builtin definitions are good enough.

As a caveat, this PR doesn't touch libtermkey at all, which still has a
conditional dependency on unibilium. This will be investigated in a
follow-up PR

Note: the check of $TERMCOLOR was moved from tui/tui.c to
_defaults.lua in d7651b27d5 as we want to
skip the logic in _defaults.lua if the env var was set, but there
is no harm in TUI getting the right value when the TUI is trying to
initialize its terminfo shenanigans. Also this check is needed when
a TUI connects to a `--headless` server later, which will observe
a different $TERMCOLOR value than the nvim core process itself.
2025-10-18 11:36:16 +02:00
..
2024-05-11 18:14:03 +08:00
2025-09-03 23:03:51 -04:00
2025-09-03 23:03:51 -04:00
2025-01-09 09:26:45 -08:00