ui: correct row highlighting in CompactListing

This commit is contained in:
Manos Pitsidianakis 2019-11-16 13:41:33 +02:00
parent 321be8555f
commit 0d03116e8a
No known key found for this signature in database
GPG Key ID: 73627C2F690DF710

View File

@ -99,7 +99,11 @@ impl ListingTrait for CompactListing {
let threads = &account.collection.threads[&folder_hash]; let threads = &account.collection.threads[&folder_hash];
let thread_node = &threads.thread_nodes[&i]; let thread_node = &threads.thread_nodes[&i];
let fg_color = self.data_columns.columns[0][(0, idx)].fg(); let fg_color = if thread_node.has_unseen() {
Color::Byte(0)
} else {
Color::Default
};
let bg_color = if context.settings.terminal.theme == "light" { let bg_color = if context.settings.terminal.theme == "light" {
if self.cursor_pos.2 == idx { if self.cursor_pos.2 == idx {
Color::Byte(244) Color::Byte(244)
@ -107,8 +111,10 @@ impl ListingTrait for CompactListing {
Color::Byte(210) Color::Byte(210)
} else if thread_node.has_unseen() { } else if thread_node.has_unseen() {
Color::Byte(251) Color::Byte(251)
} else if idx % 2 == 0 {
Color::Byte(252)
} else { } else {
self.data_columns.columns[0][(0, idx)].bg() Color::Default
} }
} else { } else {
if self.cursor_pos.2 == idx { if self.cursor_pos.2 == idx {
@ -116,9 +122,11 @@ impl ListingTrait for CompactListing {
} else if self.selection[&i] { } else if self.selection[&i] {
Color::Byte(210) Color::Byte(210)
} else if thread_node.has_unseen() { } else if thread_node.has_unseen() {
Color::Byte(251) Color::Byte(253)
} else if idx % 2 == 0 {
Color::Byte(236)
} else { } else {
self.data_columns.columns[0][(0, idx)].bg() Color::Default
} }
}; };
@ -295,8 +303,14 @@ impl ListingTrait for CompactListing {
} }
for r in 0..cmp::min(self.length - top_idx, rows) { for r in 0..cmp::min(self.length - top_idx, rows) {
let (fg_color, bg_color) = { let (fg_color, bg_color) = {
let thread_hash = self.get_thread_under_cursor(r + top_idx, context);
let c = &self.data_columns.columns[0][(0, r + top_idx)]; let c = &self.data_columns.columns[0][(0, r + top_idx)];
(c.fg(), c.bg()) if self.selection[&thread_hash] {
(c.fg(), Color::Byte(210))
} else {
(c.fg(), c.bg())
}
}; };
change_colors( change_colors(
grid, grid,