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

1126 Commits

Author SHA1 Message Date
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
Howard Huang
e01f9c0e7d FEATURE: Allow ScrollByPage f64 values
`ScrollByPage` can accept non-integer values in the configuration.
This allows fractional page scrolling, such as by half a page.

The default remains the same, at 1 page.
2022-01-12 17:01:38 -08:00
Wez Furlong
cefe45d206 Windows can be labelled with a workspace name
This is not exposed through any UX; the mux api allows setting
the workspace and propagating information about windows whose
workspace has changed.

Windows start with a blank workspace name.

This is just plumbing; nothing uses it yet.

refs: #1531
2022-01-12 16:47:08 -07:00
Wez Furlong
e314d84711 wezterm connect unix could exit on startup
This is a similar race condition to one we had before with the
multiplexer, where the connection UI made us think that we didn't
need to start a new process.

Additionally, the attach method would unconditionally create a
new client without checking whether we already had one.
2022-01-11 22:35:31 -07:00
Wez Furlong
58d969e77c gui: Avoid 450ms delay on startup(!)
In the case that the published symlink is stale, our default
client connection logic was to retry connecting with backoff
to give a newly spawned server a chance to startup.

In the context of a newly launched gui process checking to see
if an existing gui process can serve the same request, we don't
need to give it any grace: it will either answer immediately
or be deemed not useful.

This commit limits us to a single connection attempt in the case
where we're not automatically starting the server, which in turn
constrains the overhead to something in the order of microseconds
rather than nearly 0.5 seconds.

While we're in here, I noticed that if we thought we had a socket
to try and that failed, we'd always try to publish a new symlink.
However, if we failed due to mismatched version info, we shouldn't
publish over the top of the already running instance.

refs: #1529
2022-01-10 20:31:01 -07:00
Wez Furlong
1fd53d4a5d mux: propagate User Vars across to the client
user vars were stubbed out.  This commit adds storage for them
in the mux client and adds a new notification that publishes each
var as it is changed.  That differential stream is applied to the
storage in the mux client when it is received.

