From a774aaebf645be8b366a83dace61acdf958602de Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sat, 30 Mar 2019 21:12:13 +0200 Subject: [PATCH] ui: fix boundary drawing in Thread view --- ui/src/components.rs | 27 +++++++++++++++++++-------- ui/src/components/mail/compose.rs | 4 +++- ui/src/components/mail/view/thread.rs | 14 +++++++++++--- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/ui/src/components.rs b/ui/src/components.rs index 08b57fcab..3e90ab94d 100644 --- a/ui/src/components.rs +++ b/ui/src/components.rs @@ -245,6 +245,7 @@ fn set_and_join_vert(grid: &mut CellBuffer, idx: Pos) -> u32 { break; } else if adj == 0b0100 { cell.set_ch(bin_to_ch(0b0101)); + cell.set_fg(Color::Byte(240)); bin_set |= 0b0100; break; } @@ -285,11 +286,12 @@ fn set_and_join_vert(grid: &mut CellBuffer, idx: Pos) -> u32 { if let Some(cell) = grid.get_mut(x, y - 1) { if let Some(adj) = ch_to_bin(cell.ch()) { cell.set_ch(bin_to_ch(adj | 0b1000)); - break; + cell.set_fg(Color::Byte(240)); + } else { + bin_set &= 0b1101; } } } - bin_set &= 0b1101; break; } @@ -303,10 +305,11 @@ fn set_and_join_vert(grid: &mut CellBuffer, idx: Pos) -> u32 { if let Some(cell) = grid.get_mut(x, y + 1) { if let Some(adj) = ch_to_bin(cell.ch()) { cell.set_ch(bin_to_ch(adj | 0b0010)); - break; + cell.set_fg(Color::Byte(240)); + } else { + bin_set &= 0b0111; } } - bin_set &= 0b0111; break; } @@ -337,6 +340,7 @@ fn set_and_join_horz(grid: &mut CellBuffer, idx: Pos) -> u32 { } else if adj == 0b0010 { bin_set |= 0b0010; cell.set_ch(bin_to_ch(0b1010)); + cell.set_fg(Color::Byte(240)); break; } } @@ -359,7 +363,9 @@ fn set_and_join_horz(grid: &mut CellBuffer, idx: Pos) -> u32 { bin_set |= 0b1000; break; } else if adj == 0b1000 { + bin_set |= 0b1000; cell.set_ch(bin_to_ch(0b1010)); + cell.set_fg(Color::Byte(240)); break; } } @@ -379,11 +385,12 @@ fn set_and_join_horz(grid: &mut CellBuffer, idx: Pos) -> u32 { if let Some(cell) = grid.get_mut(x - 1, y) { if let Some(adj) = ch_to_bin(cell.ch()) { cell.set_ch(bin_to_ch(adj | 0b0001)); - break; + cell.set_fg(Color::Byte(240)); + } else { + bin_set &= 0b1011; } } } - bin_set &= 0b1011; break; } @@ -397,10 +404,11 @@ fn set_and_join_horz(grid: &mut CellBuffer, idx: Pos) -> u32 { if let Some(cell) = grid.get_mut(x + 1, y) { if let Some(adj) = ch_to_bin(cell.ch()) { cell.set_ch(bin_to_ch(adj | 0b0100)); - break; + cell.set_fg(Color::Byte(240)); + } else { + bin_set &= 0b1110; } } - bin_set &= 0b1110; break; } @@ -429,6 +437,7 @@ pub(crate) fn set_and_join_box(grid: &mut CellBuffer, idx: Pos, ch: char) { }; grid[idx].set_ch(bin_to_ch(bin_set)); + grid[idx].set_fg(Color::Byte(240)); } pub fn create_box(grid: &mut CellBuffer, area: Area) { @@ -441,11 +450,13 @@ pub fn create_box(grid: &mut CellBuffer, area: Area) { for x in get_x(upper_left)..get_x(bottom_right) { grid[(x, get_y(upper_left))].set_ch(HORZ_BOUNDARY); grid[(x, get_y(bottom_right))].set_ch(HORZ_BOUNDARY); + grid[(x, get_y(bottom_right))].set_fg(Color::Byte(240)); } for y in get_y(upper_left)..get_y(bottom_right) { grid[(get_x(upper_left), y)].set_ch(VERT_BOUNDARY); grid[(get_x(bottom_right), y)].set_ch(VERT_BOUNDARY); + grid[(get_x(bottom_right), y)].set_fg(Color::Byte(240)); } set_and_join_box(grid, upper_left, HORZ_BOUNDARY); set_and_join_box(grid, set_x(upper_left, get_x(bottom_right)), HORZ_BOUNDARY); diff --git a/ui/src/components/mail/compose.rs b/ui/src/components/mail/compose.rs index 5ec254435..4584b4680 100644 --- a/ui/src/components/mail/compose.rs +++ b/ui/src/components/mail/compose.rs @@ -280,6 +280,8 @@ impl Component for Composer { grid[(mid, i)].set_fg(Color::Default); grid[(mid, i)].set_bg(Color::Default); } + grid[set_x(bottom_right, mid)].set_ch(VERT_BOUNDARY); // Enforce full vert bar at the bottom + grid[set_x(bottom_right, mid)].set_fg(Color::Byte(240)); } if self.dirty { @@ -298,7 +300,7 @@ impl Component for Composer { }; if width > 80 && self.reply_context.is_some() { - let area = (upper_left, set_x(bottom_right, mid - 1)); + let area = (pos_dec(upper_left, (0, 1)), set_x(bottom_right, mid - 1)); let view = &mut self.reply_context.as_mut().unwrap().1; view.set_dirty(); view.draw(grid, area, context); diff --git a/ui/src/components/mail/view/thread.rs b/ui/src/components/mail/view/thread.rs index c3ab0ff8a..654c66c0f 100644 --- a/ui/src/components/mail/view/thread.rs +++ b/ui/src/components/mail/view/thread.rs @@ -168,6 +168,7 @@ impl ThreadView { for i in ((e.index.0 * 4) + 1)..width - 1 { set_and_join_box(&mut content, (i, 2 * y + 1), HORZ_BOUNDARY); } + set_and_join_box(&mut content, (width - 1, 2 * y), VERT_BOUNDARY); set_and_join_box(&mut content, (width - 1, 2 * y + 1), VERT_BOUNDARY); } @@ -343,9 +344,6 @@ impl ThreadView { area, ((0, 2 * top_idx), (width - 1, height - 1)), ); - for y in get_y(upper_left)..=get_y(bottom_right) { - set_and_join_box(grid, (mid, y), VERT_BOUNDARY); - } } else { let area = (set_y(upper_left, y), bottom_right); let upper_left = upper_left!(area); @@ -377,6 +375,10 @@ impl ThreadView { } else { self.draw_list(grid, (set_y(upper_left, y), bottom_right), context); } + for x in get_x(upper_left)..=get_x(bottom_right) { + set_and_join_box(grid, (x, y - 1), HORZ_BOUNDARY); + } + } fn draw_horz(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) { let upper_left = upper_left!(area); @@ -486,6 +488,8 @@ impl ThreadView { context.dirty_areas.push_back(area); self.initiated = true; } + + if self.show_mailview { self.draw_list( grid, @@ -497,6 +501,10 @@ impl ThreadView { } else { self.draw_list(grid, (set_y(upper_left, y), bottom_right), context); } + + for x in get_x(upper_left)..=get_x(bottom_right) { + set_and_join_box(grid, (x, y - 1), HORZ_BOUNDARY); + } } }