Adding feature to coloring and check syntaxis on trigger editor.

This commit is contained in:
ralph
2013-03-22 15:52:26 -04:00
parent 8bde064996
commit cbe2fbe871
10 changed files with 346 additions and 23 deletions

View File

@@ -19,6 +19,8 @@ var PHPHTMLMixedParser = Editor.Parser = (function() {
var htmlParser = XMLParser.make(stream), localParser = null,
inTag = false, lastAtt = null, phpParserState = null;
var iter = {next: top, copy: copy};
if (Editor.Parser.options && Editor.Parser.options.parserConfig.phpOnly == true)
iter.next = local(PHPParser, "?>");
function top() {
var token = htmlParser.next();
@@ -49,6 +51,10 @@ var PHPHTMLMixedParser = Editor.Parser = (function() {
lastAtt = null;
inTag = false;
}
else if (token.type == "xml-text" && token.style == "xml-text") {
if (Editor.Parser.options && Editor.Parser.options.parserConfig.phpOnly == true)
iter.next = local(PHPParser, "?>");
}
return token;
}
function local(parser, tag) {

View File

@@ -956,6 +956,14 @@ var tokenizePHP = (function() {
"SplQueue", "SplStack", "SQLite3", "SQLite3Result", "SQLite3Stmt", "SQLiteDatabase",
"SQLiteException", "SQLiteResult", "SQLiteUnbuffered", "Svn", "SvnNode", "SvnWc",
"SvnWcSchedule", "XSLTProcessor", "ZipArchive",
"PMFTaskCase","PMFTaskList","PMFUserList","PMFGroupList",
"PMFRoleList","PMFCaseList","PMFProcessList","PMFSendVariables",
"PMFDerivateCase","PMFNewCaseImpersonate","PMFNewCase","PMFPauseCase",
"PMFUnpauseCase","PMFAssignUserToGroup","PMFCreateUser","PMFUpdateUser",
"PMFInformationUser","generateCode","setCaseTrackerCode","jumping",
"PMFRedirectToStep","pauseCase","PMFSendMessage","PMFgetLabelOption",
"PMFGenerateOutputDocument","PMFGetUserEmailAddress","PMFGetNextAssignedUser","PMFDeleteCase",
"PMFCancelCase","PMFAddInputDocument","PMFAddCaseNote","PMFGetCaseNotes"
].forEach(function(element, index, array) {
result[element] = token("t_string", "php-predefined-class");
});

View File

@@ -0,0 +1,114 @@
/*
Copyright (c) 2008-2009 Yahoo! Inc. All rights reserved.
The copyrights embodied in the content of this file are licensed by
Yahoo! Inc. under the BSD (revised) open source license
@author Dan Vlad Dascalescu <dandv@yahoo-inc.com>
*/
html {
cursor: text;
}
.editbox {
margin: .4em;
padding: 0;
font-family: monospace;
font-size: 10pt;
}
/*We should define specific styles for every element of the syntax.
the setting below will cause some annoying color to show through if we missed
defining a style for a token. This is also the "color" of the whitespace and
of the cursor.
*/
pre.code, .editbox {
color: red;
}
.editbox p {
margin: 0;
}
span.php-punctuation {
color: blue;
}
span.php-keyword {
color: #770088;
font-weight: bold;
}
span.php-operator {
color: blue;
}
/* __FILE__ etc.; http://php.net/manual/en/reserved.php */
span.php-compile-time-constant {
color: #776088;
font-weight: bold;
}
/* output of get_defined_constants(). Differs from http://php.net/manual/en/reserved.constants.php */
span.php-predefined-constant {
color: darkgreen;
font-weight: bold;
}
/* PHP reserved "language constructs"... echo() etc.; http://php.net/manual/en/reserved.php */
span.php-reserved-language-construct {
color: green;
font-weight: bold;
}
/* PHP built-in functions: glob(), chr() etc.; output of get_defined_functions()["internal"] */
span.php-predefined-function {
color: green;
}
/* PHP predefined classes: PDO, Exception etc.; output of get_declared_classes() and different from http://php.net/manual/en/reserved.classes.php */
span.php-predefined-class {
color: green;
}
span.php-atom {
color: #228811;
}
/* class, interface, namespace or function names, but not $variables */
span.php-t_string {
color: black;
}
span.php-variable {
color: black;
font-weight: bold;
}
span.js-localvariable {
color: #004499;
}
span.php-comment {
color: #AA7700;
font-stretch: condensed;
/* font-style: italic; This causes line height to slightly change, getting line numbers out of sync */
}
span.php-string-single-quoted {
color: #AA2222;
}
/* double quoted strings allow interpolation */
span.php-string-double-quoted {
color: #AA2222;
font-weight: bold;
}
span.syntax-error {
background-color: red;
}
span.deprecated {
font-size: smaller;
}

View File

@@ -420,8 +420,10 @@ var Editor = (function(){
if (!Editor.Parser)
throw "No parser loaded.";
if (options.parserConfig && Editor.Parser.configure)
if (options.parserConfig && Editor.Parser.configure) {
Editor.Parser.configure(options.parserConfig);
Editor.Parser.options = options;
}
if (!options.readOnly && !internetExplorer)
select.setCursorPos(container, {node: null, offset: 0});