packages feed

brick 1.1 → 1.2

raw patch · 28 files changed

+84/−82 lines, 28 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

- Brick.BorderMap: eBottomL :: forall a_aeqk. Lens' (Edges a_aeqk) a_aeqk
+ Brick.BorderMap: eBottomL :: forall a_aeJj. Lens' (Edges a_aeJj) a_aeJj
- Brick.BorderMap: eLeftL :: forall a_aeqk. Lens' (Edges a_aeqk) a_aeqk
+ Brick.BorderMap: eLeftL :: forall a_aeJj. Lens' (Edges a_aeJj) a_aeJj
- Brick.BorderMap: eRightL :: forall a_aeqk. Lens' (Edges a_aeqk) a_aeqk
+ Brick.BorderMap: eRightL :: forall a_aeJj. Lens' (Edges a_aeJj) a_aeJj
- Brick.BorderMap: eTopL :: forall a_aeqk. Lens' (Edges a_aeqk) a_aeqk
+ Brick.BorderMap: eTopL :: forall a_aeJj. Lens' (Edges a_aeJj) a_aeJj
- Brick.Forms: [FormFieldState] :: {formFieldState :: b " The current state value associated with the field collection. Note that this type is existential. All form fields in the collection must validate to this type.", formFieldLens :: Lens' s a " A lens to extract and store a successfully-validated form input back into your form state.", formFieldUpdate :: a -> b -> b " Given a new form state value, update the form field state in place.", formFields :: [FormField a b e n] " The form fields, in order, that the user will interact with to manipulate this state value.", formFieldRenderHelper :: Widget n -> Widget n " A helper function to augment the rendered representation of this collection of form fields. It receives the default representation and can augment it, for example, by adding a label on the left.", formFieldConcat :: [Widget n] -> Widget n " Concatenation function for this field's input renderings."} -> 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) -> FormFieldState s e n
- Brick.Types: availHeightL :: forall n_axFd. Lens' (Context n_axFd) Int
+ Brick.Types: availHeightL :: forall n_azeL. Lens' (Context n_azeL) Int
- Brick.Types: availWidthL :: forall n_axFd. Lens' (Context n_axFd) Int
+ Brick.Types: availWidthL :: forall n_azeL. Lens' (Context n_azeL) Int
- Brick.Types: bordersL :: forall n_axFh. Lens' (Result n_axFh) (BorderMap DynBorder)
+ Brick.Types: bordersL :: forall n_azeP. Lens' (Result n_azeP) (BorderMap DynBorder)
- Brick.Types: ctxAttrMapL :: forall n_axFd. Lens' (Context n_axFd) AttrMap
+ Brick.Types: ctxAttrMapL :: forall n_azeL. Lens' (Context n_azeL) AttrMap
- Brick.Types: ctxAttrNameL :: forall n_axFd. Lens' (Context n_axFd) AttrName
+ Brick.Types: ctxAttrNameL :: forall n_azeL. Lens' (Context n_azeL) AttrName
- Brick.Types: ctxBorderStyleL :: forall n_axFd. Lens' (Context n_axFd) BorderStyle
+ Brick.Types: ctxBorderStyleL :: forall n_azeL. Lens' (Context n_azeL) BorderStyle
- Brick.Types: ctxDynBordersL :: forall n_axFd. Lens' (Context n_axFd) Bool
+ Brick.Types: ctxDynBordersL :: forall n_azeL. Lens' (Context n_azeL) Bool
- Brick.Types: ctxHScrollBarOrientationL :: forall n_axFd. Lens' (Context n_axFd) (Maybe HScrollBarOrientation)
+ Brick.Types: ctxHScrollBarOrientationL :: forall n_azeL. Lens' (Context n_azeL) (Maybe HScrollBarOrientation)
- Brick.Types: ctxHScrollBarRendererL :: forall n_axFd. Lens' (Context n_axFd) (Maybe (ScrollbarRenderer n_axFd))
+ Brick.Types: ctxHScrollBarRendererL :: forall n_azeL. Lens' (Context n_azeL) (Maybe (ScrollbarRenderer n_azeL))
- Brick.Types: ctxVScrollBarOrientationL :: forall n_axFd. Lens' (Context n_axFd) (Maybe VScrollBarOrientation)
+ Brick.Types: ctxVScrollBarOrientationL :: forall n_azeL. Lens' (Context n_azeL) (Maybe VScrollBarOrientation)
- Brick.Types: ctxVScrollBarRendererL :: forall n_axFd. Lens' (Context n_axFd) (Maybe (ScrollbarRenderer n_axFd))
+ Brick.Types: ctxVScrollBarRendererL :: forall n_azeL. Lens' (Context n_azeL) (Maybe (ScrollbarRenderer n_azeL))
- Brick.Types: cursorLocationL :: forall n_axFi. Lens' (CursorLocation n_axFi) Location
+ Brick.Types: cursorLocationL :: forall n_azeQ. Lens' (CursorLocation n_azeQ) Location
- Brick.Types: cursorLocationNameL :: forall n_axFi n_azO5. Lens (CursorLocation n_axFi) (CursorLocation n_azO5) (Maybe n_axFi) (Maybe n_azO5)
+ Brick.Types: cursorLocationNameL :: forall n_azeQ n_aBEH. Lens (CursorLocation n_azeQ) (CursorLocation n_aBEH) (Maybe n_azeQ) (Maybe n_aBEH)
- Brick.Types: cursorsL :: forall n_axFh. Lens' (Result n_axFh) [CursorLocation n_axFh]
+ Brick.Types: cursorsL :: forall n_azeP. Lens' (Result n_azeP) [CursorLocation n_azeP]
- Brick.Types: eBottomL :: forall a_aeqk. Lens' (Edges a_aeqk) a_aeqk
+ Brick.Types: eBottomL :: forall a_aeJj. Lens' (Edges a_aeJj) a_aeJj
- Brick.Types: eLeftL :: forall a_aeqk. Lens' (Edges a_aeqk) a_aeqk
+ Brick.Types: eLeftL :: forall a_aeJj. Lens' (Edges a_aeJj) a_aeJj
- Brick.Types: eRightL :: forall a_aeqk. Lens' (Edges a_aeqk) a_aeqk
+ Brick.Types: eRightL :: forall a_aeJj. Lens' (Edges a_aeJj) a_aeJj
- Brick.Types: eTopL :: forall a_aeqk. Lens' (Edges a_aeqk) a_aeqk
+ Brick.Types: eTopL :: forall a_aeJj. Lens' (Edges a_aeJj) a_aeJj
- Brick.Types: extentsL :: forall n_axFh. Lens' (Result n_axFh) [Extent n_axFh]
+ Brick.Types: extentsL :: forall n_azeP. Lens' (Result n_azeP) [Extent n_azeP]
- Brick.Types: imageL :: forall n_axFh. Lens' (Result n_axFh) Image
+ Brick.Types: imageL :: forall n_azeP. Lens' (Result n_azeP) Image
- Brick.Types: visibilityRequestsL :: forall n_axFh. Lens' (Result n_axFh) [VisibilityRequest]
+ Brick.Types: visibilityRequestsL :: forall n_azeP. Lens' (Result n_azeP) [VisibilityRequest]
- Brick.Types: windowHeightL :: forall n_axFd. Lens' (Context n_axFd) Int
+ Brick.Types: windowHeightL :: forall n_azeL. Lens' (Context n_azeL) Int
- Brick.Types: windowWidthL :: forall n_axFd. Lens' (Context n_axFd) Int
+ Brick.Types: windowWidthL :: forall n_azeL. Lens' (Context n_azeL) Int
- Brick.Widgets.Dialog: dialogButtonsL :: forall a_a1i3s a_a1i46. Lens (Dialog a_a1i3s) (Dialog a_a1i46) [(String, a_a1i3s)] [(String, a_a1i46)]
+ Brick.Widgets.Dialog: dialogButtonsL :: forall a_a1kw7 a_a1kwL. Lens (Dialog a_a1kw7) (Dialog a_a1kwL) [(String, a_a1kw7)] [(String, a_a1kwL)]
- Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a1i3s. Lens' (Dialog a_a1i3s) (Maybe Int)
+ Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a1kw7. Lens' (Dialog a_a1kw7) (Maybe Int)
- Brick.Widgets.Dialog: dialogTitleL :: forall a_a1i3s. Lens' (Dialog a_a1i3s) (Maybe String)
+ Brick.Widgets.Dialog: dialogTitleL :: forall a_a1kw7. Lens' (Dialog a_a1kw7) (Maybe String)
- Brick.Widgets.Dialog: dialogWidthL :: forall a_a1i3s. Lens' (Dialog a_a1i3s) Int
+ Brick.Widgets.Dialog: dialogWidthL :: forall a_a1kw7. Lens' (Dialog a_a1kw7) Int
- Brick.Widgets.Edit: editContentsL :: forall t_a1c6o n_a1c6p t_a1c73. Lens (Editor t_a1c6o n_a1c6p) (Editor t_a1c73 n_a1c6p) (TextZipper t_a1c6o) (TextZipper t_a1c73)
+ Brick.Widgets.Edit: editContentsL :: forall t_a1enE n_a1enF t_a1eoj. Lens (Editor t_a1enE n_a1enF) (Editor t_a1eoj n_a1enF) (TextZipper t_a1enE) (TextZipper t_a1eoj)
- Brick.Widgets.FileBrowser: fileBrowserEntriesG :: forall n_a1thx. SimpleGetter (FileBrowser n_a1thx) (List n_a1thx FileInfo)
+ Brick.Widgets.FileBrowser: fileBrowserEntriesG :: forall n_a1w47. SimpleGetter (FileBrowser n_a1w47) (List n_a1w47 FileInfo)
- Brick.Widgets.FileBrowser: fileBrowserEntryFilterG :: forall n_a1thx. SimpleGetter (FileBrowser n_a1thx) (Maybe (FileInfo -> Bool))
+ Brick.Widgets.FileBrowser: fileBrowserEntryFilterG :: forall n_a1w47. SimpleGetter (FileBrowser n_a1w47) (Maybe (FileInfo -> Bool))
- Brick.Widgets.FileBrowser: fileBrowserExceptionG :: forall n_a1thx. SimpleGetter (FileBrowser n_a1thx) (Maybe IOException)
+ Brick.Widgets.FileBrowser: fileBrowserExceptionG :: forall n_a1w47. SimpleGetter (FileBrowser n_a1w47) (Maybe IOException)
- Brick.Widgets.FileBrowser: fileBrowserLatestResultsG :: forall n_a1thx. SimpleGetter (FileBrowser n_a1thx) [FileInfo]
+ Brick.Widgets.FileBrowser: fileBrowserLatestResultsG :: forall n_a1w47. SimpleGetter (FileBrowser n_a1w47) [FileInfo]
- Brick.Widgets.FileBrowser: fileBrowserNameG :: forall n_a1thx. SimpleGetter (FileBrowser n_a1thx) n_a1thx
+ Brick.Widgets.FileBrowser: fileBrowserNameG :: forall n_a1w47. SimpleGetter (FileBrowser n_a1w47) n_a1w47
- Brick.Widgets.FileBrowser: fileBrowserSearchStringG :: forall n_a1thx. SimpleGetter (FileBrowser n_a1thx) (Maybe Text)
+ Brick.Widgets.FileBrowser: fileBrowserSearchStringG :: forall n_a1w47. SimpleGetter (FileBrowser n_a1w47) (Maybe Text)
- Brick.Widgets.FileBrowser: fileBrowserSelectableG :: forall n_a1thx. SimpleGetter (FileBrowser n_a1thx) (FileInfo -> Bool)
+ Brick.Widgets.FileBrowser: fileBrowserSelectableG :: forall n_a1w47. SimpleGetter (FileBrowser n_a1w47) (FileInfo -> Bool)
- Brick.Widgets.FileBrowser: fileBrowserSelectableL :: forall n_a1thx. Lens' (FileBrowser n_a1thx) (FileInfo -> Bool)
+ Brick.Widgets.FileBrowser: fileBrowserSelectableL :: forall n_a1w47. Lens' (FileBrowser n_a1w47) (FileInfo -> Bool)
- Brick.Widgets.FileBrowser: fileBrowserSelectedFilesG :: forall n_a1thx. SimpleGetter (FileBrowser n_a1thx) (Set String)
+ Brick.Widgets.FileBrowser: fileBrowserSelectedFilesG :: forall n_a1w47. SimpleGetter (FileBrowser n_a1w47) (Set String)
- Brick.Widgets.FileBrowser: fileBrowserWorkingDirectoryG :: forall n_a1thx. SimpleGetter (FileBrowser n_a1thx) FilePath
+ Brick.Widgets.FileBrowser: fileBrowserWorkingDirectoryG :: forall n_a1w47. SimpleGetter (FileBrowser n_a1w47) FilePath
- Brick.Widgets.List: listElementsL :: forall n_a1o5R t_a1o5S e_a1o5T t_a1ok4 e_a1ok5. Lens (GenericList n_a1o5R t_a1o5S e_a1o5T) (GenericList n_a1o5R t_a1ok4 e_a1ok5) (t_a1o5S e_a1o5T) (t_a1ok4 e_a1ok5)
+ Brick.Widgets.List: listElementsL :: forall n_a1qxt t_a1qxu e_a1qxv t_a1qMG e_a1qMH. Lens (GenericList n_a1qxt t_a1qxu e_a1qxv) (GenericList n_a1qxt t_a1qMG e_a1qMH) (t_a1qxu e_a1qxv) (t_a1qMG e_a1qMH)
- Brick.Widgets.List: listItemHeightL :: forall n_a1o5R t_a1o5S e_a1o5T. Lens' (GenericList n_a1o5R t_a1o5S e_a1o5T) Int
+ Brick.Widgets.List: listItemHeightL :: forall n_a1qxt t_a1qxu e_a1qxv. Lens' (GenericList n_a1qxt t_a1qxu e_a1qxv) Int
- Brick.Widgets.List: listNameL :: forall n_a1o5R t_a1o5S e_a1o5T n_a1ok6. Lens (GenericList n_a1o5R t_a1o5S e_a1o5T) (GenericList n_a1ok6 t_a1o5S e_a1o5T) n_a1o5R n_a1ok6
+ Brick.Widgets.List: listNameL :: forall n_a1qxt t_a1qxu e_a1qxv n_a1qMI. Lens (GenericList n_a1qxt t_a1qxu e_a1qxv) (GenericList n_a1qMI t_a1qxu e_a1qxv) n_a1qxt n_a1qMI
- Brick.Widgets.List: listSelectedL :: forall n_a1o5R t_a1o5S e_a1o5T. Lens' (GenericList n_a1o5R t_a1o5S e_a1o5T) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: forall n_a1qxt t_a1qxu e_a1qxv. Lens' (GenericList n_a1qxt t_a1qxu e_a1qxv) (Maybe Int)

Files

CHANGELOG.md view
@@ -2,6 +2,15 @@ Brick changelog --------------- +1.2+---++Package changes:+* Supports base 4.17 (GHC 9.4).++Bug fixes:+* `newFileBrowser` now normalizes its initial path (#387).+ 1.1 --- 
brick.cabal view
@@ -1,5 +1,5 @@ name:                brick-version:             1.1+version:             1.2 synopsis:            A declarative terminal user interface library description:   Write terminal user interfaces (TUIs) painlessly with 'brick'! You@@ -38,7 +38,7 @@ cabal-version:       1.18 Homepage:            https://github.com/jtdaugherty/brick/ Bug-reports:         https://github.com/jtdaugherty/brick/issues-tested-with:         GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.1+tested-with:         GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.2, GHC == 9.2.4, GHC == 9.4.2  extra-doc-files:     README.md,                      docs/guide.rst,@@ -118,7 +118,7 @@     Brick.Types.Internal     Brick.Widgets.Internal -  build-depends:       base >= 4.9.0.0 && < 4.17.0.0,+  build-depends:       base >= 4.9.0.0 && < 4.18.0.0,                        vty >= 5.36,                        bimap >= 0.5 && < 0.6,                        data-clist >= 0.1,
docs/guide.rst view
@@ -11,7 +11,8 @@ and as direct as possible. ``brick`` builds on `vty`_; `vty` provides the terminal input and output interface and drawing primitives, while ``brick`` builds on those to provide a high-level application-abstraction and combinators for expressing user interface layouts.+abstraction, combinators for expressing user interface layouts, and+infrastructure for handling events.  This documentation is intended to provide a high-level overview of the library's design along with guidance for using it, but details on@@ -30,9 +31,9 @@ attributes (e.g. foreground color), and express layout constraints (e.g. padding, centering, box layouts, scrolling viewports, etc.). -These functions get packaged into a structure that we hand off to the-``brick`` library's main event loop. We'll cover that in detail in `The-App Type`_.+These functions get packaged into an ``App`` structure that we hand off+to the ``brick`` library's main event loop. We'll cover that in detail+in `The App Type`_.  Installation ------------@@ -76,7 +77,7 @@   you it is a lens; the name without the "``L``" suffix is the non-lens   version. You can get by without using ``brick``'s lens interface   but your life will probably be much more pleasant if you use lenses-  to modify your application state once it state becomes sufficiently+  to modify your application state once it becomes sufficiently   complex (see `appHandleEvent: Handling Events`_ and `Event Handlers   for Component State`_). - Attribute names: some modules export attribute names (see `How@@ -247,7 +248,7 @@   the screen to change. Use this only when you are certain that no   redraw of the screen is needed *and* when you are trying to address a   performance problem. (See also `The Rendering Cache`_ for details on-  how to detail with rendering performance issues.)+  how to deal with rendering performance issues.)  The ``EventM`` monad is a transformer around ``IO`` so I/O is possible in this monad by using ``liftIO``. Keep in mind, however, that event@@ -844,7 +845,7 @@ can be independently specified to have an explicit value, and any component not explicitly specified can default to whatever the terminal is currently using. Vty styles can be combined together, e.g. underline-and bold, so styles are cummulative.+and bold, so styles are cumulative.  What if a widget attempts to draw with an attribute name that is not specified in the map at all? In that case, the attribute map's "default@@ -974,7 +975,7 @@ Wide characters are those such as many Asian characters and emoji that need more than a single terminal column to be displayed. -Unfortunatley, there is not a fully correct solution to determining+Unfortunately, there is not a fully correct solution to determining the character width that the user's terminal will use for a given character. The current recommendation is to avoid use of wide characters due to these issues. If you still must use them, you can read `vty`_'s@@ -998,7 +999,7 @@    let width = Brick.Widgets.Core.textWidth t  The ``TextWidth`` type class uses Vty's character width routine to-compute the width by looking up the string's characdters in a Unicode+compute the width by looking up the string's characters in a Unicode width table. If you need to compute the width of a single character, use ``Graphics.Text.wcwidth``. @@ -1549,7 +1550,7 @@ * ``focusedFormInputAttr`` - this attribute is used to render the form   field that has the focus. * ``invalidFormInputAttr`` - this attribute is used to render any form-  field that has user input that has valid validation.+  field that has user input that has invalid validation.  Your application should set both of these. Some good mappings in the attribute map are:@@ -1658,7 +1659,7 @@ | (no custom          | decides which keys will|    arrives when the user| | keybindings)        | trigger application    |    presses a key.       | |                     | behaviors. The event   | #. The event handler    |-|                     | handler is written to  |    pattern-mathces on   |+|                     | handler is written to  |    pattern-matches on   | |                     | pattern-match on       |    the input event to   | |                     | specific keys.         |    check for a match and| |                     |                        |    then runs the        |@@ -1790,7 +1791,7 @@ Border-joining works by iteratively *redrawing* the edges of widgets as those edges come into contact with other widgets during rendering. If the adjacent edge locations of two widgets both use joinable borders,-the Brick will re-draw one of the characters to so that it connects+the Brick will re-draw one of the characters so that it connects seamlessly with the adjacent border.  How Joining Works
programs/AttrDemo.hs view
@@ -30,9 +30,9 @@     vBox [ str "This text uses the global default attribute."          , withAttr (attrName "foundFull") $            str "Specifying an attribute name means we look it up in the attribute tree."-         , (withAttr (attrName "foundFgOnly") $-           str ("When we find a value, we merge it with its parent in the attribute")-           <=> str "name tree all the way to the root (the global default).")+         , withAttr (attrName "foundFgOnly") $+           str "When we find a value, we merge it with its parent in the attribute"+           <=> str "name tree all the way to the root (the global default)."          , withAttr (attrName "missing") $            str "A missing attribute name just resumes the search at its parent."          , withAttr (attrName "general" <> attrName "specific") $@@ -42,7 +42,7 @@          , withAttr (attrName "foundFgOnly") $            str "... or only what you want to change and inherit the rest."          , str "Attribute names are assembled with the Monoid append operation to indicate"-         , str "hierarchy levels, e.g. \"window\" <> \"title\"."+         , str "hierarchy levels, e.g. attrName \"window\" <> attrName \"title\"."          , str " "          , withAttr (attrName "linked") $            str "This text is hyperlinked in terminals that support hyperlinking."
programs/CroppingDemo.hs view
@@ -27,7 +27,7 @@  example :: Widget n example =-    border $+    border     (txt "Example" <=> txt "Widget")  mkExample :: Widget n -> Widget n
programs/CustomKeybindingDemo.hs view
@@ -242,8 +242,8 @@     -- looks in plain text and Markdown formats. These can be used to     -- generate documentation for users. Note that the output generated     -- here takes the active bindings into account! If you don't want-    -- that, use handlers that were built from a KeyConfig that didn't-    -- have any custom bindings applied.+    -- that, use a key config that doesn't have any custom bindings+    -- applied.     let sections = [("Main", handlers)]      putStrLn "Generated plain text help:"
programs/FillDemo.hs view
@@ -4,11 +4,12 @@ import Brick.Widgets.Border  ui :: Widget ()-ui = vBox [ vLimitPercent 20 $ vBox [ str "This text is at the top."+ui = vBox [ vLimitPercent 20 $ vBox [ str "This text is in the top 20% of the window due to a fill and vLimitPercent."                                     , fill ' '                                     , hBorder                                     ]-          , str "This text is at the bottom."+          , str "This text is at the bottom with another fill beneath it."+          , fill 'x'           ]  main :: IO ()
programs/LayerDemo.hs view
@@ -12,13 +12,10 @@ import qualified Graphics.Vty as V  import qualified Brick.Types as T-import Brick.Types (locationRowL, locationColumnL, Widget)+import Brick.Types (locationRowL, locationColumnL, Location(..), Widget) import qualified Brick.Main as M import qualified Brick.Widgets.Border as B import qualified Brick.Widgets.Center as C-import Brick.Types-  ( Location(..)-  ) import Brick.Widgets.Core   ( translateBy   , str
programs/TableDemo.hs view
@@ -45,7 +45,7 @@ rightTableB =     columnBorders False $     setDefaultColAlignment AlignCenter $-    table [ [txt "A",     txt "table"]+    table [ [txt "A",       txt "table"]           , [txt "without", txt "column borders"]           ] @@ -55,7 +55,7 @@     rowBorders False $     columnBorders False $     setDefaultColAlignment AlignCenter $-    table [ [txt "A",     txt "table"]+    table [ [txt "A",       txt "table"]           , [txt "without", txt "any borders"]           ] 
programs/ThemeDemo.hs view
@@ -76,9 +76,9 @@             -- we'd build the attribute map at startup and store it in             -- the application state. Here I just use themeToAttrMap to             -- show the mechanics of the API.-            if s == 1-            then themeToAttrMap theme1-            else themeToAttrMap theme2+            themeToAttrMap $ if s == 1+                             then theme1+                             else theme2         , appChooseCursor = neverShowCursor         } 
programs/ViewportScrollbarsDemo.hs view
@@ -130,7 +130,7 @@  theme :: AttrMap theme =-    attrMap V.defAttr $+    attrMap V.defAttr     [ (scrollbarAttr,       fg V.white)     , (scrollbarHandleAttr, fg V.brightYellow)     ]
src/Brick.hs view
@@ -4,7 +4,7 @@ -- [Brick User Guide](https://github.com/jtdaugherty/brick/blob/master/docs/guide.rst). -- The README also has links to other learning resources. Unlike -- most Haskell libraries that only have API documentation, Brick--- is best larned by reading the User Guide and other materials and+-- is best learned by reading the User Guide and other materials and -- referring to the API docs only as needed. Enjoy! module Brick   ( module Brick.Main
src/Brick/AttrMap.hs view
@@ -47,7 +47,7 @@ import Control.DeepSeq import Data.Bits ((.|.)) import qualified Data.Map as M-import Data.Maybe (catMaybes)+import Data.Maybe (mapMaybe) import Data.List (inits) import GHC.Generics (Generic) @@ -99,7 +99,7 @@ attrMap theDefault pairs = AttrMap theDefault (M.fromList pairs)  -- | Create an attribute map in which all lookups map to the same--- attribute. This is functionally equivalent to @AttrMap attr []@.+-- attribute. This is functionally equivalent to @attrMap attr []@. forceAttrMap :: Attr -> AttrMap forceAttrMap = ForceAttr @@ -140,17 +140,17 @@ -- For example: -- -- @--- attrMapLookup ("foo" <> "bar") (attrMap a []) == a--- attrMapLookup ("foo" <> "bar") (attrMap (bg blue) [("foo" <> "bar", fg red)]) == red \`on\` blue--- attrMapLookup ("foo" <> "bar") (attrMap (bg blue) [("foo" <> "bar", red `on` cyan)]) == red \`on\` cyan--- attrMapLookup ("foo" <> "bar") (attrMap (bg blue) [("foo" <> "bar", fg red), ("foo", bg cyan)]) == red \`on\` cyan--- attrMapLookup ("foo" <> "bar") (attrMap (bg blue) [("foo", fg red)]) == red \`on\` blue+-- attrMapLookup (attrName "foo" <> attrName "bar") (attrMap a []) == a+-- attrMapLookup (attrName "foo" <> attrName "bar") (attrMap (bg blue) [(attrName "foo" <> attrName "bar", fg red)]) == red \`on\` blue+-- attrMapLookup (attrName "foo" <> attrName "bar") (attrMap (bg blue) [(attrName "foo" <> attrName "bar", red `on` cyan)]) == red \`on\` cyan+-- attrMapLookup (attrName "foo" <> attrName "bar") (attrMap (bg blue) [(attrName "foo" <> attrName "bar", fg red), ("foo", bg cyan)]) == red \`on\` cyan+-- attrMapLookup (attrName "foo" <> attrName "bar") (attrMap (bg blue) [(attrName "foo", fg red)]) == red \`on\` blue -- @ attrMapLookup :: AttrName -> AttrMap -> Attr attrMapLookup _ (ForceAttr a) = a attrMapLookup (AttrName []) (AttrMap theDefault _) = theDefault attrMapLookup (AttrName ns) (AttrMap theDefault m) =-    let results = catMaybes $ (\n -> M.lookup n m) <$> (AttrName <$> (inits ns))+    let results = mapMaybe (\n -> M.lookup (AttrName n) m) (inits ns)     in foldl combineAttrs theDefault results  -- | Set the default attribute value in an attribute map.
src/Brick/BorderMap.hs view
@@ -1,6 +1,5 @@ {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveAnyClass #-} module Brick.BorderMap
src/Brick/Forms.hs view
@@ -281,7 +281,7 @@ newForm mkEs s =     let es = mkEs <*> pure s     in Form { formFieldStates = es-            , formFocus       = focusRing $ concat $ formFieldNames <$> es+            , formFocus       = focusRing $ concatMap formFieldNames es             , formState       = s             , formConcatAll   = vBox             }@@ -482,7 +482,7 @@         csr = if foc then putCursor name (Location (1,0)) else id     in clickable name $        addAttr $ csr $-       txt $ T.concat $+       txt $ T.concat        [ T.singleton lb        , if isSet then T.singleton check else " "        , T.singleton rb <> " " <> label@@ -664,7 +664,7 @@ -- force the user to repair invalid inputs before moving on from a form -- editing session. invalidFields :: Form s e n -> [n]-invalidFields f = concat $ getInvalidFields <$> formFieldStates f+invalidFields f = concatMap getInvalidFields (formFieldStates f)  -- | Manually indicate that a field has invalid contents. This can be -- useful in situations where validation beyond the form element's@@ -695,8 +695,8 @@ getInvalidFields :: FormFieldState s e n -> [n] getInvalidFields (FormFieldState st _ _ fs _ _) =     let gather (FormField n validate extValid _ _) =-            if (not extValid || (isNothing $ validate st)) then [n] else []-    in concat $ gather <$> fs+            if not extValid || isNothing (validate st) then [n] else []+    in concatMap gather fs  -- | Render a form. --
src/Brick/Keybindings/KeyDispatcher.hs view
@@ -172,7 +172,7 @@     where         pairs = mkPair <$> handlers         mkPair h = (khBinding h, h)-        handlers = concat $ keyHandlersFromConfig conf <$> ks+        handlers = concatMap (keyHandlersFromConfig conf) ks  keyHandlersFromConfig :: (Ord k)                       => KeyConfig k
src/Brick/Keybindings/Parse.hs view
@@ -157,7 +157,7 @@ keybindingsFromIni evs section doc =     Ini.parseIniFile doc (keybindingIniParser evs section) --- | Parse custom key binidngs from the specified INI file path. This+-- | Parse custom key bindings from the specified INI file path. This -- does not catch or convert any exceptions resulting from I/O errors. -- See 'keybindingsFromIni' for details. keybindingsFromFile :: KeyEvents k
src/Brick/Themes.hs view
@@ -37,7 +37,7 @@ -- the same @fg@, @bg@, and @style@ settings as for the default -- attribute. Furthermore, if an attribute name has multiple components, -- the fields in the INI file should use periods as delimiters. For--- example, if a theme has an attribute name (@"foo" <> "bar"@), then+-- example, if a theme has an attribute name (@attrName "foo" <> attrName "bar"@), then -- the file may specify three fields: -- --  * @foo.bar.fg@ - a color specification@@ -50,7 +50,7 @@ -- -- Attribute names with multiple components (e.g. @attr1 <> attr2@) can -- be referenced in customization files by separating the names with--- a dot. For example, the attribute name @"list" <> "selected"@ can be+-- a dot. For example, the attribute name @attrName "list" <> attrName "selected"@ can be -- referenced by using the string "list.selected". module Brick.Themes   ( CustomAttr(..)
src/Brick/Types.hs view
@@ -1,5 +1,4 @@ -- | Basic types used by this library.-{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE RankNTypes #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Brick.Types
src/Brick/Widgets/Border/Style.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveAnyClass #-} -- | This module provides styles for borders as used in terminal
src/Brick/Widgets/Core.hs view
@@ -199,7 +199,7 @@ emptyWidget :: Widget n emptyWidget = raw V.emptyImage --- | Add an offset to all cursor locations, visbility requests, and+-- | Add an offset to all cursor locations, visibility requests, and -- extents in the specified rendering result. This function is critical -- for maintaining correctness in the rendering results as they are -- processed successively by box layouts and other wrapping combinators,@@ -691,9 +691,9 @@           paddedImages = padImage <$> rewrittenImages        cropResultToContext $ Result (concatenatePrimary br paddedImages)-                            (concat $ cursors <$> allTranslatedResults)-                            (concat $ visibilityRequests <$> allTranslatedResults)-                            (concat $ extents <$> allTranslatedResults)+                            (concatMap cursors allTranslatedResults)+                            (concatMap visibilityRequests allTranslatedResults)+                            (concatMap extents allTranslatedResults)                             newBorders  catDynBorder@@ -1430,10 +1430,10 @@        -- If the rendering state includes any scrolling requests for this       -- viewport, apply those-      reqs <- lift $ gets $ (^.rsScrollRequestsL)+      reqs <- lift $ gets (^.rsScrollRequestsL)       let relevantRequests = snd <$> filter (\(n, _) -> n == vpname) reqs       when (not $ null relevantRequests) $ do-          mVp <- lift $ gets $ (^.viewportMapL.to (M.lookup vpname))+          mVp <- lift $ gets (^.viewportMapL.to (M.lookup vpname))           case mVp of               Nothing -> error $ "BUG: viewport: viewport name " <> show vpname <> " absent from viewport map"               Just vp -> do@@ -1451,7 +1451,7 @@       -- If the sub-rendering requested visibility, update the scroll       -- state accordingly       when (not $ null $ initialResult^.visibilityRequestsL) $ do-          mVp <- lift $ gets $ (^.viewportMapL.to (M.lookup vpname))+          mVp <- lift $ gets (^.viewportMapL.to (M.lookup vpname))           case mVp of               Nothing -> error $ "BUG: viewport: viewport name " <> show vpname <> " absent from viewport map"               Just vp -> do@@ -1464,7 +1464,7 @@        -- If the size of the rendering changes enough to make the       -- viewport offsets invalid, reset them-      mVp <- lift $ gets $ (^.viewportMapL.to (M.lookup vpname))+      mVp <- lift $ gets (^.viewportMapL.to (M.lookup vpname))       vp <- case mVp of           Nothing -> error $ "BUG: viewport: viewport name " <> show vpname <> " absent from viewport map"           Just v -> return v
src/Brick/Widgets/Edit.hs view
@@ -181,10 +181,12 @@        -> Editor a n 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--- current line; the editor will only ever render the first line of--- text.+-- | Apply an editing operation to the editor's contents.+--+-- This is subject to the restrictions of the underlying text zipper;+-- for example, if the underlying zipper has a line limit configured,+-- any edits applied here will be ignored if they edit text outside+-- the line limit. applyEdit :: (Z.TextZipper t -> Z.TextZipper t)           -- ^ The 'Data.Text.Zipper' editing transformation to apply           -> Editor t n
src/Brick/Widgets/FileBrowser.hs view
@@ -280,7 +280,7 @@                -- executable's current working directory.                -> IO (FileBrowser n) newFileBrowser selPredicate name mCwd = do-    initialCwd <- case mCwd of+    initialCwd <- FP.normalise <$> case mCwd of         Just path -> return path         Nothing -> D.getCurrentDirectory @@ -581,10 +581,6 @@ -- * @Ctrl-f@: 'actionFileBrowserListPageDown' -- * @Ctrl-d@: 'actionFileBrowserListHalfPageDown' -- * @Ctrl-u@: 'actionFileBrowserListHalfPageUp'--- * @g@: 'actionFileBrowserListTop'--- * @G@: 'actionFileBrowserListBottom'--- * @j@: 'actionFileBrowserListNext'--- * @k@: 'actionFileBrowserListPrev' -- * @Ctrl-n@: 'actionFileBrowserListNext' -- * @Ctrl-p@: 'actionFileBrowserListPrev' --@@ -593,6 +589,10 @@ -- * @/@: 'actionFileBrowserBeginSearch' -- * @Enter@: 'actionFileBrowserSelectEnter' -- * @Space@: 'actionFileBrowserSelectCurrent'+-- * @g@: 'actionFileBrowserListTop'+-- * @G@: 'actionFileBrowserListBottom'+-- * @j@: 'actionFileBrowserListNext'+-- * @k@: 'actionFileBrowserListPrev' -- -- Events handled only in search mode: --
src/Brick/Widgets/Internal.hs view
@@ -12,10 +12,9 @@ import Lens.Micro.Mtl ((%=)) import Control.Monad.State.Strict import Control.Monad.Reader-import Data.Maybe (fromMaybe)+import Data.Maybe (fromMaybe, mapMaybe) import qualified Data.Map as M import qualified Data.Set as S-import Data.Maybe (catMaybes) import qualified Graphics.Vty as V  import Brick.Types@@ -63,7 +62,7 @@                       }          layersTopmostFirst = reverse layerResults-        pic = V.picForLayers $ uncurry V.resize (w, h) <$> (^.imageL) <$> layersTopmostFirst+        pic = V.picForLayers $ V.resize w h <$> (^.imageL) <$> layersTopmostFirst          -- picWithBg is a workaround for runaway attributes.         -- See https://github.com/coreyoconnor/vty/issues/95@@ -91,7 +90,7 @@ cropImage c = V.crop (max 0 $ c^.availWidthL) (max 0 $ c^.availHeightL)  cropCursors :: Context n -> [CursorLocation n] -> [CursorLocation n]-cropCursors ctx cs = catMaybes $ cropCursor <$> cs+cropCursors ctx cs = mapMaybe cropCursor cs     where         -- A cursor location is removed if it is not within the region         -- described by the context.@@ -105,7 +104,7 @@                ]  cropExtents :: Context n -> [Extent n] -> [Extent n]-cropExtents ctx es = catMaybes $ cropExtent <$> es+cropExtents ctx es = mapMaybe cropExtent es     where         -- An extent is cropped in places where it is not within the         -- region described by the context.
src/Brick/Widgets/List.hs view
@@ -1,8 +1,6 @@ {-# LANGUAGE TupleSections #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-}-{-# LANGUAGE DeriveFunctor #-}-{-# LANGUAGE DeriveFoldable#-} {-# LANGUAGE DeriveTraversable #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-}
tests/List.hs view
@@ -4,7 +4,6 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-}-{-# LANGUAGE TypeSynonymInstances #-} module List   ( main   )
tests/Main.hs view
@@ -112,5 +112,5 @@  main :: IO () main =-  (all id <$> sequenceA [$quickCheckAll, List.main, Render.main])+  (and <$> sequenceA [$quickCheckAll, List.main, Render.main])   >>= bool exitFailure exitSuccess
tests/Render.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE CPP #-}-{-# LANGUAGE TypeApplications #-} module Render   ( main   )