brick 2.1.1 → 2.2
raw patch · 8 files changed
+106/−24 lines, 8 filesdep −vty-unixPVP ok
version bump matches the API change (PVP)
Dependencies removed: vty-unix
API changes (from Hackage documentation)
+ Brick.Forms: ShowAugmentedField :: FormFieldVisibilityMode
+ Brick.Forms: ShowFocusedFieldOnly :: FormFieldVisibilityMode
+ Brick.Forms: data FormFieldVisibilityMode
+ Brick.Forms: instance GHC.Classes.Eq Brick.Forms.FormFieldVisibilityMode
+ Brick.Forms: instance GHC.Show.Show Brick.Forms.FormFieldVisibilityMode
+ Brick.Forms: setFieldVisibilityMode :: Eq n => n -> FormFieldVisibilityMode -> Form s e n -> Form s e n
- Brick.BorderMap: eBottomL :: forall a_agjP. Lens' (Edges a_agjP) a_agjP
+ Brick.BorderMap: eBottomL :: forall a_af2e. Lens' (Edges a_af2e) a_af2e
- Brick.BorderMap: eLeftL :: forall a_agjP. Lens' (Edges a_agjP) a_agjP
+ Brick.BorderMap: eLeftL :: forall a_af2e. Lens' (Edges a_af2e) a_af2e
- Brick.BorderMap: eRightL :: forall a_agjP. Lens' (Edges a_agjP) a_agjP
+ Brick.BorderMap: eRightL :: forall a_af2e. Lens' (Edges a_af2e) a_af2e
- Brick.BorderMap: eTopL :: forall a_agjP. Lens' (Edges a_agjP) a_agjP
+ Brick.BorderMap: eTopL :: forall a_af2e. Lens' (Edges a_af2e) a_af2e
- Brick.Forms: [FormFieldState] :: b -> Lens' s a -> (a -> b -> b) -> [FormField a b e n] -> (Widget n -> Widget n) -> ([Widget n] -> Widget n) -> FormFieldState s e n
+ Brick.Forms: [FormFieldState] :: b -> Lens' s a -> (a -> b -> b) -> [FormField a b e n] -> (Widget n -> Widget n) -> ([Widget n] -> Widget n) -> FormFieldVisibilityMode -> FormFieldState s e n
- Brick.Types: availHeightL :: forall n_awxS. Lens' (Context n_awxS) Int
+ Brick.Types: availHeightL :: forall n_asX9. Lens' (Context n_asX9) Int
- Brick.Types: availWidthL :: forall n_awxS. Lens' (Context n_awxS) Int
+ Brick.Types: availWidthL :: forall n_asX9. Lens' (Context n_asX9) Int
- Brick.Types: bordersL :: forall n_awxW. Lens' (Result n_awxW) (BorderMap DynBorder)
+ Brick.Types: bordersL :: forall n_asXd. Lens' (Result n_asXd) (BorderMap DynBorder)
- Brick.Types: ctxAttrMapL :: forall n_awxS. Lens' (Context n_awxS) AttrMap
+ Brick.Types: ctxAttrMapL :: forall n_asX9. Lens' (Context n_asX9) AttrMap
- Brick.Types: ctxAttrNameL :: forall n_awxS. Lens' (Context n_awxS) AttrName
+ Brick.Types: ctxAttrNameL :: forall n_asX9. Lens' (Context n_asX9) AttrName
- Brick.Types: ctxBorderStyleL :: forall n_awxS. Lens' (Context n_awxS) BorderStyle
+ Brick.Types: ctxBorderStyleL :: forall n_asX9. Lens' (Context n_asX9) BorderStyle
- Brick.Types: ctxDynBordersL :: forall n_awxS. Lens' (Context n_awxS) Bool
+ Brick.Types: ctxDynBordersL :: forall n_asX9. Lens' (Context n_asX9) Bool
- Brick.Types: ctxHScrollBarOrientationL :: forall n_awxS. Lens' (Context n_awxS) (Maybe HScrollBarOrientation)
+ Brick.Types: ctxHScrollBarOrientationL :: forall n_asX9. Lens' (Context n_asX9) (Maybe HScrollBarOrientation)
- Brick.Types: ctxHScrollBarRendererL :: forall n_awxS. Lens' (Context n_awxS) (Maybe (HScrollbarRenderer n_awxS))
+ Brick.Types: ctxHScrollBarRendererL :: forall n_asX9. Lens' (Context n_asX9) (Maybe (HScrollbarRenderer n_asX9))
- Brick.Types: ctxVScrollBarOrientationL :: forall n_awxS. Lens' (Context n_awxS) (Maybe VScrollBarOrientation)
+ Brick.Types: ctxVScrollBarOrientationL :: forall n_asX9. Lens' (Context n_asX9) (Maybe VScrollBarOrientation)
- Brick.Types: ctxVScrollBarRendererL :: forall n_awxS. Lens' (Context n_awxS) (Maybe (VScrollbarRenderer n_awxS))
+ Brick.Types: ctxVScrollBarRendererL :: forall n_asX9. Lens' (Context n_asX9) (Maybe (VScrollbarRenderer n_asX9))
- Brick.Types: cursorLocationL :: forall n_awxX. Lens' (CursorLocation n_awxX) Location
+ Brick.Types: cursorLocationL :: forall n_asXe. Lens' (CursorLocation n_asXe) Location
- Brick.Types: cursorLocationNameL :: forall n_awxX n_az7z. Lens (CursorLocation n_awxX) (CursorLocation n_az7z) (Maybe n_awxX) (Maybe n_az7z)
+ Brick.Types: cursorLocationNameL :: forall n_asXe n_avwz. Lens (CursorLocation n_asXe) (CursorLocation n_avwz) (Maybe n_asXe) (Maybe n_avwz)
- Brick.Types: cursorsL :: forall n_awxW. Lens' (Result n_awxW) [CursorLocation n_awxW]
+ Brick.Types: cursorsL :: forall n_asXd. Lens' (Result n_asXd) [CursorLocation n_asXd]
- Brick.Types: eBottomL :: forall a_agjP. Lens' (Edges a_agjP) a_agjP
+ Brick.Types: eBottomL :: forall a_af2e. Lens' (Edges a_af2e) a_af2e
- Brick.Types: eLeftL :: forall a_agjP. Lens' (Edges a_agjP) a_agjP
+ Brick.Types: eLeftL :: forall a_af2e. Lens' (Edges a_af2e) a_af2e
- Brick.Types: eRightL :: forall a_agjP. Lens' (Edges a_agjP) a_agjP
+ Brick.Types: eRightL :: forall a_af2e. Lens' (Edges a_af2e) a_af2e
- Brick.Types: eTopL :: forall a_agjP. Lens' (Edges a_agjP) a_agjP
+ Brick.Types: eTopL :: forall a_af2e. Lens' (Edges a_af2e) a_af2e
- Brick.Types: extentsL :: forall n_awxW. Lens' (Result n_awxW) [Extent n_awxW]
+ Brick.Types: extentsL :: forall n_asXd. Lens' (Result n_asXd) [Extent n_asXd]
- Brick.Types: imageL :: forall n_awxW. Lens' (Result n_awxW) Image
+ Brick.Types: imageL :: forall n_asXd. Lens' (Result n_asXd) Image
- Brick.Types: visibilityRequestsL :: forall n_awxW. Lens' (Result n_awxW) [VisibilityRequest]
+ Brick.Types: visibilityRequestsL :: forall n_asXd. Lens' (Result n_asXd) [VisibilityRequest]
- Brick.Types: windowHeightL :: forall n_awxS. Lens' (Context n_awxS) Int
+ Brick.Types: windowHeightL :: forall n_asX9. Lens' (Context n_asX9) Int
- Brick.Types: windowWidthL :: forall n_awxS. Lens' (Context n_awxS) Int
+ Brick.Types: windowWidthL :: forall n_asX9. Lens' (Context n_asX9) Int
- Brick.Widgets.Dialog: dialogButtonsL :: forall a_a1riV n_a1riW a_a1rjT. Lens (Dialog a_a1riV n_a1riW) (Dialog a_a1rjT n_a1riW) [(String, n_a1riW, a_a1riV)] [(String, n_a1riW, a_a1rjT)]
+ Brick.Widgets.Dialog: dialogButtonsL :: forall a_a1fxF n_a1fxG a_a1fyD. Lens (Dialog a_a1fxF n_a1fxG) (Dialog a_a1fyD n_a1fxG) [(String, n_a1fxG, a_a1fxF)] [(String, n_a1fxG, a_a1fyD)]
- Brick.Widgets.Dialog: dialogTitleL :: forall a_a1riV n_a1riW. Lens' (Dialog a_a1riV n_a1riW) (Maybe (Widget n_a1riW))
+ Brick.Widgets.Dialog: dialogTitleL :: forall a_a1fxF n_a1fxG. Lens' (Dialog a_a1fxF n_a1fxG) (Maybe (Widget n_a1fxG))
- Brick.Widgets.Dialog: dialogWidthL :: forall a_a1riV n_a1riW. Lens' (Dialog a_a1riV n_a1riW) Int
+ Brick.Widgets.Dialog: dialogWidthL :: forall a_a1fxF n_a1fxG. Lens' (Dialog a_a1fxF n_a1fxG) Int
- Brick.Widgets.Edit: editContentsL :: forall t_a1jrt n_a1jru t_a1jse. Lens (Editor t_a1jrt n_a1jru) (Editor t_a1jse n_a1jru) (TextZipper t_a1jrt) (TextZipper t_a1jse)
+ Brick.Widgets.Edit: editContentsL :: forall t_a18Gr n_a18Gs t_a18Hc. Lens (Editor t_a18Gr n_a18Gs) (Editor t_a18Hc n_a18Gs) (TextZipper t_a18Gr) (TextZipper t_a18Hc)
- Brick.Widgets.FileBrowser: fileBrowserEntriesG :: forall n_a1E1c. SimpleGetter (FileBrowser n_a1E1c) (List n_a1E1c FileInfo)
+ Brick.Widgets.FileBrowser: fileBrowserEntriesG :: forall n_a1qaa. SimpleGetter (FileBrowser n_a1qaa) (List n_a1qaa FileInfo)
- Brick.Widgets.FileBrowser: fileBrowserEntryFilterG :: forall n_a1E1c. SimpleGetter (FileBrowser n_a1E1c) (Maybe (FileInfo -> Bool))
+ Brick.Widgets.FileBrowser: fileBrowserEntryFilterG :: forall n_a1qaa. SimpleGetter (FileBrowser n_a1qaa) (Maybe (FileInfo -> Bool))
- Brick.Widgets.FileBrowser: fileBrowserExceptionG :: forall n_a1E1c. SimpleGetter (FileBrowser n_a1E1c) (Maybe IOException)
+ Brick.Widgets.FileBrowser: fileBrowserExceptionG :: forall n_a1qaa. SimpleGetter (FileBrowser n_a1qaa) (Maybe IOException)
- Brick.Widgets.FileBrowser: fileBrowserLatestResultsG :: forall n_a1E1c. SimpleGetter (FileBrowser n_a1E1c) [FileInfo]
+ Brick.Widgets.FileBrowser: fileBrowserLatestResultsG :: forall n_a1qaa. SimpleGetter (FileBrowser n_a1qaa) [FileInfo]
- Brick.Widgets.FileBrowser: fileBrowserNameG :: forall n_a1E1c. SimpleGetter (FileBrowser n_a1E1c) n_a1E1c
+ Brick.Widgets.FileBrowser: fileBrowserNameG :: forall n_a1qaa. SimpleGetter (FileBrowser n_a1qaa) n_a1qaa
- Brick.Widgets.FileBrowser: fileBrowserSearchStringG :: forall n_a1E1c. SimpleGetter (FileBrowser n_a1E1c) (Maybe Text)
+ Brick.Widgets.FileBrowser: fileBrowserSearchStringG :: forall n_a1qaa. SimpleGetter (FileBrowser n_a1qaa) (Maybe Text)
- Brick.Widgets.FileBrowser: fileBrowserSelectableG :: forall n_a1E1c. SimpleGetter (FileBrowser n_a1E1c) (FileInfo -> Bool)
+ Brick.Widgets.FileBrowser: fileBrowserSelectableG :: forall n_a1qaa. SimpleGetter (FileBrowser n_a1qaa) (FileInfo -> Bool)
- Brick.Widgets.FileBrowser: fileBrowserSelectableL :: forall n_a1E1c. Lens' (FileBrowser n_a1E1c) (FileInfo -> Bool)
+ Brick.Widgets.FileBrowser: fileBrowserSelectableL :: forall n_a1qaa. Lens' (FileBrowser n_a1qaa) (FileInfo -> Bool)
- Brick.Widgets.FileBrowser: fileBrowserSelectedFilesG :: forall n_a1E1c. SimpleGetter (FileBrowser n_a1E1c) (Set String)
+ Brick.Widgets.FileBrowser: fileBrowserSelectedFilesG :: forall n_a1qaa. SimpleGetter (FileBrowser n_a1qaa) (Set String)
- Brick.Widgets.FileBrowser: fileBrowserWorkingDirectoryG :: forall n_a1E1c. SimpleGetter (FileBrowser n_a1E1c) FilePath
+ Brick.Widgets.FileBrowser: fileBrowserWorkingDirectoryG :: forall n_a1qaa. SimpleGetter (FileBrowser n_a1qaa) FilePath
- Brick.Widgets.List: listElementsL :: forall n_a1xEj t_a1xEk e_a1xEl t_a1xTU e_a1xTV. Lens (GenericList n_a1xEj t_a1xEk e_a1xEl) (GenericList n_a1xEj t_a1xTU e_a1xTV) (t_a1xEk e_a1xEl) (t_a1xTU e_a1xTV)
+ Brick.Widgets.List: listElementsL :: forall n_a1kCa t_a1kCb e_a1kCc t_a1kRL e_a1kRM. Lens (GenericList n_a1kCa t_a1kCb e_a1kCc) (GenericList n_a1kCa t_a1kRL e_a1kRM) (t_a1kCb e_a1kCc) (t_a1kRL e_a1kRM)
- Brick.Widgets.List: listItemHeightL :: forall n_a1xEj t_a1xEk e_a1xEl. Lens' (GenericList n_a1xEj t_a1xEk e_a1xEl) Int
+ Brick.Widgets.List: listItemHeightL :: forall n_a1kCa t_a1kCb e_a1kCc. Lens' (GenericList n_a1kCa t_a1kCb e_a1kCc) Int
- Brick.Widgets.List: listNameL :: forall n_a1xEj t_a1xEk e_a1xEl n_a1xTW. Lens (GenericList n_a1xEj t_a1xEk e_a1xEl) (GenericList n_a1xTW t_a1xEk e_a1xEl) n_a1xEj n_a1xTW
+ Brick.Widgets.List: listNameL :: forall n_a1kCa t_a1kCb e_a1kCc n_a1kRN. Lens (GenericList n_a1kCa t_a1kCb e_a1kCc) (GenericList n_a1kRN t_a1kCb e_a1kCc) n_a1kCa n_a1kRN
- Brick.Widgets.List: listSelectedL :: forall n_a1xEj t_a1xEk e_a1xEl. Lens' (GenericList n_a1xEj t_a1xEk e_a1xEl) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: forall n_a1kCa t_a1kCb e_a1kCc. Lens' (GenericList n_a1kCa t_a1kCb e_a1kCc) (Maybe Int)
Files
- CHANGELOG.md +12/−0
- brick.cabal +2/−2
- docs/guide.rst +1/−1
- programs/TailDemo.hs +0/−1
- src/Brick/Forms.hs +86/−15
- src/Brick/Main.hs +2/−2
- tests/Main.hs +1/−0
- tests/Render.hs +2/−3
CHANGELOG.md view
@@ -2,6 +2,18 @@ Brick changelog --------------- +2.2+---++Enhancements:+* `Brick.Forms` got a new `FormFieldVisibilityMode` type and a+ `setFieldVisibilityMode` function to allow greater control over+ how form field collections are brought into view when forms are+ rendered in viewports. Form fields will default to using the+ `ShowFocusedFieldOnly` mode which preserves functionality prior to+ this release. To get the new behavior, set a field's visibility mode+ to `ShowAugmentedField`.+ 2.1.1 -----
brick.cabal view
@@ -1,5 +1,5 @@ name: brick-version: 2.1.1+version: 2.2 synopsis: A declarative terminal user interface library description: Write terminal user interfaces (TUIs) painlessly with 'brick'! You@@ -575,5 +575,5 @@ microlens, vector, vty,- vty-unix,+ vty-crossplatform, QuickCheck
docs/guide.rst view
@@ -298,7 +298,7 @@ .. code:: haskell - data MyState = MyState { _editor :: Editor Text n }+ data MyState n = MyState { _editor :: Editor Text n } makeLenses ''MyState This declares the ``MyState`` type with an ``Editor`` contained within
programs/TailDemo.hs view
@@ -16,7 +16,6 @@ import Brick.BChan import Brick.Widgets.Border import qualified Graphics.Vty as V-import Graphics.Vty.CrossPlatform (mkVty) data AppState = AppState { _textAreaHeight :: Int
src/Brick/Forms.hs view
@@ -49,6 +49,7 @@ Form , FormFieldState(..) , FormField(..)+ , FormFieldVisibilityMode(..) -- * Creating and using forms , newForm@@ -65,6 +66,7 @@ , setFieldConcat , setFormFocus , updateFormState+ , setFieldVisibilityMode -- * Simple form field constructors , editTextField@@ -145,6 +147,18 @@ -- ^ An event handler for this field. } +-- | How to bring form fields into view when a form is rendered in a+-- viewport with 'viewport'.+data FormFieldVisibilityMode =+ ShowFocusedFieldOnly+ -- ^ Make only the focused field's selected input visible. For+ -- composite fields this will not bring all options into view.+ | ShowAugmentedField+ -- ^ Make all inputs in the focused field visible. For composite+ -- fields this will bring all options into view as long as the+ -- viewport is large enough to show them all.+ deriving (Eq, Show)+ -- | A form field state accompanied by the fields that manipulate that -- state. The idea is that some record field in your form state has -- one or more form fields that manipulate that value. This data type@@ -189,6 +203,9 @@ , formFieldConcat :: [Widget n] -> Widget n -- ^ Concatenation function for this field's input -- renderings.+ , formFieldVisibilityMode :: FormFieldVisibilityMode+ -- ^ This field's visibility mode for use in+ -- viewports. } -> FormFieldState s e n -- | A form: a sequence of input fields that manipulate the fields of an@@ -250,8 +267,8 @@ updateFormState :: s -> Form s e n -> Form s e n updateFormState newState f = let updateField fs = case fs of- FormFieldState st l upd s rh concatAll ->- FormFieldState (upd (newState^.l) st) l upd s rh concatAll+ FormFieldState st l upd s rh concatAll visMode ->+ FormFieldState (upd (newState^.l) st) l upd s rh concatAll visMode in f { formState = newState , formFieldStates = updateField <$> formFieldStates f }@@ -287,7 +304,7 @@ } formFieldNames :: FormFieldState s e n -> [n]-formFieldNames (FormFieldState _ _ _ fields _ _) = formFieldName <$> fields+formFieldNames (FormFieldState _ _ _ fields _ _ _) = formFieldName <$> fields -- | A form field for manipulating a boolean value. This represents -- 'True' as @[X] label@ and 'False' as @[ ] label@.@@ -345,6 +362,7 @@ \val _ -> val , formFieldRenderHelper = id , formFieldConcat = vBox+ , formFieldVisibilityMode = ShowFocusedFieldOnly } renderCheckbox :: (Ord n) => Char -> Char -> Char -> T.Text -> n -> Bool -> Bool -> Widget n@@ -406,7 +424,9 @@ Just (_, e) -> listMoveToElement e l , formFieldRenderHelper = id , formFieldConcat = vBox+ , formFieldVisibilityMode = ShowFocusedFieldOnly }+ -- | A form field for selecting a single choice from a set of possible -- choices. Each choice has an associated value and text label. --@@ -474,6 +494,7 @@ , formFieldUpdate = \val _ -> val , formFieldRenderHelper = id , formFieldConcat = vBox+ , formFieldVisibilityMode = ShowFocusedFieldOnly } renderRadio :: (Eq a, Ord n) => Char -> Char -> Char -> a -> n -> T.Text -> Bool -> a -> Widget n@@ -548,6 +569,7 @@ else applyEdit (Z.insertMany newTxt . Z.clearZipper) e , formFieldRenderHelper = id , formFieldConcat = vBox+ , formFieldVisibilityMode = ShowFocusedFieldOnly } -- | A form field using a single-line editor to edit the 'Show'@@ -691,6 +713,46 @@ invalidFields :: Form s e n -> [n] invalidFields f = concatMap getInvalidFields (formFieldStates f) +-- | Set the visibility mode of the specified form field's collection+-- when the form is rendered in viewport. This is used to change how+-- focused fields are brought into view when they're outside of view+-- in a viewport and gain focus. In practice, this means this function+-- need only be called on one form field name in a collection in order+-- to affect the visibility behavior of that field's entire input+-- collection.+--+-- There are two visibility modes:+--+-- * 'ShowFocusedFieldOnly' - this is the default behavior. In this+-- mode, when a field receives focus, it is brought into view but+-- other inputs in the same field collection (e.g. a set of radio+-- buttons) will not be brought into view along with it.+--+-- * 'ShowAugmentedField' - in this mode, when a field receives focus,+-- all of the inputs in its collection (e.g. a set of radio buttons)+-- are brought into view as long as the viewport is large enough to+-- show them all. If it isn't, the viewport will show as many as space+-- allows.+setFieldVisibilityMode :: (Eq n)+ => n+ -- ^ The name of the form field whose visibility mode is to be set.+ -> FormFieldVisibilityMode+ -- ^ The mode to set.+ -> Form s e n+ -- ^ The form to modify.+ -> Form s e n+setFieldVisibilityMode n mode form =+ let go1 [] = []+ go1 (s:ss) =+ let s' = case s of+ FormFieldState st l upd fs rh concatAll _ ->+ if n `elem` formFieldNames s+ then FormFieldState st l upd fs rh concatAll mode+ else s+ in s' : go1 ss++ in form { formFieldStates = go1 (formFieldStates form) }+ -- | Manually indicate that a field has invalid contents. This can be -- useful in situations where validation beyond the form element's -- validator needs to be performed and the result of that validation@@ -707,18 +769,18 @@ let go1 [] = [] go1 (s:ss) = let s' = case s of- FormFieldState st l upd fs rh concatAll ->+ FormFieldState st l upd fs rh concatAll visMode -> let go2 [] = [] go2 (f@(FormField fn val _ r h):ff) | n == fn = FormField fn val v r h : ff | otherwise = f : go2 ff- in FormFieldState st l upd (go2 fs) rh concatAll+ in FormFieldState st l upd (go2 fs) rh concatAll visMode in s' : go1 ss in form { formFieldStates = go1 (formFieldStates form) } getInvalidFields :: FormFieldState s e n -> [n]-getInvalidFields (FormFieldState st _ _ fs _ _) =+getInvalidFields (FormFieldState st _ _ fs _ _ _) = let gather (FormField n validate extValid _ _) = if not extValid || isNothing (validate st) then [n] else [] in concatMap gather fs@@ -750,16 +812,22 @@ => FocusRing n -> FormFieldState s e n -> Widget n-renderFormFieldState fr (FormFieldState st _ _ fields helper concatFields) =- let renderFields [] = []+renderFormFieldState fr (FormFieldState st _ _ fields helper concatFields visMode) =+ let curFocus = focusGetCurrent fr+ foc = case curFocus of+ Nothing -> False+ Just n -> n `elem` fieldNames+ maybeVisible = if foc && visMode == ShowAugmentedField then visible else id+ renderFields [] = [] renderFields ((FormField n validate extValid renderField _):fs) = let maybeInvalid = if (isJust $ validate st) && extValid then id else forceAttr invalidFormInputAttr- foc = Just n == focusGetCurrent fr- maybeVisible = if foc then visible else id- in (maybeVisible $ maybeInvalid $ renderField foc st) : renderFields fs- in helper $ concatFields $ renderFields fields+ fieldFoc = Just n == curFocus+ maybeFieldVisible = if fieldFoc && visMode == ShowFocusedFieldOnly then visible else id+ in (n, maybeFieldVisible $ maybeInvalid $ renderField fieldFoc st) : renderFields fs+ (fieldNames, renderedFields) = unzip $ renderFields fields+ in helper $ maybeVisible $ concatFields renderedFields -- | Dispatch an event to the currently focused form field. This handles -- the following events in this order:@@ -835,7 +903,10 @@ i' = if i == 0 then length as - 1 else i - 1 in as !! i' -withFocusAndGrouping :: (Eq n) => BrickEvent n e -> (n -> [n] -> EventM n (Form s e n) ()) -> EventM n (Form s e n) ()+withFocusAndGrouping :: (Eq n)+ => BrickEvent n e+ -> (n -> [n] -> EventM n (Form s e n) ())+ -> EventM n (Form s e n) () withFocusAndGrouping e act = do foc <- gets formFocus case focusGetCurrent foc of@@ -862,7 +933,7 @@ let findFieldState _ [] = return () findFieldState prev (e:es) = case e of- FormFieldState st stLens upd fields helper concatAll -> do+ FormFieldState st stLens upd fields helper concatAll visMode -> do let findField [] = return Nothing findField (field:rest) = case field of@@ -879,7 +950,7 @@ case result of Nothing -> findFieldState (prev <> [e]) es Just (newSt, maybeSt) -> do- let newFieldState = FormFieldState newSt stLens upd fields helper concatAll+ let newFieldState = FormFieldState newSt stLens upd fields helper concatAll visMode formFieldStatesL .= prev <> [newFieldState] <> es case maybeSt of Nothing -> return ()
src/Brick/Main.hs view
@@ -123,8 +123,8 @@ } -- | The default main entry point which takes an application and an--- initial state and returns the final state returned by a 'halt'--- operation.+-- initial state and returns the final state from 'EventM' once the+-- program exits. defaultMain :: (Ord n) => App s e n -- ^ The application.
tests/Main.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-}
tests/Render.hs view
@@ -10,8 +10,7 @@ import Data.Monoid #endif import qualified Graphics.Vty as V-import qualified Graphics.Vty.Platform.Unix.Output as VU-import qualified Graphics.Vty.Platform.Unix.Settings as VU+import qualified Graphics.Vty.CrossPlatform.Testing as V import Brick.Widgets.Border (hBorder) import Control.Exception (SomeException, try) @@ -20,7 +19,7 @@ renderDisplay :: Ord n => [Widget n] -> IO () renderDisplay ws = do- outp <- VU.buildOutput =<< VU.defaultSettings+ outp <- V.mkDefaultOutput ctx <- V.displayContext outp region V.outputPicture ctx (renderWidget Nothing ws region) V.releaseDisplay outp