mail/view/thread: add toggle_layout shortcut
Tests / Test on ${{ matrix.build }} (linux-amd64, ubuntu-latest, stable, x86_64-unknown-linux-gnu) (pull_request) Successful in 14m12s Details
Tests / Test on ${{ matrix.build }} (linux-amd64, ubuntu-latest, stable, x86_64-unknown-linux-gnu) (push) Successful in 7m52s Details

Toggles between horizontal and vertical layout. Previously it was
decided on the terminal width.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
pull/295/head
Manos Pitsidianakis 2023-09-02 21:47:14 +03:00
parent 49c36009ce
commit 0a9c89b6b3
Signed by: Manos Pitsidianakis
GPG Key ID: 7729C7707F7E09D0
3 changed files with 29 additions and 10 deletions

View File

@ -967,7 +967,7 @@ Scroll up list.
Scroll down list.
.Pq Em j \" default value
.It Ic collapse_subtree
collapse thread branches
collapse thread branches.
.Pq Em h \" default value
.It Ic next_page
Go to next page.
@ -976,14 +976,17 @@ Go to next page.
Go to previous page.
.Pq Em PageUp \" default value
.It Ic reverse_thread_order
reverse thread order
reverse thread order.
.Pq Em C-r \" default value
.It Ic toggle_mailview
toggle mail view visibility
toggle mail view visibility.
.Pq Em p \" default value
.It Ic toggle_threadview
toggle thread view visibility
toggle thread view visibility.
.Pq Em t \" default value
.It Ic toggle_layout
Toggle between horizontal and vertical layout.
.Pq Em Space \" default value
.El
.sp
.Sh NOTIFICATIONS

View File

@ -264,6 +264,7 @@ shortcut_key_values! { "thread-view",
prev_page |> "Go to previous page." |> Key::PageUp,
reverse_thread_order |> "reverse thread order" |> Key::Ctrl('r'),
toggle_mailview |> "toggle mail view visibility" |> Key::Char('p'),
toggle_threadview |> "toggle thread view visibility" |> Key::Char('t')
toggle_threadview |> "toggle thread view visibility" |> Key::Char('t'),
toggle_layout |> "Toggle between horizontal and vertical layout." |> Key::Char(' ')
}
}

View File

@ -62,7 +62,7 @@ pub struct ThreadView {
visible_entries: Vec<Vec<usize>>,
indentation_colors: [ThemeAttribute; 6],
use_color: bool,
horizontal: Option<bool>,
movement: Option<PageMovement>,
dirty: bool,
content: CellBuffer,
@ -104,6 +104,7 @@ impl ThreadView {
crate::conf::value(context, "mail.view.thread.indentation.f"),
],
use_color: context.settings.terminal.use_color(),
horizontal: None,
..Default::default()
};
view.initiate(expanded_hash, go_to_first_unread, context);
@ -794,7 +795,7 @@ impl ThreadView {
(set_y(upper_left, y), set_x(bottom_right, mid - 1)),
context,
);
let upper_left = (mid + 1, get_y(upper_left) + y - 1);
let upper_left = (mid + 1, get_y(upper_left));
self.entries[self.new_expanded_pos].mailview.draw(
grid,
(upper_left, bottom_right),
@ -1058,10 +1059,13 @@ impl Component for ThreadView {
self.entries[self.new_expanded_pos]
.mailview
.draw(grid, area, context);
} else if total_cols >= self.content.size().0 + 74 {
self.draw_vert(grid, area, context);
} else {
} else if self
.horizontal
.unwrap_or(total_cols >= self.content.size().0 + 74)
{
self.draw_horz(grid, area, context);
} else {
self.draw_vert(grid, area, context);
}
self.dirty = false;
}
@ -1096,6 +1100,17 @@ impl Component for ThreadView {
let shortcuts = self.shortcuts(context);
match *event {
UIEvent::Input(ref key)
if shortcut!(key == shortcuts[Shortcuts::THREAD_VIEW]["toggle_layout"]) =>
{
if let Some(ref mut v) = self.horizontal {
*v = !*v;
} else {
self.horizontal = Some(false);
}
self.set_dirty(true);
true
}
UIEvent::Input(ref key)
if shortcut!(key == shortcuts[Shortcuts::THREAD_VIEW]["scroll_up"]) =>
{