mirror of
				https://github.com/sammy-ette/Hilbish
				synced 2025-08-10 02:52:03 +00:00 
			
		
		
		
	Compare commits
	
		
			17 Commits
		
	
	
		
			f9546e10e4
			...
			60f267260b
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 60f267260b | |||
| e4c3076189 | |||
| e013ecdb7b | |||
| 157984e16c | |||
| e84a2fbdde | |||
| 2dcae512ad | |||
|  | 99a121b6fa | ||
| 47582e167e | |||
| d5e31850bb | |||
| e0d59a3239 | |||
| b6315639b2 | |||
| 4a3ceed39c | |||
|  | 6729ecddea | ||
| 485306fbe2 | |||
| 480d4de750 | |||
| d7dde44a0c | |||
| 237b306eb8 | 
							
								
								
									
										18
									
								
								.github/workflows/website.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								.github/workflows/website.yml
									
									
									
									
										vendored
									
									
								
							| @ -19,25 +19,29 @@ jobs: | |||||||
|           hugo-version: 'latest' |           hugo-version: 'latest' | ||||||
|           extended: true |           extended: true | ||||||
| 
 | 
 | ||||||
|  |       - name: Set branch name | ||||||
|  |         id: branch | ||||||
|  |         run: echo "BRANCH_NAME=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_ENV" | ||||||
|  | 
 | ||||||
|  |       - name: Fix base URL | ||||||
|  |         if: env.BRANCH_NAME != 'master' && github.repository_owner == 'Rosettea'       | ||||||
|  |         run: sed -i "s%baseURL = 'https://rosettea.github.io/Hilbish/'%baseURL = 'https://rosettea.github.io/Hilbish/versions/${{ env.BRANCH_NAME }}'%" website/config.toml | ||||||
|  | 
 | ||||||
|       - name: Build |       - name: Build | ||||||
|         run: 'cd website && hugo --minify' |         run: 'cd website && hugo --minify' | ||||||
| 
 | 
 | ||||||
|       - name: Set branch name |  | ||||||
|         id: branch |  | ||||||
|         run: echo "::set-output name=BRANCH_NAME::${GITHUB_REF##*/}" |  | ||||||
| 
 |  | ||||||
