1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-18 10:52:16 +03:00
Commit Graph

205 Commits

Author SHA1 Message Date
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
Wez Furlong
662227a725 bump vtparse version for publishing 2019-12-21 16:43:13 -08:00
Wez Furlong
4fdee2baf0 maybe fix the windows build for anyhow changes 2019-12-14 22:27:37 -08:00
Wez Furlong
9a2c7a1485 failure -> anyhow + thiserror 2019-12-14 21:43:05 -08:00
Wez Furlong
7c7825c070 term: extract configuration to a trait
This isn't complete but begins the process of extracting
the embedding application configuration into a trait provided
by the application rather than passing the values in at
construction.

This allows the application to change configuration at
runtime.

The first option to handle this is the scrollback size.
2019-11-24 12:43:41 -08:00
Wez Furlong
ac7a509dbb allow configuring the tab bar
The defaults are pretty neutral.  You can get a little more fancy
with something like this:

```
[colors.tab_bar]
background = "#0b0022"

[colors.tab_bar.active_tab]
bg_color = "#2b2042"
fg_color = "#c0c0c0"

[colors.tab_bar.inactive_tab]
bg_color = "#1b1032"
fg_color = "#808080"

[colors.tab_bar.inactive_tab_hover]
bg_color = "#3b3052"
fg_color = "#909090"
italic = true
```
2019-11-21 00:04:49 -08:00
Wez Furlong
d397976acf fix rendering of the cursor position in the line editor 2019-11-16 13:58:01 -08:00
Wez Furlong
6289c08a4e Adopt CSI u modifier encoding for keypresses
See http://www.leonerd.org.uk/hacks/fixterms/ for the specification.

