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

1090 Commits

Author SHA1 Message Date
Wez Furlong
112feb3374 add MuxTab:set_zoomed and SetPaneZoomState keyassignment
refs: #2284
2022-07-19 05:52:38 -07:00
Wez Furlong
1c32ac95bf cargo update
and address deprecation warnings for csscolorparser
2022-07-17 21:14:47 -07:00
Wez Furlong
ec65b64f30 lua: add tostring impls for window, tab and pane objects 2022-07-16 08:22:10 -07:00
Wez Furlong
910879642f retro tab bar: use resolved palette for colors
This allows tab bar colors to be defined in the toml file and
take effect on the fancy tab bar!

an example can be found at: https://github.com/catppuccin/wezterm/blob/main/dist/catppuccin-frappe.toml

refs: https://github.com/catppuccin/wezterm/issues/6
2022-07-16 06:20:26 -07:00
Wez Furlong
2450fed071 fix padding to the right of retro tab bar
refs: https://github.com/wez/wezterm/issues/2210
2022-07-15 18:40:43 -07:00
Wez Furlong
e277183cb9 overlays: handle resize better
We need to actually tell them that the pane has been resized
so now we do.
2022-07-15 16:32:26 -07:00
Wez Furlong
dba7932e3e add wezterm.gui.get_appearance to retrieve dark mode
This simplifies the "change scheme based on dark mode" example
a lot.  This was previously impossible to do because we didn't
have a lua module associated with the gui until recently, so
the only way to reference a gui-related object was via an
event callback.

refs: https://github.com/wez/wezterm/issues/2258
2022-07-14 16:46:18 -07:00
Wez Furlong
49ab340a92 debug overlay: remember last log line globally
It can be confusing to see the same log lines when re-opening
the debug overlay, so this commit remembers the last line
in a global to make that feel more natural.

Because that causes the initial `OpenGL Initialized!` log to
show only in the first instance of the overlay, that log line
is now changed to debug level and the overlay will now
explicitly log the version information, along with some
brief usage text:

```
Debug Overlay
wezterm version: 20220714-001416-810512c2
OpenGL version: AMD BEIGE_GOBY (LLVM 14.0.0, DRM 3.46, 5.18.10-200.fc36.x86_64) 4.6 (Compatibility Profile) Mesa 22.1.3
Enter lua statements or expressions and hit Enter.
Press ESC or CTRL-D to exit
```
2022-07-14 06:53:41 -07:00
Funami580
cfa95db0cc lua: add pane:is_alt_screen_active() 2022-07-12 17:06:16 -07:00
Wez Furlong
179ec9faaf wezterm.mux.set_active_workspace now updates the gui
Attach the mux events to the frontend workspace reconciliation function
so that the window is updated to match the new workspace.

Ensure that we correctly clear out any overlay panes as part of the
switch: we need to remove them from the mux so that the mux will
correctly identify that the mux is empty when the main panes from
the workspace are closed.  The problem case was that the debug overlay
state was forgotten by the gui when activating the new workspace, but
we didn't tell the mux to kill it off, so subsequently CTRL-D'ing
the windows closed the windows but left the wezterm process running with
no head.

refs: #2248
2022-07-12 09:15:38 -07:00
Wez Furlong
79d2f8197b quickselect: select bottom-most match
We don't really know which of the on-screen matches the user was
looking at when they selected the text, but assume that the one
nearest the bottom of the viewport is the one they want to select,
rather than the one closest to the top.

refs: https://github.com/wez/wezterm/issues/2250
2022-07-12 08:17:14 -07:00
Wez Furlong
8e9546fb04 repl: suppress "nil" results
When evaluating an assignment expression like `foo = "bar"` the result
of the expression is nil and we'd print nil on the next line,
which often startles me as I'm used to other languages where the
result of such an expression is the rvalue that was just assigned.

Let's just suppress nil when it is the result of an evaluation
in the repl for a cleaner look.
2022-07-12 07:45:08 -07:00
Wez Furlong
870ffdf59a ensure that we spawn open calls on a background thread
Otherwise we can block the gui waiting for eg: a freshly opened firefox to
terminate.

See also comment worrying about this in
75066cb522.
That fear was realized but now resolved!

refs: https://github.com/wez/wezterm/issues/2245
2022-07-11 08:03:37 -07:00
Wez Furlong
7a5440694d add distro-defaults feature
The intent is that when set, it changes defaults to something
more suitable for distributions.

I've also added a readme for distro maintainers.

refs: https://github.com/wez/wezterm/issues/1795
2022-07-10 16:34:43 -07:00
Wez Furlong
af5938d414 gui: fix padding color when there are splits
refs: https://github.com/wez/wezterm/issues/2210
2022-07-09 14:53:21 -07:00
Wez Furlong
39e727db58 tab bar: invalidate on resize to avoid gaps on the RHS 2022-07-09 10:45:43 -07:00
Wez Furlong
5913783d1e wayland: fix transparent gap under tab bar
Not sure why this only really showed up with Wayland, because the
issue was that the computed tab bar height ended up being 1 or 2
pixels shorter than the area we had allotted.

This commit resolves it by forcing the height to match, and
then aligning the content to the bottom of that region to avoid
having an undesirable line under the tab.

refs: #1256
2022-07-09 10:29:46 -07:00
Wez Furlong
520a8e306f invalid tab bar on scaling changes
refs: #2208
2022-07-09 07:17:03 -07:00
Wez Furlong
61f01f6ed7 allow parsing attributes from launcher labels 2022-07-08 19:28:33 -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
d78cc6edb8 new: exec_domains
An ExecDomain is a variation on WslDomain with the key difference
being that you can control how to map the command that would be
executed.

The idea is that the user can define eg: a domain for a docker
container, or a domain that chooses to run every command in its
own cgroup.

The example below shows a really crappy implementation as a
demonstration:

```
local wezterm = require 'wezterm'

return {
  exec_domains = {
    -- Commands executed in the woot domain have "WOOT" echoed
    -- first and are then run via bash.
    -- `cmd` is a SpawnCommand
    wezterm.exec_domain("woot", function(cmd)
      if cmd.args then
        cmd.args = {
          "bash",
          "-c",
          "echo WOOT && " .. wezterm.shell_join_args(cmd.args)
        }
      end
      -- you must return the SpawnCommand that will be run
      return cmd
    end),
  },
  default_domain = "woot",
}
```

This commit unfortunately does more than should go into a single
commit, but I'm a bit too lazy to wrangle splitting it up.

* Reverts the nil/null stuff from #2177 and makes the
  `ExtendSelectionToMouseCursor` parameter mandatory to dodge
  a whole load of urgh around nil in table values. That is
  necessary because SpawnCommand uses optional fields and the
  userdata proxy was making that a PITA.
* Adds some shell quoting helper functions
* Adds ExecDomain itself, which is really just a way to
  to run a callback to fixup the command that will be run.
  That command is converted to a SpawnCommand for the callback
  to process in lua and return an adjusted version of it,
  then converted back to a command builder for execution.

