huge opti
This commit is contained in:
131
src/main.rs
131
src/main.rs
@ -58,79 +58,74 @@ fn run_app(terminal: &mut Terminal<CrosstermBackend<io::Stdout>>, app: &mut App)
|
||||
}
|
||||
|
||||
match app.mode {
|
||||
// Dans la boucle, Mode::Normal :
|
||||
Mode::Normal => {
|
||||
// FIX: les deux blocs match étaient redondants et mal nommés.
|
||||
// On fusionne la logique en un seul bloc clair.
|
||||
match key.code {
|
||||
KeyCode::Enter => app.paste_selected(),
|
||||
KeyCode::Char('j') | KeyCode::Down => app.next(),
|
||||
KeyCode::Char('k') | KeyCode::Up => app.previous(),
|
||||
KeyCode::Char('G') => {
|
||||
Mode::Normal => match key.code {
|
||||
KeyCode::Enter => app.paste_selected(),
|
||||
KeyCode::Char('j') | KeyCode::Down => app.next(),
|
||||
KeyCode::Char('k') | KeyCode::Up => app.previous(),
|
||||
KeyCode::Char('G') => {
|
||||
if !app.filtered_items.is_empty() {
|
||||
let l = app.filtered_items.len() - 1;
|
||||
app.list_state.select(Some(l));
|
||||
app.update_preview();
|
||||
}
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char('g') => {
|
||||
last_d = false;
|
||||
if last_g {
|
||||
if !app.filtered_items.is_empty() {
|
||||
let l = app.filtered_items.len() - 1;
|
||||
app.list_state.select(Some(l));
|
||||
app.list_state.select(Some(0));
|
||||
app.update_preview();
|
||||
}
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char('g') => {
|
||||
last_d = false;
|
||||
if last_g {
|
||||
if !app.filtered_items.is_empty() {
|
||||
app.list_state.select(Some(0));
|
||||
app.update_preview();
|
||||
}
|
||||
last_g = false;
|
||||
} else {
|
||||
last_g = true;
|
||||
}
|
||||
}
|
||||
KeyCode::Char('d') => {
|
||||
last_g = false;
|
||||
if last_d {
|
||||
app.mode = Mode::ConfirmDelete;
|
||||
last_d = false;
|
||||
} else {
|
||||
last_d = true;
|
||||
}
|
||||
}
|
||||
KeyCode::Char('u') => {
|
||||
app.undo_delete();
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char('e') => {
|
||||
app.toggle_encrypt();
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char('t') => {
|
||||
app.cycle_type_filter();
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char('/') => {
|
||||
app.mode = Mode::Search;
|
||||
app.input_buffer.clear();
|
||||
app.update_search();
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char(':') => {
|
||||
app.mode = Mode::Command;
|
||||
app.input_buffer.clear();
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char('q') => app.should_quit = true,
|
||||
_ => {
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
} else {
|
||||
last_g = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
KeyCode::Char('d') => {
|
||||
last_g = false;
|
||||
if last_d {
|
||||
app.mode = Mode::ConfirmDelete;
|
||||
last_d = false;
|
||||
} else {
|
||||
last_d = true;
|
||||
}
|
||||
}
|
||||
KeyCode::Char('u') => {
|
||||
app.undo_delete();
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char('e') => {
|
||||
app.toggle_encrypt();
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char('t') => {
|
||||
app.cycle_type_filter();
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char('/') => {
|
||||
app.mode = Mode::Search;
|
||||
app.input_buffer.clear();
|
||||
app.update_search();
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char(':') => {
|
||||
app.mode = Mode::Command;
|
||||
app.input_buffer.clear();
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
KeyCode::Char('q') => app.should_quit = true,
|
||||
_ => {
|
||||
last_d = false;
|
||||
last_g = false;
|
||||
}
|
||||
},
|
||||
|
||||
Mode::Search => match key.code {
|
||||
KeyCode::Esc => {
|
||||
@ -169,7 +164,6 @@ fn run_app(terminal: &mut Terminal<CrosstermBackend<io::Stdout>>, app: &mut App)
|
||||
match cmd.as_str() {
|
||||
"q" | "quit" => app.should_quit = true,
|
||||
"clear" => app.clear_history(),
|
||||
// :p pour définir/changer le mot de passe
|
||||
"p" | "password" => {
|
||||
app.pending_action = None;
|
||||
app.mode = Mode::PasswordInput;
|
||||
@ -215,7 +209,6 @@ fn run_app(terminal: &mut Terminal<CrosstermBackend<io::Stdout>>, app: &mut App)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Idle : synchronisation avec le daemon
|
||||
app.sync_with_daemon();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user