1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-18 19:01:36 +03:00
Commit Graph

186 Commits

Author SHA1 Message Date
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
Thom Chiovoloni
cfc22c1fcb Update comment based on review feedback 2020-03-13 21:05:43 -07:00
Thom Chiovoloni
0874b03d65 Add support for more more sequences to the input parser's keymap 2020-03-13 21:05:43 -07:00
Wez Furlong
65749f06a3 mux: fix poll interval. show update indicator
Add an update indicator to the top right of client tabs; this is
overlaid on top of the surface when the last update from the server was
more than ~3s ago and if we expected it sooner than that.

While making this work, I noticed that the exponential poll backoff
had gotten broken in an earlier refactor; instead of a series of polls
backing off slowly, we were aggressively running the backoff up to the
max 30 second interval over the span of a few ms.   This commit fixes
up the backoff computation to only happen when we are ready to send
a poll.

refs: https://github.com/wez/wezterm/issues/127
2020-02-23 09:08:04 -08:00
Wez Furlong
3dea5a59fc termwiz: bump version for publish
heads up to @quark-zju
2020-02-22 07:40:06 -08:00
Jun Wu
4651b4c703 termwiz: bump regex to 1.0+
This makes termwiz (likely) use the same regex when being compiled
together with other dependencies in the eco-system.
2020-02-11 07:45:50 -08:00
Jun Wu
ca2e9c013a termwiz: do not depend on derive_builder
derive_builder has some extra dependencies that take a while to compile.
The builder feature can be expressed via a 30-line macro. So let's do
that to make termwiz compile faster.
2020-02-11 07:45:50 -08:00
Jun Wu
f51650c891 termwiz: remove dep on palette
The palette crate has a codegen step that translates svg_colors.txt to named.rs.
That makes it hard to build using buck.

Remove the palette dependency so termwiz is easier to build using buck.

I made sure the following code:

    fn main() {
        use termwiz::color::RgbColor;
        let r = RgbColor::from_rgb_str("#02abcd").unwrap();
        let r1 = r.to_tuple_rgba();
        let r2 = r.to_linear_tuple_rgba();
        println!("r1 = {:?}", r1);
        println!("r2 = {:?}", r2);
    }

prints

    r1 = (0.007843138, 0.67058825, 0.8039216, 1.0)
    r2 = (0.000607054, 0.4072403, 0.6104956, 1.0)

before and after the change.
2020-02-11 07:45:50 -08:00
Wez Furlong
8f3a233773 Remove dep on palette for resolving color names
Embed rgb.txt and parse it on the fly to produce the list of colors.
This list is a superset of palette's SVG color list.

refs: https://github.com/wez/wezterm/pull/144
2020-02-07 08:58:53 -08:00
Wez Furlong
152aa85e82 Add links to some docs on a couple of terminal mode codes 2020-01-26 19:14:05 -08:00
Wez Furlong
f3e42c3d2a point to local filedescriptor crate 2020-01-26 09:15:24 -08:00
Wez Furlong
ee70ec3ae0 Add support for OSC 104 (ResetColors) 2020-01-26 08:26:01 -08:00
Wez Furlong
3bc30d2d47 accept rgb:XX/XX/XX color syntax for OSC 4
The `vis` editor uses that syntax to apply its color schemes.

refs: https://github.com/wez/wezterm/issues/134
2020-01-26 07:37:08 -08:00
Wez Furlong
9d63d30fc0 vttest: make the E's show up on the cursor positioning test
Refs: https://github.com/wez/wezterm/issues/133
2020-01-25 20:20:31 -08:00
Wez Furlong
7aa0994b0f termwiz: lineedit: replace a println with render/flush
The terminal may not be attached to stdout, so the println isn't
appropriate.
2020-01-20 07:55:51 -08:00
Wez Furlong
51545ab099 termwiz: windows: normalize SHIFT+ASCII
This makes the input behavior consistent with posix: if SHIFT is held
and a letter key is pressed, make sure that we treat that as the ascii
uppercase version of that key and that the SHIFT modifier is cleared.
2020-01-17 16:56:29 -08:00
Wez Furlong
9ec4694d89 migrate some more code to the newer spawn mechanism 2020-01-16 09:15:07 -08:00
Wez Furlong
256b4e6da8 fix pollable_channel to be non-blocking on Windows
Upgrade filedescriptor to 0.7 to use the portable helper for
setting non-blocking mode, and enable non-blocking mode on Windows.
2020-01-15 21:30:14 -08:00
Wez Furlong
16c8957728 termwiz: fixup test case for 18bbd2ac6f 2020-01-14 22:09:33 -08:00
Wez Furlong
18bbd2ac6f termwiz: fixup input parser to match backspace/delete
With the changes in f0e94084d1 I
noticed that backspace and delete were inverted here in termwiz.

This diff adjusts the input parser to match.
2020-01-13 23:31:51 -08:00
Wez Furlong
da0185fee5 fix an issue where we'd scroll to the bottom when a modifier was pressed
This is irritating when switching tabs via keyboard shortcuts
2020-01-12 11:58:24 -08:00
Jeremy Fitzhardinge
b53412d0cb Track current working dir via OSC 2020-01-11 18:25:17 -08:00
Wez Furlong
b5124bfbdd set the dirty bit when joining rewrapped lines 2020-01-11 00:24:05 -08:00
Wez Furlong
e6b4aa835a re-wrap lines when resizing
Adds logic to resize handling that will consider the original logical
line length when the width of the terminal is changed.

