FTXUI  0.8.1
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 is_character () const
 
std::string character () const
 
bool is_mouse () const
 
struct Mousemouse ()
 
bool is_cursor_reporting () const
 
int cursor_x () const
 
int cursor_y () const
 
const std::string & input () const
 
bool operator== (const Event &other) const
 
bool operator!= (const Event &other) const
 

Static Public Member Functions

static Event Character (std::string)
 
static Event Character (char)
 
static Event Character (wchar_t)
 
static Event Special (std::string)
 
static Event Mouse (std::string, Mouse mouse)
 
static Event CursorReporting (std::string, int x, int y)
 

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 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("\x1B[OP")
 
static const Event F2 = Event::Special("\x1B[OQ")
 
static const Event F3 = Event::Special("\x1B[OR")
 
static const Event F4 = Event::Special("\x1B[OS")
 
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[21~")
 
static const Event F12 = Event::Special("\x1B[24~")
 
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 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

Examples
examples/component/print_key_press.cpp.

Definition at line 25 of file event.hpp.

Member Function Documentation

◆ Character() [1/3]

Event Character ( std::string  input)
static

Definition at line 10 of file event.cpp.

◆ Character() [2/3]

Event Character ( char  c)
static

Definition at line 18 of file event.cpp.

◆ Character() [3/3]

Event Character ( wchar_t  c)
static

Definition at line 23 of file event.cpp.

◆ Special()

Event Special ( std::string  input)
static

Definition at line 37 of file event.cpp.

◆ Mouse()

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

Definition at line 28 of file event.cpp.

◆ CursorReporting()

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

Definition at line 44 of file event.cpp.

◆ is_character()

bool is_character ( ) const
inline
Examples
examples/component/print_key_press.cpp.

Definition at line 59 of file event.hpp.

◆ character()

std::string character ( ) const
inline

Definition at line 60 of file event.hpp.

◆ is_mouse()

bool is_mouse ( ) const
inline
Examples
examples/component/print_key_press.cpp.

Definition at line 62 of file event.hpp.

◆ mouse()

struct Mouse& mouse ( )
inline
Examples
examples/component/print_key_press.cpp.

Definition at line 63 of file event.hpp.

◆ is_cursor_reporting()

bool is_cursor_reporting ( ) const
inline

Definition at line 67 of file event.hpp.

◆ cursor_x()

int cursor_x ( ) const
inline

Definition at line 68 of file event.hpp.

◆ cursor_y()

int cursor_y ( ) const
inline

Definition at line 69 of file event.hpp.

◆ input()

const std::string& input ( ) const
inline
Examples
examples/component/print_key_press.cpp.

Definition at line 71 of file event.hpp.

◆ operator==()

bool operator== ( const Event other) const
inline

Definition at line 73 of file event.hpp.

◆ operator!=()

bool operator!= ( const Event other) const
inline

Definition at line 74 of file event.hpp.

Field Documentation

◆ ArrowLeft

const Event ArrowLeft = Event::Special("\x1B[D")
static

Definition at line 35 of file event.hpp.

◆ ArrowRight

const Event ArrowRight = Event::Special("\x1B[C")
static

Definition at line 36 of file event.hpp.

◆ ArrowUp

const Event ArrowUp = Event::Special("\x1B[A")
static

Definition at line 37 of file event.hpp.

◆ ArrowDown

const Event ArrowDown = Event::Special("\x1B[B")
static

Definition at line 38 of file event.hpp.

◆ Backspace

const Event Backspace = Event::Special({127})
static

Definition at line 41 of file event.hpp.

◆ Delete

const Event Delete = Event::Special("\x1B[3~")
static

Definition at line 42 of file event.hpp.

◆ Return

const Event Return = Event::Special({10})
static

Definition at line 43 of file event.hpp.

◆ Escape

const Event Escape = Event::Special("\x1B")
static

Definition at line 44 of file event.hpp.

◆ Tab

const Event Tab = Event::Special({9})
static

Definition at line 45 of file event.hpp.

◆ TabReverse

const Event TabReverse = Event::Special({27, 91, 90})
static

Definition at line 46 of file event.hpp.

◆ F1

const Event F1 = Event::Special("\x1B[OP")
static

Definition at line 47 of file event.hpp.

◆ F2

const Event F2 = Event::Special("\x1B[OQ")
static

Definition at line 47 of file event.hpp.

◆ F3

const Event F3 = Event::Special("\x1B[OR")
static

Definition at line 47 of file event.hpp.

◆ F4

const Event F4 = Event::Special("\x1B[OS")
static

Definition at line 47 of file event.hpp.

◆ F5

const Event F5 = Event::Special("\x1B[15~")
static

Definition at line 47 of file event.hpp.

◆ F6

const Event F6 = Event::Special("\x1B[17~")
static

Definition at line 47 of file event.hpp.

◆ F7

const Event F7 = Event::Special("\x1B[18~")
static

Definition at line 47 of file event.hpp.

◆ F8

const Event F8 = Event::Special("\x1B[19~")
static

Definition at line 47 of file event.hpp.

◆ F9

const Event F9 = Event::Special("\x1B[20~")
static

Definition at line 47 of file event.hpp.

◆ F10

const Event F10 = Event::Special("\x1B[21~")
static

Definition at line 47 of file event.hpp.

◆ F11

const Event F11 = Event::Special("\x1B[21~")
static

Definition at line 47 of file event.hpp.

◆ F12

const Event F12 = Event::Special("\x1B[24~")
static

Definition at line 47 of file event.hpp.

◆ Home

const Event Home = Event::Special({27, 91, 72})
static

Definition at line 49 of file event.hpp.

◆ End

const Event End = Event::Special({27, 91, 70})
static

Definition at line 50 of file event.hpp.

◆ PageUp

const Event PageUp = Event::Special({27, 91, 53, 126})
static

Definition at line 52 of file event.hpp.

◆ PageDown

const Event PageDown = Event::Special({27, 91, 54, 126})
static

Definition at line 53 of file event.hpp.

◆ Custom

Event Custom = Event::Special({0})
static
Examples
examples/component/homescreen.cpp.

Definition at line 56 of file event.hpp.


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