From ce398e21ad6e072a2dabeadd82ac634941672837 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 1 Feb 2013 12:51:30 +0200 Subject: [PATCH] Add support for Matlab. --- Readme-mod.txt | 2 +- Readme.md | 2 +- build/makefile.deps.mak | 1 + build/makefile.mak | 1 + lexlink.js | 1 + scintilla/Scintilla.vcxproj | 1 + scintilla/Scintilla.vcxproj.filters | 3 +++ scintilla/src/Catalogue.cxx | 2 +- src/Notepad2.c | 8 ++++++-- src/Styles.c | 22 ++++++++++++++++++++++ 10 files changed, 38 insertions(+), 5 deletions(-) diff --git a/Readme-mod.txt b/Readme-mod.txt index 2a5174b3..9cd97350 100644 --- a/Readme-mod.txt +++ b/Readme-mod.txt @@ -7,7 +7,7 @@ Notable changes: * Option to mark all occurrences of a word * Word auto-completion * Syntax highlighting support for AutoHotkey, AutoIt3, AviSynth, Bash, - CMake, Inno Setup, LaTeX, Lua, Markdown, NSIS, Ruby, Tcl, YAML and VHDL scripts + CMake, Inno Setup, LaTeX, Lua, Markdown, MATLAB, NSIS, Ruby, Tcl, YAML and VHDL scripts * Improved support for NFO ANSI art * Support for replacing Windows Notepad using a clean, unintrusive registry-based method * Other various minor changes and tweaks diff --git a/Readme.md b/Readme.md index fa3d075f..0f365db3 100644 --- a/Readme.md +++ b/Readme.md @@ -9,7 +9,7 @@ _A modified version (fork) of Notepad2 based on Kai Liu's and other people's pat * Option to mark all occurrences of a word * Word auto-completion * Syntax highlighting support for AutoHotkey, AutoIt3, AviSynth, Bash, CMake, Inno Setup, - LaTeX, Lua, Markdown, NSIS, Ruby, Tcl, YAML and VHDL scripts + LaTeX, Lua, Markdown, MATLAB, NSIS, Ruby, Tcl, YAML and VHDL scripts * Improved support for NFO ANSI art * Support for replacing Windows Notepad using a clean, unintrusive registry-based method * Other various minor changes and tweaks diff --git a/build/makefile.deps.mak b/build/makefile.deps.mak index 2f3d1c26..32800068 100644 --- a/build/makefile.deps.mak +++ b/build/makefile.deps.mak @@ -44,6 +44,7 @@ $(SCI_LEX_OBJDIR)\LexInno.obj: $(SCI_LEX)\LexInno.cxx $(LEX_HEADERS) $(SCI_LEX_OBJDIR)\LexLua.obj: $(SCI_LEX)\LexLaTeX.cxx $(LEX_HEADERS) $(SCI_LEX_OBJDIR)\LexLua.obj: $(SCI_LEX)\LexLua.cxx $(LEX_HEADERS) $(SCI_LEX_OBJDIR)\LexMarkdown.obj: $(SCI_LEX)\LexMarkdown.cxx $(LEX_HEADERS) +$(SCI_LEX_OBJDIR)\LexMatlab.obj: $(SCI_LEX)\LexMatlab.cxx $(LEX_HEADERS) $(SCI_LEX_OBJDIR)\LexNsis.obj: $(SCI_LEX)\LexNsis.cxx $(LEX_HEADERS) $(SCI_LEX_OBJDIR)\LexOthers.obj: $(SCI_LEX)\LexOthers.cxx $(LEX_HEADERS) $(SCI_LEX_OBJDIR)\LexPascal.obj: $(SCI_LEX)\LexPascal.cxx $(LEX_HEADERS) diff --git a/build/makefile.mak b/build/makefile.mak index aa03b58d..680bd385 100644 --- a/build/makefile.mak +++ b/build/makefile.mak @@ -136,6 +136,7 @@ SCI_LEX_OBJ = \ $(SCI_LEX_OBJDIR)\LexLaTeX.obj \ $(SCI_LEX_OBJDIR)\LexLua.obj \ $(SCI_LEX_OBJDIR)\LexMarkdown.obj \ + $(SCI_LEX_OBJDIR)\LexMatlab.obj \ $(SCI_LEX_OBJDIR)\LexNsis.obj \ $(SCI_LEX_OBJDIR)\LexOthers.obj \ $(SCI_LEX_OBJDIR)\LexPascal.obj \ diff --git a/lexlink.js b/lexlink.js index 681b9e2c..fdb11464 100644 --- a/lexlink.js +++ b/lexlink.js @@ -21,6 +21,7 @@ "lmLua", "lmMake", "lmMarkdown", + "lmMatlab", "lmNsis", "lmNull", "lmPascal", diff --git a/scintilla/Scintilla.vcxproj b/scintilla/Scintilla.vcxproj index b215d4a0..ae03e946 100644 --- a/scintilla/Scintilla.vcxproj +++ b/scintilla/Scintilla.vcxproj @@ -172,6 +172,7 @@ + diff --git a/scintilla/Scintilla.vcxproj.filters b/scintilla/Scintilla.vcxproj.filters index 2fd1bcb1..73489e0a 100644 --- a/scintilla/Scintilla.vcxproj.filters +++ b/scintilla/Scintilla.vcxproj.filters @@ -60,6 +60,9 @@ lexers + + lexers + lexers diff --git a/scintilla/src/Catalogue.cxx b/scintilla/src/Catalogue.cxx index 2d556cc5..b5a272e6 100644 --- a/scintilla/src/Catalogue.cxx +++ b/scintilla/src/Catalogue.cxx @@ -136,7 +136,7 @@ int Scintilla_LinkLexers() { //LINK_LEXER(lmMagikSF); LINK_LEXER(lmMake); LINK_LEXER(lmMarkdown); - //LINK_LEXER(lmMatlab); + LINK_LEXER(lmMatlab); //LINK_LEXER(lmMETAPOST); //LINK_LEXER(lmMMIXAL); //LINK_LEXER(lmModula); diff --git a/src/Notepad2.c b/src/Notepad2.c index aa461469..50f24c96 100644 --- a/src/Notepad2.c +++ b/src/Notepad2.c @@ -3436,6 +3436,7 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) EndWaitCursor(); break; case SCLEX_LATEX: + case SCLEX_MATLAB: BeginWaitCursor(); EditToggleLineComments(hwndEdit,L"%",TRUE); EndWaitCursor(); @@ -3484,6 +3485,9 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam) break; case SCLEX_LUA: EditEncloseSelection(hwndEdit,L"--[[",L"]]"); + break; + case SCLEX_MATLAB: + EditEncloseSelection(hwndEdit,L"%{",L"%}"); } break; @@ -6244,7 +6248,7 @@ void ParseCommandLine() LocalFree(lpSchemeArg); lpSchemeArg = NULL; } - iInitialLexer = 33; + iInitialLexer = 34; flagLexerSpecified = 1; break; @@ -6253,7 +6257,7 @@ void ParseCommandLine() LocalFree(lpSchemeArg); lpSchemeArg = NULL; } - iInitialLexer = 34; + iInitialLexer = 35; flagLexerSpecified = 1; break; diff --git a/src/Styles.c b/src/Styles.c index 33c29144..a43e1c46 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -2395,6 +2395,7 @@ EDITLEXER lexYAML = { SCLEX_YAML, 63355, L"YAML", L"yaml; yml", L"", &KeyWords_Y { SCE_YAML_OPERATOR, 63132, L"Operator", L"fore:#333366", L"" }, { -1, 00000, L"", L"", L"" } } }; + KEYWORDLIST KeyWords_VHDL = { "access after alias all architecture array assert attribute begin block body buffer bus case component configuration " "constant disconnect downto else elsif end entity exit file for function generate generic group guarded if impure in " @@ -2428,6 +2429,26 @@ EDITLEXER lexVHDL = { SCLEX_VHDL, 63370, L"VHDL", L"vhdl; vhd", L"", &KeyWords_V { SCE_VHDL_STDTYPE, 63375, L"Standard type", L"fore:#FF8000", L"" }, { -1, 00000, L"", L"", L"" } } }; + +KEYWORDLIST KeyWords_MATLAB = { +"break case catch continue else elseif end for function global if otherwise " +"persistent return switch try while", +"", "", "", "", "", "", "", "" }; + + +EDITLEXER lexMATLAB = { SCLEX_MATLAB, 63360, L"MATLAB", L"matlab", L"", &KeyWords_MATLAB, { + { STYLE_DEFAULT, 63126, L"Default", L"", L"" }, + //{ SCE_MATLAB_DEFAULT, L"Default", L"", L"" }, + { SCE_MATLAB_COMMENT, 63127, L"Comment", L"fore:#008000", L"" }, + { SCE_MATLAB_COMMAND, 63236, L"Command", L"bold", L"" }, + { SCE_MATLAB_NUMBER, 63130, L"Number", L"fore:#FF8000", L"" }, + { SCE_MATLAB_KEYWORD, 63128, L"Keyword", L"fore:#00007F; bold", L"" }, + { MULTI_STYLE(SCE_MATLAB_STRING,SCE_MATLAB_DOUBLEQUOTESTRING,0,0), 63131, L"String", L"fore:#7F007F", L"" }, + { SCE_MATLAB_OPERATOR, 63132, L"Operator", L"", L"" }, + { SCE_MATLAB_IDENTIFIER, 63129, L"Identifier", L"", L"" }, + { -1, 00000, L"", L"", L"" } } }; + + // 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! @@ -2452,6 +2473,7 @@ PEDITLEXER pLexArray[NUMLEXERS] = &lexJS, &lexMAK, &lexMARKDOWN, + &lexMATLAB, &lexLATEX, &lexLUA, &lexNSIS,