packages feed

brick 0.41 → 0.41.1

raw patch · 4 files changed

+75/−17 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Brick.Forms: checkboxCustomField :: (Ord n, Show n) => Char -> Char -> Char -> Lens' s Bool -> n -> Text -> s -> FormFieldState s e n
+ Brick.Forms: radioCustomField :: (Ord n, Show n, Eq a) => Char -> Char -> Char -> Lens' s a -> [(a, n, Text)] -> s -> FormFieldState s e n
- Brick.BorderMap: eBottomL :: forall a_aidG. Lens' (Edges a_aidG) a_aidG
+ Brick.BorderMap: eBottomL :: forall a_aicm. Lens' (Edges a_aicm) a_aicm
- Brick.BorderMap: eLeftL :: forall a_aidG. Lens' (Edges a_aidG) a_aidG
+ Brick.BorderMap: eLeftL :: forall a_aicm. Lens' (Edges a_aicm) a_aicm
- Brick.BorderMap: eRightL :: forall a_aidG. Lens' (Edges a_aidG) a_aidG
+ Brick.BorderMap: eRightL :: forall a_aicm. Lens' (Edges a_aicm) a_aicm
- Brick.BorderMap: eTopL :: forall a_aidG. Lens' (Edges a_aidG) a_aidG
+ Brick.BorderMap: eTopL :: forall a_aicm. Lens' (Edges a_aicm) a_aicm
- Brick.Types: bordersL :: forall n_aEnk. Lens' (Result n_aEnk) (BorderMap DynBorder)
+ Brick.Types: bordersL :: forall n_aEm0. Lens' (Result n_aEm0) (BorderMap DynBorder)
- Brick.Types: cursorLocationL :: forall n_aD3s. Lens' (CursorLocation n_aD3s) Location
+ Brick.Types: cursorLocationL :: forall n_aD28. Lens' (CursorLocation n_aD28) Location
- Brick.Types: cursorLocationNameL :: forall n_aD3s n_aEZi. Lens (CursorLocation n_aD3s) (CursorLocation n_aEZi) (Maybe n_aD3s) (Maybe n_aEZi)
+ Brick.Types: cursorLocationNameL :: forall n_aD28 n_aEXY. Lens (CursorLocation n_aD28) (CursorLocation n_aEXY) (Maybe n_aD28) (Maybe n_aEXY)
- Brick.Types: cursorsL :: forall n_aEnk. Lens' (Result n_aEnk) [CursorLocation n_aEnk]
+ Brick.Types: cursorsL :: forall n_aEm0. Lens' (Result n_aEm0) [CursorLocation n_aEm0]
- Brick.Types: eBottomL :: forall a_aidG. Lens' (Edges a_aidG) a_aidG
+ Brick.Types: eBottomL :: forall a_aicm. Lens' (Edges a_aicm) a_aicm
- Brick.Types: eLeftL :: forall a_aidG. Lens' (Edges a_aidG) a_aidG
+ Brick.Types: eLeftL :: forall a_aicm. Lens' (Edges a_aicm) a_aicm
- Brick.Types: eRightL :: forall a_aidG. Lens' (Edges a_aidG) a_aidG
+ Brick.Types: eRightL :: forall a_aicm. Lens' (Edges a_aicm) a_aicm
- Brick.Types: eTopL :: forall a_aidG. Lens' (Edges a_aidG) a_aidG
+ Brick.Types: eTopL :: forall a_aicm. Lens' (Edges a_aicm) a_aicm
- Brick.Types: extentsL :: forall n_aEnk. Lens' (Result n_aEnk) [Extent n_aEnk]
+ Brick.Types: extentsL :: forall n_aEm0. Lens' (Result n_aEm0) [Extent n_aEm0]
- Brick.Types: imageL :: forall n_aEnk. Lens' (Result n_aEnk) Image
+ Brick.Types: imageL :: forall n_aEm0. Lens' (Result n_aEm0) Image
- Brick.Types: visibilityRequestsL :: forall n_aEnk. Lens' (Result n_aEnk) [VisibilityRequest]
+ Brick.Types: visibilityRequestsL :: forall n_aEm0. Lens' (Result n_aEm0) [VisibilityRequest]
- Brick.Widgets.Dialog: dialogButtonsL :: forall a_a1cIB a_a1cJi. Lens (Dialog a_a1cIB) (Dialog a_a1cJi) [(String, a_a1cIB)] [(String, a_a1cJi)]
+ Brick.Widgets.Dialog: dialogButtonsL :: forall a_a1cHh a_a1cHY. Lens (Dialog a_a1cHh) (Dialog a_a1cHY) [(String, a_a1cHh)] [(String, a_a1cHY)]
- Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a1cIB. Lens' (Dialog a_a1cIB) (Maybe Int)
+ Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a1cHh. Lens' (Dialog a_a1cHh) (Maybe Int)
- Brick.Widgets.Dialog: dialogTitleL :: forall a_a1cIB. Lens' (Dialog a_a1cIB) (Maybe String)
+ Brick.Widgets.Dialog: dialogTitleL :: forall a_a1cHh. Lens' (Dialog a_a1cHh) (Maybe String)
- Brick.Widgets.Dialog: dialogWidthL :: forall a_a1cIB. Lens' (Dialog a_a1cIB) Int
+ Brick.Widgets.Dialog: dialogWidthL :: forall a_a1cHh. Lens' (Dialog a_a1cHh) Int
- Brick.Widgets.Edit: editContentsL :: forall t_a18lw n_a18lx t_a18mg. Lens (Editor t_a18lw n_a18lx) (Editor t_a18mg n_a18lx) (TextZipper t_a18lw) (TextZipper t_a18mg)
+ Brick.Widgets.Edit: editContentsL :: forall t_a18kc n_a18kd t_a18kW. Lens (Editor t_a18kc n_a18kd) (Editor t_a18kW n_a18kd) (TextZipper t_a18kc) (TextZipper t_a18kW)
- Brick.Widgets.List: listElementsL :: forall n_a1hjI e_a1hjJ e_a1hwd. Lens (List n_a1hjI e_a1hjJ) (List n_a1hjI e_a1hwd) (Vector e_a1hjJ) (Vector e_a1hwd)
+ Brick.Widgets.List: listElementsL :: forall n_a1hio e_a1hip e_a1huT. Lens (List n_a1hio e_a1hip) (List n_a1hio e_a1huT) (Vector e_a1hip) (Vector e_a1huT)
- Brick.Widgets.List: listItemHeightL :: forall n_a1hjI e_a1hjJ. Lens' (List n_a1hjI e_a1hjJ) Int
+ Brick.Widgets.List: listItemHeightL :: forall n_a1hio e_a1hip. Lens' (List n_a1hio e_a1hip) Int
- Brick.Widgets.List: listNameL :: forall n_a1hjI e_a1hjJ n_a1hwe. Lens (List n_a1hjI e_a1hjJ) (List n_a1hwe e_a1hjJ) n_a1hjI n_a1hwe
+ Brick.Widgets.List: listNameL :: forall n_a1hio e_a1hip n_a1huU. Lens (List n_a1hio e_a1hip) (List n_a1huU e_a1hip) n_a1hio n_a1huU
- Brick.Widgets.List: listSelectedL :: forall n_a1hjI e_a1hjJ. Lens' (List n_a1hjI e_a1hjJ) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: forall n_a1hio e_a1hip. Lens' (List n_a1hio e_a1hip) (Maybe Int)

