ui: restore vi keys by popular demand; t toggles tree mode (#1286)

This commit is contained in:
Simon Michael 2020-07-18 08:39:23 -07:00
parent 386a967a66
commit ae830a1ace
4 changed files with 26 additions and 32 deletions

View File

@ -208,8 +208,9 @@ asDraw UIState{aopts=_uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
quickhelp = borderKeysStr' [
("?", str "help")
-- ,("RIGHT", str "register")
,("t", str "tree")
,("l", str "list")
,("t", renderToggle (tree_ ropts) "list" "tree")
-- ,("t", str "tree")
-- ,("l", str "list")
,("-+", str "depth")
,("H", renderToggle (not ishistorical) "end-bals" "changes")
,("F", renderToggle1 (isJust $ forecast_ ropts) "forecast")
@ -327,8 +328,7 @@ asHandle ui0@UIState{
-- display mode/query toggles
VtyEvent (EvKey (KChar 'H') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleHistorical ui
VtyEvent (EvKey (KChar 't') []) -> asCenterAndContinue $ regenerateScreens j d $ setTree ui
VtyEvent (EvKey (KChar 'l') []) -> asCenterAndContinue $ regenerateScreens j d $ setList ui
VtyEvent (EvKey (KChar 't') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleTree ui
VtyEvent (EvKey (KChar 'Z') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleEmpty ui
VtyEvent (EvKey (KChar 'R') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleReal ui
VtyEvent (EvKey (KChar 'U') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleUnmarked ui

View File

@ -237,9 +237,9 @@ rsDraw UIState{aopts=_uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
-- ,("RIGHT", str "transaction")
-- tree/list mode - rsForceInclusive may override, but use tree_ to ensure a visible toggle effect
-- ,("T", renderToggle (tree_ ropts) "flat(-subs)" "tree(+subs)")
,("t", str "tree(+subs)")
,("l", str "list(-subs)")
,("t", renderToggle (tree_ ropts) "list(-subs)" "tree(+subs)")
-- ,("t", str "tree(+subs)")
-- ,("l", str "list(-subs)")
,("H", renderToggle (not ishistorical) "historical" "period")
,("F", renderToggle1 (isJust $ forecast_ ropts) "forecast")
@ -335,8 +335,7 @@ rsHandle ui@UIState{
VtyEvent (EvKey (KChar 'B') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleCost ui
VtyEvent (EvKey (KChar 'V') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleValue ui
VtyEvent (EvKey (KChar 'H') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleHistorical ui
VtyEvent (EvKey (KChar 't') []) -> rsCenterAndContinue $ regenerateScreens j d $ setTree ui
VtyEvent (EvKey (KChar 'l') []) -> rsCenterAndContinue $ regenerateScreens j d $ setList ui
VtyEvent (EvKey (KChar 't') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleTree ui
VtyEvent (EvKey (KChar 'Z') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleEmpty ui
VtyEvent (EvKey (KChar 'R') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleReal ui
VtyEvent (EvKey (KChar 'U') []) -> rsCenterAndContinue $ regenerateScreens j d $ toggleUnmarked ui

View File

@ -97,11 +97,12 @@ helpDialog _copts =
padRight (Pad 1) $
vBox [
withAttr ("help" <> "heading") $ str "Navigation"
,renderKey ("UP/DOWN/PUP/PDN/HOME/END or C-p/n/f/b", "")
,str " move selection"
,renderKey ("RIGHT", "show account txns, or txn detail")
,renderKey ("LEFT ", "go back")
,renderKey ("ESC ", "cancel input, or reset everything")
,renderKey ("UP/DOWN/PUP/PDN/HOME/END/k/j/C-p/C-n", "")
,str " move selection up/down"
,renderKey ("RIGHT/l/C-f", "")
,str " show account txns, or txn detail"
,renderKey ("LEFT/h/C-b ", "go back")
,renderKey ("ESC ", "cancel input, or reset UI")
,str " "
,withAttr ("help" <> "heading") $ str "Report period"
,renderKey ("S-DOWN /S-UP ", "shrink/grow period")
@ -110,12 +111,12 @@ helpDialog _copts =
,str " "
,withAttr ("help" <> "heading") $ str "Accounts screen"
,renderKey ("1234567890-+ ", "set/adjust depth limit")
,renderKey ("t/l", "set tree/list mode")
,renderKey ("H ", "toggle historical balance/change")
,renderKey ("t ", "toggle accounts tree/list mode")
,renderKey ("H ", "toggle historical balance/change")
,str " "
,withAttr ("help" <> "heading") $ str "Register screen"
,renderKey ("t/l", "show/hide subaccount txns\n(and set accounts tree/list mode)")
,renderKey ("H ", "toggle historical/period total")
,renderKey ("t ", "toggle subaccount txns\n(and accounts tree/list mode)")
,renderKey ("H ", "toggle historical/period total")
,str " "
]
,padLeft (Pad 1) $ padRight (Pad 0) $
@ -341,16 +342,10 @@ scrollSelectionToMiddle list = do
_ -> return ()
-- arrow keys vi keys emacs keys
-- moveUpEvents = [EvKey KUp [] , EvKey (KChar 'k') [], EvKey (KChar 'p') [MCtrl]]
-- moveDownEvents = [EvKey KDown [] , EvKey (KChar 'j') [], EvKey (KChar 'n') [MCtrl]]
-- moveLeftEvents = [EvKey KLeft [] , EvKey (KChar 'h') [], EvKey (KChar 'b') [MCtrl]]
-- moveRightEvents = [EvKey KRight [], EvKey (KChar 'l') [], EvKey (KChar 'f') [MCtrl]]
-- arrow keys emacs keys
moveUpEvents = [EvKey KUp [] , EvKey (KChar 'p') [MCtrl]]
moveDownEvents = [EvKey KDown [] , EvKey (KChar 'n') [MCtrl]]
moveLeftEvents = [EvKey KLeft [] , EvKey (KChar 'b') [MCtrl]]
moveRightEvents = [EvKey KRight [], EvKey (KChar 'f') [MCtrl]]
moveUpEvents = [EvKey KUp [] , EvKey (KChar 'k') [], EvKey (KChar 'p') [MCtrl]]
moveDownEvents = [EvKey KDown [] , EvKey (KChar 'j') [], EvKey (KChar 'n') [MCtrl]]
moveLeftEvents = [EvKey KLeft [] , EvKey (KChar 'h') [], EvKey (KChar 'b') [MCtrl]]
moveRightEvents = [EvKey KRight [], EvKey (KChar 'l') [], EvKey (KChar 'f') [MCtrl]]
normaliseMovementKeys ev
| ev `elem` moveUpEvents = EvKey KUp []

View File

@ -192,8 +192,8 @@ it lists accounts and their balances, like hledger's balance command.
by default, it shows all accounts and their latest ending balances (including the balances of subaccounts).
if you specify a query on the command line, it shows just the matched accounts and the balances from matched transactions.
Press `t` or `l` to show accounts as a tree or flat list (the default).
In flat mode, account balances are exclusive of subaccounts, except where subaccounts are hidden by a depth limit (see below).
Account names are shown as a flat list by default; press `t` to toggle tree mode.
In list mode, account balances are exclusive of subaccounts, except where subaccounts are hidden by a depth limit (see below).
In tree mode, all account balances are inclusive of subaccounts.
To see less detail, press a number key, `1` to `9`, to set a depth limit.
@ -246,9 +246,9 @@ running historical balance you would see on a bank register for the current acco
Transactions affecting this account's subaccounts will be included in the register
if the accounts screen is in tree mode,
or if it's in flat mode but this account has subaccounts which are not shown due to a depth limit.
or if it's in list mode but this account has subaccounts which are not shown due to a depth limit.
In other words, the register always shows the transactions contributing to the balance shown on the accounts screen.
Tree mode or flat mode can be selected with `t`or `l` here also.
Tree mode/list mode can be toggled with `t` here also.
`U` toggles filtering by [unmarked status](journal.html#status), showing or hiding unmarked transactions.
Similarly, `P` toggles pending transactions, and `C` toggles cleared transactions.