riel 1.1.16 → 1.1.17
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -37
- data/lib/riel/log/log.rb +17 -24
- data/lib/riel/log/loggable.rb +13 -15
- data/lib/riel/log/logger.rb +34 -66
- data/lib/riel/log.rb +0 -63
- data/lib/riel/optproc.rb +0 -3
- data/lib/riel/string.rb +0 -2
- data/lib/riel.rb +1 -1
- data/test/riel/log/format_test.rb +48 -0
- data/test/riel/optproc_test.rb +1 -30
- data/test/riel/{log_stack_test.rb → testlog/log_stack_test.rb} +0 -0
- data/test/riel/testlog/log_test.rb +254 -0
- data/test/riel/testlog/loggable_test.rb +31 -0
- metadata +89 -133
- data/lib/riel/ansicolor.rb +0 -91
- data/lib/riel/asciitable/cell.rb +0 -82
- data/lib/riel/asciitable/column.rb +0 -26
- data/lib/riel/asciitable/row.rb +0 -105
- data/lib/riel/asciitable/table.rb +0 -295
- data/lib/riel/text/ansi/ansi_color.rb +0 -31
- data/lib/riel/text/ansi/ansi_colors.rb +0 -16
- data/lib/riel/text/ansi/ansi_highlight.rb +0 -69
- data/lib/riel/text/ansi/ansi_list.rb +0 -17
- data/lib/riel/text/ansi/ansi_palette.rb +0 -48
- data/lib/riel/text/ansi/attributes.rb +0 -21
- data/lib/riel/text/ansi/backgrounds.rb +0 -13
- data/lib/riel/text/ansi/color.rb +0 -62
- data/lib/riel/text/ansi/foregrounds.rb +0 -12
- data/lib/riel/text/ansi/grey.rb +0 -30
- data/lib/riel/text/ansi/grey_palette.rb +0 -36
- data/lib/riel/text/ansi/palette.rb +0 -18
- data/lib/riel/text/ansi/rgb_color.rb +0 -28
- data/lib/riel/text/ansi/rgb_highlighter.rb +0 -73
- data/lib/riel/text/ansi/rgb_palette.rb +0 -49
- data/lib/riel/text/highlight.rb +0 -130
- data/lib/riel/text/highlightable.rb +0 -85
- data/lib/riel/text/html_highlight.rb +0 -98
- data/lib/riel/text/non_highlight.rb +0 -17
- data/lib/riel/text/string.rb +0 -10
- data/lib/riel/text.rb +0 -4
- data/test/riel/asciitable/table_test.rb +0 -77
- data/test/riel/log_test.rb +0 -164
- data/test/riel/text/ansi/ansi_highlight_test.rb +0 -116
- data/test/riel/text/ansi/ansi_palette_test.rb +0 -65
- data/test/riel/text/ansi/grey_palette_test.rb +0 -39
- data/test/riel/text/ansi/rgb_highlighter_test.rb +0 -99
- data/test/riel/text/ansi/rgb_palette_test.rb +0 -122
- data/test/riel/text/highlightable_test.rb +0 -24
- data/test/riel/text/string_test.rb +0 -47
- data/test/riel/text_test.rb +0 -62
data/lib/riel/text/ansi/color.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
module Text
|
5
|
-
class Color
|
6
|
-
BOLD = "\e[1m"
|
7
|
-
RESET = "\x1b[0m"
|
8
|
-
|
9
|
-
# \e1 == \x1b
|
10
|
-
|
11
|
-
attr_reader :value
|
12
|
-
|
13
|
-
def initialize value, type
|
14
|
-
@value = value
|
15
|
-
@type = type
|
16
|
-
end
|
17
|
-
|
18
|
-
def to_s
|
19
|
-
@type == :fg ? fg : bg
|
20
|
-
end
|
21
|
-
|
22
|
-
def fg
|
23
|
-
str 38
|
24
|
-
end
|
25
|
-
|
26
|
-
def bg
|
27
|
-
str 48
|
28
|
-
end
|
29
|
-
|
30
|
-
def str num
|
31
|
-
"\x1b[#{num};5;#{value}m"
|
32
|
-
end
|
33
|
-
|
34
|
-
def bold
|
35
|
-
BOLD
|
36
|
-
end
|
37
|
-
|
38
|
-
def reset
|
39
|
-
RESET
|
40
|
-
end
|
41
|
-
|
42
|
-
def print_fg
|
43
|
-
write fg
|
44
|
-
end
|
45
|
-
|
46
|
-
def print_bg
|
47
|
-
write bg
|
48
|
-
end
|
49
|
-
|
50
|
-
def to_str
|
51
|
-
sprintf "%03d", @value
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
def write fgbg
|
56
|
-
print fgbg
|
57
|
-
print to_str
|
58
|
-
print reset
|
59
|
-
print ' '
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
data/lib/riel/text/ansi/grey.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'riel/text/ansi/color'
|
5
|
-
|
6
|
-
module Text
|
7
|
-
class Grey < Color
|
8
|
-
def initialize value
|
9
|
-
super value, nil
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_s
|
13
|
-
"\e[#{value}m"
|
14
|
-
end
|
15
|
-
|
16
|
-
def print_fg
|
17
|
-
print fg
|
18
|
-
print to_str
|
19
|
-
print reset
|
20
|
-
print ' '
|
21
|
-
end
|
22
|
-
|
23
|
-
def print_bg
|
24
|
-
print bg
|
25
|
-
print to_str
|
26
|
-
print reset
|
27
|
-
print ' '
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'riel/text/ansi/grey'
|
5
|
-
require 'riel/text/ansi/palette'
|
6
|
-
require 'singleton'
|
7
|
-
|
8
|
-
module Text
|
9
|
-
class GreyPalette < Palette
|
10
|
-
include Singleton
|
11
|
-
|
12
|
-
GREY_RG = (0 .. 23)
|
13
|
-
|
14
|
-
def each &blk
|
15
|
-
count = 0
|
16
|
-
GREY_RG.each do |grey|
|
17
|
-
code = 232 + grey
|
18
|
-
color = Grey.new code
|
19
|
-
blk.call color
|
20
|
-
count += 1
|
21
|
-
puts if count > 0 && (count % 6) == 0
|
22
|
-
end
|
23
|
-
puts
|
24
|
-
end
|
25
|
-
|
26
|
-
def print_foregrounds
|
27
|
-
puts "grey foreground colors"
|
28
|
-
write_foregrounds
|
29
|
-
end
|
30
|
-
|
31
|
-
def print_backgrounds
|
32
|
-
puts "grey background colors"
|
33
|
-
write_backgrounds
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'riel/text/ansi/color'
|
5
|
-
|
6
|
-
module Text
|
7
|
-
class RGBColor < Color
|
8
|
-
attr_reader :red
|
9
|
-
attr_reader :green
|
10
|
-
attr_reader :blue
|
11
|
-
|
12
|
-
def initialize red, green, blue, type = :fg
|
13
|
-
super((red * 36) + (green * 6) + blue + 16, type)
|
14
|
-
|
15
|
-
@red = red
|
16
|
-
@green = green
|
17
|
-
@blue = blue
|
18
|
-
end
|
19
|
-
|
20
|
-
def to_str
|
21
|
-
sprintf "%d%d%d", @red, @green, @blue
|
22
|
-
end
|
23
|
-
|
24
|
-
def value
|
25
|
-
(@red * 36) + (@green * 6) + @blue + 16
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'riel/text/ansi/rgb_color'
|
5
|
-
require 'singleton'
|
6
|
-
|
7
|
-
module Text
|
8
|
-
# Highlights using extended (RGB) ANSI escape sequences.
|
9
|
-
module RGBHighlighter
|
10
|
-
RGB_RE = Regexp.new '(on_?)?(\d)(\d)(\d)'
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
@aliases = Hash.new
|
14
|
-
end
|
15
|
-
|
16
|
-
def to_rgb_codes str
|
17
|
-
codes = str.scan(RGB_RE).collect do |bg, r, g, b|
|
18
|
-
to_rgb_code r.to_i, g.to_i, b.to_i, bg ? :bg : :fg
|
19
|
-
end
|
20
|
-
codes.join ''
|
21
|
-
end
|
22
|
-
|
23
|
-
def to_rgb_code red, green, blue, fgbg = :fg
|
24
|
-
color = RGBColor.new red, green, blue
|
25
|
-
color.send fgbg
|
26
|
-
end
|
27
|
-
|
28
|
-
def to_rgb str, red, green, blue, meth
|
29
|
-
color = RGBColor.new red, green, blue
|
30
|
-
color.send(meth) + str + color.reset
|
31
|
-
end
|
32
|
-
|
33
|
-
def rgb str, red, green, blue
|
34
|
-
to_rgb str, red, green, blue, :fg
|
35
|
-
end
|
36
|
-
|
37
|
-
def on_rgb str, red, green, blue
|
38
|
-
to_rgb str, red, green, blue, :bg
|
39
|
-
end
|
40
|
-
|
41
|
-
def rrggbb red, green, blue
|
42
|
-
[ red, green, blue ].collect { |x| (x * 6 / 255.0).to_i }
|
43
|
-
end
|
44
|
-
|
45
|
-
def add_alias name, red, green, blue
|
46
|
-
type = name.to_s[0 .. 2] == 'on_' ? :bg : :fg
|
47
|
-
color = RGBColor.new red, green, blue, type
|
48
|
-
@aliases[name] = color
|
49
|
-
end
|
50
|
-
|
51
|
-
def has_alias? name
|
52
|
-
@aliases.include? name
|
53
|
-
end
|
54
|
-
|
55
|
-
def respond_to? meth
|
56
|
-
has_alias?(meth) || super
|
57
|
-
end
|
58
|
-
|
59
|
-
def method_missing(meth, *args, &blk)
|
60
|
-
if has_alias? meth
|
61
|
-
methdecl = Array.new
|
62
|
-
methdecl << "def #{meth}(str, &blk);"
|
63
|
-
methdecl << " color = @aliases[:#{meth}];"
|
64
|
-
methdecl << " color.to_s + str + color.reset;"
|
65
|
-
methdecl << "end"
|
66
|
-
self.class.class_eval methdecl.join("\n")
|
67
|
-
send meth, *args, &blk
|
68
|
-
else
|
69
|
-
super
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'riel/text/ansi/rgb_color'
|
5
|
-
require 'riel/text/ansi/palette'
|
6
|
-
require 'singleton'
|
7
|
-
|
8
|
-
module Text
|
9
|
-
class RGBPalette < Palette
|
10
|
-
include Singleton
|
11
|
-
|
12
|
-
def each &blk
|
13
|
-
rgbrg = (0 .. 5)
|
14
|
-
|
15
|
-
count = 0
|
16
|
-
rgbrg.each do |red|
|
17
|
-
rgbrg.each do |green|
|
18
|
-
rgbrg.each do |blue|
|
19
|
-
blk.call RGBColor.new(red, green, blue)
|
20
|
-
count += 1
|
21
|
-
puts if count > 0 && (count % 6) == 0
|
22
|
-
end
|
23
|
-
end
|
24
|
-
puts
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def print_foregrounds
|
29
|
-
puts "rgb foreground colors"
|
30
|
-
write_foregrounds
|
31
|
-
end
|
32
|
-
|
33
|
-
def print_backgrounds
|
34
|
-
puts "rgb background colors"
|
35
|
-
write_backgrounds
|
36
|
-
end
|
37
|
-
|
38
|
-
def print_combinations
|
39
|
-
puts "all combinations"
|
40
|
-
each do |rgbbg|
|
41
|
-
puts "bg: #{rgbbg.to_str}"
|
42
|
-
each do |rgbfg|
|
43
|
-
print rgbbg.bg
|
44
|
-
rgbfg.print_fg
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
data/lib/riel/text/highlight.rb
DELETED
@@ -1,130 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
module Text
|
5
|
-
# Highlights text using either ANSI terminal codes, or HTML.
|
6
|
-
|
7
|
-
# Note that the foreground and background sections can have modifiers
|
8
|
-
# (attributes).
|
9
|
-
#
|
10
|
-
# Examples:
|
11
|
-
# black
|
12
|
-
# blue on white
|
13
|
-
# bold green on yellow
|
14
|
-
# underscore bold magenta on cyan
|
15
|
-
# underscore red on cyan
|
16
|
-
|
17
|
-
class Highlighter
|
18
|
-
VERSION = "1.0.4"
|
19
|
-
|
20
|
-
COLORS = %w{ black red green yellow blue magenta cyan white }
|
21
|
-
DECORATIONS = %w{ none reset bold underscore underline blink negative concealed }
|
22
|
-
|
23
|
-
BACKGROUND_COLORS = COLORS.collect { |color| "on_#{color}" }
|
24
|
-
FOREGROUND_COLORS = COLORS
|
25
|
-
|
26
|
-
COLORS_RE = Regexp.new('(?: ' +
|
27
|
-
# background will be in capture 0
|
28
|
-
'on(?:\s+|_) ( ' + COLORS.join(' | ') + ' ) | ' +
|
29
|
-
# foreground will be in capture 1
|
30
|
-
'( ' + (COLORS + DECORATIONS).join(' | ') + ' ) ' +
|
31
|
-
')', Regexp::EXTENDED);
|
32
|
-
|
33
|
-
DEFAULT_COLORS = [
|
34
|
-
"black on yellow",
|
35
|
-
"black on green",
|
36
|
-
"black on magenta",
|
37
|
-
"yellow on black",
|
38
|
-
"magenta on black",
|
39
|
-
"green on black",
|
40
|
-
"cyan on black",
|
41
|
-
"blue on yellow",
|
42
|
-
"blue on magenta",
|
43
|
-
"blue on green",
|
44
|
-
"blue on cyan",
|
45
|
-
"yellow on blue",
|
46
|
-
"magenta on blue",
|
47
|
-
"green on blue",
|
48
|
-
"cyan on blue",
|
49
|
-
]
|
50
|
-
|
51
|
-
attr_reader :colors
|
52
|
-
|
53
|
-
def parse_colors str
|
54
|
-
str.scan(Regexp.new(COLORS_RE)).collect do |color|
|
55
|
-
color[0] ? "on_" + color[0] : color[1]
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
# returns a list of all color combinations.
|
60
|
-
def self.all_colors
|
61
|
-
all_colors = Array.new
|
62
|
-
([ nil ] + DECORATIONS).each do |dec|
|
63
|
-
([ nil ] + FOREGROUND_COLORS).each do |fg|
|
64
|
-
([ nil ] + BACKGROUND_COLORS).each do |bg|
|
65
|
-
name = [ dec, fg, bg ].compact.join("_")
|
66
|
-
all_colors << name if name && name.length > 0
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
all_colors
|
71
|
-
end
|
72
|
-
|
73
|
-
def highlight str
|
74
|
-
# implemented by subclasses
|
75
|
-
end
|
76
|
-
|
77
|
-
# Colorizes the given object. If a block is passed, its return value is used
|
78
|
-
# and the stream is reset. If a String is provided as the object, it is
|
79
|
-
# colorized and the stream is reset. Otherwise, only the code for the given
|
80
|
-
# color name is returned.
|
81
|
-
|
82
|
-
def color colorstr, obj = nil, &blk
|
83
|
-
colornames = parse_colors colorstr
|
84
|
-
result = names_to_code colornames
|
85
|
-
|
86
|
-
if blk
|
87
|
-
result << blk.call
|
88
|
-
elsif obj.respond_to? :to_s
|
89
|
-
result << obj.to_s
|
90
|
-
end
|
91
|
-
result << names_to_code("reset")
|
92
|
-
result
|
93
|
-
end
|
94
|
-
|
95
|
-
# returns the code for the given color string, which is in the format:
|
96
|
-
# foreground* [on background]?
|
97
|
-
#
|
98
|
-
# Note that the foreground and background sections can have modifiers
|
99
|
-
# (attributes).
|
100
|
-
#
|
101
|
-
# Examples:
|
102
|
-
# black
|
103
|
-
# blue on white
|
104
|
-
# bold green on yellow
|
105
|
-
# underscore bold magenta on cyan
|
106
|
-
# underscore red on cyan
|
107
|
-
def code str
|
108
|
-
fg, bg = str.split(/\s*\bon_?\s*/)
|
109
|
-
(fg ? foreground(fg) : "") + (bg ? background(bg) : "")
|
110
|
-
end
|
111
|
-
|
112
|
-
# Returns the code for the given background color(s).
|
113
|
-
def background bgcolor
|
114
|
-
names_to_code "on_" + bgcolor
|
115
|
-
end
|
116
|
-
|
117
|
-
# Returns the code for the given foreground color(s).
|
118
|
-
def foreground fgcolor
|
119
|
-
fgcolor.split(/\s+/).collect { |fg| names_to_code fg }.join("")
|
120
|
-
end
|
121
|
-
|
122
|
-
# Returns a highlighted (colored) version of the string, applying the regular
|
123
|
-
# expressions in the array, which are paired with the desired color.
|
124
|
-
def gsub str, re, color
|
125
|
-
str.gsub(re) do |match|
|
126
|
-
self.color color, match
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'riel/text/highlight'
|
5
|
-
require 'riel/text/ansi/ansi_highlight'
|
6
|
-
require 'riel/text/html_highlight'
|
7
|
-
require 'riel/text/non_highlight'
|
8
|
-
|
9
|
-
module Text
|
10
|
-
# An object that can be highlighted. This is used by the String class.
|
11
|
-
module Highlightable
|
12
|
-
# The highlighter for the class in which this module is included.
|
13
|
-
@@highlighter = ANSIHighlighter.instance
|
14
|
-
|
15
|
-
# this dynamically adds methods for individual colors.
|
16
|
-
def method_missing(meth, *args, &blk)
|
17
|
-
if has_color? meth.to_s
|
18
|
-
methdecl = Array.new
|
19
|
-
methdecl << "def #{meth}(&blk);"
|
20
|
-
methdecl << " @@highlighter.color(\"#{meth}\", self, &blk);"
|
21
|
-
methdecl << "end"
|
22
|
-
self.class.class_eval methdecl.join("\n")
|
23
|
-
send meth, *args, &blk
|
24
|
-
elsif @@highlighter.has_alias? meth
|
25
|
-
methdecl = Array.new
|
26
|
-
methdecl << "def #{meth}(&blk);"
|
27
|
-
methdecl << " @@highlighter.#{meth}(self, &blk);"
|
28
|
-
methdecl << "end"
|
29
|
-
self.class.class_eval methdecl.join("\n")
|
30
|
-
send meth, *args, &blk
|
31
|
-
else
|
32
|
-
super
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def respond_to? meth
|
37
|
-
has_color?(meth.to_s) || ANSIHighlighter.instance.has_alias?(meth) || super
|
38
|
-
end
|
39
|
-
|
40
|
-
def has_color? color
|
41
|
-
Highlighter::all_colors.include? color
|
42
|
-
end
|
43
|
-
|
44
|
-
# Sets the highlighter for this class. This can be either by type or by
|
45
|
-
# String.
|
46
|
-
def highlighter= hl
|
47
|
-
@@highlighter = case hl
|
48
|
-
when Highlighter
|
49
|
-
hl
|
50
|
-
when :none, "NONE", nil
|
51
|
-
NonHighlighter.new
|
52
|
-
when :html, "HTML"
|
53
|
-
HTMLHighlighter.new
|
54
|
-
when :ansi, "ANSI"
|
55
|
-
ANSIHighlighter.instance
|
56
|
-
else
|
57
|
-
NonHighlighter.new
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
def rgb red, green, blue
|
63
|
-
@@highlighter.rgb self, red, green, blue
|
64
|
-
end
|
65
|
-
|
66
|
-
def on_rgb red, green, blue
|
67
|
-
@@highlighter.on_rgb self, red, green, blue
|
68
|
-
end
|
69
|
-
|
70
|
-
def grey value
|
71
|
-
@@highlighter.grey self, value
|
72
|
-
end
|
73
|
-
|
74
|
-
def on_grey value
|
75
|
-
@@highlighter.on_grey self, value
|
76
|
-
end
|
77
|
-
|
78
|
-
alias_method :gray, :grey
|
79
|
-
alias_method :on_gray, :on_grey
|
80
|
-
|
81
|
-
def self.add_to cls
|
82
|
-
cls.send :include, Highlightable
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
# -*- ruby -*-
|
3
|
-
|
4
|
-
require 'riel/text/highlight'
|
5
|
-
|
6
|
-
module Text
|
7
|
-
# Highlights using HTML. Fonts are highlighted using <span> tags, not <font>.
|
8
|
-
# Also note that negative is translated to white on black.
|
9
|
-
# According to http://www.w3.org/TR/REC-CSS2/syndata.html#value-def-color,
|
10
|
-
# valid color keywords are: aqua, black, blue, fuchsia, gray, green, lime,
|
11
|
-
# maroon, navy, olive, purple, red, silver, teal, white, and yellow.
|
12
|
-
# Thus, no magenta or cyan.
|
13
|
-
|
14
|
-
class HTMLHighlighter < Highlighter
|
15
|
-
def initialize
|
16
|
-
# we need to know what we're resetting from (bold, font, underlined ...)
|
17
|
-
@stack = []
|
18
|
-
end
|
19
|
-
|
20
|
-
# Returns the start tag for the given name.
|
21
|
-
|
22
|
-
def start_style name
|
23
|
-
case name
|
24
|
-
when "negative"
|
25
|
-
"<span style=\"color: white; background-color: black\">"
|
26
|
-
when /on_(\w+)/
|
27
|
-
colval = color_value $1
|
28
|
-
"<span style=\"background-color: #{colval}\">"
|
29
|
-
else
|
30
|
-
colval = color_value name
|
31
|
-
"<span style=\"color: #{colval}\">"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# Returns the end tag ("</span>").
|
36
|
-
|
37
|
-
def end_style
|
38
|
-
"</span>"
|
39
|
-
end
|
40
|
-
|
41
|
-
def color_value cname
|
42
|
-
case cname
|
43
|
-
when "cyan"
|
44
|
-
"#00FFFF"
|
45
|
-
when "magenta"
|
46
|
-
"#FF00FF"
|
47
|
-
else
|
48
|
-
cname
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# Returns the code for the given name.
|
53
|
-
def names_to_code names
|
54
|
-
str = ""
|
55
|
-
|
56
|
-
names = [ names ] unless names.kind_of? Array
|
57
|
-
|
58
|
-
names.each do |name|
|
59
|
-
@stack << name
|
60
|
-
|
61
|
-
case name
|
62
|
-
when "none", "reset"
|
63
|
-
@stack.pop
|
64
|
-
if @stack.length > 0
|
65
|
-
begin
|
66
|
-
prev = @stack.pop
|
67
|
-
case prev
|
68
|
-
when "bold"
|
69
|
-
str << "</b>"
|
70
|
-
when "underscore", "underline"
|
71
|
-
str << "</u>"
|
72
|
-
when "blink"
|
73
|
-
str << "</blink>"
|
74
|
-
when "concealed"
|
75
|
-
str << " -->"
|
76
|
-
else
|
77
|
-
str << end_style
|
78
|
-
end
|
79
|
-
end while @stack.length > 0
|
80
|
-
end
|
81
|
-
str
|
82
|
-
when "bold"
|
83
|
-
str << "<b>"
|
84
|
-
when "underscore", "underline"
|
85
|
-
str << "<u>"
|
86
|
-
when "blink"
|
87
|
-
str << "<blink>"
|
88
|
-
when "concealed"
|
89
|
-
str << "<!-- "
|
90
|
-
else
|
91
|
-
str << start_style(name)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
str
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
data/lib/riel/text/string.rb
DELETED
data/lib/riel/text.rb
DELETED