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

633 Commits

Author SHA1 Message Date
Wez Furlong
2dcf7ad98d
keyboard: plumb more modifier+state information through
This commit teaches the termwiz layer about positional modifiers,
and expands our modifier concept to also pass through led states
such as caps lock and num lock.

Those aren't actually keyboard modifiers, but the state is useful
to recognize.

Adjust the shift key normalization so that we don't uppercase
alpha characters when both SHIFT and CAPS_LOCK are held.
This processing will remove both SHIFT and CAPS_LOCK in that
situation.

Add a method to KeyEvent that will undo the OS keyboard layer
normalization of positional to generic modifier key presses.
eg: the OS may map LeftControl -> Control, but we actually
prefer to have LeftControl so if we can unambiguously reverse
that mapping, we do so.

refs: #3476
refs: #3475
2023-04-09 10:34:53 -07:00
Wez Furlong
397593be5c
kitty keeb: fixup shifted character encoding
refs: https://github.com/wez/wezterm/issues/3474
2023-04-08 20:01:10 -07:00
Wez Furlong
0540301121
kitty keeb: add test case for #2546
This passes, so I'm assuming that one of the other kitty
commits from today has resolved this.

refs: https://github.com/wez/wezterm/issues/2546
2023-04-08 19:28:22 -07:00
Wez Furlong
8bb39bd6f3
fixup kitty keyup events for alphabetical keys
refs: https://github.com/wez/wezterm/issues/3220
2023-04-08 19:19:27 -07:00
Wez Furlong
d239e65e64
fixup kitty keyboard encoding for F1-F4
refs: https://github.com/wez/wezterm/issues/3473
2023-04-08 18:19:07 -07:00
Wez Furlong
7b40f01054
switch to fancy-regex crate
Enables back references and look around assertions for quick select
and hyper link rules

refs: https://github.com/wez/wezterm/issues/3247
2023-04-07 17:39:00 -07:00
Jalil David Salamé Messina
6dd8a98ff3 fix: Derive Eq on Selection 2023-03-27 07:38:55 -07:00
Jalil David Salamé Messina
2315834109 fix: Use serde with bitflags 2023-03-27 07:38:55 -07:00
Jalil David Salamé Messina
c2f63c296b fix: Formatting 2023-03-27 07:38:55 -07:00
Jalil David Salamé Messina
fc5e8b4f3d fix: Update signal-hook to 0.3 and fix compilation errors
- Some functions are now under the `low_level` module, use that
2023-03-27 07:38:55 -07:00
Jalil David Salamé Messina
344f133608 chore: Update criterion to 0.4 2023-03-27 07:38:55 -07:00
Jalil David Salamé Messina
05df6ec054 chore: Update nix to 0.26 2023-03-27 07:38:55 -07:00
Jalil David Salamé Messina
7f89f46ae5 fix: Update bitflags to 2.0 and fix compilation errors
- v2.0 no longer derives a bunch of traits (Debug, Clone, Copy, PartialEq, Eq)
  by default, so I manually derived them.
- It also changed the snapshot results so I updated them:

  An empty bitflags struct is no longer displayed as `None` but as
  `BitFlags(0x0)`.

- `bits` is no longer a field but a method so I added the missing
  parenthesis.
2023-03-27 07:38:55 -07:00
Jalil David Salamé Messina
7721126fdd chore: Update phf to 0.11 2023-03-27 07:38:55 -07:00
Wez Furlong
5b51179265
deps: update sha2
closes: https://github.com/wez/wezterm/pull/3379
2023-03-26 19:50:53 -07:00
Wez Furlong
2e488d57c7
update terminfo to 0.8 2023-03-24 10:12:49 -07:00
Wez Furlong
bc7acc18e0
fixup images with the multiplexer
* Translate from File to EncodedFile as needed
* Adopt blob leases in the mux server
* Fix an issue where the first image sent by the mux server would
  be replaced on the client by its background image, if configured.
  Removed the ImageData::id field to resolve this: you should use
  the hash field instead to identify and disambiguate images.
  Bumped the termwiz API version because this is conceptually
  a breaking change to the API

refs: https://github.com/wez/wezterm/issues/3343
2023-03-23 21:43:28 -07:00
Wez Furlong
0f8146b212
docs: shift from return {} style to config.something style
Nudge new users towards using this style:

```lua
local config = {}
config.color_scheme = 'Batman'
return config
```

