updated todo; cleaned up defaults

This commit is contained in:
Productive2 2021-02-15 21:04:38 +01:00
parent e48cae8774
commit 49fa8ab937
2 changed files with 29 additions and 49 deletions

View File

@ -5,48 +5,33 @@ import event
import tables
import templates
# default populate
proc defInsert(editor: LineEditor) =
if editor.lastKeystroke > 31 and editor.lastKeystroke < 127:
let ch = char(editor.lastKeystroke)
editor.content.insert($ch)
proc defControl(editor: LineEditor) =
block control:
template check(key: string, blk: untyped) =
if editor.lastKeystroke == keysByName[key]:
blk
break control
check("left"):
editor.content.left()
check("right"):
editor.content.right()
check("up"):
editor.content.up()
check("down"):
editor.content.down()
check("backspace"):
editor.content.backspace()
check("delete"):
editor.content.delete()
check("enter"):
if editor.content.Y() == editor.content.high() and editor.content.getLine(editor.content.high()) == "":
editor.finish()
else:
editor.content.insertline()
check("ctrl+c"):
editor.finish()
editor.events.call(jeQuit)
check("ctrl+d"):
if editor.content.getContent() == "":
editor.finish()
editor.events.call(jeQuit)
proc defLog(editor: LineEditor) =
echo editor.lastKeystroke
proc populateDefaults*(editor: LineEditor) =
editor.bindEvent(jeKeypress):
editor.defInsert()
editor.defControl()
if editor.lastKeystroke > 31 and editor.lastKeystroke < 127:
let ch = char(editor.lastKeystroke)
editor.content.insert($ch)
editor.bindKey("left"):
editor.content.left()
editor.bindKey("right"):
editor.content.right()
editor.bindKey("up"):
editor.content.up()
editor.bindKey("down"):
editor.content.down()
editor.bindKey("backspace"):
editor.content.backspace()
editor.bindKey("delete"):
editor.content.delete()
editor.bindKey("enter"):
if editor.content.Y() == editor.content.high() and editor.content.getLine(editor.content.high()) == "":
editor.finish()
else:
editor.content.insertline()
editor.bindKey("ctrl+c"):
editor.finish()
editor.events.call(jeQuit)
editor.bindKey("ctrl+d"):
if editor.content.getContent() == "":
editor.finish()
editor.events.call(jeQuit)

View File

@ -1,20 +1,15 @@
Soon:
Horizontal scrolling for the current line in render
Add new keycodes (enter, ctrl+h, ctrl+j?)
Add a way to hook for the quit event (ctrl+c or ctrl+d auto triggers in default)
Move arrow keys to per-key events/create template that hooks by name
create template that hooks any key
Multiline editing:
- when moving up/down render should re-render the line to reset horizontal scrolling
- vertical scrolling
Other stuff:
- move codebase into multiple modules to ensure modularity (move away defaults and anything that can be submodules (keycodes) e.g.)
- tab completion into the defaults
- new events such as pre-terminate, pre-return, pre-render (filter)
- filters (for syntax highlighting)
Done: