brick-1.9: A declarative terminal user interface library

Safe Haskell | Safe-Inferred
Language | Haskell2010

Brick.BorderMap

Synopsis

- data BorderMap a
- data Edges a = Edges {
  - eTop, eBottom, eLeft, eRight :: a
  }
- eTopL :: forall a. Lens' (Edges a) a
- eBottomL :: forall a. Lens' (Edges a) a
- eRightL :: forall a. Lens' (Edges a) a
- eLeftL :: forall a. Lens' (Edges a) a
- empty :: BorderMap a
- clear :: BorderMap a -> BorderMap b
- emptyCoordinates :: Edges Int -> BorderMap a
- singleton :: Location -> a -> BorderMap a
- insertH :: Location -> Run a -> BorderMap a -> BorderMap a
- insertV :: Location -> Run a -> BorderMap a -> BorderMap a
- insert :: Location -> a -> BorderMap a -> BorderMap a
- unsafeUnion :: BorderMap a -> BorderMap a -> BorderMap a
- coordinates :: BorderMap a -> Edges Int
- bounds :: BorderMap a -> Edges (Int, Int)
- values :: BorderMap a -> Edges (IMap a)
- lookupRow :: Int -> BorderMap a -> IMap a
- lookupCol :: Int -> BorderMap a -> IMap a
- lookupH :: Location -> Run ignored -> BorderMap a -> IMap a
- lookupV :: Location -> Run ignored -> BorderMap a -> IMap a
- lookup :: Location -> BorderMap a -> Maybe a
- setCoordinates :: Edges Int -> BorderMap a -> BorderMap a
- crop :: Edges Int -> BorderMap a -> BorderMap a
- expand :: Edges Int -> BorderMap a -> BorderMap a
- translate :: Location -> BorderMap a -> BorderMap a

# Documentation

data BorderMap a Source #

A `BorderMap a` is like a `Map Location a`, except that there is a rectangle, and only `Location`s on the border of this rectangle are retained. The `BorderMap` can be queried for the position and size of the rectangle. There are also efficient bulk query and bulk update operations for adjacent positions on the border.

#### Instances

Instances details

Functor BorderMap Source # |
Instance details Defined in Brick.BorderMap Methods fmap :: (a -> b) -> BorderMap a -> BorderMap b Source # (<$) :: a -> BorderMap b -> BorderMap a Source #
Generic (BorderMap a) Source # |
Instance details Defined in Brick.BorderMap Associated Types type Rep (BorderMap a) :: Type -> Type Source # Methods from :: BorderMap a -> Rep (BorderMap a) x Source # to :: Rep (BorderMap a) x -> BorderMap a Source #
Read a => Read (BorderMap a) Source # |
Instance details Defined in Brick.BorderMap Methods readsPrec :: Int -> ReadS (BorderMap a) Source # readList :: ReadS [BorderMap a] Source # readPrec :: ReadPrec (BorderMap a) Source # readListPrec :: ReadPrec [BorderMap a] Source #
Show a => Show (BorderMap a) Source # |
Instance details Defined in Brick.BorderMap Methods showsPrec :: Int -> BorderMap a -> ShowS Source # show :: BorderMap a -> String Source # showList :: [BorderMap a] -> ShowS Source #
NFData a => NFData (BorderMap a) Source # |
Instance details Defined in Brick.BorderMap Methods rnf :: BorderMap a -> () Source #
Eq a => Eq (BorderMap a) Source # |
Instance details Defined in Brick.BorderMap Methods (==) :: BorderMap a -> BorderMap a -> Bool Source # (/=) :: BorderMap a -> BorderMap a -> Bool Source #
Ord a => Ord (BorderMap a) Source # |

Instance details

Defined in Brick.BorderMap

Methods

compare :: BorderMap a -> BorderMap a -> Ordering Source #

(<) :: BorderMap a -> BorderMap a -> Bool Source #

(<=) :: BorderMap a -> BorderMap a -> Bool Source #

(>) :: BorderMap a -> BorderMap a -> Bool Source #

(>=) :: BorderMap a -> BorderMap a -> Bool Source #

max :: BorderMap a -> BorderMap a -> BorderMap a Source #

min :: BorderMap a -> BorderMap a -> BorderMap a Source #

type Rep (BorderMap a) Source # |

Instance details

Defined in Brick.BorderMap

