159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
# File 'lib/holdify/feedback.rb', line 159
def render_line(line, lineno, width)
clean = line.strip
type, color = case
when clean.start_with?(SGR[:green]) && !line.include?(SGR[:red]) && clean.end_with?(SGR[:clear], "\e[m")
['+', :green]
when clean.start_with?(SGR[:red]) && !line.include?(SGR[:green]) && clean.end_with?(SGR[:clear], "\e[m")
['-', :red]
when line.include?(SGR[:red]) || line.include?(SGR[:green])
['~', :yellow]
else
[' ', :none]
end
gutter = if type == '+'
' ' * width
else
lineno[0] += 1
lineno[0].to_s.rjust(width)
end
"#{dye(color, "#{type}#{gutter}")} #{line}"
end
|