-
-
Notifications
You must be signed in to change notification settings - Fork 693
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 option to invert selection colors #2488
base: main
Are you sure you want to change the base?
Conversation
@@ -168,6 +168,7 @@ pub fn start_client( | |||
colors: palette, | |||
rounded_corners: config.ui.pane_frames.rounded_corners, | |||
hide_session_name: config.ui.pane_frames.hide_session_name, | |||
invert_selection_colors: config_options.invert_selection_colors.unwrap_or_default(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was initially confusing for me... why do we pass in config
and config_options
separately? I originally accessed this via config.options
but apparently the CLI options flags aren't sync'd to this. I spent quite a bit of time scratching my head. Maybe some newtype safety can help here if this separation is intentional.
let background_color = match style.colors.bg { | ||
PaletteColor::Rgb(rgb) => AnsiCode::RgbCode(rgb), | ||
PaletteColor::EightBit(col) => AnsiCode::ColorIndex(col), | ||
let selection = self.selection.offset(content_x, content_y); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved the selection offsetting here as depending on offset_*
in add_selection_and_colors
or now SelectionColors::invert / discrete
seems like a layer violation. Those methods expect a Selection
for determining which color styles to apply, but we shouldn't leak another implementation detail into them.
However, this doesn't eliminate the risk of forgetting to call Selection::offset
. Maybe returning an OffsetSelection
newtype from Selection::offset
and depending on that in SelectionColors
would ensure this guarantee.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added this guarantee in 54c107a. Now the compiler will complain if you try to pass a Selection
to SelectionColors
, so we must call offset
first.
Thanks for taking this on. Hopefully gets some traction! |
Resolves #2395
This adds a new option that inverts the fg / bg colors of the selection instead of coloring w/ palette.black.
I've just passed along a
bool
withchunk_selection_and_colors
but I can refactor into a better defined enum type if desired.Edit: 9e140a2 I've removed the magic boolean and refactored to an enum for strongly typed variants.