packages feed

brick 0.69.1 → 0.70

raw patch · 6 files changed

+69/−20 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Brick.BorderMap: clear :: BorderMap a -> BorderMap b
- Brick.BorderMap: eBottomL :: forall a_acIy. Lens' (Edges a_acIy) a_acIy
+ Brick.BorderMap: eBottomL :: forall a_acJW. Lens' (Edges a_acJW) a_acJW
- Brick.BorderMap: eLeftL :: forall a_acIy. Lens' (Edges a_acIy) a_acIy
+ Brick.BorderMap: eLeftL :: forall a_acJW. Lens' (Edges a_acJW) a_acJW
- Brick.BorderMap: eRightL :: forall a_acIy. Lens' (Edges a_acIy) a_acIy
+ Brick.BorderMap: eRightL :: forall a_acJW. Lens' (Edges a_acJW) a_acJW
- Brick.BorderMap: eTopL :: forall a_acIy. Lens' (Edges a_acIy) a_acIy
+ Brick.BorderMap: eTopL :: forall a_acJW. Lens' (Edges a_acJW) a_acJW
- Brick.Types: availHeightL :: forall n_awyw. Lens' (Context n_awyw) Int
+ Brick.Types: availHeightL :: forall n_awD8. Lens' (Context n_awD8) Int
- Brick.Types: availWidthL :: forall n_awyw. Lens' (Context n_awyw) Int
+ Brick.Types: availWidthL :: forall n_awD8. Lens' (Context n_awD8) Int
- Brick.Types: bordersL :: forall n_awyA. Lens' (Result n_awyA) (BorderMap DynBorder)
+ Brick.Types: bordersL :: forall n_awDc. Lens' (Result n_awDc) (BorderMap DynBorder)
- Brick.Types: ctxAttrMapL :: forall n_awyw. Lens' (Context n_awyw) AttrMap
+ Brick.Types: ctxAttrMapL :: forall n_awD8. Lens' (Context n_awD8) AttrMap
- Brick.Types: ctxAttrNameL :: forall n_awyw. Lens' (Context n_awyw) AttrName
+ Brick.Types: ctxAttrNameL :: forall n_awD8. Lens' (Context n_awD8) AttrName
- Brick.Types: ctxBorderStyleL :: forall n_awyw. Lens' (Context n_awyw) BorderStyle
+ Brick.Types: ctxBorderStyleL :: forall n_awD8. Lens' (Context n_awD8) BorderStyle
- Brick.Types: ctxDynBordersL :: forall n_awyw. Lens' (Context n_awyw) Bool
+ Brick.Types: ctxDynBordersL :: forall n_awD8. Lens' (Context n_awD8) Bool
- Brick.Types: ctxHScrollBarOrientationL :: forall n_awyw. Lens' (Context n_awyw) (Maybe HScrollBarOrientation)
+ Brick.Types: ctxHScrollBarOrientationL :: forall n_awD8. Lens' (Context n_awD8) (Maybe HScrollBarOrientation)
- Brick.Types: ctxHScrollBarRendererL :: forall n_awyw. Lens' (Context n_awyw) (Maybe (ScrollbarRenderer n_awyw))
+ Brick.Types: ctxHScrollBarRendererL :: forall n_awD8. Lens' (Context n_awD8) (Maybe (ScrollbarRenderer n_awD8))
- Brick.Types: ctxVScrollBarOrientationL :: forall n_awyw. Lens' (Context n_awyw) (Maybe VScrollBarOrientation)
+ Brick.Types: ctxVScrollBarOrientationL :: forall n_awD8. Lens' (Context n_awD8) (Maybe VScrollBarOrientation)
- Brick.Types: ctxVScrollBarRendererL :: forall n_awyw. Lens' (Context n_awyw) (Maybe (ScrollbarRenderer n_awyw))
+ Brick.Types: ctxVScrollBarRendererL :: forall n_awD8. Lens' (Context n_awD8) (Maybe (ScrollbarRenderer n_awD8))
- Brick.Types: cursorLocationL :: forall n_awyB. Lens' (CursorLocation n_awyB) Location
+ Brick.Types: cursorLocationL :: forall n_awDd. Lens' (CursorLocation n_awDd) Location
- Brick.Types: cursorLocationNameL :: forall n_awyB n_ayIL. Lens (CursorLocation n_awyB) (CursorLocation n_ayIL) (Maybe n_awyB) (Maybe n_ayIL)
+ Brick.Types: cursorLocationNameL :: forall n_awDd n_ayNl. Lens (CursorLocation n_awDd) (CursorLocation n_ayNl) (Maybe n_awDd) (Maybe n_ayNl)
- Brick.Types: cursorsL :: forall n_awyA. Lens' (Result n_awyA) [CursorLocation n_awyA]
+ Brick.Types: cursorsL :: forall n_awDc. Lens' (Result n_awDc) [CursorLocation n_awDc]
- Brick.Types: eBottomL :: forall a_acIy. Lens' (Edges a_acIy) a_acIy
+ Brick.Types: eBottomL :: forall a_acJW. Lens' (Edges a_acJW) a_acJW
- Brick.Types: eLeftL :: forall a_acIy. Lens' (Edges a_acIy) a_acIy
+ Brick.Types: eLeftL :: forall a_acJW. Lens' (Edges a_acJW) a_acJW
- Brick.Types: eRightL :: forall a_acIy. Lens' (Edges a_acIy) a_acIy
+ Brick.Types: eRightL :: forall a_acJW. Lens' (Edges a_acJW) a_acJW
- Brick.Types: eTopL :: forall a_acIy. Lens' (Edges a_acIy) a_acIy
+ Brick.Types: eTopL :: forall a_acJW. Lens' (Edges a_acJW) a_acJW
- Brick.Types: extentsL :: forall n_awyA. Lens' (Result n_awyA) [Extent n_awyA]
+ Brick.Types: extentsL :: forall n_awDc. Lens' (Result n_awDc) [Extent n_awDc]
- Brick.Types: imageL :: forall n_awyA. Lens' (Result n_awyA) Image
+ Brick.Types: imageL :: forall n_awDc. Lens' (Result n_awDc) Image
- Brick.Types: visibilityRequestsL :: forall n_awyA. Lens' (Result n_awyA) [VisibilityRequest]
+ Brick.Types: visibilityRequestsL :: forall n_awDc. Lens' (Result n_awDc) [VisibilityRequest]
- Brick.Types: windowHeightL :: forall n_awyw. Lens' (Context n_awyw) Int
+ Brick.Types: windowHeightL :: forall n_awD8. Lens' (Context n_awD8) Int
- Brick.Types: windowWidthL :: forall n_awyw. Lens' (Context n_awyw) Int
+ Brick.Types: windowWidthL :: forall n_awD8. Lens' (Context n_awD8) Int
- Brick.Widgets.Dialog: dialogButtonsL :: forall a_a1fxe a_a1fxS. Lens (Dialog a_a1fxe) (Dialog a_a1fxS) [(String, a_a1fxe)] [(String, a_a1fxS)]
+ Brick.Widgets.Dialog: dialogButtonsL :: forall a_a1fGn a_a1fH1. Lens (Dialog a_a1fGn) (Dialog a_a1fH1) [(String, a_a1fGn)] [(String, a_a1fH1)]
- Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a1fxe. Lens' (Dialog a_a1fxe) (Maybe Int)
+ Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a1fGn. Lens' (Dialog a_a1fGn) (Maybe Int)
- Brick.Widgets.Dialog: dialogTitleL :: forall a_a1fxe. Lens' (Dialog a_a1fxe) (Maybe String)
+ Brick.Widgets.Dialog: dialogTitleL :: forall a_a1fGn. Lens' (Dialog a_a1fGn) (Maybe String)
- Brick.Widgets.Dialog: dialogWidthL :: forall a_a1fxe. Lens' (Dialog a_a1fxe) Int
+ Brick.Widgets.Dialog: dialogWidthL :: forall a_a1fGn. Lens' (Dialog a_a1fGn) Int
- Brick.Widgets.Edit: editContentsL :: forall t_a19LW n_a19LX t_a19MB. Lens (Editor t_a19LW n_a19LX) (Editor t_a19MB n_a19LX) (TextZipper t_a19LW) (TextZipper t_a19MB)
+ Brick.Widgets.Edit: editContentsL :: forall t_a19Qx n_a19Qy t_a19Rc. Lens (Editor t_a19Qx n_a19Qy) (Editor t_a19Rc n_a19Qy) (TextZipper t_a19Qx) (TextZipper t_a19Rc)
- Brick.Widgets.FileBrowser: fileBrowserEntriesG :: forall n_a1pT6. SimpleGetter (FileBrowser n_a1pT6) (List n_a1pT6 FileInfo)
+ Brick.Widgets.FileBrowser: fileBrowserEntriesG :: forall n_a1q2f. SimpleGetter (FileBrowser n_a1q2f) (List n_a1q2f FileInfo)
- Brick.Widgets.FileBrowser: fileBrowserEntryFilterG :: forall n_a1pT6. SimpleGetter (FileBrowser n_a1pT6) (Maybe (FileInfo -> Bool))
+ Brick.Widgets.FileBrowser: fileBrowserEntryFilterG :: forall n_a1q2f. SimpleGetter (FileBrowser n_a1q2f) (Maybe (FileInfo -> Bool))
- Brick.Widgets.FileBrowser: fileBrowserExceptionG :: forall n_a1pT6. SimpleGetter (FileBrowser n_a1pT6) (Maybe IOException)
+ Brick.Widgets.FileBrowser: fileBrowserExceptionG :: forall n_a1q2f. SimpleGetter (FileBrowser n_a1q2f) (Maybe IOException)
- Brick.Widgets.FileBrowser: fileBrowserLatestResultsG :: forall n_a1pT6. SimpleGetter (FileBrowser n_a1pT6) [FileInfo]
+ Brick.Widgets.FileBrowser: fileBrowserLatestResultsG :: forall n_a1q2f. SimpleGetter (FileBrowser n_a1q2f) [FileInfo]
- Brick.Widgets.FileBrowser: fileBrowserNameG :: forall n_a1pT6. SimpleGetter (FileBrowser n_a1pT6) n_a1pT6
+ Brick.Widgets.FileBrowser: fileBrowserNameG :: forall n_a1q2f. SimpleGetter (FileBrowser n_a1q2f) n_a1q2f
- Brick.Widgets.FileBrowser: fileBrowserSearchStringG :: forall n_a1pT6. SimpleGetter (FileBrowser n_a1pT6) (Maybe Text)
+ Brick.Widgets.FileBrowser: fileBrowserSearchStringG :: forall n_a1q2f. SimpleGetter (FileBrowser n_a1q2f) (Maybe Text)
- Brick.Widgets.FileBrowser: fileBrowserSelectableG :: forall n_a1pT6. SimpleGetter (FileBrowser n_a1pT6) (FileInfo -> Bool)
+ Brick.Widgets.FileBrowser: fileBrowserSelectableG :: forall n_a1q2f. SimpleGetter (FileBrowser n_a1q2f) (FileInfo -> Bool)
- Brick.Widgets.FileBrowser: fileBrowserSelectableL :: forall n_a1pT6. Lens' (FileBrowser n_a1pT6) (FileInfo -> Bool)
+ Brick.Widgets.FileBrowser: fileBrowserSelectableL :: forall n_a1q2f. Lens' (FileBrowser n_a1q2f) (FileInfo -> Bool)
- Brick.Widgets.FileBrowser: fileBrowserSelectedFilesG :: forall n_a1pT6. SimpleGetter (FileBrowser n_a1pT6) (Set String)
+ Brick.Widgets.FileBrowser: fileBrowserSelectedFilesG :: forall n_a1q2f. SimpleGetter (FileBrowser n_a1q2f) (Set String)
- Brick.Widgets.FileBrowser: fileBrowserWorkingDirectoryG :: forall n_a1pT6. SimpleGetter (FileBrowser n_a1pT6) FilePath
+ Brick.Widgets.FileBrowser: fileBrowserWorkingDirectoryG :: forall n_a1q2f. SimpleGetter (FileBrowser n_a1q2f) FilePath
- Brick.Widgets.List: listElementsL :: forall n_a1kHe t_a1kHf e_a1kHg t_a1kVk e_a1kVl. Lens (GenericList n_a1kHe t_a1kHf e_a1kHg) (GenericList n_a1kHe t_a1kVk e_a1kVl) (t_a1kHf e_a1kHg) (t_a1kVk e_a1kVl)
+ Brick.Widgets.List: listElementsL :: forall n_a1kQn t_a1kQo e_a1kQp t_a1l4t e_a1l4u. Lens (GenericList n_a1kQn t_a1kQo e_a1kQp) (GenericList n_a1kQn t_a1l4t e_a1l4u) (t_a1kQo e_a1kQp) (t_a1l4t e_a1l4u)
- Brick.Widgets.List: listItemHeightL :: forall n_a1kHe t_a1kHf e_a1kHg. Lens' (GenericList n_a1kHe t_a1kHf e_a1kHg) Int
+ Brick.Widgets.List: listItemHeightL :: forall n_a1kQn t_a1kQo e_a1kQp. Lens' (GenericList n_a1kQn t_a1kQo e_a1kQp) Int
- Brick.Widgets.List: listNameL :: forall n_a1kHe t_a1kHf e_a1kHg n_a1kVm. Lens (GenericList n_a1kHe t_a1kHf e_a1kHg) (GenericList n_a1kVm t_a1kHf e_a1kHg) n_a1kHe n_a1kVm
+ Brick.Widgets.List: listNameL :: forall n_a1kQn t_a1kQo e_a1kQp n_a1l4v. Lens (GenericList n_a1kQn t_a1kQo e_a1kQp) (GenericList n_a1l4v t_a1kQo e_a1kQp) n_a1kQn n_a1l4v
- Brick.Widgets.List: listSelectedL :: forall n_a1kHe t_a1kHf e_a1kHg. Lens' (GenericList n_a1kHe t_a1kHf e_a1kHg) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: forall n_a1kQn t_a1kQo e_a1kQp. Lens' (GenericList n_a1kQn t_a1kQo e_a1kQp) (Maybe Int)

