diff --git a/scintilla/lexers/LexRegistry.cxx b/scintilla/lexers/LexRegistry.cxx index fa4ad4d07..d2a37740a 100644 --- a/scintilla/lexers/LexRegistry.cxx +++ b/scintilla/lexers/LexRegistry.cxx @@ -32,7 +32,7 @@ using namespace Scintilla; static const char *const RegistryWordListDesc[] = { - 0 + nullptr }; struct OptionsRegistry { @@ -64,6 +64,10 @@ class LexerRegistry : public DefaultLexer { return (state == SCE_REG_ADDEDKEY || state == SCE_REG_DELETEDKEY); } + static bool IsByteValue(int value) { + return ((value >= 0) && (value < 256)); + } + static bool AtValueType(LexAccessor &styler, Sci_Position start) { Sci_Position i = 0; while (i < 10) { @@ -79,11 +83,6 @@ class LexerRegistry : public DefaultLexer { } static bool AtEndOfLine(LexAccessor& styler, Sci_Position pos) { - //char curr; - //do { - // curr = styler.SafeGetCharAt(pos, '\0'); - // ++pos; - //} while (curr == ' ' || curr == '\t'); const char curr = styler.SafeGetCharAt(pos, '\0'); const char next = styler.SafeGetCharAt(pos+1, '\0'); return (!curr || (curr == '\n') || (curr == '\r' && next != '\n')); @@ -125,13 +124,9 @@ class LexerRegistry : public DefaultLexer { } static bool AtKeyPathEnd(LexAccessor& styler, Sci_Position start) { - bool atEOL = false; while (!AtEndOfLine(styler, start + 1)) { - ++start; - char curr = styler.SafeGetCharAt(start, '\0'); - char next = styler.SafeGetCharAt(start+1, '\0'); - atEOL = (curr == '\r' && next != '\n') || (curr == '\n'); - if (curr == ']' || !curr) { + char curr = styler.SafeGetCharAt(++start, '\0'); + if (curr == ']') { // There's still at least one or more square brackets ahead return false; } @@ -193,7 +188,7 @@ public: return -1; } void *SCI_METHOD PrivateCall(int, void *) override { - return 0; + return nullptr; } static ILexer4 *LexerFactoryRegistry() { return new LexerRegistry; @@ -223,11 +218,16 @@ void SCI_METHOD LexerRegistry::Lex(Sci_PositionU startPos, StyleContext context(startPos, length, initStyle, styler); bool highlight = true; bool afterEqualSign = false; + int stateBefore = SCE_REG_DEFAULT; + while (context.More() && context.ch) { if (context.atLineStart) { Sci_Position currPos = static_cast(context.currentPos); bool continued = styler[currPos-3] == '\\'; highlight = continued ? true : false; + if (IsKeyPathState(context.state) && !highlight) { + context.SetState(SCE_REG_DEFAULT); + } } switch (context.state) { case SCE_REG_COMMENT: @@ -276,8 +276,7 @@ void SCI_METHOD LexerRegistry::Lex(Sci_PositionU startPos, case SCE_REG_DELETEDKEY: case SCE_REG_ADDEDKEY: { Sci_Position currPos = static_cast(context.currentPos); - //if (context.ch == ']' && AtKeyPathEnd(styler, currPos)) { - if (AtEndOfLine(styler, currPos)) { + if (context.ch == ']' && AtKeyPathEnd(styler, currPos)) { context.ForwardSetState(SCE_REG_DEFAULT); } else if (context.ch == '{') { if (AtGUID(styler, currPos)) { @@ -307,9 +306,7 @@ void SCI_METHOD LexerRegistry::Lex(Sci_PositionU startPos, Sci_Position currPos = static_cast(context.currentPos); if (context.ch == '"' && IsStringState(context.state)) { context.ForwardSetState(SCE_REG_DEFAULT); - //} else if (context.ch == ']' && AtKeyPathEnd(styler, currPos) && - } else if (AtEndOfLine(styler, currPos) && - IsKeyPathState(context.state)) { + } else if (context.ch == ']' && AtKeyPathEnd(styler, currPos) && IsKeyPathState(context.state)) { context.ForwardSetState(SCE_REG_DEFAULT); } else if (context.ch == '\\' && IsStringState(context.state)) { beforeEscape = context.state; @@ -344,14 +341,18 @@ void SCI_METHOD LexerRegistry::Lex(Sci_PositionU startPos, if (wordStart && AtValueType(styler, currPos)) { context.SetState(SCE_REG_VALUETYPE); } - } else if (isxdigit(context.ch & 0xFF) && highlight) { + } else if (IsByteValue(context.ch) && isxdigit(context.ch & 0xFF) && highlight) { context.SetState(SCE_REG_HEXDIGIT); } highlight = (context.ch == '@') ? true : highlight; if (setOperators.Contains(context.ch) && highlight) { context.SetState(SCE_REG_OPERATOR); } + if (context.chPrev == ']' && !IsNextNonWhitespace(styler, currPos - 1, ';')) { + context.SetState(stateBefore); // continue Reg-Key style for eolfilled + } } + stateBefore = context.state; context.Forward(); } context.Complete(); diff --git a/src/Edit.c b/src/Edit.c index a97d79065..e27bf1feb 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -4244,7 +4244,7 @@ void EditJumpTo(HWND hwnd, DocLn iNewLine, DocPos iNewCol) // void EditFixPositions(HWND hwnd) { - DocPos iMaxPos = SciCall_GetTextLength();; + DocPos iMaxPos = SciCall_GetTextLength(); DocPos iCurrentPos = SciCall_GetCurrentPos(); DocPos iAnchorPos = SciCall_GetAnchor(); diff --git a/src/Notepad3.c b/src/Notepad3.c index 2088ec8ab..a5eacd513 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -1432,21 +1432,21 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance) pIniSection = LocalAlloc(LPTR,sizeof(WCHAR) * 32 * 1024); cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR); LoadIniSection(L"Toolbar Labels",pIniSection,cchIniSection); - n = 1; for (i = 0; i < COUNTOF(tbbMainWnd); i++) { if (tbbMainWnd[i].fsStyle == TBSTYLE_SEP) continue; - StringCchPrintf(tchIndex,COUNTOF(tchIndex),L"%02i",n++); - - if (IniSectionGetString(pIniSection,tchIndex,L"",tchDesc,COUNTOF(tchDesc))) { + n = tbbMainWnd[i].iBitmap + 1; + StringCchPrintf(tchIndex,COUNTOF(tchIndex),L"%02i",n); + if (IniSectionGetString(pIniSection,tchIndex,L"",tchDesc,COUNTOF(tchDesc))) + { tbbMainWnd[i].iString = SendMessage(g_hwndToolbar,TB_ADDSTRING,0,(LPARAM)tchDesc); tbbMainWnd[i].fsStyle |= BTNS_AUTOSIZE | BTNS_SHOWTEXT; } - - else + else { tbbMainWnd[i].fsStyle &= ~(BTNS_AUTOSIZE | BTNS_SHOWTEXT); + } } LocalFree(pIniSection); @@ -3503,10 +3503,8 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) case SCLEX_AHK: case SCLEX_NSIS: // # could also be used instead case SCLEX_INNOSETUP: - EditToggleLineComments(g_hwndEdit, L";", TRUE); - break; case SCLEX_REGISTRY: - EditToggleLineComments(g_hwndEdit, L";;", TRUE); + EditToggleLineComments(g_hwndEdit, L";", TRUE); break; case SCLEX_SQL: case SCLEX_LUA: @@ -7265,8 +7263,6 @@ void RestoreAction(int token, DoAction doAct) // we are inside undo/redo transaction, so do delayed PostMessage() instead of SendMessage() #define ISSUE_MESSAGE PostMessage - ISSUE_MESSAGE(g_hwndEdit, SCI_CANCEL, 0, 0); // prepare - not needed ? - const DocPos _anchorPos = (doAct == UNDO ? sel.anchorPos_undo : sel.anchorPos_redo); const DocPos _curPos = (doAct == UNDO ? sel.curPos_undo : sel.curPos_redo); @@ -7281,7 +7277,7 @@ void RestoreAction(int token, DoAction doAct) const int selectionMode = (doAct == UNDO ? sel.selMode_undo : sel.selMode_redo); ISSUE_MESSAGE(g_hwndEdit, SCI_SETSELECTIONMODE, (WPARAM)selectionMode, 0); - // independant from selection mode + // independent from selection mode ISSUE_MESSAGE(g_hwndEdit, SCI_SETANCHOR, (WPARAM)_anchorPos, 0); ISSUE_MESSAGE(g_hwndEdit, SCI_SETCURRENTPOS, (WPARAM)_curPos, 0); @@ -7309,8 +7305,7 @@ void RestoreAction(int token, DoAction doAct) // nothing to do here break; } - - //ISSUE_MESSAGE(g_hwndEdit, SCI_CANCEL, 0, 0); + ISSUE_MESSAGE(g_hwndEdit, SCI_CANCEL, 0, 0); #undef ISSUE_MASSAGE }