brick-0.2.1: A declarative terminal user interface library

Safe HaskellNone
LanguageHaskell2010

Brick.Widgets.Dialog

Contents

Description

This module provides a simple dialog widget. You get to pick the dialog title, if any, as well as its body and buttons.

Synopsis

Documentation

data Dialog a Source

Dialogs present a window with a title (optional), a body, and buttons (optional). They provide a HandleEvent instance that knows about Tab and Shift-Tab for changing which button is active. Dialog buttons are labeled with strings and map to values of type a, which you choose.

Dialogs handle the following events by default:

  • Tab: selecte the next button
  • Shift-tab: select the previous button

Instances

dialogTitle :: Dialog a -> Maybe String Source

The dialog title

dialogName :: Dialog a -> Name Source

The dialog name

dialogButtons :: Dialog a -> [(String, a)] Source

The dialog button labels and values

dialogSelectedIndex :: Dialog a -> Maybe Int Source

The currently selected dialog button index (if any)

dialogWidth :: Dialog a -> Int Source

The maximum width of the dialog

Construction and rendering

dialog Source

Arguments

:: Name

The dialog name, provided so that you can use this as a basis for viewport names in the dialog if desired

-> Maybe String

The dialog title

-> Maybe (Int, [(String, a)])

The currently-selected button index (starting at zero) and the button labels and values to use

-> Int

The maximum width of the dialog

-> Dialog a 

Create a dialog.

renderDialog :: Dialog a -> Widget -> Widget Source

Render a dialog with the specified body widget.

Getting a dialog's current value

dialogSelection :: Dialog a -> Maybe a Source

Obtain the value associated with the dialog's currently-selected button, if any. This function is probably what you want when someone presses Enter in a dialog.

Attributes

dialogAttr :: AttrName Source

The default attribute of the dialog

buttonAttr :: AttrName Source

The default attribute for all dialog buttons

buttonSelectedAttr :: AttrName Source

The attribute for the selected dialog button (extends dialogAttr)

Lenses

dialogButtonsL :: forall a a. Lens (Dialog a) (Dialog a) [(String, a)] [(String, a)] Source