ui/threadview: add show_thread shortcut
Press 't' by default to toggle thread visibilityjmap
parent
f3c938d8c3
commit
678889d706
|
@ -54,6 +54,7 @@ pub struct ThreadView {
|
|||
coordinates: (usize, usize, usize),
|
||||
mailview: MailView,
|
||||
show_mailview: bool,
|
||||
show_thread: bool,
|
||||
entries: Vec<ThreadEntry>,
|
||||
visible_entries: Vec<Vec<usize>>,
|
||||
|
||||
|
@ -83,6 +84,7 @@ impl ThreadView {
|
|||
coordinates,
|
||||
mailview: MailView::default(),
|
||||
show_mailview: true,
|
||||
show_thread: true,
|
||||
entries: Vec::new(),
|
||||
cursor_pos: 1,
|
||||
new_cursor_pos: 0,
|
||||
|
@ -678,7 +680,8 @@ impl ThreadView {
|
|||
grid[(x, y - 1)].set_bg(Color::Default);
|
||||
}
|
||||
|
||||
if self.show_mailview {
|
||||
match (self.show_mailview, self.show_thread) {
|
||||
(true, true) => {
|
||||
self.draw_list(
|
||||
grid,
|
||||
(set_y(upper_left, y), set_x(bottom_right, mid - 1)),
|
||||
|
@ -687,10 +690,15 @@ impl ThreadView {
|
|||
let upper_left = (mid + 1, get_y(upper_left) + y - 1);
|
||||
self.mailview
|
||||
.draw(grid, (upper_left, bottom_right), context);
|
||||
} else {
|
||||
}
|
||||
(false, true) => {
|
||||
clear_area(grid, ((mid + 1, get_y(upper_left) + y - 1), bottom_right));
|
||||
self.draw_list(grid, (set_y(upper_left, y), bottom_right), context);
|
||||
}
|
||||
(_, false) => {
|
||||
self.mailview.draw(grid, area, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
fn draw_horz(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||
let upper_left = upper_left!(area);
|
||||
|
@ -766,7 +774,8 @@ impl ThreadView {
|
|||
clear_area(grid, (set_y(upper_left, y), bottom_right));
|
||||
let (width, height) = self.content.size();
|
||||
|
||||
if self.show_mailview {
|
||||
match (self.show_mailview, self.show_thread) {
|
||||
(true, true) => {
|
||||
let area = (set_y(upper_left, y), set_y(bottom_right, mid));
|
||||
let upper_left = upper_left!(area);
|
||||
let bottom_right = bottom_right!(area);
|
||||
|
@ -784,7 +793,8 @@ impl ThreadView {
|
|||
area,
|
||||
((0, 2 * top_idx), (width - 1, height - 1)),
|
||||
);
|
||||
} else {
|
||||
}
|
||||
(false, true) => {
|
||||
let area = (set_y(upper_left, y), bottom_right);
|
||||
let upper_left = upper_left!(area);
|
||||
|
||||
|
@ -801,11 +811,14 @@ impl ThreadView {
|
|||
((0, 2 * top_idx), (width - 1, height - 1)),
|
||||
);
|
||||
}
|
||||
(_, false) => { /* show only envelope */ }
|
||||
}
|
||||
context.dirty_areas.push_back(area);
|
||||
self.initiated = true;
|
||||
}
|
||||
|
||||
if self.show_mailview {
|
||||
match (self.show_mailview, self.show_thread) {
|
||||
(true, true) => {
|
||||
let area = (set_y(upper_left, mid), set_y(bottom_right, mid));
|
||||
context.dirty_areas.push_back(area);
|
||||
for x in get_x(upper_left)..=get_x(bottom_right) {
|
||||
|
@ -817,10 +830,15 @@ impl ThreadView {
|
|||
self.draw_list(grid, area, context);
|
||||
self.mailview
|
||||
.draw(grid, (set_y(upper_left, mid + 1), bottom_right), context);
|
||||
} else {
|
||||
}
|
||||
(false, true) => {
|
||||
self.dirty = true;
|
||||
self.draw_list(grid, (set_y(upper_left, y), bottom_right), context);
|
||||
}
|
||||
(_, false) => {
|
||||
self.mailview.draw(grid, area, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn recalc_visible_entries(&mut self) {
|
||||
|
@ -997,6 +1015,12 @@ impl Component for ThreadView {
|
|||
self.set_dirty();
|
||||
return true;
|
||||
}
|
||||
UIEvent::Input(Key::Char('t')) => {
|
||||
self.show_thread = !self.show_thread;
|
||||
self.initiated = false;
|
||||
self.set_dirty();
|
||||
return true;
|
||||
}
|
||||
UIEvent::Input(Key::Ctrl('r')) => {
|
||||
self.reversed = !self.reversed;
|
||||
let expanded_hash = self.entries[self.expanded_pos].index.1;
|
||||
|
|
Loading…
Reference in New Issue