Fix event const correctness (#56)

This commit is contained in:
Mike Wallio
2020-10-24 10:47:03 -04:00
committed by GitHub
parent d969c74341
commit 1cb08fd606
2 changed files with 39 additions and 39 deletions

View File

@@ -16,7 +16,6 @@ namespace ftxui {
// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
//
struct Event {
public:
// --- Constructor section ---------------------------------------------------
static Event Character(char);
static Event Character(wchar_t);
@@ -27,29 +26,29 @@ struct Event {
static void Convert(Receiver<char>& in, Sender<Event>& out, char c);
// --- Arrow ---
static Event ArrowLeft;
static Event ArrowRight;
static Event ArrowUp;
static Event ArrowDown;
static const Event ArrowLeft;
static const Event ArrowRight;
static const Event ArrowUp;
static const Event ArrowDown;
// --- Other ---
static Event Backspace;
static Event Delete;
static Event Return;
static Event Escape;
static Event Tab;
static Event TabReverse;
static Event F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12;
static const Event Backspace;
static const Event Delete;
static const Event Return;
static const Event Escape;
static const Event Tab;
static const Event TabReverse;
static const Event F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12;
// --- Custom ---
static Event Custom;
//--- Method section ---------------------------------------------------------
bool is_character() { return is_character_; }
wchar_t character() { return character_; }
const std::string& input() { return input_; }
bool is_character() const { return is_character_; }
wchar_t character() const { return character_; }
const std::string& input() const { return input_; }
bool operator==(const Event& other) { return input_ == other.input_; }
bool operator==(const Event& other) const { return input_ == other.input_; }
//--- State section ----------------------------------------------------------
private:
@@ -58,6 +57,7 @@ struct Event {
wchar_t character_ = U'?';
};
} // namespace ftxui
#endif /* end of include guard: FTXUI_COMPONENT_EVENT_HPP */