ConversationsListing: fix invalid update_line colors

memfd
Manos Pitsidianakis 2020-07-24 22:24:36 +03:00
parent 99fbac3806
commit f9efaea0ec
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
2 changed files with 101 additions and 98 deletions

View File

@ -26,64 +26,66 @@ use std::iter::FromIterator;
macro_rules! row_attr { macro_rules! row_attr {
($field:ident, $color_cache:expr, $unseen:expr, $highlighted:expr, $selected:expr $(,)*) => {{ ($field:ident, $color_cache:expr, $unseen:expr, $highlighted:expr, $selected:expr $(,)*) => {{
let fg = if $unseen { ThemeAttribute {
$color_cache.unseen.fg fg: if $highlighted {
} else if $highlighted {
$color_cache.highlighted.fg $color_cache.highlighted.fg
} else if $selected { } else if $selected {
$color_cache.selected.fg $color_cache.selected.fg
} else if $unseen {
$color_cache.unseen.fg
} else { } else {
$color_cache.$field.fg $color_cache.$field.fg
}; },
let bg = if $unseen { bg: if $highlighted {
$color_cache.unseen.bg
} else if $highlighted {
$color_cache.highlighted.bg $color_cache.highlighted.bg
} else if $selected { } else if $selected {
$color_cache.selected.bg $color_cache.selected.bg
} else if $unseen {
$color_cache.unseen.bg
} else { } else {
$color_cache.$field.bg $color_cache.$field.bg
}; },
let attrs = if $unseen { attrs: if $highlighted {
$color_cache.unseen.attrs
} else if $highlighted {
$color_cache.highlighted.attrs $color_cache.highlighted.attrs
} else if $selected { } else if $selected {
$color_cache.selected.attrs $color_cache.selected.attrs
} else if $unseen {
$color_cache.unseen.attrs
} else { } else {
$color_cache.$field.attrs $color_cache.$field.attrs
}; },
ThemeAttribute { fg, bg, attrs } }
}}; }};
($color_cache:expr, $unseen:expr, $highlighted:expr, $selected:expr $(,)*) => {{ ($color_cache:expr, $unseen:expr, $highlighted:expr, $selected:expr $(,)*) => {{
let fg = if $unseen { ThemeAttribute {
$color_cache.unseen.fg fg: if $highlighted {
} else if $highlighted {
$color_cache.highlighted.fg $color_cache.highlighted.fg
} else if $selected { } else if $selected {
$color_cache.selected.fg $color_cache.selected.fg
} else if $unseen {
$color_cache.unseen.fg
} else { } else {
$color_cache.theme_default.fg $color_cache.theme_default.fg
}; },
let bg = if $unseen { bg: if $highlighted {
$color_cache.unseen.bg
} else if $highlighted {
$color_cache.highlighted.bg $color_cache.highlighted.bg
} else if $selected { } else if $selected {
$color_cache.selected.bg $color_cache.selected.bg
} else if $unseen {
$color_cache.unseen.bg
} else { } else {
$color_cache.theme_default.bg $color_cache.theme_default.bg
}; },
let attrs = if $unseen { attrs: if $highlighted {
$color_cache.unseen.attrs
} else if $highlighted {
$color_cache.highlighted.attrs $color_cache.highlighted.attrs
} else if $selected { } else if $selected {
$color_cache.selected.attrs $color_cache.selected.attrs
} else if $unseen {
$color_cache.unseen.attrs
} else { } else {
$color_cache.theme_default.attrs $color_cache.theme_default.attrs
}; },
ThemeAttribute { fg, bg, attrs } }
}}; }};
} }
@ -1057,7 +1059,7 @@ impl ConversationsListing {
} }
let subject_attr = row_attr!(subject, self.color_cache, thread.unseen() > 0, false, false); let subject_attr = row_attr!(subject, self.color_cache, thread.unseen() > 0, false, false);
/* draw subject */ /* draw subject */
let (x, _) = write_string_to_grid( let (mut x, _) = write_string_to_grid(
&strings.subject, &strings.subject,
&mut self.content, &mut self.content,
subject_attr.fg, subject_attr.fg,
@ -1066,8 +1068,6 @@ impl ConversationsListing {
((x, 3 * idx), (width - 1, 3 * idx)), ((x, 3 * idx), (width - 1, 3 * idx)),
None, None,
); );
let x = {
let mut x = x + 1;
for (t, &color) in strings.tags.split_whitespace().zip(strings.tags.1.iter()) { for (t, &color) in strings.tags.split_whitespace().zip(strings.tags.1.iter()) {
let color = color.unwrap_or(self.color_cache.tag_default.bg); let color = color.unwrap_or(self.color_cache.tag_default.bg);
let (_x, _) = write_string_to_grid( let (_x, _) = write_string_to_grid(
@ -1079,27 +1079,23 @@ impl ConversationsListing {
((x + 1, 3 * idx), (width - 1, 3 * idx)), ((x + 1, 3 * idx), (width - 1, 3 * idx)),
None, None,
); );
for c in self.content.row_iter(x..(x + 1), 3 * idx) { self.content[(x, 3 * idx)].set_bg(color);
self.content[c].set_bg(color); if _x < width {
self.content[(_x, 3 * idx)].set_bg(color).set_keep_bg(true);
} }
for c in self.content.row_iter(_x..(_x + 1), 3 * idx) { for x in (x + 1).._x {
self.content[c].set_bg(color); self.content[(x, 3 * idx)]
self.content[c].set_keep_bg(true); .set_keep_fg(true)
} .set_keep_bg(true);
for c in self.content.row_iter(x + 1..(_x + 1), 3 * idx) {
self.content[c].set_keep_fg(true);
self.content[c].set_keep_bg(true);
}
for c in self.content.row_iter(x..(x + 1), 3 * idx) {
self.content[c].set_keep_bg(true);
} }
self.content[(x, 3 * idx)].set_keep_bg(true);
x = _x + 1; x = _x + 1;
} }
x
};
for c in self.content.row_iter(x..width, 3 * idx) { for c in self.content.row_iter(x..width, 3 * idx) {
self.content[c].set_ch(' '); self.content[c]
self.content[c].set_bg(row_attr.bg); .set_ch(' ')
.set_fg(row_attr.fg)
.set_bg(row_attr.bg);
} }
let date_attr = row_attr!(date, self.color_cache, thread.unseen() > 0, false, false); let date_attr = row_attr!(date, self.color_cache, thread.unseen() > 0, false, false);
/* Next line, draw date */ /* Next line, draw date */
@ -1112,9 +1108,11 @@ impl ConversationsListing {
((0, 3 * idx + 1), (width - 1, 3 * idx + 1)), ((0, 3 * idx + 1), (width - 1, 3 * idx + 1)),
None, None,
); );
for c in self.content.row_iter(x..(x + 5), 3 * idx + 1) { for c in self.content.row_iter(x..(x + 4), 3 * idx + 1) {
self.content[c].set_ch('▁'); self.content[c]
self.content[c].set_bg(row_attr.bg); .set_ch('▁')
.set_fg(row_attr.fg)
.set_bg(row_attr.bg);
} }
let from_attr = row_attr!(from, self.color_cache, thread.unseen() > 0, false, false); let from_attr = row_attr!(from, self.color_cache, thread.unseen() > 0, false, false);
/* draw from */ /* draw from */
@ -1129,13 +1127,16 @@ impl ConversationsListing {
); );
for c in self.content.row_iter(x..width, 3 * idx + 1) { for c in self.content.row_iter(x..width, 3 * idx + 1) {
self.content[c].set_ch('▁'); self.content[c]
self.content[c].set_bg(row_attr.bg); .set_ch('▁')
.set_fg(row_attr.fg)
.set_bg(row_attr.bg);
} }
for c in self.content.row_iter(0..width, 3 * idx + 2) { for c in self.content.row_iter(0..width, 3 * idx + 2) {
self.content[c].set_ch('▓'); self.content[c]
self.content[c].set_fg(padding_fg); .set_ch('▓')
self.content[c].set_bg(row_attr.bg); .set_fg(padding_fg)
.set_bg(row_attr.bg);
} }
} }
} }

View File

@ -1512,9 +1512,11 @@ impl Default for Themes {
"mail.listing.conversations.highlighted", "mail.listing.conversations.highlighted",
dark = { dark = {
bg: Color::Byte(246), bg: Color::Byte(246),
attrs: Attr::BOLD,
}, },
light = { light = {
bg: Color::Byte(246) bg: Color::Byte(246),
attrs: Attr::BOLD,
} }
); );
add!("mail.listing.conversations.selected", add!("mail.listing.conversations.selected",