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

1225 Commits

Author SHA1 Message Date
Wez Furlong
ab8a4f129c
command palette: first pass
This commit introduces a rough first pass at a command palette modal.
It is an adaptation of the emoji character selector and needs
refinement.

Importantly, the default pane selector key assignment now calls
into this new command palette instead.

refs: https://github.com/wez/wezterm/issues/1485
2022-12-22 20:24:57 -07:00
Wez Furlong
6479df63b9
removed deprecated Copy, Paste, PastePrimarySelection actions
These have been deprecated since early 2021; time to remove them
and simplify a little.
2022-12-22 07:31:18 -07:00
Wez Furlong
82da1b42f7
launcher: prefer to use human description of key assignment
refs: https://github.com/wez/wezterm/issues/1485
2022-12-21 13:31:05 -07:00
Wez Furlong
98479d8530
Re-organize default command list
refs: https://github.com/wez/wezterm/issues/1485
2022-12-21 13:26:18 -07:00
Wez Furlong
01962235f4
add descriptions for all keyassignment actions
refs: https://github.com/wez/wezterm/issues/1485
2022-12-21 13:08:24 -07:00
Wez Furlong
669fec9a9f
adjust default command list
re-structure it so that we have a list of default action values,
and a function that can compute the command description from them.

This allows describing user-specified actions in the future,
as well as reducing some boilerplate: we can now generate eg:
ActivateTab(n) description text without hardcoding similar
alternatives.

refs: https://github.com/wez/wezterm/issues/1485
2022-12-21 11:00:45 -07:00
Wez Furlong
37b5dd91a5
move OpenInBrowser -> KeyAssignment
This allows defining those help actions that open URLs in the main
commands list, and not just for the macOS Help menu.

refs: https://github.com/wez/wezterm/issues/1485
2022-12-21 07:04:51 -07:00
Wez Furlong
4b3660d166
macos: allow running when there are no windows
Most of this commit is refactoring the spawn logic so that we
can reuse most of it to handle spawn requests when there is
no GUI window.
2022-12-21 00:31:58 -07:00
Wez Furlong
f7eb13dd8d
put quit at bottom of application menu 2022-12-21 00:31:58 -07:00
Wez Furlong
787f6550b8
macos: link to helpful resources from Help menu 2022-12-21 00:31:58 -07:00
Wez Furlong
b224aa1b56
macOS: add MenuBar
This took a decent amount of effort to thread through with context;
wrappers around NSMenu and NSMenuItem are added to reduce some of
the objc usability warts, and an additional NSObject wrapper is
added to help copy the KeyAssignment from the existing list
of command palette commands and associate it with the menu item.

When a menu item is selected, macOS will walk through the responder
chain and look for a responder that responds to the selector associated
with the menu item.  In practice that means that our window/view class
will be tried first, and then later, our app delegate will be tried.

This commit implements routing from both of these: the window case
routes to the associated TermWindow and drops into the existing
perform_key_assignment method.

In case there is no window (not currently possible, but will be
in the future), the app delegate also has a placeholder for dispatching
key assignments, although it will only be able to perform a subset
of the possible actions.

A couple of things to note:

* Items aren't smart enough to disable themselves or adjust their
  caption based on the context. To make that work, we either need
  to recreate the entire menubar when any possible context changes
  (doable, but feels heavy), or we need to assign a target to each
  menu item and implement a validation handler on that target.
  That seemed to mess with the responder chain when I briefly
  experimented with it.

* There's some disabled code to add a Services menu. It is disabled
  because when it is enabled, accessing either Services or Help
  from the menu bar sends the process into a busy loop somewhere
  in macOS's internals.  It's unclear what it is unhappy with.

* No keyboard accelerators are associated with the menubar yet.
  That needs some thought, as they would essentially become global
  keyboard shortcuts and take precedence over the shortcuts defined
  for other keys in the config.  This feels like it should be something
  that the user has control over, so there needs to be something to
  allow that before we go ahead and wire those up.

refs: https://github.com/wez/wezterm/issues/162
refs: https://github.com/wez/wezterm/issues/1485
2022-12-20 19:46:08 -07:00
Wez Furlong
eb8dfd32b3
macos: use interactive shell for .command scripts
This is primarily so that the user's environment is set up prior
to invoking the script.

refs: #2871
2022-12-20 08:30:07 -07:00
Wez Furlong
02eb0b4294
mux: rename Mux::get() -> try_get(), add "infallible" Mux::get()
This allows removing a bunch of unwrap/expect calls.

However, my primary motive was to replace the cases where we used
Mux::get() == None to indicate that we were not on the main thread.

A separate API has been added to test for that explicitly rather than
implicitly.
2022-12-19 11:55:35 -07:00
Wez Furlong
478cc59be3
mux: Mux is now Send+Sync 2022-12-19 11:54:02 -07:00
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