From f497b5aaa287f9f2767220934706f091e1a06d2f Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sun, 21 Feb 2010 21:35:24 +0000 Subject: Patch from Haimag Ren adds folding of line comments. --- src/LexVerilog.cxx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/LexVerilog.cxx') diff --git a/src/LexVerilog.cxx b/src/LexVerilog.cxx index 3fd0fc35c..8b531bb7e 100644 --- a/src/LexVerilog.cxx +++ b/src/LexVerilog.cxx @@ -150,6 +150,22 @@ static bool IsStreamCommentStyle(int style) { return style == SCE_V_COMMENT; } +static bool IsCommentLine(int line, Accessor &styler) { + int pos = styler.LineStart(line); + int eolPos = styler.LineStart(line + 1) - 1; + for (int i = pos; i < eolPos; i++) { + char ch = styler[i]; + char chNext = styler.SafeGetCharAt(i + 1); + int style = styler.StyleAt(i); + if (ch == '/' && chNext == '/' && + (style == SCE_V_COMMENTLINE || style == SCE_V_COMMENTLINEBANG)) { + return true; + } else if (!IsASpaceOrTab(ch)) { + return false; + } + } + return false; +} // Store both the current line's fold level and the next lines in the // level store to make it easy to pick up with each increment // and to make it possible to fiddle the current level for "} else {". @@ -195,6 +211,15 @@ static void FoldNoBoxVerilogDoc(unsigned int startPos, int length, int initStyle levelNext--; } } + if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) + { + if (!IsCommentLine(lineCurrent - 1, styler) + && IsCommentLine(lineCurrent + 1, styler)) + levelNext++; + else if (IsCommentLine(lineCurrent - 1, styler) + && !IsCommentLine(lineCurrent+1, styler)) + levelNext--; + } if (foldComment && (style == SCE_V_COMMENTLINE)) { if ((ch == '/') && (chNext == '/')) { char chNext2 = styler.SafeGetCharAt(i + 2); -- cgit v1.2.3