brick 0.60.1 → 0.60.2
raw patch · 4 files changed
+33/−10 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Brick.BorderMap: eBottomL :: forall a_acUV. Lens' (Edges a_acUV) a_acUV
+ Brick.BorderMap: eBottomL :: forall a_acV3. Lens' (Edges a_acV3) a_acV3
- Brick.BorderMap: eLeftL :: forall a_acUV. Lens' (Edges a_acUV) a_acUV
+ Brick.BorderMap: eLeftL :: forall a_acV3. Lens' (Edges a_acV3) a_acV3
- Brick.BorderMap: eRightL :: forall a_acUV. Lens' (Edges a_acUV) a_acUV
+ Brick.BorderMap: eRightL :: forall a_acV3. Lens' (Edges a_acV3) a_acV3
- Brick.BorderMap: eTopL :: forall a_acUV. Lens' (Edges a_acUV) a_acUV
+ Brick.BorderMap: eTopL :: forall a_acV3. Lens' (Edges a_acV3) a_acV3
- Brick.Types: bordersL :: forall n_axZ8. Lens' (Result n_axZ8) (BorderMap DynBorder)
+ Brick.Types: bordersL :: forall n_axZg. Lens' (Result n_axZg) (BorderMap DynBorder)
- Brick.Types: cursorLocationL :: forall n_awLE. Lens' (CursorLocation n_awLE) Location
+ Brick.Types: cursorLocationL :: forall n_awLM. Lens' (CursorLocation n_awLM) Location
- Brick.Types: cursorLocationNameL :: forall n_awLE n_ayCw. Lens (CursorLocation n_awLE) (CursorLocation n_ayCw) (Maybe n_awLE) (Maybe n_ayCw)
+ Brick.Types: cursorLocationNameL :: forall n_awLM n_ayCO. Lens (CursorLocation n_awLM) (CursorLocation n_ayCO) (Maybe n_awLM) (Maybe n_ayCO)
- Brick.Types: cursorsL :: forall n_axZ8. Lens' (Result n_axZ8) [CursorLocation n_axZ8]
+ Brick.Types: cursorsL :: forall n_axZg. Lens' (Result n_axZg) [CursorLocation n_axZg]
- Brick.Types: eBottomL :: forall a_acUV. Lens' (Edges a_acUV) a_acUV
+ Brick.Types: eBottomL :: forall a_acV3. Lens' (Edges a_acV3) a_acV3
- Brick.Types: eLeftL :: forall a_acUV. Lens' (Edges a_acUV) a_acUV
+ Brick.Types: eLeftL :: forall a_acV3. Lens' (Edges a_acV3) a_acV3
- Brick.Types: eRightL :: forall a_acUV. Lens' (Edges a_acUV) a_acUV
+ Brick.Types: eRightL :: forall a_acV3. Lens' (Edges a_acV3) a_acV3
- Brick.Types: eTopL :: forall a_acUV. Lens' (Edges a_acUV) a_acUV
+ Brick.Types: eTopL :: forall a_acV3. Lens' (Edges a_acV3) a_acV3
- Brick.Types: extentsL :: forall n_axZ8. Lens' (Result n_axZ8) [Extent n_axZ8]
+ Brick.Types: extentsL :: forall n_axZg. Lens' (Result n_axZg) [Extent n_axZg]
- Brick.Types: imageL :: forall n_axZ8. Lens' (Result n_axZ8) Image
+ Brick.Types: imageL :: forall n_axZg. Lens' (Result n_axZg) Image
- Brick.Types: visibilityRequestsL :: forall n_axZ8. Lens' (Result n_axZ8) [VisibilityRequest]
+ Brick.Types: visibilityRequestsL :: forall n_axZg. Lens' (Result n_axZg) [VisibilityRequest]
- Brick.Widgets.Dialog: dialogButtonsL :: forall a_a18MC a_a18Ng. Lens (Dialog a_a18MC) (Dialog a_a18Ng) [(String, a_a18MC)] [(String, a_a18Ng)]
+ Brick.Widgets.Dialog: dialogButtonsL :: forall a_a1920 a_a192E. Lens (Dialog a_a1920) (Dialog a_a192E) [(String, a_a1920)] [(String, a_a192E)]
- Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a18MC. Lens' (Dialog a_a18MC) (Maybe Int)
+ Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a1920. Lens' (Dialog a_a1920) (Maybe Int)
- Brick.Widgets.Dialog: dialogTitleL :: forall a_a18MC. Lens' (Dialog a_a18MC) (Maybe String)
+ Brick.Widgets.Dialog: dialogTitleL :: forall a_a1920. Lens' (Dialog a_a1920) (Maybe String)
- Brick.Widgets.Dialog: dialogWidthL :: forall a_a18MC. Lens' (Dialog a_a18MC) Int
+ Brick.Widgets.Dialog: dialogWidthL :: forall a_a1920. Lens' (Dialog a_a1920) Int
- Brick.Widgets.Edit: editContentsL :: forall t_a13id n_a13ie t_a13iS. Lens (Editor t_a13id n_a13ie) (Editor t_a13iS n_a13ie) (TextZipper t_a13id) (TextZipper t_a13iS)
+ Brick.Widgets.Edit: editContentsL :: forall t_a13xB n_a13xC t_a13yg. Lens (Editor t_a13xB n_a13xC) (Editor t_a13yg n_a13xC) (TextZipper t_a13xB) (TextZipper t_a13yg)
- Brick.Widgets.FileBrowser: fileBrowserEntryFilterL :: forall n_a1iTq. Lens' (FileBrowser n_a1iTq) (Maybe (FileInfo -> Bool))
+ Brick.Widgets.FileBrowser: fileBrowserEntryFilterL :: forall n_a1j8O. Lens' (FileBrowser n_a1j8O) (Maybe (FileInfo -> Bool))
- Brick.Widgets.FileBrowser: fileBrowserSelectableL :: forall n_a1iTq. Lens' (FileBrowser n_a1iTq) (FileInfo -> Bool)
+ Brick.Widgets.FileBrowser: fileBrowserSelectableL :: forall n_a1j8O. Lens' (FileBrowser n_a1j8O) (FileInfo -> Bool)
- Brick.Widgets.List: listElementsL :: forall n_a1dIQ t_a1dIR e_a1dIS t_a1dWX e_a1dWY. Lens (GenericList n_a1dIQ t_a1dIR e_a1dIS) (GenericList n_a1dIQ t_a1dWX e_a1dWY) (t_a1dIR e_a1dIS) (t_a1dWX e_a1dWY)
+ Brick.Widgets.List: listElementsL :: forall n_a1dYe t_a1dYf e_a1dYg t_a1ecl e_a1ecm. Lens (GenericList n_a1dYe t_a1dYf e_a1dYg) (GenericList n_a1dYe t_a1ecl e_a1ecm) (t_a1dYf e_a1dYg) (t_a1ecl e_a1ecm)
- Brick.Widgets.List: listItemHeightL :: forall n_a1dIQ t_a1dIR e_a1dIS. Lens' (GenericList n_a1dIQ t_a1dIR e_a1dIS) Int
+ Brick.Widgets.List: listItemHeightL :: forall n_a1dYe t_a1dYf e_a1dYg. Lens' (GenericList n_a1dYe t_a1dYf e_a1dYg) Int
- Brick.Widgets.List: listNameL :: forall n_a1dIQ t_a1dIR e_a1dIS n_a1dWZ. Lens (GenericList n_a1dIQ t_a1dIR e_a1dIS) (GenericList n_a1dWZ t_a1dIR e_a1dIS) n_a1dIQ n_a1dWZ
+ Brick.Widgets.List: listNameL :: forall n_a1dYe t_a1dYf e_a1dYg n_a1ecn. Lens (GenericList n_a1dYe t_a1dYf e_a1dYg) (GenericList n_a1ecn t_a1dYf e_a1dYg) n_a1dYe n_a1ecn
- Brick.Widgets.List: listSelectedL :: forall n_a1dIQ t_a1dIR e_a1dIS. Lens' (GenericList n_a1dIQ t_a1dIR e_a1dIS) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: forall n_a1dYe t_a1dYf e_a1dYg. Lens' (GenericList n_a1dYe t_a1dYf e_a1dYg) (Maybe Int)
Files
- CHANGELOG.md +8/−0
- brick.cabal +1/−1
- src/Brick/Types/Internal.hs +1/−1
- src/Brick/Widgets/Core.hs +23/−8
CHANGELOG.md view
@@ -2,6 +2,14 @@ Brick changelog --------------- +0.60.2+------++Bug fixes:+ * Widgets reported as `clickable` are now reported as clickable even+ when their renderings are cached with `cached` (#307; thanks Hari+ Menon)+ 0.60.1 ------
brick.cabal view
@@ -1,5 +1,5 @@ name: brick-version: 0.60.1+version: 0.60.2 synopsis: A declarative terminal user interface library description: Write terminal user interfaces (TUIs) painlessly with 'brick'! You
src/Brick/Types/Internal.hs view
@@ -249,7 +249,7 @@ RS { viewportMap :: !(M.Map n Viewport) , rsScrollRequests :: ![(n, ScrollRequest)] , observedNames :: !(S.Set n)- , renderCache :: !(M.Map n (Result n))+ , renderCache :: !(M.Map n ([n], Result n)) , clickableNames :: ![n] } deriving (Read, Show, Generic, NFData)
src/Brick/Widgets/Core.hs view
@@ -958,29 +958,44 @@ withReaderT (& availHeightL .~ unrestricted) (render p) Greedy -> Nothing --- | Render the specified widget. If the widget has an entry in the--- rendering cache using the specified name as the cache key, use the--- rendered version from the cache instead. If not, render the widget--- and update the cache.+-- | If the specified resource name has an entry in the rendering cache,+-- use the rendered version from the cache. If not, render the specified+-- widget and update the cache with the result. --+-- To ensure that mouse events are emitted correctly for cached widgets, +-- in addition to the rendered widget, we also cache (the names of) +-- any clickable extents that were rendered and restore that when utilizing+-- the cache.+-- -- See also 'invalidateCacheEntry'. cached :: (Ord n) => n -> Widget n -> Widget n cached n w = Widget (hSize w) (vSize w) $ do result <- cacheLookup n case result of- Just prevResult -> return prevResult+ Just (clickables, prevResult) -> do+ clickableNamesL %= (clickables ++)+ return prevResult Nothing -> do wResult <- render w- cacheUpdate n wResult+ clickables <- renderedClickables wResult+ cacheUpdate n (clickables, wResult) return wResult+ where+ -- Given the rendered result of a Widget, collect the list of "clickable" names+ -- from the extents that were in the result.+ renderedClickables :: (Ord n) => Result n -> RenderM n [n]+ renderedClickables renderResult = do+ allClickables <- use clickableNamesL+ return [extentName e | e <- renderResult^.extentsL, extentName e `elem` allClickables] -cacheLookup :: (Ord n) => n -> RenderM n (Maybe (Result n))++cacheLookup :: (Ord n) => n -> RenderM n (Maybe ([n], Result n)) cacheLookup n = do cache <- lift $ gets (^.renderCacheL) return $ M.lookup n cache -cacheUpdate :: (Ord n) => n -> Result n -> RenderM n ()+cacheUpdate :: (Ord n) => n -> ([n], Result n) -> RenderM n () cacheUpdate n r = lift $ modify (& renderCacheL %~ M.insert n r) -- | Render the specified widget in a named viewport with the