def onKeyPress(key)
if key==WidgetEvent::KeyDelete
thisline=@text[@line]
if @textm and thisline.length>0
@text[@line]=thisline.slice(0,thisline.length-1)
elsif thisline.length>3
@text[@line]=thisline.slice(0,thisline.length-1)
end
elsif key==WidgetEvent::KeySpace
@text[@line]+=" "
elsif key==WidgetEvent::KeyEscape
sleep
elsif key==WidgetEvent::KeyEnter
if @textm
if @text[@line]=="/endtext"
@textm=false
@line+=1
@text[@line]=">> "
else
@line+=1
@text[@line]=""
end
return
end
@oldtext.push @text[@line]
cmd=@text[@line].slice(3,@text[@line].length-3)
if cmd.slice(cmd.size-3,3)=="/nl"
@text[@line]=@text[@line].slice(0,@text[@line].length-3)
@text[@line+1]="|> "
@line+=1
else
runcmd(cmd)
end
@vline=@oldtext.size
elsif key==WidgetEvent::KeyUp
if @vline-1 >= 0 and
@vline-=1
@text[@line]=@oldtext[@vline]
end
elsif key==WidgetEvent::KeyDown
if @vline+1 < @oldtext.size and
@vline+=1
@text[@line]=@oldtext[@vline]
end
end
end