1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-18 19:01:36 +03:00
Commit Graph

4207 Commits

Author SHA1 Message Date
Wez Furlong
b6c6cef876 refactor: move cursor sprite generation to be dynamic
This allocates cursor sprites as needed, and uses the Poly drawing
code from the customglyph module to do it.
2021-08-04 10:01:21 -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
4e1f933e00 add some more eighth custom glyphs 2021-08-04 00:20:56 -07:00
Wez Furlong
2f6180a6bc Add graphic block output from notcurses-info
I think we may have some gaps in our block glyphs; this will
make it more convenient to verify.
2021-08-03 21:59:00 -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
524f9ddd40 render double-wide cursor for double-wide cells 2021-08-03 12:27:24 -07:00
Wez Furlong
76b72e4be4 improve handling of VS15 and VS16
These modifiers have the effect of forcing us to consider the grapheme
as being either a single cell (VS15) or two cells (VS16) in the
terminal model.

These don't affect font choice as wezterm doesn't know whether a given
font in the fallback has a textual vs. an emoji version of a given
glyph, or whether a later font in the fallback has one or the other
because we can't know until we fall back, and that has a very high
cost--we perform fallback asynchronously in another thread because
of its high cost.

Depending on the selected glyph, it may or may not render as double
wide.

refs: #997
2021-08-03 12:17:03 -07:00
Wez Furlong
2590e490cd add newline after process completed line
There are some cases where we can print that status before we've
fully drained the output; it's slightly nicer to ensure that
we have an "atomic" line of its own for that, to minimize
the crappiness of the resulting output.
2021-08-03 09:24:35 -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
76681c9879 refactor: split custom glyph code into its own file 2021-08-01 22:06:04 -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
29aaa075d6 docs: changelog for #879
refs: https://github.com/wez/wezterm/issues/879
2021-08-01 19:31:57 -07:00
Wez Furlong
a0da69f56b cargo update 2021-08-01 18:40:25 -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
86bf251f3f add some more metrics around get_lines_with_hyperlinks_applied + others 2021-08-01 14:50:50 -07:00
Wez Furlong
25f4308e4f docs: changelog for #532
closes: https://github.com/wez/wezterm/issues/532
2021-08-01 13:58:27 -07:00
Wez Furlong
ecc63e2e5d wayland: improve mouse cursor resolution and diagnostics
Switch to using `xterm` rather than `text` for the name of the
xterm style I-beam mouse cursor, as that appears to be more
compatible across themes; the gnome theme aliases text -> xterm
via a symlink.

Improve error diagnostics in the case that no cursor is found.

refs: https://github.com/wez/wezterm/issues/532
2021-08-01 13:47:24 -07:00
Wez Furlong
887152a13d Improve UX when we run out of texture space
Rather than leaving the frame un-rendered, this commit arranges
to make one last pass but with all image quad assignments skipped.

This should at least make a reasonable effort at displaying text
on the screen.

refs: https://github.com/wez/wezterm/issues/879
2021-08-01 11:29:50 -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
503d3df368 Constrain texture size to that supported by gpu
OpenGL will silently let us allocate a texture larger than the GPU can
bind to a sampler, reporting the error status out of band and leaving
the display in a perma-broken state.

This commit deliberately checks against the max texture size and raises
an error in that case.

The recovery story isn't perfect, but at least the texture remains
usable, so the user can clear the screen and still be able to see glyphs
afterwards.

refs: https://github.com/wez/wezterm/issues/879
2021-08-01 10:42:57 -07:00
Wez Furlong
267885ce0b workaround a guillotiere issue
We don't need to free any allocations, so we can use the simple
allocator instead and avoid the issue.

refs: https://github.com/nical/guillotiere/issues/25
2021-08-01 00:12:19 -07:00
Wez Furlong
09220adb07 simplify rendering pane splits
Just use a single quad for a given split

refs: #986
2021-07-31 20:34:36 -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
54f435b904 Restore bg_color to the vertex
Until we have dual source blending, we need the background color
in order to have a more visually pleasing alpha blend.

