Class: ReHighlightScanner
- Inherits:
-
HighlightScanner
- Object
- HighlightScanner
- ReHighlightScanner
- Defined in:
- ext/ae-editor/ae-editor.rb
Instance Method Summary collapse
- #find_tag(_tag, _row, _txt) ⇒ Object
- #highlight_tags(_row_begin, _code, _classes = self.classes) ⇒ Object
-
#initialize(_langs_conf) ⇒ ReHighlightScanner
constructor
A new instance of ReHighlightScanner.
Methods inherited from HighlightScanner
Constructor Details
#initialize(_langs_conf) ⇒ ReHighlightScanner
Returns a new instance of ReHighlightScanner.
3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 |
# File 'ext/ae-editor/ae-editor.rb', line 3170 def initialize(_langs_conf) super(_langs_conf) @h_re = Hash.new @op_to_end_line = Array.new @op_to_end_line.concat(@langs_conf['re_op.to_line_end'].split(',')) if @langs_conf['re_op.to_line_end'] @op_only_first = Array.new @op_only_first.concat(@langs_conf['re_op.only_first'].split(',')) if @langs_conf['re_op.only_first'] self.classes.each{|c| @h_re[c]=Regexp::new(@langs_conf["re.#{c}"].strip) if @langs_conf["re.#{c}"] } end |
Instance Method Details
#find_tag(_tag, _row, _txt) ⇒ Object
3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 |
# File 'ext/ae-editor/ae-editor.rb', line 3185 def find_tag(_tag, _row, _txt) to_ret = [] _re = @h_re[_tag] m = _re.match(_txt) _end = 0 while m && (_txt=m.post_match) if !defined?(_old_txt) || _txt != _old_txt _old_txt = _txt _ibegin = _row.to_s+'.'+(m.begin(0)+_end).to_s _end = m.end(0) + _end _iend = _row.to_s+'.'+(_end.to_s) to_ret << [_ibegin, _iend] if @op_only_first.include?(_tag) m = nil else m = _re.match(_txt) end else m = nil end end to_ret end |
#highlight_tags(_row_begin, _code, _classes = self.classes) ⇒ Object
3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 |
# File 'ext/ae-editor/ae-editor.rb', line 3209 def (_row_begin,_code,_classes=self.classes) super(_row_begin,_code) = Hash.new lines = _code.split("\n") lines.each_with_index{|_line,_i| _line+="\n" _row = _row_begin+_i #p "_row=#{_row}-_line=#{_line}" _txt = _line _end = 0 @op_to_end_line.each{|c| if _classes.include?(c) && @h_re[c] m_c = @h_re[c].match(_txt) if m_c then _ibegin = _row.to_s+'.'+(m_c.begin(0)).to_s _iend = _row.to_s+'.'+(_line.length - 1).to_s [c] = [] if [c].nil? [c] << [_ibegin, _iend] _txt = m_c.pre_match end end } if @langs_conf['re_op.to_line_end'] _classes.each{|c| if !@op_to_end_line.include?(c) && @h_re[c] = find_tag(c, _row, _txt) if .length >0 [c] = [] if [c].nil? [c].concat() end end } if _txt.strip.length > 0 } end |