packages feed

brick 0.24.2 → 0.25

raw patch · 5 files changed

+39/−14 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Brick.Widgets.List: listMoveByPages :: (Ord n, RealFrac m) => m -> List n e -> EventM n (List n e)
+ Brick.Widgets.List: listMovePageDown :: (Ord n) => List n e -> EventM n (List n e)
+ Brick.Widgets.List: listMovePageUp :: (Ord n) => List n e -> EventM n (List n e)

Files

CHANGELOG.md view
@@ -2,6 +2,16 @@ Brick changelog --------------- +0.25+----++API changes:+ * List: added page movement functions `listMoveByPages`,+   `listMovePageUp`, and `listMovePageDown` (thanks Richard Alex Hofer)++Miscellaneous:+ * Fixed a spelling mistake in the AttrMap haddock (thanks Edward Betts)+ 0.24.2 ------ 
README.md view
@@ -48,8 +48,8 @@ Featured Projects ----------------- -To give you an idea of what some people have done with `brick`, take a-look at these projects:+To get an idea of what some people have done with `brick`, take a look+at these projects:   * `tetris`: https://github.com/SamTay/tetris  * `gotta-go-fast`, a typing tutor: https://github.com/hot-leaf-juice/gotta-go-fast@@ -58,6 +58,7 @@  * `matterhorn`, a client for [Mattermost](https://about.mattermost.com/): https://github.com/matterhorn-chat/matterhorn  * `viewprof`, a GHC profile viewer: https://github.com/maoe/viewprof  * `tart`, a mouse-driven ASCII art drawing program: https://github.com/jtdaugherty/tart+ * `silly-joy`, an interpreter for Joy in Haskell: https://github.com/rootmos/silly-joy  Getting Started ---------------
brick.cabal view
@@ -1,5 +1,5 @@ name:                brick-version:             0.24.2+version:             0.25 synopsis:            A declarative terminal user interface library description:   Write terminal applications painlessly with 'brick'! You write an
src/Brick/AttrMap.hs view
@@ -53,7 +53,7 @@ import Graphics.Vty (Attr(..), MaybeDefault(..))  -- | An attribute name. Attribute names are hierarchical; use 'mappend'--- ('<>') to assemble them. Hierachy in an attribute name is used to+-- ('<>') to assemble them. Hierarchy in an attribute name is used to -- represent increasing levels of specificity in referring to the -- attribute you want to use for a visual element, with names to the -- left being general and names to the right being more specific. For
src/Brick/Widgets/List.hs view
@@ -31,6 +31,9 @@   , listMoveTo   , listMoveUp   , listMoveDown+  , listMoveByPages+  , listMovePageUp+  , listMovePageDown   , listInsert   , listRemove   , listReplace@@ -91,16 +94,8 @@         EvKey KDown [] -> return $ listMoveDown theList         EvKey KHome [] -> return $ listMoveTo 0 theList         EvKey KEnd [] -> return $ listMoveTo (V.length $ listElements theList) theList-        EvKey KPageDown [] -> do-            v <- lookupViewport (theList^.listNameL)-            case v of-                Nothing -> return theList-                Just vp -> return $ listMoveBy (vp^.vpSize._2 `div` theList^.listItemHeightL) theList-        EvKey KPageUp [] -> do-            v <- lookupViewport (theList^.listNameL)-            case v of-                Nothing -> return theList-                Just vp -> return $ listMoveBy (negate $ vp^.vpSize._2 `div` theList^.listItemHeightL) theList+        EvKey KPageDown [] -> listMovePageDown theList+        EvKey KPageUp [] -> listMovePageUp theList         _ -> return theList  -- | The top-level attribute used for the entire list.@@ -244,10 +239,29 @@ listMoveUp :: List n e -> List n e listMoveUp = listMoveBy (-1) +-- | Move the list selected index up by one page.+listMovePageUp :: (Ord n) => List n e -> EventM n (List n e)+listMovePageUp theList = listMoveByPages (-1) theList+ -- | Move the list selected index down by one. (Moves the cursor down, -- adds one to the index.) listMoveDown :: List n e -> List n e listMoveDown = listMoveBy 1++-- | Move the list selected index down by one page.+listMovePageDown :: (Ord n) => List n e -> EventM n (List n e)+listMovePageDown theList = listMoveByPages 1 theList++-- | Move the list selected index by some (fractional) number of pages.+listMoveByPages :: (Ord n, RealFrac m) => m -> List n e -> EventM n (List n e)+listMoveByPages pages theList = do+    v <- lookupViewport (theList^.listNameL)+    case v of+        Nothing -> return theList+        Just vp -> let+            nElems = round $ pages * (fromIntegral $ vp^.vpSize._2) / (fromIntegral $ theList^.listItemHeightL)+          in+            return $ listMoveBy nElems theList  -- | Move the list selected index by the specified amount, subject to -- validation.