packages feed

brick 0.18 → 0.19

raw patch · 6 files changed

+26/−24 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Brick.Widgets.Edit: editDrawContentsL :: forall t_a15vd n_a15ve. Lens' (Editor t_a15vd n_a15ve) ([t_a15vd] -> Widget n_a15ve)
- Brick.Types: cursorLocationL :: forall n_aqdt. Lens' (CursorLocation n_aqdt) Location
+ Brick.Types: cursorLocationL :: forall n_aqdu. Lens' (CursorLocation n_aqdu) Location
- Brick.Types: cursorLocationNameL :: forall n_aqdt n_aqGV. Lens (CursorLocation n_aqdt) (CursorLocation n_aqGV) (Maybe n_aqdt) (Maybe n_aqGV)
+ Brick.Types: cursorLocationNameL :: forall n_aqdu n_aqGW. Lens (CursorLocation n_aqdu) (CursorLocation n_aqGW) (Maybe n_aqdu) (Maybe n_aqGW)
- Brick.Types: cursorsL :: forall n_aqco. Lens' (Result n_aqco) [CursorLocation n_aqco]
+ Brick.Types: cursorsL :: forall n_aqcp. Lens' (Result n_aqcp) [CursorLocation n_aqcp]
- Brick.Types: extentsL :: forall n_aqco. Lens' (Result n_aqco) [Extent n_aqco]
+ Brick.Types: extentsL :: forall n_aqcp. Lens' (Result n_aqcp) [Extent n_aqcp]
- Brick.Types: imageL :: forall n_aqco. Lens' (Result n_aqco) Image
+ Brick.Types: imageL :: forall n_aqcp. Lens' (Result n_aqcp) Image
- Brick.Types: visibilityRequestsL :: forall n_aqco. Lens' (Result n_aqco) [VisibilityRequest]
+ Brick.Types: visibilityRequestsL :: forall n_aqcp. Lens' (Result n_aqcp) [VisibilityRequest]
- Brick.Widgets.Dialog: dialogButtonsL :: forall a_a13JS a_a13Ks. Lens (Dialog a_a13JS) (Dialog a_a13Ks) [(String, a_a13JS)] [(String, a_a13Ks)]
+ Brick.Widgets.Dialog: dialogButtonsL :: forall a_a13JU a_a13Ku. Lens (Dialog a_a13JU) (Dialog a_a13Ku) [(String, a_a13JU)] [(String, a_a13Ku)]
- Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a13JS. Lens' (Dialog a_a13JS) (Maybe Int)
+ Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a13JU. Lens' (Dialog a_a13JU) (Maybe Int)
- Brick.Widgets.Dialog: dialogTitleL :: forall a_a13JS. Lens' (Dialog a_a13JS) (Maybe String)
+ Brick.Widgets.Dialog: dialogTitleL :: forall a_a13JU. Lens' (Dialog a_a13JU) (Maybe String)
- Brick.Widgets.Dialog: dialogWidthL :: forall a_a13JS. Lens' (Dialog a_a13JS) Int
+ Brick.Widgets.Dialog: dialogWidthL :: forall a_a13JU. Lens' (Dialog a_a13JU) Int
- Brick.Widgets.Edit: editContentsL :: forall t_a15vd n_a15ve. Lens' (Editor t_a15vd n_a15ve) (TextZipper t_a15vd)
+ Brick.Widgets.Edit: editContentsL :: forall t_a15ve n_a15vf t_a15vQ. Lens (Editor t_a15ve n_a15vf) (Editor t_a15vQ n_a15vf) (TextZipper t_a15ve) (TextZipper t_a15vQ)
- Brick.Widgets.Edit: editor :: GenericTextZipper a => n -> ([a] -> Widget n) -> Maybe Int -> a -> Editor a n
+ Brick.Widgets.Edit: editor :: GenericTextZipper a => n -> Maybe Int -> a -> Editor a n
- Brick.Widgets.Edit: editorText :: n -> ([Text] -> Widget n) -> Maybe Int -> Text -> Editor Text n
+ Brick.Widgets.Edit: editorText :: n -> Maybe Int -> Text -> Editor Text n
- Brick.Widgets.Edit: renderEditor :: (Ord n, Show n, Monoid t, TextWidth t, GenericTextZipper t) => Bool -> Editor t n -> Widget n
+ Brick.Widgets.Edit: renderEditor :: (Ord n, Show n, Monoid t, TextWidth t, GenericTextZipper t) => ([t] -> Widget n) -> Bool -> Editor t n -> Widget n
- Brick.Widgets.List: listElementsL :: forall n_a17nQ e_a17nR e_a17xL. Lens (List n_a17nQ e_a17nR) (List n_a17nQ e_a17xL) (Vector e_a17nR) (Vector e_a17xL)
+ Brick.Widgets.List: listElementsL :: forall n_a17j8 e_a17j9 e_a17t3. Lens (List n_a17j8 e_a17j9) (List n_a17j8 e_a17t3) (Vector e_a17j9) (Vector e_a17t3)
- Brick.Widgets.List: listItemHeightL :: forall n_a17nQ e_a17nR. Lens' (List n_a17nQ e_a17nR) Int
+ Brick.Widgets.List: listItemHeightL :: forall n_a17j8 e_a17j9. Lens' (List n_a17j8 e_a17j9) Int
- Brick.Widgets.List: listNameL :: forall n_a17nQ e_a17nR n_a17xM. Lens (List n_a17nQ e_a17nR) (List n_a17xM e_a17nR) n_a17nQ n_a17xM
+ Brick.Widgets.List: listNameL :: forall n_a17j8 e_a17j9 n_a17t4. Lens (List n_a17j8 e_a17j9) (List n_a17t4 e_a17j9) n_a17j8 n_a17t4
- Brick.Widgets.List: listSelectedL :: forall n_a17nQ e_a17nR. Lens' (List n_a17nQ e_a17nR) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: forall n_a17j8 e_a17j9. Lens' (List n_a17j8 e_a17j9) (Maybe Int)

