diff --git a/scintilla/lexers/LexMatlab.cxx b/scintilla/lexers/LexMatlab.cxx index 6cdb8f9c..e955ef2f 100644 --- a/scintilla/lexers/LexMatlab.cxx +++ b/scintilla/lexers/LexMatlab.cxx @@ -48,42 +48,42 @@ using namespace Scintilla; #endif static bool IsMatlabCommentChar(int c) { - return (c == '%') ; + return (c == '%') ; } static bool IsOctaveCommentChar(int c) { - return (c == '%' || c == '#') ; + return (c == '%' || c == '#') ; } static inline int LowerCase(int c) { - if (c >= 'A' && c <= 'Z') - return 'a' + c - 'A'; - return c; + if (c >= 'A' && c <= 'Z') + return 'a' + c - 'A'; + return c; } static int CheckKeywordFoldPoint(char *str) { - if (strcmp ("if", str) == 0 || - strcmp ("for", str) == 0 || - strcmp ("switch", str) == 0 || - strcmp ("try", str) == 0 || - strcmp ("do", str) == 0 || - strcmp ("parfor", str) == 0 || - strcmp ("function", str) == 0) - return 1; - if (strncmp("end", str, 3) == 0 || - strcmp("until", str) == 0) - return -1; - return 0; + if (strcmp ("if", str) == 0 || + strcmp ("for", str) == 0 || + strcmp ("switch", str) == 0 || + strcmp ("try", str) == 0 || + strcmp ("do", str) == 0 || + strcmp ("parfor", str) == 0 || + strcmp ("function", str) == 0) + return 1; + if (strncmp("end", str, 3) == 0 || + strcmp("until", str) == 0) + return -1; + return 0; } static bool IsSpaceToEOL(Sci_Position startPos, Accessor &styler) { - Sci_Position line = styler.GetLine(startPos); - Sci_Position eol_pos = styler.LineStart(line + 1) - 1; - for (Sci_Position i = startPos; i < eol_pos; i++) { - char ch = styler[i]; - if(!IsASpace(ch)) return false; - } - return true; + Sci_Position line = styler.GetLine(startPos); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; + for (Sci_Position i = startPos; i < eol_pos; i++) { + char ch = styler[i]; + if(!IsASpace(ch)) return false; + } + return true; } static void ColouriseMatlabOctaveDoc( @@ -92,277 +92,277 @@ static void ColouriseMatlabOctaveDoc( bool (*IsCommentChar)(int), bool ismatlab) { - WordList &keywords = *keywordlists[0]; + WordList &keywords = *keywordlists[0]; - styler.StartAt(startPos); + styler.StartAt(startPos); - // boolean for when the ' is allowed to be transpose vs the start/end - // of a string - bool transpose = false; + // boolean for when the ' is allowed to be transpose vs the start/end + // of a string + bool transpose = false; - // approximate position of first non space character in a line - int nonSpaceColumn = -1; - // approximate column position of the current character in a line - int column = 0; + // approximate position of first non space character in a line + int nonSpaceColumn = -1; + // approximate column position of the current character in a line + int column = 0; // use the line state of each line to store the block comment depth - Sci_Position curLine = styler.GetLine(startPos); + Sci_Position curLine = styler.GetLine(startPos); int commentDepth = curLine > 0 ? styler.GetLineState(curLine-1) : 0; - StyleContext sc(startPos, length, initStyle, styler); + StyleContext sc(startPos, length, initStyle, styler); - for (; sc.More(); sc.Forward(), column++) { + for (; sc.More(); sc.Forward(), column++) { - if(sc.atLineStart) { - // set the line state to the current commentDepth - curLine = styler.GetLine(sc.currentPos); + if(sc.atLineStart) { + // set the line state to the current commentDepth + curLine = styler.GetLine(sc.currentPos); styler.SetLineState(curLine, commentDepth); - // reset the column to 0, nonSpace to -1 (not set) - column = 0; - nonSpaceColumn = -1; - } - - // save the column position of first non space character in a line - if((nonSpaceColumn == -1) && (! IsASpace(sc.ch))) - { - nonSpaceColumn = column; - } - - // check for end of states - if (sc.state == SCE_MATLAB_OPERATOR) { - if (sc.chPrev == '.') { - if (sc.ch == '*' || sc.ch == '/' || sc.ch == '\\' || sc.ch == '^') { - sc.ForwardSetState(SCE_MATLAB_DEFAULT); - transpose = false; - } else if (sc.ch == '\'') { - sc.ForwardSetState(SCE_MATLAB_DEFAULT); - transpose = true; + // reset the column to 0, nonSpace to -1 (not set) + column = 0; + nonSpaceColumn = -1; + } + + // save the column position of first non space character in a line + if((nonSpaceColumn == -1) && (! IsASpace(sc.ch))) + { + nonSpaceColumn = column; + } + + // check for end of states + if (sc.state == SCE_MATLAB_OPERATOR) { + if (sc.chPrev == '.') { + if (sc.ch == '*' || sc.ch == '/' || sc.ch == '\\' || sc.ch == '^') { + sc.ForwardSetState(SCE_MATLAB_DEFAULT); + transpose = false; + } else if (sc.ch == '\'') { + sc.ForwardSetState(SCE_MATLAB_DEFAULT); + transpose = true; } else if(sc.ch == '.' && sc.chNext == '.') { // we werent an operator, but a '...' sc.ChangeState(SCE_MATLAB_COMMENT); transpose = false; - } else { - sc.SetState(SCE_MATLAB_DEFAULT); - } - } else { - sc.SetState(SCE_MATLAB_DEFAULT); - } - } else if (sc.state == SCE_MATLAB_KEYWORD) { - if (!isalnum(sc.ch) && sc.ch != '_') { - char s[100]; - sc.GetCurrentLowered(s, sizeof(s)); - if (keywords.InList(s)) { - sc.SetState(SCE_MATLAB_DEFAULT); - transpose = false; - } else { - sc.ChangeState(SCE_MATLAB_IDENTIFIER); - sc.SetState(SCE_MATLAB_DEFAULT); - transpose = true; - } - } - } else if (sc.state == SCE_MATLAB_NUMBER) { - if (!isdigit(sc.ch) && sc.ch != '.' - && !(sc.ch == 'e' || sc.ch == 'E') - && !((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E'))) { - sc.SetState(SCE_MATLAB_DEFAULT); - transpose = true; - } - } else if (sc.state == SCE_MATLAB_STRING) { - if (sc.ch == '\'') { - if (sc.chNext == '\'') { - sc.Forward(); - } else { - sc.ForwardSetState(SCE_MATLAB_DEFAULT); - } - } - } else if (sc.state == SCE_MATLAB_DOUBLEQUOTESTRING) { - if (sc.ch == '\\') { - if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { - sc.Forward(); - } - } else if (sc.ch == '\"') { - sc.ForwardSetState(SCE_MATLAB_DEFAULT); - } - } else if (sc.state == SCE_MATLAB_COMMAND) { - if (sc.atLineEnd) { - sc.SetState(SCE_MATLAB_DEFAULT); - transpose = false; - } - } else if (sc.state == SCE_MATLAB_COMMENT) { - // end or start of a nested a block comment? - if( IsCommentChar(sc.ch) && sc.chNext == '}' && nonSpaceColumn == column && IsSpaceToEOL(sc.currentPos+2, styler)) { - if(commentDepth > 0) commentDepth --; - - curLine = styler.GetLine(sc.currentPos); - styler.SetLineState(curLine, commentDepth); - sc.Forward(); - - if (commentDepth == 0) { - sc.ForwardSetState(SCE_D_DEFAULT); - transpose = false; - } + } else { + sc.SetState(SCE_MATLAB_DEFAULT); + } + } else { + sc.SetState(SCE_MATLAB_DEFAULT); + } + } else if (sc.state == SCE_MATLAB_KEYWORD) { + if (!isalnum(sc.ch) && sc.ch != '_') { + char s[100]; + sc.GetCurrentLowered(s, sizeof(s)); + if (keywords.InList(s)) { + sc.SetState(SCE_MATLAB_DEFAULT); + transpose = false; + } else { + sc.ChangeState(SCE_MATLAB_IDENTIFIER); + sc.SetState(SCE_MATLAB_DEFAULT); + transpose = true; + } + } + } else if (sc.state == SCE_MATLAB_NUMBER) { + if (!isdigit(sc.ch) && sc.ch != '.' + && !(sc.ch == 'e' || sc.ch == 'E') + && !((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E'))) { + sc.SetState(SCE_MATLAB_DEFAULT); + transpose = true; + } + } else if (sc.state == SCE_MATLAB_STRING) { + if (sc.ch == '\'') { + if (sc.chNext == '\'') { + sc.Forward(); + } else { + sc.ForwardSetState(SCE_MATLAB_DEFAULT); + } + } + } else if (sc.state == SCE_MATLAB_DOUBLEQUOTESTRING) { + if (sc.ch == '\\') { + if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { + sc.Forward(); + } + } else if (sc.ch == '\"') { + sc.ForwardSetState(SCE_MATLAB_DEFAULT); + } + } else if (sc.state == SCE_MATLAB_COMMAND) { + if (sc.atLineEnd) { + sc.SetState(SCE_MATLAB_DEFAULT); + transpose = false; + } + } else if (sc.state == SCE_MATLAB_COMMENT) { + // end or start of a nested a block comment? + if( IsCommentChar(sc.ch) && sc.chNext == '}' && nonSpaceColumn == column && IsSpaceToEOL(sc.currentPos+2, styler)) { + if(commentDepth > 0) commentDepth --; + + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, commentDepth); + sc.Forward(); + + if (commentDepth == 0) { + sc.ForwardSetState(SCE_D_DEFAULT); + transpose = false; + } } else if( IsCommentChar(sc.ch) && sc.chNext == '{' && nonSpaceColumn == column && IsSpaceToEOL(sc.currentPos+2, styler)) { - commentDepth ++; + commentDepth ++; - curLine = styler.GetLine(sc.currentPos); - styler.SetLineState(curLine, commentDepth); - sc.Forward(); - transpose = false; + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, commentDepth); + sc.Forward(); + transpose = false; } else if(commentDepth == 0) { - // single line comment - if (sc.atLineEnd || sc.ch == '\r' || sc.ch == '\n') { - sc.SetState(SCE_MATLAB_DEFAULT); - transpose = false; - } - } - } - - // check start of a new state - if (sc.state == SCE_MATLAB_DEFAULT) { - if (IsCommentChar(sc.ch)) { - // ncrement depth if we are a block comment - if(sc.chNext == '{' && nonSpaceColumn == column) { - if(IsSpaceToEOL(sc.currentPos+2, styler)) { - commentDepth ++; - } - } - curLine = styler.GetLine(sc.currentPos); - styler.SetLineState(curLine, commentDepth); - sc.SetState(SCE_MATLAB_COMMENT); - } else if (sc.ch == '!' && sc.chNext != '=' ) { - if(ismatlab) { - sc.SetState(SCE_MATLAB_COMMAND); - } else { - sc.SetState(SCE_MATLAB_OPERATOR); - } - } else if (sc.ch == '\'') { - if (transpose) { - sc.SetState(SCE_MATLAB_OPERATOR); - } else { - sc.SetState(SCE_MATLAB_STRING); - } - } else if (sc.ch == '"') { - sc.SetState(SCE_MATLAB_DOUBLEQUOTESTRING); - } else if (isdigit(sc.ch) || (sc.ch == '.' && isdigit(sc.chNext))) { - sc.SetState(SCE_MATLAB_NUMBER); - } else if (isalpha(sc.ch)) { - sc.SetState(SCE_MATLAB_KEYWORD); - } else if (isoperator(static_cast(sc.ch)) || sc.ch == '@' || sc.ch == '\\') { - if (sc.ch == ')' || sc.ch == ']' || sc.ch == '}') { - transpose = true; - } else { - transpose = false; - } - sc.SetState(SCE_MATLAB_OPERATOR); - } else { - transpose = false; - } - } - } - sc.Complete(); + // single line comment + if (sc.atLineEnd || sc.ch == '\r' || sc.ch == '\n') { + sc.SetState(SCE_MATLAB_DEFAULT); + transpose = false; + } + } + } + + // check start of a new state + if (sc.state == SCE_MATLAB_DEFAULT) { + if (IsCommentChar(sc.ch)) { + // ncrement depth if we are a block comment + if(sc.chNext == '{' && nonSpaceColumn == column) { + if(IsSpaceToEOL(sc.currentPos+2, styler)) { + commentDepth ++; + } + } + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, commentDepth); + sc.SetState(SCE_MATLAB_COMMENT); + } else if (sc.ch == '!' && sc.chNext != '=' ) { + if(ismatlab) { + sc.SetState(SCE_MATLAB_COMMAND); + } else { + sc.SetState(SCE_MATLAB_OPERATOR); + } + } else if (sc.ch == '\'') { + if (transpose) { + sc.SetState(SCE_MATLAB_OPERATOR); + } else { + sc.SetState(SCE_MATLAB_STRING); + } + } else if (sc.ch == '"') { + sc.SetState(SCE_MATLAB_DOUBLEQUOTESTRING); + } else if (isdigit(sc.ch) || (sc.ch == '.' && isdigit(sc.chNext))) { + sc.SetState(SCE_MATLAB_NUMBER); + } else if (isalpha(sc.ch)) { + sc.SetState(SCE_MATLAB_KEYWORD); + } else if (isoperator(static_cast(sc.ch)) || sc.ch == '@' || sc.ch == '\\') { + if (sc.ch == ')' || sc.ch == ']' || sc.ch == '}') { + transpose = true; + } else { + transpose = false; + } + sc.SetState(SCE_MATLAB_OPERATOR); + } else { + transpose = false; + } + } + } + sc.Complete(); } static void ColouriseMatlabDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { - ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabCommentChar, true); + ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabCommentChar, true); } static void ColouriseOctaveDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { - ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveCommentChar, false); + ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveCommentChar, false); } static void FoldMatlabOctaveDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[], Accessor &styler, bool (*IsComment)(int ch)) { - Sci_PositionU endPos = startPos + length; - int visibleChars = 0; - Sci_Position lineCurrent = styler.GetLine(startPos); - int levelCurrent = SC_FOLDLEVELBASE; - if (lineCurrent > 0) - levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; - int levelNext = levelCurrent; - char chNext = styler[startPos]; - int styleNext = styler.StyleAt(startPos); - int style = initStyle; - char word[100]; - int wordlen = 0; - for (Sci_PositionU i = startPos; i < endPos; i++) { - char ch = chNext; - chNext = styler.SafeGetCharAt(i + 1); - style = styleNext; - styleNext = styler.StyleAt(i + 1); - bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); - - // a line that starts with a comment - if (style == SCE_MATLAB_COMMENT && IsComment(ch) && visibleChars == 0) { - // start/end of block comment - if (chNext == '{' && IsSpaceToEOL(i+2, styler)) - levelNext ++; - if (chNext == '}' && IsSpaceToEOL(i+2, styler)) - levelNext --; - } - // keyword - if(style == SCE_MATLAB_KEYWORD) { - word[wordlen++] = static_cast(LowerCase(ch)); - if (wordlen == 100) { // prevent overflow - word[0] = '\0'; - wordlen = 1; - } - if (styleNext != SCE_MATLAB_KEYWORD) { - word[wordlen] = '\0'; - wordlen = 0; - - levelNext += CheckKeywordFoldPoint(word); - } - } - if (!IsASpace(ch)) - visibleChars++; - if (atEOL || (i == endPos-1)) { - int levelUse = levelCurrent; - int lev = levelUse | levelNext << 16; - if (visibleChars == 0) - lev |= SC_FOLDLEVELWHITEFLAG; - if (levelUse < levelNext) - lev |= SC_FOLDLEVELHEADERFLAG; - if (lev != styler.LevelAt(lineCurrent)) { - styler.SetLevel(lineCurrent, lev); - } - lineCurrent++; - levelCurrent = levelNext; - if (atEOL && (i == static_cast(styler.Length() - 1))) { - // There is an empty line at end of file so give it same level and empty - styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG); - } - visibleChars = 0; - } - } + Sci_PositionU endPos = startPos + length; + int visibleChars = 0; + Sci_Position lineCurrent = styler.GetLine(startPos); + int levelCurrent = SC_FOLDLEVELBASE; + if (lineCurrent > 0) + levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; + int levelNext = levelCurrent; + char chNext = styler[startPos]; + int styleNext = styler.StyleAt(startPos); + int style = initStyle; + char word[100]; + int wordlen = 0; + for (Sci_PositionU i = startPos; i < endPos; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + style = styleNext; + styleNext = styler.StyleAt(i + 1); + bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); + + // a line that starts with a comment + if (style == SCE_MATLAB_COMMENT && IsComment(ch) && visibleChars == 0) { + // start/end of block comment + if (chNext == '{' && IsSpaceToEOL(i+2, styler)) + levelNext ++; + if (chNext == '}' && IsSpaceToEOL(i+2, styler)) + levelNext --; + } + // keyword + if(style == SCE_MATLAB_KEYWORD) { + word[wordlen++] = static_cast(LowerCase(ch)); + if (wordlen == 100) { // prevent overflow + word[0] = '\0'; + wordlen = 1; + } + if (styleNext != SCE_MATLAB_KEYWORD) { + word[wordlen] = '\0'; + wordlen = 0; + + levelNext += CheckKeywordFoldPoint(word); + } + } + if (!IsASpace(ch)) + visibleChars++; + if (atEOL || (i == endPos-1)) { + int levelUse = levelCurrent; + int lev = levelUse | levelNext << 16; + if (visibleChars == 0) + lev |= SC_FOLDLEVELWHITEFLAG; + if (levelUse < levelNext) + lev |= SC_FOLDLEVELHEADERFLAG; + if (lev != styler.LevelAt(lineCurrent)) { + styler.SetLevel(lineCurrent, lev); + } + lineCurrent++; + levelCurrent = levelNext; + if (atEOL && (i == static_cast(styler.Length() - 1))) { + // There is an empty line at end of file so give it same level and empty + styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG); + } + visibleChars = 0; + } + } } static void FoldMatlabDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { - FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabCommentChar); + FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabCommentChar); } static void FoldOctaveDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[], Accessor &styler) { - FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveCommentChar); + FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveCommentChar); } static const char * const matlabWordListDesc[] = { - "Keywords", - 0 + "Keywords", + 0 }; static const char * const octaveWordListDesc[] = { - "Keywords", - 0 + "Keywords", + 0 }; LexerModule lmMatlab(SCLEX_MATLAB, ColouriseMatlabDoc, "matlab", FoldMatlabDoc, matlabWordListDesc); diff --git a/src/Helpers.c b/src/Helpers.c index 967f6cb6..f92492bf 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -1166,8 +1166,11 @@ void PathAbsoluteFromApp(LPWSTR lpszSrc, LPWSTR lpszDest, int cchDest, BOOL bExp SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, wchPath); PathAppend(wchPath, lpszSrc + CSTRLEN("%CSIDL:MYDOCUMENTS%")); } - else - (void)StringCchCopy(wchPath, COUNTOF(wchPath), lpszSrc); + else { + if (lpszSrc) { + (void)StringCchCopy(wchPath, COUNTOF(wchPath), lpszSrc); + } + } if (bExpandEnv) ExpandEnvironmentStringsEx(wchPath, COUNTOF(wchPath)); diff --git a/src/Helpers.h b/src/Helpers.h index 8ac08dea..f8520157 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -27,7 +27,6 @@ extern HINSTANCE g_hInstance; #define COUNTOF(ar) ARRAYSIZE(ar) //#define COUNTOF(ar) (sizeof(ar)/sizeof(ar[0])) #define CSTRLEN(s) (COUNTOF(s)-1) - extern WCHAR szIniFile[MAX_PATH]; #define IniGetString(lpSection,lpName,lpDefault,lpReturnedStr,nSize) \ GetPrivateProfileString(lpSection,lpName,lpDefault,lpReturnedStr,nSize,szIniFile) diff --git a/src/Notepad2.rc b/src/Notepad2.rc index 7f74000c..f5426751 100644 --- a/src/Notepad2.rc +++ b/src/Notepad2.rc @@ -280,7 +280,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Zoom &In\tCtrl++", IDM_VIEW_ZOOMIN MENUITEM "Zoom &Out\tCtrl+-", IDM_VIEW_ZOOMOUT - MENUITEM "Reset &Zoom\tCtrl+/", IDM_VIEW_RESETZOOM + MENUITEM "Reset &Zoom\tCtrl+0", IDM_VIEW_RESETZOOM END POPUP "&Settings" BEGIN @@ -296,7 +296,7 @@ BEGIN MENUITEM "Sticky Window &Position", IDM_VIEW_STICKYWINPOS MENUITEM "&Always On Top\tAlt+T", IDM_VIEW_ALWAYSONTOP MENUITEM "Minimi&ze To Tray", IDM_VIEW_MINTOTRAY - MENUITEM "Transparent &Mode\tCtrl+0", IDM_VIEW_TRANSPARENT + MENUITEM "Transparent &Mode\tCtrl+Numpad_*", IDM_VIEW_TRANSPARENT MENUITEM SEPARATOR MENUITEM "Single &File Instance", IDM_VIEW_SINGLEFILEINSTANCE MENUITEM "File &Change Notification...\tAlt+F5", IDM_VIEW_CHANGENOTIFY @@ -366,7 +366,7 @@ END IDR_MAINWND ACCELERATORS BEGIN - "0", IDM_VIEW_TRANSPARENT, VIRTKEY, CONTROL, NOINVERT + "0", IDM_VIEW_RESETZOOM, VIRTKEY, CONTROL, NOINVERT "0", IDM_FILE_NEWWINDOW2, VIRTKEY, ALT, NOINVERT "0", IDM_VIEW_WORDWRAPSYMBOLS, VIRTKEY, SHIFT, CONTROL, NOINVERT "1", CMD_STRINGIFY, VIRTKEY, CONTROL, NOINVERT @@ -459,7 +459,6 @@ BEGIN VK_DELETE, CMD_CTRLDEL, VIRTKEY, CONTROL, NOINVERT VK_DELETE, IDM_EDIT_CUT, VIRTKEY, SHIFT, NOINVERT VK_DELETE, IDM_EDIT_DELETELINERIGHT, VIRTKEY, SHIFT, CONTROL, NOINVERT - VK_DIVIDE, IDM_VIEW_RESETZOOM, VIRTKEY, CONTROL, NOINVERT VK_DOWN, IDM_EDIT_MOVELINEDOWN, VIRTKEY, SHIFT, CONTROL, NOINVERT VK_ESCAPE, CMD_ESCAPE, VIRTKEY, NOINVERT VK_ESCAPE, CMD_SHIFTESC, VIRTKEY, SHIFT, NOINVERT @@ -506,7 +505,12 @@ BEGIN VK_F9, IDM_FILE_MANAGEFAV, VIRTKEY, ALT, NOINVERT VK_F9, CMD_COPYPATHNAME, VIRTKEY, SHIFT, NOINVERT VK_F9, IDM_EDIT_INSERT_PATHNAME, VIRTKEY, SHIFT, CONTROL, NOINVERT - VK_OEM_2, IDM_VIEW_RESETZOOM, VIRTKEY, CONTROL, NOINVERT + VK_OEM_2, IDM_EDIT_LINECOMMENT, VIRTKEY, CONTROL, NOINVERT + VK_OEM_2, IDM_EDIT_STREAMCOMMENT, VIRTKEY, SHIFT, CONTROL, NOINVERT + VK_DIVIDE, IDM_EDIT_LINECOMMENT, VIRTKEY, CONTROL, NOINVERT + VK_DIVIDE, IDM_EDIT_STREAMCOMMENT, VIRTKEY, SHIFT, CONTROL, NOINVERT + VK_NUMPAD0, IDM_VIEW_RESETZOOM, VIRTKEY, CONTROL, NOINVERT + VK_MULTIPLY, IDM_VIEW_TRANSPARENT, VIRTKEY, CONTROL, NOINVERT VK_OEM_COMMA, CMD_JUMP2SELSTART, VIRTKEY, CONTROL, NOINVERT VK_OEM_MINUS, IDM_VIEW_ZOOMOUT, VIRTKEY, CONTROL, NOINVERT VK_OEM_MINUS, CMD_DECREASENUM, VIRTKEY, CONTROL, ALT, NOINVERT diff --git a/src/Styles.c b/src/Styles.c index be63491a..23434b2e 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -2604,6 +2604,8 @@ EDITLEXER lexMATLAB = { SCLEX_MATLAB, 63360, L"MATLAB", L"matlab", L"", &KeyWord // This array holds all the lexers... // Don't forget to change the number of the lexer for HTML and XML // in Notepad2.c ParseCommandLine() if you change this array! +// and set #define NUMLEXERS XX in header to correct number +// PEDITLEXER pLexArray[NUMLEXERS] = { &lexDefault, @@ -2722,7 +2724,7 @@ void Style_Load() // default scheme iDefaultLexer = IniSectionGetInt(pIniSection, L"DefaultScheme", 0); - iDefaultLexer = min(max(iDefaultLexer, 0), NUMLEXERS - 1); + iDefaultLexer = min(max(iDefaultLexer, 0), COUNTOF(pLexArray) - 1); // auto select bAutoSelect = (IniSectionGetInt(pIniSection, L"AutoSelect", 1)) ? 1 : 0; @@ -2734,7 +2736,7 @@ void Style_Load() cyStyleSelectDlg = IniSectionGetInt(pIniSection, L"SelectDlgSizeY", 0); cyStyleSelectDlg = max(cyStyleSelectDlg, 324); - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) + for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) { if (LoadIniSection(pLexArray[iLexer]->pszName, pIniSection, cchIniSection) > 2L) { @@ -2803,7 +2805,7 @@ void Style_Save() return; } - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) + for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) { ZeroMemory(pIniSection, SizeOfMem(pIniSection)); IniSectionSetString(pIniSection, L"FileNameExtensions", pLexArray[iLexer]->szExtensions); @@ -2852,7 +2854,7 @@ BOOL Style_Import(HWND hwnd) int cchIniSection = (int)SizeOfMem(pIniSection) / sizeof(WCHAR); - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) + for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) { if (GetPrivateProfileSection(pLexArray[iLexer]->pszName, pIniSection, cchIniSection, szFile)) { @@ -2908,7 +2910,7 @@ BOOL Style_Export(HWND hwnd) return FALSE; //int cchIniSection = (int)SizeOfMem(pIniSection) / sizeof(WCHAR); - for (int iLexer = 0; iLexer < NUMLEXERS; iLexer++) + for (int iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) { IniSectionSetString(pIniSection, L"FileNameExtensions", pLexArray[iLexer]->szExtensions); int i = 0; @@ -3488,7 +3490,7 @@ PEDITLEXER __fastcall Style_MatchLexer(LPCWSTR lpszMatch, BOOL bCheckNames) if (!bCheckNames) { - for (i = 0; i < NUMLEXERS; i++) + for (i = 0; i < COUNTOF(pLexArray); i++) { ZeroMemory(tch, sizeof(tch)); StringCchCopy(tch, 256 + 16, pLexArray[i]->szExtensions); @@ -3515,7 +3517,7 @@ PEDITLEXER __fastcall Style_MatchLexer(LPCWSTR lpszMatch, BOOL bCheckNames) if (cch >= 3) { - for (i = 0; i < NUMLEXERS; i++) + for (i = 0; i < COUNTOF(pLexArray); i++) { if (StrCmpNI(pLexArray[i]->pszName, lpszMatch, cch) == 0) return(pLexArray[i]); @@ -3719,7 +3721,7 @@ void Style_SetXMLLexer(HWND hwnd) // void Style_SetLexerFromID(HWND hwnd, int id) { - if (id >= 0 && id < NUMLEXERS) + if (id >= 0 && id < COUNTOF(pLexArray)) { Style_SetLexer(hwnd, pLexArray[id]); } @@ -4568,7 +4570,7 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM SHGFI_SMALLICON | SHGFI_SYSICONINDEX), TVSIL_NORMAL); // Add lexers - for (i = 0; i < NUMLEXERS; i++) + for (i = 0; i < COUNTOF(pLexArray); i++) { if (!found && lstrcmp(pLexArray[i]->pszName, pLexCurrent->pszName) == 0) { @@ -5091,7 +5093,7 @@ void Style_ConfigDlg(HWND hwnd) // Backup Styles c = 0; - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) + for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) { StyleBackup[c++] = StrDup(pLexArray[iLexer]->szExtensions); i = 0; @@ -5110,7 +5112,7 @@ void Style_ConfigDlg(HWND hwnd) { // Restore Styles c = 0; - for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) + for (iLexer = 0; iLexer < COUNTOF(pLexArray); iLexer++) { StringCchCopy(pLexArray[iLexer]->szExtensions, 128, StyleBackup[c++]); i = 0; @@ -5214,7 +5216,7 @@ INT_PTR CALLBACK Style_SelectLexerDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, L ListView_InsertColumn(hwndLV, 0, &lvc); // Add lexers - for (i = 0; i < NUMLEXERS; i++) + for (i = 0; i < COUNTOF(pLexArray); i++) Style_AddLexerToListView(hwndLV, pLexArray[i]); ListView_SetColumnWidth(hwndLV, 0, LVSCW_AUTOSIZE_USEHEADER);