diff options
author | Vinzent Steinberg <Vinzent.Steinberg@gmail.com> | 2019-07-24 14:34:37 +0200 |
---|---|---|
committer | Vinzent Steinberg <Vinzent.Steinberg@gmail.com> | 2019-07-24 14:34:37 +0200 |
commit | 977e69f9aafc54f9b2ed9ddb2eee5164e30b213c (patch) | |
tree | f8f4b0d9ac1b9b3673ca07d3bd901fb243619562 /src/interactive/widgets/mark.rs | |
parent | f4028baf655e2994459e55d62435de4456fee80f (diff) |
Fix color scheme for light terminals
This is done by making sure that we never have a background that is
black or white combined with a foreground that uses the terminal's
default and vice versa.
Because we cannot access the default terminal colors, we have to rely on
inverted colors and bold text for highlighting.
Also, the mark pane was improved to be more consistent with the entries
pane. Ideally, we would use the same color as in the entries pane, but
this is currently not possible, because the mark pane does not know
whether a path is a directory or not.
Fixes #13.
Diffstat (limited to 'src/interactive/widgets/mark.rs')
-rw-r--r-- | src/interactive/widgets/mark.rs | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/interactive/widgets/mark.rs b/src/interactive/widgets/mark.rs index cbd34a6..49a4128 100644 --- a/src/interactive/widgets/mark.rs +++ b/src/interactive/widgets/mark.rs @@ -1,6 +1,6 @@ use crate::interactive::{ fit_string_graphemes_with_ellipsis, path_of, - widgets::{COLOR_BYTESIZE_SELECTED, COLOR_MARKED_LIGHT}, + widgets::get_name_color, CursorDirection, }; use dua::{ @@ -219,17 +219,21 @@ impl MarkPane { format.display(marked.iter().map(|(_k, v)| v.size).sum::<u64>()) ); let selected = self.selected; + let has_focus = self.has_focus; let entries = marked.values().sorted_by_key(|v| &v.index).enumerate().map( |(idx, v): (usize, &EntryMark)| { - let (default_style, is_selected) = match selected { - Some(selected) if idx == selected => ( + let default_style = match selected { + Some(selected) if idx == selected => { + let mut modifier = Modifier::REVERSED; + if has_focus { + modifier.insert(Modifier::BOLD); + } Style { - bg: Color::White, + modifier, ..Default::default() - }, - true, - ), - _ => (Style::default(), false), + } + }, + _ => Style::default(), }; let (path, path_len) = { let path = format!( @@ -254,14 +258,11 @@ impl MarkPane { _ => (path, num_path_graphemes), } }; + let fg_path = get_name_color(Color::Reset, false, true); // TODO: determine whether directory let path = Text::Styled( path.into(), Style { - fg: if is_selected { - Color::Black - } else { - COLOR_MARKED_LIGHT - }, + fg: fg_path, ..default_style }, ); @@ -273,11 +274,7 @@ impl MarkPane { ) .into(), Style { - fg: if is_selected { - COLOR_BYTESIZE_SELECTED - } else { - Color::Green - }, + fg: Color::Green, ..default_style }, ); @@ -290,7 +287,10 @@ impl MarkPane { .saturating_sub(format.total_width()) ) .into(), - default_style, + Style { + fg: fg_path, + ..default_style + }, ); vec![path, spacer, bytes] }, |