1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-24 07:46:59 +03:00
Commit Graph

224 Commits

Author SHA1 Message Date
Wez Furlong
39f4985741 maybe fixup windows build for num/num_traits changes 2020-06-13 12:05:47 -07:00
Wez Furlong
e70a58e7f3 cargo update 2020-06-13 10:21:49 -07:00
Wez Furlong
24fdf27d65 misc: upgrade unicode-segmentation 2020-06-13 10:10:34 -07:00
Wez Furlong
3002b40fd2 termwiz: make serde an optional dep
closes: https://github.com/wez/wezterm/pull/186
2020-06-13 09:55:18 -07:00
Wez Furlong
070afa65d6 termwiz: trim num dep to num_traits
refs: https://github.com/wez/wezterm/pull/186
2020-06-13 09:55:18 -07:00
Wez Furlong
47dc81c8d9 termwiz: separate CursorVisibility from CursorShape
They are separate concepts and this simplifies some processing.

closes: https://github.com/wez/wezterm/pull/212
2020-06-12 19:44:54 -07:00
Mark Thomas
fc352d00f9 termwiz: add CursorVisibility
Some applications want to control the cursor visibility, without affecting
cursor shape.  Provide the `CursorVisibility` change type for this purpose.

Use this when dropping `UnixTerminal` to ensure the cursor is visible
without affecting the user's cursor shape.
2020-06-12 18:52:49 -07:00
Wez Furlong
87eedfd42d wezterm: add dec private mode 1070 for sixel color map control
refs: https://github.com/wez/wezterm/issues/217
2020-06-11 19:03:12 -07:00
Wez Furlong
a78954375d wezterm: sixel rendering basically working
refs: https://github.com/wez/wezterm/issues/217
2020-06-11 08:13:37 -07:00
Wez Furlong
108def1f90 termwiz: add types for sixel parsing
refs: https://github.com/wez/wezterm/issues/217
2020-06-11 08:13:29 -07:00
Wez Furlong
b370c8020f termwiz: fix swapped width/height in size reporting sequences
Whoops! :)

refs: https://github.com/wez/wezterm/issues/211#issuecomment-642056005
2020-06-10 08:22:46 -07:00
Wez Furlong
d7c04b154d termwiz: shift Boxing of DCS around
Previously, we'd require boxing the entire DCS representation
in the escape sequence parser.  This was due to some clippy
advice that made sense at the time, but now that I'm looking
at more things using DCS it seems wasteful to Box each byte of
the dcs sequence.  This commit shifts the box to the heavier
weight portion: the DCS hook/entry representation.
2020-06-09 22:01:26 -07:00
Wez Furlong
18a234a162 termwiz: fix dec private mode parsing
When processing `\033[?1002;1003;1005;1006h`, when we encountered
`1005` we would skip 1006.  This was because we hit the unspecified
enum case for 1005 (we have no enum variant for that mode) and that
code path didn't properly advance only by a single position.

This commit fixes that.

refs: https://github.com/wez/wezterm/issues/211#issuecomment-641302077
2020-06-09 19:00:12 -07:00
Wez Furlong
65f94bd57b vtparse: fix DCS parsing
This corrects an issue where the mode byte of the DCS sequence was
discarded from the DcsHook, making it impossible to know what sequence
is being activated.

So far this hasn't come up as these sequences are relatively rare,
but in looking at sixel parsing I noticed the error.
2020-06-09 09:03:08 -07:00
Wez Furlong
ff9151bb9b termwiz/term: implement window/pixel size responses
refs: https://github.com/wez/wezterm/issues/211
2020-06-08 18:44:05 -07:00
Wez Furlong
8204a1a6b6 termwiz: recognize wezterm as supporting iterm2 images 2020-06-05 23:08:17 -07:00
Wez Furlong
82261ff16d wezterm: enable scrollback in the error window
This commit doesn't do anything specific to scrollback though!
It moves the implementation of the TermWizTermTab away from
a directly manipulated Surface and over to using the term::Terminal,
making the renderer look more like the one used by the local tab
and domain implementation.

As a side effect of doing this, we get scrollback management
for free.

refs: https://github.com/wez/wezterm/issues/201
2020-06-03 08:45:03 -07:00
Wez Furlong
ccf9fc141b wezterm: fixup DECKPAM/DECANM/DECCKM interaction
We were treating DECCKM as the sole thing to enable application
cursor reporting, but looking closely at the docs, that mode only
takes effect when both DECANM (Vt52 emulation mode) AND DECKPAM
(application keypad mode) are both active.

neovim enables DECCKM and DECKPAM but not DECANM.

refs: https://github.com/wez/wezterm/issues/203
2020-05-31 15:45:25 -07:00
Wez Furlong
92fdf043b8 termwiz: fix panic in RgbColor::from_rgb_str w/ empty string
Need to check the len before looking at the first character!

closes https://github.com/wez/wezterm/issues/198
2020-05-29 07:15:45 -07:00
Wez Furlong
58686f925f termwiz: fix a widget layout and optimization issue
This commit adds a simple example of nested widgets, which uncovered
an issue with respecting the layout positioning, and adds a secondary
screen buffer to make the widget render cycle more optimal:

```
cargo run --example widgets_nested --features widgets --release
```

refs: https://github.com/wez/wezterm/issues/171
2020-05-18 07:40:09 -07:00
Wez Furlong
77fafd512b termwiz: add example program that strips escape sequences 2020-05-17 21:30:12 -07:00
Wez Furlong
1ad6f00696 termwiz: cut 0.9.0 release 2020-05-17 12:05:46 -07:00
Wez Furlong
3349ef0dca termwiz: fix categorization of F keys
refs: https://github.com/wez/wezterm/issues/178
2020-05-16 17:25:23 -07:00
Wez Furlong
f2b12c64ba termwiz: use long form ST when rendering OSC
Neovim doesn't like using BEL as an alternative for ST when
parsing the OSC dynamic color responses.

Use the longer form sequence to make it happier!
2020-05-16 11:01:26 -07:00
Wez Furlong
a3921a73fa Explicitly ignore focus tracking (dec private mode 1004)
We still don't support it, but we no longer log that we don't
know what the mode is.
2020-05-16 09:31:02 -07:00
Wez Furlong
a1c0cabf18 term: process OSC 110+: ResetDynamicColors
neovim uses these
2020-05-16 09:25:17 -07:00
Wez Furlong
132529cfd5 support Terminal identification sequence
This reports the TERM_PROGRAM and TERM_PROGRAM_VERSION
separated by a space.

See discussion in https://github.com/mintty/mintty/issues/881
with a more concise description of the functionality here in
this VTE issue: https://gitlab.gnome.org/GNOME/vte/-/issues/235

```bash
$ printf '\033[>q'; cat
^[P>|WezTerm 20200503-171512-b13ef15f-4-g0395639a^[\
```
2020-05-03 22:10:38 -07:00
Wez Furlong
fa32457656 cargo fmt 2020-05-02 17:39:45 -07:00
Wez Furlong
b3a57f0d1c termwiz: line editor: fix a couple of bugs
* ctrl-R to find a line and then hit enter would cause the search
  text rather than the match text to be returned and run!
* When exiting the editor, clear to end of screen to make sure
  that we clean up any UI from the incremental search status
2020-04-10 21:10:42 -07:00
Wez Furlong
d4df39f793 termwiz: line editor: add ChangeSequence helper
This helps us keep track of the extent and cursor position that
we render for the line editor, making it easier to make the editor
rendering more fancy.
2020-04-10 20:42:02 -07:00
Wez Furlong
8963fb76aa termwiz: line editor: add incremental history search 2020-04-10 11:02:59 -07:00
Wez Furlong
79007d9c33 termwiz: line editor: allow custom editor actions
This restructures the LineEditor to allow the hosting application to
override key presses and apply custom edits to the editor buffer.

Methods for performing predefined actions and for accessing the line
buffer and cursor position have been provided/exposed to support this.

One consequence of this change is that the editor instance needs to be
passed through to the host trait impl and that means that the LineEditor
can no longer be generic over `Terminal`.  Instead we now take `&mut dyn
Terminal` which was how the majority of non-example code was using it in
any case.  This simplifies a bit of boilerplate in wezterm but adds an
extra line to the most basic examples.
2020-04-09 07:37:23 -07:00
Wez Furlong
eb1f583e2b termwiz: line editor: allow embedded app to override key map 2020-04-09 06:40:29 -07:00
Wez Furlong
e033e3576f termwiz: History::get() -> Option<Cow<str>>
The BasicHistory impl returned a borrowed reference but the sqlite based
impl I'm adding to wzsh needs to own it.
2020-04-08 22:32:14 -07:00
Wez Furlong
af339f7cfe termwiz: line editor: allow application cursor keys
On Windows, if you run `wsl.exe` from the terminal and start zsh
(maybe bash also?) and it enables application cursor key mode,
exiting zsh doesn't clear application cursor key mode and when we
return to the shell and are using virtual terminal input rather
than the native windows console input, we'll continue to receive
application cursor key sequences instead of regular cursor key
input sequences.

This commit recognizes both flavors as arrow movement
in the line editor to make this feel less broken.
2020-04-08 19:11:15 -07:00
Wez Furlong
5b57f5f9ff termwiz: line editor: exit completion state for a single completion result 2020-04-08 10:07:15 -07:00
Wez Furlong
11c7e29b59 termwiz: windows: toggle autonewline when toggling cooked/raw
Without this, `wzsh` will keep the terminal in raw mode between
line editor invocations, resulting in staggered/stairway output
for any spawned commands.
2020-04-08 08:57:26 -07:00
Wez Furlong
db845db55b termwiz: line editor: allow for multi-line prompts 2020-04-07 22:06:05 -07:00
Wez Furlong
5b700e4d5d wezterm: recognize MS terminal mode 25 for cursor visibility 2020-04-06 13:19:44 -07:00
Wez Furlong
d98fee9e0b termwiz: windows: allow ESC to be recognized again
After processing a batch of input records, we need to effectively
flush any pending ambiguous sequences in order to register a lone
ESC key press.
2020-04-06 10:13:49 -07:00
Wez Furlong
b279bb68e0 termwiz: windows: auto-detect virtual terminal support
With the revised native windows console renderer using the various
console APIs more deeply, I've seen a couple of cases where those
API calls fail inside eg: wezterm running via the new pty machinery.

