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

393 Commits

Author SHA1 Message Date
Wez Furlong
962e44bbfb WIP: fancier tab bar
`use_fancy_tab_bar` switches to an alternate rendering of the tab
bar that uses the window_frame config to get a proportional
title font to use to render tabs, as well as rendering a few
additional elements to space out and make the tabs feel more
like tabs.

Computing the number of tabs doesn't respect the alternate font
at this time.

Formatted tab item foreground and background colors are also
not respected at this time.

refs: #1180
2021-10-04 17:35:54 -07:00
Wez Furlong
ca89181098 bell: allow changing the cursor color when the bell is rung
I find this less distracting than both the audible and the default
background color flashing.
2021-09-29 08:02:34 -07:00
Wez Furlong
72cb110b65 add audible_bell config option
This allows using the system beep sound, currently only on macos.

refs: #3
2021-09-26 12:55:19 -07:00
Benoit de Chezelles
317772fe8f lua: Add wezterm.action_callback to help define key callbacks 2021-09-25 15:42:08 -07:00
Wez Furlong
0c1ad718d0 add visual bell
refs: #3
2021-09-25 12:40:22 -07:00
Frieder Bluemle
3f4ea691af Add additional tab activation key assignments 2021-09-12 09:52:11 -07:00
Wez Furlong
93e18b2a01 deps: colorgrad -> 0.5 2021-09-05 23:27:01 -07:00
Wez Furlong
4c8ccf8efc Add Multiple key assignment
refs: https://github.com/wez/wezterm/pull/1091
2021-09-04 13:01:34 -07:00
Wez Furlong
bc4ed3735d Add SendKey key assignment
refs: https://github.com/wez/wezterm/pull/1091
2021-09-03 12:07:17 -07:00
Wez Furlong
b53a6059de increase max fps to 60 by default, improve coalesce
* Trigger a paint immediately from invalidate if not throttled
* Otherwise defer the other events until we're about to sleep for xcb
  events, which should maximize the coalesce around resize/expose events

refs: #1051
2021-09-02 08:53:03 -07:00
Jonas Belouadi
703f2c4d67 Remove explicit deref in 256-colors loop. 2021-08-23 16:32:43 -07:00
Jonas Belouadi
4565fc4ebd Deserialize indexed keys into 'u8' instead of 'String'. 2021-08-23 16:32:43 -07:00
Jonas Belouadi
46ea5d73e7 Format code with cargo fmt. 2021-08-23 16:32:43 -07:00
Jonas Belouadi
4b3853fb0f Add support for setting arbitrary colors ranging from 16 to 256. 2021-08-23 16:32:43 -07:00
Wez Furlong
c6e1889b04 remove unused alt alpha blending config
This doesn't make sense in a dual source blending world
2021-08-19 09:41:48 -07:00
Wez Furlong
571c137955 gui: gamma fixup
This makes the comparison in https://github.com/wez/wezterm/issues/544
work for me on mac, linux (x11, wayland) and also on Windows but
only using WGL.

It looks like we can use the proper colorspace on all targets
except for ANGLE EGL.  For whatever reason, the combination of
glium and ANGLE EGL on windows over-gamma corrects.

AFAICT, the framebuffer and perhaps the surfaces it creates
don't indicate srgb support, and whatever combination of status
they return tickles glium's srgb stuff the wrong way.

I think the "solution" is just to directly use WGL by default.

EGL was on by default because it tended to be more survivable
when graphics card drivers were updated, but the last couple
of times I updated mine it still killed wezterm anyway.

