aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ui.c
Commit message (Collapse)AuthorAge
...
* UI: add "compositor" layer to merge grids for TUI use in a correct wayBjörn Linse2019-02-02
| | | | | | | | Initially we will use this for the popupmenu, floating windows will follow soon NB: writedelay + compositor is weird, we need more flexible redraw introspection.
* terminal: handle size when switching buffers in windowBjörn Linse2019-01-27
|
* window/ui: reorganize size variables, fix terminal window size with multigrid.Björn Linse2019-01-27
| | | | | | | wp->w_height_inner now contains the "inner" size, regardless if the window has been drawn yet or not. It should be used instead of wp->w_grid.Rows, for stuff that is not directly related to accessing the allocated grid memory, such like cursor movement and terminal size
* ui: multigrid mouse supportBjörn Linse2019-01-20
|
* build: enable -WshadowJustin M. Keyes2019-01-02
| | | | | | | | | | Note about shada.c: - shada_read_next_item_start was intentionally shadowing `unpacked` and `i` because many of the macros (e.g. ADDITIONAL_KEY) implicitly depended on those variable names. - Macros were changed to parameterize `unpacked` (but not `i`). Macros like CLEAR_GA_AND_ERROR_OUT do control-flow (goto), so any other approach is messy.
* multigrid: do all adjustment in screen.cBjörn Linse2019-01-01
| | | | | Adjustment will get more complex with floats, tabgrid etc, so make it into a function.
* multigrid: rename grid->ScreenLines and other grid arraysBjörn Linse2018-12-31
|
* multigrid: rename to grid.row_offset and grid.requested_rowsBjörn Linse2018-12-31
|
* multigrid: reorganize types and global varaiblesBjörn Linse2018-12-31
|
* multigrid: Fix lint errorsUtkarsh Maheshwari2018-12-31
|
* multigrid: Fix sending window grid handle in ext_newline modeUtkarsh Maheshwari2018-12-31
|
* multigrid: Put everything on default_grid if not ext_multigridUtkarsh Maheshwari2018-12-31
|
* multigrid: Add win_position eventUtkarsh Maheshwari2018-12-31
| | | | Throttle win_position events
* multigrid: Allow UIs to set grid size different from window sizeUtkarsh Maheshwari2018-12-31
|
* multigrid: Change screen_* functions to grid_* functionsUtkarsh Maheshwari2018-12-31
|
* log: rename do_log to logmsgJustin M. Keyes2018-09-19
|
* vim-patch:8.0.1809: various typosJan Edmund Lazo2018-09-11
| | | | | | Problem: Various typos. Solution: Correct the mistakes, change "cursur" to "cursor". (closes vim/vim#2887) https://github.com/vim/vim/commit/b9464821901623f983528acaed9e4dc2cea7387b
* tui: Hint wrapped lines to terminals.Ricky Zhou2018-09-03
| | | | | | | | | | | | | | | | Previously, when neovim would wrap a line across multiple lines, terminal emulators could not detect that the lines represent a single wrapped line as opposed to several separate lines. As a result, many terminals' selection/copying functionality would treat a wrapped line as several newline-delimited lines. Fix this by reenabling a "special trick" from Vim. When a line is wrapped, write the last character of that line followed by the first character of the next line to the terminal. This hints to the terminal that the next line is a continuation of the current line. Extends the raw_line event with a "wrap" parameter which controls when to do wrap hinting.
* cursor_shape: use attribute ids instead of syntax idsBjörn Linse2018-08-13
| | | | | As attribute ids is the convention in the UI protocol Also remove non-threadsafe calls in tui.c to syntax module.
* ui: use line-based rather than char-based updates in screen.cBjörn Linse2018-07-21
| | | | | | | | | | | | | Add ext_newgrid and ext_hlstate extensions. These use predefined highlights and line-segment based updates, for efficiency and simplicity.. The ext_hlstate extension in addition allows semantic identification of builtin and syntax highlights. Reimplement the old char-based updates in the remote UI layer, for compatibility. For the moment, this is still the default. The bulitin TUI uses the new line-based protocol. cmdline uses curwin cursor position when ext_cmdline is active.
* ui: add TODO for non-working terminal linewrapBjörn Linse2018-07-21
| | | | Note: this has not been working since the TUI reimplementation
* highlight: refactor to use stateful representationBjörn Linse2018-07-21
| | | | | This allows us to keep track of the source higlight groups, and not only the final combined highlights.
* highlight: extract low-level highlight logic from syntax, uiBjörn Linse2018-07-21
|
* ui: don't crash when 'writedelay' is set and redrawing inside an event handlerBjörn Linse2018-06-28
|
* nvim_list_uis: include channel idBjörn Linse2018-06-01
|
* TUI: implement "standout" attribute #8081Nimit Bhardwaj2018-03-27
| | | | closes #8054
* api: nvim_list_uis #8004geekodour2018-03-03
| | | | | ref #7438 closes #4842
* screen.c: make negative 'writedelay' show all redrawsBjörn Linse2018-02-24
| | | | | | | | | | | | | | | | | | | | Currently writedelay shows the sequence of characters that are sent to the UI/TUI module. Here nvim has already applied an optimization: when attempting to put a char in a screen cell, if the same char already was there with the same attributes, UI output is disabled. When debugging redrawing it it sometimes more useful to inspect the redraw stream one step earlier, what region of the screen nvim actually is recomputing from buffer contents (win_line) and from evaluating statusline expressions. Take the popupmenu as an example. When closing the popupmenu (in the TUI), currently 'writedelay' looks like vim only is redrawing the region which the pum covered. This is not what happens internally: vim redraws the entire screen, even if only outputs the changed region. This commit allows negative values of 'writedelay', which causes a delay for all redrawn characters, even if the character already was displayed by the UI before.
* ui_bridge: make sure TUI receives no more UI events after "stop" eventBjörn Linse2018-02-22
|
* ui: refactor ui optionsBjörn Linse2018-02-13
|
* ui/tui: highlighting refactorBjörn Linse2018-02-11
| | | | | | | | Make HlAttr contain highlighting state for both color modes (cterm and rgb). This allows us to implement termguicolors completely in the TUI. Simplify some logic duplicated between ui.c and screen.c. Also avoid some superfluous highlighting reset events.
* UI: restore 'writedelay' feature.Justin M. Keyes2018-02-07
| | | | | | | Removed by e0e41b30c61922e099a067ac5c137e745699a1aa, probably unintentionally. Useful for ye olde redraw debugging. TODO: Also delay redraw of statusline.
* tui: fix use-after-free after UI `stop` event #7922Justin M. Keyes2018-01-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ui_bridge:ui_bridge_stop() calls ui_detach_impl() last, so the check for ui_active() in ui:ui_refresh() doesn't help: tui_main() already freed the `ui` object. There is a race between ui_bridge_stop (thread T0) and tui_main (thread T1). UIBridgeData.stopped could be set while ui_bridge_stop() is in the middle of loop_poll_events(), which may invoke tui_scheduler() on T0. The pointers in tui_scheduler() may be invalid by then. Solution(?): Use the `UI.data` field as a "stopped" flag and check it in tui_scheduler(). ASAN use-after-free report observed in #7908: = ==20066==ERROR: AddressSanitizer: heap-use-after-free on address 0x611000000cd0 at pc 0x00000182abed bp 0x7ffe23b07070 sp 0x7ffe23b07068 = READ of size 8 at 0x611000000cd0 thread T0 = 0 0x182abec in tui_scheduler /home/travis/build/neovim/neovim/src/nvim/tui/tui.c:393:23 = 1 0x1876afd in ui_bridge_update_fg /home/travis/build/neovim/neovim/build/src/nvim/auto/ui_events_bridge.generated.h:205:3 = 2 0x186c130 in ui_resize /home/travis/build/neovim/neovim/src/nvim/ui.c:310:3 = 3 0x146b9c2 in screen_resize /home/travis/build/neovim/neovim/src/nvim/screen.c:7483:3 = 4 0x186a6f0 in ui_refresh /home/travis/build/neovim/neovim/src/nvim/ui.c:284:3 = 5 0x186bbe0 in ui_refresh_event /home/travis/build/neovim/neovim/src/nvim/ui.c:297:3 = 6 0xa2219a in multiqueue_process_events /home/travis/build/neovim/neovim/src/nvim/event/multiqueue.c:150:7 = 7 0xa1bd7f in loop_poll_events /home/travis/build/neovim/neovim/src/nvim/event/loop.c:63:3 = 8 0x1872709 in ui_bridge_stop /home/travis/build/neovim/neovim/src/nvim/ui_bridge.c:121:5 = 9 0x1864247 in ui_builtin_stop /home/travis/build/neovim/neovim/src/nvim/ui.c:143:3 = 10 0x1249ec8 in mch_exit /home/travis/build/neovim/neovim/src/nvim/os_unix.c:140:3 = 11 0xe56ba9 in getout /home/travis/build/neovim/neovim/src/nvim/main.c:671:3 = 12 0xfc4c8f in preserve_exit /home/travis/build/neovim/neovim/src/nvim/misc1.c:2653:3 = 13 0x1247c02 in deadly_signal /home/travis/build/neovim/neovim/src/nvim/os/signal.c:137:3 = 14 0x1247921 in on_signal /home/travis/build/neovim/neovim/src/nvim/os/signal.c:162:9 = 15 0xa35618 in signal_event /home/travis/build/neovim/neovim/src/nvim/event/signal.c:47:3 = 16 0xa2219a in multiqueue_process_events /home/travis/build/neovim/neovim/src/nvim/event/multiqueue.c:150:7 = 17 0xa1bd7f in loop_poll_events /home/travis/build/neovim/neovim/src/nvim/event/loop.c:63:3 = 18 0x1237bd6 in input_poll /home/travis/build/neovim/neovim/src/nvim/os/input.c:349:3 = 19 0x123334f in inbuf_poll /home/travis/build/neovim/neovim/src/nvim/os/input.c:372:24 = 20 0x123316d in os_inchar /home/travis/build/neovim/neovim/src/nvim/os/input.c:110:19 = 21 0x170d20e in state_enter /home/travis/build/neovim/neovim/src/nvim/state.c:55:13 = 22 0xbd7441 in command_line_enter /home/travis/build/neovim/neovim/src/nvim/ex_getln.c:384:3 = 23 0xbd0a60 in getcmdline /home/travis/build/neovim/neovim/src/nvim/ex_getln.c:1920:10 = 24 0xbdb365 in getexline /home/travis/build/neovim/neovim/src/nvim/ex_getln.c:2100:10 = 25 0xb00a6b in do_cmdline /home/travis/build/neovim/neovim/src/nvim/ex_docmd.c:528:47 = 26 0x10a7837 in nv_colon /home/travis/build/neovim/neovim/src/nvim/normal.c:4552:18 = 27 0x1091e15 in normal_execute /home/travis/build/neovim/neovim/src/nvim/normal.c:1136:3 = 28 0x170d439 in state_enter /home/travis/build/neovim/neovim/src/nvim/state.c:67:26 = 29 0x104ee14 in normal_enter /home/travis/build/neovim/neovim/src/nvim/normal.c:466:3 = 30 0xe4295c in main /home/travis/build/neovim/neovim/src/nvim/main.c:572:3 = 31 0x2b2ba340bf44 in __libc_start_main /build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:287 = 32 0x44d24b in _start (/home/travis/build/neovim/neovim/build/bin/nvim+0x44d24b) = = 0x611000000cd0 is located 16 bytes inside of 240-byte region [0x611000000cc0,0x611000000db0) = freed by thread T1 here: = 0 0x4ee0e2 in __interceptor_free /local/mnt/workspace/tmp/ubuntu_rel/llvm/utils/release/final/llvm.src/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:47:3 = 1 0xf4f6d4 in xfree /home/travis/build/neovim/neovim/src/nvim/memory.c:133:3 = 2 0x182a963 in tui_main /home/travis/build/neovim/neovim/src/nvim/tui/tui.c:383:3 = 3 0x18792b0 in ui_thread_run /home/travis/build/neovim/neovim/src/nvim/ui_bridge.c:106:3 = 4 0x2b2ba2697183 in start_thread /build/eglibc-ripdx6/eglibc-2.19/nptl/pthread_create.c:312 = = previously allocated by thread T0 here: = 0 0x4ee61a in calloc /local/mnt/workspace/tmp/ubuntu_rel/llvm/utils/release/final/llvm.src/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:76:3 = 1 0xf4f787 in xcalloc /home/travis/build/neovim/neovim/src/nvim/memory.c:147:15 = 2 0x182000a in tui_start /home/travis/build/neovim/neovim/src/nvim/tui/tui.c:127:12 = 3 0x1863f7c in ui_builtin_start /home/travis/build/neovim/neovim/src/nvim/ui.c:125:3 = 4 0xe41bb9 in main /home/travis/build/neovim/neovim/src/nvim/main.c:457:5 = 5 0x2b2ba340bf44 in __libc_start_main /build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:287 = = Thread T1 created by T0 here: = 0 0x4d774d in __interceptor_pthread_create /local/mnt/workspace/tmp/ubuntu_rel/llvm/utils/release/final/llvm.src/projects/compiler-rt/lib/asan/asan_interceptors.cc:317:3 = 1 0x1aae6b0 in uv_thread_create /home/travis/nvim-deps/build/src/libuv/src/unix/thread.c:75 = 2 0x18217fa in tui_start /home/travis/build/neovim/neovim/src/nvim/tui/tui.c:159:10 = 3 0x1863f7c in ui_builtin_start /home/travis/build/neovim/neovim/src/nvim/ui.c:125:3 = 4 0xe41bb9 in main /home/travis/build/neovim/neovim/src/nvim/main.c:457:5 = 5 0x2b2ba340bf44 in __libc_start_main /build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:287 --- Alternative attempt: commit 6ad9c02491606a0c31e907f38c9931f324327aa5 Author: Justin M. Keyes <justinkz@gmail.com> Date: Sat Jan 27 15:12:58 2018 +0100 tui: fix use-after-free: swap in empty scheduler This should make life easier for UIs like VimR which implement their own in-process bridged UI: they don't need to worry that their `scheduler` might receive an invalid pointer. To avoid that, ui_bridge_stopped() swaps in an empty scheduler. Note that this requires the call to loop_poll_events() to be moved into the critical section. diff --git a/src/nvim/ui_bridge.c b/src/nvim/ui_bridge.c index 779585416f80..491052d19d3b 100644 --- a/src/nvim/ui_bridge.c +++ b/src/nvim/ui_bridge.c @@ -93,10 +93,18 @@ UI *ui_bridge_attach(UI *ui, ui_main_fn ui_main, event_scheduler scheduler) return &rv->bridge; } +static void ui_bridge_null_scheduler(Event event, void *d) +{ + WLOG("ignoring event (bridge stopped)"); +} + void ui_bridge_stopped(UIBridgeData *bridge) { uv_mutex_lock(&bridge->mutex); bridge->stopped = true; + // Replace with an empty scheduler, so that the UI internal scheduler does + // not get invoked with an invalid pointer. #7922 + bridge->scheduler = ui_bridge_null_scheduler; uv_mutex_unlock(&bridge->mutex); } @@ -111,14 +119,11 @@ static void ui_bridge_stop(UI *b) UIBridgeData *bridge = (UIBridgeData *)b; bool stopped = bridge->stopped = false; UI_BRIDGE_CALL(b, stop, 1, b); - for (;;) { + while (!stopped) { uv_mutex_lock(&bridge->mutex); stopped = bridge->stopped; - uv_mutex_unlock(&bridge->mutex); - if (stopped) { - break; - } loop_poll_events(&main_loop, 10); // Process one event (at most). + uv_mutex_unlock(&bridge->mutex); } uv_thread_join(&bridge->ui_thread); uv_mutex_destroy(&bridge->mutex);
* ui: forward relevant option updates to UIs (#7520)Björn Linse2017-12-12
| | | also make termguicolors mutable after startup
* ui: remove ext_cmdline noise (#7486)Björn Linse2017-11-07
| | | | | Only send cmdline contents once per ui_flush. Don't send extra redraws due to 'arshape', it makes no difference to external ui.
* Increased test coverage for RGB and ctermMatthieu Coudron2017-09-30
|
* Adds nvim_get_hl_by_name/by_idMatthieu Coudron2017-09-30
| | | | | | | | | ...in order to retrieve highlights. Added test/functional/api/highlight_spec.lua HL_NORMAL is not really a good name, since it's more like an empty attribute than the normal's one. If one pays attention, syn_cterm_attr2entry is never called with attr=0 because it's always special cased before. I suggest in subsequent PRs we remove the ATTR_OFF and just insert an EMPTY ATTR/RESET_ATTR/UNINITIALIZED for id 0.
* log: introduce `context`Justin M. Keyes2017-09-05
|
* ui: disable 'lazyredraw' during ui_refresh.Justin M. Keyes2017-08-14
| | | | | | | | | | | | Could also try `do_redraw = true` instead of save/restore `p_lz`, but the nice thing about save/restore of `p_lz` is that it is "atomic". The semantics of `do_redraw` are not clear to me. Closes #4884 References #6202 References https://github.com/neovim/neovim/pull/6202#issuecomment-284379503 References #3929 #5692 #6157 References #5866
* log: all UI events, not just UI-bridgeJustin M. Keyes2017-07-22
| | | | Rename ui_bridge.c:UI_CALL to UI_BRIDGE_CALL.
* ui: cleanup UI_CALL wrappersBjörn Linse2017-05-10
| | | | remove pointless control chars in the text stream
* api: generate ui eventsBjörn Linse2017-05-10
|
* event: Remove "priority" concept.Justin M. Keyes2017-04-28
| | | | It was replaced by the "child queue" concept (MultiQueue).
* api/ui: externalize tablineJustin M. Keyes2017-04-26
| | | | | | - Work with a bool[] array parallel to the UIWidget enum. - Rename some functions. - Documentation.
* api/ui: externalize tablineDongdong Zhou2017-04-26
|
* Merge #6539 'More cursor shape modes'Justin M. Keyes2017-04-21
|\
| * ui: use an array for mode stylesBjörn Linse2017-04-21
| |
| * ui: support more cursor shape modesBjörn Linse2017-04-21
| | | | | | | | throttle unneccessary cursor shape events
* | *: Add comment to all C filesZyX2017-04-19
|/
* 'guicursor': enabled=false if 'guicursor' is emptyJustin M. Keyes2017-04-04
| | | | | Closes #6429 Closes #6430