Compare commits

..

1 Commits

Author SHA1 Message Date
sammyette 5d8b63d682
Merge 42d86f2d37 into a0513c0a05 2023-12-18 12:26:15 +00:00
23 changed files with 94 additions and 231 deletions

2
api.go
View File

@ -403,7 +403,7 @@ hilbish.appendPath '~/go/bin'
-- Will add ~/go/bin to the command path. -- Will add ~/go/bin to the command path.
-- Or do multiple: -- Or do multiple:
hilbish.appendPath { hilbush.appendPath {
'~/go/bin', '~/go/bin',
'~/.local/bin' '~/.local/bin'
} }

View File

@ -533,7 +533,7 @@ func main() {
if dps.IsMember { if dps.IsMember {
continue continue
} }
f.WriteString(fmt.Sprintf("<hr>\n<div id='%s'>", dps.FuncName)) f.WriteString(fmt.Sprintf("<hr><div id='%s'>", dps.FuncName))
htmlSig := typeTag.ReplaceAllStringFunc(strings.Replace(modname + "." + dps.FuncSig, "<", `\<`, -1), func(typ string) string { htmlSig := typeTag.ReplaceAllStringFunc(strings.Replace(modname + "." + dps.FuncSig, "<", `\<`, -1), func(typ string) string {
typName := typ[1:] typName := typ[1:]
typLookup := typeTable[strings.ToLower(typName)] typLookup := typeTable[strings.ToLower(typName)]

View File

@ -41,8 +41,7 @@ this function will set the user prompt.
|<a href="#release">release(name, catcher)</a>|Removes the `catcher` for the event with `name`.| |<a href="#release">release(name, catcher)</a>|Removes the `catcher` for the event with `name`.|
|<a href="#throw">throw(name, ...args)</a>|Throws a hook with `name` with the provided `args`.| |<a href="#throw">throw(name, ...args)</a>|Throws a hook with `name` with the provided `args`.|
<hr> <hr><div id='catch'>
<div id='catch'>
<h4 class='heading'> <h4 class='heading'>
bait.catch(name, cb) bait.catch(name, cb)
<a href="#catch" class='heading-link'> <a href="#catch" class='heading-link'>
@ -68,8 +67,7 @@ end)
``` ```
</div> </div>
<hr> <hr><div id='catchOnce'>
<div id='catchOnce'>
<h4 class='heading'> <h4 class='heading'>
bait.catchOnce(name, cb) bait.catchOnce(name, cb)
<a href="#catchOnce" class='heading-link'> <a href="#catchOnce" class='heading-link'>
@ -87,8 +85,7 @@ The function that will be called when the event is thrown.
</div> </div>
<hr> <hr><div id='hooks'>
<div id='hooks'>
<h4 class='heading'> <h4 class='heading'>
bait.hooks(name) -> table bait.hooks(name) -> table
<a href="#hooks" class='heading-link'> <a href="#hooks" class='heading-link'>
@ -103,8 +100,7 @@ The name of the function
</div> </div>
<hr> <hr><div id='release'>
<div id='release'>
<h4 class='heading'> <h4 class='heading'>
bait.release(name, catcher) bait.release(name, catcher)
<a href="#release" class='heading-link'> <a href="#release" class='heading-link'>
@ -136,8 +132,7 @@ bait.release('event', hookCallback)
``` ```
</div> </div>
<hr> <hr><div id='throw'>
<div id='throw'>
<h4 class='heading'> <h4 class='heading'>
bait.throw(name, ...args) bait.throw(name, ...args)
<a href="#throw" class='heading-link'> <a href="#throw" class='heading-link'>

View File

@ -42,8 +42,7 @@ This sink is for writing errors, as the name would suggest.
|<a href="#deregister">deregister(name)</a>|Removes the named command. Note that this will only remove Commander-registered commands.| |<a href="#deregister">deregister(name)</a>|Removes the named command. Note that this will only remove Commander-registered commands.|
|<a href="#register">register(name, cb)</a>|Adds a new command with the given `name`. When Hilbish has to run a command with a name,| |<a href="#register">register(name, cb)</a>|Adds a new command with the given `name`. When Hilbish has to run a command with a name,|
<hr> <hr><div id='deregister'>
<div id='deregister'>
<h4 class='heading'> <h4 class='heading'>
commander.deregister(name) commander.deregister(name)
<a href="#deregister" class='heading-link'> <a href="#deregister" class='heading-link'>
@ -58,8 +57,7 @@ Name of the command to remove.
</div> </div>
<hr> <hr><div id='register'>
<div id='register'>
<h4 class='heading'> <h4 class='heading'>
commander.register(name, cb) commander.register(name, cb)
<a href="#register" class='heading-link'> <a href="#register" class='heading-link'>

View File

@ -31,8 +31,7 @@ library offers more functions and will work on any operating system Hilbish does
|----|----| |----|----|
|pathSep|The operating system's path separator.| |pathSep|The operating system's path separator.|
<hr> <hr><div id='abs'>
<div id='abs'>
<h4 class='heading'> <h4 class='heading'>
fs.abs(path) -> string fs.abs(path) -> string
<a href="#abs" class='heading-link'> <a href="#abs" class='heading-link'>
@ -48,8 +47,7 @@ This can be used to resolve short paths like `..` to `/home/user`.
</div> </div>
<hr> <hr><div id='basename'>
<div id='basename'>
<h4 class='heading'> <h4 class='heading'>
fs.basename(path) -> string fs.basename(path) -> string
<a href="#basename" class='heading-link'> <a href="#basename" class='heading-link'>
@ -65,8 +63,7 @@ Path to get the base name of.
</div> </div>
<hr> <hr><div id='cd'>
<div id='cd'>
<h4 class='heading'> <h4 class='heading'>
fs.cd(dir) fs.cd(dir)
<a href="#cd" class='heading-link'> <a href="#cd" class='heading-link'>
@ -81,8 +78,7 @@ Path to change directory to.
</div> </div>
<hr> <hr><div id='dir'>
<div id='dir'>
<h4 class='heading'> <h4 class='heading'>
fs.dir(path) -> string fs.dir(path) -> string
<a href="#dir" class='heading-link'> <a href="#dir" class='heading-link'>
@ -98,8 +94,7 @@ Path to get the directory for.
</div> </div>
<hr> <hr><div id='glob'>
<div id='glob'>
<h4 class='heading'> <h4 class='heading'>
fs.glob(pattern) -> matches (table) fs.glob(pattern) -> matches (table)
<a href="#glob" class='heading-link'> <a href="#glob" class='heading-link'>
@ -130,8 +125,7 @@ print(matches)
``` ```
</div> </div>
<hr> <hr><div id='join'>
<div id='join'>
<h4 class='heading'> <h4 class='heading'>
fs.join(...path) -> string fs.join(...path) -> string
<a href="#join" class='heading-link'> <a href="#join" class='heading-link'>
@ -154,8 +148,7 @@ print(fs.join(hilbish.userDir.config, 'hilbish'))
``` ```
</div> </div>
<hr> <hr><div id='mkdir'>
<div id='mkdir'>
<h4 class='heading'> <h4 class='heading'>
fs.mkdir(name, recursive) fs.mkdir(name, recursive)
<a href="#mkdir" class='heading-link'> <a href="#mkdir" class='heading-link'>
@ -182,8 +175,7 @@ Whether to create parent directories for the provided name
``` ```
</div> </div>
<hr> <hr><div id='readdir'>
<div id='readdir'>
<h4 class='heading'> <h4 class='heading'>
fs.readdir(path) -> table[string] fs.readdir(path) -> table[string]
<a href="#readdir" class='heading-link'> <a href="#readdir" class='heading-link'>
@ -198,8 +190,7 @@ Returns a list of all files and directories in the provided path.
</div> </div>
<hr> <hr><div id='stat'>
<div id='stat'>
<h4 class='heading'> <h4 class='heading'>
fs.stat(path) -> {} fs.stat(path) -> {}
<a href="#stat" class='heading-link'> <a href="#stat" class='heading-link'>

View File

@ -46,8 +46,7 @@ interfaces and functions which directly relate to shell functionality.
|vimMode|Current Vim input mode of Hilbish (will be nil if not in Vim input mode)| |vimMode|Current Vim input mode of Hilbish (will be nil if not in Vim input mode)|
|exitCode|Exit code of the last executed command| |exitCode|Exit code of the last executed command|
<hr> <hr><div id='alias'>
<div id='alias'>
<h4 class='heading'> <h4 class='heading'>
hilbish.alias(cmd, orig) hilbish.alias(cmd, orig)
<a href="#alias" class='heading-link'> <a href="#alias" class='heading-link'>
@ -76,8 +75,7 @@ hilbish.alias('dircount', 'ls %1 | wc -l')
``` ```
</div> </div>
<hr> <hr><div id='appendPath'>
<div id='appendPath'>
<h4 class='heading'> <h4 class='heading'>
hilbish.appendPath(dir) hilbish.appendPath(dir)
<a href="#appendPath" class='heading-link'> <a href="#appendPath" class='heading-link'>
@ -98,15 +96,14 @@ hilbish.appendPath '~/go/bin'
-- Will add ~/go/bin to the command path. -- Will add ~/go/bin to the command path.
-- Or do multiple: -- Or do multiple:
hilbish.appendPath { hilbush.appendPath {
'~/go/bin', '~/go/bin',
'~/.local/bin' '~/.local/bin'
} }
``` ```
</div> </div>
<hr> <hr><div id='complete'>
<div id='complete'>
<h4 class='heading'> <h4 class='heading'>
hilbish.complete(scope, cb) hilbish.complete(scope, cb)
<a href="#complete" class='heading-link'> <a href="#complete" class='heading-link'>
@ -128,8 +125,7 @@ provides more details.
</div> </div>
<hr> <hr><div id='cwd'>
<div id='cwd'>
<h4 class='heading'> <h4 class='heading'>
hilbish.cwd() -> string hilbish.cwd() -> string
<a href="#cwd" class='heading-link'> <a href="#cwd" class='heading-link'>
@ -142,8 +138,7 @@ Returns the current directory of the shell
This function has no parameters. This function has no parameters.
</div> </div>
<hr> <hr><div id='exec'>
<div id='exec'>
<h4 class='heading'> <h4 class='heading'>
hilbish.exec(cmd) hilbish.exec(cmd)
<a href="#exec" class='heading-link'> <a href="#exec" class='heading-link'>
@ -159,8 +154,7 @@ This can be used to do an in-place restart.
</div> </div>
<hr> <hr><div id='goro'>
<div id='goro'>
<h4 class='heading'> <h4 class='heading'>
hilbish.goro(fn) hilbish.goro(fn)
<a href="#goro" class='heading-link'> <a href="#goro" class='heading-link'>
@ -177,8 +171,7 @@ This can be used to run any function in another thread.
</div> </div>
<hr> <hr><div id='highlighter'>
<div id='highlighter'>
<h4 class='heading'> <h4 class='heading'>
hilbish.highlighter(line) hilbish.highlighter(line)
<a href="#highlighter" class='heading-link'> <a href="#highlighter" class='heading-link'>
@ -205,8 +198,7 @@ end
``` ```
</div> </div>
<hr> <hr><div id='hinter'>
<div id='hinter'>
<h4 class='heading'> <h4 class='heading'>
hilbish.hinter(line, pos) hilbish.hinter(line, pos)
<a href="#hinter" class='heading-link'> <a href="#hinter" class='heading-link'>
@ -237,8 +229,7 @@ end
``` ```
</div> </div>
<hr> <hr><div id='inputMode'>
<div id='inputMode'>
<h4 class='heading'> <h4 class='heading'>
hilbish.inputMode(mode) hilbish.inputMode(mode)
<a href="#inputMode" class='heading-link'> <a href="#inputMode" class='heading-link'>
@ -255,8 +246,7 @@ Vim-like with modes and Vim keybinds.
</div> </div>
<hr> <hr><div id='interval'>
<div id='interval'>
<h4 class='heading'> <h4 class='heading'>
hilbish.interval(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a> hilbish.interval(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
<a href="#interval" class='heading-link'> <a href="#interval" class='heading-link'>
@ -275,8 +265,7 @@ This creates a timer that starts immediately.
</div> </div>
<hr> <hr><div id='multiprompt'>
<div id='multiprompt'>
<h4 class='heading'> <h4 class='heading'>
hilbish.multiprompt(str) hilbish.multiprompt(str)
<a href="#multiprompt" class='heading-link'> <a href="#multiprompt" class='heading-link'>
@ -312,8 +301,7 @@ hilbish.multiprompt '-->'
``` ```
</div> </div>
<hr> <hr><div id='prependPath'>
<div id='prependPath'>
<h4 class='heading'> <h4 class='heading'>
hilbish.prependPath(dir) hilbish.prependPath(dir)
<a href="#prependPath" class='heading-link'> <a href="#prependPath" class='heading-link'>
@ -328,8 +316,7 @@ Prepends `dir` to $PATH.
</div> </div>
<hr> <hr><div id='prompt'>
<div id='prompt'>
<h4 class='heading'> <h4 class='heading'>
hilbish.prompt(str, typ) hilbish.prompt(str, typ)
<a href="#prompt" class='heading-link'> <a href="#prompt" class='heading-link'>
@ -361,8 +348,7 @@ hilbish.prompt '%u@%h :%d $'
``` ```
</div> </div>
<hr> <hr><div id='read'>
<div id='read'>
<h4 class='heading'> <h4 class='heading'>
hilbish.read(prompt) -> input (string) hilbish.read(prompt) -> input (string)
<a href="#read" class='heading-link'> <a href="#read" class='heading-link'>
@ -379,8 +365,7 @@ Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which s
</div> </div>
<hr> <hr><div id='run'>
<div id='run'>
<h4 class='heading'> <h4 class='heading'>
hilbish.run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (string) hilbish.run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (string)
<a href="#run" class='heading-link'> <a href="#run" class='heading-link'>
@ -398,8 +383,7 @@ If this is true, the function will return the standard output and error of the c
</div> </div>
<hr> <hr><div id='runnerMode'>
<div id='runnerMode'>
<h4 class='heading'> <h4 class='heading'>
hilbish.runnerMode(mode) hilbish.runnerMode(mode)
<a href="#runnerMode" class='heading-link'> <a href="#runnerMode" class='heading-link'>
@ -418,8 +402,7 @@ will call it to execute user input instead.
</div> </div>
<hr> <hr><div id='timeout'>
<div id='timeout'>
<h4 class='heading'> <h4 class='heading'>
hilbish.timeout(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a> hilbish.timeout(cb, time) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
<a href="#timeout" class='heading-link'> <a href="#timeout" class='heading-link'>
@ -438,8 +421,7 @@ This creates a Timer that starts immediately.
</div> </div>
<hr> <hr><div id='which'>
<div id='which'>
<h4 class='heading'> <h4 class='heading'>
hilbish.which(name) -> string hilbish.which(name) -> string
<a href="#which" class='heading-link'> <a href="#which" class='heading-link'>

View File

@ -18,8 +18,7 @@ The alias interface deals with all command aliases in Hilbish.
|<a href="#aliases.list">list() -> table[string, string]</a>|Get a table of all aliases, with string keys as the alias and the value as the command.| |<a href="#aliases.list">list() -> table[string, string]</a>|Get a table of all aliases, with string keys as the alias and the value as the command.|
|<a href="#aliases.resolve">resolve(alias) -> string?</a>|Resolves an alias to its original command. Will thrown an error if the alias doesn't exist.| |<a href="#aliases.resolve">resolve(alias) -> string?</a>|Resolves an alias to its original command. Will thrown an error if the alias doesn't exist.|
<hr> <hr><div id='aliases.add'>
<div id='aliases.add'>
<h4 class='heading'> <h4 class='heading'>
hilbish.aliases.add(alias, cmd) hilbish.aliases.add(alias, cmd)
<a href="#aliases.add" class='heading-link'> <a href="#aliases.add" class='heading-link'>
@ -32,8 +31,7 @@ This is an alias (ha) for the [hilbish.alias](../#alias) function.
This function has no parameters. This function has no parameters.
</div> </div>
<hr> <hr><div id='aliases.delete'>
<div id='aliases.delete'>
<h4 class='heading'> <h4 class='heading'>
hilbish.aliases.delete(name) hilbish.aliases.delete(name)
<a href="#aliases.delete" class='heading-link'> <a href="#aliases.delete" class='heading-link'>
@ -48,8 +46,7 @@ Removes an alias.
</div> </div>
<hr> <hr><div id='aliases.list'>
<div id='aliases.list'>
<h4 class='heading'> <h4 class='heading'>
hilbish.aliases.list() -> table[string, string] hilbish.aliases.list() -> table[string, string]
<a href="#aliases.list" class='heading-link'> <a href="#aliases.list" class='heading-link'>
@ -71,8 +68,7 @@ local aliases = hilbish.aliases.list()
``` ```
</div> </div>
<hr> <hr><div id='aliases.resolve'>
<div id='aliases.resolve'>
<h4 class='heading'> <h4 class='heading'>
hilbish.aliases.resolve(alias) -> string? hilbish.aliases.resolve(alias) -> string?
<a href="#aliases.resolve" class='heading-link'> <a href="#aliases.resolve" class='heading-link'>

View File

@ -18,8 +18,7 @@ The completions interface deals with tab completions.
|<a href="#completion.files">files(query, ctx, fields) -> entries (table), prefix (string)</a>|Returns file matches based on the provided parameters.| |<a href="#completion.files">files(query, ctx, fields) -> entries (table), prefix (string)</a>|Returns file matches based on the provided parameters.|
|<a href="#completion.handler">handler(line, pos)</a>|This function contains the general completion handler for Hilbish. This function handles| |<a href="#completion.handler">handler(line, pos)</a>|This function contains the general completion handler for Hilbish. This function handles|
<hr> <hr><div id='completion.bins'>
<div id='completion.bins'>
<h4 class='heading'> <h4 class='heading'>
hilbish.completion.bins(query, ctx, fields) -> entries (table), prefix (string) hilbish.completion.bins(query, ctx, fields) -> entries (table), prefix (string)
<a href="#completion.bins" class='heading-link'> <a href="#completion.bins" class='heading-link'>
@ -61,8 +60,7 @@ end)
``` ```
</div> </div>
<hr> <hr><div id='completion.call'>
<div id='completion.call'>
<h4 class='heading'> <h4 class='heading'>
hilbish.completion.call(name, query, ctx, fields) -> completionGroups (table), prefix (string) hilbish.completion.call(name, query, ctx, fields) -> completionGroups (table), prefix (string)
<a href="#completion.call" class='heading-link'> <a href="#completion.call" class='heading-link'>
@ -88,8 +86,7 @@ You can check the Completions doc or `doc completions` for info on the `completi
</div> </div>
<hr> <hr><div id='completion.files'>
<div id='completion.files'>
<h4 class='heading'> <h4 class='heading'>
hilbish.completion.files(query, ctx, fields) -> entries (table), prefix (string) hilbish.completion.files(query, ctx, fields) -> entries (table), prefix (string)
<a href="#completion.files" class='heading-link'> <a href="#completion.files" class='heading-link'>
@ -111,8 +108,7 @@ This function is meant to be used as a helper in a command completion handler.
</div> </div>
<hr> <hr><div id='completion.handler'>
<div id='completion.handler'>
<h4 class='heading'> <h4 class='heading'>
hilbish.completion.handler(line, pos) hilbish.completion.handler(line, pos)
<a href="#completion.handler" class='heading-link'> <a href="#completion.handler" class='heading-link'>

View File

@ -20,8 +20,7 @@ directly interact with the line editor in use.
|<a href="#editor.getChar">getChar() -> string</a>|Reads a keystroke from the user. This is in a format of something like Ctrl-L.| |<a href="#editor.getChar">getChar() -> string</a>|Reads a keystroke from the user. This is in a format of something like Ctrl-L.|
|<a href="#editor.setVimRegister">setVimRegister(register, text)</a>|Sets the vim register at `register` to hold the passed text.| |<a href="#editor.setVimRegister">setVimRegister(register, text)</a>|Sets the vim register at `register` to hold the passed text.|
<hr> <hr><div id='editor.getLine'>
<div id='editor.getLine'>
<h4 class='heading'> <h4 class='heading'>
hilbish.editor.getLine() -> string hilbish.editor.getLine() -> string
<a href="#editor.getLine" class='heading-link'> <a href="#editor.getLine" class='heading-link'>
@ -34,8 +33,7 @@ Returns the current input line.
This function has no parameters. This function has no parameters.
</div> </div>
<hr> <hr><div id='editor.getVimRegister'>
<div id='editor.getVimRegister'>
<h4 class='heading'> <h4 class='heading'>
hilbish.editor.getVimRegister(register) -> string hilbish.editor.getVimRegister(register) -> string
<a href="#editor.getVimRegister" class='heading-link'> <a href="#editor.getVimRegister" class='heading-link'>
@ -50,8 +48,7 @@ Returns the text that is at the register.
</div> </div>
<hr> <hr><div id='editor.insert'>
<div id='editor.insert'>
<h4 class='heading'> <h4 class='heading'>
hilbish.editor.insert(text) hilbish.editor.insert(text)
<a href="#editor.insert" class='heading-link'> <a href="#editor.insert" class='heading-link'>
@ -66,8 +63,7 @@ Inserts text into the Hilbish command line.
</div> </div>
<hr> <hr><div id='editor.getChar'>
<div id='editor.getChar'>
<h4 class='heading'> <h4 class='heading'>
hilbish.editor.getChar() -> string hilbish.editor.getChar() -> string
<a href="#editor.getChar" class='heading-link'> <a href="#editor.getChar" class='heading-link'>
@ -80,8 +76,7 @@ Reads a keystroke from the user. This is in a format of something like Ctrl-L.
This function has no parameters. This function has no parameters.
</div> </div>
<hr> <hr><div id='editor.setVimRegister'>
<div id='editor.setVimRegister'>
<h4 class='heading'> <h4 class='heading'>
hilbish.editor.setVimRegister(register, text) hilbish.editor.setVimRegister(register, text)
<a href="#editor.setVimRegister" class='heading-link'> <a href="#editor.setVimRegister" class='heading-link'>

View File

@ -21,8 +21,7 @@ method of saving history.
|<a href="#history.get">get(index)</a>|Retrieves a command from the history based on the `index`.| |<a href="#history.get">get(index)</a>|Retrieves a command from the history based on the `index`.|
|<a href="#history.size">size() -> number</a>|Returns the amount of commands in the history.| |<a href="#history.size">size() -> number</a>|Returns the amount of commands in the history.|
<hr> <hr><div id='history.add'>
<div id='history.add'>
<h4 class='heading'> <h4 class='heading'>
hilbish.history.add(cmd) hilbish.history.add(cmd)
<a href="#history.add" class='heading-link'> <a href="#history.add" class='heading-link'>
@ -37,8 +36,7 @@ Adds a command to the history.
</div> </div>
<hr> <hr><div id='history.all'>
<div id='history.all'>
<h4 class='heading'> <h4 class='heading'>
hilbish.history.all() -> table hilbish.history.all() -> table
<a href="#history.all" class='heading-link'> <a href="#history.all" class='heading-link'>
@ -51,8 +49,7 @@ Retrieves all history as a table.
This function has no parameters. This function has no parameters.
</div> </div>
<hr> <hr><div id='history.clear'>
<div id='history.clear'>
<h4 class='heading'> <h4 class='heading'>
hilbish.history.clear() hilbish.history.clear()
<a href="#history.clear" class='heading-link'> <a href="#history.clear" class='heading-link'>
@ -65,8 +62,7 @@ Deletes all commands from the history.
This function has no parameters. This function has no parameters.
</div> </div>
<hr> <hr><div id='history.get'>
<div id='history.get'>
<h4 class='heading'> <h4 class='heading'>
hilbish.history.get(index) hilbish.history.get(index)
<a href="#history.get" class='heading-link'> <a href="#history.get" class='heading-link'>
@ -81,8 +77,7 @@ Retrieves a command from the history based on the `index`.
</div> </div>
<hr> <hr><div id='history.size'>
<div id='history.size'>
<h4 class='heading'> <h4 class='heading'>
hilbish.history.size() -> number hilbish.history.size() -> number
<a href="#history.size" class='heading-link'> <a href="#history.size" class='heading-link'>

View File

@ -23,8 +23,7 @@ interactive usage or with the functions defined below for use in external runner
|<a href="#jobs.get">get(id) -> @Job</a>|Get a job object via its ID.| |<a href="#jobs.get">get(id) -> @Job</a>|Get a job object via its ID.|
|<a href="#jobs.last">last() -> @Job</a>|Returns the last added job to the table.| |<a href="#jobs.last">last() -> @Job</a>|Returns the last added job to the table.|
<hr> <hr><div id='jobs.add'>
<div id='jobs.add'>
<h4 class='heading'> <h4 class='heading'>
hilbish.jobs.add(cmdstr, args, execPath) hilbish.jobs.add(cmdstr, args, execPath)
<a href="#jobs.add" class='heading-link'> <a href="#jobs.add" class='heading-link'>
@ -52,8 +51,7 @@ hilbish.jobs.add('go build', {'go', 'build'}, '/usr/bin/go')
``` ```
</div> </div>
<hr> <hr><div id='jobs.all'>
<div id='jobs.all'>
<h4 class='heading'> <h4 class='heading'>
hilbish.jobs.all() -> table[<a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>] hilbish.jobs.all() -> table[<a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>]
<a href="#jobs.all" class='heading-link'> <a href="#jobs.all" class='heading-link'>
@ -66,8 +64,7 @@ Returns a table of all job objects.
This function has no parameters. This function has no parameters.
</div> </div>
<hr> <hr><div id='jobs.disown'>
<div id='jobs.disown'>
<h4 class='heading'> <h4 class='heading'>
hilbish.jobs.disown(id) hilbish.jobs.disown(id)
<a href="#jobs.disown" class='heading-link'> <a href="#jobs.disown" class='heading-link'>
@ -82,8 +79,7 @@ Disowns a job. This simply deletes it from the list of jobs without stopping it.
</div> </div>
<hr> <hr><div id='jobs.get'>
<div id='jobs.get'>
<h4 class='heading'> <h4 class='heading'>
hilbish.jobs.get(id) -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a> hilbish.jobs.get(id) -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>
<a href="#jobs.get" class='heading-link'> <a href="#jobs.get" class='heading-link'>
@ -96,8 +92,7 @@ Get a job object via its ID.
This function has no parameters. This function has no parameters.
</div> </div>
<hr> <hr><div id='jobs.last'>
<div id='jobs.last'>
<h4 class='heading'> <h4 class='heading'>
hilbish.jobs.last() -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a> hilbish.jobs.last() -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>
<a href="#jobs.last" class='heading-link'> <a href="#jobs.last" class='heading-link'>

View File

@ -53,8 +53,7 @@ If you attempt to require and print the result (`print(require 'plugin')`), it w
|----|----| |----|----|
|paths|A list of paths to search when loading native modules. This is in the style of Lua search paths and will be used when requiring native modules. Example: `?.so;?/?.so`| |paths|A list of paths to search when loading native modules. This is in the style of Lua search paths and will be used when requiring native modules. Example: `?.so;?/?.so`|
<hr> <hr><div id='module.load'>
<div id='module.load'>
<h4 class='heading'> <h4 class='heading'>
hilbish.module.load(path) hilbish.module.load(path)
<a href="#module.load" class='heading-link'> <a href="#module.load" class='heading-link'>

View File

@ -21,8 +21,7 @@ write command in Fennel.
|<a href="#runner.lua">lua(cmd)</a>|Evaluates `cmd` as Lua input. This is the same as using `dofile`| |<a href="#runner.lua">lua(cmd)</a>|Evaluates `cmd` as Lua input. This is the same as using `dofile`|
|<a href="#runner.sh">sh(cmd)</a>|Runs a command in Hilbish's shell script interpreter.| |<a href="#runner.sh">sh(cmd)</a>|Runs a command in Hilbish's shell script interpreter.|
<hr> <hr><div id='runner.setMode'>
<div id='runner.setMode'>
<h4 class='heading'> <h4 class='heading'>
hilbish.runner.setMode(cb) hilbish.runner.setMode(cb)
<a href="#runner.setMode" class='heading-link'> <a href="#runner.setMode" class='heading-link'>
@ -40,8 +39,7 @@ as the higher level functions listed below this will handle it.
</div> </div>
<hr> <hr><div id='runner.lua'>
<div id='runner.lua'>
<h4 class='heading'> <h4 class='heading'>
hilbish.runner.lua(cmd) hilbish.runner.lua(cmd)
<a href="#runner.lua" class='heading-link'> <a href="#runner.lua" class='heading-link'>
@ -57,8 +55,7 @@ or `load`, but is appropriated for the runner interface.
</div> </div>
<hr> <hr><div id='runner.sh'>
<div id='runner.sh'>
<h4 class='heading'> <h4 class='heading'>
hilbish.runner.sh(cmd) hilbish.runner.sh(cmd)
<a href="#runner.sh" class='heading-link'> <a href="#runner.sh" class='heading-link'>

View File

@ -38,8 +38,7 @@ print(t.running) // true
|INTERVAL|Constant for an interval timer type| |INTERVAL|Constant for an interval timer type|
|TIMEOUT|Constant for a timeout timer type| |TIMEOUT|Constant for a timeout timer type|
<hr> <hr><div id='timers.create'>
<div id='timers.create'>
<h4 class='heading'> <h4 class='heading'>
hilbish.timers.create(type, time, callback) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a> hilbish.timers.create(type, time, callback) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
<a href="#timers.create" class='heading-link'> <a href="#timers.create" class='heading-link'>
@ -60,8 +59,7 @@ The function to run for the timer.
</div> </div>
<hr> <hr><div id='timers.get'>
<div id='timers.get'>
<h4 class='heading'> <h4 class='heading'>
hilbish.timers.get(id) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a> hilbish.timers.get(id) -> <a href="/Hilbish/docs/api/hilbish/hilbish.timers/#timer" style="text-decoration: none;" id="lol">Timer</a>
<a href="#timers.get" class='heading-link'> <a href="#timers.get" class='heading-link'>

View File

@ -18,8 +18,7 @@ The terminal library is a simple and lower level library for certain terminal in
|<a href="#setRaw">setRaw()</a>|Puts the terminal into raw mode.| |<a href="#setRaw">setRaw()</a>|Puts the terminal into raw mode.|
|<a href="#size">size()</a>|Gets the dimensions of the terminal. Returns a table with `width` and `height`| |<a href="#size">size()</a>|Gets the dimensions of the terminal. Returns a table with `width` and `height`|
<hr> <hr><div id='restoreState'>
<div id='restoreState'>
<h4 class='heading'> <h4 class='heading'>
terminal.restoreState() terminal.restoreState()
<a href="#restoreState" class='heading-link'> <a href="#restoreState" class='heading-link'>
@ -32,8 +31,7 @@ Restores the last saved state of the terminal
This function has no parameters. This function has no parameters.
</div> </div>
<hr> <hr><div id='saveState'>
<div id='saveState'>
<h4 class='heading'> <h4 class='heading'>
terminal.saveState() terminal.saveState()
<a href="#saveState" class='heading-link'> <a href="#saveState" class='heading-link'>
@ -46,8 +44,7 @@ Saves the current state of the terminal.
This function has no parameters. This function has no parameters.
</div> </div>
<hr> <hr><div id='setRaw'>
<div id='setRaw'>
<h4 class='heading'> <h4 class='heading'>
terminal.setRaw() terminal.setRaw()
<a href="#setRaw" class='heading-link'> <a href="#setRaw" class='heading-link'>
@ -60,8 +57,7 @@ Puts the terminal into raw mode.
This function has no parameters. This function has no parameters.
</div> </div>
<hr> <hr><div id='size'>
<div id='size'>
<h4 class='heading'> <h4 class='heading'>
terminal.size() terminal.size()
<a href="#size" class='heading-link'> <a href="#size" class='heading-link'>

View File

@ -1,5 +1,5 @@
--- ---
title: Signals title: Hooks
description: description:
layout: doc layout: doc
weight: -50 weight: -50
@ -7,5 +7,5 @@ menu:
docs docs
--- ---
Signals are global events emitted with the [Bait](../api/bait) module. Hooks are Hilbish's versions of events, which are used via the [Bait](../api/bait) module.
For more detail on how to use these signals, you may check the Bait page. For more detail on how to act on these hooks, you may check the Bait page.

View File

@ -4,7 +4,7 @@ description:
layout: doc layout: doc
menu: menu:
docs: docs:
parent: "Signals" parent: "Hooks"
--- ---
- `command.preexec` -> input, cmdStr > Thrown before a command - `command.preexec` -> input, cmdStr > Thrown before a command

View File

@ -4,7 +4,7 @@ description:
layout: doc layout: doc
menu: menu:
docs: docs:
parent: "Signals" parent: "Hooks"
--- ---
+ `hilbish.exit` > Sent when Hilbish is about to exit. + `hilbish.exit` > Sent when Hilbish is about to exit.

View File

@ -4,7 +4,7 @@ description:
layout: doc layout: doc
menu: menu:
docs: docs:
parent: "Signals" parent: "Hooks"
--- ---
+ `signal.sigint` > Sent when Hilbish receives SIGINT (on Ctrl-C). + `signal.sigint` > Sent when Hilbish receives SIGINT (on Ctrl-C).

View File

@ -10,8 +10,8 @@ growing to their final phase: a full plant. A lot of Hilbish itself is
written in Go, but there are parts made in Lua, being most builtins written in Go, but there are parts made in Lua, being most builtins
(`doc`, `cd`, cdr), completions, and other things. (`doc`, `cd`, cdr), completions, and other things.
Hilbish's Lua core module is called `nature`. Hilbish's Lua core module is called `nature`. It's handled after everything
It runs after Hilbish's Go core does. on the Go side initializes, which is what that first sentence was from.
# Nature Modules # Nature Modules
Currently, `nature` provides 1 intended public module: `nature.dirs`. Currently, `nature` provides 1 intended public module: `nature.dirs`.

View File

@ -6,38 +6,6 @@ local Greenhouse = require 'nature.greenhouse'
local Page = require 'nature.greenhouse.page' local Page = require 'nature.greenhouse.page'
local docfuncs = require 'nature.doc' local docfuncs = require 'nature.doc'
local function strip(text, ...)
for _, pat in ipairs {...} do
text = text:gsub(pat, '\n')
end
return text
end
local function transformHTMLandMD(text)
return strip(text, '|||', '|%-%-%-%-|%-%-%-%-|')
:gsub('|(.-)|(.-)|', function(entry1, entry2)
return string.format('%s - %s', entry1, entry2)
end)
:gsub('^\n\n', '\n')
:gsub('\n%s+\n', '\n\n')
:gsub(' \n', '\n\n')
:gsub('{{< (%w+) `(.-)` >}}', function(shortcode, text)
return docfuncs.renderInfoBlock(shortcode, text)
end)
:gsub('```(%w+)\n(.-)```', function(lang, text)
return docfuncs.renderCodeBlock(text)
end)
:gsub('```\n(.-)\n```', function(text)
return docfuncs.renderCodeBlock(text)
end)
:gsub('`[^\n].-`', lunacolors.cyan)
:gsub('#+ (.-\n)', function(heading) return lunacolors.blue(lunacolors.bold('' .. heading)) end)
:gsub('%*%*(.-)%*%*', lunacolors.bold)
:gsub('<hr>', '{separator}')
:gsub('<.->', '')
end
commander.register('doc', function(args, sinks) commander.register('doc', function(args, sinks)
local moddocPath = hilbish.dataDir .. '/docs/' local moddocPath = hilbish.dataDir .. '/docs/'
local stat = pcall(fs.stat, '.git/refs/heads/extended-job-api') local stat = pcall(fs.stat, '.git/refs/heads/extended-job-api')
@ -61,9 +29,10 @@ Available sections: ]] .. table.concat(modules, ', ')
local vals = {} local vals = {}
local docs = d local docs = d
local valsStr = docs:match '^%-%-%-\n.-\n%-%-%-' local valsStr = docs:match '%-%-%-\n([^%-%-%-]+)\n'
print(valsStr)
if valsStr then if valsStr then
docs = docs:sub(valsStr:len() + 2, #docs) docs = docs:sub(valsStr:len() + 10, #docs)
-- parse vals -- parse vals
local lines = string.split(valsStr, '\n') local lines = string.split(valsStr, '\n')
@ -148,7 +117,9 @@ Available sections: ]] .. table.concat(modules, ', ')
end end
local backtickOccurence = 0 local backtickOccurence = 0
local function formatDocText(d) local function formatDocText(d)
return transformHTMLandMD(d) return d:gsub('```(%w+)\n(.-)```', function(lang, text)
return docfuncs.renderCodeBlock(text)
end)
--[[ --[[
return lunacolors.format(d:gsub('`(.-)`', function(t) return lunacolors.format(d:gsub('`(.-)`', function(t)
return docfuncs.renderCodeBlock(t) return docfuncs.renderCodeBlock(t)
@ -160,7 +131,7 @@ Available sections: ]] .. table.concat(modules, ', ')
end end
local doc, vals = handleYamlInfo(#args == 0 and doc or formatDocText(f:read '*a')) local doc, vals = handleYamlInfo(#args == 0 and doc or formatDocText(f:read '*a':gsub('-([%d]+)', '%1')))
if #moddocs ~= 0 and f then if #moddocs ~= 0 and f then
doc = doc .. '\nSubdocs: ' .. table.concat(subdocs, ', ') .. '\n\n' doc = doc .. '\nSubdocs: ' .. table.concat(subdocs, ', ') .. '\n\n'
end end
@ -178,8 +149,8 @@ Available sections: ]] .. table.concat(modules, ', ')
end end
local f = io.open(moddocPath .. sdFile, 'rb') local f = io.open(moddocPath .. sdFile, 'rb')
local doc, vals = handleYamlInfo(formatDocText(f:read '*a')) local doc, vals = handleYamlInfo(f:read '*a':gsub('-([%d]+)', '%1'))
local page = Page(vals.title or sdName, doc) local page = Page(vals.title, formatDocText(doc))
page.description = vals.description page.description = vals.description
gh:addPage(page) gh:addPage(page)
end end

View File

@ -17,31 +17,11 @@ function M.renderCodeBlock(text)
end end
for i, line in ipairs(lines) do for i, line in ipairs(lines) do
lines[i] = ' ' .. M.highlight(line:sub(0, longest)) lines[i] = M.highlight(line:sub(0, longest))
.. string.rep(' ', longest - line:len()) .. ' ' .. string.rep(' ', longest - line:len())
end end
return '\n' .. lunacolors.format('{greyBg}' .. table.concat(lines, '\n')) .. '\n' return '\n' .. lunacolors.format('{greyBg}' .. table.concat(lines, '\n')) .. '\n'
end end
function M.renderInfoBlock(type, text)
local longest = 0
local lines = string.split(text:gsub('\t', ' '), '\n')
for i, line in ipairs(lines) do
local len = line:len()
if len > longest then longest = len end
end
for i, line in ipairs(lines) do
lines[i] = ' ' .. M.highlight(line:sub(0, longest))
.. string.rep(' ', longest - line:len()) .. ' '
end
local heading
if type == 'warning' then
heading = lunacolors.yellowBg(lunacolors.black(' ⚠ Warning '))
end
return '\n' .. heading .. '\n' .. lunacolors.format('{greyBg}' .. table.concat(lines, '\n')) .. '\n'
end
return M return M

View File

@ -18,20 +18,12 @@ function Greenhouse:new(sink)
self.contents = nil -- or can be a table self.contents = nil -- or can be a table
self.start = 1 -- where to start drawing from (should replace with self.region.y) self.start = 1 -- where to start drawing from (should replace with self.region.y)
self.offset = 1 -- vertical text offset self.offset = 1 -- vertical text offset
self.horizOffset = 1
self.sink = sink self.sink = sink
self.pages = {} self.pages = {}
self.curPage = 1 self.curPage = 1
self.step = {
horizontal = 5,
vertical = 1
}
self.separator = ''
self.keybinds = { self.keybinds = {
['Up'] = function(self) self:scroll 'up' end, ['Up'] = function(self) self:scroll 'up' end,
['Down'] = function(self) self:scroll 'down' end, ['Down'] = function(self) self:scroll 'down' end,
['Left'] = function(self) self:scroll 'left' end,
['Right'] = function(self) self:scroll 'right' end,
['Ctrl-Left'] = self.previous, ['Ctrl-Left'] = self.previous,
['Ctrl-Right'] = self.next, ['Ctrl-Right'] = self.next,
['Ctrl-N'] = function(self) self:toc(true) end, ['Ctrl-N'] = function(self) self:toc(true) end,
@ -59,7 +51,7 @@ function Greenhouse:updateCurrentPage(text)
page:setText(text) page:setText(text)
end end
function Greenhouse:sub(str, offset, limit) local function sub(str, limit)
local overhead = 0 local overhead = 0
local function addOverhead(s) local function addOverhead(s)
overhead = overhead + string.len(s) overhead = overhead + string.len(s)
@ -71,8 +63,7 @@ function Greenhouse:sub(str, offset, limit)
:gsub('\x1b%[%d+;%d+%w', addOverhead) :gsub('\x1b%[%d+;%d+%w', addOverhead)
:gsub('\x1b%[%d+%w', addOverhead) :gsub('\x1b%[%d+%w', addOverhead)
return s:sub(offset, utf8.offset(str, limit + overhead) or limit + overhead) return s:sub(0, limit + overhead)
--return s:sub(offset, limit + overhead)
end end
function Greenhouse:draw() function Greenhouse:draw()
@ -97,9 +88,7 @@ function Greenhouse:draw()
if i == offset + self.region.height - 1 then writer = self.sink.write end if i == offset + self.region.height - 1 then writer = self.sink.write end
self.sink:write(ansikit.getCSI(self.start + i - offset .. ';1', 'H')) writer(self.sink, sub(lines[i]:gsub('\t', ' '), self.region.width))
local line = lines[i]:gsub('{separator}', function() return self.separator:rep(self.region.width - 1) end)
writer(self.sink, self:sub(line:gsub('\t', ' '), self.horizOffset, self.region.width))
end end
writer(self.sink, '\27[0m') writer(self.sink, '\27[0m')
self:render() self:render()
@ -121,23 +110,13 @@ function Greenhouse:scroll(direction)
local lines = self.pages[self.curPage].lines local lines = self.pages[self.curPage].lines
local oldOffset = self.offset local oldOffset = self.offset
local oldHorizOffset = self.horizOffset
if direction == 'down' then if direction == 'down' then
self.offset = math.min(self.offset + self.step.vertical, math.max(1, #lines - self.region.height)) self.offset = math.min(self.offset + 1, math.max(1, #lines - self.region.height))
elseif direction == 'up' then elseif direction == 'up' then
self.offset = math.max(self.offset - self.step.vertical, 1) self.offset = math.max(self.offset - 1, 1)
end end
--[[
if direction == 'left' then
self.horizOffset = math.max(self.horizOffset - self.step.horizontal, 1)
elseif direction == 'right' then
self.horizOffset = self.horizOffset + self.step.horizontal
end
]]--
if self.offset ~= oldOffset then self:draw() end if self.offset ~= oldOffset then self:draw() end
if self.horizOffset ~= oldHorizOffset then self:draw() end
end end
function Greenhouse:update() function Greenhouse:update()