diff options
author | nyamatongwe <unknown> | 2010-02-21 21:35:24 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2010-02-21 21:35:24 +0000 |
commit | f497b5aaa287f9f2767220934706f091e1a06d2f (patch) | |
tree | 80db72bc673ca361da251ec3b0d63181a4e196a6 /src/LexVerilog.cxx | |
parent | c882387764423ac8b693b1909cc78e74ec63cddb (diff) | |
download | scintilla-mirror-f497b5aaa287f9f2767220934706f091e1a06d2f.tar.gz |
Patch from Haimag Ren adds folding of line comments.
Diffstat (limited to 'src/LexVerilog.cxx')
-rw-r--r-- | src/LexVerilog.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
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); |