brick 0.17 → 0.17.1
raw patch · 5 files changed
+49/−25 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Brick.Types: cursorLocationL :: forall n_apZc. Lens' (CursorLocation n_apZc) Location
+ Brick.Types: cursorLocationL :: forall n_apZn. Lens' (CursorLocation n_apZn) Location
- Brick.Types: cursorLocationNameL :: forall n_apZc n_aqsE. Lens (CursorLocation n_apZc) (CursorLocation n_aqsE) (Maybe n_apZc) (Maybe n_aqsE)
+ Brick.Types: cursorLocationNameL :: forall n_apZn n_aqsP. Lens (CursorLocation n_apZn) (CursorLocation n_aqsP) (Maybe n_apZn) (Maybe n_aqsP)
- Brick.Types: cursorsL :: forall n_apY7. Lens' (Result n_apY7) [CursorLocation n_apY7]
+ Brick.Types: cursorsL :: forall n_apYi. Lens' (Result n_apYi) [CursorLocation n_apYi]
- Brick.Types: extentsL :: forall n_apY7. Lens' (Result n_apY7) [Extent n_apY7]
+ Brick.Types: extentsL :: forall n_apYi. Lens' (Result n_apYi) [Extent n_apYi]
- Brick.Types: imageL :: forall n_apY7. Lens' (Result n_apY7) Image
+ Brick.Types: imageL :: forall n_apYi. Lens' (Result n_apYi) Image
- Brick.Types: visibilityRequestsL :: forall n_apY7. Lens' (Result n_apY7) [VisibilityRequest]
+ Brick.Types: visibilityRequestsL :: forall n_apYi. Lens' (Result n_apYi) [VisibilityRequest]
- Brick.Widgets.Dialog: dialogButtonsL :: forall a_a13de a_a13dO. Lens (Dialog a_a13de) (Dialog a_a13dO) [(String, a_a13de)] [(String, a_a13dO)]
+ Brick.Widgets.Dialog: dialogButtonsL :: forall a_a13hX a_a13ix. Lens (Dialog a_a13hX) (Dialog a_a13ix) [(String, a_a13hX)] [(String, a_a13ix)]
- Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a13de. Lens' (Dialog a_a13de) (Maybe Int)
+ Brick.Widgets.Dialog: dialogSelectedIndexL :: forall a_a13hX. Lens' (Dialog a_a13hX) (Maybe Int)
- Brick.Widgets.Dialog: dialogTitleL :: forall a_a13de. Lens' (Dialog a_a13de) (Maybe String)
+ Brick.Widgets.Dialog: dialogTitleL :: forall a_a13hX. Lens' (Dialog a_a13hX) (Maybe String)
- Brick.Widgets.Dialog: dialogWidthL :: forall a_a13de. Lens' (Dialog a_a13de) Int
+ Brick.Widgets.Dialog: dialogWidthL :: forall a_a13hX. Lens' (Dialog a_a13hX) Int
- Brick.Widgets.Edit: editContentsL :: forall t_a14WV n_a14WW. Lens' (Editor t_a14WV n_a14WW) (TextZipper t_a14WV)
+ Brick.Widgets.Edit: editContentsL :: forall t_a151H n_a151I. Lens' (Editor t_a151H n_a151I) (TextZipper t_a151H)
- Brick.Widgets.Edit: editDrawContentsL :: forall t_a14WV n_a14WW. Lens' (Editor t_a14WV n_a14WW) ([t_a14WV] -> Widget n_a14WW)
+ Brick.Widgets.Edit: editDrawContentsL :: forall t_a151H n_a151I. Lens' (Editor t_a151H n_a151I) ([t_a151H] -> Widget n_a151I)
- Brick.Widgets.List: listElementsL :: forall n_a16Py e_a16Pz e_a16Zs. Lens (List n_a16Py e_a16Pz) (List n_a16Py e_a16Zs) (Vector e_a16Pz) (Vector e_a16Zs)
+ Brick.Widgets.List: listElementsL :: forall n_a16Uk e_a16Ul e_a174e. Lens (List n_a16Uk e_a16Ul) (List n_a16Uk e_a174e) (Vector e_a16Ul) (Vector e_a174e)
- Brick.Widgets.List: listItemHeightL :: forall n_a16Py e_a16Pz. Lens' (List n_a16Py e_a16Pz) Int
+ Brick.Widgets.List: listItemHeightL :: forall n_a16Uk e_a16Ul. Lens' (List n_a16Uk e_a16Ul) Int
- Brick.Widgets.List: listNameL :: forall n_a16Py e_a16Pz n_a16Zt. Lens (List n_a16Py e_a16Pz) (List n_a16Zt e_a16Pz) n_a16Py n_a16Zt
+ Brick.Widgets.List: listNameL :: forall n_a16Uk e_a16Ul n_a174f. Lens (List n_a16Uk e_a16Ul) (List n_a174f e_a16Ul) n_a16Uk n_a174f
- Brick.Widgets.List: listSelectedL :: forall n_a16Py e_a16Pz. Lens' (List n_a16Py e_a16Pz) (Maybe Int)
+ Brick.Widgets.List: listSelectedL :: forall n_a16Uk e_a16Ul. Lens' (List n_a16Uk e_a16Ul) (Maybe Int)
Files
- CHANGELOG.md +10/−0
- README.md +1/−1
- brick.cabal +3/−3
- src/Brick/Widgets/Core.hs +34/−20
- src/Brick/Widgets/List.hs +1/−1
CHANGELOG.md view
@@ -2,6 +2,16 @@ Brick changelog --------------- +0.17.1+------++Package changes:+ * Use Extra-Doc-Files instead of Data-Files for documentation files++Bug fixes:+ * List: correctly update selected index in listInsert+ * Update example program in brick.cabal (thanks @timbod7)+ 0.17 ----
README.md view
@@ -63,7 +63,7 @@ ``` To get started, see the [first few sections of the brick-user guide](docs/guide.rst).+user guide](https://github.com/jtdaugherty/brick/blob/master/docs/guide.rst). Brick-Users Discussion ----------------------
brick.cabal view
@@ -1,5 +1,5 @@ name: brick-version: 0.17+version: 0.17.1 synopsis: A declarative terminal user interface library description: Write terminal applications painlessly with 'brick'! You write an@@ -10,7 +10,7 @@ > > import Brick >- > ui :: Widget n+ > ui :: Widget () > ui = str "Hello, world!" > > main :: IO ()@@ -38,7 +38,7 @@ Homepage: https://github.com/jtdaugherty/brick/ Bug-reports: https://github.com/jtdaugherty/brick/issues -data-files: README.md,+extra-doc-files: README.md, docs/guide.rst, CHANGELOG.md
src/Brick/Widgets/Core.hs view
@@ -433,7 +433,8 @@ c <- getContext let pairsIndexed = zip [(0::Int)..] ws- (his, lows) = partition (\p -> (primaryWidgetSize br $ snd p) == Fixed) pairsIndexed+ (his, lows) = partition (\p -> (primaryWidgetSize br $ snd p) == Fixed)+ pairsIndexed let availPrimary = c^.(contextPrimary br) availSecondary = c^.(contextSecondary br)@@ -443,14 +444,16 @@ result <- render $ limitPrimary br remainingPrimary $ limitSecondary br availSecondary $ cropToContext prim- renderHis (remainingPrimary - (result^.imageL.(to $ imagePrimary br))) (DL.snoc prev (i, result)) rest+ renderHis (remainingPrimary - (result^.imageL.(to $ imagePrimary br)))+ (DL.snoc prev (i, result)) rest renderedHis <- renderHis availPrimary DL.empty his renderedLows <- case lows of [] -> return [] ls -> do- let remainingPrimary = c^.(contextPrimary br) - (sum $ (^._2.imageL.(to $ imagePrimary br)) <$> renderedHis)+ let remainingPrimary = c^.(contextPrimary br) -+ (sum $ (^._2.imageL.(to $ imagePrimary br)) <$> renderedHis) primaryPerLow = remainingPrimary `div` length ls padFirst = remainingPrimary - (primaryPerLow * length ls) secondaryPerLow = c^.(contextSecondary br)@@ -477,7 +480,8 @@ -- attribute. In a horizontal box we want all images to have -- the same height for the same reason. maxSecondary = maximum $ imageSecondary br <$> allImages- padImage img = padImageSecondary br (maxSecondary - imageSecondary br img) img (c^.attrL)+ padImage img = padImageSecondary br (maxSecondary - imageSecondary br img)+ img (c^.attrL) paddedImages = padImage <$> allImages cropResultToContext $ Result (concatenatePrimary br paddedImages)@@ -613,13 +617,15 @@ hRelease :: Widget n -> Maybe (Widget n) hRelease p = case hSize p of- Fixed -> Just $ Widget Greedy (vSize p) $ withReaderT (& availWidthL .~ unrestricted) (render p)+ Fixed -> Just $ Widget Greedy (vSize p) $+ withReaderT (& availWidthL .~ unrestricted) (render p) Greedy -> Nothing vRelease :: Widget n -> Maybe (Widget n) vRelease p = case vSize p of- Fixed -> Just $ Widget (hSize p) Greedy $ withReaderT (& availHeightL .~ unrestricted) (render p)+ Fixed -> Just $ Widget (hSize p) Greedy $+ withReaderT (& availHeightL .~ unrestricted) (render p) Greedy -> Nothing -- | Render the specified widget. If the widget has an entry in the@@ -685,12 +691,13 @@ observed <- use observedNamesL case S.member n observed of False -> observedNamesL %= S.insert n- True -> error $ "Error: while rendering the interface, the name " <> show n <>- " was seen more than once. You should ensure that all of the widgets " <>- "in each interface have unique name values. This means either " <>- "using a different name type or adding constructors to your " <>- "existing one and using those to name your widgets. For more " <>- "information, see the \"Resource Names\" section of the Brick User Guide."+ True ->+ error $ "Error: while rendering the interface, the name " <> show n <>+ " was seen more than once. You should ensure that all of the widgets " <>+ "in each interface have unique name values. This means either " <>+ "using a different name type or adding constructors to your " <>+ "existing one and using those to name your widgets. For more " <>+ "information, see the \"Resource Names\" section of the Brick User Guide." observeName vpname @@ -703,13 +710,17 @@ let release = case typ of Vertical -> vRelease Horizontal -> hRelease- Both ->vRelease >=> hRelease+ Both -> vRelease >=> hRelease released = case release p of Just w -> w Nothing -> case typ of- Vertical -> error $ "tried to embed an infinite-height widget in vertical viewport " <> (show vpname)- Horizontal -> error $ "tried to embed an infinite-width widget in horizontal viewport " <> (show vpname)- Both -> error $ "tried to embed an infinite-width or infinite-height widget in 'Both' type viewport " <> (show vpname)+ Vertical -> error $ "tried to embed an infinite-height " <>+ "widget in vertical viewport " <> (show vpname)+ Horizontal -> error $ "tried to embed an infinite-width " <>+ "widget in horizontal viewport " <> (show vpname)+ Both -> error $ "tried to embed an infinite-width or " <>+ "infinite-height widget in 'Both' type " <>+ "viewport " <> (show vpname) initialResult <- render released @@ -772,13 +783,16 @@ , translated^.imageL.to V.imageHeight ) case translatedSize of- (0, 0) -> return $ translated & imageL .~ (V.charFill (c^.attrL) ' ' (c^.availWidthL) (c^.availHeightL))- & visibilityRequestsL .~ mempty- & extentsL .~ mempty+ (0, 0) -> do+ let spaceFill = V.charFill (c^.attrL) ' ' (c^.availWidthL) (c^.availHeightL)+ return $ translated & imageL .~ spaceFill+ & visibilityRequestsL .~ mempty+ & extentsL .~ mempty _ -> render $ cropToContext $ padBottom Max $ padRight Max- $ Widget Fixed Fixed $ return $ translated & visibilityRequestsL .~ mempty+ $ Widget Fixed Fixed+ $ return $ translated & visibilityRequestsL .~ mempty -- | Given a name, obtain the viewport for that name by consulting the -- viewport map in the rendering monad. NOTE! Some care must be taken
src/Brick/Widgets/List.hs view
@@ -202,7 +202,7 @@ es = l^.listElementsL newSel = case l^.listSelectedL of Nothing -> 0- Just s -> if safePos < s+ Just s -> if safePos <= s then s + 1 else s (front, back) = V.splitAt safePos es