ttx 0.1.0
Loading...
Searching...
No Matches
key_event_io.h
Go to the documentation of this file.
1#pragma once
2
3#include "di/reflect/prelude.h"
4#include "di/util/bitwise_enum.h"
6#include "ttx/key_event.h"
7#include "ttx/params.h"
8
9namespace ttx {
10// Application cursor keys mode. This controls whether to report the certain
11// keys using a CSI or SS3 when no modifiers are needed. For instance,
12// when enabled, the home key is reported as: SS3 H. While when not enabled,
13// the home key is reported as CSI H.
18
19constexpr auto tag_invoke(di::Tag<di::reflect>, di::InPlaceType<ApplicationCursorKeysMode>) {
21 return di::make_enumerators<"ApplicationCursorKeysMode">(di::enumerator<"Disabled", Disabled>,
22 di::enumerator<"Enabled", Enabled>);
23}
24
25// Key reporting flags from Kitty keyboard protocol:
26// https://sw.kovidgoyal.net/kitty/keyboard-protocol/#progressive-enhancement
36
37DI_DEFINE_ENUM_BITWISE_OPERATIONS(KeyReportingFlags)
38
39constexpr auto tag_invoke(di::Tag<di::reflect>, di::InPlaceType<KeyReportingFlags>) {
40 using enum KeyReportingFlags;
41 return di::make_enumerators<"KeyReportingFlags">(
42 di::enumerator<"None", None>, di::enumerator<"Disambiguate", Disambiguate>,
43 di::enumerator<"ReportEventTypes", ReportEventTypes>,
44 di::enumerator<"ReportAlternateKeys", ReportAlternateKeys>,
45 di::enumerator<"ReportAllKeysAsEscapeCodes", ReportAllKeysAsEscapeCodes>,
46 di::enumerator<"ReportAssociatedText", ReportAssociatedText>);
47}
48
49auto serialize_key_event(KeyEvent const& event, ApplicationCursorKeysMode cursor_key_mode, KeyReportingFlags flags)
50 -> di::Optional<di::String>;
51
52auto key_event_from_legacy_code_point(c32 code_point, Modifiers base_modifiers = Modifiers::None) -> KeyEvent;
53auto key_event_from_csi(CSI const& csi) -> di::Optional<KeyEvent>;
54}
Definition cursor_style.h:5
auto key_event_from_csi(CSI const &csi) -> di::Optional< KeyEvent >
Definition key_event_io.cpp:623
KeyReportingFlags
Definition key_event_io.h:27
@ ReportAssociatedText
Definition key_event_io.h:33
@ ReportAllKeysAsEscapeCodes
Definition key_event_io.h:32
@ All
Definition key_event_io.h:34
@ Disambiguate
Definition key_event_io.h:29
@ ReportEventTypes
Definition key_event_io.h:30
@ ReportAlternateKeys
Definition key_event_io.h:31
Modifiers
Definition modifiers.h:9
@ None
Definition modifiers.h:10
@ None
Definition direction.h:8
constexpr auto tag_invoke(di::Tag< di::reflect >, di::InPlaceType< CursorStyle >)
Definition cursor_style.h:16
ApplicationCursorKeysMode
Definition key_event_io.h:14
auto key_event_from_legacy_code_point(c32 code_point, Modifiers base_modifiers=Modifiers::None) -> KeyEvent
Definition key_event_io.cpp:572
@ Enabled
Definition focus_event_io.h:12
@ Disabled
Definition focus_event_io.h:11
auto serialize_key_event(KeyEvent const &event, ApplicationCursorKeysMode cursor_key_mode, KeyReportingFlags flags) -> di::Optional< di::String >
Definition key_event_io.cpp:453