talash-0.1.0.0: Line oriented fast enough text search
Safe HaskellNone
LanguageHaskell2010

Talash.Brick.Internal

Synopsis

Documentation

columns :: (a -> Widget n) -> [AttrName] -> [Int] -> [a] -> Widget n Source #

searchWidget :: (Ord n, Show n) => Bool -> Text -> Editor Text n -> Widget n Source #

searchWidgetAux :: (Ord n, Show n) => Bool -> Text -> Editor Text n -> Widget n -> Widget n Source #

listWithHighlights :: (Foldable f, Ord n, Show n) => Text -> (a -> f Text) -> Bool -> List n a -> Widget n Source #

columnsListWithHighlights :: (Foldable f, Ord n, Show n) => Text -> (a -> [f Text]) -> [AttrName] -> [Int] -> Bool -> List n a -> Widget n Source #

theMain :: Ord n => App b e n -> BChan e -> b -> IO b Source #

data Event #

Events.

Constructors

EvKey Key [Modifier]

A keyboard key was pressed with the specified modifiers.

EvMouseDown Int Int Button [Modifier]

A mouse button was pressed at the specified column and row. Any modifiers available in the event are also provided.

EvMouseUp Int Int (Maybe Button)

A mouse button was released at the specified column and row. Some terminals report only that a button was released without specifying which one; in that case, Nothing is provided. Otherwise Just the button released is included in the event.

EvResize Int Int

If read from eventChannel this is the size at the time of the signal. If read from nextEvent this is the size at the time the event was processed by Vty. Typically these are the same, but if somebody is resizing the terminal quickly they can be different.

EvPaste ByteString

A paste event occurs when a bracketed paste input sequence is received. For terminals that support bracketed paste mode, these events will be triggered on a paste event. Terminals that do not support bracketed pastes will send the paste contents as ordinary input (which is probably bad, so beware!) Note that the data is provided in raw form and you'll have to decode (e.g. as UTF-8) if that's what your application expects.

EvLostFocus

The terminal running the application lost input focus.

EvGainedFocus

The terminal running the application gained input focus.

Instances

Instances details
Eq Event 
Instance details

Defined in Graphics.Vty.Input.Events

Methods

(==) :: Event -> Event -> Bool #

(/=) :: Event -> Event -> Bool #

Ord Event 
Instance details

Defined in Graphics.Vty.Input.Events

Methods

compare :: Event -> Event -> Ordering #

(<) :: Event -> Event -> Bool #

(<=) :: Event -> Event -> Bool #

(>) :: Event -> Event -> Bool #

(>=) :: Event -> Event -> Bool #

max :: Event -> Event -> Event #

min :: Event -> Event -> Event #

Read Event 
Instance details

Defined in Graphics.Vty.Input.Events

Show Event 
Instance details

Defined in Graphics.Vty.Input.Events

Methods

showsPrec :: Int -> Event -> ShowS #

show :: Event -> String #

showList :: [Event] -> ShowS #

Generic Event 
Instance details

Defined in Graphics.Vty.Input.Events

Associated Types

type Rep Event :: Type -> Type #

Methods

from :: Event -> Rep Event x #

to :: Rep Event x -> Event #

type Rep Event 
Instance details

Defined in Graphics.Vty.Input.Events

