1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-25 14:22:37 +03:00
Commit Graph

1294 Commits

Author SHA1 Message Date
Wez Furlong
dedce44c54 reattach tabs when reconnecting to a domain
This helps to restore any individually dropped tabs and to detect
tabs that were created by other clients across a reconnection.

refs: https://github.com/wez/wezterm/issues/127
2020-02-10 22:14:15 -08:00
Wez Furlong
79d8342a9d improve portability of window path/uri check for osc 7 2020-02-09 13:16:08 -08:00
Wez Furlong
65707aba56 allow setting default values for environment variables
This is useful for setting up a reasonable initial environment.
For example, on Windows you might want to set the `prompt` environment
so that some basic shell integration is enabled; this will cause new
tabs to open with the same cwd as the current tab:

```
set_environment_variables = { "prompt"="$E]7;file://localhost/$P$E\\$P$G" }
```

This setting is intended to apply only to the local domain.

refs: https://github.com/wez/wezterm/issues/146
2020-02-09 12:55:04 -08:00
Wez Furlong
15e875f765 make setting tab bar colors more ergonomic
closes: https://github.com/wez/wezterm/issues/148
2020-02-09 09:34:59 -08:00
Wez Furlong
d73a37be24 plumb OSC 7 cwd through to windows pty layer
This allows this prompt setting to work:

```
prompt $E]7;file://localhost/$P$E\$P$G
```

although this one sets it for future prompts:

```
setx prompt $E]7;file://localhost/$P$E\$P$G
```

refs: https://github.com/wez/wezterm/issues/146
2020-02-09 09:10:26 -08:00
Wez Furlong
1a50075ae6 windows: remove gross wsl spawning workaround
This doesn't appear to be needed anymore (perhaps is windows build
dependent?) and removing it is the nicer, cleaner thing to do.
2020-02-09 08:40:51 -08:00
Wez Furlong
9558fbe6a4 Added hide_tab_bar_if_only_one_tab config option
refs: https://github.com/wez/wezterm/issues/143
2020-02-08 08:15:36 -08:00
Wez Furlong
7d94aaa475 Added initial_rows, initial_cols configuration
Allows specifying the size of new windows.

Refs: https://github.com/wez/wezterm/issues/142
2020-02-07 21:43:12 -08:00
Wez Furlong
c7012dec9b refactor: move PDU handling logic to sessionhandler
This is conceptually slightly cleaner and allows sessionhandler to
be agnostic of the details of the channel used to communicate with
the client; it just has a Sender<DecodedPdu> to work with.
2020-02-03 07:46:52 -08:00
Wez Furlong
a8a0ad579e move the umask setting to happen earlier 2020-02-02 20:42:21 -08:00
Wez Furlong
2489abf9cb connui: accommodate multi-line 2fac prompts
This fixes up the cursor position when the remote host sends
a multi-line prompt.
2020-02-02 17:01:31 -08:00
Wez Furlong
6fb4d61dc0 fix default timeout for default unix domain 2020-02-02 15:44:49 -08:00
Wez Furlong
7257cf18c2 add some more diagnostics for mux connections
I suspect some race condition because adding these made the connect
time hang stop reproducing for me on my local network.

Will try this to the corp vpn.

refs: https://github.com/wez/wezterm/issues/127
2020-02-02 15:02:30 -08:00
Wez Furlong
cb9ec2fa2a biffed: native_tls
We use openssl on all platforms now
2020-02-02 13:03:07 -08:00
Wez Furlong
fa4bddd943 mux: improve error handling around ssh bootstrap and tls setup
Work a bit harder to capture more context and log it.

As of this commit, windows is now able to use openssl to connect to
a remote mux over TLS.
2020-02-02 13:03:07 -08:00
Wez Furlong
274d22edda tls: revisit cargo features
This commit adjusts the features in Cargo.toml to allow building
without openssl on unix systems.

It teaches the native_tls flavor of the code to perform bootstrapping
via ssh, but is still not usable because there still isn't a way
to get native_tls to use PEM files.
2020-02-02 13:03:07 -08:00
Wez Furlong
9b02089849 mux: tls: auto-bootstrap via ssh
This makes the tls channel much easier to use; the config can now be as
simple as this on the server side:

```toml
[[tls_servers]]
bind_address = "192.168.1.8:8080"
```

and this on the client side:

```
[[tls_clients]]
name = "hostname"
bootstrap_via_ssh = "192.168.1.8"
remote_address = "hostname:8080"
```

and then `wezterm connect hostname` will use ssh to connect to the
host, start the mux server, request the CA and client certs and
then connect to it over TLS.

This is implemented only for openssl at the moment.
2020-02-02 13:03:07 -08:00
Wez Furlong
d2080a4e90 mux frontend: don't panic during shutdown
We could panic with a send error during shutdown in some cli/proxy
related cases.  Avoid that.
2020-02-02 13:03:07 -08:00
Wez Furlong
b5e22941f3 connui: don't panic if the user closes the window while in use
If we're actively outputting to the window and the user closes it,
we don't need to panic.

Make the window a little larger now that it shows more data.
2020-02-02 13:03:07 -08:00
Wez Furlong
28243b2a32 mux: sound groundwork for auto pki
This is a step towards automatic management of TLS certs for the
mux stuff.
2020-02-02 13:03:07 -08:00
Wez Furlong
18a45657be mux: add read and write timeout options for sockets
Adds a default 60 second timeout for read and write for the tls
and unix domain sockets that we create.  This applies to ssh
domains, but not `wezterm ssh` sessions that go direct to ssh ptys.
2020-02-02 13:03:07 -08:00
Wez Furlong
096d18c440 connection ui: pull up a level
I noticed that the reconnection UI for TLS mux sessions was annoying
on macOS: it would flash up and steal the focus, make a connection
attempt that would immediately fail because the destination was not
routable and then close the window.  It would do this each time
a connection attempt was made (every few seconds in the early
stages of backoff).

