Permalink
Browse files

update ace++

  • Loading branch information...
1 parent e058509 commit 0a08e30685ec382cee671fb1d8a92a1a63b0e1d5 @nightwing nightwing committed Dec 20, 2011
Showing with 6,958 additions and 12,234 deletions.
  1. +70 −0 chrome/content/ace++/consoleMode.js
  2. +1 −1 chrome/content/ace++/fbeditor.html
  3. +2 −0 chrome/content/ace++/imageViewer.js
  4. +0 −11,765 chrome/content/ace++/res/ace-uncompressed.js
  5. +331 −1 chrome/content/ace++/res/ace/keybinding-emacs.js
  6. +1,246 −1 chrome/content/ace++/res/ace/keybinding-vim.js
  7. +234 −1 chrome/content/ace++/res/ace/mode-c_cpp.js
  8. +288 −3 chrome/content/ace++/res/ace/mode-coffee.js
  9. +1,715 −1 chrome/content/ace++/res/ace/mode-html.js
  10. +96 −1 chrome/content/ace++/res/ace/mode-json.js
  11. +94 −1 chrome/content/ace++/res/ace/mode-xml.js
  12. +115 −1 chrome/content/ace++/res/ace/theme-clouds.js
  13. +116 −1 chrome/content/ace++/res/ace/theme-clouds_midnight.js
  14. +130 −1 chrome/content/ace++/res/ace/theme-cobalt.js
  15. +163 −1 chrome/content/ace++/res/ace/theme-crimson_editor.js
  16. +133 −1 chrome/content/ace++/res/ace/theme-dawn.js
  17. +108 −1 chrome/content/ace++/res/ace/theme-eclipse.js
  18. +122 −1 chrome/content/ace++/res/ace/theme-idle_fingers.js
  19. +125 −1 chrome/content/ace++/res/ace/theme-kr_theme.js
  20. +125 −1 chrome/content/ace++/res/ace/theme-merbivore.js
  21. +131 −1 chrome/content/ace++/res/ace/theme-merbivore_soft.js
  22. +125 −1 chrome/content/ace++/res/ace/theme-mono_industrial.js
  23. +121 −1 chrome/content/ace++/res/ace/theme-monokai.js
  24. +143 −1 chrome/content/ace++/res/ace/theme-pastel_on_dark.js
  25. +120 −1 chrome/content/ace++/res/ace/theme-solarized_dark.js
  26. +119 −1 chrome/content/ace++/res/ace/theme-solarized_light.js
  27. +141 −1 chrome/content/ace++/res/ace/theme-tomorrow.js
  28. +141 −1 chrome/content/ace++/res/ace/theme-tomorrow_night.js
  29. +141 −1 chrome/content/ace++/res/ace/theme-tomorrow_night_blue.js
  30. +141 −1 chrome/content/ace++/res/ace/theme-tomorrow_night_bright.js
  31. +137 −1 chrome/content/ace++/res/ace/theme-tomorrow_night_eighties.js
  32. +143 −1 chrome/content/ace++/res/ace/theme-twilight.js
  33. +126 −1 chrome/content/ace++/res/ace/theme-vibrant_ink.js
  34. +0 −212 chrome/content/ace++/scrollbar.js
  35. +13 −194 chrome/content/ace++/startup.js
  36. +1 −30 chrome/content/ace++/styles.css
  37. +1 −1 chrome/content/resource.js
