mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-25 14:22:54 -06:00
ide: json highlighting improved #558
git-svn-id: svn://ultimatepp.org/upp/trunk@6565 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
99592038e0
commit
08db61d4e3
5 changed files with 23 additions and 17 deletions
|
|
@ -1208,4 +1208,3 @@ CodeEditor::CodeEditor() {
|
|||
CodeEditor::~CodeEditor() {}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ public:
|
|||
enum {
|
||||
HIGHLIGHT_NONE = -1, HIGHLIGHT_CPP = 0, HIGHLIGHT_USC, HIGHLIGHT_JAVA, HIGHLIGHT_T,
|
||||
HIGHLIGHT_CALC, HIGHLIGHT_LAY, HIGHLIGHT_SCH, HIGHLIGHT_SQL, HIGHLIGHT_CS,
|
||||
HIGHLIGHT_JAVASCRIPT, HIGHLIGHT_CSS,
|
||||
HIGHLIGHT_JAVASCRIPT, HIGHLIGHT_CSS, HIGHLIGHT_JSON,
|
||||
HIGHLIGHT_COUNT
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -497,22 +497,26 @@ void CodeEditor::InitKeywords()
|
|||
"SELECT", "TABLE",
|
||||
NULL
|
||||
};
|
||||
static const char *javan[] = {
|
||||
static const char *empty[] = {
|
||||
NULL
|
||||
};
|
||||
static const char *javascriptn[] = {
|
||||
"alert", "eval", "toString", "valueOf", "length",
|
||||
NULL
|
||||
};
|
||||
static const char **kw[HIGHLIGHT_COUNT] = {
|
||||
cpp, usc, java, tfile, usc, lay, sch, sql, cs, javascript, css,
|
||||
};
|
||||
static const char **nm[HIGHLIGHT_COUNT] = {
|
||||
upp, usclib, javan, tlng, usclib, javan, javan, javan, javan, javascriptn, cssn
|
||||
};
|
||||
|
||||
for(int i = 0; i < HIGHLIGHT_COUNT; i++)
|
||||
LoadSyntax(kw[i], nm[i]);
|
||||
LoadSyntax(cpp, upp); // Order here is important, must be the same as enum
|
||||
LoadSyntax(usc, usclib);
|
||||
LoadSyntax(java, empty);
|
||||
LoadSyntax(tfile, tlng);
|
||||
LoadSyntax(usc, usclib);
|
||||
LoadSyntax(lay, empty);
|
||||
LoadSyntax(sch, empty);
|
||||
LoadSyntax(sql, empty);
|
||||
LoadSyntax(cs, empty);
|
||||
LoadSyntax(javascript, javascriptn);
|
||||
LoadSyntax(css, cssn);
|
||||
LoadSyntax(empty, empty);
|
||||
|
||||
kw_macros = InitUpp(upp_macros);
|
||||
kw_logs = InitUpp(upp_logs);
|
||||
|
|
@ -581,7 +585,7 @@ void CodeEditor::HighlightLine(int line, Vector<LineEdit::Highlight>& hl, int po
|
|||
p++;
|
||||
hls.Put(hl_style[INK_NORMAL]);
|
||||
}
|
||||
if(*p == '#' && highlight != HIGHLIGHT_JAVASCRIPT && highlight != HIGHLIGHT_CSS) {
|
||||
if(*p == '#' && findarg(highlight, HIGHLIGHT_JAVASCRIPT, HIGHLIGHT_CSS, HIGHLIGHT_JSON) < 0) {
|
||||
static const char *pd[] = {
|
||||
"define", "error", "if", "elif", "else", "endif",
|
||||
"ifdef", "ifndef", "include", "line", "undef", "pragma",
|
||||
|
|
@ -610,13 +614,13 @@ void CodeEditor::HighlightLine(int line, Vector<LineEdit::Highlight>& hl, int po
|
|||
bool is_comment = false;
|
||||
while(p < e) {
|
||||
int pair = MAKELONG(p[0], p[1]);
|
||||
if(ss.linecomment && ss.linecont || pair == MAKELONG('/', '/') && highlight != HIGHLIGHT_CSS) {
|
||||
if(ss.linecomment && ss.linecont || pair == MAKELONG('/', '/') && highlight != HIGHLIGHT_CSS && highlight != HIGHLIGHT_JSON) {
|
||||
hls.Put(text.GetLength() + 1 - hls.pos, hl_style[INK_COMMENT]);
|
||||
is_comment = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
if(ss.comment)
|
||||
if(ss.comment && highlight != HIGHLIGHT_JSON)
|
||||
if(pair == MAKELONG('*', '/')) {
|
||||
hls.Put(2, hl_style[INK_COMMENT]);
|
||||
p += 2;
|
||||
|
|
@ -630,7 +634,7 @@ void CodeEditor::HighlightLine(int line, Vector<LineEdit::Highlight>& hl, int po
|
|||
if((*p == '\"' || *p == '\'') || ss.linecont && ss.string)
|
||||
p = HlString(hls, p);
|
||||
else
|
||||
if(pair == MAKELONG('/', '*')) {
|
||||
if(pair == MAKELONG('/', '*') && highlight != HIGHLIGHT_JSON) {
|
||||
hls.Put(2, hl_style[INK_COMMENT]);
|
||||
p += 2;
|
||||
ss.comment = true;
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ void SourceFs(FileSel& fs) {
|
|||
fs.Type("Language files (*.lng)", "*.lng");
|
||||
fs.Type("Web development files (*.html *.js *.css *.witz)", "*.html *.js *.css *.witz");
|
||||
fs.Type("Other special files (*.sch *.usc *.rc *.brc *.upt)", "*.sch *.usc *.rc *.brc *.upt");
|
||||
String mask = "*.cpp *.h *.hpp *.c *.C *.cc *.cxx *.icpp *.lay *.iml *.lng *.sch *.usc *.rc *.brc *.upt *.html *.js *.css *.witz";
|
||||
String mask = "*.cpp *.h *.hpp *.c *.C *.cc *.cxx *.icpp *.lay *.iml *.lng *.sch *.usc *.rc *.brc *.upt *.html *.js *.css *.witz *.json *.xml";
|
||||
fs.Type("All source files (" + mask + ")", mask);
|
||||
IdeFs(fs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ void Ide::SetupEditor(int f, String hl, String fn)
|
|||
}
|
||||
if(IsNull(hl) && *ext == '.')
|
||||
hl = ext.Mid(1);
|
||||
if(findarg(hl, "c", "cpp", "cc", "cxx", "h", "hpp", "hh", "hxx", "m", "mm", "icpp", "conf", "json") >= 0)
|
||||
if(findarg(hl, "c", "cpp", "cc", "cxx", "h", "hpp", "hh", "hxx", "m", "mm", "icpp", "conf") >= 0)
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_CPP);
|
||||
else
|
||||
if(hl == "cs")
|
||||
|
|
@ -30,6 +30,9 @@ void Ide::SetupEditor(int f, String hl, String fn)
|
|||
if(hl == "css")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_CSS);
|
||||
else
|
||||
if(hl == "json")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_JSON);
|
||||
else
|
||||
if(hl == "t" || hl == "jt")
|
||||
editor.Highlight(CodeEditor::HIGHLIGHT_T);
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue