mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-20 22:13:29 +08:00
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:
12
Gemfile.lock
Normal file
12
Gemfile.lock
Normal 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)
|
@ -2,7 +2,7 @@
|
|||||||
# Unity Project - A Test Framework for C
|
# Unity Project - A Test Framework for C
|
||||||
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||||
# [Released under MIT License. Please refer to license.txt for details]
|
# [Released under MIT License. Please refer to license.txt for details]
|
||||||
# ==========================================
|
# ==========================================
|
||||||
|
|
||||||
if RUBY_PLATFORM =~/(win|w)32$/
|
if RUBY_PLATFORM =~/(win|w)32$/
|
||||||
begin
|
begin
|
||||||
@ -21,14 +21,14 @@ end
|
|||||||
|
|
||||||
class ColourCommandLine
|
class ColourCommandLine
|
||||||
def initialize
|
def initialize
|
||||||
if RUBY_PLATFORM =~/(win|w)32$/
|
if RUBY_PLATFORM =~/(win|w)32$/
|
||||||
get_std_handle = Win32API.new("kernel32", "GetStdHandle", ['L'], 'L')
|
get_std_handle = Win32API.new("kernel32", "GetStdHandle", ['L'], 'L')
|
||||||
@set_console_txt_attrb =
|
@set_console_txt_attrb =
|
||||||
Win32API.new("kernel32","SetConsoleTextAttribute",['L','N'], 'I')
|
Win32API.new("kernel32","SetConsoleTextAttribute",['L','N'], 'I')
|
||||||
@hout = get_std_handle.call(-11)
|
@hout = get_std_handle.call(-11)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def change_to(new_colour)
|
def change_to(new_colour)
|
||||||
if RUBY_PLATFORM =~/(win|w)32$/
|
if RUBY_PLATFORM =~/(win|w)32$/
|
||||||
@set_console_txt_attrb.call(@hout,self.win32_colour(new_colour))
|
@set_console_txt_attrb.call(@hout,self.win32_colour(new_colour))
|
||||||
@ -36,10 +36,10 @@ class ColourCommandLine
|
|||||||
"\033[30;#{posix_colour(new_colour)};22m"
|
"\033[30;#{posix_colour(new_colour)};22m"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def win32_colour(colour)
|
def win32_colour(colour)
|
||||||
case colour
|
case colour
|
||||||
when :black then 0
|
when :black then 0
|
||||||
when :dark_blue then 1
|
when :dark_blue then 1
|
||||||
when :dark_green then 2
|
when :dark_green then 2
|
||||||
when :dark_cyan then 3
|
when :dark_cyan then 3
|
||||||
@ -59,22 +59,43 @@ class ColourCommandLine
|
|||||||
0
|
0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def posix_colour(colour)
|
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
|
case colour
|
||||||
when :black then 30
|
when :black then 30
|
||||||
when :red, :failure then 31
|
when :red, :failure then 31
|
||||||
when :green, :success then 32
|
when :green, :success then 32
|
||||||
when :yellow then 33
|
when :yellow then 33
|
||||||
when :blue, :narrative then 34
|
when :blue, :narrative then 34
|
||||||
when :purple, :magenta then 35
|
when :purple, :magenta then 35
|
||||||
when :cyan, :output then 36
|
when :cyan, :output then 36
|
||||||
when :white, :default_white, :default then 37
|
when :white, :default_white then 37
|
||||||
|
when :default then 39
|
||||||
else
|
else
|
||||||
30
|
39
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def out_c(mode, colour, str)
|
def out_c(mode, colour, str)
|
||||||
case RUBY_PLATFORM
|
case RUBY_PLATFORM
|
||||||
when /(win|w)32$/
|
when /(win|w)32$/
|
||||||
@ -85,7 +106,7 @@ class ColourCommandLine
|
|||||||
else
|
else
|
||||||
$stdout.puts("#{change_to(colour)}#{str}\033[0m") if mode == :puts
|
$stdout.puts("#{change_to(colour)}#{str}\033[0m") if mode == :puts
|
||||||
$stdout.print("#{change_to(colour)}#{str}\033[0m") if mode == :print
|
$stdout.print("#{change_to(colour)}#{str}\033[0m") if mode == :print
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # ColourCommandLine
|
end # ColourCommandLine
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user