Skip to content
You are viewing documentation for v6.1.5. 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/custom_loop, component/homescreen, component/input, component/print_key_press

Summary ​

SymbolDescription
ArrowLeft
ArrowRight
ArrowUp
ArrowDown
ArrowLeftCtrl
ArrowRightCtrl
ArrowUpCtrl
ArrowDownCtrl
Backspace
Delete
Return
Escape
Tab
TabReverse
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
screen_
mouse
cursor
cursor_shape
CursorPosition
CursorShapeAn event corresponding to a terminal DCS (Device Control String).
operator==
operator!=
operator<
input
is_character
character
is_mouse
is_cursor_position
cursor_x
cursor_y
is_cursor_shape
DebugStringReturn a string representation of the event.

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");

ArrowLeftCtrl ​

cpp
static const Event ArrowLeftCtrl = Event::Special("\x1B[1;5D");

ArrowRightCtrl ​

cpp
static const Event ArrowRightCtrl = Event::Special("\x1B[1;5C");

ArrowUpCtrl ​

cpp
static const Event ArrowUpCtrl = Event::Special("\x1B[1;5A");

ArrowDownCtrl ​

cpp
static const Event ArrowDownCtrl = Event::Special("\x1B[1;5B");

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_custom, component/tab_horizontal, component/tab_vertical

TabReverse ​

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

Insert ​

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

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});

F1 ​

cpp
static const Event F1 = Event::Special("\x1BOP");

F2 ​

cpp
static const Event F2 = Event::Special("\x1BOQ");

F3 ​

cpp
static const Event F3 = Event::Special("\x1BOR");

F4 ​

