1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-25 21:07:39 +03:00
Commit Graph

448 Commits

Author SHA1 Message Date
Wez Furlong
6f78ee4f14 deps: update unicode-segmentation to 1.8 2021-08-11 23:06:17 -07:00
Wez Furlong
6c2f9f2d18 term: restore line length pre-allocation
A while back I made the line lengths lazily grown; the reduction
in memory was nice, and it helped with render performance for
really wide screens.

Unfortunately, it puts a bunch of reallocation into the hot path
of the parser and updating the terminal model when people run
the inevitable `cat giant-file.txt` benchmark.

This commit reinstates pre-allocating lines to match the physical
terminal width, and tweaks the code a bit to take advantage of
const Cell allocation and to avoid some clones (a really micro
optimization).
2021-08-11 23:06:17 -07:00
Wez Furlong
9134da8c07 term: reuse string buffer for flush_print
Avoids allocating and discarding on separate passes
2021-08-11 23:06:17 -07:00
Wez Furlong
c90ccec102 micro-optimize TeenyString and cell width
For simple graphemes, we can avoid subsequently calling
grapheme_column_width and cache that information in TeenyString.

Make blank TeenyString and Cell initializations const.
2021-08-11 23:06:17 -07:00
Wez Furlong
1e7c7e7059 term: micro optimize flush_print: directly call grapheme_column_width
Saves an additional call through unicode segmentation
2021-08-11 23:06:16 -07:00
Wez Furlong
80d261977f term: avoid dirtying lines when the cursor moves
Tag CursorPosition with the seqno of the cursor move instead.
This should avoid over-invalidating lines and the selection
if it was just the cursor that moved.
2021-08-08 22:47:10 -07:00
Wez Furlong
eae327efcc model: replace LineBits::DIRTY with a sequence number
Terminal now maintains a sequence number that increments
for each Action that is applied to it.

Changes to lines are tagged with the current sequence number.

This makes it a bit easier to reason about when an individual
line has changed relative to some point in "time"; the consumer
of the terminal can sample the current sequence number and then
can later determine which lines have changed since that point
in time.

refs: https://github.com/wez/wezterm/issues/867
2021-08-08 12:45:08 -07:00
Wez Furlong
6d9957e6e3 term, gui: allow tracking multiple buttons
We were previously only remembering the most recently pressed
button, but that's a lossy thing to do.

This commit remembers the button presses so that we can correctly
report all press/release events.

refs: #973
2021-08-07 18:37:38 -07:00
Wez Furlong
6a7e6596b9 kitty img: make allowances for permanence of image attachments
An implementation detail in wezterm is that it doesn't model
image placements as a separate entity; they are all bound to
the image cells in the terminal model.

The semantics of the kitty image protocol are that placements
are "permanent" wrt. overwriting a cell with text, except for
the explicit EraseInLine/EraseInDisplay sequences that are
used for clearing.

This commit takes a pass at implementing that semantic in
the wezterm data model.

refs: #986
2021-08-06 09:01:18 -07:00
Wez Furlong
3ea13fb530 kitty img: tidy up blit and bounds check, skip 0 duration root frame 2021-08-05 23:59:35 -07:00
Wez Furlong
815e24c24d kitty img: slightly improve protocol responses
Make a helper function for these, but there is still room
for improvement.

refs: #986
2021-08-04 13:53:54 -07:00
Wez Furlong
f3d4b59139 kitty img: flesh out some todos with anim composition
refs: #986
2021-08-04 13:31:18 -07:00
Wez Furlong
a726a170ff kitty img: support for removing all placements
and do that when the terminal is reset

refs: #986
2021-08-04 09:15:09 -07:00
Wez Furlong
6d702275df kitty img: don't move the cursor when requested not to
We were actually moving it during placement, and then restoring
the original placement.  That could potentially lead to the
screen being scrolled, so we want to avoid that.

refs: #986
2021-08-04 09:14:58 -07:00
Wez Furlong
02b5defac1 kitty img: parse and implement basic anim frame composition
This is just enough for notcurses-demo to run, and is definitely
missing various cases.

refs: #986
2021-08-03 21:57:27 -07:00
Wez Furlong
0c5753eb58 kitty img: round out support for animation frame parameters
As of this commit, `kitty +kitten icat ~/Downloads/fast-parallax.gif`
(wherein the icat kitten decodes the gif into frames and sends them
to the terminal to animate) behaves equivalently in wezterm and kitty.

(There appears to be an issue with the background color/deltas in
the icat kitten in kitty-0.21.1-1.fc33.x86_64 which I have installed,
so both wezterm and kitty have a funky black background for this
particular gif).

