11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/trace_visualization/visualization/console_color_print.rb', line 11
def self.hl(mapping, repetition)
raise 'repetition must be instance of TraceVisualization::Data::Repetition' if not repetition.instance_of? TraceVisualization::Data::Repetition
result = ''
prev_position = 0
positions = repetition.build_positions
positions.each do |position|
result += mapping.restore(prev_position, position[0][0] - prev_position)
for i in 0 ... position.size
pos, len = position[i]
result += GRN + "#{mapping.restore(pos, len)}" + FINISH
result += YLW + "#{mapping.restore(pos + len, position[i + 1][0] - (pos + len))}" + FINISH if i < position.size - 1
end
prev_position = position[-1][0] + position[-1][1]
end
result += mapping.restore(prev_position, mapping.length - prev_position)
end
|