ui: make flat the default, toggle with T, add --tree/-T/-F flags
This commit is contained in:
parent
15c666702b
commit
89712fe81d
@ -80,7 +80,7 @@ asInit d reset ui@UIState{
|
||||
as = map asItemAccountName displayitems
|
||||
|
||||
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
|
||||
|
||||
@ -97,7 +97,7 @@ asInit d reset ui@UIState{
|
||||
displayitem (fullacct, shortacct, indent, bal) =
|
||||
AccountsScreenItem{asItemIndentLevel = indent
|
||||
,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
|
||||
}
|
||||
where
|
||||
@ -219,10 +219,10 @@ asDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
|
||||
,if ishistorical
|
||||
then selectedstr "historical" <+> str "/period"
|
||||
else str "historical/" <+> selectedstr "period")
|
||||
,("F"
|
||||
,if flat_ ropts
|
||||
then str "tree/" <+> selectedstr "flat"
|
||||
else selectedstr "tree" <+> str "/flat")
|
||||
,("T"
|
||||
,if tree_ ropts
|
||||
then str "flat/" <+> selectedstr "tree"
|
||||
else selectedstr "flat" <+> str "/tree")
|
||||
,("-+", str "depth")
|
||||
--,("/", "filter")
|
||||
--,("DEL", "unfilter")
|
||||
@ -332,7 +332,7 @@ asHandle ui0@UIState{
|
||||
|
||||
-- display mode/query toggles
|
||||
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 'R') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleReal ui
|
||||
VtyEvent (EvKey (KChar 'U') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleUnmarked ui
|
||||
|
||||
@ -64,7 +64,7 @@ rsInit d reset ui@UIState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}, ajo
|
||||
where
|
||||
-- gather arguments and queries
|
||||
-- XXX temp
|
||||
inclusive = not (flat_ ropts) || rsForceInclusive
|
||||
inclusive = tree_ ropts || rsForceInclusive
|
||||
thisacctq = Acct $ (if inclusive then accountNameToAccountRegex else accountNameToAccountOnlyRegex) rsAccount
|
||||
ropts' = ropts{
|
||||
depth_=Nothing
|
||||
@ -186,7 +186,7 @@ rsDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
|
||||
|
||||
where
|
||||
ishistorical = balancetype_ ropts == HistoricalBalance
|
||||
inclusive = not (flat_ ropts) || rsForceInclusive
|
||||
inclusive = tree_ ropts || rsForceInclusive
|
||||
|
||||
toplabel =
|
||||
withAttr ("border" <> "bold") (str $ T.unpack $ replaceHiddenAccountsNameWith "All" rsAccount)
|
||||
@ -233,10 +233,10 @@ rsDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
|
||||
,if ishistorical
|
||||
then selectedstr "historical" <+> str "/period"
|
||||
else str "historical/" <+> selectedstr "period")
|
||||
,("F"
|
||||
,("T"
|
||||
,if inclusive
|
||||
then selectedstr "inclusive" <+> str "/exclusive"
|
||||
else str "inclusive/" <+> selectedstr "exclusive")
|
||||
then str "this/" <+> selectedstr "+subs"
|
||||
else selectedstr "this" <+> str "/+subs")
|
||||
-- ,("a", "add")
|
||||
-- ,("g", "reload")
|
||||
-- ,("q", "quit")
|
||||
@ -323,7 +323,7 @@ rsHandle ui@UIState{
|
||||
|
||||
-- display mode/query toggles
|
||||
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 'R') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleReal ui
|
||||
VtyEvent (EvKey (KChar 'U') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleUnmarked ui
|
||||
|
||||
@ -33,7 +33,8 @@ uiflags = [
|
||||
-- "show balance change accumulated across periods (in multicolumn reports)"
|
||||
-- ,flagNone ["historical","H"] (\opts -> setboolopt "historical" opts)
|
||||
-- "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 ["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"
|
||||
|
||||
@ -108,13 +108,13 @@ toggleEmpty ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=rop
|
||||
where
|
||||
toggleEmpty ropts = ropts{empty_=not $ empty_ ropts}
|
||||
|
||||
-- | Toggle between flat and tree mode. If in the third "default" mode, go to flat mode.
|
||||
toggleFlat :: UIState -> UIState
|
||||
toggleFlat ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =
|
||||
ui{aopts=uopts{cliopts_=copts{reportopts_=toggleFlatMode ropts}}}
|
||||
-- | Toggle between flat and tree mode. If current mode is unspecified/default, assume it's flat.
|
||||
toggleTree :: UIState -> UIState
|
||||
toggleTree ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =
|
||||
ui{aopts=uopts{cliopts_=copts{reportopts_=toggleTreeMode ropts}}}
|
||||
where
|
||||
toggleFlatMode ropts@ReportOpts{accountlistmode_=ALFlat} = ropts{accountlistmode_=ALTree}
|
||||
toggleFlatMode ropts = ropts{accountlistmode_=ALFlat}
|
||||
toggleTreeMode ropts@ReportOpts{accountlistmode_=ALTree} = ropts{accountlistmode_=ALFlat}
|
||||
toggleTreeMode ropts = ropts{accountlistmode_=ALTree}
|
||||
|
||||
-- | Toggle between historical balances and period balances.
|
||||
toggleHistorical :: UIState -> UIState
|
||||
|
||||
@ -99,11 +99,11 @@ helpDialog copts =
|
||||
,str "accounts screen:"
|
||||
,renderKey ("-+0123456789", "set depth limit")
|
||||
,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 "register screen:"
|
||||
,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 [
|
||||
|
||||
@ -66,8 +66,11 @@ Any QUERYARGS are interpreted as a hledger search query which filters the data.
|
||||
`--change`
|
||||
: show period balances (changes) at startup instead of historical balances
|
||||
|
||||
`--flat`
|
||||
: show full account names, unindented
|
||||
`-F --flat`
|
||||
: show full account names, unindented (default)
|
||||
|
||||
`-T --tree`
|
||||
: show accounts as a tree
|
||||
|
||||
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).
|
||||
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).
|
||||
To see less detail, set a depth limit by pressing a number key, `1` to `9`.
|
||||
`0` shows even less detail, collapsing all accounts to a single total.
|
||||
`-` and `+` (or `=`) decrease and increase the depth limit.
|
||||
To remove the depth limit, set it higher than the maximum account depth, or press `ESCAPE`.
|
||||
Account names are shown as a flat list by default. Press `T` to toggle tree mode.
|
||||
In flat mode, account balances are exclusive of subaccounts, except where subaccounts are hidden by a depth limit (see below).
|
||||
In tree mode, all account balances are inclusive of subaccounts.
|
||||
|
||||
`F` toggles flat mode, in which accounts are shown as a flat list, with their full names.
|
||||
In this mode, account balances exclude subaccounts, except for accounts at the depth limit
|
||||
(as with hledger's balance command).
|
||||
To see less detail, press a number key, `1` to `9`, to set a depth limit.
|
||||
Or use `-` to decrease and `+`/`=` to increase the depth limit.
|
||||
`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.
|
||||
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
|
||||
running historical balance you would see on a bank register for the current account.
|
||||
|
||||
If the accounts screen was in tree mode,
|
||||
the register screen will include transactions from both the current account and its subaccounts.
|
||||
If the accounts screen was in flat mode, and a non-depth-clipped account was selected,
|
||||
the register screen will exclude transactions from subaccounts.
|
||||
In other words, the register always shows the transactions responsible for the period balance
|
||||
shown on the accounts screen.
|
||||
As on the accounts screen, this can be toggled with `F`.
|
||||
Transactions affecting this account's subaccounts will be shown if
|
||||
the accounts screen was in tree mode,
|
||||
or if it was in flat mode but the selected account had depth-clipped subaccounts.
|
||||
In other words, the register always shows just the transactions contributing to the balance on the accounts screen.
|
||||
Tree mode/flat mode can be toggled with `T` here also.
|
||||
|
||||
`U` toggles filtering by [unmarked status](/journal.html#status), showing or hiding unmarked transactions.
|
||||
Similarly, `P` toggles pending transactions, and `C` toggles cleared transactions.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user