mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
ide: Javascript syntax highlighting
git-svn-id: svn://ultimatepp.org/upp/trunk@5063 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
52fc30693f
commit
0257c6fe8b
4 changed files with 77 additions and 44 deletions
|
|
@ -179,7 +179,7 @@ public:
|
|||
|
||||
enum {
|
||||
HIGHLIGHT_NONE = -1, HIGHLIGHT_CPP = 0, HIGHLIGHT_USC, HIGHLIGHT_JAVA, HIGHLIGHT_T,
|
||||
HIGHLIGHT_CALC, HIGHLIGHT_LAY, HIGHLIGHT_SCH, HIGHLIGHT_SQL,
|
||||
HIGHLIGHT_CALC, HIGHLIGHT_LAY, HIGHLIGHT_SCH, HIGHLIGHT_SQL, HIGHLIGHT_JAVASCRIPT,
|
||||
HIGHLIGHT_COUNT
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -320,6 +320,14 @@ void CodeEditor::InitKeywords()
|
|||
"true", "try", "void", "volatile", "while",
|
||||
NULL
|
||||
};
|
||||
static const char *javascript[] = {
|
||||
"break", "continue", "do", "for", "import", "new", "this", "void",
|
||||
"case", "default", "else", "function", "in", "return", "typeof", "while",
|
||||
"comment", "delete", "export", "if", "label", "switch", "var", "with",
|
||||
"catch", "enum", "throw", "class", "extends", "try", "const", "finally",
|
||||
"debugger", "super",
|
||||
NULL
|
||||
};
|
||||
static const char *upp_macros[] = {
|
||||
"CLASSNAME", "THISBACK", "THISBACK1", "THISBACK2", "THISBACK3", "THISBACK4",
|
||||
"PTEBACK", "PTEBACK1", "PTEBACK2", "PTEBACK3", "PTEBACK4",
|
||||
|
|
@ -418,11 +426,39 @@ void CodeEditor::InitKeywords()
|
|||
static const char *javan[] = {
|
||||
NULL
|
||||
};
|
||||
static const char *javascriptn[] = {
|
||||
"alert", "eval", "Link", "outerHeight", "scrollTo",
|
||||
"Anchor", "FileUpload", "location", "outerWidth", "Select",
|
||||
"Area", "find", "Location", "Packages", "self",
|
||||
"arguments", "focus", "locationbar", "pageXoffset", "setInterval",
|
||||
"Array", "Form", "Math", "pageYoffset", "setTimeout",
|
||||
"assign", "Frame", "menubar", "parent", "status",
|
||||
"blur", "frames", "MimeType", "parseFloat", "statusbar",
|
||||
"Boolean", "Function", "moveBy", "parseInt", "stop",
|
||||
"Button", "getClass", "moveTo", "Password", "String",
|
||||
"callee", "Hidden", "name", "personalbar", "Submit",
|
||||
"caller", "history", "NaN", "Plugin", "sun",
|
||||
"captureEvents", "History", "navigate", "print", "taint",
|
||||
"Checkbox", "home", "navigator", "prompt", "Text",
|
||||
"clearInterval", "Image", "Navigator", "prototype", "Textarea",
|
||||
"clearTimeout", "Infinity", "netscape", "Radio", "toolbar",
|
||||
"close", "innerHeight", "Number", "ref", "top",
|
||||
"closed", "innerWidth", "Object", "RegExp", "toString",
|
||||
"confirm", "isFinite", "onBlur", "releaseEvents", "unescape",
|
||||
"constructor", "isNan", "onError", "Reset", "untaint",
|
||||
"Date", "java", "onFocus", "resizeBy", "unwatch",
|
||||
"defaultStatus", "JavaArray", "onLoad", "resizeTo", "valueOf",
|
||||
"document", "JavaClass", "onUnload", "routeEvent", "watch",
|
||||
"Document", "JavaObject", "open", "scroll", "window",
|
||||
"Element", "JavaPackage", "opener", "scrollbars", "Window",
|
||||
"escape", "length", "Option", "scrollBy",
|
||||
NULL
|
||||
};
|
||||
static const char **kw[HIGHLIGHT_COUNT] = {
|
||||
cpp, usc, java, tfile, usc, lay, sch, sql
|
||||
cpp, usc, java, tfile, usc, lay, sch, sql, javascript
|
||||
};
|
||||
static const char **nm[HIGHLIGHT_COUNT] = {
|
||||
upp, usclib, javan, tlng, usclib, javan, javan, javan
|
||||
upp, usclib, javan, tlng, usclib, javan, javan, javan, javascriptn
|
||||
};
|
||||
const char **q = NULL;
|
||||
for(int i = 0; i < HIGHLIGHT_COUNT; i++) {
|
||||
|
|
@ -491,7 +527,7 @@ void CodeEditor::HighlightLine(int line, Vector<LineEdit::Highlight>& hl, int po
|
|||
p++;
|
||||
hls.Put(hl_style[INK_NORMAL]);
|
||||
}
|
||||
if(*p == '#') {
|
||||
if(*p == '#' && highlight != HIGHLIGHT_JAVASCRIPT) {
|
||||
static const char *pd[] = {
|
||||
"define", "error", "if", "elif", "else", "endif",
|
||||
"ifdef", "ifndef", "include", "line", "undef", "pragma",
|
||||
|
|
|
|||
|
|
@ -172,4 +172,6 @@ add the following somewhere early in your application`'s execution:&]
|
|||
[s0; &]
|
||||
[s7; SetLanguage( GetSystemLNG() );&]
|
||||
[s0; &]
|
||||
[s0; ]
|
||||
[s0; In multithreaded applications this setting works on per`-thread
|
||||
basis (since release 5061); threads inherit the language setting
|
||||
of main thread on startup.]
|
||||
|
|
@ -10,44 +10,35 @@ void Ide::SetupEditor(int f, String hl, String fn)
|
|||
default: editor.SetFont(editorsplit.GetZoom() < 0 && editorsplit.IsHorz() ? veditorfont :
|
||||
ext == ".t" ? tfont : editorfont); break;
|
||||
}
|
||||
if(IsNull(hl)) {
|
||||
if(ext == ".c" || ext == ".cpp" || ext == ".cc" || ext == ".cxx" ||
|
||||
ext == ".h" || ext == ".hpp" || ext == ".hh" || ext == ".hxx" ||
|
||||
ext == ".m" || ext == ".mm" || ext == ".icpp")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_CPP);
|
||||
else
|
||||
if(ext == ".usc")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_USC);
|
||||
else
|
||||
if(ext == ".java")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_JAVA);
|
||||
else
|
||||
if(ext == ".t" || ext == ".jt")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_T);
|
||||
else
|
||||
if(ext == ".lay")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_LAY);
|
||||
else
|
||||
if(ext == ".sch")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_SCH);
|
||||
else
|
||||
if(ext == ".sql")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_SQL);
|
||||
else
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_NONE);
|
||||
}
|
||||
else {
|
||||
if(hl == "cpp")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_CPP);
|
||||
else
|
||||
if(hl == "esc")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_USC);
|
||||
else
|
||||
if(hl == "java")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_JAVA);
|
||||
else
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_NONE);
|
||||
}
|
||||
if(IsNull(hl) && *ext == '.')
|
||||
hl = ext.Mid(1);
|
||||
if(hl == "c" || hl == "cpp" || hl == "cc" || hl == "cxx" ||
|
||||
hl == "h" || hl == "hpp" || hl == "hh" || hl == "hxx" ||
|
||||
hl == "m" || hl == "mm" || hl == "icpp")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_CPP);
|
||||
else
|
||||
if(hl == "usc")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_USC);
|
||||
else
|
||||
if(hl == "java")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_JAVA);
|
||||
else
|
||||
if(hl == "js")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_JAVASCRIPT);
|
||||
else
|
||||
if(hl == "t" || hl == "jt")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_T);
|
||||
else
|
||||
if(hl == "lay")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_LAY);
|
||||
else
|
||||
if(hl == "sch")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_SCH);
|
||||
else
|
||||
if(hl == "sql")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_SQL);
|
||||
else
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_NONE);
|
||||
}
|
||||
|
||||
void Ide::SetupEditor()
|
||||
|
|
@ -131,7 +122,11 @@ void Ide::FileProperties()
|
|||
d.highlight.Add(Null, "Default");
|
||||
d.highlight.Add("cpp", "C++");
|
||||
d.highlight.Add("java", "Java");
|
||||
d.highlight.Add("esc", "Esc");
|
||||
d.highlight.Add("js", "JavaScript");
|
||||
d.highlight.Add("sql", "SQL");
|
||||
d.highlight.Add("usc", "Esc");
|
||||
d.highlight.Add("sch", "DB schema");
|
||||
d.highlight.Add("lay", "Layout");
|
||||
d.tabsize <<= f.tabsize > 0 ? f.tabsize : Null;
|
||||
d.tabsize <<= d.Breaker(111);
|
||||
d.tabsize.MinMax(1, 100);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue