aboutsummaryrefslogtreecommitdiffhomepage
path: root/Main.hs
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2017-02-25 21:56:51 -0700
committerSean Whitton <spwhitton@spwhitton.name>2017-02-25 22:00:12 -0700
commit423247140f7248410bfd5d469f30ab15200aafe6 (patch)
tree5156ee75a0157a7b2f86655d07782bd2a7090e52 /Main.hs
parentc05517582ea253a8a1b662269c4e2ede6d69f197 (diff)
downloadsscan-423247140f7248410bfd5d469f30ab15200aafe6.tar.gz
factor out ifScanSess
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs24
1 files changed, 11 insertions, 13 deletions
diff --git a/Main.hs b/Main.hs
index c0a7ad8..6fa6944 100644
--- a/Main.hs
+++ b/Main.hs
@@ -19,7 +19,6 @@ import Brick.Widgets.Core
import Data.Text.Markup ((@@))
import Brick.Widgets.DefnList
-import Data.Maybe (isJust)
import Presets
import Types.Preset
import Types.State
@@ -51,16 +50,16 @@ drawUI st = [ui]
actionsBox = defnList AlignLeft
(Just $ V.withStyle V.currentAttr V.bold) $
(if st^.stOutFormat == PDF
- then (if isJust $ st^.stScanningSession
- then [ ("SPC", "scan next page")
- , ("RET", "scan final page")
- , ("q", "declare last scanned page was the final page")
- , ("ESC", "abort/restart scanning this document")
- ]
- else [ ("SPC", "scan first page of multi-page document")
- , ("RET", "scan single page document")
- , ("q", "quit sscan")
- ]
+ then (ifScanSess st
+ [ ("SPC", "scan next page")
+ , ("RET", "scan final page")
+ , ("q", "declare last scanned page was the final page")
+ , ("ESC", "abort/restart scanning this document")
+ ]
+ [ ("SPC", "scan first page of multi-page document")
+ , ("RET", "scan single page document")
+ , ("q", "quit sscan")
+ ]
)
else [ ("SPC", "scan page")
, ("q", "quit sscan")
@@ -94,8 +93,7 @@ handleHotKey st c = updateStateOutsideSession st $
_ -> id
updateStateOutsideSession :: St -> (St -> St) -> EventM () (Next St)
-updateStateOutsideSession st f = continue $
- if isJust $ st^.stScanningSession then st else f st
+updateStateOutsideSession st f = continue $ ifScanSess st st (f st)
appEvent :: St -> BrickEvent () e -> EventM () (Next St)
appEvent st (VtyEvent e) =