diff --git a/app/Types.hs b/app/Types.hs index 0363274..e2a1d90 100644 --- a/app/Types.hs +++ b/app/Types.hs @@ -125,6 +125,7 @@ data UserAction | NextPage | PrevPage | ToggleMode + | SearchFocus -- | Parsed EPUB, carried through the parser as a reader environment. data EpubEnv = EpubEnv diff --git a/app/UI.hs b/app/UI.hs index e893a32..50bca87 100644 --- a/app/UI.hs +++ b/app/UI.hs @@ -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))