and surface how to write lua modules closer to the main section
on config files. In that lua modules section, nudge towards using
a convention similar to that of the plugin spec described in
this commit: e4ae8a844d
2023-03-19 18:26:21 -07:00
Wez Furlong
c1e9bcba5f
fix non-serde termwiz build 2023-03-18 22:21:42 -07:00
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
6a9dfc409d
improve default hyperlink_rules. add default_hyperlink_rules()
refs: https://github.com/wez/wezterm/issues/928
2023-03-16 20:44:15 -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
Aram Drevekenin
f2e342a25f fix(input): support alt-left-bracket 2023-02-12 05:46:17 -08:00
Wez Furlong
44e162a986
fonts: update Symbols Nerd Font Mono
This is "NerdFontsSymbolsOnly/Symbols-1000-em Nerd Font Complete Mono.ttf" from
https://github.com/ryanoasis/nerd-fonts/releases/tag/v2.3.3
2023-02-06 06:29:32 -07:00
Thomas Linford
aadc8224e9 finish test 2023-02-05 06:32:03 -08:00
Thomas Linford
ad8c393fbb fix: correctly set WHEEL_POSITIVE 2023-02-05 06:32:03 -08:00
Thomas Linford
96ed17aaca wip: horizontal scroll support 2023-02-05 06:32:03 -08:00
Wez Furlong
36519f0d90
fix crash bug uncovered by rust 1.67
Rust 1.67, released today, is a bit more particular about the layout
of the memory used in TeenyString and segfaults in the test suite.

On closer inspection, our Drop impl was casting to Vec<u8> instead of
TeenyStringHeap and the fault was freeing bogus memory within that
region.

Fixing the cast to the correct type resolves the issue.
2023-01-26 17:00:21 -07:00
Wez Furlong
d34297cd2c
update base64, work around another batch of breaking API changes
closes: https://github.com/wez/wezterm/pull/2931
2023-01-08 18:49:45 -07:00
Wez Furlong
fe60155d3d
withdraw DEC private SGR handling for super/subscript
refs: https://github.com/mintty/mintty/issues/1189
refs: https://github.com/mintty/mintty/issues/1171
2022-12-19 11:37:53 -07:00
Wez Furlong
91ea1095c9
deps: update base64
closes: https://github.com/wez/wezterm/pull/2855
2022-12-12 09:15:09 -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
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
4ed2fd8e94 wezterm.terminfo: add statusline entries
nvim uses these to set the title string; really, it is setting the
status line, but it has an assumed fallback for xterm that redefines the
status line update operations in terms of setting the title of the xterm
window.

Let's ensure that our terminfo has these entries defined, as the nvim
fallback currently looks for `xterm` in the value of $TERM to decide
whether the fallback is appropriate, and that test does not pass when
the user has set term=wezterm.

refs: https://github.com/neovim/neovim/issues/20706
refs: https://github.com/wez/wezterm/issues/2635

See also: https://codeberg.org/dnkl/foot/pulls/243/files,
https://codeberg.org/dnkl/foot/issues/242,
https://github.com/alacritty/alacritty/issues/1636
2022-11-06 20:57:58 -07:00
Wez Furlong
40e08fafe2 rust 1.65 does a better job with enum packing
so adjust test expectations

refs: https://github.com/wez/wezterm/pull/2700
2022-11-03 19:57:02 -07:00
Wez Furlong
a6fc9323e2 termwiz: release 0.19 2022-11-02 08:16:09 -07:00
Jonathan LEI
4df6d2a477 fix: temp fix for Android build error 2022-11-02 08:08:35 -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
7b904f05eb termwiz: fixup for 32-bit systems
I noticed from https://github.com/void-linux/void-packages/pull/36903
that 32-bit systems were failing to pass the test suite.

Running `cargo test --target i686-unknown-linux-gnu  -- --nocapture
teeny_string` showed that we were faulting in the teenystring code
and digging a bit deeper showed that it was because our assumptions
about the high bits were wrong for 32-bit systems.

Fix this by making TeenyString based around a u64 rather than usize
so that we guarantee its size on all current systems.
2022-10-15 16:45:02 -07:00
Wez Furlong
75f7d505ef termwiz: update widechar_width for unicode 15
Sync from the upstream data.  Note that I upstreamed our local
perf improvements in https://github.com/ridiculousfish/widecharwidth/pull/23
and this is a copy of the result of that PR, with rustfmt applied.
2022-10-15 15:45:06 -07:00
Wez Furlong
6415ba0e16 fmt 2022-10-12 09:26:13 -07:00
Wez Furlong
13e57fa0b5 fix wrapping issue with double-wide cells and hyperlink rules
We weren't including the invisible space cells into the model
as part of building up the logical line, resulting in the logical
line being shorter than it should have been.

That resulted in some of the components of the double wide cells
not being rendered in the correct place.

refs: https://github.com/wez/wezterm/issues/2571
refs: https://github.com/wez/wezterm/issues/2568
2022-10-12 09:23:21 -07:00
Charlie Groves
c764888186 Allow cursor visibility to be changed by widgets 2022-10-08 12:34:58 -07:00
Charlie Groves
37f65bb1f3 Expose applying an AttributeChange on CellAttributes 2022-10-08 08:17:46 -07:00
Wez Furlong
42f855d912 termwiz: request xterm modifyOtherKeys
When in raw mode, go to level 2, but use level 1 for cooked
so that we don't obfuscate ctrl-c.

A consequnce of this is that CTRL-C is now reported to the app
as CTRL-lowercase-c where we previously reported as CTRL-uppercase-C.
Made a note of the breaking nature of this change in a new changelog
file.

Fixed recognizing SHIFT-TAB

refs: https://github.com/wez/wezterm/issues/2511
2022-09-21 21:07:10 -07:00
Wez Furlong
c91d6c396c termwiz: prepare for a 0.18.0 release 2022-09-21 19:20:26 -07:00
Muir Manders
1dcec5e5ae termwiz: add flag to force use of standard ANSI SGR codes
With a TERM of "screen-256color" or "screen", common attributes such
as bold are rendered with a \x0f AKA ^O AKA \017 code that
makes pagers such as less and streampager grumpy. In particular,
streampager renders as inverted "<0F>" and less as inverted "^O".

Add a new flag force_terminfo_render_to_use_ansi_sgr which makes the
TerminfoRenderer ignore the terminfo entries for common attributes,
instead using the standard ANSI/ECMA-48 sequences.
2022-09-21 19:17:49 -07:00
Wez Furlong
6d375091a1 termwiz: recognize some dec private SGR codes
Recognize DEC private SGR codes that are equivalent to
super/subscript, overline and reset.

