Skip to content

Commit

Permalink
feat(tui): change binds for log scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyshew committed Dec 12, 2024
1 parent ffd4679 commit e842f9f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
6 changes: 2 additions & 4 deletions crates/turborepo-ui/src/tui/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,8 @@ fn translate_key_event(options: InputOptions, key_event: KeyEvent) -> Option<Eve
}
// Fall through if we aren't in interactive mode
KeyCode::Char('h') => Some(Event::ToggleSidebar),
KeyCode::Char('p') if key_event.modifiers == KeyModifiers::CONTROL => Some(Event::ScrollUp),
KeyCode::Char('n') if key_event.modifiers == KeyModifiers::CONTROL => {
Some(Event::ScrollDown)
}
KeyCode::Char('u') => Some(Event::ScrollUp),
KeyCode::Char('d') => Some(Event::ScrollDown),
KeyCode::Char('m') => Some(Event::ToggleHelpPopup),
KeyCode::Up | KeyCode::Char('k') => Some(Event::Up),
KeyCode::Down | KeyCode::Char('j') => Some(Event::Down),
Expand Down
12 changes: 8 additions & 4 deletions crates/turborepo-ui/src/tui/pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ 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 ENTER_INTERACTIVE_HINT: &str = "i - Interact";
const HAS_SELECTION: &str = "c - Copy selection";
const SCROLL_LOGS: &str = "u/d - Scroll logs";
const TASK_LIST_HIDDEN: &str = "h - Show task list";
const FOOTER_TEXT_ACTIVE: &str = "Ctrl-z - Stop interacting";

pub struct TerminalPane<'a, W> {
terminal_output: &'a TerminalOutput<W>,
Expand Down Expand Up @@ -47,7 +48,7 @@ impl<'a, W> TerminalPane<'a, W> {
}

// Spaces are used to pad the footer text for aesthetics
let formatted_messages = format!(" {}", messages.join(", "));
let formatted_messages = format!(" {}", messages.join(" "));

Line::styled(
formatted_messages.to_string(),
Expand All @@ -58,7 +59,10 @@ impl<'a, W> TerminalPane<'a, W> {

match self.section {
LayoutSections::Pane => build_message_vec(FOOTER_TEXT_ACTIVE),
LayoutSections::TaskList => build_message_vec(FOOTER_TEXT_INACTIVE),
LayoutSections::TaskList => {
// Spaces are used to pad the footer text for aesthetics
build_message_vec(format!("{} {}", ENTER_INTERACTIVE_HINT, SCROLL_LOGS).as_str())
}
LayoutSections::Search { results, .. } => {
Line::from(format!("/ {}", results.query())).left_aligned()
}
Expand Down
4 changes: 2 additions & 2 deletions crates/turborepo-ui/src/tui/popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const BIND_LIST: [&str; 11] = [
"i - Interact with task",
"Ctrl+z - Stop interacting with task",
"c - Copy logs selection (Only when logs are selected)",
"Ctrl+n - Scroll logs up",
"Ctrl+p - Scroll logs down",
"d - Scroll logs up",
"u - Scroll logs down",
];

pub fn popup_area(area: Rect) -> Rect {
Expand Down

0 comments on commit e842f9f

Please sign in to comment.