Merge master

This commit is contained in:
Garen Torikian 2012-04-10 10:39:55 -07:00
commit fc4625e1b6
335 changed files with 25316 additions and 11663 deletions

2
.gitignore vendored
View file

@ -22,7 +22,7 @@ node_modules/mime/
node_modules/dryice/ node_modules/dryice/
node_modules/uglify-js/ node_modules/uglify-js/
node_modules/.bin/ node_modules/.bin/
tool/node_modules/
.git-ref .git-ref
npm-debug.log npm-debug.log

View file

@ -218,9 +218,9 @@ function buildAce(aceProject, options) {
compat: true, compat: true,
modes: [ modes: [
"css", "html", "javascript", "php", "coldfusion", "python", "lua", "xml", "ruby", "java", "c_cpp", "css", "html", "javascript", "php", "coldfusion", "python", "lua", "xml", "ruby", "java", "c_cpp",
"coffee", "perl", "csharp", "haxe", "svg", "clojure", "scss", "json", "groovy", "coffee", "perl", "csharp", "haxe", "liquid", "svg", "clojure", "scss", "json", "groovy",
"ocaml", "scala", "textile", "scad", "markdown", "latex", "powershell", "sql", "ocaml", "scala", "textile", "scad", "markdown", "latex", "powershell", "sql",
"text", "pgsql", "sh" "text", "pgsql", "sh", "xquery"
], ],
themes: [ themes: [
"chrome", "clouds", "clouds_midnight", "cobalt", "crimson_editor", "dawn", "chrome", "clouds", "clouds_midnight", "cobalt", "crimson_editor", "dawn",

View file

@ -244,7 +244,7 @@ exportAce(ACE_NAMESPACE);
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
define('kitchen-sink/demo', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/config', 'ace/lib/event', 'ace/theme/textmate', 'ace/edit_session', 'ace/undomanager', 'ace/keyboard/keybinding/vim', 'ace/keyboard/keybinding/emacs', 'ace/keyboard/hash_handler', 'text!kitchen-sink/docs/plaintext.txt', 'text!kitchen-sink/docs/javascript.js', 'text!kitchen-sink/docs/coffeescript.coffee', 'text!kitchen-sink/docs/json.json', 'text!kitchen-sink/docs/css.css', 'text!kitchen-sink/docs/scss.scss', 'text!kitchen-sink/docs/html.html', 'text!kitchen-sink/docs/xml.xml', 'text!kitchen-sink/docs/svg.svg', 'text!kitchen-sink/docs/php.php', 'text!kitchen-sink/docs/coldfusion.cfm', 'text!kitchen-sink/docs/python.py', 'text!kitchen-sink/docs/ruby.rb', 'text!kitchen-sink/docs/perl.pl', 'text!kitchen-sink/docs/ocaml.ml', 'text!kitchen-sink/docs/lua.lua', 'text!kitchen-sink/docs/java.java', 'text!kitchen-sink/docs/clojure.clj', 'text!kitchen-sink/docs/groovy.groovy', 'text!kitchen-sink/docs/scala.scala', 'text!kitchen-sink/docs/csharp.cs', 'text!kitchen-sink/docs/powershell.ps1', 'text!kitchen-sink/docs/cpp.cpp', 'text!kitchen-sink/docs/Haxe.hx', 'text!kitchen-sink/docs/sh.sh', 'text!kitchen-sink/docs/markdown.md', 'text!kitchen-sink/docs/textile.textile', 'text!kitchen-sink/docs/latex.tex', 'text!kitchen-sink/docs/sql.sql', 'text!kitchen-sink/docs/pgsql.pgsql', 'ace/split'], function(require, exports, module) { define('kitchen-sink/demo', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/config', 'ace/lib/event', 'ace/theme/textmate', 'ace/edit_session', 'ace/undomanager', 'ace/keyboard/keybinding/vim', 'ace/keyboard/keybinding/emacs', 'ace/keyboard/hash_handler', 'text!kitchen-sink/docs/plaintext.txt', 'text!kitchen-sink/docs/javascript.js', 'text!kitchen-sink/docs/coffeescript.coffee', 'text!kitchen-sink/docs/json.json', 'text!kitchen-sink/docs/css.css', 'text!kitchen-sink/docs/scss.scss', 'text!kitchen-sink/docs/html.html', 'text!kitchen-sink/docs/xml.xml', 'text!kitchen-sink/docs/svg.svg', 'text!kitchen-sink/docs/php.php', 'text!kitchen-sink/docs/coldfusion.cfm', 'text!kitchen-sink/docs/python.py', 'text!kitchen-sink/docs/ruby.rb', 'text!kitchen-sink/docs/perl.pl', 'text!kitchen-sink/docs/ocaml.ml', 'text!kitchen-sink/docs/lua.lua', 'text!kitchen-sink/docs/liquid.liquid', 'text!kitchen-sink/docs/java.java', 'text!kitchen-sink/docs/clojure.clj', 'text!kitchen-sink/docs/groovy.groovy', 'text!kitchen-sink/docs/scala.scala', 'text!kitchen-sink/docs/csharp.cs', 'text!kitchen-sink/docs/powershell.ps1', 'text!kitchen-sink/docs/cpp.cpp', 'text!kitchen-sink/docs/Haxe.hx', 'text!kitchen-sink/docs/sh.sh', 'text!kitchen-sink/docs/xquery.xq', 'text!kitchen-sink/docs/markdown.md', 'text!kitchen-sink/docs/textile.textile', 'text!kitchen-sink/docs/latex.tex', 'text!kitchen-sink/docs/sql.sql', 'text!kitchen-sink/docs/pgsql.pgsql', 'ace/split'], function(require, exports, module) {
require("ace/lib/fixoldbrowsers"); require("ace/lib/fixoldbrowsers");
require("ace/config").init(); require("ace/config").init();
@ -266,7 +266,6 @@ var Doc = function(name, desc, file) {
this.name = name; this.name = name;
this.desc = desc; this.desc = desc;
this.doc = new EditSession(file); this.doc = new EditSession(file);
this.doc.setMode(modesByName[name].mode);
this.doc.modeName = name; this.doc.modeName = name;
this.doc.setUndoManager(new UndoManager()); this.doc.setUndoManager(new UndoManager());
}; };
@ -304,6 +303,7 @@ var modes = [
new Mode("json", "JSON", ["json"]), new Mode("json", "JSON", ["json"]),
new Mode("latex", "LaTeX", ["tex"]), new Mode("latex", "LaTeX", ["tex"]),
new Mode("lua", "Lua", ["lua"]), new Mode("lua", "Lua", ["lua"]),
new Mode("liquid", "Liquid", ["liquid"]),
new Mode("markdown", "Markdown", ["md", "markdown"]), new Mode("markdown", "Markdown", ["md", "markdown"]),
new Mode("ocaml", "OCaml", ["ml", "mli"]), new Mode("ocaml", "OCaml", ["ml", "mli"]),
new Mode("perl", "Perl", ["pl", "pm"]), new Mode("perl", "Perl", ["pl", "pm"]),
@ -319,7 +319,8 @@ var modes = [
new Mode("text", "Text", ["txt"]), new Mode("text", "Text", ["txt"]),
new Mode("textile", "Textile", ["textile"]), new Mode("textile", "Textile", ["textile"]),
new Mode("xml", "XML", ["xml"]), new Mode("xml", "XML", ["xml"]),
new Mode("sh", "SH", ["sh"]) new Mode("sh", "SH", ["sh"]),
new Mode("xquery", "XQuery", ["xq"])
]; ];
modesByName = {}; modesByName = {};
@ -394,6 +395,10 @@ var docs = [
"lua", "Lua", "lua", "Lua",
require("text!./docs/lua.lua") require("text!./docs/lua.lua")
), ),
new Doc(
"liquid", "Liquid",
require("text!./docs/liquid.liquid")
),
new Doc( new Doc(
"java", "Java", "java", "Java",
require("text!./docs/java.java") require("text!./docs/java.java")
@ -430,6 +435,10 @@ var docs = [
"sh", "SH", "sh", "SH",
require("text!./docs/sh.sh") require("text!./docs/sh.sh")
), ),
new Doc(
"xquery", "XQuery",
require("text!./docs/xquery.xq")
),
new WrappedDoc( new WrappedDoc(
"markdown", "Markdown", "markdown", "Markdown",
require("text!./docs/markdown.md") require("text!./docs/markdown.md")
@ -517,6 +526,12 @@ modes.forEach(function(mode) {
bindDropdown("doc", function(value) { bindDropdown("doc", function(value) {
var doc = docsByName[value].doc; var doc = docsByName[value].doc;
if (!docsByName[value].initialized) {
docsByName[value].initialized = true;
doc.setMode(modesByName[docsByName[value].name].mode);
}
var session = env.split.setSession(doc); var session = env.split.setSession(doc);
session.name = doc.name; session.name = doc.name;
@ -3853,6 +3868,10 @@ var EditSession = function(text, mode) {
return callback(_self.$modes[mode]); return callback(_self.$modes[mode]);
_self.$modes[mode] = new module.Mode(); _self.$modes[mode] = new module.Mode();
_self._emit("loadmode", {
name: mode,
mode: _self.$modes[mode]
});
callback(_self.$modes[mode]); callback(_self.$modes[mode]);
} }
@ -6395,6 +6414,10 @@ var Tokenizer = function(rules, flag) {
var mapping = this.matchMappings[key] = {}; var mapping = this.matchMappings[key] = {};
for ( var i = 0; i < state.length; i++) { for ( var i = 0; i < state.length; i++) {
if (state[i].regex instanceof RegExp)
state[i].regex = state[i].regex.toString().slice(1, -1);
// Count number of matching groups. 2 extra groups from the full match // Count number of matching groups. 2 extra groups from the full match
// And the catch-all on the end (used to force a match); // And the catch-all on the end (used to force a match);
var matchcount = new RegExp("(?:(" + state[i].regex + ")|(.))").exec("a").length - 2; var matchcount = new RegExp("(?:(" + state[i].regex + ")|(.))").exec("a").length - 2;
@ -6404,6 +6427,9 @@ var Tokenizer = function(rules, flag) {
return "\\" + (parseInt(digit, 10) + matchTotal + 1); return "\\" + (parseInt(digit, 10) + matchTotal + 1);
}); });
if (matchcount > 1 && state[i].token.length !== matchcount-1)
throw new Error("Matching groups and length of the token array don't match in rule #" + i + " of state " + key);
mapping[matchTotal] = { mapping[matchTotal] = {
rule: i, rule: i,
len: matchcount len: matchcount
@ -6441,31 +6467,31 @@ var Tokenizer = function(rules, flag) {
var value = [match[0]]; var value = [match[0]];
for (var i = 0; i < match.length-2; i++) { for (var i = 0; i < match.length-2; i++) {
if (match[i + 1] !== undefined) { if (match[i + 1] === undefined)
rule = state[mapping[i].rule]; continue;
if (mapping[i].len > 1) { rule = state[mapping[i].rule];
value = match.slice(i+2, i+1+mapping[i].len);
}
// compute token type if (mapping[i].len > 1)
if (typeof rule.token == "function") value = match.slice(i+2, i+1+mapping[i].len);
type = rule.token.apply(this, value);
else
type = rule.token;
var next = rule.next; // compute token type
if (next && next !== currentState) { if (typeof rule.token == "function")
currentState = next; type = rule.token.apply(this, value);
state = this.rules[currentState]; else
mapping = this.matchMappings[currentState]; type = rule.token;
lastIndex = re.lastIndex;
re = this.regExps[currentState]; var next = rule.next;
re.lastIndex = lastIndex; if (next && next !== currentState) {
} currentState = next;
break; state = this.rules[currentState];
mapping = this.matchMappings[currentState];
lastIndex = re.lastIndex;
re = this.regExps[currentState];
re.lastIndex = lastIndex;
} }
break;
} }
if (value[0]) { if (value[0]) {
@ -6474,12 +6500,14 @@ var Tokenizer = function(rules, flag) {
type = [type]; type = [type];
} }
for (var i = 0; i < value.length; i++) { for (var i = 0; i < value.length; i++) {
if (!value[i])
continue;
if ((!rule || rule.merge || type[i] === "text") && token.type === type[i]) { if ((!rule || rule.merge || type[i] === "text") && token.type === type[i]) {
token.value += value[i]; token.value += value[i];
} else { } else {
if (token.type) { if (token.type)
tokens.push(token); tokens.push(token);
}
token = { token = {
type: type[i], type: type[i],
@ -7002,6 +7030,7 @@ var Document = function(text) {
position = this.$clipPosition(position); position = this.$clipPosition(position);
// only detect new lines if the document has no line break yet
if (this.getLength() <= 1) if (this.getLength() <= 1)
this.$detectNewLine(text); this.$detectNewLine(text);
@ -10258,6 +10287,84 @@ define("text!kitchen-sink/docs/lua.lua", [], "--[[--\n" +
"print(table.maxn{1,2,[4]=4,[8]=8) -- outputs 8 instead of 2\n" + "print(table.maxn{1,2,[4]=4,[8]=8) -- outputs 8 instead of 2\n" +
""); "");
define("text!kitchen-sink/docs/liquid.liquid", [], "The following examples can be found in full at http://liquidmarkup.org/\n" +
"\n" +
"Liquid is an extraction from the e-commerce system Shopify.\n" +
"Shopify powers many thousands of e-commerce stores which all call for unique designs.\n" +
"For this we developed Liquid which allows our customers complete design freedom while\n" +
"maintaining the integrity of our servers.\n" +
"\n" +
"Liquid has been in production use since June 2006 and is now used by many other\n" +
"hosted web applications.\n" +
"\n" +
"It was developed for usage in Ruby on Rails web applications and integrates seamlessly\n" +
"as a plugin but it also works excellently as a stand alone library.\n" +
"\n" +
"Here's what it looks like:\n" +
"\n" +
" <ul id=\"products\">\n" +
" {% for product in products %}\n" +
" <li>\n" +
" <h2>{{ product.title }}</h2>\n" +
" Only {{ product.price | format_as_money }}\n" +
"\n" +
" <p>{{ product.description | prettyprint | truncate: 200 }}</p>\n" +
"\n" +
" </li>\n" +
" {% endfor %}\n" +
" </ul>\n" +
"\n" +
"\n" +
"Some more features include:\n" +
"\n" +
"<h2>Filters</h2>\n" +
"<p> The word \"tobi\" in uppercase: {{ 'tobi' | upcase }} </p>\n" +
"<p>The word \"tobi\" has {{ 'tobi' | size }} letters! </p>\n" +
"<p>Change \"Hello world\" to \"Hi world\": {{ 'Hello world' | replace: 'Hello', 'Hi' }} </p>\n" +
"<p>The date today is {{ 'now' | date: \"%Y %b %d\" }} </p>\n" +
"\n" +
"\n" +
"<h2>If</h2>\n" +
"<p>\n" +
" {% if user.name == 'tobi' or user.name == 'marc' %} \n" +
" hi marc or tobi\n" +
" {% endif %}\n" +
"</p>\n" +
"\n" +
"\n" +
"<h2>Case</h2>\n" +
"<p>\n" +
" {% case template %}\n" +
" {% when 'index' %}\n" +
" Welcome\n" +
" {% when 'product' %}\n" +
" {{ product.vendor | link_to_vendor }} / {{ product.title }}\n" +
" {% else %}\n" +
" {{ page_title }}\n" +
" {% endcase %}\n" +
"</p>\n" +
"\n" +
"\n" +
"<h2>For Loops</h2>\n" +
"<p>\n" +
" {% for item in array %} \n" +
" {{ item }}\n" +
" {% endfor %}\n" +
"</p>\n" +
"\n" +
"\n" +
"<h2>Tables</h2>\n" +
"<p>\n" +
" {% tablerow item in items cols: 3 %}\n" +
" {% if tablerowloop.col_first %}\n" +
" First column: {{ item.variable }}\n" +
" {% else %}\n" +
" Different column: {{ item.variable }}\n" +
" {% endif %}\n" +
" {% endtablerow %}\n" +
"</p>\n" +
"");
define("text!kitchen-sink/docs/java.java", [], "public class InfiniteLoop {\n" + define("text!kitchen-sink/docs/java.java", [], "public class InfiniteLoop {\n" +
"\n" + "\n" +
" /*\n" + " /*\n" +
@ -10509,6 +10616,14 @@ define("text!kitchen-sink/docs/sh.sh", [], "#!/bin/sh\n" +
"fi\n" + "fi\n" +
""); "");
define("text!kitchen-sink/docs/xquery.xq", [], "xquery version \"1.0\";\n" +
"\n" +
"let $message := \"Hello World!\"\n" +
"return <results>\n" +
" <message>{$message}</message>\n" +
"</results>\n" +
"");
define("text!kitchen-sink/docs/markdown.md", [], "Ace (Ajax.org Cloud9 Editor)\n" + define("text!kitchen-sink/docs/markdown.md", [], "Ace (Ajax.org Cloud9 Editor)\n" +
"============================\n" + "============================\n" +
"\n" + "\n" +
@ -11472,7 +11587,11 @@ var Editor = function(renderer, session) {
this.renderer.updateCursor(); this.renderer.updateCursor();
if (!this.$blockScrolling) { if (!this.$blockScrolling) {
this.renderer.scrollCursorIntoView(); var selection = this.getSelection();
if (selection.isEmpty())
this.renderer.scrollCursorIntoView(selection.getCursor());
else
this.renderer.scrollSelectionIntoView(selection.getSelectionLead(), selection.getSelectionAnchor());
} }
// move text input over the cursor // move text input over the cursor
@ -11754,6 +11873,14 @@ var Editor = function(renderer, session) {
return this.$highlightSelectedWord; return this.$highlightSelectedWord;
}; };
this.setAnimatedScroll = function(shouldAnimate){
this.renderer.setAnimatedScroll(shouldAnimate);
}
this.getAnimatedScroll = function(){
this.rendered.getAnimatedScroll();
}
this.setShowInvisibles = function(showInvisibles) { this.setShowInvisibles = function(showInvisibles) {
if (this.getShowInvisibles() == showInvisibles) if (this.getShowInvisibles() == showInvisibles)
return; return;
@ -13920,13 +14047,13 @@ exports.commands = [{
}, { }, {
name: "backspace", name: "backspace",
bindKey: bindKey( bindKey: bindKey(
"Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace", "Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
"Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H" "Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"
), ),
exec: function(editor) { editor.remove("left"); } exec: function(editor) { editor.remove("left"); }
}, { }, {
name: "removetolinestart", name: "removetolinestart",
bindKey: bindKey("Alt-Backspace", "Option-Backspace"), bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
exec: function(editor) { editor.removeToLineStart(); } exec: function(editor) { editor.removeToLineStart(); }
}, { }, {
name: "removetolineend", name: "removetolineend",
@ -14411,7 +14538,7 @@ var CommandManager = function(platform, commands) {
var key = typeof binding == "string" ? binding: binding[this.platform]; var key = typeof binding == "string" ? binding: binding[this.platform];
this.bindKey(key, command); this.bindKey(key, command);
} };
function parseKeys(keys, val, ret) { function parseKeys(keys, val, ret) {
var key; var key;
@ -14428,10 +14555,10 @@ var CommandManager = function(platform, commands) {
return { return {
key: key, key: key,
hashId: hashId hashId: hashId
} };
} }
function splitSafe(s, separator) { function splitSafe(s) {
return (s.toLowerCase() return (s.toLowerCase()
.trim() .trim()
.split(new RegExp("[\\s ]*\\-[\\s ]*", "g"), 999)); .split(new RegExp("[\\s ]*\\-[\\s ]*", "g"), 999));
@ -14445,7 +14572,7 @@ var CommandManager = function(platform, commands) {
var ckbr = this.commmandKeyBinding; var ckbr = this.commmandKeyBinding;
return ckbr[hashId] && ckbr[hashId][textOrKey.toLowerCase()]; return ckbr[hashId] && ckbr[hashId][textOrKey.toLowerCase()];
} };
this.exec = function(command, editor, args) { this.exec = function(command, editor, args) {
if (typeof command === 'string') if (typeof command === 'string')
@ -14497,7 +14624,7 @@ var CommandManager = function(platform, commands) {
this.exec(x, editor); this.exec(x, editor);
else else
this.exec(x[0], editor, x[1]); this.exec(x[0], editor, x[1]);
}, this) }, this);
} finally { } finally {
this.$inReplay = false; this.$inReplay = false;
} }
@ -14509,9 +14636,9 @@ var CommandManager = function(platform, commands) {
x[0] = x[0].name; x[0] = x[0].name;
if (!x[1]) if (!x[1])
x = x[0]; x = x[0];
return x return x;
}) });
} };
}).call(CommandManager.prototype); }).call(CommandManager.prototype);
@ -14623,6 +14750,8 @@ var VirtualRenderer = function(container, theme) {
this.$horizScroll = true; this.$horizScroll = true;
this.$horizScrollAlwaysVisible = true; this.$horizScrollAlwaysVisible = true;
this.$animatedScroll = false;
this.scrollBar = new ScrollBar(container); this.scrollBar = new ScrollBar(container);
this.scrollBar.addEventListener("scroll", function(e) { this.scrollBar.addEventListener("scroll", function(e) {
_self.session.setScrollTop(e.data); _self.session.setScrollTop(e.data);
@ -14794,6 +14923,14 @@ var VirtualRenderer = function(container, theme) {
return this.session.adjustWrapLimit(limit); return this.session.adjustWrapLimit(limit);
}; };
this.setAnimatedScroll = function(shouldAnimate){
this.$animatedScroll = shouldAnimate;
}
this.getAnimatedscroll = function(){
return this.$animatedScroll
}
this.setShowInvisibles = function(showInvisibles) { this.setShowInvisibles = function(showInvisibles) {
if (this.$textLayer.setShowInvisibles(showInvisibles)) if (this.$textLayer.setShowInvisibles(showInvisibles))
this.$loop.schedule(this.CHANGE_TEXT); this.$loop.schedule(this.CHANGE_TEXT);
@ -15167,12 +15304,18 @@ var VirtualRenderer = function(container, theme) {
this.$cursorLayer.showCursor(); this.$cursorLayer.showCursor();
}; };
this.scrollCursorIntoView = function() { this.scrollSelectionIntoView = function(anchor, lead) {
// first scroll anchor into view then scroll lead into view
this.scrollCursorIntoView(anchor);
this.scrollCursorIntoView(lead);
};
this.scrollCursorIntoView = function(cursor) {
// the editor is not visible // the editor is not visible
if (this.$size.scrollerHeight === 0) if (this.$size.scrollerHeight === 0)
return; return;
var pos = this.$cursorLayer.getPixelPosition(); var pos = this.$cursorLayer.getPixelPosition(cursor);
var left = pos.left; var left = pos.left;
var top = pos.top; var top = pos.top;
@ -15220,7 +15363,7 @@ var VirtualRenderer = function(container, theme) {
//@todo I would like to make this animation a setting. How? //@todo I would like to make this animation a setting. How?
var STEPS = 15; var STEPS = 10;
function calcSteps(fromValue, toValue){ function calcSteps(fromValue, toValue){
var i = 0, var i = 0,
l = STEPS, l = STEPS,
@ -15244,15 +15387,20 @@ var VirtualRenderer = function(container, theme) {
if (center) if (center)
offset -= this.$size.scrollerHeight / 2; offset -= this.$size.scrollerHeight / 2;
var i = 0, _self = this, if (this.$animatedScroll && Math.abs(offset - this.scrollTop) < 10000) {
steps = calcSteps(this.scrollTop, offset);// console.dir(steps); var i = 0, _self = this,
clearInterval(_self.$timer); steps = calcSteps(this.scrollTop, offset);
this.$timer = setInterval(function(){ clearInterval(_self.$timer);
_self.session.setScrollTop(steps[i]); this.$timer = setInterval(function(){
_self.session.setScrollTop(steps[i]);
if (++i == STEPS + 1) if (++i == STEPS + 1)
clearInterval(_self.$timer); clearInterval(_self.$timer);
}, 10); }, 10);
}
else {
this.session.setScrollTop(offset);
}
}; };
this.scrollToY = function(scrollTop) { this.scrollToY = function(scrollTop) {

View file

@ -541,12 +541,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -558,7 +558,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -576,7 +576,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -601,12 +601,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -618,7 +618,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -637,14 +637,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -665,7 +666,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -674,19 +675,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -695,7 +696,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -705,7 +706,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -259,9 +259,9 @@ var ClojureHighlightRules = function() {
token : "comment", token : "comment",
regex : ";.*$" regex : ";.*$"
}, { }, {
token : "comment", // multi line comment token : "comment", // multi line comment
regex : "^\=begin$", regex : "^=begin$",
next : "comment" next : "comment"
}, { }, {
token : "keyword", //parens token : "keyword", //parens
regex : "[\\(|\\)]" regex : "[\\(|\\)]"
@ -314,17 +314,17 @@ var ClojureHighlightRules = function() {
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, { }, {
token : "string", // symbol token : "string", // symbol
regex : "[:](?:[a-zA-Z]|\d)+" regex : "[:](?:[a-zA-Z]|\\d)+"
}, { }, {
token : "string.regexp", //Regular Expressions token : "string.regexp", //Regular Expressions
regex : '/#"(?:\.|(\\\")|[^\""\n])*"/g' regex : '/#"(?:\\.|(?:\\\")|[^\""\n])*"/g'
} }
], ],
"comment" : [ "comment" : [
{ {
token : "comment", // closing comment token : "comment", // closing comment
regex : "^\=end$", regex : "^=end$",
next : "start" next : "start"
}, { }, {
token : "comment", // comment spanning whole line token : "comment", // comment spanning whole line

View file

@ -528,12 +528,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -545,7 +545,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -563,7 +563,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -588,12 +588,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -605,7 +605,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -624,14 +624,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -652,7 +653,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -661,19 +662,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -682,7 +683,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -692,7 +693,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;
@ -1350,13 +1352,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -1368,33 +1370,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -1417,29 +1507,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -2231,6 +2321,12 @@ var CssHighlightRules = function() {
"purple|red|silver|teal|white|yellow").split("|") "purple|red|silver|teal|white|yellow").split("|")
); );
var fonts = lang.arrayToMap(
("arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|" +
"symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|" +
"serif|monospace").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -2249,8 +2345,11 @@ var CssHighlightRules = function() {
token : "string", // single line token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, { }, {
token : "constant.numeric", token : ["constant.numeric", "keyword"],
regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)" regex : "(" + numRe + ")(em|ex|px|ch|cm|mm|in|pt|pc|deg|rad|dpi|grad|ms|s|hz|khz|%)"
}, {
token : ["constant.numeric"],
regex : "([0-9]+)"
}, { }, {
token : "constant.numeric", // hex6 color token : "constant.numeric", // hex6 color
regex : "#[a-f0-9]{6}" regex : "#[a-f0-9]{6}"
@ -2271,6 +2370,9 @@ var CssHighlightRules = function() {
else if (colors.hasOwnProperty(value.toLowerCase())) { else if (colors.hasOwnProperty(value.toLowerCase())) {
return "support.constant.color"; return "support.constant.color";
} }
else if (fonts.hasOwnProperty(value.toLowerCase())) {
return "support.constant.fonts";
}
else { else {
return "text"; return "text";
} }

View file

@ -391,12 +391,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -408,7 +408,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -426,7 +426,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -451,12 +451,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -468,7 +468,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -487,14 +487,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -515,7 +516,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -524,19 +525,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -545,7 +546,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -555,7 +556,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -215,6 +215,12 @@ var CssHighlightRules = function() {
"purple|red|silver|teal|white|yellow").split("|") "purple|red|silver|teal|white|yellow").split("|")
); );
var fonts = lang.arrayToMap(
("arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|" +
"symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|" +
"serif|monospace").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -233,8 +239,11 @@ var CssHighlightRules = function() {
token : "string", // single line token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, { }, {
token : "constant.numeric", token : ["constant.numeric", "keyword"],
regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)" regex : "(" + numRe + ")(em|ex|px|ch|cm|mm|in|pt|pc|deg|rad|dpi|grad|ms|s|hz|khz|%)"
}, {
token : ["constant.numeric"],
regex : "([0-9]+)"
}, { }, {
token : "constant.numeric", // hex6 color token : "constant.numeric", // hex6 color
regex : "#[a-f0-9]{6}" regex : "#[a-f0-9]{6}"
@ -255,6 +264,9 @@ var CssHighlightRules = function() {
else if (colors.hasOwnProperty(value.toLowerCase())) { else if (colors.hasOwnProperty(value.toLowerCase())) {
return "support.constant.color"; return "support.constant.color";
} }
else if (fonts.hasOwnProperty(value.toLowerCase())) {
return "support.constant.fonts";
}
else { else {
return "text"; return "text";
} }

View file

@ -302,13 +302,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -320,33 +320,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -369,29 +457,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -926,12 +1014,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -943,7 +1031,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -961,7 +1049,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -986,12 +1074,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -1003,7 +1091,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -1022,14 +1110,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -1050,7 +1139,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -1059,19 +1148,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -1080,7 +1169,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -1090,7 +1179,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -391,12 +391,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -408,7 +408,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -426,7 +426,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -451,12 +451,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -468,7 +468,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -487,14 +487,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -515,7 +516,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -524,19 +525,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -545,7 +546,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -555,7 +556,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -361,13 +361,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -379,33 +379,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -428,29 +516,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -985,12 +1073,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -1002,7 +1090,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -1020,7 +1108,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -1045,12 +1133,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -1062,7 +1150,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -1081,14 +1169,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -1109,7 +1198,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -1118,19 +1207,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -1139,7 +1228,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -1149,7 +1238,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;
@ -1577,6 +1667,12 @@ var CssHighlightRules = function() {
"purple|red|silver|teal|white|yellow").split("|") "purple|red|silver|teal|white|yellow").split("|")
); );
var fonts = lang.arrayToMap(
("arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|" +
"symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|" +
"serif|monospace").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -1595,8 +1691,11 @@ var CssHighlightRules = function() {
token : "string", // single line token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, { }, {
token : "constant.numeric", token : ["constant.numeric", "keyword"],
regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)" regex : "(" + numRe + ")(em|ex|px|ch|cm|mm|in|pt|pc|deg|rad|dpi|grad|ms|s|hz|khz|%)"
}, {
token : ["constant.numeric"],
regex : "([0-9]+)"
}, { }, {
token : "constant.numeric", // hex6 color token : "constant.numeric", // hex6 color
regex : "#[a-f0-9]{6}" regex : "#[a-f0-9]{6}"
@ -1617,6 +1716,9 @@ var CssHighlightRules = function() {
else if (colors.hasOwnProperty(value.toLowerCase())) { else if (colors.hasOwnProperty(value.toLowerCase())) {
return "support.constant.color"; return "support.constant.color";
} }
else if (fonts.hasOwnProperty(value.toLowerCase())) {
return "support.constant.fonts";
}
else { else {
return "text"; return "text";
} }

View file

@ -303,13 +303,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -321,33 +321,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -370,29 +458,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -927,12 +1015,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -944,7 +1032,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -962,7 +1050,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -987,12 +1075,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -1004,7 +1092,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -1023,14 +1111,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -1051,7 +1140,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -1060,19 +1149,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -1081,7 +1170,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -1091,7 +1180,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -278,13 +278,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -296,33 +296,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -345,29 +433,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -902,12 +990,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -919,7 +1007,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -937,7 +1025,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -962,12 +1050,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -979,7 +1067,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -998,14 +1086,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -1026,7 +1115,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -1035,19 +1124,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -1056,7 +1145,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -1066,7 +1155,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -319,12 +319,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -336,7 +336,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -354,7 +354,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -379,12 +379,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -396,7 +396,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -415,14 +415,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -443,7 +444,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -452,19 +453,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -473,7 +474,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -483,7 +484,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

File diff suppressed because it is too large Load diff

View file

@ -358,13 +358,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -376,33 +376,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -425,29 +513,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -982,12 +1070,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -999,7 +1087,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -1017,7 +1105,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -1042,12 +1130,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -1059,7 +1147,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -1078,14 +1166,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -1106,7 +1195,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -1115,19 +1204,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -1136,7 +1225,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -1146,7 +1235,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;
@ -2323,6 +2413,12 @@ var CssHighlightRules = function() {
"purple|red|silver|teal|white|yellow").split("|") "purple|red|silver|teal|white|yellow").split("|")
); );
var fonts = lang.arrayToMap(
("arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|" +
"symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|" +
"serif|monospace").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -2341,8 +2437,11 @@ var CssHighlightRules = function() {
token : "string", // single line token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, { }, {
token : "constant.numeric", token : ["constant.numeric", "keyword"],
regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)" regex : "(" + numRe + ")(em|ex|px|ch|cm|mm|in|pt|pc|deg|rad|dpi|grad|ms|s|hz|khz|%)"
}, {
token : ["constant.numeric"],
regex : "([0-9]+)"
}, { }, {
token : "constant.numeric", // hex6 color token : "constant.numeric", // hex6 color
regex : "#[a-f0-9]{6}" regex : "#[a-f0-9]{6}"
@ -2363,6 +2462,9 @@ var CssHighlightRules = function() {
else if (colors.hasOwnProperty(value.toLowerCase())) { else if (colors.hasOwnProperty(value.toLowerCase())) {
return "support.constant.color"; return "support.constant.color";
} }
else if (fonts.hasOwnProperty(value.toLowerCase())) {
return "support.constant.fonts";
}
else { else {
return "text"; return "text";
} }
@ -2854,7 +2956,7 @@ var MarkdownHighlightRules = function() {
token : "empty_line", token : "empty_line",
regex : '^$' regex : '^$'
}, { // code span ` }, { // code span `
token : "support.function", token : ["support.function", "support.function", "support.function"],
regex : "(`+)([^\\r]*?[^`])(\\1)" regex : "(`+)([^\\r]*?[^`])(\\1)"
}, { // code block }, { // code block
token : "support.function", token : "support.function",
@ -2884,7 +2986,7 @@ var MarkdownHighlightRules = function() {
next : "blockquote" next : "blockquote"
}, { // reference }, { // reference
token : ["text", "constant", "text", "url", "string", "text"], token : ["text", "constant", "text", "url", "string", "text"],
regex : "^([ ]{0,3}\\[)([^\\]]+)(\\]:\\s*)([^ ]+)(\\s*(?:[\"][^\"]+[\"])?\\s*)$" regex : "^([ ]{0,3}\\[)([^\\]]+)(\\]:\\s*)([^ ]+)(\\s*(?:[\"][^\"]+[\"])?(\\s*))$"
}, { // link by reference }, { // link by reference
token : ["text", "string", "text", "constant", "text"], token : ["text", "string", "text", "constant", "text"],
regex : "(\\[)((?:[[^\\]]*\\]|[^\\[\\]])*)(\\][ ]?(?:\\n[ ]*)?\\[)(.*?)(\\])" regex : "(\\[)((?:[[^\\]]*\\]|[^\\[\\]])*)(\\][ ]?(?:\\n[ ]*)?\\[)(.*?)(\\])"
@ -2910,10 +3012,10 @@ var MarkdownHighlightRules = function() {
regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+", regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
next : "listblock" next : "listblock"
}, { // strong ** __ }, { // strong ** __
token : "string", token : ["string", "string", "string"],
regex : "([*]{2}|[_]{2}(?=\\S))([^\\r]*?\\S[*_]*)(\\1)" regex : "([*]{2}|[_]{2}(?=\\S))([^\\r]*?\\S[*_]*)(\\1)"
}, { // emphasis * _ }, { // emphasis * _
token : "string", token : ["string", "string", "string"],
regex : "([*]|[_](?=\\S))([^\\r]*?\\S[*_]*)(\\1)" regex : "([*]|[_](?=\\S))([^\\r]*?\\S[*_]*)(\\1)"
}, { // }, { //
token : ["text", "url", "text"], token : ["text", "url", "text"],

View file

@ -1071,14 +1071,14 @@ var PhpHighlightRules = function() {
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, { }, {
token : "string", // multi line string start token : "string", // multi line string start
regex : '["].*\\\\$', regex : '["][\\s\\S]*',
next : "qqstring" next : "qqstring"
}, { }, {
token : "string", // single line token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, { }, {
token : "string", // multi line string start token : "string", // multi line string start
regex : "['].*\\\\$", regex : "['][\\s\\S]+",
next : "qstring" next : "qstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
@ -1160,21 +1160,21 @@ var PhpHighlightRules = function() {
"qqstring" : [ "qqstring" : [
{ {
token : "string", token : "string",
regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', regex : '"',
next : "start" next : "start"
}, { }, {
token : "string", token : "string",
regex : '.+' regex : '[^"]+'
} }
], ],
"qstring" : [ "qstring" : [
{ {
token : "string", token : "string",
regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", regex : "'",
next : "start" next : "start"
}, { }, {
token : "string", token : "string",
regex : '.+' regex : "[^']+"
} }
], ],
"htmlcomment" : [ "htmlcomment" : [
@ -1213,7 +1213,7 @@ var PhpHighlightRules = function() {
next : "htmltag" next : "htmltag"
}, { }, {
token : "meta.tag", token : "meta.tag",
regex : ">", regex : ">"
}, { }, {
token : 'text', token : 'text',
regex : "(?:media|type|href)" regex : "(?:media|type|href)"
@ -1223,7 +1223,7 @@ var PhpHighlightRules = function() {
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "\{", regex : "\{",
next : "cssdeclaration", next : "cssdeclaration"
}, { }, {
token : "keyword", token : "keyword",
regex : "#[A-Za-z0-9\-\_\.]+" regex : "#[A-Za-z0-9\-\_\.]+"
@ -1265,7 +1265,7 @@ var PhpHighlightRules = function() {
regex : ";", regex : ";",
next : "cssdeclaration" next : "cssdeclaration"
} }
], ]
}; };
this.embedRules(DocCommentHighlightRules, "doc-", this.embedRules(DocCommentHighlightRules, "doc-",
@ -1507,12 +1507,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -1524,7 +1524,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -1542,7 +1542,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -1567,12 +1567,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -1584,7 +1584,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -1603,14 +1603,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -1631,7 +1632,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -1640,19 +1641,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -1661,7 +1662,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -1671,7 +1672,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -329,12 +329,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -346,7 +346,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -364,7 +364,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -389,12 +389,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -406,7 +406,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -425,14 +425,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -453,7 +454,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -462,19 +463,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -483,7 +484,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -493,7 +494,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -529,12 +529,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -546,7 +546,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -564,7 +564,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -589,12 +589,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -606,7 +606,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -625,14 +625,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -653,7 +654,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -662,19 +663,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -683,7 +684,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -693,7 +694,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -303,13 +303,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -321,33 +321,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -370,29 +458,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -927,12 +1015,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -944,7 +1032,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -962,7 +1050,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -987,12 +1075,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -1004,7 +1092,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -1023,14 +1111,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -1051,7 +1140,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -1060,19 +1149,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -1081,7 +1170,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -1091,7 +1180,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -202,11 +202,6 @@ var ShHighlightRules = function() {
).split('|') ).split('|')
); );
var builtinVariables = lang.arrayToMap(
// TODO
('$?|$$|$!|$SHLVL').split('|')
);
var integer = "(?:(?:[1-9]\\d*)|(?:0))"; var integer = "(?:(?:[1-9]\\d*)|(?:0))";
// var integer = "(?:" + decimalInteger + ")"; // var integer = "(?:" + decimalInteger + ")";
@ -215,6 +210,14 @@ var ShHighlightRules = function() {
var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))"; var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))";
var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + ")"; var exponentFloat = "(?:(?:" + pointFloat + "|" + intPart + ")" + ")";
var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")"; var floatNumber = "(?:" + exponentFloat + "|" + pointFloat + ")";
var fileDescriptor = "(?:&" + intPart + ")";
var variableName = "[a-zA-Z][a-zA-Z0-9_]*";
var variable = "(?:(?:\\$" + variableName + ")|(?:" + variableName + "=))";
var builtinVariable = "(?:\\$(?:SHLVL|\\$|\\!|\\?))";
var func = "(?:" + variableName + "\\s*\\(\\))";
this.$rules = { this.$rules = {
"start" : [ { "start" : [ {
@ -223,6 +226,18 @@ var ShHighlightRules = function() {
}, { }, {
token : "string", // " string token : "string", // " string
regex : '"(?:[^\\\\]|\\\\.)*?"' regex : '"(?:[^\\\\]|\\\\.)*?"'
}, {
token : "variable.language",
regex : builtinVariable
}, {
token : "variable",
regex : variable
}, {
token : "support.function",
regex : func,
}, {
token : "support.function",
regex : fileDescriptor
}, { }, {
token : "string", // ' string token : "string", // ' string
regex : "'(?:[^\\\\]|\\\\.)*?'" regex : "'(?:[^\\\\]|\\\\.)*?'"
@ -238,8 +253,6 @@ var ShHighlightRules = function() {
return "keyword"; return "keyword";
else if (languageConstructs.hasOwnProperty(value)) else if (languageConstructs.hasOwnProperty(value))
return "constant.language"; return "constant.language";
else if (builtinVariables.hasOwnProperty(value))
return "support.function";
else if (value == "debugger") else if (value == "debugger")
return "invalid.deprecated"; return "invalid.deprecated";
else else

View file

@ -535,12 +535,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -552,7 +552,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -570,7 +570,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -595,12 +595,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -612,7 +612,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -631,14 +631,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -659,7 +660,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -668,19 +669,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -689,7 +690,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -699,7 +700,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;
@ -1357,13 +1359,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -1375,33 +1377,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -1424,29 +1514,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This

View file

@ -457,12 +457,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -474,7 +474,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -492,7 +492,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -517,12 +517,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -534,7 +534,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -553,14 +553,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -581,7 +582,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -590,19 +591,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -611,7 +612,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -621,7 +622,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -0,0 +1,540 @@
/*
* eXide - web-based XQuery IDE
*
* Copyright (C) 2011 Wolfgang Meier
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define('ace/mode/xquery', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/xquery_highlight_rules', 'ace/mode/behaviour/xquery', 'ace/range'], function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var Tokenizer = require("../tokenizer").Tokenizer;
var XQueryHighlightRules = require("./xquery_highlight_rules").XQueryHighlightRules;
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
var Range = require("../range").Range;
var Mode = function(parent) {
this.$tokenizer = new Tokenizer(new XQueryHighlightRules().getRules());
this.$behaviour = new XQueryBehaviour(parent);
};
oop.inherits(Mode, TextMode);
(function() {
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);
var match = line.match(/\s*(?:then|else|return|[{\(]|<\w+>)\s*$/);
if (match)
indent += tab;
return indent;
};
this.checkOutdent = function(state, line, input) {
if (! /^\s+$/.test(line))
return false;
return /^\s*[\}\)]/.test(input);
};
this.autoOutdent = function(state, doc, row) {
var line = doc.getLine(row);
var match = line.match(/^(\s*[\}\)])/);
if (!match) return 0;
var column = match[1].length;
var openBracePos = doc.findMatchingBracket({row: row, column: column});
if (!openBracePos || openBracePos.row == row) return 0;
var indent = this.$getIndent(doc.getLine(openBracePos.row));
doc.replace(new Range(row, 0, row, column-1), indent);
};
this.$getIndent = function(line) {
var match = line.match(/^(\s+)/);
if (match) {
return match[1];
}
return "";
};
this.toggleCommentLines = function(state, doc, startRow, endRow) {
var i, line;
var outdent = true;
var re = /^\s*\(:(.*):\)/;
for (i=startRow; i<= endRow; i++) {
if (!re.test(doc.getLine(i))) {
outdent = false;
break;
}
}
var range = new Range(0, 0, 0, 0);
for (i=startRow; i<= endRow; i++) {
line = doc.getLine(i);
range.start.row = i;
range.end.row = i;
range.end.column = line.length;
doc.replace(range, outdent ? line.match(re)[1] : "(:" + line + ":)");
}
};
}).call(Mode.prototype);
exports.Mode = Mode;
});
/*
* eXide - web-based XQuery IDE
*
* Copyright (C) 2011 Wolfgang Meier
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define('ace/mode/xquery_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var lang = require("../lib/lang");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var XQueryHighlightRules = function() {
var keywords = lang.arrayToMap(
("return|for|let|where|order|by|declare|function|variable|xquery|version|option|namespace|import|module|when|encoding|" +
"switch|default|try|catch|group|tumbling|sliding|window|start|end|at|only|" +
"using|stemming|" +
"while|" +
"external|" +
"if|then|else|as|and|or|typeswitch|case|ascending|descending|empty|in|count|updating|insert|delete|replace|value|node|attribute|text|element|into|of|with|contains").split("|")
);
// regexp must not have capturing parentheses
// regexps are ordered -> the first match is used
this.$rules = {
start : [ {
token : "text",
regex : "<\\!\\[CDATA\\[",
next : "cdata"
}, {
token : "xml_pe",
regex : "<\\?.*?\\?>"
}, {
token : "comment",
regex : "<\\!--",
next : "comment"
}, {
token : "comment",
regex : "\\(:",
next : "comment"
}, {
token : "text", // opening tag
regex : "<\\/?",
next : "tag"
}, {
token : "constant", // number
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token : "variable", // variable
regex : "\\$[a-zA-Z_][a-zA-Z0-9_\\-:]*\\b"
}, {
token: "string",
regex : '".*?"'
}, {
token: "string",
regex : "'.*?'"
}, {
token : "text",
regex : "\\s+"
}, {
token: "support.function",
regex: "\\w[\\w+_\\-:]+(?=\\()"
}, {
token : function(value) {
if (keywords[value])
return "keyword";
else
return "identifier";
},
regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token: "keyword.operator",
regex: "\\*|=|<|>|\\-|\\+|and|or|eq|ne|lt|gt"
}, {
token: "lparen",
regex: "[[({]"
}, {
token: "rparen",
regex: "[\\])}]"
} ],
tag : [ {
token : "text",
regex : ">",
next : "start"
}, {
token : "meta.tag",
regex : "[-_a-zA-Z0-9:]+"
}, {
token : "text",
regex : "\\s+"
}, {
token : "string",
regex : '".*?"'
}, {
token : "string",
regex : "'.*?'"
} ],
cdata : [ {
token : "text",
regex : "\\]\\]>",
next : "start"
}, {
token : "text",
regex : "\\s+"
}, {
token : "text",
regex : "(?:[^\\]]|\\](?!\\]>))+"
} ],
comment : [ {
token : "comment",
regex : ".*?-->",
next : "start"
}, {
token: "comment",
regex : ".*:\\)",
next : "start"
}, {
token : "comment",
regex : ".+"
} ]
};
};
oop.inherits(XQueryHighlightRules, TextHighlightRules);
exports.XQueryHighlightRules = XQueryHighlightRules;
});
/*
* eXide - web-based XQuery IDE
*
* Copyright (C) 2011 Wolfgang Meier
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define('ace/mode/behaviour/xquery', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle'], function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var Behaviour = require('../behaviour').Behaviour;
var CstyleBehaviour = require('./cstyle').CstyleBehaviour;
var XQueryBehaviour = function (parent) {
this.inherit(CstyleBehaviour, ["braces", "parens", "string_dquotes"]); // Get string behaviour
this.parent = parent;
this.add("brackets", "insertion", function (state, action, editor, session, text) {
if (text == "\n") {
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
var rightChars = line.substring(cursor.column, cursor.column + 2);
if (rightChars == '</') {
var indent = this.$getIndent(session.doc.getLine(cursor.row)) + session.getTabString();
var next_indent = this.$getIndent(session.doc.getLine(cursor.row));
return {
text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length]
}
}
}
return false;
});
// Check for open tag if user enters / and auto-close it.
this.add("slash", "insertion", function (state, action, editor, session, text) {
if (text == "/") {
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
if (cursor.column > 0 && line.charAt(cursor.column - 1) == "<") {
line = line.substring(0, cursor.column) + "/" + line.substring(cursor.column);
var lines = session.doc.getAllLines();
lines[cursor.row] = line;
// call mode helper to close the tag if possible
parent.exec("closeTag", lines.join(session.doc.getNewLineCharacter()), cursor.row);
}
}
return false;
});
}
oop.inherits(XQueryBehaviour, Behaviour);
exports.XQueryBehaviour = XQueryBehaviour;
});
/* vim:ts=4:sts=4:sw=4:
* ***** 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):
* Chris Spencer <chris.ag.spencer AT googlemail DOT com>
*
* 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('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) {
"use strict";
var oop = require("../../lib/oop");
var Behaviour = require('../behaviour').Behaviour;
var CstyleBehaviour = function () {
this.add("braces", "insertion", function (state, action, editor, session, text) {
if (text == '{') {
var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection);
if (selected !== "") {
return {
text: '{' + selected + '}',
selection: false
};
} else {
return {
text: '{}',
selection: [1, 1]
};
}
} else if (text == '}') {
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '}') {
var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
if (matching !== null) {
return {
text: '',
selection: [1, 1]
};
}
}
} else if (text == "\n") {
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '}') {
var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1});
if (!openBracePos)
return null;
var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString());
var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row));
return {
text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length]
};
}
}
});
this.add("braces", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '{') {
var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.end.column, range.end.column + 1);
if (rightChar == '}') {
range.end.column++;
return range;
}
}
});
this.add("parens", "insertion", function (state, action, editor, session, text) {
if (text == '(') {
var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection);
if (selected !== "") {
return {
text: '(' + selected + ')',
selection: false
};
} else {
return {
text: '()',
selection: [1, 1]
};
}
} else if (text == ')') {
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == ')') {
var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
if (matching !== null) {
return {
text: '',
selection: [1, 1]
};
}
}
}
});
this.add("parens", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '(') {
var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == ')') {
range.end.column++;
return range;
}
}
});
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection);
if (selected !== "") {
return {
text: quote + selected + quote,
selection: false
};
} else {
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
var leftChar = line.substring(cursor.column-1, cursor.column);
// We're escaped.
if (leftChar == '\\') {
return null;
}
// Find what token we're inside.
var tokens = session.getTokens(selection.start.row, selection.start.row)[0].tokens;
var col = 0, token;
var quotepos = -1; // Track whether we're inside an open quote.
for (var x = 0; x < tokens.length; x++) {
token = tokens[x];
if (token.type == "string") {
quotepos = -1;
} else if (quotepos < 0) {
quotepos = token.value.indexOf(quote);
}
if ((token.value.length + col) > selection.start.column) {
break;
}
col += tokens[x].value.length;
}
// Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return {
text: quote + quote,
selection: [1,1]
};
} else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == quote) {
return {
text: '',
selection: [1, 1]
};
}
}
}
}
});
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') {
range.end.column++;
return range;
}
}
});
};
oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour;
});

View file

@ -47,7 +47,6 @@ exports.cssText = ".ace-chrome .ace_editor {\
}\ }\
\ \
.ace-chrome .ace_gutter {\ .ace-chrome .ace_gutter {\
width: 50px;\
background: #e8e8e8;\ background: #e8e8e8;\
color: #333;\ color: #333;\
overflow : hidden;\ overflow : hidden;\
@ -58,10 +57,6 @@ exports.cssText = ".ace-chrome .ace_editor {\
text-align: right;\ text-align: right;\
}\ }\
\ \
.ace-chrome .ace_gutter-layer .ace_gutter-cell {\
padding-right: 6px;\
}\
\
.ace-chrome .ace_print_margin {\ .ace-chrome .ace_print_margin {\
width: 1px;\ width: 1px;\
background: #e8e8e8;\ background: #e8e8e8;\

View file

@ -101,7 +101,7 @@ exports.cssText = "\
color: #BFBFBF;\ color: #BFBFBF;\
}\ }\
\ \
.ace-clouds .ace_keyword {\ .ace-clouds .ace_keyword, .ace-clouds .ace_meta {\
color:#AF956F;\ color:#AF956F;\
}\ }\
\ \

View file

@ -101,7 +101,7 @@ exports.cssText = "\
color: #BFBFBF;\ color: #BFBFBF;\
}\ }\
\ \
.ace-clouds-midnight .ace_keyword {\ .ace-clouds-midnight .ace_keyword, .ace-clouds-midnight .ace_meta {\
color:#927C5D;\ color:#927C5D;\
}\ }\
\ \

View file

@ -101,11 +101,11 @@ exports.cssText = "\
color: rgba(255, 255, 255, 0.15);\ color: rgba(255, 255, 255, 0.15);\
}\ }\
\ \
.ace-cobalt .ace_keyword {\ .ace-cobalt .ace_keyword, .ace-cobalt .ace_meta {\
color:#FF9D00;\ color:#FF9D00;\
}\ }\
\ \
.ace-cobalt .ace_constant {\ .ace-cobalt .ace_constant, .ace-cobalt .ace_constant.ace_other {\
color:#FF628C;\ color:#FF628C;\
}\ }\
\ \
@ -118,6 +118,10 @@ background-color:#800F00;\
color:#80FFBB;\ color:#80FFBB;\
}\ }\
\ \
.ace-cobalt .ace_support.ace_constant {\
color:#EB939A;\
}\
\
.ace-cobalt .ace_fold {\ .ace-cobalt .ace_fold {\
background-color: #FF9D00;\ background-color: #FF9D00;\
border-color: #FFFFFF;\ border-color: #FFFFFF;\

View file

@ -101,11 +101,11 @@ exports.cssText = "\
color: rgba(75, 75, 126, 0.50);\ color: rgba(75, 75, 126, 0.50);\
}\ }\
\ \
.ace-dawn .ace_keyword {\ .ace-dawn .ace_keyword, .ace-dawn .ace_meta {\
color:#794938;\ color:#794938;\
}\ }\
\ \
.ace-dawn .ace_constant {\ .ace-dawn .ace_constant, .ace-dawn .ace_constant.ace_other {\
color:#811F24;\ color:#811F24;\
}\ }\
\ \
@ -126,6 +126,10 @@ color:#B52A1D;\
color:#691C97;\ color:#691C97;\
}\ }\
\ \
.ace-dawn .ace_support.ace_constant {\
color:#B4371F;\
}\
\
.ace-dawn .ace_fold {\ .ace-dawn .ace_fold {\
background-color: #794938;\ background-color: #794938;\
border-color: #080808;\ border-color: #080808;\

View file

@ -101,11 +101,11 @@ exports.cssText = "\
color: #404040;\ color: #404040;\
}\ }\
\ \
.ace-idle-fingers .ace_keyword {\ .ace-idle-fingers .ace_keyword, .ace-idle-fingers .ace_meta {\
color:#CC7833;\ color:#CC7833;\
}\ }\
\ \
.ace-idle-fingers .ace_constant {\ .ace-idle-fingers .ace_constant, .ace-idle-fingers .ace_constant.ace_other {\
color:#6C99BB;\ color:#6C99BB;\
}\ }\
\ \
@ -114,6 +114,10 @@ exports.cssText = "\
background-color:#FF0000;\ background-color:#FF0000;\
}\ }\
\ \
.ace-idle-fingers .ace_support.ace_constant {\
color:#6C99BB;\
}\
\
.ace-idle-fingers .ace_fold {\ .ace-idle-fingers .ace_fold {\
background-color: #CC7833;\ background-color: #CC7833;\
border-color: #FFFFFF;\ border-color: #FFFFFF;\

View file

@ -101,11 +101,11 @@ exports.cssText = "\
color: rgba(255, 177, 111, 0.32);\ color: rgba(255, 177, 111, 0.32);\
}\ }\
\ \
.ace-kr-theme .ace_keyword {\ .ace-kr-theme .ace_keyword, .ace-kr-theme .ace_meta {\
color:#949C8B;\ color:#949C8B;\
}\ }\
\ \
.ace-kr-theme .ace_constant {\ .ace-kr-theme .ace_constant, .ace-kr-theme .ace_constant.ace_other {\
color:rgba(210, 117, 24, 0.76);\ color:rgba(210, 117, 24, 0.76);\
}\ }\
\ \
@ -118,6 +118,10 @@ background-color:#A41300;\
color:#9FC28A;\ color:#9FC28A;\
}\ }\
\ \
.ace-kr-theme .ace_support.ace_constant {\
color:#C27E66;\
}\
\
.ace-kr-theme .ace_fold {\ .ace-kr-theme .ace_fold {\
background-color: #949C8B;\ background-color: #949C8B;\
border-color: #FCFFE0;\ border-color: #FCFFE0;\

View file

@ -101,11 +101,11 @@ exports.cssText = "\
color: #404040;\ color: #404040;\
}\ }\
\ \
.ace-merbivore .ace_keyword {\ .ace-merbivore .ace_keyword, .ace-merbivore .ace_meta {\
color:#FC6F09;\ color:#FC6F09;\
}\ }\
\ \
.ace-merbivore .ace_constant {\ .ace-merbivore .ace_constant, .ace-merbivore .ace_constant.ace_other {\
color:#1EDAFB;\ color:#1EDAFB;\
}\ }\
\ \
@ -126,6 +126,10 @@ exports.cssText = "\
background-color:#990000;\ background-color:#990000;\
}\ }\
\ \
.ace-merbivore .ace_support.ace_constant {\
color:#8DFF0A;\
}\
\
.ace-merbivore .ace_fold {\ .ace-merbivore .ace_fold {\
background-color: #FC6F09;\ background-color: #FC6F09;\
border-color: #E6E1DC;\ border-color: #E6E1DC;\

View file

@ -101,11 +101,11 @@ exports.cssText = "\
color: #404040;\ color: #404040;\
}\ }\
\ \
.ace-merbivore-soft .ace_keyword {\ .ace-merbivore-soft .ace_keyword, .ace-merbivore-soft .ace_meta {\
color:#FC803A;\ color:#FC803A;\
}\ }\
\ \
.ace-merbivore-soft .ace_constant {\ .ace-merbivore-soft .ace_constant, .ace-merbivore-soft .ace_constant.ace_other {\
color:#68C1D8;\ color:#68C1D8;\
}\ }\
\ \
@ -131,6 +131,10 @@ background-color:#FE3838;\
background-color:#FE3838;\ background-color:#FE3838;\
}\ }\
\ \
.ace-merbivore-soft .ace_support.ace_constant {\
color:#8EC65F;\
}\
\
.ace-merbivore-soft .ace_fold {\ .ace-merbivore-soft .ace_fold {\
background-color: #FC803A;\ background-color: #FC803A;\
border-color: #E6E1DC;\ border-color: #E6E1DC;\

View file

@ -101,7 +101,7 @@ exports.cssText = "\
color: rgba(102, 108, 104, 0.50);\ color: rgba(102, 108, 104, 0.50);\
}\ }\
\ \
.ace-mono-industrial .ace_keyword {\ .ace-mono-industrial .ace_keyword, .ace-mono-industrial .ace_meta {\
color:#A39E64;\ color:#A39E64;\
}\ }\
\ \
@ -109,7 +109,7 @@ exports.cssText = "\
color:#A8B3AB;\ color:#A8B3AB;\
}\ }\
\ \
.ace-mono-industrial .ace_constant {\ .ace-mono-industrial .ace_constant, .ace-mono-industrial .ace_constant.ace_other {\
color:#E98800;\ color:#E98800;\
}\ }\
\ \
@ -122,6 +122,10 @@ exports.cssText = "\
background-color:rgba(153, 0, 0, 0.68);\ background-color:rgba(153, 0, 0, 0.68);\
}\ }\
\ \
.ace-mono-industrial .ace_support.ace_constant {\
color:#C87500;\
}\
\
.ace-mono-industrial .ace_fold {\ .ace-mono-industrial .ace_fold {\
background-color: #A8B3AB;\ background-color: #A8B3AB;\
border-color: #FFFFFF;\ border-color: #FFFFFF;\
@ -135,6 +139,10 @@ background-color:rgba(153, 0, 0, 0.68);\
color:#C23B00;\ color:#C23B00;\
}\ }\
\ \
.ace-mono-industrial .ace_variable {\
color:#A8B3AB;\
}\
\
.ace-mono-industrial .ace_variable.ace_parameter {\ .ace-mono-industrial .ace_variable.ace_parameter {\
color:#648BD2;\ color:#648BD2;\
}\ }\

View file

@ -101,7 +101,7 @@ exports.cssText = "\
color: #49483E;\ color: #49483E;\
}\ }\
\ \
.ace-monokai .ace_keyword {\ .ace-monokai .ace_keyword, .ace-monokai .ace_meta {\
color:#F92672;\ color:#F92672;\
}\ }\
\ \
@ -113,6 +113,10 @@ exports.cssText = "\
color:#AE81FF;\ color:#AE81FF;\
}\ }\
\ \
.ace-monokai .ace_constant.ace_other {\
color:#AE81FF;\
}\
\
.ace-monokai .ace_invalid {\ .ace-monokai .ace_invalid {\
color:#F8F8F0;\ color:#F8F8F0;\
background-color:#F92672;\ background-color:#F92672;\
@ -123,6 +127,10 @@ background-color:#F92672;\
background-color:#AE81FF;\ background-color:#AE81FF;\
}\ }\
\ \
.ace-monokai .ace_support.ace_constant {\
color:#66D9EF;\
}\
\
.ace-monokai .ace_fold {\ .ace-monokai .ace_fold {\
background-color: #A6E22E;\ background-color: #A6E22E;\
border-color: #F8F8F2;\ border-color: #F8F8F2;\
@ -136,11 +144,15 @@ background-color:#AE81FF;\
color:#F92672;\ color:#F92672;\
}\ }\
\ \
.ace-monokai .ace_storage.ace_type {\ .ace-monokai .ace_storage.ace_type, .ace-monokai .ace_support.ace_type{\
font-style:italic;\ font-style:italic;\
color:#66D9EF;\ color:#66D9EF;\
}\ }\
\ \
.ace-monokai .ace_variable {\
color:#A6E22E;\
}\
\
.ace-monokai .ace_variable.ace_parameter {\ .ace-monokai .ace_variable.ace_parameter {\
font-style:italic;\ font-style:italic;\
color:#FD971F;\ color:#FD971F;\

View file

@ -101,7 +101,7 @@ exports.cssText = "\
color: rgba(255, 255, 255, 0.25);\ color: rgba(255, 255, 255, 0.25);\
}\ }\
\ \
.ace-pastel-on-dark .ace_keyword {\ .ace-pastel-on-dark .ace_keyword, .ace-pastel-on-dark .ace_meta {\
color:#757aD8;\ color:#757aD8;\
}\ }\
\ \
@ -109,7 +109,7 @@ exports.cssText = "\
color:#797878;\ color:#797878;\
}\ }\
\ \
.ace-pastel-on-dark .ace_constant {\ .ace-pastel-on-dark .ace_constant, .ace-pastel-on-dark .ace_constant.ace_other {\
color:#4FB7C5;\ color:#4FB7C5;\
}\ }\
\ \

View file

@ -101,7 +101,7 @@ exports.cssText = "\
color: rgba(147, 161, 161, 0.50);\ color: rgba(147, 161, 161, 0.50);\
}\ }\
\ \
.ace-solarized-dark .ace_keyword {\ .ace-solarized-dark .ace_keyword, .ace-solarized-dark .ace_meta {\
color:#859900;\ color:#859900;\
}\ }\
\ \
@ -113,6 +113,10 @@ exports.cssText = "\
color:#D33682;\ color:#D33682;\
}\ }\
\ \
.ace-solarized-dark .ace_constant.ace_other {\
color:#CB4B16;\
}\
\
.ace-solarized-dark .ace_fold {\ .ace-solarized-dark .ace_fold {\
background-color: #268BD2;\ background-color: #268BD2;\
border-color: #93A1A1;\ border-color: #93A1A1;\
@ -126,6 +130,10 @@ exports.cssText = "\
color:#93A1A1;\ color:#93A1A1;\
}\ }\
\ \
.ace-solarized-dark .ace_variable {\
color:#268BD2;\
}\
\
.ace-solarized-dark .ace_string {\ .ace-solarized-dark .ace_string {\
color:#2AA198;\ color:#2AA198;\
}\ }\

View file

@ -101,7 +101,7 @@ exports.cssText = "\
color: rgba(147, 161, 161, 0.50);\ color: rgba(147, 161, 161, 0.50);\
}\ }\
\ \
.ace-solarized-light .ace_keyword {\ .ace-solarized-light .ace_keyword, .ace-solarized-light .ace_meta {\
color:#859900;\ color:#859900;\
}\ }\
\ \
@ -113,6 +113,10 @@ exports.cssText = "\
color:#D33682;\ color:#D33682;\
}\ }\
\ \
.ace-solarized-light .ace_constant.ace_other {\
color:#CB4B16;\
}\
\
.ace-solarized-light .ace_fold {\ .ace-solarized-light .ace_fold {\
background-color: #268BD2;\ background-color: #268BD2;\
border-color: #586E75;\ border-color: #586E75;\
@ -126,6 +130,10 @@ exports.cssText = "\
color:#073642;\ color:#073642;\
}\ }\
\ \
.ace-solarized-light .ace_variable {\
color:#268BD2;\
}\
\
.ace-solarized-light .ace_string {\ .ace-solarized-light .ace_string {\
color:#2AA198;\ color:#2AA198;\
}\ }\

View file

@ -101,7 +101,7 @@ exports.cssText = "\
color: #D1D1D1;\ color: #D1D1D1;\
}\ }\
\ \
.ace-tomorrow .ace_keyword {\ .ace-tomorrow .ace_keyword, .ace-tomorrow .ace_meta {\
color:#8959A8;\ color:#8959A8;\
}\ }\
\ \
@ -117,6 +117,10 @@ exports.cssText = "\
color:#F5871F;\ color:#F5871F;\
}\ }\
\ \
.ace-tomorrow .ace_constant.ace_other {\
color:#666969;\
}\
\
.ace-tomorrow .ace_invalid {\ .ace-tomorrow .ace_invalid {\
color:#FFFFFF;\ color:#FFFFFF;\
background-color:#C82829;\ background-color:#C82829;\
@ -127,6 +131,10 @@ background-color:#C82829;\
background-color:#8959A8;\ background-color:#8959A8;\
}\ }\
\ \
.ace-tomorrow .ace_support.ace_constant {\
color:#F5871F;\
}\
\
.ace-tomorrow .ace_fold {\ .ace-tomorrow .ace_fold {\
background-color: #4271AE;\ background-color: #4271AE;\
border-color: #4D4D4C;\ border-color: #4D4D4C;\
@ -140,10 +148,14 @@ background-color:#8959A8;\
color:#8959A8;\ color:#8959A8;\
}\ }\
\ \
.ace-tomorrow .ace_storage.ace_type {\ .ace-tomorrow .ace_storage.ace_type, .ace-tomorrow .ace_support.ace_type{\
color:#8959A8;\ color:#8959A8;\
}\ }\
\ \
.ace-tomorrow .ace_variable {\
color:#4271AE;\
}\
\
.ace-tomorrow .ace_variable.ace_parameter {\ .ace-tomorrow .ace_variable.ace_parameter {\
color:#F5871F;\ color:#F5871F;\
}\ }\

View file

@ -101,7 +101,7 @@ exports.cssText = "\
color: #4B4E55;\ color: #4B4E55;\
}\ }\
\ \
.ace-tomorrow-night .ace_keyword {\ .ace-tomorrow-night .ace_keyword, .ace-tomorrow-night .ace_meta {\
color:#B294BB;\ color:#B294BB;\
}\ }\
\ \
@ -117,6 +117,10 @@ exports.cssText = "\
color:#DE935F;\ color:#DE935F;\
}\ }\
\ \
.ace-tomorrow-night .ace_constant.ace_other {\
color:#CED1CF;\
}\
\
.ace-tomorrow-night .ace_invalid {\ .ace-tomorrow-night .ace_invalid {\
color:#CED2CF;\ color:#CED2CF;\
background-color:#DF5F5F;\ background-color:#DF5F5F;\
@ -127,6 +131,10 @@ background-color:#DF5F5F;\
background-color:#B798BF;\ background-color:#B798BF;\
}\ }\
\ \
.ace-tomorrow-night .ace_support.ace_constant {\
color:#DE935F;\
}\
\
.ace-tomorrow-night .ace_fold {\ .ace-tomorrow-night .ace_fold {\
background-color: #81A2BE;\ background-color: #81A2BE;\
border-color: #C5C8C6;\ border-color: #C5C8C6;\
@ -140,10 +148,14 @@ background-color:#B798BF;\
color:#B294BB;\ color:#B294BB;\
}\ }\
\ \
.ace-tomorrow-night .ace_storage.ace_type {\ .ace-tomorrow-night .ace_storage.ace_type, .ace-tomorrow-night .ace_support.ace_type{\
color:#B294BB;\ color:#B294BB;\
}\ }\
\ \
.ace-tomorrow-night .ace_variable {\
color:#81A2BE;\
}\
\
.ace-tomorrow-night .ace_variable.ace_parameter {\ .ace-tomorrow-night .ace_variable.ace_parameter {\
color:#DE935F;\ color:#DE935F;\
}\ }\

View file

@ -101,7 +101,7 @@ exports.cssText = "\
color: #404F7D;\ color: #404F7D;\
}\ }\
\ \
.ace-tomorrow-night-blue .ace_keyword {\ .ace-tomorrow-night-blue .ace_keyword, .ace-tomorrow-night-blue .ace_meta {\
color:#EBBBFF;\ color:#EBBBFF;\
}\ }\
\ \
@ -117,6 +117,10 @@ exports.cssText = "\
color:#FFC58F;\ color:#FFC58F;\
}\ }\
\ \
.ace-tomorrow-night-blue .ace_constant.ace_other {\
color:#FFFFFF;\
}\
\
.ace-tomorrow-night-blue .ace_invalid {\ .ace-tomorrow-night-blue .ace_invalid {\
color:#FFFFFF;\ color:#FFFFFF;\
background-color:#F99DA5;\ background-color:#F99DA5;\
@ -127,6 +131,10 @@ background-color:#F99DA5;\
background-color:#EBBBFF;\ background-color:#EBBBFF;\
}\ }\
\ \
.ace-tomorrow-night-blue .ace_support.ace_constant {\
color:#FFC58F;\
}\
\
.ace-tomorrow-night-blue .ace_fold {\ .ace-tomorrow-night-blue .ace_fold {\
background-color: #BBDAFF;\ background-color: #BBDAFF;\
border-color: #FFFFFF;\ border-color: #FFFFFF;\
@ -140,10 +148,14 @@ background-color:#EBBBFF;\
color:#EBBBFF;\ color:#EBBBFF;\
}\ }\
\ \
.ace-tomorrow-night-blue .ace_storage.ace_type {\ .ace-tomorrow-night-blue .ace_storage.ace_type, .ace-tomorrow-night-blue .ace_support.ace_type{\
color:#EBBBFF;\ color:#EBBBFF;\
}\ }\
\ \
.ace-tomorrow-night-blue .ace_variable {\
color:#BBDAFF;\
}\
\
.ace-tomorrow-night-blue .ace_variable.ace_parameter {\ .ace-tomorrow-night-blue .ace_variable.ace_parameter {\
color:#FFC58F;\ color:#FFC58F;\
}\ }\

View file

@ -101,7 +101,7 @@ exports.cssText = "\
color: #343434;\ color: #343434;\
}\ }\
\ \
.ace-tomorrow-night-bright .ace_keyword {\ .ace-tomorrow-night-bright .ace_keyword, .ace-tomorrow-night-bright .ace_meta {\
color:#C397D8;\ color:#C397D8;\
}\ }\
\ \
@ -117,6 +117,10 @@ exports.cssText = "\
color:#E78C45;\ color:#E78C45;\
}\ }\
\ \
.ace-tomorrow-night-bright .ace_constant.ace_other {\
color:#EEEEEE;\
}\
\
.ace-tomorrow-night-bright .ace_invalid {\ .ace-tomorrow-night-bright .ace_invalid {\
color:#CED2CF;\ color:#CED2CF;\
background-color:#DF5F5F;\ background-color:#DF5F5F;\
@ -127,6 +131,10 @@ background-color:#DF5F5F;\
background-color:#B798BF;\ background-color:#B798BF;\
}\ }\
\ \
.ace-tomorrow-night-bright .ace_support.ace_constant {\
color:#E78C45;\
}\
\
.ace-tomorrow-night-bright .ace_fold {\ .ace-tomorrow-night-bright .ace_fold {\
background-color: #7AA6DA;\ background-color: #7AA6DA;\
border-color: #DEDEDE;\ border-color: #DEDEDE;\
@ -140,10 +148,14 @@ background-color:#B798BF;\
color:#C397D8;\ color:#C397D8;\
}\ }\
\ \
.ace-tomorrow-night-bright .ace_storage.ace_type {\ .ace-tomorrow-night-bright .ace_storage.ace_type, .ace-tomorrow-night-bright .ace_support.ace_type{\
color:#C397D8;\ color:#C397D8;\
}\ }\
\ \
.ace-tomorrow-night-bright .ace_variable {\
color:#7AA6DA;\
}\
\
.ace-tomorrow-night-bright .ace_variable.ace_parameter {\ .ace-tomorrow-night-bright .ace_variable.ace_parameter {\
color:#E78C45;\ color:#E78C45;\
}\ }\

View file

@ -101,7 +101,7 @@ exports.cssText = "\
color: #6A6A6A;\ color: #6A6A6A;\
}\ }\
\ \
.ace-tomorrow-night-eighties .ace_keyword {\ .ace-tomorrow-night-eighties .ace_keyword, .ace-tomorrow-night-eighties .ace_meta {\
color:#CC99CC;\ color:#CC99CC;\
}\ }\
\ \
@ -117,6 +117,10 @@ exports.cssText = "\
color:#F99157;\ color:#F99157;\
}\ }\
\ \
.ace-tomorrow-night-eighties .ace_constant.ace_other {\
color:#CCCCCC;\
}\
\
.ace-tomorrow-night-eighties .ace_invalid {\ .ace-tomorrow-night-eighties .ace_invalid {\
color:#CDCDCD;\ color:#CDCDCD;\
background-color:#F2777A;\ background-color:#F2777A;\
@ -127,6 +131,10 @@ background-color:#F2777A;\
background-color:#CC99CC;\ background-color:#CC99CC;\
}\ }\
\ \
.ace-tomorrow-night-eighties .ace_support.ace_constant {\
color:#F99157;\
}\
\
.ace-tomorrow-night-eighties .ace_fold {\ .ace-tomorrow-night-eighties .ace_fold {\
background-color: #6699CC;\ background-color: #6699CC;\
border-color: #CCCCCC;\ border-color: #CCCCCC;\
@ -140,10 +148,14 @@ background-color:#CC99CC;\
color:#CC99CC;\ color:#CC99CC;\
}\ }\
\ \
.ace-tomorrow-night-eighties .ace_storage.ace_type {\ .ace-tomorrow-night-eighties .ace_storage.ace_type, .ace-tomorrow-night-eighties .ace_support.ace_type{\
color:#CC99CC;\ color:#CC99CC;\
}\ }\
\ \
.ace-tomorrow-night-eighties .ace_variable {\
color:#6699CC;\
}\
\
.ace-tomorrow-night-eighties .ace_variable.ace_parameter {\ .ace-tomorrow-night-eighties .ace_variable.ace_parameter {\
color:#F99157;\ color:#F99157;\
}\ }\

View file

@ -101,11 +101,11 @@ exports.cssText = "\
color: rgba(255, 255, 255, 0.25);\ color: rgba(255, 255, 255, 0.25);\
}\ }\
\ \
.ace-twilight .ace_keyword {\ .ace-twilight .ace_keyword, .ace-twilight .ace_meta {\
color:#CDA869;\ color:#CDA869;\
}\ }\
\ \
.ace-twilight .ace_constant {\ .ace-twilight .ace_constant, .ace-twilight .ace_constant.ace_other {\
color:#CF6A4C;\ color:#CF6A4C;\
}\ }\
\ \
@ -124,6 +124,10 @@ color:#D2A8A1;\
color:#9B859D;\ color:#9B859D;\
}\ }\
\ \
.ace-twilight .ace_support.ace_constant {\
color:#CF6A4C;\
}\
\
.ace-twilight .ace_fold {\ .ace-twilight .ace_fold {\
background-color: #AC885B;\ background-color: #AC885B;\
border-color: #F8F8F8;\ border-color: #F8F8F8;\
@ -137,6 +141,10 @@ color:#D2A8A1;\
color:#F9EE98;\ color:#F9EE98;\
}\ }\
\ \
.ace-twilight .ace_variable {\
color:#AC885B;\
}\
\
.ace-twilight .ace_string {\ .ace-twilight .ace_string {\
color:#8F9D6A;\ color:#8F9D6A;\
}\ }\

View file

@ -101,11 +101,11 @@ exports.cssText = "\
color: #404040;\ color: #404040;\
}\ }\
\ \
.ace-vibrant-ink .ace_keyword {\ .ace-vibrant-ink .ace_keyword, .ace-vibrant-ink .ace_meta {\
color:#FF6600;\ color:#FF6600;\
}\ }\
\ \
.ace-vibrant-ink .ace_constant {\ .ace-vibrant-ink .ace_constant, .ace-vibrant-ink .ace_constant.ace_other {\
color:#339999;\ color:#339999;\
}\ }\
\ \
@ -132,6 +132,10 @@ background-color:#000000;\
color:#FFCC00;\ color:#FFCC00;\
}\ }\
\ \
.ace-vibrant-ink .ace_variable {\
color:#FFCC00;\
}\
\
.ace-vibrant-ink .ace_variable.ace_parameter {\ .ace-vibrant-ink .ace_variable.ace_parameter {\
font-style:italic;\ font-style:italic;\
}\ }\

View file

@ -1816,6 +1816,7 @@ var Document = function(text) {
position = this.$clipPosition(position); position = this.$clipPosition(position);
// only detect new lines if the document has no line break yet
if (this.getLength() <= 1) if (this.getLength() <= 1)
this.$detectNewLine(text); this.$detectNewLine(text);

View file

@ -1790,6 +1790,7 @@ var Document = function(text) {
position = this.$clipPosition(position); position = this.$clipPosition(position);
// only detect new lines if the document has no line break yet
if (this.getLength() <= 1) if (this.getLength() <= 1)
this.$detectNewLine(text); this.$detectNewLine(text);

File diff suppressed because it is too large Load diff

View file

@ -1827,6 +1827,7 @@ var Document = function(text) {
position = this.$clipPosition(position); position = this.$clipPosition(position);
// only detect new lines if the document has no line break yet
if (this.getLength() <= 1) if (this.getLength() <= 1)
this.$detectNewLine(text); this.$detectNewLine(text);

View file

@ -11,7 +11,7 @@
Ace Ace
version 0.2.0 version 0.2.0
commit b47b0e9225814c5b86de1804ce0de3e46d8218ec commit d6a1779f4b00794b0dc56917371e25492083e6d7
--> -->

File diff suppressed because one or more lines are too long

View file

@ -2701,7 +2701,11 @@ var Editor = function(renderer, session) {
this.renderer.updateCursor(); this.renderer.updateCursor();
if (!this.$blockScrolling) { if (!this.$blockScrolling) {
this.renderer.scrollCursorIntoView(); var selection = this.getSelection();
if (selection.isEmpty())
this.renderer.scrollCursorIntoView(selection.getCursor());
else
this.renderer.scrollSelectionIntoView(selection.getSelectionLead(), selection.getSelectionAnchor());
} }
// move text input over the cursor // move text input over the cursor
@ -2983,6 +2987,14 @@ var Editor = function(renderer, session) {
return this.$highlightSelectedWord; return this.$highlightSelectedWord;
}; };
this.setAnimatedScroll = function(shouldAnimate){
this.renderer.setAnimatedScroll(shouldAnimate);
}
this.getAnimatedScroll = function(){
this.rendered.getAnimatedScroll();
}
this.setShowInvisibles = function(showInvisibles) { this.setShowInvisibles = function(showInvisibles) {
if (this.getShowInvisibles() == showInvisibles) if (this.getShowInvisibles() == showInvisibles)
return; return;
@ -5419,13 +5431,13 @@ exports.commands = [{
}, { }, {
name: "backspace", name: "backspace",
bindKey: bindKey( bindKey: bindKey(
"Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace", "Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
"Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H" "Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"
), ),
exec: function(editor) { editor.remove("left"); } exec: function(editor) { editor.remove("left"); }
}, { }, {
name: "removetolinestart", name: "removetolinestart",
bindKey: bindKey("Alt-Backspace", "Option-Backspace"), bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
exec: function(editor) { editor.removeToLineStart(); } exec: function(editor) { editor.removeToLineStart(); }
}, { }, {
name: "removetolineend", name: "removetolineend",
@ -5984,6 +5996,10 @@ var EditSession = function(text, mode) {
return callback(_self.$modes[mode]); return callback(_self.$modes[mode]);
_self.$modes[mode] = new module.Mode(); _self.$modes[mode] = new module.Mode();
_self._emit("loadmode", {
name: mode,
mode: _self.$modes[mode]
});
callback(_self.$modes[mode]); callback(_self.$modes[mode]);
} }
@ -8533,6 +8549,10 @@ var Tokenizer = function(rules, flag) {
var mapping = this.matchMappings[key] = {}; var mapping = this.matchMappings[key] = {};
for ( var i = 0; i < state.length; i++) { for ( var i = 0; i < state.length; i++) {
if (state[i].regex instanceof RegExp)
state[i].regex = state[i].regex.toString().slice(1, -1);
// Count number of matching groups. 2 extra groups from the full match // Count number of matching groups. 2 extra groups from the full match
// And the catch-all on the end (used to force a match); // And the catch-all on the end (used to force a match);
var matchcount = new RegExp("(?:(" + state[i].regex + ")|(.))").exec("a").length - 2; var matchcount = new RegExp("(?:(" + state[i].regex + ")|(.))").exec("a").length - 2;
@ -8542,6 +8562,9 @@ var Tokenizer = function(rules, flag) {
return "\\" + (parseInt(digit, 10) + matchTotal + 1); return "\\" + (parseInt(digit, 10) + matchTotal + 1);
}); });
if (matchcount > 1 && state[i].token.length !== matchcount-1)
throw new Error("Matching groups and length of the token array don't match in rule #" + i + " of state " + key);
mapping[matchTotal] = { mapping[matchTotal] = {
rule: i, rule: i,
len: matchcount len: matchcount
@ -8579,31 +8602,31 @@ var Tokenizer = function(rules, flag) {
var value = [match[0]]; var value = [match[0]];
for (var i = 0; i < match.length-2; i++) { for (var i = 0; i < match.length-2; i++) {
if (match[i + 1] !== undefined) { if (match[i + 1] === undefined)
rule = state[mapping[i].rule]; continue;
if (mapping[i].len > 1) { rule = state[mapping[i].rule];
value = match.slice(i+2, i+1+mapping[i].len);
}
// compute token type if (mapping[i].len > 1)
if (typeof rule.token == "function") value = match.slice(i+2, i+1+mapping[i].len);
type = rule.token.apply(this, value);
else
type = rule.token;
var next = rule.next; // compute token type
if (next && next !== currentState) { if (typeof rule.token == "function")
currentState = next; type = rule.token.apply(this, value);
state = this.rules[currentState]; else
mapping = this.matchMappings[currentState]; type = rule.token;
lastIndex = re.lastIndex;
re = this.regExps[currentState]; var next = rule.next;
re.lastIndex = lastIndex; if (next && next !== currentState) {
} currentState = next;
break; state = this.rules[currentState];
mapping = this.matchMappings[currentState];
lastIndex = re.lastIndex;
re = this.regExps[currentState];
re.lastIndex = lastIndex;
} }
break;
} }
if (value[0]) { if (value[0]) {
@ -8612,12 +8635,14 @@ var Tokenizer = function(rules, flag) {
type = [type]; type = [type];
} }
for (var i = 0; i < value.length; i++) { for (var i = 0; i < value.length; i++) {
if (!value[i])
continue;
if ((!rule || rule.merge || type[i] === "text") && token.type === type[i]) { if ((!rule || rule.merge || type[i] === "text") && token.type === type[i]) {
token.value += value[i]; token.value += value[i];
} else { } else {
if (token.type) { if (token.type)
tokens.push(token); tokens.push(token);
}
token = { token = {
type: type[i], type: type[i],
@ -9140,6 +9165,7 @@ var Document = function(text) {
position = this.$clipPosition(position); position = this.$clipPosition(position);
// only detect new lines if the document has no line break yet
if (this.getLength() <= 1) if (this.getLength() <= 1)
this.$detectNewLine(text); this.$detectNewLine(text);
@ -11613,7 +11639,7 @@ var CommandManager = function(platform, commands) {
var key = typeof binding == "string" ? binding: binding[this.platform]; var key = typeof binding == "string" ? binding: binding[this.platform];
this.bindKey(key, command); this.bindKey(key, command);
} };
function parseKeys(keys, val, ret) { function parseKeys(keys, val, ret) {
var key; var key;
@ -11630,10 +11656,10 @@ var CommandManager = function(platform, commands) {
return { return {
key: key, key: key,
hashId: hashId hashId: hashId
} };
} }
function splitSafe(s, separator) { function splitSafe(s) {
return (s.toLowerCase() return (s.toLowerCase()
.trim() .trim()
.split(new RegExp("[\\s ]*\\-[\\s ]*", "g"), 999)); .split(new RegExp("[\\s ]*\\-[\\s ]*", "g"), 999));
@ -11647,7 +11673,7 @@ var CommandManager = function(platform, commands) {
var ckbr = this.commmandKeyBinding; var ckbr = this.commmandKeyBinding;
return ckbr[hashId] && ckbr[hashId][textOrKey.toLowerCase()]; return ckbr[hashId] && ckbr[hashId][textOrKey.toLowerCase()];
} };
this.exec = function(command, editor, args) { this.exec = function(command, editor, args) {
if (typeof command === 'string') if (typeof command === 'string')
@ -11699,7 +11725,7 @@ var CommandManager = function(platform, commands) {
this.exec(x, editor); this.exec(x, editor);
else else
this.exec(x[0], editor, x[1]); this.exec(x[0], editor, x[1]);
}, this) }, this);
} finally { } finally {
this.$inReplay = false; this.$inReplay = false;
} }
@ -11711,9 +11737,9 @@ var CommandManager = function(platform, commands) {
x[0] = x[0].name; x[0] = x[0].name;
if (!x[1]) if (!x[1])
x = x[0]; x = x[0];
return x return x;
}) });
} };
}).call(CommandManager.prototype); }).call(CommandManager.prototype);
@ -11919,6 +11945,8 @@ var VirtualRenderer = function(container, theme) {
this.$horizScroll = true; this.$horizScroll = true;
this.$horizScrollAlwaysVisible = true; this.$horizScrollAlwaysVisible = true;
this.$animatedScroll = false;
this.scrollBar = new ScrollBar(container); this.scrollBar = new ScrollBar(container);
this.scrollBar.addEventListener("scroll", function(e) { this.scrollBar.addEventListener("scroll", function(e) {
_self.session.setScrollTop(e.data); _self.session.setScrollTop(e.data);
@ -12090,6 +12118,14 @@ var VirtualRenderer = function(container, theme) {
return this.session.adjustWrapLimit(limit); return this.session.adjustWrapLimit(limit);
}; };
this.setAnimatedScroll = function(shouldAnimate){
this.$animatedScroll = shouldAnimate;
}
this.getAnimatedscroll = function(){
return this.$animatedScroll
}
this.setShowInvisibles = function(showInvisibles) { this.setShowInvisibles = function(showInvisibles) {
if (this.$textLayer.setShowInvisibles(showInvisibles)) if (this.$textLayer.setShowInvisibles(showInvisibles))
this.$loop.schedule(this.CHANGE_TEXT); this.$loop.schedule(this.CHANGE_TEXT);
@ -12463,12 +12499,18 @@ var VirtualRenderer = function(container, theme) {
this.$cursorLayer.showCursor(); this.$cursorLayer.showCursor();
}; };
this.scrollCursorIntoView = function() { this.scrollSelectionIntoView = function(anchor, lead) {
// first scroll anchor into view then scroll lead into view
this.scrollCursorIntoView(anchor);
this.scrollCursorIntoView(lead);
};
this.scrollCursorIntoView = function(cursor) {
// the editor is not visible // the editor is not visible
if (this.$size.scrollerHeight === 0) if (this.$size.scrollerHeight === 0)
return; return;
var pos = this.$cursorLayer.getPixelPosition(); var pos = this.$cursorLayer.getPixelPosition(cursor);
var left = pos.left; var left = pos.left;
var top = pos.top; var top = pos.top;
@ -12516,7 +12558,7 @@ var VirtualRenderer = function(container, theme) {
//@todo I would like to make this animation a setting. How? //@todo I would like to make this animation a setting. How?
var STEPS = 15; var STEPS = 10;
function calcSteps(fromValue, toValue){ function calcSteps(fromValue, toValue){
var i = 0, var i = 0,
l = STEPS, l = STEPS,
@ -12540,15 +12582,20 @@ var VirtualRenderer = function(container, theme) {
if (center) if (center)
offset -= this.$size.scrollerHeight / 2; offset -= this.$size.scrollerHeight / 2;
var i = 0, _self = this, if (this.$animatedScroll && Math.abs(offset - this.scrollTop) < 10000) {
steps = calcSteps(this.scrollTop, offset);// console.dir(steps); var i = 0, _self = this,
clearInterval(_self.$timer); steps = calcSteps(this.scrollTop, offset);
this.$timer = setInterval(function(){ clearInterval(_self.$timer);
_self.session.setScrollTop(steps[i]); this.$timer = setInterval(function(){
_self.session.setScrollTop(steps[i]);
if (++i == STEPS + 1) if (++i == STEPS + 1)
clearInterval(_self.$timer); clearInterval(_self.$timer);
}, 10); }, 10);
}
else {
this.session.setScrollTop(offset);
}
}; };
this.scrollToY = function(scrollTop) { this.scrollToY = function(scrollTop) {

View file

@ -2701,7 +2701,11 @@ var Editor = function(renderer, session) {
this.renderer.updateCursor(); this.renderer.updateCursor();
if (!this.$blockScrolling) { if (!this.$blockScrolling) {
this.renderer.scrollCursorIntoView(); var selection = this.getSelection();
if (selection.isEmpty())
this.renderer.scrollCursorIntoView(selection.getCursor());
else
this.renderer.scrollSelectionIntoView(selection.getSelectionLead(), selection.getSelectionAnchor());
} }
// move text input over the cursor // move text input over the cursor
@ -2983,6 +2987,14 @@ var Editor = function(renderer, session) {
return this.$highlightSelectedWord; return this.$highlightSelectedWord;
}; };
this.setAnimatedScroll = function(shouldAnimate){
this.renderer.setAnimatedScroll(shouldAnimate);
}
this.getAnimatedScroll = function(){
this.rendered.getAnimatedScroll();
}
this.setShowInvisibles = function(showInvisibles) { this.setShowInvisibles = function(showInvisibles) {
if (this.getShowInvisibles() == showInvisibles) if (this.getShowInvisibles() == showInvisibles)
return; return;
@ -5419,13 +5431,13 @@ exports.commands = [{
}, { }, {
name: "backspace", name: "backspace",
bindKey: bindKey( bindKey: bindKey(
"Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace", "Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
"Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H" "Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"
), ),
exec: function(editor) { editor.remove("left"); } exec: function(editor) { editor.remove("left"); }
}, { }, {
name: "removetolinestart", name: "removetolinestart",
bindKey: bindKey("Alt-Backspace", "Option-Backspace"), bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
exec: function(editor) { editor.removeToLineStart(); } exec: function(editor) { editor.removeToLineStart(); }
}, { }, {
name: "removetolineend", name: "removetolineend",
@ -5984,6 +5996,10 @@ var EditSession = function(text, mode) {
return callback(_self.$modes[mode]); return callback(_self.$modes[mode]);
_self.$modes[mode] = new module.Mode(); _self.$modes[mode] = new module.Mode();
_self._emit("loadmode", {
name: mode,
mode: _self.$modes[mode]
});
callback(_self.$modes[mode]); callback(_self.$modes[mode]);
} }
@ -8533,6 +8549,10 @@ var Tokenizer = function(rules, flag) {
var mapping = this.matchMappings[key] = {}; var mapping = this.matchMappings[key] = {};
for ( var i = 0; i < state.length; i++) { for ( var i = 0; i < state.length; i++) {
if (state[i].regex instanceof RegExp)
state[i].regex = state[i].regex.toString().slice(1, -1);
// Count number of matching groups. 2 extra groups from the full match // Count number of matching groups. 2 extra groups from the full match
// And the catch-all on the end (used to force a match); // And the catch-all on the end (used to force a match);
var matchcount = new RegExp("(?:(" + state[i].regex + ")|(.))").exec("a").length - 2; var matchcount = new RegExp("(?:(" + state[i].regex + ")|(.))").exec("a").length - 2;
@ -8542,6 +8562,9 @@ var Tokenizer = function(rules, flag) {
return "\\" + (parseInt(digit, 10) + matchTotal + 1); return "\\" + (parseInt(digit, 10) + matchTotal + 1);
}); });
if (matchcount > 1 && state[i].token.length !== matchcount-1)
throw new Error("Matching groups and length of the token array don't match in rule #" + i + " of state " + key);
mapping[matchTotal] = { mapping[matchTotal] = {
rule: i, rule: i,
len: matchcount len: matchcount
@ -8579,31 +8602,31 @@ var Tokenizer = function(rules, flag) {
var value = [match[0]]; var value = [match[0]];
for (var i = 0; i < match.length-2; i++) { for (var i = 0; i < match.length-2; i++) {
if (match[i + 1] !== undefined) { if (match[i + 1] === undefined)
rule = state[mapping[i].rule]; continue;
if (mapping[i].len > 1) { rule = state[mapping[i].rule];
value = match.slice(i+2, i+1+mapping[i].len);
}
// compute token type if (mapping[i].len > 1)
if (typeof rule.token == "function") value = match.slice(i+2, i+1+mapping[i].len);
type = rule.token.apply(this, value);
else
type = rule.token;
var next = rule.next; // compute token type
if (next && next !== currentState) { if (typeof rule.token == "function")
currentState = next; type = rule.token.apply(this, value);
state = this.rules[currentState]; else
mapping = this.matchMappings[currentState]; type = rule.token;
lastIndex = re.lastIndex;
re = this.regExps[currentState]; var next = rule.next;
re.lastIndex = lastIndex; if (next && next !== currentState) {
} currentState = next;
break; state = this.rules[currentState];
mapping = this.matchMappings[currentState];
lastIndex = re.lastIndex;
re = this.regExps[currentState];
re.lastIndex = lastIndex;
} }
break;
} }
if (value[0]) { if (value[0]) {
@ -8612,12 +8635,14 @@ var Tokenizer = function(rules, flag) {
type = [type]; type = [type];
} }
for (var i = 0; i < value.length; i++) { for (var i = 0; i < value.length; i++) {
if (!value[i])
continue;
if ((!rule || rule.merge || type[i] === "text") && token.type === type[i]) { if ((!rule || rule.merge || type[i] === "text") && token.type === type[i]) {
token.value += value[i]; token.value += value[i];
} else { } else {
if (token.type) { if (token.type)
tokens.push(token); tokens.push(token);
}
token = { token = {
type: type[i], type: type[i],
@ -9140,6 +9165,7 @@ var Document = function(text) {
position = this.$clipPosition(position); position = this.$clipPosition(position);
// only detect new lines if the document has no line break yet
if (this.getLength() <= 1) if (this.getLength() <= 1)
this.$detectNewLine(text); this.$detectNewLine(text);
@ -11613,7 +11639,7 @@ var CommandManager = function(platform, commands) {
var key = typeof binding == "string" ? binding: binding[this.platform]; var key = typeof binding == "string" ? binding: binding[this.platform];
this.bindKey(key, command); this.bindKey(key, command);
} };
function parseKeys(keys, val, ret) { function parseKeys(keys, val, ret) {
var key; var key;
@ -11630,10 +11656,10 @@ var CommandManager = function(platform, commands) {
return { return {
key: key, key: key,
hashId: hashId hashId: hashId
} };
} }
function splitSafe(s, separator) { function splitSafe(s) {
return (s.toLowerCase() return (s.toLowerCase()
.trim() .trim()
.split(new RegExp("[\\s ]*\\-[\\s ]*", "g"), 999)); .split(new RegExp("[\\s ]*\\-[\\s ]*", "g"), 999));
@ -11647,7 +11673,7 @@ var CommandManager = function(platform, commands) {
var ckbr = this.commmandKeyBinding; var ckbr = this.commmandKeyBinding;
return ckbr[hashId] && ckbr[hashId][textOrKey.toLowerCase()]; return ckbr[hashId] && ckbr[hashId][textOrKey.toLowerCase()];
} };
this.exec = function(command, editor, args) { this.exec = function(command, editor, args) {
if (typeof command === 'string') if (typeof command === 'string')
@ -11699,7 +11725,7 @@ var CommandManager = function(platform, commands) {
this.exec(x, editor); this.exec(x, editor);
else else
this.exec(x[0], editor, x[1]); this.exec(x[0], editor, x[1]);
}, this) }, this);
} finally { } finally {
this.$inReplay = false; this.$inReplay = false;
} }
@ -11711,9 +11737,9 @@ var CommandManager = function(platform, commands) {
x[0] = x[0].name; x[0] = x[0].name;
if (!x[1]) if (!x[1])
x = x[0]; x = x[0];
return x return x;
}) });
} };
}).call(CommandManager.prototype); }).call(CommandManager.prototype);
@ -11919,6 +11945,8 @@ var VirtualRenderer = function(container, theme) {
this.$horizScroll = true; this.$horizScroll = true;
this.$horizScrollAlwaysVisible = true; this.$horizScrollAlwaysVisible = true;
this.$animatedScroll = false;
this.scrollBar = new ScrollBar(container); this.scrollBar = new ScrollBar(container);
this.scrollBar.addEventListener("scroll", function(e) { this.scrollBar.addEventListener("scroll", function(e) {
_self.session.setScrollTop(e.data); _self.session.setScrollTop(e.data);
@ -12090,6 +12118,14 @@ var VirtualRenderer = function(container, theme) {
return this.session.adjustWrapLimit(limit); return this.session.adjustWrapLimit(limit);
}; };
this.setAnimatedScroll = function(shouldAnimate){
this.$animatedScroll = shouldAnimate;
}
this.getAnimatedscroll = function(){
return this.$animatedScroll
}
this.setShowInvisibles = function(showInvisibles) { this.setShowInvisibles = function(showInvisibles) {
if (this.$textLayer.setShowInvisibles(showInvisibles)) if (this.$textLayer.setShowInvisibles(showInvisibles))
this.$loop.schedule(this.CHANGE_TEXT); this.$loop.schedule(this.CHANGE_TEXT);
@ -12463,12 +12499,18 @@ var VirtualRenderer = function(container, theme) {
this.$cursorLayer.showCursor(); this.$cursorLayer.showCursor();
}; };
this.scrollCursorIntoView = function() { this.scrollSelectionIntoView = function(anchor, lead) {
// first scroll anchor into view then scroll lead into view
this.scrollCursorIntoView(anchor);
this.scrollCursorIntoView(lead);
};
this.scrollCursorIntoView = function(cursor) {
// the editor is not visible // the editor is not visible
if (this.$size.scrollerHeight === 0) if (this.$size.scrollerHeight === 0)
return; return;
var pos = this.$cursorLayer.getPixelPosition(); var pos = this.$cursorLayer.getPixelPosition(cursor);
var left = pos.left; var left = pos.left;
var top = pos.top; var top = pos.top;
@ -12516,7 +12558,7 @@ var VirtualRenderer = function(container, theme) {
//@todo I would like to make this animation a setting. How? //@todo I would like to make this animation a setting. How?
var STEPS = 15; var STEPS = 10;
function calcSteps(fromValue, toValue){ function calcSteps(fromValue, toValue){
var i = 0, var i = 0,
l = STEPS, l = STEPS,
@ -12540,15 +12582,20 @@ var VirtualRenderer = function(container, theme) {
if (center) if (center)
offset -= this.$size.scrollerHeight / 2; offset -= this.$size.scrollerHeight / 2;
var i = 0, _self = this, if (this.$animatedScroll && Math.abs(offset - this.scrollTop) < 10000) {
steps = calcSteps(this.scrollTop, offset);// console.dir(steps); var i = 0, _self = this,
clearInterval(_self.$timer); steps = calcSteps(this.scrollTop, offset);
this.$timer = setInterval(function(){ clearInterval(_self.$timer);
_self.session.setScrollTop(steps[i]); this.$timer = setInterval(function(){
_self.session.setScrollTop(steps[i]);
if (++i == STEPS + 1) if (++i == STEPS + 1)
clearInterval(_self.$timer); clearInterval(_self.$timer);
}, 10); }, 10);
}
else {
this.session.setScrollTop(offset);
}
}; };
this.scrollToY = function(scrollTop) { this.scrollToY = function(scrollTop) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -541,12 +541,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -558,7 +558,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -576,7 +576,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -601,12 +601,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -618,7 +618,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -637,14 +637,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -665,7 +666,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -674,19 +675,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -695,7 +696,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -705,7 +706,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -541,12 +541,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -558,7 +558,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -576,7 +576,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -601,12 +601,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -618,7 +618,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -637,14 +637,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -665,7 +666,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -674,19 +675,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -695,7 +696,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -705,7 +706,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -259,9 +259,9 @@ var ClojureHighlightRules = function() {
token : "comment", token : "comment",
regex : ";.*$" regex : ";.*$"
}, { }, {
token : "comment", // multi line comment token : "comment", // multi line comment
regex : "^\=begin$", regex : "^=begin$",
next : "comment" next : "comment"
}, { }, {
token : "keyword", //parens token : "keyword", //parens
regex : "[\\(|\\)]" regex : "[\\(|\\)]"
@ -314,17 +314,17 @@ var ClojureHighlightRules = function() {
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, { }, {
token : "string", // symbol token : "string", // symbol
regex : "[:](?:[a-zA-Z]|\d)+" regex : "[:](?:[a-zA-Z]|\\d)+"
}, { }, {
token : "string.regexp", //Regular Expressions token : "string.regexp", //Regular Expressions
regex : '/#"(?:\.|(\\\")|[^\""\n])*"/g' regex : '/#"(?:\\.|(?:\\\")|[^\""\n])*"/g'
} }
], ],
"comment" : [ "comment" : [
{ {
token : "comment", // closing comment token : "comment", // closing comment
regex : "^\=end$", regex : "^=end$",
next : "start" next : "start"
}, { }, {
token : "comment", // comment spanning whole line token : "comment", // comment spanning whole line

View file

@ -259,9 +259,9 @@ var ClojureHighlightRules = function() {
token : "comment", token : "comment",
regex : ";.*$" regex : ";.*$"
}, { }, {
token : "comment", // multi line comment token : "comment", // multi line comment
regex : "^\=begin$", regex : "^=begin$",
next : "comment" next : "comment"
}, { }, {
token : "keyword", //parens token : "keyword", //parens
regex : "[\\(|\\)]" regex : "[\\(|\\)]"
@ -314,17 +314,17 @@ var ClojureHighlightRules = function() {
regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
}, { }, {
token : "string", // symbol token : "string", // symbol
regex : "[:](?:[a-zA-Z]|\d)+" regex : "[:](?:[a-zA-Z]|\\d)+"
}, { }, {
token : "string.regexp", //Regular Expressions token : "string.regexp", //Regular Expressions
regex : '/#"(?:\.|(\\\")|[^\""\n])*"/g' regex : '/#"(?:\\.|(?:\\\")|[^\""\n])*"/g'
} }
], ],
"comment" : [ "comment" : [
{ {
token : "comment", // closing comment token : "comment", // closing comment
regex : "^\=end$", regex : "^=end$",
next : "start" next : "start"
}, { }, {
token : "comment", // comment spanning whole line token : "comment", // comment spanning whole line

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -528,12 +528,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -545,7 +545,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -563,7 +563,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -588,12 +588,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -605,7 +605,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -624,14 +624,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -652,7 +653,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -661,19 +662,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -682,7 +683,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -692,7 +693,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;
@ -1350,13 +1352,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -1368,33 +1370,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -1417,29 +1507,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -2065,6 +2155,12 @@ var CssHighlightRules = function() {
"purple|red|silver|teal|white|yellow").split("|") "purple|red|silver|teal|white|yellow").split("|")
); );
var fonts = lang.arrayToMap(
("arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|" +
"symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|" +
"serif|monospace").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -2083,8 +2179,11 @@ var CssHighlightRules = function() {
token : "string", // single line token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, { }, {
token : "constant.numeric", token : ["constant.numeric", "keyword"],
regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)" regex : "(" + numRe + ")(em|ex|px|ch|cm|mm|in|pt|pc|deg|rad|dpi|grad|ms|s|hz|khz|%)"
}, {
token : ["constant.numeric"],
regex : "([0-9]+)"
}, { }, {
token : "constant.numeric", // hex6 color token : "constant.numeric", // hex6 color
regex : "#[a-f0-9]{6}" regex : "#[a-f0-9]{6}"
@ -2105,6 +2204,9 @@ var CssHighlightRules = function() {
else if (colors.hasOwnProperty(value.toLowerCase())) { else if (colors.hasOwnProperty(value.toLowerCase())) {
return "support.constant.color"; return "support.constant.color";
} }
else if (fonts.hasOwnProperty(value.toLowerCase())) {
return "support.constant.fonts";
}
else { else {
return "text"; return "text";
} }

View file

@ -528,12 +528,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -545,7 +545,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -563,7 +563,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -588,12 +588,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -605,7 +605,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -624,14 +624,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -652,7 +653,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -661,19 +662,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -682,7 +683,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -692,7 +693,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;
@ -1350,13 +1352,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -1368,33 +1370,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -1417,29 +1507,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -2065,6 +2155,12 @@ var CssHighlightRules = function() {
"purple|red|silver|teal|white|yellow").split("|") "purple|red|silver|teal|white|yellow").split("|")
); );
var fonts = lang.arrayToMap(
("arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|" +
"symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|" +
"serif|monospace").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -2083,8 +2179,11 @@ var CssHighlightRules = function() {
token : "string", // single line token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, { }, {
token : "constant.numeric", token : ["constant.numeric", "keyword"],
regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)" regex : "(" + numRe + ")(em|ex|px|ch|cm|mm|in|pt|pc|deg|rad|dpi|grad|ms|s|hz|khz|%)"
}, {
token : ["constant.numeric"],
regex : "([0-9]+)"
}, { }, {
token : "constant.numeric", // hex6 color token : "constant.numeric", // hex6 color
regex : "#[a-f0-9]{6}" regex : "#[a-f0-9]{6}"
@ -2105,6 +2204,9 @@ var CssHighlightRules = function() {
else if (colors.hasOwnProperty(value.toLowerCase())) { else if (colors.hasOwnProperty(value.toLowerCase())) {
return "support.constant.color"; return "support.constant.color";
} }
else if (fonts.hasOwnProperty(value.toLowerCase())) {
return "support.constant.fonts";
}
else { else {
return "text"; return "text";
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -391,12 +391,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -408,7 +408,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -426,7 +426,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -451,12 +451,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -468,7 +468,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -487,14 +487,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -515,7 +516,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -524,19 +525,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -545,7 +546,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -555,7 +556,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -391,12 +391,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -408,7 +408,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -426,7 +426,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -451,12 +451,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -468,7 +468,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -487,14 +487,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -515,7 +516,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -524,19 +525,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -545,7 +546,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -555,7 +556,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -215,6 +215,12 @@ var CssHighlightRules = function() {
"purple|red|silver|teal|white|yellow").split("|") "purple|red|silver|teal|white|yellow").split("|")
); );
var fonts = lang.arrayToMap(
("arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|" +
"symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|" +
"serif|monospace").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -233,8 +239,11 @@ var CssHighlightRules = function() {
token : "string", // single line token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, { }, {
token : "constant.numeric", token : ["constant.numeric", "keyword"],
regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)" regex : "(" + numRe + ")(em|ex|px|ch|cm|mm|in|pt|pc|deg|rad|dpi|grad|ms|s|hz|khz|%)"
}, {
token : ["constant.numeric"],
regex : "([0-9]+)"
}, { }, {
token : "constant.numeric", // hex6 color token : "constant.numeric", // hex6 color
regex : "#[a-f0-9]{6}" regex : "#[a-f0-9]{6}"
@ -255,6 +264,9 @@ var CssHighlightRules = function() {
else if (colors.hasOwnProperty(value.toLowerCase())) { else if (colors.hasOwnProperty(value.toLowerCase())) {
return "support.constant.color"; return "support.constant.color";
} }
else if (fonts.hasOwnProperty(value.toLowerCase())) {
return "support.constant.fonts";
}
else { else {
return "text"; return "text";
} }

View file

@ -215,6 +215,12 @@ var CssHighlightRules = function() {
"purple|red|silver|teal|white|yellow").split("|") "purple|red|silver|teal|white|yellow").split("|")
); );
var fonts = lang.arrayToMap(
("arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|" +
"symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|" +
"serif|monospace").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -233,8 +239,11 @@ var CssHighlightRules = function() {
token : "string", // single line token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, { }, {
token : "constant.numeric", token : ["constant.numeric", "keyword"],
regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)" regex : "(" + numRe + ")(em|ex|px|ch|cm|mm|in|pt|pc|deg|rad|dpi|grad|ms|s|hz|khz|%)"
}, {
token : ["constant.numeric"],
regex : "([0-9]+)"
}, { }, {
token : "constant.numeric", // hex6 color token : "constant.numeric", // hex6 color
regex : "#[a-f0-9]{6}" regex : "#[a-f0-9]{6}"
@ -255,6 +264,9 @@ var CssHighlightRules = function() {
else if (colors.hasOwnProperty(value.toLowerCase())) { else if (colors.hasOwnProperty(value.toLowerCase())) {
return "support.constant.color"; return "support.constant.color";
} }
else if (fonts.hasOwnProperty(value.toLowerCase())) {
return "support.constant.fonts";
}
else { else {
return "text"; return "text";
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -302,13 +302,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -320,33 +320,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -369,29 +457,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -760,12 +848,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -777,7 +865,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -795,7 +883,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -820,12 +908,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -837,7 +925,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -856,14 +944,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -884,7 +973,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -893,19 +982,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -914,7 +1003,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -924,7 +1013,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -302,13 +302,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -320,33 +320,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -369,29 +457,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -760,12 +848,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -777,7 +865,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -795,7 +883,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -820,12 +908,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -837,7 +925,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -856,14 +944,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -884,7 +973,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -893,19 +982,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -914,7 +1003,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -924,7 +1013,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -391,12 +391,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -408,7 +408,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -426,7 +426,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -451,12 +451,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -468,7 +468,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -487,14 +487,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -515,7 +516,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -524,19 +525,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -545,7 +546,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -555,7 +556,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -391,12 +391,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -408,7 +408,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -426,7 +426,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -451,12 +451,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -468,7 +468,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -487,14 +487,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -515,7 +516,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -524,19 +525,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -545,7 +546,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -555,7 +556,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -361,13 +361,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -379,33 +379,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -428,29 +516,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -819,12 +907,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -836,7 +924,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -854,7 +942,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -879,12 +967,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -896,7 +984,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -915,14 +1003,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -943,7 +1032,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -952,19 +1041,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -973,7 +1062,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -983,7 +1072,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;
@ -1411,6 +1501,12 @@ var CssHighlightRules = function() {
"purple|red|silver|teal|white|yellow").split("|") "purple|red|silver|teal|white|yellow").split("|")
); );
var fonts = lang.arrayToMap(
("arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|" +
"symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|" +
"serif|monospace").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -1429,8 +1525,11 @@ var CssHighlightRules = function() {
token : "string", // single line token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, { }, {
token : "constant.numeric", token : ["constant.numeric", "keyword"],
regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)" regex : "(" + numRe + ")(em|ex|px|ch|cm|mm|in|pt|pc|deg|rad|dpi|grad|ms|s|hz|khz|%)"
}, {
token : ["constant.numeric"],
regex : "([0-9]+)"
}, { }, {
token : "constant.numeric", // hex6 color token : "constant.numeric", // hex6 color
regex : "#[a-f0-9]{6}" regex : "#[a-f0-9]{6}"
@ -1451,6 +1550,9 @@ var CssHighlightRules = function() {
else if (colors.hasOwnProperty(value.toLowerCase())) { else if (colors.hasOwnProperty(value.toLowerCase())) {
return "support.constant.color"; return "support.constant.color";
} }
else if (fonts.hasOwnProperty(value.toLowerCase())) {
return "support.constant.fonts";
}
else { else {
return "text"; return "text";
} }

View file

@ -361,13 +361,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -379,33 +379,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -428,29 +516,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -819,12 +907,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -836,7 +924,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -854,7 +942,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -879,12 +967,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -896,7 +984,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -915,14 +1003,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -943,7 +1032,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -952,19 +1041,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -973,7 +1062,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -983,7 +1072,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;
@ -1411,6 +1501,12 @@ var CssHighlightRules = function() {
"purple|red|silver|teal|white|yellow").split("|") "purple|red|silver|teal|white|yellow").split("|")
); );
var fonts = lang.arrayToMap(
("arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|" +
"symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|" +
"serif|monospace").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used
@ -1429,8 +1525,11 @@ var CssHighlightRules = function() {
token : "string", // single line token : "string", // single line
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, { }, {
token : "constant.numeric", token : ["constant.numeric", "keyword"],
regex : numRe + "(?:em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|%)" regex : "(" + numRe + ")(em|ex|px|ch|cm|mm|in|pt|pc|deg|rad|dpi|grad|ms|s|hz|khz|%)"
}, {
token : ["constant.numeric"],
regex : "([0-9]+)"
}, { }, {
token : "constant.numeric", // hex6 color token : "constant.numeric", // hex6 color
regex : "#[a-f0-9]{6}" regex : "#[a-f0-9]{6}"
@ -1451,6 +1550,9 @@ var CssHighlightRules = function() {
else if (colors.hasOwnProperty(value.toLowerCase())) { else if (colors.hasOwnProperty(value.toLowerCase())) {
return "support.constant.color"; return "support.constant.color";
} }
else if (fonts.hasOwnProperty(value.toLowerCase())) {
return "support.constant.fonts";
}
else { else {
return "text"; return "text";
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -303,13 +303,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -321,33 +321,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -370,29 +458,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -761,12 +849,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -778,7 +866,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -796,7 +884,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -821,12 +909,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -838,7 +926,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -857,14 +945,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -885,7 +974,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -894,19 +983,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -915,7 +1004,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -925,7 +1014,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -303,13 +303,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -321,33 +321,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -370,29 +458,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -761,12 +849,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -778,7 +866,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -796,7 +884,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -821,12 +909,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -838,7 +926,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -857,14 +945,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -885,7 +974,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -894,19 +983,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -915,7 +1004,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -925,7 +1014,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -278,13 +278,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -296,33 +296,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -345,29 +433,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -736,12 +824,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -753,7 +841,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -771,7 +859,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -796,12 +884,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -813,7 +901,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -832,14 +920,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -860,7 +949,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -869,19 +958,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -890,7 +979,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -900,7 +989,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -278,13 +278,13 @@ var JavaScriptHighlightRules = function() {
"start" : [ "start" : [
{ {
token : "comment", token : "comment",
regex : "\\/\\/.*$" regex : /\/\/.*$/
}, },
new DocCommentHighlightRules().getStartRule("doc-start"), new DocCommentHighlightRules().getStartRule("doc-start"),
{ {
token : "comment", // multi line comment token : "comment", // multi line comment
merge : true, merge : true,
regex : "\\/\\*", regex : /\/\*/,
next : "comment" next : "comment"
}, { }, {
token : "string", token : "string",
@ -296,33 +296,121 @@ var JavaScriptHighlightRules = function() {
next : "qqstring" next : "qqstring"
}, { }, {
token : "constant.numeric", // hex token : "constant.numeric", // hex
regex : "0[xX][0-9a-fA-F]+\\b" regex : /0[xX][0-9a-fA-F]+\b/
}, { }, {
token : "constant.numeric", // float token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
}, { }, { // match stuff like: Sound.prototype.play = function() { }
token : ["storage.type", "text", "entity.name.function", "text", "paren.lparen", "variable.parameter", "paren.rparen"], token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: Sound.prototype.play = myfunc
token : [
"storage.type",
"punctuation.operator",
"support.function",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text"
],
regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
}, { // match stuff like: Sound.play = function() { }
token : [
"storage.type",
"punctuation.operator",
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: play = function() { }
token : [
"entity.name.function",
"text",
"keyword.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // match regular function like: function myFunc(arg) { }
token : [
"storage.type",
"text",
"entity.name.function",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))" regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
}, { // match stuff like: foobar: function() { }
token : [
"entity.name.function",
"text",
"punctuation.operator",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
}, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
token : [
"text",
"text",
"storage.type",
"text",
"paren.lparen",
"variable.parameter",
"paren.rparen"
],
regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
}, { }, {
token : "constant.language.boolean", token : "constant.language.boolean",
regex : "(?:true|false)\\b" regex : /(?:true|false)\b/
}, { }, {
token : "keyword", token : "keyword",
regex : "(?:" + kwBeforeRe + ")\\b", regex : "(?:" + kwBeforeRe + ")\\b",
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "support.function", token : "support.function",
regex : "\\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\\b(?=\\()" regex : /\b(?:s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
}, { }, {
token : "support.function.dom", token : "support.function.dom",
regex : "\\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\\b(?=\\()" regex : /\b(?:s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
}, { }, {
token : "support.function.constant", token : "support.constant",
regex : "\\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\\b" regex : /\b(?:s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
}, { }, {
token : ["punctuation.operator", "support.function.firebug"], token : ["storage.type", "punctuation.operator", "support.function.firebug"],
regex : "(\\.)(warn|info|log|error|time|timeEnd|assert)\\b" regex : /\b(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
}, { }, {
token : function(value) { token : function(value) {
if (globals.hasOwnProperty(value)) if (globals.hasOwnProperty(value))
@ -345,29 +433,29 @@ var JavaScriptHighlightRules = function() {
regex : identifierRe regex : identifierRe
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)", regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "punctuation.operator", token : "punctuation.operator",
regex : "\\?|\\:|\\,|\\;|\\.", regex : /\?|\:|\,|\;|\./,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.lparen", token : "paren.lparen",
regex : "[[({]", regex : /[\[({]/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token : "paren.rparen", token : "paren.rparen",
regex : "[\\])}]" regex : /[\])}]/
}, { }, {
token : "keyword.operator", token : "keyword.operator",
regex : "\\/=?", regex : /\/=?/,
next : "regex_allowed" next : "regex_allowed"
}, { }, {
token: "comment", token: "comment",
regex: "^#!.*$" regex: /^#!.*$/
}, { }, {
token : "text", token : "text",
regex : "\\s+" regex : /\s+/
} }
], ],
// regular expressions are only allowed after certain tokens. This // regular expressions are only allowed after certain tokens. This
@ -736,12 +824,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -753,7 +841,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -771,7 +859,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -796,12 +884,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -813,7 +901,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -832,14 +920,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -860,7 +949,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -869,19 +958,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -890,7 +979,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -900,7 +989,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -319,12 +319,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -336,7 +336,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -354,7 +354,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -379,12 +379,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -396,7 +396,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -415,14 +415,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -443,7 +444,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -452,19 +453,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -473,7 +474,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -483,7 +484,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

View file

@ -319,12 +319,12 @@ var CstyleBehaviour = function () {
return { return {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
} };
} else { } else {
return { return {
text: '{}', text: '{}',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == '}') { } else if (text == '}') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -336,7 +336,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} else if (text == "\n") { } else if (text == "\n") {
@ -354,7 +354,7 @@ var CstyleBehaviour = function () {
return { return {
text: '\n' + indent + '\n' + next_indent, text: '\n' + indent + '\n' + next_indent,
selection: [1, indent.length, 1, indent.length] selection: [1, indent.length, 1, indent.length]
} };
} }
} }
}); });
@ -379,12 +379,12 @@ var CstyleBehaviour = function () {
return { return {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
} };
} else { } else {
return { return {
text: '()', text: '()',
selection: [1, 1] selection: [1, 1]
} };
} }
} else if (text == ')') { } else if (text == ')') {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
@ -396,7 +396,7 @@ var CstyleBehaviour = function () {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -415,14 +415,15 @@ var CstyleBehaviour = function () {
}); });
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
if (text == '"') { if (text == '"' || text == "'") {
var quote = text;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
return { return {
text: '"' + selected + '"', text: quote + selected + quote,
selection: false selection: false
} };
} else { } else {
var cursor = editor.getCursorPosition(); var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row); var line = session.doc.getLine(cursor.row);
@ -443,7 +444,7 @@ var CstyleBehaviour = function () {
if (token.type == "string") { if (token.type == "string") {
quotepos = -1; quotepos = -1;
} else if (quotepos < 0) { } else if (quotepos < 0) {
quotepos = token.value.indexOf('"'); quotepos = token.value.indexOf(quote);
} }
if ((token.value.length + col) > selection.start.column) { if ((token.value.length + col) > selection.start.column) {
break; break;
@ -452,19 +453,19 @@ var CstyleBehaviour = function () {
} }
// Try and be smart about when we auto insert. // Try and be smart about when we auto insert.
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) { if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
return { return {
text: '""', text: quote + quote,
selection: [1,1] selection: [1,1]
} };
} else if (token && token.type === "string") { } else if (token && token.type === "string") {
// Ignore input and move right one if we're typing over the closing quote. // Ignore input and move right one if we're typing over the closing quote.
var rightChar = line.substring(cursor.column, cursor.column + 1); var rightChar = line.substring(cursor.column, cursor.column + 1);
if (rightChar == '"') { if (rightChar == quote) {
return { return {
text: '', text: '',
selection: [1, 1] selection: [1, 1]
} };
} }
} }
} }
@ -473,7 +474,7 @@ var CstyleBehaviour = function () {
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
var selected = session.doc.getTextRange(range); var selected = session.doc.getTextRange(range);
if (!range.isMultiLine() && selected == '"') { if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
var line = session.doc.getLine(range.start.row); var line = session.doc.getLine(range.start.row);
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
if (rightChar == '"') { if (rightChar == '"') {
@ -483,7 +484,8 @@ var CstyleBehaviour = function () {
} }
}); });
} };
oop.inherits(CstyleBehaviour, Behaviour); oop.inherits(CstyleBehaviour, Behaviour);
exports.CstyleBehaviour = CstyleBehaviour; exports.CstyleBehaviour = CstyleBehaviour;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

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