packages feed

brick 0.33 → 0.34

raw patch · 5 files changed

+48/−10 lines, 5 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

- Brick.Types: cursorLocationL :: forall n_asrl. Lens' (CursorLocation n_asrl) Location
+ Brick.Types: cursorLocationL :: forall n_asrj. Lens' (CursorLocation n_asrj) Location
- Brick.Types: cursorLocationNameL :: forall n_asrl n_asUW. Lens (CursorLocation n_asrl) (CursorLocation n_asUW) (Maybe n_asrl) (Maybe n_asUW)
+ Brick.Types: cursorLocationNameL :: forall n_asrj n_asUU. Lens (CursorLocation n_asrj) (CursorLocation n_asUU) (Maybe n_asrj) (Maybe n_asUU)
- Brick.Types: cursorsL :: forall n_asrk. Lens' (Result n_asrk) [CursorLocation n_asrk]
+ Brick.Types: cursorsL :: forall n_asri. Lens' (Result n_asri) [CursorLocation n_asri]
- Brick.Types: extentsL :: forall n_asrk. Lens' (Result n_asrk) [Extent n_asrk]
+ Brick.Types: extentsL :: forall n_asri. Lens' (Result n_asri) [Extent n_asri]
- Brick.Types: imageL :: forall n_asrk. Lens' (Result n_asrk) Image
+ Brick.Types: imageL :: forall n_asri. Lens' (Result n_asri) Image
- Brick.Types: visibilityRequestsL :: forall n_asrk. Lens' (Result n_asrk) [VisibilityRequest]
+ Brick.Types: visibilityRequestsL :: forall n_asri. Lens' (Result n_asri) [VisibilityRequest]
- Brick.Widgets.Dialog: dialogButtonsL :: forall a_aQfs a_aQg8. Lens (Dialog a_aQfs) (Dialog a_aQg8) [(String, a_aQfs)] [(String, a_aQg8)]
+ Brick.Widgets.Dialog: dialogButtonsL :: forall a_aQgC a_aQhi. Lens (Dialog a_aQgC) (Dialog a_aQhi) [(String, a_aQgC)] [(String, a_aQhi)]
- Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_aQfs. Lens' (Dialog a_aQfs) (Maybe Int)
+ Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_aQgC. Lens' (Dialog a_aQgC) (Maybe Int)
- Brick.Widgets.Dialog: dialogTitleL :: forall a_aQfs. Lens' (Dialog a_aQfs) (Maybe String)
+ Brick.Widgets.Dialog: dialogTitleL :: forall a_aQgC. Lens' (Dialog a_aQgC) (Maybe String)
- Brick.Widgets.Dialog: dialogWidthL :: forall a_aQfs. Lens' (Dialog a_aQfs) Int
+ Brick.Widgets.Dialog: dialogWidthL :: forall a_aQgC. Lens' (Dialog a_aQgC) Int
- Brick.Widgets.Edit: editContentsL :: forall t_aMi2 n_aMi3 t_aMiK. Lens (Editor t_aMi2 n_aMi3) (Editor t_aMiK n_aMi3) (TextZipper t_aMi2) (TextZipper t_aMiK)
+ Brick.Widgets.Edit: editContentsL :: forall t_aMjc n_aMjd t_aMjU. Lens (Editor t_aMjc n_aMjd) (Editor t_aMjU n_aMjd) (TextZipper t_aMjc) (TextZipper t_aMjU)
- Brick.Widgets.List: listElementsL :: forall n_aYrF e_aYrG e_aYCl. Lens (List n_aYrF e_aYrG) (List n_aYrF e_aYCl) (Vector e_aYrG) (Vector e_aYCl)
+ Brick.Widgets.List: listElementsL :: forall n_aYvy e_aYvz e_aYGe. Lens (List n_aYvy e_aYvz) (List n_aYvy e_aYGe) (Vector e_aYvz) (Vector e_aYGe)
- Brick.Widgets.List: listItemHeightL :: forall n_aYrF e_aYrG. Lens' (List n_aYrF e_aYrG) Int
+ Brick.Widgets.List: listItemHeightL :: forall n_aYvy e_aYvz. Lens' (List n_aYvy e_aYvz) Int
- Brick.Widgets.List: listNameL :: forall n_aYrF e_aYrG n_aYCm. Lens (List n_aYrF e_aYrG) (List n_aYCm e_aYrG) n_aYrF n_aYCm
+ Brick.Widgets.List: listNameL :: forall n_aYvy e_aYvz n_aYGf. Lens (List n_aYvy e_aYvz) (List n_aYGf e_aYvz) n_aYvy n_aYGf
- Brick.Widgets.List: listSelectedL :: forall n_aYrF e_aYrG. Lens' (List n_aYrF e_aYrG) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: forall n_aYvy e_aYvz. Lens' (List n_aYvy e_aYvz) (Maybe Int)

Files

