81 Commits

Author SHA1 Message Date
Qwerasd
10abeba414 test: big perf win by pausing integ checks while growing pages
In multiple tests we create 1 or more pages by growing them 1 row at a
time, which results in an integrity check of the page for each row grown
which is just... horrible. By simply pausing integrity checks while
growing these pages (since growing them is not the point of the test) we
MASSIVELY speed up all of these tests.

Also reduced grapheme bytes during testing and made the Terminal "glitch
text" test actually assert what it intends to achieve, rather than just
blindly assuming 100 copies of the text will be the right amount -- this
lets us stop a lot earlier, making it take practically no time.
2024-12-12 16:58:48 -05:00
Mitchell Hashimoto
204e4f8663 terminal: support cell_map for encodeUtf8 2024-12-03 15:53:12 -08:00
Mitchell Hashimoto
bcefbfd7b4 terminal: move UTF8 encoding to Page and wrap around it 2024-12-03 15:53:12 -08:00
Mitchell Hashimoto
6109edd00b terminal: refactor hyperlink memory management
Fixes #2500
Based on #2508

This separates out the concept of a "hyperlink" from a "hyperlink page
entry." The difference is that the former has real Zig slices into
things like strings and the latter has offsets into terminal page
memory.

From this separation, the Page structure now has an `insertHyperlink`
function that takes a hyperlink and converts it to a page entry.

This does a couple things: (1) it moves page memory management out of
Screen and into Page which is historically more appropriate and (2) it
let's us more easily test hyperlinks from the Page unit tests.

Finally, this PR makes some error sets explicit.
2024-10-28 15:30:04 -07:00
Mitchell Hashimoto
f0149722e6 terminal: add integrity check for unmarked grapheme cell 2024-09-05 14:17:11 -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
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
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
Mitchell Hashimoto
df09a37597 terminal: tests for same page clone with hyperlinks 2024-08-28 09:58:36 -07: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
Łukasz Niemier
f9be02a20f chore: clean up typos 2024-08-05 13:56:57 +02:00
Mitchell Hashimoto
77ee2f413c terminal: hasText no longer special cases kitty placeholders 2024-07-29 14:36:49 -07:00
Mitchell Hashimoto
6668930b96 terminal: appendGrapheme should text for codepoint, not text 2024-07-26 12:24:35 -07:00
Mitchell Hashimoto
3549619a64 terminal: introduce row bit for kitty virtual placeholders 2024-07-25 21:32:45 -07:00
Mitchell Hashimoto
13df93a1d0 temrinal/kitty: really basic row/col diacritic decoding 2024-07-25 21:32:44 -07:00
Mitchell Hashimoto
deacb10fb1 terminal: print must use codepoint() now to work with placeholders 2024-07-25 21:32:44 -07:00
Mitchell Hashimoto
bb1a9bf532 terminal/kitty: rename diacritics to unicode 2024-07-25 21:32:44 -07:00
Mitchell Hashimoto
2c0f9bfc28 terminal: cell returns empty for Kitty placeholder
So we don't render the replacement char
2024-07-25 21:32:44 -07:00
Mitchell Hashimoto
902913554b terminal: printing over a cell with the same hyperlink keeps flag
Fixes #1990

This fixes and adds a unit test for an edge case where when printing
over the same cell with the same hyperlink ID, we were unsetting the
cell hyperlink state.

This commit also adds a number of integrity checks to verify hyperlinks
remain in a consistent state.
2024-07-23 16:00:09 -07:00
Mitchell Hashimoto
3b889438aa terminal: page clone handles case where hyperlink can't dupe
Fixes #1991

To check if a hyperlink from another page is already present in our
page's set, we need to dupe the hyperlink struct. If the hyperlink is
already present in our page, this dupe is a waste and is freed.

In the case where the hyperlink is present AND we don't have enough
memory to dupe the hyperlink to check if its present, we'd previous
simply crash out and fail rendering. Debug builds would crash with
integrity errors.

This commit resolves the issue by falling back to a slow path when our
string allocation table is full and iterating over the hyperlink map to
check one by one if we have the hyperlink. This O(N) is much slower than
allocating (in this case) but N is usually low on top of this case being
rare.

