all repos — min @ 3fce9f69594d99fb2a7f335781010c74ea3e65f7

A small but practical concatenative programming language.

Implemented insert and delete key behaviors.
h3rald h3rald@h3rald.com
Thu, 08 Sep 2016 21:30:27 +0200
commit

3fce9f69594d99fb2a7f335781010c74ea3e65f7

parent

a94154ff1b018d66371fa25c9044bafc7d358181

1 files changed, 15 insertions(+), 1 deletions(-)

jump to
M core/line.nimcore/line.nim

@@ -106,6 +106,15 @@ putchar i.ord

ln.text = ln.fromFirst & ln.text[ln.position+1..ln.last] stdout.cursorBackward(rest.len) +proc deleteNext*(ln: var Line) = + if not ln.empty: + if not ln.full: + let rest = ln.toLast[1..^1] & " " + for c in rest: + putchar c.ord + stdout.cursorBackward(rest.len) + ln.text = ln.fromFirst & ln.toLast[1..^1] + proc printChar*(ln: var Line, c: int) = if ln.full: putchar(c.cint)

@@ -149,7 +158,12 @@

KEYMAP["backspace"] = proc(ln: var Line) = ln.deletePrevious() KEYMAP["delete"] = proc(ln: var Line) = - discard #TODO + ln.deleteNext() +KEYMAP["insert"] = proc(ln: var Line) = + if ln.mode == mdInsert: + ln.mode = mdReplace + else: + ln.mode = mdInsert KEYMAP["down"] = proc(ln: var Line) = discard #TODO KEYMAP["up"] = proc(ln: var Line) =