ui: make flat the default, toggle with T, add --tree/-T/-F flags

This commit is contained in:
Simon Michael 2018-10-15 13:41:41 -07:00
parent 15c666702b
commit 89712fe81d
6 changed files with 40 additions and 39 deletions

View File

@ -80,7 +80,7 @@ asInit d reset ui@UIState{
as = map asItemAccountName displayitems as = map asItemAccountName displayitems
uopts' = uopts{cliopts_=copts{reportopts_=ropts'}} uopts' = uopts{cliopts_=copts{reportopts_=ropts'}}
ropts' = ropts{accountlistmode_=if flat_ ropts then ALFlat else ALTree} ropts' = ropts{accountlistmode_=if tree_ ropts then ALTree else ALFlat}
q = queryFromOpts d ropts q = queryFromOpts d ropts
@ -97,7 +97,7 @@ asInit d reset ui@UIState{
displayitem (fullacct, shortacct, indent, bal) = displayitem (fullacct, shortacct, indent, bal) =
AccountsScreenItem{asItemIndentLevel = indent AccountsScreenItem{asItemIndentLevel = indent
,asItemAccountName = fullacct ,asItemAccountName = fullacct
,asItemDisplayAccountName = replaceHiddenAccountsNameWith "All" $ if flat_ ropts' then fullacct else shortacct ,asItemDisplayAccountName = replaceHiddenAccountsNameWith "All" $ if tree_ ropts' then shortacct else fullacct
,asItemRenderedAmounts = map showAmountWithoutPrice amts -- like showMixedAmountOneLineWithoutPrice ,asItemRenderedAmounts = map showAmountWithoutPrice amts -- like showMixedAmountOneLineWithoutPrice
} }
where where
@ -219,10 +219,10 @@ asDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
,if ishistorical ,if ishistorical
then selectedstr "historical" <+> str "/period" then selectedstr "historical" <+> str "/period"
else str "historical/" <+> selectedstr "period") else str "historical/" <+> selectedstr "period")
,("F" ,("T"
,if flat_ ropts ,if tree_ ropts
then str "tree/" <+> selectedstr "flat" then str "flat/" <+> selectedstr "tree"
else selectedstr "tree" <+> str "/flat") else selectedstr "flat" <+> str "/tree")
,("-+", str "depth") ,("-+", str "depth")
--,("/", "filter") --,("/", "filter")
--,("DEL", "unfilter") --,("DEL", "unfilter")
@ -332,7 +332,7 @@ asHandle ui0@UIState{
-- display mode/query toggles -- display mode/query toggles
VtyEvent (EvKey (KChar 'H') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleHistorical ui VtyEvent (EvKey (KChar 'H') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleHistorical ui
VtyEvent (EvKey (KChar 'F') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleFlat ui VtyEvent (EvKey (KChar 'T') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleTree ui
VtyEvent (EvKey (KChar 'Z') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleEmpty ui VtyEvent (EvKey (KChar 'Z') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleEmpty ui
VtyEvent (EvKey (KChar 'R') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleReal ui VtyEvent (EvKey (KChar 'R') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleReal ui
VtyEvent (EvKey (KChar 'U') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleUnmarked ui VtyEvent (EvKey (KChar 'U') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleUnmarked ui

View File

@ -64,7 +64,7 @@ rsInit d reset ui@UIState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}, ajo
where where
-- gather arguments and queries -- gather arguments and queries
-- XXX temp -- XXX temp
inclusive = not (flat_ ropts) || rsForceInclusive inclusive = tree_ ropts || rsForceInclusive
thisacctq = Acct $ (if inclusive then accountNameToAccountRegex else accountNameToAccountOnlyRegex) rsAccount thisacctq = Acct $ (if inclusive then accountNameToAccountRegex else accountNameToAccountOnlyRegex) rsAccount
ropts' = ropts{ ropts' = ropts{
depth_=Nothing depth_=Nothing
@ -186,7 +186,7 @@ rsDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
where where
ishistorical = balancetype_ ropts == HistoricalBalance ishistorical = balancetype_ ropts == HistoricalBalance
inclusive = not (flat_ ropts) || rsForceInclusive inclusive = tree_ ropts || rsForceInclusive
toplabel = toplabel =
withAttr ("border" <> "bold") (str $ T.unpack $ replaceHiddenAccountsNameWith "All" rsAccount) withAttr ("border" <> "bold") (str $ T.unpack $ replaceHiddenAccountsNameWith "All" rsAccount)
@ -233,10 +233,10 @@ rsDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
,if ishistorical ,if ishistorical
then selectedstr "historical" <+> str "/period" then selectedstr "historical" <+> str "/period"
else str "historical/" <+> selectedstr "period") else str "historical/" <+> selectedstr "period")
,("F" ,("T"
,if inclusive ,if inclusive
then selectedstr "inclusive" <+> str "/exclusive" then str "this/" <+> selectedstr "+subs"
else str "inclusive/" <+> selectedstr "exclusive") else selectedstr "this" <+> str "/+subs")
-- ,("a", "add") -- ,("a", "add")
-- ,("g", "reload") -- ,("g", "reload")
-- ,("q", "quit") -- ,("q", "quit")
@ -323,7 +323,7 @@ rsHandle ui@UIState{
-- display mode/query toggles -- display mode/query toggles
VtyEvent (EvKey (KChar 'H') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleHistorical ui VtyEvent (EvKey (KChar 'H') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleHistorical ui
VtyEvent (EvKey (KChar 'F') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleFlat ui VtyEvent (EvKey (KChar 'T') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleTree ui
VtyEvent (EvKey (KChar 'Z') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleEmpty ui VtyEvent (EvKey (KChar 'Z') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleEmpty ui
VtyEvent (EvKey (KChar 'R') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleReal ui VtyEvent (EvKey (KChar 'R') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleReal ui
VtyEvent (EvKey (KChar 'U') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleUnmarked ui VtyEvent (EvKey (KChar 'U') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleUnmarked ui

View File

@ -33,7 +33,8 @@ uiflags = [
-- "show balance change accumulated across periods (in multicolumn reports)" -- "show balance change accumulated across periods (in multicolumn reports)"
-- ,flagNone ["historical","H"] (\opts -> setboolopt "historical" opts) -- ,flagNone ["historical","H"] (\opts -> setboolopt "historical" opts)
-- "show historical ending balance in each period (includes postings before report start date)\n " -- "show historical ending balance in each period (includes postings before report start date)\n "
,flagNone ["flat"] (\opts -> setboolopt "flat" opts) "show full account names, unindented" ,flagNone ["flat","F"] (\opts -> setboolopt "flat" opts) "show full account names, unindented (default)"
,flagNone ["tree","T"] (\opts -> setboolopt "tree" opts) "show accounts as a tree"
-- ,flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "with --flat, omit this many leading account name components" -- ,flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "with --flat, omit this many leading account name components"
-- ,flagReq ["format"] (\s opts -> Right $ setopt "format" s opts) "FORMATSTR" "use this custom line format" -- ,flagReq ["format"] (\s opts -> Right $ setopt "format" s opts) "FORMATSTR" "use this custom line format"
-- ,flagNone ["no-elide"] (\opts -> setboolopt "no-elide" opts) "don't compress empty parent accounts on one line" -- ,flagNone ["no-elide"] (\opts -> setboolopt "no-elide" opts) "don't compress empty parent accounts on one line"

View File

@ -108,13 +108,13 @@ toggleEmpty ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=rop
where where
toggleEmpty ropts = ropts{empty_=not $ empty_ ropts} toggleEmpty ropts = ropts{empty_=not $ empty_ ropts}
-- | Toggle between flat and tree mode. If in the third "default" mode, go to flat mode. -- | Toggle between flat and tree mode. If current mode is unspecified/default, assume it's flat.
toggleFlat :: UIState -> UIState toggleTree :: UIState -> UIState
toggleFlat ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} = toggleTree ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =
ui{aopts=uopts{cliopts_=copts{reportopts_=toggleFlatMode ropts}}} ui{aopts=uopts{cliopts_=copts{reportopts_=toggleTreeMode ropts}}}
where where
toggleFlatMode ropts@ReportOpts{accountlistmode_=ALFlat} = ropts{accountlistmode_=ALTree} toggleTreeMode ropts@ReportOpts{accountlistmode_=ALTree} = ropts{accountlistmode_=ALFlat}
toggleFlatMode ropts = ropts{accountlistmode_=ALFlat} toggleTreeMode ropts = ropts{accountlistmode_=ALTree}
-- | Toggle between historical balances and period balances. -- | Toggle between historical balances and period balances.
toggleHistorical :: UIState -> UIState toggleHistorical :: UIState -> UIState

View File

@ -99,11 +99,11 @@ helpDialog copts =
,str "accounts screen:" ,str "accounts screen:"
,renderKey ("-+0123456789", "set depth limit") ,renderKey ("-+0123456789", "set depth limit")
,renderKey ("H", "toggle period balance (shows change) or\nhistorical balance (includes older postings)") ,renderKey ("H", "toggle period balance (shows change) or\nhistorical balance (includes older postings)")
,renderKey ("F", "toggle tree (amounts include subaccounts) or\nflat mode (amounts exclude subaccounts\nexcept when account is depth-clipped)") ,renderKey ("T", "toggle tree (amounts include subaccounts) or\nflat mode (amounts exclude subaccounts\nexcept at depth limit)")
,str " " ,str " "
,str "register screen:" ,str "register screen:"
,renderKey ("H", "toggle period or historical total") ,renderKey ("H", "toggle period or historical total")
,renderKey ("F", "toggle subaccount transaction inclusion\n(and tree/flat mode)") ,renderKey ("T", "toggle inclusion of subaccount transactions\n(and tree/flat mode on accounts screen)")
] ]
] ]
-- ,vBox [ -- ,vBox [

View File

@ -66,8 +66,11 @@ Any QUERYARGS are interpreted as a hledger search query which filters the data.
`--change` `--change`
: show period balances (changes) at startup instead of historical balances : show period balances (changes) at startup instead of historical balances
`--flat` `-F --flat`
: show full account names, unindented : show full account names, unindented (default)
`-T --tree`
: show accounts as a tree
hledger input options: hledger input options:
@ -156,15 +159,14 @@ It lists accounts and their balances, like hledger's balance command.
By default, it shows all accounts and their latest ending balances (including the balances of subaccounts). By default, it shows all accounts and their latest ending balances (including the balances of subaccounts).
if you specify a query on the command line, it shows just the matched accounts and the balances from matched transactions. if you specify a query on the command line, it shows just the matched accounts and the balances from matched transactions.
Account names are normally indented to show the hierarchy (tree mode). Account names are shown as a flat list by default. Press `T` to toggle tree mode.
To see less detail, set a depth limit by pressing a number key, `1` to `9`. In flat mode, account balances are exclusive of subaccounts, except where subaccounts are hidden by a depth limit (see below).
`0` shows even less detail, collapsing all accounts to a single total. In tree mode, all account balances are inclusive of subaccounts.
`-` and `+` (or `=`) decrease and increase the depth limit.
To remove the depth limit, set it higher than the maximum account depth, or press `ESCAPE`.
`F` toggles flat mode, in which accounts are shown as a flat list, with their full names. To see less detail, press a number key, `1` to `9`, to set a depth limit.
In this mode, account balances exclude subaccounts, except for accounts at the depth limit Or use `-` to decrease and `+`/`=` to increase the depth limit.
(as with hledger's balance command). `0` shows even less detail, collapsing all accounts to a single total.
To remove the depth limit, set it higher than the maximum account depth, or press `ESCAPE`.
`H` toggles between showing historical balances or period balances. `H` toggles between showing historical balances or period balances.
Historical balances (the default) are ending balances at the end of the report period, Historical balances (the default) are ending balances at the end of the report period,
@ -209,13 +211,11 @@ Similar to the accounts screen, the historical total is affected by transactions
If the historical total is not disturbed by a filter query, it will be the If the historical total is not disturbed by a filter query, it will be the
running historical balance you would see on a bank register for the current account. running historical balance you would see on a bank register for the current account.
If the accounts screen was in tree mode, Transactions affecting this account's subaccounts will be shown if
the register screen will include transactions from both the current account and its subaccounts. the accounts screen was in tree mode,
If the accounts screen was in flat mode, and a non-depth-clipped account was selected, or if it was in flat mode but the selected account had depth-clipped subaccounts.
the register screen will exclude transactions from subaccounts. In other words, the register always shows just the transactions contributing to the balance on the accounts screen.
In other words, the register always shows the transactions responsible for the period balance Tree mode/flat mode can be toggled with `T` here also.
shown on the accounts screen.
As on the accounts screen, this can be toggled with `F`.
`U` toggles filtering by [unmarked status](/journal.html#status), showing or hiding unmarked transactions. `U` toggles filtering by [unmarked status](/journal.html#status), showing or hiding unmarked transactions.
Similarly, `P` toggles pending transactions, and `C` toggles cleared transactions. Similarly, `P` toggles pending transactions, and `C` toggles cleared transactions.