From 8b207b38b2e1b88f4d5629ce7891c44ad35d870b Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Fri, 16 Oct 2015 22:34:24 -0400 Subject: [PATCH] highlight: add flag `include_whole_lines` Signed-off-by: Jean Privat --- src/highlight.nit | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/highlight.nit b/src/highlight.nit index d2be8d8..424824f 100644 --- a/src/highlight.nit +++ b/src/highlight.nit @@ -59,6 +59,14 @@ class HighlightVisitor # Default: false. var include_loose_tokens = false is writable + # When highlighting a node, the first and the last lines are fully included. + # + # If the highlighted node starts (or ends) in the middle of a line, + # this flags forces the whole line to be highlighted. + # + # Default: false + var include_whole_lines = false is writable + # The entry-point of the highlighting. # Will fill `html` with the generated HTML content. fun enter_visit(n: ANode) @@ -84,6 +92,11 @@ class HighlightVisitor if l.next_looses.not_empty then l = l.next_looses.last end + if include_whole_lines then + f = f.first_real_token_in_line + l = l.last_real_token_in_line + end + htmlize(f, l) end -- 1.7.9.5