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

1261 Commits

Author SHA1 Message Date
Wez Furlong
696148941c
Rc<Tab> -> Arc<Tab> 2022-12-19 11:52:38 -07:00
Wez Furlong
6e06b9af02
mux: Pane is now required to be Send+Sync. Use Arc<dyn Pane> 2022-12-19 11:52:33 -07:00
Wez Furlong
28c7c0ba19
macos: allow association with .command file type
Implement an app delegate to receive a callback when the system
requests that we open `.command` files, and then ask the mux
layer to spawn a window for it and execute it via the shell.

Also allow handling `.sh`, `.zsh`, `.bash`, `.fish` and `.tool`,
per kitty.

refs: https://github.com/wez/wezterm/issues/2741
refs: https://github.com/wez/wezterm/issues/2871
2022-12-19 11:06:12 -07:00
Wez Furlong
9923ae20b5
env_logger -> 0.10
closes: https://github.com/wez/wezterm/pull/2803
2022-11-27 21:37:25 -07:00
Peter Nguyen
b26da03085 wezterm-gui: implement move_by_page function 2022-11-22 07:35:09 -08:00
Peter Nguyen
9fa44574a8 wezterm-gui: support half page up/down navigation 2022-11-22 07:35:09 -08:00
Wez Furlong
49b9839fdb
fix IME composition status applying to all panes
refs: https://github.com/wez/wezterm/issues/2569
2022-11-19 14:50:34 -07:00
Wez Furlong
2dd3968b9e
allow disabling tabs, new tab button in tab bar
refs: https://github.com/wez/wezterm/issues/2082
2022-11-19 13:54:10 -07:00
kas
74e55d09e1 Fix relative CWD path given on command line being interpreted as within the server's CWD 2022-11-19 08:11:13 -08:00
Jet Spark
ec2715a354 Fix background cover algorithm 2022-11-19 07:34:36 -08:00
Wez Furlong
fde535faf1
Fix dragging by left or right status with retro tab bar
Another good example of why `_ =>` in a match is probably a bad idea.

refs: https://github.com/wez/wezterm/issues/2758
2022-11-19 08:26:33 -07:00
Wez Furlong
d96b05c06c
docs: fix MoveTabRelative default key assignments
closes: https://github.com/wez/wezterm/issues/2705
2022-11-19 08:14:00 -07:00
KevinSilvester
2c6748daa6
gui: improve error message for unsupported height/width values for Color and Gradient
closes: https://github.com/wez/wezterm/pull/2681
2022-11-19 08:01:57 -07:00
Wez Furlong
e0aa66489f
webgpu: improve messaging when no adapters are found
refs: #2756
2022-11-19 07:30:08 -07:00
Wez Furlong
7afe0c5f40
webgpu: minor optimization of shader
compute the actual color once for the vertex, rather than for each
fragment.
2022-11-19 07:13:34 -07:00
Wez Furlong
a4ec2560a2
use constants for has_color values in wgsl shader and in the rust code
Slightly improve the efficiency of the hsv transform for text
by multiplying the two transforms together and performing just
one hsv color conversion.
2022-11-18 13:22:18 -07:00
Wez Furlong
dad5fbd1f9
webgpu: support hsv transforms 2022-11-18 10:29:31 -07:00
Wez Furlong
783b39aae1
add some config options to influence webgpu selection 2022-11-18 10:03:49 -07:00
Wez Furlong
883e2d11d7
make drawRect work on macos when using webgpu 2022-11-18 10:03:49 -07:00
Wez Furlong
76576daa69
This makes webgpu actually render
It doesn't have some of the functions from the egl shader yet,
but the text is visible!
2022-11-18 10:03:49 -07:00
Wez Furlong
acbec709b5
fixup crash when running in webgpu mode 2022-11-18 10:03:49 -07:00
Wez Furlong
ac15dd54c0
plumb webgpu code into draw path
Using the new abstractions, we can call into webgpu code now.

It doesn't do anything useful, and in fact crashes because
the mapping of the quads is doing the wrong thing.

Will fix in the next commit.
2022-11-18 10:03:49 -07:00
Wez Furlong
9c1a88d797
Abstract more over the render state, add RenderContext 2022-11-18 10:03:49 -07:00
Wez Furlong
19385d3355
put WebGpuState into an Rc
So that we can pass it to RenderState
2022-11-18 10:03:49 -07:00
Wez Furlong
334fb8a2ed
Add IndexBuffer abstraction 2022-11-18 10:03:49 -07:00
Wez Furlong
d712559b72
Add VertexBuffer abstraction 2022-11-18 10:03:49 -07:00
Wez Furlong
7a77854bf0
Add MappedVertexBuffer abstraction 2022-11-18 10:03:49 -07:00
Wez Furlong
c1f9fe3a84
make TripleLayerQuadAlloctor::Gpu(BorrowedLayers) self-referential
This makes it easier to manage the lifetimes of the various pieces
needed to allocate vertices, and to make it work with webgpu
in the future.
2022-11-18 10:03:49 -07:00
Wez Furlong
043606772f
use a self-referential struct for mapping vertexbuffers 2022-11-18 10:03:49 -07:00
Wez Furlong
09f1ecbf82
erase generic T from Atlas, Sprite, CachedGlyph etc.
This will make it easier to use the same impl for webgpu and opengl
for a bunch of this stuff.
2022-11-18 10:03:49 -07:00
Wez Furlong
8e7eb82a22
notionally allow webgpu texture atlas creation
Nothing calls it yet, may not be correct
2022-11-18 10:03:49 -07:00
Wez Furlong
00943345b6
make Vertex conform to Pod 2022-11-18 10:03:49 -07:00
Wez Furlong
8479be7465
Basic useless wgpu based rendering foundation 2022-11-18 10:03:49 -07:00
Wez Furlong
35fd69b0d5
partially handling overflowing tab titles
The recent changes to clustering make this more likely to happen.
This doesn't handle overflow resulting from changing styles in the tab
title, but those are less common.

refs: https://github.com/wez/wezterm/issues/2560
2022-11-15 15:38:45 -07:00
Wez Furlong
30daed40b3
reduce size of BoxedQuad by 2/3
Since we're no longer tied to contiguous Vertex slices, we can
record the Quad data used for HeapQuadAllocator in a smaller structure,
so that's what this does.

It reduces the per-Quad storage from 272 bytes down to 84 bytes,
which helps with overall memory usage: the default cache size is 1024
lines worth of quads, so this can add up to multiple MB of RAM.

refs:  https://github.com/wez/wezterm/issues/2626
2022-11-14 23:11:02 -07:00
Wez Furlong
a852e47dba
quads: switch to allocating quads rather than contiguous vertices
This reduces peak heap usage by several MB by making better use
of allocated memory--no wasted overhead in the Vec capacity.

refs: https://github.com/wez/wezterm/issues/2626
2022-11-14 14:44:25 -07:00
Wez Furlong
84e2501df2
remove dead code 2022-11-14 13:47:38 -07:00
Wez Furlong
173e27d2e8
Add support for heap profiling using dhat
refs: https://github.com/wez/wezterm/issues/2626
2022-11-14 13:26:02 -07:00
Wez Furlong
831eda86b9
perf: adjust clustering when bidi is disabled
When a line is rapidly updated with only some of the cells being
actually changed (eg: progress counter or other status being frequently
updated), it is desirable to avoid paying the cost of shaping the entire
line.

