vty-ui-1.4: An interactive terminal user interface library for Vty




This module provides ''check box'' widgets and ''radio button'' widgets. In addition, this module provides a generalized ''multi-state'' check box type which allows you to set multiple states in the checkbox, each with its own character representation.

All of these types of widgets are toggled with the Spacebar and Enter keys.



data CheckBox a Source


Show a => Show (CheckBox a) 

type RadioGroup = IORef RadioGroupDataSource

Traditional binary-mode checkboxes

newCheckbox :: String -> IO (Widget (CheckBox Bool))Source

Create a new checkbox with the specified text label.

setCheckboxUnchecked :: Widget (CheckBox Bool) -> IO ()Source

Set a binary checkbox to unchecked.

setCheckboxChecked :: Widget (CheckBox Bool) -> IO ()Source

Set a binary checkbox to checked.

toggleCheckbox :: Widget (CheckBox Bool) -> IO ()Source

Toggle a binary checkbox.

Event handler registration

onCheckboxChange :: Widget (CheckBox a) -> (a -> IO ()) -> IO ()Source

Register a handler for a checkbox state change. The handler will be passed the new state value.

Generalized checkbox functions



:: Eq a 
=> String

The checkbox label.

-> [(a, Char)]

The list of valid states that the checkbox can be in, along with the visual representation (Char) for each state.

-> IO (Widget (CheckBox a)) 

Create a new multi-state checkbox.

setCheckboxState :: Eq a => Widget (CheckBox a) -> a -> IO ()Source

Set the state of a checkbox. May throw BadCheckboxState.

cycleCheckbox :: Eq a => Widget (CheckBox a) -> IO ()Source

Cycle a checkbox's state to the next value in its state list.

setStateChar :: Eq a => Widget (CheckBox a) -> a -> Char -> IO ()Source

Set the visual representation for a state in a checkbox. May throw BadStateArgument.

setBracketChars :: Widget (CheckBox a) -> Char -> Char -> IO ()Source

Set the checkbox's bracketing characters for the left and right brackets around the state character.

getCheckboxLabel :: Widget (CheckBox a) -> IO StringSource

Get a checkbox's text label.

getCheckboxState :: Widget (CheckBox a) -> IO aSource

Get a checkbox's current state value.

Radio groups

newRadioGroup :: IO RadioGroupSource

Create a new radio button group. This is used to guarantee exclusivity among the check boxes in the group so that they behave like radio buttons.

onRadioChange :: RadioGroup -> (Widget (CheckBox Bool) -> IO ()) -> IO ()Source

Register a handler to be notified when the currently-selected check box in a radio group changes.

addToRadioGroup :: RadioGroup -> Widget (CheckBox Bool) -> IO ()Source

Add a check box to a radio group. The check box's apperance will be changed so that it resembles a radio button.

getCurrentRadio :: RadioGroup -> IO (Maybe (Widget (CheckBox Bool)))Source

Get the currently-selected checkbox in a radio group, if any.