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 = [
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)

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.column = pos.column;
this._emit("change", {
this._signal("change", {
old: old,
value: pos
});

View file

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

View file

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

View file

@ -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<rows.length; i++) {
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.$breakpoints = [];
this._emit("changeBreakpoint", {});
this._signal("changeBreakpoint", {});
};
/**
@ -588,7 +588,7 @@ var EditSession = function(text, mode) {
this.$breakpoints[row] = className;
else
delete this.$breakpoints[row];
this._emit("changeBreakpoint", {});
this._signal("changeBreakpoint", {});
};
/**
@ -599,7 +599,7 @@ var EditSession = function(text, mode) {
**/
this.clearBreakpoint = function(row) {
delete this.$breakpoints[row];
this._emit("changeBreakpoint", {});
this._signal("changeBreakpoint", {});
};
/**
@ -626,10 +626,10 @@ var EditSession = function(text, mode) {
if (inFront) {
this.$frontMarkers[id] = marker;
this._emit("changeFrontMarker")
this._signal("changeFrontMarker")
} else {
this.$backMarkers[id] = marker;
this._emit("changeBackMarker")
this._signal("changeBackMarker")
}
return id;
@ -652,10 +652,10 @@ var EditSession = function(text, mode) {
if (inFront) {
this.$frontMarkers[id] = marker;
this._emit("changeFrontMarker")
this._signal("changeFrontMarker")
} else {
this.$backMarkers[id] = marker;
this._emit("changeBackMarker")
this._signal("changeBackMarker")
}
return marker;
@ -676,7 +676,7 @@ var EditSession = function(text, mode) {
var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
if (marker) {
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.$annotations = annotations;
this._emit("changeAnnotation", {});
this._signal("changeAnnotation", {});
};
/**
@ -858,7 +858,7 @@ var EditSession = function(text, mode) {
this.onReloadTokenizer = function(e) {
var rows = e.data;
this.bgTokenizer.start(rows.first);
this._emit("tokenizerUpdate", e);
this._signal("tokenizerUpdate", e);
};
this.$modes = {};
@ -937,7 +937,7 @@ var EditSession = function(text, mode) {
this.bgTokenizer = new BackgroundTokenizer(tokenizer);
var _self = this;
this.bgTokenizer.addEventListener("update", function(e) {
_self._emit("tokenizerUpdate", e);
_self._signal("tokenizerUpdate", e);
});
} else {
this.bgTokenizer.setTokenizer(tokenizer);
@ -1563,7 +1563,7 @@ var EditSession = function(text, mode) {
this.$updateWrapData(0, len - 1);
}
this._emit("changeWrapMode");
this._signal("changeWrapMode");
}
};
@ -1594,7 +1594,7 @@ var EditSession = function(text, mode) {
};
this.$modified = true;
// 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) {
this.$updateWrapData(0, this.getLength() - 1);
this.$resetRowCache(0);
this._emit("changeWrapLimit");
this._signal("changeWrapLimit");
}
return true;
}
@ -2507,7 +2507,7 @@ config.defineOptions(EditSession.prototype, "session", {
initialValue: "auto"
},
firstLineNumber: {
set: function() {this._emit("changeBreakpoint");},
set: function() {this._signal("changeBreakpoint");},
initialValue: 1
},
useWorker: {
@ -2528,13 +2528,13 @@ config.defineOptions(EditSession.prototype, "session", {
this.$modified = true;
this.$rowLengthCache = [];
this.$tabSize = tabSize;
this._emit("changeTabSize");
this._signal("changeTabSize");
},
initialValue: 4,
handlesSet: true
},
overwrite: {
set: function(val) {this._emit("changeOverwrite");},
set: function(val) {this._signal("changeOverwrite");},
initialValue: false
},
newLineMode: {

View file

@ -102,7 +102,7 @@ var Editor = function(renderer, session) {
this.setSession(session || new EditSession(""));
config.resetOptions(this);
config._emit("editor", this);
config._signal("editor", this);
};
(function(){
@ -384,7 +384,7 @@ var Editor = function(renderer, session) {
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
this.renderer.updateFull();
this._emit("changeSession", {
this._signal("changeSession", {
session: session,
oldSession: oldSession
});
@ -617,7 +617,7 @@ var Editor = function(renderer, session) {
lastRow = Infinity;
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
this.$cursorChange();
@ -650,7 +650,7 @@ var Editor = function(renderer, session) {
this.$highlightBrackets();
this.$updateHighlightActiveLine();
this._emit("changeSelection");
this._signal("changeSelection");
};
this.$updateHighlightActiveLine = function() {
@ -675,7 +675,7 @@ var Editor = function(renderer, session) {
session.$highlightLineMarker.start.row = highlight.row;
session.$highlightLineMarker.end.row = highlight.row;
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();
this.session.highlight(re);
this._emit("changeSelection");
this._signal("changeSelection");
};
this.$getSelectionHighLightRegexp = function() {
@ -2302,7 +2302,7 @@ var Editor = function(renderer, session) {
**/
this.destroy = function() {
this.renderer.destroy();
this._emit("destroy", this);
this._signal("destroy", this);
};
/**
@ -2379,7 +2379,7 @@ config.defineOptions(Editor.prototype, "editor", {
selectionStyle: {
set: function(style) {
this.onSelectionChange();
this._emit("changeSelectionStyle", {data: style});
this._signal("changeSelectionStyle", {data: style});
},
initialValue: "line"
},

View file

@ -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) {

View file

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

View file

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

View file

@ -0,0 +1,569 @@
/*
* MUSHCodeMode
*/
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var MushCodeRules = function() {
var keywords = (
"@if|"+
"@ifelse|"+
"@switch|"+
"@halt|"+
"@dolist|"+
"@create|"+
"@scent|"+
"@sound|"+
"@touch|"+
"@ataste|"+
"@osound|"+
"@ahear|"+
"@aahear|"+
"@amhear|"+
"@otouch|"+
"@otaste|"+
"@drop|"+
"@odrop|"+
"@adrop|"+
"@dropfail|"+
"@odropfail|"+
"@smell|"+
"@oemit|"+
"@emit|"+
"@pemit|"+
"@parent|"+
"@clone|"+
"@taste|"+
"whisper|"+
"page|"+
"say|"+
"pose|"+
"semipose|"+
"teach|"+
"touch|"+
"taste|"+
"smell|"+
"listen|"+
"look|"+
"move|"+
"go|"+
"home|"+
"follow|"+
"unfollow|"+
"desert|"+
"dismiss|"+
"@tel"
);
var builtinConstants = (
"=#0"
);
var builtinFunctions = (
"default|"+
"edefault|"+
"eval|"+
"get_eval|"+
"get|"+
"grep|"+
"grepi|"+
"hasattr|"+
"hasattrp|"+
"hasattrval|"+
"hasattrpval|"+
"lattr|"+
"nattr|"+
"poss|"+
"udefault|"+
"ufun|"+
"u|"+
"v|"+
"uldefault|"+
"xget|"+
"zfun|"+
"band|"+
"bnand|"+
"bnot|"+
"bor|"+
"bxor|"+
"shl|"+
"shr|"+
"and|"+
"cand|"+
"cor|"+
"eq|"+
"gt|"+
"gte|"+
"lt|"+
"lte|"+
"nand|"+
"neq|"+
"nor|"+
"not|"+
"or|"+
"t|"+
"xor|"+
"con|"+
"entrances|"+
"exit|"+
"followers|"+
"home|"+
"lcon|"+
"lexits|"+
"loc|"+
"locate|"+
"lparent|"+
"lsearch|"+
"next|"+
"num|"+
"owner|"+
"parent|"+
"pmatch|"+
"rloc|"+
"rnum|"+
"room|"+
"where|"+
"zone|"+
"worn|"+
"held|"+
"carried|"+
"acos|"+
"asin|"+
"atan|"+
"ceil|"+
"cos|"+
"e|"+
"exp|"+
"fdiv|"+
"fmod|"+
"floor|"+
"log|"+
"ln|"+
"pi|"+
"power|"+
"round|"+
"sin|"+
"sqrt|"+
"tan|"+
"aposs|"+
"andflags|"+
"conn|"+
"commandssent|"+
"controls|"+
"doing|"+
"elock|"+
"findable|"+
"flags|"+
"fullname|"+
"hasflag|"+
"haspower|"+
"hastype|"+
"hidden|"+
"idle|"+
"isbaker|"+
"lock|"+
"lstats|"+
"money|"+
"who|"+
"name|"+
"nearby|"+
"obj|"+
"objflags|"+
"photo|"+
"poll|"+
"powers|"+
"pendingtext|"+
"receivedtext|"+
"restarts|"+
"restarttime|"+
"subj|"+
"shortestpath|"+
"tmoney|"+
"type|"+
"visible|"+
"cat|"+
"element|"+
"elements|"+
"extract|"+
"filter|"+
"filterbool|"+
"first|"+
"foreach|"+
"fold|"+
"grab|"+
"graball|"+
"index|"+
"insert|"+
"itemize|"+
"items|"+
"iter|"+
"last|"+
"ldelete|"+
"map|"+
"match|"+
"matchall|"+
"member|"+
"mix|"+
"munge|"+
"pick|"+
"remove|"+
"replace|"+
"rest|"+
"revwords|"+
"setdiff|"+
"setinter|"+
"setunion|"+
"shuffle|"+
"sort|"+
"sortby|"+
"splice|"+
"step|"+
"wordpos|"+
"words|"+
"add|"+
"lmath|"+
"max|"+
"mean|"+
"median|"+
"min|"+
"mul|"+
"percent|"+
"sign|"+
"stddev|"+
"sub|"+
"val|"+
"bound|"+
"abs|"+
"inc|"+
"dec|"+
"dist2d|"+
"dist3d|"+
"div|"+
"floordiv|"+
"mod|"+
"modulo|"+
"remainder|"+
"vadd|"+
"vdim|"+
"vdot|"+
"vmag|"+
"vmax|"+
"vmin|"+
"vmul|"+
"vsub|"+
"vunit|"+
"regedit|"+
"regeditall|"+
"regeditalli|"+
"regediti|"+
"regmatch|"+
"regmatchi|"+
"regrab|"+
"regraball|"+
"regraballi|"+
"regrabi|"+
"regrep|"+
"regrepi|"+
"after|"+
"alphamin|"+
"alphamax|"+
"art|"+
"before|"+
"brackets|"+
"capstr|"+
"case|"+
"caseall|"+
"center|"+
"containsfansi|"+
"comp|"+
"decompose|"+
"decrypt|"+
"delete|"+
"edit|"+
"encrypt|"+
"escape|"+
"if|"+
"ifelse|"+
"lcstr|"+
"left|"+
"lit|"+
"ljust|"+
"merge|"+
"mid|"+
"ostrlen|"+
"pos|"+
"repeat|"+
"reverse|"+
"right|"+
"rjust|"+
"scramble|"+
"secure|"+
"space|"+
"spellnum|"+
"squish|"+
"strcat|"+
"strmatch|"+
"strinsert|"+
"stripansi|"+
"stripfansi|"+
"strlen|"+
"switch|"+
"switchall|"+
"table|"+
"tr|"+
"trim|"+
"ucstr|"+
"unsafe|"+
"wrap|"+
"ctitle|"+
"cwho|"+
"channels|"+
"clock|"+
"cflags|"+
"ilev|"+
"itext|"+
"inum|"+
"convsecs|"+
"convutcsecs|"+
"convtime|"+
"ctime|"+
"etimefmt|"+
"isdaylight|"+
"mtime|"+
"secs|"+
"msecs|"+
"starttime|"+
"time|"+
"timefmt|"+
"timestring|"+
"utctime|"+
"atrlock|"+
"clone|"+
"create|"+
"cook|"+
"dig|"+
"emit|"+
"lemit|"+
"link|"+
"oemit|"+
"open|"+
"pemit|"+
"remit|"+
"set|"+
"tel|"+
"wipe|"+
"zemit|"+
"fbcreate|"+
"fbdestroy|"+
"fbwrite|"+
"fbclear|"+
"fbcopy|"+
"fbcopyto|"+
"fbclip|"+
"fbdump|"+
"fbflush|"+
"fbhset|"+
"fblist|"+
"fbstats|"+
"qentries|"+
"qentry|"+
"play|"+
"ansi|"+
"break|"+
"c|"+
"asc|"+
"die|"+
"isdbref|"+
"isint|"+
"isnum|"+
"isletters|"+
"linecoords|"+
"localize|"+
"lnum|"+
"nameshort|"+
"null|"+
"objeval|"+
"r|"+
"rand|"+
"s|"+
"setq|"+
"setr|"+
"soundex|"+
"soundslike|"+
"valid|"+
"vchart|"+
"vchart2|"+
"vlabel|"+
"@@|"+
"bakerdays|"+
"bodybuild|"+
"box|"+
"capall|"+
"catalog|"+
"children|"+
"ctrailer|"+
"darttime|"+
"debt|"+
"detailbar|"+
"exploredroom|"+
"fansitoansi|"+
"fansitoxansi|"+
"fullbar|"+
"halfbar|"+
"isdarted|"+
"isnewbie|"+
"isword|"+
"lambda|"+
"lobjects|"+
"lplayers|"+
"lthings|"+
"lvexits|"+
"lvobjects|"+
"lvplayers|"+
"lvthings|"+
"newswrap|"+
"numsuffix|"+
"playerson|"+
"playersthisweek|"+
"randomad|"+
"randword|"+
"realrandword|"+
"replacechr|"+
"second|"+
"splitamount|"+
"strlenall|"+
"text|"+
"third|"+
"tofansi|"+
"totalac|"+
"unique|"+
"getaddressroom|"+
"listpropertycomm|"+
"listpropertyres|"+
"lotowner|"+
"lotrating|"+
"lotratingcount|"+
"lotvalue|"+
"boughtproduct|"+
"companyabb|"+
"companyicon|"+
"companylist|"+
"companyname|"+
"companyowners|"+
"companyvalue|"+
"employees|"+
"invested|"+
"productlist|"+
"productname|"+
"productowners|"+
"productrating|"+
"productratingcount|"+
"productsoldat|"+
"producttype|"+
"ratedproduct|"+
"soldproduct|"+
"topproducts|"+
"totalspentonproduct|"+
"totalstock|"+
"transfermoney|"+
"uniquebuyercount|"+
"uniqueproductsbought|"+
"validcompany|"+
"deletepicture|"+
"fbsave|"+
"getpicturesecurity|"+
"haspicture|"+
"listpictures|"+
"picturesize|"+
"replacecolor|"+
"rgbtocolor|"+
"savepicture|"+
"setpicturesecurity|"+
"showpicture|"+
"piechart|"+
"piechartlabel|"+
"createmaze|"+
"drawmaze|"+
"drawwireframe"
);
var keywordMapper = this.createKeywordMapper({
"invalid.deprecated": "debugger",
"support.function": builtinFunctions,
"constant.language": builtinConstants,
"keyword": keywords
}, "identifier");
var strPre = "(?:r|u|ur|R|U|UR|Ur|uR)?";
var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))";
var octInteger = "(?:0[oO]?[0-7]+)";
var hexInteger = "(?:0[xX][\\dA-Fa-f]+)";
var binInteger = "(?:0[bB][01]+)";
var integer = "(?:" + decimalInteger + "|" + octInteger + "|" + hexInteger + "|" + binInteger + ")";
var exponent = "(?:[eE][+-]?\\d+)";
var fraction = "(?:\\.\\d+)";
var intPart = "(?:\\d+)";
var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))";
var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + exponent + ")";
var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")";
this.$rules = {
"start" : [
{
token : "variable", // mush substitution register
regex : "%[0-9]{1}"
},
{
token : "variable", // mush substitution register
regex : "%q[0-9A-Za-z]{1}"
},
{
token : "variable", // mush special character register
regex : "%[a-zA-Z]{1}"
},
{
token: "variable.language",
regex: "%[a-z0-9-_]+"
},
{
token : "constant.numeric", // imaginary
regex : "(?:" + floatNumber + "|\\d+)[jJ]\\b"
}, {
token : "constant.numeric", // float
regex : floatNumber
}, {
token : "constant.numeric", // long integer
regex : integer + "[lL]\\b"
}, {
token : "constant.numeric", // integer
regex : integer + "\\b"
}, {
token : keywordMapper,
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token : "keyword.operator",
regex : "\\+|\\-|\\*|\\*\\*|\\/|\\/\\/|#|%|<<|>>|\\||\\^|~|<|>|<=|=>|==|!=|<>|="
}, {
token : "paren.lparen",
regex : "[\\[\\(\\{]"
}, {
token : "paren.rparen",
regex : "[\\]\\)\\}]"
}, {
token : "text",
regex : "\\s+"
} ]
};
};
oop.inherits(MushCodeRules, TextHighlightRules);
exports.MushCodeRules = MushCodeRules;
});

View file

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

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" : [ {
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);

View file

@ -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];

View file

@ -100,7 +100,7 @@ var EditSession = require("./edit_session").EditSession;
this.$onRemoveRange(removed);
if (this.rangeCount > 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);
}

View file

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

View file

@ -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

View file

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

Some files were not shown because too many files have changed in this diff Show more