Is there an easy way to color/control console output?

Hello everyone, is there an easy way for me to color my console
output? What about updating just a particular x/y coordinate? I
don’t have time to learn Tk right now for a graphical GUI but just
being able to control the color and locations of what I print out
would be so nice. I am on windows right now but I would like the code
to be cross platform if it as all possible. Anyone here have any
suggestions for something light weight?

On Feb 5, 7:13 pm, Andy [email protected] wrote:

“I have a great faith in fools; self-confidence my friends call it.” -
Edgar Allen Poe

Take a look at ncurses. I’ve never used the ruby extension for it,
but it’s a fairly easy way to manipulate the console. There is color
support. Also, Coderay (http://coderay.rubychan.de/) is a gem that
colorizes text based on coding language.

On Wed, Feb 06, 2008 at 09:54:55AM +0900, Reacher wrote:

-Andy
“I have a great faith in fools; self-confidence my friends call it.” -
Edgar Allen Poe

Take a look at ncurses. I’ve never used the ruby extension for it,
but it’s a fairly easy way to manipulate the console. There is color
support. Also, Coderay (http://coderay.rubychan.de/) is a gem that
colorizes text based on coding language.

Also look at highline (http://highline.rubyforge.org/). It has
themeable colorized output for command line interfaces.

http://highline.rubyforge.org/doc/classes/HighLine/ColorScheme.html

enjoy,

-jeremy

See:

http://benjaminbaka.wordpress.com/2008/02/06/console-output-with-color-using-ruby/

Thank you all very much for your info and links. It’s very much
appreciated.


-Andy
“I have a great faith in fools; self-confidence my friends call it.” –
Edgar Allen Poe

On Feb 5, 7:13 pm, Andy [email protected] wrote:

Hello everyone, is there an easy way for me to color my console
output? What about updating just a particular x/y coordinate? I
don’t have time to learn Tk right now for a graphical GUI but just
being able to control the color and locations of what I print out
would be so nice. I am on windows right now but I would like the code
to be cross platform if it as all possible. Anyone here have any
suggestions for something light weight?

If all you need is basic ANSI, ie. color:

$ gem install facets
$ irb

require ‘facets/ansicode’
include Console::ANSICode

p red, “Hello”, blue, “World”
“\e[31mHello\e[34mWorld”

p red{ “Hello” } + blue{ “World” }
“\e[31mHello\e[0m\e[34mWorld\e[0m”

We have Florian F. to thank for the original version of this lib.

T.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs