ui: use "border" instead of borderAttr everywhere
Assume it won't change, it's clearer and more consistent.
This commit is contained in:
		
							parent
							
								
									5bc82e9536
								
							
						
					
					
						commit
						42a4a4a7e4
					
				| @ -14,7 +14,6 @@ where | |||||||
| import Brick | import Brick | ||||||
| import Brick.Widgets.List | import Brick.Widgets.List | ||||||
| import Brick.Widgets.Edit | import Brick.Widgets.Edit | ||||||
| import Brick.Widgets.Border (borderAttr) |  | ||||||
| import Control.Monad | import Control.Monad | ||||||
| import Control.Monad.IO.Class (liftIO) | import Control.Monad.IO.Class (liftIO) | ||||||
| import Data.List | import Data.List | ||||||
| @ -174,7 +173,7 @@ asDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} | |||||||
| 
 | 
 | ||||||
|         toplabel = |         toplabel = | ||||||
|               files |               files | ||||||
|           -- <+> withAttr (borderAttr <> "query") (str (if flat_ ropts then " flat" else "")) |           -- <+> withAttr ("border" <> "query") (str (if flat_ ropts then " flat" else "")) | ||||||
|           <+> nonzero |           <+> nonzero | ||||||
|           <+> str (if ishistorical then " accounts" else " account changes") |           <+> str (if ishistorical then " accounts" else " account changes") | ||||||
|           -- <+> str (if ishistorical then " balances" else " changes") |           -- <+> str (if ishistorical then " balances" else " changes") | ||||||
| @ -188,7 +187,7 @@ asDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} | |||||||
|           <+> total |           <+> total | ||||||
|           <+> str ")" |           <+> str ")" | ||||||
|           <+> (if ignore_assertions_ $ inputopts_ copts |           <+> (if ignore_assertions_ $ inputopts_ copts | ||||||
|                then withAttr (borderAttr <> "query") (str " ignoring balance assertions") |                then withAttr ("border" <> "query") (str " ignoring balance assertions") | ||||||
|                else str "") |                else str "") | ||||||
|           where |           where | ||||||
|             files = case journalFilePaths j of |             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 [] |                   ,if real_ ropts then ["real"] else [] | ||||||
|                   ] of |                   ] of | ||||||
|                 [] -> str "" |                 [] -> 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 "" |             nonzero | empty_ ropts = str "" | ||||||
|                     | otherwise    = withAttr (borderAttr <> "query") (str " nonzero") |                     | otherwise    = withAttr ("border" <> "query") (str " nonzero") | ||||||
|             cur = str (case _asList s ^. listSelectedL of |             cur = str (case _asList s ^. listSelectedL of | ||||||
|                         Nothing -> "-" |                         Nothing -> "-" | ||||||
|                         Just i -> show (i + 1)) |                         Just i -> show (i + 1)) | ||||||
| @ -217,7 +216,7 @@ asDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} | |||||||
|                         Minibuffer ed -> minibuffer ed |                         Minibuffer ed -> minibuffer ed | ||||||
|                         _             -> quickhelp |                         _             -> quickhelp | ||||||
|           where |           where | ||||||
|             selectedstr = withAttr (borderAttr <> "selected") . str |             selectedstr = withAttr ("border" <> "selected") . str | ||||||
|             quickhelp = borderKeysStr' [ |             quickhelp = borderKeysStr' [ | ||||||
|                ("?", str "help") |                ("?", str "help") | ||||||
|               ,("RIGHT", str "register") |               ,("RIGHT", str "register") | ||||||
|  | |||||||
| @ -12,7 +12,7 @@ module Hledger.UI.ErrorScreen | |||||||
| where | where | ||||||
| 
 | 
 | ||||||
| import Brick | import Brick | ||||||
| -- import Brick.Widgets.Border (borderAttr) | -- import Brick.Widgets.Border ("border") | ||||||
| import Control.Monad | import Control.Monad | ||||||
| import Control.Monad.IO.Class (liftIO) | import Control.Monad.IO.Class (liftIO) | ||||||
| #if !(MIN_VERSION_base(4,11,0)) | #if !(MIN_VERSION_base(4,11,0)) | ||||||
| @ -57,7 +57,7 @@ esDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{}} | |||||||
|       where |       where | ||||||
|         toplabel = |         toplabel = | ||||||
|               withAttr ("border" <> "bold") (str "Oops. Please fix this problem then press g to reload") |               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 |         bottomlabel = case mode of | ||||||
|                         -- Minibuffer ed -> minibuffer ed |                         -- Minibuffer ed -> minibuffer ed | ||||||
|  | |||||||
| @ -26,7 +26,6 @@ import Graphics.Vty (Event(..),Key(..),Modifier(..)) | |||||||
| import Brick | import Brick | ||||||
| import Brick.Widgets.List | import Brick.Widgets.List | ||||||
| import Brick.Widgets.Edit | import Brick.Widgets.Edit | ||||||
| import Brick.Widgets.Border (borderAttr) |  | ||||||
| import Lens.Micro.Platform | import Lens.Micro.Platform | ||||||
| import Safe | import Safe | ||||||
| import System.Console.ANSI | import System.Console.ANSI | ||||||
| @ -192,7 +191,7 @@ rsDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} | |||||||
| 
 | 
 | ||||||
