Copyright | © Patrick Pelletier 2017 |
---|---|
License | BSD3 |
Maintainer | code@funwithsoftware.org |
Safe Haskell | Safe |
Language | Haskell2010 |
Displays a simple user interface. The first line of the display is used as a "list box", where the user can scroll through a list of items one at a time using the up and down buttons. The second line of the display is used for virtual "buttons", such as "OK" and "Cancel". The user uses the left and right buttons to select a virtual "button". When the user presses the Select button, the interaction is considered done, and the calling program is given the list item and button selection that the user made.
If there is only one item in the list, the up and down buttons won't do anything, and the "↕" indicator will not be displayed. So, if you want to display a static line of text and some buttons, just create a single-element list containing the line of text.
- data UiData = UiData {}
- data UiState = UiState {
- usList :: !Int
- usButtons :: !Int
- usInternal :: !InternalState
- data InternalState
- defaultUiState :: UiState
- runUi :: UiData -> UiState -> Maybe ButtonEvent -> Int -> ([Text], UiState, Bool)
- data Button
- data ButtonDirection
- data ButtonEvent = ButtonEvent Button ButtonDirection
User interface
The data to be displayed in the user interface.
The current state of the user interaction.
UiState | |
|
data InternalState Source #
Opaque data.
defaultUiState :: UiState Source #
Defaults to displaying the first list item (index 0) and highlighting the first button (index 0).
:: UiData | Data to display in the UI |
-> UiState | Current state of the interaction |
-> Maybe ButtonEvent | optional button press/release |
-> Int | Number of columns in the LCD |
-> ([Text], UiState, Bool) | text to display, new UI state, and a flag indicating whether the interaction is done (i. e. user has pressed and released the "Select" button) |
Computes the text which should be displayed for the current state of the UI, and optionally applies a button press/release to the state.
Buttons
Indicates one of the five buttons on the LCD+Keypad kit.
data ButtonDirection Source #
Indicates whether a button was pressed or released.
data ButtonEvent Source #
Indicates a press or release of one of the five buttons on the LCD+Keypad kit.