Skip to content

Commit

Permalink
feat/tui: show/hide CWD in cmdline
Browse files Browse the repository at this point in the history
  • Loading branch information
kxxt committed May 15, 2024
1 parent 3ba84dc commit 0828d3f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub enum Action {
ScrollToEnd,
ToggleFollow,
ToggleEnvDisplay,
ToggleCwdDisplay,
StopFollow,
// Sizing
ShrinkPane,
Expand Down
2 changes: 1 addition & 1 deletion src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl TracerEventDetails {
});
});
// Handle cwd
if cwd != &baseline.cwd {
if cwd != &baseline.cwd && rt_modifier.show_cwd {
spans.push(space.clone());
spans.push(format!("-C {}", escape_str_for_bash!(cwd)).set_style(THEME.cwd));
}
Expand Down
14 changes: 14 additions & 0 deletions src/tui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ impl App {
KeyCode::Char('e') if ke.modifiers == KeyModifiers::NONE => {
action_tx.send(Action::ToggleEnvDisplay)?;
}
KeyCode::Char('w') if ke.modifiers == KeyModifiers::NONE => {
action_tx.send(Action::ToggleCwdDisplay)?;
}
KeyCode::F(1) if ke.modifiers == KeyModifiers::NONE => {
action_tx.send(Action::SetActivePopup(ActivePopup::Help))?;
}
Expand Down Expand Up @@ -460,6 +463,9 @@ impl App {
Action::ToggleEnvDisplay => {
self.event_list.toggle_env_display();
}
Action::ToggleCwdDisplay => {
self.event_list.toggle_cwd_display();
}
Action::StopFollow => {
self.event_list.stop_follow();
}
Expand Down Expand Up @@ -740,6 +746,14 @@ impl App {
"Show Env"
}
),
help_item!(
"W",
if self.event_list.is_cwd_in_cmdline() {
"Hide CWD"
} else {
"Show CWD"
}
),
help_item!("V", "View"),
help_item!("Ctrl+F", "Search"),
));
Expand Down
6 changes: 6 additions & 0 deletions src/tui/event_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ impl EventList {
self.rebuild_event_strings();
}

pub fn toggle_cwd_display(&mut self) {
self.rt_modifier.show_cwd = !self.rt_modifier.show_cwd;
self.should_refresh_lines_cache = true;
self.rebuild_event_strings();
}

/// returns the index of the selected item if there is any
pub fn selection_index(&self) -> Option<usize> {
self.state.selected().map(|i| self.window.0 + i)
Expand Down

0 comments on commit 0828d3f

Please sign in to comment.