Fix NO_COLOR cursor highlight in sidebar and progress spinner
parent
60350eaa88
commit
aaee6d094c
|
@ -273,28 +273,35 @@ impl ContactList {
|
||||||
|
|
||||||
let width = width!(area);
|
let width = width!(area);
|
||||||
let must_highlight_account: bool = self.account_pos == a.index;
|
let must_highlight_account: bool = self.account_pos == a.index;
|
||||||
let (fg_color, bg_color) = if must_highlight_account {
|
let account_attrs = if must_highlight_account {
|
||||||
if self.account_pos == a.index {
|
let mut v = crate::conf::value(context, "mail.sidebar_highlighted");
|
||||||
(Color::Byte(233), Color::Byte(15))
|
if !context.settings.terminal.use_color() {
|
||||||
} else {
|
v.attrs |= Attr::REVERSE;
|
||||||
(Color::Byte(15), Color::Byte(233))
|
|
||||||
}
|
}
|
||||||
|
v
|
||||||
} else {
|
} 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());
|
let s = format!(" [{}]", context.accounts[a.index].address_book.len());
|
||||||
|
|
||||||
if a.name.grapheme_len() + s.len() > width + 1 {
|
if a.name.grapheme_len() + s.len() > width + 1 {
|
||||||
/* Print account name */
|
/* Print account name */
|
||||||
let (x, y) =
|
let (x, y) = write_string_to_grid(
|
||||||
write_string_to_grid(&a.name, grid, fg_color, bg_color, Attr::BOLD, area, None);
|
&a.name,
|
||||||
|
grid,
|
||||||
|
account_attrs.fg,
|
||||||
|
account_attrs.bg,
|
||||||
|
account_attrs.attrs,
|
||||||
|
area,
|
||||||
|
None,
|
||||||
|
);
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
&s,
|
&s,
|
||||||
grid,
|
grid,
|
||||||
fg_color,
|
account_attrs.fg,
|
||||||
bg_color,
|
account_attrs.bg,
|
||||||
Attr::BOLD,
|
account_attrs.attrs,
|
||||||
(
|
(
|
||||||
pos_dec(
|
pos_dec(
|
||||||
(get_x(bottom_right!(area)), get_y(upper_left!(area))),
|
(get_x(bottom_right!(area)), get_y(upper_left!(area))),
|
||||||
|
@ -307,9 +314,9 @@ impl ContactList {
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
"…",
|
"…",
|
||||||
grid,
|
grid,
|
||||||
fg_color,
|
account_attrs.fg,
|
||||||
bg_color,
|
account_attrs.bg,
|
||||||
Attr::BOLD,
|
account_attrs.attrs,
|
||||||
(
|
(
|
||||||
pos_dec(
|
pos_dec(
|
||||||
(get_x(bottom_right!(area)), get_y(upper_left!(area))),
|
(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)) {
|
for x in x..=get_x(bottom_right!(area)) {
|
||||||
grid[(x, y)].set_fg(fg_color);
|
grid[(x, y)]
|
||||||
grid[(x, y)].set_bg(bg_color);
|
.set_fg(account_attrs.fg)
|
||||||
|
.set_bg(account_attrs.bg)
|
||||||
|
.set_attrs(account_attrs.attrs);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Print account name */
|
/* Print account name */
|
||||||
|
|
||||||
let (x, y) =
|
let (x, y) = write_string_to_grid(
|
||||||
write_string_to_grid(&a.name, grid, fg_color, bg_color, Attr::BOLD, area, None);
|
&a.name,
|
||||||
|
grid,
|
||||||
|
account_attrs.fg,
|
||||||
|
account_attrs.bg,
|
||||||
|
account_attrs.attrs,
|
||||||
|
area,
|
||||||
|
None,
|
||||||
|
);
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
&s,
|
&s,
|
||||||
grid,
|
grid,
|
||||||
fg_color,
|
account_attrs.fg,
|
||||||
bg_color,
|
account_attrs.bg,
|
||||||
Attr::BOLD,
|
account_attrs.attrs,
|
||||||
(
|
(
|
||||||
pos_dec(
|
pos_dec(
|
||||||
(get_x(bottom_right!(area)), get_y(upper_left!(area))),
|
(get_x(bottom_right!(area)), get_y(upper_left!(area))),
|
||||||
|
@ -345,8 +361,10 @@ impl ContactList {
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
for x in x..=get_x(bottom_right!(area)) {
|
for x in x..=get_x(bottom_right!(area)) {
|
||||||
grid[(x, y)].set_fg(fg_color);
|
grid[(x, y)]
|
||||||
grid[(x, y)].set_bg(bg_color);
|
.set_fg(account_attrs.fg)
|
||||||
|
.set_bg(account_attrs.bg)
|
||||||
|
.set_attrs(account_attrs.attrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1526,13 +1526,18 @@ impl Listing {
|
||||||
|
|
||||||
let account_attrs = if must_highlight_account {
|
let account_attrs = if must_highlight_account {
|
||||||
if self.focus == ListingFocus::Menu && self.menu_cursor_pos.1 == 0 {
|
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 {
|
} else {
|
||||||
crate::conf::value(context, "mail.sidebar_highlighted_account_name")
|
crate::conf::value(context, "mail.sidebar_highlighted_account_name")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
crate::conf::value(context, "mail.sidebar_account_name")
|
crate::conf::value(context, "mail.sidebar_account_name")
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Print account name first */
|
/* Print account name first */
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
&a.name,
|
&a.name,
|
||||||
|
@ -1549,8 +1554,8 @@ impl Listing {
|
||||||
"offline",
|
"offline",
|
||||||
grid,
|
grid,
|
||||||
Color::Byte(243),
|
Color::Byte(243),
|
||||||
self.theme_default.bg,
|
account_attrs.bg,
|
||||||
self.theme_default.attrs,
|
account_attrs.attrs,
|
||||||
(pos_inc(upper_left, (0, 1)), bottom_right),
|
(pos_inc(upper_left, (0, 1)), bottom_right),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
|
@ -1158,6 +1158,7 @@ pub struct ProgressSpinner {
|
||||||
stage: usize,
|
stage: usize,
|
||||||
pub kind: std::result::Result<usize, Vec<String>>,
|
pub kind: std::result::Result<usize, Vec<String>>,
|
||||||
pub width: usize,
|
pub width: usize,
|
||||||
|
theme_attr: ThemeAttribute,
|
||||||
active: bool,
|
active: bool,
|
||||||
dirty: bool,
|
dirty: bool,
|
||||||
id: ComponentId,
|
id: ComponentId,
|
||||||
|
@ -1212,11 +1213,17 @@ impl ProgressSpinner {
|
||||||
.map(|f| f.grapheme_len())
|
.map(|f| f.grapheme_len())
|
||||||
.max()
|
.max()
|
||||||
.unwrap_or(0);
|
.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 {
|
ProgressSpinner {
|
||||||
timer,
|
timer,
|
||||||
stage: 0,
|
stage: 0,
|
||||||
kind: Ok(kind),
|
kind: Ok(kind),
|
||||||
width,
|
width,
|
||||||
|
theme_attr,
|
||||||
dirty: true,
|
dirty: true,
|
||||||
active: false,
|
active: false,
|
||||||
id: ComponentId::new_v4(),
|
id: ComponentId::new_v4(),
|
||||||
|
@ -1278,8 +1285,7 @@ impl fmt::Display for ProgressSpinner {
|
||||||
impl Component for ProgressSpinner {
|
impl Component for ProgressSpinner {
|
||||||
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||||
if self.dirty {
|
if self.dirty {
|
||||||
let theme_attr = crate::conf::value(context, "status.bar");
|
clear_area(grid, area, self.theme_attr);
|
||||||
clear_area(grid, area, theme_attr);
|
|
||||||
if self.active {
|
if self.active {
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
match self.kind.as_ref() {
|
match self.kind.as_ref() {
|
||||||
|
@ -1287,9 +1293,9 @@ impl Component for ProgressSpinner {
|
||||||
Err(custom) => custom[self.stage].as_ref(),
|
Err(custom) => custom[self.stage].as_ref(),
|
||||||
},
|
},
|
||||||
grid,
|
grid,
|
||||||
theme_attr.fg,
|
self.theme_attr.fg,
|
||||||
theme_attr.bg,
|
self.theme_attr.bg,
|
||||||
theme_attr.attrs,
|
self.theme_attr.attrs,
|
||||||
area,
|
area,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue