ui: U key shows only uncleared transactions/postings

This commit is contained in:
Simon Michael 2016-06-03 18:27:35 -07:00
parent 3b24c15813
commit d1d6e237ec
9 changed files with 80 additions and 46 deletions

View File

@ -127,6 +127,8 @@ drawAccountsScreen AppState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}
togglefilters = togglefilters =
case concat [ case concat [
if cleared_ ropts then ["cleared"] else [] 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 real_ ropts then ["real"] else []
] of ] of
[] -> str "" [] -> str ""
@ -144,6 +146,7 @@ drawAccountsScreen AppState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}
,("F", "flat?") ,("F", "flat?")
,("E", "nonzero?") ,("E", "nonzero?")
,("C", "cleared?") ,("C", "cleared?")
,("U", "uncleared?")
,("R", "real?") ,("R", "real?")
,("right/enter", "register") ,("right/enter", "register")
,("g", "reload") ,("g", "reload")
@ -262,6 +265,7 @@ handleAccountsScreen st@AppState{
Vty.EvKey (Vty.KChar 'F') [] -> continue $ reload j d $ stToggleFlat st' 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 'E') [] -> scrollTop >> (continue $ reload j d $ stToggleEmpty st')
Vty.EvKey (Vty.KChar 'C') [] -> scrollTop >> (continue $ reload j d $ stToggleCleared 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.KChar 'R') [] -> scrollTop >> (continue $ reload j d $ stToggleReal st')
Vty.EvKey (Vty.KLeft) [] -> continue $ popScreen st' Vty.EvKey (Vty.KLeft) [] -> continue $ popScreen st'
Vty.EvKey (k) [] | k `elem` [Vty.KRight, Vty.KEnter] -> do Vty.EvKey (k) [] | k `elem` [Vty.KRight, Vty.KEnter] -> do

View File

@ -46,6 +46,7 @@ main = do
run opts run opts
| "h" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStr (showModeUsage uimode) >> exitSuccess | "h" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStr (showModeUsage uimode) >> exitSuccess
| "help" `inRawOpts` (rawopts_ $ cliopts_ opts) = printHelpForTopic (topicForMode 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 | "info" `inRawOpts` (rawopts_ $ cliopts_ opts) = runInfoForTopic (topicForMode uimode) >> exitSuccess
| "version" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStrLn prognameandversion >> exitSuccess | "version" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStrLn prognameandversion >> exitSuccess
| "binary-filename" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStrLn (binaryfilename progname) | "binary-filename" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStrLn (binaryfilename progname)

View File

@ -109,6 +109,8 @@ drawRegisterScreen AppState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}
togglefilters = togglefilters =
case concat [ case concat [
if cleared_ ropts then ["cleared"] else [] 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 real_ ropts then ["real"] else []
,if empty_ ropts then [] else ["nonzero"] ,if empty_ ropts then [] else ["nonzero"]
] of ] of
@ -172,6 +174,7 @@ drawRegisterScreen AppState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}
("left", "back") ("left", "back")
,("E", "nonzero?") ,("E", "nonzero?")
,("C", "cleared?") ,("C", "cleared?")
,("U", "uncleared?")
,("R", "real?") ,("R", "real?")
,("right/enter", "transaction") ,("right/enter", "transaction")
,("g", "reload") ,("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 'E') [] -> scrollTop >> (continue $ reload j d $ stToggleEmpty st)
Vty.EvKey (Vty.KChar 'C') [] -> scrollTop >> (continue $ reload j d $ stToggleCleared 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.KChar 'R') [] -> scrollTop >> (continue $ reload j d $ stToggleReal st)
Vty.EvKey (Vty.KLeft) [] -> continue $ popScreen st Vty.EvKey (Vty.KLeft) [] -> continue $ popScreen st

View File

@ -68,6 +68,8 @@ drawTransactionScreen AppState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}
togglefilters = togglefilters =
case concat [ case concat [
if cleared_ ropts then ["cleared"] else [] 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 real_ ropts then ["real"] else []
,if empty_ ropts then [] else ["nonzero"] ,if empty_ ropts then [] else ["nonzero"]
] of ] of
@ -77,6 +79,7 @@ drawTransactionScreen AppState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}
("left", "back") ("left", "back")
,("up/down", "prev/next") ,("up/down", "prev/next")
-- ,("C", "cleared?") -- ,("C", "cleared?")
-- ,("U", "uncleared?")
-- ,("R", "real?") -- ,("R", "real?")
,("g", "reload") ,("g", "reload")
,("q", "quit") ,("q", "quit")

