diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2026-09-22 22:47:33 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2026-09-22 22:47:33 +0200 |
| commit | d05b9343f69a0841043963088e0003368e205bd9 (patch) | |
| tree | 8cde07ff86d27cbc808a0a149b89d0024b4a586c /ttwhy/scanners/terminal_events.cppm | |
| parent | 22f6534081acfabdab4956d337604a21e7da5b64 (diff) | |
| download | ttwhy-d05b9343f69a0841043963088e0003368e205bd9.tar.xz ttwhy-d05b9343f69a0841043963088e0003368e205bd9.zip | |
Diffstat (limited to 'ttwhy/scanners/terminal_events.cppm')
| -rw-r--r-- | ttwhy/scanners/terminal_events.cppm | 100 |
1 files changed, 0 insertions, 100 deletions
diff --git a/ttwhy/scanners/terminal_events.cppm b/ttwhy/scanners/terminal_events.cppm deleted file mode 100644 index 3e4c849..0000000 --- a/ttwhy/scanners/terminal_events.cppm +++ /dev/null @@ -1,100 +0,0 @@ -module; - -#include <cstdint> -#include <utility> -#include <variant> - -export module ttwhy.scanners:terminal_events; - -export namespace ttwhy::scanners -{ - enum struct control_key : std::uint8_t - { - enter, - escape, - tab, - backspace, - }; - - enum struct navigation_key : std::uint8_t - { - up, - down, - left, - right, - home, - end, - delete_key, - insert_key, - page_up, - page_down, - }; - - enum struct modifier : std::uint8_t - { - none = 0, - shift = 1, - alt = 2, - ctrl = 4, - meta = 8, - }; - - enum struct modifier_set : std::uint8_t - { - }; - - constexpr auto operator|(modifier lhs, modifier rhs) -> modifier_set - { - return static_cast<modifier_set>(std::to_underlying(lhs) | std::to_underlying(rhs)); - } - - constexpr auto operator|(modifier_set lhs, modifier rhs) -> modifier_set - { - return static_cast<modifier_set>(std::to_underlying(lhs) | std::to_underlying(rhs)); - } - - constexpr auto operator&(modifier lhs, modifier rhs) -> modifier_set - { - return static_cast<modifier_set>(std::to_underlying(lhs) & std::to_underlying(rhs)); - } - - constexpr auto operator&(modifier_set lhs, modifier rhs) -> modifier_set - { - return static_cast<modifier_set>(std::to_underlying(lhs) & std::to_underlying(rhs)); - } - - template<std::same_as<modifier>... Modifier> - constexpr auto has_all(modifier_set mask, Modifier... flag) -> bool - { - return (true && ... && (mask & flag)); - } - - template<std::same_as<modifier>... Modifier> - constexpr auto has_any(modifier_set mask, Modifier... flag) -> bool - { - return (false || ... || (mask & flag)); - } - - struct character_event - { - char value{}; - }; - - struct control_event - { - control_key key{}; - }; - - struct navigation_event - { - navigation_key key{}; - modifier_set modifiers{}; - }; - - struct ctrl_chord_event - { - char key{}; - }; - - using input_event = std::variant<character_event, control_event, navigation_event, ctrl_chord_event>; -} // namespace ttwhy::scanners |