Files

CHANGELOG.md view
@@ -2,6 +2,15 @@ Brick changelog --------------- +0.19+----++API changes:+ * The editor content drawing function is now passed to renderEditor,+   not the constructor, to improve separation of presentation and+   representation concerns. The corresponding Editor drawing function+   lens and accessor were removed.+ 0.18 ---- 
brick.cabal view
@@ -1,5 +1,5 @@ name:                brick-version:             0.18+version:             0.19 synopsis:            A declarative terminal user interface library description:   Write terminal applications painlessly with 'brick'! You write an
programs/EditDemo.hs view
@@ -37,8 +37,8 @@ drawUI :: St -> [T.Widget Name] drawUI st = [ui]     where-        e1 = F.withFocusRing (st^.focusRing) E.renderEditor (st^.edit1)-        e2 = F.withFocusRing (st^.focusRing) E.renderEditor (st^.edit2)+        e1 = F.withFocusRing (st^.focusRing) (E.renderEditor (str . unlines)) (st^.edit1)+        e2 = F.withFocusRing (st^.focusRing) (E.renderEditor (str . unlines)) (st^.edit2)          ui = C.center $             (str "Input 1 (unlimited): " <+> (hLimit 30 $ vLimit 5 e1)) <=>@@ -63,8 +63,8 @@ initialState :: St initialState =     St (F.focusRing [Edit1, Edit2])-       (E.editor Edit1 (str . unlines) Nothing "")-       (E.editor Edit2 (str . unlines) (Just 2) "")+       (E.editor Edit1 Nothing "")+       (E.editor Edit2 (Just 2) "")  theMap :: A.AttrMap theMap = A.attrMap V.defAttr
programs/MouseDemo.hs view
@@ -46,7 +46,7 @@       C.hCenterLayer (padBottom (T.Pad 1) $ str "Click a button:") <=>       C.hCenterLayer (hBox $ padLeftRight 1 <$> buttons) <=>       C.hCenterLayer (padTopBottom 1 $ str "Or enter text and then click in this editor:") <=>-      C.hCenterLayer (vLimit 3 $ hLimit 50 $ E.renderEditor True (st^.edit))+      C.hCenterLayer (vLimit 3 $ hLimit 50 $ E.renderEditor (str . unlines) True (st^.edit))     where         buttons = mkButton <$> buttonData         buttonData = [ (Button1, "Button 1", "button1")@@ -143,4 +143,4 @@            \Excepteur sint occaecat cupidatat not proident,\n\            \sunt in culpa qui officia deserunt mollit\n\            \anim id est laborum.\n"-           (E.editor TextBox (str . unlines) Nothing "")+           (E.editor TextBox Nothing "")
src/Brick/Focus.hs view
@@ -1,7 +1,5 @@ -- | 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--- anything beyond keep track of that.+-- of values. -- -- This interface is experimental. module Brick.Focus@@ -31,13 +29,13 @@ focusRing :: [n] -> FocusRing n focusRing = FocusRing . C.fromList --- | Advance focus to the next widget in the ring.+-- | Advance focus to the next value in the ring. focusNext :: FocusRing n -> FocusRing n focusNext r@(FocusRing l)     | C.isEmpty l = r     | otherwise = FocusRing $ C.rotR l --- | Advance focus to the previous widget in the ring.+-- | Advance focus to the previous value in the ring. focusPrev :: FocusRing n -> FocusRing n focusPrev r@(FocusRing l)     | C.isEmpty l = r
src/Brick/Widgets/Edit.hs view
@@ -18,7 +18,7 @@ -- Emacs. It is also not suitable for building sophisticated editors. If -- you want to build your own editor, I suggest starting from scratch. module Brick.Widgets.Edit-  ( Editor(editContents, editorName, editDrawContents)+  ( Editor(editContents, editorName)   -- * Constructing an editor   , editor   , editorText@@ -30,7 +30,6 @@   , applyEdit   -- * Lenses for working with editors   , editContentsL-  , editDrawContentsL   -- * Rendering editors   , renderEditor   -- * Attributes@@ -64,8 +63,6 @@ data Editor t n =     Editor { editContents :: Z.TextZipper t            -- ^ The contents of the editor-           , editDrawContents :: [t] -> Widget n-           -- ^ The function the editor uses to draw its contents            , editorName :: n            -- ^ The name of the editor            }@@ -105,8 +102,6 @@ -- | Construct an editor over 'Text' values editorText :: n        -- ^ The editor's name (must be unique)-       -> ([T.Text] -> Widget n)-       -- ^ The content rendering function        -> Maybe Int        -- ^ The limit on the number of lines in the editor ('Nothing'        -- means no limit)@@ -119,15 +114,13 @@ editor :: Z.GenericTextZipper a        => n        -- ^ The editor's name (must be unique)-       -> ([a] -> Widget n)-       -- ^ The content rendering function        -> Maybe Int        -- ^ The limit on the number of lines in the editor ('Nothing'        -- means no limit)        -> a        -- ^ The initial content        -> Editor a n-editor name draw limit s = Editor (Z.textZipper (Z.lines s) limit) draw name+editor name limit s = Editor (Z.textZipper (Z.lines s) limit) name  -- | Apply an editing operation to the editor's contents. Bear in mind -- that you should only apply zipper operations that operate on the@@ -156,13 +149,15 @@ -- name for its scrollable viewport handle and the name is also used to -- report mouse events. renderEditor :: (Ord n, Show n, Monoid t, TextWidth t, Z.GenericTextZipper t)-             => Bool+             => ([t] -> Widget n)+             -- ^ The content drawing function+             -> Bool              -- ^ Whether the editor has focus. It will report a cursor              -- position if and only if it has focus.              -> Editor t n              -- ^ The editor.              -> Widget n-renderEditor foc e =+renderEditor draw foc e =     let cp = Z.cursorPosition z         z = e^.editContentsL         toLeft = Z.take (cp^._2) (Z.currentLine z)@@ -178,7 +173,7 @@        clickable (e^.editorNameL) $        (if foc then showCursor (e^.editorNameL) cursorLoc else id) $        visibleRegion cursorLoc (atCharWidth, 1) $-       e^.editDrawContentsL $+       draw $        getEditContents e  charAtCursor :: (Z.GenericTextZipper t) => Z.TextZipper t -> Maybe t