mirror of
				https://github.com/sammy-ette/Hilbish
				synced 2025-08-10 02:52:03 +00:00 
			
		
		
		
	Compare commits
	
		
			No commits in common. "75b51075b8b7fc82d127467c9e8e3b9853da490e" and "14274a94322b4a5d53c3556655a54d660d182db5" have entirely different histories.
		
	
	
		
			75b51075b8
			...
			14274a9432
		
	
		
							
								
								
									
										33
									
								
								api.go
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								api.go
									
									
									
									
									
								
							| @ -18,7 +18,7 @@ import ( | ||||
| 	rt "github.com/arnodel/golua/runtime" | ||||
| 	"github.com/arnodel/golua/lib/packagelib" | ||||
| 	"github.com/maxlandon/readline" | ||||
| 	"github.com/blackfireio/osinfo" | ||||
| //	"github.com/blackfireio/osinfo" | ||||
| 	"mvdan.cc/sh/v3/interp" | ||||
| ) | ||||
| 
 | ||||
| @ -76,59 +76,60 @@ Check out the {blue}{bold}guide{reset} command to get started. | ||||
| 	util.SetField(rtm, mod, "greeting", rt.StringValue(greeting), "Hilbish's welcome message for interactive shells. It has Lunacolors formatting.") | ||||
| 	util.SetField(rtm, mod, "vimMode", rt.NilValue, "Current Vim mode of Hilbish (nil if not in Vim mode)") | ||||
| 	util.SetField(rtm, hshMod, "exitCode", rt.IntValue(0), "Exit code of last exected command") | ||||
| 	util.Document(mod, "Hilbish's core API, containing submodules and functions which relate to the shell itself.") | ||||
| 	//util.Document(rtm, mod, "Hilbish's core API, containing submodules and functions which relate to the shell itself.") | ||||
| 
 | ||||
| 	// hilbish.userDir table | ||||
| 	hshuser := rt.NewTable() | ||||
| 
 | ||||
| 	util.SetField(rtm, hshuser, "config", rt.StringValue(confDir), "User's config directory") | ||||
| 	util.SetField(rtm, hshuser, "data", rt.StringValue(userDataDir), "XDG data directory") | ||||
| 	util.Document(hshuser, "User directories to store configs and/or modules.") | ||||
| 	//util.Document(rtm, hshuser, "User directories to store configs and/or modules.") | ||||
| 	mod.Set(rt.StringValue("userDir"), rt.TableValue(hshuser)) | ||||
| 
 | ||||
| /* | ||||
| 	// hilbish.os table | ||||
| 	hshos := rt.NewTable() | ||||
| 	hshos := L.NewTable() | ||||
| 	info, _ := osinfo.GetOSInfo() | ||||
| 
 | ||||
| 	util.SetField(rtm, hshos, "family", rt.StringValue(info.Family), "Family name of the current OS") | ||||
| 	util.SetField(rtm, hshos, "name", rt.StringValue(info.Name), "Pretty name of the current OS") | ||||
| 	util.SetField(rtm, hshos, "version", rt.StringValue(info.Version), "Version of the current OS") | ||||
| 	util.Document(hshos, "OS info interface") | ||||
| 	mod.Set(rt.StringValue("os"), rt.TableValue(hshos)) | ||||
| 	util.SetField(L, hshos, "family", lua.LString(info.Family), "Family name of the current OS") | ||||
| 	util.SetField(L, hshos, "name", lua.LString(info.Name), "Pretty name of the current OS") | ||||
| 	util.SetField(L, hshos, "version", lua.LString(info.Version), "Version of the current OS") | ||||
| 	util.Document(L, hshos, "OS info interface") | ||||
| 	L.SetField(mod, "os", hshos) | ||||
| */ | ||||
| 
 | ||||
| 	// hilbish.aliases table | ||||
| 	aliases = newAliases() | ||||
| 	aliasesModule := aliases.Loader(rtm) | ||||
| 	util.Document(aliasesModule, "Alias inferface for Hilbish.") | ||||
| 	//util.Document(L, aliasesModule, "Alias inferface for Hilbish.") | ||||
| 	mod.Set(rt.StringValue("aliases"), rt.TableValue(aliasesModule)) | ||||
| 
 | ||||
