提交 47a778d6 编写于 作者: G Greg Williams

Fixed posix default foregroud color to use 39/default instead of...

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.
上级 93db16b6
GEM
remote: http://rubygems.org/
specs:
rake (10.3.2)
test-unit (2.4.3)
PLATFORMS
ruby
DEPENDENCIES
rake
test-unit (= 2.4.3)
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册