Improved REPL output

This commit is contained in:
obscuren
2014-05-19 16:32:45 +02:00
parent 16421106d4
commit 017bbbb582
5 changed files with 89 additions and 12 deletions

View File

@ -8,6 +8,7 @@ package main
import "C"
import (
"github.com/robertkrimen/otto"
"strings"
"unsafe"
)
@ -63,18 +64,30 @@ L:
for {
switch result := readLine(&self.prompt); true {
case result == nil:
break L //exit loop
break L
case *result != "": //ignore blank lines
case *result != "":
str += *result + "\n"
self.setIndent()
if indentCount <= 0 {
if *result == "exit" {
self.Stop()
break L
}
addHistory(str) //allow user to recall this line
self.parseInput(str)
str = ""
}
}
}
}
func (self *JSRepl) PrintValue(value otto.Value) {
method, _ := self.re.vm.Get("prettyPrint")
method.Call(method, value)
}