diff --git a/src/ui/activities/auth/components/mod.rs b/src/ui/activities/auth/components/mod.rs index 4791f4f..c7c4330 100644 --- a/src/ui/activities/auth/components/mod.rs +++ b/src/ui/activities/auth/components/mod.rs @@ -44,7 +44,7 @@ pub use popup::{ ErrorPopup, InfoPopup, InstallUpdatePopup, Keybindings, QuitPopup, ReleaseNotes, WaitPopup, WindowSizeError, }; -pub use text::{HelpText, NewVersionDisclaimer, Subtitle, Title}; +pub use text::{HelpFooter, NewVersionDisclaimer, Subtitle, Title}; use tui_realm_stdlib::Phantom; use tuirealm::event::{Event, Key, KeyEvent, KeyModifiers, NoUserEvent}; @@ -60,7 +60,10 @@ pub struct GlobalListener { impl Component for GlobalListener { fn on(&mut self, ev: Event) -> Option { match ev { - Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => Some(Msg::ShowQuitPopup), + Event::Keyboard(KeyEvent { + code: Key::Esc | Key::Function(10), + .. + }) => Some(Msg::ShowQuitPopup), Event::Keyboard(KeyEvent { code: Key::Char('c'), modifiers: KeyModifiers::CONTROL, @@ -69,6 +72,10 @@ impl Component for GlobalListener { code: Key::Char('h'), modifiers: KeyModifiers::CONTROL, }) => Some(Msg::ShowKeybindingsPopup), + Event::Keyboard(KeyEvent { + code: Key::Function(1), + .. + }) => Some(Msg::ShowKeybindingsPopup), Event::Keyboard(KeyEvent { code: Key::Char('r'), modifiers: KeyModifiers::CONTROL, diff --git a/src/ui/activities/auth/components/text.rs b/src/ui/activities/auth/components/text.rs index c2f7fa7..2e32324 100644 --- a/src/ui/activities/auth/components/text.rs +++ b/src/ui/activities/auth/components/text.rs @@ -104,28 +104,35 @@ impl Component for NewVersionDisclaimer { } } -// -- HelpText +// -- HelpFooter #[derive(MockComponent)] -pub struct HelpText { +pub struct HelpFooter { component: Span, } -impl HelpText { +impl HelpFooter { pub fn new(key_color: Color) -> Self { Self { component: Span::default().spans(&[ - TextSpan::new("Press ").bold(), - TextSpan::new("").bold().fg(key_color), - TextSpan::new(" to show keybindings; ").bold(), - TextSpan::new("").bold().fg(key_color), - TextSpan::new(" to enter setup").bold(), + TextSpan::from("").bold().fg(key_color), + TextSpan::from(" Help "), + TextSpan::from("").bold().fg(key_color), + TextSpan::from(" Enter setup "), + TextSpan::from("").bold().fg(key_color), + TextSpan::from(" Change field "), + TextSpan::from("").bold().fg(key_color), + TextSpan::from(" Switch tab "), + TextSpan::from("").bold().fg(key_color), + TextSpan::from(" Submit form "), + TextSpan::from("").bold().fg(key_color), + TextSpan::from(" Quit "), ]), } } } -impl Component for HelpText { +impl Component for HelpFooter { fn on(&mut self, _ev: Event) -> Option { None } diff --git a/src/ui/activities/auth/mod.rs b/src/ui/activities/auth/mod.rs index 2c8fd28..56e4211 100644 --- a/src/ui/activities/auth/mod.rs +++ b/src/ui/activities/auth/mod.rs @@ -55,7 +55,7 @@ pub enum Id { DeleteRecentPopup, ErrorPopup, GlobalListener, - HelpText, + HelpFooter, InfoPopup, InstallUpdatePopup, Keybindings, diff --git a/src/ui/activities/auth/view.rs b/src/ui/activities/auth/view.rs index e5a979a..9d2b1c6 100644 --- a/src/ui/activities/auth/view.rs +++ b/src/ui/activities/auth/view.rs @@ -58,8 +58,8 @@ impl AuthActivity { assert!(self .app .mount( - Id::HelpText, - Box::new(components::HelpText::new(key_color)), + Id::HelpFooter, + Box::new(components::HelpFooter::new(key_color)), vec![] ) .is_ok()); @@ -111,17 +111,30 @@ impl AuthActivity { let height: u16 = f.size().height; self.check_minimum_window_size(height); // Prepare chunks - let chunks = Layout::default() + let body = Layout::default() .direction(Direction::Vertical) - .margin(1) .constraints( [ - Constraint::Length(21), // Auth Form - Constraint::Min(3), // Bookmarks + Constraint::Min(24), // Body + Constraint::Length(1), // Footer ] .as_ref(), ) .split(f.size()); + // Footer + self.app.view(&Id::HelpFooter, f, body[1]); + let auth_form_len = 7 + self.input_mask_size(); + let main_chunks = Layout::default() + .direction(Direction::Vertical) + .margin(1) + .constraints( + [ + Constraint::Length(auth_form_len), // Auth Form + Constraint::Min(3), // Bookmarks + ] + .as_ref(), + ) + .split(body[0]); // Create explorer chunks let auth_chunks = Layout::default() .constraints( @@ -131,12 +144,12 @@ impl AuthActivity { Constraint::Length(1), // Version Constraint::Length(3), // protocol Constraint::Length(self.input_mask_size()), // Input mask - Constraint::Length(3), // footer + Constraint::Length(1), // Prevents last field to overflow ] .as_ref(), ) .direction(Direction::Vertical) - .split(chunks[0]); + .split(main_chunks[0]); // Input mask chunks let input_mask = match self.input_mask() { InputMask::AwsS3 => Layout::default() @@ -167,7 +180,7 @@ impl AuthActivity { let bookmark_chunks = Layout::default() .constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref()) .direction(Direction::Horizontal) - .split(chunks[1]); + .split(main_chunks[1]); // Render // Auth chunks self.app.view(&Id::Title, f, auth_chunks[0]); @@ -188,7 +201,6 @@ impl AuthActivity { self.app.view(&Id::Password, f, input_mask[3]); } } - self.app.view(&Id::HelpText, f, auth_chunks[5]); // Bookmark chunks self.app.view(&Id::BookmarksList, f, bookmark_chunks[0]); self.app.view(&Id::RecentsList, f, bookmark_chunks[1]); @@ -788,6 +800,13 @@ impl AuthActivity { }), Self::no_popup_mounted_clause(), ), + Sub::new( + SubEventClause::Keyboard(KeyEvent { + code: Key::Function(10), + modifiers: KeyModifiers::NONE, + }), + Self::no_popup_mounted_clause(), + ), Sub::new( SubEventClause::Keyboard(KeyEvent { code: Key::Char('c'), @@ -802,6 +821,13 @@ impl AuthActivity { }), Self::no_popup_mounted_clause(), ), + Sub::new( + SubEventClause::Keyboard(KeyEvent { + code: Key::Function(1), + modifiers: KeyModifiers::NONE, + }), + Self::no_popup_mounted_clause(), + ), Sub::new( SubEventClause::Keyboard(KeyEvent { code: Key::Char('r'), diff --git a/src/ui/activities/filetransfer/components/misc.rs b/src/ui/activities/filetransfer/components/misc.rs index 0b95096..ef903be 100644 --- a/src/ui/activities/filetransfer/components/misc.rs +++ b/src/ui/activities/filetransfer/components/misc.rs @@ -40,27 +40,27 @@ impl FooterBar { pub fn new(key_color: Color) -> Self { Self { component: Span::default().spans(&[ - TextSpan::from("").fg(key_color), + TextSpan::from("").bold().fg(key_color), TextSpan::from(" Help "), - TextSpan::from("").fg(key_color), + TextSpan::from("").bold().fg(key_color), TextSpan::from(" Change tab "), - TextSpan::from("").fg(key_color), + TextSpan::from("").bold().fg(key_color), TextSpan::from(" Transfer "), - TextSpan::from("").fg(key_color), + TextSpan::from("").bold().fg(key_color), TextSpan::from(" Enter dir "), - TextSpan::from("").fg(key_color), + TextSpan::from("").bold().fg(key_color), TextSpan::from(" View "), - TextSpan::from("").fg(key_color), + TextSpan::from("").bold().fg(key_color), TextSpan::from(" Edit "), - TextSpan::from("").fg(key_color), + TextSpan::from("").bold().fg(key_color), TextSpan::from(" Copy "), - TextSpan::from("").fg(key_color), + TextSpan::from("").bold().fg(key_color), TextSpan::from(" Rename "), - TextSpan::from("").fg(key_color), + TextSpan::from("").bold().fg(key_color), TextSpan::from(" Make dir "), - TextSpan::from("").fg(key_color), + TextSpan::from("").bold().fg(key_color), TextSpan::from(" Make dir "), - TextSpan::from("").fg(key_color), + TextSpan::from("").bold().fg(key_color), TextSpan::from(" Quit "), ]), } diff --git a/src/ui/activities/setup/components/commons.rs b/src/ui/activities/setup/components/commons.rs index bd62000..e9f212c 100644 --- a/src/ui/activities/setup/components/commons.rs +++ b/src/ui/activities/setup/components/commons.rs @@ -76,13 +76,16 @@ impl Default for Footer { fn default() -> Self { Self { component: Span::default().spans(&[ - TextSpan::new("Press ").bold(), - TextSpan::new("").bold().fg(Color::Cyan), - TextSpan::new(" to show keybindings; ").bold(), - TextSpan::new("").bold().fg(Color::Cyan), - TextSpan::new(" to save parameters; ").bold(), + TextSpan::new("").bold().fg(Color::Cyan), + TextSpan::new(" Help "), + TextSpan::new("").bold().fg(Color::Cyan), + TextSpan::new(" Save parameters "), + TextSpan::new("").bold().fg(Color::Cyan), + TextSpan::new(" Exit "), TextSpan::new("").bold().fg(Color::Cyan), - TextSpan::new(" to change panel").bold(), + TextSpan::new(" Change panel "), + TextSpan::new("").bold().fg(Color::Cyan), + TextSpan::new(" Change field "), ]), } } diff --git a/src/ui/activities/setup/components/mod.rs b/src/ui/activities/setup/components/mod.rs index 841dad0..7be6352 100644 --- a/src/ui/activities/setup/components/mod.rs +++ b/src/ui/activities/setup/components/mod.rs @@ -54,9 +54,10 @@ pub struct GlobalListener { impl Component for GlobalListener { fn on(&mut self, ev: Event) -> Option { match ev { - Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => { - Some(Msg::Common(CommonMsg::ShowQuitPopup)) - } + Event::Keyboard(KeyEvent { + code: Key::Esc | Key::Function(10), + .. + }) => Some(Msg::Common(CommonMsg::ShowQuitPopup)), Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => { Some(Msg::Common(CommonMsg::ChangeLayout)) } @@ -64,6 +65,10 @@ impl Component for GlobalListener { code: Key::Char('h'), modifiers: KeyModifiers::CONTROL, }) => Some(Msg::Common(CommonMsg::ShowKeybindings)), + Event::Keyboard(KeyEvent { + code: Key::Function(1), + modifiers: KeyModifiers::NONE, + }) => Some(Msg::Common(CommonMsg::ShowKeybindings)), Event::Keyboard(KeyEvent { code: Key::Char('r'), modifiers: KeyModifiers::CONTROL, @@ -72,6 +77,10 @@ impl Component for GlobalListener { code: Key::Char('s'), modifiers: KeyModifiers::CONTROL, }) => Some(Msg::Common(CommonMsg::ShowSavePopup)), + Event::Keyboard(KeyEvent { + code: Key::Function(4), + modifiers: KeyModifiers::NONE, + }) => Some(Msg::Common(CommonMsg::ShowSavePopup)), _ => None, } } diff --git a/src/ui/activities/setup/view/mod.rs b/src/ui/activities/setup/view/mod.rs index 1f36e19..796a601 100644 --- a/src/ui/activities/setup/view/mod.rs +++ b/src/ui/activities/setup/view/mod.rs @@ -206,6 +206,13 @@ impl SetupActivity { }), Self::no_popup_mounted_clause(), ), + Sub::new( + SubEventClause::Keyboard(KeyEvent { + code: Key::Function(10), + modifiers: KeyModifiers::NONE, + }), + Self::no_popup_mounted_clause(), + ), Sub::new( SubEventClause::Keyboard(KeyEvent { code: Key::Tab, @@ -220,6 +227,13 @@ impl SetupActivity { }), Self::no_popup_mounted_clause(), ), + Sub::new( + SubEventClause::Keyboard(KeyEvent { + code: Key::Function(1), + modifiers: KeyModifiers::NONE, + }), + Self::no_popup_mounted_clause(), + ), Sub::new( SubEventClause::Keyboard(KeyEvent { code: Key::Char('r'), @@ -234,6 +248,13 @@ impl SetupActivity { }), Self::no_popup_mounted_clause(), ), + Sub::new( + SubEventClause::Keyboard(KeyEvent { + code: Key::Function(4), + modifiers: KeyModifiers::NONE, + }), + Self::no_popup_mounted_clause(), + ), ] ) .is_ok()); diff --git a/src/ui/activities/setup/view/setup.rs b/src/ui/activities/setup/view/setup.rs index 14ede28..65566a9 100644 --- a/src/ui/activities/setup/view/setup.rs +++ b/src/ui/activities/setup/view/setup.rs @@ -59,9 +59,9 @@ impl SetupActivity { .margin(1) .constraints( [ - Constraint::Length(3), // Current tab - Constraint::Length(18), // Main body - Constraint::Length(3), // Help footer + Constraint::Length(3), // Current tab + Constraint::Min(18), // Main body + Constraint::Length(1), // Help footer ] .as_ref(), ) @@ -85,6 +85,7 @@ impl SetupActivity { Constraint::Length(3), // Updates tab Constraint::Length(3), // Prompt file replace Constraint::Length(3), // Group dirs + Constraint::Length(1), // Prevent overflow ] .as_ref(), ) @@ -120,7 +121,7 @@ impl SetupActivity { Constraint::Length(3), // Notifications enabled Constraint::Length(3), // Notifications threshold Constraint::Length(3), // Ssh config - Constraint::Length(1), // Filler + Constraint::Length(1), // Prevent overflow ] .as_ref(), ) diff --git a/src/ui/activities/setup/view/ssh_keys.rs b/src/ui/activities/setup/view/ssh_keys.rs index e029ecb..19f5fc6 100644 --- a/src/ui/activities/setup/view/ssh_keys.rs +++ b/src/ui/activities/setup/view/ssh_keys.rs @@ -56,9 +56,9 @@ impl SetupActivity { .margin(1) .constraints( [ - Constraint::Length(3), // Current tab - Constraint::Percentage(90), // Main body - Constraint::Length(3), // Help footer + Constraint::Length(3), // Current tab + Constraint::Min(5), // Main body + Constraint::Length(1), // Help footer ] .as_ref(), ) diff --git a/src/ui/activities/setup/view/theme.rs b/src/ui/activities/setup/view/theme.rs index c1cf2f2..8990136 100644 --- a/src/ui/activities/setup/view/theme.rs +++ b/src/ui/activities/setup/view/theme.rs @@ -56,9 +56,9 @@ impl SetupActivity { .margin(1) .constraints( [ - Constraint::Length(3), // Current tab - Constraint::Length(22), // Main body - Constraint::Length(3), // Help footer + Constraint::Length(3), // Current tab + Constraint::Min(22), // Main body + Constraint::Length(1), // Help footer ] .as_ref(), ) @@ -91,6 +91,7 @@ impl SetupActivity { Constraint::Length(3), // Password Constraint::Length(3), // Bookmarks Constraint::Length(3), // Recents + Constraint::Length(1), // Prevent overflow ] .as_ref(), ) @@ -126,6 +127,7 @@ impl SetupActivity { Constraint::Length(3), // Quit Constraint::Length(3), // Save Constraint::Length(3), // Warn + Constraint::Length(1), // Prevent overflow ] .as_ref(), ) @@ -158,7 +160,7 @@ impl SetupActivity { Constraint::Length(3), // remote explorer bg Constraint::Length(3), // remote explorer fg Constraint::Length(3), // remote explorer hg - Constraint::Length(3), // empty + Constraint::Length(1), // Prevent overflow ] .as_ref(), ) @@ -210,6 +212,7 @@ impl SetupActivity { Constraint::Length(3), // status sorting Constraint::Length(3), // status hidden Constraint::Length(3), // sync browsing + Constraint::Length(1), // Prevent overflow ] .as_ref(), )