ui: use "border" instead of borderAttr everywhere

Assume it won't change, it's clearer and more consistent.
This commit is contained in:
Simon Michael 2018-10-23 06:43:21 -07:00
parent 5bc82e9536
commit 42a4a4a7e4
5 changed files with 21 additions and 24 deletions

View File

@ -14,7 +14,6 @@ where
import Brick
import Brick.Widgets.List
import Brick.Widgets.Edit
import Brick.Widgets.Border (borderAttr)
import Control.Monad
import Control.Monad.IO.Class (liftIO)
import Data.List
@ -174,7 +173,7 @@ asDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
toplabel =
files
-- <+> withAttr (borderAttr <> "query") (str (if flat_ ropts then " flat" else ""))
-- <+> withAttr ("border" <> "query") (str (if flat_ ropts then " flat" else ""))
<+> nonzero
<+> str (if ishistorical then " accounts" else " account changes")
-- <+> str (if ishistorical then " balances" else " changes")
@ -188,7 +187,7 @@ asDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
<+> total
<+> str ")"
<+> (if ignore_assertions_ $ inputopts_ copts
then withAttr (borderAttr <> "query") (str " ignoring balance assertions")
then withAttr ("border" <> "query") (str " ignoring balance assertions")
else str "")
where
files = case journalFilePaths j of
@ -204,9 +203,9 @@ asDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
,if real_ ropts then ["real"] else []
] of
[] -> str ""
fs -> str " from " <+> withAttr (borderAttr <> "query") (str $ intercalate ", " fs) <+> str " txns"
fs -> str " from " <+> withAttr ("border" <> "query") (str $ intercalate ", " fs) <+> str " txns"
nonzero | empty_ ropts = str ""
| otherwise = withAttr (borderAttr <> "query") (str " nonzero")
| otherwise = withAttr ("border" <> "query") (str " nonzero")
cur = str (case _asList s ^. listSelectedL of
Nothing -> "-"
Just i -> show (i + 1))
@ -217,7 +216,7 @@ asDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
Minibuffer ed -> minibuffer ed
_ -> quickhelp
where
selectedstr = withAttr (borderAttr <> "selected") . str
selectedstr = withAttr ("border" <> "selected") . str
quickhelp = borderKeysStr' [
("?", str "help")
,("RIGHT", str "register")

View File

@ -12,7 +12,7 @@ module Hledger.UI.ErrorScreen
where
import Brick
-- import Brick.Widgets.Border (borderAttr)
-- import Brick.Widgets.Border ("border")
import Control.Monad
import Control.Monad.IO.Class (liftIO)
#if !(MIN_VERSION_base(4,11,0))
@ -57,7 +57,7 @@ esDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{}}
where
toplabel =
withAttr ("border" <> "bold") (str "Oops. Please fix this problem then press g to reload")
-- <+> (if ignore_assertions_ copts then withAttr (borderAttr <> "query") (str " ignoring") else str " not ignoring")
-- <+> (if ignore_assertions_ copts then withAttr ("border" <> "query") (str " ignoring") else str " not ignoring")
bottomlabel = case mode of
-- Minibuffer ed -> minibuffer ed

View File

@ -26,7 +26,6 @@ import Graphics.Vty (Event(..),Key(..),Modifier(..))
import Brick
import Brick.Widgets.List
import Brick.Widgets.Edit
import Brick.Widgets.Border (borderAttr)
import Lens.Micro.Platform
import Safe
import System.Console.ANSI
@ -192,7 +191,7 @@ rsDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
toplabel =
withAttr ("border" <> "bold") (str $ T.unpack $ replaceHiddenAccountsNameWith "All" rsAccount)
-- <+> withAttr (borderAttr <> "query") (str $ if inclusive then "" else " exclusive")
-- <+> withAttr ("border" <> "query") (str $ if inclusive then "" else " exclusive")
<+> togglefilters
<+> str " transactions"
-- <+> str (if ishistorical then " historical total" else " period total")
@ -204,7 +203,7 @@ rsDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
<+> str "/"
<+> total
<+> str ")"
<+> (if ignore_assertions_ $ inputopts_ copts then withAttr (borderAttr <> "query") (str " ignoring balance assertions") else str "")
<+> (if ignore_assertions_ $ inputopts_ copts then withAttr ("border" <> "query") (str " ignoring balance assertions") else str "")
where
togglefilters =
case concat [
@ -213,7 +212,7 @@ rsDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
,if empty_ ropts then [] else ["nonzero"]
] of
[] -> str ""
fs -> withAttr (borderAttr <> "query") (str $ " " ++ intercalate ", " fs)
fs -> withAttr ("border" <> "query") (str $ " " ++ intercalate ", " fs)
cur = str $ case rsList ^. listSelectedL of
Nothing -> "-"
Just i -> show (i + 1)
@ -226,7 +225,7 @@ rsDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
Minibuffer ed -> minibuffer ed
_ -> quickhelp
where
selectedstr = withAttr (borderAttr <> "query") . str
selectedstr = withAttr ("border" <> "query") . str
quickhelp = borderKeysStr' [
("?", str "help")
,("LEFT", str "back")

