fix: keep explorer selections readable on light terminals
This commit is contained in:
+22
-5
@@ -484,9 +484,22 @@ impl BufferViewports {
|
||||
}
|
||||
self.theme = theme;
|
||||
let colors = DiffColors::new(theme);
|
||||
let file_selection_background = theme.and_then(|theme| {
|
||||
let [r, g, b] = theme.background.map(u32::from);
|
||||
if r * 299 + g * 587 + b * 114 < 128_000 {
|
||||
return None;
|
||||
}
|
||||
// Keep ANSI status/directory foregrounds readable on light terminals.
|
||||
let [r, g, b] = theme
|
||||
.background
|
||||
.map(|c| ((u16::from(c) * 95 + 50) / 100) as u8);
|
||||
Some(Color::Rgb(r, g, b))
|
||||
});
|
||||
self.panels.diff_colors = colors;
|
||||
self.panels.file_selection_background = file_selection_background;
|
||||
for pane in self.parked.values_mut() {
|
||||
pane.panels.diff_colors = colors;
|
||||
pane.panels.file_selection_background = file_selection_background;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,6 +555,7 @@ impl BufferViewports {
|
||||
})()
|
||||
.unwrap_or_default();
|
||||
inherited.panels.diff_colors = self.panels.diff_colors;
|
||||
inherited.panels.file_selection_background = self.panels.file_selection_background;
|
||||
self.parked.insert(id, inherited);
|
||||
}
|
||||
let outgoing = self
|
||||
@@ -5699,6 +5713,7 @@ struct WheelPanels {
|
||||
picker_scroll: PickerScroll,
|
||||
diff: Option<DiffGeometry>,
|
||||
diff_colors: DiffColors,
|
||||
file_selection_background: Option<Color>,
|
||||
diff_syntax: Option<DiffSyntaxCache>,
|
||||
previous_diff: Option<DiffGeometry>,
|
||||
diff_wrap: Option<DiffWrapViewport>,
|
||||
@@ -6380,11 +6395,13 @@ fn draw_file_list(
|
||||
};
|
||||
if selected {
|
||||
style = style
|
||||
.bg(if picker.focused {
|
||||
Color::Blue
|
||||
} else {
|
||||
Color::DarkGray
|
||||
})
|
||||
.bg(panels
|
||||
.file_selection_background
|
||||
.unwrap_or(if picker.focused {
|
||||
Color::Blue
|
||||
} else {
|
||||
Color::DarkGray
|
||||
}))
|
||||
.add_modifier(Modifier::BOLD);
|
||||
}
|
||||
let changed = entry
|
||||
|
||||
Reference in New Issue
Block a user