packages feed

brick 0.3.1 → 0.4

raw patch · 6 files changed

+55/−6 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Brick.Widgets.Core: unsafeLookupViewport :: Name -> RenderM (Maybe Viewport)
+ Brick.Widgets.List: instance Data.Foldable.Foldable Brick.Widgets.List.List
+ Brick.Widgets.List: instance Data.Traversable.Traversable Brick.Widgets.List.List
+ Brick.Widgets.List: instance GHC.Base.Functor Brick.Widgets.List.List
+ Brick.Widgets.List: listClear :: List e -> List e
+ Brick.Widgets.List: listReverse :: List e -> List e
- Brick.Widgets.Dialog: dialogButtonsL :: Lens (Dialog a_aHMd) (Dialog a_aHMI) [(String, a_aHMd)] [(String, a_aHMI)]
+ Brick.Widgets.Dialog: dialogButtonsL :: Lens (Dialog a_aHOc) (Dialog a_aHOH) [(String, a_aHOc)] [(String, a_aHOH)]
- Brick.Widgets.Dialog: dialogNameL :: Lens' (Dialog a_aHMd) Name
+ Brick.Widgets.Dialog: dialogNameL :: Lens' (Dialog a_aHOc) Name
- Brick.Widgets.Dialog: dialogSelectedIndexL :: Lens' (Dialog a_aHMd) (Maybe Int)
+ Brick.Widgets.Dialog: dialogSelectedIndexL :: Lens' (Dialog a_aHOc) (Maybe Int)
- Brick.Widgets.Dialog: dialogTitleL :: Lens' (Dialog a_aHMd) (Maybe String)
+ Brick.Widgets.Dialog: dialogTitleL :: Lens' (Dialog a_aHOc) (Maybe String)
- Brick.Widgets.Dialog: dialogWidthL :: Lens' (Dialog a_aHMd) Int
+ Brick.Widgets.Dialog: dialogWidthL :: Lens' (Dialog a_aHOc) Int
- Brick.Widgets.List: listElementsL :: Lens (List e_aMcW) (List e_aMdQ) (Vector e_aMcW) (Vector e_aMdQ)
+ Brick.Widgets.List: listElementsL :: Lens (List e_aMeV) (List e_aMlE) (Vector e_aMeV) (Vector e_aMlE)
- Brick.Widgets.List: listItemHeightL :: Lens' (List e_aMcW) Int
+ Brick.Widgets.List: listItemHeightL :: Lens' (List e_aMeV) Int
- Brick.Widgets.List: listNameL :: Lens' (List e_aMcW) Name
+ Brick.Widgets.List: listNameL :: Lens' (List e_aMeV) Name
- Brick.Widgets.List: listSelectedL :: Lens' (List e_aMcW) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: Lens' (List e_aMeV) (Maybe Int)

Files

