ui: U key shows only uncleared transactions/postings
This commit is contained in:
		
							parent
							
								
									3b24c15813
								
							
						
					
					
						commit
						d1d6e237ec
					
				| @ -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 | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
| @ -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 | ||||
| 
 | ||||
|  | ||||
| @ -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") | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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. | ||||
| 
 | ||||
|  | ||||
| @ -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. | ||||
| 
 | ||||
| @ -217,8 +218,9 @@ SSCCRREEEENNSS | ||||
|        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. | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user