View File

@ -16,6 +16,8 @@ module Hledger.UI.UIUtils (
,borderKeysStr ,borderKeysStr
-- --
,stToggleCleared ,stToggleCleared
,stTogglePending
,stToggleUncleared
,stToggleEmpty ,stToggleEmpty
,stToggleFlat ,stToggleFlat
,stToggleReal ,stToggleReal
@ -42,37 +44,47 @@ import Hledger.Reports.ReportOptions
import Hledger.Utils (applyN) import Hledger.Utils (applyN)
-- import Hledger.Utils.Debug -- import Hledger.Utils.Debug
-- | Toggle between showing only cleared items or all items.
stToggleCleared :: AppState -> AppState stToggleCleared :: AppState -> AppState
stToggleCleared st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} = stToggleCleared st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =
st{aopts=uopts{cliopts_=copts{reportopts_=toggleCleared 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. -- | Toggle between showing only pending items or all items.
toggleCleared :: ReportOpts -> ReportOpts stTogglePending :: AppState -> AppState
toggleCleared ropts = ropts{cleared_=not $ cleared_ ropts} 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 :: AppState -> AppState
stToggleEmpty st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} = stToggleEmpty st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =
st{aopts=uopts{cliopts_=copts{reportopts_=toggleEmpty ropts}}} st{aopts=uopts{cliopts_=copts{reportopts_=toggleEmpty ropts}}}
where
-- | Toggle between showing all and showing only empty items.
toggleEmpty :: ReportOpts -> ReportOpts
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.
stToggleFlat :: AppState -> AppState stToggleFlat :: AppState -> AppState
stToggleFlat st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} = stToggleFlat st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =
st{aopts=uopts{cliopts_=copts{reportopts_=toggleFlatMode ropts}}} st{aopts=uopts{cliopts_=copts{reportopts_=toggleFlatMode ropts}}}
where
-- | 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@ReportOpts{accountlistmode_=ALFlat} = ropts{accountlistmode_=ALTree}
toggleFlatMode ropts = ropts{accountlistmode_=ALFlat} toggleFlatMode ropts = ropts{accountlistmode_=ALFlat}
-- | Toggle between showing all and showing only real (non-virtual) items.
stToggleReal :: AppState -> AppState stToggleReal :: AppState -> AppState
stToggleReal st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} = stToggleReal st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =
st{aopts=uopts{cliopts_=copts{reportopts_=toggleReal ropts}}} st{aopts=uopts{cliopts_=copts{reportopts_=toggleReal ropts}}}
where
-- | Toggle between showing all and showing only real (non-virtual) items.
toggleReal :: ReportOpts -> ReportOpts
toggleReal ropts = ropts{real_=not $ real_ ropts} toggleReal ropts = ropts{real_=not $ real_ ropts}
-- | Regenerate the content for the current and previous screens, from a new journal and current date. -- | Regenerate the content for the current and previous screens, from a new journal and current date.

View File

