vty-ui-0.2: A user interface composition library for VtySource codeContentsIndex
Graphics.Vty.Widgets.List
Contents
List creation
List manipulation
List inspection
Description

This module provides a List widget for rendering a list of arbitrary widgets. A List has the following features:

  • A style for the list elements
  • A styled cursor indicating which element is selected
  • A window size indicating how many elements should be visible to the user
  • An internal pointer to the start of the visible window, which automatically shifts as the list is scrolled
Synopsis
data List a b
type SimpleList = List String Text
type ListItem a b = (a, b)
mkList :: Widget b => Attr -> Attr -> Int -> [ListItem a b] -> List a b
mkSimpleList :: Attr -> Attr -> Int -> [String] -> SimpleList
scrollBy :: Int -> List a b -> List a b
scrollUp :: List a b -> List a b
scrollDown :: List a b -> List a b
pageUp :: List a b -> List a b
pageDown :: List a b -> List a b
resize :: Int -> List a b -> List a b
listItems :: List a b -> [ListItem a b]
getSelected :: List a b -> ListItem a b
selectedIndex :: List a b -> Int
scrollTopIndex :: List a b -> Int
scrollWindowSize :: List a b -> Int
getVisibleItems :: List a b -> [(ListItem a b, Bool)]
Documentation
data List a b Source
The list widget type. Lists are parameterized over the internal identifier type a, the type of internal identifiers used to refer to the visible representations of the list contents, and the widget type b, the type of widgets used to represent the list visually.
show/hide Instances
Widget b => Widget (List a b)
type SimpleList = List String TextSource
type ListItem a b = (a, b)Source
A list item. Each item contains an arbitrary internal identifier a and a widget b representing it.
List creation
mkListSource
:: Widget b
=> AttrThe attribute of normal, non-selected items
-> AttrThe attribute of the selected item
-> IntThe scrolling window size, i.e., the number of items which should be visible to the user at any given time
-> [ListItem a b]The list items
-> List a b
Create a new list. Emtpy lists and empty scrolling windows are not allowed.
mkSimpleListSource
:: AttrThe attribute of normal, non-selected items
-> AttrThe attribute of the selected item
-> IntThe scrolling window size, i.e., the number of items which should be visible to the user at any given time
-> [String]The list items
-> SimpleList
A convenience function to create a new list using Strings as the internal identifiers and Text widgets to represent those strings.
List manipulation
scrollBy :: Int -> List a b -> List a bSource

Scroll a list up or down by the specified number of positions and return the new scrolled list. Scrolling by a positive amount scrolls downward and scrolling by a negative amount scrolls upward. This automatically takes care of managing internal list state:

  • Moves the cursor by the specified amount and clamps the cursor position to the beginning or the end of the list where appropriate
  • Moves the scrolling window position if necessary (i.e., if the cursor moves to an item not currently in view)
scrollUp :: List a b -> List a bSource
Scroll a list up by one position.
scrollDown :: List a b -> List a bSource
Scroll a list down by one position.
pageUp :: List a b -> List a bSource
Scroll a list up by one page from the current cursor position.
pageDown :: List a b -> List a bSource
Scroll a list down by one page from the current cursor position.
resize :: Int -> List a b -> List a bSource
Set the window size of the list. This automatically adjusts the window position to keep the selected item visible.
List inspection
listItems :: List a b -> [ListItem a b]Source
The items in the list.
getSelected :: List a b -> ListItem a bSource
Get the currently selected list item.
selectedIndex :: List a b -> IntSource
The currently selected list index.
scrollTopIndex :: List a b -> IntSource
The start index of the window of visible list items.
scrollWindowSize :: List a b -> IntSource
The size of the window of visible list items.
getVisibleItems :: List a b -> [(ListItem a b, Bool)]Source
Given a List, return the items that are currently visible according to the state of the list. Returns the visible items and flags indicating whether each is selected.
Produced by Haddock version 2.4.2