brick-panes 1.0.0.0 → 1.0.0.1
raw patch · 3 files changed
+57/−12 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−0
- brick-panes.cabal +1/−1
- src/Brick/Panes.hs +52/−11
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for brick-panes +## 1.0.0.1 -- 2022-10-13++* Documentation improvements.+ ## 1.0.0.0 -- 2022-10-01 * Public release.
brick-panes.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: brick-panes-version: 1.0.0.0+version: 1.0.0.1 synopsis: Panes library for Brick providing composition and isolation for TUI apps.
src/Brick/Panes.hs view
@@ -19,6 +19,47 @@ {-| This package provides an overlay library for Brick that allows individual TUI screen areas to be independently developed and then easily composed into the overall application.++ This is done by representing each 'Pane' via a class that describes the common+ types and methods for that 'Pane', as well as the internal state of the 'Pane'.+ The full 'Pane' class is shown here in brief (more extensive documentation is+ available below):++ > class Pane n appEv pane | pane -> n where+ > data PaneState pane appEv+ >+ > type InitConstraints pane initctxt :: Constraint+ > initPaneState :: (InitConstraints pane i) => i -> PaneState pane appEv+ >+ > type DrawConstraints pane drwctxt n :: Constraint+ > drawPane :: (DrawConstraints pane drawcontext n, Eq n)+ > => PaneState pane appEv -> drawcontext -> Maybe (Widget n)+ >+ > type EventConstraints pane evctxt :: Constraint+ > type EventType pane n appEv+ > focusable :: (EventConstraints pane eventcontext, Eq n)+ > => eventcontext -> PaneState pane appEv -> Seq.Seq n+ > handlePaneEvent :: (EventConstraints pane eventcontext, Eq n)+ > => eventcontext+ > -> EventType pane n appEv+ > -> PaneState pane appEv+ > -> EventM n es (PaneState pane appEv)+ >+ > type UpdateType pane+ > updatePane :: UpdateType pane+ > -> PaneState pane appEv+ > -> PaneState pane appEv++ Each 'Pane' can be added to an overall 'Panel', where the 'Panel' provides+ appropriate focus management and consolidates event and draw dispatching to the+ (appropriate) panes. The 'Panel' can support modal panes which grab focus (and+ are not visible wheen not active and focused), panes which participate in a+ normal focus ring, and panes which are never focused. The 'Panel' is+ represented by a recursive data structure that is initialized by calling the+ 'basePanel' function with the global application state and passing that result+ to the 'addToPanel' function for each 'Pane' that should be added to the+ 'Panel'.+ -} module Brick.Panes@@ -131,20 +172,20 @@ class Pane n appEv pane | pane -> n where -- | State information associated with this pane- data (PaneState pane appEv)+ data PaneState pane appEv -- | Type of data provided to updatePane- type (UpdateType pane)+ type UpdateType pane -- | Constraints on argument passed to 'initPaneState'. If there are no -- constraints, this may be specified as @()@, or simply omitted because @()@ -- is the default.- type (InitConstraints pane initctxt) :: Constraint+ type InitConstraints pane initctxt :: Constraint -- | Function called to initialize the internal 'PaneState' initPaneState :: (InitConstraints pane i) => i -> PaneState pane appEv -- | Constraints on the @drawcontext@ parameter passed to 'drawPane'.- type (DrawConstraints pane drwctxt n) :: Constraint+ type DrawConstraints pane drwctxt n :: Constraint -- | Function called to draw the 'Pane' as a Brick 'Widget', or 'Nothing' if -- this 'Pane' should not be drawn at the current time. drawPane :: (DrawConstraints pane drawcontext n, Eq n)@@ -152,11 +193,11 @@ -- | The constraints that should exist on the 'eventcontext' argment passed to -- 'focusable' and 'handlePaneEvent'.- type (EventConstraints pane evctxt) :: Constraint+ type EventConstraints pane evctxt :: Constraint -- | The type of the event argument delivered to 'handlePaneEvent'. This -- should either be 'Vty.Event' or 'BrickEvent', depending on what level of -- granularity the 'handlePaneEvent' operates at.- type (EventType pane n appEv)+ type EventType pane n appEv -- | The 'focusable' method is called to determine which Widget targets should -- be part of the Brick 'FocusRing'. focusable :: (EventConstraints pane eventcontext, Eq n)@@ -184,11 +225,11 @@ -> PaneState pane appEv -- A set of defaults that allows a minimal instance specification- type (UpdateType pane) = ()- type (InitConstraints pane initctxt) = ()- type (DrawConstraints pane drwctxt n) = ()- type (EventConstraints pane evctxt) = ()- type (EventType pane n appev) = Vty.Event -- by default, handle Vty events+ type UpdateType pane = ()+ type InitConstraints pane initctxt = ()+ type DrawConstraints pane drwctxt n = ()+ type EventConstraints pane evctxt = ()+ type EventType pane n appev = Vty.Event -- by default, handle Vty events focusable _ _ = mempty handlePaneEvent _ _ = return updatePane _ = id