Class: CoderayHighlightScannerOld

Inherits:
HighlightScanner show all
Defined in:
ext/ae-editor/ae-editor.rb

Instance Method Summary collapse

Methods inherited from HighlightScanner

#classes

Constructor Details

#initialize(_langs_conf) ⇒ CoderayHighlightScannerOld

Returns a new instance of CoderayHighlightScannerOld.



4184
4185
4186
4187
# File 'ext/ae-editor/ae-editor.rb', line 4184

def initialize(_langs_conf)
  super(_langs_conf)
  require 'coderay'
end

Instance Method Details

#highlight_tags(_row_begin, _code) ⇒ Object

end



4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
# File 'ext/ae-editor/ae-editor.rb', line 4195

def highlight_tags(_row_begin,_code)
  super(_row_begin,_code)
  c_scanner = CodeRay::Scanners[@lang].new _code
  row=_row_begin
  col=0
  tags_map = Hash.new 
  c_scanner.tokens.each{|tok|
    #p tok
    if tok[1]==:space && tok[0].include?("\n")
      row+=tok[0].count("\n")
      begin_gap = tok[0].split("\n")[-1]
      if begin_gap && tok[0][-1..-1]!="\n"
        col = begin_gap.length
      else
        col = 0
      end
    elsif !([:open,:close].include?(tok[0])&& tok[1].class==Symbol)
      toklength = tok[0].length
      t_begin="#{row}.#{col}"
      if tok[0].include?("\n")
        ar = tok[0].split
        row+=tok[0].count("\n")

        begin_gap = ar[-1]
        if begin_gap && tok[0][-1..-1]!="\n"
          col = begin_gap.length
        else
          col = 0
        end
      else
        col+=toklength
      end
      t_end="#{row}.#{col}"
      if tok[1]!=:space
        tags_map[tok[1]] = [] if tags_map[tok[1]].nil?
        tags_map[tok[1]] << [t_begin,t_end]
        #Arcadia.console(self, 'msg'=>"#{tok[1]}=#{[t_begin,t_end]}", 'level'=>'error')          
        #p [t_begin,t_end]
      end
    end  
  }
  tags_map
end