summaryrefslogtreecommitdiffstats
path: root/ui/src/components
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2020-01-19 14:43:36 +0200
committerManos Pitsidianakis <el13635@mail.ntua.gr>2020-01-21 12:02:21 +0200
commita9842cacee7b7324832f5775b969b3f14fe17f31 (patch)
tree9ba7512b7674395a19f9987c79ecaa4bfc78046b /ui/src/components
parent63ff25b36ae87b0c4f901d8adfb8a62a83212f83 (diff)
ui: add theming support
Configuration flag "terminal.themes" has two default theme entries, "dark" and "light". This commit alters only CompactListing for theme support.
Diffstat (limited to 'ui/src/components')
-rw-r--r--ui/src/components/mail/listing/compact.rs155
1 files changed, 80 insertions, 75 deletions
diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs
index 9c5ea6d3..15cae3f8 100644
--- a/ui/src/components/mail/listing/compact.rs
+++ b/ui/src/components/mail/listing/compact.rs
@@ -126,34 +126,24 @@ impl ListingTrait for CompactListing {
let thread = threads.thread_ref(thread_hash);
let fg_color = if thread.unseen() > 0 {
- Color::Byte(0)
+ crate::conf::color(context, "mail.listing.compact.unseen_fg")
+ } else if self.cursor_pos.2 == idx {
+ crate::conf::color(context, "mail.listing.compact.highlighted_fg")
+ } else if idx % 2 == 0 {
+ crate::conf::color(context, "mail.listing.compact.even_fg")
} else {
- Color::Default
+ crate::conf::color(context, "mail.listing.compact.odd_fg")
};
- let bg_color = if context.settings.terminal.theme == "light" {
- if self.cursor_pos.2 == idx {
- Color::Byte(244)
- } else if self.selection[&thread_hash] {
- Color::Byte(210)
- } else if thread.unseen() > 0 {
- Color::Byte(251)
- } else if idx % 2 == 0 {
- Color::Byte(252)
- } else {
- Color::Default
- }
+ let bg_color = if self.cursor_pos.2 == idx {
+ crate::conf::color(context, "mail.listing.compact.highlighted_bg")
+ } else if self.selection[&thread_hash] {
+ crate::conf::color(context, "mail.listing.compact.selected_bg")
+ } else if thread.unseen() > 0 {
+ crate::conf::color(context, "mail.listing.compact.unseen_bg")
+ } else if idx % 2 == 0 {
+ crate::conf::color(context, "mail.listing.compact.even_bg")
} else {
- if self.cursor_pos.2 == idx {
- Color::Byte(246)
- } else if self.selection[&thread_hash] {
- Color::Byte(210)
- } else if thread.unseen() > 0 {
- Color::Byte(251)
- } else if idx % 2 == 0 {
- Color::Byte(236)
- } else {
- Color::Default
- }
+ crate::conf::color(context, "mail.listing.compact.odd_bg")
};
let (upper_left, bottom_right) = area;
@@ -356,7 +346,10 @@ impl ListingTrait for CompactListing {
let c = &self.data_columns.columns[0][(0, r + top_idx)];
if self.selection[&thread_hash] {
- (c.fg(), Color::Byte(210))
+ (
+ c.fg(),
+ crate::conf::color(context, "mail.listing.compact.selected_bg"),
+ )
} else {
(c.fg(), c.bg())
}
@@ -810,27 +803,21 @@ impl CompactListing {
panic!();
}
let thread = threads.thread_ref(thread);
- let fg_color = if thread.unseen() > 0 {
- Color::Byte(0)
- } else {
- Color::Default
- };
- let bg_color = if context.settings.terminal.theme == "light" {
- if thread.unseen() > 0 {
- Color::Byte(251)
- } else if idx % 2 == 0 {
- Color::Byte(252)
- } else {
- Color::Default
- }
+ let (fg_color, bg_color) = if thread.unseen() > 0 {
+ (
+ crate::conf::color(context, "mail.listing.compact.unseen_fg"),
+ crate::conf::color(context, "mail.listing.compact.unseen_bg"),
+ )
+ } else if idx % 2 == 0 {
+ (
+ crate::conf::color(context, "mail.listing.compact.even_fg"),
+ crate::conf::color(context, "mail.listing.compact.even_bg"),
+ )
} else {
- if thread.unseen() > 0 {
- Color::Byte(251)
- } else if idx % 2 == 0 {
- Color::Byte(236)
- } else {
- Color::Default
- }
+ (
+ crate::conf::color(context, "mail.listing.compact.odd_fg"),
+ crate::conf::color(context, "mail.listing.compact.odd_bg"),
+ )
};
let (x, _) = write_string_to_grid(
&idx.to_string(),
@@ -921,14 +908,26 @@ impl CompactListing {
}
match (thread.snoozed(), thread.has_attachments()) {
(true, true) => {
- self.data_columns.columns[3][(0, idx)].set_fg(Color::Byte(103));
- self.data_columns.columns[3][(2, idx)].set_fg(Color::Red);
+ self.data_columns.columns[3][(0, idx)].set_fg(crate::conf::color(
+ context,
+ "mail.listing.attachment_flag_fg",
+ ));
+ self.data_columns.columns[3][(2, idx)].set_fg(crate::conf::color(
+ context,
+ "mail.listing.thread_snooze_flag_fg",
+ ));
}
(true, false) => {
- self.data_columns.columns[3][(0, idx)].set_fg(Color::Red);
+ self.data_columns.columns[3][(0, idx)].set_fg(crate::conf::color(
+ context,
+ "mail.listing.thread_snooze_flag_fg",
+ ));
}
(false, true) => {
- self.data_columns.columns[3][(0, idx)].set_fg(Color::Byte(103));
+ self.data_columns.columns[3][(0, idx)].set_fg(crate::conf::color(
+ context,
+ "mail.listing.attachment_flag_fg",
+ ));
}
(false, false) => {}
}
@@ -981,30 +980,24 @@ impl CompactListing {
* arrive */
return;
}
- let envelope: EnvelopeRef = account.collection.get_env(env_hash);
- let fg_color = if thread.unseen() > 0 {
- Color::Byte(0)
- } else {
- Color::Default
- };
let idx = self.order[&thread_hash];
- let bg_color = if context.settings.terminal.theme == "light" {
- if thread.unseen() > 0 {
- Color::Byte(251)
- } else if idx % 2 == 0 {
- Color::Byte(252)
- } else {
- Color::Default
- }
+ let (fg_color, bg_color) = if thread.unseen() > 0 {
+ (
+ crate::conf::color(context, "mail.listing.compact.unseen_fg"),
+ crate::conf::color(context, "mail.listing.compact.unseen_bg"),
+ )
+ } else if idx % 2 == 0 {
+ (
+ crate::conf::color(context, "mail.listing.compact.even_fg"),
+ crate::conf::color(context, "mail.listing.compact.even_bg"),
+ )
} else {
- if thread.unseen() > 0 {
- Color::Byte(253)
- } else if idx % 2 == 0 {
- Color::Byte(236)
- } else {
- Color::Default
- }
+ (
+ crate::conf::color(context, "mail.listing.compact.odd_fg"),
+ crate::conf::color(context, "mail.listing.compact.odd_bg"),
+ )
};
+ let envelope: EnvelopeRef = account.collection.get_env(env_hash);
let strings = self.make_entry_string(&envelope, context, threads, thread_hash);
drop(envelope);
let columns = &mut self.data_columns.columns;
@@ -1108,14 +1101,26 @@ impl CompactListing {
}
match (thread.snoozed(), thread.has_attachments()) {
(true, true) => {
- columns[3][(0, idx)].set_fg(Color::Byte(103));
- columns[3][(2, idx)].set_fg(Color::Red);
+ columns[3][(0, idx)].set_fg(crate::conf::color(
+ context,
+ "mail.listing.attachment_flag_fg",
+ ));
+ columns[3][(2, idx)].set_fg(crate::conf::color(
+ context,
+ "mail.listing.thread_snooze_flag_fg",
+ ));
}
(true, false) => {
- columns[3][(0, idx)].set_fg(Color::Red);
+ columns[3][(0, idx)].set_fg(crate::conf::color(
+ context,
+ "mail.listing.thread_snooze_flag_fg",
+ ));
}
(false, true) => {
- columns[3][(0, idx)].set_fg(Color::Byte(103));
+ columns[3][(0, idx)].set_fg(crate::conf::color(
+ context,
+ "mail.listing.attachment_flag_fg",
+ ));
}
(false, false) => {}
}