n+l leader key for new list creation
- n is now a leader key (like t for dates) - n + l opens Input popup to name and create a new list - n + n opens EditTask popup to create a new task - Popup::Input Enter now creates a list regardless of focus - Removed immediate n behavior (list/task creation)
This commit is contained in:
+30
-17
@@ -49,6 +49,7 @@ pub struct App {
|
|||||||
last_sync_version: u64,
|
last_sync_version: u64,
|
||||||
editing_task_id: Option<String>,
|
editing_task_id: Option<String>,
|
||||||
pending_date_key: bool,
|
pending_date_key: bool,
|
||||||
|
pending_new_key: bool,
|
||||||
auth_tx: std_mpsc::Sender<AuthEvent>,
|
auth_tx: std_mpsc::Sender<AuthEvent>,
|
||||||
auth_rx: std_mpsc::Receiver<AuthEvent>,
|
auth_rx: std_mpsc::Receiver<AuthEvent>,
|
||||||
sync_tx: mpsc::Sender<SyncCommand>,
|
sync_tx: mpsc::Sender<SyncCommand>,
|
||||||
@@ -118,6 +119,7 @@ impl App {
|
|||||||
last_sync_version: 0,
|
last_sync_version: 0,
|
||||||
editing_task_id: None,
|
editing_task_id: None,
|
||||||
pending_date_key: false,
|
pending_date_key: false,
|
||||||
|
pending_new_key: false,
|
||||||
auth_tx,
|
auth_tx,
|
||||||
auth_rx,
|
auth_rx,
|
||||||
sync_tx,
|
sync_tx,
|
||||||
@@ -246,6 +248,33 @@ impl App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_key(&mut self, key: KeyEvent) {
|
pub fn handle_key(&mut self, key: KeyEvent) {
|
||||||
|
if self.pending_new_key {
|
||||||
|
self.pending_new_key = false;
|
||||||
|
match key.code {
|
||||||
|
KeyCode::Char('l') | KeyCode::Char('L') => {
|
||||||
|
self.editing_task_id = None;
|
||||||
|
self.popup_input.clear();
|
||||||
|
self.popup_cursor = 0;
|
||||||
|
self.show_popup = Some(Popup::Input);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
KeyCode::Char('n') | KeyCode::Char('N') => {
|
||||||
|
if !self.lists.is_empty() {
|
||||||
|
self.editing_task_id = None;
|
||||||
|
self.popup_input.clear();
|
||||||
|
self.popup_cursor = 0;
|
||||||
|
self.popup_secondary.clear();
|
||||||
|
self.popup_secondary_cursor = 0;
|
||||||
|
self.edit_field = 0;
|
||||||
|
self.notes_scroll = 0;
|
||||||
|
self.show_popup = Some(Popup::EditTask { field: 0 });
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(ref popup) = self.show_popup.clone() {
|
if let Some(ref popup) = self.show_popup.clone() {
|
||||||
self.handle_popup_key(key, popup);
|
self.handle_popup_key(key, popup);
|
||||||
return;
|
return;
|
||||||
@@ -348,21 +377,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
KeyCode::Char('n') | KeyCode::Char('N') => {
|
KeyCode::Char('n') | KeyCode::Char('N') => {
|
||||||
if !self.needs_auth {
|
if !self.needs_auth {
|
||||||
if self.focus == Focus::Tabs {
|
self.pending_new_key = true;
|
||||||
self.editing_task_id = None;
|
|
||||||
self.popup_input.clear();
|
|
||||||
self.popup_cursor = 0;
|
|
||||||
self.show_popup = Some(Popup::Input);
|
|
||||||
} else if !self.lists.is_empty() {
|
|
||||||
self.editing_task_id = None;
|
|
||||||
self.popup_input.clear();
|
|
||||||
self.popup_cursor = 0;
|
|
||||||
self.popup_secondary.clear();
|
|
||||||
self.popup_secondary_cursor = 0;
|
|
||||||
self.edit_field = 0;
|
|
||||||
self.notes_scroll = 0;
|
|
||||||
self.show_popup = Some(Popup::EditTask { field: 0 });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KeyCode::Char('d') | KeyCode::Char('D') => {
|
KeyCode::Char('d') | KeyCode::Char('D') => {
|
||||||
@@ -452,7 +467,6 @@ impl App {
|
|||||||
KeyCode::Enter => {
|
KeyCode::Enter => {
|
||||||
let input = self.popup_input.trim().to_string();
|
let input = self.popup_input.trim().to_string();
|
||||||
if !input.is_empty() {
|
if !input.is_empty() {
|
||||||
if self.focus == Focus::Tabs {
|
|
||||||
let list = TaskList {
|
let list = TaskList {
|
||||||
id: uuid_v4(),
|
id: uuid_v4(),
|
||||||
title: input,
|
title: input,
|
||||||
@@ -467,7 +481,6 @@ impl App {
|
|||||||
self.trigger_sync();
|
self.trigger_sync();
|
||||||
self.load_lists();
|
self.load_lists();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
self.show_popup = None;
|
self.show_popup = None;
|
||||||
}
|
}
|
||||||
KeyCode::Char(c) => {
|
KeyCode::Char(c) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user