type Rep (BorderMap a) = D1 ('MetaData "BorderMap" "Brick.BorderMap" "brick-1.9-B374GEMQshy4UvqHBN1VYr" 'False) (C1 ('MetaCons "BorderMap" 'PrefixI 'True) (S1 ('MetaSel ('Just "_coordinates") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Edges Int)) :*: S1 ('MetaSel ('Just "_values") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Edges (IMap a)))))

data Edges a Source #

Constructors

Edges |

Fields

- eTop, eBottom, eLeft, eRight :: a

#### Instances

Instances details

Applicative Edges Source # |
Instance details Defined in Brick.Types.Common Methods pure :: a -> Edges a Source # (<*>) :: Edges (a -> b) -> Edges a -> Edges b Source # liftA2 :: (a -> b -> c) -> Edges a -> Edges b -> Edges c Source # (*>) :: Edges a -> Edges b -> Edges b Source # (<*) :: Edges a -> Edges b -> Edges a Source #
Functor Edges Source # |
Instance details Defined in Brick.Types.Common Methods fmap :: (a -> b) -> Edges a -> Edges b Source # (<$) :: a -> Edges b -> Edges a Source #
Monad Edges Source # |
Instance details Defined in Brick.Types.Common Methods (>>=) :: Edges a -> (a -> Edges b) -> Edges b Source # (>>) :: Edges a -> Edges b -> Edges b Source # return :: a -> Edges a Source #
Generic (Edges a) Source # |
Instance details Defined in Brick.Types.Common Associated Types type Rep (Edges a) :: Type -> Type Source # Methods from :: Edges a -> Rep (Edges a) x Source # to :: Rep (Edges a) x -> Edges a Source #
Read a => Read (Edges a) Source # |
Instance details Defined in Brick.Types.Common Methods readsPrec :: Int -> ReadS (Edges a) Source # readList :: ReadS [Edges a] Source # readPrec :: ReadPrec (Edges a) Source # readListPrec :: ReadPrec [Edges a] Source #
Show a => Show (Edges a) Source # |
Instance details Defined in Brick.Types.Common Methods showsPrec :: Int -> Edges a -> ShowS Source # show :: Edges a -> String Source # showList :: [Edges a] -> ShowS Source #
NFData a => NFData (Edges a) Source # |
Instance details Defined in Brick.Types.Common Methods rnf :: Edges a -> () Source #
Eq a => Eq (Edges a) Source # |
Instance details Defined in Brick.Types.Common Methods (==) :: Edges a -> Edges a -> Bool Source # (/=) :: Edges a -> Edges a -> Bool Source #
Ord a => Ord (Edges a) Source # |
Instance details Defined in Brick.Types.Common Methods compare :: Edges a -> Edges a -> Ordering Source # (<) :: Edges a -> Edges a -> Bool Source # (<=) :: Edges a -> Edges a -> Bool Source # (>) :: Edges a -> Edges a -> Bool Source # (>=) :: Edges a -> Edges a -> Bool Source # max :: Edges a -> Edges a -> Edges a Source # min :: Edges a -> Edges a -> Edges a Source #
type Rep (Edges a) Source # |

Instance details

Defined in Brick.Types.Common

type Rep (Edges a) = D1 ('MetaData "Edges" "Brick.Types.Common" "brick-1.9-B374GEMQshy4UvqHBN1VYr" '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))))

eTopL :: forall a. Lens' (Edges a) a Source #

eBottomL :: forall a. Lens' (Edges a) a Source #

eRightL :: forall a. Lens' (Edges a) a Source #

eLeftL :: forall a. Lens' (Edges a) a Source #

empty :: BorderMap a Source #

An empty `BorderMap` that does not track any points.

clear :: BorderMap a -> BorderMap b Source #

An empty `BorderMap` that tracks the same points as the input.

emptyCoordinates :: Edges Int -> BorderMap a Source #

Given a rectangle (specified as the coordinates of the top, left, bottom, and right sides), initialize an empty `BorderMap`.

singleton :: Location -> a -> BorderMap a Source #

A `BorderMap` that tracks only the given the point (and initially maps it to the given value).

insertH :: Location -> Run a -> BorderMap a -> BorderMap a Source #

Bulk insertion of horizontally-adjacent values. The `Location` gives the start point, and the `Run` extends in the "larger columns" direction.

insertV :: Location -> Run a -> BorderMap a -> BorderMap a Source #

Bulk insertion of vertically-adjacent values. The `Location` gives the start point, and the `Run` extends in the "larger rows" direction.

insert :: Location -> a -> BorderMap a -> BorderMap a Source #

Insert a single value at the given location.

unsafeUnion :: BorderMap a -> BorderMap a -> BorderMap a Source #

Assumes the two `BorderMap`s are tracking the same rectangles, but have disjoint keys. This property is not checked.

coordinates :: BorderMap a -> Edges Int Source #

The positions of the edges of the rectangle whose border is retained in a `BorderMap`. For example, if `coordinates m = e`, then the top border contains the `Location`s on row `eTop e` and between columns `eLeft e` to `eRight e` inclusive.

bounds :: BorderMap a -> Edges (Int, Int) Source #

A complementary way to query the edges of the rectangle whose border is retained in a `BorderMap`. For example, if `bounds m = b`, then a `Location`'s column must be between `fst (eTop b)` and `snd (eTop b)` to be retained. See also `coordinates`, which is in most cases a more natural border query.

values :: BorderMap a -> Edges (IMap a) Source #

Maps giving the values along each edge. Corner values are replicated in all relevant edges.

lookupRow :: Int -> BorderMap a -> IMap a Source #

Look up all values on a given row. The `IMap` returned maps columns to values.

lookupCol :: Int -> BorderMap a -> IMap a Source #

Look up all values on a given column. The `IMap` returned maps rows to values.

lookupH :: Location -> Run ignored -> BorderMap a -> IMap a Source #

Bulk lookup of horizontally-adjacent values. The `Location` gives the starting point, and the `Run` extends in the "larger columns" direction. The `IMap` returned maps columns to values.

lookupV :: Location -> Run ignored -> BorderMap a -> IMap a Source #

Bulk lookup of vertically-adjacent values. The `Location` gives the starting point, and the `Run` extends in the "larger rows" direction. The `IMap` returned maps rows to values.

lookup :: Location -> BorderMap a -> Maybe a Source #

Look up a single position.

setCoordinates :: Edges Int -> BorderMap a -> BorderMap a Source #

Set the rectangle being tracked by this `BorderMap`, throwing away any values that do not lie on this new rectangle.

crop :: Edges Int -> BorderMap a -> BorderMap a Source #

Ensure that the rectangle being tracked by this `BorderMap` extends no farther than the given one.

expand :: Edges Int -> BorderMap a -> BorderMap a Source #

Ensure that the rectangle being tracked by this `BorderMap` extends at least as far as the given one.

translate :: Location -> BorderMap a -> BorderMap a Source #

Move a `BorderMap` by adding the given `Location` to all keys in the map.