From b4ac07ffc4a072807e164e8114b91d220725907c Mon Sep 17 00:00:00 2001 From: electria Date: Wed, 26 Aug 2026 12:42:29 -0700 Subject: [PATCH] feat: quit and focus_search keybinds --- src/app/mod.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/mod.rs b/src/app/mod.rs index 83990d8..447be4c 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -3,7 +3,7 @@ use std::{borrow::Cow, fs}; use iced::{ Alignment, Color, Length, Subscription, Task, application, clipboard, event, keyboard::{self, Key, key}, - theme, widget, + theme, widget, window, }; use rfd::{AsyncFileDialog, FileHandle}; @@ -35,6 +35,9 @@ enum Message { FocusNext, FocusPrevious, + FocusSearch, + + Quit, } #[derive(Default)] @@ -172,6 +175,9 @@ impl State { Message::FocusNext => return widget::operation::focus_next(), Message::FocusPrevious => return widget::operation::focus_previous(), + Message::FocusSearch => return widget::operation::focus("search"), + + Message::Quit => return window::latest().and_then(window::close), } Task::none() @@ -181,6 +187,7 @@ impl State { widget::column([ widget::text_input("search query", &self.query) .on_input(Message::ChangeQuery) + .id("search") .into(), widget::scrollable( widget::grid(self.db_view.iter().enumerate().flat_map(|(i, entry)| { @@ -331,6 +338,7 @@ impl State { } else { Message::FocusNext }), + Key::Character("/") => Some(Message::FocusSearch), Key::Named(key::Named::Enter) if !db_loaded && db_path_exists => { Some(Message::OpenDb) @@ -352,6 +360,8 @@ impl State { Key::Character("y" | "c") if db_loaded => Some(Message::Copy), + Key::Character("q") => Some(Message::Quit), + // ignore unused keys _ => None, }