mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-23 03:10:01 +08:00
Added Home, End, PageUp, PageDown events.
Added handling for Home and End for input component
This commit is contained in:
parent
a6c692edcf
commit
160b1c8bbc
@ -44,6 +44,12 @@ struct Event {
|
|||||||
static const Event TabReverse;
|
static const Event TabReverse;
|
||||||
static const Event F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12;
|
static const Event F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12;
|
||||||
|
|
||||||
|
static const Event Home;
|
||||||
|
static const Event End;
|
||||||
|
|
||||||
|
static const Event PageUp;
|
||||||
|
static const Event PageDown;
|
||||||
|
|
||||||
// --- Custom ---
|
// --- Custom ---
|
||||||
static Event Custom;
|
static Event Custom;
|
||||||
|
|
||||||
@ -53,6 +59,7 @@ struct Event {
|
|||||||
const std::string& input() const { return input_; }
|
const std::string& input() const { return input_; }
|
||||||
|
|
||||||
bool operator==(const Event& other) const { return input_ == other.input_; }
|
bool operator==(const Event& other) const { return input_ == other.input_; }
|
||||||
|
bool operator!=(const Event& other) const { return !operator==(other); }
|
||||||
|
|
||||||
//--- State section ----------------------------------------------------------
|
//--- State section ----------------------------------------------------------
|
||||||
private:
|
private:
|
||||||
|
@ -62,6 +62,11 @@ const Event Event::F9 = Event::Special("\x1B[20~");
|
|||||||
const Event Event::F10 = Event::Special("\x1B[21~");
|
const Event Event::F10 = Event::Special("\x1B[21~");
|
||||||
const Event Event::F11 = Event::Special("\x1B[21~"); // Doesn't exist
|
const Event Event::F11 = Event::Special("\x1B[21~"); // Doesn't exist
|
||||||
const Event Event::F12 = Event::Special("\x1B[24~");
|
const Event Event::F12 = Event::Special("\x1B[24~");
|
||||||
|
const Event Event::Home = Event::Special({27, 91, 72});
|
||||||
|
const Event Event::End = Event::Special({27, 91, 70});
|
||||||
|
const Event Event::PageUp = Event::Special({27, 91, 53, 126});
|
||||||
|
const Event Event::PageDown = Event::Special({27, 91, 54, 126});
|
||||||
|
|
||||||
Event Event::Custom = Event::Special({0});
|
Event Event::Custom = Event::Special({0});
|
||||||
|
|
||||||
} // namespace ftxui
|
} // namespace ftxui
|
||||||
|
@ -85,6 +85,16 @@ bool Input::OnEvent(Event event) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event == Event::Home) {
|
||||||
|
cursor_position = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event == Event::End) {
|
||||||
|
cursor_position = (int)content.size();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Content
|
// Content
|
||||||
if (event.is_character()) {
|
if (event.is_character()) {
|
||||||
content.insert(cursor_position, 1, event.character());
|
content.insert(cursor_position, 1, event.character());
|
||||||
|
Loading…
Reference in New Issue
Block a user