packages feed

brick 0.21 → 0.22

raw patch · 4 files changed

+42/−12 lines, 4 filesdep ~word-wrapPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: word-wrap

API changes (from Hackage documentation)

+ Brick.Widgets.Core: strWrapWith :: WrapSettings -> String -> Widget n
+ Brick.Widgets.Core: txtWrapWith :: WrapSettings -> Text -> Widget n
- Brick.Types: cursorLocationL :: forall n_aqfI. Lens' (CursorLocation n_aqfI) Location
+ Brick.Types: cursorLocationL :: forall n_aqfJ. Lens' (CursorLocation n_aqfJ) Location
- Brick.Types: cursorLocationNameL :: forall n_aqfI n_aqJm. Lens (CursorLocation n_aqfI) (CursorLocation n_aqJm) (Maybe n_aqfI) (Maybe n_aqJm)
+ Brick.Types: cursorLocationNameL :: forall n_aqfJ n_aqJn. Lens (CursorLocation n_aqfJ) (CursorLocation n_aqJn) (Maybe n_aqfJ) (Maybe n_aqJn)
- Brick.Types: cursorsL :: forall n_aqeD. Lens' (Result n_aqeD) [CursorLocation n_aqeD]
+ Brick.Types: cursorsL :: forall n_aqeE. Lens' (Result n_aqeE) [CursorLocation n_aqeE]
- Brick.Types: extentsL :: forall n_aqeD. Lens' (Result n_aqeD) [Extent n_aqeD]
+ Brick.Types: extentsL :: forall n_aqeE. Lens' (Result n_aqeE) [Extent n_aqeE]
- Brick.Types: imageL :: forall n_aqeD. Lens' (Result n_aqeD) Image
+ Brick.Types: imageL :: forall n_aqeE. Lens' (Result n_aqeE) Image
- Brick.Types: visibilityRequestsL :: forall n_aqeD. Lens' (Result n_aqeD) [VisibilityRequest]
+ Brick.Types: visibilityRequestsL :: forall n_aqeE. Lens' (Result n_aqeE) [VisibilityRequest]
- Brick.Widgets.Dialog: dialogButtonsL :: forall a_a14qr a_a14r1. Lens (Dialog a_a14qr) (Dialog a_a14r1) [(String, a_a14qr)] [(String, a_a14r1)]
+ Brick.Widgets.Dialog: dialogButtonsL :: forall a_a14rS a_a14ss. Lens (Dialog a_a14rS) (Dialog a_a14ss) [(String, a_a14rS)] [(String, a_a14ss)]
- Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a14qr. Lens' (Dialog a_a14qr) (Maybe Int)
+ Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a14rS. Lens' (Dialog a_a14rS) (Maybe Int)
- Brick.Widgets.Dialog: dialogTitleL :: forall a_a14qr. Lens' (Dialog a_a14qr) (Maybe String)
+ Brick.Widgets.Dialog: dialogTitleL :: forall a_a14rS. Lens' (Dialog a_a14rS) (Maybe String)
- Brick.Widgets.Dialog: dialogWidthL :: forall a_a14qr. Lens' (Dialog a_a14qr) Int
+ Brick.Widgets.Dialog: dialogWidthL :: forall a_a14rS. Lens' (Dialog a_a14rS) Int
- Brick.Widgets.Edit: editContentsL :: forall t_a16bz n_a16bA t_a16cb. Lens (Editor t_a16bz n_a16bA) (Editor t_a16cb n_a16bA) (TextZipper t_a16bz) (TextZipper t_a16cb)
+ Brick.Widgets.Edit: editContentsL :: forall t_a16d0 n_a16d1 t_a16dC. Lens (Editor t_a16d0 n_a16d1) (Editor t_a16dC n_a16d1) (TextZipper t_a16d0) (TextZipper t_a16dC)
- Brick.Widgets.List: listElementsL :: forall n_a17Zt e_a17Zu e_a189I. Lens (List n_a17Zt e_a17Zu) (List n_a17Zt e_a189I) (Vector e_a17Zu) (Vector e_a189I)
+ Brick.Widgets.List: listElementsL :: forall n_a180U e_a180V e_a18b9. Lens (List n_a180U e_a180V) (List n_a180U e_a18b9) (Vector e_a180V) (Vector e_a18b9)
- Brick.Widgets.List: listItemHeightL :: forall n_a17Zt e_a17Zu. Lens' (List n_a17Zt e_a17Zu) Int
+ Brick.Widgets.List: listItemHeightL :: forall n_a180U e_a180V. Lens' (List n_a180U e_a180V) Int
- Brick.Widgets.List: listNameL :: forall n_a17Zt e_a17Zu n_a189J. Lens (List n_a17Zt e_a17Zu) (List n_a189J e_a17Zu) n_a17Zt n_a189J
+ Brick.Widgets.List: listNameL :: forall n_a180U e_a180V n_a18ba. Lens (List n_a180U e_a180V) (List n_a18ba e_a180V) n_a180U n_a18ba
- Brick.Widgets.List: listSelectedL :: forall n_a17Zt e_a17Zu. Lens' (List n_a17Zt e_a17Zu) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: forall n_a180U e_a180V. Lens' (List n_a180U e_a180V) (Maybe Int)

