diff --git a/hledger-ui/Hledger/UI/AccountsScreen.hs b/hledger-ui/Hledger/UI/AccountsScreen.hs index 4c5052914..c8655cd08 100644 --- a/hledger-ui/Hledger/UI/AccountsScreen.hs +++ b/hledger-ui/Hledger/UI/AccountsScreen.hs @@ -69,7 +69,7 @@ asDrawHelper :: UIState -> ReportOpts -> String -> [Widget Name] asDrawHelper UIState{aScreen=scr, aopts=uopts, ajournal=j, aMode=mode} ropts scrname = dbgui "asDrawHelper" $ case toAccountsLikeScreen scr of - Nothing -> dbgui "asDrawHelper" $ errorWrongScreenType "draw helper" -- PARTIAL: + Nothing -> dbgui "asDrawHelper" $ errorWrongScreenType "asDrawHelper" -- PARTIAL: Just (ALS _ ass) -> case mode of Help -> [helpDialog, maincontent] _ -> [maincontent] @@ -189,7 +189,7 @@ asHandle ev = do dbguiEv "asHandle" ui0@UIState{aScreen=scr, aMode=mode} <- get' case toAccountsLikeScreen scr of - Nothing -> dbgui "asHandle" $ errorWrongScreenType "event handler" -- PARTIAL: + Nothing -> dbgui "asHandle" $ errorWrongScreenType "asHandle" -- PARTIAL: Just als@(ALS scons ass) -> do -- save the currently selected account, in case we leave this screen and lose the selection put' ui0{aScreen=scons ass{_assSelectedAccount=asSelectedAccount ass}} diff --git a/hledger-ui/Hledger/UI/ErrorScreen.hs b/hledger-ui/Hledger/UI/ErrorScreen.hs index e6954688c..9bebe6b10 100644 --- a/hledger-ui/Hledger/UI/ErrorScreen.hs +++ b/hledger-ui/Hledger/UI/ErrorScreen.hs @@ -104,7 +104,7 @@ esHandle ev = do VtyEvent (EvKey (KChar 'z') [MCtrl]) -> suspend ui _ -> return () - _ -> errorWrongScreenType "event handler" + _ -> errorWrongScreenType "esHandle" -- | 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 diff --git a/hledger-ui/Hledger/UI/MenuScreen.hs b/hledger-ui/Hledger/UI/MenuScreen.hs index ebab451de..fb5d36486 100644 --- a/hledger-ui/Hledger/UI/MenuScreen.hs +++ b/hledger-ui/Hledger/UI/MenuScreen.hs @@ -87,7 +87,7 @@ msDraw UIState{aopts=_uopts@UIOpts{uoCliOpts=copts@CliOpts{reportspec_=_rspec@Re ,("q", str "quit") ] -msDraw _ = dbgui "msDraw" $ errorWrongScreenType "draw function" -- PARTIAL: +msDraw _ = dbgui "msDraw" $ errorWrongScreenType "msDraw" -- PARTIAL: -- msDrawItem :: (Int,Int) -> Bool -> MenuScreenItem -> Widget Name -- msDrawItem (_acctwidth, _balwidth) _selected MenuScreenItem{..} = @@ -257,7 +257,7 @@ msHandle ev = do MouseUp{} -> return () AppEvent _ -> return () - _ -> dbguiEv "msHandle" >> errorWrongScreenType "event handler" + _ -> dbguiEv "msHandle" >> errorWrongScreenType "msHandle" msEnterScreen :: Day -> ScreenName -> UIState -> EventM Name UIState () msEnterScreen d scrname ui@UIState{ajournal=j, aopts=uopts} = do diff --git a/hledger-ui/Hledger/UI/RegisterScreen.hs b/hledger-ui/Hledger/UI/RegisterScreen.hs index 2afd82dff..56a46ec1e 100644 --- a/hledger-ui/Hledger/UI/RegisterScreen.hs +++ b/hledger-ui/Hledger/UI/RegisterScreen.hs @@ -49,7 +49,7 @@ rsDraw :: UIState -> [Widget Name] rsDraw UIState{aopts=_uopts@UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec}} ,aScreen=RS RSS{..} ,aMode=mode - } = dbgui "rsDraw 1" $ + } = dbgui "rsDraw" $ case mode of Help -> [helpDialog, maincontent] _ -> [maincontent] @@ -156,7 +156,7 @@ rsDraw UIState{aopts=_uopts@UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec}} -- ,("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 (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 ev = do ui0 <- get' - dbguiEv "rsHandle 1" + dbguiEv "rsHandle" case ui0 of ui@UIState{ aScreen=RS sst@RSS{..} @@ -332,7 +332,7 @@ rsHandle ev = do MouseUp{} -> return () AppEvent _ -> return () - _ -> dbgui "rsHandle 2" $ errorWrongScreenType "event handler" + _ -> errorWrongScreenType "rsHandle" isBlankElement mel = ((rsItemDate . snd) <$> mel) == Just "" diff --git a/hledger-ui/Hledger/UI/TransactionScreen.hs b/hledger-ui/Hledger/UI/TransactionScreen.hs index cad3ae752..b875308f6 100644 --- a/hledger-ui/Hledger/UI/TransactionScreen.hs +++ b/hledger-ui/Hledger/UI/TransactionScreen.hs @@ -97,7 +97,7 @@ tsDraw UIState{aopts=UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec@ReportSpec -- ,("q", "quit") ] -tsDraw _ = errorWrongScreenType "draw function" -- PARTIAL: +tsDraw _ = errorWrongScreenType "tsDraw" -- PARTIAL: -- Render a transaction suitably for the transaction screen. showTxn :: ReportOpts -> ReportSpec -> Journal -> Transaction -> T.Text @@ -190,7 +190,7 @@ tsHandle ev = do VtyEvent (EvKey (KChar 'z') [MCtrl]) -> suspend ui _ -> return () - _ -> errorWrongScreenType "event handler" + _ -> errorWrongScreenType "tsHandle" -- | Select a new transaction and update the previous register screen tsSelect :: Integer -> Transaction -> UIState -> UIState diff --git a/hledger-ui/Hledger/UI/UIState.hs b/hledger-ui/Hledger/UI/UIState.hs index c045ff38b..a67309b4c 100644 --- a/hledger-ui/Hledger/UI/UIState.hs +++ b/hledger-ui/Hledger/UI/UIState.hs @@ -60,6 +60,7 @@ import Hledger.Cli.CliOptions import Hledger.UI.UITypes import Hledger.UI.UIOptions (UIOpts(uoCliOpts)) import Hledger.UI.UIScreens (screenUpdate) +import Hledger.UI.UIUtils (showScreenId) -- | Make an initial UI state with the given options, journal, -- parent screen stack if any, and starting screen. @@ -340,12 +341,18 @@ setMode :: Mode -> UIState -> UIState setMode m ui = ui{aMode=m} pushScreen :: Screen -> UIState -> UIState -pushScreen scr ui = ui{aPrevScreens=(aScreen ui:aPrevScreens ui) - ,aScreen=scr - } +pushScreen scr ui = + dbg1Msg ("pushing screen " <> showScreenId scr) + ui{aPrevScreens=aScreen ui:aPrevScreens ui + ,aScreen=scr + } 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 -- | Reset options to their startup values, discard screen navigation history,