lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I also wrote a similar module, with a focus on colors:

http://github.com/hoelzro/ansicolors/blob/master/ansicolors.lua

You can use this module as follows:

local colors = require 'ansicolors'

print(colors.red('hello'))
print(colors.red .. 'hello' .. colors.reset)
print(colors.red, 'hello', colors.reset)

- -Rob

Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:

> BTW, here is a simple ANSI terminal module that you may find useful.
> 
> term={
> 	output=io.write,
> 	clear = function () term.output("\027[2J") end,
> 	cleareol = function () term.output("\027[K") end,
> 	goto = function (l,c) term.output("\027[",l,";",c,"H") end,
> 	goup = function (n) term.output("\027[",n or 1,";","A") end,
> 	godown = function (n) term.output("\027[",n or 1,";","B") end,
> 	goright = function (n) term.output("\027[",n or 1,";","C")
> end, goleft = function (n) term.output("\027[",n or 1,";","D") end,
> 	color = function (f,b) term.output("\027[",f,";",b,"m") end,
> 	save = function () term.output("\027[s") end,
> 	restore = function () term.output("\027[u") end,
> }
> 
> --term.clear()
> term.goto(10,1)
> term.cleareol()
> term.goto(10,10)
> term.output("hello!")
> term.color(31,42)
> term.output("bye!")
> term.color(43,31)
> term.output("tchau mesmo!")
> term.color(0,0)
> term.output("ok!")
> term.goup(4)
> term.goleft(8)
> term.output("here")
> term.save()
> term.goto(2,3)
> term.output("HERE")
> term.restore()
> term.output("DONE")
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkw/BywACgkQUoGaR6SGEaqkBgCfd+jTzKtdS0HLvcqkxqRyJ1IT
AvkAniumX0WJ3fH9QHU7bHiPKiSCRaXr
=oURc
-----END PGP SIGNATURE-----