Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SGR direct-color parsing issue #4216

Merged
merged 2 commits into from
Dec 31, 2024

Conversation

qwerasd205
Copy link
Collaborator

Fix for a little parsing issue I took note of here.

The disparity in behavior between ghostty@main and xterm can be seen with this reproduction script:

printf "\e[0m\nForeground:\n";
printf "\e[38:2:0:255:0mGreen\n";
printf "\e[38;2;0;255;0mGreen\n";
printf "\e[38:2:0:255:0:255mMagenta\n";
printf "\e[38;2;0;255;0;255mGreen\n";

printf "\e[0m\nBackground:\n";
printf "\e[48:2:0:255:0mGreen\n";
printf "\e[48;2;0;255;0mGreen\n";
printf "\e[48:2:0:255:0:255mMagenta\n";
printf "\e[48;2;0;255;0;255mGreen\n";

printf "\e[0m\nUnderline:\n";
printf "\e[58:2:0:255:0m\e[4mGreen\n";
printf "\e[58;2;0;255;0m\e[4mGreen\n";
printf "\e[58:2:0:255:0:255m\e[4mMagenta\n";
printf "\e[58;2;0;255;0;255m\e[4mGreen\n";

printf "\e[0m\n";

Outputs:

xterm ghostty@main this PR
image image image

@qwerasd205
Copy link
Collaborator Author

Oh oops, I somehow left a test failure in, I must have accidentally hit undo at some point!

@qwerasd205 qwerasd205 force-pushed the ignore-sgr-colorspace-param branch from f6fcf6e to 1d4c777 Compare December 31, 2024 19:58
src/terminal/sgr.zig Outdated Show resolved Hide resolved
@qwerasd205 qwerasd205 force-pushed the ignore-sgr-colorspace-param branch from 1d4c777 to 4543cde Compare December 31, 2024 20:06
Copy link
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should extract this to a comptime-based helper (so it can take the union tags). But this looks good and I'll merge as-is for now. Thanks!

@mitchellh mitchellh merged commit df0620a into ghostty-org:main Dec 31, 2024
21 checks passed
@github-actions github-actions bot added this to the 1.0.1 milestone Dec 31, 2024
@qwerasd205 qwerasd205 deleted the ignore-sgr-colorspace-param branch December 31, 2024 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants