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

feat: enforce minimum contrast ratio for reverse video cursor #6584

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jameshurst
Copy link

This PR ensures the reverse video cursor meets a minimum contrast ratio, otherwise the default fg/bg is used instead.

The minimum contrast ratio of 2.5 was chosen from the kitty implementation linked in #2861.

The SrgbaTuple::contrast_ratio implementation also appeared to be incorrect since it was comparing lightness instead of luminance.

This should resolve #2861.

Before

After

Copy link
Member

@wez wez left a comment

Choose a reason for hiding this comment

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

Thanks for this!

Let's add a config option to control that contrast ratio. There will also need to be an entry in the docs for that page, you can add one to https://github.com/wezterm/wezterm/tree/main/docs/config/lua/config

Thanks again!

@@ -484,6 +484,8 @@ impl crate::TermWindow {
}

pub fn compute_cell_fg_bg(&self, params: ComputeCellFgBgParams) -> ComputeCellFgBgResult {
const CURSOR_MIN_CONTRAST: f32 = 2.5;
Copy link
Member

Choose a reason for hiding this comment

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

I think we should make this an option because I just know that someone is going to complain about this otherwise, regardless of how well selected the default value might be!

I'd suggest adding an option named something like cursor_minimum_contrast: f32 over here:

#[dynamic(default = "linear_ease")]
pub cursor_blink_ease_out: EasingFunction,

You'll also need to add a little helper function to return the 2.5 default value and assign that using #[dynamic(default = "default_contrast_ratio")] as an attribute on that option.

then I think you should be good to examine self.config.cursor_minimum_contrast in this function instead of the constant.

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