Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shifted sequences #122

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
33 changes: 32 additions & 1 deletion src/action.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
//! The different actions that can be done.
//! The different actions that can be executed via any given key.

use crate::key_code::KeyCode;
use crate::layout::{StackedIter, WaitingAction};
use core::fmt::Debug;

/// The different types of actions we support for key sequences/macros
#[non_exhaustive]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub enum SequenceEvent<K: 'static> {
/// No operation action: just do nothing (a placeholder).
NoOp,
/// A keypress/keydown
Press(K),
/// Key release/keyup
Release(K),
/// A shortcut for `Press(K), Release(K)`
Tap(K),
/// For sequences that need to wait a bit before continuing
Delay {
/// How long (in ticks) this Delay will last
duration: u32, // NOTE: This isn't a u16 because that's only max ~65 seconds (assuming 1000 ticks/sec)
},
/// Cancels the running sequence and can be used to mark the end of a sequence
/// instead of using a number of Release() events
Complete,
/// If those keys are pressed, release them
Filter(&'static &'static [K]),
/// Restore keys if they were previously Filter-ed
Restore,
}

/// Behavior configuration of HoldTap.
#[non_exhaustive]
#[derive(Clone, Copy)]
Expand Down Expand Up @@ -198,6 +224,11 @@ where
DefaultLayer(usize),
/// Perform different actions on key hold/tap (see [`HoldTapAction`]).
HoldTap(&'static HoldTapAction<T, K>),
/// A sequence of SequenceEvents
Sequence(
/// An array of SequenceEvents that will be triggered (in order)
&'static &'static [SequenceEvent<K>],
),
/// Custom action.
///
/// Define a user defined action. This enum can be anything you
Expand Down
Loading