|       - name: Deploy |       - name: Deploy | ||||||
|         if: steps.branch.outputs.BRANCH_NAME == 'master' && github.repository_owner == 'Rosettea' |         if: env.BRANCH_NAME == 'master' && github.repository_owner == 'Rosettea' | ||||||
|         uses: peaceiris/actions-gh-pages@v3 |         uses: peaceiris/actions-gh-pages@v3 | ||||||
|         with: |         with: | ||||||
|           github_token: ${{ secrets.GITHUB_TOKEN }} |           github_token: ${{ secrets.GITHUB_TOKEN }} | ||||||
|           publish_dir: ./website/public |           publish_dir: ./website/public | ||||||
|           keep_files: true |           keep_files: true | ||||||
|       - name: Deploy |       - name: Deploy | ||||||
|         if: steps.branch.outputs.BRANCH_NAME != 'master' && github.repository_owner == 'Rosettea' |         if: env.BRANCH_NAME != 'master' && github.repository_owner == 'Rosettea' | ||||||
|         uses: peaceiris/actions-gh-pages@v3 |         uses: peaceiris/actions-gh-pages@v3 | ||||||
|         with: |         with: | ||||||
|           github_token: ${{ secrets.GITHUB_TOKEN }} |           github_token: ${{ secrets.GITHUB_TOKEN }} | ||||||
|           publish_dir: ./website/public |           publish_dir: ./website/public | ||||||
|           destination_dir: versions/${( steps.branch.outputs.BRANCH_NAME }} |           destination_dir: versions/${{ env.BRANCH_NAME }} | ||||||
|           keep_files: true |           keep_files: true | ||||||
|  | |||||||
							
								
								
									
										8
									
								
								api.go
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								api.go
									
									
									
									
									
								
							| @ -639,6 +639,14 @@ func hlhinter(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { | |||||||
| // reality could set the input of the prompt to *display* anything. The | // reality could set the input of the prompt to *display* anything. The | ||||||
| // callback is passed the current line and is expected to return a line that | // callback is passed the current line and is expected to return a line that | ||||||
| // will be used as the input display. | // will be used as the input display. | ||||||
|  | // Note that to set a highlighter, one has to override this function. | ||||||
|  | // Example: | ||||||
|  | // ``` | ||||||
|  | // function hilbish.highlighter(line) | ||||||
|  | //    return line:gsub('"%w+"', function(c) return lunacolors.green(c) end) | ||||||
|  | // end | ||||||
|  | // ``` | ||||||
|  | // This code will highlight all double quoted strings in green. | ||||||
| // --- @param line string | // --- @param line string | ||||||
| func hlhighlighter(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { | func hlhighlighter(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { | ||||||
| 	return c.Next(), nil | 	return c.Next(), nil | ||||||
|  | |||||||
| @ -49,6 +49,14 @@ Line highlighter handler. This is mainly for syntax highlighting, but in | |||||||
| reality could set the input of the prompt to *display* anything. The | reality could set the input of the prompt to *display* anything. The | ||||||
| callback is passed the current line and is expected to return a line that | callback is passed the current line and is expected to return a line that | ||||||
| will be used as the input display. | will be used as the input display. | ||||||
|  | Note that to set a highlighter, one has to override this function. | ||||||
|  | Example: | ||||||
|  | ``` | ||||||
|  | function hilbish.highlighter(line) | ||||||
|  |    return line:gsub('"%w+"', function(c) return lunacolors.green(c) end) | ||||||
|  | end | ||||||
|  | ``` | ||||||
|  | This code will highlight all double quoted strings in green. | ||||||
| 
 | 
 | ||||||
| ### hinter(line, pos) | ### hinter(line, pos) | ||||||
| The command line hint handler. It gets called on every key insert to | The command line hint handler. It gets called on every key insert to | ||||||
| @ -117,7 +125,10 @@ A call with no argument will toggle the value. | |||||||
| Flush writes all buffered input to the sink. | Flush writes all buffered input to the sink. | ||||||
| 
 | 
 | ||||||
| #### read() -> string | #### read() -> string | ||||||
| Reads input from the sink. | Reads a liine of input from the sink. | ||||||
|  | 
 | ||||||
|  | #### readAll() -> string | ||||||
|  | Reads all input from the sink. | ||||||
| 
 | 
 | ||||||
| #### write(str) | #### write(str) | ||||||
| Writes data to a sink. | Writes data to a sink. | ||||||
|  | |||||||
| @ -21,6 +21,10 @@ Returns the text that is at the register. | |||||||
| ### insert(text) | ### insert(text) | ||||||
| Inserts text into the line. | Inserts text into the line. | ||||||
| 
 | 
 | ||||||
|  | ### getChar() -> string | ||||||
|  | Reads a keystroke from the user. This is in a format | ||||||
|  | of something like Ctrl-L. | ||||||
|  | 
 | ||||||
| ### setVimRegister(register, text) | ### setVimRegister(register, text) | ||||||
| Sets the vim register at `register` to hold the passed text. | Sets the vim register at `register` to hold the passed text. | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										11
									
								
								editor.go
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								editor.go
									
									
									
									
									
								
							| @ -16,6 +16,7 @@ func editorLoader(rtm *rt.Runtime) *rt.Table { | |||||||
| 		"setVimRegister": {editorSetRegister, 1, false}, | 		"setVimRegister": {editorSetRegister, 1, false}, | ||||||
| 		"getVimRegister": {editorGetRegister, 2, false}, | 		"getVimRegister": {editorGetRegister, 2, false}, | ||||||
| 		"getLine": {editorGetLine, 0, false}, | 		"getLine": {editorGetLine, 0, false}, | ||||||
|  | 		"readChar": {editorReadChar, 0, false}, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	mod := rt.NewTable() | 	mod := rt.NewTable() | ||||||
| @ -94,3 +95,13 @@ func editorGetLine(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { | |||||||
| 
 | 
 | ||||||
| 	return c.PushingNext1(t.Runtime, rt.StringValue(string(buf))), nil | 	return c.PushingNext1(t.Runtime, rt.StringValue(string(buf))), nil | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | // #interface editor | ||||||
|  | // getChar() -> string | ||||||
|  | // Reads a keystroke from the user. This is in a format | ||||||
|  | // of something like Ctrl-L.. | ||||||
|  | func editorReadChar(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { | ||||||
|  | 	buf := lr.rl.ReadChar() | ||||||
|  | 
 | ||||||
|  | 	return c.PushingNext1(t.Runtime, rt.StringValue(string(buf))), nil | ||||||
|  | } | ||||||
|  | |||||||
| @ -40,6 +40,10 @@ function hilbish.editor.getVimRegister(register) end | |||||||
| --- Inserts text into the line. | --- Inserts text into the line. | ||||||
| function hilbish.editor.insert(text) end | function hilbish.editor.insert(text) end | ||||||
| 
 | 
 | ||||||
|  | --- Reads a keystroke from the user. This is in a format | ||||||
|  | --- of something like Ctrl-L. | ||||||
|  | function hilbish.editor.getChar() end | ||||||
|  | 
 | ||||||
| --- Sets the vim register at `register` to hold the passed text. | --- Sets the vim register at `register` to hold the passed text. | ||||||
| --- @param register string | --- @param register string | ||||||
| --- @param text string | --- @param text string | ||||||
| @ -79,6 +83,14 @@ function hilbish.goro(fn) end | |||||||
| --- reality could set the input of the prompt to *display* anything. The | --- reality could set the input of the prompt to *display* anything. The | ||||||
| --- callback is passed the current line and is expected to return a line that | --- callback is passed the current line and is expected to return a line that | ||||||
| --- will be used as the input display. | --- will be used as the input display. | ||||||
|  | --- Note that to set a highlighter, one has to override this function. | ||||||
|  | --- Example: | ||||||
|  | --- ``` | ||||||
|  | --- function hilbish.highlighter(line) | ||||||
|  | ---    return line:gsub('"%w+"', function(c) return lunacolors.green(c) end) | ||||||
|  | --- end | ||||||
|  | --- ``` | ||||||
|  | --- This code will highlight all double quoted strings in green. | ||||||
| --- @param line string | --- @param line string | ||||||
| function hilbish.highlighter(line) end | function hilbish.highlighter(line) end | ||||||
| 
 | 
 | ||||||
| @ -188,10 +200,14 @@ function hilbish:autoFlush(auto) end | |||||||
| --- Flush writes all buffered input to the sink. | --- Flush writes all buffered input to the sink. | ||||||
| function hilbish:flush() end | function hilbish:flush() end | ||||||
| 
 | 
 | ||||||
| --- Reads input from the sink. | --- Reads a liine of input from the sink. | ||||||
| --- @returns string | --- @returns string | ||||||
| function hilbish:read() end | function hilbish:read() end | ||||||
| 
 | 
 | ||||||
|  | --- Reads all input from the sink. | ||||||
|  | --- @returns string | ||||||
|  | function hilbish:readAll() end | ||||||
|  | 
 | ||||||
| --- Writes data to a sink. | --- Writes data to a sink. | ||||||
| function hilbish:write(str) end | function hilbish:write(str) end | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -60,7 +60,7 @@ Available sections: ]] .. table.concat(modules, ', ') | |||||||
| 			return lunacolors.underline(lunacolors.blue(string.gsub(fname, '.md', ''))) | 			return lunacolors.underline(lunacolors.blue(string.gsub(fname, '.md', ''))) | ||||||
| 		end) | 		end) | ||||||
| 		if #moddocs ~= 0 then | 		if #moddocs ~= 0 then | ||||||
| 			funcdocs = funcdocs .. '\nSubdocs: ' .. table.concat(subdocs, ', ') | 			funcdocs = funcdocs .. '\nSubdocs: ' .. table.concat(subdocs, ', ') .. '\nLMAO' | ||||||
| 		end | 		end | ||||||
| 
 | 
 | ||||||
| 		local valsStr = funcdocs:match '%-%-%-\n([^%-%-%-]+)\n' | 		local valsStr = funcdocs:match '%-%-%-\n([^%-%-%-]+)\n' | ||||||
|  | |||||||
| @ -110,10 +110,21 @@ function Greenhouse:initUi() | |||||||
| 	hilbish.goro(function() | 	hilbish.goro(function() | ||||||
| 		while not done do | 		while not done do | ||||||
| 			local c = read() | 			local c = read() | ||||||
| 			if c == 3 then | 			if c == 'Ctrl-D' then | ||||||
| 				done = true | 				done = true | ||||||
| 			end | 			end | ||||||
| 
 | 
 | ||||||
|  | 			if c == 'Up' then | ||||||
|  | 				self:scroll 'up' | ||||||
|  | 			end | ||||||
|  | 			if c == 'Down' then | ||||||
|  | 				self:scroll 'down' | ||||||
|  | 			end | ||||||
|  | 
 | ||||||
|  | 			if c == 'Ctrl-Right' then self:next() end | ||||||
|  | 			if c == 'Ctrl-Left' then self:previous() end | ||||||
|  | 
 | ||||||
|  | 	--[[ | ||||||
| 			if c == 27 then | 			if c == 27 then | ||||||
| 				local c1 = read() | 				local c1 = read() | ||||||
| 				if c1 == 91 then | 				if c1 == 91 then | ||||||
| @ -141,8 +152,7 @@ function Greenhouse:initUi() | |||||||
| 				end | 				end | ||||||
| 				goto continue | 				goto continue | ||||||
| 			end | 			end | ||||||
| 			print('\nchar:') | 			]]-- | ||||||
| 			print(c) |  | ||||||
| 
 | 
 | ||||||
| 			::continue:: | 			::continue:: | ||||||
| 		end | 		end | ||||||
| @ -157,10 +167,10 @@ end | |||||||
| function read() | function read() | ||||||
| 	terminal.saveState() | 	terminal.saveState() | ||||||
| 	terminal.setRaw() | 	terminal.setRaw() | ||||||
| 	local c = io.read(1) | 	local c = hilbish.editor.readChar() | ||||||
| 
 | 
 | ||||||
| 	terminal.restoreState() | 	terminal.restoreState() | ||||||
| 	return c:byte() | 	return c | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| return Greenhouse | return Greenhouse | ||||||
|  | |||||||
| @ -1,5 +1,7 @@ | |||||||
| package readline | package readline | ||||||
| 
 | 
 | ||||||
|  | import "os" | ||||||
|  | 
 | ||||||
| // Character codes | // Character codes | ||||||
| const ( | const ( | ||||||
| 	charCtrlA = iota + 1 | 	charCtrlA = iota + 1 | ||||||
| @ -134,3 +136,57 @@ const ( | |||||||
| const ( | const ( | ||||||
| 	seqCtermFg255 = "\033[48;5;255m" | 	seqCtermFg255 = "\033[48;5;255m" | ||||||
| ) | ) | ||||||
|  | 
 | ||||||
|  | // TODO: return whether its actually a sequence or not | ||||||
|  | // remedies the edge case of someone literally typing Ctrl-A for example. | ||||||
|  | func (rl *Instance) ReadChar() string { | ||||||
|  | 	b := make([]byte, 1024) | ||||||
|  | 	i, _ := os.Stdin.Read(b) | ||||||
|  | 	r := []rune(string(b)) | ||||||
|  | 	s := string(r[:i]) | ||||||
|  | 
 | ||||||
|  | 	switch b[0] { | ||||||
|  | 		case charCtrlA: return "Ctrl-A" | ||||||
|  | 		case charCtrlB: return "Ctrl-B" | ||||||
|  | 		case charCtrlC: return "Ctrl-C" | ||||||
|  | 		case charEOF: return "Ctrl-D" | ||||||
|  | 		case charCtrlE: return "Ctrl-E" | ||||||
|  | 		case charCtrlF: return "Ctrl-F" | ||||||
|  | 		case charCtrlG: return "Ctrl-G" | ||||||
|  | 		case charBackspace, charBackspace2: return "Backspace" | ||||||
|  | 		case charTab: return "Tab" | ||||||
|  | 		case charCtrlJ: return "Ctrl-J" | ||||||
|  | 		case charCtrlK: return "Ctrl-K" | ||||||
|  | 		case charCtrlL: return "Ctrl-L" | ||||||
|  | 		case charCtrlM: return "Ctrl-M" | ||||||
|  | 		case charCtrlN: return "Ctrl-N" | ||||||
|  | 		case charCtrlO: return "Ctrl-O" | ||||||
|  | 		case charCtrlP: return "Ctrl-P" | ||||||
|  | 		case charCtrlQ: return "Ctrl-Q" | ||||||
|  | 		case charCtrlR: return "Ctrl-R" | ||||||
|  | 		case charCtrlS: return "Ctrl-S" | ||||||
|  | 		case charCtrlT: return "Ctrl-T" | ||||||
|  | 		case charCtrlU: return "Ctrl-U" | ||||||
|  | 		case charCtrlV: return "Ctrl-V" | ||||||
|  | 		case charCtrlW: return "Ctrl-W" | ||||||
|  | 		case charCtrlX: return "Ctrl-X" | ||||||
|  | 		case charCtrlY: return "Ctrl-Y" | ||||||
|  | 		case charCtrlZ: return "Ctrl-Z" | ||||||
|  | 		case charEscape: | ||||||
|  | 			switch s { | ||||||
|  | 				case string(charEscape): return "Escape" | ||||||
|  | 				case seqUp: return "Up" | ||||||
|  | 				case seqDown: return "Down" | ||||||
|  | 				case seqBackwards: return "Left" | ||||||
|  | 				case seqForwards: return "Right" | ||||||
|  | 				case seqCtrlLeftArrow: return "Ctrl-Left" | ||||||
|  | 				case seqCtrlRightArrow: return "Ctrl-Right" | ||||||
|  | 				case seqCtrlDelete, seqCtrlDelete2: return "Ctrl-Delete" | ||||||
|  | 				case seqHome, seqHomeSc: return "Home" | ||||||
|  | 				case seqEnd, seqEndSc: return "End" | ||||||
|  | 				case seqDelete, seqDelete2: return "Delete" | ||||||
|  | 			} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return "???" | ||||||
|  | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user