1440 Commits

Author SHA1 Message Date
Mitchell Hashimoto
2acd7e8a42 kitty: respond OK with metadata on display transmissions 2024-09-03 11:05:16 -07:00
Mitchell Hashimoto
e9c83a5f64 kitty: ENOENT when image ID not found for placement 2024-09-03 10:38:10 -07:00
Mitchell Hashimoto
de612934a0 some tweaks for wuffs 2024-09-02 20:47:07 -07:00
Jeffrey C. Ollie
6edeb45e7e kitty graphics: address review comments
- move wuffs code from src/ to pkg/
- eliminate stray debug logs
- make logs a warning instead of an error
- remove initialization of some structs to zero
2024-09-02 20:47:07 -07:00
Jeffrey C. Ollie
6dbb82c259 kitty graphics: performance enhancements
Improve the performance of Kitty graphics by switching to the WUFFS
library for decoding PNG images and for "swizzling" G, GA, and RGB data
to RGBA formats needed by the renderers.

WUFFS claims 2-3x performance benefits over other implementations, as
well as memory-safe operations.

Although not thorougly benchmarked, performance is on par with Kitty's
graphics decoding.

https://github.com/google/wuffs
2024-09-02 20:45:08 -07:00
Mitchell Hashimoto
d8fc54d1bf Merge pull request #2177 from jcollie/kitty-graphics-local-more
kitty graphics: fix usage of "m" key for local-only transmission mediums
2024-09-01 21:19:05 -07:00
Jeffrey C. Ollie
5e925db521 kitty graphics: fix usage of "m" key for local-only transmission mediums
If the transmission medium is a local-only medium, ignore the "m"
key. The Kitty graphics protocol specification does not explicitly
call out this behavior (although the "m" key is only mentioned in
connection with remote clients) but that's how it's implemented in
Kitty and at least one client (mpv) relies on this behavior when
using the shared memory transmission medium.

https://sw.kovidgoyal.net/kitty/graphics-protocol/#the-transmission-medium
ccc3bee9af/kitty/graphics.c (L547-L592)
2024-09-01 21:10:08 -07:00
Mitchell Hashimoto
5d476135c5 terminal: do not run page integrity checks unless slow runtime safety 2024-09-01 21:02:44 -07:00
Mitchell Hashimoto
5ade197f91 Merge pull request #2175 from qwerasd205/pagelist-fix
fix(terminal/PageList): update self.cols at start of resizeCols
2024-09-01 09:58:39 -07:00
Qwerasd
7fb2bd16a9 fix(terminal/PageList): update self.cols at start of resizeCols
It's possible for `self.grow` to be called within the body of the
function, and `self.grow` uses `self.cols` to create a new page if
there's no more room in the current one.
2024-09-01 09:55:00 -07:00
Mitchell Hashimoto
6aab430caf terminal: disable slow safety tests in releasesafe 2024-08-31 21:14:12 -07:00
Mitchell Hashimoto
9d08ed32ee terminal: make error sets more explicit, capture explicit errors 2024-08-31 10:31:38 -07:00
Qwerasd
3807ee34c1 terminal: handle clonePartialRowFrom errors in insert/deleteLines
Handle `clonePartialRowFrom` errors in `insertLines` and `deleteLines`
by adjusting page capacity. To do this, I've rewritten both functions
with a new way of iterating rows by moving a tracked pin up/down.

Benchmarks seem to indicate that this has no effect on performance.
2024-08-30 13:45:18 -04:00
Qwerasd
daa1755793 terminal/page: discriminate cloneFrom errors
Doing this makes it possible to appropriately handle a failed cloneFrom
operation by adjusting the correct part of the page capacity accordingly
2024-08-30 13:45:18 -04:00
Qwerasd
3bc2dbfa72 RefCountedSet: make lookup public 2024-08-30 13:30:40 -04:00
Mitchell Hashimoto
df09a37597 terminal: tests for same page clone with hyperlinks 2024-08-28 09:58:36 -07:00
Mitchell Hashimoto
6a2d57edfd terminal: cursorCopy has option to not copy hyperlink 2024-08-28 09:41:57 -07:00
Qwerasd
a3fb96f543 this should be a doc comment 2024-08-27 01:23:29 -04:00
Qwerasd
5714c2feed PageList: refactor clone to avoid excess work
Also avoids leaving content in out-of-bounds rows, since it doesn't copy
the content to them in the first place. Over all, just a lot cleaner.
2024-08-27 01:23:29 -04:00
Qwerasd
38bb9b40a6 Terminal: release hyperlink before copying cursor when switching screen
To avoid an unnecessary copy.
2024-08-27 01:07:29 -04:00
Qwerasd
170f55aa84 Screen: update cursorCopy to handle hyperlink state 2024-08-27 01:07:29 -04:00
Qwerasd
cb1cb3526a test(Screen): add failing tests for cursorCopy hyperlink handling 2024-08-27 01:07:29 -04:00
Qwerasd
d43d5b26ee fix(terminal): avoid trying to clone bad managed memory in reflow
If we call `moveLastRowToNewPage` at any point because we failed to copy
some managed memory, it tries to copy managed memory that hasn't been
cloned yet when moving our progress to a new page.

