From d1d6e237ecb21db9c7202cafd27a24da5984168d Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 3 Jun 2016 18:27:35 -0700 Subject: [PATCH] ui: U key shows only uncleared transactions/postings --- hledger-ui/Hledger/UI/AccountsScreen.hs | 4 ++ hledger-ui/Hledger/UI/Main.hs | 1 + hledger-ui/Hledger/UI/RegisterScreen.hs | 4 ++ hledger-ui/Hledger/UI/TransactionScreen.hs | 3 ++ hledger-ui/Hledger/UI/UIUtils.hs | 44 ++++++++++++++-------- hledger-ui/doc/hledger-ui.1 | 12 ++++-- hledger-ui/doc/hledger-ui.1.info | 22 ++++++----- hledger-ui/doc/hledger-ui.1.m4.md | 10 +++-- hledger-ui/doc/hledger-ui.1.txt | 26 +++++++------ 9 files changed, 80 insertions(+), 46 deletions(-) diff --git a/hledger-ui/Hledger/UI/AccountsScreen.hs b/hledger-ui/Hledger/UI/AccountsScreen.hs index 8fd11309d..1b078a751 100644 --- a/hledger-ui/Hledger/UI/AccountsScreen.hs +++ b/hledger-ui/Hledger/UI/AccountsScreen.hs @@ -127,6 +127,8 @@ drawAccountsScreen AppState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}} togglefilters = case concat [ if cleared_ ropts then ["cleared"] else [] + ,if uncleared_ ropts then ["uncleared"] else [] + ,if pending_ ropts then ["pending"] else [] ,if real_ ropts then ["real"] else [] ] of [] -> str "" @@ -144,6 +146,7 @@ drawAccountsScreen AppState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}} ,("F", "flat?") ,("E", "nonzero?") ,("C", "cleared?") + ,("U", "uncleared?") ,("R", "real?") ,("right/enter", "register") ,("g", "reload") @@ -262,6 +265,7 @@ handleAccountsScreen st@AppState{ Vty.EvKey (Vty.KChar 'F') [] -> continue $ reload j d $ stToggleFlat st' Vty.EvKey (Vty.KChar 'E') [] -> scrollTop >> (continue $ reload j d $ stToggleEmpty st') Vty.EvKey (Vty.KChar 'C') [] -> scrollTop >> (continue $ reload j d $ stToggleCleared st') + Vty.EvKey (Vty.KChar 'U') [] -> scrollTop >> (continue $ reload j d $ stToggleUncleared st') Vty.EvKey (Vty.KChar 'R') [] -> scrollTop >> (continue $ reload j d $ stToggleReal st') Vty.EvKey (Vty.KLeft) [] -> continue $ popScreen st' Vty.EvKey (k) [] | k `elem` [Vty.KRight, Vty.KEnter] -> do diff --git a/hledger-ui/Hledger/UI/Main.hs b/hledger-ui/Hledger/UI/Main.hs index dec964b38..5af3849ac 100644 --- a/hledger-ui/Hledger/UI/Main.hs +++ b/hledger-ui/Hledger/UI/Main.hs @@ -46,6 +46,7 @@ main = do run opts | "h" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStr (showModeUsage uimode) >> exitSuccess | "help" `inRawOpts` (rawopts_ $ cliopts_ opts) = printHelpForTopic (topicForMode uimode) >> exitSuccess + | "man" `inRawOpts` (rawopts_ $ cliopts_ opts) = runManForTopic (topicForMode uimode) >> exitSuccess | "info" `inRawOpts` (rawopts_ $ cliopts_ opts) = runInfoForTopic (topicForMode uimode) >> exitSuccess | "version" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStrLn prognameandversion >> exitSuccess | "binary-filename" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStrLn (binaryfilename progname) diff --git a/hledger-ui/Hledger/UI/RegisterScreen.hs b/hledger-ui/Hledger/UI/RegisterScreen.hs index fc8eb9d66..48dae71f1 100644 --- a/hledger-ui/Hledger/UI/RegisterScreen.hs +++ b/hledger-ui/Hledger/UI/RegisterScreen.hs @@ -109,6 +109,8 @@ drawRegisterScreen AppState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}} togglefilters = case concat [ if cleared_ ropts then ["cleared"] else [] + ,if uncleared_ ropts then ["uncleared"] else [] + ,if pending_ ropts then ["pending"] else [] ,if real_ ropts then ["real"] else [] ,if empty_ ropts then [] else ["nonzero"] ] of @@ -172,6 +174,7 @@ drawRegisterScreen AppState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}} ("left", "back") ,("E", "nonzero?") ,("C", "cleared?") + ,("U", "uncleared?") ,("R", "real?") ,("right/enter", "transaction") ,("g", "reload") @@ -222,6 +225,7 @@ handleRegisterScreen st@AppState{ Vty.EvKey (Vty.KChar 'E') [] -> scrollTop >> (continue $ reload j d $ stToggleEmpty st) Vty.EvKey (Vty.KChar 'C') [] -> scrollTop >> (continue $ reload j d $ stToggleCleared st) + Vty.EvKey (Vty.KChar 'U') [] -> scrollTop >> (continue $ reload j d $ stToggleUncleared st) Vty.EvKey (Vty.KChar 'R') [] -> scrollTop >> (continue $ reload j d $ stToggleReal st) Vty.EvKey (Vty.KLeft) [] -> continue $ popScreen st diff --git a/hledger-ui/Hledger/UI/TransactionScreen.hs b/hledger-ui/Hledger/UI/TransactionScreen.hs index fb8645810..0756d3bba 100644 --- a/hledger-ui/Hledger/UI/TransactionScreen.hs +++ b/hledger-ui/Hledger/UI/TransactionScreen.hs @@ -68,6 +68,8 @@ drawTransactionScreen AppState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}} togglefilters = case concat [ if cleared_ ropts then ["cleared"] else [] + ,if uncleared_ ropts then ["uncleared"] else [] + ,if pending_ ropts then ["pending"] else [] ,if real_ ropts then ["real"] else [] ,if empty_ ropts then [] else ["nonzero"] ] of @@ -77,6 +79,7 @@ drawTransactionScreen AppState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}} ("left", "back") ,("up/down", "prev/next") -- ,("C", "cleared?") +-- ,("U", "uncleared?") -- ,("R", "real?") ,("g", "reload") ,("q", "quit") diff --git a/hledger-ui/Hledger/UI/UIUtils.hs b/hledger-ui/Hledger/UI/UIUtils.hs index 0682fd526..02287d2a6 100644 --- a/hledger-ui/Hledger/UI/UIUtils.hs +++ b/hledger-ui/Hledger/UI/UIUtils.hs @@ -16,6 +16,8 @@ module Hledger.UI.UIUtils ( ,borderKeysStr -- ,stToggleCleared + ,stTogglePending + ,stToggleUncleared ,stToggleEmpty ,stToggleFlat ,stToggleReal @@ -42,38 +44,48 @@ import Hledger.Reports.ReportOptions import Hledger.Utils (applyN) -- import Hledger.Utils.Debug +-- | Toggle between showing only cleared items or all items. stToggleCleared :: AppState -> AppState stToggleCleared st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} = st{aopts=uopts{cliopts_=copts{reportopts_=toggleCleared ropts}}} + where + toggleCleared ropts = ropts{cleared_=not $ cleared_ ropts, uncleared_=False, pending_=False} --- | Toggle between showing all and showing only cleared items. -toggleCleared :: ReportOpts -> ReportOpts -toggleCleared ropts = ropts{cleared_=not $ cleared_ ropts} +-- | Toggle between showing only pending items or all items. +stTogglePending :: AppState -> AppState +stTogglePending st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} = + st{aopts=uopts{cliopts_=copts{reportopts_=togglePending ropts}}} + where + togglePending ropts = ropts{pending_=not $ pending_ ropts, uncleared_=False, cleared_=False} +-- | Toggle between showing only uncleared items or all items. +stToggleUncleared :: AppState -> AppState +stToggleUncleared st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} = + st{aopts=uopts{cliopts_=copts{reportopts_=toggleUncleared ropts}}} + where + toggleUncleared ropts = ropts{uncleared_=not $ uncleared_ ropts, cleared_=False, pending_=False} + +-- | Toggle between showing all and showing only nonempty (more precisely, nonzero) items. stToggleEmpty :: AppState -> AppState stToggleEmpty st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} = st{aopts=uopts{cliopts_=copts{reportopts_=toggleEmpty ropts}}} + where + toggleEmpty ropts = ropts{empty_=not $ empty_ ropts} --- | Toggle between showing all and showing only empty items. -toggleEmpty :: ReportOpts -> ReportOpts -toggleEmpty ropts = ropts{empty_=not $ empty_ ropts} - +-- | Toggle between flat and tree mode. If in the third "default" mode, go to flat mode. stToggleFlat :: AppState -> AppState stToggleFlat st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} = st{aopts=uopts{cliopts_=copts{reportopts_=toggleFlatMode ropts}}} + where + toggleFlatMode ropts@ReportOpts{accountlistmode_=ALFlat} = ropts{accountlistmode_=ALTree} + toggleFlatMode ropts = ropts{accountlistmode_=ALFlat} --- | Toggle between flat and tree mode. If in the third "default" mode, go to flat mode. -toggleFlatMode :: ReportOpts -> ReportOpts -toggleFlatMode ropts@ReportOpts{accountlistmode_=ALFlat} = ropts{accountlistmode_=ALTree} -toggleFlatMode ropts = ropts{accountlistmode_=ALFlat} - +-- | Toggle between showing all and showing only real (non-virtual) items. stToggleReal :: AppState -> AppState stToggleReal st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} = st{aopts=uopts{cliopts_=copts{reportopts_=toggleReal ropts}}} - --- | Toggle between showing all and showing only real (non-virtual) items. -toggleReal :: ReportOpts -> ReportOpts -toggleReal ropts = ropts{real_=not $ real_ ropts} + where + toggleReal ropts = ropts{real_=not $ real_ ropts} -- | Regenerate the content for the current and previous screens, from a new journal and current date. reload :: Journal -> Day -> AppState -> AppState diff --git a/hledger-ui/doc/hledger-ui.1 b/hledger-ui/doc/hledger-ui.1 index d377738b2..66f10d817 100644 --- a/hledger-ui/doc/hledger-ui.1 +++ b/hledger-ui/doc/hledger-ui.1 @@ -257,8 +257,10 @@ Or, adjust the depth limit by pressing \f[C]\-\f[] or \f[C]+\f[] balances are shown (hledger\-ui shows zero items by default, unlike command\-line hledger). .PP -\f[C]C\f[] toggles cleared mode, in which uncleared transactions (and -postings) are ignored. +\f[C]C\f[] toggles cleared mode, in which uncleared transactions and +postings are not shown. +\f[C]U\f[] toggles uncleared mode, in which only uncleared +transactions/postings are shown. .PP \f[C]R\f[] toggles real mode, in which virtual postings are ignored. .PP @@ -312,8 +314,10 @@ $\ hledger\-ui\ \-\-register\ checking\ \-\-cleared nonzero change are shown (hledger\-ui shows zero items by default, unlike command\-line hledger). .PP -\f[C]C\f[] toggles cleared mode, in which uncleared transactions (and -postings) are ignored. +\f[C]C\f[] toggles cleared mode, in which uncleared transactions and +postings are not shown. +\f[C]U\f[] toggles uncleared mode, in which only uncleared +transactions/postings are shown. .PP \f[C]R\f[] toggles real mode, in which virtual postings are ignored. .PP diff --git a/hledger-ui/doc/hledger-ui.1.info b/hledger-ui/doc/hledger-ui.1.info index 8d13eadb0..f309ac5cb 100644 --- a/hledger-ui/doc/hledger-ui.1.info +++ b/hledger-ui/doc/hledger-ui.1.info @@ -201,8 +201,9 @@ limit. balances are shown (hledger-ui shows zero items by default, unlike command-line hledger). - `C' toggles cleared mode, in which uncleared transactions (and -postings) are ignored. + `C' toggles cleared mode, in which uncleared transactions and +postings are not shown. `U' toggles uncleared mode, in which only +uncleared transactions/postings are shown. `R' toggles real mode, in which virtual postings are ignored. @@ -251,8 +252,9 @@ individual postings), in hledger-ui's register: nonzero change are shown (hledger-ui shows zero items by default, unlike command-line hledger). - `C' toggles cleared mode, in which uncleared transactions (and -postings) are ignored. + `C' toggles cleared mode, in which uncleared transactions and +postings are not shown. `U' toggles uncleared mode, in which only +uncleared transactions/postings are shown. `R' toggles real mode, in which virtual postings are ignored. @@ -305,11 +307,11 @@ Node: SCREENS4209 Ref: #screens4296 Node: Accounts screen4386 Ref: #accounts-screen4516 -Node: Register screen5535 -Ref: #register-screen5692 -Node: Transaction screen7264 -Ref: #transaction-screen7424 -Node: Error screen8291 -Ref: #error-screen8415 +Node: Register screen5620 +Ref: #register-screen5777 +Node: Transaction screen7434 +Ref: #transaction-screen7594 +Node: Error screen8461 +Ref: #error-screen8585  End Tag Table diff --git a/hledger-ui/doc/hledger-ui.1.m4.md b/hledger-ui/doc/hledger-ui.1.m4.md index 1a02b5665..bb337d6f8 100644 --- a/hledger-ui/doc/hledger-ui.1.m4.md +++ b/hledger-ui/doc/hledger-ui.1.m4.md @@ -115,8 +115,9 @@ are shown (hledger-ui shows zero items by default, unlike command-line hledger). `C` toggles cleared mode, in which -[uncleared transactions (and postings)](/journal.html#transactions) are -ignored. +[uncleared transactions and postings](/journal.html#transactions) are +not shown. `U` toggles uncleared mode, in which only uncleared +transactions/postings are shown. `R` toggles real mode, in which [virtual postings](/journal.html#virtual-postings) are ignored. @@ -162,8 +163,9 @@ change are shown (hledger-ui shows zero items by default, unlike command-line hledger). `C` toggles cleared mode, in which -[uncleared transactions (and postings)](/journal.html#transactions) are -ignored. +[uncleared transactions and postings](/journal.html#transactions) are +not shown. `U` toggles uncleared mode, in which only uncleared +transactions/postings are shown. `R` toggles real mode, in which [virtual postings](/journal.html#virtual-postings) are ignored. diff --git a/hledger-ui/doc/hledger-ui.1.txt b/hledger-ui/doc/hledger-ui.1.txt index aa9e01d5e..00c689ca4 100644 --- a/hledger-ui/doc/hledger-ui.1.txt +++ b/hledger-ui/doc/hledger-ui.1.txt @@ -175,8 +175,9 @@ SSCCRREEEENNSS are shown (hledger-ui shows zero items by default, unlike command-line hledger). - C toggles cleared mode, in which uncleared transactions (and postings) - are ignored. + C toggles cleared mode, in which uncleared transactions and postings + are not shown. U toggles uncleared mode, in which only uncleared + transactions/postings are shown. R toggles real mode, in which virtual postings are ignored. @@ -189,17 +190,17 @@ SSCCRREEEENNSS +o Each line represents a whole transaction. - +o For each transaction, it shows the other account(s) involved, in - abbreviated form. (If there are both real and virtual postings, it + +o For each transaction, it shows the other account(s) involved, in + abbreviated form. (If there are both real and virtual postings, it shows only the accounts affected by real postings.) - +o It shows the overall change to the current account's balance from - each transaction; positive for an inflow to this account, negative + +o It shows the overall change to the current account's balance from + each transaction; positive for an inflow to this account, negative for an outflow. +o When no query other than a date limit is in effect, it shows the cur- - rent account's historic balance as of the transaction date. Other- - wise it shows a running total starting from zero. Eg, these will + rent account's historic balance as of the transaction date. Other- + wise it shows a running total starting from zero. Eg, these will show historic balances: $ hledger-ui @@ -213,12 +214,13 @@ SSCCRREEEENNSS $ hledger-ui --begin 'this month' desc:market $ hledger-ui --register checking --cleared - E toggles nonzero mode, in which only transactions posting a nonzero - change are shown (hledger-ui shows zero items by default, unlike com- + E toggles nonzero mode, in which only transactions posting a nonzero + change are shown (hledger-ui shows zero items by default, unlike com- mand-line hledger). - C toggles cleared mode, in which uncleared transactions (and postings) - are ignored. + C toggles cleared mode, in which uncleared transactions and postings + are not shown. U toggles uncleared mode, in which only uncleared + transactions/postings are shown. R toggles real mode, in which virtual postings are ignored.