module Brick.Util
( clamp
, on
, fg
, bg
, clOffset
)
where
import Lens.Micro ((&), (%~))
#if !(MIN_VERSION_base(4,11,0))
import Data.Monoid ((<>))
#endif
import Graphics.Vty
import Brick.Types.Internal (Location(..), CursorLocation(..), cursorLocationL)
clamp :: (Ord a)
=> a
-> a
-> a
-> a
clamp :: forall a. Ord a => a -> a -> a -> a
clamp a
mn a
mx a
val = forall a. Ord a => a -> a -> a
max a
mn (forall a. Ord a => a -> a -> a
min a
val a
mx)
on :: Color
-> Color
-> Attr
on :: Color -> Color -> Attr
on Color
f Color
b = Attr
defAttr Attr -> Color -> Attr
`withForeColor` Color
f
Attr -> Color -> Attr
`withBackColor` Color
b
fg :: Color -> Attr
fg :: Color -> Attr
fg = (Attr
defAttr Attr -> Color -> Attr
`withForeColor`)
bg :: Color -> Attr
bg :: Color -> Attr
bg = (Attr
defAttr Attr -> Color -> Attr
`withBackColor`)
clOffset :: CursorLocation n -> Location -> CursorLocation n
clOffset :: forall n. CursorLocation n -> Location -> CursorLocation n
clOffset CursorLocation n
cl Location
off = CursorLocation n
cl forall a b. a -> (a -> b) -> b
& forall n. Lens' (CursorLocation n) Location
cursorLocationL forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ (forall a. Semigroup a => a -> a -> a
<> Location
off)