Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tui): change binds for log scrolling and add UI hints #9610

Merged
merged 5 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
16 changes: 9 additions & 7 deletions crates/turborepo-ui/src/tui/pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ 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 EXIT_INTERACTIVE_HINT: &str = "Ctrl-z - Stop interacting";
const ENTER_INTERACTIVE_HINT: &str = "i - Interact";
const HAS_SELECTION: &str = "c - Copy selection";
const SCROLL_LOGS: &str = "u/d - Scroll logs";
anthonyshew marked this conversation as resolved.
Show resolved Hide resolved
const TASK_LIST_HIDDEN: &str = "h - Show task list";

pub struct TerminalPane<'a, W> {
Expand All @@ -35,8 +36,9 @@ impl<'a, W> TerminalPane<'a, W> {
}

fn footer(&self) -> Line {
let build_message_vec = |footer_text: &str| -> Line {
let mut messages = vec![footer_text];
let build_message_vec = |footer_text: &[&str]| -> Line {
let mut messages = Vec::new();
messages.extend_from_slice(footer_text);

if !self.has_sidebar {
messages.push(TASK_LIST_HIDDEN);
Expand All @@ -47,7 +49,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 @@ -57,8 +59,8 @@ 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::Pane => build_message_vec(&[EXIT_INTERACTIVE_HINT]),
LayoutSections::TaskList => build_message_vec(&[ENTER_INTERACTIVE_HINT, SCROLL_LOGS]),
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",
"u - Scroll logs up",
"d - Scroll logs down",
];

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