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

63 Commits

Author SHA1 Message Date
Wez Furlong
74da631430
mux: allow client to provide palette to mux server
The server-side ownership of the palette is a stumbling block for
many users, so let's fix it.

This commit allows the client to pass its configured palette to
the server when it connects, and when the config is changed.

That palette takes precedence over the palette from the server config.

However, if the remote application uses any escape sequences that
redefine the color palette, the color palette that was active at
that point in time is forked and use as the basis, and will remain
the active palette until the palette is reset via escape sequences.

refs: https://github.com/wez/wezterm/issues/2686
refs: https://github.com/wez/wezterm/issues/3397
2023-03-31 08:02:32 -07:00
Wez Furlong
98e137942a
mux: move-pane-to-new-tab didn't resync structure
Resolution is to propagate the MuxNotification to the clients
and have them resync.

refs: https://github.com/wez/wezterm/issues/3219
2023-03-25 20:50:03 -07:00
Wez Furlong
622ea1add8
mux: notify clients when the size/structure of a tab changes
This helps to notify when eg: splits are changed, or the tab
is resized by another client.

refs: https://github.com/wez/wezterm/issues/2133
refs: https://github.com/wez/wezterm/issues/2351
refs: https://github.com/wez/wezterm/issues/783
2023-03-24 17:28:34 -07:00
Wez Furlong
f71bce1727
mux: propagate pane focus change events to clients
This commit causes the mux to generate a PaneFocused notification
when the active pane is changed.

The mux server will forward that as a unilateral PDU to connected
clients.

The clientpane implementation will handle that by applying the
same state to the local mux.

refs: #2863
2023-03-24 13:13:31 -07:00
Wez Furlong
2b298f5f96
mux: pass gui window position through from new mux window
Threads through a GuiPosition from mux window creation to allow it to be
used when the corresponding gui window is created.

SpawnCommand now has an optional position field to use for that purpose.

```lua
wezterm.mux.spawn_window {
  position = {
    x = 10,
    y = 300,
    -- Optional origin to use for x and y.
    -- Possible values:
    -- * "ScreenCoordinateSystem" (this is the default)
    -- * "MainScreen" (the primary or main screen)
    -- * "ActiveScreen" (whichever screen hosts the active/focused window)
    -- * {Named="HDMI-1"} - uses a screen by name. See wezterm.gui.screens()
    -- origin = "ScreenCoordinateSystem"
  },
}
```

refs: https://github.com/wez/wezterm/issues/2976
2023-02-05 21:43:37 -07:00
Wez Furlong
1609fd386b
add wezterm cli get-text command
closes: https://github.com/wez/wezterm/pull/2729
2023-02-05 09:05:48 -07:00
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
6e06b9af02
mux: Pane is now required to be Send+Sync. Use Arc<dyn Pane> 2022-12-19 11:52:33 -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
ef532fc7e5 mux: adjust window size after attach
Since the initial attach is async, we'd create the window at the
default/initial size and then never reconcile the size of the remote
tabs once they'd attached.

This commit introduces an event that allows the gui window to do that.

The action that it takes is to take the max width and height between
its current size and the size of a newly added tab and resizes to
that new size, if it changed.

refs: https://github.com/wez/wezterm/issues/2133
refs: https://github.com/wez/wezterm/issues/2351
2022-08-05 07:53:44 -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
ec46aba089 mux: prefer compressed Lines when syncing 2022-07-24 16:15:47 -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
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
69f1f1e7d5 deps: update to rcgen 0.9 2022-05-04 20:16:41 -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
b162f6f1e2 reduce log level of some diagnostics printed on startup 2022-04-09 22:19:22 -07:00
Wez Furlong
b70ca55bdb mux: suppress error messages when client disconnects 2022-04-06 22:23:42 -07:00
Wez Furlong
27d7666a8d downloader: restructure how we propagate to the gui
same deal as 210999b915 but for the
download handler.

The download handler doesn't work across the multiplexer today.
2022-03-31 20:06:43 -07:00
Wez Furlong
210999b915 clipboard: restructure how we capture OSC 52
Previously, we'd create a clipboard handler associated with a GUI window
and take care to pass that down to the underlying Pane whenever we
spawned a new pane.

For the mux server, instead of being associated with a GUI window, the
clipboard was a special RemoteClipboard that would send a PDU through
to the client that spawned the window.

The bug here was that when that client went away, the clipboard for
that window was broken.