| 	// hilbish.history table | ||||
| 	historyModule := lr.Loader(rtm) | ||||
| 	//util.Document(L, historyModule, "History interface for Hilbish.") | ||||
| 	mod.Set(rt.StringValue("history"), rt.TableValue(historyModule)) | ||||
| 	util.Document(historyModule, "History interface for Hilbish.") | ||||
| 
 | ||||
| 	// hilbish.completion table | ||||
| 	hshcomp := rt.NewTable() | ||||
| 
 | ||||
| 	util.SetField(rtm, hshcomp, "files", | ||||
| 	rt.FunctionValue(rt.NewGoFunction(luaFileComplete, "files", 3, false)), | ||||
| 	"Completer for files") | ||||
| 
 | ||||
| 	util.SetField(rtm, hshcomp, "bins", | ||||
| 	rt.FunctionValue(rt.NewGoFunction(luaBinaryComplete, "bins", 3, false)), | ||||
| 	"Completer for executables/binaries") | ||||
| 
 | ||||
| 	util.Document(hshcomp, "Completions interface for Hilbish.") | ||||
| 	//util.Document(L, hshcomp, "Completions interface for Hilbish.") | ||||
| 	mod.Set(rt.StringValue("completion"), rt.TableValue(hshcomp)) | ||||
| 
 | ||||
| 	// hilbish.runner table | ||||
| 	runnerModule := runnerModeLoader(rtm) | ||||
| 	util.Document(runnerModule, "Runner/exec interface for Hilbish.") | ||||
| 	//util.Document(L, runnerModule, "Runner/exec interface for Hilbish.") | ||||
| 	mod.Set(rt.StringValue("runner"), rt.TableValue(runnerModule)) | ||||
| 
 | ||||
| 	// hilbish.jobs table | ||||
| 	jobs = newJobHandler() | ||||
| 	jobModule := jobs.loader(rtm) | ||||
| 	util.Document(jobModule, "(Background) job interface.") | ||||
| //	util.Document(L, jobModule, "(Background) job interface.") | ||||
| 	mod.Set(rt.StringValue("jobs"), rt.TableValue(jobModule)) | ||||
| 
 | ||||
| 	return rt.TableValue(mod), nil | ||||
|  | ||||
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							| @ -4,10 +4,10 @@ go 1.17 | ||||
| 
 | ||||
| require ( | ||||
| 	github.com/arnodel/golua v0.0.0-20220221163911-dfcf252b6f86 | ||||
| 	github.com/blackfireio/osinfo v1.0.3 | ||||
| 	github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 | ||||
| 	github.com/maxlandon/readline v0.1.0-beta.0.20211027085530-2b76cabb8036 | ||||
| 	github.com/pborman/getopt v1.1.0 | ||||
| 	github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 | ||||
| 	golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 | ||||
| 	mvdan.cc/sh/v3 v3.4.3 | ||||
| ) | ||||
|  | ||||
							
								
								
									
										8
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								go.sum
									
									
									
									
									
								
							| @ -8,10 +8,11 @@ github.com/arnodel/edit v0.0.0-20220202110212-dfc8d7a13890/go.mod h1:AcpttpuZBaL | ||||