When bidi is not enabled we can assume that it is safe to break clusters
on whitespace boundaries. Doing so allows each of those whitespace
separated words to be shaped and potentially cached independently,
which reduces the amount of CPU time spent for the whole line.

This commit just adjusts the clustering, which reduces the CPU
utilization a bit.

refs: https://github.com/wez/wezterm/issues/2701
2022-11-14 10:05:20 -07:00
Wez Furlong
0516b61f62
lfucache: improve LFU algorithm and structure
Do it "more properly": use intrusive list linkage to manage three
indices:

* hash lookup
* recency
* frequency

eviction is frequency based, but in order to avoid things that were
super hot in the past and that are no longer hot clogging up the cache,
eviction will incrementally age out least recently used entries that
haven't been active in the span of some number of get/put operations.

Aging scales down the frequency value to reduce its strength, so an aged
item isn't necessarily immediately a candidate for removal, it just
makes it more likely to be picked up by the frequency based removal as
it goes unused for an extended period.
2022-11-14 10:00:49 -07:00
Wez Furlong
72757b8849
refactor: move lfucache into its own crate 2022-11-14 07:35:37 -07:00
Wez Furlong
1c8a20d577
gui: fix cursor color invalidation issue
Things like compose cursor and dynamically changed cursor colors
were not factored into our cache keys, making the cursor color
"sticky" in the wrong ways.

refs: https://github.com/wez/wezterm/issues/2708

Might possibly also help with https://github.com/wez/wezterm/issues/2635
2022-11-13 16:47:34 -07:00
Wez Furlong
c71e22e57d keyevent: fixup prevent_fallback processing
refs: #2702
2022-11-07 09:36:25 -07:00
Wez Furlong
6aceb97ded keys: add prevent_fallback option for ActivateKeyTable
The behavior is to prevent falling back to a later key table
if no key matched.

refs: https://github.com/wez/wezterm/issues/2702
2022-11-04 07:02:36 -07:00
Magnus Groß
0d4cd8a1e0 Allow to pass the command to execute via "-e"
Right now wezterm already allows to pass a cmdline to execute (instead
of the shell) by calling "wezterm start" with trailing arguments, e.g.
wezterm start -- bash

However, most other terminals implement this via a "-e" option. This
seems to be adopted widely in the wild, such that some third-party
frameworks just blindly expect the user's terminal to use the "-e"
option for this.

One such notable framework is kio from KDE Plasma, that calls the user's
terminal in that way when launching a desktop file that uses
Terminal=true. [1]

To solve this problem, we add a compatibility layer by adding a dummy
"-e" option. This will then consume the "-e" leaving the remaining
arguments as trailing arguments, which will later be consumed by our
existing implementation in the "prog" option.

Given that clap does not really support multiple arguments writing to
the same destination [2], this seems like the most sane implementation,
even if it is a hack.

It seems to work reliable, even for edge cases where we pass wezterm
options as trailing arguments, e.g. the following will just work and do
the expected outcome (and will **not** parse "--position" as a wezterm
argument):
wezterm start -e echo --position 10,10

Fixes #2622

[1] https://bugs.kde.org/show_bug.cgi?id=459616
[2] https://github.com/clap-rs/clap/issues/3146
2022-11-04 06:32:32 -07:00
Wez Furlong
43f2265ef1 deps: textwrap -> 0.16
closes: https://github.com/wez/wezterm/pull/2664
2022-10-23 20:50:47 -07:00
Wez Furlong
b1faba9d8a deps: upgrade finl_unicode to 1.2 2022-10-23 12:07:00 -07:00
Wez Furlong
4f05e2e1f1 render: remove redundant extra quad buffer
I can't think of a good reason for this being here.  I think I
may have been lazy about resolving the lifetime annotations
and just stuck in an extra buffer while building the original
version of this logic, and then forgot about it.

This commit resolves the lifetime annotations and directly
references the passed in buffer.

refs: https://github.com/wez/wezterm/issues/2626
2022-10-22 19:51:52 -07:00
Wez Furlong
35ce2fe74d trim heap usage
I spent a few hours in heap profilers.  What I found was:

* Inefficient use of heap when building up runs of
  `Action::Print(char)`.
    -> Solve by adding `Action::PrintString(String)`
  and accumulating utf8 bytes rather than u32 codepoints.
* Inefficient use of heap when building Quad buffers: the default
  exponential growth of `Vec` tended to waste 40%-75% of the allocated
  capacity, and since we could keep ~1024 of these in cache, there's
  a lot of potential for waste.
   -> Solve by bounding the growth to 64 at a time.  This has similar
   characteristics to exponential growth at the default 80x24 terminal
   size.  May need to add a config option for this step size for users
   with very large terminals.
* Lazy eviction from the LFU caches. The underlying cache advisor is
  somewhat probabilistic and has a minimum cache size of 256, making
  it difficult to maintain low heap utilization.
   -> Solve by replacing it with a very simple LFU algorithm. It doesn't
   seem to hurt much at the default terminal size with the default
   cache sizes.  If we make the cache sizes smaller, its overhead is
   reduced.

Some further experimentation is needed to adjust defaults, but this
should help reduce heap usage.

refs: https://github.com/wez/wezterm/issues/2626
2022-10-22 17:10:36 -07:00
Wez Furlong
5dd1f513f9 reduce log level strength of "breaking on overflow" 2022-10-22 06:26:10 -07:00
Wez Furlong
ec4d5eb1d5 gui: set up mux socket for wezterm connect case as well
It can be helpful for debugging purposes.
The socket can be discovered by setting:

WEZTERM_LOG=wezterm_mux_server_impl::local=trace,info

to get it to log a line like:

```
setting up /Users/wez/.local/share/wezterm/gui-sock-38183
```

Then it can be helpful to do:

```
WEZTERM_UNIX_SOCKET=/Users/wez/.local/share/wezterm/gui-sock-38183 wezterm cli list
```

to see what is in the gui's mux model.

refs: https://github.com/wez/wezterm/issues/2616
2022-10-17 20:45:32 -07:00
Wez Furlong
313fabd747 keys: ctrl-shift-1 didn't switch to the first tab
When using `key_map_preference="Mapped"`, `ctrl-shift-1` is actually
`ctrl-shift-!` in a US layout.

This commit adds the us-layout mapping for shifted number keys to
allow that to work, but it is worth calling out that this will only
be meaningful in layouts that have the same US mapping for the number
keys.

refs: https://github.com/wez/wezterm/issues/2623
2022-10-15 09:14:42 -07:00
Wez Furlong
b2e901ecd3 launcher: don't panic when launching nothing
refs: https://github.com/wez/wezterm/issues/2629
2022-10-15 08:55:11 -07:00
Wez Furlong
3c06b99675 charselect: improve compatibility with QMK unicode inputs
refs: https://github.com/wez/wezterm/issues/2581
2022-10-11 10:57:56 -07:00
Wez Furlong
4e5945c061 Add ResetTerminal and pane:inject_output method
refs: https://github.com/wez/wezterm/discussions/2606
2022-10-08 10:25:22 -07:00
Wez Furlong
473316934b add window-focus-changed event 2022-10-08 09:45:57 -07:00
Wez Furlong
0e98b23392 tweak --always-new-process messaging
refs: https://github.com/wez/wezterm/discussions/2589
2022-10-06 18:14:32 -07:00
Wez Furlong
eefd57b8ed fmt 2022-10-04 19:09:09 -07:00
Wez Furlong
1a4749940b fix charselect panic when pressing enter on no matches
refs: https://github.com/wez/wezterm/issues/2580
2022-10-04 09:09:47 -07:00
Wez Furlong
2cae10016f deps: update emojis crate 2022-10-04 09:00:18 -07:00
Wez Furlong
a050849695 deps: update to clap 4
Deal with some breaking changes
2022-10-04 08:55:31 -07:00
Wez Furlong
3c1cf930ae ls-fonts: --rasterize-ascii now works for custom glyphs 2022-09-24 08:16:22 -07:00
Wez Furlong
8e7a2cce79 overlays: pass down window config and apply overrides
refs: https://github.com/wez/wezterm/issues/2544
2022-09-23 05:00:31 -07:00
Wez Furlong
c839aeb431 reduce 'cancel mux subscription' log from error -> error 2022-09-22 07:32:56 -07:00
Wez Furlong
07675d5d57 copy-mode: fix greediness of jump
refs: https://github.com/wez/wezterm/issues/2528#issuecomment-1254557556
2022-09-22 06:15:14 -07:00
Wez Furlong
9a7aad0200 add window:is_focused() method
refs: https://github.com/wez/wezterm/discussions/2537
2022-09-21 19:44:44 -07:00
Wez Furlong
134c804cea copy mode: fixup jump position
refs: https://github.com/wez/wezterm/issues/2528#issuecomment-1253773858
2022-09-21 19:05:04 -07:00
Wez Furlong
b11451f727 add wezterm ls-fonts --codepoints 2022-09-20 22:06:03 -07:00
Wez Furlong
4d45bd7bc4 remove FIXME: I fixed it differently 2022-09-20 19:54:59 -07:00
Wez Furlong
7f65c2242b copy-mode: vim style jump to character motion
refs: https://github.com/wez/wezterm/issues/2528
2022-09-20 19:52:20 -07:00
Wez Furlong
1b99690990 Add superscript and subscript cell attributes
I've expanded the number of bits from 16->32 without impacting
the overall struct sizes and reserved 2 bits for super/subscript.
I refer to these as vertical alignment properties for conceptual
consistency with css.

SGR 73, 74, 75 are used to set super, sub and normal vertical alignment.
These are compatible with mintty.

