Skip to content

Commit

Permalink
feat: make key bindings pane into just a row (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyu08 authored Jun 13, 2024
1 parent c27701e commit 54276aa
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions src/usecase/fzf_make/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ pub fn ui(f: &mut Frame, model: &mut Model) {
if let AppState::SelectTarget(model) = &mut model.app_state {
let main_and_key_bindings = Layout::default()
.direction(Direction::Vertical)
.constraints([Constraint::Min(3), Constraint::Length(5)])
.constraints([Constraint::Min(3), Constraint::Length(1)])
.split(f.size());
render_key_bindings_block(model, f, main_and_key_bindings[1]);
render_hint_block(model, f, main_and_key_bindings[1]);

let main = Layout::default()
.direction(Direction::Vertical)
Expand Down Expand Up @@ -206,31 +206,19 @@ fn render_history_block(
);
}

fn render_key_bindings_block(
model: &mut SelectTargetState,
f: &mut Frame,
chunk: ratatui::layout::Rect,
) {
fn render_hint_block(model: &mut SelectTargetState, f: &mut Frame, chunk: ratatui::layout::Rect) {
let hint_text = match model.current_pane {
CurrentPane::Main => {
"(Any key except the following): Narrow down targets, <UP>/<DOWN>/<c-n>/<c-p>: Move cursor, <Enter>: Execute target, <esc>: Quit, <tab> Move to next tab, <BACKSPACE>/<c-h>: Delete last character, <c-w>: Delete all key input"
CurrentPane::Main => {
"Execute the selected target: <enter> | Select target: ↑/↓ | Narrow down target: (type any character) | Move to next tab: <tab> | Quit: <esc>"
}
CurrentPane::History => {
"Execute the selected target: <enter> | Select target: ↑/↓ | Move to next tab: <tab> | Quit: q/<esc>"
}
CurrentPane::History => "q/<esc>: Quit, <tab> Move to next tab",
};
let current_keys_hint = Span::styled(hint_text, Style::default().fg(FG_COLOR_SELECTED));
let hint = Span::styled(hint_text, Style::default().fg(FG_COLOR_SELECTED));

let title = " 💬 Key bindings ";
let block = Block::default()
.title(title)
.title_style(TITLE_STYLE)
.borders(Borders::ALL)
.border_type(BORDER_STYLE_NOT_SELECTED)
.border_style(Style::default().fg(Color::default()))
.style(Style::default())
.padding(ratatui::widgets::Padding::new(2, 2, 0, 0));
let key_notes_footer = Paragraph::new(current_keys_hint)
.wrap(Wrap { trim: true })
.block(block);
let block = Block::default().padding(ratatui::widgets::Padding::new(2, 2, 0, 0));
let key_notes_footer = Paragraph::new(hint).wrap(Wrap { trim: true }).block(block);

f.render_widget(key_notes_footer, chunk);
}
Expand Down

0 comments on commit 54276aa

Please sign in to comment.