mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-06-25 09:01:11 +08:00
Fix Event.Control test.
This commit is contained in:
parent
2b73998d56
commit
092482f63b
@ -33,8 +33,8 @@ int main() {
|
|||||||
|
|
||||||
auto left_column = Renderer([&] {
|
auto left_column = Renderer([&] {
|
||||||
Elements children = {
|
Elements children = {
|
||||||
text("Codes"),
|
text("Codes"),
|
||||||
separator(),
|
separator(),
|
||||||
};
|
};
|
||||||
for (size_t i = std::max(0, (int)keys.size() - 20); i < keys.size(); ++i) {
|
for (size_t i = std::max(0, (int)keys.size() - 20); i < keys.size(); ++i) {
|
||||||
children.push_back(text(Code(keys[i])));
|
children.push_back(text(Code(keys[i])));
|
||||||
@ -44,8 +44,8 @@ int main() {
|
|||||||
|
|
||||||
auto right_column = Renderer([&] {
|
auto right_column = Renderer([&] {
|
||||||
Elements children = {
|
Elements children = {
|
||||||
text("Event"),
|
text("Event"),
|
||||||
separator(),
|
separator(),
|
||||||
};
|
};
|
||||||
for (size_t i = std::max(0, (int)keys.size() - 20); i < keys.size(); ++i) {
|
for (size_t i = std::max(0, (int)keys.size() - 20); i < keys.size(); ++i) {
|
||||||
children.push_back(text(keys[i].DebugString()));
|
children.push_back(text(keys[i].DebugString()));
|
||||||
|
@ -59,12 +59,12 @@ class ScreenInteractive : public Screen {
|
|||||||
// temporarily uninstalled.
|
// temporarily uninstalled.
|
||||||
Closure WithRestoredIO(Closure);
|
Closure WithRestoredIO(Closure);
|
||||||
|
|
||||||
// FTXUI implements handlers for Ctrl-C and Ctrl-Z. By default, these handlers
|
// FTXUI implements handlers for Ctrl-C and Ctrl-Z. By default, these handlers
|
||||||
// are executed, even if the component catches the event. This avoid users
|
// are executed, even if the component catches the event. This avoid users
|
||||||
// handling every event to be trapped in the application. However, in some
|
// handling every event to be trapped in the application. However, in some
|
||||||
// cases, the application may want to handle these events itself. In this case,
|
// cases, the application may want to handle these events itself. In this
|
||||||
// the application can force FTXUI to not handle these events by calling the
|
// case, the application can force FTXUI to not handle these events by calling
|
||||||
// following functions with force=true.
|
// the following functions with force=true.
|
||||||
void ForceHandleCtrlC(bool force);
|
void ForceHandleCtrlC(bool force);
|
||||||
void ForceHandleCtrlZ(bool force);
|
void ForceHandleCtrlZ(bool force);
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#include <string> // for string
|
#include <string> // for string
|
||||||
#include <unordered_map> // for unordered_map
|
#include <unordered_map> // for unordered_map
|
||||||
|
|
||||||
#include "ftxui/screen/color.hpp" // for Color
|
#include "ftxui/screen/color.hpp" // for Color
|
||||||
#include "ftxui/screen/image.hpp" // for Pixel, Image
|
#include "ftxui/screen/image.hpp" // for Pixel, Image
|
||||||
|
|
||||||
#ifdef DrawText
|
#ifdef DrawText
|
||||||
// Workaround for WinUsr.h (via Windows.h) defining macros that break things.
|
// Workaround for WinUsr.h (via Windows.h) defining macros that break things.
|
||||||
@ -94,7 +94,7 @@ struct Canvas {
|
|||||||
void DrawText(int x, int y, const std::string& value);
|
void DrawText(int x, int y, const std::string& value);
|
||||||
void DrawText(int x, int y, const std::string& value, const Color& color);
|
void DrawText(int x, int y, const std::string& value, const Color& color);
|
||||||
void DrawText(int x, int y, const std::string& value, const Stylizer& style);
|
void DrawText(int x, int y, const std::string& value, const Stylizer& style);
|
||||||
|
|
||||||
// Draw using directly pixels or images --------------------------------------
|
// Draw using directly pixels or images --------------------------------------
|
||||||
// x is considered to be a multiple of 2.
|
// x is considered to be a multiple of 2.
|
||||||
// y is considered to be a multiple of 4.
|
// y is considered to be a multiple of 4.
|
||||||
|
@ -36,7 +36,8 @@ class Screen : public Image {
|
|||||||
// Print the Screen on to the terminal.
|
// Print the Screen on to the terminal.
|
||||||
void Print() const;
|
void Print() const;
|
||||||
|
|
||||||
// Fill the screen with space and reset any screen state, like hyperlinks, and cursor
|
// Fill the screen with space and reset any screen state, like hyperlinks, and
|
||||||
|
// cursor
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
// Move the terminal cursor n-lines up with n = dimy().
|
// Move the terminal cursor n-lines up with n = dimy().
|
||||||
|
@ -229,7 +229,7 @@ std::string Event::DebugString() const {
|
|||||||
{Mouse::Motion::Moved, ".motion = Mouse::Moved"},
|
{Mouse::Motion::Moved, ".motion = Mouse::Moved"},
|
||||||
};
|
};
|
||||||
|
|
||||||
switch(type_) {
|
switch (type_) {
|
||||||
case Type::Character: {
|
case Type::Character: {
|
||||||
return "Event::Character(\"" + input_ + "\")";
|
return "Event::Character(\"" + input_ + "\")";
|
||||||
}
|
}
|
||||||
@ -311,139 +311,191 @@ const Event Event::PageUp = Event::Special({27, 91, 53, 126}); // NOLINT
|
|||||||
const Event Event::PageDown = Event::Special({27, 91, 54, 126}); // NOLINT
|
const Event Event::PageDown = Event::Special({27, 91, 54, 126}); // NOLINT
|
||||||
const Event Event::Custom = Event::Special({0}); // NOLINT
|
const Event Event::Custom = Event::Special({0}); // NOLINT
|
||||||
//
|
//
|
||||||
const Event Event::a = Event::Character("a"); // NOLINT
|
const Event Event::a = Event::Character("a"); // NOLINT
|
||||||
const Event Event::b = Event::Character("b"); // NOLINT
|
const Event Event::b = Event::Character("b"); // NOLINT
|
||||||
const Event Event::c = Event::Character("c"); // NOLINT
|
const Event Event::c = Event::Character("c"); // NOLINT
|
||||||
const Event Event::d = Event::Character("d"); // NOLINT
|
const Event Event::d = Event::Character("d"); // NOLINT
|
||||||
const Event Event::e = Event::Character("e"); // NOLINT
|
const Event Event::e = Event::Character("e"); // NOLINT
|
||||||
const Event Event::f = Event::Character("f"); // NOLINT
|
const Event Event::f = Event::Character("f"); // NOLINT
|
||||||
const Event Event::g = Event::Character("g"); // NOLINT
|
const Event Event::g = Event::Character("g"); // NOLINT
|
||||||
const Event Event::h = Event::Character("h"); // NOLINT
|
const Event Event::h = Event::Character("h"); // NOLINT
|
||||||
const Event Event::i = Event::Character("i"); // NOLINT
|
const Event Event::i = Event::Character("i"); // NOLINT
|
||||||
const Event Event::j = Event::Character("j"); // NOLINT
|
const Event Event::j = Event::Character("j"); // NOLINT
|
||||||
const Event Event::k = Event::Character("k"); // NOLINT
|
const Event Event::k = Event::Character("k"); // NOLINT
|
||||||
const Event Event::l = Event::Character("l"); // NOLINT
|
const Event Event::l = Event::Character("l"); // NOLINT
|
||||||
const Event Event::m = Event::Character("m"); // NOLINT
|
const Event Event::m = Event::Character("m"); // NOLINT
|
||||||
const Event Event::n = Event::Character("n"); // NOLINT
|
const Event Event::n = Event::Character("n"); // NOLINT
|
||||||
const Event Event::o = Event::Character("o"); // NOLINT
|
const Event Event::o = Event::Character("o"); // NOLINT
|
||||||
const Event Event::p = Event::Character("p"); // NOLINT
|
const Event Event::p = Event::Character("p"); // NOLINT
|
||||||
const Event Event::q = Event::Character("q"); // NOLINT
|
const Event Event::q = Event::Character("q"); // NOLINT
|
||||||
const Event Event::r = Event::Character("r"); // NOLINT
|
const Event Event::r = Event::Character("r"); // NOLINT
|
||||||
const Event Event::s = Event::Character("s"); // NOLINT
|
const Event Event::s = Event::Character("s"); // NOLINT
|
||||||
const Event Event::t = Event::Character("t"); // NOLINT
|
const Event Event::t = Event::Character("t"); // NOLINT
|
||||||
const Event Event::u = Event::Character("u"); // NOLINT
|
const Event Event::u = Event::Character("u"); // NOLINT
|
||||||
const Event Event::v = Event::Character("v"); // NOLINT
|
const Event Event::v = Event::Character("v"); // NOLINT
|
||||||
const Event Event::w = Event::Character("w"); // NOLINT
|
const Event Event::w = Event::Character("w"); // NOLINT
|
||||||
const Event Event::x = Event::Character("x"); // NOLINT
|
const Event Event::x = Event::Character("x"); // NOLINT
|
||||||
const Event Event::y = Event::Character("y"); // NOLINT
|
const Event Event::y = Event::Character("y"); // NOLINT
|
||||||
const Event Event::z = Event::Character("z"); // NOLINT
|
const Event Event::z = Event::Character("z"); // NOLINT
|
||||||
|
|
||||||
const Event Event::A = Event::Character("A"); // NOLINT
|
const Event Event::A = Event::Character("A"); // NOLINT
|
||||||
const Event Event::B = Event::Character("B"); // NOLINT
|
const Event Event::B = Event::Character("B"); // NOLINT
|
||||||
const Event Event::C = Event::Character("C"); // NOLINT
|
const Event Event::C = Event::Character("C"); // NOLINT
|
||||||
const Event Event::D = Event::Character("D"); // NOLINT
|
const Event Event::D = Event::Character("D"); // NOLINT
|
||||||
const Event Event::E = Event::Character("E"); // NOLINT
|
const Event Event::E = Event::Character("E"); // NOLINT
|
||||||
const Event Event::F = Event::Character("F"); // NOLINT
|
const Event Event::F = Event::Character("F"); // NOLINT
|
||||||
const Event Event::G = Event::Character("G"); // NOLINT
|
const Event Event::G = Event::Character("G"); // NOLINT
|
||||||
const Event Event::H = Event::Character("H"); // NOLINT
|
const Event Event::H = Event::Character("H"); // NOLINT
|
||||||
const Event Event::I = Event::Character("I"); // NOLINT
|
const Event Event::I = Event::Character("I"); // NOLINT
|
||||||
const Event Event::J = Event::Character("J"); // NOLINT
|
const Event Event::J = Event::Character("J"); // NOLINT
|
||||||
const Event Event::K = Event::Character("K"); // NOLINT
|
const Event Event::K = Event::Character("K"); // NOLINT
|
||||||
const Event Event::L = Event::Character("L"); // NOLINT
|
const Event Event::L = Event::Character("L"); // NOLINT
|
||||||
const Event Event::M = Event::Character("M"); // NOLINT
|
const Event Event::M = Event::Character("M"); // NOLINT
|
||||||
const Event Event::N = Event::Character("N"); // NOLINT
|
const Event Event::N = Event::Character("N"); // NOLINT
|
||||||
const Event Event::O = Event::Character("O"); // NOLINT
|
const Event Event::O = Event::Character("O"); // NOLINT
|
||||||
const Event Event::P = Event::Character("P"); // NOLINT
|
const Event Event::P = Event::Character("P"); // NOLINT
|
||||||
const Event Event::Q = Event::Character("Q"); // NOLINT
|
const Event Event::Q = Event::Character("Q"); // NOLINT
|
||||||
const Event Event::R = Event::Character("R"); // NOLINT
|
const Event Event::R = Event::Character("R"); // NOLINT
|
||||||
const Event Event::S = Event::Character("S"); // NOLINT
|
const Event Event::S = Event::Character("S"); // NOLINT
|
||||||
const Event Event::T = Event::Character("T"); // NOLINT
|
const Event Event::T = Event::Character("T"); // NOLINT
|
||||||
const Event Event::U = Event::Character("U"); // NOLINT
|
const Event Event::U = Event::Character("U"); // NOLINT
|
||||||
const Event Event::V = Event::Character("V"); // NOLINT
|
const Event Event::V = Event::Character("V"); // NOLINT
|
||||||
const Event Event::W = Event::Character("W"); // NOLINT
|
const Event Event::W = Event::Character("W"); // NOLINT
|
||||||
const Event Event::X = Event::Character("X"); // NOLINT
|
const Event Event::X = Event::Character("X"); // NOLINT
|
||||||
const Event Event::Y = Event::Character("Y"); // NOLINT
|
const Event Event::Y = Event::Character("Y"); // NOLINT
|
||||||
const Event Event::Z = Event::Character("Z"); // NOLINT
|
const Event Event::Z = Event::Character("Z"); // NOLINT
|
||||||
|
|
||||||
const Event Event::CtrlA = Event::Special("\x01"); // NOLINT
|
const Event Event::CtrlA = Event::Special("\x01"); // NOLINT
|
||||||
const Event Event::CtrlB = Event::Special("\x02"); // NOLINT
|
const Event Event::CtrlB = Event::Special("\x02"); // NOLINT
|
||||||
const Event Event::CtrlC = Event::Special("\x03"); // NOLINT
|
const Event Event::CtrlC = Event::Special("\x03"); // NOLINT
|
||||||
const Event Event::CtrlD = Event::Special("\x04"); // NOLINT
|
const Event Event::CtrlD = Event::Special("\x04"); // NOLINT
|
||||||
const Event Event::CtrlE = Event::Special("\x05"); // NOLINT
|
const Event Event::CtrlE = Event::Special("\x05"); // NOLINT
|
||||||
const Event Event::CtrlF = Event::Special("\x06"); // NOLINT
|
const Event Event::CtrlF = Event::Special("\x06"); // NOLINT
|
||||||
const Event Event::CtrlG = Event::Special("\x07"); // NOLINT
|
const Event Event::CtrlG = Event::Special("\x07"); // NOLINT
|
||||||
const Event Event::CtrlH = Event::Special("\x08"); // NOLINT
|
const Event Event::CtrlH = Event::Special("\x08"); // NOLINT
|
||||||
const Event Event::CtrlI = Event::Special("\x09"); // NOLINT
|
const Event Event::CtrlI = Event::Special("\x09"); // NOLINT
|
||||||
const Event Event::CtrlJ = Event::Special("\x0a"); // NOLINT
|
const Event Event::CtrlJ = Event::Special("\x0a"); // NOLINT
|
||||||
const Event Event::CtrlK = Event::Special("\x0b"); // NOLINT
|
const Event Event::CtrlK = Event::Special("\x0b"); // NOLINT
|
||||||
const Event Event::CtrlL = Event::Special("\x0c"); // NOLINT
|
const Event Event::CtrlL = Event::Special("\x0c"); // NOLINT
|
||||||
const Event Event::CtrlM = Event::Special("\x0d"); // NOLINT
|
const Event Event::CtrlM = Event::Special("\x0d"); // NOLINT
|
||||||
const Event Event::CtrlN = Event::Special("\x0e"); // NOLINT
|
const Event Event::CtrlN = Event::Special("\x0e"); // NOLINT
|
||||||
const Event Event::CtrlO = Event::Special("\x0f"); // NOLINT
|
const Event Event::CtrlO = Event::Special("\x0f"); // NOLINT
|
||||||
const Event Event::CtrlP = Event::Special("\x10"); // NOLINT
|
const Event Event::CtrlP = Event::Special("\x10"); // NOLINT
|
||||||
const Event Event::CtrlQ = Event::Special("\x11"); // NOLINT
|
const Event Event::CtrlQ = Event::Special("\x11"); // NOLINT
|
||||||
const Event Event::CtrlR = Event::Special("\x12"); // NOLINT
|
const Event Event::CtrlR = Event::Special("\x12"); // NOLINT
|
||||||
const Event Event::CtrlS = Event::Special("\x13"); // NOLINT
|
const Event Event::CtrlS = Event::Special("\x13"); // NOLINT
|
||||||
const Event Event::CtrlT = Event::Special("\x14"); // NOLINT
|
const Event Event::CtrlT = Event::Special("\x14"); // NOLINT
|
||||||
const Event Event::CtrlU = Event::Special("\x15"); // NOLINT
|
const Event Event::CtrlU = Event::Special("\x15"); // NOLINT
|
||||||
const Event Event::CtrlV = Event::Special("\x16"); // NOLINT
|
const Event Event::CtrlV = Event::Special("\x16"); // NOLINT
|
||||||
const Event Event::CtrlW = Event::Special("\x17"); // NOLINT
|
const Event Event::CtrlW = Event::Special("\x17"); // NOLINT
|
||||||
const Event Event::CtrlX = Event::Special("\x18"); // NOLINT
|
const Event Event::CtrlX = Event::Special("\x18"); // NOLINT
|
||||||
const Event Event::CtrlY = Event::Special("\x19"); // NOLINT
|
const Event Event::CtrlY = Event::Special("\x19"); // NOLINT
|
||||||
const Event Event::CtrlZ = Event::Special("\x1a"); // NOLINT
|
const Event Event::CtrlZ = Event::Special("\x1a"); // NOLINT
|
||||||
|
|
||||||
const Event Event::AltA = Event::Special("\x1b""a"); // NOLINT
|
const Event Event::AltA = Event::Special(
|
||||||
const Event Event::AltB = Event::Special("\x1b""b"); // NOLINT
|
"\x1b"
|
||||||
const Event Event::AltC = Event::Special("\x1b""c"); // NOLINT
|
"a"); // NOLINT
|
||||||
const Event Event::AltD = Event::Special("\x1b""d"); // NOLINT
|
const Event Event::AltB = Event::Special(
|
||||||
const Event Event::AltE = Event::Special("\x1b""e"); // NOLINT
|
"\x1b"
|
||||||
const Event Event::AltF = Event::Special("\x1b""f"); // NOLINT
|
"b"); // NOLINT
|
||||||
const Event Event::AltG = Event::Special("\x1b""g"); // NOLINT
|
const Event Event::AltC = Event::Special(
|
||||||
const Event Event::AltH = Event::Special("\x1b""h"); // NOLINT
|
"\x1b"
|
||||||
const Event Event::AltI = Event::Special("\x1b""i"); // NOLINT
|
"c"); // NOLINT
|
||||||
const Event Event::AltJ = Event::Special("\x1b""j"); // NOLINT
|
const Event Event::AltD = Event::Special(
|
||||||
const Event Event::AltK = Event::Special("\x1b""k"); // NOLINT
|
"\x1b"
|
||||||
const Event Event::AltL = Event::Special("\x1b""l"); // NOLINT
|
"d"); // NOLINT
|
||||||
const Event Event::AltM = Event::Special("\x1b""m"); // NOLINT
|
const Event Event::AltE = Event::Special(
|
||||||
const Event Event::AltN = Event::Special("\x1b""n"); // NOLINT
|
"\x1b"
|
||||||
const Event Event::AltO = Event::Special("\x1b""o"); // NOLINT
|
"e"); // NOLINT
|
||||||
const Event Event::AltP = Event::Special("\x1b""p"); // NOLINT
|
const Event Event::AltF = Event::Special(
|
||||||
const Event Event::AltQ = Event::Special("\x1b""q"); // NOLINT
|
"\x1b"
|
||||||
const Event Event::AltR = Event::Special("\x1b""r"); // NOLINT
|
"f"); // NOLINT
|
||||||
const Event Event::AltS = Event::Special("\x1b""s"); // NOLINT
|
const Event Event::AltG = Event::Special(
|
||||||
const Event Event::AltT = Event::Special("\x1b""t"); // NOLINT
|
"\x1b"
|
||||||
const Event Event::AltU = Event::Special("\x1b""u"); // NOLINT
|
"g"); // NOLINT
|
||||||
const Event Event::AltV = Event::Special("\x1b""v"); // NOLINT
|
const Event Event::AltH = Event::Special(
|
||||||
const Event Event::AltW = Event::Special("\x1b""w"); // NOLINT
|
"\x1b"
|
||||||
const Event Event::AltX = Event::Special("\x1b""x"); // NOLINT
|
"h"); // NOLINT
|
||||||
const Event Event::AltY = Event::Special("\x1b""y"); // NOLINT
|
const Event Event::AltI = Event::Special(
|
||||||
const Event Event::AltZ = Event::Special("\x1b""z"); // NOLINT
|
"\x1b"
|
||||||
|
"i"); // NOLINT
|
||||||
|
const Event Event::AltJ = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"j"); // NOLINT
|
||||||
|
const Event Event::AltK = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"k"); // NOLINT
|
||||||
|
const Event Event::AltL = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"l"); // NOLINT
|
||||||
|
const Event Event::AltM = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"m"); // NOLINT
|
||||||
|
const Event Event::AltN = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"n"); // NOLINT
|
||||||
|
const Event Event::AltO = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"o"); // NOLINT
|
||||||
|
const Event Event::AltP = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"p"); // NOLINT
|
||||||
|
const Event Event::AltQ = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"q"); // NOLINT
|
||||||
|
const Event Event::AltR = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"r"); // NOLINT
|
||||||
|
const Event Event::AltS = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"s"); // NOLINT
|
||||||
|
const Event Event::AltT = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"t"); // NOLINT
|
||||||
|
const Event Event::AltU = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"u"); // NOLINT
|
||||||
|
const Event Event::AltV = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"v"); // NOLINT
|
||||||
|
const Event Event::AltW = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"w"); // NOLINT
|
||||||
|
const Event Event::AltX = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"x"); // NOLINT
|
||||||
|
const Event Event::AltY = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"y"); // NOLINT
|
||||||
|
const Event Event::AltZ = Event::Special(
|
||||||
|
"\x1b"
|
||||||
|
"z"); // NOLINT
|
||||||
|
|
||||||
const Event Event::CtrlAltA = Event::Special("\x1b\x01"); // NOLINT
|
const Event Event::CtrlAltA = Event::Special("\x1b\x01"); // NOLINT
|
||||||
const Event Event::CtrlAltB = Event::Special("\x1b\x02"); // NOLINT
|
const Event Event::CtrlAltB = Event::Special("\x1b\x02"); // NOLINT
|
||||||
const Event Event::CtrlAltC = Event::Special("\x1b\x03"); // NOLINT
|
const Event Event::CtrlAltC = Event::Special("\x1b\x03"); // NOLINT
|
||||||
const Event Event::CtrlAltD = Event::Special("\x1b\x04"); // NOLINT
|
const Event Event::CtrlAltD = Event::Special("\x1b\x04"); // NOLINT
|
||||||
const Event Event::CtrlAltE = Event::Special("\x1b\x05"); // NOLINT
|
const Event Event::CtrlAltE = Event::Special("\x1b\x05"); // NOLINT
|
||||||
const Event Event::CtrlAltF = Event::Special("\x1b\x06"); // NOLINT
|
const Event Event::CtrlAltF = Event::Special("\x1b\x06"); // NOLINT
|
||||||
const Event Event::CtrlAltG = Event::Special("\x1b\x07"); // NOLINT
|
const Event Event::CtrlAltG = Event::Special("\x1b\x07"); // NOLINT
|
||||||
const Event Event::CtrlAltH = Event::Special("\x1b\x08"); // NOLINT
|
const Event Event::CtrlAltH = Event::Special("\x1b\x08"); // NOLINT
|
||||||
const Event Event::CtrlAltI = Event::Special("\x1b\x09"); // NOLINT
|
const Event Event::CtrlAltI = Event::Special("\x1b\x09"); // NOLINT
|
||||||
const Event Event::CtrlAltJ = Event::Special("\x1b\x0a"); // NOLINT
|
const Event Event::CtrlAltJ = Event::Special("\x1b\x0a"); // NOLINT
|
||||||
const Event Event::CtrlAltK = Event::Special("\x1b\x0b"); // NOLINT
|
const Event Event::CtrlAltK = Event::Special("\x1b\x0b"); // NOLINT
|
||||||
const Event Event::CtrlAltL = Event::Special("\x1b\x0c"); // NOLINT
|
const Event Event::CtrlAltL = Event::Special("\x1b\x0c"); // NOLINT
|
||||||
const Event Event::CtrlAltM = Event::Special("\x1b\x0d"); // NOLINT
|
const Event Event::CtrlAltM = Event::Special("\x1b\x0d"); // NOLINT
|
||||||
const Event Event::CtrlAltN = Event::Special("\x1b\x0e"); // NOLINT
|
const Event Event::CtrlAltN = Event::Special("\x1b\x0e"); // NOLINT
|
||||||
const Event Event::CtrlAltO = Event::Special("\x1b\x0f"); // NOLINT
|
const Event Event::CtrlAltO = Event::Special("\x1b\x0f"); // NOLINT
|
||||||
const Event Event::CtrlAltP = Event::Special("\x1b\x10"); // NOLINT
|
const Event Event::CtrlAltP = Event::Special("\x1b\x10"); // NOLINT
|
||||||
const Event Event::CtrlAltQ = Event::Special("\x1b\x11"); // NOLINT
|
const Event Event::CtrlAltQ = Event::Special("\x1b\x11"); // NOLINT
|
||||||
const Event Event::CtrlAltR = Event::Special("\x1b\x12"); // NOLINT
|
const Event Event::CtrlAltR = Event::Special("\x1b\x12"); // NOLINT
|
||||||
const Event Event::CtrlAltS = Event::Special("\x1b\x13"); // NOLINT
|
const Event Event::CtrlAltS = Event::Special("\x1b\x13"); // NOLINT
|
||||||
const Event Event::CtrlAltT = Event::Special("\x1b\x14"); // NOLINT
|
const Event Event::CtrlAltT = Event::Special("\x1b\x14"); // NOLINT
|
||||||
const Event Event::CtrlAltU = Event::Special("\x1b\x15"); // NOLINT
|
const Event Event::CtrlAltU = Event::Special("\x1b\x15"); // NOLINT
|
||||||
const Event Event::CtrlAltV = Event::Special("\x1b\x16"); // NOLINT
|
const Event Event::CtrlAltV = Event::Special("\x1b\x16"); // NOLINT
|
||||||
const Event Event::CtrlAltW = Event::Special("\x1b\x17"); // NOLINT
|
const Event Event::CtrlAltW = Event::Special("\x1b\x17"); // NOLINT
|
||||||
const Event Event::CtrlAltX = Event::Special("\x1b\x18"); // NOLINT
|
const Event Event::CtrlAltX = Event::Special("\x1b\x18"); // NOLINT
|
||||||
const Event Event::CtrlAltY = Event::Special("\x1b\x19"); // NOLINT
|
const Event Event::CtrlAltY = Event::Special("\x1b\x19"); // NOLINT
|
||||||
const Event Event::CtrlAltZ = Event::Special("\x1b\x1a"); // NOLINT
|
const Event Event::CtrlAltZ = Event::Special("\x1b\x1a"); // NOLINT
|
||||||
|
|
||||||
} // namespace ftxui
|
} // namespace ftxui
|
||||||
|
@ -559,7 +559,6 @@ Closure ScreenInteractive::WithRestoredIO(Closure fn) { // NOLINT
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// @brief Force FTXUI to handle or not handle Ctrl-C, even if the component
|
/// @brief Force FTXUI to handle or not handle Ctrl-C, even if the component
|
||||||
/// catches the Event::CtrlC.
|
/// catches the Event::CtrlC.
|
||||||
void ScreenInteractive::ForceHandleCtrlC(bool force) {
|
void ScreenInteractive::ForceHandleCtrlC(bool force) {
|
||||||
@ -580,7 +579,6 @@ ScreenInteractive* ScreenInteractive::Active() {
|
|||||||
|
|
||||||
// private
|
// private
|
||||||
void ScreenInteractive::Install() {
|
void ScreenInteractive::Install() {
|
||||||
|
|
||||||
frame_valid_ = false;
|
frame_valid_ = false;
|
||||||
|
|
||||||
// Flush the buffer for stdout to ensure whatever the user has printed before
|
// Flush the buffer for stdout to ensure whatever the user has printed before
|
||||||
@ -672,9 +670,9 @@ void ScreenInteractive::Install() {
|
|||||||
terminal.c_lflag &= ~IEXTEN; // Disable extended input processing
|
terminal.c_lflag &= ~IEXTEN; // Disable extended input processing
|
||||||
terminal.c_cflag |= CS8; // 8 bits per byte
|
terminal.c_cflag |= CS8; // 8 bits per byte
|
||||||
|
|
||||||
terminal.c_cc[VMIN] = 0; // Minimum number of characters for non-canonical
|
terminal.c_cc[VMIN] = 0; // Minimum number of characters for non-canonical
|
||||||
// read.
|
// read.
|
||||||
terminal.c_cc[VTIME] = 0; // Timeout in deciseconds for non-canonical read.
|
terminal.c_cc[VTIME] = 0; // Timeout in deciseconds for non-canonical read.
|
||||||
|
|
||||||
tcsetattr(STDIN_FILENO, TCSANOW, &terminal);
|
tcsetattr(STDIN_FILENO, TCSANOW, &terminal);
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ TerminalInputParser::Output TerminalInputParser::Parse() {
|
|||||||
if (!Eat()) {
|
if (!Eat()) {
|
||||||
return UNCOMPLETED;
|
return UNCOMPLETED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Current() == '\x1B') {
|
if (Current() == '\x1B') {
|
||||||
return ParseESC();
|
return ParseESC();
|
||||||
}
|
}
|
||||||
@ -285,8 +285,7 @@ TerminalInputParser::Output TerminalInputParser::ParseESC() {
|
|||||||
case '*':
|
case '*':
|
||||||
case '+':
|
case '+':
|
||||||
case 'O':
|
case 'O':
|
||||||
case 'N':
|
case 'N': {
|
||||||
{
|
|
||||||
if (!Eat()) {
|
if (!Eat()) {
|
||||||
return UNCOMPLETED;
|
return UNCOMPLETED;
|
||||||
}
|
}
|
||||||
|
@ -353,8 +353,8 @@ TEST(Event, Control) {
|
|||||||
continue;
|
continue;
|
||||||
cases.push_back({char(i), false});
|
cases.push_back({char(i), false});
|
||||||
}
|
}
|
||||||
cases.push_back({char(24), true});
|
cases.push_back({char(24), false});
|
||||||
cases.push_back({char(26), true});
|
cases.push_back({char(26), false});
|
||||||
cases.push_back({char(127), false});
|
cases.push_back({char(127), false});
|
||||||
|
|
||||||
for (auto test : cases) {
|
for (auto test : cases) {
|
||||||
@ -386,12 +386,9 @@ TEST(Event, Special) {
|
|||||||
Event expected;
|
Event expected;
|
||||||
} kTestCase[] = {
|
} kTestCase[] = {
|
||||||
// Arrow (default cursor mode)
|
// Arrow (default cursor mode)
|
||||||
{str("\x1B[A"), Event::ArrowUp},
|
{str("\x1B[A"), Event::ArrowUp}, {str("\x1B[B"), Event::ArrowDown},
|
||||||
{str("\x1B[B"), Event::ArrowDown},
|
{str("\x1B[C"), Event::ArrowRight}, {str("\x1B[D"), Event::ArrowLeft},
|
||||||
{str("\x1B[C"), Event::ArrowRight},
|
{str("\x1B[H"), Event::Home}, {str("\x1B[F"), Event::End},
|
||||||
{str("\x1B[D"), Event::ArrowLeft},
|
|
||||||
{str("\x1B[H"), Event::Home},
|
|
||||||
{str("\x1B[F"), Event::End},
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
// Arrow (application cursor mode)
|
// Arrow (application cursor mode)
|
||||||
|
@ -828,7 +828,7 @@ void Canvas::DrawPixel(int x, int y, const Pixel& p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Draw a predefined image, with top-left corner at the given coordinate
|
/// @brief Draw a predefined image, with top-left corner at the given coordinate
|
||||||
/// You can supply negative coordinates to align the image however you like -
|
/// You can supply negative coordinates to align the image however you like -
|
||||||
/// only the 'visible' portion will be drawn
|
/// only the 'visible' portion will be drawn
|
||||||
/// @param x the x coordinate corresponding to the top-left corner of the image.
|
/// @param x the x coordinate corresponding to the top-left corner of the image.
|
||||||
/// @param y the y coordinate corresponding to the top-left corner of the image.
|
/// @param y the y coordinate corresponding to the top-left corner of the image.
|
||||||
|
@ -10,17 +10,16 @@
|
|||||||
#include <utility> // for pair
|
#include <utility> // for pair
|
||||||
|
|
||||||
#include "ftxui/screen/image.hpp"
|
#include "ftxui/screen/image.hpp"
|
||||||
#include "ftxui/screen/string.hpp" // for string_width
|
#include "ftxui/screen/string.hpp" // for string_width
|
||||||
|
|
||||||
namespace ftxui {
|
namespace ftxui {
|
||||||
|
|
||||||
namespace
|
namespace {
|
||||||
{
|
Pixel& dev_null_pixel() {
|
||||||
Pixel& dev_null_pixel() {
|
static Pixel pixel;
|
||||||
static Pixel pixel;
|
return pixel;
|
||||||
return pixel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
Image::Image(int dimx, int dimy)
|
Image::Image(int dimx, int dimy)
|
||||||
: stencil{0, dimx - 1, 0, dimy - 1},
|
: stencil{0, dimx - 1, 0, dimy - 1},
|
||||||
|
@ -391,9 +391,9 @@ Screen::Screen(int dimx, int dimy) : Image{dimx, dimy} {
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
// The placement of this call is a bit weird, however we can assume that
|
// The placement of this call is a bit weird, however we can assume that
|
||||||
// anybody who instantiates a Screen object eventually wants to output
|
// anybody who instantiates a Screen object eventually wants to output
|
||||||
// something to the console. If that is not the case, use an instance of Image instead.
|
// something to the console. If that is not the case, use an instance of Image
|
||||||
// As we require UTF8 for all input/output operations we will just switch to
|
// instead. As we require UTF8 for all input/output operations we will just
|
||||||
// UTF8 encoding here
|
// switch to UTF8 encoding here
|
||||||
SetConsoleOutputCP(CP_UTF8);
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
SetConsoleCP(CP_UTF8);
|
SetConsoleCP(CP_UTF8);
|
||||||
WindowsEmulateVT100Terminal();
|
WindowsEmulateVT100Terminal();
|
||||||
|
Loading…
Reference in New Issue
Block a user