brick 2.8 → 2.8.1
raw patch · 4 files changed
+54/−47 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Brick.Widgets.Dialog: dialogButtonsL :: forall a_a1gjv n_a1gjw a_a1gkt. Lens (Dialog a_a1gjv n_a1gjw) (Dialog a_a1gkt n_a1gjw) [(String, n_a1gjw, a_a1gjv)] [(String, n_a1gjw, a_a1gkt)]
+ Brick.Widgets.Dialog: dialogButtonsL :: forall a_a1gqF n_a1gqG a_a1grD. Lens (Dialog a_a1gqF n_a1gqG) (Dialog a_a1grD n_a1gqG) [(String, n_a1gqG, a_a1gqF)] [(String, n_a1gqG, a_a1grD)]
- Brick.Widgets.Dialog: dialogTitleL :: forall a_a1gjv n_a1gjw. Lens' (Dialog a_a1gjv n_a1gjw) (Maybe (Widget n_a1gjw))
+ Brick.Widgets.Dialog: dialogTitleL :: forall a_a1gqF n_a1gqG. Lens' (Dialog a_a1gqF n_a1gqG) (Maybe (Widget n_a1gqG))
- Brick.Widgets.Dialog: dialogWidthL :: forall a_a1gjv n_a1gjw. Lens' (Dialog a_a1gjv n_a1gjw) Int
+ Brick.Widgets.Dialog: dialogWidthL :: forall a_a1gqF n_a1gqG. Lens' (Dialog a_a1gqF n_a1gqG) Int
- Brick.Widgets.Edit: editContentsL :: forall t_a19rG n_a19rH t_a19sr. Lens (Editor t_a19rG n_a19rH) (Editor t_a19sr n_a19rH) (TextZipper t_a19rG) (TextZipper t_a19sr)
+ Brick.Widgets.Edit: editContentsL :: forall t_a19yQ n_a19yR t_a19zB. Lens (Editor t_a19yQ n_a19yR) (Editor t_a19zB n_a19yR) (TextZipper t_a19yQ) (TextZipper t_a19zB)
- Brick.Widgets.FileBrowser: fileBrowserEntriesG :: forall n_a1sjV. SimpleGetter (FileBrowser n_a1sjV) (List n_a1sjV FileInfo)
+ Brick.Widgets.FileBrowser: fileBrowserEntriesG :: forall n_a1sr5. SimpleGetter (FileBrowser n_a1sr5) (List n_a1sr5 FileInfo)
- Brick.Widgets.FileBrowser: fileBrowserEntryFilterG :: forall n_a1sjV. SimpleGetter (FileBrowser n_a1sjV) (Maybe (FileInfo -> Bool))
+ Brick.Widgets.FileBrowser: fileBrowserEntryFilterG :: forall n_a1sr5. SimpleGetter (FileBrowser n_a1sr5) (Maybe (FileInfo -> Bool))
- Brick.Widgets.FileBrowser: fileBrowserExceptionG :: forall n_a1sjV. SimpleGetter (FileBrowser n_a1sjV) (Maybe IOException)
+ Brick.Widgets.FileBrowser: fileBrowserExceptionG :: forall n_a1sr5. SimpleGetter (FileBrowser n_a1sr5) (Maybe IOException)
- Brick.Widgets.FileBrowser: fileBrowserLatestResultsG :: forall n_a1sjV. SimpleGetter (FileBrowser n_a1sjV) [FileInfo]
+ Brick.Widgets.FileBrowser: fileBrowserLatestResultsG :: forall n_a1sr5. SimpleGetter (FileBrowser n_a1sr5) [FileInfo]
- Brick.Widgets.FileBrowser: fileBrowserNameG :: forall n_a1sjV. SimpleGetter (FileBrowser n_a1sjV) n_a1sjV
+ Brick.Widgets.FileBrowser: fileBrowserNameG :: forall n_a1sr5. SimpleGetter (FileBrowser n_a1sr5) n_a1sr5
- Brick.Widgets.FileBrowser: fileBrowserSearchStringG :: forall n_a1sjV. SimpleGetter (FileBrowser n_a1sjV) (Maybe Text)
+ Brick.Widgets.FileBrowser: fileBrowserSearchStringG :: forall n_a1sr5. SimpleGetter (FileBrowser n_a1sr5) (Maybe Text)
- Brick.Widgets.FileBrowser: fileBrowserSelectableG :: forall n_a1sjV. SimpleGetter (FileBrowser n_a1sjV) (FileInfo -> Bool)
+ Brick.Widgets.FileBrowser: fileBrowserSelectableG :: forall n_a1sr5. SimpleGetter (FileBrowser n_a1sr5) (FileInfo -> Bool)
- Brick.Widgets.FileBrowser: fileBrowserSelectableL :: forall n_a1sjV. Lens' (FileBrowser n_a1sjV) (FileInfo -> Bool)
+ Brick.Widgets.FileBrowser: fileBrowserSelectableL :: forall n_a1sr5. Lens' (FileBrowser n_a1sr5) (FileInfo -> Bool)
- Brick.Widgets.FileBrowser: fileBrowserSelectedFilesG :: forall n_a1sjV. SimpleGetter (FileBrowser n_a1sjV) (Set String)
+ Brick.Widgets.FileBrowser: fileBrowserSelectedFilesG :: forall n_a1sr5. SimpleGetter (FileBrowser n_a1sr5) (Set String)
- Brick.Widgets.FileBrowser: fileBrowserWorkingDirectoryG :: forall n_a1sjV. SimpleGetter (FileBrowser n_a1sjV) FilePath
+ Brick.Widgets.FileBrowser: fileBrowserWorkingDirectoryG :: forall n_a1sr5. SimpleGetter (FileBrowser n_a1sr5) FilePath
- Brick.Widgets.List: listElementsL :: forall n_a1mRw t_a1mRx e_a1mRy t_a1n7a e_a1n7b. Lens (GenericList n_a1mRw t_a1mRx e_a1mRy) (GenericList n_a1mRw t_a1n7a e_a1n7b) (t_a1mRx e_a1mRy) (t_a1n7a e_a1n7b)
+ Brick.Widgets.List: listElementsL :: forall n_a1mYG t_a1mYH e_a1mYI t_a1nek e_a1nel. Lens (GenericList n_a1mYG t_a1mYH e_a1mYI) (GenericList n_a1mYG t_a1nek e_a1nel) (t_a1mYH e_a1mYI) (t_a1nek e_a1nel)
- Brick.Widgets.List: listItemHeightL :: forall n_a1mRw t_a1mRx e_a1mRy. Lens' (GenericList n_a1mRw t_a1mRx e_a1mRy) Int
+ Brick.Widgets.List: listItemHeightL :: forall n_a1mYG t_a1mYH e_a1mYI. Lens' (GenericList n_a1mYG t_a1mYH e_a1mYI) Int
- Brick.Widgets.List: listNameL :: forall n_a1mRw t_a1mRx e_a1mRy n_a1n7c. Lens (GenericList n_a1mRw t_a1mRx e_a1mRy) (GenericList n_a1n7c t_a1mRx e_a1mRy) n_a1mRw n_a1n7c
+ Brick.Widgets.List: listNameL :: forall n_a1mYG t_a1mYH e_a1mYI n_a1nem. Lens (GenericList n_a1mYG t_a1mYH e_a1mYI) (GenericList n_a1nem t_a1mYH e_a1mYI) n_a1mYG n_a1nem
- Brick.Widgets.List: listSelectedL :: forall n_a1mRw t_a1mRx e_a1mRy. Lens' (GenericList n_a1mRw t_a1mRx e_a1mRy) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: forall n_a1mYG t_a1mYH e_a1mYI. Lens' (GenericList n_a1mYG t_a1mYH e_a1mYI) (Maybe Int)
Files
- CHANGELOG.md +8/−0
- brick.cabal +1/−1
- src/Brick/Widgets/Core.hs +21/−24
- src/Brick/Widgets/Internal.hs +24/−22
CHANGELOG.md view
@@ -2,6 +2,14 @@ Brick changelog --------------- +2.8.1+-----++* Fixed a long-standing bug in `cropToContext` that resulted in some+ extents getting left around when they should be dropped, possibly+ leading to application bugs when handling mouse clicks in extent+ regions that should have been removed from the rendering result.+ 2.8 ---
brick.cabal view
@@ -1,5 +1,5 @@ name: brick-version: 2.8+version: 2.8.1 synopsis: A declarative terminal user interface library description: Write terminal user interfaces (TUIs) painlessly with 'brick'! You
src/Brick/Widgets/Core.hs view
@@ -719,12 +719,11 @@ (concatMap extents allTranslatedResults) newBorders -catDynBorder- :: Lens' (Edges BorderSegment) BorderSegment- -> Lens' (Edges BorderSegment) BorderSegment- -> DynBorder- -> DynBorder- -> Maybe DynBorder+catDynBorder :: Lens' (Edges BorderSegment) BorderSegment+ -> Lens' (Edges BorderSegment) BorderSegment+ -> DynBorder+ -> DynBorder+ -> Maybe DynBorder catDynBorder towardsA towardsB a b -- Currently, we check if the 'BorderStyle's are exactly the same. In the -- future, it might be nice to relax this restriction. For example, if a@@ -742,12 +741,11 @@ = Just (a & dbSegmentsL.towardsB.bsDrawL .~ True) | otherwise = Nothing -catDynBorders- :: Lens' (Edges BorderSegment) BorderSegment- -> Lens' (Edges BorderSegment) BorderSegment- -> I.IMap DynBorder- -> I.IMap DynBorder- -> I.IMap DynBorder+catDynBorders :: Lens' (Edges BorderSegment) BorderSegment+ -> Lens' (Edges BorderSegment) BorderSegment+ -> I.IMap DynBorder+ -> I.IMap DynBorder+ -> I.IMap DynBorder catDynBorders towardsA towardsB am bm = I.mapMaybe id $ I.intersectionWith (catDynBorder towardsA towardsB) am bm @@ -757,9 +755,8 @@ -- images to keep the image in sync with the border information. -- -- The input borders are assumed to be disjoint. This property is not checked.-catBorders- :: (border ~ BM.BorderMap DynBorder, rewrite ~ I.IMap V.Image)- => BoxRenderer n -> border -> border -> ((rewrite, rewrite), border)+catBorders :: (border ~ BM.BorderMap DynBorder, rewrite ~ I.IMap V.Image)+ => BoxRenderer n -> border -> border -> ((rewrite, rewrite), border) catBorders br r l = if lCoord + 1 == rCoord then ((lRe, rRe), lr') else ((I.empty, I.empty), lr)@@ -788,20 +785,20 @@ -- overlap and are strictly increasing in the primary direction), produce: a -- list of rewrites for the lo and hi directions of each border, respectively, -- and the borders describing the fully concatenated object.-catAllBorders ::- BoxRenderer n ->- [BM.BorderMap DynBorder] ->- ([(I.IMap V.Image, I.IMap V.Image)], BM.BorderMap DynBorder)+catAllBorders :: BoxRenderer n+ -> [BM.BorderMap DynBorder]+ -> ([(I.IMap V.Image, I.IMap V.Image)], BM.BorderMap DynBorder) catAllBorders _ [] = ([], BM.empty) catAllBorders br (bm:bms) = (zip ([I.empty]++los) (his++[I.empty]), bm') where (rewrites, bm') = runState (traverse (state . catBorders br) bms) bm (his, los) = unzip rewrites -rewriteEdge ::- (Int -> V.Image -> V.Image) ->- (Int -> V.Image -> V.Image) ->- ([V.Image] -> V.Image) ->- I.IMap V.Image -> V.Image -> V.Image+rewriteEdge :: (Int -> V.Image -> V.Image)+ -> (Int -> V.Image -> V.Image)+ -> ([V.Image] -> V.Image)+ -> I.IMap V.Image+ -> V.Image+ -> V.Image rewriteEdge splitLo splitHi combine = (combine .) . go . offsets 0 . I.unsafeToAscList where -- convert absolute positions into relative ones
src/Brick/Widgets/Internal.hs view
@@ -114,29 +114,31 @@ cropExtents :: Context n -> [Extent n] -> [Extent n] cropExtents ctx es = mapMaybe cropExtent es where- -- An extent is cropped in places where it is not within the- -- region described by the context.- --- -- If its entirety is outside the context region, it is dropped.- --- -- Otherwise its size is adjusted so that it is contained within- -- the context region. cropExtent (Extent n (Location (c, r)) (w, h)) =- -- Determine the new lower-right corner- let endCol = c + w- endRow = r + h- -- Then clamp the lower-right corner based on the- -- context- endCol' = min (ctx^.availWidthL) endCol- endRow' = min (ctx^.availHeightL) endRow- -- Then compute the new width and height from the- -- clamped lower-right corner.- w' = endCol' - c- h' = endRow' - r- e = Extent n (Location (c, r)) (w', h')- in if w' < 0 || h' < 0- then Nothing- else Just e+ -- Clamp the original extent's UL corner to the context.+ --+ -- Clamp the original extent's LR corner to the context.+ --+ -- Keep the modified extent (i.e. with clamped corners)+ -- only if the resulting extent has non-zero size in both+ -- dimensions.+ let nonEmpty = nonEmptyH && nonEmptyV+ nonEmptyH = newWidth > 0+ nonEmptyV = newHeight > 0+ newWidth = newEndCol - newStartCol+ newHeight = newEndRow - newStartRow+ (newStartCol, newStartRow) = clampCorner (c, r)+ (newEndCol, newEndRow) = clampCorner (c + w, r + h)+ clampCorner (cols, rows) =+ ( clampRange (ctx^.availWidthL) cols+ , clampRange (ctx^.availHeightL) rows+ )+ clampRange bound val =+ min bound $ max 0 val+ newExtent = Extent n (Location (newStartCol, newStartRow)) (newWidth, newHeight)+ in if nonEmpty+ then Just newExtent+ else Nothing cropBorders :: Context n -> BorderMap DynBorder -> BorderMap DynBorder cropBorders ctx = BM.crop Edges