1
1
mirror of https://github.com/Yvee1/hascard.git synced 2024-11-26 07:30:14 +03:00

Merge pull request #13 from g-w1/master

Add quit with q
This commit is contained in:
Steven van den Broek 2020-09-13 19:34:28 +02:00 committed by GitHub
commit efc5a24bd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 79 additions and 74 deletions

View File

@ -73,6 +73,7 @@ handleEvent gs s@CSS{_list=l, _exception=exc} (VtyEvent ev) =
(Just _, _) -> continue' $ s & exception .~ Nothing (Just _, _) -> continue' $ s & exception .~ Nothing
(_, e) -> case e of (_, e) -> case e of
V.EvKey V.KEsc [] -> halt' gs V.EvKey V.KEsc [] -> halt' gs
V.EvKey (V.KChar 'q') [] -> halt' gs
_ -> do l' <- L.handleListEventVi L.handleListEvent e l _ -> do l' <- L.handleListEventVi L.handleListEvent e l
let s' = (s & list .~ l') in let s' = (s & list .~ l') in

View File

@ -33,7 +33,7 @@ drawUI s = [maybe emptyWidget (`drawPopup` s) (s^.popup), drawCardUI s <=> draw
drawInfo :: CS -> Widget Name drawInfo :: CS -> Widget Name
drawInfo s = if not (s ^. showControls) then emptyWidget else drawInfo s = if not (s ^. showControls) then emptyWidget else
strWrap . ("ESC: quit" <>) $ case s ^. cardState of strWrap . ("ESC or q: quit" <>) $ case s ^. cardState of
DefinitionState {} -> ", ENTER: flip card / continue" DefinitionState {} -> ", ENTER: flip card / continue"
MultipleChoiceState {} -> ", ENTER: submit answer / continue" MultipleChoiceState {} -> ", ENTER: submit answer / continue"
MultipleAnswerState {} -> ", ENTER: select / continue, c: submit selection" MultipleAnswerState {} -> ", ENTER: select / continue, c: submit selection"

View File

@ -46,7 +46,7 @@ drawUI FBS{_fb=b, _exception'=exc} = [drawException exc, center $ ui <=> help]
vBox [ hCenter $ txt "Up/Down: select, h: toggle show hidden files" vBox [ hCenter $ txt "Up/Down: select, h: toggle show hidden files"
, hCenter $ txt "/: search, Ctrl-C or Esc: cancel search" , hCenter $ txt "/: search, Ctrl-C or Esc: cancel search"
, hCenter $ txt "Enter: change directory or select file" , hCenter $ txt "Enter: change directory or select file"
, hCenter $ txt "Esc: quit" , hCenter $ txt "Esc or q: quit"
] ]
handleEvent :: GlobalState -> FBS -> BrickEvent Name Event -> EventM Name (Next GlobalState) handleEvent :: GlobalState -> FBS -> BrickEvent Name Event -> EventM Name (Next GlobalState)

View File

@ -29,6 +29,7 @@ handleEvent gs s (VtyEvent e) =
halt' = continue . popState in halt' = continue . popState in
case e of case e of
V.EvKey V.KEsc [] -> halt' gs V.EvKey V.KEsc [] -> halt' gs
V.EvKey (V.KChar 'q') [] -> halt' gs
V.EvKey V.KEnter [] -> halt' gs V.EvKey V.KEnter [] -> halt' gs
V.EvKey V.KDown [] -> vScrollBy (viewportScroll Ordinary) 1 >> continue' s V.EvKey V.KDown [] -> vScrollBy (viewportScroll Ordinary) 1 >> continue' s
V.EvKey (V.KChar 'j') [] -> vScrollBy (viewportScroll Ordinary) 1 >> continue' s V.EvKey (V.KChar 'j') [] -> vScrollBy (viewportScroll Ordinary) 1 >> continue' s

View File

@ -49,6 +49,7 @@ handleEvent gs s (VtyEvent e) =
let update = updateMMS gs in let update = updateMMS gs in
case e of case e of
V.EvKey V.KEsc [] -> halt gs V.EvKey V.KEsc [] -> halt gs
V.EvKey (V.KChar 'q') [] -> halt gs
V.EvKey V.KEnter [] -> V.EvKey V.KEnter [] ->
case L.listSelected (s^.l) of case L.listSelected (s^.l) of
Just 0 -> continue =<< (gs `goToState`) <$> liftIO cardSelectorState Just 0 -> continue =<< (gs `goToState`) <$> liftIO cardSelectorState

View File

@ -50,6 +50,7 @@ handleEvent gs s ev@(VtyEvent e) =
in case e of in case e of
-- continue gs -- continue gs
V.EvKey V.KEsc [] -> halt' gs V.EvKey V.KEsc [] -> halt' gs
V.EvKey (V.KChar 'q') [] -> halt' gs
V.EvKey V.KDown [] -> down V.EvKey V.KDown [] -> down
V.EvKey (V.KChar 'j') [] -> down V.EvKey (V.KChar 'j') [] -> down
V.EvKey V.KUp [] -> up V.EvKey V.KUp [] -> up

View File

@ -45,6 +45,7 @@ handleEvent gs form ev@(VtyEvent e) =
in in
case e of case e of
V.EvKey V.KEsc [] -> halt' gs V.EvKey V.KEsc [] -> halt' gs
V.EvKey (V.KChar 'q') [] -> halt' gs
V.EvKey V.KDown [] -> down V.EvKey V.KDown [] -> down
V.EvKey (V.KChar 'j') [] -> down V.EvKey (V.KChar 'j') [] -> down
V.EvKey V.KUp [] -> up V.EvKey V.KUp [] -> up