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

1204 Commits

Author SHA1 Message Date
Wez Furlong
d60cdbf74e
palette: show key assignment alongside entries
For items in the main set of key assignments, show the keyboard
shortcut to the right.

Some items have multiple key assignments; we show only the first
one. We'll probably want to be a bit smarter. For instance,
both linux and windows tend to occupy the Windows/Super key
assignments, so we should probably prioritize showing the Ctrl+Shift
variants on those platforms.

refs: https://github.com/wez/wezterm/issues/3335
2023-03-24 23:34:49 -07:00
Wez Furlong
499e5f73d0
palette: show the label from the command in the palette
Given an assignment like this:

```
{
  key = "b",
  mods = "ALT",
  action = wezterm.action.SplitPane {
    direction = 'Right',
    command = {
      label = 'Bash Right',
      args = {'/usr/bin/bash' }
    }
  }
}
```

we should show the label from the command in the palette.
That's what this commit enables.

If there is no label, but the arguments are set, then the
arguments will be shown instead.

refs: #3252
2023-03-24 21:05:14 -07:00
Wez Furlong
604ef152be
add wezterm cli activate-pane, wezterm cli activate-tab
refs: #3352
refs: https://github.com/wez/wezterm/issues/886
2023-03-24 17:32:55 -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
2e488d57c7
update terminfo to 0.8 2023-03-24 10:12:49 -07:00
Wez Furlong
bc7acc18e0
fixup images with the multiplexer
* Translate from File to EncodedFile as needed
* Adopt blob leases in the mux server
* Fix an issue where the first image sent by the mux server would
  be replaced on the client by its background image, if configured.
  Removed the ImageData::id field to resolve this: you should use
  the hash field instead to identify and disambiguate images.
  Bumped the termwiz API version because this is conceptually
  a breaking change to the API

refs: https://github.com/wez/wezterm/issues/3343
2023-03-23 21:43:28 -07:00
Wez Furlong
57a1b7f2ef
factor window border sizes when computing window sizes
This one was a bit weird because something appeared to be a bit
non-deterministic.  With this config:

```lua
local wezterm = require 'wezterm'

return {
  window_frame = {
    border_left_width = '1cell',
    border_right_width = '1cell',
    border_bottom_height = '0.5cell',
    border_top_height = '0.5cell',

    border_left_color = '#444',
    border_right_color = '#444',
    border_bottom_color = '#444',
    border_top_color = '#444',
  },

  window_padding = {
    left = '1.5cell',
    right = '1.5cell',
    top = '0.5cell',
    bottom = '0.5cell',
  },
}
```

starting wezterm could result in a terminal that reported either 23 or
24 lines. I got 24 when running the build from da7e29df but usually
23 when running a build out of my repo.

Looking closely, the issue is that the initial window size didn't
account for the configured border size, and that we'd subsequently
fix that up when we later do a resize fixup after creating the window.

This commit refactors the window border logic so that it can be
used prior to having fully constructed the terminal window and then
uses that to fixup the initial computed dimensions.

I also noticed with this config that increasing the font size
with CTRL-+ could also result in an inconsistency between the displayed
terminal size and the pty size we set in the kernel: it was missing
the border adjustment as well, so I added it in there.

refs: #3333
2023-03-23 07:11:07 -07:00
Wez Furlong
1a32908beb
fix lua string escaping in wezterm show-keys
We didn't render stuff like this correctly:

```
{ key = "{", mods = "SHIFT|CMD", action = wezterm.action.SendString("\2p") },
```

