brick-0.33: A declarative terminal user interface library

Safe HaskellNone




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

Note that this dialog is really for simple use cases where you want to get the user's answer to a question, such as "Would you like to save changes before quitting?" If you require something more sophisticated, you'll need to build it yourself. You might also consider seeing the Forms module for help with input management, and see the implementation of this module to see how to reproduce a dialog-style UI.



data Dialog a Source #

Dialogs present a window with a title (optional), a body, and buttons (optional). Dialog buttons are labeled with strings and map to values of type a, which you choose.

Dialogs handle the following events by default with handleDialogEvent:

  • Tab or Right Arrow: select the next button
  • Shift-tab or Left Arrow: select the previous button

dialogTitle :: Dialog a -> Maybe String Source #

The dialog title

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 #


:: 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 n -> Widget n Source #

Render a dialog with the specified body widget. This renders the dialog as a layer, which makes this suitable as a top-level layer in your rendering function to be rendered on top of the rest of your interface.

Handling events

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.


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)


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

dialogWidthL :: forall a. Lens' (Dialog a) Int Source #