xkb_parser/ast/
xkb_compatibility.rs

1use crate::{ast::*, xkb::Rule};
2use derivative::Derivative;
3use pest_ast::FromPest;
4
5#[derive(Derivative, FromPest, Clone, PartialEq)]
6#[derivative(Debug)]
7#[pest_ast(rule(Rule::xkb_compatibility))]
8pub struct XkbCompatibility<'src> {
9    pub name: StringContent<'src>,
10    pub values: Vec<XkbCompatItem<'src>>,
11}
12
13#[derive(Derivative, FromPest, Clone, PartialEq)]
14#[derivative(Debug)]
15#[pest_ast(rule(Rule::xkb_compat_item))]
16pub enum XkbCompatItem<'src> {
17    #[derivative(Debug = "transparent")]
18    Include(Include<'src>),
19    #[derivative(Debug = "transparent")]
20    Override(Override<'src>),
21    #[derivative(Debug = "transparent")]
22    Augment(Augment<'src>),
23
24    #[derivative(Debug = "transparent")]
25    VirtualModifiers(VirtualModifiers<'src>),
26    #[derivative(Debug = "transparent")]
27    CompatSetMods(CompatSetMods<'src>),
28    #[derivative(Debug = "transparent")]
29    CompatLatchMods(CompatLatchMods<'src>),
30    #[derivative(Debug = "transparent")]
31    CompatGroup(CompatGroup<'src>),
32    #[derivative(Debug = "transparent")]
33    CompatInterpretLine(CompatInterpretLine<'src>),
34    #[derivative(Debug = "transparent")]
35    CompatIndicatorLine(CompatIndicatorLine<'src>),
36    #[derivative(Debug = "transparent")]
37    CompatInterpretBlock(CompatInterpretBlock<'src>),
38    #[derivative(Debug = "transparent")]
39    CompatIndicatorBlock(CompatIndicatorBlock<'src>),
40}
41
42#[derive(Derivative, FromPest, Clone, PartialEq)]
43#[derivative(Debug)]
44#[pest_ast(rule(Rule::compat_set_mods))]
45pub struct CompatSetMods<'src> {
46    pub item: Ident<'src>,
47    pub value: Ident<'src>,
48}
49
50#[derive(Derivative, FromPest, Clone, PartialEq)]
51#[derivative(Debug)]
52#[pest_ast(rule(Rule::compat_latch_mods))]
53pub struct CompatLatchMods<'src> {
54    pub item: Ident<'src>,
55    pub value: Ident<'src>,
56}
57
58#[derive(Derivative, FromPest, Clone, PartialEq)]
59#[derivative(Debug)]
60#[pest_ast(rule(Rule::compat_group))]
61pub struct CompatGroup<'src> {
62    pub name: Ident<'src>,
63    pub value: Ident<'src>,
64}
65
66#[derive(Derivative, FromPest, Clone, PartialEq)]
67#[derivative(Debug)]
68#[pest_ast(rule(Rule::compat_interpret_line))]
69pub struct CompatInterpretLine<'src> {
70    pub key: Ident<'src>,
71    pub value: Ident<'src>,
72}
73
74#[derive(Derivative, FromPest, Clone, PartialEq)]
75#[derivative(Debug)]
76#[pest_ast(rule(Rule::compat_indicator_line))]
77pub struct CompatIndicatorLine<'src> {
78    pub key: Ident<'src>,
79    pub value: Ident<'src>,
80}
81
82#[derive(Derivative, FromPest, Clone, PartialEq)]
83#[derivative(Debug)]
84#[pest_ast(rule(Rule::compat_interpret_block))]
85pub struct CompatInterpretBlock<'src> {
86    pub keys: KeyCombo<'src>,
87    pub condition: Option<KeyCombo<'src>>,
88    pub values: Vec<CompatInterpretItem<'src>>,
89}
90
91#[derive(Derivative, FromPest, Clone, PartialEq)]
92#[derivative(Debug)]
93#[pest_ast(rule(Rule::interpret_item))]
94pub enum CompatInterpretItem<'src> {
95    #[derivative(Debug = "transparent")]
96    CompatAction(CompatAction<'src>),
97    #[derivative(Debug = "transparent")]
98    CompatModifier(CompatModifier<'src>),
99    #[derivative(Debug = "transparent")]
100    UseModMapMods(UseModMapMods<'src>),
101}
102
103#[derive(Derivative, FromPest, Clone, PartialEq)]
104#[derivative(Debug)]
105#[pest_ast(rule(Rule::compat_action))]
106pub struct CompatAction<'src> {
107    pub action: Action<'src>,
108}
109
110#[derive(Derivative, FromPest, Clone, PartialEq)]
111#[derivative(Debug)]
112#[pest_ast(rule(Rule::compat_modifier))]
113pub struct CompatModifier<'src> {
114    pub name: Ident<'src>,
115}
116
117#[derive(Derivative, FromPest, Clone, PartialEq)]
118#[derivative(Debug)]
119#[pest_ast(rule(Rule::use_mod_map_mods))]
120pub struct UseModMapMods<'src> {
121    pub name: Ident<'src>,
122}
123
124#[derive(Derivative, FromPest, Clone, PartialEq)]
125#[derivative(Debug)]
126#[pest_ast(rule(Rule::compat_indicator_block))]
127pub struct CompatIndicatorBlock<'src> {
128    pub name: StringContent<'src>,
129    pub values: Vec<IndicatorItem<'src>>,
130}
131
132#[derive(Derivative, FromPest, Clone, PartialEq)]
133#[derivative(Debug)]
134#[pest_ast(rule(Rule::indicator_item))]
135pub enum IndicatorItem<'src> {
136    #[derivative(Debug = "transparent")]
137    IndicatorNegation(IndicatorNegation<'src>),
138    #[derivative(Debug = "transparent")]
139    AllowExplicit(AllowExplicit),
140    #[derivative(Debug = "transparent")]
141    IndicatorDrivesKeyboard(IndicatorDrivesKeyboard),
142    #[derivative(Debug = "transparent")]
143    IndicatorControls(IndicatorControls<'src>),
144    #[derivative(Debug = "transparent")]
145    WhichModState(WhichModState<'src>),
146    #[derivative(Debug = "transparent")]
147    IndicatorModifiers(IndicatorModifiers<'src>),
148    #[derivative(Debug = "transparent")]
149    IndicatorGroups(IndicatorGroups<'src>),
150}
151
152#[derive(Derivative, FromPest, Clone, PartialEq)]
153#[derivative(Debug)]
154#[pest_ast(rule(Rule::indicator_negation))]
155pub struct IndicatorNegation<'src> {
156    pub name: Negation<'src>,
157}
158
159#[derive(Derivative, FromPest, Clone, PartialEq)]
160#[derivative(Debug)]
161#[pest_ast(rule(Rule::allow_explicit))]
162pub struct AllowExplicit;
163
164#[derive(Derivative, FromPest, Clone, PartialEq)]
165#[derivative(Debug)]
166#[pest_ast(rule(Rule::indicator_drives_keyboard))]
167pub struct IndicatorDrivesKeyboard;
168
169#[derive(Derivative, FromPest, Clone, PartialEq)]
170#[derivative(Debug)]
171#[pest_ast(rule(Rule::indicator_controls))]
172pub struct IndicatorControls<'src> {
173    pub name: Ident<'src>,
174}
175
176#[derive(Derivative, FromPest, Clone, PartialEq)]
177#[derivative(Debug)]
178#[pest_ast(rule(Rule::which_mod_state))]
179pub struct WhichModState<'src> {
180    pub name: Ident<'src>,
181}
182
183#[derive(Derivative, FromPest, Clone, PartialEq)]
184#[derivative(Debug)]
185#[pest_ast(rule(Rule::indicator_modifiers))]
186pub struct IndicatorModifiers<'src> {
187    pub name: Ident<'src>,
188}
189
190#[derive(Derivative, FromPest, Clone, PartialEq)]
191#[derivative(Debug)]
192#[pest_ast(rule(Rule::indicator_groups))]
193pub struct IndicatorGroups<'src> {
194    pub name: Ident<'src>,
195}