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

772 Commits

Author SHA1 Message Date
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