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

View File

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