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

407 Commits

Author SHA1 Message Date
Erlend Lind Madsen
c3ea11487c gui: add Linear gradient 2022-05-26 16:45:19 -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
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
478b0df58b Add wezterm.strftime_utc 2022-05-24 17:24:19 -07:00
Wez Furlong
a5162765e9 config: make wezterm.action more ergonomic
you can try this in the debug overlay repl:

```
> wezterm.action{QuickSelectArgs={}}
{
    "QuickSelectArgs": {},
}
```

```
> wezterm.action.QuickSelectArgs
{
    "QuickSelectArgs": {
        "alphabet": "",
        "label": "",
        "patterns": {},
    },
}
```

```
> wezterm.action.QuickSelectArgs{alphabet="abc"}
{
    "QuickSelectArgs": {
        "alphabet": "abc",
    },
}
```

```
> wezterm.action.QuickSelectArgs{}
{
    "QuickSelectArgs": {},
}
```

```
> wezterm.action.Copy
"Copy"
```

```
> wezterm.action.ActivatePaneByIndex(1)
{
    "ActivatePaneByIndex": 1,
}
```

refs: https://github.com/wez/wezterm/issues/1150
2022-05-23 23:01:18 -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
efb8d14064 config: avoid rebuilding when git index changes
Focus instead on the head and check whether a commit is made.
2022-05-23 08:16:52 -07:00
kumattau
c890c238c1 Add support of IME preedit rendered by system on Windows 2022-05-22 06:02:51 -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
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
d6063e180a config: fix specifying numeric font weights
add helpers to Value coerce to different numeric types, and use
one of those in the FontWeight conversion.