|         toplabel = |         toplabel = | ||||||
|               withAttr ("border" <> "bold") (str $ T.unpack $ replaceHiddenAccountsNameWith "All" rsAccount) |               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 |           <+> togglefilters | ||||||
|           <+> str " transactions" |           <+> str " transactions" | ||||||
|           -- <+> str (if ishistorical then " historical total" else " period total") |           -- <+> str (if ishistorical then " historical total" else " period total") | ||||||
| @ -204,7 +203,7 @@ rsDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} | |||||||
|           <+> str "/" |           <+> str "/" | ||||||
|           <+> total |           <+> total | ||||||
|           <+> str ")" |           <+> 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 |           where | ||||||
|             togglefilters = |             togglefilters = | ||||||
|               case concat [ |               case concat [ | ||||||
| @ -213,7 +212,7 @@ rsDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} | |||||||
|                   ,if empty_ ropts then [] else ["nonzero"] |                   ,if empty_ ropts then [] else ["nonzero"] | ||||||
|                   ] of |                   ] of | ||||||
|                 [] -> str "" |                 [] -> str "" | ||||||
|                 fs -> withAttr (borderAttr <> "query") (str $ " " ++ intercalate ", " fs) |                 fs -> withAttr ("border" <> "query") (str $ " " ++ intercalate ", " fs) | ||||||
|             cur = str $ case rsList ^. listSelectedL of |             cur = str $ case rsList ^. listSelectedL of | ||||||
|                          Nothing -> "-" |                          Nothing -> "-" | ||||||
|                          Just i -> show (i + 1) |                          Just i -> show (i + 1) | ||||||
| @ -226,7 +225,7 @@ rsDraw UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} | |||||||
|                         Minibuffer ed -> minibuffer ed |                         Minibuffer ed -> minibuffer ed | ||||||
|                         _             -> quickhelp |                         _             -> quickhelp | ||||||
|           where |           where | ||||||
|             selectedstr = withAttr (borderAttr <> "query") . str |             selectedstr = withAttr ("border" <> "query") . str | ||||||
|             quickhelp = borderKeysStr' [ |             quickhelp = borderKeysStr' [ | ||||||
|                ("?", str "help") |                ("?", str "help") | ||||||
|               ,("LEFT", str "back") |               ,("LEFT", str "back") | ||||||
|  | |||||||
| @ -20,7 +20,6 @@ import Data.Time.Calendar (Day) | |||||||
| import Graphics.Vty (Event(..),Key(..)) | import Graphics.Vty (Event(..),Key(..)) | ||||||
| import Brick | import Brick | ||||||
| import Brick.Widgets.List (listMoveTo) | import Brick.Widgets.List (listMoveTo) | ||||||
| import Brick.Widgets.Border (borderAttr) |  | ||||||
| 
 | 
 | ||||||
| import Hledger | import Hledger | ||||||
| import Hledger.Cli hiding (progname,prognameandversion) | import Hledger.Cli hiding (progname,prognameandversion) | ||||||
| @ -77,7 +76,7 @@ tsDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} | |||||||
|           <+> togglefilters |           <+> togglefilters | ||||||
|           <+> borderQueryStr (query_ ropts) |           <+> borderQueryStr (query_ ropts) | ||||||
|           <+> str (" in "++T.unpack (replaceHiddenAccountsNameWith "All" acct)++")") |           <+> 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 |           where | ||||||
|             togglefilters = |             togglefilters = | ||||||
|               case concat [ |               case concat [ | ||||||
| @ -86,7 +85,7 @@ tsDraw UIState{aopts=UIOpts{cliopts_=copts@CliOpts{reportopts_=ropts}} | |||||||
|                   ,if empty_ ropts then [] else ["nonzero"] |                   ,if empty_ ropts then [] else ["nonzero"] | ||||||
|                   ] of |                   ] of | ||||||
|                 [] -> str "" |                 [] -> str "" | ||||||
|                 fs -> withAttr (borderAttr <> "query") (str $ " " ++ intercalate ", " fs) |                 fs -> withAttr ("border" <> "query") (str $ " " ++ intercalate ", " fs) | ||||||
| 
 | 
 | ||||||
|         bottomlabel = case mode of |         bottomlabel = case mode of | ||||||
|                         -- Minibuffer ed -> minibuffer ed |                         -- Minibuffer ed -> minibuffer ed | ||||||
|  | |||||||
| @ -141,7 +141,7 @@ helpHandle ui ev = do | |||||||
| -- | Draw the minibuffer. | -- | Draw the minibuffer. | ||||||
| minibuffer :: Editor String Name -> Widget Name | minibuffer :: Editor String Name -> Widget Name | ||||||
| minibuffer ed = | minibuffer ed = | ||||||
|   forceAttr (borderAttr <> "minibuffer") $ |   forceAttr ("border" <> "minibuffer") $ | ||||||
|   hBox $ |   hBox $ | ||||||
| #if MIN_VERSION_brick(0,19,0) | #if MIN_VERSION_brick(0,19,0) | ||||||
|   [txt "filter: ", renderEditor (str . unlines) True ed] |   [txt "filter: ", renderEditor (str . unlines) True ed] | ||||||
| @ -160,15 +160,15 @@ defaultLayout toplabel bottomlabel = | |||||||
| 
 | 
 | ||||||
| borderQueryStr :: String -> Widget Name | borderQueryStr :: String -> Widget Name | ||||||
| borderQueryStr ""  = str "" | 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 :: Maybe Int -> Widget Name | ||||||
| borderDepthStr Nothing  = str "" | 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 :: String -> Period -> Widget Name | ||||||
| borderPeriodStr _           PeriodAll = str "" | 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 :: [(String,String)] -> Widget Name | ||||||
| borderKeysStr = borderKeysStr' . map (\(a,b) -> (a, str b)) | borderKeysStr = borderKeysStr' . map (\(a,b) -> (a, str b)) | ||||||
| @ -177,7 +177,7 @@ borderKeysStr' :: [(String,Widget Name)] -> Widget Name | |||||||
| borderKeysStr' keydescs = | borderKeysStr' keydescs = | ||||||
|   hBox $ |   hBox $ | ||||||
|   intersperse sep $ |   intersperse sep $ | ||||||
|   [withAttr (borderAttr <> "key") (str keys) <+> str ":" <+> desc | (keys, desc) <- keydescs] |   [withAttr ("border" <> "key") (str keys) <+> str ":" <+> desc | (keys, desc) <- keydescs] | ||||||
|   where |   where | ||||||
|     -- sep = str " | " |     -- sep = str " | " | ||||||
|     sep = str " " |     sep = str " " | ||||||
| @ -222,11 +222,11 @@ topBottomBorderWithLabels toplabel bottomlabel body = | |||||||
|           "" |           "" | ||||||
|           -- "  debug: "++show (_w,h') |           -- "  debug: "++show (_w,h') | ||||||
|     render $ |     render $ | ||||||
|       hBorderWithLabel (withAttr borderAttr $ toplabel <+> str debugmsg) |       hBorderWithLabel (withAttr "border" $ toplabel <+> str debugmsg) | ||||||
|       <=> |       <=> | ||||||
|       body' |       body' | ||||||
|       <=> |       <=> | ||||||
|       hBorderWithLabel (withAttr borderAttr bottomlabel) |       hBorderWithLabel (withAttr "border" bottomlabel) | ||||||
| 
 | 
 | ||||||
| ---- XXX should be equivalent to the above, but isn't (page down goes offscreen) | ---- XXX should be equivalent to the above, but isn't (page down goes offscreen) | ||||||
| --_topBottomBorderWithLabel2 :: Widget Name -> Widget Name -> Widget Name | --_topBottomBorderWithLabel2 :: Widget Name -> Widget Name -> Widget Name | ||||||
| @ -264,7 +264,7 @@ margin h v mcolour = \w -> | |||||||
|    -- applyN n border |    -- applyN n border | ||||||
| 
 | 
 | ||||||
| withBorderAttr :: Attr -> Widget Name -> Widget Name | 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. | ---- | 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. | ---- This action does not affect the app state, but might eg adjust a widget's scroll position. | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user