345 Commits

Author SHA1 Message Date
Mitchell Hashimoto
004405ccf9 terminal: only apply VS15/16 to emoji
Fixes #1482
2024-02-10 17:26:45 -08:00
Mitchell Hashimoto
f7c945c4a7 Merge pull request #1494 from mitchellh/grapheme-break
Optimized grapheme break detection (6x speedup)
2024-02-10 07:54:06 -08:00
Mitchell Hashimoto
6f8b4204b9 terminal: use new grapheme break algo 2024-02-09 20:31:20 -08:00
Gregory Anders
21412847c7 Reset status display after a full reset 2024-02-09 15:50:50 -06:00
Mitchell Hashimoto
8d891fb05c terminal: fast-path ASCII on char width 2024-02-08 21:28:14 -08:00
Mitchell Hashimoto
c838bfc1c1 terminal: swap to table implementatino 2024-02-08 21:17:30 -08:00
Mitchell Hashimoto
17dc64053e terminal: swap codepointwidth implementations 2024-02-07 09:38:17 -08:00
Mitchell Hashimoto
eb653907d6 config: grapheme-width-method sets mode 2027
Fixes #1403

This changes the behavior of `grapheme-width-method = unicode` to change
the default state of mode 2027 to true. Prior to this, setting this
config would force grapheme clustering regardless of mode 2027. Now,
this only sets the default and running TUI programs can disable it if
they want.
2024-02-02 12:13:13 -08:00
Mitchell Hashimoto
4b607a07fe terminal: avoid reading reset memory for preserving prompt
Fixes #1400
2024-01-28 08:58:43 -08:00
Mitchell Hashimoto
2d612ab168 terminal: preserve multi-point grapheme clusters on scrollback deletion
This codepath was not previously tested (an accident). Upon testing
this codepath its clear to see the logic was incorrect. When we have to
remove rows from our scrollback to fit new rows in the circular buffer,
we have to delete graphemes, but we were deleting them from the wrong
row offset.

For the row offset, we previously used the _active_ screen but the
proper offset is the _full_ screen. Tests verify.
2024-01-25 09:35:56 -08:00
Mitchell Hashimoto
628b54fbb5 Merge pull request #1344 from rockorager/reflow
reflow: respect wraparound mode when reflowing text
2024-01-21 09:12:18 -08:00
Mitchell Hashimoto
8b23d5c9ab terminal: handle wide character print at edge with wraparound disabled
Fixes #1343

If a wide character is found at the right edge of a terminal screen and
can't be printed without wrapping, the wide character is ignored. This
matches xterm behavior.

The one funky behavior is with grapheme clustering enabled and VS16
emoji. For VS16, we act as if VS16 was never received. This is not
specified in any way and no other terminal handles this correctly at the
time of authoring this so we're just making this up because it seems
most sensible.
2024-01-21 09:02:15 -08:00
Tim Culverhouse
6dcec75e32 reflow: add unit tests for wraparound mode
Add unit tests for resizing with wraparound on and off.
2024-01-21 07:02:06 -06:00
Tim Culverhouse
28732b950c reflow: respect wraparound mode when reflowing text
When calling resize, Ghostty should be respecting the wraparound state.
This behavior matches xterm. Note that this same bug was also found in
kitty.

Fixes: #1343
2024-01-21 06:43:22 -06:00
Mitchell Hashimoto
3e3c07619e terminal: soft-wrap inherits semantic prompt status of previous line
Fixes #1334
2024-01-19 18:58:28 -08:00
Mitchell Hashimoto
e9fe14c750 terminal: ECH resets line wrap state in any scenario 2024-01-19 14:31:33 -08:00
Mitchell Hashimoto
bab932431f terminal: erase line right should reset soft wrap state 2024-01-19 14:08:09 -08:00
Mitchell Hashimoto
b87bbd55c5 termio: handle termio thread failure by showing a message in window
Fixes #1301
2024-01-15 20:22:55 -08:00
Mitchell Hashimoto
adb7958f61 remove tracy usage from all files 2024-01-13 15:06:08 -08:00
Gregory Anders
060bdff117 terminal: track palette color in cell state
Rather than immediately converting a color palette index into an RGB
value for a cell color, when a palette color is used track the palette
color directly in the cell state and convert to an RGB value in the
renderer.

This causes palette color changes to take effect immediately instead of
only for newly drawn cells.
2024-01-02 22:34:06 -06:00
Mitchell Hashimoto
53dffc8e18 termio/exec: style the exec failure error better 2023-12-30 19:34:45 -08:00
Mitchell Hashimoto
3e9a4ea234 terminal: cub with reverse wrap consumes pending wrap state as one
Related to #1184

See the updated website page and associated test.
2023-12-29 12:45:57 -08:00
Mitchell Hashimoto
fdd519f73b terminal: cursor back should not reduce by one with pending wrap
Fixes #1183

I'm not sure why the original logic was there. When I translated the
original test cases to shell and ran them in xterm, they did NOT match
what Ghostty expected. This updates the tests to match xterm and removes
this case. We can add back in more tests if/when we figure out under
what scenario this original logic was correct (if it ever was).
2023-12-29 12:34:33 -08:00
Mitchell Hashimoto
8b3094465d config: grapheme-width-method, default to "unicode"
This adds a new configuration `grapheme-width-method` to change the
default behavior that Ghostty uses to calculate grapheme width. The
default value is `unicode` which is identical to setting mode 2027.