refs: https://github.com/wez/wezterm/issues/1776
2022-07-07 16:38:14 -07:00
Wez Furlong
dbc2c85361 add window:toggle_fullscreen()
You can start a window in full screen mode using something like:

```lua
local wezterm = require 'wezterm'

local mux = wezterm.mux

wezterm.on("gui-startup", function()
  local tab, pane, window = mux.spawn_window{}
  window:gui_window():toggle_fullscreen()
end)

return {
}
```

refs: #177
refs: #284
2022-07-06 23:57:32 -07:00
Wez Furlong
8853df02ca lua: add window:maximize() and window:restore() methods
Implemented on macOS only for the moment.

refs: https://github.com/wez/wezterm/issues/284
2022-07-06 23:11:02 -07:00
Wez Furlong
533e52c589 lua: make gui_window() reconcile workspace
reconciling causes gui windows to be created and allows for stuff like
this, that would otherwise fail because the gui window hadn't been
created yet.

```lua
local wezterm = require 'wezterm'

local mux = wezterm.mux

wezterm.on("gui-startup", function()
  local tab, pane, window = mux.spawn_window{}
  window:gui_window():set_inner_size(1200, 1200)
end)

return {
}
```
2022-07-06 18:52:14 -07:00
Wez Furlong
3e01d44ece add window:set_position window:set_inner_size 2022-07-06 18:49:39 -07:00
Wez Furlong
87ce88b924 lua: add wezterm.gui.gui_window_for_mux_window()
This is the inverse of wezterm.mux.get_window()
2022-07-06 15:39:43 -07:00
Wez Furlong
a6cf13e1e2 lua: add wezterm.window.screens()
Currently implemented on X11 only, this function returns information
about the geometry of the screen(s).

This is taken from the same source of information we use for the
`--position` CLI argument to `wezterm start`.

```
> wezterm.window.screens()
{
    "by_name": {
        "DisplayPort-1": {
            "height": 2160,
            "name": "DisplayPort-1",
            "width": 3840,
            "x": 0,
            "y": 0,
        },
    },
    "main": {
        "height": 2160,
        "name": "DisplayPort-1",
        "width": 3840,
        "x": 0,
        "y": 0,
    },
    "origin_x": 0,
    "origin_y": 0,
    "virtual_height": 2160,
    "virtual_width": 3840,
}
```
2022-07-06 08:35:05 -07:00
Wez Furlong
082c61c2c3 ensure that we reset attributes to defaults when producing escapes
refs: https://github.com/wez/wezterm/issues/2223
2022-07-06 07:21:08 -07:00
Wez Furlong
00fb0c58f3 Add window:get_selection_escapes_for_pane()
This method extracts the selected text in a form that includes
escape sequences.

