mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-26 03:42:25 +03:00
fix: ui: fix state bugs from brick 1 migration (#1889)
This commit is contained in:
parent
67cd6be424
commit
b6353804b8
@ -371,21 +371,24 @@ asHandle ev = do
|
||||
list' <- nestEventM' _asList $ handleListEvent (normaliseMovementKeys ev)
|
||||
put' $ ui{aScreen=scr & asList .~ list' & asSelectedAccount .~ selacct }
|
||||
|
||||
MouseDown{} -> put ui
|
||||
MouseUp{} -> put ui
|
||||
AppEvent _ -> put ui
|
||||
MouseDown{} -> return ()
|
||||
MouseUp{} -> return ()
|
||||
AppEvent _ -> return ()
|
||||
|
||||
_ -> dlogUiTraceM "asHandle 2" >> errorWrongScreenType "event handler"
|
||||
|
||||
asEnterRegister :: Day -> AccountName -> UIState -> EventM Name UIState ()
|
||||
asEnterRegister d selacct ui = do
|
||||
rsCenterAndContinue $
|
||||
-- flip rsHandle (VtyEvent (EvKey (KChar 'l') [MCtrl])) $
|
||||
screenEnter d regscr ui
|
||||
dlogUiTraceM "asEnterRegister"
|
||||
let
|
||||
regscr = rsSetAccount selacct isdepthclipped registerScreen
|
||||
where
|
||||
regscr = rsSetAccount selacct isdepthclipped registerScreen
|
||||
isdepthclipped = case getDepth ui of
|
||||
Just d -> accountNameLevel selacct >= d
|
||||
Nothing -> False
|
||||
Just d -> accountNameLevel selacct >= d
|
||||
Nothing -> False
|
||||
let ui' = screenEnter d regscr ui
|
||||
put' ui'
|
||||
rsCenterSelection ui'
|
||||
|
||||
asSetSelectedAccount a s@AccountsScreen{} = s & asSelectedAccount .~ a
|
||||
asSetSelectedAccount _ s = s
|
||||
|
@ -166,8 +166,8 @@ runBrickUi uopts@UIOpts{uoCliOpts=copts@CliOpts{inputopts_=_iopts,reportspec_=rs
|
||||
appStartEvent = return ()
|
||||
, appAttrMap = const $ fromMaybe defaultTheme $ getTheme =<< uoTheme uopts'
|
||||
, appChooseCursor = showFirstCursor
|
||||
, appHandleEvent = sHandle (aScreen ui)
|
||||
, appDraw = sDraw (aScreen ui)
|
||||
, appHandleEvent = \ev -> do ui <- get; sHandle (aScreen ui) ev
|
||||
, appDraw = \ui -> sDraw (aScreen ui) ui
|
||||
}
|
||||
|
||||
-- print (length (show ui)) >> exitSuccess -- show any debug output to this point & quit
|
||||
|
@ -425,8 +425,7 @@ rsHandle ev = do
|
||||
|
||||
isBlankElement mel = ((rsItemDate . snd) <$> mel) == Just ""
|
||||
|
||||
rsCenterAndContinue ui = do
|
||||
scrollSelectionToMiddle $ rsList $ aScreen ui
|
||||
put ui
|
||||
rsCenterSelection :: UIState -> EventM Name UIState ()
|
||||
rsCenterSelection = scrollSelectionToMiddle . rsList . aScreen
|
||||
|
||||
rsListSize = V.length . V.takeWhile ((/="").rsItemDate) . listElements
|
||||
|
Loading…
Reference in New Issue
Block a user