jale/templates.nim

22 lines
546 B
Nim
Raw Normal View History

2021-02-15 20:18:31 +01:00
import editor
import event
import keycodes
template bindKey*(editor: LineEditor, key: int, body: untyped) =
proc action {.gensym.} =
body
editor.keystrokes.add(key, action)
template bindKey*(editor: LineEditor, key: char, body: untyped) =
editor.bindKey(int(key)):
body
template bindKey*(editor: LineEditor, key: string, body: untyped) =
editor.bindKey(keysByName[key]):
body
template bindEvent*(editor: LineEditor, event: JaleEvent, body: untyped) =
proc action {.gensym.} =
body
editor.events.add(event, action)