From 4b2f6a60ff0413132116148c0fbf220602f45ca9 Mon Sep 17 00:00:00 2001 From: Tim Gerundt Date: Fri, 24 Mar 2006 20:41:13 +0000 Subject: [PATCH] PATCH: [ 1457306 ] Revamped Visual Basic syntax highlighter --- Src/Changes.txt | 4 ++++ Src/editlib/basic.cpp | 51 +++++++++++---------------------------------------- 2 files changed, 15 insertions(+), 40 deletions(-) diff --git a/Src/Changes.txt b/Src/Changes.txt index d72a296fa..3324bc9dc 100644 --- a/Src/Changes.txt +++ b/Src/Changes.txt @@ -2,6 +2,10 @@ Src\Changes.txt Add new items to top. (This summarizes all changes to all files under Src, including Src\Languages.) +2006-03-24 Tim + PATCH: [ 1457306 ] Revamped Visual Basic syntax highlighter + Src\editlib: basic.cpp + 2006-03-24 Kimmo BUG: [ 1455656 ] GPL text still contains 'How to Apply These Terms...' Docs/Users: GPL.rtf diff --git a/Src/editlib/basic.cpp b/Src/editlib/basic.cpp index 2735f96ee..2dd2c2764 100644 --- a/Src/editlib/basic.cpp +++ b/Src/editlib/basic.cpp @@ -265,7 +265,7 @@ IsBasicNumber (LPCTSTR pszChars, int nLength) return TRUE; } -#define DEFINE_BLOCK(pos, colorindex) \ +#define DEFINE_BLOCK(pos, colorindex) \ ASSERT((pos) >= 0 && (pos) <= nLength);\ if (pBuf != NULL)\ {\ @@ -276,11 +276,11 @@ if (pBuf != NULL)\ nActualItems ++;}\ } -#define COOKIE_COMMENT 0x0001 -#define COOKIE_PREPROCESSOR 0x0002 -#define COOKIE_EXT_COMMENT 0x0004 -#define COOKIE_STRING 0x0008 -#define COOKIE_CHAR 0x0010 +#define COOKIE_COMMENT 0x0001 +#define COOKIE_PREPROCESSOR 0x0002 +#define COOKIE_EXT_COMMENT 0x0004 +#define COOKIE_STRING 0x0008 +#define COOKIE_CHAR 0x0010 DWORD CCrystalTextView:: ParseLineBasic (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems) @@ -307,16 +307,11 @@ ParseLineBasic (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualIt { DEFINE_BLOCK (nPos, COLORINDEX_COMMENT); } - else if (dwCookie & (COOKIE_STRING)) + else if (dwCookie & (COOKIE_CHAR | COOKIE_STRING)) { DEFINE_BLOCK (nPos, COLORINDEX_STRING); } - //Use COOKIE_CHAR for comments, because Visual Basic use ' for comments. - else if (dwCookie & (COOKIE_CHAR)) - { - DEFINE_BLOCK (nPos, COLORINDEX_COMMENT); - } - else + else { if (xisalnum (pszChars[nPos]) || pszChars[nPos] == '.' && nPos > 0 && (!xisalpha (*::CharPrev(pszChars, pszChars + nPos)) && !xisalpha (*::CharNext(pszChars + nPos)))) { @@ -348,7 +343,7 @@ out: // String constant "...." if (dwCookie & COOKIE_STRING) { - if (pszChars[I] == '"' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\'))) + if (pszChars[I] == '"') { dwCookie &= ~COOKIE_STRING; bRedefineBlock = TRUE; @@ -356,35 +351,13 @@ out: continue; } - // Char constant '..' - if (dwCookie & COOKIE_CHAR) - { - if (pszChars[I] == '\'' && (I == 0 || I == 1 && pszChars[nPrevI] != '\\' || I >= 2 && (pszChars[nPrevI] != '\\' || pszChars[nPrevI] == '\\' && *::CharPrev(pszChars, pszChars + nPrevI) == '\\'))) - { - dwCookie &= ~COOKIE_CHAR; - bRedefineBlock = TRUE; - } - continue; - } - if (pszChars[I] == '\'') { - // if (I + 1 < nLength && pszChars[I + 1] == '\'' || I + 2 < nLength && pszChars[I + 1] != '\\' && pszChars[I + 2] == '\'' || I + 3 < nLength && pszChars[I + 1] == '\\' && pszChars[I + 3] == '\'') - if (!I || !xisalnum (pszChars[nPrevI])) - { - DEFINE_BLOCK (I, COLORINDEX_STRING); - dwCookie |= COOKIE_CHAR; - continue; - } - } - if (I > 2 && !xisalnum (pszChars[I]) && (pszChars[nPrevI] == 'M' || pszChars[nPrevI] == 'm') && (*::CharPrev(pszChars, pszChars + nPrevI) == 'E' || *::CharPrev(pszChars, pszChars + nPrevI) == 'e') && (pszChars[I - 3] == 'R' || pszChars[I - 3] == 'r')) - { - DEFINE_BLOCK (I - 3, COLORINDEX_COMMENT); + DEFINE_BLOCK (I, COLORINDEX_COMMENT); dwCookie |= COOKIE_COMMENT; break; } - // Normal text if (pszChars[I] == '"') { @@ -479,8 +452,6 @@ out: } } - if (pszChars[nLength - 1] != '\\' || m_pTextBuffer->IsMBSTrail(nLineIndex, nLength - 1)) - dwCookie &= COOKIE_EXT_COMMENT; + dwCookie &= COOKIE_EXT_COMMENT; return dwCookie; } - -- 2.11.0