From 09177ddbae1ef2501a29d7fe8305363eb789c1cf Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Fri, 9 Jun 2023 15:48:30 +0700 Subject: [PATCH] Simplify keybindings and description. Add g and G movements. Remove -d flag --- src/app.rs | 4 ++++ src/input.rs | 10 ++++++---- src/main.rs | 4 +++- src/ui.rs | 18 +++++++++++++++++- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/app.rs b/src/app.rs index 002aeb2..87468ea 100644 --- a/src/app.rs +++ b/src/app.rs @@ -125,6 +125,10 @@ impl<'a> Column { *task_idx = min(*task_idx + 1, self.tasks.len().saturating_sub(1)); } + pub fn select_first_task(&mut self) { + self.selected_task_idx = 0; + } + pub fn select_last_task(&mut self) { self.selected_task_idx = self.tasks.len() - 1; } diff --git a/src/input.rs b/src/input.rs index 9ef0477..adeb8af 100644 --- a/src/input.rs +++ b/src/input.rs @@ -73,10 +73,12 @@ pub fn handle(state: &mut State<'_>) -> Result<(), std::io::Error> { KeyCode::Up => column.select_previous_task(), KeyCode::Char('l') | KeyCode::Right => { project.select_next_column(); }, - KeyCode::Char('<' | 'H') => project.move_task_previous_column(), - KeyCode::Char('>' | 'L') => project.move_task_next_column(), - KeyCode::Char('=' | 'J') => project.move_task_down(), - KeyCode::Char('-' | 'K') => project.move_task_up(), + KeyCode::Char('g') => column.select_first_task(), + KeyCode::Char('G') => column.select_last_task(), + KeyCode::Char('H') => project.move_task_previous_column(), + KeyCode::Char('L') => project.move_task_next_column(), + KeyCode::Char('J') => project.move_task_down(), + KeyCode::Char('K') => project.move_task_up(), KeyCode::Char('n') => state.task_edit_state = Some(TaskState::default()), KeyCode::Char('e') => state.task_edit_state = column.get_task_state_from_curr_selected_task(), diff --git a/src/main.rs b/src/main.rs index ca4b2d4..d6e5809 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,11 +25,13 @@ const DEFAULT_DATABASE_NAME: &str = "kanban.json"; #[command(name = "kanban")] /// kanban-tui is a simple, interactive TUI based task manager using kanban columns pub struct CliArgs { - #[arg(short('d'), long("database"), value_name="DATABASE", value_hint=FilePath)] + #[arg(value_name="DATABASE", value_hint=FilePath, index=1)] /// Path to the pub filepath: Option } +// TODO: This should just return a struct beacuse we should add a +// "should_quit" thing instead of calling exit(0) here fn prompt_project_init(default_name: &str) -> (String, io::Result) { let mut input = String::new(); diff --git a/src/ui.rs b/src/ui.rs index 352ca1d..fbea5d7 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -212,7 +212,23 @@ pub fn draw(f: &mut Frame<'_, B>, state: &mut State<'_>) { let block = Block::default().title("KEYBINDINGS").borders(Borders::TOP); - let foot_txt = "q : Quit | ⏪🔽🔼⏩ or hjkl : Navigation | < > or H L : Shift task left/right | = - or J K : Shift task up/down"; + // TODO: Cache this + let foot_txt = vec![ + ("quit", "c"), + ("navigation", "hjkl"), + ("move task", "HJKL"), + ("new task", "n"), + ("edit task", "e"), + ("cycle edit fields", "Tab"), + ("column top", "g"), + ("column bottom", "G"), + ] + .iter() + .map(|(k, b)| { + format!("{k}: {b}") + }) + .collect::>() + .join(" | "); let footer = Paragraph::new(foot_txt).block(block); f.render_widget(footer, main_layout[3]);