Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type Box = Widget BoxId
- newtype BoxId = BoxId {}
- data Win = Win {}
- data Act = Quit
- data MouseUpEvent = MouseUpEvent BoxId (Maybe Button) Location
- data MouseDownEvent = MouseDownEvent BoxId Button [Modifier] Location
- liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c
- sort2B :: (IfB a, OrdB a) => (a, a) -> (a, a)
- maxB :: (IfB a, OrdB a) => a -> a -> a
- minB :: (IfB a, OrdB a) => a -> a -> a
- caseB :: (IfB b, bool ~ BooleanOf b) => a -> [(a -> bool, b)] -> b -> b
- guardedB :: (IfB b, bool ~ BooleanOf b) => bool -> [(bool, b)] -> b -> b
- crop :: (Applicative f, Monoid (f a), IfB a, bool ~ BooleanOf a) => f bool -> f a -> f a
- cond :: (Applicative f, IfB a, bool ~ BooleanOf a) => f bool -> f a -> f a -> f a
- boolean :: (IfB a, bool ~ BooleanOf a) => a -> a -> bool -> a
- class Boolean b where
- type family BooleanOf a
- class Boolean (BooleanOf a) => IfB a where
- class Boolean (BooleanOf a) => EqB a where
- class Boolean (BooleanOf a) => OrdB a where
- liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
- makeVisible :: Ord n => n -> EventM n ()
- suspendAndResume :: IO s -> EventM n (Next s)
- halt :: s -> EventM n (Next s)
- continueWithoutRedraw :: s -> EventM n (Next s)
- continue :: s -> EventM n (Next s)
- viewportScroll :: n -> ViewportScroll n
- showCursorNamed :: Eq n => n -> [CursorLocation n] -> Maybe (CursorLocation n)
- showFirstCursor :: s -> [CursorLocation n] -> Maybe (CursorLocation n)
- neverShowCursor :: s -> [CursorLocation n] -> Maybe (CursorLocation n)
- resetRenderState :: RenderState n -> RenderState n
- getRenderState :: EventM n (RenderState n)
- invalidateCache :: Ord n => EventM n ()
- invalidateCacheEntry :: Ord n => n -> EventM n ()
- getVtyHandle :: EventM n Vty
- findClickedExtents :: (Int, Int) -> EventM n [Extent n]
- lookupExtent :: Eq n => n -> EventM n (Maybe (Extent n))
- clickedExtent :: (Int, Int) -> Extent n -> Bool
- lookupViewport :: Ord n => n -> EventM n (Maybe Viewport)
- customMainWithVty :: Ord n => Vty -> IO Vty -> Maybe (BChan e) -> App s e n -> s -> IO (s, Vty)
- customMain :: Ord n => Vty -> IO Vty -> Maybe (BChan e) -> App s e n -> s -> IO s
- resizeOrQuit :: s -> BrickEvent n e -> EventM n (Next s)
- simpleApp :: Widget n -> App s e n
- simpleMain :: Ord n => Widget n -> IO ()
- defaultMain :: Ord n => App s e n -> s -> IO s
- data App s e n = App {
- appDraw :: s -> [Widget n]
- appChooseCursor :: s -> [CursorLocation n] -> Maybe (CursorLocation n)
- appHandleEvent :: s -> BrickEvent n e -> EventM n (Next s)
- appStartEvent :: s -> EventM n s
- appAttrMap :: s -> AttrMap
- data ViewportScroll n
- (<=>) :: Widget n -> Widget n -> Widget n
- (<+>) :: Widget n -> Widget n -> Widget n
- visibleRegion :: Location -> DisplayRegion -> Widget n -> Widget n
- visible :: Widget n -> Widget n
- unsafeLookupViewport :: Ord n => n -> RenderM n (Maybe Viewport)
- horizontalScrollbar :: Ord n => ScrollbarRenderer n -> n -> Maybe (ClickableScrollbarElement -> n -> n) -> Bool -> Int -> Int -> Int -> Widget n
- verticalScrollbar :: Ord n => ScrollbarRenderer n -> n -> Maybe (ClickableScrollbarElement -> n -> n) -> Bool -> Int -> Int -> Int -> Widget n
- scrollbarHandleAttr :: AttrName
- scrollbarTroughAttr :: AttrName
- scrollbarAttr :: AttrName
- viewport :: (Ord n, Show n) => n -> ViewportType -> Widget n -> Widget n
- horizontalScrollbarRenderer :: ScrollbarRenderer n
- withHScrollBarRenderer :: ScrollbarRenderer n -> Widget n -> Widget n
- withHScrollBarHandles :: Widget n -> Widget n
- withClickableVScrollBars :: (ClickableScrollbarElement -> n -> n) -> Widget n -> Widget n
- withClickableHScrollBars :: (ClickableScrollbarElement -> n -> n) -> Widget n -> Widget n
- withHScrollBars :: HScrollBarOrientation -> Widget n -> Widget n
- verticalScrollbarRenderer :: ScrollbarRenderer n
- withVScrollBarRenderer :: ScrollbarRenderer n -> Widget n -> Widget n
- withVScrollBarHandles :: Widget n -> Widget n
- withVScrollBars :: VScrollBarOrientation -> Widget n -> Widget n
- cached :: Ord n => n -> Widget n -> Widget n
- putCursor :: n -> Location -> Widget n -> Widget n
- showCursor :: n -> Location -> Widget n -> Widget n
- cropBottomTo :: Int -> Widget n -> Widget n
- cropBottomBy :: Int -> Widget n -> Widget n
- cropTopTo :: Int -> Widget n -> Widget n
- cropTopBy :: Int -> Widget n -> Widget n
- cropRightTo :: Int -> Widget n -> Widget n
- cropRightBy :: Int -> Widget n -> Widget n
- cropLeftTo :: Int -> Widget n -> Widget n
- cropLeftBy :: Int -> Widget n -> Widget n
- translateBy :: Location -> Widget n -> Widget n
- raw :: Image -> Widget n
- overrideAttr :: AttrName -> AttrName -> Widget n -> Widget n
- forceAttr :: AttrName -> Widget n -> Widget n
- updateAttrMap :: (AttrMap -> AttrMap) -> Widget n -> Widget n
- withDefAttr :: AttrName -> Widget n -> Widget n
- modifyDefAttr :: (Attr -> Attr) -> Widget n -> Widget n
- withAttr :: AttrName -> Widget n -> Widget n
- setAvailableSize :: (Int, Int) -> Widget n -> Widget n
- vLimitPercent :: Int -> Widget n -> Widget n
- vLimit :: Int -> Widget n -> Widget n
- hLimitPercent :: Int -> Widget n -> Widget n
- hLimit :: Int -> Widget n -> Widget n
- hBox :: [Widget n] -> Widget n
- vBox :: [Widget n] -> Widget n
- fill :: Char -> Widget n
- padAll :: Int -> Widget n -> Widget n
- padTopBottom :: Int -> Widget n -> Widget n
- padLeftRight :: Int -> Widget n -> Widget n
- padBottom :: Padding -> Widget n -> Widget n
- padTop :: Padding -> Widget n -> Widget n
- padRight :: Padding -> Widget n -> Widget n
- padLeft :: Padding -> Widget n -> Widget n
- hyperlink :: Text -> Widget n -> Widget n
- txt :: Text -> Widget n
- str :: String -> Widget n
- txtWrapWith :: WrapSettings -> Text -> Widget n
- txtWrap :: Text -> Widget n
- strWrapWith :: WrapSettings -> String -> Widget n
- strWrap :: String -> Widget n
- clickable :: Ord n => n -> Widget n -> Widget n
- reportExtent :: Ord n => n -> Widget n -> Widget n
- addResultOffset :: Location -> Result n -> Result n
- emptyWidget :: Widget n
- freezeBorders :: Widget n -> Widget n
- separateBorders :: Widget n -> Widget n
- joinBorders :: Widget n -> Widget n
- withBorderStyle :: BorderStyle -> Widget n -> Widget n
- class TextWidth a where
- class Named a n where
- getName :: a -> n
- cropToContext :: Widget n -> Widget n
- renderFinal :: AttrMap -> [Widget n] -> DisplayRegion -> ([CursorLocation n] -> Maybe (CursorLocation n)) -> RenderState n -> (RenderState n, Picture, Maybe (CursorLocation n), [Extent n])
- lookupAttrName :: AttrName -> RenderM n Attr
- attrL :: Getting r (Context n) Attr
- handleEventLensed :: a -> Lens' a b -> (e -> b -> EventM n b) -> e -> EventM n a
- data Padding
- newtype EventM n a = EventM {}
- clOffset :: CursorLocation n -> Location -> CursorLocation n
- bg :: Color -> Attr
- fg :: Color -> Attr
- on :: Color -> Color -> Attr
- clamp :: Ord a => a -> a -> a -> a
- vpTop :: Lens' Viewport Int
- vpSize :: Lens' Viewport DisplayRegion
- vpLeft :: Lens' Viewport Int
- vpContentSize :: Lens' Viewport DisplayRegion
- bsOfferL :: Lens' BorderSegment Bool
- bsDrawL :: Lens' BorderSegment Bool
- bsAcceptL :: Lens' BorderSegment Bool
- visibilityRequestsL :: Lens' (Result n) [VisibilityRequest]
- imageL :: Lens' (Result n) Image
- extentsL :: Lens' (Result n) [Extent n]
- cursorsL :: Lens' (Result n) [CursorLocation n]
- bordersL :: Lens' (Result n) (BorderMap DynBorder)
- dbStyleL :: Lens' DynBorder BorderStyle
- dbSegmentsL :: Lens' DynBorder (Edges BorderSegment)
- dbAttrL :: Lens' DynBorder Attr
- windowWidthL :: Lens' (Context n) Int
- windowHeightL :: Lens' (Context n) Int
- ctxVScrollBarRendererL :: Lens' (Context n) (Maybe (ScrollbarRenderer n))
- ctxVScrollBarOrientationL :: Lens' (Context n) (Maybe VScrollBarOrientation)
- ctxHScrollBarRendererL :: Lens' (Context n) (Maybe (ScrollbarRenderer n))
- ctxHScrollBarOrientationL :: Lens' (Context n) (Maybe HScrollBarOrientation)
- ctxDynBordersL :: Lens' (Context n) Bool
- ctxBorderStyleL :: Lens' (Context n) BorderStyle
- ctxAttrNameL :: Lens' (Context n) AttrName
- ctxAttrMapL :: Lens' (Context n) AttrMap
- availWidthL :: Lens' (Context n) Int
- availHeightL :: Lens' (Context n) Int
- cursorLocationNameL :: Lens (CursorLocation n1) (CursorLocation n2) (Maybe n1) (Maybe n2)
- cursorLocationL :: Lens' (CursorLocation n) Location
- vrSizeL :: Lens' VisibilityRequest DisplayRegion
- vrPositionL :: Lens' VisibilityRequest Location
- emptyResult :: Result n
- getContext :: RenderM n (Context n)
- data Size
- data Widget n = Widget {}
- data RenderState n
- type RenderM n a = ReaderT (Context n) (State (RenderState n)) a
- data VScrollBarOrientation
- data HScrollBarOrientation
- data ScrollbarRenderer n = ScrollbarRenderer {}
- data VisibilityRequest = VR {}
- data Viewport = VP {}
- data ViewportType
- = Vertical
- | Horizontal
- | Both
- data Extent n = Extent {
- extentName :: n
- extentUpperLeft :: Location
- extentSize :: (Int, Int)
- data Next a
- data Direction
- class TerminalLocation a where
- locationColumnL :: Lens' a Int
- locationColumn :: a -> Int
- locationRowL :: Lens' a Int
- locationRow :: a -> Int
- data CursorLocation n = CursorLocation {
- cursorLocation :: !Location
- cursorLocationName :: !(Maybe n)
- cursorLocationVisible :: !Bool
- data BorderSegment = BorderSegment {}
- data DynBorder = DynBorder {}
- data Result n = Result {
- image :: Image
- cursors :: [CursorLocation n]
- visibilityRequests :: [VisibilityRequest]
- extents :: [Extent n]
- borders :: BorderMap DynBorder
- data BrickEvent n e
- data ClickableScrollbarElement
- data Context n
- eTopL :: Lens' (Edges a) a
- eRightL :: Lens' (Edges a) a
- eLeftL :: Lens' (Edges a) a
- eBottomL :: Lens' (Edges a) a
- locL :: Lens' Location (Int, Int)
- data Edges a = Edges {}
- data Location = Location {}
- suffixLensesWith :: String -> LensRules -> Name -> DecsQ
- suffixLenses :: Name -> DecsQ
- mapAttrNames :: [(AttrName, AttrName)] -> AttrMap -> AttrMap
- mapAttrName :: AttrName -> AttrName -> AttrMap -> AttrMap
- applyAttrMappings :: [(AttrName, Attr)] -> AttrMap -> AttrMap
- getDefaultAttr :: AttrMap -> Attr
- setDefaultAttr :: Attr -> AttrMap -> AttrMap
- attrMapLookup :: AttrName -> AttrMap -> Attr
- mergeWithDefault :: Attr -> AttrMap -> Attr
- forceAttrMap :: Attr -> AttrMap
- attrMap :: Attr -> [(AttrName, Attr)] -> AttrMap
- attrNameComponents :: AttrName -> [String]
- attrName :: String -> AttrName
- data AttrName
- data AttrMap
- class Default a where
- def :: a
- newtype Sum a = Sum {
- getSum :: a
- class AdditiveGroup v where
- sumV :: (Foldable f, AdditiveGroup v) => f v -> v
- inSum :: (a -> b) -> Sum a -> Sum b
- inSum2 :: (a -> b -> c) -> Sum a -> Sum b -> Sum c
- class (VectorSpace v, AdditiveGroup (Scalar v)) => InnerSpace v where
- class AdditiveGroup v => VectorSpace v where
- type family Scalar v
- (^/) :: (VectorSpace v, s ~ Scalar v, Fractional s) => v -> s -> v
- (^*) :: (VectorSpace v, s ~ Scalar v) => v -> s -> v
- lerp :: VectorSpace v => v -> v -> Scalar v -> v
- linearCombo :: VectorSpace v => [(v, Scalar v)] -> v
- magnitudeSq :: (InnerSpace v, s ~ Scalar v) => v -> s
- magnitude :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> s
- normalized :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> v
- project :: (InnerSpace v, s ~ Scalar v, Fractional s) => v -> v -> v
- class AdditiveGroup (Diff p) => AffineSpace p where
- type family Diff p
- (.-^) :: AffineSpace p => p -> Diff p -> p
- distanceSq :: (AffineSpace p, v ~ Diff p, InnerSpace v) => p -> p -> Scalar v
- distance :: (AffineSpace p, v ~ Diff p, InnerSpace v, s ~ Scalar v, Floating (Scalar v)) => p -> p -> s
- alerp :: (AffineSpace p, VectorSpace (Diff p)) => p -> p -> Scalar (Diff p) -> p
- affineCombo :: (AffineSpace p, v ~ Diff p, VectorSpace v) => p -> [(p, Scalar v)] -> p
- class HasCross3 v where
- cross3 :: v -> v -> v
- class HasCross2 v where
- cross2 :: v -> v
- type Three s = (s, s, s)
- type Two s = (s, s)
- type One s = s
- class HasNormal v where
- normalVec :: v -> v
- normal :: (HasNormal v, InnerSpace v, Floating (Scalar v)) => v -> v
- class Loop a where
- loop :: a -> a
- class Limit a where
- class (Melody a, Harmony a) => Compose a
- class Harmony a where
- class Melody a where
- recompose :: HasBasis v => [(Basis v, Scalar v)] -> v
- type family Basis v
- class VectorSpace v => HasBasis v where
- type Basis v
- basisValue :: Basis v -> v
- decompose :: v -> [(Basis v, Scalar v)]
- decompose' :: v -> Basis v -> Scalar v
- data Key
- data Modifier
- data Dyn a
- data Evt a
- data Run a
- data Spec = Spec {
- spec'attrMap :: AttrMap
- spec'cursor :: [CursorLocation BoxId] -> Maybe (CursorLocation BoxId)
- defSpec :: AttrMap -> Spec
- emptyAttrMap :: AttrMap
- runApp :: Spec -> Run Win -> IO ()
- vtyEvents :: Evt Event
- mouseDown :: Evt MouseDownEvent
- mouseUp :: Evt MouseUpEvent
- keyEvents :: Evt (Key, [Modifier])
- onChar :: Char -> Evt [Modifier]
- readChars :: Evt Char
- onKey :: Key -> Evt [Modifier]
- class RunFunctor f where
- data DynRef a
- constDyn :: Run a -> Dyn a
- runDyn :: Dyn a -> Run (DynRef a)
- once :: Run a -> Evt a
- never :: Evt a
- newEvt :: Evt a -> Run (Evt a)
- newDyn :: Dyn a -> Run (Dyn a)
- accum :: (a -> s -> (b, s)) -> s -> Evt a -> Evt b
- accum' :: (a -> s -> Run (b, s)) -> s -> Evt a -> Evt b
- accumMay :: (a -> s -> Maybe (b, s)) -> s -> Evt a -> Evt b
- accumMay' :: (a -> s -> Run (Maybe (b, s))) -> s -> Evt a -> Evt b
- scan :: (a -> b -> b) -> b -> Evt a -> Evt b
- scan' :: (a -> b -> Run b) -> b -> Evt a -> Evt b
- scanMay :: (a -> b -> Maybe b) -> b -> Evt a -> Evt b
- scanMay' :: (a -> b -> Run (Maybe b)) -> b -> Evt a -> Evt b
- foldMaps :: Monoid b => (a -> b) -> Evt a -> Evt b
- races :: Evt a -> Evt a -> Evt a
- forks :: Evt a -> Evt a
- forevers :: Evt a -> Evt a
- iterates :: (a -> a) -> a -> Evt b -> Evt a
- withIterates :: (a -> a) -> a -> Evt b -> Evt (a, b)
- iterates' :: (a -> Run a) -> a -> Evt b -> Evt a
- readDyn :: DynRef a -> Run a
- cancelDyn :: DynRef a -> Run ()
- hold :: a -> Evt a -> Dyn a
- count :: Evt a -> Evt Int
- withCount :: Evt a -> Evt (Int, a)
- unhold :: Dyn a -> Evt a
- scanD :: (a -> b -> b) -> b -> Evt a -> Dyn b
- accumB :: a -> Evt (a -> a) -> Dyn a
- scanMayD :: (a -> b -> Maybe b) -> b -> Evt a -> Dyn b
- foreach :: (a -> Run ()) -> Evt a -> Evt a
- posteach :: (a -> Run ()) -> Evt a -> Evt a
- apply :: Dyn (a -> b) -> Evt a -> Evt b
- apply' :: Dyn (a -> Run b) -> Evt a -> Evt b
- (<@>) :: Dyn (a -> b) -> Evt a -> Evt b
- (<@) :: Dyn a -> Evt b -> Evt a
- applyMay :: Dyn (a -> Maybe b) -> Evt a -> Evt b
- applyMay' :: Dyn (a -> Run (Maybe b)) -> Evt a -> Evt b
- snap :: Dyn a -> Evt b -> Evt a
- attach :: Dyn a -> Evt b -> Evt (a, b)
- attachWith :: (a -> b -> c) -> Dyn a -> Evt b -> Evt c
- attachWithMay :: (a -> b -> Maybe c) -> Dyn a -> Evt b -> Evt c
- mapMay :: (a -> Maybe b) -> Evt a -> Evt b
- mapMay' :: (a -> Run (Maybe b)) -> Evt a -> Evt b
- filters :: (a -> Bool) -> Evt a -> Evt a
- filters' :: (a -> Run Bool) -> Evt a -> Evt a
- filterJust :: Evt (Maybe a) -> Evt a
- whens :: Dyn Bool -> Evt a -> Evt a
- splits :: Evt (Either a b) -> (Evt a, Evt b)
- lefts :: Evt (Either a b) -> Evt a
- rights :: Evt (Either a b) -> Evt b
- takes :: Int -> Evt a -> Evt a
- drops :: Int -> Evt a -> Evt a
- takesWhile :: (a -> Bool) -> Evt a -> Evt a
- dropsWhile :: (a -> Bool) -> Evt a -> Evt a
- listAt :: [a] -> Evt Int -> Evt a
- toToggle :: Evt a -> Evt Bool
- cycles :: [a] -> Evt b -> Evt a
- sums :: Num a => Evt a -> Evt a
- sumD :: Num a => Float -> Dyn a -> Dyn a
- integrate :: (VectorSpace v, Scalar v ~ Float) => Float -> Dyn v -> Dyn v
- integrate2 :: (VectorSpace v, Scalar v ~ Float) => Float -> Dyn v -> Dyn v
- products :: Num a => Evt a -> Evt a
- appends :: Monoid a => Evt a -> Evt a
- folds :: Monoid a => Evt a -> Run a
- foldls :: (b -> a -> b) -> b -> Evt a -> Run b
- foldls' :: (b -> a -> Run b) -> b -> Evt a -> Run b
- foldrs :: (a -> b -> b) -> b -> Evt a -> Run b
- foldrs' :: (a -> b -> Run b) -> b -> Evt a -> Run b
- prints :: Show a => Evt a -> Run ()
- putStrLns :: Evt String -> Run ()
- switchDyn :: Dyn (Evt a) -> Evt a
- joins :: Evt (Evt a) -> Evt a
- fix1 :: (Evt a -> Run (Evt a)) -> Evt a
- fix2 :: (Evt a -> Evt b -> Run (Evt a, Evt b)) -> (Evt a, Evt b)
- fix3 :: (Evt a -> Evt b -> Evt c -> Run (Evt a, Evt b, Evt c)) -> (Evt a, Evt b, Evt c)
- fix4 :: (Evt a -> Evt b -> Evt c -> Evt d -> Run (Evt a, Evt b, Evt c, Evt d)) -> (Evt a, Evt b, Evt c, Evt d)
- switch :: Evt (Evt a) -> Evt a
- switchD :: Dyn a -> Evt (Dyn a) -> Dyn a
- mchanEvt :: Chan a -> Evt a
- tchanEvt :: TChan a -> Evt a
- uchanEvt :: InChan a -> Evt a
- clock :: NominalDiffTime -> Evt UTCTime
- pulse :: NominalDiffTime -> Evt ()
- ticks :: Float -> Evt Float
- timer :: Float -> Evt Float
- timerD :: Float -> Dyn Float
- toRandom :: Random b => Evt a -> Evt b
- toRandomR :: Random b => (b, b) -> Evt a -> Evt b
- withRandom :: Random b => Evt a -> Evt (b, a)
- withRandomR :: Random b => (b, b) -> Evt a -> Evt (b, a)
- oneOf :: [a] -> Evt b -> Evt a
- withOneOf :: [a] -> Evt b -> Evt (a, b)
- freqOf :: Dyn [(a, Rational)] -> Evt b -> Evt a
- withFreqOf :: Dyn [(a, Rational)] -> Evt b -> Evt (a, b)
- randSkip :: Dyn Double -> Evt a -> Evt a
- randSkipBy :: Dyn (a -> Double) -> Evt a -> Evt a
- delay :: NominalDiffTime -> Evt a -> Evt a
- delayFork :: NominalDiffTime -> Evt a -> Evt a
Brick helper types
Box identifier
Window of the application
Re-exports
liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c #
Lift a binary function to actions.
Some functors support an implementation of liftA2
that is more
efficient than the default one. In particular, if fmap
is an
expensive operation, it is likely better to use liftA2
than to
fmap
over the structure and then use <*>
.
This became a typeclass method in 4.10.0.0. Prior to that, it was
a function defined in terms of <*>
and fmap
.
Using ApplicativeDo
: '
' can be understood
as the liftA2
f as bsdo
expression
do a <- as b <- bs pure (f a b)
caseB :: (IfB b, bool ~ BooleanOf b) => a -> [(a -> bool, b)] -> b -> b #
A generalized version of a case like control structure.
guardedB :: (IfB b, bool ~ BooleanOf b) => bool -> [(bool, b)] -> b -> b #
A generalized replacement for guards and chained ifs.
crop :: (Applicative f, Monoid (f a), IfB a, bool ~ BooleanOf a) => f bool -> f a -> f a #
Generalized cropping, filling in mempty
where the test yields false.
cond :: (Applicative f, IfB a, bool ~ BooleanOf a) => f bool -> f a -> f a -> f a #
Point-wise conditional
boolean :: (IfB a, bool ~ BooleanOf a) => a -> a -> bool -> a #
Expression-lifted conditional with condition last
Generalized boolean class
BooleanOf
computed the boolean analog of a specific type.
Instances
type BooleanOf Bool | |
Defined in Data.Boolean | |
type BooleanOf Char | |
Defined in Data.Boolean | |
type BooleanOf Double | |
Defined in Data.Boolean | |
type BooleanOf Float | |
Defined in Data.Boolean | |
type BooleanOf Int | |
Defined in Data.Boolean | |
type BooleanOf Integer | |
Defined in Data.Boolean | |
type BooleanOf [a] | |
Defined in Data.Boolean | |
type BooleanOf (Dyn a) Source # | |
Defined in Dyna.Brick.Types | |
type BooleanOf (z -> a) | |
Defined in Data.Boolean | |
type BooleanOf (a, b) | |
Defined in Data.Boolean | |
type BooleanOf (Dyn m a) | |
type BooleanOf (a :> b) | |
Defined in Data.Maclaurin | |
type BooleanOf (a, b, c) | |
Defined in Data.Boolean | |
type BooleanOf (a, b, c, d) | |
Defined in Data.Boolean |
class Boolean (BooleanOf a) => IfB a where #
Types with conditionals
Instances
IfB Bool | |
IfB Char | |
IfB Double | |
IfB Float | |
IfB Int | |
IfB Integer | |
(Boolean (BooleanOf a), BooleanOf a ~ Bool) => IfB [a] | |
Defined in Data.Boolean | |
IfB a => IfB (Dyn a) Source # | |
IfB a => IfB (z -> a) | |
Defined in Data.Boolean | |
(bool ~ BooleanOf p, bool ~ BooleanOf q, IfB p, IfB q) => IfB (p, q) | |
Defined in Data.Boolean | |
(Frp m, IfB a) => IfB (Dyn m a) | |
(AdditiveGroup v, HasBasis u, HasTrie (Basis u), IfB v) => IfB (u :> v) | |
(bool ~ BooleanOf p, bool ~ BooleanOf q, bool ~ BooleanOf r, IfB p, IfB q, IfB r) => IfB (p, q, r) | |
Defined in Data.Boolean | |
(bool ~ BooleanOf p, bool ~ BooleanOf q, bool ~ BooleanOf r, bool ~ BooleanOf s, IfB p, IfB q, IfB r, IfB s) => IfB (p, q, r, s) | |
Defined in Data.Boolean |
class Boolean (BooleanOf a) => EqB a where #
Types with equality. Minimum definition: (==*)
.
class Boolean (BooleanOf a) => OrdB a where #
Types with inequality. Minimum definition: (<*)
.
(<*) :: bool ~ BooleanOf a => a -> a -> bool infix 4 #
(<=*) :: bool ~ BooleanOf a => a -> a -> bool infix 4 #
liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d #
Lift a ternary function to actions.
Using ApplicativeDo
: '
' can be understood
as the liftA3
f as bs csdo
expression
do a <- as b <- bs c <- cs pure (f a b c)
makeVisible :: Ord n => n -> EventM n () #
Request that the specified UI element be made visible on the
next rendering. This is provided to allow event handlers to make
visibility requests in the same way that the visible
function does
at rendering time.
suspendAndResume :: IO s -> EventM n (Next s) #
Suspend the event loop, save the terminal state, and run the specified action. When it returns an application state value, restore the terminal state, empty the rendering cache, redraw the application from the new state, and resume the event loop.
Note that any changes made to the terminal's input state are ignored when Brick resumes execution and are not preserved in the final terminal input state after the Brick application returns the terminal to the user.
halt :: s -> EventM n (Next s) #
Halt the event loop and return the specified application state as the final state value.
continueWithoutRedraw :: s -> EventM n (Next s) #
Continue running the event loop with the specified application
state without redrawing the screen. This is faster than continue
because it skips the redraw, but the drawback is that you need to
be really sure that you don't want a screen redraw. If your state
changed in a way that needs to be reflected on the screen, use
continue
. This function is for cases where you know that you did
something that won't have an impact on the screen state and you want
to save on redraw cost.
continue :: s -> EventM n (Next s) #
Continue running the event loop with the specified application state.
viewportScroll :: n -> ViewportScroll n #
Build a viewport scroller for the viewport with the specified name.
showCursorNamed :: Eq n => n -> [CursorLocation n] -> Maybe (CursorLocation n) #
Show the cursor with the specified resource name, if such a cursor location has been reported.
showFirstCursor :: s -> [CursorLocation n] -> Maybe (CursorLocation n) #
Always show the first cursor, if any, returned by the rendering
process. This is a convenience function useful as an
appChooseCursor
value when a simple program has zero or more
widgets that advertise a cursor position.
neverShowCursor :: s -> [CursorLocation n] -> Maybe (CursorLocation n) #
Ignore all requested cursor positions returned by the rendering
process. This is a convenience function useful as an
appChooseCursor
value when a simple application has no need to
position the cursor.
resetRenderState :: RenderState n -> RenderState n #
getRenderState :: EventM n (RenderState n) #
invalidateCache :: Ord n => EventM n () #
Invalidate the entire rendering cache.
invalidateCacheEntry :: Ord n => n -> EventM n () #
Invalidate the rendering cache entry with the specified resource name.
getVtyHandle :: EventM n Vty #
Get the Vty handle currently in use.
findClickedExtents :: (Int, Int) -> EventM n [Extent n] #
Given a mouse click location, return the extents intersected by the click. The returned extents are sorted such that the first extent in the list is the most specific extent and the last extent is the most generic (top-level). So if two extents A and B both intersected the mouse click but A contains B, then they would be returned [B, A].
lookupExtent :: Eq n => n -> EventM n (Maybe (Extent n)) #
Given a resource name, get the most recent rendering extent for the name (if any).
clickedExtent :: (Int, Int) -> Extent n -> Bool #
Did the specified mouse coordinates (column, row) intersect the specified extent?
lookupViewport :: Ord n => n -> EventM n (Maybe Viewport) #
Given a viewport name, get the viewport's size and offset
information from the most recent rendering. Returns Nothing
if
no such state could be found, either because the name was invalid
or because no rendering has occurred (e.g. in an appStartEvent
handler). An important consequence of this behavior is that if this
function is called before a viewport is rendered for the first
time, no state will be found because the renderer only knows about
viewports it has rendered in the most recent rendering. As a result,
if you need to make viewport transformations before they are drawn
for the first time, you may need to use viewportScroll
and its
associated functions without relying on this function. Those
functions queue up scrolling requests that can be made in advance of
the next rendering to affect the viewport.
:: Ord n | |
=> Vty | The initial Vty handle to use. |
-> IO Vty | An IO action to build a Vty handle. This is used to build a Vty handle whenever the event loop needs to reinitialize the terminal, e.g. on resume after suspension. |
-> Maybe (BChan e) | An event channel for sending custom events to the event
loop (you write to this channel, the event loop reads from
it). Provide |
-> App s e n | The application. |
-> s | The initial application state. |
-> IO (s, Vty) |
Like customMain
, except the last Vty
handle used by the
application is returned without being shut down with shutdown
. This
allows the caller to re-use the Vty
handle for something else, such
as another Brick application.
:: Ord n | |
=> Vty | The initial Vty handle to use. |
-> IO Vty | An IO action to build a Vty handle. This is used to build a Vty handle whenever the event loop needs to reinitialize the terminal, e.g. on resume after suspension. |
-> Maybe (BChan e) | An event channel for sending custom events to the event
loop (you write to this channel, the event loop reads from
it). Provide |
-> App s e n | The application. |
-> s | The initial application state. |
-> IO s |
The custom event loop entry point to use when the simpler ones don't permit enough control. Returns the final application state after the application halts.
Note that this function guarantees that the terminal input state prior to the first Vty initialization is the terminal input state that is restored on shutdown (regardless of exceptions).
resizeOrQuit :: s -> BrickEvent n e -> EventM n (Next s) #
An event-handling function which continues execution of the event
loop only when resize events occur; all other types of events trigger
a halt. This is a convenience function useful as an appHandleEvent
value for simple applications using the Event
type that do not need
to get more sophisticated user input.
simpleApp :: Widget n -> App s e n #
A simple application with reasonable defaults to be overridden as desired:
- Draws only the specified widget
- Quits on any event other than resizes
- Has no start event handler
- Provides no attribute map
- Never shows any cursors
A simple main entry point which takes a widget and renders it. This event loop terminates when the user presses any key, but terminal resize events cause redraws.
The default main entry point which takes an application and an
initial state and returns the final state returned by a halt
operation.
The library application abstraction. Your application's operations
are provided in an App
and then the App
is provided to one of the
various main functions in this module. An application App s e n
is in terms of an application state type s
, an application event
type e
, and a resource name type n
. In the simplest case e
is
unused (left polymorphic or set to ()
), but you may define your own
event type and use customMain
to provide custom events. The state
type s
is the type of application state to be provided by you and
iteratively modified by event handlers. The resource name type n
is the type of names you can assign to rendering resources such as
viewports and cursor locations. Your application must define this
type.
App | |
|
data ViewportScroll n #
A viewport scrolling handle for managing the scroll state of viewports.
Vertical box layout: put the specified widgets one above the other
in the specified order. Defers growth policies to the growth policies
of both widgets. This operator is a binary version of vBox
.
Horizontal box layout: put the specified widgets next to each other
in the specified order. Defers growth policies to the growth policies
of both widgets. This operator is a binary version of hBox
.
visibleRegion :: Location -> DisplayRegion -> Widget n -> Widget n #
Similar to visible
, request that a region (with the specified
Location
as its origin and DisplayRegion
as its size) be made
visible when it is rendered inside a viewport. The Location
is
relative to the specified widget's upper-left corner of (0, 0).
This does nothing if not rendered in a viewport.
visible :: Widget n -> Widget n #
Request that the specified widget be made visible when it is
rendered inside a viewport. This permits widgets (whose sizes and
positions cannot be known due to being embedded in arbitrary layouts)
to make a request for a parent viewport to locate them and scroll
enough to put them in view. This, together with viewport
, is what
makes the text editor and list widgets possible without making them
deal with the details of scrolling state management.
This does nothing if not rendered in a viewport.
unsafeLookupViewport :: Ord n => n -> RenderM n (Maybe Viewport) #
Given a name, obtain the viewport for that name by consulting the viewport map in the rendering monad. NOTE! Some care must be taken when calling this function, since it only returns useful values after the viewport in question has been rendered. If you call this function during rendering before a viewport has been rendered, you may get nothing or you may get a stale version of the viewport. This is because viewports are updated during rendering and the one you are interested in may not have been rendered yet. So if you want to use this, be sure you know what you are doing.
:: Ord n | |
=> ScrollbarRenderer n | The renderer to use. |
-> n | The viewport name associated with this scroll bar. |
-> Maybe (ClickableScrollbarElement -> n -> n) | Constructor for clickable scroll bar element names. |
-> Bool | Whether to show handles. |
-> Int | The total viewport width in effect. |
-> Int | The viewport horizontal scrolling offset in effect. |
-> Int | The total viewport content width. |
-> Widget n |
Build a horizontal scroll bar using the specified render and settings.
You probably don't want to use this directly; instead, use
viewport
, withHScrollBars
, and, if needed,
withHScrollBarRenderer
. This is exposed so that if you want to
render a scroll bar of your own, you can do so outside the viewport
context.
:: Ord n | |
=> ScrollbarRenderer n | The renderer to use. |
-> n | The viewport name associated with this scroll bar. |
-> Maybe (ClickableScrollbarElement -> n -> n) | Constructor for clickable scroll bar element names. |
-> Bool | Whether to display handles. |
-> Int | The total viewport height in effect. |
-> Int | The viewport vertical scrolling offset in effect. |
-> Int | The total viewport content height. |
-> Widget n |
Build a vertical scroll bar using the specified render and settings.
You probably don't want to use this directly; instead,
use viewport
, withVScrollBars
, and, if needed,
withVScrollBarRenderer
. This is exposed so that if you want to
render a scroll bar of your own, you can do so outside the viewport
context.
scrollbarHandleAttr :: AttrName #
The attribute for scroll bar handles. This attribute is a
specialization of scrollbarAttr
.
scrollbarTroughAttr :: AttrName #
The attribute for scroll bar troughs. This attribute is a
specialization of scrollbarAttr
.
The base attribute for scroll bars.
:: (Ord n, Show n) | |
=> n | The name of the viewport (must be unique and stable for reliable behavior) |
-> ViewportType | The type of viewport (indicates the permitted scrolling direction) |
-> Widget n | The widget to be rendered in the scrollable viewport |
-> Widget n |
Render the specified widget in a named viewport with the
specified type. This permits widgets to be scrolled without being
scrolling-aware. To make the most use of viewports, the specified
widget should use the visible
combinator to make a "visibility
request". This viewport combinator will then translate the resulting
rendering to make the requested region visible. In addition, the
EventM
monad provides primitives to scroll viewports
created by this function if visible
is not what you want.
This function can automatically render vertical and horizontal scroll
bars if desired. To enable scroll bars, wrap your call to viewport
with a call to withVScrollBars
and/or withHScrollBars
. If you
don't like the appearance of the resulting scroll bars (defaults:
verticalScrollbarRenderer
and horizontalScrollbarRenderer
),
you can customize how they are drawn by making your own
ScrollbarRenderer
and using withVScrollBarRenderer
and/or
withHScrollBarRenderer
. Note that when you enable scrollbars, the
content of your viewport will lose one column of available space if
vertical scroll bars are enabled and one row of available space if
horizontal scroll bars are enabled.
If a viewport receives more than one visibility request, then the
visibility requests are merged with the inner visibility request
taking preference. If a viewport receives more than one scrolling
request from EventM
, all are honored in the order in
which they are received.
Some caution should be advised when using this function. The viewport renders its contents anew each time the viewport is drawn; in many cases this is prohibitively expensive, and viewports should not be used to display large contents for scrolling. This function is best used when the contents are not too large OR when the contents are large and render-cacheable.
Also, be aware that there is a rich API for accessing viewport
information from within the EventM
monad; check the docs for
Brick.Main
to learn more about ways to get information about
viewports after they're drawn.
horizontalScrollbarRenderer :: ScrollbarRenderer n #
The default renderer for horizontal viewport scroll bars. Override
with withHScrollBarRenderer
.
withHScrollBarRenderer :: ScrollbarRenderer n -> Widget n -> Widget n #
Render horizontal viewport scroll bars in the specified widget with
the specified renderer. This is only needed if you want to override
the use of the default renderer, horizontalScrollbarRenderer
.
withHScrollBarHandles :: Widget n -> Widget n #
Enable scroll bar handles on all horizontal scroll bars in
the specified widget. Handles appear at the ends of the scroll
bar, representing the "handles" that are typically clickable in
graphical UIs to move the scroll bar incrementally. Horizontal
scroll bars are also clickable if mouse mode is enabled and if
withClickableHScrollBars
is used.
This will only have an effect if withHScrollBars
is also called.
withClickableVScrollBars :: (ClickableScrollbarElement -> n -> n) -> Widget n -> Widget n #
Enable mouse click reporting on vertical scroll bars in the
specified widget. This must be used with withVScrollBars
. The
provided function is used to build a resource name containing the
scroll bar element clicked and the viewport name associated with the
scroll bar. It is usually a data constructor of the n
type.
withClickableHScrollBars :: (ClickableScrollbarElement -> n -> n) -> Widget n -> Widget n #
Enable mouse click reporting on horizontal scroll bars in the
specified widget. This must be used with withHScrollBars
. The
provided function is used to build a resource name containing the
scroll bar element clicked and the viewport name associated with the
scroll bar. It is usually a data constructor of the n
type.
withHScrollBars :: HScrollBarOrientation -> Widget n -> Widget n #
Enable horizontal scroll bars on all viewports in the specified widget and draw them with the specified orientation.
verticalScrollbarRenderer :: ScrollbarRenderer n #
The default renderer for vertical viewport scroll bars. Override
with withVScrollBarRenderer
.
withVScrollBarRenderer :: ScrollbarRenderer n -> Widget n -> Widget n #
Render vertical viewport scroll bars in the specified widget with
the specified renderer. This is only needed if you want to override
the use of the default renderer, verticalScrollbarRenderer
.
withVScrollBarHandles :: Widget n -> Widget n #
Enable scroll bar handles on all vertical scroll bars in the
specified widget. Handles appear at the ends of the scroll bar,
representing the "handles" that are typically clickable in
graphical UIs to move the scroll bar incrementally. Vertical
scroll bars are also clickable if mouse mode is enabled and if
withClickableVScrollBars
is used.
This will only have an effect if withVScrollBars
is also called.
withVScrollBars :: VScrollBarOrientation -> Widget n -> Widget n #
Enable vertical scroll bars on all viewports in the specified widget and draw them with the specified orientation.
cached :: Ord n => n -> Widget n -> Widget n #
If the specified resource name has an entry in the rendering cache, use the rendered version from the cache. If not, render the specified widget and update the cache with the result.
To ensure that mouse events are emitted correctly for cached widgets, in addition to the rendered widget, we also cache (the names of) any clickable extents that were rendered and restore that when utilizing the cache.
See also invalidateCacheEntry
.
putCursor :: n -> Location -> Widget n -> Widget n #
When rendering the specified widget, also register a cursor positioning request using the specified name and location. The cursor will only be positioned but not made visible.
showCursor :: n -> Location -> Widget n -> Widget n #
When rendering the specified widget, also register a cursor positioning request using the specified name and location.
cropBottomTo :: Int -> Widget n -> Widget n #
Crop the specified widget to the specified size from the bottom. Defers to the cropped widget for growth policy.
cropBottomBy :: Int -> Widget n -> Widget n #
Crop the specified widget on the bottom by the specified number of rows. Defers to the cropped widget for growth policy.
cropTopTo :: Int -> Widget n -> Widget n #
Crop the specified widget to the specified size from the top. Defers to the cropped widget for growth policy.
cropTopBy :: Int -> Widget n -> Widget n #
Crop the specified widget on the top by the specified number of rows. Defers to the cropped widget for growth policy.
cropRightTo :: Int -> Widget n -> Widget n #
Crop the specified widget to the specified size from the right. Defers to the cropped widget for growth policy.
cropRightBy :: Int -> Widget n -> Widget n #
Crop the specified widget on the right by the specified number of columns. Defers to the cropped widget for growth policy.
cropLeftTo :: Int -> Widget n -> Widget n #
Crop the specified widget to the specified size from the left. Defers to the cropped widget for growth policy.
cropLeftBy :: Int -> Widget n -> Widget n #
Crop the specified widget on the left by the specified number of columns. Defers to the cropped widget for growth policy.
translateBy :: Location -> Widget n -> Widget n #
Translate the specified widget by the specified offset amount. Defers to the translated widget for growth policy.
overrideAttr :: AttrName -> AttrName -> Widget n -> Widget n #
Override the lookup of the attribute name targetName
to return
the attribute value associated with fromName
when rendering the
specified widget.
For example:
appAttrMap = attrMap (white on
blue) [ ("highlight", fg yellow)
, ("notice", fg red)
]
renderA :: (String, String) -> [Widget n]
renderA (a, b) = str a + str " is " + withAttr "highlight" (str b)
render1 = withAttr "notice" $ renderA (Brick, "fun")
render2 = overrideAttr "highlight" "notice" render1
In the example above, render1
will show Brick is fun
where the
first two words are red on a blue background, but fun
is yellow on
a blue background. However, render2
will show all three words in
red on a blue background.
forceAttr :: AttrName -> Widget n -> Widget n #
When rendering the specified widget, force all attribute lookups
in the attribute map to use the value currently assigned to the
specified attribute name. This means that the attribute lookups will
behave as if they all used the name specified here. That further
means that the resolved attribute will still inherit from its parent
entry in the attribute map as would normally be the case. If you
want to have more control over the resulting attribute, consider
modifyDefAttr
.
For example:
...
appAttrMap = attrMap (white on
blue) [ ("highlight", fg yellow)
, ("notice", fg red) ]
...
renderA :: (String, String) -> [Widget n]
renderA (a,b) = hBox [ withAttr "highlight" (str a)
, str " is "
, withAttr "highlight" (str b)
]
render1 = renderA (Brick, "fun")
render2 = forceAttr "notice" render1
In the above, render1 will show "Brick is fun" where the first and last words are yellow on a blue background and the middle word is white on a blue background. However, render2 will show all words in red on a blue background. In both versions, the middle word will be in white on a blue background.
updateAttrMap :: (AttrMap -> AttrMap) -> Widget n -> Widget n #
While rendering the specified widget, use a transformed version
of the current attribute map. This is a very general function with
broad capabilities: you probably want a more specific function such
as withDefAttr
or withAttr
.
withDefAttr :: AttrName -> Widget n -> Widget n #
Update the attribute map used while rendering the specified widget (and any sub-widgets): set its new *default* attribute (i.e. the attribute components that will be applied if not overridden by any more specific attributes) to the one that we get by looking up the specified attribute name in the map.
For example:
... appAttrMap = attrMap (whiteon
blue) [ ("highlight", fg yellow) , ("warning", bg magenta) , ("good", whiteon
green) ] ... renderA :: (String, String) -> [Widget n] renderA (a,b) = hBox [ withAttr "good" (str a) , str " is " , withAttr "highlight" (str b) ] render1 = renderA (Brick, "fun") render2 = withDefAttr "warning" render1
In the above, render1 will show "Brick is fun" where the first word is white on a green background, the middle word is white on a blue background, and the last word is yellow on a blue background. However, render2 will show the first word in the same colors but the middle word will be shown in whatever the terminal's normal foreground is on a magenta background, and the third word will be yellow on a magenta background.
modifyDefAttr :: (Attr -> Attr) -> Widget n -> Widget n #
Update the attribute map while rendering the specified widget: set
the map's default attribute to the one that we get by applying the
specified function to the current map's default attribute. This is a
variant of withDefAttr
; see the latter for more information.
withAttr :: AttrName -> Widget n -> Widget n #
When drawing the specified widget, set the attribute used for
drawing to the one with the specified name. Note that the widget
may use further calls to withAttr
to change the active drawing
attribute, so this only takes effect if nothing in the specified
widget invokes withAttr
. If you want to prevent that, use
forceAttr
. Attributes used this way still get merged hierarchically
and still fall back to the attribute map's default attribute. If you
want to change the default attribute, use withDefAttr
.
For example:
appAttrMap = attrMap (white on
blue) [ ("highlight", fg yellow)
, ("warning", bg magenta)
]
renderA :: (String, String) -> [Widget n]
renderA (a,b) = hBox [ str a
, str " is "
, withAttr "highlight" (str b)
]
render1 = renderA (Brick, "fun")
render2 = withAttr "warning" render1
In the example above, render1
will show Brick is fun
where the
first two words are white on a blue background and the last word
is yellow on a blue background. However, render2
will show the
first two words in white on magenta although the last word is still
rendered in yellow on blue.
setAvailableSize :: (Int, Int) -> Widget n -> Widget n #
Set the rendering context height and width for this widget. This is useful for relaxing the rendering size constraints on e.g. layer widgets where cropping to the screen size is undesirable.
vLimitPercent :: Int -> Widget n -> Widget n #
Limit the space available to the specified widget to the specified percentage of available height, as a value between 0 and 100 inclusive. Values outside the valid range will be clamped to the range endpoints. This is important for constraining the vertical growth of otherwise-greedy widgets. This is non-greedy vertically and defers to the limited widget horizontally.
vLimit :: Int -> Widget n -> Widget n #
Limit the space available to the specified widget to the specified number of rows. This is important for constraining the vertical growth of otherwise-greedy widgets. This is non-greedy vertically and defers to the limited widget horizontally.
hLimitPercent :: Int -> Widget n -> Widget n #
Limit the space available to the specified widget to the specified percentage of available width, as a value between 0 and 100 inclusive. Values outside the valid range will be clamped to the range endpoints. This is important for constraining the horizontal growth of otherwise-greedy widgets. This is non-greedy horizontally and defers to the limited widget vertically.
hLimit :: Int -> Widget n -> Widget n #
Limit the space available to the specified widget to the specified number of columns. This is important for constraining the horizontal growth of otherwise-greedy widgets. This is non-greedy horizontally and defers to the limited widget vertically.
hBox :: [Widget n] -> Widget n #
Horizontal box layout: put the specified widgets next to each other in the specified order (leftmost first). Defers growth policies to the growth policies of the contained widgets (if any are greedy, so is the box).
vBox :: [Widget n] -> Widget n #
Vertical box layout: put the specified widgets one above the other in the specified order (uppermost first). Defers growth policies to the growth policies of the contained widgets (if any are greedy, so is the box).
Fill all available space with the specified character. Grows both horizontally and vertically.
padAll :: Int -> Widget n -> Widget n #
Pad a widget on all sides. Defers to the padded widget for growth policy.
padTopBottom :: Int -> Widget n -> Widget n #
Pad a widget on the top and bottom. Defers to the padded widget for growth policy.
padLeftRight :: Int -> Widget n -> Widget n #
Pad a widget on the left and right. Defers to the padded widget for growth policy.
padBottom :: Padding -> Widget n -> Widget n #
Pad the specified widget on the bottom. If max padding is used, this grows greedily vertically; otherwise it defers to the padded widget.
padTop :: Padding -> Widget n -> Widget n #
Pad the specified widget on the top. If max padding is used, this grows greedily vertically; otherwise it defers to the padded widget.
padRight :: Padding -> Widget n -> Widget n #
Pad the specified widget on the right. If max padding is used, this grows greedily horizontally; otherwise it defers to the padded widget.
padLeft :: Padding -> Widget n -> Widget n #
Pad the specified widget on the left. If max padding is used, this grows greedily horizontally; otherwise it defers to the padded widget.
hyperlink :: Text -> Widget n -> Widget n #
Hyperlink the given widget to the specified URL. Not all terminal emulators support this. In those that don't, this should have no discernible effect.
Build a widget from a 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. The input text should not contain escape sequences or carriage returns.
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. The input string should not contain escape sequences or carriage returns.
txtWrapWith :: WrapSettings -> Text -> Widget n #
Make a widget from text, but wrap the words in the input's lines at the available width using the specified wrapping settings. The input text should not contain escape sequences or carriage returns.
Unlike txt
, this is greedy horizontally.
Make a widget from text, but wrap the words in the input's lines at the available width using the default wrapping settings. The input text should not contain escape sequences or carriage returns.
Unlike txt
, this is greedy horizontally.
strWrapWith :: WrapSettings -> String -> Widget n #
Make a widget from a string, but wrap the words in the input's lines at the available width using the specified wrapping settings. The input string should not contain escape sequences or carriage returns.
Unlike str
, this is greedy horizontally.
strWrap :: String -> Widget n #
Make a widget from a string, but wrap the words in the input's lines at the available width using the default wrapping settings. The input string should not contain escape sequences or carriage returns.
Unlike str
, this is greedy horizontally.
clickable :: Ord n => n -> Widget n -> Widget n #
Request mouse click events on the specified widget.
Regions used with clickable
can be scrolled into view with
makeVisible
.
reportExtent :: Ord n => n -> Widget n -> Widget n #
Render the specified widget and record its rendering extent using
the specified name (see also lookupExtent
).
This function is the counterpart to makeVisible
; any visibility
requests made with makeVisible
must have a corresponding
reportExtent
in order to work. The clickable
function will also
work for this purpose to tell the renderer about the clickable
region.
addResultOffset :: Location -> Result n -> Result n #
Add an offset to all cursor locations, visbility requests, and extents in the specified rendering result. This function is critical for maintaining correctness in the rendering results as they are processed successively by box layouts and other wrapping combinators, since calls to this function result in converting from widget-local coordinates to (ultimately) terminal-global ones so they can be used by other combinators. You should call this any time you render something and then translate it or otherwise offset it from its original origin.
emptyWidget :: Widget n #
The empty widget.
freezeBorders :: Widget n -> Widget n #
After the specified widget has been rendered, freeze its borders. A
frozen border will not be affected by neighbors, nor will it affect
neighbors. Compared to separateBorders
, freezeBorders
will not
affect whether borders connect internally to a widget (whereas
separateBorders
prevents them from connecting).
Frozen borders cannot be thawed.
separateBorders :: Widget n -> Widget n #
When rendering the specified widget, use static borders. This may be marginally faster, but will introduce a small gap between neighboring orthogonal borders.
This is the default for backwards compatibility.
joinBorders :: Widget n -> Widget n #
When rendering the specified widget, create borders that respond dynamically to their neighbors to form seamless connections.
withBorderStyle :: BorderStyle -> Widget n -> Widget n #
When rendering the specified widget, use the specified border style for any border rendering.
The class of types that store interface element names.
cropToContext :: Widget n -> Widget n #
After rendering the specified widget, crop its result image to the dimensions in the rendering context.
renderFinal :: AttrMap -> [Widget n] -> DisplayRegion -> ([CursorLocation n] -> Maybe (CursorLocation n)) -> RenderState n -> (RenderState n, Picture, Maybe (CursorLocation n), [Extent n]) #
lookupAttrName :: AttrName -> RenderM n Attr #
Given an attribute name, obtain the attribute for the attribute name by consulting the context's attribute map.
:: a | The state value. |
-> Lens' a b | The lens to use to extract and store the target of the event. |
-> (e -> b -> EventM n b) | The event handler. |
-> e | The event to handle. |
-> EventM n a |
A convenience function for handling events intended for values
that are targets of lenses in your application state. This function
obtains the target value of the specified lens, invokes handleEvent
on it, and stores the resulting transformed value back in the state
using the lens.
The type of padding.
The monad in which event handlers run. Although it may be tempting
to dig into the reader value yourself, just use
lookupViewport
.
Instances
Monad (EventM n) | |
Functor (EventM n) | |
MonadFail (EventM n) | |
Defined in Brick.Types | |
Applicative (EventM n) | |
MonadIO (EventM n) | |
Defined in Brick.Types | |
MonadThrow (EventM n) | |
Defined in Brick.Types | |
MonadCatch (EventM n) | |
MonadMask (EventM n) | |
clOffset :: CursorLocation n -> Location -> CursorLocation n #
Add a Location
offset to the specified CursorLocation
.
Create an attribute from the specified background color (the background color is the "default").
Create an attribute from the specified foreground color (the background color is the "default").
Build an attribute from a foreground color and a background color. Intended to be used infix.
:: Ord a | |
=> a | The minimum value |
-> a | The maximum value |
-> a | The value to clamp |
-> a |
Given a minimum value and a maximum value, clamp a value to that range (values less than the minimum map to the minimum and values greater than the maximum map to the maximum).
>>>
clamp 1 10 11
10>>>
clamp 1 10 2
2>>>
clamp 5 10 1
5
visibilityRequestsL :: Lens' (Result n) [VisibilityRequest] #
cursorsL :: Lens' (Result n) [CursorLocation n] #
windowWidthL :: Lens' (Context n) Int #
windowHeightL :: Lens' (Context n) Int #
ctxVScrollBarRendererL :: Lens' (Context n) (Maybe (ScrollbarRenderer n)) #
ctxHScrollBarRendererL :: Lens' (Context n) (Maybe (ScrollbarRenderer n)) #
ctxDynBordersL :: Lens' (Context n) Bool #
ctxBorderStyleL :: Lens' (Context n) BorderStyle #
ctxAttrNameL :: Lens' (Context n) AttrName #
ctxAttrMapL :: Lens' (Context n) AttrMap #
availWidthL :: Lens' (Context n) Int #
availHeightL :: Lens' (Context n) Int #
cursorLocationNameL :: Lens (CursorLocation n1) (CursorLocation n2) (Maybe n1) (Maybe n2) #
cursorLocationL :: Lens' (CursorLocation n) Location #
emptyResult :: Result n #
getContext :: RenderM n (Context n) #
Get the current rendering context.
Widget size policies. These policies communicate how a widget uses
space when being rendered. These policies influence rendering order
and space allocation in the box layout algorithm for hBox
and
vBox
.
Fixed | Widgets advertising this size policy should take up the same amount of space no matter how much they are given, i.e. their size depends on their contents alone rather than on the size of the rendering area. |
Greedy | Widgets advertising this size policy must take up all the space they are given. |
The type of widgets.
data RenderState n #
Instances
type RenderM n a = ReaderT (Context n) (State (RenderState n)) a #
The type of the rendering monad. This monad is used by the library's rendering routines to manage rendering state and communicate rendering parameters to widgets' rendering functions.
data VScrollBarOrientation #
Orientations for vertical scroll bars.
Instances
Eq VScrollBarOrientation | |
Defined in Brick.Types.Internal (==) :: VScrollBarOrientation -> VScrollBarOrientation -> Bool # (/=) :: VScrollBarOrientation -> VScrollBarOrientation -> Bool # | |
Show VScrollBarOrientation | |
Defined in Brick.Types.Internal showsPrec :: Int -> VScrollBarOrientation -> ShowS # show :: VScrollBarOrientation -> String # showList :: [VScrollBarOrientation] -> ShowS # |
data HScrollBarOrientation #
Orientations for horizontal scroll bars.
Instances
Eq HScrollBarOrientation | |
Defined in Brick.Types.Internal (==) :: HScrollBarOrientation -> HScrollBarOrientation -> Bool # (/=) :: HScrollBarOrientation -> HScrollBarOrientation -> Bool # | |
Show HScrollBarOrientation | |
Defined in Brick.Types.Internal showsPrec :: Int -> HScrollBarOrientation -> ShowS # show :: HScrollBarOrientation -> String # showList :: [HScrollBarOrientation] -> ShowS # |
data ScrollbarRenderer n #
A scroll bar renderer.
ScrollbarRenderer | |
|
data VisibilityRequest #
Instances
Describes the state of a viewport as it appears as its most recent rendering.
VP | |
|
Instances
Read Viewport | |
Show Viewport | |
Generic Viewport | |
NFData Viewport | |
Defined in Brick.Types.Internal | |
type Rep Viewport | |
Defined in Brick.Types.Internal type Rep Viewport = D1 ('MetaData "Viewport" "Brick.Types.Internal" "brick-0.68.1-CVaBpv5Fx673dDbo389k7Y" 'False) (C1 ('MetaCons "VP" 'PrefixI 'True) ((S1 ('MetaSel ('Just "_vpLeft") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "_vpTop") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :*: (S1 ('MetaSel ('Just "_vpSize") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DisplayRegion) :*: S1 ('MetaSel ('Just "_vpContentSize") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DisplayRegion)))) |
data ViewportType #
The type of viewports that indicates the direction(s) in which a viewport is scrollable.
Vertical | Viewports of this type are scrollable only vertically. |
Horizontal | Viewports of this type are scrollable only horizontally. |
Both | Viewports of this type are scrollable vertically and horizontally. |
Instances
Eq ViewportType | |
Defined in Brick.Types.Internal (==) :: ViewportType -> ViewportType -> Bool # (/=) :: ViewportType -> ViewportType -> Bool # | |
Show ViewportType | |
Defined in Brick.Types.Internal showsPrec :: Int -> ViewportType -> ShowS # show :: ViewportType -> String # showList :: [ViewportType] -> ShowS # |
An extent of a named area: its size, location, and origin.
Extent | |
|
Instances
Read n => Read (Extent n) | |
Show n => Show (Extent n) | |
Generic (Extent n) | |
NFData n => NFData (Extent n) | |
Defined in Brick.Types.Internal | |
type Rep (Extent n) | |
Defined in Brick.Types.Internal type Rep (Extent n) = D1 ('MetaData "Extent" "Brick.Types.Internal" "brick-0.68.1-CVaBpv5Fx673dDbo389k7Y" 'False) (C1 ('MetaCons "Extent" 'PrefixI 'True) (S1 ('MetaSel ('Just "extentName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 n) :*: (S1 ('MetaSel ('Just "extentUpperLeft") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Location) :*: S1 ('MetaSel ('Just "extentSize") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Int, Int))))) |
The type of actions to take upon completion of an event handler.
Scrolling direction.
class TerminalLocation a where #
The class of types that behave like terminal locations.
locationColumnL :: Lens' a Int #
Get the column out of the value
locationColumn :: a -> Int #
locationRowL :: Lens' a Int #
Get the row out of the value
locationRow :: a -> Int #
Instances
TerminalLocation Location | |
Defined in Brick.Types.Internal locationColumnL :: Lens' Location Int # locationColumn :: Location -> Int # locationRowL :: Lens' Location Int # locationRow :: Location -> Int # |
data CursorLocation n #
A cursor location. These are returned by the rendering process.
CursorLocation | |
|
Instances
data BorderSegment #
A border character has four segments, one extending in each direction (horizontally and vertically) from the center of the character.
Instances
Information about how to redraw a dynamic border character when it abuts another dynamic border character.
DynBorder | |
|
Instances
Eq DynBorder | |
Read DynBorder | |
Show DynBorder | |
Generic DynBorder | |
NFData DynBorder | |
Defined in Brick.Types.Internal | |
type Rep DynBorder | |
Defined in Brick.Types.Internal type Rep DynBorder = D1 ('MetaData "DynBorder" "Brick.Types.Internal" "brick-0.68.1-CVaBpv5Fx673dDbo389k7Y" 'False) (C1 ('MetaCons "DynBorder" 'PrefixI 'True) (S1 ('MetaSel ('Just "dbStyle") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BorderStyle) :*: (S1 ('MetaSel ('Just "dbAttr") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Attr) :*: S1 ('MetaSel ('Just "dbSegments") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Edges BorderSegment))))) |
The type of result returned by a widget's rendering function. The result provides the image, cursor positions, and visibility requests that resulted from the rendering process.
Result | |
|
Instances
Read n => Read (Result n) | |
Show n => Show (Result n) | |
Generic (Result n) | |
NFData n => NFData (Result n) | |
Defined in Brick.Types.Internal | |
type Rep (Result n) | |
Defined in Brick.Types.Internal type Rep (Result n) = D1 ('MetaData "Result" "Brick.Types.Internal" "brick-0.68.1-CVaBpv5Fx673dDbo389k7Y" 'False) (C1 ('MetaCons "Result" 'PrefixI 'True) ((S1 ('MetaSel ('Just "image") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Image) :*: S1 ('MetaSel ('Just "cursors") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [CursorLocation n])) :*: (S1 ('MetaSel ('Just "visibilityRequests") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [VisibilityRequest]) :*: (S1 ('MetaSel ('Just "extents") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Extent n]) :*: S1 ('MetaSel ('Just "borders") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (BorderMap DynBorder)))))) |
data BrickEvent n e #
The type of events.
VtyEvent Event | The event was a Vty event. |
AppEvent e | The event was an application event. |
MouseDown n Button [Modifier] Location | A mouse-down event on the specified region was
received. The |
MouseUp n (Maybe Button) Location | A mouse-up event on the specified region was
received. The |
Instances
(Eq e, Eq n) => Eq (BrickEvent n e) | |
Defined in Brick.Types.Internal (==) :: BrickEvent n e -> BrickEvent n e -> Bool # (/=) :: BrickEvent n e -> BrickEvent n e -> Bool # | |
(Ord e, Ord n) => Ord (BrickEvent n e) | |
Defined in Brick.Types.Internal compare :: BrickEvent n e -> BrickEvent n e -> Ordering # (<) :: BrickEvent n e -> BrickEvent n e -> Bool # (<=) :: BrickEvent n e -> BrickEvent n e -> Bool # (>) :: BrickEvent n e -> BrickEvent n e -> Bool # (>=) :: BrickEvent n e -> BrickEvent n e -> Bool # max :: BrickEvent n e -> BrickEvent n e -> BrickEvent n e # min :: BrickEvent n e -> BrickEvent n e -> BrickEvent n e # | |
(Show e, Show n) => Show (BrickEvent n e) | |
Defined in Brick.Types.Internal showsPrec :: Int -> BrickEvent n e -> ShowS # show :: BrickEvent n e -> String # showList :: [BrickEvent n e] -> ShowS # |
data ClickableScrollbarElement #
Clickable elements of a scroll bar.
SBHandleBefore | The handle at the beginning (left/top) of the scroll bar. |
SBHandleAfter | The handle at the end (right/bottom) of the scroll bar. |
SBBar | The scroll bar itself. |
SBTroughBefore | The trough before the scroll bar. |
SBTroughAfter | The trough after the scroll bar. |
Instances
The rendering context. This tells widgets how to render: how much space they have in which to render, which attribute they should use to render, which bordering style should be used, and the attribute map available for rendering.
Instances
Monad Edges | |
Functor Edges | |
Applicative Edges | |
Eq a => Eq (Edges a) | |
Ord a => Ord (Edges a) | |
Read a => Read (Edges a) | |
Show a => Show (Edges a) | |
Generic (Edges a) | |
NFData a => NFData (Edges a) | |
Defined in Brick.Types.Common | |
type Rep (Edges a) | |
Defined in Brick.Types.Common type Rep (Edges a) = D1 ('MetaData "Edges" "Brick.Types.Common" "brick-0.68.1-CVaBpv5Fx673dDbo389k7Y" 'False) (C1 ('MetaCons "Edges" 'PrefixI 'True) ((S1 ('MetaSel ('Just "eTop") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Just "eBottom") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :*: (S1 ('MetaSel ('Just "eLeft") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Just "eRight") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))) |
A terminal screen location.
Instances
Eq Location | |
Ord Location | |
Defined in Brick.Types.Common | |
Read Location | |
Show Location | |
Generic Location | |
Semigroup Location | |
Monoid Location | |
TerminalLocation Location | |
Defined in Brick.Types.Internal locationColumnL :: Lens' Location Int # locationColumn :: Location -> Int # locationRowL :: Lens' Location Int # locationRow :: Location -> Int # | |
NFData Location | |
Defined in Brick.Types.Common | |
Field1 Location Location Int Int | |
Field2 Location Location Int Int | |
type Rep Location | |
Defined in Brick.Types.Common |
suffixLensesWith :: String -> LensRules -> Name -> DecsQ #
A more general version of suffixLenses
that allows customization
of the lens-building rules and allows customization of the suffix.
suffixLenses :: Name -> DecsQ #
A template haskell function to build lenses for a record type. This
function differs from the makeLenses
function in that
it does not require the record fields to be prefixed with underscores
and it adds an L suffix to lens names to make it clear that they
are lenses.
mapAttrNames :: [(AttrName, AttrName)] -> AttrMap -> AttrMap #
Map several attributes to return the value associated with an
alternate name. Applies mapAttrName
across a list of mappings.
mapAttrName :: AttrName -> AttrName -> AttrMap -> AttrMap #
Update an attribute map such that a lookup of ontoName
returns
the attribute value specified by fromName
. This is useful for
composite widgets with specific attribute names mapping those names
to the sub-widget's expected name when calling that sub-widget's
rendering function. See the ProgressBarDemo for an example usage,
and overrideAttr
for an alternate syntax.
applyAttrMappings :: [(AttrName, Attr)] -> AttrMap -> AttrMap #
Insert a set of attribute mappings to an attribute map.
getDefaultAttr :: AttrMap -> Attr #
Get the default attribute value in an attribute map.
setDefaultAttr :: Attr -> AttrMap -> AttrMap #
Set the default attribute value in an attribute map.
attrMapLookup :: AttrName -> AttrMap -> Attr #
Look up the specified attribute name in the map. Map lookups
proceed as follows. If the attribute map is forcing all lookups to a
specific attribute, that attribute is returned along with its style
settings. If the attribute name is empty, the map's default attribute
is returned. If the attribute name is non-empty, every subsequence of
names from the specified name are used to perform a lookup and the
results are combined as in mergeWithDefault
, with more specific
results taking precedence over less specific ones. As attributes are
merged, styles are also merged. If a more specific attribute name
introduces a style (underline, say) and a less specific attribute
name introduces an additional style (bold, say) then the final result
will include both styles.
For example:
attrMapLookup ("foo" <> "bar") (attrMap a []) == a
attrMapLookup ("foo" <> "bar") (attrMap (bg blue) [("foo" <> "bar", fg red)]) == red `on` blue
attrMapLookup ("foo" <> "bar") (attrMap (bg blue) [("foo" <> "bar", red on
cyan)]) == red `on` cyan
attrMapLookup ("foo" <> "bar") (attrMap (bg blue) [("foo" <> "bar", fg red), ("foo", bg cyan)]) == red `on` cyan
attrMapLookup ("foo" <> "bar") (attrMap (bg blue) [("foo", fg red)]) == red `on` blue
mergeWithDefault :: Attr -> AttrMap -> Attr #
Given an attribute and a map, merge the attribute with the map's default attribute. If the map is forcing all lookups to a specific attribute, the forced attribute is returned without merging it with the one specified here. Otherwise the attribute given here is merged with the attribute map's default attribute in that any aspect of the specified attribute that is not provided falls back to the map default. For example,
mergeWithDefault (fg blue) $ attrMap (bg red) []
returns
blue `on` red
forceAttrMap :: Attr -> AttrMap #
Create an attribute map in which all lookups map to the same
attribute. This is functionally equivalent to AttrMap attr []
.
:: Attr | The map's default attribute to be returned when a name lookup fails, and the attribute that will be merged with successful lookups. |
-> [(AttrName, Attr)] | The map's initial contents. |
-> AttrMap |
Create an attribute map.
attrNameComponents :: AttrName -> [String] #
Get the components of an attribute name.
An attribute name. Attribute names are hierarchical; use mappend
(<>
) 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
example:
"window" <> "border" "window" <> "title" "header" <> "clock" <> "seconds"
Instances
Instances
Show AttrMap | |
Generic AttrMap | |
NFData AttrMap | |
Defined in Brick.AttrMap | |
type Rep AttrMap | |
Defined in Brick.AttrMap type Rep AttrMap = D1 ('MetaData "AttrMap" "Brick.AttrMap" "brick-0.68.1-CVaBpv5Fx673dDbo389k7Y" 'False) (C1 ('MetaCons "AttrMap" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Attr) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map AttrName Attr))) :+: C1 ('MetaCons "ForceAttr" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Attr))) |
A class for types with a default value.
Nothing
Instances
Monoid under group addition. Alternative to the Sum
in
Data.Monoid, which uses Num
instead of AdditiveGroup
.
class AdditiveGroup v where #
Additive group v
.
Nothing
The zero element: identity for (^+^)
(^+^) :: v -> v -> v infixl 6 #
Add vectors
Additive inverse
(^-^) :: v -> v -> v infixl 6 #
Group subtraction
Instances
sumV :: (Foldable f, AdditiveGroup v) => f v -> v #
Sum over several vectors
class (VectorSpace v, AdditiveGroup (Scalar v)) => InnerSpace v where #
Adds inner (dot) products.
Nothing
Instances
class AdditiveGroup v => VectorSpace v where #
Vector space v
.
Nothing
Instances
Instances
(^/) :: (VectorSpace v, s ~ Scalar v, Fractional s) => v -> s -> v infixr 7 #
Vector divided by scalar
(^*) :: (VectorSpace v, s ~ Scalar v) => v -> s -> v infixl 7 #
Vector multiplied by scalar
lerp :: VectorSpace v => v -> v -> Scalar v -> v #
Linear interpolation between a
(when t==0
) and b
(when t==1
).
linearCombo :: VectorSpace v => [(v, Scalar v)] -> v #
Linear combination of vectors
magnitudeSq :: (InnerSpace v, s ~ Scalar v) => v -> s #
Square of the length of a vector. Sometimes useful for efficiency.
See also magnitude
.
magnitude :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> s #
Length of a vector. See also magnitudeSq
.
normalized :: (InnerSpace v, s ~ Scalar v, Floating s) => v -> v #
Vector in same direction as given one but with length of one. If given the zero vector, then return it.
project :: (InnerSpace v, s ~ Scalar v, Fractional s) => v -> v -> v #
project u v
computes the projection of v
onto u
.
class AdditiveGroup (Diff p) => AffineSpace p where #
Nothing
(.-.) :: p -> p -> Diff p infix 6 #
Subtract points
(.+^) :: p -> Diff p -> p infixl 6 #
Point plus vector
Instances
AffineSpace Double | |
AffineSpace Float | |
AffineSpace Int | |
AffineSpace Integer | |
AffineSpace CSChar | |
AffineSpace CShort | |
AffineSpace CInt | |
AffineSpace CLong | |
AffineSpace CLLong | |
AffineSpace CFloat | |
AffineSpace CDouble | |
AffineSpace CIntMax | |
Integral a => AffineSpace (Ratio a) | |
AffineSpace a => AffineSpace (Dyn a) Source # | |
AffineSpace p => AffineSpace (a -> p) | |
(AffineSpace p, AffineSpace q) => AffineSpace (p, q) | |
(AffineSpace p, Frp m) => AffineSpace (Dyn m p) | |
AffineSpace a => AffineSpace (Rec0 a s) | |
(AffineSpace p, AffineSpace q, AffineSpace r) => AffineSpace (p, q, r) | |
(AffineSpace (f p), AffineSpace (g p)) => AffineSpace (AffineDiffProductSpace f g p) | |
(AffineSpace (f p), AffineSpace (g p)) => AffineSpace ((f :*: g) p) | |
AffineSpace (f p) => AffineSpace (M1 i c f p) | |
Associated vector space
Instances
type Diff Double | |
Defined in Data.AffineSpace | |
type Diff Float | |
Defined in Data.AffineSpace | |
type Diff Int | |
Defined in Data.AffineSpace | |
type Diff Integer | |
Defined in Data.AffineSpace | |
type Diff CSChar | |
Defined in Data.AffineSpace | |
type Diff CShort | |
Defined in Data.AffineSpace | |
type Diff CInt | |
Defined in Data.AffineSpace | |
type Diff CLong | |
Defined in Data.AffineSpace | |
type Diff CLLong | |
Defined in Data.AffineSpace | |
type Diff CFloat | |
Defined in Data.AffineSpace | |
type Diff CDouble | |
Defined in Data.AffineSpace | |
type Diff CIntMax | |
Defined in Data.AffineSpace | |
type Diff (Ratio a) | |
Defined in Data.AffineSpace | |
type Diff (Dyn a) Source # | |
type Diff (a -> p) | |
Defined in Data.AffineSpace | |
type Diff (p, q) | |
Defined in Data.AffineSpace | |
type Diff (Dyn m p) | |
type Diff (Rec0 a s) | |
Defined in Data.AffineSpace | |
type Diff (p, q, r) | |
Defined in Data.AffineSpace | |
type Diff (AffineDiffProductSpace f g p) | |
Defined in Data.AffineSpace type Diff (AffineDiffProductSpace f g p) = AffineDiffProductSpace f g p | |
type Diff ((f :*: g) p) | |
Defined in Data.AffineSpace | |
type Diff (M1 i c f p) | |
Defined in Data.AffineSpace |
(.-^) :: AffineSpace p => p -> Diff p -> p infixl 6 #
Point minus vector
distanceSq :: (AffineSpace p, v ~ Diff p, InnerSpace v) => p -> p -> Scalar v #
Square of the distance between two points. Sometimes useful for
efficiency. See also distance
.
distance :: (AffineSpace p, v ~ Diff p, InnerSpace v, s ~ Scalar v, Floating (Scalar v)) => p -> p -> s #
Distance between two points. See also distanceSq
.
alerp :: (AffineSpace p, VectorSpace (Diff p)) => p -> p -> Scalar (Diff p) -> p #
Affine linear interpolation. Varies from p
to p'
as s
varies
from 0 to 1. See also lerp
(on vector spaces).
affineCombo :: (AffineSpace p, v ~ Diff p, VectorSpace v) => p -> [(p, Scalar v)] -> p #
Compute an affine combination (weighted average) of points. The first element is used as origin and is weighted such that all coefficients sum to 1. For example,
affineCombo a [(0.3,b), (0.2,c)]
is equal to
a .+^ (0.3 *^ (b .-. a) ^+^ 0.2 *^ (c .-. a))
and if a
, b
, and c
were in a vector space would also be equal to
0.5 *^ a ^+^ 0.3 *^ b ^+^ 0.2 *^ c
See also linearCombo
(on vector spaces).
Cross product of various forms of 3D vectors
Cross product of various forms of 2D vectors
Instances
HasCross2 a => HasCross2 (Dyn a) Source # | |
Defined in Dyna.Brick.Types | |
AdditiveGroup u => HasCross2 (u, u) | |
Defined in Data.Cross | |
(HasCross2 v, Frp m) => HasCross2 (Dyn m v) | |
(HasTrie (Basis a), HasCross2 v) => HasCross2 (a :> v) | |
Defined in Data.Cross |
Thing with a normal vector (not necessarily normalized).
Instances
(VectorSpace s, HasBasis s, HasTrie (Basis s), HasNormal (Two s :> Three s)) => HasNormal (Three (Two s :> s)) | |
(VectorSpace s, HasBasis s, HasTrie (Basis s), Basis s ~ ()) => HasNormal (Two (One s :> s)) | |
HasNormal a => HasNormal (Dyn a) Source # | |
Defined in Dyna.Brick.Types | |
(HasNormal v, Frp m) => HasNormal (Dyn m v) | |
(Num s, HasTrie (Basis (s, s)), HasBasis s, Basis s ~ ()) => HasNormal (Two s :> Three s) | |
(HasBasis s, HasTrie (Basis s), Basis s ~ ()) => HasNormal (One s :> Two s) | |
normal :: (HasNormal v, InnerSpace v, Floating (Scalar v)) => v -> v #
Normalized normal vector. See also cross
.
Parallel composition for a list of values (harmony).
Parallel composition. Play two tracks simultaneously.
Sequent composition for a list of values (melody).
Sequent composition. Play first track then second.
Representation of the canonical basis for v
Instances
type Basis Double | |
Defined in Data.Basis | |
type Basis Float | |
Defined in Data.Basis | |
type Basis CFloat | |
Defined in Data.Basis | |
type Basis CDouble | |
Defined in Data.Basis | |
type Basis (Ratio a) | |
Defined in Data.Basis | |
type Basis (GenericDiff p) | |
Defined in Data.AffineSpace | |
type Basis (Dyn a) Source # | |
type Basis (u, v) | |
Defined in Data.Basis | |
type Basis (Dyn m v) | |
type Basis (Rec0 a s) | |
Defined in Data.Basis | |
type Basis (u, v, w) | |
Defined in Data.Basis | |
type Basis (AffineDiffProductSpace f g p) | |
type Basis ((f :*: g) p) | |
type Basis (M1 i c f p) | |
Defined in Data.Basis |
class VectorSpace v => HasBasis v where #
Nothing
basisValue :: Basis v -> v #
Interpret basis rep as a vector
decompose :: v -> [(Basis v, Scalar v)] #
Extract coordinates
decompose' :: v -> Basis v -> Scalar v #
Experimental version. More elegant definitions, and friendly to infinite-dimensional vector spaces.
Instances
HasBasis Double | |
HasBasis Float | |
HasBasis CFloat | |
HasBasis CDouble | |
Integral a => HasBasis (Ratio a) | |
HasBasis (Diff (VRep p)) => HasBasis (GenericDiff p) | |
Defined in Data.AffineSpace | |
(BasisArity a, HasBasis a) => HasBasis (Dyn a) Source # | |
(HasBasis u, s ~ Scalar u, HasBasis v, s ~ Scalar v) => HasBasis (u, v) | |
Defined in Data.Basis | |
(BasisArity v, HasBasis v, Frp m) => HasBasis (Dyn m v) | |
HasBasis a => HasBasis (Rec0 a s) | |
(HasBasis u, s ~ Scalar u, HasBasis v, s ~ Scalar v, HasBasis w, s ~ Scalar w) => HasBasis (u, v, w) | |
Defined in Data.Basis | |
(AffineSpace (f p), AffineSpace (g p), HasBasis (Diff (f p)), HasBasis (Diff (g p)), Scalar (Diff (f p)) ~ Scalar (Diff (g p))) => HasBasis (AffineDiffProductSpace f g p) | |
Defined in Data.AffineSpace basisValue :: Basis (AffineDiffProductSpace f g p) -> AffineDiffProductSpace f g p # decompose :: AffineDiffProductSpace f g p -> [(Basis (AffineDiffProductSpace f g p), Scalar (AffineDiffProductSpace f g p))] # decompose' :: AffineDiffProductSpace f g p -> Basis (AffineDiffProductSpace f g p) -> Scalar (AffineDiffProductSpace f g p) # | |
(HasBasis (f p), HasBasis (g p), Scalar (f p) ~ Scalar (g p)) => HasBasis ((f :*: g) p) | |
HasBasis (f p) => HasBasis (M1 i c f p) | |
Representations of non-modifier keys.
- KFun is indexed from 0 to 63. Range of supported FKeys varies by terminal and keyboard.
- KUpLeft, KUpRight, KDownLeft, KDownRight, KCenter support varies by terminal and keyboard.
- Actually, support for most of these but KEsc, KChar, KBS, and KEnter vary by terminal and keyboard.
KEsc | |
KChar Char | |
KBS | |
KEnter | |
KLeft | |
KRight | |
KUp | |
KDown | |
KUpLeft | |
KUpRight | |
KDownLeft | |
KDownRight | |
KCenter | |
KFun Int | |
KBackTab | |
KPrtScr | |
KPause | |
KIns | |
KHome | |
KPageUp | |
KDel | |
KEnd | |
KPageDown | |
KBegin | |
KMenu |
Instances
Modifier keys. Key codes are interpreted such that users are more
likely to have Meta than Alt; for instance on the PC Linux console,
MMeta
will generally correspond to the physical Alt key.
Instances
Eq Modifier | |
Ord Modifier | |
Defined in Graphics.Vty.Input.Events | |
Read Modifier | |
Show Modifier | |
Generic Modifier | |
NFData Modifier | |
Defined in Graphics.Vty.Input.Events | |
Parse Modifier | |
Defined in Graphics.Vty.Config parseValue :: Parser Modifier | |
type Rep Modifier | |
Defined in Graphics.Vty.Input.Events type Rep Modifier = D1 ('MetaData "Modifier" "Graphics.Vty.Input.Events" "vty-5.35.1-KZM7sNe0OABAUeGlQIWLj" 'False) ((C1 ('MetaCons "MShift" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MCtrl" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "MMeta" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MAlt" 'PrefixI 'False) (U1 :: Type -> Type))) |
Dynamic value that continuously changes over time
Instances
Functor Dyn Source # | |
Applicative Dyn Source # | |
RunFunctor Dyn Source # | |
Fractional a => Fractional (Dyn a) Source # | |
Num a => Num (Dyn a) Source # | |
IsString a => IsString (Dyn a) Source # | |
Defined in Dyna.Brick.Types fromString :: String -> Dyn a # | |
Semigroup a => Semigroup (Dyn a) Source # | |
Monoid a => Monoid (Dyn a) Source # | |
Boolean a => Boolean (Dyn a) Source # | |
IfB a => IfB (Dyn a) Source # | |
EqB a => EqB (Dyn a) Source # | |
OrdB a => OrdB (Dyn a) Source # | |
AdditiveGroup a => AdditiveGroup (Dyn a) Source # | |
VectorSpace a => VectorSpace (Dyn a) Source # | |
AffineSpace a => AffineSpace (Dyn a) Source # | |
HasCross3 a => HasCross3 (Dyn a) Source # | |
HasCross2 a => HasCross2 (Dyn a) Source # | |
Defined in Dyna.Brick.Types | |
HasNormal a => HasNormal (Dyn a) Source # | |
Defined in Dyna.Brick.Types | |
(BasisArity a, HasBasis a) => HasBasis (Dyn a) Source # | |
type BooleanOf (Dyn a) Source # | |
Defined in Dyna.Brick.Types | |
type Scalar (Dyn a) Source # | |
type Diff (Dyn a) Source # | |
type Basis (Dyn a) Source # | |
Event stream
Instances
Monad Evt Source # | |
Functor Evt Source # | |
Applicative Evt Source # | |
RunFunctor Evt Source # | |
Semigroup (Evt a) Source # | |
Monoid (Evt a) Source # | |
Loop (Evt a) Source # | |
Defined in Dyna.Brick.Types | |
Limit (Evt a) Source # | |
Compose (Evt a) Source # | |
Defined in Dyna.Brick.Types | |
Harmony (Evt a) Source # | |
Melody (Evt a) Source # | |
type DurOf (Evt a) Source # | |
Defined in Dyna.Brick.Types |
Instances
Monad Run Source # | |
Functor Run Source # | |
Applicative Run Source # | |
MonadIO Run Source # | |
Defined in Dyna.Brick.Types | |
MonadRandom Run Source # | |
Defined in Dyna.Brick.Types | |
Frp Run Source # | |
MonadReader Env Run Source # | |
MonadBase IO Run Source # | |
Defined in Dyna.Brick.Types | |
MonadBaseControl IO Run Source # | |
type Ref Run Source # | |
Defined in Dyna.Brick.Types | |
type StM Run a Source # | |
Defined in Dyna.Brick.Types |
Spec | |
|
class RunFunctor f where Source #
Reference to running dynamic process by which we can query values (readDyn
).
Also note that we no longer need the reference we should release the resources
by calling cancelDyn
.
runDyn :: Dyn a -> Run (DynRef a) Source #
Executes dynamic for observation. The dynamic is step-wise constant function that is driven by some event stream. The function runs the event stream process in background and samples the updated state.
We can observe the value with readDyn
. We need to shut down the stream when
we no longer need it with cancelDyn
function.
newEvt :: Evt a -> Run (Evt a) Source #
Runs the argument event stream as background process and produces event stream that is fed with events over channel (unagi-channel package). When result event stream shuts down the background process also shuts down.
newDyn :: Dyn a -> Run (Dyn a) Source #
Runs the dynamic process in background and returns dynamic
that just samples the background proces with readDyn
.
accumMay' :: (a -> s -> Run (Maybe (b, s))) -> s -> Evt a -> Evt b Source #
Accumulate over event stream.
scan :: (a -> b -> b) -> b -> Evt a -> Evt b Source #
scan over event stream. Example:
naturals = scan (+) 0 pulse
scan' :: (a -> b -> Run b) -> b -> Evt a -> Evt b Source #
scan over event stream with effectful function.
scanMay :: (a -> b -> Maybe b) -> b -> Evt a -> Evt b Source #
scan combined with filter. If accumulator function produces Nothing
on event then
that event is ignored and state is kept to previous state.
scanMay' :: (a -> b -> Run (Maybe b)) -> b -> Evt a -> Evt b Source #
scan combined with filter for effectful function. See scanMay
for details.
iterates :: (a -> a) -> a -> Evt b -> Evt a Source #
Iterates over event stream. It's like scan but it ignores the values of underying stream and starts with initial value as first element.
withIterates :: (a -> a) -> a -> Evt b -> Evt (a, b) Source #
cancelDyn :: DynRef a -> Run () Source #
Shuts down the background process for dynamic and releases resulrces for event stream that drives the dynamic.
hold :: a -> Evt a -> Dyn a Source #
Turns event stream to dynamic. It holds the values of events until the next event happen. It starts with initial value.
hold initVal events = ...
unhold :: Dyn a -> Evt a Source #
Turns dynamic into event stream of underlying events that trigger dynamic updates.
scanD :: (a -> b -> b) -> b -> Evt a -> Dyn b Source #
scans over event stream and converts it to dynamic.
accumB :: a -> Evt (a -> a) -> Dyn a Source #
Accumulates the values with event stream that produce functions.
scanMayD :: (a -> b -> Maybe b) -> b -> Evt a -> Dyn b Source #
Dynamic scan that can also filter out events. If Nothing is produced then the event is skipped.
foreach :: (a -> Run ()) -> Evt a -> Evt a Source #
Adds some procedure to callback. Procedure is called prior to callback execution.
posteach :: (a -> Run ()) -> Evt a -> Evt a Source #
Adds some procedure to callback. Procedure is called after callback execution.
apply :: Dyn (a -> b) -> Evt a -> Evt b Source #
Applies a function to event stream value. The function is sampled from dynamic process.
snap :: Dyn a -> Evt b -> Evt a Source #
Snapshot of dynamic process with event stream. All values in the event stream are substituted with current value of dynamic.
attach :: Dyn a -> Evt b -> Evt (a, b) Source #
Kind of zipWith
function for dynamics and event streams.
attachWith :: (a -> b -> c) -> Dyn a -> Evt b -> Evt c Source #
Kind of zipWith
function for dynamics and event streams.
attachWithMay :: (a -> b -> Maybe c) -> Dyn a -> Evt b -> Evt c Source #
Attach with filtering. When Nothing
is produced event is omitted from the stream.
mapMay :: (a -> Maybe b) -> Evt a -> Evt b Source #
Map with filtering. When Nothing
is produced event is omitted from the stream.
mapMay' :: (a -> Run (Maybe b)) -> Evt a -> Evt b Source #
Map with filtering. When Nothing
is produced event is omitted from the stream.
filters :: (a -> Bool) -> Evt a -> Evt a Source #
Filtering of the event strewams. Only events that produce True remain in the stream.
filterJust :: Evt (Maybe a) -> Evt a Source #
Filters based on Maybe. If Nothing
is produced forthe event it is omitted from the stream.
whens :: Dyn Bool -> Evt a -> Evt a Source #
Filters with dynamic. When dynamic is true events pass through and when it's false events are omitted.
listAt :: [a] -> Evt Int -> Evt a Source #
Takes elements from the list by index. If index is out of bounds the event is omitted.
toToggle :: Evt a -> Evt Bool Source #
Turns event stream to toggle stream. It produce cyclic sequence of [True, False]
integrate2 :: (VectorSpace v, Scalar v ~ Float) => Float -> Dyn v -> Dyn v Source #
folds :: Monoid a => Evt a -> Run a Source #
Monoidal fold for event streams, note that stream have to be finite for the function to complete
foldls :: (b -> a -> b) -> b -> Evt a -> Run b Source #
Left fold for event streams, note that stream have to be finite for the function to complete
foldrs :: (a -> b -> b) -> b -> Evt a -> Run b Source #
Right fold for event streams, note that stream have to be finite for the function to complete
prints :: Show a => Evt a -> Run () Source #
Starts event stream process and as callback prints it values.
putStrLns :: Evt String -> Run () Source #
Starts event stream process and as callback prints it values.
switchDyn :: Dyn (Evt a) -> Evt a Source #
Queries the event stream form dynamic and runs it all next event streams are ignored.
joins :: Evt (Evt a) -> Evt a Source #
Joins event stream of streams. If stream is started it runs until the end.
fix1 :: (Evt a -> Run (Evt a)) -> Evt a Source #
Recursion on event streams. As event streams are functions we can not use
normal recursion that haskell provides. It will stuck the execution.
But we can use fix1
to create event stream that feeds back the events to itself.
Note that any sort of recursion can be implemented with fix1
.
For example if we need 3-recursive event stream:
fix3 :: (Evt a -> Evt b -> Evt c -> (Evt a, Evt b, Evt c)) -> (Evt a, Evt b, Evt c)
we can use sum tpye tags to join it to single stream:
data Tag a b c = TagA a | TagB b | TagC c
fix3 f = unwrap $ fix1 g where g x = wrap (f (unwrapA x) (unwrapB x) (unwrapC x)) wrap a b c = mconcat [TagA <$> a, TagB <$> b, TagC <$> c] unwrap evt = (unwrapA evt, unwrapB evt, unwrapC evt) unwrapA = flip mapMay $ \x -> case x of TagA a -> Just a _ -> Nothing
We can use this trck with any number of streams. There are helper functions: fix2
, fix3
, fix4
fix2 :: (Evt a -> Evt b -> Run (Evt a, Evt b)) -> (Evt a, Evt b) Source #
Recursion for binary functions
fix3 :: (Evt a -> Evt b -> Evt c -> Run (Evt a, Evt b, Evt c)) -> (Evt a, Evt b, Evt c) Source #
Recursion for ternary functions
fix4 :: (Evt a -> Evt b -> Evt c -> Evt d -> Run (Evt a, Evt b, Evt c, Evt d)) -> (Evt a, Evt b, Evt c, Evt d) Source #
Recursion for functions of four arguments
switch :: Evt (Evt a) -> Evt a Source #
Flattens event stream producer by switching between event streams. When next event stream happens it shuts down the previous one.
mchanEvt :: Chan a -> Evt a Source #
Creates the event stream that listens to MVar based channel. If any value is put chan the event stream fires the callback.
tchanEvt :: TChan a -> Evt a Source #
Creates the event stream that listens to MVar based channel. If any value is put chan the event stream fires the callback.
uchanEvt :: InChan a -> Evt a Source #
Creates the event stream that listens to unagi channel (package unagi-chan
).
If any value is put chan the event stream fires the callback.
clock :: NominalDiffTime -> Evt UTCTime Source #
Queries current time periodically with given period in seconds.
pulse :: NominalDiffTime -> Evt () Source #
Produces pulse events with given period in seconds.
ticks :: Float -> Evt Float Source #
Produces pulse events with given period in seconds and also tells how many seconds exactly has passed. It can be useful for simulations of models that are based on differential equations. As event streams carries how much time has passed between simulation steps.
timer :: Float -> Evt Float Source #
Timer behaves like tocks only it produces accumulated time since beginning of the process. It calculates them by querying current time and suntracting start time from it.
It can be though of as:
sumE ticks
toRandom :: Random b => Evt a -> Evt b Source #
Substitutes values in event stream with random values.
toRandomR :: Random b => (b, b) -> Evt a -> Evt b Source #
Substitutes values in event stream with random values from the given range.
withRandom :: Random b => Evt a -> Evt (b, a) Source #
Substitutes values in event stream with random values.
withRandomR :: Random b => (b, b) -> Evt a -> Evt (b, a) Source #
Substitutes values in event stream with random values from the given range.
freqOf :: Dyn [(a, Rational)] -> Evt b -> Evt a Source #
Picks at random one element from the list. We also provide distribution of events. Probability to pick up the element. Sum of probabilities should equal to 1.
withFreqOf :: Dyn [(a, Rational)] -> Evt b -> Evt (a, b) Source #
Picks at random one element from the list. We also provide distribution of events. Probability to pick up the element. Sum of probabilities should equal to 1.
randSkip :: Dyn Double -> Evt a -> Evt a Source #
Skips at random elements from the list. We provide frequency to skip events with dynamic first argument.
randSkipBy :: Dyn (a -> Double) -> Evt a -> Evt a Source #
Skips elements at random. The probability to skip element depends on the element itself.