This commit pulls the UI up a level so that we open the window at
the start of the connection (or re-connection) attempt, and keep
the same one for its lifetime.

This also introduces a headless UI object that doesn't output or
respond to anything.  You can set the log level to trace to see
what is happening inside.  It is used by the CLI mode.  It could
perhaps be made smart enough to conditionally show a UI when needed,
but since it is targeting local unix domain sockets, that doesn't
seem like it is needed right now.
2020-02-01 08:28:05 -08:00
Wez Furlong
f6df70a1df blow shaper cache when config is reloaded
It may be fine to preserve across a reload, but it doesn't hurt
much to blow it to be sure.
2020-01-27 20:56:47 -08:00
Wez Furlong
f5568b777b add font shaping lru cache
I'm adding this primarily to avoid repeatedly showing "No more
fallbacks" errors when moving the mouse over a terminal that contains
cells with no matching glyphs.

It has the nice side effect of changing the typical opengl tab render
time from ~2.9ms to ~1.3ms.
2020-01-27 20:48:01 -08:00
Wez Furlong
c778307b0e macos: fix light background/border
The opengl based render first clears the window to the background
color and then renders the cells over the top.

on macOS I noticed a weird lighter strip to the bottom and right of
the window and ran it down to the initial clear: our colors are SRGB
rather than plain RGB and the discrepancy from rendering SRGB as RGB
results in the color being made a brighter shade.  This was less
noticeable for black backgrounds.
2020-01-26 19:04:34 -08:00
Wez Furlong
d19db3c87b middle click on a tab to close it
Closes: https://github.com/wez/wezterm/issues/123
2020-01-26 10:21:47 -08:00
Wez Furlong
f41d82a254 remove some dead TerminalHost code 2020-01-26 08:55:56 -08:00
Wez Furlong
f125bd863a remove dead click_link method from terminal host
This is now handled by the gui layer
2020-01-25 23:17:45 -08:00
Wez Furlong
cdbb131833 mux: respect color scheme option for remote tabs 2020-01-25 23:05:02 -08:00
Wez Furlong
d52881a04e overlay: tab navigator fix down arrow
We'd allow going off the bottom of the list; fix the math to limit it
2020-01-25 22:42:13 -08:00
Wez Furlong
1c7e0d4e20 remove some debug prints 2020-01-25 22:32:01 -08:00
Wez Furlong
50d07acf99 Flesh out the tab navigator overlay
We now display a list of tabs and allow selecting them with either
the up/down arrows or the k/j keys.  Enter activates the selected
tab, Escape cancels the overlay.
2020-01-25 19:16:23 -08:00
Wez Furlong
42379d4edf remove unused local variables 2020-01-25 17:18:45 -08:00
Wez Furlong
ff82b63fb8 alt-9 pops up an overlay on the current tab
This is placeholder for the moment, but proves the concept
2020-01-25 17:18:45 -08:00
Wez Furlong
3940684b4e respect color scheme for termwiz derived tabs 2020-01-25 17:18:45 -08:00
Wez Furlong
0822c67e32 overlay: initial prep
An overlay is a little termwiz app that can be overlaid over the
content of a gui tab.

The intent is for these to provide the mechanism for meta operations;
listing all tabs in a long-form list and switching between them,
dropping into configuration or error log review and so on.
2020-01-25 17:18:45 -08:00
Wez Furlong
78ab99e0d0 avoid allocating an empty window id
This prevents logging a message about a window being removed
from being printed at startup when connecting to a remote mux.
2020-01-25 17:18:45 -08:00
Wez Furlong
eff682e0bb add connecting status UI for mux connection attempts
We now show a little status window when we're making a connection
for a remote mux domain.

This should make things feel slightly nicer if there is a connectivity
problem.

refs: https://github.com/wez/wezterm/issues/127
2020-01-25 15:58:12 -08:00
Wez Furlong
1fe9e16f25 refactor ssh connection ui into its own module
I want to re-use this for the mux client
2020-01-25 15:10:34 -08:00
Wez Furlong
fd8f28960f ssh: use a single window for authenticating a session
This makes it so that we preserve context while showing the connection
status and authentication prompts.
2020-01-25 13:00:16 -08:00
Wez Furlong
1ef95b917a do a better job at tearing down termwiztermtabs
This avoids lingering on shutdown after showing one of these windows.
2020-01-25 12:59:28 -08:00
Wez Furlong
a1b9d04709 Update structopt to 0.3 2020-01-24 21:49:42 -08:00
Wez Furlong
4f08d010b7 move unix listener to its own module 2020-01-24 19:31:04 -08:00
Wez Furlong
ee1c335703 ssh: canonicalize line endings for prompt text
We most likely get instructions with unix line endings, but the
termwiz surface wants canonical CRLF, so fix that up.
2020-01-24 16:41:23 -08:00
Wez Furlong
8eb5a0e72c ssh: fix for sites that use 2fac 2020-01-24 16:08:20 -08:00
Wez Furlong
b59893fd9f ssh: allow a number of auth retries
Rather than just a single attempt at each mechanism, let's allow up
to 3 loops, each time trying all supported mechanisms.  This helps
for the case where the user makes a typo with their password, and
should also help for more complicated auth setups where succeeding
with one mechanism may not be sufficient.