CHANGELOG.md view
@@ -2,6 +2,23 @@ Brick changelog --------------- +0.4+---++API changes:+* Added Brick.Widgets.Core.unsafeLookupViewport to make certain kinds+  of custom widget implementations easier when viewport states are needed+  (thanks Markus Hauck <markus1189@gmail.com>)+* List: added listClear and listReverse functions (thanks Markus Hauck)+* List: Derive instances for Functor, Foldable, Traversable (thanks+  Markus Hauck)++Documentation changes:+* Hyperlink "Data.Text.Markup" inside Brick.Markup haddock (thanks+  Markus Hauck)+* Fix typo in 'Attribute Management' section of user guide (thanks+  Markus Hauck)+ 0.3.1 ----- 
brick.cabal view
@@ -1,5 +1,5 @@ name:                brick-version:             0.3.1+version:             0.4 synopsis:            A declarative terminal user interface library description:   Write terminal applications painlessly with 'brick'! You write an
src/Brick/Markup.hs view
@@ -1,5 +1,5 @@ -- | This module provides an API for turning "markup" values into--- widgets. This module uses the Data.Text.Markup interface in this+-- widgets. This module uses the "Data.Text.Markup" interface in this -- package to assign attributes to substrings in a text string; to -- manipulate markup using (for example) syntax highlighters, see that -- module.
src/Brick/Types.hs view
@@ -72,6 +72,7 @@ import Data.Monoid (Monoid(..)) import Control.Monad.Trans.State.Lazy import Control.Monad.Trans.Reader+import Control.Monad.Trans.Class (lift) import Graphics.Vty (Event, Image, emptyImage, Attr) import Data.Default (Default(..)) import Data.Functor.Contravariant
src/Brick/Widgets/Core.hs view
@@ -30,7 +30,7 @@   , hLimit   , vLimit -  -- * Attribute mangement+  -- * Attribute management   , withDefAttr   , withAttr   , forceAttr@@ -55,6 +55,7 @@   , viewport   , visible   , visibleRegion+  , unsafeLookupViewport    -- ** Adding offsets to cursor positions and visibility requests   , addResultOffset@@ -628,6 +629,18 @@                       $ padBottom Max                       $ padRight Max                       $ Widget Fixed Fixed $ return $ translated & visibilityRequestsL .~ mempty++-- | Given a name, obtain the viewport for that name by consulting the+-- viewport map in the rendering monad. NOTE! Some care must be taken+-- when calling this function, since it only returns useful values+-- after the viewport in question has been rendered. If you call this+-- function during rendering before a viewport has been rendered, you+-- may get nothing or you may get a stale version of the viewport. This+-- is because viewports are updated during rendering and the one you are+-- interested in may not have been rendered yet. So if you want to use+-- this, be sure you know what you are doing.+unsafeLookupViewport :: Name -> RenderM (Maybe Viewport)+unsafeLookupViewport name = lift $ gets (M.lookup name . (^.viewportMapL))  scrollTo :: ViewportType -> ScrollRequest -> V.Image -> Viewport -> Viewport scrollTo Both _ _ _ = error "BUG: called scrollTo on viewport type 'Both'"
src/Brick/Widgets/List.hs view
@@ -1,6 +1,9 @@ {-# LANGUAGE TupleSections #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE DeriveFoldable#-}+{-# LANGUAGE DeriveTraversable #-} -- | This module provides a scrollable list type and functions for -- manipulating and rendering it. module Brick.Widgets.List@@ -27,6 +30,8 @@   , listRemove   , listReplace   , listSelectedElement+  , listClear+  , listReverse    -- * Attributes   , listAttr@@ -34,8 +39,10 @@   ) where -import Control.Applicative ((<$>))-import Control.Lens ((^.), (&), (.~), _2)+import Control.Applicative ((<$>),(<*>),pure)+import Control.Lens ((^.), (&), (.~), (%~), _2)+import Data.Foldable (Foldable)+import Data.Traversable (Traversable) import Data.Maybe (fromMaybe) import Data.Monoid ((<>)) import Graphics.Vty (Event(..), Key(..))@@ -60,7 +67,7 @@          , listSelected :: !(Maybe Int)          , listName :: Name          , listItemHeight :: Int-         }+         } deriving (Functor, Foldable, Traversable)  suffixLenses ''List @@ -227,3 +234,14 @@ listSelectedElement l = do   sel <- l^.listSelectedL   return (sel, (l^.listElementsL) V.! sel)++-- | Remove all elements from the list and clear the selection.+listClear :: List e -> List e+listClear l = l & listElementsL .~ V.empty & listSelectedL .~ Nothing++-- | Reverse the list.  The element selected before the reversal will+-- again be the selected one.+listReverse :: List e -> List e+listReverse theList = theList & listElementsL %~ V.reverse & listSelectedL .~ newSel+  where n = V.length (listElements theList)+        newSel = (-) <$> pure (n-1) <*> listSelected theList