Logo implementation
[jackhill/mal.git] / logo / readline.lg
1 make "backspace_char char 8
2 make "space_char char 32
3
4 to readline :prompt
5 type :prompt
6 wait 0 ; flush standard output
7 localmake "line "
8 forever [
9 localmake "c readchar
10 ifelse emptyp :c [
11 output []
12 ] [
13 localmake "ascii rawascii :c
14 case :ascii [
15 [[4] output []]
16 [[10] type :c
17 output :line]
18 [[127] if not emptyp :line [
19 type (word :backspace_char :space_char :backspace_char)
20 make "line butlast :line
21 ]]
22 [else type :c
23 make "line word :line :c]
24 ]
25 ]
26 ]
27 end