From 9cbcfb35d3231d51a894d79b623428f02825359f Mon Sep 17 00:00:00 2001 From: nightwing Date: Mon, 20 Jan 2014 21:38:23 +0400 Subject: [PATCH 01/11] use _signal where possible --- lib/ace/anchor.js | 2 +- lib/ace/background_tokenizer.js | 2 +- lib/ace/document.js | 12 ++++----- lib/ace/edit_session.js | 44 ++++++++++++++++----------------- lib/ace/editor.js | 16 ++++++------ lib/ace/multi_select.js | 8 +++--- lib/ace/worker/worker.js | 2 +- lib/ace/worker/worker_client.js | 6 ++--- 8 files changed, 46 insertions(+), 46 deletions(-) diff --git a/lib/ace/anchor.js b/lib/ace/anchor.js index 3a62e632..0f2e9571 100644 --- a/lib/ace/anchor.js +++ b/lib/ace/anchor.js @@ -191,7 +191,7 @@ var Anchor = exports.Anchor = function(doc, row, column) { this.row = pos.row; this.column = pos.column; - this._emit("change", { + this._signal("change", { old: old, value: pos }); diff --git a/lib/ace/background_tokenizer.js b/lib/ace/background_tokenizer.js index 217be1b3..b2ba3733 100644 --- a/lib/ace/background_tokenizer.js +++ b/lib/ace/background_tokenizer.js @@ -150,7 +150,7 @@ var BackgroundTokenizer = function(tokenizer, editor) { first: firstRow, last: lastRow }; - this._emit("update", {data: data}); + this._signal("update", {data: data}); }; /** diff --git a/lib/ace/document.js b/lib/ace/document.js index 75a7920d..ce9a6e31 100644 --- a/lib/ace/document.js +++ b/lib/ace/document.js @@ -326,7 +326,7 @@ var Document = function(text) { range: range, lines: lines }; - this._emit("change", { data: delta }); + this._signal("change", { data: delta }); return end || range.end; }; @@ -356,7 +356,7 @@ var Document = function(text) { range: Range.fromPoints(position, end), text: this.getNewLineCharacter() }; - this._emit("change", { data: delta }); + this._signal("change", { data: delta }); return end; }; @@ -390,7 +390,7 @@ var Document = function(text) { range: Range.fromPoints(position, end), text: text }; - this._emit("change", { data: delta }); + this._signal("change", { data: delta }); return end; }; @@ -458,7 +458,7 @@ var Document = function(text) { range: range, text: removed }; - this._emit("change", { data: delta }); + this._signal("change", { data: delta }); return range.start; }; @@ -485,7 +485,7 @@ var Document = function(text) { nl: this.getNewLineCharacter(), lines: removed }; - this._emit("change", { data: delta }); + this._signal("change", { data: delta }); return removed; }; @@ -508,7 +508,7 @@ var Document = function(text) { range: range, text: this.getNewLineCharacter() }; - this._emit("change", { data: delta }); + this._signal("change", { data: delta }); }; /** diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 5b2eb747..8f772db7 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -163,7 +163,7 @@ var EditSession = function(text, mode) { config.resetOptions(this); this.setMode(mode); - config._emit("session", this); + config._signal("session", this); }; @@ -269,7 +269,7 @@ var EditSession = function(text, mode) { } this.bgTokenizer.$updateOnChange(delta); - this._emit("change", e); + this._signal("change", e); }; /** @@ -528,7 +528,7 @@ var EditSession = function(text, mode) { if (!this.$decorations[row]) this.$decorations[row] = ""; this.$decorations[row] += " " + className; - this._emit("changeBreakpoint", {}); + this._signal("changeBreakpoint", {}); }; /** @@ -540,7 +540,7 @@ var EditSession = function(text, mode) { **/ this.removeGutterDecoration = function(row, className) { this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, ""); - this._emit("changeBreakpoint", {}); + this._signal("changeBreakpoint", {}); }; /** @@ -563,7 +563,7 @@ var EditSession = function(text, mode) { for (var i=0; i 1 && !this.inMultiSelectMode) { - this._emit("multiSelect"); + this._signal("multiSelect"); this.inMultiSelectMode = true; this.session.$undoSelect = false; this.rangeList.attach(this.session); @@ -150,7 +150,7 @@ var EditSession = require("./edit_session").EditSession; this.$onAddRange = function(range) { this.rangeCount = this.rangeList.ranges.length; this.ranges.unshift(range); - this._emit("addRange", {range: range}); + this._signal("addRange", {range: range}); }; this.$onRemoveRange = function(removed) { @@ -166,11 +166,11 @@ var EditSession = require("./edit_session").EditSession; this.ranges.splice(index, 1); } - this._emit("removeRange", {ranges: removed}); + this._signal("removeRange", {ranges: removed}); if (this.rangeCount == 0 && this.inMultiSelectMode) { this.inMultiSelectMode = false; - this._emit("singleSelect"); + this._signal("singleSelect"); this.session.$undoSelect = true; this.rangeList.detach(this.session); } diff --git a/lib/ace/worker/worker.js b/lib/ace/worker/worker.js index b1b83ba9..2646ed17 100644 --- a/lib/ace/worker/worker.js +++ b/lib/ace/worker/worker.js @@ -176,7 +176,7 @@ window.onmessage = function(e) { main = new clazz(sender); } else if (msg.event && sender) { - sender._emit(msg.event, msg.data); + sender._signal(msg.event, msg.data); } }; })(this); \ No newline at end of file diff --git a/lib/ace/worker/worker_client.js b/lib/ace/worker/worker_client.js index 743bd0ed..cb18998f 100644 --- a/lib/ace/worker/worker_client.js +++ b/lib/ace/worker/worker_client.js @@ -96,7 +96,7 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) { break; case "event": - this._emit(msg.name, {data: msg.data}); + this._signal(msg.name, {data: msg.data}); break; case "call": @@ -121,7 +121,7 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) { }; this.terminate = function() { - this._emit("terminate", {}); + this._signal("terminate", {}); this.deltaQueue = null; this.$worker.terminate(); this.$worker = null; @@ -217,7 +217,7 @@ var UIWorkerClient = function(topLevelNamespaces, mod, classname) { if (msg.command) main[msg.command].apply(main, msg.args); else if (msg.event) - sender._emit(msg.event, msg.data); + sender._signal(msg.event, msg.data); }; sender.postMessage = function(msg) { From 1e46543b0502a7f7a3d4e0cac7a9d8379d2f0692 Mon Sep 17 00:00:00 2001 From: nightwing Date: Mon, 20 Jan 2014 21:37:53 +0400 Subject: [PATCH 02/11] fix error marker column --- lib/ace/ext/error_marker.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ace/ext/error_marker.js b/lib/ace/ext/error_marker.js index 28663c6d..5e87529e 100644 --- a/lib/ace/ext/error_marker.js +++ b/lib/ace/ext/error_marker.js @@ -108,8 +108,9 @@ exports.showErrorMarker = function(editor, dir) { var gutterAnno; if (annotations) { var annotation = annotations[0]; - if (annotation.pos && annotation.column == null) - pos.column = annotation.pos.sc; + pos.column = (annotation.pos && typeof annotation.column != "number" + ? annotation.pos.sc + : annotation.column) || 0; pos.row = annotation.row; gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row]; } else if (oldWidget) { From 0eb2b74a666ceafd52075787222f8a627cf3afee Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 4 Feb 2014 02:41:21 +0400 Subject: [PATCH 03/11] fix #1795 PHP variables that begin with an underscore are not highlighted --- lib/ace/mode/php_highlight_rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/php_highlight_rules.js b/lib/ace/mode/php_highlight_rules.js index 033671eb..0c0557d6 100644 --- a/lib/ace/mode/php_highlight_rules.js +++ b/lib/ace/mode/php_highlight_rules.js @@ -969,7 +969,7 @@ var PhpLangHighlightRules = 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"; }, From 31e1a2d1f3b3bc6f6b5dafacd0cc61ab728b742c Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 5 Feb 2014 21:24:03 +0400 Subject: [PATCH 04/11] improve php variable regexp --- lib/ace/mode/php_highlight_rules.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/ace/mode/php_highlight_rules.js b/lib/ace/mode/php_highlight_rules.js index 0c0557d6..f8d5e29e 100644 --- a/lib/ace/mode/php_highlight_rules.js +++ b/lib/ace/mode/php_highlight_rules.js @@ -969,13 +969,11 @@ var PhpLangHighlightRules = 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_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*|self|parent)$/)) return "variable"; return "identifier"; }, - // TODO: Unicode escape sequences - // TODO: Unicode identifiers - regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + regex : "[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\\b" }, { onMatch : function(value, currentSate, state) { value = value.substr(3); From 99f49fdc4998097d03ba31a32012511dbc045520 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 5 Feb 2014 21:26:17 +0400 Subject: [PATCH 05/11] add smarty mode --- demo/kitchen-sink/docs/smarty.smarty | 7 + lib/ace/ext/modelist.js | 1 + lib/ace/mode/mushcode.js | 2 +- ...h_rules.js => mushcode_highlight_rules.js} | 0 lib/ace/mode/smarty.js | 58 ++++++++ lib/ace/mode/smarty_highlight_rules.js | 136 ++++++++++++++++++ 6 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 demo/kitchen-sink/docs/smarty.smarty rename lib/ace/mode/{mushcode_high_rules.js => mushcode_highlight_rules.js} (100%) create mode 100644 lib/ace/mode/smarty.js create mode 100644 lib/ace/mode/smarty_highlight_rules.js diff --git a/demo/kitchen-sink/docs/smarty.smarty b/demo/kitchen-sink/docs/smarty.smarty new file mode 100644 index 00000000..77206724 --- /dev/null +++ b/demo/kitchen-sink/docs/smarty.smarty @@ -0,0 +1,7 @@ +{foreach $foo as $bar} + {$bar.zag} + {$bar.zag2} + {$bar.zag3} +{foreachelse} + There were no rows found. +{/foreach} \ No newline at end of file diff --git a/lib/ace/ext/modelist.js b/lib/ace/ext/modelist.js index 632ae088..8a2c7bd6 100644 --- a/lib/ace/ext/modelist.js +++ b/lib/ace/ext/modelist.js @@ -123,6 +123,7 @@ var supportedModes = { SASS: ["sass"], SCAD: ["scad"], Scala: ["scala"], + Smarty: ["smarty|tpl"], Scheme: ["scm|rkt"], SCSS: ["scss"], SH: ["sh|bash|^.bashrc"], diff --git a/lib/ace/mode/mushcode.js b/lib/ace/mode/mushcode.js index 42e85040..4501e6c9 100644 --- a/lib/ace/mode/mushcode.js +++ b/lib/ace/mode/mushcode.js @@ -34,7 +34,7 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var Tokenizer = require("../tokenizer").Tokenizer; -var MushCodeRules = require("./mushcode_high_rules").MushCodeRules; +var MushCodeRules = require("./mushcode_highlight_rules").MushCodeRules; var PythonFoldMode = require("./folding/pythonic").FoldMode; var Range = require("../range").Range; diff --git a/lib/ace/mode/mushcode_high_rules.js b/lib/ace/mode/mushcode_highlight_rules.js similarity index 100% rename from lib/ace/mode/mushcode_high_rules.js rename to lib/ace/mode/mushcode_highlight_rules.js diff --git a/lib/ace/mode/smarty.js b/lib/ace/mode/smarty.js new file mode 100644 index 00000000..af0a33ed --- /dev/null +++ b/lib/ace/mode/smarty.js @@ -0,0 +1,58 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { + "use strict"; + +var oop = require("../lib/oop"); +var HtmlMode = require("./html").Mode; +var Tokenizer = require("../tokenizer").Tokenizer; +var SmartyHighlightRules = require("./smarty_highlight_rules").SmartyHighlightRules; +var HtmlBehaviour = require("./behaviour/html").HtmlBehaviour; +var HtmlFoldMode = require("./folding/html").FoldMode; + +var Mode = function() { + HtmlMode.call(this); + this.HighlightRules = SmartyHighlightRules; + this.$behaviour = new HtmlBehaviour(); + + + this.foldingRules = new HtmlFoldMode(); +}; + +oop.inherits(Mode, HtmlMode); + +(function() { + + this.$id = "ace/mode/smarty"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/lib/ace/mode/smarty_highlight_rules.js b/lib/ace/mode/smarty_highlight_rules.js new file mode 100644 index 00000000..f67ee068 --- /dev/null +++ b/lib/ace/mode/smarty_highlight_rules.js @@ -0,0 +1,136 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + +/* This file was autogenerated from https://raw.github.com/amitsnyderman/sublime-smarty/master/Syntaxes/Smarty.tmLanguage (uuid: ) */ +/**************************************************************************************** + * IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. * + * fileTypes * + ****************************************************************************************/ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; + +var SmartyHighlightRules = function() { + HtmlHighlightRules.call(this); + var smartyRules = { start: + [ { include: '#comments' }, + { include: '#blocks' } ], + '#blocks': + [ { token: 'punctuation.section.embedded.begin.smarty', + regex: '\\{%?', + push: + [ { token: 'punctuation.section.embedded.end.smarty', + regex: '%?\\}', + next: 'pop' }, + { include: '#strings' }, + { include: '#variables' }, + { include: '#lang' }, + { defaultToken: 'source.smarty' } ] } ], + '#comments': + [ { token: + [ 'punctuation.definition.comment.smarty', + 'comment.block.smarty' ], + regex: '(\\{%?)(\\*)', + push: + [ { token: 'comment.block.smarty', regex: '\\*%?\\}', next: 'pop' }, + { defaultToken: 'comment.block.smarty' } ] } ], + '#lang': + [ { token: 'keyword.operator.smarty', + regex: '(?:!=|!|<=|>=|<|>|===|==|%|&&|\\|\\|)|\\b(?:and|or|eq|neq|ne|gte|gt|ge|lte|lt|le|not|mod)\\b' }, + { token: 'constant.language.smarty', + regex: '\\b(?:TRUE|FALSE|true|false)\\b' }, + { token: 'keyword.control.smarty', + regex: '\\b(?:if|else|elseif|foreach|foreachelse|section|switch|case|break|default)\\b' }, + { token: 'variable.parameter.smarty', regex: '\\b[a-zA-Z]+=' }, + { token: 'support.function.built-in.smarty', + regex: '\\b(?:capture|config_load|counter|cycle|debug|eval|fetch|include_php|include|insert|literal|math|strip|rdelim|ldelim|assign|constant|block|html_[a-z_]*)\\b' }, + { token: 'support.function.variable-modifier.smarty', + regex: '\\|(?:capitalize|cat|count_characters|count_paragraphs|count_sentences|count_words|date_format|default|escape|indent|lower|nl2br|regex_replace|replace|spacify|string_format|strip_tags|strip|truncate|upper|wordwrap)' } ], + '#strings': + [ { token: 'punctuation.definition.string.begin.smarty', + regex: '\'', + push: + [ { token: 'punctuation.definition.string.end.smarty', + regex: '\'', + next: 'pop' }, + { token: 'constant.character.escape.smarty', regex: '\\\\.' }, + { defaultToken: 'string.quoted.single.smarty' } ] }, + { token: 'punctuation.definition.string.begin.smarty', + regex: '"', + push: + [ { token: 'punctuation.definition.string.end.smarty', + regex: '"', + next: 'pop' }, + { token: 'constant.character.escape.smarty', regex: '\\\\.' }, + { defaultToken: 'string.quoted.double.smarty' } ] } ], + '#variables': + [ { token: + [ 'punctuation.definition.variable.smarty', + 'variable.other.global.smarty' ], + regex: '\\b(\\$)(Smarty\\.)' }, + { token: + [ 'punctuation.definition.variable.smarty', + 'variable.other.smarty' ], + regex: '(\\$)([a-zA-Z_][a-zA-Z0-9_]*)\\b' }, + { token: [ 'keyword.operator.smarty', 'variable.other.property.smarty' ], + regex: '(->)([a-zA-Z_][a-zA-Z0-9_]*)\\b' }, + { token: + [ 'keyword.operator.smarty', + 'meta.function-call.object.smarty', + 'punctuation.definition.variable.smarty', + 'variable.other.smarty', + 'punctuation.definition.variable.smarty' ], + regex: '(->)([a-zA-Z_][a-zA-Z0-9_]*)(\\()(.*?)(\\))' } ] } + + var smartyStart = smartyRules.start; + + Object.keys(smartyRules).forEach(function(x) { + if (x == "start") + this.$rules[x].unshift.apply(this.$rules[x], smartyRules[x]); + else + this.$rules[x] = smartyRules[x]; + }, this); + this.normalizeRules(); +}; + +SmartyHighlightRules.metaData = { fileTypes: [ 'tpl' ], + foldingStartMarker: '\\{%?', + foldingStopMarker: '%?\\}', + name: 'Smarty', + scopeName: 'text.html.smarty' } + + +oop.inherits(SmartyHighlightRules, HtmlHighlightRules); + +exports.SmartyHighlightRules = SmartyHighlightRules; +}); \ No newline at end of file From 42f274a42cd50c43cd13d261f18a29169865a0b2 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 5 Feb 2014 23:59:17 +0400 Subject: [PATCH 06/11] update smarty mode --- lib/ace/mode/smarty_highlight_rules.js | 11 +++++++---- lib/ace/mode/text_highlight_rules.js | 4 +++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/ace/mode/smarty_highlight_rules.js b/lib/ace/mode/smarty_highlight_rules.js index f67ee068..dfc1f593 100644 --- a/lib/ace/mode/smarty_highlight_rules.js +++ b/lib/ace/mode/smarty_highlight_rules.js @@ -113,13 +113,16 @@ var SmartyHighlightRules = function() { regex: '(->)([a-zA-Z_][a-zA-Z0-9_]*)(\\()(.*?)(\\))' } ] } var smartyStart = smartyRules.start; - + + ["start", "qqstring_inner", "qstring_inner", "attributes", "cdata"].forEach(function(x) { + this.$rules[x].unshift.apply(this.$rules[x], smartyStart); + }, this); + Object.keys(smartyRules).forEach(function(x) { - if (x == "start") - this.$rules[x].unshift.apply(this.$rules[x], smartyRules[x]); - else + if (!this.$rules[x]) this.$rules[x] = smartyRules[x]; }, this); + this.normalizeRules(); }; diff --git a/lib/ace/mode/text_highlight_rules.js b/lib/ace/mode/text_highlight_rules.js index 416e8182..c4fcf588 100644 --- a/lib/ace/mode/text_highlight_rules.js +++ b/lib/ace/mode/text_highlight_rules.js @@ -80,7 +80,9 @@ var TextHighlightRules = function() { }; this.embedRules = function (HighlightRules, prefix, escapeRules, states, append) { - var embedRules = new HighlightRules().getRules(); + var embedRules = typeof HighlightRules == "function" + ? new HighlightRules().getRules() + : HighlightRules; if (states) { for (var i = 0; i < states.length; i++) states[i] = prefix + states[i]; From 4795261b94619e9f864f86c1b582b2f9657297f6 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 6 Feb 2014 00:13:52 +0400 Subject: [PATCH 07/11] fix infinite loop when inserting snippet with self referencing tabstop fixes #1802 --- lib/ace/snippets.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ace/snippets.js b/lib/ace/snippets.js index ee1a5498..4418550d 100644 --- a/lib/ace/snippets.js +++ b/lib/ace/snippets.js @@ -329,8 +329,11 @@ var SnippetManager = function() { continue; var id = p.tabstopId; var i1 = tokens.indexOf(p, i + 1); - if (expanding[id] == p) { - expanding[id] = null; + if (expanding[id]) { + // if reached closing bracket clear expanding state + if (expanding[id] === p) + expanding[id] = null; + // otherwise just ignore recursive tabstop continue; } From eac48f519040e8e2d17dd1a5b76c2818ecf58cd1 Mon Sep 17 00:00:00 2001 From: nightwing Date: Thu, 6 Feb 2014 00:19:41 +0400 Subject: [PATCH 08/11] fix broken python snippet --- lib/ace/snippets.js | 2 +- lib/ace/snippets/python.snippets | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ace/snippets.js b/lib/ace/snippets.js index 4418550d..f382f7ba 100644 --- a/lib/ace/snippets.js +++ b/lib/ace/snippets.js @@ -169,7 +169,7 @@ var SnippetManager = function() { // defult but can't fill :( case "FILENAME": case "FILEPATH": - return "ace.ajax.org"; + return ""; case "FULLNAME": return "Ace"; } diff --git a/lib/ace/snippets/python.snippets b/lib/ace/snippets/python.snippets index dd2e8123..347bbdeb 100644 --- a/lib/ace/snippets/python.snippets +++ b/lib/ace/snippets/python.snippets @@ -7,8 +7,8 @@ snippet from # Module Docstring snippet docs ''' - File: ${1:`Filename('$1.py', 'foo.py')`} - Author: ${2:`g:snips_author`} + File: ${1:FILENAME:file_name} + Author: ${2:author} Description: ${3} ''' snippet wh @@ -129,7 +129,7 @@ snippet " """ # test function/method snippet test - def test_${1:description}(${2:`indent('.') ? 'self' : ''`}): + def test_${1:description}(${2:self}): ${3:# TODO: write code...} # test case snippet testcase From 471e9c6d4089b05b5f06ffd307ff437c28100150 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 9 Feb 2014 17:34:25 +0400 Subject: [PATCH 09/11] fix typo --- lib/ace/mode/php_highlight_rules.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/mode/php_highlight_rules.js b/lib/ace/mode/php_highlight_rules.js index f8d5e29e..d0419aca 100644 --- a/lib/ace/mode/php_highlight_rules.js +++ b/lib/ace/mode/php_highlight_rules.js @@ -973,7 +973,7 @@ var PhpLangHighlightRules = function() { return "variable"; return "identifier"; }, - regex : "[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\\b" + regex : "[a-zA-Z_$\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\\b" }, { onMatch : function(value, currentSate, state) { value = value.substr(3); From 9db70f0351bea04e93feef19b0a43fb8921643df Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 11 Feb 2014 20:22:08 +0400 Subject: [PATCH 10/11] add block comment for sql --- lib/ace/mode/sql_highlight_rules.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ace/mode/sql_highlight_rules.js b/lib/ace/mode/sql_highlight_rules.js index e16ac9ab..df04786c 100644 --- a/lib/ace/mode/sql_highlight_rules.js +++ b/lib/ace/mode/sql_highlight_rules.js @@ -59,6 +59,10 @@ var SqlHighlightRules = function() { "start" : [ { token : "comment", regex : "--.*$" + }, { + token : "comment", + start : "/\\*", + end : "\\*/" }, { token : "string", // " string regex : '".*?"' @@ -85,6 +89,7 @@ var SqlHighlightRules = function() { regex : "\\s+" } ] }; + this.normalizeRules(); }; oop.inherits(SqlHighlightRules, TextHighlightRules); From 68096ff38d155068f44280d7ba2d6da22750aabf Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 11 Feb 2014 20:40:31 +0400 Subject: [PATCH 11/11] run extension files automatically --- Makefile.dryice.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Makefile.dryice.js b/Makefile.dryice.js index 549f3665..49bf0b28 100755 --- a/Makefile.dryice.js +++ b/Makefile.dryice.js @@ -280,7 +280,7 @@ function addSuffix(options) { } } -function getWriteFilters(options, projectType) { +function getWriteFilters(options, projectType, main) { var filters = [ copy.filter.moduleDefines, removeUseStrict, @@ -310,11 +310,9 @@ function getWriteFilters(options, projectType) { return text; }); - if (options.exportModule && projectType == "main") { - if (options.noconflict) - filters.push(exportAce(options.ns, options.exportModule, options.ns)); - else - filters.push(exportAce(options.ns, options.exportModule)); + if (options.exportModule && projectType == "main" || projectType == "ext") { + filters.push(exportAce(options.ns, options.exportModule, + options.noconflict ? options.ns : "", projectType == "ext" && main)); } return filters; } @@ -390,7 +388,7 @@ var buildAce = function(options) { project: cloneProject(project), require: [ 'ace/ext/' + ext ] }], - filter: getWriteFilters(options, "ext"), + filter: getWriteFilters(options, "ext", 'ace/ext/' + ext), dest: targetDir + "/ext-" + ext + ".js" }); }); @@ -650,7 +648,7 @@ function namespace(ns) { }; } -function exportAce(ns, module, requireBase) { +function exportAce(ns, module, requireBase, extModule) { requireBase = requireBase || "window"; module = module || "ace/ace"; return function(text) { @@ -666,7 +664,16 @@ function exportAce(ns, module, requireBase) { }); })(); }; - + + if (extModule) { + module = extModule; + template = function() { + (function() { + REQUIRE_NS.require(["MODULE"], function() {}); + })(); + }; + } + return (text + ";" + template .toString() .replace(/MODULE/g, module)