color_echo 1.3.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,26 @@
1
- @explain_v = "Show version of color_echo."
2
- @explain_s = "Show symbol list that can to specify."
3
- @explain_l = "Show color index list that can to specify."
4
- @explain_p = "Decorate your specified wrods. You can use this option any number of times."
5
- @explain_f = "Specify the foreground color."
6
- @explain_b = "Specify the background color."
7
- @explain_t = "Specify the text attributes."
8
- @explain_w = "Interactive mode. Break word is -> exit, quit, bye; Or Ctl + c"
9
- @explain_n = "Do not output the trailing newline."
10
- @explain_e = "Enable interpretation of line feed."
11
- @explain_h = "Show this message."
12
- @explain_stripe = "Decorate on every other line. pickup option is ignored."
1
+ @explain_v = %(Show version of color_echo.)
2
+ @explain_s = %(Show symbol list that can to specify.)
3
+ @explain_l = %(Show color index list that can to specify.)
4
+ @explain_p = %(Decorate your specified wrods. You can use this option any number of times.)
5
+ @explain_H = %(Highlight the match lines by -p options word. format -H "fg_color, bg_color, text_attribute[,...]")
6
+ @explain_f = %(Specify the foreground color.)
7
+ @explain_b = %(Specify the background color.)
8
+ @explain_t = %(Specify the text attributes.)
9
+ @explain_w = %(Interactive mode. Break word is -> exit, quit, bye; Or Ctl + c)
10
+ @explain_n = %(Do not output the trailing newline.)
11
+ @explain_e = %(Enable interpretation of line feed.)
12
+ @explain_h = %(Show help message with example.)
13
+ @explain_r = %(Try to remove the sequence code from the given before matching pickups.)
14
+ @explain_R = %(Try to remove the sequence code from the given.)
15
+ @explain_stripe = %(Decorate on every other line. pickup option is ignored.)
16
+ @padding = " " * 4
17
+ @explain_usage = @padding * 2 + %(colorecho [options] message) + $/
18
+ @explain_usage += @padding * 2 + %(colorecho [options] < /path/to/file) + $/
19
+ @explain_usage += @padding * 2 + %(echo "message" | colorecho [options]) + $/
20
+ @explain_usage += @padding * 2 + %(colorecho -v) + $/
21
+ @explain_usage += @padding * 2 + %(colorecho -s) + $/
22
+ @explain_usage += @padding * 2 + %(colorecho -l) + $/
23
+ @explain_usage += @padding * 2 + %(colorecho -h)
13
24
 
14
25
  def version
15
26
  require_color_echo
@@ -23,140 +34,151 @@ def usage
23
34
 
24
35
  CE.once.ch :yellow
25
36
  puts <<-EOS
26
-
27
37
  #{CE::LIBS_NAME} - #{CE::SUMMARY}
28
38
  VERSION: #{CE::VERSION}
29
39
  README: #{CE::DOCS_PAGE}
30
40
 
31
41
  EOS
32
42
 
33
- padding = " " * 4
34
43
  headers = ["* Usage", "* Options", "* Example"]
35
44
  headers_op = [
36
- "-v:", "--symbol-list:", "--index-list:", "--pickup word [--pickup word ...]:", "--fg color_name:", "--bg color_name:",
37
- "--tx text_attribute[,...]:", "--watch:", "--stripe:", "-n:", "-e:", "-h:"
45
+ "-v:", "--symbol-list:", "--index-list:", "--pickup word [--pickup word ...]:", "--fg color_name:", "--bg color_name:",
46
+ "--tx text_attribute[,...]:", "--watch:", "--stripe:", %(--hightlight "foreground_color[,background_color[,text_attribute]]:"),
47
+ "--refresh:", "--refresh-pre-match:", "--help:", "-n:", "-e:"
38
48
  ]
39
49
  CE.pickup(headers, :h_green)
40
50
  CE.pickup(headers_op, :cyan)
41
51
 
42
- puts padding + "* Usage"
52
+ puts @padding + "* Usage"
43
53
 
44
54
  CE.ch :h_blue
45
- puts padding * 2 + "color_echo [options] text"
46
- puts padding * 2 + "color_echo [options] < /path/to/file"
47
- puts padding * 2 + "echo text | color_echo [options]"
48
- puts padding * 2 + "color_echo -v"
49
- puts padding * 2 + "color_echo -s"
50
- puts padding * 2 + "color_echo -l"
51
- puts padding * 2 + "color_echo -h" + $/ + $/
55
+ puts @explain_usage + $/ + $/
52
56
  CE.off :fg
53
57
 
54
- puts padding + "* Options"
55
-
56
- puts padding * 2 + "-v:"
57
- puts padding * 3 + @explain_v + $/ + $/
58
+ puts @padding + "* Options"
58
59
 
59
- puts padding * 2 + "--symbol-list:"
60
- puts padding * 3 + @explain_s
61
- puts padding * 3 + "short option is -s." + $/ + $/
60
+ puts @padding * 2 + "--symbol-list:"
61
+ puts @padding * 3 + @explain_s
62
+ puts @padding * 3 + "short option is -s." + $/ + $/
62
63
 
63
- puts padding * 2 + "--index-list:"
64
- puts padding * 3 + @explain_l
65
- puts padding * 3 + "short option is -l." + $/ + $/
64
+ puts @padding * 2 + "--index-list:"
65
+ puts @padding * 3 + @explain_l
66
+ puts @padding * 3 + "short option is -l." + $/ + $/
67
+
68
+ puts @padding * 2 + "--pickup word [--pickup word ...]:"
69
+ puts @padding * 3 + @explain_p
70
+ puts @padding * 3 + "Regular expressions can be used; like that -> /^foo/i"
71
+ puts @padding * 3 + "short option is -p." + $/ + $/
72
+
73
+ puts @padding * 2 + %(--hightlight "foreground_color[,background_color[,text_attribute]]:")
74
+ puts @padding * 3 + @explain_H
75
+ puts @padding * 3 + %(example -> echo "some message" | colorecho -H "nil,gray" -p /some patturn/ -f h_yellow)
76
+ puts @padding * 3 + "short option is -H." + $/ + $/
77
+
78
+ puts @padding * 2 + "--fg color_name:"
79
+ puts @padding * 3 + @explain_f
80
+ puts @padding * 3 + "short option is -f." + $/ + $/
81
+
82
+ puts @padding * 2 + "--bg color_name:"
83
+ puts @padding * 3 + @explain_b
84
+ puts @padding * 3 + "short option is -b." + $/ + $/
66
85
 
67
- puts padding * 2 + "--pickup word [--pickup word ...]:"
68
- puts padding * 3 + @explain_p
69
- puts padding * 3 + "Regular expressions can be used; like that -> /^foo/i"
70
- puts padding * 3 + "short option is -p." + $/ + $/
86
+ puts @padding * 2 + "--tx text_attribute[,...]:"
87
+ puts @padding * 3 + @explain_t
88
+ puts @padding * 3 + "short option is -t." + $/ + $/
71
89
 
72
- puts padding * 2 + "--fg color_name:"
73
- puts padding * 3 + @explain_f
74
- puts padding * 3 + "short option is -f." + $/ + $/
90
+ puts @padding * 2 + "--watch:"
91
+ puts @padding * 3 + @explain_w
92
+ puts @padding * 3 + "short option is -w." + $/ + $/
75
93
 
76
- puts padding * 2 + "--bg color_name:"
77
- puts padding * 3 + @explain_b
78
- puts padding * 3 + "short option is -b." + $/ + $/
94
+ puts @padding * 2 + "--stripe:"
95
+ puts @padding * 3 + @explain_stripe + $/ + $/
79
96
 
80
- puts padding * 2 + "--tx text_attribute[,...]:"
81
- puts padding * 3 + @explain_t
82
- puts padding * 3 + "short option is -t." + $/ + $/
97
+ puts @padding * 2 + "--refresh-pre-match:"
98
+ puts @padding * 3 + @explain_r
99
+ puts @padding * 3 + "If it matches, Try to remove sequence code from it."
100
+ puts @padding * 3 + "short option is -r." + $/ + $/
83
101
 
84
- puts padding * 2 + "--watch:"
85
- puts padding * 3 + @explain_w
86
- puts padding * 3 + "short option is -w." + $/ + $/
102
+ puts @padding * 2 + "--refresh:"
103
+ puts @padding * 3 + @explain_R
104
+ puts @padding * 3 + "short option is -R." + $/ + $/
87
105
 
88
- puts padding * 2 + "--stripe:"
89
- puts padding * 3 + @explain_stripe + $/ + $/
106
+ puts @padding * 2 + "-n:"
107
+ puts @padding * 3 + @explain_n + $/ + $/
90
108
 
