packages feed

brick 0.37.2 → 0.38

raw patch · 3 files changed

+58/−27 lines, 3 filesdep ~vtyPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: vty

API changes (from Hackage documentation)

- Brick.BorderMap: eBottomL :: forall a_adTy. Lens' (Edges a_adTy) a_adTy
+ Brick.BorderMap: eBottomL :: forall a_aegN. Lens' (Edges a_aegN) a_aegN
- Brick.BorderMap: eLeftL :: forall a_adTy. Lens' (Edges a_adTy) a_adTy
+ Brick.BorderMap: eLeftL :: forall a_aegN. Lens' (Edges a_aegN) a_aegN
- Brick.BorderMap: eRightL :: forall a_adTy. Lens' (Edges a_adTy) a_adTy
+ Brick.BorderMap: eRightL :: forall a_aegN. Lens' (Edges a_aegN) a_aegN
- Brick.BorderMap: eTopL :: forall a_adTy. Lens' (Edges a_adTy) a_adTy
+ Brick.BorderMap: eTopL :: forall a_aegN. Lens' (Edges a_aegN) a_aegN
- Brick.Types: bordersL :: forall n_azTD. Lens' (Result n_azTD) (BorderMap DynBorder)
+ Brick.Types: bordersL :: forall n_aDRA. Lens' (Result n_aDRA) (BorderMap DynBorder)
- Brick.Types: cursorLocationL :: forall n_azjA. Lens' (CursorLocation n_azjA) Location
+ Brick.Types: cursorLocationL :: forall n_aDgx. Lens' (CursorLocation n_aDgx) Location
- Brick.Types: cursorLocationNameL :: forall n_azjA n_aAfa. Lens (CursorLocation n_azjA) (CursorLocation n_aAfa) (Maybe n_azjA) (Maybe n_aAfa)
+ Brick.Types: cursorLocationNameL :: forall n_aDgx n_aEd7. Lens (CursorLocation n_aDgx) (CursorLocation n_aEd7) (Maybe n_aDgx) (Maybe n_aEd7)
- Brick.Types: cursorsL :: forall n_azTD. Lens' (Result n_azTD) [CursorLocation n_azTD]
+ Brick.Types: cursorsL :: forall n_aDRA. Lens' (Result n_aDRA) [CursorLocation n_aDRA]
- Brick.Types: eBottomL :: forall a_adTy. Lens' (Edges a_adTy) a_adTy
+ Brick.Types: eBottomL :: forall a_aegN. Lens' (Edges a_aegN) a_aegN
- Brick.Types: eLeftL :: forall a_adTy. Lens' (Edges a_adTy) a_adTy
+ Brick.Types: eLeftL :: forall a_aegN. Lens' (Edges a_aegN) a_aegN
- Brick.Types: eRightL :: forall a_adTy. Lens' (Edges a_adTy) a_adTy
+ Brick.Types: eRightL :: forall a_aegN. Lens' (Edges a_aegN) a_aegN
- Brick.Types: eTopL :: forall a_adTy. Lens' (Edges a_adTy) a_adTy
+ Brick.Types: eTopL :: forall a_aegN. Lens' (Edges a_aegN) a_aegN
- Brick.Types: extentsL :: forall n_azTD. Lens' (Result n_azTD) [Extent n_azTD]
+ Brick.Types: extentsL :: forall n_aDRA. Lens' (Result n_aDRA) [Extent n_aDRA]
- Brick.Types: imageL :: forall n_azTD. Lens' (Result n_azTD) Image
+ Brick.Types: imageL :: forall n_aDRA. Lens' (Result n_aDRA) Image
- Brick.Types: visibilityRequestsL :: forall n_azTD. Lens' (Result n_azTD) [VisibilityRequest]
+ Brick.Types: visibilityRequestsL :: forall n_aDRA. Lens' (Result n_aDRA) [VisibilityRequest]
- Brick.Widgets.Dialog: dialogButtonsL :: forall a_a11Lj a_a11M0. Lens (Dialog a_a11Lj) (Dialog a_a11M0) [(String, a_a11Lj)] [(String, a_a11M0)]
+ Brick.Widgets.Dialog: dialogButtonsL :: forall a_a1788 a_a178P. Lens (Dialog a_a1788) (Dialog a_a178P) [(String, a_a1788)] [(String, a_a178P)]
- Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a11Lj. Lens' (Dialog a_a11Lj) (Maybe Int)
+ Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a1788. Lens' (Dialog a_a1788) (Maybe Int)
- Brick.Widgets.Dialog: dialogTitleL :: forall a_a11Lj. Lens' (Dialog a_a11Lj) (Maybe String)
+ Brick.Widgets.Dialog: dialogTitleL :: forall a_a1788. Lens' (Dialog a_a1788) (Maybe String)
- Brick.Widgets.Dialog: dialogWidthL :: forall a_a11Lj. Lens' (Dialog a_a11Lj) Int
+ Brick.Widgets.Dialog: dialogWidthL :: forall a_a1788. Lens' (Dialog a_a1788) Int
- Brick.Widgets.Edit: editContentsL :: forall t_aXok n_aXol t_aXp4. Lens (Editor t_aXok n_aXol) (Editor t_aXp4 n_aXol) (TextZipper t_aXok) (TextZipper t_aXp4)
+ Brick.Widgets.Edit: editContentsL :: forall t_a12uU n_a12uV t_a12vE. Lens (Editor t_a12uU n_a12uV) (Editor t_a12vE n_a12uV) (TextZipper t_a12uU) (TextZipper t_a12vE)
- Brick.Widgets.List: listElementsL :: forall n_a16i5 e_a16i6 e_a16rN. Lens (List n_a16i5 e_a16i6) (List n_a16i5 e_a16rN) (Vector e_a16i6) (Vector e_a16rN)
+ Brick.Widgets.List: listElementsL :: forall n_a1cbQ e_a1cbR e_a1cly. Lens (List n_a1cbQ e_a1cbR) (List n_a1cbQ e_a1cly) (Vector e_a1cbR) (Vector e_a1cly)
- Brick.Widgets.List: listItemHeightL :: forall n_a16i5 e_a16i6. Lens' (List n_a16i5 e_a16i6) Int
+ Brick.Widgets.List: listItemHeightL :: forall n_a1cbQ e_a1cbR. Lens' (List n_a1cbQ e_a1cbR) Int
- Brick.Widgets.List: listNameL :: forall n_a16i5 e_a16i6 n_a16rO. Lens (List n_a16i5 e_a16i6) (List n_a16rO e_a16i6) n_a16i5 n_a16rO
+ Brick.Widgets.List: listNameL :: forall n_a1cbQ e_a1cbR n_a1clz. Lens (List n_a1cbQ e_a1cbR) (List n_a1clz e_a1cbR) n_a1cbQ n_a1clz
- Brick.Widgets.List: listSelectedL :: forall n_a16i5 e_a16i6. Lens' (List n_a16i5 e_a16i6) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: forall n_a1cbQ e_a1cbR. Lens' (List n_a1cbQ e_a1cbR) (Maybe Int)

