Merge pull request #1809 from ajaxorg/c9

Add smarty mode and fix several small bugs
This commit is contained in:
Lennart Kats 2014-02-12 11:21:41 +01:00
commit ffc9cec9ef
21 changed files with 290 additions and 69 deletions

View file

@ -280,7 +280,7 @@ function addSuffix(options) {
} }
} }
function getWriteFilters(options, projectType) { function getWriteFilters(options, projectType, main) {
var filters = [ var filters = [
copy.filter.moduleDefines, copy.filter.moduleDefines,
removeUseStrict, removeUseStrict,
@ -310,11 +310,9 @@ function getWriteFilters(options, projectType) {
return text; return text;
}); });
if (options.exportModule && projectType == "main") { if (options.exportModule && projectType == "main" || projectType == "ext") {
if (options.noconflict) filters.push(exportAce(options.ns, options.exportModule,
filters.push(exportAce(options.ns, options.exportModule, options.ns)); options.noconflict ? options.ns : "", projectType == "ext" && main));
else
filters.push(exportAce(options.ns, options.exportModule));
} }
return filters; return filters;
} }
@ -390,7 +388,7 @@ var buildAce = function(options) {
project: cloneProject(project), project: cloneProject(project),
require: [ 'ace/ext/' + ext ] require: [ 'ace/ext/' + ext ]
}], }],
filter: getWriteFilters(options, "ext"), filter: getWriteFilters(options, "ext", 'ace/ext/' + ext),
dest: targetDir + "/ext-" + ext + ".js" 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"; requireBase = requireBase || "window";
module = module || "ace/ace"; module = module || "ace/ace";
return function(text) { 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 return (text + ";" + template
.toString() .toString()
.replace(/MODULE/g, module) .replace(/MODULE/g, module)

View file

@ -0,0 +1,7 @@
{foreach $foo as $bar}
<a href="{$bar.zig}">{$bar.zag}</a>
<a href="{$bar.zig2}">{$bar.zag2}</a>
<a href="{$bar.zig3}">{$bar.zag3}</a>
{foreachelse}
There were no rows found.
{/foreach}

View file

@ -191,7 +191,7 @@ var Anchor = exports.Anchor = function(doc, row, column) {
this.row = pos.row; this.row = pos.row;
this.column = pos.column; this.column = pos.column;
this._emit("change", { this._signal("change", {
old: old, old: old,
value: pos value: pos
}); });

View file

@ -150,7 +150,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
first: firstRow, first: firstRow,
last: lastRow last: lastRow
}; };
this._emit("update", {data: data}); this._signal("update", {data: data});
}; };
/** /**

View file

@ -326,7 +326,7 @@ var Document = function(text) {
range: range, range: range,
lines: lines lines: lines
}; };
this._emit("change", { data: delta }); this._signal("change", { data: delta });
return end || range.end; return end || range.end;
}; };
@ -356,7 +356,7 @@ var Document = function(text) {
range: Range.fromPoints(position, end), range: Range.fromPoints(position, end),
text: this.getNewLineCharacter() text: this.getNewLineCharacter()
}; };
this._emit("change", { data: delta }); this._signal("change", { data: delta });
return end; return end;
}; };
@ -390,7 +390,7 @@ var Document = function(text) {
range: Range.fromPoints(position, end), range: Range.fromPoints(position, end),
text: text text: text
}; };
this._emit("change", { data: delta }); this._signal("change", { data: delta });
return end; return end;
}; };
@ -458,7 +458,7 @@ var Document = function(text) {
range: range, range: range,
text: removed text: removed
}; };
this._emit("change", { data: delta }); this._signal("change", { data: delta });
return range.start; return range.start;
}; };
@ -485,7 +485,7 @@ var Document = function(text) {
nl: this.getNewLineCharacter(), nl: this.getNewLineCharacter(),
lines: removed lines: removed
}; };
this._emit("change", { data: delta }); this._signal("change", { data: delta });
return removed; return removed;
}; };
@ -508,7 +508,7 @@ var Document = function(text) {
range: range, range: range,
text: this.getNewLineCharacter() text: this.getNewLineCharacter()
}; };
this._emit("change", { data: delta }); this._signal("change", { data: delta });
}; };
/** /**

View file

@ -163,7 +163,7 @@ var EditSession = function(text, mode) {
config.resetOptions(this); config.resetOptions(this);
this.setMode(mode); 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.bgTokenizer.$updateOnChange(delta);
this._emit("change", e); this._signal("change", e);
}; };
/** /**
@ -528,7 +528,7 @@ var EditSession = function(text, mode) {
if (!this.$decorations[row]) if (!this.$decorations[row])
this.$decorations[row] = ""; this.$decorations[row] = "";
this.$decorations[row] += " " + className; 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.removeGutterDecoration = function(row, className) {
this.$decorations[row] = (this.$decorations[row] || "").replace(" " + 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<rows.length; i++) { for (var i=0; i<rows.length; i++) {
this.$breakpoints[rows[i]] = "ace_breakpoint"; this.$breakpoints[rows[i]] = "ace_breakpoint";
} }
this._emit("changeBreakpoint", {}); this._signal("changeBreakpoint", {});
}; };
/** /**
@ -571,7 +571,7 @@ var EditSession = function(text, mode) {
**/ **/
this.clearBreakpoints = function() { this.clearBreakpoints = function() {
this.$breakpoints = []; this.$breakpoints = [];
this._emit("changeBreakpoint", {}); this._signal("changeBreakpoint", {});
}; };
/** /**
@ -588,7 +588,7 @@ var EditSession = function(text, mode) {
this.$breakpoints[row] = className; this.$breakpoints[row] = className;
else else
delete this.$breakpoints[row]; delete this.$breakpoints[row];
this._emit("changeBreakpoint", {}); this._signal("changeBreakpoint", {});
}; };
/** /**
@ -599,7 +599,7 @@ var EditSession = function(text, mode) {
**/ **/
this.clearBreakpoint = function(row) { this.clearBreakpoint = function(row) {
delete this.$breakpoints[row]; delete this.$breakpoints[row];
this._emit("changeBreakpoint", {}); this._signal("changeBreakpoint", {});
}; };
/** /**
@ -626,10 +626,10 @@ var EditSession = function(text, mode) {
if (inFront) { if (inFront) {
this.$frontMarkers[id] = marker; this.$frontMarkers[id] = marker;
this._emit("changeFrontMarker") this._signal("changeFrontMarker")
} else { } else {
this.$backMarkers[id] = marker; this.$backMarkers[id] = marker;
this._emit("changeBackMarker") this._signal("changeBackMarker")
} }
return id; return id;
@ -652,10 +652,10 @@ var EditSession = function(text, mode) {
if (inFront) { if (inFront) {
this.$frontMarkers[id] = marker; this.$frontMarkers[id] = marker;
this._emit("changeFrontMarker") this._signal("changeFrontMarker")
} else { } else {
this.$backMarkers[id] = marker; this.$backMarkers[id] = marker;
this._emit("changeBackMarker") this._signal("changeBackMarker")
} }
return marker; return marker;
@ -676,7 +676,7 @@ var EditSession = function(text, mode) {
var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers; var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
if (marker) { if (marker) {
delete (markers[markerId]); delete (markers[markerId]);
this._emit(marker.inFront ? "changeFrontMarker" : "changeBackMarker"); this._signal(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
} }
}; };
@ -728,7 +728,7 @@ var EditSession = function(text, mode) {
**/ **/
this.setAnnotations = function(annotations) { this.setAnnotations = function(annotations) {
this.$annotations = annotations; this.$annotations = annotations;
this._emit("changeAnnotation", {}); this._signal("changeAnnotation", {});
}; };
/** /**
@ -858,7 +858,7 @@ var EditSession = function(text, mode) {
this.onReloadTokenizer = function(e) { this.onReloadTokenizer = function(e) {
var rows = e.data; var rows = e.data;
this.bgTokenizer.start(rows.first); this.bgTokenizer.start(rows.first);
this._emit("tokenizerUpdate", e); this._signal("tokenizerUpdate", e);
}; };
this.$modes = {}; this.$modes = {};
@ -937,7 +937,7 @@ var EditSession = function(text, mode) {
this.bgTokenizer = new BackgroundTokenizer(tokenizer); this.bgTokenizer = new BackgroundTokenizer(tokenizer);
var _self = this; var _self = this;
this.bgTokenizer.addEventListener("update", function(e) { this.bgTokenizer.addEventListener("update", function(e) {
_self._emit("tokenizerUpdate", e); _self._signal("tokenizerUpdate", e);
}); });
} else { } else {
this.bgTokenizer.setTokenizer(tokenizer); this.bgTokenizer.setTokenizer(tokenizer);
@ -1563,7 +1563,7 @@ var EditSession = function(text, mode) {
this.$updateWrapData(0, len - 1); this.$updateWrapData(0, len - 1);
} }
this._emit("changeWrapMode"); this._signal("changeWrapMode");
} }
}; };
@ -1594,7 +1594,7 @@ var EditSession = function(text, mode) {
}; };
this.$modified = true; this.$modified = true;
// This will force a recalculation of the wrap limit // This will force a recalculation of the wrap limit
this._emit("changeWrapMode"); this._signal("changeWrapMode");
} }
}; };
@ -1616,7 +1616,7 @@ var EditSession = function(text, mode) {
if (this.$useWrapMode) { if (this.$useWrapMode) {
this.$updateWrapData(0, this.getLength() - 1); this.$updateWrapData(0, this.getLength() - 1);
this.$resetRowCache(0); this.$resetRowCache(0);
this._emit("changeWrapLimit"); this._signal("changeWrapLimit");
} }
return true; return true;
} }
@ -2507,7 +2507,7 @@ config.defineOptions(EditSession.prototype, "session", {
initialValue: "auto" initialValue: "auto"
}, },
firstLineNumber: { firstLineNumber: {
set: function() {this._emit("changeBreakpoint");}, set: function() {this._signal("changeBreakpoint");},
initialValue: 1 initialValue: 1
}, },
useWorker: { useWorker: {
@ -2528,13 +2528,13 @@ config.defineOptions(EditSession.prototype, "session", {
this.$modified = true; this.$modified = true;
this.$rowLengthCache = []; this.$rowLengthCache = [];
this.$tabSize = tabSize; this.$tabSize = tabSize;
this._emit("changeTabSize"); this._signal("changeTabSize");
}, },
initialValue: 4, initialValue: 4,
handlesSet: true handlesSet: true
}, },
overwrite: { overwrite: {
set: function(val) {this._emit("changeOverwrite");}, set: function(val) {this._signal("changeOverwrite");},
initialValue: false initialValue: false
}, },
newLineMode: { newLineMode: {

View file

@ -102,7 +102,7 @@ var Editor = function(renderer, session) {
this.setSession(session || new EditSession("")); this.setSession(session || new EditSession(""));
config.resetOptions(this); config.resetOptions(this);
config._emit("editor", this); config._signal("editor", this);
}; };
(function(){ (function(){
@ -384,7 +384,7 @@ var Editor = function(renderer, session) {
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit(); this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
this.renderer.updateFull(); this.renderer.updateFull();
this._emit("changeSession", { this._signal("changeSession", {
session: session, session: session,
oldSession: oldSession oldSession: oldSession
}); });
@ -617,7 +617,7 @@ var Editor = function(renderer, session) {
lastRow = Infinity; lastRow = Infinity;
this.renderer.updateLines(range.start.row, lastRow); this.renderer.updateLines(range.start.row, lastRow);
this._emit("change", e); this._signal("change", e);
// update cursor because tab characters can influence the cursor position // update cursor because tab characters can influence the cursor position
this.$cursorChange(); this.$cursorChange();
@ -650,7 +650,7 @@ var Editor = function(renderer, session) {
this.$highlightBrackets(); this.$highlightBrackets();
this.$updateHighlightActiveLine(); this.$updateHighlightActiveLine();
this._emit("changeSelection"); this._signal("changeSelection");
}; };
this.$updateHighlightActiveLine = function() { this.$updateHighlightActiveLine = function() {
@ -675,7 +675,7 @@ var Editor = function(renderer, session) {
session.$highlightLineMarker.start.row = highlight.row; session.$highlightLineMarker.start.row = highlight.row;
session.$highlightLineMarker.end.row = highlight.row; session.$highlightLineMarker.end.row = highlight.row;
session.$highlightLineMarker.start.column = highlight.column; session.$highlightLineMarker.start.column = highlight.column;
session._emit("changeBackMarker"); session._signal("changeBackMarker");
} }
}; };
@ -698,7 +698,7 @@ var Editor = function(renderer, session) {
var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp(); var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp();
this.session.highlight(re); this.session.highlight(re);
this._emit("changeSelection"); this._signal("changeSelection");
}; };
this.$getSelectionHighLightRegexp = function() { this.$getSelectionHighLightRegexp = function() {
@ -2302,7 +2302,7 @@ var Editor = function(renderer, session) {
**/ **/
this.destroy = function() { this.destroy = function() {
this.renderer.destroy(); this.renderer.destroy();
this._emit("destroy", this); this._signal("destroy", this);
}; };
/** /**
@ -2379,7 +2379,7 @@ config.defineOptions(Editor.prototype, "editor", {
selectionStyle: { selectionStyle: {
set: function(style) { set: function(style) {
this.onSelectionChange(); this.onSelectionChange();
this._emit("changeSelectionStyle", {data: style}); this._signal("changeSelectionStyle", {data: style});
}, },
initialValue: "line" initialValue: "line"
}, },

View file

@ -108,8 +108,9 @@ exports.showErrorMarker = function(editor, dir) {
var gutterAnno; var gutterAnno;
if (annotations) { if (annotations) {
var annotation = annotations[0]; var annotation = annotations[0];
if (annotation.pos && annotation.column == null) pos.column = (annotation.pos && typeof annotation.column != "number"
pos.column = annotation.pos.sc; ? annotation.pos.sc
: annotation.column) || 0;
pos.row = annotation.row; pos.row = annotation.row;
gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row]; gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row];
} else if (oldWidget) { } else if (oldWidget) {

View file

@ -123,6 +123,7 @@ var supportedModes = {
SASS: ["sass"], SASS: ["sass"],
SCAD: ["scad"], SCAD: ["scad"],
Scala: ["scala"], Scala: ["scala"],
Smarty: ["smarty|tpl"],
Scheme: ["scm|rkt"], Scheme: ["scm|rkt"],
SCSS: ["scss"], SCSS: ["scss"],
SH: ["sh|bash|^.bashrc"], SH: ["sh|bash|^.bashrc"],

View file

@ -34,7 +34,7 @@ define(function(require, exports, module) {
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextMode = require("./text").Mode; var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer; 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 PythonFoldMode = require("./folding/pythonic").FoldMode;
var Range = require("../range").Range; var Range = require("../range").Range;

View file

@ -969,13 +969,11 @@ var PhpLangHighlightRules = function() {
else if (value == "debugger") else if (value == "debugger")
return "invalid.deprecated"; return "invalid.deprecated";
else 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 "variable";
return "identifier"; return "identifier";
}, },
// TODO: Unicode escape sequences regex : "[a-zA-Z_$\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\\b"
// TODO: Unicode identifiers
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, { }, {
onMatch : function(value, currentSate, state) { onMatch : function(value, currentSate, state) {
value = value.substr(3); value = value.substr(3);

58
lib/ace/mode/smarty.js Normal file
View file

@ -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;
});

View file

@ -0,0 +1,139 @@
/* ***** 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;
["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 (!this.$rules[x])
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;
});

View file

@ -59,6 +59,10 @@ var SqlHighlightRules = function() {
"start" : [ { "start" : [ {
token : "comment", token : "comment",
regex : "--.*$" regex : "--.*$"
}, {
token : "comment",
start : "/\\*",
end : "\\*/"
}, { }, {
token : "string", // " string token : "string", // " string
regex : '".*?"' regex : '".*?"'
@ -85,6 +89,7 @@ var SqlHighlightRules = function() {
regex : "\\s+" regex : "\\s+"
} ] } ]
}; };
this.normalizeRules();
}; };
oop.inherits(SqlHighlightRules, TextHighlightRules); oop.inherits(SqlHighlightRules, TextHighlightRules);

View file

@ -80,7 +80,9 @@ var TextHighlightRules = function() {
}; };
this.embedRules = function (HighlightRules, prefix, escapeRules, states, append) { this.embedRules = function (HighlightRules, prefix, escapeRules, states, append) {
var embedRules = new HighlightRules().getRules(); var embedRules = typeof HighlightRules == "function"
? new HighlightRules().getRules()
: HighlightRules;
if (states) { if (states) {
for (var i = 0; i < states.length; i++) for (var i = 0; i < states.length; i++)
states[i] = prefix + states[i]; states[i] = prefix + states[i];

View file

@ -100,7 +100,7 @@ var EditSession = require("./edit_session").EditSession;
this.$onRemoveRange(removed); this.$onRemoveRange(removed);
if (this.rangeCount > 1 && !this.inMultiSelectMode) { if (this.rangeCount > 1 && !this.inMultiSelectMode) {
this._emit("multiSelect"); this._signal("multiSelect");
this.inMultiSelectMode = true; this.inMultiSelectMode = true;
this.session.$undoSelect = false; this.session.$undoSelect = false;
this.rangeList.attach(this.session); this.rangeList.attach(this.session);
@ -150,7 +150,7 @@ var EditSession = require("./edit_session").EditSession;
this.$onAddRange = function(range) { this.$onAddRange = function(range) {
this.rangeCount = this.rangeList.ranges.length; this.rangeCount = this.rangeList.ranges.length;
this.ranges.unshift(range); this.ranges.unshift(range);
this._emit("addRange", {range: range}); this._signal("addRange", {range: range});
}; };
this.$onRemoveRange = function(removed) { this.$onRemoveRange = function(removed) {
@ -166,11 +166,11 @@ var EditSession = require("./edit_session").EditSession;
this.ranges.splice(index, 1); this.ranges.splice(index, 1);
} }
this._emit("removeRange", {ranges: removed}); this._signal("removeRange", {ranges: removed});
if (this.rangeCount == 0 && this.inMultiSelectMode) { if (this.rangeCount == 0 && this.inMultiSelectMode) {
this.inMultiSelectMode = false; this.inMultiSelectMode = false;
this._emit("singleSelect"); this._signal("singleSelect");
this.session.$undoSelect = true; this.session.$undoSelect = true;
this.rangeList.detach(this.session); this.rangeList.detach(this.session);
} }

View file

@ -169,7 +169,7 @@ var SnippetManager = function() {
// defult but can't fill :( // defult but can't fill :(
case "FILENAME": case "FILENAME":
case "FILEPATH": case "FILEPATH":
return "ace.ajax.org"; return "";
case "FULLNAME": case "FULLNAME":
return "Ace"; return "Ace";
} }
@ -329,8 +329,11 @@ var SnippetManager = function() {
continue; continue;
var id = p.tabstopId; var id = p.tabstopId;
var i1 = tokens.indexOf(p, i + 1); var i1 = tokens.indexOf(p, i + 1);
if (expanding[id] == p) { if (expanding[id]) {
expanding[id] = null; // if reached closing bracket clear expanding state
if (expanding[id] === p)
expanding[id] = null;
// otherwise just ignore recursive tabstop
continue; continue;
} }

View file

@ -7,8 +7,8 @@ snippet from
# Module Docstring # Module Docstring
snippet docs snippet docs
''' '''
File: ${1:`Filename('$1.py', 'foo.py')`} File: ${1:FILENAME:file_name}
Author: ${2:`g:snips_author`} Author: ${2:author}
Description: ${3} Description: ${3}
''' '''
snippet wh snippet wh
@ -129,7 +129,7 @@ snippet "
""" """
# test function/method # test function/method
snippet test snippet test
def test_${1:description}(${2:`indent('.') ? 'self' : ''`}): def test_${1:description}(${2:self}):
${3:# TODO: write code...} ${3:# TODO: write code...}
# test case # test case
snippet testcase snippet testcase

View file

@ -176,7 +176,7 @@ window.onmessage = function(e) {
main = new clazz(sender); main = new clazz(sender);
} }
else if (msg.event && sender) { else if (msg.event && sender) {
sender._emit(msg.event, msg.data); sender._signal(msg.event, msg.data);
} }
}; };
})(this); })(this);

View file

@ -96,7 +96,7 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
break; break;
case "event": case "event":
this._emit(msg.name, {data: msg.data}); this._signal(msg.name, {data: msg.data});
break; break;
case "call": case "call":
@ -121,7 +121,7 @@ var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
}; };
this.terminate = function() { this.terminate = function() {
this._emit("terminate", {}); this._signal("terminate", {});
this.deltaQueue = null; this.deltaQueue = null;
this.$worker.terminate(); this.$worker.terminate();
this.$worker = null; this.$worker = null;
@ -217,7 +217,7 @@ var UIWorkerClient = function(topLevelNamespaces, mod, classname) {
if (msg.command) if (msg.command)
main[msg.command].apply(main, msg.args); main[msg.command].apply(main, msg.args);
else if (msg.event) else if (msg.event)
sender._emit(msg.event, msg.data); sender._signal(msg.event, msg.data);
}; };
sender.postMessage = function(msg) { sender.postMessage = function(msg) {