refs: #986
2021-08-03 19:27:14 -07:00
Wez Furlong
07bea8c269 gui: change image frame caching scheme to use frame hash
Since we can now mutate individual frames, we need to avoid
falsely caching across a change; switch from using (image_id, frame_idx)
to frame_hash.

refs: #986
2021-08-03 08:42:39 -07:00
Wez Furlong
e85e94248b basic kitty img animation support
this is the bare minimum to squeak by with notcurses; it currently
only supports editing single frame images.

refs: #986
2021-08-02 21:35:57 -07:00
Wez Furlong
29a64e10b8 allow locking ImageData's ImageDataType for mutation
refs: #986
2021-08-02 21:35:57 -07:00
Wez Furlong
90b16b9518 move image decoding into termwiz
Adds a use_image feature to termwiz that enables an optional
dep on the image crate.  This in turn allows decoding of animation
formats (gif, apng) from file data, but more crucially, allows
modeling animation frames at the termwiz layer, which is a pre-req
for enabling kitty img protocol animation support.

refs: #986
2021-08-02 21:35:50 -07:00
Wez Furlong
b862c8d111 termwiz: add ImageData::hash
Moves the localized hashing logic from term -> termwiz
where it can be re-used.

refs: #986
2021-08-02 09:18:25 -07:00
Wez Furlong
7f9d96328c kitty img: parser support for animation frame transmission
refs: #986
2021-08-01 23:33:27 -07:00
Wez Furlong
0f5494db98 refactor: split terminalstate into modules
Long overdue!  Move the various image protocols into their own files,
and the performer too!
2021-08-01 20:51:36 -07:00
Wez Furlong
1f49147560 kitty img: prune unreferenced images when RAM utilization is high
This adds a simple garbage collection scheme; when adding an image,
check to see if we're over budget on the total amount of RAM used
by the image data.

If we are, remove unreferenced images (images that are not placed)
until we're below the budget.

refs: #986
2021-08-01 15:43:48 -07:00
Wez Furlong
4d5d5a7516 kitty img: fix deletion by image_id with no placement_id
refs: #986
2021-08-01 15:12:29 -07:00
Wez Furlong
94d409d340 prefer to hold rgba8 rather than png data for kitty, sixel
I noticed when running the notcurses demo that we're spending a
decent amount of time decoding png data whenever we need to
re-do the texture atlas.

Let's avoid that by allowing for ImageData at the termwiz layer
to represent both the image file format and decoded rgba8 data.

This commit is a bit muddy and also includes some stuff to try
to delete placements from the model.  It's not perfect by any
means--more expensive than I want, and there's something funky
that causes a large number of images to build up during some
phases of the demo.

refs: #986
2021-08-01 11:29:50 -07:00
Wez Furlong
ff3ba4c4ec parse and respond to kitty img protocol queries
refs: #986
refs: https://github.com/dankamongmen/notcurses/issues/1998
2021-07-31 17:32:40 -07:00
Wez Furlong
bbe019db96 implement kitty image source and offset options for placement
Allows selecting a source "sprite" from the image data, and offsetting
its position within the cell.

refs: #986
2021-07-31 14:03:27 -07:00
Wez Furlong
fb9338f0e7 default disable kitty graphics until support is improved
You can run `wezterm --config enable_kitty_graphics=true` to do ad-hoc
tests with the protocol enabled.

refs: #986
refs: #1998
2021-07-31 10:23:44 -07:00
Wez Furlong
71e88a4fea conceptually allow for multiple image attachments in a cell
refs: #986
2021-07-29 19:41:52 -07:00
Wez Furlong
96f15a065c kitty img: add deflate support
Untested... it compiles!

refs: #986
2021-07-28 09:29:40 -07:00
Wez Furlong
62cc64f293 incomplete, basic implementation of kitty image protocol
This isn't complete; many of the placement options are not supported,
and the status reporting is missing in a number of cases, including
querying/probing, and shared memory objects are not supported yet.

