Skip to content
You are viewing documentation for v3.0.0. Switch to latest (main).

ftxui::Event ​

cpp
#include <ftxui/component/event.hpp>

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: component/canvas_animated, component/homescreen, component/print_key_press

Summary ​

SymbolDescription
ArrowLeft
ArrowRight
ArrowUp
ArrowDown
Backspace
Delete
Return
Escape
Tab
TabReverse
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
Home
End
PageUp
PageDown
Custom
screen_
mouse_
cursor_
Character
Special
Mouse
CursorReporting
is_character
character
is_mouse
mouse
is_cursor_reporting
cursor_x
cursor_y
input
operator==
operator!=

Static Attributes ​

ArrowLeft ​

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

ArrowRight ​

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

ArrowUp ​

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

ArrowDown ​

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

Backspace ​

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

Delete ​

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

Return ​

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

Escape ​

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

Tab ​

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

Examples: component/canvas_animated, component/homescreen, component/modal_dialog, component/tab_horizontal, component/tab_vertical

TabReverse ​

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

F1 ​

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

F2 ​

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

F3 ​

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

F4 ​

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

F5 ​

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

F6 ​

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

F7 ​

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

F8 ​

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

F9 ​

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

F10 ​

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

F11 ​

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

F12 ​

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

Home ​

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

End ​

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

PageUp ​

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

PageDown ​

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

Custom ​

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

Public Attributes ​

screen_ ​

cpp
ScreenInteractive * screen_ = nullptr;

mouse_ ​

cpp
struct Mouse mouse_;

cursor_ ​

cpp
struct Cursor cursor_;

Static Functions ​

Character ​

cpp
static Event Character(std::string);

Character ​

cpp
static Event Character(char);

Character ​

cpp
static Event Character(wchar_t);

Special ​

cpp
static Event Special(std::string);

Mouse ​

cpp
static Event Mouse(std::string, Mouse mouse);

Examples: component/print_key_press

CursorReporting ​

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

Public Member Functions ​

is_character ​

cpp
bool is_character() const;

Examples: component/print_key_press

character ​

cpp
std::string character() const;

is_mouse ​

cpp
bool is_mouse() const;

Examples: component/canvas_animated, component/print_key_press

mouse ​

cpp
struct Mouse & mouse();

Examples: component/canvas_animated, component/print_key_press

is_cursor_reporting ​

cpp
bool is_cursor_reporting() const;

cursor_x ​

cpp
int cursor_x() const;

cursor_y ​

cpp
int cursor_y() const;

input ​

cpp
const std::string & input() const;

Examples: component/print_key_press

operator== ​

cpp
bool operator==(const Event & other) const;

operator!= ​

cpp
bool operator!=(const Event & other) const;