move validators and metas to their respective modules
This commit is contained in:
@@ -1,13 +1,22 @@
|
||||
'''One layer isn't enough. Adds keys to get to more of them'''
|
||||
from kmk.key_validators import layer_key_validator
|
||||
from kmk.keys import KC, make_argumented_key
|
||||
from kmk.modules.holdtap import ActivationType, HoldTap
|
||||
from kmk.types import HoldTapKeyMeta
|
||||
from kmk.modules.holdtap import ActivationType, HoldTap, HoldTapKeyMeta
|
||||
from kmk.utils import Debug
|
||||
|
||||
debug = Debug(__name__)
|
||||
|
||||
|
||||
def layer_key_validator(layer, kc=None):
|
||||
'''
|
||||
Validates the syntax (but not semantics) of a layer key call. We won't
|
||||
have access to the keymap here, so we can't verify much of anything useful
|
||||
here (like whether the target layer actually exists). The spirit of this
|
||||
existing is mostly that Python will catch extraneous args/kwargs and error
|
||||
out.
|
||||
'''
|
||||
return LayerKeyMeta(layer, kc)
|
||||
|
||||
|
||||
def layer_key_validator_lt(layer, kc, prefer_hold=False, **kwargs):
|
||||
return HoldTapKeyMeta(tap=kc, hold=KC.MO(layer), prefer_hold=prefer_hold, **kwargs)
|
||||
|
||||
@@ -18,6 +27,12 @@ def layer_key_validator_tt(layer, prefer_hold=True, **kwargs):
|
||||
)
|
||||
|
||||
|
||||
class LayerKeyMeta:
|
||||
def __init__(self, layer, kc=None):
|
||||
self.layer = layer
|
||||
self.kc = kc
|
||||
|
||||
|
||||
class Layers(HoldTap):
|
||||
'''Gives access to the keys used to enable the layer system'''
|
||||
|
||||
|
Reference in New Issue
Block a user