From 76283793f8f096e5a8b507cdd2d0f0cfe34c3d59 Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 18 Sep 2015 18:01:15 +0000 Subject: [PATCH] CodeEditor: #include highlighting #1268 git-svn-id: svn://ultimatepp.org/upp/trunk@8949 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CodeEditor/CHighlight.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/uppsrc/CodeEditor/CHighlight.cpp b/uppsrc/CodeEditor/CHighlight.cpp index 61c29110c..d88fd8227 100644 --- a/uppsrc/CodeEditor/CHighlight.cpp +++ b/uppsrc/CodeEditor/CHighlight.cpp @@ -108,6 +108,8 @@ void CSyntax::Highlight(const wchar *ltext, const wchar *e, HighlightOutput& hls InitKeywords(); } + bool include = false; + int tabsize = editor ? editor->GetTabSize() : 4; LTIMING("HighlightLine"); @@ -156,16 +158,17 @@ void CSyntax::Highlight(const wchar *ltext, const wchar *e, HighlightOutput& hls hls.Put(hl_style[INK_NORMAL]); } if(*p == '#' && findarg(highlight, HIGHLIGHT_JAVASCRIPT, HIGHLIGHT_CSS, HIGHLIGHT_JSON) < 0) { - static const char *pd[] = { - "define", "error", "if", "elif", "else", "endif", - "ifdef", "ifndef", "include", "line", "undef", "pragma", - // CLR - "using" - }; static Index macro; - if(macro.GetCount() == 0) + ONCELOCK { + static const char *pd[] = { + "include", "define", "error", "if", "elif", "else", "endif", + "ifdef", "ifndef", "line", "undef", "pragma", + // CLR + "using" + }; for(int i = 0; i < __countof(pd); i++) macro.Add(pd[i]); + } const wchar *q = p + 1; while(*q == ' ' || *q == '\t') q++; @@ -173,7 +176,10 @@ void CSyntax::Highlight(const wchar *ltext, const wchar *e, HighlightOutput& hls while(IsAlpha(*q)) id.Cat(*q++); cppid = id; - hls.Put(macro.Find(cppid) < 0 ? 1 : int(q - p), hl_style[INK_MACRO]); + int mq = macro.Find(cppid); + hls.Put(mq < 0 ? 1 : int(q - p), hl_style[INK_MACRO]); + if(mq == 0) + include = true; p = q; } } @@ -307,8 +313,8 @@ void CSyntax::Highlight(const wchar *ltext, const wchar *e, HighlightOutput& hls if(highlight == HIGHLIGHT_SQL) iid = ToUpper(iid); int uq = kw_upp.Find(iid); - int nq; - hls.Put(int(q - p), (nq = keyword[highlight].Find(iid)) >= 0 ? hl_style[INK_KEYWORD] : + int nq = -1; + hls.Put(int(q - p), !include && (nq = keyword[highlight].Find(iid)) >= 0 ? hl_style[INK_KEYWORD] : name[highlight].Find(iid) >= 0 ? hl_style[INK_UPP] : uq >= 0 ? uq < kw_macros ? hl_style[INK_UPPMACROS] : uq < kw_logs ? hl_style[INK_UPPLOGS] :