Class: IO
Constant Summary
IronTermAnsiColor::ANSI_REGEXP, IronTermAnsiColor::BGCOLORS, IronTermAnsiColor::FGCOLORS
Instance Method Summary
collapse
#set_color
Instance Method Details
#puts(*args) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/iron-term-ansicolor.rb', line 69
def puts(*args)
if args.empty?
syswrite "\n"
else
args.each do |str|
write(str)
syswrite "\n"
end
end
nil
end
|
#write(str) ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/iron-term-ansicolor.rb', line 81
def write(str)
result = 0
str = str.to_s
match = ANSI_REGEXP.match(str)
if match.nil?
result += syswrite str
else
result += syswrite str[0, match.begin(1) - 2]
set_color(match[1].to_i)
result += write(str[(match.end(1) + 1)..-1])
end
result
end
|