refs: https://github.com/wez/wezterm/issues/3326
2023-03-22 18:49:47 -07:00
Wez Furlong
b384dc999f
fix delegation of --skip-config to wezterm-gui
refs: #3325
2023-03-22 07:24:02 -07:00
eaglgenes101
4ee16328b8 Changed config option name to mouse_wheel_scrolls_tabs, made it default to true (matching current behavior) 2023-03-21 22:09:14 -07:00
eaglgenes101
8308887d21 Add config option for scrolling the tab bar 2023-03-21 22:09:14 -07:00
Wez Furlong
0b83c97427
keys: avoid scrolling to bottom when CapsLock is pressed
refs: https://github.com/wez/wezterm/issues/3306
2023-03-21 09:17:24 -07:00
Wez Furlong
001a49be4c
minor optimization for single-frame animated formats
Use 1-day duration for the single frame when an animated
format yields only a single frame.
2023-03-20 10:14:17 -07:00
Wez Furlong
829e5c15cf
fix potential deadlock when using wezterm cli split-pane
refs: #1818
2023-03-20 07:44:13 -07:00
Wez Furlong
f5ba73a1a2
add own open_url crate
The upstream open crate keeps making stuff async/blocking/not-working on
windows, so this is a step towards removing this dependency.

refs: https://github.com/wez/wezterm/issues/3288
2023-03-19 12:44:12 -07:00
Wez Furlong
7a6dce3ff0
fix hover state for retro tab bar
Make the math consistent between the hover logic and the render
logic.

refs: https://github.com/wez/wezterm/issues/3113
2023-03-19 09:09:54 -07:00
Wez Furlong
4d471807c3
mouse: don't over invalidate when hovering tabs
refs: #3276
2023-03-19 06:35:17 -07:00
Wez Furlong
4466997b88
clean up blob storage on shutdown
The static OnceCell didn't run destructors, so shift to something
where we can explicitly trigger them to run and clean up the
temporary directory area.
2023-03-18 22:19:46 -07:00
Wez Furlong
344a41f944
use blob leases for decoded animation frames
This allows the decoder thread to live only long enough
to decode the full set of frames; we can then store the
leases in memory and pull them in only when there is
a cache miss.

refs: https://github.com/wez/wezterm/issues/3263
2023-03-18 21:55:57 -07:00
Wez Furlong
7cd0cc21bf
ImageDataType::File -> EncodedLease
Adopt the new blob lease layer to storing and referencing
image files.

This reduces the number of open files needed when
images are being displayed in the terminal.

refs: https://github.com/wez/wezterm/issues/3263
2023-03-18 20:32:49 -07:00
Wez Furlong
203bd10d8e
handle unsupported images better 2023-03-17 13:52:43 -07:00
Wez Furlong
e090eb9eae
Image decoding is now done in a bg thread
Continuing from the previous commit, this shifts:

* In-memory data -> temporary file
* Image decoding -> background thread

The background thread asynchronously decodes frames and
sends them to the render thread via a bounded channel.

While decoding frames, it writes them, uncompressed, to
a scratch file so that when the animation loops, it is
a very cheap operation to rewind and pull that data
from the file, without having to burn CPU to re-decode
the data from the start.

Memory usage is bounded to 4 uncompressed frames while
decoding, then 3 uncompressed frames (triple buffered)
while looping over the rest.

However, disk usage is N uncompressed frames.

refs: https://github.com/wez/wezterm/issues/3263
2023-03-17 11:41:20 -07:00
Wez Furlong
aa929a1a9b
move animation decoding from term layer to gui layer
This makes decoding animation frames a lazy operation, but it
comes at the cost of needing to re-decode the image from scratch
when it loops, because the image crate doesn't provide a way
to rewind its frame iterator.

That initial decode can have a significant time cost; a small
webp file consistently takes 150ms to decode, which is too
much to do inline in the render thread.