If the mux server was the built-in mux in a gui process this could
leave a tab without working OSC 52 clipboard support.

This commit restructures things so that the Mux is responsible for
assigning a clipboard handler that rephrases the clipboard event
as a MuxNotification.

Both the GUI frontend and the mux server dispatcher already listen
for mux notifications and translate those events into appropriate
operations on the system clipboard or Pdus to send to the client(s).

refs: #1790
2022-03-31 09:55:51 -07:00
Wez Furlong
1a71a0b216 improve error logging for OSC 52 in mux
refs: #1790
2022-03-29 08:09:52 -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
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
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
bb174811fa Revert "mux: don't include unchanged lines in the bonus lines"
This reverts commit a189bb57c14ec2245f276a077fbe13a88622c1d7;
it turns out that we do need to send those bonus lines because
the sequence number available to the logic here doesn't account
for the actual last rendered sequence number on the client, and
in a bursty update situation we can skip or otherwise omit a
line range.

refs: #1597
2022-01-29 09:31:12 -07:00
Wez Furlong
6d288696c8 Add SwitchToWorkspace keyassignment action
This action causes the active workspace for the gui to change.

If the name is omitted a random name will be generated.
If the workspace doesn't exist, it will be be created.
The optional spawn parameter can be used to launch a specific
program into the new workspace; if omitted, the default prog
will be used.

The gui only supports a single active workspace. Switching workspaces
will repurpose existing gui windows and re-assign them to windows
in the new workspace, adjusting their size to fit those windows,
spawning new windows or closing unused windows as required.

The gui now exits when there are no panes in the active workspace,
rather than no panes at all.

refs: #1531
2022-01-15 13:53:34 -07:00
Wez Furlong
9a241509a4 mux: add current identity concept
The mux now has a notion of which client is actively doing things.
This allows, for example, newly spawned windows to take on the
active workspace for a given client.

The gui now assigns a client id on startup, and sets the active
workspace to `default`.

The mux server temporarily overrides the active id to that of
the currently dispatching client when processing PDUs.

refs: https://github.com/wez/wezterm/issues/1531
2022-01-15 06:25:11 -07:00
Wez Furlong
30a9692f9d refactor: centralize some more spawn logic 2022-01-14 22:28:35 -07:00
Wez Furlong
31c754f6e4 refactor: move split_pane logic from mux server to mux 2022-01-14 22:28:35 -07:00
Wez Furlong
1704af88ba refactor: move logic -> Mux::spawn_tab_or_window
Tidies up some code duplication within the mux protocol handler.
Move some of the logic into Mux, remove legacy Spawn Pdu to reduce
more duplication.

I want to dedup some of the similar logic that exists in the gui
spawn implementation as well in a follow up.
2022-01-14 22:28:35 -07:00
Wez Furlong
cefe45d206 Windows can be labelled with a workspace name
This is not exposed through any UX; the mux api allows setting
the workspace and propagating information about windows whose
workspace has changed.

Windows start with a blank workspace name.

This is just plumbing; nothing uses it yet.

refs: #1531
2022-01-12 16:47:08 -07:00
Wez Furlong
9b9bd0ae8c mux: track list of clients
Define a way to compute a client ID and pass that through to the
mux server when verifying version compatibility.

Once associated, the session handler will keep some metadata
updated in the mux.

A new cli subcommand exposes the info:

```
; ./target/debug/wezterm cli list-clients
USER HOST              PID CONNECTED  IDLE      WORKSPACE
wez  mba.localdomain 52979 30.009225s 1.009225s
```

refs: #1531
2022-01-11 22:43:26 -07:00
Wez Furlong
e40042e605 remove stray dbg! 2022-01-10 18:39:59 -07:00
Wez Furlong
1fd53d4a5d mux: propagate User Vars across to the client
user vars were stubbed out.  This commit adds storage for them
in the mux client and adds a new notification that publishes each
var as it is changed.  That differential stream is applied to the
storage in the mux client when it is received.

```lua
local wezterm = require 'wezterm'

wezterm.on("update-right-status", function(window, pane)
  local woot = pane:get_user_vars().woot
  window:set_right_status(tostring(woot))
end);

return {
  unix_domains = {
    {name="unix"},
  },
}
```

then running:

* `wezterm connect unix`
* in that session: `printf "\033]1337;SetUserVar=%s=%s\007" woot `echo -n nice | base64``

causes `nice` to show in the status area.

