Fixed posix default foregroud color to use 39/default instead of 37/light-gray, since was very hard to see on some dark background terminals.

Added Gemfile.lock for rubygems bundle environment consistency.
This commit is contained in:
Greg Williams
2014-07-25 11:36:33 -04:00
parent 93db16b6dc
commit 47a778d606
2 changed files with 44 additions and 11 deletions

12
Gemfile.lock Normal file
View File

@ -0,0 +1,12 @@
GEM
remote: http://rubygems.org/
specs:
rake (10.3.2)
test-unit (2.4.3)
PLATFORMS
ruby
DEPENDENCIES
rake
test-unit (= 2.4.3)

View File

@ -2,7 +2,7 @@
# Unity Project - A Test Framework for C
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
# [Released under MIT License. Please refer to license.txt for details]
# ==========================================
# ==========================================
if RUBY_PLATFORM =~/(win|w)32$/
begin
@ -21,14 +21,14 @@ end
class ColourCommandLine
def initialize
if RUBY_PLATFORM =~/(win|w)32$/
if RUBY_PLATFORM =~/(win|w)32$/
get_std_handle = Win32API.new("kernel32", "GetStdHandle", ['L'], 'L')
@set_console_txt_attrb =
Win32API.new("kernel32","SetConsoleTextAttribute",['L','N'], 'I')
@hout = get_std_handle.call(-11)
end
end
def change_to(new_colour)
if RUBY_PLATFORM =~/(win|w)32$/
@set_console_txt_attrb.call(@hout,self.win32_colour(new_colour))
@ -36,10 +36,10 @@ class ColourCommandLine
"\033[30;#{posix_colour(new_colour)};22m"
end
end
def win32_colour(colour)
case colour
when :black then 0
when :black then 0
when :dark_blue then 1
when :dark_green then 2
when :dark_cyan then 3
@ -59,22 +59,43 @@ class ColourCommandLine
0
end
end
def posix_colour(colour)
# ANSI Escape Codes - Foreground colors
# | Code | Color |
# | 39 | Default foreground color |
# | 30 | Black |
# | 31 | Red |
# | 32 | Green |
# | 33 | Yellow |
# | 34 | Blue |
# | 35 | Magenta |
# | 36 | Cyan |
# | 37 | Light gray |
# | 90 | Dark gray |
# | 91 | Light red |
# | 92 | Light green |
# | 93 | Light yellow |
# | 94 | Light blue |
# | 95 | Light magenta |
# | 96 | Light cyan |
# | 97 | White |
case colour
when :black then 30
when :black then 30
when :red, :failure then 31
when :green, :success then 32
when :yellow then 33
when :blue, :narrative then 34
when :purple, :magenta then 35
when :cyan, :output then 36
when :white, :default_white, :default then 37
when :white, :default_white then 37
when :default then 39
else
30
39
end
end
def out_c(mode, colour, str)
case RUBY_PLATFORM
when /(win|w)32$/
@ -85,7 +106,7 @@ class ColourCommandLine
else
$stdout.puts("#{change_to(colour)}#{str}\033[0m") if mode == :puts
$stdout.print("#{change_to(colour)}#{str}\033[0m") if mode == :print
end
end
end
end # ColourCommandLine