mirror of
				https://github.com/sammy-ette/Hilbish
				synced 2025-08-10 02:52:03 +00:00 
			
		
		
		
	Compare commits
	
		
			13 Commits
		
	
	
		
			96a6fa189b
			...
			0fc27dda31
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 0fc27dda31 | ||
|  | f7806f5479 | ||
|  | c8c30e9861 | ||
|  | 083c266438 | ||
|  | dd9bdca5e0 | ||
|  | 9902560061 | ||
|  | dd9aa4b6ea | ||
|  | be8bdef9c8 | ||
|  | e185a32685 | ||
|  | 2b480e50e6 | ||
|  | b65acca903 | ||
|  | 08e2951513 | ||
|  | 174c094bfd | 
							
								
								
									
										11
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								CHANGELOG.md
									
									
									
									
									
								
							| @ -56,6 +56,7 @@ having and using multiple runners. | ||||
|   - `fs.basename(path)` gets the basename of path | ||||
|   - `fs.dir(path)` gets the directory part of path | ||||
|   - `fs.glob(pattern)` globs files and directories based on patterns | ||||
|   - `fs.join(dirs...)` joins directories by OS dir separator | ||||
| - .. and 2 properties | ||||
|   - `fs.pathSep` is the separator for filesystem paths and directories | ||||
|   - `fs.pathListSep` is the separator for $PATH env entries | ||||
| @ -67,6 +68,8 @@ small news pieces for releases. It is printed by default. To disable it, | ||||
| set `hilbish.opts.motd` to false. | ||||
| - `history` opt has been added and is true by default. Setting it to false | ||||
| disables commands being added to history. | ||||
| - `hilbish.rawInput` hook for input from the readline library | ||||
| - Completion of files in quotes | ||||
| 
 | ||||
| ### Changed | ||||
| - **Breaking Change:** Upgraded to Lua 5.4. | ||||
| @ -125,6 +128,14 @@ for explanation. | ||||
| Lua `job.stop` function. | ||||
| - Jobs are always started in sh exec handler now instead of only successful start. | ||||
| - SIGTERM is handled properly now, which means stopping jobs and timers. | ||||
| - Fix panic on trailing newline on pasted multiline text. | ||||
| - Completions will no longer be refreshed if the prompt refreshes while the | ||||
| menu is open. | ||||
| - Print error on search fail instead of panicking | ||||
| - Windows related fixes: | ||||
|   - `hilbish.dataDir` now has tilde (`~`) expanded. | ||||
|   - Arrow keys now work on Windows terminals. | ||||
|   - Escape codes now work. | ||||
| 
 | ||||
| ## [1.2.0] - 2022-03-17 | ||||
| ### Added | ||||
|  | ||||
| @ -11,6 +11,9 @@ filepath.Dir | ||||
| glob(pattern) > Glob all files and directories that match the pattern. | ||||
| For the rules, see Go's filepath.Glob | ||||
| 
 | ||||
| join(paths...) > Takes paths and joins them together with the OS's | ||||
| directory separator (forward or backward slash). | ||||
| 
 | ||||
| mkdir(name, recursive) > Makes a directory called `name`. If `recursive` is true, it will create its parent directories. | ||||
| 
 | ||||
| readdir(dir) > Returns a table of files in `dir` | ||||
|  | ||||
| @ -22,6 +22,10 @@ function fs.dir() end | ||||
| --- For the rules, see Go's filepath.Glob | ||||
| function fs.glob() end | ||||
| 
 | ||||
| --- Takes paths and joins them together with the OS's | ||||
| --- directory separator (forward or backward slash). | ||||
| function fs.join() end | ||||
| 
 | ||||
| --- Makes a directory called `name`. If `recursive` is true, it will create its parent directories. | ||||
| --- @param name string | ||||
| --- @param recursive boolean | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| package fs | ||||
| 
 | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"path/filepath" | ||||
