brick 0.2.2 → 0.2.3
raw patch · 3 files changed
+28/−3 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Brick.Widgets.Dialog: dialogButtonsL :: Lens (Dialog a_aGrY) (Dialog a_aGst) [(String, a_aGrY)] [(String, a_aGst)]
+ Brick.Widgets.Dialog: dialogButtonsL :: Lens (Dialog a_aGHj) (Dialog a_aGHO) [(String, a_aGHj)] [(String, a_aGHO)]
- Brick.Widgets.Dialog: dialogNameL :: Lens' (Dialog a_aGrY) Name
+ Brick.Widgets.Dialog: dialogNameL :: Lens' (Dialog a_aGHj) Name
- Brick.Widgets.Dialog: dialogSelectedIndexL :: Lens' (Dialog a_aGrY) (Maybe Int)
+ Brick.Widgets.Dialog: dialogSelectedIndexL :: Lens' (Dialog a_aGHj) (Maybe Int)
- Brick.Widgets.Dialog: dialogTitleL :: Lens' (Dialog a_aGrY) (Maybe String)
+ Brick.Widgets.Dialog: dialogTitleL :: Lens' (Dialog a_aGHj) (Maybe String)
- Brick.Widgets.Dialog: dialogWidthL :: Lens' (Dialog a_aGrY) Int
+ Brick.Widgets.Dialog: dialogWidthL :: Lens' (Dialog a_aGHj) Int
- Brick.Widgets.List: listElementsL :: Lens (List e_aMcj) (List e_aMdd) (Vector e_aMcj) (Vector e_aMdd)
+ Brick.Widgets.List: listElementsL :: Lens (List e_aMrE) (List e_aMsy) (Vector e_aMrE) (Vector e_aMsy)
- Brick.Widgets.List: listItemHeightL :: Lens' (List e_aMcj) Int
+ Brick.Widgets.List: listItemHeightL :: Lens' (List e_aMrE) Int
- Brick.Widgets.List: listNameL :: Lens' (List e_aMcj) Name
+ Brick.Widgets.List: listNameL :: Lens' (List e_aMrE) Name
- Brick.Widgets.List: listSelectedL :: Lens' (List e_aMcj) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: Lens' (List e_aMrE) (Maybe Int)
Files
- CHANGELOG.md +9/−0
- brick.cabal +1/−1
- src/Brick/Widgets/Core.hs +18/−2
CHANGELOG.md view
@@ -2,6 +2,15 @@ Brick changelog --------------- +0.2.3+-----++Bug fixes:+* Fixed viewport behavior when the image in a viewport reduces its size+ enough to render the viewport offsets invalid. Before, this behavior+ caused a crash during image croppin in vty; now the behavior is+ handled sanely (fixes #22; reported by Hans-Peter Deifel)+ 0.2.2 -----
brick.cabal view
@@ -1,5 +1,5 @@ name: brick-version: 0.2.2+version: 0.2.3 synopsis: A declarative terminal user interface library description: Write terminal applications painlessly with 'brick'! You write an
src/Brick/Widgets/Core.hs view
@@ -593,12 +593,28 @@ Vertical -> scrollToView typ rq vp lift $ modify (& viewportMapL %~ (M.insert vpname updatedVp)) + -- If the size of the rendering changes enough to make the+ -- viewport offsets invalid, reset them+ Just vp <- lift $ gets $ (^.viewportMapL.to (M.lookup vpname))+ let img = initialResult^.imageL+ fixTop v = if V.imageHeight img < v^.vpSize._2+ then v & vpTop .~ 0+ else v+ fixLeft v = if V.imageWidth img < v^.vpSize._1+ then v & vpLeft .~ 0+ else v+ updateVp = case typ of+ Both -> fixLeft . fixTop+ Horizontal -> fixLeft+ Vertical -> fixTop+ lift $ modify (& viewportMapL %~ (M.insert vpname (updateVp vp)))+ -- Get the viewport state now that it has been updated.- Just vp <- lift $ gets (M.lookup vpname . (^.viewportMapL))+ Just vpFinal <- lift $ gets (M.lookup vpname . (^.viewportMapL)) -- Then perform a translation of the sub-rendering to fit into the -- viewport- translated <- render $ translateBy (Location (-1 * vp^.vpLeft, -1 * vp^.vpTop))+ translated <- render $ translateBy (Location (-1 * vpFinal^.vpLeft, -1 * vpFinal^.vpTop)) $ Widget Fixed Fixed $ return initialResult -- Return the translated result with the visibility requests