Skip to content

Commit 1bec1b0

Browse files
committed
layout: document SequenceState and State::FakeKey
1 parent 644d19c commit 1bec1b0

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

src/layout.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,22 @@ impl<T> CustomEvent<T> {
183183

184184
#[derive(Debug, Eq, PartialEq)]
185185
enum State<T: 'static, K: 'static + Copy> {
186-
NormalKey { keycode: K, coord: (u8, u8) },
187-
LayerModifier { value: usize, coord: (u8, u8) },
188-
Custom { value: &'static T, coord: (u8, u8) },
189-
FakeKey { keycode: K }, // Fake key event for sequences
186+
NormalKey {
187+
keycode: K,
188+
coord: (u8, u8),
189+
},
190+
LayerModifier {
191+
value: usize,
192+
coord: (u8, u8),
193+
},
194+
Custom {
195+
value: &'static T,
196+
coord: (u8, u8),
197+
},
198+
/// Fake key event for sequences
199+
FakeKey {
200+
keycode: K,
201+
},
190202
}
191203
impl<T: 'static, K: 'static + Copy> Copy for State<T, K> {}
192204
impl<T: 'static, K: 'static + Copy> Clone for State<T, K> {
@@ -215,6 +227,7 @@ impl<T: 'static, K: 'static + Copy + Eq> State<T, K> {
215227
_ => Some(*self),
216228
}
217229
}
230+
/// Return whether the state is a [`State::FakeKey`] with keycode `kc`.
218231
fn seq_release(&self, kc: K) -> Option<Self> {
219232
match *self {
220233
FakeKey { keycode, .. } if keycode == kc => None,
@@ -314,10 +327,15 @@ impl<'a> Iterator for StackedIter<'a> {
314327

315328
#[derive(Debug, Copy, Clone)]
316329
struct SequenceState<K: 'static> {
330+
/// Current event being processed
317331
cur_event: Option<SequenceEvent<K>>,
318-
delay: u32, // Keeps track of SequenceEvent::Delay time remaining
319-
tapped: Option<K>, // Keycode of a key that should be released at the next tick
332+
/// Remaining events to process
320333
remaining_events: &'static [SequenceEvent<K>],
334+
/// Keeps track of SequenceEvent::Delay time remaining
335+
delay: u32,
336+
/// Keycode of a key that should be released at the next tick
337+
tapped: Option<K>,
338+
321339
}
322340

323341
/// An event, waiting in a stack to be processed.

0 commit comments

Comments
 (0)