```lua
local wezterm = require 'wezterm'

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

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

then running:

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

causes `nice` to show in the status area.

refs: #1528
2022-01-10 18:33:32 -07:00
Wez Furlong
0d18a40d60 improve some of our counters/stats 2022-01-10 17:59:53 -07:00
Wez Furlong
aa648797ae Include executable path and config path in version info
Use that to decide if the running version is equivalent to the
newly spawning one when deciding if we can route a command to it
or spawn a new gui
2022-01-10 17:59:53 -07:00
Wez Furlong
fc5c435949 stats: fix .size counters showing up as time counters 2022-01-10 10:36:33 -07:00
Wez Furlong
5d52902b4a invalidate fancy title bar before we potentially error out
This feels slightly more robust in the face of errors

refs: https://github.com/wez/wezterm/issues/1527
2022-01-10 08:31:10 -07:00
Wez Furlong
fe0488420b speculative fix for https://github.com/wez/wezterm/issues/1527
We need to invalidate the elements in the title bar if we reallocate
the quads, otherwise we'll be left with random stuff in the texture
coords.
2022-01-10 08:20:18 -07:00
Wez Furlong
a045cfe092 standardize on SshDomain as the way to configure RemoteSshDomain
refs: https://github.com/wez/wezterm/issues/1456
2022-01-09 19:45:11 -07:00
Wez Furlong
79f7f63064 deps: ordered-float -> 2.10
closes: https://github.com/wez/wezterm/pull/1524
2022-01-09 19:25:48 -07:00
Wez Furlong
3593a288ea ssh: rename use_multiplexer to multiplexing
This puts us in a better position for the future to be able
to configure whether we use wezterm, tmux or no multiplexing.

Today we allow wezterm or no multiplexing.

Add docs on this new setting.

refs: https://github.com/wez/wezterm/issues/1456
2022-01-09 19:16:54 -07:00
Wez Furlong
f84c0632d8 gui: allow wezterm connect sshdomnomux
If an ssh domain is set to use_multiplexer=false, it is now
possible to `wezterm connect` to it.

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

refs: https://github.com/wez/wezterm/issues/1456
2022-01-09 15:52:40 -07:00
Wez Furlong
0676eed42f gui: refactor common code between ssh/connect/start subcommands 2022-01-09 15:25:00 -07:00
Wez Furlong
524663e9ce gui: refactor connect/ssh subcommands to share more code 2022-01-09 14:41:43 -07:00
Wez Furlong
59be1bf8ac wezterm ssh and wezterm serial: now support --class
Notice these were missing when compared to the other gui subcommands.
2022-01-09 13:18:08 -07:00
Wez Furlong
f69177b022 ssh: allow setting SshDomain::use_multiplexer = false
Currently has no effect.

refs: #1456
2022-01-09 13:13:54 -07:00
Wez Furlong
380a67dd85 gui: tidy up whether we use existing gui or publish as a new one
If we decide we want re-use and existing gui due to config differences
we shouldn't then publish the new, differently configured, gui as
the canonical path for that display/class.

Clarify the message that we print when re-using an existing gui
in case someone doesn't want that behavior.
2022-01-09 11:18:47 -07:00
Wez Furlong
627001762e rename dead_key_is_active -> composition_status, dead_key_cursor -> compose_cursor
Since the composition state isn't strictly tied to dead keys, use
a name that better reflects that.
2022-01-09 08:39:21 -07:00
Wez Furlong
71bfa38cf4 input: don't scroll to bottom on key up events
refs: #1483
2022-01-08 15:37:15 -07:00
Wez Furlong
b2ee6793f9 Add default_domain option
When set, changes the default domain to the domain with the specified
name, which potentially affects the default program.

eg: default_domain = "WSL:Ubuntu-18.04" will cause the initial tab
to be spawned via WSL.
2022-01-08 15:05:05 -07:00
Wez Furlong
cdf3fc89f7 launcher: remove WSL items from list
These are now redundant with the list of wsl_domains.

The `add_wsl_distributions_to_launch_menu` option has been removed.
2022-01-08 15:05:05 -07:00
Wez Furlong
0e9924e585 new: WslDomain, a variant on the local domain
The idea is that we want to be able to spawn into wsl with the
convenience of a local domain, but without the awkwardness of
it having a different filesystem namespace.

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

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

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

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

This commit:

* Introduces `wsl_domains` config and its default list of wsl
  distributions
* Creates LocalDomain instances from that list
* The launcher menu allows spawning a new tab via one of those domains
2022-01-08 15:05:05 -07:00
Wez Furlong
7a824a2594 client: remove race condition in cli shutdown
The client machinery would try to spawn an async attempt at
detaching the unixdomain from the mux on shutdown, but since
we're in the middle of tearing down the scoped executor,
we could sometimes panic.

The client we have in this situation isn't actually associated
with a domain, so we don't need to detach in that situation.

Formalize that by making it an Option, and address the
fanout.
2022-01-07 17:51:10 -07:00
Wez Furlong
e8995c5370 wezterm-gui start now prefers to run via existing gui instance
Using the new publish/discovery stuff from the past couple of commits,
if we can find a matching socket path for a running gui, and the
configuration is likely a match, then use the mux protocol to talk
to the already running gui and ask it to spawn the equivalent program
into the same process.

refs: https://github.com/wez/wezterm/discussions/1486
2022-01-07 17:12:35 -07:00
Wez Furlong
33dd3f393c fix leader key deactivating on key up
refs: https://github.com/wez/wezterm/issues/1520
refs: #1483
2022-01-07 14:10:27 -07:00
Wez Furlong
78c4c56425 input: fix KeyCode::Physical -> termwiz KeyCode conversion
refs: https://github.com/wez/wezterm/issues/1519
refs: #1483
2022-01-07 14:01:01 -07:00
Wez Furlong
4524abcdba gui: revise win32-input-mode flow
We need 100% of the info for it to work correctly, so this commit:

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

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

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

refs: #1509
2022-01-07 13:02:09 -07:00
Wez Furlong
3c6bc2c366 add ActivatePaneByIndex key assignment action
refs: #1517
2022-01-07 07:30:17 -07:00
Wez Furlong
17a9d6159a wezterm cli now prefers to talk to main GUI instance
When spawned with no WEZTERM_UNIX_SOCKET environment set,
we now prefer to resolve the gui instance, falling back to
the mux if it doesn't look like the gui is running.

`wezterm cli --prefer-mux` will use the original behavior of
trying to resolve the path from the unix domain in the config.
2022-01-06 22:31:42 -07:00
Wez Furlong
eddf1c031a refactor: move gui socket list from update module to discovery module 2022-01-06 21:55:16 -07:00
Wez Furlong
91fc705e26 gui/client: add stubs for publishing a main gui instance sock path
This will help to route things through a main gui instance per desktop
session/class.

Currently has stubs for windows.
2022-01-06 20:07:46 -07:00
Wez Furlong
27d452a20f input: route key up events to pane on win32
refs: https://github.com/wez/wezterm/issues/1509
2022-01-06 09:45:51 -07:00
Wez Furlong
763c4d7f7e term: reintroduce possibility of key_up events
Nothing generates them right now, and the mux client has no
way to represent them on the wire.

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

refs: https://github.com/wez/wezterm/issues/1509
2022-01-06 09:45:51 -07:00
Wez Furlong
8437d787b8 ls-fonts --text used wrong per-glyph text
It was showing the whole text for the cluster for each shaped
glyph.

Fix it up to map back to the corresponding cell range and
extract the text from the line.

Include the x_advance metric in the output while we're in
there.

refs: https://github.com/wez/wezterm/issues/1333
2022-01-05 23:36:33 -07:00
Wez Furlong
9f6f901f5b launcher: unbreak filtered view
I refactored and accidentally used entries instead of filtered_entries
2022-01-05 19:56:14 -07:00
Wez Furlong
59f5b849c5 gui: treat IME composition region as a giant stretched cursor
That way we get consistent styling for the span of the composing text
2022-01-05 10:52:33 -07:00
Wez Furlong
b05cb1241e force clusters to break around cursor boundary
When rendering the IME composing text, I noticed that for the Korean
input sequence: shift+'ㅅ' followed by 'ㅏ' we'd render the 'ㅆ' (the
shifted first character) in black and the composing 'ㅏ' in white
against the cursor color, and that was very difficult to read,
especially at the default font size.

To resolve this, this commit:

* Forces clustering to break around the cursor boundary, so that
  we treat the cursor position as its own separately styled cluster
* Adjusts cursor/bg rendering so that we always consider the start of
  the cluster for the colors of that run.  We are guaranteed that a
  ligatured sequence will fit in the background area anyway.

This has the effect of "breaking" programming ligatures such as '->'
when cursoring through them, and decomposing them into their individual
'-' and '>' glyphs, which is a reasonable price to pay for being able
to see things better on screen.

refs: https://github.com/wez/wezterm/issues/1504
refs: https://github.com/wez/wezterm/issues/478
2022-01-05 09:20:11 -07:00
Wez Furlong
0d6fbc1aa2 macos: improve ime vs dead key composing
When we translate a dead key, send the composed event immediately
and don't try to route the current key press via the IME.

Improve rendering when in the composing state: overlay the composing
text at the cursor position to show what the composing text would
look like, even though it hasn't been committed to the input stream
yet.

refs: https://github.com/wez/wezterm/issues/1504
2022-01-05 07:50:12 -07:00
Wez Furlong
71dae34b75 macos: improve IME handling
For Korean text input, pressing SHIFT and then typing in certain
keys begins a composition sequence.  Our logic for when to route
via the IME got so distracted by ALT that it didn't consider SHIFT
and didn't send this sequence to the IME, so we'd fail to compose
those sequences.

While poking at this, I realized that we should treat this composition
similarly to dead keys, in that we can signal the term window to
highlight the cursor color and report that status.

There's some further work to do: the composing text should be rendered
by us.  So far our IME integration assumes that the IME itself will
render over the top of our window, but for this particular input
it doesn't do that.

refs: https://github.com/wez/wezterm/issues/1504
2022-01-04 22:51:49 -07:00
Wez Furlong
6d72101879 launcher: restore j/k movement by default
You now press `/` to enter search mode
2022-01-04 20:49:21 -07:00
Wez Furlong
621dcd3b30 launcher: don't fall off bottom of launcher when filtered 2022-01-04 20:49:21 -07:00
Wez Furlong
6927faebfb launcher: refactor and simplify 2022-01-04 20:49:21 -07:00
Autumn Lamonte
c10ff1e41f fix nits 2022-01-04 19:49:06 -08:00
Autumn Lamonte
07a2acb840 #1457 refactor, ClickPosition 2022-01-04 19:49:06 -08:00
Autumn Lamonte
81f4bbd4aa #1457 Initial commit compiles but doesn't yet work 2022-01-04 19:49:06 -08:00
Wez Furlong
1f6e4497e0 launcher: simplify logic
Remove the local awareness of how to spawn into a window and replace
it with using a KeyAssignment to do that instead.

refs: #1485
2022-01-04 09:49:32 -07:00
Wez Furlong
541701d822 refactor tab navigator into launcher menu
The same core code is used to render both the tab navigator
and the launcher.  The context is specified using some flags
so that you don't get an unholy mess in both places.

The net result of this is that the tab navigator now supports
fuzzy matching.

refs: #664
refs: 1485
2022-01-04 09:35:07 -07:00
Wez Furlong
142f3c7d81 launcher now has fuzzy matching
Just start typing text to build up the fuzzy matching term.
The list of items updates to match the results.

refs: #664
refs: #1485
2022-01-04 08:45:15 -07:00
Wez Furlong
68fb416b34 launcher: fix subtraction overflow for tall windows 2022-01-04 08:05:31 -07:00
Wez Furlong
99f94f8425 launcher overlay: fix build on windows 2022-01-04 08:01:37 -07:00
Wez Furlong
9919745d4e launcher: tidy up key/mod display impl to make it look nicer
Make things a little more compact and display friendly

refs: #1485
2022-01-03 23:38:36 -07:00
Wez Furlong
05ec80d945 gui: dedup and sort key assignment launcher entries
refs: #1485
2022-01-03 23:28:37 -07:00
Wez Furlong
509122c152 Improve launcher menu
* Allow selecting the first few rows by number
* Allow scrolling through long lists of items
* Add actions from key assignments to list

refs: #1485
refs: #1413
2022-01-03 23:07:54 -07:00
Wez Furlong
f002b16ee1 refactor launcher entries to make it easier to build command palette
refs: #1485
2022-01-03 18:27:58 -07:00
Wez Furlong
ad96d84745 fonts: remove descender adjustment
It seems like we don't need this any more; things look better
without it.

refs: #1203
refs: #1499
2022-01-03 14:52:19 -07:00
Wez Furlong
cc507951d0 gui: fix new tab hover colors
refs: #1498
2022-01-03 12:52:58 -07:00
Wez Furlong
34dd0b6688 add mapping from phys to keycode, tidy up windows event processing
refs: #1483
2022-01-03 10:56:32 -07:00
Wez Furlong
5f26746286 window/gui: remove raw/phys fallback fields from KeyEvent
Since we now have RawKeyEvent and a sane way to indicate handling,
we don't need these any more, and it simplifies key dispatch to
remove them.

refs: #1483
2022-01-03 09:13:55 -07:00
Wez Furlong
0224f65fed gui: avoid glitchy live resize
Pass down whether we are in a live resize to the gui layer, so that
we don't incorrectly assume that the scale has changed, and fight
with the window manager.

Built this on my mac: will need to fixup for windows and linux.

refs: https://github.com/wez/wezterm/issues/1491
2022-01-03 08:29:05 -07:00
Wez Furlong
028026049d add window:dead_key_is_active window:leader_is_active
This commit adds a couple of helper methods that provide insight into
the state of the keyboard layer.

The intent is for users to add status information about the keyboard
state.

This commit also ensures that we schedule an update when the leader
key duration expires, and ensures that we close out the leader state
for an invalid key press.

refs: #686
closes: #688

```lua
local wezterm = require 'wezterm';

