FTXUI  5.0.0
C++ functional terminal UI.
Event Struct Reference

Represent an event. It can be key press event, a terminal resize, or more ... More...

Public Member Functions

bool operator== (const Event &other) const
 
bool operator!= (const Event &other) const
 
const std::string & input () const
 
bool is_character () const
 
std::string character () const
 
bool is_mouse () const
 
struct Mousemouse ()
 
bool is_cursor_position () const
 
int cursor_x () const
 
int cursor_y () const
 
bool is_cursor_shape () const
 
int cursor_shape () const
 

Static Public Member Functions

static Event Character (std::string)
 An event corresponding to a given typed character. More...
 
static Event Character (char)
 An event corresponding to a given typed character. More...
 
static Event Character (wchar_t)
 An event corresponding to a given typed character. More...
 
static Event Special (std::string)
 An custom event whose meaning is defined by the user of the library. More...
 
static Event Mouse (std::string, Mouse mouse)
 An event corresponding to a given typed character. More...
 
static Event CursorPosition (std::string, int x, int y)
 
static Event CursorShape (std::string, int shape)
 An event corresponding to a terminal DCS (Device Control String). More...
 

Data Fields

ScreenInteractivescreen_ = nullptr
 

Static Public Attributes

static const Event ArrowLeft = Event::Special("\x1B[D")
 
static const Event ArrowRight = Event::Special("\x1B[C")
 
static const Event ArrowUp = Event::Special("\x1B[A")
 
static const Event ArrowDown = Event::Special("\x1B[B")
 
static const Event ArrowLeftCtrl = Event::Special("\x1B[1;5D")
 
static const Event ArrowRightCtrl = Event::Special("\x1B[1;5C")
 
static const Event ArrowUpCtrl = Event::Special("\x1B[1;5A")
 
static const Event ArrowDownCtrl = Event::Special("\x1B[1;5B")
 
static const Event Backspace = Event::Special({127})
 
static const Event Delete = Event::Special("\x1B[3~")
 
static const Event Return = Event::Special({10})
 
static const Event Escape = Event::Special("\x1B")
 
static const Event Tab = Event::Special({9})
 
static const Event TabReverse = Event::Special({27, 91, 90})
 
static const Event F1 = Event::Special("\x1BOP")
 
static const Event F2 = Event::Special("\x1BOQ")
 
static const Event F3 = Event::Special("\x1BOR")
 
static const Event F4 = Event::Special("\x1BOS")
 
static const Event F5 = Event::Special("\x1B[15~")
 
static const Event F6 = Event::Special("\x1B[17~")
 
static const Event F7 = Event::Special("\x1B[18~")
 
static const Event F8 = Event::Special("\x1B[19~")
 
static const Event F9 = Event::Special("\x1B[20~")
 
static const Event F10 = Event::Special("\x1B[21~")
 
static const Event F11 = Event::Special("\x1B[23~")
 
static const Event F12 = Event::Special("\x1B[24~")
 
static const Event Insert = Event::Special("\x1B[2~")
 
static const Event Home = Event::Special({27, 91, 72})
 
static const Event End = Event::Special({27, 91, 70})
 
static const Event PageUp = Event::Special({27, 91, 53, 126})
 
static const Event PageDown = Event::Special({27, 91, 54, 126})
 
static const Event Custom = Event::Special({0})
 

Detailed Description

Represent an event. It can be key press event, a terminal resize, or more ...

For example:

  • Printable character can be created using Event::Character('a').
  • Some special are predefined, like Event::ArrowLeft.
  • One can find arbitrary code for special Events using: ./example/util/print_key_press For instance, CTLR+A maps to Event::Special({1});

Useful documentation about xterm specification: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html

Definition at line 29 of file event.hpp.

Member Function Documentation

◆ Character() [1/3]

Event Character ( std::string  input)
static

An event corresponding to a given typed character.

Parameters
inputThe character typed by the user.

Definition at line 16 of file event.cpp.

◆ Character() [2/3]

Event Character ( char  c)
static

An event corresponding to a given typed character.

Parameters
cThe character typed by the user.

Definition at line 27 of file event.cpp.

◆ Character() [3/3]

Event Character ( wchar_t  c)
static

An event corresponding to a given typed character.

Parameters
cThe character typed by the user.

Definition at line 35 of file event.cpp.

◆ Special()

Event Special ( std::string  input)
static

An custom event whose meaning is defined by the user of the library.

Parameters
inputAn arbitrary sequence of character defined by the developer.

Definition at line 66 of file event.cpp.

◆ Mouse()

Event Mouse ( std::string  input,
Mouse  mouse 
)
static

An event corresponding to a given typed character.

Parameters
inputThe sequence of character send by the terminal.
mouseThe mouse state.

Definition at line 44 of file event.cpp.

◆ CursorPosition()

Event CursorPosition ( std::string  input,
int  x,
int  y 
)
static

Definition at line 74 of file event.cpp.

◆ CursorShape()

Event CursorShape ( std::string  input,
int  shape 
)
static

An event corresponding to a terminal DCS (Device Control String).

Definition at line 54 of file event.cpp.

◆ operator==()

bool operator== ( const Event other) const
inline

Definition at line 70 of file event.hpp.

◆ operator!=()

bool operator!= ( const Event other) const
inline

