brick-0.20.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). 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 #

Arguments

:: 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.

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 #

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