Enable repl history
This commit is contained in:
parent
28d7be6efd
commit
468b446a4f
|
@ -21,6 +21,8 @@ package core
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/chzyer/readline"
|
||||
)
|
||||
|
@ -53,12 +55,19 @@ Replace the readline implementation with go-prompt.
|
|||
|
||||
func REPL(debug bool) {
|
||||
rt := MakeRuntime(debug)
|
||||
|
||||
rt.CreateNS("user", "REPL", true)
|
||||
rl, err := readline.New("> ")
|
||||
|
||||
rl, err := readline.NewEx(&readline.Config{
|
||||
Prompt: "> ",
|
||||
HistoryFile: filepath.Join(os.Getenv("HOME"), ".serene.history"),
|
||||
InterruptPrompt: "^C",
|
||||
EOFPrompt: "exit",
|
||||
HistorySearchFold: true,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
rl.HistoryEnable()
|
||||
defer rl.Close()
|
||||
|
||||
fmt.Println(`Serene's bootstrap interpreter is used to
|
||||
|
|
|
@ -136,7 +136,6 @@ tco:
|
|||
break tco //return
|
||||
}
|
||||
|
||||
fmt.Printf("<<< %s\n", list)
|
||||
f := exprs.(*List).First()
|
||||
|
||||
switch f.GetType() {
|
||||
|
|
Loading…
Reference in New Issue