Files

CHANGELOG.md view
@@ -2,6 +2,18 @@ Brick changelog --------------- +0.70+----++Enhancements:+ * The table widget now behaves much better when some or all cells are+   empty.++Bug fixes:+ * BorderMaps got fixed to ensure that smart borders connect even in the+   presence of empty widgets (#370). Thanks to Daniel Wagner for this+   fix!+ 0.69.1 ------ 
brick.cabal view
@@ -1,5 +1,5 @@ name:                brick-version:             0.69.1+version:             0.70 synopsis:            A declarative terminal user interface library description:   Write terminal user interfaces (TUIs) painlessly with 'brick'! You
src/Brick/BorderMap.hs view
@@ -7,7 +7,7 @@     ( BorderMap     , Edges(..)     , eTopL, eBottomL, eRightL, eLeftL-    , empty, emptyCoordinates, singleton+    , empty, clear, emptyCoordinates, singleton     , insertH, insertV, insert     , unsafeUnion     , coordinates, bounds@@ -54,14 +54,23 @@ emptyCoordinates :: Edges Int -> BorderMap a emptyCoordinates cs = BorderMap { _coordinates = cs, _values = pure IM.empty } --- | An empty 'BorderMap' that only tracks the point (0,0).+-- | An empty 'BorderMap' that tracks the same points as the input.+clear :: BorderMap a -> BorderMap b+clear = emptyCoordinates . coordinates++-- | An empty 'BorderMap' that does not track any points. empty :: BorderMap a-empty = emptyCoordinates (pure 0)+empty = emptyCoordinates Edges+    { eTop = 0+    , eBottom = -1+    , eLeft = 0+    , eRight = -1+    }  -- | A 'BorderMap' that tracks only the given the point (and initially maps it -- to the given value). singleton :: Location -> a -> BorderMap a-singleton l v = translate l . insert origin v $ empty+singleton l v = translate l . insert origin v . emptyCoordinates $ pure 0  {-# INLINE coordinates #-} -- | The positions of the edges of the rectangle whose border is retained in a
src/Brick/Types/Internal.hs view
@@ -338,7 +338,13 @@            deriving (Show, Read, Generic, NFData)  emptyResult :: Result n-emptyResult = Result emptyImage [] [] [] BM.empty+emptyResult =+    Result { image = emptyImage+           , cursors = []+           , visibilityRequests = []+           , extents = []+           , borders = BM.empty+           }  -- | The type of events. data BrickEvent n e = VtyEvent Event
src/Brick/Widgets/Core.hs view
@@ -194,7 +194,7 @@ -- -- Frozen borders cannot be thawed. freezeBorders :: Widget n -> Widget n-freezeBorders p = Widget (hSize p) (vSize p) $ (bordersL .~ BM.empty) <$> render p+freezeBorders p = Widget (hSize p) (vSize p) $ (bordersL %~ BM.clear) <$> render p  -- | The empty widget. emptyWidget :: Widget n
src/Brick/Widgets/Table.hs view
@@ -107,9 +107,7 @@ -- 'TableException'. -- -- All rows must have the same number of cells. If not, this will raise--- a 'TableException'. In addition, all rows and columns must provide at--- least one non-empty cell respectively, or the final result may not--- look as desired.+-- a 'TableException'. table :: [[Widget n]] -> Table n table rows =     if not allFixed@@ -205,7 +203,6 @@ renderTable :: Table n -> Widget n renderTable t =     joinBorders $-    (if drawSurroundingBorder t then border else id) $     Widget Fixed Fixed $ do         ctx <- getContext         let rows = tableRows t@@ -220,7 +217,6 @@             colWidth = maximum . fmap (imageWidth . image)             byColumn = transpose cellResults             toW = Widget Fixed Fixed . return-            totalHeight = sum rowHeights             applyColAlignment align width w =                 Widget Fixed Fixed $ do                     result <- render w@@ -249,11 +245,37 @@                                       else id                 render $ vBox $ maybeRowBorders paddedCells         columns <- mapM mkColumn $ zip3 allColAligns colWidths byColumn-        let maybeColumnBorders =-                if drawColumnBorders t-                then let rowBorderHeight = if drawRowBorders t-                                           then length rows - 1-                                           else 0-                     in intersperse (vLimit (totalHeight + rowBorderHeight) vBorder)-                else id-        render $ hBox $ maybeColumnBorders $ toW <$> columns++        let tl = joinableBorder (Edges False True False True)+            tr = joinableBorder (Edges False True True False)+            bl = joinableBorder (Edges True False False True)+            br = joinableBorder (Edges True False True False)+            cross = joinableBorder (Edges True True True True)+            leftT = joinableBorder (Edges True True False True)+            rightT = joinableBorder (Edges True True True False)+            topT = joinableBorder (Edges False True True True)+            bottomT = joinableBorder (Edges True False True True)+            vBorders = mkVBorder <$> rowHeights+            hBorders = mkHBorder <$> colWidths+            mkHBorder w = hLimit w hBorder+            mkVBorder h = vLimit h vBorder+            topBorder = hBox $ (if drawColumnBorders t then intersperse topT else id) hBorders+            bottomBorder = hBox $ (if drawColumnBorders t then intersperse bottomT else id) hBorders+            leftBorder = vBox $ tl : (if drawRowBorders t then intersperse leftT else id) vBorders <> [bl]+            rightBorder = vBox $ tr : (if drawRowBorders t then intersperse rightT else id) vBorders <> [br]+            maybeAddSurroundingBorder body =+                if not $ drawSurroundingBorder t+                then body+                else leftBorder <+> (topBorder <=> body <=> bottomBorder) <+> rightBorder+            maybeAddColumnBorders =+                if not $ drawColumnBorders t+                then id+                else let maybeAddCrosses = if drawRowBorders t+                                           then intersperse cross+                                           else id+                         columnBorder = vBox $ maybeAddCrosses vBorders+                     in intersperse columnBorder++        render $ maybeAddSurroundingBorder $+                 hBox $+                 maybeAddColumnBorders $ toW <$> columns