Add JSON language support; Add auto-detection for xml, php and bash.
parent
11b49e6ad5
commit
46e810aa53
|
@ -39,7 +39,7 @@ enum LangType {L_TEXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\
|
|||
L_ASM, L_DIFF, L_PROPS, L_PS, L_RUBY, L_SMALLTALK, L_VHDL, L_KIX, L_AU3,\
|
||||
L_CAML, L_ADA, L_VERILOG, L_MATLAB, L_HASKELL, L_INNO, L_SEARCHRESULT,\
|
||||
L_CMAKE, L_YAML, L_COBOL, L_GUI4CLI, L_D, L_POWERSHELL, L_R, L_JSP,\
|
||||
L_COFFEESCRIPT,\
|
||||
L_COFFEESCRIPT, L_JSON,\
|
||||
// The end of enumated language type, so it should be always at the end
|
||||
L_EXTERNAL};
|
||||
enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV_S2003, WV_XPX64, WV_VISTA, WV_WIN7, WV_WIN8, WV_WIN81};
|
||||
|
|
|
@ -2573,6 +2573,8 @@ enum LangType Notepad_plus::menuID2LangType(int cmdID)
|
|||
return L_XML;
|
||||
case IDM_LANG_JS :
|
||||
return L_JS;
|
||||
case IDM_LANG_JSON:
|
||||
return L_JSON;
|
||||
case IDM_LANG_PHP :
|
||||
return L_PHP;
|
||||
case IDM_LANG_ASP :
|
||||
|
|
|
@ -668,6 +668,7 @@ BEGIN
|
|||
MENUITEM "INNO", IDM_LANG_INNO
|
||||
MENUITEM "Java", IDM_LANG_JAVA
|
||||
MENUITEM "Javascript", IDM_LANG_JS
|
||||
MENUITEM "JSON", IDM_LANG_JSON
|
||||
MENUITEM "JSP", IDM_LANG_JSP
|
||||
MENUITEM "KIXtart", IDM_LANG_KIX
|
||||
MENUITEM "LISP", IDM_LANG_LISP
|
||||
|
@ -747,6 +748,7 @@ BEGIN
|
|||
BEGIN
|
||||
MENUITEM "Java", IDM_LANG_JAVA
|
||||
MENUITEM "Javascript", IDM_LANG_JS
|
||||
MENUITEM "JSON", IDM_LANG_JSON
|
||||
MENUITEM "JSP", IDM_LANG_JSP
|
||||
END
|
||||
MENUITEM "KIXtart", IDM_LANG_KIX
|
||||
|
|
|
@ -2377,6 +2377,7 @@ void Notepad_plus::command(int id)
|
|||
case IDM_LANG_HTML :
|
||||
case IDM_LANG_XML :
|
||||
case IDM_LANG_JS :
|
||||
case IDM_LANG_JSON :
|
||||
case IDM_LANG_PHP :
|
||||
case IDM_LANG_ASP :
|
||||
case IDM_LANG_CSS :
|
||||
|
|
|
@ -3444,9 +3444,11 @@ TiXmlNode * NppParameters::getChildElementByAttribut(TiXmlNode *pere, const TCHA
|
|||
LangType NppParameters::getLangIDFromStr(const TCHAR *langName)
|
||||
{
|
||||
int lang = (int)L_TEXT;
|
||||
for(; lang < L_EXTERNAL; ++lang) {
|
||||
for(; lang < L_EXTERNAL; ++lang)
|
||||
{
|
||||
const TCHAR * name = ScintillaEditView::langNames[lang].lexerName;
|
||||
if (!lstrcmp(name, langName)) { //found lang?
|
||||
if (!lstrcmp(name, langName)) //found lang?
|
||||
{
|
||||
return (LangType)lang;
|
||||
}
|
||||
}
|
||||
|
@ -3454,7 +3456,8 @@ LangType NppParameters::getLangIDFromStr(const TCHAR *langName)
|
|||
//Cannot find language, check if its an external one
|
||||
|
||||
LangType l = (LangType)lang;
|
||||
if (l == L_EXTERNAL) { //try find external lexer
|
||||
if (l == L_EXTERNAL) //try find external lexer
|
||||
{
|
||||
int id = _pSelf->getExternalLangIndexFromName(langName);
|
||||
if (id != -1) return (LangType)(id + L_EXTERNAL);
|
||||
}
|
||||
|
@ -5887,6 +5890,8 @@ int NppParameters::langTypeToCommandID(LangType lt) const
|
|||
id = IDM_LANG_XML; break;
|
||||
case L_JS :
|
||||
id = IDM_LANG_JS; break;
|
||||
case L_JSON:
|
||||
id = IDM_LANG_JSON; break;
|
||||
case L_PHP :
|
||||
id = IDM_LANG_PHP; break;
|
||||
case L_ASP :
|
||||
|
|
|
@ -76,14 +76,15 @@ const int ScintillaEditView::_markersArray[][NB_FOLDER_STATE] = {
|
|||
{SC_MARK_BOXMINUS, SC_MARK_BOXPLUS, SC_MARK_VLINE, SC_MARK_LCORNER, SC_MARK_BOXPLUSCONNECTED, SC_MARK_BOXMINUSCONNECTED, SC_MARK_TCORNER}
|
||||
};
|
||||
|
||||
//Array with all the names of all languages
|
||||
// Array with all the names of all languages
|
||||
// The order of lang type (enum LangType) must be respected
|
||||
LanguageName ScintillaEditView::langNames[L_EXTERNAL+1] = {
|
||||
{TEXT("normal"), TEXT("Normal text"), TEXT("Normal text file"), L_TEXT, SCLEX_NULL},
|
||||
{TEXT("php"), TEXT("PHP"), TEXT("PHP Hypertext Preprocessor file"), L_PHP, SCLEX_HTML},
|
||||
{TEXT("c"), TEXT("C"), TEXT("C source file"), L_C, SCLEX_CPP},
|
||||
{TEXT("cpp"), TEXT("C++"), TEXT("C++ source file"), L_CPP, SCLEX_CPP},
|
||||
{TEXT("cs"), TEXT("C#"), TEXT("C# source file"), L_CS, SCLEX_CPP},
|
||||
{TEXT("objc"), TEXT("Objective-C"), TEXT("Objective-C source file"), L_OBJC, SCLEX_CPP},
|
||||
{TEXT("objc"), TEXT("Objective-C"), TEXT("Objective-C source file"), L_OBJC, SCLEX_CPP},
|
||||
{TEXT("java"), TEXT("Java"), TEXT("Java source file"), L_JAVA, SCLEX_CPP},
|
||||
{TEXT("rc"), TEXT("RC"), TEXT("Windows Resource file"), L_RC, SCLEX_CPP},
|
||||
{TEXT("html"), TEXT("HTML"), TEXT("Hyper Text Markup Language file"), L_HTML, SCLEX_HTML},
|
||||
|
@ -135,6 +136,7 @@ LanguageName ScintillaEditView::langNames[L_EXTERNAL+1] = {
|
|||
{TEXT("r"), TEXT("R"), TEXT("R programming language"), L_R, SCLEX_R},
|
||||
{TEXT("jsp"), TEXT("JSP"), TEXT("JavaServer Pages script file"), L_JSP, SCLEX_HTML},
|
||||
{TEXT("coffeescript"), TEXT("CoffeeScript"), TEXT("CoffeeScript file"), L_COFFEESCRIPT, SCLEX_COFFEESCRIPT},
|
||||
{ TEXT("json"), TEXT("json"), TEXT("JSON file"), L_JSON, SCLEX_CPP },
|
||||
{TEXT("ext"), TEXT("External"), TEXT("External"), L_EXTERNAL, SCLEX_NULL}
|
||||
};
|
||||
|
||||
|
@ -490,28 +492,35 @@ void ScintillaEditView::setStyle(Style styleToSet)
|
|||
{
|
||||
Style & style = stylers.getStyler(i);
|
||||
|
||||
if (go.enableFg) {
|
||||
if (style._colorStyle & COLORSTYLE_FOREGROUND) {
|
||||
if (go.enableFg)
|
||||
{
|
||||
if (style._colorStyle & COLORSTYLE_FOREGROUND)
|
||||
{
|
||||
styleToSet._colorStyle |= COLORSTYLE_FOREGROUND;
|
||||
styleToSet._fgColor = style._fgColor;
|
||||
} else {
|
||||
if (styleToSet._styleID == STYLE_DEFAULT) { //if global is set to transparent, use default style color
|
||||
}
|
||||
else
|
||||
{
|
||||
if (styleToSet._styleID == STYLE_DEFAULT) //if global is set to transparent, use default style color
|
||||
styleToSet._colorStyle |= COLORSTYLE_FOREGROUND;
|
||||
} else {
|
||||
else
|
||||
styleToSet._colorStyle &= ~COLORSTYLE_FOREGROUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (go.enableBg) {
|
||||
if (style._colorStyle & COLORSTYLE_BACKGROUND) {
|
||||
|
||||
if (go.enableBg)
|
||||
{
|
||||
if (style._colorStyle & COLORSTYLE_BACKGROUND)
|
||||
{
|
||||
styleToSet._colorStyle |= COLORSTYLE_BACKGROUND;
|
||||
styleToSet._bgColor = style._bgColor;
|
||||
} else {
|
||||
if (styleToSet._styleID == STYLE_DEFAULT) { //if global is set to transparent, use default style color
|
||||
}
|
||||
else
|
||||
{
|
||||
if (styleToSet._styleID == STYLE_DEFAULT) //if global is set to transparent, use default style color
|
||||
styleToSet._colorStyle |= COLORSTYLE_BACKGROUND;
|
||||
} else {
|
||||
else
|
||||
styleToSet._colorStyle &= ~COLORSTYLE_BACKGROUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (go.enableFont && style._fontName && style._fontName[0])
|
||||
|
@ -598,6 +607,21 @@ void ScintillaEditView::setEmbeddedJSLexer()
|
|||
execute(SCI_STYLESETEOLFILLED, SCE_HJ_COMMENTDOC, true);
|
||||
}
|
||||
|
||||
void ScintillaEditView::setJsonLexer()
|
||||
{
|
||||
execute(SCI_SETLEXER, SCLEX_CPP);
|
||||
|
||||
const TCHAR *pKwArray[10] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
|
||||
|
||||
makeStyle(L_JSON, pKwArray);
|
||||
|
||||
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold"), reinterpret_cast<LPARAM>("1"));
|
||||
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.compact"), reinterpret_cast<LPARAM>("0"));
|
||||
|
||||
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.comment"), reinterpret_cast<LPARAM>("1"));
|
||||
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.preprocessor"), reinterpret_cast<LPARAM>("1"));
|
||||
}
|
||||
|
||||
void ScintillaEditView::setEmbeddedPhpLexer()
|
||||
{
|
||||
const TCHAR *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
|
||||
|
@ -1215,6 +1239,9 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
|
|||
case L_XML :
|
||||
setXmlLexer(typeDoc); break;
|
||||
|
||||
case L_JSON:
|
||||
setJsonLexer(); break;
|
||||
|
||||
case L_CSS :
|
||||
setCssLexer(); break;
|
||||
|
||||
|
|
|
@ -699,6 +699,7 @@ protected:
|
|||
void setEmbeddedJSLexer();
|
||||
void setEmbeddedPhpLexer();
|
||||
void setEmbeddedAspLexer();
|
||||
void setJsonLexer();
|
||||
//Simple lexers
|
||||
void setCssLexer() {
|
||||
setLexer(SCLEX_CSS, L_CSS, LIST_0 | LIST_1);
|
||||
|
|
|
@ -110,9 +110,10 @@
|
|||
<Keywords name="instre1">instanceof assert if else switch case default break goto return for while do continue new throw throws try catch finally this super extends implements import true false null</Keywords>
|
||||
<Keywords name="type1">package transient strictfp void char short int long double float const static volatile byte boolean class interface native private protected public final abstract synchronized enum</Keywords>
|
||||
</Language>
|
||||
<Language name="javascript" ext="js jsm json" commentLine="//" commentStart="/*" commentEnd="*/">
|
||||
<Language name="javascript" ext="js jsm" commentLine="//" commentStart="/*" commentEnd="*/">
|
||||
<Keywords name="instre1">abstract boolean break byte case catch char class const continue debugger default delete do double else enum export extends final finally float for from function goto if implements import in instanceof int interface let long native new of package private protected public return short static super switch synchronized this throw throws transient try typeof var void volatile while with true false prototype</Keywords>
|
||||
</Language>
|
||||
<Language name="json" ext="json" commentLine="" commentStart="" commentEnd=""/>
|
||||
<Language name="jsp" ext="jsp" commentLine="//" commentStart="/*" commentEnd="*/"/>
|
||||
<Language name="kix" ext="kix" commentLine=";" commentStart="" commentEnd="">
|
||||
<Keywords name="instre1">? and beep big break call cd cls color cookie1 copy debug del dim display do until exit flushkb for each next function endfunction get gets global go gosub goto if else endif md or password play quit rd redim return run select case endselect set setl setm settime shell sleep small use while loop</Keywords>
|
||||
|
|
|
@ -464,6 +464,7 @@
|
|||
#define IDM_LANG_R (IDM_LANG + 54)
|
||||
#define IDM_LANG_JSP (IDM_LANG + 55)
|
||||
#define IDM_LANG_COFFEESCRIPT (IDM_LANG + 56)
|
||||
#define IDM_LANG_JSON (IDM_LANG + 57)
|
||||
|
||||
#define IDM_LANG_EXTERNAL (IDM_LANG + 65)
|
||||
#define IDM_LANG_EXTERNAL_LIMIT (IDM_LANG + 79)
|
||||
|
|
|
@ -393,6 +393,13 @@
|
|||
<WordsStyle name="COMMENTLINE" styleID="43" fgColor="008000" bgColor="F2F4FF" fontName="" fontStyle="0" fontSize="" />
|
||||
<WordsStyle name="COMMENTDOC" styleID="44" fgColor="008080" bgColor="F2F4FF" fontName="" fontStyle="0" fontSize="" />
|
||||
</LexerType>
|
||||
<LexerType name="json" desc="JSON" ext="">
|
||||
<WordsStyle name="DEFAULT" styleID="11" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
|
||||
<WordsStyle name="NUMBER" styleID="4" fgColor="FF8000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
|
||||
<WordsStyle name="STRING" styleID="6" fgColor="373737" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
|
||||
<WordsStyle name="CHARACTER" styleID="7" fgColor="808080" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
|
||||
<WordsStyle name="OPERATOR" styleID="10" fgColor="8000FF" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="" />
|
||||
</LexerType>
|
||||
<LexerType name="kix" desc="KiXtart" ext="">
|
||||
<WordsStyle name="DEFAULT" styleID="31" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
|
||||
<WordsStyle name="COMMENT" styleID="1" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="" />
|
||||
|
|
Loading…
Reference in New Issue