ui: use t/l keys for tree/list, T for "today", drop vi keys?! retune help (#1286)

This commit is contained in:
Simon Michael 2020-07-17 15:17:21 -07:00
parent a3ae4d88f8
commit 847fc23236
6 changed files with 108 additions and 84 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")
,("-+", str "depth")
,("T", renderToggle (tree_ ropts) "flat" "tree")
,("H", renderToggle (not ishistorical) "end-bals" "changes")
,("F", renderToggle1 (isJust $ forecast_ ropts) "forecast")
--,("/", "filter")
@ -322,11 +323,12 @@ asHandle ui0@UIState{
VtyEvent (EvKey (KChar '-') []) -> continue $ regenerateScreens j d $ decDepth ui
VtyEvent (EvKey (KChar '_') []) -> continue $ regenerateScreens j d $ decDepth ui
VtyEvent (EvKey (KChar c) []) | c `elem` ['+','='] -> continue $ regenerateScreens j d $ incDepth ui
VtyEvent (EvKey (KChar 't') []) -> continue $ regenerateScreens j d $ setReportPeriod (DayPeriod d) ui
VtyEvent (EvKey (KChar 'T') []) -> continue $ regenerateScreens j d $ setReportPeriod (DayPeriod d) ui
-- display mode/query toggles
VtyEvent (EvKey (KChar 'H') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleHistorical ui
VtyEvent (EvKey (KChar 'T') []) -> asCenterAndContinue $ regenerateScreens j d $ toggleTree ui
VtyEvent (EvKey (KChar 't') []) -> asCenterAndContinue $ regenerateScreens j d $ setTree ui
VtyEvent (EvKey (KChar 'l') []) -> asCenterAndContinue $ regenerateScreens j d $ setList 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

@ -235,7 +235,12 @@ rsDraw UIState{aopts=_uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
("?", str "help")
,("LEFT", str "back")
-- ,("RIGHT", str "transaction")
,("T", renderToggle (tree_ ropts) "flat(-subs)" "tree(+subs)") -- rsForceInclusive may override, but use tree_ to ensure a visible toggle effect
-- 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)")
,("H", renderToggle (not ishistorical) "historical" "period")
,("F", renderToggle1 (isJust $ forecast_ ropts) "forecast")
-- ,("a", "add")
@ -316,7 +321,7 @@ rsHandle ui@UIState{
VtyEvent (EvKey (KChar 'I') []) -> continue $ uiCheckBalanceAssertions d (toggleIgnoreBalanceAssertions ui)
VtyEvent (EvKey (KChar 'a') []) -> suspendAndResume $ clearScreen >> setCursorPosition 0 0 >> add copts j >> uiReloadJournalIfChanged copts d j ui
VtyEvent (EvKey (KChar 'A') []) -> suspendAndResume $ void (runIadd (journalFilePath j)) >> uiReloadJournalIfChanged copts d j ui
VtyEvent (EvKey (KChar 't') []) -> continue $ regenerateScreens j d $ setReportPeriod (DayPeriod d) ui
VtyEvent (EvKey (KChar 'T') []) -> continue $ regenerateScreens j d $ setReportPeriod (DayPeriod d) ui
VtyEvent (EvKey (KChar 'E') []) -> suspendAndResume $ void (runEditor pos f) >> uiReloadJournalIfChanged copts d j ui
where
(pos,f) = case listSelectedElement rsList of
@ -330,7 +335,8 @@ 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 $ toggleTree ui
VtyEvent (EvKey (KChar 't') []) -> rsCenterAndContinue $ regenerateScreens j d $ setTree ui
VtyEvent (EvKey (KChar 'l') []) -> rsCenterAndContinue $ regenerateScreens j d $ setList 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

@ -1,6 +1,7 @@
{-# LANGUAGE CPP #-}
{- | UIState operations. -}
{-# LANGUAGE CPP #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
@ -135,6 +136,16 @@ valuationToggleValue :: Maybe ValuationType -> Maybe ValuationType
valuationToggleValue (Just (AtDefault _)) = Nothing
valuationToggleValue _ = Just $ AtDefault Nothing
-- | Set hierarchic account tree mode.
setTree :: UIState -> UIState
setTree ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =
ui{aopts=uopts{cliopts_=copts{reportopts_=ropts{accountlistmode_=ALTree}}}}
-- | Set flat account list mode.
setList :: UIState -> UIState
setList ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =
ui{aopts=uopts{cliopts_=copts{reportopts_=ropts{accountlistmode_=ALFlat}}}}
-- | Toggle between flat and tree mode. If current mode is unspecified/default, assume it's flat.
toggleTree :: UIState -> UIState
toggleTree ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}} =

View File

@ -91,31 +91,31 @@ helpDialog _copts =
render $
withDefAttr "help" $
renderDialog (dialog (Just "Help (?/LEFT/ESC to close)") Nothing (c^.availWidthL)) $ -- (Just (0,[("ok",())]))
padTop (Pad 1) $ padLeft (Pad 1) $ padRight (Pad 1) $
padTop (Pad 0) $ padLeft (Pad 1) $ padRight (Pad 1) $
vBox [
hBox [
padRight (Pad 1) $
vBox [
withAttr ("help" <> "heading") $ str "Navigation"
,renderKey ("UP/DOWN/PUP/PDN/HOME/END/emacs/vi keys", "")
,renderKey ("UP/DOWN/PUP/PDN/HOME/END or C-p/n/f/b", "")
,str " move selection"
,renderKey ("RIGHT", "show account txns, txn detail")
,renderKey ("RIGHT", "show account txns, or txn detail")
,renderKey ("LEFT ", "go back")
,renderKey ("ESC ", "cancel or reset")
,renderKey ("ESC ", "cancel input, or reset")
,str " "
,withAttr ("help" <> "heading") $ str "Report period"
,renderKey ("S-DOWN /S-UP ", "shrink/grow period")
,renderKey ("S-RIGHT/S-LEFT", "next/previous period")
,renderKey ("t ", "set period to today")
,renderKey ("T ", "set period to today")
,str " "
,withAttr ("help" <> "heading") $ str "Accounts screen"
,renderKey ("-+0123456789 ", "set depth limit")
,renderKey ("T ", "toggle tree/flat mode")
,renderKey ("H ", "historical end balance/period change")
,renderKey ("1234567890-+ ", "set/adjust depth limit")
,renderKey ("t/l", "set tree/list mode")
,renderKey ("H ", "toggle historical balance/change")
,str " "
,withAttr ("help" <> "heading") $ str "Register screen"
,renderKey ("T ", "toggle subaccount txns\n(and accounts screen tree/flat mode)")
,renderKey ("H ", "show historical total/period total")
,renderKey ("t/l", "show/hide subaccount txns\n(and set accounts tree/list mode)")
,renderKey ("H ", "toggle historical/period total")
,str " "
]
,padLeft (Pad 1) $ padRight (Pad 0) $
@ -130,8 +130,8 @@ helpDialog _copts =
,str " "
,withAttr ("help" <> "heading") $ str "Help"
,renderKey ("? ", "toggle this help")
,renderKey ("p/m/i ", "(with this help open)\nshow manual in pager/man/info")
,str " "
,renderKey ("p/m/i", "(with this help open)\nshow manual in pager/man/info")
-- ,str " " -- need one more line in 80x25
,withAttr ("help" <> "heading") $ str "Other"
,renderKey ("a ", "add transaction (hledger add)")
,renderKey ("A ", "add transaction (hledger-iadd)")
@ -341,10 +341,16 @@ 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]]
-- 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]]
normaliseMovementKeys ev
| ev `elem` moveUpEvents = EvKey KUp []

View File

@ -69,10 +69,10 @@ Any QUERYARGS are interpreted as a hledger search query which filters the data.
`--change`
: show period balances (changes) at startup instead of historical balances
`-F --flat`
: show accounts as a list (default)
`-l --flat`
: show accounts as a flat list (default)
`-T --tree`
`-t --tree`
: show accounts as a tree
hledger input options:
@ -87,113 +87,112 @@ hledger help options:
_helpoptions_
A @FILE argument will be expanded to the contents of FILE,
a @file argument will be expanded to the contents of file,
which should contain one command line option/argument per line.
(To prevent this, insert a `--` argument before.)
(to prevent this, insert a `--` argument before.)
# KEYS
# keys
`?` shows a help dialog listing all keys.
(Some of these also appear in the quick help at the bottom of each screen.)
Press `?` again (or `ESCAPE`, or `LEFT`) to close it.
The following keys work on most screens:
(some of these also appear in the quick help at the bottom of each screen.)
press `?` again (or `escape`, or `left`) to close it.
the following keys work on most screens:
The cursor keys navigate:
the cursor keys navigate:
`right` (or `enter`) goes deeper,
`left` returns to the previous screen,
`up`/`down`/`page up`/`page down`/`home`/`end` move up and down through lists.
Vi-style (`h`/`j`/`k`/`l`) and Emacs-style (`CTRL-p`/`CTRL-n`/`CTRL-f`/`CTRL-b`) movement keys are also supported.
Emacs-style (`ctrl-p`/`ctrl-n`/`ctrl-f`/`ctrl-b`) movement keys are also supported
(but not vi-style keys, since hledger-1.19, sorry!).
A tip: movement speed is limited by your keyboard repeat rate,
to move faster you may want to adjust it.
(If you're on a mac, the Karabiner app is one way to do that.)
(If you're on a mac, the karabiner app is one way to do that.)
With shift pressed, the cursor keys adjust the report period,
with shift pressed, the cursor keys adjust the report period,
limiting the transactions to be shown (by default, all are shown).
`shift-down/up` steps downward and upward through these standard report period durations:
year, quarter, month, week, day.
Then, `shift-left/right` moves to the previous/next period.
`t` sets the report period to today.
With the `--watch` option, when viewing a "current" period
then, `shift-left/right` moves to the previous/next period.
`T` sets the report period to today.
with the `--watch` option, when viewing a "current" period
(the current day, week, month, quarter, or year),
the period will move automatically to track the current date.
To set a non-standard period, you can use `/` and a `date:` query.
to set a non-standard period, you can use `/` and a `date:` query.
`/` lets you set a general filter query limiting the data shown,
using the same [query terms](hledger.html#queries) as in hledger and hledger-web.
While editing the query, you can use [CTRL-a/e/d/k, BS, cursor keys](http://hackage.haskell.org/package/brick-0.7/docs/Brick-Widgets-Edit.html#t:Editor);
press `ENTER` to set it, or `ESCAPE`to cancel.
There are also keys for quickly adjusting some common filters like account depth and transaction status (see below).
`BACKSPACE` or `DELETE` removes all filters, showing all transactions.
while editing the query, you can use [ctrl-a/e/d/k, bs, cursor keys](http://hackage.haskell.org/package/brick-0.7/docs/brick-widgets-edit.html#t:editor);
press `enter` to set it, or `escape`to cancel.
there are also keys for quickly adjusting some common filters like account depth and transaction status (see below).
`backspace` or `delete` removes all filters, showing all transactions.
As mentioned above, by default hledger-ui hides future transactions -
as mentioned above, by default hledger-ui hides future transactions -
both ordinary transactions recorded in the journal, and periodic
transactions generated by rule. `F` toggles forecast mode, in which
future/forecasted transactions are shown. (experimental)
transactions generated by rule. `f` toggles forecast mode, in which
future/forecasted transactions are shown. *(experimental)*
`ESCAPE` removes all filters and jumps back to the top screen.
Or, it cancels a minibuffer edit or help dialog in progress.
`escape` removes all filters and jumps back to the top screen.
or, it cancels a minibuffer edit or help dialog in progress.
`CTRL-l` redraws the screen and centers the selection if possible
`ctrl-l` redraws the screen and centers the selection if possible
(selections near the top won't be centered, since we don't scroll above the top).
`g` reloads from the data file(s) and updates the current screen and any
previous screens. (With large files, this could cause a noticeable pause.)
previous screens. (with large files, this could cause a noticeable pause.)
`I` toggles balance assertion checking.
Disabling balance assertions temporarily can be useful for troubleshooting.
`i` toggles balance assertion checking.
disabling balance assertions temporarily can be useful for troubleshooting.
`a` runs command-line hledger's add command, and reloads the updated file.
This allows some basic data entry.
this allows some basic data entry.
`A` is like `a`, but runs the [hledger-iadd](http://hackage.haskell.org/package/hledger-iadd) tool,
`a` is like `a`, but runs the [hledger-iadd](http://hackage.haskell.org/package/hledger-iadd) tool,
which provides a terminal interface.
This key will be available if `hledger-iadd` is installed in $PATH.
this key will be available if `hledger-iadd` is installed in $path.
`E` runs $HLEDGER_UI_EDITOR, or $EDITOR, or a default (`emacsclient -a "" -nw`) on the journal file.
With some editors (emacs, vi), the cursor will be positioned at the current transaction
`e` runs $hledger_ui_editor, or $editor, or a default (`emacsclient -a "" -nw`) on the journal file.
with some editors (emacs, vi), the cursor will be positioned at the current transaction
when invoked from the register and transaction screens, and at the error location (if possible)
when invoked from the error screen.
`q` quits the application.
Experimental:
`B` toggles cost mode, showing amounts in their transaction price's
`b` toggles cost mode, showing amounts in their transaction price's
commodity (like toggling the
[`-B/--cost`](https://hledger.org/hledger.html#b-cost) flag).
[`-b/--cost`](https://hledger.org/hledger.html#b-cost) flag).
`V` toggles value mode, showing amounts' current market value in their
`v` toggles value mode, showing amounts' current market value in their
default valuation commodity (like toggling the
[`-V/--market`](https://hledger.org/hledger.html#v-market-value) flag).
Note, "current market value" means the value on the report end date if specified, otherwise today.
To see the value on another date, you can temporarily set that as the report end date.
Eg: to see a transaction as it was valued on july 30,
[`-v/--market`](https://hledger.org/hledger.html#v-market-value) flag).
note, "current market value" means the value on the report end date if specified, otherwise today.
to see the value on another date, you can temporarily set that as the report end date.
eg: to see a transaction as it was valued on july 30,
go to the accounts or register screen,
press `/`,
and add ` date:-7/30` to the query.
At most one of cost or value mode can be active at once.
at most one of cost or value mode can be active at once.
There's not yet any visual reminder when cost or value mode is active;
for now pressing `B` `B` `V` should reliably reset to normal mode.
there's not yet any visual reminder when cost or value mode is active;
for now pressing `b` `b` `v` should reliably reset to normal mode.
With --watch active, if you save an edit to the journal file
with --watch active, if you save an edit to the journal file
while viewing the transaction screen in cost or value mode,
the `B`/`V` keys will stop working.
To work around, press g to force a manual reload, or exit the transaction screen.
the `b`/`v` keys will stop working.
to work around, press g to force a manual reload, or exit the transaction screen.
Additional screen-specific keys are described below.
`q` quits the application.
# SCREENS
additional screen-specific keys are described below.
## Accounts screen
# screens
This is normally the first screen displayed.
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).
## accounts screen
this is normally the first screen displayed.
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.
Account names are shown as a flat list by default. Press `T` to toggle tree mode.
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).
In tree mode, all account balances are inclusive of subaccounts.
@ -249,7 +248,7 @@ Transactions affecting this account's subaccounts will be included in the regist
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.
In other words, the register always shows the transactions contributing to the balance shown on the accounts screen.
Tree mode/flat mode can be toggled with `T` here also.
Tree mode or flat mode can be selected with `t`or `l` 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.

View File

@ -209,7 +209,7 @@ flattreeflags showamounthelp = [
("show accounts as a flat list (default)"
++ if showamounthelp then ". Amounts exclude subaccount amounts, except where the account is depth-clipped." else "")
,flagNone ["tree","t"] (setboolopt "tree")
("show accounts as a hierarchic tree" ++ if showamounthelp then ". Amounts include subaccount amounts." else "")
("show accounts as a tree" ++ if showamounthelp then ". Amounts include subaccount amounts." else "")
]
-- | Common flags that are accepted but not shown in --help,