From 29d3f325188647ca2fcc6fded6f28804180ae203 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Wed, 20 Nov 2024 23:04:45 -0700 Subject: [PATCH 1/4] refactor(tui): Gain better aesthetic for helper text. --- crates/turborepo-ui/src/tui/input.rs | 1 + crates/turborepo-ui/src/tui/pane.rs | 41 ++++++++++++++++------------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/crates/turborepo-ui/src/tui/input.rs b/crates/turborepo-ui/src/tui/input.rs index fb17dc5b19b8d..5354d2b7b22f5 100644 --- a/crates/turborepo-ui/src/tui/input.rs +++ b/crates/turborepo-ui/src/tui/input.rs @@ -115,6 +115,7 @@ fn translate_key_event(options: InputOptions, key_event: KeyEvent) -> Option Some(Event::Up), KeyCode::Down => Some(Event::Down), KeyCode::Enter => Some(Event::EnterInteractive), + KeyCode::Char('i') => Some(Event::EnterInteractive), _ => None, } } diff --git a/crates/turborepo-ui/src/tui/pane.rs b/crates/turborepo-ui/src/tui/pane.rs index 361743c7f4567..859c5472998e0 100644 --- a/crates/turborepo-ui/src/tui/pane.rs +++ b/crates/turborepo-ui/src/tui/pane.rs @@ -7,10 +7,10 @@ use tui_term::widget::PseudoTerminal; use super::{app::LayoutSections, TerminalOutput}; -const FOOTER_TEXT_ACTIVE: &str = "Press`Ctrl-Z` to stop interacting."; -const FOOTER_TEXT_INACTIVE: &str = "Press `Enter` to interact."; -const HAS_SELECTION: &str = "Press `c` to copy selection"; -const TASK_LIST_HIDDEN: &str = "Press `h` to show task list."; +const FOOTER_TEXT_ACTIVE: &str = "Ctrl-z - Stop interacting"; +const FOOTER_TEXT_INACTIVE: &str = "i - Interact"; +const HAS_SELECTION: &str = "c - Copy selection"; +const TASK_LIST_HIDDEN: &str = "h - Show task list"; pub struct TerminalPane<'a, W> { terminal_output: &'a TerminalOutput, @@ -39,24 +39,29 @@ impl<'a, W> TerminalPane<'a, W> { } fn footer(&self) -> Line { - let task_list_message = if !self.has_sidebar { - TASK_LIST_HIDDEN - } else { - "" + let build_message_vec = |footer_text: &str| -> String { + let mut messages = vec![footer_text]; + + if !self.has_sidebar { + messages.push(TASK_LIST_HIDDEN); + } + + if self.terminal_output.has_selection() { + messages.push(HAS_SELECTION); + } + + // Spaces are used to pad the footer text for aesthetics + [" ".into(), messages.join(", ")].join("") }; match self.section { - LayoutSections::Pane if self.terminal_output.has_selection() => Line::from(format!( - "{FOOTER_TEXT_ACTIVE} {task_list_message} {HAS_SELECTION}" - )) - .centered(), - LayoutSections::Pane => Line::from(FOOTER_TEXT_ACTIVE.to_owned()).centered(), - LayoutSections::TaskList if self.terminal_output.has_selection() => Line::from( - format!("{FOOTER_TEXT_INACTIVE} {task_list_message} {HAS_SELECTION}"), - ) - .centered(), + LayoutSections::Pane => { + let messages = build_message_vec(FOOTER_TEXT_ACTIVE); + Line::from(messages).left_aligned() + } LayoutSections::TaskList => { - Line::from(format!("{FOOTER_TEXT_INACTIVE} {task_list_message}")).centered() + let messages = build_message_vec(FOOTER_TEXT_INACTIVE); + Line::from(messages).left_aligned() } LayoutSections::Search { results, .. } => { Line::from(format!("/ {}", results.query())).left_aligned() From c3381edf723cfcdb6fbb388219c8ab77c2b77e95 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Wed, 20 Nov 2024 23:18:35 -0700 Subject: [PATCH 2/4] WIP --- crates/turborepo-ui/src/tui/input.rs | 1 - crates/turborepo-ui/src/tui/pane.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/turborepo-ui/src/tui/input.rs b/crates/turborepo-ui/src/tui/input.rs index 5354d2b7b22f5..fb17dc5b19b8d 100644 --- a/crates/turborepo-ui/src/tui/input.rs +++ b/crates/turborepo-ui/src/tui/input.rs @@ -115,7 +115,6 @@ fn translate_key_event(options: InputOptions, key_event: KeyEvent) -> Option Some(Event::Up), KeyCode::Down => Some(Event::Down), KeyCode::Enter => Some(Event::EnterInteractive), - KeyCode::Char('i') => Some(Event::EnterInteractive), _ => None, } } diff --git a/crates/turborepo-ui/src/tui/pane.rs b/crates/turborepo-ui/src/tui/pane.rs index 859c5472998e0..3d9edb20bdb19 100644 --- a/crates/turborepo-ui/src/tui/pane.rs +++ b/crates/turborepo-ui/src/tui/pane.rs @@ -8,7 +8,7 @@ use tui_term::widget::PseudoTerminal; use super::{app::LayoutSections, TerminalOutput}; const FOOTER_TEXT_ACTIVE: &str = "Ctrl-z - Stop interacting"; -const FOOTER_TEXT_INACTIVE: &str = "i - Interact"; +const FOOTER_TEXT_INACTIVE: &str = "Enter - Interact"; const HAS_SELECTION: &str = "c - Copy selection"; const TASK_LIST_HIDDEN: &str = "h - Show task list"; From 919d150aa3aa9bc859f6ef6a195ee9fb073fcf68 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 21 Nov 2024 12:49:34 -0700 Subject: [PATCH 3/4] Update crates/turborepo-ui/src/tui/pane.rs Co-authored-by: Chris Olszewski --- crates/turborepo-ui/src/tui/pane.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/turborepo-ui/src/tui/pane.rs b/crates/turborepo-ui/src/tui/pane.rs index 3d9edb20bdb19..cedbcec9088a4 100644 --- a/crates/turborepo-ui/src/tui/pane.rs +++ b/crates/turborepo-ui/src/tui/pane.rs @@ -51,7 +51,7 @@ impl<'a, W> TerminalPane<'a, W> { } // Spaces are used to pad the footer text for aesthetics - [" ".into(), messages.join(", ")].join("") + format!(" {}", messages.join(", ")) }; match self.section { From 21d961a7e63048073b31a09799201e00b36a5744 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 21 Nov 2024 12:49:56 -0700 Subject: [PATCH 4/4] Update crates/turborepo-ui/src/tui/pane.rs --- crates/turborepo-ui/src/tui/pane.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/turborepo-ui/src/tui/pane.rs b/crates/turborepo-ui/src/tui/pane.rs index cedbcec9088a4..d0ca9d61f7688 100644 --- a/crates/turborepo-ui/src/tui/pane.rs +++ b/crates/turborepo-ui/src/tui/pane.rs @@ -8,7 +8,7 @@ use tui_term::widget::PseudoTerminal; use super::{app::LayoutSections, TerminalOutput}; const FOOTER_TEXT_ACTIVE: &str = "Ctrl-z - Stop interacting"; -const FOOTER_TEXT_INACTIVE: &str = "Enter - Interact"; +const FOOTER_TEXT_INACTIVE: &str = "i - Interact"; const HAS_SELECTION: &str = "c - Copy selection"; const TASK_LIST_HIDDEN: &str = "h - Show task list";