Files

CHANGELOG.md view
@@ -2,6 +2,14 @@ Brick changelog --------------- +0.41.1+------++New features:+ * `Forms`: added `checkboxCustomField` and `radioCustomField` to permit+   customization of characters used to draw selection state for such+   fields.+ 0.41 ---- 
brick.cabal view
@@ -1,5 +1,5 @@ name:                brick-version:             0.41+version:             0.41.1 synopsis:            A declarative terminal user interface library description:   Write terminal applications painlessly with 'brick'! You write an
docs/guide.rst view
@@ -349,7 +349,7 @@    main = do        eventChan <- Brick.BChan.newBChan 10        finalState <- customMain-                       (Graphics.Vty.mkVty Data.Default.defaultConfig)+                       (Graphics.Vty.mkVty Graphics.Vty.defaultConfig)                        (Just eventChan) app initialState        -- Use finalState and exit 
src/Brick/Forms.hs view
@@ -70,6 +70,8 @@    -- * Advanced form field constructors   , editField+  , radioCustomField+  , checkboxCustomField    -- * Attributes   , formAttr@@ -78,7 +80,7 @@   ) where -import Graphics.Vty+import Graphics.Vty hiding (showCursor) #if !(MIN_VERSION_base(4,11,0)) import Data.Monoid #endif@@ -88,6 +90,7 @@  import Brick import Brick.Focus+import Brick.Widgets.Core (showCursor) import Brick.Widgets.Edit import Brick.Widgets.List import qualified Data.Text.Zipper as Z@@ -267,7 +270,31 @@               -> s               -- ^ The initial form state.               -> FormFieldState s e n-checkboxField stLens name label initialState =+checkboxField = checkboxCustomField '[' 'X' ']'++-- | A form field for manipulating a boolean value. This represents+-- 'True' as @[X] label@ and 'False' as @[ ] label@. This function+-- permits the customization of the @[X]@ notation characters.+--+-- This field responds to `Space` keypresses to toggle the checkbox and+-- to mouse clicks.+checkboxCustomField :: (Ord n, Show n)+                    => Char+                    -- ^ Left bracket character.+                    -> Char+                    -- ^ Checkmark character.+                    -> Char+                    -- ^ Right bracket character.+                    -> Lens' s Bool+                    -- ^ The state lens for this value.+                    -> n+                    -- ^ The resource name for the input field.+                    -> T.Text+                    -- ^ The label for the check box, to appear at its right.+                    -> s+                    -- ^ The initial form state.+                    -> FormFieldState s e n+checkboxCustomField lb check rb stLens name label initialState =     let initVal = initialState ^. stLens          handleEvent (MouseDown n _ _ _) s | n == name = return $ not s@@ -276,7 +303,7 @@      in FormFieldState { formFieldState        = initVal                       , formFields            = [ FormField name Just True-                                                            (renderCheckbox label name)+                                                            (renderCheckbox lb check rb label name)                                                             handleEvent                                                 ]                       , formFieldLens         = stLens@@ -284,12 +311,14 @@                       , formFieldConcat       = vBox                       } -renderCheckbox :: T.Text -> n -> Bool -> Bool -> Widget n-renderCheckbox label n foc val =+renderCheckbox :: Char -> Char -> Char -> T.Text -> n -> Bool -> Bool -> Widget n+renderCheckbox lb check rb label n foc val =     let addAttr = if foc then withDefAttr focusedFormInputAttr else id+        csr = if foc then showCursor n (Location (1,0)) else id     in clickable n $-       addAttr $-       (str $ "[" <> (if val then "X" else " ") <> "] ") <+> txt label+       addAttr $ csr $+       (txt $ T.singleton lb <> (if val then T.singleton check else " ") <>+              T.singleton rb <> " ") <+> txt label  -- | A form field for selecting a single choice from a set of possible -- choices in a scrollable list. This uses a 'List' internally.@@ -349,7 +378,27 @@            -> s            -- ^ The initial form state.            -> FormFieldState s e n-radioField stLens options initialState =+radioField = radioCustomField '[' '*' ']'++-- | A form field for selecting a single choice from a set of possible+-- choices. Each choice has an associated value and text label. This+-- function permits the customization of the @[*]@ notation characters.+--+-- This field responds to `Space` keypresses to select a radio button+-- option and to mouse clicks.+radioCustomField :: (Ord n, Show n, Eq a)+                 => Char+                 -> Char+                 -> Char+                 -> Lens' s a+                 -- ^ The state lens for this value.+                 -> [(a, n, T.Text)]+                 -- ^ The available choices, in order. Each choice has a value+                 -- of type @a@, a resource name, and a text label.+                 -> s+                 -- ^ The initial form state.+                 -> FormFieldState s e n+radioCustomField lb check rb stLens options initialState =     let initVal = initialState ^. stLens          lookupOptionValue n =@@ -370,7 +419,7 @@             FormField name                       Just                       True-                      (renderRadio val name label)+                      (renderRadio lb check rb val name label)                       (handleEvent val)      in FormFieldState { formFieldState        = initVal@@ -380,17 +429,18 @@                       , formFieldConcat       = vBox                       } -renderRadio :: (Eq a) => a -> n -> T.Text -> Bool -> a -> Widget n-renderRadio val name label foc cur =+renderRadio :: (Eq a) => Char -> Char -> Char -> a -> n -> T.Text -> Bool -> a -> Widget n+renderRadio lb check rb val name label foc cur =     let addAttr = if foc                   then withDefAttr focusedFormInputAttr                   else id         isSet = val == cur+        csr = if foc then showCursor name (Location (1,0)) else id     in clickable name $-       addAttr $-       hBox [ str "["-            , str $ if isSet then "*" else " "-            , txt $ "] " <> label+       addAttr $ csr $+       hBox [ txt $ T.singleton lb+            , txt $ if isSet then T.singleton check else " "+            , txt $ T.singleton rb <> " " <> label             ]  -- | A form field for using an editor to edit the text representation of