brick-0.6.3: A declarative terminal user interface library

Safe HaskellNone
LanguageHaskell2010

Brick.Widgets.List

Contents

Description

This module provides a scrollable list type and functions for manipulating and rendering it.

Synopsis

Documentation

data List e Source #

List state. Lists have an element type e that is the data stored by the list. 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

Instances

Functor List Source # 

Methods

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

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

Foldable List Source # 

Methods

fold :: Monoid m => List m -> m #

foldMap :: Monoid m => (a -> m) -> List a -> m #

foldr :: (a -> b -> b) -> b -> List a -> b #

foldr' :: (a -> b -> b) -> b -> List a -> b #

foldl :: (b -> a -> b) -> b -> List a -> b #

foldl' :: (b -> a -> b) -> b -> List a -> b #

foldr1 :: (a -> a -> a) -> List a -> a #

foldl1 :: (a -> a -> a) -> List a -> a #

toList :: List a -> [a] #

null :: List a -> Bool #

length :: List a -> Int #

elem :: Eq a => a -> List a -> Bool #

maximum :: Ord a => List a -> a #

minimum :: Ord a => List a -> a #

sum :: Num a => List a -> a #

product :: Num a => List a -> a #

Traversable List Source # 

Methods

traverse :: Applicative f => (a -> f b) -> List a -> f (List b) #

sequenceA :: Applicative f => List (f a) -> f (List a) #

mapM :: Monad m => (a -> m b) -> List a -> m (List b) #

sequence :: Monad m => List (m a) -> m (List a) #

HandleEvent (List e) Source # 

Methods

handleEvent :: Event -> List e -> EventM (List e) Source #

Constructing a list

list Source #

Arguments

:: Name

The list name (must be unique)

-> Vector e

The initial list contents

-> Int

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

-> List e 

Construct a list in terms of an element type e.

Rendering a list

renderList Source #

Arguments

:: List e

The List to be rendered

-> (Bool -> e -> Widget)

Rendering function, True for the selected element

-> Widget

rendered widget

Turn a list state value into a widget given an item drawing function.

Lenses

listElementsL :: forall e e. Lens (List e) (List e) (Vector e) (Vector e) Source #

listSelectedL :: forall e. Lens' (List e) (Maybe Int) Source #

listNameL :: forall e. Lens' (List e) Name Source #

Manipulating a list

listMoveBy :: Int -> List e -> List e Source #

Move the list selected index by the specified amount, subject to validation.

listMoveTo :: Int -> List e -> List e Source #

Set the selected index for a list to the specified index, subject to validation.

listMoveUp :: List e -> List e Source #

Move the list selected index up by one. (Moves the cursor up, subtracts one from the index.)

listMoveDown :: List e -> List e Source #

Move the list selected index down by one. (Moves the cursor down, adds one to the index.)

listInsert Source #

Arguments

:: Int

The position at which to insert (0 <= i <= size)

-> e

The element to insert

-> List e 
-> List e 

Insert an item into a list at the specified position.

listRemove Source #

Arguments

:: Int

The position at which to remove an element (0 <= i < size)

-> List e 
-> List e 

Remove an element from a list at the specified position.

listReplace :: Vector e -> Maybe Int -> List e -> List e Source #

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

listSelectedElement :: List e -> Maybe (Int, e) Source #

Return a list's selected element, if any.

listClear :: List e -> List e Source #

Remove all elements from the list and clear the selection.

listReverse :: List e -> List e Source #

Reverse the list. The element selected before the reversal will again be the selected one.

Attributes

listAttr :: AttrName Source #

The top-level attribute used for the entire list.

listSelectedAttr :: AttrName Source #

The attribute used only for the currently-selected list item. Extends listAttr.