type Rep Event = D1 ('MetaData "Event" "Graphics.Vty.Input.Events" "vty-5.33-d400eec211b41e58acc410b10d79ca4624828bcbf5f0eb291b0c1dd87f602843" 'False) ((C1 ('MetaCons "EvKey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Key) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Modifier])) :+: (C1 ('MetaCons "EvMouseDown" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Button) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Modifier]))) :+: C1 ('MetaCons "EvMouseUp" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Button)))))) :+: ((C1 ('MetaCons "EvResize" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :+: C1 ('MetaCons "EvPaste" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) :+: (C1 ('MetaCons "EvLostFocus" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EvGainedFocus" 'PrefixI 'False) (U1 :: Type -> Type))))

data Attr #

A display attribute defines the Color and Style of all the characters rendered after the attribute is applied.

At most 256 colors, picked from a 240 and 16 color palette, are possible for the background and foreground. The 240 colors and 16 colors are points in different palettes. See Color for more information.

Instances

Instances details
Eq Attr 
Instance details

Defined in Graphics.Vty.Attributes

Methods

(==) :: Attr -> Attr -> Bool #

(/=) :: Attr -> Attr -> Bool #

Read Attr 
Instance details

Defined in Graphics.Vty.Attributes

Show Attr 
Instance details

Defined in Graphics.Vty.Attributes

Methods

showsPrec :: Int -> Attr -> ShowS #

show :: Attr -> String #

showList :: [Attr] -> ShowS #

Generic Attr 
Instance details

Defined in Graphics.Vty.Attributes

Associated Types

type Rep Attr :: Type -> Type #

Methods

from :: Attr -> Rep Attr x #

to :: Rep Attr x -> Attr #

Semigroup Attr 
Instance details

Defined in Graphics.Vty.Attributes

Methods

(<>) :: Attr -> Attr -> Attr #

sconcat :: NonEmpty Attr -> Attr #

stimes :: Integral b => b -> Attr -> Attr #

Monoid Attr 
Instance details

Defined in Graphics.Vty.Attributes

Methods

mempty :: Attr #

mappend :: Attr -> Attr -> Attr #

mconcat :: [Attr] -> Attr #

GetAttr Attr 
Instance details

Defined in Brick.Markup

Methods

getAttr :: Attr -> RenderM n Attr #

NFData Attr 
Instance details

Defined in Graphics.Vty.Attributes

Methods

rnf :: Attr -> () #

type Rep Attr 
Instance details

Defined in Graphics.Vty.Attributes

type Rep Attr = D1 ('MetaData "Attr" "Graphics.Vty.Attributes" "vty-5.33-d400eec211b41e58acc410b10d79ca4624828bcbf5f0eb291b0c1dd87f602843" 'False) (C1 ('MetaCons "Attr" 'PrefixI 'True) ((S1 ('MetaSel ('Just "attrStyle") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (MaybeDefault Style)) :*: S1 ('MetaSel ('Just "attrForeColor") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (MaybeDefault Color))) :*: (S1 ('MetaSel ('Just "attrBackColor") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (MaybeDefault Color)) :*: S1 ('MetaSel ('Just "attrURL") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (MaybeDefault Text)))))

markup :: (Eq a, GetAttr a) => Markup a -> Widget n #

Build a widget from markup.

(@?) :: Text -> AttrName -> Markup AttrName #

Build a piece of markup from text with an assigned attribute name. When the markup is rendered, the attribute name will be looked up in the rendering context's AttrMap to determine the attribute to use for this piece of text.

class GetAttr a #

A type class for types that provide access to an attribute in the rendering monad. You probably won't need to instance this.

Minimal complete definition

getAttr

Instances

Instances details
GetAttr Attr 
Instance details

Defined in Brick.Markup

Methods

getAttr :: Attr -> RenderM n Attr #

GetAttr AttrName 
Instance details

Defined in Brick.Markup

Methods

getAttr :: AttrName -> RenderM n Attr #

toText :: Eq a => Markup a -> Text #

Extract the text from markup, discarding the markup metadata.

data Markup a #

Markup with metadata type a assigned to each character.

Instances

Instances details
Show a => Show (Markup a) 
Instance details

Defined in Data.Text.Markup

Methods

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

show :: Markup a -> String #

showList :: [Markup a] -> ShowS #

Monoid a => IsString (Markup a) 
Instance details

Defined in Data.Text.Markup

Methods

fromString :: String -> Markup a #

Semigroup (Markup a) 
Instance details

Defined in Data.Text.Markup

Methods

(<>) :: Markup a -> Markup a -> Markup a #

sconcat :: NonEmpty (Markup a) -> Markup a #

stimes :: Integral b => b -> Markup a -> Markup a #

Monoid (Markup a) 
Instance details

Defined in Data.Text.Markup

Methods

mempty :: Markup a #

mappend :: Markup a -> Markup a -> Markup a #

mconcat :: [Markup a] -> Markup a #

listSelectedElement :: forall (t :: Type -> Type) n e. (Splittable t, Foldable t) => GenericList n t e -> Maybe (Int, e) #

Return a list's selected element, if any.

Only evaluates as much of the container as needed.

Complexity: same as splitAt for the container type.

listSelectedElement for List: O(1)
listSelectedElement for Seq: O(log(min(i, n - i)))

listReplace :: (Foldable t, Splittable t) => t e -> Maybe Int -> GenericList n t e -> GenericList n t e #

Replace the contents of a list with a new set of elements and update the new selected index. If the list is empty, empty selection is used instead. Otherwise, if the specified selected index (via Just) is not in the list bounds, zero is used instead.

Complexity: same as splitAt for the container type.

renderListWithIndex #

Arguments

:: forall (t :: Type -> Type) n e. (Traversable t, Splittable t, Ord n, Show n) 
=> (Int -> Bool -> e -> Widget n)

Rendering function, taking index, and True for the selected element

-> Bool

Whether the list has focus

-> GenericList n t e

The List to be rendered

-> Widget n

rendered widget

Like renderList, except the render function is also provided with the index of each element.

Has the same evaluation characteristics as renderList.

renderList #

Arguments

:: forall (t :: Type -> Type) n e. (Traversable t, Splittable t, Ord n, Show n) 
=> (Bool -> e -> Widget n)

Rendering function, True for the selected element

-> Bool

Whether the list has focus

-> GenericList n t e

The List to be rendered

-> Widget n

rendered widget

Render a list using the specified item drawing function.

Evaluates the underlying container up to, and a bit beyond, the selected element. The exact amount depends on available height for drawing and listItemHeight. At most, it will evaluate up to element (i + h + 1) where i is the selected index and h is the available height.

Note that this function renders the list with the listAttr as the default attribute and then uses listSelectedAttr as the default attribute for the selected item if the list is not focused or listSelectedFocusedAttr otherwise. This is provided as a convenience so that the item rendering function doesn't have to be concerned with attributes, but if those attributes are undesirable for your purposes, forceAttr can always be used by the item rendering function to ensure that another attribute is used instead.

list #

Arguments

:: Foldable t 
=> n

The list name (must be unique)

-> t e

The initial list contents

-> Int

The list item height in rows (all list item widgets must be this high).

-> GenericList n t e 

Construct a list in terms of container t with element type e.

listSelectedAttr :: AttrName #

The attribute used only for the currently-selected list item when the list does not have focus. Extends listAttr.

listAttr :: AttrName #

The top-level attribute used for the entire list.

handleListEventVi #

Arguments

:: forall (t :: Type -> Type) n e. (Foldable t, Splittable t, Ord n) 
=> (Event -> GenericList n t e -> EventM n (GenericList n t e))

Fallback event handler to use if none of the vi keys match.

-> Event 
-> GenericList n t e 
-> EventM n (GenericList n t e) 

Enable list movement with the vi keys with a fallback handler if none match. Use handleListEventVi handleListEvent in place of handleListEvent to add the vi keys bindings to the standard ones. Movements handled include:

  • Up (k)
  • Down (j)
  • Page Up (Ctrl-b)
  • Page Down (Ctrl-f)
  • Half Page Up (Ctrl-u)
  • Half Page Down (Ctrl-d)
  • Go to first element (g)
  • Go to last element (G)

handleListEvent :: forall (t :: Type -> Type) n e. (Foldable t, Splittable t, Ord n) => Event -> GenericList n t e -> EventM n (GenericList n t e) #

Handle events for list cursor movement. Events handled are:

  • Up (up arrow key)
  • Down (down arrow key)
  • Page Up (PgUp)
  • Page Down (PgDown)
  • Go to first element (Home)
  • Go to last element (End)

listSelectedL :: forall n (t :: Type -> Type) e. Lens' (GenericList n t e) (Maybe Int) #

type List n e = GenericList n Vector e #

An alias for GenericList specialized to use a Vector as its container type.

data GenericList n (t :: Type -> Type) e #

List state. Lists have a container t of element type e that is the data stored by the list. Internally, Lists handle the following events by default:

  • Up/down arrow keys: move cursor of selected item
  • Page up / page down keys: move cursor of selected item by one page at a time (based on the number of items shown)
  • Home/end keys: move cursor of selected item to beginning or end of list

The List type synonym fixes t to Vector for compatibility with previous versions of this library.

For a container type to be usable with GenericList, it must have instances of Traversable and Splittable. The following functions impose further constraints:

Instances

Instances details
Functor t => Functor (GenericList n t) 
Instance details

Defined in Brick.Widgets.List

Methods

fmap :: (a -> b) -> GenericList n t a -> GenericList n t b #

(<$) :: a -> GenericList n t b -> GenericList n t a #

Foldable t => Foldable (GenericList n t) 
Instance details

Defined in Brick.Widgets.List

Methods

fold :: Monoid m => GenericList n t m -> m #

foldMap :: Monoid m => (a -> m) -> GenericList n t a -> m #

foldMap' :: Monoid m => (a -> m) -> GenericList n t a -> m #

foldr :: (a -> b -> b) -> b -> GenericList n t a -> b #

foldr' :: (a -> b -> b) -> b -> GenericList n t a -> b #

foldl :: (b -> a -> b) -> b -> GenericList n t a -> b #

foldl' :: (b -> a -> b) -> b -> GenericList n t a -> b #

foldr1 :: (a -> a -> a) -> GenericList n t a -> a #

foldl1 :: (a -> a -> a) -> GenericList n t a -> a #

toList :: GenericList n t a -> [a] #

null :: GenericList n t a -> Bool #

length :: GenericList n t a -> Int #

elem :: Eq a => a -> GenericList n t a -> Bool #

maximum :: Ord a => GenericList n t a -> a #

minimum :: Ord a => GenericList n t a -> a #

sum :: Num a => GenericList n t a -> a #

product :: Num a => GenericList n t a -> a #

Traversable t => Traversable (GenericList n t) 
Instance details

Defined in Brick.Widgets.List

Methods

traverse :: Applicative f => (a -> f b) -> GenericList n t a -> f (GenericList n t b) #

sequenceA :: Applicative f => GenericList n t (f a) -> f (GenericList n t a) #

mapM :: Monad m => (a -> m b) -> GenericList n t a -> m (GenericList n t b) #

sequence :: Monad m => GenericList n t (m a) -> m (GenericList n t a) #

(Show n, Show (t e)) => Show (GenericList n t e) 
Instance details

Defined in Brick.Widgets.List

Methods

showsPrec :: Int -> GenericList n t e -> ShowS #

show :: GenericList n t e -> String #

showList :: [GenericList n t e] -> ShowS #

Generic (GenericList n t e) 
Instance details

Defined in Brick.Widgets.List

Associated Types

type Rep (GenericList n t e) :: Type -> Type #

Methods

from :: GenericList n t e -> Rep (GenericList n t e) x #

to :: Rep (GenericList n t e) x -> GenericList n t e #

Named (GenericList n t e) n 
Instance details

Defined in Brick.Widgets.List

Methods

getName :: GenericList n t e -> n #

type Rep (GenericList n t e) 
Instance details

Defined in Brick.Widgets.List

type Rep (GenericList n t e) = D1 ('MetaData "GenericList" "Brick.Widgets.List" "brick-0.62-1e79edf9d5b0299388734a25939a48645b839d61d7654ecff0a3eb424ccc31a7" 'False) (C1 ('MetaCons "List" 'PrefixI 'True) ((S1 ('MetaSel ('Just "listElements") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (t e)) :*: S1 ('MetaSel ('Just "listSelected") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe Int))) :*: (S1 ('MetaSel ('Just "listName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 n) :*: S1 ('MetaSel ('Just "listItemHeight") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int))))

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.

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.

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

customMainWithVty #

Arguments

:: 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 Nothing if you don't plan on sending custom events.

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

customMain #

Arguments

:: 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 Nothing if you don't plan on sending custom events.

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

simpleMain #

Arguments

:: Ord n 
=> Widget n

The widget to draw.

-> IO () 

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.

defaultMain #

Arguments

:: Ord n 
=> App s e n

The application.

-> s

The initial application state.

-> IO s 

The default main entry point which takes an application and an initial state and returns the final state returned by a halt operation.

data App s e n #

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.

Constructors

App 

Fields

  • appDraw :: s -> [Widget n]

    This function turns your application state into a list of widget layers. The layers are listed topmost first.

  • appChooseCursor :: s -> [CursorLocation n] -> Maybe (CursorLocation n)

    This function chooses which of the zero or more cursor locations reported by the rendering process should be selected as the one to use to place the cursor. If this returns Nothing, no cursor is placed. The rationale here is that many widgets may request a cursor placement but your application state is what you probably want to use to decide which one wins.

  • appHandleEvent :: s -> BrickEvent n e -> EventM n (Next s)

    This function takes the current application state and an event and returns an action to be taken and a corresponding transformed application state. Possible options are continue, suspendAndResume, and halt.

  • appStartEvent :: s -> EventM n s

    This function gets called once just prior to the first drawing of your application. Here is where you can make initial scrolling requests, for example.

  • appAttrMap :: s -> AttrMap

    The attribute map that should be used during rendering.

data ViewportScroll n #

A viewport scrolling handle for managing the scroll state of viewports.

vBorder :: Widget n #

A vertical border. Fills all vertical space.

hBorder :: Widget n #

A horizontal border. Fills all horizontal space.

border :: Widget n -> Widget n #

Put a border around the specified widget.

borderAttr :: AttrName #

The top-level border attribute name.

center :: Widget n -> Widget n #

Center a widget both vertically and horizontally. Consumes all available vertical and horizontal space.

vCenter :: Widget n -> Widget n #

Center a widget vertically. Consumes all vertical space.

renderEditor #

Arguments

:: (Ord n, Show n, Monoid t, TextWidth t, GenericTextZipper t) 
=> ([t] -> Widget n)

The content drawing function

-> Bool

Whether the editor has focus. It will report a cursor position if and only if it has focus.

-> Editor t n

The editor.

-> Widget n 

Turn an editor state value into a widget. This uses the editor's name for its scrollable viewport handle and the name is also used to report mouse events.

getEditContents :: Monoid t => Editor t n -> [t] #

Get the contents of the editor.

applyEdit #

Arguments

:: (TextZipper t -> TextZipper t)

The Zipper editing transformation to apply

-> Editor t n 
-> Editor t n 

Apply an editing operation to the editor's contents. Bear in mind that you should only apply zipper operations that operate on the current line; the editor will only ever render the first line of text.

editor #

Arguments

:: GenericTextZipper a 
=> n

The editor's name (must be unique)

-> Maybe Int

The limit on the number of lines in the editor (Nothing means no limit)

-> a

The initial content

-> Editor a n 

Construct an editor over String values

editorText #

Arguments

:: n

The editor's name (must be unique)

-> Maybe Int

The limit on the number of lines in the editor (Nothing means no limit)

-> Text

The initial content

-> Editor Text n 

Construct an editor over Text values

handleEditorEvent :: (DecodeUtf8 t, Eq t, Monoid t) => Event -> Editor t n -> EventM n (Editor t n) #

data Editor t n #

Editor state. Editors support the following events by default:

  • Ctrl-a: go to beginning of line
  • Ctrl-e: go to end of line
  • Ctrl-d, Del: delete character at cursor position
  • Backspace: delete character prior to cursor position
  • Ctrl-k: delete all from cursor to end of line
  • Ctrl-u: delete all from cursor to beginning of line
  • Arrow keys: move cursor
  • Enter: break the current line at the cursor position
  • Paste: Bracketed Pastes from the terminal will be pasted, provided the incoming data is UTF-8-encoded.

Instances

Instances details
(Show t, Show n) => Show (Editor t n) 
Instance details

Defined in Brick.Widgets.Edit

Methods

showsPrec :: Int -> Editor t n -> ShowS #

show :: Editor t n -> String #

showList :: [Editor t n] -> ShowS #

Named (Editor t n) n 
Instance details

Defined in Brick.Widgets.Edit

Methods

getName :: Editor t n -> n #

(<=>) #

Arguments

:: Widget n

Top

-> Widget n

Bottom

-> Widget n 

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.

(<+>) #

Arguments

:: Widget n

Left

-> Widget n

Right

-> Widget n 

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.

viewport #

Arguments

:: (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.

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.

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.

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.

raw :: Image -> Widget n #

Build a widget directly from a raw Vty image.

overrideAttr :: AttrName -> AttrName -> Widget n -> Widget n #

Override the lookup of targetName to return the attribute value associated with fromName when rendering the specified widget. See also mapAttrName.

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.

updateAttrMap :: (AttrMap -> AttrMap) -> Widget n -> Widget n #

When rendering the specified widget, update the attribute map with the specified transformation.

withDefAttr :: AttrName -> Widget n -> Widget n #

Update the attribute map while rendering the specified widget: set its new default attribute to the one that we get by looking up the specified attribute name in the map.

modifyDefAttr :: (Attr -> Attr) -> Widget n -> Widget n #

Update the attribute map while rendering the specified widget: set its new default attribute to the one that we get by looking up the specified attribute name in the map and then modifying it with the specified function.

withAttr :: AttrName -> Widget n -> Widget n #

When drawing the specified widget, set the current attribute used for drawing to the one with the specified name. Note that the widget may use further calls to withAttr to override this; if you really 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.

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 :: Char -> Widget n #

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.

txt :: Text -> Widget n #

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.

str :: String -> Widget n #

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.

txtWrap :: Text -> Widget n #

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 :: n -> Widget n -> Widget n #

Request mouse click events on the specified widget.

reportExtent :: n -> Widget n -> Widget n #

Render the specified widget and record its rendering extent using the specified name (see also lookupExtent).

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.

class TextWidth a where #

The class of text types that have widths measured in terminal columns. NEVER use length etc. to measure the length of a string if you need to compute how much screen space it will occupy; always use textWidth.

Methods

textWidth :: a -> Int #

Instances

Instances details
TextWidth Text 
Instance details

Defined in Brick.Widgets.Core

Methods

textWidth :: Text -> Int #

Foldable f => TextWidth (f Char) 
Instance details

Defined in Brick.Widgets.Core

Methods

textWidth :: f Char -> Int #

class Named a n where #

The class of types that store interface element names.

Methods

getName :: a -> n #

Get the name of the specified value.

Instances

Instances details
Named (Editor t n) n 
Instance details

Defined in Brick.Widgets.Edit

Methods

getName :: Editor t n -> n #

Named (GenericList n t e) n 
Instance details

Defined in Brick.Widgets.List

Methods

getName :: GenericList n t e -> n #

cropToContext :: Widget n -> Widget n #

After rendering the specified widget, crop its result image to the dimensions in the rendering context.

lookupAttrName :: AttrName -> RenderM n Attr #

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

attrL :: Getting r Context Attr #

The rendering context's current drawing attribute.

getContext :: RenderM n Context #

Get the current rendering context.

handleEventLensed #

Arguments

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

data Padding #

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.

newtype EventM n a #

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

Instances

Instances details
Monad (EventM n) 
Instance details

Defined in Brick.Types

Methods

(>>=) :: EventM n a -> (a -> EventM n b) -> EventM n b #

(>>) :: EventM n a -> EventM n b -> EventM n b #

return :: a -> EventM n a #

Functor (EventM n) 
Instance details

Defined in Brick.Types

Methods

fmap :: (a -> b) -> EventM n a -> EventM n b #

(<$) :: a -> EventM n b -> EventM n a #

MonadFail (EventM n) 
Instance details

Defined in Brick.Types

Methods

fail :: String -> EventM n a #

Applicative (EventM n) 
Instance details

Defined in Brick.Types

Methods

pure :: a -> EventM n a #

(<*>) :: EventM n (a -> b) -> EventM n a -> EventM n b #

liftA2 :: (a -> b -> c) -> EventM n a -> EventM n b -> EventM n c #

(*>) :: EventM n a -> EventM n b -> EventM n b #

(<*) :: EventM n a -> EventM n b -> EventM n a #

MonadIO (EventM n) 
Instance details

Defined in Brick.Types

Methods

liftIO :: IO a -> EventM n a #

MonadThrow (EventM n) 
Instance details

Defined in Brick.Types

Methods

throwM :: Exception e => e -> EventM n a #

MonadCatch (EventM n) 
Instance details

Defined in Brick.Types

Methods

catch :: Exception e => EventM n a -> (e -> EventM n a) -> EventM n a #

MonadMask (EventM n) 
Instance details

Defined in Brick.Types

Methods

mask :: ((forall a. EventM n a -> EventM n a) -> EventM n b) -> EventM n b #

uninterruptibleMask :: ((forall a. EventM n a -> EventM n a) -> EventM n b) -> EventM n b #

generalBracket :: EventM n a -> (a -> ExitCase b -> EventM n c) -> (a -> EventM n b) -> EventM n (b, c) #

data Size #

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.

Constructors

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.

Instances

Instances details
Eq Size 
Instance details

Defined in Brick.Types

Methods

(==) :: Size -> Size -> Bool #

(/=) :: Size -> Size -> Bool #

Ord Size 
Instance details

Defined in Brick.Types

Methods

compare :: Size -> Size -> Ordering #

(<) :: Size -> Size -> Bool #

(<=) :: Size -> Size -> Bool #

(>) :: Size -> Size -> Bool #

(>=) :: Size -> Size -> Bool #

max :: Size -> Size -> Size #

min :: Size -> Size -> Size #

Show Size 
Instance details

Defined in Brick.Types

Methods

showsPrec :: Int -> Size -> ShowS #

show :: Size -> String #

showList :: [Size] -> ShowS #

data Widget n #

The type of widgets.

Constructors

Widget 

Fields

type RenderM n a = ReaderT Context (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.

clOffset :: CursorLocation n -> Location -> CursorLocation n #

Add a Location offset to the specified CursorLocation.

bg :: Color -> Attr #

Create an attribute from the specified background color (the background color is the "default").

fg :: Color -> Attr #

Create an attribute from the specified foreground color (the background color is the "default").

on #

Arguments

:: Color

The foreground color

-> Color

The background color

-> Attr 

Build an attribute from a foreground color and a background color. Intended to be used infix.

clamp #

Arguments

:: 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

data BrickEvent n e #

The type of events.

Constructors

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 n value is the resource name of the clicked widget (see clickable).

MouseUp n (Maybe Button) Location

A mouse-up event on the specified region was received. The n value is the resource name of the clicked widget (see clickable).

Instances

Instances details
(Eq e, Eq n) => Eq (BrickEvent n e) 
Instance details

Defined in Brick.Types.Internal

Methods

(==) :: BrickEvent n e -> BrickEvent n e -> Bool #

(/=) :: BrickEvent n e -> BrickEvent n e -> Bool #

(Ord e, Ord n) => Ord (BrickEvent n e) 
Instance details

Defined in Brick.Types.Internal

Methods

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) 
Instance details

Defined in Brick.Types.Internal

Methods

showsPrec :: Int -> BrickEvent n e -> ShowS #

show :: BrickEvent n e -> String #

showList :: [BrickEvent n e] -> ShowS #

data RenderState n #

Instances

Instances details
(Ord n, Read n) => Read (RenderState n) 
Instance details

Defined in Brick.Types.Internal

Show n => Show (RenderState n) 
Instance details

Defined in Brick.Types.Internal

Generic (RenderState n) 
Instance details

Defined in Brick.Types.Internal

Associated Types

type Rep (RenderState n) :: Type -> Type #

Methods

from :: RenderState n -> Rep (RenderState n) x #

to :: Rep (RenderState n) x -> RenderState n #

NFData n => NFData (RenderState n) 
Instance details

Defined in Brick.Types.Internal

Methods

rnf :: RenderState n -> () #

type Rep (RenderState n) 
Instance details

Defined in Brick.Types.Internal

type Rep (RenderState n) = D1 ('MetaData "RenderState" "Brick.Types.Internal" "brick-0.62-1e79edf9d5b0299388734a25939a48645b839d61d7654ecff0a3eb424ccc31a7" 'False) (C1 ('MetaCons "RS" 'PrefixI 'True) ((S1 ('MetaSel ('Just "viewportMap") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map n Viewport)) :*: S1 ('MetaSel ('Just "rsScrollRequests") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [(n, ScrollRequest)])) :*: (S1 ('MetaSel ('Just "observedNames") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Set n)) :*: (S1 ('MetaSel ('Just "renderCache") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Map n ([n], Result n))) :*: S1 ('MetaSel ('Just "clickableNames") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [n])))))

data Context #

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

Instances details
Show Context 
Instance details

Defined in Brick.Types.Internal

data Result n #

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

Instances

Instances details
Read n => Read (Result n) 
Instance details

Defined in Brick.Types.Internal

Show n => Show (Result n) 
Instance details

Defined in Brick.Types.Internal

Methods

showsPrec :: Int -> Result n -> ShowS #

show :: Result n -> String #

showList :: [Result n] -> ShowS #

Generic (Result n) 
Instance details

Defined in Brick.Types.Internal

Associated Types

type Rep (Result n) :: Type -> Type #

Methods

from :: Result n -> Rep (Result n) x #

to :: Rep (Result n) x -> Result n #

NFData n => NFData (Result n) 
Instance details

Defined in Brick.Types.Internal

Methods

rnf :: Result n -> () #

type Rep (Result n) 
Instance details

Defined in Brick.Types.Internal

type Rep (Result n) = D1 ('MetaData "Result" "Brick.Types.Internal" "brick-0.62-1e79edf9d5b0299388734a25939a48645b839d61d7654ecff0a3eb424ccc31a7" '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 DynBorder #

Information about how to redraw a dynamic border character when it abuts another dynamic border character.

Constructors

DynBorder 

Fields

Instances

Instances details
Eq DynBorder 
Instance details

Defined in Brick.Types.Internal

Read DynBorder 
Instance details

Defined in Brick.Types.Internal

Show DynBorder 
Instance details

Defined in Brick.Types.Internal

Generic DynBorder 
Instance details

Defined in Brick.Types.Internal

Associated Types

type Rep DynBorder :: Type -> Type #

NFData DynBorder 
Instance details

Defined in Brick.Types.Internal

Methods

rnf :: DynBorder -> () #

type Rep DynBorder 
Instance details

Defined in Brick.Types.Internal

type Rep DynBorder = D1 ('MetaData "DynBorder" "Brick.Types.Internal" "brick-0.62-1e79edf9d5b0299388734a25939a48645b839d61d7654ecff0a3eb424ccc31a7" '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)))))

data VisibilityRequest #

Constructors

VR 

Instances

Instances details
Eq VisibilityRequest 
Instance details

Defined in Brick.Types.Internal

Read VisibilityRequest 
Instance details

Defined in Brick.Types.Internal

Show VisibilityRequest 
Instance details

Defined in Brick.Types.Internal

Generic VisibilityRequest 
Instance details

Defined in Brick.Types.Internal

Associated Types

type Rep VisibilityRequest :: Type -> Type #

NFData VisibilityRequest 
Instance details

Defined in Brick.Types.Internal

Methods

rnf :: VisibilityRequest -> () #

type Rep VisibilityRequest 
Instance details

Defined in Brick.Types.Internal

type Rep VisibilityRequest = D1 ('MetaData "VisibilityRequest" "Brick.Types.Internal" "brick-0.62-1e79edf9d5b0299388734a25939a48645b839d61d7654ecff0a3eb424ccc31a7" 'False) (C1 ('MetaCons "VR" 'PrefixI 'True) (S1 ('MetaSel ('Just "vrPosition") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Location) :*: S1 ('MetaSel ('Just "vrSize") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DisplayRegion)))

data Viewport #

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

Constructors

VP 

Fields

Instances

Instances details
Read Viewport 
Instance details

Defined in Brick.Types.Internal

Show Viewport 
Instance details

Defined in Brick.Types.Internal

Generic Viewport 
Instance details

Defined in Brick.Types.Internal

Associated Types

type Rep Viewport :: Type -> Type #

Methods

from :: Viewport -> Rep Viewport x #

to :: Rep Viewport x -> Viewport #

NFData Viewport 
Instance details

Defined in Brick.Types.Internal

Methods

rnf :: Viewport -> () #

type Rep Viewport 
Instance details

Defined in Brick.Types.Internal

type Rep Viewport = D1 ('MetaData "Viewport" "Brick.Types.Internal" "brick-0.62-1e79edf9d5b0299388734a25939a48645b839d61d7654ecff0a3eb424ccc31a7" '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))))

data ViewportType #

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.

Instances

Instances details
Eq ViewportType 
Instance details

Defined in Brick.Types.Internal

Show ViewportType 
Instance details

Defined in Brick.Types.Internal

data Extent n #

An extent of a named area: its size, location, and origin.

Constructors

Extent 

Instances

Instances details
Read n => Read (Extent n) 
Instance details

Defined in Brick.Types.Internal

Show n => Show (Extent n) 
Instance details

Defined in Brick.Types.Internal

Methods

showsPrec :: Int -> Extent n -> ShowS #

show :: Extent n -> String #

showList :: [Extent n] -> ShowS #

Generic (Extent n) 
Instance details

Defined in Brick.Types.Internal

Associated Types

type Rep (Extent n) :: Type -> Type #

Methods

from :: Extent n -> Rep (Extent n) x #

to :: Rep (Extent n) x -> Extent n #

NFData n => NFData (Extent n) 
Instance details

Defined in Brick.Types.Internal

Methods

rnf :: Extent n -> () #

type Rep (Extent n) 
Instance details

Defined in Brick.Types.Internal

type Rep (Extent n) = D1 ('MetaData "Extent" "Brick.Types.Internal" "brick-0.62-1e79edf9d5b0299388734a25939a48645b839d61d7654ecff0a3eb424ccc31a7" '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)))))

data Next a #

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

Instances

Instances details
Functor Next 
Instance details

Defined in Brick.Types.Internal

Methods

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

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

data Direction #

Scrolling direction.

Constructors

Up

Up/left

Down

Down/right

Instances

Instances details
Eq Direction 
Instance details

Defined in Brick.Types.Internal

Read Direction 
Instance details

Defined in Brick.Types.Internal

Show Direction 
Instance details

Defined in Brick.Types.Internal

Generic Direction 
Instance details

Defined in Brick.Types.Internal

Associated Types

type Rep Direction :: Type -> Type #

NFData Direction 
Instance details

Defined in Brick.Types.Internal

Methods

rnf :: Direction -> () #

type Rep Direction 
Instance details

Defined in Brick.Types.Internal

type Rep Direction = D1 ('MetaData "Direction" "Brick.Types.Internal" "brick-0.62-1e79edf9d5b0299388734a25939a48645b839d61d7654ecff0a3eb424ccc31a7" 'False) (C1 ('MetaCons "Up" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Down" 'PrefixI 'False) (U1 :: Type -> Type))

class TerminalLocation a where #

The class of types that behave like terminal locations.

Methods

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 #

data CursorLocation n #

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

Constructors

CursorLocation 

Fields

Instances

Instances details
Read n => Read (CursorLocation n) 
Instance details

Defined in Brick.Types.Internal

Show n => Show (CursorLocation n) 
Instance details

Defined in Brick.Types.Internal

Generic (CursorLocation n) 
Instance details

Defined in Brick.Types.Internal

Associated Types

type Rep (CursorLocation n) :: Type -> Type #

NFData n => NFData (CursorLocation n) 
Instance details

Defined in Brick.Types.Internal

Methods

rnf :: CursorLocation n -> () #

type Rep (CursorLocation n) 
Instance details

Defined in Brick.Types.Internal

type Rep (CursorLocation n) = D1 ('MetaData "CursorLocation" "Brick.Types.Internal" "brick-0.62-1e79edf9d5b0299388734a25939a48645b839d61d7654ecff0a3eb424ccc31a7" 'False) (C1 ('MetaCons "CursorLocation" 'PrefixI 'True) (S1 ('MetaSel ('Just "cursorLocation") 'NoSourceUnpackedness 'SourceStrict 'DecidedUnpack) (Rec0 Location) :*: S1 ('MetaSel ('Just "cursorLocationName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (Maybe n))))

data BorderSegment #

A border character has four segments, one extending in each direction (horizontally and vertically) from the center of the character.

Constructors

BorderSegment 

Fields

  • bsAccept :: Bool

    Would this segment be willing to be drawn if a neighbor wanted to connect to it?

  • bsOffer :: Bool

    Does this segment want to connect to its neighbor?

  • bsDraw :: Bool

    Should this segment be represented visually?

Instances

Instances details
Eq BorderSegment 
Instance details

Defined in Brick.Types.Internal

Ord BorderSegment 
Instance details

Defined in Brick.Types.Internal

Read BorderSegment 
Instance details

Defined in Brick.Types.Internal

Show BorderSegment 
Instance details

Defined in Brick.Types.Internal

Generic BorderSegment 
Instance details

Defined in Brick.Types.Internal

Associated Types

type Rep BorderSegment :: Type -> Type #

NFData BorderSegment 
Instance details

Defined in Brick.Types.Internal

Methods

rnf :: BorderSegment -> () #

type Rep BorderSegment 
Instance details

Defined in Brick.Types.Internal

type Rep BorderSegment = D1 ('MetaData "BorderSegment" "Brick.Types.Internal" "brick-0.62-1e79edf9d5b0299388734a25939a48645b839d61d7654ecff0a3eb424ccc31a7" 'False) (C1 ('MetaCons "BorderSegment" 'PrefixI 'True) (S1 ('MetaSel ('Just "bsAccept") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: (S1 ('MetaSel ('Just "bsOffer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool) :*: S1 ('MetaSel ('Just "bsDraw") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Bool))))

unicodeRounded :: BorderStyle #

A unicode border style with rounded corners.

unicodeBold :: BorderStyle #

A unicode border style in a bold typeface.

unicode :: BorderStyle #

A unicode border style with real corner and intersection characters.

ascii :: BorderStyle #

An ASCII border style which will work in any terminal.

borderStyleFromChar :: Char -> BorderStyle #

Make a border style using the specified character everywhere.

data BorderStyle #

A border style for use in any widget that needs to render borders in a consistent style.

Constructors

BorderStyle 

Fields

Instances

Instances details
Eq BorderStyle 
Instance details

Defined in Brick.Widgets.Border.Style

Read BorderStyle 
Instance details

Defined in Brick.Widgets.Border.Style

Show BorderStyle 
Instance details

Defined in Brick.Widgets.Border.Style

Generic BorderStyle 
Instance details

Defined in Brick.Widgets.Border.Style

Associated Types

type Rep BorderStyle :: Type -> Type #

NFData BorderStyle 
Instance details

Defined in Brick.Widgets.Border.Style

Methods

rnf :: BorderStyle -> () #

type Rep BorderStyle 
Instance details

Defined in Brick.Widgets.Border.Style

eTopL :: Lens' (Edges a) a #

eRightL :: Lens' (Edges a) a #

eLeftL :: Lens' (Edges a) a #

data Edges a #

Constructors

Edges 

Fields

Instances

Instances details
Monad Edges 
Instance details

Defined in Brick.Types.Common

Methods

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

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

return :: a -> Edges a #

Functor Edges 
Instance details

Defined in Brick.Types.Common

Methods

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

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

Applicative Edges 
Instance details

Defined in Brick.Types.Common

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) 
Instance details

Defined in Brick.Types.Common

Methods

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

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

Ord a => Ord (Edges a) 
Instance details

Defined in Brick.Types.Common

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) 
Instance details

Defined in Brick.Types.Common

Show a => Show (Edges a) 
Instance details

Defined in Brick.Types.Common

Methods

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

show :: Edges a -> String #

showList :: [Edges a] -> ShowS #

Generic (Edges a) 
Instance details

Defined in Brick.Types.Common

Associated Types

type Rep (Edges a) :: Type -> Type #

Methods

from :: Edges a -> Rep (Edges a) x #

to :: Rep (Edges a) x -> Edges a #

NFData a => NFData (Edges a) 
Instance details

Defined in Brick.Types.Common

Methods

rnf :: Edges a -> () #

type Rep (Edges a) 
Instance details

Defined in Brick.Types.Common

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

data Location #

A terminal screen location.

Constructors

Location 

Fields

Instances

Instances details
Eq Location 
Instance details

Defined in Brick.Types.Common

Ord Location 
Instance details

Defined in Brick.Types.Common

Read Location 
Instance details

Defined in Brick.Types.Common

Show Location 
Instance details

Defined in Brick.Types.Common

Generic Location 
Instance details

Defined in Brick.Types.Common

Associated Types

type Rep Location :: Type -> Type #

Methods

from :: Location -> Rep Location x #

to :: Rep Location x -> Location #

Semigroup Location 
Instance details

Defined in Brick.Types.Common

Monoid Location 
Instance details

Defined in Brick.Types.Common

TerminalLocation Location 
Instance details

Defined in Brick.Types.Internal

NFData Location 
Instance details

Defined in Brick.Types.Common

Methods

rnf :: Location -> () #

Field1 Location Location Int Int 
Instance details

Defined in Brick.Types.Common

Field2 Location Location Int Int 
Instance details

Defined in Brick.Types.Common

type Rep Location 
Instance details

Defined in Brick.Types.Common

type Rep Location = D1 ('MetaData "Location" "Brick.Types.Common" "brick-0.62-1e79edf9d5b0299388734a25939a48645b839d61d7654ecff0a3eb424ccc31a7" 'False) (C1 ('MetaCons "Location" 'PrefixI 'True) (S1 ('MetaSel ('Just "loc") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Int, Int))))

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.

writeBChan :: BChan a -> a -> IO () #

Writes a value to a BChan; blocks if the channel is full.

newBChan #

Arguments

:: Int

maximum number of elements the channel can hold

-> IO (BChan a) 

Builds and returns a new instance of BChan.

data BChan a #

BChan is an abstract type representing a bounded FIFO channel.

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.

attrMap #

Arguments

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

attrName :: String -> AttrName #

Create an attribute name from a string.

data AttrName #

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 details
Eq AttrName 
Instance details

Defined in Brick.AttrMap

Ord AttrName 
Instance details

Defined in Brick.AttrMap

Read AttrName 
Instance details

Defined in Brick.AttrMap

Show AttrName 
Instance details

Defined in Brick.AttrMap

IsString AttrName 
Instance details

Defined in Brick.AttrMap

Generic AttrName 
Instance details

Defined in Brick.AttrMap

Associated Types

type Rep AttrName :: Type -> Type #

Methods

from :: AttrName -> Rep AttrName x #

to :: Rep AttrName x -> AttrName #

Semigroup AttrName 
Instance details

Defined in Brick.AttrMap

Monoid AttrName 
Instance details

Defined in Brick.AttrMap

GetAttr AttrName 
Instance details

Defined in Brick.Markup

Methods

getAttr :: AttrName -> RenderM n Attr #

NFData AttrName 
Instance details

Defined in Brick.AttrMap

Methods

rnf :: AttrName -> () #

type Rep AttrName 
Instance details

Defined in Brick.AttrMap

type Rep AttrName = D1 ('MetaData "AttrName" "Brick.AttrMap" "brick-0.62-1e79edf9d5b0299388734a25939a48645b839d61d7654ecff0a3eb424ccc31a7" 'False) (C1 ('MetaCons "AttrName" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [String])))

data AttrMap #

An attribute map which maps AttrName values to Attr values.

Instances

Instances details
Show AttrMap 
Instance details

Defined in Brick.AttrMap

Generic AttrMap 
Instance details

Defined in Brick.AttrMap

Associated Types

type Rep AttrMap :: Type -> Type #

Methods

from :: AttrMap -> Rep AttrMap x #

to :: Rep AttrMap x -> AttrMap #

NFData AttrMap 
Instance details

Defined in Brick.AttrMap

Methods

rnf :: AttrMap -> () #

type Rep AttrMap 
Instance details

Defined in Brick.AttrMap

type Rep AttrMap = D1 ('MetaData "AttrMap" "Brick.AttrMap" "brick-0.62-1e79edf9d5b0299388734a25939a48645b839d61d7654ecff0a3eb424ccc31a7" '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)))

(^.) :: s -> Getting a s a -> a infixl 8 #

(^.) applies a getter to a value; in other words, it gets a value out of a structure using a getter (which can be a lens, traversal, fold, etc.).

Getting 1st field of a tuple:

(^. _1) :: (a, b) -> a
(^. _1) = fst

When (^.) is used with a traversal, it combines all results using the Monoid instance for the resulting type. For instance, for lists it would be simple concatenation:

>>> ("str","ing") ^. each
"string"

The reason for this is that traversals use Applicative, and the Applicative instance for Const uses monoid concatenation to combine “effects” of Const.

A non-operator version of (^.) is called view, and it's a bit more general than (^.) (it works in MonadReader). If you need the general version, you can get it from microlens-mtl; otherwise there's view available in Lens.Micro.Extras.

(?~) :: ASetter s t a (Maybe b) -> b -> s -> t infixr 4 #

(?~) is a version of (.~) that wraps the value into Just before setting.

l ?~ b = l .~ Just b

It can be useful in combination with at:

>>> Map.empty & at 3 ?~ x
fromList [(3,x)]

set :: ASetter s t a b -> b -> s -> t #

set is a synonym for (.~).

Setting the 1st component of a pair:

set _1 :: x -> (a, b) -> (x, b)
set _1 = \x t -> (x, snd t)

Using it to rewrite (<$):

set mapped :: Functor f => a -> f b -> f a
set mapped = (<$)

(.~) :: ASetter s t a b -> b -> s -> t infixr 4 #

(.~) assigns a value to the target. It's the same thing as using (%~) with const:

l .~ x = l %~ const x

See set if you want a non-operator synonym.

Here it is used to change 2 fields of a 3-tuple:

>>> (0,0,0) & _1 .~ 1 & _3 .~ 3
(1,0,3)

over :: ASetter s t a b -> (a -> b) -> s -> t #

over is a synonym for (%~).

Getting fmap in a roundabout way:

over mapped :: Functor f => (a -> b) -> f a -> f b
over mapped = fmap

Applying a function to both components of a pair:

over both :: (a -> b) -> (a, a) -> (b, b)
over both = \f t -> (f (fst t), f (snd t))

Using over _2 as a replacement for second:

>>> over _2 show (10,20)
(10,"20")

(%~) :: ASetter s t a b -> (a -> b) -> s -> t infixr 4 #

(%~) applies a function to the target; an alternative explanation is that it is an inverse of sets, which turns a setter into an ordinary function. mapped %~ reverse is the same thing as fmap reverse.

See over if you want a non-operator synonym.

Negating the 1st element of a pair:

>>> (1,2) & _1 %~ negate
(-1,2)

Turning all Lefts in a list to upper case:

>>> (mapped._Left.mapped %~ toUpper) [Left "foo", Right "bar"]
[Left "FOO",Right "bar"]

_1 :: Field1 s t a b => Lens s t a b #

Gives access to the 1st field of a tuple (up to 5-tuples).

Getting the 1st component:

>>> (1,2,3,4,5) ^. _1
1

Setting the 1st component:

>>> (1,2,3) & _1 .~ 10
(10,2,3)

Note that this lens is lazy, and can set fields even of undefined:

>>> set _1 10 undefined :: (Int, Int)
(10,*** Exception: Prelude.undefined

This is done to avoid violating a lens law stating that you can get back what you put:

>>> view _1 . set _1 10 $ (undefined :: (Int, Int))
10

The implementation (for 2-tuples) is:

_1 f t = (,) <$> f    (fst t)
             <*> pure (snd t)

or, alternatively,

_1 f ~(a,b) = (\a' -> (a',b)) <$> f a

(where ~ means a lazy pattern).

_2, _3, _4, and _5 are also available (see below).

_2 :: Field2 s t a b => Lens s t a b #

_3 :: Field3 s t a b => Lens s t a b #

type ASetter' s a = ASetter s s a a #

This is a type alias for monomorphic setters which don't change the type of the container (or of the value inside). It's useful more often than the same type in lens, because we can't provide real setters and so it does the job of both ASetter' and Setter'.

makeLenses :: Name -> DecsQ #

Generate lenses for a data type or a newtype.

To use it, you have to enable Template Haskell first:

{-# LANGUAGE TemplateHaskell #-}

Then, after declaring the datatype (let's say Foo), add makeLenses ''Foo on a separate line (if you do it before the type is declared, you'll get a “not in scope” error – see the section at the top of this page):

data Foo = Foo {
  _x :: Int,
  _y :: Bool }

makeLenses ''Foo

This would generate the following lenses, which can be used to access the fields of Foo:

x :: Lens' Foo Int
x f foo = (\x' -> foo {_x = x'}) <$> f (_x foo)

y :: Lens' Foo Bool
y f foo = (\y' -> foo {_y = y'}) <$> f (_y foo)

(If you don't want a lens to be generated for some field, don't prefix it with “_”.)

If you want to create lenses for many types, you can do it all in one place like this (of course, instead you just can use makeLenses several times if you feel it would be more readable):

data Foo = ...
data Bar = ...
data Quux = ...

concat <$> mapM makeLenses [''Foo, ''Bar, ''Quux]

When the data type has type parameters, it's possible for a lens to do a polymorphic update – i.e. change the type of the thing along with changing the type of the field. For instance, with this type

data Foo a = Foo {
  _x :: a,
  _y :: Bool }

the following lenses would be generated:

x :: Lens (Foo a) (Foo b) a b
y :: Lens' (Foo a) Bool

However, when there are several fields using the same type parameter, type-changing updates are no longer possible:

data Foo a = Foo {
  _x :: a,
  _y :: a }

generates

x :: Lens' (Foo a) a
y :: Lens' (Foo a) a

Finally, when the type has several constructors, some of fields may not be always present – for those, a Traversal is generated instead. For instance, in this example y can be present or absent:

data FooBar
  = Foo { _x :: Int, _y :: Bool }
  | Bar { _x :: Int }

and the following accessors would be generated:

x :: Lens' FooBar Int
y :: Traversal' FooBar Bool

So, to get _y, you'd have to either use (^?) if you're not sure it's there, or (^?!) if you're absolutely sure (and if you're wrong, you'll get an exception). Setting and updating _y can be done as usual.

mkVty :: Config -> IO Vty #

Create a Vty handle. At most one handle should be created at a time for a given terminal device.

The specified configuration is added to the the configuration loaded by userConfig with the userConfig configuration taking precedence. See Graphics.Vty.Config.

For most applications mkVty defaultConfig is sufficient.

standardIOConfig :: IO Config #

Configures VTY using defaults suitable for terminals. This function can raise VtyConfigurationError.

data Key #

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.

Instances

Instances details
Eq Key 
Instance details

Defined in Graphics.Vty.Input.Events

Methods

(==) :: Key -> Key -> Bool #

(/=) :: Key -> Key -> Bool #

Ord Key 
Instance details

Defined in Graphics.Vty.Input.Events

Methods

compare :: Key -> Key -> Ordering #

(<) :: Key -> Key -> Bool #

(<=) :: Key -> Key -> Bool #

(>) :: Key -> Key -> Bool #

(>=) :: Key -> Key -> Bool #

max :: Key -> Key -> Key #

min :: Key -> Key -> Key #

Read Key 
Instance details

Defined in Graphics.Vty.Input.Events

Show Key 
Instance details

Defined in Graphics.Vty.Input.Events

Methods

showsPrec :: Int -> Key -> ShowS #

show :: Key -> String #

showList :: [Key] -> ShowS #

Generic Key 
Instance details

Defined in Graphics.Vty.Input.Events

Associated Types

type Rep Key :: Type -> Type #

Methods

from :: Key -> Rep Key x #

to :: Rep Key x -> Key #

Parse Key 
Instance details

Defined in Graphics.Vty.Config

Methods

parseValue :: Parser Key

type Rep Key 
Instance details

Defined in Graphics.Vty.Input.Events

type Rep Key = D1 ('MetaData "Key" "Graphics.Vty.Input.Events" "vty-5.33-d400eec211b41e58acc410b10d79ca4624828bcbf5f0eb291b0c1dd87f602843" 'False) ((((C1 ('MetaCons "KEsc" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "KChar" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Char)) :+: C1 ('MetaCons "KBS" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "KEnter" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "KLeft" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "KRight" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "KUp" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "KDown" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "KUpLeft" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "KUpRight" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "KDownLeft" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "KDownRight" 'PrefixI 'False) (U1 :: Type -> Type))))) :+: (((C1 ('MetaCons "KCenter" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "KFun" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :+: C1 ('MetaCons "KBackTab" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "KPrtScr" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "KPause" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "KIns" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "KHome" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "KPageUp" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "KDel" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "KEnd" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "KPageDown" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "KBegin" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "KMenu" 'PrefixI 'False) (U1 :: Type -> Type))))))

data Modifier #

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.

Constructors

MShift 
MCtrl 
MMeta 
MAlt 

Instances

Instances details
Eq Modifier 
Instance details

Defined in Graphics.Vty.Input.Events

Ord Modifier 
Instance details

Defined in Graphics.Vty.Input.Events

Read Modifier 
Instance details

Defined in Graphics.Vty.Input.Events

Show Modifier 
Instance details

Defined in Graphics.Vty.Input.Events

Generic Modifier 
Instance details

Defined in Graphics.Vty.Input.Events

Associated Types

type Rep Modifier :: Type -> Type #

Methods

from :: Modifier -> Rep Modifier x #

to :: Rep Modifier x -> Modifier #

Parse Modifier 
Instance details

Defined in Graphics.Vty.Config

Methods

parseValue :: Parser Modifier

type Rep Modifier 
Instance details

Defined in Graphics.Vty.Input.Events

type Rep Modifier = D1 ('MetaData "Modifier" "Graphics.Vty.Input.Events" "vty-5.33-d400eec211b41e58acc410b10d79ca4624828bcbf5f0eb291b0c1dd87f602843" '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)))

data Button #

Mouse buttons.

Instances

Instances details
Eq Button 
Instance details

Defined in Graphics.Vty.Input.Events

Methods

(==) :: Button -> Button -> Bool #

(/=) :: Button -> Button -> Bool #

Ord Button 
Instance details

Defined in Graphics.Vty.Input.Events

Read Button 
Instance details

Defined in Graphics.Vty.Input.Events

Show Button 
Instance details

Defined in Graphics.Vty.Input.Events

Generic Button 
Instance details

Defined in Graphics.Vty.Input.Events

Associated Types

type Rep Button :: Type -> Type #

Methods

from :: Button -> Rep Button x #

to :: Rep Button x -> Button #

type Rep Button 
Instance details

Defined in Graphics.Vty.Input.Events

type Rep Button = D1 ('MetaData "Button" "Graphics.Vty.Input.Events" "vty-5.33-d400eec211b41e58acc410b10d79ca4624828bcbf5f0eb291b0c1dd87f602843" 'False) ((C1 ('MetaCons "BLeft" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BMiddle" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "BRight" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "BScrollUp" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "BScrollDown" 'PrefixI 'False) (U1 :: Type -> Type))))

defAttr :: Attr #

Sets the style, background color and foreground color to the default values for the terminal. There is no easy way to determine what the default background and foreground colors are.

withStyle :: Attr -> Style -> Attr #

Add the given style attribute

bold :: Style #

Valid style attributes include:

  • standout
  • underline
  • reverseVideo
  • blink
  • dim
  • bold/bright
  • italic
  • strikethrough (via the smxx/rmxx terminfo capabilities)

(The invisible, protect, and altcharset display attributes some terminals support are not supported via VTY.)