vty-ui-0.1: A user interface composition library for VtySource codeContentsIndex
Graphics.Vty.Widgets.List
Description

This module provides a List widget for rendering a list of single-line strings. 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

To create a list, see mkList. To modify the list's state, see scrollDown and scrollUp. To inspect the list, see, see getSelected and getVisibleItems.

Synopsis
data List
mkList :: Attr -> Attr -> Int -> [String] -> List
scrollDown :: List -> List
scrollUp :: List -> List
getSelected :: List -> String
getVisibleItems :: List -> [(String, Bool)]
Documentation
data List Source
The list widget type.
show/hide Instances
mkListSource
:: 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
-> List
Create a new list. Emtpy lists are not allowed.
scrollDown :: List -> ListSource

Scroll a list down one position and return the new scrolled list. This automatically takes care of managing all list state:

  • Moves the cursor down one position, unless the cursor is already in the last position (in which case this does nothing)
  • Moves the scrolling window position if necessary (i.e., if the cursor moves to an item not currently in view)
scrollUp :: List -> ListSource

Scroll a list up one position and return the new scrolled list. This automatically takes care of managing all list state:

  • Moves the cursor up one position, unless the cursor is already in the first position (in which case this does nothing)
  • Moves the scrolling window position if necessary (i.e., if the cursor moves to an item not currently in view)
getSelected :: List -> StringSource
Get the currently selected list item.
getVisibleItems :: List -> [(String, 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