diff options
-rw-r--r-- | include/SciLexer.h | 4 | ||||
-rw-r--r-- | src/Editor.cxx | 10 | ||||
-rw-r--r-- | src/LexHTML.cxx | 40 | ||||
-rw-r--r-- | src/ScintillaBase.cxx | 1 |
4 files changed, 47 insertions, 8 deletions
diff --git a/include/SciLexer.h b/include/SciLexer.h index 4671941f7..950f0cf48 100644 --- a/include/SciLexer.h +++ b/include/SciLexer.h @@ -57,7 +57,7 @@ #define SCE_C_IDENTIFIER 11 #define SCE_C_STRINGEOL 12 -// Lexical states for SCLEX_HTML, SCLEX_xML +// Lexical states for SCLEX_HTML, SCLEX_XML #define SCE_H_DEFAULT 0 #define SCE_H_TAG 1 #define SCE_H_TAGUNKNOWN 2 @@ -78,6 +78,8 @@ #define SCE_H_ASPAT 16 #define SCE_H_CDATA 17 #define SCE_H_QUESTION 18 +// More HTML +#define SCE_H_VALUE 19 // Embedded Javascript #define SCE_HJ_START 40 #define SCE_HJ_DEFAULT 41 diff --git a/src/Editor.cxx b/src/Editor.cxx index 6969458d3..e6f44f5df 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1230,12 +1230,14 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { if (line == lineCaret) { int offset = Platform::Minimum(posCaret - posLineStart, LineLayout::maxLineLength); int xposCaret = ll.positions[offset] + xStart; - int widthOverstrikeCaret = - ll.positions[offset + 1] - ll.positions[offset]; - if (posCaret == pdoc->Length()) // At end of document + int widthOverstrikeCaret = 1; + if (posCaret == pdoc->Length()) { // At end of document widthOverstrikeCaret = vs.aveCharWidth; - if ((posCaret - posLineStart) >= ll.numCharsInLine) // At end of line + } else if ((posCaret - posLineStart) >= ll.numCharsInLine) { // At end of line widthOverstrikeCaret = vs.aveCharWidth; + } else { + widthOverstrikeCaret = ll.positions[offset + 1] - ll.positions[offset]; + } if (widthOverstrikeCaret < 3) // Make sure its visible widthOverstrikeCaret = 3; if (((caret.active && caret.on) || (posDrag >= 0)) && xposCaret >= 0) { diff --git a/src/LexHTML.cxx b/src/LexHTML.cxx index 15f7ed3cb..54fac38e1 100644 --- a/src/LexHTML.cxx +++ b/src/LexHTML.cxx @@ -115,9 +115,13 @@ static int stateForPrintState(int StateToPrint) { return state; } -static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { - bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.') || +static inline bool IsNumber(unsigned int start, Accessor &styler) { + return isdigit(styler[start]) || (styler[start] == '.') || (styler[start] == '-') || (styler[start] == '#'); +} + +static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { + bool wordIsNumber = IsNumber(start, styler); char chAttr = SCE_H_ATTRIBUTEUNKNOWN; if (wordIsNumber) { chAttr = SCE_H_NUMBER; @@ -603,6 +607,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } else { state = SCE_H_DEFAULT; } + } else if (ch == '=') { + styler.ColourTo(i, SCE_H_OTHER); + state = SCE_H_VALUE; } else { state = SCE_H_OTHER; } @@ -623,6 +630,9 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } else if (ch == '\'') { styler.ColourTo(i - 1, StateToPrint); state = SCE_H_SINGLESTRING; + } else if (ch == '=') { + styler.ColourTo(i, StateToPrint); + state = SCE_H_VALUE; } else if (ch == '/' && chNext == '>') { styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i + 1, SCE_H_TAGEND); @@ -658,6 +668,32 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty state = SCE_H_OTHER; } break; + case SCE_H_VALUE: + if (!ishtmlwordchar(ch)) { + if (ch == '\"') { + // Should really test for being first character + state = SCE_H_DOUBLESTRING; + } else if (ch == '\'') { + state = SCE_H_SINGLESTRING; + } else { + if (IsNumber(styler.GetStartSegment(), styler)) { + styler.ColourTo(i - 1, SCE_H_NUMBER); + } else { + styler.ColourTo(i - 1, StateToPrint); + } + if (ch == '>') { + styler.ColourTo(i, SCE_H_TAG); + if (inScriptType == eNonHtmlScript) { + state = StateForScript(scriptLanguage); + } else { + state = SCE_H_DEFAULT; + } + } else { + state = SCE_H_OTHER; + } + } + } + break; case SCE_HJ_DEFAULT: case SCE_HJ_START: case SCE_HJ_SYMBOLS: diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 70e890e1a..4f182850a 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -62,7 +62,6 @@ void ScintillaBase::AddCharUTF(char *s, unsigned int len) { bool acActiveBeforeCharAdded = ac.Active(); if (!acActiveBeforeCharAdded || !ac.IsFillUpChar(*s)) Editor::AddCharUTF(s, len); - Editor::AddCharUTF(s, len); if (acActiveBeforeCharAdded) AutoCompleteChanged(s[0]); } |