mirror of
				https://github.com/sammy-ette/Hilbish
				synced 2025-08-10 02:52:03 +00:00 
			
		
		
		
	fix: switch back to readline for the time being
This commit is contained in:
		
							parent
							
								
									17e12c8c2a
								
							
						
					
					
						commit
						935bed3dc6
					
				
							
								
								
									
										19
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								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()
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										7
									
								
								shell.go
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								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)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user