refs: #544
2021-08-19 09:17:09 -07:00
Wez Furlong
ab21910d80 deps: update bitflags -> 1.3 2021-08-15 18:21:17 -07:00
Wez Furlong
ab6c4777cb config: add wezterm.gradient_colors 2021-08-13 23:52:32 -07:00
Wez Furlong
e234ea7933 gradients: add presets 2021-08-13 22:41:31 -07:00
Wez Furlong
615b5b3966 gui: support radial gradients 2021-08-13 17:38:33 -07:00
Wez Furlong
d9e0340a94 gui: add some randomness to gradients to avoid banding 2021-08-13 13:35:55 -07:00
Wez Furlong
cbfb6d59c5 added new window_background_gradient config option 2021-08-12 23:08:38 -07:00
Wez Furlong
6f78ee4f14 deps: update unicode-segmentation to 1.8 2021-08-11 23:06:17 -07:00
Wez Furlong
3370466dc4 config: adjust default mux_output_parser_buffer_size
This size seems to be ~sweet spot for `time cat bigfile`, cutting the
time in half from the prior value.  Making the buffer smaller doesn't
improve things, nor does making it bigger; this is balancing the latency
of applying the update to the model with the back-pressured parsing
latency.
2021-08-11 23:06:16 -07:00
Wez Furlong
8cc90dcf33 tidy up add_to_config_reload_watch_list
refs: #989
2021-08-10 20:38:41 -07:00
AusCyberman
e8e40c9704
Added watch_path (#989) 2021-08-10 20:30:43 -07:00
Wez Furlong
2b6ba0dfcc increase default mux_output_parser_buffer_size
refs: #999
2021-08-08 16:41:14 -07:00
Wez Furlong
17fc41fc52 add option to select alternative alpha blending
I'm not sure if this is needed now that we have a single draw call, but
based on the history and the nuance of different gl/driver/os quirks it
feels like a good idea to keep this option in the back pocket.
2021-08-04 15:26:48 -07:00
Wez Furlong
fb9338f0e7 default disable kitty graphics until support is improved
You can run `wezterm --config enable_kitty_graphics=true` to do ad-hoc
tests with the protocol enabled.

refs: #986
refs: #1998
2021-07-31 10:23:44 -07:00
Wez Furlong
159abe5e28 mux: make action parser buffer size configurable and smaller
Previously, we'd use a 1MB buffer both to read the output from the
associated pty (blocking), and the same size buffer again to do the
non-blocking read on top of that.

For pathological cases (eg: cat 100MB+ files), we could build a
resulting `Vec<Action>` with over 1mm entries and it could take as much
as 100ms to apply those actions to the terminal model.

This meant that the output could stutter/lag and appear to be processed
more slowly.

This commit introduces a configuration value for the buffer size for the
second stage, and makes it 10KB in size.  This helps to constrain the
size of the Action vec and keeps the incremental processing costs down,
while still managing the same throughput.
2021-07-31 08:57:13 -07:00
Autumn Lamonte
ce9d166733 #133 ENQ response 2021-07-24 23:36:20 -07:00
Autumn Lamonte
d8cacee28a #133 blinking text 50% 2021-07-24 23:29:31 -07:00
Wez Furlong
d592696ca7 config: capture the value of WSLENV, rather than its name
Doh!
2021-07-22 07:14:03 -07:00
Cédric Schieli
77261ac374 Allow styling of the whole new tab button 2021-07-18 19:11:12 -07:00
Wez Furlong
91b3c64568 config: update WSLENV to hold TERM related environment
refs: #230
refs: #936
2021-07-18 17:49:41 -07:00
Wez Furlong
1f5b900f3d plumb appearance change event -> reload on macos
This commit causes a window-config-reloaded event to trigger
when the appearance (dark/light mode) is changed on macos.

It also arranges to propagate the window level config to newly
spawned panes and tabs, created both via the gui and via the
CLI/mux interface.

refs: https://github.com/wez/wezterm/issues/894
refs: https://github.com/wez/wezterm/issues/806
2021-07-18 00:01:53 -07:00
Wez Furlong
75eaaab6a1 Allow window config overrides to apply per-pane
This allows window-level config overrides to apply
to panes contained within the window.

For instance, this allows setting a window-level
color scheme.
2021-07-17 23:02:41 -07:00
Wez Furlong
ac5199c216 config: add bypass_mouse_reporting_modifiers option
This allows changing eg: SHIFT to ALT for bypassing mouse reporting.

refs: https://github.com/wez/wezterm/issues/911
2021-07-11 22:02:23 -07:00
Wez Furlong
db6da81272 window: move away from async event queue
I added this originally thinking that it would make it easier to resolve
https://github.com/wez/wezterm/issues/695 and to integrate wgpu support,
but it's the cause of https://github.com/wez/wezterm/issues/922 so let's
take it out and more directly connect the window events to those in the
terminal.

This commit likely breaks mac and windows; pushing it so that I can
check it out and verify on those systems.
2021-07-10 17:30:19 -07:00
Wez Furlong
9c77d56026 RgbColor: hide internal red, green, blue fields
I'd like to adjust this to support 10bpc color, so the first step
is hiding the individual 8bpc fields.
2021-07-10 14:22:31 -07:00
Wez Furlong
423b208780 font weight can now be specified as the underlying opentype weight
opentype allows a font to have a weight in the range 0-1000.
MacOS has its own concept of symbolic weight names and opentype
values that is a slightly different scale of boldness to Windows
and Linux.

That means that Medium could be a different range of opentype
weight values depending on the system.

To further complicate things, the font designer can name their
variant with any name they like and assign it an arbitrary
opentype weight value.

For the Operator Mono font, it has Book variant with opentype
weight 325 and a Light variant with an opentype weight of 300.

wezterm was considering these both to have `FontWeight::Light` because
that's how those values were bucketed, which results in amibiguity in
resolve the font and frustration in not being able to access one of the
variants.

This commit changes the `FontWeight` type to now hold the unambiguous
opentype weight value, and to define some symbolic aliases for
some specified weights.

When serializing, if the weight matches a symbolic alias, then that
name will be used in the canonical name (eg: as listed via ls-fonts).
Otherwise, the numeric value will be used.

When parsing the font configuration, wezterm will allow both symbolic
and numeric values.

This allows all of the Operator Mono variants to be referenced
unambiguously, although some variants have to be specified via the
numeric weight:

```
wezterm.font("Operator Mono", {weight=275, stretch="Normal", italic=false}) -- /Users/wez/.fonts/OperatorMono-XLight.otf, FontDirs
wezterm.font("Operator Mono", {weight="Light", stretch="Normal", italic=false}) -- /Users/wez/.fonts/OperatorMono-Light.otf, FontDirs
wezterm.font("Operator Mono", {weight=325, stretch="Normal", italic=false}) -- /Users/wez/.fonts/OperatorMono-Book.otf, FontDirs
wezterm.font("Operator Mono", {weight="DemiLight", stretch="Normal", italic=false}) -- /Users/wez/.fonts/OperatorMono-Medium.otf, FontDirs
wezterm.font("Operator Mono", {weight="Regular", stretch="Normal", italic=false}) -- /Users/wez/.fonts/OperatorMono-Bold.otf, FontDirs
```

https://github.com/wez/wezterm/issues/849#issuecomment-873454483
2021-07-04 08:55:08 -07:00
Wez Furlong
c514254138 wayland: use proportional font for title bar
allow specifying the font in the config file
2021-06-27 13:04:20 -07:00
Wez Furlong
ca8209b230 wayland: move frame color config to the config file
This simplifies it a bit and exposes the config via the config file;
the following options are possible, each one specifies a color

```lua
return {
  window_frame = {
    inactive_titlebar_bg = "",
    active_titlebar_bg = "",
    inactive_titlebar_fg = "",
    active_titlebar_fg = "",
    inactive_titlebar_border_bottom = "",
    active_titlebar_border_bottom = "",
    button_fg = "",
    button_bg = "",
    button_hover_fg = "",
    button_hover_bg = "",
  }
}
```

refs: https://github.com/wez/wezterm/issues/761
2021-06-27 12:33:56 -07:00
Wez Furlong
f752d0e7ac set COLORTERM=truecolor in the environment
closes: https://github.com/wez/wezterm/issues/875
2021-06-15 19:34:31 -07:00
Wez Furlong
3ea030794b memoize the renderer used for termwiztermtab and custom tab bars
Create only one, then just clone as needed.

refs: #817
2021-06-13 09:06:29 -07:00
Wez Furlong
cc19aaca9f revise skip_close_confirmation_for_processes_named for Windows
closes: #843
2021-06-10 07:39:00 -07:00
Wez Furlong
cb4da18021 key assignment and docs for ShowDebugOverlay
refs: https://github.com/wez/wezterm/issues/641
2021-05-30 19:56:11 -07:00
Wez Furlong
e29fdae3b9 dead code: remove old FontHinting, FontAntialiasing bits 2021-05-22 15:04:42 -07:00
Wez Furlong
9b082edb8d log errors when a color scheme fails to load
refs: https://github.com/wez/wezterm/issues/794
2021-05-15 13:39:31 -07:00
Wez Furlong
58157c47a9 config: can now subscribe to config change events
This removes a couple of periodic config polls

refs: https://github.com/wez/wezterm/issues/770
2021-05-08 11:06:07 -07:00
Chris
2add312c5c
Allow VoidSymbol keycode to be seen by wezterm (#759)
* allow voidsymbol for key code

* update docs, cleanup

* cleanup and fmt of files

* remove unnecessary inputs
2021-05-07 07:54:24 -07:00
Wez Furlong
0e9d86f9f9 lua: print -> log_info
Make print equivalent to log_info.
Improve the various log functions so that all of their arguments
are considered.

refs: https://github.com/wez/wezterm/issues/641
2021-05-03 09:19:52 -07:00
Wez Furlong
09f0421b48 add lua repl to the debug overlay
`wezterm` is pre-imported.
The repl prints the result of the expressions to the overlay.

refs: https://github.com/wez/wezterm/issues/641
2021-05-03 09:19:44 -07:00
Wez Furlong
8b71a57513 add debug overlay
Adds a `ShowDebugOverlay` key assignment that will create a tab
overlay that shows a limited number of recently logged events.

refs: https://github.com/wez/wezterm/issues/641
2021-05-03 09:19:38 -07:00
Wez Furlong
b5f6a79520 add nushell to list of shells 2021-05-01 19:50:31 -07:00
Wez Furlong
82d825ab37 split padding out from truncation
This makes these functions a bit more composable!

Heads up @jankatins; this is a breaking change (for the better!)

refs: https://github.com/wez/wezterm/issues/647
2021-05-01 18:26:53 -07:00
Wez Furlong
8880979586 Adjust font scaling math again
This commit introduces the knowledge about whether a font is
scalable or was using bitmap strikes (eg: color emoji bitmaps).

Then that information is used to help figure out whether and
how to scale a glyph.

refs: https://github.com/wez/wezterm/issues/685
2021-05-01 16:45:57 -07:00
Wez Furlong
9ccdc157a7 fonts: search locator for fallbacks first
Also add an option to control whether we look in font_dirs for fallback.
Previously we would, but it could lead to some surprising fallback
choices.

The default now is to search locator then built-in.

refs: https://github.com/wez/wezterm/issues/685
refs: https://github.com/wez/wezterm/issues/727
2021-05-01 16:45:57 -07:00
Wez Furlong
35eb7383b1 ci: simplify version number
Previously, we used `git describe --tags` to produce a version number
for non-released builds derived from the most recent tag + some info
such as the number of commits since that tag and then `g{HASH}`.

That always confuses people because the date portion at the front
looks old (it is typically the previous release) and the hash at
the end has that `g` in it.

This commit simplifies both the tag name used when making a release
and the computed version number take the date/time from the current
commit, and then append the hash.  That way the version number always
corresponds to a commit.

This scheme doesn't help detect situations where the commit is
dirty, but I don't think the old one would have helped with that
either.
2021-04-29 20:23:47 -07:00
Wez Furlong
c4dc358282 add truncate_left_to_width
refs: #647
2021-04-27 06:23:19 -07:00
Wez Furlong
7e996950f6 add wezterm.truncate_to_width
refs: https://github.com/wez/wezterm/issues/647
2021-04-26 22:27:12 -07:00
Wez Furlong
be9c60bfc8 removed tab_bar_style options in favor of format-tab-title
refs: https://github.com/wez/wezterm/issues/647
2021-04-26 20:16:47 -07:00
Wez Furlong
0f2f3734d9 add wezterm.column_width
refs: https://github.com/wez/wezterm/issues/647
2021-04-26 20:10:27 -07:00
Wez Furlong
3028756ccb add tab_bar_at_bottom config option
closes: https://github.com/wez/wezterm/issues/278
2021-04-25 20:49:48 -07:00
Wez Furlong
8ce376753f round out quick select mode
* Make alphabet and patterns configurable
* add docs
* Enhance scrollback search to support regex captures so that
  searching for eg: `fo(o)` will select the last `o` in `foo`.

refs: https://github.com/wez/wezterm/issues/732
2021-04-25 16:27:39 -07:00
Wez Furlong
5b1631fe21 add quickselect overlay
This is the first pass implementation, drawing on the alphabet logic
and default patterns from tmux-thumbs (thanks @fcsonline!).

ctrl-shift-space pops up the quick select overlay.
Typing the highlighted prefix will select the matching text and
copy it as though the `Copy` key assignment was used.

TODOs are to make the alphabet and patterns configurable, as well
as write up some docs.

refs: #732
2021-04-25 11:52:14 -07:00
Wez Furlong
053cb11e9f improve ssh domain support for ssh_config
This tidies up how we pass the ssh config to the connection ui
logic, by moving the ssh_config setup to the two callers.

A couple of notable adjustments:

* SshDomain::username is now optional; it will default to the
  values computed by the ssh config file loader
* no_agent_auth value wasn't hooked up to anything, but now it is

refs: https://github.com/wez/wezterm/issues/730
2021-04-24 21:56:32 -07:00
Wez Furlong
2c89e47f9e add force_reverse_video_cursor option
refs: https://github.com/wez/wezterm/issues/706
2021-04-24 21:16:58 -07:00
Wez Furlong
e3fcdc9f36 add format-window-title event
This provides a flexible way for users to customize what gets
shown in the window title bar.

closes: https://github.com/wez/wezterm/pull/603
2021-04-24 16:47:26 -07:00
Wez Furlong
e83d059fc7 couple of build tweaks for git versioning and macos build perf 2021-04-23 23:29:43 -07:00
Wez Furlong
d705886b53 Add pane_focus_follows_mouse
closes: https://github.com/wez/wezterm/issues/600
2021-04-23 22:17:33 -07:00
Wez Furlong
657ed92d82 add swallow_mouse_click_on_pane_focus option
refs: https://github.com/wez/wezterm/issues/724
2021-04-23 22:17:06 -07:00
Wez Furlong
76353a6240 fix: InputMap reading global config instead of window overrides
refs: #656
2021-04-16 08:59:49 -07:00
Wez Furlong
1b12b0a23d fonts: improve font_rules behavior
We now always append the synthetic rules to the those in the config,
and include rules for generating half-bright font selection.
2021-04-15 09:43:24 -07:00
Wez Furlong
776aedf97e fonts: allow specifying weight/stretch/italic for each fallback font 2021-04-12 22:30:55 -07:00
Wez Furlong
5ced58c37b Allow disabling re-sorting fallback fonts
The system locator may have a reasonable default ordering
in its list of fallbacks.

refs: #685
2021-04-12 08:03:17 -07:00
Wez Furlong
406d1044fa fonts: restore messaging about missing glyphs
Now that all platforms know whether the system fallbacks
covered the requested glyph range, it is reasonable to
restore the configuration error window to advise the user
if they are missing fonts for the text they want to display.

refs: https://github.com/wez/wezterm/issues/671
2021-04-10 21:35:58 -07:00
Wez Furlong
99fc3ee3cd fonts: rename width/FontWidth to stretch/FontStretch
This terminology is consistent with that used in CSS to describe
this same property of the font.
2021-04-09 12:00:18 -07:00
Wez Furlong
4c1de197bd fonts: use ParsedFont rather than FontDataHandle
This can avoid extraneous parses in a few cases.
2021-04-08 17:11:23 -07:00
Wez Furlong
ecc500af05 ssh: don't override the ssh config User value 2021-04-08 16:17:49 -07:00
Wez Furlong
43ea2f192a Allow matching font weight and font width in wezterm.font
refs: https://github.com/wez/wezterm/issues/655
2021-04-08 15:42:53 -07:00
Wez Furlong
a6ebae3be2 refine reduce_first_font_to_family 2021-04-07 23:48:49 -07:00
Wez Furlong
b03300404a Allow specifying distinct load and render targets
refs: https://github.com/wez/wezterm/issues/639
2021-04-07 12:15:03 -07:00
Wez Furlong
d7c7c27203 config: distinguish between fallback and synthesized fonts
refs: #648
2021-04-05 08:59:24 -07:00
Wez Furlong
b63a949df8 config: fix wezterm.config_dir, add wezterm.config_file
refs: https://github.com/wez/wezterm/discussions/635#discussioncomment-567968
2021-04-04 08:53:50 -07:00
Wez Furlong
fe48951e7a macos: fixup SUPER+SHIFT+[ key decoding
One of the default key assignments was registered as `SUPER+SHIFT+{`
which worked on macOS, but on Linux, would never match because the
keypress over there was (correctly) reporting as `SUPER+{`.

I originally thought that the user reported issue was a linux
normalization problem, but in looking deeper, the issue is really
that macos is doing something funky!

On macos we collect the interpreted key event as a string, and also
the interpretation of that event without any modifiers applied.

For letters this means that eg: `ALT-l` reports as `¬` for the
processed string and `l` for the unmodified string.  That's good!

However, for punctuation we get a backwards result: SUPER+SHIFT+[
produces `[` for the processed text and `{` for the unmodified
text!

This commit tries to detect this, using a heuristic that is
potentially bad on non-US layouts: if both the processed and
unmodified strings are punctuation then we bias to the unmodified
version.

With that change, that key press is correctly reported as `SUPER+{`,
and we can fix the key assignment registration to reflect that.

I quickly checked the behavior of pressing that same physical key
combination with a DEU layout active, and it appears that the unmodified
stuff is also flipped there; we get a lower-case version of something
that I think should be uppercase.  This commit doesn't change that
behavior:

```
key_event KeyEvent { key: Char('ü'), modifiers: NONE,
        raw_key: Some(Char('Ü')),
        raw_modifiers: SHIFT | SUPER,
        raw_code: Some(33),
        repeat_count: 1, key_is_down: true }
```

refs: https://github.com/wez/wezterm/issues/601
2021-04-03 06:32:13 -07:00
Wez Furlong
47e62cc243 Avoid confusing error when the font has no bold/italic variant
refs: https://github.com/wez/wezterm/issues/617
2021-04-02 17:59:27 -07:00
Alex Gartrell
ee4b4b598c Add ActivateLastTab command
This replicates `last-window` in tmux. To pull this off, I
deliberately store the last tab whenever I'm activating a new one or
spawning a new one. I had to do this explicitly rather than hooking
set_active, because we end up setting the active tab briefly for some
common operations like moving a tab.
2021-04-02 09:14:59 -07:00
Wez Furlong
64236c6216 clippy 2021-03-26 09:03:28 -07:00
Wez Furlong
2902a76c5c lint: fix some clippy stuff 2021-03-25 10:05:34 -07:00
Wez Furlong
3bec6fb5c0 lint: remove redundant semicolons
Newer versions of Rust emit warnings for these
2021-03-25 09:44:27 -07:00
Wez Furlong
ad4b3b4648 add skip_close_confirmation_for_processes_named option
Currently only respected on linux.

refs: https://github.com/wez/wezterm/issues/562
2021-03-22 12:42:46 -07:00
Wez Furlong
b27e4ce2b2 keys: CMD-Q for QuitApplication is now a default on macos 2021-03-22 11:43:53 -07:00
Wez Furlong
22522dc39e render more symbol/icon/emoji at double width by default
Default `allow_square_glyphs_to_overflow_width="WhenFollowedBySpace"`,
and expand its meaning from mostly square glyphs to glyphs that are
also wider than they are tall.

refs: https://github.com/wez/wezterm/issues/565
2021-03-22 11:36:45 -07:00
Wez Furlong
57f1aa2785 fixup build to not consider termwiz tags as wezterm tags
CI got broken by the termwiz release.  This commit teaches the
various `git describe --tags` calls to filter to the wezterm
tags which all start with the year.  We're match `20*` which should
be good for the next 79 years.

I've removed the vergen dependency as there was no way to teach it
to do the equivalent matching, and it wasn't a terrible burden
to just inline the git describe call anyway.
2021-03-17 21:02:03 -07:00
Wez Furlong
eb4323ee59 add config for customizing the tabs and new tab button
```lua
local wezterm = require 'wezterm';

-- The filled in variant of the < symbol
local SOLID_LEFT_ARROW = utf8.char(0xe0b2)

-- The filled in variant of the > symbol
local SOLID_RIGHT_ARROW = utf8.char(0xe0b0)

return {
  tab_bar_style = {
    active_tab_left = wezterm.format({
      {Background={Color="#0b0022"}},
      {Foreground={Color="#2b2042"}},
      {Text=SOLID_LEFT_ARROW},
    }),
    active_tab_right = wezterm.format({
      {Background={Color="#0b0022"}},
      {Foreground={Color="#2b2042"}},
      {Text=SOLID_RIGHT_ARROW},
    }),
    inactive_tab_left = wezterm.format({
      {Background={Color="#0b0022"}},
      {Foreground={Color="#1b1032"}},
      {Text=SOLID_LEFT_ARROW},
    }),
    inactive_tab_right = wezterm.format({
      {Background={Color="#0b0022"}},
      {Foreground={Color="#1b1032"}},
      {Text=SOLID_RIGHT_ARROW},
    }),
  }
}
```
2021-03-11 21:22:10 -08:00
Wez Furlong
f6c37ae371 increase default font size to 12 points 2021-03-10 19:43:02 -08:00
Wez Furlong
fa9cf66fa2 Add file:// to the default implicit hyperlink rule list
closes: https://github.com/wez/wezterm/issues/525
2021-03-09 07:43:33 -08:00
Benoit de Chezelles
683d8e96e8 windows: Add option to treat left ctrl-alt as altgr
The previous behavior was to always treat ctrl-alt as altgr on Windows,
this has been done to better support altgr through a VNC session,
but this is very unintuitive when you don't need this behavior.

ref: #472
2021-03-07 12:52:03 -08:00
Wez Furlong
8fd515d6fa fix typo in battery state value 2021-03-07 00:22:27 -08:00
Wez Furlong
336f209ede Revert and gate shaping changes
I'm calling it a temporary defeat on the shaping changes;
this commit effectively reverts the series of changes made
to support slicing up ligatures like `->` when the cursor
moves through them.

They've introduced so many issues and I've spent hours
that haven't resulted in a complete solution, so I've
disabled those changes by putting them behind a boolean
option.

I'll revisit them after I've cut the next release.

refs: https://github.com/wez/wezterm/issues/478
2021-03-06 23:49:37 -08:00
Wez Furlong
e992ac7ad0 lua: add wezterm.battery_info() function
Queries the system battery information and returns an array of
battery information.

Each element is a lua table with the following entries:

* state_of_charge: expressed as percents
* vendor: the battery manufacturer
* model: the battery model
* serial: the battery serial number
* time_to_full: how long until the battery is full
* time_to_empty: how long until the battery is empty
* state: "Charging", "Discharging", "Empty", "Full", "Unknown"

I haven't run this on a system with a battery yet, so I'm holding
off from showing an example until I've got a work one.

refs: https://github.com/wez/wezterm/issues/500
2021-03-06 14:25:36 -08:00
Wez Furlong
1178639a22 windows: implement decoration setting, change to bitfield
Can now set `window_decorations = "TITLE|RESIZE"` or variations
on those flags.  `NONE` is a shortcut for no flags.
2021-03-04 09:40:38 -08:00
Wez Furlong
945b6b726f windows: allow disabling titlebar, fixup dragging 2021-03-04 08:37:29 -08:00
Wez Furlong
7e1d16e671 Add SUPER+Drag to drag the window 2021-03-03 23:45:02 -08:00
Wez Furlong
4834a29791 macos: support disabling the titlebar
This isn't fully baked yet, so I'm not documenting it yet.
2021-03-03 22:47:31 -08:00
Wez Furlong
9ac230876c Add status_update_interval option for status updates
The status event is triggered at window creation, and
then every `status_update_interval` milliseconds.

refs: https://github.com/wez/wezterm/issues/500
2021-03-02 20:44:08 -08:00
Wez Furlong
ff8bda29e3 lua: add wezterm.strftime
refs: https://github.com/wez/wezterm/issues/500
2021-03-02 09:52:54 -08:00
Wez Furlong
565a4c69d5 lua: add wezterm.format function
The intent is to use this to compose text for a configurable tab bar.

refs: https://github.com/wez/wezterm/issues/500
2021-03-02 09:52:54 -08:00
Wez Furlong
62e14efcb3 lua: add log_info and log_warn 2021-03-02 09:52:54 -08:00
Wez Furlong
1415e9ce4d ci: fixup build on macos where --target is in use 2021-02-28 18:51:09 -08:00
Wez Furlong
d56c5178da shaping: add test for FiraCode
Adds a test and seemingly a fix for https://github.com/wez/wezterm/issues/478#issuecomment-787520977

Fira Code is OFL-1.1 licensed like the other fonts we include,
however, I'm not distributing Fira Code with wezterm.
2021-02-28 13:35:00 -08:00
Wez Furlong
522d4ad814 make exit_behavior = "CloseOnCleanExit" the default
It seems generally useful and non-intrusive, so do that.
2021-02-28 12:01:07 -08:00
Wez Furlong
0597684ebd Render custom block glyphs
As explained in the docs included in this commit, ideally this
wouldn't be needed, but due to a long-standing hinting bug in
freetype <https://gitlab.freedesktop.org/freetype/freetype/-/issues/761>
it seems most expedient to just render our own block glyphs,
so that's what this does!

refs: #433
2021-02-28 09:43:26 -08:00
Wez Furlong
db08b8c1dc add window:set_config_overrides lua method
This commit expands on the prior commits to introduce the concept
of per-window configuration overrides.

Each TermWindow maintains json compatible object value holding
a map of config key -> config value overrides.

When the window notices that the config has changed, the config
file is loaded, the CLI overrides (if any) are applied, and then
finally the per-window overrides, before attempting to coerce
the resultant lua value into a Config object.

This mechanism has some important constraints:

* Only data can be assigned to the overrides.  Closures or special
  lua userdata object handles are not permitted.  This is because
  the lifetime of those objects is tied to the lua context in which
  they were parsed, which doesn't really exist in the context of
  the window.
* Only simple keys are supported for the per-window overrides.
  That means that trying to override a very specific field of
  a deeply structured value (eg: something like `font_rules[1].italic = false`
  isn't able to be expressed in this scheme.  Instead, you would
  need to assign the entire `font_rules` key.  I don't anticipate
  this being a common desire at this time; if more advance manipulations
  are required, then I have some thoughts on an event where arbitrary
  lua modifications can be applied.

The implementation details are fairly straight-forward, but in testing
the two examplary use cases I noticed that some hangovers from
supporting overrides for a couple of font related options meant that the
window-specific config wasn't being honored.  I've removed the code that
handled those overrides in favor of the newer more general CLI option
override support, and threaded the config through to the font code.

closes: #469
closes: #329
2021-02-27 14:53:19 -08:00
Wez Furlong
60be1a98a0 lua: add window::effective_config() method
Expose the current window configuration to lua scripts.

refs: https://github.com/wez/wezterm/issues/469
2021-02-27 12:39:22 -08:00
Wez Furlong
2d02df5f38 add --config name=value CLI options
`wezterm`, `wezterm-gui` and `wezterm-mux-server` now all support
a new `--config name=value` CLI option that can be specified
multiple times to supply config overrides.

Since there isn't a simple, direct way to update arbitrary fields
of a struct in Rust (there's no runtime reflection), we do this
work in lua.

The config file returns a config table. Before that is mapped
to the Rust Config type, we have a new phase that takes each
of the `--config` values and applies it to the config table.

For example, you can think of configuration as working like this
if wezterm is started as `wezterm --config foo="bar"`:

```lua
config = load_config_file();
config.foo = "bar";
return config;
```

The `--config name=value` option is split into `name` and `value`
parts.  The name part is literally concatenated with `config` in
the generated lua code, so the name MUST be valid in that context.
The `value` portion is literally inserted verbatim as the rvalue in the
assignment.  Not quoting or other processing is done, which means
that you can (and must!) use the same form that you would use in
the config file for the RHS.  Strings must be quoted.  This allows
you to use more complicated expressions on the right hand side,
such as:

```
wezterm --config 'font=wezterm.font("Fira Code")'
```

The overrides stick for the lifetime of the process; even if
you change the config file and reload, then the value specified
by the override will take precedence.

refs: https://github.com/wez/wezterm/issues/469
refs: https://github.com/wez/wezterm/issues/499
2021-02-27 10:53:45 -08:00
Wez Furlong
697a6abd04 add exit_behavior config option
`exit_behavior = "Hold"` will keep the pane alive until explicitly
closed.  More details in the docs that are part of this commit.

refs: https://github.com/wez/wezterm/issues/499
2021-02-27 00:15:51 -08:00
Wez Furlong
181ed704c9 docs for freetype_load_target and deprecation of font_antialias
refs: #491
2021-02-23 08:49:46 -08:00
Wez Furlong
c964b69b1d Add ScrollByLine key assignment
refs: #497
2021-02-23 08:02:07 -08:00
Wez Furlong
01f587d1d0 fixup tests for macos
refs: #478
2021-02-22 20:38:24 -08:00
Wez Furlong
ee17e4e174 Add shaper post-processing function
This function is intended to deal with certain kinds of ligatures
and certain combining sequences that don't have corresponding glyphs.

It isn't hooked up to the gui yet, but does have unit tests that
are probably mostly correct.

refs: https://github.com/wez/wezterm/issues/478
2021-02-22 19:17:24 -08:00
Wez Furlong
1bbe594354 allow specifiying font size as an integer
This trips me up every so often, so it seems worth making this
a bit easier.
2021-02-22 12:07:11 -08:00
Wez Furlong
2ffcd08eda config: remove hard coded fallback fonts on macos and windows
We don't need these now that we know how to ask the system to
resolve fallbacks for specific glyphs.
2021-02-20 23:41:14 -08:00
Wez Furlong
7a16e71e07 Add ResetFontAndWindowSize key assignment
closes: https://github.com/wez/wezterm/issues/480
2021-02-20 21:50:20 -08:00
Wez Furlong
dd70a8a53b introduce freetype_load_flags and freetype_load_target config
In the earlier times wezterm supported different font rasterizers,
and the configuration was a bit vague and generic to accomodate
differences in how the rasterizers worked.

Since then, we've standardized on freetype.

One of the things that's been bothering me for a while is that
we have some fiddly logic to transform from the config to the freetype
flags.

This commit does away with the transformation and simply exposes
the two sets of freetype options.

The main thing that I expect people to play with is
`freetype_load_target` which can have one of the following values:

```
pub enum FreeTypeLoadTarget {
    /// This corresponds to the default hinting algorithm, optimized
    for standard gray-level rendering.
    Normal,
    /// A lighter hinting algorithm for non-monochrome modes. Many
    generated glyphs are more fuzzy but better resemble its original
    shape. A bit like rendering on Mac OS X.  This target implies
    FT_LOAD_FORCE_AUTOHINT.
    Light,
    /// Strong hinting algorithm that should only be used for
    monochrome output. The result is probably unpleasant if the glyph
    is rendered in non-monochrome modes.
    Mono,
    /// A variant of Normal optimized for horizontally decimated LCD displays.
    HorizontalLcd,
    /// A variant of Normal optimized for vertically decimated LCD displays.
    VerticalLcd,
}
```

I expect most people will want to set this to one of `Normal`, `Light`
or `HorizontalLcd`.  `HorizontalLcd` is what `font_antialias=Subpixel`
used to select.

refs: #491
2021-02-20 14:00:38 -08:00
Wez Furlong
08b6043166 gui: introduce foreground_text_hsb transform
This allows explicitly manipulating the hue, saturation, brightness
of the text rendered in the terminal, allowing users to dial in
the accidental effect that was introduced by
d886de8300

For example, this will punch up the brightness:

```
  foreground_text_hsb = {
    hue = 1.0,
    saturation = 1.0,
    brightness = 1.5,
  },
```

refs: https://github.com/wez/wezterm/issues/491
2021-02-19 08:30:32 -08:00
Benoit de Chezelles
c576b9d534
Add cli option --config-file (#459)
* Add cli option --config-file
* Update cli arg doc & make it conflict with skipping config
* When the config is given explicitly (either using --config-file or via WEZTERM_CONFIG_FILE), failing to load this file will use the default config.
* Otherwise the config file is searched one by one in a few directories.
2021-02-07 08:47:33 -08:00
Wez Furlong
70cb992924 config: improve font_rule synthesis
This should help to avoid frustration for minor config issues.

closes: https://github.com/wez/wezterm/issues/456
2021-02-06 08:23:22 -08:00
Benoit de Chezelles
808ea8c8c4 Remove unnecessary Result in config 2021-02-05 18:51:14 -08:00
Wez Furlong
b6d85f941d config: set speculative default pixel dims for initialize size
A bit gross. Details in the comments added by this commit.
2021-02-02 09:08:50 -08:00
Wez Furlong
df3387e12c wezterm: change default copy/paste behavior on X11
This commit changes mouse-based selection and middle click to use the
PrimarySelection.

CTRL-SHIFT-{C,V} use Clipboard.

{SHIFT,CTRL}-Insert use PrimarySelection.

`CompleteSelection` and `CompleteSelectionOrOpenLinkAtMouseCursor` now
require a parameter to specify the destination clipboard.

Removed the `default_clipboard_XXX` options added in
8dad34fa61 in favor of just explicitly
assigning the key/mouse bindings.

closes: #417
2021-01-31 09:28:42 -08:00
Wez Furlong
d10f7bbb1b wezterm: add alternate_buffer_wheel_scroll_speed option and increase to 3
More details in the included docs.

closes: #432
2021-01-30 10:14:01 -08:00
Wez Furlong
8dad34fa61 more configuration options for Copy/Paste
* Adds `CopyTo` and `PasteFrom` assignments that specify the
  destination/source.
* Adds `default_clipboard_copy_destination` and `default_paste_source`
  config options that specify the default destination/source for
  existing `Copy` and `Paste` operations (for @bew)
* Deprecating `PastePrimarySelection` in favor of `PasteFrom`.
* Added `CTRL-Insert` -> `Copy` (for @Babar)

Aside from the new key assignment, these changes shouldn't change
the default behavior, but do make it easier to consider changing
that in a later commit.

They should allow for example:

* Set `default_clipboard_copy_destination = "PrimarySelection"` to
  prevent populating the clipboard by default when using the mouse.
* Overriding the CTRL-Insert, CTRL-SHIFT-C to explicitly populate
  the clipboard
* Set `default_paste_source = "PrimarySelection"` for middle click
  to paste the selection.
* Overriding SHIFT-Insert, CTRL-SHIFT-V to explicitly paste from
  the clipboard.

refs: #417
2021-01-27 10:20:17 -08:00
Dylan Frankland
3793ff2587
Add config option to specify default current working directory (#438)
* Add config option to specify default current working directory

* Make `cwd` of CLI take precedence over `default_cwd`

* Update docs for `default_cwd` and Launching Programs

Explains the `default_cwd` property more succinctly on the `Config` struct.

Adds documentation on the various ways to set the working directory and the logic used to decide the working directory.
2021-01-26 10:40:22 -08:00
Dylan Frankland
88f44f5b5f
Add erase mode to ClearScrollback action (#439)
* Add ClearBuffer action

Clears all lines, both visible and those scrolled off the top of the viewport, making the prompt line the new first line and resetting the scrollbar thumb to the full height of the window.

This is the behavior that Hyper / xterm has for clearing the terminal.

* Combine ClearBuffer into ClearScrollback as enum with associated erase mode

Makes it easier to manage the different options of clearing the terminal.
2021-01-25 21:26:23 -08:00
Wez Furlong
89c1ac5b4c wezterm: add adjust_window_size_when_changing_font_size option
The default is true, which means that adjusting the font size will
cause the window to resize to preserve the number of rows/cols in
the terminal.

When set to false, the window size is preserved and the number of
terminal rows/cols is adjusted instead.

refs: https://github.com/wez/wezterm/issues/431
2021-01-18 13:23:02 -08:00
Wez Furlong
f39c4f9d6e deps: update to mlua 0.5 2021-01-13 10:06:35 -08:00
Wez Furlong
db0d54cf44 Take care to restore the original umask
wezterm sets a more restrictive umask (`0o077`) by default so that any files
that it creates (eg: unix domain socket, log files) are more secure
by default.

However, some environments rely on the more general default of (`0o022`)
without checking that it is set.

This matters because programs spawned by wezterm inherit its more
restricted umask.

I hadn't noticed this because I've had `umask 022` in my shell RC files
since sometime in the 1990's.

This commit adds some plumbing to the pty layer to specify an optional
umask for the child process, and some more to our umask saver helper
so that any thread can determine the saved umask without needing a
reference to the saver itself, which may be in a different crate.

The logic in the config crate has been adjusted to connect the saved
value to the default command builder arguments.

The net result of this is that running `wezterm -n start bash -- --norc`
and typing `umask` in the resultant window now prints `0022`.

refs: #416
2021-01-07 09:20:13 -08:00
Wez Furlong
154ab20d0e wezterm-gui: we now start an implicit unix mux server
When running the GUI, we generate a unix domain socket path for
the current process and start up a mux server for that path.

This allows `wezterm cli list` and `wezterm cli split-pane` to
work implicitly inside the GUI session.

When started in this way, the mux server is not persistent;
when the GUI process is terminated, all of its windows, tabs
and panes are terminated.

refs: https://github.com/wez/wezterm/issues/230
2020-12-29 15:58:39 -08:00
Wez Furlong
6578d657b3 add ` to the default selection_word_boundary config 2020-12-29 11:34:55 -08:00
Wez Furlong
da55e12b5e Add selection_word_boundary configuration option
refs: https://github.com/wez/wezterm/issues/405
2020-12-28 14:13:25 -08:00
Wez Furlong
d302f82335 window+gui: macOS: add native_macos_fullscreen_mode option
Defaults to false.  If set to true, the ToggleFullScreen action
prefers native macOS fullscreen mode.

refs: https://github.com/wez/wezterm/issues/177
2020-12-27 22:34:31 -08:00
Wez Furlong
e7677aa212 suppress updater window
The new banner is less intrusive; it doesn't steal focus
and for users that have multiple wezterm processes, doesn't show
one per process.

So let's turn off the updater window.  I'm considering moving the
"smart" upgrade links into a helper subcommand, but that's for
another diff.
2020-12-26 19:17:17 -08:00
Wez Furlong
5787bdff53 wezterm: closing a window now prompts for confirmation by default
Adds `window_close_confirmation = "AlwaysPrompt"` as the default
configuration.  Can be set to `NeverPrompt` to disable prompting.
2020-12-23 09:58:38 -08:00
Wez Furlong
2356be0cc2 fonts: default to Greyscale antialiasing
The font rendering changes make Subpixel look a bit anemic in
comparison to prior releases, so let's make the default Greyscale.
2020-12-22 10:09:06 -08:00
Wez Furlong
3d37b4a956 fix Option key combinations on macos
61c52af491 accidentally broke key
assignments that included ALT on macOS (and perhaps others?) because
LEFT_ALT or RIGHT_ALT were also now being passed through to the
keymap lookup, preventing a direct match.
2020-12-21 22:09:34 -08:00
Wez Furlong
979368c4eb font: add freetype_interpreter_version configuration option
This defaults to None, taking the default from the freetype library.
You can select an integer value to tell the library to use an
alternative version.

Versions that are available in the build used by wezterm are 35, 38 and
40.

See https://freetype.org/freetype2/docs/subpixel-hinting.html for
more information.
2020-12-21 09:15:13 -08:00
Wez Furlong
0ae494fb94 config: add line_height config option
The default is 1.0.  `line_height` is used to scale the effective
cell height, increasing the amount of space between font baselines.

refs: https://github.com/wez/wezterm/discussions/387
2020-12-20 14:33:18 -08:00
Wez Furlong
e3f91afeda config: avoid storing default color schemes in config object
This helps keep the config object a bit smaller and the trace logging
output less verbose.

We now memoize the effective palette in the config, which should shave
off a little bit of time in the renderer.
2020-12-19 10:08:41 -08:00
Wez Furlong
2603f9d4b4 fixup mux output processing
in ab342d9c46 I started to rearrange how
the output processing thread works.  It wasn't quite right, so this
commit tidies things up.

The main change here is that there is now back-pressure from the output
parser on the reader; if it is taking a while to parse the output then
we don't buffer up so much input.

This makes operations like `find /` followed immediately by `CTRL-C`
more responsive.

With this change, I don't feel that the
`ratelimit_output_bytes_per_second` option is needed any more, so it
has been removed.
2020-12-12 08:53:45 -08:00
Wez Furlong
eb83f28810 deps: dirs -> dirs_next
I saw that former is unmaintained, and dependabot wants
to upgrade that one.
2020-12-10 10:08:49 -08:00
Wez Furlong
694fec0d5d wezterm: normalize configured keys
To avoid confusing behavior, normalize the configured keys
in the same way that we normalize key presses.

In other words, this:

```lua
{
  key = "y",
  mods = "CTRL|SHIFT",
  action = "Copy",
}
```

is treated as if you wrote:

```lua
{
  key = "Y",
  mods = "CTRL",
  action = "Copy",
}
```

refs: https://github.com/wez/wezterm/issues/372
2020-12-09 17:17:20 -08:00
Wez Furlong
22b4e99c82 tidy up default_dpi vs DEFAULT_DPI
This commit breaks the dependency from config -> window,
which in turn breaks the dependency from mux-server -> x11 libs
on linux.
2020-12-09 13:48:23 -08:00
Wez Furlong
c6334a45dd extract window::input to wezterm-input-types 2020-12-09 13:48:23 -08:00
Wez Furlong
2888428dda wezterm-font: add system font fallback on macOS
Teach the core text locator how to obtain the system fallback list
and add that to the fallback.

Fixup handling of ttc files on macOS; we'd always assume index 0
when extracting font info from the font descriptor.  We now make
the effort to enumerate the contents of the TTC and find a match.
2020-12-06 22:23:39 -08:00
Wez Furlong
92827a1bea wezterm: default dpi on macOS is now 72
https://wiki.lazarus.freepascal.org/Cocoa_DPI states that the dpi
on macOS is 72.  That matches up to the experimental results reported
in #332 (in which 74.0 appears about the right size).

This commit introduces a `DEFAULT_DPI` constant that is set to 72 on
macOS and 96 on other operating systems.

The result of this is that a 10 point Menlo font now appears to be
the same size in Terminal.app and WezTerm.app.

refs: https://github.com/wez/wezterm/issues/332
2020-12-06 18:34:06 -08:00
Wez Furlong
61c52af491 wezterm: add raw_code concept to input layer
This commit is a bit noisy because it also meant flipping the key map
code from using the termwiz input types to the window input types, which
I thought I'd done some time ago, but clearly didn't.

This commit allows defining key assignments in terms of the underlying
operating system raw codes, if provided by the relevant layer in the
window crate (currently, only X11/Wayland).

The raw codes are inherently OS/Machine/Hardware dependent; they are the
rawest value that we have available and there is no meaningful
understanding that we can perform in code to understand what that key
is.

One useful property of the raw code is that, because it hasn't gone
through any OS level keymapping processing, its value reflects its
physical position on the keyboard, allowing you to map keys by position
rather than by value.  That's useful if you use software to implement
eg: DVORAK or COLEMAK but want your muscle memory to kick in for some of
your key bindings.

New config option:

`debug_key_events = true` will cause wezterm to log an "error" to stderr
each time you press a key and show the details in the key event:

```
2020-12-06T21:23:10.313Z ERROR wezterm_gui::gui::termwindow > key_event KeyEvent { key: Char('@'), modifiers: SHIFT | CTRL, raw_key: None, raw_modifiers: SHIFT | CTRL, raw_code: Some(11), repeat_count: 1, key_is_down: true }
```

This is useful if you want to figure out the `raw_code` for a key in your
setup.

In your config, you can use this information to setup new key bindings.
The motivating example for me is that because `raw_key` (the unmodified
equivalent of `key`) is `None`, the built-in `CTRL-SHIFT-1` key
assignment doesn't function for me on Linux, but I can now "fix" this in
my local configuration, taking care to make it linux specific:

```lua
local wezterm = require 'wezterm';
local keys = {}

if wezterm.target_triple == "x86_64-unknown-linux-gnu" then
  local tab_no = 0
  -- raw codes 10 through 19 correspond to the number key 1-9 positions
  -- on my keyboard on my linux system.  They may be different on
  -- your system!
  for i = 10, 20 do
    table.insert(keys, {
      key="raw:"..tostring(i),
      mods="CTRL|SHIFT",
      action=wezterm.action{ActivateTab=tab_no},
    })
    tab_no = tab_no + 1
  end
end

return {
  keys = keys,
}
```

Notice that the key assignment accepts encoding a raw key code using
a value like `key="raw:11"` to indicate that you want a `raw_code` of
`11` to match your key assignment.  The `raw_modifiers` portion of
the `KeyEvent` is used together with the `raw_code` when deciding
the key assignment.

cc: @bew
2020-12-06 13:41:29 -08:00
Wez Furlong
e86d949dae cargo update
We need a newer version of ring in order to compile on M1

refs: #343
2020-12-05 10:35:00 -08:00
Wez Furlong
3b69586416 wezterm: add allow_square_glyphs_to_overflow_width = "WhenFollowedBySpace"
Adds an option to control how wide glyphs (more specifically: square
aspect glyphs) are scaled to conform to their specified width.

The three options are `Never`, `Always`, and `WhenFollowedBySpace`.

When a glyph is loaded, if it is approximately square, this option is
consulted.  If overflow is permitted then the glyph will be scaled
to fit only the height of the cell, rather than ensuring that it fits
in both the height and width of the cell.

refs: #342
2020-11-24 10:38:20 -08:00
Wez Furlong
6e8f8298af wezterm: explain where the font came from in fallback errors
Make an effort to explain what failed to load and where it came from,
and funnel users to the documentation on font configuration.

The message presented is slightly different depending on whether
we think that the font was their primary font, an explicitly
specified font_rule or an implicitly synthesized font_rule.

refs: #340
2020-11-24 08:49:26 -08:00
Wez Furlong
3bd8d8c845 wezterm-font: bundle a last resort font
Bundle the *Last Resort High-Efficiency* font from
https://github.com/unicode-org/last-resort-font/
version 13.001 (Oct 22 2020).

This provides a more useful fallback glyph than we'd otherwise
produce if there is no matching glyph in any of the fonts.

Its license is OFL-1.1 which is compatible with the other
bundled fonts.
2020-11-22 16:12:20 -08:00
Wez Furlong
4500510d5c wezterm-font: improve perf of windows font locator
This avoids enumerating and parsing all fonts on startup, and improves
matching in general.
2020-11-22 12:39:29 -08:00
Wez Furlong
30cc10d4cf wezterm-font: remove font-loader dependency
This commit replaces it with the underlying core text calls
on macos.

refs: #337
2020-11-22 11:19:44 -08:00
Wez Furlong
9ca428c4e1 wezterm-font: remove font-loader dep on windows
There are a number of cases where font-loader might panic on windows,
and the optional font-loader dep causes problems with `cargo vendor`
in #337, so this is a step to removing that dep.

This commit makes direct GDI calls to enumerate monospace truetype
fonts from the system and then applies our normal matching on the
result.
2020-11-22 10:27:48 -08:00
Wez Furlong
e8ad765ff5 wezterm: add SelectionMode::SemanticZone
This makes it possible to configure wezterm to eg: triple click
on command input (or output) to select the entire input or output
without messing around trying to find the bounds.

The docs have an example of how to configure this; it requires
setting up shell integration to define the appropriate semantic
zones.
2020-11-15 22:23:18 -08:00
Wez Furlong
37a3f7db5f wezterm: add ScrollToPrompt key assignment
Adds some supporting methods for computing the `SemanticZone`s
in the display and a key assignment that allows scrolling the
viewport to jump to the next/prev Prompt zone.
2020-11-08 09:58:02 -08:00
Wez Furlong
5619eb718c wezterm: default inactive_pane_hsb to dim/desaturate
Let's make the suggested config in the docs the default
and dim/desaturate inactive panes slightly.
2020-10-30 23:12:35 -07:00
Wez Furlong
ea0d8d6f11 wezterm-font: remove font-kit dep
This wasn't used by anything and the version was getting pretty stale.
Upgrading is awkward because newer versions pull in an incompatible
freetype library version.
2020-10-24 22:01:00 -07:00
Wez Furlong
7f82f333f1 wezterm: revise opacity configuration
This commit revises the opacity configuration to make it more
consistently applied.

* `window_background_opacity` controls the overall window capacity,
  whether a background image is present or not.
* When a background image is present, or if the window is transparent,
  then text whose background color is the default background is
  changed to have a fully transparent background.
* `text_background_opacity` controls the alpha channel value for
  text whose background color is NOT the default background.
  It defaults to 1.0 (fully opaque), but can be set to be
  transparent by setting it to a number between 0.0 and 1.0.
* The inactive pane hue, saturation, brightness multipliers
  have been factored out into their own struct which changes
  that set of options to:

```lua
return {
  inactive_pane_hsb = {
    hue = 1.0,
    saturation = 1.0,
    brightness = 1.0,
  },
}
```

* `window_background_image_hsb` is a new option that can apply
  a hue, saturation, brightness transformation to a background
  image.  This is primarily useful to make a background image
  darker:

```lua
return {
  window_background_image = "/some/pic.png",
  window_background_image_hsb = {
    brightness = 0.3,
  },
}
```

refs: #302
refs: #297
2020-10-23 23:16:00 -07:00
Wez Furlong
1978eba0a1 wezterm: make the split color configurable and darker
This makes the color of the split divider darker by default,
and configurable via the color scheme configuration file.

refs: #297
2020-10-19 22:05:13 -07:00
Wez Furlong
eb9f7aefc6 wezterm: add options to dim inactive panes
refs: #297
2020-10-19 20:59:22 -07:00
Wez Furlong
eaa6536325 wezterm: remove OldSoftware frontend
Upcoming changes to the GUI mean that it will be double
the work to keep maintaining this, and it is already lagging
behind on pane support.

With the Mesa llvmpipe fallback we should be in a pretty
good state to not need another non-GL implementation.
2020-10-19 09:22:02 -07:00
Wez Furlong
f2cbc182cd wezterm: add window background image and opacity options
I thought it would be cute to add an option to add a background image to
the window.

While playing around with the parameters, I accidentally implemented
window transparency on X11/Wayland, provided that you have a compositing
window manager.  I don't know of the transparency also works on macOS or
Windows as of yet; will try that out once I push this commit.

This commit introduces three new configuration options explained below.

In the future I'd like to allow specifying equivalent settings in a
color scheme, and then that would allow setting per-pane background
images.

```lua
return {
    --[[
     Specifies the path to a background image attachment file.
     The file can be any image format that the rust `image`
     crate is able to identify and load.
     A window background image is rendered into the background
     of the window before any other content.
     The image will be scaled to fit the window.
     If the path is not absolute, then it will taken as being
     relative to the directory containing wezterm.lua.
    ]]
    window_background_image = "/some/file",

    --[[ Specifies the alpha value to use when rendering the background
     of the window.  The background is taken either from the
     window_background_image, or if there is none, the background
     color of the cell in the current position.
     The default is 1.0 which is 100% opaque.  Setting it to a number
     between 0.0 and 1.0 will allow for the screen behind the window
     to "shine through" to varying degrees.
     This only works on systems with a compositing window manager.
     Setting opacity to a value other than 1.0 can impact render
     performance.
     ]]
    window_background_opacity = 1.0,

    --[[
    Specifies the alpha value to use when applying the default
    background color in a cell.  This is useful to apply a kind
    of "tint" to the background image if either window_background_image
    or window_background_opacity are in used.

    It can be a number between 0.0 and 1.0.
    The default is 0.0

    Larger numbers increase the amount of the color scheme's
    background color that is applied over the background image.

    This can be useful to increase effective contrast for text
    that is rendered over the top.
    ]]
    window_background_tint = 0.0,
}
```

refs: https://github.com/wez/wezterm/issues/141
2020-10-18 09:47:55 -07:00
Wez Furlong
b7e303f39c Windows: prefer to use Direct3D11 via ANGLE
This is similar in spirit to the work in 4d71a7913a
but for Windows.

This commit adds ANGLE binaries built from
07ea804e62
to the repo.  The build and packaging will copy those into the same
directory as wezterm.exe so that they can be resolved at runtime.

By default, `prefer_egl = true`, which will cause the window
crate to first try to load an EGL implementation.  If that fails,
or if `prefer_egl = false`, then the window crate will perform
the usual WGL initialization.

The practical effect of this change is that Direct3D11 is used for the
underlying render, which avoids problematic OpenGL drivers and means
that the process can survive graphics drivers being updated.

It may also increase the chances that the GPU will really be used
in an RDP session rather than the pessimised use of the software
renderer.

The one downside that I've noticed is that the resize behavior feels a
little janky in comparison to WGL (frames can render with mismatched
surface/window sizes which makes the window contents feel like they're
zooming/rippling slightly as the window is live resized). I think this
is specific to the ANGLE D3D implementation as EGL on other platforms
feels more solid.

I'm a little on the fence about making this the default; I think
it makes sense to prefer something that won't quit unexpectedly
while a software update is in progress, so that's a strong plus
in favor of EGL as the default, but I'm not sure how much the
resize wobble is going to set people off.

If you prefer WGL and are fine with the risk of a drive update
killing wezterm, then you can set this in your config:

```lua
return {
  prefer_egl = false,
}
```

refs: https://github.com/wez/wezterm/issues/265
closes: https://github.com/wez/wezterm/issues/156
2020-10-17 19:08:16 -07:00
Wez Furlong
13cd24d9b5 Windows: improve ALT + dead key handling, part 2
This changes the ALT/dead key behavior a little bit more,
and in a way that is likely more useful to terminal users.

The default behavior is that system dead key processing is enabled.
For example, with DEU keyboard layout activated:

* `^` `<SPACE>` results in a single `^`
* `^` `e` result in those two characters combining into an e with a
  diacritic.

If the config sets `use_dead_keys = false` then the behavior changes;
wezterm probes the active keymap to determine which keys are marked
as dead keys and computes their single character expansion.  When
the dead key is pressed then that expansion is substituted instead.
So `^` is simply `^`.

In order to pull this off, the window layer needs to selectively
call `TranslateMessage` for the system dead key expansion case
instead of unconditionally in the global message loop.

As a result of *that*, it means that we don't perform the default ALT
key translation for every key press any more.  I looked to see how old
friend putty handles this and found that it only allows default system
processing for ALT-space and ALT-F4.  I was resistent to selectively
processing system shortcuts because the full set are effectively
unknowable to an application and I didn't want to try to replicate
a wide selection of varying keypresses.  I'm fine to only allow
these two, so this commit does that, and reverts the portion of
the prior commit that prevented passing general ALT key combinations
through.

refs: #275
refs: #296
2020-10-15 17:06:09 -07:00
Wez Furlong
ba096771ef wezterm: show config error window when fonts fail to load
This commit teaches the config layer to distinguish between
explicitly configured fonts and automatic fallback fonts.

Font loading now maintains the set of loaded fonts.  If after
loading from all configured sources a non-fallback font is
not present in the loaded set, wezterm will now pop up the
configuration error window to explain what is happening.

closes: #263
2020-10-11 16:54:51 -07:00
Wez Furlong
ab6cda81aa Add permute_any_mods and permute_any_or_no_mods functions
refs: #288
2020-10-10 15:11:21 -07:00
Wez Furlong
5a8fc09336 lua: add wezterm.sleep_ms
This will delay for the specified number of milliseconds.
This is an async function; it won't block the gui thread,
it will deschedule running the script and resume it once
the timeout has expired.

refs: #222
2020-10-09 21:11:30 -07:00
Wez Furlong
9d9f3c3c1a lua: add GuiWin and PaneObject proxies for use in script
This commit adds very basic first passes at representing the Pane
and GuiWindow types in lua script.

The `open-uri` event from 9397f2a2db
has been redefined to receive `(window, pane, uri)` parameters
instead of its prior very basic `uri` parameter.

A new key assignment `wezterm.action{EmitEvent="event-name"}` is
now available that allows a key binding assignment to emit an arbitrary
event, which in turn allows for triggering an arbitrary lua callback
in response to a key or mouse click.

`EmitEvent` passes the `(window, pane)` from the triggering window and
pane as parameters.

Here's a brief example:

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

wezterm.on("my-thingy", function(window, pane)
  local dims = pane:get_dimensions();
  wezterm.log_error("did my thingy with window " .. window:window_id() ..
    " pane " .. pane:pane_id() .. " " .. dims.cols .. "x" .. dims.viewport_rows);
  window:perform_action("IncreaseFontSize", pane);
end)

return {
  keys = {
     {key="E", mods="CTRL", action=wezterm.action{EmitEvent="my-thingy"}},
  }
}
```

refs: #223
refs: #225
2020-10-09 13:55:36 -07:00
Wez Furlong
9397f2a2db wezterm: allow overriding the default open-uri event
This builds on the new lua event handler plumbing added
in ccea650a93 to co-opt
the default URI opening action:

```lua
wezterm.on("open-uri", function(uri)
  if uri:find("jira") then
    wezterm.log_error("do something with jira")
    wezterm.run_child_process({
      "wezterm",
      "start",
      "--",
      "jira",
      "view",
      extract_task_from_uri(uri)
    })
    -- prevent the default action from opening in a browser
    return false
  else
    -- log but allow the uri to be opened in the browser
    wezterm.log_error("clicken " .. uri)
  end
end)
```

This doesn't allow exactly the sketched out option from
issue #223 to be implemented, but may be close enough
to be useful.

refs: #223
refs: #225
2020-10-07 18:26:16 -07:00
Wez Furlong
882f47f4ad wezterm.glob is now async capable 2020-10-07 09:00:37 -07:00
Wez Furlong
15b6a7c355 wezterm.read_dir is now async capable 2020-10-07 08:55:37 -07:00
Wez Furlong
c7f95cac72 wezterm.run_child_process is now async capable 2020-10-07 08:51:54 -07:00
Wez Furlong
ccea650a93 add wezterm.on(), wezterm.emit()
* `wezterm.on("event-name", func)`
* `wezterm.emit("event-name", "arg1", "arg2")`

`on` allows registering multiple functions.
`emit` will call each of the registered functions in turn, passing
a copy of the arguments.  If a handler returns false, no additional
handlers are called and `emit` will return false.  Otherwise,
once all the handlers have been called, `emit` will return true.

`emit` is capable of being called by async code.

These functions are available to the config layer, but nothing in
wezterm uses them at this time.

refs: #225
2020-10-07 08:42:06 -07:00
Wez Furlong
4acf1e3935 Upgrade mlua to 0.4, lua to 5.4 2020-10-06 18:34:29 -07:00
Wez Furlong
8d1af908bf fixup starting mux on windows
* Taught wezterm-mux-server how to `--daemonize` on windows
* Removed pty based command spawn used to spawn unix domain servers.
  This was present because it was the only way to successfully spawn
  wsl in the past.  What I'm finding today is that it doesn't work
  at all for me, generating an `0xc0000142` Application failed to
  initialize error.  A plain command builder spawn seems to work,
  so that's what we're going with.
* Ensure that we put `.exe` on executable name on windows, otherwise
  the spawn may fail.
* `Path::exists()` always returns false for unix domain sockets on
  Windows, so unconditionally try to remove the socket before binding,
  otherwise the bind will falsely fail, claiming that another process
  is already bound.

The docs for mux will need to be updated to show how to revise them
for the new mux server invocation:

```lua
  unix_domains = {
    {
      name = "wsl",
      serve_command = {"wsl", "wezterm-mux-server", "--daemonize"}
    },
  }
```
2020-10-05 20:29:47 -07:00
Wez Furlong
bf266a326d maybe fixup build for windows 2020-10-05 11:57:08 -07:00
Wez Furlong
5eb4d32004 upgrade misc deps, notably, async-task 2020-10-05 00:06:01 -07:00
Wez Furlong
e8be716cb3 clean up mux server startup
kindof a lot going on in this commit, unintentionally:

* Need the lua context set to be moved into the config crate
  otherwise configs cannot be parsed by the server and we end
  up with the default configs
* Make the server use smol for async io
* Drop the use of the daemonize crate, which I had forked anyway.
  Just inline our own tighter daemonize module
* Improve daemon spawning synchronization, however, it still needs
  work for windows to avoid blocking forever where we don't do
  daemonizing.
2020-10-04 09:39:28 -07:00
Wez Furlong
0c32963f1c Move server to its own wezterm-mux-server binary 2020-10-03 11:15:57 -07:00
Wez Furlong
2af699fe79 move running_under_wsl to config crate 2020-10-03 11:15:57 -07:00
Wez Furlong
ee6864c217 move config into its own crate 2020-10-03 11:15:57 -07:00