ui: refactor: drop Vty. prefix
This commit is contained in:
parent
9ba8465421
commit
0851851ea9
@ -252,47 +252,47 @@ asHandle st'@AppState{
|
||||
case mode of
|
||||
Minibuffer ed ->
|
||||
case ev of
|
||||
Vty.EvKey Vty.KEsc [] -> continue $ stCloseMinibuffer st
|
||||
Vty.EvKey Vty.KEnter [] -> continue $ regenerateScreens j d $ stFilter s $ stCloseMinibuffer st
|
||||
where s = chomp $ unlines $ getEditContents ed
|
||||
ev -> do ed' <- handleEvent ev ed
|
||||
continue $ st{aMode=Minibuffer ed'}
|
||||
EvKey KEsc [] -> continue $ stCloseMinibuffer st
|
||||
EvKey KEnter [] -> continue $ regenerateScreens j d $ stFilter s $ stCloseMinibuffer st
|
||||
where s = chomp $ unlines $ getEditContents ed
|
||||
ev -> do ed' <- handleEvent ev ed
|
||||
continue $ st{aMode=Minibuffer ed'}
|
||||
|
||||
Help ->
|
||||
case ev of
|
||||
Vty.EvKey (Vty.KChar 'q') [] -> halt st
|
||||
_ -> helpHandle st ev
|
||||
EvKey (KChar 'q') [] -> halt st
|
||||
_ -> helpHandle st ev
|
||||
|
||||
Normal ->
|
||||
case ev of
|
||||
Vty.EvKey (Vty.KChar 'q') [] -> halt st
|
||||
-- Vty.EvKey (Vty.KChar 'l') [Vty.MCtrl] -> do
|
||||
Vty.EvKey Vty.KEsc [] -> continue $ resetScreens d st
|
||||
Vty.EvKey k [] | k `elem` [Vty.KChar 'h', Vty.KChar '?'] -> continue $ setMode Help st
|
||||
Vty.EvKey (Vty.KChar 'g') [] -> liftIO (stReloadJournalIfChanged copts d j st) >>= continue
|
||||
Vty.EvKey (Vty.KChar 'a') [] -> suspendAndResume $ clearScreen >> setCursorPosition 0 0 >> add copts j >> stReloadJournalIfChanged copts d j st
|
||||
Vty.EvKey (Vty.KChar '0') [] -> continue $ regenerateScreens j d $ setDepth (Just 0) st
|
||||
Vty.EvKey (Vty.KChar '1') [] -> continue $ regenerateScreens j d $ setDepth (Just 1) st
|
||||
Vty.EvKey (Vty.KChar '2') [] -> continue $ regenerateScreens j d $ setDepth (Just 2) st
|
||||
Vty.EvKey (Vty.KChar '3') [] -> continue $ regenerateScreens j d $ setDepth (Just 3) st
|
||||
Vty.EvKey (Vty.KChar '4') [] -> continue $ regenerateScreens j d $ setDepth (Just 4) st
|
||||
Vty.EvKey (Vty.KChar '5') [] -> continue $ regenerateScreens j d $ setDepth (Just 5) st
|
||||
Vty.EvKey (Vty.KChar '6') [] -> continue $ regenerateScreens j d $ setDepth (Just 6) st
|
||||
Vty.EvKey (Vty.KChar '7') [] -> continue $ regenerateScreens j d $ setDepth (Just 7) st
|
||||
Vty.EvKey (Vty.KChar '8') [] -> continue $ regenerateScreens j d $ setDepth (Just 8) st
|
||||
Vty.EvKey (Vty.KChar '9') [] -> continue $ regenerateScreens j d $ setDepth (Just 9) st
|
||||
Vty.EvKey (Vty.KChar '-') [] -> continue $ regenerateScreens j d $ decDepth st
|
||||
Vty.EvKey (Vty.KChar '_') [] -> continue $ regenerateScreens j d $ decDepth st
|
||||
Vty.EvKey k [] | k `elem` [Vty.KChar '+', Vty.KChar '='] -> continue $ regenerateScreens j d $ incDepth st
|
||||
Vty.EvKey (Vty.KChar 'F') [] -> continue $ regenerateScreens j d $ stToggleFlat st
|
||||
Vty.EvKey (Vty.KChar 'E') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleEmpty st)
|
||||
Vty.EvKey (Vty.KChar 'C') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleCleared st)
|
||||
Vty.EvKey (Vty.KChar 'U') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleUncleared st)
|
||||
Vty.EvKey (Vty.KChar 'R') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleReal st)
|
||||
Vty.EvKey k [] | k `elem` [Vty.KChar '/'] -> continue $ regenerateScreens j d $ stShowMinibuffer st
|
||||
Vty.EvKey k [] | k `elem` [Vty.KBS, Vty.KDel] -> (continue $ regenerateScreens j d $ stResetFilter st)
|
||||
Vty.EvKey (Vty.KLeft) [] -> continue $ popScreen st
|
||||
Vty.EvKey (k) [] | k `elem` [Vty.KRight, Vty.KEnter] -> scrollTopRegister >> continue (screenEnter d scr st)
|
||||
EvKey (KChar 'q') [] -> halt st
|
||||
-- EvKey (KChar 'l') [MCtrl] -> do
|
||||
EvKey KEsc [] -> continue $ resetScreens d st
|
||||
EvKey k [] | k `elem` [KChar 'h', KChar '?'] -> continue $ setMode Help st
|
||||
EvKey (KChar 'g') [] -> liftIO (stReloadJournalIfChanged copts d j st) >>= continue
|
||||
EvKey (KChar 'a') [] -> suspendAndResume $ clearScreen >> setCursorPosition 0 0 >> add copts j >> stReloadJournalIfChanged copts d j st
|
||||
EvKey (KChar '0') [] -> continue $ regenerateScreens j d $ setDepth (Just 0) st
|
||||
EvKey (KChar '1') [] -> continue $ regenerateScreens j d $ setDepth (Just 1) st
|
||||
EvKey (KChar '2') [] -> continue $ regenerateScreens j d $ setDepth (Just 2) st
|
||||
EvKey (KChar '3') [] -> continue $ regenerateScreens j d $ setDepth (Just 3) st
|
||||
EvKey (KChar '4') [] -> continue $ regenerateScreens j d $ setDepth (Just 4) st
|
||||
EvKey (KChar '5') [] -> continue $ regenerateScreens j d $ setDepth (Just 5) st
|
||||
EvKey (KChar '6') [] -> continue $ regenerateScreens j d $ setDepth (Just 6) st
|
||||
EvKey (KChar '7') [] -> continue $ regenerateScreens j d $ setDepth (Just 7) st
|
||||
EvKey (KChar '8') [] -> continue $ regenerateScreens j d $ setDepth (Just 8) st
|
||||
EvKey (KChar '9') [] -> continue $ regenerateScreens j d $ setDepth (Just 9) st
|
||||
EvKey (KChar '-') [] -> continue $ regenerateScreens j d $ decDepth st
|
||||
EvKey (KChar '_') [] -> continue $ regenerateScreens j d $ decDepth st
|
||||
EvKey k [] | k `elem` [KChar '+', KChar '='] -> continue $ regenerateScreens j d $ incDepth st
|
||||
EvKey (KChar 'F') [] -> continue $ regenerateScreens j d $ stToggleFlat st
|
||||
EvKey (KChar 'E') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleEmpty st)
|
||||
EvKey (KChar 'C') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleCleared st)
|
||||
EvKey (KChar 'U') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleUncleared st)
|
||||
EvKey (KChar 'R') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleReal st)
|
||||
EvKey k [] | k `elem` [KChar '/'] -> continue $ regenerateScreens j d $ stShowMinibuffer st
|
||||
EvKey k [] | k `elem` [KBS, KDel] -> (continue $ regenerateScreens j d $ stResetFilter st)
|
||||
EvKey (KLeft) [] -> continue $ popScreen st
|
||||
EvKey (k) [] | k `elem` [KRight, KEnter] -> scrollTopRegister >> continue (screenEnter d scr st)
|
||||
where
|
||||
scr = rsSetAccount selacct registerScreen
|
||||
|
||||
|
||||
@ -75,23 +75,22 @@ esHandle st@AppState{
|
||||
case mode of
|
||||
Help ->
|
||||
case ev of
|
||||
Vty.EvKey (Vty.KChar 'q') [] -> halt st
|
||||
_ -> helpHandle st ev
|
||||
EvKey (KChar 'q') [] -> halt st
|
||||
_ -> helpHandle st ev
|
||||
|
||||
_ -> do
|
||||
d <- liftIO getCurrentDay
|
||||
case ev of
|
||||
Vty.EvKey (Vty.KChar 'q') [] -> halt st
|
||||
Vty.EvKey Vty.KEsc [] -> continue $ resetScreens d st
|
||||
Vty.EvKey k [] | k `elem` [Vty.KChar 'h', Vty.KChar '?'] -> continue $ setMode Help st
|
||||
Vty.EvKey (Vty.KChar 'g') [] -> do
|
||||
EvKey (KChar 'q') [] -> halt st
|
||||
EvKey KEsc [] -> continue $ resetScreens d st
|
||||
EvKey k [] | k `elem` [KChar 'h', KChar '?'] -> continue $ setMode Help st
|
||||
EvKey (KChar 'g') [] -> do
|
||||
(ej, _) <- liftIO $ journalReloadIfChanged copts d j
|
||||
case ej of
|
||||
Left err -> continue st{aScreen=s{esError=err}} -- show latest parse error
|
||||
Right j' -> continue $ regenerateScreens j' d $ popScreen st -- return to previous screen, and reload it
|
||||
|
||||
-- Vty.EvKey (Vty.KLeft) [] -> continue $ popScreen st
|
||||
-- Vty.EvKey (Vty.KRight) [] -> error (show curItem) where curItem = listSelectedElement is
|
||||
-- EvKey (KLeft) [] -> continue $ popScreen st
|
||||
-- EvKey (KRight) [] -> error (show curItem) where curItem = listSelectedElement is
|
||||
-- fall through to the list's event handler (handles [pg]up/down)
|
||||
_ -> do continue st
|
||||
-- is' <- handleEvent ev is
|
||||
|
||||
@ -231,33 +231,33 @@ rsHandle st@AppState{
|
||||
case mode of
|
||||
Minibuffer ed ->
|
||||
case ev of
|
||||
Vty.EvKey Vty.KEsc [] -> continue $ stCloseMinibuffer st
|
||||
Vty.EvKey Vty.KEnter [] -> continue $ regenerateScreens j d $ stFilter s $ stCloseMinibuffer st
|
||||
where s = chomp $ unlines $ getEditContents ed
|
||||
ev -> do ed' <- handleEvent ev ed
|
||||
continue $ st{aMode=Minibuffer ed'}
|
||||
EvKey KEsc [] -> continue $ stCloseMinibuffer st
|
||||
EvKey KEnter [] -> continue $ regenerateScreens j d $ stFilter s $ stCloseMinibuffer st
|
||||
where s = chomp $ unlines $ getEditContents ed
|
||||
ev -> do ed' <- handleEvent ev ed
|
||||
continue $ st{aMode=Minibuffer ed'}
|
||||
|
||||
Help ->
|
||||
case ev of
|
||||
Vty.EvKey (Vty.KChar 'q') [] -> halt st
|
||||
_ -> helpHandle st ev
|
||||
EvKey (KChar 'q') [] -> halt st
|
||||
_ -> helpHandle st ev
|
||||
|
||||
Normal ->
|
||||
case ev of
|
||||
Vty.EvKey (Vty.KChar 'q') [] -> halt st
|
||||
Vty.EvKey Vty.KEsc [] -> continue $ resetScreens d st
|
||||
Vty.EvKey k [] | k `elem` [Vty.KChar 'h', Vty.KChar '?'] -> continue $ setMode Help st
|
||||
Vty.EvKey (Vty.KChar 'g') [] -> liftIO (stReloadJournalIfChanged copts d j st) >>= continue
|
||||
Vty.EvKey (Vty.KChar 'a') [] -> suspendAndResume $ clearScreen >> setCursorPosition 0 0 >> add copts j >> stReloadJournalIfChanged copts d j st
|
||||
Vty.EvKey (Vty.KChar 'E') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleEmpty st)
|
||||
Vty.EvKey (Vty.KChar 'C') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleCleared st)
|
||||
Vty.EvKey (Vty.KChar 'U') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleUncleared st)
|
||||
Vty.EvKey (Vty.KChar 'R') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleReal st)
|
||||
Vty.EvKey k [] | k `elem` [Vty.KChar '/'] -> (continue $ regenerateScreens j d $ stShowMinibuffer st)
|
||||
Vty.EvKey k [] | k `elem` [Vty.KBS, Vty.KDel] -> (continue $ regenerateScreens j d $ stResetFilter st)
|
||||
Vty.EvKey (Vty.KLeft) [] -> continue $ popScreen st
|
||||
EvKey (KChar 'q') [] -> halt st
|
||||
EvKey KEsc [] -> continue $ resetScreens d st
|
||||
EvKey k [] | k `elem` [KChar 'h', KChar '?'] -> continue $ setMode Help st
|
||||
EvKey (KChar 'g') [] -> liftIO (stReloadJournalIfChanged copts d j st) >>= continue
|
||||
EvKey (KChar 'a') [] -> suspendAndResume $ clearScreen >> setCursorPosition 0 0 >> add copts j >> stReloadJournalIfChanged copts d j st
|
||||
EvKey (KChar 'E') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleEmpty st)
|
||||
EvKey (KChar 'C') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleCleared st)
|
||||
EvKey (KChar 'U') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleUncleared st)
|
||||
EvKey (KChar 'R') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleReal st)
|
||||
EvKey k [] | k `elem` [KChar '/'] -> (continue $ regenerateScreens j d $ stShowMinibuffer st)
|
||||
EvKey k [] | k `elem` [KBS, KDel] -> (continue $ regenerateScreens j d $ stResetFilter st)
|
||||
EvKey (KLeft) [] -> continue $ popScreen st
|
||||
|
||||
Vty.EvKey (k) [] | k `elem` [Vty.KRight, Vty.KEnter] -> do
|
||||
EvKey (k) [] | k `elem` [KRight, KEnter] -> do
|
||||
case listSelectedElement rsList of
|
||||
Just (_, RegisterScreenItem{rsItemTransaction=t}) ->
|
||||
let
|
||||
@ -271,10 +271,9 @@ rsHandle st@AppState{
|
||||
Nothing -> continue st
|
||||
|
||||
-- fall through to the list's event handler (handles [pg]up/down)
|
||||
ev -> do
|
||||
newitems <- handleEvent ev rsList
|
||||
continue st{aScreen=s{rsList=newitems}}
|
||||
-- continue =<< handleEventLensed st someLens ev
|
||||
ev -> do newitems <- handleEvent ev rsList
|
||||
continue st{aScreen=s{rsList=newitems}}
|
||||
-- continue =<< handleEventLensed st someLens ev
|
||||
|
||||
where
|
||||
-- Encourage a more stable scroll position when toggling list items (cf AccountsScreen.hs)
|
||||
|
||||
@ -119,8 +119,8 @@ tsHandle st@AppState{aScreen=s@TransactionScreen{tsTransaction=(i,t)
|
||||
case mode of
|
||||
Help ->
|
||||
case ev of
|
||||
Vty.EvKey (Vty.KChar 'q') [] -> halt st
|
||||
_ -> helpHandle st ev
|
||||
EvKey (KChar 'q') [] -> halt st
|
||||
_ -> helpHandle st ev
|
||||
|
||||
_ -> do
|
||||
d <- liftIO getCurrentDay
|
||||
@ -128,13 +128,14 @@ tsHandle st@AppState{aScreen=s@TransactionScreen{tsTransaction=(i,t)
|
||||
(iprev,tprev) = maybe (i,t) ((i-1),) $ lookup (i-1) nts
|
||||
(inext,tnext) = maybe (i,t) ((i+1),) $ lookup (i+1) nts
|
||||
case ev of
|
||||
Vty.EvKey (Vty.KChar 'q') [] -> halt st
|
||||
Vty.EvKey Vty.KEsc [] -> continue $ resetScreens d st
|
||||
Vty.EvKey k [] | k `elem` [Vty.KChar 'h', Vty.KChar '?'] -> continue $ setMode Help st
|
||||
Vty.EvKey (Vty.KChar 'g') [] -> do
|
||||
EvKey (KChar 'q') [] -> halt st
|
||||
EvKey KEsc [] -> continue $ resetScreens d st
|
||||
EvKey k [] | k `elem` [KChar 'h', KChar '?'] -> continue $ setMode Help st
|
||||
EvKey (KChar 'g') [] -> do
|
||||
d <- liftIO getCurrentDay
|
||||
(ej, _) <- liftIO $ journalReloadIfChanged copts d j
|
||||
case ej of
|
||||
Left err -> continue $ screenEnter d errorScreen{esError=err} st
|
||||
Right j' -> do
|
||||
-- got to redo the register screen's transactions report, to get the latest transactions list for this screen
|
||||
-- XXX duplicates rsInit
|
||||
@ -158,23 +159,17 @@ tsHandle st@AppState{aScreen=s@TransactionScreen{tsTransaction=(i,t)
|
||||
,tsTransactions=numberedts
|
||||
,tsAccount=acct}}
|
||||
continue $ regenerateScreens j' d st'
|
||||
|
||||
Left err -> continue $ screenEnter d errorScreen{esError=err} st
|
||||
|
||||
-- if allowing toggling here, we should refresh the txn list from the parent register screen
|
||||
-- Vty.EvKey (Vty.KChar 'E') [] -> continue $ regenerateScreens j d $ stToggleEmpty st
|
||||
-- Vty.EvKey (Vty.KChar 'C') [] -> continue $ regenerateScreens j d $ stToggleCleared st
|
||||
-- Vty.EvKey (Vty.KChar 'R') [] -> continue $ regenerateScreens j d $ stToggleReal st
|
||||
|
||||
Vty.EvKey (Vty.KUp) [] -> continue $ regenerateScreens j d st{aScreen=s{tsTransaction=(iprev,tprev)}}
|
||||
Vty.EvKey (Vty.KDown) [] -> continue $ regenerateScreens j d st{aScreen=s{tsTransaction=(inext,tnext)}}
|
||||
|
||||
Vty.EvKey (Vty.KLeft) [] -> continue st''
|
||||
-- EvKey (KChar 'E') [] -> continue $ regenerateScreens j d $ stToggleEmpty st
|
||||
-- EvKey (KChar 'C') [] -> continue $ regenerateScreens j d $ stToggleCleared st
|
||||
-- EvKey (KChar 'R') [] -> continue $ regenerateScreens j d $ stToggleReal st
|
||||
EvKey KUp [] -> continue $ regenerateScreens j d st{aScreen=s{tsTransaction=(iprev,tprev)}}
|
||||
EvKey KDown [] -> continue $ regenerateScreens j d st{aScreen=s{tsTransaction=(inext,tnext)}}
|
||||
EvKey KLeft [] -> continue st''
|
||||
where
|
||||
st'@AppState{aScreen=scr} = popScreen st
|
||||
st'' = st'{aScreen=rsSelect (fromIntegral i) scr}
|
||||
|
||||
_ev -> continue st
|
||||
_ -> continue st
|
||||
|
||||
tsHandle _ _ = error "event handler called with wrong screen type, should not happen"
|
||||
|
||||
|
||||
@ -253,7 +253,7 @@ helpDialog =
|
||||
-- | Event handler used when help mode is active.
|
||||
helpHandle st ev =
|
||||
case ev of
|
||||
Vty.EvKey k [] | k `elem` [Vty.KEsc, Vty.KChar 'h'] -> continue $ setMode Normal st
|
||||
EvKey k [] | k `elem` [KEsc, KChar 'h'] -> continue $ setMode Normal st
|
||||
_ -> continue st
|
||||
|
||||
-- | In the EventM monad, get the named current viewport's width and height,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user