keybinds: toggling paginated/scrolling, focus/unfocus search bar

This commit is contained in:
Marko Andjelic 2026-07-06 17:44:39 +01:00
commit 6ca9e43520
Signed by: marko
GPG key ID: 9C5E99C8C682FB59
2 changed files with 5 additions and 0 deletions

View file

@ -125,6 +125,7 @@ data UserAction
| NextPage
| PrevPage
| ToggleMode
| SearchFocus
-- | Parsed EPUB, carried through the parser as a reader environment.
data EpubEnv = EpubEnv

View file

@ -163,6 +163,8 @@ wireEvents ctx = do
Gdk.KEY_Page_Up -> dispatch PrevChapter >> pure True
Gdk.KEY_equal -> dispatch ZoomIn >> pure True
Gdk.KEY_minus -> dispatch ZoomOut >> pure True
Gdk.KEY_p -> dispatch ToggleMode >> pure True
Gdk.KEY_f -> dispatch SearchFocus >> pure True
_ -> pure False
Gtk.widgetAddController (appWindow (ctxWidgets ctx)) keyCtrl
@ -177,6 +179,7 @@ wireEvents ctx = do
case keyval of
Gdk.KEY_Down -> WebKit.findControllerSearchNext fc >> pure True
Gdk.KEY_Up -> WebKit.findControllerSearchPrevious fc >> pure True
Gdk.KEY_Escape -> Gtk.setEditableText entry "" >> WebKit.findControllerSearchFinish fc >> Gtk.widgetGrabFocus (appWebView (ctxWidgets ctx)) >> pure True
_ -> pure False
Gtk.widgetAddController entry searchKeys
@ -288,6 +291,7 @@ handleAction :: Ctx -> UserAction -> IO ()
handleAction ctx action = do
st <- readTVarIO (ctxState ctx)
let wv = appWebView (ctxWidgets ctx)
let entry = appSearch (ctxWidgets ctx)
case action of
ZoomIn -> setZoom ctx (stZoom st + 0.1)
ZoomOut -> setZoom ctx (max 0.1 (stZoom st - 0.1))