@ -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 balances are shown (hledger\-ui shows zero items by default, unlike
command\-line hledger). command\-line hledger).
.PP .PP
\f[C]C\f[] toggles cleared mode, in which uncleared transactions (and \f[C]C\f[] toggles cleared mode, in which uncleared transactions and
postings) are ignored. postings are not shown.
\f[C]U\f[] toggles uncleared mode, in which only uncleared
transactions/postings are shown.
.PP .PP
\f[C]R\f[] toggles real mode, in which virtual postings are ignored. \f[C]R\f[] toggles real mode, in which virtual postings are ignored.
.PP .PP
@ -312,8 +314,10 @@ $\ hledger\-ui\ \-\-register\ checking\ \-\-cleared
nonzero change are shown (hledger\-ui shows zero items by default, nonzero change are shown (hledger\-ui shows zero items by default,
unlike command\-line hledger). unlike command\-line hledger).
.PP .PP
\f[C]C\f[] toggles cleared mode, in which uncleared transactions (and \f[C]C\f[] toggles cleared mode, in which uncleared transactions and
postings) are ignored. postings are not shown.
\f[C]U\f[] toggles uncleared mode, in which only uncleared
transactions/postings are shown.
.PP .PP
\f[C]R\f[] toggles real mode, in which virtual postings are ignored. \f[C]R\f[] toggles real mode, in which virtual postings are ignored.
.PP .PP

View File

@ -201,8 +201,9 @@ limit.
balances are shown (hledger-ui shows zero items by default, unlike balances are shown (hledger-ui shows zero items by default, unlike
command-line hledger). command-line hledger).
`C' toggles cleared mode, in which uncleared transactions (and `C' toggles cleared mode, in which uncleared transactions and
postings) are ignored. 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. `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 nonzero change are shown (hledger-ui shows zero items by default, unlike
command-line hledger). command-line hledger).
`C' toggles cleared mode, in which uncleared transactions (and `C' toggles cleared mode, in which uncleared transactions and
postings) are ignored. 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. `R' toggles real mode, in which virtual postings are ignored.
@ -305,11 +307,11 @@ Node: SCREENS4209
Ref: #screens4296 Ref: #screens4296
Node: Accounts screen4386 Node: Accounts screen4386
Ref: #accounts-screen4516 Ref: #accounts-screen4516
Node: Register screen5535 Node: Register screen5620
Ref: #register-screen5692 Ref: #register-screen5777
Node: Transaction screen7264 Node: Transaction screen7434
Ref: #transaction-screen7424 Ref: #transaction-screen7594
Node: Error screen8291 Node: Error screen8461
Ref: #error-screen8415 Ref: #error-screen8585
 
End Tag Table End Tag Table

View File

@ -115,8 +115,9 @@ are shown (hledger-ui shows zero items by default, unlike command-line
hledger). hledger).
`C` toggles cleared mode, in which `C` toggles cleared mode, in which
[uncleared transactions (and postings)](/journal.html#transactions) are [uncleared transactions and postings](/journal.html#transactions) are
ignored. 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. `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). unlike command-line hledger).
`C` toggles cleared mode, in which `C` toggles cleared mode, in which
[uncleared transactions (and postings)](/journal.html#transactions) are [uncleared transactions and postings](/journal.html#transactions) are
ignored. 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. `R` toggles real mode, in which [virtual postings](/journal.html#virtual-postings) are ignored.

View File

@ -175,8 +175,9 @@ SSCCRREEEENNSS
are shown (hledger-ui shows zero items by default, unlike command-line are shown (hledger-ui shows zero items by default, unlike command-line
hledger). hledger).
C toggles cleared mode, in which uncleared transactions (and postings) C toggles cleared mode, in which uncleared transactions and postings
are ignored. 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. R toggles real mode, in which virtual postings are ignored.
@ -217,8 +218,9 @@ SSCCRREEEENNSS
change are shown (hledger-ui shows zero items by default, unlike com- change are shown (hledger-ui shows zero items by default, unlike com-
mand-line hledger). mand-line hledger).
C toggles cleared mode, in which uncleared transactions (and postings) C toggles cleared mode, in which uncleared transactions and postings
are ignored. 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. R toggles real mode, in which virtual postings are ignored.