brick-0.6: A declarative terminal user interface library

Safe HaskellNone
LanguageHaskell2010

Brick.Types

Contents

Description

Basic types used by this library.

Synopsis

The Widget type

data Widget Source

The type of widgets.

Constructors

Widget 

Fields

hSize :: Size

This widget's horizontal growth policy

vSize :: Size

This widget's vertical growth policy

render :: RenderM Result

This widget's rendering function

Location types and lenses

class TerminalLocation a where Source

The class of types that behave like terminal locations.

Methods

columnL :: Lens' a Int Source

Get the column out of the value

column :: a -> Int Source

rowL :: Lens' a Int Source

Get the row out of the value

row :: a -> Int Source

data CursorLocation Source

A cursor location. These are returned by the rendering process.

Constructors

CursorLocation 

Fields

cursorLocation :: !Location

The location

cursorLocationName :: !(Maybe Name)

The name of the widget associated with the location

Viewports

data Viewport Source

Describes the state of a viewport as it appears as its most recent rendering.

Constructors

VP 

Fields

_vpLeft :: Int

The column offset of left side of the viewport.

_vpTop :: Int

The row offset of the top of the viewport.

_vpSize :: DisplayRegion

The size of the viewport.

Instances

data ViewportType Source

The type of viewports that indicates the direction(s) in which a viewport is scrollable.

Constructors

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.

Event-handling types

newtype EventM a Source

The monad in which event handlers run. Although it may be tempting to dig into the reader value yourself, just use lookupViewport.

Constructors

EventM 

Fields

runEventM :: ReaderT (Map Name Viewport) (StateT EventState IO) a
 

data Next a Source

The type of actions to take upon completion of an event handler.

class HandleEvent a where Source

The class of types that provide some basic event-handling.

Methods

handleEvent :: Event -> a -> EventM a Source

Handle a Vty event

handleEventLensed Source

Arguments

:: HandleEvent b 
=> a

The state value.

-> Lens' a b

The lens to use to extract and store the target of the event.

-> Event

The event to handle.

-> EventM 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.

Rendering infrastructure

type RenderM a = ReaderT Context (State RenderState) a Source

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.

getContext :: RenderM Context Source

Get the current rendering context.

The rendering context

data Context Source

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 bordring style should be used, and the attribute map available for rendering.

attrL :: forall r. Getting r Context Attr Source

The rendering context's current drawing attribute.

Rendering results

data Result Source

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.

Constructors

Result 

Fields

image :: Image

The final rendered image for a widget

cursors :: [CursorLocation]

The list of reported cursor positions for the application to choose from

visibilityRequests :: [VisibilityRequest]

The list of visibility requests made by widgets rendered while rendering this one (used by viewports)

lookupAttrName :: AttrName -> RenderM Attr Source

Given an attribute name, obtain the attribute for the attribute name by consulting the context's attribute map.

Rendering result lenses

Visibility requests

Making lenses

suffixLenses :: Name -> DecsQ Source

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.

Miscellaneous

data Size Source

Widget growth policies. These policies communicate to layout algorithms how a widget uses space when being rendered. These policies influence rendering order and space allocation in the box layout algorithm.

Constructors

Fixed

Fixed widgets take up the same amount of space no matter how much they are given (non-greedy).

Greedy

Greedy widgets take up all the space they are given.

data Padding Source

The type of padding.

Constructors

Pad Int

Pad by the specified number of rows or columns.

Max

Pad up to the number of available rows or columns.

data Direction Source

Scrolling direction.

Constructors

Up

Up/left

Down

Down/right

newtype Name Source

Names of things. Used to name cursor locations, widgets, and viewports.

Constructors

Name String