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.



3741
3742
3743
3744
# File 'ext/ae-editor/ae-editor.rb', line 3741

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

Instance Method Details

#highlight_tags(_row_begin, _code) ⇒ Object

end



3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
# File 'ext/ae-editor/ae-editor.rb', line 3752

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