ui: 0 now limits depth to 0 instead of resetting it

This commit is contained in:
Simon Michael 2016-06-10 12:51:10 -07:00
parent dc6f39a859
commit 8b9f5e1cdf
6 changed files with 50 additions and 46 deletions

View File

@ -192,7 +192,7 @@ asDraw AppState{aopts=UIOpts{cliopts_=CliOpts{reportopts_=ropts}}
("h", "help")
,("right", "register")
,("F", "flat?")
,("-+=1234567890", "depth")
,("-+0123456789", "depth")
--,("/", "filter")
--,("DEL", "unfilter")
--,("ESC", "cancel/top")
@ -271,19 +271,19 @@ asHandle st'@AppState{
Vty.EvKey k [] | k `elem` [Vty.KChar 'h', Vty.KChar '?'] -> continue $ setMode Help st
Vty.EvKey (Vty.KChar 'g') [] -> liftIO (stReloadJournalIfChanged copts d j st) >>= continue
Vty.EvKey (Vty.KChar 'a') [] -> suspendAndResume $ clearScreen >> setCursorPosition 0 0 >> add copts j >> stReloadJournalIfChanged copts d j st
Vty.EvKey (Vty.KChar '0') [] -> continue $ regenerateScreens j d $ setDepth (Just 0) st
Vty.EvKey (Vty.KChar '1') [] -> continue $ regenerateScreens j d $ setDepth (Just 1) st
Vty.EvKey (Vty.KChar '2') [] -> continue $ regenerateScreens j d $ setDepth (Just 2) st
Vty.EvKey (Vty.KChar '3') [] -> continue $ regenerateScreens j d $ setDepth (Just 3) st
Vty.EvKey (Vty.KChar '4') [] -> continue $ regenerateScreens j d $ setDepth (Just 4) st
Vty.EvKey (Vty.KChar '5') [] -> continue $ regenerateScreens j d $ setDepth (Just 5) st
Vty.EvKey (Vty.KChar '6') [] -> continue $ regenerateScreens j d $ setDepth (Just 6) st
Vty.EvKey (Vty.KChar '7') [] -> continue $ regenerateScreens j d $ setDepth (Just 7) st
Vty.EvKey (Vty.KChar '8') [] -> continue $ regenerateScreens j d $ setDepth (Just 8) st
Vty.EvKey (Vty.KChar '9') [] -> continue $ regenerateScreens j d $ setDepth (Just 9) st
Vty.EvKey (Vty.KChar '-') [] -> continue $ regenerateScreens j d $ decDepth st
Vty.EvKey (Vty.KChar '+') [] -> continue $ regenerateScreens j d $ incDepth st
Vty.EvKey (Vty.KChar '=') [] -> continue $ regenerateScreens j d $ incDepth st
Vty.EvKey (Vty.KChar '1') [] -> continue $ regenerateScreens j d $ setDepth 1 st
Vty.EvKey (Vty.KChar '2') [] -> continue $ regenerateScreens j d $ setDepth 2 st
Vty.EvKey (Vty.KChar '3') [] -> continue $ regenerateScreens j d $ setDepth 3 st
Vty.EvKey (Vty.KChar '4') [] -> continue $ regenerateScreens j d $ setDepth 4 st
Vty.EvKey (Vty.KChar '5') [] -> continue $ regenerateScreens j d $ setDepth 5 st
Vty.EvKey (Vty.KChar '6') [] -> continue $ regenerateScreens j d $ setDepth 6 st
Vty.EvKey (Vty.KChar '7') [] -> continue $ regenerateScreens j d $ setDepth 7 st
Vty.EvKey (Vty.KChar '8') [] -> continue $ regenerateScreens j d $ setDepth 8 st
Vty.EvKey (Vty.KChar '9') [] -> continue $ regenerateScreens j d $ setDepth 9 st
Vty.EvKey (Vty.KChar '0') [] -> continue $ regenerateScreens j d $ setDepth 0 st
Vty.EvKey (Vty.KChar '_') [] -> continue $ regenerateScreens j d $ decDepth st
Vty.EvKey k [] | k `elem` [Vty.KChar '+', Vty.KChar '='] -> continue $ regenerateScreens j d $ incDepth st
Vty.EvKey (Vty.KChar 'F') [] -> continue $ regenerateScreens j d $ stToggleFlat st
Vty.EvKey (Vty.KChar 'E') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleEmpty st)
Vty.EvKey (Vty.KChar 'C') [] -> scrollTop >> (continue $ regenerateScreens j d $ stToggleCleared st)

View File

