packages feed

brick 0.27 → 0.28

raw patch · 5 files changed

+41/−7 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Brick.AttrMap: setDefault :: Attr -> AttrMap -> AttrMap
+ Brick.AttrMap: getDefaultAttr :: AttrMap -> Attr
+ Brick.AttrMap: setDefaultAttr :: Attr -> AttrMap -> AttrMap
+ Brick.Widgets.Core: modifyDefAttr :: (Attr -> Attr) -> Widget n -> Widget n
- Brick.Types: cursorLocationL :: forall n_aqmN. Lens' (CursorLocation n_aqmN) Location
+ Brick.Types: cursorLocationL :: forall n_aqoO. Lens' (CursorLocation n_aqoO) Location
- Brick.Types: cursorLocationNameL :: forall n_aqmN n_aqQD. Lens (CursorLocation n_aqmN) (CursorLocation n_aqQD) (Maybe n_aqmN) (Maybe n_aqQD)
+ Brick.Types: cursorLocationNameL :: forall n_aqoO n_aqSE. Lens (CursorLocation n_aqoO) (CursorLocation n_aqSE) (Maybe n_aqoO) (Maybe n_aqSE)
- Brick.Types: cursorsL :: forall n_aqlI. Lens' (Result n_aqlI) [CursorLocation n_aqlI]
+ Brick.Types: cursorsL :: forall n_aqnJ. Lens' (Result n_aqnJ) [CursorLocation n_aqnJ]
- Brick.Types: extentsL :: forall n_aqlI. Lens' (Result n_aqlI) [Extent n_aqlI]
+ Brick.Types: extentsL :: forall n_aqnJ. Lens' (Result n_aqnJ) [Extent n_aqnJ]
- Brick.Types: imageL :: forall n_aqlI. Lens' (Result n_aqlI) Image
+ Brick.Types: imageL :: forall n_aqnJ. Lens' (Result n_aqnJ) Image
- Brick.Types: visibilityRequestsL :: forall n_aqlI. Lens' (Result n_aqlI) [VisibilityRequest]
+ Brick.Types: visibilityRequestsL :: forall n_aqnJ. Lens' (Result n_aqnJ) [VisibilityRequest]
- Brick.Widgets.Dialog: dialogButtonsL :: forall a_a14Q2 a_a14QC. Lens (Dialog a_a14Q2) (Dialog a_a14QC) [(String, a_a14Q2)] [(String, a_a14QC)]
+ Brick.Widgets.Dialog: dialogButtonsL :: forall a_a1529 a_a152J. Lens (Dialog a_a1529) (Dialog a_a152J) [(String, a_a1529)] [(String, a_a152J)]
- Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a14Q2. Lens' (Dialog a_a14Q2) (Maybe Int)
+ Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a1529. Lens' (Dialog a_a1529) (Maybe Int)
- Brick.Widgets.Dialog: dialogTitleL :: forall a_a14Q2. Lens' (Dialog a_a14Q2) (Maybe String)
+ Brick.Widgets.Dialog: dialogTitleL :: forall a_a1529. Lens' (Dialog a_a1529) (Maybe String)
- Brick.Widgets.Dialog: dialogWidthL :: forall a_a14Q2. Lens' (Dialog a_a14Q2) Int
+ Brick.Widgets.Dialog: dialogWidthL :: forall a_a1529. Lens' (Dialog a_a1529) Int
- Brick.Widgets.Edit: editContentsL :: forall t_a16Bc n_a16Bd t_a16BO. Lens (Editor t_a16Bc n_a16Bd) (Editor t_a16BO n_a16Bd) (TextZipper t_a16Bc) (TextZipper t_a16BO)
+ Brick.Widgets.Edit: editContentsL :: forall t_a16Nj n_a16Nk t_a16NV. Lens (Editor t_a16Nj n_a16Nk) (Editor t_a16NV n_a16Nk) (TextZipper t_a16Nj) (TextZipper t_a16NV)
- Brick.Widgets.List: listElementsL :: forall n_a18p8 e_a18p9 e_a18zn. Lens (List n_a18p8 e_a18p9) (List n_a18p8 e_a18zn) (Vector e_a18p9) (Vector e_a18zn)
+ Brick.Widgets.List: listElementsL :: forall n_a18Bf e_a18Bg e_a18Lu. Lens (List n_a18Bf e_a18Bg) (List n_a18Bf e_a18Lu) (Vector e_a18Bg) (Vector e_a18Lu)
- Brick.Widgets.List: listItemHeightL :: forall n_a18p8 e_a18p9. Lens' (List n_a18p8 e_a18p9) Int
+ Brick.Widgets.List: listItemHeightL :: forall n_a18Bf e_a18Bg. Lens' (List n_a18Bf e_a18Bg) Int
- Brick.Widgets.List: listNameL :: forall n_a18p8 e_a18p9 n_a18zo. Lens (List n_a18p8 e_a18p9) (List n_a18zo e_a18p9) n_a18p8 n_a18zo
+ Brick.Widgets.List: listNameL :: forall n_a18Bf e_a18Bg n_a18Lv. Lens (List n_a18Bf e_a18Bg) (List n_a18Lv e_a18Bg) n_a18Bf n_a18Lv
- Brick.Widgets.List: listSelectedL :: forall n_a18p8 e_a18p9. Lens' (List n_a18p8 e_a18p9) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: forall n_a18Bf e_a18Bg. Lens' (List n_a18Bf e_a18Bg) (Maybe Int)