CHANGELOG.md view
@@ -2,6 +2,28 @@ Brick changelog --------------- +0.34+----++API changes:+ * Core: vLimit and hLimit now *bound* sizes rather than setting them.+   This was the original intention of these combinators. The change in+   behavior means that now `vLimit N` means that *at most* `N` rows will+   be available; if the context has less, then the smaller constraint in+   the context is used instead. Programs affected by this behavior will+   be those that assume that `vLimit` doesn't do this, but that should+   be very few or zero.++Other changes:+ * Dialog: now arrow keys no longer wrap around available buttons but+   stop at rightmost or leftmost button to avoid confusion when+   attempting to tell which button is selected in two-button dialogs+   (thanks to Karl Ostmo for this change)++Documentation changes:+ * Updated Haddocks for str/txt in Core to mention tab character+   considerations+ 0.33 ---- 
README.md view
@@ -66,6 +66,7 @@  * `herms`, a command-line tool for managing kitchen recipes: https://github.com/jackkiefer/herms  * `purebred`, a mail user agent: https://github.com/purebred-mua/purebred  * `2048Haskell`, an implementation of the 2048 game: https://github.com/8Gitbrix/2048Haskell+ * `bhoogle`, a [Hoogle](https://www.haskell.org/hoogle/) client: https://github.com/andrevdm/bhoogle  Getting Started ---------------
brick.cabal view
@@ -1,5 +1,5 @@ name:                brick-version:             0.33+version:             0.34 synopsis:            A declarative terminal user interface library description:   Write terminal applications painlessly with 'brick'! You write an
src/Brick/Widgets/Core.hs view
@@ -244,6 +244,11 @@  -- | Build a widget from a 'String'. Breaks newlines up and space-pads -- short lines out to the length of the longest line.+--+-- The input string must not contain tab characters. If it does,+-- interface corruption will result since the terminal will likely+-- render it as taking up more than a single column. The caller should+-- replace tabs with the appropriate number of spaces as desired. str :: String -> Widget n str s =     Widget Fixed Fixed $ do@@ -264,6 +269,11 @@  -- | Build a widget from a 'T.Text' value. Behaves the same as 'str' -- when the input contains multiple lines.+--+-- The input string must not contain tab characters. If it does,+-- interface corruption will result since the terminal will likely+-- render it as taking up more than a single column. The caller should+-- replace tabs with the appropriate number of spaces as desired. txt :: T.Text -> Widget n txt = str . T.unpack @@ -555,7 +565,7 @@ hLimit :: Int -> Widget n -> Widget n hLimit w p =     Widget Fixed (vSize p) $-      withReaderT (& availWidthL .~ w) $ render $ cropToContext p+      withReaderT (& availWidthL %~ (min w)) $ render $ cropToContext p  -- | Limit the space available to the specified widget to the specified -- number of rows. This is important for constraining the vertical@@ -564,7 +574,7 @@ vLimit :: Int -> Widget n -> Widget n vLimit h p =     Widget (hSize p) Fixed $-      withReaderT (& availHeightL .~ h) $ render $ cropToContext p+      withReaderT (& availHeightL %~ (min h)) $ render $ cropToContext p  -- | Set the rendering context height and width for this widget. This -- is useful for relaxing the rendering size constraints on e.g. layer
src/Brick/Widgets/Dialog.hs view
@@ -76,10 +76,10 @@ handleDialogEvent :: Event -> Dialog a -> EventM n (Dialog a) handleDialogEvent ev d =     return $ case ev of-        EvKey (KChar '\t') [] -> nextButtonBy 1 d-        EvKey KBackTab [] -> nextButtonBy (-1) d-        EvKey KRight [] -> nextButtonBy 1 d-        EvKey KLeft [] -> nextButtonBy (-1) d+        EvKey (KChar '\t') [] -> nextButtonBy 1 True d+        EvKey KBackTab [] -> nextButtonBy (-1) True d+        EvKey KRight [] -> nextButtonBy 1 False d+        EvKey KLeft [] -> nextButtonBy (-1) False d         _ -> d  -- | Create a dialog.@@ -133,13 +133,18 @@             , hCenter buttons             ] -nextButtonBy :: Int -> Dialog a -> Dialog a-nextButtonBy amt d =+nextButtonBy :: Int -> Bool -> Dialog a -> Dialog a+nextButtonBy amt wrapCycle d =     let numButtons = length $ d^.dialogButtonsL     in if numButtons == 0 then d        else case d^.dialogSelectedIndexL of            Nothing -> d & dialogSelectedIndexL .~ (Just 0)-           Just i -> d & dialogSelectedIndexL .~ (Just $ (i + amt) `mod` numButtons)+           Just i -> d & dialogSelectedIndexL .~ (Just newIndex)+               where+                   addedIndex = i + amt+                   newIndex = if wrapCycle+                              then addedIndex `mod` numButtons+                              else max 0 $ min addedIndex $ numButtons - 1  -- | Obtain the value associated with the dialog's currently-selected -- button, if any. This function is probably what you want when someone