HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulebrick-2.10Haskell2010

Brick.Widgets.Edit

This module provides a basic text editor widget. You'll need to embed an Editor in your application state and transform it with handleEditorEvent when relevant events arrive. To get the contents of the editor, just use getEditContents. To modify it, use the TextZipper interface with applyEdit.

The editor's handleEditorEvent function handles a set of basic input events that should suffice for most purposes; see the source for a complete list.

Bear in mind that the editor provided by this module is intended to provide basic input support for brick applications but it is not intended to be a replacement for your favorite editor such as Vim or Emacs. It is also not suitable for building sophisticated editors. If you want to build your own editor, I suggest starting from scratch.

  • 1 type
  • 1 class
  • 12 values
  • Packagebrick-2.10
  • Exports14
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceEdit.hs
datadata Editor t n
#

Editor state. Editors support the following events by default:

  • Mouse clicks: change cursor position

  • Meta-<: go to beginning of file

  • Meta->: go to end of file

  • Ctrl-a, Home: go to beginning of line

  • Ctrl-e, End: go to end of line

  • Ctrl-d, Del: delete character at cursor position

  • Meta-d: delete word at cursor position

  • Backspace: delete character prior to cursor position

  • Ctrl-k: delete all from cursor to end of line

  • Ctrl-u: delete all from cursor to beginning of line

  • Ctrl-t: transpose character before cursor with the one at cursor position

  • Meta-b: move one word to the left

  • Ctrl-b: move one character to the left

  • Meta-f: move one word to the right

  • Ctrl-f: move one character to the right

  • Arrow keys: move cursor

  • Enter: break the current line at the cursor position

  • Paste: Bracketed Pastes from the terminal will be pasted, provided the incoming data is UTF-8-encoded.

Instances2Show, Named

Constructing an editor

2 declarations
valueeditor
  1. :: GenericTextZipper a
  2. => n

    The editor's name (must be unique)

  3. -> Maybe Int

    The limit on the number of lines in the editor (Nothing means no limit)

  4. -> a

    The initial content

  5. -> Editor a n
#

Construct an editor over generic text values

valueeditorText
  1. :: n

    The editor's name (must be unique)

  2. -> Maybe Int

    The limit on the number of lines in the editor (Nothing means no limit)

  3. -> Text

    The initial content

  4. -> Editor Text n
#

Construct an editor over Text values

Reading editor contents

2 declarations

Handling events

1 declaration

Editing text

1 declaration
valueapplyEdit
  1. :: (TextZipper t -> TextZipper t)

    The TextZipper editing transformation to apply

  2. -> Editor t n
  3. -> Editor t n
#

Apply an editing operation to the editor's contents.

This is subject to the restrictions of the underlying text zipper; for example, if the underlying zipper has a line limit configured, any edits applied here will be ignored if they edit text outside the line limit.

Lenses for working with editors

1 declaration

Rendering editors

1 declaration
valuerenderEditor
  1. :: (Ord n, Show n, Monoid t, TextWidth t, GenericTextZipper t)
  2. => ([t] -> Widget n)

    The content drawing function

  3. -> Bool

    Whether the editor has focus. It will report a cursor position if and only if it has focus.

  4. -> Editor t n

    The editor.

  5. -> Widget n
#

Turn an editor state value into a widget. This uses the editor's name for its scrollable viewport handle and the name is also used to report mouse events.

Attributes

2 declarations
valueeditAttr :: AttrName
#

The attribute assigned to the editor when it does not have focus.

UTF-8 decoding of editor pastes

1 declaration
classclass DecodeUtf8 t where
#

Values that can be constructed by decoding bytestrings in UTF-8 encoding.

Methods

Instances2DecodeUtf8