refs: https://github.com/mintty/mintty/issues/1171#issuecomment-1250317539
2022-09-19 20:46:15 -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
e2c658e598 termwiz: fix recognizing \u{1b}[>4;m as modifyOtherKeys
refs: https://github.com/wez/wezterm/issues/2527
2022-09-18 06:22:57 -07:00
Wez Furlong
427477dfb1 termwiz: update nerdfont symbol data
This makes codicons available by name to lua, and to have them
show up in the charselect modal.
2022-09-17 07:36:24 -07:00
Wez Furlong
85db555b37 deps: update finl_unicode 2022-09-16 07:47:33 -07:00
Wez Furlong
e1a0b63923 termwiz: track size of sgr enum 2022-09-10 07:23:11 -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
a0c2df2d86 Line: save 8 bytes per line 2022-09-09 21:39:31 -07:00
Wez Furlong
55fa2e7893 fmt 2022-09-09 21:22:17 -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
7a0461989e termwiz: add test to track size_of Action
no functional change
2022-09-09 21:03:19 -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
dbacf98b89 fix incorrect underline attribute when scrolling
Given this sequence:

ENABLE-UNDERLINE CRLF SGR-RESET

if the CRLF caused the terminal to scroll, the newly created line
at the bottom would be filled in with a "blank" cell that had
the underline attribute set.

That's because we're supposed to preserve the coloring in that
scenario, but we were also preserving other SGR attributes.

This commit explicitly clears out under, over and strikethrough
lines from these blank attributes.

refs: https://github.com/wez/wezterm/issues/2489
2022-09-06 20:06:01 -07:00
Wez Furlong
d8e43b92b8 termwiz: slim down size of clustered line storage
Move is_double_wide to a box; it is relatively rare to need
this and we're okay with it being a separate heap allocation
when it is needed if it reduces the size of Line in the common case.
2022-09-06 18:56:29 -07:00
Wez Furlong
62ca174d19 termwiz: remove assertions
I don't think these are really necessary any more; the implementation
cannot go out of bounds, so the worst that can happen is that we
don't return any changes.

refs: https://github.com/wez/wezterm/issues/2222
2022-09-04 10:19:17 -07:00
Wez Furlong
9732f9ee2b Adjust render caching; switch to LFU caches from LRU 2022-08-28 10:28:26 -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
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
66761ed014 termwiz: use interior mutability for Line::set_appdata 2022-08-25 06:19:56 -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
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
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
9cce9ff81b fix potential panic when computing hyperlink rules
refs: https://github.com/wez/wezterm/issues/2355
2022-08-03 21:34:12 -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
33866dad70 termwiz: fix min version dep on winapi. publish 0.17.1
Need at least 0.3.5 (I think) for the type used in
https://github.com/wez/wezterm/pull/2349 as well as the impl-default
feature.

refs: https://github.com/markbt/streampager/issues/57#event-7110671310
2022-08-02 18:21:49 -07:00
Mateusz Kwapich
edbc98304b [termwiz] add impl-default feature to winapi dep to fix the build
Without the feature the build fails with:

    --> src\escape\apc.rs:377:57
     |
377  |         let mut memory_info = MEMORY_BASIC_INFORMATION::default();
     |                                                         ^^^^^^^ function or associated item not found in `MEMORY_BASIC_INFORMATION`
     |
2022-08-02 13:29:05 -07:00
Wez Furlong
673ca3ad07 color types version bump for crates.io 2022-08-01 18:41:52 -07:00
Wez Furlong
56de27c773 bidi version bump for publish to crates.io 2022-08-01 18:38:44 -07:00
Wez Furlong
edeae72b5f termwiz: bump version to 0.17 2022-08-01 18:31:43 -07:00
Mark Juggurnauth-Thomas
40df2f14d2 termwiz: ensure ST sequence is grouped with OSC
When `parse_first_as_vec` is parsing an OSC sequence (e.g.
`SetHyperlink`) that is terminated by the escaped form of ST (`ESC \`),
ensure that the ST sequence is included in the returned vector.

This is achieved by ensuring the VTParser has returned to the "ground"
state: i.e. the stored state after the `ESC` is processed is not enough
for `parse_first_as_vec` to terminate.  We must also parse the `\` to
ensure that we return a complete span to the caller.

Fixes https://github.com/markbt/streampager/issues/57
2022-08-01 18:30:04 -07:00
Wez Furlong
b1c60ba258 termwiz: add test cases for parse_first_as_vec w/ OSC+ST
refs: https://github.com/markbt/streampager/issues/57
2022-07-29 06:40:26 -07:00
Wez Furlong
718a021817 termwiz: use 6 for the rgba colorspace
`4` is actually defined as CMYK according to ITU-T Rec. T.416:

> A parameter substring for values 38 or 48 may be divided by one or more separators (03/10) into parameter elements,
> denoted as Pe. The format of such a parameter sub-string is indicated as:
>
>     Pe : P ...
>
> Each parameter element consists of zero, one or more bit combinations from 03/00 to 03/09, representing the digits
> 0 to 9. An empty parameter element represents a default value for this parameter element. Empty parameter elements at
> the end of the parameter substring need not be included.
>
> The first parameter element indicates a choice between:
>
> 0    implementation defined (only applicable for the character foreground colour)
> 1    transparent;
> 2    direct colour in RGB space;
> 3    direct colour in CMY space;
> 4    direct colour in CMYK space;
> 5    indexed colour.

refs: 6e9a22e199 (commitcomment-79669016)
2022-07-28 17:09:15 -07:00
Wez Furlong
c7c81e3161 really fix termwiz --all-features build 2022-07-26 22:35:49 -07:00
Wez Furlong
9559404c3c fix termwiz --all-features build 2022-07-26 21:26:20 -07:00
Wez Furlong
6e9a22e199 termwiz: allow setting alpha for SGR fg, bg attributes
This commit extends the sgr color parser to support a wezterm
extension that I just made up:

```
printf "\e[48:4:255:0:0:60mhello\e0m"
```

The `4` is wezterm specific and denotes 4 channel color, in this case
RGBA. red is 255, green is 0, blue is 0 and alpha is 60; the values are
interpreted as u8 values.

CSI 38 (fg), 48 (bg) and 58 (underline) support this.

refs: https://github.com/wez/wezterm/issues/2313
2022-07-26 21:05:18 -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
cb89f2c36e allow setting alpha for OSC 10, 11, 12
refs: https://github.com/wez/wezterm/issues/2313
2022-07-26 19:02:47 -07:00
Wez Furlong
c32db29474 termwiz: refactor: split line into sub-modules 2022-07-25 07:20:59 -07:00
Wez Furlong
9deed0b8b4 Line::wrap now prefers cluster storage
Want to avoid inflating scrollback when the window is resized
2022-07-24 16:05:42 -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
e8dfb553b4 termwiz: microoptimize ClusteredLine::set_last_cell_was_wrapped
Cache the last cell width so that we can avoid iterating the whole
line cell-wise to compute it for time cat bigfile.
2022-07-24 08:36:04 -07:00
Wez Furlong
656f725623 termwiz: micro-optimize ClusteredLine::new(), set_last_wrapped 2022-07-24 08:18:23 -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
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