aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/tui/tui.c
Commit message (Collapse)AuthorAge
* refactor: fix headers with IWYUdundargoc2023-11-28
|
* refactor: rename types.h to types_defs.hdundargoc2023-11-27
|
* build(IWYU): fix includes for func_attr.hdundargoc2023-11-27
|
* refactor: move Arena and ArenaMem to memory_defs.h (#26240)zeertzjq2023-11-27
|
* 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.
* refactor(tui): remove unnecessary scheduling when suspending (#26190)zeertzjq2023-11-24
| | | | Nvim no longer calls loop_poll_events() when suspending, so it isn't necessary to schedule suspend_event.
* build: adjust clang-tidy warning exclusion logicdundargoc2023-11-20
| | | | | | | Enable all clang-tidy warnings by default instead of disabling them. This ensures that we don't miss useful warnings on each clang-tidy version upgrade. A drawback of this is that it will force us to either fix or adjust the warnings as soon as possible.
* 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.
* build: bump uncrustify versiondundargoc2023-11-19
| | | | Biggest change is that uncrustify is silent during linting.
* refactor(tui): use termkey_interpret_modereportGregory Anders2023-11-17
| | | | | The sign extension issue has been fixed upstream, so we no longer need to use our own workaround.
* refactor(tui): refactor Kitty keyboard query implementationGregory Anders2023-11-17
| | | | | | | | | | | | | | | | | | | Refactor our implementation of querying for Kitty keyboard protocol support: - Remove usage of the "extkeys" term. This is not standard or really used elsewhere. Use "key encoding" instead - Replace usages of "CSIu" with "Kitty". "Kitty keyboard protocol" is vastly more common than "CSIu" now - Replace the countdown response counter with a simple boolean flag. We don't actually need a countdown counter because we request the primary device attributes along with the Kitty keyboard query, so we will always receive a "terminating event", making a countdown/timer unnecessary - Move the CSI response handling into a dedicated function - Bypass Unibilium for sending key encoding escape sequences. These sequences are not part of terminfo and do not have any parameters, so there's no reason to go through Unibilium
* fix(tui): handle cursor visibility properly (#26091)zeertzjq2023-11-17
| | | | The test is for the case without 'termsync' because libvterm doesn't support synchronized output, and it passes without this PR.
* refactor: iwyu (#26062)zeertzjq2023-11-16
|
* fix(tui): do not toggle cursor visibility when flushing the buffer (#26055)Gregory Anders2023-11-15
| | | | | | | | | | | | | | | | | | | | | | When writing large amounts of data to the tty it is common to first hide the cursor to avoid a flickering effect. This has been done in Nvim for a long time and was implemented in the function that actually flushed the TUI buffer out to the TTY. However, when using synchronized updates with the 'termsync' option this is no longer necessary, as the terminal emulator will buffer all of the updates and display them atomically. Thus there is no need to toggle the cursor visibility when flushing the buffer when synchronized updates are used. In fact, doing so can actually reintroduce cursor flickering in certain scenarios because the visibility state is itself being synchronized by the terminal. In addition, the management of the cursor visibility should not happen when the TUI _buffer_ is flushed, but rather when the TUI itself is flushed. This is a subtle but meaningful distinction: the former literally writes bytes to the TTY while the latter flushes the TUI's grid into its buffer. There is no need to hide the cursor every time we write bytes to the TTY, only at the beginning of a full TUI "flush" event.
* feat(tui): add 'termsync' option (#25871)Gregory Anders2023-11-14
| | | | | | | The 'termsync' option enables a mode (provided the underlying terminal supports it) where all screen updates during a redraw cycle are buffered and drawn together when the redraw is complete. This eliminates tearing or flickering in cases where Nvim redraws slower than the terminal redraws the screen.
* refactor: move background color detection into LuaGregory Anders2023-11-13
|
* 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: 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.
* build(iwyu): add a few more _defs.h mappings (#25435)zeertzjq2023-09-30
|
* fix(tui): make :cquit work properly with remote TUI (#25313)zeertzjq2023-09-23
|
* fix(tui): don't overwrite an assertion faliure message on exitbfredl2023-09-21
| | | | | | | | | | | | | | | If nvim exited with nonzero status this is for one of the two reasons - `:cquit` was invoked. This is used by users and plugins to communicate a result, like a nonzero status will fail a `git commit` operation - There was an internal error or deadly signal. in this case an error message was likely written to stderr or to the screen. In the latter case, the error message was often hidden by the TUI exiting altscreen mode, which erases all visible terminal text. This change prevents this in the latter case, while still cleaning up the terminal properly when `:cquit` was deliberatily invoked. Other cleanup like exiting mouse mode and raw mode is still done.
* 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.
* fix(tui): restore title before exiting alternate screen (#23776)zeertzjq2023-05-27
| | | | Since title stack is now saved after entering alternate screen, it makes more sense to restore title before exiting alternate screen.
* refactor(api): new helper macrosFamiu Haque2023-05-23
| | | | Adds new API helper macros `CSTR_AS_OBJ()`, `STATIC_CSTR_AS_OBJ()`, and `STATIC_CSTR_TO_OBJ()`, which cleans up a lot of the current code. These macros will also be used extensively in the upcoming option refactor PRs because then API Objects will be used to get/set options. This PR also modifies pre-existing code to use old API helper macros like `CSTR_TO_OBJ()` to make them cleaner.
* fix(tui): make disabling title restore old title from stack (#23585)zeertzjq2023-05-19
| | | | This makes setting 'notitle' in Nvim behave more like Vim in terminals that support title stacking.
* Merge pull request #23415 from zeertzjq/sigwinch-redrawbfredl2023-05-06
|\ | | | | fix(tui): redraw on SIGWINCH even if size didn't change
| * fix(tui): redraw on SIGWINCH even if size didn't changezeertzjq2023-05-01
| |
* | fix(tui): grid_clear properly clears the screenLuuk van Baal2023-05-03
|/ | | | | | | Problem: When setting a shell size smaller than the containing terminal window through `:winsize` or `:set lines/columns` the screen is not properly cleared. Solution: Clear the tui dimensions rather than the grid dimensions.
* fix(tui): position cursor at bottom-left before stopping (#23369)zeertzjq2023-04-28
| | | Fix #23361
* refactor: uncrustifydundargoc2023-04-26
| | | | Notable changes: replace all infinite loops to `while(true)` and remove `int` from `unsigned int`.
* build: update uncrustify to 0.76Lewis Russell2023-04-19
|
* refactor(build): graduate unibilium VAR_FROM feature from 2017bfredl2023-03-03
|
* fix(tui): avoid stack-use-after-scope with cursor color (#22435)zeertzjq2023-02-28
|
* fix(tui): properly check if stdin is a tty (#22321)zeertzjq2023-02-19
| | | | | | After #21831 `in_fd` is no longer set to stderr when starting TUI, so check for `stdin_isatty` instead. Fix #22259.
* fix: uv_tty_set_mode failed in Windows #22264Enan Ajmain2023-02-14
| | | | | | | | Problem: uv_tty_set_mode on stdout in Windows exits with error. Cause: Windows cannot set the properties of the output of a tty. Solution: Remove call to uv_tty_set_mode. Ref: #21445 Ref: https://github.com/libuv/libuv/commit/88634c1405097c19582e870d278dd0e29dc55455#r100598822
* fix(tui): exit on input eofzeertzjq2023-02-14
|
* build: enable MSVC level 3 warnings (#21934)dundargoc2023-02-11
| | | | | | MSVC has 4 different warning levels: 1 (severe), 2 (significant), 3 (production quality) and 4 (informational). Enabling level 3 warnings mostly revealed conversion problems, similar to GCC/clang -Wconversion flag.
* refactor(exit): pass error message to preserve_exit() (#22097)zeertzjq2023-02-04
| | | | | | | | | | | | | | | Problem: 1. Some calls to preserve_exit() don't put a message in IObuff, so the IObuff printed by preserve_exit() contains unrelated information. 2. If a TUI client runs out of memory or receives a deadly signal, the error message is shown on alternate screen and cannot be easily seen because the TUI exits alternate screen soon afterwards. Solution: Pass error message to preserve_exit() and exit alternate screen before printing it. Note that this doesn't fix the problem that server error messages cannot be easily seen on exit. This is tracked in #21608 and #21843.
* fix(tui): detach/attach on suspend/resume (#22040)zeertzjq2023-02-02
| | | | | | | | | | | | | | | | | | Problem: When a TUI client is suspended it still receives UI events from the server, and has to process these accumulated events when it is resumed. With mulitple TUI clients this is a bigger problem, considering the following steps: 1. A TUI client is attached. 2. CTRL-Z is pressed and the first client is suspended. 3. Another TUI client is attached. 4. CTRL-Z is pressed and a "suspend" event is sent to both clients. The second client is suspended, while the first client isn't able to process the event because it has already been suspended. 5. The first client is resumed. It processes the accumulated "suspend" event and suspends immediately. Solution: Make a TUI client detach on suspend and re-attach on resume.
* fix(exit): skip unnecessary steps in TUI preserve_exit() (#21897)zeertzjq2023-02-02
| | | | This prevents the TUI from doing unexpected things when receiving a deadly signal or running out of memory.
* fix(tui): set stdin as "blocking" on exit (#21973)zeertzjq2023-01-25
| | | | | | | | This fixes a regression from #21605 that stdin is no longer set as "blocking" after Nvim TUI exits, and the problems described in #2598 happen again. I'm not sure if this should be done in TUI code or common exiting code. I added this call in tui_stop() as it is also present in tui_suspend().
* feat(tui): support altfont mode in tui.cPaul "LeoNerd" Evans2023-01-24
|
* refactor(highlight): reshape the HL_UNDER* bits into a 3-bit integer maskPaul "LeoNerd" Evans2023-01-24
| | | | Saves two bits for reuse for new features
* Merge pull request #21831 from bfredl/nofdbfredl2023-01-16
|\ | | | | fix(ui): re-organize tty fd handling and fix issues
| * fix(ui): re-organize tty fd handling and fix issuesbfredl2023-01-16
| | | | | | | | | | | | | | - Use the correct fd to replace stdin on windows (CONIN) - Don't start the TUI if there are no tty fd (not a regression, but makes sense regardless) - De-mythologize "global input fd". it is just STDIN.
* | refactor: fix IWYU mapping file and use IWYU (#21802)dundargoc2023-01-15
|/ | | Also add the EXITFREE definition to main_lib rather than the nvim target, as the header generation needs the EXITFREE flag to work properly.
* fix(tui): do not invoke loop recursively for pad()bfredl2023-01-06
| | | | fixes #21610
* refactor(ui): devirtualize the ui layerbfredl2023-01-05
| | | | | | | | | | | | | | | | | - The defined interface for the UI is only the RPC protocol. The original UI interface as an array of function pointers fill no function. - On the server, all the UI:s are all RPC channels. - ui.c is only used on the server. - The compositor is a preprocessing step for single-grid UI:s - on the client, ui_client and tui talk directly to each other - we still do module separation, as ui_client.c could form the basis of a libnvim client module later. Items for later PR:s - vim.ui_attach is still an unhappy child, reconsider based on plugin experience. - the flags in ui_events.in.h are still a mess. Can be simplified now. - UX for remote attachment needs more work. - startup for client can be simplified further (think of the millisecs we can save)
* fix(tui): make a copy of data->params before unibi_format() (#21643)zeertzjq2023-01-05
| | | | | | | | Problem: When unibi_format() modifies params and data->buf overflows, unibi_format() is called again, causing the params to be modified twice. This can happen for escapes sequences that use the %i terminfo format specifier (e.g. cursor_address), which makes unibi_format() increase the param by 1. Solution: Make a copy of data->params before calling unibi_format().