themes: add a highlighted_selected theme key
So that if you select a mail/thread entry that is currently under the cursor (making it `highlighted`) you can also see its `selected` status. Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>pull/293/head
parent
5459a84f3d
commit
290cfb86c0
|
@ -237,6 +237,10 @@ mail.listing.compact.even_highlighted
|
|||
.It
|
||||
mail.listing.compact.odd_highlighted
|
||||
.It
|
||||
mail.listing.compact.even_highlighted_selected
|
||||
.It
|
||||
mail.listing.compact.odd_highlighted_selected
|
||||
.It
|
||||
mail.listing.plain.even
|
||||
.It
|
||||
mail.listing.plain.odd
|
||||
|
@ -253,6 +257,10 @@ mail.listing.plain.even_highlighted
|
|||
.It
|
||||
mail.listing.plain.odd_highlighted
|
||||
.It
|
||||
mail.listing.plain.even_highlighted_selected
|
||||
.It
|
||||
mail.listing.plain.odd_highlighted_selected
|
||||
.It
|
||||
mail.listing.conversations
|
||||
.It
|
||||
mail.listing.conversations.subject
|
||||
|
@ -267,6 +275,8 @@ mail.listing.conversations.highlighted
|
|||
.It
|
||||
mail.listing.conversations.selected
|
||||
.It
|
||||
mail.listing.conversations.highlighted_selected
|
||||
.It
|
||||
mail.view.headers
|
||||
.It
|
||||
mail.view.headers_names
|
||||
|
|
|
@ -285,6 +285,8 @@ const DEFAULT_KEYS: &[&str] = &[
|
|||
"mail.listing.compact.odd_selected",
|
||||
"mail.listing.compact.even_highlighted",
|
||||
"mail.listing.compact.odd_highlighted",
|
||||
"mail.listing.compact.even_highlighted_selected",
|
||||
"mail.listing.compact.odd_highlighted_selected",
|
||||
"mail.listing.plain.even",
|
||||
"mail.listing.plain.odd",
|
||||
"mail.listing.plain.even_unseen",
|
||||
|
@ -293,6 +295,8 @@ const DEFAULT_KEYS: &[&str] = &[
|
|||
"mail.listing.plain.odd_selected",
|
||||
"mail.listing.plain.even_highlighted",
|
||||
"mail.listing.plain.odd_highlighted",
|
||||
"mail.listing.plain.even_highlighted_selected",
|
||||
"mail.listing.plain.odd_highlighted_selected",
|
||||
"mail.listing.conversations",
|
||||
"mail.listing.conversations.subject",
|
||||
"mail.listing.conversations.from",
|
||||
|
@ -300,6 +304,7 @@ const DEFAULT_KEYS: &[&str] = &[
|
|||
"mail.listing.conversations.unseen",
|
||||
"mail.listing.conversations.highlighted",
|
||||
"mail.listing.conversations.selected",
|
||||
"mail.listing.conversations.highlighted_selected",
|
||||
"mail.view.headers",
|
||||
"mail.view.headers_names",
|
||||
"mail.view.headers_area",
|
||||
|
@ -1491,6 +1496,20 @@ impl Default for Themes {
|
|||
bg: Color::Byte(244)
|
||||
}
|
||||
);
|
||||
add!("mail.listing.compact.even_highlighted_selected",
|
||||
dark = {
|
||||
bg: Color::Byte(210),
|
||||
attrs: Attr::REVERSE,
|
||||
},
|
||||
light = {
|
||||
bg: Color::Byte(210),
|
||||
attrs: Attr::REVERSE,
|
||||
}
|
||||
);
|
||||
add!(
|
||||
"mail.listing.compact.odd_highlighted_selected",
|
||||
"mail.listing.compact.even_highlighted_selected"
|
||||
);
|
||||
|
||||
/* ConversationsListing */
|
||||
|
||||
|
@ -1554,6 +1573,17 @@ impl Default for Themes {
|
|||
}
|
||||
);
|
||||
|
||||
add!("mail.listing.conversations.highlighted_selected",
|
||||
dark = {
|
||||
bg: Color::Byte(210),
|
||||
attrs: Attr::REVERSE,
|
||||
},
|
||||
light = {
|
||||
bg: Color::Byte(210),
|
||||
attrs: Attr::REVERSE,
|
||||
}
|
||||
);
|
||||
|
||||
/* PlainListing */
|
||||
add!("mail.listing.plain.even",
|
||||
dark = {
|
||||
|
@ -1622,6 +1652,20 @@ impl Default for Themes {
|
|||
bg: Color::Byte(244)
|
||||
}
|
||||
);
|
||||
add!("mail.listing.plain.even_highlighted_selected",
|
||||
dark = {
|
||||
bg: Color::Byte(210),
|
||||
attrs: Attr::REVERSE,
|
||||
},
|
||||
light = {
|
||||
bg: Color::Byte(210),
|
||||
attrs: Attr::REVERSE,
|
||||
}
|
||||
);
|
||||
add!(
|
||||
"mail.listing.plain.odd_highlighted_selected",
|
||||
"mail.listing.plain.even_highlighted_selected"
|
||||
);
|
||||
|
||||
add!(
|
||||
"mail.view.headers",
|
||||
|
|
|
@ -266,6 +266,7 @@ pub struct ColorCache {
|
|||
pub unseen: ThemeAttribute,
|
||||
pub highlighted: ThemeAttribute,
|
||||
pub selected: ThemeAttribute,
|
||||
pub highlighted_selected: ThemeAttribute,
|
||||
pub even: ThemeAttribute,
|
||||
pub odd: ThemeAttribute,
|
||||
pub even_unseen: ThemeAttribute,
|
||||
|
@ -274,6 +275,8 @@ pub struct ColorCache {
|
|||
pub odd_unseen: ThemeAttribute,
|
||||
pub odd_highlighted: ThemeAttribute,
|
||||
pub odd_selected: ThemeAttribute,
|
||||
pub even_highlighted_selected: ThemeAttribute,
|
||||
pub odd_highlighted_selected: ThemeAttribute,
|
||||
pub tag_default: ThemeAttribute,
|
||||
|
||||
/* Conversations */
|
||||
|
@ -295,7 +298,15 @@ impl ColorCache {
|
|||
"mail.listing.plain.even_highlighted",
|
||||
),
|
||||
odd_highlighted: crate::conf::value(context, "mail.listing.plain.odd_highlighted"),
|
||||
odd_highlighted_selected: crate::conf::value(
|
||||
context,
|
||||
"mail.listing.plain.odd_highlighted_selected",
|
||||
),
|
||||
even_selected: crate::conf::value(context, "mail.listing.plain.even_selected"),
|
||||
even_highlighted_selected: crate::conf::value(
|
||||
context,
|
||||
"mail.listing.plain.even_highlighted_selected",
|
||||
),
|
||||
odd_selected: crate::conf::value(context, "mail.listing.plain.odd_selected"),
|
||||
tag_default: crate::conf::value(context, "mail.listing.tag_default"),
|
||||
theme_default: crate::conf::value(context, "theme_default"),
|
||||
|
@ -308,9 +319,17 @@ impl ColorCache {
|
|||
context,
|
||||
"mail.listing.plain.even_highlighted",
|
||||
),
|
||||
even_highlighted_selected: crate::conf::value(
|
||||
context,
|
||||
"mail.listing.plain.even_highlighted_selected",
|
||||
),
|
||||
odd_unseen: crate::conf::value(context, "mail.listing.plain.odd_unseen"),
|
||||
odd_selected: crate::conf::value(context, "mail.listing.plain.odd_selected"),
|
||||
odd_highlighted: crate::conf::value(context, "mail.listing.plain.odd_highlighted"),
|
||||
odd_highlighted_selected: crate::conf::value(
|
||||
context,
|
||||
"mail.listing.plain.odd_highlighted_selected",
|
||||
),
|
||||
even: crate::conf::value(context, "mail.listing.plain.even"),
|
||||
odd: crate::conf::value(context, "mail.listing.plain.odd"),
|
||||
tag_default: crate::conf::value(context, "mail.listing.tag_default"),
|
||||
|
@ -324,12 +343,20 @@ impl ColorCache {
|
|||
context,
|
||||
"mail.listing.compact.even_highlighted",
|
||||
),
|
||||
even_highlighted_selected: crate::conf::value(
|
||||
context,
|
||||
"mail.listing.compact.even_highlighted_selected",
|
||||
),
|
||||
odd_unseen: crate::conf::value(context, "mail.listing.compact.odd_unseen"),
|
||||
odd_selected: crate::conf::value(context, "mail.listing.compact.odd_selected"),
|
||||
odd_highlighted: crate::conf::value(
|
||||
context,
|
||||
"mail.listing.compact.odd_highlighted",
|
||||
),
|
||||
odd_highlighted_selected: crate::conf::value(
|
||||
context,
|
||||
"mail.listing.compact.odd_highlighted_selected",
|
||||
),
|
||||
even: crate::conf::value(context, "mail.listing.compact.even"),
|
||||
odd: crate::conf::value(context, "mail.listing.compact.odd"),
|
||||
tag_default: crate::conf::value(context, "mail.listing.tag_default"),
|
||||
|
@ -344,6 +371,10 @@ impl ColorCache {
|
|||
selected: crate::conf::value(context, "mail.listing.conversations.selected"),
|
||||
unseen: crate::conf::value(context, "mail.listing.conversations.unseen"),
|
||||
highlighted: crate::conf::value(context, "mail.listing.conversations.highlighted"),
|
||||
highlighted_selected: crate::conf::value(
|
||||
context,
|
||||
"mail.listing.conversations.highlighted_selected",
|
||||
),
|
||||
tag_default: crate::conf::value(context, "mail.listing.tag_default"),
|
||||
..Self::default()
|
||||
},
|
||||
|
@ -353,6 +384,8 @@ impl ColorCache {
|
|||
ret.tag_default.attrs |= Attr::REVERSE;
|
||||
ret.even_highlighted.attrs |= Attr::REVERSE;
|
||||
ret.odd_highlighted.attrs |= Attr::REVERSE;
|
||||
ret.even_highlighted_selected.attrs |= Attr::REVERSE | Attr::DIM;
|
||||
ret.odd_highlighted_selected.attrs |= Attr::REVERSE | Attr::DIM;
|
||||
}
|
||||
ret
|
||||
}
|
||||
|
|
|
@ -83,75 +83,98 @@ macro_rules! address_list {
|
|||
|
||||
macro_rules! row_attr {
|
||||
($color_cache:expr, $even: expr, $unseen:expr, $highlighted:expr, $selected:expr $(,)*) => {{
|
||||
let color_cache = &$color_cache;
|
||||
let even = $even;
|
||||
let unseen = $unseen;
|
||||
let highlighted = $highlighted;
|
||||
let selected = $selected;
|
||||
ThemeAttribute {
|
||||
fg: if $highlighted {
|
||||
if $even {
|
||||
$color_cache.even_highlighted.fg
|
||||
fg: if highlighted && selected {
|
||||
if even {
|
||||
color_cache.even_highlighted_selected.fg
|
||||
} else {
|
||||
$color_cache.odd_highlighted.fg
|
||||
color_cache.odd_highlighted_selected.fg
|
||||
}
|
||||
} else if $selected {
|
||||
if $even {
|
||||
$color_cache.even_selected.fg
|
||||
} else if highlighted {
|
||||
if even {
|
||||
color_cache.even_highlighted.fg
|
||||
} else {
|
||||
$color_cache.odd_selected.fg
|
||||
color_cache.odd_highlighted.fg
|
||||
}
|
||||
} else if $unseen {
|
||||
if $even {
|
||||
$color_cache.even_unseen.fg
|
||||
} else if selected {
|
||||
if even {
|
||||
color_cache.even_selected.fg
|
||||
} else {
|
||||
$color_cache.odd_unseen.fg
|
||||
color_cache.odd_selected.fg
|
||||
}
|
||||
} else if $even {
|
||||
$color_cache.even.fg
|
||||
} else if unseen {
|
||||
if even {
|
||||
color_cache.even_unseen.fg
|
||||
} else {
|
||||
color_cache.odd_unseen.fg
|
||||
}
|
||||
} else if even {
|
||||
color_cache.even.fg
|
||||
} else {
|
||||
$color_cache.odd.fg
|
||||
color_cache.odd.fg
|
||||
},
|
||||
bg: if $highlighted {
|
||||
if $even {
|
||||
$color_cache.even_highlighted.bg
|
||||
bg: if highlighted && selected {
|
||||
if even {
|
||||
color_cache.even_highlighted_selected.bg
|
||||
} else {
|
||||
$color_cache.odd_highlighted.bg
|
||||
color_cache.odd_highlighted_selected.bg
|
||||
}
|
||||
} else if $selected {
|
||||
if $even {
|
||||
$color_cache.even_selected.bg
|
||||
} else if highlighted {
|
||||
if even {
|
||||
color_cache.even_highlighted.bg
|
||||
} else {
|
||||
$color_cache.odd_selected.bg
|
||||
color_cache.odd_highlighted.bg
|
||||
}
|
||||
} else if $unseen {
|
||||
if $even {
|
||||
$color_cache.even_unseen.bg
|
||||
} else if selected {
|
||||
if even {
|
||||
color_cache.even_selected.bg
|
||||
} else {
|
||||
$color_cache.odd_unseen.bg
|
||||
color_cache.odd_selected.bg
|
||||
}
|
||||
} else if $even {
|
||||
$color_cache.even.bg
|
||||
} else if unseen {
|
||||
if even {
|
||||
color_cache.even_unseen.bg
|
||||
} else {
|
||||
color_cache.odd_unseen.bg
|
||||
}
|
||||
} else if even {
|
||||
color_cache.even.bg
|
||||
} else {
|
||||
$color_cache.odd.bg
|
||||
color_cache.odd.bg
|
||||
},
|
||||
attrs: if $highlighted {
|
||||
if $even {
|
||||
$color_cache.even_highlighted.attrs
|
||||
attrs: if highlighted && selected {
|
||||
if even {
|
||||
color_cache.even_highlighted_selected.attrs
|
||||
} else {
|
||||
$color_cache.odd_highlighted.attrs
|
||||
color_cache.odd_highlighted_selected.attrs
|
||||
}
|
||||
} else if $selected {
|
||||
if $even {
|
||||
$color_cache.even_selected.attrs
|
||||
} else if highlighted {
|
||||
if even {
|
||||
color_cache.even_highlighted.attrs
|
||||
} else {
|
||||
$color_cache.odd_selected.attrs
|
||||
color_cache.odd_highlighted.attrs
|
||||
}
|
||||
} else if $unseen {
|
||||
if $even {
|
||||
$color_cache.even_unseen.attrs
|
||||
} else if selected {
|
||||
if even {
|
||||
color_cache.even_selected.attrs
|
||||
} else {
|
||||
$color_cache.odd_unseen.attrs
|
||||
color_cache.odd_selected.attrs
|
||||
}
|
||||
} else if $even {
|
||||
$color_cache.even.attrs
|
||||
} else if unseen {
|
||||
if even {
|
||||
color_cache.even_unseen.attrs
|
||||
} else {
|
||||
color_cache.odd_unseen.attrs
|
||||
}
|
||||
} else if even {
|
||||
color_cache.even.attrs
|
||||
} else {
|
||||
$color_cache.odd.attrs
|
||||
color_cache.odd.attrs
|
||||
},
|
||||
}
|
||||
}};
|
||||
|
|
|
@ -29,64 +29,76 @@ use crate::{components::PageMovement, jobs::JoinHandle};
|
|||
|
||||
macro_rules! row_attr {
|
||||
($field:ident, $color_cache:expr, $unseen:expr, $highlighted:expr, $selected:expr $(,)*) => {{
|
||||
let color_cache = &$color_cache;
|
||||
let unseen = $unseen;
|
||||
let highlighted = $highlighted;
|
||||
let selected = $selected;
|
||||
ThemeAttribute {
|
||||
fg: if $highlighted {
|
||||
$color_cache.highlighted.fg
|
||||
} else if $selected {
|
||||
$color_cache.selected.fg
|
||||
} else if $unseen {
|
||||
$color_cache.unseen.fg
|
||||
fg: if highlighted {
|
||||
color_cache.highlighted.fg
|
||||
} else if selected {
|
||||
color_cache.selected.fg
|
||||
} else if unseen {
|
||||
color_cache.unseen.fg
|
||||
} else {
|
||||
$color_cache.$field.fg
|
||||
color_cache.$field.fg
|
||||
},
|
||||
bg: if $highlighted {
|
||||
$color_cache.highlighted.bg
|
||||
} else if $selected {
|
||||
$color_cache.selected.bg
|
||||
} else if $unseen {
|
||||
$color_cache.unseen.bg
|
||||
bg: if highlighted {
|
||||
color_cache.highlighted.bg
|
||||
} else if selected {
|
||||
color_cache.selected.bg
|
||||
} else if unseen {
|
||||
color_cache.unseen.bg
|
||||
} else {
|
||||
$color_cache.$field.bg
|
||||
color_cache.$field.bg
|
||||
},
|
||||
attrs: if $highlighted {
|
||||
$color_cache.highlighted.attrs
|
||||
} else if $selected {
|
||||
$color_cache.selected.attrs
|
||||
} else if $unseen {
|
||||
$color_cache.unseen.attrs
|
||||
attrs: if highlighted && selected {
|
||||
color_cache.highlighted_selected.attrs
|
||||
} else if highlighted {
|
||||
color_cache.highlighted.attrs
|
||||
} else if selected {
|
||||
color_cache.selected.attrs
|
||||
} else if unseen {
|
||||
color_cache.unseen.attrs
|
||||
} else {
|
||||
$color_cache.$field.attrs
|
||||
color_cache.$field.attrs
|
||||
},
|
||||
}
|
||||
}};
|
||||
($color_cache:expr, $unseen:expr, $highlighted:expr, $selected:expr $(,)*) => {{
|
||||
let color_cache = &$color_cache;
|
||||
let unseen = $unseen;
|
||||
let highlighted = $highlighted;
|
||||
let selected = $selected;
|
||||
ThemeAttribute {
|
||||
fg: if $highlighted {
|
||||
$color_cache.highlighted.fg
|
||||
} else if $selected {
|
||||
$color_cache.selected.fg
|
||||
} else if $unseen {
|
||||
$color_cache.unseen.fg
|
||||
fg: if highlighted {
|
||||
color_cache.highlighted.fg
|
||||
} else if selected {
|
||||
color_cache.selected.fg
|
||||
} else if unseen {
|
||||
color_cache.unseen.fg
|
||||
} else {
|
||||
$color_cache.theme_default.fg
|
||||
color_cache.theme_default.fg
|
||||
},
|
||||
bg: if $highlighted {
|
||||
$color_cache.highlighted.bg
|
||||
} else if $selected {
|
||||
$color_cache.selected.bg
|
||||
} else if $unseen {
|
||||
$color_cache.unseen.bg
|
||||
bg: if highlighted {
|
||||
color_cache.highlighted.bg
|
||||
} else if selected {
|
||||
color_cache.selected.bg
|
||||
} else if unseen {
|
||||
color_cache.unseen.bg
|
||||
} else {
|
||||
$color_cache.theme_default.bg
|
||||
color_cache.theme_default.bg
|
||||
},
|
||||
attrs: if $highlighted {
|
||||
$color_cache.highlighted.attrs
|
||||
} else if $selected {
|
||||
$color_cache.selected.attrs
|
||||
} else if $unseen {
|
||||
$color_cache.unseen.attrs
|
||||
attrs: if highlighted && selected {
|
||||
color_cache.highlighted_selected.attrs
|
||||
} else if highlighted {
|
||||
color_cache.highlighted.attrs
|
||||
} else if selected {
|
||||
color_cache.selected.attrs
|
||||
} else if unseen {
|
||||
color_cache.unseen.attrs
|
||||
} else {
|
||||
$color_cache.theme_default.attrs
|
||||
color_cache.theme_default.attrs
|
||||
},
|
||||
}
|
||||
}};
|
||||
|
|
|
@ -44,75 +44,98 @@ macro_rules! address_list {
|
|||
|
||||
macro_rules! row_attr {
|
||||
($color_cache:expr, $even: expr, $unseen:expr, $highlighted:expr, $selected:expr $(,)*) => {{
|
||||
let color_cache = &$color_cache;
|
||||
let even = $even;
|
||||
let unseen = $unseen;
|
||||
let highlighted = $highlighted;
|
||||
let selected = $selected;
|
||||
ThemeAttribute {
|
||||
fg: if $highlighted {
|
||||
if $even {
|
||||
$color_cache.even_highlighted.fg
|
||||
fg: if highlighted && selected {
|
||||
if even {
|
||||
color_cache.even_highlighted_selected.fg
|
||||
} else {
|
||||
$color_cache.odd_highlighted.fg
|
||||
color_cache.odd_highlighted_selected.fg
|
||||
}
|
||||
} else if $selected {
|
||||
if $even {
|
||||
$color_cache.even_selected.fg
|
||||
} else if highlighted {
|
||||
if even {
|
||||
color_cache.even_highlighted.fg
|
||||
} else {
|
||||
$color_cache.odd_selected.fg
|
||||
color_cache.odd_highlighted.fg
|
||||
}
|
||||
} else if $unseen {
|
||||
if $even {
|
||||
$color_cache.even_unseen.fg
|
||||
} else if selected {
|
||||
if even {
|
||||
color_cache.even_selected.fg
|
||||
} else {
|
||||
$color_cache.odd_unseen.fg
|
||||
color_cache.odd_selected.fg
|
||||
}
|
||||
} else if $even {
|
||||
$color_cache.even.fg
|
||||
} else if unseen {
|
||||
if even {
|
||||
color_cache.even_unseen.fg
|
||||
} else {
|
||||
color_cache.odd_unseen.fg
|
||||
}
|
||||
} else if even {
|
||||
color_cache.even.fg
|
||||
} else {
|
||||
$color_cache.odd.fg
|
||||
color_cache.odd.fg
|
||||
},
|
||||
bg: if $highlighted {
|
||||
if $even {
|
||||
$color_cache.even_highlighted.bg
|
||||
bg: if highlighted && selected {
|
||||
if even {
|
||||
color_cache.even_highlighted_selected.bg
|
||||
} else {
|
||||
$color_cache.odd_highlighted.bg
|
||||
color_cache.odd_highlighted_selected.bg
|
||||
}
|
||||
} else if $selected {
|
||||
if $even {
|
||||
$color_cache.even_selected.bg
|
||||
} else if highlighted {
|
||||
if even {
|
||||
color_cache.even_highlighted.bg
|
||||
} else {
|
||||
$color_cache.odd_selected.bg
|
||||
color_cache.odd_highlighted.bg
|
||||
}
|
||||
} else if $unseen {
|
||||
if $even {
|
||||
$color_cache.even_unseen.bg
|
||||
} else if selected {
|
||||
if even {
|
||||
color_cache.even_selected.bg
|
||||
} else {
|
||||
$color_cache.odd_unseen.bg
|
||||
color_cache.odd_selected.bg
|
||||
}
|
||||
} else if $even {
|
||||
$color_cache.even.bg
|
||||
} else if unseen {
|
||||
if even {
|
||||
color_cache.even_unseen.bg
|
||||
} else {
|
||||
color_cache.odd_unseen.bg
|
||||
}
|
||||
} else if even {
|
||||
color_cache.even.bg
|
||||
} else {
|
||||
$color_cache.odd.bg
|
||||
color_cache.odd.bg
|
||||
},
|
||||
attrs: if $highlighted {
|
||||
if $even {
|
||||
$color_cache.even_highlighted.attrs
|
||||
attrs: if highlighted && selected {
|
||||
if even {
|
||||
color_cache.even_highlighted_selected.attrs
|
||||
} else {
|
||||
$color_cache.odd_highlighted.attrs
|
||||
color_cache.odd_highlighted_selected.attrs
|
||||
}
|
||||
} else if $selected {
|
||||
if $even {
|
||||
$color_cache.even_selected.attrs
|
||||
} else if highlighted {
|
||||
if even {
|
||||
color_cache.even_highlighted.attrs
|
||||
} else {
|
||||
$color_cache.odd_selected.attrs
|
||||
color_cache.odd_highlighted.attrs
|
||||
}
|
||||
} else if $unseen {
|
||||
if $even {
|
||||
$color_cache.even_unseen.attrs
|
||||
} else if selected {
|
||||
if even {
|
||||
color_cache.even_selected.attrs
|
||||
} else {
|
||||
$color_cache.odd_unseen.attrs
|
||||
color_cache.odd_selected.attrs
|
||||
}
|
||||
} else if $even {
|
||||
$color_cache.even.attrs
|
||||
} else if unseen {
|
||||
if even {
|
||||
color_cache.even_unseen.attrs
|
||||
} else {
|
||||
color_cache.odd_unseen.attrs
|
||||
}
|
||||
} else if even {
|
||||
color_cache.even.attrs
|
||||
} else {
|
||||
$color_cache.odd.attrs
|
||||
color_cache.odd.attrs
|
||||
},
|
||||
}
|
||||
}};
|
||||
|
|
|
@ -28,75 +28,98 @@ use crate::components::PageMovement;
|
|||
|
||||
macro_rules! row_attr {
|
||||
($color_cache:expr, $even: expr, $unseen:expr, $highlighted:expr, $selected:expr $(,)*) => {{
|
||||
let color_cache = &$color_cache;
|
||||
let even = $even;
|
||||
let unseen = $unseen;
|
||||
let highlighted = $highlighted;
|
||||
let selected = $selected;
|
||||
ThemeAttribute {
|
||||
fg: if $highlighted {
|
||||
if $even {
|
||||
$color_cache.even_highlighted.fg
|
||||
fg: if highlighted && selected {
|
||||
if even {
|
||||
color_cache.even_highlighted_selected.fg
|
||||
} else {
|
||||
$color_cache.odd_highlighted.fg
|
||||
color_cache.odd_highlighted_selected.fg
|
||||
}
|
||||
} else if $selected {
|
||||
if $even {
|
||||
$color_cache.even_selected.fg
|
||||
} else if highlighted {
|
||||
if even {
|
||||
color_cache.even_highlighted.fg
|
||||
} else {
|
||||
$color_cache.odd_selected.fg
|
||||
color_cache.odd_highlighted.fg
|
||||
}
|
||||
} else if $unseen {
|
||||
if $even {
|
||||
$color_cache.even_unseen.fg
|
||||
} else if selected {
|
||||
if even {
|
||||
color_cache.even_selected.fg
|
||||
} else {
|
||||
$color_cache.odd_unseen.fg
|
||||
color_cache.odd_selected.fg
|
||||
}
|
||||
} else if $even {
|
||||
$color_cache.even.fg
|
||||
} else if unseen {
|
||||
if even {
|
||||
color_cache.even_unseen.fg
|
||||
} else {
|
||||
color_cache.odd_unseen.fg
|
||||
}
|
||||
} else if even {
|
||||
color_cache.even.fg
|
||||
} else {
|
||||
$color_cache.odd.fg
|
||||
color_cache.odd.fg
|
||||
},
|
||||
bg: if $highlighted {
|
||||
if $even {
|
||||
$color_cache.even_highlighted.bg
|
||||
bg: if highlighted && selected {
|
||||
if even {
|
||||
color_cache.even_highlighted_selected.bg
|
||||
} else {
|
||||
$color_cache.odd_highlighted.bg
|
||||
color_cache.odd_highlighted_selected.bg
|
||||
}
|
||||
} else if $selected {
|
||||
if $even {
|
||||
$color_cache.even_selected.bg
|
||||
} else if highlighted {
|
||||
if even {
|
||||
color_cache.even_highlighted.bg
|
||||
} else {
|
||||
$color_cache.odd_selected.bg
|
||||
color_cache.odd_highlighted.bg
|
||||
}
|
||||
} else if $unseen {
|
||||
if $even {
|
||||
$color_cache.even_unseen.bg
|
||||
} else if selected {
|
||||
if even {
|
||||
color_cache.even_selected.bg
|
||||
} else {
|
||||
$color_cache.odd_unseen.bg
|
||||
color_cache.odd_selected.bg
|
||||
}
|
||||
} else if $even {
|
||||
$color_cache.even.bg
|
||||
} else if unseen {
|
||||
if even {
|
||||
color_cache.even_unseen.bg
|
||||
} else {
|
||||
color_cache.odd_unseen.bg
|
||||
}
|
||||
} else if even {
|
||||
color_cache.even.bg
|
||||
} else {
|
||||
$color_cache.odd.bg
|
||||
color_cache.odd.bg
|
||||
},
|
||||
attrs: if $highlighted {
|
||||
if $even {
|
||||
$color_cache.even_highlighted.attrs
|
||||
attrs: if highlighted && selected {
|
||||
if even {
|
||||
color_cache.even_highlighted_selected.attrs
|
||||
} else {
|
||||
$color_cache.odd_highlighted.attrs
|
||||
color_cache.odd_highlighted_selected.attrs
|
||||
}
|
||||
} else if $selected {
|
||||
if $even {
|
||||
$color_cache.even_selected.attrs
|
||||
} else if highlighted {
|
||||
if even {
|
||||
color_cache.even_highlighted.attrs
|
||||
} else {
|
||||
$color_cache.odd_selected.attrs
|
||||
color_cache.odd_highlighted.attrs
|
||||
}
|
||||
} else if $unseen {
|
||||
if $even {
|
||||
$color_cache.even_unseen.attrs
|
||||
} else if selected {
|
||||
if even {
|
||||
color_cache.even_selected.attrs
|
||||
} else {
|
||||
$color_cache.odd_unseen.attrs
|
||||
color_cache.odd_selected.attrs
|
||||
}
|
||||
} else if $even {
|
||||
$color_cache.even.attrs
|
||||
} else if unseen {
|
||||
if even {
|
||||
color_cache.even_unseen.attrs
|
||||
} else {
|
||||
color_cache.odd_unseen.attrs
|
||||
}
|
||||
} else if even {
|
||||
color_cache.even.attrs
|
||||
} else {
|
||||
$color_cache.odd.attrs
|
||||
color_cache.odd.attrs
|
||||
},
|
||||
}
|
||||
}};
|
||||
|
@ -123,6 +146,7 @@ pub struct ThreadListing {
|
|||
|
||||
data_columns: DataColumns<5>,
|
||||
rows: RowsState<(ThreadHash, EnvelopeHash)>,
|
||||
seen_cache: IndexMap<EnvelopeHash, bool>,
|
||||
/// If we must redraw on next redraw event
|
||||
dirty: bool,
|
||||
force_draw: bool,
|
||||
|
@ -355,14 +379,7 @@ impl MailListingTrait for ThreadListing {
|
|||
smallvec::smallvec![env_hash],
|
||||
entry_strings,
|
||||
);
|
||||
let row_attr = row_attr!(
|
||||
self.color_cache,
|
||||
idx % 2 == 0,
|
||||
!envelope.is_seen(),
|
||||
false,
|
||||
false,
|
||||
);
|
||||
self.rows.row_attr_cache.insert(idx, row_attr);
|
||||
self.seen_cache.insert(env_hash, envelope.is_seen());
|
||||
idx += 1;
|
||||
}
|
||||
|
||||
|
@ -539,11 +556,15 @@ impl ListingTrait for ThreadListing {
|
|||
let new_area = nth_row_area(area, idx % rows);
|
||||
self.data_columns
|
||||
.draw(grid, idx, self.cursor_pos.2, grid.bounds_iter(new_area));
|
||||
if highlight {
|
||||
let row_attr = row_attr!(self.color_cache, idx % 2 == 0, false, true, false);
|
||||
if let Some(env_hash) = self.get_env_under_cursor(idx) {
|
||||
let row_attr = row_attr!(
|
||||
self.color_cache,
|
||||
idx % 2 == 0,
|
||||
!self.seen_cache[&env_hash],
|
||||
highlight,
|
||||
self.rows.selection[&env_hash]
|
||||
);
|
||||
change_theme(grid, new_area, row_attr);
|
||||
} else if let Some(row_attr) = self.rows.row_attr_cache.get(&idx) {
|
||||
change_theme(grid, new_area, *row_attr);
|
||||
}
|
||||
context.dirty_areas.push_back(new_area);
|
||||
}
|
||||
|
@ -579,21 +600,30 @@ impl ListingTrait for ThreadListing {
|
|||
self.draw_relative_numbers(grid, area, top_idx);
|
||||
}
|
||||
/* apply each row colors separately */
|
||||
for i in top_idx..(top_idx + height!(area)) {
|
||||
if let Some(row_attr) = self.rows.row_attr_cache.get(&i) {
|
||||
change_theme(grid, nth_row_area(area, i % rows), *row_attr);
|
||||
for idx in top_idx..(top_idx + height!(area)) {
|
||||
if let Some(env_hash) = self.get_env_under_cursor(idx) {
|
||||
let row_attr = row_attr!(
|
||||
self.color_cache,
|
||||
idx % 2 == 0,
|
||||
!self.seen_cache[&env_hash],
|
||||
self.cursor_pos.2 == idx,
|
||||
self.rows.selection[&env_hash]
|
||||
);
|
||||
change_theme(grid, nth_row_area(area, idx % rows), row_attr);
|
||||
}
|
||||
}
|
||||
|
||||
/* highlight cursor */
|
||||
let row_attr = row_attr!(
|
||||
self.color_cache,
|
||||
self.cursor_pos.2 % 2 == 0,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
);
|
||||
change_theme(grid, nth_row_area(area, self.cursor_pos.2 % rows), row_attr);
|
||||
if let Some(env_hash) = self.get_env_under_cursor(self.cursor_pos.2) {
|
||||
/* highlight cursor */
|
||||
let row_attr = row_attr!(
|
||||
self.color_cache,
|
||||
self.cursor_pos.2 % 2 == 0,
|
||||
!self.seen_cache[&env_hash],
|
||||
true, // because self.cursor_pos.2 == idx,
|
||||
self.rows.selection[&env_hash]
|
||||
);
|
||||
change_theme(grid, nth_row_area(area, self.cursor_pos.2 % rows), row_attr);
|
||||
}
|
||||
|
||||
/* clear gap if available height is more than count of entries */
|
||||
if top_idx + rows > self.length {
|
||||
|
@ -745,6 +775,7 @@ impl ThreadListing {
|
|||
color_cache: ColorCache::new(context, IndexStyle::Threaded),
|
||||
data_columns: DataColumns::default(),
|
||||
rows: RowsState::default(),
|
||||
seen_cache: IndexMap::default(),
|
||||
search_job: None,
|
||||
dirty: true,
|
||||
force_draw: true,
|
||||
|
@ -910,7 +941,13 @@ impl ThreadListing {
|
|||
|
||||
panic!();
|
||||
}
|
||||
let row_attr = self.rows.row_attr_cache[&idx];
|
||||
let row_attr = row_attr!(
|
||||
self.color_cache,
|
||||
idx % 2 == 0,
|
||||
!self.seen_cache[env_hash],
|
||||
self.cursor_pos.2 == idx,
|
||||
self.rows.selection[env_hash]
|
||||
);
|
||||
if !*account_settings!(context[self.cursor_pos.0].listing.relative_list_indices) {
|
||||
let (x, _) = write_string_to_grid(
|
||||
&idx.to_string(),
|
||||
|
@ -1053,7 +1090,7 @@ impl ThreadListing {
|
|||
false,
|
||||
self.rows.selection[&env_hash]
|
||||
);
|
||||
self.rows.row_attr_cache.insert(idx, row_attr);
|
||||
self.seen_cache.insert(env_hash, envelope.is_seen());
|
||||
|
||||
let mut strings = self.make_entry_string(&envelope, context);
|
||||
drop(envelope);
|
||||
|
@ -1083,7 +1120,17 @@ impl ThreadListing {
|
|||
let width = self.data_columns.columns[0].size().0;
|
||||
let upper_left = upper_left!(area);
|
||||
for i in 0..height!(area) {
|
||||
let row_attr = row_attr!(self.color_cache, (top_idx + i) % 2 == 0, false, true, false);
|
||||
let row_attr = if let Some(env_hash) = self.get_env_under_cursor(top_idx + i) {
|
||||
row_attr!(
|
||||
self.color_cache,
|
||||
(top_idx + i) % 2 == 0,
|
||||
!self.seen_cache[&env_hash],
|
||||
self.cursor_pos.2 == (top_idx + i),
|
||||
self.rows.selection[&env_hash]
|
||||
)
|
||||
} else {
|
||||
row_attr!(self.color_cache, (top_idx + i) % 2 == 0, false, true, false)
|
||||
};
|
||||
|
||||
clear_area(
|
||||
&mut self.data_columns.columns[0],
|
||||
|
@ -1490,6 +1537,9 @@ impl Component for ThreadListing {
|
|||
return false;
|
||||
}
|
||||
self.rows.rename_env(*old_hash, *new_hash);
|
||||
self.seen_cache.remove(old_hash);
|
||||
self.seen_cache
|
||||
.insert(*new_hash, account.collection.get_env(*new_hash).is_seen());
|
||||
if let Some(&row) = self.rows.env_order.get(new_hash) {
|
||||
(self.rows.entries[row].0).1 = *new_hash;
|
||||
}
|
||||
|
@ -1499,6 +1549,7 @@ impl Component for ThreadListing {
|
|||
UIEvent::EnvelopeRemove(ref env_hash, _) => {
|
||||
if self.rows.contains_env(*env_hash) {
|
||||
self.refresh_mailbox(context, false);
|
||||
self.seen_cache.remove(env_hash);
|
||||
self.set_dirty(true);
|
||||
}
|
||||
}
|
||||
|
@ -1509,6 +1560,8 @@ impl Component for ThreadListing {
|
|||
}
|
||||
if self.rows.contains_env(*env_hash) {
|
||||
self.rows.row_updates.push(*env_hash);
|
||||
self.seen_cache
|
||||
.insert(*env_hash, account.collection.get_env(*env_hash).is_seen());
|
||||
}
|
||||
|
||||
self.set_dirty(true);
|
||||
|
|
Loading…
Reference in New Issue