summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2020-11-12 03:11:57 +0200
committerManos Pitsidianakis <el13635@mail.ntua.gr>2020-11-12 03:19:56 +0200
commitaaee6d094c448a83794c7c88f8e666867139e8fd (patch)
tree805d9afa1d3fe2225f381bfbe77cb894ee58665c /src
parent60350eaa8872023d23d4557dbcd67c308b96b3fb (diff)
Fix NO_COLOR cursor highlight in sidebar and progress spinner
Diffstat (limited to 'src')
-rw-r--r--src/components/contacts/contact_list.rs64
-rw-r--r--src/components/mail/listing.rs11
-rw-r--r--src/components/utilities/widgets.rs16
3 files changed, 60 insertions, 31 deletions
diff --git a/src/components/contacts/contact_list.rs b/src/components/contacts/contact_list.rs
index b316894b..e6e016a0 100644
--- a/src/components/contacts/contact_list.rs
+++ b/src/components/contacts/contact_list.rs
@@ -273,28 +273,35 @@ impl ContactList {
let width = width!(area);
let must_highlight_account: bool = self.account_pos == a.index;
- let (fg_color, bg_color) = if must_highlight_account {
- if self.account_pos == a.index {
- (Color::Byte(233), Color::Byte(15))
- } else {
- (Color::Byte(15), Color::Byte(233))
+ let account_attrs = if must_highlight_account {
+ let mut v = crate::conf::value(context, "mail.sidebar_highlighted");
+ if !context.settings.terminal.use_color() {
+ v.attrs |= Attr::REVERSE;
}
+ v
} else {
- (self.theme_default.fg, self.theme_default.bg)
+ crate::conf::value(context, "mail.sidebar_account_name")
};
let s = format!(" [{}]", context.accounts[a.index].address_book.len());
if a.name.grapheme_len() + s.len() > width + 1 {
/* Print account name */
- let (x, y) =
- write_string_to_grid(&a.name, grid, fg_color, bg_color, Attr::BOLD, area, None);
+ let (x, y) = write_string_to_grid(
+ &a.name,
+ grid,
+ account_attrs.fg,
+ account_attrs.bg,
+ account_attrs.attrs,
+ area,
+ None,
+ );
write_string_to_grid(
&s,
grid,
- fg_color,
- bg_color,
- Attr::BOLD,
+ account_attrs.fg,
+ account_attrs.bg,
+ account_attrs.attrs,
(
pos_dec(
(get_x(bottom_right!(area)), get_y(upper_left!(area))),
@@ -307,9 +314,9 @@ impl ContactList {
write_string_to_grid(
"…",
grid,
- fg_color,
- bg_color,
- Attr::BOLD,
+ account_attrs.fg,
+ account_attrs.bg,
+ account_attrs.attrs,
(
pos_dec(
(get_x(bottom_right!(area)), get_y(upper_left!(area))),
@@ -321,20 +328,29 @@ impl ContactList {
);
for x in x..=get_x(bottom_right!(area)) {
- grid[(x, y)].set_fg(fg_color);
- grid[(x, y)].set_bg(bg_color);
+ grid[(x, y)]
+ .set_fg(account_attrs.fg)
+ .set_bg(account_attrs.bg)
+ .set_attrs(account_attrs.attrs);
}
} else {
/* Print account name */
- let (x, y) =
- write_string_to_grid(&a.name, grid, fg_color, bg_color, Attr::BOLD, area, None);
+ let (x, y) = write_string_to_grid(
+ &a.name,
+ grid,
+ account_attrs.fg,
+ account_attrs.bg,
+ account_attrs.attrs,
+ area,
+ None,
+ );
write_string_to_grid(
&s,
grid,
- fg_color,
- bg_color,
- Attr::BOLD,
+ account_attrs.fg,
+ account_attrs.bg,
+ account_attrs.attrs,
(
pos_dec(
(get_x(bottom_right!(area)), get_y(upper_left!(area))),
@@ -345,8 +361,10 @@ impl ContactList {
None,
);
for x in x..=get_x(bottom_right!(area)) {
- grid[(x, y)].set_fg(fg_color);
- grid[(x, y)].set_bg(bg_color);
+ grid[(x, y)]
+ .set_fg(account_attrs.fg)
+ .set_bg(account_attrs.bg)
+ .set_attrs(account_attrs.attrs);
}
}
}
diff --git a/src/components/mail/listing.rs b/src/components/mail/listing.rs
index 07b8f88d..9dd7ff0c 100644
--- a/src/components/mail/listing.rs
+++ b/src/components/mail/listing.rs
@@ -1526,13 +1526,18 @@ impl Listing {
let account_attrs = if must_highlight_account {
if self.focus == ListingFocus::Menu && self.menu_cursor_pos.1 == 0 {
- crate::conf::value(context, "mail.sidebar_highlighted")
+ let mut v = crate::conf::value(context, "mail.sidebar_highlighted");
+ if !context.settings.terminal.use_color() {
+ v.attrs |= Attr::REVERSE;
+ }
+ v
} else {
crate::conf::value(context, "mail.sidebar_highlighted_account_name")
}
} else {
crate::conf::value(context, "mail.sidebar_account_name")
};
+
/* Print account name first */
write_string_to_grid(
&a.name,
@@ -1549,8 +1554,8 @@ impl Listing {
"offline",
grid,
Color::Byte(243),
- self.theme_default.bg,
- self.theme_default.attrs,
+ account_attrs.bg,
+ account_attrs.attrs,
(pos_inc(upper_left, (0, 1)), bottom_right),
None,
);
diff --git a/src/components/utilities/widgets.rs b/src/components/utilities/widgets.rs
index cd7d9030..930b1916 100644
--- a/src/components/utilities/widgets.rs
+++ b/src/components/utilities/widgets.rs
@@ -1158,6 +1158,7 @@ pub struct ProgressSpinner {
stage: usize,
pub kind: std::result::Result<usize, Vec<String>>,
pub width: usize,
+ theme_attr: ThemeAttribute,
active: bool,
dirty: bool,
id: ComponentId,
@@ -1212,11 +1213,17 @@ impl ProgressSpinner {
.map(|f| f.grapheme_len())
.max()
.unwrap_or(0);
+ let mut theme_attr = crate::conf::value(context, "status.bar");
+ if !context.settings.terminal.use_color() {
+ theme_attr.attrs |= Attr::REVERSE;
+ }
+ theme_attr.attrs |= Attr::BOLD;
ProgressSpinner {
timer,
stage: 0,
kind: Ok(kind),
width,
+ theme_attr,
dirty: true,
active: false,
id: ComponentId::new_v4(),
@@ -1278,8 +1285,7 @@ impl fmt::Display for ProgressSpinner {
impl Component for ProgressSpinner {
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
if self.dirty {
- let theme_attr = crate::conf::value(context, "status.bar");
- clear_area(grid, area, theme_attr);
+ clear_area(grid, area, self.theme_attr);
if self.active {
write_string_to_grid(
match self.kind.as_ref() {
@@ -1287,9 +1293,9 @@ impl Component for ProgressSpinner {
Err(custom) => custom[self.stage].as_ref(),
},
grid,
- theme_attr.fg,
- theme_attr.bg,
- theme_attr.attrs,
+ self.theme_attr.fg,
+ self.theme_attr.bg,
+ self.theme_attr.attrs,
area,
None,
);