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"
 | 
						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()
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										7
									
								
								shell.go
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								shell.go
									
									
									
									
									
								
							@ -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)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user