[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: ANSI Terminal Colors Module
- From: Rob Hoelz <rob@...>
- Date: Tue, 29 Dec 2009 11:47:00 -0600
On Tue, 29 Dec 2009 09:15:05 +0200
"Juris Kalnins" <juris@mt.lv> wrote:
> On Mon, 28 Dec 2009 22:46:05 +0200, Rob Hoelz <rob@hoelzro.net> wrote:
> > I figured I'd just start simple, but feel free to optimize! =)
>
> Well, since you say so... :)
>
> simple:
> bright = '\27[1m'
> red = '\27[31m'
> ...
> reset = '\27[m'
> ----
> print(red, "text", reset)
>
>
> more simple:
> print "\27[1;31mBAD HAPPEN!\27[m"
>
> Actually, most of the time writing escapes inline is much easier
> than using a library. And since Lua accepts control characters inside
> quotes, you actually can type ^[ character instead of \27 (when
> writing with e.g. vim or emacs) and then using "less -R" you can see
> your code in full color.
I agree most of the time, but sometimes I forget the codes for the
different colors/effects, and I figured this would also be simpler for
someone not familiar with ANSI terminal codes. (After all, I learned
them from Perl's Term::ANSIColor =) ) As far as actually typing ^[,
I'm a big fan of not seeing color when I cat my code, but to each
his/her own.
Attachment:
signature.asc
Description: PGP signature