Next steps will be to move that cost off the render thread.
2023-03-17 11:41:20 -07:00
Wez Furlong
c093b8861a
rustfmt 2023-03-16 18:13:30 -07:00
Wez Furlong
c2cf376d8f
fix DisableDefaultAssignment not working for CTRL|SHIFT P
refs: https://github.com/wez/wezterm/issues/3262
2023-03-16 18:08:37 -07:00
Wez Furlong
88e53a5f11
apply reloaded config to all panes, regardless of zoom state
refs: https://github.com/wez/wezterm/issues/3259
2023-03-16 09:31:32 -07:00
Wez Furlong
4576f46828
Set minimum animation frame duration to match max_fps
In #3260, the candidate animation had a frame delay of 1ms.  That is
problematic because there is no hope for wezterm running at 60fps (a
frame delay of ~16ms) to render that without dropping frames.

A consequence of such a short frame delay, coupled with the way that
images are carved up into cells, is that individual cells can easily
become visibled de-synchronized from their neighbors and results in what
looks like mpeg artifacts but are really regions where the cells are a
few frames ahead/behind their neighbors.

The solution is to clamp the frame duration up to match the minimum
displayable frame duration as governed by max_fps.

refs: https://github.com/wez/wezterm/issues/3260
2023-03-16 09:06:59 -07:00
Wez Furlong
2bfb29f1be
improve handling of animated webp images
Use mainline image crate to avoid an otherwise unavoidable panic
in the upstream: https://github.com/image-rs/image/issues/1775

Explicitly operate on the frames from the animation.

refs: https://github.com/wez/wezterm/issues/3250
2023-03-15 11:34:47 -07:00
Wez Furlong
4b2973a9d4
deps: open -> 4.0 2023-03-12 20:37:58 -07:00
Wez Furlong
73f50efb7f
ls-fonts: emulate the effect of normalize_output_to_unicode_nfc
This aids in debugging:

```
; wezterm --config normalize_output_to_unicode_nfc=false ls-fonts --text $(echo a$'\u301\u302')
LeftToRight
 0                   x_adv=8  cells=1  glyph=aacute,190  wezterm.font("JetBrains Mono", {weight="Regular", stretch="Normal", style="Normal"})
                                      /usr/share/fonts/jetbrains-mono-fonts/JetBrainsMono-Regular.otf, FontConfig
 0 á̂  \u{61}\u{301}\u{302} x_adv=0  cells=0  glyph=uni0302,1646 wezterm.font("JetBrains Mono", {weight="Regular", stretch="Normal", style="Normal"})
                                      /usr/share/fonts/jetbrains-mono-fonts/JetBrainsMono-Regular.otf, FontConfig
```

```
; ./target/debug/wezterm --config normalize_output_to_unicode_nfc=true ls-fonts --text $(echo a$'\u301\u302')
LeftToRight
 0                   x_adv=8  cells=1  glyph=aacute,190  wezterm.font("JetBrains Mono", {weight="Regular", stretch="Normal", style="Normal"})
                                      /usr/share/fonts/jetbrains-mono-fonts/JetBrainsMono-Regular.otf, FontConfig
 0 á̂   \u{e1}\u{302} x_adv=0  cells=0  glyph=uni0302,1646 wezterm.font("JetBrains Mono", {weight="Regular", stretch="Normal", style="Normal"})
                                      /usr/share/fonts/jetbrains-mono-fonts/JetBrainsMono-Regular.otf, FontConfig
```

refs: #3093
2023-02-11 08:15:08 -07:00
Wez Furlong
51e0c1b393
x11/wayland: restore mouse copying to both clipboard and primary selection
I don't recall changing it to copy to the primary selection only, and
it doesn't feel like it is something I would want anyway, and I think
it generally makes things annoying for all but power users