Refs: https://github.com/wez/wezterm/issues/63
2019-11-16 13:38:03 -08:00
Wez Furlong
7323e30be7 try to normalize the shift state in the keymap handling code
We weren't recognizing ctrl+shift+c for example on linux.
2019-11-11 09:11:52 -08:00
Wez Furlong
a26cab3833 add wezterm imgcat subcommand to output images to the terminal
This subcommand parses its input and outputs an iTerm2 compatible
img escape sequence (https://iterm2.com/documentation-images.html)

Usage is straightforward:

```
$ wezterm imgcat  assets/windows/terminal.ico --width "10%" --height "10%"
```
2019-11-09 15:50:59 -08:00
Wez Furlong
6da7b3ecd0 internalized password/auth UI for ssh
This is a bit of a large commit because it needed some plumbing:

* Change mux creation to allow deferring associating any domains,
  and to change the default domain later in the lifetime of the
  program
* De-bounce the empty mux detection to allow for transient windows
  during early startup
* Implement a bridge between the termwiz client Surface and the
  frontend gui renderer so that we can render from termwiz to
  the gui.
* Adjust the line editor logic so that the highlight_line method
  can change the length of the output.  This enables replacing
  the input text with placeholders so that we can obscure password
  input
2019-11-08 19:55:12 -08:00
Wez Furlong
1ab438c1e2 improve emoji width calculation
I noticed while scrolling `emoji-test.txt` that some of the combined
emoji sequences rendered very poorly.  This was due to the unicode
width being reported as up to 4 in some cases.

Digging into it, I discovered that the unicode width crate uses a
standard calculation that doesn't take emoji combination sequences
into account (see https://github.com/unicode-rs/unicode-width/issues/4).

This commit takes a dep on the xi-unicode crate as a lightweight way
to gain access to emoji tables and test whether a given grapheme is
part of a combining sequence of emoji.
2019-11-05 08:45:08 -08:00
Wez Furlong
a9bdca6d84 bump up to latest unicode segmentation crate 2019-11-04 22:12:21 -08:00
Wez Furlong
23b4876d75 fix an issue with utf-8 in OSC sequences
I've noticed this off and on for a while, and thought it was something
fishy with my shell dotfiles.

Tracing through I found that the final byte in the "Face with head
bandage" emoji 🤕 U+1F915 was being interpreted as the MW control
code and causing the vt parser to jump out of the OSC state.

The solution for this is to hook up proper UTF-8 processing in the
same way that it is applied in the ground state.

Since we don't have enough bits to introduce new state values (we're
pretty tightly packed in the 16 bits available), I've introduced a
memory of the state to which the utf8 parser needs to return once
a complete sequence is detected.
2019-11-03 22:01:35 -08:00
Wez Furlong
c3d8f26e3e fix test case
refs: https://github.com/wez/wezterm/issues/52
2019-10-28 00:14:19 -07:00
Wez Furlong
d80169ceff Avoid accidental application mode delete output in key processing
I thought that I'd broken something with the DEL processing in vim with
the new frontend but it turned out that the other frontend was emitting
BS always and that I'd actuall unbroken passing DEL through and that
other layers were translating DEL into an application cursor mode output
for DEL that emits a totally different sequence.

This diff preserves DEL and disables that other sequence.

Will follow up with some explicit configuration to control this
behavior, but in the short term, the default behavior should be much
closer to what people actually want and expect!

refs: https://github.com/wez/wezterm/issues/52
2019-10-27 23:59:15 -07:00
Wez Furlong
d97a84f984 render iterm2 image protocol in the software renderer
This is still a bit rough because the terminal parser doesn't
understand the pixel sizes, so it relies on the hard coded
cell dimensions being accurate.
2019-10-26 23:30:39 -07:00
Wez Furlong
52a65370fa cargo fmt with rust 1.38 2019-09-28 21:40:40 -07:00
Wez Furlong
950a7d2b22 cargo fix dyn 2019-09-28 20:29:48 -07:00
Wez Furlong
23e174a324 fully bump filedescriptor dep 2019-07-23 09:50:48 -07:00
Wez Furlong
6ace6d4fcc avoid a panic when resizing a muxed tab as the first event 2019-07-16 09:34:51 -07:00
Wez Furlong
d18383416e termwiz: update version
This pulls in the new vtparse crate and publishes Mark's new
API in the termwiz parser.
2019-06-29 19:20:11 -07:00
Wez Furlong
5440cbe521 replace vte with our own vtparse crate
This enables using large OSC buffers in a form that we can publish
to crates.io without blocking on an external crate.  Large OSC
buffers are important both for some tunnelling use cases and for
eg: iTerm2 image protocol handling.
2019-06-29 16:28:39 -07:00
Wez Furlong
2361d88c2a initial take on a low level vt parser
This is based on the state machine described by
https://vt100.net/emu/dec_ansi_parser

and the public domain C implementation:
https://github.com/haberman/vtparse
2019-06-29 15:21:09 -07:00
Mark Thomas
dbb0bd565e add parse_first_as_vec
Add a convenience function to the escape parser that, like `parse_first`,
matches only the first escape sequence, but instead collects all matching
actions.
2019-06-25 06:44:30 -07:00
Wez Furlong
2c7138cc6e use consistent version of filedescriptor crate 2019-06-22 14:31:19 -07:00
Wez Furlong
cb4fa1ac21 get_dirty_lines now uses Cow<Line>
This avoids some extra allocations in the local tab case.
2019-06-22 06:57:35 -07:00
Wez Furlong
97daa8b246 switch to using the poll stuff from filedescriptor 0.3 2019-06-19 00:01:35 -07:00
Wez Furlong
b58d329b07 some plumbing to use Surface+Change for the mux protocol 2019-06-16 21:04:53 -07:00
Wez Furlong
01a8c32b55 unblock tunneled mux protocol work
It's taking a while for https://github.com/jwilm/vte/pull/20 to get
merged, so point to my branch directly while I build out some
tunneled mux protocol escape sequences.

I'll need to fork vte on crates.io if vte doesn't merge the PR
before the next termwiz crate bump.
2019-06-13 06:57:10 -07:00
Wez Furlong
86cd39eb4e we can now send input to a client tab 2019-06-09 16:33:57 -07:00
Wez Furlong
8055957406 clippy 2019-06-09 07:33:00 -07:00
Wez Furlong
5ccff722ef more log 2019-06-08 15:37:55 -07:00
Wez Furlong
3b94cddf8e allow specifying key bindings in wezterm.toml
refs: https://github.com/wez/wezterm/issues/32
2019-06-08 08:28:34 -07:00
Wez Furlong
e9780d6a34 termwiz: bump version for crates.io/streampager 2019-06-02 21:00:26 -07:00
Wez Furlong
43fcca6343 termwiz: ensure that the tty is in blocking mode
Refs: https://github.com/markbt/streampager/issues/1
Refs: https://github.com/markbt/streampager/issues/3
2019-06-02 20:36:01 -07:00
Wez Furlong
c0e3bdfb70 termwiz: avoid emitting a wake event on a spurious pipe wakeup 2019-06-02 18:27:15 -07:00
Wez Furlong
ae303fea56 termwiz: avoid emitting a resize event on a spurious sigwinch read 2019-06-02 18:11:07 -07:00
Wez Furlong
d000938fef emulate poll(2) on macos using select(2)
Refs: https://github.com/wez/wezterm/issues/31
2019-06-02 16:15:17 -07:00
Wez Furlong
090c24554f introduce our own poll function
This is just a minor refactoring at this stage

Refs https://github.com/wez/wezterm/issues/31
2019-06-02 14:53:07 -07:00
Wez Furlong
00c1000caa bump termwiz version for crates.io 2019-06-02 13:55:25 -07:00
Mark Thomas
70741d4f80 set underline and blink in fallback path
pull/29 inadvertently removed the fallback path for setting single
underline and slow blink.  Restore it.
2019-06-02 13:55:07 -07:00
Mark Thomas
3f16979067 clean up flush_pending_attr
The `flush_pending_attr` method does lots of unnecessary comparisons.
If the attributes have changed, then it works by resetting the
attributes and then setting new values.  There's no need to emit the
codes for exiting modes.

It also doesn't support double underscore or rapid blink in the cases
where the terminfo capabilities are used, as these capabilities can't
express these attributes.  Fall back to CSI sequences when these
attributes are requested.
2019-06-02 12:41:46 -07:00
Mark Thomas
90689d4406 set colors after resetting attributes
Changing the terminal attributes (bold, underline, etc.) involves
emitting the `exit_attribute_mode` or SGR reset sequence.  This also
resets the colors back to their defaults.  If this happens when the
foreground or background colors haven't changed, set the colors again.
2019-06-02 12:41:46 -07:00
Wez Furlong
99919dc807 implement answerback for osc 4, 10-18
These codes are used to change the color palette, but if the `?`
string is used in place of a color spec, then we must respond with
the current color value string for that palette entry, so lets
implement that!
2019-06-02 12:19:58 -07:00
Wez Furlong
8f8d03fc05 support osc 10-19 dynamic color changing 2019-06-01 21:47:25 -07:00
Wez Furlong
276e9aef91 osc 4 accepts multiple parameters 2019-06-01 19:59:44 -07:00
Wez Furlong
d18dbe9ff7 parse OSC 4
This code is used to change the color palette at runtime.
We can parse it but not do anything useful with it yet.
2019-06-01 15:39:46 -07:00
Wez Furlong
fb1a5b42d2 bump filedescriptor crate 2019-06-01 08:23:23 -07:00
Wez Furlong
906aa0c95c termwiz: use filedescriptor crate instead of RawHandle bits 2019-06-01 07:43:06 -07:00
Wez Furlong
38adc117f4 termwiz: use filedescriptor crate instead of RawFd bits 2019-05-31 22:52:40 -07:00
Wez Furlong
3c6552b975 cargo publish wants a.b.c rather than a.b for package.version 2019-05-27 20:09:33 -07:00
Wez Furlong
98bd82e212 bump some deps 2019-05-27 20:08:30 -07:00
Wez Furlong
91ea7cd576 add keywords 2019-05-27 19:57:44 -07:00
Wez Furlong
37f451843c termwiz: prep for publishing on crates.io 2019-05-27 19:53:52 -07:00
Wez Furlong
3a3755fbe6 moved varbincode to its own repo 2019-05-27 19:44:55 -07:00
Wez Furlong
5976e8d229 lineedit: add tab completion support 2019-05-27 17:39:10 -07:00
Wez Furlong
330c8e8c1f lineedit: add ctrl-d -> EOF 2019-05-27 16:17:49 -07:00
Wez Furlong
a94c802a74 lineedit: add history 2019-05-27 13:35:24 -07:00
Wez Furlong
2b85d5dca4 termwiz: introduce host concept, prompt and coloring
The LineEditorHost trait allows colorizing the line editor.
2019-05-27 12:42:19 -07:00
Wez Furlong
fb5d0464fb lineedit: ctrl-c cancels the current line 2019-05-27 10:29:22 -07:00
Wez Furlong
3e24ef2ea8 cargo fmt 2019-05-27 10:20:33 -07:00
Wez Furlong
0d2bbcfce6 lineedit: add ctrl-w to delete word up to cursor 2019-05-27 09:21:19 -07:00
Wez Furlong
56885e5bad lineedit: add word movement commands 2019-05-27 09:18:36 -07:00
Wez Furlong
0f3869be16 lineedit: implement ctrl-k and fixup deletion of emoji 2019-05-27 08:17:24 -07:00
Wez Furlong
8a44344937 lineedit: split out action and movement concepts
This makes it a bit easier to implement more key bindings and
to make them configurable in the future
2019-05-27 08:02:38 -07:00
Wez Furlong
8a74eff72e lineedit: add ctrl-L repaint/refresh binding 2019-05-27 07:14:39 -07:00
Wez Furlong
90fece7b27 fixup windows build 2019-05-26 23:02:50 -07:00
Wez Furlong
cd027430db fixup tests 2019-05-26 22:58:38 -07:00
Wez Furlong
b1af0cefbd tidy up the line editor interface and docs a bit 2019-05-26 22:52:07 -07:00
Wez Furlong
5dd0e39b05 termwiz: improve line editor
Move the cursor to the correct column when emoji are input.
Add some docs.
2019-05-26 22:39:50 -07:00
Wez Furlong
4fe790dd0c add cursor movement, deletion 2019-05-26 22:04:47 -07:00
Wez Furlong
07910f1d59 disable mouse input in line editor example 2019-05-26 21:20:43 -07:00
Wez Furlong
6d243ec1f1 termwiz: add very basic line editor 2019-05-26 21:10:37 -07:00
Wez Furlong
cc0d2e5493 termwiz: fixup key_tester example on macOS
We need to set the terminal to blocking mode when we want poll_input
to block forever, otherwise we immediately receive WouldBlock error
response and quit the program.
2019-05-26 19:01:03 -07:00
Wez Furlong
0bb3714435 improve double-click selection of wrapped lines
This one has been bugging me for a while; we now know when we've
wrapped a line and can join it without a line break when double-clicking
to select a word.

This commit introduces a wrapped attribute to help record this
information, which could potentially help with when it comes
to looking at nicer resize behavior in refs: https://github.com/wez/wezterm/issues/14
2019-05-26 16:05:51 -07:00
Wez Furlong
09f168a0db plumbing for double click selection of wrapped lines 2019-05-26 14:52:03 -07:00
Wez Furlong
038100922a clippy 2019-05-26 12:49:10 -07:00
Wez Furlong
607e180122 Range::contains is now stable; use it. 2019-05-26 11:40:33 -07:00
Wez Furlong
bba1d69c13 remove bincode dep 2019-05-26 09:30:34 -07:00
Wez Furlong
3cf20acd13 remove the last of the extern crate lines 2019-05-26 09:00:42 -07:00
Wez Furlong
f87901c484 tidy up some failure usage 2019-05-26 08:58:59 -07:00