1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-22 13:16:39 +03:00
Commit Graph

596 Commits

Author SHA1 Message Date
Wez Furlong
7cd0cc21bf
ImageDataType::File -> EncodedLease
Adopt the new blob lease layer to storing and referencing
image files.

This reduces the number of open files needed when
images are being displayed in the terminal.

refs: https://github.com/wez/wezterm/issues/3263
2023-03-18 20:32:49 -07:00
Wez Furlong
2d255c2d75
fix kitty image protocol handling
Input data:

\e_Ga=T,f=32,s=10,v=22,c=1,r=1,m=1\e\\e_Gm=1;/xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T//P=\e\\e_Gm=1;/xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T////E////xP///8T//P=\e\\e_Gm=0\e\

There were two issues in handling this:

* We expected there to be `;payload` in the first transmission packet,
  but there wasn't one, so we ignored it as ill-formed.
* The standard base64 decoder in the rust ecosystem is super strict
  and rejects the "sloppy" python base64 encoder output that isn't
  strictly conformant with the RFC.  We need to jump through some
  hoops to get it to relax and accept the input.

refs: https://github.com/wez/wezterm/issues/2716
2023-03-17 15:39:01 -07:00
Wez Furlong
e090eb9eae
Image decoding is now done in a bg thread
Continuing from the previous commit, this shifts:

* In-memory data -> temporary file
* Image decoding -> background thread

The background thread asynchronously decodes frames and
sends them to the render thread via a bounded channel.

While decoding frames, it writes them, uncompressed, to
a scratch file so that when the animation loops, it is
a very cheap operation to rewind and pull that data
from the file, without having to burn CPU to re-decode
the data from the start.

Memory usage is bounded to 4 uncompressed frames while
decoding, then 3 uncompressed frames (triple buffered)
while looping over the rest.

However, disk usage is N uncompressed frames.

refs: https://github.com/wez/wezterm/issues/3263
2023-03-17 11:41:20 -07:00
Wez Furlong
aa929a1a9b
move animation decoding from term layer to gui layer
This makes decoding animation frames a lazy operation, but it
comes at the cost of needing to re-decode the image from scratch
when it loops, because the image crate doesn't provide a way
to rewind its frame iterator.

That initial decode can have a significant time cost; a small
webp file consistently takes 150ms to decode, which is too
much to do inline in the render thread.

Next steps will be to move that cost off the render thread.
2023-03-17 11:41:20 -07:00
Wez Furlong
587ceca98e
term: avoid breaking animated webp images when resizing
refs: https://github.com/wez/wezterm/issues/3258
2023-03-16 22:55:38 -07:00
Wez Furlong
97452d0ccc
term: improve readability of error message for oversized image
refs: https://github.com/wez/wezterm/issues/3264
2023-03-16 22:41:52 -07:00
Wez Furlong
a115fc0df7
fix iterm2 image cursor position
refs: https://github.com/wez/wezterm/issues/3266
2023-03-16 21:53:13 -07:00
Jalil David Salamé Messina
cb9dc3a800 fix(clippy): Remove unnecessary clone/to_string calls 2023-03-16 07:40:12 -07:00
Wez Furlong
5e5f816f83
add log_unknown_escape_sequences config option 2023-03-15 22:47:32 -07:00
Wez Furlong
2bfb29f1be
improve handling of animated webp images
Use mainline image crate to avoid an otherwise unavoidable panic
in the upstream: https://github.com/image-rs/image/issues/1775

Explicitly operate on the frames from the animation.

refs: https://github.com/wez/wezterm/issues/3250
2023-03-15 11:34:47 -07:00
Wez Furlong
3509e210ce
termwiz: bump version ready for publish 2023-02-12 06:57:31 -07:00
Wez Furlong
9dc76b852b
lua: add some more tab methods 2023-01-20 20:02:29 -07:00
Wez Furlong
15cd1afbdc
lua: add some pane methods for working with zones
refs: https://github.com/wez/wezterm/issues/2968
2023-01-18 19:38:51 -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
e70f97903b
disable window title reporting escape sequence by default 2022-12-18 10:37:21 -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
Wez Furlong
274b1819a1
Fix horizontal wheel events
refs: https://github.com/wez/wezterm/issues/2649
2022-11-13 08:58:35 -07:00
Wez Furlong
a6fc9323e2 termwiz: release 0.19 2022-11-02 08:16:09 -07:00
Wez Furlong
b1faba9d8a deps: upgrade finl_unicode to 1.2 2022-10-23 12:07:00 -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
ed63d728bf term: support utf8 mouse reporting (DECSET 1005) 2022-10-10 23:06:40 -07:00
Wez Furlong
47a15153b9 rename normalize_to_nfc to normalize_output_to_unicode_nfc
Makes it a bit more verbose, but also a bit clearer what it does.

refs: #2482
2022-09-24 19:41:37 -07:00
Wez Furlong
c91d6c396c termwiz: prepare for a 0.18.0 release 2022-09-21 19:20:26 -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
754d80db85 term: ignore various unsupported private mode codes 2022-09-18 09:56:31 -07:00
Wez Furlong
47f4987687 Add preliminary support for xterm's modifyOtherKeys encoding
see: https://invisible-island.net/xterm/modified-keys.html

I wouldn't be surprised if I've missed some cases, but this seems
to work for the keys mentioned in this issue:

refs: https://github.com/wez/wezterm/issues/2527
2022-09-18 08:26:08 -07:00
Wez Furlong
85db555b37 deps: update finl_unicode 2022-09-16 07:47:33 -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
ef14f78e08 Reduce size of Action
Action is used to encode parsed terminal output and shuttle it between
the thread that does the parsing and the main gui thread that applies
it to the terminal model.

Take it down from 184 bytes to 40 bytes (on 64-bit systems).  This seems
to boost `time cat bigfile` by reducing the runtime to ~40% of its prior
duration: down from 8s -> 4.5s on an M1 macbook air.

Size reductions achieved by Box'ing relatively less frequently
used enum variants. The kitty image data variant is particularly
large, and the Window variant is also pretty heavy.
2022-09-09 21:11:11 -07:00
Wez Furlong
2bbad26dd1 sixel: skip setting pixel if x-coord is out of range
speculative fix for https://github.com/wez/wezterm/issues/2500
which doesn't repro for me(!)
2022-09-07 16:47:42 -07:00
Wez Furlong
77ed919098 invalidate the display when using ClearScrollback("ScrollbackAndViewport")
refs: https://github.com/wez/wezterm/issues/2498
2022-09-07 05:36:50 -07:00
Wez Furlong
c25e6820ef add normalize_to_nfc config option
refs: #2482
2022-09-06 08:58:09 -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
4963187eaf termwiz: associate appdata with a Line
I plan to use this to hang cached shaper data with a line
and avoid expensive hashing to resolve it.
2022-08-24 20:11:27 -07:00
Wez Furlong
35ed9ac197 conpty: work around mangled tmux title sequence
refs: https://github.com/wez/wezterm/issues/2442
2022-08-21 18:14:13 -07:00
Davide Cavalca
0048209bcf Add missing license files 2022-08-17 07:19:12 -07:00
Wez Furlong
259210dc2d term: hook flush up to ThreadedWriter
I'd forgotten that this was in here.
The recentish fixes to flush for various terminal queries
likely need this to be 100% good.  Surprised this hasn't
come up as a bug already :-/
2022-08-12 07:55:18 -07:00
Wez Furlong
edeae72b5f termwiz: bump version to 0.17 2022-08-01 18:31:43 -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
858bc3ccce term: avoid panic in phys_row when row is out of range
Just clamp it to the current physical, non-scrollback portion
of the screen.

This avoids a panic but doesn't address the screen size mismatch
in the associated issue.

refs: https://github.com/wez/wezterm/issues/2133
2022-07-26 09:40:44 -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
4bf89e0c10 term: fixup cursor position during rewrap
refs: https://github.com/wez/wezterm/issues/2162
2022-07-24 22:55:46 -07:00
Wez Furlong
dec5ca0349 term: refactor getting logical lines
This will make it easier to refactor search in a subsequent commit
2022-07-24 10:57:05 -07:00
Wez Furlong
c722db22d6 term/termwiz: microoptimize set cell
If we can avoid constructing a Cell then do so
2022-07-24 09:14:44 -07:00
Wez Furlong
7be01110ca termwiz: avoid cluster -> vec conversions in a few more cases
This reduces the resident memory by another ~10% because it avoids
keeping as many runs of whitespace.

Runtime for `time cat enwiki8.wiki` is still ~11-12s, resident: 530K

refs: https://github.com/wez/wezterm/issues/1626
2022-07-24 07:57:33 -07:00
Wez Furlong
8002a17242 term: default to cluster storage
The previous commit added the option to convert the storage to
the cluster format.  That saves memory as rows are moved to scrollback,
but makes scrolling back more expensive due to that conversion.

This commit adds a fast(ish) path for the common case of simply
appending text to a new line before it gets scrolled: the default
format for lines in the screen is now the cluster format and,
provided that the cursor moves from left to right as text is
emitted, can simply append to the cluster storage in-place
and avoids a conversion when the line is moved to scrollback.

This improves the throughput of `time cat enwiki8.wiki` so
that the runtime is typically around 11-12s (compared to 9-10s
before introducing cluster storage).  However, this is often
a deal of variance in the measured time and I believe that
that is due to the renderer triggering conversions back to
the vec storage and introducing slowdowns from the render side.

That's what I'll investigate next.
2022-07-23 22:54:43 -07:00
Wez Furlong
751dd460da term: compress rows as they move into scrollback
This commit causes lines to be "compressed" (really, just translated
to the new clustered line storage variant) as they move into scrollback.

The memory savings are significant for large scrollback:

`wezterm -n --config scrollback_lines=1000000`

`time cat enwiki8.wiki`

before: ~9s, Resident: 2.1G
after: ~15s, Resident: 620K (!)

The performance impact is non-trivial, and I will dig into that
next.

refs: https://github.com/wez/wezterm/issues/1626
2022-07-23 13:01:48 -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
3547efc567 term: refactor the charset/remapping out of flush_print
I wanted to rule it out of the profile, so put it in its own function
to confirm that it had neglibible cost for time cat bigfile.
2022-07-22 19:23:41 -07:00