Simplify keybindings and description. Add g and G movements. Remove -d flag

This commit is contained in:
Joseph Ferano 2023-06-09 15:48:30 +07:00
parent c6343a4805
commit 09177ddbae
4 changed files with 30 additions and 6 deletions

View File

@ -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;
}

View File

@ -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(),

View File

@ -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<PathBuf>
}
// 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<File>) {
let mut input = String::new();

View File

@ -212,7 +212,23 @@ pub fn draw<B: Backend>(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::<Vec<String>>()
.join(" | ");
let footer = Paragraph::new(foot_txt).block(block);
f.render_widget(footer, main_layout[3]);