ftxui::Event
#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/custom_loop, component/input, component/print_above, component/print_key_press, component/terminal_info
Summary
Static Attributes
ArrowLeft
ArrowRight
static const Event ArrowRight = Event::Special("\x1B[C");ArrowUp
ArrowDown
ArrowLeftCtrl
static const Event ArrowLeftCtrl = Event::Special("\x1B[1;5D");ArrowRightCtrl
static const Event ArrowRightCtrl = Event::Special("\x1B[1;5C");ArrowUpCtrl
static const Event ArrowUpCtrl = Event::Special("\x1B[1;5A");ArrowDownCtrl
static const Event ArrowDownCtrl = Event::Special("\x1B[1;5B");ArrowLeftAlt
static const Event ArrowLeftAlt = Event::Special("\x1B[1;3D");ArrowRightAlt
static const Event ArrowRightAlt = Event::Special("\x1B[1;3C");ArrowUpAlt
static const Event ArrowUpAlt = Event::Special("\x1B[1;3A");ArrowDownAlt
static const Event ArrowDownAlt = Event::Special("\x1B[1;3B");Backspace
BackspaceAlt
static const Event BackspaceAlt = Event::Special({27, 127});AltBackspace
static const Event AltBackspace = Event::Special({27, 127});Delete
DeleteAlt
DeleteCtrl
static const Event DeleteCtrl = Event::Special("\x1B[3;5~");Return
Escape
Tab
Examples: component/canvas_animated, component/homescreen, component/modal_dialog_custom, component/tab_horizontal, component/tab_vertical
TabReverse
static const Event TabReverse = Event::Special({27, 91, 90});Insert
Home
End
PageUp
PageDown
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
a
A
CtrlA
AltA
CtrlAltA
b
B
CtrlB
AltB
CtrlAltB
c
C
CtrlC
AltC
CtrlAltC
d
D
CtrlD
AltD
CtrlAltD
e
E
CtrlE
AltE
CtrlAltE
f
F
CtrlF
AltF
CtrlAltF
g
G
CtrlG
AltG
CtrlAltG
h
H
CtrlH
AltH
CtrlAltH
i
I
CtrlI
AltI
CtrlAltI
j
J
CtrlJ
AltJ
CtrlAltJ
k
K
CtrlK
AltK
CtrlAltK
l
L
CtrlL
AltL
CtrlAltL
m
M
CtrlM
AltM
CtrlAltM
n
N
CtrlN
AltN
CtrlAltN
o
O
CtrlO
AltO
CtrlAltO
p
P
CtrlP
AltP
CtrlAltP
q
Q
CtrlQ
AltQ
CtrlAltQ
r
R
CtrlR
AltR
CtrlAltR
s
S
CtrlS
AltS
CtrlAltS
t
T
CtrlT
AltT
CtrlAltT
u
U
CtrlU
AltU
CtrlAltU
v
V
CtrlV
AltV
CtrlAltV
w
W
CtrlW
AltW
CtrlAltW
x
X
CtrlX
AltX
CtrlAltX
y
Y
CtrlY
AltY
CtrlAltY
z
Z
CtrlZ
AltZ
CtrlAltZ
Custom
Public Attributes
screen_
App * screen_ = nullptr;mouse
struct Mouse mouse;Examples: component/canvas_animated
cursor
struct Cursor cursor;cursor_shape
int cursor_shape;terminal_version
int terminal_version;Static Functions
Character
An event corresponding to a given typed character.
Parameters:
input: The character typed by the user.
Character
An event corresponding to a given typed character.
Parameters:
c: The character typed by the user.
Character
An event corresponding to a given typed character.
Parameters:
c: The character typed by the user.
Special
An custom event whose meaning is defined by the user of the library.
Parameters:
input: An arbitrary sequence of character defined by the developer.
Special
An custom event whose meaning is defined by the user of the library.
Parameters:
input: An arbitrary sequence of character defined by the developer.
Mouse
An event corresponding to a given typed character.
Parameters:
input: The sequence of character send by the terminal.mouse: The mouse state.
CursorPosition
static Event CursorPosition(std::string_view, int x, int y);CursorShape
static Event CursorShape(std::string_view, int shape);An event corresponding to a terminal DCS (Device Control String).
TerminalNameVersion
static Event TerminalNameVersion(std::string_view, std::string name, int version);An event corresponding to a terminal name and version report.
TerminalEmulator
static Event TerminalEmulator(std::string_view, std::string name, std::string version);An event corresponding to a terminal emulator report.
TerminalCapabilities
static Event TerminalCapabilities(std::string_view, std::vector< int > capabilities);An event corresponding to a terminal capabilities report.
Public Member Functions
operator==
bool operator==(const Event & other) const;operator!=
bool operator!=(const Event & other) const;operator<
bool operator<(const Event & other) const;input
const std::string & input() const;Examples: component/print_key_press
is_character
bool is_character() const;character
std::string character() const;Examples: component/input
is_mouse
bool is_mouse() const;Examples: component/canvas_animated
mouse
struct Mouse & mouse();is_cursor_position
bool is_cursor_position() const;cursor_x
int cursor_x() const;cursor_y
int cursor_y() const;is_cursor_shape
bool is_cursor_shape() const;cursor_shape
int cursor_shape() const;IsTerminalNameVersion
bool IsTerminalNameVersion() const;Whether the event is a terminal name and version report.
TerminalName
const std::string & TerminalName() const;Return the terminal name.
TerminalVersion
int TerminalVersion() const;Return the terminal version.
IsTerminalEmulator
bool IsTerminalEmulator() const;Whether the event is a terminal emulator report.
TerminalEmulatorName
const std::string & TerminalEmulatorName() const;Return the terminal emulator name.
TerminalEmulatorVersion
const std::string & TerminalEmulatorVersion() const;Return the terminal emulator version.
IsTerminalCapabilities
bool IsTerminalCapabilities() const;Whether the event is a terminal capabilities report.
TerminalCapabilities
const std::vector< int > & TerminalCapabilities() const;Return the terminal capabilities.
TerminalCapabilityNames
std::vector< std::string > TerminalCapabilityNames() const;Return the names of the terminal capabilities.
DebugString
std::string DebugString() const;Return a string representation of the event.