Featre: Support ctrl+arrow in input. (#494)

CTRL+LEFT: Move the cursor to the beginning of the word.
CTRL+RIGHT: Move the cursor to the beginning of the word.

This was requested by:
https://github.com/ArthurSonzogni/FTXUI/issues/490
This commit is contained in:
Arthur Sonzogni
2022-10-06 21:16:55 +02:00
committed by GitHub
parent ccfe22bc24
commit f4b47333be
8 changed files with 1776 additions and 250 deletions

View File

@@ -38,6 +38,11 @@ struct Event {
static const Event ArrowUp;
static const Event ArrowDown;
static const Event ArrowLeftCtrl;
static const Event ArrowRightCtrl;
static const Event ArrowUpCtrl;
static const Event ArrowDownCtrl;
// --- Other ---
static const Event Backspace;
static const Event Delete;

View File

@@ -26,6 +26,33 @@ int GlyphPosition(const std::string& input,
// Returns the number of glyphs in |input|.
int GlyphCount(const std::string& input);
// Properties from:
// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/WordBreakProperty.txt
enum class WordBreakProperty {
ALetter,
CR,
Double_Quote,
Extend,
ExtendNumLet,
Format,
Hebrew_Letter,
Katakana,
LF,
MidLetter,
MidNum,
MidNumLet,
Newline,
Numeric,
Regional_Indicator,
Single_Quote,
WSegSpace,
ZWJ,
};
std::vector<WordBreakProperty> Utf8ToWordBreakProperty(
const std::string& input);
bool IsWordBreakingCharacter(const std::string& input, size_t glyph_index);
// Map every cells drawn by |input| to their corresponding Glyphs. Half-size
// Glyphs takes one cell, full-size Glyphs take two cells.
std::vector<int> CellToGlyphIndex(const std::string& input);