imp: cli: pick help accent color to contrast with terminal bg when possible

This commit is contained in:
Simon Michael 2023-01-26 00:31:10 -10:00
parent 1da4fd1eaf
commit 9c7144e939

View File

@ -121,8 +121,6 @@ builtinCommands = [
,(testmode , testcmd)
]
accent = blue
-- figlet -f FONTNAME hledger, then escape backslashes
_banner_slant = drop 1 [""
-----------------------------------------80-------------------------------------
@ -134,7 +132,7 @@ _banner_slant = drop 1 [""
," /____/ "
]
_banner_smslant = map accent $ drop 1 [""
_banner_smslant = drop 1 [""
," __ __ __ "
," / / / /__ ___/ /__ ____ ____"
," / _ \\/ / -_) _ / _ `/ -_) __/"
@ -151,6 +149,11 @@ _banner_speed = drop 1 [""
," /____/ "
]
-- | Choose and apply an accent color for hledger output, if possible
-- picking one that will contrast with the current terminal background colour.
accent :: String -> String
accent = if terminalIsLight == Just False then yellow else blue
highlightAddon = id
-- | The commands list, showing command names, standard aliases,
@ -174,7 +177,7 @@ highlightAddon = id
commandsList :: String -> [String] -> Bool -> [String]
commandsList progversion othercmds highlight =
(if highlight then (map (\s -> if "+" `isPrefixOf` s then highlightAddon (' ' : drop 1 s) else s)) else id) $
_banner_smslant ++ [
map accent _banner_smslant ++ [
-- keep synced with hledger.m4.md > PART 4: COMMANDS, Hledger/Cli/Commands > commands.m4 -->
-----------------------------------------80-------------------------------------
""