packages feed

vty-ui 1.0 → 1.0.1

raw patch · 3 files changed

+27/−4 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

src/Graphics/Vty/Widgets/Core.hs view
@@ -399,13 +399,28 @@                                 , currentEntryNum = 0                                 } +  -- Now we need to be sure that we have the event handlers set+  -- correctly on each widget.  The reason we don't just call+  -- addToFocusGroup on each entry's widget is because the user may+  -- have added event handlers to the FocusEntries themselves, and we+  -- want to preserve those, so we extract the widget from the focus+  -- entry to add the onGainFocus handler, but use the existing+  -- FocusEntries when constructing the new focus group.+  forM_ (zip [0..] aEntries) $ \(i, e) -> do+    (FocusEntry w) <- state <~ e+    w `onGainFocus` (const $ setCurrentFocus c i)++  forM_ (zip [(length aEntries)..] bEntries) $ \(i, e) -> do+    (FocusEntry w) <- state <~ e+    w `onGainFocus` (const $ setCurrentFocus c i)+   return c  resetFocusGroup :: (MonadIO m) => Widget FocusGroup -> m () resetFocusGroup fg = do   cur <- currentEntryNum <~~ fg   es <- entries <~~ fg-  forM_ (zip [1..] es) $ \(i, e) ->+  forM_ (zip [0..] es) $ \(i, e) ->       when (i /= cur) $ unfocus e   when (cur >= 0) $        focus =<< currentEntry fg
src/Graphics/Vty/Widgets/List.hs view
@@ -149,6 +149,7 @@   st <- getState list    let numItems = length $ listItems st+      oldScr = scrollTopIndex st    when (pos < 0 || pos >= numItems) $        throw $ BadItemIndex pos@@ -157,9 +158,15 @@   let (label, w) = listItems st !! pos       sel = selectedIndex st +      newScrollTop = if pos <= oldScr+                     then if oldScr == 0+                          then oldScr+                          else oldScr - 1+                     else oldScr+       -- If that item is currently selected, select a different item.       newSelectedIndex = if pos > sel-                         then pos+                         then sel                          else if pos < sel                               then if sel == 0                                    then 0@@ -175,6 +182,7 @@   updateWidgetState list $ \s -> s { selectedIndex = newSelectedIndex                                    , listItems = take pos (listItems st) ++                                                  drop (pos + 1) (listItems st)+                                   , scrollTopIndex = newScrollTop                                    }    -- Notify the removal handler.@@ -262,7 +270,7 @@ clearList :: (MonadIO m) => Widget (List a b) -> m () clearList w = do   updateWidgetState w $ \l ->-      l { selectedIndex = 0+      l { selectedIndex = (-1)         , scrollTopIndex = 0         , listItems = []         }
vty-ui.cabal view
@@ -1,5 +1,5 @@ Name:                vty-ui-Version:             1.0+Version:             1.0.1 Synopsis:            An interactive terminal user interface library                      for Vty Description:         An extensible library of user interface widgets