move validators and metas to their respective modules

This commit is contained in:
xs5871
2022-07-21 15:50:30 +00:00
committed by Kyle Brown
parent e0ca1124fb
commit 5a85c6cfb3
7 changed files with 58 additions and 64 deletions

View File

@@ -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'''