ui: style help headings & keys; style cleanups

This commit is contained in:
Simon Michael 2018-10-23 06:07:35 -07:00
parent 16faa7dd9c
commit f66bb8d5c0
2 changed files with 24 additions and 17 deletions

View File

@ -68,14 +68,18 @@ themeNames = map fst themesList
themesList :: [(String, AttrMap)] themesList :: [(String, AttrMap)]
themesList = [ themesList = [
("default", attrMap ("default", attrMap
(black `on` white & bold) [ -- default style for this theme (black `on` white) [ -- default style for this theme
("error", currentAttr `withForeColor` red),
(borderAttr , white `on` black & dim), (borderAttr , white `on` black & dim),
(borderAttr <> "bold", white `on` black & bold), (borderAttr <> "bold", currentAttr & bold),
(borderAttr <> "query", cyan `on` black & bold), (borderAttr <> "query", currentAttr `withForeColor` cyan & bold),
(borderAttr <> "depth", yellow `on` black & bold), (borderAttr <> "depth", currentAttr `withForeColor` yellow & bold),
-- (borderAttr <> "keys", black `on` white & bold), (borderAttr <> "key", currentAttr `withForeColor` brightWhite & bold),
(borderAttr <> "minibuffer", white `on` black & bold), (borderAttr <> "minibuffer", white `on` black & bold),
("help", white `on` black & dim),
("help" <> "heading", currentAttr `withForeColor` yellow),
("help" <> "key", currentAttr `withForeColor` brightWhite & bold),
-- ("normal" , black `on` white), -- ("normal" , black `on` white),
("list" , black `on` white), -- regular list items ("list" , black `on` white), -- regular list items
("list" <> "selected" , white `on` blue & bold), -- selected list items ("list" <> "selected" , white `on` blue & bold), -- selected list items
@ -88,7 +92,10 @@ themesList = [
("list" <> "amount" <> "increase" <> "selected", brightGreen `on` blue & bold), ("list" <> "amount" <> "increase" <> "selected", brightGreen `on` blue & bold),
("list" <> "amount" <> "decrease" <> "selected", brightRed `on` blue & bold), ("list" <> "amount" <> "decrease" <> "selected", brightRed `on` blue & bold),
("list" <> "balance" <> "positive" <> "selected", white `on` blue & bold), ("list" <> "balance" <> "positive" <> "selected", white `on` blue & bold),
("list" <> "balance" <> "negative" <> "selected", brightRed `on` blue & bold) ("list" <> "balance" <> "negative" <> "selected", brightRed `on` blue & bold),
("error", currentAttr `withForeColor` red)
]), ]),
("terminal", attrMap ("terminal", attrMap

View File

@ -54,38 +54,38 @@ helpDialog _copts =
Widget Fixed Fixed $ do Widget Fixed Fixed $ do
c <- getContext c <- getContext
render $ render $
withDefAttr borderAttr $ -- color help dialog like the borders withDefAttr "help" $
renderDialog (dialog (Just "Help (?/LEFT/ESC to close)") Nothing (c^.availWidthL)) $ -- (Just (0,[("ok",())])) renderDialog (dialog (Just "Help (?/LEFT/ESC to close)") Nothing (c^.availWidthL)) $ -- (Just (0,[("ok",())]))
padAll 1 $ padAll 1 $
vBox [ vBox [
hBox [ hBox [
padRight (Pad 1) $ padRight (Pad 1) $
vBox [ vBox [
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 more detail")
,renderKey ("LEFT ", "go back") ,renderKey ("LEFT ", "go back")
,renderKey ("ESC ", "cancel or reset") ,renderKey ("ESC ", "cancel or reset")
,str " " ,str " "
,str "Report period" ,withAttr ("help" <> "heading") $ str "Report period"
,renderKey ("S-DOWN /S-UP ", "shrink/grow period") ,renderKey ("S-DOWN /S-UP ", "shrink/grow period")
,renderKey ("S-RIGHT/S-LEFT", "next/previous period") ,renderKey ("S-RIGHT/S-LEFT", "next/previous period")
,renderKey ("t ", "set period to today") ,renderKey ("t ", "set period to today")
,str " " ,str " "
,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 ", "period change/historical end balance")
,str " " ,str " "
,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 period total/historical total")
,str " " ,str " "
] ]
,padLeft (Pad 1) $ padRight (Pad 0) $ ,padLeft (Pad 1) $ padRight (Pad 0) $
vBox [ vBox [
str "Filtering" withAttr ("help" <> "heading") $ str "Filtering"
,renderKey ("/ ", "set a filter query") ,renderKey ("/ ", "set a filter query")
,renderKey ("UPC ", "show unmarked/pending/cleared") ,renderKey ("UPC ", "show unmarked/pending/cleared")
,renderKey ("F ", "show future/present txns") ,renderKey ("F ", "show future/present txns")
@ -93,11 +93,11 @@ helpDialog _copts =
,renderKey ("Z ", "show nonzero/all amounts") ,renderKey ("Z ", "show nonzero/all amounts")
,renderKey ("DEL ", "remove filters") ,renderKey ("DEL ", "remove filters")
,str " " ,str " "
,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 help showing)\nshow manual in pager/man/info")
,str " " ,str " "
,str "Other" ,withAttr ("help" <> "heading") $ str "Other"
,renderKey ("a ", "add transaction (hledger add)") ,renderKey ("a ", "add transaction (hledger add)")
,renderKey ("A ", "add transaction (hledger-iadd)") ,renderKey ("A ", "add transaction (hledger-iadd)")
,renderKey ("E ", "open editor") ,renderKey ("E ", "open editor")
@ -122,7 +122,7 @@ helpDialog _copts =
-- ] -- ]
] ]
where where
renderKey (key,desc) = withAttr (borderAttr <> "keys") (str key) <+> str " " <+> str desc renderKey (key,desc) = withAttr ("help" <> "key") (str key) <+> str " " <+> str desc
-- | Event handler used when help mode is active. -- | Event handler used when help mode is active.
-- May invoke $PAGER, less, man or info, which is likely to fail on MS Windows, TODO. -- May invoke $PAGER, less, man or info, which is likely to fail on MS Windows, TODO.
@ -177,7 +177,7 @@ borderKeysStr' :: [(String,Widget Name)] -> Widget Name
borderKeysStr' keydescs = borderKeysStr' keydescs =
hBox $ hBox $
intersperse sep $ intersperse sep $
[withAttr (borderAttr <> "keys") (str keys) <+> str ":" <+> desc | (keys, desc) <- keydescs] [withAttr (borderAttr <> "key") (str keys) <+> str ":" <+> desc | (keys, desc) <- keydescs]
where where
-- sep = str " | " -- sep = str " | "
sep = str " " sep = str " "