1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-24 07:46:59 +03:00
Commit Graph

169 Commits

Author SHA1 Message Date
Wez Furlong
e575bc9ff9 simplify window reconciliation logic
refs: https://github.com/wez/wezterm/issues/1531
2022-01-16 09:50:16 -07:00
Wez Furlong
76a213f7ab Gui switches to a different workspace when current workspace is emptied
Rather than just quitting the app and potentially silently killing off
a number of panes that might be running in other workspaces, we now
will pick one of those workspaces and activate it.

refs: #1531
2022-01-15 14:41:19 -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
626a022dd5 mux: function to list workspaces and generate a new name
refs: #1531
2022-01-15 08:46:21 -07:00
Wez Furlong
324815b625 mux: update last input time for local pane actions
This commit updates the last input time for the active client
id when calling into local pane.  That time is visible in the
`wezterm cli list-clients` output.
2022-01-15 07:03:20 -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
170bb31f4f refactor: move more spawn logic into new mux methods 2022-01-14 22:28:35 -07:00
Wez Furlong
30a9692f9d refactor: centralize some more spawn logic 2022-01-14 22:28:35 -07:00
Wez Furlong
e0fe1e7f04 mux: factor out common SpawnTabDomain resolution 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
1bc5c5a663 refactor: common spawn bits into Domain::spawn_pane
This a step towards decoupling split_pane from Domain.

refs: #1531
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
f48e2d9a85 SshDomain: assume_unix -> assume_shell = "Posix" 2022-01-10 08:27:09 -07:00
Wez Furlong
1357480ce6 SshDomain: add assume_unix option; enables setting cwd for new panes
If we know that the remote host is a unix system, and that it uses some
version of the posix shell, then we can adjust our command line to cd to
the requested directory (as set by OSC 7) and then exec the requested
command.

That's what SshDomain::assume_unix indicates and what this commit does.
2022-01-09 21:32:09 -07:00
Wez Furlong
b3987bec12 ssh: allow setting default_prog for SshDomain when multiplexing=None
```
return {
  ssh_domains = {
    {
      name = "woot",
      remote_address = "192.168.1.8",
      multiplexing = "None",
      default_prog = {"fish"},
    }
  },

  default_domain = "woot",
}
```

refs: https://github.com/wez/wezterm/issues/1456
2022-01-09 20:09:53 -07:00
Wez Furlong
a045cfe092 standardize on SshDomain as the way to configure RemoteSshDomain
refs: https://github.com/wez/wezterm/issues/1456
2022-01-09 19:45:11 -07:00
Wez Furlong
f84c0632d8 gui: allow wezterm connect sshdomnomux
If an ssh domain is set to use_multiplexer=false, it is now
possible to `wezterm connect` to it.

Previously, it was only possible to connect to domains that
used the mux client.

refs: https://github.com/wez/wezterm/issues/1456
2022-01-09 15:52:40 -07:00
Wez Furlong
328aaaefd2 mux: ssh: RemoteSshDomain: defer session creation until spawn time
refs: #1456
2022-01-09 13:04:15 -07:00
Wez Furlong
3e99390299 LocalDomain: don't use global default_prog/default_cwd for WslDomains
They have their own versions of these options, and logically it doesn't
make sense to use the default_prog from the `local` domain with a wsl
domain.

refs: #1242
2022-01-08 16:07:22 -07:00
Wez Furlong
0e9924e585 new: WslDomain, a variant on the local domain
The idea is that we want to be able to spawn into wsl with the
convenience of a local domain, but without the awkwardness of
it having a different filesystem namespace.

It would also be great to be able to spawn a new tab or pane
in the same domain and pick up the cwd of the existing one.

The WslDomain allows the user to explicitly list WslDomains
and control eg: default shell, username and so on, but wezterm
will pre-fill a default list of domains based on the `wsl -l`
output that we were already using in the launcher menu.

The existing LocalDomain has been augmented to understand that
it may need to fixup a command invocation and that gives it
the opportunity to rewrite the command so that we can launch
it via `wsl.exe` and pass down the cwd and so on.

This same technique might be extensible to eg: docker instances
in the future.

This commit:

* Introduces `wsl_domains` config and its default list of wsl
  distributions
* Creates LocalDomain instances from that list
* The launcher menu allows spawning a new tab via one of those domains
2022-01-08 15:05:05 -07:00
Wez Furlong
4524abcdba gui: revise win32-input-mode flow
We need 100% of the info for it to work correctly, so this commit:

* Exposes the keyboard encoding mode via the Pane trait
* Adds the scan code to the RawKeyEvent
* Has the GUI perform the encoding if the keyboard is set that way
* Removes the basic encoder from termwiz in favor of the gui level one

The net result is that we bypass the Pane::key_up/Pane::key_down methods
in almost all cases when the encoding mode is set to win32-input-mode.

There is now a config option: allow_win32_input_mode that can be
used to prevent using this mode.

refs: #1509
2022-01-07 13:02:09 -07:00
Wez Furlong
763c4d7f7e term: reintroduce possibility of key_up events
Nothing generates them right now, and the mux client has no
way to represent them on the wire.

I'm considering constraining them to just win32 for now.

refs: https://github.com/wez/wezterm/issues/1509
2022-01-06 09:45:51 -07:00
Wez Furlong
09a705b78f mux: fix unix build 2022-01-01 11:38:42 -07:00
Wez Furlong
5660942055 procinfo: add windows console field. mux: ignore non-console procs
When considering the fg process, we don't want a newly spawned
notepad.exe to show as the fg process in a cmd/pwsh pane, as it
runs async from the console and isn't attached to it.

We can extract the console handle from the process information and
use a 0 value handle to indicate win32 apps that are not attached
to any console.