View File

@ -20,7 +20,6 @@ import Data.Time.Calendar (Day)
import Graphics.Vty (Event(..),Key(..))
import Brick
import Brick.Widgets.List (listMoveTo)
import Brick.Widgets.Border (borderAttr)
import Hledger
import Hledger.Cli hiding (progname,prognameandversion)
@ -77,7 +76,7 @@ tsDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
<+> togglefilters
<+> borderQueryStr (query_ ropts)
<+> str (" in "++T.unpack (replaceHiddenAccountsNameWith "All" acct)++")")
<+> (if ignore_assertions_ $ inputopts_ copts then withAttr (borderAttr <> "query") (str " ignoring balance assertions") else str "")
<+> (if ignore_assertions_ $ inputopts_ copts then withAttr ("border" <> "query") (str " ignoring balance assertions") else str "")
where
togglefilters =
case concat [
@ -86,7 +85,7 @@ tsDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}}
,if empty_ ropts then [] else ["nonzero"]
] of
[] -> str ""
fs -> withAttr (borderAttr <> "query") (str $ " " ++ intercalate ", " fs)
fs -> withAttr ("border" <> "query") (str $ " " ++ intercalate ", " fs)
bottomlabel = case mode of
-- Minibuffer ed -> minibuffer ed

View File

@ -141,7 +141,7 @@ helpHandle ui ev = do
-- | Draw the minibuffer.
minibuffer :: Editor String Name -> Widget Name
minibuffer ed =
forceAttr (borderAttr <> "minibuffer") $
forceAttr ("border" <> "minibuffer") $
hBox $
#if MIN_VERSION_brick(0,19,0)
[txt "filter: ", renderEditor (str . unlines) True ed]
@ -160,15 +160,15 @@ defaultLayout toplabel bottomlabel =
borderQueryStr :: String -> Widget Name
borderQueryStr "" = str ""
borderQueryStr qry = str " matching " <+> withAttr (borderAttr <> "query") (str qry)
borderQueryStr qry = str " matching " <+> withAttr ("border" <> "query") (str qry)
borderDepthStr :: Maybe Int -> Widget Name
borderDepthStr Nothing = str ""
borderDepthStr (Just d) = str " to " <+> withAttr (borderAttr <> "query") (str $ "depth "++show d)
borderDepthStr (Just d) = str " to " <+> withAttr ("border" <> "query") (str $ "depth "++show d)
borderPeriodStr :: String -> Period -> Widget Name
borderPeriodStr _ PeriodAll = str ""
borderPeriodStr preposition p = str (" "++preposition++" ") <+> withAttr (borderAttr <> "query") (str $ showPeriod p)
borderPeriodStr preposition p = str (" "++preposition++" ") <+> withAttr ("border" <> "query") (str $ showPeriod p)
borderKeysStr :: [(String,String)] -> Widget Name
borderKeysStr = borderKeysStr' . map (\(a,b) -> (a, str b))
@ -177,7 +177,7 @@ borderKeysStr' :: [(String,Widget Name)] -> Widget Name
borderKeysStr' keydescs =
hBox $
intersperse sep $
[withAttr (borderAttr <> "key") (str keys) <+> str ":" <+> desc | (keys, desc) <- keydescs]
[withAttr ("border" <> "key") (str keys) <+> str ":" <+> desc | (keys, desc) <- keydescs]
where
-- sep = str " | "
sep = str " "
@ -222,11 +222,11 @@ topBottomBorderWithLabels toplabel bottomlabel body =
""
-- " debug: "++show (_w,h')
render $
hBorderWithLabel (withAttr borderAttr $ toplabel <+> str debugmsg)
hBorderWithLabel (withAttr "border" $ toplabel <+> str debugmsg)
<=>
body'
<=>
hBorderWithLabel (withAttr borderAttr bottomlabel)
hBorderWithLabel (withAttr "border" bottomlabel)
---- XXX should be equivalent to the above, but isn't (page down goes offscreen)
--_topBottomBorderWithLabel2 :: Widget Name -> Widget Name -> Widget Name
@ -264,7 +264,7 @@ margin h v mcolour = \w ->
-- applyN n border
withBorderAttr :: Attr -> Widget Name -> Widget Name
withBorderAttr attr = updateAttrMap (applyAttrMappings [(borderAttr, attr)])
withBorderAttr attr = updateAttrMap (applyAttrMappings [("border", attr)])
---- | Like brick's continue, but first run some action to modify brick's state.
---- This action does not affect the app state, but might eg adjust a widget's scroll position.