blob: c9fc050b546ac5d85e1978c65c355b279ab782e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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(())
}
|