View
70 chrome/content/ace++/consoleMode.js
@@ -6,6 +6,73 @@ var TextMode = require("ace/mode/text").Mode;
var Range = require("ace/range").Range;
var jsMode = require("ace/mode/javascript").Mode
+var foldMode = new (require("ace/mode/folding/cstyle").FoldMode);
+foldMode.foldingStartMarker = /(^#>>)|(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
+foldMode.getFoldWidgetRange = function(session, foldStyle, row) {
+ var line = session.getLine(row);
+ var match = line.match(this.foldingStartMarker);
+ if (match) {
+ var i = match.index;
+
+ if (match[1]) {
+ var cell = session.$mode.getCellBounds(row)
+ var start = {row: row, column: session.$mode.dl};
+ var end = {row: cell.bodyEnd, column: session.getLine(cell.bodyEnd).length};
+ var placeholder = session.getLine(cell.headerStart).slice(0,10) + "=====================";
+ range = Range.fromPoints(start, end)
+ range.placeholder = placeholder
+ return range
+ }
+
+ if (match[3]) {
+ var range = session.getCommentFoldRange(row, i + match[0].length);
+ range.end.column -= 2;
+ return range;
+ }
+
+ var start = {row: row, column: i+1};
+ var end = session.$findClosingBracket(match[2], start);
+ if (!end)
+ return;
+
+ var fw = session.foldWidgets[end.row];
+ if (fw == null)
+ fw = this.getFoldWidget(session, end.row);
+
+ if (fw == "start") {
+ end.row --;
+ end.column = session.getLine(end.row).length;
+ }
+ return Range.fromPoints(start, end);
+ }
+
+ if (foldStyle !== "markbeginend")
+ return;
+
+ var match = line.match(this.foldingStopMarker);
+ if (match) {
+ var i = match.index + match[0].length;
+
+ if (match[2]) {
+ var range = session.getCommentFoldRange(row, i);
+ range.end.column -= 2;
+ return range;
+ }
+
+ var end = {row: row, column: i};
+ var start = session.$findOpeningBracket(match[1], end);
+
+ if (!start)
+ return;
+
+ start.column++;
+ end.column--;
+
+ return Range.fromPoints(start, end);
+ }
+};
+
+
modes = {
js: new jsMode,
get coffee() {
@@ -25,6 +92,8 @@ modes = {
}
jsMode = modes.js
+
+
var tk = {}
var delimiter = '#>>'
var dl = delimiter.length
@@ -83,6 +152,7 @@ tk.getLineTokens = function(line, startState) {
var Mode = function() {
this.$tokenizer = tk;
+ this.foldingRules = foldMode
};
oop.inherits(Mode, TextMode);
View
2 chrome/content/ace++/fbeditor.html
@@ -149,7 +149,7 @@
}
onLaunch = callback || true;
// "ace/mode/javascript", "ace/mode/css", are loaded with html // "ace-uncompressed" for debugging
- var rootDeps = ["fbace/scrollbar", "fbace/startup", "res/ace-uncompressed", "ace/mode/xml", "ace/mode/html"];
+ var rootDeps = ["fbace/startup", "res/ace/ace-uncompressed", "ace/mode/xml", "ace/mode/html"];
if (!options)
options = {
softtabs: true,
View
2 chrome/content/ace++/imageViewer.js
@@ -20,6 +20,8 @@ exports.showImage = function(data) {
// this.buttons.style.display = '';
this.iframe.setAttribute('src', 'view-source:' + data.href);
+ this.iframe.className=""
+ this.iframe.parentNode.appendChild(this.iframe)
this.isOpen = true;
};
View
11,765 chrome/content/ace++/res/ace-uncompressed.js
0 additions, 11,765 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
332 chrome/content/ace++/res/ace/keybinding-emacs.js
@@ -1 +1,331 @@
-define("ace/keyboard/keybinding/emacs",["require","exports","module","ace/keyboard/state_handler"],function(a,b,c){var d=a("../state_handler").StateHandler,e=a("../state_handler").matchCharacterOnly,f={start:[{key:"ctrl-x",then:"c-x"},{regex:["(?:command-([0-9]*))*","(down|ctrl-n)"],exec:"golinedown",params:[{name:"times",match:1,type:"number",defaultValue:1}]},{regex:["(?:command-([0-9]*))*","(right|ctrl-f)"],exec:"gotoright",params:[{name:"times",match:1,type:"number",defaultValue:1}]},{regex:["(?:command-([0-9]*))*","(up|ctrl-p)"],exec:"golineup",params:[{name:"times",match:1,type:"number",defaultValue:1}]},{regex:["(?:command-([0-9]*))*","(left|ctrl-b)"],exec:"gotoleft",params:[{name:"times",match:1,type:"number",defaultValue:1}]},{comment:"This binding matches all printable characters except numbers as long as they are no numbers and print them n times.",regex:["(?:command-([0-9]*))","([^0-9]+)*"],match:e,exec:"inserttext",params:[{name:"times",match:1,type:"number",defaultValue:"1"},{name:"text",match:2}]},{comment:"This binding matches numbers as long as there is no meta_number in the buffer.",regex:["(command-[0-9]*)*","([0-9]+)"],match:e,disallowMatches:[1],exec:"inserttext",params:[{name:"text",match:2,type:"text"}]},{regex:["command-([0-9]*)","(command-[0-9]|[0-9])"],comment:"Stops execution if the regex /meta_[0-9]+/ matches to avoid resetting the buffer."}],"c-x":[{key:"ctrl-g",then:"start"},{key:"ctrl-s",exec:"save",then:"start"}]};b.Emacs=new d(f)}),define("ace/keyboard/state_handler",["require","exports","module"],function(a,b,c){function e(a){this.keymapping=this.$buildKeymappingRegex(a)}var d=!1;e.prototype={$buildKeymappingRegex:function(a){for(var b in a)this.$buildBindingsRegex(a[b]);return a},$buildBindingsRegex:function(a){a.forEach(function(a){a.key?a.key=new RegExp("^"+a.key+"$"):Array.isArray(a.regex)?("key"in a||(a.key=new RegExp("^"+a.regex[1]+"$")),a.regex=new RegExp(a.regex.join("")+"$")):a.regex&&(a.regex=new RegExp(a.regex+"$"))})},$composeBuffer:function(a,b,c){if(a.state==null||a.buffer==null)a.state="start",a.buffer="";var d=[];b&1&&d.push("ctrl"),b&8&&d.push("command"),b&2&&d.push("option"),b&4&&d.push("shift"),c&&d.push(c);var e=d.join("-"),f=a.buffer+e;return b!=2&&(a.buffer=f),{bufferToUse:f,symbolicName:e}},$find:function(a,b,c,e,f){var g={};return this.keymapping[a.state].some(function(h){var i;if(h.key&&!h.key.test(c))return!1;if(h.regex&&!(i=h.regex.exec(b)))return!1;if(h.match&&!h.match(b,e,f,c))return!1;if(h.disallowMatches)for(var j=0;j<h.disallowMatches.length;j++)if(!!i[h.disallowMatches[j]])return!1;if(h.exec){g.command=h.exec;if(h.params){var k;g.args={},h.params.forEach(function(a){a.match!=null&&i!=null?k=i[a.match]||a.defaultValue:k=a.defaultValue,a.type==="number"&&(k=parseInt(k)),g.args[a.name]=k})}a.buffer=""}return h.then&&(a.state=h.then,a.buffer=""),g.command==null&&(g.command="null"),d&&console.log("KeyboardStateMapper#find",h),!0}),g.command?g:(a.buffer="",!1)},handleKeyboard:function(a,b,c){if(b==0||c!=""&&c!=String.fromCharCode(0)){var e=this.$composeBuffer(a,b,c),f=e.bufferToUse,g=e.symbolicName;return e=this.$find(a,f,g,b,c),d&&console.log("KeyboardStateMapper#match",f,g,e),e}return null}},b.matchCharacterOnly=function(a,b,c,d){return b==0?!0:b==4&&c.length==1?!0:!1},b.StateHandler=e})
+define("ace/keyboard/emacs",[], function(require, exports, module) {
+
+var StateHandler = require("ace/keyboard/state_handler").StateHandler;
+var matchCharacterOnly = require("ace/keyboard/state_handler").matchCharacterOnly;
+
+var emacsState = {
+ start: [
+ {
+ key: "ctrl-x",
+ then: "c-x"
+ },
+ {
+ regex: [ "(?:command-([0-9]*))*", "(down|ctrl-n)" ],
+ exec: "golinedown",
+ params: [
+ {
+ name: "times",
+ match: 1,
+ type: "number",
+ defaultValue: 1
+ }
+ ]
+ },
+ {
+ regex: [ "(?:command-([0-9]*))*", "(right|ctrl-f)" ],
+ exec: "gotoright",
+ params: [
+ {
+ name: "times",
+ match: 1,
+ type: "number",
+ defaultValue: 1
+ }
+ ]
+ },
+ {
+ regex: [ "(?:command-([0-9]*))*", "(up|ctrl-p)" ],
+ exec: "golineup",
+ params: [
+ {
+ name: "times",
+ match: 1,
+ type: "number",
+ defaultValue: 1
+ }
+ ]
+ },
+ {
+ regex: [ "(?:command-([0-9]*))*", "(left|ctrl-b)" ],
+ exec: "gotoleft",
+ params: [
+ {
+ name: "times",
+ match: 1,
+ type: "number",
+ defaultValue: 1
+ }
+ ]
+ },
+ {
+ comment: "This binding matches all printable characters except numbers as long as they are no numbers and print them n times.",
+ regex: [ "(?:command-([0-9]*))", "([^0-9]+)*" ],
+ match: matchCharacterOnly,
+ exec: "inserttext",
+ params: [
+ {
+ name: "times",
+ match: 1,
+ type: "number",
+ defaultValue: "1"
+ },
+ {
+ name: "text",
+ match: 2
+ }
+ ]
+ },
+ {
+ comment: "This binding matches numbers as long as there is no meta_number in the buffer.",
+ regex: [ "(command-[0-9]*)*", "([0-9]+)" ],
+ match: matchCharacterOnly,
+ disallowMatches: [ 1 ],
+ exec: "inserttext",
+ params: [
+ {
+ name: "text",
+ match: 2,
+ type: "text"
+ }
+ ]
+ },
+ {
+ regex: [ "command-([0-9]*)", "(command-[0-9]|[0-9])" ],
+ comment: "Stops execution if the regex /meta_[0-9]+/ matches to avoid resetting the buffer."
+ }
+ ],
+ "c-x": [
+ {
+ key: "ctrl-g",
+ then: "start"
+ },
+ {
+ key: "ctrl-s",
+ exec: "save",
+ then: "start"
+ }
+ ]
+};
+
+exports.handler = new StateHandler(emacsState);
+
+});
+
+define("ace/keyboard/state_handler",[], function(require, exports, module) {
+
+// If you're developing a new keymapping and want to get an idea what's going
+// on, then enable debugging.
+var DEBUG = false;
+
+function StateHandler(keymapping) {
+ this.keymapping = this.$buildKeymappingRegex(keymapping);
+}
+
+StateHandler.prototype = {
+ /**
+ * Build the RegExp from the keymapping as RegExp can't stored directly
+ * in the metadata JSON and as the RegExp used to match the keys/buffer
+ * need to be adapted.
+ */
+ $buildKeymappingRegex: function(keymapping) {
+ for (var state in keymapping) {
+ this.$buildBindingsRegex(keymapping[state]);
+ }
+ return keymapping;
+ },
+
+ $buildBindingsRegex: function(bindings) {
+ // Escape a given Regex string.
+ bindings.forEach(function(binding) {
+ if (binding.key) {
+ binding.key = new RegExp('^' + binding.key + '$');
+ } else if (Array.isArray(binding.regex)) {
+ if (!('key' in binding))
+ binding.key = new RegExp('^' + binding.regex[1] + '$');
+ binding.regex = new RegExp(binding.regex.join('') + '$');
+ } else if (binding.regex) {
+ binding.regex = new RegExp(binding.regex + '$');
+ }
+ });
+ },
+
+ $composeBuffer: function(data, hashId, key, e) {
+ // Initialize the data object.
+ if (data.state == null || data.buffer == null) {
+ data.state = "start";
+ data.buffer = "";
+ }
+
+ var keyArray = [];
+ if (hashId & 1) keyArray.push("ctrl");
+ if (hashId & 8) keyArray.push("command");
+ if (hashId & 2) keyArray.push("option");
+ if (hashId & 4) keyArray.push("shift");
+ if (key) keyArray.push(key);
+
+ var symbolicName = keyArray.join("-");
+ var bufferToUse = data.buffer + symbolicName;
+
+ // Don't add the symbolic name to the key buffer if the alt_ key is
+ // part of the symbolic name. If it starts with alt_, this means
+ // that the user hit an alt keycombo and there will be a single,
+ // new character detected after this event, which then will be
+ // added to the buffer (e.g. alt_j will result in ∆).
+ //
+ // We test for 2 and not for & 2 as we only want to exclude the case where
+ // the option key is pressed alone.
+ if (hashId != 2) {
+ data.buffer = bufferToUse;
+ }
+
+ var bufferObj = {
+ bufferToUse: bufferToUse,
+ symbolicName: symbolicName,
+ };
+
+ if (e) {
+ bufferObj.keyIdentifier = e.keyIdentifier
+ }
+
+ return bufferObj;
+ },
+
+ $find: function(data, buffer, symbolicName, hashId, key, keyIdentifier) {
+ // Holds the command to execute and the args if a command matched.
+ var result = {};
+
+ // Loop over all the bindings of the keymap until a match is found.
+ this.keymapping[data.state].some(function(binding) {
+ var match;
+
+ // Check if the key matches.
+ if (binding.key && !binding.key.test(symbolicName)) {
+ return false;
+ }
+
+ // Check if the regex matches.
+ if (binding.regex && !(match = binding.regex.exec(buffer))) {
+ return false;
+ }
+
+ // Check if the match function matches.
+ if (binding.match && !binding.match(buffer, hashId, key, symbolicName, keyIdentifier)) {
+ return false;
+ }
+
+ // Check for disallowed matches.
+ if (binding.disallowMatches) {
+ for (var i = 0; i < binding.disallowMatches.length; i++) {
+ if (!!match[binding.disallowMatches[i]]) {
+ return false;
+ }
+ }
+ }
+
+ // If there is a command to execute, then figure out the
+ // command and the arguments.
+ if (binding.exec) {
+ result.command = binding.exec;
+
+ // Build the arguments.
+ if (binding.params) {
+ var value;
+ result.args = {};
+ binding.params.forEach(function(param) {
+ if (param.match != null && match != null) {
+ value = match[param.match] || param.defaultValue;
+ } else {
+ value = param.defaultValue;
+ }
+
+ if (param.type === 'number') {
+ value = parseInt(value);
+ }
+
+ result.args[param.name] = value;
+ });
+ }
+ data.buffer = "";
+ }
+
+ // Handle the 'then' property.
+ if (binding.then) {
+ data.state = binding.then;
+ data.buffer = "";
+ }
+
+ // If no command is set, then execute the "null" fake command.
+ if (result.command == null) {
+ result.command = "null";
+ }
+
+ if (DEBUG) {
+ console.log("KeyboardStateMapper#find", binding);
+ }
+ return true;
+ });
+
+ if (result.command) {
+ return result;
+ } else {
+ data.buffer = "";
+ return false;
+ }
+ },
+
+ /**
+ * This function is called by keyBinding.
+ */
+ handleKeyboard: function(data, hashId, key, keyCode, e) {
+ // If we pressed any command key but no other key, then ignore the input.
+ // Otherwise "shift-" is added to the buffer, and later on "shift-g"
+ // which results in "shift-shift-g" which doesn't make sense.
+ if (hashId != 0 && (key == "" || key == String.fromCharCode(0))) {
+ return null;
+ }
+
+ // Compute the current value of the keyboard input buffer.
+ var r = this.$composeBuffer(data, hashId, key, e);
+ var buffer = r.bufferToUse;
+ var symbolicName = r.symbolicName;
+ var keyId = r.keyIdentifier;
+
+ r = this.$find(data, buffer, symbolicName, hashId, key, keyId);
+ if (DEBUG) {
+ console.log("KeyboardStateMapper#match", buffer, symbolicName, r);
+ }
+
+ return r;
+ }
+}
+
+/**
+ * This is a useful matching function and therefore is defined here so that
+ * users of KeyboardStateMapper can use it.
+ *
+ * @return boolean
+ * If no command key (Command|Option|Shift|Ctrl) is pressed, it
+ * returns true. If the only the Shift key is pressed + a character
+ * true is returned as well. Otherwise, false is returned.
+ * Summing up, the function returns true whenever the user typed
+ * a normal character on the keyboard and no shortcut.
+ */
+exports.matchCharacterOnly = function(buffer, hashId, key, symbolicName) {
+ // If no command keys are pressed, then catch the input.
+ if (hashId == 0) {
+ return true;
+ }
+ // If only the shift key is pressed and a character key, then
+ // catch that input as well.
+ else if ((hashId == 4) && key.length == 1) {
+ return true;
+ }
+ // Otherwise, we let the input got through.
+ else {
+ return false;
+ }
+};
+
+exports.StateHandler = StateHandler;
+});
+
View
1,247 chrome/content/ace++/res/ace/keybinding-vim.js
@@ -1 +1,1246 @@
-define("ace/keyboard/keybinding/vim",["require","exports","module","ace/keyboard/state_handler"],function(a,b,c){var d=a("../state_handler").StateHandler,e=a("../state_handler").matchCharacterOnly,f=function(a,b,c){return{regex:["([0-9]*)",a],exec:b,params:[{name:"times",match:1,type:"number",defaultValue:1}],then:c}},g={start:[{key:"i",then:"insertMode"},{key:"d",then:"deleteMode"},{key:"a",exec:"gotoright",then:"insertMode"},{key:"shift-i",exec:"gotolinestart",then:"insertMode"},{key:"shift-a",exec:"gotolineend",then:"insertMode"},{key:"shift-c",exec:"removetolineend",then:"insertMode"},{key:"shift-r",exec:"overwrite",then:"replaceMode"},f("(k|up)","golineup"),f("(j|down)","golinedown"),f("(l|right)","gotoright"),f("(h|left)","gotoleft"),{key:"shift-g",exec:"gotoend"},f("b","gotowordleft"),f("e","gotowordright"),f("x","del"),f("shift-x","backspace"),f("shift-d","removetolineend"),f("u","undo"),{comment:"Catch some keyboard input to stop it here",match:e}],insertMode:[{key:"esc",then:"start"}],replaceMode:[{key:"esc",exec:"overwrite",then:"start"}],deleteMode:[{key:"d",exec:"removeline",then:"start"}]};b.Vim=new d(g)}),define("ace/keyboard/state_handler",["require","exports","module"],function(a,b,c){function e(a){this.keymapping=this.$buildKeymappingRegex(a)}var d=!1;e.prototype={$buildKeymappingRegex:function(a){for(var b in a)this.$buildBindingsRegex(a[b]);return a},$buildBindingsRegex:function(a){a.forEach(function(a){a.key?a.key=new RegExp("^"+a.key+"$"):Array.isArray(a.regex)?("key"in a||(a.key=new RegExp("^"+a.regex[1]+"$")),a.regex=new RegExp(a.regex.join("")+"$")):a.regex&&(a.regex=new RegExp(a.regex+"$"))})},$composeBuffer:function(a,b,c){if(a.state==null||a.buffer==null)a.state="start",a.buffer="";var d=[];b&1&&d.push("ctrl"),b&8&&d.push("command"),b&2&&d.push("option"),b&4&&d.push("shift"),c&&d.push(c);var e=d.join("-"),f=a.buffer+e;return b!=2&&(a.buffer=f),{bufferToUse:f,symbolicName:e}},$find:function(a,b,c,e,f){var g={};return this.keymapping[a.state].some(function(h){var i;if(h.key&&!h.key.test(c))return!1;if(h.regex&&!(i=h.regex.exec(b)))return!1;if(h.match&&!h.match(b,e,f,c))return!1;if(h.disallowMatches)for(var j=0;j<h.disallowMatches.length;j++)if(!!i[h.disallowMatches[j]])return!1;if(h.exec){g.command=h.exec;if(h.params){var k;g.args={},h.params.forEach(function(a){a.match!=null&&i!=null?k=i[a.match]||a.defaultValue:k=a.defaultValue,a.type==="number"&&(k=parseInt(k)),g.args[a.name]=k})}a.buffer=""}return h.then&&(a.state=h.then,a.buffer=""),g.command==null&&(g.command="null"),d&&console.log("KeyboardStateMapper#find",h),!0}),g.command?g:(a.buffer="",!1)},handleKeyboard:function(a,b,c){if(b==0||c!=""&&c!=String.fromCharCode(0)){var e=this.$composeBuffer(a,b,c),f=e.bufferToUse,g=e.symbolicName;return e=this.$find(a,f,g,b,c),d&&console.log("KeyboardStateMapper#match",f,g,e),e}return null}},b.matchCharacterOnly=function(a,b,c,d){return b==0?!0:b==4&&c.length==1?!0:!1},b.StateHandler=e})
+define("ace/keyboard/vim",[], function(require, exports, module) {
+
+"never use strict";
+
+var commands = require("ace/keyboard/vim/commands");
+var util = require("ace/keyboard/vim/maps/util");
+
+exports.handler = require("ace/keyboard/vim/keyboard").handler;
+
+exports.onCursorMove = function(e) {
+ commands.onCursorMove(e.editor);
+ exports.onCursorMove.scheduled = false;
+};
+
+exports.handler.attach = function(editor) {
+ editor.on("click", exports.onCursorMove);
+ if (util.currentMode !== "insert")
+ commands.coreCommands.stop.exec(editor);
+};
+
+exports.handler.detach = function(editor) {
+ editor.removeListener("click", exports.onCursorMove);
+ commands.coreCommands.start.exec(editor);
+ util.currentMode = "normal";
+};
+
+});
+
+define("ace/keyboard/vim/commands",[], function(require, exports, module) {
+
+"never use strict";
+
+var util = require("ace/keyboard/vim/maps/util");
+var motions = require("ace/keyboard/vim/maps/motions");
+var operators = require("ace/keyboard/vim/maps/operators");
+var alias = require("ace/keyboard/vim/maps/aliases");
+var registers = require("ace/keyboard/vim/registers");
+
+var NUMBER = 1;
+var OPERATOR = 2;
+var MOTION = 3;
+var ACTION = 4;
+
+//var NORMAL_MODE = 0;
+//var INSERT_MODE = 1;
+//var VISUAL_MODE = 2;
+//getSelectionLead
+
+exports.searchStore = {
+ current: "",
+ options: {
+ needle: "",
+ backwards: false,
+ wrap: true,
+ caseSensitive: false,
+ wholeWord: false,
+ regExp: false
+ }
+};
+
+var repeat = function repeat(fn, count, args) {
+ count = parseInt(count);
+ while (0 < count--)
+ fn.apply(this, args);
+};
+
+var actions = {
+ "z": {
+ param: true,
+ fn: function(editor, range, count, param) {
+ switch (param) {
+ case "z":
+ editor.centerSelection();
+ break;
+ case "t":
+ editor.scrollToRow(editor.getCursorPosition().row);
+ break;
+ }
+ }
+ },
+ "r": {
+ param: true,
+ fn: function(editor, range, count, param) {
+ param = util.toRealChar(param);
+ if (param && param.length) {
+ repeat(function() { editor.insert(param); }, count || 1);
+ editor.navigateLeft();
+ }
+ }
+ },
+ // "~" HACK
+ "shift-`": {
+ fn: function(editor, range, count) {
+ repeat(function() {
+ var pos = editor.getCursorPosition();
+ var line = editor.session.getLine(pos.row);
+ var ch = line[pos.column];
+ editor.insert(toggleCase(ch));
+ }, count || 1);
+ }
+ },
+ "*": {
+ fn: function(editor, range, count, param) {
+ editor.selection.selectWord();
+ editor.findNext();
+ var cursor = editor.selection.getCursor();
+ var range = editor.session.getWordRange(cursor.row, cursor.column);
+ editor.selection.setSelectionRange(range, true);
+ }
+ },
+ "#": {
+ fn: function(editor, range, count, param) {
+ editor.selection.selectWord();
+ editor.findPrevious();
+ var cursor = editor.selection.getCursor();
+ var range = editor.session.getWordRange(cursor.row, cursor.column);
+ editor.selection.setSelectionRange(range, true);
+ }
+ },
+ "n": {
+ fn: function(editor, range, count, param) {
+ editor.findNext(editor.getLastSearchOptions());
+ editor.selection.clearSelection();
+ //editor.navigateWordLeft();
+ }
+ },
+ "shift-n": {
+ fn: function(editor, range, count, param) {
+ editor.findPrevious(editor.getLastSearchOptions());
+ editor.selection.clearSelection();
+ //editor.navigateWordLeft();
+ }
+ },
+ "v": {
+ fn: function(editor, range, count, param) {
+ editor.selection.selectRight();
+ util.onVisualMode = true;
+ util.onVisualLineMode = false;
+ var cursor = document.getElementsByClassName("ace_cursor")[0];
+ cursor.style.display = "none";
+ }
+ },
+ "shift-v": {
+ fn: function(editor, range, count, param) {
+ util.onVisualLineMode = true;
+ //editor.selection.selectLine();
+ //editor.selection.selectLeft();
+ var row = editor.getCursorPosition().row;
+ editor.selection.clearSelection();
+ editor.selection.moveCursorTo(row, 0);
+ editor.selection.selectLineEnd();
+ editor.selection.visualLineStart = row;
+ }
+ },
+ "shift-y": {
+ fn: function(editor, range, count, param) {
+ util.copyLine(editor);
+ }
+ },
+ "p": {
+ fn: function(editor, range, count, param) {
+ var defaultReg = registers._default;
+
+ editor.setOverwrite(false);
+ if (defaultReg.isLine) {
+ var pos = editor.getCursorPosition();
+ var lines = defaultReg.text.split("\n");
+ editor.session.getDocument().insertLines(pos.row + 1, lines);
+ editor.moveCursorTo(pos.row + 1, 0);
+ }
+ else {
+ editor.navigateRight();
+ editor.insert(defaultReg.text);
+ editor.navigateLeft();
+ }
+ editor.setOverwrite(true);
+ editor.selection.clearSelection();
+ }
+ },
+ "shift-p": {
+ fn: function(editor, range, count, param) {
+ var defaultReg = registers._default;
+ editor.setOverwrite(false);
+
+ if (defaultReg.isLine) {
+ var pos = editor.getCursorPosition();
+ var lines = defaultReg.text.split("\n");
+ editor.session.getDocument().insertLines(pos.row, lines);
+ editor.moveCursorTo(pos.row, 0);
+ }
+ else {
+ editor.insert(defaultReg.text);
+ }
+ editor.setOverwrite(true);
+ editor.selection.clearSelection();
+ }
+ },
+ "shift-j": {
+ fn: function(editor, range, count, param) {
+ var pos = editor.getCursorPosition();
+
+ if (editor.session.getLength() === pos.row + 1)
+ return;
+
+ var nextLine = editor.session.getLine(pos.row + 1);
+ var cleanLine = /^\s*(.*)$/.exec(nextLine)[1];
+
+ editor.navigateDown();
+ editor.removeLines();
+
+ if (editor.session.getLength() > editor.getCursorPosition().row + 1)
+ editor.navigateUp();
+
+ editor.navigateLineEnd();
+ editor.insert(" " + (cleanLine || ""));
+ editor.moveCursorTo(pos.row, pos.column);
+
+ }
+ },
+ "u": {
+ fn: function(editor, range, count, param) {
+ count = parseInt(count || 1, 10);
+ for (var i = 0; i < count; i++) {
+ editor.undo();
+ }
+ editor.selection.clearSelection();
+ }
+ },
+ "ctrl-r": {
+ fn: function(editor, range, count, param) {
+ count = parseInt(count || 1, 10);
+ for (var i = 0; i < count; i++) {
+ editor.redo();
+ }
+ editor.selection.clearSelection();
+ }
+ },
+ ":": {
+ fn: function(editor, range, count, param) {
+ editor.blur();
+ txtConsoleInput.focus();
+ txtConsoleInput.setValue(":");
+ }
+ },
+ "/": {
+ fn: function(editor, range, count, param) {
+ editor.blur();
+ txtConsoleInput.focus();
+ txtConsoleInput.setValue("/");
+ }
+ },
+ ".": {
+ fn: function(editor, range, count, param) {
+ var previous = inputBuffer.previous;
+ util.onInsertReplaySequence = inputBuffer.lastInsertCommands;
+ inputBuffer.exec(editor, previous.action, previous.param);
+ }
+ }
+};
+
+var inputBuffer = exports.inputBuffer = {
+ accepting: [NUMBER, OPERATOR, MOTION, ACTION],
+ currentCmd: null,
+ //currentMode: 0,
+ currentCount: "",
+
+ // Types
+ operator: null,
+ motion: null,
+
+ lastInsertCommands: [],
+
+ push: function(editor, char, keyId) {
+ if (char && char.length > 1) { // There is a modifier key
+ if (!char[char.length - 1].match(/[A-za-z]/) && keyId) // It is a letter
+ char = keyId;
+ }
+
+ this.idle = false;
+ var wObj = this.waitingForParam;
+ if (wObj) {
+ this.exec(editor, wObj, char);
+ }
+ // If input is a number (that doesn't start with 0)
+ else if (!(char === "0" && !this.currentCount.length) &&
+ (char.match(/^\d+$/) && this.isAccepting(NUMBER))) {
+ // Assuming that char is always of type String, and not Number
+ this.currentCount += char;
+ this.currentCmd = NUMBER;
+ this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
+ }
+ else if (!this.operator && this.isAccepting(OPERATOR) && operators[char]) {
+ this.operator = {
+ char: char,
+ count: this.getCount()
+ };
+ this.currentCmd = OPERATOR;
+ this.accepting = [NUMBER, MOTION, ACTION];
+ this.exec(editor, { operator: this.operator });
+ }
+ else if (motions[char] && this.isAccepting(MOTION)) {
+ this.currentCmd = MOTION;
+
+ var ctx = {
+ operator: this.operator,
+ motion: {
+ char: char,
+ count: this.getCount()
+ }
+ };
+
+ if (motions[char].param)
+ this.waitForParam(ctx);
+ else
+ this.exec(editor, ctx);
+ }
+ else if (alias[char] && this.isAccepting(MOTION)) {
+ alias[char].operator.count = this.getCount();
+ this.exec(editor, alias[char]);
+ }
+ else if (actions[char] && this.isAccepting(ACTION)) {
+ var actionObj = {
+ action: {
+ fn: actions[char].fn,
+ count: this.getCount()
+ }
+ };
+
+ if (actions[char].param) {
+ this.waitForParam(actionObj);
+ }
+ else {
+ this.exec(editor, actionObj);
+ }
+ }
+ else if (this.operator) {
+ this.exec(editor, { operator: this.operator }, char);
+ }
+ else {
+ this.reset();
+ }
+ },
+
+ waitForParam: function(cmd) {
+ this.waitingForParam = cmd;
+ },
+
+ getCount: function() {
+ var count = this.currentCount;
+ this.currentCount = "";
+ return count;
+ },
+
+ exec: function(editor, action, param) {
+ var m = action.motion;
+ var o = action.operator;
+ var a = action.action;
+
+ if(o) {
+ this.previous = {
+ action: action,
+ param: param
+ };
+ }
+
+ if (o && !editor.selection.isEmpty()) {
+ if (operators[o.char].selFn) {
+ operators[o.char].selFn(editor, editor.getSelectionRange(), o.count, param);
+ this.reset();
+ }
+ return;
+ }
+
+ // There is an operator, but no motion or action. We try to pass the
+ // current char to the operator to see if it responds to it (an example
+ // of this is the 'dd' operator).
+ else if (!m && !a && o && param) {
+ operators[o.char].fn(editor, null, o.count, param);
+ this.reset();
+ }
+ else if (m) {
+ var run = function(fn) {
+ if (fn && typeof fn === "function") { // There should always be a motion
+ if (m.count)
+ repeat(fn, m.count, [editor, null, m.count, param]);
+ else
+ fn(editor, null, m.count, param);
+ }
+ };
+
+ var motionObj = motions[m.char];
+ var selectable = motionObj.sel;
+
+ if (!o) {
+ if ((util.onVisualMode || util.onVisualLineMode) && selectable)
+ run(motionObj.sel);
+ else
+ run(motionObj.nav);
+ }
+ else if (selectable) {
+ repeat(function() {
+ run(motionObj.sel);
+ operators[o.char].fn(editor, editor.getSelectionRange(), o.count, param);
+ }, o.count || 1);
+ }
+ this.reset();
+ }
+ else if (a) {
+ a.fn(editor, editor.getSelectionRange(), a.count, param);
+ this.reset();
+ }
+ handleCursorMove(editor);
+ },
+
+ isAccepting: function(type) {
+ return this.accepting.indexOf(type) !== -1;
+ },
+
+ reset: function() {
+ this.operator = null;
+ this.motion = null;
+ this.currentCount = "";
+ this.accepting = [NUMBER, OPERATOR, MOTION, ACTION];
+ this.idle = true;
+ this.waitingForParam = null;
+ }
+};
+
+function setPreviousCommand(fn) {
+ inputBuffer.previous = { action: { action: { fn: fn } } };
+}
+
+exports.coreCommands = {
+ start: {
+ exec: function start(editor) {
+ util.insertMode(editor);
+ setPreviousCommand(start);
+ }
+ },
+ startBeginning: {
+ exec: function startBeginning(editor) {
+ editor.navigateLineStart();
+ util.insertMode(editor);
+ setPreviousCommand(startBeginning);
+ }
+ },
+ // Stop Insert mode as soon as possible. Works like typing <Esc> in
+ // insert mode.
+ stop: {
+ exec: function stop(editor) {
+ inputBuffer.reset();
+ util.onVisualMode = false;
+ util.onVisualLineMode = false;
+ inputBuffer.lastInsertCommands = util.normalMode(editor);
+ }
+ },
+ append: {
+ exec: function append(editor) {
+ var pos = editor.getCursorPosition();
+ var lineLen = editor.session.getLine(pos.row).length;
+ if (lineLen)
+ editor.navigateRight();
+ util.insertMode(editor);
+ setPreviousCommand(append);
+ }
+ },
+ appendEnd: {
+ exec: function appendEnd(editor) {
+ editor.navigateLineEnd();
+ util.insertMode(editor);
+ setPreviousCommand(appendEnd);
+ }
+ },
+ builder: {
+ exec: function builder(editor) {}
+ }
+};
+
+var handleCursorMove = exports.onCursorMove = function(editor) {
+ if(util.currentMode === 'insert' || handleCursorMove.running)
+ return;
+ else if(!editor.selection.isEmpty()) {
+ handleCursorMove.running = true;
+ if(util.onVisualLineMode) {
+ var originRow = editor.selection.visualLineStart;
+ var cursorRow = editor.getCursorPosition().row;
+ if(originRow <= cursorRow) {
+ var endLine = editor.session.getLine(cursorRow);
+ editor.selection.clearSelection();
+ editor.selection.moveCursorTo(originRow, 0);
+ editor.selection.selectTo(cursorRow, endLine.length);
+ } else {
+ var endLine = editor.session.getLine(originRow);
+ editor.selection.clearSelection();
+ editor.selection.moveCursorTo(originRow, endLine.length);
+ editor.selection.selectTo(cursorRow, 0);
+ }
+ }
+ handleCursorMove.running = false;
+ return;
+ }
+ else {
+ handleCursorMove.running = true;
+ var pos = editor.getCursorPosition();
+ var lineLen = editor.session.getLine(pos.row).length;
+
+ if (lineLen && pos.column === lineLen)
+ editor.navigateLeft();
+ handleCursorMove.running = false;
+ }
+};
+
+function toggleCase(ch) {
+ if(ch.toUpperCase() === ch)
+ return ch.toLowerCase();
+ else
+ return ch.toUpperCase();
+}
+
+});
+
+define("ace/keyboard/vim/maps/util",[], function(require, exports, module) {
+var registers = require("ace/keyboard/vim/registers");
+
+module.exports = {
+ onVisualMode: false,
+ onVisualLineMode: false,
+ currentMode: 'normal',
+ insertMode: function(editor) {
+ var _self = this;
+ var theme = editor && editor.getTheme() || "ace/theme/textmate";
+
+ require(["require", theme], function (require) {
+ var isDarkTheme = require(theme).isDark;
+
+ _self.currentMode = 'insert';
+ // Switch editor to insert mode
+ editor.unsetStyle('insert-mode');
+
+ var cursor = document.getElementsByClassName("ace_cursor")[0];
+ if (cursor) {
+ cursor.style.display = null;
+ cursor.style.backgroundColor = null;
+ cursor.style.opacity = null;
+ cursor.style.border = null;
+ cursor.style.borderLeftColor = isDarkTheme? "#eeeeee" : "#333333";
+ cursor.style.borderLeftStyle = "solid";
+ cursor.style.borderLeftWidth = "2px";
+ }
+
+ editor.setOverwrite(false);
+ editor.keyBinding.$data.buffer = "";
+ editor.keyBinding.$data.state = "insertMode";
+ _self.onVisualMode = false;
+ _self.onVisualLineMode = false;
+ if(_self.onInsertReplaySequence) {
+ // Ok, we're apparently replaying ("."), so let's do it
+ editor.commands.macro = _self.onInsertReplaySequence;
+ editor.commands.replay(editor);
+ _self.onInsertReplaySequence = null;
+ _self.normalMode(editor);
+ } else {
+ // Record any movements, insertions in insert mode
+ if(!editor.commands.recording)
+ editor.commands.toggleRecording();
+ }
+ });
+ },
+ normalMode: function(editor) {
+ // Switch editor to normal mode
+ this.currentMode = 'normal';
+
+ editor.setStyle('normal-mode');
+ editor.clearSelection();
+
+ var cursor = document.getElementsByClassName("ace_cursor")[0];
+ if (cursor) {
+ cursor.style.display = null;
+ cursor.style.backgroundColor = "red";
+ cursor.style.opacity = ".5";
+ cursor.style.border = "0";
+ }
+
+ var pos;
+ if (!editor.getOverwrite()) {
+ pos = editor.getCursorPosition();
+ if (pos.column > 0)
+ editor.navigateLeft();
+ }
+ editor.setOverwrite(true);
+ editor.keyBinding.$data.buffer = "";
+ editor.keyBinding.$data.state = "start";
+ this.onVisualMode = false;
+ this.onVisualLineMode = false;
+ // Save recorded keystrokes
+ if(editor.commands.recording) {
+ editor.commands.toggleRecording();
+ return editor.commands.macro;
+ }
+ else {
+ return [];
+ }
+ },
+ getRightNthChar: function(editor, cursor, char, n) {
+ var line = editor.getSession().getLine(cursor.row);
+ var matches = line.substr(cursor.column + 1).split(char);
+
+ return n < matches.length ? matches.slice(0, n).join(char).length : 0;
+ },
+ getLeftNthChar: function(editor, cursor, char, n) {
+ var line = editor.getSession().getLine(cursor.row);
+ var matches = line.substr(0, cursor.column + 1).split(char);
+
+ return n < matches.length ? matches.slice(-1 * n).join(char).length + 1: 0;
+ },
+ toRealChar: function(char) {
+ if (char.length === 1)
+ return char;
+
+ if (/^shift-./.test(char))
+ return char[char.length - 1].toUpperCase();
+ else
+ return "";
+ },
+ copyLine: function(editor) {
+ var pos = editor.getCursorPosition();
+ editor.selection.clearSelection();
+ editor.moveCursorTo(pos.row, pos.column);
+ editor.selection.selectLine();
+ registers._default.isLine = true;
+ registers._default.text = editor.getCopyText().replace(/\n$/, "");
+ editor.selection.clearSelection();
+ editor.moveCursorTo(pos.row, pos.column);
+ }
+};
+});
+
+define("ace/keyboard/vim/keyboard",[], function(require, exports, module) {
+
+"never use strict";
+
+var StateHandler = require("ace/keyboard/state_handler").StateHandler;
+var cmds = require("ace/keyboard/vim/commands");
+var coreCommands = cmds.coreCommands;
+
+var matchChar = function(buffer, hashId, key, symbolicName, keyId) {
+ // If no command keys are pressed, then catch the input.
+ // If only the shift key is pressed and a character key, then
+ // catch that input as well.
+ // Otherwise, we let the input got through.
+ var matched = ((hashId === 0) || (((hashId === 1) || (hashId === 4)) && key.length === 1));
+ //console.log("INFO", arguments)
+
+ if (matched) {
+ if (keyId) {
+ keyId = String.fromCharCode(parseInt(keyId.replace("U+", "0x"), 10));
+ }
+
+ coreCommands.builder.exec = function(editor) {
+ cmds.inputBuffer.push.call(cmds.inputBuffer, editor, symbolicName, keyId);
+ }
+ }
+ return matched;
+};
+
+var inIdleState = function() {
+ if (cmds.inputBuffer.idle) {
+ return true;
+ }
+ return false;
+};
+
+var states = exports.states = {
+ start: [ // normal mode
+ {
+ key: "esc",
+ exec: coreCommands.stop,
+ then: "start"
+ },
+ {
+ regex: "^i$",
+ match: inIdleState,
+ exec: coreCommands.start,
+ then: "insertMode"
+ },
+ {
+ regex: "^shift-i$",
+ match: inIdleState,
+ exec: coreCommands.startBeginning,
+ then: "insertMode"
+ },
+ {
+ regex: "^a$",
+ match: inIdleState,
+ exec: coreCommands.append,
+ then: "insertMode"
+ },
+ {
+ regex: "^shift-a$",
+ match: inIdleState,
+ exec: coreCommands.appendEnd,
+ then: "insertMode"
+ },
+ {
+ // The rest of input will be processed here
+ match: matchChar,
+ exec: coreCommands.builder
+ }
+ ],
+ insertMode: [
+ {
+ key: "esc",
+ exec: coreCommands.stop,
+ then: "start"
+ },
+ {
+ key: "backspace",
+ exec: "backspace"
+ }
+ ]
+};
+
+exports.handler = new StateHandler(states);
+});
+
+"never use strict"
+
+define("ace/keyboard/vim/maps/motions",[], function(require, exports, module) {
+
+var util = require("ace/keyboard/vim/maps/util");
+
+var keepScrollPosition = function(editor, fn) {
+ var scrollTopRow = editor.renderer.getScrollTopRow();
+ var initialRow = editor.getCursorPosition().row;
+ var diff = initialRow - scrollTopRow;
+ fn && fn.call(editor);
+ editor.renderer.scrollToRow(editor.getCursorPosition().row - diff);
+};
+
+module.exports = {
+ "w": {
+ nav: function(editor) {
+ editor.navigateWordRight();
+ },
+ sel: function(editor) {
+ editor.selection.selectWordRight();
+ }
+ },
+ "b": {
+ nav: function(editor) {
+ editor.navigateWordLeft();
+ },
+ sel: function(editor) {
+ editor.selection.selectWordLeft();
+ }
+ },
+ "l": {
+ nav: function(editor) {
+ editor.navigateRight();
+ },
+ sel: function(editor) {
+ var pos = editor.getCursorPosition();
+ var col = pos.column;
+ var lineLen = editor.session.getLine(pos.row).length;
+
+ // Solving the behavior at the end of the line due to the
+ // different 0 index-based colum positions in ACE.
+ if (lineLen && col !== lineLen) //In selection mode you can select the newline
+ editor.selection.selectRight();
+ }
+ },
+ "h": {
+ nav: function(editor) {
+ var pos = editor.getCursorPosition();
+ if (pos.column > 0)
+ editor.navigateLeft();
+ },
+ sel: function(editor) {
+ var pos = editor.getCursorPosition();
+ if (pos.column > 0)
+ editor.selection.selectLeft();
+ }
+ },
+ "k": {
+ nav: function(editor) {
+ editor.navigateUp();
+ },
+ sel: function(editor) {
+ editor.selection.selectUp();
+ }
+ },
+ "j": {
+ nav: function(editor) {
+ editor.navigateDown();
+ },
+ sel: function(editor) {
+ editor.selection.selectDown();
+ }
+ },
+ "i": {
+ param: true,
+ sel: function(editor, range, count, param) {
+ switch (param) {
+ case "w":
+ editor.selection.selectWord();
+ }
+ }
+ },
+ "a": {
+ param: true,
+ sel: function(editor, range, count, param) {
+ switch (param) {
+ case "w":
+ editor.selection.selectAWord();
+ }
+ }
+ },
+ "f": {
+ param: true,
+ nav: function(editor, range, count, param) {
+ count = parseInt(count, 10) || 1;
+ var ed = editor;
+ var cursor = ed.getCursorPosition();
+ var column = util.getRightNthChar(editor, cursor, param, count);
+
+ if (typeof column === "number") {
+ ed.selection.clearSelection(); // Why does it select in the first place?
+ ed.moveCursorTo(cursor.row, column + cursor.column + 1);
+ }
+ },
+ sel: function(editor, range, count, param) {
+ count = parseInt(count, 10) || 1;
+ var ed = editor;
+ var cursor = ed.getCursorPosition();
+ var column = util.getRightNthChar(editor, cursor, param, count);
+
+ if (typeof column === "number") {
+ ed.moveCursorTo(cursor.row, column + cursor.column + 1);
+ }
+ }
+ },
+ "t": {
+ param: true,
+ nav: function(editor, range, count, param) {
+ count = parseInt(count, 10) || 1;
+ var ed = editor;
+ var cursor = ed.getCursorPosition();
+ var column = util.getRightNthChar(editor, cursor, param, count);
+
+ if (typeof column === "number") {
+ ed.selection.clearSelection(); // Why does it select in the first place?
+ ed.moveCursorTo(cursor.row, column + cursor.column);
+ }
+ },
+ sel: function(editor, range, count, param) {
+ count = parseInt(count, 10) || 1;
+ var ed = editor;
+ var cursor = ed.getCursorPosition();
+ var column = util.getRightNthChar(editor, cursor, param, count);
+
+ if (typeof column === "number") {
+ ed.moveCursorTo(cursor.row, column + cursor.column);
+ }
+ }
+ },
+ "^": {
+ nav: function(editor) {
+ editor.navigateLineStart();
+ },
+ sel: function(editor) {
+ editor.selection.selectLineStart();
+ }
+ },
+ "$": {
+ nav: function(editor) {
+ editor.navigateLineEnd();
+ },
+ sel: function(editor) {
+ editor.selection.selectLineEnd();
+ }
+ },
+ "0": {
+ nav: function(editor) {
+ var ed = editor;
+ ed.navigateTo(ed.selection.selectionLead.row, 0);
+ },
+ sel: function(editor) {
+ var ed = editor;
+ ed.selectTo(ed.selection.selectionLead.row, 0);
+ }
+ },
+ "shift-g": {
+ nav: function(editor, range, count, param) {
+ count = parseInt(count, 10);
+ if (!count && count !== 0) { // Stupid JS
+ count = editor.session.getLength();
+ }
+ editor.gotoLine(count);
+ },
+ sel: function(editor, range, count, param) {
+ count = parseInt(count, 10);
+ if (!count && count !== 0) { // Stupid JS
+ count = editor.session.getLength();
+ }
+ editor.selection.selectTo(count, 0);
+ }
+ },
+ "ctrl-d": {
+ nav: function(editor, range, count, param) {
+ editor.selection.clearSelection();
+ keepScrollPosition(editor, editor.gotoPageDown);
+ },
+ sel: function(editor, range, count, param) {
+ keepScrollPosition(editor, editor.selectPageDown);
+ }
+ },
+ "ctrl-u": {
+ nav: function(editor, range, count, param) {
+ editor.selection.clearSelection();
+ keepScrollPosition(editor, editor.gotoPageUp);
+
+ },
+ sel: function(editor, range, count, param) {
+ keepScrollPosition(editor, editor.selectPageUp);
+ }
+ },
+ "g": {
+ param: true,
+ nav: function(editor, range, count, param) {
+ switch(param) {
+ case "m":
+ console.log("Middle line");
+ break;
+ case "e":
+ console.log("End of prev word");
+ break;
+ case "g":
+ editor.gotoLine(count || 0);
+ }
+ },
+ sel: function(editor, range, count, param) {
+ switch(param) {
+ case "m":
+ console.log("Middle line");
+ break;
+ case "e":
+ console.log("End of prev word");
+ break;
+ case "g":
+ editor.selection.selectTo(count || 0, 0);
+ }
+ }
+ },
+ "o": {
+ nav: function(editor, range, count, param) {
+ count = count || 1;
+ var content = "";
+ while (0 < count--)
+ content += "\n";
+
+ if (content.length) {
+ editor.navigateLineEnd()
+ editor.insert(content);
+ util.insertMode(editor);
+ }
+ }
+ },
+ "shift-o": {
+ nav: function(editor, range, count, param) {
+ var row = editor.getCursorPosition().row;
+ count = count || 1;
+ var content = "";
+ while (0 < count--)
+ content += "\n";
+
+ if (content.length) {
+ if(row > 0) {
+ editor.navigateUp();
+ editor.navigateLineEnd()
+ editor.insert(content);
+ } else {
+ editor.session.insert({row: 0, column: 0}, content);
+ editor.navigateUp();
+ }
+ util.insertMode(editor);
+ }
+ }
+ },
+ "%": {
+ nav: function(editor, range, count, param) {
+ var cursor = editor.getCursorPosition();
+ var match = editor.session.findMatchingBracket({
+ row: cursor.row,
+ column: cursor.column + 1
+ });
+
+ if (match)
+ editor.moveCursorTo(match.row, match.column);
+ }
+ }
+};
+
+module.exports.backspace = module.exports.left = module.exports.h;
+module.exports.right = module.exports.l;
+module.exports.up = module.exports.k;
+module.exports.down = module.exports.j;
+module.exports.pagedown = module.exports["ctrl-d"];
+module.exports.pageup = module.exports["ctrl-u"];
+
+});
+
+define("ace/keyboard/vim/maps/operators",[], function(require, exports, module) {
+
+"never use strict";
+
+var util = require("ace/keyboard/vim/maps/util");
+var registers = require("ace/keyboard/vim/registers");
+
+module.exports = {
+ "d": {
+ selFn: function(editor, range, count, param) {
+ registers._default.text = editor.getCopyText();
+ registers._default.isLine = util.onVisualLineMode;
+ if(util.onVisualLineMode)
+ editor.removeLines();
+ else
+ editor.session.remove(range);
+ util.normalMode(editor);
+ },
+ fn: function(editor, range, count, param) {
+ count = parseInt(count || 1, 10);
+ switch (param) {
+ case "d":
+ registers._default.text = "";
+ registers._default.isLine = true;
+ for (var i=0; i<count; i++) {
+ editor.selection.selectLine();
+ registers._default.text += editor.getCopyText();
+ var selRange = editor.getSelectionRange();
+ editor.session.remove(selRange);
+ editor.selection.clearSelection();
+ }
+ registers._default.text = registers._default.text.replace(/\n$/, "");
+ break;
+ default:
+ if (range) {
+ editor.selection.setSelectionRange(range);
+ registers._default.text = editor.getCopyText();
+ registers._default.isLine = false;
+ editor.session.remove(range);
+ editor.selection.clearSelection();
+ }
+ }
+ }
+ },
+ "c": {
+ selFn: function(editor, range, count, param) {
+ editor.session.remove(range);
+ util.insertMode(editor);
+ },
+ fn: function(editor, range, count, param) {
+ count = parseInt(count || 1, 10);
+ switch (param) {
+ case "c":
+ for (var i=0; i < count; i++) {
+ editor.removeLines();
+ util.insertMode(editor);
+ }
+
+ break;
+ default:
+ if (range) {
+ editor.session.remove(range);
+ util.insertMode(editor);
+ }
+ }
+ }
+ },
+ "y": {
+ selFn: function(editor, range, count, param) {
+ registers._default.text = editor.getCopyText();
+ registers._default.isLine = util.onVisualLineMode;
+ editor.selection.clearSelection();
+ util.normalMode(editor);
+ },
+ fn: function(editor, range, count, param) {
+ count = parseInt(count || 1, 10);
+ switch (param) {
+ case "y":
+ var pos = editor.getCursorPosition();
+ editor.selection.selectLine();
+ for (var i = 0; i < count - 1; i++) {
+ editor.selection.moveCursorDown();
+ }
+ registers._default.text = editor.getCopyText().replace(/\n$/, "");
+ editor.selection.clearSelection();
+ registers._default.isLine = true;
+ editor.moveCursorToPosition(pos);
+ break;
+ default:
+ if (range) {
+ var pos = editor.getCursorPosition();
+ editor.selection.setSelectionRange(range);
+ registers._default.text = editor.getCopyText();
+ registers._default.isLine = false;
+ editor.selection.clearSelection();
+ editor.moveCursorTo(pos.row, pos.column);
+ }
+ }
+ }
+ },
+ ">": {
+ selFn: function(editor, range, count, param) {
+ count = parseInt(count || 1, 10);
+ for (var i = 0; i < count; i++) {
+ editor.indent();
+ }
+ util.normalMode(editor);
+ },
+ fn: function(editor, range, count, param) {
+ count = parseInt(count || 1, 10);
+ switch (param) {
+ case ">":
+ var pos = editor.getCursorPosition();
+ editor.selection.selectLine();
+ for (var i = 0; i < count - 1; i++) {
+ editor.selection.moveCursorDown();
+ }
+ editor.indent();
+ editor.selection.clearSelection();
+ editor.moveCursorToPosition(pos);
+ editor.navigateLineEnd();
+ editor.navigateLineStart();
+ break;
+ }
+ }
+ },
+ "<": {
+ selFn: function(editor, range, count, param) {
+ count = parseInt(count || 1, 10);
+ for (var i = 0; i < count; i++) {
+ editor.blockOutdent();
+ }
+ util.normalMode(editor);
+ },
+ fn: function(editor, range, count, param) {
+ count = parseInt(count || 1, 10);
+ switch (param) {
+ case "<":
+ var pos = editor.getCursorPosition();
+ editor.selection.selectLine();
+ for (var i = 0; i < count - 1; i++) {
+ editor.selection.moveCursorDown();
+ }
+ editor.blockOutdent();
+ editor.selection.clearSelection();
+ editor.moveCursorToPosition(pos);
+ editor.navigateLineEnd();
+ editor.navigateLineStart();
+ break;
+ }
+ }
+ }
+};
+});
+
+"never use strict"
+
+define("ace/keyboard/vim/maps/aliases",[], function(require, exports, module) {
+module.exports = {
+ "x": {
+ operator: {
+ char: "d",
+ count: 1
+ },
+ motion: {
+ char: "l",
+ count: 1
+ }
+ },
+ "shift-x": {
+ operator: {
+ char: "d",
+ count: 1
+ },
+ motion: {
+ char: "h",
+ count: 1
+ }
+ },
+ "shift-d": {
+ operator: {
+ char: "d",
+ count: 1
+ },
+ motion: {
+ char: "$",
+ count: 1
+ }
+ },
+ "shift-c": {
+ operator: {
+ char: "c",
+ count: 1
+ },
+ motion: {
+ char: "$",
+ count: 1
+ }
+ },
+ "s": {
+ operator: {
+ char: "c",
+ count: 1
+ },
+ motion: {
+ char: "l",
+ count: 1
+ }
+ },
+ "shift-s": {
+ operator: {
+ char: "c",
+ count: 1
+ },
+ motion: {
+ char: "l",
+ count: 1
+ }
+ }
+};
+});
+
+define("ace/keyboard/vim/registers",[], function(require, exports, module) {
+
+"never use strict";
+
+module.exports = {
+ _default: {
+ text: "",
+ isLine: false
+ }
+};
+
+});
+
View
235 chrome/content/ace++/res/ace/mode-c_cpp.js
@@ -1 +1,234 @@
-define("ace/mode/c_cpp",["require","exports","module","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/c_cpp_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle"],function(a,b,c){var d=a("../lib/oop"),e=a("./text").Mode,f=a("../tokenizer").Tokenizer,g=a("./c_cpp_highlight_rules").c_cppHighlightRules,h=a("./matching_brace_outdent").MatchingBraceOutdent,i=a("../range").Range,j=a("./behaviour/cstyle").CstyleBehaviour,k=function(){this.$tokenizer=new f((new g).getRules()),this.$outdent=new h,this.$behaviour=new j};d.inherits(k,e),function(){this.toggleCommentLines=function(a,b,c,d){var e=!0,f=[],g=/^(\s*)\/\//;for(var h=c;h<=d;h++)if(!g.test(b.getLine(h))){e=!1;break}if(e){var j=new i(0,0,0,0);for(var h=c;h<=d;h++){var k=b.getLine(h),l=k.match(g);j.start.row=h,j.end.row=h,j.end.column=l[0].length,b.replace(j,l[1])}}else b.indentRows(c,d,"//")},this.getNextLineIndent=function(a,b,c){var d=this.$getIndent(b),e=this.$tokenizer.getLineTokens(b,a),f=e.tokens,g=e.state;if(f.length&&f[f.length-1].type=="comment")return d;if(a=="start"){var h=b.match(/^.*[\{\(\[]\s*$/);h&&(d+=c)}else if(a=="doc-start"){if(g=="start")return"";var h=b.match(/^\s*(\/?)\*/);h&&(h[1]&&(d+=" "),d+="* ")}return d},this.checkOutdent=function(a,b,c){return this.$outdent.checkOutdent(b,c)},this.autoOutdent=function(a,b,c){this.$outdent.autoOutdent(b,c)}}.call(k.prototype),b.Mode=k}),define("ace/mode/c_cpp_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"],function(a,b,c){var d=a("../lib/oop"),e=a("../lib/lang"),f=a("./doc_comment_highlight_rules").DocCommentHighlightRules,g=a("./text_highlight_rules").TextHighlightRules,h=function(){var a=e.arrayToMap("and|double|not_eq|throw|and_eq|dynamic_cast|operator|true|asm|else|or|try|auto|enum|or_eq|typedef|bitand|explicit|private|typeid|bitor|extern|protected|typename|bool|false|public|union|break|float|register|unsigned|case|fro|reinterpret-cast|using|catch|friend|return|virtual|char|goto|short|void|class|if|signed|volatile|compl|inline|sizeof|wchar_t|const|int|static|while|const-cast|long|static_cast|xor|continue|mutable|struct|xor_eq|default|namespace|switch|delete|new|template|do|not|this|for".split("|")),b=e.arrayToMap("NULL".split("|"));this.$rules={start:[{token:"comment",regex:"\\/\\/.*$"},(new f).getStartRule("doc-start"),{token:"comment",merge:!0,regex:"\\/\\*",next:"comment"},{token:"string",regex:'["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'},{token:"string",merge:!0,regex:'["].*\\\\$',next:"qqstring"},{token:"string",regex:"['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"},{token:"string",merge:!0,regex:"['].*\\\\$",next:"qstring"},{token:"constant.numeric",regex:"0[xX][0-9a-fA-F]+\\b"},{token:"constant.numeric",regex:"[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"},{token:"constant",regex:"<[a-zA-Z0-9.]+>"},{token:"keyword",regex:"(?:#include|#pragma|#line|#define|#undef|#ifdef|#else|#elif|#endif|#ifndef)"},{token:function(c){return c=="this"?"variable.language":a.hasOwnProperty(c)?"keyword":b.hasOwnProperty(c)?"constant.language":"identifier"},regex:"[a-zA-Z_$][a-zA-Z0-9_$]*\\b"},{token:"keyword.operator",regex:"!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)"},{token:"punctuation.operator",regex:"\\?|\\:|\\,|\\;|\\."},{token:"paren.lparen",regex:"[[({]"},{token:"paren.rparen",regex:"[\\])}]"},{token:"text",regex:"\\s+"}],comment:[{token:"comment",regex:".*?\\*\\/",next:"start"},{token:"comment",merge:!0,regex:".+"}],qqstring:[{token:"string",regex:'(?:(?:\\\\.)|(?:[^"\\\\]))*?"',next:"start"},{token:"string",merge:!0,regex:".+"}],qstring:[{token:"string",regex:"(?:(?:\\\\.)|(?:[^'\\\\]))*?'",next:"start"},{token:"string",merge:!0,regex:".+"}]},this.embedRules(f,"doc-",[(new f).getEndRule("start")])};d.inherits(h,g),b.c_cppHighlightRules=h}),define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(a,b,c){var d=a("../lib/oop"),e=a("./text_highlight_rules").TextHighlightRules,f=function(){this.$rules={start:[{token:"comment.doc.tag",regex:"@[\\w\\d_]+"},{token:"comment.doc",merge:!0,regex:"\\s+"},{token:"comment.doc",merge:!0,regex:"TODO"},{token:"comment.doc",merge:!0,regex:"[^@\\*]+"},{token:"comment.doc",merge:!0,regex:"."}]}};d.inherits(f,e),function(){this.getStartRule=function(a){return{token:"comment.doc",merge:!0,regex:"\\/\\*(?=\\*)",next:a}},this.getEndRule=function(a){return{token:"comment.doc",merge:!0,regex:"\\*\\/",next:a}}}.call(f.prototype),b.DocCommentHighlightRules=f}),define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(a,b,c){var d=a("../range").Range,e=function(){};((function(){this.checkOutdent=function(a,b){return/^\s+$/.test(a)?/^\s*\}/.test(b):!1},this.autoOutdent=function(a,b){var c=a.getLine(b),e=c.match(/^(\s*\})/);if(!e)return 0;var f=e[1].length,g=a.findMatchingBracket({row:b,column:f});if(!g||g.row==b)return 0;var h=this.$getIndent(a.getLine(g.row));a.replace(new d(b,0,b,f-1),h)},this.$getIndent=function(a){var b=a.match(/^(\s+)/);return b?b[1]:""}})).call(e.prototype),b.MatchingBraceOutdent=e}),define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour"],function(a,b,c){var d=a("../../lib/oop"),e=a("../behaviour").Behaviour,f=function(){this.add("braces","insertion",function(a,b,c,d,e){if(e=="{"){var f=c.getSelectionRange(),g=d.doc.getTextRange(f);return g!==""?{text:"{"+g+"}",selection:!1}:{text:"{}",selection:[1,1]}}if(e=="}"){var h=c.getCursorPosition(),i=d.doc.getLine(h.row),j=i.substring(h.column,h.column+1);if(j=="}"){var k=d.$findOpeningBracket("}",{column:h.column+1,row:h.row});if(k!==null)return{text:"",selection:[1,1]}}}else if(e=="\n"){var h=c.getCursorPosition(),i=d.doc.getLine(h.row),j=i.substring(h.column,h.column+1);if(j=="}"){var l=d.findMatchingBracket({row:h.row,column:h.column+1});if(!l)return null;var m=this.getNextLineIndent(a,i.substring(0,i.length-1),d.getTabString()),n=this.$getIndent(d.doc.getLine(l.row));return{text:"\n"+m+"\n"+n,selection:[1,m.length,1,m.length]}}}}),this.add("braces","deletion",function(a,b,c,d,e){var f=d.doc.getTextRange(e);if(!e.isMultiLine()&&f=="{"){var g=d.doc.getLine(e.start.row),h=g.substring(e.end.column,e.end.column+1);if(h=="}")return e.end.column++,e}}),this.add("parens","insertion",function(a,b,c,d,e){if(e=="("){var f=c.getSelectionRange(),g=d.doc.getTextRange(f);return g!==""?{text:"("+g+")",selection:!1}:{text:"()",selection:[1,1]}}if(e==")"){var h=c.getCursorPosition(),i=d.doc.getLine(h.row),j=i.substring(h.column,h.column+1);if(j==")"){var k=d.$findOpeningBracket(")",{column:h.column+1,row:h.row});if(k!==null)return{text:"",selection:[1,1]}}}}),this.add("parens","deletion",function(a,b,c,d,e){var f=d.doc.getTextRange(e);if(!e.isMultiLine()&&f=="("){var g=d.doc.getLine(e.start.row),h=g.substring(e.start.column+1,e.start.column+2);if(h==")")return e.end.column++,e}}),this.add("string_dquotes","insertion",function(a,b,c,d,e){if(e=='"'){var f=c.getSelectionRange(),g=d.doc.getTextRange(f);if(g!=="")return{text:'"'+g+'"',selection:!1};var h=c.getCursorPosition(),i=d.doc.getLine(h.row),j=i.substring(h.column-1,h.column);if(j=="\\")return null;var k=d.getTokens(f.start.row,f.start.row)[0].tokens,l=0,m,n=-1;for(var o=0;o<k.length;o++){m=k[o],m.type=="string"?n=-1:n<0&&(n=m.value.indexOf('"'));if(m.value.length+l>f.start.column)break;l+=k[o].value.length}if(!m||n<0&&m.type!=="comment"&&(m.type!=="string"||f.start.column!==m.value.length+l-1&&m.value.lastIndexOf('"')===m.value.length-1))return{text:'""',selection:[1,1]};if(m&&m.type==="string"){var p=i.substring(h.column,h.column+1);if(p=='"')return{text:"",selection:[1,1]}}}}),this.add("string_dquotes","deletion",function(a,b,c,d,e){var f=d.doc.getTextRange(e);if(!e.isMultiLine()&&f=='"'){var g=d.doc.getLine(e.start.row),h=g.substring(e.start.column+1,e.start.column+2);if(h=='"')return e.end.column++,e}})};d.inherits(f,e),b.CstyleBehaviour=f})
+define("ace/mode/c_cpp",[], function(require, exports, module) {
+
+var oop = require("ace/lib/oop");
+var TextMode = require("ace/mode/text").Mode;
+var Tokenizer = require("ace/tokenizer").Tokenizer;
+var c_cppHighlightRules = require("ace/mode/c_cpp_highlight_rules").c_cppHighlightRules;
+var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
+var Range = require("ace/range").Range;
+var CstyleBehaviour = require("ace/mode/behaviour/cstyle").CstyleBehaviour;
+var CStyleFoldMode = require("ace/mode/folding/cstyle").FoldMode;
+
+var Mode = function() {
+ this.$tokenizer = new Tokenizer(new c_cppHighlightRules().getRules());
+ this.$outdent = new MatchingBraceOutdent();
+ this.$behaviour = new CstyleBehaviour();
+ this.foldingRules = new CStyleFoldMode();
+};
+oop.inherits(Mode, TextMode);
+
+(function() {
+
+ this.toggleCommentLines = function(state, doc, startRow, endRow) {
+ var outdent = true;
+ var re = /^(\s*)\/\//;
+
+ for (var i=startRow; i<= endRow; i++) {
+ if (!re.test(doc.getLine(i))) {
+ outdent = false;
+ break;
+ }
+ }
+
+ if (outdent) {
+ var deleteRange = new Range(0, 0, 0, 0);
+ for (var i=startRow; i<= endRow; i++)
+ {
+ var line = doc.getLine(i);
+ var m = line.match(re);
+ deleteRange.start.row = i;
+ deleteRange.end.row = i;
+ deleteRange.end.column = m[0].length;
+ doc.replace(deleteRange, m[1]);
+ }
+ }
+ else {
+ doc.indentRows(startRow, endRow, "//");
+ }
+ };
+
+ this.getNextLineIndent = function(state, line, tab) {
+ var indent = this.$getIndent(line);
+
+ var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
+ var tokens = tokenizedLine.tokens;
+ var endState = tokenizedLine.state;
+
+ if (tokens.length && tokens[tokens.length-1].type == "comment") {
+ return indent;
+ }
+
+ if (state == "start") {
+ var match = line.match(/^.*[\{\(\[]\s*$/);
+ if (match) {
+ indent += tab;
+ }
+ } else if (state == "doc-start") {
+ if (endState == "start") {
+ return "";
+ }
+ var match = line.match(/^\s*(\/?)\*/);
+ if (match) {
+ if (match[1]) {
+ indent += " ";
+ }
+ indent += "* ";
+ }
+ }
+
+ return indent;
+ };
+
+ this.checkOutdent = function(state, line, input) {
+ return this.$outdent.checkOutdent(line, input);
+ };
+
+ this.autoOutdent = function(state, doc, row) {
+ this.$outdent.autoOutdent(doc, row);
+ };
+
+}).call(Mode.prototype);
+
+exports.Mode = Mode;
+});
+
+define("ace/mode/c_cpp_highlight_rules",[], function(require, exports, module) {
+
+var oop = require("ace/lib/oop");
+var lang = require("ace/lib/lang");
+var DocCommentHighlightRules = require("ace/mode/doc_comment_highlight_rules").DocCommentHighlightRules;
+var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
+
+var c_cppHighlightRules = function() {
+
+ var keywords = lang.arrayToMap(
+ ("and|double|not_eq|throw|and_eq|dynamic_cast|operator|true|" +
+ "asm|else|or|try|auto|enum|or_eq|typedef|bitand|explicit|private|" +
+ "typeid|bitor|extern|protected|typename|bool|false|public|union|" +
+ "break|float|register|unsigned|case|fro|reinterpret-cast|using|catch|" +
+ "friend|return|virtual|char|goto|short|void|class|if|signed|volatile|" +
+ "compl|inline|sizeof|wchar_t|const|int|static|while|const-cast|long|" +
+ "static_cast|xor|continue|mutable|struct|xor_eq|default|namespace|" +
+ "switch|delete|new|template|do|not|this|for").split("|")
+ );
+
+ var buildinConstants = lang.arrayToMap(
+ ("NULL").split("|")
+ );
+
+ // regexp must not have capturing parentheses. Use (?:) instead.
+ // regexps are ordered -> the first match is used
+
+ this.$rules = {
+ "start" : [
+ {
+ token : "comment",
+ regex : "\\/\\/.*$"
+ },
+ new DocCommentHighlightRules().getStartRule("doc-start"),
+ {
+ token : "comment", // multi line comment
+ merge : true,
+ regex : "\\/\\*",
+ next : "comment"
+ }, {
+ token : "string", // single line
+ regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
+ }, {
+ token : "string", // multi line string start
+ merge : true,
+ regex : '["].*\\\\$',
+ next : "qqstring"
+ }, {
+ token : "string", // single line
+ regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
+ }, {
+ token : "string", // multi line string start
+ merge : true,
+ regex : "['].*\\\\$",
+ next : "qstring"
+ }, {
+ token : "constant.numeric", // hex
+ regex : "0[xX][0-9a-fA-F]+\\b"
+ }, {
+ token : "constant.numeric", // float
+ regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
+ }, {
+ token : "constant", // <CONSTANT>
+ regex : "<[a-zA-Z0-9.]+>"
+ }, {
+ token : "keyword", // pre-compiler directivs
+ regex : "(?:#include|#pragma|#line|#define|#undef|#ifdef|#else|#elif|#endif|#ifndef)"
+ }, {
+ token : function(value) {
+ if (value == "this")
+ return "variable.language";
+ else if (keywords.hasOwnProperty(value))
+ return "keyword";
+ else if (buildinConstants.hasOwnProperty(value))
+ return "constant.language";
+ else
+ return "identifier";
+ },
+ regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
+ }, {
+ token : "keyword.operator",
+ regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)"
+ }, {
+ token : "punctuation.operator",
+ regex : "\\?|\\:|\\,|\\;|\\."
+ }, {
+ token : "paren.lparen",
+ regex : "[[({]"
+ }, {
+ token : "paren.rparen",
+ regex : "[\\])}]"
+ }, {
+ token : "text",
+ regex : "\\s+"
+ }
+ ],
+ "comment" : [
+ {
+ token : "comment", // closing comment
+ regex : ".*?\\*\\/",
+ next : "start"
+ }, {
+ token : "comment", // comment spanning whole line
+ merge : true,
+ regex : ".+"
+ }
+ ],
+ "qqstring" : [
+ {
+ token : "string",
+ regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
+ next : "start"
+ }, {
+ token : "string",
+ merge : true,
+ regex : '.+'
+ }
+ ],
+ "qstring" : [
+ {
+ token : "string",
+ regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
+ next : "start"
+ }, {
+ token : "string",
+ merge : true,
+ regex : '.+'
+ }
+ ]
+ };
+
+ this.embedRules(DocCommentHighlightRules, "doc-",
+ [ new DocCommentHighlightRules().getEndRule("start") ]);
+};
+
+oop.inherits(c_cppHighlightRules, TextHighlightRules);
+
+exports.c_cppHighlightRules = c_cppHighlightRules;
+});
+
View
291 chrome/content/ace++/res/ace/mode-coffee.js
@@ -1,3 +1,288 @@
-define("ace/mode/coffee",["require","exports","module","ace/tokenizer","ace/mode/coffee_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/text","ace/worker/worker_client","ace/lib/oop"],function(a,b,c){function k(){this.$tokenizer=new d((new e).getRules()),this.$outdent=new f}var d=a("ace/tokenizer").Tokenizer,e=a("ace/mode/coffee_highlight_rules").CoffeeHighlightRules,f=a("ace/mode/matching_brace_outdent").MatchingBraceOutdent,g=a("ace/range").Range,h=a("ace/mode/text").Mode,i=a("ace/worker/worker_client").WorkerClient,j=a("ace/lib/oop");j.inherits(k,h),function(){var a=/(?:[({[=:]|[-=]>|\b(?:else|switch|try|catch(?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$/,b=/^(\s*)#/,c=/^\s*###(?!#)/,d=/^\s*/;this.getNextLineIndent=function(b,c,d){var e=this.$getIndent(c),f=this.$tokenizer.getLineTokens(c,b).tokens;return(!f.length||f[f.length-1].type!=="comment")&&b==="start"&&a.test(c)&&(e+=d),e},this.toggleCommentLines=function(a,e,f,h){console.log("toggle");var i=new g(0,0,0,0);for(var j=f;j<=h;++j){var k=e.getLine(j);if(c.test(k))continue;b.test(k)?k=k.replace(b,"$1"):k=k.replace(d,"$&#"),i.end.row=i.start.row=j,i.end.column=k.length+1,e.replace(i,k)}},this.checkOutdent=function(a,b,c){return this.$outdent.checkOutdent(b,c)},this.autoOutdent=function(a,b,c){this.$outdent.autoOutdent(b,c)},this.createWorker=function(a){var b=new i(["ace"],"worker-coffee.js","ace/mode/coffee_worker","Worker");b.attachToDocument(a.getDocument()),b.on("error",function(b){a.setAnnotations([b.data])}),b.on("ok",function(b){a.clearAnnotations()})}}.call(k.prototype),b.Mode=k}),
-define("ace/mode/coffee_highlight_rules",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/mode/text_highlight_rules"],function(a,b,c){function g(){var a="[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*",b={token:"string",merge:!0,regex:".+"},c=d.arrayToMap("this|throw|then|try|typeof|super|switch|return|break|by)|continue|catch|class|in|instanceof|is|isnt|if|else|extends|for|forown|finally|function|while|when|new|no|not|delete|debugger|do|loop|of|off|or|on|unless|until|and|yes".split("|")),e=d.arrayToMap("true|false|null|undefined".split("|")),f=d.arrayToMap("case|const|default|function|var|void|with|enum|export|implements|interface|let|package|private|protected|public|static|yield|__hasProp|extends|slice|bind|indexOf".split("|")),g=d.arrayToMap("Array|Boolean|Date|Function|Number|Object|RegExp|ReferenceError|RangeError|String|SyntaxError|Error|EvalError|TypeError|URIError".split("|")),h=d.arrayToMap("Math|JSON|isNaN|isFinite|parseInt|parseFloat|encodeURI|encodeURIComponent|decodeURI|decodeURIComponent|RangeError|String|SyntaxError|Error|EvalError|TypeError|URIError".split("|"));this.$rules={start:[{token:"identifier",regex:"(?:(?:\\.|::)\\s*)"+a},{token:"variable",regex:"@"+a},{token:function(a){return c.hasOwnProperty(a)?"keyword":e.hasOwnProperty(a)?"constant.language":f.hasOwnProperty(a)?"invalid.illegal":g.hasOwnProperty(a)?"language.support.class":h.hasOwnProperty(a)?"language.support.function":"identifier"},regex:a},{token:"constant.numeric",regex:"(?:0x[\\da-fA-F]+|(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[eE][+-]?\\d+)?)"},{token:"string",merge:!0,regex:"'''",next:"qdoc"},{token:"string",merge:!0,regex:'"""',next:"qqdoc"},{token:"string",merge:!0,regex:"'",next:"qstring"},{token:"string",merge:!0,regex:'"',next:"qqstring"},{token:"string",merge:!0,regex:"`",next:"js"},{token:"string.regex",merge:!0,regex:"///",next:"heregex"},{token:"string.regex",regex:"/(?!\\s)[^[/\\n\\\\]*(?: (?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[/\\n\\\\]*)*/[imgy]{0,4}(?!\\w)"},{token:"comment",merge:!0,regex:"###(?!#)",next:"comment"},{token:"comment",regex:"#.*"},{token:"punctuation.operator",regex:"\\?|\\:|\\,|\\."},{token:"paren.lparen",regex:"[({[]"},{token:"paren.rparen",regex:"[\\]})]"},{token:"keyword.operator",regex:"\\S+"},{token:"text",regex:"\\s+"}],qdoc:[{token:"string",regex:".*?'''",next:"start"},b],qqdoc:[{token:"string",regex:'.*?"""',next:"start"},b],qstring:[{token:"string",regex:"[^\\\\']*(?:\\\\.[^\\\\']*)*'",next:"start"},b],qqstring:[{token:"string",regex:'[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',next:"start"},b],js:[{token:"string",merge:!0,regex:"[^\\\\`]*(?:\\\\.[^\\\\`]*)*`",next:"start"},b],heregex:[{token:"string.regex",regex:".*?///[imgy]{0,4}",next:"start"},{token:"comment.regex",regex:"\\s+(?:#.*)?"},{token:"string.regex",merge:!0,regex:"\\S+"}],comment:[{token:"comment",regex:".*?###",next:"start"},{token:"comment",merge:!0,regex:".+"}]}}var d=a("ace/lib/lang"),e=a("ace/lib/oop"),f=a("ace/mode/text_highlight_rules").TextHighlightRules;e.inherits(g,f),b.CoffeeHighlightRules=g}),
-define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(a,b,c){var d=a("ace/range").Range,e=function(){};((function(){this.checkOutdent=function(a,b){return/^\s+$/.test(a)?/^\s*\}/.test(b):!1},this.autoOutdent=function(a,b){var c=a.getLine(b),e=c.match(/^(\s*\})/);if(!e)return 0;var f=e[1].length,g=a.findMatchingBracket({row:b,column:f});if(!g||g.row==b)return 0;var h=this.$getIndent(a.getLine(g.row));a.replace(new d(b,0,b,f-1),h)},this.$getIndent=function(a){var b=a.match(/^(\s+)/);return b?b[1]:""}})).call(e.prototype),b.MatchingBraceOutdent=e})
+define("ace/mode/coffee",[], function(require, exports, module) {
+
+var Tokenizer = require("ace/tokenizer").Tokenizer;
+var Rules = require("ace/mode/coffee_highlight_rules").CoffeeHighlightRules;
+var Outdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
+var PythonFoldMode = require("ace/mode/folding/pythonic").FoldMode;
+var Range = require("ace/range").Range;
+var TextMode = require("ace/mode/text").Mode;
+var oop = require("ace/lib/oop");
+
+function Mode() {
+ this.$tokenizer = new Tokenizer(new Rules().getRules());
+ this.$outdent = new Outdent();
+ this.foldingRules = new PythonFoldMode("=|=>|->|\\s*class [^#]*");
+}
+
+oop.inherits(Mode, TextMode);
+
+(function() {
+
+ this.foldingType = "indentation";
+
+ var indenter = /(?:[({[=:]|[-=]>|\b(?:else|switch|try|catch(?:\s*[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$/;
+ var commentLine = /^(\s*)#/;
+ var hereComment = /^\s*###(?!#)/;
+ var indentation = /^\s*/;
+
+ this.getNextLineIndent = function(state, line, tab) {
+ var indent = this.$getIndent(line);
+ var tokens = this.$tokenizer.getLineTokens(line, state).tokens;
+
+ if (!(tokens.length && tokens[tokens.length - 1].type === 'comment') &&
+ state === 'start' && indenter.test(line))
+ indent += tab;
+ return indent;
+ };
+
+ this.toggleCommentLines = function(state, doc, startRow, endRow){
+ console.log("toggle");
+ var range = new Range(0, 0, 0, 0);
+ for (var i = startRow; i <= endRow; ++i) {
+ var line = doc.getLine(i);
+ if (hereComment.test(line))
+ continue;
+
+ if (commentLine.test(line))
+ line = line.replace(commentLine, '$1');
+ else
+ line = line.replace(indentation, '$&#');
+
+ range.end.row = range.start.row = i;
+ range.end.column = line.length + 1;
+ doc.replace(range, line);
+ }
+ };
+
+ this.checkOutdent = function(state, line, input) {
+ return this.$outdent.checkOutdent(line, input);
+ };
+
+ this.autoOutdent = function(state, doc, row) {
+ this.$outdent.autoOutdent(doc, row);
+ };
+
+}).call(Mode.prototype);
+
+exports.Mode = Mode;
+
+});
+
+define("ace/mode/coffee_highlight_rules",[], function(require, exports, module) {
+
+ var lang = require("ace/lib/lang");
+ var oop = require("ace/lib/oop");
+ var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
+
+ oop.inherits(CoffeeHighlightRules, TextHighlightRules);
+
+ function CoffeeHighlightRules() {
+ var identifier = "[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*";
+ var stringfill = {
+ token : "string",
+ merge : true,
+ regex : ".+"
+ };
+
+ var keywords = lang.arrayToMap((
+ "this|throw|then|try|typeof|super|switch|return|break|by)|continue|" +
+ "catch|class|in|instanceof|is|isnt|if|else|extends|for|forown|" +
+ "finally|function|while|when|new|no|not|delete|debugger|do|loop|of|off|" +
+ "or|on|unless|until|and|yes").split("|")
+ );
+
+ var langConstant = lang.arrayToMap((
+ "true|false|null|undefined").split("|")
+ );
+
+ var illegal = lang.arrayToMap((
+ "case|const|default|function|var|void|with|enum|export|implements|" +
+ "interface|let|package|private|protected|public|static|yield|" +
+ "__hasProp|extends|slice|bind|indexOf").split("|")
+ );
+
+ var supportClass = lang.arrayToMap((
+ "Array|Boolean|Date|Function|Number|Object|RegExp|ReferenceError|" +
+ "RangeError|String|SyntaxError|Error|EvalError|TypeError|URIError").split("|")
+ );
+
+ var supportFunction = lang.arrayToMap((
+ "Math|JSON|isNaN|isFinite|parseInt|parseFloat|encodeURI|" +
+ "encodeURIComponent|decodeURI|decodeURIComponent|RangeError|String|" +
+ "SyntaxError|Error|EvalError|TypeError|URIError").split("|")
+ );
+
+ this.$rules = {
+ start : [
+ {
+ token : "identifier",
+ regex : "(?:(?:\\.|::)\\s*)" + identifier
+ }, {
+ token : "variable",
+ regex : "@(?:" + identifier + ")?"
+ }, {
+ token: function(value) {
+ if (keywords.hasOwnProperty(value))
+ return "keyword";
+ else if (langConstant.hasOwnProperty(value))
+ return "constant.language";
+ else if (illegal.hasOwnProperty(value))
+ return "invalid.illegal";
+ else if (supportClass.hasOwnProperty(value))
+ return "language.support.class";
+ else if (supportFunction.hasOwnProperty(value))
+ return "language.support.function";
+ else
+ return "identifier";
+ },
+ regex : identifier
+ }, {
+ token : "constant.numeric",
+ regex : "(?:0x[\\da-fA-F]+|(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[eE][+-]?\\d+)?)"
+ }, {
+ token : "string",
+ merge : true,
+ regex : "'''",
+ next : "qdoc"
+ }, {
+ token : "string",
+ merge : true,
+ regex : '"""',
+ next : "qqdoc"
+ }, {
+ token : "string",
+ merge : true,
+ regex : "'",
+ next : "qstring"
+ }, {
+ token : "string",
+ merge : true,
+ regex : '"',
+ next : "qqstring"
+ }, {
+ token : "string",
+ merge : true,
+ regex : "`",
+ next : "js"
+ }, {
+ token : "string.regex",
+ merge : true,
+ regex : "///",
+ next : "heregex"
+ }, {
+ token : "string.regex",
+ regex : "/(?!\\s)[^[/\\n\\\\]*(?: (?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[/\\n\\\\]*)*/[imgy]{0,4}(?!\\w)"
+ }, {
+ token : "comment",
+ merge : true,
+ regex : "###(?!#)",
+ next : "comment"
+ }, {
+ token : "comment",
+ regex : "#.*"
+ }, {
+ token : "punctuation.operator",
+ regex : "\\?|\\:|\\,|\\."
+ }, {
+ token : "keyword.operator",
+ regex : "(?:[\\-=]>|[-+*/%<>&|^!?=]=|>>>=?|\\-\\-|\\+\\+|::|&&=|\\|\\|=|<<=|>>=|\\?\\.|\\.{2,3}|\\!)"
+ }, {
+ token : "paren.lparen",
+ regex : "[({[]"
+ }, {
+ token : "paren.rparen",
+ regex : "[\\]})]"
+ }, {
+ token : "text",
+ regex : "\\s+"
+ }],
+
+ qdoc : [{
+ token : "string",
+ regex : ".*?'''",
+ next : "start"
+ }, stringfill],
+
+ qqdoc : [{
+ token : "string",
+ regex : '.*?"""',
+ next : "start"
+ }, stringfill],
+
+ qstring : [{
+ token : "string",
+ regex : "[^\\\\']*(?:\\\\.[^\\\\']*)*'",
+ merge : true,
+ next : "start"