fix: switch back to readline for the time being

pull/38/head
sammy 2021-04-23 23:42:34 -04:00
parent 17e12c8c2a
commit 935bed3dc6
No known key found for this signature in database
GPG Key ID: 50EE40A2809851F5
2 changed files with 12 additions and 14 deletions

19
main.go
View File

@ -11,12 +11,12 @@ import (
hooks "hilbish/golibs/bait"
"github.com/akamensky/argparse"
"github.com/Hilbis/Hilbiline"
"github.com/bobappleyard/readline"
"github.com/yuin/gopher-lua"
"golang.org/x/term"
)
const version = "0.4.0-dev.2+hilbiline"
const version = "0.4.0-dev.2"
var (
l *lua.LState
@ -104,15 +104,13 @@ func main() {
go HandleSignals()
LuaInit(*configflag)
hl := hilbiline.New("")
//readline.Completer = readline.FilenameCompleter
//readline.LoadHistory(homedir + "/.hilbish-history")
readline.Completer = readline.FilenameCompleter
readline.LoadHistory(homedir + "/.hilbish-history")
for {
running = false
hl.SetPrompt(fmtPrompt())
input, err := hl.Read()
input, err := readline.String(fmtPrompt())
if err == io.EOF {
// Exit if user presses ^D (ctrl + d)
@ -125,7 +123,7 @@ func main() {
}
input = strings.TrimSpace(input)
if len(input) == 0 { fmt.Print("\n"); continue }
if len(input) == 0 { continue }
if strings.HasSuffix(input, "\\") {
for {
@ -192,9 +190,8 @@ func HandleSignals() {
for range c {
if !running {
//fmt.Println(" // interrupt")
//readline.ReplaceLine("", 0)
//readline.RefreshLine()
readline.ReplaceLine("", 0)
readline.RefreshLine()
}
}
}

View File

@ -9,6 +9,7 @@ import (
"strings"
"github.com/yuin/gopher-lua"
"github.com/bobappleyard/readline"
"layeh.com/gopher-luar"
"mvdan.cc/sh/v3/interp"
"mvdan.cc/sh/v3/syntax"
@ -113,7 +114,7 @@ func splitInput(input string) ([]string, string) {
cmdArgs := []string{}
sb := &strings.Builder{}
cmdstr := &strings.Builder{}
lastcmd := "" //readline.GetHistory(readline.HistorySize() - 1)
lastcmd := readline.GetHistory(readline.HistorySize() - 1)
for _, r := range input {
if r == '"' {
@ -158,8 +159,8 @@ func splitInput(input string) ([]string, string) {
}
func HandleHistory(cmd string) {
//readline.AddHistory(cmd)
//readline.SaveHistory(homedir + "/.hilbish-history")
readline.AddHistory(cmd)
readline.SaveHistory(homedir + "/.hilbish-history")
// TODO: load history again (history shared between sessions like this ye)
}