Files

CHANGELOG.md view
@@ -2,6 +2,16 @@ Brick changelog --------------- +0.22+----++API changes:+ * Core: added txtWrapWith and strWrapWith functions to provide control+   over wrapping behavior by specifying custom wrapping settings.++Other changes:+ * Updated TextWrapDemo.hs to demonstrate customizing wrapping settings.+ 0.21 ---- 
brick.cabal view
@@ -1,5 +1,5 @@ name:                brick-version:             0.21+version:             0.22 synopsis:            A declarative terminal user interface library description:   Write terminal applications painlessly with 'brick'! You write an@@ -118,7 +118,8 @@   main-is:             TextWrapDemo.hs   build-depends:       base,                        brick,-                       text+                       text,+                       word-wrap  executable brick-cache-demo   if !flag(demos)
programs/TextWrapDemo.hs view
@@ -2,12 +2,21 @@  import Data.Monoid ((<>)) import Brick+import Text.Wrap (defaultWrapSettings, preserveIndentation)  ui :: Widget ()-ui = strWrap $ "Hello, world! This line is long enough that " <>-               "it's likely to wrap on your terminal if your window " <>-               "isn't especially wide. Try narrowing and widening " <>-               "the window to see what happens to this text."+ui =+    t1 <=> (padTop (Pad 1) t2)+    where+      t1 = strWrap $ "Hello, world! This line is long enough that " <>+                     "it's likely to wrap on your terminal if your window " <>+                     "isn't especially wide. Try narrowing and widening " <>+                     "the window to see what happens to this text."+      settings = defaultWrapSettings { preserveIndentation = True }+      t2 = strWrapWith settings $+          "This text wraps\n" <>+          "   with different settings to preserve indentation\n" <>+          "   so that long lines wrap in nicer way."  main :: IO () main = simpleMain ui
src/Brick/Widgets/Core.hs view
@@ -13,8 +13,10 @@   , raw   , txt   , txtWrap+  , txtWrapWith   , str   , strWrap+  , strWrapWith   , fill    -- * Padding@@ -103,7 +105,7 @@ import qualified Graphics.Vty as V import Control.DeepSeq -import Text.Wrap (wrapTextToLines, defaultWrapSettings)+import Text.Wrap (wrapTextToLines, WrapSettings, defaultWrapSettings)  import Brick.Types import Brick.Types.Internal@@ -201,20 +203,28 @@             else ""  -- | Make a widget from a string, but wrap the words in the input's--- lines at the available width.+-- lines at the available width using the default wrapping settings. strWrap :: String -> Widget n-strWrap = txtWrap . T.pack+strWrap = strWrapWith defaultWrapSettings +-- | Make a widget from a string, but wrap the words in the input's+-- lines at the available width using the specified wrapping settings.+strWrapWith :: WrapSettings -> String -> Widget n+strWrapWith settings t = txtWrapWith settings $ T.pack t+ safeTextWidth :: T.Text -> Int safeTextWidth = V.safeWcswidth . T.unpack  -- | Make a widget from text, but wrap the words in the input's lines at--- the available width.+-- the available width using the default wrapping settings. txtWrap :: T.Text -> Widget n-txtWrap s =+txtWrap = txtWrapWith defaultWrapSettings++txtWrapWith :: WrapSettings -> T.Text -> Widget n+txtWrapWith settings s =     Widget Fixed Fixed $ do       c <- getContext-      let theLines = fixEmpty <$> wrapTextToLines defaultWrapSettings (c^.availWidthL) s+      let theLines = fixEmpty <$> wrapTextToLines settings (c^.availWidthL) s           fixEmpty l | T.null l = " "                      | otherwise = l       case force theLines of