feat(tui): W puts the pane layout back
Hiding panes with w and zooming with z had no way back short of pressing each hidden pane's number and Esc. W shows every pane and leaves zoom in one go, and the shortcut bar offers it only while there is a layout to reset.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use super::MainTui;
|
||||
use crate::models::{CommandBarMode, FocusedPane, LogView};
|
||||
use crate::models::{CommandBarMode, FocusedPane, LogView, PaneLayout};
|
||||
use crate::ui::page_of;
|
||||
use crate::ui::panes::{
|
||||
InfoSubject, name_end_offset, query_end_offset, selected_transfer,
|
||||
@@ -100,6 +100,10 @@ impl MainTui {
|
||||
self.state.hide_focused_pane();
|
||||
return;
|
||||
}
|
||||
KeyCode::Char('W') => {
|
||||
self.state.layout = PaneLayout::default();
|
||||
return;
|
||||
}
|
||||
KeyCode::Esc if self.state.layout.zoomed => {
|
||||
self.state.layout.zoomed = false;
|
||||
return;
|
||||
|
||||
@@ -1818,6 +1818,26 @@ mod tests {
|
||||
assert!(screen.contains("[C → clear all]"), "{screen}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shift_w_brings_every_pane_back_and_leaves_zoom() {
|
||||
let mut tui = furnished_tui();
|
||||
tui.state.focused_pane = FocusedPane::Searches;
|
||||
assert!(!screen_sized(&mut tui, 300, 40).contains("[W → "));
|
||||
press(&mut tui, KeyCode::Char('w'));
|
||||
press(&mut tui, KeyCode::Char('z'));
|
||||
assert!(tui.state.layout.zoomed);
|
||||
assert!(!tui.state.layout.is_visible(FocusedPane::Searches));
|
||||
let screen = screen_sized(&mut tui, 300, 40);
|
||||
assert!(screen.contains("[W → reset layout]"), "{screen}");
|
||||
press(&mut tui, KeyCode::Char('W'));
|
||||
assert!(!tui.state.layout.zoomed);
|
||||
assert!(
|
||||
FocusedPane::ALL
|
||||
.iter()
|
||||
.all(|p| tui.state.layout.is_visible(*p))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn page_keys_work_in_the_transfers_and_searches_lists_too() {
|
||||
let mut tui = furnished_tui();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::MainTui;
|
||||
use crate::models::{CommandBarMode, FocusedPane, RoomsView};
|
||||
use crate::models::{CommandBarMode, FocusedPane, PaneLayout, RoomsView};
|
||||
use crate::ui::panes::{
|
||||
InfoSubject, ResultsPaneParams, render_browse_pane, render_chat_pane,
|
||||
render_download_info_pane, render_downloads_pane, render_results_pane,
|
||||
@@ -29,6 +29,7 @@ const HELP_LEFT: &[(&str, &[(&str, &str)])] = &[
|
||||
("z", "zoom the focused pane"),
|
||||
("w", "hide the focused pane"),
|
||||
("Esc", "leave zoom"),
|
||||
("W", "every pane back, zoom off"),
|
||||
("click", "focus a pane"),
|
||||
],
|
||||
),
|
||||
@@ -497,7 +498,7 @@ impl MainTui {
|
||||
/// The keys every pane shares for moving between and resizing panes,
|
||||
/// ending the bar the same way wherever the focus sits.
|
||||
fn pane_shortcuts(&self) -> Vec<(&'static str, &'static str)> {
|
||||
vec![
|
||||
let mut keys = vec![
|
||||
("Tab/1-3", "pane"),
|
||||
(
|
||||
"z",
|
||||
@@ -508,9 +509,13 @@ impl MainTui {
|
||||
},
|
||||
),
|
||||
("w", "hide"),
|
||||
("?", "keys"),
|
||||
("q", "quit"),
|
||||
]
|
||||
];
|
||||
// Only once a pane is hidden or zoomed is there a layout to reset.
|
||||
if self.state.layout != PaneLayout::default() {
|
||||
keys.push(("W", "reset layout"));
|
||||
}
|
||||
keys.extend([("?", "keys"), ("q", "quit")]);
|
||||
keys
|
||||
}
|
||||
|
||||
/// Which shortcuts the bar offers, which is purely a question of what is
|
||||
|
||||
Reference in New Issue
Block a user