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.
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.
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.
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
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.
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).
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`.