**IMPORTANT:** This changes the default Ghostty behavior to be fully
grapheme-aware including ZWJs, VS15, VS16. This may cause issues with
some legacy programs and shells.

I've changed my mind that this should become the default because enough
people use emojis now that I've found in the beta program there are more
issues reported about "incorrect emoji width" than any possibly desync
issues. We'll see.

For legacy programs, this can still be set to `grapheme-width-method =
wcswidth`.
2023-12-25 14:19:05 -08:00
Mitchell Hashimoto
4a3e1e15e5 core: click to move cursor 2023-12-20 21:33:13 -08:00
Gregory Anders
bf06c05c09 termio: implement DECRQSS
Only SGR, DECSCUSR, DECSTBM, and DECSLRM are handled, as these are the
only ones that Ghostty supports (as far as I can tell) and are the only
ones that seem actually useful.
2023-12-14 17:26:53 -06:00
Mitchell Hashimoto
84a0e4e62d terminal: support 58;5 for setting underline color via 256 palette
Fixes #1013
2023-12-07 14:57:07 -08:00
Mitchell Hashimoto
34cfe0abab xterm audit: DECOM (origin mode) 2023-11-21 18:32:00 -08:00
Mitchell Hashimoto
fd84178cc7 terminal: switching alt/primary screen invalidates Kitty image state 2023-11-21 08:37:41 -08:00
Mitchell Hashimoto
3c98c6375a terminal: handle width==3 glyphs by just pretending they're width 2 2023-11-20 19:55:06 -08:00
Mitchell Hashimoto
7066fb7bbb terminal: ESC [ 2 J does a scroll and clear if viewport is at a prompt 2023-11-19 21:07:16 -08:00
Mitchell Hashimoto
39c2549b1a terminal: add ESC [ 22 J (scroll and clear) 2023-11-19 20:45:57 -08:00
Krzysztof Wolicki
44a48f62f1 change unmodified vars to consts in anticipation of zig changes 2023-11-17 15:46:46 +01:00
Mitchell Hashimoto
f00c87e805 xterm audit: DECCOLM and 132COLS 2023-11-12 22:05:26 -08:00
Mitchell Hashimoto
53a5734d09 terminal: change mask from u256 to StaticBitSet 2023-11-09 15:14:33 -08:00
Gregory Anders
33753f59c8 core: implement OSC 104, 110, and 111 to reset colors 2023-11-09 16:17:21 -06:00
Mitchell Hashimoto
4781a83e4a replace utf8proc with ziglyph 2023-11-07 13:17:56 -08:00
Mitchell Hashimoto
d20c4866b1 some comments, make switch exaustive 2023-11-06 14:42:10 -08:00
Tim Culverhouse
49fb5c8688 gtk(mouse): use "text" enum as default value
Use the .text field of the enum as the default value of the mouse shape
instead of renaming .default. Store the default value as the current
value for use in subsequent commits
2023-11-06 14:36:57 -08:00
Mitchell Hashimoto
069e16cb46 terminal: restore cursor should clamp x/y 2023-10-27 09:42:39 -07:00
Mitchell Hashimoto
0b6cbfa141 terminal: only clear spacer tail if exists 2023-10-27 09:14:53 -07:00
Mitchell Hashimoto
597f95120b terminal: ECH minimum count is 1 2023-10-27 08:50:05 -07:00
Mitchell Hashimoto
3a77df7ce2 terminal: in mode 2027, do not attach any width=0 char unless grapheme 2023-10-27 08:23:43 -07:00
Mitchell Hashimoto
578dd730f9 terminal: CUB with reverse wrap on first row should not crash 2023-10-26 23:01:55 -07:00
Mitchell Hashimoto
ea1ef0641d terminal: assertion should check x is on left margin 2023-10-26 22:52:12 -07:00
Mitchell Hashimoto
9c165ecbd2 terminal: clamp cursor left above scroll region with XTREVWRAP2
Fixes a crash found through fuzzing. This crash is also exhibited in
xterm (as of v384). The issue arises when you set the cursor above the top
scroll margin, then issue a large cursor left (CSI D) with extended reverse
wrap (?1045) set. Extended reverse wrap loops back until it reaches the top
scroll then wraps around. But since the cursor is before the top scroll,
xterm just arbitrarily moves back into negative row numbers, which reads into
bad memory.

We decided to fix this by clamping to (0,0) and exiting because this
will mimic the xterm behavior for valid values of cursor left count
(prior to crashing).
2023-10-26 22:38:33 -07:00
Mitchell Hashimoto
c1469eb7b2 inspector: track lots of metadata for vt events 2023-10-24 21:56:38 -07:00
Mitchell Hashimoto
aee05d9e99 terminal: deleteLines has to reset wrap state on blank lines 2023-10-24 12:50:06 -07:00
Mitchell Hashimoto
66d97ab5f3 terminal: do not attach grapheme to empty cell 2023-10-24 12:20:37 -07:00
Mitchell Hashimoto
1457bcec90 terminal: deleteCharacters should clear wide spacer tails if split 2023-10-24 12:10:41 -07:00