imp:ui: debug output improvements

This commit is contained in:
Simon Michael 2025-09-11 23:25:15 +01:00
parent 7ccc0d5bdd
commit 53bd228973
6 changed files with 22 additions and 15 deletions

View File

@ -69,7 +69,7 @@ asDrawHelper :: UIState -> ReportOpts -> String -> [Widget Name]
asDrawHelper UIState{aScreen=scr, aopts=uopts, ajournal=j, aMode=mode} ropts scrname = asDrawHelper UIState{aScreen=scr, aopts=uopts, ajournal=j, aMode=mode} ropts scrname =
dbgui "asDrawHelper" $ dbgui "asDrawHelper" $
case toAccountsLikeScreen scr of case toAccountsLikeScreen scr of
Nothing -> dbgui "asDrawHelper" $ errorWrongScreenType "draw helper" -- PARTIAL: Nothing -> dbgui "asDrawHelper" $ errorWrongScreenType "asDrawHelper" -- PARTIAL:
Just (ALS _ ass) -> case mode of Just (ALS _ ass) -> case mode of
Help -> [helpDialog, maincontent] Help -> [helpDialog, maincontent]
_ -> [maincontent] _ -> [maincontent]
@ -189,7 +189,7 @@ asHandle ev = do
dbguiEv "asHandle" dbguiEv "asHandle"
ui0@UIState{aScreen=scr, aMode=mode} <- get' ui0@UIState{aScreen=scr, aMode=mode} <- get'
case toAccountsLikeScreen scr of case toAccountsLikeScreen scr of
Nothing -> dbgui "asHandle" $ errorWrongScreenType "event handler" -- PARTIAL: Nothing -> dbgui "asHandle" $ errorWrongScreenType "asHandle" -- PARTIAL:
Just als@(ALS scons ass) -> do Just als@(ALS scons ass) -> do
-- save the currently selected account, in case we leave this screen and lose the selection -- save the currently selected account, in case we leave this screen and lose the selection
put' ui0{aScreen=scons ass{_assSelectedAccount=asSelectedAccount ass}} put' ui0{aScreen=scons ass{_assSelectedAccount=asSelectedAccount ass}}

View File

@ -104,7 +104,7 @@ esHandle ev = do
VtyEvent (EvKey (KChar 'z') [MCtrl]) -> suspend ui VtyEvent (EvKey (KChar 'z') [MCtrl]) -> suspend ui
_ -> return () _ -> return ()
_ -> errorWrongScreenType "event handler" _ -> errorWrongScreenType "esHandle"
-- | Parse the file name, line and column number from a hledger parse error message, if possible. -- | Parse the file name, line and column number from a hledger parse error message, if possible.
-- Temporary, we should keep the original parse error location. XXX -- Temporary, we should keep the original parse error location. XXX

View File

@ -87,7 +87,7 @@ msDraw UIState{aopts=_uopts@UIOpts{uoCliOpts=copts@CliOpts{reportspec_=_rspec@Re
,("q", str "quit") ,("q", str "quit")
] ]
msDraw _ = dbgui "msDraw" $ errorWrongScreenType "draw function" -- PARTIAL: msDraw _ = dbgui "msDraw" $ errorWrongScreenType "msDraw" -- PARTIAL:
-- msDrawItem :: (Int,Int) -> Bool -> MenuScreenItem -> Widget Name -- msDrawItem :: (Int,Int) -> Bool -> MenuScreenItem -> Widget Name
-- msDrawItem (_acctwidth, _balwidth) _selected MenuScreenItem{..} = -- msDrawItem (_acctwidth, _balwidth) _selected MenuScreenItem{..} =
@ -257,7 +257,7 @@ msHandle ev = do
MouseUp{} -> return () MouseUp{} -> return ()
AppEvent _ -> return () AppEvent _ -> return ()
_ -> dbguiEv "msHandle" >> errorWrongScreenType "event handler" _ -> dbguiEv "msHandle" >> errorWrongScreenType "msHandle"
msEnterScreen :: Day -> ScreenName -> UIState -> EventM Name UIState () msEnterScreen :: Day -> ScreenName -> UIState -> EventM Name UIState ()
msEnterScreen d scrname ui@UIState{ajournal=j, aopts=uopts} = do msEnterScreen d scrname ui@UIState{ajournal=j, aopts=uopts} = do

View File

@ -49,7 +49,7 @@ rsDraw :: UIState -> [Widget Name]
rsDraw UIState{aopts=_uopts@UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec}} rsDraw UIState{aopts=_uopts@UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec}}
,aScreen=RS RSS{..} ,aScreen=RS RSS{..}
,aMode=mode ,aMode=mode
} = dbgui "rsDraw 1" $ } = dbgui "rsDraw" $
case mode of case mode of
Help -> [helpDialog, maincontent] Help -> [helpDialog, maincontent]
_ -> [maincontent] _ -> [maincontent]
@ -156,7 +156,7 @@ rsDraw UIState{aopts=_uopts@UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec}}
-- ,("q", "quit") -- ,("q", "quit")
] ]
rsDraw _ = dbgui "rsDraw 2" $ errorWrongScreenType "draw function" -- PARTIAL: rsDraw _ = dbgui "rsDraw" $ errorWrongScreenType "rsDraw" -- PARTIAL:
rsDrawItem :: (Int,Int,Int,Int,Int) -> Bool -> RegisterScreenItem -> Widget Name rsDrawItem :: (Int,Int,Int,Int,Int) -> Bool -> RegisterScreenItem -> Widget Name
rsDrawItem (datewidth,descwidth,acctswidth,changewidth,balwidth) selected RegisterScreenItem{..} = rsDrawItem (datewidth,descwidth,acctswidth,changewidth,balwidth) selected RegisterScreenItem{..} =
@ -187,7 +187,7 @@ rsDrawItem (datewidth,descwidth,acctswidth,changewidth,balwidth) selected Regist
rsHandle :: BrickEvent Name AppEvent -> EventM Name UIState () rsHandle :: BrickEvent Name AppEvent -> EventM Name UIState ()
rsHandle ev = do rsHandle ev = do
ui0 <- get' ui0 <- get'
dbguiEv "rsHandle 1" dbguiEv "rsHandle"
case ui0 of case ui0 of
ui@UIState{ ui@UIState{
aScreen=RS sst@RSS{..} aScreen=RS sst@RSS{..}
@ -332,7 +332,7 @@ rsHandle ev = do
MouseUp{} -> return () MouseUp{} -> return ()
AppEvent _ -> return () AppEvent _ -> return ()
_ -> dbgui "rsHandle 2" $ errorWrongScreenType "event handler" _ -> errorWrongScreenType "rsHandle"
isBlankElement mel = ((rsItemDate . snd) <$> mel) == Just "" isBlankElement mel = ((rsItemDate . snd) <$> mel) == Just ""

View File

@ -97,7 +97,7 @@ tsDraw UIState{aopts=UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec@ReportSpec
-- ,("q", "quit") -- ,("q", "quit")
] ]
tsDraw _ = errorWrongScreenType "draw function" -- PARTIAL: tsDraw _ = errorWrongScreenType "tsDraw" -- PARTIAL:
-- Render a transaction suitably for the transaction screen. -- Render a transaction suitably for the transaction screen.
showTxn :: ReportOpts -> ReportSpec -> Journal -> Transaction -> T.Text showTxn :: ReportOpts -> ReportSpec -> Journal -> Transaction -> T.Text
@ -190,7 +190,7 @@ tsHandle ev = do
VtyEvent (EvKey (KChar 'z') [MCtrl]) -> suspend ui VtyEvent (EvKey (KChar 'z') [MCtrl]) -> suspend ui
_ -> return () _ -> return ()
_ -> errorWrongScreenType "event handler" _ -> errorWrongScreenType "tsHandle"
-- | Select a new transaction and update the previous register screen -- | Select a new transaction and update the previous register screen
tsSelect :: Integer -> Transaction -> UIState -> UIState tsSelect :: Integer -> Transaction -> UIState -> UIState

View File

@ -60,6 +60,7 @@ import Hledger.Cli.CliOptions
import Hledger.UI.UITypes import Hledger.UI.UITypes
import Hledger.UI.UIOptions (UIOpts(uoCliOpts)) import Hledger.UI.UIOptions (UIOpts(uoCliOpts))
import Hledger.UI.UIScreens (screenUpdate) import Hledger.UI.UIScreens (screenUpdate)
import Hledger.UI.UIUtils (showScreenId)
-- | Make an initial UI state with the given options, journal, -- | Make an initial UI state with the given options, journal,
-- parent screen stack if any, and starting screen. -- parent screen stack if any, and starting screen.
@ -340,12 +341,18 @@ setMode :: Mode -> UIState -> UIState
setMode m ui = ui{aMode=m} setMode m ui = ui{aMode=m}
pushScreen :: Screen -> UIState -> UIState pushScreen :: Screen -> UIState -> UIState
pushScreen scr ui = ui{aPrevScreens=(aScreen ui:aPrevScreens ui) pushScreen scr ui =
,aScreen=scr dbg1Msg ("pushing screen " <> showScreenId scr)
} ui{aPrevScreens=aScreen ui:aPrevScreens ui
,aScreen=scr
}
popScreen :: UIState -> UIState popScreen :: UIState -> UIState
popScreen ui@UIState{aPrevScreens=s:ss} = ui{aScreen=s, aPrevScreens=ss} popScreen ui@UIState{aPrevScreens = s : ss} =
dbg1Msg ("popping screen " <> showScreenId (aScreen ui))
ui{aPrevScreens = ss
,aScreen = s
}
popScreen ui = ui popScreen ui = ui
-- | Reset options to their startup values, discard screen navigation history, -- | Reset options to their startup values, discard screen navigation history,