91
- puts padding * 2 + "-n:"
92
- puts padding * 3 + @explain_n + $/ + $/
109
+ puts @padding * 2 + "-e:"
110
+ puts @padding * 3 + @explain_e + $/ + $/
93
111
 
94
- puts padding * 2 + "-e:"
95
- puts padding * 3 + @explain_e + $/ + $/
112
+ puts @padding * 2 + "-v:"
113
+ puts @padding * 3 + @explain_v + $/ + $/
96
114
 
97
- puts padding * 2 + "-h:"
98
- puts padding * 3 + @explain_h + $/ + $/
115
+ puts @padding * 2 + "--help:"
116
+ puts @padding * 3 + @explain_h
117
+ puts @padding * 3 + "short option is -h." + $/ + $/
99
118
 
100
- puts padding + "* Example"
119
+ puts @padding + "* Example"
101
120
 
102
121
  CE.once.ch :h_magenta
103
- puts padding * 2 + %(* color_echo can to highlight even when you following the log file by tailf, tail -f.)
104
- puts padding * 3 + %(tailf /var/log/httpd/access_log | color_echo -w -p "127.0.0.1" -t bold)
105
- puts padding * 3 + %(tailf /var/log/php/php_error.log | color_echo -w -p "foo.php" -p "Fatal error:" -f h_blue) + $/ + $/
122
+ puts @padding * 2 + %(* color_echo can to highlight even when you following the log file by tailf, tail -f.)
123
+ puts @padding * 3 + %(tailf /var/log/httpd/access_log | colorecho -w -p "127.0.0.1" -t bold)
124
+ puts @padding * 3 + %(tailf /var/log/php/php_error.log | colorecho -w -p "foo.php" -p "Fatal error:" -f h_blue) + $/ + $/
106
125
 
107
126
  CE.once.ch :h_magenta
108
- puts padding * 2 + %(* color_echo is useful to read the access log, etc.)
109
- puts padding * 3 + %(cat /var/log/httpd/access_log | color_echo -p "Sun Jan 18" -f h_cyan -t underscore | less)
110
- puts padding * 3 + %(color_echo -p "Sun Jan 18" -f h_cyan -t underscore < /var/log/httpd/access_log | less)
111
- puts padding * 3 + %((color_echo -f cyan -p /\\\\s2..\\\\s/ | color_echo -f h_red -p /\\\\s5..\\\\s/ | less) < /var/log/httpd/access_log)
112
- puts padding * 3 + %(sed -n 1,1000p /var/log/httpd/access_log | color_echo -f cyan -p /\\\\s2..\\\\s/ | color_echo -f h_red -p /\\\\s5..\\\\s/ | less) + $/ + $/
127
+ puts @padding * 2 + %(* color_echo is useful to read the access log, etc.)
128
+ puts @padding * 3 + %(cat /var/log/httpd/access_log | colorecho -p "Sun Jan 18" -f h_cyan -t underscore | less -R)
129
+ puts @padding * 3 + %(colorecho -p "Sun Jan 18" -f h_cyan -t underscore < /var/log/httpd/access_log | less -R)
130
+ puts @padding * 3 + %((colorecho -f cyan -p /\\\\s2..\\\\s/ | colorecho -f h_red -p /\\\\s5..\\\\s/ | less -R) < /var/log/httpd/access_log)
131
+ puts @padding * 3 + %(sed -n 1,1000p /var/log/httpd/access_log | colorecho -f cyan -p /\\\\s2..\\\\s/ | colorecho -f h_red -p /\\\\s5..\\\\s/ | less -R) + $/ + $/
113
132
 
114
133
  CE.once.ch :h_magenta
115
- puts padding * 2 + %(* It is a simple to use.)
116
- puts padding * 3 + %(color_echo Hello\\!\\! -f h_white -b index199)
117
- puts padding * 3 + %(color_echo Hello\\!\\! -t blink,bold -f magenta) + $/ + $/
134
+ puts @padding * 2 + %(* It is a simple to use.)
135
+ puts @padding * 3 + %(colorecho Hello\\!\\! -f h_white -b index199)
136
+ puts @padding * 3 + %(colorecho Hello\\!\\! -t blink,bold -f magenta) + $/ + $/
118
137
 
119
138
  CE.once.ch :h_magenta
120
- puts padding * 2 + %(* color_echo can to receive the standard input.)
121
- puts padding * 3 + %(echo FooFoOfOO | color_echo -t reverse_video)
122
- puts padding * 3 + %(echo FooFoOfOO | color_echo -f index130 -p /foo$/i | color_echo -f index180 -p /^foo/i)
123
- puts padding * 3 + %(netstat -na | color_echo -p ":80" | color_echo -p "127.0.0.1" -f h_cyan) + $/ + $/
139
+ puts @padding * 2 + %(* color_echo can to receive the standard input.)
140
+ puts @padding * 3 + %(echo FooFoOfOO | colorecho -t reverse_video)
141
+ puts @padding * 3 + %(echo FooFoOfOO | colorecho -f index130 -p /foo$/i | colorecho -f index180 -p /^foo/i)
142
+ puts @padding * 3 + %(netstat -na | colorecho -p ":80" | colorecho -p "127.0.0.1" -f h_cyan) + $/ + $/
124
143
 
125
144
  CE.once.ch :h_magenta
126
- puts padding * 2 + %(* color_echo can to decorate on every other line.)
127
- puts padding * 3 + %(color_echo -f gray -t bold --stripe < /path/to/file)
128
- puts padding * 3 + %(tailf /var/log/httpd/access_log | color_echo -w -f black -b index150 -t bold --stripe) + $/ + $/
145
+ puts @padding * 2 + %(* color_echo can to decorate on every other line.)
146
+ puts @padding * 3 + %(colorecho -f gray -t bold --stripe < /path/to/file)
147
+ puts @padding * 3 + %(tailf /var/log/httpd/access_log | colorecho -w -f black -b index150 -t bold --stripe) + $/ + $/
148
+
149
+ CE.once.rainbow
150
+ puts @padding * 2 + %(* Enjoy colors!!)
151
+ puts @padding * 3 + %(tailf /var/log/httpd/access_log | colorecho -w -f index235 -r | colorecho -w -p "pattern1" -f index3 -t underscore,bold -H index85 -r | colorecho -w -p "pattern2" -f index28,nil -t underscore,bold -H index46 -r | colorecho -w -p "pattern3" -t bold,underscore -f index198 -H index178 -r) + $/ + $/
129
152
 
130
153
  exit 0
131
154
  end
132
155
 
156
+ # TODO need pager like 'less'?
133
157
  def display_color_index
134
- require_color_echo
158
+ require_color_echo_get
135
159
 
136
160
  CE.rainbow
137
- cnt = 134
138
- padding = " " * 2
139
- mes = "OK, Let me check color index list... :)"
140
- puts padding + "-" * cnt
141
- puts padding + " " * ((cnt - mes.size)/2) + mes
142
- puts padding + "-" * cnt
143
-
144
- print padding
161
+ cnt = 134
162
+ @padding = " " * 2
163
+
164
+ header = "OK, Let me check color index list... :)"
165
+ mes = CE.rainbow.get(@padding + "-" * cnt) + $/
166
+ mes += @padding + " " * ((cnt - header.size)/2) + CE.rainbow.get(header) + $/
167
+ mes += CE.rainbow.get(@padding + "-" * cnt) + $/
168
+
169
+ mes += @padding
145
170
  256.times do |i|
146
171
  num = i + 1
147
- CE.fg "index#{num}".intern
148
- print "index#{num}" + " " * (4 - num.to_s.size)
149
- CE.bg "index#{num}".intern
150
- print " " * 5
151
- CE.off
152
- print " " * 3
172
+ mes += CE.fg("index#{num}".intern).get("index#{num}" + " " * (4 - num.to_s.size))
173
+ mes += CE.bg("index#{num}".intern).get(" " * 5)
174
+ mes += " " * 3
153
175
 
154
176
  if num % 8 == 0
155
- print $/ + $/
156
- print padding if num != 256
177
+ mes += $/ + $/
178
+ mes += @padding if num != 256
157
179
  end
158
180
  end
159
- CE.off
181
+ print mes
160
182
 
161
183
  exit 0
162
184
  end
@@ -192,20 +214,20 @@ def display_symbol_list
192
214
 
193
215
  CE.times(3).rainbow
194
216
  cnt = 60
195
- padding = " " * 2
217
+ @padding = " " * 2
196
218
  mes = "OK, Let me check color name list... :)"