A better solution would probably be to ensure we always have some % of
available space free in our string allocation table. This would result
in some wasteful page reallocs but would speed up the render loop. We
can look into that later.
2024-07-22 17:01:25 -07:00
Qwerasd
8589f2c0fb terminal/PageList: rework reflow logic to fix issues
Reflow logic now lives inside of ReflowCursor. This fixes multiple
issues with the previous implementation, and is more straightforward
in how it works. The old impl resulted in fragmentation of pages,
leading to unbounded memory growth when resizing repeatedly.

Also improves the preserved_cursor logic in `resizeCols`.
2024-07-08 22:35:15 -04:00
Qwerasd
0cee115ba3 terminal/page: use addWithIdContext when cloning hyperlink data 2024-07-08 22:22:18 -04:00
Qwerasd
29e6dcdee5 terminal/page: add methods to get hyperlink and grapheme map capacities 2024-07-08 22:20:31 -04:00
Mitchell Hashimoto
a6051b931e terminal: disable zombie styles integrity check 2024-07-05 21:40:40 -07:00
Mitchell Hashimoto
4f099af76f terminal: set hyperlink state on clone 2024-07-05 21:40:40 -07:00
Mitchell Hashimoto
b0f99307d3 terminal: pause integrity checks in clone row until done 2024-07-05 21:40:39 -07:00
Mitchell Hashimoto
041c779512 renderer: matchSet matches OSC8 2024-07-05 21:40:39 -07:00
Mitchell Hashimoto
f777e42af2 terminal: page clone needs to clone strings 2024-07-05 21:40:39 -07:00
Mitchell Hashimoto
961a4b6b31 terminal: support page oom with hyperlinks 2024-07-05 21:40:39 -07:00
Mitchell Hashimoto
d7e089e2aa terminal: simplify hyperlink capacity 2024-07-05 21:40:38 -07:00
Mitchell Hashimoto
365567b3c6 terminal: increase std cap for now until we implement resize 2024-07-05 21:40:38 -07:00
Mitchell Hashimoto
84edaed690 terminal: scrollDown with hyperlinks 2024-07-05 21:40:38 -07:00
Mitchell Hashimoto
bac1307c4b terminal: index hyperlink tests 2024-07-05 21:40:38 -07:00
Mitchell Hashimoto
57c5522a6b terminal: handle moving/swapping/clearing cells with hyperlinks 2024-07-05 21:40:38 -07:00
Mitchell Hashimoto
e2133cbd92 terminal: row needs hyperlink state, test clearing hyperlink 2024-07-05 21:40:38 -07:00
Mitchell Hashimoto
a3a445a066 terminal: print sets hyperlink state, tests 2024-07-05 21:40:38 -07:00
Mitchell Hashimoto
2a7755c515 terminal: hyperlink data structures beginning, alloc into page 2024-07-05 21:39:07 -07:00
Mitchell Hashimoto
a71b487d58 terminal: add strings table to page 2024-07-05 21:39:07 -07:00
Mitchell Hashimoto
69705cbced terminal: remove the hyperlink stuff i'm starting over 2024-07-05 21:39:07 -07:00
Mitchell Hashimoto
75e1655228 terminal: change default hyperlink count to zero 2024-07-05 21:39:07 -07:00
Mitchell Hashimoto
25d1e861ec terminal: page memory layout for uri/hyperlink data 2024-07-05 21:39:07 -07:00
Qwerasd
93b038f490 fix(RefCountedSet): add NeedsRehash error and fix PSL counting bug
Prevent bad input from causing repeated OutOfMemory errors by erroring
with NeedsRehash instead when there are unused dead IDs available.

Additionally, properly decrement PSL stats when reviving dead IDs.
2024-06-24 20:32:22 -07:00
Qwerasd
35793ee7cc page integrity checks: detect zombie styles 2024-06-24 20:32:22 -07:00
Qwerasd
6f732cca55 RefCountedSet: use usize for cap to allow up to max Id+1 2024-06-24 20:32:22 -07:00
Mitchell Hashimoto
eebc7d4c3a small stylistic changes 2024-06-23 09:44:54 -07:00
Qwerasd
9741b3a18c perf: introduce RefCountedSet structure, use it for Style.Set 2024-06-13 22:59:03 -04:00
Mitchell Hashimoto
7e52f94278 terminal: on clone, only mark rows dirty that were previously dirty 2024-05-01 20:31:49 -07:00
Mitchell Hashimoto
d47f14f86a terminal: dirty tracking on screen clone 2024-05-01 20:31:49 -07:00