| github.com/arnodel/strftime v0.1.6 h1:0hc0pUvk8KhEMXE+htyaOUV42zNcf/csIbjzEFCJqsw= | ||||
| github.com/arnodel/strftime v0.1.6/go.mod h1:5NbK5XqYK8QpRZpqKNt4OlxLtIB8cotkLk4KTKzJfWs= | ||||
| github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= | ||||
| github.com/blackfireio/osinfo v1.0.3 h1:Yk2t2GTPjBcESv6nDSWZKO87bGMQgO+Hi9OoXPpxX8c= | ||||
| github.com/blackfireio/osinfo v1.0.3/go.mod h1:Pd987poVNmd5Wsx6PRPw4+w7kLlf9iJxoRKPtPAjOrA= | ||||
| github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 h1:xz6Nv3zcwO2Lila35hcb0QloCQsc38Al13RNEzWRpX4= | ||||
| github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9/go.mod h1:2wSM9zJkl1UQEFZgSd68NfCgRz1VL1jzy/RjCg+ULrs= | ||||
| github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= | ||||
| github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= | ||||
| github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= | ||||
| github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= | ||||
| github.com/creack/pty v1.1.15 h1:cKRCLMj3Ddm54bKSpemfQ8AtYFBhAI2MPmdys22fBdc= | ||||
| github.com/creack/pty v1.1.15/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= | ||||
| @ -41,8 +42,11 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ | ||||
| github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= | ||||
| github.com/rogpeppe/go-internal v1.8.1-0.20210923151022-86f73c517451 h1:d1PiN4RxzIFXCJTvRkvSkKqwtRAl5ZV4lATKtQI0B7I= | ||||
| github.com/rogpeppe/go-internal v1.8.1-0.20210923151022-86f73c517451/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= | ||||
| github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 h1:k/gmLsJDWwWqbLCur2yWnJzwQEKRcAHXo6seXGuSwWw= | ||||
| github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA= | ||||
| golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= | ||||
| golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||
| golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
|  | ||||
| @ -40,7 +40,8 @@ func (b *Bait) loaderFunc(rtm *rt.Runtime) (rt.Value, func()) { | ||||
| 	mod := rt.NewTable() | ||||
| 	util.SetExports(rtm, mod, exports) | ||||
| 
 | ||||
| 	util.Document(mod, | ||||
| /* | ||||
| 	util.Document(L, mod, | ||||
| `Bait is the event emitter for Hilbish. Why name it bait? | ||||
| Because it throws hooks that you can catch (emits events | ||||
| that you can listen to) and because why not, fun naming | ||||
| @ -48,6 +49,7 @@ is fun. This is what you will use if you want to listen | ||||
| in on hooks to know when certain things have happened, | ||||
| like when you've changed directory, a command has | ||||
| failed, etc. To find all available hooks, see doc hooks.`) | ||||
| */ | ||||
| 
 | ||||
| 	return rt.TableValue(mod), nil | ||||
| } | ||||
|  | ||||
| @ -32,7 +32,7 @@ func (c *Commander) loaderFunc(rtm *rt.Runtime) (rt.Value, func()) { | ||||
| 	} | ||||
| 	mod := rt.NewTable() | ||||
| 	util.SetExports(rtm, mod, exports) | ||||
| 	util.Document(mod, "Commander is Hilbish's custom command library, a way to write commands in Lua.") | ||||
| //	util.Document(L, mod, "Commander is Hilbish's custom command library, a way to write commands in Lua.") | ||||
| 
 | ||||
| 	return rt.TableValue(mod), nil | ||||
| } | ||||
|  | ||||
| @ -26,9 +26,11 @@ func loaderFunc(rtm *rt.Runtime) (rt.Value, func()) { | ||||
| 	mod := rt.NewTable() | ||||
| 	util.SetExports(rtm, mod, exports) | ||||
| 
 | ||||
| 	util.Document(mod, `The fs module provides easy and simple access to | ||||
| /* | ||||
| 	util.Document(L, mod, `The fs module provides easy and simple access to | ||||
| filesystem functions and other things, and acts an | ||||
| addition to the Lua standard library's I/O and fs functions.`) | ||||
| */ | ||||
| 
 | ||||
| 	return rt.TableValue(mod), nil | ||||
| } | ||||
|  | ||||
| @ -26,7 +26,7 @@ func loaderFunc(rtm *rt.Runtime) (rt.Value, func()) { | ||||
| 
 | ||||
| 	mod := rt.NewTable() | ||||
| 	util.SetExports(rtm, mod, exports) | ||||
| 	util.Document(mod, "The terminal library is a simple and lower level library for certain terminal interactions.") | ||||
| 	//util.Document(L, mod, "The terminal library is a simple and lower level library for certain terminal interactions.") | ||||
| 
 | ||||
| 	return rt.TableValue(mod), nil | ||||
| } | ||||
|  | ||||
| @ -48,11 +48,9 @@ var ( | ||||
| 	seqEnd       = string([]byte{27, 91, 70}) | ||||
| 	seqEndSc     = string([]byte{27, 91, 52, 126}) | ||||
| 	seqDelete    = string([]byte{27, 91, 51, 126}) | ||||
| 	seqDelete2      = string([]byte{27, 91, 80}) | ||||
| 	seqShiftTab  = string([]byte{27, 91, 90}) | ||||
| 	seqAltQuote  = string([]byte{27, 34})  // Added for showing registers ^[" | ||||
| 	seqAltR      = string([]byte{27, 114}) // Used for alternative history | ||||
| 	seqAltBackspace = string([]byte{27, 127}) | ||||
| ) | ||||
| 
 | ||||
| const ( | ||||
|  | ||||
| @ -712,15 +712,12 @@ func (rl *Instance) escapeSeq(r []rune) { | ||||
| 		rl.updateHelpers() | ||||
| 		return | ||||
| 
 | ||||
| 	case seqDelete,seqDelete2: | ||||
| 	case seqDelete: | ||||
| 		if rl.modeTabFind { | ||||
| 			rl.backspaceTabFind() | ||||
| 		} else { | ||||
| 			if (rl.pos < len(rl.line)) { | ||||
| 			rl.deleteBackspace(true) | ||||
| 		} | ||||
| 		} | ||||
| 
 | ||||
| 	case seqHome, seqHomeSc: | ||||
| 		if rl.modeTabCompletion { | ||||
| 			return | ||||
| @ -755,19 +752,6 @@ func (rl *Instance) escapeSeq(r []rune) { | ||||
| 		rl.updateTabFind([]rune{}) | ||||
| 		rl.viUndoSkipAppend = true | ||||
| 
 | ||||
| 	case seqAltBackspace: | ||||
| 		if rl.modeTabCompletion { | ||||
| 			rl.resetVirtualComp(false) | ||||
| 		} | ||||
| 		// This is only available in Insert mode | ||||
| 		if rl.modeViMode != VimInsert { | ||||
| 			return | ||||
| 		} | ||||
| 
 | ||||
| 		rl.saveToRegister(rl.viJumpB(tokeniseLine)) | ||||
| 		rl.viDeleteByAdjust(rl.viJumpB(tokeniseLine)) | ||||
| 		rl.updateHelpers() | ||||
| 
 | ||||
| 	default: | ||||
| 		if rl.modeTabFind { | ||||
| 			return | ||||
|  | ||||
							
								
								
									
										17
									
								
								util/util.go
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								util/util.go
									
									
									
									
									
								
							| @ -3,20 +3,21 @@ package util | ||||
| import ( | ||||
| 	"os" | ||||
| 
 | ||||
| 	"github.com/yuin/gopher-lua" | ||||
| 	rt "github.com/arnodel/golua/runtime" | ||||
| ) | ||||
| 
 | ||||
| // Document adds a documentation string to a module. | ||||
| // It is accessible via the __doc metatable. | ||||
| func Document(module *rt.Table, doc string) { | ||||
| 	mt := module.Metatable() | ||||
| 	 | ||||
| 	if mt == nil { | ||||
| 		mt = rt.NewTable() | ||||
| 		module.SetMetatable(mt) | ||||
| func Document(L *lua.LState, module lua.LValue, doc string) { | ||||
| /* | ||||
| 	mt := L.GetMetatable(module) | ||||
| 	if mt == lua.LNil { | ||||
| 		mt = L.NewTable() | ||||
| 		L.SetMetatable(module, mt) | ||||
| 	} | ||||
| 
 | ||||
| 	mt.Set(rt.StringValue("__doc"), rt.StringValue(doc)) | ||||
| 	L.SetField(mt, "__doc", lua.LString(doc)) | ||||
| */ | ||||
| } | ||||
| 
 | ||||
| // SetField sets a field in a table, adding docs for it. | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user