packages feed

brick 0.10 → 0.11

raw patch · 6 files changed

+28/−9 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Brick.Main: getVtyHandle :: EventM n (Maybe Vty)
- Brick.Types: EventM :: ReaderT (Map n Viewport) (StateT (EventState n) IO) a -> EventM n a
+ Brick.Types: EventM :: ReaderT (EventRO n) (StateT (EventState n) IO) a -> EventM n a
- Brick.Types: [runEventM] :: EventM n a -> ReaderT (Map n Viewport) (StateT (EventState n) IO) a
+ Brick.Types: [runEventM] :: EventM n a -> ReaderT (EventRO n) (StateT (EventState n) IO) a
- Brick.Types: cursorLocationL :: forall n_aoPe. Lens' (CursorLocation n_aoPe) Location
+ Brick.Types: cursorLocationL :: forall n_atdr. Lens' (CursorLocation n_atdr) Location
- Brick.Types: cursorLocationNameL :: forall n_aoPe n_apGg. Lens (CursorLocation n_aoPe) (CursorLocation n_apGg) (Maybe n_aoPe) (Maybe n_apGg)
+ Brick.Types: cursorLocationNameL :: forall n_atdr n_attD. Lens (CursorLocation n_atdr) (CursorLocation n_attD) (Maybe n_atdr) (Maybe n_attD)
- Brick.Types: cursorsL :: forall n_aoO9 n_apyF. Lens (Result n_aoO9) (Result n_apyF) [CursorLocation n_aoO9] [CursorLocation n_apyF]
+ Brick.Types: cursorsL :: forall n_atcs n_atm6. Lens (Result n_atcs) (Result n_atm6) [CursorLocation n_atcs] [CursorLocation n_atm6]
- Brick.Types: imageL :: forall n_aoO9. Lens' (Result n_aoO9) Image
+ Brick.Types: imageL :: forall n_atcs. Lens' (Result n_atcs) Image
- Brick.Types: visibilityRequestsL :: forall n_aoO9. Lens' (Result n_aoO9) [VisibilityRequest]
+ Brick.Types: visibilityRequestsL :: forall n_atcs. Lens' (Result n_atcs) [VisibilityRequest]
- Brick.Widgets.Dialog: dialogButtonsL :: forall a_aY6y a_aY78. Lens (Dialog a_aY6y) (Dialog a_aY78) [(String, a_aY6y)] [(String, a_aY78)]
+ Brick.Widgets.Dialog: dialogButtonsL :: forall a_aYro a_aYrY. Lens (Dialog a_aYro) (Dialog a_aYrY) [(String, a_aYro)] [(String, a_aYrY)]
- Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_aY6y. Lens' (Dialog a_aY6y) (Maybe Int)
+ Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_aYro. Lens' (Dialog a_aYro) (Maybe Int)
- Brick.Widgets.Dialog: dialogTitleL :: forall a_aY6y. Lens' (Dialog a_aY6y) (Maybe String)
+ Brick.Widgets.Dialog: dialogTitleL :: forall a_aYro. Lens' (Dialog a_aYro) (Maybe String)
- Brick.Widgets.Dialog: dialogWidthL :: forall a_aY6y. Lens' (Dialog a_aY6y) Int
+ Brick.Widgets.Dialog: dialogWidthL :: forall a_aYro. Lens' (Dialog a_aYro) Int
- Brick.Widgets.Edit: editContentsL :: forall t_aZQf n_aZQg. Lens' (Editor t_aZQf n_aZQg) (TextZipper t_aZQf)
+ Brick.Widgets.Edit: editContentsL :: forall t_a10f9 n_a10fa. Lens' (Editor t_a10f9 n_a10fa) (TextZipper t_a10f9)
- Brick.Widgets.Edit: editDrawContentsL :: forall t_aZQf n_aZQg. Lens' (Editor t_aZQf n_aZQg) ([t_aZQf] -> Widget n_aZQg)
+ Brick.Widgets.Edit: editDrawContentsL :: forall t_a10f9 n_a10fa. Lens' (Editor t_a10f9 n_a10fa) ([t_a10f9] -> Widget n_a10fa)
- Brick.Widgets.List: listElementsL :: forall n_a11mR e_a11mS e_a11vs. Lens (List n_a11mR e_a11mS) (List n_a11mR e_a11vs) (Vector e_a11mS) (Vector e_a11vs)
+ Brick.Widgets.List: listElementsL :: forall n_a17ex e_a17ey e_a17kd. Lens (List n_a17ex e_a17ey) (List n_a17ex e_a17kd) (Vector e_a17ey) (Vector e_a17kd)
- Brick.Widgets.List: listItemHeightL :: forall n_a11mR e_a11mS. Lens' (List n_a11mR e_a11mS) Int
+ Brick.Widgets.List: listItemHeightL :: forall n_a17ex e_a17ey. Lens' (List n_a17ex e_a17ey) Int
- Brick.Widgets.List: listNameL :: forall n_a11mR e_a11mS n_a11vt. Lens (List n_a11mR e_a11mS) (List n_a11vt e_a11mS) n_a11mR n_a11vt
+ Brick.Widgets.List: listNameL :: forall n_a17ex e_a17ey n_a17ke. Lens (List n_a17ex e_a17ey) (List n_a17ke e_a17ey) n_a17ex n_a17ke
- Brick.Widgets.List: listSelectedL :: forall n_a11mR e_a11mS. Lens' (List n_a11mR e_a11mS) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: forall n_a17ex e_a17ey. Lens' (List n_a17ex e_a17ey) (Maybe Int)

