forked from marko/svitak
keybinds: toggling paginated/scrolling, focus/unfocus search bar
This commit is contained in:
parent
4170a958d1
commit
6ca9e43520
2 changed files with 5 additions and 0 deletions
|
|
@ -125,6 +125,7 @@ data UserAction
|
|||
| NextPage
|
||||
| PrevPage
|
||||
| ToggleMode
|
||||
| SearchFocus
|
||||
|
||||
-- | Parsed EPUB, carried through the parser as a reader environment.
|
||||
data EpubEnv = EpubEnv
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in a new issue