Files

CHANGELOG.md view
@@ -2,6 +2,15 @@ Brick changelog --------------- +0.38+----++New features:+ * Added support for parsing `#RRGGBB` color values in theme+   customization files in addition to the color names already supported+   (thanks Brent Carmer). These values are mapped to the nearest+   reasonable entry in the 240-color space.+ 0.37.2 ------ 
brick.cabal view
@@ -1,5 +1,5 @@ name:                brick-version:             0.37.2+version:             0.38 synopsis:            A declarative terminal user interface library description:   Write terminal applications painlessly with 'brick'! You write an@@ -87,7 +87,7 @@     Brick.Widgets.Internal    build-depends:       base <= 4.11.1.0,-                       vty >= 5.18.1,+                       vty >= 5.22,                        transformers,                        data-clist >= 0.1,                        dlist,@@ -157,7 +157,7 @@   main-is:             CacheDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens >= 0.3.0.0,                        microlens-th@@ -171,7 +171,7 @@   main-is:             VisibilityDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens >= 0.3.0.0,                        microlens-th@@ -186,7 +186,7 @@   main-is:             ViewportScrollDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens @@ -199,7 +199,7 @@   main-is:             DialogDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens @@ -212,7 +212,7 @@   main-is:             MouseDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens >= 0.3.0.0,                        microlens-th,@@ -227,7 +227,7 @@   main-is:             LayerDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens >= 0.3.0.0,                        microlens-th@@ -241,7 +241,7 @@   main-is:             SuspendAndResumeDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens >= 0.3.0.0,                        microlens-th@@ -255,7 +255,7 @@   main-is:             PaddingDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens @@ -268,7 +268,7 @@   main-is:             ThemeDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens @@ -281,7 +281,7 @@   main-is:             AttrDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens @@ -294,7 +294,7 @@   main-is:             MarkupDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens @@ -307,7 +307,7 @@   main-is:             ListDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens >= 0.3.0.0,                        vector@@ -321,7 +321,7 @@   main-is:             ListViDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens >= 0.3.0.0,                        vector@@ -335,7 +335,7 @@   main-is:             CustomEventDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens >= 0.3.0.0,                        microlens-th@@ -349,7 +349,7 @@   main-is:             FillDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens @@ -362,7 +362,7 @@   main-is:             HelloWorldDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens @@ -375,7 +375,7 @@   main-is:             EditDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        vector,                        microlens >= 0.3.0.0,@@ -391,7 +391,7 @@   main-is:             BorderDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens @@ -405,7 +405,7 @@   main-is:             DynamicBorderDemo.hs   build-depends:       base <= 5,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens @@ -419,7 +419,7 @@   main-is:             ProgressBarDemo.hs   build-depends:       base,                        brick,-                       vty >= 5.18.1,+                       vty >= 5.22,                        text,                        microlens 
src/Brick/Themes.hs view
@@ -21,6 +21,10 @@ -- @brightRed@, @brightGreen@, @brightYellow@, @brightBlue@, -- @brightMagenta@, @brightCyan@, @brightWhite@, or @default@. --+-- We also support color specifications in the common hex format @#RRGGBB@, but+-- note that this specification is lossy: terminals can only display 256 colors,+-- but hex codes can specify @256^3 = 16777216@ colors.+-- -- A style specification can be either one of the following values -- (without quotes) or a comma-delimited list of one or more of the -- following values (e.g. @"[bold,underline]"@) indicating that all@@ -75,13 +79,14 @@ import Control.Monad (forM, join) import Control.Applicative ((<|>)) import qualified Data.Text as T+import qualified Data.Text.Read as T import qualified Data.Text.IO as T import qualified Data.Map as M import qualified Data.Semigroup as Sem import Data.Tuple (swap) import Data.List (intercalate) import Data.Bits ((.|.), (.&.))-import Data.Maybe (fromMaybe, isNothing, catMaybes)+import Data.Maybe (fromMaybe, isNothing, catMaybes, mapMaybe) import Data.Monoid ((<>)) import qualified Data.Foldable as F @@ -90,6 +95,8 @@ import Brick.AttrMap (AttrMap, AttrName, attrMap, attrNameComponents) import Brick.Types.TH (suffixLenses) +import Text.Printf+ -- | An attribute customization can specify which aspects of an -- attribute to customize. data CustomAttr =@@ -194,15 +201,28 @@     isNothing (customBg c) &&     isNothing (customStyle c) +-- |  This function is lossy in the sense that we only internally support 240 colors but+-- the #RRGGBB format supports 16^3 colors. parseColor :: T.Text -> Either String (MaybeDefault Color) parseColor s =     let stripped = T.strip $ T.toLower s         normalize (t, c) = (T.toLower t, c)     in if stripped == "default"-       then Right Default-       else maybe (Left $ "Invalid color: " <> show stripped) (Right . SetTo) $-                  lookup stripped (normalize <$> swap <$> allColors)+          then Right Default+          else case parseRGB stripped of+              Just c  -> Right (SetTo c)+              Nothing -> maybe (Left $ "Invalid color: " <> show stripped) (Right . SetTo) $+                             lookup stripped (normalize <$> swap <$> allColors)+  where+    parseRGB t = if T.head t /= '#'+                    then Nothing+                    else case mapMaybe readHex (T.chunksOf 2 (T.tail t)) of+                            [r,g,b] -> Just (rgbColor r g b)+                            _ -> Nothing +    readHex :: T.Text -> Maybe Int+    readHex t = either (const Nothing) (Just . fst) (T.hexadecimal t)+ allColors :: [(Color, T.Text)] allColors =     [ (black, "black")@@ -309,7 +329,9 @@             return $ Right $ applyCustomizations customDef (flip M.lookup customMap) t  vtyColorName :: Color -> T.Text-vtyColorName (Color240 _) = error "Color240 space not supported yet"+vtyColorName c@(Color240 n) = case color240CodeToRGB (fromIntegral n) of+    Just (r,g,b) -> T.pack (printf "#%02x%02x%02x" r g b)+    Nothing -> (error $ "Invalid color: " <> show c) vtyColorName c =     fromMaybe (error $ "Invalid color: " <> show c)               (lookup c allColors)