FabGL
ESP32 Display Controller and Graphics Library
LineEditor Class Reference

LineEditor is a single-line / multiple-rows editor which uses the Terminal object as input and output. More...

#include <terminal.h>

Public Member Functions

 LineEditor (Terminal *terminal)
 Object constructor. More...
 
char const * edit (int maxLength=0)
 Reads user input and return the inserted line. More...
 
char const * get ()
 Gets current content. More...
 
void setInsertMode (bool value)
 Sets insert mode state. More...
 
void setText (char const *text, bool moveCursor=true)
 Sets initial text. More...
 
void setText (char const *text, int length, bool moveCursor=true)
 Sets initial text specifying length. More...
 
void typeText (char const *text)
 Simulates user typing. More...
 

Public Attributes

Delegate< int * > onCarriageReturn
 A delegate called whenever carriage return has been pressed. More...
 
Delegate< int * > onChar
 A delegate called whenever a character has been received. More...
 
Delegate< int * > onRead
 Read character delegate. More...
 
Delegate< LineEditorSpecialCharonSpecialChar
 A delegate called whenever a special character has been pressed. More...
 
Delegate< int > onWrite
 Write character delegate. More...
 

Detailed Description

LineEditor is a single-line / multiple-rows editor which uses the Terminal object as input and output.

The editor supports following control keys:

  • Left and Right Arrow keys: Move cursor left and right, even across rows
  • CTRL + Left and Right Arrow keys: Move cursor at the begining of prevous or next word
  • Home key: Move cursor at the beginning of the line
  • End key: Move cursor at the end of the line
  • Delete key: Delete character at cursor
  • Insert key: Enable/disable insert mode
  • Backspace key: Delete character at left of the cursor
  • Enter/Return: Move cursor at the beginning of the next line and exit editor

Example:

Terminal.write("> ");  // show prompt
LineEditor ed(&Terminal);
char * txt = ed.get();
Terminal.printf("Your input is: %s\r\n", txt);
Examples
SSD1306_OLED/128x64/NetworkTerminal/NetworkTerminal.ino, SSD1306_OLED/128x64/RTClock/RTClock.ino, and VGA/NetworkTerminal/NetworkTerminal.ino.

Definition at line 2043 of file terminal.h.


The documentation for this class was generated from the following files: