mirror of https://github.com/Hilbis/Hilbish
Compare commits
7 Commits
2e21af4d6b
...
51b1219003
Author | SHA1 | Date |
---|---|---|
TorchedSammy | 51b1219003 | |
TorchedSammy | dd45766bae | |
TorchedSammy | 144e158473 | |
TorchedSammy | dedb8cbf76 | |
TorchedSammy | 284d4e01a3 | |
TorchedSammy | 3d36786cc7 | |
TorchedSammy | 074c5f6766 |
|
@ -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, "throw", luar.New(L, b.bthrow))
|
||||||
L.SetField(mod, "catch", luar.New(L, b.bcatch))
|
L.SetField(mod, "catch", luar.New(L, b.bcatch))
|
||||||
|
L.SetField(mod, "catchOnce", luar.New(L, b.bcatchOnce))
|
||||||
|
|
||||||
L.Push(mod)
|
L.Push(mod)
|
||||||
|
|
||||||
|
@ -55,3 +56,9 @@ func (b *Bait) bthrow(name string, args ...interface{}) {
|
||||||
func (b *Bait) bcatch(name string, catcher func(...interface{})) {
|
func (b *Bait) bcatch(name string, catcher func(...interface{})) {
|
||||||
b.Em.On(name, catcher)
|
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)
|
||||||
|
}
|
||||||
|
|
|
@ -5,11 +5,11 @@ local lunacolors = require 'lunacolors'
|
||||||
local ansikit = {}
|
local ansikit = {}
|
||||||
|
|
||||||
ansikit.clear = function(scrollback)
|
ansikit.clear = function(scrollback)
|
||||||
typ = (scrollback and 3 or 2)
|
local typ = (scrollback and 3 or 2)
|
||||||
return ansikit.printCSI(typ, 'J')
|
return ansikit.printCSI(typ, 'J')
|
||||||
end
|
end
|
||||||
|
|
||||||
ansikit.clearFromPos = function(scrollback)
|
ansikit.clearFromPos = function()
|
||||||
return ansikit.printCSI(0, 'J')
|
return ansikit.printCSI(0, 'J')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ end
|
||||||
ansikit.cursorStyle = function(style)
|
ansikit.cursorStyle = function(style)
|
||||||
style = (style and style or ansikit.underlineCursor)
|
style = (style and style or ansikit.underlineCursor)
|
||||||
if style > 6 or style < 1 then style = ansikit.underlineCursor end
|
if style > 6 or style < 1 then style = ansikit.underlineCursor end
|
||||||
|
|
||||||
return ansikit.printCSI(style, ' q')
|
return ansikit.printCSI(style, ' q')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ end
|
||||||
|
|
||||||
ansikit.link = function(url, text)
|
ansikit.link = function(url, text)
|
||||||
if not url then error 'ansikit: missing url for hyperlink' end
|
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')
|
return lunacolors.blue('\27]8;;' .. url .. '\27\\' .. text .. '\27]8;;\27\\\n')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
17
preload.lua
17
preload.lua
|
@ -1,9 +1,9 @@
|
||||||
-- The preload file initializes everything else for our shell
|
-- The preload file initializes everything else for our shell
|
||||||
|
|
||||||
local fs = require 'fs'
|
|
||||||
local commander = require 'commander'
|
|
||||||
local bait = require 'bait'
|
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 oldDir = hilbish.cwd()
|
||||||
|
|
||||||
local shlvl = tonumber(os.getenv 'SHLVL')
|
local shlvl = tonumber(os.getenv 'SHLVL')
|
||||||
|
@ -37,8 +37,6 @@ commander.register('cd', function (args)
|
||||||
end
|
end
|
||||||
fs.cd(hilbish.home)
|
fs.cd(hilbish.home)
|
||||||
bait.throw('cd', hilbish.home)
|
bait.throw('cd', hilbish.home)
|
||||||
|
|
||||||
return
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
commander.register('exit', function()
|
commander.register('exit', function()
|
||||||
|
@ -74,8 +72,8 @@ These are the global Hilbish functions that are always available and not part of
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
funcdocs = f:read '*a'
|
funcdocs = f:read '*a'
|
||||||
local subdocs = table.map(fs.readdir(moddocPath), function(f)
|
local subdocs = table.map(fs.readdir(moddocPath), function(fname)
|
||||||
return lunacolors.underline(lunacolors.blue(string.gsub(f, '.txt', '')))
|
return lunacolors.underline(lunacolors.blue(string.gsub(fname, '.txt', '')))
|
||||||
end)
|
end)
|
||||||
if subdocName == 'index' then
|
if subdocName == 'index' then
|
||||||
funcdocs = funcdocs .. '\nSubdocs: ' .. table.concat(subdocs, ', ')
|
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: ]]
|
Available sections: ]]
|
||||||
|
|
||||||
print(table.concat(modules, ', '))
|
print(table.concat(modules, ', '))
|
||||||
|
|
||||||
return
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
do
|
do
|
||||||
|
@ -207,7 +203,6 @@ to get a list of recent directories, use {green}{underline}cdr list{reset}]])
|
||||||
end
|
end
|
||||||
|
|
||||||
fs.cd(recentDirs[index])
|
fs.cd(recentDirs[index])
|
||||||
return
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Hook handles
|
-- Hook handles
|
||||||
|
|
Loading…
Reference in New Issue