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

1126 Commits

Author SHA1 Message Date
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
Wez Furlong
22cea37959 deps: textwrap -> 0.15 2022-03-03 07:19:21 -07:00
Wez Furlong
18c63c0526 fix copying trailing whitespace from wrapped lines
refs: #1635
2022-02-12 09:47:03 -07:00
Wez Furlong
dbf190d414 gui: changing cursor color with escape sequences > force_reverse_video_cursor
refs: 1625
2022-02-08 06:46:31 -07:00
Wez Furlong
0826fb060c Add separate animation_fps config for easing
and adjust animation scheduling to avoid excessive scheduling
if the time we compute is later than an already scheduled time
2022-02-07 23:02:52 -07:00
Wez Furlong
39babc1f1e fix overflow calc
refs: #1627
2022-02-07 07:49:51 -07:00
Wez Furlong
7a5956d3b8 gui: blinking cursor now eases rather binary blinks
Also: I recently broke force_reverse_video_cursor with the recent
glyph rendering fixes; this commit restores that functionality.
2022-02-06 22:09:52 -07:00
Wez Furlong
435ff1e93b deps: image -> 0.24 2022-02-06 18:51:32 -07:00
Wez Furlong
842e4800b5 blinking text is now eased between bg and fg color 2022-02-06 18:28:45 -07:00
Wez Furlong
7b4c3d0397 refactor: visual bell easing to a helper 2022-02-06 18:28:45 -07:00
Wez Furlong
75e785e01e allow using CSS style color specs in the config
This change also allows removing the dep on the palette crate,
which I found to be difficult to use (API changed often, and relied
on a lot of `.into` that was hard to follow and reconcile across
upgrades).  We already pulled in the csscolorparse crate as an indirect
dep of colorgrad, so we can replace the color conversion we need for
sixel with that crate while we're in here.

refs: #1615
2022-02-06 08:23:26 -07:00
Wez Furlong
52f3d6c0e5 gui: clarify code, no functional change 2022-02-06 07:29:07 -07:00
Wez Furlong
2ccf2378fd fix vertical positioning for custom block glyphs
refs: https://github.com/wez/wezterm/issues/1621
2022-02-06 06:19:49 -07:00
Wez Furlong
d0a7fc9fd3 gui: take a run at rendering double-width/height lines
This is using the existing attributes on the lines and rendering
the lines with doubled dimensions.

Selection on double width lines is a bit wonky because we don't
know how to translate the column position correctly.
2022-02-05 21:28:18 -07:00
Wez Furlong
1f6764f792 fixup underlines
bd47979292 made underlines only as
wide as the glyph texture.

This commit renders them under the width of the cluster region.
2022-02-05 16:29:04 -07:00
Wez Furlong
8cb74c62d2 allow setting selection colors with alpha values
This commit allows the following configuration:

```
wezterm -n --config 'colors = { selection_fg = "clear", selection_bg = "rgba:50% 50% 50% 50%" }'
```

which sets the selection_bg to fully transparent, and selection_bg to
50% transparent gray.

When selection_fg is fully transparent we'll use the normal fg color.

When selection_bg is partially (or fully!) transparent, it will be
alpha blended over the current cell background color.

To support this, the config file will now accept rgba colors specified
as 4 whitespace delimited numeric values. If a value ends with `%` it
is interpreted as a number in the range 0-100.  Otherwise, it is
interpreted as a number in the range 0-255.  The 4 values are
red, green, blue, alpha.

At this time, only the selection_fg and selection_bg settings accept
alpha values.

refs: #1615
2022-02-05 15:17:22 -07:00
Wez Furlong
240026de48 refactor: move color parsing into wezerm-color-types crate
Resolves a little bit of the awkward duplication of color types
between some of the crates by factoring them a little bit better.