However, this commit is sufficient to allow the kitty-png.py script
(that was copied from
https://sw.kovidgoyal.net/kitty/graphics-protocol/#a-minimal-example)
to render a PNG in the terminal.

This implementation routes the basic image display via the same
code that we use for iterm2 and sixel protocols, but it isn't
sufficient to support the rest of the placement options allowed
by the spec.

Notably, we'll need to add the concept of image placements to
the data model maintained by the terminal state and find a way
to efficiently manage placements both by id and by a viewport
range.

The renderer will need to manage separate quads for placements
and order them by z-index, and adjust the render phases so that
images can appear in the correct plane.

refs: #986
2021-07-28 09:04:52 -07:00
Wez Furlong
7b0b042683 termwiz: parse and encode kitty image protocol
This teaches termwiz to recognize and encode the APC
sequences used by the kitty image protocol.

This doesn't include support for animations, just the
transmit, placement and delete requests.

refs: #986
2021-07-28 09:04:37 -07:00
Wez Furlong
1c366063a3 take another crack at fixing up line wrapping attributes
This time we set the wrapped attribute when we implicitly emit
a newline and the wrap_next flag is set.

refs: #978
refs: #971
2021-07-25 09:47:29 -07:00
Autumn Lamonte
e3f1d15f5d #133 unit tests 2021-07-24 23:43:30 -07:00
Autumn Lamonte
d100dded23 #133 cleanup + terminalstate-level reverse video mode 2021-07-24 23:36:49 -07:00
Autumn Lamonte
ce9d166733 #133 ENQ response 2021-07-24 23:36:20 -07:00
Autumn Lamonte
c19f330194 #133 parse out double-width/double-height, but do not render 2021-07-24 23:20:06 -07:00
Autumn Lamonte
d2e2c5dec6 #133 clean up DECREQTPARM 2021-07-24 23:19:51 -07:00
Autumn Lamonte
e3cadc5782 #133 AutomaticNewline mode 2021-07-24 23:15:24 -07:00
Autumn Lamonte
ad30664361 #133 Screen.reverse_video_mode + fmt fixes 2021-07-24 23:13:40 -07:00
Autumn Lamonte
31aff81884 #133 DECREQTPARM - needs cleanup 2021-07-24 23:10:52 -07:00
Autumn Lamonte
d3b0881ded #133 Tab stops, reverse video. 2021-07-24 23:07:20 -07:00
Wez Furlong
6ddc8afc64 termwiz: recognize the XTGETTCAP DCS sequence
Parse and respond to this sequence docs can be found
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h4-Device-Control-functions:DCS-plus-q-Pt-ST.F95

refs: https://github.com/wez/wezterm/issues/954
2021-07-24 21:06:48 -07:00
Wez Furlong
365a68dfb8 Wrap up synchronized output handling, parser changes
This commit hooks up DECRQM so that we can report that we implement
synchronized updates, and then refines the code that manages sending
data to the terminal model; the first cut at synchronized updates
was a bit simplistic, and now we make a point of "flushing" pending
actions when we start a sync point, and again as soon as we release
the sync point.

This smooths out the jaggies around the orca that I mentioned in
dcbbda7702

and while testing this, I realized that recent parser changes had
mangled processing bundled dec private mode sequences where multiple
modes were specified in the same overall escape sequence.  I've
added the missing unit test case for this and made that work again.

refs: https://github.com/wez/wezterm/issues/955
refs: https://github.com/wez/wezterm/issues/882
2021-07-24 17:01:21 -07:00
Wez Furlong
c6dc677e50 preliminary support for synchronized output
This implementation doesn't include a timeout, but should be
recoverable via a SoftReset.

There's no query response either: I think I'm missing DECRQM
entirely at the moment.

refs: https://github.com/wez/wezterm/issues/882
2021-07-24 08:34:36 -07:00
Wez Furlong
dcbbda7702 allow images to overlay text
This commit introduces a 4th draw pass for rendering sixel and
iterm images that are attached to cells.

Previously, a cell could container either text or an image from
the perspective of the renderer.  If it had an image then the glyph
bitmap would be ignored in favor of the image.

However, that causes sixel behavior to diverge from other terminals
(https://github.com/wez/wezterm/issues/942) so we need to be render
both of these.

The simplest way to achieve this is to add a distinct set of texture
coordinates for the attached image and then add a draw pass to alpha
blend it over the glyph content.

The sixel/iterm image processing stage is also adjusted to preserve
the prior cell information and "simply" attach the image info to
the cell.  Previously, the cell would be replaced with a blank cell
with the image attached.

The result of this is that the notcurses-demo intro section can
now render the orca "enveloped in the soft glow of glyphs" rather
than caged in a black box.

Note that there are some cases where the render turns blocky but
I suspect that that is due to some other misunderstanding between
wezterm and notcurses and that we'll root cause it as a follow up.
2021-07-22 09:46:08 -07:00
Wez Furlong
5076fe2dda term: fix rewrap issue for lines == terminal width
closes: https://github.com/wez/wezterm/issues/971
2021-07-22 07:49:18 -07:00
Wez Furlong
a2e882a7cb deps: cargo update, and a couple of dependabot suggestions 2021-07-18 19:10:46 -07:00
Wez Furlong
1f5b900f3d plumb appearance change event -> reload on macos
This commit causes a window-config-reloaded event to trigger
when the appearance (dark/light mode) is changed on macos.

It also arranges to propagate the window level config to newly
spawned panes and tabs, created both via the gui and via the
CLI/mux interface.

refs: https://github.com/wez/wezterm/issues/894
refs: https://github.com/wez/wezterm/issues/806
2021-07-18 00:01:53 -07:00