diff --git a/kitchen-sink.html b/kitchen-sink.html index 22f9f7d3..ee49cd28 100644 --- a/kitchen-sink.html +++ b/kitchen-sink.html @@ -56,6 +56,7 @@ + diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 02eb0bcc..b3fa60c4 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -529,6 +529,14 @@ var Editor = function(renderer, session) { return this.$mouseHandler.getScrollSpeed(); }; + this.setDragTimer = function(dragTimer) { + this.$mouseHandler.setDragTimer(dragTimer); + }; + + this.getDragTimer = function() { + return this.$mouseHandler.getDragTimer(); + }; + this.$selectionStyle = "line"; this.setSelectionStyle = function(style) { if (this.$selectionStyle == style) return; diff --git a/lib/ace/mode/php_highlight_rules.js b/lib/ace/mode/php_highlight_rules.js index a873f6fc..69a5181f 100644 --- a/lib/ace/mode/php_highlight_rules.js +++ b/lib/ace/mode/php_highlight_rules.js @@ -44,6 +44,7 @@ var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocComme var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var PhpHighlightRules = function() { + var docComment = new DocCommentHighlightRules(); // http://php.net/quickref.php var builtinFunctions = lang.arrayToMap( ('abs|acos|acosh|addcslashes|addslashes|aggregate|aggregate_info|aggregate_methods|aggregate_methods_by_list|aggregate_methods_by_regexp|' + @@ -903,13 +904,32 @@ var PhpHighlightRules = function() { this.$rules = { "start" : [ { - token : "support", // php open tag + token : "support.php_tag", // php open tag regex : "<\\?(?:php|\\=)" }, { - token : "support", // php close tag + token : "support.php_tag", // php close tag regex : "\\?>" }, + { + token : "comment", + regex : "<\\!--", + next : "htmlcomment" + }, + { + token : "meta.tag", + regex : "' + }, { token : "comment", regex : "\\/\\/.*$" @@ -918,10 +938,9 @@ var PhpHighlightRules = function() { token : "comment", regex : "#.*$" }, - new DocCommentHighlightRules().getStartRule("doc-start"), + docComment.getStartRule("doc-start"), { token : "comment", // multi line comment - merge : true, regex : "\\/\\*", next : "comment" }, { @@ -932,7 +951,6 @@ var PhpHighlightRules = function() { regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' }, { token : "string", // multi line string start - merge : true, regex : '["].*\\\\$', next : "qqstring" }, { @@ -940,7 +958,6 @@ var PhpHighlightRules = function() { regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" }, { token : "string", // multi line string start - merge : true, regex : "['].*\\\\$", next : "qstring" }, { @@ -976,11 +993,7 @@ var PhpHighlightRules = function() { "T(?:HOUS(?:ANDS_SEP|EP)|_FMT(?:_AMPM|))|YES(?:EXPR|STR)|STD(?:IN|OUT|ERR))\\b" }, { token : function(value) { - if (keywordsDeprecated.hasOwnProperty(value)) - return "invalid.deprecated"; - else if (keywords.hasOwnProperty(value)) - return "keyword"; - else if (languageConstructs.hasOwnProperty(value)) + if (keywords.hasOwnProperty(value)) return "keyword"; else if (builtinConstants.hasOwnProperty(value)) return "constant.language"; @@ -988,12 +1001,12 @@ var PhpHighlightRules = function() { return "variable.language"; else if (futureReserved.hasOwnProperty(value)) return "invalid.illegal"; - else if (builtinFunctionsDeprecated.hasOwnProperty(value)) - return "invalid.deprecated"; else if (builtinFunctions.hasOwnProperty(value)) return "support.function"; + else if (value == "debugger") + return "invalid.deprecated"; else - if(value.match(/^(\$[a-zA-Z_][a-zA-Z0-9_]*|self|parent)$/)) + if(value.match(/^(\$[a-zA-Z][a-zA-Z0-9_]*|self|parent)$/)) return "variable"; return "identifier"; }, @@ -1004,10 +1017,10 @@ var PhpHighlightRules = function() { token : "keyword.operator", regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)" }, { - token : "paren.lparen", + token : "lparen", regex : "[[({]" }, { - token : "paren.rparen", + token : "rparen", regex : "[\\])}]" }, { token : "text", @@ -1021,7 +1034,6 @@ var PhpHighlightRules = function() { next : "start" }, { token : "comment", // comment spanning whole line - merge : true, regex : ".+" } ], @@ -1032,7 +1044,6 @@ var PhpHighlightRules = function() { next : "start" }, { token : "string", - merge : true, regex : '.+' } ], @@ -1043,10 +1054,98 @@ var PhpHighlightRules = function() { next : "start" }, { token : "string", - merge : true, regex : '.+' } - ] + ], + "htmlcomment" : [ + { + token : "comment", + regex : ".*?-->", + next : "start" + }, { + token : "comment", + regex : ".+" + } + ], + "htmltag" : [ + { + token : "meta.tag", + regex : ">", + next : "start" + }, { + token : "text", + regex : "[-_a-zA-Z0-9:]+" + }, { + token : "text", + regex : "\\s+" + }, { + token : "string", + regex : '".*?"' + }, { + token : "string", + regex : "'.*?'" + } + ], + "css" : [ + { + token : "meta.tag", + regex : "<\/style>", + next : "htmltag" + }, { + token : "meta.tag", + regex : ">", + }, { + token : 'text', + regex : "(?:media|type|href)" + }, { + token : 'string', + regex : '=".*?"' + }, { + token : "paren.lparen", + regex : "\{", + next : "cssdeclaration", + }, { + token : "keyword", + regex : "#[A-Za-z0-9\-\_\.]+" + }, { + token : "variable", + regex : "\\.[A-Za-z0-9\-\_\.]+" + }, { + token : "constant", + regex : "[A-Za-z0-9]+" + } + ], + "cssdeclaration" : [ + { + token : "support.type", + regex : "[\-a-zA-Z]+", + next : "cssvalue" + }, + { + token : "paren.rparen", + regex : '\}', + next : "css" + } + ], + "cssvalue" : [ + { + token : "text", + regex : "\:" + }, + { + token : "constant", + regex : "#[0-9a-zA-Z]+" + }, + { + token : "text", + regex : "[\-\_0-9a-zA-Z\"' ,%]+" + }, + { + token : "text", + regex : ";", + next : "cssdeclaration" + } + ], }; this.embedRules(DocCommentHighlightRules, "doc-", diff --git a/lib/ace/mode/xml_util.js b/lib/ace/mode/xml_util.js index aa0756c4..9632fddf 100644 --- a/lib/ace/mode/xml_util.js +++ b/lib/ace/mode/xml_util.js @@ -36,6 +36,15 @@ * ***** END LICENSE BLOCK ***** */ define(function(require, exports, module) { + var lang = require("../lib/lang"); + + var formTags = lang.arrayToMap( + ("button|form|input|label|select|textarea").split("|") + ); + + var tableTags = lang.arrayToMap( + ("table|tbody|td|tfoot|th|tr").split("|") + ); function string(state) { return [{ @@ -75,9 +84,33 @@ exports.tag = function(states, name, nextState) { token : "text", regex : "\\s+" }, { - token : "meta.tag", + //token : "meta.tag", + + token : function(value) { + if ( value==='a' ) { + return "meta.tag.anchor"; + } + else if ( value==='img' ) { + return "meta.tag.image"; + } + else if ( value==='script' ) { + return "meta.tag.script"; + } + else if ( value==='style' ) { + return "meta.tag.style"; + } + else if (formTags.hasOwnProperty(value.toLowerCase())) { + return "meta.tag.form"; + } + else if (tableTags.hasOwnProperty(value.toLowerCase())) { + return "meta.tag.table"; + } + else { + return "meta.tag"; + } + }, merge : true, - regex : "[-_a-zA-Z0-9:]+", + regex : "[-_a-zA-Z0-9:!]+", next : name + "embed-attribute-list" }, { token: "empty", diff --git a/lib/ace/mouse/default_handlers.js b/lib/ace/mouse/default_handlers.js index 2ae23cbf..3d4e81e3 100644 --- a/lib/ace/mouse/default_handlers.js +++ b/lib/ace/mouse/default_handlers.js @@ -47,7 +47,6 @@ var STATE_UNKNOWN = 0; var STATE_SELECT = 1; var STATE_DRAG = 2; -var DRAG_TIMER = 250; // milliseconds var DRAG_OFFSET = 5; // pixels function DefaultHandlers(editor) { @@ -172,7 +171,7 @@ function DefaultHandlers(editor) { cursor.row = Math.max(0, Math.min(cursor.row, editor.session.getLength()-1)); onStartSelect(cursor); } - else if ((time - mousedownTime) > DRAG_TIMER) { + else if ((time - mousedownTime) > editor.getDragTimer()) { state = STATE_DRAG; dragRange = editor.getSelectionRange(); var style = editor.getSelectionStyle(); diff --git a/lib/ace/mouse/mouse_handler.js b/lib/ace/mouse/mouse_handler.js index 1371d6fb..f65c55c1 100644 --- a/lib/ace/mouse/mouse_handler.js +++ b/lib/ace/mouse/mouse_handler.js @@ -88,6 +88,15 @@ var MouseHandler = function(editor) { this.onMouseEvent = function(name, e) { this.editor._dispatchEvent(name, new MouseEvent(e, this.editor)); }; + + this.$dragTimer = 250; + this.setDragTimer = function(dragTimer) { + this.$dragTimer = dragTimer; + }; + + this.getDragTimer = function() { + return this.$dragTimer; + }; this.onMouseMove = function(name, e) { // optimization, because mousemove doesn't have a default handler. diff --git a/lib/ace/theme/dreamweaver.js b/lib/ace/theme/dreamweaver.js new file mode 100644 index 00000000..727910f3 --- /dev/null +++ b/lib/ace/theme/dreamweaver.js @@ -0,0 +1,233 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Adam Jimenez + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +exports.isDark = false; +exports.cssClass = "ace-tm"; +exports.cssText = ".ace-tm .ace_editor {\ + border: 2px solid rgb(159, 159, 159);\ +}\ +\ +.ace-tm .ace_editor.ace_focus {\ + border: 2px solid #327fbd;\ +}\ +\ +.ace-tm .ace_gutter {\ + width: 50px;\ + background: #e8e8e8;\ + color: #333;\ + overflow : hidden;\ +}\ +\ +.ace-tm .ace_gutter-layer {\ + width: 100%;\ + text-align: right;\ +}\ +\ +.ace-tm .ace_gutter-layer .ace_gutter-cell {\ + padding-right: 6px;\ +}\ +\ +.ace-tm .ace_print_margin {\ + width: 1px;\ + background: #e8e8e8;\ +}\ +\ +.ace-tm .ace_text-layer {\ + cursor: text;\ +}\ +\ +.ace-tm .ace_cursor {\ + border-left: 2px solid black;\ +}\ +\ +.ace-tm .ace_cursor.ace_overwrite {\ + border-left: 0px;\ + border-bottom: 1px solid black;\ +}\ + \ +.ace-tm .ace_line .ace_invisible {\ + color: rgb(191, 191, 191);\ +}\ +\ +.ace-tm .ace_line .ace_keyword {\ + color: blue;\ +}\ +\ +.ace-tm .ace_line .ace_constant.ace_buildin {\ + color: rgb(88, 72, 246);\ +}\ +\ +.ace-tm .ace_line .ace_constant.ace_language {\ + color: rgb(88, 92, 246);\ +}\ +\ +.ace-tm .ace_line .ace_constant.ace_library {\ + color: rgb(6, 150, 14);\ +}\ +\ +.ace-tm .ace_line .ace_invalid {\ + background-color: rgb(153, 0, 0);\ + color: white;\ +}\ +\ +.ace-tm .ace_line .ace_support.ace_function {\ + color: rgb(60, 76, 114);\ +}\ +\ +.ace-tm .ace_line .ace_support.ace_constant {\ + color: rgb(6, 150, 14);\ +}\ +\ +.ace-tm .ace_line .ace_support.ace_type,\ +.ace-tm .ace_line .ace_support.ace_class {\ + color: #009;\ +}\ +\ +.ace-tm .ace_line .ace_support.ace_php_tag {\ + color: #f00;\ +}\ +\ +.ace-tm .ace_line .ace_keyword.ace_operator {\ + color: rgb(104, 118, 135);\ +}\ +\ +.ace-tm .ace_line .ace_string {\ + color: #00F;\ +}\ +\ +.ace-tm .ace_line .ace_comment {\ + color: rgb(76, 136, 107);\ +}\ +\ +.ace-tm .ace_line .ace_comment.ace_doc {\ + color: rgb(0, 102, 255);\ +}\ +\ +.ace-tm .ace_line .ace_comment.ace_doc.ace_tag {\ + color: rgb(128, 159, 191);\ +}\ +\ +.ace-tm .ace_line .ace_constant.ace_numeric {\ + color: rgb(0, 0, 205);\ +}\ +\ +.ace-tm .ace_line .ace_variable {\ + color: #06F\ +}\ +\ +.ace-tm .ace_line .ace_xml_pe {\ + color: rgb(104, 104, 91);\ +}\ +\ +.ace-tm .ace_entity.ace_name.ace_function {\ + color: #00F;\ +}\ +\ +.ace-tm .ace_markup.ace_markupine {\ + text-decoration:underline;\ +}\ +\ +.ace-tm .ace_markup.ace_heading {\ + color: rgb(12, 7, 255);\ +}\ +\ +.ace-tm .ace_markup.ace_list {\ + color:rgb(185, 6, 144);\ +}\ +\ +.ace-tm .ace_marker-layer .ace_selection {\ + background: rgb(181, 213, 255);\ +}\ +\ +.ace-tm .ace_marker-layer .ace_step {\ + background: rgb(252, 255, 0);\ +}\ +\ +.ace-tm .ace_marker-layer .ace_stack {\ + background: rgb(164, 229, 101);\ +}\ +\ +.ace-tm .ace_marker-layer .ace_bracket {\ + margin: -1px 0 0 -1px;\ + border: 1px solid rgb(192, 192, 192);\ +}\ +\ +.ace-tm .ace_marker-layer .ace_active_line {\ + background: rgba(0, 0, 0, 0.07);\ +}\ +\ +.ace-tm .ace_marker-layer .ace_selected_word {\ + background: rgb(250, 250, 255);\ + border: 1px solid rgb(200, 200, 250);\ +}\ +\ +.ace-tm .ace_meta.ace_tag {\ + color:#009;\ +}\ +\ +.ace-tm .ace_meta.ace_tag.ace_anchor {\ + color:#060;\ +}\ +\ +.ace-tm .ace_meta.ace_tag.ace_form {\ + color:#F90;\ +}\ +\ +.ace-tm .ace_meta.ace_tag.ace_image {\ + color:#909;\ +}\ +\ +.ace-tm .ace_meta.ace_tag.ace_script {\ + color:#900;\ +}\ +\ +.ace-tm .ace_meta.ace_tag.ace_style {\ + color:#909;\ +}\ +\ +.ace-tm .ace_meta.ace_tag.ace_table {\ + color:#099;\ +}\ +\ +.ace-tm .ace_string.ace_regex {\ + color: rgb(255, 0, 0)\ +}"; + + var dom = require("../lib/dom"); + dom.importCssString(exports.cssText); +});