From 995e70e009e5f2bbf934dc3132debab6dbdf6b8e Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Mon, 18 Nov 2019 13:06:30 +0200 Subject: [PATCH] ui: change line_break meaning in write_string_to_grid Change line_break parameter from bool flag (whether to break in the end of a line or not) to an Option, where the value is the x_offset of the left side of the area. Thus if line_break == Some(_) when a line ends its value is set as x to continue in the next line properly. --- ui/src/components/contacts.rs | 6 +- ui/src/components/contacts/contact_list.rs | 24 ++++---- ui/src/components/mail/compose.rs | 16 +++--- ui/src/components/mail/listing.rs | 16 +++--- ui/src/components/mail/listing/compact.rs | 20 +++---- .../components/mail/listing/conversations.rs | 16 +++--- ui/src/components/mail/listing/plain.rs | 20 +++---- ui/src/components/mail/listing/thread.rs | 14 +++-- ui/src/components/mail/status.rs | 34 +++++------ ui/src/components/mail/view.rs | 39 +++++-------- ui/src/components/mail/view/envelope.rs | 10 ++-- ui/src/components/mail/view/thread.rs | 8 +-- ui/src/components/utilities.rs | 56 +++++++++---------- ui/src/components/utilities/widgets.rs | 12 ++-- ui/src/terminal/cells.rs | 7 ++- 15 files changed, 145 insertions(+), 153 deletions(-) diff --git a/ui/src/components/contacts.rs b/ui/src/components/contacts.rs index 5c98a5dd..4eef427c 100644 --- a/ui/src/components/contacts.rs +++ b/ui/src/components/contacts.rs @@ -83,7 +83,7 @@ impl ContactManager { Color::Default, Attr::Default, ((0, 0), (width - 1, 0)), - false, + None, ); let (x, y) = write_string_to_grid( &self.card.last_edited(), @@ -92,7 +92,7 @@ impl ContactManager { Color::Default, Attr::Default, ((x, 0), (width - 1, 0)), - false, + None, ); if self.card.external_resource() { @@ -106,7 +106,7 @@ impl ContactManager { Color::Default, Attr::Default, ((x, y), (width - 1, y)), - false, + None, ); } diff --git a/ui/src/components/contacts/contact_list.rs b/ui/src/components/contacts/contact_list.rs index 515022bd..4df6dd57 100644 --- a/ui/src/components/contacts/contact_list.rs +++ b/ui/src/components/contacts/contact_list.rs @@ -135,7 +135,7 @@ impl ContactList { Color::White, Attr::Bold, ((0, 0), (MAX_COLS - 1, self.length)), - false, + None, ); write_string_to_grid( "E-MAIL", @@ -144,7 +144,7 @@ impl ContactList { Color::White, Attr::Bold, ((0, 0), (MAX_COLS - 1, self.length)), - false, + None, ); write_string_to_grid( @@ -154,7 +154,7 @@ impl ContactList { Color::White, Attr::Bold, ((0, 0), (MAX_COLS - 1, self.length)), - false, + None, ); let account = &mut context.accounts[self.account_pos]; @@ -169,7 +169,7 @@ impl ContactList { Color::Default, Attr::Default, ((0, idx + 1), (min_width.0, idx + 1)), - false, + None, ); write_string_to_grid( @@ -179,7 +179,7 @@ impl ContactList { Color::Default, Attr::Default, ((0, idx + 1), (min_width.1, idx + 1)), - false, + None, ); write_string_to_grid( @@ -189,7 +189,7 @@ impl ContactList { Color::Default, Attr::Default, ((0, idx + 1), (min_width.2, idx + 1)), - false, + None, ); } @@ -208,7 +208,7 @@ impl ContactList { Color::Default, Attr::Default, ((0, 0), (MAX_COLS - 1, 0)), - false, + None, ); return; } @@ -273,7 +273,7 @@ impl ContactList { if a.name.grapheme_len() + s.len() > width + 1 { /* Print account name */ - write_string_to_grid(&a.name, grid, fg_color, bg_color, Attr::Bold, area, false); + write_string_to_grid(&a.name, grid, fg_color, bg_color, Attr::Bold, area, None); write_string_to_grid( &s, grid, @@ -287,7 +287,7 @@ impl ContactList { ), bottom_right!(area), ), - false, + None, ); write_string_to_grid( "…", @@ -302,12 +302,12 @@ impl ContactList { ), bottom_right!(area), ), - false, + None, ); } else { /* Print account name */ - write_string_to_grid(&a.name, grid, fg_color, bg_color, Attr::Bold, area, false); + write_string_to_grid(&a.name, grid, fg_color, bg_color, Attr::Bold, area, None); write_string_to_grid( &s, grid, @@ -321,7 +321,7 @@ impl ContactList { ), bottom_right!(area), ), - false, + None, ); } } diff --git a/ui/src/components/mail/compose.rs b/ui/src/components/mail/compose.rs index 71092bb6..82a5d8fe 100644 --- a/ui/src/components/mail/compose.rs +++ b/ui/src/components/mail/compose.rs @@ -317,7 +317,7 @@ impl Composer { Color::Default, Attr::Default, (pos_inc(upper_left!(area), (0, 1)), bottom_right!(area)), - false, + None, ); } else { write_string_to_grid( @@ -327,7 +327,7 @@ impl Composer { Color::Default, Attr::Default, (pos_inc(upper_left!(area), (0, 1)), bottom_right!(area)), - false, + None, ); } if attachments_no == 0 { @@ -338,7 +338,7 @@ impl Composer { Color::Default, Attr::Default, (pos_inc(upper_left!(area), (0, 2)), bottom_right!(area)), - false, + None, ); } else { write_string_to_grid( @@ -348,7 +348,7 @@ impl Composer { Color::Default, Attr::Default, (pos_inc(upper_left!(area), (0, 2)), bottom_right!(area)), - false, + None, ); for (i, a) in self.draft.attachments().iter().enumerate() { if let Some(name) = a.content_type().name() { @@ -365,7 +365,7 @@ impl Composer { Color::Default, Attr::Default, (pos_inc(upper_left!(area), (0, 3 + i)), bottom_right!(area)), - false, + None, ); } else { write_string_to_grid( @@ -375,7 +375,7 @@ impl Composer { Color::Default, Attr::Default, (pos_inc(upper_left!(area), (0, 3 + i)), bottom_right!(area)), - false, + None, ); } } @@ -510,7 +510,7 @@ impl Component for Composer { pos_dec(upper_left!(header_area), (0, 1)), bottom_right!(header_area), ), - false, + None, ); clear_area(grid, ((x, y), (set_y(bottom_right, y)))); change_colors( @@ -580,7 +580,7 @@ impl Component for Composer { Color::Default, Attr::Default, body_area, - false, + None, ); context.dirty_areas.push_back(body_area); self.dirty = false; diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs index e0831899..53e24e00 100644 --- a/ui/src/components/mail/listing.rs +++ b/ui/src/components/mail/listing.rs @@ -234,7 +234,7 @@ impl Component for Listing { Color::Default, Attr::Default, area, - false, + None, ); context.dirty_areas.push_back(area); return; @@ -258,7 +258,7 @@ impl Component for Listing { Color::Default, Attr::Default, (set_x(upper_left, mid + 1), bottom_right), - false, + None, ); context.dirty_areas.push_back(area); return; @@ -892,7 +892,7 @@ impl Listing { Color::Default, Attr::Bold, area, - false, + None, ); if lines.is_empty() { @@ -903,7 +903,7 @@ impl Listing { Color::Default, Attr::Default, (pos_inc(upper_left, (0, 1)), bottom_right), - false, + None, ); return 0; } @@ -950,7 +950,7 @@ impl Listing { bg_color, Attr::Default, (set_y(upper_left, y), bottom_right), - false, + None, ); let (x, _) = write_string_to_grid( &" ".repeat(depth + 1), @@ -959,7 +959,7 @@ impl Listing { bg_color, Attr::Default, ((x, y), bottom_right), - false, + None, ); let (x, _) = write_string_to_grid( entries[&folder_idx].name(), @@ -968,7 +968,7 @@ impl Listing { bg_color, Attr::Default, ((x, y), bottom_right), - false, + None, ); /* Unread message count */ @@ -1000,7 +1000,7 @@ impl Listing { ), bottom_right, ), - false, + None, ); change_colors(grid, ((x, y), set_y(bottom_right, y)), fg_color, bg_color); idx += 1; diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs index dc25ec00..a6649bf8 100644 --- a/ui/src/components/mail/listing/compact.rs +++ b/ui/src/components/mail/listing/compact.rs @@ -442,7 +442,7 @@ impl ListingTrait for CompactListing { Color::Default, Attr::Default, ((0, 0), (message.len() - 1, 0)), - false, + None, ); } } @@ -562,7 +562,7 @@ impl CompactListing { Color::Default, Attr::Default, ((0, 0), (MAX_COLS - 1, 0)), - false, + None, ); return; } @@ -717,7 +717,7 @@ impl CompactListing { bg_color, Attr::Default, ((0, idx), (min_width.0, idx)), - false, + None, ); for x in x..min_width.0 { self.data_columns.columns[0][(x, idx)].set_bg(bg_color); @@ -729,7 +729,7 @@ impl CompactListing { bg_color, Attr::Default, ((0, idx), (min_width.1, idx)), - false, + None, ); for x in x..min_width.1 { self.data_columns.columns[1][(x, idx)].set_bg(bg_color); @@ -741,7 +741,7 @@ impl CompactListing { bg_color, Attr::Default, ((0, idx), (min_width.2, idx)), - false, + None, ); for x in x..min_width.2 { self.data_columns.columns[2][(x, idx)].set_bg(bg_color); @@ -753,7 +753,7 @@ impl CompactListing { bg_color, Attr::Default, ((0, idx), (min_width.3, idx)), - false, + None, ); for x in x..min_width.3 { self.data_columns.columns[3][(x, idx)].set_bg(bg_color); @@ -765,7 +765,7 @@ impl CompactListing { bg_color, Attr::Default, ((0, idx), (min_width.4, idx)), - false, + None, ); for x in x..min_width.4 { self.data_columns.columns[4][(x, idx)].set_bg(bg_color); @@ -806,7 +806,7 @@ impl CompactListing { Color::Default, Attr::Default, ((0, 0), (MAX_COLS - 1, 0)), - false, + None, ); } } @@ -961,6 +961,7 @@ impl Component for CompactListing { } let mut area = area; if !self.filter_term.is_empty() { + let (upper_left, bottom_right) = area; let (x, y) = write_string_to_grid( &format!( "{} results for `{}` (Press ESC to exit)", @@ -972,9 +973,8 @@ impl Component for CompactListing { Color::Default, Attr::Default, area, - true, + Some(get_x(upper_left)), ); - let (upper_left, bottom_right) = area; clear_area(grid, ((x, y), set_y(bottom_right, y))); context .dirty_areas diff --git a/ui/src/components/mail/listing/conversations.rs b/ui/src/components/mail/listing/conversations.rs index 233cc0f2..0dac1be6 100644 --- a/ui/src/components/mail/listing/conversations.rs +++ b/ui/src/components/mail/listing/conversations.rs @@ -417,7 +417,7 @@ impl ListingTrait for ConversationsListing { Color::Default, Attr::Default, ((0, 0), (message.len() - 1, 0)), - false, + None, ); } } @@ -538,7 +538,7 @@ impl ConversationsListing { Color::Default, Attr::Default, ((0, 0), (message.len() - 1, 0)), - false, + None, ); return; } @@ -703,7 +703,7 @@ impl ConversationsListing { bg_color, Attr::Default, ((0, 3 * idx), (width - 1, 3 * idx)), - false, + None, ); for x in x..(x + 3) { self.content[(x, 3 * idx)].set_bg(bg_color); @@ -716,7 +716,7 @@ impl ConversationsListing { bg_color, Attr::Bold, ((x, 3 * idx), (width - 1, 3 * idx)), - false, + None, ); for x in x..width { self.content[(x, 3 * idx)].set_bg(bg_color); @@ -729,7 +729,7 @@ impl ConversationsListing { bg_color, Attr::Default, ((0, 3 * idx + 1), (width - 1, 3 * idx + 1)), - false, + None, ); for x in x..(x + 4) { self.content[(x, 3 * idx + 1)].set_ch('▁'); @@ -743,7 +743,7 @@ impl ConversationsListing { bg_color, Attr::Default, ((x + 4, 3 * idx + 1), (width - 1, 3 * idx + 1)), - false, + None, ); for x in x..width { @@ -768,7 +768,7 @@ impl ConversationsListing { Color::Default, Attr::Default, ((0, 0), (message.len() - 1, 0)), - false, + None, ); } } @@ -916,7 +916,7 @@ impl Component for ConversationsListing { Color::Default, Attr::Default, area, - true, + Some(get_x(upper_left)), ); clear_area(grid, ((x, y), set_y(bottom_right, y))); context diff --git a/ui/src/components/mail/listing/plain.rs b/ui/src/components/mail/listing/plain.rs index 3491fde2..59c8c052 100644 --- a/ui/src/components/mail/listing/plain.rs +++ b/ui/src/components/mail/listing/plain.rs @@ -417,7 +417,7 @@ impl ListingTrait for PlainListing { Color::Default, Attr::Default, ((0, 0), (message.len() - 1, 0)), - false, + None, ); } } @@ -517,7 +517,7 @@ impl PlainListing { Color::Default, Attr::Default, ((0, 0), (MAX_COLS - 1, 0)), - false, + None, ); return; } @@ -683,7 +683,7 @@ impl PlainListing { bg_color, Attr::Default, ((0, idx), (min_width.0, idx)), - false, + None, ); for x in x..min_width.0 { self.data_columns.columns[0][(x, idx)].set_bg(bg_color); @@ -695,7 +695,7 @@ impl PlainListing { bg_color, Attr::Default, ((0, idx), (min_width.1, idx)), - false, + None, ); for x in x..min_width.1 { self.data_columns.columns[1][(x, idx)].set_bg(bg_color); @@ -707,7 +707,7 @@ impl PlainListing { bg_color, Attr::Default, ((0, idx), (min_width.2, idx)), - false, + None, ); for x in x..min_width.2 { self.data_columns.columns[2][(x, idx)].set_bg(bg_color); @@ -719,7 +719,7 @@ impl PlainListing { bg_color, Attr::Default, ((0, idx), (min_width.3, idx)), - false, + None, ); for x in x..min_width.3 { self.data_columns.columns[3][(x, idx)].set_bg(bg_color); @@ -731,7 +731,7 @@ impl PlainListing { bg_color, Attr::Default, ((0, idx), (min_width.4, idx)), - false, + None, ); for x in x..min_width.4 { self.data_columns.columns[4][(x, idx)].set_bg(bg_color); @@ -760,7 +760,7 @@ impl PlainListing { Color::Default, Attr::Default, ((0, 0), (MAX_COLS - 1, 0)), - false, + None, ); } } @@ -827,6 +827,7 @@ impl Component for PlainListing { } let mut area = area; if !self.filter_term.is_empty() { + let (upper_left, bottom_right) = area; let (x, y) = write_string_to_grid( &format!( "{} results for `{}` (Press ESC to exit)", @@ -838,9 +839,8 @@ impl Component for PlainListing { Color::Default, Attr::Default, area, - true, + Some(get_x(upper_left)), ); - let (upper_left, bottom_right) = area; clear_area(grid, ((x, y), set_y(bottom_right, y))); context .dirty_areas diff --git a/ui/src/components/mail/listing/thread.rs b/ui/src/components/mail/listing/thread.rs index 3d79a297..6003a7cc 100644 --- a/ui/src/components/mail/listing/thread.rs +++ b/ui/src/components/mail/listing/thread.rs @@ -277,7 +277,7 @@ impl ThreadListing { Color::Default, Attr::Default, ((0, 0), (MAX_COLS - 1, 0)), - false, + None, ); return; } @@ -287,20 +287,22 @@ impl ThreadListing { let threads = &account.collection.threads[&mailbox.folder.hash()]; self.length = threads.len(); - self.content = CellBuffer::new(MAX_COLS, self.length + 1, Cell::with_char(' ')); self.locations.clear(); if self.length == 0 { + let message = format!("Folder `{}` is empty.", mailbox.folder.name()); + self.content = CellBuffer::new(message.len(), 1, Cell::with_char(' ')); write_string_to_grid( - &format!("Folder `{}` is empty.", mailbox.folder.name()), + &message, &mut self.content, Color::Default, Color::Default, Attr::Default, - ((0, 0), (MAX_COLS - 1, 0)), - true, + ((0, 0), (message.len() - 1, 0)), + None, ); return; } + self.content = CellBuffer::new(MAX_COLS, self.length + 1, Cell::with_char(' ')); let mut indentations: Vec = Vec::with_capacity(6); let mut thread_idx = 0; // needed for alternate thread colors @@ -347,7 +349,7 @@ impl ThreadListing { bg_color, Attr::Default, ((0, idx), (MAX_COLS - 1, idx)), - false, + None, ); for x in x..MAX_COLS { diff --git a/ui/src/components/mail/status.rs b/ui/src/components/mail/status.rs index 1c72c030..4f74abcf 100644 --- a/ui/src/components/mail/status.rs +++ b/ui/src/components/mail/status.rs @@ -54,7 +54,7 @@ impl Component for StatusPanel { Color::Default, Attr::Bold, ((1, 1), (width - 1, height - 1)), - true, + Some(1), ); let mut y = y + 1; let work_controller = context.work_controller().threads.lock().unwrap(); @@ -77,7 +77,7 @@ impl Component for StatusPanel { Color::Default, Attr::Default, ((1, y), (width - 1, height - 1)), - true, + Some(1), ); for x in x..(width - 1) { self.content[(x, y)].set_ch(' '); @@ -92,7 +92,7 @@ impl Component for StatusPanel { Color::Default, Attr::Bold, ((1, y + 1), (width - 1, height - 1)), - true, + Some(1), ); y += 2; @@ -117,7 +117,7 @@ impl Component for StatusPanel { Color::Default, Attr::Default, ((1, y), (width - 1, height - 1)), - true, + Some(1), ); for x in x..(width - 1) { self.content[(x, y)].set_ch(' '); @@ -247,7 +247,7 @@ impl StatusPanel { Color::Default, Attr::Default, ((2, 10), (120 - 1, 10)), - true, + Some(2), ); for (i, a) in context.accounts.iter().enumerate() { @@ -262,7 +262,7 @@ impl StatusPanel { Color::Default, Attr::Bold, ((3, 12 + i * 10), (120 - 2, 12 + i * 10)), - true, + Some(3), ); write_string_to_grid( " ▒██▒ ", @@ -271,7 +271,7 @@ impl StatusPanel { Color::Default, Attr::Default, ((x, y), (120 - 2, 12 + i * 10)), - true, + None, ); write_string_to_grid( &a.runtime_settings.account().identity, @@ -280,7 +280,7 @@ impl StatusPanel { Color::Default, Attr::Default, ((4, y + 2), (120 - 2, y + 2)), - true, + None, ); if i == self.account_cursor { for h in 1..8 { @@ -308,7 +308,7 @@ impl StatusPanel { Color::Default, Attr::Default, ((5, y + 3), (120 - 2, y + 3)), - true, + None, ); column_width = std::cmp::max( column_width, @@ -319,7 +319,7 @@ impl StatusPanel { Color::Default, Attr::Default, ((5, y + 4), (120 - 2, y + 4)), - true, + None, ) .0, ); @@ -332,7 +332,7 @@ impl StatusPanel { Color::Default, Attr::Default, ((5, y + 5), (120 - 2, y + 5)), - true, + None, ) .0, ); @@ -354,7 +354,7 @@ impl StatusPanel { Color::Default, Attr::Default, ((5 + column_width, y + 2), (120 - 2, y + 2)), - true, + None, ); } } @@ -380,7 +380,7 @@ impl Component for AccountStatus { Color::Default, Attr::Default, ((1, 1), (width - 1, height - 1)), - true, + None, ); let mut capabilities = imap_backend.capabilities(); let max_name_width = std::cmp::max( @@ -394,7 +394,7 @@ impl Component for AccountStatus { Color::Default, Attr::Default, ((max_name_width + 6, 1), (width - 1, height - 1)), - true, + None, ); capabilities.sort(); for (i, cap) in capabilities.into_iter().enumerate() { @@ -406,7 +406,7 @@ impl Component for AccountStatus { Color::Default, Attr::Default, ((1, 2 + i), (width - 1, height - 1)), - true, + None, ); let (width, height) = self.content.size(); @@ -418,7 +418,7 @@ impl Component for AccountStatus { Color::Default, Attr::Default, ((max_name_width + 6, 2 + i), (width - 1, height - 1)), - true, + None, ); } else { write_string_to_grid( @@ -428,7 +428,7 @@ impl Component for AccountStatus { Color::Default, Attr::Default, ((max_name_width + 6, 2 + i), (width - 1, height - 1)), - true, + None, ); } } diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs index e002c249..5485e255 100644 --- a/ui/src/components/mail/view.rs +++ b/ui/src/components/mail/view.rs @@ -352,7 +352,7 @@ impl Component for MailView { Color::Default, Attr::Default, area, - true, + Some(get_x(upper_left)), ); for x in x..=get_x(bottom_right) { grid[(x, y)].set_ch(' '); @@ -366,7 +366,7 @@ impl Component for MailView { Color::Default, Attr::Default, (set_y(upper_left, y + 1), bottom_right), - true, + Some(get_x(upper_left)), ); for x in x..=get_x(bottom_right) { grid[(x, y)].set_ch(' '); @@ -380,7 +380,7 @@ impl Component for MailView { Color::Default, Attr::Default, (set_y(upper_left, y + 1), bottom_right), - true, + Some(get_x(upper_left)), ); for x in x..=get_x(bottom_right) { grid[(x, y)].set_ch(' '); @@ -394,7 +394,7 @@ impl Component for MailView { Color::Default, Attr::Default, (set_y(upper_left, y + 1), bottom_right), - true, + Some(get_x(upper_left)), ); for x in x..=get_x(bottom_right) { grid[(x, y)].set_ch(' '); @@ -408,7 +408,7 @@ impl Component for MailView { Color::Default, Attr::Default, (set_y(upper_left, y + 1), bottom_right), - true, + Some(get_x(upper_left)), ); for x in x..=get_x(bottom_right) { grid[(x, y)].set_ch(' '); @@ -423,7 +423,7 @@ impl Component for MailView { Color::Default, Attr::Default, (set_y(upper_left, y + 1), bottom_right), - true, + Some(get_x(upper_left)), ); for x in x..=get_x(bottom_right) { grid[(x, _y)].set_ch(' '); @@ -445,7 +445,7 @@ impl Component for MailView { Color::Default, Attr::Default, (set_y(upper_left, _y + 1), bottom_right), - true, + Some(get_x(upper_left)), ); for x in x..=get_x(bottom_right) { grid[(x, _y)].set_ch(' '); @@ -471,7 +471,7 @@ impl Component for MailView { Color::Default, Attr::Default, (set_y(upper_left, y), bottom_right), - false, + None, ); let (_x, _y) = write_string_to_grid( id, @@ -480,7 +480,7 @@ impl Component for MailView { Color::Default, Attr::Default, ((_x, y), bottom_right), - false, + None, ); x = _x; if _y != y { @@ -496,13 +496,9 @@ impl Component for MailView { Color::Default, Attr::Default, ((x, y), bottom_right), - true, + Some(get_x(upper_left)), ); x = _x; - if _y != y { - x = get_x(upper_left); - } - y = _y; } if archive.is_some() { @@ -513,12 +509,9 @@ impl Component for MailView { Color::Default, Attr::Default, ((x, y), bottom_right), - true, + Some(get_x(upper_left)), ); x = _x; - if _y != y { - x = get_x(upper_left); - } y = _y; } if post.is_some() { @@ -529,12 +522,9 @@ impl Component for MailView { Color::Default, Attr::Default, ((x, y), bottom_right), - true, + Some(get_x(upper_left)), ); x = _x; - if _y != y { - x = get_x(upper_left); - } y = _y; } if unsubscribe.is_some() { @@ -545,12 +535,9 @@ impl Component for MailView { Color::Default, Attr::Default, ((x, y), bottom_right), - true, + Some(get_x(upper_left)), ); x = _x; - if _y != y { - x = get_x(upper_left); - } y = _y; } if archive.is_some() || post.is_some() || unsubscribe.is_some() { diff --git a/ui/src/components/mail/view/envelope.rs b/ui/src/components/mail/view/envelope.rs index b6ea3dfc..5a43370b 100644 --- a/ui/src/components/mail/view/envelope.rs +++ b/ui/src/components/mail/view/envelope.rs @@ -243,7 +243,7 @@ impl Component for EnvelopeView { Color::Default, Attr::Default, area, - true, + Some(get_x(upper_left)), ); for x in x..=get_x(bottom_right) { grid[(x, y)].set_ch(' '); @@ -257,7 +257,7 @@ impl Component for EnvelopeView { Color::Default, Attr::Default, (set_y(upper_left, y + 1), bottom_right), - true, + Some(get_x(upper_left)), ); for x in x..=get_x(bottom_right) { grid[(x, y)].set_ch(' '); @@ -271,7 +271,7 @@ impl Component for EnvelopeView { Color::Default, Attr::Default, (set_y(upper_left, y + 1), bottom_right), - true, + Some(get_x(upper_left)), ); for x in x..=get_x(bottom_right) { grid[(x, y)].set_ch(' '); @@ -285,7 +285,7 @@ impl Component for EnvelopeView { Color::Default, Attr::Default, (set_y(upper_left, y + 1), bottom_right), - true, + Some(get_x(upper_left)), ); for x in x..=get_x(bottom_right) { grid[(x, y)].set_ch(' '); @@ -299,7 +299,7 @@ impl Component for EnvelopeView { Color::Default, Attr::Default, (set_y(upper_left, y + 1), bottom_right), - true, + Some(get_x(upper_left)), ); for x in x..=get_x(bottom_right) { grid[(x, y)].set_ch(' '); diff --git a/ui/src/components/mail/view/thread.rs b/ui/src/components/mail/view/thread.rs index dd6384e1..9b398a2a 100644 --- a/ui/src/components/mail/view/thread.rs +++ b/ui/src/components/mail/view/thread.rs @@ -264,7 +264,7 @@ impl ThreadView { (e.index.0 * 4 + 1, 2 * y), (e.index.0 * 4 + e.heading.grapheme_width() + 1, height - 1), ), - true, + None, ); { let envelope: EnvelopeRef = context.accounts[self.coordinates.0] @@ -342,7 +342,7 @@ impl ThreadView { (e.index.0 * 4 + 1, 2 * y), (e.index.0 * 4 + e.heading.grapheme_width() + 1, height - 1), ), - false, + None, ); { let envelope: EnvelopeRef = context.accounts[self.coordinates.0] @@ -650,7 +650,7 @@ impl ThreadView { Color::Default, Attr::Default, area, - true, + Some(get_x(upper_left)), ); for x in x..=get_x(bottom_right) { grid[(x, y)].set_ch(' '); @@ -736,7 +736,7 @@ impl ThreadView { Color::Default, Attr::Default, area, - true, + Some(get_x(upper_left)), ); for x in x..=get_x(bottom_right) { grid[(x, y)].set_ch(' '); diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs index 5ea0c737..6f4c0fda 100644 --- a/ui/src/components/utilities.rs +++ b/ui/src/components/utilities.rs @@ -435,7 +435,7 @@ impl Pager { Color::Default, Attr::Default, ((0, i), (width.saturating_sub(1), i)), - true, + None, ); } } @@ -678,7 +678,7 @@ impl StatusBar { Color::Byte(26), Attr::Default, area, - false, + None, ); let offset = self.status.find('|').unwrap_or_else(|| self.status.len()); for x in get_x(upper_left!(area))..get_x(upper_left!(area)) + offset { @@ -697,7 +697,7 @@ impl StatusBar { (std::cmp::max(x, width!(area).saturating_sub(n.len())), y), bottom_right!(area), ), - false, + None, ); } else { self.cur_notification = None; @@ -715,7 +715,7 @@ impl StatusBar { (std::cmp::max(x, width!(area).saturating_sub(n.len())), y), bottom_right!(area), ), - false, + None, ); self.cur_notification = Some((std::time::Instant::now(), n)); } @@ -742,7 +742,7 @@ impl StatusBar { Color::Byte(88), Attr::Default, area, - false, + None, ); grid[(x, y)].set_attrs(Attr::Underline); change_colors(grid, area, Color::Byte(219), Color::Byte(88)); @@ -927,7 +927,7 @@ impl Component for StatusBar { ), bottom_right!(hist_area), ), - true, + Some(get_x(upper_left!(hist_area))), ); write_string_to_grid( &s.description, @@ -936,7 +936,7 @@ impl Component for StatusBar { Color::Byte(174), Attr::Default, ((x + 2, y), bottom_right!(hist_area)), - false, + None, ); if y_offset + offset == self.auto_complete.cursor() { change_colors( @@ -962,13 +962,13 @@ impl Component for StatusBar { Attr::Default, ( ( - get_y(upper_left) + get_x(upper_left) + self.ex_buffer.as_str().split_graphemes().len(), get_y(bottom_right) - height + 1, ), set_y(bottom_right, get_y(bottom_right) - height + 1), ), - true, + None, ); } } @@ -1262,7 +1262,7 @@ impl Tabbed { bg, Attr::Default, (set_x(upper_left, x), bottom_right!(area)), - false, + None, ); x = x_ + 1; if idx == self.pinned.saturating_sub(1) { @@ -1429,7 +1429,7 @@ impl Component for Tabbed { Color::Default, Attr::Default, ((2, 0), (max_width.saturating_sub(2), max_length - 1)), - false, + None, ); } let mut idx = 0; @@ -1441,7 +1441,7 @@ impl Component for Tabbed { Color::Default, Attr::Default, ((2, 2 + idx), (max_width.saturating_sub(2), max_length - 1)), - false, + None, ); idx += 2; let mut shortcuts = shortcuts.iter().collect::>(); @@ -1455,7 +1455,7 @@ impl Component for Tabbed { Color::Default, Attr::Default, ((2, 2 + idx), (max_width.saturating_sub(2), max_length - 1)), - false, + None, ); write_string_to_grid( &format!("{}", v), @@ -1464,7 +1464,7 @@ impl Component for Tabbed { Color::Default, Attr::Default, ((x + 2, y), (max_width.saturating_sub(2), max_length - 1)), - false, + None, ); idx += 1; } @@ -1720,7 +1720,7 @@ impl Component for Selector { Color::Default, Attr::Default, ((3, c + 2), (width - 2, c + 2)), - false, + None, ); } else { write_string_to_grid( @@ -1730,7 +1730,7 @@ impl Component for Selector { Color::Default, Attr::Default, ((3, c + 2), (width - 2, c + 2)), - false, + None, ); } self.dirty = true; @@ -1967,7 +1967,7 @@ impl Selector { Color::Default, Attr::Default, ((0, 0), (width - 1, 0)), - false, + None, ); let (x, _) = write_string_to_grid( title, @@ -1976,7 +1976,7 @@ impl Selector { Color::Default, Attr::Default, ((2, 0), (width - 1, 0)), - false, + None, ); for i in 1..(width - title.len() - 1) { write_string_to_grid( @@ -1986,7 +1986,7 @@ impl Selector { Color::Default, Attr::Default, ((x + i, 0), (width - 1, 0)), - false, + None, ); } write_string_to_grid( @@ -1996,7 +1996,7 @@ impl Selector { Color::Default, Attr::Default, ((width - 1, 0), (width - 1, 0)), - false, + None, ); write_string_to_grid( if ascii_drawing { "+" } else { "┗" }, @@ -2005,7 +2005,7 @@ impl Selector { Color::Default, Attr::Default, ((0, height - 1), (width - 1, height - 1)), - false, + None, ); write_string_to_grid( &if ascii_drawing { @@ -2018,7 +2018,7 @@ impl Selector { Color::Default, Attr::Default, ((1, height - 1), (width - 2, height - 1)), - false, + None, ); write_string_to_grid( if ascii_drawing { "+" } else { "┛" }, @@ -2027,7 +2027,7 @@ impl Selector { Color::Default, Attr::Default, ((width - 1, height - 1), (width - 1, height - 1)), - false, + None, ); for i in 1..height - 1 { write_string_to_grid( @@ -2037,7 +2037,7 @@ impl Selector { Color::Default, Attr::Default, ((0, i), (width - 1, i)), - false, + None, ); write_string_to_grid( if ascii_drawing { "|" } else { "┃" }, @@ -2046,7 +2046,7 @@ impl Selector { Color::Default, Attr::Default, ((width - 1, i), (width - 1, i)), - false, + None, ); } if single_only { @@ -2062,7 +2062,7 @@ impl Selector { }, Attr::Default, ((2, i + 2), (width - 1, i + 2)), - false, + None, ); } } else { @@ -2074,7 +2074,7 @@ impl Selector { Color::Default, Attr::Default, ((2, i + 2), (width - 1, i + 2)), - false, + None, ); if i == 0 { content[(2, i + 2)].set_bg(Color::Byte(8)); @@ -2092,7 +2092,7 @@ impl Selector { ((width - "OK Cancel".len()) / 2, height - 3), (width - 1, height - 3), ), - false, + None, ); } let mut identifiers: Vec<(T, bool)> = diff --git a/ui/src/components/utilities/widgets.rs b/ui/src/components/utilities/widgets.rs index 7e0e5404..29538b2b 100644 --- a/ui/src/components/utilities/widgets.rs +++ b/ui/src/components/utilities/widgets.rs @@ -120,7 +120,7 @@ impl Component for Field { Color::Default, Attr::Default, area, - true, + None, ); } fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool { @@ -351,7 +351,7 @@ impl Component for FormWidget { pos_inc(upper_left, (1, i)), set_y(bottom_right, i + get_y(upper_left)), ), - false, + None, ); /* draw field */ v.draw( @@ -595,7 +595,7 @@ where pos_inc(upper_left, (len, 0)), pos_inc(upper_left, (cur_len + len, 0)), ), - false, + None, ); len += cur_len + 3; } @@ -778,7 +778,7 @@ impl AutoComplete { Color::Byte(7), Attr::Default, ((0, i), (width - 1, i)), - false, + None, ); write_string_to_grid( &e.description, @@ -787,7 +787,7 @@ impl AutoComplete { Color::Byte(7), Attr::Default, ((x + 2, i), (width - 1, i)), - false, + None, ); write_string_to_grid( "▒", @@ -796,7 +796,7 @@ impl AutoComplete { Color::Byte(7), Attr::Default, ((width - 1, i), (width - 1, i)), - false, + None, ); } self.content = content; diff --git a/ui/src/terminal/cells.rs b/ui/src/terminal/cells.rs index 7183b182..13fdd164 100644 --- a/ui/src/terminal/cells.rs +++ b/ui/src/terminal/cells.rs @@ -770,8 +770,10 @@ macro_rules! inspect_bounds { } else { $x = get_x(upper_left); $y += 1; - if !$line_break { + if $line_break.is_none() { break; + } else { + $x = $line_break.unwrap(); } } } @@ -793,7 +795,8 @@ pub fn write_string_to_grid( bg_color: Color, attrs: Attr, area: Area, - line_break: bool, + // The left-most x coordinate. + line_break: Option, ) -> Pos { let bounds = grid.size(); let upper_left = upper_left!(area);