display(2).mode = displayMode.text
t2 = display(2)
t2.color = text.color
t2.backColor = text.backColor[:7]
t2.clear
update = function()
for row in range(25,0)
for col in range(0,67)
t2.setCell col, row, text.cell(67-col, row)
end for
end for
end function
blinkTillKeyAvail = function()
c = 67 - text.column
r = text.row
while not key.available
t2.setCellColor c, r, t2.backColor
t2.setCellBackColor c, r, t2.color
t = time
while not key.available and time-t < 0.6; end while
t2.setCellColor c, r, t2.color
t2.setCellBackColor c, r, t2.backColor
t = time
while not key.available and time-t < 0.3; end while
end while
end function
inp = function(prompt)
text.delimiter = ""
print prompt
buf = ""
while true
update
blinkTillKeyAvail
k = key.__isa.get
if k == char(10) or k == char(3) then break
if k == char(8) then
if buf == "" then continue
buf = buf[:-1]
text.setCell text.column-1, text.row, " "
text.column = text.column - 1
continue
end if
buf = buf + k
print k
end while
text.delimiter = char(13)
print
return buf
end function
if not key.hasIndex("__isa") then
key = new key
key.get = function()
update
return super.get
end function
end if
while true
update
cmd = inp(env.prompt)
if cmd == "clear" then
text.clear
else if cmd == "source" then
print _source.join(char(13))
else if cmd == "quit" then
t2.mode = displayMode.off
exit
else if globals.hasIndex(cmd) then
f = globals[cmd]
f
end if
end while