vty-ui-1.5: An interactive terminal user interface library for Vty

Safe HaskellSafe-Infered

Graphics.Vty.Widgets.Edit

Description

This module provides a text-editing widget. Edit widgets can operate in single- and multi-line modes.

Edit widgets support the following special keystrokes:

  • Arrow keys to navigate the text
  • Enter - Activate single-line edit widgets or insert new lines into multi-line widgets
  • Home / Control-a - Go to beginning of the current line
  • End / Control-e - Go to end of the current line
  • Control-k - Remove text from the cursor to the end of the line, or remove the line if it is empty
  • Del / Control-d - delete the current character
  • Backspace - delete the previous character

Synopsis

Documentation

data Edit Source

Instances

editWidget :: IO (Widget Edit)Source

Construct a text widget for editing a single line of text. Single-line edit widgets will send activation events when the user presses Enter (see onActivate).

multiLineEditWidget :: IO (Widget Edit)Source

Construct a text widget for editing multi-line documents. Multi-line edit widgets never send activation events, since the Enter key inserts a new line at the cursor position.

getEditText :: Widget Edit -> IO StringSource

Get the current contents of the edit widget. This returns all of the lines of text in the widget, separated by newlines.

getEditCurrentLine :: Widget Edit -> IO StringSource

Get the contents of the current line of the edit widget (the line on which the cursor is positioned).

setEditText :: Widget Edit -> String -> IO ()Source

Set the contents of the edit widget. Newlines will be used to break up the text in multiline widgets. If the edit widget has a line limit, only those lines within the limit will be set.

setEditCursorPosition :: Widget Edit -> (Int, Int) -> IO ()Source

Set the current edit widget cursor position. The tuple is (row, column) with each starting at zero. Invalid cursor positions will be ignored.

getEditCursorPosition :: Widget Edit -> IO (Int, Int)Source

Get the edit widget's current cursor position (row, column).

setEditLineLimit :: Widget Edit -> Maybe Int -> IO ()Source

Set the limit on the number of lines for the edit widget. Nothing indicates no limit, while Just indicates a limit of the specified number of lines.

getEditLineLimit :: Widget Edit -> IO (Maybe Int)Source

Get the current line limit, if any, for the edit widget.

onActivate :: Widget Edit -> (Widget Edit -> IO ()) -> IO ()Source

Register handlers to be invoked when the edit widget has been ''activated'' (when the user presses Enter while the widget is focused). These handlers will only be invoked when a single-line edit widget is activated; multi-line widgets never generate these events.

onChange :: Widget Edit -> (String -> IO ()) -> IO ()Source

Register handlers to be invoked when the edit widget's contents change. Handlers will be passed the new contents.

onCursorMove :: Widget Edit -> ((Int, Int) -> IO ()) -> IO ()Source

Register handlers to be invoked when the edit widget's cursor position changes. Handlers will be passed the new cursor position, relative to the beginning of the string (position 0).