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 lines in kitty terminal with text_fg_override_threshold set #197

Merged
merged 3 commits into from
Nov 2, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/cli/hdcanvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,21 @@ impl Canvas {
let p_bottom = self.pixel(2 * i_div_2 + 1, j);

match (p_top, p_bottom) {
(Some(top), Some(bottom)) => write!(
out,
"{}",
self.brush.paint("▀", top.ansi_style().on(bottom))
)?,
(Some(top), Some(bottom)) => {
if top == bottom {
write!(
out,
"{}",
self.brush.paint(" ", top.ansi_style().on(bottom))
)?
} else {
Copy link
Owner

Choose a reason for hiding this comment

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

what about the else path? Isn't that still potentially causing problems if kitty changes colors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Potentially, however I think it is only used in the checkerboard, which has a fairly high luminosity difference. I think kitty uses a simple percentage luminosity difference (I want to work on the compare functionality from #21 next and would like to add the value that kitty uses). I set it to 40 which seems high enough to avoid issues with text and the checkerboard still works. Maybe a comment about this potential issue would be appropriate to avoid it being used for something else in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just checked and 40 is the highest value of text_fg_override_threshold that the current checkerboard works with, so I guess that would be a potential reason to use the graphics protocol, although I'm not sure if anyone will want to set it higher than that. Does look a bit odd when it triggers.

write!(
out,
"{}",
self.brush.paint("▀", top.ansi_style().on(bottom))
)?
}
}
(Some(top), None) => write!(out, "{}", self.brush.paint("▀", top))?,
(None, Some(bottom)) => write!(out, "{}", self.brush.paint("▄", bottom))?,
(None, None) => write!(out, " ")?,
Expand Down
Loading