wezterm.on("update-right-status", function(window, pane)
  local leader = ""
  if window:leader_is_active() then
    leader = "LEADER"
  end
  local dead = ""
  if window:dead_key_active() then
    dead = "DEAD"
  end
  window:set_right_status(leader .. " " .. dead)
end);

return {
  leader = { key="a", mods="CTRL" },
  colors = {
    dead_key_cursor = "orange",
  },
}
```
2022-01-02 19:41:21 -07:00
Wez Furlong
c29212be49 add colors.dead_key_cursor to signal dead and leader key processing
When set, the cursor will change to this color during dead key
or leader key processing.

```lua
return {
  colors = {
    dead_key_cursor = "orange",
  },
}
```

refs: #686
refs: #688
2022-01-02 17:49:32 -07:00
Wez Furlong
79ab6e8103 window: add deadkeystatus event
Plumbs it for Windows.
Doesn't do anything useful with it yet.

refs: #688
2022-01-02 17:00:18 -07:00
Wez Furlong
d5726ba91a window: add RawKeyEvent concept
on macos only (for now), we generate a RawKeyEvent prior to
dead key or IME composition and route it to the window to give it
a chance to handle the event.

RawKeyEvent handling is scoped only to key assignments, not generating
input for the terminal.

A raw key event can be marked as handled to prevent moving on to
performing composition and generating cooked key input.

refs: https://github.com/wez/wezterm/issues/877
2022-01-02 15:04:27 -07:00
Wez Furlong
69e8d9144c gui: allow matching keys with a physical position
```lua
local wezterm = require 'wezterm'

return {
  debug_key_events = true,
  keys = {
    {key="phys:Q", action=wezterm.action{SendString="woot"}},
  },
}
```

The above will send "woot" to the pane whenever the key in same
physical position as Q on an ANSI standard US keyboard is pressed.

refs: https://github.com/wez/wezterm/issues/1483
2022-01-02 01:20:21 -07:00
Wez Furlong
b15907f61f input-types: introduce PhysKeyCode type
Based on the mac constants of the equivalent functionality;
may need some tweaking for other OS's.

refs: https://github.com/wez/wezterm/issues/1483
2022-01-01 21:35:37 -07:00
Wez Furlong
ea7030ae11 clarify the purpose of wezterm start in the --help output
This makes it a bit more understandable/discoverable.

refs: #1478
2022-01-01 12:44:38 -07:00
Wez Furlong
8251e04c63 gui: invalidate windows resources when icon changes
I noticed that by myself and another user who built from source
still had the old icon show up.
2022-01-01 12:15:03 -07:00
Wez Furlong
907b92b3ea gui: box: better job at avoiding overflowing bounds
This makes the x button overflow look better when the tab titles are
wide
2022-01-01 09:03:19 -07:00
Wez Furlong
7e8e215dc7 gui: remove adjust from vertex
This comes from a time where our quads were always locked to grid
positions.  We don't need it any more: we can simply add the adjustments
to the quad positions that we set.

Removing it makes the vertex a bit smaller and reduces the amount
of GPU accessible memory we need to use.
2022-01-01 08:11:10 -07:00
Wez Furlong
0184038c55 gui: invalidate window after window:perform_action
closes: #1475
2021-12-31 10:02:15 -07:00
Wez Furlong
7efc6a6cb8 gui: ensure that the tab bar occupies a full pixel height
Otherwise we get weird vertical misalignment effects in the
terminal cell area for eg: the top of a `z` glyph being drawn
at a half pixel height.
2021-12-30 20:06:05 -07:00
Wez Furlong
1e7d552844 fonts: replace font_ptr with a font id
I'm running down a weird thing where the main font renders weirdly
when the title font is 12 pt vs the main font 10 pt.

I thought there might have been a cache invalidation issue and
realized that we could have an A-B-A style issue with the font_ptr
stuff, so I replaced it with an incrementing id.

That didn't fix the thing I was looking at, but does feel a bit
nicer overall.
2021-12-30 19:09:30 -07:00
Wez Furlong
00a393b3d1 gui: bundle and use Roboto for title font on Linux + Windows
The default we use on macOS looks decent.  Roboto is a similar
looking font that we can use for the other platforms.
I may make it the same on all three once I've had a chance
to compare it on a mac.
2021-12-30 17:51:22 -07:00
Wez Furlong
97c8cda974 gui: ls-fonts: include title font in ls-fonts output 2021-12-30 16:51:30 -07:00
Wez Furlong
561efcb8d1 gui: invalidate fancy tab bar on config reload
Otherwise we won't pick up font changes as quickly
2021-12-30 16:50:44 -07:00
Wez Furlong
07af7e0c4b gui: constrain fancy tab size to fit the width
closes: https://github.com/wez/wezterm/issues/1470
2021-12-30 09:20:51 -07:00
Wez Furlong
e5dd859ecc gui: tidy up metrics/line widths for X and + tab bar buttons 2021-12-29 09:00:50 -07:00
Wez Furlong
5608e9477b termwiz: make seqno a required param for Line
Previously, we would implicitly set it to the special SEQ_ZERO
value, but since that value always flags the row as changed,
it causes some over-invalidation issues downstream in wezterm.

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

refs: #1472
2021-12-29 08:34:59 -07:00
Wez Furlong
93a9b5a7fe gui: add Poly content drawing to box model; use it for x and + buttons
This should make those buttons look a bit more consistent
2021-12-28 23:24:18 -07:00
Wez Furlong
74caa9c173 gui: fixup bottom alignment of tab bar buttons 2021-12-28 21:53:08 -07:00
Wez Furlong
add3863871 gui: add x close button in fancy tabs
closes: #1351
2021-12-28 19:15:45 -07:00
Wez Furlong
494a0983ee gui: cache shaping and layout of fancy tab bar, allow placing at bottom
We only need to recompute when the tab content changes, or when
the window is resized, plus invalidations of the shape cache
of texture atlas filling up.

Hover events don't need to re-shape.

We can now also place the tab bar at the bottom of the screen again.
2021-12-28 12:29:54 -07:00
Wez Furlong
cc2bbced82 gui: respect tab background color
The main tab area now takes the background color from the first
cell in a formatted tab bar item as the full background color
for the whole tab area, which looks a lot nicer than just the
using that color for the minimal bounding box of the tab text.
2021-12-28 10:10:13 -07:00
Wez Furlong
f92d8112ae gui: avoid seeing right-status underneath left tabs when window is small
Introduce an opaque container to hold the left items and have that
sit over the top of the floated right status area to make things
look cleaner.
2021-12-28 09:22:16 -07:00
Wez Furlong
4ca7514029 gui: tighten up fancy tab bar to 1.75 line height
Add bottom alignment for tabs and make them slightly shorter
than the right status area; this avoids some pixel gaps.
2021-12-28 08:51:09 -07:00
Wez Furlong
13ac944e7f cargo fmt
refs: #1468
2021-12-28 08:50:43 -07:00
Wez Furlong
6ac6ac45b6 lua: add pane:get_logical_lines_as_text
refs: #1468
2021-12-28 08:04:41 -07:00
Wez Furlong
f4fab10e69 gui: box model style layout/render for fancy tab bar
This commit adds a CSS box model inspired element / layout
facility, and replaces the hand implemented fancy tab bar
element render.

This makes the code for fancy tab bar much easier to read
and update.

The right status area now expands to the full height of the
tab bar area, and uses a line height of 2.0, which makes
it line up nicely in the tab bar.
2021-12-28 00:14:54 -07:00
Wez Furlong
8c7072c5ef gui: flesh out test case for wsl -l -v
closes: https://github.com/wez/wezterm/issues/1462
2021-12-27 10:39:26 -07:00
Wez Furlong
780756bea8 gui: don't warn about wsl helper function on unix
Technically is only used on windows, but I'm fine with having
it built and tested on all platforms.
2021-12-27 10:35:11 -07:00
Wez Furlong
7e90a7008c deps: update pulldown_cmark, cargo update 2021-12-27 09:49:22 -07:00
Wez Furlong
4cf90bf7a1 gui: avoid invalidating window when only a modifier key is held down 2021-12-26 12:58:14 -07:00
Wez Furlong
2464e8fb3a gui: use wsl -l -v output for launcher items
Switch to the slightly more structured verbose output of `wsl -l -v`
in the hope that we are less prone to localization issues and
are more robust in the face of future changes.

refs: #1462
2021-12-26 09:19:38 -07:00
Wez Furlong
d51ce704d9 gui: don't use win32 gui subsystem in test configuration
We won't see test output in that case, because the tests won't
be able to write to the console!
2021-12-26 09:16:22 -07:00
Wez Furlong
2e24b0fc22 gui: improve new tab button appearance for fancy tab bar 2021-12-26 08:21:09 -07:00
Wez Furlong
790b515c21 gui: allow mouse wheel to route to hovered pane
refs: https://github.com/wez/wezterm/issues/798
2021-12-25 15:37:14 -07:00
Wez Furlong
c937f0c77c cargo fmt 2021-12-25 14:01:36 -07:00
Wez Furlong
a1ff2d6415 gui: make another pass over focus/mouse event routing
refs: #1437
2021-12-25 13:59:23 -07:00