197
- puts padding + "-" * cnt
198
- puts padding + " " * ((cnt - mes.size)/2) + mes
199
- puts padding + "-" * cnt
219
+ puts @padding + "-" * cnt
220
+ puts @padding + " " * ((cnt - mes.size)/2) + mes
221
+ puts @padding + "-" * cnt
200
222
 
201
223
  header_colors = "* foreground or background colors"
202
224
  header_text_attrs = "* text attributes"
203
225
  CE.pickup([header_colors, header_text_attrs], :cyan, nil, [:underscore, :bold])
204
226
 
205
- puts padding + header_colors
227
+ puts @padding + header_colors
206
228
  symbols_color.each do |color_name|
207
229
  CE.off(:bg).fg color_name
208
- print "#{padding*2}:#{color_name}" + " " * (11 - color_name.to_s.size)
230
+ print "#{@padding*2}:#{color_name}" + " " * (11 - color_name.to_s.size)
209
231
  CE.bg color_name
210
232
  puts color_name.to_s + " " * (30 - color_name.to_s.size)
211
233
  end
@@ -213,15 +235,14 @@ def display_symbol_list
213
235
  CE.off [:bg, :fg]
214
236
  print $/ + $/
215
237
 
216
- puts padding + header_text_attrs
238
+ puts @padding + header_text_attrs
217
239
  symbols_text_attr.each do |tx_name|
218
240
  CE.off(:tx)
219
241
  CE.tx tx_name if tx_name != :concealed
220
- puts "#{padding*2}:#{tx_name}" + " " * (30 - tx_name.to_s.size)
242
+ puts "#{@padding*2}:#{tx_name}" + " " * (30 - tx_name.to_s.size)
221
243
  end
222
244
 
223
245
  print $/
224
246
 
225
247
  exit 0
226
248
  end
227
-
@@ -1,6 +1,6 @@
1
1
  module CE
2
2
  LIBS_NAME = "color_echo"
3
- VERSION = "1.3.0"
3
+ VERSION = "2.0.0"
4
4
  SUMMARY = "Decorate the command line output with ANSI escape sequence."
5
5
  DOCS_PAGE = "https://github.com/khotta/color_echo"
6
6
  DESCRIPTION = <<EOS
@@ -22,6 +22,7 @@ module CE
22
22
  reset_bg
23
23
  reset_tx
24
24
  reset_pickup
25
+ reset_hitline
25
26
  reset_rainbow
26
27
  when :fg
27
28
  reset_fg
@@ -31,6 +32,8 @@ module CE
31
32
  reset_tx
32
33
  when :pickup
33
34
  reset_pickup
35
+ when :hitline
36
+ reset_hitline
34
37
  when :rainbow
35
38
  reset_rainbow
36
39
  end
@@ -150,6 +153,38 @@ module CE
150
153
  return self
151
154
  end
152
155
 
156
+ # change hit lines decoration
157
+ # @return void
158
+ def hitline(fg=nil, bg=nil, *txs)
159
+ if fg.instance_of?(Symbol)
160
+ @@code_hitline_fg_color = convert_to_code("ForeGround", fg)
161
+ else
162
+ @@code_hitline_fg_color = ""
163
+ end
164
+
165
+ if bg.instance_of?(Symbol)
166
+ @@code_hitline_bg_color = convert_to_code("BackGround", bg)
167
+ else
168
+ @@code_hitline_bg_color = ""
169
+ end
170
+
171
+ if txs.size > 0
172
+ txs = txs[0] if txs[0].instance_of?(Array)
173
+ txs.each do |name|
174
+ next if !name.is_a?(Symbol)
175
+ @@code_hitline_text_attr += convert_to_code("TextAttr", name)
176
+ end
177
+ end
178
+
179
+ return self
180
+ end
181
+
182
+ # get escape sequence code of that hit record line
183
+ # @return string
184
+ def get_hitline_code
185
+ return @@code_hitline_fg_color + @@code_hitline_bg_color + @@code_hitline_text_attr
186
+ end
187
+
153
188
  # get decorated text
154
189
  # require "color_echo/get"
155
190
  # @param string text
@@ -166,6 +201,26 @@ module CE
166
201
  @@task.call(text)
167
202
  end
168
203
 