Definition at line 71 of file event.hpp.

◆ input()

const std::string& input ( ) const
inline

Definition at line 73 of file event.hpp.

◆ is_character()

bool is_character ( ) const
inline

Definition at line 75 of file event.hpp.

◆ character()

std::string character ( ) const
inline

Definition at line 76 of file event.hpp.

◆ is_mouse()

bool is_mouse ( ) const
inline

Definition at line 78 of file event.hpp.

◆ mouse()

struct Mouse& mouse ( )
inline

Definition at line 79 of file event.hpp.

◆ is_cursor_position()

bool is_cursor_position ( ) const
inline

Definition at line 82 of file event.hpp.

◆ cursor_x()

int cursor_x ( ) const
inline

Definition at line 83 of file event.hpp.

◆ cursor_y()

int cursor_y ( ) const
inline

Definition at line 84 of file event.hpp.

◆ is_cursor_shape()

bool is_cursor_shape ( ) const
inline

Definition at line 86 of file event.hpp.

◆ cursor_shape()

int cursor_shape ( ) const
inline

Definition at line 87 of file event.hpp.

Field Documentation

◆ ArrowLeft

const Event ArrowLeft = Event::Special("\x1B[D")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 40 of file event.hpp.

◆ ArrowRight

const Event ArrowRight = Event::Special("\x1B[C")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 41 of file event.hpp.

◆ ArrowUp

const Event ArrowUp = Event::Special("\x1B[A")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 42 of file event.hpp.

◆ ArrowDown

const Event ArrowDown = Event::Special("\x1B[B")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 43 of file event.hpp.

◆ ArrowLeftCtrl

const Event ArrowLeftCtrl = Event::Special("\x1B[1;5D")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 45 of file event.hpp.

◆ ArrowRightCtrl

const Event ArrowRightCtrl = Event::Special("\x1B[1;5C")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 46 of file event.hpp.

◆ ArrowUpCtrl

const Event ArrowUpCtrl = Event::Special("\x1B[1;5A")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 47 of file event.hpp.

◆ ArrowDownCtrl

const Event ArrowDownCtrl = Event::Special("\x1B[1;5B")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 48 of file event.hpp.

◆ Backspace

const Event Backspace = Event::Special({127})
static
Examples
examples/component/print_key_press.cpp.

Definition at line 51 of file event.hpp.

◆ Delete

const Event Delete = Event::Special("\x1B[3~")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 52 of file event.hpp.

◆ Return

const Event Return = Event::Special({10})
static
Examples
examples/component/print_key_press.cpp.

Definition at line 53 of file event.hpp.

◆ Escape

const Event Escape = Event::Special("\x1B")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 54 of file event.hpp.

◆ Tab

const Event Tab = Event::Special({9})
static
Examples
examples/component/print_key_press.cpp.

Definition at line 55 of file event.hpp.

◆ TabReverse

const Event TabReverse = Event::Special({27, 91, 90})
static
Examples
examples/component/print_key_press.cpp.

Definition at line 56 of file event.hpp.

◆ F1

const Event F1 = Event::Special("\x1BOP")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 57 of file event.hpp.

◆ F2

const Event F2 = Event::Special("\x1BOQ")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 57 of file event.hpp.

◆ F3

const Event F3 = Event::Special("\x1BOR")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 57 of file event.hpp.

◆ F4

const Event F4 = Event::Special("\x1BOS")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 57 of file event.hpp.

◆ F5

const Event F5 = Event::Special("\x1B[15~")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 57 of file event.hpp.

◆ F6

const Event F6 = Event::Special("\x1B[17~")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 57 of file event.hpp.

◆ F7

const Event F7 = Event::Special("\x1B[18~")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 57 of file event.hpp.

◆ F8

const Event F8 = Event::Special("\x1B[19~")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 57 of file event.hpp.

◆ F9

const Event F9 = Event::Special("\x1B[20~")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 57 of file event.hpp.

◆ F10

const Event F10 = Event::Special("\x1B[21~")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 57 of file event.hpp.

◆ F11

const Event F11 = Event::Special("\x1B[23~")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 57 of file event.hpp.

◆ F12

const Event F12 = Event::Special("\x1B[24~")
static
Examples
examples/component/print_key_press.cpp.

Definition at line 57 of file event.hpp.

◆ Insert

const Event Insert = Event::Special("\x1B[2~")
static

Definition at line 59 of file event.hpp.

◆ Home

const Event Home = Event::Special({27, 91, 72})
static
Examples
examples/component/print_key_press.cpp.

Definition at line 60 of file event.hpp.

◆ End

const Event End = Event::Special({27, 91, 70})
static
Examples
examples/component/print_key_press.cpp.

Definition at line 61 of file event.hpp.

◆ PageUp

const Event PageUp = Event::Special({27, 91, 53, 126})
static
Examples
examples/component/print_key_press.cpp.

Definition at line 63 of file event.hpp.

◆ PageDown

const Event PageDown = Event::Special({27, 91, 54, 126})
static
Examples
examples/component/print_key_press.cpp.

Definition at line 64 of file event.hpp.

◆ Custom

const Event Custom = Event::Special({0})
static

◆ screen_

ScreenInteractive* screen_ = nullptr

Definition at line 90 of file event.hpp.


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