However, mintty just added support for setting both attributes to render in
small caps in 06ac446049
(https://github.com/mintty/mintty/issues/1171)
2022-09-19 06:42:14 -07:00
Wez Furlong
5a754e44e7 avoid panic when attempting to search the launcher menu
refs: https://github.com/wez/wezterm/issues/2529
2022-09-18 13:06:29 -07:00
Wez Furlong
5625ae53ed fix tests for nerdfont update 2022-09-17 06:38:22 -07:00
Wez Furlong
85db555b37 deps: update finl_unicode 2022-09-16 07:47:33 -07:00
Wez Furlong
10cd78a81a fonts: remove last resort font
I was going to upgrade to the unicode 15 font, but in testing this I
decided that the logic is slightly complex and the glyphs are often
difficult to see at most terminal font sizes, which generates questions
from users, so just fall back to notdef.
2022-09-15 08:23:58 -07:00
Wez Furlong
42e4a51a28 lua: no longer distinction between gui and mux panes
There is no gui-specific functionality for PaneObject, so
just fold everything into MuxPane and use that.
2022-09-11 07:05:48 -07:00
Wez Furlong
295677ed52 config: cursor_thickness, strikethrough_position, underline_position, underline_thickness
refs: https://github.com/wez/wezterm/issues/2326
refs: https://github.com/wez/wezterm/issues/2505
2022-09-10 18:34:35 -07:00
Wez Furlong
72674f5d28 perf: reduce number of calls to Line::get_cell
The clustered line storage impl of get_cell() is O(column-index)
as cells have to be iterated in order.

The render pass was calling it 3 times to resolve information
about the cursor; reduce that to just once.

It was also calling it once per cell to determine whether the
cell needed to be replaced with a custom glyph if custom block
glyphs were enabled, making it accidentally quadratic!

While it wasn't especially expensive, it did show up in profiling,
so this commit removes that call: we can cache the block glyph
key in the shaper info which is a better place for it anyway,
so that's what we do.

Similarly, there was some extraneous work to call get_cell
when computing some shaper info; remove that too!

That one might be slightly contentious: the is-followed-by-space
logic used to check the successor cell by index to see if it
was a space, but now looks at the successor shaped glyph to see
if it was a space. That might actually be a better choice, but
it may have some ripple effects.
2022-09-10 09:11:22 -07:00
Wez Furlong
96c4e7e9b9 Switch to finl_unicode for grapheme clustering
According to its benchmarks, it's almost 2x faster than
unicode_segmentation.  It doesn't appear to make a visible
difference to `time cat bigfile`, but I'll take anything
that gives more headroom for such little effort of switching.
2022-09-10 07:15:49 -07:00
Wez Furlong
ad35b9dc21 Add compile time features to allow building without vendored fonts
closes: #2305
2022-09-09 08:53:39 -07:00
Wez Furlong
39dd4cdd82 Add config options to control various cache sizes
These are more for low level testing than they are intended
for users to play with, so they are deliberately undocumented
at this time.
2022-09-09 07:30:53 -07:00
Wez Furlong
25cd05a80a ls-fonts: cut over to glyphcache's rasterizer
This way we get the same metrics and rendering as used by
the main termwindow
2022-09-08 19:16:26 -07:00
Wez Furlong
598f5081ec respect invisible text attribute
This is a weird attribute TBH.

xterm seems to replace the cells with spaces: copying and pasting
results in spaces.

Kitty ignores it.

VTE doesn't render it but allows copying and pasting.

The latter is now also the behavior in wezterm.
2022-09-08 08:43:27 -07:00
Wez Furlong
c0fff4e843 Add wezterm.gui.default_key_tables()
This provides a means for more easily extending the default key
tables without forcing the user to recreate the entire config
for themselves.

wezterm.gui.default_keys is also added by this, but it is likely
not as useful.
2022-09-07 10:21:54 -07:00
Funami580
cd2c2a1a83 charselect: add option to cycle to previous group of characters 2022-09-07 10:21:35 -07:00
Wez Furlong
026b9e3577 fix hyperlink underlines
There were two problems:

* We weren't correctly invalidating when the hover state changed
  (a recent regression caused by recent caching changes)
* We'd underline every link with the same destination on hover,
  not just the one under the mouse (longstanding wart)

Recent changes allow the application layer to reference the underlying
Lines directly, so we can restore the original and expected
only-highlight-under-the-mouse by switching to those newer APIs.

Adjust the cache values so that we know to also verify the current
highlight and invalidate.

I was a little surprised to see that this also works with mux client
panes: I was expecting to need to do some follow up on those because
they return copies of Line rather than references to them. That happens
to work because the mux client updates the hyperlinks at the time where
it inserts into its cache. The effect of that is that lines in mux
client panes won't update to new hyperlink rules if they were received
prior to a change in the config.

refs: https://github.com/wez/wezterm/issues/2496
2022-09-07 07:51:28 -07:00
Wez Furlong
72c83e0599 ls-fonts: fix ascii rasterization of emoji/bitmap fonts
Need to scale them using the same rules we do when the window
renders them for real.

wezterm  ls-fonts --text "$(printf hi\\U1faf0💩)" --rasterize-ascii
2022-09-06 18:49:20 -07:00
Wez Furlong
ea1513f480 Search incrementally in chunks of 1000 lines, show progress
This makes the search feel more responsive.

We search from bottom to top so that we show the more recent results
first, but for the sake of efficiency when accumulating result chunks
we need to reverse the order of the results vec from how it was
previously.

Each result chunk is loosely ordered from top to bottom, so we sort
it and reverse it: results[0] is the bottom-most result.

New rows are accumulated on the end of the result array; this is
not only more efficient, but it preverses the match result number
ordering.

The next/prior functions need to be swapped to account for this change
in result order.

refs: https://github.com/wez/wezterm/issues/1209
2022-09-05 09:21:20 -07:00
Wez Furlong
6b81cd4777 fix quad cache top pixel value
It was set to the first non-tab bar pixel y coordinate rather than
the line y pixel coordinate.

Move the calculation up!

refs: https://github.com/wez/wezterm/issues/2483
2022-09-05 07:52:10 -07:00
Wez Furlong
a29d8ed4ae charselect: options to control copy behavior, + docs
refs: https://github.com/wez/wezterm/issues/2163
2022-09-03 13:58:50 -07:00
Wez Furlong
0a3998887f correctly invalidate line shape data when fallback fonts load async
Ensure that the cache key changes when the shape generation changes
2022-09-03 09:31:08 -07:00
Wez Furlong
1b9ea2de3f change text cursor to fa_lock when entering passwords
There are caveats to determining this, but when we think
password entry is enabled, switch the cursor to the font-awesome
lock glyph instead of the normal cursor sprite.

fa_lock is used because it is monochrome and can thus be tinted
to the configured cursor color, and it respects blinking/easing.

refs: https://github.com/wez/wezterm/issues/2460
2022-09-02 09:00:28 -07:00
Wez Furlong
14c613a064 add Pane::get_metadata
The idea here is that different kinds of panes may want to expose
additional metadata to lua scripts. It would be a bit weird to add
a Pane method for each of those and plumb it all the way through
the various APIs, so just allowing a pane impl to return a dynamic
value (likely an Object) allows a bunch of flexibility.

This commit exposes the clientpane is_tardy boolean and the time
since the last data was recevied (since_last_response_ms) from
the mux client pane implementation: these are used to show the
tardiness indicator in the client pane.

Exposing this data enables the user to add that info to their
status bar if they wish.
2022-09-01 21:27:49 -07:00
Wez Furlong
8adc78b587 reset mouse cursor to arrow when mouse leaves the window
refs: https://github.com/wez/wezterm/issues/2471
2022-09-01 18:45:20 -07:00
Wez Furlong
16bf00c63c charselect: add explicit recent category, show category in UI
The default behavior for charselect is to show the recent category
if you have previously used it, otherwise, show the default emotion
category.

refs: https://github.com/wez/wezterm/issues/2163
2022-09-01 07:19:17 -07:00
Wez Furlong
7670c4f0ae char selector: track recently selected emoji and use frecency to show it
refs: https://github.com/wez/wezterm/issues/2163
2022-08-31 22:56:58 -07:00
Wez Furlong
ed731a0d8d Add CharSelect modal for emoji/nerdfont/unicode input
CTRL-SHIFT-U is a new default key assignment for this new modal.
It opens up a fuzzy searchable browser that defaults to showing
emoji/emoticons.  The category can by cycled through the suggested
emoji categories using CTRL-r.  Unlike the system emoji palette,
wezterm includes a category for nerdfont symbols, and another
that is a list of all unicode codepoint names, so you should be
able to browse for pretty much any codepoint you can think of.

The modal also allows fuzzy searching based on:

* The official unicode name
* The github shortcode
* codepoint value in hex

so if you know the codepoint value but not the name, you can
still find a way to input what you're looking for.

Pressing Enter will copy the selected item to the clipboard
send it to the active pane, and cancel the modal. You can therefore
repeat the insert by simply pasting.

I plan to add frecency to this in a later commit: that way the
frequently/recently used selections will show in a category of
their own and make it easier to re-input them.

refs: https://github.com/wez/wezterm/issues/2163
2022-08-31 18:15:28 -07:00
Wez Furlong
ccc1a2beff add pane_id and active state to render cache key
refs: https://github.com/wez/wezterm/issues/2467
2022-08-30 08:18:13 -07:00
Wez Furlong
60c5eb1f51 add cursor shape/visibility to quad cache key
otherwise strangeness can occur in vim when vim hides the cursor
as part of partially updating the screen.
2022-08-30 07:28:13 -07:00
Wez Furlong
b9d0843b71 deps: tiny-skia 0.7 -> 0.8 2022-08-28 20:50:27 -07:00
Wez Furlong
9732f9ee2b Adjust render caching; switch to LFU caches from LRU 2022-08-28 10:28:26 -07:00
Wez Furlong
1398c0d4b0 add user-var-changed event 2022-08-27 17:22:21 -07:00
Wez Furlong
3c7b75a4f3 fixup invalidation of blinking cursor, and on focus change 2022-08-27 12:14:10 -07:00
Wez Furlong
d38caf4088 cargo fmt 2022-08-27 10:32:01 -07:00
Wez Furlong
bf39e90676 track fps and recent frame duration for diagnostic purposes 2022-08-27 09:10:26 -07:00
Wez Furlong
5d250bce36 invalidate shape cache when reverse video mode changes 2022-08-27 08:47:22 -07:00
Wez Furlong
cb9fe1a676 flesh out some todos with new pane trait methods
Tidy some things up to avoid some dead code and redundant impls.
Make it easier to select whether you want to implement the new
methods in terms of the old, or the old methods in terms of
the new in a given pane impl.
2022-08-27 07:58:17 -07:00
Wez Furlong
d492eef700 implement new pane trait methods for copy and quickselect overlays 2022-08-27 06:19:12 -07:00
Wez Furlong
f03dc68f96 move shape & quad caching to hang off Line appdata
Remove the faulty cache key stuff and hang references to the cached
data directly off the underlying Line.  That makes the association
between the the Line and the data O(1) plus some basic cache
invalidation checks.

Adjust the shape cache portion of this to use the same ID for the
shape, so that things that invalidate just the quads (such as cursor
movement when not composing, and selection) only need to recompute
the quads without re-shaping.
2022-08-26 21:49:33 -07:00
Wez Furlong
b7b1e4020a revise Pane line related funcs
Adds Pane::for_each_logical_line_in_stable_range_mut and
Pane::with_lines_mut which allow iterating mutably over lines.

The idea is that this will allow the renderer to directly cache
data in the Line via its appdata without having to build cumbersome
external caching logic and managing cache keys.

This commit just swaps the implementation around for localpane
and sanity checks that the renderer functions.

Various overlays and the mux client don't properly implement these
yet and current warn at compile time and panic at runtime.

To follow is the logic to cache the data and make sure that it
works the way that I think before converting the other Pane
implementations.
2022-08-26 08:05:06 -07:00
Wez Furlong
6962d6805a cargo fmt 2022-08-24 23:04:15 -07:00
Wez Furlong
c4ea703d4b disable some of the recent caching stuff
The cache key isn't quite right, leading to some artifacts
in some cases.

I have a cunning plan, but it will take me a bit to wrap
it up, so in the meantime, disable these caches.

refs: https://github.com/wez/wezterm/issues/2455
2022-08-24 22:57:57 -07:00
Wez Furlong
5e993c581a termwiz: remove reverse video attribute from Line
It didn't really belong there; it was added as a bit of a hack
to propagate screen reverse video mode.

Move that to the RenderableDims struct and remove the related
bits from Line
2022-08-24 22:43:47 -07:00
Wez Furlong
0fe8bba147 fix copymode and quickselect overlays
the new caching broke these because they play dirty tricks by
aliasing the delegated pane id.

Skip caching for those by reporting the pane_id as None
2022-08-24 08:07:16 -07:00
Wez Furlong
ad7199c1cc trim down lru cache sizes
refs: https://github.com/wez/wezterm/issues/2453
2022-08-23 22:34:26 -07:00
Wez Furlong
3b4e859956 allow cursor_fg = "none" to use text fg color
Similar to selection_fg, setting the cursor_fg to transparent ("none")
will use the foreground color of the text behind the cursor.

refs: https://github.com/wez/wezterm/issues/1835
2022-08-23 19:54:19 -07:00
Wez Furlong
0141d340f3 gui: cache get_lines_with_hyperlinks_applied
If the pane is unchanged and we're at the same viewport, cache
the values from the last call.
2022-08-23 17:39:56 -07:00
Wez Furlong
03246fba23 gui: factor out background rect calc
avoid some copypasta
2022-08-23 17:16:04 -07:00
Wez Furlong
9029b3bca6 fix blinking text 2022-08-23 14:43:35 -07:00
Wez Furlong
65d350be36 fixup retro tab bar
I broke this with the performance changes I pushed earlier today.

Poke a hole in caching for it as well, as it doesn't use the seqno
to track changes like the rest of the Line based data.

cc: @DeadlySquad13
2022-08-23 12:30:45 -07:00
Wez Furlong
619b1ad292 scroll to bottom on mouse input when mouse is grabbed
refs: https://github.com/wez/wezterm/issues/2447
2022-08-23 10:15:39 -07:00
Wez Furlong
144d2a353e add focus state to cache key 2022-08-23 09:41:44 -07:00
Wez Furlong
64a10014cf treat Constant ease-in-and-out as equivalent to "1 fps" case
This doesn't mean that it renders at 1fps, just that it goes through
the simpler path of scheduling on the boundaries rather than at
animation_fps through the intermediate stages, where it would be
useless.
2022-08-23 08:29:57 -07:00
Wez Furlong
f582d35d8e improve blink easing scheduling
We weren't really respecting animation_fps very well. Account
for the last_render time when computing the next frame time.
2022-08-23 08:17:46 -07:00
Wez Furlong
00ddfbf9b8 perf: cache quads by line
Introduces a heap-based quad allocator that we cache on a per-line
basis, so if a line is unchanged we simply need to copy the previously
computed set of quads for it into the gpu quad buffer.

The results are encouraging wrt. constructing those quads; the
`quad_buffer_apply` is the cost of the copy operation, compare with
`render_screen_line_opengl` which is the cost of computing the quads;
it's 300x better at the p50 and >100x better at p95 for a full-screen
updating program:

full 2880x1800 screen top:

```
STAT                                             p50      p75      p95
Key(quad_buffer_apply)                           2.26µs   5.22µs   9.60µs
Key(render_screen_line_opengl)                   610.30µs 905.22µs 1.33ms
Key(gui.paint.opengl)                            35.39ms  37.75ms  45.88ms
```

However, the extra buffering does increase the latency of
`gui.paint.opengl` (the overall cost of painting a frame); contrast the
above with the latency in the same scenario with the current `main`
(rather than this branch):

```
Key(gui.paint.opengl)                            19.14ms  21.10ms  28.18ms
```

Note that for an idle screen this latency is ~1.5ms but that is also true
of `main`.

While the overall latency in the histogram isn't a slam dunk,
running `time cat bigfile` is ~10% faster on my mac.

I'm sure there's something that can be shaved off to get a more
convincing win.
2022-08-23 06:37:12 -07:00
Wez Furlong
9aaa4c4db6 Abstract quad and layer allocation
allows adding an alternative, cacheable, quad backing in a subsequent commit
2022-08-22 19:48:19 -07:00
Wez Furlong
d2b3d7ed94 add cheaper to cache shape info
Use essentially just a couple of very cheap integers as cache keys
for the shape info from a pane
2022-08-22 18:37:11 -07:00
Wez Furlong
5f64adb7f0 start building out box model based render of pane 2022-08-22 11:03:24 -07:00
Wez Furlong
8040a8ae81 revise how uniforms are passed to shader
This is really a proof of concept commit; I want to be able to pass
more structured data into the shader as uniforms and the basic
macros provided by glium make that a bit awkward.

What I came up with is a slightly more dynamic uniform builder
thingy.

I'm using this to pass in a copy of the various blinking easing
functions.

Those are incomplete and unused, but it shows that the technique works.
2022-08-22 10:22:00 -07:00
Wez Furlong
f2f2b83899 respect close confirmation prompt when middle clicking a tab
refs: #2350
2022-08-21 09:34:24 -07:00
Wez Furlong
de89d650a3 cargo update 2022-08-21 08:51:16 -07:00
Wez Furlong
3917fc2184 tab bar: force x and + buttons to be square
Use the font height as the basis for the size, rather than the width,
to avoid the buttons being too condensed.

Explicitly use the pixel height for the dimensions so that the
buttons are square.

refs: https://github.com/wez/wezterm/issues/2399
2022-08-20 22:34:19 -07:00
Wez Furlong
78b5ac0eb5 add border size and color config
refs: https://github.com/wez/wezterm/issues/2417
2022-08-20 17:05:17 -07:00
Wez Furlong
8b3a52ba9a colors now override color_scheme
The prior mutually exclusive behavior kept surprising people so let's
just flip this around.

This is potentially a "breaking" change for folks, but I think it is
worth it.
2022-08-20 11:48:22 -07:00
Wez Furlong
8b2ef50ca7 gui-startup event now also works for wezterm ssh.
This is done by adjusting how `wezterm ssh` works; we now set up
the default domain and call into the main `wezterm start` logic.

refs: #284
2022-08-20 08:01:45 -07:00
Wez Furlong
429c18b7ee fixup boundary condition for MoveBackwardZoneOfType
refs: #2346
2022-08-20 07:35:28 -07:00
Wez Furlong
f39ae2f762 background: avoid weird wraparound in radial gradients
I was seeing a black "hole" in the center of this gradient:

```
  background = {
    {
      source = {
        Gradient={
          colors = {"rgb(45,26,109)", "black"},
          orientation = {
            Radial={
              cx = 0.75,
              cy = 0.75,
              radius = 1.25,
            }
          },
        }
      },
      width="100%",
      height="100%",
    },
```

setting noise=0 "fixed" it, so this commit localizes that fix
to the center of the gradient by preventing noise from wrapping
around the gradient.
2022-08-14 08:25:31 -07:00
Wez Furlong
e6421d1b72 pty: try_clone_writer -> take_writer
This breaking API change allows us to explicitly generate EOF when the
taken writer is dropped.

The examples have been updated to show how to manage read, write
and waiting without deadlock for both linux and windows.
Need to confirm that this is still good on macOS, but my
confidence is high.

I've also removed ssh2 support from this crate as part of this
change. We haven't used it directly in wezterm in a long while
and removing it from here means that there is slightly less code
to keep compiling over and over.

refs: https://github.com/wez/wezterm/discussions/2392
refs: https://github.com/wez/wezterm/issues/1396
2022-08-12 07:56:46 -07:00
Wez Furlong
555bce3f7d fix bypass_mouse_reporting_modifiers
refs: https://github.com/wez/wezterm/issues/2389
2022-08-11 07:38:55 -07:00
Wez Furlong
130645414d add update-status event. deprecates update-right-status
refs: #1561
2022-08-10 06:10:48 -07:00
Wez Furlong
04bc838b63 fix overly truncated tab titles
refs: https://github.com/wez/wezterm/issues/2379
2022-08-09 20:46:41 -07:00
Wez Furlong
e4435938a8 add window:set_left_status
refs: https://github.com/wez/wezterm/issues/1561
2022-08-06 20:41:39 -07:00
Wez Furlong
28d803e3f4 refine dual source blending / subpixel aa and RGBA color interaction
Previously, we'd unconditionally enable dual source blending for the
text foreground layer when rendering. That meant that if the user had
configured the fg color to include an alpha value it would get "stamped
through" the draw all the way to the background, making that whole pixel
take on that alpha value rather than allowing it to blend through the
way you might expect.

In prior releases that didn't matter, but since we now allow configuring
the fg color with alpha, and allow using escape sequences to set the fg
for a span to something with alpha, there is now a much higher chance of
something looking weird.

Dual source blending is only really needed for subpixel-aa and that
isn't enabled by default.

This commit changes the behavior to use regular alpha blending if the
main config (rather than a per-font override) hasn't set the freetype
load/render target to one that enables subpixel-aa.

That means that alpha channel values work as expected for fg color
by default.

If you want to enable subpixel-aa you need to enable it globally
and be aware that it will cause weirdness when trying to use alpha
channels for the fg text color.

The docs now also indicate this behavior.

This limitation could be removed by making text rendering significantly
more complex and I don't fancy doing that at this time.
2022-08-06 17:41:44 -07:00
Wez Furlong
4c1fd693b4 fix positioning of visual bell
refs: https://github.com/wez/wezterm/issues/2364
2022-08-06 13:42:28 -07:00
Wez Furlong
3941d2a564 boxmodel: fix missing bearing_x / x_offset
Fixes up horizontal positioning in the fancy tab bar and spacing
in tab titles in some cases.

refs: https://github.com/wez/wezterm/issues/2357
2022-08-06 12:46:54 -07:00
Wez Furlong
3e298dc63a add wezterm ls-fonts --rasterize-ascii --text foo
This renders the glyph in ascii blocks, and shows some
additional data about the glyphs.
2022-08-06 12:46:01 -07:00
Wez Furlong
ef532fc7e5 mux: adjust window size after attach
Since the initial attach is async, we'd create the window at the
default/initial size and then never reconcile the size of the remote
tabs once they'd attached.

This commit introduces an event that allows the gui window to do that.

The action that it takes is to take the max width and height between
its current size and the size of a newly added tab and resizes to
that new size, if it changed.

refs: https://github.com/wez/wezterm/issues/2133
refs: https://github.com/wez/wezterm/issues/2351
2022-08-05 07:53:44 -07:00
Wez Furlong
1212865974 use titlebar bg for right status background
We were using the tab background, which is a bit awkward.

refs: https://github.com/wez/wezterm/issues/2356
2022-08-04 20:45:05 -07:00
Wez Furlong
3f7443f4c1 showkeys/docs: generate copy_mode defaults from the code
Uses `wezterm show-keys --lua --key-table copy_mode` to dump the
actual copy mode key table.  Include that in the docs.

Same for search_mode.
2022-08-04 06:28:32 -07:00
Wez Furlong
decde7c3be wezterm show-keys --lua to print a lua version of the config
This is handy for eg: copying and pasting out the default config.

I think I'll use this to update some parts of the docs in a more
automated fashion.
2022-08-03 18:14:00 -07:00
aznhe21
63d5c00af9 Add new action CopyMode('ClearSelectionMode') 2022-08-03 08:21:04 -07:00
Wez Furlong
1df1f166ca copy mode: move by semantic zone, select by zone
Allows the following assignment actions; I was just over-using z for
no real reason, I'm not suggesting that these are good assignments.

```
      -- move the cursor backwards to the start of the current zone, or
      -- to the prior zone if already at the start
      { key = 'z', mods = 'NONE', action = act.CopyMode 'MoveBackwardSemanticZone' },
      -- move the cursor forwards to the start of the next zone
      { key = 'Z', mods = 'NONE', action = act.CopyMode 'MoveForwardSemanticZone' },
      -- start selecting by zone: both the start point and the cursor
      -- position will be expanded to the containing zone and the union
      -- of those two will be used for the selection
      {
        key = 'z',
        mods = 'CTRL',
        action = act.CopyMode { SetSelectionMode = 'SemanticZone' },
      },
      -- like MoveBackwardSemanticZone by only considers zones of the
      -- specified type
      { key = 'z', mods = 'ALT', action = act.CopyMode { MoveBackwardZoneOfType ='Output' }},
      -- like MoveForwardSemanticZone by only considers zones of the
      -- specified type
      { key = 'Z', mods = 'ALT', action = act.CopyMode { MoveForwardZoneOfType ='Output' }},
```

refs: https://github.com/wez/wezterm/issues/2346
2022-08-02 21:56:53 -07:00
Wez Furlong
aed0e3ebf8 populate pixel dims + dpi in PaneEntry
This makes those fields usable in `wezterm cli list --format json`.

This doesn't change the ABI of the mux protocol, but prior to
this commit, those fields were always 0.

refs: #2319
2022-07-31 11:25:39 -07:00
Wez Furlong
bd846975fa allow wheel events with no mods. allow mouse events in mouse reporting mode
Adjusts how mouse events are matched so that we can now indicate whether
mouse reporting and alt-screen should be considered as part of the event
trigger criteria.

refs: #2173
refs: #581
2022-07-31 09:15:02 -07:00
Funami580
cf423dc614 lua: WheelUp and WheelDown support for mouse_bindings 2022-07-31 07:10:56 -07:00
Wez Furlong
10121790df copy mode: pressing v while in v mode toggles off v mode. Add yank.
refs: https://github.com/wez/wezterm/discussions/2246
refs: https://github.com/wez/wezterm/issues/993#issuecomment-1118512595
2022-07-29 05:00:35 -07:00
Wez Furlong
7e3b35303c gui: allow specifying colors for copy mode and quickselect
refs: https://github.com/wez/wezterm/issues/2320

```lua
return {
  colors = {
    copy_mode_active_highlight_fg={Color="red"},
    copy_mode_active_highlight_bg={Color="blue"},
    copy_mode_inactive_highlight_fg={AnsiColor="Black"},
    copy_mode_inactive_highlight_bg={AnsiColor="White"},
    quick_select_label_fg={Color="white"},
    quick_select_label_bg={Color="blue"},
    quick_select_match_fg={Color="grey"},
    quick_select_match_bg={Color="skyblue"},
  }
}
```
2022-07-28 17:54:07 -07:00
Wez Furlong
4c30131a6f lua: expose metrics to lua 2022-07-26 22:33:52 -07:00
Wez Furlong
bc083ee470 termwiz: ColorSpec now allows for alpha to be tracked
This doesn't really change any behavior, but adjusts the types
such that CSIs that set colors have the potential to track the
alpha channel and that can make it through to the GUI/render layer.
2022-07-26 19:39:53 -07:00
Wez Furlong
39adbb984d Pane::search: expose range, limit. Limit quickselect by default
The recent work on the scrollback made it easier to constrain the
search region, so expose those parameters to the Pane::search
interface and to the mux protocol.

Use those new parameters to constrain quickselect search to
1000 rows above and below the current viewport by default, and
add a new parameter to QuickSelectArgs that allows overriding that
range.

A follow-up commit could make the search/copy overlay issue a series
of searches in chunks so that it avoids blocking the UI when
searching very large scrollback.

refs: https://github.com/wez/wezterm/pull/1317
2022-07-25 18:31:27 -07:00
Wez Furlong
dd6d2e1971 search: debounce searches by ~350ms
In order to avoid searching for "c", "ca", "cat" when typing "cat",
this commit introduces a hard-coded 350ms debounce.

refs: https://github.com/wez/wezterm/issues/1569
2022-07-24 13:30:08 -07:00
Wez Furlong
6d61ceac47 search: fix incorrect highlight in search results
If you typed "cat" in the search, the chances are that wezterm
would kick off a search for "c" before you finished typing,
then "ca" and then finally "cat".

There was a race:

clear by_line highlights,
queue search for "c"
clear by_line highlights,
queue search for "ca"
clear by_line highlights,
queue search for "cat"
accumulate highlights for "c" into by_line
accumulate highlights for "ca" into by_line
accumulate highlights for "cat" into by_line

so the final result was a superposition of all of those results,
which was weird!

The fix is simple: clear by_line when we get the results of
an async search.
2022-07-24 13:15:09 -07:00
Wez Furlong
565b03b1c5 localpane: revise search method implementation
Avoids allocating strings for the non-wrapped line case,
has bounded memory usage compared to prior implementation.
2022-07-24 11:38:06 -07:00
Wez Furlong
c2dfba27f3 termwiz: don't claim that visible_cells is double-ended
It's not; there's important state that only works in forward iteration.
2022-07-24 08:11:11 -07:00
Wez Furlong
d5d161b510 termwiz: add clustered line storage for line
Adds the option to use an alternative clusted line storage for
the cells component of the line.

This structure is not optimal for mutation, but is better structured
for:

* matching/extracting textual content
* using less memory than the prior simple vector

For some contrast: the line "hello" occupies 5 Cells in the cell based
storage; that 5 discrete Cells each with their own tiny string
and a copy of their attributes.

The clustered version of the line stores one copy of the cell
attributes, the string "hello" and some small (almost constant size)
overhead for some metadata.  For simple lines of ascii text, the
clustered version is smaller as there are fewer copies of the cell
attributes.  Over the span of a large scrollback and typical terminal
display composition, this saving is anticipated to be significant.

The clustered version is also cheaper to search as it doesn't require
building a copy of the search text for each line (provided the line is
already in clustered form).

This commit introduces the capability: none of the internals request the
new form yet, and there are likely a few call sites that need to be
tweaked to avoid coersion from clustered to vector form.
2022-07-23 12:03:00 -07:00
Wez Furlong
614900f85c line: introduce possibility of alternate cell backing
Uses an enum as a way to use an alternative to Vec<Cell>, but
doesn't provide that alternative in this commit.
2022-07-23 08:18:34 -07:00
Wez Furlong
e26d634da1 termwiz: refactor Line::visible_cells()
Don't promise that we iterate Cell directly, but things that smell
like Cell.  That makes it easier to adjust internal storage in
a later commit.
2022-07-23 07:03:34 -07:00
Wez Furlong
355f3d3975 fix reloading the global config when the appearance changes
We didn't actually update the global config, just the per-window
configs, which led to weird stale throwbacks to earlier versions
of the config when spawning windows or new panes.

Fix that up by explicitly reloading the global config when the
window appearance is changed.  That isn't ideal as we will reload
once per window, but it's "OK".

While poking at this, I noticed that the get/set config methods
on the termwiztermtab overlay weren't hooked up, and also made
a point of calling those for any overlays during a window config
reload event, so that per-window overrides are more likely to get
picked up and respected.

refs: https://github.com/wez/wezterm/issues/2295
2022-07-22 20:23:04 -07:00
Wez Furlong
67ae0e021f fix tab x button being obscured by tab title text
Need to explicitly pop it in front of the tab text layer so that
the button is physically rendered on top of the tab title.

refs: https://github.com/wez/wezterm/issues/2269
2022-07-21 18:51:21 -07:00
Wez Furlong
badfae7d23 gui-startup event now accepts SpawnCommand
This allows the hook to choose how to handle eg: `wezterm start -- top`.
Previously, if you had implemented this event you would essentially lose
the ability to specify a command that you wanted to launch.

refs: https://github.com/wez/wezterm/issues/284
2022-07-19 19:45:27 -07:00
Wez Furlong
aee66daccb key table activation timeout is now reset on matching key presses
refs: https://github.com/wez/wezterm/issues/1129
2022-07-19 06:18:26 -07:00
Wez Furlong
112feb3374 add MuxTab:set_zoomed and SetPaneZoomState keyassignment
refs: #2284
2022-07-19 05:52:38 -07:00
Wez Furlong
1c32ac95bf cargo update
and address deprecation warnings for csscolorparser
2022-07-17 21:14:47 -07:00
Wez Furlong
ec65b64f30 lua: add tostring impls for window, tab and pane objects 2022-07-16 08:22:10 -07:00
Wez Furlong
910879642f retro tab bar: use resolved palette for colors
This allows tab bar colors to be defined in the toml file and
take effect on the fancy tab bar!

an example can be found at: https://github.com/catppuccin/wezterm/blob/main/dist/catppuccin-frappe.toml

refs: https://github.com/catppuccin/wezterm/issues/6
2022-07-16 06:20:26 -07:00
Wez Furlong
2450fed071 fix padding to the right of retro tab bar
refs: https://github.com/wez/wezterm/issues/2210
2022-07-15 18:40:43 -07:00
Wez Furlong
e277183cb9 overlays: handle resize better
We need to actually tell them that the pane has been resized
so now we do.
2022-07-15 16:32:26 -07:00
Wez Furlong
dba7932e3e add wezterm.gui.get_appearance to retrieve dark mode
This simplifies the "change scheme based on dark mode" example
a lot.  This was previously impossible to do because we didn't
have a lua module associated with the gui until recently, so
the only way to reference a gui-related object was via an
event callback.

refs: https://github.com/wez/wezterm/issues/2258
2022-07-14 16:46:18 -07:00
Wez Furlong
49ab340a92 debug overlay: remember last log line globally
It can be confusing to see the same log lines when re-opening
the debug overlay, so this commit remembers the last line
in a global to make that feel more natural.

Because that causes the initial `OpenGL Initialized!` log to
show only in the first instance of the overlay, that log line
is now changed to debug level and the overlay will now
explicitly log the version information, along with some
brief usage text:

```
Debug Overlay
wezterm version: 20220714-001416-810512c2
OpenGL version: AMD BEIGE_GOBY (LLVM 14.0.0, DRM 3.46, 5.18.10-200.fc36.x86_64) 4.6 (Compatibility Profile) Mesa 22.1.3
Enter lua statements or expressions and hit Enter.
Press ESC or CTRL-D to exit
```
2022-07-14 06:53:41 -07:00
Funami580
cfa95db0cc lua: add pane:is_alt_screen_active() 2022-07-12 17:06:16 -07:00
Wez Furlong
179ec9faaf wezterm.mux.set_active_workspace now updates the gui
Attach the mux events to the frontend workspace reconciliation function
so that the window is updated to match the new workspace.

Ensure that we correctly clear out any overlay panes as part of the
switch: we need to remove them from the mux so that the mux will
correctly identify that the mux is empty when the main panes from
the workspace are closed.  The problem case was that the debug overlay
state was forgotten by the gui when activating the new workspace, but
we didn't tell the mux to kill it off, so subsequently CTRL-D'ing
the windows closed the windows but left the wezterm process running with
no head.

refs: #2248
2022-07-12 09:15:38 -07:00
Wez Furlong
79d2f8197b quickselect: select bottom-most match
We don't really know which of the on-screen matches the user was
looking at when they selected the text, but assume that the one
nearest the bottom of the viewport is the one they want to select,
rather than the one closest to the top.

refs: https://github.com/wez/wezterm/issues/2250
2022-07-12 08:17:14 -07:00
Wez Furlong
8e9546fb04 repl: suppress "nil" results
When evaluating an assignment expression like `foo = "bar"` the result
of the expression is nil and we'd print nil on the next line,
which often startles me as I'm used to other languages where the
result of such an expression is the rvalue that was just assigned.

Let's just suppress nil when it is the result of an evaluation
in the repl for a cleaner look.
2022-07-12 07:45:08 -07:00
Wez Furlong
870ffdf59a ensure that we spawn open calls on a background thread
Otherwise we can block the gui waiting for eg: a freshly opened firefox to
terminate.

See also comment worrying about this in
75066cb522.
That fear was realized but now resolved!

refs: https://github.com/wez/wezterm/issues/2245
2022-07-11 08:03:37 -07:00
Wez Furlong
7a5440694d add distro-defaults feature
The intent is that when set, it changes defaults to something
more suitable for distributions.

I've also added a readme for distro maintainers.

refs: https://github.com/wez/wezterm/issues/1795
2022-07-10 16:34:43 -07:00
Wez Furlong
af5938d414 gui: fix padding color when there are splits
refs: https://github.com/wez/wezterm/issues/2210
2022-07-09 14:53:21 -07:00
Wez Furlong
39e727db58 tab bar: invalidate on resize to avoid gaps on the RHS 2022-07-09 10:45:43 -07:00
Wez Furlong
5913783d1e wayland: fix transparent gap under tab bar
Not sure why this only really showed up with Wayland, because the
issue was that the computed tab bar height ended up being 1 or 2
pixels shorter than the area we had allotted.

This commit resolves it by forcing the height to match, and
then aligning the content to the bottom of that region to avoid
having an undesirable line under the tab.

refs: #1256
2022-07-09 10:29:46 -07:00
Wez Furlong
520a8e306f invalid tab bar on scaling changes
refs: #2208
2022-07-09 07:17:03 -07:00
Wez Furlong
61f01f6ed7 allow parsing attributes from launcher labels 2022-07-08 19:28:33 -07:00
Wez Furlong
8f44dc46d9 exec_domains: allow async callbacks. can now also set label for launcher
The fixup callback can now by async, which makes it possible to use
other async functions in the callback.

There is an additional parameter to wezterm.exec_domain that allows
setting the label that is shown in the launcher menu.
It accepts either a string value or an async callback function
that can be used to compute the label dynamically.
2022-07-08 18:46:09 -07:00
Wez Furlong
d78cc6edb8 new: exec_domains
An ExecDomain is a variation on WslDomain with the key difference
being that you can control how to map the command that would be
executed.

The idea is that the user can define eg: a domain for a docker
container, or a domain that chooses to run every command in its
own cgroup.

The example below shows a really crappy implementation as a
demonstration:

```
local wezterm = require 'wezterm'

return {
  exec_domains = {
    -- Commands executed in the woot domain have "WOOT" echoed
    -- first and are then run via bash.
    -- `cmd` is a SpawnCommand
    wezterm.exec_domain("woot", function(cmd)
      if cmd.args then
        cmd.args = {
          "bash",
          "-c",
          "echo WOOT && " .. wezterm.shell_join_args(cmd.args)
        }
      end
      -- you must return the SpawnCommand that will be run
      return cmd
    end),
  },
  default_domain = "woot",
}
```

This commit unfortunately does more than should go into a single
commit, but I'm a bit too lazy to wrangle splitting it up.

* Reverts the nil/null stuff from #2177 and makes the
  `ExtendSelectionToMouseCursor` parameter mandatory to dodge
  a whole load of urgh around nil in table values. That is
  necessary because SpawnCommand uses optional fields and the
  userdata proxy was making that a PITA.
* Adds some shell quoting helper functions
* Adds ExecDomain itself, which is really just a way to
  to run a callback to fixup the command that will be run.
  That command is converted to a SpawnCommand for the callback
  to process in lua and return an adjusted version of it,
  then converted back to a command builder for execution.

refs: https://github.com/wez/wezterm/issues/1776
2022-07-07 16:38:14 -07:00
Wez Furlong
dbc2c85361 add window:toggle_fullscreen()
You can start a window in full screen mode using something like:

```lua
local wezterm = require 'wezterm'

local mux = wezterm.mux

wezterm.on("gui-startup", function()
  local tab, pane, window = mux.spawn_window{}
  window:gui_window():toggle_fullscreen()
end)

return {
}
```

refs: #177
refs: #284
2022-07-06 23:57:32 -07:00
Wez Furlong
8853df02ca lua: add window:maximize() and window:restore() methods
Implemented on macOS only for the moment.

refs: https://github.com/wez/wezterm/issues/284
2022-07-06 23:11:02 -07:00
Wez Furlong
533e52c589 lua: make gui_window() reconcile workspace
reconciling causes gui windows to be created and allows for stuff like
this, that would otherwise fail because the gui window hadn't been
created yet.

```lua
local wezterm = require 'wezterm'

local mux = wezterm.mux

wezterm.on("gui-startup", function()
  local tab, pane, window = mux.spawn_window{}
  window:gui_window():set_inner_size(1200, 1200)
end)

return {
}
```
2022-07-06 18:52:14 -07:00
Wez Furlong
3e01d44ece add window:set_position window:set_inner_size 2022-07-06 18:49:39 -07:00
Wez Furlong
87ce88b924 lua: add wezterm.gui.gui_window_for_mux_window()
This is the inverse of wezterm.mux.get_window()
2022-07-06 15:39:43 -07:00
Wez Furlong
a6cf13e1e2 lua: add wezterm.window.screens()
Currently implemented on X11 only, this function returns information
about the geometry of the screen(s).

This is taken from the same source of information we use for the
`--position` CLI argument to `wezterm start`.

```
> wezterm.window.screens()
{
    "by_name": {
        "DisplayPort-1": {
            "height": 2160,
            "name": "DisplayPort-1",
            "width": 3840,
            "x": 0,
            "y": 0,
        },
    },
    "main": {
        "height": 2160,
        "name": "DisplayPort-1",
        "width": 3840,
        "x": 0,
        "y": 0,
    },
    "origin_x": 0,
    "origin_y": 0,
    "virtual_height": 2160,
    "virtual_width": 3840,
}
```
2022-07-06 08:35:05 -07:00
Wez Furlong
082c61c2c3 ensure that we reset attributes to defaults when producing escapes
refs: https://github.com/wez/wezterm/issues/2223
2022-07-06 07:21:08 -07:00
Wez Furlong
00fb0c58f3 Add window:get_selection_escapes_for_pane()
This method extracts the selected text in a form that includes
escape sequences.

refs: https://github.com/wez/wezterm/issues/2223
2022-07-05 22:01:16 -07:00