This is prep for allowing specifying alpha for some colors
in the config.
2022-02-05 13:59:54 -07:00
Wez Furlong
bd47979292 revise ligature render / cursor intersection
This puts to final rest #478, wherein ligatured glyphs that span
cells would render portions of the glyph with the wrong fg color,
where wrong was usually the bg color and cause the glyph to turn
invisible when cursoring through the ligature.

The approach used here is to divide the glyph into 7 discrete strips
where each strip either intersects with the cursor, the selection, or
neither. That allows us to render each strip with the appropriate
foreground color.

This change simplifies some of the logic and allows some other code
to be removed, so that feels good!

As is tradition with these renderer changes, there's a good chance that
I overlooked something in testing and that the metrics or alignment
might be slightly off for some font/text combo.  Let's see how this
goes!

refs: #784
refs: #478
refs: #1617
2022-02-05 10:49:49 -07:00
Wez Furlong
1e32ccbd2f shaping: fix an issue where we'd lose combining marks like U+20d7
For a sequence like `e U+20d7` the intent is to render the `e` with
a vector arrow over the top.

This is typically implemented by fonts as an `e` followed by the
vector glyph (or vice versa), where either one of those may have
a zero advance so that the two elements are combined.

There were two problems here:

* During shaping we'd see the zero advance and assume that the entry
  was useless and skip it
* During rendering, if we didn't think it had any cell width, we'd
  not render it

Cursoring through that particular sequence can hide the vector
mark if the cursor is set to the default block cursor due to annoyances
in how the block cursor is rendered (it changes the fg color to match
the bg, but for elements outside where we think the cursor is, this
makes those elements invisible).

refs: https://github.com/wez/wezterm/issues/1617
2022-02-05 06:19:25 -07:00
Wez Furlong
092663a332 slightly simplify compute_cell_fg_bg
Reduce the number of parameters passed down into it
2022-02-04 08:38:16 -07:00
Wez Furlong
f4c3eab3f8 remove some dead code 2022-02-04 07:54:47 -07:00
Wez Furlong
cb1f35a7f9 remove experimental_shape_post_processing option
This has been obsoleted by the work in 9de0e1ac90
2022-02-04 07:43:01 -07:00
Wez Furlong
024261672a maybe really fix the alignment issues!
refs: #1570
refs: #1607
refs: #1563
2022-02-02 08:46:10 -07:00
Wez Furlong
9de0e1ac90 shaping: improve glyph cell width math
This is a more robust approach; we make a separate pass to figure
out information about the (harfbuzz) cluster for a sequence of glyphs,
and then map that sequence back to the original cell sequence, and
from there compute the total cell width for the run, then distribute
the glyphs across the run.

This should yield more sane results for bidi.

Fixup the x-position math; it was still wonky despite the
efforts in 5f2c905db8 and
af92265ffb

refs: #1570
refs: #1607
refs: #1563
2022-02-01 22:03:50 -07:00
Wez Furlong
5f2c905db8 shaping: feed presentation width from the terminal through to glyph info
This allows unicode_version to be respected again when rendering.

The updated emoji-presentation.sh script now highlights this slightly
better by putting `.` characters after the emoji; unicode version 14
emoji presentation will show the `.` in the 3rd column, while earlier
versions will show it in the 2nd column for glyphs that are sensitive
to the version.

refs: #1607
refs: #1563
2022-02-01 09:23:57 -07:00
Wez Furlong
af92265ffb render: fix regression with emoji width rendering
refs: #1607
refs: #1609
2022-02-01 08:25:05 -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
0da3e159a4 bidi: sort of make right-aligned text do something
with:

```
  bidi_enabled = false,
  bidi_direction = "RightToLeft",
```

lines are now rendered right-justified in the terminal.
I think there's still work to do on this, because the cluster
order seems weird to me, but it's hard for me to intuit how
this should really look.

refs: #784
2022-01-30 20:14:22 -07:00
Wez Furlong
98f35bbf24 bidi: tag Line with bidi mode
This commit refines bidi property handling:

