brick 0.12 → 0.13
raw patch · 8 files changed
+33/−15 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Brick.Focus: instance GHC.Base.Functor Brick.Focus.FocusRing
- Brick.Main: customMain :: (Ord n) => IO Vty -> Chan e -> App s e n -> s -> IO s
+ Brick.Main: customMain :: (Ord n) => IO Vty -> Maybe (Chan e) -> App s e n -> s -> IO s
- Brick.Widgets.Dialog: dialogButtonsL :: forall a_a11pP a_a11qp. Lens (Dialog a_a11pP) (Dialog a_a11qp) [(String, a_a11pP)] [(String, a_a11qp)]
+ Brick.Widgets.Dialog: dialogButtonsL :: forall a_a11xt a_a11y3. Lens (Dialog a_a11xt) (Dialog a_a11y3) [(String, a_a11xt)] [(String, a_a11y3)]
- Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a11pP. Lens' (Dialog a_a11pP) (Maybe Int)
+ Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a11xt. Lens' (Dialog a_a11xt) (Maybe Int)
- Brick.Widgets.Dialog: dialogTitleL :: forall a_a11pP. Lens' (Dialog a_a11pP) (Maybe String)
+ Brick.Widgets.Dialog: dialogTitleL :: forall a_a11xt. Lens' (Dialog a_a11xt) (Maybe String)
- Brick.Widgets.Dialog: dialogWidthL :: forall a_a11pP. Lens' (Dialog a_a11pP) Int
+ Brick.Widgets.Dialog: dialogWidthL :: forall a_a11xt. Lens' (Dialog a_a11xt) Int
- Brick.Widgets.Edit: editContentsL :: forall t_a139w n_a139x. Lens' (Editor t_a139w n_a139x) (TextZipper t_a139w)
+ Brick.Widgets.Edit: editContentsL :: forall t_a13ha n_a13hb. Lens' (Editor t_a13ha n_a13hb) (TextZipper t_a13ha)
- Brick.Widgets.Edit: editDrawContentsL :: forall t_a139w n_a139x. Lens' (Editor t_a139w n_a139x) ([t_a139w] -> Widget n_a139x)
+ Brick.Widgets.Edit: editDrawContentsL :: forall t_a13ha n_a13hb. Lens' (Editor t_a13ha n_a13hb) ([t_a13ha] -> Widget n_a13hb)
- Brick.Widgets.List: listElementsL :: forall n_a14Uh e_a14Ui e_a154M. Lens (List n_a14Uh e_a14Ui) (List n_a14Uh e_a154M) (Vector e_a14Ui) (Vector e_a154M)
+ Brick.Widgets.List: listElementsL :: forall n_a151V e_a151W e_a15cq. Lens (List n_a151V e_a151W) (List n_a151V e_a15cq) (Vector e_a151W) (Vector e_a15cq)
- Brick.Widgets.List: listItemHeightL :: forall n_a14Uh e_a14Ui. Lens' (List n_a14Uh e_a14Ui) Int
+ Brick.Widgets.List: listItemHeightL :: forall n_a151V e_a151W. Lens' (List n_a151V e_a151W) Int
- Brick.Widgets.List: listNameL :: forall n_a14Uh e_a14Ui n_a154N. Lens (List n_a14Uh e_a14Ui) (List n_a154N e_a14Ui) n_a14Uh n_a154N
+ Brick.Widgets.List: listNameL :: forall n_a151V e_a151W n_a15cr. Lens (List n_a151V e_a151W) (List n_a15cr e_a151W) n_a151V n_a15cr
- Brick.Widgets.List: listSelectedL :: forall n_a14Uh e_a14Ui. Lens' (List n_a14Uh e_a14Ui) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: forall n_a151V e_a151W. Lens' (List n_a151V e_a151W) (Maybe Int)
Files
- CHANGELOG.md +8/−0
- README.md +0/−2
- brick.cabal +1/−1
- docs/guide.rst +1/−1
- programs/CustomEventDemo.hs +1/−1
- programs/MouseDemo.hs +8/−1
- src/Brick/Focus.hs +3/−0
- src/Brick/Main.hs +11/−9
CHANGELOG.md view
@@ -2,6 +2,14 @@ Brick changelog --------------- +0.13+----++API changes:+ * Mouse mode is no longer enabled by default.+ * customMain's event channel parameter is now optional+ * FocusRing now provides a Functor instance (thanks Ian Jeffries)+ 0.12 ----
README.md view
@@ -34,8 +34,6 @@ * Border-drawing widgets (put borders around or in between things) * Generic scrollable viewports * Extensible widget-building API- * Mouse interaction- * Rendering cache * (And many more general-purpose layout control combinators) In addition, some of `brick`'s more powerful features may not be obvious
brick.cabal view
@@ -1,5 +1,5 @@ name: brick-version: 0.12+version: 0.13 synopsis: A declarative terminal user interface library description: Write terminal applications painlessly with 'brick'! You write an
docs/guide.rst view
@@ -343,7 +343,7 @@ main :: IO () main = do eventChan <- Control.Concurrent.newChan- finalState <- customMain (Graphics.Vty.mkVty Data.Default.def) eventChan app initialState+ finalState <- customMain (Graphics.Vty.mkVty Data.Default.def) (Just eventChan) app initialState -- Use finalState and exit The ``customMain`` function lets us have control over how the ``vty``
programs/CustomEventDemo.hs view
@@ -76,4 +76,4 @@ writeChan chan Counter threadDelay 1000000 - void $ customMain (V.mkVty def) chan theApp initialState+ void $ customMain (V.mkVty def) (Just chan) theApp initialState
programs/MouseDemo.hs view
@@ -3,6 +3,7 @@ module Main where import Control.Applicative ((<$>))+import Control.Concurrent (newChan) import Data.Monoid ((<>)) import Lens.Micro ((^.), (&), (.~)) import Lens.Micro.TH (makeLenses)@@ -88,4 +89,10 @@ } main :: IO ()-main = void $ M.defaultMain app $ St [] Nothing+main = do+ let buildVty = do+ v <- V.mkVty =<< V.standardIOConfig+ V.setMode (V.outputIface v) V.Mouse True+ return v++ void $ M.customMain buildVty Nothing app $ St [] Nothing
src/Brick/Focus.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE DeriveFunctor #-}+ -- | This module provides a type and functions for handling focus rings -- of widgets. Note that this interface is merely provided for managing -- the focus state for a sequence of resource names; it does not do@@ -25,6 +27,7 @@ -- currently-focused name. data FocusRing n = FocusRingEmpty | FocusRingNonempty ![n] !Int+ deriving Functor -- | Construct a focus ring from the list of resource names. focusRing :: [n] -> FocusRing n
src/Brick/Main.hs view
@@ -42,7 +42,7 @@ import Control.Exception (finally) import Lens.Micro ((^.), (&), (.~))-import Control.Monad (forever)+import Control.Monad (forever, void) import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.State import Control.Monad.Trans.Reader@@ -60,8 +60,6 @@ , Picture(..) , Cursor(..) , Event(..)- , Mode(..)- , setMode , update , outputIface , displayBounds@@ -121,7 +119,7 @@ -> IO s defaultMain app st = do chan <- newChan- customMain (mkVty def) chan app st+ customMain (mkVty def) (Just chan) app st -- | A simple main entry point which takes a widget and renders it. This -- event loop terminates when the user presses any key, but terminal@@ -160,7 +158,6 @@ -> IO (InternalNext n s) runWithNewVty buildVty chan app initialRS initialSt = withVty buildVty $ \vty -> do- setMode (outputIface vty) Mouse True pid <- forkIO $ supplyVtyEvents vty chan let runInner rs st = do (result, newRS) <- runVty vty chan app st (rs & observedNamesL .~ S.empty@@ -182,16 +179,17 @@ -- ^ An IO action to build a Vty handle. This is used to -- build a Vty handle whenever the event loop begins or is -- resumed after suspension.- -> Chan e+ -> Maybe (Chan e) -- ^ An event channel for sending custom events to the event -- loop (you write to this channel, the event loop reads from- -- it).+ -- it). Provide 'Nothing' if you don't plan on sending custom+ -- events. -> App s e n -- ^ The application. -> s -- ^ The initial application state. -> IO s-customMain buildVty userChan app initialAppState = do+customMain buildVty mUserChan app initialAppState = do let run rs st chan = do result <- runWithNewVty buildVty chan app rs st case result of@@ -205,7 +203,11 @@ (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 $ AppEvent userEvent)+ case mUserChan of+ Just userChan ->+ void $ forkIO $ forever $ readChan userChan >>= (\userEvent -> writeChan chan $ AppEvent userEvent)+ Nothing -> return ()+ run initialRS st chan supplyVtyEvents :: Vty -> Chan (BrickEvent n e) -> IO ()