Skip to main content

Context

Trait Context 

pub trait Context: Clone + Copy {
    type Event;

    // Required methods
    fn handle_event(
        &mut self,
        event: Event<Self::Event>,
    ) -> KeyEvents<Self::Event>;
    fn reset(&mut self);
}
Expand description

Used to provide state that may affect behaviour when pressing the key.

e.g. the behaviour of layered::LayeredKey depends on which layers are active in layered::Context.

Required Associated Types§

type Event

The type of Event the context handles.

Required Methods§

fn handle_event(&mut self, event: Event<Self::Event>) -> KeyEvents<Self::Event>

Used to update the Context’s state.

fn reset(&mut self)

Restore runtime state from this context’s keymap config.

Config data (timeouts, chords, …) is preserved; ephemeral state (active layers, sticky mods, queues, …) is cleared.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

§

impl Context for smart_keymap::key::caps_word::Context

§

type Event = Event

§

impl Context for smart_keymap::key::key_lock::Context

§

type Event = Event

§

impl Context for smart_keymap::key::keyboard::Context

§

type Event = Event

§

impl Context for smart_keymap::key::mod_conditioned::Context

§

type Event = Event

§

impl Context for smart_keymap::key::sticky::Context

§

type Event = Event

§

impl Context for smart_keymap::key::tri_state::Context

§

type Event = Event

Source§

impl Context for smart_keymap::init::key_system::Context

§

impl<const ALT_REPEAT_RULE_COUNT: usize> Context for smart_keymap::key::history::Context<ALT_REPEAT_RULE_COUNT>

§

type Event = Event

§

impl<const INSTRUCTION_COUNT: usize> Context for smart_keymap::key::automation::Context<INSTRUCTION_COUNT>

§

type Event = Event

§

impl<const LAYER_COUNT: usize, const CONDITIONAL_LAYER_COUNT: usize> Context for smart_keymap::key::layered::Context<LAYER_COUNT, CONDITIONAL_LAYER_COUNT>

§

impl<const MAX_CHORDS: usize, const MAX_CHORD_SIZE: usize, const MAX_PRESSED_INDICES: usize> Context for smart_keymap::key::chorded::Context<MAX_CHORDS, MAX_CHORD_SIZE, MAX_PRESSED_INDICES>

§

type Event = Event

§

impl<const MAX_SEQUENCES: usize, const MAX_SEQUENCE_LEN: usize> Context for smart_keymap::key::sequence::Context<MAX_SEQUENCES, MAX_SEQUENCE_LEN>

§

type Event = Event