Commit Graph

179 Commits

Author SHA1 Message Date
Daniel Hahler
1e2af5e39d
tests: make TERM=interix test pending (#10576)
Ref: https://github.com/neovim/neovim/issues/10179
Ref: https://github.com/neovim/neovim/pull/9494
2019-07-22 18:49:37 +02:00
Daniel Hahler
3a1d3e9ef1
tests: shell-test: use count for REP (#10514)
Also fix V576: use width specification

> Incorrect format. Consider checking the third actual argument of the
> 'sscanf' function. It's dangerous to use string specifier without width
> specification. Buffer overflow is possible.
2019-07-16 21:35:53 +02:00
Daniel Hahler
c07f266c5b
tests: ex_terminal_spec: add test for previous leak (#10450)
Closes https://github.com/neovim/neovim/pull/4766.
2019-07-08 18:42:52 +02:00
Daniel Hahler
e48257e63e
tests: fix/improve "TUI background color" tests (#10229)
- Ensure the opposite of the expected bg is active.
- Improves performance: 1.2s instead of 4.5s.
2019-07-03 03:37:19 +02:00
Daniel Hahler
1c45ba462b
tests: fix flaky "terminal (with fake shell) with not arguments …" (#10401)
`retry()` would only try it three times (waiting for 20ms in between),
despite the large timeout.

Fixes https://github.com/neovim/neovim/issues/10265.
2019-07-02 19:31:36 +02:00
Alan Wu
9fd4a0b526 getchar: Handle incomplete <Paste> in typeahead buffer #10311
<Paste> is a 3-byte sequence and the beginning one or two bytes can appear at
the very end of the typeahead buffer. When this happens, we were exiting from
`vgetorpeek()` instead of reading more characters to see the complete sequence.

I think this should fix #7994 -- at least partially. Before this change, when I
paste exactly 64 characters into a freshly booted instance, I get what I pasted
plus the literal text "<Paste>" at the end. Nvim also stays in nopaste mode.
The attached test case fails in this manner without the code change.

Fix #7994
2019-06-24 00:28:04 +02:00
Harm te Hennepe
424ddd01f5 tui: support rgba background detection (#10205)
Fixes https://github.com/neovim/neovim/issues/10159.
2019-06-13 14:14:41 +02:00
erw7
ce90a19abd TUI: set os/input.c:global_fd to input->in_fd #10174
Problem: When we changed startup to wait for the TUI (like a remote UI),
         we forgot to set os/input.c:global_fd.  That used to be done by
         input_start().

Solution: Initialize os/input.c:global_fd before initializing libtermkey
          (termkey_new_abstract) so that tui_get_stty_erase() and
          friends can inspect the correct fd.

fixes #10134
close #10174
2019-06-10 16:43:52 +02:00
Justin M. Keyes
fd04877eb0 test: remove use of require('test.helpers')
The test.functional.helpers and test.unit.helpers modules now include
all of the public functions from test.helpers, so there is no need to
separately require('test.helpers').
2019-05-18 15:48:13 +02:00
Björn Linse
94f78ccf89
Merge pull request #9883 from bfredl/termredraw
make terminal state redraw like any other state
2019-05-14 13:39:00 +02:00
Björn Linse
5020daa6e5 ui/terminal: make terminal state redraw like any other state
Previously, ordinary redraws were missing from terminal mode. Instead,
there was an async callback that invoked update_screen() on terminal
data regardless of mode (as if :redraw! was invoked by a timer).

This created some issues:

- async changes to an unrelated ordinary buffer were not always redrawn in
  terminal mode
- screen cursor position was not properly updated in terminal mode (partial
  fix, will be properly fixed in a follow up PR)
- ad-hoc logic was needed for interaction with special states such as
  inccommand or horizontal wildmenu.

Instead redraw terminal mode just like any other state. This disables forced
redraws in cmdline mode, which were inconisent which async changes to
normal buffers (which are not redrawn in cmdline mode).
2019-05-14 12:54:39 +02:00
Justin M. Keyes
b9ad12e6c2 UI/nvim_ui_attach(): add override option
Before now, Nvim always degrades UI capabilities to the lowest-common
denominator. For example, if any connected UI has `ext_messages=false`
then `ext_messages=true` requested by any other connected UI is ignored.

Now `nvim_ui_attach()` supports `override=true`, which flips the
behavior: if any UI requests an `ext_*` UI capability then the
capability is enabled (and the legacy behavior is disabled).

Legacy UIs will be broken while a `override=true` UI is connected, but
it's useful for debugging: you can type into the TUI and observe the UI
events from another connected (UI) client. And the legacy UI will
"recover" after the `override=true` UI disconnects.

Example using pynvim:

    >>> n.ui_attach(2048, 2048, rgb=True, override=True, ext_multigrid=True, ext_messages=True, ext_popupmenu=True)
    >>> while True: n.next_message();
2019-05-09 22:27:41 +02:00
Justin M. Keyes
fd0fd752c8 terminal: swap priority of terminal, editor highlights
closes #9964
2019-05-02 09:56:22 +02:00
glacambre
b3fd83a0ea Reset stop_insert_mode in terminal_enter rather than terminal_check
Problem: Using `:stopinsert` while in normal mode in a terminal buffer
prevents neovim from entering insert mode.

Solution: Move `stop_insert_mode = false` from terminal_check to
terminal_enter to be consistent with edit.c, as suggested by bfredl in
 #9889.

Closes https://github.com/neovim/neovim/issues/9889.
2019-04-20 10:41:46 +02:00
glacambre
d928b036dc :stopinsert should leave terminal-mode #9856
Problem:  Calling :stopinsert from RPC while in terminal-mode does not
          go back to normal-mode.
Solution: Implement a check() handler for state_enter(), adapted from
          insert_check().

Fix #7807
2019-04-08 01:13:43 +02:00
Justin M. Keyes
b90256e6cc test: simplify TUI bg-detection test
Previous approach skipped the test if the expected value matched the
default value ("dark"). New approach always checks, but uses retry() to
ignore potentially wrong 'background' before the terminal response is
handled.
2019-03-15 05:26:41 +01:00
Justin M. Keyes
43184566aa TUI/background detection: hook into VimEnter event
If terminal response is received during startup, set 'background' from
a nested "one-shot" (once) VimEnter autocmd.

The previous not-so-clever "self-rescheduling" approach could cause
a long delay at startup (event-loop does not make forward progress).

fixes #9675
ref #9509
2019-03-11 08:43:27 +01:00
Justin M. Keyes
3cb89cafe3
vim-patch:8.1.0994: fix relative cursor position #9676
Problem:    Relative cursor position is not calculated correctly.
Solution:   Always set topline, also when window is one line only.
            (Robert Webb) Add more info to getwininfo() for testing.
8fcb60f961
2019-03-09 23:12:33 +01:00
Justin M. Keyes
d3dc946155 TUI: rework background-color detection
- Like Vim, use set_option_value() followed by reset_option_was_set().
- Do not use set_string_default(), so the default is predictable.
  This affects `:set bg&`.
- Wait until end-of-startup (VimEnter) to handle the response. The
  response is racey anyways, so timing is irrelevant. This allows
  OptionSet to be triggered, unlike during startup.
2019-02-22 21:15:16 +01:00
Justin M. Keyes
6bd6927656 Merge #5027 'TUI: detect background color' 2019-02-17 14:47:40 +01:00
Justin M. Keyes
5225c1ec30
terminal: Fix potential invalid local 'scrollback' (#9605)
TermOpen autocmd may set local 'scrollback' to -1, this needs to be
adjusted as in on_scrollback_option_changed().

fixes #9588 (OOM, out of memory)
2019-02-17 08:07:30 +01:00
Björn Linse
baf93d9606 UI: always use contrete colors for default_colors_set
But add an escape hatch needed for external TUI, so it still can use
terminal emulator defaults.
2019-02-05 19:41:38 +01:00
Marco Hinz
91688b4883 options: set 'scrollback' to -1 by default #9563
Makes the 'scrollback' option more consistent (same default for all buffers) and future-proof.

- Default to -1 for all buffers, but treat it as an implementation detail.
- Document range of 1 - 100_000.
- New terminal buffer by default sets scrollback=10_000 if the global default is -1.
- Existing terminal buffer: On entering terminal-mode or on refresh, if the user explicitly did `:set[local] scbk=-1`, the local value goes to 100_000 (max). (This is undocumented on purpose. Users should work with explicit values in the range of 1-100_000.)
2019-02-04 02:53:23 +01:00
Justin M. Keyes
d4750100b0 test: improve reliability of ":terminal topline" test
- Avoid using platform-specific shell, it failed in MINGW_64 env.
- tty-test.c echos our input, which is exactly what we need for this test.
- Test fails correctly if 894f6bee54 is reverted.
2019-01-31 22:26:32 +01:00
Andrew Pyatkov
894f6bee54 :terminal : set topline based on window height #8325
closes #8324
closes #8556
2019-01-29 03:00:48 +01:00
Björn Linse
30bd1c1e85 terminal: handle size when switching buffers in window 2019-01-27 12:07:06 +01:00
Björn Linse
2ab70cb55c window/ui: reorganize size variables, fix terminal window size with multigrid.
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
2019-01-27 12:07:06 +01:00
Justin M. Keyes
7e9b99d55b Merge #5027 'TUI: detect background color' 2019-01-17 13:05:51 +01:00
Utkarsh Maheshwari
ebe16cd9bd multigrid: add multigrid screen tests 2018-12-31 12:44:22 +01:00
Björn Linse
1f8afe15a4 multigrid: add multigrid support to test infrastructure
make Screen explicitly tied to its session
2018-12-31 12:44:22 +01:00
Justin M. Keyes
e85b911f02 test: win/TUI builtin terminfos 2018-12-28 01:46:25 +01:00
Justin M. Keyes
32a30d90b4
highlight: Fix missing .rgb_sp_color in initializers (#9287)
terminal_get_line_attributes() had this bug for a long time, though it
likely had no effect visible to users.

ref #9028
ref 60f845ca55
2018-11-30 21:13:01 +01:00
Justin M. Keyes
deb18a050e
defaults: background=dark #2894 (#9205)
By historical accident, Nvim defaults to background=light. So on a dark
background, `:colorscheme default` looks completely wrong.

The "smart" logic that Vim uses is confusing for anyone who uses Vim on
multiple platforms, so rather than mimic that, pick the (hopefully) most
common default.

- Since Neovim is dark-powered, we assume most users have dark backgrounds.
- Most of the GUIs tend to have a dark background by default.

ref #6289
2018-11-20 10:52:49 +01:00
Justin M. Keyes
f8639dc99c
test: adjust time-sensitive tests (#9220)
- window_split_tab_spec.lua: Put cursor at bottom of :terminal buffer so
  that it follows output.
- inccommand_spec.lua: Increase timeout to allow 2nd retry.
- Timer tests are less reliable on Travis CI macOS 10.12/10.13.
  ref #6829
  ref e39dade80b
  ref de13113dc1
  ref https://github.com/neovim/neovim/pull/9095#issuecomment-429603452
  > We don't guarantee that a X ms timer is triggered during Y ms sleep
  > for any X<Y, though I would expect the load to be really bad for this
  > to happen with X=10ms, Y=40ms.
2018-11-10 11:12:04 +01:00
Justin M. Keyes
6fe740c7ab test/win: window_split_tab_spec: fix retry() 2018-11-05 07:59:14 +01:00
Justin M. Keyes
10ef903648 test/win: window_split_tab_spec: increase retry() time
The default timeout of 10s only allows 1 retry.
2018-11-05 03:25:36 +01:00
Justin M. Keyes
697176fc3e test/win: retry unreliable SIGWINCH test 2018-11-04 14:24:05 +01:00
Justin M. Keyes
f5671c8614 win: test: SIGWINCH is noisy #7506 2018-11-01 17:17:07 +01:00
Jan Edmund Lazo
db6521a560 test: fix/speedup scrollback_spec
- fix: Use "set PROMPT=$" trick to satisfy screen:expect{any='%$'}
- speedup: Use cmd.exe instead of powershell.
2018-10-22 01:30:28 +02:00
Björn Linse
c8810a51a3 tests: improve robustness of immediate successes in screen tests 2018-10-15 20:13:11 +02:00
Björn Linse
075dc42fb2 test: replace wait() with pre-assertion in assert_term_colors 2018-10-06 11:36:09 +02:00
Björn Linse
43823acae2 ui: rename ext_newgrid to ext_linegrid 2018-10-01 21:24:15 +02:00
Björn Linse
3d88287e30 tests: introduce screen:expect{...} form 2018-08-27 15:15:49 +02:00
Björn Linse
1adb01c120 ui: use line-based rather than char-based updates in screen.c
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.
2018-07-21 13:21:58 +02:00
Marco Hinz
01570f1ff3
terminal: handle &confirm and :confirm on unloading (#8726)
Show a proper confirmation dialog when trying to unload a terminal buffer while
the confirm option is set or when :confirm is used.

Fixes https://github.com/neovim/neovim/issues/4651
2018-07-12 14:57:20 +02:00
林千里
451c48a092 terminal: flush vterm output buffer on pty output #8486
Fixes #4151

libvterm uses an "output buffer" for terminal reporting
(e.g. \e[6n to report cursor position)
Flush it in on_channel_output() not just terminal_send_key()

See also this line from pangoterm:
https://bazaar.launchpad.net/~leonerd/pangoterm/trunk/view/607/pangoterm.c#L2159
2018-06-08 02:18:27 +02:00
Björn Linse
5be3865ce7 nvim_list_uis: include channel id 2018-06-01 10:20:13 +02:00
Justin M. Keyes
48967695c4
test: tui_spec.lua: relax test (#8289)
Sometimes an extra FocusGained/FocusLost event might trigger. This
doesn't matter, we just want to test that the events were received in
cmdline-mode.
2018-04-16 23:35:58 +02:00
Andrew Pyatkov
84359a467f terminal: resize to the max dimensions (#8249)
closes #8096
2018-04-16 22:25:23 +02:00
Justin M. Keyes
224ebc0078 insert-mode: interpret unmapped META as ESC
closes #2454
closes #8213
ref #7972
2018-04-04 03:23:15 +02:00