ui: improve theming coverage
parent
9b7875c023
commit
eef007600b
|
@ -141,12 +141,15 @@ impl fmt::Display for Composer {
|
||||||
|
|
||||||
impl Composer {
|
impl Composer {
|
||||||
const DESCRIPTION: &'static str = "composing";
|
const DESCRIPTION: &'static str = "composing";
|
||||||
pub fn new(account_cursor: usize) -> Self {
|
pub fn new(account_cursor: usize, context: &Context) -> Self {
|
||||||
Composer {
|
let mut ret = Composer {
|
||||||
account_cursor,
|
account_cursor,
|
||||||
id: ComponentId::new_v4(),
|
id: ComponentId::new_v4(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
};
|
||||||
|
ret.pager
|
||||||
|
.set_colors(crate::conf::value(context, "theme_default"));
|
||||||
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn edit(account_pos: usize, h: EnvelopeHash, context: &Context) -> Result<Self> {
|
pub fn edit(account_pos: usize, h: EnvelopeHash, context: &Context) -> Result<Self> {
|
||||||
|
@ -167,6 +170,8 @@ impl Composer {
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let account = &context.accounts[coordinates.0];
|
let account = &context.accounts[coordinates.0];
|
||||||
let mut ret = Composer::default();
|
let mut ret = Composer::default();
|
||||||
|
ret.pager
|
||||||
|
.set_colors(crate::conf::value(context, "theme_default"));
|
||||||
let parent_message = account.collection.get_env(msg);
|
let parent_message = account.collection.get_env(msg);
|
||||||
/* If message is from a mailing list and we detect a List-Post header, ask user if they
|
/* If message is from a mailing list and we detect a List-Post header, ask user if they
|
||||||
* want to reply to the mailing list or the submitter of the message */
|
* want to reply to the mailing list or the submitter of the message */
|
||||||
|
|
|
@ -611,9 +611,9 @@ impl ListingTrait for CompactListing {
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
&message,
|
&message,
|
||||||
&mut self.data_columns.columns[0],
|
&mut self.data_columns.columns[0],
|
||||||
Color::Default,
|
self.color_cache.theme_default.fg,
|
||||||
Color::Default,
|
self.color_cache.theme_default.bg,
|
||||||
Attr::Default,
|
self.color_cache.theme_default.attrs,
|
||||||
((0, 0), (message.len() - 1, 0)),
|
((0, 0), (message.len() - 1, 0)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -763,7 +763,6 @@ impl CompactListing {
|
||||||
);
|
);
|
||||||
|
|
||||||
for (idx, thread) in items.enumerate() {
|
for (idx, thread) in items.enumerate() {
|
||||||
debug!(thread);
|
|
||||||
self.length += 1;
|
self.length += 1;
|
||||||
let thread_node = &threads.thread_nodes()[&threads.thread_ref(thread).root()];
|
let thread_node = &threads.thread_nodes()[&threads.thread_ref(thread).root()];
|
||||||
let root_env_hash = thread_node.message().unwrap_or_else(|| {
|
let root_env_hash = thread_node.message().unwrap_or_else(|| {
|
||||||
|
@ -870,67 +869,75 @@ impl CompactListing {
|
||||||
panic!();
|
panic!();
|
||||||
}
|
}
|
||||||
let thread = threads.thread_ref(thread);
|
let thread = threads.thread_ref(thread);
|
||||||
let (fg_color, bg_color) = if thread.unseen() > 0 {
|
let row_attr = if thread.unseen() > 0 {
|
||||||
(self.color_cache.unseen.fg, self.color_cache.unseen.bg)
|
self.color_cache.unseen
|
||||||
} else if idx % 2 == 0 {
|
} else if idx % 2 == 0 {
|
||||||
(self.color_cache.even.fg, self.color_cache.even.bg)
|
self.color_cache.even
|
||||||
} else {
|
} else {
|
||||||
(self.color_cache.odd.fg, self.color_cache.odd.bg)
|
self.color_cache.odd
|
||||||
};
|
};
|
||||||
let (x, _) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
&idx.to_string(),
|
&idx.to_string(),
|
||||||
&mut self.data_columns.columns[0],
|
&mut self.data_columns.columns[0],
|
||||||
fg_color,
|
row_attr.fg,
|
||||||
bg_color,
|
row_attr.bg,
|
||||||
Attr::Default,
|
row_attr.attrs,
|
||||||
((0, idx), (min_width.0, idx)),
|
((0, idx), (min_width.0, idx)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
for x in x..min_width.0 {
|
for x in x..min_width.0 {
|
||||||
self.data_columns.columns[0][(x, idx)].set_bg(bg_color);
|
self.data_columns.columns[0][(x, idx)]
|
||||||
|
.set_bg(row_attr.bg)
|
||||||
|
.set_attrs(row_attr.attrs);
|
||||||
}
|
}
|
||||||
let (x, _) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
&strings.date,
|
&strings.date,
|
||||||
&mut self.data_columns.columns[1],
|
&mut self.data_columns.columns[1],
|
||||||
fg_color,
|
row_attr.fg,
|
||||||
bg_color,
|
row_attr.bg,
|
||||||
Attr::Default,
|
row_attr.attrs,
|
||||||
((0, idx), (min_width.1, idx)),
|
((0, idx), (min_width.1, idx)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
for x in x..min_width.1 {
|
for x in x..min_width.1 {
|
||||||
self.data_columns.columns[1][(x, idx)].set_bg(bg_color);
|
self.data_columns.columns[1][(x, idx)]
|
||||||
|
.set_bg(row_attr.bg)
|
||||||
|
.set_attrs(row_attr.attrs);
|
||||||
}
|
}
|
||||||
let (x, _) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
&strings.from,
|
&strings.from,
|
||||||
&mut self.data_columns.columns[2],
|
&mut self.data_columns.columns[2],
|
||||||
fg_color,
|
row_attr.fg,
|
||||||
bg_color,
|
row_attr.bg,
|
||||||
Attr::Default,
|
row_attr.attrs,
|
||||||
((0, idx), (min_width.2, idx)),
|
((0, idx), (min_width.2, idx)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
for x in x..min_width.2 {
|
for x in x..min_width.2 {
|
||||||
self.data_columns.columns[2][(x, idx)].set_bg(bg_color);
|
self.data_columns.columns[2][(x, idx)]
|
||||||
|
.set_bg(row_attr.bg)
|
||||||
|
.set_attrs(row_attr.attrs);
|
||||||
}
|
}
|
||||||
let (x, _) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
&strings.flag,
|
&strings.flag,
|
||||||
&mut self.data_columns.columns[3],
|
&mut self.data_columns.columns[3],
|
||||||
fg_color,
|
row_attr.fg,
|
||||||
bg_color,
|
row_attr.bg,
|
||||||
Attr::Default,
|
row_attr.attrs,
|
||||||
((0, idx), (min_width.3, idx)),
|
((0, idx), (min_width.3, idx)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
for x in x..min_width.3 {
|
for x in x..min_width.3 {
|
||||||
self.data_columns.columns[3][(x, idx)].set_bg(bg_color);
|
self.data_columns.columns[3][(x, idx)]
|
||||||
|
.set_bg(row_attr.bg)
|
||||||
|
.set_attrs(row_attr.attrs);
|
||||||
}
|
}
|
||||||
let (x, _) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
&strings.subject,
|
&strings.subject,
|
||||||
&mut self.data_columns.columns[4],
|
&mut self.data_columns.columns[4],
|
||||||
fg_color,
|
row_attr.fg,
|
||||||
bg_color,
|
row_attr.bg,
|
||||||
Attr::Default,
|
row_attr.attrs,
|
||||||
((0, idx), (min_width.4, idx)),
|
((0, idx), (min_width.4, idx)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -961,8 +968,10 @@ impl CompactListing {
|
||||||
x
|
x
|
||||||
};
|
};
|
||||||
for x in x..min_width.4 {
|
for x in x..min_width.4 {
|
||||||
self.data_columns.columns[4][(x, idx)].set_ch(' ');
|
self.data_columns.columns[4][(x, idx)]
|
||||||
self.data_columns.columns[4][(x, idx)].set_bg(bg_color);
|
.set_ch(' ')
|
||||||
|
.set_bg(row_attr.bg)
|
||||||
|
.set_attrs(row_attr.attrs);
|
||||||
}
|
}
|
||||||
match (thread.snoozed(), thread.has_attachments()) {
|
match (thread.snoozed(), thread.has_attachments()) {
|
||||||
(true, true) => {
|
(true, true) => {
|
||||||
|
@ -1169,9 +1178,9 @@ impl Component for CompactListing {
|
||||||
self.filter_term
|
self.filter_term
|
||||||
),
|
),
|
||||||
grid,
|
grid,
|
||||||
Color::Default,
|
self.color_cache.theme_default.fg,
|
||||||
Color::Default,
|
self.color_cache.theme_default.bg,
|
||||||
Attr::Default,
|
self.color_cache.theme_default.attrs,
|
||||||
area,
|
area,
|
||||||
Some(get_x(upper_left)),
|
Some(get_x(upper_left)),
|
||||||
);
|
);
|
||||||
|
|
|
@ -133,17 +133,24 @@ impl MailListingTrait for ConversationsListing {
|
||||||
match context.accounts[self.cursor_pos.0].status(self.folder_hash) {
|
match context.accounts[self.cursor_pos.0].status(self.folder_hash) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
let default_cell = {
|
||||||
|
let mut ret = Cell::with_char(' ');
|
||||||
|
ret.set_fg(self.color_cache.theme_default.fg)
|
||||||
|
.set_bg(self.color_cache.theme_default.bg)
|
||||||
|
.set_attrs(self.color_cache.theme_default.attrs);
|
||||||
|
ret
|
||||||
|
};
|
||||||
let message: String =
|
let message: String =
|
||||||
context.accounts[self.cursor_pos.0][self.folder_hash].to_string();
|
context.accounts[self.cursor_pos.0][self.folder_hash].to_string();
|
||||||
self.content =
|
self.content =
|
||||||
CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context);
|
CellBuffer::new_with_context(message.len(), 1, default_cell, context);
|
||||||
self.length = 0;
|
self.length = 0;
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
message.as_str(),
|
message.as_str(),
|
||||||
&mut self.content,
|
&mut self.content,
|
||||||
Color::Default,
|
self.color_cache.theme_default.fg,
|
||||||
Color::Default,
|
self.color_cache.theme_default.bg,
|
||||||
Attr::Default,
|
self.color_cache.theme_default.attrs,
|
||||||
((0, 0), (message.len() - 1, 0)),
|
((0, 0), (message.len() - 1, 0)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -421,12 +428,14 @@ impl ListingTrait for ConversationsListing {
|
||||||
let bg_color = grid[(get_x(upper_left) + width - 1, y_offset + 3 * y)].bg();
|
let bg_color = grid[(get_x(upper_left) + width - 1, y_offset + 3 * y)].bg();
|
||||||
for x in (get_x(upper_left) + width)..=get_x(bottom_right) {
|
for x in (get_x(upper_left) + width)..=get_x(bottom_right) {
|
||||||
grid[(x, y_offset + 3 * y)].set_bg(bg_color);
|
grid[(x, y_offset + 3 * y)].set_bg(bg_color);
|
||||||
grid[(x, y_offset + 3 * y + 1)].set_ch('▁');
|
grid[(x, y_offset + 3 * y + 1)]
|
||||||
grid[(x, y_offset + 3 * y + 2)].set_fg(Color::Default);
|
.set_ch('▁')
|
||||||
grid[(x, y_offset + 3 * y + 1)].set_bg(bg_color);
|
.set_fg(self.color_cache.theme_default.fg)
|
||||||
grid[(x, y_offset + 3 * y + 2)].set_ch('▓');
|
.set_bg(bg_color);
|
||||||
grid[(x, y_offset + 3 * y + 2)].set_fg(padding_fg);
|
grid[(x, y_offset + 3 * y + 2)]
|
||||||
grid[(x, y_offset + 3 * y + 2)].set_bg(bg_color);
|
.set_ch('▓')
|
||||||
|
.set_fg(padding_fg)
|
||||||
|
.set_bg(bg_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if pad > 0 {
|
if pad > 0 {
|
||||||
|
@ -437,10 +446,10 @@ impl ListingTrait for ConversationsListing {
|
||||||
grid[(x, y_offset + y + 1)].set_ch('▁');
|
grid[(x, y_offset + y + 1)].set_ch('▁');
|
||||||
grid[(x, y_offset + y + 1)].set_bg(bg_color);
|
grid[(x, y_offset + y + 1)].set_bg(bg_color);
|
||||||
if pad == 2 {
|
if pad == 2 {
|
||||||
grid[(x, y_offset + y + 2)].set_fg(Color::Default);
|
grid[(x, y_offset + y + 2)]
|
||||||
grid[(x, y_offset + y + 2)].set_ch('▓');
|
.set_ch('▓')
|
||||||
grid[(x, y_offset + y + 2)].set_fg(padding_fg);
|
.set_fg(padding_fg)
|
||||||
grid[(x, y_offset + y + 2)].set_bg(bg_color);
|
.set_bg(bg_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -497,8 +506,14 @@ impl ListingTrait for ConversationsListing {
|
||||||
self.new_cursor_pos.2 =
|
self.new_cursor_pos.2 =
|
||||||
std::cmp::min(self.filtered_selection.len() - 1, self.cursor_pos.2);
|
std::cmp::min(self.filtered_selection.len() - 1, self.cursor_pos.2);
|
||||||
} else {
|
} else {
|
||||||
self.content =
|
let default_cell = {
|
||||||
CellBuffer::new_with_context(0, 0, Cell::with_char(' '), context);
|
let mut ret = Cell::with_char(' ');
|
||||||
|
ret.set_fg(self.color_cache.theme_default.fg)
|
||||||
|
.set_bg(self.color_cache.theme_default.bg)
|
||||||
|
.set_attrs(self.color_cache.theme_default.attrs);
|
||||||
|
ret
|
||||||
|
};
|
||||||
|
self.content = CellBuffer::new_with_context(0, 0, default_cell, context);
|
||||||
}
|
}
|
||||||
self.redraw_list(
|
self.redraw_list(
|
||||||
context,
|
context,
|
||||||
|
@ -517,14 +532,21 @@ impl ListingTrait for ConversationsListing {
|
||||||
format!("Failed to search for term {}: {}", self.filter_term, e),
|
format!("Failed to search for term {}: {}", self.filter_term, e),
|
||||||
ERROR,
|
ERROR,
|
||||||
);
|
);
|
||||||
|
let default_cell = {
|
||||||
|
let mut ret = Cell::with_char(' ');
|
||||||
|
ret.set_fg(self.color_cache.theme_default.fg)
|
||||||
|
.set_bg(self.color_cache.theme_default.bg)
|
||||||
|
.set_attrs(self.color_cache.theme_default.attrs);
|
||||||
|
ret
|
||||||
|
};
|
||||||
self.content =
|
self.content =
|
||||||
CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context);
|
CellBuffer::new_with_context(message.len(), 1, default_cell, context);
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
&message,
|
&message,
|
||||||
&mut self.content,
|
&mut self.content,
|
||||||
Color::Default,
|
self.color_cache.theme_default.fg,
|
||||||
Color::Default,
|
self.color_cache.theme_default.bg,
|
||||||
Attr::Default,
|
self.color_cache.theme_default.attrs,
|
||||||
((0, 0), (message.len() - 1, 0)),
|
((0, 0), (message.len() - 1, 0)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -839,16 +861,22 @@ impl ConversationsListing {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if self.length == 0 && self.filter_term.is_empty() {
|
if self.length == 0 && self.filter_term.is_empty() {
|
||||||
|
let default_cell = {
|
||||||
|
let mut ret = Cell::with_char(' ');
|
||||||
|
ret.set_fg(self.color_cache.theme_default.fg)
|
||||||
|
.set_bg(self.color_cache.theme_default.bg)
|
||||||
|
.set_attrs(self.color_cache.theme_default.attrs);
|
||||||
|
ret
|
||||||
|
};
|
||||||
let mailbox = &account[self.cursor_pos.1];
|
let mailbox = &account[self.cursor_pos.1];
|
||||||
let message = mailbox.to_string();
|
let message = mailbox.to_string();
|
||||||
self.content =
|
self.content = CellBuffer::new_with_context(message.len(), 1, default_cell, context);
|
||||||
CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context);
|
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
&message,
|
&message,
|
||||||
&mut self.content,
|
&mut self.content,
|
||||||
Color::Default,
|
self.color_cache.theme_default.fg,
|
||||||
Color::Default,
|
self.color_cache.theme_default.bg,
|
||||||
Attr::Default,
|
self.color_cache.theme_default.attrs,
|
||||||
((0, 0), (message.len() - 1, 0)),
|
((0, 0), (message.len() - 1, 0)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -1077,9 +1105,9 @@ impl Component for ConversationsListing {
|
||||||
self.filter_term
|
self.filter_term
|
||||||
),
|
),
|
||||||
grid,
|
grid,
|
||||||
Color::Default,
|
self.color_cache.theme_default.fg,
|
||||||
Color::Default,
|
self.color_cache.theme_default.bg,
|
||||||
Attr::Default,
|
self.color_cache.theme_default.attrs,
|
||||||
area,
|
area,
|
||||||
Some(get_x(upper_left)),
|
Some(get_x(upper_left)),
|
||||||
);
|
);
|
||||||
|
|
|
@ -148,17 +148,24 @@ impl MailListingTrait for PlainListing {
|
||||||
match context.accounts[self.cursor_pos.0].status(self.folder_hash) {
|
match context.accounts[self.cursor_pos.0].status(self.folder_hash) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
let default_cell = {
|
||||||
|
let mut ret = Cell::with_char(' ');
|
||||||
|
ret.set_fg(self.color_cache.theme_default.fg)
|
||||||
|
.set_bg(self.color_cache.theme_default.bg)
|
||||||
|
.set_attrs(self.color_cache.theme_default.attrs);
|
||||||
|
ret
|
||||||
|
};
|
||||||
let message: String =
|
let message: String =
|
||||||
context.accounts[self.cursor_pos.0][self.folder_hash].to_string();
|
context.accounts[self.cursor_pos.0][self.folder_hash].to_string();
|
||||||
self.data_columns.columns[0] =
|
self.data_columns.columns[0] =
|
||||||
CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context);
|
CellBuffer::new_with_context(message.len(), 1, default_cell, context);
|
||||||
self.length = 0;
|
self.length = 0;
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
message.as_str(),
|
message.as_str(),
|
||||||
&mut self.data_columns.columns[0],
|
&mut self.data_columns.columns[0],
|
||||||
Color::Default,
|
self.color_cache.theme_default.fg,
|
||||||
Color::Default,
|
self.color_cache.theme_default.bg,
|
||||||
Attr::Default,
|
self.color_cache.theme_default.attrs,
|
||||||
((0, 0), (MAX_COLS - 1, 0)),
|
((0, 0), (MAX_COLS - 1, 0)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -535,8 +542,15 @@ impl ListingTrait for PlainListing {
|
||||||
self.new_cursor_pos.2 =
|
self.new_cursor_pos.2 =
|
||||||
std::cmp::min(self.filtered_selection.len() - 1, self.cursor_pos.2);
|
std::cmp::min(self.filtered_selection.len() - 1, self.cursor_pos.2);
|
||||||
} else {
|
} else {
|
||||||
|
let default_cell = {
|
||||||
|
let mut ret = Cell::with_char(' ');
|
||||||
|
ret.set_fg(self.color_cache.theme_default.fg)
|
||||||
|
.set_bg(self.color_cache.theme_default.bg)
|
||||||
|
.set_attrs(self.color_cache.theme_default.attrs);
|
||||||
|
ret
|
||||||
|
};
|
||||||
self.data_columns.columns[0] =
|
self.data_columns.columns[0] =
|
||||||
CellBuffer::new_with_context(0, 0, Cell::with_char(' '), context);
|
CellBuffer::new_with_context(0, 0, default_cell, context);
|
||||||
}
|
}
|
||||||
self.redraw_list(context);
|
self.redraw_list(context);
|
||||||
}
|
}
|
||||||
|
@ -551,14 +565,21 @@ impl ListingTrait for PlainListing {
|
||||||
format!("Failed to search for term {}: {}", &self.filter_term, e),
|
format!("Failed to search for term {}: {}", &self.filter_term, e),
|
||||||
ERROR,
|
ERROR,
|
||||||
);
|
);
|
||||||
|
let default_cell = {
|
||||||
|
let mut ret = Cell::with_char(' ');
|
||||||
|
ret.set_fg(self.color_cache.theme_default.fg)
|
||||||
|
.set_bg(self.color_cache.theme_default.bg)
|
||||||
|
.set_attrs(self.color_cache.theme_default.attrs);
|
||||||
|
ret
|
||||||
|
};
|
||||||
self.data_columns.columns[0] =
|
self.data_columns.columns[0] =
|
||||||
CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context);
|
CellBuffer::new_with_context(message.len(), 1, default_cell, context);
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
&message,
|
&message,
|
||||||
&mut self.data_columns.columns[0],
|
&mut self.data_columns.columns[0],
|
||||||
Color::Default,
|
self.color_cache.theme_default.fg,
|
||||||
Color::Default,
|
self.color_cache.theme_default.bg,
|
||||||
Attr::Default,
|
self.color_cache.theme_default.attrs,
|
||||||
((0, 0), (message.len() - 1, 0)),
|
((0, 0), (message.len() - 1, 0)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -740,21 +761,28 @@ impl PlainListing {
|
||||||
|
|
||||||
min_width.0 = self.length.saturating_sub(1).to_string().len();
|
min_width.0 = self.length.saturating_sub(1).to_string().len();
|
||||||
|
|
||||||
|
let default_cell = {
|
||||||
|
let mut ret = Cell::with_char(' ');
|
||||||
|
ret.set_fg(self.color_cache.theme_default.fg)
|
||||||
|
.set_bg(self.color_cache.theme_default.bg)
|
||||||
|
.set_attrs(self.color_cache.theme_default.attrs);
|
||||||
|
ret
|
||||||
|
};
|
||||||
/* index column */
|
/* index column */
|
||||||
self.data_columns.columns[0] =
|
self.data_columns.columns[0] =
|
||||||
CellBuffer::new_with_context(min_width.0, rows.len(), Cell::with_char(' '), context);
|
CellBuffer::new_with_context(min_width.0, rows.len(), default_cell, context);
|
||||||
/* date column */
|
/* date column */
|
||||||
self.data_columns.columns[1] =
|
self.data_columns.columns[1] =
|
||||||
CellBuffer::new_with_context(min_width.1, rows.len(), Cell::with_char(' '), context);
|
CellBuffer::new_with_context(min_width.1, rows.len(), default_cell, context);
|
||||||
/* from column */
|
/* from column */
|
||||||
self.data_columns.columns[2] =
|
self.data_columns.columns[2] =
|
||||||
CellBuffer::new_with_context(min_width.2, rows.len(), Cell::with_char(' '), context);
|
CellBuffer::new_with_context(min_width.2, rows.len(), default_cell, context);
|
||||||
/* flags column */
|
/* flags column */
|
||||||
self.data_columns.columns[3] =
|
self.data_columns.columns[3] =
|
||||||
CellBuffer::new_with_context(min_width.3, rows.len(), Cell::with_char(' '), context);
|
CellBuffer::new_with_context(min_width.3, rows.len(), default_cell, context);
|
||||||
/* subject column */
|
/* subject column */
|
||||||
self.data_columns.columns[4] =
|
self.data_columns.columns[4] =
|
||||||
CellBuffer::new_with_context(min_width.4, rows.len(), Cell::with_char(' '), context);
|
CellBuffer::new_with_context(min_width.4, rows.len(), default_cell, context);
|
||||||
|
|
||||||
let iter = if self.filter_term.is_empty() {
|
let iter = if self.filter_term.is_empty() {
|
||||||
Box::new(self.local_collection.iter().cloned())
|
Box::new(self.local_collection.iter().cloned())
|
||||||
|
@ -779,82 +807,67 @@ impl PlainListing {
|
||||||
}
|
}
|
||||||
|
|
||||||
let envelope: EnvelopeRef = context.accounts[self.cursor_pos.0].collection.get_env(i);
|
let envelope: EnvelopeRef = context.accounts[self.cursor_pos.0].collection.get_env(i);
|
||||||
let fg_color = if !envelope.is_seen() {
|
let row_attr = if !envelope.is_seen() {
|
||||||
Color::Byte(0)
|
self.color_cache.unseen
|
||||||
|
} else if idx % 2 == 0 {
|
||||||
|
self.color_cache.even
|
||||||
} else {
|
} else {
|
||||||
Color::Default
|
self.color_cache.odd
|
||||||
};
|
|
||||||
let bg_color = if context.settings.terminal.theme == "light" {
|
|
||||||
if !envelope.is_seen() {
|
|
||||||
Color::Byte(251)
|
|
||||||
} else if idx % 2 == 0 {
|
|
||||||
Color::Byte(252)
|
|
||||||
} else {
|
|
||||||
Color::Default
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if !envelope.is_seen() {
|
|
||||||
Color::Byte(253)
|
|
||||||
} else if idx % 2 == 0 {
|
|
||||||
Color::Byte(236)
|
|
||||||
} else {
|
|
||||||
Color::Default
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let (x, _) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
&idx.to_string(),
|
&idx.to_string(),
|
||||||
&mut columns[0],
|
&mut columns[0],
|
||||||
fg_color,
|
row_attr.fg,
|
||||||
bg_color,
|
row_attr.bg,
|
||||||
Attr::Default,
|
row_attr.attrs,
|
||||||
((0, idx), (min_width.0, idx)),
|
((0, idx), (min_width.0, idx)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
for c in columns[0].row_iter(x..min_width.0, idx) {
|
for c in columns[0].row_iter(x..min_width.0, idx) {
|
||||||
columns[0][c].set_bg(bg_color);
|
columns[0][c].set_bg(row_attr.bg).set_attrs(row_attr.attrs);
|
||||||
}
|
}
|
||||||
let (x, _) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
&strings.date,
|
&strings.date,
|
||||||
&mut columns[1],
|
&mut columns[1],
|
||||||
fg_color,
|
row_attr.fg,
|
||||||
bg_color,
|
row_attr.bg,
|
||||||
Attr::Default,
|
row_attr.attrs,
|
||||||
((0, idx), (min_width.1, idx)),
|
((0, idx), (min_width.1, idx)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
for c in columns[1].row_iter(x..min_width.1, idx) {
|
for c in columns[1].row_iter(x..min_width.1, idx) {
|
||||||
columns[1][c].set_bg(bg_color);
|
columns[1][c].set_bg(row_attr.bg).set_attrs(row_attr.attrs);
|
||||||
}
|
}
|
||||||
let (x, _) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
&strings.from,
|
&strings.from,
|
||||||
&mut columns[2],
|
&mut columns[2],
|
||||||
fg_color,
|
row_attr.fg,
|
||||||
bg_color,
|
row_attr.bg,
|
||||||
Attr::Default,
|
row_attr.attrs,
|
||||||
((0, idx), (min_width.2, idx)),
|
((0, idx), (min_width.2, idx)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
for c in columns[2].row_iter(x..min_width.2, idx) {
|
for c in columns[2].row_iter(x..min_width.2, idx) {
|
||||||
columns[2][c].set_bg(bg_color);
|
columns[2][c].set_bg(row_attr.bg).set_attrs(row_attr.attrs);
|
||||||
}
|
}
|
||||||
let (x, _) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
&strings.flag,
|
&strings.flag,
|
||||||
&mut columns[3],
|
&mut columns[3],
|
||||||
fg_color,
|
row_attr.fg,
|
||||||
bg_color,
|
row_attr.bg,
|
||||||
Attr::Default,
|
row_attr.attrs,
|
||||||
((0, idx), (min_width.3, idx)),
|
((0, idx), (min_width.3, idx)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
for c in columns[3].row_iter(x..min_width.3, idx) {
|
for c in columns[3].row_iter(x..min_width.3, idx) {
|
||||||
columns[3][c].set_bg(bg_color);
|
columns[3][c].set_bg(row_attr.bg).set_attrs(row_attr.attrs);
|
||||||
}
|
}
|
||||||
let (x, _) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
&strings.subject,
|
&strings.subject,
|
||||||
&mut columns[4],
|
&mut columns[4],
|
||||||
fg_color,
|
row_attr.fg,
|
||||||
bg_color,
|
row_attr.bg,
|
||||||
Attr::Default,
|
row_attr.attrs,
|
||||||
((0, idx), (min_width.4, idx)),
|
((0, idx), (min_width.4, idx)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -874,12 +887,10 @@ impl PlainListing {
|
||||||
columns[4][c].set_bg(color);
|
columns[4][c].set_bg(color);
|
||||||
}
|
}
|
||||||
for c in columns[4].row_iter(_x..(_x + 1), idx) {
|
for c in columns[4].row_iter(_x..(_x + 1), idx) {
|
||||||
columns[4][c].set_bg(color);
|
columns[4][c].set_bg(color).set_keep_bg(true);
|
||||||
columns[4][c].set_keep_bg(true);
|
|
||||||
}
|
}
|
||||||
for c in columns[4].row_iter((x + 1)..(_x + 1), idx) {
|
for c in columns[4].row_iter((x + 1)..(_x + 1), idx) {
|
||||||
columns[4][c].set_keep_fg(true);
|
columns[4][c].set_keep_fg(true).set_keep_bg(true);
|
||||||
columns[4][c].set_keep_bg(true);
|
|
||||||
}
|
}
|
||||||
for c in columns[4].row_iter(x..(x + 1), idx) {
|
for c in columns[4].row_iter(x..(x + 1), idx) {
|
||||||
columns[4][c].set_keep_bg(true);
|
columns[4][c].set_keep_bg(true);
|
||||||
|
@ -889,7 +900,7 @@ impl PlainListing {
|
||||||
x
|
x
|
||||||
};
|
};
|
||||||
for c in columns[4].row_iter(x..min_width.4, idx) {
|
for c in columns[4].row_iter(x..min_width.4, idx) {
|
||||||
columns[4][c].set_bg(bg_color);
|
columns[4][c].set_bg(row_attr.bg).set_attrs(row_attr.attrs);
|
||||||
}
|
}
|
||||||
if context.accounts[self.cursor_pos.0]
|
if context.accounts[self.cursor_pos.0]
|
||||||
.collection
|
.collection
|
||||||
|
@ -902,18 +913,14 @@ impl PlainListing {
|
||||||
if self.length == 0 && self.filter_term.is_empty() {
|
if self.length == 0 && self.filter_term.is_empty() {
|
||||||
let mailbox = &account[self.cursor_pos.1];
|
let mailbox = &account[self.cursor_pos.1];
|
||||||
let message = mailbox.to_string();
|
let message = mailbox.to_string();
|
||||||
self.data_columns.columns[0] = CellBuffer::new_with_context(
|
self.data_columns.columns[0] =
|
||||||
message.len(),
|
CellBuffer::new_with_context(message.len(), self.length + 1, default_cell, context);
|
||||||
self.length + 1,
|
|
||||||
Cell::with_char(' '),
|
|
||||||
context,
|
|
||||||
);
|
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
&message,
|
&message,
|
||||||
&mut self.data_columns.columns[0],
|
&mut self.data_columns.columns[0],
|
||||||
Color::Default,
|
self.color_cache.theme_default.fg,
|
||||||
Color::Default,
|
self.color_cache.theme_default.bg,
|
||||||
Attr::Default,
|
self.color_cache.theme_default.attrs,
|
||||||
((0, 0), (MAX_COLS - 1, 0)),
|
((0, 0), (MAX_COLS - 1, 0)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
|
@ -81,21 +81,46 @@ impl MailListingTrait for ThreadListing {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.color_cache = ColorCache {
|
||||||
|
unseen: crate::conf::value(context, "mail.listing.plain.unseen"),
|
||||||
|
highlighted: crate::conf::value(context, "mail.listing.plain.highlighted"),
|
||||||
|
even: crate::conf::value(context, "mail.listing.plain.even"),
|
||||||
|
odd: crate::conf::value(context, "mail.listing.plain.odd"),
|
||||||
|
selected: crate::conf::value(context, "mail.listing.plain.selected"),
|
||||||
|
attachment_flag: crate::conf::value(context, "mail.listing.attachment_flag"),
|
||||||
|
thread_snooze_flag: crate::conf::value(context, "mail.listing.thread_snooze_flag"),
|
||||||
|
..self.color_cache
|
||||||
|
};
|
||||||
|
if std::env::var("NO_COLOR").is_ok()
|
||||||
|
&& (context.settings.terminal.use_color.is_false()
|
||||||
|
|| context.settings.terminal.use_color.is_internal())
|
||||||
|
{
|
||||||
|
self.color_cache.highlighted.attrs |= Attr::Reverse;
|
||||||
|
}
|
||||||
|
|
||||||
// Get mailbox as a reference.
|
// Get mailbox as a reference.
|
||||||
//
|
//
|
||||||
match context.accounts[self.cursor_pos.0].status(self.folder_hash) {
|
match context.accounts[self.cursor_pos.0].status(self.folder_hash) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
let default_cell = {
|
||||||
|
let mut ret = Cell::with_char(' ');
|
||||||
|
ret.set_fg(self.color_cache.theme_default.fg)
|
||||||
|
.set_bg(self.color_cache.theme_default.bg)
|
||||||
|
.set_attrs(self.color_cache.theme_default.attrs);
|
||||||
|
ret
|
||||||
|
};
|
||||||
let message: String =
|
let message: String =
|
||||||
context.accounts[self.cursor_pos.0][self.folder_hash].to_string();
|
context.accounts[self.cursor_pos.0][self.cursor_pos.1].to_string();
|
||||||
self.content = CellBuffer::new(message.len(), 1, Cell::with_char(' '));
|
self.content =
|
||||||
|
CellBuffer::new_with_context(message.len(), 1, default_cell, context);
|
||||||
self.length = 0;
|
self.length = 0;
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
message.as_str(),
|
message.as_str(),
|
||||||
&mut self.content,
|
&mut self.content,
|
||||||
Color::Default,
|
self.color_cache.theme_default.fg,
|
||||||
Color::Default,
|
self.color_cache.theme_default.bg,
|
||||||
Attr::Default,
|
self.color_cache.theme_default.attrs,
|
||||||
((0, 0), (MAX_COLS - 1, 0)),
|
((0, 0), (MAX_COLS - 1, 0)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -108,21 +133,29 @@ impl MailListingTrait for ThreadListing {
|
||||||
let threads = &account.collection.threads[&mailbox.folder.hash()];
|
let threads = &account.collection.threads[&mailbox.folder.hash()];
|
||||||
self.length = threads.len();
|
self.length = threads.len();
|
||||||
self.locations.clear();
|
self.locations.clear();
|
||||||
|
let default_cell = {
|
||||||
|
let mut ret = Cell::with_char(' ');
|
||||||
|
ret.set_fg(self.color_cache.theme_default.fg)
|
||||||
|
.set_bg(self.color_cache.theme_default.bg)
|
||||||
|
.set_attrs(self.color_cache.theme_default.attrs);
|
||||||
|
ret
|
||||||
|
};
|
||||||
if self.length == 0 {
|
if self.length == 0 {
|
||||||
let message = format!("Folder `{}` is empty.", mailbox.folder.name());
|
let message = format!("Folder `{}` is empty.", mailbox.folder.name());
|
||||||
self.content = CellBuffer::new(message.len(), 1, Cell::with_char(' '));
|
self.content = CellBuffer::new_with_context(message.len(), 1, default_cell, context);
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
&message,
|
&message,
|
||||||
&mut self.content,
|
&mut self.content,
|
||||||
Color::Default,
|
self.color_cache.theme_default.fg,
|
||||||
Color::Default,
|
self.color_cache.theme_default.bg,
|
||||||
Attr::Default,
|
self.color_cache.theme_default.attrs,
|
||||||
((0, 0), (message.len() - 1, 0)),
|
((0, 0), (message.len() - 1, 0)),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.content = CellBuffer::new(MAX_COLS, self.length + 1, Cell::with_char(' '));
|
self.content =
|
||||||
|
CellBuffer::new_with_context(MAX_COLS, self.length + 1, default_cell, context);
|
||||||
|
|
||||||
let mut indentations: Vec<bool> = Vec::with_capacity(6);
|
let mut indentations: Vec<bool> = Vec::with_capacity(6);
|
||||||
let mut thread_idx = 0; // needed for alternate thread colors
|
let mut thread_idx = 0; // needed for alternate thread colors
|
||||||
|
@ -387,7 +420,7 @@ impl ThreadListing {
|
||||||
length: 0,
|
length: 0,
|
||||||
sort: (Default::default(), Default::default()),
|
sort: (Default::default(), Default::default()),
|
||||||
subsort: (Default::default(), Default::default()),
|
subsort: (Default::default(), Default::default()),
|
||||||
content,
|
content: CellBuffer::new(0, 0, Cell::with_char(' ')),
|
||||||
color_cache: ColorCache::default(),
|
color_cache: ColorCache::default(),
|
||||||
row_updates: SmallVec::new(),
|
row_updates: SmallVec::new(),
|
||||||
locations: Vec::new(),
|
locations: Vec::new(),
|
||||||
|
|
|
@ -305,8 +305,14 @@ impl fmt::Display for Pager {
|
||||||
|
|
||||||
impl Pager {
|
impl Pager {
|
||||||
pub const DESCRIPTION: &'static str = "pager";
|
pub const DESCRIPTION: &'static str = "pager";
|
||||||
pub fn set_reflow(&mut self, new_val: Reflow) {
|
pub fn set_colors(&mut self, new_val: ThemeAttribute) -> &mut Self {
|
||||||
|
self.colors = new_val;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_reflow(&mut self, new_val: Reflow) -> &mut Self {
|
||||||
self.reflow = new_val;
|
self.reflow = new_val;
|
||||||
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reflow(&self) -> Reflow {
|
pub fn reflow(&self) -> Reflow {
|
||||||
|
@ -699,6 +705,7 @@ impl Component for Pager {
|
||||||
fn is_dirty(&self) -> bool {
|
fn is_dirty(&self) -> bool {
|
||||||
self.dirty
|
self.dirty
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_dirty(&mut self, value: bool) {
|
fn set_dirty(&mut self, value: bool) {
|
||||||
self.dirty = value;
|
self.dirty = value;
|
||||||
}
|
}
|
||||||
|
@ -713,6 +720,7 @@ impl Component for Pager {
|
||||||
fn id(&self) -> ComponentId {
|
fn id(&self) -> ComponentId {
|
||||||
self.id
|
self.id
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_id(&mut self, id: ComponentId) {
|
fn set_id(&mut self, id: ComponentId) {
|
||||||
self.id = id;
|
self.id = id;
|
||||||
}
|
}
|
||||||
|
@ -1645,7 +1653,7 @@ impl Component for Tabbed {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
UIEvent::Action(Tab(NewDraft(account_idx, ref draft))) => {
|
UIEvent::Action(Tab(NewDraft(account_idx, ref draft))) => {
|
||||||
let mut composer = Composer::new(account_idx);
|
let mut composer = Composer::new(account_idx, context);
|
||||||
if let Some(draft) = draft {
|
if let Some(draft) = draft {
|
||||||
composer.set_draft(draft.clone());
|
composer.set_draft(draft.clone());
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,13 +133,14 @@ impl Field {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component for Field {
|
impl Component for Field {
|
||||||
fn draw(&mut self, grid: &mut CellBuffer, area: Area, _context: &mut Context) {
|
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||||
|
let theme_attr = crate::conf::value(context, "widgets.form.field");
|
||||||
write_string_to_grid(
|
write_string_to_grid(
|
||||||
self.as_str(),
|
self.as_str(),
|
||||||
grid,
|
grid,
|
||||||
Color::Default,
|
theme_attr.fg,
|
||||||
Color::Default,
|
theme_attr.bg,
|
||||||
Attr::Default,
|
theme_attr.attrs,
|
||||||
area,
|
area,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
@ -388,15 +389,16 @@ impl Component for FormWidget {
|
||||||
let bottom_right = bottom_right!(area);
|
let bottom_right = bottom_right!(area);
|
||||||
|
|
||||||
if self.dirty {
|
if self.dirty {
|
||||||
let label_attrs = crate::conf::value(context, "widgets.form.label");
|
let theme_default = crate::conf::value(context, "theme_default");
|
||||||
clear_area(
|
clear_area(
|
||||||
grid,
|
grid,
|
||||||
(
|
(
|
||||||
upper_left,
|
upper_left,
|
||||||
set_y(bottom_right, get_y(upper_left) + self.layout.len()),
|
set_y(bottom_right, get_y(upper_left) + self.layout.len()),
|
||||||
),
|
),
|
||||||
label_attrs,
|
theme_default,
|
||||||
);
|
);
|
||||||
|
let label_attrs = crate::conf::value(context, "widgets.form.label");
|
||||||
|
|
||||||
for (i, k) in self.layout.iter().enumerate() {
|
for (i, k) in self.layout.iter().enumerate() {
|
||||||
let v = self.fields.get_mut(k).unwrap();
|
let v = self.fields.get_mut(k).unwrap();
|
||||||
|
@ -473,7 +475,7 @@ impl Component for FormWidget {
|
||||||
pos_inc(upper_left, (0, length)),
|
pos_inc(upper_left, (0, length)),
|
||||||
set_y(bottom_right, length + 2 + get_y(upper_left)),
|
set_y(bottom_right, length + 2 + get_y(upper_left)),
|
||||||
),
|
),
|
||||||
label_attrs,
|
theme_default,
|
||||||
);
|
);
|
||||||
if !self.hide_buttons {
|
if !self.hide_buttons {
|
||||||
self.buttons.draw(
|
self.buttons.draw(
|
||||||
|
@ -491,7 +493,7 @@ impl Component for FormWidget {
|
||||||
set_y(upper_left, length + 4 + get_y(upper_left)),
|
set_y(upper_left, length + 4 + get_y(upper_left)),
|
||||||
bottom_right,
|
bottom_right,
|
||||||
),
|
),
|
||||||
label_attrs,
|
theme_default,
|
||||||
);
|
);
|
||||||
self.dirty = false;
|
self.dirty = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue