ui: refactor, try to clarify toggles' help
Consistent ordering with most-used toggles first, more intuitive wording
This commit is contained in:
parent
1e7760a2c7
commit
12d3ba6fc0
@ -216,23 +216,13 @@ asDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
|
|||||||
Minibuffer ed -> minibuffer ed
|
Minibuffer ed -> minibuffer ed
|
||||||
_ -> quickhelp
|
_ -> quickhelp
|
||||||
where
|
where
|
||||||
selectedstr = withAttr ("border" <> "selected") . str
|
|
||||||
quickhelp = borderKeysStr' [
|
quickhelp = borderKeysStr' [
|
||||||
("?", str "help")
|
("?", str "help")
|
||||||
,("RIGHT", str "register")
|
-- ,("RIGHT", str "register")
|
||||||
,("H"
|
|
||||||
,if ishistorical
|
|
||||||
then selectedstr "historical" <+> str "/period"
|
|
||||||
else str "historical/" <+> selectedstr "period")
|
|
||||||
,("T"
|
|
||||||
,if tree_ ropts
|
|
||||||
then str "flat/" <+> selectedstr "tree"
|
|
||||||
else selectedstr "flat" <+> str "/tree")
|
|
||||||
,("F"
|
|
||||||
,if presentorfuture_ uopts == PFFuture
|
|
||||||
then str "present/" <+> selectedstr "future"
|
|
||||||
else selectedstr "present" <+> str "/future")
|
|
||||||
,("-+", str "depth")
|
,("-+", str "depth")
|
||||||
|
,("T", renderToggle (tree_ ropts) "flat" "tree")
|
||||||
|
,("H", renderToggle (not ishistorical) "end-bals" "changes")
|
||||||
|
,("F", renderToggle (presentorfuture_ uopts == PFFuture) "present" "future")
|
||||||
--,("/", "filter")
|
--,("/", "filter")
|
||||||
--,("DEL", "unfilter")
|
--,("DEL", "unfilter")
|
||||||
--,("ESC", "cancel/top")
|
--,("ESC", "cancel/top")
|
||||||
|
|||||||
@ -225,24 +225,13 @@ rsDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
|
|||||||
Minibuffer ed -> minibuffer ed
|
Minibuffer ed -> minibuffer ed
|
||||||
_ -> quickhelp
|
_ -> quickhelp
|
||||||
where
|
where
|
||||||
selectedstr = withAttr ("border" <> "query") . str
|
|
||||||
quickhelp = borderKeysStr' [
|
quickhelp = borderKeysStr' [
|
||||||
("?", str "help")
|
("?", str "help")
|
||||||
,("LEFT", str "back")
|
,("LEFT", str "back")
|
||||||
,("RIGHT", str "transaction")
|
-- ,("RIGHT", str "transaction")
|
||||||
,("H"
|
,("T", renderToggle (tree_ ropts) "flat(-subs)" "tree(+subs)") -- rsForceInclusive may override, but use tree_ to ensure a visible toggle effect
|
||||||
,if ishistorical
|
,("H", renderToggle (not ishistorical) "historical" "period")
|
||||||
then selectedstr "historical" <+> str "/period"
|
,("F", renderToggle (presentorfuture_ uopts == PFFuture) "present" "future")
|
||||||
else str "historical/" <+> selectedstr "period")
|
|
||||||
,("T"
|
|
||||||
-- rsForceInclusive may override, but use tree_ here to ensure a visible toggle effect
|
|
||||||
,if tree_ ropts
|
|
||||||
then str "flat/" <+> selectedstr "tree"
|
|
||||||
else selectedstr "flat" <+> str "/tree")
|
|
||||||
,("F"
|
|
||||||
,if presentorfuture_ uopts == PFFuture
|
|
||||||
then str "present/" <+> selectedstr "future"
|
|
||||||
else selectedstr "present" <+> str "/future")
|
|
||||||
-- ,("a", "add")
|
-- ,("a", "add")
|
||||||
-- ,("g", "reload")
|
-- ,("g", "reload")
|
||||||
-- ,("q", "quit")
|
-- ,("q", "quit")
|
||||||
|
|||||||
@ -18,6 +18,7 @@ module Hledger.UI.UIUtils (
|
|||||||
,moveRightEvents
|
,moveRightEvents
|
||||||
,moveUpEvents
|
,moveUpEvents
|
||||||
,normaliseMovementKeys
|
,normaliseMovementKeys
|
||||||
|
,renderToggle
|
||||||
,replaceHiddenAccountsNameWith
|
,replaceHiddenAccountsNameWith
|
||||||
,scrollSelectionToMiddle
|
,scrollSelectionToMiddle
|
||||||
)
|
)
|
||||||
@ -48,6 +49,15 @@ import Hledger.UI.UIState
|
|||||||
|
|
||||||
-- ui
|
-- ui
|
||||||
|
|
||||||
|
-- | Wrap a widget in the default hledger-ui screen layout.
|
||||||
|
defaultLayout :: Widget Name -> Widget Name -> Widget Name -> Widget Name
|
||||||
|
defaultLayout toplabel bottomlabel =
|
||||||
|
topBottomBorderWithLabels (str " "<+>toplabel<+>str " ") (str " "<+>bottomlabel<+>str " ") .
|
||||||
|
margin 1 0 Nothing
|
||||||
|
-- topBottomBorderWithLabel2 label .
|
||||||
|
-- padLeftRight 1 -- XXX should reduce inner widget's width by 2, but doesn't
|
||||||
|
-- "the layout adjusts... if you use the core combinators"
|
||||||
|
|
||||||
-- | Draw the help dialog, called when help mode is active.
|
-- | Draw the help dialog, called when help mode is active.
|
||||||
helpDialog :: CliOpts -> Widget Name
|
helpDialog :: CliOpts -> Widget Name
|
||||||
helpDialog _copts =
|
helpDialog _copts =
|
||||||
@ -64,7 +74,7 @@ helpDialog _copts =
|
|||||||
withAttr ("help" <> "heading") $ str "Navigation"
|
withAttr ("help" <> "heading") $ str "Navigation"
|
||||||
,renderKey ("UP/DOWN/PUP/PDN/HOME/END/emacs/vi keys", "")
|
,renderKey ("UP/DOWN/PUP/PDN/HOME/END/emacs/vi keys", "")
|
||||||
,str " move selection"
|
,str " move selection"
|
||||||
,renderKey ("RIGHT", "show more detail")
|
,renderKey ("RIGHT", "show account txns, txn detail")
|
||||||
,renderKey ("LEFT ", "go back")
|
,renderKey ("LEFT ", "go back")
|
||||||
,renderKey ("ESC ", "cancel or reset")
|
,renderKey ("ESC ", "cancel or reset")
|
||||||
,str " "
|
,str " "
|
||||||
@ -76,11 +86,11 @@ helpDialog _copts =
|
|||||||
,withAttr ("help" <> "heading") $ str "Accounts screen"
|
,withAttr ("help" <> "heading") $ str "Accounts screen"
|
||||||
,renderKey ("-+0123456789 ", "set depth limit")
|
,renderKey ("-+0123456789 ", "set depth limit")
|
||||||
,renderKey ("T ", "toggle tree/flat mode")
|
,renderKey ("T ", "toggle tree/flat mode")
|
||||||
,renderKey ("H ", "period change/historical end balance")
|
,renderKey ("H ", "historical end balance/period change")
|
||||||
,str " "
|
,str " "
|
||||||
,withAttr ("help" <> "heading") $ str "Register screen"
|
,withAttr ("help" <> "heading") $ str "Register screen"
|
||||||
,renderKey ("T ", "toggle subaccount txns\n(and accounts screen tree/flat mode)")
|
,renderKey ("T ", "toggle subaccount txns\n(and accounts screen tree/flat mode)")
|
||||||
,renderKey ("H ", "show period total/historical total")
|
,renderKey ("H ", "show historical total/period total")
|
||||||
,str " "
|
,str " "
|
||||||
]
|
]
|
||||||
,padLeft (Pad 1) $ padRight (Pad 0) $
|
,padLeft (Pad 1) $ padRight (Pad 0) $
|
||||||
@ -95,7 +105,7 @@ helpDialog _copts =
|
|||||||
,str " "
|
,str " "
|
||||||
,withAttr ("help" <> "heading") $ str "Help"
|
,withAttr ("help" <> "heading") $ str "Help"
|
||||||
,renderKey ("? ", "toggle this help")
|
,renderKey ("? ", "toggle this help")
|
||||||
,renderKey ("pmi ", "(with help showing)\nshow manual in pager/man/info")
|
,renderKey ("pmi ", "(with this help open)\nshow manual in pager/man/info")
|
||||||
,str " "
|
,str " "
|
||||||
,withAttr ("help" <> "heading") $ str "Other"
|
,withAttr ("help" <> "heading") $ str "Other"
|
||||||
,renderKey ("a ", "add transaction (hledger add)")
|
,renderKey ("a ", "add transaction (hledger add)")
|
||||||
@ -149,15 +159,6 @@ minibuffer ed =
|
|||||||
[txt "filter: ", renderEditor True ed]
|
[txt "filter: ", renderEditor True ed]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
-- | Wrap a widget in the default hledger-ui screen layout.
|
|
||||||
defaultLayout :: Widget Name -> Widget Name -> Widget Name -> Widget Name
|
|
||||||
defaultLayout toplabel bottomlabel =
|
|
||||||
topBottomBorderWithLabels (str " "<+>toplabel<+>str " ") (str " "<+>bottomlabel<+>str " ") .
|
|
||||||
margin 1 0 Nothing
|
|
||||||
-- topBottomBorderWithLabel2 label .
|
|
||||||
-- padLeftRight 1 -- XXX should reduce inner widget's width by 2, but doesn't
|
|
||||||
-- "the layout adjusts... if you use the core combinators"
|
|
||||||
|
|
||||||
borderQueryStr :: String -> Widget Name
|
borderQueryStr :: String -> Widget Name
|
||||||
borderQueryStr "" = str ""
|
borderQueryStr "" = str ""
|
||||||
borderQueryStr qry = str " matching " <+> withAttr ("border" <> "query") (str qry)
|
borderQueryStr qry = str " matching " <+> withAttr ("border" <> "query") (str qry)
|
||||||
@ -182,6 +183,14 @@ borderKeysStr' keydescs =
|
|||||||
-- sep = str " | "
|
-- sep = str " | "
|
||||||
sep = str " "
|
sep = str " "
|
||||||
|
|
||||||
|
-- | Render the two states of a toggle, highlighting the active one.
|
||||||
|
renderToggle :: Bool -> String -> String -> Widget Name
|
||||||
|
renderToggle isright l r =
|
||||||
|
let bold = withAttr ("border" <> "selected") in
|
||||||
|
if isright
|
||||||
|
then str (l++"/") <+> bold (str r)
|
||||||
|
else bold (str l) <+> str ("/"++r)
|
||||||
|
|
||||||
-- temporary shenanigans:
|
-- temporary shenanigans:
|
||||||
|
|
||||||
-- | Convert the special account name "*" (from balance report with depth limit 0) to something clearer.
|
-- | Convert the special account name "*" (from balance report with depth limit 0) to something clearer.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user