Compare commits

..

7 Commits

Author SHA1 Message Date
TorchedSammy 51b1219003
feat(bait): add catchOnce function 2021-12-04 17:59:19 -04:00
TorchedSammy dd45766bae
style: dont redeclare function param, just assign 2021-12-04 17:56:45 -04:00
TorchedSammy 144e158473
chore: remove unused function param 2021-12-04 17:56:11 -04:00
TorchedSammy dedb8cbf76
chore: make typ a local 2021-12-04 17:54:04 -04:00
TorchedSammy 284d4e01a3
chore: rename f to fname in subdoc map (doesnt redefine f) 2021-12-04 17:53:34 -04:00
TorchedSammy 3d36786cc7
chore: remove redundant returns 2021-12-04 17:53:10 -04:00
TorchedSammy 074c5f6766
fix: require lunacolors in preload 2021-12-04 17:50:04 -04:00
3 changed files with 17 additions and 15 deletions

View File

@ -38,6 +38,7 @@ failed, etc. To find all available hooks, see doc hooks.`)
L.SetField(mod, "throw", luar.New(L, b.bthrow))
L.SetField(mod, "catch", luar.New(L, b.bcatch))
L.SetField(mod, "catchOnce", luar.New(L, b.bcatchOnce))
L.Push(mod)
@ -55,3 +56,9 @@ func (b *Bait) bthrow(name string, args ...interface{}) {
func (b *Bait) bcatch(name string, catcher func(...interface{})) {
b.Em.On(name, catcher)
}
// catchOnce(name, cb)
// Same as catch, but only runs the `cb` once and then removes the hook
func (b *Bait) bcatchOnce(name string, catcher func(...interface{})) {
b.Em.Once(name, catcher)
}

View File

@ -5,11 +5,11 @@ local lunacolors = require 'lunacolors'
local ansikit = {}
ansikit.clear = function(scrollback)
typ = (scrollback and 3 or 2)
local typ = (scrollback and 3 or 2)
return ansikit.printCSI(typ, 'J')
end
ansikit.clearFromPos = function(scrollback)
ansikit.clearFromPos = function()
return ansikit.printCSI(0, 'J')
end
@ -47,7 +47,7 @@ end
ansikit.cursorStyle = function(style)
style = (style and style or ansikit.underlineCursor)
if style > 6 or style < 1 then style = ansikit.underlineCursor end
return ansikit.printCSI(style, ' q')
end
@ -79,7 +79,7 @@ end
ansikit.link = function(url, text)
if not url then error 'ansikit: missing url for hyperlink' end
local text = (text and text or 'link')
text = (text and text or 'link')
return lunacolors.blue('\27]8;;' .. url .. '\27\\' .. text .. '\27]8;;\27\\\n')
end

View File

@ -1,9 +1,9 @@
-- The preload file initializes everything else for our shell
local fs = require 'fs'
local commander = require 'commander'
local bait = require 'bait'
require 'succulent' -- Function additions
local commander = require 'commander'
local fs = require 'fs'
local lunacolors = require 'lunacolors'
local _ require 'succulent' -- Function additions
local oldDir = hilbish.cwd()
local shlvl = tonumber(os.getenv 'SHLVL')
@ -37,8 +37,6 @@ commander.register('cd', function (args)
end
fs.cd(hilbish.home)
bait.throw('cd', hilbish.home)
return
end)
commander.register('exit', function()
@ -74,8 +72,8 @@ These are the global Hilbish functions that are always available and not part of
return
end
funcdocs = f:read '*a'
local subdocs = table.map(fs.readdir(moddocPath), function(f)
return lunacolors.underline(lunacolors.blue(string.gsub(f, '.txt', '')))
local subdocs = table.map(fs.readdir(moddocPath), function(fname)
return lunacolors.underline(lunacolors.blue(string.gsub(fname, '.txt', '')))
end)
if subdocName == 'index' then
funcdocs = funcdocs .. '\nSubdocs: ' .. table.concat(subdocs, ', ')
@ -135,8 +133,6 @@ A section is a module or a literal section and a subdoc is a subsection for it.
Available sections: ]]
print(table.concat(modules, ', '))
return
end)
do
@ -207,7 +203,6 @@ to get a list of recent directories, use {green}{underline}cdr list{reset}]])
end
fs.cd(recentDirs[index])
return
end)
-- Hook handles