| 	"strconv" | ||||
| 	"os" | ||||
| @ -27,6 +28,7 @@ func loaderFunc(rtm *rt.Runtime) (rt.Value, func()) { | ||||
| 		"basename": util.LuaExport{fbasename, 1, false}, | ||||
| 		"dir": util.LuaExport{fdir, 1, false}, | ||||
| 		"glob": util.LuaExport{fglob, 1, false}, | ||||
| 		"join": util.LuaExport{fjoin, 0, true}, | ||||
| 	} | ||||
| 	mod := rt.NewTable() | ||||
| 	util.SetExports(rtm, mod, exports) | ||||
| @ -216,3 +218,21 @@ func fglob(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { | ||||
| 	 | ||||
| 	return c.PushingNext(t.Runtime, rt.TableValue(luaMatches)), nil | ||||
| } | ||||
| 
 | ||||
| // join(paths...) | ||||
| // Takes paths and joins them together with the OS's | ||||
| // directory separator (forward or backward slash). | ||||
| func fjoin(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { | ||||
| 	strs := make([]string, len(c.Etc())) | ||||
| 	for i, v := range c.Etc() { | ||||
| 		if v.Type() != rt.StringType { | ||||
| 			// +2; go indexes of 0 and first arg from above | ||||
| 			return nil, fmt.Errorf("bad argument #%d to run (expected string, got %s)", i + 1, v.TypeName()) | ||||
| 		} | ||||
| 		strs[i] = v.AsString() | ||||
| 	} | ||||
| 
 | ||||
| 	res := filepath.Join(strs...) | ||||
| 
 | ||||
| 	return c.PushingNext(t.Runtime, rt.StringValue(res)), nil | ||||
| } | ||||
|  | ||||
| @ -5,7 +5,13 @@ package main | ||||
| import "golang.org/x/sys/windows" | ||||
| 
 | ||||
| func init() { | ||||
| 	var mode uint32 | ||||
| 	windows.GetConsoleMode(windows.Stdout, &mode) | ||||
| 	windows.SetConsoleMode(windows.Stdout, mode | windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING) | ||||
| 	// vt output (escape codes) | ||||
| 	var outMode uint32 | ||||
| 	windows.GetConsoleMode(windows.Stdout, &outMode) | ||||
| 	windows.SetConsoleMode(windows.Stdout, outMode | windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING) | ||||
| 
 | ||||
| 	// vt input | ||||
| 	var inMode uint32 | ||||
| 	windows.GetConsoleMode(windows.Stdin, &inMode) | ||||
| 	windows.SetConsoleMode(windows.Stdin, inMode | windows.ENABLE_VIRTUAL_TERMINAL_INPUT) | ||||
| } | ||||
|  | ||||
							
								
								
									
										8
									
								
								lua.go
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								lua.go
									
									
									
									
									
								
							| @ -12,12 +12,16 @@ import ( | ||||
| 
 | ||||
| 	rt "github.com/arnodel/golua/runtime" | ||||
| 	"github.com/arnodel/golua/lib" | ||||
| 	"github.com/arnodel/golua/lib/debuglib" | ||||
| ) | ||||
| 
 | ||||
| var minimalconf = `hilbish.prompt '& '` | ||||
| 
 | ||||
| func luaInit() { | ||||
| 	l = rt.New(os.Stdout) | ||||
| 	l.PushContext(rt.RuntimeContextDef{ | ||||
| 		MessageHandler: debuglib.Traceback, | ||||
| 	}) | ||||
| 	lib.LoadAll(l) | ||||
| 
 | ||||
| 	lib.LoadLibs(l, hilbishLoader) | ||||
| @ -48,6 +52,10 @@ func luaInit() { | ||||
| 		} | ||||
| 	}) | ||||
| 
 | ||||
| 	lr.rl.RawInputCallback = func(r []rune) { | ||||
| 		hooks.Em.Emit("hilbish.rawInput", string(r)) | ||||
| 	} | ||||
| 
 | ||||
| 	// Add more paths that Lua can require from | ||||
| 	err := util.DoString(l, "package.path = package.path .. " + requirePaths) | ||||
| 	if err != nil { | ||||
|  | ||||
| @ -21,7 +21,7 @@ end | ||||
| 
 | ||||
| local defaultOpts = { | ||||
| 	autocd = false, | ||||
| 	history = true | ||||
| 	history = true, | ||||
| 	greeting = string.format([[Welcome to {magenta}Hilbish{reset}, {cyan}%s{reset}. | ||||
| The nice lil shell for {blue}Lua{reset} fanatics! | ||||
| ]], hilbish.user), | ||||
|  | ||||
| @ -198,6 +198,8 @@ type Instance struct { | ||||
| 
 | ||||
| 	ViModeCallback func(ViMode) | ||||
| 	ViActionCallback func(ViAction, []string) | ||||
| 
 | ||||
| 	RawInputCallback func([]rune) // called on all input | ||||
| } | ||||
| 
 | ||||
| // NewInstance is used to create a readline instance and initialise it with sane defaults. | ||||
|  | ||||
| @ -94,6 +94,9 @@ func (rl *Instance) Readline() (string, error) { | ||||
| 
 | ||||
| 		rl.skipStdinRead = false | ||||
| 		r := []rune(string(b)) | ||||
| 		if rl.RawInputCallback != nil { | ||||
| 			rl.RawInputCallback(r[:i]) | ||||
| 		} | ||||
| 
 | ||||
| 		if isMultiline(r[:i]) || len(rl.multiline) > 0 { | ||||
| 			rl.multiline = append(rl.multiline, b[:i]...) | ||||
|  | ||||
| @ -2,13 +2,15 @@ | ||||
| 
 | ||||
| package main | ||||
| 
 | ||||
| import "hilbish/util" | ||||
| 
 | ||||
| // String vars that are free to be changed at compile time | ||||
| var ( | ||||
| 	requirePaths = commonRequirePaths + `.. ';' | ||||
| 	.. hilbish.userDir.config .. '\\Hilbish\\libs\\?\\init.lua;' | ||||
| 	.. hilbish.userDir.config .. '\\Hilbish\\libs\\?\\?.lua;' | ||||
| 	.. hilbish.userDir.config .. '\\Hilbish\\libs\\?.lua;'` | ||||
| 	dataDir = "~\\Appdata\\Roaming\\Hilbish" // ~ and \ gonna cry? | ||||
| 	dataDir = util.ExpandHome("~\\Appdata\\Roaming\\Hilbish") // ~ and \ gonna cry? | ||||
| 	preloadPath = dataDir + "\\nature\\init.lua" | ||||
| 	sampleConfPath = dataDir + "\\hilbishrc.lua" // Path to default/sample config | ||||
| 	defaultConfDir = "" | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user