Using the virtual terminal APIs and the terminfo renderer is the
right thing to do in that case.

This commit probes for virtual terminal support and uses the builtin
xterm terminfo, unless the environment has
`TERMWIZ_BYPASS_VIRTUAL_TERMINAL=1` set.  This allows forcing the
use of the windows console layer.
2020-04-06 09:51:15 -07:00
Wez Furlong
92fa32695c termwiz: windows: fixup viewport handling
Some windows APIs have inclusive dimensions and some exclusive;
we were off by one for the height of the display which led to some
weirdness with eg: `sp` and the line editor.

When it comes to scrolling: if the scroll request is for the entire
viewport then we simply adjust the viewport; this is desirable because
it allows data to scroll back into the history in the native console.
2020-04-06 09:33:52 -07:00
Wez Furlong
290bc5567e termwiz: windows: tidy up flushing a bit 2020-04-06 07:52:56 -07:00
Wez Furlong
03ab5ea659 termwiz: windows: fix bounds check for cursor positioning 2020-04-05 21:00:54 -07:00
Wez Furlong
58c07b6da0 termwiz: line editor: fixup cursor positioning for multiline
This fixes the math around cursor positioning for the edge case where
the width of text and the cursor position are close to the width of
the terminal.
2020-04-05 20:46:41 -07:00
Wez Furlong
96880a08b4 termwiz: improve performance of windows console renderer
This reduces flickering updates in the native windows console;
it works by taking a copy of the screen buffer, applying the
Change's to that buffer and then copying back to the console.
2020-04-05 19:15:48 -07:00
Wez Furlong
fe89082764 termwiz: remove Position::NoChange, fixup multiline line editing and moar!
This is unfortunately a bit of a muddy commit and I'm too lazy to split
it up.

* Removed `Position::NoChange`; use `Position::Relative(0)` instead
* Added missing cursor positioning cases in the terminfo renderer
* Taught line editor about the cursor position when the line spans
  multiple physical lines
* Taught the Windows input layer to process escape sequences for eg:
  the arrow keys when running with virtual terminal enabled.
* Removed the hack that under-reported the terminal width; the hack
  was present to make some aspects of rendering with the native windows
  console logic easier, but it was getting in the way of the line
  editor.  This may well break something, but it fixed up the line
  editor :-/

cc: @markbt
2020-04-05 11:14:08 -07:00
Wez Furlong
6d5a7ad143 termwiz: ensure virtual terminal processing is enabled on windows
I'm not sure if this is strictly needed as it seems to be the default
for the ways that I interact with windows (via wezterm and via ssh).
2020-04-04 18:02:47 -07:00
Wez Furlong
aaf3a7fcaf termwiz: allow using terminfo on Windows
This commit changes the behavior on Windows:

* If $TERM is set and the `terminfo` crate is able to
  successfully initialize and locate a terminfo database (this also
  requires that $TERMINFO be set in the environment), then we'll
  use the `TerminfoRenderer` instead of the `WindowsConsoleRenderer`
* If $TERM is set to `xterm-256color` and no terminfo database was
  found, use our modern compiled-in copy (look in the `termwiz/data/`
  directory for the source and compiled version of this) and use
  the `TerminfoRenderer`.
* Otherwise use the `WindowsConsoleRenderer`.

In practice, this allows termwiz apps to opt in to features such as
true color support on Windows 10 build 1903 an later by setting their
`TERM=xterm-256color`.   This happens to be the default behavior when
`ssh`ing in to a windows host via `wezterm`.

You can see the truecolor mode get applied by running this example:

```
cargo run --example widgets_basic --features widgets
```

with TERM set as above the background region that is painted by the app
will be a blueish/purplish color, but with it unset or set to something
invalid, it will fall back to black.

I'd like to eventually make termwiz assume the equivalent configuration
to `TERM=xterm-256color` by default on Windows 10 build 1903 and later,
but it's worth getting some feedback on how this works for clients such
as `streampager`.

cc: @quark-zju and @markbt
2020-04-04 17:52:53 -07:00
Wez Furlong
fb6d0bbc7c termwiz: windows: fix default text foreground color
We were defaulting to bright white for `CellAttributes::default()`
rather than standard grey.

heads up @quark-zju and @markbt
2020-04-04 13:52:20 -07:00