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

fix: Fixup preview rendering and logic of preview key binding being shown in shortcut list #387

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 4 additions & 1 deletion tui/src/floating_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use ratatui::{
layout::Rect,
style::{Style, Stylize},
text::Line,
widgets::{Block, Borders, List},
widgets::{Block, Borders, Clear, List},
Frame,
};

Expand Down Expand Up @@ -91,6 +91,9 @@ impl FloatContent for FloatingText {
.block(Block::default())
.highlight_style(Style::default().reversed());

// Clear the text underneath the floats rendered area
frame.render_widget(Clear, inner_area);

// Render the list inside the bordered area
frame.render_widget(list, inner_area);
}
Expand Down
14 changes: 11 additions & 3 deletions tui/src/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ pub fn draw_shortcuts(state: &AppState, frame: &mut Frame, area: Rect) {
scope_name: "Search bar",
hints: vec![Shortcut::new(vec!["Enter"], "Finish search")],
},

Focus::List => {
let mut hints = Vec::new();
hints.push(Shortcut::new(vec!["q", "CTRL-c"], "Exit linutil"));

if state.at_root() {
hints.push(Shortcut::new(vec!["h", "Left", "Tab"], "Focus tab list"));
hints.push(get_list_item_shortcut(state));
Expand All @@ -129,21 +131,26 @@ pub fn draw_shortcuts(state: &AppState, frame: &mut Frame, area: Rect) {
} else {
hints.push(Shortcut::new(vec!["h", "Left"], "Go to parrent directory"));
hints.push(get_list_item_shortcut(state));
if state.selected_item_is_cmd() {
hints.push(Shortcut::new(vec!["p"], "Enable preview"));
}
}

hints.push(Shortcut::new(vec!["Tab"], "Focus tab list"));
};

if state.selected_item_is_cmd() {
hints.push(Shortcut::new(vec!["p"], "Enable preview"));
}

hints.push(Shortcut::new(vec!["k", "Up"], "Select item above"));
hints.push(Shortcut::new(vec!["j", "Down"], "Select item below"));
hints.push(Shortcut::new(vec!["t"], "Next theme"));
hints.push(Shortcut::new(vec!["T"], "Previous theme"));

ShortcutList {
scope_name: "Item list",
hints,
}
}

Focus::TabList => ShortcutList {
scope_name: "Tab list",
hints: vec![
Expand All @@ -155,6 +162,7 @@ pub fn draw_shortcuts(state: &AppState, frame: &mut Frame, area: Rect) {
Shortcut::new(vec!["T"], "Previous theme"),
],
},

Focus::FloatingWindow(ref float) => float.get_shortcut_list(),
}
.draw(frame, area);
Expand Down