lib: add modificators to the lib
This commit is contained in:
parent
f823ebd2ba
commit
9e3e4b8345
2 changed files with 79 additions and 1 deletions
|
@ -2,9 +2,10 @@
|
|||
|
||||
let
|
||||
types = import ./types.nix { inherit lib nix2lua; };
|
||||
mod = import ./mod.nix { inherit lib; };
|
||||
in
|
||||
lib // {
|
||||
inherit nix2lua;
|
||||
inherit nix2lua mod;
|
||||
|
||||
types = lib.types // types;
|
||||
}
|
||||
|
|
77
lib/mod.nix
Normal file
77
lib/mod.nix
Normal file
|
@ -0,0 +1,77 @@
|
|||
{ lib }:
|
||||
|
||||
let
|
||||
inherit (builtins) listToAttrs;
|
||||
inherit (lib) nameValuePair toLower;
|
||||
|
||||
wrap = val: "<${val}>";
|
||||
|
||||
char = num: wrap "Char-${num}"; # map a character by its decimal, octal or hexadecimal number
|
||||
shift = key: wrap "S-${key}"; # shift-key *shift* *<S-*
|
||||
ctrl = key: wrap "C-${key}"; # control-key *control* *ctrl* *<C-*
|
||||
meta = key: wrap "M-${key}"; # alt-key or meta-key *META* *ALT* *<M-*
|
||||
super = key: wrap "D-${key}"; # command-key or "super" key *<D-*
|
||||
|
||||
keys = listToAttrs (map (v: nameValuePair v (wrap (toLower v))) (
|
||||
[
|
||||
"leader"
|
||||
"localLeader"
|
||||
"cmd"
|
||||
"plug"
|
||||
"mouseMove"
|
||||
|
||||
"nul"
|
||||
"bs"
|
||||
"tab"
|
||||
"nl"
|
||||
"cr"
|
||||
"esc"
|
||||
"space"
|
||||
"lt"
|
||||
"bslash"
|
||||
"bar"
|
||||
"del"
|
||||
"csi"
|
||||
"eol"
|
||||
"ignore"
|
||||
"nop"
|
||||
"up"
|
||||
"down"
|
||||
"left"
|
||||
"right"
|
||||
"help"
|
||||
"undo"
|
||||
"insert"
|
||||
"home"
|
||||
"end"
|
||||
"pageUp"
|
||||
"pageDown"
|
||||
"kUp"
|
||||
"kDown"
|
||||
"kLeft"
|
||||
"kRight"
|
||||
"kHome"
|
||||
"kEnd"
|
||||
"kOrigin"
|
||||
"kPageUp"
|
||||
"kPageDown"
|
||||
"kDel"
|
||||
"kPlus"
|
||||
"kMinus"
|
||||
"kMultiply"
|
||||
"kDivide"
|
||||
"kPoint"
|
||||
"kComma"
|
||||
"kEqual"
|
||||
"kEnter"
|
||||
]
|
||||
++ map (n: "F${toString n}") (lib.range 1 12)
|
||||
++ map (n: "k${toString n}") (lib.range 0 9)
|
||||
)
|
||||
);
|
||||
in
|
||||
{ inherit char shift ctrl meta super; } // keys // {
|
||||
return = keys.cr;
|
||||
enter = keys.cr;
|
||||
backslash = keys.bslash;
|
||||
}
|
Loading…
Reference in a new issue