~ubuntu-branches/ubuntu/quantal/psicode/quantal

« back to all changes in this revision

Viewing changes to lib/ruby/color.rb

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck, Michael Banck, Daniel Leidert
  • Date: 2009-02-23 00:12:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090223001202-rutldoy3dimfpesc
Tags: 3.4.0-1
* New upstream release.

[ Michael Banck ]
* debian/patches/01_DESTDIR.dpatch: Refreshed.
* debian/patches/02_FHS.dpatch: Removed, applied upstream.
* debian/patches/03_debian_docdir: Likewise.
* debian/patches/04_man.dpatch: Likewise.
* debian/patches/06_466828_fix_gcc_43_ftbfs.dpatch: Likewise.
* debian/patches/07_464867_move_executables: Fixed and refreshed.
* debian/patches/00list: Adjusted.
* debian/control: Improved description.
* debian/patches-held: Removed.
* debian/rules (install/psi3): Do not ship the ruby bindings for now.

[ Daniel Leidert ]
* debian/rules: Fix txtdir via DEB_MAKE_INSTALL_TARGET.
* debian/patches/01_DESTDIR.dpatch: Refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
def colorize(text, color_code)
 
2
  # Make sure the terminal supports color
 
3
  if (ENV.has_key?("COLORTERM") and ENV["COLORTERM"] == 1) or
 
4
    (ENV.has_key?("TERM") and ENV["TERM"].include?("color"))
 
5
    "#{color_code}#{text}\e[0m"
 
6
  else
 
7
    text
 
8
  end
 
9
end
 
10
 
 
11
def red(text);     colorize(text, "\e[31m"); end
 
12
def green(text);   colorize(text, "\e[32m"); end
 
13
def blue(text);    colorize(text, "\e[34m"); end
 
14
def yellow(text);  colorize(text, "\e[33m"); end
 
15
def magenta(text); colorize(text, "\e[35m"); end
 
16
def cyan(text);    colorize(text, "\e[36m"); end
 
17
def white(text);   colorize(text, "\e[37m"); end
 
18
def bold(text);    colorize(text, "\e[1m");  end