@ -113,8 +113,8 @@ stResetFilter st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=
,query_=""
}}}}
stResetDepth :: AppState -> AppState
stResetDepth st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =
resetDepth :: AppState -> AppState
resetDepth st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =
st{aopts=uopts{cliopts_=copts{reportopts_=ropts{depth_=Nothing}}}}
-- | Get the maximum account depth in the current journal.
@ -139,20 +139,19 @@ incDepth st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts
inc (Just d) | d < (maxDepth st - 1) = Just $ d+1
inc _ = Nothing
-- | Set the current depth limit to the specified depth, which should
-- be a positive number. If it is zero, or equal to or greater than the
-- current maximum account depth, the depth limit will be removed.
-- (Slight inconsistency here: zero is currently a valid display depth
-- which can be reached using the - key. But we need a key to remove
-- the depth limit, and 0 is it.)
setDepth :: Int -> AppState -> AppState
setDepth depth st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}}
-- | Set the current depth limit to the specified depth, or remove the depth limit.
-- Also remove the depth limit if the specified depth is greater than the current
-- maximum account depth. If the specified depth is negative, reset the depth limit
-- to whatever was specified at startup.
setDepth :: Maybe Int -> AppState -> AppState
setDepth mdepth st@AppState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}}
= st{aopts=uopts{cliopts_=copts{reportopts_=ropts{depth_=mdepth'}}}}
where
mdepth' | depth < 0 = depth_ ropts
| depth == 0 = Nothing
| depth >= maxDepth st = Nothing
| otherwise = Just depth
mdepth' = case mdepth of
Nothing -> Nothing
Just d | d < 0 -> depth_ ropts
| d >= maxDepth st -> Nothing
| otherwise -> mdepth
-- | Open the minibuffer, setting its content to the current query with the cursor at the end.
stShowMinibuffer st = setMode (Minibuffer e) st
@ -192,7 +191,7 @@ popScreen st = st
resetScreens :: Day -> AppState -> AppState
resetScreens d st@AppState{aScreen=s,aPrevScreens=ss} =
(sInit topscreen) d True $ stResetDepth $ stResetFilter $ stCloseMinibuffer st{aScreen=topscreen, aPrevScreens=[]}
(sInit topscreen) d True $ resetDepth $ stResetFilter $ stCloseMinibuffer st{aScreen=topscreen, aPrevScreens=[]}
where
topscreen = case ss of _:_ -> last ss
[] -> s
@ -243,8 +242,8 @@ helpDialog =
,str " "
,str "accounts screen:"
,renderKey ("F", "toggle flat mode")
,renderKey ("-+=1234567890", "")
,str " adjust/set/remove depth limit"
,renderKey ("-+0123456789", "")
,str " adjust/set depth limit"
]
)
]

View File

@ -267,9 +267,10 @@ When not in flat mode, indentation indicates the account hierarchy.
By default, all subaccounts are displayed.
To see less detail, set a depth limit by pressing a number key,
\f[C]1\f[] to \f[C]9\f[].
Or, adjust the depth limit by pressing \f[C]\-\f[] or \f[C]+\f[]
(\f[C]=\f[] also works).
\f[C]0\f[] removes the depth limit.
\f[C]0\f[] shows even less detail, collapsing all accounts to a single
total.
\f[C]\-\f[] and \f[C]+\f[] decrease and increase the depth limit.
To remove the depth limit press \f[C]=\f[], or just keep increasing it.
.PP
\f[C]C\f[] toggles cleared mode, in which uncleared transactions and
postings are not shown.

View File

@ -212,9 +212,10 @@ matched transactions.
`F' toggles flat mode on and off.
By default, all subaccounts are displayed. To see less detail, set a
depth limit by pressing a number key, `1' to `9'. Or, adjust the depth
limit by pressing `-' or `+' (`=' also works). `0' removes the depth
limit.
depth limit by pressing a number key, `1' to `9'. `0' shows even less
detail, collapsing all accounts to a single total. `-' and `+'
decrease and increase the depth limit. To remove the depth limit press
`=', or just keep increasing it.
`C' toggles cleared mode, in which uncleared transactions and
postings are not shown. `U' toggles uncleared mode, in which only
@ -330,11 +331,11 @@ Node: SCREENS5098
Ref: #screens5185
Node: Accounts screen5275
Ref: #accounts-screen5405
Node: Register screen6509
Ref: #register-screen6666
Node: Transaction screen8419
Ref: #transaction-screen8579
Node: Error screen9446
Ref: #error-screen9570
Node: Register screen6599
Ref: #register-screen6756
Node: Transaction screen8509
Ref: #transaction-screen8669
Node: Error screen9536
Ref: #error-screen9660

End Tag Table

View File

@ -118,8 +118,9 @@ When not in flat mode, indentation indicates the account hierarchy. `F` toggles
By default, all subaccounts are displayed.
To see less detail, set a depth limit by pressing a number key, `1` to `9`.
Or, adjust the depth limit by pressing `-` or `+` (`=` also works).
`0` removes the depth limit.
`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`.
`C` toggles cleared mode, in which
[uncleared transactions and postings](/journal.html#transactions) are

View File

@ -183,8 +183,10 @@ SSCCRREEEENNSS
toggles flat mode on and off.
By default, all subaccounts are displayed. To see less detail, set a
depth limit by pressing a number key, 1 to 9. Or, adjust the depth
limit by pressing - or + (= also works). 0 removes the depth limit.
depth limit by pressing a number key, 1 to 9. 0 shows even less
detail, collapsing all accounts to a single total. - and + decrease
and increase the depth limit. To remove the depth limit press =, or
just keep increasing it.
C toggles cleared mode, in which uncleared transactions and postings
are not shown. U toggles uncleared mode, in which only uncleared