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

1090 Commits

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