We cannot compare console handle values directly: without probing
deeper into the handle we don't know that two differently valued
handles refer to different consoles, because a handle can be
duplicated into another with a different numeric value.
2022-01-01 09:40:18 -07:00
Wez Furlong
eac630003c mux: restore caching of proc tree on windows 2021-12-31 22:19:45 -07:00
Wez Furlong
3e05ee667f procinfo: fix linux build 2021-12-31 21:31:28 -07:00
Wez Furlong
1ad4015f9c procinfo: reorg a bit; enable cwd probing on windows
Likely breaks the mac and windows builds
2021-12-31 21:28:03 -07:00
Wez Furlong
6650879260 move platform logic about LocalProcessInfo into procinfo crate 2021-12-31 19:45:09 -07:00
Wez Furlong
416c700841 procinfo: start_time is now in unspecified units since boot 2021-12-31 19:39:37 -07:00
Wez Furlong
910b111efa move procinfo bits into own crate 2021-12-31 19:31:21 -07:00
Wez Furlong
2aa491af1a mux: remove dep on sysinfo; we now do our own win32 stuff
This also removes the sysinfo cache; will replace it with
something else in a follow up commit.
2021-12-31 19:21:45 -07:00
Wez Furlong
2b38c3dd32 mux: macos: add missing status and comm/name fields to procinfo 2021-12-31 16:25:03 -07:00
Wez Furlong
259c78d514 mux: remove sysinfo dep on linux 2021-12-31 16:16:04 -07:00
Wez Furlong
3eb5408135 mux: use linux specific impl for get_foreground_process_name 2021-12-31 15:21:45 -07:00
Wez Furlong
efbcdc860e mux: remove sysinfo dep on macos
We can get just the targeted information we need a bit more robustly
and cheaply.
2021-12-31 14:54:03 -07:00
Wez Furlong
80d16574e3 mux: refactor sysinfo. Use own fn for macos foreground process path
I noticed that sysinfo failed to yield info about 50% of the time on
macos!

Just go direct to the underlying system function; we don't need all
of the info that sysinfo collects in any case.
2021-12-31 11:30:10 -07:00
Wez Furlong
09e8d7b92f mux: proc_pidinfo is now available in libc on macos
So we don't need our own copy of the ffi bits here
2021-12-31 11:09:43 -07:00
Wez Furlong
e225589b05 mux: improve process name cache and fg proc name on windows
Reduce the cache lifetime a bit, and resolve a potential
racy/non-deterministic result due to the timestamp granularity.
2021-12-30 17:17:28 -07:00
Wez Furlong
5608e9477b termwiz: make seqno a required param for Line
Previously, we would implicitly set it to the special SEQ_ZERO
value, but since that value always flags the row as changed,
it causes some over-invalidation issues downstream in wezterm.

This commit makes that parameter required, so that the code that
is creating a new Line always passes down the seqno from that event.

refs: #1472
2021-12-29 08:34:59 -07:00
Wez Furlong
910ad5edb7 mux: add cache around sysinfo
This limits sysinfo process info updates to once per second,
which should help keep tab titles snappier.
2021-12-25 23:15:08 -07:00
Wez Furlong
a0cbea2703 term: ignore first OSC title change sequence on Windows
ConPTY emits a sequence that sets the title to the name of the
program that is initially launched into it.

This commit tries to ignore that sequence in that circumstance,
so that the logic in b5d156c282
can more dynamically set the tab title.
2021-12-25 01:10:37 -07:00
Wez Furlong
b5d156c282 mux: use pgrp leader basename as default pane title
If the pane title is the default `wezterm`, then return the
process basename instead.  This makes the tab titles more useful
by default, although on Windows, conpty will set the title
to the initial executable path and defeat this.
2021-12-25 00:14:31 -07:00
Wez Furlong
6c1710f87d mux: remove ProgDomain; just pass down default prog/cwd as appropriate
This allows making these values configurable per-domain in the
future.

refs: #1456
2021-12-24 07:52:02 -07:00
Wez Furlong
a38757ef3b mux: improve process leader heuristics on windows
refs: #1417
2021-12-24 07:21:00 -07:00
Wez Furlong
bd6072b320 avoid default_prog, default_cwd when spawning panes via ssh
refs: https://github.com/wez/wezterm/issues/1456
2021-12-23 23:24:42 -07:00
Wez Furlong
225d15c9aa ActivatePaneDirection now supports Next and Prev
This allows cycling through all the panes in a tab

refs: #976
2021-12-23 21:00:26 -07:00
Wez Furlong
1d064e0913 Add get_foreground_process_name, expose it and cwd in PaneInformation
Add `get_foreground_process_name` to both Pane and the lua wrapper.

Add `foreground_process_name` and `current_working_dir` fields to
`PaneInformation`.  In order for those to be dynamically fetched,
switch the lua conversion for `PaneInformation` to be a UserData
with field access methods.  It's a little more verbose but allows
us to lazily compute these two new fields.

refs: https://github.com/wez/wezterm/discussions/1421
refs: https://github.com/wez/wezterm/issues/915
refs: https://github.com/wez/wezterm/issues/876
2021-12-23 18:49:17 -07:00
Wez Furlong
5c222cfcdc term: allow iterm2 file transfer protocol
Adds some plumbing to allow the GUI to implement a download handler
and connect that up for iterm2 image/file transfers that have their
inline property set to false.

Previously we'd just log an error.

Now we will by default download the file to the user's download
directory.

This behavior can be turned off via the new `allow_download_protocols`
configuration setting.

File transfers can be initiated on a remote host via the
https://iterm2.com/utilities/it2dl script.

When the download completes, a toast notification is shown that will
open the file when clicked.

refs: https://github.com/wez/wezterm/discussions/1450
2021-12-22 09:21:39 -07:00