refs: #986
refs: #932
2021-07-31 10:44: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
159abe5e28 mux: make action parser buffer size configurable and smaller
Previously, we'd use a 1MB buffer both to read the output from the
associated pty (blocking), and the same size buffer again to do the
non-blocking read on top of that.

For pathological cases (eg: cat 100MB+ files), we could build a
resulting `Vec<Action>` with over 1mm entries and it could take as much
as 100ms to apply those actions to the terminal model.

This meant that the output could stutter/lag and appear to be processed
more slowly.

This commit introduces a configuration value for the buffer size for the
second stage, and makes it 10KB in size.  This helps to constrain the
size of the Action vec and keeps the incremental processing costs down,
while still managing the same throughput.
2021-07-31 08:57:13 -07:00
Wez Furlong
e165cdf210 Consolidate shader logic
Now that we have a single pass, we don't need to "include" snippets,
and that makes the shaders a lot easier to follow.

refs: #986
2021-07-31 07:34:14 -07:00
Wez Furlong
725572de9c reduce to a single draw call
Taking further advantage of dynamic quad allocation, we can now
remove the multiple render passes in favor of allocating the quads
and painting them from back to front.

In turn, this means that we can reduce the amount of data that we
store in the vertex, which simplifies the shaders a bit, at the
expense of making the render code in rust a bit more complex.

However, we can take advantage of stretching runs of cells with
background colors in to a single quad.

refs: #986
2021-07-31 00:23:16 -07:00
Wez Furlong
9a8b2e1e81 fix log level when loading background image 2021-07-30 20:06:41 -07:00
Wez Furlong
175ca9f722 remove draw pass 4
This was added in 365a68dfb8 to free the
orca from its cage.  With the recent dynamic quad allocation changes, we
don't need a distinct 4th pass any more and can simply layer a separate
quad on top of the glyph quad.

refs: #986
2021-07-30 19:23:02 -07:00
Wez Furlong
89586d658e dynamically allocate quads as needed
This removes the pre-allocated (at resize) number of quads
and replaces it with a dynamic mechanism that tracks how many
quads are needed for a frame and then will re-allocate and
re-render when there weren't enough.

We start with 1024 quads and try to allocate in multiples
of 1024 quads.

refs: #986
2021-07-30 16:59:47 -07:00
Wez Furlong
6a84f051b6 Make quad allocation more dynamic
This commit removes the `Quads` struct which maintained pre-defined quad
indices for each of the cells, the background image and scrollbar thumb.

In its place, we now "dynamically" hand out quads to meet the needs of
what is being rendered.  There are some efficiency gains here with
things like the selection (which can now be a single stretched quad,
rather than `n` quads in width).

This isn't a fully dynamic allocation scheme, as we still allocate the
current worst case number of quads when resizing.

A following commit will adjust that so that we allocate a ballpark and
then employ a mechanism similar to OutOfTextureSpace to grow and retry a
render pass when we need more quads.

Futhermore, this dynamic approach may allow reducing the amount of stuff
we have in the Vertex and "simply" render some quads before others so
that we don't have to have so many draw() passes to build up the
complete scene.

refs: #986
2021-07-30 12:59:15 -07:00
Wez Furlong
72d368440f move some of the vertex buffer state into TripleVertexBuffer
This is a stepping stone towards dynamically allocating
vertices.

refs: #986
2021-07-29 22:21:46 -07:00
Wez Furlong
38e350e9c8 ErrorKind::Unsupported is rust 1.53 and up
This isn't a hard requirement, but tracking 1.53 doesn't
feel like a burden as 1.54 is now the stable rust version.
2021-07-29 19:50:22 -07:00
Wez Furlong
c867b4e079 window: fix warning when buildings tests on !macos 2021-07-29 19:44:34 -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
f0996a5dc5 termwiz: add KittyImageData::load_data
refs: #986
2021-07-28 09:04:45 -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
de1298f8b2 vtparse: parse APC sequences
These were parsed but swallowed. This commit expands the transitions
to be able to track the APC start, data and end and then adds
an `apc_dispatch` method to allow capturing APC sequences.

APC sequences are used in the kitty image protocol.

refs: #986
2021-07-28 09:04:28 -07:00