The intent is that this will cause the text to be re-flowed as if it had
been printed into the terminal at the new width.  Lines that were
wrapped due to hittin the margin will be un-wrapped and made into a
single logical line, and then split into chunks of the new width.

This can cause new lines to be generated in the scrollback when
making the terminal narrower.  To avoid losing the top of the buffer
in that case, the rewrapping logic will prune blank lines off the
bottom.

This is a pretty simplistic brute force algorithm: each of the lines
will be visited and split, and for large scrollback buffers this could
be relatively costly with a busy live resize.  We don't have much choice
in the current implementation.

refs: https://github.com/wez/wezterm/issues/14
2020-01-11 00:10:25 -08:00
Wez Furlong
ad2f724416 bump some versions 2020-01-09 22:39:34 -08:00
Wez Furlong
9a6a0ffc37 termwiz: fix a bug where the cursor style wasn't restore on exit
`cargo run --example widgets_basic --features widgets` changes the
cursor style but wasn't changing it back when exiting.

In addition, setting the cursor to Default was only restoring visibility
and not restoring the style.
2020-01-09 22:29:11 -08:00
Wez Furlong
561cc856d6 prep termwiz for a new release
Make the widgets portion a feature that can be disabled
2020-01-09 21:52:47 -08:00
Jun Wu
1c5538976d Make windows::EventHandle Sync
See also https://github.com/wez/wzsh/issues/4.

This makes `WindowsTerminalWaker` Send and unblocks building streampager on Windows.
2020-01-05 19:59:19 -08:00
Jun Wu
6fdae9b226 Make UnixTerminalWaker::wake non-blocking
I was running `hg log --config pager.pager=sp` and pressing space without
releasing it. After about 10k lines sp appears to deadlock. It seems sp uses a
single thread for both reading terminal events and sending wake events and it
sends too many wake events without reading the events.

Failing to write to the wake pipe due to EWOULDBLOCK does not seem to be a
problem - there are enough events in the pipe to wake up the other side.
Therefore let's just make wake_pipe_write nonblocking and treat EWOULDBLOCK as
a success.

Context: The stuck thread looks like:

    #0  0x00007f32671ee237 in write () from /usr/lib/libc.so.6
    #1  0x000055c466022823 in std::sys::unix::fd::FileDesc::write () at src/libstd/sys/unix/fd.rs:96
    #2  std::sys::unix::net::Socket::write () at src/libstd/sys/unix/net.rs:276
    #3  <&std::sys::unix::ext::net::UnixStream as std::io::Write>::write ()
        at src/libstd/sys/unix/ext/net.rs:597
    #4  <std::sys::unix::ext::net::UnixStream as std::io::Write>::write ()
        at src/libstd/sys/unix/ext/net.rs:582
    #5  0x000055c465d010a6 in termwiz::terminal::unix::UnixTerminalWaker::wake (self=0x7ffe6bd32de0)
        at /home/quark/.cargo/git/checkouts/wezterm-6425bab852909cc8/ef1b836/termwiz/src/terminal/unix.rs:278
    #6  0x000055c465a6c64b in streampager::event::EventSender::send_unique (self=0x7ffe6bd32dd0, event=..., 
        unique=0x7ffe6bd32de8) at src/event.rs:66
    #7  0x000055c465a7e65a in streampager::display::start (term=..., term_caps=..., events=..., files=..., 
        error_files=..., progress=..., mode=streampager::config::FullScreenMode::Auto) at src/display.rs:295
    #8  0x000055c465a453a7 in streampager::Pager::run (self=...) at src/lib.rs:171
    #9  0x000055c465a0aced in sp::open_files (args=...) at src/bin/sp/main.rs:170
    #10 0x000055c465a08e4f in sp::main () at src/bin/sp/main.rs:25
2020-01-05 19:26:55 -08:00
Wez Furlong
624c7234e4 Improve serializing hyperlinks in lines for the mux
This is both a little more efficient on the wire and results in
hovering over hyperlinks working as you would expect in the mux.
2020-01-05 14:37:17 -08:00
Wez Furlong
12b537d2c8 serde_derive -> serde with derive feature 2020-01-05 14:37:17 -08:00
Jun Wu
318267c88b Fix negative cursor movement
I noticed moving-up does not work and tracked it down here.
2020-01-05 14:18:08 -08:00
Jun Wu
ef1b836441 Drop unnecessary mut from WindowsTerminalWaker::wake
This matches `UnixTerminalWaker`.
2020-01-04 14:04:56 -08:00
Jun Wu
0ac59cb44c Remove unused dependency
Detected by `cargo-udeps`.

I was wondering why @markbt/streampager requires `jpeg-decoder`.
2020-01-03 22:55:05 -08:00
Jeremy Fitzhardinge
887991f464 Remove BlockOutline cursor style
Not really needed, since its something we can handle at rendering time.
2019-12-29 16:58:15 -08:00
Jeremy Fitzhardinge
6d5fbf93ff Define outline cursor for unfocused use 2019-12-29 16:58:15 -08:00
Wez Furlong
8135ce46a5 Blink the cursor when it is set to blink
The blink rate is configurable via a new option.

Refs: https://github.com/wez/wezterm/issues/7
2019-12-22 10:08:31 -08:00
Wez Furlong
5abc4e543e rendering now respects cursor visibility
This commit adds some plumbing for describing the cursor shape
(block, line, blinking etc) and visibility, and feeds that through
the mux and render layers.

The renderer now knows to omit the cursor when it is not visible.
2019-12-22 08:52:51 -08:00
Wez Furlong
f493139305 clippy 2019-12-21 23:13:26 -08:00