* experimental_bidi has been split into two new configuration settings;
  `bidi_enabled` (which controls whether the terminal performs implicit
  bidi processing) and `bidi_direction` which specifies the base
  direction and whether auto detection is enabled.
* The `Line` type can now store those bidi properties (they are actually
  split across 3 bits representing enabled, auto-detection and
  direction)
* The terminal now has a concept of active bidi properties and default
  bidi properties
* The default properties are pulled from the wezterm configuration
* active bidi properties are potentially set via escape sequences,
  BDSM (which sets bidi_enabled) and SCP (which sets bidi_direction).
  We don't support the 2501 temporary dec private mode suggested by
  the BIDI recommendation doc at this time.
* When creating new `Line`'s or clearing from the start of a `Line`, the
  effective bidi properties are computed (from the active props,
  falling back to default propr) and applied to the `Line`.
* When rendering the line, we now look at its bidi properties instead
  of just the global config.

The default bidi properties are `bidi_enabled: false` and
`bidi_direction: LeftToRight` which corresponds to the typical
bidi-unaware mode of most terminals.

It is possible to live reload the config to change the effective
defaults, but note that they apply, by design, to new lines being
processed through the terminal.  That means existing output is
left unaffected by a config reload, but subsequently printed lines
will respect it.  Pressing CTRL-L or otherwise contriving to have
the running application refresh its display should cause the
refreshed display to update and apply the new bidi mode.

refs: #784
2022-01-30 09:50:04 -07:00
Wez Furlong
a2779cafec gui: fix rendering to account for RTL text
We were using the physical cell position to place the glyphs,
but we need to use the visual cell position (post-RTL-reordering).

refs: #784
2022-01-29 05:59:24 -07:00
Wez Furlong
e8f5463b7d adjust ls-fonts --text diagnostic output 2022-01-29 05:59:24 -07:00
Wez Furlong
66183ed336 fix test build 2022-01-28 18:51:49 -07:00
Wez Furlong
4ca1378f1f fonts: allow shaping with additional paragraph context
we don't really use this yet, except internally when we do fallback
2022-01-28 17:19:36 -07:00
Wez Furlong
0324ff66f0 wezterm: add experimental_bidi config option and very basic bidi
This commit is larger than it appears to due fanout from threading
through bidi parameters.  The main changes are:

* When clustering cells, add an additional phase to resolve embedding
  levels and further sub-divide a cluster based on the resolved bidi
  runs; this is where we get the direction for a run and this needs
  to be passed through to the shaper.
* When doing bidi, the forced cluster boundary hack that we use to
  de-ligature when cursoring through text needs to be disabled,
  otherwise the cursor appears to push/rotate the text in that
  cluster when moving through it! We'll need to find a different
  way to handle shading the cursor that eliminates the original
  cursor/ligature/black issue.
* In the shaper, the logic for coalescing unresolved runs for font
  fallback assumed LTR and needed to be adjusted to cluster RTL.
  That meant also computing a little index of codepoint lengths.
* Added `experimental_bidi` boolean option that defaults to false.
  When enabled, it activates the bidi processing phase in clustering
  with a strong hint that the paragraph is LTR.

This implementation is incomplete and/or wrong for a number of cases:

* The config option should probably allow specifying the paragraph
  direction hint to use by default.
* https://terminal-wg.pages.freedesktop.org/bidi/recommendation/paragraphs.html
  recommends that bidi be applied to logical lines, not physical
  lines (or really: ranges within physical lines) that we're doing
  at the moment
* The paragraph direction hint should be overridden by cell attributes
  and other escapes; see 85a6b178cf

and probably others.

However, as of this commit, if you `experimental_bidi=true` then

```
echo This is RTL -> عربي فارسی bidi
```

