From 935bed3dc6888c105b7326b0d232d1a94578704b Mon Sep 17 00:00:00 2001 From: sammy <38820196+TorchedSammy@users.noreply.github.com> Date: Fri, 23 Apr 2021 23:42:34 -0400 Subject: [PATCH] fix: switch back to readline for the time being --- main.go | 19 ++++++++----------- shell.go | 7 ++++--- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/main.go b/main.go index 7277e82..02ad3a7 100644 --- a/main.go +++ b/main.go @@ -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() } } } diff --git a/shell.go b/shell.go index d3e4e12..c1c1d5f 100644 --- a/shell.go +++ b/shell.go @@ -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) }