summaryrefslogtreecommitdiffstats
path: root/ui/src/components
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2020-01-27 17:33:35 +0200
committerManos Pitsidianakis <el13635@mail.ntua.gr>2020-01-27 17:35:13 +0200
commitf15e569627ca7d94b01eecee0a8b2b04dd75d58f (patch)
tree99e9ab5b0f15c9854d4d9c24f95a35f0d41733b8 /ui/src/components
parent5dc477bcd59d22ee8636d51cda8893dd6a1cf429 (diff)
ui/themes: add status.{bar,notification} and theme_default keys
- theme_default replaces general for all default colors/attributes - add status.{bar,notification} support
Diffstat (limited to 'ui/src/components')
-rw-r--r--ui/src/components/mail/listing.rs3
-rw-r--r--ui/src/components/mail/listing/conversations.rs14
-rw-r--r--ui/src/components/utilities.rs29
3 files changed, 27 insertions, 19 deletions
diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs
index 50bd3370..2e58a9f5 100644
--- a/ui/src/components/mail/listing.rs
+++ b/ui/src/components/mail/listing.rs
@@ -46,6 +46,8 @@ pub struct DataColumns {
#[derive(Debug, Default)]
/// Save theme colors to avoid looking them up again and again from settings
struct ColorCache {
+ theme_default: ThemeAttribute,
+
unseen: ThemeAttribute,
highlighted: ThemeAttribute,
even: ThemeAttribute,
@@ -55,7 +57,6 @@ struct ColorCache {
thread_snooze_flag: ThemeAttribute,
/* Conversations */
- general: ThemeAttribute,
subject: ThemeAttribute,
from: ThemeAttribute,
date: ThemeAttribute,
diff --git a/ui/src/components/mail/listing/conversations.rs b/ui/src/components/mail/listing/conversations.rs
index 328e44b7..5fe9b225 100644
--- a/ui/src/components/mail/listing/conversations.rs
+++ b/ui/src/components/mail/listing/conversations.rs
@@ -108,7 +108,7 @@ impl ListingTrait for ConversationsListing {
let fg_color = if thread.unseen() > 0 {
self.color_cache.unseen.fg
} else {
- self.color_cache.general.fg
+ self.color_cache.theme_default.fg
};
let bg_color = if self.cursor_pos.2 == idx {
self.color_cache.highlighted.bg
@@ -117,7 +117,7 @@ impl ListingTrait for ConversationsListing {
} else if thread.unseen() > 0 {
self.color_cache.unseen.bg
} else {
- self.color_cache.general.bg
+ self.color_cache.theme_default.bg
};
copy_area(
@@ -554,7 +554,7 @@ impl ConversationsListing {
};
self.color_cache = ColorCache {
- general: crate::conf::value(context, "mail.listing.conversations"),
+ theme_default: crate::conf::value(context, "mail.listing.conversations"),
subject: crate::conf::value(context, "mail.listing.conversations.subject"),
from: crate::conf::value(context, "mail.listing.conversations.from"),
date: crate::conf::value(context, "mail.listing.conversations.date"),
@@ -706,12 +706,12 @@ impl ConversationsListing {
let fg_color = if thread.unseen() > 0 {
self.color_cache.unseen.fg
} else {
- self.color_cache.general.fg
+ self.color_cache.theme_default.fg
};
let bg_color = if thread.unseen() > 0 {
self.color_cache.unseen.bg
} else {
- self.color_cache.general.bg
+ self.color_cache.theme_default.bg
};
/* draw flags */
let (x, _) = write_string_to_grid(
@@ -884,12 +884,12 @@ impl ConversationsListing {
let fg_color = if thread.unseen() > 0 {
self.color_cache.unseen.fg
} else {
- self.color_cache.general.fg
+ self.color_cache.theme_default.fg
};
let bg_color = if thread.unseen() > 0 {
self.color_cache.unseen.bg
} else {
- self.color_cache.general.bg
+ self.color_cache.theme_default.bg
};
let padding_fg = self.color_cache.padding.fg;
let mut from_address_list = Vec::new();
diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs
index a450278c..f19891a1 100644
--- a/ui/src/components/utilities.rs
+++ b/ui/src/components/utilities.rs
@@ -764,16 +764,23 @@ impl StatusBar {
}
}
fn draw_status_bar(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
- clear_area(grid, area);
+ let attribute = crate::conf::value(context, "status.bar");
let (x, y) = write_string_to_grid(
&self.status,
grid,
- Color::Byte(123),
- Color::Byte(26),
- Attr::Default,
+ attribute.fg,
+ attribute.bg,
+ attribute.attrs,
area,
None,
);
+ for c in grid.row_iter_from(x.., y) {
+ grid[c]
+ .set_ch(' ')
+ .set_fg(attribute.fg)
+ .set_bg(attribute.bg)
+ .set_attrs(attribute.attrs);
+ }
let offset = self.status.find('|').unwrap_or_else(|| self.status.len());
if y < get_y(bottom_right!(area)) + 1 {
for x in get_x(upper_left!(area))
@@ -785,15 +792,16 @@ impl StatusBar {
grid[(x, y)].set_attrs(Attr::Bold);
}
}
+ let noto_colors = crate::conf::value(context, "status.notification");
if self.cur_notification.is_some() {
let (t, n) = self.cur_notification.as_ref().unwrap();
if std::time::Instant::now().duration_since(*t) < std::time::Duration::new(5, 0) {
write_string_to_grid(
n,
grid,
- Color::Byte(219),
- Color::Byte(88),
- Attr::Default,
+ noto_colors.fg,
+ noto_colors.bg,
+ noto_colors.attrs,
(
(std::cmp::max(x, width!(area).saturating_sub(n.len())), y),
bottom_right!(area),
@@ -809,9 +817,9 @@ impl StatusBar {
write_string_to_grid(
&n,
grid,
- Color::Byte(219),
- Color::Byte(88),
- Attr::Default,
+ noto_colors.fg,
+ noto_colors.bg,
+ noto_colors.attrs,
(
(std::cmp::max(x, width!(area).saturating_sub(n.len())), y),
bottom_right!(area),
@@ -831,7 +839,6 @@ impl StatusBar {
}
}
- change_colors(grid, area, Color::Byte(123), Color::Byte(26));
context.dirty_areas.push_back(area);
}