diff options
| author | krolxon <krolyxon@tutanota.com> | 2024-05-01 23:45:05 +0530 |
|---|---|---|
| committer | krolxon <krolyxon@tutanota.com> | 2024-05-01 23:45:05 +0530 |
| commit | b7fc6bc1a70da169f80afdc790c1a8ccf853d319 (patch) | |
| tree | e2a5e56029fbc927b81bc72891eff50a5a048516 /src/event/pl_rename_keys.rs | |
| parent | 955532893fc6db5a78f88ef2a2700dec56cd3012 (diff) | |
move the keymaps to thier individual files
Diffstat (limited to 'src/event/pl_rename_keys.rs')
| -rwxr-xr-x | src/event/pl_rename_keys.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/event/pl_rename_keys.rs b/src/event/pl_rename_keys.rs new file mode 100755 index 0000000..fff1582 --- /dev/null +++ b/src/event/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.list.get(app.pl_list.index).unwrap(), + &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(()) +} |
