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

add the ability to have an underline in a separate color than text #52

Merged
merged 2 commits into from
Aug 4, 2022
Merged

add the ability to have an underline in a separate color than text #52

merged 2 commits into from
Aug 4, 2022

Conversation

fdncred
Copy link
Contributor

@fdncred fdncred commented Aug 2, 2022

This PR augments the Style struct to add the underline color as an Option<Color>. Previously, underline, which is ansi escape 58, was not being parsed which was why the foreground color was being parsed as the underline color thereby making text blink on some terminals namely Mac's Terminal.app and Windows Terminal.

So, now when one calls to_crossterm_style(), if there is no underline set, underline will be set to None, and therefore not blink.

I also augmented the tests in style.rs to test a underline style.

Sorry for all the PRs from the nushell team. We've just been trying to upgrade to crossterm 0.24 and found these issues. Hopefully this is the last hotfix we come across for underlines. I have tested this PR with nushell and it seems to be working fine now with these changes in Windows Terminal.

_ => {
break;
}
},
Copy link
Owner

Choose a reason for hiding this comment

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

According to https://en.wikipedia.org/wiki/ANSI_escape_code, 58 is a non-standard addition. But it seems to be supported in some terminals, so I'm okay with adding it. Should we support 59 as well (default underline color)? Similar to, say, 24 for disabling underlining.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I just added 59. Thanks.

@sharkdp
Copy link
Owner

sharkdp commented Aug 3, 2022

Thank you! Just one minor comment.

Sorry for all the PRs from the nushell team. We've just been trying to upgrade to crossterm 0.24 and found these issues. Hopefully this is the last hotfix we come across for underlines. I have tested this PR with nushell and it seems to be working fine now with these changes in Windows Terminal.

Quite the contrary, the contributions are very much appreciated!

@fdncred
Copy link
Contributor Author

fdncred commented Aug 3, 2022

For anyone following this issue in the future. I just want to add a bit of documentation here since some takes a bit to find.

WezTerm
Kitty
iTerm2 Issue
Wikipedia

Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

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

Thank you

@sharkdp sharkdp merged commit bfc0d45 into sharkdp:master Aug 4, 2022
@fdncred fdncred deleted the fix_underline_colors branch August 4, 2022 19:43
@fdncred
Copy link
Contributor Author

fdncred commented Aug 8, 2022

@sharkdp Would it be possible to get a published release of this by 8/15? Our next nushell release is 8/16.

@sharkdp
Copy link
Owner

sharkdp commented Aug 9, 2022

Done: https://github.com/sharkdp/lscolors/releases/tag/v0.12.0

This is v0.12.0 instead of v0.11.2 because the Style struct and all fields are public: https://docs.rs/lscolors/0.12.0/lscolors/style/struct.Style.html

That's maybe something that should be improved using non_exhaustive or similar

@fdncred
Copy link
Contributor Author

fdncred commented Aug 9, 2022

Thank you, sir.

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.

2 participants