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

458 Commits

Author SHA1 Message Date
Wez Furlong
0ee1f7529b fonts: Fix shaping metrics
This was a bit of a PITA to run down; the essence of the problem
was that the shaper was returning an x_advance of 0 for U+3000,
which caused wezterm's shaping layer to elide that glyph.

I eventually tracked down the x_advance to be the result of
scaling by an x_scale of 0, which in turn is the result of
harfbuzz not knowing the font size.

The critical portion of this diff is the line that advises
harfbuzz that the font has changed after we've applied the
font size.

The rest is just stuff to make it easier to debug and verify.

This:

```
printf "x\u3000x."
```

Now correctly renders on screen as "x  x".

fixes: #1161
2021-09-22 08:34:40 -07:00
Wez Furlong
0e5d0d8117 term: fix encoding F1-F4
This was accidentally broken by 8da1f676a8

refs: #892
2021-09-12 09:30:14 -07:00
Greg V
ce5615082c gui: cancel mouse click streak when the cursor has moved to a different cell (fixes #910)
Fast-clicking users generally expect to be able to rapidly do regular selections
or otherwise cancel double/triple/quad clicks, so significant mouse movement should end the streak.

Allowing tiny pixel movements to account for touchpads is necessary.
Fortunately, the position here is already in character grid cells, which provides enough margin for this.
Other code editors like gedit also seem to do this based on the character grid.
2021-09-08 17:38:59 -07:00
Wez Furlong
545a8fc8a7 deps: ordered-float -> 2.8 2021-09-05 23:25:37 -07:00
Wez Furlong
311bd78902 Fix SU (scroll up) using default-blank cells
closes: https://github.com/wez/wezterm/issues/1102#
2021-09-04 17:35:33 -07:00
Wez Furlong
67e8bdc5c2 term: fix DCH removing cells instead of setting to current bg color
refs: #789
2021-09-03 16:21:15 -07:00
Wez Furlong
c5d1f67853 term/termwiz: move key encoding to termwiz
This will enable eg: a lua helper function to serialize keycodes to
assist in some key rebinding scenarios (see:
https://github.com/wez/wezterm/pull/1091#issuecomment-910940833 for the
gist of it) but also makes it a bit easier to write unit tests for key
encoding so that situations like those in #892 are potentially less
likely to occur in the future.
2021-09-03 11:12:42 -07:00
Wez Furlong
24d971c87d Defend against crazy big images sent via iterm image protocol
This also handles a Nan case and allows us to survive term-crash-tests as of fb6fa3192a65e8862c3c743ba102f7e2af45b519

refs: https://github.com/wez/wezterm/issues/1031
2021-08-16 23:44:31 -07:00
Wez Furlong
ab21910d80 deps: update bitflags -> 1.3 2021-08-15 18:21:17 -07:00
Wez Furlong
aa9cbd4552 refactor: update a couple of callers to Cell::blank 2021-08-15 15:42:35 -07:00
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