4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
|
# File 'ext/ae-editor/ae-editor.rb', line 4006
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{|t|
if @i.nil?
@tok = []
@tok << t
@i = 1
next
else
@tok << t
@i = nil
end
tok = @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, :begin_group,:end_group].include?(tok[0])&& tok[1].class==Symbol)
toklength = tok[0].length
t_begin="#{row}.#{col}"
if tok[0].include?("\n")
ar = tok[0].split("\n")
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]
end
end
}
tags_map
end
|