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),
|
coordinates: (usize, usize, usize),
|
||||||
mailview: MailView,
|
mailview: MailView,
|
||||||
show_mailview: bool,
|
show_mailview: bool,
|
||||||
|
show_thread: bool,
|
||||||
entries: Vec<ThreadEntry>,
|
entries: Vec<ThreadEntry>,
|
||||||
visible_entries: Vec<Vec<usize>>,
|
visible_entries: Vec<Vec<usize>>,
|
||||||
|
|
||||||
|
@ -83,6 +84,7 @@ impl ThreadView {
|
||||||
coordinates,
|
coordinates,
|
||||||
mailview: MailView::default(),
|
mailview: MailView::default(),
|
||||||
show_mailview: true,
|
show_mailview: true,
|
||||||
|
show_thread: true,
|
||||||
entries: Vec::new(),
|
entries: Vec::new(),
|
||||||
cursor_pos: 1,
|
cursor_pos: 1,
|
||||||
new_cursor_pos: 0,
|
new_cursor_pos: 0,
|
||||||
|
@ -678,18 +680,24 @@ impl ThreadView {
|
||||||
grid[(x, y - 1)].set_bg(Color::Default);
|
grid[(x, y - 1)].set_bg(Color::Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.show_mailview {
|
match (self.show_mailview, self.show_thread) {
|
||||||
self.draw_list(
|
(true, true) => {
|
||||||
grid,
|
self.draw_list(
|
||||||
(set_y(upper_left, y), set_x(bottom_right, mid - 1)),
|
grid,
|
||||||
context,
|
(set_y(upper_left, y), set_x(bottom_right, mid - 1)),
|
||||||
);
|
context,
|
||||||
let upper_left = (mid + 1, get_y(upper_left) + y - 1);
|
);
|
||||||
self.mailview
|
let upper_left = (mid + 1, get_y(upper_left) + y - 1);
|
||||||
.draw(grid, (upper_left, bottom_right), context);
|
self.mailview
|
||||||
} else {
|
.draw(grid, (upper_left, bottom_right), context);
|
||||||
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, 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) {
|
fn draw_horz(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||||
|
@ -766,60 +774,70 @@ impl ThreadView {
|
||||||
clear_area(grid, (set_y(upper_left, y), bottom_right));
|
clear_area(grid, (set_y(upper_left, y), bottom_right));
|
||||||
let (width, height) = self.content.size();
|
let (width, height) = self.content.size();
|
||||||
|
|
||||||
if self.show_mailview {
|
match (self.show_mailview, self.show_thread) {
|
||||||
let area = (set_y(upper_left, y), set_y(bottom_right, mid));
|
(true, true) => {
|
||||||
let upper_left = upper_left!(area);
|
let area = (set_y(upper_left, y), set_y(bottom_right, mid));
|
||||||
let bottom_right = bottom_right!(area);
|
let upper_left = upper_left!(area);
|
||||||
|
let bottom_right = bottom_right!(area);
|
||||||
|
|
||||||
let rows = (get_y(bottom_right).saturating_sub(get_y(upper_left) + 1)) / 2;
|
let rows = (get_y(bottom_right).saturating_sub(get_y(upper_left) + 1)) / 2;
|
||||||
if rows == 0 {
|
if rows == 0 {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
let page_no = (self.new_cursor_pos).wrapping_div(rows);
|
||||||
|
let top_idx = page_no * rows;
|
||||||
|
|
||||||
|
copy_area(
|
||||||
|
grid,
|
||||||
|
&self.content,
|
||||||
|
area,
|
||||||
|
((0, 2 * top_idx), (width - 1, height - 1)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let page_no = (self.new_cursor_pos).wrapping_div(rows);
|
(false, true) => {
|
||||||
let top_idx = page_no * rows;
|
let area = (set_y(upper_left, y), bottom_right);
|
||||||
|
let upper_left = upper_left!(area);
|
||||||
|
|
||||||
copy_area(
|
let rows = (get_y(bottom_right).saturating_sub(get_y(upper_left) + 1)) / 2;
|
||||||
grid,
|
if rows == 0 {
|
||||||
&self.content,
|
return;
|
||||||
area,
|
}
|
||||||
((0, 2 * top_idx), (width - 1, height - 1)),
|
let page_no = (self.new_cursor_pos).wrapping_div(rows);
|
||||||
);
|
let top_idx = page_no * rows;
|
||||||
} else {
|
copy_area(
|
||||||
let area = (set_y(upper_left, y), bottom_right);
|
grid,
|
||||||
let upper_left = upper_left!(area);
|
&self.content,
|
||||||
|
area,
|
||||||
let rows = (get_y(bottom_right).saturating_sub(get_y(upper_left) + 1)) / 2;
|
((0, 2 * top_idx), (width - 1, height - 1)),
|
||||||
if rows == 0 {
|
);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
let page_no = (self.new_cursor_pos).wrapping_div(rows);
|
(_, false) => { /* show only envelope */ }
|
||||||
let top_idx = page_no * rows;
|
|
||||||
copy_area(
|
|
||||||
grid,
|
|
||||||
&self.content,
|
|
||||||
area,
|
|
||||||
((0, 2 * top_idx), (width - 1, height - 1)),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
context.dirty_areas.push_back(area);
|
context.dirty_areas.push_back(area);
|
||||||
self.initiated = true;
|
self.initiated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.show_mailview {
|
match (self.show_mailview, self.show_thread) {
|
||||||
let area = (set_y(upper_left, mid), set_y(bottom_right, mid));
|
(true, true) => {
|
||||||
context.dirty_areas.push_back(area);
|
let area = (set_y(upper_left, mid), set_y(bottom_right, mid));
|
||||||
for x in get_x(upper_left)..=get_x(bottom_right) {
|
context.dirty_areas.push_back(area);
|
||||||
set_and_join_box(grid, (x, mid), HORZ_BOUNDARY);
|
for x in get_x(upper_left)..=get_x(bottom_right) {
|
||||||
grid[(x, mid)].set_fg(Color::Default);
|
set_and_join_box(grid, (x, mid), HORZ_BOUNDARY);
|
||||||
grid[(x, mid)].set_bg(Color::Default);
|
grid[(x, mid)].set_fg(Color::Default);
|
||||||
|
grid[(x, mid)].set_bg(Color::Default);
|
||||||
|
}
|
||||||
|
let area = (set_y(upper_left, y), set_y(bottom_right, mid - 1));
|
||||||
|
self.draw_list(grid, area, context);
|
||||||
|
self.mailview
|
||||||
|
.draw(grid, (set_y(upper_left, mid + 1), bottom_right), context);
|
||||||
|
}
|
||||||
|
(false, true) => {
|
||||||
|
self.dirty = true;
|
||||||
|
self.draw_list(grid, (set_y(upper_left, y), bottom_right), context);
|
||||||
|
}
|
||||||
|
(_, false) => {
|
||||||
|
self.mailview.draw(grid, area, context);
|
||||||
}
|
}
|
||||||
let area = (set_y(upper_left, y), set_y(bottom_right, mid - 1));
|
|
||||||
self.draw_list(grid, area, context);
|
|
||||||
self.mailview
|
|
||||||
.draw(grid, (set_y(upper_left, mid + 1), bottom_right), context);
|
|
||||||
} else {
|
|
||||||
self.dirty = true;
|
|
||||||
self.draw_list(grid, (set_y(upper_left, y), bottom_right), context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -997,6 +1015,12 @@ impl Component for ThreadView {
|
||||||
self.set_dirty();
|
self.set_dirty();
|
||||||
return true;
|
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')) => {
|
UIEvent::Input(Key::Ctrl('r')) => {
|
||||||
self.reversed = !self.reversed;
|
self.reversed = !self.reversed;
|
||||||
let expanded_hash = self.entries[self.expanded_pos].index.1;
|
let expanded_hash = self.entries[self.expanded_pos].index.1;
|
||||||
|
|
Loading…
Reference in New Issue