refs: https://github.com/wez/wezterm/issues/2223
2022-07-05 22:01:16 -07:00
Wez Furlong
741cd37bd4 lua: add window:copy_to_clipboard method
refs: https://github.com/wez/wezterm/issues/2223
2022-07-05 21:59:00 -07:00
Wez Furlong
3dbd866b06 deps: tiny-skia -> 0.7
closes: #2219
2022-07-04 06:30:34 -07:00
dependabot[bot]
adc42bd470 build(deps): bump embed-resource from 1.7.2 to 1.7.3
Bumps [embed-resource](https://github.com/nabijaczleweli/rust-embed-resource) from 1.7.2 to 1.7.3.
- [Release notes](https://github.com/nabijaczleweli/rust-embed-resource/releases)
- [Commits](https://github.com/nabijaczleweli/rust-embed-resource/compare/v1.7.2...v1.7.3)

---
updated-dependencies:
- dependency-name: embed-resource
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-03 22:48:13 -07:00
Wez Furlong
1e85e79fc7 keys: add ActivateKeyTable::until_unknown=true
This will implicitly pop key table entries if they don't match keys.

refs: https://github.com/wez/wezterm/issues/2178
2022-06-30 07:14:22 -07:00
Wez Furlong
d23414105e allow debug overlay to open even if the config file is busted
refs: https://github.com/wez/wezterm/issues/1174
2022-06-29 14:47:45 -07:00
Wez Furlong
eb50c68228 config: allow reloading after config errors detected
This commit adjusts the config loading code so that we can return
information about the paths the should be watched for a subsequent
reload even in the more common error cases.

refs: #1174
2022-06-29 14:34:28 -07:00
Wez Furlong
d41ed68b1a lua: save and restore debug overlay repl history 2022-06-28 17:48:18 -07:00
Wez Furlong
b5518d5cd9 x11: avoid protocol error around DestroyWindow request
This is a bit of an unsatisfactory commit... the bulk of it is
augmenting our calls into XCB to ensure that we check the status of each
request; the idea was that doing so would highlight the source of the
bad drawable error that is being surfaced in #2198, but after doing
that, it still doesn't highlight the offending call.

My conclusion is that either something in MESA/EGL or the IME is
generating calls that we cannot see into and that one of those is
referencing the window id that we just destroyed.

The resolution then is a bit gross: instead of destroying the window
when we need to close it, we first unmap it to remove it from the
screen, then after 2 seconds we destroy it.

refs: https://github.com/wez/wezterm/issues/2198
2022-06-28 08:30:52 -07:00
Wez Furlong
f1c53495e7 lua: add window:mux_window() and pane:mux_window() methods
These allow converting the gui versions of these objects
to the mux versions.

refs: https://github.com/wez/wezterm/issues/225
2022-06-27 20:28:26 -07:00
Wez Furlong
fb1a659c4c fix wezterm connect sshdomain when password auth is needed
We need the mux window builder to notify in order for the ConnectionUI
to show up, but we wouldn't trigger the notify (which happens on drop)
until we'd awaited the connection ui completing password auth.

Force it to drop earlier to unblock.

refs: https://github.com/wez/wezterm/issues/2194
2022-06-27 16:49:05 -07:00
Wez Furlong
a282d07776 mux: add titles to mux window and tab objects
Previously, the mux layer had no internal understanding of titles other
than the Pane::get_title method to return state from a pane.

Users have asked for ways to explicitly set titles on windows and tabs,
so this commit is a step towards that.

The mux window and tab objects now store a title string.

The terminal layer now emits Alert::WindowTitleChanged when the window
title is changed via eg: OSC 0 or OSC 2.

The mux layer will respond to Alert::WindowTitleChanged by resolving the
window that corresponds to the source pane and amending its title.

The MuxWindow and MuxTab objects now provide accessor methods for the
title.

TabInformation (as used by format-tab-title and format-window-title) now
exposes the underlying window_id as well as tab_title and window_title.

The tab title can be changed via the lua MuxTab type, but there is not
currently an escape sequence associated with this.

The defaults for format-tab-title and format-window-title don't
currently consider these new title strings.

refs: https://github.com/wez/wezterm/issues/1598
2022-06-27 12:01:40 -07:00
Wez Furlong
21f1e63218 show-keys: make keys more readable to humans
refs: #2134
2022-06-22 11:33:25 -07:00
Wez Furlong
1b766326fd debug overlay: now supports statements as well as expressions
Previously, trying to do something like `foo = "bar"` in the debug
overlay wouldn't succeed, because we were always trying to wrap
the line inside `return {line}`, which allowed for only expressions
to be used.

Now we also allow a fully formed statement to be used, which means
that that kind of assignment can be performed in the repl, making
it a bit more convenient to try stuff out.

refs: https://github.com/wez/wezterm/issues/1238
2022-06-22 11:16:11 -07:00
Wez Furlong
80671f29bd add wezterm show-keys command
This prints out the key and mouse assignments

refs: https://github.com/wez/wezterm/issues/2134
2022-06-22 09:14:34 -07:00
Funami580
6a9056d77c Fix mouse selection including the first character of the next line
ref: #2089

Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2022-06-21 14:52:09 -07:00
Benoit de Chezelles
f79ce00b65 Implement line selection for copy mode 2022-06-21 13:43:11 -07:00
Benoit de Chezelles
6767144a09 Update wezterm-gui/src/overlay/copy.rs
Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2022-06-21 11:53:37 -07:00
Benoit de Chezelles
097abc4fe8 Implement o & O to move cursor to other end of selection in copy mode 2022-06-21 11:53:37 -07:00
Funami580
b3e160ff4a Fix scrollbar thumb position for modified minimum thumb sizes 2022-06-20 08:08:53 -07:00
Wez Furlong
347e1fdc46 completions: improve zsh completions for --cwd, --config-file, prog
Make these complete the appropriate type of thing
2022-06-19 16:27:59 -07:00
Wez Furlong
e0616e5eb3 fix AltGr-7 reporting for win32 input mode
We need to carry the RIGHT_ALT modifier flag through to the win32
input mode encoder so that it is correctly handled by both win32
and wsl apps.

Take care to avoid RIGHT_ALT being encoded as ALT for the
non-win32-input-mode case.

refs: https://github.com/wez/wezterm/issues/2127
refs: https://github.com/wez/wezterm/issues/2098
2022-06-18 10:48:07 -07:00
Wez Furlong
66033e4c6d lua api: improve error handling
Don't prevent wezterm from starting up if the gui-startup event
errors out.

Show a toast notification with the error message.

refs: #674
2022-06-18 07:25:05 -07:00
Wez Furlong
699bbce8e2 add gui-startup and mux-startup events
Using the newly exposed-to-lua mux apis, you may now run some lua code
at GUI startup and/or mux startup, just prior to any default windows
being created.

If you happen to spawn any panes as a result of this, wezterm will
skip creating the default program.

```lua
local wezterm = require 'wezterm'
local mux = wezterm.mux

-- This produces a window split horizontally into three equal parts
wezterm.on("gui-startup", function()
  wezterm.log_info("doing gui startup")
  local tab, pane, window = mux.spawn_window{}
  mux.split_pane(pane, {size=0.3})
  mux.split_pane(pane, {size=0.5})
end)

wezterm.on("mux-startup", function()
  wezterm.log_info("doing mux startup")
  local tab, pane, window = mux.spawn_window{}
  mux.split_pane(pane, {size=0.5, direction="Top"})
end)

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

refs: #674
refs: #1949
2022-06-17 12:37:19 -07:00
Wez Furlong
e8bb0e03ee add wezterm.mux lua module
The intent is to expose Mux related functions to lua, so `wezterm.mux`
will be that module table.

In order to test this out in the debug overlay, I realized that the
overlay was running functions in a different thread and didn't have
access to the mux, so this commit also tweaks the debug overlay repl to
execute the input in the main thread.

The result is that it is now possible to do
`wezterm.mux.active_workspace()` in the debug overlay to print the
active workspace name.

More functions will follow.

refs: https://github.com/wez/wezterm/issues/225
2022-06-17 07:46:25 -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
75066cb522 deps: update
Main thing to note here is that the open crate has deprecated
open::that_in_background, but made open::that non-blocking.

I think this is OK, but I'm a little cagey about what will
happen with this on Windows.  We may need to spawn our own
thread for this if things go awry.
2022-06-12 20:17:48 -07:00
Wez Furlong
d85b7bf3b9 win32: add extended/enhanced key concept for win32 input mode
refs: https://github.com/wez/wezterm/issues/2009
refs: https://github.com/microsoft/terminal/issues/13134#issuecomment-1148000328
2022-06-08 07:41:19 -07:00
Wez Furlong
402e5b7382 background: round down fractional pixels when tiling 2022-06-03 09:28:24 -07:00
Wez Furlong
35f14ec34c box model: allow for eased colors to be set
I did an ad-hoc test where I set the new tab button background to
an Animated value and saw that it eased in and out.

However, this commit doesn't make anything use this yet.
2022-06-03 06:58:57 -07:00
Wez Furlong
f60e39b4c3 gui: speculative fix for #2068
refs: https://github.com/wez/wezterm/issues/2068
2022-06-02 21:06:19 -07:00
Wez Furlong
a0ad3dd378 gui: move ease/interpolation into shader
This is prep for future work where I'll be moving more of the main
monospace rendering into the box model code and factoring out
this aspect of animation.
2022-06-02 07:10:57 -07:00
Wez Furlong
3dfb570162 background: round down fractional y offsets
Otherwise there is a chance that we'll end up with a 1-pixel
transparent gap between tiled textures
2022-06-01 20:44:27 -07:00
Wez Furlong
749db1435d background: avoid allocating empty layers
Only increment the layer index if we allocated any quads into it
2022-06-01 12:07:14 -07:00
Wez Furlong
2b083cc131 background: cache computed gradient images
Avoid recomputing on each config change/reload.
2022-06-01 07:29:24 -07:00
Wez Furlong
5f56b96dd2 background: allow repeat to mirror 2022-05-31 21:49:12 -07:00
Wez Furlong
590bcf2f75 background: implement offsets and alignment 2022-05-31 19:39:28 -07:00
Wez Furlong
1360e13f24 background: use Dimension for background size 2022-05-31 12:36:47 -07:00
Wez Furlong
040cd19f88 background: allow specifying the repeat interval
Useful if you want to add smaller items to your background layers
every so often; you can specify the distance between them and make
it independent of the item height.
2022-05-31 12:11:27 -07:00
Wez Furlong
e85258a212 background: allow specifying a solid color layer
The color can have alpha and blend with other layers.
This is helpful if your image has fully transparent portions
and you want to explicitly place a color in there.
2022-05-31 08:47:28 -07:00
Wez Furlong
4cb75c154f background: allow specifying the animation speed for images
The `File` variant for background layers may now be an object
that specifes a speed factor.  That factor is applied to the
animation frame durations in the loaded image, allowing the
playback rate to be adjusted.
2022-05-31 07:32:05 -07:00
Wez Furlong
3ef533e858 background: respect alpha in background images 2022-05-30 08:51:48 -07:00
Wez Furlong
7738f89381 background: use the actual sprite width
not the width of the full texture
2022-05-30 08:05:26 -07:00
Wez Furlong
303b908f9b fmt 2022-05-30 07:24:13 -07:00
Wez Furlong
62532704c2 background: implement attachment scrolling and parallax!
```lua
return {
  background = {
    {
      source = {File="/home/wez/Downloads/grey-bricks.png"},
      -- attachment = "Scroll",
      attachment = {Parallax=0.1},
      hsb = { brightness = 0.3, },
    },
  },
}
```
2022-05-30 07:20:14 -07:00
Wez Furlong
08d2ec67dc background: refactor where we trigger background painting
moving it so that we have access to the full set of positioned panes
in a subsequent commit.
2022-05-30 07:20:14 -07:00
Wez Furlong
27511c59ef background: implement scaling and repeating options 2022-05-30 07:20:14 -07:00
Wez Furlong
77b2674f6c render multiple backgrounds with alpha
Adjusts the background rendering logic so that we now allocate
a render layer for each defined background layer. This allows
their individual opacity value to multiple and blend together.

As part of this, I noticed that the big jpegs I was using could
take 400ms or more to load, so I added a basic cache to avoid
loading the same image multiple times around a config reload.
2022-05-30 07:20:14 -07:00
Wez Furlong
5d44ed6f85 notionally allow multiple background image layers
This adds some types that will enable richer background images.

* Can specify multiple layers
* Each layer can select from image files or gradient definitions
* Layers have additional properties to specify positioning, scaling,
  tiling and whether they scroll with the viewport.

None of the additional properties are hooked up yet.
2022-05-30 07:20:14 -07:00
Wez Furlong
f857ec6a5a deps: structopt -> clap 3 2022-05-28 07:07:52 -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
8d29631808 gui: fixup config overrides typing
refs: https://github.com/wez/wezterm/issues/2042
2022-05-27 18:41:48 -07:00
Erlend Lind Madsen
c3ea11487c gui: add Linear gradient 2022-05-26 16:45:19 -07:00
Wez Furlong
4e00b24dbf gui: allow layers to be allocated for zindex on the fly
Make the layer allocation more dynamic, which makes it
possible for the box model stuff to allocate a layer based
on the zindex for an element.

Adjust the box model code to cascade the base zindex via
the layer context so that the render stage can select
the correct layer.

This fixes up rendering tabs over the top of the right status
area.
2022-05-26 08:32:55 -07:00
Wez Furlong
b2cd800c70 fix positional modifiers on Windows
I overlooked this as part of e83f2c95f4
The positional mods need to be stripped out when looking up keymap
assignments, so let's do that.

refs: https://github.com/wez/wezterm/issues/2009
refs: https://github.com/wez/wezterm/issues/2037
2022-05-26 05:38:15 -07:00
Wez Furlong
3be4dbc878 pane select: allow bg to have alpha channel
Wraps up the changes from the following diff and allows for the modal
layer (and box model) to use alpha for poly quads.

Change the default background color for pane select to be slightly
transparent.
2022-05-25 23:25:09 -07:00
Wez Furlong
3058e245d0 Allow for multiple layers
Each layer has the same 3-pass draw that we use for the main terminal
display.

These layers allow for potentially compositing between the layers.
That is untested at the moment as the upper layers use the box model
stuff which hard-codes its work to the vb index 1 which doesn't
use regular alpha blending.
2022-05-25 20:51:36 -07:00
Wez Furlong
8cce462780 debug overlay: avoid stair case when printing log messages
Need to normalize \n to \r\n so that `wezterm.log_error("foo\nbar")`
shows up correctly in the overlay.
2022-05-25 07:34:49 -07:00
Wez Furlong
2725559fc0 paneselect: add mode parameter and a mode for swapping panes
Extends the pane selector to allow:

```
wezterm --config 'keys={{key="p", mods="CTRL", action=wezterm.action{PaneSelect={mode="SwapWithActive"}}}}'
```

to swap the active pane with the selected pane.
Similar to https://wezfurlong.org/wezterm/config/lua/keyassignment/RotatePanes.html
except that only the active and the selected panes have their positions
adjusted.

refs: https://github.com/wez/wezterm/issues/1842
refs: https://github.com/wez/wezterm/issues/1975
2022-05-24 22:52:54 -07:00
Wez Furlong
c34e9b45d4 paneselect: ctrl-g as emacs-y way to close it 2022-05-24 18:39:22 -07:00
Wez Furlong
504841f0ae revert accidental portion of prior commit 2022-05-24 09:33:49 -07:00
Wez Furlong
06db8b51aa paneselect: adjust padding/styling 2022-05-24 07:17:12 -07:00
Wez Furlong
5bf736bd21 add PaneSelect key assignment
This is still a bit of a WIP, but this commit:

* Introduces a new "Modal" concept to the GUI layer. The intent is
  that modal intercepts key and mouse events while active, and renders
  over the top of the rest of the normal display.
  I think there might be a couple of cases where key events skirt
  through this, but this is good enough as a first step.
  Also, the render is forced into layer 1 which has some funny side
  effects: if the modal choses to render transparent, it will poke
  a hole in the window because all the rendering happens together:
  there aren't distinct layer compositing passes.

* Add a new PaneSelect action that is implemented as a modal.
  It uses quickselect style alphabet -> pane label generation and
  renders the labels over ~the middle of each pane using an
  enlarged version of the window frame font.  Typing the label
  will activate that pane.  Escape will cancel the modal.

More styling and docs will follow in a later commit.

refs: #1975
2022-05-23 08:16:52 -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
d2d4257f79 Add RotatePanes key assignment 2022-05-21 17:10:04 -07:00
Wez Furlong
da7da888cd config: generate errors for things like --config tarm=foo
Invalid option names, or values that evaluate as nil (such as the `foo`
above: that's treated as a global variable reference, but `foo` isn't a
defined global and evaluates as `nil`) will now cause the program
startup to error out with an actionable error message.

Previously, the invalid config name would generate a warning, and the
invalid value would silently have no effect as it has the same effect as
omitting the named value and leaving it as its default value.

I think these cases should both immediately error out and stop
further processing, so that's what we're doing.

This commit also adds support for adding:

```
   #[dynamic(deprecated = "use newer option instead")]
   pub some_config_value: bool,
```

but not options currently use this.
2022-05-21 13:10:30 -07:00
Wez Furlong
736169a752 add min_scroll_bar_height config option
refs: https://github.com/wez/wezterm/issues/1936
2022-05-21 10:06:18 -07:00
Wez Furlong
107d3d2378 search mode can now default to searching the selection text
To do this, we split `Pattern` into the underlying pattern for the mux
layer (which is part of the codec), and another for the config layer,
so that we can specify this new mode.

At the gui layer, we translate the selection variant into the actual
selection text and map it to the mux Pattern enum.

When taking the selection text, we restrict it to just the first line.

refs: https://github.com/wez/wezterm/issues/1912
2022-05-21 07:24:50 -07:00
Wez Furlong
e8c3de9c16 copy/search mode: change scope of saved search to be per-tab
refs: https://github.com/wez/wezterm/issues/1912
2022-05-21 06:45:26 -07:00
Wez Furlong
c04d831ee5 add cell_width config to scale cell_width
This works similarly to line_height

refs: #1979
2022-05-21 06:10:03 -07:00
Wez Furlong
b312479266 quickselect: allow multiline matches
Turn on multi-line mode by default, and improve the localpane
search function to collapse runs of trailing whitespace into
just a newline.

That allows:

```
./target/debug/wezterm -n --config 'quick_select_patterns={"foo$"}'
```

to match the first line from this, but not the second:

```
printf "foo\nfoobar\n"
```

and this to match both:

```
./target/debug/wezterm -n --config 'quick_select_patterns={"^foo"}'
```

refs: https://github.com/wez/wezterm/issues/2008
2022-05-20 09:47:08 -07:00
Wez Furlong
1e61d1ea8b wayland: avoid noisy panic-within-panic on shutdown
Ensure that we eagerly clear the window map to avoid
drop-during-global-dtor related panic which confuses
the root cause of wayland protocol errors.
2022-05-20 07:54:00 -07:00
Wez Furlong
55767c69b1 quickselect: avoid jumping to bottom of viewport when activated 2022-05-20 06:16:31 -07:00
Wez Furlong
2f14d640e8 config: split out lua functions into their own crates
This shaves off some build time and allows more parallism in the build.
2022-05-19 06:48:09 -07:00
Wez Furlong
92eea8e064 restore pretty printing lua values in repl
This time with more correctly working cycle detection
2022-05-18 07:47:39 -07:00
Wez Furlong
55e7d845e9 Add cycle detection when converting lua values to dynamic 2022-05-18 07:47:39 -07:00
Wez Furlong
862dbc604a cut more things over to dynamic 2022-05-18 07:47:39 -07:00
Wez Furlong
f587cac145 config: cut over to wezterm-dynamic
Avoid using serde for mapping between Lua and Rust for the `Config`
struct.

This improves the build speed of the config crate by 2x; it goes down
from 30 seconds to 9 seconds on my 5950x.
2022-05-18 07:47:39 -07:00
kumattau
9b5c887874 Fix text cursor position when using multiple panes 2022-05-17 18:45:46 -07:00
aznhe21
28466d517d Fix IME candidate window position 2022-05-17 07:40:55 -07:00
Funami580
4b302e8f57 rectangular selection: fix selection
fixes:
* beginning the selection with the top right or bottom left corner
* beginning the selection with the bottom right corner and only select a single line
2022-05-16 19:43:30 -07:00
Funami580
9600d52cd8 rectangular selection: add option to select with Alt+Shift 2022-05-16 19:43:30 -07:00
Funami580
55c5bcb6ae Make DecreaseFontSize the inverse of IncreaseFontSize
Otherwise increasing the font size and then decreasing it again
will not return to the original font size.
2022-05-16 14:09:48 -07:00
Wez Furlong
46ca0679b1 add pane:get_foreground_process_info()
Returns all known information about the foreground process in the pane.

refs: #1987
2022-05-14 09:14:35 -07:00
Wez Furlong
3018a8f32e launcher: process ESC and CTRL-G ahead of feeding into filter
refs: https://github.com/wez/wezterm/issues/1977
2022-05-13 18:48:51 -07:00
Wez Furlong
97f0bd16f2 launcher: allow CTRL-G to cancel
refs: https://github.com/wez/wezterm/issues/1977
2022-05-12 14:27:30 -07:00
kumattau
cba1cfe533 Fix text cursor position when showing tab bar 2022-05-12 09:01:04 -07:00
Wez Furlong
7858f652fb input: fix ALT when used for the leader key
The issue here was that we'd try to match this:

```
key_event RawKeyEvent { key: Char('t'), modifiers: ALT | LEFT_ALT, phys_code: Some(T), raw_code: 17, repeat_count: 1, key_is_down: true, handled: Handled(false) }
```

which has mods=`ALT|LEFT_ALT` against `ALT` and would fail.

We need to strip out the positional ALTs from the modifiers
in order to successfully match.

refs: https://github.com/wez/wezterm/issues/1958
2022-05-08 22:34:36 -07:00
Wez Furlong
89e427bd79 overlays: improve key_table handling
This commit re-arranges the code so that an overlay can have a local
stack of key table activations; this allows copy_mode and search_mode
key tables to layer on top of the user's window level key tables.

Previously, we'd just stick the search_mode entry on top of the global
state, which worked, but had the undesirable side effect of hijacking
the Enter key when switching to another tab in the window.

refs: https://github.com/wez/wezterm/issues/993
2022-05-06 17:57:55 -07:00
Wez Furlong
39f53161be copy mode: ctrl-v enables rectangular selection
refs: https://github.com/wez/wezterm/issues/1656
2022-05-05 21:10:06 -07:00
Wez Furlong
ef4a95211e add rectangular selection
Alt-dragging will use rectangular selection in the default mouse
assignments.

refs: https://github.com/wez/wezterm/issues/1361
2022-05-05 20:49:22 -07:00
Wez Furlong
dc0fde7ae0 search: save last used search term and restore it
When search mode is activated with an empty pattern, restore
the most recently used search term in any pane.

refs: https://github.com/wez/wezterm/issues/1912
2022-05-05 12:12:06 -07:00
Wez Furlong
2710cefb3e merge copy and search overlay code
The copy overlay now has a notion of running in search mode vs. copy
mode; it can be launched in either mode.

Search mode has a separate key table called `search_mode`.

Activating copy mode while search mode is active will now update
the mode of the existing overlay, rather than cancelling and creating
a new instance, and vice versa.

Activating copy mode while search mode is active will replace the
current key table activation (which is assumed to be `copy_mode`)
with `search_mode`, and vice versa.

The viewport is no longer scrolled to the bottom when activating search
mode.

refs: https://github.com/wez/wezterm/issues/993
refs: https://github.com/wez/wezterm/issues/1592
2022-05-05 08:18:04 -07:00
Wez Furlong
94bb4ad09d key tables: we now search the whole stack for match
This change causes key table activations to effectively layer
over prior key table activations.

This is necessary for the copy mode key assignment changes to
work.

refs: https://github.com/wez/wezterm/issues/993
2022-05-04 23:09:21 -07:00
Wez Furlong
551af2f47b define copy_mode key table and use it in copy mode
Moves the key handling in the copy overlay to be driven entirely
by configurable key assignments.

Note: copy mode wants you to use the `Copy` assignment to actually
do the copy, but this implementation hides the normal key assignments
by activating the copy mode key table.  This will be addressed
in the following commit.

refs: https://github.com/wez/wezterm/issues/993
2022-05-04 22:49:58 -07:00
Wez Furlong
99081e757a overlays: capture/restore the key_table_state when activating/closing
refs: https://github.com/wez/wezterm/issues/993
2022-05-04 22:17:22 -07:00
Wez Furlong
de97f16d56 copy mode: add CopyMode key assignment actions
Defines an assignment action for each of the pre-defined actions
in copy mode.

refs: https://github.com/wez/wezterm/issues/993
2022-05-04 21:44:04 -07:00
Wez Furlong
262531631c mux: add Pane::perform_assignment
Allows a pane to override/implement the action for an assignment

refs: https://github.com/wez/wezterm/issues/993
2022-05-04 21:29:07 -07:00
Wez Furlong
e0785311c1 deps: ordered-float
closes: https://github.com/wez/wezterm/pull/1946
2022-05-01 21:43:22 -07:00
Ye Sijun
b73838c426 support scrolling tabs
Signed-off-by: Ye Sijun <junnplus@gmail.com>
2022-05-01 10:09:31 -07:00
Ye Sijun
27d36250a9 introduce quote_dropped_files config option
Signed-off-by: Ye Sijun <junnplus@gmail.com>
2022-04-25 09:49:32 -07:00
Ye Sijun
8f6facd584 support drag and drop files for macos
Signed-off-by: Ye Sijun <junnplus@gmail.com>
2022-04-25 09:49:32 -07:00
Wez Furlong
f1d96b2d19 gui: show LEADER status in debug_key_events logging 2022-04-25 07:42:23 -07:00
Wez Furlong
e9cd0ce072 add ClearSelection action
refs: https://github.com/wez/wezterm/issues/1900
2022-04-21 06:58:08 -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
b375886073 mux: spawn pane if needed when using launcher to attach
If we had previously killed all the panes in a remote mux,
and then reconnected to it using the launcher menu attach option,
we could end up in a confusing state where we connect but don't
show anything for the remote; it looks like nothing happened
even though it is legitimately showing the empty remote mux.

This commit checks for that case and spawns the default program
in the remote if there are no panes.
2022-04-17 18:24:46 -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
David Rios
fddf4f1fee fix: broken scroll bar after screen is cleared/reset
When the screen is cleared/reset, the physical top is not reset with it,
instead the scrollback_top variable gets set with the point at which the
screen was reset / you are allowed to scroll back to. The scroll bar
code wasn't aware of that.

refs: https://github.com/wez/wezterm/issues/1866
2022-04-17 08:12:03 -07:00
Ye Sijun
3ca45cf269 lanucher support CTRL-N and CTRL-P to move up and down
Signed-off-by: Ye Sijun <junnplus@gmail.com>
2022-04-16 11:02:54 -07:00
Wez Furlong
756a9789c8 Add PaneInformation.domain_name and pane:get_domain_name()
refs: https://github.com/wez/wezterm/issues/1881
2022-04-16 10:53:23 -07:00
Nikita Govorov
a8597c72dd fix(default-keys): aligned Scroll Down One Page command's key binding with the docs
PageUp -> PageDown, apparently it was a copy/paste issue.
2022-04-13 05:22:38 -07:00
Wez Furlong
20e019d2ed fix ctrl-shift-x copypasta from recent commands refactor
refs: https://github.com/wez/wezterm/issues/1863
2022-04-12 20:42:05 -07:00
Wez Furlong
e615720444 really fix cmd-q on macos
copypasta!

cc: @gegoune
2022-04-12 16:25:28 -07:00
Wez Furlong
fa22a6cd41 fix cmd-q on macos
copypasta!

cc: @gegoune
2022-04-12 16:24:39 -07:00
Wez Furlong
c1d7ca96db fonts: include glyph names in ls-fonts --text output 2022-04-12 08:34:32 -07:00
Wez Furlong
2e8b5f5e7b Add command defs to default launcher menu view 2022-04-10 06:52:12 -07:00
Wez Furlong
b83c3272f6 Add some more entries to command defs
These don't have any default key assignments.

refs: https://github.com/wez/wezterm/issues/1485
2022-04-09 22:19:22 -07:00
Wez Furlong
b162f6f1e2 reduce log level of some diagnostics printed on startup 2022-04-09 22:19:22 -07:00
Wez Furlong
1956054e6f Move default key assignments to gui layer, add more metadata
Create a list of command definitions to hold the default key
assignments.

That list has more metadata, such as a brief and longer human
readable description of the purpose, and allows for (in the
future) reasoning about the context where the command is valid,
as well as providing more information when rendering in the
launcher menu.

refs: https://github.com/wez/wezterm/issues/1485
2022-04-09 22:19:22 -07:00
Wez Furlong
bbead38f82 gui: reduce log level for Ding log line
Since we have working visual and audible bells, we can
avoid polluting the logs with this.

refs: #1844
2022-04-09 06:37:24 -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
5914a91490 palette now stores alpha for all color values
We're now capable of remembering an alpha value for everything
in the palette and the main window theme, but not the tab bar theme.

Whether the alpha is correctly respected at render time is a different
story!

refs: #1835
2022-04-08 07:08:33 -07:00
Wez Furlong
d356b72ca9 cursor_fg, cursor_bg, cursor_border now accept alpha values
refs: https://github.com/wez/wezterm/issues/1835
2022-04-07 21:55:28 -07:00
Wez Furlong
d8cfdae27b avoid ping-ponging focus updates with multiple windows
The bug here was that each paint call in a window would update
the focus state of its panes to reflect the one that had focus.

However, it didn't account for the actual window focus; it would
just assume that it was focused.

The result was that the perceived focus would alternate between each of
the windows in the wezterm process, and if you were running an
application that had enabled focus tracking, those events could cause a
repaint and drive up the CPU utilization.

This commit addresses that by gating the focus update to only occur
when we have the focus, and for extra safety, avoid generating focus
events at the terminal layer if the new state matches the current state.

refs: https://github.com/wez/wezterm/issues/1838
2022-04-07 21:43:05 -07:00
Wez Furlong
a2da7efbf7 remove send_composed_key_when_alt_is_pressed option
refs: https://github.com/wez/wezterm/issues/1826
2022-04-07 21:21:14 -07:00
Wez Furlong
a7cdd46720 logging: use our own custom logger
I wanted to use the Target::Pipe feature of env_logger so that we could
log to a log file as well as stderr, but it just doesn't work
(https://github.com/env-logger-rs/env_logger/issues/208).

Since we were already composing over the top of the logger in order
to capture data for our ringlog, this commit embraces that and makes
our logger responsible for both stderr and log file printing.

Thankfully, we can use the filter parsing code from env_logger to
avoid having to get too crazy with this.

Logs are stored in the runtime directory and look something like:

/run/user/1000/wezterm/wezterm-gui-log-596324.txt

Logs are collected on all platforms.

There isn't currently a thing to clean up logs.
2022-04-07 09:51:00 -07:00
Wez Furlong
b35e3b2aad deps: remove pretty_env_loggger
Go directly to the underlying env_logger crate, as pretty_env_logger
hasn't been updated in some time, and I'd like to be able to redirect
the log output to a file more directly, and that feature is in a newer
version of the env logger than pretty_env_logger was pulling in.
2022-04-07 08:24:07 -07:00
Wez Furlong
81a6089289 Use PaneId type in MouseCapture::TerminalPane variant 2022-04-06 20:00:00 -07:00
David Rios
4c304233f5 Extend mouse capture concept to individual panes 2022-04-06 20:00:00 -07:00
Wez Furlong
16e5a3604d ls-fonts: show pixel_sizes for font-dirs and built-ins 2022-04-05 20:55:15 -07:00
David Rios
33e0858f8d fix incorrect mouse position reporting for split panes
fixes #1822
2022-04-05 17:38:22 -07:00
Wez Furlong
de615080b2 Restore window creation error logging
revert 4f59c17f19 as it didn't help
2022-04-05 07:17:07 -07:00
Wez Furlong
526cc26b1e allow disabling aa for custom block glyphs
This is definitely in the band-aid category, but two issues have
mentioned the AA in custom block glyphs recently.

This commit adds an `anti_alias_custom_block_glyphs` option that can be
set to false to prevent the custom block glyphs from enabling AA.

I think a better long term fix would be some kind of hinting to avoid
the degenerate AA case, but when I made an enquiry about this class of
issue in tiny skia in the past, the author didn't want to diverge from
skia-compatible behavior, so I think we'd need to find (or build!) an
alternative rasterizer for these path instructions.

refs: https://github.com/wez/wezterm/issues/1753
refs: #1817
2022-04-04 20:39:30 -07:00
Wez Furlong
59a5b5ab12 gui: assume --always-new-process if --position is specified
To fix this correctly, the mux protocol would need to have some
special cases for talk to a gui server implementation, and we don't
have those today.

refs: #1794
2022-04-04 20:07:10 -07:00
Wez Furlong
24b2597183 ls-fonts: improve output for custom_block_glyphs
Print the correct text fragment, and clarify why wezterm
is drawing a glyph.

refs: #1817
2022-04-04 20:03:05 -07:00
Wez Furlong
53cae843c8 Clear key table stack on config reload 2022-04-04 09:30:04 -07:00
Wez Furlong
4f59c17f19 window: include debug repr of window creation errors
The glium IncompatibleOpenGl Display doesn't include any of the
useful context to explain what the issue was, so this commit
renders the error both in human friendly and Debug form to
see if we can understand more about what is happening.

refs: https://github.com/wez/wezterm/issues/1813
2022-04-04 07:06:27 -07:00
Wez Furlong
018f5df7d5 cargo fmt after resolving conflicts via GH UI 2022-04-03 18:29:59 -07:00
David Rios
c5687acf8c
gui: improve mouse text selection (#1805)
* gui: improve mouse text selection
* implement mouse press capture between the terminal and UI, so when you
  start selecting text from the terminal the tabs won't activate and
  vice-versa
* selecting from the top and bottom lines won't scroll the viewport
  anymore, it will only scroll if the mouse is moved out of line bounds
* change cell selection so that it behaves like text selection usually
  does in other popular software

refs: https://github.com/wez/wezterm/issues/1199
refs: https://github.com/wez/wezterm/issues/1386
refs: https://github.com/wez/wezterm/issues/354
2022-04-03 18:29:31 -07:00
Wez Furlong
54d503de9d keys: add ActivateKeyTable assignment
`ActivateKeyTable` pushes a new named key table entry onto the stack.

It has some parameters:

* name - required; the name of a entry in `key_tables` that should be
  activated.
* timeout_milliseconds - how long the entry should remain active.
  When this duration elapses, the entry will pop itself from the
  stack. If omitted, the entry will not pop itself due to time.
* one_shot - if true (or omitted; true is default), the entry will pop
  itself after one use.  If false the entry will not pop itself after use.
  But note that if timeout_milliseconds is set then it may pop itself
  due to time.
* replace_current - if true, will pop the current stack entry before
  activating the current entry. Most useful when combined with some
  other one_shot=false activation.

`PopKeyTable` explicitly pops the top of the key table stack.
Most useful with `one_shot=false` activations.

`ClearKeyTableStack` clears the key table stack. Most useful with
`one_shot=false` activations.

```
local wezterm = require 'wezterm';

wezterm.on("update-right-status", function(window, pane)
  local name = window:active_key_table()
  if name then
    name = "TABLE: " .. name
  end
  window:set_right_status(name or "")
end);

return {
  debug_key_events = true,
  keys = {
    -- Activate the "woot" table as a one-shot with
    -- a 2 second timeout, after which it will restore
    -- the default table.
    {
      key="a", mods="CTRL",
      action=wezterm.action{
        ActivateKeyTable={
          name="woot",
          timeout_milliseconds=2000,
        }
      }
    },

    -- Activate the "woot" table.
    -- The table will remain active until explicitly popped
    -- by the `PopKeyTable` action. See the Escape binding below!
    {
      key="b", mods="CTRL",
      action=wezterm.action{
        ActivateKeyTable={
          name="woot",
          one_shot = false,
        }
      }
    },

    -- Activate the "woot" table as a one-shot with
    -- no timeout. It will remain active until a key is pressed,
    -- after which is will restore the default table.
    {
      key="c", mods="CTRL",
      action=wezterm.action{
        ActivateKeyTable={
          name="woot",
        }
      }
    },

  },
  key_tables = {
    woot = {
      {key="a", action=wezterm.action{SendString="woot"}},
      {key="Escape", action="PopKeyTable"},
    },
  },
}
```
2022-04-03 14:49:23 -07:00
Wez Furlong
3c4eb0846f keyboard: define keytable related types
This commit introduces a new `key_tables` config option that allows
defining named groups of key assignments, but that have no effect yet.

To support this change, the InputMap type has been adjusted to allow
for the idea that multiple tables can exist.

refs: https://github.com/wez/wezterm/discussions/1812
2022-04-03 13:45:21 -07:00
Wez Furlong
14323a08d1 fonts: adjust descender for scaled fallback fonts
The gist of the issue is that when setting eg: scale=1.2 to draw
a larger CJK glyph, it is drawn at the same descender level, which
makes it more likely to leave the top of the cell.

This commit adjusts the y position by the difference between the
original and the scaled descender so that is less likely to cause
problems.

refs: https://github.com/wez/wezterm/issues/1803
2022-04-03 09:39:48 -07:00
Wez Furlong
8ac793a619 add --position CLI option for requesting initial window position
refs: #1794
2022-04-02 09:32:21 -07:00
Wez Furlong
69288aee4c window: Add RequestedWindowGeometry type
This is mostly a refactoring: pulling out the discrete width/height from
the `new_window` method and preparing to pass down x/y coords as well.

The types are expressed as Dimension so that screen relative sizes could
be expressed in the future... once we know how to obtain that
information on each platform.

refs: https://github.com/wez/wezterm/issues/1794
2022-04-02 07:25:59 -07:00
Wez Furlong
bd02d33bf5 tab bar: constrain to constant height
The tab bar height could vary by a couple of pixels depending on the
text shown inside it, which results in visual jitter as the title bar
changes.

Avoid that: always return our constant reserved amount of space for the
tab bar, even if it means that there are a couple of pixels "wasted".

cc: @davidrios
2022-04-01 09:34:14 -07:00
Wez Furlong
508baabc79 keys: default assignments can now be set to mapped or physical
A bit of a PITA, this commit:

* Introduces a DeferredKeyCode type that defers resolving a concrete
  keycode
* Adds key_map_preference config which can be Mapped or Physical
* Key map building resolves the keycode using key_map_preference
* Default key assignments have been re-phrased in order to produce
  DeferredKeyCodes
* User-specified keys without `mapped:` or `phys:` prefixes will
  resolve according to key_map_preference

refs: https://github.com/wez/wezterm/issues/1788
refs: https://github.com/wez/wezterm/issues/1784
2022-04-01 08:07:23 -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
34090580a0 tabbar: default to a dummy, non-empty state
This is to avoid computing a zero height initial tab bar as discussed
in 808d7df8d4 (commitcomment-69980693)

cc: @davidrios
2022-03-31 07:50:34 -07:00
Wez Furlong
808d7df8d4 gui: fixup tab bar height issue
In https://github.com/wez/wezterm/pull/1779#issuecomment-1082058134 we
discuss a weird case where the tab bar height is computed as 0 and then
gets stuck at 0.

What's happening is that the initial `TabBarState::default()` value has
no items yet, and `build_fancy_tab` generates an area that occupies 0
pixels.  This computed element is cached, and then the height from that
is cached.

When `invalidate_fancy_tab` is called, it didn't invalidate the cached
height and the resultant metrics were wonky.

One possible fix for this was to also invalidate the cached height,
but since that height is already stored in the built fancy tab,
we can remove that derived-cached value in favor of just passing
down the value.

refs: https://github.com/wez/wezterm/pull/1779
2022-03-30 07:03:14 -07:00
Wez Furlong
ab944341d8 Minor tweaks 2022-03-29 08:55:25 -07:00
David Rios
45072fa475 Overhaul scroll thumb calculation
- Simplify scroll thumb calculations
- Correct thumb position when dragging with mouse
- Support border OS parameters
- Use usize for OS borders, to explicitly only accept positive integers
- Get correct tab height when using fancy tab bar
- Correctly draw depending on tab bar position
- Adjust minimum thumb size to be 1/2 of a cell height, so it has consistent size across platforms and screen densities

Fixes #1525
2022-03-29 08:55:25 -07:00
Wez Furlong
ec022275e5 factor in notch/borders during resize
refs: #1737
2022-03-28 07:06:17 -07:00
Wez Furlong
b65cf803d7 fonts: show aliases in ls-fonts --list-system output 2022-03-27 20:21:09 -07:00
Wez Furlong
53fc926b1c gui: fix wonky logic for simple_dpi_change
The condition should be: dpi-changed && (close-enough-stuff)
but was (dpi-changed && (some-close-enough-stuff)) ||
(other-close-enough-stuff).

The net result was toggling non-native full screen on macos could
falsely try to do scale change handling even though the dpi was
unchanged, because the window resized by only a couple of pixels.
2022-03-27 16:28:07 -07:00
Wez Furlong
4e343eb1e5 macos: try to avoid the notch
Flesh out the get_os_parameters impl for macOS.  When running on a
system that provides `NSScreen::safeAreaInsets`, use that to determine
the border required to avoid the "notch" on certain models of mac.

In the GUI layer: when the os parameters include a border, adjust
the render position to account for it.

This is a bit of a speculative change, as I don't have a mac with
a notch.

refs: https://github.com/wez/wezterm/issues/1737
2022-03-26 22:47:42 -07:00
David Rios
fca3559a0f
Implement native window dragging on Windows (#1771)
Implement native window dragging on Windows
2022-03-26 17:28:43 -07:00
Wez Furlong
4035860f45 update retro tab bar hover state in more cases
refs: https://github.com/wez/wezterm/issues/1764
2022-03-26 09:45:12 -07:00
David Rios
a95b081620 Improve the responsiveness of the drawn border 2022-03-26 07:27:54 -07:00
David Rios
b036bb3b05 Improve RESIZE window_decoration on Windows 2022-03-26 07:27:54 -07:00
Wez Furlong
409ff74b84 gui: speculative improvement for resize/scaling issue
I think this may help with #1745 and #1566 but I'm not on a mac
at the moment(!)
2022-03-22 06:41:22 -07:00
Wez Furlong
7fc7201ae5 add swallow_mouse_click_on_window_focus option
Separates out window vs pane click-to-focus behavior more distinctly,
and fixes up the behavior when
swallow_mouse_click_on_window_focus=false.

refs: #1540
2022-03-19 07:41:34 -07:00
Wez Furlong
5f1b0cff18 gui: move last_mouse_terminal_coords to per-pane state 2022-03-19 07:10: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
9db419a3f8 pretty print output in the debug overlay 2022-03-18 07:34:41 -07:00
Wez Furlong
ace8253498 allow debug overlay to run async chunks
allows eg: `window:effective_config()` to print the config for the
window
2022-03-17 09:17:02 -07:00
Wez Furlong
d290f532d4 fix hang with open crate when spawning the browser
The `open` crate blocks forever when spawning the browser via xdg-open,
which feels kinda "wrong" to me, but does offer a method that can stick
that in a background thread, so that's what we do here.

refs: #1721
2022-03-15 07:50:08 -07:00
David Rios
aaad2be606
Detect mouse leaving the window (#1679)
* Detect mouse leaving the window

* Implement leave

* Use new API

* Fix mouse leave

* Fix mouse leave on Wayland

* Mouse leave on X11

* Detect mouse leaving window on macOS

* Fix example

refs:  #1434
2022-03-11 08:26:09 -08:00
David Rios
3b05dac0c6 Use newer windows crate 2022-03-11 07:40:39 -08:00
Greg V
9879005f87 add support for XF86Copy/XF86Paste keys 2022-03-11 06:43:18 -08:00
Wez Furlong
ce3dd00444 fix panic when spawning invalid command via reused gui instance
refs: #1696
2022-03-09 10:33:29 -07:00