refs: #2012
2022-05-20 06:33:12 -07:00
Wez Furlong
0e0bac2576 deps: prune some unused deps 2022-05-19 06:48:09 -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
4fac2e8dc9 tidy up handling of index colors
IndexedMap was a temporary measure while I was hacking through the
dynamic crate stuff; we don't need it any more.
2022-05-18 09:35:32 -07:00
Wez Furlong
0b61d41f8f remove serde from bidi 2022-05-18 09:25:41 -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
Wez Furlong
ea7571734f config: remove some dead code 2022-05-10 20:57:52 -07:00
datasone
74e1cdcb40
Add support for drag and drop files in Windows (#1953)
* Add support for drag and drop files in Windows

* Add two drag and drop filename quoting patterns (mainly) for Windows, change doc examples.

* Code style cleanup

* Improve Windows quoting pattern and rename DoubleQuoteAlways to WindowsAlwaysQuoted

* Improve special char finding for DroppedFileQuoting::Windows and fix doc.
2022-05-09 07:38:52 -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
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
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
ef96646f1c deps: migrate battery to starship-battery
The former is unmaintained and is flagging in cargo audit for its
indirect deps.

The starship folks have forked it; let's use that.

refs: https://github.com/svartalf/rust-battery/pull/92
refs: https://github.com/wez/wezterm/issues/1952
2022-05-04 20:11:48 -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
ccd3403bad add docs for quote_dropped_files
Signed-off-by: Ye Sijun <junnplus@gmail.com>
2022-04-25 09:49:32 -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
Wez Furlong
e9cd0ce072 add ClearSelection action
refs: https://github.com/wez/wezterm/issues/1900
2022-04-21 06:58:08 -07:00
Wez Furlong
c85fce703d config: avoid watching and reloading for home dir changes
refs: #1697
refs: https://github.com/wez/wezterm/issues/1895
2022-04-21 06:34:01 -07:00
Wez Furlong
f7b34438ed add clean_exit_codes config
refs: https://github.com/wez/wezterm/issues/1889
2022-04-19 07:48:49 -07:00
Wez Furlong
5b8b9630a3 Add treat_east_asian_ambiguous_width_as_wide option
I've bundled this into termwiz's UnicodeVersion type as that is
a similar concept that is already routed through to the appropriate
function.

refs: https://github.com/wez/wezterm/issues/1888
2022-04-19 06:56:39 -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
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
7977fe7ee1 config: watch the directory containing the wezterm.lua too
refs: #1697
2022-04-09 07:08:19 -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
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
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
f34d3a872e keys: fix always parsing key="F" as physical key
When considering "F" we'd try to parse it as "F<NUMBER>" and fail,
so fall back to producing `Physical(F)` instead.

Since this was in the context of CMD-F in the default keymap code,
we'd then generate ctrl-F as an equivalent when considering the
ctrl-shift case.

cc: @CIAvash
2022-04-07 06:39:06 -07:00
Wez Furlong
eefe4bd201 keys: improve key config parsing
The recent switch to DeferredKeyCode introduced a bit of ambiguity
when parsing certain keys.

One issue was with the map that was used for some parsing didn't have
consistent/distinct entries for physical vs. mapped.

Another issue is that the key resolution for the simple case where
a key had the same physical and mapped representations would always
return the mapped one even when physical mode was set as a preference.

This commit kills the ambiguous map in favor of an string conversion
method on KeyCode.

It's possible that this will help with https://github.com/wez/wezterm/issues/1826
a little, but I started looking at this because there were a couple of
comments about Alt-Enter and some numpad keys no longer working in the
Element channel.
2022-04-06 09:50:08 -07:00
Wez Furlong
a1b573c3c5 fix parsing raw: keycodes
refs: #1824
2022-04-06 07:01:10 -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
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
8d699fccb7 keys: only synthesize ctrl+uppercase from ctrl+shift+key if actually uppercase
This prevents the ctrl+shift+space assignment from also binding
ctrl+space
2022-04-03 06:02:19 -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
dc414dfde0 keys: auto synthesize ctrl+shift versions of keys
This should prevent overlooking various weird cases for the ctrl-shift
versions of key assignments.
2022-04-01 09:20:09 -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
76cbcb1341 config: refactor to reduce repeating key+mods
Use serde(flatten) so we can reuse KeyNoAction for 3 different structs.
2022-03-31 22:38:56 -07:00
Wez Furlong
72214b7db9 Disable ligatures for Menlo and Monaco
refs: https://github.com/wez/wezterm/issues/1736
refs: https://github.com/wez/wezterm/issues/1786
2022-03-28 19:32:00 -07:00
Wez Furlong
4e6b348921 fonts: allow fallback-level scaling factor
This commit allows specifying a scaling factor as part of the font
attribute definition.  This scaling factor is fed through to the
rasterizer and the shaper to adjust the actual font size that is
loaded.

The intent is to provide manual control for situations where the
fallback font has a different scale to the primary font and renders
either too small or too large.

The concrete example is
https://github.com/wez/wezterm/issues/1761#issuecomment-1079708207 where
the CJK fallback looks too small.

The scaling factor doesn't influence font metrics so it may also be
desirable to configure line height.

```lua
local wezterm = require 'wezterm'

return {
  line_height = 1.2,
  font = wezterm.font_with_fallback({
    "JetBrains Mono",
    {family="Microsoft YaHei", scale=1.5},
  }),
}
```
2022-03-26 16:37:50 -07:00
Wez Furlong
1c605f7bf1 Add Constant easing function
refs: https://github.com/wez/wezterm/issues/1738
2022-03-26 11:25:06 -07:00
Wez Furlong
185f52efaf remove some dead code 2022-03-23 20:43:50 -07:00
Wez Furlong
9936b8a5ab add xcursor_theme and xcursor_size config options
refs: #1742
2022-03-22 08:23:17 -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
37d2b04af6 fix some warnings on windows 2022-03-18 10:29:01 -07:00
Wez Furlong
29995c7cb3 add wezterm.enumerate_ssh_hosts() helper
This helper extracts the concrete set of hosts and their configurations
from the ssh config, and arranges to reload the wezterm config if they
are changed.

This is useful when constructing ssh domain configs.

refs: https://github.com/wez/wezterm/discussions/1731
2022-03-18 07:48:12 -07:00
Wez Furlong
deb7594eb5 Add doc comment
forgot to save before committing 89f20d265f
2022-03-17 09:49:13 -07:00
Wez Furlong
89f20d265f Allow mux_env_remove={} to produce an empty vec
We need to do a little dance to get this to work because
`{}` is ambiguous in lua; could be a map or a vec.

refs: https://github.com/wez/wezterm/issues/1622
2022-03-17 09:20:12 -07:00
Wez Furlong
6df26b476e fonts: FontSlant -> FontStyle
after reading around italic vs. oblique, I think "slant" is a misleading
way to categorize this, as slant implies something about the angle of
the font but really the difference between italic and oblique is purely
stylistic and without a suggested angle.

style more closely matches the CSS name which is well understood by
many, so we go for that.

refs: #1646
2022-03-12 09:46:14 -07:00
Wez Furlong
84d4187c9a fonts: replace italic boolean with FontSlant enum
There are three slants that are broadly recognized; normal, italic and
oblique.  Prior to this commit, we only considered normal or italic.

This is mostly a mechanical change to replace the boolean with the enum,
and rename the field from `italic` to `slant`.

For the sake of backwards compatibility with existing configs, the lua
helpers for working with fonts continue to accept boolean italic values
and rewrite them to the equivalent slant value.

refs: #1646
2022-03-12 08:16:27 -07:00
Greg V
9879005f87 add support for XF86Copy/XF86Paste keys 2022-03-11 06:43:18 -08: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
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
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
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
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
7933500b6d fix build on macos
refs: #1601
2022-01-31 08:28:46 -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
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
Quentin Perret
39086c048b Make the threshold for predictive echo configurable
Introduce a new config knob called 'local_echo_threshold_ms' to let
users configure when the local echo prediction should kick in. The
default value is 100ms to retain the current behavior.
2022-01-28 09:49:35 -08: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
8ee6739ece config: expand canonicalize_pasted_newlines
This setting now allows specifying what the canonical format is;
previously it was a boolean that meant "don't change anything"
if false, and rewrite to CRLF if true.

It's now an enum with None, CR, LF, and CRLF variants that express
more control.

The config accepts true (maps to CRLF) and false (maps to None)
for backwards compatibility.

The default behavior is unchanged by this commit, however, I did
uncover a bug in the canonicalizer for inputs like `\r\r\n`.

refs: #1575
2022-01-22 09:46:27 -07:00
Wez Furlong
0fe7a22f67 expose pixel positioning config option
refs: #1563
2022-01-18 08:13:30 -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
7eec41c284 Add ShowLauncherArgs key assignment
refs: https://github.com/wez/wezterm/issues/1485
2022-01-17 08:16:18 -07:00
Wez Furlong
4b457da62f cargo fmt 2022-01-16 18:48:26 -07:00
Wez Furlong
54e92b6858 Add module to map nerd font symbol names to codepoints
I generated nerdfonts_data.rs with this shell script; it uses `i_all.sh`
from the nerdfonts repo to get the base mapping:

```
source ./lib/i_all.sh

echo "//! Data mapping nerd font symbol names to their char codepoints"
echo "pub const NERD_FONT_GLYPHS: &[(&str, char)] = &["
for var in "${!i@}"; do
  # trim 'i_' prefix
  glyph_name=${var#*_}
  glyph_char=${!var}
  glyph_code=$(printf "%x" "'$glyph_char'")
  echo "(\"$glyph_name\", '\u{$glyph_code}'), // $glyph_char"
done
echo "];"
```

Then intent is to use it in wezterm:

```
local wezterm = require 'wezterm'

wezterm.log_info(wezterm.nerdfonts.dev_mozilla)
```
2022-01-16 17:25:08 -07:00
Wez Furlong
070c4030c6 Bundle Symbols Nerd Font Mono
Built using:

```
./FontForge-2020-11-07-21ad4a1-x86_64.AppImage --script $PWD/font-patcher "$PWD/src/unpatched-fonts/NerdFontsSymbolsOnly/NerdFontsSymbolsOnly Template 1000 em.ttf" --powerline --use-single-width-glyphs -out /tmp/nerd-fonts-out --fontawesome --fontawesomeextension --fontlinux --octicons --codicons --powersymbols --powerline --powerlineextra --mdi --weathericons
```

which is everything *except* Pomicons at the time of writing, pending
clarifications of its distribution license
(https://github.com/ryanoasis/nerd-fonts/issues/266)

refs: https://github.com/wez/wezterm/issues/1521
2022-01-16 16:04:35 -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
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
a9427aca63 Remove ALT-number default key assignments
The issue is that we work hard to match the keys pre-composition,
but for French and Norwegian layouts ALT-number are valid,
useful punctuation keys.  It's awkward to make exceptions for
ALT keys when matching assignments, especially on macOS, and
the simplest thing to do is simply to remove the assignments
and leave it to our users to add their own if they want them.

The ctrl-shift and cmd based assignments are generally much
easier to keep, because those key combinations are not widely
used default mappings on any keyboard layout.

refs: #1543
refs: #1542
refs: https://github.com/wez/wezterm/pull/1132
2022-01-14 22:24:40 -07:00
Wez Furlong
91f8a341dd input: ALT-<number> default keys are now post-mapping assignments
This resolves some issues with non-US layouts (French, Norweigan)
where ALT-number are important and useful punctuation that we were
otherwise blocking.

This new behavior seems consistent with eg: vte terminals on linux
when switching to a French layout.

refs: #1543
refs: #1542
2022-01-14 08:49:34 -07:00
Wez Furlong
b5dfbc392c make use_ime=true the default for all platforms
The key repeat issues that were blocking this from being enabled
on macos have been resolved.
2022-01-13 09:19:23 -07:00
Howard Huang
5b353df78e STYLE: Fix code format
Using `cargo fmt --all`
2022-01-12 17:01:38 -08: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
f48e2d9a85 SshDomain: assume_unix -> assume_shell = "Posix" 2022-01-10 08:27:09 -07:00
Wez Furlong
1357480ce6 SshDomain: add assume_unix option; enables setting cwd for new panes
If we know that the remote host is a unix system, and that it uses some
version of the posix shell, then we can adjust our command line to cd to
the requested directory (as set by OSC 7) and then exec the requested
command.

That's what SshDomain::assume_unix indicates and what this commit does.
2022-01-09 21:32:09 -07:00
Wez Furlong
b3987bec12 ssh: allow setting default_prog for SshDomain when multiplexing=None
```
return {
  ssh_domains = {
    {
      name = "woot",
      remote_address = "192.168.1.8",
      multiplexing = "None",
      default_prog = {"fish"},
    }
  },

  default_domain = "woot",
}
```

refs: https://github.com/wez/wezterm/issues/1456
2022-01-09 20:09:53 -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
f69177b022 ssh: allow setting SshDomain::use_multiplexer = false
Currently has no effect.

refs: #1456
2022-01-09 13:13:54 -07:00
Wez Furlong
42a13f63df cargo fmt 2022-01-09 11:12:14 -07:00