brick-0.36.1: A declarative terminal user interface library

Safe HaskellNone
LanguageHaskell2010

Brick.BorderMap

Synopsis

Documentation

data BorderMap a Source #

A BorderMap a is like a Map Location a, except that there is a rectangle, and only Locations 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

Functor BorderMap Source # 

Methods

fmap :: (a -> b) -> BorderMap a -> BorderMap b #

(<$) :: a -> BorderMap b -> BorderMap a #

Eq a => Eq (BorderMap a) Source # 

Methods

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

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

Ord a => Ord (BorderMap a) Source # 
Show a => Show (BorderMap a) Source # 

data Edges a Source #

Constructors

Edges 

Fields

Instances

Monad Edges Source # 

Methods

(>>=) :: Edges a -> (a -> Edges b) -> Edges b #

(>>) :: Edges a -> Edges b -> Edges b #

return :: a -> Edges a #

fail :: String -> Edges a #

Functor Edges Source # 

Methods

fmap :: (a -> b) -> Edges a -> Edges b #

(<$) :: a -> Edges b -> Edges a #

Applicative Edges Source # 

Methods

pure :: a -> Edges a #

(<*>) :: Edges (a -> b) -> Edges a -> Edges b #

liftA2 :: (a -> b -> c) -> Edges a -> Edges b -> Edges c #

(*>) :: Edges a -> Edges b -> Edges b #

(<*) :: Edges a -> Edges b -> Edges a #

Eq a => Eq (Edges a) Source # 

Methods

(==) :: Edges a -> Edges a -> Bool #

(/=) :: Edges a -> Edges a -> Bool #

Ord a => Ord (Edges a) Source # 

Methods

compare :: Edges a -> Edges a -> Ordering #

(<) :: Edges a -> Edges a -> Bool #

(<=) :: Edges a -> Edges a -> Bool #

(>) :: Edges a -> Edges a -> Bool #

(>=) :: Edges a -> Edges a -> Bool #

max :: Edges a -> Edges a -> Edges a #

min :: Edges a -> Edges a -> Edges a #

Read a => Read (Edges a) Source # 
Show a => Show (Edges a) Source # 

Methods

showsPrec :: Int -> Edges a -> ShowS #

show :: Edges a -> String #

showList :: [Edges a] -> ShowS #

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 only tracks the point (0,0).

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 BorderMaps 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 Locations 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.