While testing this out I noticed that were deferring closing the
OS level window until after the entire auth attempt, so I added
some logic to proactively close the prompt windows.  In the longer
term I'd like all related prompts to render in the same window
for improved cognotive continuity.
2020-01-24 08:39:34 -08:00
Wez Furlong
970e4a8e64 ssh: try password auth before keyboard interactive
This may help for sites that use 2fac; after entering the password
correctly, the 2fac prompt may appear.
2020-01-24 00:04:37 -08:00
Wez Furlong
cb89ec73e3
First pass at building an AppImage (#125)
refs: https://github.com/wez/wezterm/issues/124
2020-01-20 23:11:38 -08:00
Jun Wu
70e9c7cb16 Make Shift+LeftClick extend existing selection
This matches cmd.exe and other programs (notepad, office, etc) behavior:
First click selects "start", then Shift+click selects "end". They form
a range.

This is particularly useful to select a large range of text, since the
user can release the left button, then operate on the scroll bar without
worrying about messing up text selection.

It gets a bit more complicated with the POSIX "mouse grabbed" situation.
When the mouse is grabbed, it's usually a full-screen ncurses-like
application. Selection mostly likely only makes sense within a single
screen. So Shift + LeftClick just works as starting a selection in this
case (otherwise it'll be hard to clear a selection).
2020-01-20 15:18:36 -08:00
Jun Wu
6f3c52f5d3 Fix IME position on Windows
The IME position is related to on-screen Window, not the
off-screen buffer.

    Buffer
    +- 0
    |
    |                    Window
    |                    +- 0
    |                    | (Tab bar)
    +- 20 physical_top   +- 1
    |                    | (Terminal view)
    |                    |
    |                    |
    +- 30 cursor.y       +- 11 Correct IME position
2020-01-20 13:58:21 -08:00
Jun Wu
dba0fdd94f Drop an unused &mut 2020-01-20 13:58:21 -08:00
Wez Furlong
82c824f371 pty: remove conpty support
It's too fiddly to setup in practice, and literally no one has
expressed an interest in using it.

Removing it simplifies some upcoming work.

Closes: https://github.com/wez/wezterm/issues/35
2020-01-20 07:55:51 -08:00
Wez Furlong
ec082bec31 split ClientSession out of the main listener module 2020-01-20 07:55:51 -08:00
Wez Furlong
36656585a2 move UmaskSaver to its own file 2020-01-20 07:55:51 -08:00
Wez Furlong
7688d669d7 read_bytes -> std::fs::read 2020-01-20 07:55:51 -08:00
Wez Furlong
22622219c7 refactor: move listener and tls bits into own files 2020-01-20 07:55:51 -08:00
Wez Furlong
894e971e25 Show a window with the full error message for failed config load
This is a very basic first approximation for the feature discussed
in the associated github issue.

Refs: https://github.com/wez/wezterm/issues/80
2020-01-17 18:47:02 -08:00
Wez Furlong
e823207809 mux: avoid deadlock when remote has grabbed the mouse 2020-01-17 12:13:36 -08:00
Wez Furlong
a9b50267e9 avoid pruning windows/tabs while user activity is in progress
This caused "window removed" messages to appear in the log for some
slow/broken muxer configurations, which then masked surfacing of
the real problem.
2020-01-17 09:02:42 -08:00
Wez Furlong
b058ac9170 there's no such thing as an acquire store... 2020-01-17 09:02:16 -08:00
Wez Furlong
efd1db8581 simplify frontend layer
remove the executor bits that now reside in promise::spawn
2020-01-16 23:17:01 -08:00
Wez Furlong
b295575953 tidy up wezterm cli list
There's a panic during shutdown that needs to be run down though
2020-01-16 23:06:25 -08:00
Wez Furlong
c3bee703bb asyncify the client rpc methods + fanout 2020-01-16 22:49:01 -08:00
Wez Furlong
e814bc4267 mux: Domain::spawn is now async
This was another source of hanging on windows with connecting to a unix
domain.
2020-01-16 16:36:27 -08:00
Wez Furlong
7de282fd07 mux: make Domain::attach an async fn 2020-01-16 15:55:15 -08:00
Wez Furlong
aeb91ff238 migrate more things over to the new spawn stuff 2020-01-16 10:31:53 -08:00
Wez Furlong
9ec4694d89 migrate some more code to the newer spawn mechanism 2020-01-16 09:15:07 -08:00
Wez Furlong
75eb16bec4 move spawn_task into a new promise::spawn module 2020-01-16 03:50:48 -08:00
Wez Furlong
ac3ccab1c5 window: adopt async_task for spawn_task 2020-01-16 01:31:28 -08:00
Wez Furlong
62f0f7a273 adopt async-task for muxserver task runner
This simplifies some of its code
2020-01-16 01:03:32 -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
101aedd6a5 remove .wait() from finish_attach
While debugging on windows earlier today I saw that we were
blocked on this wait on the main thread.  For whatever reason,
that only blocks in practice on Windows; I suspect that this is
due to a timing issue on windows where the server side takes
longer to respond than it does on posix.
2020-01-15 20:50:54 -08:00
Wez Furlong
4442e8030d mux: fix disconnect when a lot of output is dumped to the terminal
The root cause and secondary effect were a little surprising: the mux
pub/sub notification pipe filled up and because the mux notify routine
uses `retain` with the success of the send as a predicate it meant that
the full pipe resulted in the muxer killing that end of the subscriber
and that in turn made the ClientSession loop fail when it was
dispatching a notify on the other end, which terminated the loop and
disconnected the client.

Now, with this fixed, we have a flow control problem and the terminal
will remain busy with ctrl-c not being effective in the mux session.
2020-01-14 22:51:48 -08:00
Wez Furlong
3352013614 fix lingering selection when a row is changed
This was an accidental casualty of some recent refactoring;
we need to clear the selection range when lines that intersect
with it are changed, so that's what this does.

Fixes: https://github.com/wez/wezterm/issues/118
2020-01-14 22:21:25 -08:00
Wez Furlong
4b455288dd track the full current dir URL for OSC 7
Matching against the current dir when it includes a host and a
path seems like a handy way to automate selecting appropriate
theme/color/profile settings, so I'd like to make sure that
we have the full URL content available for that.

Refs: https://github.com/wez/wezterm/issues/115
Refs: https://github.com/wez/wezterm/issues/117
2020-01-14 22:06:13 -08:00
Wez Furlong
ced85ac11b macos: teach it about the color schemes path in the .app bundle 2020-01-13 10:44:54 -08:00
Wez Furlong
bb6251fad9 prevent stats printing from interfering with cli proxy
This makes using stats with the mux possible again:

```
periodic_stat_logging = 10
```
2020-01-13 08:56:38 -08:00
Wez Furlong
c989485a77 mux: add basic version handshake at domain connect time 2020-01-13 08:10:23 -08:00
Wez Furlong
ac32ae19d8 gah, rustfmt 2020-01-12 22:20:18 -08:00
Wez Furlong
1af9ded3ce Add color_scheme configuration option
I'll write up more comprehensive docs once CI has proven that
the color schemes are packaged correctly.

The gist of it is that you can now specify:

```
color_scheme = "Batman"
```

to specify the default color palette.

The name corresponds to one of the color schemes from the
`assets/colors` directory.  That directory is packaged and installed by
the CI deployment script, but we're also able to load them from the
source dir if you're running from in the wezterm source tree.

You can see previews of the various schemes here:
<https://iterm2colorschemes.com/>

In addition to loading from those that path, wezterm will search:

* In the `config` dir that is a sibling to `wezterm.exe` on windows
  (not yet tested!)
* The directories specified in your `color_scheme_dirs` config setting
  (multiple paths can be specified)
* You may also define schemes directly inline in your config file
  using syntax like this:

```
[color_schemes."My Name"]
foreground = "#4a4543"
background = "#f7f7f7"
```
2020-01-12 22:08:36 -08:00
Wez Furlong
ab2090c5c4 load color schemes when we parse the config
This eagerly parses all eligible schemes
2020-01-12 21:40:30 -08:00
Wez Furlong
6656097794 fix "random" thick cursor outlines
These visual artifacts seemed to affect everything other than Wayland
and were a bit annoying.  The manifestation was that the cursor outline
box might have an extra line of another color on one or more of the
borders; whether it did or not seemed dependent on a combination of the
position of the cursor and the pixel width/height of the overall window.

This commit sets the texture sampler to prefer not to interpolate/merge
the value if it is between pixels and instead take the nearest texel.
2020-01-12 17:52:19 -08:00
Wez Furlong
746f42be17 opengl: don't give up on the paint if a line is too long
Resizes can transiently result in lines whose length doesn't
match the vertex buffer width.  If that happens, we probably
still derive value from painting the remaining lines, so allow
that to continue rather than blowing up the render.
2020-01-12 15:22:17 -08:00
Wez Furlong
756774ede2 mux: invalidate rather than drop lines on resize
This avoids a blank flash during resize/redraw operations

refs: https://github.com/wez/wezterm/issues/116
2020-01-12 14:56:49 -08:00
Wez Furlong
3c3e73e374 avoid some number of resize rpc calls
Skip them if the size doesn't appear to have changed

refs: https://github.com/wez/wezterm/issues/116
2020-01-12 14:49:15 -08:00
Wez Furlong
367a44fb96 avoid accidentally blocking on the pollable channel
make sure the socketpair is nonblocking (note: this only works
on unix at this time)

refs: https://github.com/wez/wezterm/issues/116
2020-01-12 14:42:38 -08:00
Wez Furlong
22884a2e81 double/triple click and drag extend selection by word/line
Closes: https://github.com/wez/wezterm/issues/89
2020-01-12 13:30:14 -08:00
Wez Furlong
e6a6825b28 refactor double/triple click boundary logic into selection.rs 2020-01-12 13:13:19 -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
eac29274ed Comment typo 2020-01-11 18:25:17 -08:00
Jeremy Fitzhardinge
cb34ac9cdd Add working dir to mux protocol 2020-01-11 18:25:17 -08:00
Jeremy Fitzhardinge
24ecfca5a5 Drop directory for ssh domains 2020-01-11 18:25:17 -08:00
Jeremy Fitzhardinge
83641ed46c Spawn new tabs using the current tab's current directory
(If known.)
2020-01-11 18:25:17 -08:00
Jeremy Fitzhardinge
71eb27ccb5 Add get_current_working_dir to Tab 2020-01-11 18:25:17 -08:00
Wez Furlong
5f0e2b01da Mux: add window invalidation concept
This fixes a problem where a closed tab would linger until a subsequent
input event.  The issue was that the layer at which we detect the tab
closure didn't have a way to signal the gui layer to repaint.

This commit adds an invalidated flag to the mux window object that is
updated when structural changes occur to its tabs; added, deleted,
activated and so on.

We check that flag in our periodic function in the gui layer and then
trigger a gui level invalidation if we see that it is set.
2020-01-11 11:48:00 -08:00
Wez Furlong
2e581252c1 refine vertical size adjustments when resizing the terminal 2020-01-11 09:40:36 -08:00
Wez Furlong
44b3c412b6 mux: always send the cursor row 2020-01-10 09:11:44 -08:00
Wez Furlong
ba90abf805 mux: reintroduce server side state to gate pushes
Record a notion of the state of the invalidations that we've sent
to the client so that we can skip sending updates if nothing has
changed since the last push.
2020-01-10 08:56:27 -08:00
Wez Furlong
88c3d620bf mux: bounded number of fds for ServerPollable
It was possible to exhaust the number of fds on the server by
opening a vertical vim split and aggressively sliding it left
and right.

This commit allows the produce side to clone an arbitrary number
of senders without using up file descriptors.
2020-01-10 08:56:04 -08:00
Wez Furlong
c8635c07f3 mux: avoid over-invalidating in a couple of cases 2020-01-09 08:47:29 -08:00
Wez Furlong
0f5eec0244 mux: I think I found the invalidation issue
Need to treat None as dirty when looking at the line cache in
get_dirty_lines
2020-01-09 08:07:17 -08:00
Wez Furlong
4765ce60e5 mux: avoid overly aggressively dirtying lines
Still not perfect; there's a window invalidation missing from
the mux somewhere on higher latency connections that gets
resolved just by moving the mouse :-/
2020-01-09 06:39:00 -08:00
Wez Furlong
4516036479 reduce debug log level 2020-01-08 23:09:34 -08:00
Wez Furlong
4391ab5f55 mux:improve management of line cache
There was an issue where we'd get stuck with a placeholder empty
line in a couple of rows when running `ls -l /etc` and scrolling
backwards.  The damage was actually done during execution of the
ls command and was because we'd get confused about the state of
some of the line entries.

This diff introduces a proper state enum for them and defines
state transitions more rigorously.
2020-01-08 22:05:58 -08:00
Wez Furlong
d76e4ed42d use RangeSet for the result of get_dirty_lines 2020-01-08 08:34:22 -08:00
Wez Furlong
cb624173d2 leave it up to get_lines to clear the dirty flag 2020-01-08 07:49:06 -08:00
Wez Furlong
9639d137a7 mux: avoid dirtying a line if it is unchanged on fetch
I noticed the mux was running hot when idle and observed that it was
repeatedly fetching the line with the cursor.

Extract the logic into a helper function that is called from both
of the places that fetch and put lines; noticed that we were not
consistently processing hyperlinks.
2020-01-07 23:01:49 -08:00
Wez Furlong
199e873e54 add spawn_task helper function
When running the mux server we don't have an active window::Connection
so we can't use its spawn_task function.  This little helper runs
the futures on the appropriate Tasks instance.

We can't use a trait method for this because traits abhor generic
parameter types.
2020-01-07 20:23:26 -08:00
Wez Furlong
68d460295a improve some rate control in the mux protocol
The client side will limit how many rows it decides to speculatively
prefetch and defer to the lines requested by the renderer once we
exceed a certain number of fetch requests per second.

On the server side, we weren't actually coalescing individual tab
output events together; this commit restructures the end of the
appropriate loop block to make that effective.
2020-01-07 18:04:22 -08:00
Wez Furlong
3fb89d7e02 ensure that domain.attach() is awaited for or waited on 2020-01-07 07:55:22 -08:00
Wez Furlong
a8561a40b2 asyncify the ssh initialization 2020-01-07 07:46:21 -08:00
Wez Furlong
4edc17f157 simply the logic in run_mux_client a bit 2020-01-07 07:30:32 -08:00
Wez Furlong
9c9bf6fb97 add CommandBuilder::from_argv 2020-01-07 07:27:02 -08:00
Wez Furlong
89171cd706 begin async'ifying main.rs 2020-01-07 07:16:41 -08:00
Wez Furlong
41ee87f43c make Domain::attach return a Future
This avoids a hang on startup if you're using an ssh multiplexer
connection and haven't already registered your ssh key and need
to perform password authentication.
2020-01-06 22:41:59 -08:00
Wez Furlong
6a5f203e4b Fix an issue where a config reload would trigger a cascade of reloads
The last config reload time didn't seem to stick in the periodic timer
callback.

Need to investigate that further, and also see if the blink paint
time is similarly impacted.
2020-01-06 14:08:14 -08:00
Wez Furlong
c7aa8cd845 fix some warnings 2020-01-06 11:42:09 -08:00
Wez Furlong
93256f3339 fix lingering after closing down
The root cause of this was a bit of a hack to ensure that we didn't
prematurely shut down while waiting for ssh sessions.

Introduce an Activity token that will extend the lifetime of the
event loop even if there are no windows present.

This cleans things up both on macos the application would linger in
the application switcher until you had tabbed away and back again,
and also for the null frontend which had grown a less gross hack.
2020-01-06 11:37:41 -08:00
Wez Furlong
2f6f3ed933 restructure to avoid borrow error
Rust maintains the borrow from the match expression for the lifetime of
the match blocks, even though there is no relationship between the
value in scope in the blocks :-/

Having separate statements makes things happier.
2020-01-06 10:00:46 -08:00
Wez Furlong
57ad948af1 mux: add bonus lines to GetTabRenderChangesResponse
The server now uses this to send the line content for
whichever line the cursor is on, which makes typing
latency better.
2020-01-06 08:36:56 -08:00
Wez Furlong
b384ee4233 make it possible to re-use the line serialization in other pdus 2020-01-06 08:21:12 -08:00
Wez Furlong
0b3af1b7fe add a pdu size histogram to the stats
It tracks the serialized size of the data; here's some stats from a `--release`
build:

```
STAT                                               p50      p75      p95
Key(executor.spawn_delay)                          9.09µs   11.14µs  29.44µs
Key(gui.paint.opengl)                              7.18ms   7.86ms   28.31ms
Key(pdu.decode.compressed.size)                    161      807      2575
Key(pdu.decode.size)                               34       41       45
Key(pdu.encode.size)                               5        6        12
Key(pdu.size, [pdu = GetLinesResponse])            161      807      2575
Key(pdu.size, [pdu = GetLines])                    9        12       16
Key(pdu.size, [pdu = GetTabRenderChangesResponse]) 41       41       47
Key(pdu.size, [pdu = GetTabRenderChanges])         5        5        5
Key(pdu.size, [pdu = ListTabsResponse])            15       15       15
Key(pdu.size, [pdu = ListTabs])                    3        3        3
Key(pdu.size, [pdu = Resize])                      10       11       11
Key(pdu.size, [pdu = SendKeyDown])                 7        8        8
Key(pdu.size, [pdu = UnitResponse])                0        0        0
Key(rpc, [method = get_lines])                     729.09µs 4.06ms   10.16ms
Key(rpc, [method = get_tab_render_changes])        335.87µs 362.50µs 436.22µs
Key(rpc, [method = key_down])                      183.30µs 205.82µs 284.67µs
Key(rpc, [method = list_tabs])                     244.74µs 244.74µs 244.74µs
Key(rpc, [method = resize])                        557.06µs 1.35ms   1.82ms
Key(shape.harfbuzz)                                10.24µs  19.20µs  35.33µs
```
2020-01-06 08:03:29 -08:00
Wez Furlong
f0ea9af97a renumber some pdus to make version mismatch more apparent 2020-01-06 07:54:30 -08:00
Wez Furlong
b0c04c4da0 tidy up proxy path computation 2020-01-06 07:51:50 -08:00
Wez Furlong
0c88894a5a don't assume my own local build paths by default(!) 2020-01-06 07:46:37 -08:00
Wez Furlong
a9a7a9662e ensure that we update fetch_pending in the error case 2020-01-06 07:42:40 -08:00
Wez Furlong
100084d6e5 remove the OpenURL pdu from the codec
Link clicking is handled locally now, so this is not needed.
2020-01-06 07:33:40 -08:00
Wez Furlong
b07babb335 Closing a window closes the window, rather than the tab
refs: https://github.com/wez/wezterm/issues/101
2020-01-06 00:03:01 -08:00
Wez Furlong
8419862f12 track selection per tab again
Selection got accidentally moved to be scoped by window during
the remodel.  This commit moves it to the per tab state.

refs: https://github.com/wez/wezterm/issues/89
2020-01-05 23:23:26 -08:00
Wez Furlong
180a991760 macos: add use_ime option to disable the IME
The IME stuff on macos tends to swallow repeats for some keys.
Ugh.  So this commit adds an option to disable the use of the IME.

Switching away from it effectively inverts the meanging of backspace
and delete (because our method is no longer called by the IME), so
we need to check for that and remap it.  Ugh.

Ugh.
2020-01-05 22:54:59 -08:00
Wez Furlong
bf910397dd fix error reporting if daemonize fails
This got broken in the move to anyhow
2020-01-05 20:38:53 -08:00
Wez Furlong
f38e39134e reinstate scroll to bottom on input behavior
This was temporarily disabled as part of the mux datamodel changes
2020-01-05 18:17:06 -08:00
Wez Furlong
fe0b9bde86 fix selection row when viewport is scrolled back 2020-01-05 17:31:45 -08:00
Wez Furlong
ac2c8aadf6 fix an issue where the cursor would appear in the tab bar
If the cursor was in the first non-tab bar row, we'd incorrectly render
it in the same column on both rows.
2020-01-05 16:23:03 -08:00
Wez Furlong
bda0a3b5fe windows: remove DoubleClick from input enums
double clicks weren't registering correctly with the new selection
logic.  Tell windows that we're doing all our own click counting
and simplify the logic.
2020-01-05 16:16:06 -08:00
Wez Furlong
4687b3bb48 clippy 2020-01-05 15:14:32 -08:00
Wez Furlong
89f2023577 mux: invalidate StableRowIndex 0..rows when switching alt screen
We would leave a copy of the alt screen lines at the top of the
scrollback.

This commit ensures that those lines are marked dirty and that
the dirty bits are propagated to the client to invalidate its cache.
2020-01-05 15:07:00 -08:00
Wez Furlong
9f270c25e7 mux: fix tab title at attach time
We were ignoring the title returned by list tabs and would subsequently
only pick up the title after a later update.

This passes the title in at construction.
2020-01-05 14:44:08 -08:00
Wez Furlong
94b78a47c8 mux: workaround a spurious panic notification with ssh connections
The issue is that when we start the proxy mode up, we haven't set
up a frontend, and the ssh client wants to kick off a non-essential
task via the executor.

This commit starts up a null frontend in proxy mode so that that
machinery is present.

Then, because we don't register any tabs with the mux, we need to
adjust the behavior of the null frontend to not terminate when
the mux has no tabs.

It's a little gross.
2020-01-05 14:37:17 -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
dfa2b08c72 move URL highlight processing to the gui layer 2020-01-05 14:37:17 -08:00
Wez Furlong
ad91742439 refine log levels of some debug logs 2020-01-05 14:37:17 -08:00
Wez Furlong
cd2b57cc51 use rangeset to streamline line fetches 2020-01-05 14:37:17 -08:00
Wez Furlong
01f3adc2cb remove more old surface sync code, improve fetch quality
Still not perfect and still iterating
2020-01-05 14:37:17 -08:00
Wez Furlong
d79455c2b4 switch most of the rest of the mux over to the new model
This mostly works, but has a cache invalidation issue wrt.
passing invalidated rows from the server to the client...
sometimes.

However, scrollback is cached on demand and selection works.
2020-01-05 14:37:17 -08:00
Wez Furlong
66b8b774f5 partially connect new data to mux rpc layer 2020-01-05 14:37:17 -08:00
Wez Furlong
400c8aa66d remove explicit dirty manipulation from Renderable
This commit leaves mux domains broken for the moment,
but also simplifes the implementation of the renderable interface.
2020-01-05 14:37:17 -08:00
Wez Furlong
ed97a56055 remove viewport control from renderable trait
This is now handled 100% by the gui layer
2020-01-05 14:37:17 -08:00
Wez Furlong
bc24399f06 instrument rpc size distribution 2020-01-05 14:37:17 -08:00
Wez Furlong
43dd7dd03b add harfbuzz shaping stats 2020-01-05 14:37:17 -08:00
Wez Furlong
4f5441deb6 make the stats output a bit prettier 2020-01-05 14:37:17 -08:00
Wez Furlong
e4fed76bd1 instrument painting and rpc calls 2020-01-05 14:37:17 -08:00
Wez Furlong
4270d144d4 Add GetLines rpc 2020-01-05 14:37:17 -08:00
Wez Furlong
f17feb305b remove highlight and mouse response bits from the rpc 2020-01-05 14:37:17 -08:00
Wez Furlong
0a1a44eef0 pass mouse grabbed state over remote tabs
This allows local double click selection to work outside vim
and for mouse reporting to work inside vim.
2020-01-05 14:37:17 -08:00
Wez Furlong
c5a8531a91 fix mouse cursor after changing the selection logic
We weren't setting the cursor to an I-beam
2020-01-05 14:37:17 -08:00
Wez Furlong
1b925b593a fix reported scrollback size for surface based tabs 2020-01-05 14:37:17 -08:00
Wez Furlong
bcf3d8db35 remove some dead code 2020-01-05 14:37:17 -08:00
Wez Furlong
6db31d5f64 implement triple click selection 2020-01-05 14:37:17 -08:00
Wez Furlong
fac3c3c719 implement double click word selection 2020-01-05 14:37:17 -08:00
Wez Furlong
02ab0f1c3e Implement select and copy 2020-01-05 14:37:17 -08:00
Wez Furlong
5a605ea5c5 render selection locally
This enables drag to select and rendering of the selection.

Actually copying it is still TODO, as is double and triple click
handling.
2020-01-05 14:37:17 -08:00
Wez Furlong
55e4050aa3 use LastMouseClick for paste click counting 2020-01-05 14:37:17 -08:00
Wez Furlong
17b2c49c68 rearrange more mouse event code 2020-01-05 14:37:17 -08:00
Wez Furlong
48d971c106 pull click counting code up from terminalstate 2020-01-05 14:37:17 -08:00
Wez Furlong
f1089e84bf Middle button always pastes if shift is held 2020-01-05 14:37:17 -08:00
Wez Furlong
fa9f699d46 rearrange mouse coordinate math
Move it up so that we can reference it in a later diff
2020-01-05 14:37:17 -08:00
Wez Furlong
a8bf11a825 add Selection types to the gui layer
These are still unused

refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
4912e83f3e StableCursorPosition to track the cursor
This fixes up the cursor position when scrolling.

refs: https://github.com/wez/wezterm/issues/106
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
Wez Furlong
1c716898e7 Remove viewport_offset from RenderableDimensions
refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
ef072255dd Process shift+pageup/down at the gui layer
Refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
6183434bda Track viewport in the gui layer
Use StableRowIndex to implement tracking the viewport in the gui layer.
This resolves an issue where a busy terminal would continue to scroll
through the scrollback when you were paging backwards and look weird.

There's still some cleanup though:

- This breaks the selection ui
- the cursor position is wrong when scrolling back
- shift-pageup/pagedown need to be processed in the gui layer

Refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
39dc6516df simplify key_event logic a little
Early return and remove some explicit return statements
2020-01-05 14:37:17 -08:00
Wez Furlong
e8d46442ac move mouse wheel scroll handling to gui layer
It's not really moved, but rather duplicated there; we still have
fallback logic in terminalstate.rs that processes the equivalent
action, but adding the logic to the gui layer means that we can
process it in terms of the Tab and Renderable interfaces.

refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
bafa36b8ca simplify middle mouse button paste logic
Now that we can tell whether the mouse is grabbed, we can safely
process the paste in the same way that we use for keyboard initiated
pasting.
2020-01-05 14:37:17 -08:00
Wez Furlong
5f5113ce50 Renderable: fold get_scrollbar_info into get_dimensions 2020-01-05 14:37:17 -08:00
Wez Furlong
5ba0c70cdb add Tab::is_mouse_grabbed concept
refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
f1846ab0ae add Renderable::get_lines
This allows retrieving arbitrary lines from the scrollback

refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
56c170240f Renderable: replace a 2-tuple with an expanded struct
This cleans up the API a little as part of
refs: https://github.com/wez/wezterm/issues/106
2020-01-05 14:37:17 -08:00
Wez Furlong
8d3e513ed8 Ensure that the scroll thumb is well defined when disabled
When the scrollbar is disabled we still create a quad for it, and that
quad stretches to the window height.  It is left with undefined texture
and could be either partially or totally transparent and lead to weird
effects like it appearing as though the titlebar was too wide for the
window, or by dimming the RHS of the window when toggling the scroll
bar on and off a few times.

This commit ensures that we set a well defined size and color when
the scroll bar is disabled, and seems to improve things for me.

Refs: https://github.com/wez/wezterm/issues/103
2020-01-02 11:20:42 -08:00
Wez Furlong
364fc147be Instant::elapsed() 2019-12-31 15:56:41 -08:00
Wez Furlong
253c36bf8c use duration_since per @jsgf 2019-12-31 15:38:57 -08:00
Wez Furlong
6b78d1ad27 Implement tab movement via key assignment
This commit adds the ability to change the relative or absolute
position of a tab within its containing window through the
use of a key assignment.

We include a default assignment of CTRL+SHIFT+PageUp for moving
left and CTRL+SHIFT+PageDown for moving right.

Closes: https://github.com/wez/wezterm/issues/84
2019-12-31 15:31:50 -08:00
Wez Furlong
cc27f3f902 Only highlight cells that use exactly the highlight URL
If the cells refer to the same object instance (rather than equivalent
instances), then we treat them as part of the same highlight.

Refs: https://github.com/wez/wezterm/issues/94
2019-12-31 14:35:36 -08:00
Wez Furlong
699d092a6b Ignore mouse clicks that coincide with window focusing
Now that we can track focus changes, we can eliminate an annoyance:
clicking in the window to focus it would cause a click event to
be passed to the terminal and clear the selection.

This commit will swallow button events that occur within 200ms
of the focus being gained by the window.
2019-12-31 14:11:09 -08:00
Wez Furlong
5540b2e66b Don't default to swapped backspace and delete on macos
With the changes in Refs: https://github.com/wez/wezterm/issues/88
we don't need to swap them by default on macos any more.
2019-12-30 10:33:52 -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
999ba79436 Use non-focused cursor shape for unfocused windows 2019-12-29 16:58:15 -08:00
Jeremy Fitzhardinge
a499eedb86 Make sure cursor gets refreshed properly on focus change 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
Jeremy Fitzhardinge
0bc0972f75 Track focus state and disable cursor blinking when not focused
Issue https://github.com/wez/wezterm/issues/93
2019-12-29 16:58:15 -08:00
Jeremy Fitzhardinge
962b74c458 Only blink cursor when it's not moving
The cursor should only start blinking when its been sitting in once place;
a moving cursor should always be visible. Rather than making the cursor blink
relative to the creation time of the window, track its position, and use the
last time it moved as the blinking timebase.

Fixes https://github.com/wez/wezterm/issues/83
2019-12-29 09:38:59 -08:00
Wez Furlong
5d55b8bc2e Ensure that the scrollbar defines more vertex fields
This is a bit of a speculative change to see if it helps with
refs: https://github.com/wez/wezterm/issues/82

I have sometimes seen my scrollbar have a color that I didn't
choose and ISTR having some issues in the past when updating
the quads if I didn't set all of the fields of the vertex
to a better defined value.
2019-12-28 12:15:48 -08:00
Wez Furlong
afc96688ae Use $WEZTERM_CONFIG_FILE for config path if set
This makes it easier for me to test other configurations when
troubleshooting issues!
2019-12-28 11:30:32 -08:00
Wez Furlong
fa7a007a9f Don't hang when using middle mouse button to paste
A while back I moved the clipboard related processing mostly out
of the term processing code, but since I mostly use the keyboard
for pasting, I'd overlooked the middle mouse button paste flow.

This is problematic because fetching the clipboard requires a
degree of inter process communication and needs the event loop
to be pumped.  Since the terminal callbacks are dispatched from
an event loop callback, attempting to block on the clipboard
future causes a deadlock.

This commit resolves that issue by anticipating that we'll need
the clipboard contents for the majority of middle mouse button
clicks and scheduling a fetch and cache ahead of passing that
event down to the terminal layer.

Why don't we simply use the same technique as the Paste key
assignment?  If the terminal is currently using SGR mouse
tracking mode then the application on the other end of the
pty will want the raw button press.   Our layering doesn't
allow for passing up the concept of whether a middle button
does paste or sends the raw event.

tricksy!

Refs: https://github.com/wez/wezterm/issues/87
2019-12-28 09:15:24 -08:00
Wez Furlong
c8cd600706 wayland: fix unintentional blend with other windows
@jsgf mentioned this to me, and since I've started running "proper"
wayland gnome-shell/mutter on my pixelbook go, I'm seeing it too.

The issue is that the alpha values are potentially <1.0 when they
are committed to the frame buffer and the mutter compositor is
faithfully blending wezterm with the window behind it, leading to
weird looking effects such as varying brightness of text, or for
cases where the window behind wezterm is bright white, a halo
effect that makes the text less sharp.

This commit addresses this issue by asking glium to ask opengl to
set the destination alpha to 1.0 in the final draw stage.
2019-12-27 19:12:19 -08:00
Wez Furlong
de3ffb3428 fix min underline height
I noticed this for small enough sizes of Fira Code the border width
for the cursor would round to zero, and then looking at eg: `man ls`,
the underlined portions had no underline.

Ensure that the underline size is at least 1 pixel.
2019-12-27 12:03:45 -08:00
Wez Furlong
0a6e3fda30 move scrollbar bits to their own module 2019-12-27 11:37:45 -08:00
Wez Furlong
ba2caa815d Allow omitting window_padding fields
Closes: https://github.com/wez/wezterm/issues/85
2019-12-27 09:58:51 -08:00