aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ui_client.c
Commit message (Collapse)AuthorAge
* refactor: iwyu #31637Justin M. Keyes2024-12-23
| | | Result of `make iwyu` (after some "fixups").
* 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.
* feat(tui): builtin UI (TUI) sets client info #30397Justin M. Keyes2024-09-18
| | | | | | | | | | | | Problem: The default builtin UI client does not declare its client info. This reduces discoverability and makes it difficult for plugins to identify the UI. Solution: - Call nvim_set_client_info after attaching, as recommended by `:help dev-ui`. - Also set the "pid" field. - Also change `ui_active()` to return a count. Not directly relevant to this commit, but will be useful later.
* feat(log): use "ui" as default name for TUI client #30345Justin M. Keyes2024-09-11
| | | | | | | | | | | | | The default "session name" for the builtin TUI is "ui". before: INF 2024-09-10T14:57:35.385 hello.sock os_exit:692: Nvim exit: 1 INF 2024-09-10T14:57:35.388 ?.4543 os_exit:692: Nvim exit: 1 after: INF 2024-09-10T14:59:19.919 hello.sock os_exit:692: Nvim exit: 1 INF 2024-09-10T14:59:19.922 ui.5684 os_exit:692: Nvim exit: 1
* refactor(shada): rework msgpack decoding without msgpack-cbfredl2024-08-05
| | | | | | | This also makes shada reading slightly faster due to avoiding some copying and allocation. Use keysets to drive decoding of msgpack maps for shada entries.
* fix(ui_client): check return value of channel_job_start (#27729)Sean Dewar2024-03-04
| | | | | | | | | | | | Problem: null pointer member access in ui_client_start_server if channel_job_start returns NULL. Solution: check for it, return 0 in that case (which is already used to indicate failure and is handled by main). Happened on Linux when trying to run Nvim in an old gdbserver instance after having rebuilt Nvim since. This gave E903 (the nvim binary was deleted, so " (deleted)" appears as a suffix in the `v:progpath`, making it invalid), then ASAN complains due to the NPD; instead it now then prints "Failed to start Nvim server!", as expected.
* refactor(lua): use Arena when converting from lua stack to API argsbfredl2024-02-13
| | | | | | | | | | | | and for return value of nlua_exec/nlua_call_ref, as this uses the same family of functions. NB: the handling of luaref:s is a bit of a mess. add api_luarefs_free_XX functions as a stop-gap as refactoring luarefs is a can of worms for another PR:s. as a minor feature/bug-fix, nvim_buf_call and nvim_win_call now preserves arbitrary return values.
* feat(ui): add support for OSC 8 hyperlinks (#27109)Gregory Anders2024-01-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extmarks can contain URLs which can then be drawn in any supporting UI. In the TUI, for example, URLs are "drawn" by emitting the OSC 8 control sequence to the TTY. On terminals which support the OSC 8 sequence this will create clickable hyperlinks. URLs are treated as inline highlights in the decoration subsystem, so are included in the `DecorSignHighlight` structure. However, unlike other inline highlights they use allocated memory which must be freed, so they set the `ext` flag in `DecorInline` so that their lifetimes are managed along with other allocated memory like virtual text. The decoration subsystem then adds the URLs as a new highlight attribute. The highlight subsystem maintains a set of unique URLs to avoid duplicating allocations for the same string. To attach a URL to an existing highlight attribute we call `hl_add_url` which finds the URL in the set (allocating and adding it if it does not exist) and sets the `url` highlight attribute to the index of the URL in the set (using an index helps keep the size of the `HlAttrs` struct small). This has the potential to lead to an increase in highlight attributes if a URL is used over a range that contains many different highlight attributes, because now each existing attribute must be combined with the URL. In practice, however, URLs typically span a range containing a single highlight (e.g. link text in Markdown), so this is likely just a pathological edge case. When a new highlight attribute is defined with a URL it is copied to all attached UIs with the `hl_attr_define` UI event. The TUI manages its own set of URLs (just like the highlight subsystem) to minimize allocations. The TUI keeps track of which URL is "active" for the cell it is printing. If no URL is active and a cell containing a URL is printed, the opening OSC 8 sequence is emitted and that URL becomes the actively tracked URL. If the cursor is moved while in the middle of a URL span, we emit the terminating OSC sequence to prevent the hyperlink from spanning multiple lines. This does not support nested hyperlinks, but that is a rare (and, frankly, bizarre) use case. If a valid use case for nested hyperlinks ever presents itself we can address that issue then.
* 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: run IWYU on entire repodundargoc2023-12-21
| | | | Reference: https://github.com/neovim/neovim/issues/6371.
* docs: add style rule regarding initializationdundargoc2023-12-18
| | | | | Specifically, specify that each initialization should be done on a separate line.
* refactor: move non-symbols to defs.h headersdundargoc2023-12-17
|
* feat(defaults): enable 'termguicolors' by default when supported by terminalGregory Anders2023-12-06
| | | | | | | | | | | | Enable 'termguicolors' automatically when Nvim can detect that truecolor is supported by the host terminal. If $COLORTERM is set to "truecolor" or "24bit", or the terminal's terminfo entry contains capabilities for Tc, RGB, or setrgbf and setrgbb, then we assume that the terminal supports truecolor. Otherwise, the terminal is queried (using both XTGETTCAP and SGR + DECRQSS). If the terminal's response to these queries (if any) indicates that it supports truecolor, then 'termguicolors' is enabled.
* refactor: free more reachable memory with EXITFREE (#26349)zeertzjq2023-12-02
| | | Discovered using __sanitizer_print_memory_profile().
* build: don't define FUNC_ATTR_* as empty in headers (#26317)zeertzjq2023-11-30
| | | | | | 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.
* refactor: fix includes for api/autocmd.hdundargoc2023-11-27
|
* build(IWYU): fix includes for func_attr.hdundargoc2023-11-27
|
* build(IWYU): replace public-to-public mappings with pragmas (#26237)zeertzjq2023-11-27
|
* docs: deprecate the "term_background" UI fieldGregory 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.
* build(iwyu): add a few more _defs.h mappings (#25435)zeertzjq2023-09-30
|
* fix(startup): run embedded Nvim with real path (#24282)zeertzjq2023-07-08
| | | fix(startup): run embedded process with real path
* Merge pull request #23891 from rickyz/grid_line_flagsbfredl2023-07-03
|\ | | | | fix(ui): propagate line flags on grid_line events
| * fix(ui): propagate line wrapping state on grid_line eventsRicky Zhou2023-06-05
| | | | | | | | | | | | This fixes the TUI's line-wrapping behavior, which was broken with the migration to the msgpack-based UI protocol (see https://github.com/neovim/neovim/issues/7369#issuecomment-1571812273).
* | fix(tui): v:argv does not report the original argv[0] #24015t0muxx2023-06-14
|/ | | | | | | | | | Problem: Since TUI was moved to another process 24488169564c39a506c235bf6a33b8e23a8cb528 v:argv and v:progname don't report the original argv[0]. ["/usr/bin/nvim", "--embed", ...] Solution: Use argv[0] instead of VV_PROGPATH in ui_client_start_server(). Fix #23953
* 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.
* refactor: revert incorrect change to ui_client.c codebfredl2023-04-21
| | | | | | | | | - There is no "resource leak". - "return 0" is definitely not the correct behavior if we ever occur a platform where this would fail. - There was no problem here to fix. so let's not "fix" it. - once CI is upgraded to gcc 13, we'll figure out the correct way to make it shut the fuck up. warnings on non-ci platforms are not critical.
* fix(ui_client): check return code of dup()Andreas Schneider2023-04-21
| | | | | | | gsrc/nvim/ui_client.c: In function ‘ui_client_start_server’: gsrc/nvim/ui_client.c:68:5: warning: ignoring return value of ‘dup’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 68 | dup(stderr_isatty ? STDERR_FILENO : STDOUT_FILENO); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* refactor: remove redundant const char * castsii142023-04-07
|
* feat(api): more fields in nvim_list_uisJustin M. Keyes2023-02-27
| | | | | | | | Problem: nvim_list_uis does not report all ":help ui-option" fields. Solution: Store ":help ui-option" fields on the `UI` object and update ui_array.
* docs: fix typos (#22353)zeertzjq2023-02-22
|
* fix(tui): only forward stdin_fd on first attach (#22293)zeertzjq2023-02-17
|
* 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(unittests): fix TUI broken test previously ignoredbfredl2023-01-18
|
* 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(embed): handle stdio in server properlybfredl2023-01-09
| | | | | Rename stdin/stdout in the server, so that RPC data won't get corrupted. This also restores the use of stderr to write directly to the terminal.
* 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)
* refactor(api): do not allocate temporaries for internal eventsbfredl2023-01-03
|
* fix(tui): more work in the TUIbfredl2022-12-31
|
* feat(tui): run TUI as external processhlpr982022-12-31
|
* 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.
* perf(api): allow to use an arena for return valuesbfredl2022-08-23
|
* docs: fix typos (#19588)dundargoc2022-08-03
| | | | Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: notomo <notomo.motono@gmail.com>
* perf(ui): unpack grid_line (screen contents) directlybfredl2022-07-19
|
* perf(ui): unpack a single ui event at a time, instead of a "redraw" batchbfredl2022-07-18
| | | | | This reduces the memory overhead for large redraw batches, as a much smaller prefix of the api object buffer is used and needs to be hot in cache.