feat(ansikit): add link function

pull/78/head
sammyette 2021-10-17 13:23:58 -04:00
parent 6b065dc035
commit 85b347d5f3
No known key found for this signature in database
GPG Key ID: 50EE40A2809851F5
1 changed files with 7 additions and 1 deletions

View File

@ -1,7 +1,7 @@
-- We're basically porting Ansikit to lua -- We're basically porting Ansikit to lua
-- https://github.com/Luvella/AnsiKit/blob/master/lib/index.js -- https://github.com/Luvella/AnsiKit/blob/master/lib/index.js
-- which is made by yours truly sammy :^) -- which is made by yours truly sammy :^)
local lunacolors = require 'lunacolors'
local ansikit = {} local ansikit = {}
ansikit.clear = function(scrollback) ansikit.clear = function(scrollback)
@ -77,6 +77,12 @@ ansikit.hideCursor = function()
return ansikit.printCSI('?25', 'l') return ansikit.printCSI('?25', 'l')
end end
ansikit.link = function(url, text)
if not url then error 'ansikit: missing url for hyperlink' end
local text = (text and text or 'link')
io.write(lunacolors.blue('\27]8;;' .. url .. '\27\\' .. text .. '\27]8;;\27\\\n'))
end
ansikit.print = function(text) ansikit.print = function(text)
io.write(ansikit.format(text)) io.write(ansikit.format(text))
return ansikit return ansikit