(that text was sourced from:
https://github.com/microsoft/terminal/issues/538#issuecomment-677017322)

then wezterm will display the text in the same order as the text
renders in Chrome for that github comment.

```
; ./target/debug/wezterm --config experimental_bidi=false ls-fonts --text "عربي فارسی ->"
LeftToRight
 0 ع    \u{639}      x_adv=8  glyph=300  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 2 ر    \u{631}      x_adv=3.78125 glyph=273  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 4 ب    \u{628}      x_adv=4  glyph=244  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 6 ي    \u{64a}      x_adv=4  glyph=363  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 8      \u{20}       x_adv=8  glyph=2    wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
 9 ف    \u{641}      x_adv=11 glyph=328  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
11 ا    \u{627}      x_adv=4  glyph=240  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
13 ر    \u{631}      x_adv=3.78125 glyph=273  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
15 س    \u{633}      x_adv=10 glyph=278  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
17 ی    \u{6cc}      x_adv=4  glyph=664  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
19      \u{20}       x_adv=8  glyph=2    wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
20 -    \u{2d}       x_adv=8  glyph=276  wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
21 >    \u{3e}       x_adv=8  glyph=338  wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
```

```
; ./target/debug/wezterm --config experimental_bidi=true ls-fonts --text "عربي فارسی ->"
RightToLeft
17 ی    \u{6cc}      x_adv=9  glyph=906  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
15 س    \u{633}      x_adv=10 glyph=277  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
13 ر    \u{631}      x_adv=4.78125 glyph=272  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
11 ا    \u{627}      x_adv=4  glyph=241  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 9 ف    \u{641}      x_adv=5  glyph=329  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 8      \u{20}       x_adv=8  glyph=2    wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
 6 ي    \u{64a}      x_adv=9  glyph=904  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 4 ب    \u{628}      x_adv=4  glyph=243  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 2 ر    \u{631}      x_adv=5  glyph=273  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
 0 ع    \u{639}      x_adv=6  glyph=301  wezterm.font(".Geeza Pro Interface", {weight="Regular", stretch="Normal", italic=false})
                                      /System/Library/Fonts/GeezaPro.ttc index=2 variation=0, CoreText
LeftToRight
 0      \u{20}       x_adv=8  glyph=2    wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
 1 -    \u{2d}       x_adv=8  glyph=480  wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
 2 >    \u{3e}       x_adv=8  glyph=470  wezterm.font("Operator Mono SSm Lig", {weight="DemiLight", stretch="Normal", italic=false})
                                      /Users/wez/.fonts/OperatorMonoSSmLig-Medium.otf, FontDirs
;
```

refs: https://github.com/wez/wezterm/issues/784
2022-01-25 09:00:53 -07:00
Wez Furlong
2deba1ece4 fonts: fix ligature widths at the cost of unicode version conformance
refs: #1563
2022-01-19 18:16:48 -07:00
Wez Furlong
a590955229 spawning a new tab didn't unfocus current pane
This commit centralizes the focus-loss logic to the Window so
that activating a new tab will deactivate the pane in the current
window.

Note that this cannot see overlays in the gui, but overlays shouldn't
care about focus, so it should be ok.

refs: https://github.com/wez/wezterm/discussions/796
2022-01-18 18:56:26 -07:00
Wez Furlong
0bf1b8d13e Plumbing for unseen activity indication
This commit enables the following config to work for local (not mux yet!)
panes:

```lua
local wezterm = require 'wezterm'

wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width)
  if tab.is_active then
    return {
      {Background={Color="blue"}},
      {Text=" " .. tab.active_pane.title .. " "},
    }
  end
  local has_unseen_output = false
  for _, pane in ipairs(tab.panes) do
    if pane.has_unseen_output then
      has_unseen_output = true
      break;
    end
  end
  if has_unseen_output then
    return {
      {Background={Color="Orange"}},
      {Text=" " .. tab.active_pane.title .. " "},
    }
  end
  return tab.active_pane.title
end)

return {
}
```

refs: https://github.com/wez/wezterm/discussions/796
2022-01-18 09:38:46 -07:00
Wez Furlong
0fe7a22f67 expose pixel positioning config option
refs: #1563
2022-01-18 08:13:30 -07:00
Wez Furlong
c930e333c4 fix an issue where ScrollToPrompt got confused by two prompts on same line
refs: https://github.com/wez/wezterm/issues/1121
2022-01-17 22:48:53 -07:00
Wez Furlong
2c44abc700 fix naming of get_semantic_prompt_zones
It previously had the more generic name of get_semantic_zones
which implied that it cached all zones, but this method is
scoped only to Prompt zones.
2022-01-17 22:25:43 -07:00
Wez Furlong
e4ed2c93e2 encoding my preferred import grouping in the rustfmt config
This uses an unstable option in rustfmt, you `cargo +nightly fmt`
needs to be used to format the code correctly.
2022-01-17 13:50:51 -07:00
Wez Furlong
db8f588c5e Add SwitchWorkspaceRelative key assignment 2022-01-17 09:54:11 -07:00
Wez Furlong
8d3d3e02a7 add default_workspace config option
refs: #1322
refs: #1531
2022-01-17 09:31:20 -07:00
Wez Furlong
d169088694 fix clipping issue in fancy tab bar
We budget size based on the x_advance, which can be 1 pixel less
than the width of the glyph texture, so we could often end up
omitting the last character in "Launcher" or "default" in the
tab title or right status area.

This commit uses x_advance in both places.
2022-01-17 09:24:23 -07:00
Wez Furlong
e8900d47cd add window:active_workspace()
refs: #1531
refs: https://github.com/wez/wezterm/discussions/1322#discussioncomment-1984256
2022-01-17 09:11:06 -07:00
Wez Furlong
7eec41c284 Add ShowLauncherArgs key assignment
refs: https://github.com/wez/wezterm/issues/1485
2022-01-17 08:16:18 -07:00
Wez Furlong
631f7869a5 launcher: consistently order entries 2022-01-16 20:59:51 -07:00
Wez Furlong
b6141d650e launcher: improve scrolling through options and mouse selection
Make the scrolling mostly independent of the active row; adjust
the top row when hitting the top/bottom edges of the display.

Mouse movement no longer changes the scroll position.  Instead,
the wheel is used to scroll the list.

refs: https://github.com/wez/wezterm/issues/1485
2022-01-16 20:28:46 -07:00
Wez Furlong
25c0540875 fix bar cursors when moving through double-width cells
Don't render two copies of the cursor in the same cell,
and compute different graphics for double wide cells.

refs: #1548
2022-01-16 12:19:49 -07:00
Wez Furlong
71630844c8 fix warning 2022-01-16 09:53:34 -07:00
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
12f32aeda8 tidy up front end accessors 2022-01-15 21:46:40 -07:00
Wez Furlong
39c2da3bdf avoid race condition when closing last window in a workspace
This isn't ideal, but it is better than previously: we would
close the window and before the Drop impl had updated the
list of known windows, we'd try to re-assign that window
to another mux window in a different workspace, but it would
never appear because the window was closed.

refs: https://github.com/wez/wezterm/issues/1531
2022-01-15 20:02:14 -07:00
Wez Furlong
093b448624 When switching workspaces, resize workspace to fit the window
Originally I had this the other way around but it was problematic
when considering things like maximized, font scaling and full screen
states.

refs: https://github.com/wez/wezterm/issues/1531
2022-01-15 19:33:29 -07:00
Wez Furlong
bb9290f431 launcher: avoid subtract with overflow panic 2022-01-15 19:33:02 -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
aa52555fb8 add workspaces to launcher menu
refs: #1531
2022-01-15 14:16:41 -07:00
Wez Furlong
6ba9d7f72e Add --workspace parameter to most gui subcommands
These allow setting the initial workspace name
2022-01-15 14:01:30 -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
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
3947014bad refactor: decouple domain from cwd matching in spawn.rs
This will make it easier to re-use other spawn functions in a later
commit.
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
12de21df95 clarify debug_key_events logging
up/down events were ambiguous
2022-01-14 21:59:29 -07:00