cpp
static const Event F4 = Event::Special("\x1BOS");

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[23~");

F12 ​

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

a ​

cpp
static const Event a = Event::Character("a");

A ​

cpp
static const Event A = Event::Character("A");

CtrlA ​

cpp
static const Event CtrlA = Event::Special("\x01");

AltA ​

cpp
static const Event AltA = Event::Special("\x1b""a");

CtrlAltA ​

cpp
static const Event CtrlAltA = Event::Special("\x1b\x01");

b ​

cpp
static const Event b = Event::Character("b");

B ​

cpp
static const Event B = Event::Character("B");

CtrlB ​

cpp
static const Event CtrlB = Event::Special("\x02");

AltB ​

cpp
static const Event AltB = Event::Special("\x1b""b");

CtrlAltB ​

cpp
static const Event CtrlAltB = Event::Special("\x1b\x02");

c ​

cpp
static const Event c = Event::Character("c");

C ​

cpp
static const Event C = Event::Character("C");

CtrlC ​

cpp
static const Event CtrlC = Event::Special("\x03");

AltC ​

cpp
static const Event AltC = Event::Special("\x1b""c");

CtrlAltC ​

cpp
static const Event CtrlAltC = Event::Special("\x1b\x03");

d ​

cpp
static const Event d = Event::Character("d");

D ​

cpp
static const Event D = Event::Character("D");

CtrlD ​

cpp
static const Event CtrlD = Event::Special("\x04");

AltD ​

cpp
static const Event AltD = Event::Special("\x1b""d");

CtrlAltD ​

cpp
static const Event CtrlAltD = Event::Special("\x1b\x04");

e ​

cpp
static const Event e = Event::Character("e");

E ​

cpp
static const Event E = Event::Character("E");

CtrlE ​

cpp
static const Event CtrlE = Event::Special("\x05");

AltE ​

cpp
static const Event AltE = Event::Special("\x1b""e");

CtrlAltE ​

cpp
static const Event CtrlAltE = Event::Special("\x1b\x05");

f ​

cpp
static const Event f = Event::Character("f");

F ​

cpp
static const Event F = Event::Character("F");

CtrlF ​

cpp
static const Event CtrlF = Event::Special("\x06");

AltF ​

cpp
static const Event AltF = Event::Special("\x1b""f");

CtrlAltF ​

cpp
static const Event CtrlAltF = Event::Special("\x1b\x06");

g ​

cpp
static const Event g = Event::Character("g");

G ​

cpp
static const Event G = Event::Character("G");

CtrlG ​

cpp
static const Event CtrlG = Event::Special("\x07");

AltG ​

cpp
static const Event AltG = Event::Special("\x1b""g");

CtrlAltG ​

cpp
static const Event CtrlAltG = Event::Special("\x1b\x07");

h ​

cpp
static const Event h = Event::Character("h");

H ​

cpp
static const Event H = Event::Character("H");

CtrlH ​

cpp
static const Event CtrlH = Event::Special("\x08");

AltH ​

cpp
static const Event AltH = Event::Special("\x1b""h");

CtrlAltH ​

cpp
static const Event CtrlAltH = Event::Special("\x1b\x08");

i ​

cpp
static const Event i = Event::Character("i");

I ​

cpp
static const Event I = Event::Character("I");

CtrlI ​

cpp
static const Event CtrlI = Event::Special("\x09");

AltI ​

cpp
static const Event AltI = Event::Special("\x1b""i");

CtrlAltI ​

cpp
static const Event CtrlAltI = Event::Special("\x1b\x09");

j ​

cpp
static const Event j = Event::Character("j");

J ​

cpp
static const Event J = Event::Character("J");

CtrlJ ​

cpp
static const Event CtrlJ = Event::Special("\x0a");

AltJ ​

cpp
static const Event AltJ = Event::Special("\x1b""j");

CtrlAltJ ​

cpp
static const Event CtrlAltJ = Event::Special("\x1b\x0a");

k ​

cpp
static const Event k = Event::Character("k");

K ​

cpp
static const Event K = Event::Character("K");

CtrlK ​

cpp
static const Event CtrlK = Event::Special("\x0b");

AltK ​

cpp
static const Event AltK = Event::Special("\x1b""k");

CtrlAltK ​

cpp
static const Event CtrlAltK = Event::Special("\x1b\x0b");

l ​

cpp
static const Event l = Event::Character("l");

L ​

cpp
static const Event L = Event::Character("L");

CtrlL ​

cpp
static const Event CtrlL = Event::Special("\x0c");

AltL ​

cpp
static const Event AltL = Event::Special("\x1b""l");

CtrlAltL ​

cpp
static const Event CtrlAltL = Event::Special("\x1b\x0c");

m ​

cpp
static const Event m = Event::Character("m");

M ​

cpp
static const Event M = Event::Character("M");

CtrlM ​

cpp
static const Event CtrlM = Event::Special("\x0d");

AltM ​

cpp
static const Event AltM = Event::Special("\x1b""m");

CtrlAltM ​

cpp
static const Event CtrlAltM = Event::Special("\x1b\x0d");

n ​

cpp
static const Event n = Event::Character("n");

N ​

cpp
static const Event N = Event::Character("N");

CtrlN ​

cpp
static const Event CtrlN = Event::Special("\x0e");

AltN ​

cpp
static const Event AltN = Event::Special("\x1b""n");

CtrlAltN ​

cpp
static const Event CtrlAltN = Event::Special("\x1b\x0e");

o ​

cpp
static const Event o = Event::Character("o");

O ​

cpp
static const Event O = Event::Character("O");

CtrlO ​

cpp
static const Event CtrlO = Event::Special("\x0f");

AltO ​

cpp
static const Event AltO = Event::Special("\x1b""o");

CtrlAltO ​

cpp
static const Event CtrlAltO = Event::Special("\x1b\x0f");

p ​

cpp
static const Event p = Event::Character("p");

P ​

cpp
static const Event P = Event::Character("P");

CtrlP ​

cpp
static const Event CtrlP = Event::Special("\x10");

AltP ​

cpp
static const Event AltP = Event::Special("\x1b""p");

CtrlAltP ​

cpp
static const Event CtrlAltP = Event::Special("\x1b\x10");

q ​

cpp
static const Event q = Event::Character("q");

Q ​

cpp
static const Event Q = Event::Character("Q");

CtrlQ ​

cpp
static const Event CtrlQ = Event::Special("\x11");

AltQ ​

cpp
static const Event AltQ = Event::Special("\x1b""q");

CtrlAltQ ​

cpp
static const Event CtrlAltQ = Event::Special("\x1b\x11");

r ​

cpp
static const Event r = Event::Character("r");

R ​

cpp
static const Event R = Event::Character("R");

CtrlR ​

cpp
static const Event CtrlR = Event::Special("\x12");

AltR ​

cpp
static const Event AltR = Event::Special("\x1b""r");

CtrlAltR ​

cpp
static const Event CtrlAltR = Event::Special("\x1b\x12");

s ​

cpp
static const Event s = Event::Character("s");

S ​

cpp
static const Event S = Event::Character("S");

CtrlS ​

cpp
static const Event CtrlS = Event::Special("\x13");

AltS ​

cpp
static const Event AltS = Event::Special("\x1b""s");

CtrlAltS ​

cpp
static const Event CtrlAltS = Event::Special("\x1b\x13");

t ​

cpp
static const Event t = Event::Character("t");

T ​

cpp
static const Event T = Event::Character("T");

CtrlT ​

cpp
static const Event CtrlT = Event::Special("\x14");

AltT ​

cpp
static const Event AltT = Event::Special("\x1b""t");

CtrlAltT ​

cpp
static const Event CtrlAltT = Event::Special("\x1b\x14");

u ​

cpp
static const Event u = Event::Character("u");

U ​

cpp
static const Event U = Event::Character("U");

CtrlU ​

cpp
static const Event CtrlU = Event::Special("\x15");

AltU ​

cpp
static const Event AltU = Event::Special("\x1b""u");

CtrlAltU ​

cpp
static const Event CtrlAltU = Event::Special("\x1b\x15");

v ​

cpp
static const Event v = Event::Character("v");

V ​

cpp
static const Event V = Event::Character("V");

CtrlV ​

cpp
static const Event CtrlV = Event::Special("\x16");

AltV ​

cpp
static const Event AltV = Event::Special("\x1b""v");

CtrlAltV ​

cpp
static const Event CtrlAltV = Event::Special("\x1b\x16");

w ​

cpp
static const Event w = Event::Character("w");

W ​

cpp
static const Event W = Event::Character("W");

CtrlW ​

cpp
static const Event CtrlW = Event::Special("\x17");

AltW ​

cpp
static const Event AltW = Event::Special("\x1b""w");

CtrlAltW ​

cpp
static const Event CtrlAltW = Event::Special("\x1b\x17");

x ​

cpp
static const Event x = Event::Character("x");

X ​

cpp
static const Event X = Event::Character("X");

CtrlX ​

cpp
static const Event CtrlX = Event::Special("\x18");

AltX ​

cpp
static const Event AltX = Event::Special("\x1b""x");

CtrlAltX ​

cpp
static const Event CtrlAltX = Event::Special("\x1b\x18");

y ​

cpp
static const Event y = Event::Character("y");

Y ​

cpp
static const Event Y = Event::Character("Y");

CtrlY ​

cpp
static const Event CtrlY = Event::Special("\x19");

AltY ​

cpp
static const Event AltY = Event::Special("\x1b""y");

CtrlAltY ​

cpp
static const Event CtrlAltY = Event::Special("\x1b\x19");

z ​

cpp
static const Event z = Event::Character("z");

Z ​

cpp
static const Event Z = Event::Character("Z");

CtrlZ ​

cpp
static const Event CtrlZ = Event::Special("\x1a");

AltZ ​

cpp
static const Event AltZ = Event::Special("\x1b""z");

CtrlAltZ ​

cpp
static const Event CtrlAltZ = Event::Special("\x1b\x1a");

Custom ​

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

Public Attributes ​

screen_ ​

cpp
ScreenInteractive * screen_ = nullptr;

mouse ​

cpp
struct Mouse mouse;

Examples: component/canvas_animated

cursor ​

cpp
struct Cursor cursor;

cursor_shape ​

cpp
int cursor_shape;

Static Functions ​

CursorPosition ​

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

CursorShape ​

cpp
static Event CursorShape(std::string, int shape);

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

Public Member Functions ​

operator== ​

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

operator!= ​

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

operator< ​

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

input ​

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

Examples: component/print_key_press

is_character ​

cpp
bool is_character() const;

character ​

cpp
std::string character() const;

Examples: component/input

is_mouse ​

cpp
bool is_mouse() const;

Examples: component/canvas_animated

mouse ​

cpp
struct Mouse & mouse();

is_cursor_position ​

cpp
bool is_cursor_position() const;

cursor_x ​

cpp
int cursor_x() const;

cursor_y ​

cpp
int cursor_y() const;

is_cursor_shape ​

cpp
bool is_cursor_shape() const;

cursor_shape ​

cpp
int cursor_shape() const;

DebugString ​

cpp
std::string DebugString() const;

Return a string representation of the event.