204
+ # Enable refresh flag
205
+ # @return self
206
+ def enable_refresh(scope=:all)
207
+ if scope == :all
208
+ @@refresh = true
209
+ elsif scope == :prematch
210
+ @@refresh_pre_match = true
211
+ end
212
+
213
+ return self
214
+ end
215
+
216
+ # Disable refresh flag
217
+ # @return self
218
+ def disable_refresh
219
+ @@refresh = false
220
+ @@refresh_pre_match = false
221
+ return self
222
+ end
223
+
169
224
  # method alias
170
225
  alias_method :off, :reset
171
226
  alias_method :disable, :reset
@@ -45,6 +45,15 @@ module CE
45
45
  return self
46
46
  end
47
47
 
48
+ # reset hitline code
49
+ # @return self
50
+ def reset_hitline
51
+ @@code_hitline_bg_color = ""
52
+ @@code_hitline_fg_color = ""
53
+ @@code_hitline_text_attr = ""
54
+ return self
55
+ end
56
+
48
57
  # reset and off raubow mode
49
58
  # @return self
50
59
  def reset_rainbow
@@ -66,9 +75,11 @@ module CE
66
75
 
67
76
  # return start escape sequence code
68
77
  # @return string
69
- def get_start_code
78
+ def get_start_code(type=nil)
70
79
  if @@rainbow
71
80
  return @@code_rainbow
81
+ elsif type == :hitline
82
+ return @@code_hitline_fg_color + @@code_hitline_bg_color + @@code_hitline_text_attr
72
83
  else
73
84
  return @@code_fg_color + @@code_bg_color + @@code_text_attr
74
85
  end
@@ -82,6 +93,7 @@ module CE
82
93
  # add reset & start code to line feed code
83
94
  # @param string input
84
95
  def add_reset_line_feed(input)
96
+ input = input.unpack("C*").pack("U*") if !input.valid_encoding?
85
97
  input.gsub!(/#{$/}/, get_reset_code + $/ + get_start_code)
86
98
  input += get_reset_code
87
99
  return input
@@ -100,6 +112,7 @@ module CE
100
112
  next
101
113
  end
102
114
 
115
+ # TODO This way so lame...
103
116
  case cnt
104
117
  when 0
105
118
  output += ForeGround::RED + char + Off::ALL + get_start_code
@@ -129,9 +142,16 @@ module CE
129
142
  # @param string text
130
143
  # @return string
131
144
  def add_pickup_code(text)
145
+ if @@refresh_pre_match
146
+ # remove sequence code from given If it matches pickups
147
+ orgtext = text.clone
148
+ text = cleanup_text(text)
149
+ end
150
+
151
+ is_match = false
132
152
  @@pickup_list.each_pair do |key, hash|
133
- patterns = hash[:patterns]
134
- code = hash[:code]
153
+ patterns = hash[:patterns]
154
+ code_pickup = hash[:code]
135
155
 
136
156
  # repeat to each specified pickup pattern
137
157
  patterns.each do |pattern|
@@ -141,18 +161,26 @@ module CE
141
161
  # global match
142
162
  (text.scan(pattern)).size.times do
143
163
  pattern =~ text
144
- after_text += $` + code + $& + get_reset_code + get_start_code
164
+ after_text += $` + get_reset_code + code_pickup + $& + get_reset_code + get_start_code + get_start_code(:hitline)
145
165
  text = $'
146
166
  end
147
- text = after_text + text
167
+ text = after_text + text
168
+ is_match = ($& != nil) if (!is_match)
148
169
 
149
170
  # pattern is String
150
171
  else
151
- text.gsub!(pattern, code + pattern + get_reset_code + get_start_code)
172
+ res = text.gsub!(pattern, get_reset_code + code_pickup + pattern + get_reset_code + get_start_code + get_start_code(:hitline))
173
+ is_match = (res != nil) if (!is_match)
152
174
  end
153
175
  end
154
176
  end
155
177
 
178
+ if is_match
179
+ text = get_start_code(:hitline) + text + get_reset_code
180
+ elsif @@refresh_pre_match
181
+ text = orgtext
182
+ end
183
+
156
184
  return text
157
185
  end
158
186
 
@@ -183,4 +211,12 @@ module CE
183
211
  def task
184
212
  return @@task
185
213
  end
214
+
215
+ # try to remove escape sequence code
216
+ # @param string text
217
+ # @return texgt
218
+ def cleanup_text(text)
219
+ text.gsub!(/\e\[[0-9;]+[mK]/, "")
220
+ return text
221
+ end
186
222
  end