aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2017-03-01 09:48:47 -0700
committerSean Whitton <spwhitton@spwhitton.name>2017-03-01 09:48:47 -0700
commitbb17a258054d190724f81062dca9cefba818d69a (patch)
tree914d5e1574e53157e5bb6b62ca022f65d17ae3d4
parent120161665af41b254acfbb851f83bef83efc5522 (diff)
downloadsscan-bb17a258054d190724f81062dca9cefba818d69a.tar.gz
implement new action handlers in UI
-rw-r--r--Types/State.hs7
-rw-r--r--UI.hs12
2 files changed, 15 insertions, 4 deletions
diff --git a/Types/State.hs b/Types/State.hs
index f49ee31..2fb081f 100644
--- a/Types/State.hs
+++ b/Types/State.hs
@@ -116,6 +116,13 @@ setScanSessDir dir st = case st^.stScanSess of
Just (ScanSess c p _) ->
st & stScanSess .~ (Just $ ScanSess c p (Just dir))
+setScanSessCommand :: Command -> St -> St
+setScanSessCommand c st = case st^.stScanSess of
+ Just (ScanSess _ p d) ->
+ st & stScanSess .~ (Just $ ScanSess c p d)
+ Nothing ->
+ st & stScanSess .~ (Just $ ScanSess c 0 Nothing)
+
incrementPages :: St -> St
incrementPages st = case st^.stScanSess of
Nothing -> st
diff --git a/UI.hs b/UI.hs
index b685c18..872b30a 100644
--- a/UI.hs
+++ b/UI.hs
@@ -99,16 +99,20 @@ drawUI st = [ui]
)
handleQ :: St -> EventM () (Next St)
-handleQ st = undefined
+handleQ st = halt $ ifScanSess st
+ (setScanSessCommand Finalise st)
+ (resetScanSess st)
handleRET :: St -> EventM () (Next St)
-handleRET st = undefined
+handleRET st = halt $ setScanSessCommand FinalPage st
handleSPC :: St -> EventM () (Next St)
-handleSPC st = undefined
+handleSPC st = halt $ setScanSessCommand NextPage st
handleESC :: St -> EventM () (Next St)
-handleESC st = undefined
+handleESC st = ifScanSess st
+ (halt $ setScanSessCommand Abort st)
+ (continue st)
handleHotKey :: St -> Char -> EventM () (Next St)
handleHotKey st 'q' = handleQ st