diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2026-10-26 19:15:33 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2026-10-26 19:15:33 +0100 |
| commit | b051983db21290871c7a33cf8189f415c07f8a24 (patch) | |
| tree | 4258f9fdc05f5eec0341147047d8eb40ea055454 /ttwhy/terminal/events.cppm | |
| parent | 79a35574ce6d472f7a7cc4a200a1ed7befe34066 (diff) | |
| download | ttwhy-b051983db21290871c7a33cf8189f415c07f8a24.tar.xz ttwhy-b051983db21290871c7a33cf8189f415c07f8a24.zip | |
terminal: improve function and control key handling
Diffstat (limited to 'ttwhy/terminal/events.cppm')
| -rw-r--r-- | ttwhy/terminal/events.cppm | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/ttwhy/terminal/events.cppm b/ttwhy/terminal/events.cppm index ce4a7d5..5df397d 100644 --- a/ttwhy/terminal/events.cppm +++ b/ttwhy/terminal/events.cppm @@ -34,6 +34,31 @@ export namespace ttwhy::terminal page_down, }; + //! Represents terminal function keys (F1 through F20). + enum struct function_key : std::uint8_t + { + f1, + f2, + f3, + f4, + f5, + f6, + f7, + f8, + f9, + f10, + f11, + f12, + f13, + f14, + f15, + f16, + f17, + f18, + f19, + f20, + }; + //! Represents individual keyboard modifier keys. enum struct modifier : std::uint8_t { @@ -138,14 +163,23 @@ export namespace ttwhy::terminal char key{}; }; + //! Represents a terminal function key event. + struct function_key_event + { + function_key key{}; + modifier_set modifiers{}; + }; + //! Variant representing any input event produced by a terminal scanner. - using input_event = std::variant<character_event, control_event, navigation_event, ctrl_chord_event>; + using input_event = + std::variant<character_event, control_event, navigation_event, ctrl_chord_event, function_key_event>; //! Validates that a sink can receive all terminal input event types. //! //! @tparam Sink The sink callable type to validate. template<typename Sink> concept event_sink = ttwhy::event_sink<Sink, character_event> && ttwhy::event_sink<Sink, control_event> && - ttwhy::event_sink<Sink, navigation_event>; + ttwhy::event_sink<Sink, navigation_event> && ttwhy::event_sink<Sink, ctrl_chord_event> && + ttwhy::event_sink<Sink, function_key_event>; } // namespace ttwhy::terminal |