refs: #1528
2022-01-10 18:33:32 -07:00
Wez Furlong
3ae38eb5bf mux: synthesize PaletteChanged event when config is reloaded
This is slightly misusing or misattributing things, but in
the context of the problem at hand, it is OK.

The issue is that palette changes are normally signalled by
the terminal instance in response to escape sequences.  Those
changes are propagated to the mux client through the existing
alerting channel.

If the palette is changed implicitly via a config change, then
the terminal doesn't trigger that alert and the mux client(s)
don't know that they need to refresh the palette.

This commit tracks the last config generation per pane and
synthesizes a palette alert when it changes.

It might be better to have another variant of alert to indicate
config changes.

refs: #1526
2022-01-10 18:13:42 -07:00
Wez Furlong
a189bb57c1 mux: don't include unchanged lines in the bonus lines
This doesn't make a huge difference; I think we already addressed
the worst of the overhead with a combination of
eae327efcc
and the more recent commits to avoid over invalidation around
cursor movement and screen scrolling.

The numbers I see are a very small number of bytes per second when
scrolling through eg: vim and aren't crazy or alarming.

So I'm going to consider the related issue resolved!

closes: https://github.com/wez/wezterm/issues/867
2022-01-10 17:59:53 -07:00
Wez Furlong
aa648797ae Include executable path and config path in version info
Use that to decide if the running version is equivalent to the
newly spawning one when deciding if we can route a command to it
or spawn a new gui
2022-01-10 17:59:53 -07:00
Wez Furlong
37c83b8308 deps: update 2021-12-20 08:15:56 -07:00
Wez Furlong
dfad493266 unpin rcgen, update to 0.8.13
refs: https://github.com/est31/rcgen/issues/63
2021-08-23 09:07:53 -07:00
Wez Furlong
a7fa2fe0e1 pin rcgen to 0.8.11
0.8.12 breaks the API by removing Send+Sync from Certificate;
pin until that is resolved.

refs: https://github.com/est31/rcgen/issues/63
2021-08-23 07:45:35 -07:00
Wez Furlong
3ec6041b0f mux: use tab size when spawning a new tab
Rather than using the configured initial window size, use the
size of the current tab to size the newly spawned tab.

refs: https://github.com/wez/wezterm/issues/920
2021-08-14 18:31:23 -07:00
Wez Furlong
eae327efcc model: replace LineBits::DIRTY with a sequence number
Terminal now maintains a sequence number that increments
for each Action that is applied to it.

Changes to lines are tagged with the current sequence number.

This makes it a bit easier to reason about when an individual
line has changed relative to some point in "time"; the consumer
of the terminal can sample the current sequence number and then
can later determine which lines have changed since that point
in time.

refs: https://github.com/wez/wezterm/issues/867
2021-08-08 12:45:08 -07:00
Wez Furlong
1f5b900f3d plumb appearance change event -> reload on macos
This commit causes a window-config-reloaded event to trigger
when the appearance (dark/light mode) is changed on macos.

It also arranges to propagate the window level config to newly
spawned panes and tabs, created both via the gui and via the
CLI/mux interface.

refs: https://github.com/wez/wezterm/issues/894
refs: https://github.com/wez/wezterm/issues/806
2021-07-18 00:01:53 -07:00
Wez Furlong
020c0991e4 cleanup: remove term::Clipboard::get_contents method
This dates back to long ago, and is never called.
Remove it, and cleanup some state associated with it.
2021-07-17 07:38:48 -07:00
Wez Furlong
1a44255529 mux client: connect all mux panes in window to clipboard when attaching
refs: https://github.com/wez/wezterm/issues/836
2021-05-31 08:40:19 -07:00
Wez Furlong
5359f39dcf mux: fix an issue where auth window would linger before closing
Same vein as 8931afba5cee07ab12990f06c2ff34d6f8426b19; the auth
window could sometimes get stuck until an input event was sent
to it.

Wire up a mux event so that the window can close itself.
2021-05-31 00:11:47 -07:00
Wez Furlong
dc4c8f07dd mux protocol sending alerts to client
refs: https://github.com/wez/wezterm/issues/748
refs: https://github.com/wez/wezterm/issues/489
2021-05-30 10:18:30 -07:00
Wez Furlong
a652896418 fix OSC 52 not working in multiplexer
closes: https://github.com/wez/wezterm/issues/764
2021-05-30 07:40:00 -07:00