summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary McCain2013-11-08 14:25:16 (EST)
committerStephan Born2013-12-04 05:11:29 (EST)
commitefa1522a4d15db3a46f0897014e023330637dd33 (patch)
treedd33dbed4f7e21440522addf5210934aef8c95d1
parent2d2e347ec29cfdc1e580e4b0e51596a76cb80f2e (diff)
downloadorg.eclipse.stardust.ui.web-efa1522a4d15db3a46f0897014e023330637dd33.zip
org.eclipse.stardust.ui.web-efa1522a4d15db3a46f0897014e023330637dd33.tar.gz
org.eclipse.stardust.ui.web-efa1522a4d15db3a46f0897014e023330637dd33.tar.bz2
Jira-ID: CRNT-30922
- In support of Upgrade Ace Code Editor to Version 'package 07.31.2013'. Added angular directive wrapper for the ace code editor. Upgraded code editor and added snippets and autocomplete. git-svn-id: https://svn.csa.sungard.com/repos/ipp2/product/trunk/stardust/ui.web@68699 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b Signed-off-by: Zachary McCain <zachary.mccain@sungard.com>
-rw-r--r--stardust-web-reporting/src/main/resources/META-INF/webapp/css/bpm-reporting.css7
-rw-r--r--stardust-web-reporting/src/main/resources/META-INF/webapp/js/AngularAdapter.js65
-rw-r--r--stardust-web-reporting/src/main/resources/META-INF/webapp/js/ReportDefinitionController.js10
-rw-r--r--stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/ace.js6726
-rw-r--r--stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/ext-language_tools.js1429
-rw-r--r--stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/mode-javascript.js1787
-rw-r--r--stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/snippets/javascript.js202
-rw-r--r--stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/theme-chrome.js322
-rw-r--r--stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/theme-textmate.js326
-rw-r--r--stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/worker-javascript.js16491
-rw-r--r--stardust-web-reporting/src/main/resources/META-INF/webapp/views/reportDefinitionView.html13
11 files changed, 16839 insertions, 10539 deletions
diff --git a/stardust-web-reporting/src/main/resources/META-INF/webapp/css/bpm-reporting.css b/stardust-web-reporting/src/main/resources/META-INF/webapp/css/bpm-reporting.css
index dd14764..cebe194 100644
--- a/stardust-web-reporting/src/main/resources/META-INF/webapp/css/bpm-reporting.css
+++ b/stardust-web-reporting/src/main/resources/META-INF/webapp/css/bpm-reporting.css
@@ -299,4 +299,11 @@ div.right {
font-size: 11px !important;
font-weight: normal !important;
font-family: Helvetica, Arial, sans-serif !important;
+}
+
+/*ipp-Ace styling for our directive*/
+[ipp-Ace] {
+ width:500px;
+ height:80px;"
+ border:solid 1px #555555;
} \ No newline at end of file
diff --git a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/AngularAdapter.js b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/AngularAdapter.js
index 127e8e2..9449aca 100644
--- a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/AngularAdapter.js
+++ b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/AngularAdapter.js
@@ -310,6 +310,71 @@ if (!window.bpm.portal.AngularAdapter) {
});
};
});
+
+ /*Angular directive to wrap the ace code editor and provide
+ *a basic set of functionality.
+ *Supports via attributes:
+ * mode: defines the language we will support
+ * theme: defines the css for the syntax highlighter
+ * snippets: whether or not to support snippets (if available)
+ * ng-Model: model we will bind our value to.*/
+ this.angularModule.directive("ippAce",function(){
+
+ /*Check for our global ace object, if it isn't there then bail.*/
+ if(!ace){return;}
+
+ return {
+ restrict: 'EA', /*Elements and attributes*/
+ require: '?ngModel',
+ link: function (scope, elm, attrs, ngModel) {
+ var options,
+ editor,
+ session,
+ langTools;
+
+ /*Setting up language tool options for editor*/
+ options={
+ "enableSnippets": !!attrs.snippets,
+ "enableBasicAutocompletion": !!attrs.autocomplete
+ };
+
+ /*Setting options from user attributes*/
+ editor = window.ace.edit(elm[0]);
+ session = editor.getSession();
+ session.setMode("ace/mode/" + attrs.mode);
+ editor.setTheme("ace/theme/" + attrs.theme);
+
+ /*Get a reference to languageTools module, if it exists*/
+ langTools=ace.define.modules["ace/ext/language_tools"];
+
+ /*if module is loaded go ahead and set our options, otherwise load it
+ *and set options on the callback.*/
+ if(langTools){
+ editor.setOptions(options);
+ }
+ else{
+ ace.config.loadModule("ace/ext/language_tools",function(){
+ editor.setOptions(options);
+ });
+ }
+
+ /*set our initial value to that of our bound model*/
+ ngModel.$render = function () {
+ session.setValue(ngModel.$viewValue);
+ };
+
+ /*any time our editors session registers a change event,
+ *set the resultant value on our bound model.*/
+ session.on('change',function(){
+ scope.$apply(function(){
+ ngModel.$setViewValue(session.getValue());
+ });
+ });
+ }
+ };
+ });
+ /****Angular Ace Directive END *****/
+
};
}
} \ No newline at end of file
diff --git a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/ReportDefinitionController.js b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/ReportDefinitionController.js
index cffacb4..aae785a 100644
--- a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/ReportDefinitionController.js
+++ b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/ReportDefinitionController.js
@@ -115,15 +115,7 @@ define(
name : 'colors'
} ]
});
-
- // this.computedColumnExpressionEditor = Ace
- // .edit(jQuery("#computedColumnExpressionEditor"));
- //
- // this.computedColumnExpressionEditor.getSession().setMode(
- // "ace/mode/javascript");
- // this.computedColumnExpressionEditor
- // .setTheme("ace/theme/chrome");
-
+
CKEDITOR.instances["documentTemplateEditor"]
.on(
'blur',
diff --git a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/ace.js b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/ace.js
index 451041d..a905789 100644
--- a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/ace.js
+++ b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/ace.js
@@ -30,7 +30,7 @@
(function() {
-var ACE_NAMESPACE = "";
+var ACE_NAMESPACE = "ace";
var global = (function() {
return this;
@@ -55,10 +55,13 @@ var _define = function(module, deps, payload) {
if (arguments.length == 2)
payload = deps;
- if (!_define.modules)
+ if (!_define.modules) {
_define.modules = {};
-
- _define.modules[module] = payload;
+ _define.payloads = {};
+ }
+
+ _define.payloads[module] = payload;
+ _define.modules[module] = null;
};
var _require = function(parentId, module, callback) {
if (Object.prototype.toString.call(module) === "[object Array]") {
@@ -113,28 +116,27 @@ var lookup = function(parentId, moduleName) {
var module = _define.modules[moduleName];
if (!module) {
- return null;
- }
-
- if (typeof module === 'function') {
- var exports = {};
- var mod = {
- id: moduleName,
- uri: '',
- exports: exports,
- packaged: true
- };
+ module = _define.payloads[moduleName];
+ if (typeof module === 'function') {
+ var exports = {};
+ var mod = {
+ id: moduleName,
+ uri: '',
+ exports: exports,
+ packaged: true
+ };
- var req = function(module, callback) {
- return _require(moduleName, module, callback);
- };
+ var req = function(module, callback) {
+ return _require(moduleName, module, callback);
+ };
- var returnValue = module(req, exports, mod);
- exports = returnValue || mod.exports;
- _define.modules[moduleName] = exports;
- return exports;
+ var returnValue = module(req, exports, mod);
+ exports = returnValue || mod.exports;
+ _define.modules[moduleName] = exports;
+ delete _define.payloads[moduleName];
+ }
+ module = _define.modules[moduleName] = exports || module;
}
-
return module;
};
@@ -167,7 +169,7 @@ exportAce(ACE_NAMESPACE);
})();
-define('ace/ace', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/lib/dom', 'ace/lib/event', 'ace/editor', 'ace/edit_session', 'ace/undomanager', 'ace/virtual_renderer', 'ace/multi_select', 'ace/worker/worker_client', 'ace/keyboard/hash_handler', 'ace/placeholder', 'ace/mode/folding/fold_mode', 'ace/config'], function(require, exports, module) {
+ace.define('ace/ace', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/lib/dom', 'ace/lib/event', 'ace/editor', 'ace/edit_session', 'ace/undomanager', 'ace/virtual_renderer', 'ace/multi_select', 'ace/worker/worker_client', 'ace/keyboard/hash_handler', 'ace/placeholder', 'ace/mode/folding/fold_mode', 'ace/theme/textmate', 'ace/config'], function(require, exports, module) {
require("./lib/fixoldbrowsers");
@@ -184,6 +186,8 @@ require("./worker/worker_client");
require("./keyboard/hash_handler");
require("./placeholder");
require("./mode/folding/fold_mode");
+require("./theme/textmate");
+
exports.config = require("./config");
exports.require = require;
exports.edit = function(el) {
@@ -207,14 +211,17 @@ exports.edit = function(el) {
var env = {
document: doc,
editor: editor,
- onResize: editor.resize.bind(editor)
+ onResize: editor.resize.bind(editor, null)
};
event.addListener(window, "resize", env.onResize);
+ editor.on("destroy", function() {
+ event.removeListener(window, "resize", env.onResize);
+ });
el.env = editor.env = env;
return editor;
};
exports.createEditSession = function(text, mode) {
- var doc = new EditSession(text, doc);
+ var doc = new EditSession(text, mode);
doc.setUndoManager(new UndoManager());
return doc;
}
@@ -222,7 +229,7 @@ exports.EditSession = EditSession;
exports.UndoManager = UndoManager;
});
-define('ace/lib/fixoldbrowsers', ['require', 'exports', 'module' , 'ace/lib/regexp', 'ace/lib/es5-shim'], function(require, exports, module) {
+ace.define('ace/lib/fixoldbrowsers', ['require', 'exports', 'module' , 'ace/lib/regexp', 'ace/lib/es5-shim'], function(require, exports, module) {
require("./regexp");
@@ -230,7 +237,7 @@ require("./es5-shim");
});
-define('ace/lib/regexp', ['require', 'exports', 'module' ], function(require, exports, module) {
+ace.define('ace/lib/regexp', ['require', 'exports', 'module' ], function(require, exports, module) {
var real = {
exec: RegExp.prototype.exec,
@@ -302,7 +309,7 @@ define('ace/lib/regexp', ['require', 'exports', 'module' ], function(require, ex
});
-define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) {
+ace.define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) {
function Empty() {}
@@ -936,23 +943,6 @@ if (!Date.now) {
return new Date().getTime();
};
}
-if("0".split(void 0, 0).length) {
- var string_split = String.prototype.split;
- String.prototype.split = function(separator, limit) {
- if(separator === void 0 && limit === 0)return [];
- return string_split.apply(this, arguments);
- }
-}
-if("".substr && "0b".substr(-1) !== "b") {
- var string_substr = String.prototype.substr;
- String.prototype.substr = function(start, length) {
- return string_substr.call(
- this,
- start < 0 ? (start = this.length + start) < 0 ? 0 : start : start,
- length
- );
- }
-}
var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
"\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
"\u2029\uFEFF";
@@ -961,12 +951,7 @@ if (!String.prototype.trim || ws.trim()) {
var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
trimEndRegexp = new RegExp(ws + ws + "*$");
String.prototype.trim = function trim() {
- if (this === undefined || this === null) {
- throw new TypeError("can't convert "+this+" to object");
- }
- return String(this)
- .replace(trimBeginRegexp, "")
- .replace(trimEndRegexp, "");
+ return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
};
}
@@ -1021,26 +1006,26 @@ var toObject = function (o) {
});
-define('ace/lib/dom', ['require', 'exports', 'module' ], function(require, exports, module) {
+ace.define('ace/lib/dom', ['require', 'exports', 'module' ], function(require, exports, module) {
+
+if (typeof document == "undefined")
+ return;
var XHTML_NS = "http://www.w3.org/1999/xhtml";
+exports.getDocumentHead = function(doc) {
+ if (!doc)
+ doc = document;
+ return doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement;
+}
+
exports.createElement = function(tag, ns) {
return document.createElementNS ?
document.createElementNS(ns || XHTML_NS, tag) :
document.createElement(tag);
};
-exports.setText = function(elem, text) {
- if (elem.innerText !== undefined) {
- elem.innerText = text;
- }
- if (elem.textContent !== undefined) {
- elem.textContent = text;
- }
-};
-
exports.hasCssClass = function(el, name) {
var classes = el.className.split(/\s+/g);
return classes.indexOf(name) !== -1;
@@ -1122,8 +1107,7 @@ exports.importCssString = function importCssString(cssText, id, doc) {
if (id)
style.id = id;
- var head = doc.getElementsByTagName("head")[0] || doc.documentElement;
- head.appendChild(style);
+ exports.getDocumentHead(doc).appendChild(style);
}
};
@@ -1135,8 +1119,7 @@ exports.importCssStylsheet = function(uri, doc) {
link.rel = 'stylesheet';
link.href = uri;
- var head = doc.getElementsByTagName("head")[0] || doc.documentElement;
- head.appendChild(link);
+ exports.getDocumentHead(doc).appendChild(link);
}
};
@@ -1231,22 +1214,24 @@ exports.setInnerHtml = function(el, innerHtml) {
return element;
};
-exports.setInnerText = function(el, innerText) {
- var document = el.ownerDocument;
- if (document.body && "textContent" in document.body)
+if ("textContent" in document.documentElement) {
+ exports.setInnerText = function(el, innerText) {
el.textContent = innerText;
- else
- el.innerText = innerText;
-
-};
+ };
-exports.getInnerText = function(el) {
- var document = el.ownerDocument;
- if (document.body && "textContent" in document.body)
+ exports.getInnerText = function(el) {
return el.textContent;
- else
- return el.innerText || el.textContent || "";
-};
+ };
+}
+else {
+ exports.setInnerText = function(el, innerText) {
+ el.innerText = innerText;
+ };
+
+ exports.getInnerText = function(el) {
+ return el.innerText;
+ };
+}
exports.getParentWindow = function(document) {
return document.defaultView || document.parentWindow;
@@ -1254,7 +1239,7 @@ exports.getParentWindow = function(document) {
});
-define('ace/lib/event', ['require', 'exports', 'module' , 'ace/lib/keys', 'ace/lib/useragent', 'ace/lib/dom'], function(require, exports, module) {
+ace.define('ace/lib/event', ['require', 'exports', 'module' , 'ace/lib/keys', 'ace/lib/useragent', 'ace/lib/dom'], function(require, exports, module) {
var keys = require("./keys");
@@ -1356,9 +1341,9 @@ else {
}
exports.addMouseWheelListener = function(el, callback) {
- var factor = 8;
- var listener = function(e) {
- if (e.wheelDelta !== undefined) {
+ if ("onmousewheel" in el) {
+ var factor = 8;
+ exports.addListener(el, "mousewheel", function(e) {
if (e.wheelDeltaX !== undefined) {
e.wheelX = -e.wheelDeltaX / factor;
e.wheelY = -e.wheelDeltaY / factor;
@@ -1366,8 +1351,16 @@ exports.addMouseWheelListener = function(el, callback) {
e.wheelX = 0;
e.wheelY = -e.wheelDelta / factor;
}
- }
- else {
+ callback(e);
+ });
+ } else if ("onwheel" in el) {
+ exports.addListener(el, "wheel", function(e) {
+ e.wheelX = (e.deltaX || 0) * 5;
+ e.wheelY = (e.deltaY || 0) * 5;
+ callback(e);
+ });
+ } else {
+ exports.addListener(el, "DOMMouseScroll", function(e) {
if (e.axis && e.axis == e.HORIZONTAL_AXIS) {
e.wheelX = (e.detail || 0) * 5;
e.wheelY = 0;
@@ -1375,11 +1368,9 @@ exports.addMouseWheelListener = function(el, callback) {
e.wheelX = 0;
e.wheelY = (e.detail || 0) * 5;
}
- }
- callback(e);
- };
- exports.addListener(el, "DOMMouseScroll", listener);
- exports.addListener(el, "mousewheel", listener);
+ callback(e);
+ });
+ }
};
exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbackName) {
@@ -1441,6 +1432,29 @@ function normalizeCommandKeys(callback, e, keyCode) {
| (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
}
+ if (!useragent.isMac && pressedKeys) {
+ if (pressedKeys[91] || pressedKeys[92])
+ hashId |= 8;
+ if (pressedKeys.altGr) {
+ if ((3 & hashId) != 3)
+ pressedKeys.altGr = 0
+ else
+ return;
+ }
+ if (keyCode == 18 || keyCode == 17) {
+ var location = e.location || e.keyLocation;
+ if (keyCode == 17 && location == 1) {
+ ts = e.timeStamp;
+ } else if (keyCode == 18 && hashId == 3 && location == 2) {
+ var dt = -ts;
+ ts = e.timeStamp;
+ dt += ts;
+ if (dt < 3)
+ pressedKeys.altGr = true;
+ }
+ }
+ }
+
if (keyCode in keys.MODIFIER_KEYS) {
switch (keys.MODIFIER_KEYS[keyCode]) {
case "Alt":
@@ -1462,12 +1476,25 @@ function normalizeCommandKeys(callback, e, keyCode) {
if (hashId & 8 && (keyCode == 91 || keyCode == 93)) {
keyCode = 0;
}
+
+ if (!hashId && keyCode == 13) {
+ if (e.keyLocation || e.location == 3) {
+ callback(e, hashId, -keyCode)
+ if (e.defaultPrevented)
+ return;
+ }
+ }
if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) {
return false;
}
+
+
+
return callback(e, hashId, keyCode);
}
+var pressedKeys = null;
+var ts = 0;
exports.addCommandKeyListener = function(el, callback) {
var addListener = exports.addListener;
if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) {
@@ -1479,12 +1506,32 @@ exports.addCommandKeyListener = function(el, callback) {
return normalizeCommandKeys(callback, e, lastKeyDownKeyCode);
});
} else {
- var lastDown = null;
+ var lastDefaultPrevented = null;
addListener(el, "keydown", function(e) {
- lastDown = e.keyIdentifier || e.keyCode;
- return normalizeCommandKeys(callback, e, e.keyCode);
+ pressedKeys[e.keyCode] = true;
+ var result = normalizeCommandKeys(callback, e, e.keyCode);
+ lastDefaultPrevented = e.defaultPrevented;
+ return result;
});
+
+ addListener(el, "keypress", function(e) {
+ if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
+ exports.stopEvent(e);
+ lastDefaultPrevented = null;
+ }
+ });
+
+ addListener(el, "keyup", function(e) {
+ pressedKeys[e.keyCode] = null;
+ });
+
+ if (!pressedKeys) {
+ pressedKeys = Object.create(null);
+ addListener(window, "focus", function(e) {
+ pressedKeys = Object.create(null);
+ });
+ }
}
};
@@ -1506,10 +1553,10 @@ if (window.postMessage && !useragent.isOldIE) {
exports.nextFrame = window.requestAnimationFrame ||
- window.oRequestAnimationFrame ||
- window.msRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
- window.webkitRequestAnimationFrame;
+ window.webkitRequestAnimationFrame ||
+ window.msRequestAnimationFrame ||
+ window.oRequestAnimationFrame;
if (exports.nextFrame)
exports.nextFrame = exports.nextFrame.bind(window);
@@ -1519,7 +1566,7 @@ else
};
});
-define('ace/lib/keys', ['require', 'exports', 'module' , 'ace/lib/oop'], function(require, exports, module) {
+ace.define('ace/lib/keys', ['require', 'exports', 'module' , 'ace/lib/oop'], function(require, exports, module) {
var oop = require("./oop");
@@ -1531,7 +1578,7 @@ var Keys = (function() {
KEY_MODS: {
"ctrl": 1, "alt": 2, "option" : 2,
- "shift": 4, "meta": 8, "command": 8
+ "shift": 4, "meta": 8, "command": 8, "cmd": 8
},
FUNCTION_KEYS : {
@@ -1562,6 +1609,7 @@ var Keys = (function() {
103: "Numpad7",
104: "Numpad8",
105: "Numpad9",
+ '-13': "NumpadEnter",
112: "F1",
113: "F2",
114: "F3",
@@ -1611,7 +1659,7 @@ exports.keyCodeToString = function(keyCode) {
});
-define('ace/lib/oop', ['require', 'exports', 'module' ], function(require, exports, module) {
+ace.define('ace/lib/oop', ['require', 'exports', 'module' ], function(require, exports, module) {
exports.inherits = (function() {
@@ -1628,6 +1676,7 @@ exports.mixin = function(obj, mixin) {
for (var key in mixin) {
obj[key] = mixin[key];
}
+ return obj;
};
exports.implement = function(proto, mixin) {
@@ -1636,7 +1685,7 @@ exports.implement = function(proto, mixin) {
});
-define('ace/lib/useragent', ['require', 'exports', 'module' ], function(require, exports, module) {
+ace.define('ace/lib/useragent', ['require', 'exports', 'module' ], function(require, exports, module) {
exports.OS = {
LINUX: "LINUX",
MAC: "MAC",
@@ -1679,12 +1728,13 @@ exports.isTouchPad = ua.indexOf("TouchPad") >= 0;
});
-define('ace/editor', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/lib/oop', 'ace/lib/lang', 'ace/lib/useragent', 'ace/keyboard/textinput', 'ace/mouse/mouse_handler', 'ace/mouse/fold_handler', 'ace/keyboard/keybinding', 'ace/edit_session', 'ace/search', 'ace/range', 'ace/lib/event_emitter', 'ace/commands/command_manager', 'ace/autocomplete', 'ace/commands/default_commands', 'ace/config'], function(require, exports, module) {
+ace.define('ace/editor', ['require', 'exports', 'module' , 'ace/lib/fixoldbrowsers', 'ace/lib/oop', 'ace/lib/dom', 'ace/lib/lang', 'ace/lib/useragent', 'ace/keyboard/textinput', 'ace/mouse/mouse_handler', 'ace/mouse/fold_handler', 'ace/keyboard/keybinding', 'ace/edit_session', 'ace/search', 'ace/range', 'ace/lib/event_emitter', 'ace/commands/command_manager', 'ace/commands/default_commands', 'ace/config'], function(require, exports, module) {
require("./lib/fixoldbrowsers");
var oop = require("./lib/oop");
+var dom = require("./lib/dom");
var lang = require("./lib/lang");
var useragent = require("./lib/useragent");
var TextInput = require("./keyboard/textinput").TextInput;
@@ -1696,7 +1746,6 @@ var Search = require("./search").Search;
var Range = require("./range").Range;
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var CommandManager = require("./commands/command_manager").CommandManager;
-var Autocomplete = require("./autocomplete").Autocomplete;
var defaultCommands = require("./commands/default_commands").commands;
var config = require("./config");
var Editor = function(renderer, session) {
@@ -1716,15 +1765,131 @@ var Editor = function(renderer, session) {
wrap: true
});
+ this.$historyTracker = this.$historyTracker.bind(this);
+ this.commands.on("exec", this.$historyTracker);
+
+ this.$initOperationListeners();
+
this.setSession(session || new EditSession(""));
- Autocomplete.addTo(this);
+ config.resetOptions(this);
+ config._emit("editor", this);
};
(function(){
oop.implement(this, EventEmitter);
+
+ this.$initOperationListeners = function() {
+ function last(a) {return a[a.length - 1]};
+
+ this.selections = [];
+ this.commands.on("exec", function(e) {
+ this.startOperation(e);
+
+ var command = e.command;
+ if (command.group == "fileJump") {
+ var prev = this.prevOp;
+ if (!prev || prev.command.group != "fileJump") {
+ this.lastFileJumpPos = last(this.selections)
+ }
+ } else {
+ this.lastFileJumpPos = null;
+ }
+ }.bind(this), true);
+
+ this.commands.on("afterExec", function(e) {
+ var command = e.command;
+
+ if (command.group == "fileJump") {
+ if (this.lastFileJumpPos && !this.curOp.selectionChanged) {
+ this.selection.fromJSON(this.lastFileJumpPos);
+ return
+ }
+ }
+ this.endOperation(e);
+ }.bind(this), true);
+
+ this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this));
+
+ this.on("change", function() {
+ this.curOp || this.startOperation();
+ this.curOp.docChanged = true;
+ }.bind(this), true);
+
+ this.on("changeSelection", function() {
+ this.curOp || this.startOperation();
+ this.curOp.selectionChanged = true;
+ }.bind(this), true);
+ }
+
+ this.curOp = null;
+ this.prevOp = {};
+ this.startOperation = function(commadEvent) {
+ if (this.curOp) {
+ if (!commadEvent || this.curOp.command)
+ return;
+ this.prevOp = this.curOp;
+ }
+ if (!commadEvent) {
+ this.previousCommand = null;
+ commadEvent = {};
+ }
+
+ this.$opResetTimer.schedule();
+ this.curOp = {
+ command: commadEvent.command || {},
+ args: commadEvent.args
+ };
+
+ this.selections.push(this.selection.toJSON());
+ };
+
+ this.endOperation = function() {
+ if (this.curOp) {
+ this.prevOp = this.curOp;
+ this.curOp = null;
+ }
+ };
+
+ this.$historyTracker = function(e) {
+ if (!this.$mergeUndoDeltas)
+ return;
+
+
+ var prev = this.prevOp;
+ var mergeableCommands = ["backspace", "del", "insertstring"];
+ var shouldMerge = prev.command && (e.command.name == prev.command.name);
+ if (e.command.name == "insertstring") {
+ var text = e.args;
+ if (this.mergeNextCommand === undefined)
+ this.mergeNextCommand = true;
+
+ shouldMerge = shouldMerge
+ && this.mergeNextCommand // previous command allows to coalesce with
+ && (!/\s/.test(text) || /\s/.test(prev.args)) // previous insertion was of same type
+
+ this.mergeNextCommand = true;
+ } else {
+ shouldMerge = shouldMerge
+ && mergeableCommands.indexOf(e.command.name) !== -1// the command is mergeable
+ }
+
+ if (
+ this.$mergeUndoDeltas != "always"
+ && Date.now() - this.sequenceStartTime > 2000
+ ) {
+ shouldMerge = false; // the sequence is too long
+ }
+
+ if (shouldMerge)
+ this.session.mergeUndoDeltas = true;
+ else if (mergeableCommands.indexOf(e.command.name) !== -1)
+ this.sequenceStartTime = Date.now();
+ };
this.setKeyboardHandler = function(keyboardHandler) {
- if (typeof keyboardHandler == "string" && keyboardHandler) {
+ if (!keyboardHandler) {
+ this.keyBinding.setKeyboardHandler(null);
+ } else if (typeof keyboardHandler == "string") {
this.$keybindingId = keyboardHandler;
var _self = this;
config.loadModule(["keybinding", keyboardHandler], function(module) {
@@ -1758,7 +1923,7 @@ var Editor = function(renderer, session) {
this.session.removeEventListener("changeAnnotation", this.$onChangeAnnotation);
this.session.removeEventListener("changeOverwrite", this.$onCursorChange);
this.session.removeEventListener("changeScrollTop", this.$onScrollTopChange);
- this.session.removeEventListener("changeLeftTop", this.$onScrollLeftChange);
+ this.session.removeEventListener("changeScrollLeft", this.$onScrollLeftChange);
var selection = this.session.getSelection();
selection.removeEventListener("changeCursor", this.$onCursorChange);
@@ -1873,11 +2038,12 @@ var Editor = function(renderer, session) {
this.unsetStyle = function(style) {
this.renderer.unsetStyle(style);
};
+ this.getFontSize = function () {
+ return this.getOption("fontSize") ||
+ dom.computedStyle(this.container, "fontSize");
+ };
this.setFontSize = function(size) {
- if (typeof size == "number")
- size = size + "px";
- this.container.style.fontSize = size;
- this.renderer.updateFontSize();
+ this.setOption("fontSize", size);
};
this.$highlightBrackets = function() {
@@ -1897,8 +2063,11 @@ var Editor = function(renderer, session) {
var pos = self.session.findMatchingBracket(self.getCursorPosition());
if (pos) {
var range = new Range(pos.row, pos.column, pos.row, pos.column+1);
- self.session.$bracketHighlight = self.session.addMarker(range, "ace_bracket", "text");
+ } else if (self.session.$mode.getMatching) {
+ var range = self.session.$mode.getMatching(self.session);
}
+ if (range)
+ self.session.$bracketHighlight = self.session.addMarker(range, "ace_bracket", "text");
}, 50);
};
this.focus = function() {
@@ -1958,7 +2127,7 @@ var Editor = function(renderer, session) {
this.onScrollTopChange = function() {
this.renderer.scrollToY(this.session.getScrollTop());
};
-
+
this.onScrollLeftChange = function() {
this.renderer.scrollToX(this.session.getScrollLeft());
};
@@ -1981,16 +2150,21 @@ var Editor = function(renderer, session) {
if (this.$highlightActiveLine) {
if ((this.$selectionStyle != "line" || !this.selection.isMultiLine()))
highlight = this.getCursorPosition();
+ if (this.renderer.$maxLines && this.session.getLength() === 1)
+ highlight = false;
}
if (session.$highlightLineMarker && !highlight) {
session.removeMarker(session.$highlightLineMarker.id);
session.$highlightLineMarker = null;
} else if (!session.$highlightLineMarker && highlight) {
- session.$highlightLineMarker = session.highlightLines(highlight.row, highlight.row, "ace_active-line");
+ var range = new Range(highlight.row, highlight.column, highlight.row, Infinity);
+ range.id = session.addMarker(range, "ace_active-line", "screenLine");
+ session.$highlightLineMarker = range;
} else if (highlight) {
session.$highlightLineMarker.start.row = highlight.row;
session.$highlightLineMarker.end.row = highlight.row;
+ session.$highlightLineMarker.start.column = highlight.column;
session._emit("changeBackMarker");
}
};
@@ -2013,7 +2187,7 @@ var Editor = function(renderer, session) {
var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp()
this.session.highlight(re);
-
+
this._emit("changeSelection");
};
@@ -2066,8 +2240,9 @@ var Editor = function(renderer, session) {
};
- this.onChangeMode = function() {
+ this.onChangeMode = function(e) {
this.renderer.updateText();
+ this._emit("changeMode", e);
};
@@ -2100,7 +2275,7 @@ var Editor = function(renderer, session) {
this.commands.exec("cut", this);
};
this.onPaste = function(text) {
- if (this.$readOnly)
+ if (this.$readOnly)
return;
this._emit("paste", text);
this.insert(text);
@@ -2117,13 +2292,21 @@ var Editor = function(renderer, session) {
if (this.getBehavioursEnabled()) {
var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
- if (transform)
+ if (transform) {
+ if (text !== transform.text) {
+ this.session.mergeUndoDeltas = false;
+ this.$mergeNextCommand = false;
+ }
text = transform.text;
- }
- text = text.replace("\t", this.session.getTabString());
+ }
+ }
+
+ if (text == "\t")
+ text = this.session.getTabString();
if (!this.selection.isEmpty()) {
- cursor = this.session.remove(this.getSelectionRange());
+ var range = this.getSelectionRange();
+ cursor = this.session.remove(range);
this.clearSelection();
}
else if (this.session.getOverwrite()) {
@@ -2132,6 +2315,13 @@ var Editor = function(renderer, session) {
this.session.remove(range);
}
+ if (text == "\n" || text == "\r\n") {
+ var line = session.getLine(cursor.row)
+ if (cursor.column > line.search(/\S|$/)) {
+ var d = line.substr(cursor.column).search(/\S|$/);
+ session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d);
+ }
+ }
this.clearSelection();
var start = cursor.column;
@@ -2153,41 +2343,11 @@ var Editor = function(renderer, session) {
transform.selection[3]));
}
}
+
if (session.getDocument().isNewLine(text)) {
var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
- this.moveCursorTo(cursor.row+1, 0);
-
- var size = session.getTabSize();
- var minIndent = Number.MAX_VALUE;
-
- for (var row = cursor.row + 1; row <= end.row; ++row) {
- var indent = 0;
-
- line = session.getLine(row);
- for (var i = 0; i < line.length; ++i)
- if (line.charAt(i) == '\t')
- indent += size;
- else if (line.charAt(i) == ' ')
- indent += 1;
- else
- break;
- if (/[^\s]/.test(line))
- minIndent = Math.min(indent, minIndent);
- }
-
- for (var row = cursor.row + 1; row <= end.row; ++row) {
- var outdent = minIndent;
-
- line = session.getLine(row);
- for (var i = 0; i < line.length && outdent > 0; ++i)
- if (line.charAt(i) == '\t')
- outdent -= size;
- else if (line.charAt(i) == ' ')
- outdent -= 1;
- session.remove(new Range(row, 0, row, i));
- }
- session.indentRows(cursor.row + 1, end.row, lineIndent);
+ session.insert({row: cursor.row+1, column: 0}, lineIndent);
}
if (shouldOutdent)
mode.autoOutdent(lineState, session, cursor.row);
@@ -2210,62 +2370,38 @@ var Editor = function(renderer, session) {
this.session.toggleOverwrite();
};
this.setScrollSpeed = function(speed) {
- this.$mouseHandler.setScrollSpeed(speed);
+ this.setOption("scrollSpeed", speed);
};
this.getScrollSpeed = function() {
- return this.$mouseHandler.getScrollSpeed();
+ return this.getOption("scrollSpeed");
};
this.setDragDelay = function(dragDelay) {
- this.$mouseHandler.setDragDelay(dragDelay);
+ this.setOption("dragDelay", dragDelay);
};
this.getDragDelay = function() {
- return this.$mouseHandler.getDragDelay();
+ return this.getOption("dragDelay");
};
-
- this.$selectionStyle = "line";
- this.setSelectionStyle = function(style) {
- if (this.$selectionStyle == style) return;
-
- this.$selectionStyle = style;
- this.onSelectionChange();
- this._emit("changeSelectionStyle", {data: style});
+ this.setSelectionStyle = function(val) {
+ this.setOption("selectionStyle", val);
};
this.getSelectionStyle = function() {
- return this.$selectionStyle;
+ return this.getOption("selectionStyle");
};
-
- this.$highlightActiveLine = true;
this.setHighlightActiveLine = function(shouldHighlight) {
- if (this.$highlightActiveLine == shouldHighlight)
- return;
-
- this.$highlightActiveLine = shouldHighlight;
- this.$updateHighlightActiveLine();
+ this.setOption("highlightActiveLine", shouldHighlight);
};
this.getHighlightActiveLine = function() {
- return this.$highlightActiveLine;
+ return this.getOption("highlightActiveLine");
};
-
- this.$highlightGutterLine = true;
this.setHighlightGutterLine = function(shouldHighlight) {
- if (this.$highlightGutterLine == shouldHighlight)
- return;
-
- this.renderer.setHighlightGutterLine(shouldHighlight);
- this.$highlightGutterLine = shouldHighlight;
+ this.setOption("highlightGutterLine", shouldHighlight);
};
this.getHighlightGutterLine = function() {
- return this.$highlightGutterLine;
+ return this.getOption("highlightGutterLine");
};
-
- this.$highlightSelectedWord = true;
this.setHighlightSelectedWord = function(shouldHighlight) {
- if (this.$highlightSelectedWord == shouldHighlight)
- return;
-
- this.$highlightSelectedWord = shouldHighlight;
- this.$onSelectionChange();
+ this.setOption("highlightSelectedWord", shouldHighlight);
};
this.getHighlightSelectedWord = function() {
return this.$highlightSelectedWord;
@@ -2304,51 +2440,38 @@ var Editor = function(renderer, session) {
this.getPrintMarginColumn = function() {
return this.renderer.getPrintMarginColumn();
};
-
- this.$readOnly = false;
this.setReadOnly = function(readOnly) {
- this.$readOnly = readOnly;
- this.textInput.setReadOnly(readOnly);
- this.renderer.$cursorLayer.setBlinking(!readOnly);
+ this.setOption("readOnly", readOnly);
};
this.getReadOnly = function() {
- return this.$readOnly;
+ return this.getOption("readOnly");
};
-
- this.$modeBehaviours = true;
this.setBehavioursEnabled = function (enabled) {
- this.$modeBehaviours = enabled;
+ this.setOption("behavioursEnabled", enabled);
};
this.getBehavioursEnabled = function () {
- return this.$modeBehaviours;
+ return this.getOption("behavioursEnabled");
};
-
- this.$modeWrapBehaviours = true;
this.setWrapBehavioursEnabled = function (enabled) {
- this.$modeWrapBehaviours = enabled;
+ this.setOption("wrapBehavioursEnabled", enabled);
};
this.getWrapBehavioursEnabled = function () {
- return this.$modeWrapBehaviours;
+ return this.getOption("wrapBehavioursEnabled");
};
this.setShowFoldWidgets = function(show) {
- var gutter = this.renderer.$gutterLayer;
- if (gutter.getShowFoldWidgets() == show)
- return;
+ this.setOption("showFoldWidgets", show);
- this.renderer.$gutterLayer.setShowFoldWidgets(show);
- this.$showFoldWidgets = show;
- this.renderer.updateFull();
};
this.getShowFoldWidgets = function() {
- return this.renderer.$gutterLayer.getShowFoldWidgets();
+ return this.getOption("showFoldWidgets");
};
- this.setFadeFoldWidgets = function(show) {
- this.renderer.setFadeFoldWidgets(show);
+ this.setFadeFoldWidgets = function(fade) {
+ this.setOption("fadeFoldWidgets", fade);
};
this.getFadeFoldWidgets = function() {
- return this.renderer.getFadeFoldWidgets();
+ return this.getOption("fadeFoldWidgets");
};
this.remove = function(dir) {
if (this.selection.isEmpty()){
@@ -2363,6 +2486,16 @@ var Editor = function(renderer, session) {
var session = this.session;
var state = session.getState(range.start.row);
var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
+
+ if (range.end.column == 0) {
+ var text = session.getTextRange(range);
+ if (text[text.length - 1] == "\n") {
+ var line = session.getLine(range.end.row)
+ if (/^\s+$/.test(line)) {
+ range.end.column = line.length
+ }
+ }
+ }
if (new_range)
range = new_range;
}
@@ -2462,23 +2595,37 @@ var Editor = function(renderer, session) {
var session = this.session;
var range = this.getSelectionRange();
- if (range.start.row < range.end.row || range.start.column < range.end.column) {
+ if (range.start.row < range.end.row) {
var rows = this.$getSelectedRows();
session.indentRows(rows.first, rows.last, "\t");
+ return;
+ } else if (range.start.column < range.end.column) {
+ var text = session.getTextRange(range)
+ if (!/^\s+$/.test(text)) {
+ var rows = this.$getSelectedRows();
+ session.indentRows(rows.first, rows.last, "\t");
+ return;
+ }
+ }
+
+ var line = session.getLine(range.start.row)
+ var position = range.start;
+ var size = session.getTabSize();
+ var column = session.documentToScreenColumn(position.row, position.column);
+
+ if (this.session.getUseSoftTabs()) {
+ var count = (size - column % size);
+ var indentString = lang.stringRepeat(" ", count);
} else {
- var indentString;
-
- if (this.session.getUseSoftTabs()) {
- var size = session.getTabSize(),
- position = this.getCursorPosition(),
- column = session.documentToScreenColumn(position.row, position.column),
- count = (size - column % size);
-
- indentString = lang.stringRepeat(" ", count);
- } else
- indentString = "\t";
- return this.insert(indentString);
+ var count = column % size;
+ while (line[range.start.column] == " " && count) {
+ range.start.column--;
+ count--;
+ }
+ this.selection.setSelectionRange(range);
+ indentString = "\t";
}
+ return this.insert(indentString);
};
this.blockIndent = function() {
var rows = this.$getSelectedRows();
@@ -2516,21 +2663,27 @@ var Editor = function(renderer, session) {
var rows = this.$getSelectedRows();
this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last);
};
+
+ this.toggleBlockComment = function() {
+ var cursor = this.getCursorPosition();
+ var state = this.session.getState(cursor.row);
+ var range = this.getSelectionRange();
+ this.session.getMode().toggleBlockComment(state, this.session, range, cursor);
+ };
this.getNumberAt = function( row, column ) {
var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g
_numberRx.lastIndex = 0
var s = this.session.getLine(row)
- while(_numberRx.lastIndex < column - 1 ){
+ while (_numberRx.lastIndex < column) {
var m = _numberRx.exec(s)
if(m.index <= column && m.index+m[0].length >= column){
var number = {
value: m[0],
start: m.index,
end: m.index+m[0].length
-
}
- return number
+ return number;
}
}
return null;
@@ -2549,14 +2702,14 @@ var Editor = function(renderer, session) {
var t = parseFloat(nr.value);
t *= Math.pow(10, decimals);
-
+
if(fp !== nr.end && column < fp){
amount *= Math.pow(10, nr.end - column - 1);
} else {
amount *= Math.pow(10, nr.end - column);
}
-
+
t += amount;
t /= Math.pow(10, decimals);
var nnr = t.toFixed(decimals);
@@ -2585,16 +2738,16 @@ var Editor = function(renderer, session) {
var sel = this.selection;
var doc = this.session;
var range = sel.getRange();
+ var reverse = sel.isBackwards();
if (range.isEmpty()) {
var row = range.start.row;
doc.duplicateLines(row, row);
} else {
- var reverse = sel.isBackwards()
- var point = sel.isBackwards() ? range.start : range.end;
+ var point = reverse ? range.start : range.end;
var endPoint = doc.insert(point, doc.getTextRange(range), false);
range.start = point;
range.end = endPoint;
-
+
sel.setSelectionRange(range, reverse)
}
};
@@ -2609,9 +2762,6 @@ var Editor = function(renderer, session) {
});
};
this.moveText = function(range, toPosition) {
- if (this.$readOnly)
- return null;
-
return this.session.moveText(range, toPosition);
};
this.copyLinesUp = function() {
@@ -2626,25 +2776,39 @@ var Editor = function(renderer, session) {
});
};
this.$moveLines = function(mover) {
- var rows = this.$getSelectedRows();
var selection = this.selection;
- if (!selection.isMultiLine()) {
- var range = selection.getRange();
- var reverse = selection.isBackwards();
- }
-
- var linesMoved = mover.call(this, rows.first, rows.last);
+ if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
+ var range = selection.toOrientedRange();
+ var rows = this.$getSelectedRows(range);
+ var linesMoved = mover.call(this, rows.first, rows.last);
+ range.moveBy(linesMoved, 0);
+ selection.fromOrientedRange(range);
+ } else {
+ var ranges = selection.rangeList.ranges;
+ selection.rangeList.detach(this.session);
+
+ for (var i = ranges.length; i--; ) {
+ var rangeIndex = i;
+ var rows = ranges[i].collapseRows();
+ var last = rows.end.row;
+ var first = rows.start.row;
+ while (i--) {
+ var rows = ranges[i].collapseRows();
+ if (first - rows.end.row <= 1)
+ first = rows.end.row;
+ else
+ break;
+ }
+ i++;
- if (range) {
- range.start.row += linesMoved;
- range.end.row += linesMoved;
- selection.setSelectionRange(range, reverse);
- }
- else {
- selection.setSelectionAnchor(rows.last+linesMoved+1, 0);
- selection.$moveSelection(function() {
- selection.moveCursorTo(rows.first+linesMoved, 0);
- });
+ var linesMoved = mover.call(this, first, last);
+ while (rangeIndex >= i) {
+ ranges[rangeIndex].moveBy(linesMoved, 0);
+ rangeIndex--;
+ }
+ }
+ selection.fromOrientedRange(selection.ranges[0]);
+ selection.rangeList.attach(this.session);
}
};
this.$getSelectedRows = function() {
@@ -2778,7 +2942,7 @@ var Editor = function(renderer, session) {
if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
range = this.session.getBracketRange(pos);
}
-
+
pos = range && range.cursor || pos;
if (pos) {
if (select) {
@@ -2797,6 +2961,7 @@ var Editor = function(renderer, session) {
this.session.unfold({row: lineNumber - 1, column: column || 0});
this.$blockScrolling += 1;
+ this.exitMultiSelectMode && this.exitMultiSelectMode();
this.moveCursorTo(lineNumber - 1, column || 0);
this.$blockScrolling -= 1;
@@ -2808,11 +2973,19 @@ var Editor = function(renderer, session) {
this.moveCursorTo(row, column);
};
this.navigateUp = function(times) {
+ if (this.selection.isMultiLine() && !this.selection.isBackwards()) {
+ var selectionStart = this.selection.anchor.getPosition();
+ return this.moveCursorToPosition(selectionStart);
+ }
this.selection.clearSelection();
times = times || 1;
this.selection.moveCursorBy(-times, 0);
};
this.navigateDown = function(times) {
+ if (this.selection.isMultiLine() && this.selection.isBackwards()) {
+ var selectionEnd = this.selection.anchor.getPosition();
+ return this.moveCursorToPosition(selectionEnd);
+ }
this.selection.clearSelection();
times = times || 1;
this.selection.moveCursorBy(times, 0);
@@ -3000,15 +3173,140 @@ var Editor = function(renderer, session) {
};
this.destroy = function() {
this.renderer.destroy();
+ this._emit("destroy", this);
+ };
+ this.setAutoScrollEditorIntoView = function(enable) {
+ if (enable === false)
+ return;
+ var rect;
+ var self = this;
+ var shouldScroll = false;
+ if (!this.$scrollAnchor)
+ this.$scrollAnchor = document.createElement("div");
+ var scrollAnchor = this.$scrollAnchor;
+ scrollAnchor.style.cssText = "position:absolute";
+ this.container.insertBefore(scrollAnchor, this.container.firstChild);
+ var onChangeSelection = this.on("changeSelection", function() {
+ shouldScroll = true;
+ });
+ var onBeforeRender = this.renderer.on("beforeRender", function() {
+ if (shouldScroll)
+ rect = self.renderer.container.getBoundingClientRect();
+ });
+ var onAfterRender = this.renderer.on("afterRender", function() {
+ if (shouldScroll && rect && self.isFocused()) {
+ var renderer = self.renderer;
+ var pos = renderer.$cursorLayer.$pixelPos;
+ var config = renderer.layerConfig;
+ var top = pos.top - config.offset;
+ if (pos.top >= 0 && top + rect.top < 0) {
+ shouldScroll = true;
+ } else if (pos.top < config.height &&
+ pos.top + rect.top + config.lineHeight > window.innerHeight) {
+ shouldScroll = false;
+ } else {
+ shouldScroll = null;
+ }
+ if (shouldScroll != null) {
+ scrollAnchor.style.top = top + "px";
+ scrollAnchor.style.left = pos.left + "px";
+ scrollAnchor.style.height = config.lineHeight + "px";
+ scrollAnchor.scrollIntoView(shouldScroll);
+ }
+ shouldScroll = rect = null;
+ }
+ });
+ this.setAutoScrollEditorIntoView = function(enable) {
+ if (enable === true)
+ return;
+ delete this.setAutoScrollEditorIntoView;
+ this.removeEventListener("changeSelection", onChangeSelection);
+ this.renderer.removeEventListener("afterRender", onAfterRender);
+ this.renderer.removeEventListener("beforeRender", onBeforeRender);
+ };
+ };
+
+
+ this.$resetCursorStyle = function() {
+ var style = this.$cursorStyle || "ace";
+ var cursorLayer = this.renderer.$cursorLayer;
+ if (!cursorLayer)
+ return;
+ cursorLayer.setSmoothBlinking(style == "smooth");
+ cursorLayer.isBlinking = !this.$readOnly && style != "wide";
};
}).call(Editor.prototype);
+
+config.defineOptions(Editor.prototype, "editor", {
+ selectionStyle: {
+ set: function(style) {
+ this.onSelectionChange();
+ this._emit("changeSelectionStyle", {data: style});
+ },
+ initialValue: "line"
+ },
+ highlightActiveLine: {
+ set: function() {this.$updateHighlightActiveLine();},
+ initialValue: true
+ },
+ highlightSelectedWord: {
+ set: function(shouldHighlight) {this.$onSelectionChange();},
+ initialValue: true
+ },
+ readOnly: {
+ set: function(readOnly) { this.$resetCursorStyle(); },
+ initialValue: false
+ },
+ cursorStyle: {
+ set: function(val) { this.$resetCursorStyle(); },
+ values: ["ace", "slim", "smooth", "wide"],
+ initialValue: "ace"
+ },
+ mergeUndoDeltas: {
+ values: [false, true, "always"],
+ initialValue: true
+ },
+ behavioursEnabled: {initialValue: true},
+ wrapBehavioursEnabled: {initialValue: true},
+
+ hScrollBarAlwaysVisible: "renderer",
+ highlightGutterLine: "renderer",
+ animatedScroll: "renderer",
+ showInvisibles: "renderer",
+ showPrintMargin: "renderer",
+ printMarginColumn: "renderer",
+ printMargin: "renderer",
+ fadeFoldWidgets: "renderer",
+ showFoldWidgets: "renderer",
+ showGutter: "renderer",
+ displayIndentGuides: "renderer",
+ fontSize: "renderer",
+ fontFamily: "renderer",
+ maxLines: "renderer",
+ minLines: "renderer",
+ scrollPastEnd: "renderer",
+
+ scrollSpeed: "$mouseHandler",
+ dragDelay: "$mouseHandler",
+ focusTimout: "$mouseHandler",
+
+ firstLineNumber: "session",
+ overwrite: "session",
+ newLineMode: "session",
+ useWorker: "session",
+ useSoftTabs: "session",
+ tabSize: "session",
+ wrap: "session",
+ foldStyle: "session"
+});
+
exports.Editor = Editor;
});
-define('ace/lib/lang', ['require', 'exports', 'module' ], function(require, exports, module) {
+ace.define('ace/lib/lang', ['require', 'exports', 'module' ], function(require, exports, module) {
exports.stringReverse = function(string) {
@@ -3185,7 +3483,7 @@ exports.delayedCall = function(fcn, defaultTimeout) {
};
});
-define('ace/keyboard/textinput', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/lib/useragent', 'ace/lib/dom', 'ace/lib/lang'], function(require, exports, module) {
+ace.define('ace/keyboard/textinput', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/lib/useragent', 'ace/lib/dom', 'ace/lib/lang'], function(require, exports, module) {
var event = require("../lib/event");
@@ -3213,7 +3511,7 @@ var TextInput = function(parentNode, host) {
var cut = false;
var copied = false;
var pasted = false;
- var inCompostion = false;
+ var inComposition = false;
var tempStyle = '';
var isSelectionEmpty = true;
try { var isFocused = document.activeElement === text; } catch(e) {}
@@ -3236,24 +3534,29 @@ var TextInput = function(parentNode, host) {
isFocused && resetSelection(isSelectionEmpty);
});
var syncValue = lang.delayedCall(function() {
- if (!inCompostion) {
+ if (!inComposition) {
text.value = PLACEHOLDER;
isFocused && resetSelection();
}
});
function resetSelection(isEmpty) {
- if (inCompostion)
+ if (inComposition)
return;
- var selectionStart = isEmpty ? 2 : 1;
- var selectionEnd = 2;
+ if (inputHandler) {
+ selectionStart = 0;
+ selectionEnd = isEmpty ? 0 : text.value.length - 1;
+ } else {
+ var selectionStart = isEmpty ? 2 : 1;
+ var selectionEnd = 2;
+ }
try {
text.setSelectionRange(selectionStart, selectionEnd);
} catch(e){}
}
function resetValue() {
- if (inCompostion)
+ if (inComposition)
return;
text.value = PLACEHOLDER;
if (useragent.isWebKit)
@@ -3297,7 +3600,7 @@ var TextInput = function(parentNode, host) {
if (inPropertyChange)
return;
var data = text.value;
- if (inCompostion || !data || data == PLACEHOLDER)
+ if (inComposition || !data || data == PLACEHOLDER)
return;
if (e && data == PLACEHOLDER[0])
return syncProperty.schedule();
@@ -3312,38 +3615,49 @@ var TextInput = function(parentNode, host) {
var keytable = { 13:1, 27:1 };
event.addListener(text, "keyup", function (e) {
- if (inCompostion && (!text.value || keytable[e.keyCode]))
+ if (inComposition && (!text.value || keytable[e.keyCode]))
setTimeout(onCompositionEnd, 0);
if ((text.value.charCodeAt(0)||0) < 129) {
- return;
+ return syncProperty.call();
}
- inCompostion ? onCompositionUpdate() : onCompositionStart();
+ inComposition ? onCompositionUpdate() : onCompositionStart();
+ });
+ event.addListener(text, "keydown", function (e) {
+ syncProperty.schedule(50);
});
}
var onSelect = function(e) {
if (cut) {
cut = false;
- return;
- }
- if (copied) {
+ } else if (copied) {
copied = false;
- return;
- }
- if (isAllSelected(text)) {
+ } else if (isAllSelected(text)) {
host.selectAll();
resetSelection();
+ } else if (inputHandler) {
+ resetSelection(host.selection.isEmpty());
}
};
+ var inputHandler = null;
+ this.setInputHandler = function(cb) {inputHandler = cb};
+ this.getInputHandler = function() {return inputHandler};
+ var afterContextMenu = false;
+
var sendText = function(data) {
+ if (inputHandler) {
+ data = inputHandler(data);
+ inputHandler = null;
+ }
if (pasted) {
resetSelection();
if (data)
host.onPaste(data);
pasted = false;
} else if (data == PLACEHOLDER[0]) {
- host.execCommand("del", {source: "ace"});
+ if (afterContextMenu)
+ host.execCommand("del", {source: "ace"});
} else {
if (data.substring(0, 2) == PLACEHOLDER)
data = data.substr(2);
@@ -3357,14 +3671,15 @@ var TextInput = function(parentNode, host) {
if (data)
host.onTextInput(data);
}
+ if (afterContextMenu)
+ afterContextMenu = false;
};
var onInput = function(e) {
- if (inCompostion)
+ if (inComposition)
return;
var data = text.value;
- resetValue();
-
sendText(data);
+ resetValue();
};
var onCut = function(e) {
@@ -3470,20 +3785,66 @@ var TextInput = function(parentNode, host) {
});
}
var onCompositionStart = function(e) {
- inCompostion = true;
+ if (inComposition) return;
+ inComposition = {};
host.onCompositionStart();
setTimeout(onCompositionUpdate, 0);
+ host.on("mousedown", onCompositionEnd);
+ if (!host.selection.isEmpty()) {
+ host.insert("");
+ host.session.markUndoGroup();
+ host.selection.clearSelection();
+ }
+ host.session.markUndoGroup();
};
var onCompositionUpdate = function() {
- if (!inCompostion) return;
+ if (!inComposition) return;
host.onCompositionUpdate(text.value);
+ if (inComposition.lastValue)
+ host.undo();
+ inComposition.lastValue = text.value.replace(/\x01/g, "")
+ if (inComposition.lastValue) {
+ var r = host.selection.getRange();
+ host.insert(inComposition.lastValue);
+ host.session.markUndoGroup();
+ inComposition.range = host.selection.getRange();
+ host.selection.setRange(r);
+ host.selection.clearSelection();
+ }
};
var onCompositionEnd = function(e) {
- inCompostion = false;
+ var c = inComposition;
+ inComposition = false;
+ var timer = setTimeout(function() {
+ var str = text.value.replace(/\x01/g, "");
+ if (inComposition)
+ return
+ else if (str == c.lastValue)
+ resetValue();
+ else if (!c.lastValue && str) {
+ resetValue();
+ sendText(str);
+ }
+ });
+ inputHandler = function compositionInputHandler(str) {
+ clearTimeout(timer);
+ str = str.replace(/\x01/g, "");
+ if (str == c.lastValue)
+ return "";
+ if (c.lastValue)
+ host.undo();
+ return str;
+ }
host.onCompositionEnd();
+ host.removeListener("mousedown", onCompositionEnd);
+ if (e.type == "compositionend" && c.range) {
+ host.selection.setRange(c.range);
+ }
};
+
+
var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
@@ -3500,18 +3861,23 @@ var TextInput = function(parentNode, host) {
};
this.onContextMenu = function(e) {
+ afterContextMenu = true;
if (!tempStyle)
tempStyle = text.style.cssText;
text.style.cssText = "z-index:100000;" + (useragent.isIE ? "opacity:0.1;" : "");
resetSelection(host.selection.isEmpty());
- host._emit("nativecontextmenu", {target: host});
+ host._emit("nativecontextmenu", {target: host, domEvent: e});
var rect = host.container.getBoundingClientRect();
+ var style = dom.computedStyle(host.container);
+ var top = rect.top + (parseInt(style.borderTopWidth) || 0);
+ var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
+ var maxTop = rect.bottom - top - text.clientHeight;
var move = function(e) {
- text.style.left = e.clientX - rect.left - 2 + "px";
- text.style.top = e.clientY - rect.top - 2 + "px";
- };
+ text.style.left = e.clientX - left - 2 + "px";
+ text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
+ };
move(e);
if (e.type != "mousedown")
@@ -3536,7 +3902,7 @@ var TextInput = function(parentNode, host) {
}
}, 0);
}
- if (!useragent.isGecko) {
+ if (!useragent.isGecko || useragent.isMac) {
event.addListener(text, "contextmenu", function(e) {
host.textInput.onContextMenu(e);
onContextMenuClose();
@@ -3547,7 +3913,7 @@ var TextInput = function(parentNode, host) {
exports.TextInput = TextInput;
});
-define('ace/mouse/mouse_handler', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/lib/useragent', 'ace/mouse/default_handlers', 'ace/mouse/default_gutter_handler', 'ace/mouse/mouse_event', 'ace/mouse/dragdrop'], function(require, exports, module) {
+ace.define('ace/mouse/mouse_handler', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/lib/useragent', 'ace/mouse/default_handlers', 'ace/mouse/default_gutter_handler', 'ace/mouse/mouse_event', 'ace/mouse/dragdrop', 'ace/config'], function(require, exports, module) {
var event = require("../lib/event");
@@ -3556,6 +3922,7 @@ var DefaultHandlers = require("./default_handlers").DefaultHandlers;
var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler;
var MouseEvent = require("./mouse_event").MouseEvent;
var DragdropHandler = require("./dragdrop").DragdropHandler;
+var config = require("../config");
var MouseHandler = function(editor) {
this.editor = editor;
@@ -3564,11 +3931,6 @@ var MouseHandler = function(editor) {
new DefaultGutterHandler(this);
new DragdropHandler(this);
- event.addListener(editor.container, "mousedown", function(e) {
- editor.focus();
- return event.preventDefault(e);
- });
-
var mouseTarget = editor.renderer.getMouseEventTarget();
event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
@@ -3580,32 +3942,23 @@ var MouseHandler = function(editor) {
event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"));
event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"));
event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove"));
+
+ event.addListener(mouseTarget, "mousedown", function(e) {
+ editor.focus();
+ return event.preventDefault(e);
+ });
+
+ event.addListener(gutterEl, "mousedown", function(e) {
+ editor.focus();
+ return event.preventDefault(e);
+ });
};
(function() {
-
- this.$scrollSpeed = 1;
- this.setScrollSpeed = function(speed) {
- this.$scrollSpeed = speed;
- };
-
- this.getScrollSpeed = function() {
- return this.$scrollSpeed;
- };
-
this.onMouseEvent = function(name, e) {
this.editor._emit(name, new MouseEvent(e, this.editor));
};
- this.$dragDelay = 250;
- this.setDragDelay = function(dragDelay) {
- this.$dragDelay = dragDelay;
- };
-
- this.getDragDelay = function() {
- return this.$dragDelay;
- };
-
this.onMouseMove = function(name, e) {
var listeners = this.editor._eventRegistry && this.editor._eventRegistry.mousemove;
if (!listeners || !listeners.length)
@@ -3647,6 +4000,7 @@ var MouseHandler = function(editor) {
var onCaptureEnd = function(e) {
clearInterval(timerId);
+ onCaptureInterval();
self[self.state + "End"] && self[self.state + "End"](e);
self.$clickSelection = null;
if (renderer.$keepTextAreaAtCursor == null) {
@@ -3654,18 +4008,15 @@ var MouseHandler = function(editor) {
renderer.$moveTextAreaToCursor();
}
self.isMousePressed = false;
+ self.onMouseEvent("mouseup", e)
};
var onCaptureInterval = function() {
self[self.state] && self[self.state]();
- }
+ };
if (useragent.isOldIE && ev.domEvent.type == "dblclick") {
- setTimeout(function() {
- onCaptureInterval();
- onCaptureEnd(ev.domEvent);
- });
- return;
+ return setTimeout(function() {onCaptureEnd(ev);});
}
event.capture(this.editor.container, onMouseMove, onCaptureEnd);
@@ -3673,16 +4024,23 @@ var MouseHandler = function(editor) {
};
}).call(MouseHandler.prototype);
+config.defineOptions(MouseHandler.prototype, "mouseHandler", {
+ scrollSpeed: {initialValue: 2},
+ dragDelay: {initialValue: 150},
+ focusTimout: {initialValue: 0}
+});
+
+
exports.MouseHandler = MouseHandler;
});
-define('ace/mouse/default_handlers', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/lib/useragent'], function(require, exports, module) {
+ace.define('ace/mouse/default_handlers', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/lib/useragent'], function(require, exports, module) {
var dom = require("../lib/dom");
var useragent = require("../lib/useragent");
-var DRAG_OFFSET = 5; // pixels
+var DRAG_OFFSET = 0; // pixels
function DefaultHandlers(mouseHandler) {
mouseHandler.$clickSelection = null;
@@ -3703,8 +4061,6 @@ function DefaultHandlers(mouseHandler) {
mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
-
- mouseHandler.$focusWaitTimout = 250;
}
(function() {
@@ -3729,14 +4085,14 @@ function DefaultHandlers(mouseHandler) {
}
if (inSelection && !editor.isFocused()) {
editor.focus();
- if (this.$focusWaitTimout && !this.$clickSelection) {
+ if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) {
this.setState("focusWait");
this.captureMouse(ev);
return ev.preventDefault();
}
}
- if (!inSelection || this.$clickSelection || ev.getShiftKey()) {
+ if (!inSelection || this.$clickSelection || ev.getShiftKey() || editor.inMultiSelectMode) {
this.startSelect(pos);
} else if (inSelection) {
this.mousedownEvent.time = (new Date()).getTime();
@@ -3846,8 +4202,8 @@ function DefaultHandlers(mouseHandler) {
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
var time = (new Date()).getTime();
- if (distance > DRAG_OFFSET ||time - this.mousedownEvent.time > this.$focusWaitTimout)
- this.startSelect();
+ if (distance > DRAG_OFFSET || time - this.mousedownEvent.time > this.$focusTimout)
+ this.startSelect(this.mousedownEvent.getDocumentPosition());
};
this.dragWait = function(e) {
@@ -3857,7 +4213,7 @@ function DefaultHandlers(mouseHandler) {
if (distance > DRAG_OFFSET) {
this.startSelect(this.mousedownEvent.getDocumentPosition());
- } else if (time - this.mousedownEvent.time > editor.getDragDelay()) {
+ } else if (time - this.mousedownEvent.time > editor.$mouseHandler.$dragDelay) {
this.startDrag();
}
};
@@ -3940,28 +4296,18 @@ function DefaultHandlers(mouseHandler) {
};
this.onMouseWheel = function(ev) {
- if (ev.getShiftKey() || ev.getAccelKey()){
+ if (ev.getShiftKey() || ev.getAccelKey())
return;
- }
+ var t = ev.domEvent.timeStamp;
+ var dt = t - (this.$lastScrollTime||0);
+
var editor = this.editor;
var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
- if (isScrolable) {
- this.$passScrollEvent = false;
- } else {
- if (this.$passScrollEvent)
- return;
-
- if (!this.$scrollStopTimeout) {
- var self = this;
- this.$scrollStopTimeout = setTimeout(function() {
- self.$passScrollEvent = true;
- self.$scrollStopTimeout = null;
- }, 200);
- }
+ if (isScrolable || dt < 200) {
+ this.$lastScrollTime = t;
+ editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
+ return ev.stop();
}
-
- editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
- return ev.preventDefault();
};
}).call(DefaultHandlers.prototype);
@@ -3975,6 +4321,8 @@ function calcDistance(ax, ay, bx, by) {
function calcRangeOrientation(range, cursor) {
if (range.start.row == range.end.row)
var cmp = 2 * cursor.column - range.start.column - range.end.column;
+ else if (range.start.row == range.end.row - 1 && !range.start.column && !range.end.column)
+ var cmp = cursor.column - 4;
else
var cmp = 2 * cursor.row - range.start.row - range.end.row;
@@ -3986,7 +4334,7 @@ function calcRangeOrientation(range, cursor) {
});
-define('ace/mouse/default_gutter_handler', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/lib/event'], function(require, exports, module) {
+ace.define('ace/mouse/default_gutter_handler', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/lib/event'], function(require, exports, module) {
var dom = require("../lib/dom");
var event = require("../lib/event");
@@ -3996,7 +4344,7 @@ function GutterHandler(mouseHandler) {
var gutter = editor.renderer.$gutterLayer;
mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
- if (!editor.isFocused())
+ if (!editor.isFocused() || e.getButton() != 0)
return;
var gutterRegion = gutter.getRegion(e);
@@ -4108,14 +4456,15 @@ function GutterHandler(mouseHandler) {
hideTooltip();
}, 50);
});
-
+
+ editor.on("changeSession", hideTooltip);
}
exports.GutterHandler = GutterHandler;
});
-define('ace/mouse/mouse_event', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/lib/useragent'], function(require, exports, module) {
+ace.define('ace/mouse/mouse_event', ['require', 'exports', 'module' , 'ace/lib/event', 'ace/lib/useragent'], function(require, exports, module) {
var event = require("../lib/event");
@@ -4192,7 +4541,7 @@ var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
});
-define('ace/mouse/dragdrop', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) {
+ace.define('ace/mouse/dragdrop', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) {
var event = require("../lib/event");
@@ -4200,74 +4549,495 @@ var event = require("../lib/event");
var DragdropHandler = function(mouseHandler) {
var editor = mouseHandler.editor;
var dragSelectionMarker, x, y;
- var timerId, range, isBackwards;
+ var timerId, range;
var dragCursor, counter = 0;
var mouseTarget = editor.container;
event.addListener(mouseTarget, "dragenter", function(e) {
if (editor.getReadOnly())
return;
+ var types = e.dataTransfer.types;
+ if (types && Array.prototype.indexOf.call(types, "text/plain") === -1)
+ return;
+ if (!dragSelectionMarker)
+ addDragMarker();
counter++;
- if (!dragSelectionMarker) {
- range = editor.getSelectionRange();
- isBackwards = editor.selection.isBackwards();
- var style = editor.getSelectionStyle();
- dragSelectionMarker = editor.session.addMarker(range, "ace_selection", style);
- editor.clearSelection();
- clearInterval(timerId);
- timerId = setInterval(onDragInterval, 20);
- }
return event.preventDefault(e);
});
event.addListener(mouseTarget, "dragover", function(e) {
if (editor.getReadOnly())
return;
+ var types = e.dataTransfer.types;
+ if (types && Array.prototype.indexOf.call(types, "text/plain") === -1)
+ return;
+ if (onMouseMoveTimer !== null)
+ onMouseMoveTimer = null;
x = e.clientX;
y = e.clientY;
return event.preventDefault(e);
});
-
+
var onDragInterval = function() {
dragCursor = editor.renderer.screenToTextCoordinates(x, y);
editor.moveCursorToPosition(dragCursor);
editor.renderer.scrollCursorIntoView();
};
-
+
event.addListener(mouseTarget, "dragleave", function(e) {
- if (editor.getReadOnly())
- return;
counter--;
- if (counter > 0)
- return;
- clearInterval(timerId);
- editor.session.removeMarker(dragSelectionMarker);
- dragSelectionMarker = null;
- editor.selection.setSelectionRange(range, isBackwards);
- return event.preventDefault(e);
+ if (counter <= 0 && dragSelectionMarker) {
+ clearDragMarker();
+ return event.preventDefault(e);
+ }
});
-
+
event.addListener(mouseTarget, "drop", function(e) {
- if (editor.getReadOnly())
+ if (!dragSelectionMarker)
return;
- counter = 0;
- clearInterval(timerId);
- editor.session.removeMarker(dragSelectionMarker);
- dragSelectionMarker = null;
-
range.end = editor.session.insert(dragCursor, e.dataTransfer.getData('Text'));
range.start = dragCursor;
+ clearDragMarker();
editor.focus();
- editor.selection.setSelectionRange(range);
return event.preventDefault(e);
});
+ function addDragMarker() {
+ range = editor.selection.toOrientedRange();
+ dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle());
+ editor.clearSelection();
+ clearInterval(timerId);
+ timerId = setInterval(onDragInterval, 20);
+ counter = 0;
+ event.addListener(document, "mousemove", onMouseMove);
+ }
+ function clearDragMarker() {
+ clearInterval(timerId);
+ editor.session.removeMarker(dragSelectionMarker);
+ dragSelectionMarker = null;
+ editor.selection.fromOrientedRange(range);
+ counter = 0;
+ event.removeListener(document, "mousemove", onMouseMove);
+ }
+ var onMouseMoveTimer = null;
+ function onMouseMove() {
+ if (onMouseMoveTimer == null) {
+ onMouseMoveTimer = setTimeout(function() {
+ if (onMouseMoveTimer != null && dragSelectionMarker)
+ clearDragMarker();
+ }, 20);
+ }
+ }
};
exports.DragdropHandler = DragdropHandler;
});
-define('ace/mouse/fold_handler', ['require', 'exports', 'module' ], function(require, exports, module) {
+ace.define('ace/config', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/lib/oop', 'ace/lib/net', 'ace/lib/event_emitter'], function(require, exports, module) {
+"no use strict";
+
+var lang = require("./lib/lang");
+var oop = require("./lib/oop");
+var net = require("./lib/net");
+var EventEmitter = require("./lib/event_emitter").EventEmitter;
+
+var global = (function() {
+ return this;
+})();
+
+var options = {
+ packaged: false,
+ workerPath: null,
+ modePath: null,
+ themePath: null,
+ basePath: "",
+ suffix: ".js",
+ $moduleUrls: {}
+};
+
+exports.get = function(key) {
+ if (!options.hasOwnProperty(key))
+ throw new Error("Unknown config key: " + key);
+
+ return options[key];
+};
+
+exports.set = function(key, value) {
+ if (!options.hasOwnProperty(key))
+ throw new Error("Unknown config key: " + key);
+
+ options[key] = value;
+};
+
+exports.all = function() {
+ return lang.copyObject(options);
+};
+oop.implement(exports, EventEmitter);
+
+exports.moduleUrl = function(name, component) {
+ if (options.$moduleUrls[name])
+ return options.$moduleUrls[name];
+
+ var parts = name.split("/");
+ component = component || parts[parts.length - 2] || "";
+ var sep = component == "snippets" ? "/" : "-";
+ var base = parts[parts.length - 1];
+ if (sep == "-") {
+ var re = new RegExp("^" + component + "[\-_]|[\-_]" + component + "$", "g");
+ base = base.replace(re, "");
+ }
+
+ if ((!base || base == component) && parts.length > 1)
+ base = parts[parts.length - 2];
+ var path = options[component + "Path"];
+ if (path == null) {
+ path = options.basePath;
+ } else if (sep == "/") {
+ component = sep = "";
+ }
+ if (path && path.slice(-1) != "/")
+ path += "/";
+ return path + component + sep + base + this.get("suffix");
+};
+
+exports.setModuleUrl = function(name, subst) {
+ return options.$moduleUrls[name] = subst;
+};
+
+exports.$loading = {};
+exports.loadModule = function(moduleName, onLoad) {
+ var module, moduleType;
+ if (Array.isArray(moduleName)) {
+ moduleType = moduleName[0];
+ moduleName = moduleName[1];
+ }
+
+ try {
+ module = require(moduleName);
+ } catch (e) {};
+ if (module && !exports.$loading[moduleName])
+ return onLoad && onLoad(module);
+
+ if (!exports.$loading[moduleName])
+ exports.$loading[moduleName] = [];
+
+ exports.$loading[moduleName].push(onLoad);
+
+ if (exports.$loading[moduleName].length > 1)
+ return;
+
+ var afterLoad = function() {
+ require([moduleName], function(module) {
+ exports._emit("load.module", {name: moduleName, module: module});
+ var listeners = exports.$loading[moduleName];
+ exports.$loading[moduleName] = null;
+ listeners.forEach(function(onLoad) {
+ onLoad && onLoad(module);
+ });
+ });
+ };
+
+ if (!exports.get("packaged"))
+ return afterLoad();
+ net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
+};
+exports.init = function() {
+ options.packaged = require.packaged || module.packaged || (global.define && define.packaged);
+
+ if (!global.document)
+ return "";
+
+ var scriptOptions = {};
+ var scriptUrl = "";
+
+ var scripts = document.getElementsByTagName("script");
+ for (var i=0; i<scripts.length; i++) {
+ var script = scripts[i];
+
+ var src = script.src || script.getAttribute("src");
+ if (!src)
+ continue;
+
+ var attributes = script.attributes;
+ for (var j=0, l=attributes.length; j < l; j++) {
+ var attr = attributes[j];
+ if (attr.name.indexOf("data-ace-") === 0) {
+ scriptOptions[deHyphenate(attr.name.replace(/^data-ace-/, ""))] = attr.value;
+ }
+ }
+
+ var m = src.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);
+ if (m)
+ scriptUrl = m[1];
+ }
+
+ if (scriptUrl) {
+ scriptOptions.base = scriptOptions.base || scriptUrl;
+ scriptOptions.packaged = true;
+ }
+
+ scriptOptions.basePath = scriptOptions.base;
+ scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
+ scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
+ scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
+ delete scriptOptions.base;
+
+ for (var key in scriptOptions)
+ if (typeof scriptOptions[key] !== "undefined")
+ exports.set(key, scriptOptions[key]);
+};
+
+function deHyphenate(str) {
+ return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
+}
+
+var optionsProvider = {
+ setOptions: function(optList) {
+ Object.keys(optList).forEach(function(key) {
+ this.setOption(key, optList[key]);
+ }, this);
+ },
+ getOptions: function(optionNames) {
+ var result = {};
+ if (!optionNames) {
+ optionNames = Object.keys(this.$options);
+ } else if (!Array.isArray(optionNames)) {
+ result = optionNames;
+ optionNames = Object.keys(result);
+ }
+ optionNames.forEach(function(key) {
+ result[key] = this.getOption(key);
+ }, this);
+ return result;
+ },
+ setOption: function(name, value) {
+ if (this["$" + name] === value)
+ return;
+ var opt = this.$options[name];
+ if (!opt)
+ return undefined;
+ if (opt.forwardTo)
+ return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
+
+ if (!opt.handlesSet)
+ this["$" + name] = value;
+ if (opt && opt.set)
+ opt.set.call(this, value);
+ },
+ getOption: function(name) {
+ var opt = this.$options[name];
+ if (!opt)
+ return undefined;
+ if (opt.forwardTo)
+ return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
+ return opt && opt.get ? opt.get.call(this) : this["$" + name];
+ }
+};
+
+var defaultOptions = {};
+exports.defineOptions = function(obj, path, options) {
+ if (!obj.$options)
+ defaultOptions[path] = obj.$options = {};
+
+ Object.keys(options).forEach(function(key) {
+ var opt = options[key];
+ if (typeof opt == "string")
+ opt = {forwardTo: opt};
+
+ opt.name || (opt.name = key);
+ obj.$options[opt.name] = opt;
+ if ("initialValue" in opt)
+ obj["$" + opt.name] = opt.initialValue;
+ });
+ oop.implement(obj, optionsProvider);
+
+ return this;
+};
+
+exports.resetOptions = function(obj) {
+ Object.keys(obj.$options).forEach(function(key) {
+ var opt = obj.$options[key];
+ if ("value" in opt)
+ obj.setOption(key, opt.value);
+ });
+};
+
+exports.setDefaultValue = function(path, name, value) {
+ var opts = defaultOptions[path] || (defaultOptions[path] = {});
+ if (opts[name]) {
+ if (opts.forwardTo)
+ exports.setDefaultValue(opts.forwardTo, name, value)
+ else
+ opts[name].value = value;
+ }
+};
+
+exports.setDefaultValues = function(path, optionHash) {
+ Object.keys(optionHash).forEach(function(key) {
+ exports.setDefaultValue(path, key, optionHash[key]);
+ });
+};
+
+});
+ace.define('ace/lib/net', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
+
+var dom = require("./dom");
+
+exports.get = function (url, callback) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', url, true);
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState === 4) {
+ callback(xhr.responseText);
+ }
+ };
+ xhr.send(null);
+};
+
+exports.loadScript = function(path, callback) {
+ var head = dom.getDocumentHead();
+ var s = document.createElement('script');
+
+ s.src = path;
+ head.appendChild(s);
+
+ s.onload = s.onreadystatechange = function(_, isAbort) {
+ if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
+ s = s.onload = s.onreadystatechange = null;
+ if (!isAbort)
+ callback();
+ }
+ };
+};
+
+});
+
+ace.define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) {
+
+
+var EventEmitter = {};
+var stopPropagation = function() { this.propagationStopped = true; };
+var preventDefault = function() { this.defaultPrevented = true; };
+
+EventEmitter._emit =
+EventEmitter._dispatchEvent = function(eventName, e) {
+ this._eventRegistry || (this._eventRegistry = {});
+ this._defaultHandlers || (this._defaultHandlers = {});
+
+ var listeners = this._eventRegistry[eventName] || [];
+ var defaultHandler = this._defaultHandlers[eventName];
+ if (!listeners.length && !defaultHandler)
+ return;
+
+ if (typeof e != "object" || !e)
+ e = {};
+
+ if (!e.type)
+ e.type = eventName;
+ if (!e.stopPropagation)
+ e.stopPropagation = stopPropagation;
+ if (!e.preventDefault)
+ e.preventDefault = preventDefault;
+
+ for (var i=0; i<listeners.length; i++) {
+ listeners[i](e, this);
+ if (e.propagationStopped)
+ break;
+ }
+
+ if (defaultHandler && !e.defaultPrevented)
+ return defaultHandler(e, this);
+};
+
+
+EventEmitter._signal = function(eventName, e) {
+ var listeners = (this._eventRegistry || {})[eventName];
+ if (!listeners)
+ return;
+
+ for (var i=0; i<listeners.length; i++)
+ listeners[i](e, this);
+};
+
+EventEmitter.once = function(eventName, callback) {
+ var _self = this;
+ callback && this.addEventListener(eventName, function newCallback() {
+ _self.removeEventListener(eventName, newCallback);
+ callback.apply(null, arguments);
+ });
+};
+
+
+EventEmitter.setDefaultHandler = function(eventName, callback) {
+ var handlers = this._defaultHandlers
+ if (!handlers)
+ handlers = this._defaultHandlers = {_disabled_: {}};
+
+ if (handlers[eventName]) {
+ var old = handlers[eventName];
+ var disabled = handlers._disabled_[eventName];
+ if (!disabled)
+ handlers._disabled_[eventName] = disabled = [];
+ disabled.push(old);
+ var i = disabled.indexOf(callback);
+ if (i != -1)
+ disabled.splice(i, 1);
+ }
+ handlers[eventName] = callback;
+};
+EventEmitter.removeDefaultHandler = function(eventName, callback) {
+ var handlers = this._defaultHandlers
+ if (!handlers)
+ return;
+ var disabled = handlers._disabled_[eventName];
+
+ if (handlers[eventName] == callback) {
+ var old = handlers[eventName];
+ if (disabled)
+ this.setDefaultHandler(eventName, disabled.pop());
+ } else if (disabled) {
+ var i = disabled.indexOf(callback);
+ if (i != -1)
+ disabled.splice(i, 1);
+ }
+};
+
+EventEmitter.on =
+EventEmitter.addEventListener = function(eventName, callback, capturing) {
+ this._eventRegistry = this._eventRegistry || {};
+
+ var listeners = this._eventRegistry[eventName];
+ if (!listeners)
+ listeners = this._eventRegistry[eventName] = [];
+
+ if (listeners.indexOf(callback) == -1)
+ listeners[capturing ? "unshift" : "push"](callback);
+ return callback;
+};
+
+EventEmitter.off =
+EventEmitter.removeListener =
+EventEmitter.removeEventListener = function(eventName, callback) {
+ this._eventRegistry = this._eventRegistry || {};
+
+ var listeners = this._eventRegistry[eventName];
+ if (!listeners)
+ return;
+
+ var index = listeners.indexOf(callback);
+ if (index !== -1)
+ listeners.splice(index, 1);
+};
+
+EventEmitter.removeAllListeners = function(eventName) {
+ if (this._eventRegistry) this._eventRegistry[eventName] = [];
+};
+
+exports.EventEmitter = EventEmitter;
+
+});
+
+ace.define('ace/mouse/fold_handler', ['require', 'exports', 'module' ], function(require, exports, module) {
function FoldHandler(editor) {
@@ -4286,9 +5056,7 @@ function FoldHandler(editor) {
}
});
- editor.on("guttermousedown", function(e) {
- if (!editor.isFocused())
- return;
+ editor.on("gutterclick", function(e) {
var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
if (gutterRegion == "foldWidgets") {
@@ -4296,6 +5064,8 @@ function FoldHandler(editor) {
var session = editor.session;
if (session.foldWidgets && session.foldWidgets[row])
editor.session.onFoldWidgetClick(row, e);
+ if (!editor.isFocused())
+ editor.focus();
e.stop();
}
});
@@ -4306,27 +5076,8 @@ function FoldHandler(editor) {
if (gutterRegion == "foldWidgets") {
var row = e.getDocumentPosition().row;
var session = editor.session;
- var fw = session.foldWidgets;
- if (!fw || fw[row])
- return;
-
- var i = row - 1, firstRange;
- while (i >= 0) {
- var c = fw[i];
- if (c == null)
- c = fw[i] = session.getFoldWidget();
-
- if (c == "start") {
- var range = session.getFoldWidgetRange(i);
- if (!firstRange)
- firstRange = range;
- if (range && range.end.row >= row)
- break;
- }
- i--;
- }
- if (i == -1)
- range = firstRange;
+ var data = session.getParentFoldRangeData(row, true);
+ var range = data.range || data.firstRange;
if (range) {
var row = range.start.row;
@@ -4348,7 +5099,7 @@ exports.FoldHandler = FoldHandler;
});
-define('ace/keyboard/keybinding', ['require', 'exports', 'module' , 'ace/lib/keys', 'ace/lib/event'], function(require, exports, module) {
+ace.define('ace/keyboard/keybinding', ['require', 'exports', 'module' , 'ace/lib/keys', 'ace/lib/event'], function(require, exports, module) {
var keyUtil = require("../lib/keys");
@@ -4370,11 +5121,12 @@ var KeyBinding = function(editor) {
};
this.setKeyboardHandler = function(kb) {
- if (this.$handlers[this.$handlers.length - 1] == kb)
+ var h = this.$handlers;
+ if (h[h.length - 1] == kb)
return;
- while (this.$handlers[1])
- this.removeKeyboardHandler(this.$handlers[1]);
+ while (h[h.length - 1] && h[h.length - 1] != this.$defaultHandler)
+ this.removeKeyboardHandler(h[h.length - 1]);
this.addKeyboardHandler(kb, 1);
};
@@ -4420,11 +5172,11 @@ var KeyBinding = function(editor) {
if (!toExecute || !toExecute.command)
continue;
if (toExecute.command == "null") {
- success = toExecute.passEvent != true;
+ success = true;
} else {
success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
}
- if (success && e && hashId != -1)
+ if (success && e && hashId != -1 && toExecute.passEvent != true)
event.stopEvent(e);
if (success)
break;
@@ -4448,13 +5200,12 @@ var KeyBinding = function(editor) {
exports.KeyBinding = KeyBinding;
});
-define('ace/edit_session', ['require', 'exports', 'module' , 'ace/config', 'ace/lib/oop', 'ace/lib/lang', 'ace/lib/net', 'ace/lib/event_emitter', 'ace/selection', 'ace/mode/text', 'ace/range', 'ace/document', 'ace/background_tokenizer', 'ace/search_highlight', 'ace/edit_session/folding', 'ace/edit_session/bracket_match'], function(require, exports, module) {
+ace.define('ace/edit_session', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/config', 'ace/lib/event_emitter', 'ace/selection', 'ace/mode/text', 'ace/range', 'ace/document', 'ace/background_tokenizer', 'ace/search_highlight', 'ace/edit_session/folding', 'ace/edit_session/bracket_match'], function(require, exports, module) {
-var config = require("./config");
var oop = require("./lib/oop");
var lang = require("./lib/lang");
-var net = require("./lib/net");
+var config = require("./config");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var Selection = require("./selection").Selection;
var TextMode = require("./mode/text").Mode;
@@ -4470,25 +5221,23 @@ var EditSession = function(text, mode) {
this.$backMarkers = {};
this.$markerId = 1;
this.$undoSelect = true;
-
+
this.$foldData = [];
this.$foldData.toString = function() {
- var str = "";
- this.forEach(function(foldLine) {
- str += "\n" + foldLine.toString();
- });
- return str;
+ return this.join("\n");
}
this.on("changeFold", this.onChangeFold.bind(this));
this.$onChange = this.onChange.bind(this);
-
+
if (typeof text != "object" || !text.getLine)
text = new Document(text);
this.setDocument(text);
-
this.selection = new Selection(this);
+
+ config.resetOptions(this);
this.setMode(mode);
+ config._emit("session", this);
};
@@ -4516,12 +5265,12 @@ var EditSession = function(text, mode) {
this.$screenRowCache = [];
return;
}
-
- var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
var l = this.$docRowCache.length;
- this.$docRowCache.splice(i, l);
- this.$screenRowCache.splice(i, l);
-
+ var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
+ if (l > i) {
+ this.$docRowCache.splice(i, l);
+ this.$screenRowCache.splice(i, l);
+ }
};
this.$getRowCacheIndex = function(cacheArray, val) {
@@ -4657,17 +5406,21 @@ var EditSession = function(text, mode) {
if (self.$deltas.length > 0) {
undoManager.execute({
action: "aceupdate",
- args: [self.$deltas, self]
+ args: [self.$deltas, self],
+ merge: self.mergeUndoDeltas
});
}
-
+ self.mergeUndoDeltas = false;
self.$deltas = [];
}
- this.$informUndoManager =
- lang.deferredCall(this.$syncInformUndoManager);
+ this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager);
}
};
-
+ this.markUndoGroup = function() {
+ if (this.$syncInformUndoManager)
+ this.$syncInformUndoManager();
+ };
+
this.$defaultUndoManager = {
undo: function() {},
redo: function() {},
@@ -4683,25 +5436,14 @@ var EditSession = function(text, mode) {
return "\t";
}
};
-
- this.$useSoftTabs = true;
- this.setUseSoftTabs = function(useSoftTabs) {
- if (this.$useSoftTabs === useSoftTabs) return;
-
- this.$useSoftTabs = useSoftTabs;
+ this.setUseSoftTabs = function(val) {
+ this.setOption("useSoftTabs", val);
};
this.getUseSoftTabs = function() {
- return this.$useSoftTabs;
+ return this.$useSoftTabs && !this.$mode.$indentWithTabs;
};
-
- this.$tabSize = 4;
this.setTabSize = function(tabSize) {
- if (isNaN(tabSize) || this.$tabSize === tabSize) return;
-
- this.$modified = true;
- this.$rowLengthCache = [];
- this.$tabSize = tabSize;
- this._emit("changeTabSize");
+ this.setOption("tabSize", tabSize)
};
this.getTabSize = function() {
return this.$tabSize;
@@ -4712,10 +5454,7 @@ var EditSession = function(text, mode) {
this.$overwrite = false;
this.setOverwrite = function(overwrite) {
- if (this.$overwrite == overwrite) return;
-
- this.$overwrite = overwrite;
- this._emit("changeOverwrite");
+ this.setOption("overwrite", overwrite)
};
this.getOverwrite = function() {
return this.$overwrite;
@@ -4828,11 +5567,9 @@ var EditSession = function(text, mode) {
}
if (!clazz)
clazz = "ace_step";
-
+
var range = new Range(startRow, 0, endRow, Infinity);
-
- var id = this.addMarker(range, clazz, "fullLine", inFront);
- range.id = id;
+ range.id = this.addMarker(range, clazz, "fullLine", inFront);
return range;
};
this.setAnnotations = function(annotations) {
@@ -4843,8 +5580,7 @@ var EditSession = function(text, mode) {
return this.$annotations || [];
};
this.clearAnnotations = function() {
- this.$annotations = {};
- this._emit("changeAnnotation", {});
+ this.setAnnotations([]);
};
this.$detectNewLine = function(text) {
var match = text.match(/^.*?(\r?\n)/m);
@@ -4863,7 +5599,7 @@ var EditSession = function(text, mode) {
if (!inToken)
inToken = !!line.charAt(column).match(this.tokenRe);
-
+
if (inToken)
var re = this.tokenRe;
else if (/^\s+$/.test(line.slice(column-1, column+1)))
@@ -4902,21 +5638,8 @@ var EditSession = function(text, mode) {
this.getNewLineMode = function() {
return this.doc.getNewLineMode();
};
-
- this.$useWorker = true;
- this.setUseWorker = function(useWorker) {
- if (this.$useWorker == useWorker)
- return;
-
- this.$useWorker = useWorker;
-
- this.$stopWorker();
- if (useWorker)
- this.$startWorker();
- };
- this.getUseWorker = function() {
- return this.$useWorker;
- };
+ this.setUseWorker = function(useWorker) { this.setOption("useWorker", useWorker); };
+ this.getUseWorker = function() { return this.$useWorker; };
this.onReloadTokenizer = function(e) {
var rows = e.data;
this.bgTokenizer.start(rows.first);
@@ -4926,7 +5649,7 @@ var EditSession = function(text, mode) {
this.$modes = {};
this.$mode = null;
this.$modeId = null;
- this.setMode = function(mode) {
+ this.setMode = function(mode, cb) {
if (mode && typeof mode === "object") {
if (mode.getTokenizer)
return this.$onChangeMode(mode);
@@ -4943,7 +5666,7 @@ var EditSession = function(text, mode) {
this.$modeId = path;
config.loadModule(["mode", path], function(m) {
if (this.$modeId !== path)
- return;
+ return cb && cb();
if (this.$modes[path] && !options)
return this.$onChangeMode(this.$modes[path]);
if (m && m.Mode) {
@@ -4952,7 +5675,8 @@ var EditSession = function(text, mode) {
this.$modes[path] = m;
m.$id = path;
}
- this.$onChangeMode(m)
+ this.$onChangeMode(m);
+ cb && cb(this.mode);
}
}.bind(this));
if (!this.$mode)
@@ -4960,7 +5684,11 @@ var EditSession = function(text, mode) {
};
this.$onChangeMode = function(mode, $isPlaceholder) {
- if (this.$mode === mode) return;
+ if (!$isPlaceholder)
+ this.$modeId = mode.$id;
+ if (this.$mode === mode)
+ return;
+
this.$mode = mode;
this.$stopWorker();
@@ -4992,41 +5720,10 @@ var EditSession = function(text, mode) {
if (!$isPlaceholder) {
- this.$modeId = mode.$id;
this.$setFolding(mode.foldingRules);
this._emit("changeMode");
this.bgTokenizer.start(0);
}
- var rules = null, completionKeywords = [];
- for (var rule in rules) {
- if (rules.hasOwnProperty(rule)) {
- var ruleItr = rules[rule];
- for (var r = 0, l = ruleItr.length; r < l; r++) {
- if (typeof ruleItr[r].token === "string") {
- if (/keyword|support|storage/.test(ruleItr[r].token))
- completionKeywords.push(ruleItr[r].regex);
- }
- else if (typeof ruleItr[r].token === "object") {
- for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) {
- if (/keyword|support|storage/.test(ruleItr[r].token[a])) {
- var rule = ruleItr[r].regex.match(/\(.+?\)/g)[a];
- completionKeywords.push(rule.substr(1, rule.length - 2));
- }
- }
- }
- }
- }
- }
-
- if (mode.$id != null) {
- var self = this;
- this.$modes[mode.$id].getKeywords = function(append) {
- if (!append)
- return self.$modes[mode.$id].$keywordList;
-
- return completionKeywords.concat(self.$modes[mode.$id].$keywordList || []);
- };
- }
};
@@ -5037,7 +5734,6 @@ var EditSession = function(text, mode) {
this.$worker = null;
};
-
this.$startWorker = function() {
if (typeof Worker !== "undefined" && !require.noWorker) {
try {
@@ -5057,12 +5753,12 @@ var EditSession = function(text, mode) {
this.$scrollTop = 0;
this.setScrollTop = function(scrollTop) {
- scrollTop = Math.round(Math.max(0, scrollTop));
- if (this.$scrollTop === scrollTop)
+ scrollTop = Math.round(scrollTop);
+ if (this.$scrollTop === scrollTop || isNaN(scrollTop))
return;
this.$scrollTop = scrollTop;
- this._emit("changeScrollTop", scrollTop);
+ this._signal("changeScrollTop", scrollTop);
};
this.getScrollTop = function() {
return this.$scrollTop;
@@ -5070,12 +5766,12 @@ var EditSession = function(text, mode) {
this.$scrollLeft = 0;
this.setScrollLeft = function(scrollLeft) {
- scrollLeft = Math.round(Math.max(0, scrollLeft));
- if (this.$scrollLeft === scrollLeft)
+ scrollLeft = Math.round(scrollLeft);
+ if (this.$scrollLeft === scrollLeft || isNaN(scrollLeft))
return;
this.$scrollLeft = scrollLeft;
- this._emit("changeScrollLeft", scrollLeft);
+ this._signal("changeScrollLeft", scrollLeft);
};
this.getScrollLeft = function() {
return this.$scrollLeft;
@@ -5189,7 +5885,7 @@ var EditSession = function(text, mode) {
this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
function isInsert(delta) {
var insert =
- delta.action == "insertText" || delta.action == "insertLines";
+ delta.action === "insertText" || delta.action === "insertLines";
return isUndo ? !insert : insert;
}
@@ -5197,7 +5893,7 @@ var EditSession = function(text, mode) {
var range, point;
var lastDeltaIsInsert = false;
if (isInsert(delta)) {
- range = delta.range.clone();
+ range = Range.fromPoints(delta.range.start, delta.range.end);
lastDeltaIsInsert = true;
} else {
range = Range.fromPoints(delta.range.start, delta.range.start);
@@ -5226,6 +5922,11 @@ var EditSession = function(text, mode) {
}
}
if (lastUndoRange != null) {
+ if (Range.comparePoints(lastUndoRange.start, range.start) == 0) {
+ lastUndoRange.start.column += range.end.column - range.start.column;
+ lastUndoRange.end.column += range.end.column - range.start.column;
+ }
+
var cmp = lastUndoRange.compareRange(range);
if (cmp == 1) {
range.setStart(lastUndoRange.start);
@@ -5239,29 +5940,44 @@ var EditSession = function(text, mode) {
this.replace = function(range, text) {
return this.doc.replace(range, text);
};
- this.moveText = function(fromRange, toPosition) {
+ this.moveText = function(fromRange, toPosition, copy) {
var text = this.getTextRange(fromRange);
- this.remove(fromRange);
+ var folds = this.getFoldsInRange(fromRange);
- var toRow = toPosition.row;
- var toColumn = toPosition.column;
- if (!fromRange.isMultiLine() && fromRange.start.row == toRow &&
- fromRange.end.column < toColumn)
- toColumn -= text.length;
-
- if (fromRange.isMultiLine() && fromRange.end.row < toRow) {
- var lines = this.doc.$split(text);
- toRow -= lines.length - 1;
+ var toRange = Range.fromPoints(toPosition, toPosition);
+ if (!copy) {
+ this.remove(fromRange);
+ var rowDiff = fromRange.start.row - fromRange.end.row;
+ var collDiff = rowDiff ? -fromRange.end.column : fromRange.start.column - fromRange.end.column;
+ if (collDiff) {
+ if (toRange.start.row == fromRange.end.row && toRange.start.column > fromRange.end.column)
+ toRange.start.column += collDiff;
+ if (toRange.end.row == fromRange.end.row && toRange.end.column > fromRange.end.column)
+ toRange.end.column += collDiff;
+ }
+ if (rowDiff && toRange.start.row >= fromRange.end.row) {
+ toRange.start.row += rowDiff;
+ toRange.end.row += rowDiff;
+ }
}
- var endRow = toRow + fromRange.end.row - fromRange.start.row;
- var endColumn = fromRange.isMultiLine() ?
- fromRange.end.column :
- toColumn + fromRange.end.column - fromRange.start.column;
-
- var toRange = new Range(toRow, toColumn, endRow, endColumn);
-
this.insert(toRange.start, text);
+ if (folds.length) {
+ var oldStart = fromRange.start;
+ var newStart = toRange.start;
+ var rowDiff = newStart.row - oldStart.row;
+ var collDiff = newStart.column - oldStart.column;
+ this.addFolds(folds.map(function(x) {
+ x = x.clone();
+ if (x.start.row == oldStart.row)
+ x.start.column += collDiff;
+ if (x.end.row == oldStart.row)
+ x.end.column += collDiff;
+ x.start.row += rowDiff;
+ x.end.row += rowDiff;
+ return x;
+ }));
+ }
return toRange;
};
@@ -5293,29 +6009,47 @@ var EditSession = function(text, mode) {
this.remove(deleteRange);
}
};
- this.moveLinesUp = function(firstRow, lastRow) {
- if (firstRow <= 0) return 0;
- var removed = this.doc.removeLines(firstRow, lastRow);
- this.doc.insertLines(firstRow - 1, removed);
- return -1;
+ this.$moveLines = function(firstRow, lastRow, dir) {
+ firstRow = this.getRowFoldStart(firstRow);
+ lastRow = this.getRowFoldEnd(lastRow);
+ if (dir < 0) {
+ var row = this.getRowFoldStart(firstRow + dir);
+ if (row < 0) return 0;
+ var diff = row-firstRow;
+ } else if (dir > 0) {
+ var row = this.getRowFoldEnd(lastRow + dir);
+ if (row > this.doc.getLength()-1) return 0;
+ var diff = row-lastRow;
+ } else {
+ firstRow = this.$clipRowToDocument(firstRow);
+ lastRow = this.$clipRowToDocument(lastRow);
+ var diff = lastRow - firstRow + 1;
+ }
+
+ var range = new Range(firstRow, 0, lastRow, Number.MAX_VALUE);
+ var folds = this.getFoldsInRange(range).map(function(x){
+ x = x.clone();
+ x.start.row += diff;
+ x.end.row += diff;
+ return x;
+ });
+
+ var lines = dir == 0
+ ? this.doc.getLines(firstRow, lastRow)
+ : this.doc.removeLines(firstRow, lastRow);
+ this.doc.insertLines(firstRow+diff, lines);
+ folds.length && this.addFolds(folds);
+ return diff;
+ };
+ this.moveLinesUp = function(firstRow, lastRow) {
+ return this.$moveLines(firstRow, lastRow, -1);
};
this.moveLinesDown = function(firstRow, lastRow) {
- if (lastRow >= this.doc.getLength()-1) return 0;
-
- var removed = this.doc.removeLines(firstRow, lastRow);
- this.doc.insertLines(firstRow+1, removed);
- return 1;
+ return this.$moveLines(firstRow, lastRow, 1);
};
this.duplicateLines = function(firstRow, lastRow) {
- var firstRow = this.$clipRowToDocument(firstRow);
- var lastRow = this.$clipRowToDocument(lastRow);
-
- var lines = this.getLines(firstRow, lastRow);
- this.doc.insertLines(firstRow, lines);
-
- var addedRows = lastRow - firstRow + 1;
- return addedRows;
+ return this.$moveLines(firstRow, lastRow, 0);
};
@@ -5409,9 +6143,12 @@ var EditSession = function(text, mode) {
this._emit("changeWrapMode");
}
};
- this.adjustWrapLimit = function(desiredLimit) {
- var wrapLimit = this.$constrainWrapLimit(desiredLimit);
- if (wrapLimit != this.$wrapLimit && wrapLimit > 0) {
+ this.adjustWrapLimit = function(desiredLimit, $printMargin) {
+ var limits = this.$wrapLimitRange
+ if (limits.max < 0)
+ limits = {min: $printMargin, max: $printMargin};
+ var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max);
+ if (wrapLimit != this.$wrapLimit && wrapLimit > 1) {
this.$wrapLimit = wrapLimit;
this.$modified = true;
if (this.$useWrapMode) {
@@ -5424,19 +6161,21 @@ var EditSession = function(text, mode) {
return false;
};
- this.$constrainWrapLimit = function(wrapLimit) {
- var min = this.$wrapLimitRange.min;
+ this.$constrainWrapLimit = function(wrapLimit, min, max) {
if (min)
wrapLimit = Math.max(min, wrapLimit);
- var max = this.$wrapLimitRange.max;
if (max)
wrapLimit = Math.min(max, wrapLimit);
- return Math.max(1, wrapLimit);
+
+ return wrapLimit;
};
this.getWrapLimit = function() {
return this.$wrapLimit;
};
+ this.setWrapLimit = function (limit) {
+ this.setWrapLimitRange(limit, limit);
+ };
this.getWrapLimitRange = function() {
return {
min : this.$wrapLimitRange.min,
@@ -5465,6 +6204,7 @@ var EditSession = function(text, mode) {
len = lastRow - firstRow;
}
+ this.$updating = true;
if (len != 0) {
if (action.indexOf("remove") != -1) {
this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
@@ -5548,6 +6288,7 @@ var EditSession = function(text, mode) {
if (useWrapMode && this.$wrapData.length != this.doc.getLength()) {
console.error("doc.getLength() and $wrapData.length have to be the same!");
}
+ this.$updating = false;
if (useWrapMode)
this.$updateWrapData(firstRow, lastRow);
@@ -5823,7 +6564,7 @@ var EditSession = function(text, mode) {
foldStart = foldLine ? foldLine.start.row : Infinity;
}
}
-
+
if (doCache) {
this.$docRowCache.push(docRow);
this.$screenRowCache.push(row);
@@ -6020,292 +6761,77 @@ var EditSession = function(text, mode) {
require("./edit_session/folding").Folding.call(EditSession.prototype);
require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype);
-exports.EditSession = EditSession;
-});
-
-define('ace/config', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/lib/oop', 'ace/lib/net', 'ace/lib/event_emitter'], function(require, exports, module) {
-"no use strict";
-
-var lang = require("./lib/lang");
-var oop = require("./lib/oop");
-var net = require("./lib/net");
-var EventEmitter = require("./lib/event_emitter").EventEmitter;
-
-var global = (function() {
- return this;
-})();
-
-var options = {
- packaged: false,
- workerPath: null,
- modePath: null,
- themePath: null,
- basePath: "",
- suffix: ".js",
- $moduleUrls: {}
-};
-
-exports.get = function(key) {
- if (!options.hasOwnProperty(key))
- throw new Error("Unknown config key: " + key);
-
- return options[key];
-};
-
-exports.set = function(key, value) {
- if (!options.hasOwnProperty(key))
- throw new Error("Unknown config key: " + key);
-
- options[key] = value;
-};
-
-exports.all = function() {
- return lang.copyObject(options);
-};
-oop.implement(exports, EventEmitter);
-
-exports.moduleUrl = function(name, component) {
- if (options.$moduleUrls[name])
- return options.$moduleUrls[name];
-
- var parts = name.split("/");
- component = component || parts[parts.length - 2] || "";
- var base = parts[parts.length - 1].replace(component, "").replace(/(^[\-_])|([\-_]$)/, "");
-
- if (!base && parts.length > 1)
- base = parts[parts.length - 2];
- var path = options[component + "Path"];
- if (path == null)
- path = options.basePath;
- if (path && path.slice(-1) != "/")
- path += "/";
- return path + component + "-" + base + this.get("suffix");
-};
-
-exports.setModuleUrl = function(name, subst) {
- return options.$moduleUrls[name] = subst;
-};
-
-exports.loadModule = function(moduleName, onLoad) {
- var module, moduleType;
- if (Array.isArray(moduleName)) {
- moduleType = moduleName[0];
- moduleName = moduleName[1];
- }
- try {
- module = require(moduleName);
- } catch (e) {};
- if (module)
- return onLoad(module);
-
- var afterLoad = function() {
- require([moduleName], function(module) {
- exports._emit("load.module", {name: moduleName, module: module});
- onLoad(module);
- });
- };
-
- if (!exports.get("packaged"))
- return afterLoad();
- net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
-};
-exports.init = function() {
- options.packaged = require.packaged || module.packaged || (global.define && define.packaged);
-
- if (!global.document)
- return "";
-
- var scriptOptions = {};
- var scriptUrl = "";
- var scripts = document.getElementsByTagName("script");
- for (var i=0; i<scripts.length; i++) {
- var script = scripts[i];
+config.defineOptions(EditSession.prototype, "session", {
+ wrap: {
+ set: function(value) {
+ if (!value || value == "off")
+ value = false;
+ else if (value == "free")
+ value = true;
+ else if (value == "printMargin")
+ value = -1;
+ else if (typeof value == "string")
+ value = parseInt(value, 10) || false;
- var src = script.src || script.getAttribute("src");
- if (!src)
- continue;
-
- var attributes = script.attributes;
- for (var j=0, l=attributes.length; j < l; j++) {
- var attr = attributes[j];
- if (attr.name.indexOf("data-ace-") === 0) {
- scriptOptions[deHyphenate(attr.name.replace(/^data-ace-/, ""))] = attr.value;
+ if (this.$wrap == value)
+ return;
+ if (!value) {
+ this.setUseWrapMode(false);
+ } else {
+ var col = typeof value == "number" ? value : null;
+ this.setWrapLimitRange(col, col);
+ this.setUseWrapMode(true);
}
- }
-
- var m = src.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);
- if (m)
- scriptUrl = m[1];
- }
-
- if (scriptUrl) {
- scriptOptions.base = scriptOptions.base || scriptUrl;
- scriptOptions.packaged = true;
- }
-
- scriptOptions.basePath = scriptOptions.base;
- scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
- scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
- scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
- delete scriptOptions.base;
-
- for (var key in scriptOptions)
- if (typeof scriptOptions[key] !== "undefined")
- exports.set(key, scriptOptions[key]);
-};
-
-function deHyphenate(str) {
- return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
-}
-
-});
-define('ace/lib/net', ['require', 'exports', 'module' , 'ace/lib/useragent'], function(require, exports, module) {
-
-
-var useragent = require("./useragent");
-
-exports.get = function (url, callback) {
- var xhr = exports.createXhr();
- xhr.open('GET', url, true);
- xhr.onreadystatechange = function (evt) {
- if (xhr.readyState === 4) {
- callback(xhr.responseText);
- }
- };
- xhr.send(null);
-};
-
-var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
-
-exports.createXhr = function() {
- var xhr, i, progId;
- if (typeof XMLHttpRequest !== "undefined") {
- return new XMLHttpRequest();
- } else {
- for (i = 0; i < 3; i++) {
- progId = progIds[i];
- try {
- xhr = new ActiveXObject(progId);
- } catch (e) {}
+ this.$wrap = value;
+ },
+ get: function() {
+ return this.getUseWrapMode() ? this.getWrapLimitRange().min || "free" : "off";
+ },
+ handlesSet: true
+ },
+ firstLineNumber: {
+ set: function() {this._emit("changeBreakpoint");},
+ initialValue: 1
+ },
+ useWorker: {
+ set: function(useWorker) {
+ this.$useWorker = useWorker;
- if (xhr) {
- progIds = [progId]; // so faster next time
- break;
- }
- }
- }
+ this.$stopWorker();
+ if (useWorker)
+ this.$startWorker();
+ },
+ initialValue: true
+ },
+ useSoftTabs: {initialValue: true},
+ tabSize: {
+ set: function(tabSize) {
+ if (isNaN(tabSize) || this.$tabSize === tabSize) return;
- if (!xhr) {
- throw new Error("createXhr(): XMLHttpRequest not available");
+ this.$modified = true;
+ this.$rowLengthCache = [];
+ this.$tabSize = tabSize;
+ this._emit("changeTabSize");
+ },
+ initialValue: 4,
+ handlesSet: true
+ },
+ overwrite: {
+ set: function(val) {this._emit("changeOverwrite");},
+ initialValue: false
+ },
+ newLineMode: {
+ set: function(val) {this.doc.setNewLineMode(val)},
+ get: function() {return this.doc.getNewLineMode()},
+ handlesSet: true
}
-
- return xhr;
-};
-
-exports.loadScript = function(path, callback) {
- var head = document.getElementsByTagName('head')[0];
- var s = document.createElement('script');
-
- s.src = path;
- head.appendChild(s);
-
- if (useragent.isOldIE)
- s.onreadystatechange = function () {
- this.readyState == 'loaded' && callback();
- };
- else
- s.onload = callback;
-};
-
});
-define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) {
-
-
-var EventEmitter = {};
-
-EventEmitter._emit =
-EventEmitter._dispatchEvent = function(eventName, e) {
- this._eventRegistry = this._eventRegistry || {};
- this._defaultHandlers = this._defaultHandlers || {};
-
- var listeners = this._eventRegistry[eventName] || [];
- var defaultHandler = this._defaultHandlers[eventName];
- if (!listeners.length && !defaultHandler)
- return;
-
- if (typeof e != "object" || !e)
- e = {};
-
- if (!e.type)
- e.type = eventName;
-
- if (!e.stopPropagation) {
- e.stopPropagation = function() {
- this.propagationStopped = true;
- };
- }
-
- if (!e.preventDefault) {
- e.preventDefault = function() {
- this.defaultPrevented = true;
- };
- }
-
- for (var i=0; i<listeners.length; i++) {
- listeners[i](e);
- if (e.propagationStopped)
- break;
- }
-
- if (defaultHandler && !e.defaultPrevented)
- return defaultHandler(e);
-};
-
-EventEmitter.setDefaultHandler = function(eventName, callback) {
- this._defaultHandlers = this._defaultHandlers || {};
-
- if (this._defaultHandlers[eventName])
- throw new Error("The default handler for '" + eventName + "' is already set");
-
- this._defaultHandlers[eventName] = callback;
-};
-
-EventEmitter.on =
-EventEmitter.addEventListener = function(eventName, callback) {
- this._eventRegistry = this._eventRegistry || {};
-
- var listeners = this._eventRegistry[eventName];
- if (!listeners)
- listeners = this._eventRegistry[eventName] = [];
-
- if (listeners.indexOf(callback) == -1)
- listeners.push(callback);
-};
-
-EventEmitter.removeListener =
-EventEmitter.removeEventListener = function(eventName, callback) {
- this._eventRegistry = this._eventRegistry || {};
-
- var listeners = this._eventRegistry[eventName];
- if (!listeners)
- return;
-
- var index = listeners.indexOf(callback);
- if (index !== -1)
- listeners.splice(index, 1);
-};
-
-EventEmitter.removeAllListeners = function(eventName) {
- if (this._eventRegistry) this._eventRegistry[eventName] = [];
-};
-
-exports.EventEmitter = EventEmitter;
-
+exports.EditSession = EditSession;
});
-define('ace/selection', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/lib/event_emitter', 'ace/range'], function(require, exports, module) {
+ace.define('ace/selection', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/lib/event_emitter', 'ace/range'], function(require, exports, module) {
var oop = require("./lib/oop");
@@ -6430,6 +6956,8 @@ var Selection = function(session) {
this.setSelectionAnchor(range.start.row, range.start.column);
this.selectTo(range.end.row, range.end.column);
}
+ if (this.getRange().isEmpty())
+ this.$isEmpty = true;
this.$desiredColumn = null;
};
@@ -6681,7 +7209,7 @@ var Selection = function(session) {
while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
index ++;
- if (index <= 1) {
+ if (index < 1) {
tokenRe.lastIndex = 0;
while ((ch = rightOfCursor[index]) && !tokenRe.test(ch)) {
tokenRe.lastIndex = 0;
@@ -6717,11 +7245,11 @@ var Selection = function(session) {
if (column == line.length) {
var l = this.doc.getLength();
- do {
+ do {
row++;
rightOfCursor = this.doc.getLine(row)
} while (row < l && /^\s*$/.test(rightOfCursor))
-
+
if (!/^\s+/.test(rightOfCursor))
rightOfCursor = ""
column = 0;
@@ -6742,11 +7270,11 @@ var Selection = function(session) {
var line = this.session.getLine(row).substring(0, column);
if (column == 0) {
- do {
+ do {
row--;
line = this.doc.getLine(row);
} while (row > 0 && /^\s*$/.test(line))
-
+
column = line.length;
if (!/\s+$/.test(line))
line = ""
@@ -6835,12 +7363,62 @@ var Selection = function(session) {
return range;
}
+ this.toJSON = function() {
+ if (this.rangeCount) {
+ var data = this.ranges.map(function(r) {
+ var r1 = r.clone();
+ r1.isBackwards = r.cursor == r.start;
+ return r1;
+ });
+ } else {
+ var data = this.getRange();
+ data.isBackwards = this.isBackwards();
+ }
+ return data;
+ };
+
+ this.fromJSON = function(data) {
+ if (data.start == undefined) {
+ if (this.rangeList) {
+ this.toSingleRange(data[0]);
+ for (var i = data.length; i--; ) {
+ var r = Range.fromPoints(data[i].start, data[i].end);
+ if (data.isBackwards)
+ r.cursor = r.start;
+ this.addRange(r, true);
+ }
+ return;
+ } else
+ data = data[0];
+ }
+ if (this.rangeList)
+ this.toSingleRange(data);
+ this.setSelectionRange(data, data.isBackwards);
+ };
+
+ this.isEqual = function(data) {
+ if ((data.length || this.rangeCount) && data.length != this.rangeCount)
+ return false;
+ if (!data.length || !this.ranges)
+ return this.getRange().isEqual(data);
+
+ for (var i = this.ranges.length; i--; ) {
+ if (!this.ranges[i].isEqual(data[i]))
+ return false
+ }
+ return true;
+ }
+
}).call(Selection.prototype);
exports.Selection = Selection;
});
-define('ace/range', ['require', 'exports', 'module' ], function(require, exports, module) {
+ace.define('ace/range', ['require', 'exports', 'module' ], function(require, exports, module) {
+
+var comparePoints = function(p1, p2) {
+ return p1.row - p2.row || p1.column - p2.column;
+};
var Range = function(startRow, startColumn, endRow, endColumn) {
this.start = {
row: startRow,
@@ -6853,21 +7431,21 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
};
};
-(function() {
+(function() {
this.isEqual = function(range) {
- return this.start.row == range.start.row &&
- this.end.row == range.end.row &&
- this.start.column == range.start.column &&
- this.end.column == range.end.column
- };
+ return this.start.row === range.start.row &&
+ this.end.row === range.end.row &&
+ this.start.column === range.start.column &&
+ this.end.column === range.end.column;
+ };
this.toString = function() {
return ("Range: [" + this.start.row + "/" + this.start.column +
"] -> [" + this.end.row + "/" + this.end.column + "]");
- };
+ };
this.contains = function(row, column) {
return this.compare(row, column) == 0;
- };
+ };
this.compareRange = function(range) {
var cmp,
end = range.end,
@@ -6895,10 +7473,10 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
return 0;
}
}
- };
+ };
this.comparePoint = function(p) {
return this.compare(p.row, p.column);
- };
+ };
this.containsRange = function(range) {
return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
};
@@ -6908,10 +7486,10 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
};
this.isEnd = function(row, column) {
return this.end.row == row && this.end.column == column;
- };
+ };
this.isStart = function(row, column) {
return this.start.row == row && this.start.column == column;
- };
+ };
this.setStart = function(row, column) {
if (typeof row == "object") {
this.start.column = row.column;
@@ -6920,7 +7498,7 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
this.start.row = row;
this.start.column = column;
}
- };
+ };
this.setEnd = function(row, column) {
if (typeof row == "object") {
this.end.column = row.column;
@@ -6929,7 +7507,7 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
this.end.row = row;
this.end.column = column;
}
- };
+ };
this.inside = function(row, column) {
if (this.compare(row, column) == 0) {
if (this.isEnd(row, column) || this.isStart(row, column)) {
@@ -6939,7 +7517,7 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
}
}
return false;
- };
+ };
this.insideStart = function(row, column) {
if (this.compare(row, column) == 0) {
if (this.isEnd(row, column)) {
@@ -6949,7 +7527,7 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
}
}
return false;
- };
+ };
this.insideEnd = function(row, column) {
if (this.compare(row, column) == 0) {
if (this.isStart(row, column)) {
@@ -7005,33 +7583,16 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
}
};
this.clipRows = function(firstRow, lastRow) {
- if (this.end.row > lastRow) {
- var end = {
- row: lastRow+1,
- column: 0
- };
- }
-
- if (this.start.row > lastRow) {
- var start = {
- row: lastRow+1,
- column: 0
- };
- }
+ if (this.end.row > lastRow)
+ var end = {row: lastRow + 1, column: 0};
+ else if (this.end.row < firstRow)
+ var end = {row: firstRow, column: 0};
- if (this.start.row < firstRow) {
- var start = {
- row: firstRow,
- column: 0
- };
- }
+ if (this.start.row > lastRow)
+ var start = {row: lastRow + 1, column: 0};
+ else if (this.start.row < firstRow)
+ var start = {row: firstRow, column: 0};
- if (this.end.row < firstRow) {
- var end = {
- row: firstRow,
- column: 0
- };
- }
return Range.fromPoints(start || this.start, end || this.end);
};
this.extend = function(row, column) {
@@ -7048,7 +7609,7 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
};
this.isEmpty = function() {
- return (this.start.row == this.end.row && this.start.column == this.end.column);
+ return (this.start.row === this.end.row && this.start.column === this.end.column);
};
this.isMultiLine = function() {
return (this.start.row !== this.end.row);
@@ -7063,32 +7624,45 @@ var Range = function(startRow, startColumn, endRow, endColumn) {
return new Range(this.start.row, 0, this.end.row, 0)
};
this.toScreenRange = function(session) {
- var screenPosStart =
- session.documentToScreenPosition(this.start);
- var screenPosEnd =
- session.documentToScreenPosition(this.end);
+ var screenPosStart = session.documentToScreenPosition(this.start);
+ var screenPosEnd = session.documentToScreenPosition(this.end);
return new Range(
screenPosStart.row, screenPosStart.column,
screenPosEnd.row, screenPosEnd.column
);
};
+ this.moveBy = function(row, column) {
+ this.start.row += row;
+ this.start.column += column;
+ this.end.row += row;
+ this.end.column += column;
+ };
}).call(Range.prototype);
Range.fromPoints = function(start, end) {
return new Range(start.row, start.column, end.row, end.column);
};
+Range.comparePoints = comparePoints;
+
+Range.comparePoints = function(p1, p2) {
+ return p1.row - p2.row || p1.column - p2.column;
+};
+
exports.Range = Range;
});
-define('ace/mode/text', ['require', 'exports', 'module' , 'ace/tokenizer', 'ace/mode/text_highlight_rules', 'ace/mode/behaviour', 'ace/unicode'], function(require, exports, module) {
+ace.define('ace/mode/text', ['require', 'exports', 'module' , 'ace/tokenizer', 'ace/mode/text_highlight_rules', 'ace/mode/behaviour', 'ace/unicode', 'ace/lib/lang', 'ace/token_iterator', 'ace/range'], function(require, exports, module) {
var Tokenizer = require("../tokenizer").Tokenizer;
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var Behaviour = require("./behaviour").Behaviour;
var unicode = require("../unicode");
+var lang = require("../lib/lang");
+var TokenIterator = require("../token_iterator").TokenIterator;
+var Range = require("../range").Range;
var Mode = function() {
this.$tokenizer = new Tokenizer(new TextHighlightRules().getRules());
@@ -7103,7 +7677,7 @@ var Mode = function() {
+ unicode.packages.Nd
+ unicode.packages.Pc + "\\$_]+", "g"
);
-
+
this.nonTokenRe = new RegExp("^(?:[^"
+ unicode.packages.L
+ unicode.packages.Mn + unicode.packages.Mc
@@ -7115,11 +7689,194 @@ var Mode = function() {
return this.$tokenizer;
};
- this.toggleCommentLines = function(state, doc, startRow, endRow) {
+ this.lineCommentStart = "";
+ this.blockComment = "";
+
+ this.toggleCommentLines = function(state, session, startRow, endRow) {
+ var doc = session.doc;
+
+ var ignoreBlankLines = true;
+ var shouldRemove = true;
+ var minIndent = Infinity;
+ var tabSize = session.getTabSize();
+ var insertAtTabStop = false;
+
+ if (!this.lineCommentStart) {
+ if (!this.blockComment)
+ return false;
+ var lineCommentStart = this.blockComment.start;
+ var lineCommentEnd = this.blockComment.end;
+ var regexpStart = new RegExp("^(\\s*)(?:" + lang.escapeRegExp(lineCommentStart) + ")");
+ var regexpEnd = new RegExp("(?:" + lang.escapeRegExp(lineCommentEnd) + ")\\s*$");
+
+ var comment = function(line, i) {
+ if (testRemove(line, i))
+ return;
+ if (!ignoreBlankLines || /\S/.test(line)) {
+ doc.insertInLine({row: i, column: line.length}, lineCommentEnd);
+ doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
+ }
+ };
+
+ var uncomment = function(line, i) {
+ var m;
+ if (m = line.match(regexpEnd))
+ doc.removeInLine(i, line.length - m[0].length, line.length);
+ if (m = line.match(regexpStart))
+ doc.removeInLine(i, m[1].length, m[0].length);
+ };
+
+ var testRemove = function(line, row) {
+ if (regexpStart.test(line))
+ return true;
+ var tokens = session.getTokens(row);
+ for (var i = 0; i < tokens.length; i++) {
+ if (tokens[i].type === 'comment')
+ return true;
+ }
+ };
+ } else {
+ if (Array.isArray(this.lineCommentStart)) {
+ var regexpStart = this.lineCommentStart.map(lang.escapeRegExp).join("|");
+ var lineCommentStart = this.lineCommentStart[0];
+ } else {
+ var regexpStart = lang.escapeRegExp(this.lineCommentStart);
+ var lineCommentStart = this.lineCommentStart;
+ }
+ regexpStart = new RegExp("^(\\s*)(?:" + regexpStart + ") ?");
+
+ insertAtTabStop = session.getUseSoftTabs();
+
+ var uncomment = function(line, i) {
+ var m = line.match(regexpStart);
+ if (!m) return;
+ var start = m[1].length, end = m[0].length;
+ if (!shouldInsertSpace(line, start, end) && m[0][end - 1] == " ")
+ end--;
+ doc.removeInLine(i, start, end);
+ };
+ var commentWithSpace = lineCommentStart + " ";
+ var comment = function(line, i) {
+ if (!ignoreBlankLines || /\S/.test(line)) {
+ if (shouldInsertSpace(line, minIndent, minIndent))
+ doc.insertInLine({row: i, column: minIndent}, commentWithSpace);
+ else
+ doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
+ }
+ };
+ var testRemove = function(line, i) {
+ return regexpStart.test(line);
+ };
+
+ var shouldInsertSpace = function(line, before, after) {
+ var spaces = 0;
+ while (before-- && line.charAt(before) == " ")
+ spaces++;
+ if (spaces % tabSize != 0)
+ return false;
+ var spaces = 0;
+ while (line.charAt(after++) == " ")
+ spaces++;
+ if (tabSize > 2)
+ return spaces % tabSize != tabSize - 1;
+ else
+ return spaces % tabSize == 0;
+ return true;
+ };
+ }
+
+ function iter(fun) {
+ for (var i = startRow; i <= endRow; i++)
+ fun(doc.getLine(i), i);
+ }
+
+
+ var minEmptyLength = Infinity;
+ iter(function(line, i) {
+ var indent = line.search(/\S/);
+ if (indent !== -1) {
+ if (indent < minIndent)
+ minIndent = indent;
+ if (shouldRemove && !testRemove(line, i))
+ shouldRemove = false;
+ } else if (minEmptyLength > line.length) {
+ minEmptyLength = line.length;
+ }
+ });
+
+ if (minIndent == Infinity) {
+ minIndent = minEmptyLength;
+ ignoreBlankLines = false;
+ shouldRemove = false;
+ }
+
+ if (insertAtTabStop && minIndent % tabSize != 0)
+ minIndent = Math.floor(minIndent / tabSize) * tabSize;
+
+ iter(shouldRemove ? uncomment : comment);
+ };
+
+ this.toggleBlockComment = function(state, session, range, cursor) {
+ var comment = this.blockComment;
+ if (!comment)
+ return;
+ if (!comment.start && comment[0])
+ comment = comment[0];
+
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
+ var token = iterator.getCurrentToken();
+
+ var sel = session.selection;
+ var initialRange = session.selection.toOrientedRange();
+ var startRow, colDiff;
+
+ if (token && /comment/.test(token.type)) {
+ var startRange, endRange;
+ while (token && /comment/.test(token.type)) {
+ var i = token.value.indexOf(comment.start);
+ if (i != -1) {
+ var row = iterator.getCurrentTokenRow();
+ var column = iterator.getCurrentTokenColumn() + i;
+ startRange = new Range(row, column, row, column + comment.start.length);
+ break
+ }
+ token = iterator.stepBackward();
+ };
+
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
+ var token = iterator.getCurrentToken();
+ while (token && /comment/.test(token.type)) {
+ var i = token.value.indexOf(comment.end);
+ if (i != -1) {
+ var row = iterator.getCurrentTokenRow();
+ var column = iterator.getCurrentTokenColumn() + i;
+ endRange = new Range(row, column, row, column + comment.end.length);
+ break;
+ }
+ token = iterator.stepForward();
+ }
+ if (endRange)
+ session.remove(endRange);
+ if (startRange) {
+ session.remove(startRange);
+ startRow = startRange.start.row;
+ colDiff = -comment.start.length
+ }
+ } else {
+ colDiff = comment.start.length
+ startRow = range.start.row;
+ session.insert(range.end, comment.end);
+ session.insert(range.start, comment.start);
+ }
+ if (initialRange.start.row == startRow)
+ initialRange.start.column += colDiff;
+ if (initialRange.end.row == startRow)
+ initialRange.end.column += colDiff;
+ session.selection.fromOrientedRange(initialRange);
};
this.getNextLineIndent = function(state, line, tab) {
- return "";
+ return this.$getIndent(line);
};
this.checkOutdent = function(state, line, input) {
@@ -7130,14 +7887,9 @@ var Mode = function() {
};
this.$getIndent = function(line) {
- var match = line.match(/^(\s+)/);
- if (match) {
- return match[1];
- }
-
- return "";
+ return line.match(/^\s*/)[0];
};
-
+
this.createWorker = function(session) {
return null;
};
@@ -7152,7 +7904,7 @@ var Mode = function() {
this.$modes[this.$embeds[i]] = new mapping[this.$embeds[i]]();
}
}
-
+
var delegations = ['toggleCommentLines', 'getNextLineIndent', 'checkOutdent', 'autoOutdent', 'transformAction'];
for (var i = 0; i < delegations.length; i++) {
@@ -7164,14 +7916,15 @@ var Mode = function() {
}
} (this));
}
- }
-
+ };
+
this.$delegator = function(method, args, defaultHandler) {
var state = args[0];
-
+ if (typeof state != "string")
+ state = state[0];
for (var i = 0; i < this.$embeds.length; i++) {
if (!this.$modes[this.$embeds[i]]) continue;
-
+
var split = state.split(this.$embeds[i]);
if (!split[0] && split[1]) {
args[0] = split[1];
@@ -7182,7 +7935,7 @@ var Mode = function() {
var ret = defaultHandler.apply(this, args);
return defaultHandler ? ret : undefined;
};
-
+
this.transformAction = function(state, action, editor, session, param) {
if (this.$behaviour) {
var behaviours = this.$behaviour.getBehaviours();
@@ -7195,16 +7948,44 @@ var Mode = function() {
}
}
}
- }
+ };
+
+ this.getKeywords = function(append) {
+ if (!this.completionKeywords) {
+ var rules = this.$tokenizer.rules;
+ var completionKeywords = [];
+ for (var rule in rules) {
+ var ruleItr = rules[rule];
+ for (var r = 0, l = ruleItr.length; r < l; r++) {
+ if (typeof ruleItr[r].token === "string") {
+ if (/keyword|support|storage/.test(ruleItr[r].token))
+ completionKeywords.push(ruleItr[r].regex);
+ }
+ else if (typeof ruleItr[r].token === "object") {
+ for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) {
+ if (/keyword|support|storage/.test(ruleItr[r].token[a])) {
+ var rule = ruleItr[r].regex.match(/\(.+?\)/g)[a];
+ completionKeywords.push(rule.substr(1, rule.length - 2));
+ }
+ }
+ }
+ }
+ }
+ this.completionKeywords = completionKeywords;
+ }
+ if (!append)
+ return this.$keywordList;
+ return completionKeywords.concat(this.$keywordList || []);
+ };
}).call(Mode.prototype);
exports.Mode = Mode;
});
-define('ace/tokenizer', ['require', 'exports', 'module' ], function(require, exports, module) {
-var Tokenizer = function(rules, flag) {
- flag = flag ? "g" + flag : "g";
+ace.define('ace/tokenizer', ['require', 'exports', 'module' ], function(require, exports, module) {
+var MAX_TOKEN_COUNT = 1000;
+var Tokenizer = function(rules) {
this.states = rules;
this.regExps = {};
@@ -7214,24 +7995,39 @@ var Tokenizer = function(rules, flag) {
var ruleRegExps = [];
var matchTotal = 0;
var mapping = this.matchMappings[key] = {defaultToken: "text"};
+ var flag = "g";
+ var splitterRurles = [];
for (var i = 0; i < state.length; i++) {
var rule = state[i];
- if (rule.defaultToken) {
+ if (rule.defaultToken)
mapping.defaultToken = rule.defaultToken;
+ if (rule.caseInsensitive)
+ flag = "gi";
+ if (rule.regex == null)
continue;
- }
+
if (rule.regex instanceof RegExp)
rule.regex = rule.regex.toString().slice(1, -1);
var adjustedregex = rule.regex;
var matchcount = new RegExp("(?:(" + adjustedregex + ")|(.))").exec("a").length - 2;
if (Array.isArray(rule.token)) {
- if (rule.token.length == 1) {
+ if (rule.token.length == 1 || matchcount == 1) {
rule.token = rule.token[0];
+ } else if (matchcount - 1 != rule.token.length) {
+ throw new Error("number of classes and regexp groups in '" +
+ rule.token + "'\n'" + rule.regex + "' doesn't match\n"
+ + (matchcount - 1) + "!=" + rule.token.length);
} else {
rule.tokenArray = rule.token;
- rule.token = this.$arrayTokens;
+ rule.token = null;
+ rule.onMatch = this.$arrayTokens;
}
+ } else if (typeof rule.token == "function" && !rule.onMatch) {
+ if (matchcount > 1)
+ rule.onMatch = this.$applyToken;
+ else
+ rule.onMatch = rule.token;
}
if (matchcount > 1) {
@@ -7243,43 +8039,63 @@ var Tokenizer = function(rules, flag) {
matchcount = 1;
adjustedregex = this.removeCapturingGroups(rule.regex);
}
- if (!rule.splitRegex)
- rule.splitRegex = this.createSplitterRegexp(rule.regex, flag);
+ if (!rule.splitRegex && typeof rule.token != "string")
+ splitterRurles.push(rule); // flag will be known only at the very end
}
mapping[matchTotal] = i;
matchTotal += matchcount;
ruleRegExps.push(adjustedregex);
+ if (!rule.onMatch)
+ rule.onMatch = null;
+ rule.__proto__ = null;
}
+
+ splitterRurles.forEach(function(rule) {
+ rule.splitRegex = this.createSplitterRegexp(rule.regex, flag);
+ }, this);
this.regExps[key] = new RegExp("(" + ruleRegExps.join(")|(") + ")|($)", flag);
}
};
(function() {
+ this.$applyToken = function(str) {
+ var values = this.splitRegex.exec(str).slice(1);
+ var types = this.token.apply(this, values);
+ if (typeof types === "string")
+ return [{type: types, value: str}];
+
+ var tokens = [];
+ for (var i = 0, l = types.length; i < l; i++) {
+ if (values[i])
+ tokens[tokens.length] = {
+ type: types[i],
+ value: values[i]
+ };
+ }
+ return tokens;
+ },
+
this.$arrayTokens = function(str) {
if (!str)
return [];
- var values = str.split(this.splitRegex)
+ var values = this.splitRegex.exec(str);
+ if (!values)
+ return "text";
var tokens = [];
var types = this.tokenArray;
- if (types.length != values.length - 2) {
- if (window.console)
- console.error(types.length , values.length - 2, str, this.splitRegex);
- return [{type: "error.invalid", value: str}];
- }
- for (var i = 0; i < types.length; i++) {
- if (values[i + 1]) {
+ for (var i = 0, l = types.length; i < l; i++) {
+ if (values[i + 1])
tokens[tokens.length] = {
type: types[i],
value: values[i + 1]
};
- }
}
return tokens;
};
-
+
this.removeCapturingGroups = function(src) {
var r = src.replace(
/\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g,
@@ -7287,10 +8103,39 @@ var Tokenizer = function(rules, flag) {
);
return r;
};
-
+
this.createSplitterRegexp = function(src, flag) {
- src = src.replace(/\(\?=([^()]|\\.)*?\)$/, "");
- return new RegExp(src, flag);
+ if (src.indexOf("(?=") != -1) {
+ var stack = 0;
+ var inChClass = false;
+ var lastCapture = {};
+ src.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g, function(
+ m, esc, parenOpen, parenClose, square, index
+ ) {
+ if (inChClass) {
+ inChClass = square != "]";
+ } else if (square) {
+ inChClass = true;
+ } else if (parenClose) {
+ if (stack == lastCapture.stack) {
+ lastCapture.end = index+1;
+ lastCapture.stack = -1;
+ }
+ stack--;
+ } else if (parenOpen) {
+ stack++;
+ if (parenOpen.length != 1) {
+ lastCapture.stack = stack
+ lastCapture.start = index;
+ }
+ }
+ return m;
+ });
+
+ if (lastCapture.end != null && /^\)*$/.test(src.substr(lastCapture.end)))
+ src = src.substring(0, lastCapture.start) + src.substr(lastCapture.end);
+ }
+ return new RegExp(src, (flag||"").replace("g", ""));
};
this.getLineTokens = function(line, startState) {
if (startState && typeof startState != "string") {
@@ -7332,12 +8177,18 @@ var Tokenizer = function(rules, flag) {
continue;
rule = state[mapping[i]];
- type = typeof rule.token == "function"
- ? rule.token(value, currentState, stack)
- : rule.token;
+
+ if (rule.onMatch)
+ type = rule.onMatch(value, currentState, stack);
+ else
+ type = rule.token;
if (rule.next) {
- currentState = rule.next;
+ if (typeof rule.next == "string")
+ currentState = rule.next;
+ else
+ currentState = rule.next(currentState, stack);
+
state = this.states[currentState];
if (!state) {
window.console && console.error && console.error(currentState, "doesn't exist");
@@ -7361,7 +8212,7 @@ var Tokenizer = function(rules, flag) {
tokens.push(token);
token = {type: type, value: value};
}
- } else {
+ } else if (type) {
if (token.type)
tokens.push(token);
token = {type: null, value: ""};
@@ -7374,6 +8225,20 @@ var Tokenizer = function(rules, flag) {
break;
lastIndex = index;
+
+ if (tokens.length > MAX_TOKEN_COUNT) {
+ while (lastIndex < line.length) {
+ if (token.type)
+ tokens.push(token);
+ token = {
+ value: line.substring(lastIndex, lastIndex += 2000),
+ type: "overflow"
+ }
+ }
+ currentState = "start";
+ stack = [];
+ break;
+ }
}
if (token.type)
@@ -7390,7 +8255,7 @@ var Tokenizer = function(rules, flag) {
exports.Tokenizer = Tokenizer;
});
-define('ace/mode/text_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) {
+ace.define('ace/mode/text_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/lang'], function(require, exports, module) {
var lang = require("../lib/lang");
@@ -7402,8 +8267,7 @@ var TextHighlightRules = function() {
token : "empty_line",
regex : '^$'
}, {
- token : "text",
- regex : ".+"
+ defaultToken : "text"
}]
};
};
@@ -7411,12 +8275,24 @@ var TextHighlightRules = function() {
(function() {
this.addRules = function(rules, prefix) {
+ if (!prefix) {
+ for (var key in rules)
+ this.$rules[key] = rules[key];
+ return;
+ }
for (var key in rules) {
var state = rules[key];
for (var i = 0; i < state.length; i++) {
var rule = state[i];
if (rule.next) {
- rule.next = prefix + rule.next;
+ if (typeof rule.next != "string") {
+ if (rule.nextState && rule.nextState.indexOf(prefix) !== 0)
+ rule.nextState = prefix + rule.nextState;
+ } else {
+ if (rule.next.indexOf(prefix) !== 0)
+ rule.next = prefix + rule.next;
+ }
+
}
}
this.$rules[prefix + key] = state;
@@ -7437,7 +8313,7 @@ var TextHighlightRules = function() {
for (var key in embedRules)
states.push(prefix + key);
}
-
+
this.addRules(embedRules, prefix);
if (escapeRules) {
@@ -7449,41 +8325,103 @@ var TextHighlightRules = function() {
if (!this.$embeds)
this.$embeds = [];
this.$embeds.push(prefix);
- }
+ };
this.getEmbeds = function() {
return this.$embeds;
};
-
+
+ var pushState = function(currentState, stack) {
+ if (currentState != "start")
+ stack.unshift(this.nextState, currentState);
+ return this.nextState;
+ };
+ var popState = function(currentState, stack) {
+ if (stack[0] !== currentState)
+ return "start";
+ stack.shift();
+ return stack.shift();
+ };
+
this.normalizeRules = function() {
var id = 0;
- for (var key in this.$rules) {
- var state = this.$rules[key];
+ var rules = this.$rules;
+ function processState(key) {
+ var state = rules[key];
+ state.processed = true;
for (var i = 0; i < state.length; i++) {
var rule = state[i];
- if (rule.next && Array.isArray(rule.next)) {
- var stateName = rule.stateName || ("state" + id++);
- this.$rules[stateName] = rule.next;
+ if (!rule.regex && rule.start) {
+ rule.regex = rule.start;
+ if (!rule.next)
+ rule.next = [];
+ rule.next.push({
+ defaultToken: rule.token
+ }, {
+ token: rule.token + ".end",
+ regex: rule.end || rule.start,
+ next: "pop"
+ });
+ rule.token = rule.token + ".start";
+ rule.push = true;
+ }
+ var next = rule.next || rule.push;
+ if (next && Array.isArray(next)) {
+ var stateName = rule.stateName;
+ if (!stateName) {
+ stateName = rule.token;
+ if (typeof stateName != "string")
+ stateName = stateName[0] || "";
+ if (rules[stateName])
+ stateName += id++;
+ }
+ rules[stateName] = next;
rule.next = stateName;
+ processState(stateName);
+ } else if (next == "pop") {
+ rule.next = popState;
+ }
+
+ if (rule.push) {
+ rule.nextState = rule.next || rule.push;
+ rule.next = pushState;
+ delete rule.push;
}
+
if (rule.rules) {
- for (var r in rule.rules) {
- if (this.$rules[r]) {
- if (this.$rules[r].push)
- this.$rules[r].push.apply(this.$rules[r], rule.rules[r]);
+ for (var r in rule.rules) {
+ if (rules[r]) {
+ if (rules[r].push)
+ rules[r].push.apply(rules[r], rule.rules[r]);
} else {
- this.$rules[r] = rule.rules[r];
+ rules[r] = rule.rules[r];
}
}
}
if (rule.include || typeof rule == "string") {
- var args = [i, 1].concat(this.$rules[rule.include || rule]);
+ var includeName = rule.include || rule;
+ var toInsert = rules[includeName];
+ } else if (Array.isArray(rule))
+ toInsert = rule;
+
+ if (toInsert) {
+ var args = [i, 1].concat(toInsert);
if (rule.noEscape)
args = args.filter(function(x) {return !x.next;});
state.splice.apply(state, args);
+ i--;
+ toInsert = null
+ }
+
+ if (rule.keywordMap) {
+ rule.token = this.createKeywordMapper(
+ rule.keywordMap, rule.defaultToken || "text", rule.caseInsensitive
+ );
+ delete rule.defaultToken;
}
}
- }
+ };
+ Object.keys(rules).forEach(processState, this);
};
this.createKeywordMapper = function(map, defaultToken, ignoreCase, splitChar) {
@@ -7512,7 +8450,7 @@ var TextHighlightRules = function() {
exports.TextHighlightRules = TextHighlightRules;
});
-define('ace/mode/behaviour', ['require', 'exports', 'module' ], function(require, exports, module) {
+ace.define('ace/mode/behaviour', ['require', 'exports', 'module' ], function(require, exports, module) {
var Behaviour = function() {
@@ -7572,7 +8510,7 @@ var Behaviour = function() {
exports.Behaviour = Behaviour;
});
-define('ace/unicode', ['require', 'exports', 'module' ], function(require, exports, module) {
+ace.define('ace/unicode', ['require', 'exports', 'module' ], function(require, exports, module) {
exports.packages = {};
addUnicodePackage({
@@ -7623,7 +8561,79 @@ function addUnicodePackage (pack) {
});
-define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/range', 'ace/anchor'], function(require, exports, module) {
+ace.define('ace/token_iterator', ['require', 'exports', 'module' ], function(require, exports, module) {
+var TokenIterator = function(session, initialRow, initialColumn) {
+ this.$session = session;
+ this.$row = initialRow;
+ this.$rowTokens = session.getTokens(initialRow);
+
+ var token = session.getTokenAt(initialRow, initialColumn);
+ this.$tokenIndex = token ? token.index : -1;
+};
+
+(function() {
+ this.stepBackward = function() {
+ this.$tokenIndex -= 1;
+
+ while (this.$tokenIndex < 0) {
+ this.$row -= 1;
+ if (this.$row < 0) {
+ this.$row = 0;
+ return null;
+ }
+
+ this.$rowTokens = this.$session.getTokens(this.$row);
+ this.$tokenIndex = this.$rowTokens.length - 1;
+ }
+
+ return this.$rowTokens[this.$tokenIndex];
+ };
+ this.stepForward = function() {
+ this.$tokenIndex += 1;
+ var rowCount;
+ while (this.$tokenIndex >= this.$rowTokens.length) {
+ this.$row += 1;
+ if (!rowCount)
+ rowCount = this.$session.getLength();
+ if (this.$row >= rowCount) {
+ this.$row = rowCount - 1;
+ return null;
+ }
+
+ this.$rowTokens = this.$session.getTokens(this.$row);
+ this.$tokenIndex = 0;
+ }
+
+ return this.$rowTokens[this.$tokenIndex];
+ };
+ this.getCurrentToken = function () {
+ return this.$rowTokens[this.$tokenIndex];
+ };
+ this.getCurrentTokenRow = function () {
+ return this.$row;
+ };
+ this.getCurrentTokenColumn = function() {
+ var rowTokens = this.$rowTokens;
+ var tokenIndex = this.$tokenIndex;
+ var column = rowTokens[tokenIndex].start;
+ if (column !== undefined)
+ return column;
+
+ column = 0;
+ while (tokenIndex > 0) {
+ tokenIndex -= 1;
+ column += rowTokens[tokenIndex].value.length;
+ }
+
+ return column;
+ };
+
+}).call(TokenIterator.prototype);
+
+exports.TokenIterator = TokenIterator;
+});
+
+ace.define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/range', 'ace/anchor'], function(require, exports, module) {
var oop = require("./lib/oop");
@@ -7636,7 +8646,7 @@ var Document = function(text) {
if (text.length == 0) {
this.$lines = [""];
} else if (Array.isArray(text)) {
- this.insertLines(0, text);
+ this._insertLines(0, text);
} else {
this.insert({row: 0, column:0}, text);
}
@@ -7666,23 +8676,16 @@ var Document = function(text) {
};
-
this.$detectNewLine = function(text) {
var match = text.match(/^.*?(\r\n|\r|\n)/m);
- if (match) {
- this.$autoNewLine = match[1];
- } else {
- this.$autoNewLine = "\n";
- }
+ this.$autoNewLine = match ? match[1] : "\n";
};
this.getNewLineCharacter = function() {
switch (this.$newLineMode) {
case "windows":
return "\r\n";
-
case "unix":
return "\n";
-
default:
return this.$autoNewLine;
}
@@ -7716,15 +8719,15 @@ var Document = function(text) {
};
this.getTextRange = function(range) {
if (range.start.row == range.end.row) {
- return this.$lines[range.start.row].substring(range.start.column,
- range.end.column);
- }
- else {
- var lines = this.getLines(range.start.row+1, range.end.row-1);
- lines.unshift((this.$lines[range.start.row] || "").substring(range.start.column));
- lines.push((this.$lines[range.end.row] || "").substring(0, range.end.column));
- return lines.join(this.getNewLineCharacter());
+ return this.getLine(range.start.row)
+ .substring(range.start.column, range.end.column);
}
+ var lines = this.getLines(range.start.row, range.end.row);
+ lines[0] = (lines[0] || "").substring(range.start.column);
+ var l = lines.length - 1;
+ if (range.end.row - range.start.row == l)
+ lines[l] = lines[l].substring(0, range.end.column);
+ return lines.join(this.getNewLineCharacter());
};
this.$clipPosition = function(position) {
@@ -7732,7 +8735,8 @@ var Document = function(text) {
if (position.row >= length) {
position.row = Math.max(0, length - 1);
position.column = this.getLine(length-1).length;
- }
+ } else if (position.row < 0)
+ position.row = 0;
return position;
};
this.insert = function(position, text) {
@@ -7750,16 +8754,21 @@ var Document = function(text) {
position = this.insertInLine(position, firstLine);
if (lastLine !== null) {
position = this.insertNewLine(position); // terminate first line
- position = this.insertLines(position.row, lines);
+ position = this._insertLines(position.row, lines);
position = this.insertInLine(position, lastLine || "");
}
return position;
};
this.insertLines = function(row, lines) {
+ if (row >= this.getLength())
+ return this.insert({row: row, column: 0}, "\n" + lines.join("\n"));
+ return this._insertLines(Math.max(row, 0), lines);
+ };
+ this._insertLines = function(row, lines) {
if (lines.length == 0)
return {row: row, column: 0};
if (lines.length > 0xFFFF) {
- var end = this.insertLines(row, lines.slice(0xFFFF));
+ var end = this._insertLines(row, lines.slice(0xFFFF));
lines = lines.slice(0, 0xFFFF);
}
@@ -7838,7 +8847,7 @@ var Document = function(text) {
this.removeInLine(lastRow, 0, range.end.column);
if (lastFullRow >= firstFullRow)
- this.removeLines(firstFullRow, lastFullRow);
+ this._removeLines(firstFullRow, lastFullRow);
if (firstFullRow != firstRow) {
this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
@@ -7869,6 +8878,12 @@ var Document = function(text) {
return range.start;
};
this.removeLines = function(firstRow, lastRow) {
+ if (firstRow < 0 || lastRow >= this.getLength())
+ return this.remove(new Range(firstRow, 0, lastRow + 1, 0));
+ return this._removeLines(firstRow, lastRow);
+ };
+
+ this._removeLines = function(firstRow, lastRow) {
var range = new Range(firstRow, 0, lastRow + 1, 0);
var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
@@ -7923,7 +8938,7 @@ var Document = function(text) {
else if (delta.action == "insertText")
this.insert(range.start, delta.text);
else if (delta.action == "removeLines")
- this.removeLines(range.start.row, range.end.row - 1);
+ this._removeLines(range.start.row, range.end.row - 1);
else if (delta.action == "removeText")
this.remove(range);
}
@@ -7935,11 +8950,11 @@ var Document = function(text) {
var range = Range.fromPoints(delta.range.start, delta.range.end);
if (delta.action == "insertLines")
- this.removeLines(range.start.row, range.end.row - 1);
+ this._removeLines(range.start.row, range.end.row - 1);
else if (delta.action == "insertText")
this.remove(range);
else if (delta.action == "removeLines")
- this.insertLines(range.start.row, delta.lines);
+ this._insertLines(range.start.row, delta.lines);
else if (delta.action == "removeText")
this.insert(range.start, delta.text);
}
@@ -7960,9 +8975,9 @@ var Document = function(text) {
var index = 0;
var row = Math.min(pos.row, lines.length);
for (var i = startRow || 0; i < row; ++i)
- index += lines[i].length;
+ index += lines[i].length + newlineLength;
- return index + newlineLength * i + pos.column;
+ return index + pos.column;
};
}).call(Document.prototype);
@@ -7970,93 +8985,85 @@ var Document = function(text) {
exports.Document = Document;
});
-define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
+ace.define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var Anchor = exports.Anchor = function(doc, row, column) {
- this.document = doc;
+ this.$onChange = this.onChange.bind(this);
+ this.attach(doc);
if (typeof column == "undefined")
this.setPosition(row.row, row.column);
else
this.setPosition(row, column);
-
- this.$onChange = this.onChange.bind(this);
- doc.on("change", this.$onChange);
};
(function() {
oop.implement(this, EventEmitter);
-
this.getPosition = function() {
return this.$clipPositionToDocument(this.row, this.column);
};
-
this.getDocument = function() {
return this.document;
};
-
this.onChange = function(e) {
var delta = e.data;
var range = delta.range;
-
+
if (range.start.row == range.end.row && range.start.row != this.row)
return;
-
+
if (range.start.row > this.row)
return;
-
+
if (range.start.row == this.row && range.start.column > this.column)
return;
-
+
var row = this.row;
var column = this.column;
-
+ var start = range.start;
+ var end = range.end;
+
if (delta.action === "insertText") {
- if (range.start.row === row && range.start.column <= column) {
- if (range.start.row === range.end.row) {
- column += range.end.column - range.start.column;
- }
- else {
- column -= range.start.column;
- row += range.end.row - range.start.row;
+ if (start.row === row && start.column <= column) {
+ if (start.row === end.row) {
+ column += end.column - start.column;
+ } else {
+ column -= start.column;
+ row += end.row - start.row;
}
- }
- else if (range.start.row !== range.end.row && range.start.row < row) {
- row += range.end.row - range.start.row;
+ } else if (start.row !== end.row && start.row < row) {
+ row += end.row - start.row;
}
} else if (delta.action === "insertLines") {
- if (range.start.row <= row) {
- row += range.end.row - range.start.row;
+ if (start.row <= row) {
+ row += end.row - start.row;
}
- }
- else if (delta.action == "removeText") {
- if (range.start.row == row && range.start.column < column) {
- if (range.end.column >= column)
- column = range.start.column;
+ } else if (delta.action === "removeText") {
+ if (start.row === row && start.column < column) {
+ if (end.column >= column)
+ column = start.column;
else
- column = Math.max(0, column - (range.end.column - range.start.column));
-
- } else if (range.start.row !== range.end.row && range.start.row < row) {
- if (range.end.row == row) {
- column = Math.max(0, column - range.end.column) + range.start.column;
- }
- row -= (range.end.row - range.start.row);
- }
- else if (range.end.row == row) {
- row -= range.end.row - range.start.row;
- column = Math.max(0, column - range.end.column) + range.start.column;
+ column = Math.max(0, column - (end.column - start.column));
+
+ } else if (start.row !== end.row && start.row < row) {
+ if (end.row === row)
+ column = Math.max(0, column - end.column) + start.column;
+ row -= (end.row - start.row);
+ } else if (end.row === row) {
+ row -= end.row - start.row;
+ column = Math.max(0, column - end.column) + start.column;
}
} else if (delta.action == "removeLines") {
- if (range.start.row <= row) {
- if (range.end.row <= row)
- row -= range.end.row - range.start.row;
+ if (start.row <= row) {
+ if (end.row <= row)
+ row -= end.row - start.row;
else {
- row = range.start.row;
+ row = start.row;
column = 0;
}
}
@@ -8064,7 +9071,6 @@ var Anchor = exports.Anchor = function(doc, row, column) {
this.setPosition(row, column, true);
};
-
this.setPosition = function(row, column, noClip) {
var pos;
if (noClip) {
@@ -8072,19 +9078,18 @@ var Anchor = exports.Anchor = function(doc, row, column) {
row: row,
column: column
};
- }
- else {
+ } else {
pos = this.$clipPositionToDocument(row, column);
}
-
+
if (this.row == pos.row && this.column == pos.column)
return;
-
+
var old = {
row: this.row,
column: this.column
};
-
+
this.row = pos.row;
this.column = pos.column;
this._emit("change", {
@@ -8092,13 +9097,16 @@ var Anchor = exports.Anchor = function(doc, row, column) {
value: pos
});
};
-
this.detach = function() {
this.document.removeEventListener("change", this.$onChange);
};
+ this.attach = function(doc) {
+ this.document = doc || this.document;
+ this.document.on("change", this.$onChange);
+ };
this.$clipPositionToDocument = function(row, column) {
var pos = {};
-
+
if (row >= this.document.getLength()) {
pos.row = Math.max(0, this.document.getLength() - 1);
pos.column = this.document.getLine(pos.row).length;
@@ -8111,23 +9119,22 @@ var Anchor = exports.Anchor = function(doc, row, column) {
pos.row = row;
pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
}
-
+
if (column < 0)
pos.column = 0;
-
+
return pos;
};
-
+
}).call(Anchor.prototype);
});
-define('ace/background_tokenizer', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
+ace.define('ace/background_tokenizer', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
-var MAX_LINE_LENGTH = 5000;
var BackgroundTokenizer = function(tokenizer, editor) {
this.running = false;
@@ -8142,27 +9149,35 @@ var BackgroundTokenizer = function(tokenizer, editor) {
if (!self.running) { return; }
var workerStart = new Date();
- var startLine = self.currentLine;
+ var currentLine = self.currentLine;
+ var endLine = -1;
var doc = self.doc;
- var processedLines = 0;
+ while (self.lines[currentLine])
+ currentLine++;
+
+ var startLine = currentLine;
var len = doc.getLength();
- while (self.currentLine < len) {
- self.$tokenizeRow(self.currentLine);
- while (self.lines[self.currentLine])
- self.currentLine++;
+ var processedLines = 0;
+ self.running = false;
+ while (currentLine < len) {
+ self.$tokenizeRow(currentLine);
+ endLine = currentLine;
+ do {
+ currentLine++;
+ } while (self.lines[currentLine]);
processedLines ++;
- if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) {
- self.fireUpdateEvent(startLine, self.currentLine-1);
+ if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) {
self.running = setTimeout(self.$worker, 20);
+ self.currentLine = currentLine;
return;
}
}
-
- self.running = false;
-
- self.fireUpdateEvent(startLine, len - 1);
+ self.currentLine = currentLine;
+
+ if (startLine <= endLine)
+ self.fireUpdateEvent(startLine, endLine);
};
};
@@ -8239,15 +9254,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
var line = this.doc.getLine(row);
var state = this.states[row - 1];
- if (line.length > MAX_LINE_LENGTH) {
- var overflow = {value: line.substr(MAX_LINE_LENGTH), type: "text"};
- line = line.slice(0, MAX_LINE_LENGTH);
- }
- var data = this.tokenizer.getLineTokens(line, state);
- if (overflow) {
- data.tokens.push(overflow);
- data.state = "start";
- }
+ var data = this.tokenizer.getLineTokens(line, state, row);
if (this.states[row] + "" !== data.state + "") {
this.states[row] = data.state;
@@ -8266,7 +9273,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
exports.BackgroundTokenizer = BackgroundTokenizer;
});
-define('ace/search_highlight', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/lib/oop', 'ace/range'], function(require, exports, module) {
+ace.define('ace/search_highlight', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/lib/oop', 'ace/range'], function(require, exports, module) {
var lang = require("./lib/lang");
@@ -8308,9 +9315,7 @@ var SearchHighlight = function(regExp, clazz, type) {
for (var j = ranges.length; j --; ) {
markerLayer.drawSingleLineMarker(
- html, ranges[j].toScreenRange(session), this.clazz, config,
- null, this.type
- );
+ html, ranges[j].toScreenRange(session), this.clazz, config);
}
}
};
@@ -8320,7 +9325,7 @@ var SearchHighlight = function(regExp, clazz, type) {
exports.SearchHighlight = SearchHighlight;
});
-define('ace/edit_session/folding', ['require', 'exports', 'module' , 'ace/range', 'ace/edit_session/fold_line', 'ace/edit_session/fold', 'ace/token_iterator'], function(require, exports, module) {
+ace.define('ace/edit_session/folding', ['require', 'exports', 'module' , 'ace/range', 'ace/edit_session/fold_line', 'ace/edit_session/fold', 'ace/token_iterator'], function(require, exports, module) {
var Range = require("../range").Range;
@@ -8348,7 +9353,6 @@ function Folding() {
}
};
this.getFoldsInRange = function(range) {
- range = range.clone();
var start = range.start;
var end = range.end;
var foldLines = this.$foldData;
@@ -8381,6 +9385,9 @@ function Folding() {
foundFolds.push(fold);
}
}
+ start.column -= 1;
+ end.column += 1;
+
return foundFolds;
};
this.getAllFolds = function() {
@@ -8389,11 +9396,6 @@ function Folding() {
function addFold(fold) {
folds.push(fold);
- if (!fold.subFolds)
- return;
-
- for (var i = 0; i < fold.subFolds.length; i++)
- addFold(fold.subFolds[i]);
}
for (var i = 0; i < foldLines.length; i++)
@@ -8507,9 +9509,10 @@ function Folding() {
if (placeholder instanceof Fold)
fold = placeholder;
- else
+ else {
fold = new Fold(range, placeholder);
-
+ fold.collapseChildren = range.collapseChildren;
+ }
this.$clipRangeToDocument(fold.range);
var startRow = fold.start.row;
@@ -8533,7 +9536,9 @@ function Folding() {
var folds = this.getFoldsInRange(fold.range);
if (folds.length > 0) {
this.removeFolds(folds);
- fold.subFolds = folds;
+ folds.forEach(function(subFold) {
+ fold.addSubFold(subFold);
+ });
}
for (var i = 0; i < foldData.length; i++) {
@@ -8542,8 +9547,7 @@ function Folding() {
foldLine.addFold(fold);
added = true;
break;
- }
- else if (startRow == foldLine.end.row) {
+ } else if (startRow == foldLine.end.row) {
foldLine.addFold(fold);
added = true;
if (!fold.sameRow) {
@@ -8554,8 +9558,7 @@ function Folding() {
}
}
break;
- }
- else if (endRow <= foldLine.start.row) {
+ } else if (endRow <= foldLine.start.row) {
break;
}
}
@@ -8568,7 +9571,7 @@ function Folding() {
else
this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row);
this.$modified = true;
- this._emit("changeFold", { data: fold });
+ this._emit("changeFold", { data: fold, action: "add" });
return fold;
};
@@ -8610,12 +9613,14 @@ function Folding() {
newFoldLine.start.column = folds[0].start.column;
}
- if (this.$useWrapMode)
- this.$updateWrapData(startRow, endRow);
- else
- this.$updateRowLengthCache(startRow, endRow);
+ if (!this.$updating) {
+ if (this.$useWrapMode)
+ this.$updateWrapData(startRow, endRow);
+ else
+ this.$updateRowLengthCache(startRow, endRow);
+ }
this.$modified = true;
- this._emit("changeFold", { data: fold });
+ this._emit("changeFold", { data: fold, action: "remove" });
};
this.removeFolds = function(folds) {
@@ -8631,10 +9636,14 @@ function Folding() {
};
this.expandFold = function(fold) {
- this.removeFold(fold);
- fold.subFolds.forEach(function(fold) {
- this.addFold(fold);
+ this.removeFold(fold);
+ fold.subFolds.forEach(function(subFold) {
+ fold.restoreRange(subFold);
+ this.addFold(subFold);
}, this);
+ if (fold.collapseChildren > 0) {
+ this.foldAll(fold.start.row+1, fold.end.row, fold.collapseChildren-1);
+ }
fold.subFolds = [];
};
@@ -8646,9 +9655,10 @@ function Folding() {
this.unfold = function(location, expandInner) {
var range, folds;
- if (location == null)
+ if (location == null) {
range = new Range(0, 0, this.getLength(), 0);
- else if (typeof location == "number")
+ expandInner = true;
+ } else if (typeof location == "number")
range = new Range(location, 0, location, this.getLine(location).length);
else if ("row" in location)
range = Range.fromPoints(location, location);
@@ -8674,6 +9684,11 @@ function Folding() {
return foldLine ? foldLine.end.row : docRow;
};
+ this.getRowFoldStart = function(docRow, startFoldRow) {
+ var foldLine = this.getFoldLine(docRow, startFoldRow);
+ return foldLine ? foldLine.start.row : docRow;
+ };
+
this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
if (startRow == null) {
startRow = foldLine.start.row;
@@ -8688,20 +9703,20 @@ function Folding() {
var textLine = "";
foldLine.walk(function(placeholder, row, column, lastColumn) {
- if (row < startRow) {
+ if (row < startRow)
return;
- } else if (row == startRow) {
- if (column < startColumn) {
+ if (row == startRow) {
+ if (column < startColumn)
return;
- }
lastColumn = Math.max(startColumn, lastColumn);
}
+
if (placeholder != null) {
textLine += placeholder;
} else {
textLine += doc.getLine(row).substring(lastColumn, column);
}
- }.bind(this), endRow, endColumn);
+ }, endRow, endColumn);
return textLine;
};
@@ -8743,26 +9758,22 @@ function Folding() {
if (fold) {
this.expandFold(fold);
return;
- }
- else if (bracketPos = this.findMatchingBracket(cursor)) {
+ } else if (bracketPos = this.findMatchingBracket(cursor)) {
if (range.comparePoint(bracketPos) == 1) {
range.end = bracketPos;
- }
- else {
+ } else {
range.start = bracketPos;
range.start.column++;
range.end.column--;
}
- }
- else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
+ } else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
if (range.comparePoint(bracketPos) == 1)
range.end = bracketPos;
else
range.start = bracketPos;
range.start.column++;
- }
- else {
+ } else {
range = this.getCommentFoldRange(cursor.row, cursor.column) || range;
}
} else {
@@ -8770,8 +9781,7 @@ function Folding() {
if (tryToUnfold && folds.length) {
this.expandFolds(folds);
return;
- }
- else if (folds.length == 1 ) {
+ } else if (folds.length == 1 ) {
fold = folds[0];
}
}
@@ -8827,7 +9837,9 @@ function Folding() {
}
};
- this.foldAll = function(startRow, endRow) {
+ this.foldAll = function(startRow, endRow, depth) {
+ if (depth == undefined)
+ depth = 100000; // JSON.stringify doesn't hanle Infinity
var foldWidgets = this.foldWidgets;
endRow = endRow || this.getLength();
for (var row = startRow || 0; row < endRow; row++) {
@@ -8838,11 +9850,12 @@ function Folding() {
var range = this.getFoldWidgetRange(row);
if (range && range.end.row <= endRow) try {
- this.addFold("...", range);
+ var fold = this.addFold("...", range);
+ fold.collapseChildren = depth;
+ row = range.end.row;
} catch(e) {}
}
};
-
this.$foldStyles = {
"manual": 1,
"markbegin": 1,
@@ -8864,6 +9877,7 @@ function Folding() {
this.$setFolding(null);
this.$setFolding(mode);
};
+
this.$setFolding = function(foldMode) {
if (this.$foldMode == foldMode)
return;
@@ -8887,21 +9901,46 @@ function Folding() {
};
+ this.getParentFoldRangeData = function (row, ignoreCurrent) {
+ var fw = this.foldWidgets;
+ if (!fw || (ignoreCurrent && fw[row]))
+ return {};
+
+ var i = row - 1, firstRange;
+ while (i >= 0) {
+ var c = fw[i];
+ if (c == null)
+ c = fw[i] = this.getFoldWidget(i);
+
+ if (c == "start") {
+ var range = this.getFoldWidgetRange(i);
+ if (!firstRange)
+ firstRange = range;
+ if (range && range.end.row >= row)
+ break;
+ }
+ i--;
+ }
+
+ return {
+ range: i !== -1 && range,
+ firstRange: firstRange
+ };
+ }
+
this.onFoldWidgetClick = function(row, e) {
- e = e.domEvent;
var type = this.getFoldWidget(row);
var line = this.getLine(row);
- var onlySubfolds = e.shiftKey;
- var addSubfolds = onlySubfolds || e.ctrlKey || e.altKey || e.metaKey;
- var fold;
+ e = e.domEvent;
+ var children = e.shiftKey;
+ var all = e.ctrlKey || e.metaKey;
+ var siblings = e.altKey;
- if (type == "end")
- fold = this.getFoldAt(row, 0, -1);
- else
- fold = this.getFoldAt(row, line.length, 1);
+ var dir = type === "end" ? -1 : 1;
+ var fold = this.getFoldAt(row, dir === -1 ? 0 : line.length, dir);
if (fold) {
- if (addSubfolds)
+ if (children || all)
this.removeFold(fold);
else
this.expandFold(fold);
@@ -8909,27 +9948,34 @@ function Folding() {
}
var range = this.getFoldWidgetRange(row);
- if (range) {
- if (!range.isMultiLine()) {
- fold = this.getFoldAt(range.start.row, range.start.column, 1);
- if (fold && range.isEqual(fold.range)) {
- this.removeFold(fold);
- return;
- }
+ if (range && !range.isMultiLine()) {
+ fold = this.getFoldAt(range.start.row, range.start.column, 1);
+ if (fold && range.isEqual(fold.range)) {
+ this.removeFold(fold);
+ return;
}
-
- if (!onlySubfolds)
- this.addFold("...", range);
-
- if (addSubfolds)
- this.foldAll(range.start.row + 1, range.end.row);
- } else {
- if (addSubfolds)
- this.foldAll(row + 1, this.getLength());
- (e.target || e.srcElement).className += " ace_invalid"
}
+
+ if (siblings) {
+ var data = this.getParentFoldRangeData(row);
+ if (data.range) {
+ var startRow = data.range.start.row + 1;
+ var endRow = data.range.end.row;
+ }
+ this.foldAll(startRow, endRow, all ? 10000 : 0);
+ } else if (children) {
+ var endRow = range ? range.end.row : this.getLength();
+ this.foldAll(row + 1, range.end.row, all ? 10000 : 0);
+ } else if (range) {
+ if (all)
+ range.collapseChildren = 10000;
+ this.addFold("...", range);
+ }
+
+ if (!range)
+ (e.target || e.srcElement).className += " ace_invalid"
};
-
+
this.updateFoldWidgets = function(e) {
var delta = e.data;
var range = delta.range;
@@ -8953,7 +9999,7 @@ exports.Folding = Folding;
});
-define('ace/edit_session/fold_line', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
+ace.define('ace/edit_session/fold_line', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
var Range = require("../range").Range;
@@ -9101,13 +10147,13 @@ function FoldLine(foldData, folds) {
}
this.split = function(row, column) {
- var fold = this.getNextFoldTo(row, column).fold,
- folds = this.folds;
+ var fold = this.getNextFoldTo(row, column).fold;
+ var folds = this.folds;
var foldData = this.foldData;
- if (!fold) {
+ if (!fold)
return null;
- }
+
var i = folds.indexOf(fold);
var foldBefore = folds[i - 1];
this.end.row = foldBefore.end.row;
@@ -9171,7 +10217,12 @@ function FoldLine(foldData, folds) {
exports.FoldLine = FoldLine;
});
-define('ace/edit_session/fold', ['require', 'exports', 'module' ], function(require, exports, module) {
+ace.define('ace/edit_session/fold', ['require', 'exports', 'module' , 'ace/range', 'ace/range_list', 'ace/lib/oop'], function(require, exports, module) {
+
+
+var Range = require("../range").Range;
+var RangeList = require("../range_list").RangeList;
+var oop = require("../lib/oop")
var Fold = exports.Fold = function(range, placeholder) {
this.foldLine = null;
this.placeholder = placeholder;
@@ -9180,9 +10231,11 @@ var Fold = exports.Fold = function(range, placeholder) {
this.end = range.end;
this.sameRow = range.start.row == range.end.row;
- this.subFolds = [];
+ this.subFolds = this.ranges = [];
};
+oop.inherits(Fold, RangeList);
+
(function() {
this.toString = function() {
@@ -9202,17 +10255,19 @@ var Fold = exports.Fold = function(range, placeholder) {
this.subFolds.forEach(function(subFold) {
fold.subFolds.push(subFold.clone());
});
+ fold.collapseChildren = this.collapseChildren;
return fold;
};
this.addSubFold = function(fold) {
if (this.range.isEqual(fold))
- return this;
+ return;
if (!this.range.containsRange(fold))
throw "A fold can't intersect already existing fold" + fold.range + this.range;
+ consumeRange(fold, this.start);
- var row = fold.range.start.row, column = fold.range.start.column;
+ var row = fold.start.row, column = fold.start.column;
for (var i = 0, cmp = -1; i < this.subFolds.length; i++) {
cmp = this.subFolds[i].range.compare(row, column);
if (cmp != 1)
@@ -9238,83 +10293,237 @@ var Fold = exports.Fold = function(range, placeholder) {
return fold;
};
+
+ this.restoreRange = function(range) {
+ return restoreRange(range, this.start);
+ };
}).call(Fold.prototype);
+function consumePoint(point, anchor) {
+ point.row -= anchor.row;
+ if (point.row == 0)
+ point.column -= anchor.column;
+}
+function consumeRange(range, anchor) {
+ consumePoint(range.start, anchor);
+ consumePoint(range.end, anchor);
+}
+function restorePoint(point, anchor) {
+ if (point.row == 0)
+ point.column += anchor.column;
+ point.row += anchor.row;
+}
+function restoreRange(range, anchor) {
+ restorePoint(range.start, anchor);
+ restorePoint(range.end, anchor);
+}
+
});
-define('ace/token_iterator', ['require', 'exports', 'module' ], function(require, exports, module) {
-var TokenIterator = function(session, initialRow, initialColumn) {
- this.$session = session;
- this.$row = initialRow;
- this.$rowTokens = session.getTokens(initialRow);
+ace.define('ace/range_list', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
- var token = session.getTokenAt(initialRow, initialColumn);
- this.$tokenIndex = token ? token.index : -1;
+var Range = require("./range").Range;
+var comparePoints = Range.comparePoints;
+
+var RangeList = function() {
+ this.ranges = [];
};
-(function() {
- this.stepBackward = function() {
- this.$tokenIndex -= 1;
+(function() {
+ this.comparePoints = comparePoints;
+
+ this.pointIndex = function(pos, excludeEdges, startIndex) {
+ var list = this.ranges;
+
+ for (var i = startIndex || 0; i < list.length; i++) {
+ var range = list[i];
+ var cmpEnd = comparePoints(pos, range.end);
+ if (cmpEnd > 0)
+ continue;
+ var cmpStart = comparePoints(pos, range.start);
+ if (cmpEnd === 0)
+ return excludeEdges && cmpStart !== 0 ? -i-2 : i;
+ if (cmpStart > 0 || (cmpStart === 0 && !excludeEdges))
+ return i;
+
+ return -i-1;
+ }
+ return -i - 1;
+ };
+
+ this.add = function(range) {
+ var excludeEdges = !range.isEmpty();
+ var startIndex = this.pointIndex(range.start, excludeEdges);
+ if (startIndex < 0)
+ startIndex = -startIndex - 1;
+
+ var endIndex = this.pointIndex(range.end, excludeEdges, startIndex);
+
+ if (endIndex < 0)
+ endIndex = -endIndex - 1;
+ else
+ endIndex++;
+ return this.ranges.splice(startIndex, endIndex - startIndex, range);
+ };
+
+ this.addList = function(list) {
+ var removed = [];
+ for (var i = list.length; i--; ) {
+ removed.push.call(removed, this.add(list[i]));
+ }
+ return removed;
+ };
+
+ this.substractPoint = function(pos) {
+ var i = this.pointIndex(pos);
+
+ if (i >= 0)
+ return this.ranges.splice(i, 1);
+ };
+ this.merge = function() {
+ var removed = [];
+ var list = this.ranges;
- while (this.$tokenIndex < 0) {
- this.$row -= 1;
- if (this.$row < 0) {
- this.$row = 0;
- return null;
+ list = list.sort(function(a, b) {
+ return comparePoints(a.start, b.start);
+ });
+
+ var next = list[0], range;
+ for (var i = 1; i < list.length; i++) {
+ range = next;
+ next = list[i];
+ var cmp = comparePoints(range.end, next.start);
+ if (cmp < 0)
+ continue;
+
+ if (cmp == 0 && !range.isEmpty() && !next.isEmpty())
+ continue;
+
+ if (comparePoints(range.end, next.end) < 0) {
+ range.end.row = next.end.row;
+ range.end.column = next.end.column;
}
-
- this.$rowTokens = this.$session.getTokens(this.$row);
- this.$tokenIndex = this.$rowTokens.length - 1;
+
+ list.splice(i, 1);
+ removed.push(next);
+ next = range;
+ i--;
}
-
- return this.$rowTokens[this.$tokenIndex];
- };
- this.stepForward = function() {
- var rowCount = this.$session.getLength();
- this.$tokenIndex += 1;
- while (this.$tokenIndex >= this.$rowTokens.length) {
- this.$row += 1;
- if (this.$row >= rowCount) {
- this.$row = rowCount - 1;
- return null;
- }
+ this.ranges = list;
- this.$rowTokens = this.$session.getTokens(this.$row);
- this.$tokenIndex = 0;
+ return removed;
+ };
+
+ this.contains = function(row, column) {
+ return this.pointIndex({row: row, column: column}) >= 0;
+ };
+
+ this.containsPoint = function(pos) {
+ return this.pointIndex(pos) >= 0;
+ };
+
+ this.rangeAtPoint = function(pos) {
+ var i = this.pointIndex(pos);
+ if (i >= 0)
+ return this.ranges[i];
+ };
+
+
+ this.clipRows = function(startRow, endRow) {
+ var list = this.ranges;
+ if (list[0].start.row > endRow || list[list.length - 1].start.row < startRow)
+ return [];
+
+ var startIndex = this.pointIndex({row: startRow, column: 0});
+ if (startIndex < 0)
+ startIndex = -startIndex - 1;
+ var endIndex = this.pointIndex({row: endRow, column: 0}, startIndex);
+ if (endIndex < 0)
+ endIndex = -endIndex - 1;
+
+ var clipped = [];
+ for (var i = startIndex; i < endIndex; i++) {
+ clipped.push(list[i]);
}
-
- return this.$rowTokens[this.$tokenIndex];
- };
- this.getCurrentToken = function () {
- return this.$rowTokens[this.$tokenIndex];
- };
- this.getCurrentTokenRow = function () {
- return this.$row;
- };
- this.getCurrentTokenColumn = function() {
- var rowTokens = this.$rowTokens;
- var tokenIndex = this.$tokenIndex;
- var column = rowTokens[tokenIndex].start;
- if (column !== undefined)
- return column;
-
- column = 0;
- while (tokenIndex > 0) {
- tokenIndex -= 1;
- column += rowTokens[tokenIndex].value.length;
+ return clipped;
+ };
+
+ this.removeAll = function() {
+ return this.ranges.splice(0, this.ranges.length);
+ };
+
+ this.attach = function(session) {
+ if (this.session)
+ this.detach();
+
+ this.session = session;
+ this.onChange = this.$onChange.bind(this);
+
+ this.session.on('change', this.onChange);
+ };
+
+ this.detach = function() {
+ if (!this.session)
+ return;
+ this.session.removeListener('change', this.onChange);
+ this.session = null;
+ };
+
+ this.$onChange = function(e) {
+ var changeRange = e.data.range;
+ if (e.data.action[0] == "i"){
+ var start = changeRange.start;
+ var end = changeRange.end;
+ } else {
+ var end = changeRange.start;
+ var start = changeRange.end;
+ }
+ var startRow = start.row;
+ var endRow = end.row;
+ var lineDif = endRow - startRow;
+
+ var colDiff = -start.column + end.column;
+ var ranges = this.ranges;
+
+ for (var i = 0, n = ranges.length; i < n; i++) {
+ var r = ranges[i];
+ if (r.end.row < startRow)
+ continue;
+ if (r.start.row > startRow)
+ break;
+
+ if (r.start.row == startRow && r.start.column >= start.column ) {
+
+ r.start.column += colDiff;
+ r.start.row += lineDif;
+ }
+ if (r.end.row == startRow && r.end.column >= start.column) {
+ if (r.end.column == start.column && colDiff > 0 && i < n - 1) {
+ if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column)
+ r.end.column -= colDiff;
+ }
+ r.end.column += colDiff;
+ r.end.row += lineDif;
+ }
+ }
+
+ if (lineDif != 0 && i < n) {
+ for (; i < n; i++) {
+ var r = ranges[i];
+ r.start.row += lineDif;
+ r.end.row += lineDif;
+ }
}
-
- return column;
};
-
-}).call(TokenIterator.prototype);
-exports.TokenIterator = TokenIterator;
+}).call(RangeList.prototype);
+
+exports.RangeList = RangeList;
});
-define('ace/edit_session/bracket_match', ['require', 'exports', 'module' , 'ace/token_iterator', 'ace/range'], function(require, exports, module) {
+ace.define('ace/edit_session/bracket_match', ['require', 'exports', 'module' , 'ace/token_iterator', 'ace/range'], function(require, exports, module) {
var TokenIterator = require("../token_iterator").TokenIterator;
@@ -9323,10 +10532,10 @@ var Range = require("../range").Range;
function BracketMatch() {
- this.findMatchingBracket = function(position, char) {
+ this.findMatchingBracket = function(position, chr) {
if (position.column == 0) return null;
- var charBeforeCursor = char || this.getLine(position.row).charAt(position.column-1);
+ var charBeforeCursor = chr || this.getLine(position.row).charAt(position.column-1);
if (charBeforeCursor == "") return null;
var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
@@ -9494,7 +10703,7 @@ exports.BracketMatch = BracketMatch;
});
-define('ace/search', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/lib/oop', 'ace/range'], function(require, exports, module) {
+ace.define('ace/search', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/lib/oop', 'ace/range'], function(require, exports, module) {
var lang = require("./lib/lang");
@@ -9584,7 +10793,12 @@ var Search = function() {
while (i < j && ranges[j].end.column > endColumn && ranges[j].end.row == range.end.row)
j--;
- return ranges.slice(i, j + 1);
+
+ ranges = ranges.slice(i, j + 1);
+ for (i = 0, j = ranges.length; i < j; i++) {
+ ranges[i].start.row += range.start.row;
+ ranges[i].end.row += range.start.row;
+ }
}
return ranges;
@@ -9674,7 +10888,7 @@ var Search = function() {
};
};
- this.$assembleRegExp = function(options) {
+ this.$assembleRegExp = function(options, $disableFakeMultiline) {
if (options.needle instanceof RegExp)
return options.re = options.needle;
@@ -9691,7 +10905,7 @@ var Search = function() {
var modifier = options.caseSensitive ? "g" : "gi";
- options.$isMultiLine = /[\n\r]/.test(needle);
+ options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle);
if (options.$isMultiLine)
return options.re = this.$assembleMultilineRegExp(needle, modifier);
@@ -9778,7 +10992,7 @@ var Search = function() {
exports.Search = Search;
});
-define('ace/commands/command_manager', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/keyboard/hash_handler', 'ace/lib/event_emitter'], function(require, exports, module) {
+ace.define('ace/commands/command_manager', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/keyboard/hash_handler', 'ace/lib/event_emitter'], function(require, exports, module) {
var oop = require("../lib/oop");
@@ -9791,7 +11005,7 @@ var CommandManager = function(platform, commands) {
this.commmandKeyBinding = {};
this.addCommands(commands);
-
+
this.setDefaultHandler("exec", function(e) {
return e.command.exec(e.editor, e.args || {});
});
@@ -9813,11 +11027,9 @@ oop.inherits(CommandManager, HashHandler);
if (editor && editor.$readOnly && !command.readOnly)
return false;
- var retvalue = this._emit("exec", {
- editor: editor,
- command: command,
- args: args
- });
+ var e = {editor: editor, command: command, args: args};
+ var retvalue = this._emit("exec", e);
+ this._signal("afterExec", e);
return retvalue === false ? false : true;
};
@@ -9884,13 +11096,14 @@ exports.CommandManager = CommandManager;
});
-define('ace/keyboard/hash_handler', ['require', 'exports', 'module' , 'ace/lib/keys'], function(require, exports, module) {
+ace.define('ace/keyboard/hash_handler', ['require', 'exports', 'module' , 'ace/lib/keys', 'ace/lib/useragent'], function(require, exports, module) {
-var keyUtil = require("../lib/keys");
+var keyUtil = require("../lib/keys");
+var useragent = require("../lib/useragent");
function HashHandler(config, platform) {
- this.platform = platform;
+ this.platform = platform || (useragent.isMac ? "mac" : "win");
this.commands = {};
this.commmandKeyBinding = {};
@@ -9926,7 +11139,7 @@ function HashHandler(config, platform) {
if(!key)
return;
if (typeof command == "function") {
- this.addCommand({exec: command, bindKey: key, name: key});
+ this.addCommand({exec: command, bindKey: key, name: command.name || key});
return;
}
@@ -9975,6 +11188,9 @@ function HashHandler(config, platform) {
this.bindKey(key, command);
};
this.parseKeys = function(keys) {
+ if (keys.indexOf(" ") != -1)
+ keys = keys.split(/\s+/).pop();
+
var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x});
var key = parts.pop();
@@ -9989,8 +11205,11 @@ function HashHandler(config, platform) {
var hashId = 0;
for (var i = parts.length; i--;) {
var modifier = keyUtil.KEY_MODS[parts[i]];
- if (modifier == null)
- throw "invalid modifier " + parts[i] + " in " + keys;
+ if (modifier == null) {
+ if (typeof console != "undefined")
+ console.error("invalid modifier " + parts[i] + " in " + keys);
+ return false;
+ }
hashId |= modifier;
}
return {key: key, hashId: hashId};
@@ -10012,487 +11231,534 @@ function HashHandler(config, platform) {
exports.HashHandler = HashHandler;
});
-define('ace/autocomplete', ['require', 'exports', 'module' , 'ace/edit_session', 'ace/virtual_renderer', 'ace/range', 'ace/lib/event', 'ace/token_iterator', 'ace/lib/dom', 'ace/keyboard/hash_handler', 'ace/mode/text', 'ace/worker/worker_client'], function(require, exports, module) {
+ace.define('ace/commands/default_commands', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/config'], function(require, exports, module) {
-var EditSession = require("./edit_session").EditSession;
-var Renderer = require("./virtual_renderer").VirtualRenderer;
-var Range = require("./range").Range;
-var event = require("./lib/event");
-var TokenIterator = require("./token_iterator").TokenIterator;
+var lang = require("../lib/lang");
+var config = require("../config");
-var dom = require("./lib/dom");
-var HashHandler = require("./keyboard/hash_handler").HashHandler;
-var TextMode = require("./mode/text").Mode;
+function bindKey(win, mac) {
+ return {
+ win: win,
+ mac: mac
+ };
+}
-var WorkerClient = require("./worker/worker_client").WorkerClient;
-// TODO: Hack! - changed "ace/autocomplete/autocomplete_worker" to "ace/mode/autocomplete_worker"
-var worker = new WorkerClient(["ace"], "ace/mode/autocomplete_worker", "AutocompleteWorker");
+exports.commands = [{
+ name: "showSettingsMenu",
+ bindKey: bindKey("Ctrl-,", "Command-,"),
+ exec: function(editor) {
+ config.loadModule("ace/ext/settings_menu", function(module) {
+ module.init(editor);
+ editor.showSettingsMenu();
+ });
+ },
+ readOnly: true
+}, {
+ name: "selectall",
+ bindKey: bindKey("Ctrl-A", "Command-A"),
+ exec: function(editor) { editor.selectAll(); },
+ readOnly: true
+}, {
+ name: "centerselection",
+ bindKey: bindKey(null, "Ctrl-L"),
+ exec: function(editor) { editor.centerSelection(); },
+ readOnly: true
+}, {
+ name: "gotoline",
+ bindKey: bindKey("Ctrl-L", "Command-L"),
+ exec: function(editor) {
+ var line = parseInt(prompt("Enter line number:"), 10);
+ if (!isNaN(line)) {
+ editor.gotoLine(line);
+ }
+ },
+ readOnly: true
+}, {
+ name: "fold",
+ bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
+ exec: function(editor) { editor.session.toggleFold(false); },
+ readOnly: true
+}, {
+ name: "unfold",
+ bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
+ exec: function(editor) { editor.session.toggleFold(true); },
+ readOnly: true
+}, {
+ name: "foldall",
+ bindKey: bindKey("Alt-0", "Command-Option-0"),
+ exec: function(editor) { editor.session.foldAll(); },
+ readOnly: true
+}, {
+ name: "unfoldall",
+ bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"),
+ exec: function(editor) { editor.session.unfold(); },
+ readOnly: true
+}, {
+ name: "findnext",
+ bindKey: bindKey("Ctrl-K", "Command-G"),
+ exec: function(editor) { editor.findNext(); },
+ readOnly: true
+}, {
+ name: "findprevious",
+ bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
+ exec: function(editor) { editor.findPrevious(); },
+ readOnly: true
+}, {
+ name: "find",
+ bindKey: bindKey("Ctrl-F", "Command-F"),
+ exec: function(editor) {
+ config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor)});
+ },
+ readOnly: true
+}, {
+ name: "overwrite",
+ bindKey: "Insert",
+ exec: function(editor) { editor.toggleOverwrite(); },
+ readOnly: true
+}, {
+ name: "selecttostart",
+ bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"),
+ exec: function(editor) { editor.getSelection().selectFileStart(); },
+ multiSelectAction: "forEach",
+ readOnly: true,
+ group: "fileJump"
+}, {
+ name: "gotostart",
+ bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
+ exec: function(editor) { editor.navigateFileStart(); },
+ multiSelectAction: "forEach",
+ readOnly: true,
+ group: "fileJump"
+}, {
+ name: "selectup",
+ bindKey: bindKey("Shift-Up", "Shift-Up"),
+ exec: function(editor) { editor.getSelection().selectUp(); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "golineup",
+ bindKey: bindKey("Up", "Up|Ctrl-P"),
+ exec: function(editor, args) { editor.navigateUp(args.times); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "selecttoend",
+ bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-Down"),
+ exec: function(editor) { editor.getSelection().selectFileEnd(); },
+ multiSelectAction: "forEach",
+ readOnly: true,
+ group: "fileJump"
+}, {
+ name: "gotoend",
+ bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
+ exec: function(editor) { editor.navigateFileEnd(); },
+ multiSelectAction: "forEach",
+ readOnly: true,
+ group: "fileJump"
+}, {
+ name: "selectdown",
+ bindKey: bindKey("Shift-Down", "Shift-Down"),
+ exec: function(editor) { editor.getSelection().selectDown(); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "golinedown",
+ bindKey: bindKey("Down", "Down|Ctrl-N"),
+ exec: function(editor, args) { editor.navigateDown(args.times); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "selectwordleft",
+ bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
+ exec: function(editor) { editor.getSelection().selectWordLeft(); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "gotowordleft",
+ bindKey: bindKey("Ctrl-Left", "Option-Left"),
+ exec: function(editor) { editor.navigateWordLeft(); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "selecttolinestart",
+ bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
+ exec: function(editor) { editor.getSelection().selectLineStart(); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "gotolinestart",
+ bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
+ exec: function(editor) { editor.navigateLineStart(); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "selectleft",
+ bindKey: bindKey("Shift-Left", "Shift-Left"),
+ exec: function(editor) { editor.getSelection().selectLeft(); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "gotoleft",
+ bindKey: bindKey("Left", "Left|Ctrl-B"),
+ exec: function(editor, args) { editor.navigateLeft(args.times); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "selectwordright",
+ bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
+ exec: function(editor) { editor.getSelection().selectWordRight(); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "gotowordright",
+ bindKey: bindKey("Ctrl-Right", "Option-Right"),
+ exec: function(editor) { editor.navigateWordRight(); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "selecttolineend",
+ bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
+ exec: function(editor) { editor.getSelection().selectLineEnd(); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "gotolineend",
+ bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
+ exec: function(editor) { editor.navigateLineEnd(); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "selectright",
+ bindKey: bindKey("Shift-Right", "Shift-Right"),
+ exec: function(editor) { editor.getSelection().selectRight(); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "gotoright",
+ bindKey: bindKey("Right", "Right|Ctrl-F"),
+ exec: function(editor, args) { editor.navigateRight(args.times); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "selectpagedown",
+ bindKey: "Shift-PageDown",
+ exec: function(editor) { editor.selectPageDown(); },
+ readOnly: true
+}, {
+ name: "pagedown",
+ bindKey: bindKey(null, "Option-PageDown"),
+ exec: function(editor) { editor.scrollPageDown(); },
+ readOnly: true
+}, {
+ name: "gotopagedown",
+ bindKey: bindKey("PageDown", "PageDown|Ctrl-V"),
+ exec: function(editor) { editor.gotoPageDown(); },
+ readOnly: true
+}, {
+ name: "selectpageup",
+ bindKey: "Shift-PageUp",
+ exec: function(editor) { editor.selectPageUp(); },
+ readOnly: true
+}, {
+ name: "pageup",
+ bindKey: bindKey(null, "Option-PageUp"),
+ exec: function(editor) { editor.scrollPageUp(); },
+ readOnly: true
+}, {
+ name: "gotopageup",
+ bindKey: "PageUp",
+ exec: function(editor) { editor.gotoPageUp(); },
+ readOnly: true
+}, {
+ name: "scrollup",
+ bindKey: bindKey("Ctrl-Up", null),
+ exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); },
+ readOnly: true
+}, {
+ name: "scrolldown",
+ bindKey: bindKey("Ctrl-Down", null),
+ exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); },
+ readOnly: true
+}, {
+ name: "selectlinestart",
+ bindKey: "Shift-Home",
+ exec: function(editor) { editor.getSelection().selectLineStart(); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "selectlineend",
+ bindKey: "Shift-End",
+ exec: function(editor) { editor.getSelection().selectLineEnd(); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "togglerecording",
+ bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
+ exec: function(editor) { editor.commands.toggleRecording(editor); },
+ readOnly: true
+}, {
+ name: "replaymacro",
+ bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
+ exec: function(editor) { editor.commands.replay(editor); },
+ readOnly: true
+}, {
+ name: "jumptomatching",
+ bindKey: bindKey("Ctrl-P", "Ctrl-Shift-P"),
+ exec: function(editor) { editor.jumpToMatching(); },
+ multiSelectAction: "forEach",
+ readOnly: true
+}, {
+ name: "selecttomatching",
+ bindKey: bindKey("Ctrl-Shift-P", null),
+ exec: function(editor) { editor.jumpToMatching(true); },
+ multiSelectAction: "forEach",
+ readOnly: true
+},
+{
+ name: "cut",
+ exec: function(editor) {
+ var range = editor.getSelectionRange();
+ editor._emit("cut", range);
-var mode = new TextMode();
-mode.$tokenizer = {
- getLineTokens: function(line) {
-
+ if (!editor.selection.isEmpty()) {
+ editor.session.remove(range);
+ editor.clearSelection();
+ }
+ },
+ multiSelectAction: "forEach"
+}, {
+ name: "removeline",
+ bindKey: bindKey("Ctrl-D", "Command-D"),
+ exec: function(editor) { editor.removeLines(); },
+ multiSelectAction: "forEachLine"
+}, {
+ name: "duplicateSelection",
+ bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
+ exec: function(editor) { editor.duplicateSelection(); },
+ multiSelectAction: "forEach"
+}, {
+ name: "sortlines",
+ bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
+ exec: function(editor) { editor.sortLines(); },
+ multiSelectAction: "forEachLine"
+}, {
+ name: "togglecomment",
+ bindKey: bindKey("Ctrl-/", "Command-/"),
+ exec: function(editor) { editor.toggleCommentLines(); },
+ multiSelectAction: "forEachLine"
+}, {
+ name: "toggleBlockComment",
+ bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"),
+ exec: function(editor) { editor.toggleBlockComment(); },
+ multiSelectAction: "forEach"
+}, {
+ name: "modifyNumberUp",
+ bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
+ exec: function(editor) { editor.modifyNumber(1); },
+ multiSelectAction: "forEach"
+}, {
+ name: "modifyNumberDown",
+ bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
+ exec: function(editor) { editor.modifyNumber(-1); },
+ multiSelectAction: "forEach"
+}, {
+ name: "replace",
+ bindKey: bindKey("Ctrl-H", "Command-Option-F"),
+ exec: function(editor) {
+ config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor, true)});
}
-};
+}, {
+ name: "undo",
+ bindKey: bindKey("Ctrl-Z", "Command-Z"),
+ exec: function(editor) { editor.undo(); }
+}, {
+ name: "redo",
+ bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
+ exec: function(editor) { editor.redo(); }
+}, {
+ name: "copylinesup",
+ bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"),
+ exec: function(editor) { editor.copyLinesUp(); }
+}, {
+ name: "movelinesup",
+ bindKey: bindKey("Alt-Up", "Option-Up"),
+ exec: function(editor) { editor.moveLinesUp(); }
+}, {
+ name: "copylinesdown",
+ bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"),
+ exec: function(editor) { editor.copyLinesDown(); }
+}, {
+ name: "movelinesdown",
+ bindKey: bindKey("Alt-Down", "Option-Down"),
+ exec: function(editor) { editor.moveLinesDown(); }
+}, {
+ name: "del",
+ bindKey: bindKey("Delete", "Delete|Ctrl-D"),
+ exec: function(editor) { editor.remove("right"); },
+ multiSelectAction: "forEach"
+}, {
+ name: "backspace",
+ bindKey: bindKey(
+ "Shift-Backspace|Backspace",
+ "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"
+ ),
+ exec: function(editor) { editor.remove("left"); },
+ multiSelectAction: "forEach"
+}, {
+ name: "removetolinestart",
+ bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
+ exec: function(editor) { editor.removeToLineStart(); },
+ multiSelectAction: "forEach"
+}, {
+ name: "removetolineend",
+ bindKey: bindKey("Alt-Delete", "Ctrl-K"),
+ exec: function(editor) { editor.removeToLineEnd(); },
+ multiSelectAction: "forEach"
+}, {
+ name: "removewordleft",
+ bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
+ exec: function(editor) { editor.removeWordLeft(); },
+ multiSelectAction: "forEach"
+}, {
+ name: "removewordright",
+ bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
+ exec: function(editor) { editor.removeWordRight(); },
+ multiSelectAction: "forEach"
+}, {
+ name: "outdent",
+ bindKey: bindKey("Shift-Tab", "Shift-Tab"),
+ exec: function(editor) { editor.blockOutdent(); },
+ multiSelectAction: "forEach"
+}, {
+ name: "indent",
+ bindKey: bindKey("Tab", "Tab"),
+ exec: function(editor) { editor.indent(); },
+ multiSelectAction: "forEach"
+},{
+ name: "blockoutdent",
+ bindKey: bindKey("Ctrl-[", "Ctrl-["),
+ exec: function(editor) { editor.blockOutdent(); },
+ multiSelectAction: "forEachLine"
+},{
+ name: "blockindent",
+ bindKey: bindKey("Ctrl-]", "Ctrl-]"),
+ exec: function(editor) { editor.blockIndent(); },
+ multiSelectAction: "forEachLine"
+}, {
+ name: "insertstring",
+ exec: function(editor, str) { editor.insert(str); },
+ multiSelectAction: "forEach"
+}, {
+ name: "inserttext",
+ exec: function(editor, args) {
+ editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
+ },
+ multiSelectAction: "forEach"
+}, {
+ name: "splitline",
+ bindKey: bindKey(null, "Ctrl-O"),
+ exec: function(editor) { editor.splitLine(); },
+ multiSelectAction: "forEach"
+}, {
+ name: "transposeletters",
+ bindKey: bindKey("Ctrl-T", "Ctrl-T"),
+ exec: function(editor) { editor.transposeLetters(); },
+ multiSelectAction: function(editor) {editor.transposeSelections(1); }
+}, {
+ name: "touppercase",
+ bindKey: bindKey("Ctrl-U", "Ctrl-U"),
+ exec: function(editor) { editor.toUpperCase(); },
+ multiSelectAction: "forEach"
+}, {
+ name: "tolowercase",
+ bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
+ exec: function(editor) { editor.toLowerCase(); },
+ multiSelectAction: "forEach"
+}];
-var Autocomplete = function() {
- this.keyboardHandler = new HashHandler();
- this.keyboardHandler.bindKeys(this.commands);
+});
- this.$blurListener = this.blurListener.bind(this);
- this.$changeListener = this.changeListener.bind(this);
- this.$mousedownListener = this.mousedownListener.bind(this);
+ace.define('ace/undomanager', ['require', 'exports', 'module' ], function(require, exports, module) {
+var UndoManager = function() {
+ this.reset();
};
-
(function() {
- this.$init = function() {
- this.popup = new AcePopup();
- this.popup.on("click", function(e) {
- this.insertMatch();
- }.bind(this));
- };
-
- this.openPopup = function(editor) {
- if (!this.popup)
- this.$init();
-
- this.popup.setData(this.completions.filtered)
-
- var renderer = editor.renderer;
- var lineHeight = renderer.layerConfig.lineHeight;
- var pos = renderer.$cursorLayer.getPixelPosition(null, true)
- var rect = editor.container.getBoundingClientRect()
- pos.top += rect.top - renderer.layerConfig.offset;
- pos.left += rect.left;
- pos.left += renderer.$gutterLayer.gutterWidth;
-
- var el = this.popup.container;
- if (pos.top > window.innerHeight / 2 + lineHeight) {
- el.style.top = ""
- el.style.bottom = window.innerHeight - pos.top + "px";
- } else {
- pos.top += lineHeight;
- el.style.top = pos.top + "px";
- el.style.bottom = ""
+ this.execute = function(options) {
+ var deltas = options.args[0];
+ this.$doc = options.args[1];
+ if (options.merge && this.hasUndo()){
+ deltas = this.$undoStack.pop().concat(deltas);
}
+ this.$undoStack.push(deltas);
+ this.$redoStack = [];
- el.style.left = pos.left + "px";
- el.style.display = "";
-
- renderer.updateText();
- };
-
- this.detach = function() {
- this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
- this.editor.removeEventListener("changeSelection", this.changeListener);
- this.editor.removeEventListener("blur", this.changeListener);
- this.editor.removeEventListener("mousedown", this.changeListener);
-
- if (this.popup)
- this.popup.container.style.display = "none";
-
- this.editor.Autocomplete.activated = false;
- };
-
- this.changeListener = function(e) {
- if (this.editor.Autocomplete.activated)
- Autocomplete.startCommand.exec(this.editor);
- else
- this.detach();
- };
-
- this.blurListener = function() {
- if (document.activeElement != this.editor.textInput.getElement())
- this.detach();
- };
-
- this.mousedownListener = function(e) {
- var mouseX = e.clientX, mouseY = e.clientY;
- var newRow = this.editor.renderer.pixelToScreenCoordinates(mouseX, mouseY).row;
- var currentRow = e.editor.getCursorPosition().row;
-
- if (newRow !== currentRow) {
- this.detach();
+ if (this.dirtyCounter < 0) {
+ this.dirtyCounter = NaN;
}
+ this.dirtyCounter++;
};
-
- this.goTo = function(where) {
- var row = this.popup.getRow();
- var max = this.popup.session.getLength() - 1;
-
- switch(where) {
- case "up": row = row <= 0 ? max : row - 1; break;
- case "down": row = row >= max ? 0 : row + 1; break;
- case "start": row = 0; break;
- case "end": row = max; break
- }
-
- this.popup.setRow(row);
- };
-
- this.insertMatch = function(row) {
- this.detach();
-
- if (row == undefined)
- row = this.popup.getRow();
- var text = this.completions.filtered[row];
- if (text.value)
- text = text.value;
- this.editor.getSession().remove(this.identifierRange);
- this.editor.insert(text);
- };
-
- this.commands = {
- "up": function(editor) { editor.Autocomplete.goTo("up"); },
- "down": function(editor) { editor.Autocomplete.goTo("down"); },
- "ctrl-up": function(editor) { editor.Autocomplete.goTo("start"); },
- "ctrl-down": function(editor) { editor.Autocomplete.goTo("end"); },
-
- "esc": function(editor) { editor.Autocomplete.detach(); },
- "space": function(editor) { editor.Autocomplete.detach(); editor.insert(" ");},
- "Return": function(editor) { editor.Autocomplete.insertMatch(); },
- "Shift-Return": function(editor) { editor.Autocomplete.insertMatch(true); },
- "Tab": function(editor) { editor.Autocomplete.insertMatch(); }
- };
- function getCompletions(token, context, keywords) {
- var found = [], start = token.value;
-
- function arrayContains(arr, item) {
- if (!Array.prototype.indexOf) {
- var i = arr.length;
- while (i--) {
- if (arr[i] === item) {
- return true;
- }
- }
- return false;
- }
- return arr.indexOf(item) != -1;
- }
-
- function maybeAdd(str) {
- if (str.indexOf(start) == 0 && !arrayContains(found, str)) found.push(str);
- }
- function gatherCompletions(obj) {
- for (var name in obj) maybeAdd(name);
- }
-
- if (context) {
- var obj = context.pop(), base;
-
- if (obj.type == "identifier")
- base = window[obj.value];
- else
- base = "";
- while (base != null && context.length)
- base = base[context.pop().value];
- if (base != null) gatherCompletions(base);
- }
- else {
- }
- return found;
- }
-
- function getCurrentToken(editor)
- {
- var stream = new TokenIterator(editor.session, editor.getCursorPosition().row, editor.getCursorPosition().column);
- var currToken = stream.getCurrentToken();
- if (currToken == null || (currToken.type == "punctuation.operator" && currToken.value == ".")) currToken = { type: "", value: "" };
-
- return currToken;
- }
-
- function getContext(editor)
- {
- var stream = new TokenIterator(editor.session, editor.getCursorPosition().row, editor.getCursorPosition().column);
- var token = stream.stepBackward();
- var tokenRow = stream.getCurrentTokenRow();
- var editorRow = editor.getCursorPosition().row;
- while (tokenRow == editorRow) {
- if ((token == null || stream.$tokenIndex <= -1) || (token != null && token.type == "text")) {
- break;
- }
- if (!(token != null && token.type == "punctuation.operator" && token.value == ".")) {
- if (!context) var context = [];
- context.push(token);
- }
- token = stream.stepBackward();
- tokenRow = stream.getCurrentTokenRow();
- }
-
- return context;
- }
-
- this.complete = function(editor) {
- if (this.editor)
- this.detach();
-
- var _self = this;
- this.editor = editor;
- if (editor.Autocomplete != this) {
- if (editor.Autocomplete)
- editor.Autocomplete.detach();
- editor.Autocomplete = this;
+ this.undo = function(dontSelect) {
+ var deltas = this.$undoStack.pop();
+ var undoSelectionRange = null;
+ if (deltas) {
+ undoSelectionRange =
+ this.$doc.undoChanges(deltas, dontSelect);
+ this.$redoStack.push(deltas);
+ this.dirtyCounter--;
}
- editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
- editor.on("changeSelection", this.$changeListener);
- editor.on("blur", this.$blurListener);
- editor.on("mousedown", this.$mousedownListener);
-
- var objCompletions = getCompletions(getCurrentToken(editor), getContext(editor), new Array());
-
- worker.attachToDocument(editor.session.getDocument(), {cursor: editor.getCursorPosition(), keywords: editor.session.getMode().getKeywords()}, true);
-
- worker.on("complete", function(data) {
- var matches = data.data.matches;
-
- if (!matches.length) {
- matches = objCompletions;
- }
-
- if (matches.length) {
- _self.completions = new FilteredList(matches);
- _self.completions.setFilter("a");
- _self.identifierRange = new Range(data.data.startRow, data.data.startColumn, data.data.endRow, data.data.endColumn);
- _self.openPopup(editor);
- }
- else {
- _self.detach();
- }
- });
- };
-
-}).call(Autocomplete.prototype);
-
-Autocomplete.startCommand = {
- name: "startAutocomplete",
- exec: function(editor) {
- if (!editor.Autocomplete)
- editor.Autocomplete = new Autocomplete();
- editor.Autocomplete.complete(editor);
- editor.Autocomplete.activated = true;
- },
- bindKey: "Ctrl-Space|Shift-Space|Alt-Space"
-}
-Autocomplete.addTo = function(editor) {
- editor.commands.addCommand(Autocomplete.startCommand);
-}
-
-var FilteredList = function(array, mutateData) {
- this.all = array;
- this.filtered = array.concat();
- this.filterText = "";
-};
-(function(){
- this.setFilter = function(str) {
-
- };
-
-}).call(FilteredList.prototype);
-
-
-var $singleLineEditor = function(el) {
- var renderer = new Renderer(el);
- el.style.overflow = "hidden";
- renderer.scrollBar.element.style.top = "0";
- renderer.scrollBar.element.style.display = "none";
- renderer.scrollBar.orginalWidth = renderer.scrollBar.width;
- renderer.scrollBar.width = 0;
- renderer.content.style.height = "auto";
-
- renderer.screenToTextCoordinates = function(x, y) {
- var pos = this.pixelToScreenCoordinates(x, y);
- return this.session.screenToDocumentPosition(
- Math.min(this.session.getScreenLength() - 1, Math.max(pos.row, 0)),
- Math.max(pos.column, 0)
- );
+ return undoSelectionRange;
};
-
- renderer.maxLines = 4;
- renderer.$computeLayerConfigWithScroll = renderer.$computeLayerConfig;
- renderer.$computeLayerConfig = function() {
- var config = this.layerConfig;
- var height = this.session.getScreenLength() * this.lineHeight;
- if (config.height != height) {
- var maxHeight = this.maxLines * this.lineHeight
- var vScroll = height > maxHeight;
-
- if (vScroll != this.$vScroll || this.lineHeight != config.lineHeight) {
- if (vScroll) {
- this.scrollBar.element.style.display = "";
- this.scrollBar.width = this.scrollBar.orginalWidth;
- this.container.style.height = maxHeight + "px";
- height = maxHeight;
- this.scrollTop = height - this.maxLines * this.lineHeight;
- } else {
- this.scrollBar.element.style.display = "none";
- this.scrollBar.width = 0;
- }
-
- this.$size.height = 0;
- this.$size.width = 0;
- this.onResize();
- this.$vScroll = vScroll;
- }
-
- if (this.$vScroll)
- return renderer.$computeLayerConfigWithScroll();
-
- this.container.style.height = height + "px";
- this.scroller.style.height = height + "px";
- this.content.style.height = height + "px";
- this._emit("resize");
+ this.redo = function(dontSelect) {
+ var deltas = this.$redoStack.pop();
+ var redoSelectionRange = null;
+ if (deltas) {
+ redoSelectionRange =
+ this.$doc.redoChanges(deltas, dontSelect);
+ this.$undoStack.push(deltas);
+ this.dirtyCounter++;
}
- var longestLine = this.$getLongestLine();
- var firstRow = 0;
- var lastRow = this.session.getLength();
-
- this.scrollTop = 0;
- config.width = longestLine;
- config.padding = this.$padding;
- config.firstRow = 0;
- config.firstRowScreen = 0;
- config.lastRow = lastRow;
- config.lineHeight = this.lineHeight;
- config.characterWidth = this.characterWidth;
- config.minHeight = height;
- config.maxHeight = height;
- config.offset = 0;
- config.height = height;
-
- this.$gutterLayer.element.style.marginTop = 0 + "px";
- this.content.style.marginTop = 0 + "px";
- this.content.style.width = longestLine + 2 * this.$padding + "px";
+ return redoSelectionRange;
};
-
-
- var Editor = require("ace/editor").Editor;
- var editor = new Editor(renderer);
-
- editor.setHighlightActiveLine(false);
- editor.setShowPrintMargin(false);
- editor.renderer.setShowGutter(false);
- editor.renderer.setHighlightGutterLine(false);
-
- editor.$mouseHandler.$focusWaitTimout = 0;
-
- return editor;
-};
-
-var AcePopup = function(e) {
- var el = dom.createElement("div");
- var popup = new $singleLineEditor(el);
- document.body.appendChild(el);
- el.style.display = "none";
- popup.renderer.content.style.cursor = "default";
- popup.renderer.setStyle("ace_autocomplete");
-
- var noop = function(){};
-
- popup.focus = noop;
- popup.$isFocused = true;
-
- popup.renderer.$cursorLayer.restartTimer = noop;
- popup.renderer.$cursorLayer.element.style.opacity = 0;
-
- popup.renderer.maxLines = 8
- popup.renderer.$keepTextAreaAtCursor = false;
-
- popup.setHighlightActiveLine(true);
- popup.setSession(new EditSession(""));
-
- popup.on("mousedown", function(e) {
- var pos = e.getDocumentPosition();
- popup.moveCursorToPosition(pos);
- popup.selection.clearSelection();
- e.stop();
- });
-
- popup.getRow = function() {
- var line = this.getCursorPosition().row;
- if (line == 0 && !this.getHighlightActiveLine())
- line = -1;
- return line;
+ this.reset = function() {
+ this.$undoStack = [];
+ this.$redoStack = [];
+ this.dirtyCounter = 0;
};
-
- popup.setRow = function(line) {
- popup.setHighlightActiveLine(line != -1);
- popup.gotoLine(line + 1);
+ this.hasUndo = function() {
+ return this.$undoStack.length > 0;
};
-
- var hoverMarker = new Range(0,0,0,Infinity);
- hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine");
- popup.on("mousemove", function(e) {
- var row = e.getDocumentPosition().row;
- hoverMarker.start.row = hoverMarker.end.row = row;
- popup.session._emit("changeBackMarker");
- });
- event.addListener(popup.container, "mouseout", function(e) {
- hoverMarker.start.row = hoverMarker.end.row = -1;
- popup.session._emit("changeBackMarker");
- });
-
- popup.setData = function(list) {
- var value = ""
- if (list) {
- if (typeof list[0] == "string")
- value = list.join("\n");
- else
- value = list.map(function(x){return x.value}).join("\n");
- }
-
- this.setValue(value, -1);
+ this.hasRedo = function() {
+ return this.$redoStack.length > 0;
};
-
- popup.setHighlight = function(re) {
- ace.session.highlight(re);
- ace.session._emit("changeFrontMarker");
+ this.markClean = function() {
+ this.dirtyCounter = 0;
+ };
+ this.isClean = function() {
+ return this.dirtyCounter === 0;
};
-
- return popup;
-};
-
-dom.importCssString("\
-.ace_autocomplete.ace-tm .ace_marker-layer .ace_active-line {\
- background-color: #abbffe;\
-}\
-.ace_autocomplete.ace-tm .ace_line-hover {\
- border: 1px solid #abbffe;\
- position: absolute;\
- background: rgb(233,233,232);\
- z-index: 2;\
-}\
-.ace_autocomplete {\
- width: 200px;\
- z-index: 200000;\
- background: #f8f8f8;\
- border: 1px lightgray solid;\
- position: fixed;\
-}");
-exports.Autocomplete = Autocomplete;
-exports.FilteredList = FilteredList;
+}).call(UndoManager.prototype);
+exports.UndoManager = UndoManager;
});
-define('ace/virtual_renderer', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/dom', 'ace/lib/event', 'ace/lib/useragent', 'ace/config', 'ace/lib/net', 'ace/layer/gutter', 'ace/layer/marker', 'ace/layer/text', 'ace/layer/cursor', 'ace/scrollbar', 'ace/renderloop', 'ace/lib/event_emitter'], function(require, exports, module) {
+ace.define('ace/virtual_renderer', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/dom', 'ace/lib/useragent', 'ace/config', 'ace/layer/gutter', 'ace/layer/marker', 'ace/layer/text', 'ace/layer/cursor', 'ace/scrollbar', 'ace/renderloop', 'ace/lib/event_emitter'], function(require, exports, module) {
var oop = require("./lib/oop");
var dom = require("./lib/dom");
-var event = require("./lib/event");
var useragent = require("./lib/useragent");
var config = require("./config");
-var net = require("./lib/net");
var GutterLayer = require("./layer/gutter").Gutter;
var MarkerLayer = require("./layer/marker").Marker;
var TextLayer = require("./layer/text").Text;
var CursorLayer = require("./layer/cursor").Cursor;
-var ScrollBar = require("./scrollbar").ScrollBar;
+var ScrollBarH = require("./scrollbar").ScrollBarH;
+var ScrollBarV = require("./scrollbar").ScrollBarV;
var RenderLoop = require("./renderloop").RenderLoop;
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var editorCss = ".ace_editor {\
@@ -10501,12 +11767,14 @@ overflow: hidden;\
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\
font-size: 12px;\
line-height: normal;\
+color: black;\
}\
.ace_scroller {\
position: absolute;\
overflow: hidden;\
top: 0;\
bottom: 0;\
+background-color: inherit;\
}\
.ace_content {\
position: absolute;\
@@ -10556,8 +11824,8 @@ background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCA
}\
.ace_scrollbar {\
position: absolute;\
-overflow-x: hidden;\
-overflow-y: scroll;\
+overflow: hidden;\
+overflow-y: auto;\
right: 0;\
top: 0;\
bottom: 0;\
@@ -10567,6 +11835,19 @@ position: absolute;\
width: 1px;\
left: 0;\
}\
+.ace_scrollbar-h {\
+position: absolute;\
+overflow-x: auto;\
+overflow-y: hidden;\
+right: 0;\
+left: 0;\
+bottom: 0;\
+}\
+.ace_scrollbar-inner {\
+position: absolute;\
+height: 1px;\
+left: 0;\
+}\
.ace_print-margin {\
position: absolute;\
height: 100%;\
@@ -10585,15 +11866,14 @@ resize: none;\
outline: none;\
overflow: hidden;\
font: inherit;\
+padding: 0 1px;\
+margin: 0 -1px;\
}\
.ace_text-input.ace_composition {\
background: #f8f8f8;\
color: #111;\
z-index: 1000;\
opacity: 1;\
-border: solid lightgray 1px;\
-margin: -1px;\
-padding: 0 1px;\
}\
.ace_layer {\
z-index: 1;\
@@ -10616,7 +11896,6 @@ text-align: right;\
pointer-events: auto;\
}\
.ace_text-layer {\
-color: black;\
font: inherit !important;\
}\
.ace_cjk {\
@@ -10652,7 +11931,7 @@ border-left-width: 1px;\
.ace_line {\
white-space: nowrap;\
}\
-.ace_marker-layer .ace_step {\
+.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\
position: absolute;\
z-index: 3;\
}\
@@ -10710,7 +11989,7 @@ cursor: move;\
}\
.ace_gutter-tooltip {\
background-color: #FFF;\
-background-image: -webkit-linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\
+background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));\
background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\
border: 1px solid gray;\
border-radius: 1px;\
@@ -10740,7 +12019,7 @@ padding-right: 13px;\
-webkit-box-sizing: border-box;\
box-sizing: border-box;\
margin: 0 -12px 0 1px;\
-display: inline-block;\
+display: none;\
width: 11px;\
vertical-align: top;\
background-image: url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAe%8A%B1%0D%000%0C%C2%F2%2CK%96%BC%D0%8F9%81%88H%E9%D0%0E%96%C0%10%92%3E%02%80%5E%82%E4%A9*-%EEsw%C8%CC%11%EE%96w%D8%DC%E9*Eh%0C%151(%00%00%00%00IEND%AEB%60%82\");\
@@ -10748,6 +12027,10 @@ background-repeat: no-repeat;\
background-position: center;\
border-radius: 3px;\
border: 1px solid transparent;\
+cursor: pointer;\
+}\
+.ace_folding-enabled .ace_fold-widget {\
+display: inline-block; \
}\
.ace_fold-widget.ace_end {\
background-image: url(\"data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%05%00%00%00%05%08%06%00%00%00%8Do%26%E5%00%00%004IDATx%DAm%C7%C1%09%000%08C%D1%8C%ECE%C8E(%8E%EC%02)%1EZJ%F1%C1'%04%07I%E1%E5%EE%CAL%F5%A2%99%99%22%E2%D6%1FU%B5%FE0%D9x%A7%26Wz5%0E%D5%00%00%00%00IEND%AEB%60%82\");\
@@ -10822,6 +12105,16 @@ font-weight: normal;\
.ace_italic {\
font-style: italic;\
}\
+.ace_error-marker {\
+background-color: rgba(255, 0, 0,0.2);\
+position: absolute;\
+z-index: 9;\
+}\
+.ace_highlight-marker {\
+background-color: rgba(255, 255, 0,0.2);\
+position: absolute;\
+z-index: 8;\
+}\
";
dom.importCssString(editorCss, "ace_editor");
@@ -10848,7 +12141,6 @@ var VirtualRenderer = function(container, theme) {
this.content.className = "ace_content";
this.scroller.appendChild(this.content);
- this.setHighlightGutterLine(true);
this.$gutterLayer = new GutterLayer(this.$gutter);
this.$gutterLayer.on("changeGutterWidth", this.onGutterResize.bind(this));
@@ -10861,25 +12153,23 @@ var VirtualRenderer = function(container, theme) {
this.$cursorLayer = new CursorLayer(this.content);
this.$horizScroll = false;
- this.$horizScrollAlwaysVisible = false;
-
- this.$animatedScroll = false;
-
- this.scrollBar = new ScrollBar(this.container);
- this.scrollBar.addEventListener("scroll", function(e) {
- if (!_self.$inScrollAnimation)
- _self.session.setScrollTop(e.data);
+ this.$vScroll = false;
+
+ this.scrollBar =
+ this.scrollBarV = new ScrollBarV(this.container, this);
+ this.scrollBarH = new ScrollBarH(this.container, this);
+ this.scrollBarV.addEventListener("scroll", function(e) {
+ if (!_self.$scrollAnimation)
+ _self.session.setScrollTop(e.data - _self.scrollMargin.top);
+ });
+ this.scrollBarH.addEventListener("scroll", function(e) {
+ if (!_self.$scrollAnimation)
+ _self.session.setScrollLeft(e.data - _self.scrollMargin.left);
});
this.scrollTop = 0;
this.scrollLeft = 0;
- event.addListener(this.scroller, "scroll", function() {
- var scrollLeft = _self.scroller.scrollLeft;
- _self.scrollLeft = scrollLeft;
- _self.session.setScrollLeft(scrollLeft);
- });
-
this.cursorPos = {
row : 0,
column : 0
@@ -10888,6 +12178,7 @@ var VirtualRenderer = function(container, theme) {
this.$textLayer.addEventListener("changeCharacterSize", function() {
_self.updateCharacterSize();
_self.onResize(true);
+ _self._signal("changeCharacterSize");
});
this.$size = {
@@ -10910,6 +12201,15 @@ var VirtualRenderer = function(container, theme) {
offset : 0,
height : 1
};
+
+ this.scrollMargin = {
+ left: 0,
+ right: 0,
+ top: 0,
+ bottom: 0,
+ v: 0,
+ h: 0
+ };
this.$loop = new RenderLoop(
this.$renderChanges.bind(this),
@@ -10919,10 +12219,11 @@ var VirtualRenderer = function(container, theme) {
this.updateCharacterSize();
this.setPadding(4);
+ config.resetOptions(this);
+ config._emit("renderer", this);
};
(function() {
- this.showGutter = true;
this.CHANGE_CURSOR = 1;
this.CHANGE_MARKER = 2;
@@ -10937,29 +12238,31 @@ var VirtualRenderer = function(container, theme) {
this.CHANGE_H_SCROLL = 1024;
oop.implement(this, EventEmitter);
-
+
this.updateCharacterSize = function() {
if (this.$textLayer.allowBoldFonts != this.$allowBoldFonts) {
this.$allowBoldFonts = this.$textLayer.allowBoldFonts;
this.setStyle("ace_nobold", !this.$allowBoldFonts);
}
-
+
+ this.layerConfig.characterWidth =
this.characterWidth = this.$textLayer.getCharacterWidth();
+ this.layerConfig.lineHeight =
this.lineHeight = this.$textLayer.getLineHeight();
this.$updatePrintMargin();
};
this.setSession = function(session) {
this.session = session;
-
+
this.scroller.className = "ace_scroller";
-
+
this.$cursorLayer.setSession(session);
this.$markerBack.setSession(session);
this.$markerFront.setSession(session);
this.$gutterLayer.setSession(session);
this.$textLayer.setSession(session);
this.$loop.schedule(this.CHANGE_FULL);
-
+
};
this.updateLines = function(firstRow, lastRow) {
if (lastRow === undefined)
@@ -10978,7 +12281,7 @@ var VirtualRenderer = function(container, theme) {
if (this.$changedLines.lastRow < lastRow)
this.$changedLines.lastRow = lastRow;
}
-
+
if (this.$changedLines.firstRow > this.layerConfig.lastRow ||
this.$changedLines.lastRow < this.layerConfig.firstRow)
return;
@@ -10993,168 +12296,175 @@ var VirtualRenderer = function(container, theme) {
this.$loop.schedule(this.CHANGE_TEXT);
};
this.updateFull = function(force) {
- if (force){
+ if (force)
this.$renderChanges(this.CHANGE_FULL, true);
- }
- else {
+ else
this.$loop.schedule(this.CHANGE_FULL);
- }
};
this.updateFontSize = function() {
this.$textLayer.checkForSizeChanges();
};
- this.onResize = function(force, gutterWidth, width, height) {
- var changes = this.CHANGE_SIZE;
- var size = this.$size;
+ this.$changes = 0;
+ this.onResize = function(force, gutterWidth, width, height) {
if (this.resizing > 2)
return;
- else if (this.resizing > 1)
+ else if (this.resizing > 0)
this.resizing++;
else
this.resizing = force ? 1 : 0;
+ var el = this.container;
if (!height)
- height = dom.getInnerHeight(this.container);
+ height = el.clientHeight || el.scrollHeight;
+ if (!width)
+ width = el.clientWidth || el.scrollWidth;
+
+ var changes = this.$updateCachedSize(force, gutterWidth, width, height);
+
+ if (!this.$size.scrollerHeight || (!width && !height))
+ return this.resizing = 0;
+
+ if (force)
+ this.$gutterLayer.$padding = null;
+ if (force)
+ this.$renderChanges(changes, true);
+ else
+ this.$loop.schedule(changes || this.$changes);
+
+ if (this.resizing)
+ this.resizing = 0;
+ };
+
+ this.$updateCachedSize = function(force, gutterWidth, width, height) {
+ var changes = 0;
+ var size = this.$size;
if (height && (force || size.height != height)) {
size.height = height;
+ changes = this.CHANGE_SIZE;
- size.scrollerHeight = this.scroller.clientHeight;
- this.scrollBar.setHeight(size.scrollerHeight);
+ size.scrollerHeight = size.height;
+ if (this.$horizScroll)
+ size.scrollerHeight -= this.scrollBarH.getHeight();
+ this.scrollBarV.element.style.bottom = this.scrollBarH.getHeight() + "px";
if (this.session) {
this.session.setScrollTop(this.getScrollTop());
- changes = changes | this.CHANGE_FULL;
+ changes = changes | this.CHANGE_SCROLL;
}
}
- if (!width)
- width = dom.getInnerWidth(this.container);
-
- if (width && (force || this.resizing > 1 || size.width != width)) {
+ if (width && (force || size.width != width)) {
+ changes = this.CHANGE_SIZE;
size.width = width;
-
- var gutterWidth = this.showGutter ? this.$gutter.offsetWidth : 0;
+
+ if (gutterWidth == null)
+ gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
+
+ this.gutterWidth = gutterWidth;
+
+ this.scrollBarH.element.style.left =
this.scroller.style.left = gutterWidth + "px";
- size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBar.getWidth());
- this.scroller.style.right = this.scrollBar.getWidth() + "px";
+ size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth());
+
+ this.scrollBarH.element.style.right =
+ this.scroller.style.right = this.scrollBarV.getWidth() + "px";
+ this.scroller.style.bottom = this.scrollBarH.getHeight() + "px";
- if (this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
+ if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
changes = changes | this.CHANGE_FULL;
}
-
- if (force)
- this.$renderChanges(changes, true);
- else
- this.$loop.schedule(changes);
- if (force)
- delete this.resizing;
+ if (changes)
+ this._signal("resize");
+
+ return changes;
};
this.onGutterResize = function() {
- var width = this.$size.width;
- var gutterWidth = this.showGutter ? this.$gutter.offsetWidth : 0;
- this.scroller.style.left = gutterWidth + "px";
- this.$size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBar.getWidth());
+ var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
+ if (gutterWidth != this.gutterWidth)
+ this.$changes != this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height);
if (this.session.getUseWrapMode() && this.adjustWrapLimit())
this.$loop.schedule(this.CHANGE_FULL);
+ else {
+ this.$computeLayerConfig();
+ this.$loop.schedule(this.CHANGE_MARKER);
+ }
};
this.adjustWrapLimit = function() {
var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
var limit = Math.floor(availableWidth / this.characterWidth);
- return this.session.adjustWrapLimit(limit);
+ return this.session.adjustWrapLimit(limit, this.$showPrintMargin && this.$printMarginColumn);
};
this.setAnimatedScroll = function(shouldAnimate){
- this.$animatedScroll = shouldAnimate;
+ this.setOption("animatedScroll", shouldAnimate);
};
this.getAnimatedScroll = function() {
return this.$animatedScroll;
};
this.setShowInvisibles = function(showInvisibles) {
- if (this.$textLayer.setShowInvisibles(showInvisibles))
- this.$loop.schedule(this.CHANGE_TEXT);
+ this.setOption("showInvisibles", showInvisibles);
};
this.getShowInvisibles = function() {
- return this.$textLayer.showInvisibles;
+ return this.getOption("showInvisibles");
};
-
this.getDisplayIndentGuides = function() {
- return this.$textLayer.displayIndentGuides;
+ return this.getOption("displayIndentGuides");
};
-
+
this.setDisplayIndentGuides = function(display) {
- if (this.$textLayer.setDisplayIndentGuides(display))
- this.$loop.schedule(this.CHANGE_TEXT);
+ this.setOption("displayIndentGuides", display);
};
-
- this.$showPrintMargin = true;
this.setShowPrintMargin = function(showPrintMargin) {
- this.$showPrintMargin = showPrintMargin;
- this.$updatePrintMargin();
+ this.setOption("showPrintMargin", showPrintMargin);
};
this.getShowPrintMargin = function() {
- return this.$showPrintMargin;
+ return this.getOption("showPrintMargin");
};
-
- this.$printMarginColumn = 80;
this.setPrintMarginColumn = function(showPrintMargin) {
- this.$printMarginColumn = showPrintMargin;
- this.$updatePrintMargin();
+ this.setOption("printMarginColumn", showPrintMargin);
};
this.getPrintMarginColumn = function() {
- return this.$printMarginColumn;
+ return this.getOption("printMarginColumn");
};
this.getShowGutter = function(){
- return this.showGutter;
+ return this.getOption("showGutter");
};
this.setShowGutter = function(show){
- if(this.showGutter === show)
- return;
- this.$gutter.style.display = show ? "block" : "none";
- this.showGutter = show;
- this.onResize(true);
+ return this.setOption("showGutter", show);
};
this.getFadeFoldWidgets = function(){
- return dom.hasCssClass(this.$gutter, "ace_fade-fold-widgets");
+ return this.getOption("fadeFoldWidgets")
};
this.setFadeFoldWidgets = function(show) {
- if (show)
- dom.addCssClass(this.$gutter, "ace_fade-fold-widgets");
- else
- dom.removeCssClass(this.$gutter, "ace_fade-fold-widgets");
+ this.setOption("fadeFoldWidgets", show);
};
- this.$highlightGutterLine = false;
this.setHighlightGutterLine = function(shouldHighlight) {
- if (this.$highlightGutterLine == shouldHighlight)
- return;
- this.$highlightGutterLine = shouldHighlight;
-
- if (!this.$gutterLineHighlight) {
- this.$gutterLineHighlight = dom.createElement("div");
- this.$gutterLineHighlight.className = "ace_gutter-active-line";
- this.$gutter.appendChild(this.$gutterLineHighlight);
- return;
- }
-
- this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none";
- if (this.$cursorLayer.$pixelPos)
- this.$updateGutterLineHighlight();
+ this.setOption("highlightGutterLine", shouldHighlight);
};
this.getHighlightGutterLine = function() {
- return this.$highlightGutterLine;
+ return this.getOption("highlightGutterLine");
};
this.$updateGutterLineHighlight = function() {
- this.$gutterLineHighlight.style.top = this.$cursorLayer.$pixelPos.top - this.layerConfig.offset + "px";
- this.$gutterLineHighlight.style.height = this.layerConfig.lineHeight + "px";
+ var pos = this.$cursorLayer.$pixelPos;
+ var height = this.layerConfig.lineHeight;
+ if (this.session.getUseWrapMode()) {
+ var cursor = this.session.selection.getCursor();
+ cursor.column = 0;
+ pos = this.$cursorLayer.getPixelPosition(cursor, true);
+ height *= this.session.getRowLength(cursor.row);
+ }
+ this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px";
+ this.$gutterLineHighlight.style.height = height + "px";
};
-
+
this.$updatePrintMargin = function() {
if (!this.$showPrintMargin && !this.$printMarginEl)
return;
@@ -11171,6 +12481,9 @@ var VirtualRenderer = function(container, theme) {
var style = this.$printMarginEl.style;
style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
style.visibility = this.$showPrintMargin ? "visible" : "hidden";
+
+ if (this.session && this.session.$wrap == -1)
+ this.adjustWrapLimit();
};
this.getContainerElement = function() {
return this.container;
@@ -11189,13 +12502,16 @@ var VirtualRenderer = function(container, theme) {
var posLeft = this.$cursorLayer.$pixelPos.left;
posTop -= config.offset;
- if (posTop < 0 || posTop > config.height - this.lineHeight)
+ var h = this.lineHeight;
+ if (posTop < 0 || posTop > config.height - h)
return;
var w = this.characterWidth;
if (this.$composition) {
var val = this.textarea.value.replace(/^\x01+/, "");
- w *= this.session.$getStringScreenWidth(val)[0];
+ w *= (this.session.$getStringScreenWidth(val)[0]+2);
+ h += 2;
+ posTop -= 1;
}
posLeft -= this.scrollLeft;
if (posLeft > this.$size.scrollerWidth - w)
@@ -11203,10 +12519,10 @@ var VirtualRenderer = function(container, theme) {
posLeft -= this.scrollBar.width;
- this.textarea.style.height = this.lineHeight + "px";
+ this.textarea.style.height = h + "px";
this.textarea.style.width = w + "px";
- this.textarea.style.right = this.$size.scrollerWidth - posLeft - w + "px";
- this.textarea.style.bottom = this.$size.height - posTop - this.lineHeight + "px";
+ this.textarea.style.right = Math.max(0, this.$size.scrollerWidth - posLeft - w) + "px";
+ this.textarea.style.bottom = Math.max(0, this.$size.height - posTop - h) + "px";
};
this.getFirstVisibleRow = function() {
return this.layerConfig.firstRow;
@@ -11232,81 +12548,109 @@ var VirtualRenderer = function(container, theme) {
this.$loop.schedule(this.CHANGE_FULL);
this.$updatePrintMargin();
};
+
+ this.setScrollMargin = function(top, bottom, left, right) {
+ var sm = this.scrollMargin;
+ sm.top = top|0;
+ sm.bottom = bottom|0;
+ sm.right = right|0;
+ sm.left = left|0;
+ sm.v = sm.top + sm.bottom;
+ sm.h = sm.left + sm.right;
+ this.updateFull();
+ };
this.getHScrollBarAlwaysVisible = function() {
- return this.$horizScrollAlwaysVisible;
+ return this.$hScrollBarAlwaysVisible;
};
this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
- if (this.$horizScrollAlwaysVisible != alwaysVisible) {
- this.$horizScrollAlwaysVisible = alwaysVisible;
- if (!this.$horizScrollAlwaysVisible || !this.$horizScroll)
- this.$loop.schedule(this.CHANGE_SCROLL);
- }
+ this.setOption("hScrollBarAlwaysVisible", alwaysVisible);
+ };
+ this.getVScrollBarAlwaysVisible = function() {
+ return this.$hScrollBarAlwaysVisible;
+ };
+ this.setVScrollBarAlwaysVisible = function(alwaysVisible) {
+ this.setOption("vScrollBarAlwaysVisible", alwaysVisible);
};
- this.$updateScrollBar = function() {
- this.scrollBar.setInnerHeight(this.layerConfig.maxHeight);
- this.scrollBar.setScrollTop(this.scrollTop);
+ this.$updateScrollBarV = function() {
+ this.scrollBarV.setInnerHeight(this.layerConfig.maxHeight + this.scrollMargin.v);
+ this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top);
+ };
+ this.$updateScrollBarH = function() {
+ this.scrollBarH.setInnerWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h);
+ this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left);
};
this.$renderChanges = function(changes, force) {
- if (!force && (!changes || !this.session || !this.container.offsetWidth))
- return;
+ if (this.$changes) {
+ changes |= this.$changes;
+ this.$changes = 0;
+ }
+ if ((!this.session || !this.container.offsetWidth) || (!changes && !force)) {
+ this.$changes |= changes;
+ return;
+ }
+ if (!this.$size.width)
+ return this.onResize(true);
+
+ this._signal("beforeRender");
if (changes & this.CHANGE_FULL ||
changes & this.CHANGE_SIZE ||
changes & this.CHANGE_TEXT ||
changes & this.CHANGE_LINES ||
- changes & this.CHANGE_SCROLL
+ changes & this.CHANGE_SCROLL ||
+ changes & this.CHANGE_H_SCROLL
)
- this.$computeLayerConfig();
+ changes |= this.$computeLayerConfig();
if (changes & this.CHANGE_H_SCROLL) {
- this.scroller.scrollLeft = this.scrollLeft;
- var scrollLeft = this.scroller.scrollLeft;
- this.scrollLeft = scrollLeft;
- this.session.setScrollLeft(scrollLeft);
-
- this.scroller.className = this.scrollLeft == 0 ? "ace_scroller" : "ace_scroller ace_scroll-left";
+ this.$updateScrollBarH();
+ this.content.style.marginLeft = -this.scrollLeft + "px";
+ this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left";
}
if (changes & this.CHANGE_FULL) {
this.$textLayer.checkForSizeChanges();
- this.$updateScrollBar();
+ this.$updateScrollBarV();
+ this.$updateScrollBarH();
this.$textLayer.update(this.layerConfig);
- if (this.showGutter)
+ if (this.$showGutter)
this.$gutterLayer.update(this.layerConfig);
this.$markerBack.update(this.layerConfig);
this.$markerFront.update(this.layerConfig);
this.$cursorLayer.update(this.layerConfig);
this.$moveTextAreaToCursor();
this.$highlightGutterLine && this.$updateGutterLineHighlight();
+ this._signal("afterRender");
return;
}
if (changes & this.CHANGE_SCROLL) {
- this.$updateScrollBar();
+ this.$updateScrollBarV();
if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
this.$textLayer.update(this.layerConfig);
else
this.$textLayer.scrollLines(this.layerConfig);
- if (this.showGutter)
+ if (this.$showGutter)
this.$gutterLayer.update(this.layerConfig);
this.$markerBack.update(this.layerConfig);
this.$markerFront.update(this.layerConfig);
this.$cursorLayer.update(this.layerConfig);
- this.$moveTextAreaToCursor();
this.$highlightGutterLine && this.$updateGutterLineHighlight();
+ this.$moveTextAreaToCursor();
+ this._signal("afterRender");
return;
}
if (changes & this.CHANGE_TEXT) {
this.$textLayer.update(this.layerConfig);
- if (this.showGutter)
+ if (this.$showGutter)
this.$gutterLayer.update(this.layerConfig);
}
else if (changes & this.CHANGE_LINES) {
- if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.showGutter)
+ if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter)
this.$gutterLayer.update(this.layerConfig);
}
else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) {
- if (this.showGutter)
+ if (this.$showGutter)
this.$gutterLayer.update(this.layerConfig);
}
@@ -11324,28 +12668,83 @@ var VirtualRenderer = function(container, theme) {
this.$markerBack.update(this.layerConfig);
}
- if (changes & this.CHANGE_SIZE)
- this.$updateScrollBar();
+ if (changes & this.CHANGE_SIZE || changes & this.CHANGE_LINES) {
+ this.$updateScrollBarV();
+ this.$updateScrollBarH();
+ }
+
+ this._signal("afterRender");
};
+
+ this.$autosize = function(height, width) {
+ var height = this.session.getScreenLength() * this.lineHeight;
+ var maxHeight = this.$maxLines * this.lineHeight;
+ var desiredHeight = Math.max(
+ (this.$minLines||1) * this.lineHeight,
+ Math.min(maxHeight, height)
+ );
+ var vScroll = height > maxHeight;
+
+ if (desiredHeight != this.desiredHeight ||
+ this.$size.height != this.desiredHeight || vScroll != this.$vScroll) {
+ if (vScroll != this.$vScroll) {
+ this.$vScroll = vScroll;
+ this.scrollBarV.setVisible(vScroll);
+ }
+
+ var w = this.container.clientWidth;
+ this.container.style.height = desiredHeight + "px";
+ this.$updateCachedSize(true, this.$gutterWidth, w, desiredHeight);
+ this.desiredHeight = desiredHeight;
+ }
+ };
+
this.$computeLayerConfig = function() {
+ if (this.$maxLines && this.lineHeight > 1)
+ this.$autosize();
+
var session = this.session;
+
+ var hideScrollbars = this.$size.height <= 2 * this.lineHeight;
+ var screenLines = this.session.getScreenLength()
+ var maxHeight = screenLines * this.lineHeight;
var offset = this.scrollTop % this.lineHeight;
var minHeight = this.$size.scrollerHeight + this.lineHeight;
var longestLine = this.$getLongestLine();
+
+ var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
+ this.$size.scrollerWidth - longestLine - 2 * this.$padding < 0);
- var horizScroll = this.$horizScrollAlwaysVisible || this.$size.scrollerWidth - longestLine < 0;
- var horizScrollChanged = this.$horizScroll !== horizScroll;
- this.$horizScroll = horizScroll;
- if (horizScrollChanged) {
- this.scroller.style.overflowX = horizScroll ? "scroll" : "hidden";
- if (!horizScroll)
- this.session.setScrollLeft(0);
+ var hScrollChanged = this.$horizScroll !== horizScroll;
+ if (hScrollChanged) {
+ this.$horizScroll = horizScroll;
+ this.scrollBarH.setVisible(horizScroll);
}
- var maxHeight = this.session.getScreenLength() * this.lineHeight;
- this.session.setScrollTop(Math.max(0, Math.min(this.scrollTop, maxHeight - this.$size.scrollerHeight)));
+
+ if (!this.$maxLines && this.$scrollPastEnd) {
+ if (this.scrollTop > maxHeight - this.$size.scrollerHeight)
+ maxHeight += Math.min(
+ (this.$size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd,
+ this.scrollTop - maxHeight + this.$size.scrollerHeight
+ );
+ }
+
+ var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
+ this.$size.scrollerHeight - maxHeight < 0);
+ var vScrollChanged = this.$vScroll !== vScroll;
+ if (vScrollChanged) {
+ this.$vScroll = vScroll;
+ this.scrollBarV.setVisible(vScroll);
+ }
+
+ this.session.setScrollTop(Math.max(-this.scrollMargin.top,
+ Math.min(this.scrollTop, maxHeight - this.$size.scrollerHeight + this.scrollMargin.v)));
+
+ this.session.setScrollLeft(Math.max(-this.scrollMargin.left, Math.min(this.scrollLeft,
+ longestLine + 2 * this.$padding - this.$size.scrollerWidth + this.scrollMargin.h)));
var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
@@ -11367,6 +12766,14 @@ var VirtualRenderer = function(container, theme) {
offset = this.scrollTop - firstRowScreen * lineHeight;
+ var changes = 0;
+ if (hScrollChanged || vScrollChanged) {
+ changes = this.$updateCachedSize(true, this.gutterWidth, this.$size.width, this.$size.height);
+ this._signal("scrollbarVisibilityChanged");
+ if (vScrollChanged)
+ longestLine = this.$getLongestLine();
+ }
+
this.layerConfig = {
width : longestLine,
padding : this.$padding,
@@ -11385,8 +12792,8 @@ var VirtualRenderer = function(container, theme) {
this.content.style.marginTop = (-offset) + "px";
this.content.style.width = longestLine + 2 * this.$padding + "px";
this.content.style.height = minHeight + "px";
- if (horizScrollChanged)
- this.onResize(true);
+
+ return changes;
};
this.$updateLines = function() {
@@ -11399,7 +12806,7 @@ var VirtualRenderer = function(container, theme) {
if (firstRow > layerConfig.lastRow + 1) { return; }
if (lastRow < layerConfig.firstRow) { return; }
if (lastRow === Infinity) {
- if (this.showGutter)
+ if (this.$showGutter)
this.$gutterLayer.update(layerConfig);
this.$textLayer.update(layerConfig);
return;
@@ -11458,12 +12865,18 @@ var VirtualRenderer = function(container, theme) {
var left = pos.left;
var top = pos.top;
+
+ var scrollTop = this.$scrollAnimation ? this.session.getScrollTop() : this.scrollTop;
- if (this.scrollTop > top) {
+ if (scrollTop > top) {
if (offset)
top -= offset * this.$size.scrollerHeight;
+ if (top == 0)
+ top = - this.scrollMargin.top;
+ else if (top == 0)
+ top = + this.scrollMargin.bottom;
this.session.setScrollTop(top);
- } else if (this.scrollTop + this.$size.scrollerHeight < top + this.lineHeight) {
+ } else if (scrollTop + this.$size.scrollerHeight < top + this.lineHeight) {
if (offset)
top += offset * this.$size.scrollerHeight;
this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
@@ -11473,10 +12886,12 @@ var VirtualRenderer = function(container, theme) {
if (scrollLeft > left) {
if (left < this.$padding + 2 * this.layerConfig.characterWidth)
- left = 0;
+ left = -this.scrollMargin.left;
this.session.setScrollLeft(left);
} else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
+ } else if (scrollLeft <= this.$padding && left - scrollLeft < this.characterWidth) {
+ this.session.setScrollLeft(0);
}
};
this.getScrollTop = function() {
@@ -11536,29 +12951,42 @@ var VirtualRenderer = function(container, theme) {
this.animateScrolling = function(fromValue, callback) {
var toValue = this.scrollTop;
- if (this.$animatedScroll && Math.abs(fromValue - toValue) < 100000) {
- var _self = this;
- var steps = _self.$calcSteps(fromValue, toValue);
- this.$inScrollAnimation = true;
-
- clearInterval(this.$timer);
-
- _self.session.setScrollTop(steps.shift());
- this.$timer = setInterval(function() {
- if (steps.length) {
- _self.session.setScrollTop(steps.shift());
- _self.session.$scrollTop = toValue;
- } else if (toValue != null) {
- _self.session.$scrollTop = -1;
- _self.session.setScrollTop(toValue);
- toValue = null;
- } else {
- _self.$timer = clearInterval(_self.$timer);
- _self.$inScrollAnimation = false;
- callback && callback();
- }
- }, 10);
+ if (!this.$animatedScroll)
+ return;
+ var _self = this;
+
+ if (fromValue == toValue)
+ return;
+
+ if (this.$scrollAnimation) {
+ var oldSteps = this.$scrollAnimation.steps;
+ if (oldSteps.length) {
+ fromValue = oldSteps[0];
+ if (fromValue == toValue)
+ return;
+ }
}
+
+ var steps = _self.$calcSteps(fromValue, toValue);
+ this.$scrollAnimation = {from: fromValue, to: toValue, steps: steps};
+
+ clearInterval(this.$timer);
+
+ _self.session.setScrollTop(steps.shift());
+ this.$timer = setInterval(function() {
+ if (steps.length) {
+ _self.session.setScrollTop(steps.shift());
+ _self.session.$scrollTop = toValue;
+ } else if (toValue != null) {
+ _self.session.$scrollTop = -1;
+ _self.session.setScrollTop(toValue);
+ toValue = null;
+ } else {
+ _self.$timer = clearInterval(_self.$timer);
+ _self.$scrollAnimation = null;
+ callback && callback();
+ }
+ }, 10);
};
this.scrollToY = function(scrollTop) {
if (this.scrollTop !== scrollTop) {
@@ -11567,9 +12995,6 @@ var VirtualRenderer = function(container, theme) {
}
};
this.scrollToX = function(scrollLeft) {
- if (scrollLeft < 0)
- scrollLeft = 0;
-
if (this.scrollLeft !== scrollLeft)
this.scrollLeft = scrollLeft;
this.$loop.schedule(this.CHANGE_H_SCROLL);
@@ -11579,9 +13004,13 @@ var VirtualRenderer = function(container, theme) {
deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX);
};
this.isScrollableBy = function(deltaX, deltaY) {
- if (deltaY < 0 && this.session.getScrollTop() > 0)
+ if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top)
+ return true;
+ if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight
+ - this.layerConfig.maxHeight - (this.$size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
+ < -1 + this.scrollMargin.bottom)
return true;
- if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight < this.layerConfig.maxHeight)
+ if (deltaX)
return true;
};
@@ -11649,15 +13078,11 @@ var VirtualRenderer = function(container, theme) {
this.textarea.style.cssText = this.$composition.cssText;
this.$composition = null;
};
-
- this._loadTheme = function(name, callback) {
-
- };
- this.setTheme = function(theme) {
+ this.setTheme = function(theme, cb) {
var _self = this;
this.$themeValue = theme;
_self._dispatchEvent('themeChange',{theme:theme});
-
+
if (!theme || typeof theme == "string") {
var moduleName = theme || "ace/theme/textmate";
config.loadModule(["theme", moduleName], afterLoad);
@@ -11665,30 +13090,35 @@ var VirtualRenderer = function(container, theme) {
afterLoad(theme);
}
- function afterLoad(theme) {
+ function afterLoad(module) {
+ if (_self.$themeValue != theme)
+ return cb && cb();
+ if (!module.cssClass)
+ return;
dom.importCssString(
- theme.cssText,
- theme.cssClass,
+ module.cssText,
+ module.cssClass,
_self.container.ownerDocument
);
if (_self.theme)
dom.removeCssClass(_self.container, _self.theme.cssClass);
- _self.$theme = theme.cssClass;
+ _self.$theme = module.cssClass;
- _self.theme = theme;
- dom.addCssClass(_self.container, theme.cssClass);
- dom.setCssClass(_self.container, "ace_dark", theme.isDark);
+ _self.theme = module;
+ dom.addCssClass(_self.container, module.cssClass);
+ dom.setCssClass(_self.container, "ace_dark", module.isDark);
- var padding = theme.padding || 4;
+ var padding = module.padding || 4;
if (_self.$padding && padding != _self.$padding)
_self.setPadding(padding);
if (_self.$size) {
_self.$size.width = 0;
_self.onResize();
}
-
- _self._dispatchEvent('themeLoaded',{theme:theme});
+
+ _self._dispatchEvent('themeLoaded', {theme:module});
+ cb && cb();
}
};
this.getTheme = function() {
@@ -11707,10 +13137,131 @@ var VirtualRenderer = function(container, theme) {
}).call(VirtualRenderer.prototype);
+
+config.defineOptions(VirtualRenderer.prototype, "renderer", {
+ animatedScroll: {initialValue: false},
+ showInvisibles: {
+ set: function(value) {
+ if (this.$textLayer.setShowInvisibles(value))
+ this.$loop.schedule(this.CHANGE_TEXT);
+ },
+ initialValue: false
+ },
+ showPrintMargin: {
+ set: function() { this.$updatePrintMargin(); },
+ initialValue: true
+ },
+ printMarginColumn: {
+ set: function() { this.$updatePrintMargin(); },
+ initialValue: 80
+ },
+ printMargin: {
+ set: function(val) {
+ if (typeof val == "number")
+ this.$printMarginColumn = val;
+ this.$showPrintMargin = !!val;
+ this.$updatePrintMargin();
+ },
+ get: function() {
+ return this.$showPrintMargin && this.$printMarginColumn;
+ }
+ },
+ showGutter: {
+ set: function(show){
+ this.$gutter.style.display = show ? "block" : "none";
+ this.onGutterResize();
+ },
+ initialValue: true
+ },
+ fadeFoldWidgets: {
+ set: function(show) {
+ dom.setCssClass(this.$gutter, "ace_fade-fold-widgets", show);
+ },
+ initialValue: false
+ },
+ showFoldWidgets: {
+ set: function(show) {this.$gutterLayer.setShowFoldWidgets(show)},
+ initialValue: true
+ },
+ displayIndentGuides: {
+ set: function(show) {
+ if (this.$textLayer.setDisplayIndentGuides(show))
+ this.$loop.schedule(this.CHANGE_TEXT);
+ },
+ initialValue: true
+ },
+ highlightGutterLine: {
+ set: function(shouldHighlight) {
+ if (!this.$gutterLineHighlight) {
+ this.$gutterLineHighlight = dom.createElement("div");
+ this.$gutterLineHighlight.className = "ace_gutter-active-line";
+ this.$gutter.appendChild(this.$gutterLineHighlight);
+ return;
+ }
+
+ this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none";
+ if (this.$cursorLayer.$pixelPos)
+ this.$updateGutterLineHighlight();
+ },
+ initialValue: false,
+ value: true
+ },
+ hScrollBarAlwaysVisible: {
+ set: function(val) {
+ if (!this.$hScrollBarAlwaysVisible || !this.$horizScroll)
+ this.$loop.schedule(this.CHANGE_SCROLL);
+ },
+ initialValue: false
+ },
+ vScrollBarAlwaysVisible: {
+ set: function(val) {
+ if (!this.$vScrollBarAlwaysVisible || !this.$vScroll)
+ this.$loop.schedule(this.CHANGE_SCROLL);
+ },
+ initialValue: false
+ },
+ fontSize: {
+ set: function(size) {
+ if (typeof size == "number")
+ size = size + "px";
+ this.container.style.fontSize = size;
+ this.updateFontSize();
+ },
+ initialValue: 12
+ },
+ fontFamily: {
+ set: function(name) {
+ this.container.style.fontFamily = name;
+ this.updateFontSize();
+ }
+ },
+ maxLines: {
+ set: function(val) {
+ this.updateFull();
+ }
+ },
+ minLines: {
+ set: function(val) {
+ this.updateFull();
+ }
+ },
+ scrollPastEnd: {
+ set: function(val) {
+ val = +val || 0;
+ if (this.$scrollPastEnd == val)
+ return;
+ this.$scrollPastEnd = val;
+ this.$loop.schedule(this.CHANGE_SCROLL);
+ },
+ initialValue: 0,
+ handlesSet: true
+ }
+});
+
exports.VirtualRenderer = VirtualRenderer;
});
-define('ace/layer/gutter', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/lib/oop', 'ace/lib/lang', 'ace/lib/event_emitter'], function(require, exports, module) {
+ace.define('ace/layer/gutter', ['require', 'exports', 'module' , 'ace/lib/dom', 'ace/lib/oop', 'ace/lib/lang', 'ace/lib/event_emitter'], function(require, exports, module) {
var dom = require("../lib/dom");
@@ -11806,6 +13357,7 @@ var Gutter = function(parentEl) {
var foldWidgets = this.$showFoldWidgets && this.session.foldWidgets;
var breakpoints = this.session.$breakpoints;
var decorations = this.session.$decorations;
+ var firstLineNumber = this.session.$firstLineNumber;
var lastLineNumber = 0;
while (true) {
@@ -11822,7 +13374,7 @@ var Gutter = function(parentEl) {
"<div class='ace_gutter-cell ",
breakpoints[i] || "", decorations[i] || "", annotation.className,
"' style='height:", this.session.getRowLength(i) * config.lineHeight, "px;'>",
- lastLineNumber = i + 1
+ lastLineNumber = i + firstLineNumber
);
if (foldWidgets) {
@@ -11852,7 +13404,7 @@ var Gutter = function(parentEl) {
var gutterWidth = ("" + lastLineNumber).length * config.characterWidth;
var padding = this.$padding || this.$computePadding();
gutterWidth += padding.left + padding.right;
- if (gutterWidth !== this.gutterWidth) {
+ if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) {
this.gutterWidth = gutterWidth;
this.element.style.width = Math.ceil(this.gutterWidth) + "px";
this._emit("changeGutterWidth", gutterWidth);
@@ -11878,9 +13430,9 @@ var Gutter = function(parentEl) {
if (!this.element.firstChild)
return {left: 0, right: 0};
var style = dom.computedStyle(this.element.firstChild);
- this.$padding = {}
- this.$padding.left = parseInt(style.paddingLeft) + 1;
- this.$padding.right = parseInt(style.paddingRight);
+ this.$padding = {};
+ this.$padding.left = parseInt(style.paddingLeft) + 1 || 0;
+ this.$padding.right = parseInt(style.paddingRight) || 0;
return this.$padding;
};
@@ -11899,7 +13451,7 @@ exports.Gutter = Gutter;
});
-define('ace/layer/marker', ['require', 'exports', 'module' , 'ace/range', 'ace/lib/dom'], function(require, exports, module) {
+ace.define('ace/layer/marker', ['require', 'exports', 'module' , 'ace/range', 'ace/lib/dom'], function(require, exports, module) {
var Range = require("../range").Range;
@@ -11953,6 +13505,8 @@ var Marker = function(parentEl) {
marker.renderer(html, range, left, top, config);
} else if (marker.type == "fullLine") {
this.drawFullLineMarker(html, range, marker.clazz, config);
+ } else if (marker.type == "screenLine") {
+ this.drawScreenLineMarker(html, range, marker.clazz, config);
} else if (range.isMultiLine()) {
if (marker.type == "text")
this.drawTextMarker(html, range, marker.clazz, config);
@@ -11968,37 +13522,38 @@ var Marker = function(parentEl) {
this.$getTop = function(row, layerConfig) {
return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
};
- this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig) {
+ this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
var row = range.start.row;
var lineRange = new Range(
row, range.start.column,
row, this.session.getScreenLastRowColumn(row)
);
- this.drawSingleLineMarker(stringBuilder, lineRange, clazz + " ace_start", layerConfig, 1, "text");
+ this.drawSingleLineMarker(stringBuilder, lineRange, clazz + " ace_start", layerConfig, 1, extraStyle);
row = range.end.row;
lineRange = new Range(row, 0, row, range.end.column);
- this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 0, "text");
+ this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 0, extraStyle);
for (row = range.start.row + 1; row < range.end.row; row++) {
lineRange.start.row = row;
lineRange.end.row = row;
lineRange.end.column = this.session.getScreenLastRowColumn(row);
- this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 1, "text");
+ this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 1, extraStyle);
}
};
- this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, type) {
+ this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
var padding = this.$padding;
var height = config.lineHeight;
var top = this.$getTop(range.start.row, config);
var left = padding + range.start.column * config.characterWidth;
+ extraStyle = extraStyle || "";
stringBuilder.push(
"<div class='", clazz, " ace_start' style='",
"height:", height, "px;",
"right:0;",
"top:", top, "px;",
- "left:", left, "px;'></div>"
+ "left:", left, "px;", extraStyle, "'></div>"
);
top = this.$getTop(range.end.row, config);
var width = range.end.column * config.characterWidth;
@@ -12008,7 +13563,7 @@ var Marker = function(parentEl) {
"height:", height, "px;",
"width:", width, "px;",
"top:", top, "px;",
- "left:", padding, "px;'></div>"
+ "left:", padding, "px;", extraStyle, "'></div>"
);
height = (range.end.row - range.start.row - 1) * config.lineHeight;
if (height < 0)
@@ -12020,10 +13575,10 @@ var Marker = function(parentEl) {
"height:", height, "px;",
"right:0;",
"top:", top, "px;",
- "left:", padding, "px;'></div>"
+ "left:", padding, "px;", extraStyle, "'></div>"
);
};
- this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength) {
+ this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
var height = config.lineHeight;
var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth;
@@ -12035,11 +13590,11 @@ var Marker = function(parentEl) {
"height:", height, "px;",
"width:", width, "px;",
"top:", top, "px;",
- "left:", left,"px;'></div>"
+ "left:", left, "px;", extraStyle || "", "'></div>"
);
};
- this.drawFullLineMarker = function(stringBuilder, range, clazz, config) {
+ this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
var top = this.$getTop(range.start.row, config);
var height = config.lineHeight;
if (range.start.row != range.end.row)
@@ -12049,9 +13604,21 @@ var Marker = function(parentEl) {
"<div class='", clazz, "' style='",
"height:", height, "px;",
"top:", top, "px;",
- "left:0;right:0;'></div>"
+ "left:0;right:0;", extraStyle || "", "'></div>"
);
- }
+ };
+
+ this.drawScreenLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
+ var top = this.$getTop(range.start.row, config);
+ var height = config.lineHeight;
+
+ stringBuilder.push(
+ "<div class='", clazz, "' style='",
+ "height:", height, "px;",
+ "top:", top, "px;",
+ "left:0;right:0;", extraStyle || "", "'></div>"
+ );
+ };
}).call(Marker.prototype);
@@ -12059,7 +13626,7 @@ exports.Marker = Marker;
});
-define('ace/layer/text', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/dom', 'ace/lib/lang', 'ace/lib/useragent', 'ace/lib/event_emitter'], function(require, exports, module) {
+ace.define('ace/layer/text', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/dom', 'ace/lib/lang', 'ace/lib/useragent', 'ace/lib/event_emitter'], function(require, exports, module) {
var oop = require("../lib/oop");
@@ -12662,7 +14229,7 @@ exports.Text = Text;
});
-define('ace/layer/cursor', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
+ace.define('ace/layer/cursor', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
var dom = require("../lib/dom");
@@ -12804,7 +14371,7 @@ var Cursor = function(parentEl) {
selections = [{cursor: null}];
}
- for (var i = selections.length; i--; ) {
+ for (var i = 0, n = selections.length; i < n; i++) {
var pixelPos = this.getPixelPosition(selections[i].cursor, true);
if ((pixelPos.top > config.height + config.offset ||
pixelPos.top < -config.offset) && i > 1) {
@@ -12848,14 +14415,14 @@ exports.Cursor = Cursor;
});
-define('ace/scrollbar', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/dom', 'ace/lib/event', 'ace/lib/event_emitter'], function(require, exports, module) {
+ace.define('ace/scrollbar', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/dom', 'ace/lib/event', 'ace/lib/event_emitter'], function(require, exports, module) {
var oop = require("./lib/oop");
var dom = require("./lib/dom");
var event = require("./lib/event");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
-var ScrollBar = function(parent) {
+var ScrollBarV = function(parent, renderer) {
this.element = dom.createElement("div");
this.element.className = "ace_scrollbar";
@@ -12864,43 +14431,108 @@ var ScrollBar = function(parent) {
this.element.appendChild(this.inner);
parent.appendChild(this.element);
+ renderer.$scrollbarWidth =
this.width = dom.scrollbarWidth(parent.ownerDocument);
+ this.fullWidth = this.width;
this.element.style.width = (this.width || 15) + 5 + "px";
+ this.setVisible(false);
+ this.element.style.overflowY = "scroll";
+
+ event.addListener(this.element, "scroll", this.onScrollV.bind(this));
+};
- event.addListener(this.element, "scroll", this.onScroll.bind(this));
+var ScrollBarH = function(parent, renderer) {
+ this.element = dom.createElement("div");
+ this.element.className = "ace_scrollbar-h";
+
+ this.inner = dom.createElement("div");
+ this.inner.className = "ace_scrollbar-inner";
+ this.element.appendChild(this.inner);
+
+ parent.appendChild(this.element);
+ this.height = renderer.$scrollbarWidth;
+ this.fullHeight = this.height;
+ this.element.style.height = (this.height || 15) + 5 + "px";
+ this.setVisible(false);
+ this.element.style.overflowX = "scroll";
+
+ event.addListener(this.element, "scroll", this.onScrollH.bind(this));
};
(function() {
oop.implement(this, EventEmitter);
- this.onScroll = function() {
+
+ this.setVisible = function(show) {
+ if (show) {
+ this.element.style.display = "";
+ if (this.fullWidth)
+ this.width = this.fullWidth;
+ if (this.fullHeight)
+ this.height = this.fullHeight;
+ } else {
+ this.element.style.display = "none";
+ this.height = this.width = 0;
+ }
+ };
+ this.onScrollV = function() {
if (!this.skipEvent) {
this.scrollTop = this.element.scrollTop;
this._emit("scroll", {data: this.scrollTop});
}
this.skipEvent = false;
};
+ this.onScrollH = function() {
+ if (!this.skipEvent) {
+ this.scrollLeft = this.element.scrollLeft;
+ this._emit("scroll", {data: this.scrollLeft});
+ }
+ this.skipEvent = false;
+ };
this.getWidth = function() {
return this.width;
};
+
+ this.getHeight = function() {
+ return this.height;
+ };
this.setHeight = function(height) {
this.element.style.height = height + "px";
};
+
+ this.setWidth = function(width) {
+ this.element.style.width = width + "px";
+ };
this.setInnerHeight = function(height) {
this.inner.style.height = height + "px";
};
+
+ this.setInnerWidth = function(width) {
+ this.inner.style.width = width + "px";
+ };
this.setScrollTop = function(scrollTop) {
if (this.scrollTop != scrollTop) {
this.skipEvent = true;
this.scrollTop = this.element.scrollTop = scrollTop;
}
};
+ this.setScrollLeft = function(scrollLeft) {
+ if (this.scrollLeft != scrollLeft) {
+ this.skipEvent = true;
+ this.scrollLeft = this.element.scrollLeft = scrollLeft;
+ }
+ };
+
+}).call(ScrollBarV.prototype);
+ScrollBarH.prototype = ScrollBarV.prototype;
-}).call(ScrollBar.prototype);
-exports.ScrollBar = ScrollBar;
+
+exports.ScrollBar = ScrollBarV; // backward compatibility
+exports.ScrollBarV = ScrollBarV;
+exports.ScrollBarH = ScrollBarH;
});
-define('ace/renderloop', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) {
+ace.define('ace/renderloop', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) {
var event = require("./lib/event");
@@ -12937,676 +14569,7 @@ var RenderLoop = function(onRender, win) {
exports.RenderLoop = RenderLoop;
});
-define('ace/worker/worker_client', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/config'], function(require, exports, module) {
-
-
-var oop = require("../lib/oop");
-var EventEmitter = require("../lib/event_emitter").EventEmitter;
-var config = require("../config");
-
-var WorkerClient = function(topLevelNamespaces, mod, classname) {
- this.changeListener = this.changeListener.bind(this);
- this.onMessage = this.onMessage.bind(this);
- this.onError = this.onError.bind(this);
-
- // TODO: Hack!
- if (classname == "AutocompleteWorker") {
- config.set("packaged", "false");
- }
-
- var workerUrl;
- if (config.get("packaged")) {
- workerUrl = config.moduleUrl(mod, "worker");
- } else {
- var normalizePath = this.$normalizePath;
- if (typeof require.supports !== "undefined" && require.supports.indexOf("ucjs2-pinf-0") >= 0) {
- workerUrl = require.nameToUrl("ace/worker/worker_sourcemint");
- } else {
- if (require.nameToUrl && !require.toUrl)
- require.toUrl = require.nameToUrl;
- workerUrl = normalizePath(require.toUrl("ace/worker/worker", null, "_"));
- }
-
- var tlns = {};
- topLevelNamespaces.forEach(function(ns) {
- tlns[ns] = normalizePath(require.toUrl(ns, null, "_").replace(/.js(\?.*)?$/, ""));
- });
- }
-
- // TODO: Hack!
- if (mod == "ace/mode/autocomplete_worker") {
- workerUrl = "../../js/libs/ace/worker-autocomplete.js";
- }
-
- this.$worker = new Worker(workerUrl);
- this.$worker.postMessage({
- init : true,
- tlns: tlns,
- module: mod,
- classname: classname
- });
-
- this.callbackId = 1;
- this.callbacks = {};
-
- this.$worker.onerror = this.onError;
- this.$worker.onmessage = this.onMessage;
-};
-
-(function(){
-
- oop.implement(this, EventEmitter);
-
- this.onError = function(e) {
- window.console && console.log && console.log(e);
- throw e;
- };
-
- this.onMessage = function(e) {
- var msg = e.data;
- switch(msg.type) {
- case "log":
- window.console && console.log && console.log.apply(console, msg.data);
- break;
-
- case "event":
- this._emit(msg.name, {data: msg.data});
- break;
-
- case "call":
- var callback = this.callbacks[msg.id];
- if (callback) {
- callback(msg.data);
- delete this.callbacks[msg.id];
- }
- break;
- }
- };
-
- this.$normalizePath = function(path) {
- if (!location.host) // needed for file:// protocol
- return path;
- path = path.replace(/^[a-z]+:\/\/[^\/]+/, ""); // Remove domain name and rebuild it
- path = location.protocol + "//" + location.host
- + (path.charAt(0) == "/" ? "" : location.pathname.replace(/\/[^\/]*$/, ""))
- + "/" + path.replace(/^[\/]+/, "");
- return path;
- };
-
- this.terminate = function() {
- this._emit("terminate", {});
- this.$worker.terminate();
- this.$worker = null;
- this.$doc.removeEventListener("change", this.changeListener);
- this.$doc = null;
- };
-
- this.send = function(cmd, args) {
- this.$worker.postMessage({command: cmd, args: args});
- };
-
- this.call = function(cmd, args, callback) {
- if (callback) {
- var id = this.callbackId++;
- this.callbacks[id] = callback;
- args.push(id);
- }
- this.send(cmd, args);
- };
-
- this.emit = function(event, data) {
- try {
- this.$worker.postMessage({event: event, data: {data: data.data}});
- }
- catch(ex) {}
- };
-
- this.attachToDocument = function(doc, data, ignore) {
- if (this.$doc && !ignore)
- this.terminate();
-
- this.$doc = doc;
- this.call("setValue", [doc.getValue(), data]);
- doc.on("change", this.changeListener);
- };
-
- this.changeListener = function(e) {
- e.range = {
- start: e.data.range.start,
- end: e.data.range.end
- };
- this.emit("change", e);
- };
-
-}).call(WorkerClient.prototype);
-
-
-var UIWorkerClient = function(topLevelNamespaces, mod, classname) {
- this.changeListener = this.changeListener.bind(this);
- this.callbackId = 1;
- this.callbacks = {};
- this.messageBuffer = [];
-
- var main = null;
- var sender = Object.create(EventEmitter);
- var _self = this;
-
- this.$worker = {}
- this.$worker.terminate = function() {};
- this.$worker.postMessage = function(e) {
- _self.messageBuffer.push(e);
- main && setTimeout(processNext);
- };
-
- var processNext = function() {
- var msg = _self.messageBuffer.shift();
- if (msg.command)
- main[msg.command].apply(main, msg.args);
- else if (msg.event)
- sender._emit(msg.event, msg.data);
- };
-
- sender.postMessage = function(msg) {
- _self.onMessage({data: msg});
- };
- sender.callback = function(data, callbackId) {
- this.postMessage({type: "call", id: callbackId, data: data});
- };
- sender.emit = function(name, data) {
- this.postMessage({type: "event", name: name, data: data});
- };
-
- require([mod], function(Main) {
- main = new Main[classname](sender);
- while (_self.messageBuffer.length)
- processNext();
- });
-};
-
-UIWorkerClient.prototype = WorkerClient.prototype;
-
-exports.UIWorkerClient = UIWorkerClient;
-exports.WorkerClient = WorkerClient;
-
-});
-
-define('ace/commands/default_commands', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/config'], function(require, exports, module) {
-
-
-var lang = require("../lib/lang");
-var config = require("../config");
-
-function bindKey(win, mac) {
- return {
- win: win,
- mac: mac
- };
-}
-
-exports.commands = [{
- name: "selectall",
- bindKey: bindKey("Ctrl-A", "Command-A"),
- exec: function(editor) { editor.selectAll(); },
- readOnly: true
-}, {
- name: "centerselection",
- bindKey: bindKey(null, "Ctrl-L"),
- exec: function(editor) { editor.centerSelection(); },
- readOnly: true
-}, {
- name: "gotoline",
- bindKey: bindKey("Ctrl-L", "Command-L"),
- exec: function(editor) {
- var line = parseInt(prompt("Enter line number:"), 10);
- if (!isNaN(line)) {
- editor.gotoLine(line);
- }
- },
- readOnly: true
-}, {
- name: "fold",
- bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
- exec: function(editor) { editor.session.toggleFold(false); },
- readOnly: true
-}, {
- name: "unfold",
- bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
- exec: function(editor) { editor.session.toggleFold(true); },
- readOnly: true
-}, {
- name: "foldall",
- bindKey: bindKey("Alt-0", "Command-Option-0"),
- exec: function(editor) { editor.session.foldAll(); },
- readOnly: true
-}, {
- name: "unfoldall",
- bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"),
- exec: function(editor) { editor.session.unfold(); },
- readOnly: true
-}, {
- name: "findnext",
- bindKey: bindKey("Ctrl-K", "Command-G"),
- exec: function(editor) { editor.findNext(); },
- readOnly: true
-}, {
- name: "findprevious",
- bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
- exec: function(editor) { editor.findPrevious(); },
- readOnly: true
-}, {
- name: "find",
- bindKey: bindKey("Ctrl-F", "Command-F"),
- exec: function(editor) {
- config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor)});
- },
- readOnly: true
-}, {
- name: "overwrite",
- bindKey: "Insert",
- exec: function(editor) { editor.toggleOverwrite(); },
- readOnly: true
-}, {
- name: "selecttostart",
- bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"),
- exec: function(editor) { editor.getSelection().selectFileStart(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "gotostart",
- bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
- exec: function(editor) { editor.navigateFileStart(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "selectup",
- bindKey: bindKey("Shift-Up", "Shift-Up"),
- exec: function(editor) { editor.getSelection().selectUp(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "golineup",
- bindKey: bindKey("Up", "Up|Ctrl-P"),
- exec: function(editor, args) { editor.navigateUp(args.times); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "selecttoend",
- bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-Down"),
- exec: function(editor) { editor.getSelection().selectFileEnd(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "gotoend",
- bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
- exec: function(editor) { editor.navigateFileEnd(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "selectdown",
- bindKey: bindKey("Shift-Down", "Shift-Down"),
- exec: function(editor) { editor.getSelection().selectDown(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "golinedown",
- bindKey: bindKey("Down", "Down|Ctrl-N"),
- exec: function(editor, args) { editor.navigateDown(args.times); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "selectwordleft",
- bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
- exec: function(editor) { editor.getSelection().selectWordLeft(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "gotowordleft",
- bindKey: bindKey("Ctrl-Left", "Option-Left"),
- exec: function(editor) { editor.navigateWordLeft(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "selecttolinestart",
- bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
- exec: function(editor) { editor.getSelection().selectLineStart(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "gotolinestart",
- bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
- exec: function(editor) { editor.navigateLineStart(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "selectleft",
- bindKey: bindKey("Shift-Left", "Shift-Left"),
- exec: function(editor) { editor.getSelection().selectLeft(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "gotoleft",
- bindKey: bindKey("Left", "Left|Ctrl-B"),
- exec: function(editor, args) { editor.navigateLeft(args.times); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "selectwordright",
- bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
- exec: function(editor) { editor.getSelection().selectWordRight(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "gotowordright",
- bindKey: bindKey("Ctrl-Right", "Option-Right"),
- exec: function(editor) { editor.navigateWordRight(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "selecttolineend",
- bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
- exec: function(editor) { editor.getSelection().selectLineEnd(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "gotolineend",
- bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
- exec: function(editor) { editor.navigateLineEnd(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "selectright",
- bindKey: bindKey("Shift-Right", "Shift-Right"),
- exec: function(editor) { editor.getSelection().selectRight(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "gotoright",
- bindKey: bindKey("Right", "Right|Ctrl-F"),
- exec: function(editor, args) { editor.navigateRight(args.times); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "selectpagedown",
- bindKey: "Shift-PageDown",
- exec: function(editor) { editor.selectPageDown(); },
- readOnly: true
-}, {
- name: "pagedown",
- bindKey: bindKey(null, "Option-PageDown"),
- exec: function(editor) { editor.scrollPageDown(); },
- readOnly: true
-}, {
- name: "gotopagedown",
- bindKey: bindKey("PageDown", "PageDown|Ctrl-V"),
- exec: function(editor) { editor.gotoPageDown(); },
- readOnly: true
-}, {
- name: "selectpageup",
- bindKey: "Shift-PageUp",
- exec: function(editor) { editor.selectPageUp(); },
- readOnly: true
-}, {
- name: "pageup",
- bindKey: bindKey(null, "Option-PageUp"),
- exec: function(editor) { editor.scrollPageUp(); },
- readOnly: true
-}, {
- name: "gotopageup",
- bindKey: "PageUp",
- exec: function(editor) { editor.gotoPageUp(); },
- readOnly: true
-}, {
- name: "scrollup",
- bindKey: bindKey("Ctrl-Up", null),
- exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); },
- readOnly: true
-}, {
- name: "scrolldown",
- bindKey: bindKey("Ctrl-Down", null),
- exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); },
- readOnly: true
-}, {
- name: "selectlinestart",
- bindKey: "Shift-Home",
- exec: function(editor) { editor.getSelection().selectLineStart(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "selectlineend",
- bindKey: "Shift-End",
- exec: function(editor) { editor.getSelection().selectLineEnd(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "togglerecording",
- bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
- exec: function(editor) { editor.commands.toggleRecording(editor); },
- readOnly: true
-}, {
- name: "replaymacro",
- bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
- exec: function(editor) { editor.commands.replay(editor); },
- readOnly: true
-}, {
- name: "jumptomatching",
- bindKey: bindKey("Ctrl-P", "Ctrl-Shift-P"),
- exec: function(editor) { editor.jumpToMatching(); },
- multiSelectAction: "forEach",
- readOnly: true
-}, {
- name: "selecttomatching",
- bindKey: bindKey("Ctrl-Shift-P", null),
- exec: function(editor) { editor.jumpToMatching(true); },
- readOnly: true
-},
-{
- name: "cut",
- exec: function(editor) {
- var range = editor.getSelectionRange();
- editor._emit("cut", range);
-
- if (!editor.selection.isEmpty()) {
- editor.session.remove(range);
- editor.clearSelection();
- }
- },
- multiSelectAction: "forEach"
-}, {
- name: "removeline",
- bindKey: bindKey("Ctrl-D", "Command-D"),
- exec: function(editor) { editor.removeLines(); },
- multiSelectAction: "forEach"
-}, {
- name: "duplicateSelection",
- bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
- exec: function(editor) { editor.duplicateSelection(); },
- multiSelectAction: "forEach"
-}, {
- name: "sortlines",
- bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
- exec: function(editor) { editor.sortLines(); },
- multiSelectAction: "forEach"
-}, {
- name: "togglecomment",
- bindKey: bindKey("Ctrl-/", "Command-/"),
- exec: function(editor) { editor.toggleCommentLines(); },
- multiSelectAction: "forEach"
-}, {
- name: "modifyNumberUp",
- bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
- exec: function(editor) { editor.modifyNumber(1); },
- multiSelectAction: "forEach"
-}, {
- name: "modifyNumberDown",
- bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
- exec: function(editor) { editor.modifyNumber(-1); },
- multiSelectAction: "forEach"
-}, {
- name: "replace",
- bindKey: bindKey("Ctrl-H", "Command-Option-F"),
- exec: function(editor) {
- config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor, true)});
- }
-}, {
- name: "undo",
- bindKey: bindKey("Ctrl-Z", "Command-Z"),
- exec: function(editor) { editor.undo(); }
-}, {
- name: "redo",
- bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
- exec: function(editor) { editor.redo(); }
-}, {
- name: "copylinesup",
- bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"),
- exec: function(editor) { editor.copyLinesUp(); }
-}, {
- name: "movelinesup",
- bindKey: bindKey("Alt-Up", "Option-Up"),
- exec: function(editor) { editor.moveLinesUp(); }
-}, {
- name: "copylinesdown",
- bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"),
- exec: function(editor) { editor.copyLinesDown(); }
-}, {
- name: "movelinesdown",
- bindKey: bindKey("Alt-Down", "Option-Down"),
- exec: function(editor) { editor.moveLinesDown(); }
-}, {
- name: "del",
- bindKey: bindKey("Delete", "Delete|Ctrl-D"),
- exec: function(editor) { editor.remove("right"); },
- multiSelectAction: "forEach"
-}, {
- name: "backspace",
- bindKey: bindKey(
- "Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
- "Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"
- ),
- exec: function(editor) { editor.remove("left"); },
- multiSelectAction: "forEach"
-}, {
- name: "removetolinestart",
- bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
- exec: function(editor) { editor.removeToLineStart(); },
- multiSelectAction: "forEach"
-}, {
- name: "removetolineend",
- bindKey: bindKey("Alt-Delete", "Ctrl-K"),
- exec: function(editor) { editor.removeToLineEnd(); },
- multiSelectAction: "forEach"
-}, {
- name: "removewordleft",
- bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
- exec: function(editor) { editor.removeWordLeft(); },
- multiSelectAction: "forEach"
-}, {
- name: "removewordright",
- bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
- exec: function(editor) { editor.removeWordRight(); },
- multiSelectAction: "forEach"
-}, {
- name: "outdent",
- bindKey: bindKey("Shift-Tab", "Shift-Tab"),
- exec: function(editor) { editor.blockOutdent(); },
- multiSelectAction: "forEach"
-}, {
- name: "indent",
- bindKey: bindKey("Tab", "Tab"),
- exec: function(editor) { editor.indent(); },
- multiSelectAction: "forEach"
-},{
- name: "blockoutdent",
- bindKey: bindKey("Ctrl-[", "Ctrl-["),
- exec: function(editor) { editor.blockOutdent(); },
- multiSelectAction: "forEach"
-},{
- name: "blockindent",
- bindKey: bindKey("Ctrl-]", "Ctrl-]"),
- exec: function(editor) { editor.blockIndent(); },
- multiSelectAction: "forEach"
-}, {
- name: "insertstring",
- exec: function(editor, str) { editor.insert(str); },
- multiSelectAction: "forEach"
-}, {
- name: "inserttext",
- exec: function(editor, args) {
- editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
- },
- multiSelectAction: "forEach"
-}, {
- name: "splitline",
- bindKey: bindKey(null, "Ctrl-O"),
- exec: function(editor) { editor.splitLine(); },
- multiSelectAction: "forEach"
-}, {
- name: "transposeletters",
- bindKey: bindKey("Ctrl-T", "Ctrl-T"),
- exec: function(editor) { editor.transposeLetters(); },
- multiSelectAction: function(editor) {editor.transposeSelections(1); }
-}, {
- name: "touppercase",
- bindKey: bindKey("Ctrl-U", "Ctrl-U"),
- exec: function(editor) { editor.toUpperCase(); },
- multiSelectAction: "forEach"
-}, {
- name: "tolowercase",
- bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
- exec: function(editor) { editor.toLowerCase(); },
- multiSelectAction: "forEach"
-}];
-
-});
-
-define('ace/undomanager', ['require', 'exports', 'module' ], function(require, exports, module) {
-var UndoManager = function() {
- this.reset();
-};
-
-(function() {
- this.execute = function(options) {
- var deltas = options.args[0];
- this.$doc = options.args[1];
- this.$undoStack.push(deltas);
- this.$redoStack = [];
- };
- this.undo = function(dontSelect) {
- var deltas = this.$undoStack.pop();
- var undoSelectionRange = null;
- if (deltas) {
- undoSelectionRange =
- this.$doc.undoChanges(deltas, dontSelect);
- this.$redoStack.push(deltas);
- }
- return undoSelectionRange;
- };
- this.redo = function(dontSelect) {
- var deltas = this.$redoStack.pop();
- var redoSelectionRange = null;
- if (deltas) {
- redoSelectionRange =
- this.$doc.redoChanges(deltas, dontSelect);
- this.$undoStack.push(deltas);
- }
- return redoSelectionRange;
- };
- this.reset = function() {
- this.$undoStack = [];
- this.$redoStack = [];
- };
- this.hasUndo = function() {
- return this.$undoStack.length > 0;
- };
- this.hasRedo = function() {
- return this.$redoStack.length > 0;
- };
-
-}).call(UndoManager.prototype);
-
-exports.UndoManager = UndoManager;
-});
-
-define('ace/multi_select', ['require', 'exports', 'module' , 'ace/range_list', 'ace/range', 'ace/selection', 'ace/mouse/multi_select_handler', 'ace/lib/event', 'ace/lib/lang', 'ace/commands/multi_select_commands', 'ace/search', 'ace/edit_session', 'ace/editor'], function(require, exports, module) {
+ace.define('ace/multi_select', ['require', 'exports', 'module' , 'ace/range_list', 'ace/range', 'ace/selection', 'ace/mouse/multi_select_handler', 'ace/lib/event', 'ace/lib/lang', 'ace/commands/multi_select_commands', 'ace/search', 'ace/edit_session', 'ace/editor', 'ace/config'], function(require, exports, module) {
var RangeList = require("./range_list").RangeList;
var Range = require("./range").Range;
@@ -13640,9 +14603,13 @@ var EditSession = require("./edit_session").EditSession;
if (!this.inMultiSelectMode && this.rangeCount == 0) {
var oldRange = this.toOrientedRange();
- if (range.intersects(oldRange))
+ this.rangeList.add(oldRange);
+ this.rangeList.add(range);
+ if (this.rangeList.ranges.length != 2) {
+ this.rangeList.removeAll();
return $blockChangeEvents || this.fromOrientedRange(range);
-
+ }
+ this.rangeList.removeAll();
this.rangeList.add(oldRange);
this.$onAddRange(oldRange);
}
@@ -13913,7 +14880,7 @@ var Editor = require("./editor").Editor;
this.setStyle("ace_multiselect");
this.keyBinding.addKeyboardHandler(commands.keyboardHandler);
- this.commands.on("exec", this.$onMultiSelectExec);
+ this.commands.setDefaultHandler("exec", this.$onMultiSelectExec);
this.renderer.updateCursor();
this.renderer.updateBackMarkers();
@@ -13927,7 +14894,7 @@ var Editor = require("./editor").Editor;
this.unsetStyle("ace_multiselect");
this.keyBinding.removeKeyboardHandler(commands.keyboardHandler);
- this.commands.removeEventListener("exec", this.$onMultiSelectExec);
+ this.commands.removeDefaultHandler("exec", this.$onMultiSelectExec);
this.renderer.updateCursor();
this.renderer.updateBackMarkers();
};
@@ -13938,36 +14905,45 @@ var Editor = require("./editor").Editor;
if (!editor.multiSelect)
return;
if (!command.multiSelectAction) {
- command.exec(editor, e.args || {});
+ var result = command.exec(editor, e.args || {});
editor.multiSelect.addRange(editor.multiSelect.toOrientedRange());
editor.multiSelect.mergeOverlappingRanges();
} else if (command.multiSelectAction == "forEach") {
- editor.forEachSelection(command, e.args);
+ result = editor.forEachSelection(command, e.args);
+ } else if (command.multiSelectAction == "forEachLine") {
+ result = editor.forEachSelection(command, e.args, true);
} else if (command.multiSelectAction == "single") {
editor.exitMultiSelectMode();
- command.exec(editor, e.args || {});
+ result = command.exec(editor, e.args || {});
} else {
- command.multiSelectAction(editor, e.args || {});
+ result = command.multiSelectAction(editor, e.args || {});
}
- e.preventDefault();
+ return result;
};
- this.forEachSelection = function(cmd, args) {
+ this.forEachSelection = function(cmd, args, $byLines) {
if (this.inVirtualSelectionMode)
return;
var session = this.session;
var selection = this.selection;
var rangeList = selection.rangeList;
-
+ var result;
+
var reg = selection._eventRegistry;
selection._eventRegistry = {};
var tmpSel = new Selection(session);
this.inVirtualSelectionMode = true;
for (var i = rangeList.ranges.length; i--;) {
+ if ($byLines) {
+ while (i > 0 && rangeList.ranges[i].start.row == rangeList.ranges[i - 1].end.row)
+ i--;
+ }
tmpSel.fromOrientedRange(rangeList.ranges[i]);
this.selection = session.selection = tmpSel;
- cmd.exec(this, args || {});
+ var cmdResult = cmd.exec(this, args || {});
+ if (!result == undefined)
+ result = cmdResult;
tmpSel.toOrientedRange(rangeList.ranges[i]);
}
tmpSel.detach();
@@ -13976,46 +14952,54 @@ var Editor = require("./editor").Editor;
this.inVirtualSelectionMode = false;
selection._eventRegistry = reg;
selection.mergeOverlappingRanges();
-
+
+ var anim = this.renderer.$scrollAnimation;
this.onCursorChange();
this.onSelectionChange();
+ if (anim && anim.from == anim.to)
+ this.renderer.animateScrolling(anim.from);
+
+ return result;
};
this.exitMultiSelectMode = function() {
- if (this.inVirtualSelectionMode)
+ if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
return;
this.multiSelect.toSingleRange();
};
this.getCopyText = function() {
var text = "";
- if (this.inMultiSelectMode) {
+ if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
var ranges = this.multiSelect.rangeList.ranges;
- text = [];
+ var buf = [];
for (var i = 0; i < ranges.length; i++) {
- text.push(this.session.getTextRange(ranges[i]));
+ buf.push(this.session.getTextRange(ranges[i]));
}
- text = text.join(this.session.getDocument().getNewLineCharacter());
+ var nl = this.session.getDocument().getNewLineCharacter();
+ text = buf.join(nl);
+ if (text.length == (buf.length - 1) * nl.length)
+ text = "";
} else if (!this.selection.isEmpty()) {
text = this.session.getTextRange(this.getSelectionRange());
}
-
+ this._signal("copy", text);
return text;
};
this.onPaste = function(text) {
if (this.$readOnly)
return;
- this._emit("paste", text);
- if (!this.inMultiSelectMode)
+ this._signal("paste", text);
+ if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
return this.insert(text);
var lines = text.split(/\r\n|\r|\n/);
var ranges = this.selection.rangeList.ranges;
- if (lines.length > ranges.length || (lines.length <= 2 || !lines[1]))
+ if (lines.length > ranges.length || lines.length < 2 || !lines[1])
return this.commands.exec("insertstring", this, text);
- for (var i = ranges.length; i--; ) {
+ for (var i = ranges.length; i--;) {
var range = ranges[i];
if (!range.isEmpty())
this.session.remove(range);
@@ -14263,13 +15247,10 @@ exports.onSessionChange = function(e) {
var oldSession = e.oldSession;
if (oldSession) {
- if (oldSession.multiSelect && oldSession.multiSelect.editor == this)
- oldSession.multiSelect.editor = null;
-
- session.multiSelect.removeEventListener("addRange", this.$onAddRange);
- session.multiSelect.removeEventListener("removeRange", this.$onRemoveRange);
- session.multiSelect.removeEventListener("multiSelect", this.$onMultiSelect);
- session.multiSelect.removeEventListener("singleSelect", this.$onSingleSelect);
+ oldSession.multiSelect.removeEventListener("addRange", this.$onAddRange);
+ oldSession.multiSelect.removeEventListener("removeRange", this.$onRemoveRange);
+ oldSession.multiSelect.removeEventListener("multiSelect", this.$onMultiSelect);
+ oldSession.multiSelect.removeEventListener("singleSelect", this.$onSingleSelect);
}
session.multiSelect.on("addRange", this.$onAddRange);
@@ -14285,13 +15266,16 @@ exports.onSessionChange = function(e) {
}
};
function MultiSelect(editor) {
+ if (editor.$multiselectOnSessionChange)
+ return;
editor.$onAddRange = editor.$onAddRange.bind(editor);
editor.$onRemoveRange = editor.$onRemoveRange.bind(editor);
editor.$onMultiSelect = editor.$onMultiSelect.bind(editor);
editor.$onSingleSelect = editor.$onSingleSelect.bind(editor);
+ editor.$multiselectOnSessionChange = exports.onSessionChange.bind(editor);
- exports.onSessionChange.call(editor, editor);
- editor.on("changeSession", exports.onSessionChange.bind(editor));
+ editor.$multiselectOnSessionChange(editor);
+ editor.on("changeSession", editor.$multiselectOnSessionChange);
editor.on("mousedown", onMouseDown);
editor.commands.addCommands(commands.defaultCommands);
@@ -14326,201 +15310,28 @@ function addAltCursorListeners(editor){
exports.MultiSelect = MultiSelect;
-});
-
-define('ace/range_list', ['require', 'exports', 'module' ], function(require, exports, module) {
-
-
-var RangeList = function() {
- this.ranges = [];
-};
-
-(function() {
- this.comparePoints = function(p1, p2) {
- return p1.row - p2.row || p1.column - p2.column;
- };
-
- this.pointIndex = function(pos, startIndex) {
- var list = this.ranges;
-
- for (var i = startIndex || 0; i < list.length; i++) {
- var range = list[i];
- var cmp = this.comparePoints(pos, range.end);
-
- if (cmp > 0)
- continue;
- if (cmp == 0)
- return i;
- cmp = this.comparePoints(pos, range.start);
- if (cmp >= 0)
- return i;
-
- return -i-1;
- }
- return -i - 1;
- };
-
- this.add = function(range) {
- var startIndex = this.pointIndex(range.start);
- if (startIndex < 0)
- startIndex = -startIndex - 1;
-
- var endIndex = this.pointIndex(range.end, startIndex);
-
- if (endIndex < 0)
- endIndex = -endIndex - 1;
- else
- endIndex++;
-
- return this.ranges.splice(startIndex, endIndex - startIndex, range);
- };
-
- this.addList = function(list) {
- var removed = [];
- for (var i = list.length; i--; ) {
- removed.push.call(removed, this.add(list[i]));
- }
- return removed;
- };
-
- this.substractPoint = function(pos) {
- var i = this.pointIndex(pos);
-
- if (i >= 0)
- return this.ranges.splice(i, 1);
- };
- this.merge = function() {
- var removed = [];
- var list = this.ranges;
- var next = list[0], range;
- for (var i = 1; i < list.length; i++) {
- range = next;
- next = list[i];
- var cmp = this.comparePoints(range.end, next.start);
- if (cmp < 0)
- continue;
-
- if (cmp == 0 && !(range.isEmpty() || next.isEmpty()))
- continue;
-
- if (this.comparePoints(range.end, next.end) < 0) {
- range.end.row = next.end.row;
- range.end.column = next.end.column;
- }
-
- list.splice(i, 1);
- removed.push(next);
- next = range;
- i--;
- }
-
- return removed;
- };
-
- this.contains = function(row, column) {
- return this.pointIndex({row: row, column: column}) >= 0;
- };
-
- this.containsPoint = function(pos) {
- return this.pointIndex(pos) >= 0;
- };
-
- this.rangeAtPoint = function(pos) {
- var i = this.pointIndex(pos);
- if (i >= 0)
- return this.ranges[i];
- };
-
-
- this.clipRows = function(startRow, endRow) {
- var list = this.ranges;
- if (list[0].start.row > endRow || list[list.length - 1].start.row < startRow)
- return [];
-
- var startIndex = this.pointIndex({row: startRow, column: 0});
- if (startIndex < 0)
- startIndex = -startIndex - 1;
- var endIndex = this.pointIndex({row: endRow, column: 0}, startIndex);
- if (endIndex < 0)
- endIndex = -endIndex - 1;
-
- var clipped = [];
- for (var i = startIndex; i < endIndex; i++) {
- clipped.push(list[i]);
- }
- return clipped;
- };
-
- this.removeAll = function() {
- return this.ranges.splice(0, this.ranges.length);
- };
-
- this.attach = function(session) {
- if (this.session)
- this.detach();
-
- this.session = session;
- this.onChange = this.$onChange.bind(this);
-
- this.session.on('change', this.onChange);
- };
-
- this.detach = function() {
- if (!this.session)
- return;
- this.session.removeListener('change', this.onChange);
- this.session = null;
- };
-
- this.$onChange = function(e) {
- var changeRange = e.data.range;
- if (e.data.action[0] == "i"){
- var start = changeRange.start;
- var end = changeRange.end;
- } else {
- var end = changeRange.start;
- var start = changeRange.end;
- }
- var startRow = start.row;
- var endRow = end.row;
- var lineDif = endRow - startRow;
-
- var colDiff = -start.column + end.column;
- var ranges = this.ranges;
-
- for (var i = 0, n = ranges.length; i < n; i++) {
- var r = ranges[i];
- if (r.end.row < startRow)
- continue;
- if (r.start.row > startRow)
- break;
-
- if (r.start.row == startRow && r.start.column >= start.column ) {
- r.start.column += colDiff;
- r.start.row += lineDif;
- }
- if (r.end.row == startRow && r.end.column >= start.column) {
- r.end.column += colDiff;
- r.end.row += lineDif;
+require("./config").defineOptions(Editor.prototype, "editor", {
+ enableMultiselect: {
+ set: function(val) {
+ MultiSelect(this);
+ if (val) {
+ this.on("changeSession", this.$multiselectOnSessionChange);
+ this.on("mousedown", onMouseDown);
+ } else {
+ this.off("changeSession", this.$multiselectOnSessionChange);
+ this.off("mousedown", onMouseDown);
}
- }
+ },
+ value: true
+ }
+})
- if (lineDif != 0 && i < n) {
- for (; i < n; i++) {
- var r = ranges[i];
- r.start.row += lineDif;
- r.end.row += lineDif;
- }
- }
- };
-}).call(RangeList.prototype);
-exports.RangeList = RangeList;
});
-define('ace/mouse/multi_select_handler', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) {
+ace.define('ace/mouse/multi_select_handler', ['require', 'exports', 'module' , 'ace/lib/event'], function(require, exports, module) {
var event = require("../lib/event");
function isSamePoint(p1, p2) {
@@ -14595,7 +15406,7 @@ function onMouseDown(e) {
var oldRange = selection.rangeList.rangeAtPoint(pos);
- event.capture(editor.container, function(){}, function() {
+ editor.once("mouseup", function() {
var tmpSel = selection.toOrientedRange();
if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
@@ -14609,7 +15420,7 @@ function onMouseDown(e) {
}
});
- } else if (!shift && alt && button == 0) {
+ } else if (alt && button == 0) {
e.stop();
if (isMultiSelect && !ctrl)
@@ -14617,10 +15428,15 @@ function onMouseDown(e) {
else if (!isMultiSelect && ctrl)
selection.addRange();
- selection.moveCursorToPosition(pos);
- selection.clearSelection();
-
var rectSel = [];
+ if (shift) {
+ screenAnchor = session.documentToScreenPosition(selection.lead);
+ blockSelect();
+ } else {
+ selection.moveCursorToPosition(pos);
+ selection.clearSelection();
+ }
+
var onMouseSelectionEnd = function(e) {
clearInterval(timerId);
@@ -14643,7 +15459,7 @@ exports.onMouseDown = onMouseDown;
});
-define('ace/commands/multi_select_commands', ['require', 'exports', 'module' , 'ace/keyboard/hash_handler'], function(require, exports, module) {
+ace.define('ace/commands/multi_select_commands', ['require', 'exports', 'module' , 'ace/keyboard/hash_handler'], function(require, exports, module) {
exports.defaultCommands = [{
name: "addCursorAbove",
exec: function(editor) { editor.selectMoreLines(-1); },
@@ -14706,7 +15522,199 @@ var HashHandler = require("../keyboard/hash_handler").HashHandler;
exports.keyboardHandler = new HashHandler(exports.multiSelectCommands);
});
-define('ace/placeholder', ['require', 'exports', 'module' , 'ace/range', 'ace/lib/event_emitter', 'ace/lib/oop'], function(require, exports, module) {
+
+ace.define('ace/worker/worker_client', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/config'], function(require, exports, module) {
+
+
+var oop = require("../lib/oop");
+var EventEmitter = require("../lib/event_emitter").EventEmitter;
+var config = require("../config");
+
+var WorkerClient = function(topLevelNamespaces, mod, classname) {
+ this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
+ this.changeListener = this.changeListener.bind(this);
+ this.onMessage = this.onMessage.bind(this);
+ this.onError = this.onError.bind(this);
+ if (require.nameToUrl && !require.toUrl)
+ require.toUrl = require.nameToUrl;
+
+ var workerUrl;
+ if (config.get("packaged") || !require.toUrl) {
+ workerUrl = config.moduleUrl(mod, "worker");
+ } else {
+ var normalizePath = this.$normalizePath;
+ workerUrl = normalizePath(require.toUrl("ace/worker/worker.js", null, "_"));
+
+ var tlns = {};
+ topLevelNamespaces.forEach(function(ns) {
+ tlns[ns] = normalizePath(require.toUrl(ns, null, "_").replace(/(\.js)?(\?.*)?$/, ""));
+ });
+ }
+
+ this.$worker = new Worker(workerUrl);
+ this.$worker.postMessage({
+ init : true,
+ tlns: tlns,
+ module: mod,
+ classname: classname
+ });
+
+ this.callbackId = 1;
+ this.callbacks = {};
+
+ this.$worker.onerror = this.onError;
+ this.$worker.onmessage = this.onMessage;
+};
+
+(function(){
+
+ oop.implement(this, EventEmitter);
+
+ this.onError = function(e) {
+ window.console && console.log && console.log(e);
+ throw e;
+ };
+
+ this.onMessage = function(e) {
+ var msg = e.data;
+ switch(msg.type) {
+ case "log":
+ window.console && console.log && console.log.apply(console, msg.data);
+ break;
+
+ case "event":
+ this._emit(msg.name, {data: msg.data});
+ break;
+
+ case "call":
+ var callback = this.callbacks[msg.id];
+ if (callback) {
+ callback(msg.data);
+ delete this.callbacks[msg.id];
+ }
+ break;
+ }
+ };
+
+ this.$normalizePath = function(path) {
+ if (!location.host) // needed for file:// protocol
+ return path;
+ path = path.replace(/^[a-z]+:\/\/[^\/]+/, ""); // Remove domain name and rebuild it
+ path = location.protocol + "//" + location.host
+ + (path.charAt(0) == "/" ? "" : location.pathname.replace(/\/[^\/]*$/, ""))
+ + "/" + path.replace(/^[\/]+/, "");
+ return path;
+ };
+
+ this.terminate = function() {
+ this._emit("terminate", {});
+ this.deltaQueue = null;
+ this.$worker.terminate();
+ this.$worker = null;
+ this.$doc.removeEventListener("change", this.changeListener);
+ this.$doc = null;
+ };
+
+ this.send = function(cmd, args) {
+ this.$worker.postMessage({command: cmd, args: args});
+ };
+
+ this.call = function(cmd, args, callback) {
+ if (callback) {
+ var id = this.callbackId++;
+ this.callbacks[id] = callback;
+ args.push(id);
+ }
+ this.send(cmd, args);
+ };
+
+ this.emit = function(event, data) {
+ try {
+ this.$worker.postMessage({event: event, data: {data: data.data}});
+ }
+ catch(ex) {}
+ };
+
+ this.attachToDocument = function(doc) {
+ if(this.$doc)
+ this.terminate();
+
+ this.$doc = doc;
+ this.call("setValue", [doc.getValue()]);
+ doc.on("change", this.changeListener);
+ };
+
+ this.changeListener = function(e) {
+ if (!this.deltaQueue) {
+ this.deltaQueue = [e.data];
+ setTimeout(this.$sendDeltaQueue, 1);
+ } else
+ this.deltaQueue.push(e.data);
+ };
+
+ this.$sendDeltaQueue = function() {
+ var q = this.deltaQueue;
+ if (!q) return;
+ this.deltaQueue = null;
+ if (q.length > 20 && q.length > this.$doc.getLength() >> 1) {
+ this.call("setValue", [this.$doc.getValue()]);
+ } else
+ this.emit("change", {data: q});
+ }
+
+}).call(WorkerClient.prototype);
+
+
+var UIWorkerClient = function(topLevelNamespaces, mod, classname) {
+ this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
+ this.changeListener = this.changeListener.bind(this);
+ this.callbackId = 1;
+ this.callbacks = {};
+ this.messageBuffer = [];
+
+ var main = null;
+ var sender = Object.create(EventEmitter);
+ var _self = this;
+
+ this.$worker = {};
+ this.$worker.terminate = function() {};
+ this.$worker.postMessage = function(e) {
+ _self.messageBuffer.push(e);
+ main && setTimeout(processNext);
+ };
+
+ var processNext = function() {
+ var msg = _self.messageBuffer.shift();
+ if (msg.command)
+ main[msg.command].apply(main, msg.args);
+ else if (msg.event)
+ sender._emit(msg.event, msg.data);
+ };
+
+ sender.postMessage = function(msg) {
+ _self.onMessage({data: msg});
+ };
+ sender.callback = function(data, callbackId) {
+ this.postMessage({type: "call", id: callbackId, data: data});
+ };
+ sender.emit = function(name, data) {
+ this.postMessage({type: "event", name: name, data: data});
+ };
+
+ config.loadModule(["worker", mod], function(Main) {
+ main = new Main[classname](sender);
+ while (_self.messageBuffer.length)
+ processNext();
+ });
+};
+
+UIWorkerClient.prototype = WorkerClient.prototype;
+
+exports.UIWorkerClient = UIWorkerClient;
+exports.WorkerClient = WorkerClient;
+
+});
+ace.define('ace/placeholder', ['require', 'exports', 'module' , 'ace/range', 'ace/lib/event_emitter', 'ace/lib/oop'], function(require, exports, module) {
var Range = require("./range").Range;
@@ -14878,7 +15886,7 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
exports.PlaceHolder = PlaceHolder;
});
-define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
+ace.define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
var Range = require("../../range").Range;
@@ -14966,9 +15974,143 @@ var FoldMode = exports.FoldMode = function() {};
}).call(FoldMode.prototype);
});
+
+ace.define('ace/theme/textmate', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
+
+
+exports.isDark = false;
+exports.cssClass = "ace-tm";
+exports.cssText = ".ace-tm .ace_gutter {\
+background: #f0f0f0;\
+color: #333;\
+}\
+.ace-tm .ace_print-margin {\
+width: 1px;\
+background: #e8e8e8;\
+}\
+.ace-tm .ace_fold {\
+background-color: #6B72E6;\
+}\
+.ace-tm {\
+background-color: #FFFFFF;\
+}\
+.ace-tm .ace_cursor {\
+border-left: 2px solid black;\
+}\
+.ace-tm .ace_overwrite-cursors .ace_cursor {\
+border-left: 0px;\
+border-bottom: 1px solid black;\
+}\
+.ace-tm .ace_invisible {\
+color: rgb(191, 191, 191);\
+}\
+.ace-tm .ace_storage,\
+.ace-tm .ace_keyword {\
+color: blue;\
+}\
+.ace-tm .ace_constant {\
+color: rgb(197, 6, 11);\
+}\
+.ace-tm .ace_constant.ace_buildin {\
+color: rgb(88, 72, 246);\
+}\
+.ace-tm .ace_constant.ace_language {\
+color: rgb(88, 92, 246);\
+}\
+.ace-tm .ace_constant.ace_library {\
+color: rgb(6, 150, 14);\
+}\
+.ace-tm .ace_invalid {\
+background-color: rgba(255, 0, 0, 0.1);\
+color: red;\
+}\
+.ace-tm .ace_support.ace_function {\
+color: rgb(60, 76, 114);\
+}\
+.ace-tm .ace_support.ace_constant {\
+color: rgb(6, 150, 14);\
+}\
+.ace-tm .ace_support.ace_type,\
+.ace-tm .ace_support.ace_class {\
+color: rgb(109, 121, 222);\
+}\
+.ace-tm .ace_keyword.ace_operator {\
+color: rgb(104, 118, 135);\
+}\
+.ace-tm .ace_string {\
+color: rgb(3, 106, 7);\
+}\
+.ace-tm .ace_comment {\
+color: rgb(76, 136, 107);\
+}\
+.ace-tm .ace_comment.ace_doc {\
+color: rgb(0, 102, 255);\
+}\
+.ace-tm .ace_comment.ace_doc.ace_tag {\
+color: rgb(128, 159, 191);\
+}\
+.ace-tm .ace_constant.ace_numeric {\
+color: rgb(0, 0, 205);\
+}\
+.ace-tm .ace_variable {\
+color: rgb(49, 132, 149);\
+}\
+.ace-tm .ace_xml-pe {\
+color: rgb(104, 104, 91);\
+}\
+.ace-tm .ace_entity.ace_name.ace_function {\
+color: #0000A2;\
+}\
+.ace-tm .ace_heading {\
+color: rgb(12, 7, 255);\
+}\
+.ace-tm .ace_list {\
+color:rgb(185, 6, 144);\
+}\
+.ace-tm .ace_meta.ace_tag {\
+color:rgb(0, 22, 142);\
+}\
+.ace-tm .ace_string.ace_regex {\
+color: rgb(255, 0, 0)\
+}\
+.ace-tm .ace_marker-layer .ace_selection {\
+background: rgb(181, 213, 255);\
+}\
+.ace-tm.ace_multiselect .ace_selection.ace_start {\
+box-shadow: 0 0 3px 0px white;\
+border-radius: 2px;\
+}\
+.ace-tm .ace_marker-layer .ace_step {\
+background: rgb(252, 255, 0);\
+}\
+.ace-tm .ace_marker-layer .ace_stack {\
+background: rgb(164, 229, 101);\
+}\
+.ace-tm .ace_marker-layer .ace_bracket {\
+margin: -1px 0 0 -1px;\
+border: 1px solid rgb(192, 192, 192);\
+}\
+.ace-tm .ace_marker-layer .ace_active-line {\
+background: rgba(0, 0, 0, 0.07);\
+}\
+.ace-tm .ace_gutter-active-line {\
+background-color : #dcdcdc;\
+}\
+.ace-tm .ace_marker-layer .ace_selected-word {\
+background: rgb(250, 250, 255);\
+border: 1px solid rgb(200, 200, 250);\
+}\
+.ace-tm .ace_indent-guide {\
+background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
+}\
+";
+
+var dom = require("../lib/dom");
+dom.importCssString(exports.cssText, exports.cssClass);
+});
;
(function() {
- window.require(["ace/ace"], function(a) {
+ ace.require(["ace/ace"], function(a) {
a && a.config.init();
if (!window.ace)
window.ace = {};
diff --git a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/ext-language_tools.js b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/ext-language_tools.js
new file mode 100644
index 0000000..e29b715
--- /dev/null
+++ b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/ext-language_tools.js
@@ -0,0 +1,1429 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2012, Ajax.org B.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Ajax.org B.V. nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+ace.define('ace/ext/language_tools', ['require', 'exports', 'module' , 'ace/snippets', 'ace/autocomplete', 'ace/config', 'ace/autocomplete/text_completer', 'ace/editor'], function(require, exports, module) {
+
+
+var snippetManager = require("../snippets").snippetManager;
+var Autocomplete = require("../autocomplete").Autocomplete;
+var config = require("../config");
+
+var textCompleter = require("../autocomplete/text_completer");
+var keyWordCompleter = {
+ getCompletions: function(editor, session, pos, prefix, callback) {
+ var keywords = session.$mode.$keywordList || [];
+ keywords = keywords.filter(function(w) {
+ return w.lastIndexOf(prefix, 0) == 0;
+ });
+ callback(null, keywords.map(function(word) {
+ return {
+ name: word,
+ value: word,
+ score: 0,
+ meta: "keyword"
+ };
+ }));
+ }
+};
+
+var snippetCompleter = {
+ getCompletions: function(editor, session, pos, prefix, callback) {
+ var scope = snippetManager.$getScope(editor);
+ var snippetMap = snippetManager.snippetMap;
+ var completions = [];
+ [scope, "_"].forEach(function(scope) {
+ var snippets = snippetMap[scope] || [];
+ for (var i = snippets.length; i--;) {
+ var s = snippets[i];
+ if (s.tabTrigger && s.tabTrigger.indexOf(prefix) === 0)
+ completions.push({
+ caption: s.tabTrigger,
+ snippet: s.content,
+ meta: "snippet"
+ });
+ }
+ }, this);
+ callback(null, completions);
+ }
+};
+
+var completers = [snippetCompleter, textCompleter, keyWordCompleter];
+exports.addCompleter = function(completer) {
+ completers.push(completer);
+};
+
+var expandSnippet = {
+ name: "expandSnippet",
+ exec: function(editor) {
+ var success = snippetManager.expandWithTab(editor);
+ if (!success)
+ editor.execCommand("indent");
+ },
+ bindKey: "tab"
+}
+
+var onChangeMode = function(e, editor) {
+ var mode = editor.session.$mode;
+ var id = mode.$id
+ if (!snippetManager.files) snippetManager.files = {};
+ if (id && !snippetManager.files[id]) {
+ var snippetFilePath = id.replace("mode", "snippets");
+ config.loadModule(snippetFilePath, function(m) {
+ if (m) {
+ snippetManager.files[id] = m;
+ m.snippets = snippetManager.parseSnippetFile(m.snippetText);
+ snippetManager.register(m.snippets, m.scope);
+ }
+ });
+ }
+};
+
+var Editor = require("../editor").Editor;
+require("../config").defineOptions(Editor.prototype, "editor", {
+ enableBasicAutocompletion: {
+ set: function(val) {
+ if (val) {
+ this.completers = completers
+ this.commands.addCommand(Autocomplete.startCommand);
+ } else {
+ this.commands.removeCommand(Autocomplete.startCommand);
+ }
+ },
+ value: false
+ },
+ enableSnippets: {
+ set: function(val) {
+ if (val) {
+ this.commands.addCommand(expandSnippet);
+ this.on("changeMode", onChangeMode);
+ onChangeMode(null, this)
+ } else {
+ this.commands.removeCommand(expandSnippet);
+ this.off("changeMode", onChangeMode);
+ }
+ },
+ value: false
+ }
+});
+
+});
+
+ace.define('ace/snippets', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/range', 'ace/keyboard/hash_handler', 'ace/tokenizer', 'ace/lib/dom'], function(require, exports, module) {
+
+var lang = require("./lib/lang")
+var Range = require("./range").Range
+var HashHandler = require("./keyboard/hash_handler").HashHandler;
+var Tokenizer = require("./tokenizer").Tokenizer;
+var comparePoints = Range.comparePoints;
+
+var SnippetManager = function() {
+ this.snippetMap = {};
+ this.snippetNameMap = {};
+};
+
+(function() {
+ this.getTokenizer = function() {
+ function TabstopToken(str, _, stack) {
+ str = str.substr(1);
+ if (/^\d+$/.test(str) && !stack.inFormatString)
+ return [{tabstopId: parseInt(str, 10)}];
+ return [{text: str}]
+ }
+ function escape(ch) {
+ return "(?:[^\\\\" + ch + "]|\\\\.)";
+ }
+ SnippetManager.$tokenizer = new Tokenizer({
+ start: [
+ {regex: /:/, onMatch: function(val, state, stack) {
+ if (stack.length && stack[0].expectIf) {
+ stack[0].expectIf = false;
+ stack[0].elseBranch = stack[0];
+ return [stack[0]];
+ }
+ return ":";
+ }},
+ {regex: /\\./, onMatch: function(val, state, stack) {
+ var ch = val[1];
+ if (ch == "}" && stack.length) {
+ val = ch;
+ }else if ("`$\\".indexOf(ch) != -1) {
+ val = ch;
+ } else if (stack.inFormatString) {
+ if (ch == "n")
+ val = "\n";
+ else if (ch == "t")
+ val = "\n";
+ else if ("ulULE".indexOf(ch) != -1) {
+ val = {changeCase: ch, local: ch > "a"};
+ }
+ }
+
+ return [val];
+ }},
+ {regex: /}/, onMatch: function(val, state, stack) {
+ return [stack.length ? stack.shift() : val];
+ }},
+ {regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken},
+ {regex: /\$\{[\dA-Z_a-z]+/, onMatch: function(str, state, stack) {
+ var t = TabstopToken(str.substr(1), state, stack);
+ stack.unshift(t[0]);
+ return t;
+ }, next: "snippetVar"},
+ {regex: /\n/, token: "newline", merge: false}
+ ],
+ snippetVar: [
+ {regex: "\\|" + escape("\\|") + "*\\|", onMatch: function(val, state, stack) {
+ stack[0].choices = val.slice(1, -1).split(",");
+ }, next: "start"},
+ {regex: "/(" + escape("/") + "+)/(?:(" + escape("/") + "*)/)(\\w*):?",
+ onMatch: function(val, state, stack) {
+ var ts = stack[0];
+ ts.fmtString = val;
+
+ val = this.splitRegex.exec(val);
+ ts.guard = val[1];
+ ts.fmt = val[2];
+ ts.flag = val[3];
+ return "";
+ }, next: "start"},
+ {regex: "`" + escape("`") + "*`", onMatch: function(val, state, stack) {
+ stack[0].code = val.splice(1, -1);
+ return "";
+ }, next: "start"},
+ {regex: "\\?", onMatch: function(val, state, stack) {
+ if (stack[0])
+ stack[0].expectIf = true;
+ }, next: "start"},
+ {regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start"}
+ ],
+ formatString: [
+ {regex: "/(" + escape("/") + "+)/", token: "regex"},
+ {regex: "", onMatch: function(val, state, stack) {
+ stack.inFormatString = true;
+ }, next: "start"}
+ ]
+ });
+ SnippetManager.prototype.getTokenizer = function() {
+ return SnippetManager.$tokenizer;
+ }
+ return SnippetManager.$tokenizer;
+ };
+
+ this.tokenizeTmSnippet = function(str, startState) {
+ return this.getTokenizer().getLineTokens(str, startState).tokens.map(function(x) {
+ return x.value || x;
+ });
+ };
+
+ this.$getDefaultValue = function(editor, name) {
+ if (/^[A-Z]\d+$/.test(name)) {
+ var i = name.substr(1);
+ return (this.variables[name[0] + "__"] || {})[i];
+ }
+ if (/^\d+$/.test(name)) {
+ return (this.variables.__ || {})[name];
+ }
+ name = name.replace(/^TM_/, "");
+
+ if (!editor)
+ return;
+ var s = editor.session;
+ switch(name) {
+ case "CURRENT_WORD":
+ var r = s.getWordRange();
+ case "SELECTION":
+ case "SELECTED_TEXT":
+ return s.getTextRange(r);
+ case "CURRENT_LINE":
+ return s.getLine(e.getCursorPosition().row);
+ case "LINE_INDEX":
+ return e.getCursorPosition().column;
+ case "LINE_NUMBER":
+ return e.getCursorPosition().row + 1;
+ case "SOFT_TABS":
+ return s.getUseSoftTabs() ? "YES" : "NO";
+ case "TAB_SIZE":
+ return s.getTabSize();
+ case "FILENAME":
+ case "FILEPATH":
+ return "ace.ajax.org";
+ case "FULLNAME":
+ return "Ace";
+ }
+ };
+ this.variables = {};
+ this.getVariableValue = function(editor, varName) {
+ if (this.variables.hasOwnProperty(varName))
+ return this.variables[varName](editor, varName) || "";
+ return this.$getDefaultValue(editor, varName) || "";
+ };
+ this.tmStrFormat = function(str, ch, editor) {
+ var flag = ch.flag || "";
+ var re = ch.guard;
+ re = new RegExp(re, flag.replace(/[^gi]/, ""));
+ var fmtTokens = this.tokenizeTmSnippet(ch.fmt, "formatString");
+ var _self = this;
+ var formatted = str.replace(re, function() {
+ _self.variables.__ = arguments;
+ var fmtParts = _self.resolveVariables(fmtTokens, editor);
+ var gChangeCase = "E";
+ for (var i = 0; i < fmtParts.length; i++) {
+ var ch = fmtParts[i];
+ if (typeof ch == "object") {
+ fmtParts[i] = "";
+ if (ch.changeCase && ch.local) {
+ var next = fmtParts[i + 1];
+ if (next && typeof next == "string") {
+ if (ch.changeCase == "u")
+ fmtParts[i] = next[0].toUpperCase();
+ else
+ fmtParts[i] = next[0].toLowerCase();
+ fmtParts[i + 1] = next.substr(1);
+ }
+ } else if (ch.changeCase) {
+ gChangeCase = ch.changeCase;
+ }
+ } else if (gChangeCase == "U") {
+ fmtParts[i] = ch.toUpperCase();
+ } else if (gChangeCase == "L") {
+ fmtParts[i] = ch.toLowerCase();
+ }
+ }
+ return fmtParts.join("");
+ });
+ this.variables.__ = null;
+ return formatted;
+ };
+
+ this.resolveVariables = function(snippet, editor) {
+ var result = [];
+ for (var i = 0; i < snippet.length; i++) {
+ var ch = snippet[i];
+ if (typeof ch == "string") {
+ result.push(ch);
+ } else if (typeof ch != "object") {
+ continue;
+ } else if (ch.skip) {
+ gotoNext(ch);
+ } else if (ch.processed < i) {
+ continue;
+ } else if (ch.text) {
+ var value = this.getVariableValue(editor, ch.text);
+ if (value && ch.fmtString)
+ value = this.tmStrFormat(value, ch);
+ ch.processed = i;
+ if (ch.expectIf == null) {
+ if (value) {
+ result.push(value);
+ gotoNext(ch);
+ }
+ } else {
+ if (value) {
+ ch.skip = ch.elseBranch;
+ } else
+ gotoNext(ch);
+ }
+ } else if (ch.tabstopId != null) {
+ result.push(ch);
+ } else if (ch.changeCase != null) {
+ result.push(ch);
+ }
+ }
+ function gotoNext(ch) {
+ var i1 = snippet.indexOf(ch, i + 1);
+ if (i1 != -1)
+ i = i1;
+ }
+ return result;
+ };
+
+ this.insertSnippet = function(editor, snippetText) {
+ var cursor = editor.getCursorPosition();
+ var line = editor.session.getLine(cursor.row);
+ var indentString = line.match(/^\s*/)[0];
+ var tabString = editor.session.getTabString();
+
+ var tokens = this.tokenizeTmSnippet(snippetText);
+ tokens = this.resolveVariables(tokens, editor);
+ tokens = tokens.map(function(x) {
+ if (x == "\n")
+ return x + indentString;
+ if (typeof x == "string")
+ return x.replace(/\t/g, tabString);
+ return x;
+ });
+ var tabstops = [];
+ tokens.forEach(function(p, i) {
+ if (typeof p != "object")
+ return;
+ var id = p.tabstopId;
+ if (!tabstops[id]) {
+ tabstops[id] = [];
+ tabstops[id].index = id;
+ tabstops[id].value = "";
+ }
+ if (tabstops[id].indexOf(p) != -1)
+ return;
+ tabstops[id].push(p);
+ var i1 = tokens.indexOf(p, i + 1);
+ if (i1 == -1)
+ return;
+ var value = tokens.slice(i + 1, i1).join("");
+ if (value)
+ tabstops[id].value = value;
+ });
+
+ tabstops.forEach(function(ts) {
+ ts.value && ts.forEach(function(p) {
+ var i = tokens.indexOf(p);
+ var i1 = tokens.indexOf(p, i + 1);
+ if (i1 == -1)
+ tokens.splice(i + 1, 0, ts.value, p);
+ else if (i1 == i + 1)
+ tokens.splice(i + 1, 0, ts.value);
+ });
+ });
+ var row = 0, column = 0;
+ var text = "";
+ tokens.forEach(function(t) {
+ if (typeof t == "string") {
+ if (t[0] == "\n"){
+ column = t.length - 1;
+ row ++;
+ } else
+ column += t.length;
+ text += t;
+ } else {
+ if (!t.start)
+ t.start = {row: row, column: column};
+ else
+ t.end = {row: row, column: column};
+ }
+ });
+ var range = editor.getSelectionRange();
+ var end = editor.session.replace(range, text);
+
+ var tabstopManager = new TabstopManager(editor);
+ tabstopManager.addTabstops(tabstops, range.start, end);
+ tabstopManager.tabNext();
+ };
+
+ this.$getScope = function(editor) {
+ var scope = editor.session.$mode.$id || "";
+ scope = scope.split("/").pop();
+ if (editor.session.$mode.$modes) {
+ var c = editor.getCursorPosition()
+ var state = editor.session.getState(c.row);
+ if (state.substring) {
+ if (state.substring(0, 3) == "js-")
+ scope = "javascript";
+ else if (state.substring(0, 4) == "css-")
+ scope = "css";
+ else if (state.substring(0, 4) == "php-")
+ scope = "php";
+ }
+ }
+ return scope;
+ };
+
+ this.expandWithTab = function(editor) {
+ var cursor = editor.getCursorPosition();
+ var line = editor.session.getLine(cursor.row);
+ var before = line.substring(0, cursor.column);
+ var after = line.substr(cursor.column);
+
+ var scope = this.$getScope(editor);
+ var snippetMap = this.snippetMap;
+ var snippet;
+ [scope, "_"].some(function(scope) {
+ var snippets = snippetMap[scope];
+ if (snippets)
+ snippet = this.findMatchingSnippet(snippets, before, after);
+ return !!snippet;
+ }, this);
+ if (!snippet)
+ return false;
+
+ editor.session.doc.removeInLine(cursor.row,
+ cursor.column - snippet.replaceBefore.length,
+ cursor.column + snippet.replaceAfter.length
+ );
+
+ this.variables.M__ = snippet.matchBefore;
+ this.variables.T__ = snippet.matchAfter;
+ this.insertSnippet(editor, snippet.content);
+
+ this.variables.M__ = this.variables.T__ = null;
+ return true;
+ };
+
+ this.findMatchingSnippet = function(snippetList, before, after) {
+ for (var i = snippetList.length; i--;) {
+ var s = snippetList[i];
+ if (s.startRe && !s.startRe.test(before))
+ continue;
+ if (s.endRe && !s.endRe.test(after))
+ continue;
+ if (!s.startRe && !s.endRe)
+ continue;
+
+ s.matchBefore = s.startRe ? s.startRe.exec(before) : [""];
+ s.matchAfter = s.endRe ? s.endRe.exec(after) : [""];
+ s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : "";
+ s.replaceAfter = s.endTriggerRe ? s.endTriggerRe.exec(after)[0] : "";
+ return s;
+ }
+ };
+
+ this.snippetMap = {};
+ this.snippetNameMap = {};
+ this.register = function(snippets, scope) {
+ var snippetMap = this.snippetMap;
+ var snippetNameMap = this.snippetNameMap;
+ var self = this;
+ function wrapRegexp(src) {
+ if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src))
+ src = "(?:" + src + ")"
+
+ return src || "";
+ }
+ function guardedRegexp(re, guard, opening) {
+ re = wrapRegexp(re);
+ guard = wrapRegexp(guard);
+ if (opening) {
+ re = guard + re;
+ if (re && re[re.length - 1] != "$")
+ re = re + "$";
+ } else {
+ re = re + guard;
+ if (re && re[0] != "^")
+ re = "^" + re;
+ }
+ return new RegExp(re);
+ }
+
+ function addSnippet(s) {
+ if (!s.scope)
+ s.scope = scope || "_";
+ scope = s.scope
+ if (!snippetMap[scope]) {
+ snippetMap[scope] = [];
+ snippetNameMap[scope] = {};
+ }
+
+ var map = snippetNameMap[scope];
+ if (s.name) {
+ var old = map[s.name];
+ if (old)
+ self.unregister(old);
+ map[s.name] = s;
+ }
+ snippetMap[scope].push(s);
+
+ if (s.tabTrigger && !s.trigger) {
+ if (!s.guard && /^\w/.test(s.tabTrigger))
+ s.guard = "\\b";
+ s.trigger = lang.escapeRegExp(s.tabTrigger);
+ }
+
+ s.startRe = guardedRegexp(s.trigger, s.guard, true);
+ s.triggerRe = new RegExp(s.trigger, "", true);
+
+ s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true);
+ s.endTriggerRe = new RegExp(s.endTrigger, "", true);
+ };
+
+ if (snippets.content)
+ addSnippet(snippets);
+ else if (Array.isArray(snippets))
+ snippets.forEach(addSnippet);
+ };
+ this.unregister = function(snippets, scope) {
+ var snippetMap = this.snippetMap;
+ var snippetNameMap = this.snippetNameMap;
+
+ function removeSnippet(s) {
+ var nameMap = snippetNameMap[s.scope||scope];
+ if (nameMap && nameMap[s.name]) {
+ delete nameMap[s.name];
+ var map = snippetMap[s.scope||scope];
+ var i = map && map.indexOf(s);
+ if (i >= 0)
+ map.splice(i, 1);
+ }
+ }
+ if (snippets.content)
+ removeSnippet(snippets);
+ else if (Array.isArray(snippets))
+ snippets.forEach(removeSnippet);
+ };
+ this.parseSnippetFile = function(str) {
+ str = str.replace(/\r/, "");
+ var list = [], snippet = {};
+ var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm;
+ var m;
+ while (m = re.exec(str)) {
+ if (m[1]) {
+ try {
+ snippet = JSON.parse(m[1])
+ list.push(snippet);
+ } catch (e) {}
+ } if (m[4]) {
+ snippet.content = m[4].replace(/^\t/gm, "");
+ list.push(snippet);
+ snippet = {};
+ } else {
+ var key = m[2], val = m[3];
+ if (key == "regex") {
+ var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g;
+ snippet.guard = guardRe.exec(val)[1];
+ snippet.trigger = guardRe.exec(val)[1];
+ snippet.endTrigger = guardRe.exec(val)[1];
+ snippet.endGuard = guardRe.exec(val)[1];
+ } else if (key == "snippet") {
+ snippet.tabTrigger = val.match(/^\S*/)[0];
+ if (!snippet.name)
+ snippet.name = val;
+ } else {
+ snippet[key] = val;
+ }
+ }
+ }
+ return list;
+ };
+ this.getSnippetByName = function(name, editor) {
+ var scope = editor && this.$getScope(editor);
+ var snippetMap = this.snippetNameMap;
+ var snippet;
+ [scope, "_"].some(function(scope) {
+ var snippets = snippetMap[scope];
+ if (snippets)
+ snippet = snippets[name];
+ return !!snippet;
+ }, this);
+ return snippet;
+ };
+
+}).call(SnippetManager.prototype);
+
+
+var TabstopManager = function(editor) {
+ if (editor.tabstopManager)
+ return editor.tabstopManager;
+ editor.tabstopManager = this;
+ this.$onChange = this.onChange.bind(this);
+ this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule;
+ this.$onChangeSession = this.onChangeSession.bind(this);
+ this.$onAfterExec = this.onAfterExec.bind(this);
+ this.attach(editor);
+};
+(function() {
+ this.attach = function(editor) {
+ this.index = -1;
+ this.ranges = [];
+ this.tabstops = [];
+ this.selectedTabstop = null;
+
+ this.editor = editor;
+ this.editor.on("change", this.$onChange);
+ this.editor.on("changeSelection", this.$onChangeSelection);
+ this.editor.on("changeSession", this.$onChangeSession);
+ this.editor.commands.on("afterExec", this.$onAfterExec);
+ this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
+ };
+ this.detach = function() {
+ this.tabstops.forEach(this.removeTabstopMarkers, this);
+ this.ranges = null;
+ this.tabstops = null;
+ this.selectedTabstop = null;
+ this.editor.removeListener("change", this.$onChange);
+ this.editor.removeListener("changeSelection", this.$onChangeSelection);
+ this.editor.removeListener("changeSession", this.$onChangeSession);
+ this.editor.commands.removeListener("afterExec", this.$onAfterExec);
+ this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
+ this.editor.tabstopManager = null;
+ this.editor = null;
+ };
+
+ this.onChange = function(e) {
+ var changeRange = e.data.range;
+ var isRemove = e.data.action[0] == "r";
+ var start = changeRange.start;
+ var end = changeRange.end;
+ var startRow = start.row;
+ var endRow = end.row;
+ var lineDif = endRow - startRow;
+ var colDiff = end.column - start.column;
+
+ if (isRemove) {
+ lineDif = -lineDif;
+ colDiff = -colDiff;
+ }
+ if (!this.$inChange && isRemove) {
+ var ts = this.selectedTabstop;
+ var changedOutside = !ts.some(function(r) {
+ return comparePoints(r.start, start) <= 0 && comparePoints(r.end, end) >= 0;
+ });
+ if (changedOutside)
+ return this.detach();
+ }
+ var ranges = this.ranges;
+ for (var i = 0; i < ranges.length; i++) {
+ var r = ranges[i];
+ if (r.end.row < start.row)
+ continue;
+
+ if (comparePoints(start, r.start) < 0 && comparePoints(end, r.end) > 0) {
+ this.removeRange(r);
+ i--;
+ continue;
+ }
+
+ if (r.start.row == startRow && r.start.column > start.column)
+ r.start.column += colDiff;
+ if (r.end.row == startRow && r.end.column >= start.column)
+ r.end.column += colDiff;
+ if (r.start.row >= startRow)
+ r.start.row += lineDif;
+ if (r.end.row >= startRow)
+ r.end.row += lineDif;
+
+ if (comparePoints(r.start, r.end) > 0)
+ this.removeRange(r);
+ }
+ if (!ranges.length)
+ this.detach();
+ };
+ this.updateLinkedFields = function() {
+ var ts = this.selectedTabstop;
+ if (!ts.hasLinkedRanges)
+ return;
+ this.$inChange = true;
+ var session = this.editor.session;
+ var text = session.getTextRange(ts.firstNonLinked);
+ for (var i = ts.length; i--;) {
+ var range = ts[i];
+ if (!range.linked)
+ continue;
+ var fmt = exports.snippetManager.tmStrFormat(text, range.original)
+ session.replace(range, fmt);
+ }
+ this.$inChange = false;
+ };
+ this.onAfterExec = function(e) {
+ if (e.command && !e.command.readOnly)
+ this.updateLinkedFields();
+ };
+ this.onChangeSelection = function() {
+ if (!this.editor)
+ return
+ var lead = this.editor.selection.lead;
+ var anchor = this.editor.selection.anchor;
+ var isEmpty = this.editor.selection.isEmpty();
+ for (var i = this.ranges.length; i--;) {
+ if (this.ranges[i].linked)
+ continue;
+ var containsLead = this.ranges[i].contains(lead.row, lead.column);
+ var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column);
+ if (containsLead && containsAnchor)
+ return;
+ }
+ this.detach();
+ };
+ this.onChangeSession = function() {
+ this.detach();
+ };
+ this.tabNext = function(dir) {
+ var max = this.tabstops.length - 1;
+ var index = this.index + (dir || 1);
+ index = Math.min(Math.max(index, 0), max);
+ this.selectTabstop(index);
+ if (index == max)
+ this.detach();
+ };
+ this.selectTabstop = function(index) {
+ var ts = this.tabstops[this.index];
+ if (ts)
+ this.addTabstopMarkers(ts);
+ this.index = index;
+ ts = this.tabstops[this.index];
+ if (!ts || !ts.length)
+ return;
+
+ this.selectedTabstop = ts;
+ if (!this.editor.inVirtualSelectionMode) {
+ var sel = this.editor.multiSelect;
+ sel.toSingleRange(ts.firstNonLinked.clone());
+ for (var i = ts.length; i--;) {
+ if (ts.hasLinkedRanges && ts[i].linked)
+ continue;
+ sel.addRange(ts[i].clone(), true);
+ }
+ } else {
+ this.editor.selection.setRange(ts.firstNonLinked);
+ }
+
+ this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
+ };
+ this.addTabstops = function(tabstops, start, end) {
+ if (!tabstops[0]) {
+ var p = Range.fromPoints(end, end);
+ moveRelative(p.start, start);
+ moveRelative(p.end, start);
+ tabstops[0] = [p];
+ tabstops[0].index = 0;
+ }
+
+ var i = this.index;
+ var arg = [i, 0];
+ var ranges = this.ranges;
+ var editor = this.editor;
+ tabstops.forEach(function(ts) {
+ for (var i = ts.length; i--;) {
+ var p = ts[i];
+ var range = Range.fromPoints(p.start, p.end || p.start);
+ movePoint(range.start, start);
+ movePoint(range.end, start);
+ range.original = p;
+ range.tabstop = ts;
+ ranges.push(range);
+ ts[i] = range;
+ if (p.fmtString) {
+ range.linked = true;
+ ts.hasLinkedRanges = true;
+ } else if (!ts.firstNonLinked)
+ ts.firstNonLinked = range;
+ }
+ if (!ts.firstNonLinked)
+ ts.hasLinkedRanges = false;
+ arg.push(ts);
+ this.addTabstopMarkers(ts);
+ }, this);
+ arg.push(arg.splice(2, 1)[0]);
+ this.tabstops.splice.apply(this.tabstops, arg);
+ };
+
+ this.addTabstopMarkers = function(ts) {
+ var session = this.editor.session;
+ ts.forEach(function(range) {
+ if (!range.markerId)
+ range.markerId = session.addMarker(range, "ace_snippet-marker", "text");
+ });
+ };
+ this.removeTabstopMarkers = function(ts) {
+ var session = this.editor.session;
+ ts.forEach(function(range) {
+ session.removeMarker(range.markerId);
+ range.markerId = null;
+ });
+ };
+ this.removeRange = function(range) {
+ var i = range.tabstop.indexOf(range);
+ range.tabstop.splice(i, 1);
+ i = this.ranges.indexOf(range);
+ this.ranges.splice(i, 1);
+ this.editor.session.removeMarker(range.markerId);
+ };
+
+ this.keyboardHandler = new HashHandler();
+ this.keyboardHandler.bindKeys({
+ "Tab": function(ed) {
+ ed.tabstopManager.tabNext(1);
+ },
+ "Shift-Tab": function(ed) {
+ ed.tabstopManager.tabNext(-1);
+ },
+ "Esc": function(ed) {
+ ed.tabstopManager.detach();
+ },
+ "Return": function(ed) {
+ return false;
+ }
+ });
+}).call(TabstopManager.prototype);
+
+
+var movePoint = function(point, diff) {
+ if (point.row == 0)
+ point.column += diff.column;
+ point.row += diff.row;
+};
+
+var moveRelative = function(point, start) {
+ if (point.row == start.row)
+ point.column -= start.column;
+ point.row -= start.row;
+};
+
+
+require("./lib/dom").importCssString("\
+.ace_snippet-marker {\
+ -moz-box-sizing: border-box;\
+ box-sizing: border-box;\
+ background: rgba(194, 193, 208, 0.09);\
+ border: 1px dotted rgba(211, 208, 235, 0.62);\
+ position: absolute;\
+}");
+
+exports.snippetManager = new SnippetManager();
+
+
+});
+
+ace.define('ace/autocomplete', ['require', 'exports', 'module' , 'ace/keyboard/hash_handler', 'ace/autocomplete/popup', 'ace/autocomplete/util', 'ace/lib/event', 'ace/lib/lang', 'ace/snippets'], function(require, exports, module) {
+
+
+var HashHandler = require("./keyboard/hash_handler").HashHandler;
+var AcePopup = require("./autocomplete/popup").AcePopup;
+var util = require("./autocomplete/util");
+var event = require("./lib/event");
+var lang = require("./lib/lang");
+var snippetManager = require("./snippets").snippetManager;
+
+var Autocomplete = function() {
+ this.keyboardHandler = new HashHandler();
+ this.keyboardHandler.bindKeys(this.commands);
+
+ this.blurListener = this.blurListener.bind(this);
+ this.changeListener = this.changeListener.bind(this);
+ this.mousedownListener = this.mousedownListener.bind(this);
+ this.mousewheelListener = this.mousewheelListener.bind(this);
+
+ this.changeTimer = lang.delayedCall(function() {
+ this.updateCompletions(true);
+ }.bind(this))
+};
+
+(function() {
+ this.$init = function() {
+ this.popup = new AcePopup(document.body || document.documentElement);
+ this.popup.on("click", function(e) {
+ this.insertMatch();
+ e.stop();
+ }.bind(this));
+ };
+
+ this.openPopup = function(editor, keepPopupPosition) {
+ if (!this.popup)
+ this.$init();
+
+ this.popup.setData(this.completions.filtered);
+
+ var renderer = editor.renderer;
+ if (!keepPopupPosition) {
+ var lineHeight = renderer.layerConfig.lineHeight;
+ var pos = renderer.$cursorLayer.getPixelPosition(null, true);
+ var rect = editor.container.getBoundingClientRect();
+ pos.top += rect.top - renderer.layerConfig.offset;
+ pos.left += rect.left;
+ pos.left += renderer.$gutterLayer.gutterWidth;
+
+ this.popup.show(pos, lineHeight);
+ }
+ renderer.updateText();
+ };
+
+ this.detach = function() {
+ this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
+ this.editor.removeEventListener("changeSelection", this.changeListener);
+ this.editor.removeEventListener("blur", this.changeListener);
+ this.editor.removeEventListener("mousedown", this.changeListener);
+ this.changeTimer.cancel();
+
+ if (this.popup)
+ this.popup.hide();
+
+ this.activated = false;
+ };
+
+ this.changeListener = function(e) {
+ if (this.activated)
+ this.changeTimer.schedule();
+ else
+ this.detach();
+ };
+
+ this.blurListener = function() {
+ if (document.activeElement != this.editor.textInput.getElement())
+ this.detach();
+ };
+
+ this.mousedownListener = function(e) {
+ this.detach();
+ };
+
+ this.mousewheelListener = function(e) {
+ this.detach();
+ };
+
+ this.goTo = function(where) {
+ var row = this.popup.getRow();
+ var max = this.popup.session.getLength() - 1;
+
+ switch(where) {
+ case "up": row = row <= 0 ? max : row - 1; break;
+ case "down": row = row >= max ? 0 : row + 1; break;
+ case "start": row = 0; break;
+ case "end": row = max; break;
+ }
+
+ this.popup.setRow(row);
+ };
+
+ this.insertMatch = function(data) {
+ this.detach();
+ if (!data)
+ data = this.popup.getData(this.popup.getRow());
+ if (!data)
+ return false;
+ if (data.completer && data.completer.insertMatch) {
+ data.completer.insertMatch(this.editor);
+ } else {
+ if (this.completions.filterText) {
+ var range = this.editor.selection.getRange();
+ range.start.column -= this.completions.filterText.length;
+ this.editor.session.remove(range);
+ }
+ if (data.snippet)
+ snippetManager.insertSnippet(this.editor, data.snippet);
+ else
+ this.editor.insert(data.value || data);
+ }
+ };
+
+ this.commands = {
+ "Up": function(editor) { editor.completer.goTo("up"); },
+ "Down": function(editor) { editor.completer.goTo("down"); },
+ "Ctrl-Up|Ctrl-Home": function(editor) { editor.completer.goTo("start"); },
+ "Ctrl-Down|Ctrl-End": function(editor) { editor.completer.goTo("end"); },
+
+ "Esc": function(editor) { editor.completer.detach(); },
+ "Space": function(editor) { editor.completer.detach(); editor.insert(" ");},
+ "Return": function(editor) { editor.completer.insertMatch(); },
+ "Shift-Return": function(editor) { editor.completer.insertMatch(true); },
+ "Tab": function(editor) { editor.completer.insertMatch(); },
+
+ "PageUp": function(editor) { editor.completer.popup.gotoPageDown(); },
+ "PageDown": function(editor) { editor.completer.popup.gotoPageUp(); }
+ };
+
+ this.gatherCompletions = function(editor, callback) {
+ var session = editor.getSession();
+ var pos = editor.getCursorPosition();
+
+ var line = session.getLine(pos.row);
+ var prefix = util.retrievePrecedingIdentifier(line, pos.column);
+
+ var matches = [];
+ util.parForEach(editor.completers, function(completer, next) {
+ completer.getCompletions(editor, session, pos, prefix, function(err, results) {
+ if (!err)
+ matches = matches.concat(results);
+ next();
+ });
+ }, function() {
+ matches.sort(function(a, b) {
+ return b.score - a.score;
+ });
+ callback(null, {
+ prefix: prefix,
+ matches: matches
+ });
+ });
+ return true;
+ };
+
+ this.showPopup = function(editor) {
+ if (this.editor)
+ this.detach();
+
+ this.activated = true;
+
+ this.editor = editor;
+ if (editor.completer != this) {
+ if (editor.completer)
+ editor.completer.detach();
+ editor.completer = this;
+ }
+
+ editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
+ editor.on("changeSelection", this.changeListener);
+ editor.on("blur", this.blurListener);
+ editor.on("mousedown", this.mousedownListener);
+ this.updateCompletions();
+ }
+
+ this.updateCompletions = function(keepPopupPosition) {
+ this.gatherCompletions(this.editor, function(err, results) {
+ var matches = results && results.matches;
+ if (!matches || !matches.length)
+ return this.detach();
+
+ this.completions = new FilteredList(matches);
+ this.completions.setFilter(results.prefix);
+ this.openPopup(this.editor, keepPopupPosition);
+ this.popup.setHighlight(results.prefix);
+ }.bind(this));
+ };
+
+ this.cancelContextMenu = function() {
+ var stop = function(e) {
+ this.editor.off("nativecontextmenu", stop);
+ if (e && e.domEvent)
+ event.stopEvent(e.domEvent);
+ }.bind(this);
+ setTimeout(stop, 10);
+ this.editor.on("nativecontextmenu", stop);
+ };
+
+}).call(Autocomplete.prototype);
+
+Autocomplete.startCommand = {
+ name: "startAutocomplete",
+ exec: function(editor) {
+ if (!editor.completer)
+ editor.completer = new Autocomplete();
+ editor.completer.showPopup(editor);
+ editor.completer.cancelContextMenu();
+ },
+ bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space"
+};
+
+var FilteredList = function(array, mutateData) {
+ this.all = array;
+ this.filtered = array.concat();
+ this.filterText = "";
+};
+(function(){
+ this.setFilter = function(str) {
+ this.filterText = str;
+ };
+
+}).call(FilteredList.prototype);
+
+exports.Autocomplete = Autocomplete;
+exports.FilteredList = FilteredList;
+
+});
+
+ace.define('ace/autocomplete/popup', ['require', 'exports', 'module' , 'ace/edit_session', 'ace/virtual_renderer', 'ace/editor', 'ace/range', 'ace/lib/event', 'ace/lib/lang', 'ace/lib/dom'], function(require, exports, module) {
+
+
+var EditSession = require("../edit_session").EditSession;
+var Renderer = require("../virtual_renderer").VirtualRenderer;
+var Editor = require("../editor").Editor;
+var Range = require("../range").Range;
+var event = require("../lib/event");
+var lang = require("../lib/lang");
+var dom = require("../lib/dom");
+
+var $singleLineEditor = function(el) {
+ var renderer = new Renderer(el);
+
+ renderer.$maxLines = 4;
+
+ var editor = new Editor(renderer);
+
+ editor.setHighlightActiveLine(false);
+ editor.setShowPrintMargin(false);
+ editor.renderer.setShowGutter(false);
+ editor.renderer.setHighlightGutterLine(false);
+
+ editor.$mouseHandler.$focusWaitTimout = 0;
+
+ return editor;
+};
+
+var AcePopup = function(parentNode) {
+ var el = dom.createElement("div");
+ var popup = new $singleLineEditor(el);
+
+ if (parentNode)
+ parentNode.appendChild(el);
+ el.style.display = "none";
+ popup.renderer.content.style.cursor = "default";
+ popup.renderer.setStyle("ace_autocomplete");
+
+ var noop = function(){};
+
+ popup.focus = noop;
+ popup.$isFocused = true;
+
+ popup.renderer.$cursorLayer.restartTimer = noop;
+ popup.renderer.$cursorLayer.element.style.opacity = 0;
+
+ popup.renderer.$maxLines = 8;
+ popup.renderer.$keepTextAreaAtCursor = false;
+
+ popup.setHighlightActiveLine(true);
+ popup.session.highlight("");
+ popup.session.$searchHighlight.clazz = "ace_highlight-marker";
+
+ popup.on("mousedown", function(e) {
+ var pos = e.getDocumentPosition();
+ popup.moveCursorToPosition(pos);
+ popup.selection.clearSelection();
+ e.stop();
+ });
+
+ var hoverMarker = new Range(-1,0,-1,Infinity);
+ hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine");
+ popup.on("mousemove", function(e) {
+ var row = e.getDocumentPosition().row;
+ hoverMarker.start.row = hoverMarker.end.row = row;
+ popup.session._emit("changeBackMarker");
+ });
+ var hideHoverMarker = function() {
+ hoverMarker.start.row = hoverMarker.end.row = -1;
+ popup.session._emit("changeBackMarker");
+ };
+ event.addListener(popup.container, "mouseout", hideHoverMarker);
+ popup.on("hide", hideHoverMarker);
+ popup.on("changeSelection", hideHoverMarker);
+ popup.on("mousewheel", function(e) {
+ setTimeout(function() {
+ popup._signal("mousemove", e);
+ });
+ });
+
+ popup.session.doc.getLength = function() {
+ return popup.data.length;
+ };
+ popup.session.doc.getLine = function(i) {
+ var data = popup.data[i];
+ if (typeof data == "string")
+ return data;
+ return (data && data.value) || "";
+ };
+
+ var bgTokenizer = popup.session.bgTokenizer;
+ bgTokenizer.$tokenizeRow = function(i) {
+ var data = popup.data[i];
+ var tokens = [];
+ if (!data)
+ return tokens;
+ if (typeof data == "string")
+ data = {value: data};
+ if (!data.caption)
+ data.caption = data.value;
+
+ tokens.push({type: data.className || "", value: data.caption});
+ if (data.meta) {
+ var maxW = popup.renderer.$size.scrollerWidth / popup.renderer.layerConfig.characterWidth;
+ if (data.meta.length + data.caption.length < maxW - 2)
+ tokens.push({type: "rightAlignedText", value: data.meta});
+ }
+ return tokens;
+ };
+ bgTokenizer.$updateOnChange = noop;
+
+ popup.session.$computeWidth = function() {
+ return this.screenWidth = 0;
+ }
+ popup.data = [];
+ popup.setData = function(list) {
+ popup.data = list || [];
+ popup.setValue(lang.stringRepeat("\n", list.length), -1);
+ };
+ popup.getData = function(row) {
+ return popup.data[row];
+ };
+
+ popup.getRow = function() {
+ var line = this.getCursorPosition().row;
+ if (line == 0 && !this.getHighlightActiveLine())
+ line = -1;
+ return line;
+ };
+ popup.setRow = function(line) {
+ popup.setHighlightActiveLine(line != -1);
+ popup.selection.clearSelection();
+ popup.moveCursorTo(line, 0 || 0);
+ };
+
+ popup.setHighlight = function(re) {
+ popup.session.highlight(re);
+ popup.session._emit("changeFrontMarker");
+ };
+
+ popup.hide = function() {
+ this.container.style.display = "none";
+ this._signal("hide");
+ };
+ popup.show = function(pos, lineHeight) {
+ var el = this.container;
+ if (pos.top > window.innerHeight / 2 + lineHeight) {
+ el.style.top = "";
+ el.style.bottom = window.innerHeight - pos.top + "px";
+ } else {
+ pos.top += lineHeight;
+ el.style.top = pos.top + "px";
+ el.style.bottom = "";
+ }
+
+ el.style.left = pos.left + "px";
+ el.style.display = "";
+ this.renderer.$textLayer.checkForSizeChanges();
+
+ this._signal("show");
+ };
+
+ return popup;
+};
+
+dom.importCssString("\
+.ace_autocomplete.ace-tm .ace_marker-layer .ace_active-line {\
+ background-color: #abbffe;\
+}\
+.ace_autocomplete.ace-tm .ace_line-hover {\
+ border: 1px solid #abbffe;\
+ position: absolute;\
+ background: rgba(233,233,253,0.4);\
+ z-index: 2;\
+ margin-top: -1px;\
+}\
+.ace_rightAlignedText {\
+ color: gray;\
+ display: inline-block;\
+ position: absolute;\
+ right: 4px;\
+ text-align: right;\
+ z-index: -1;\
+}\
+.ace_autocomplete {\
+ width: 200px;\
+ z-index: 200000;\
+ background: #f8f8f8;\
+ border: 1px lightgray solid;\
+ position: fixed;\
+ box-shadow: 2px 3px 5px rgba(0,0,0,.2);\
+}");
+
+exports.AcePopup = AcePopup;
+
+});
+
+ace.define('ace/autocomplete/util', ['require', 'exports', 'module' ], function(require, exports, module) {
+
+
+exports.parForEach = function(array, fn, callback) {
+ var completed = 0;
+ var arLength = array.length;
+ if (arLength === 0)
+ callback();
+ for (var i = 0; i < arLength; i++) {
+ fn(array[i], function(result, err) {
+ completed++;
+ if (completed === arLength)
+ callback(result, err);
+ });
+ }
+}
+
+var ID_REGEX = /[a-zA-Z_0-9\$-\.]/;
+
+exports.retrievePrecedingIdentifier = function(text, pos, regex) {
+ regex = regex || ID_REGEX;
+ var buf = [];
+ for (var i = pos-1; i >= 0; i--) {
+ if (regex.test(text[i]))
+ buf.push(text[i]);
+ else
+ break;
+ }
+ return buf.reverse().join("");
+}
+
+exports.retrieveFollowingIdentifier = function(text, pos, regex) {
+ regex = regex || ID_REGEX;
+ var buf = [];
+ for (var i = pos; i < text.length; i++) {
+ if (regex.test(text[i]))
+ buf.push(text[i]);
+ else
+ break;
+ }
+ return buf;
+}
+
+});
+
+ace.define('ace/autocomplete/text_completer', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
+ var Range = require("ace/range").Range;
+
+ var splitRegex = /[^a-zA-Z_0-9\$\-]+/;
+
+ function getWordIndex(doc, pos) {
+ var textBefore = doc.getTextRange(Range.fromPoints({row: 0, column:0}, pos));
+ return textBefore.split(splitRegex).length - 1;
+ }
+ function filterPrefix(prefix, words) {
+ var results = [];
+ for (var i = 0; i < words.length; i++) {
+ if (words[i].lastIndexOf(prefix, 0) === 0) {
+ results.push(words[i]);
+ }
+ }
+ return results;
+ }
+ function wordDistance(doc, pos) {
+ var prefixPos = getWordIndex(doc, pos);
+ var words = doc.getValue().split(splitRegex);
+ var wordScores = Object.create(null);
+
+ var currentWord = words[prefixPos];
+
+ words.forEach(function(word, idx) {
+ if (!word || word === currentWord) return;
+
+ var distance = Math.abs(prefixPos - idx);
+ var score = words.length - distance;
+ if (wordScores[word]) {
+ wordScores[word] = Math.max(score, wordScores[word]);
+ } else {
+ wordScores[word] = score;
+ }
+ });
+ return wordScores;
+ }
+
+ exports.getCompletions = function(editor, session, pos, prefix, callback) {
+ var wordScore = wordDistance(session, pos, prefix);
+ var wordList = filterPrefix(prefix, Object.keys(wordScore));
+ callback(null, wordList.map(function(word) {
+ return {
+ name: word,
+ value: word,
+ score: wordScore[word],
+ meta: "local"
+ };
+ }));
+ };
+}); \ No newline at end of file
diff --git a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/mode-javascript.js b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/mode-javascript.js
index bc71ab9..cd030c4 100644
--- a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/mode-javascript.js
+++ b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/mode-javascript.js
@@ -1,899 +1,888 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) {
-
-
-var oop = require("../lib/oop");
-var TextMode = require("./text").Mode;
-var Tokenizer = require("../tokenizer").Tokenizer;
-var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
-var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
-var Range = require("../range").Range;
-var WorkerClient = require("../worker/worker_client").WorkerClient;
-var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
-var CStyleFoldMode = require("./folding/cstyle").FoldMode;
-
-var Mode = function() {
- var highlighter = new JavaScriptHighlightRules();
-
- this.$tokenizer = new Tokenizer(highlighter.getRules());
- this.$outdent = new MatchingBraceOutdent();
- this.$behaviour = new CstyleBehaviour();
- this.$keywordList = highlighter.$keywordList;
- 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" || state == "regex_allowed") {
- var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
- if (match) {
- indent += tab;
- }
- } else if (state == "doc-start") {
- if (endState == "start" || state == "regex_allowed") {
- 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);
- };
-
- this.createWorker = function(session) {
- var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
- worker.attachToDocument(session.getDocument());
-
- worker.on("jslint", function(results) {
- session.setAnnotations(results.data);
- });
-
- worker.on("terminate", function() {
- session.clearAnnotations();
- });
-
- return worker;
- };
-
-}).call(Mode.prototype);
-
-exports.Mode = Mode;
-});
-
-define('ace/mode/javascript_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
-
-
-var oop = require("../lib/oop");
-var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
-var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
-
-var JavaScriptHighlightRules = function() {
- var keywordMapper = this.createKeywordMapper({
- "variable.language":
- "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
- "Namespace|QName|XML|XMLList|" + // E4X
- "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
- "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
- "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
- "SyntaxError|TypeError|URIError|" +
- "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
- "isNaN|parseFloat|parseInt|" +
- "JSON|Math|" + // Other
- "this|arguments|prototype|window|document" , // Pseudo
- "keyword":
- "const|yield|import|get|set|" +
- "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
- "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
- "__parent__|__count__|escape|unescape|with|__proto__|" +
- "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
- "storage.type":
- "const|let|var|function",
- "constant.language":
- "null|Infinity|NaN|undefined",
- "support.function":
- "alert",
- "constant.language.boolean": "true|false"
- }, "identifier");
- var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
- var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
-
- var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
- "u[0-9a-fA-F]{4}|" + // unicode
- "[0-2][0-7]{0,2}|" + // oct
- "3[0-6][0-7]?|" + // oct
- "37[0-7]?|" + // oct
- "[4-7][0-7]?|" + //oct
- ".)";
-
- this.$rules = {
- "start" : [
- {
- token : "comment",
- regex : /\/\/.*$/
- },
- DocCommentHighlightRules.getStartRule("doc-start"),
- {
- token : "comment", // multi line comment
- regex : /\/\*/,
- next : "comment"
- }, {
- token : "string",
- regex : "'(?=.)",
- next : "qstring"
- }, {
- token : "string",
- regex : '"(?=.)',
- next : "qqstring"
- }, {
- token : "constant.numeric", // hex
- regex : /0[xX][0-9a-fA-F]+\b/
- }, {
- token : "constant.numeric", // float
- regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
- }, {
- token : [
- "storage.type", "punctuation.operator", "support.function",
- "punctuation.operator", "entity.name.function", "text","keyword.operator"
- ],
- regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
- next: "function_arguments"
- }, {
- token : [
- "storage.type", "punctuation.operator", "entity.name.function", "text",
- "keyword.operator", "text", "storage.type", "text", "paren.lparen"
- ],
- regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
- next: "function_arguments"
- }, {
- token : [
- "entity.name.function", "text", "keyword.operator", "text", "storage.type",
- "text", "paren.lparen"
- ],
- regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
- next: "function_arguments"
- }, {
- token : [
- "storage.type", "punctuation.operator", "entity.name.function", "text",
- "keyword.operator", "text",
- "storage.type", "text", "entity.name.function", "text", "paren.lparen"
- ],
- regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
- next: "function_arguments"
- }, {
- token : [
- "storage.type", "text", "entity.name.function", "text", "paren.lparen"
- ],
- regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
- next: "function_arguments"
- }, {
- token : [
- "entity.name.function", "text", "punctuation.operator",
- "text", "storage.type", "text", "paren.lparen"
- ],
- regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
- next: "function_arguments"
- }, {
- token : [
- "text", "text", "storage.type", "text", "paren.lparen"
- ],
- regex : "(:)(\\s*)(function)(\\s*)(\\()",
- next: "function_arguments"
- }, {
- token : "keyword",
- regex : "(?:" + kwBeforeRe + ")\\b",
- next : "regex_allowed"
- }, {
- token : ["punctuation.operator", "support.function"],
- regex : /(\.)(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 : ["punctuation.operator", "support.function.dom"],
- regex : /(\.)(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 : ["punctuation.operator", "support.constant"],
- regex : /(\.)(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 : ["storage.type", "punctuation.operator", "support.function.firebug"],
- regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
- }, {
- token : keywordMapper,
- regex : identifierRe
- }, {
- token : "keyword.operator",
- regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/,
- next : "regex_allowed"
- }, {
- token : "punctuation.operator",
- regex : /\?|\:|\,|\;|\./,
- next : "regex_allowed"
- }, {
- token : "paren.lparen",
- regex : /[\[({]/,
- next : "regex_allowed"
- }, {
- token : "paren.rparen",
- regex : /[\])}]/
- }, {
- token : "keyword.operator",
- regex : /\/=?/,
- next : "regex_allowed"
- }, {
- token: "comment",
- regex: /^#!.*$/
- }
- ],
- "regex_allowed": [
- DocCommentHighlightRules.getStartRule("doc-start"),
- {
- token : "comment", // multi line comment
- regex : "\\/\\*",
- next : "comment_regex_allowed"
- }, {
- token : "comment",
- regex : "\\/\\/.*$"
- }, {
- token: "string.regexp",
- regex: "\\/",
- next: "regex",
- }, {
- token : "text",
- regex : "\\s+"
- }, {
- token: "empty",
- regex: "",
- next: "start"
- }
- ],
- "regex": [
- {
- token: "regexp.keyword.operator",
- regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
- }, {
- token: "string.regexp",
- regex: "/\\w*",
- next: "start",
- }, {
- token : "invalid",
- regex: /\{\d+,?(?:\d+)?}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
- }, {
- token : "constant.language.escape",
- regex: /\(\?[:=!]|\)|{\d+,?(?:\d+)?}|{,\d+}|[+*]\?|[()$^+*?]/
- }, {
- token : "constant.language.delimiter",
- regex: /\|/
- }, {
- token: "constant.language.escape",
- regex: /\[\^?/,
- next: "regex_character_class",
- }, {
- token: "empty",
- regex: "$",
- next: "start"
- }, {
- defaultToken: "string.regexp"
- }
- ],
- "regex_character_class": [
- {
- token: "regexp.keyword.operator",
- regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
- }, {
- token: "constant.language.escape",
- regex: "]",
- next: "regex",
- }, {
- token: "constant.language.escape",
- regex: "-"
- }, {
- token: "empty",
- regex: "$",
- next: "start"
- }, {
- defaultToken: "string.regexp.charachterclass"
- }
- ],
- "function_arguments": [
- {
- token: "variable.parameter",
- regex: identifierRe
- }, {
- token: "punctuation.operator",
- regex: "[, ]+",
- }, {
- token: "punctuation.operator",
- regex: "$",
- }, {
- token: "empty",
- regex: "",
- next: "start"
- }
- ],
- "comment_regex_allowed" : [
- {token : "comment", regex : "\\*\\/", next : "regex_allowed"},
- {defaultToken : "comment"}
- ],
- "comment" : [
- {token : "comment", regex : "\\*\\/", next : "start"},
- {defaultToken : "comment"}
- ],
- "qqstring" : [
- {
- token : "constant.language.escape",
- regex : escapedRe
- }, {
- token : "string",
- regex : "\\\\$",
- next : "qqstring",
- }, {
- token : "string",
- regex : '"|$',
- next : "start",
- }, {
- defaultToken: "string"
- }
- ],
- "qstring" : [
- {
- token : "constant.language.escape",
- regex : escapedRe
- }, {
- token : "string",
- regex : "\\\\$",
- next : "qstring",
- }, {
- token : "string",
- regex : "'|$",
- next : "start",
- }, {
- defaultToken: "string"
- }
- ]
- };
-
- this.embedRules(DocCommentHighlightRules, "doc-",
- [ DocCommentHighlightRules.getEndRule("start") ]);
-};
-
-oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
-
-exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
-});
-
-define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
-
-
-var oop = require("../lib/oop");
-var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
-
-var DocCommentHighlightRules = function() {
-
- this.$rules = {
- "start" : [ {
- token : "comment.doc.tag",
- regex : "@[\\w\\d_]+" // TODO: fix email addresses
- }, {
- token : "comment.doc.tag",
- regex : "\\bTODO\\b"
- }, {
- defaultToken : "comment.doc"
- }]
- };
-};
-
-oop.inherits(DocCommentHighlightRules, TextHighlightRules);
-
-DocCommentHighlightRules.getStartRule = function(start) {
- return {
- token : "comment.doc", // doc comment
- regex : "\\/\\*(?=\\*)",
- next : start
- };
-};
-
-DocCommentHighlightRules.getEndRule = function (start) {
- return {
- token : "comment.doc", // closing comment
- regex : "\\*\\/",
- next : start
- };
-};
-
-
-exports.DocCommentHighlightRules = DocCommentHighlightRules;
-
-});
-
-define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
-
-
-var Range = require("../range").Range;
-
-var MatchingBraceOutdent = function() {};
-
-(function() {
-
- this.checkOutdent = function(line, input) {
- if (! /^\s+$/.test(line))
- return false;
-
- return /^\s*\}/.test(input);
- };
-
- this.autoOutdent = function(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 "";
- };
-
-}).call(MatchingBraceOutdent.prototype);
-
-exports.MatchingBraceOutdent = MatchingBraceOutdent;
-});
-
-define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
-
-
-var oop = require("../../lib/oop");
-var Behaviour = require("../behaviour").Behaviour;
-var TokenIterator = require("../../token_iterator").TokenIterator;
-var lang = require("../../lib/lang");
-
-var SAFE_INSERT_IN_TOKENS =
- ["text", "paren.rparen", "punctuation.operator"];
-var SAFE_INSERT_BEFORE_TOKENS =
- ["text", "paren.rparen", "punctuation.operator", "comment"];
-
-
-var autoInsertedBrackets = 0;
-var autoInsertedRow = -1;
-var autoInsertedLineEnd = "";
-var maybeInsertedBrackets = 0;
-var maybeInsertedRow = -1;
-var maybeInsertedLineStart = "";
-var maybeInsertedLineEnd = "";
-
-var CstyleBehaviour = function () {
-
- CstyleBehaviour.isSaneInsertion = function(editor, session) {
- var cursor = editor.getCursorPosition();
- var iterator = new TokenIterator(session, cursor.row, cursor.column);
- if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
- var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
- if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
- return false;
- }
- iterator.stepForward();
- return iterator.getCurrentTokenRow() !== cursor.row ||
- this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
- };
-
- CstyleBehaviour.$matchTokenType = function(token, types) {
- return types.indexOf(token.type || token) > -1;
- };
-
- CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
- var cursor = editor.getCursorPosition();
- var line = session.doc.getLine(cursor.row);
- if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
- autoInsertedBrackets = 0;
- autoInsertedRow = cursor.row;
- autoInsertedLineEnd = bracket + line.substr(cursor.column);
- autoInsertedBrackets++;
- };
-
- CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
- var cursor = editor.getCursorPosition();
- var line = session.doc.getLine(cursor.row);
- if (!this.isMaybeInsertedClosing(cursor, line))
- maybeInsertedBrackets = 0;
- maybeInsertedRow = cursor.row;
- maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
- maybeInsertedLineEnd = line.substr(cursor.column);
- maybeInsertedBrackets++;
- };
-
- CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
- return autoInsertedBrackets > 0 &&
- cursor.row === autoInsertedRow &&
- bracket === autoInsertedLineEnd[0] &&
- line.substr(cursor.column) === autoInsertedLineEnd;
- };
-
- CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
- return maybeInsertedBrackets > 0 &&
- cursor.row === maybeInsertedRow &&
- line.substr(cursor.column) === maybeInsertedLineEnd &&
- line.substr(0, cursor.column) == maybeInsertedLineStart;
- };
-
- CstyleBehaviour.popAutoInsertedClosing = function() {
- autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
- autoInsertedBrackets--;
- };
-
- CstyleBehaviour.clearMaybeInsertedClosing = function() {
- maybeInsertedBrackets = 0;
- maybeInsertedRow = -1;
- };
-
- this.add("braces", "insertion", function (state, action, editor, session, text) {
- var cursor = editor.getCursorPosition();
- var line = session.doc.getLine(cursor.row);
- if (text == '{') {
- var selection = editor.getSelectionRange();
- var selected = session.doc.getTextRange(selection);
- if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
- return {
- text: '{' + selected + '}',
- selection: false
- };
- } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
- if (/[\]\}\)]/.test(line[cursor.column])) {
- CstyleBehaviour.recordAutoInsert(editor, session, "}");
- return {
- text: '{}',
- selection: [1, 1]
- };
- } else {
- CstyleBehaviour.recordMaybeInsert(editor, session, "{");
- return {
- text: '{',
- selection: [1, 1]
- };
- }
- }
- } else if (text == '}') {
- 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 && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
- CstyleBehaviour.popAutoInsertedClosing();
- return {
- text: '',
- selection: [1, 1]
- };
- }
- }
- } else if (text == "\n" || text == "\r\n") {
- var closing = "";
- if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
- closing = lang.stringRepeat("}", maybeInsertedBrackets);
- CstyleBehaviour.clearMaybeInsertedClosing();
- }
- var rightChar = line.substring(cursor.column, cursor.column + 1);
- if (rightChar == '}' || closing !== "") {
- var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column}, '}');
- if (!openBracePos)
- return null;
-
- var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
- var next_indent = this.$getIndent(line);
-
- return {
- text: '\n' + indent + '\n' + next_indent + closing,
- 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;
- } else {
- maybeInsertedBrackets--;
- }
- }
- });
-
- this.add("parens", "insertion", function (state, action, editor, session, text) {
- if (text == '(') {
- var selection = editor.getSelectionRange();
- var selected = session.doc.getTextRange(selection);
- if (selected !== "" && editor.getWrapBehavioursEnabled()) {
- return {
- text: '(' + selected + ')',
- selection: false
- };
- } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
- CstyleBehaviour.recordAutoInsert(editor, session, ")");
- 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 && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
- CstyleBehaviour.popAutoInsertedClosing();
- 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("brackets", "insertion", function (state, action, editor, session, text) {
- if (text == '[') {
- var selection = editor.getSelectionRange();
- var selected = session.doc.getTextRange(selection);
- if (selected !== "" && editor.getWrapBehavioursEnabled()) {
- return {
- text: '[' + selected + ']',
- selection: false
- };
- } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
- CstyleBehaviour.recordAutoInsert(editor, session, "]");
- 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 && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
- CstyleBehaviour.popAutoInsertedClosing();
- return {
- text: '',
- selection: [1, 1]
- };
- }
- }
- }
- });
-
- this.add("brackets", "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 !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
- 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);
- if (leftChar == '\\') {
- return null;
- }
- var tokens = session.getTokens(selection.start.row);
- 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;
- }
- 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)))) {
- if (!CstyleBehaviour.isSaneInsertion(editor, session))
- return;
- return {
- text: quote + quote,
- selection: [1,1]
- };
- } else if (token && token.type === "string") {
- 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 == selected) {
- range.end.column++;
- return range;
- }
- }
- });
-
-};
-
-oop.inherits(CstyleBehaviour, Behaviour);
-
-exports.CstyleBehaviour = CstyleBehaviour;
-});
-
-define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
-
-
-var oop = require("../../lib/oop");
-var Range = require("../../range").Range;
-var BaseFoldMode = require("./fold_mode").FoldMode;
-
-var FoldMode = exports.FoldMode = function() {};
-oop.inherits(FoldMode, BaseFoldMode);
-
-(function() {
-
- this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
- this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
-
- this.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])
- return this.openingBracketBlock(session, match[1], row, i);
-
- return session.getCommentFoldRange(row, i + match[0].length, 1);
- }
-
- if (foldStyle !== "markbeginend")
- return;
-
- var match = line.match(this.foldingStopMarker);
- if (match) {
- var i = match.index + match[0].length;
-
- if (match[1])
- return this.closingBracketBlock(session, match[1], row, i);
-
- return session.getCommentFoldRange(row, i, -1);
- }
- };
-
-}).call(FoldMode.prototype);
-
-});
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2010, Ajax.org B.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Ajax.org B.V. nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+ace.define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) {
+
+
+var oop = require("../lib/oop");
+var TextMode = require("./text").Mode;
+var Tokenizer = require("../tokenizer").Tokenizer;
+var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
+var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
+var Range = require("../range").Range;
+var WorkerClient = require("../worker/worker_client").WorkerClient;
+var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
+var CStyleFoldMode = require("./folding/cstyle").FoldMode;
+
+var Mode = function() {
+ var highlighter = new JavaScriptHighlightRules();
+
+ this.$tokenizer = new Tokenizer(highlighter.getRules());
+ this.$outdent = new MatchingBraceOutdent();
+ this.$behaviour = new CstyleBehaviour();
+ this.$keywordList = highlighter.$keywordList;
+ this.foldingRules = new CStyleFoldMode();
+};
+oop.inherits(Mode, TextMode);
+
+(function() {
+
+ this.lineCommentStart = "//";
+ this.blockComment = {start: "/*", end: "*/"};
+
+ 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" || state == "no_regex") {
+ var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
+ if (match) {
+ indent += tab;
+ }
+ } else if (state == "doc-start") {
+ if (endState == "start" || endState == "no_regex") {
+ 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);
+ };
+
+ this.createWorker = function(session) {
+ var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
+ worker.attachToDocument(session.getDocument());
+
+ worker.on("jslint", function(results) {
+ session.setAnnotations(results.data);
+ });
+
+ worker.on("terminate", function() {
+ session.clearAnnotations();
+ });
+
+ return worker;
+ };
+
+}).call(Mode.prototype);
+
+exports.Mode = Mode;
+});
+
+ace.define('ace/mode/javascript_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
+
+
+var oop = require("../lib/oop");
+var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
+var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
+
+var JavaScriptHighlightRules = function() {
+ var keywordMapper = this.createKeywordMapper({
+ "variable.language":
+ "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
+ "Namespace|QName|XML|XMLList|" + // E4X
+ "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
+ "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
+ "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
+ "SyntaxError|TypeError|URIError|" +
+ "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
+ "isNaN|parseFloat|parseInt|" +
+ "JSON|Math|" + // Other
+ "this|arguments|prototype|window|document" , // Pseudo
+ "keyword":
+ "const|yield|import|get|set|" +
+ "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
+ "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
+ "__parent__|__count__|escape|unescape|with|__proto__|" +
+ "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
+ "storage.type":
+ "const|let|var|function",
+ "constant.language":
+ "null|Infinity|NaN|undefined",
+ "support.function":
+ "alert",
+ "constant.language.boolean": "true|false"
+ }, "identifier");
+ var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
+ var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
+
+ var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
+ "u[0-9a-fA-F]{4}|" + // unicode
+ "[0-2][0-7]{0,2}|" + // oct
+ "3[0-6][0-7]?|" + // oct
+ "37[0-7]?|" + // oct
+ "[4-7][0-7]?|" + //oct
+ ".)";
+
+ this.$rules = {
+ "no_regex" : [
+ {
+ token : "comment",
+ regex : "\\/\\/",
+ next : "line_comment"
+ },
+ DocCommentHighlightRules.getStartRule("doc-start"),
+ {
+ token : "comment", // multi line comment
+ regex : /\/\*/,
+ next : "comment"
+ }, {
+ token : "string",
+ regex : "'(?=.)",
+ next : "qstring"
+ }, {
+ token : "string",
+ regex : '"(?=.)',
+ next : "qqstring"
+ }, {
+ token : "constant.numeric", // hex
+ regex : /0[xX][0-9a-fA-F]+\b/
+ }, {
+ token : "constant.numeric", // float
+ regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
+ }, {
+ token : [
+ "storage.type", "punctuation.operator", "support.function",
+ "punctuation.operator", "entity.name.function", "text","keyword.operator"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
+ next: "function_arguments"
+ }, {
+ token : [
+ "storage.type", "punctuation.operator", "entity.name.function", "text",
+ "keyword.operator", "text", "storage.type", "text", "paren.lparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
+ next: "function_arguments"
+ }, {
+ token : [
+ "entity.name.function", "text", "keyword.operator", "text", "storage.type",
+ "text", "paren.lparen"
+ ],
+ regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
+ next: "function_arguments"
+ }, {
+ token : [
+ "storage.type", "punctuation.operator", "entity.name.function", "text",
+ "keyword.operator", "text",
+ "storage.type", "text", "entity.name.function", "text", "paren.lparen"
+ ],
+ regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
+ next: "function_arguments"
+ }, {
+ token : [
+ "storage.type", "text", "entity.name.function", "text", "paren.lparen"
+ ],
+ regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
+ next: "function_arguments"
+ }, {
+ token : [
+ "entity.name.function", "text", "punctuation.operator",
+ "text", "storage.type", "text", "paren.lparen"
+ ],
+ regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
+ next: "function_arguments"
+ }, {
+ token : [
+ "text", "text", "storage.type", "text", "paren.lparen"
+ ],
+ regex : "(:)(\\s*)(function)(\\s*)(\\()",
+ next: "function_arguments"
+ }, {
+ token : "keyword",
+ regex : "(?:" + kwBeforeRe + ")\\b",
+ next : "start"
+ }, {
+ token : ["punctuation.operator", "support.function"],
+ regex : /(\.)(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 : ["punctuation.operator", "support.function.dom"],
+ regex : /(\.)(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 : ["punctuation.operator", "support.constant"],
+ regex : /(\.)(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 : ["storage.type", "punctuation.operator", "support.function.firebug"],
+ regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
+ }, {
+ token : keywordMapper,
+ regex : identifierRe
+ }, {
+ token : "keyword.operator",
+ regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/,
+ next : "start"
+ }, {
+ token : "punctuation.operator",
+ regex : /\?|\:|\,|\;|\./,
+ next : "start"
+ }, {
+ token : "paren.lparen",
+ regex : /[\[({]/,
+ next : "start"
+ }, {
+ token : "paren.rparen",
+ regex : /[\])}]/
+ }, {
+ token : "keyword.operator",
+ regex : /\/=?/,
+ next : "start"
+ }, {
+ token: "comment",
+ regex: /^#!.*$/
+ }
+ ],
+ "start": [
+ DocCommentHighlightRules.getStartRule("doc-start"),
+ {
+ token : "comment", // multi line comment
+ regex : "\\/\\*",
+ next : "comment_regex_allowed"
+ }, {
+ token : "comment",
+ regex : "\\/\\/",
+ next : "line_comment_regex_allowed"
+ }, {
+ token: "string.regexp",
+ regex: "\\/",
+ next: "regex"
+ }, {
+ token : "text",
+ regex : "\\s+|^$",
+ next : "start"
+ }, {
+ token: "empty",
+ regex: "",
+ next: "no_regex"
+ }
+ ],
+ "regex": [
+ {
+ token: "regexp.keyword.operator",
+ regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
+ }, {
+ token: "string.regexp",
+ regex: "/\\w*",
+ next: "no_regex"
+ }, {
+ token : "invalid",
+ regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
+ }, {
+ token : "constant.language.escape",
+ regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?]/
+ }, {
+ token : "constant.language.delimiter",
+ regex: /\|/
+ }, {
+ token: "constant.language.escape",
+ regex: /\[\^?/,
+ next: "regex_character_class"
+ }, {
+ token: "empty",
+ regex: "$",
+ next: "no_regex"
+ }, {
+ defaultToken: "string.regexp"
+ }
+ ],
+ "regex_character_class": [
+ {
+ token: "regexp.keyword.operator",
+ regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
+ }, {
+ token: "constant.language.escape",
+ regex: "]",
+ next: "regex"
+ }, {
+ token: "constant.language.escape",
+ regex: "-"
+ }, {
+ token: "empty",
+ regex: "$",
+ next: "no_regex"
+ }, {
+ defaultToken: "string.regexp.charachterclass"
+ }
+ ],
+ "function_arguments": [
+ {
+ token: "variable.parameter",
+ regex: identifierRe
+ }, {
+ token: "punctuation.operator",
+ regex: "[, ]+"
+ }, {
+ token: "punctuation.operator",
+ regex: "$"
+ }, {
+ token: "empty",
+ regex: "",
+ next: "no_regex"
+ }
+ ],
+ "comment_regex_allowed" : [
+ {token : "comment", regex : "\\*\\/", next : "start"},
+ {defaultToken : "comment"}
+ ],
+ "comment" : [
+ {token : "comment", regex : "\\*\\/", next : "no_regex"},
+ {defaultToken : "comment"}
+ ],
+ "line_comment_regex_allowed" : [
+ {token : "comment", regex : "$|^", next : "start"},
+ {defaultToken : "comment"}
+ ],
+ "line_comment" : [
+ {token : "comment", regex : "$|^", next : "no_regex"},
+ {defaultToken : "comment"}
+ ],
+ "qqstring" : [
+ {
+ token : "constant.language.escape",
+ regex : escapedRe
+ }, {
+ token : "string",
+ regex : "\\\\$",
+ next : "qqstring"
+ }, {
+ token : "string",
+ regex : '"|$',
+ next : "no_regex"
+ }, {
+ defaultToken: "string"
+ }
+ ],
+ "qstring" : [
+ {
+ token : "constant.language.escape",
+ regex : escapedRe
+ }, {
+ token : "string",
+ regex : "\\\\$",
+ next : "qstring"
+ }, {
+ token : "string",
+ regex : "'|$",
+ next : "no_regex"
+ }, {
+ defaultToken: "string"
+ }
+ ]
+ };
+
+ this.embedRules(DocCommentHighlightRules, "doc-",
+ [ DocCommentHighlightRules.getEndRule("no_regex") ]);
+};
+
+oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
+
+exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
+});
+
+ace.define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
+
+
+var oop = require("../lib/oop");
+var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
+
+var DocCommentHighlightRules = function() {
+
+ this.$rules = {
+ "start" : [ {
+ token : "comment.doc.tag",
+ regex : "@[\\w\\d_]+" // TODO: fix email addresses
+ }, {
+ token : "comment.doc.tag",
+ regex : "\\bTODO\\b"
+ }, {
+ defaultToken : "comment.doc"
+ }]
+ };
+};
+
+oop.inherits(DocCommentHighlightRules, TextHighlightRules);
+
+DocCommentHighlightRules.getStartRule = function(start) {
+ return {
+ token : "comment.doc", // doc comment
+ regex : "\\/\\*(?=\\*)",
+ next : start
+ };
+};
+
+DocCommentHighlightRules.getEndRule = function (start) {
+ return {
+ token : "comment.doc", // closing comment
+ regex : "\\*\\/",
+ next : start
+ };
+};
+
+
+exports.DocCommentHighlightRules = DocCommentHighlightRules;
+
+});
+
+ace.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
+
+
+var Range = require("../range").Range;
+
+var MatchingBraceOutdent = function() {};
+
+(function() {
+
+ this.checkOutdent = function(line, input) {
+ if (! /^\s+$/.test(line))
+ return false;
+
+ return /^\s*\}/.test(input);
+ };
+
+ this.autoOutdent = function(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) {
+ return line.match(/^\s*/)[0];
+ };
+
+}).call(MatchingBraceOutdent.prototype);
+
+exports.MatchingBraceOutdent = MatchingBraceOutdent;
+});
+
+ace.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
+
+
+var oop = require("../../lib/oop");
+var Behaviour = require("../behaviour").Behaviour;
+var TokenIterator = require("../../token_iterator").TokenIterator;
+var lang = require("../../lib/lang");
+
+var SAFE_INSERT_IN_TOKENS =
+ ["text", "paren.rparen", "punctuation.operator"];
+var SAFE_INSERT_BEFORE_TOKENS =
+ ["text", "paren.rparen", "punctuation.operator", "comment"];
+
+
+var autoInsertedBrackets = 0;
+var autoInsertedRow = -1;
+var autoInsertedLineEnd = "";
+var maybeInsertedBrackets = 0;
+var maybeInsertedRow = -1;
+var maybeInsertedLineStart = "";
+var maybeInsertedLineEnd = "";
+
+var CstyleBehaviour = function () {
+
+ CstyleBehaviour.isSaneInsertion = function(editor, session) {
+ var cursor = editor.getCursorPosition();
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
+ if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
+ var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
+ if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
+ return false;
+ }
+ iterator.stepForward();
+ return iterator.getCurrentTokenRow() !== cursor.row ||
+ this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
+ };
+
+ CstyleBehaviour.$matchTokenType = function(token, types) {
+ return types.indexOf(token.type || token) > -1;
+ };
+
+ CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
+ var cursor = editor.getCursorPosition();
+ var line = session.doc.getLine(cursor.row);
+ if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
+ autoInsertedBrackets = 0;
+ autoInsertedRow = cursor.row;
+ autoInsertedLineEnd = bracket + line.substr(cursor.column);
+ autoInsertedBrackets++;
+ };
+
+ CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
+ var cursor = editor.getCursorPosition();
+ var line = session.doc.getLine(cursor.row);
+ if (!this.isMaybeInsertedClosing(cursor, line))
+ maybeInsertedBrackets = 0;
+ maybeInsertedRow = cursor.row;
+ maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
+ maybeInsertedLineEnd = line.substr(cursor.column);
+ maybeInsertedBrackets++;
+ };
+
+ CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
+ return autoInsertedBrackets > 0 &&
+ cursor.row === autoInsertedRow &&
+ bracket === autoInsertedLineEnd[0] &&
+ line.substr(cursor.column) === autoInsertedLineEnd;
+ };
+
+ CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
+ return maybeInsertedBrackets > 0 &&
+ cursor.row === maybeInsertedRow &&
+ line.substr(cursor.column) === maybeInsertedLineEnd &&
+ line.substr(0, cursor.column) == maybeInsertedLineStart;
+ };
+
+ CstyleBehaviour.popAutoInsertedClosing = function() {
+ autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
+ autoInsertedBrackets--;
+ };
+
+ CstyleBehaviour.clearMaybeInsertedClosing = function() {
+ maybeInsertedBrackets = 0;
+ maybeInsertedRow = -1;
+ };
+
+ this.add("braces", "insertion", function (state, action, editor, session, text) {
+ var cursor = editor.getCursorPosition();
+ var line = session.doc.getLine(cursor.row);
+ if (text == '{') {
+ var selection = editor.getSelectionRange();
+ var selected = session.doc.getTextRange(selection);
+ if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
+ return {
+ text: '{' + selected + '}',
+ selection: false
+ };
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
+ if (/[\]\}\)]/.test(line[cursor.column])) {
+ CstyleBehaviour.recordAutoInsert(editor, session, "}");
+ return {
+ text: '{}',
+ selection: [1, 1]
+ };
+ } else {
+ CstyleBehaviour.recordMaybeInsert(editor, session, "{");
+ return {
+ text: '{',
+ selection: [1, 1]
+ };
+ }
+ }
+ } else if (text == '}') {
+ 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 && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
+ CstyleBehaviour.popAutoInsertedClosing();
+ return {
+ text: '',
+ selection: [1, 1]
+ };
+ }
+ }
+ } else if (text == "\n" || text == "\r\n") {
+ var closing = "";
+ if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
+ closing = lang.stringRepeat("}", maybeInsertedBrackets);
+ CstyleBehaviour.clearMaybeInsertedClosing();
+ }
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
+ if (rightChar == '}' || closing !== "") {
+ var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column}, '}');
+ if (!openBracePos)
+ return null;
+
+ var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
+ var next_indent = this.$getIndent(line);
+
+ return {
+ text: '\n' + indent + '\n' + next_indent + closing,
+ 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;
+ } else {
+ maybeInsertedBrackets--;
+ }
+ }
+ });
+
+ this.add("parens", "insertion", function (state, action, editor, session, text) {
+ if (text == '(') {
+ var selection = editor.getSelectionRange();
+ var selected = session.doc.getTextRange(selection);
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
+ return {
+ text: '(' + selected + ')',
+ selection: false
+ };
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
+ CstyleBehaviour.recordAutoInsert(editor, session, ")");
+ 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 && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
+ CstyleBehaviour.popAutoInsertedClosing();
+ 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("brackets", "insertion", function (state, action, editor, session, text) {
+ if (text == '[') {
+ var selection = editor.getSelectionRange();
+ var selected = session.doc.getTextRange(selection);
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
+ return {
+ text: '[' + selected + ']',
+ selection: false
+ };
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
+ CstyleBehaviour.recordAutoInsert(editor, session, "]");
+ 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 && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
+ CstyleBehaviour.popAutoInsertedClosing();
+ return {
+ text: '',
+ selection: [1, 1]
+ };
+ }
+ }
+ }
+ });
+
+ this.add("brackets", "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 !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
+ 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);
+ if (leftChar == '\\') {
+ return null;
+ }
+ var tokens = session.getTokens(selection.start.row);
+ 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;
+ }
+ 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)))) {
+ if (!CstyleBehaviour.isSaneInsertion(editor, session))
+ return;
+ return {
+ text: quote + quote,
+ selection: [1,1]
+ };
+ } else if (token && token.type === "string") {
+ 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 == selected) {
+ range.end.column++;
+ return range;
+ }
+ }
+ });
+
+};
+
+oop.inherits(CstyleBehaviour, Behaviour);
+
+exports.CstyleBehaviour = CstyleBehaviour;
+});
+
+ace.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
+
+
+var oop = require("../../lib/oop");
+var Range = require("../../range").Range;
+var BaseFoldMode = require("./fold_mode").FoldMode;
+
+var FoldMode = exports.FoldMode = function(commentRegex) {
+ if (commentRegex) {
+ this.foldingStartMarker = new RegExp(
+ this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
+ );
+ this.foldingStopMarker = new RegExp(
+ this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
+ );
+ }
+};
+oop.inherits(FoldMode, BaseFoldMode);
+
+(function() {
+
+ this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
+ this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
+
+ this.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])
+ return this.openingBracketBlock(session, match[1], row, i);
+
+ return session.getCommentFoldRange(row, i + match[0].length, 1);
+ }
+
+ if (foldStyle !== "markbeginend")
+ return;
+
+ var match = line.match(this.foldingStopMarker);
+ if (match) {
+ var i = match.index + match[0].length;
+
+ if (match[1])
+ return this.closingBracketBlock(session, match[1], row, i);
+
+ return session.getCommentFoldRange(row, i, -1);
+ }
+ };
+
+}).call(FoldMode.prototype);
+
+});
diff --git a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/snippets/javascript.js b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/snippets/javascript.js
new file mode 100644
index 0000000..c8845fb
--- /dev/null
+++ b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/snippets/javascript.js
@@ -0,0 +1,202 @@
+ace.define('ace/snippets/javascript', ['require', 'exports', 'module' ], function(require, exports, module) {
+
+
+exports.snippetText = "# Prototype\n\
+snippet proto\n\
+ ${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) {\n\
+ ${4:// body...}\n\
+ };\n\
+# Function\n\
+snippet fun\n\
+ function ${1?:function_name}(${2:argument}) {\n\
+ ${3:// body...}\n\
+ }\n\
+# Anonymous Function\n\
+regex /((=)\\s*|(:)\\s*|(\\()|\\b)/f/(\\))?/\n\
+name f\n\
+ function${M1?: ${1:functionName}}($2) {\n\
+ ${0:$TM_SELECTED_TEXT}\n\
+ }${M2?;}${M3?,}${M4?)}\n\
+# Immediate function\n\
+trigger \\(?f\\(\n\
+endTrigger \\)?\n\
+snippet f(\n\
+ (function(${1}) {\n\
+ ${0:${TM_SELECTED_TEXT:/* code */}}\n\
+ }(${1}));\n\
+# if\n\
+snippet if\n\
+ if (${1:true}) {\n\
+ ${0}\n\
+ }\n\
+# if ... else\n\
+snippet ife\n\
+ if (${1:true}) {\n\
+ ${2}\n\
+ } else {\n\
+ ${0}\n\
+ }\n\
+# tertiary conditional\n\
+snippet ter\n\
+ ${1:/* condition */} ? ${2:a} : ${3:b}\n\
+# switch\n\
+snippet switch\n\
+ switch (${1:expression}) {\n\
+ case '${3:case}':\n\
+ ${4:// code}\n\
+ break;\n\
+ ${5}\n\
+ default:\n\
+ ${2:// code}\n\
+ }\n\
+# case\n\
+snippet case\n\
+ case '${1:case}':\n\
+ ${2:// code}\n\
+ break;\n\
+ ${3}\n\
+\n\
+# while (...) {...}\n\
+snippet wh\n\
+ while (${1:/* condition */}) {\n\
+ ${0:/* code */}\n\
+ }\n\
+# try\n\
+snippet try\n\
+ try {\n\
+ ${0:/* code */}\n\
+ } catch (e) {}\n\
+# do...while\n\
+snippet do\n\
+ do {\n\
+ ${2:/* code */}\n\
+ } while (${1:/* condition */});\n\
+# Object Method\n\
+snippet :f\n\
+regex /([,{[])|^\\s*/:f/\n\
+ ${1:method_name}: function(${2:attribute}) {\n\
+ ${0}\n\
+ }${3:,}\n\
+# setTimeout function\n\
+snippet setTimeout\n\
+regex /\\b/st|timeout|setTimeo?u?t?/\n\
+ setTimeout(function() {${3:$TM_SELECTED_TEXT}}, ${1:10});\n\
+# Get Elements\n\
+snippet gett\n\
+ getElementsBy${1:TagName}('${2}')${3}\n\
+# Get Element\n\
+snippet get\n\
+ getElementBy${1:Id}('${2}')${3}\n\
+# console.log (Firebug)\n\
+snippet cl\n\
+ console.log(${1});\n\
+# return\n\
+snippet ret\n\
+ return ${1:result}\n\
+# for (property in object ) { ... }\n\
+snippet fori\n\
+ for (var ${1:prop} in ${2:Things}) {\n\
+ ${0:$2[$1]}\n\
+ }\n\
+# hasOwnProperty\n\
+snippet has\n\
+ hasOwnProperty(${1})\n\
+# docstring\n\
+snippet /**\n\
+ /**\n\
+ * ${1:description}\n\
+ *\n\
+ */\n\
+snippet @par\n\
+regex /^\\s*\\*\\s*/@(para?m?)?/\n\
+ @param {${1:type}} ${2:name} ${3:description}\n\
+snippet @ret\n\
+ @return {${1:type}} ${2:description}\n\
+# JSON.parse\n\
+snippet jsonp\n\
+ JSON.parse(${1:jstr});\n\
+# JSON.stringify\n\
+snippet jsons\n\
+ JSON.stringify(${1:object});\n\
+# self-defining function\n\
+snippet sdf\n\
+ var ${1:function_name} = function(${2:argument}) {\n\
+ ${3:// initial code ...}\n\
+\n\
+ $1 = function($2) {\n\
+ ${4:// main code}\n\
+ };\n\
+ }\n\
+# singleton\n\
+snippet sing\n\
+ function ${1:Singleton} (${2:argument}) {\n\
+ // the cached instance\n\
+ var instance;\n\
+\n\
+ // rewrite the constructor\n\
+ $1 = function $1($2) {\n\
+ return instance;\n\
+ };\n\
+ \n\
+ // carry over the prototype properties\n\
+ $1.prototype = this;\n\
+\n\
+ // the instance\n\
+ instance = new $1();\n\
+\n\
+ // reset the constructor pointer\n\
+ instance.constructor = $1;\n\
+\n\
+ ${3:// code ...}\n\
+\n\
+ return instance;\n\
+ }\n\
+# class\n\
+name class\n\
+regex /^\\s*/clas{0,2}/\n\
+ var ${1:class} = function(${20}) {\n\
+ $40$0\n\
+ };\n\
+ \n\
+ (function() {\n\
+ ${60:this.prop = \"\"}\n\
+ }).call(${1:class}.prototype);\n\
+ \n\
+ exports.${1:class} = ${1:class};\n\
+# \n\
+snippet for-\n\
+ for (var ${1:i} = ${2:Things}.length; ${1:i}--; ) {\n\
+ ${0:${2:Things}[${1:i}];}\n\
+ }\n\
+# for (...) {...}\n\
+snippet for\n\
+ for (var ${1:i} = 0; $1 < ${2:Things}.length; $1++) {\n\
+ ${3:$2[$1]}$0\n\
+ }\n\
+# for (...) {...} (Improved Native For-Loop)\n\
+snippet forr\n\
+ for (var ${1:i} = ${2:Things}.length - 1; $1 >= 0; $1--) {\n\
+ ${3:$2[$1]}$0\n\
+ }\n\
+\n\
+\n\
+#modules\n\
+snippet def\n\
+ ace.define(function(require, exports, module) {\n\
+ \"use strict\";\n\
+ var ${1/.*\\///} = require(\"${1}\");\n\
+ \n\
+ $TM_SELECTED_TEXT\n\
+ });\n\
+snippet req\n\
+guard ^\\s*\n\
+ var ${1/.*\\///} = require(\"${1}\");\n\
+ $0\n\
+snippet requ\n\
+guard ^\\s*\n\
+ var ${1/.*\\/(.)/\\u$1/} = require(\"${1}\").${1/.*\\/(.)/\\u$1/};\n\
+ $0\n\
+";
+exports.scope = "javascript";
+
+});
diff --git a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/theme-chrome.js b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/theme-chrome.js
index 38b2d5e..51d98b7 100644
--- a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/theme-chrome.js
+++ b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/theme-chrome.js
@@ -1,161 +1,161 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define('ace/theme/chrome', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
-
-exports.isDark = false;
-exports.cssClass = "ace-chrome";
-exports.cssText = ".ace-chrome .ace_gutter {\
-background: #ebebeb;\
-color: #333;\
-overflow : hidden;\
-}\
-.ace-chrome .ace_print-margin {\
-width: 1px;\
-background: #e8e8e8;\
-}\
-.ace-chrome .ace_scroller {\
-background-color: #FFFFFF;\
-}\
-.ace-chrome .ace_cursor {\
-border-left: 2px solid black;\
-}\
-.ace-chrome .ace_overwrite-cursors .ace_cursor {\
-border-left: 0px;\
-border-bottom: 1px solid black;\
-}\
-.ace-chrome .ace_invisible {\
-color: rgb(191, 191, 191);\
-}\
-.ace-chrome .ace_constant.ace_buildin {\
-color: rgb(88, 72, 246);\
-}\
-.ace-chrome .ace_constant.ace_language {\
-color: rgb(88, 92, 246);\
-}\
-.ace-chrome .ace_constant.ace_library {\
-color: rgb(6, 150, 14);\
-}\
-.ace-chrome .ace_invalid {\
-background-color: rgb(153, 0, 0);\
-color: white;\
-}\
-.ace-chrome .ace_fold {\
-}\
-.ace-chrome .ace_support.ace_function {\
-color: rgb(60, 76, 114);\
-}\
-.ace-chrome .ace_support.ace_constant {\
-color: rgb(6, 150, 14);\
-}\
-.ace-chrome .ace_support.ace_type,\
-.ace-chrome .ace_support.ace_class\
-.ace-chrome .ace_support.ace_other {\
-color: rgb(109, 121, 222);\
-}\
-.ace-chrome .ace_variable.ace_parameter {\
-font-style:italic;\
-color:#FD971F;\
-}\
-.ace-chrome .ace_keyword.ace_operator {\
-color: rgb(104, 118, 135);\
-}\
-.ace-chrome .ace_comment {\
-color: #236e24;\
-}\
-.ace-chrome .ace_comment.ace_doc {\
-color: #236e24;\
-}\
-.ace-chrome .ace_comment.ace_doc.ace_tag {\
-color: #236e24;\
-}\
-.ace-chrome .ace_constant.ace_numeric {\
-color: rgb(0, 0, 205);\
-}\
-.ace-chrome .ace_variable {\
-color: rgb(49, 132, 149);\
-}\
-.ace-chrome .ace_xml-pe {\
-color: rgb(104, 104, 91);\
-}\
-.ace-chrome .ace_entity.ace_name.ace_function {\
-color: #0000A2;\
-}\
-.ace-chrome .ace_markup.ace_heading {\
-color: rgb(12, 7, 255);\
-}\
-.ace-chrome .ace_markup.ace_list {\
-color:rgb(185, 6, 144);\
-}\
-.ace-chrome .ace_marker-layer .ace_selection {\
-background: rgb(181, 213, 255);\
-}\
-.ace-chrome .ace_marker-layer .ace_step {\
-background: rgb(252, 255, 0);\
-}\
-.ace-chrome .ace_marker-layer .ace_stack {\
-background: rgb(164, 229, 101);\
-}\
-.ace-chrome .ace_marker-layer .ace_bracket {\
-margin: -1px 0 0 -1px;\
-border: 1px solid rgb(192, 192, 192);\
-}\
-.ace-chrome .ace_marker-layer .ace_active-line {\
-background: rgba(0, 0, 0, 0.07);\
-}\
-.ace-chrome .ace_gutter-active-line {\
-background-color : #dcdcdc;\
-}\
-.ace-chrome .ace_marker-layer .ace_selected-word {\
-background: rgb(250, 250, 255);\
-border: 1px solid rgb(200, 200, 250);\
-}\
-.ace-chrome .ace_storage,\
-.ace-chrome .ace_keyword,\
-.ace-chrome .ace_meta.ace_tag {\
-color: rgb(147, 15, 128);\
-}\
-.ace-chrome .ace_string.ace_regex {\
-color: rgb(255, 0, 0)\
-}\
-.ace-chrome .ace_string {\
-color: #1A1AA6;\
-}\
-.ace-chrome .ace_entity.ace_other.ace_attribute-name {\
-color: #994409;\
-}\
-.ace-chrome .ace_indent-guide {\
-background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
-}\
-";
-
-var dom = require("../lib/dom");
-dom.importCssString(exports.cssText, exports.cssClass);
-});
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2010, Ajax.org B.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Ajax.org B.V. nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+ace.define('ace/theme/chrome', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
+
+exports.isDark = false;
+exports.cssClass = "ace-chrome";
+exports.cssText = ".ace-chrome .ace_gutter {\
+background: #ebebeb;\
+color: #333;\
+overflow : hidden;\
+}\
+.ace-chrome .ace_print-margin {\
+width: 1px;\
+background: #e8e8e8;\
+}\
+.ace-chrome {\
+background-color: #FFFFFF;\
+}\
+.ace-chrome .ace_cursor {\
+border-left: 2px solid black;\
+}\
+.ace-chrome .ace_overwrite-cursors .ace_cursor {\
+border-left: 0px;\
+border-bottom: 1px solid black;\
+}\
+.ace-chrome .ace_invisible {\
+color: rgb(191, 191, 191);\
+}\
+.ace-chrome .ace_constant.ace_buildin {\
+color: rgb(88, 72, 246);\
+}\
+.ace-chrome .ace_constant.ace_language {\
+color: rgb(88, 92, 246);\
+}\
+.ace-chrome .ace_constant.ace_library {\
+color: rgb(6, 150, 14);\
+}\
+.ace-chrome .ace_invalid {\
+background-color: rgb(153, 0, 0);\
+color: white;\
+}\
+.ace-chrome .ace_fold {\
+}\
+.ace-chrome .ace_support.ace_function {\
+color: rgb(60, 76, 114);\
+}\
+.ace-chrome .ace_support.ace_constant {\
+color: rgb(6, 150, 14);\
+}\
+.ace-chrome .ace_support.ace_type,\
+.ace-chrome .ace_support.ace_class\
+.ace-chrome .ace_support.ace_other {\
+color: rgb(109, 121, 222);\
+}\
+.ace-chrome .ace_variable.ace_parameter {\
+font-style:italic;\
+color:#FD971F;\
+}\
+.ace-chrome .ace_keyword.ace_operator {\
+color: rgb(104, 118, 135);\
+}\
+.ace-chrome .ace_comment {\
+color: #236e24;\
+}\
+.ace-chrome .ace_comment.ace_doc {\
+color: #236e24;\
+}\
+.ace-chrome .ace_comment.ace_doc.ace_tag {\
+color: #236e24;\
+}\
+.ace-chrome .ace_constant.ace_numeric {\
+color: rgb(0, 0, 205);\
+}\
+.ace-chrome .ace_variable {\
+color: rgb(49, 132, 149);\
+}\
+.ace-chrome .ace_xml-pe {\
+color: rgb(104, 104, 91);\
+}\
+.ace-chrome .ace_entity.ace_name.ace_function {\
+color: #0000A2;\
+}\
+.ace-chrome .ace_heading {\
+color: rgb(12, 7, 255);\
+}\
+.ace-chrome .ace_list {\
+color:rgb(185, 6, 144);\
+}\
+.ace-chrome .ace_marker-layer .ace_selection {\
+background: rgb(181, 213, 255);\
+}\
+.ace-chrome .ace_marker-layer .ace_step {\
+background: rgb(252, 255, 0);\
+}\
+.ace-chrome .ace_marker-layer .ace_stack {\
+background: rgb(164, 229, 101);\
+}\
+.ace-chrome .ace_marker-layer .ace_bracket {\
+margin: -1px 0 0 -1px;\
+border: 1px solid rgb(192, 192, 192);\
+}\
+.ace-chrome .ace_marker-layer .ace_active-line {\
+background: rgba(0, 0, 0, 0.07);\
+}\
+.ace-chrome .ace_gutter-active-line {\
+background-color : #dcdcdc;\
+}\
+.ace-chrome .ace_marker-layer .ace_selected-word {\
+background: rgb(250, 250, 255);\
+border: 1px solid rgb(200, 200, 250);\
+}\
+.ace-chrome .ace_storage,\
+.ace-chrome .ace_keyword,\
+.ace-chrome .ace_meta.ace_tag {\
+color: rgb(147, 15, 128);\
+}\
+.ace-chrome .ace_string.ace_regex {\
+color: rgb(255, 0, 0)\
+}\
+.ace-chrome .ace_string {\
+color: #1A1AA6;\
+}\
+.ace-chrome .ace_entity.ace_other.ace_attribute-name {\
+color: #994409;\
+}\
+.ace-chrome .ace_indent-guide {\
+background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
+}\
+";
+
+var dom = require("../lib/dom");
+dom.importCssString(exports.cssText, exports.cssClass);
+});
diff --git a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/theme-textmate.js b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/theme-textmate.js
index f25d0f5..d3fdeef 100644
--- a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/theme-textmate.js
+++ b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/theme-textmate.js
@@ -1,163 +1,163 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-define('ace/theme/textmate', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
-
-
-exports.isDark = false;
-exports.cssClass = "ace-tm";
-exports.cssText = ".ace-tm .ace_gutter {\
-background: #f0f0f0;\
-color: #333;\
-}\
-.ace-tm .ace_print-margin {\
-width: 1px;\
-background: #e8e8e8;\
-}\
-.ace-tm .ace_fold {\
-background-color: #6B72E6;\
-}\
-.ace-tm .ace_scroller {\
-background-color: #FFFFFF;\
-}\
-.ace-tm .ace_cursor {\
-border-left: 2px solid black;\
-}\
-.ace-tm .ace_overwrite-cursors .ace_cursor {\
-border-left: 0px;\
-border-bottom: 1px solid black;\
-}\
-.ace-tm .ace_invisible {\
-color: rgb(191, 191, 191);\
-}\
-.ace-tm .ace_storage,\
-.ace-tm .ace_keyword {\
-color: blue;\
-}\
-.ace-tm .ace_constant {\
-color: rgb(197, 6, 11);\
-}\
-.ace-tm .ace_constant.ace_buildin {\
-color: rgb(88, 72, 246);\
-}\
-.ace-tm .ace_constant.ace_language {\
-color: rgb(88, 92, 246);\
-}\
-.ace-tm .ace_constant.ace_library {\
-color: rgb(6, 150, 14);\
-}\
-.ace-tm .ace_invalid {\
-background-color: rgba(255, 0, 0, 0.1);\
-color: red;\
-}\
-.ace-tm .ace_support.ace_function {\
-color: rgb(60, 76, 114);\
-}\
-.ace-tm .ace_support.ace_constant {\
-color: rgb(6, 150, 14);\
-}\
-.ace-tm .ace_support.ace_type,\
-.ace-tm .ace_support.ace_class {\
-color: rgb(109, 121, 222);\
-}\
-.ace-tm .ace_keyword.ace_operator {\
-color: rgb(104, 118, 135);\
-}\
-.ace-tm .ace_string {\
-color: rgb(3, 106, 7);\
-}\
-.ace-tm .ace_comment {\
-color: rgb(76, 136, 107);\
-}\
-.ace-tm .ace_comment.ace_doc {\
-color: rgb(0, 102, 255);\
-}\
-.ace-tm .ace_comment.ace_doc.ace_tag {\
-color: rgb(128, 159, 191);\
-}\
-.ace-tm .ace_constant.ace_numeric {\
-color: rgb(0, 0, 205);\
-}\
-.ace-tm .ace_variable {\
-color: rgb(49, 132, 149);\
-}\
-.ace-tm .ace_xml-pe {\
-color: rgb(104, 104, 91);\
-}\
-.ace-tm .ace_entity.ace_name.ace_function {\
-color: #0000A2;\
-}\
-.ace-tm .ace_markup.ace_heading {\
-color: rgb(12, 7, 255);\
-}\
-.ace-tm .ace_markup.ace_list {\
-color:rgb(185, 6, 144);\
-}\
-.ace-tm .ace_meta.ace_tag {\
-color:rgb(0, 22, 142);\
-}\
-.ace-tm .ace_string.ace_regex {\
-color: rgb(255, 0, 0)\
-}\
-.ace-tm .ace_marker-layer .ace_selection {\
-background: rgb(181, 213, 255);\
-}\
-.ace-tm.ace_multiselect .ace_selection.ace_start {\
-box-shadow: 0 0 3px 0px white;\
-border-radius: 2px;\
-}\
-.ace-tm .ace_marker-layer .ace_step {\
-background: rgb(252, 255, 0);\
-}\
-.ace-tm .ace_marker-layer .ace_stack {\
-background: rgb(164, 229, 101);\
-}\
-.ace-tm .ace_marker-layer .ace_bracket {\
-margin: -1px 0 0 -1px;\
-border: 1px solid rgb(192, 192, 192);\
-}\
-.ace-tm .ace_marker-layer .ace_active-line {\
-background: rgba(0, 0, 0, 0.07);\
-}\
-.ace-tm .ace_gutter-active-line {\
-background-color : #dcdcdc;\
-}\
-.ace-tm .ace_marker-layer .ace_selected-word {\
-background: rgb(250, 250, 255);\
-border: 1px solid rgb(200, 200, 250);\
-}\
-.ace-tm .ace_indent-guide {\
-background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
-}\
-";
-
-var dom = require("../lib/dom");
-dom.importCssString(exports.cssText, exports.cssClass);
-});
+/* ***** BEGIN LICENSE BLOCK *****
+ * Distributed under the BSD license:
+ *
+ * Copyright (c) 2010, Ajax.org B.V.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Ajax.org B.V. nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+ace.define('ace/theme/textmate', ['require', 'exports', 'module' , 'ace/lib/dom'], function(require, exports, module) {
+
+
+exports.isDark = false;
+exports.cssClass = "ace-tm";
+exports.cssText = ".ace-tm .ace_gutter {\
+background: #f0f0f0;\
+color: #333;\
+}\
+.ace-tm .ace_print-margin {\
+width: 1px;\
+background: #e8e8e8;\
+}\
+.ace-tm .ace_fold {\
+background-color: #6B72E6;\
+}\
+.ace-tm {\
+background-color: #FFFFFF;\
+}\
+.ace-tm .ace_cursor {\
+border-left: 2px solid black;\
+}\
+.ace-tm .ace_overwrite-cursors .ace_cursor {\
+border-left: 0px;\
+border-bottom: 1px solid black;\
+}\
+.ace-tm .ace_invisible {\
+color: rgb(191, 191, 191);\
+}\
+.ace-tm .ace_storage,\
+.ace-tm .ace_keyword {\
+color: blue;\
+}\
+.ace-tm .ace_constant {\
+color: rgb(197, 6, 11);\
+}\
+.ace-tm .ace_constant.ace_buildin {\
+color: rgb(88, 72, 246);\
+}\
+.ace-tm .ace_constant.ace_language {\
+color: rgb(88, 92, 246);\
+}\
+.ace-tm .ace_constant.ace_library {\
+color: rgb(6, 150, 14);\
+}\
+.ace-tm .ace_invalid {\
+background-color: rgba(255, 0, 0, 0.1);\
+color: red;\
+}\
+.ace-tm .ace_support.ace_function {\
+color: rgb(60, 76, 114);\
+}\
+.ace-tm .ace_support.ace_constant {\
+color: rgb(6, 150, 14);\
+}\
+.ace-tm .ace_support.ace_type,\
+.ace-tm .ace_support.ace_class {\
+color: rgb(109, 121, 222);\
+}\
+.ace-tm .ace_keyword.ace_operator {\
+color: rgb(104, 118, 135);\
+}\
+.ace-tm .ace_string {\
+color: rgb(3, 106, 7);\
+}\
+.ace-tm .ace_comment {\
+color: rgb(76, 136, 107);\
+}\
+.ace-tm .ace_comment.ace_doc {\
+color: rgb(0, 102, 255);\
+}\
+.ace-tm .ace_comment.ace_doc.ace_tag {\
+color: rgb(128, 159, 191);\
+}\
+.ace-tm .ace_constant.ace_numeric {\
+color: rgb(0, 0, 205);\
+}\
+.ace-tm .ace_variable {\
+color: rgb(49, 132, 149);\
+}\
+.ace-tm .ace_xml-pe {\
+color: rgb(104, 104, 91);\
+}\
+.ace-tm .ace_entity.ace_name.ace_function {\
+color: #0000A2;\
+}\
+.ace-tm .ace_heading {\
+color: rgb(12, 7, 255);\
+}\
+.ace-tm .ace_list {\
+color:rgb(185, 6, 144);\
+}\
+.ace-tm .ace_meta.ace_tag {\
+color:rgb(0, 22, 142);\
+}\
+.ace-tm .ace_string.ace_regex {\
+color: rgb(255, 0, 0)\
+}\
+.ace-tm .ace_marker-layer .ace_selection {\
+background: rgb(181, 213, 255);\
+}\
+.ace-tm.ace_multiselect .ace_selection.ace_start {\
+box-shadow: 0 0 3px 0px white;\
+border-radius: 2px;\
+}\
+.ace-tm .ace_marker-layer .ace_step {\
+background: rgb(252, 255, 0);\
+}\
+.ace-tm .ace_marker-layer .ace_stack {\
+background: rgb(164, 229, 101);\
+}\
+.ace-tm .ace_marker-layer .ace_bracket {\
+margin: -1px 0 0 -1px;\
+border: 1px solid rgb(192, 192, 192);\
+}\
+.ace-tm .ace_marker-layer .ace_active-line {\
+background: rgba(0, 0, 0, 0.07);\
+}\
+.ace-tm .ace_gutter-active-line {\
+background-color : #dcdcdc;\
+}\
+.ace-tm .ace_marker-layer .ace_selected-word {\
+background: rgb(250, 250, 255);\
+border: 1px solid rgb(200, 200, 250);\
+}\
+.ace-tm .ace_indent-guide {\
+background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
+}\
+";
+
+var dom = require("../lib/dom");
+dom.importCssString(exports.cssText, exports.cssClass);
+});
diff --git a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/worker-javascript.js b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/worker-javascript.js
index ae891e5..43803b5 100644
--- a/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/worker-javascript.js
+++ b/stardust-web-reporting/src/main/resources/META-INF/webapp/js/libs/ace/worker-javascript.js
@@ -1,6513 +1,9980 @@
-"no use strict";
-
-if (typeof window != "undefined" && window.document)
- throw "atempt to load ace worker into main window instead of webWorker";
-
-var console = {
- log: function() {
- var msgs = Array.prototype.slice.call(arguments, 0);
- postMessage({type: "log", data: msgs});
- },
- error: function() {
- var msgs = Array.prototype.slice.call(arguments, 0);
- postMessage({type: "log", data: msgs});
- }
-};
-var window = {
- console: console
-};
-
-var normalizeModule = function(parentId, moduleName) {
- // normalize plugin requires
- if (moduleName.indexOf("!") !== -1) {
- var chunks = moduleName.split("!");
- return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
- }
- // normalize relative requires
- if (moduleName.charAt(0) == ".") {
- var base = parentId.split("/").slice(0, -1).join("/");
- moduleName = base + "/" + moduleName;
-
- while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
- var previous = moduleName;
- moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
- }
- }
-
- return moduleName;
-};
-
-var require = function(parentId, id) {
- if (!id.charAt)
- throw new Error("worker.js require() accepts only (parentId, id) as arguments");
-
- id = normalizeModule(parentId, id);
-
- var module = require.modules[id];
- if (module) {
- if (!module.initialized) {
- module.initialized = true;
- module.exports = module.factory().exports;
- }
- return module.exports;
- }
-
- var chunks = id.split("/");
- chunks[0] = require.tlns[chunks[0]] || chunks[0];
- var path = chunks.join("/") + ".js";
-
- require.id = id;
- importScripts(path);
- return require(parentId, id);
-};
-
-require.modules = {};
-require.tlns = {};
-
-var define = function(id, deps, factory) {
- if (arguments.length == 2) {
- factory = deps;
- if (typeof id != "string") {
- deps = id;
- id = require.id;
- }
- } else if (arguments.length == 1) {
- factory = id;
- id = require.id;
- }
-
- if (id.indexOf("text!") === 0)
- return;
-
- var req = function(deps, factory) {
- return require(id, deps, factory);
- };
-
- require.modules[id] = {
- factory: function() {
- var module = {
- exports: {}
- };
- var returnExports = factory(req, module.exports, module);
- if (returnExports)
- module.exports = returnExports;
- return module;
- }
- };
-};
-
-function initBaseUrls(topLevelNamespaces) {
- require.tlns = topLevelNamespaces;
-}
-
-function initSender() {
-
- var EventEmitter = require(null, "ace/lib/event_emitter").EventEmitter;
- var oop = require(null, "ace/lib/oop");
-
- var Sender = function() {};
-
- (function() {
-
- oop.implement(this, EventEmitter);
-
- this.callback = function(data, callbackId) {
- postMessage({
- type: "call",
- id: callbackId,
- data: data
- });
- };
-
- this.emit = function(name, data) {
- postMessage({
- type: "event",
- name: name,
- data: data
- });
- };
-
- }).call(Sender.prototype);
-
- return new Sender();
-}
-
-var main;
-var sender;
-
-onmessage = function(e) {
- var msg = e.data;
- if (msg.command) {
- if (main[msg.command])
- main[msg.command].apply(main, msg.args);
- else
- throw new Error("Unknown command:" + msg.command);
- }
- else if (msg.init) {
- initBaseUrls(msg.tlns);
- require(null, "ace/lib/fixoldbrowsers");
- sender = initSender();
- var clazz = require(null, msg.module)[msg.classname];
- main = new clazz(sender);
- }
- else if (msg.event && sender) {
- sender._emit(msg.event, msg.data);
- }
-};
-// vim:set ts=4 sts=4 sw=4 st:
-
-define('ace/lib/fixoldbrowsers', ['require', 'exports', 'module' , 'ace/lib/regexp', 'ace/lib/es5-shim'], function(require, exports, module) {
-
-
-require("./regexp");
-require("./es5-shim");
-
-});
-
-define('ace/lib/regexp', ['require', 'exports', 'module' ], function(require, exports, module) {
-
- var real = {
- exec: RegExp.prototype.exec,
- test: RegExp.prototype.test,
- match: String.prototype.match,
- replace: String.prototype.replace,
- split: String.prototype.split
- },
- compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
- compliantLastIndexIncrement = function () {
- var x = /^/g;
- real.test.call(x, "");
- return !x.lastIndex;
- }();
-
- if (compliantLastIndexIncrement && compliantExecNpcg)
- return;
- RegExp.prototype.exec = function (str) {
- var match = real.exec.apply(this, arguments),
- name, r2;
- if ( typeof(str) == 'string' && match) {
- if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
- r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
- real.replace.call(str.slice(match.index), r2, function () {
- for (var i = 1; i < arguments.length - 2; i++) {
- if (arguments[i] === undefined)
- match[i] = undefined;
- }
- });
- }
- if (this._xregexp && this._xregexp.captureNames) {
- for (var i = 1; i < match.length; i++) {
- name = this._xregexp.captureNames[i - 1];
- if (name)
- match[name] = match[i];
- }
- }
- if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
- this.lastIndex--;
- }
- return match;
- };
- if (!compliantLastIndexIncrement) {
- RegExp.prototype.test = function (str) {
- var match = real.exec.call(this, str);
- if (match && this.global && !match[0].length && (this.lastIndex > match.index))
- this.lastIndex--;
- return !!match;
- };
- }
-
- function getNativeFlags (regex) {
- return (regex.global ? "g" : "") +
- (regex.ignoreCase ? "i" : "") +
- (regex.multiline ? "m" : "") +
- (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
- (regex.sticky ? "y" : "");
- }
-
- function indexOf (array, item, from) {
- if (Array.prototype.indexOf) // Use the native array method if available
- return array.indexOf(item, from);
- for (var i = from || 0; i < array.length; i++) {
- if (array[i] === item)
- return i;
- }
- return -1;
- }
-
-});
-
-define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) {
-
-function Empty() {}
-
-if (!Function.prototype.bind) {
- Function.prototype.bind = function bind(that) { // .length is 1
- var target = this;
- if (typeof target != "function") {
- throw new TypeError("Function.prototype.bind called on incompatible " + target);
- }
- var args = slice.call(arguments, 1); // for normal call
- var bound = function () {
-
- if (this instanceof bound) {
-
- var result = target.apply(
- this,
- args.concat(slice.call(arguments))
- );
- if (Object(result) === result) {
- return result;
- }
- return this;
-
- } else {
- return target.apply(
- that,
- args.concat(slice.call(arguments))
- );
-
- }
-
- };
- if(target.prototype) {
- Empty.prototype = target.prototype;
- bound.prototype = new Empty();
- Empty.prototype = null;
- }
- return bound;
- };
-}
-var call = Function.prototype.call;
-var prototypeOfArray = Array.prototype;
-var prototypeOfObject = Object.prototype;
-var slice = prototypeOfArray.slice;
-var _toString = call.bind(prototypeOfObject.toString);
-var owns = call.bind(prototypeOfObject.hasOwnProperty);
-var defineGetter;
-var defineSetter;
-var lookupGetter;
-var lookupSetter;
-var supportsAccessors;
-if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
- defineGetter = call.bind(prototypeOfObject.__defineGetter__);
- defineSetter = call.bind(prototypeOfObject.__defineSetter__);
- lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
- lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
-}
-if ([1,2].splice(0).length != 2) {
- if(function() { // test IE < 9 to splice bug - see issue #138
- function makeArray(l) {
- var a = new Array(l+2);
- a[0] = a[1] = 0;
- return a;
- }
- var array = [], lengthBefore;
-
- array.splice.apply(array, makeArray(20));
- array.splice.apply(array, makeArray(26));
-
- lengthBefore = array.length; //46
- array.splice(5, 0, "XXX"); // add one element
-
- lengthBefore + 1 == array.length
-
- if (lengthBefore + 1 == array.length) {
- return true;// has right splice implementation without bugs
- }
- }()) {//IE 6/7
- var array_splice = Array.prototype.splice;
- Array.prototype.splice = function(start, deleteCount) {
- if (!arguments.length) {
- return [];
- } else {
- return array_splice.apply(this, [
- start === void 0 ? 0 : start,
- deleteCount === void 0 ? (this.length - start) : deleteCount
- ].concat(slice.call(arguments, 2)))
- }
- };
- } else {//IE8
- Array.prototype.splice = function(pos, removeCount){
- var length = this.length;
- if (pos > 0) {
- if (pos > length)
- pos = length;
- } else if (pos == void 0) {
- pos = 0;
- } else if (pos < 0) {
- pos = Math.max(length + pos, 0);
- }
-
- if (!(pos+removeCount < length))
- removeCount = length - pos;
-
- var removed = this.slice(pos, pos+removeCount);
- var insert = slice.call(arguments, 2);
- var add = insert.length;
- if (pos === length) {
- if (add) {
- this.push.apply(this, insert);
- }
- } else {
- var remove = Math.min(removeCount, length - pos);
- var tailOldPos = pos + remove;
- var tailNewPos = tailOldPos + add - remove;
- var tailCount = length - tailOldPos;
- var lengthAfterRemove = length - remove;
-
- if (tailNewPos < tailOldPos) { // case A
- for (var i = 0; i < tailCount; ++i) {
- this[tailNewPos+i] = this[tailOldPos+i];
- }
- } else if (tailNewPos > tailOldPos) { // case B
- for (i = tailCount; i--; ) {
- this[tailNewPos+i] = this[tailOldPos+i];
- }
- } // else, add == remove (nothing to do)
-
- if (add && pos === lengthAfterRemove) {
- this.length = lengthAfterRemove; // truncate array
- this.push.apply(this, insert);
- } else {
- this.length = lengthAfterRemove + add; // reserves space
- for (i = 0; i < add; ++i) {
- this[pos+i] = insert[i];
- }
- }
- }
- return removed;
- };
- }
-}
-if (!Array.isArray) {
- Array.isArray = function isArray(obj) {
- return _toString(obj) == "[object Array]";
- };
-}
-var boxedString = Object("a"),
- splitString = boxedString[0] != "a" || !(0 in boxedString);
-
-if (!Array.prototype.forEach) {
- Array.prototype.forEach = function forEach(fun /*, thisp*/) {
- var object = toObject(this),
- self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- object,
- thisp = arguments[1],
- i = -1,
- length = self.length >>> 0;
- if (_toString(fun) != "[object Function]") {
- throw new TypeError(); // TODO message
- }
-
- while (++i < length) {
- if (i in self) {
- fun.call(thisp, self[i], i, object);
- }
- }
- };
-}
-if (!Array.prototype.map) {
- Array.prototype.map = function map(fun /*, thisp*/) {
- var object = toObject(this),
- self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- object,
- length = self.length >>> 0,
- result = Array(length),
- thisp = arguments[1];
- if (_toString(fun) != "[object Function]") {
- throw new TypeError(fun + " is not a function");
- }
-
- for (var i = 0; i < length; i++) {
- if (i in self)
- result[i] = fun.call(thisp, self[i], i, object);
- }
- return result;
- };
-}
-if (!Array.prototype.filter) {
- Array.prototype.filter = function filter(fun /*, thisp */) {
- var object = toObject(this),
- self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- object,
- length = self.length >>> 0,
- result = [],
- value,
- thisp = arguments[1];
- if (_toString(fun) != "[object Function]") {
- throw new TypeError(fun + " is not a function");
- }
-
- for (var i = 0; i < length; i++) {
- if (i in self) {
- value = self[i];
- if (fun.call(thisp, value, i, object)) {
- result.push(value);
- }
- }
- }
- return result;
- };
-}
-if (!Array.prototype.every) {
- Array.prototype.every = function every(fun /*, thisp */) {
- var object = toObject(this),
- self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- object,
- length = self.length >>> 0,
- thisp = arguments[1];
- if (_toString(fun) != "[object Function]") {
- throw new TypeError(fun + " is not a function");
- }
-
- for (var i = 0; i < length; i++) {
- if (i in self && !fun.call(thisp, self[i], i, object)) {
- return false;
- }
- }
- return true;
- };
-}
-if (!Array.prototype.some) {
- Array.prototype.some = function some(fun /*, thisp */) {
- var object = toObject(this),
- self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- object,
- length = self.length >>> 0,
- thisp = arguments[1];
- if (_toString(fun) != "[object Function]") {
- throw new TypeError(fun + " is not a function");
- }
-
- for (var i = 0; i < length; i++) {
- if (i in self && fun.call(thisp, self[i], i, object)) {
- return true;
- }
- }
- return false;
- };
-}
-if (!Array.prototype.reduce) {
- Array.prototype.reduce = function reduce(fun /*, initial*/) {
- var object = toObject(this),
- self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- object,
- length = self.length >>> 0;
- if (_toString(fun) != "[object Function]") {
- throw new TypeError(fun + " is not a function");
- }
- if (!length && arguments.length == 1) {
- throw new TypeError("reduce of empty array with no initial value");
- }
-
- var i = 0;
- var result;
- if (arguments.length >= 2) {
- result = arguments[1];
- } else {
- do {
- if (i in self) {
- result = self[i++];
- break;
- }
- if (++i >= length) {
- throw new TypeError("reduce of empty array with no initial value");
- }
- } while (true);
- }
-
- for (; i < length; i++) {
- if (i in self) {
- result = fun.call(void 0, result, self[i], i, object);
- }
- }
-
- return result;
- };
-}
-if (!Array.prototype.reduceRight) {
- Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
- var object = toObject(this),
- self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- object,
- length = self.length >>> 0;
- if (_toString(fun) != "[object Function]") {
- throw new TypeError(fun + " is not a function");
- }
- if (!length && arguments.length == 1) {
- throw new TypeError("reduceRight of empty array with no initial value");
- }
-
- var result, i = length - 1;
- if (arguments.length >= 2) {
- result = arguments[1];
- } else {
- do {
- if (i in self) {
- result = self[i--];
- break;
- }
- if (--i < 0) {
- throw new TypeError("reduceRight of empty array with no initial value");
- }
- } while (true);
- }
-
- do {
- if (i in this) {
- result = fun.call(void 0, result, self[i], i, object);
- }
- } while (i--);
-
- return result;
- };
-}
-if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
- Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
- var self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- toObject(this),
- length = self.length >>> 0;
-
- if (!length) {
- return -1;
- }
-
- var i = 0;
- if (arguments.length > 1) {
- i = toInteger(arguments[1]);
- }
- i = i >= 0 ? i : Math.max(0, length + i);
- for (; i < length; i++) {
- if (i in self && self[i] === sought) {
- return i;
- }
- }
- return -1;
- };
-}
-if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
- Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
- var self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- toObject(this),
- length = self.length >>> 0;
-
- if (!length) {
- return -1;
- }
- var i = length - 1;
- if (arguments.length > 1) {
- i = Math.min(i, toInteger(arguments[1]));
- }
- i = i >= 0 ? i : length - Math.abs(i);
- for (; i >= 0; i--) {
- if (i in self && sought === self[i]) {
- return i;
- }
- }
- return -1;
- };
-}
-if (!Object.getPrototypeOf) {
- Object.getPrototypeOf = function getPrototypeOf(object) {
- return object.__proto__ || (
- object.constructor ?
- object.constructor.prototype :
- prototypeOfObject
- );
- };
-}
-if (!Object.getOwnPropertyDescriptor) {
- var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
- "non-object: ";
- Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
- if ((typeof object != "object" && typeof object != "function") || object === null)
- throw new TypeError(ERR_NON_OBJECT + object);
- if (!owns(object, property))
- return;
-
- var descriptor, getter, setter;
- descriptor = { enumerable: true, configurable: true };
- if (supportsAccessors) {
- var prototype = object.__proto__;
- object.__proto__ = prototypeOfObject;
-
- var getter = lookupGetter(object, property);
- var setter = lookupSetter(object, property);
- object.__proto__ = prototype;
-
- if (getter || setter) {
- if (getter) descriptor.get = getter;
- if (setter) descriptor.set = setter;
- return descriptor;
- }
- }
- descriptor.value = object[property];
- return descriptor;
- };
-}
-if (!Object.getOwnPropertyNames) {
- Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
- return Object.keys(object);
- };
-}
-if (!Object.create) {
- var createEmpty;
- if (Object.prototype.__proto__ === null) {
- createEmpty = function () {
- return { "__proto__": null };
- };
- } else {
- createEmpty = function () {
- var empty = {};
- for (var i in empty)
- empty[i] = null;
- empty.constructor =
- empty.hasOwnProperty =
- empty.propertyIsEnumerable =
- empty.isPrototypeOf =
- empty.toLocaleString =
- empty.toString =
- empty.valueOf =
- empty.__proto__ = null;
- return empty;
- }
- }
-
- Object.create = function create(prototype, properties) {
- var object;
- if (prototype === null) {
- object = createEmpty();
- } else {
- if (typeof prototype != "object")
- throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
- var Type = function () {};
- Type.prototype = prototype;
- object = new Type();
- object.__proto__ = prototype;
- }
- if (properties !== void 0)
- Object.defineProperties(object, properties);
- return object;
- };
-}
-
-function doesDefinePropertyWork(object) {
- try {
- Object.defineProperty(object, "sentinel", {});
- return "sentinel" in object;
- } catch (exception) {
- }
-}
-if (Object.defineProperty) {
- var definePropertyWorksOnObject = doesDefinePropertyWork({});
- var definePropertyWorksOnDom = typeof document == "undefined" ||
- doesDefinePropertyWork(document.createElement("div"));
- if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
- var definePropertyFallback = Object.defineProperty;
- }
-}
-
-if (!Object.defineProperty || definePropertyFallback) {
- var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
- var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
- var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
- "on this javascript engine";
-
- Object.defineProperty = function defineProperty(object, property, descriptor) {
- if ((typeof object != "object" && typeof object != "function") || object === null)
- throw new TypeError(ERR_NON_OBJECT_TARGET + object);
- if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
- throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
- if (definePropertyFallback) {
- try {
- return definePropertyFallback.call(Object, object, property, descriptor);
- } catch (exception) {
- }
- }
- if (owns(descriptor, "value")) {
-
- if (supportsAccessors && (lookupGetter(object, property) ||
- lookupSetter(object, property)))
- {
- var prototype = object.__proto__;
- object.__proto__ = prototypeOfObject;
- delete object[property];
- object[property] = descriptor.value;
- object.__proto__ = prototype;
- } else {
- object[property] = descriptor.value;
- }
- } else {
- if (!supportsAccessors)
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
- if (owns(descriptor, "get"))
- defineGetter(object, property, descriptor.get);
- if (owns(descriptor, "set"))
- defineSetter(object, property, descriptor.set);
- }
-
- return object;
- };
-}
-if (!Object.defineProperties) {
- Object.defineProperties = function defineProperties(object, properties) {
- for (var property in properties) {
- if (owns(properties, property))
- Object.defineProperty(object, property, properties[property]);
- }
- return object;
- };
-}
-if (!Object.seal) {
- Object.seal = function seal(object) {
- return object;
- };
-}
-if (!Object.freeze) {
- Object.freeze = function freeze(object) {
- return object;
- };
-}
-try {
- Object.freeze(function () {});
-} catch (exception) {
- Object.freeze = (function freeze(freezeObject) {
- return function freeze(object) {
- if (typeof object == "function") {
- return object;
- } else {
- return freezeObject(object);
- }
- };
- })(Object.freeze);
-}
-if (!Object.preventExtensions) {
- Object.preventExtensions = function preventExtensions(object) {
- return object;
- };
-}
-if (!Object.isSealed) {
- Object.isSealed = function isSealed(object) {
- return false;
- };
-}
-if (!Object.isFrozen) {
- Object.isFrozen = function isFrozen(object) {
- return false;
- };
-}
-if (!Object.isExtensible) {
- Object.isExtensible = function isExtensible(object) {
- if (Object(object) === object) {
- throw new TypeError(); // TODO message
- }
- var name = '';
- while (owns(object, name)) {
- name += '?';
- }
- object[name] = true;
- var returnValue = owns(object, name);
- delete object[name];
- return returnValue;
- };
-}
-if (!Object.keys) {
- var hasDontEnumBug = true,
- dontEnums = [
- "toString",
- "toLocaleString",
- "valueOf",
- "hasOwnProperty",
- "isPrototypeOf",
- "propertyIsEnumerable",
- "constructor"
- ],
- dontEnumsLength = dontEnums.length;
-
- for (var key in {"toString": null}) {
- hasDontEnumBug = false;
- }
-
- Object.keys = function keys(object) {
-
- if (
- (typeof object != "object" && typeof object != "function") ||
- object === null
- ) {
- throw new TypeError("Object.keys called on a non-object");
- }
-
- var keys = [];
- for (var name in object) {
- if (owns(object, name)) {
- keys.push(name);
- }
- }
-
- if (hasDontEnumBug) {
- for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
- var dontEnum = dontEnums[i];
- if (owns(object, dontEnum)) {
- keys.push(dontEnum);
- }
- }
- }
- return keys;
- };
-
-}
-if (!Date.now) {
- Date.now = function now() {
- return new Date().getTime();
- };
-}
-if("0".split(void 0, 0).length) {
- var string_split = String.prototype.split;
- String.prototype.split = function(separator, limit) {
- if(separator === void 0 && limit === 0)return [];
- return string_split.apply(this, arguments);
- }
-}
-if("".substr && "0b".substr(-1) !== "b") {
- var string_substr = String.prototype.substr;
- String.prototype.substr = function(start, length) {
- return string_substr.call(
- this,
- start < 0 ? (start = this.length + start) < 0 ? 0 : start : start,
- length
- );
- }
-}
-var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
- "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
- "\u2029\uFEFF";
-if (!String.prototype.trim || ws.trim()) {
- ws = "[" + ws + "]";
- var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
- trimEndRegexp = new RegExp(ws + ws + "*$");
- String.prototype.trim = function trim() {
- if (this === undefined || this === null) {
- throw new TypeError("can't convert "+this+" to object");
- }
- return String(this)
- .replace(trimBeginRegexp, "")
- .replace(trimEndRegexp, "");
- };
-}
-
-function toInteger(n) {
- n = +n;
- if (n !== n) { // isNaN
- n = 0;
- } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
- n = (n > 0 || -1) * Math.floor(Math.abs(n));
- }
- return n;
-}
-
-function isPrimitive(input) {
- var type = typeof input;
- return (
- input === null ||
- type === "undefined" ||
- type === "boolean" ||
- type === "number" ||
- type === "string"
- );
-}
-
-function toPrimitive(input) {
- var val, valueOf, toString;
- if (isPrimitive(input)) {
- return input;
- }
- valueOf = input.valueOf;
- if (typeof valueOf === "function") {
- val = valueOf.call(input);
- if (isPrimitive(val)) {
- return val;
- }
- }
- toString = input.toString;
- if (typeof toString === "function") {
- val = toString.call(input);
- if (isPrimitive(val)) {
- return val;
- }
- }
- throw new TypeError();
-}
-var toObject = function (o) {
- if (o == null) { // this matches both null and undefined
- throw new TypeError("can't convert "+o+" to object");
- }
- return Object(o);
-};
-
-});
-
-define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) {
-
-
-var EventEmitter = {};
-
-EventEmitter._emit =
-EventEmitter._dispatchEvent = function(eventName, e) {
- this._eventRegistry = this._eventRegistry || {};
- this._defaultHandlers = this._defaultHandlers || {};
-
- var listeners = this._eventRegistry[eventName] || [];
- var defaultHandler = this._defaultHandlers[eventName];
- if (!listeners.length && !defaultHandler)
- return;
-
- if (typeof e != "object" || !e)
- e = {};
-
- if (!e.type)
- e.type = eventName;
-
- if (!e.stopPropagation) {
- e.stopPropagation = function() {
- this.propagationStopped = true;
- };
- }
-
- if (!e.preventDefault) {
- e.preventDefault = function() {
- this.defaultPrevented = true;
- };
- }
-
- for (var i=0; i<listeners.length; i++) {
- listeners[i](e);
- if (e.propagationStopped)
- break;
- }
-
- if (defaultHandler && !e.defaultPrevented)
- return defaultHandler(e);
-};
-
-EventEmitter.setDefaultHandler = function(eventName, callback) {
- this._defaultHandlers = this._defaultHandlers || {};
-
- if (this._defaultHandlers[eventName])
- throw new Error("The default handler for '" + eventName + "' is already set");
-
- this._defaultHandlers[eventName] = callback;
-};
-
-EventEmitter.on =
-EventEmitter.addEventListener = function(eventName, callback) {
- this._eventRegistry = this._eventRegistry || {};
-
- var listeners = this._eventRegistry[eventName];
- if (!listeners)
- listeners = this._eventRegistry[eventName] = [];
-
- if (listeners.indexOf(callback) == -1)
- listeners.push(callback);
-};
-
-EventEmitter.removeListener =
-EventEmitter.removeEventListener = function(eventName, callback) {
- this._eventRegistry = this._eventRegistry || {};
-
- var listeners = this._eventRegistry[eventName];
- if (!listeners)
- return;
-
- var index = listeners.indexOf(callback);
- if (index !== -1)
- listeners.splice(index, 1);
-};
-
-EventEmitter.removeAllListeners = function(eventName) {
- if (this._eventRegistry) this._eventRegistry[eventName] = [];
-};
-
-exports.EventEmitter = EventEmitter;
-
-});
-
-define('ace/lib/oop', ['require', 'exports', 'module' ], function(require, exports, module) {
-
-
-exports.inherits = (function() {
- var tempCtor = function() {};
- return function(ctor, superCtor) {
- tempCtor.prototype = superCtor.prototype;
- ctor.super_ = superCtor.prototype;
- ctor.prototype = new tempCtor();
- ctor.prototype.constructor = ctor;
- };
-}());
-
-exports.mixin = function(obj, mixin) {
- for (var key in mixin) {
- obj[key] = mixin[key];
- }
-};
-
-exports.implement = function(proto, mixin) {
- exports.mixin(proto, mixin);
-};
-
-});
-
-define('ace/mode/javascript_worker', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/worker/mirror', 'ace/mode/javascript/jshint'], function(require, exports, module) {
-
-
-var oop = require("../lib/oop");
-var Mirror = require("../worker/mirror").Mirror;
-var lint = require("./javascript/jshint").JSHINT;
-
-function startRegex(arr) {
- return RegExp("^(" + arr.join("|") + ")");
-}
-
-var disabledWarningsRe = startRegex([
- "Bad for in variable '(.+)'.",
- 'Missing "use strict"'
-]);
-var errorsRe = startRegex([
- "Unexpected",
- "Expected ",
- "Confusing (plus|minus)",
- "\\{a\\} unterminated regular expression",
- "Unclosed ",
- "Unmatched ",
- "Unbegun comment",
- "Bad invocation",
- "Missing space after",
- "Missing operator at"
-]);
-var infoRe = startRegex([
- "Expected an assignment",
- "Bad escapement of EOL",
- "Unexpected comma",
- "Unexpected space",
- "Missing radix parameter.",
- "A leading decimal point can",
- "\\['{a}'\\] is better written in dot notation.",
- "'{a}' used out of scope"
-]);
-
-var JavaScriptWorker = exports.JavaScriptWorker = function(sender) {
- Mirror.call(this, sender);
- this.setTimeout(500);
- this.setOptions();
-};
-
-oop.inherits(JavaScriptWorker, Mirror);
-
-(function() {
- this.setOptions = function(options) {
- this.options = options || {
- es5: true,
- esnext: true,
- devel: true,
- browser: true,
- node: true,
- laxcomma: true,
- laxbreak: true,
- lastsemic: true,
- onevar: false,
- passfail: false,
- maxerr: 100,
- expr: true,
- multistr: true,
- globalstrict: true
- };
- this.doc.getValue() && this.deferredUpdate.schedule(100);
- };
-
- this.changeOptions = function(newOptions) {
- oop.mixin(this.options, newOptions);
- this.doc.getValue() && this.deferredUpdate.schedule(100);
- };
-
- this.isValidJS = function(str) {
- try {
- eval("throw 0;" + str);
- } catch(e) {
- if (e === 0)
- return true;
- }
- return false
- };
-
- this.onUpdate = function() {
- var value = this.doc.getValue();
- value = value.replace(/^#!.*\n/, "\n");
- if (!value) {
- this.sender.emit("jslint", []);
- return;
- }
- var errors = [];
- var maxErrorLevel = this.isValidJS(value) ? "warning" : "error";
- lint(value, this.options);
- var results = lint.errors;
-
- var errorAdded = false
- for (var i = 0; i < results.length; i++) {
- var error = results[i];
- if (!error)
- continue;
- var raw = error.raw;
- var type = "warning";
-
- if (raw == "Missing semicolon.") {
- var str = error.evidence.substr(error.character);
- str = str.charAt(str.search(/\S/));
- if (maxErrorLevel == "error" && str && /[\w\d{(['"]/.test(str)) {
- error.reason = 'Missing ";" before statement';
- type = "error";
- } else {
- type = "info";
- }
- }
- else if (disabledWarningsRe.test(raw)) {
- continue;
- }
- else if (infoRe.test(raw)) {
- type = "info"
- }
- else if (errorsRe.test(raw)) {
- errorAdded = true;
- type = maxErrorLevel;
- }
- else if (raw == "'{a}' is not defined.") {
- type = "warning";
- }
- else if (raw == "'{a}' is defined but never used.") {
- type = "info";
- }
-
- errors.push({
- row: error.line-1,
- column: error.character-1,
- text: error.reason,
- type: type,
- raw: raw
- });
-
- if (errorAdded) {
- }
- }
-
- this.sender.emit("jslint", errors);
- };
-
-}).call(JavaScriptWorker.prototype);
-
-});
-define('ace/worker/mirror', ['require', 'exports', 'module' , 'ace/document', 'ace/lib/lang'], function(require, exports, module) {
-
-
-var Document = require("../document").Document;
-var lang = require("../lib/lang");
-
-var Mirror = exports.Mirror = function(sender) {
- this.sender = sender;
- var doc = this.doc = new Document("");
- this.data = {};
-
- var deferredUpdate = this.deferredUpdate = lang.deferredCall(this.onUpdate.bind(this));
-
- var _self = this;
- sender.on("change", function(e) {
- doc.applyDeltas([e.data]);
- if (_self.$defer)
- deferredUpdate.schedule(_self.$timeout);
- });
-};
-
-(function() {
-
- this.$timeout = 500;
- this.$defer = true;
-
- this.setTimeout = function(timeout) {
- this.$timeout = timeout;
- };
-
- this.setDeferredUpdate = function(defer) {
- this.$defer = defer;
- };
-
- this.setValue = function(value, data) {
- this.doc.setValue(value);
- this.data = data;
- this.deferredUpdate.schedule(this.$timeout);
- };
-
- this.getValue = function(callbackId) {
- this.sender.callback(this.doc.getValue(), callbackId);
- };
-
- this.onUpdate = function() {
- };
-
-}).call(Mirror.prototype);
-
-});
-
-define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/range', 'ace/anchor'], function(require, exports, module) {
-
-
-var oop = require("./lib/oop");
-var EventEmitter = require("./lib/event_emitter").EventEmitter;
-var Range = require("./range").Range;
-var Anchor = require("./anchor").Anchor;
-
-var Document = function(text) {
- this.$lines = [];
- if (text.length == 0) {
- this.$lines = [""];
- } else if (Array.isArray(text)) {
- this.insertLines(0, text);
- } else {
- this.insert({row: 0, column:0}, text);
- }
-};
-
-(function() {
-
- oop.implement(this, EventEmitter);
- this.setValue = function(text) {
- var len = this.getLength();
- this.remove(new Range(0, 0, len, this.getLine(len-1).length));
- this.insert({row: 0, column:0}, text);
- };
- this.getValue = function() {
- return this.getAllLines().join(this.getNewLineCharacter());
- };
- this.createAnchor = function(row, column) {
- return new Anchor(this, row, column);
- };
- if ("aaa".split(/a/).length == 0)
- this.$split = function(text) {
- return text.replace(/\r\n|\r/g, "\n").split("\n");
- }
- else
- this.$split = function(text) {
- return text.split(/\r\n|\r|\n/);
- };
-
-
-
- this.$detectNewLine = function(text) {
- var match = text.match(/^.*?(\r\n|\r|\n)/m);
- if (match) {
- this.$autoNewLine = match[1];
- } else {
- this.$autoNewLine = "\n";
- }
- };
- this.getNewLineCharacter = function() {
- switch (this.$newLineMode) {
- case "windows":
- return "\r\n";
-
- case "unix":
- return "\n";
-
- default:
- return this.$autoNewLine;
- }
- };
-
- this.$autoNewLine = "\n";
- this.$newLineMode = "auto";
- this.setNewLineMode = function(newLineMode) {
- if (this.$newLineMode === newLineMode)
- return;
-
- this.$newLineMode = newLineMode;
- };
- this.getNewLineMode = function() {
- return this.$newLineMode;
- };
- this.isNewLine = function(text) {
- return (text == "\r\n" || text == "\r" || text == "\n");
- };
- this.getLine = function(row) {
- return this.$lines[row] || "";
- };
- this.getLines = function(firstRow, lastRow) {
- return this.$lines.slice(firstRow, lastRow + 1);
- };
- this.getAllLines = function() {
- return this.getLines(0, this.getLength());
- };
- this.getLength = function() {
- return this.$lines.length;
- };
- this.getTextRange = function(range) {
- if (range.start.row == range.end.row) {
- return this.$lines[range.start.row].substring(range.start.column,
- range.end.column);
- }
- else {
- var lines = this.getLines(range.start.row+1, range.end.row-1);
- lines.unshift((this.$lines[range.start.row] || "").substring(range.start.column));
- lines.push((this.$lines[range.end.row] || "").substring(0, range.end.column));
- return lines.join(this.getNewLineCharacter());
- }
- };
-
- this.$clipPosition = function(position) {
- var length = this.getLength();
- if (position.row >= length) {
- position.row = Math.max(0, length - 1);
- position.column = this.getLine(length-1).length;
- }
- return position;
- };
- this.insert = function(position, text) {
- if (!text || text.length === 0)
- return position;
-
- position = this.$clipPosition(position);
- if (this.getLength() <= 1)
- this.$detectNewLine(text);
-
- var lines = this.$split(text);
- var firstLine = lines.splice(0, 1)[0];
- var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
-
- position = this.insertInLine(position, firstLine);
- if (lastLine !== null) {
- position = this.insertNewLine(position); // terminate first line
- position = this.insertLines(position.row, lines);
- position = this.insertInLine(position, lastLine || "");
- }
- return position;
- };
- this.insertLines = function(row, lines) {
- if (lines.length == 0)
- return {row: row, column: 0};
- if (lines.length > 0xFFFF) {
- var end = this.insertLines(row, lines.slice(0xFFFF));
- lines = lines.slice(0, 0xFFFF);
- }
-
- var args = [row, 0];
- args.push.apply(args, lines);
- this.$lines.splice.apply(this.$lines, args);
-
- var range = new Range(row, 0, row + lines.length, 0);
- var delta = {
- action: "insertLines",
- range: range,
- lines: lines
- };
- this._emit("change", { data: delta });
- return end || range.end;
- };
- this.insertNewLine = function(position) {
- position = this.$clipPosition(position);
- var line = this.$lines[position.row] || "";
-
- this.$lines[position.row] = line.substring(0, position.column);
- this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
-
- var end = {
- row : position.row + 1,
- column : 0
- };
-
- var delta = {
- action: "insertText",
- range: Range.fromPoints(position, end),
- text: this.getNewLineCharacter()
- };
- this._emit("change", { data: delta });
-
- return end;
- };
- this.insertInLine = function(position, text) {
- if (text.length == 0)
- return position;
-
- var line = this.$lines[position.row] || "";
-
- this.$lines[position.row] = line.substring(0, position.column) + text
- + line.substring(position.column);
-
- var end = {
- row : position.row,
- column : position.column + text.length
- };
-
- var delta = {
- action: "insertText",
- range: Range.fromPoints(position, end),
- text: text
- };
- this._emit("change", { data: delta });
-
- return end;
- };
- this.remove = function(range) {
- range.start = this.$clipPosition(range.start);
- range.end = this.$clipPosition(range.end);
-
- if (range.isEmpty())
- return range.start;
-
- var firstRow = range.start.row;
- var lastRow = range.end.row;
-
- if (range.isMultiLine()) {
- var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
- var lastFullRow = lastRow - 1;
-
- if (range.end.column > 0)
- this.removeInLine(lastRow, 0, range.end.column);
-
- if (lastFullRow >= firstFullRow)
- this.removeLines(firstFullRow, lastFullRow);
-
- if (firstFullRow != firstRow) {
- this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
- this.removeNewLine(range.start.row);
- }
- }
- else {
- this.removeInLine(firstRow, range.start.column, range.end.column);
- }
- return range.start;
- };
- this.removeInLine = function(row, startColumn, endColumn) {
- if (startColumn == endColumn)
- return;
-
- var range = new Range(row, startColumn, row, endColumn);
- var line = this.getLine(row);
- var removed = line.substring(startColumn, endColumn);
- var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
- this.$lines.splice(row, 1, newLine);
-
- var delta = {
- action: "removeText",
- range: range,
- text: removed
- };
- this._emit("change", { data: delta });
- return range.start;
- };
- this.removeLines = function(firstRow, lastRow) {
- var range = new Range(firstRow, 0, lastRow + 1, 0);
- var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
-
- var delta = {
- action: "removeLines",
- range: range,
- nl: this.getNewLineCharacter(),
- lines: removed
- };
- this._emit("change", { data: delta });
- return removed;
- };
- this.removeNewLine = function(row) {
- var firstLine = this.getLine(row);
- var secondLine = this.getLine(row+1);
-
- var range = new Range(row, firstLine.length, row+1, 0);
- var line = firstLine + secondLine;
-
- this.$lines.splice(row, 2, line);
-
- var delta = {
- action: "removeText",
- range: range,
- text: this.getNewLineCharacter()
- };
- this._emit("change", { data: delta });
- };
- this.replace = function(range, text) {
- if (text.length == 0 && range.isEmpty())
- return range.start;
- if (text == this.getTextRange(range))
- return range.end;
-
- this.remove(range);
- if (text) {
- var end = this.insert(range.start, text);
- }
- else {
- end = range.start;
- }
-
- return end;
- };
- this.applyDeltas = function(deltas) {
- for (var i=0; i<deltas.length; i++) {
- var delta = deltas[i];
- var range = Range.fromPoints(delta.range.start, delta.range.end);
-
- if (delta.action == "insertLines")
- this.insertLines(range.start.row, delta.lines);
- else if (delta.action == "insertText")
- this.insert(range.start, delta.text);
- else if (delta.action == "removeLines")
- this.removeLines(range.start.row, range.end.row - 1);
- else if (delta.action == "removeText")
- this.remove(range);
- }
- };
- this.revertDeltas = function(deltas) {
- for (var i=deltas.length-1; i>=0; i--) {
- var delta = deltas[i];
-
- var range = Range.fromPoints(delta.range.start, delta.range.end);
-
- if (delta.action == "insertLines")
- this.removeLines(range.start.row, range.end.row - 1);
- else if (delta.action == "insertText")
- this.remove(range);
- else if (delta.action == "removeLines")
- this.insertLines(range.start.row, delta.lines);
- else if (delta.action == "removeText")
- this.insert(range.start, delta.text);
- }
- };
- this.indexToPosition = function(index, startRow) {
- var lines = this.$lines || this.getAllLines();
- var newlineLength = this.getNewLineCharacter().length;
- for (var i = startRow || 0, l = lines.length; i < l; i++) {
- index -= lines[i].length + newlineLength;
- if (index < 0)
- return {row: i, column: index + lines[i].length + newlineLength};
- }
- return {row: l-1, column: lines[l-1].length};
- };
- this.positionToIndex = function(pos, startRow) {
- var lines = this.$lines || this.getAllLines();
- var newlineLength = this.getNewLineCharacter().length;
- var index = 0;
- var row = Math.min(pos.row, lines.length);
- for (var i = startRow || 0; i < row; ++i)
- index += lines[i].length;
-
- return index + newlineLength * i + pos.column;
- };
-
-}).call(Document.prototype);
-
-exports.Document = Document;
-});
-
-define('ace/range', ['require', 'exports', 'module' ], function(require, exports, module) {
-var Range = function(startRow, startColumn, endRow, endColumn) {
- this.start = {
- row: startRow,
- column: startColumn
- };
-
- this.end = {
- row: endRow,
- column: endColumn
- };
-};
-
-(function() {
- this.isEqual = function(range) {
- return this.start.row == range.start.row &&
- this.end.row == range.end.row &&
- this.start.column == range.start.column &&
- this.end.column == range.end.column
- };
- this.toString = function() {
- return ("Range: [" + this.start.row + "/" + this.start.column +
- "] -> [" + this.end.row + "/" + this.end.column + "]");
- };
-
- this.contains = function(row, column) {
- return this.compare(row, column) == 0;
- };
- this.compareRange = function(range) {
- var cmp,
- end = range.end,
- start = range.start;
-
- cmp = this.compare(end.row, end.column);
- if (cmp == 1) {
- cmp = this.compare(start.row, start.column);
- if (cmp == 1) {
- return 2;
- } else if (cmp == 0) {
- return 1;
- } else {
- return 0;
- }
- } else if (cmp == -1) {
- return -2;
- } else {
- cmp = this.compare(start.row, start.column);
- if (cmp == -1) {
- return -1;
- } else if (cmp == 1) {
- return 42;
- } else {
- return 0;
- }
- }
- };
- this.comparePoint = function(p) {
- return this.compare(p.row, p.column);
- };
- this.containsRange = function(range) {
- return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
- };
- this.intersects = function(range) {
- var cmp = this.compareRange(range);
- return (cmp == -1 || cmp == 0 || cmp == 1);
- };
- this.isEnd = function(row, column) {
- return this.end.row == row && this.end.column == column;
- };
- this.isStart = function(row, column) {
- return this.start.row == row && this.start.column == column;
- };
- this.setStart = function(row, column) {
- if (typeof row == "object") {
- this.start.column = row.column;
- this.start.row = row.row;
- } else {
- this.start.row = row;
- this.start.column = column;
- }
- };
- this.setEnd = function(row, column) {
- if (typeof row == "object") {
- this.end.column = row.column;
- this.end.row = row.row;
- } else {
- this.end.row = row;
- this.end.column = column;
- }
- };
- this.inside = function(row, column) {
- if (this.compare(row, column) == 0) {
- if (this.isEnd(row, column) || this.isStart(row, column)) {
- return false;
- } else {
- return true;
- }
- }
- return false;
- };
- this.insideStart = function(row, column) {
- if (this.compare(row, column) == 0) {
- if (this.isEnd(row, column)) {
- return false;
- } else {
- return true;
- }
- }
- return false;
- };
- this.insideEnd = function(row, column) {
- if (this.compare(row, column) == 0) {
- if (this.isStart(row, column)) {
- return false;
- } else {
- return true;
- }
- }
- return false;
- };
- this.compare = function(row, column) {
- if (!this.isMultiLine()) {
- if (row === this.start.row) {
- return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
- };
- }
-
- if (row < this.start.row)
- return -1;
-
- if (row > this.end.row)
- return 1;
-
- if (this.start.row === row)
- return column >= this.start.column ? 0 : -1;
-
- if (this.end.row === row)
- return column <= this.end.column ? 0 : 1;
-
- return 0;
- };
- this.compareStart = function(row, column) {
- if (this.start.row == row && this.start.column == column) {
- return -1;
- } else {
- return this.compare(row, column);
- }
- };
- this.compareEnd = function(row, column) {
- if (this.end.row == row && this.end.column == column) {
- return 1;
- } else {
- return this.compare(row, column);
- }
- };
- this.compareInside = function(row, column) {
- if (this.end.row == row && this.end.column == column) {
- return 1;
- } else if (this.start.row == row && this.start.column == column) {
- return -1;
- } else {
- return this.compare(row, column);
- }
- };
- this.clipRows = function(firstRow, lastRow) {
- if (this.end.row > lastRow) {
- var end = {
- row: lastRow+1,
- column: 0
- };
- }
-
- if (this.start.row > lastRow) {
- var start = {
- row: lastRow+1,
- column: 0
- };
- }
-
- if (this.start.row < firstRow) {
- var start = {
- row: firstRow,
- column: 0
- };
- }
-
- if (this.end.row < firstRow) {
- var end = {
- row: firstRow,
- column: 0
- };
- }
- return Range.fromPoints(start || this.start, end || this.end);
- };
- this.extend = function(row, column) {
- var cmp = this.compare(row, column);
-
- if (cmp == 0)
- return this;
- else if (cmp == -1)
- var start = {row: row, column: column};
- else
- var end = {row: row, column: column};
-
- return Range.fromPoints(start || this.start, end || this.end);
- };
-
- this.isEmpty = function() {
- return (this.start.row == this.end.row && this.start.column == this.end.column);
- };
- this.isMultiLine = function() {
- return (this.start.row !== this.end.row);
- };
- this.clone = function() {
- return Range.fromPoints(this.start, this.end);
- };
- this.collapseRows = function() {
- if (this.end.column == 0)
- return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
- else
- return new Range(this.start.row, 0, this.end.row, 0)
- };
- this.toScreenRange = function(session) {
- var screenPosStart =
- session.documentToScreenPosition(this.start);
- var screenPosEnd =
- session.documentToScreenPosition(this.end);
-
- return new Range(
- screenPosStart.row, screenPosStart.column,
- screenPosEnd.row, screenPosEnd.column
- );
- };
-
-}).call(Range.prototype);
-Range.fromPoints = function(start, end) {
- return new Range(start.row, start.column, end.row, end.column);
-};
-
-exports.Range = Range;
-});
-
-define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
-
-
-var oop = require("./lib/oop");
-var EventEmitter = require("./lib/event_emitter").EventEmitter;
-
-var Anchor = exports.Anchor = function(doc, row, column) {
- this.document = doc;
-
- if (typeof column == "undefined")
- this.setPosition(row.row, row.column);
- else
- this.setPosition(row, column);
-
- this.$onChange = this.onChange.bind(this);
- doc.on("change", this.$onChange);
-};
-
-(function() {
-
- oop.implement(this, EventEmitter);
-
- this.getPosition = function() {
- return this.$clipPositionToDocument(this.row, this.column);
- };
-
- this.getDocument = function() {
- return this.document;
- };
-
- this.onChange = function(e) {
- var delta = e.data;
- var range = delta.range;
-
- if (range.start.row == range.end.row && range.start.row != this.row)
- return;
-
- if (range.start.row > this.row)
- return;
-
- if (range.start.row == this.row && range.start.column > this.column)
- return;
-
- var row = this.row;
- var column = this.column;
-
- if (delta.action === "insertText") {
- if (range.start.row === row && range.start.column <= column) {
- if (range.start.row === range.end.row) {
- column += range.end.column - range.start.column;
- }
- else {
- column -= range.start.column;
- row += range.end.row - range.start.row;
- }
- }
- else if (range.start.row !== range.end.row && range.start.row < row) {
- row += range.end.row - range.start.row;
- }
- } else if (delta.action === "insertLines") {
- if (range.start.row <= row) {
- row += range.end.row - range.start.row;
- }
- }
- else if (delta.action == "removeText") {
- if (range.start.row == row && range.start.column < column) {
- if (range.end.column >= column)
- column = range.start.column;
- else
- column = Math.max(0, column - (range.end.column - range.start.column));
-
- } else if (range.start.row !== range.end.row && range.start.row < row) {
- if (range.end.row == row) {
- column = Math.max(0, column - range.end.column) + range.start.column;
- }
- row -= (range.end.row - range.start.row);
- }
- else if (range.end.row == row) {
- row -= range.end.row - range.start.row;
- column = Math.max(0, column - range.end.column) + range.start.column;
- }
- } else if (delta.action == "removeLines") {
- if (range.start.row <= row) {
- if (range.end.row <= row)
- row -= range.end.row - range.start.row;
- else {
- row = range.start.row;
- column = 0;
- }
- }
- }
-
- this.setPosition(row, column, true);
- };
-
- this.setPosition = function(row, column, noClip) {
- var pos;
- if (noClip) {
- pos = {
- row: row,
- column: column
- };
- }
- else {
- pos = this.$clipPositionToDocument(row, column);
- }
-
- if (this.row == pos.row && this.column == pos.column)
- return;
-
- var old = {
- row: this.row,
- column: this.column
- };
-
- this.row = pos.row;
- this.column = pos.column;
- this._emit("change", {
- old: old,
- value: pos
- });
- };
-
- this.detach = function() {
- this.document.removeEventListener("change", this.$onChange);
- };
- this.$clipPositionToDocument = function(row, column) {
- var pos = {};
-
- if (row >= this.document.getLength()) {
- pos.row = Math.max(0, this.document.getLength() - 1);
- pos.column = this.document.getLine(pos.row).length;
- }
- else if (row < 0) {
- pos.row = 0;
- pos.column = 0;
- }
- else {
- pos.row = row;
- pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
- }
-
- if (column < 0)
- pos.column = 0;
-
- return pos;
- };
-
-}).call(Anchor.prototype);
-
-});
-
-define('ace/lib/lang', ['require', 'exports', 'module' ], function(require, exports, module) {
-
-
-exports.stringReverse = function(string) {
- return string.split("").reverse().join("");
-};
-
-exports.stringRepeat = function (string, count) {
- var result = '';
- while (count > 0) {
- if (count & 1)
- result += string;
-
- if (count >>= 1)
- string += string;
- }
- return result;
-};
-
-var trimBeginRegexp = /^\s\s*/;
-var trimEndRegexp = /\s\s*$/;
-
-exports.stringTrimLeft = function (string) {
- return string.replace(trimBeginRegexp, '');
-};
-
-exports.stringTrimRight = function (string) {
- return string.replace(trimEndRegexp, '');
-};
-
-exports.copyObject = function(obj) {
- var copy = {};
- for (var key in obj) {
- copy[key] = obj[key];
- }
- return copy;
-};
-
-exports.copyArray = function(array){
- var copy = [];
- for (var i=0, l=array.length; i<l; i++) {
- if (array[i] && typeof array[i] == "object")
- copy[i] = this.copyObject( array[i] );
- else
- copy[i] = array[i];
- }
- return copy;
-};
-
-exports.deepCopy = function (obj) {
- if (typeof obj != "object") {
- return obj;
- }
-
- var copy = obj.constructor();
- for (var key in obj) {
- if (typeof obj[key] == "object") {
- copy[key] = this.deepCopy(obj[key]);
- } else {
- copy[key] = obj[key];
- }
- }
- return copy;
-};
-
-exports.arrayToMap = function(arr) {
- var map = {};
- for (var i=0; i<arr.length; i++) {
- map[arr[i]] = 1;
- }
- return map;
-
-};
-
-exports.createMap = function(props) {
- var map = Object.create(null);
- for (var i in props) {
- map[i] = props[i];
- }
- return map;
-};
-exports.arrayRemove = function(array, value) {
- for (var i = 0; i <= array.length; i++) {
- if (value === array[i]) {
- array.splice(i, 1);
- }
- }
-};
-
-exports.escapeRegExp = function(str) {
- return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
-};
-
-exports.escapeHTML = function(str) {
- return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
-};
-
-exports.getMatchOffsets = function(string, regExp) {
- var matches = [];
-
- string.replace(regExp, function(str) {
- matches.push({
- offset: arguments[arguments.length-2],
- length: str.length
- });
- });
-
- return matches;
-};
-exports.deferredCall = function(fcn) {
-
- var timer = null;
- var callback = function() {
- timer = null;
- fcn();
- };
-
- var deferred = function(timeout) {
- deferred.cancel();
- timer = setTimeout(callback, timeout || 0);
- return deferred;
- };
-
- deferred.schedule = deferred;
-
- deferred.call = function() {
- this.cancel();
- fcn();
- return deferred;
- };
-
- deferred.cancel = function() {
- clearTimeout(timer);
- timer = null;
- return deferred;
- };
-
- return deferred;
-};
-
-
-exports.delayedCall = function(fcn, defaultTimeout) {
- var timer = null;
- var callback = function() {
- timer = null;
- fcn();
- };
-
- var _self = function(timeout) {
- timer && clearTimeout(timer);
- timer = setTimeout(callback, timeout || defaultTimeout);
- };
-
- _self.delay = _self;
- _self.schedule = function(timeout) {
- if (timer == null)
- timer = setTimeout(callback, timeout || 0);
- };
-
- _self.call = function() {
- this.cancel();
- fcn();
- };
-
- _self.cancel = function() {
- timer && clearTimeout(timer);
- timer = null;
- };
-
- _self.isPending = function() {
- return timer;
- };
-
- return _self;
-};
-});
-define('ace/mode/javascript/jshint', ['require', 'exports', 'module' ], function(require, exports, module) {
-
-var JSHINT = (function () {
-
-
- var anonname, // The guessed name for anonymous functions.
-
- bang = {
- "<" : true,
- "<=" : true,
- "==" : true,
- "===": true,
- "!==": true,
- "!=" : true,
- ">" : true,
- ">=" : true,
- "+" : true,
- "-" : true,
- "*" : true,
- "/" : true,
- "%" : true
- },
- boolOptions = {
- asi : true, // if automatic semicolon insertion should be tolerated
- bitwise : true, // if bitwise operators should not be allowed
- boss : true, // if advanced usage of assignments should be allowed
- browser : true, // if the standard browser globals should be predefined
- camelcase : true, // if identifiers should be required in camel case
- couch : true, // if CouchDB globals should be predefined
- curly : true, // if curly braces around all blocks should be required
- debug : true, // if debugger statements should be allowed
- devel : true, // if logging globals should be predefined (console,
- dojo : true, // if Dojo Toolkit globals should be predefined
- eqeqeq : true, // if === should be required
- eqnull : true, // if == null comparisons should be tolerated
- es5 : true, // if ES5 syntax should be allowed
- esnext : true, // if es.next specific syntax should be allowed
- evil : true, // if eval should be allowed
- expr : true, // if ExpressionStatement should be allowed as Programs
- forin : true, // if for in statements must filter
- funcscope : true, // if only function scope should be used for scope tests
- globalstrict: true, // if global should be allowed (also
- immed : true, // if immediate invocations must be wrapped in parens
- iterator : true, // if the `__iterator__` property should be allowed
- jquery : true, // if jQuery globals should be predefined
- lastsemic : true, // if semicolons may be ommitted for the trailing
- latedef : true, // if the use before definition should not be tolerated
- laxbreak : true, // if line breaks should not be checked
- laxcomma : true, // if line breaks should not be checked around commas
- loopfunc : true, // if functions should be allowed to be defined within
- mootools : true, // if MooTools globals should be predefined
- multistr : true, // allow multiline strings
- newcap : true, // if constructor names must be capitalized
- noarg : true, // if arguments.caller and arguments.callee should be
- node : true, // if the Node.js environment globals should be
- noempty : true, // if empty blocks should be disallowed
- nonew : true, // if using `new` for side-effects should be disallowed
- nonstandard : true, // if non-standard (but widely adopted) globals should
- nomen : true, // if names should be checked
- onevar : true, // if only one var statement per function should be
- onecase : true, // if one case switch statements should be allowed
- passfail : true, // if the scan should stop on first error
- plusplus : true, // if increment/decrement should not be allowed
- proto : true, // if the `__proto__` property should be allowed
- prototypejs : true, // if Prototype and Scriptaculous globals should be
- regexdash : true, // if unescaped first/last dash (-) inside brackets
- regexp : true, // if the . should not be allowed in regexp literals
- rhino : true, // if the Rhino environment globals should be predefined
- undef : true, // if variables should be declared before used
- unused : true, // if variables should be always used
- scripturl : true, // if script-targeted URLs should be tolerated
- shadow : true, // if variable shadowing should be tolerated
- smarttabs : true, // if smarttabs should be tolerated
- strict : true, // require the pragma
- sub : true, // if all forms of subscript notation are tolerated
- supernew : true, // if `new function () { ... };` and `new Object;`
- trailing : true, // if trailing whitespace rules apply
- validthis : true, // if 'this' inside a non-constructor function is valid.
- withstmt : true, // if with statements should be allowed
- white : true, // if strict whitespace rules apply
- worker : true, // if Web Worker script symbols should be allowed
- wsh : true, // if the Windows Scripting Host environment globals
- yui : true // YUI variables should be predefined
- },
- valOptions = {
- maxlen : false,
- indent : false,
- maxerr : false,
- predef : false,
- quotmark : false, //'single'|'double'|true
- scope : false,
- maxstatements: false, // {int} max statements per function
- maxdepth : false, // {int} max nested block depth per function
- maxparams : false, // {int} max params per function
- maxcomplexity: false // {int} max cyclomatic complexity per function
- },
- invertedOptions = {
- bitwise : true,
- forin : true,
- newcap : true,
- nomen : true,
- plusplus : true,
- regexp : true,
- undef : true,
- white : true,
- eqeqeq : true,
- onevar : true
- },
- renamedOptions = {
- eqeq : "eqeqeq",
- vars : "onevar",
- windows : "wsh"
- },
- browser = {
- ArrayBuffer : false,
- ArrayBufferView : false,
- Audio : false,
- Blob : false,
- addEventListener : false,
- applicationCache : false,
- atob : false,
- blur : false,
- btoa : false,
- clearInterval : false,
- clearTimeout : false,
- close : false,
- closed : false,
- DataView : false,
- DOMParser : false,
- defaultStatus : false,
- document : false,
- event : false,
- FileReader : false,
- Float32Array : false,
- Float64Array : false,
- FormData : false,
- focus : false,
- frames : false,
- getComputedStyle : false,
- HTMLElement : false,
- HTMLAnchorElement : false,
- HTMLBaseElement : false,
- HTMLBlockquoteElement : false,
- HTMLBodyElement : false,
- HTMLBRElement : false,
- HTMLButtonElement : false,
- HTMLCanvasElement : false,
- HTMLDirectoryElement : false,
- HTMLDivElement : false,
- HTMLDListElement : false,
- HTMLFieldSetElement : false,
- HTMLFontElement : false,
- HTMLFormElement : false,
- HTMLFrameElement : false,
- HTMLFrameSetElement : false,
- HTMLHeadElement : false,
- HTMLHeadingElement : false,
- HTMLHRElement : false,
- HTMLHtmlElement : false,
- HTMLIFrameElement : false,
- HTMLImageElement : false,
- HTMLInputElement : false,
- HTMLIsIndexElement : false,
- HTMLLabelElement : false,
- HTMLLayerElement : false,
- HTMLLegendElement : false,
- HTMLLIElement : false,
- HTMLLinkElement : false,
- HTMLMapElement : false,
- HTMLMenuElement : false,
- HTMLMetaElement : false,
- HTMLModElement : false,
- HTMLObjectElement : false,
- HTMLOListElement : false,
- HTMLOptGroupElement : false,
- HTMLOptionElement : false,
- HTMLParagraphElement : false,
- HTMLParamElement : false,
- HTMLPreElement : false,
- HTMLQuoteElement : false,
- HTMLScriptElement : false,
- HTMLSelectElement : false,
- HTMLStyleElement : false,
- HTMLTableCaptionElement : false,
- HTMLTableCellElement : false,
- HTMLTableColElement : false,
- HTMLTableElement : false,
- HTMLTableRowElement : false,
- HTMLTableSectionElement : false,
- HTMLTextAreaElement : false,
- HTMLTitleElement : false,
- HTMLUListElement : false,
- HTMLVideoElement : false,
- history : false,
- Int16Array : false,
- Int32Array : false,
- Int8Array : false,
- Image : false,
- length : false,
- localStorage : false,
- location : false,
- MessageChannel : false,
- MessageEvent : false,
- MessagePort : false,
- moveBy : false,
- moveTo : false,
- MutationObserver : false,
- name : false,
- Node : false,
- NodeFilter : false,
- navigator : false,
- onbeforeunload : true,
- onblur : true,
- onerror : true,
- onfocus : true,
- onload : true,
- onresize : true,
- onunload : true,
- open : false,
- openDatabase : false,
- opener : false,
- Option : false,
- parent : false,
- print : false,
- removeEventListener : false,
- resizeBy : false,
- resizeTo : false,
- screen : false,
- scroll : false,
- scrollBy : false,
- scrollTo : false,
- sessionStorage : false,
- setInterval : false,
- setTimeout : false,
- SharedWorker : false,
- status : false,
- top : false,
- Uint16Array : false,
- Uint32Array : false,
- Uint8Array : false,
- WebSocket : false,
- window : false,
- Worker : false,
- XMLHttpRequest : false,
- XMLSerializer : false,
- XPathEvaluator : false,
- XPathException : false,
- XPathExpression : false,
- XPathNamespace : false,
- XPathNSResolver : false,
- XPathResult : false
- },
-
- couch = {
- "require" : false,
- respond : false,
- getRow : false,
- emit : false,
- send : false,
- start : false,
- sum : false,
- log : false,
- exports : false,
- module : false,
- provides : false
- },
-
- declared, // Globals that were declared using /*global ... */ syntax.
-
- devel = {
- alert : false,
- confirm : false,
- console : false,
- Debug : false,
- opera : false,
- prompt : false
- },
-
- dojo = {
- dojo : false,
- dijit : false,
- dojox : false,
- define : false,
- "require" : false
- },
-
- funct, // The current function
-
- functionicity = [
- "closure", "exception", "global", "label",
- "outer", "unused", "var"
- ],
-
- functions, // All of the functions
-
- global, // The global scope
- implied, // Implied globals
- inblock,
- indent,
- jsonmode,
-
- jquery = {
- "$" : false,
- jQuery : false
- },
-
- lines,
- lookahead,
- member,
- membersOnly,
-
- mootools = {
- "$" : false,
- "$$" : false,
- Asset : false,
- Browser : false,
- Chain : false,
- Class : false,
- Color : false,
- Cookie : false,
- Core : false,
- Document : false,
- DomReady : false,
- DOMEvent : false,
- DOMReady : false,
- Drag : false,
- Element : false,
- Elements : false,
- Event : false,
- Events : false,
- Fx : false,
- Group : false,
- Hash : false,
- HtmlTable : false,
- Iframe : false,
- IframeShim : false,
- InputValidator : false,
- instanceOf : false,
- Keyboard : false,
- Locale : false,
- Mask : false,
- MooTools : false,
- Native : false,
- Options : false,
- OverText : false,
- Request : false,
- Scroller : false,
- Slick : false,
- Slider : false,
- Sortables : false,
- Spinner : false,
- Swiff : false,
- Tips : false,
- Type : false,
- typeOf : false,
- URI : false,
- Window : false
- },
-
- nexttoken,
-
- node = {
- __filename : false,
- __dirname : false,
- Buffer : false,
- console : false,
- exports : true, // In Node it is ok to exports = module.exports = foo();
- GLOBAL : false,
- global : false,
- module : false,
- process : false,
- require : false,
- setTimeout : false,
- clearTimeout : false,
- setInterval : false,
- clearInterval : false
- },
-
- noreach,
- option,
- predefined, // Global variables defined by option
- prereg,
- prevtoken,
-
- prototypejs = {
- "$" : false,
- "$$" : false,
- "$A" : false,
- "$F" : false,
- "$H" : false,
- "$R" : false,
- "$break" : false,
- "$continue" : false,
- "$w" : false,
- Abstract : false,
- Ajax : false,
- Class : false,
- Enumerable : false,
- Element : false,
- Event : false,
- Field : false,
- Form : false,
- Hash : false,
- Insertion : false,
- ObjectRange : false,
- PeriodicalExecuter: false,
- Position : false,
- Prototype : false,
- Selector : false,
- Template : false,
- Toggle : false,
- Try : false,
- Autocompleter : false,
- Builder : false,
- Control : false,
- Draggable : false,
- Draggables : false,
- Droppables : false,
- Effect : false,
- Sortable : false,
- SortableObserver : false,
- Sound : false,
- Scriptaculous : false
- },
-
- quotmark,
-
- rhino = {
- defineClass : false,
- deserialize : false,
- gc : false,
- help : false,
- importPackage: false,
- "java" : false,
- load : false,
- loadClass : false,
- print : false,
- quit : false,
- readFile : false,
- readUrl : false,
- runCommand : false,
- seal : false,
- serialize : false,
- spawn : false,
- sync : false,
- toint32 : false,
- version : false
- },
-
- scope, // The current scope
- stack,
- standard = {
- Array : false,
- Boolean : false,
- Date : false,
- decodeURI : false,
- decodeURIComponent : false,
- encodeURI : false,
- encodeURIComponent : false,
- Error : false,
- "eval" : false,
- EvalError : false,
- Function : false,
- hasOwnProperty : false,
- isFinite : false,
- isNaN : false,
- JSON : false,
- Map : false,
- Math : false,
- NaN : false,
- Number : false,
- Object : false,
- parseInt : false,
- parseFloat : false,
- RangeError : false,
- ReferenceError : false,
- RegExp : false,
- Set : false,
- String : false,
- SyntaxError : false,
- TypeError : false,
- URIError : false,
- WeakMap : false
- },
- nonstandard = {
- escape : false,
- unescape : false
- },
-
- directive,
- syntax = {},
- tab,
- token,
- unuseds,
- urls,
- useESNextSyntax,
- warnings,
-
- worker = {
- importScripts : true,
- postMessage : true,
- self : true
- },
-
- wsh = {
- ActiveXObject : true,
- Enumerator : true,
- GetObject : true,
- ScriptEngine : true,
- ScriptEngineBuildVersion : true,
- ScriptEngineMajorVersion : true,
- ScriptEngineMinorVersion : true,
- VBArray : true,
- WSH : true,
- WScript : true,
- XDomainRequest : true
- },
-
- yui = {
- YUI : false,
- Y : false,
- YUI_config : false
- };
- var ax, cx, tx, nx, nxg, lx, ix, jx, ft;
- (function () {
- ax = /@cc|<\/?|script|\]\s*\]|<\s*!|&lt/i;
- cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
- tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/=(?!(\S*\/[gim]?))|\/(\*(jshint|jslint|members?|global)?|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/;
- nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
- nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
- lx = /\*\//;
- ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/;
- jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i;
- ft = /^\s*\/\*\s*falls\sthrough\s*\*\/\s*$/;
- }());
-
- function F() {} // Used by Object.create
-
- function is_own(object, name) {
- return Object.prototype.hasOwnProperty.call(object, name);
- }
-
- function checkOption(name, t) {
- if (valOptions[name] === undefined && boolOptions[name] === undefined) {
- warning("Bad option: '" + name + "'.", t);
- }
- }
-
- function isString(obj) {
- return Object.prototype.toString.call(obj) === "[object String]";
- }
-
- if (typeof Array.isArray !== "function") {
- Array.isArray = function (o) {
- return Object.prototype.toString.apply(o) === "[object Array]";
- };
- }
-
- if (!Array.prototype.forEach) {
- Array.prototype.forEach = function (fn, scope) {
- var len = this.length;
-
- for (var i = 0; i < len; i++) {
- fn.call(scope || this, this[i], i, this);
- }
- };
- }
-
- if (!Array.prototype.indexOf) {
- Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
- if (this === null || this === undefined) {
- throw new TypeError();
- }
-
- var t = new Object(this);
- var len = t.length >>> 0;
-
- if (len === 0) {
- return -1;
- }
-
- var n = 0;
- if (arguments.length > 0) {
- n = Number(arguments[1]);
- if (n != n) { // shortcut for verifying if it's NaN
- n = 0;
- } else if (n !== 0 && n != Infinity && n != -Infinity) {
- n = (n > 0 || -1) * Math.floor(Math.abs(n));
- }
- }
-
- if (n >= len) {
- return -1;
- }
-
- var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
- for (; k < len; k++) {
- if (k in t && t[k] === searchElement) {
- return k;
- }
- }
-
- return -1;
- };
- }
-
- if (typeof Object.create !== "function") {
- Object.create = function (o) {
- F.prototype = o;
- return new F();
- };
- }
-
- if (typeof Object.keys !== "function") {
- Object.keys = function (o) {
- var a = [], k;
- for (k in o) {
- if (is_own(o, k)) {
- a.push(k);
- }
- }
- return a;
- };
- }
-
- function isAlpha(str) {
- return (str >= "a" && str <= "z\uffff") ||
- (str >= "A" && str <= "Z\uffff");
- }
-
- function isDigit(str) {
- return (str >= "0" && str <= "9");
- }
-
- function isIdentifier(token, value) {
- if (!token)
- return false;
-
- if (!token.identifier || token.value !== value)
- return false;
-
- return true;
- }
-
- function supplant(str, data) {
- return str.replace(/\{([^{}]*)\}/g, function (a, b) {
- var r = data[b];
- return typeof r === "string" || typeof r === "number" ? r : a;
- });
- }
-
- function combine(t, o) {
- var n;
- for (n in o) {
- if (is_own(o, n) && !is_own(JSHINT.blacklist, n)) {
- t[n] = o[n];
- }
- }
- }
-
- function updatePredefined() {
- Object.keys(JSHINT.blacklist).forEach(function (key) {
- delete predefined[key];
- });
- }
-
- function assume() {
- if (option.couch) {
- combine(predefined, couch);
- }
-
- if (option.rhino) {
- combine(predefined, rhino);
- }
-
- if (option.prototypejs) {
- combine(predefined, prototypejs);
- }
-
- if (option.node) {
- combine(predefined, node);
- option.globalstrict = true;
- }
-
- if (option.devel) {
- combine(predefined, devel);
- }
-
- if (option.dojo) {
- combine(predefined, dojo);
- }
-
- if (option.browser) {
- combine(predefined, browser);
- }
-
- if (option.nonstandard) {
- combine(predefined, nonstandard);
- }
-
- if (option.jquery) {
- combine(predefined, jquery);
- }
-
- if (option.mootools) {
- combine(predefined, mootools);
- }
-
- if (option.worker) {
- combine(predefined, worker);
- }
-
- if (option.wsh) {
- combine(predefined, wsh);
- }
-
- if (option.esnext) {
- useESNextSyntax();
- }
-
- if (option.globalstrict && option.strict !== false) {
- option.strict = true;
- }
-
- if (option.yui) {
- combine(predefined, yui);
- }
- }
- function quit(message, line, chr) {
- var percentage = Math.floor((line / lines.length) * 100);
-
- throw {
- name: "JSHintError",
- line: line,
- character: chr,
- message: message + " (" + percentage + "% scanned).",
- raw: message
- };
- }
-
- function isundef(scope, m, t, a) {
- return JSHINT.undefs.push([scope, m, t, a]);
- }
-
- function warning(m, t, a, b, c, d) {
- var ch, l, w;
- t = t || nexttoken;
- if (t.id === "(end)") { // `~
- t = token;
- }
- l = t.line || 0;
- ch = t.from || 0;
- w = {
- id: "(error)",
- raw: m,
- evidence: lines[l - 1] || "",
- line: l,
- character: ch,
- scope: JSHINT.scope,
- a: a,
- b: b,
- c: c,
- d: d
- };
- w.reason = supplant(m, w);
- JSHINT.errors.push(w);
- if (option.passfail) {
- quit("Stopping. ", l, ch);
- }
- warnings += 1;
- if (warnings >= option.maxerr) {
- quit("Too many errors.", l, ch);
- }
- return w;
- }
-
- function warningAt(m, l, ch, a, b, c, d) {
- return warning(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
-
- function error(m, t, a, b, c, d) {
- warning(m, t, a, b, c, d);
- }
-
- function errorAt(m, l, ch, a, b, c, d) {
- return error(m, {
- line: l,
- from: ch
- }, a, b, c, d);
- }
- function addInternalSrc(elem, src) {
- var i;
- i = {
- id: "(internal)",
- elem: elem,
- value: src
- };
- JSHINT.internals.push(i);
- return i;
- }
-
- var lex = (function lex() {
- var character, from, line, s;
-
- function nextLine() {
- var at,
- match,
- tw; // trailing whitespace check
-
- if (line >= lines.length)
- return false;
-
- character = 1;
- s = lines[line];
- line += 1;
- if (option.smarttabs) {
- match = s.match(/(\/\/)? \t/);
- at = match && !match[1] ? 0 : -1;
- } else {
- at = s.search(/ \t|\t [^\*]/);
- }
-
- if (at >= 0)
- warningAt("Mixed spaces and tabs.", line, at + 1);
-
- s = s.replace(/\t/g, tab);
- at = s.search(cx);
-
- if (at >= 0)
- warningAt("Unsafe character.", line, at);
-
- if (option.maxlen && option.maxlen < s.length)
- warningAt("Line too long.", line, s.length);
- tw = option.trailing && s.match(/^(.*?)\s+$/);
- if (tw && !/^\s+$/.test(s)) {
- warningAt("Trailing whitespace.", line, tw[1].length + 1);
- }
- return true;
- }
-
- function it(type, value) {
- var i, t;
-
- function checkName(name) {
- if (!option.proto && name === "__proto__") {
- warningAt("The '{a}' property is deprecated.", line, from, name);
- return;
- }
-
- if (!option.iterator && name === "__iterator__") {
- warningAt("'{a}' is only available in JavaScript 1.7.", line, from, name);
- return;
- }
-
- var hasDangling = /^(_+.*|.*_+)$/.test(name);
-
- if (option.nomen && hasDangling && name !== "_") {
- if (option.node && token.id !== "." && /^(__dirname|__filename)$/.test(name))
- return;
-
- warningAt("Unexpected {a} in '{b}'.", line, from, "dangling '_'", name);
- return;
- }
-
- if (option.camelcase) {
- if (name.replace(/^_+/, "").indexOf("_") > -1 && !name.match(/^[A-Z0-9_]*$/)) {
- warningAt("Identifier '{a}' is not in camel case.", line, from, value);
- }
- }
- }
-
- if (type === "(color)" || type === "(range)") {
- t = {type: type};
- } else if (type === "(punctuator)" ||
- (type === "(identifier)" && is_own(syntax, value))) {
- t = syntax[value] || syntax["(error)"];
- } else {
- t = syntax[type];
- }
-
- t = Object.create(t);
-
- if (type === "(string)" || type === "(range)") {
- if (!option.scripturl && jx.test(value)) {
- warningAt("Script URL.", line, from);
- }
- }
-
- if (type === "(identifier)") {
- t.identifier = true;
- checkName(value);
- }
-
- t.value = value;
- t.line = line;
- t.character = character;
- t.from = from;
- i = t.id;
- if (i !== "(endline)") {
- prereg = i &&
- (("(,=:[!&|?{};".indexOf(i.charAt(i.length - 1)) >= 0) ||
- i === "return" ||
- i === "case");
- }
- return t;
- }
- return {
- init: function (source) {
- if (typeof source === "string") {
- lines = source
- .replace(/\r\n/g, "\n")
- .replace(/\r/g, "\n")
- .split("\n");
- } else {
- lines = source;
- }
- if (lines[0] && lines[0].substr(0, 2) === "#!")
- lines[0] = "";
-
- line = 0;
- nextLine();
- from = 1;
- },
-
- range: function (begin, end) {
- var c, value = "";
- from = character;
- if (s.charAt(0) !== begin) {
- errorAt("Expected '{a}' and instead saw '{b}'.",
- line, character, begin, s.charAt(0));
- }
- for (;;) {
- s = s.slice(1);
- character += 1;
- c = s.charAt(0);
- switch (c) {
- case "":
- errorAt("Missing '{a}'.", line, character, c);
- break;
- case end:
- s = s.slice(1);
- character += 1;
- return it("(range)", value);
- case "\\":
- warningAt("Unexpected '{a}'.", line, character, c);
- }
- value += c;
- }
-
- },
- token: function () {
- var b, c, captures, d, depth, high, i, l, low, q, t, isLiteral, isInRange, n;
-
- function match(x) {
- var r = x.exec(s), r1;
-
- if (r) {
- l = r[0].length;
- r1 = r[1];
- c = r1.charAt(0);
- s = s.substr(l);
- from = character + l - r1.length;
- character += l;
- return r1;
- }
- }
-
- function string(x) {
- var c, j, r = "", allowNewLine = false;
-
- if (jsonmode && x !== "\"") {
- warningAt("Strings must use doublequote.",
- line, character);
- }
-
- if (option.quotmark) {
- if (option.quotmark === "single" && x !== "'") {
- warningAt("Strings must use singlequote.",
- line, character);
- } else if (option.quotmark === "double" && x !== "\"") {
- warningAt("Strings must use doublequote.",
- line, character);
- } else if (option.quotmark === true) {
- quotmark = quotmark || x;
- if (quotmark !== x) {
- warningAt("Mixed double and single quotes.",
- line, character);
- }
- }
- }
-
- function esc(n) {
- var i = parseInt(s.substr(j + 1, n), 16);
- j += n;
- if (i >= 32 && i <= 126 &&
- i !== 34 && i !== 92 && i !== 39) {
- warningAt("Unnecessary escapement.", line, character);
- }
- character += n;
- c = String.fromCharCode(i);
- }
-
- j = 0;
-
-unclosedString:
- for (;;) {
- while (j >= s.length) {
- j = 0;
-
- var cl = line, cf = from;
- if (!nextLine()) {
- errorAt("Unclosed string.", cl, cf);
- break unclosedString;
- }
-
- if (allowNewLine) {
- allowNewLine = false;
- } else {
- warningAt("Unclosed string.", cl, cf);
- }
- }
-
- c = s.charAt(j);
- if (c === x) {
- character += 1;
- s = s.substr(j + 1);
- return it("(string)", r, x);
- }
-
- if (c < " ") {
- if (c === "\n" || c === "\r") {
- break;
- }
- warningAt("Control character in string: {a}.",
- line, character + j, s.slice(0, j));
- } else if (c === "\\") {
- j += 1;
- character += 1;
- c = s.charAt(j);
- n = s.charAt(j + 1);
- switch (c) {
- case "\\":
- case "\"":
- case "/":
- break;
- case "\'":
- if (jsonmode) {
- warningAt("Avoid \\'.", line, character);
- }
- break;
- case "b":
- c = "\b";
- break;
- case "f":
- c = "\f";
- break;
- case "n":
- c = "\n";
- break;
- case "r":
- c = "\r";
- break;
- case "t":
- c = "\t";
- break;
- case "0":
- c = "\0";
- if (n >= 0 && n <= 7 && directive["use strict"]) {
- warningAt(
- "Octal literals are not allowed in strict mode.",
- line, character);
- }
- break;
- case "u":
- esc(4);
- break;
- case "v":
- if (jsonmode) {
- warningAt("Avoid \\v.", line, character);
- }
- c = "\v";
- break;
- case "x":
- if (jsonmode) {
- warningAt("Avoid \\x-.", line, character);
- }
- esc(2);
- break;
- case "":
- allowNewLine = true;
- if (option.multistr) {
- if (jsonmode) {
- warningAt("Avoid EOL escapement.", line, character);
- }
- c = "";
- character -= 1;
- break;
- }
- warningAt("Bad escapement of EOL. Use option multistr if needed.",
- line, character);
- break;
- case "!":
- if (s.charAt(j - 2) === "<")
- break;
- default:
- warningAt("Bad escapement.", line, character);
- }
- }
- r += c;
- character += 1;
- j += 1;
- }
- }
-
- for (;;) {
- if (!s) {
- return it(nextLine() ? "(endline)" : "(end)", "");
- }
-
- t = match(tx);
-
- if (!t) {
- t = "";
- c = "";
- while (s && s < "!") {
- s = s.substr(1);
- }
- if (s) {
- errorAt("Unexpected '{a}'.", line, character, s.substr(0, 1));
- s = "";
- }
- } else {
-
- if (isAlpha(c) || c === "_" || c === "$") {
- return it("(identifier)", t);
- }
-
- if (isDigit(c)) {
- if (!isFinite(Number(t))) {
- warningAt("Bad number '{a}'.",
- line, character, t);
- }
- if (isAlpha(s.substr(0, 1))) {
- warningAt("Missing space after '{a}'.",
- line, character, t);
- }
- if (c === "0") {
- d = t.substr(1, 1);
- if (isDigit(d)) {
- if (token.id !== ".") {
- warningAt("Don't use extra leading zeros '{a}'.",
- line, character, t);
- }
- } else if (jsonmode && (d === "x" || d === "X")) {
- warningAt("Avoid 0x-. '{a}'.",
- line, character, t);
- }
- }
- if (t.substr(t.length - 1) === ".") {
- warningAt(
-"A trailing decimal point can be confused with a dot '{a}'.", line, character, t);
- }
- return it("(number)", t);
- }
- switch (t) {
-
- case "\"":
- case "'":
- return string(t);
-
- case "//":
- s = "";
- token.comment = true;
- break;
-
- case "/*":
- for (;;) {
- i = s.search(lx);
- if (i >= 0) {
- break;
- }
- if (!nextLine()) {
- errorAt("Unclosed comment.", line, character);
- }
- }
- s = s.substr(i + 2);
- token.comment = true;
- break;
-
- case "/*members":
- case "/*member":
- case "/*jshint":
- case "/*jslint":
- case "/*global":
- case "*/":
- return {
- value: t,
- type: "special",
- line: line,
- character: character,
- from: from
- };
-
- case "":
- break;
- case "/":
- if (s.charAt(0) === "=") {
- errorAt("A regular expression literal can be confused with '/='.",
- line, from);
- }
-
- if (prereg) {
- depth = 0;
- captures = 0;
- l = 0;
- for (;;) {
- b = true;
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case "":
- errorAt("Unclosed regular expression.", line, from);
- return quit("Stopping.", line, from);
- case "/":
- if (depth > 0) {
- warningAt("{a} unterminated regular expression " +
- "group(s).", line, from + l, depth);
- }
- c = s.substr(0, l - 1);
- q = {
- g: true,
- i: true,
- m: true
- };
- while (q[s.charAt(l)] === true) {
- q[s.charAt(l)] = false;
- l += 1;
- }
- character += l;
- s = s.substr(l);
- q = s.charAt(0);
- if (q === "/" || q === "*") {
- errorAt("Confusing regular expression.",
- line, from);
- }
- return it("(regexp)", c);
- case "\\":
- c = s.charAt(l);
- if (c < " ") {
- warningAt(
-"Unexpected control character in regular expression.", line, from + l);
- } else if (c === "<") {
- warningAt(
-"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
- break;
- case "(":
- depth += 1;
- b = false;
- if (s.charAt(l) === "?") {
- l += 1;
- switch (s.charAt(l)) {
- case ":":
- case "=":
- case "!":
- l += 1;
- break;
- default:
- warningAt(
-"Expected '{a}' and instead saw '{b}'.", line, from + l, ":", s.charAt(l));
- }
- } else {
- captures += 1;
- }
- break;
- case "|":
- b = false;
- break;
- case ")":
- if (depth === 0) {
- warningAt("Unescaped '{a}'.",
- line, from + l, ")");
- } else {
- depth -= 1;
- }
- break;
- case " ":
- q = 1;
- while (s.charAt(l) === " ") {
- l += 1;
- q += 1;
- }
- if (q > 1) {
- warningAt(
-"Spaces are hard to count. Use {{a}}.", line, from + l, q);
- }
- break;
- case "[":
- c = s.charAt(l);
- if (c === "^") {
- l += 1;
- if (s.charAt(l) === "]") {
- errorAt("Unescaped '{a}'.",
- line, from + l, "^");
- }
- }
- if (c === "]") {
- warningAt("Empty class.", line,
- from + l - 1);
- }
- isLiteral = false;
- isInRange = false;
-klass:
- do {
- c = s.charAt(l);
- l += 1;
- switch (c) {
- case "[":
- case "^":
- warningAt("Unescaped '{a}'.",
- line, from + l, c);
- if (isInRange) {
- isInRange = false;
- } else {
- isLiteral = true;
- }
- break;
- case "-":
- if (isLiteral && !isInRange) {
- isLiteral = false;
- isInRange = true;
- } else if (isInRange) {
- isInRange = false;
- } else if (s.charAt(l) === "]") {
- isInRange = true;
- } else {
- if (option.regexdash !== (l === 2 || (l === 3 &&
- s.charAt(1) === "^"))) {
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, "-");
- }
- isLiteral = true;
- }
- break;
- case "]":
- if (isInRange && !option.regexdash) {
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, "-");
- }
- break klass;
- case "\\":
- c = s.charAt(l);
- if (c < " ") {
- warningAt(
-"Unexpected control character in regular expression.", line, from + l);
- } else if (c === "<") {
- warningAt(
-"Unexpected escaped character '{a}' in regular expression.", line, from + l, c);
- }
- l += 1;
- if (/[wsd]/i.test(c)) {
- if (isInRange) {
- warningAt("Unescaped '{a}'.",
- line, from + l, "-");
- isInRange = false;
- }
- isLiteral = false;
- } else if (isInRange) {
- isInRange = false;
- } else {
- isLiteral = true;
- }
- break;
- case "/":
- warningAt("Unescaped '{a}'.",
- line, from + l - 1, "/");
-
- if (isInRange) {
- isInRange = false;
- } else {
- isLiteral = true;
- }
- break;
- case "<":
- if (isInRange) {
- isInRange = false;
- } else {
- isLiteral = true;
- }
- break;
- default:
- if (isInRange) {
- isInRange = false;
- } else {
- isLiteral = true;
- }
- }
- } while (c);
- break;
- case ".":
- if (option.regexp) {
- warningAt("Insecure '{a}'.", line,
- from + l, c);
- }
- break;
- case "]":
- case "?":
- case "{":
- case "}":
- case "+":
- case "*":
- warningAt("Unescaped '{a}'.", line,
- from + l, c);
- }
- if (b) {
- switch (s.charAt(l)) {
- case "?":
- case "+":
- case "*":
- l += 1;
- if (s.charAt(l) === "?") {
- l += 1;
- }
- break;
- case "{":
- l += 1;
- c = s.charAt(l);
- if (c < "0" || c > "9") {
- warningAt(
-"Expected a number and instead saw '{a}'.", line, from + l, c);
- break; // No reason to continue checking numbers.
- }
- l += 1;
- low = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < "0" || c > "9") {
- break;
- }
- l += 1;
- low = +c + (low * 10);
- }
- high = low;
- if (c === ",") {
- l += 1;
- high = Infinity;
- c = s.charAt(l);
- if (c >= "0" && c <= "9") {
- l += 1;
- high = +c;
- for (;;) {
- c = s.charAt(l);
- if (c < "0" || c > "9") {
- break;
- }
- l += 1;
- high = +c + (high * 10);
- }
- }
- }
- if (s.charAt(l) !== "}") {
- warningAt(
-"Expected '{a}' and instead saw '{b}'.", line, from + l, "}", c);
- } else {
- l += 1;
- }
- if (s.charAt(l) === "?") {
- l += 1;
- }
- if (low > high) {
- warningAt(
-"'{a}' should not be greater than '{b}'.", line, from + l, low, high);
- }
- }
- }
- }
- c = s.substr(0, l - 1);
- character += l;
- s = s.substr(l);
- return it("(regexp)", c);
- }
- return it("(punctuator)", t);
-
- case "#":
- return it("(punctuator)", t);
- default:
- return it("(punctuator)", t);
- }
- }
- }
- }
- };
- }());
-
-
- function addlabel(t, type, token) {
- if (t === "hasOwnProperty") {
- warning("'hasOwnProperty' is a really bad name.");
- }
- if (type === "exception") {
- if (is_own(funct["(context)"], t)) {
- if (funct[t] !== true && !option.node) {
- warning("Value of '{a}' may be overwritten in IE.", nexttoken, t);
- }
- }
- }
-
- if (is_own(funct, t) && !funct["(global)"]) {
- if (funct[t] === true) {
- if (option.latedef)
- warning("'{a}' was used before it was defined.", nexttoken, t);
- } else {
- if (!option.shadow && type !== "exception") {
- warning("'{a}' is already defined.", nexttoken, t);
- }
- }
- }
-
- funct[t] = type;
-
- if (token) {
- funct["(tokens)"][t] = token;
- }
-
- if (funct["(global)"]) {
- global[t] = funct;
- if (is_own(implied, t)) {
- if (option.latedef)
- warning("'{a}' was used before it was defined.", nexttoken, t);
- delete implied[t];
- }
- } else {
- scope[t] = funct;
- }
- }
-
-
- function doOption() {
- var nt = nexttoken;
- var o = nt.value;
- var quotmarkValue = option.quotmark;
- var predef = {};
- var b, obj, filter, t, tn, v, minus;
-
- switch (o) {
- case "*/":
- error("Unbegun comment.");
- break;
- case "/*members":
- case "/*member":
- o = "/*members";
- if (!membersOnly) {
- membersOnly = {};
- }
- obj = membersOnly;
- option.quotmark = false;
- break;
- case "/*jshint":
- case "/*jslint":
- obj = option;
- filter = boolOptions;
- break;
- case "/*global":
- obj = predef;
- break;
- default:
- error("What?");
- }
-
- t = lex.token();
-
-loop:
- for (;;) {
- minus = false;
- for (;;) {
- if (t.type === "special" && t.value === "*/") {
- break loop;
- }
- if (t.id !== "(endline)" && t.id !== ",") {
- break;
- }
- t = lex.token();
- }
-
- if (o === "/*global" && t.value === "-") {
- minus = true;
- t = lex.token();
- }
-
- if (t.type !== "(string)" && t.type !== "(identifier)" && o !== "/*members") {
- error("Bad option.", t);
- }
-
- v = lex.token();
- if (v.id === ":") {
- v = lex.token();
-
- if (obj === membersOnly) {
- error("Expected '{a}' and instead saw '{b}'.", t, "*/", ":");
- }
-
- if (o === "/*jshint") {
- checkOption(t.value, t);
- }
-
- var numericVals = [
- "maxstatements",
- "maxparams",
- "maxdepth",
- "maxcomplexity",
- "maxerr",
- "maxlen",
- "indent"
- ];
-
- if (numericVals.indexOf(t.value) > -1 && (o === "/*jshint" || o === "/*jslint")) {
- b = +v.value;
-
- if (typeof b !== "number" || !isFinite(b) || b <= 0 || Math.floor(b) !== b) {
- error("Expected a small integer and instead saw '{a}'.", v, v.value);
- }
-
- if (t.value === "indent")
- obj.white = true;
-
- obj[t.value] = b;
- } else if (t.value === "validthis") {
- if (funct["(global)"]) {
- error("Option 'validthis' can't be used in a global scope.");
- } else {
- if (v.value === "true" || v.value === "false")
- obj[t.value] = v.value === "true";
- else
- error("Bad option value.", v);
- }
- } else if (t.value === "quotmark" && (o === "/*jshint")) {
- switch (v.value) {
- case "true":
- obj.quotmark = true;
- break;
- case "false":
- obj.quotmark = false;
- break;
- case "double":
- case "single":
- obj.quotmark = v.value;
- break;
- default:
- error("Bad option value.", v);
- }
- } else if (v.value === "true" || v.value === "false") {
- if (o === "/*jslint") {
- tn = renamedOptions[t.value] || t.value;
- obj[tn] = v.value === "true";
- if (invertedOptions[tn] !== undefined) {
- obj[tn] = !obj[tn];
- }
- } else {
- obj[t.value] = v.value === "true";
- }
-
- if (t.value === "newcap")
- obj["(explicitNewcap)"] = true;
- } else {
- error("Bad option value.", v);
- }
- t = lex.token();
- } else {
- if (o === "/*jshint" || o === "/*jslint") {
- error("Missing option value.", t);
- }
-
- obj[t.value] = false;
-
- if (o === "/*global" && minus === true) {
- JSHINT.blacklist[t.value] = t.value;
- updatePredefined();
- }
-
- t = v;
- }
- }
-
- if (o === "/*members") {
- option.quotmark = quotmarkValue;
- }
-
- combine(predefined, predef);
-
- for (var key in predef) {
- if (is_own(predef, key)) {
- declared[key] = nt;
- }
- }
-
- if (filter) {
- assume();
- }
- }
-
- function peek(p) {
- var i = p || 0, j = 0, t;
-
- while (j <= i) {
- t = lookahead[j];
- if (!t) {
- t = lookahead[j] = lex.token();
- }
- j += 1;
- }
- return t;
- }
-
- function advance(id, t) {
- switch (token.id) {
- case "(number)":
- if (nexttoken.id === ".") {
- warning("A dot following a number can be confused with a decimal point.", token);
- }
- break;
- case "-":
- if (nexttoken.id === "-" || nexttoken.id === "--") {
- warning("Confusing minusses.");
- }
- break;
- case "+":
- if (nexttoken.id === "+" || nexttoken.id === "++") {
- warning("Confusing plusses.");
<