dev: ui: rename hledger-ui debug helpers
This commit is contained in:
parent
603fae70c0
commit
9a9ebfc0e3
@ -50,7 +50,7 @@ import Control.Arrow ((>>>))
|
|||||||
|
|
||||||
|
|
||||||
asDraw :: UIState -> [Widget Name]
|
asDraw :: UIState -> [Widget Name]
|
||||||
asDraw ui = dlogUiTrace "asDraw" $ asDrawHelper ui ropts' scrname showbalchgkey
|
asDraw ui = dbgui "asDraw" $ asDrawHelper ui ropts' scrname showbalchgkey
|
||||||
where
|
where
|
||||||
ropts' = _rsReportOpts $ reportspec_ $ uoCliOpts $ aopts ui
|
ropts' = _rsReportOpts $ reportspec_ $ uoCliOpts $ aopts ui
|
||||||
scrname = "account " ++ if ishistorical then "balances" else "changes"
|
scrname = "account " ++ if ishistorical then "balances" else "changes"
|
||||||
@ -63,9 +63,9 @@ asDraw ui = dlogUiTrace "asDraw" $ asDrawHelper ui ropts' scrname showbalchgkey
|
|||||||
-- for toggling between end balance and balance change mode.
|
-- for toggling between end balance and balance change mode.
|
||||||
asDrawHelper :: UIState -> ReportOpts -> String -> Bool -> [Widget Name]
|
asDrawHelper :: UIState -> ReportOpts -> String -> Bool -> [Widget Name]
|
||||||
asDrawHelper UIState{aScreen=scr, aopts=uopts, ajournal=j, aMode=mode} ropts scrname showbalchgkey =
|
asDrawHelper UIState{aScreen=scr, aopts=uopts, ajournal=j, aMode=mode} ropts scrname showbalchgkey =
|
||||||
dlogUiTrace "asDrawHelper" $
|
dbgui "asDrawHelper" $
|
||||||
case toAccountsLikeScreen scr of
|
case toAccountsLikeScreen scr of
|
||||||
Nothing -> dlogUiTrace "asDrawHelper" $ errorWrongScreenType "draw helper" -- PARTIAL:
|
Nothing -> dbgui "asDrawHelper" $ errorWrongScreenType "draw helper" -- PARTIAL:
|
||||||
Just (ALS _ ass) -> case mode of
|
Just (ALS _ ass) -> case mode of
|
||||||
Help -> [helpDialog, maincontent]
|
Help -> [helpDialog, maincontent]
|
||||||
_ -> [maincontent]
|
_ -> [maincontent]
|
||||||
@ -178,10 +178,10 @@ asDrawItem (acctwidth, balwidth) selected AccountsScreenItem{..} =
|
|||||||
-- | Handle events on any accounts-like screen (all accounts, balance sheet, income statement..).
|
-- | Handle events on any accounts-like screen (all accounts, balance sheet, income statement..).
|
||||||
asHandle :: BrickEvent Name AppEvent -> EventM Name UIState ()
|
asHandle :: BrickEvent Name AppEvent -> EventM Name UIState ()
|
||||||
asHandle ev = do
|
asHandle ev = do
|
||||||
dlogUiTraceM "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 -> dlogUiTrace "asHandle" $ errorWrongScreenType "event handler" -- PARTIAL:
|
Nothing -> dbgui "asHandle" $ errorWrongScreenType "event handler" -- 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}}
|
||||||
@ -194,7 +194,7 @@ asHandle ev = do
|
|||||||
-- The provided AccountsLikeScreen should correspond to the ui state's current screen.
|
-- The provided AccountsLikeScreen should correspond to the ui state's current screen.
|
||||||
asHandleNormalMode :: AccountsLikeScreen -> BrickEvent Name AppEvent -> EventM Name UIState ()
|
asHandleNormalMode :: AccountsLikeScreen -> BrickEvent Name AppEvent -> EventM Name UIState ()
|
||||||
asHandleNormalMode (ALS scons ass) ev = do
|
asHandleNormalMode (ALS scons ass) ev = do
|
||||||
dlogUiTraceM "asHandleNormalMode"
|
dbguiEv "asHandleNormalMode"
|
||||||
|
|
||||||
ui@UIState{aopts=UIOpts{uoCliOpts=copts}, ajournal=j} <- get'
|
ui@UIState{aopts=UIOpts{uoCliOpts=copts}, ajournal=j} <- get'
|
||||||
d <- liftIO getCurrentDay
|
d <- liftIO getCurrentDay
|
||||||
@ -353,7 +353,7 @@ handleHelpMode ev = do
|
|||||||
|
|
||||||
enterRegisterScreen :: Day -> AccountName -> UIState -> EventM Name UIState ()
|
enterRegisterScreen :: Day -> AccountName -> UIState -> EventM Name UIState ()
|
||||||
enterRegisterScreen d acct ui@UIState{ajournal=j, aopts=uopts} = do
|
enterRegisterScreen d acct ui@UIState{ajournal=j, aopts=uopts} = do
|
||||||
dlogUiTraceM "enterRegisterScreen"
|
dbguiEv "enterRegisterScreen"
|
||||||
let
|
let
|
||||||
regscr = rsNew uopts d j acct isdepthclipped
|
regscr = rsNew uopts d j acct isdepthclipped
|
||||||
where
|
where
|
||||||
|
|||||||
@ -20,11 +20,11 @@ import Hledger.UI.AccountsScreen (asHandle, asDrawHelper)
|
|||||||
|
|
||||||
|
|
||||||
bsDraw :: UIState -> [Widget Name]
|
bsDraw :: UIState -> [Widget Name]
|
||||||
bsDraw ui = dlogUiTrace "bsDraw" $ asDrawHelper ui ropts' scrname showbalchgkey
|
bsDraw ui = dbgui "bsDraw" $ asDrawHelper ui ropts' scrname showbalchgkey
|
||||||
where
|
where
|
||||||
scrname = "balance sheet"
|
scrname = "balance sheet"
|
||||||
ropts' = (_rsReportOpts $ reportspec_ $ uoCliOpts $ aopts ui){balanceaccum_=Historical}
|
ropts' = (_rsReportOpts $ reportspec_ $ uoCliOpts $ aopts ui){balanceaccum_=Historical}
|
||||||
showbalchgkey = False
|
showbalchgkey = False
|
||||||
|
|
||||||
bsHandle :: BrickEvent Name AppEvent -> EventM Name UIState ()
|
bsHandle :: BrickEvent Name AppEvent -> EventM Name UIState ()
|
||||||
bsHandle = asHandle . dlogUiTrace "bsHandle"
|
bsHandle = asHandle . dbgui "bsHandle"
|
||||||
|
|||||||
@ -149,10 +149,10 @@ uiReloadJournal copts d ui = do
|
|||||||
ej <-
|
ej <-
|
||||||
let copts' = enableForecastPreservingPeriod ui copts
|
let copts' = enableForecastPreservingPeriod ui copts
|
||||||
in runExceptT $ journalReload copts'
|
in runExceptT $ journalReload copts'
|
||||||
-- dlogUiTraceIO $ ("uiReloadJournal before reload: "++) $ pshow' $ map tdescription $ jtxns $ ajournal ui
|
-- dbguiIO $ ("uiReloadJournal before reload: "++) $ pshow' $ map tdescription $ jtxns $ ajournal ui
|
||||||
return $ case ej of
|
return $ case ej of
|
||||||
Right j ->
|
Right j ->
|
||||||
-- dlogUiTrace (("uiReloadJournal after reload: "++) $ pshow' $ map tdescription $ jtxns j) $
|
-- dbgui (("uiReloadJournal after reload: "++) $ pshow' $ map tdescription $ jtxns j) $
|
||||||
regenerateScreens j d ui
|
regenerateScreens j d ui
|
||||||
Left err ->
|
Left err ->
|
||||||
case ui of
|
case ui of
|
||||||
|
|||||||
@ -20,11 +20,11 @@ import Hledger.UI.AccountsScreen (asHandle, asDrawHelper)
|
|||||||
|
|
||||||
|
|
||||||
isDraw :: UIState -> [Widget Name]
|
isDraw :: UIState -> [Widget Name]
|
||||||
isDraw ui = dlogUiTrace "isDraw" $ asDrawHelper ui ropts' scrname showbalchgkey
|
isDraw ui = dbgui "isDraw" $ asDrawHelper ui ropts' scrname showbalchgkey
|
||||||
where
|
where
|
||||||
scrname = "income statement"
|
scrname = "income statement"
|
||||||
ropts' = (_rsReportOpts $ reportspec_ $ uoCliOpts $ aopts ui){balanceaccum_=PerPeriod}
|
ropts' = (_rsReportOpts $ reportspec_ $ uoCliOpts $ aopts ui){balanceaccum_=PerPeriod}
|
||||||
showbalchgkey = False
|
showbalchgkey = False
|
||||||
|
|
||||||
isHandle :: BrickEvent Name AppEvent -> EventM Name UIState ()
|
isHandle :: BrickEvent Name AppEvent -> EventM Name UIState ()
|
||||||
isHandle = asHandle . dlogUiTrace "isHandle"
|
isHandle = asHandle . dbgui "isHandle"
|
||||||
|
|||||||
@ -33,7 +33,7 @@ import Hledger.UI.Theme
|
|||||||
import Hledger.UI.UIOptions
|
import Hledger.UI.UIOptions
|
||||||
import Hledger.UI.UITypes
|
import Hledger.UI.UITypes
|
||||||
import Hledger.UI.UIState (uiState, getDepth)
|
import Hledger.UI.UIState (uiState, getDepth)
|
||||||
import Hledger.UI.UIUtils (dlogUiTraceM, dlogUiTraceIO)
|
import Hledger.UI.UIUtils (dbguiEv, dbguiIO)
|
||||||
import Hledger.UI.MenuScreen
|
import Hledger.UI.MenuScreen
|
||||||
import Hledger.UI.AccountsScreen
|
import Hledger.UI.AccountsScreen
|
||||||
import Hledger.UI.BalancesheetScreen
|
import Hledger.UI.BalancesheetScreen
|
||||||
@ -167,7 +167,7 @@ runBrickUi uopts0@UIOpts{uoCliOpts=copts@CliOpts{inputopts_=_iopts,reportspec_=r
|
|||||||
setMode (outputIface v) Mouse True
|
setMode (outputIface v) Mouse True
|
||||||
return v
|
return v
|
||||||
|
|
||||||
dlogUiTraceIO "\n\n==== hledger-ui start"
|
dbguiIO "\n\n==== hledger-ui start"
|
||||||
|
|
||||||
if not (uoWatch uopts)
|
if not (uoWatch uopts)
|
||||||
then do
|
then do
|
||||||
@ -244,7 +244,7 @@ brickApp mtheme = App {
|
|||||||
|
|
||||||
uiHandle :: BrickEvent Name AppEvent -> EventM Name UIState ()
|
uiHandle :: BrickEvent Name AppEvent -> EventM Name UIState ()
|
||||||
uiHandle ev = do
|
uiHandle ev = do
|
||||||
dlogUiTraceM $ "\n==== " ++ show ev
|
dbguiEv $ "\n==== " ++ show ev
|
||||||
ui <- get
|
ui <- get
|
||||||
case aScreen ui of
|
case aScreen ui of
|
||||||
MS _ -> msHandle ev
|
MS _ -> msHandle ev
|
||||||
|
|||||||
@ -42,7 +42,7 @@ msDraw UIState{aopts=_uopts@UIOpts{uoCliOpts=copts@CliOpts{reportspec_=_rspec}}
|
|||||||
,ajournal=j
|
,ajournal=j
|
||||||
,aScreen=MS sst
|
,aScreen=MS sst
|
||||||
,aMode=mode
|
,aMode=mode
|
||||||
} = dlogUiTrace "msDraw" $
|
} = dbgui "msDraw" $
|
||||||
case mode of
|
case mode of
|
||||||
Help -> [helpDialog, maincontent]
|
Help -> [helpDialog, maincontent]
|
||||||
_ -> [maincontent]
|
_ -> [maincontent]
|
||||||
@ -83,7 +83,7 @@ msDraw UIState{aopts=_uopts@UIOpts{uoCliOpts=copts@CliOpts{reportspec_=_rspec}}
|
|||||||
,("q", str "quit")
|
,("q", str "quit")
|
||||||
]
|
]
|
||||||
|
|
||||||
msDraw _ = dlogUiTrace "msDraw" $ errorWrongScreenType "draw function" -- PARTIAL:
|
msDraw _ = dbgui "msDraw" $ errorWrongScreenType "draw function" -- 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{..} =
|
||||||
@ -96,7 +96,7 @@ msDrawItem _selected MenuScreenItem{..} =
|
|||||||
msHandle :: BrickEvent Name AppEvent -> EventM Name UIState ()
|
msHandle :: BrickEvent Name AppEvent -> EventM Name UIState ()
|
||||||
msHandle ev = do
|
msHandle ev = do
|
||||||
ui0 <- get'
|
ui0 <- get'
|
||||||
dlogUiTraceM "msHandle"
|
dbguiEv "msHandle"
|
||||||
case ui0 of
|
case ui0 of
|
||||||
ui@UIState{
|
ui@UIState{
|
||||||
aopts=UIOpts{uoCliOpts=copts}
|
aopts=UIOpts{uoCliOpts=copts}
|
||||||
@ -249,11 +249,11 @@ msHandle ev = do
|
|||||||
MouseUp{} -> return ()
|
MouseUp{} -> return ()
|
||||||
AppEvent _ -> return ()
|
AppEvent _ -> return ()
|
||||||
|
|
||||||
_ -> dlogUiTraceM "msHandle" >> errorWrongScreenType "event handler"
|
_ -> dbguiEv "msHandle" >> errorWrongScreenType "event handler"
|
||||||
|
|
||||||
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
|
||||||
dlogUiTraceM "msEnterScreen"
|
dbguiEv "msEnterScreen"
|
||||||
let
|
let
|
||||||
scr = case scrname of
|
scr = case scrname of
|
||||||
Accounts -> asNew uopts d j Nothing
|
Accounts -> asNew uopts d j Nothing
|
||||||
|
|||||||
@ -45,7 +45,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
|
||||||
} = dlogUiTrace "rsDraw 1" $
|
} = dbgui "rsDraw 1" $
|
||||||
case mode of
|
case mode of
|
||||||
Help -> [helpDialog, maincontent]
|
Help -> [helpDialog, maincontent]
|
||||||
_ -> [maincontent]
|
_ -> [maincontent]
|
||||||
@ -152,7 +152,7 @@ rsDraw UIState{aopts=_uopts@UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec}}
|
|||||||
-- ,("q", "quit")
|
-- ,("q", "quit")
|
||||||
]
|
]
|
||||||
|
|
||||||
rsDraw _ = dlogUiTrace "rsDraw 2" $ errorWrongScreenType "draw function" -- PARTIAL:
|
rsDraw _ = dbgui "rsDraw 2" $ errorWrongScreenType "draw function" -- 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{..} =
|
||||||
@ -183,7 +183,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'
|
||||||
dlogUiTraceM "rsHandle 1"
|
dbguiEv "rsHandle 1"
|
||||||
case ui0 of
|
case ui0 of
|
||||||
ui@UIState{
|
ui@UIState{
|
||||||
aScreen=RS sst@RSS{..}
|
aScreen=RS sst@RSS{..}
|
||||||
@ -328,7 +328,7 @@ rsHandle ev = do
|
|||||||
MouseUp{} -> return ()
|
MouseUp{} -> return ()
|
||||||
AppEvent _ -> return ()
|
AppEvent _ -> return ()
|
||||||
|
|
||||||
_ -> dlogUiTrace "rsHandle 2" $ errorWrongScreenType "event handler"
|
_ -> dbgui "rsHandle 2" $ errorWrongScreenType "event handler"
|
||||||
|
|
||||||
isBlankElement mel = ((rsItemDate . snd) <$> mel) == Just ""
|
isBlankElement mel = ((rsItemDate . snd) <$> mel) == Just ""
|
||||||
|
|
||||||
@ -349,7 +349,7 @@ rsCenterSelection ui = return ui
|
|||||||
|
|
||||||
rsEnterTransactionScreen :: AccountName -> [NumberedTransaction] -> NumberedTransaction -> UIState -> EventM Name UIState ()
|
rsEnterTransactionScreen :: AccountName -> [NumberedTransaction] -> NumberedTransaction -> UIState -> EventM Name UIState ()
|
||||||
rsEnterTransactionScreen acct nts nt ui = do
|
rsEnterTransactionScreen acct nts nt ui = do
|
||||||
dlogUiTraceM "rsEnterTransactionScreen"
|
dbguiEv "rsEnterTransactionScreen"
|
||||||
put' $
|
put' $
|
||||||
pushScreen (tsNew acct nts nt)
|
pushScreen (tsNew acct nts nt)
|
||||||
ui
|
ui
|
||||||
|
|||||||
@ -62,7 +62,7 @@ screenUpdate opts d j = \case
|
|||||||
-- Screen-specific arguments: the error message to show.
|
-- Screen-specific arguments: the error message to show.
|
||||||
esNew :: String -> Screen
|
esNew :: String -> Screen
|
||||||
esNew msg =
|
esNew msg =
|
||||||
dlogUiTrace "esNew" $
|
dbgui "esNew" $
|
||||||
ES ESS {
|
ES ESS {
|
||||||
_essError = msg
|
_essError = msg
|
||||||
,_essUnused = ()
|
,_essUnused = ()
|
||||||
@ -71,13 +71,13 @@ esNew msg =
|
|||||||
-- | Update an error screen. Currently a no-op since error screen
|
-- | Update an error screen. Currently a no-op since error screen
|
||||||
-- depends only on its screen-specific state.
|
-- depends only on its screen-specific state.
|
||||||
esUpdate :: ErrorScreenState -> ErrorScreenState
|
esUpdate :: ErrorScreenState -> ErrorScreenState
|
||||||
esUpdate = dlogUiTrace "esUpdate`"
|
esUpdate = dbgui "esUpdate`"
|
||||||
|
|
||||||
-- | Construct a menu screen.
|
-- | Construct a menu screen.
|
||||||
-- Screen-specific arguments: none.
|
-- Screen-specific arguments: none.
|
||||||
msNew :: Screen
|
msNew :: Screen
|
||||||
msNew =
|
msNew =
|
||||||
dlogUiTrace "msNew" $
|
dbgui "msNew" $
|
||||||
MS MSS {
|
MS MSS {
|
||||||
_mssList = list MenuList (V.fromList [
|
_mssList = list MenuList (V.fromList [
|
||||||
MenuScreenItem "All accounts" Accounts
|
MenuScreenItem "All accounts" Accounts
|
||||||
@ -90,7 +90,7 @@ msNew =
|
|||||||
-- | Update a menu screen. Currently a no-op since menu screen
|
-- | Update a menu screen. Currently a no-op since menu screen
|
||||||
-- has unchanging content.
|
-- has unchanging content.
|
||||||
msUpdate :: MenuScreenState -> MenuScreenState
|
msUpdate :: MenuScreenState -> MenuScreenState
|
||||||
msUpdate = dlogUiTrace "msUpdate"
|
msUpdate = dbgui "msUpdate"
|
||||||
|
|
||||||
nullass macct = ASS {
|
nullass macct = ASS {
|
||||||
_assSelectedAccount = fromMaybe "" macct
|
_assSelectedAccount = fromMaybe "" macct
|
||||||
@ -101,11 +101,11 @@ nullass macct = ASS {
|
|||||||
-- with the appropriate one selected.
|
-- with the appropriate one selected.
|
||||||
-- Screen-specific arguments: the account to select if any.
|
-- Screen-specific arguments: the account to select if any.
|
||||||
asNew :: UIOpts -> Day -> Journal -> Maybe AccountName -> Screen
|
asNew :: UIOpts -> Day -> Journal -> Maybe AccountName -> Screen
|
||||||
asNew uopts d j macct = dlogUiTrace "asNew" $ AS $ asUpdate uopts d j $ nullass macct
|
asNew uopts d j macct = dbgui "asNew" $ AS $ asUpdate uopts d j $ nullass macct
|
||||||
|
|
||||||
-- | Update an accounts screen's state from these options, reporting date, and journal.
|
-- | Update an accounts screen's state from these options, reporting date, and journal.
|
||||||
asUpdate :: UIOpts -> Day -> Journal -> AccountsScreenState -> AccountsScreenState
|
asUpdate :: UIOpts -> Day -> Journal -> AccountsScreenState -> AccountsScreenState
|
||||||
asUpdate uopts d = dlogUiTrace "asUpdate" .
|
asUpdate uopts d = dbgui "asUpdate" .
|
||||||
asUpdateHelper rspec d copts roptsmod extraquery
|
asUpdateHelper rspec d copts roptsmod extraquery
|
||||||
where
|
where
|
||||||
UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec}} = uopts
|
UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec}} = uopts
|
||||||
@ -115,7 +115,7 @@ asUpdate uopts d = dlogUiTrace "asUpdate" .
|
|||||||
-- | Update an accounts-like screen's state from this report spec, reporting date,
|
-- | Update an accounts-like screen's state from this report spec, reporting date,
|
||||||
-- cli options, report options modifier, extra query, and journal.
|
-- cli options, report options modifier, extra query, and journal.
|
||||||
asUpdateHelper :: ReportSpec -> Day -> CliOpts -> (ReportOpts -> ReportOpts) -> Query -> Journal -> AccountsScreenState -> AccountsScreenState
|
asUpdateHelper :: ReportSpec -> Day -> CliOpts -> (ReportOpts -> ReportOpts) -> Query -> Journal -> AccountsScreenState -> AccountsScreenState
|
||||||
asUpdateHelper rspec0 d copts roptsModify extraquery j ass = dlogUiTrace "asUpdateHelper"
|
asUpdateHelper rspec0 d copts roptsModify extraquery j ass = dbgui "asUpdateHelper"
|
||||||
ass{_assList=l}
|
ass{_assList=l}
|
||||||
where
|
where
|
||||||
ropts = roptsModify $ _rsReportOpts rspec0
|
ropts = roptsModify $ _rsReportOpts rspec0
|
||||||
@ -171,11 +171,11 @@ asUpdateHelper rspec0 d copts roptsModify extraquery j ass = dlogUiTrace "asUpda
|
|||||||
-- with the appropriate one selected.
|
-- with the appropriate one selected.
|
||||||
-- Screen-specific arguments: the account to select if any.
|
-- Screen-specific arguments: the account to select if any.
|
||||||
bsNew :: UIOpts -> Day -> Journal -> Maybe AccountName -> Screen
|
bsNew :: UIOpts -> Day -> Journal -> Maybe AccountName -> Screen
|
||||||
bsNew uopts d j macct = dlogUiTrace "bsNew" $ BS $ bsUpdate uopts d j $ nullass macct
|
bsNew uopts d j macct = dbgui "bsNew" $ BS $ bsUpdate uopts d j $ nullass macct
|
||||||
|
|
||||||
-- | Update a balance sheet screen's state from these options, reporting date, and journal.
|
-- | Update a balance sheet screen's state from these options, reporting date, and journal.
|
||||||
bsUpdate :: UIOpts -> Day -> Journal -> AccountsScreenState -> AccountsScreenState
|
bsUpdate :: UIOpts -> Day -> Journal -> AccountsScreenState -> AccountsScreenState
|
||||||
bsUpdate uopts d = dlogUiTrace "bsUpdate" .
|
bsUpdate uopts d = dbgui "bsUpdate" .
|
||||||
asUpdateHelper rspec d copts roptsmod extraquery
|
asUpdateHelper rspec d copts roptsmod extraquery
|
||||||
where
|
where
|
||||||
UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec}} = uopts
|
UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec}} = uopts
|
||||||
@ -186,11 +186,11 @@ bsUpdate uopts d = dlogUiTrace "bsUpdate" .
|
|||||||
-- with the appropriate one selected.
|
-- with the appropriate one selected.
|
||||||
-- Screen-specific arguments: the account to select if any.
|
-- Screen-specific arguments: the account to select if any.
|
||||||
isNew :: UIOpts -> Day -> Journal -> Maybe AccountName -> Screen
|
isNew :: UIOpts -> Day -> Journal -> Maybe AccountName -> Screen
|
||||||
isNew uopts d j macct = dlogUiTrace "isNew" $ IS $ isUpdate uopts d j $ nullass macct
|
isNew uopts d j macct = dbgui "isNew" $ IS $ isUpdate uopts d j $ nullass macct
|
||||||
|
|
||||||
-- | Update an income statement screen's state from these options, reporting date, and journal.
|
-- | Update an income statement screen's state from these options, reporting date, and journal.
|
||||||
isUpdate :: UIOpts -> Day -> Journal -> AccountsScreenState -> AccountsScreenState
|
isUpdate :: UIOpts -> Day -> Journal -> AccountsScreenState -> AccountsScreenState
|
||||||
isUpdate uopts d = dlogUiTrace "isUpdate" .
|
isUpdate uopts d = dbgui "isUpdate" .
|
||||||
asUpdateHelper rspec d copts roptsmod extraquery
|
asUpdateHelper rspec d copts roptsmod extraquery
|
||||||
where
|
where
|
||||||
UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec}} = uopts
|
UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec}} = uopts
|
||||||
@ -203,7 +203,7 @@ isUpdate uopts d = dlogUiTrace "isUpdate" .
|
|||||||
-- whether to force inclusive balances.
|
-- whether to force inclusive balances.
|
||||||
rsNew :: UIOpts -> Day -> Journal -> AccountName -> Bool -> Screen
|
rsNew :: UIOpts -> Day -> Journal -> AccountName -> Bool -> Screen
|
||||||
rsNew uopts d j acct forceinclusive = -- XXX forcedefaultselection - whether to force selecting the last transaction.
|
rsNew uopts d j acct forceinclusive = -- XXX forcedefaultselection - whether to force selecting the last transaction.
|
||||||
dlogUiTrace "rsNew" $
|
dbgui "rsNew" $
|
||||||
RS $
|
RS $
|
||||||
rsUpdate uopts d j $
|
rsUpdate uopts d j $
|
||||||
RSS {
|
RSS {
|
||||||
@ -215,7 +215,7 @@ rsNew uopts d j acct forceinclusive = -- XXX forcedefaultselection - whether to
|
|||||||
-- | Update a register screen from these options, reporting date, and journal.
|
-- | Update a register screen from these options, reporting date, and journal.
|
||||||
rsUpdate :: UIOpts -> Day -> Journal -> RegisterScreenState -> RegisterScreenState
|
rsUpdate :: UIOpts -> Day -> Journal -> RegisterScreenState -> RegisterScreenState
|
||||||
rsUpdate uopts d j rss@RSS{_rssAccount, _rssForceInclusive, _rssList=oldlist} =
|
rsUpdate uopts d j rss@RSS{_rssAccount, _rssForceInclusive, _rssList=oldlist} =
|
||||||
dlogUiTrace "rsUpdate"
|
dbgui "rsUpdate"
|
||||||
rss{_rssList=l'}
|
rss{_rssList=l'}
|
||||||
where
|
where
|
||||||
UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}} = uopts
|
UIOpts{uoCliOpts=copts@CliOpts{reportspec_=rspec@ReportSpec{_rsReportOpts=ropts}}} = uopts
|
||||||
@ -320,7 +320,7 @@ rsUpdate uopts d j rss@RSS{_rssAccount, _rssForceInclusive, _rssList=oldlist} =
|
|||||||
-- the list of showable transactions, the currently shown transaction.
|
-- the list of showable transactions, the currently shown transaction.
|
||||||
tsNew :: AccountName -> [NumberedTransaction] -> NumberedTransaction -> Screen
|
tsNew :: AccountName -> [NumberedTransaction] -> NumberedTransaction -> Screen
|
||||||
tsNew acct nts nt =
|
tsNew acct nts nt =
|
||||||
dlogUiTrace "tsNew" $
|
dbgui "tsNew" $
|
||||||
TS TSS{
|
TS TSS{
|
||||||
_tssAccount = acct
|
_tssAccount = acct
|
||||||
,_tssTransactions = nts
|
,_tssTransactions = nts
|
||||||
@ -330,5 +330,5 @@ tsNew acct nts nt =
|
|||||||
-- | Update a transaction screen. Currently a no-op since transaction screen
|
-- | Update a transaction screen. Currently a no-op since transaction screen
|
||||||
-- depends only on its screen-specific state.
|
-- depends only on its screen-specific state.
|
||||||
tsUpdate :: TransactionScreenState -> TransactionScreenState
|
tsUpdate :: TransactionScreenState -> TransactionScreenState
|
||||||
tsUpdate = dlogUiTrace "tsUpdate"
|
tsUpdate = dbgui "tsUpdate"
|
||||||
|
|
||||||
|
|||||||
@ -32,14 +32,13 @@ module Hledger.UI.UIUtils (
|
|||||||
,reportSpecAddQuery
|
,reportSpecAddQuery
|
||||||
,reportSpecSetFutureAndForecast
|
,reportSpecSetFutureAndForecast
|
||||||
,listScrollPushingSelection
|
,listScrollPushingSelection
|
||||||
,dlogUiTrace
|
,dbgui
|
||||||
,dlogUiTraceIO
|
,dbguiIO
|
||||||
,dlogUiTraceM
|
,dbguiEv
|
||||||
,dlogUiScreenStack
|
,dbguiScreensEv
|
||||||
,screenRegisterDescriptions
|
,screenRegisterDescriptions
|
||||||
,screenId
|
,screenId
|
||||||
,mapScreens
|
,mapScreens
|
||||||
,uiDebugLevel
|
|
||||||
,uiNumBlankItems
|
,uiNumBlankItems
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
@ -87,32 +86,32 @@ suspendSignal = raiseSignal sigSTOP
|
|||||||
|
|
||||||
get' = do
|
get' = do
|
||||||
x <- get
|
x <- get
|
||||||
dlogUiTraceM $ "getting state: " ++ (head $ lines $ pshow $ aScreen x)
|
dbguiEv $ "getting state: " ++ (head $ lines $ pshow $ aScreen x)
|
||||||
-- ++ " " ++ (show $ map tdescription $ jtxns $ ajournal x)
|
-- ++ " " ++ (show $ map tdescription $ jtxns $ ajournal x)
|
||||||
-- dlogUiTraceM $ ("query: "++) $ pshow' $ x & aopts & uoCliOpts & reportspec_ & _rsQuery
|
-- dbguiEv $ ("query: "++) $ pshow' $ x & aopts & uoCliOpts & reportspec_ & _rsQuery
|
||||||
-- dlogUiScreenStack "getting" screenId x
|
-- dbguiScreensEv "getting" screenId x
|
||||||
-- dlogUiScreenStack "getting, with register descriptions" screenRegisterDescriptions x
|
-- dbguiScreensEv "getting, with register descriptions" screenRegisterDescriptions x
|
||||||
return x
|
return x
|
||||||
|
|
||||||
put' x = do
|
put' x = do
|
||||||
dlogUiTraceM $ "putting state: " ++ (head $ lines $ pshow $ aScreen x)
|
dbguiEv $ "putting state: " ++ (head $ lines $ pshow $ aScreen x)
|
||||||
-- ++ " " ++ (show $ map tdescription $ jtxns $ ajournal x)
|
-- ++ " " ++ (show $ map tdescription $ jtxns $ ajournal x)
|
||||||
-- dlogUiTraceM $ ("query: "++) $ pshow' $ x & aopts & uoCliOpts & reportspec_ & _rsQuery
|
-- dbguiEv $ ("query: "++) $ pshow' $ x & aopts & uoCliOpts & reportspec_ & _rsQuery
|
||||||
-- dlogUiScreenStack "putting" screenId x
|
-- dbguiScreensEv "putting" screenId x
|
||||||
-- dlogUiScreenStack "putting, with register descriptions" screenRegisterDescriptions x
|
-- dbguiScreensEv "putting, with register descriptions" screenRegisterDescriptions x
|
||||||
put x
|
put x
|
||||||
|
|
||||||
modify' f = do
|
modify' f = do
|
||||||
x <- get
|
x <- get
|
||||||
let x' = f x
|
let x' = f x
|
||||||
dlogUiTraceM $ "modifying state: " ++ (head $ lines $ pshow $ aScreen x')
|
dbguiEv $ "modifying state: " ++ (head $ lines $ pshow $ aScreen x')
|
||||||
-- ++ " " ++ (show $ map tdescription $ jtxns $ ajournal x')
|
-- ++ " " ++ (show $ map tdescription $ jtxns $ ajournal x')
|
||||||
-- dlogUiTraceM $ ("from: "++) $ pshow' $ x & aopts & uoCliOpts & reportspec_ & _rsQuery
|
-- dbguiEv $ ("from: "++) $ pshow' $ x & aopts & uoCliOpts & reportspec_ & _rsQuery
|
||||||
-- dlogUiTraceM $ ("to: "++) $ pshow' $ x' & aopts & uoCliOpts & reportspec_ & _rsQuery
|
-- dbguiEv $ ("to: "++) $ pshow' $ x' & aopts & uoCliOpts & reportspec_ & _rsQuery
|
||||||
-- dlogUiScreenStack "getting" screenId x
|
-- dbguiScreensEv "getting" screenId x
|
||||||
-- dlogUiScreenStack "putting" screenId x'
|
-- dbguiScreensEv "putting" screenId x'
|
||||||
-- dlogUiScreenStack "getting, with register descriptions" screenRegisterDescriptions x
|
-- dbguiScreensEv "getting, with register descriptions" screenRegisterDescriptions x
|
||||||
-- dlogUiScreenStack "putting, with register descriptions" screenRegisterDescriptions x'
|
-- dbguiScreensEv "putting, with register descriptions" screenRegisterDescriptions x'
|
||||||
modify f
|
modify f
|
||||||
|
|
||||||
-- | On posix platforms, suspend the program using the STOP signal,
|
-- | On posix platforms, suspend the program using the STOP signal,
|
||||||
@ -439,29 +438,33 @@ listScrollPushingSelection name listheight scrollamt = do
|
|||||||
_ -> return list
|
_ -> return list
|
||||||
_ -> return list
|
_ -> return list
|
||||||
|
|
||||||
-- | Log a string to ./debug.log before returning the second argument,
|
-- Log hledger-ui events at this debug level and above.
|
||||||
-- if the global debug level is at or above a standard hledger-ui debug level.
|
uiDebugLevel :: Int
|
||||||
-- Uses unsafePerformIO.
|
uiDebugLevel = 1
|
||||||
dlogUiTrace :: String -> a -> a
|
|
||||||
dlogUiTrace = traceLogAt uiDebugLevel
|
|
||||||
|
|
||||||
-- | Like dlogUiTrace, but convenient in IO.
|
-- | A debug logging helper to use in hledger-ui code:
|
||||||
dlogUiTraceIO :: String -> IO ()
|
-- at any debug level >= 1, logs the string to ./debug.log before returning the second argument.
|
||||||
dlogUiTraceIO s = dlogUiTrace s $ return ()
|
-- Like traceLogAt 1. Uses unsafePerformIO.
|
||||||
|
dbgui :: String -> a -> a
|
||||||
|
dbgui = traceLogAt uiDebugLevel
|
||||||
|
|
||||||
-- | Like dlogUiTrace, but convenient in event handlers.
|
-- | Like dbgui, but convenient in IO.
|
||||||
dlogUiTraceM :: String -> EventM Name UIState ()
|
dbguiIO :: String -> IO ()
|
||||||
dlogUiTraceM s = dlogUiTrace s $ return ()
|
dbguiIO s = dbgui s $ return ()
|
||||||
|
|
||||||
-- | Like dlogUiTraceM, but log a compact view of the current screen stack,
|
-- | Like dbgui, but convenient in hledger EventM handlers.
|
||||||
|
dbguiEv :: String -> EventM Name s ()
|
||||||
|
dbguiEv s = dbgui s $ return ()
|
||||||
|
|
||||||
|
-- | Like dbguiEv, but log a compact view of the current screen stack,
|
||||||
-- from topmost screen to currently-viewed screen,
|
-- from topmost screen to currently-viewed screen,
|
||||||
-- with each screen rendered by the given rendering function
|
-- with each screen rendered by the given rendering function
|
||||||
-- (and with the given extra label if any).
|
-- (and with the given extra label if any).
|
||||||
-- Useful for inspecting states across the whole screen stack.
|
-- Useful for inspecting states across the whole screen stack.
|
||||||
-- To just show the stack: @dlogUiScreenStack "" screenId ui@
|
-- To just show the stack: @dbguiScreensEv "" screenId ui@
|
||||||
dlogUiScreenStack :: String -> (Screen -> String) -> UIState -> EventM Name UIState ()
|
dbguiScreensEv :: String -> (Screen -> String) -> UIState -> EventM Name UIState ()
|
||||||
dlogUiScreenStack postfix showscr ui =
|
dbguiScreensEv postfix showscr ui =
|
||||||
dlogUiTraceM $ concat [
|
dbguiEv $ concat [
|
||||||
"screen stack"
|
"screen stack"
|
||||||
,if null postfix then "" else " (" ++ postfix ++ ")"
|
,if null postfix then "" else " (" ++ postfix ++ ")"
|
||||||
,": "
|
,": "
|
||||||
@ -492,10 +495,6 @@ screenId = \case
|
|||||||
TS _ -> "T" -- transaction
|
TS _ -> "T" -- transaction
|
||||||
ES _ -> "E" -- error
|
ES _ -> "E" -- error
|
||||||
|
|
||||||
-- | Log hledger-ui events at this debug level.
|
|
||||||
uiDebugLevel :: Int
|
|
||||||
uiDebugLevel = 2
|
|
||||||
|
|
||||||
-- | How many blank items to add to lists to fill the full window height.
|
-- | How many blank items to add to lists to fill the full window height.
|
||||||
uiNumBlankItems :: Int
|
uiNumBlankItems :: Int
|
||||||
uiNumBlankItems
|
uiNumBlankItems
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user