Related: #92 The context is allowing uses to build their own keymaps that mimic nested keymaps, but with slightly different/programmatic behavior.
Potential callbacks per keymap:
- after_match
- after_no_match
- before_match
- before_no_match
Or perhaps just two with context:
- after(context)
- before(context)
context:
Currently @RedBearAK is using a "trigger keymap" to support their deadkeys config:
keymap("Escape actions for dead keys", {
C("a"): [getDK(),C("a"),setDK(None)],
}, when = lambda _: ac_Chr in deadkeys_US)
keymap("Disable Dead Keys",{
# Nothing needs to be here. Tripwire keymap to disable active dead keys keymap(s)
}, when = lambda _: setDK(None)())
First we deal with "escaping" because of normal keypresses, then a fake keymap sets the dead key character to None as the mapper passes over it's conditional to consider if it should be ac active keymap or not. This is all a bit "hacky" and implicit... I'm considering if this should be handled with explicit callbacks:
keymap("Escape actions for dead keys", {
C("a"): [getDK(),C("a"),setDK(None)],
}, when = lambda _: ac_Chr in deadkeys_US,
# disable dead keys after this map is considered
afterConsideration = lambda _: setDK(None)()
)
And of course it's worth mentioning this could all be done inside a single lambda/function as well, though again that's slightly more implicit/hacky... changing state inside a conditional vs it being a "pure" conditional.
Creating this as a discussion topic. I like that we are powerful enough to do this, but I'm not sure we've found the correct abstraction yet - and I worry the current way is going to break in the future when internals change since it's based too much on the internal behavior.
Related: #92 The context is allowing uses to build their own keymaps that mimic nested keymaps, but with slightly different/programmatic behavior.
Potential callbacks per keymap:
Or perhaps just two with context:
context:
match: booleanCurrently @RedBearAK is using a "trigger keymap" to support their deadkeys config:
First we deal with "escaping" because of normal keypresses, then a fake keymap sets the dead key character to None as the mapper passes over it's conditional to consider if it should be ac active keymap or not. This is all a bit "hacky" and implicit... I'm considering if this should be handled with explicit callbacks:
And of course it's worth mentioning this could all be done inside a single lambda/function as well, though again that's slightly more implicit/hacky... changing state inside a conditional vs it being a "pure" conditional.
Creating this as a discussion topic. I like that we are powerful enough to do this, but I'm not sure we've found the correct abstraction yet - and I worry the current way is going to break in the future when internals change since it's based too much on the internal behavior.