diff --git a/ChangeLog.md b/ChangeLog.md index b95cd07..9b61a6c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ # Revision history for reflex-vty +## Unreleased + +* *Breaking Change*: `Reflex.Vty.Widget.Scroll.scrollable` now require child widgets to return a value in addition to their images and update events. Specifically, the child widget type has gone from `m (Behavior t Image, Event t ())` to `m (Behavior t Image, Event t (), a)`. + ## 0.5.2.1 * Extend version bounds diff --git a/src/Reflex/Vty/Widget/Scroll.hs b/src/Reflex/Vty/Widget/Scroll.hs index 723153a..6245d7a 100644 --- a/src/Reflex/Vty/Widget/Scroll.hs +++ b/src/Reflex/Vty/Widget/Scroll.hs @@ -47,12 +47,14 @@ data Scrollable t = Scrollable -- | Scrollable widget. The output exposes the current scroll position and -- total number of lines (including those that are hidden) scrollable - :: forall t m. (Reflex t, MonadHold t m, MonadFix m, HasDisplayRegion t m, HasInput t m, HasImageWriter t m, HasTheme t m) + :: forall t m a. + ( Reflex t, MonadHold t m, MonadFix m + , HasDisplayRegion t m, HasInput t m, HasImageWriter t m, HasTheme t m) => ScrollableConfig t - -> (m (Behavior t V.Image, Event t ())) - -> m (Scrollable t) + -> (m (Behavior t V.Image, Event t (), a)) + -> m (Scrollable t, a) scrollable (ScrollableConfig scrollBy scrollTo startingPos onAppend) mkImg = do - (img, update) <- mkImg + (img, update, a) <- mkImg let sz = V.imageHeight <$> img kup <- key V.KUp kdown <- key V.KDown @@ -85,7 +87,7 @@ scrollable (ScrollableConfig scrollBy scrollTo startingPos onAppend) mkImg = do ScrollPos_Top -> images -- take height images ScrollPos_Line n -> V.translateY ((-1) * n) images tellImages $ fmap (:[]) $ imgsToTell <$> current dh <*> current lineIndex <*> sz <*> img - return $ Scrollable + return $ (,a) $ Scrollable { _scrollable_scrollPosition = current lineIndex , _scrollable_totalLines = sz , _scrollable_scrollHeight = current dh diff --git a/src/Reflex/Vty/Widget/Text.hs b/src/Reflex/Vty/Widget/Text.hs index dd1fb0b..283138f 100644 --- a/src/Reflex/Vty/Widget/Text.hs +++ b/src/Reflex/Vty/Widget/Text.hs @@ -79,7 +79,6 @@ scrollableText => ScrollableConfig t -> Dynamic t Text -> m (Scrollable t) -scrollableText cfg t = do - scrollable cfg $ do - ((), images) <- runImageWriter $ text (current t) - pure $ (V.vertCat <$> images, () <$ updated t) +scrollableText cfg t = fmap fst $ scrollable cfg $ do + ((), images) <- runImageWriter $ text (current t) + pure $ (V.vertCat <$> images, () <$ updated t, ())