# Rendering format
#
# Set the output format for this piece of code.
- # Can be "raw" or "html".
+ # Can be "raw", "html" or "ansi".
# Default is "raw".
#
# This format can be different than the format used in the command response.
var hl = new HtmlightVisitor
hl.highlight_node node
return hl.html
+ else if format == "ansi" then
+ var hl = new AnsiHighlightVisitor
+ hl.highlight_node node
+ return hl.result
end
- # TODO make a raw visitor
- return node.to_s
+ var mentity = self.mentity
+ if mentity == null then return null
+ return mentity.location.text
end
end
end
redef class CmdCode
+
+ redef var format = "ansi" is optional
+
redef fun execute(no_color) do
var mentity = self.mentity
if mentity == null then return
else
print title
end
- printn mentity.cs_source_code
+ if no_color == null or not no_color then
+ var ansi = render
+ if ansi != null then
+ print "~~~"
+ print ansi.write_to_string
+ print "~~~"
+ end
+ else
+ printn mentity.cs_source_code
+ end
end
end