1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 23:21:08 +03:00
Commit Graph

129 Commits

Author SHA1 Message Date
Wez Furlong
02eb0b4294
mux: rename Mux::get() -> try_get(), add "infallible" Mux::get()
This allows removing a bunch of unwrap/expect calls.

However, my primary motive was to replace the cases where we used
Mux::get() == None to indicate that we were not on the main thread.

A separate API has been added to test for that explicitly rather than
implicitly.
2022-12-19 11:55:35 -07:00
Wez Furlong
ee2aac0902
mux: require that Domain be Send + Sync 2022-12-19 11:52:38 -07:00
Wez Furlong
696148941c
Rc<Tab> -> Arc<Tab> 2022-12-19 11:52:38 -07:00
Wez Furlong
6e06b9af02
mux: Pane is now required to be Send+Sync. Use Arc<dyn Pane> 2022-12-19 11:52:33 -07:00
Wez Furlong
43f2265ef1 deps: textwrap -> 0.16
closes: https://github.com/wez/wezterm/pull/2664
2022-10-23 20:50:47 -07:00
Wez Furlong
f2b0ce7d2e mux client: add a warning 2022-10-18 08:22:51 -07:00
Wez Furlong
ac1413a99a fix panic with window:set_workspace when default domain is mux
refs: https://github.com/wez/wezterm/issues/2638
2022-10-17 07:06:43 -07:00
Wez Furlong
0d78261a30 mux client: consider domain id when mapping panes
We weren't matching the domain id when resolving the remote->local pane
mapping, which meant that having 2 or more mux client domains active
would lead to associating eg: remote pane id 1 with whichever local
pane was associated with any remote pane id 1 *first*.

This commit requires that both the domain id and the remote pane id
match.

refs: https://github.com/wez/wezterm/issues/2616
2022-10-11 21:28:11 -07:00
Wez Furlong
7ba9c00e49 mux client: add domain id to logs
refs: https://github.com/wez/wezterm/issues/2616
2022-10-11 20:27:55 -07:00
Wez Furlong
0e27fe847f mux client: refine some debug a big
refs: #2616
2022-10-11 19:26:46 -07:00
Wez Furlong
4d598eb1ad mux: fix stale local/remote window id mapping in mux client
When closing the all mux tabs in a window, the remote will close
the window. If the local has a mixture of local and remote tabs
then subsequent attempts to spawn a tab in that window would
fail due to reusing the stale remote window id.

This commit purges the local/remote mappings that are (probably)
dead when the remote indicates that a pane has been removed.

The mapping should be re-established as needed later on.

refs: https://github.com/wez/wezterm/issues/2614
2022-10-11 08:03:57 -07:00
Wez Furlong
a0afe9c5ae mux: disable the lag indicator by default
I'd like to push that into the status bar, so nudge people towards
that in the docs for this.

There is a config option to restore it. I'd like to ultimately
remove that though.

