Skip to content

Commit

Permalink
keybindings configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq committed Nov 7, 2015
1 parent ff327f8 commit e7bb456
Show file tree
Hide file tree
Showing 6 changed files with 413 additions and 194 deletions.
17 changes: 17 additions & 0 deletions api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,20 @@ proc setupApi(result: PEvalContext; ed: Editor) =
ed.main.saveAs(getString(a, 0))
expose defineAlias:
ed.con.aliases.add((getString(a, 0), getString(a, 1)))


result.registerCallback "nimedit.keydefs.bindKey",
proc (a: VmArgs) =
let keyset = getNode(a, 0)
doAssert keyset.kind == nkCurly
var bitset: set[Key] = {}
for n in keyset:
if n.kind in {nkCharLit..nkUInt64Lit} and n.intVal >= 0 and
n.intVal <= int(high(Key)):
bitset.incl n.intVal.Key
else:
doAssert false
let action = getInt(a, 1)
doAssert action >= 0 and action <= int(high(Action))
ed.keymapping[bitset] = Command(action: Action(action),
arg: getString(a, 2))
Loading

0 comments on commit e7bb456

Please sign in to comment.