https://fosstodon.org/@trentskunk@mstdn.social/109808345817367266
2023-02-09 12:56:51 -07:00
Antoine Busch
70d2829b79 palette: add CTRL-p / CTRL-n key bindings to move up/down 2023-02-08 07:13:18 -08:00
Wez Furlong
e5e5ce610e
palette: add full doc and enum name to text to match
refs: https://github.com/wez/wezterm/issues/1485
2023-02-07 15:41:37 -07:00
Wez Furlong
d2905d53b1
defer loading background until after rescaling in config reload
render metrics might be adjusted by the scaling logic, so we
should load the background after resizing.
2023-02-07 09:32:08 -07:00
Wez Furlong
f031acfe43
wgpu: ensure that the srgb format is available before using it
refs: https://github.com/wez/wezterm/issues/3032
2023-02-06 07:40:30 -07:00
Wez Furlong
9945c04e8f
fixup test for nerd font symbol update 2023-02-06 07:23:59 -07:00
Wez Furlong
74dc74b7c8
deps: wgpu -> 0.15
This might help with https://github.com/wez/wezterm/issues/3032
2023-02-06 07:19: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
d2fd2c6b1a
remove some debug prints
These are no longer needed
2023-02-05 18:00:22 -07:00
Wez Furlong
6968ad5c3c
Add quit_when_all_windows_are_closed config option
refs: https://github.com/wez/wezterm/issues/3057
2023-02-05 16:55:56 -07:00
Italo Cunha
09e82b353a
Add bindings for Home and End in copy_mode (#2762)
* Add bindings for Home and End in copy_mode

* Add Home/End bindings to copymode.md

---------

Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2023-02-05 09:20:01 -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
9e3a5ba8fa
cargo fmt 2023-02-05 07:58:31 -07:00
Wez Furlong
d336c8a61e
deps: http_req -> 0.9 2023-02-05 07:38:55 -07:00
gzliew
20c8135fc5 fix(wezterm-gui): Move word able to jump next line 2023-02-05 06:33:57 -08:00
Wez Furlong
691ec187ba
macos: don't include LEADER based key assignments in menubar
refs: https://github.com/wez/wezterm/issues/3021
2023-01-27 15:52:54 -07:00
Wez Furlong
d7145561c2
Add wezterm start --domain DOMAIN --attach + gui-attached event
The motivation here was to remove some similar but not quite the same
logic that existed for starting up when using `wezterm connect`.

Now `wezterm connect DOMAIN` is implemented as `wezterm start --domain
DOMAIN --attach --always-new-process` and a little extra hand-wave to
ensure that the default domain is set correctly.

The startup events have been refactored a bit; a new gui-attached
event is emitted after attaching and starting any default programs
in the selected domain at startup.

That event can be used to maximize windows and so on, if desired.

The gui-attached event is independent of the startup command and fires
for `wezterm connect`, which `gui-startup` did not (and could not) do.
2023-01-26 15:56:11 -07:00
Wez Furlong
6f62a0f2b1
config: capture warnings and show them in config error window
This allows deprecated and invalid fields to be surfaced more visibly
in the config error window.
2023-01-24 14:18:15 -07:00
Wez Furlong
33f25e9ce6
reduce latency when heavily using foreground process info
The tcgetpgrp call appears to have high variance in latency, ranging
from 200-700us on my system.

If you have 10 tabs and mouse over the tab bar, that's around 7ms
spent per frame just figuring out the foreground process; that doesn't
include actually extracting the process executable or current working
directory paths.

This was exacerbated by the mouse move events triggering a tab bar
recompute on every pixel of mouse movement.

This commit takes the following steps to resolve this:

* We now only re-compute the tab bar when the UI item is changed by
  a mouse movement
* A simple single-item cache is now used on unix that allows the caller
  to proceed quickly with stale-but-probably-still-mostly-accurate data
  while queuing up an update to a background thread which can absorb
  the latency.

The result of this is that hovering over several tabs in quick
succession no longer takes a noticeable length of time to render the
hover, but the consequence is that the contents of a given tab may be
stale by 300-400ms.

I think that trade-off is worth while.

We already have a similar trade-off on Windows, although we don't
yet do the updates in a different thread on Windows. Perhaps in
a follow up commit?

refs: https://github.com/wez/wezterm/issues/2991
2023-01-21 15:25:57 -07:00