refs: https://github.com/wez/wezterm/discussions/2542
2022-09-22 06:46:56 -07:00
Antoine Büsch
36f47ec3f6
Expose activate-pane-direction cli command (#2526)
* Expose `activate-pane-direction` cli command

Add a new subcommand for `wezterm cli` called `activate-pane-direction`.
It allows switching the active pane in the current tab in the given
direction.

* Bump codec version

* Replace boolean flags with a single direction arg

* Run cargo fmt
2022-09-20 08:37:05 -07:00
Wez Furlong
14c613a064 add Pane::get_metadata
The idea here is that different kinds of panes may want to expose
additional metadata to lua scripts. It would be a bit weird to add
a Pane method for each of those and plumb it all the way through
the various APIs, so just allowing a pane impl to return a dynamic
value (likely an Object) allows a bunch of flexibility.

This commit exposes the clientpane is_tardy boolean and the time
since the last data was recevied (since_last_response_ms) from
the mux client pane implementation: these are used to show the
tardiness indicator in the client pane.

Exposing this data enables the user to add that info to their
status bar if they wish.
2022-09-01 21:27:49 -07:00
Wez Furlong
cb9fe1a676 flesh out some todos with new pane trait methods
Tidy some things up to avoid some dead code and redundant impls.
Make it easier to select whether you want to implement the new
methods in terms of the old, or the old methods in terms of
the new in a given pane impl.
2022-08-27 07:58:17 -07:00
Wez Furlong
b7b1e4020a revise Pane line related funcs
Adds Pane::for_each_logical_line_in_stable_range_mut and
Pane::with_lines_mut which allow iterating mutably over lines.

The idea is that this will allow the renderer to directly cache
data in the Line via its appdata without having to build cumbersome
external caching logic and managing cache keys.

This commit just swaps the implementation around for localpane
and sanity checks that the renderer functions.

Various overlays and the mux client don't properly implement these
yet and current warn at compile time and panic at runtime.

To follow is the logic to cache the data and make sure that it
works the way that I think before converting the other Pane
implementations.
2022-08-26 08:05:06 -07:00
Wez Furlong
5e993c581a termwiz: remove reverse video attribute from Line
It didn't really belong there; it was added as a bit of a hack
to propagate screen reverse video mode.

Move that to the RenderableDims struct and remove the related
bits from Line
2022-08-24 22:43:47 -07:00
Wez Furlong
aed0e3ebf8 populate pixel dims + dpi in PaneEntry
This makes those fields usable in `wezterm cli list --format json`.

This doesn't change the ABI of the mux protocol, but prior to
this commit, those fields were always 0.

refs: #2319
2022-07-31 11:25:39 -07:00
Wez Furlong
39adbb984d Pane::search: expose range, limit. Limit quickselect by default
The recent work on the scrollback made it easier to constrain the
search region, so expose those parameters to the Pane::search
interface and to the mux protocol.

Use those new parameters to constrain quickselect search to
1000 rows above and below the current viewport by default, and
add a new parameter to QuickSelectArgs that allows overriding that
range.

A follow-up commit could make the search/copy overlay issue a series
of searches in chunks so that it avoids blocking the UI when
searching very large scrollback.

refs: https://github.com/wez/wezterm/pull/1317
2022-07-25 18:31:27 -07:00
Wez Furlong
8002a17242 term: default to cluster storage
The previous commit added the option to convert the storage to
the cluster format.  That saves memory as rows are moved to scrollback,
but makes scrolling back more expensive due to that conversion.

This commit adds a fast(ish) path for the common case of simply
appending text to a new line before it gets scrolled: the default
format for lines in the screen is now the cluster format and,
provided that the cursor moves from left to right as text is
emitted, can simply append to the cluster storage in-place
and avoids a conversion when the line is moved to scrollback.

This improves the throughput of `time cat enwiki8.wiki` so
that the runtime is typically around 11-12s (compared to 9-10s
before introducing cluster storage).  However, this is often
a deal of variance in the measured time and I believe that
that is due to the renderer triggering conversions back to
the vec storage and introducing slowdowns from the render side.

That's what I'll investigate next.
2022-07-23 22:54:43 -07:00
Wez Furlong
614900f85c line: introduce possibility of alternate cell backing
Uses an enum as a way to use an alternative to Vec<Cell>, but
doesn't provide that alternative in this commit.
2022-07-23 08:18:34 -07:00
Wez Furlong
8f44dc46d9 exec_domains: allow async callbacks. can now also set label for launcher
The fixup callback can now by async, which makes it possible to use
other async functions in the callback.

There is an additional parameter to wezterm.exec_domain that allows
setting the label that is shown in the launcher menu.
It accepts either a string value or an async callback function
that can be used to compute the label dynamically.
2022-07-08 18:46:09 -07:00
Wez Furlong
df7c09d760 track dpi in mux and terminal model
refs: https://github.com/wez/wezterm/issues/2085
2022-06-15 18:54:51 -07:00
Wez Furlong
167127c14b disco: reduce info -> debug for gui-sock publish 2022-06-01 05:59:06 -07:00
Wez Furlong
75420c1b8f cli: add move-pane-to-new-tab command
This allows moving a pane to a new tab, which can in turn be
created in a new window.

refs: https://github.com/wez/wezterm/issues/1253
2022-05-28 06:43:22 -07:00
Wez Furlong
c4a248f1a3 mux: split-pane can optionally move an existing pane into the split
This commit allows for the SplitPane internal action to use the
pane id of an existing pane as the source of the pane to be added
in the new split target, rather than spawning a new command.

This can be used to move a pane from one tab to another, and is
analagous to tmux's `join-pane` command.

refs: https://github.com/wez/wezterm/discussions/2043
refs: https://github.com/wez/wezterm/issues/1253
2022-05-27 19:47:12 -07:00
Wez Furlong
ecd05547d5 Add SplitPane assignment
This, along with the plumbing included here, allows specifying
the destination of the split (now you can specify top/left, whereas
previously it was limited to right/bottom), as well as the size
of the split, and also whether the split targets the node at the
top level of the tab rather than the active pane--that is referred
to as full-width in tmux terminology.

https://github.com/wez/wezterm/issues/578
2022-05-21 21:09:11 -07:00
Wez Furlong
39bb8b3f39 mux: match workspace to local window when syncing panes
The logic that figures out whether/how to map remote windows
to the potential local window needs to account for the workspaces
on any given local/remote pair.

In particular, if we are called with a primary window id that
has say "default" as its workspace, we mustn't decide to place
remote tabs from a window whose workspace is not "default"
into that local window, or else we can end up in a weird
state where we have 3 workspaces on the remote, but have
accidentally folded one of them into the `default` workspace
and thus end up thinking that we have one workspace with two
windows and one other workspace, instead of the intended
3 windows each with a distinct workspace.

refs: https://github.com/wez/wezterm/issues/1978
2022-05-19 22:45:34 -07:00
Wez Furlong
c8c3b8378a ssh: avoid busy loop when all channels are closed on the session
We need to notice when all of the streams associated with a channel are
closed and remove the channel from the set that we're polling in the
main loop, to avoid continually polling the closed descriptors.

Additionally, if the Session has been dropped, we know that we cannot
be asked to create any new channels, so if there are no more channels
then we can and should exit that dispatch loop and allow the resources
to be cleaned up.

refs: https://github.com/wez/wezterm/issues/1993#issuecomment-1130539934
2022-05-19 21:02:06 -07:00
Wez Furlong
b833ee73b3 mux: don't kill panes when the domain is detached!
refs: #1993
2022-05-15 17:02:24 -07:00
Wez Furlong
e9e590c64e cargo update
note: this pins the openssl crate to workaround the combination
of these two issues:

refs: https://github.com/sfackler/rust-openssl/issues/1630
refs: https://github.com/sfackler/rust-openssl/pull/1578
2022-05-08 20:50:47 -07:00
Wez Furlong
fb635c4362 feed unicode version config through to Line for ls-fonts
This makes the reported metrics show correctly for:

```
wezterm -n --config "font=wezterm.font('Noto Sans Mono CJK JP')" \
        --config treat_east_asian_ambiguous_width_as_wide=true \
        ls-fonts --text ".☆a☆☆☆☆"
```

refs: https://github.com/wez/wezterm/issues/1888
2022-04-19 21:12:21 -07:00
Wez Furlong
8fbb1d0c0b mux: add AttachDomain and DetachDomain key assignments
The launcher menu code to perform attaching has been generalized
into a key assignment action and reimplemented in terms of that
action.

A detach action has been added to disconnect and detach.

refs: https://github.com/wez/wezterm/issues/1874
2022-04-17 21:41:50 -07:00
Wez Furlong
7afc9e4d56 mux: use --prefer-mux when spawning cli proxy for domain attach
It doesn't make sense to try to connect to a possibly stale gui instance
that might have been running on the same host.
2022-04-17 18:15:17 -07:00
Wez Furlong
03d8f10d11 mux: pass current window_id to Domain::attach
This commit allows the currently active window to:

* Spawn a new tab in the active window (rather than spawning
  a new window) to host the connection status
* Auto-close that connection UI tab (rather than the whole window)
  when the window is no longer needed
* Pass the current window through to use as the primary window when
  assigning remote window/tabs.

The net effect of this is that there are fewer transient windows,
and that it is easier to connect a set of domains to the active
workspace.

refs: https://github.com/wez/wezterm/issues/1874
2022-04-17 18:07:58 -07:00
Wez Furlong
6b67ae842c mux: try to detect invalid data on stdout during connection
Use some heuristics to verify the data that is about to be parsed;
this can help to detect eg: data being output to stdout prior
to us sending any encoded data to the remote mux.

In addition, add a timeout to help avoid waiting forever in
the case that we didn't detect a problem.

refs: https://github.com/wez/wezterm/issues/1860
2022-04-11 21:08:57 -07:00
Wez Furlong
b908e2dd8c mux: fix update issue
The heart of the issue here was due to the window-reuse logic that
tries to reuse a GUI window that is no longer associated with a mux
window.

Each GUI window subscribes to the mux for mux events, but it filters
according to is understanding of the mux_window_id that it is associated
with.

The GUI frontend maintains an mapping of GUI and mux window so that it
knows when to reuse a GUI window and when to close it.

When connecting to a remote mux, wezterm spawns a temporary connection
progress window.  Once connected, workspace reconiliation is triggered
and decides that this window can be used for something else.

As part of workspace reconciliation, this mapping can be adjusted and
the frontend will notify a GUI window that its mux window has changed.

However, that updated mux window was not visible to the mux notification
subscription so the effect was that a variety of notifications were
effectively ignored, including updates from a remote mux when the output
was changed.

To make matters worse, the workspace reconciliation could "double-tap"
window creation and create excess windows only to later realize they
weren't needed and close them out again.

This commit addresses both of these concerns.

refs: #1841
refs: #1814
2022-04-08 10:15:18 -07:00
Wez Furlong
9ee2d0f6b2 clientpane: delay before re-sync
The fix for f478672fd8 regressed
the one for b398eaf656.

Compensate by adding a short delay.

refs: #1752
2022-04-05 07:29:57 -07:00
Wez Furlong
f478672fd8 mux: fix artifacts in multi-pane layouts after closing a pane
refs: https://github.com/wez/wezterm/issues/1277
refs: https://github.com/wez/wezterm/issues/783
2022-03-28 22:47:32 -07:00
Wez Furlong
b398eaf656 mux: fix CloseCurrentPane={confirm=false}
After killing the remote pane, we no longer trigger the renderable
poll stuff that would detect that the pane was dead.

Let's speculatively set it to dead so that we don't get stuck with
stray tabs/panes.

https://github.com/wez/wezterm/issues/1752
2022-03-28 22:18:53 -07:00
Wez Furlong
1c9bd347c2 multiplexer: improve handling of image attachments
There were a a couple of issues:

* `ImageData::hash` would re-hash the image on every call, and this was
  called for every cell that comprised an image on the mux server side
* `SerializedLine` needed to understand how to remove the `Arc<ImageData>`
  image attachments so that we didn't serialize a complete copy of the
  image per cell that comprised the image.

A new RPC was introduced to attempt to fetch `ImageData` given its
content hash and pane, row and cell index as a hint to locate it.

A client side LRU of content hash to `ImageData` is used to avoid
issuing repeat calls to that new RPC.

refs: #1237
2022-03-28 20:28:05 -07:00
Wez Furlong
3c701d9dc8 mux: propagate focus changes to remote mux
Pretty much the same test plan as b4c4c85683

but start wezterm:

./target/debug/wezterm -n --config 'ssh_domains={{name="s",remote_address="localhost"}}' connect s

This reliably propagates focus=true events, but if the client switches
focus away from a mux pane to a local pane, then the focus=false event
may not be propagated to the remote mux.

refs: #1608
2022-03-27 09:30:18 -07:00
Wez Furlong
4007ccbcd2 track focused pane in the client info
wezterm cli spawn, and wezterm cli split-pane can use this information
to pick a default for the pane id when invoked from outside of wezterm.

refs: https://github.com/wez/wezterm/issues/1531
2022-03-18 19:24:54 -07:00
Wez Furlong
22cea37959 deps: textwrap -> 0.15 2022-03-03 07:19:21 -07:00
Wez Furlong
e7b8374c3f thread original umask through when spawning mux server
refs: #1633
2022-02-11 10:00:09 -07:00
Wez Furlong
9c83e27172 remove grey_out method from palette
This was used by the mux client when the session is tardy.
I've heard feedback that the greying out is distracting and not
especially useful, so I don't think this is any great loss.
2022-02-05 17:01:31 -07:00
Wez Furlong
cf518c9186 fun with sticky bits and RUNTIME_DIR
This commit does two related things, from opposite ends of the spectrum:

* Sets the sticky bit on pid files and unix sockets to avoid tmpwatch
  deleting them in cleanup scenarios
* Falls back to looking at the changed time if the filesystem doesn't
  support reporting creation time when wezterm does its own liveness
  and cleanup checks for unix domain sockets in the runtime dir
* Allow any wezterm instance to perform that cleanup

refs: #1601
2022-01-31 07:29:15 -07:00
Wez Furlong
4b94214530 mux: remove Dirty state from client renderable
That concept was obsoleted by line sequence numbers.

refs: #1597
2022-01-29 09:27:54 -07:00
Quentin Perret
39086c048b Make the threshold for predictive echo configurable
Introduce a new config knob called 'local_echo_threshold_ms' to let
users configure when the local echo prediction should kick in. The
default value is 100ms to retain the current behavior.
2022-01-28 09:49:35 -08:00
Wez Furlong
e4ed2c93e2 encoding my preferred import grouping in the rustfmt config
This uses an unstable option in rustfmt, you `cargo +nightly fmt`
needs to be used to format the code correctly.
2022-01-17 13:50:51 -07:00