diff --git a/src/components/mail/compose.rs b/src/components/mail/compose.rs index 4965ac222..b1e69ab08 100644 --- a/src/components/mail/compose.rs +++ b/src/components/mail/compose.rs @@ -141,12 +141,15 @@ impl fmt::Display for Composer { impl Composer { const DESCRIPTION: &'static str = "composing"; - pub fn new(account_cursor: usize) -> Self { - Composer { + pub fn new(account_cursor: usize, context: &Context) -> Self { + let mut ret = Composer { account_cursor, id: ComponentId::new_v4(), ..Default::default() - } + }; + ret.pager + .set_colors(crate::conf::value(context, "theme_default")); + ret } pub fn edit(account_pos: usize, h: EnvelopeHash, context: &Context) -> Result { @@ -167,6 +170,8 @@ impl Composer { ) -> Self { let account = &context.accounts[coordinates.0]; let mut ret = Composer::default(); + ret.pager + .set_colors(crate::conf::value(context, "theme_default")); 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 * want to reply to the mailing list or the submitter of the message */ diff --git a/src/components/mail/listing/compact.rs b/src/components/mail/listing/compact.rs index f09f6b4b9..b16199bc6 100644 --- a/src/components/mail/listing/compact.rs +++ b/src/components/mail/listing/compact.rs @@ -611,9 +611,9 @@ impl ListingTrait for CompactListing { write_string_to_grid( &message, &mut self.data_columns.columns[0], - Color::Default, - Color::Default, - Attr::Default, + self.color_cache.theme_default.fg, + self.color_cache.theme_default.bg, + self.color_cache.theme_default.attrs, ((0, 0), (message.len() - 1, 0)), None, ); @@ -763,7 +763,6 @@ impl CompactListing { ); for (idx, thread) in items.enumerate() { - debug!(thread); self.length += 1; let thread_node = &threads.thread_nodes()[&threads.thread_ref(thread).root()]; let root_env_hash = thread_node.message().unwrap_or_else(|| { @@ -870,67 +869,75 @@ impl CompactListing { panic!(); } let thread = threads.thread_ref(thread); - let (fg_color, bg_color) = if thread.unseen() > 0 { - (self.color_cache.unseen.fg, self.color_cache.unseen.bg) + let row_attr = if thread.unseen() > 0 { + self.color_cache.unseen } else if idx % 2 == 0 { - (self.color_cache.even.fg, self.color_cache.even.bg) + self.color_cache.even } else { - (self.color_cache.odd.fg, self.color_cache.odd.bg) + self.color_cache.odd }; let (x, _) = write_string_to_grid( &idx.to_string(), &mut self.data_columns.columns[0], - fg_color, - bg_color, - Attr::Default, + row_attr.fg, + row_attr.bg, + row_attr.attrs, ((0, idx), (min_width.0, idx)), None, ); 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( &strings.date, &mut self.data_columns.columns[1], - fg_color, - bg_color, - Attr::Default, + row_attr.fg, + row_attr.bg, + row_attr.attrs, ((0, idx), (min_width.1, idx)), None, ); 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( &strings.from, &mut self.data_columns.columns[2], - fg_color, - bg_color, - Attr::Default, + row_attr.fg, + row_attr.bg, + row_attr.attrs, ((0, idx), (min_width.2, idx)), None, ); 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( &strings.flag, &mut self.data_columns.columns[3], - fg_color, - bg_color, - Attr::Default, + row_attr.fg, + row_attr.bg, + row_attr.attrs, ((0, idx), (min_width.3, idx)), None, ); 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( &strings.subject, &mut self.data_columns.columns[4], - fg_color, - bg_color, - Attr::Default, + row_attr.fg, + row_attr.bg, + row_attr.attrs, ((0, idx), (min_width.4, idx)), None, ); @@ -961,8 +968,10 @@ impl CompactListing { x }; for x in x..min_width.4 { - self.data_columns.columns[4][(x, idx)].set_ch(' '); - self.data_columns.columns[4][(x, idx)].set_bg(bg_color); + self.data_columns.columns[4][(x, idx)] + .set_ch(' ') + .set_bg(row_attr.bg) + .set_attrs(row_attr.attrs); } match (thread.snoozed(), thread.has_attachments()) { (true, true) => { @@ -1169,9 +1178,9 @@ impl Component for CompactListing { self.filter_term ), grid, - Color::Default, - Color::Default, - Attr::Default, + self.color_cache.theme_default.fg, + self.color_cache.theme_default.bg, + self.color_cache.theme_default.attrs, area, Some(get_x(upper_left)), ); diff --git a/src/components/mail/listing/conversations.rs b/src/components/mail/listing/conversations.rs index b8d136c76..fe10465ea 100644 --- a/src/components/mail/listing/conversations.rs +++ b/src/components/mail/listing/conversations.rs @@ -133,17 +133,24 @@ impl MailListingTrait for ConversationsListing { match context.accounts[self.cursor_pos.0].status(self.folder_hash) { Ok(()) => {} 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 = context.accounts[self.cursor_pos.0][self.folder_hash].to_string(); 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; write_string_to_grid( message.as_str(), &mut self.content, - Color::Default, - Color::Default, - Attr::Default, + self.color_cache.theme_default.fg, + self.color_cache.theme_default.bg, + self.color_cache.theme_default.attrs, ((0, 0), (message.len() - 1, 0)), None, ); @@ -421,12 +428,14 @@ impl ListingTrait for ConversationsListing { 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) { 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 + 2)].set_fg(Color::Default); - grid[(x, y_offset + 3 * y + 1)].set_bg(bg_color); - grid[(x, y_offset + 3 * y + 2)].set_ch('▓'); - grid[(x, y_offset + 3 * y + 2)].set_fg(padding_fg); - grid[(x, y_offset + 3 * y + 2)].set_bg(bg_color); + grid[(x, y_offset + 3 * y + 1)] + .set_ch('▁') + .set_fg(self.color_cache.theme_default.fg) + .set_bg(bg_color); + grid[(x, y_offset + 3 * y + 2)] + .set_ch('▓') + .set_fg(padding_fg) + .set_bg(bg_color); } } 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_bg(bg_color); if pad == 2 { - grid[(x, y_offset + y + 2)].set_fg(Color::Default); - grid[(x, y_offset + y + 2)].set_ch('▓'); - grid[(x, y_offset + y + 2)].set_fg(padding_fg); - grid[(x, y_offset + y + 2)].set_bg(bg_color); + grid[(x, y_offset + y + 2)] + .set_ch('▓') + .set_fg(padding_fg) + .set_bg(bg_color); } } } @@ -497,8 +506,14 @@ impl ListingTrait for ConversationsListing { self.new_cursor_pos.2 = std::cmp::min(self.filtered_selection.len() - 1, self.cursor_pos.2); } else { - self.content = - CellBuffer::new_with_context(0, 0, Cell::with_char(' '), context); + 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 = CellBuffer::new_with_context(0, 0, default_cell, context); } self.redraw_list( context, @@ -517,14 +532,21 @@ impl ListingTrait for ConversationsListing { format!("Failed to search for term {}: {}", self.filter_term, e), 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 = - 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( &message, &mut self.content, - Color::Default, - Color::Default, - Attr::Default, + self.color_cache.theme_default.fg, + self.color_cache.theme_default.bg, + self.color_cache.theme_default.attrs, ((0, 0), (message.len() - 1, 0)), None, ); @@ -839,16 +861,22 @@ impl ConversationsListing { } } 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 message = mailbox.to_string(); - self.content = - CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context); + self.content = CellBuffer::new_with_context(message.len(), 1, default_cell, context); write_string_to_grid( &message, &mut self.content, - Color::Default, - Color::Default, - Attr::Default, + self.color_cache.theme_default.fg, + self.color_cache.theme_default.bg, + self.color_cache.theme_default.attrs, ((0, 0), (message.len() - 1, 0)), None, ); @@ -1077,9 +1105,9 @@ impl Component for ConversationsListing { self.filter_term ), grid, - Color::Default, - Color::Default, - Attr::Default, + self.color_cache.theme_default.fg, + self.color_cache.theme_default.bg, + self.color_cache.theme_default.attrs, area, Some(get_x(upper_left)), ); diff --git a/src/components/mail/listing/plain.rs b/src/components/mail/listing/plain.rs index 561124fbc..9cb3383fb 100644 --- a/src/components/mail/listing/plain.rs +++ b/src/components/mail/listing/plain.rs @@ -148,17 +148,24 @@ impl MailListingTrait for PlainListing { match context.accounts[self.cursor_pos.0].status(self.folder_hash) { Ok(()) => {} 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 = context.accounts[self.cursor_pos.0][self.folder_hash].to_string(); 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; write_string_to_grid( message.as_str(), &mut self.data_columns.columns[0], - Color::Default, - Color::Default, - Attr::Default, + self.color_cache.theme_default.fg, + self.color_cache.theme_default.bg, + self.color_cache.theme_default.attrs, ((0, 0), (MAX_COLS - 1, 0)), None, ); @@ -535,8 +542,15 @@ impl ListingTrait for PlainListing { self.new_cursor_pos.2 = std::cmp::min(self.filtered_selection.len() - 1, self.cursor_pos.2); } 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] = - CellBuffer::new_with_context(0, 0, Cell::with_char(' '), context); + CellBuffer::new_with_context(0, 0, default_cell, context); } self.redraw_list(context); } @@ -551,14 +565,21 @@ impl ListingTrait for PlainListing { format!("Failed to search for term {}: {}", &self.filter_term, e), 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] = - 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( &message, &mut self.data_columns.columns[0], - Color::Default, - Color::Default, - Attr::Default, + self.color_cache.theme_default.fg, + self.color_cache.theme_default.bg, + self.color_cache.theme_default.attrs, ((0, 0), (message.len() - 1, 0)), None, ); @@ -740,21 +761,28 @@ impl PlainListing { 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 */ 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 */ 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 */ 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 */ 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 */ 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() { 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 fg_color = if !envelope.is_seen() { - Color::Byte(0) + let row_attr = if !envelope.is_seen() { + self.color_cache.unseen + } else if idx % 2 == 0 { + self.color_cache.even } else { - Color::Default - }; - 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 - } + self.color_cache.odd }; let (x, _) = write_string_to_grid( &idx.to_string(), &mut columns[0], - fg_color, - bg_color, - Attr::Default, + row_attr.fg, + row_attr.bg, + row_attr.attrs, ((0, idx), (min_width.0, idx)), None, ); 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( &strings.date, &mut columns[1], - fg_color, - bg_color, - Attr::Default, + row_attr.fg, + row_attr.bg, + row_attr.attrs, ((0, idx), (min_width.1, idx)), None, ); 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( &strings.from, &mut columns[2], - fg_color, - bg_color, - Attr::Default, + row_attr.fg, + row_attr.bg, + row_attr.attrs, ((0, idx), (min_width.2, idx)), None, ); 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( &strings.flag, &mut columns[3], - fg_color, - bg_color, - Attr::Default, + row_attr.fg, + row_attr.bg, + row_attr.attrs, ((0, idx), (min_width.3, idx)), None, ); 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( &strings.subject, &mut columns[4], - fg_color, - bg_color, - Attr::Default, + row_attr.fg, + row_attr.bg, + row_attr.attrs, ((0, idx), (min_width.4, idx)), None, ); @@ -874,12 +887,10 @@ impl PlainListing { columns[4][c].set_bg(color); } for c in columns[4].row_iter(_x..(_x + 1), idx) { - columns[4][c].set_bg(color); - columns[4][c].set_keep_bg(true); + columns[4][c].set_bg(color).set_keep_bg(true); } for c in columns[4].row_iter((x + 1)..(_x + 1), idx) { - columns[4][c].set_keep_fg(true); - columns[4][c].set_keep_bg(true); + columns[4][c].set_keep_fg(true).set_keep_bg(true); } for c in columns[4].row_iter(x..(x + 1), idx) { columns[4][c].set_keep_bg(true); @@ -889,7 +900,7 @@ impl PlainListing { x }; 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] .collection @@ -902,18 +913,14 @@ impl PlainListing { if self.length == 0 && self.filter_term.is_empty() { let mailbox = &account[self.cursor_pos.1]; let message = mailbox.to_string(); - self.data_columns.columns[0] = CellBuffer::new_with_context( - message.len(), - self.length + 1, - Cell::with_char(' '), - context, - ); + self.data_columns.columns[0] = + CellBuffer::new_with_context(message.len(), self.length + 1, default_cell, context); write_string_to_grid( &message, &mut self.data_columns.columns[0], - Color::Default, - Color::Default, - Attr::Default, + self.color_cache.theme_default.fg, + self.color_cache.theme_default.bg, + self.color_cache.theme_default.attrs, ((0, 0), (MAX_COLS - 1, 0)), None, ); diff --git a/src/components/mail/listing/thread.rs b/src/components/mail/listing/thread.rs index 6efa939c9..c58ded680 100644 --- a/src/components/mail/listing/thread.rs +++ b/src/components/mail/listing/thread.rs @@ -81,21 +81,46 @@ impl MailListingTrait for ThreadListing { 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. // match context.accounts[self.cursor_pos.0].status(self.folder_hash) { Ok(_) => {} 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 = - context.accounts[self.cursor_pos.0][self.folder_hash].to_string(); - self.content = CellBuffer::new(message.len(), 1, Cell::with_char(' ')); + context.accounts[self.cursor_pos.0][self.cursor_pos.1].to_string(); + self.content = + CellBuffer::new_with_context(message.len(), 1, default_cell, context); self.length = 0; write_string_to_grid( message.as_str(), &mut self.content, - Color::Default, - Color::Default, - Attr::Default, + self.color_cache.theme_default.fg, + self.color_cache.theme_default.bg, + self.color_cache.theme_default.attrs, ((0, 0), (MAX_COLS - 1, 0)), None, ); @@ -108,21 +133,29 @@ impl MailListingTrait for ThreadListing { let threads = &account.collection.threads[&mailbox.folder.hash()]; self.length = threads.len(); 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 { 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( &message, &mut self.content, - Color::Default, - Color::Default, - Attr::Default, + self.color_cache.theme_default.fg, + self.color_cache.theme_default.bg, + self.color_cache.theme_default.attrs, ((0, 0), (message.len() - 1, 0)), None, ); 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 = Vec::with_capacity(6); let mut thread_idx = 0; // needed for alternate thread colors @@ -387,7 +420,7 @@ impl ThreadListing { length: 0, sort: (Default::default(), Default::default()), subsort: (Default::default(), Default::default()), - content, + content: CellBuffer::new(0, 0, Cell::with_char(' ')), color_cache: ColorCache::default(), row_updates: SmallVec::new(), locations: Vec::new(), diff --git a/src/components/utilities.rs b/src/components/utilities.rs index 0d9ecd996..5837303e5 100644 --- a/src/components/utilities.rs +++ b/src/components/utilities.rs @@ -305,8 +305,14 @@ impl fmt::Display for Pager { impl 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 } pub fn reflow(&self) -> Reflow { @@ -699,6 +705,7 @@ impl Component for Pager { fn is_dirty(&self) -> bool { self.dirty } + fn set_dirty(&mut self, value: bool) { self.dirty = value; } @@ -713,6 +720,7 @@ impl Component for Pager { fn id(&self) -> ComponentId { self.id } + fn set_id(&mut self, id: ComponentId) { self.id = id; } @@ -1645,7 +1653,7 @@ impl Component for Tabbed { return true; } 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 { composer.set_draft(draft.clone()); } diff --git a/src/components/utilities/widgets.rs b/src/components/utilities/widgets.rs index 62c548e2c..fd6507d3c 100644 --- a/src/components/utilities/widgets.rs +++ b/src/components/utilities/widgets.rs @@ -133,13 +133,14 @@ impl 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( self.as_str(), grid, - Color::Default, - Color::Default, - Attr::Default, + theme_attr.fg, + theme_attr.bg, + theme_attr.attrs, area, None, ); @@ -388,15 +389,16 @@ impl Component for FormWidget { let bottom_right = bottom_right!(area); if self.dirty { - let label_attrs = crate::conf::value(context, "widgets.form.label"); + let theme_default = crate::conf::value(context, "theme_default"); clear_area( grid, ( upper_left, 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() { let v = self.fields.get_mut(k).unwrap(); @@ -473,7 +475,7 @@ impl Component for FormWidget { pos_inc(upper_left, (0, length)), set_y(bottom_right, length + 2 + get_y(upper_left)), ), - label_attrs, + theme_default, ); if !self.hide_buttons { self.buttons.draw( @@ -491,7 +493,7 @@ impl Component for FormWidget { set_y(upper_left, length + 4 + get_y(upper_left)), bottom_right, ), - label_attrs, + theme_default, ); self.dirty = false; }