diff --git a/hledger-lib/Hledger/Reports/ReportOptions.hs b/hledger-lib/Hledger/Reports/ReportOptions.hs index d63e46c59..27d741f8a 100644 --- a/hledger-lib/Hledger/Reports/ReportOptions.hs +++ b/hledger-lib/Hledger/Reports/ReportOptions.hs @@ -15,6 +15,7 @@ module Hledger.Reports.ReportOptions ( checkReportOpts, flat_, tree_, + reportOptsToggleStatus, whichDateFromOpts, journalSelectingAmountFromOpts, queryFromOpts, @@ -284,6 +285,11 @@ simplifyStatuses l l' = nub $ sort l numstatuses = length [minBound .. maxBound :: Status] +-- | Add/remove this status from the status list. Used by hledger-ui. +reportOptsToggleStatus s ropts@ReportOpts{statuses_=ss} + | s `elem` ss = ropts{statuses_=filter (/= s) ss} + | otherwise = ropts{statuses_=simplifyStatuses (s:ss)} + type DisplayExp = String maybedisplayopt :: Day -> RawOpts -> Maybe DisplayExp diff --git a/hledger-ui/Hledger/UI/UIState.hs b/hledger-ui/Hledger/UI/UIState.hs index 8327010ce..597d3ae4a 100644 --- a/hledger-ui/Hledger/UI/UIState.hs +++ b/hledger-ui/Hledger/UI/UIState.hs @@ -32,10 +32,6 @@ toggleCleared :: UIState -> UIState toggleCleared ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} = ui{aopts=uopts{cliopts_=copts{reportopts_=reportOptsToggleStatus Cleared ropts}}} -reportOptsToggleStatus s ropts - | clearedstatus_ ropts == [s] = ropts{clearedstatus_=[]} - | otherwise = ropts{clearedstatus_=[s]} - -- | Toggle between showing all and showing only nonempty (more precisely, nonzero) items. toggleEmpty :: UIState -> UIState toggleEmpty ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} = diff --git a/hledger-ui/Hledger/UI/UIUtils.hs b/hledger-ui/Hledger/UI/UIUtils.hs index b1323165f..cbd7d075f 100644 --- a/hledger-ui/Hledger/UI/UIUtils.hs +++ b/hledger-ui/Hledger/UI/UIUtils.hs @@ -76,9 +76,9 @@ helpDialog = ,renderKey ("t", "set report period to today") ,str " " ,renderKey ("/", "set a filter query") - ,renderKey ("U", "toggle unmarked/all") - ,renderKey ("P", "toggle pending/all") - ,renderKey ("C", "toggle cleared/all") + ,renderKey ("U", "toggle unmarked filter") + ,renderKey ("P", "toggle pending filter") + ,renderKey ("C", "toggle cleared filter") ,renderKey ("R", "toggle real/all") ,renderKey ("Z", "toggle nonzero/all") ,renderKey ("DEL/BS", "remove filters") diff --git a/hledger-ui/doc/hledger-ui.1.m4.md b/hledger-ui/doc/hledger-ui.1.m4.md index 8008fe2c4..3930b7c08 100644 --- a/hledger-ui/doc/hledger-ui.1.m4.md +++ b/hledger-ui/doc/hledger-ui.1.m4.md @@ -163,9 +163,13 @@ balances are what you would see on a bank statement for that account (unless dis a filter query). Period balances ignore transactions before the report start date, so they show the change in balance during the report period. They are more useful eg when viewing a time log. -`C` toggles cleared mode, which shows balances for postings with [cleared status](/journal.html#status) only. -Similarly, `P` toggles pending mode, which shows balances for pending postings only, -and `U` toggles uncleared mode, which shows balances for unmarked postings only. +`U` toggles filtering by [unmarked status](/journal.html#status), +including or excluding unmarked postings in the balances. +Similarly, `P` toggles pending postings, +and `C` toggles cleared postings. +(By default, balances include all postings; +if you activate one or two status filters, only those postings are included; +and if you activate all three, the filter is removed.) `R` toggles real mode, in which [virtual postings](/journal.html#virtual-postings) are ignored. @@ -202,9 +206,11 @@ In other words, the register always shows the transactions responsible for the p shown on the accounts screen. As on the accounts screen, this can be toggled with `F`. -`C` toggles cleared mode, which shows transactions with [cleared status](/journal.html#status) only. -Similarly, `P` toggles pending mode, which shows only pending transactions, -and `U` toggles uncleared mode, which shows only 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. +(By default, transactions with all statuses are shown; +if you activate one or two status filters, only those transactions are shown; +and if you activate all three, the filter is removed.)q `R` toggles real mode, in which [virtual postings](/journal.html#virtual-postings) are ignored.