diff options
| author | krolxon <krolyxon@tutanota.com> | 2024-06-15 00:06:35 +0530 |
|---|---|---|
| committer | krolxon <krolyxon@tutanota.com> | 2024-06-15 00:06:35 +0530 |
| commit | f2b90514899af2e55f4fca9ad759029aa7511e0e (patch) | |
| tree | 67375c06e03fcc7646fd82958c92f742efa8a674 /src/event_handler/pl_rename_keys.rs | |
| parent | 5795d00831da803442d737a928922093e2750aec (diff) | |
change event to event_handler
Diffstat (limited to 'src/event_handler/pl_rename_keys.rs')
| -rw-r--r-- | src/event_handler/pl_rename_keys.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/event_handler/pl_rename_keys.rs b/src/event_handler/pl_rename_keys.rs new file mode 100644 index 0000000..c9fc050 --- /dev/null +++ b/src/event_handler/pl_rename_keys.rs @@ -0,0 +1,43 @@ +use crate::{ + app::{App, AppResult}, + ui::InputMode, +}; +use crossterm::event::{KeyCode, KeyEvent}; + +pub fn handle_pl_rename_keys(key_event: KeyEvent, app: &mut App) -> AppResult<()> { + match key_event.code { + KeyCode::Esc => { + app.pl_newname_input.clear(); + app.reset_cursor(); + app.inputmode = InputMode::Normal; + } + KeyCode::Char(to_insert) => { + app.enter_char(to_insert); + } + KeyCode::Enter => { + app.conn.conn.pl_rename( + app.pl_list.get_item_at_current_index(), + &app.pl_newname_input, + )?; + app.pl_list.list = App::get_playlist(&mut app.conn.conn)?; + app.pl_newname_input.clear(); + app.reset_cursor(); + app.inputmode = InputMode::Normal; + } + + KeyCode::Backspace => { + app.delete_char(); + } + + KeyCode::Left => { + app.move_cursor_left(); + } + + KeyCode::Right => { + app.move_cursor_right(); + } + + _ => {} + } + Ok(()) +} |