Files

CHANGELOG.md view
@@ -2,6 +2,19 @@ Brick changelog --------------- +0.28+----++API changes:+ * Brick.AttrMap.setDefault was renamed to setDefaultAttr.+ * Added Brick.AttrMap.getDefaultAttr: get the default attribute from an+   attribute map.+ * Added Brick.Widgets.Core.modifyDefAttr to modify the default+   attribute of the rendering context.++Other changes:+ * Updated AttrDemo to show usage of modifyDefAttr.+ 0.27 ---- 
brick.cabal view
@@ -1,5 +1,5 @@ name:                brick-version:             0.27+version:             0.28 synopsis:            A declarative terminal user interface library description:   Write terminal applications painlessly with 'brick'! You write an
programs/AttrDemo.hs view
@@ -17,6 +17,7 @@   , vBox   , str   , hyperlink+  , modifyDefAttr   ) import Brick.Util (on, fg) import Brick.AttrMap (attrMap, AttrMap)@@ -45,6 +46,9 @@          , str " "          , hyperlink "http://www.google.com/" $            str "This text is also hyperlinked in terminals that support hyperlinking."+         , str " "+         , modifyDefAttr (`withURL` "http://www.google.com/") $+           str "This text is hyperlinked by modifying the default attribute."          ]  globalDefault :: Attr
src/Brick/AttrMap.hs view
@@ -32,7 +32,8 @@   -- * Finding attributes from names   , attrMapLookup   -- * Manipulating attribute maps-  , setDefault+  , setDefaultAttr+  , getDefaultAttr   , applyAttrMappings   , mergeWithDefault   , mapAttrName@@ -145,9 +146,14 @@     in foldl combineAttrs theDefault results  -- | Set the default attribute value in an attribute map.-setDefault :: Attr -> AttrMap -> AttrMap-setDefault _ (ForceAttr a) = ForceAttr a-setDefault newDefault (AttrMap _ m) = AttrMap newDefault m+setDefaultAttr :: Attr -> AttrMap -> AttrMap+setDefaultAttr _ (ForceAttr a) = ForceAttr a+setDefaultAttr newDefault (AttrMap _ m) = AttrMap newDefault m++-- | Get the default attribute value in an attribute map.+getDefaultAttr :: AttrMap -> Attr+getDefaultAttr (ForceAttr a) = a+getDefaultAttr (AttrMap d _) = d  combineAttrs :: Attr -> Attr -> Attr combineAttrs (Attr s1 f1 b1 u1) (Attr s2 f2 b2 u2) =
src/Brick/Widgets/Core.hs view
@@ -42,6 +42,7 @@    -- * Attribute management   , withDefAttr+  , modifyDefAttr   , withAttr   , forceAttr   , overrideAttr@@ -274,7 +275,7 @@     Widget (hSize p) (vSize p) $ do         c <- getContext         let attr = attrMapLookup (c^.ctxAttrNameL) (c^.ctxAttrMapL) `V.withURL` url-        withReaderT (& ctxAttrMapL %~ setDefault attr) (render p)+        withReaderT (& ctxAttrMapL %~ setDefaultAttr attr) (render p)  -- | Pad the specified widget on the left. If max padding is used, this -- grows greedily horizontally; otherwise it defers to the padded@@ -588,12 +589,22 @@  -- | Update the attribute map while rendering the specified widget: set -- its new default attribute to the one that we get by looking up the+-- specified attribute name in the map and then modifying it with the+-- specified function.+modifyDefAttr :: (V.Attr -> V.Attr) -> Widget n -> Widget n+modifyDefAttr f p =+    Widget (hSize p) (vSize p) $ do+        c <- getContext+        withReaderT (& ctxAttrMapL %~ (setDefaultAttr (f $ getDefaultAttr (c^.ctxAttrMapL)))) (render p)++-- | Update the attribute map while rendering the specified widget: set+-- its new default attribute to the one that we get by looking up the -- specified attribute name in the map. withDefAttr :: AttrName -> Widget n -> Widget n withDefAttr an p =     Widget (hSize p) (vSize p) $ do         c <- getContext-        withReaderT (& ctxAttrMapL %~ (setDefault (attrMapLookup an (c^.ctxAttrMapL)))) (render p)+        withReaderT (& ctxAttrMapL %~ (setDefaultAttr (attrMapLookup an (c^.ctxAttrMapL)))) (render p)  -- | When rendering the specified widget, update the attribute map with -- the specified transformation.