Files

CHANGELOG.md view
@@ -2,6 +2,14 @@ Brick changelog --------------- +0.11+----++API changes:+ * Added getVtyHandle in EventM for obtaining the current Vty context.+   It returns Nothing when calling the appStartEvent handler but after+   that a context is always available.+ 0.10 ---- 
brick.cabal view
@@ -1,5 +1,5 @@ name:                brick-version:             0.10+version:             0.11 synopsis:            A declarative terminal user interface library description:   Write terminal applications painlessly with 'brick'! You write an
docs/guide.rst view
@@ -906,7 +906,7 @@        Widget Greedy Greedy $ do            ctx <- getContext            let a = ctx^.attrL-           return $ Result (Graphics.Vty.charFill ch a (ctx^.availWidth) (ctx^.availHeight))+           return $ Result (Graphics.Vty.charFill a ch (ctx^.availWidthL) (ctx^.availHeightL))                            [] []  Rendering Sub-Widgets
src/Brick/Main.hs view
@@ -10,6 +10,7 @@   , halt   , suspendAndResume   , lookupViewport+  , getVtyHandle    -- ** Viewport scrolling   , viewportScroll@@ -65,7 +66,7 @@   )  import Brick.Types (Viewport, Direction, Widget, rowL, columnL, CursorLocation(..), cursorLocationNameL, EventM(..))-import Brick.Types.Internal (ScrollRequest(..), RenderState(..), observedNamesL, Next(..), EventState(..), CacheInvalidateRequest(..))+import Brick.Types.Internal (EventRO(..), ScrollRequest(..), RenderState(..), observedNamesL, Next(..), EventState(..), CacheInvalidateRequest(..)) import Brick.Widgets.Internal (renderFinal) import Brick.AttrMap @@ -198,7 +199,8 @@                     run newRS newAppState chan          emptyES = ES [] []-    (st, eState) <- runStateT (runReaderT (runEventM (appStartEvent app initialAppState)) M.empty) emptyES+        eventRO = EventRO M.empty Nothing+    (st, eState) <- runStateT (runReaderT (runEventM (appStartEvent app initialAppState)) eventRO) emptyES     let initialRS = RS M.empty (esScrollRequests eState) S.empty mempty     chan <- newChan     forkIO $ forever $ readChan userChan >>= (\userEvent -> writeChan chan (Right userEvent))@@ -234,8 +236,9 @@             Left e' -> appLiftVtyEvent app e'             Right e' -> e' +    let eventRO = EventRO (viewportMap nextRS) (Just vty)     (next, eState) <- runStateT (runReaderT (runEventM (appHandleEvent app appState userEvent))-                                (viewportMap nextRS)) emptyES+                                eventRO) emptyES     return (next, nextRS { rsScrollRequests = esScrollRequests eState                          , renderCache = applyInvalidations (cacheInvalidateRequests eState) $                                          renderCache nextRS@@ -253,7 +256,11 @@ -- or because no rendering has occurred (e.g. in an 'appStartEvent' -- handler). lookupViewport :: (Ord n) => n -> EventM n (Maybe Viewport)-lookupViewport = EventM . asks . M.lookup+lookupViewport n = EventM $ asks (M.lookup n . eventViewportMap)++-- | Get the Vty handle currently in use.+getVtyHandle :: EventM n (Maybe Vty)+getVtyHandle = EventM $ asks eventVtyHandle  -- | Invalidate the rendering cache entry with the specified name. invalidateCacheEntry :: n -> EventM n ()
src/Brick/Types.hs view
@@ -75,7 +75,6 @@ import Control.Monad.Trans.State.Lazy import Control.Monad.Trans.Reader import Graphics.Vty (Event, Attr)-import qualified Data.Map as M import Control.Monad.IO.Class  import Brick.Types.TH@@ -111,7 +110,7 @@ -- to dig into the reader value yourself, just use -- 'Brick.Main.lookupViewport'. newtype EventM n a =-    EventM { runEventM :: ReaderT (M.Map n Viewport) (StateT (EventState n) IO) a+    EventM { runEventM :: ReaderT (EventRO n) (StateT (EventState n) IO) a            }            deriving (Functor, Applicative, Monad, MonadIO) 
src/Brick/Types/Internal.hs view
@@ -19,6 +19,7 @@   , cursorLocationNameL   , Context(..)   , EventState(..)+  , EventRO(..)   , Next(..)   , Result(..)   , CacheInvalidateRequest(..)@@ -45,7 +46,7 @@ import Lens.Micro.Internal (Field1, Field2) import qualified Data.Set as S import qualified Data.Map as M-import Graphics.Vty (DisplayRegion, Image, emptyImage)+import Graphics.Vty (Vty, DisplayRegion, Image, emptyImage) import Data.Default (Default(..))  import Brick.Types.TH@@ -97,6 +98,10 @@ data EventState n = ES { esScrollRequests :: [(n, ScrollRequest)]                        , cacheInvalidateRequests :: [CacheInvalidateRequest n]                        }++data EventRO n = EventRO { eventViewportMap :: M.Map n Viewport+                         , eventVtyHandle :: Maybe Vty+                         }  -- | The type of actions to take upon completion of an event handler. data Next a = Continue a