|
|
|
@ -104,6 +104,46 @@ func outputResult(txt string) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Repl() {
|
|
|
|
|
initialTerm, _ = ln.TerminalMode()
|
|
|
|
|
line = ln.NewLiner()
|
|
|
|
|
line.SetCtrlCAborts(true)
|
|
|
|
|
linerTerm, _ = ln.TerminalMode()
|
|
|
|
|
defer line.Close()
|
|
|
|
|
|
|
|
|
|
histFile := ExpandedAbsFilepath(filepath.Join(getModBaseDir(), "..", historyFilename))
|
|
|
|
|
if f, e := os.Open(histFile); e == nil {
|
|
|
|
|
line.ReadHistory(f)
|
|
|
|
|
f.Close()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var text strings.Builder
|
|
|
|
|
var cont bool
|
|
|
|
|
for {
|
|
|
|
|
globalenv.vars[symbol("slope-interactive?")] = true
|
|
|
|
|
if linerTerm != nil {
|
|
|
|
|
linerTerm.ApplyMode()
|
|
|
|
|
}
|
|
|
|
|
in := prompt(line, cont)
|
|
|
|
|
if initialTerm != nil {
|
|
|
|
|
initialTerm.ApplyMode()
|
|
|
|
|
}
|
|
|
|
|
if len(strings.TrimSpace(in)) == 0 {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
text.WriteString(in)
|
|
|
|
|
text.WriteRune('\n')
|
|
|
|
|
if !stringParensMatch(text.String()){
|
|
|
|
|
cont = true
|
|
|
|
|
} else {
|
|
|
|
|
cont = false
|
|
|
|
|
outputResult(text.String())
|
|
|
|
|
text.Reset()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func RunCommand(s string) {
|
|
|
|
|
if strings.Count(s, "(") != strings.Count(s, ")") {
|
|
|
|
|
fmt.Fprintf(os.Stderr, "Invalid input string, uneven parens")
|
|
|
|
@ -235,45 +275,6 @@ func PrintVersion() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Repl() {
|
|
|
|
|
initialTerm, _ = ln.TerminalMode()
|
|
|
|
|
line = ln.NewLiner()
|
|
|
|
|
line.SetCtrlCAborts(true)
|
|
|
|
|
linerTerm, _ = ln.TerminalMode()
|
|
|
|
|
defer line.Close()
|
|
|
|
|
|
|
|
|
|
histFile := ExpandedAbsFilepath(filepath.Join(getModBaseDir(), "..", historyFilename))
|
|
|
|
|
if f, e := os.Open(histFile); e == nil {
|
|
|
|
|
line.ReadHistory(f)
|
|
|
|
|
f.Close()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var text strings.Builder
|
|
|
|
|
var cont bool
|
|
|
|
|
for {
|
|
|
|
|
globalenv.vars[symbol("slope-interactive?")] = true
|
|
|
|
|
if linerTerm != nil {
|
|
|
|
|
linerTerm.ApplyMode()
|
|
|
|
|
}
|
|
|
|
|
in := prompt(line, cont)
|
|
|
|
|
if initialTerm != nil {
|
|
|
|
|
initialTerm.ApplyMode()
|
|
|
|
|
}
|
|
|
|
|
if len(strings.TrimSpace(in)) == 0 {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
text.WriteString(in)
|
|
|
|
|
text.WriteRune('\n')
|
|
|
|
|
if !stringParensMatch(text.String()){
|
|
|
|
|
cont = true
|
|
|
|
|
} else {
|
|
|
|
|
cont = false
|
|
|
|
|
outputResult(text.String())
|
|
|
|
|
text.Reset()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
defer RecoverError()
|
|
|
|
|
verFlag := flag.Bool("v", false, "Print version information and exit")
|
|
|
|
|