Avoid this by setting our content tag, hyperlink flag, and style id to
indicate no managed memory is present on the cell.
2024-08-27 01:01:31 -04:00
Qwerasd
a6992baa30 fix(terminal): don't MOVE hyperlinks in clonePartialRowFrom 2024-08-27 01:01:31 -04:00
Qwerasd
30bba9bf06 terminal: move refcount responsibility out of setHyperlink
avoids double counting in several places
2024-08-27 01:01:31 -04:00
Mitchell Hashimoto
d0c510ed29 Merge pull request #2128 from jcollie/kitty-color-protocol-fixup
Clean up Kitty color protocol by using a union
2024-08-24 19:57:44 -07:00
Mitchell Hashimoto
8e2d63b6fa small stylistic changes 2024-08-24 19:55:09 -07:00
Mitchell Hashimoto
cff907940f renderer: do not extend padding color if any cell has default bg color
Before, cells that were explicitly set to match the default bg color
were treated as if they did NOT have the default and extending would
occur. We now check the exact RGB of each cell.
2024-08-22 14:57:46 -07:00
Mitchell Hashimoto
9a287e1589 terminal: hyperlink state for cursor needs to be preserved on resize
When a screen is resized, the pages are generally reallocated. This
causes the cursor hyperlink state to be lost and ultimately the
hyperlink ref count is off by one.

The unit test in this commit showcases the issue very clearly. And you
can see we do this logic already for styles. We never copied it over for
hyperlinks.
2024-08-21 18:29:10 -04:00
Jeffrey C. Ollie
b8d4969fee Make the Kind parsing simpler 2024-08-21 15:28:00 -05:00
Jeffrey C. Ollie
54e2ea05a5 Use switch and not if to format Kind 2024-08-21 12:37:18 -05:00
Jeffrey C. Ollie
571988bf99 Clean up Kitty color protocol by using a union
Non-exhaustive enums should be avoided, use a union to
make the code cleaner and safer.
2024-08-21 11:57:27 -05:00
Mitchell Hashimoto
140d1dde5a typos 2024-08-21 09:45:47 -04:00
Mitchell Hashimoto
8df5ec10e3 Merge pull request #2113 from jcollie/osc-21
Implement Kitty Color Protocol (OSC 21)
2024-08-21 09:23:23 -04:00
Mitchell Hashimoto
6bf1acc5a2 terminal: move kitty color structs out to kitty package 2024-08-21 09:18:42 -04:00
Mitchell Hashimoto
e12cfe80b0 terminal: formatter for kitty color protocol kinds 2024-08-20 23:31:34 -04:00
Mitchell Hashimoto
3b2ed40854 terminal: stylistic tweaks to kitty color protocol parsing 2024-08-20 23:21:28 -04:00
Mitchell Hashimoto
f4b2925434 terminal: make kitty color tests a bit more readable 2024-08-20 23:06:09 -04:00
Jeffrey C. Ollie
a2ef0ca751 Address review comments.
- Cap the total number of requests at twice the maximum number of
  keys (currently 263, so 526 requests). Basically you can set and then
  query every key in one message. This is an absurdly high number
  but should prevent serious DOS attacks.
- Clarify meaning of new hex color codes.
- Better handle sending messages to the renderer in a way that should
  prevent deadlocks.
- Handle 0-255 palette color requests by creatively using non-exhautive
  enums.
- Fix an error in the query reply.
2024-08-19 00:22:09 -05:00
Mitchell Hashimoto
37d19b3cef Merge pull request #2109 from edmz/block_hollow
Config: cursor-style can bet set to block_hollow
2024-08-18 15:08:08 -07:00
Mitchell Hashimoto
18a8d2b01d Minor changes, mainly commenting to clarify some behaviors 2024-08-18 15:05:31 -07:00
Mitchell Hashimoto
994514981f terminal: handle case grow allocates but cursor is multiple pages back 2024-08-18 10:20:23 -07:00
Mitchell Hashimoto
602fea52ec terminal: cursorScrollAbove handles case of no new page, prev page 2024-08-18 10:14:35 -07:00
Mitchell Hashimoto
1028fe1c56 terminal: only call new method 2024-08-17 22:02:48 -07:00
Mitchell Hashimoto
adb382f1c8 terminal: call new method for scroll operation 2024-08-17 22:00:52 -07:00
Mitchell Hashimoto
9898489e25 terminal: add Screen.cursorScrollAbove and tests 2024-08-17 21:57:07 -07:00
Mitchell Hashimoto
a125dc9682 terminal: add more tests for index, verified that l/r margin handling is
good
2024-08-17 20:01:47 -07:00
Jeffrey C. Ollie
254072e656 fix test error and improve error logging 2024-08-17 15:34:35 -05:00
Mitchell Hashimoto
1d7e87c88d terminal: index from bottom row of scroll region always makes scrollback
Ghostty previously incorrectly only created scrollback if the top/bot
margins were the full height of the viewport. The actual xterm behavior
is to create scrollback as long as the top margin is the top row and the
cursor is on the bottom margin (wherever that may be).
2024-08-17 10:58:34 -07:00
Jeffrey C. Ollie
b11b8be124 Implement Kitty Color Protocol (OSC 21)
Kitty 0.36.0 added support for a new OSC escape sequence for
quering, setting, and resetting the terminal colors. Details
can be found [here](https://sw.kovidgoyal.net/kitty/color-stack/#setting-and-querying-colors).

This fully parses the OSC 21 escape sequences, but only supports
actually querying and changing the foreground color, the background
color, and the cursor color because that's what Ghostty currently
supports. Adding support for the other settings that Kitty supports
changing ranges from easy (cursor text) to difficult (visual bell,
second transparent background color).
2024-08-17 07:05:28 -05:00