diff options
Diffstat (limited to 'ui/src/components')
-rw-r--r-- | ui/src/components/mail/compose.rs | 7 | ||||
-rw-r--r-- | ui/src/components/mail/listing/compact.rs | 36 | ||||
-rw-r--r-- | ui/src/components/mail/listing/conversations.rs | 15 | ||||
-rw-r--r-- | ui/src/components/mail/view.rs | 1 | ||||
-rw-r--r-- | ui/src/components/mail/view/thread.rs | 2 | ||||
-rw-r--r-- | ui/src/components/utilities.rs | 53 |
6 files changed, 74 insertions, 40 deletions
diff --git a/ui/src/components/mail/compose.rs b/ui/src/components/mail/compose.rs index b9bfc739..25497994 100644 --- a/ui/src/components/mail/compose.rs +++ b/ui/src/components/mail/compose.rs @@ -171,6 +171,7 @@ impl Composer { (list_address, list_address_string), ], false, + context, )); } } @@ -826,7 +827,7 @@ impl Component for Composer { } } - fn kill(&mut self, uuid: Uuid, _context: &mut Context) { + fn kill(&mut self, uuid: Uuid, context: &mut Context) { self.mode = ViewMode::Discard( uuid, Selector::new( @@ -837,6 +838,7 @@ impl Component for Composer { ('n', "cancel".to_string()), ], true, + context, ), ); } @@ -873,7 +875,7 @@ impl Component for Composer { self.id = id; } - fn can_quit_cleanly(&mut self) -> bool { + fn can_quit_cleanly(&mut self, context: &Context) -> bool { /* Play it safe and ask user for confirmation */ self.mode = ViewMode::Discard( self.id, @@ -885,6 +887,7 @@ impl Component for Composer { ('n', "cancel".to_string()), ], true, + context, ), ); self.set_dirty(); diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs index e486009d..82bf0786 100644 --- a/ui/src/components/mail/listing/compact.rs +++ b/ui/src/components/mail/listing/compact.rs @@ -405,7 +405,8 @@ impl ListingTrait for CompactListing { ), ERROR, ); - self.data_columns.columns[0] = CellBuffer::new(message.len(), 1, Cell::with_char(' ')); + self.data_columns.columns[0] = + CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context); write_string_to_grid( &message, &mut self.data_columns.columns[0], @@ -422,7 +423,8 @@ impl ListingTrait for CompactListing { } else { self.length = 0; let message = format!("No results for `{}`.", filter_term); - self.data_columns.columns[0] = CellBuffer::new(message.len(), 1, Cell::with_char(' ')); + self.data_columns.columns[0] = + CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context); write_string_to_grid( &message, &mut self.data_columns.columns[0], @@ -530,7 +532,7 @@ impl CompactListing { Err(_) => { let message: String = context.accounts[self.cursor_pos.0][folder_hash].to_string(); self.data_columns.columns[0] = - CellBuffer::new(message.len(), 1, Cell::with_char(' ')); + CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context); self.length = 0; write_string_to_grid( message.as_str(), @@ -610,19 +612,19 @@ impl CompactListing { /* index column */ self.data_columns.columns[0] = - CellBuffer::new(min_width.0, rows.len(), Cell::with_char(' ')); + CellBuffer::new_with_context(min_width.0, rows.len(), Cell::with_char(' '), context); /* date column */ self.data_columns.columns[1] = - CellBuffer::new(min_width.1, rows.len(), Cell::with_char(' ')); + CellBuffer::new_with_context(min_width.1, rows.len(), Cell::with_char(' '), context); /* from column */ self.data_columns.columns[2] = - CellBuffer::new(min_width.2, rows.len(), Cell::with_char(' ')); + CellBuffer::new_with_context(min_width.2, rows.len(), Cell::with_char(' '), context); /* flags column */ self.data_columns.columns[3] = - CellBuffer::new(min_width.3, rows.len(), Cell::with_char(' ')); + CellBuffer::new_with_context(min_width.3, rows.len(), Cell::with_char(' '), context); /* subject column */ self.data_columns.columns[4] = - CellBuffer::new(min_width.4, rows.len(), Cell::with_char(' ')); + CellBuffer::new_with_context(min_width.4, rows.len(), Cell::with_char(' '), context); for ((idx, root_idx), strings) in threads.root_iter().enumerate().zip(rows) { let thread_node = &threads.thread_nodes()[&root_idx]; @@ -750,8 +752,12 @@ impl CompactListing { if self.length == 0 { let mailbox = &account[self.cursor_pos.1]; let message = mailbox.to_string(); - self.data_columns.columns[0] = - CellBuffer::new(message.len(), self.length + 1, Cell::with_char(' ')); + self.data_columns.columns[0] = CellBuffer::new_with_context( + message.len(), + self.length + 1, + Cell::with_char(' '), + context, + ); write_string_to_grid( &message, &mut self.data_columns.columns[0], @@ -803,19 +809,19 @@ impl CompactListing { /* index column */ self.data_columns.columns[0] = - CellBuffer::new(min_width.0, rows.len(), Cell::with_char(' ')); + CellBuffer::new_with_context(min_width.0, rows.len(), Cell::with_char(' '), context); /* date column */ self.data_columns.columns[1] = - CellBuffer::new(min_width.1, rows.len(), Cell::with_char(' ')); + CellBuffer::new_with_context(min_width.1, rows.len(), Cell::with_char(' '), context); /* from column */ self.data_columns.columns[2] = - CellBuffer::new(min_width.2, rows.len(), Cell::with_char(' ')); + CellBuffer::new_with_context(min_width.2, rows.len(), Cell::with_char(' '), context); /* flags column */ self.data_columns.columns[3] = - CellBuffer::new(min_width.3, rows.len(), Cell::with_char(' ')); + CellBuffer::new_with_context(min_width.3, rows.len(), Cell::with_char(' '), context); /* subject column */ self.data_columns.columns[4] = - CellBuffer::new(min_width.4, rows.len(), Cell::with_char(' ')); + CellBuffer::new_with_context(min_width.4, rows.len(), Cell::with_char(' '), context); for ((idx, thread_hash), strings) in self.filtered_selection.iter().enumerate().zip(rows) { let i = threads.thread_nodes()[thread_hash].message().unwrap(); diff --git a/ui/src/components/mail/listing/conversations.rs b/ui/src/components/mail/listing/conversations.rs index 7289f081..4010907a 100644 --- a/ui/src/components/mail/listing/conversations.rs +++ b/ui/src/components/mail/listing/conversations.rs @@ -448,7 +448,8 @@ impl ListingTrait for ConversationsListing { if let Some(error) = error { self.length = 0; let message = format!("Error: {}", error.to_string()); - self.content = CellBuffer::new(message.len(), 1, Cell::with_char(' ')); + self.content = + CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context); write_string_to_grid( &message, &mut self.content, @@ -465,7 +466,8 @@ impl ListingTrait for ConversationsListing { } else { self.length = 0; let message = format!("No results for `{}`.", filter_term); - self.content = CellBuffer::new(message.len(), 1, Cell::with_char(' ')); + self.content = + CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context); write_string_to_grid( &message, &mut self.content, @@ -576,7 +578,8 @@ impl ConversationsListing { Ok(()) => {} Err(_) => { let message: String = context.accounts[self.cursor_pos.0][folder_hash].to_string(); - self.content = CellBuffer::new(message.len(), 1, Cell::with_char(' ')); + self.content = + CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context); self.length = 0; write_string_to_grid( message.as_str(), @@ -653,7 +656,8 @@ impl ConversationsListing { selection.retain(|e, _| order.contains_key(e)); let width = std::cmp::min(MAX_COLS, max_entry_columns); - self.content = CellBuffer::new(width, 4 * rows.len(), Cell::with_char(' ')); + self.content = + CellBuffer::new_with_context(width, 4 * rows.len(), Cell::with_char(' '), context); let padding_fg = if context.settings.terminal.theme == "light" { Color::Byte(254) @@ -749,7 +753,8 @@ impl ConversationsListing { if self.length == 0 { let mailbox = &account[self.cursor_pos.1]; let message = mailbox.to_string(); - self.content = CellBuffer::new(message.len(), 1, Cell::with_char(' ')); + self.content = + CellBuffer::new_with_context(message.len(), 1, Cell::with_char(' '), context); write_string_to_grid( &message, &mut self.content, diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs index 6845e28a..1a6dbc57 100644 --- a/ui/src/components/mail/view.rs +++ b/ui/src/components/mail/view.rs @@ -706,6 +706,7 @@ impl Component for MailView { "select contacts to add", entries, false, + context, )); self.dirty = true; return true; diff --git a/ui/src/components/mail/view/thread.rs b/ui/src/components/mail/view/thread.rs index f84ad207..a5100e66 100644 --- a/ui/src/components/mail/view/thread.rs +++ b/ui/src/components/mail/view/thread.rs @@ -222,7 +222,7 @@ impl ThreadView { e.heading = string; width = cmp::max(width, e.index.0 * 4 + e.heading.grapheme_width() + 2); } - let mut content = CellBuffer::new(width, height, Cell::default()); + let mut content = CellBuffer::new_with_context(width, height, Cell::default(), context); if self.reversed { for (y, e) in self.entries.iter().rev().enumerate() { /* Box character drawing stuff */ diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs index 9c744fb1..a065ea2a 100644 --- a/ui/src/components/utilities.rs +++ b/ui/src/components/utilities.rs @@ -305,7 +305,9 @@ impl Pager { let height = lines.len() + 1; let width = width.unwrap_or_else(|| lines.iter().map(|l| l.len()).max().unwrap_or(0)); + let ascii_drawing = self.content.ascii_drawing; let mut content = CellBuffer::new(width, height, Cell::with_char(' ')); + content.set_ascii_drawing(ascii_drawing); Pager::print_string(&mut content, lines); self.text = text.to_string(); self.content = content; @@ -361,7 +363,11 @@ impl Pager { let height = lines.len() + 1; let width = width.unwrap_or_else(|| lines.iter().map(|l| l.len()).max().unwrap_or(0)); - let mut content = CellBuffer::new(width, height, Cell::with_char(' ')); + let mut content = if let Some(context) = context { + CellBuffer::new_with_context(width, height, Cell::with_char(' '), context) + } else { + CellBuffer::new(width, height, Cell::with_char(' ')) + }; //interpret_format_flowed(&text); Pager::print_string(&mut content, lines); content @@ -479,7 +485,8 @@ impl Component for Pager { let height = lines.len() + 1; self.width = width; self.height = height; - self.content = CellBuffer::new(width, height, Cell::with_char(' ')); + self.content = + CellBuffer::new_with_context(width, height, Cell::with_char(' '), context); Pager::print_string(&mut self.content, lines); } if self.cursor_pos + height >= self.height { @@ -1067,8 +1074,8 @@ impl Component for StatusBar { self.id = id; } - fn can_quit_cleanly(&mut self) -> bool { - self.container.can_quit_cleanly() + fn can_quit_cleanly(&mut self, context: &Context) -> bool { + self.container.can_quit_cleanly(context) } } @@ -1335,7 +1342,8 @@ impl Component for Tabbed { ), ); } - self.help_content = CellBuffer::new(max_width, max_length + 2, Cell::default()); + self.help_content = + CellBuffer::new_with_context(max_width, max_length + 2, Cell::default(), context); let (width, height) = self.help_content.size(); let (cols, rows) = (width!(area), height!(area)); if cols == 0 || rows == 0 { @@ -1556,9 +1564,9 @@ impl Component for Tabbed { self.id = id; } - fn can_quit_cleanly(&mut self) -> bool { + fn can_quit_cleanly(&mut self, context: &Context) -> bool { for (i, c) in self.children.iter_mut().enumerate() { - if !c.can_quit_cleanly() { + if !c.can_quit_cleanly(context) { self.cursor_pos = i; self.set_dirty(); return false; @@ -1843,7 +1851,12 @@ impl<T: PartialEq + Debug + Clone + Sync + Send> Component for Selector<T> { } impl<T: PartialEq + Debug + Clone + Sync + Send> Selector<T> { - pub fn new(title: &str, entries: Vec<(T, String)>, single_only: bool) -> Selector<T> { + pub fn new( + title: &str, + entries: Vec<(T, String)>, + single_only: bool, + context: &Context, + ) -> Selector<T> { let width = std::cmp::max( "OK Cancel".len(), std::cmp::max( @@ -1863,9 +1876,11 @@ impl<T: PartialEq + Debug + Clone + Sync + Send> Selector<T> { /* Extra room for buttons Okay/Cancel */ 3 }; - let mut content = CellBuffer::new(width, height, Cell::with_char(' ')); + let mut content = + CellBuffer::new_with_context(width, height, Cell::with_char(' '), context); + let ascii_drawing = context.settings.terminal.ascii_drawing; write_string_to_grid( - "┏━", + if ascii_drawing { "+-" } else { "┏━" }, &mut content, Color::Byte(8), Color::Default, @@ -1884,7 +1899,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send> Selector<T> { ); for i in 1..(width - title.len() - 1) { write_string_to_grid( - "━", + if ascii_drawing { "-" } else { "━" }, &mut content, Color::Byte(8), Color::Default, @@ -1894,7 +1909,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send> Selector<T> { ); } write_string_to_grid( - "┓", + if ascii_drawing { "+" } else { "┓" }, &mut content, Color::Byte(8), Color::Default, @@ -1903,7 +1918,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send> Selector<T> { false, ); write_string_to_grid( - "┗", + if ascii_drawing { "+" } else { "┗" }, &mut content, Color::Byte(8), Color::Default, @@ -1912,7 +1927,11 @@ impl<T: PartialEq + Debug + Clone + Sync + Send> Selector<T> { false, ); write_string_to_grid( - &"━".repeat(width - 2), + &if ascii_drawing { + "-".repeat(width - 2) + } else { + "━".repeat(width - 2) + }, &mut content, Color::Byte(8), Color::Default, @@ -1921,7 +1940,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send> Selector<T> { false, ); write_string_to_grid( - "┛", + if ascii_drawing { "+" } else { "┛" }, &mut content, Color::Byte(8), Color::Default, @@ -1931,7 +1950,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send> Selector<T> { ); for i in 1..height - 1 { write_string_to_grid( - "┃", + if ascii_drawing { "|" } else { "┃" }, &mut content, Color::Byte(8), Color::Default, @@ -1940,7 +1959,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send> Selector<T> { false, ); write_string_to_grid( - "┃", + if ascii_drawing { "|" } else { "┃" }, &mut content, Color::Byte(8), Color::Default, |