ui/themes: add status.{bar,notification} and theme_default keys
- theme_default replaces general for all default colors/attributes - add status.{bar,notification} supportmemfd
parent
5dc477bcd5
commit
f15e569627
|
@ -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,
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -143,11 +143,12 @@ fn unlink_attrs<'k, 't: 'k>(
|
|||
}
|
||||
|
||||
const DEFAULT_KEYS: &'static [&'static str] = &[
|
||||
"general",
|
||||
"general.status_bar",
|
||||
"general.tab_focused",
|
||||
"general.tab_unfocused",
|
||||
"general.tab_bar",
|
||||
"theme_default",
|
||||
"status.bar",
|
||||
"status.notification",
|
||||
"tab.focused",
|
||||
"tab.unfocused",
|
||||
"tab.bar",
|
||||
"mail.sidebar",
|
||||
"mail.sidebar_unread_count",
|
||||
"mail.sidebar_index",
|
||||
|
@ -180,7 +181,7 @@ const DEFAULT_KEYS: &'static [&'static str] = &[
|
|||
"mail.listing.thread_snooze_flag",
|
||||
];
|
||||
|
||||
#[derive(Debug, Clone, Default, Copy, Serialize, Deserialize)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Default, Copy, Serialize, Deserialize)]
|
||||
pub struct ThemeAttribute {
|
||||
pub fg: Color,
|
||||
pub bg: Color,
|
||||
|
@ -395,11 +396,13 @@ impl Default for Theme {
|
|||
dark.insert($key.into(), ThemeAttributeInner::default());
|
||||
};
|
||||
}
|
||||
add!("general");
|
||||
add!("general.status_bar");
|
||||
add!("general.tab_focused");
|
||||
add!("general.tab_unfocused");
|
||||
add!("general.tab_bar");
|
||||
add!("theme_default");
|
||||
add!("status.bar", dark = { fg: Color::Byte(123), bg: Color::Byte(26) }, light = { fg: Color::Byte(123), bg: Color::Byte(26) });
|
||||
add!("status.notification", dark = { fg: Color::Byte(219), bg: Color::Byte(88) }, light = { fg: Color::Byte(219), bg: Color::Byte(88) });
|
||||
|
||||
add!("tab.focused");
|
||||
add!("tab.unfocused");
|
||||
add!("tab.bar");
|
||||
|
||||
/* Mail Sidebar */
|
||||
|
||||
|
|
|
@ -366,6 +366,19 @@ impl CellBuffer {
|
|||
RowIterator { row, col: 0..0 }
|
||||
}
|
||||
}
|
||||
|
||||
/// row_iter() but with `RangeFrom`.
|
||||
/// See `RowIterator` documentation.
|
||||
pub fn row_iter_from(&self, bounds: std::ops::RangeFrom<usize>, row: usize) -> RowIterator {
|
||||
if row < self.rows {
|
||||
RowIterator {
|
||||
row,
|
||||
col: std::cmp::min(self.cols.saturating_sub(1), bounds.start)..self.cols,
|
||||
}
|
||||
} else {
|
||||
RowIterator { row, col: 0..0 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for CellBuffer {
|
||||
|
|
Loading…
Reference in New Issue