| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
(function() { |
| 38 |
|
| 39 |
var ACE_NAMESPACE = "ace"; |
| 40 |
|
| 41 |
var global = (function() { return this; })(); |
| 42 |
if (!global && typeof window != "undefined") global = window; |
| 43 |
|
| 44 |
|
| 45 |
if (!ACE_NAMESPACE && typeof requirejs !== "undefined") |
| 46 |
return; |
| 47 |
|
| 48 |
|
| 49 |
var define = function(module, deps, payload) { |
| 50 |
if (typeof module !== "string") { |
| 51 |
if (define.original) |
| 52 |
define.original.apply(this, arguments); |
| 53 |
else { |
| 54 |
console.error("dropping module because define wasn\'t a string."); |
| 55 |
console.trace(); |
| 56 |
} |
| 57 |
return; |
| 58 |
} |
| 59 |
if (arguments.length == 2) |
| 60 |
payload = deps; |
| 61 |
if (!define.modules[module]) { |
| 62 |
define.payloads[module] = payload; |
| 63 |
define.modules[module] = null; |
| 64 |
} |
| 65 |
}; |
| 66 |
|
| 67 |
define.modules = {}; |
| 68 |
define.payloads = {}; |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
var _require = function(parentId, module, callback) { |
| 74 |
if (typeof module === "string") { |
| 75 |
var payload = lookup(parentId, module); |
| 76 |
if (payload != undefined) { |
| 77 |
callback && callback(); |
| 78 |
return payload; |
| 79 |
} |
| 80 |
} else if (Object.prototype.toString.call(module) === "[object Array]") { |
| 81 |
var params = []; |
| 82 |
for (var i = 0, l = module.length; i < l; ++i) { |
| 83 |
var dep = lookup(parentId, module[i]); |
| 84 |
if (dep == undefined && require.original) |
| 85 |
return; |
| 86 |
params.push(dep); |
| 87 |
} |
| 88 |
return callback && callback.apply(null, params) || true; |
| 89 |
} |
| 90 |
}; |
| 91 |
|
| 92 |
var require = function(module, callback) { |
| 93 |
var packagedModule = _require("", module, callback); |
| 94 |
if (packagedModule == undefined && require.original) |
| 95 |
return require.original.apply(this, arguments); |
| 96 |
return packagedModule; |
| 97 |
}; |
| 98 |
|
| 99 |
var normalizeModule = function(parentId, moduleName) { |
| 100 |
|
| 101 |
if (moduleName.indexOf("!") !== -1) { |
| 102 |
var chunks = moduleName.split("!"); |
| 103 |
return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]); |
| 104 |
} |
| 105 |
|
| 106 |
if (moduleName.charAt(0) == ".") { |
| 107 |
var base = parentId.split("/").slice(0, -1).join("/"); |
| 108 |
moduleName = base + "/" + moduleName; |
| 109 |
|
| 110 |
while(moduleName.indexOf(".") !== -1 && previous != moduleName) { |
| 111 |
var previous = moduleName; |
| 112 |
moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, ""); |
| 113 |
} |
| 114 |
} |
| 115 |
return moduleName; |
| 116 |
}; |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
var lookup = function(parentId, moduleName) { |
| 123 |
moduleName = normalizeModule(parentId, moduleName); |
| 124 |
|
| 125 |
var module = define.modules[moduleName]; |
| 126 |
if (!module) { |
| 127 |
module = define.payloads[moduleName]; |
| 128 |
if (typeof module === 'function') { |
| 129 |
var exports = {}; |
| 130 |
var mod = { |
| 131 |
id: moduleName, |
| 132 |
uri: '', |
| 133 |
exports: exports, |
| 134 |
packaged: true |
| 135 |
}; |
| 136 |
|
| 137 |
var req = function(module, callback) { |
| 138 |
return _require(moduleName, module, callback); |
| 139 |
}; |
| 140 |
|
| 141 |
var returnValue = module(req, exports, mod); |
| 142 |
exports = returnValue || mod.exports; |
| 143 |
define.modules[moduleName] = exports; |
| 144 |
delete define.payloads[moduleName]; |
| 145 |
} |
| 146 |
module = define.modules[moduleName] = exports || module; |
| 147 |
} |
| 148 |
return module; |
| 149 |
}; |
| 150 |
|
| 151 |
function exportAce(ns) { |
| 152 |
var root = global; |
| 153 |
if (ns) { |
| 154 |
if (!global[ns]) |
| 155 |
global[ns] = {}; |
| 156 |
root = global[ns]; |
| 157 |
} |
| 158 |
|
| 159 |
if (!root.define || !root.define.packaged) { |
| 160 |
define.original = root.define; |
| 161 |
root.define = define; |
| 162 |
root.define.packaged = true; |
| 163 |
} |
| 164 |
|
| 165 |
if (!root.require || !root.require.packaged) { |
| 166 |
require.original = root.require; |
| 167 |
root.require = require; |
| 168 |
root.require.packaged = true; |
| 169 |
} |
| 170 |
} |
| 171 |
|
| 172 |
exportAce(ACE_NAMESPACE); |
| 173 |
|
| 174 |
})(); |
| 175 |
|
| 176 |
ace.define("ace/lib/es6-shim",["require","exports","module"], function(require, exports, module){function defineProp(obj, name, val) { |
| 177 |
Object.defineProperty(obj, name, { |
| 178 |
value: val, |
| 179 |
enumerable: false, |
| 180 |
writable: true, |
| 181 |
configurable: true |
| 182 |
}); |
| 183 |
} |
| 184 |
if (!String.prototype.startsWith) { |
| 185 |
defineProp(String.prototype, "startsWith", function (searchString, position) { |
| 186 |
position = position || 0; |
| 187 |
return this.lastIndexOf(searchString, position) === position; |
| 188 |
}); |
| 189 |
} |
| 190 |
if (!String.prototype.endsWith) { |
| 191 |
defineProp(String.prototype, "endsWith", function (searchString, position) { |
| 192 |
var subjectString = this; |
| 193 |
if (position === undefined || position > subjectString.length) { |
| 194 |
position = subjectString.length; |
| 195 |
} |
| 196 |
position -= searchString.length; |
| 197 |
var lastIndex = subjectString.indexOf(searchString, position); |
| 198 |
return lastIndex !== -1 && lastIndex === position; |
| 199 |
}); |
| 200 |
} |
| 201 |
if (!String.prototype.repeat) { |
| 202 |
defineProp(String.prototype, "repeat", function (count) { |
| 203 |
var result = ""; |
| 204 |
var string = this; |
| 205 |
while (count > 0) { |
| 206 |
if (count & 1) |
| 207 |
result += string; |
| 208 |
if ((count >>= 1)) |
| 209 |
string += string; |
| 210 |
} |
| 211 |
return result; |
| 212 |
}); |
| 213 |
} |
| 214 |
if (!String.prototype.includes) { |
| 215 |
defineProp(String.prototype, "includes", function (str, position) { |
| 216 |
return this.indexOf(str, position) != -1; |
| 217 |
}); |
| 218 |
} |
| 219 |
if (!Object.assign) { |
| 220 |
Object.assign = function (target) { |
| 221 |
if (target === undefined || target === null) { |
| 222 |
throw new TypeError("Cannot convert undefined or null to object"); |
| 223 |
} |
| 224 |
var output = Object(target); |
| 225 |
for (var index = 1; index < arguments.length; index++) { |
| 226 |
var source = arguments[index]; |
| 227 |
if (source !== undefined && source !== null) { |
| 228 |
Object.keys(source).forEach(function (key) { |
| 229 |
output[key] = source[key]; |
| 230 |
}); |
| 231 |
} |
| 232 |
} |
| 233 |
return output; |
| 234 |
}; |
| 235 |
} |
| 236 |
if (!Object.values) { |
| 237 |
Object.values = function (o) { |
| 238 |
return Object.keys(o).map(function (k) { |
| 239 |
return o[k]; |
| 240 |
}); |
| 241 |
}; |
| 242 |
} |
| 243 |
if (!Array.prototype.find) { |
| 244 |
defineProp(Array.prototype, "find", function (predicate) { |
| 245 |
var len = this.length; |
| 246 |
var thisArg = arguments[1]; |
| 247 |
for (var k = 0; k < len; k++) { |
| 248 |
var kValue = this[k]; |
| 249 |
if (predicate.call(thisArg, kValue, k, this)) { |
| 250 |
return kValue; |
| 251 |
} |
| 252 |
} |
| 253 |
}); |
| 254 |
} |
| 255 |
if (!Array.prototype.findIndex) { |
| 256 |
defineProp(Array.prototype, "findIndex", function (predicate) { |
| 257 |
var len = this.length; |
| 258 |
var thisArg = arguments[1]; |
| 259 |
for (var k = 0; k < len; k++) { |
| 260 |
var kValue = this[k]; |
| 261 |
if (predicate.call(thisArg, kValue, k, this)) { |
| 262 |
return k; |
| 263 |
} |
| 264 |
} |
| 265 |
}); |
| 266 |
} |
| 267 |
if (!Array.prototype.includes) { |
| 268 |
defineProp(Array.prototype, "includes", function (item, position) { |
| 269 |
return this.indexOf(item, position) != -1; |
| 270 |
}); |
| 271 |
} |
| 272 |
if (!Array.prototype.fill) { |
| 273 |
defineProp(Array.prototype, "fill", function (value) { |
| 274 |
var O = this; |
| 275 |
var len = O.length >>> 0; |
| 276 |
var start = arguments[1]; |
| 277 |
var relativeStart = start >> 0; |
| 278 |
var k = relativeStart < 0 |
| 279 |
? Math.max(len + relativeStart, 0) |
| 280 |
: Math.min(relativeStart, len); |
| 281 |
var end = arguments[2]; |
| 282 |
var relativeEnd = end === undefined ? len : end >> 0; |
| 283 |
var final = relativeEnd < 0 |
| 284 |
? Math.max(len + relativeEnd, 0) |
| 285 |
: Math.min(relativeEnd, len); |
| 286 |
while (k < final) { |
| 287 |
O[k] = value; |
| 288 |
k++; |
| 289 |
} |
| 290 |
return O; |
| 291 |
}); |
| 292 |
} |
| 293 |
if (!Array.of) { |
| 294 |
defineProp(Array, "of", function () { |
| 295 |
return Array.prototype.slice.call(arguments); |
| 296 |
}); |
| 297 |
} |
| 298 |
|
| 299 |
}); |
| 300 |
|
| 301 |
ace.define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/es6-shim"], function(require, exports, module){ |
| 302 |
"use strict"; |
| 303 |
require("./es6-shim"); |
| 304 |
|
| 305 |
}); |
| 306 |
|
| 307 |
ace.define("ace/lib/deep_copy",["require","exports","module"], function(require, exports, module){exports.deepCopy = function deepCopy(obj) { |
| 308 |
if (typeof obj !== "object" || !obj) |
| 309 |
return obj; |
| 310 |
var copy; |
| 311 |
if (Array.isArray(obj)) { |
| 312 |
copy = []; |
| 313 |
for (var key = 0; key < obj.length; key++) { |
| 314 |
copy[key] = deepCopy(obj[key]); |
| 315 |
} |
| 316 |
return copy; |
| 317 |
} |
| 318 |
if (Object.prototype.toString.call(obj) !== "[object Object]") |
| 319 |
return obj; |
| 320 |
copy = {}; |
| 321 |
for (var key in obj) |
| 322 |
copy[key] = deepCopy(obj[key]); |
| 323 |
return copy; |
| 324 |
}; |
| 325 |
|
| 326 |
}); |
| 327 |
|
| 328 |
ace.define("ace/lib/lang",["require","exports","module","ace/lib/deep_copy"], function(require, exports, module){"use strict"; |
| 329 |
exports.last = function (a) { |
| 330 |
return a[a.length - 1]; |
| 331 |
}; |
| 332 |
exports.stringReverse = function (string) { |
| 333 |
return string.split("").reverse().join(""); |
| 334 |
}; |
| 335 |
exports.stringRepeat = function (string, count) { |
| 336 |
var result = ''; |
| 337 |
while (count > 0) { |
| 338 |
if (count & 1) |
| 339 |
result += string; |
| 340 |
if (count >>= 1) |
| 341 |
string += string; |
| 342 |
} |
| 343 |
return result; |
| 344 |
}; |
| 345 |
var trimBeginRegexp = /^\s\s*/; |
| 346 |
var trimEndRegexp = /\s\s*$/; |
| 347 |
exports.stringTrimLeft = function (string) { |
| 348 |
return string.replace(trimBeginRegexp, ''); |
| 349 |
}; |
| 350 |
exports.stringTrimRight = function (string) { |
| 351 |
return string.replace(trimEndRegexp, ''); |
| 352 |
}; |
| 353 |
exports.copyObject = function (obj) { |
| 354 |
var copy = {}; |
| 355 |
for (var key in obj) { |
| 356 |
copy[key] = obj[key]; |
| 357 |
} |
| 358 |
return copy; |
| 359 |
}; |
| 360 |
exports.copyArray = function (array) { |
| 361 |
var copy = []; |
| 362 |
for (var i = 0, l = array.length; i < l; i++) { |
| 363 |
if (array[i] && typeof array[i] == "object") |
| 364 |
copy[i] = this.copyObject(array[i]); |
| 365 |
else |
| 366 |
copy[i] = array[i]; |
| 367 |
} |
| 368 |
return copy; |
| 369 |
}; |
| 370 |
exports.deepCopy = require("./deep_copy").deepCopy; |
| 371 |
exports.arrayToMap = function (arr) { |
| 372 |
var map = {}; |
| 373 |
for (var i = 0; i < arr.length; i++) { |
| 374 |
map[arr[i]] = 1; |
| 375 |
} |
| 376 |
return map; |
| 377 |
}; |
| 378 |
exports.createMap = function (props) { |
| 379 |
var map = Object.create(null); |
| 380 |
for (var i in props) { |
| 381 |
map[i] = props[i]; |
| 382 |
} |
| 383 |
return map; |
| 384 |
}; |
| 385 |
exports.arrayRemove = function (array, value) { |
| 386 |
for (var i = 0; i <= array.length; i++) { |
| 387 |
if (value === array[i]) { |
| 388 |
array.splice(i, 1); |
| 389 |
} |
| 390 |
} |
| 391 |
}; |
| 392 |
exports.escapeRegExp = function (str) { |
| 393 |
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1'); |
| 394 |
}; |
| 395 |
exports.escapeHTML = function (str) { |
| 396 |
return ("" + str).replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<"); |
| 397 |
}; |
| 398 |
exports.getMatchOffsets = function (string, regExp) { |
| 399 |
var matches = []; |
| 400 |
string.replace(regExp, function (str) { |
| 401 |
matches.push({ |
| 402 |
offset: arguments[arguments.length - 2], |
| 403 |
length: str.length |
| 404 |
}); |
| 405 |
}); |
| 406 |
return matches; |
| 407 |
}; |
| 408 |
exports.deferredCall = function (fcn) { |
| 409 |
var timer = null; |
| 410 |
var callback = function () { |
| 411 |
timer = null; |
| 412 |
fcn(); |
| 413 |
}; |
| 414 |
var deferred = function (timeout) { |
| 415 |
deferred.cancel(); |
| 416 |
timer = setTimeout(callback, timeout || 0); |
| 417 |
return deferred; |
| 418 |
}; |
| 419 |
deferred.schedule = deferred; |
| 420 |
deferred.call = function () { |
| 421 |
this.cancel(); |
| 422 |
fcn(); |
| 423 |
return deferred; |
| 424 |
}; |
| 425 |
deferred.cancel = function () { |
| 426 |
clearTimeout(timer); |
| 427 |
timer = null; |
| 428 |
return deferred; |
| 429 |
}; |
| 430 |
deferred.isPending = function () { |
| 431 |
return timer; |
| 432 |
}; |
| 433 |
return deferred; |
| 434 |
}; |
| 435 |
exports.delayedCall = function (fcn, defaultTimeout) { |
| 436 |
var timer = null; |
| 437 |
var callback = function () { |
| 438 |
timer = null; |
| 439 |
fcn(); |
| 440 |
}; |
| 441 |
var _self = function (timeout) { |
| 442 |
if (timer == null) |
| 443 |
timer = setTimeout(callback, timeout || defaultTimeout); |
| 444 |
}; |
| 445 |
_self.delay = function (timeout) { |
| 446 |
timer && clearTimeout(timer); |
| 447 |
timer = setTimeout(callback, timeout || defaultTimeout); |
| 448 |
}; |
| 449 |
_self.schedule = _self; |
| 450 |
_self.call = function () { |
| 451 |
this.cancel(); |
| 452 |
fcn(); |
| 453 |
}; |
| 454 |
_self.cancel = function () { |
| 455 |
timer && clearTimeout(timer); |
| 456 |
timer = null; |
| 457 |
}; |
| 458 |
_self.isPending = function () { |
| 459 |
return timer; |
| 460 |
}; |
| 461 |
return _self; |
| 462 |
}; |
| 463 |
exports.supportsLookbehind = function () { |
| 464 |
try { |
| 465 |
new RegExp('(?<=.)'); |
| 466 |
} |
| 467 |
catch (e) { |
| 468 |
return false; |
| 469 |
} |
| 470 |
return true; |
| 471 |
}; |
| 472 |
exports.skipEmptyMatch = function (line, last, supportsUnicodeFlag) { |
| 473 |
return supportsUnicodeFlag && line.codePointAt(last) > 0xffff ? 2 : 1; |
| 474 |
}; |
| 475 |
|
| 476 |
}); |
| 477 |
|
| 478 |
ace.define("ace/lib/useragent",["require","exports","module"], function(require, exports, module){"use strict"; |
| 479 |
exports.OS = { |
| 480 |
LINUX: "LINUX", |
| 481 |
MAC: "MAC", |
| 482 |
WINDOWS: "WINDOWS" |
| 483 |
}; |
| 484 |
exports.getOS = function () { |
| 485 |
if (exports.isMac) { |
| 486 |
return exports.OS.MAC; |
| 487 |
} |
| 488 |
else if (exports.isLinux) { |
| 489 |
return exports.OS.LINUX; |
| 490 |
} |
| 491 |
else { |
| 492 |
return exports.OS.WINDOWS; |
| 493 |
} |
| 494 |
}; |
| 495 |
var _navigator = typeof navigator == "object" ? navigator : {}; |
| 496 |
var os = (/mac|win|linux/i.exec(_navigator.platform) || ["other"])[0].toLowerCase(); |
| 497 |
var ua = _navigator.userAgent || ""; |
| 498 |
var appName = _navigator.appName || ""; |
| 499 |
exports.isWin = (os == "win"); |
| 500 |
exports.isMac = (os == "mac"); |
| 501 |
exports.isLinux = (os == "linux"); |
| 502 |
exports.isIE = |
| 503 |
(appName == "Microsoft Internet Explorer" || appName.indexOf("MSAppHost") >= 0) |
| 504 |
? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/) || [])[1]) |
| 505 |
: parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/) || [])[1]); |
| 506 |
exports.isOldIE = exports.isIE && exports.isIE < 9; |
| 507 |
exports.isGecko = exports.isMozilla = ua.match(/ Gecko\/\d+/); |
| 508 |
exports.isOpera = typeof opera == "object" && Object.prototype.toString.call(window["opera"]) == "[object Opera]"; |
| 509 |
exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined; |
| 510 |
exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined; |
| 511 |
exports.isSafari = parseFloat(ua.split(" Safari/")[1]) && !exports.isChrome || undefined; |
| 512 |
exports.isEdge = parseFloat(ua.split(" Edge/")[1]) || undefined; |
| 513 |
exports.isAIR = ua.indexOf("AdobeAIR") >= 0; |
| 514 |
exports.isAndroid = ua.indexOf("Android") >= 0; |
| 515 |
exports.isChromeOS = ua.indexOf(" CrOS ") >= 0; |
| 516 |
exports.isIOS = /iPad|iPhone|iPod/.test(ua) && !window["MSStream"]; |
| 517 |
if (exports.isIOS) |
| 518 |
exports.isMac = true; |
| 519 |
exports.isMobile = exports.isIOS || exports.isAndroid; |
| 520 |
|
| 521 |
}); |
| 522 |
|
| 523 |
ace.define("ace/lib/dom",["require","exports","module","ace/lib/useragent"], function(require, exports, module){"use strict"; |
| 524 |
var useragent = require("./useragent"); |
| 525 |
var XHTML_NS = "http://www.w3.org/1999/xhtml"; |
| 526 |
exports.buildDom = function buildDom(arr, parent, refs) { |
| 527 |
if (typeof arr == "string" && arr) { |
| 528 |
var txt = document.createTextNode(arr); |
| 529 |
if (parent) |
| 530 |
parent.appendChild(txt); |
| 531 |
return txt; |
| 532 |
} |
| 533 |
if (!Array.isArray(arr)) { |
| 534 |
if (arr && arr.appendChild && parent) |
| 535 |
parent.appendChild(arr); |
| 536 |
return arr; |
| 537 |
} |
| 538 |
if (typeof arr[0] != "string" || !arr[0]) { |
| 539 |
var els = []; |
| 540 |
for (var i = 0; i < arr.length; i++) { |
| 541 |
var ch = buildDom(arr[i], parent, refs); |
| 542 |
ch && els.push(ch); |
| 543 |
} |
| 544 |
return els; |
| 545 |
} |
| 546 |
var el = document.createElement(arr[0]); |
| 547 |
var options = arr[1]; |
| 548 |
var childIndex = 1; |
| 549 |
if (options && typeof options == "object" && !Array.isArray(options)) |
| 550 |
childIndex = 2; |
| 551 |
for (var i = childIndex; i < arr.length; i++) |
| 552 |
buildDom(arr[i], el, refs); |
| 553 |
if (childIndex == 2) { |
| 554 |
Object.keys(options).forEach(function (n) { |
| 555 |
var val = options[n]; |
| 556 |
if (n === "class") { |
| 557 |
el.className = Array.isArray(val) ? val.join(" ") : val; |
| 558 |
} |
| 559 |
else if (typeof val == "function" || n == "value" || n[0] == "$") { |
| 560 |
el[n] = val; |
| 561 |
} |
| 562 |
else if (n === "ref") { |
| 563 |
if (refs) |
| 564 |
refs[val] = el; |
| 565 |
} |
| 566 |
else if (n === "style") { |
| 567 |
if (typeof val == "string") |
| 568 |
el.style.cssText = val; |
| 569 |
} |
| 570 |
else if (val != null) { |
| 571 |
el.setAttribute(n, val); |
| 572 |
} |
| 573 |
}); |
| 574 |
} |
| 575 |
if (parent) |
| 576 |
parent.appendChild(el); |
| 577 |
return el; |
| 578 |
}; |
| 579 |
exports.getDocumentHead = function (doc) { |
| 580 |
if (!doc) |
| 581 |
doc = document; |
| 582 |
return doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement; |
| 583 |
}; |
| 584 |
exports.createElement = function (tag, ns) { |
| 585 |
return document.createElementNS ? |
| 586 |
document.createElementNS(ns || XHTML_NS, tag) : |
| 587 |
document.createElement(tag); |
| 588 |
}; |
| 589 |
exports.removeChildren = function (element) { |
| 590 |
element.innerHTML = ""; |
| 591 |
}; |
| 592 |
exports.createTextNode = function (textContent, element) { |
| 593 |
var doc = element ? element.ownerDocument : document; |
| 594 |
return doc.createTextNode(textContent); |
| 595 |
}; |
| 596 |
exports.createFragment = function (element) { |
| 597 |
var doc = element ? element.ownerDocument : document; |
| 598 |
return doc.createDocumentFragment(); |
| 599 |
}; |
| 600 |
exports.hasCssClass = function (el, name) { |
| 601 |
var classes = (el.className + "").split(/\s+/g); |
| 602 |
return classes.indexOf(name) !== -1; |
| 603 |
}; |
| 604 |
exports.addCssClass = function (el, name) { |
| 605 |
if (!exports.hasCssClass(el, name)) { |
| 606 |
el.className += " " + name; |
| 607 |
} |
| 608 |
}; |
| 609 |
exports.removeCssClass = function (el, name) { |
| 610 |
var classes = el.className.split(/\s+/g); |
| 611 |
while (true) { |
| 612 |
var index = classes.indexOf(name); |
| 613 |
if (index == -1) { |
| 614 |
break; |
| 615 |
} |
| 616 |
classes.splice(index, 1); |
| 617 |
} |
| 618 |
el.className = classes.join(" "); |
| 619 |
}; |
| 620 |
exports.toggleCssClass = function (el, name) { |
| 621 |
var classes = el.className.split(/\s+/g), add = true; |
| 622 |
while (true) { |
| 623 |
var index = classes.indexOf(name); |
| 624 |
if (index == -1) { |
| 625 |
break; |
| 626 |
} |
| 627 |
add = false; |
| 628 |
classes.splice(index, 1); |
| 629 |
} |
| 630 |
if (add) |
| 631 |
classes.push(name); |
| 632 |
el.className = classes.join(" "); |
| 633 |
return add; |
| 634 |
}; |
| 635 |
exports.setCssClass = function (node, className, include) { |
| 636 |
if (include) { |
| 637 |
exports.addCssClass(node, className); |
| 638 |
} |
| 639 |
else { |
| 640 |
exports.removeCssClass(node, className); |
| 641 |
} |
| 642 |
}; |
| 643 |
exports.hasCssString = function (id, doc) { |
| 644 |
var index = 0, sheets; |
| 645 |
doc = doc || document; |
| 646 |
if ((sheets = doc.querySelectorAll("style"))) { |
| 647 |
while (index < sheets.length) { |
| 648 |
if (sheets[index++].id === id) { |
| 649 |
return true; |
| 650 |
} |
| 651 |
} |
| 652 |
} |
| 653 |
}; |
| 654 |
exports.removeElementById = function (id, doc) { |
| 655 |
doc = doc || document; |
| 656 |
if (doc.getElementById(id)) { |
| 657 |
doc.getElementById(id).remove(); |
| 658 |
} |
| 659 |
}; |
| 660 |
var strictCSP; |
| 661 |
var cssCache = []; |
| 662 |
exports.useStrictCSP = function (value) { |
| 663 |
strictCSP = value; |
| 664 |
if (value == false) |
| 665 |
insertPendingStyles(); |
| 666 |
else if (!cssCache) |
| 667 |
cssCache = []; |
| 668 |
}; |
| 669 |
function insertPendingStyles() { |
| 670 |
var cache = cssCache; |
| 671 |
cssCache = null; |
| 672 |
cache && cache.forEach(function (item) { |
| 673 |
importCssString(item[0], item[1]); |
| 674 |
}); |
| 675 |
} |
| 676 |
function importCssString(cssText, id, target) { |
| 677 |
if (typeof document == "undefined") |
| 678 |
return; |
| 679 |
if (cssCache) { |
| 680 |
if (target) { |
| 681 |
insertPendingStyles(); |
| 682 |
} |
| 683 |
else if (target === false) { |
| 684 |
return cssCache.push([cssText, id]); |
| 685 |
} |
| 686 |
} |
| 687 |
if (strictCSP) |
| 688 |
return; |
| 689 |
var container = target; |
| 690 |
if (!target || !target.getRootNode) { |
| 691 |
container = document; |
| 692 |
} |
| 693 |
else { |
| 694 |
container = target.getRootNode(); |
| 695 |
if (!container || container == target) |
| 696 |
container = document; |
| 697 |
} |
| 698 |
var doc = container.ownerDocument || container; |
| 699 |
if (id && exports.hasCssString(id, container)) |
| 700 |
return null; |
| 701 |
if (id) |
| 702 |
cssText += "\n/*# sourceURL=ace/css/" + id + " */"; |
| 703 |
var style = exports.createElement("style"); |
| 704 |
style.appendChild(doc.createTextNode(cssText)); |
| 705 |
if (id) |
| 706 |
style.id = id; |
| 707 |
if (container == doc) |
| 708 |
container = exports.getDocumentHead(doc); |
| 709 |
container.insertBefore(style, container.firstChild); |
| 710 |
} |
| 711 |
exports.importCssString = importCssString; |
| 712 |
exports.importCssStylsheet = function (uri, doc) { |
| 713 |
exports.buildDom(["link", { rel: "stylesheet", href: uri }], exports.getDocumentHead(doc)); |
| 714 |
}; |
| 715 |
exports.scrollbarWidth = function (doc) { |
| 716 |
var inner = exports.createElement("ace_inner"); |
| 717 |
inner.style.width = "100%"; |
| 718 |
inner.style.minWidth = "0px"; |
| 719 |
inner.style.height = "200px"; |
| 720 |
inner.style.display = "block"; |
| 721 |
var outer = exports.createElement("ace_outer"); |
| 722 |
var style = outer.style; |
| 723 |
style.position = "absolute"; |
| 724 |
style.left = "-10000px"; |
| 725 |
style.overflow = "hidden"; |
| 726 |
style.width = "200px"; |
| 727 |
style.minWidth = "0px"; |
| 728 |
style.height = "150px"; |
| 729 |
style.display = "block"; |
| 730 |
outer.appendChild(inner); |
| 731 |
var body = (doc && doc.documentElement) || (document && document.documentElement); |
| 732 |
if (!body) |
| 733 |
return 0; |
| 734 |
body.appendChild(outer); |
| 735 |
var noScrollbar = inner.offsetWidth; |
| 736 |
style.overflow = "scroll"; |
| 737 |
var withScrollbar = inner.offsetWidth; |
| 738 |
if (noScrollbar === withScrollbar) { |
| 739 |
withScrollbar = outer.clientWidth; |
| 740 |
} |
| 741 |
body.removeChild(outer); |
| 742 |
return noScrollbar - withScrollbar; |
| 743 |
}; |
| 744 |
exports.computedStyle = function (element, style) { |
| 745 |
return window.getComputedStyle(element, "") || {}; |
| 746 |
}; |
| 747 |
exports.setStyle = function (styles, property, value) { |
| 748 |
if (styles[property] !== value) { |
| 749 |
styles[property] = value; |
| 750 |
} |
| 751 |
}; |
| 752 |
exports.HAS_CSS_ANIMATION = false; |
| 753 |
exports.HAS_CSS_TRANSFORMS = false; |
| 754 |
exports.HI_DPI = useragent.isWin |
| 755 |
? typeof window !== "undefined" && window.devicePixelRatio >= 1.5 |
| 756 |
: true; |
| 757 |
if (useragent.isChromeOS) |
| 758 |
exports.HI_DPI = false; |
| 759 |
if (typeof document !== "undefined") { |
| 760 |
var div = document.createElement("div"); |
| 761 |
if (exports.HI_DPI && div.style.transform !== undefined) |
| 762 |
exports.HAS_CSS_TRANSFORMS = true; |
| 763 |
if (!useragent.isEdge && typeof div.style.animationName !== "undefined") |
| 764 |
exports.HAS_CSS_ANIMATION = true; |
| 765 |
div = null; |
| 766 |
} |
| 767 |
if (exports.HAS_CSS_TRANSFORMS) { |
| 768 |
exports.translate = function (element, tx, ty) { |
| 769 |
element.style.transform = "translate(" + Math.round(tx) + "px, " + Math.round(ty) + "px)"; |
| 770 |
}; |
| 771 |
} |
| 772 |
else { |
| 773 |
exports.translate = function (element, tx, ty) { |
| 774 |
element.style.top = Math.round(ty) + "px"; |
| 775 |
element.style.left = Math.round(tx) + "px"; |
| 776 |
}; |
| 777 |
} |
| 778 |
|
| 779 |
}); |
| 780 |
|
| 781 |
ace.define("ace/lib/net",["require","exports","module","ace/lib/dom"], function(require, exports, module){ |
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
"use strict"; |
| 789 |
var dom = require("./dom"); |
| 790 |
exports.get = function (url, callback) { |
| 791 |
var xhr = new XMLHttpRequest(); |
| 792 |
xhr.open('GET', url, true); |
| 793 |
xhr.onreadystatechange = function () { |
| 794 |
if (xhr.readyState === 4) { |
| 795 |
callback(xhr.responseText); |
| 796 |
} |
| 797 |
}; |
| 798 |
xhr.send(null); |
| 799 |
}; |
| 800 |
exports.loadScript = function (path, callback) { |
| 801 |
var head = dom.getDocumentHead(); |
| 802 |
var s = document.createElement('script'); |
| 803 |
s.src = path; |
| 804 |
head.appendChild(s); |
| 805 |
s.onload = s.onreadystatechange = function (_, isAbort) { |
| 806 |
if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") { |
| 807 |
s = s.onload = s.onreadystatechange = null; |
| 808 |
if (!isAbort) |
| 809 |
callback(); |
| 810 |
} |
| 811 |
}; |
| 812 |
}; |
| 813 |
exports.qualifyURL = function (url) { |
| 814 |
var a = document.createElement('a'); |
| 815 |
a.href = url; |
| 816 |
return a.href; |
| 817 |
}; |
| 818 |
|
| 819 |
}); |
| 820 |
|
| 821 |
ace.define("ace/lib/oop",["require","exports","module"], function(require, exports, module){"use strict"; |
| 822 |
exports.inherits = function (ctor, superCtor) { |
| 823 |
ctor.super_ = superCtor; |
| 824 |
ctor.prototype = Object.create(superCtor.prototype, { |
| 825 |
constructor: { |
| 826 |
value: ctor, |
| 827 |
enumerable: false, |
| 828 |
writable: true, |
| 829 |
configurable: true |
| 830 |
} |
| 831 |
}); |
| 832 |
}; |
| 833 |
exports.mixin = function (obj, mixin) { |
| 834 |
for (var key in mixin) { |
| 835 |
obj[key] = mixin[key]; |
| 836 |
} |
| 837 |
return obj; |
| 838 |
}; |
| 839 |
exports.implement = function (proto, mixin) { |
| 840 |
exports.mixin(proto, mixin); |
| 841 |
}; |
| 842 |
|
| 843 |
}); |
| 844 |
|
| 845 |
ace.define("ace/lib/event_emitter",["require","exports","module"], function(require, exports, module){"use strict"; |
| 846 |
var EventEmitter = {}; |
| 847 |
var stopPropagation = function () { this.propagationStopped = true; }; |
| 848 |
var preventDefault = function () { this.defaultPrevented = true; }; |
| 849 |
EventEmitter._emit = |
| 850 |
EventEmitter._dispatchEvent = function (eventName, e) { |
| 851 |
this._eventRegistry || (this._eventRegistry = {}); |
| 852 |
this._defaultHandlers || (this._defaultHandlers = {}); |
| 853 |
var listeners = this._eventRegistry[eventName] || []; |
| 854 |
var defaultHandler = this._defaultHandlers[eventName]; |
| 855 |
if (!listeners.length && !defaultHandler) |
| 856 |
return; |
| 857 |
if (typeof e != "object" || !e) |
| 858 |
e = {}; |
| 859 |
if (!e.type) |
| 860 |
e.type = eventName; |
| 861 |
if (!e.stopPropagation) |
| 862 |
e.stopPropagation = stopPropagation; |
| 863 |
if (!e.preventDefault) |
| 864 |
e.preventDefault = preventDefault; |
| 865 |
listeners = listeners.slice(); |
| 866 |
for (var i = 0; i < listeners.length; i++) { |
| 867 |
listeners[i](e, this); |
| 868 |
if (e.propagationStopped) |
| 869 |
break; |
| 870 |
} |
| 871 |
if (defaultHandler && !e.defaultPrevented) |
| 872 |
return defaultHandler(e, this); |
| 873 |
}; |
| 874 |
EventEmitter._signal = function (eventName, e) { |
| 875 |
var listeners = (this._eventRegistry || {})[eventName]; |
| 876 |
if (!listeners) |
| 877 |
return; |
| 878 |
listeners = listeners.slice(); |
| 879 |
for (var i = 0; i < listeners.length; i++) |
| 880 |
listeners[i](e, this); |
| 881 |
}; |
| 882 |
EventEmitter.once = function (eventName, callback) { |
| 883 |
var _self = this; |
| 884 |
this.on(eventName, function newCallback() { |
| 885 |
_self.off(eventName, newCallback); |
| 886 |
callback.apply(null, arguments); |
| 887 |
}); |
| 888 |
if (!callback) { |
| 889 |
return new Promise(function (resolve) { |
| 890 |
callback = resolve; |
| 891 |
}); |
| 892 |
} |
| 893 |
}; |
| 894 |
EventEmitter.setDefaultHandler = function (eventName, callback) { |
| 895 |
var handlers = this._defaultHandlers; |
| 896 |
if (!handlers) |
| 897 |
handlers = this._defaultHandlers = { _disabled_: {} }; |
| 898 |
if (handlers[eventName]) { |
| 899 |
var old = handlers[eventName]; |
| 900 |
var disabled = handlers._disabled_[eventName]; |
| 901 |
if (!disabled) |
| 902 |
handlers._disabled_[eventName] = disabled = []; |
| 903 |
disabled.push(old); |
| 904 |
var i = disabled.indexOf(callback); |
| 905 |
if (i != -1) |
| 906 |
disabled.splice(i, 1); |
| 907 |
} |
| 908 |
handlers[eventName] = callback; |
| 909 |
}; |
| 910 |
EventEmitter.removeDefaultHandler = function (eventName, callback) { |
| 911 |
var handlers = this._defaultHandlers; |
| 912 |
if (!handlers) |
| 913 |
return; |
| 914 |
var disabled = handlers._disabled_[eventName]; |
| 915 |
if (handlers[eventName] == callback) { |
| 916 |
if (disabled) |
| 917 |
this.setDefaultHandler(eventName, disabled.pop()); |
| 918 |
} |
| 919 |
else if (disabled) { |
| 920 |
var i = disabled.indexOf(callback); |
| 921 |
if (i != -1) |
| 922 |
disabled.splice(i, 1); |
| 923 |
} |
| 924 |
}; |
| 925 |
EventEmitter.on = |
| 926 |
EventEmitter.addEventListener = function (eventName, callback, capturing) { |
| 927 |
this._eventRegistry = this._eventRegistry || {}; |
| 928 |
var listeners = this._eventRegistry[eventName]; |
| 929 |
if (!listeners) |
| 930 |
listeners = this._eventRegistry[eventName] = []; |
| 931 |
if (listeners.indexOf(callback) == -1) |
| 932 |
listeners[capturing ? "unshift" : "push"](callback); |
| 933 |
return callback; |
| 934 |
}; |
| 935 |
EventEmitter.off = |
| 936 |
EventEmitter.removeListener = |
| 937 |
EventEmitter.removeEventListener = function (eventName, callback) { |
| 938 |
this._eventRegistry = this._eventRegistry || {}; |
| 939 |
var listeners = this._eventRegistry[eventName]; |
| 940 |
if (!listeners) |
| 941 |
return; |
| 942 |
var index = listeners.indexOf(callback); |
| 943 |
if (index !== -1) |
| 944 |
listeners.splice(index, 1); |
| 945 |
}; |
| 946 |
EventEmitter.removeAllListeners = function (eventName) { |
| 947 |
if (!eventName) |
| 948 |
this._eventRegistry = this._defaultHandlers = undefined; |
| 949 |
if (this._eventRegistry) |
| 950 |
this._eventRegistry[eventName] = undefined; |
| 951 |
if (this._defaultHandlers) |
| 952 |
this._defaultHandlers[eventName] = undefined; |
| 953 |
}; |
| 954 |
exports.EventEmitter = EventEmitter; |
| 955 |
|
| 956 |
}); |
| 957 |
|
| 958 |
ace.define("ace/lib/report_error",["require","exports","module"], function(require, exports, module){exports.reportError = function reportError(msg, data) { |
| 959 |
var e = new Error(msg); |
| 960 |
e["data"] = data; |
| 961 |
if (typeof console == "object" && console.error) |
| 962 |
console.error(e); |
| 963 |
setTimeout(function () { throw e; }); |
| 964 |
}; |
| 965 |
|
| 966 |
}); |
| 967 |
|
| 968 |
ace.define("ace/lib/app_config",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/lib/report_error"], function(require, exports, module){"no use strict"; |
| 969 |
var oop = require("./oop"); |
| 970 |
var EventEmitter = require("./event_emitter").EventEmitter; |
| 971 |
var reportError = require("./report_error").reportError; |
| 972 |
var optionsProvider = { |
| 973 |
setOptions: function (optList) { |
| 974 |
Object.keys(optList).forEach(function (key) { |
| 975 |
this.setOption(key, optList[key]); |
| 976 |
}, this); |
| 977 |
}, |
| 978 |
getOptions: function (optionNames) { |
| 979 |
var result = {}; |
| 980 |
if (!optionNames) { |
| 981 |
var options = this.$options; |
| 982 |
optionNames = Object.keys(options).filter(function (key) { |
| 983 |
return !options[key].hidden; |
| 984 |
}); |
| 985 |
} |
| 986 |
else if (!Array.isArray(optionNames)) { |
| 987 |
result = optionNames; |
| 988 |
optionNames = Object.keys(result); |
| 989 |
} |
| 990 |
optionNames.forEach(function (key) { |
| 991 |
result[key] = this.getOption(key); |
| 992 |
}, this); |
| 993 |
return result; |
| 994 |
}, |
| 995 |
setOption: function (name, value) { |
| 996 |
if (this["$" + name] === value) |
| 997 |
return; |
| 998 |
var opt = this.$options[name]; |
| 999 |
if (!opt) { |
| 1000 |
return warn('misspelled option "' + name + '"'); |
| 1001 |
} |
| 1002 |
if (opt.forwardTo) |
| 1003 |
return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value); |
| 1004 |
if (!opt.handlesSet) |
| 1005 |
this["$" + name] = value; |
| 1006 |
if (opt && opt.set) |
| 1007 |
opt.set.call(this, value); |
| 1008 |
}, |
| 1009 |
getOption: function (name) { |
| 1010 |
var opt = this.$options[name]; |
| 1011 |
if (!opt) { |
| 1012 |
return warn('misspelled option "' + name + '"'); |
| 1013 |
} |
| 1014 |
if (opt.forwardTo) |
| 1015 |
return this[opt.forwardTo] && this[opt.forwardTo].getOption(name); |
| 1016 |
return opt && opt.get ? opt.get.call(this) : this["$" + name]; |
| 1017 |
} |
| 1018 |
}; |
| 1019 |
function warn(message) { |
| 1020 |
if (typeof console != "undefined" && console.warn) |
| 1021 |
console.warn.apply(console, arguments); |
| 1022 |
} |
| 1023 |
var messages; |
| 1024 |
var AppConfig = (function () { |
| 1025 |
function AppConfig() { |
| 1026 |
this.$defaultOptions = {}; |
| 1027 |
} |
| 1028 |
AppConfig.prototype.defineOptions = function (obj, path, options) { |
| 1029 |
if (!obj.$options) |
| 1030 |
this.$defaultOptions[path] = obj.$options = {}; |
| 1031 |
Object.keys(options).forEach(function (key) { |
| 1032 |
var opt = options[key]; |
| 1033 |
if (typeof opt == "string") |
| 1034 |
opt = { forwardTo: opt }; |
| 1035 |
opt.name || (opt.name = key); |
| 1036 |
obj.$options[opt.name] = opt; |
| 1037 |
if ("initialValue" in opt) |
| 1038 |
obj["$" + opt.name] = opt.initialValue; |
| 1039 |
}); |
| 1040 |
oop.implement(obj, optionsProvider); |
| 1041 |
return this; |
| 1042 |
}; |
| 1043 |
AppConfig.prototype.resetOptions = function (obj) { |
| 1044 |
Object.keys(obj.$options).forEach(function (key) { |
| 1045 |
var opt = obj.$options[key]; |
| 1046 |
if ("value" in opt) |
| 1047 |
obj.setOption(key, opt.value); |
| 1048 |
}); |
| 1049 |
}; |
| 1050 |
AppConfig.prototype.setDefaultValue = function (path, name, value) { |
| 1051 |
if (!path) { |
| 1052 |
for (path in this.$defaultOptions) |
| 1053 |
if (this.$defaultOptions[path][name]) |
| 1054 |
break; |
| 1055 |
if (!this.$defaultOptions[path][name]) |
| 1056 |
return false; |
| 1057 |
} |
| 1058 |
var opts = this.$defaultOptions[path] || (this.$defaultOptions[path] = {}); |
| 1059 |
if (opts[name]) { |
| 1060 |
if (opts.forwardTo) |
| 1061 |
this.setDefaultValue(opts.forwardTo, name, value); |
| 1062 |
else |
| 1063 |
opts[name].value = value; |
| 1064 |
} |
| 1065 |
}; |
| 1066 |
AppConfig.prototype.setDefaultValues = function (path, optionHash) { |
| 1067 |
Object.keys(optionHash).forEach(function (key) { |
| 1068 |
this.setDefaultValue(path, key, optionHash[key]); |
| 1069 |
}, this); |
| 1070 |
}; |
| 1071 |
AppConfig.prototype.setMessages = function (value) { |
| 1072 |
messages = value; |
| 1073 |
}; |
| 1074 |
AppConfig.prototype.nls = function (string, params) { |
| 1075 |
if (messages && !messages[string]) { |
| 1076 |
warn("No message found for '" + string + "' in the provided messages, falling back to default English message."); |
| 1077 |
} |
| 1078 |
var translated = messages && messages[string] || string; |
| 1079 |
if (params) { |
| 1080 |
translated = translated.replace(/\$(\$|[\d]+)/g, function (_, name) { |
| 1081 |
if (name == "$") |
| 1082 |
return "$"; |
| 1083 |
return params[name]; |
| 1084 |
}); |
| 1085 |
} |
| 1086 |
return translated; |
| 1087 |
}; |
| 1088 |
return AppConfig; |
| 1089 |
}()); |
| 1090 |
AppConfig.prototype.warn = warn; |
| 1091 |
AppConfig.prototype.reportError = reportError; |
| 1092 |
oop.implement(AppConfig.prototype, EventEmitter); |
| 1093 |
exports.AppConfig = AppConfig; |
| 1094 |
|
| 1095 |
}); |
| 1096 |
|
| 1097 |
ace.define("ace/theme/textmate-css",["require","exports","module"], function(require, exports, module){module.exports = ".ace-tm .ace_gutter {\n background: #f0f0f0;\n color: #333;\n}\n\n.ace-tm .ace_print-margin {\n width: 1px;\n background: #e8e8e8;\n}\n\n.ace-tm .ace_fold {\n background-color: #6B72E6;\n}\n\n.ace-tm {\n background-color: #FFFFFF;\n color: black;\n}\n\n.ace-tm .ace_cursor {\n color: black;\n}\n \n.ace-tm .ace_invisible {\n color: rgb(191, 191, 191);\n}\n\n.ace-tm .ace_storage,\n.ace-tm .ace_keyword {\n color: blue;\n}\n\n.ace-tm .ace_constant {\n color: rgb(197, 6, 11);\n}\n\n.ace-tm .ace_constant.ace_buildin {\n color: rgb(88, 72, 246);\n}\n\n.ace-tm .ace_constant.ace_language {\n color: rgb(88, 92, 246);\n}\n\n.ace-tm .ace_constant.ace_library {\n color: rgb(6, 150, 14);\n}\n\n.ace-tm .ace_invalid {\n background-color: rgba(255, 0, 0, 0.1);\n color: red;\n}\n\n.ace-tm .ace_support.ace_function {\n color: rgb(60, 76, 114);\n}\n\n.ace-tm .ace_support.ace_constant {\n color: rgb(6, 150, 14);\n}\n\n.ace-tm .ace_support.ace_type,\n.ace-tm .ace_support.ace_class {\n color: rgb(109, 121, 222);\n}\n\n.ace-tm .ace_keyword.ace_operator {\n color: rgb(104, 118, 135);\n}\n\n.ace-tm .ace_string {\n color: rgb(3, 106, 7);\n}\n\n.ace-tm .ace_comment {\n color: rgb(76, 136, 107);\n}\n\n.ace-tm .ace_comment.ace_doc {\n color: rgb(0, 102, 255);\n}\n\n.ace-tm .ace_comment.ace_doc.ace_tag {\n color: rgb(128, 159, 191);\n}\n\n.ace-tm .ace_constant.ace_numeric {\n color: rgb(0, 0, 205);\n}\n\n.ace-tm .ace_variable {\n color: rgb(49, 132, 149);\n}\n\n.ace-tm .ace_xml-pe {\n color: rgb(104, 104, 91);\n}\n\n.ace-tm .ace_entity.ace_name.ace_function {\n color: #0000A2;\n}\n\n\n.ace-tm .ace_heading {\n color: rgb(12, 7, 255);\n}\n\n.ace-tm .ace_list {\n color:rgb(185, 6, 144);\n}\n\n.ace-tm .ace_meta.ace_tag {\n color:rgb(0, 22, 142);\n}\n\n.ace-tm .ace_string.ace_regex {\n color: rgb(255, 0, 0)\n}\n\n.ace-tm .ace_marker-layer .ace_selection {\n background: rgb(181, 213, 255);\n}\n.ace-tm.ace_multiselect .ace_selection.ace_start {\n box-shadow: 0 0 3px 0px white;\n}\n.ace-tm .ace_marker-layer .ace_step {\n background: rgb(252, 255, 0);\n}\n\n.ace-tm .ace_marker-layer .ace_stack {\n background: rgb(164, 229, 101);\n}\n\n.ace-tm .ace_marker-layer .ace_bracket {\n margin: -1px 0 0 -1px;\n border: 1px solid rgb(192, 192, 192);\n}\n\n.ace-tm .ace_marker-layer .ace_active-line {\n background: rgba(0, 0, 0, 0.07);\n}\n\n.ace-tm .ace_gutter-active-line {\n background-color : #dcdcdc;\n}\n\n.ace-tm .ace_marker-layer .ace_selected-word {\n background: rgb(250, 250, 255);\n border: 1px solid rgb(200, 200, 250);\n}\n\n.ace-tm .ace_indent-guide {\n background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\n}\n\n.ace-tm .ace_indent-guide-active {\n background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAAZSURBVHjaYvj///9/hivKyv8BAAAA//8DACLqBhbvk+/eAAAAAElFTkSuQmCC\") right repeat-y;\n}\n"; |
| 1098 |
|
| 1099 |
}); |
| 1100 |
|
| 1101 |
ace.define("ace/theme/textmate",["require","exports","module","ace/theme/textmate-css","ace/lib/dom"], function(require, exports, module){"use strict"; |
| 1102 |
exports.isDark = false; |
| 1103 |
exports.cssClass = "ace-tm"; |
| 1104 |
exports.cssText = require("./textmate-css"); |
| 1105 |
exports.$id = "ace/theme/textmate"; |
| 1106 |
var dom = require("../lib/dom"); |
| 1107 |
dom.importCssString(exports.cssText, exports.cssClass, false); |
| 1108 |
|
| 1109 |
}); |
| 1110 |
|
| 1111 |
ace.define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/net","ace/lib/dom","ace/lib/app_config","ace/theme/textmate"], function(require, exports, module){"no use strict"; |
| 1112 |
var lang = require("./lib/lang"); |
| 1113 |
var net = require("./lib/net"); |
| 1114 |
var dom = require("./lib/dom"); |
| 1115 |
var AppConfig = require("./lib/app_config").AppConfig; |
| 1116 |
module.exports = exports = new AppConfig(); |
| 1117 |
var options = { |
| 1118 |
packaged: false, |
| 1119 |
workerPath: null, |
| 1120 |
modePath: null, |
| 1121 |
themePath: null, |
| 1122 |
basePath: "", |
| 1123 |
suffix: ".js", |
| 1124 |
$moduleUrls: {}, |
| 1125 |
loadWorkerFromBlob: true, |
| 1126 |
sharedPopups: false, |
| 1127 |
useStrictCSP: null |
| 1128 |
}; |
| 1129 |
exports.get = function (key) { |
| 1130 |
if (!options.hasOwnProperty(key)) |
| 1131 |
throw new Error("Unknown config key: " + key); |
| 1132 |
return options[key]; |
| 1133 |
}; |
| 1134 |
exports.set = function (key, value) { |
| 1135 |
if (options.hasOwnProperty(key)) |
| 1136 |
options[key] = value; |
| 1137 |
else if (this.setDefaultValue("", key, value) == false) |
| 1138 |
throw new Error("Unknown config key: " + key); |
| 1139 |
if (key == "useStrictCSP") |
| 1140 |
dom.useStrictCSP(value); |
| 1141 |
}; |
| 1142 |
exports.all = function () { |
| 1143 |
return lang.copyObject(options); |
| 1144 |
}; |
| 1145 |
exports.$modes = {}; |
| 1146 |
exports.moduleUrl = function (name, component) { |
| 1147 |
if (options.$moduleUrls[name]) |
| 1148 |
return options.$moduleUrls[name]; |
| 1149 |
var parts = name.split("/"); |
| 1150 |
component = component || parts[parts.length - 2] || ""; |
| 1151 |
var sep = component == "snippets" ? "/" : "-"; |
| 1152 |
var base = parts[parts.length - 1]; |
| 1153 |
if (component == "worker" && sep == "-") { |
| 1154 |
var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g"); |
| 1155 |
base = base.replace(re, ""); |
| 1156 |
} |
| 1157 |
if ((!base || base == component) && parts.length > 1) |
| 1158 |
base = parts[parts.length - 2]; |
| 1159 |
var path = options[component + "Path"]; |
| 1160 |
if (path == null) { |
| 1161 |
path = options.basePath; |
| 1162 |
} |
| 1163 |
else if (sep == "/") { |
| 1164 |
component = sep = ""; |
| 1165 |
} |
| 1166 |
if (path && path.slice(-1) != "/") |
| 1167 |
path += "/"; |
| 1168 |
return path + component + sep + base + this.get("suffix"); |
| 1169 |
}; |
| 1170 |
exports.setModuleUrl = function (name, subst) { |
| 1171 |
return options.$moduleUrls[name] = subst; |
| 1172 |
}; |
| 1173 |
var loader = function (moduleName, cb) { |
| 1174 |
if (moduleName === "ace/theme/textmate" || moduleName === "./theme/textmate") |
| 1175 |
return cb(null, require("./theme/textmate")); |
| 1176 |
if (customLoader) |
| 1177 |
return customLoader(moduleName, cb); |
| 1178 |
console.error("loader is not configured"); |
| 1179 |
}; |
| 1180 |
var customLoader; |
| 1181 |
exports.setLoader = function (cb) { |
| 1182 |
customLoader = cb; |
| 1183 |
}; |
| 1184 |
exports.dynamicModules = Object.create(null); |
| 1185 |
exports.$loading = {}; |
| 1186 |
exports.$loaded = {}; |
| 1187 |
exports.loadModule = function (moduleId, onLoad) { |
| 1188 |
var loadedModule; |
| 1189 |
if (Array.isArray(moduleId)) { |
| 1190 |
var moduleType = moduleId[0]; |
| 1191 |
var moduleName = moduleId[1]; |
| 1192 |
} |
| 1193 |
else if (typeof moduleId == "string") { |
| 1194 |
var moduleName = moduleId; |
| 1195 |
} |
| 1196 |
var load = function (module) { |
| 1197 |
if (module && !exports.$loading[moduleName]) |
| 1198 |
return onLoad && onLoad(module); |
| 1199 |
if (!exports.$loading[moduleName]) |
| 1200 |
exports.$loading[moduleName] = []; |
| 1201 |
exports.$loading[moduleName].push(onLoad); |
| 1202 |
if (exports.$loading[moduleName].length > 1) |
| 1203 |
return; |
| 1204 |
var afterLoad = function () { |
| 1205 |
loader(moduleName, function (err, module) { |
| 1206 |
if (module) |
| 1207 |
exports.$loaded[moduleName] = module; |
| 1208 |
exports._emit("load.module", { name: moduleName, module: module }); |
| 1209 |
var listeners = exports.$loading[moduleName]; |
| 1210 |
exports.$loading[moduleName] = null; |
| 1211 |
listeners.forEach(function (onLoad) { |
| 1212 |
onLoad && onLoad(module); |
| 1213 |
}); |
| 1214 |
}); |
| 1215 |
}; |
| 1216 |
if (!exports.get("packaged")) |
| 1217 |
return afterLoad(); |
| 1218 |
net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad); |
| 1219 |
reportErrorIfPathIsNotConfigured(); |
| 1220 |
}; |
| 1221 |
if (exports.dynamicModules[moduleName]) { |
| 1222 |
exports.dynamicModules[moduleName]().then(function (module) { |
| 1223 |
if (module.default) { |
| 1224 |
load(module.default); |
| 1225 |
} |
| 1226 |
else { |
| 1227 |
load(module); |
| 1228 |
} |
| 1229 |
}); |
| 1230 |
} |
| 1231 |
else { |
| 1232 |
try { |
| 1233 |
loadedModule = this.$require(moduleName); |
| 1234 |
} |
| 1235 |
catch (e) { } |
| 1236 |
load(loadedModule || exports.$loaded[moduleName]); |
| 1237 |
} |
| 1238 |
}; |
| 1239 |
exports.$require = function (moduleName) { |
| 1240 |
if (typeof module["require"] == "function") { |
| 1241 |
var req = "require"; |
| 1242 |
return module[req](moduleName); |
| 1243 |
} |
| 1244 |
}; |
| 1245 |
exports.setModuleLoader = function (moduleName, onLoad) { |
| 1246 |
exports.dynamicModules[moduleName] = onLoad; |
| 1247 |
}; |
| 1248 |
var reportErrorIfPathIsNotConfigured = function () { |
| 1249 |
if (!options.basePath && !options.workerPath |
| 1250 |
&& !options.modePath && !options.themePath |
| 1251 |
&& !Object.keys(options.$moduleUrls).length) { |
| 1252 |
console.error("Unable to infer path to ace from script src,", "use ace.config.set('basePath', 'path') to enable dynamic loading of modes and themes", "or with webpack use ace/webpack-resolver"); |
| 1253 |
reportErrorIfPathIsNotConfigured = function () { }; |
| 1254 |
} |
| 1255 |
}; |
| 1256 |
exports.version = "1.32.7"; |
| 1257 |
|
| 1258 |
}); |
| 1259 |
|
| 1260 |
ace.define("ace/loader_build",["require","exports","module","ace/lib/fixoldbrowsers","ace/config"], function(require, exports, module) { |
| 1261 |
"use strict"; |
| 1262 |
|
| 1263 |
require("./lib/fixoldbrowsers"); |
| 1264 |
var config = require("./config"); |
| 1265 |
config.setLoader(function(moduleName, cb) { |
| 1266 |
require([moduleName], function(module) { |
| 1267 |
cb(null, module); |
| 1268 |
}); |
| 1269 |
}); |
| 1270 |
|
| 1271 |
var global = (function() { |
| 1272 |
return this || typeof window != "undefined" && window; |
| 1273 |
})(); |
| 1274 |
|
| 1275 |
module.exports = function(ace) { |
| 1276 |
config.init = init; |
| 1277 |
config.$require = require; |
| 1278 |
ace.require = require; |
| 1279 |
|
| 1280 |
if (typeof define === "function") |
| 1281 |
ace.define = define; |
| 1282 |
}; |
| 1283 |
init(true);function init(packaged) { |
| 1284 |
|
| 1285 |
if (!global || !global.document) |
| 1286 |
return; |
| 1287 |
|
| 1288 |
config.set("packaged", packaged || require.packaged || module.packaged || (global.define && define.packaged)); |
| 1289 |
|
| 1290 |
var scriptOptions = {}; |
| 1291 |
var scriptUrl = ""; |
| 1292 |
var currentScript = (document.currentScript || document._currentScript ); |
| 1293 |
var currentDocument = currentScript && currentScript.ownerDocument || document; |
| 1294 |
|
| 1295 |
if (currentScript && currentScript.src) { |
| 1296 |
scriptUrl = currentScript.src.split(/[?#]/)[0].split("/").slice(0, -1).join("/") || ""; |
| 1297 |
} |
| 1298 |
|
| 1299 |
var scripts = currentDocument.getElementsByTagName("script"); |
| 1300 |
for (var i=0; i<scripts.length; i++) { |
| 1301 |
var script = scripts[i]; |
| 1302 |
|
| 1303 |
var src = script.src || script.getAttribute("src"); |
| 1304 |
if (!src) |
| 1305 |
continue; |
| 1306 |
|
| 1307 |
var attributes = script.attributes; |
| 1308 |
for (var j=0, l=attributes.length; j < l; j++) { |
| 1309 |
var attr = attributes[j]; |
| 1310 |
if (attr.name.indexOf("data-ace-") === 0) { |
| 1311 |
scriptOptions[deHyphenate(attr.name.replace(/^data-ace-/, ""))] = attr.value; |
| 1312 |
} |
| 1313 |
} |
| 1314 |
|
| 1315 |
var m = src.match(/^(.*)\/ace([\-.]\w+)?\.js(\?|$)/); |
| 1316 |
if (m) |
| 1317 |
scriptUrl = m[1]; |
| 1318 |
} |
| 1319 |
|
| 1320 |
if (scriptUrl) { |
| 1321 |
scriptOptions.base = scriptOptions.base || scriptUrl; |
| 1322 |
scriptOptions.packaged = true; |
| 1323 |
} |
| 1324 |
|
| 1325 |
scriptOptions.basePath = scriptOptions.base; |
| 1326 |
scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base; |
| 1327 |
scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base; |
| 1328 |
scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base; |
| 1329 |
delete scriptOptions.base; |
| 1330 |
|
| 1331 |
for (var key in scriptOptions) |
| 1332 |
if (typeof scriptOptions[key] !== "undefined") |
| 1333 |
config.set(key, scriptOptions[key]); |
| 1334 |
} |
| 1335 |
|
| 1336 |
function deHyphenate(str) { |
| 1337 |
return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); }); |
| 1338 |
} |
| 1339 |
}); |
| 1340 |
|
| 1341 |
ace.define("ace/range",["require","exports","module"], function(require, exports, module){"use strict"; |
| 1342 |
var Range = (function () { |
| 1343 |
function Range(startRow, startColumn, endRow, endColumn) { |
| 1344 |
this.start = { |
| 1345 |
row: startRow, |
| 1346 |
column: startColumn |
| 1347 |
}; |
| 1348 |
this.end = { |
| 1349 |
row: endRow, |
| 1350 |
column: endColumn |
| 1351 |
}; |
| 1352 |
} |
| 1353 |
Range.prototype.isEqual = function (range) { |
| 1354 |
return this.start.row === range.start.row && |
| 1355 |
this.end.row === range.end.row && |
| 1356 |
this.start.column === range.start.column && |
| 1357 |
this.end.column === range.end.column; |
| 1358 |
}; |
| 1359 |
Range.prototype.toString = function () { |
| 1360 |
return ("Range: [" + this.start.row + "/" + this.start.column + |
| 1361 |
"] -> [" + this.end.row + "/" + this.end.column + "]"); |
| 1362 |
}; |
| 1363 |
Range.prototype.contains = function (row, column) { |
| 1364 |
return this.compare(row, column) == 0; |
| 1365 |
}; |
| 1366 |
Range.prototype.compareRange = function (range) { |
| 1367 |
var cmp, end = range.end, start = range.start; |
| 1368 |
cmp = this.compare(end.row, end.column); |
| 1369 |
if (cmp == 1) { |
| 1370 |
cmp = this.compare(start.row, start.column); |
| 1371 |
if (cmp == 1) { |
| 1372 |
return 2; |
| 1373 |
} |
| 1374 |
else if (cmp == 0) { |
| 1375 |
return 1; |
| 1376 |
} |
| 1377 |
else { |
| 1378 |
return 0; |
| 1379 |
} |
| 1380 |
} |
| 1381 |
else if (cmp == -1) { |
| 1382 |
return -2; |
| 1383 |
} |
| 1384 |
else { |
| 1385 |
cmp = this.compare(start.row, start.column); |
| 1386 |
if (cmp == -1) { |
| 1387 |
return -1; |
| 1388 |
} |
| 1389 |
else if (cmp == 1) { |
| 1390 |
return 42; |
| 1391 |
} |
| 1392 |
else { |
| 1393 |
return 0; |
| 1394 |
} |
| 1395 |
} |
| 1396 |
}; |
| 1397 |
Range.prototype.comparePoint = function (p) { |
| 1398 |
return this.compare(p.row, p.column); |
| 1399 |
}; |
| 1400 |
Range.prototype.containsRange = function (range) { |
| 1401 |
return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0; |
| 1402 |
}; |
| 1403 |
Range.prototype.intersects = function (range) { |
| 1404 |
var cmp = this.compareRange(range); |
| 1405 |
return (cmp == -1 || cmp == 0 || cmp == 1); |
| 1406 |
}; |
| 1407 |
Range.prototype.isEnd = function (row, column) { |
| 1408 |
return this.end.row == row && this.end.column == column; |
| 1409 |
}; |
| 1410 |
Range.prototype.isStart = function (row, column) { |
| 1411 |
return this.start.row == row && this.start.column == column; |
| 1412 |
}; |
| 1413 |
Range.prototype.setStart = function (row, column) { |
| 1414 |
if (typeof row == "object") { |
| 1415 |
this.start.column = row.column; |
| 1416 |
this.start.row = row.row; |
| 1417 |
} |
| 1418 |
else { |
| 1419 |
this.start.row = row; |
| 1420 |
this.start.column = column; |
| 1421 |
} |
| 1422 |
}; |
| 1423 |
Range.prototype.setEnd = function (row, column) { |
| 1424 |
if (typeof row == "object") { |
| 1425 |
this.end.column = row.column; |
| 1426 |
this.end.row = row.row; |
| 1427 |
} |
| 1428 |
else { |
| 1429 |
this.end.row = row; |
| 1430 |
this.end.column = column; |
| 1431 |
} |
| 1432 |
}; |
| 1433 |
Range.prototype.inside = function (row, column) { |
| 1434 |
if (this.compare(row, column) == 0) { |
| 1435 |
if (this.isEnd(row, column) || this.isStart(row, column)) { |
| 1436 |
return false; |
| 1437 |
} |
| 1438 |
else { |
| 1439 |
return true; |
| 1440 |
} |
| 1441 |
} |
| 1442 |
return false; |
| 1443 |
}; |
| 1444 |
Range.prototype.insideStart = function (row, column) { |
| 1445 |
if (this.compare(row, column) == 0) { |
| 1446 |
if (this.isEnd(row, column)) { |
| 1447 |
return false; |
| 1448 |
} |
| 1449 |
else { |
| 1450 |
return true; |
| 1451 |
} |
| 1452 |
} |
| 1453 |
return false; |
| 1454 |
}; |
| 1455 |
Range.prototype.insideEnd = function (row, column) { |
| 1456 |
if (this.compare(row, column) == 0) { |
| 1457 |
if (this.isStart(row, column)) { |
| 1458 |
return false; |
| 1459 |
} |
| 1460 |
else { |
| 1461 |
return true; |
| 1462 |
} |
| 1463 |
} |
| 1464 |
return false; |
| 1465 |
}; |
| 1466 |
Range.prototype.compare = function (row, column) { |
| 1467 |
if (!this.isMultiLine()) { |
| 1468 |
if (row === this.start.row) { |
| 1469 |
return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0); |
| 1470 |
} |
| 1471 |
} |
| 1472 |
if (row < this.start.row) |
| 1473 |
return -1; |
| 1474 |
if (row > this.end.row) |
| 1475 |
return 1; |
| 1476 |
if (this.start.row === row) |
| 1477 |
return column >= this.start.column ? 0 : -1; |
| 1478 |
if (this.end.row === row) |
| 1479 |
return column <= this.end.column ? 0 : 1; |
| 1480 |
return 0; |
| 1481 |
}; |
| 1482 |
Range.prototype.compareStart = function (row, column) { |
| 1483 |
if (this.start.row == row && this.start.column == column) { |
| 1484 |
return -1; |
| 1485 |
} |
| 1486 |
else { |
| 1487 |
return this.compare(row, column); |
| 1488 |
} |
| 1489 |
}; |
| 1490 |
Range.prototype.compareEnd = function (row, column) { |
| 1491 |
if (this.end.row == row && this.end.column == column) { |
| 1492 |
return 1; |
| 1493 |
} |
| 1494 |
else { |
| 1495 |
return this.compare(row, column); |
| 1496 |
} |
| 1497 |
}; |
| 1498 |
Range.prototype.compareInside = function (row, column) { |
| 1499 |
if (this.end.row == row && this.end.column == column) { |
| 1500 |
return 1; |
| 1501 |
} |
| 1502 |
else if (this.start.row == row && this.start.column == column) { |
| 1503 |
return -1; |
| 1504 |
} |
| 1505 |
else { |
| 1506 |
return this.compare(row, column); |
| 1507 |
} |
| 1508 |
}; |
| 1509 |
Range.prototype.clipRows = function (firstRow, lastRow) { |
| 1510 |
if (this.end.row > lastRow) |
| 1511 |
var end = { row: lastRow + 1, column: 0 }; |
| 1512 |
else if (this.end.row < firstRow) |
| 1513 |
var end = { row: firstRow, column: 0 }; |
| 1514 |
if (this.start.row > lastRow) |
| 1515 |
var start = { row: lastRow + 1, column: 0 }; |
| 1516 |
else if (this.start.row < firstRow) |
| 1517 |
var start = { row: firstRow, column: 0 }; |
| 1518 |
return Range.fromPoints(start || this.start, end || this.end); |
| 1519 |
}; |
| 1520 |
Range.prototype.extend = function (row, column) { |
| 1521 |
var cmp = this.compare(row, column); |
| 1522 |
if (cmp == 0) |
| 1523 |
return this; |
| 1524 |
else if (cmp == -1) |
| 1525 |
var start = { row: row, column: column }; |
| 1526 |
else |
| 1527 |
var end = { row: row, column: column }; |
| 1528 |
return Range.fromPoints(start || this.start, end || this.end); |
| 1529 |
}; |
| 1530 |
Range.prototype.isEmpty = function () { |
| 1531 |
return (this.start.row === this.end.row && this.start.column === this.end.column); |
| 1532 |
}; |
| 1533 |
Range.prototype.isMultiLine = function () { |
| 1534 |
return (this.start.row !== this.end.row); |
| 1535 |
}; |
| 1536 |
Range.prototype.clone = function () { |
| 1537 |
return Range.fromPoints(this.start, this.end); |
| 1538 |
}; |
| 1539 |
Range.prototype.collapseRows = function () { |
| 1540 |
if (this.end.column == 0) |
| 1541 |
return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row - 1), 0); |
| 1542 |
else |
| 1543 |
return new Range(this.start.row, 0, this.end.row, 0); |
| 1544 |
}; |
| 1545 |
Range.prototype.toScreenRange = function (session) { |
| 1546 |
var screenPosStart = session.documentToScreenPosition(this.start); |
| 1547 |
var screenPosEnd = session.documentToScreenPosition(this.end); |
| 1548 |
return new Range(screenPosStart.row, screenPosStart.column, screenPosEnd.row, screenPosEnd.column); |
| 1549 |
}; |
| 1550 |
Range.prototype.moveBy = function (row, column) { |
| 1551 |
this.start.row += row; |
| 1552 |
this.start.column += column; |
| 1553 |
this.end.row += row; |
| 1554 |
this.end.column += column; |
| 1555 |
}; |
| 1556 |
return Range; |
| 1557 |
}()); |
| 1558 |
Range.fromPoints = function (start, end) { |
| 1559 |
return new Range(start.row, start.column, end.row, end.column); |
| 1560 |
}; |
| 1561 |
Range.comparePoints = function (p1, p2) { |
| 1562 |
return p1.row - p2.row || p1.column - p2.column; |
| 1563 |
}; |
| 1564 |
exports.Range = Range; |
| 1565 |
|
| 1566 |
}); |
| 1567 |
|
| 1568 |
ace.define("ace/lib/keys",["require","exports","module","ace/lib/oop"], function(require, exports, module){ |
| 1569 |
|
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
|
| 1577 |
|
| 1578 |
|
| 1579 |
|
| 1580 |
|
| 1581 |
|
| 1582 |
|
| 1583 |
|
| 1584 |
|
| 1585 |
|
| 1586 |
|
| 1587 |
|
| 1588 |
|
| 1589 |
|
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
|
| 1595 |
|
| 1596 |
|
| 1597 |
|
| 1598 |
"use strict"; |
| 1599 |
var oop = require("./oop"); |
| 1600 |
var Keys = (function () { |
| 1601 |
var ret = { |
| 1602 |
MODIFIER_KEYS: { |
| 1603 |
16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta', |
| 1604 |
91: 'MetaLeft', 92: 'MetaRight', 93: 'ContextMenu' |
| 1605 |
}, |
| 1606 |
KEY_MODS: { |
| 1607 |
"ctrl": 1, "alt": 2, "option": 2, "shift": 4, |
| 1608 |
"super": 8, "meta": 8, "command": 8, "cmd": 8, |
| 1609 |
"control": 1 |
| 1610 |
}, |
| 1611 |
FUNCTION_KEYS: { |
| 1612 |
8: "Backspace", |
| 1613 |
9: "Tab", |
| 1614 |
13: "Return", |
| 1615 |
19: "Pause", |
| 1616 |
27: "Esc", |
| 1617 |
32: "Space", |
| 1618 |
33: "PageUp", |
| 1619 |
34: "PageDown", |
| 1620 |
35: "End", |
| 1621 |
36: "Home", |
| 1622 |
37: "Left", |
| 1623 |
38: "Up", |
| 1624 |
39: "Right", |
| 1625 |
40: "Down", |
| 1626 |
44: "Print", |
| 1627 |
45: "Insert", |
| 1628 |
46: "Delete", |
| 1629 |
96: "Numpad0", |
| 1630 |
97: "Numpad1", |
| 1631 |
98: "Numpad2", |
| 1632 |
99: "Numpad3", |
| 1633 |
100: "Numpad4", |
| 1634 |
101: "Numpad5", |
| 1635 |
102: "Numpad6", |
| 1636 |
103: "Numpad7", |
| 1637 |
104: "Numpad8", |
| 1638 |
105: "Numpad9", |
| 1639 |
'-13': "NumpadEnter", |
| 1640 |
112: "F1", |
| 1641 |
113: "F2", |
| 1642 |
114: "F3", |
| 1643 |
115: "F4", |
| 1644 |
116: "F5", |
| 1645 |
117: "F6", |
| 1646 |
118: "F7", |
| 1647 |
119: "F8", |
| 1648 |
120: "F9", |
| 1649 |
121: "F10", |
| 1650 |
122: "F11", |
| 1651 |
123: "F12", |
| 1652 |
144: "Numlock", |
| 1653 |
145: "Scrolllock" |
| 1654 |
}, |
| 1655 |
PRINTABLE_KEYS: { |
| 1656 |
32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5', |
| 1657 |
54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a', |
| 1658 |
66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h', |
| 1659 |
73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o', |
| 1660 |
80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v', |
| 1661 |
87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.', |
| 1662 |
186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`', |
| 1663 |
219: '[', 220: '\\', 221: ']', 222: "'", 111: '/', 106: '*' |
| 1664 |
} |
| 1665 |
}; |
| 1666 |
ret.PRINTABLE_KEYS[173] = '-'; |
| 1667 |
var name, i; |
| 1668 |
for (i in ret.FUNCTION_KEYS) { |
| 1669 |
name = ret.FUNCTION_KEYS[i].toLowerCase(); |
| 1670 |
ret[name] = parseInt(i, 10); |
| 1671 |
} |
| 1672 |
for (i in ret.PRINTABLE_KEYS) { |
| 1673 |
name = ret.PRINTABLE_KEYS[i].toLowerCase(); |
| 1674 |
ret[name] = parseInt(i, 10); |
| 1675 |
} |
| 1676 |
oop.mixin(ret, ret.MODIFIER_KEYS); |
| 1677 |
oop.mixin(ret, ret.PRINTABLE_KEYS); |
| 1678 |
oop.mixin(ret, ret.FUNCTION_KEYS); |
| 1679 |
ret.enter = ret["return"]; |
| 1680 |
ret.escape = ret.esc; |
| 1681 |
ret.del = ret["delete"]; |
| 1682 |
(function () { |
| 1683 |
var mods = ["cmd", "ctrl", "alt", "shift"]; |
| 1684 |
for (var i = Math.pow(2, mods.length); i--;) { |
| 1685 |
ret.KEY_MODS[i] = mods.filter(function (x) { |
| 1686 |
return i & ret.KEY_MODS[x]; |
| 1687 |
}).join("-") + "-"; |
| 1688 |
} |
| 1689 |
})(); |
| 1690 |
ret.KEY_MODS[0] = ""; |
| 1691 |
ret.KEY_MODS[-1] = "input-"; |
| 1692 |
return ret; |
| 1693 |
})(); |
| 1694 |
oop.mixin(exports, Keys); |
| 1695 |
exports.default = exports; |
| 1696 |
exports.keyCodeToString = function (keyCode) { |
| 1697 |
var keyString = Keys[keyCode]; |
| 1698 |
if (typeof keyString != "string") |
| 1699 |
keyString = String.fromCharCode(keyCode); |
| 1700 |
return keyString.toLowerCase(); |
| 1701 |
}; |
| 1702 |
|
| 1703 |
}); |
| 1704 |
|
| 1705 |
ace.define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module){"use strict"; var keys = require("./keys"); |
| 1706 |
var useragent = require("./useragent"); |
| 1707 |
var pressedKeys = null; |
| 1708 |
var ts = 0; |
| 1709 |
var activeListenerOptions; |
| 1710 |
function detectListenerOptionsSupport() { |
| 1711 |
activeListenerOptions = false; |
| 1712 |
try { |
| 1713 |
document.createComment("").addEventListener("test", function () { }, { |
| 1714 |
get passive() { |
| 1715 |
activeListenerOptions = { passive: false }; |
| 1716 |
return true; |
| 1717 |
} |
| 1718 |
}); |
| 1719 |
} |
| 1720 |
catch (e) { } |
| 1721 |
} |
| 1722 |
function getListenerOptions() { |
| 1723 |
if (activeListenerOptions == undefined) |
| 1724 |
detectListenerOptionsSupport(); |
| 1725 |
return activeListenerOptions; |
| 1726 |
} |
| 1727 |
function EventListener(elem, type, callback) { |
| 1728 |
this.elem = elem; |
| 1729 |
this.type = type; |
| 1730 |
this.callback = callback; |
| 1731 |
} |
| 1732 |
EventListener.prototype.destroy = function () { |
| 1733 |
removeListener(this.elem, this.type, this.callback); |
| 1734 |
this.elem = this.type = this.callback = undefined; |
| 1735 |
}; |
| 1736 |
var addListener = exports.addListener = function (elem, type, callback, destroyer) { |
| 1737 |
elem.addEventListener(type, callback, getListenerOptions()); |
| 1738 |
if (destroyer) |
| 1739 |
destroyer.$toDestroy.push(new EventListener(elem, type, callback)); |
| 1740 |
}; |
| 1741 |
var removeListener = exports.removeListener = function (elem, type, callback) { |
| 1742 |
elem.removeEventListener(type, callback, getListenerOptions()); |
| 1743 |
}; |
| 1744 |
exports.stopEvent = function (e) { |
| 1745 |
exports.stopPropagation(e); |
| 1746 |
exports.preventDefault(e); |
| 1747 |
return false; |
| 1748 |
}; |
| 1749 |
exports.stopPropagation = function (e) { |
| 1750 |
if (e.stopPropagation) |
| 1751 |
e.stopPropagation(); |
| 1752 |
}; |
| 1753 |
exports.preventDefault = function (e) { |
| 1754 |
if (e.preventDefault) |
| 1755 |
e.preventDefault(); |
| 1756 |
}; |
| 1757 |
exports.getButton = function (e) { |
| 1758 |
if (e.type == "dblclick") |
| 1759 |
return 0; |
| 1760 |
if (e.type == "contextmenu" || (useragent.isMac && (e.ctrlKey && !e.altKey && !e.shiftKey))) |
| 1761 |
return 2; |
| 1762 |
return e.button; |
| 1763 |
}; |
| 1764 |
exports.capture = function (el, eventHandler, releaseCaptureHandler) { |
| 1765 |
var ownerDocument = el && el.ownerDocument || document; |
| 1766 |
function onMouseUp(e) { |
| 1767 |
eventHandler && eventHandler(e); |
| 1768 |
releaseCaptureHandler && releaseCaptureHandler(e); |
| 1769 |
removeListener(ownerDocument, "mousemove", eventHandler); |
| 1770 |
removeListener(ownerDocument, "mouseup", onMouseUp); |
| 1771 |
removeListener(ownerDocument, "dragstart", onMouseUp); |
| 1772 |
} |
| 1773 |
addListener(ownerDocument, "mousemove", eventHandler); |
| 1774 |
addListener(ownerDocument, "mouseup", onMouseUp); |
| 1775 |
addListener(ownerDocument, "dragstart", onMouseUp); |
| 1776 |
return onMouseUp; |
| 1777 |
}; |
| 1778 |
exports.addMouseWheelListener = function (el, callback, destroyer) { |
| 1779 |
addListener(el, "wheel", function (e) { |
| 1780 |
var factor = 0.15; |
| 1781 |
var deltaX = e.deltaX || 0; |
| 1782 |
var deltaY = e.deltaY || 0; |
| 1783 |
switch (e.deltaMode) { |
| 1784 |
case e.DOM_DELTA_PIXEL: |
| 1785 |
e.wheelX = deltaX * factor; |
| 1786 |
e.wheelY = deltaY * factor; |
| 1787 |
break; |
| 1788 |
case e.DOM_DELTA_LINE: |
| 1789 |
var linePixels = 15; |
| 1790 |
e.wheelX = deltaX * linePixels; |
| 1791 |
e.wheelY = deltaY * linePixels; |
| 1792 |
break; |
| 1793 |
case e.DOM_DELTA_PAGE: |
| 1794 |
var pagePixels = 150; |
| 1795 |
e.wheelX = deltaX * pagePixels; |
| 1796 |
e.wheelY = deltaY * pagePixels; |
| 1797 |
break; |
| 1798 |
} |
| 1799 |
callback(e); |
| 1800 |
}, destroyer); |
| 1801 |
}; |
| 1802 |
exports.addMultiMouseDownListener = function (elements, timeouts, eventHandler, callbackName, destroyer) { |
| 1803 |
var clicks = 0; |
| 1804 |
var startX, startY, timer; |
| 1805 |
var eventNames = { |
| 1806 |
2: "dblclick", |
| 1807 |
3: "tripleclick", |
| 1808 |
4: "quadclick" |
| 1809 |
}; |
| 1810 |
function onMousedown(e) { |
| 1811 |
if (exports.getButton(e) !== 0) { |
| 1812 |
clicks = 0; |
| 1813 |
} |
| 1814 |
else if (e.detail > 1) { |
| 1815 |
clicks++; |
| 1816 |
if (clicks > 4) |
| 1817 |
clicks = 1; |
| 1818 |
} |
| 1819 |
else { |
| 1820 |
clicks = 1; |
| 1821 |
} |
| 1822 |
if (useragent.isIE) { |
| 1823 |
var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5; |
| 1824 |
if (!timer || isNewClick) |
| 1825 |
clicks = 1; |
| 1826 |
if (timer) |
| 1827 |
clearTimeout(timer); |
| 1828 |
timer = setTimeout(function () { timer = null; }, timeouts[clicks - 1] || 600); |
| 1829 |
if (clicks == 1) { |
| 1830 |
startX = e.clientX; |
| 1831 |
startY = e.clientY; |
| 1832 |
} |
| 1833 |
} |
| 1834 |
e._clicks = clicks; |
| 1835 |
eventHandler[callbackName]("mousedown", e); |
| 1836 |
if (clicks > 4) |
| 1837 |
clicks = 0; |
| 1838 |
else if (clicks > 1) |
| 1839 |
return eventHandler[callbackName](eventNames[clicks], e); |
| 1840 |
} |
| 1841 |
if (!Array.isArray(elements)) |
| 1842 |
elements = [elements]; |
| 1843 |
elements.forEach(function (el) { |
| 1844 |
addListener(el, "mousedown", onMousedown, destroyer); |
| 1845 |
}); |
| 1846 |
}; |
| 1847 |
function getModifierHash(e) { |
| 1848 |
return 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0); |
| 1849 |
} |
| 1850 |
exports.getModifierString = function (e) { |
| 1851 |
return keys.KEY_MODS[getModifierHash(e)]; |
| 1852 |
}; |
| 1853 |
function normalizeCommandKeys(callback, e, keyCode) { |
| 1854 |
var hashId = getModifierHash(e); |
| 1855 |
if (!useragent.isMac && pressedKeys) { |
| 1856 |
if (e.getModifierState && (e.getModifierState("OS") || e.getModifierState("Win"))) |
| 1857 |
hashId |= 8; |
| 1858 |
if (pressedKeys.altGr) { |
| 1859 |
if ((3 & hashId) != 3) |
| 1860 |
pressedKeys.altGr = 0; |
| 1861 |
else |
| 1862 |
return; |
| 1863 |
} |
| 1864 |
if (keyCode === 18 || keyCode === 17) { |
| 1865 |
var location = e.location; |
| 1866 |
if (keyCode === 17 && location === 1) { |
| 1867 |
if (pressedKeys[keyCode] == 1) |
| 1868 |
ts = e.timeStamp; |
| 1869 |
} |
| 1870 |
else if (keyCode === 18 && hashId === 3 && location === 2) { |
| 1871 |
var dt = e.timeStamp - ts; |
| 1872 |
if (dt < 50) |
| 1873 |
pressedKeys.altGr = true; |
| 1874 |
} |
| 1875 |
} |
| 1876 |
} |
| 1877 |
if (keyCode in keys.MODIFIER_KEYS) { |
| 1878 |
keyCode = -1; |
| 1879 |
} |
| 1880 |
if (!hashId && keyCode === 13) { |
| 1881 |
if (e.location === 3) { |
| 1882 |
callback(e, hashId, -keyCode); |
| 1883 |
if (e.defaultPrevented) |
| 1884 |
return; |
| 1885 |
} |
| 1886 |
} |
| 1887 |
if (useragent.isChromeOS && hashId & 8) { |
| 1888 |
callback(e, hashId, keyCode); |
| 1889 |
if (e.defaultPrevented) |
| 1890 |
return; |
| 1891 |
else |
| 1892 |
hashId &= ~8; |
| 1893 |
} |
| 1894 |
if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) { |
| 1895 |
return false; |
| 1896 |
} |
| 1897 |
return callback(e, hashId, keyCode); |
| 1898 |
} |
| 1899 |
exports.addCommandKeyListener = function (el, callback, destroyer) { |
| 1900 |
var lastDefaultPrevented = null; |
| 1901 |
addListener(el, "keydown", function (e) { |
| 1902 |
pressedKeys[e.keyCode] = (pressedKeys[e.keyCode] || 0) + 1; |
| 1903 |
var result = normalizeCommandKeys(callback, e, e.keyCode); |
| 1904 |
lastDefaultPrevented = e.defaultPrevented; |
| 1905 |
return result; |
| 1906 |
}, destroyer); |
| 1907 |
addListener(el, "keypress", function (e) { |
| 1908 |
if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) { |
| 1909 |
exports.stopEvent(e); |
| 1910 |
lastDefaultPrevented = null; |
| 1911 |
} |
| 1912 |
}, destroyer); |
| 1913 |
addListener(el, "keyup", function (e) { |
| 1914 |
pressedKeys[e.keyCode] = null; |
| 1915 |
}, destroyer); |
| 1916 |
if (!pressedKeys) { |
| 1917 |
resetPressedKeys(); |
| 1918 |
addListener(window, "focus", resetPressedKeys); |
| 1919 |
} |
| 1920 |
}; |
| 1921 |
function resetPressedKeys() { |
| 1922 |
pressedKeys = Object.create(null); |
| 1923 |
} |
| 1924 |
if (typeof window == "object" && window.postMessage && !useragent.isOldIE) { |
| 1925 |
var postMessageId = 1; |
| 1926 |
exports.nextTick = function (callback, win) { |
| 1927 |
win = win || window; |
| 1928 |
var messageName = "zero-timeout-message-" + (postMessageId++); |
| 1929 |
var listener = function (e) { |
| 1930 |
if (e.data == messageName) { |
| 1931 |
exports.stopPropagation(e); |
| 1932 |
removeListener(win, "message", listener); |
| 1933 |
callback(); |
| 1934 |
} |
| 1935 |
}; |
| 1936 |
addListener(win, "message", listener); |
| 1937 |
win.postMessage(messageName, "*"); |
| 1938 |
}; |
| 1939 |
} |
| 1940 |
exports.$idleBlocked = false; |
| 1941 |
exports.onIdle = function (cb, timeout) { |
| 1942 |
return setTimeout(function handler() { |
| 1943 |
if (!exports.$idleBlocked) { |
| 1944 |
cb(); |
| 1945 |
} |
| 1946 |
else { |
| 1947 |
setTimeout(handler, 100); |
| 1948 |
} |
| 1949 |
}, timeout); |
| 1950 |
}; |
| 1951 |
exports.$idleBlockId = null; |
| 1952 |
exports.blockIdle = function (delay) { |
| 1953 |
if (exports.$idleBlockId) |
| 1954 |
clearTimeout(exports.$idleBlockId); |
| 1955 |
exports.$idleBlocked = true; |
| 1956 |
exports.$idleBlockId = setTimeout(function () { |
| 1957 |
exports.$idleBlocked = false; |
| 1958 |
}, delay || 100); |
| 1959 |
}; |
| 1960 |
exports.nextFrame = typeof window == "object" && (window.requestAnimationFrame |
| 1961 |
|| window["mozRequestAnimationFrame"] |
| 1962 |
|| window["webkitRequestAnimationFrame"] |
| 1963 |
|| window["msRequestAnimationFrame"] |
| 1964 |
|| window["oRequestAnimationFrame"]); |
| 1965 |
if (exports.nextFrame) |
| 1966 |
exports.nextFrame = exports.nextFrame.bind(window); |
| 1967 |
else |
| 1968 |
exports.nextFrame = function (callback) { |
| 1969 |
setTimeout(callback, 17); |
| 1970 |
}; |
| 1971 |
|
| 1972 |
}); |
| 1973 |
|
| 1974 |
ace.define("ace/clipboard",["require","exports","module"], function(require, exports, module){"use strict"; |
| 1975 |
var $cancelT; |
| 1976 |
module.exports = { |
| 1977 |
lineMode: false, |
| 1978 |
pasteCancelled: function () { |
| 1979 |
if ($cancelT && $cancelT > Date.now() - 50) |
| 1980 |
return true; |
| 1981 |
return $cancelT = false; |
| 1982 |
}, |
| 1983 |
cancel: function () { |
| 1984 |
$cancelT = Date.now(); |
| 1985 |
} |
| 1986 |
}; |
| 1987 |
|
| 1988 |
}); |
| 1989 |
|
| 1990 |
ace.define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/config","ace/lib/useragent","ace/lib/dom","ace/lib/lang","ace/clipboard","ace/lib/keys"], function(require, exports, module){"use strict"; |
| 1991 |
var event = require("../lib/event"); |
| 1992 |
var nls = require("../config").nls; |
| 1993 |
var useragent = require("../lib/useragent"); |
| 1994 |
var dom = require("../lib/dom"); |
| 1995 |
var lang = require("../lib/lang"); |
| 1996 |
var clipboard = require("../clipboard"); |
| 1997 |
var BROKEN_SETDATA = useragent.isChrome < 18; |
| 1998 |
var USE_IE_MIME_TYPE = useragent.isIE; |
| 1999 |
var HAS_FOCUS_ARGS = useragent.isChrome > 63; |
| 2000 |
var MAX_LINE_LENGTH = 400; |
| 2001 |
var KEYS = require("../lib/keys"); |
| 2002 |
var MODS = KEYS.KEY_MODS; |
| 2003 |
var isIOS = useragent.isIOS; |
| 2004 |
var valueResetRegex = isIOS ? /\s/ : /\n/; |
| 2005 |
var isMobile = useragent.isMobile; |
| 2006 |
var TextInput; |
| 2007 |
TextInput = function (parentNode, host) { |
| 2008 |
var text = dom.createElement("textarea"); |
| 2009 |
text.className = "ace_text-input"; |
| 2010 |
text.setAttribute("wrap", "off"); |
| 2011 |
text.setAttribute("autocorrect", "off"); |
| 2012 |
text.setAttribute("autocapitalize", "off"); |
| 2013 |
text.setAttribute("spellcheck", "false"); |
| 2014 |
text.style.opacity = "0"; |
| 2015 |
parentNode.insertBefore(text, parentNode.firstChild); |
| 2016 |
var copied = false; |
| 2017 |
var pasted = false; |
| 2018 |
var inComposition = false; |
| 2019 |
var sendingText = false; |
| 2020 |
var tempStyle = ''; |
| 2021 |
if (!isMobile) |
| 2022 |
text.style.fontSize = "1px"; |
| 2023 |
var commandMode = false; |
| 2024 |
var ignoreFocusEvents = false; |
| 2025 |
var lastValue = ""; |
| 2026 |
var lastSelectionStart = 0; |
| 2027 |
var lastSelectionEnd = 0; |
| 2028 |
var lastRestoreEnd = 0; |
| 2029 |
var rowStart = Number.MAX_SAFE_INTEGER; |
| 2030 |
var rowEnd = Number.MIN_SAFE_INTEGER; |
| 2031 |
var numberOfExtraLines = 0; |
| 2032 |
try { |
| 2033 |
var isFocused = document.activeElement === text; |
| 2034 |
} |
| 2035 |
catch (e) { } |
| 2036 |
this.setNumberOfExtraLines = function (number) { |
| 2037 |
rowStart = Number.MAX_SAFE_INTEGER; |
| 2038 |
rowEnd = Number.MIN_SAFE_INTEGER; |
| 2039 |
if (number < 0) { |
| 2040 |
numberOfExtraLines = 0; |
| 2041 |
return; |
| 2042 |
} |
| 2043 |
numberOfExtraLines = number; |
| 2044 |
}; |
| 2045 |
this.setAriaOptions = function (options) { |
| 2046 |
if (options.activeDescendant) { |
| 2047 |
text.setAttribute("aria-haspopup", "true"); |
| 2048 |
text.setAttribute("aria-autocomplete", options.inline ? "both" : "list"); |
| 2049 |
text.setAttribute("aria-activedescendant", options.activeDescendant); |
| 2050 |
} |
| 2051 |
else { |
| 2052 |
text.setAttribute("aria-haspopup", "false"); |
| 2053 |
text.setAttribute("aria-autocomplete", "both"); |
| 2054 |
text.removeAttribute("aria-activedescendant"); |
| 2055 |
} |
| 2056 |
if (options.role) { |
| 2057 |
text.setAttribute("role", options.role); |
| 2058 |
} |
| 2059 |
if (options.setLabel) { |
| 2060 |
text.setAttribute("aria-roledescription", nls("editor")); |
| 2061 |
if (host.session) { |
| 2062 |
var row = host.session.selection.cursor.row; |
| 2063 |
text.setAttribute("aria-label", nls("Cursor at row $0", [row + 1])); |
| 2064 |
} |
| 2065 |
} |
| 2066 |
}; |
| 2067 |
this.setAriaOptions({ role: "textbox" }); |
| 2068 |
event.addListener(text, "blur", function (e) { |
| 2069 |
if (ignoreFocusEvents) |
| 2070 |
return; |
| 2071 |
host.onBlur(e); |
| 2072 |
isFocused = false; |
| 2073 |
}, host); |
| 2074 |
event.addListener(text, "focus", function (e) { |
| 2075 |
if (ignoreFocusEvents) |
| 2076 |
return; |
| 2077 |
isFocused = true; |
| 2078 |
if (useragent.isEdge) { |
| 2079 |
try { |
| 2080 |
if (!document.hasFocus()) |
| 2081 |
return; |
| 2082 |
} |
| 2083 |
catch (e) { } |
| 2084 |
} |
| 2085 |
host.onFocus(e); |
| 2086 |
if (useragent.isEdge) |
| 2087 |
setTimeout(resetSelection); |
| 2088 |
else |
| 2089 |
resetSelection(); |
| 2090 |
}, host); |
| 2091 |
this.$focusScroll = false; |
| 2092 |
this.focus = function () { |
| 2093 |
this.setAriaOptions({ |
| 2094 |
setLabel: host.renderer.enableKeyboardAccessibility |
| 2095 |
}); |
| 2096 |
if (tempStyle || HAS_FOCUS_ARGS || this.$focusScroll == "browser") |
| 2097 |
return text.focus({ preventScroll: true }); |
| 2098 |
var top = text.style.top; |
| 2099 |
text.style.position = "fixed"; |
| 2100 |
text.style.top = "0px"; |
| 2101 |
try { |
| 2102 |
var isTransformed = text.getBoundingClientRect().top != 0; |
| 2103 |
} |
| 2104 |
catch (e) { |
| 2105 |
return; |
| 2106 |
} |
| 2107 |
var ancestors = []; |
| 2108 |
if (isTransformed) { |
| 2109 |
var t = text.parentElement; |
| 2110 |
while (t && t.nodeType == 1) { |
| 2111 |
ancestors.push(t); |
| 2112 |
t.setAttribute("ace_nocontext", "true"); |
| 2113 |
if (!t.parentElement && t.getRootNode) |
| 2114 |
t = t.getRootNode()["host"]; |
| 2115 |
else |
| 2116 |
t = t.parentElement; |
| 2117 |
} |
| 2118 |
} |
| 2119 |
text.focus({ preventScroll: true }); |
| 2120 |
if (isTransformed) { |
| 2121 |
ancestors.forEach(function (p) { |
| 2122 |
p.removeAttribute("ace_nocontext"); |
| 2123 |
}); |
| 2124 |
} |
| 2125 |
setTimeout(function () { |
| 2126 |
text.style.position = ""; |
| 2127 |
if (text.style.top == "0px") |
| 2128 |
text.style.top = top; |
| 2129 |
}, 0); |
| 2130 |
}; |
| 2131 |
this.blur = function () { |
| 2132 |
text.blur(); |
| 2133 |
}; |
| 2134 |
this.isFocused = function () { |
| 2135 |
return isFocused; |
| 2136 |
}; |
| 2137 |
host.on("beforeEndOperation", function () { |
| 2138 |
var curOp = host.curOp; |
| 2139 |
var commandName = curOp && curOp.command && curOp.command.name; |
| 2140 |
if (commandName == "insertstring") |
| 2141 |
return; |
| 2142 |
var isUserAction = commandName && (curOp.docChanged || curOp.selectionChanged); |
| 2143 |
if (inComposition && isUserAction) { |
| 2144 |
lastValue = text.value = ""; |
| 2145 |
onCompositionEnd(); |
| 2146 |
} |
| 2147 |
resetSelection(); |
| 2148 |
}); |
| 2149 |
var positionToSelection = function (row, column) { |
| 2150 |
var selection = column; |
| 2151 |
for (var i = 1; i <= row - rowStart && i < 2 * numberOfExtraLines + 1; i++) { |
| 2152 |
selection += host.session.getLine(row - i).length + 1; |
| 2153 |
} |
| 2154 |
return selection; |
| 2155 |
}; |
| 2156 |
var resetSelection = isIOS |
| 2157 |
? function (value) { |
| 2158 |
if (!isFocused || (copied && !value) || sendingText) |
| 2159 |
return; |
| 2160 |
if (!value) |
| 2161 |
value = ""; |
| 2162 |
var newValue = "\n ab" + value + "cde fg\n"; |
| 2163 |
if (newValue != text.value) |
| 2164 |
text.value = lastValue = newValue; |
| 2165 |
var selectionStart = 4; |
| 2166 |
var selectionEnd = 4 + (value.length || (host.selection.isEmpty() ? 0 : 1)); |
| 2167 |
if (lastSelectionStart != selectionStart || lastSelectionEnd != selectionEnd) { |
| 2168 |
text.setSelectionRange(selectionStart, selectionEnd); |
| 2169 |
} |
| 2170 |
lastSelectionStart = selectionStart; |
| 2171 |
lastSelectionEnd = selectionEnd; |
| 2172 |
} |
| 2173 |
: function () { |
| 2174 |
if (inComposition || sendingText) |
| 2175 |
return; |
| 2176 |
if (!isFocused && !afterContextMenu) |
| 2177 |
return; |
| 2178 |
inComposition = true; |
| 2179 |
var selectionStart = 0; |
| 2180 |
var selectionEnd = 0; |
| 2181 |
var line = ""; |
| 2182 |
if (host.session) { |
| 2183 |
var selection = host.selection; |
| 2184 |
var range = selection.getRange(); |
| 2185 |
var row = selection.cursor.row; |
| 2186 |
if (row === rowEnd + 1) { |
| 2187 |
rowStart = rowEnd + 1; |
| 2188 |
rowEnd = rowStart + 2 * numberOfExtraLines; |
| 2189 |
} |
| 2190 |
else if (row === rowStart - 1) { |
| 2191 |
rowEnd = rowStart - 1; |
| 2192 |
rowStart = rowEnd - 2 * numberOfExtraLines; |
| 2193 |
} |
| 2194 |
else if (row < rowStart - 1 || row > rowEnd + 1) { |
| 2195 |
rowStart = row > numberOfExtraLines ? row - numberOfExtraLines : 0; |
| 2196 |
rowEnd = row > numberOfExtraLines ? row + numberOfExtraLines : 2 * numberOfExtraLines; |
| 2197 |
} |
| 2198 |
var lines = []; |
| 2199 |
for (var i = rowStart; i <= rowEnd; i++) { |
| 2200 |
lines.push(host.session.getLine(i)); |
| 2201 |
} |
| 2202 |
line = lines.join('\n'); |
| 2203 |
selectionStart = positionToSelection(range.start.row, range.start.column); |
| 2204 |
selectionEnd = positionToSelection(range.end.row, range.end.column); |
| 2205 |
if (range.start.row < rowStart) { |
| 2206 |
var prevLine = host.session.getLine(rowStart - 1); |
| 2207 |
selectionStart = range.start.row < rowStart - 1 ? 0 : selectionStart; |
| 2208 |
selectionEnd += prevLine.length + 1; |
| 2209 |
line = prevLine + "\n" + line; |
| 2210 |
} |
| 2211 |
else if (range.end.row > rowEnd) { |
| 2212 |
var nextLine = host.session.getLine(rowEnd + 1); |
| 2213 |
selectionEnd = range.end.row > rowEnd + 1 ? nextLine.length : range.end.column; |
| 2214 |
selectionEnd += line.length + 1; |
| 2215 |
line = line + "\n" + nextLine; |
| 2216 |
} |
| 2217 |
else if (isMobile && row > 0) { |
| 2218 |
line = "\n" + line; |
| 2219 |
selectionEnd += 1; |
| 2220 |
selectionStart += 1; |
| 2221 |
} |
| 2222 |
if (line.length > MAX_LINE_LENGTH) { |
| 2223 |
if (selectionStart < MAX_LINE_LENGTH && selectionEnd < MAX_LINE_LENGTH) { |
| 2224 |
line = line.slice(0, MAX_LINE_LENGTH); |
| 2225 |
} |
| 2226 |
else { |
| 2227 |
line = "\n"; |
| 2228 |
if (selectionStart == selectionEnd) { |
| 2229 |
selectionStart = selectionEnd = 0; |
| 2230 |
} |
| 2231 |
else { |
| 2232 |
selectionStart = 0; |
| 2233 |
selectionEnd = 1; |
| 2234 |
} |
| 2235 |
} |
| 2236 |
} |
| 2237 |
var newValue = line + "\n\n"; |
| 2238 |
if (newValue != lastValue) { |
| 2239 |
text.value = lastValue = newValue; |
| 2240 |
lastSelectionStart = lastSelectionEnd = newValue.length; |
| 2241 |
} |
| 2242 |
} |
| 2243 |
if (afterContextMenu) { |
| 2244 |
lastSelectionStart = text.selectionStart; |
| 2245 |
lastSelectionEnd = text.selectionEnd; |
| 2246 |
} |
| 2247 |
if (lastSelectionEnd != selectionEnd |
| 2248 |
|| lastSelectionStart != selectionStart |
| 2249 |
|| text.selectionEnd != lastSelectionEnd |
| 2250 |
) { |
| 2251 |
try { |
| 2252 |
text.setSelectionRange(selectionStart, selectionEnd); |
| 2253 |
lastSelectionStart = selectionStart; |
| 2254 |
lastSelectionEnd = selectionEnd; |
| 2255 |
} |
| 2256 |
catch (e) { } |
| 2257 |
} |
| 2258 |
inComposition = false; |
| 2259 |
}; |
| 2260 |
this.resetSelection = resetSelection; |
| 2261 |
if (isFocused) |
| 2262 |
host.onFocus(); |
| 2263 |
var isAllSelected = function (text) { |
| 2264 |
return text.selectionStart === 0 && text.selectionEnd >= lastValue.length |
| 2265 |
&& text.value === lastValue && lastValue |
| 2266 |
&& text.selectionEnd !== lastSelectionEnd; |
| 2267 |
}; |
| 2268 |
var onSelect = function (e) { |
| 2269 |
if (inComposition) |
| 2270 |
return; |
| 2271 |
if (copied) { |
| 2272 |
copied = false; |
| 2273 |
} |
| 2274 |
else if (isAllSelected(text)) { |
| 2275 |
host.selectAll(); |
| 2276 |
resetSelection(); |
| 2277 |
} |
| 2278 |
else if (isMobile && text.selectionStart != lastSelectionStart) { |
| 2279 |
resetSelection(); |
| 2280 |
} |
| 2281 |
}; |
| 2282 |
var inputHandler = null; |
| 2283 |
this.setInputHandler = function (cb) { inputHandler = cb; }; |
| 2284 |
this.getInputHandler = function () { return inputHandler; }; |
| 2285 |
var afterContextMenu = false; |
| 2286 |
var sendText = function (value, fromInput) { |
| 2287 |
if (afterContextMenu) |
| 2288 |
afterContextMenu = false; |
| 2289 |
if (pasted) { |
| 2290 |
resetSelection(); |
| 2291 |
if (value) |
| 2292 |
host.onPaste(value); |
| 2293 |
pasted = false; |
| 2294 |
return ""; |
| 2295 |
} |
| 2296 |
else { |
| 2297 |
var selectionStart = text.selectionStart; |
| 2298 |
var selectionEnd = text.selectionEnd; |
| 2299 |
var extendLeft = lastSelectionStart; |
| 2300 |
var extendRight = lastValue.length - lastSelectionEnd; |
| 2301 |
var inserted = value; |
| 2302 |
var restoreStart = value.length - selectionStart; |
| 2303 |
var restoreEnd = value.length - selectionEnd; |
| 2304 |
var i = 0; |
| 2305 |
while (extendLeft > 0 && lastValue[i] == value[i]) { |
| 2306 |
i++; |
| 2307 |
extendLeft--; |
| 2308 |
} |
| 2309 |
inserted = inserted.slice(i); |
| 2310 |
i = 1; |
| 2311 |
while (extendRight > 0 && lastValue.length - i > lastSelectionStart - 1 && lastValue[lastValue.length - i] == value[value.length - i]) { |
| 2312 |
i++; |
| 2313 |
extendRight--; |
| 2314 |
} |
| 2315 |
restoreStart -= i - 1; |
| 2316 |
restoreEnd -= i - 1; |
| 2317 |
var endIndex = inserted.length - i + 1; |
| 2318 |
if (endIndex < 0) { |
| 2319 |
extendLeft = -endIndex; |
| 2320 |
endIndex = 0; |
| 2321 |
} |
| 2322 |
inserted = inserted.slice(0, endIndex); |
| 2323 |
if (!fromInput && !inserted && !restoreStart && !extendLeft && !extendRight && !restoreEnd) |
| 2324 |
return ""; |
| 2325 |
sendingText = true; |
| 2326 |
var shouldReset = false; |
| 2327 |
if (useragent.isAndroid && inserted == ". ") { |
| 2328 |
inserted = " "; |
| 2329 |
shouldReset = true; |
| 2330 |
} |
| 2331 |
if (inserted && !extendLeft && !extendRight && !restoreStart && !restoreEnd || commandMode) { |
| 2332 |
host.onTextInput(inserted); |
| 2333 |
} |
| 2334 |
else { |
| 2335 |
host.onTextInput(inserted, { |
| 2336 |
extendLeft: extendLeft, |
| 2337 |
extendRight: extendRight, |
| 2338 |
restoreStart: restoreStart, |
| 2339 |
restoreEnd: restoreEnd |
| 2340 |
}); |
| 2341 |
} |
| 2342 |
sendingText = false; |
| 2343 |
lastValue = value; |
| 2344 |
lastSelectionStart = selectionStart; |
| 2345 |
lastSelectionEnd = selectionEnd; |
| 2346 |
lastRestoreEnd = restoreEnd; |
| 2347 |
return shouldReset ? "\n" : inserted; |
| 2348 |
} |
| 2349 |
}; |
| 2350 |
var onInput = function (e) { |
| 2351 |
if (inComposition) |
| 2352 |
return onCompositionUpdate(); |
| 2353 |
if (e && e.inputType) { |
| 2354 |
if (e.inputType == "historyUndo") |
| 2355 |
return host.execCommand("undo"); |
| 2356 |
if (e.inputType == "historyRedo") |
| 2357 |
return host.execCommand("redo"); |
| 2358 |
} |
| 2359 |
var data = text.value; |
| 2360 |
var inserted = sendText(data, true); |
| 2361 |
if (data.length > MAX_LINE_LENGTH + 100 |
| 2362 |
|| valueResetRegex.test(inserted) |
| 2363 |
|| isMobile && lastSelectionStart < 1 && lastSelectionStart == lastSelectionEnd) { |
| 2364 |
resetSelection(); |
| 2365 |
} |
| 2366 |
}; |
| 2367 |
var handleClipboardData = function (e, data, forceIEMime) { |
| 2368 |
var clipboardData = e.clipboardData || window["clipboardData"]; |
| 2369 |
if (!clipboardData || BROKEN_SETDATA) |
| 2370 |
return; |
| 2371 |
var mime = USE_IE_MIME_TYPE || forceIEMime ? "Text" : "text/plain"; |
| 2372 |
try { |
| 2373 |
if (data) { |
| 2374 |
return clipboardData.setData(mime, data) !== false; |
| 2375 |
} |
| 2376 |
else { |
| 2377 |
return clipboardData.getData(mime); |
| 2378 |
} |
| 2379 |
} |
| 2380 |
catch (e) { |
| 2381 |
if (!forceIEMime) |
| 2382 |
return handleClipboardData(e, data, true); |
| 2383 |
} |
| 2384 |
}; |
| 2385 |
var doCopy = function (e, isCut) { |
| 2386 |
var data = host.getCopyText(); |
| 2387 |
if (!data) |
| 2388 |
return event.preventDefault(e); |
| 2389 |
if (handleClipboardData(e, data)) { |
| 2390 |
if (isIOS) { |
| 2391 |
resetSelection(data); |
| 2392 |
copied = data; |
| 2393 |
setTimeout(function () { |
| 2394 |
copied = false; |
| 2395 |
}, 10); |
| 2396 |
} |
| 2397 |
isCut ? host.onCut() : host.onCopy(); |
| 2398 |
event.preventDefault(e); |
| 2399 |
} |
| 2400 |
else { |
| 2401 |
copied = true; |
| 2402 |
text.value = data; |
| 2403 |
text.select(); |
| 2404 |
setTimeout(function () { |
| 2405 |
copied = false; |
| 2406 |
resetSelection(); |
| 2407 |
isCut ? host.onCut() : host.onCopy(); |
| 2408 |
}); |
| 2409 |
} |
| 2410 |
}; |
| 2411 |
var onCut = function (e) { |
| 2412 |
doCopy(e, true); |
| 2413 |
}; |
| 2414 |
var onCopy = function (e) { |
| 2415 |
doCopy(e, false); |
| 2416 |
}; |
| 2417 |
var onPaste = function (e) { |
| 2418 |
var data = handleClipboardData(e); |
| 2419 |
if (clipboard.pasteCancelled()) |
| 2420 |
return; |
| 2421 |
if (typeof data == "string") { |
| 2422 |
if (data) |
| 2423 |
host.onPaste(data, e); |
| 2424 |
if (useragent.isIE) |
| 2425 |
setTimeout(resetSelection); |
| 2426 |
event.preventDefault(e); |
| 2427 |
} |
| 2428 |
else { |
| 2429 |
text.value = ""; |
| 2430 |
pasted = true; |
| 2431 |
} |
| 2432 |
}; |
| 2433 |
event.addCommandKeyListener(text, function (e, hashId, keyCode) { |
| 2434 |
if (inComposition) |
| 2435 |
return; |
| 2436 |
return host.onCommandKey(e, hashId, keyCode); |
| 2437 |
}, host); |
| 2438 |
event.addListener(text, "select", onSelect, host); |
| 2439 |
event.addListener(text, "input", onInput, host); |
| 2440 |
event.addListener(text, "cut", onCut, host); |
| 2441 |
event.addListener(text, "copy", onCopy, host); |
| 2442 |
event.addListener(text, "paste", onPaste, host); |
| 2443 |
if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)) { |
| 2444 |
event.addListener(parentNode, "keydown", function (e) { |
| 2445 |
if ((useragent.isMac && !e.metaKey) || !e.ctrlKey) |
| 2446 |
return; |
| 2447 |
switch (e.keyCode) { |
| 2448 |
case 67: |
| 2449 |
onCopy(e); |
| 2450 |
break; |
| 2451 |
case 86: |
| 2452 |
onPaste(e); |
| 2453 |
break; |
| 2454 |
case 88: |
| 2455 |
onCut(e); |
| 2456 |
break; |
| 2457 |
} |
| 2458 |
}, host); |
| 2459 |
} |
| 2460 |
var onCompositionStart = function (e) { |
| 2461 |
if (inComposition || !host.onCompositionStart || host.$readOnly) |
| 2462 |
return; |
| 2463 |
inComposition = {}; |
| 2464 |
if (commandMode) |
| 2465 |
return; |
| 2466 |
if (e.data) |
| 2467 |
inComposition.useTextareaForIME = false; |
| 2468 |
setTimeout(onCompositionUpdate, 0); |
| 2469 |
host._signal("compositionStart"); |
| 2470 |
host.on("mousedown", cancelComposition); |
| 2471 |
var range = host.getSelectionRange(); |
| 2472 |
range.end.row = range.start.row; |
| 2473 |
range.end.column = range.start.column; |
| 2474 |
inComposition.markerRange = range; |
| 2475 |
inComposition.selectionStart = lastSelectionStart; |
| 2476 |
host.onCompositionStart(inComposition); |
| 2477 |
if (inComposition.useTextareaForIME) { |
| 2478 |
lastValue = text.value = ""; |
| 2479 |
lastSelectionStart = 0; |
| 2480 |
lastSelectionEnd = 0; |
| 2481 |
} |
| 2482 |
else { |
| 2483 |
if (text.msGetInputContext) |
| 2484 |
inComposition.context = text.msGetInputContext(); |
| 2485 |
if (text.getInputContext) |
| 2486 |
inComposition.context = text.getInputContext(); |
| 2487 |
} |
| 2488 |
}; |
| 2489 |
var onCompositionUpdate = function () { |
| 2490 |
if (!inComposition || !host.onCompositionUpdate || host.$readOnly) |
| 2491 |
return; |
| 2492 |
if (commandMode) |
| 2493 |
return cancelComposition(); |
| 2494 |
if (inComposition.useTextareaForIME) { |
| 2495 |
host.onCompositionUpdate(text.value); |
| 2496 |
} |
| 2497 |
else { |
| 2498 |
var data = text.value; |
| 2499 |
sendText(data); |
| 2500 |
if (inComposition.markerRange) { |
| 2501 |
if (inComposition.context) { |
| 2502 |
inComposition.markerRange.start.column = inComposition.selectionStart |
| 2503 |
= inComposition.context.compositionStartOffset; |
| 2504 |
} |
| 2505 |
inComposition.markerRange.end.column = inComposition.markerRange.start.column |
| 2506 |
+ lastSelectionEnd - inComposition.selectionStart + lastRestoreEnd; |
| 2507 |
} |
| 2508 |
} |
| 2509 |
}; |
| 2510 |
var onCompositionEnd = function (e) { |
| 2511 |
if (!host.onCompositionEnd || host.$readOnly) |
| 2512 |
return; |
| 2513 |
inComposition = false; |
| 2514 |
host.onCompositionEnd(); |
| 2515 |
host.off("mousedown", cancelComposition); |
| 2516 |
if (e) |
| 2517 |
onInput(); |
| 2518 |
}; |
| 2519 |
function cancelComposition() { |
| 2520 |
ignoreFocusEvents = true; |
| 2521 |
text.blur(); |
| 2522 |
text.focus(); |
| 2523 |
ignoreFocusEvents = false; |
| 2524 |
} |
| 2525 |
var syncComposition = lang.delayedCall(onCompositionUpdate, 50).schedule.bind(null, null); |
| 2526 |
function onKeyup(e) { |
| 2527 |
if (e.keyCode == 27 && text.value.length < text.selectionStart) { |
| 2528 |
if (!inComposition) |
| 2529 |
lastValue = text.value; |
| 2530 |
lastSelectionStart = lastSelectionEnd = -1; |
| 2531 |
resetSelection(); |
| 2532 |
} |
| 2533 |
syncComposition(); |
| 2534 |
} |
| 2535 |
event.addListener(text, "compositionstart", onCompositionStart, host); |
| 2536 |
event.addListener(text, "compositionupdate", onCompositionUpdate, host); |
| 2537 |
event.addListener(text, "keyup", onKeyup, host); |
| 2538 |
event.addListener(text, "keydown", syncComposition, host); |
| 2539 |
event.addListener(text, "compositionend", onCompositionEnd, host); |
| 2540 |
this.getElement = function () { |
| 2541 |
return text; |
| 2542 |
}; |
| 2543 |
this.setCommandMode = function (value) { |
| 2544 |
commandMode = value; |
| 2545 |
text.readOnly = false; |
| 2546 |
}; |
| 2547 |
this.setReadOnly = function (readOnly) { |
| 2548 |
if (!commandMode) |
| 2549 |
text.readOnly = readOnly; |
| 2550 |
}; |
| 2551 |
this.setCopyWithEmptySelection = function (value) { |
| 2552 |
}; |
| 2553 |
this.onContextMenu = function (e) { |
| 2554 |
afterContextMenu = true; |
| 2555 |
resetSelection(); |
| 2556 |
host._emit("nativecontextmenu", { target: host, domEvent: e }); |
| 2557 |
this.moveToMouse(e, true); |
| 2558 |
}; |
| 2559 |
this.moveToMouse = function (e, bringToFront) { |
| 2560 |
if (!tempStyle) |
| 2561 |
tempStyle = text.style.cssText; |
| 2562 |
text.style.cssText = (bringToFront ? "z-index:100000;" : "") |
| 2563 |
+ (useragent.isIE ? "opacity:0.1;" : "") |
| 2564 |
+ "text-indent: -" + (lastSelectionStart + lastSelectionEnd) * host.renderer.characterWidth * 0.5 + "px;"; |
| 2565 |
var rect = host.container.getBoundingClientRect(); |
| 2566 |
var style = dom.computedStyle(host.container); |
| 2567 |
var top = rect.top + (parseInt(style.borderTopWidth) || 0); |
| 2568 |
var left = rect.left + (parseInt(rect.borderLeftWidth) || 0); |
| 2569 |
var maxTop = rect.bottom - top - text.clientHeight - 2; |
| 2570 |
var move = function (e) { |
| 2571 |
dom.translate(text, e.clientX - left - 2, Math.min(e.clientY - top - 2, maxTop)); |
| 2572 |
}; |
| 2573 |
move(e); |
| 2574 |
if (e.type != "mousedown") |
| 2575 |
return; |
| 2576 |
host.renderer.$isMousePressed = true; |
| 2577 |
clearTimeout(closeTimeout); |
| 2578 |
if (useragent.isWin) |
| 2579 |
event.capture(host.container, move, onContextMenuClose); |
| 2580 |
}; |
| 2581 |
this.onContextMenuClose = onContextMenuClose; |
| 2582 |
var closeTimeout; |
| 2583 |
function onContextMenuClose() { |
| 2584 |
clearTimeout(closeTimeout); |
| 2585 |
closeTimeout = setTimeout(function () { |
| 2586 |
if (tempStyle) { |
| 2587 |
text.style.cssText = tempStyle; |
| 2588 |
tempStyle = ''; |
| 2589 |
} |
| 2590 |
host.renderer.$isMousePressed = false; |
| 2591 |
if (host.renderer.$keepTextAreaAtCursor) |
| 2592 |
host.renderer.$moveTextAreaToCursor(); |
| 2593 |
}, 0); |
| 2594 |
} |
| 2595 |
var onContextMenu = function (e) { |
| 2596 |
host.textInput.onContextMenu(e); |
| 2597 |
onContextMenuClose(); |
| 2598 |
}; |
| 2599 |
event.addListener(text, "mouseup", onContextMenu, host); |
| 2600 |
event.addListener(text, "mousedown", function (e) { |
| 2601 |
e.preventDefault(); |
| 2602 |
onContextMenuClose(); |
| 2603 |
}, host); |
| 2604 |
event.addListener(host.renderer.scroller, "contextmenu", onContextMenu, host); |
| 2605 |
event.addListener(text, "contextmenu", onContextMenu, host); |
| 2606 |
if (isIOS) |
| 2607 |
addIosSelectionHandler(parentNode, host, text); |
| 2608 |
function addIosSelectionHandler(parentNode, host, text) { |
| 2609 |
var typingResetTimeout = null; |
| 2610 |
var typing = false; |
| 2611 |
text.addEventListener("keydown", function (e) { |
| 2612 |
if (typingResetTimeout) |
| 2613 |
clearTimeout(typingResetTimeout); |
| 2614 |
typing = true; |
| 2615 |
}, true); |
| 2616 |
text.addEventListener("keyup", function (e) { |
| 2617 |
typingResetTimeout = setTimeout(function () { |
| 2618 |
typing = false; |
| 2619 |
}, 100); |
| 2620 |
}, true); |
| 2621 |
var detectArrowKeys = function (e) { |
| 2622 |
if (document.activeElement !== text) |
| 2623 |
return; |
| 2624 |
if (typing || inComposition || host.$mouseHandler.isMousePressed) |
| 2625 |
return; |
| 2626 |
if (copied) { |
| 2627 |
return; |
| 2628 |
} |
| 2629 |
var selectionStart = text.selectionStart; |
| 2630 |
var selectionEnd = text.selectionEnd; |
| 2631 |
var key = null; |
| 2632 |
var modifier = 0; |
| 2633 |
if (selectionStart == 0) { |
| 2634 |
key = KEYS.up; |
| 2635 |
} |
| 2636 |
else if (selectionStart == 1) { |
| 2637 |
key = KEYS.home; |
| 2638 |
} |
| 2639 |
else if (selectionEnd > lastSelectionEnd && lastValue[selectionEnd] == "\n") { |
| 2640 |
key = KEYS.end; |
| 2641 |
} |
| 2642 |
else if (selectionStart < lastSelectionStart && lastValue[selectionStart - 1] == " ") { |
| 2643 |
key = KEYS.left; |
| 2644 |
modifier = MODS.option; |
| 2645 |
} |
| 2646 |
else if (selectionStart < lastSelectionStart |
| 2647 |
|| (selectionStart == lastSelectionStart |
| 2648 |
&& lastSelectionEnd != lastSelectionStart |
| 2649 |
&& selectionStart == selectionEnd)) { |
| 2650 |
key = KEYS.left; |
| 2651 |
} |
| 2652 |
else if (selectionEnd > lastSelectionEnd && lastValue.slice(0, selectionEnd).split("\n").length > 2) { |
| 2653 |
key = KEYS.down; |
| 2654 |
} |
| 2655 |
else if (selectionEnd > lastSelectionEnd && lastValue[selectionEnd - 1] == " ") { |
| 2656 |
key = KEYS.right; |
| 2657 |
modifier = MODS.option; |
| 2658 |
} |
| 2659 |
else if (selectionEnd > lastSelectionEnd |
| 2660 |
|| (selectionEnd == lastSelectionEnd |
| 2661 |
&& lastSelectionEnd != lastSelectionStart |
| 2662 |
&& selectionStart == selectionEnd)) { |
| 2663 |
key = KEYS.right; |
| 2664 |
} |
| 2665 |
if (selectionStart !== selectionEnd) |
| 2666 |
modifier |= MODS.shift; |
| 2667 |
if (key) { |
| 2668 |
var result = host.onCommandKey({}, modifier, key); |
| 2669 |
if (!result && host.commands) { |
| 2670 |
key = KEYS.keyCodeToString(key); |
| 2671 |
var command = host.commands.findKeyCommand(modifier, key); |
| 2672 |
if (command) |
| 2673 |
host.execCommand(command); |
| 2674 |
} |
| 2675 |
lastSelectionStart = selectionStart; |
| 2676 |
lastSelectionEnd = selectionEnd; |
| 2677 |
resetSelection(""); |
| 2678 |
} |
| 2679 |
}; |
| 2680 |
document.addEventListener("selectionchange", detectArrowKeys); |
| 2681 |
host.on("destroy", function () { |
| 2682 |
document.removeEventListener("selectionchange", detectArrowKeys); |
| 2683 |
}); |
| 2684 |
} |
| 2685 |
this.destroy = function () { |
| 2686 |
if (text.parentElement) |
| 2687 |
text.parentElement.removeChild(text); |
| 2688 |
}; |
| 2689 |
}; |
| 2690 |
exports.TextInput = TextInput; |
| 2691 |
exports.$setUserAgentForTests = function (_isMobile, _isIOS) { |
| 2692 |
isMobile = _isMobile; |
| 2693 |
isIOS = _isIOS; |
| 2694 |
}; |
| 2695 |
|
| 2696 |
}); |
| 2697 |
|
| 2698 |
ace.define("ace/mouse/default_handlers",["require","exports","module","ace/lib/useragent"], function(require, exports, module){"use strict"; |
| 2699 |
var useragent = require("../lib/useragent"); |
| 2700 |
var DRAG_OFFSET = 0; |
| 2701 |
var SCROLL_COOLDOWN_T = 550; |
| 2702 |
var DefaultHandlers = (function () { |
| 2703 |
function DefaultHandlers(mouseHandler) { |
| 2704 |
mouseHandler.$clickSelection = null; |
| 2705 |
var editor = mouseHandler.editor; |
| 2706 |
editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler)); |
| 2707 |
editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(mouseHandler)); |
| 2708 |
editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(mouseHandler)); |
| 2709 |
editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler)); |
| 2710 |
editor.setDefaultHandler("mousewheel", this.onMouseWheel.bind(mouseHandler)); |
| 2711 |
var exports = ["select", "startSelect", "selectEnd", "selectAllEnd", "selectByWordsEnd", |
| 2712 |
"selectByLinesEnd", "dragWait", "dragWaitEnd", "focusWait"]; |
| 2713 |
exports.forEach(function (x) { |
| 2714 |
mouseHandler[x] = this[x]; |
| 2715 |
}, this); |
| 2716 |
mouseHandler["selectByLines"] = this.extendSelectionBy.bind(mouseHandler, "getLineRange"); |
| 2717 |
mouseHandler["selectByWords"] = this.extendSelectionBy.bind(mouseHandler, "getWordRange"); |
| 2718 |
} |
| 2719 |
DefaultHandlers.prototype.onMouseDown = function (ev) { |
| 2720 |
var inSelection = ev.inSelection(); |
| 2721 |
var pos = ev.getDocumentPosition(); |
| 2722 |
this.mousedownEvent = ev; |
| 2723 |
var editor = this.editor; |
| 2724 |
var button = ev.getButton(); |
| 2725 |
if (button !== 0) { |
| 2726 |
var selectionRange = editor.getSelectionRange(); |
| 2727 |
var selectionEmpty = selectionRange.isEmpty(); |
| 2728 |
if (selectionEmpty || button == 1) |
| 2729 |
editor.selection.moveToPosition(pos); |
| 2730 |
if (button == 2) { |
| 2731 |
editor.textInput.onContextMenu(ev.domEvent); |
| 2732 |
if (!useragent.isMozilla) |
| 2733 |
ev.preventDefault(); |
| 2734 |
} |
| 2735 |
return; |
| 2736 |
} |
| 2737 |
this.mousedownEvent.time = Date.now(); |
| 2738 |
if (inSelection && !editor.isFocused()) { |
| 2739 |
editor.focus(); |
| 2740 |
if (this.$focusTimeout && !this.$clickSelection && !editor.inMultiSelectMode) { |
| 2741 |
this.setState("focusWait"); |
| 2742 |
this.captureMouse(ev); |
| 2743 |
return; |
| 2744 |
} |
| 2745 |
} |
| 2746 |
this.captureMouse(ev); |
| 2747 |
this.startSelect(pos, ev.domEvent._clicks > 1); |
| 2748 |
return ev.preventDefault(); |
| 2749 |
}; |
| 2750 |
DefaultHandlers.prototype.startSelect = function (pos, waitForClickSelection) { |
| 2751 |
pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y); |
| 2752 |
var editor = this.editor; |
| 2753 |
if (!this.mousedownEvent) |
| 2754 |
return; |
| 2755 |
if (this.mousedownEvent.getShiftKey()) |
| 2756 |
editor.selection.selectToPosition(pos); |
| 2757 |
else if (!waitForClickSelection) |
| 2758 |
editor.selection.moveToPosition(pos); |
| 2759 |
if (!waitForClickSelection) |
| 2760 |
this.select(); |
| 2761 |
editor.setStyle("ace_selecting"); |
| 2762 |
this.setState("select"); |
| 2763 |
}; |
| 2764 |
DefaultHandlers.prototype.select = function () { |
| 2765 |
var anchor, editor = this.editor; |
| 2766 |
var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y); |
| 2767 |
if (this.$clickSelection) { |
| 2768 |
var cmp = this.$clickSelection.comparePoint(cursor); |
| 2769 |
if (cmp == -1) { |
| 2770 |
anchor = this.$clickSelection.end; |
| 2771 |
} |
| 2772 |
else if (cmp == 1) { |
| 2773 |
anchor = this.$clickSelection.start; |
| 2774 |
} |
| 2775 |
else { |
| 2776 |
var orientedRange = calcRangeOrientation(this.$clickSelection, cursor); |
| 2777 |
cursor = orientedRange.cursor; |
| 2778 |
anchor = orientedRange.anchor; |
| 2779 |
} |
| 2780 |
editor.selection.setSelectionAnchor(anchor.row, anchor.column); |
| 2781 |
} |
| 2782 |
editor.selection.selectToPosition(cursor); |
| 2783 |
editor.renderer.scrollCursorIntoView(); |
| 2784 |
}; |
| 2785 |
DefaultHandlers.prototype.extendSelectionBy = function (unitName) { |
| 2786 |
var anchor, editor = this.editor; |
| 2787 |
var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y); |
| 2788 |
var range = editor.selection[unitName](cursor.row, cursor.column); |
| 2789 |
if (this.$clickSelection) { |
| 2790 |
var cmpStart = this.$clickSelection.comparePoint(range.start); |
| 2791 |
var cmpEnd = this.$clickSelection.comparePoint(range.end); |
| 2792 |
if (cmpStart == -1 && cmpEnd <= 0) { |
| 2793 |
anchor = this.$clickSelection.end; |
| 2794 |
if (range.end.row != cursor.row || range.end.column != cursor.column) |
| 2795 |
cursor = range.start; |
| 2796 |
} |
| 2797 |
else if (cmpEnd == 1 && cmpStart >= 0) { |
| 2798 |
anchor = this.$clickSelection.start; |
| 2799 |
if (range.start.row != cursor.row || range.start.column != cursor.column) |
| 2800 |
cursor = range.end; |
| 2801 |
} |
| 2802 |
else if (cmpStart == -1 && cmpEnd == 1) { |
| 2803 |
cursor = range.end; |
| 2804 |
anchor = range.start; |
| 2805 |
} |
| 2806 |
else { |
| 2807 |
var orientedRange = calcRangeOrientation(this.$clickSelection, cursor); |
| 2808 |
cursor = orientedRange.cursor; |
| 2809 |
anchor = orientedRange.anchor; |
| 2810 |
} |
| 2811 |
editor.selection.setSelectionAnchor(anchor.row, anchor.column); |
| 2812 |
} |
| 2813 |
editor.selection.selectToPosition(cursor); |
| 2814 |
editor.renderer.scrollCursorIntoView(); |
| 2815 |
}; |
| 2816 |
DefaultHandlers.prototype.selectByLinesEnd = function () { |
| 2817 |
this.$clickSelection = null; |
| 2818 |
this.editor.unsetStyle("ace_selecting"); |
| 2819 |
}; |
| 2820 |
DefaultHandlers.prototype.focusWait = function () { |
| 2821 |
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y); |
| 2822 |
var time = Date.now(); |
| 2823 |
if (distance > DRAG_OFFSET || time - this.mousedownEvent.time > this.$focusTimeout) |
| 2824 |
this.startSelect(this.mousedownEvent.getDocumentPosition()); |
| 2825 |
}; |
| 2826 |
DefaultHandlers.prototype.onDoubleClick = function (ev) { |
| 2827 |
var pos = ev.getDocumentPosition(); |
| 2828 |
var editor = this.editor; |
| 2829 |
var session = editor.session; |
| 2830 |
var range = session.getBracketRange(pos); |
| 2831 |
if (range) { |
| 2832 |
if (range.isEmpty()) { |
| 2833 |
range.start.column--; |
| 2834 |
range.end.column++; |
| 2835 |
} |
| 2836 |
this.setState("select"); |
| 2837 |
} |
| 2838 |
else { |
| 2839 |
range = editor.selection.getWordRange(pos.row, pos.column); |
| 2840 |
this.setState("selectByWords"); |
| 2841 |
} |
| 2842 |
this.$clickSelection = range; |
| 2843 |
this.select(); |
| 2844 |
}; |
| 2845 |
DefaultHandlers.prototype.onTripleClick = function (ev) { |
| 2846 |
var pos = ev.getDocumentPosition(); |
| 2847 |
var editor = this.editor; |
| 2848 |
this.setState("selectByLines"); |
| 2849 |
var range = editor.getSelectionRange(); |
| 2850 |
if (range.isMultiLine() && range.contains(pos.row, pos.column)) { |
| 2851 |
this.$clickSelection = editor.selection.getLineRange(range.start.row); |
| 2852 |
this.$clickSelection.end = editor.selection.getLineRange(range.end.row).end; |
| 2853 |
} |
| 2854 |
else { |
| 2855 |
this.$clickSelection = editor.selection.getLineRange(pos.row); |
| 2856 |
} |
| 2857 |
this.select(); |
| 2858 |
}; |
| 2859 |
DefaultHandlers.prototype.onQuadClick = function (ev) { |
| 2860 |
var editor = this.editor; |
| 2861 |
editor.selectAll(); |
| 2862 |
this.$clickSelection = editor.getSelectionRange(); |
| 2863 |
this.setState("selectAll"); |
| 2864 |
}; |
| 2865 |
DefaultHandlers.prototype.onMouseWheel = function (ev) { |
| 2866 |
if (ev.getAccelKey()) |
| 2867 |
return; |
| 2868 |
if (ev.getShiftKey() && ev.wheelY && !ev.wheelX) { |
| 2869 |
ev.wheelX = ev.wheelY; |
| 2870 |
ev.wheelY = 0; |
| 2871 |
} |
| 2872 |
var editor = this.editor; |
| 2873 |
if (!this.$lastScroll) |
| 2874 |
this.$lastScroll = { t: 0, vx: 0, vy: 0, allowed: 0 }; |
| 2875 |
var prevScroll = this.$lastScroll; |
| 2876 |
var t = ev.domEvent.timeStamp; |
| 2877 |
var dt = t - prevScroll.t; |
| 2878 |
var vx = dt ? ev.wheelX / dt : prevScroll.vx; |
| 2879 |
var vy = dt ? ev.wheelY / dt : prevScroll.vy; |
| 2880 |
if (dt < SCROLL_COOLDOWN_T) { |
| 2881 |
vx = (vx + prevScroll.vx) / 2; |
| 2882 |
vy = (vy + prevScroll.vy) / 2; |
| 2883 |
} |
| 2884 |
var direction = Math.abs(vx / vy); |
| 2885 |
var canScroll = false; |
| 2886 |
if (direction >= 1 && editor.renderer.isScrollableBy(ev.wheelX * ev.speed, 0)) |
| 2887 |
canScroll = true; |
| 2888 |
if (direction <= 1 && editor.renderer.isScrollableBy(0, ev.wheelY * ev.speed)) |
| 2889 |
canScroll = true; |
| 2890 |
if (canScroll) { |
| 2891 |
prevScroll.allowed = t; |
| 2892 |
} |
| 2893 |
else if (t - prevScroll.allowed < SCROLL_COOLDOWN_T) { |
| 2894 |
var isSlower = Math.abs(vx) <= 1.5 * Math.abs(prevScroll.vx) |
| 2895 |
&& Math.abs(vy) <= 1.5 * Math.abs(prevScroll.vy); |
| 2896 |
if (isSlower) { |
| 2897 |
canScroll = true; |
| 2898 |
prevScroll.allowed = t; |
| 2899 |
} |
| 2900 |
else { |
| 2901 |
prevScroll.allowed = 0; |
| 2902 |
} |
| 2903 |
} |
| 2904 |
prevScroll.t = t; |
| 2905 |
prevScroll.vx = vx; |
| 2906 |
prevScroll.vy = vy; |
| 2907 |
if (canScroll) { |
| 2908 |
editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed); |
| 2909 |
return ev.stop(); |
| 2910 |
} |
| 2911 |
}; |
| 2912 |
return DefaultHandlers; |
| 2913 |
}()); |
| 2914 |
DefaultHandlers.prototype.selectEnd = DefaultHandlers.prototype.selectByLinesEnd; |
| 2915 |
DefaultHandlers.prototype.selectAllEnd = DefaultHandlers.prototype.selectByLinesEnd; |
| 2916 |
DefaultHandlers.prototype.selectByWordsEnd = DefaultHandlers.prototype.selectByLinesEnd; |
| 2917 |
exports.DefaultHandlers = DefaultHandlers; |
| 2918 |
function calcDistance(ax, ay, bx, by) { |
| 2919 |
return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2)); |
| 2920 |
} |
| 2921 |
function calcRangeOrientation(range, cursor) { |
| 2922 |
if (range.start.row == range.end.row) |
| 2923 |
var cmp = 2 * cursor.column - range.start.column - range.end.column; |
| 2924 |
else if (range.start.row == range.end.row - 1 && !range.start.column && !range.end.column) |
| 2925 |
var cmp = cursor.column - 4; |
| 2926 |
else |
| 2927 |
var cmp = 2 * cursor.row - range.start.row - range.end.row; |
| 2928 |
if (cmp < 0) |
| 2929 |
return { cursor: range.start, anchor: range.end }; |
| 2930 |
else |
| 2931 |
return { cursor: range.end, anchor: range.start }; |
| 2932 |
} |
| 2933 |
|
| 2934 |
}); |
| 2935 |
|
| 2936 |
ace.define("ace/lib/scroll",["require","exports","module"], function(require, exports, module){exports.preventParentScroll = function preventParentScroll(event) { |
| 2937 |
event.stopPropagation(); |
| 2938 |
var target = event.currentTarget; |
| 2939 |
var contentOverflows = target.scrollHeight > target.clientHeight; |
| 2940 |
if (!contentOverflows) { |
| 2941 |
event.preventDefault(); |
| 2942 |
} |
| 2943 |
}; |
| 2944 |
|
| 2945 |
}); |
| 2946 |
|
| 2947 |
ace.define("ace/tooltip",["require","exports","module","ace/lib/dom","ace/lib/event","ace/range","ace/lib/scroll"], function(require, exports, module){"use strict"; |
| 2948 |
var __extends = (this && this.__extends) || (function () { |
| 2949 |
var extendStatics = function (d, b) { |
| 2950 |
extendStatics = Object.setPrototypeOf || |
| 2951 |
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
| 2952 |
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; |
| 2953 |
return extendStatics(d, b); |
| 2954 |
}; |
| 2955 |
return function (d, b) { |
| 2956 |
if (typeof b !== "function" && b !== null) |
| 2957 |
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); |
| 2958 |
extendStatics(d, b); |
| 2959 |
function __() { this.constructor = d; } |
| 2960 |
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
| 2961 |
}; |
| 2962 |
})(); |
| 2963 |
var __values = (this && this.__values) || function(o) { |
| 2964 |
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; |
| 2965 |
if (m) return m.call(o); |
| 2966 |
if (o && typeof o.length === "number") return { |
| 2967 |
next: function () { |
| 2968 |
if (o && i >= o.length) o = void 0; |
| 2969 |
return { value: o && o[i++], done: !o }; |
| 2970 |
} |
| 2971 |
}; |
| 2972 |
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); |
| 2973 |
}; |
| 2974 |
var dom = require("./lib/dom"); |
| 2975 |
var event = require("./lib/event"); |
| 2976 |
var Range = require("./range").Range; |
| 2977 |
var preventParentScroll = require("./lib/scroll").preventParentScroll; |
| 2978 |
var CLASSNAME = "ace_tooltip"; |
| 2979 |
var Tooltip = (function () { |
| 2980 |
function Tooltip(parentNode) { |
| 2981 |
this.isOpen = false; |
| 2982 |
this.$element = null; |
| 2983 |
this.$parentNode = parentNode; |
| 2984 |
} |
| 2985 |
Tooltip.prototype.$init = function () { |
| 2986 |
this.$element = dom.createElement("div"); |
| 2987 |
this.$element.className = CLASSNAME; |
| 2988 |
this.$element.style.display = "none"; |
| 2989 |
this.$parentNode.appendChild(this.$element); |
| 2990 |
return this.$element; |
| 2991 |
}; |
| 2992 |
Tooltip.prototype.getElement = function () { |
| 2993 |
return this.$element || this.$init(); |
| 2994 |
}; |
| 2995 |
Tooltip.prototype.setText = function (text) { |
| 2996 |
this.getElement().textContent = text; |
| 2997 |
}; |
| 2998 |
Tooltip.prototype.setHtml = function (html) { |
| 2999 |
this.getElement().innerHTML = html; |
| 3000 |
}; |
| 3001 |
Tooltip.prototype.setPosition = function (x, y) { |
| 3002 |
this.getElement().style.left = x + "px"; |
| 3003 |
this.getElement().style.top = y + "px"; |
| 3004 |
}; |
| 3005 |
Tooltip.prototype.setClassName = function (className) { |
| 3006 |
dom.addCssClass(this.getElement(), className); |
| 3007 |
}; |
| 3008 |
Tooltip.prototype.setTheme = function (theme) { |
| 3009 |
this.$element.className = CLASSNAME + " " + |
| 3010 |
(theme.isDark ? "ace_dark " : "") + (theme.cssClass || ""); |
| 3011 |
}; |
| 3012 |
Tooltip.prototype.show = function (text, x, y) { |
| 3013 |
if (text != null) |
| 3014 |
this.setText(text); |
| 3015 |
if (x != null && y != null) |
| 3016 |
this.setPosition(x, y); |
| 3017 |
if (!this.isOpen) { |
| 3018 |
this.getElement().style.display = "block"; |
| 3019 |
this.isOpen = true; |
| 3020 |
} |
| 3021 |
}; |
| 3022 |
Tooltip.prototype.hide = function (e) { |
| 3023 |
if (this.isOpen) { |
| 3024 |
this.getElement().style.display = "none"; |
| 3025 |
this.getElement().className = CLASSNAME; |
| 3026 |
this.isOpen = false; |
| 3027 |
} |
| 3028 |
}; |
| 3029 |
Tooltip.prototype.getHeight = function () { |
| 3030 |
return this.getElement().offsetHeight; |
| 3031 |
}; |
| 3032 |
Tooltip.prototype.getWidth = function () { |
| 3033 |
return this.getElement().offsetWidth; |
| 3034 |
}; |
| 3035 |
Tooltip.prototype.destroy = function () { |
| 3036 |
this.isOpen = false; |
| 3037 |
if (this.$element && this.$element.parentNode) { |
| 3038 |
this.$element.parentNode.removeChild(this.$element); |
| 3039 |
} |
| 3040 |
}; |
| 3041 |
return Tooltip; |
| 3042 |
}()); |
| 3043 |
var PopupManager = (function () { |
| 3044 |
function PopupManager() { |
| 3045 |
this.popups = []; |
| 3046 |
} |
| 3047 |
PopupManager.prototype.addPopup = function (popup) { |
| 3048 |
this.popups.push(popup); |
| 3049 |
this.updatePopups(); |
| 3050 |
}; |
| 3051 |
PopupManager.prototype.removePopup = function (popup) { |
| 3052 |
var index = this.popups.indexOf(popup); |
| 3053 |
if (index !== -1) { |
| 3054 |
this.popups.splice(index, 1); |
| 3055 |
this.updatePopups(); |
| 3056 |
} |
| 3057 |
}; |
| 3058 |
PopupManager.prototype.updatePopups = function () { |
| 3059 |
var e_1, _a, e_2, _b; |
| 3060 |
this.popups.sort(function (a, b) { return b.priority - a.priority; }); |
| 3061 |
var visiblepopups = []; |
| 3062 |
try { |
| 3063 |
for (var _c = __values(this.popups), _d = _c.next(); !_d.done; _d = _c.next()) { |
| 3064 |
var popup = _d.value; |
| 3065 |
var shouldDisplay = true; |
| 3066 |
try { |
| 3067 |
for (var visiblepopups_1 = (e_2 = void 0, __values(visiblepopups)), visiblepopups_1_1 = visiblepopups_1.next(); !visiblepopups_1_1.done; visiblepopups_1_1 = visiblepopups_1.next()) { |
| 3068 |
var visiblePopup = visiblepopups_1_1.value; |
| 3069 |
if (this.doPopupsOverlap(visiblePopup, popup)) { |
| 3070 |
shouldDisplay = false; |
| 3071 |
break; |
| 3072 |
} |
| 3073 |
} |
| 3074 |
} |
| 3075 |
catch (e_2_1) { e_2 = { error: e_2_1 }; } |
| 3076 |
finally { |
| 3077 |
try { |
| 3078 |
if (visiblepopups_1_1 && !visiblepopups_1_1.done && (_b = visiblepopups_1.return)) _b.call(visiblepopups_1); |
| 3079 |
} |
| 3080 |
finally { if (e_2) throw e_2.error; } |
| 3081 |
} |
| 3082 |
if (shouldDisplay) { |
| 3083 |
visiblepopups.push(popup); |
| 3084 |
} |
| 3085 |
else { |
| 3086 |
popup.hide(); |
| 3087 |
} |
| 3088 |
} |
| 3089 |
} |
| 3090 |
catch (e_1_1) { e_1 = { error: e_1_1 }; } |
| 3091 |
finally { |
| 3092 |
try { |
| 3093 |
if (_d && !_d.done && (_a = _c.return)) _a.call(_c); |
| 3094 |
} |
| 3095 |
finally { if (e_1) throw e_1.error; } |
| 3096 |
} |
| 3097 |
}; |
| 3098 |
PopupManager.prototype.doPopupsOverlap = function (popupA, popupB) { |
| 3099 |
var rectA = popupA.getElement().getBoundingClientRect(); |
| 3100 |
var rectB = popupB.getElement().getBoundingClientRect(); |
| 3101 |
return (rectA.left < rectB.right && rectA.right > rectB.left && rectA.top < rectB.bottom && rectA.bottom |
| 3102 |
> rectB.top); |
| 3103 |
}; |
| 3104 |
return PopupManager; |
| 3105 |
}()); |
| 3106 |
var popupManager = new PopupManager(); |
| 3107 |
exports.popupManager = popupManager; |
| 3108 |
exports.Tooltip = Tooltip; |
| 3109 |
var HoverTooltip = (function (_super) { |
| 3110 |
__extends(HoverTooltip, _super); |
| 3111 |
function HoverTooltip(parentNode) { |
| 3112 |
if (parentNode === void 0) { parentNode = document.body; } |
| 3113 |
var _this = _super.call(this, parentNode) || this; |
| 3114 |
_this.timeout = undefined; |
| 3115 |
_this.lastT = 0; |
| 3116 |
_this.idleTime = 350; |
| 3117 |
_this.lastEvent = undefined; |
| 3118 |
_this.onMouseOut = _this.onMouseOut.bind(_this); |
| 3119 |
_this.onMouseMove = _this.onMouseMove.bind(_this); |
| 3120 |
_this.waitForHover = _this.waitForHover.bind(_this); |
| 3121 |
_this.hide = _this.hide.bind(_this); |
| 3122 |
var el = _this.getElement(); |
| 3123 |
el.style.whiteSpace = "pre-wrap"; |
| 3124 |
el.style.pointerEvents = "auto"; |
| 3125 |
el.addEventListener("mouseout", _this.onMouseOut); |
| 3126 |
el.tabIndex = -1; |
| 3127 |
el.addEventListener("blur", function () { |
| 3128 |
if (!el.contains(document.activeElement)) |
| 3129 |
this.hide(); |
| 3130 |
}.bind(_this)); |
| 3131 |
el.addEventListener("wheel", preventParentScroll); |
| 3132 |
return _this; |
| 3133 |
} |
| 3134 |
HoverTooltip.prototype.addToEditor = function (editor) { |
| 3135 |
editor.on("mousemove", this.onMouseMove); |
| 3136 |
editor.on("mousedown", this.hide); |
| 3137 |
editor.renderer.getMouseEventTarget().addEventListener("mouseout", this.onMouseOut, true); |
| 3138 |
}; |
| 3139 |
HoverTooltip.prototype.removeFromEditor = function (editor) { |
| 3140 |
editor.off("mousemove", this.onMouseMove); |
| 3141 |
editor.off("mousedown", this.hide); |
| 3142 |
editor.renderer.getMouseEventTarget().removeEventListener("mouseout", this.onMouseOut, true); |
| 3143 |
if (this.timeout) { |
| 3144 |
clearTimeout(this.timeout); |
| 3145 |
this.timeout = null; |
| 3146 |
} |
| 3147 |
}; |
| 3148 |
HoverTooltip.prototype.onMouseMove = function (e, editor) { |
| 3149 |
this.lastEvent = e; |
| 3150 |
this.lastT = Date.now(); |
| 3151 |
var isMousePressed = editor.$mouseHandler.isMousePressed; |
| 3152 |
if (this.isOpen) { |
| 3153 |
var pos = this.lastEvent && this.lastEvent.getDocumentPosition(); |
| 3154 |
if (!this.range |
| 3155 |
|| !this.range.contains(pos.row, pos.column) |
| 3156 |
|| isMousePressed |
| 3157 |
|| this.isOutsideOfText(this.lastEvent)) { |
| 3158 |
this.hide(); |
| 3159 |
} |
| 3160 |
} |
| 3161 |
if (this.timeout || isMousePressed) |
| 3162 |
return; |
| 3163 |
this.lastEvent = e; |
| 3164 |
this.timeout = setTimeout(this.waitForHover, this.idleTime); |
| 3165 |
}; |
| 3166 |
HoverTooltip.prototype.waitForHover = function () { |
| 3167 |
if (this.timeout) |
| 3168 |
clearTimeout(this.timeout); |
| 3169 |
var dt = Date.now() - this.lastT; |
| 3170 |
if (this.idleTime - dt > 10) { |
| 3171 |
this.timeout = setTimeout(this.waitForHover, this.idleTime - dt); |
| 3172 |
return; |
| 3173 |
} |
| 3174 |
this.timeout = null; |
| 3175 |
if (this.lastEvent && !this.isOutsideOfText(this.lastEvent)) { |
| 3176 |
this.$gatherData(this.lastEvent, this.lastEvent.editor); |
| 3177 |
} |
| 3178 |
}; |
| 3179 |
HoverTooltip.prototype.isOutsideOfText = function (e) { |
| 3180 |
var editor = e.editor; |
| 3181 |
var docPos = e.getDocumentPosition(); |
| 3182 |
var line = editor.session.getLine(docPos.row); |
| 3183 |
if (docPos.column == line.length) { |
| 3184 |
var screenPos = editor.renderer.pixelToScreenCoordinates(e.clientX, e.clientY); |
| 3185 |
var clippedPos = editor.session.documentToScreenPosition(docPos.row, docPos.column); |
| 3186 |
if (clippedPos.column != screenPos.column |
| 3187 |
|| clippedPos.row != screenPos.row) { |
| 3188 |
return true; |
| 3189 |
} |
| 3190 |
} |
| 3191 |
return false; |
| 3192 |
}; |
| 3193 |
HoverTooltip.prototype.setDataProvider = function (value) { |
| 3194 |
this.$gatherData = value; |
| 3195 |
}; |
| 3196 |
HoverTooltip.prototype.showForRange = function (editor, range, domNode, startingEvent) { |
| 3197 |
var MARGIN = 10; |
| 3198 |
if (startingEvent && startingEvent != this.lastEvent) |
| 3199 |
return; |
| 3200 |
if (this.isOpen && document.activeElement == this.getElement()) |
| 3201 |
return; |
| 3202 |
var renderer = editor.renderer; |
| 3203 |
if (!this.isOpen) { |
| 3204 |
popupManager.addPopup(this); |
| 3205 |
this.$registerCloseEvents(); |
| 3206 |
this.setTheme(renderer.theme); |
| 3207 |
} |
| 3208 |
this.isOpen = true; |
| 3209 |
this.addMarker(range, editor.session); |
| 3210 |
this.range = Range.fromPoints(range.start, range.end); |
| 3211 |
var position = renderer.textToScreenCoordinates(range.start.row, range.start.column); |
| 3212 |
var rect = renderer.scroller.getBoundingClientRect(); |
| 3213 |
if (position.pageX < rect.left) |
| 3214 |
position.pageX = rect.left; |
| 3215 |
var element = this.getElement(); |
| 3216 |
element.innerHTML = ""; |
| 3217 |
element.appendChild(domNode); |
| 3218 |
element.style.maxHeight = ""; |
| 3219 |
element.style.display = "block"; |
| 3220 |
var labelHeight = element.clientHeight; |
| 3221 |
var labelWidth = element.clientWidth; |
| 3222 |
var spaceBelow = window.innerHeight - position.pageY - renderer.lineHeight; |
| 3223 |
var isAbove = true; |
| 3224 |
if (position.pageY - labelHeight < 0 && position.pageY < spaceBelow) { |
| 3225 |
isAbove = false; |
| 3226 |
} |
| 3227 |
element.style.maxHeight = (isAbove ? position.pageY : spaceBelow) - MARGIN + "px"; |
| 3228 |
element.style.top = isAbove ? "" : position.pageY + renderer.lineHeight + "px"; |
| 3229 |
element.style.bottom = isAbove ? window.innerHeight - position.pageY + "px" : ""; |
| 3230 |
element.style.left = Math.min(position.pageX, window.innerWidth - labelWidth - MARGIN) + "px"; |
| 3231 |
}; |
| 3232 |
HoverTooltip.prototype.addMarker = function (range, session) { |
| 3233 |
if (this.marker) { |
| 3234 |
this.$markerSession.removeMarker(this.marker); |
| 3235 |
} |
| 3236 |
this.$markerSession = session; |
| 3237 |
this.marker = session && session.addMarker(range, "ace_highlight-marker", "text"); |
| 3238 |
}; |
| 3239 |
HoverTooltip.prototype.hide = function (e) { |
| 3240 |
if (!e && document.activeElement == this.getElement()) |
| 3241 |
return; |
| 3242 |
if (e && e.target && (e.type != "keydown" || e.ctrlKey || e.metaKey) && this.$element.contains(e.target)) |
| 3243 |
return; |
| 3244 |
this.lastEvent = null; |
| 3245 |
if (this.timeout) |
| 3246 |
clearTimeout(this.timeout); |
| 3247 |
this.timeout = null; |
| 3248 |
this.addMarker(null); |
| 3249 |
if (this.isOpen) { |
| 3250 |
this.$removeCloseEvents(); |
| 3251 |
this.getElement().style.display = "none"; |
| 3252 |
this.isOpen = false; |
| 3253 |
popupManager.removePopup(this); |
| 3254 |
} |
| 3255 |
}; |
| 3256 |
HoverTooltip.prototype.$registerCloseEvents = function () { |
| 3257 |
window.addEventListener("keydown", this.hide, true); |
| 3258 |
window.addEventListener("wheel", this.hide, true); |
| 3259 |
window.addEventListener("mousedown", this.hide, true); |
| 3260 |
}; |
| 3261 |
HoverTooltip.prototype.$removeCloseEvents = function () { |
| 3262 |
window.removeEventListener("keydown", this.hide, true); |
| 3263 |
window.removeEventListener("wheel", this.hide, true); |
| 3264 |
window.removeEventListener("mousedown", this.hide, true); |
| 3265 |
}; |
| 3266 |
HoverTooltip.prototype.onMouseOut = function (e) { |
| 3267 |
if (this.timeout) { |
| 3268 |
clearTimeout(this.timeout); |
| 3269 |
this.timeout = null; |
| 3270 |
} |
| 3271 |
this.lastEvent = null; |
| 3272 |
if (!this.isOpen) |
| 3273 |
return; |
| 3274 |
if (!e.relatedTarget || this.getElement().contains(e.relatedTarget)) |
| 3275 |
return; |
| 3276 |
if (e && e.currentTarget.contains(e.relatedTarget)) |
| 3277 |
return; |
| 3278 |
if (!e.relatedTarget.classList.contains("ace_content")) |
| 3279 |
this.hide(); |
| 3280 |
}; |
| 3281 |
return HoverTooltip; |
| 3282 |
}(Tooltip)); |
| 3283 |
exports.HoverTooltip = HoverTooltip; |
| 3284 |
|
| 3285 |
}); |
| 3286 |
|
| 3287 |
ace.define("ace/mouse/default_gutter_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/tooltip","ace/config"], function(require, exports, module){"use strict"; |
| 3288 |
var __extends = (this && this.__extends) || (function () { |
| 3289 |
var extendStatics = function (d, b) { |
| 3290 |
extendStatics = Object.setPrototypeOf || |
| 3291 |
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
| 3292 |
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; |
| 3293 |
return extendStatics(d, b); |
| 3294 |
}; |
| 3295 |
return function (d, b) { |
| 3296 |
if (typeof b !== "function" && b !== null) |
| 3297 |
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); |
| 3298 |
extendStatics(d, b); |
| 3299 |
function __() { this.constructor = d; } |
| 3300 |
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
| 3301 |
}; |
| 3302 |
})(); |
| 3303 |
var __values = (this && this.__values) || function(o) { |
| 3304 |
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; |
| 3305 |
if (m) return m.call(o); |
| 3306 |
if (o && typeof o.length === "number") return { |
| 3307 |
next: function () { |
| 3308 |
if (o && i >= o.length) o = void 0; |
| 3309 |
return { value: o && o[i++], done: !o }; |
| 3310 |
} |
| 3311 |
}; |
| 3312 |
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); |
| 3313 |
}; |
| 3314 |
var dom = require("../lib/dom"); |
| 3315 |
var event = require("../lib/event"); |
| 3316 |
var Tooltip = require("../tooltip").Tooltip; |
| 3317 |
var nls = require("../config").nls; |
| 3318 |
function GutterHandler(mouseHandler) { |
| 3319 |
var editor = mouseHandler.editor; |
| 3320 |
var gutter = editor.renderer.$gutterLayer; |
| 3321 |
var tooltip = new GutterTooltip(editor); |
| 3322 |
mouseHandler.editor.setDefaultHandler("guttermousedown", function (e) { |
| 3323 |
if (!editor.isFocused() || e.getButton() != 0) |
| 3324 |
return; |
| 3325 |
var gutterRegion = gutter.getRegion(e); |
| 3326 |
if (gutterRegion == "foldWidgets") |
| 3327 |
return; |
| 3328 |
var row = e.getDocumentPosition().row; |
| 3329 |
var selection = editor.session.selection; |
| 3330 |
if (e.getShiftKey()) |
| 3331 |
selection.selectTo(row, 0); |
| 3332 |
else { |
| 3333 |
if (e.domEvent.detail == 2) { |
| 3334 |
editor.selectAll(); |
| 3335 |
return e.preventDefault(); |
| 3336 |
} |
| 3337 |
mouseHandler.$clickSelection = editor.selection.getLineRange(row); |
| 3338 |
} |
| 3339 |
mouseHandler.setState("selectByLines"); |
| 3340 |
mouseHandler.captureMouse(e); |
| 3341 |
return e.preventDefault(); |
| 3342 |
}); |
| 3343 |
var tooltipTimeout, mouseEvent; |
| 3344 |
function showTooltip() { |
| 3345 |
var row = mouseEvent.getDocumentPosition().row; |
| 3346 |
var maxRow = editor.session.getLength(); |
| 3347 |
if (row == maxRow) { |
| 3348 |
var screenRow = editor.renderer.pixelToScreenCoordinates(0, mouseEvent.y).row; |
| 3349 |
var pos = mouseEvent.$pos; |
| 3350 |
if (screenRow > editor.session.documentToScreenRow(pos.row, pos.column)) |
| 3351 |
return hideTooltip(); |
| 3352 |
} |
| 3353 |
tooltip.showTooltip(row); |
| 3354 |
if (!tooltip.isOpen) |
| 3355 |
return; |
| 3356 |
editor.on("mousewheel", hideTooltip); |
| 3357 |
if (mouseHandler.$tooltipFollowsMouse) { |
| 3358 |
moveTooltip(mouseEvent); |
| 3359 |
} |
| 3360 |
else { |
| 3361 |
var gutterRow = mouseEvent.getGutterRow(); |
| 3362 |
var gutterCell = gutter.$lines.get(gutterRow); |
| 3363 |
if (gutterCell) { |
| 3364 |
var gutterElement = gutterCell.element.querySelector(".ace_gutter_annotation"); |
| 3365 |
var rect = gutterElement.getBoundingClientRect(); |
| 3366 |
var style = tooltip.getElement().style; |
| 3367 |
style.left = rect.right + "px"; |
| 3368 |
style.top = rect.bottom + "px"; |
| 3369 |
} |
| 3370 |
else { |
| 3371 |
moveTooltip(mouseEvent); |
| 3372 |
} |
| 3373 |
} |
| 3374 |
} |
| 3375 |
function hideTooltip() { |
| 3376 |
if (tooltipTimeout) |
| 3377 |
tooltipTimeout = clearTimeout(tooltipTimeout); |
| 3378 |
if (tooltip.isOpen) { |
| 3379 |
tooltip.hideTooltip(); |
| 3380 |
editor.off("mousewheel", hideTooltip); |
| 3381 |
} |
| 3382 |
} |
| 3383 |
function moveTooltip(e) { |
| 3384 |
tooltip.setPosition(e.x, e.y); |
| 3385 |
} |
| 3386 |
mouseHandler.editor.setDefaultHandler("guttermousemove", function (e) { |
| 3387 |
var target = e.domEvent.target || e.domEvent.srcElement; |
| 3388 |
if (dom.hasCssClass(target, "ace_fold-widget")) |
| 3389 |
return hideTooltip(); |
| 3390 |
if (tooltip.isOpen && mouseHandler.$tooltipFollowsMouse) |
| 3391 |
moveTooltip(e); |
| 3392 |
mouseEvent = e; |
| 3393 |
if (tooltipTimeout) |
| 3394 |
return; |
| 3395 |
tooltipTimeout = setTimeout(function () { |
| 3396 |
tooltipTimeout = null; |
| 3397 |
if (mouseEvent && !mouseHandler.isMousePressed) |
| 3398 |
showTooltip(); |
| 3399 |
else |
| 3400 |
hideTooltip(); |
| 3401 |
}, 50); |
| 3402 |
}); |
| 3403 |
event.addListener(editor.renderer.$gutter, "mouseout", function (e) { |
| 3404 |
mouseEvent = null; |
| 3405 |
if (!tooltip.isOpen || tooltipTimeout) |
| 3406 |
return; |
| 3407 |
tooltipTimeout = setTimeout(function () { |
| 3408 |
tooltipTimeout = null; |
| 3409 |
hideTooltip(); |
| 3410 |
}, 50); |
| 3411 |
}, editor); |
| 3412 |
editor.on("changeSession", hideTooltip); |
| 3413 |
editor.on("input", hideTooltip); |
| 3414 |
} |
| 3415 |
exports.GutterHandler = GutterHandler; |
| 3416 |
var GutterTooltip = (function (_super) { |
| 3417 |
__extends(GutterTooltip, _super); |
| 3418 |
function GutterTooltip(editor) { |
| 3419 |
var _this = _super.call(this, editor.container) || this; |
| 3420 |
_this.editor = editor; |
| 3421 |
return _this; |
| 3422 |
} |
| 3423 |
GutterTooltip.prototype.setPosition = function (x, y) { |
| 3424 |
var windowWidth = window.innerWidth || document.documentElement.clientWidth; |
| 3425 |
var windowHeight = window.innerHeight || document.documentElement.clientHeight; |
| 3426 |
var width = this.getWidth(); |
| 3427 |
var height = this.getHeight(); |
| 3428 |
x += 15; |
| 3429 |
y += 15; |
| 3430 |
if (x + width > windowWidth) { |
| 3431 |
x -= (x + width) - windowWidth; |
| 3432 |
} |
| 3433 |
if (y + height > windowHeight) { |
| 3434 |
y -= 20 + height; |
| 3435 |
} |
| 3436 |
Tooltip.prototype.setPosition.call(this, x, y); |
| 3437 |
}; |
| 3438 |
Object.defineProperty(GutterTooltip, "annotationLabels", { |
| 3439 |
get: function () { |
| 3440 |
return { |
| 3441 |
error: { singular: nls("error"), plural: nls("errors") }, |
| 3442 |
warning: { singular: nls("warning"), plural: nls("warnings") }, |
| 3443 |
info: { singular: nls("information message"), plural: nls("information messages") } |
| 3444 |
}; |
| 3445 |
}, |
| 3446 |
enumerable: false, |
| 3447 |
configurable: true |
| 3448 |
}); |
| 3449 |
GutterTooltip.prototype.showTooltip = function (row) { |
| 3450 |
var gutter = this.editor.renderer.$gutterLayer; |
| 3451 |
var annotationsInRow = gutter.$annotations[row]; |
| 3452 |
var annotation; |
| 3453 |
if (annotationsInRow) |
| 3454 |
annotation = { text: Array.from(annotationsInRow.text), type: Array.from(annotationsInRow.type) }; |
| 3455 |
else |
| 3456 |
annotation = { text: [], type: [] }; |
| 3457 |
var fold = gutter.session.getFoldLine(row); |
| 3458 |
if (fold && gutter.$showFoldedAnnotations) { |
| 3459 |
var annotationsInFold = { error: [], warning: [], info: [] }; |
| 3460 |
var mostSevereAnnotationInFoldType; |
| 3461 |
for (var i = row + 1; i <= fold.end.row; i++) { |
| 3462 |
if (!gutter.$annotations[i]) |
| 3463 |
continue; |
| 3464 |
for (var j = 0; j < gutter.$annotations[i].text.length; j++) { |
| 3465 |
var annotationType = gutter.$annotations[i].type[j]; |
| 3466 |
annotationsInFold[annotationType].push(gutter.$annotations[i].text[j]); |
| 3467 |
if (annotationType === "error") { |
| 3468 |
mostSevereAnnotationInFoldType = "error_fold"; |
| 3469 |
continue; |
| 3470 |
} |
| 3471 |
if (annotationType === "warning") { |
| 3472 |
mostSevereAnnotationInFoldType = "warning_fold"; |
| 3473 |
continue; |
| 3474 |
} |
| 3475 |
} |
| 3476 |
} |
| 3477 |
if (mostSevereAnnotationInFoldType === "error_fold" || mostSevereAnnotationInFoldType === "warning_fold") { |
| 3478 |
var summaryFoldedAnnotations = "".concat(GutterTooltip.annotationsToSummaryString(annotationsInFold), " in folded code."); |
| 3479 |
annotation.text.push(summaryFoldedAnnotations); |
| 3480 |
annotation.type.push(mostSevereAnnotationInFoldType); |
| 3481 |
} |
| 3482 |
} |
| 3483 |
if (annotation.text.length === 0) |
| 3484 |
return this.hide(); |
| 3485 |
var annotationMessages = { error: [], warning: [], info: [] }; |
| 3486 |
var iconClassName = gutter.$useSvgGutterIcons ? "ace_icon_svg" : "ace_icon"; |
| 3487 |
for (var i = 0; i < annotation.text.length; i++) { |
| 3488 |
var line = "<span class='ace_".concat(annotation.type[i], " ").concat(iconClassName, "' aria-label='").concat(GutterTooltip.annotationLabels[annotation.type[i].replace("_fold", "")].singular, "' role=img> </span> ").concat(annotation.text[i]); |
| 3489 |
annotationMessages[annotation.type[i].replace("_fold", "")].push(line); |
| 3490 |
} |
| 3491 |
var tooltipContent = [].concat(annotationMessages.error, annotationMessages.warning, annotationMessages.info).join("<br>"); |
| 3492 |
this.setHtml(tooltipContent); |
| 3493 |
this.$element.setAttribute("aria-live", "polite"); |
| 3494 |
if (!this.isOpen) { |
| 3495 |
this.setTheme(this.editor.renderer.theme); |
| 3496 |
this.setClassName("ace_gutter-tooltip"); |
| 3497 |
} |
| 3498 |
this.show(); |
| 3499 |
this.editor._signal("showGutterTooltip", this); |
| 3500 |
}; |
| 3501 |
GutterTooltip.prototype.hideTooltip = function () { |
| 3502 |
this.$element.removeAttribute("aria-live"); |
| 3503 |
this.hide(); |
| 3504 |
this.editor._signal("hideGutterTooltip", this); |
| 3505 |
}; |
| 3506 |
GutterTooltip.annotationsToSummaryString = function (annotations) { |
| 3507 |
var e_1, _a; |
| 3508 |
var summary = []; |
| 3509 |
var annotationTypes = ['error', 'warning', 'info']; |
| 3510 |
try { |
| 3511 |
for (var annotationTypes_1 = __values(annotationTypes), annotationTypes_1_1 = annotationTypes_1.next(); !annotationTypes_1_1.done; annotationTypes_1_1 = annotationTypes_1.next()) { |
| 3512 |
var annotationType = annotationTypes_1_1.value; |
| 3513 |
if (!annotations[annotationType].length) |
| 3514 |
continue; |
| 3515 |
var label = annotations[annotationType].length === 1 ? GutterTooltip.annotationLabels[annotationType].singular : GutterTooltip.annotationLabels[annotationType].plural; |
| 3516 |
summary.push("".concat(annotations[annotationType].length, " ").concat(label)); |
| 3517 |
} |
| 3518 |
} |
| 3519 |
catch (e_1_1) { e_1 = { error: e_1_1 }; } |
| 3520 |
finally { |
| 3521 |
try { |
| 3522 |
if (annotationTypes_1_1 && !annotationTypes_1_1.done && (_a = annotationTypes_1.return)) _a.call(annotationTypes_1); |
| 3523 |
} |
| 3524 |
finally { if (e_1) throw e_1.error; } |
| 3525 |
} |
| 3526 |
return summary.join(", "); |
| 3527 |
}; |
| 3528 |
return GutterTooltip; |
| 3529 |
}(Tooltip)); |
| 3530 |
exports.GutterTooltip = GutterTooltip; |
| 3531 |
|
| 3532 |
}); |
| 3533 |
|
| 3534 |
ace.define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module){"use strict"; |
| 3535 |
var event = require("../lib/event"); |
| 3536 |
var useragent = require("../lib/useragent"); |
| 3537 |
var MouseEvent = (function () { |
| 3538 |
function MouseEvent(domEvent, editor) { this.speed; this.wheelX; this.wheelY; |
| 3539 |
this.domEvent = domEvent; |
| 3540 |
this.editor = editor; |
| 3541 |
this.x = this.clientX = domEvent.clientX; |
| 3542 |
this.y = this.clientY = domEvent.clientY; |
| 3543 |
this.$pos = null; |
| 3544 |
this.$inSelection = null; |
| 3545 |
this.propagationStopped = false; |
| 3546 |
this.defaultPrevented = false; |
| 3547 |
} |
| 3548 |
MouseEvent.prototype.stopPropagation = function () { |
| 3549 |
event.stopPropagation(this.domEvent); |
| 3550 |
this.propagationStopped = true; |
| 3551 |
}; |
| 3552 |
MouseEvent.prototype.preventDefault = function () { |
| 3553 |
event.preventDefault(this.domEvent); |
| 3554 |
this.defaultPrevented = true; |
| 3555 |
}; |
| 3556 |
MouseEvent.prototype.stop = function () { |
| 3557 |
this.stopPropagation(); |
| 3558 |
this.preventDefault(); |
| 3559 |
}; |
| 3560 |
MouseEvent.prototype.getDocumentPosition = function () { |
| 3561 |
if (this.$pos) |
| 3562 |
return this.$pos; |
| 3563 |
this.$pos = this.editor.renderer.screenToTextCoordinates(this.clientX, this.clientY); |
| 3564 |
return this.$pos; |
| 3565 |
}; |
| 3566 |
MouseEvent.prototype.getGutterRow = function () { |
| 3567 |
var documentRow = this.getDocumentPosition().row; |
| 3568 |
var screenRow = this.editor.session.documentToScreenRow(documentRow, 0); |
| 3569 |
var screenTopRow = this.editor.session.documentToScreenRow(this.editor.renderer.$gutterLayer.$lines.get(0).row, 0); |
| 3570 |
return screenRow - screenTopRow; |
| 3571 |
}; |
| 3572 |
MouseEvent.prototype.inSelection = function () { |
| 3573 |
if (this.$inSelection !== null) |
| 3574 |
return this.$inSelection; |
| 3575 |
var editor = this.editor; |
| 3576 |
var selectionRange = editor.getSelectionRange(); |
| 3577 |
if (selectionRange.isEmpty()) |
| 3578 |
this.$inSelection = false; |
| 3579 |
else { |
| 3580 |
var pos = this.getDocumentPosition(); |
| 3581 |
this.$inSelection = selectionRange.contains(pos.row, pos.column); |
| 3582 |
} |
| 3583 |
return this.$inSelection; |
| 3584 |
}; |
| 3585 |
MouseEvent.prototype.getButton = function () { |
| 3586 |
return event.getButton(this.domEvent); |
| 3587 |
}; |
| 3588 |
MouseEvent.prototype.getShiftKey = function () { |
| 3589 |
return this.domEvent.shiftKey; |
| 3590 |
}; |
| 3591 |
MouseEvent.prototype.getAccelKey = function () { |
| 3592 |
return useragent.isMac ? this.domEvent.metaKey : this.domEvent.ctrlKey; |
| 3593 |
}; |
| 3594 |
return MouseEvent; |
| 3595 |
}()); |
| 3596 |
exports.MouseEvent = MouseEvent; |
| 3597 |
|
| 3598 |
}); |
| 3599 |
|
| 3600 |
ace.define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module){"use strict"; |
| 3601 |
var dom = require("../lib/dom"); |
| 3602 |
var event = require("../lib/event"); |
| 3603 |
var useragent = require("../lib/useragent"); |
| 3604 |
var AUTOSCROLL_DELAY = 200; |
| 3605 |
var SCROLL_CURSOR_DELAY = 200; |
| 3606 |
var SCROLL_CURSOR_HYSTERESIS = 5; |
| 3607 |
function DragdropHandler(mouseHandler) { |
| 3608 |
var editor = mouseHandler.editor; |
| 3609 |
var dragImage = dom.createElement("div"); |
| 3610 |
dragImage.style.cssText = "top:-100px;position:absolute;z-index:2147483647;opacity:0.5"; |
| 3611 |
dragImage.textContent = "\xa0"; |
| 3612 |
var exports = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"]; |
| 3613 |
exports.forEach(function (x) { |
| 3614 |
mouseHandler[x] = this[x]; |
| 3615 |
}, this); |
| 3616 |
editor.on("mousedown", this.onMouseDown.bind(mouseHandler)); |
| 3617 |
var mouseTarget = editor.container; |
| 3618 |
var dragSelectionMarker, x, y; |
| 3619 |
var timerId, range; |
| 3620 |
var dragCursor, counter = 0; |
| 3621 |
var dragOperation; |
| 3622 |
var isInternal; |
| 3623 |
var autoScrollStartTime; |
| 3624 |
var cursorMovedTime; |
| 3625 |
var cursorPointOnCaretMoved; |
| 3626 |
this.onDragStart = function (e) { |
| 3627 |
if (this.cancelDrag || !mouseTarget.draggable) { |
| 3628 |
var self = this; |
| 3629 |
setTimeout(function () { |
| 3630 |
self.startSelect(); |
| 3631 |
self.captureMouse(e); |
| 3632 |
}, 0); |
| 3633 |
return e.preventDefault(); |
| 3634 |
} |
| 3635 |
range = editor.getSelectionRange(); |
| 3636 |
var dataTransfer = e.dataTransfer; |
| 3637 |
dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove"; |
| 3638 |
editor.container.appendChild(dragImage); |
| 3639 |
dataTransfer.setDragImage && dataTransfer.setDragImage(dragImage, 0, 0); |
| 3640 |
setTimeout(function () { |
| 3641 |
editor.container.removeChild(dragImage); |
| 3642 |
}); |
| 3643 |
dataTransfer.clearData(); |
| 3644 |
dataTransfer.setData("Text", editor.session.getTextRange()); |
| 3645 |
isInternal = true; |
| 3646 |
this.setState("drag"); |
| 3647 |
}; |
| 3648 |
this.onDragEnd = function (e) { |
| 3649 |
mouseTarget.draggable = false; |
| 3650 |
isInternal = false; |
| 3651 |
this.setState(null); |
| 3652 |
if (!editor.getReadOnly()) { |
| 3653 |
var dropEffect = e.dataTransfer.dropEffect; |
| 3654 |
if (!dragOperation && dropEffect == "move") |
| 3655 |
editor.session.remove(editor.getSelectionRange()); |
| 3656 |
editor.$resetCursorStyle(); |
| 3657 |
} |
| 3658 |
this.editor.unsetStyle("ace_dragging"); |
| 3659 |
this.editor.renderer.setCursorStyle(""); |
| 3660 |
}; |
| 3661 |
this.onDragEnter = function (e) { |
| 3662 |
if (editor.getReadOnly() || !canAccept(e.dataTransfer)) |
| 3663 |
return; |
| 3664 |
x = e.clientX; |
| 3665 |
y = e.clientY; |
| 3666 |
if (!dragSelectionMarker) |
| 3667 |
addDragMarker(); |
| 3668 |
counter++; |
| 3669 |
e.dataTransfer.dropEffect = dragOperation = getDropEffect(e); |
| 3670 |
return event.preventDefault(e); |
| 3671 |
}; |
| 3672 |
this.onDragOver = function (e) { |
| 3673 |
if (editor.getReadOnly() || !canAccept(e.dataTransfer)) |
| 3674 |
return; |
| 3675 |
x = e.clientX; |
| 3676 |
y = e.clientY; |
| 3677 |
if (!dragSelectionMarker) { |
| 3678 |
addDragMarker(); |
| 3679 |
counter++; |
| 3680 |
} |
| 3681 |
if (onMouseMoveTimer !== null) |
| 3682 |
onMouseMoveTimer = null; |
| 3683 |
e.dataTransfer.dropEffect = dragOperation = getDropEffect(e); |
| 3684 |
return event.preventDefault(e); |
| 3685 |
}; |
| 3686 |
this.onDragLeave = function (e) { |
| 3687 |
counter--; |
| 3688 |
if (counter <= 0 && dragSelectionMarker) { |
| 3689 |
clearDragMarker(); |
| 3690 |
dragOperation = null; |
| 3691 |
return event.preventDefault(e); |
| 3692 |
} |
| 3693 |
}; |
| 3694 |
this.onDrop = function (e) { |
| 3695 |
if (!dragCursor) |
| 3696 |
return; |
| 3697 |
var dataTransfer = e.dataTransfer; |
| 3698 |
if (isInternal) { |
| 3699 |
switch (dragOperation) { |
| 3700 |
case "move": |
| 3701 |
if (range.contains(dragCursor.row, dragCursor.column)) { |
| 3702 |
range = { |
| 3703 |
start: dragCursor, |
| 3704 |
end: dragCursor |
| 3705 |
}; |
| 3706 |
} |
| 3707 |
else { |
| 3708 |
range = editor.moveText(range, dragCursor); |
| 3709 |
} |
| 3710 |
break; |
| 3711 |
case "copy": |
| 3712 |
range = editor.moveText(range, dragCursor, true); |
| 3713 |
break; |
| 3714 |
} |
| 3715 |
} |
| 3716 |
else { |
| 3717 |
var dropData = dataTransfer.getData('Text'); |
| 3718 |
range = { |
| 3719 |
start: dragCursor, |
| 3720 |
end: editor.session.insert(dragCursor, dropData) |
| 3721 |
}; |
| 3722 |
editor.focus(); |
| 3723 |
dragOperation = null; |
| 3724 |
} |
| 3725 |
clearDragMarker(); |
| 3726 |
return event.preventDefault(e); |
| 3727 |
}; |
| 3728 |
event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler), editor); |
| 3729 |
event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler), editor); |
| 3730 |
event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler), editor); |
| 3731 |
event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler), editor); |
| 3732 |
event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler), editor); |
| 3733 |
event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler), editor); |
| 3734 |
function scrollCursorIntoView(cursor, prevCursor) { |
| 3735 |
var now = Date.now(); |
| 3736 |
var vMovement = !prevCursor || cursor.row != prevCursor.row; |
| 3737 |
var hMovement = !prevCursor || cursor.column != prevCursor.column; |
| 3738 |
if (!cursorMovedTime || vMovement || hMovement) { |
| 3739 |
editor.moveCursorToPosition(cursor); |
| 3740 |
cursorMovedTime = now; |
| 3741 |
cursorPointOnCaretMoved = { x: x, y: y }; |
| 3742 |
} |
| 3743 |
else { |
| 3744 |
var distance = calcDistance(cursorPointOnCaretMoved.x, cursorPointOnCaretMoved.y, x, y); |
| 3745 |
if (distance > SCROLL_CURSOR_HYSTERESIS) { |
| 3746 |
cursorMovedTime = null; |
| 3747 |
} |
| 3748 |
else if (now - cursorMovedTime >= SCROLL_CURSOR_DELAY) { |
| 3749 |
editor.renderer.scrollCursorIntoView(); |
| 3750 |
cursorMovedTime = null; |
| 3751 |
} |
| 3752 |
} |
| 3753 |
} |
| 3754 |
function autoScroll(cursor, prevCursor) { |
| 3755 |
var now = Date.now(); |
| 3756 |
var lineHeight = editor.renderer.layerConfig.lineHeight; |
| 3757 |
var characterWidth = editor.renderer.layerConfig.characterWidth; |
| 3758 |
var editorRect = editor.renderer.scroller.getBoundingClientRect(); |
| 3759 |
var offsets = { |
| 3760 |
x: { |
| 3761 |
left: x - editorRect.left, |
| 3762 |
right: editorRect.right - x |
| 3763 |
}, |
| 3764 |
y: { |
| 3765 |
top: y - editorRect.top, |
| 3766 |
bottom: editorRect.bottom - y |
| 3767 |
} |
| 3768 |
}; |
| 3769 |
var nearestXOffset = Math.min(offsets.x.left, offsets.x.right); |
| 3770 |
var nearestYOffset = Math.min(offsets.y.top, offsets.y.bottom); |
| 3771 |
var scrollCursor = { row: cursor.row, column: cursor.column }; |
| 3772 |
if (nearestXOffset / characterWidth <= 2) { |
| 3773 |
scrollCursor.column += (offsets.x.left < offsets.x.right ? -3 : +2); |
| 3774 |
} |
| 3775 |
if (nearestYOffset / lineHeight <= 1) { |
| 3776 |
scrollCursor.row += (offsets.y.top < offsets.y.bottom ? -1 : +1); |
| 3777 |
} |
| 3778 |
var vScroll = cursor.row != scrollCursor.row; |
| 3779 |
var hScroll = cursor.column != scrollCursor.column; |
| 3780 |
var vMovement = !prevCursor || cursor.row != prevCursor.row; |
| 3781 |
if (vScroll || (hScroll && !vMovement)) { |
| 3782 |
if (!autoScrollStartTime) |
| 3783 |
autoScrollStartTime = now; |
| 3784 |
else if (now - autoScrollStartTime >= AUTOSCROLL_DELAY) |
| 3785 |
editor.renderer.scrollCursorIntoView(scrollCursor); |
| 3786 |
} |
| 3787 |
else { |
| 3788 |
autoScrollStartTime = null; |
| 3789 |
} |
| 3790 |
} |
| 3791 |
function onDragInterval() { |
| 3792 |
var prevCursor = dragCursor; |
| 3793 |
dragCursor = editor.renderer.screenToTextCoordinates(x, y); |
| 3794 |
scrollCursorIntoView(dragCursor, prevCursor); |
| 3795 |
autoScroll(dragCursor, prevCursor); |
| 3796 |
} |
| 3797 |
function addDragMarker() { |
| 3798 |
range = editor.selection.toOrientedRange(); |
| 3799 |
dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle()); |
| 3800 |
editor.clearSelection(); |
| 3801 |
if (editor.isFocused()) |
| 3802 |
editor.renderer.$cursorLayer.setBlinking(false); |
| 3803 |
clearInterval(timerId); |
| 3804 |
onDragInterval(); |
| 3805 |
timerId = setInterval(onDragInterval, 20); |
| 3806 |
counter = 0; |
| 3807 |
event.addListener(document, "mousemove", onMouseMove); |
| 3808 |
} |
| 3809 |
function clearDragMarker() { |
| 3810 |
clearInterval(timerId); |
| 3811 |
editor.session.removeMarker(dragSelectionMarker); |
| 3812 |
dragSelectionMarker = null; |
| 3813 |
editor.selection.fromOrientedRange(range); |
| 3814 |
if (editor.isFocused() && !isInternal) |
| 3815 |
editor.$resetCursorStyle(); |
| 3816 |
range = null; |
| 3817 |
dragCursor = null; |
| 3818 |
counter = 0; |
| 3819 |
autoScrollStartTime = null; |
| 3820 |
cursorMovedTime = null; |
| 3821 |
event.removeListener(document, "mousemove", onMouseMove); |
| 3822 |
} |
| 3823 |
var onMouseMoveTimer = null; |
| 3824 |
function onMouseMove() { |
| 3825 |
if (onMouseMoveTimer == null) { |
| 3826 |
onMouseMoveTimer = setTimeout(function () { |
| 3827 |
if (onMouseMoveTimer != null && dragSelectionMarker) |
| 3828 |
clearDragMarker(); |
| 3829 |
}, 20); |
| 3830 |
} |
| 3831 |
} |
| 3832 |
function canAccept(dataTransfer) { |
| 3833 |
var types = dataTransfer.types; |
| 3834 |
return !types || Array.prototype.some.call(types, function (type) { |
| 3835 |
return type == 'text/plain' || type == 'Text'; |
| 3836 |
}); |
| 3837 |
} |
| 3838 |
function getDropEffect(e) { |
| 3839 |
var copyAllowed = ['copy', 'copymove', 'all', 'uninitialized']; |
| 3840 |
var moveAllowed = ['move', 'copymove', 'linkmove', 'all', 'uninitialized']; |
| 3841 |
var copyModifierState = useragent.isMac ? e.altKey : e.ctrlKey; |
| 3842 |
var effectAllowed = "uninitialized"; |
| 3843 |
try { |
| 3844 |
effectAllowed = e.dataTransfer.effectAllowed.toLowerCase(); |
| 3845 |
} |
| 3846 |
catch (e) { } |
| 3847 |
var dropEffect = "none"; |
| 3848 |
if (copyModifierState && copyAllowed.indexOf(effectAllowed) >= 0) |
| 3849 |
dropEffect = "copy"; |
| 3850 |
else if (moveAllowed.indexOf(effectAllowed) >= 0) |
| 3851 |
dropEffect = "move"; |
| 3852 |
else if (copyAllowed.indexOf(effectAllowed) >= 0) |
| 3853 |
dropEffect = "copy"; |
| 3854 |
return dropEffect; |
| 3855 |
} |
| 3856 |
} |
| 3857 |
(function () { |
| 3858 |
this.dragWait = function () { |
| 3859 |
var interval = Date.now() - this.mousedownEvent.time; |
| 3860 |
if (interval > this.editor.getDragDelay()) |
| 3861 |
this.startDrag(); |
| 3862 |
}; |
| 3863 |
this.dragWaitEnd = function () { |
| 3864 |
var target = this.editor.container; |
| 3865 |
target.draggable = false; |
| 3866 |
this.startSelect(this.mousedownEvent.getDocumentPosition()); |
| 3867 |
this.selectEnd(); |
| 3868 |
}; |
| 3869 |
this.dragReadyEnd = function (e) { |
| 3870 |
this.editor.$resetCursorStyle(); |
| 3871 |
this.editor.unsetStyle("ace_dragging"); |
| 3872 |
this.editor.renderer.setCursorStyle(""); |
| 3873 |
this.dragWaitEnd(); |
| 3874 |
}; |
| 3875 |
this.startDrag = function () { |
| 3876 |
this.cancelDrag = false; |
| 3877 |
var editor = this.editor; |
| 3878 |
var target = editor.container; |
| 3879 |
target.draggable = true; |
| 3880 |
editor.renderer.$cursorLayer.setBlinking(false); |
| 3881 |
editor.setStyle("ace_dragging"); |
| 3882 |
var cursorStyle = useragent.isWin ? "default" : "move"; |
| 3883 |
editor.renderer.setCursorStyle(cursorStyle); |
| 3884 |
this.setState("dragReady"); |
| 3885 |
}; |
| 3886 |
this.onMouseDrag = function (e) { |
| 3887 |
var target = this.editor.container; |
| 3888 |
if (useragent.isIE && this.state == "dragReady") { |
| 3889 |
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y); |
| 3890 |
if (distance > 3) |
| 3891 |
target.dragDrop(); |
| 3892 |
} |
| 3893 |
if (this.state === "dragWait") { |
| 3894 |
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y); |
| 3895 |
if (distance > 0) { |
| 3896 |
target.draggable = false; |
| 3897 |
this.startSelect(this.mousedownEvent.getDocumentPosition()); |
| 3898 |
} |
| 3899 |
} |
| 3900 |
}; |
| 3901 |
this.onMouseDown = function (e) { |
| 3902 |
if (!this.$dragEnabled) |
| 3903 |
return; |
| 3904 |
this.mousedownEvent = e; |
| 3905 |
var editor = this.editor; |
| 3906 |
var inSelection = e.inSelection(); |
| 3907 |
var button = e.getButton(); |
| 3908 |
var clickCount = e.domEvent.detail || 1; |
| 3909 |
if (clickCount === 1 && button === 0 && inSelection) { |
| 3910 |
if (e.editor.inMultiSelectMode && (e.getAccelKey() || e.getShiftKey())) |
| 3911 |
return; |
| 3912 |
this.mousedownEvent.time = Date.now(); |
| 3913 |
var eventTarget = e.domEvent.target || e.domEvent.srcElement; |
| 3914 |
if ("unselectable" in eventTarget) |
| 3915 |
eventTarget.unselectable = "on"; |
| 3916 |
if (editor.getDragDelay()) { |
| 3917 |
if (useragent.isWebKit) { |
| 3918 |
this.cancelDrag = true; |
| 3919 |
var mouseTarget = editor.container; |
| 3920 |
mouseTarget.draggable = true; |
| 3921 |
} |
| 3922 |
this.setState("dragWait"); |
| 3923 |
} |
| 3924 |
else { |
| 3925 |
this.startDrag(); |
| 3926 |
} |
| 3927 |
this.captureMouse(e, this.onMouseDrag.bind(this)); |
| 3928 |
e.defaultPrevented = true; |
| 3929 |
} |
| 3930 |
}; |
| 3931 |
}).call(DragdropHandler.prototype); |
| 3932 |
function calcDistance(ax, ay, bx, by) { |
| 3933 |
return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2)); |
| 3934 |
} |
| 3935 |
exports.DragdropHandler = DragdropHandler; |
| 3936 |
|
| 3937 |
}); |
| 3938 |
|
| 3939 |
ace.define("ace/mouse/touch_handler",["require","exports","module","ace/mouse/mouse_event","ace/lib/event","ace/lib/dom"], function(require, exports, module){"use strict"; |
| 3940 |
var MouseEvent = require("./mouse_event").MouseEvent; |
| 3941 |
var event = require("../lib/event"); |
| 3942 |
var dom = require("../lib/dom"); |
| 3943 |
exports.addTouchListeners = function (el, editor) { |
| 3944 |
var mode = "scroll"; |
| 3945 |
var startX; |
| 3946 |
var startY; |
| 3947 |
var touchStartT; |
| 3948 |
var lastT; |
| 3949 |
var longTouchTimer; |
| 3950 |
var animationTimer; |
| 3951 |
var animationSteps = 0; |
| 3952 |
var pos; |
| 3953 |
var clickCount = 0; |
| 3954 |
var vX = 0; |
| 3955 |
var vY = 0; |
| 3956 |
var pressed; |
| 3957 |
var contextMenu; |
| 3958 |
function createContextMenu() { |
| 3959 |
var clipboard = window.navigator && window.navigator.clipboard; |
| 3960 |
var isOpen = false; |
| 3961 |
var updateMenu = function () { |
| 3962 |
var selected = editor.getCopyText(); |
| 3963 |
var hasUndo = editor.session.getUndoManager().hasUndo(); |
| 3964 |
contextMenu.replaceChild(dom.buildDom(isOpen ? ["span", |
| 3965 |
!selected && ["span", { class: "ace_mobile-button", action: "selectall" }, "Select All"], |
| 3966 |
selected && ["span", { class: "ace_mobile-button", action: "copy" }, "Copy"], |
| 3967 |
selected && ["span", { class: "ace_mobile-button", action: "cut" }, "Cut"], |
| 3968 |
clipboard && ["span", { class: "ace_mobile-button", action: "paste" }, "Paste"], |
| 3969 |
hasUndo && ["span", { class: "ace_mobile-button", action: "undo" }, "Undo"], |
| 3970 |
["span", { class: "ace_mobile-button", action: "find" }, "Find"], |
| 3971 |
["span", { class: "ace_mobile-button", action: "openCommandPalette" }, "Palette"] |
| 3972 |
] : ["span"]), contextMenu.firstChild); |
| 3973 |
}; |
| 3974 |
var handleClick = function (e) { |
| 3975 |
var action = e.target.getAttribute("action"); |
| 3976 |
if (action == "more" || !isOpen) { |
| 3977 |
isOpen = !isOpen; |
| 3978 |
return updateMenu(); |
| 3979 |
} |
| 3980 |
if (action == "paste") { |
| 3981 |
clipboard.readText().then(function (text) { |
| 3982 |
editor.execCommand(action, text); |
| 3983 |
}); |
| 3984 |
} |
| 3985 |
else if (action) { |
| 3986 |
if (action == "cut" || action == "copy") { |
| 3987 |
if (clipboard) |
| 3988 |
clipboard.writeText(editor.getCopyText()); |
| 3989 |
else |
| 3990 |
document.execCommand("copy"); |
| 3991 |
} |
| 3992 |
editor.execCommand(action); |
| 3993 |
} |
| 3994 |
contextMenu.firstChild.style.display = "none"; |
| 3995 |
isOpen = false; |
| 3996 |
if (action != "openCommandPalette") |
| 3997 |
editor.focus(); |
| 3998 |
}; |
| 3999 |
contextMenu = dom.buildDom(["div", |
| 4000 |
{ |
| 4001 |
class: "ace_mobile-menu", |
| 4002 |
ontouchstart: function (e) { |
| 4003 |
mode = "menu"; |
| 4004 |
e.stopPropagation(); |
| 4005 |
e.preventDefault(); |
| 4006 |
editor.textInput.focus(); |
| 4007 |
}, |
| 4008 |
ontouchend: function (e) { |
| 4009 |
e.stopPropagation(); |
| 4010 |
e.preventDefault(); |
| 4011 |
handleClick(e); |
| 4012 |
}, |
| 4013 |
onclick: handleClick |
| 4014 |
}, |
| 4015 |
["span"], |
| 4016 |
["span", { class: "ace_mobile-button", action: "more" }, "..."] |
| 4017 |
], editor.container); |
| 4018 |
} |
| 4019 |
function showContextMenu() { |
| 4020 |
if (!contextMenu) |
| 4021 |
createContextMenu(); |
| 4022 |
var cursor = editor.selection.cursor; |
| 4023 |
var pagePos = editor.renderer.textToScreenCoordinates(cursor.row, cursor.column); |
| 4024 |
var leftOffset = editor.renderer.textToScreenCoordinates(0, 0).pageX; |
| 4025 |
var scrollLeft = editor.renderer.scrollLeft; |
| 4026 |
var rect = editor.container.getBoundingClientRect(); |
| 4027 |
contextMenu.style.top = pagePos.pageY - rect.top - 3 + "px"; |
| 4028 |
if (pagePos.pageX - rect.left < rect.width - 70) { |
| 4029 |
contextMenu.style.left = ""; |
| 4030 |
contextMenu.style.right = "10px"; |
| 4031 |
} |
| 4032 |
else { |
| 4033 |
contextMenu.style.right = ""; |
| 4034 |
contextMenu.style.left = leftOffset + scrollLeft - rect.left + "px"; |
| 4035 |
} |
| 4036 |
contextMenu.style.display = ""; |
| 4037 |
contextMenu.firstChild.style.display = "none"; |
| 4038 |
editor.on("input", hideContextMenu); |
| 4039 |
} |
| 4040 |
function hideContextMenu(e) { |
| 4041 |
if (contextMenu) |
| 4042 |
contextMenu.style.display = "none"; |
| 4043 |
editor.off("input", hideContextMenu); |
| 4044 |
} |
| 4045 |
function handleLongTap() { |
| 4046 |
longTouchTimer = null; |
| 4047 |
clearTimeout(longTouchTimer); |
| 4048 |
var range = editor.selection.getRange(); |
| 4049 |
var inSelection = range.contains(pos.row, pos.column); |
| 4050 |
if (range.isEmpty() || !inSelection) { |
| 4051 |
editor.selection.moveToPosition(pos); |
| 4052 |
editor.selection.selectWord(); |
| 4053 |
} |
| 4054 |
mode = "wait"; |
| 4055 |
showContextMenu(); |
| 4056 |
} |
| 4057 |
function switchToSelectionMode() { |
| 4058 |
longTouchTimer = null; |
| 4059 |
clearTimeout(longTouchTimer); |
| 4060 |
editor.selection.moveToPosition(pos); |
| 4061 |
var range = clickCount >= 2 |
| 4062 |
? editor.selection.getLineRange(pos.row) |
| 4063 |
: editor.session.getBracketRange(pos); |
| 4064 |
if (range && !range.isEmpty()) { |
| 4065 |
editor.selection.setRange(range); |
| 4066 |
} |
| 4067 |
else { |
| 4068 |
editor.selection.selectWord(); |
| 4069 |
} |
| 4070 |
mode = "wait"; |
| 4071 |
} |
| 4072 |
event.addListener(el, "contextmenu", function (e) { |
| 4073 |
if (!pressed) |
| 4074 |
return; |
| 4075 |
var textarea = editor.textInput.getElement(); |
| 4076 |
textarea.focus(); |
| 4077 |
}, editor); |
| 4078 |
event.addListener(el, "touchstart", function (e) { |
| 4079 |
var touches = e.touches; |
| 4080 |
if (longTouchTimer || touches.length > 1) { |
| 4081 |
clearTimeout(longTouchTimer); |
| 4082 |
longTouchTimer = null; |
| 4083 |
touchStartT = -1; |
| 4084 |
mode = "zoom"; |
| 4085 |
return; |
| 4086 |
} |
| 4087 |
pressed = editor.$mouseHandler.isMousePressed = true; |
| 4088 |
var h = editor.renderer.layerConfig.lineHeight; |
| 4089 |
var w = editor.renderer.layerConfig.lineHeight; |
| 4090 |
var t = e.timeStamp; |
| 4091 |
lastT = t; |
| 4092 |
var touchObj = touches[0]; |
| 4093 |
var x = touchObj.clientX; |
| 4094 |
var y = touchObj.clientY; |
| 4095 |
if (Math.abs(startX - x) + Math.abs(startY - y) > h) |
| 4096 |
touchStartT = -1; |
| 4097 |
startX = e.clientX = x; |
| 4098 |
startY = e.clientY = y; |
| 4099 |
vX = vY = 0; |
| 4100 |
var ev = new MouseEvent(e, editor); |
| 4101 |
pos = ev.getDocumentPosition(); |
| 4102 |
if (t - touchStartT < 500 && touches.length == 1 && !animationSteps) { |
| 4103 |
clickCount++; |
| 4104 |
e.preventDefault(); |
| 4105 |
e.button = 0; |
| 4106 |
switchToSelectionMode(); |
| 4107 |
} |
| 4108 |
else { |
| 4109 |
clickCount = 0; |
| 4110 |
var cursor = editor.selection.cursor; |
| 4111 |
var anchor = editor.selection.isEmpty() ? cursor : editor.selection.anchor; |
| 4112 |
var cursorPos = editor.renderer.$cursorLayer.getPixelPosition(cursor, true); |
| 4113 |
var anchorPos = editor.renderer.$cursorLayer.getPixelPosition(anchor, true); |
| 4114 |
var rect = editor.renderer.scroller.getBoundingClientRect(); |
| 4115 |
var offsetTop = editor.renderer.layerConfig.offset; |
| 4116 |
var offsetLeft = editor.renderer.scrollLeft; |
| 4117 |
var weightedDistance = function (x, y) { |
| 4118 |
x = x / w; |
| 4119 |
y = y / h - 0.75; |
| 4120 |
return x * x + y * y; |
| 4121 |
}; |
| 4122 |
if (e.clientX < rect.left) { |
| 4123 |
mode = "zoom"; |
| 4124 |
return; |
| 4125 |
} |
| 4126 |
var diff1 = weightedDistance(e.clientX - rect.left - cursorPos.left + offsetLeft, e.clientY - rect.top - cursorPos.top + offsetTop); |
| 4127 |
var diff2 = weightedDistance(e.clientX - rect.left - anchorPos.left + offsetLeft, e.clientY - rect.top - anchorPos.top + offsetTop); |
| 4128 |
if (diff1 < 3.5 && diff2 < 3.5) |
| 4129 |
mode = diff1 > diff2 ? "cursor" : "anchor"; |
| 4130 |
if (diff2 < 3.5) |
| 4131 |
mode = "anchor"; |
| 4132 |
else if (diff1 < 3.5) |
| 4133 |
mode = "cursor"; |
| 4134 |
else |
| 4135 |
mode = "scroll"; |
| 4136 |
longTouchTimer = setTimeout(handleLongTap, 450); |
| 4137 |
} |
| 4138 |
touchStartT = t; |
| 4139 |
}, editor); |
| 4140 |
event.addListener(el, "touchend", function (e) { |
| 4141 |
pressed = editor.$mouseHandler.isMousePressed = false; |
| 4142 |
if (animationTimer) |
| 4143 |
clearInterval(animationTimer); |
| 4144 |
if (mode == "zoom") { |
| 4145 |
mode = ""; |
| 4146 |
animationSteps = 0; |
| 4147 |
} |
| 4148 |
else if (longTouchTimer) { |
| 4149 |
editor.selection.moveToPosition(pos); |
| 4150 |
animationSteps = 0; |
| 4151 |
showContextMenu(); |
| 4152 |
} |
| 4153 |
else if (mode == "scroll") { |
| 4154 |
animate(); |
| 4155 |
hideContextMenu(); |
| 4156 |
} |
| 4157 |
else { |
| 4158 |
showContextMenu(); |
| 4159 |
} |
| 4160 |
clearTimeout(longTouchTimer); |
| 4161 |
longTouchTimer = null; |
| 4162 |
}, editor); |
| 4163 |
event.addListener(el, "touchmove", function (e) { |
| 4164 |
if (longTouchTimer) { |
| 4165 |
clearTimeout(longTouchTimer); |
| 4166 |
longTouchTimer = null; |
| 4167 |
} |
| 4168 |
var touches = e.touches; |
| 4169 |
if (touches.length > 1 || mode == "zoom") |
| 4170 |
return; |
| 4171 |
var touchObj = touches[0]; |
| 4172 |
var wheelX = startX - touchObj.clientX; |
| 4173 |
var wheelY = startY - touchObj.clientY; |
| 4174 |
if (mode == "wait") { |
| 4175 |
if (wheelX * wheelX + wheelY * wheelY > 4) |
| 4176 |
mode = "cursor"; |
| 4177 |
else |
| 4178 |
return e.preventDefault(); |
| 4179 |
} |
| 4180 |
startX = touchObj.clientX; |
| 4181 |
startY = touchObj.clientY; |
| 4182 |
e.clientX = touchObj.clientX; |
| 4183 |
e.clientY = touchObj.clientY; |
| 4184 |
var t = e.timeStamp; |
| 4185 |
var dt = t - lastT; |
| 4186 |
lastT = t; |
| 4187 |
if (mode == "scroll") { |
| 4188 |
var mouseEvent = new MouseEvent(e, editor); |
| 4189 |
mouseEvent.speed = 1; |
| 4190 |
mouseEvent.wheelX = wheelX; |
| 4191 |
mouseEvent.wheelY = wheelY; |
| 4192 |
if (10 * Math.abs(wheelX) < Math.abs(wheelY)) |
| 4193 |
wheelX = 0; |
| 4194 |
if (10 * Math.abs(wheelY) < Math.abs(wheelX)) |
| 4195 |
wheelY = 0; |
| 4196 |
if (dt != 0) { |
| 4197 |
vX = wheelX / dt; |
| 4198 |
vY = wheelY / dt; |
| 4199 |
} |
| 4200 |
editor._emit("mousewheel", mouseEvent); |
| 4201 |
if (!mouseEvent.propagationStopped) { |
| 4202 |
vX = vY = 0; |
| 4203 |
} |
| 4204 |
} |
| 4205 |
else { |
| 4206 |
var ev = new MouseEvent(e, editor); |
| 4207 |
var pos = ev.getDocumentPosition(); |
| 4208 |
if (mode == "cursor") |
| 4209 |
editor.selection.moveCursorToPosition(pos); |
| 4210 |
else if (mode == "anchor") |
| 4211 |
editor.selection.setSelectionAnchor(pos.row, pos.column); |
| 4212 |
editor.renderer.scrollCursorIntoView(pos); |
| 4213 |
e.preventDefault(); |
| 4214 |
} |
| 4215 |
}, editor); |
| 4216 |
function animate() { |
| 4217 |
animationSteps += 60; |
| 4218 |
animationTimer = setInterval(function () { |
| 4219 |
if (animationSteps-- <= 0) { |
| 4220 |
clearInterval(animationTimer); |
| 4221 |
animationTimer = null; |
| 4222 |
} |
| 4223 |
if (Math.abs(vX) < 0.01) |
| 4224 |
vX = 0; |
| 4225 |
if (Math.abs(vY) < 0.01) |
| 4226 |
vY = 0; |
| 4227 |
if (animationSteps < 20) |
| 4228 |
vX = 0.9 * vX; |
| 4229 |
if (animationSteps < 20) |
| 4230 |
vY = 0.9 * vY; |
| 4231 |
var oldScrollTop = editor.session.getScrollTop(); |
| 4232 |
editor.renderer.scrollBy(10 * vX, 10 * vY); |
| 4233 |
if (oldScrollTop == editor.session.getScrollTop()) |
| 4234 |
animationSteps = 0; |
| 4235 |
}, 10); |
| 4236 |
} |
| 4237 |
}; |
| 4238 |
|
| 4239 |
}); |
| 4240 |
|
| 4241 |
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_handler","ace/mouse/touch_handler","ace/config"], function(require, exports, module){"use strict"; |
| 4242 |
var event = require("../lib/event"); |
| 4243 |
var useragent = require("../lib/useragent"); |
| 4244 |
var DefaultHandlers = require("./default_handlers").DefaultHandlers; |
| 4245 |
var DefaultGutterHandler = require("./default_gutter_handler").GutterHandler; |
| 4246 |
var MouseEvent = require("./mouse_event").MouseEvent; |
| 4247 |
var DragdropHandler = require("./dragdrop_handler").DragdropHandler; |
| 4248 |
var addTouchListeners = require("./touch_handler").addTouchListeners; |
| 4249 |
var config = require("../config"); |
| 4250 |
var MouseHandler = (function () { |
| 4251 |
function MouseHandler(editor) { this.$dragDelay; this.$dragEnabled; this.$mouseMoved; this.mouseEvent; this.$focusTimeout; |
| 4252 |
var _self = this; |
| 4253 |
this.editor = editor; |
| 4254 |
new DefaultHandlers(this); |
| 4255 |
new DefaultGutterHandler(this); |
| 4256 |
new DragdropHandler(this); |
| 4257 |
var focusEditor = function (e) { |
| 4258 |
var windowBlurred = !document.hasFocus || !document.hasFocus() |
| 4259 |
|| !editor.isFocused() && document.activeElement == (editor.textInput && editor.textInput.getElement()); |
| 4260 |
if (windowBlurred) |
| 4261 |
window.focus(); |
| 4262 |
editor.focus(); |
| 4263 |
setTimeout(function () { |
| 4264 |
if (!editor.isFocused()) |
| 4265 |
editor.focus(); |
| 4266 |
}); |
| 4267 |
}; |
| 4268 |
var mouseTarget = editor.renderer.getMouseEventTarget(); |
| 4269 |
event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"), editor); |
| 4270 |
event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"), editor); |
| 4271 |
event.addMultiMouseDownListener([ |
| 4272 |
mouseTarget, |
| 4273 |
editor.renderer.scrollBarV && editor.renderer.scrollBarV.inner, |
| 4274 |
editor.renderer.scrollBarH && editor.renderer.scrollBarH.inner, |
| 4275 |
editor.textInput && editor.textInput.getElement() |
| 4276 |
].filter(Boolean), [400, 300, 250], this, "onMouseEvent", editor); |
| 4277 |
event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"), editor); |
| 4278 |
addTouchListeners(editor.container, editor); |
| 4279 |
var gutterEl = editor.renderer.$gutter; |
| 4280 |
event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"), editor); |
| 4281 |
event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"), editor); |
| 4282 |
event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"), editor); |
| 4283 |
event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove"), editor); |
| 4284 |
event.addListener(mouseTarget, "mousedown", focusEditor, editor); |
| 4285 |
event.addListener(gutterEl, "mousedown", focusEditor, editor); |
| 4286 |
if (useragent.isIE && editor.renderer.scrollBarV) { |
| 4287 |
event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor, editor); |
| 4288 |
event.addListener(editor.renderer.scrollBarH.element, "mousedown", focusEditor, editor); |
| 4289 |
} |
| 4290 |
editor.on("mousemove", function (e) { |
| 4291 |
if (_self.state || _self.$dragDelay || !_self.$dragEnabled) |
| 4292 |
return; |
| 4293 |
var character = editor.renderer.screenToTextCoordinates(e.x, e.y); |
| 4294 |
var range = editor.session.selection.getRange(); |
| 4295 |
var renderer = editor.renderer; |
| 4296 |
if (!range.isEmpty() && range.insideStart(character.row, character.column)) { |
| 4297 |
renderer.setCursorStyle("default"); |
| 4298 |
} |
| 4299 |
else { |
| 4300 |
renderer.setCursorStyle(""); |
| 4301 |
} |
| 4302 |
}, |
| 4303 |
editor); |
| 4304 |
} |
| 4305 |
MouseHandler.prototype.onMouseEvent = function (name, e) { |
| 4306 |
if (!this.editor.session) |
| 4307 |
return; |
| 4308 |
this.editor._emit(name, new MouseEvent(e, this.editor)); |
| 4309 |
}; |
| 4310 |
MouseHandler.prototype.onMouseMove = function (name, e) { |
| 4311 |
var listeners = this.editor._eventRegistry && this.editor._eventRegistry.mousemove; |
| 4312 |
if (!listeners || !listeners.length) |
| 4313 |
return; |
| 4314 |
this.editor._emit(name, new MouseEvent(e, this.editor)); |
| 4315 |
}; |
| 4316 |
MouseHandler.prototype.onMouseWheel = function (name, e) { |
| 4317 |
var mouseEvent = new MouseEvent(e, this.editor); |
| 4318 |
mouseEvent.speed = this.$scrollSpeed * 2; |
| 4319 |
mouseEvent.wheelX = e.wheelX; |
| 4320 |
mouseEvent.wheelY = e.wheelY; |
| 4321 |
this.editor._emit(name, mouseEvent); |
| 4322 |
}; |
| 4323 |
MouseHandler.prototype.setState = function (state) { |
| 4324 |
this.state = state; |
| 4325 |
}; |
| 4326 |
MouseHandler.prototype.captureMouse = function (ev, mouseMoveHandler) { |
| 4327 |
this.x = ev.x; |
| 4328 |
this.y = ev.y; |
| 4329 |
this.isMousePressed = true; |
| 4330 |
var editor = this.editor; |
| 4331 |
var renderer = this.editor.renderer; |
| 4332 |
renderer.$isMousePressed = true; |
| 4333 |
var self = this; |
| 4334 |
var onMouseMove = function (e) { |
| 4335 |
if (!e) |
| 4336 |
return; |
| 4337 |
if (useragent.isWebKit && !e.which && self.releaseMouse) |
| 4338 |
return self.releaseMouse(); |
| 4339 |
self.x = e.clientX; |
| 4340 |
self.y = e.clientY; |
| 4341 |
mouseMoveHandler && mouseMoveHandler(e); |
| 4342 |
self.mouseEvent = new MouseEvent(e, self.editor); |
| 4343 |
self.$mouseMoved = true; |
| 4344 |
}; |
| 4345 |
var onCaptureEnd = function (e) { |
| 4346 |
editor.off("beforeEndOperation", onOperationEnd); |
| 4347 |
clearInterval(timerId); |
| 4348 |
if (editor.session) |
| 4349 |
onCaptureInterval(); |
| 4350 |
self[self.state + "End"] && self[self.state + "End"](e); |
| 4351 |
self.state = ""; |
| 4352 |
self.isMousePressed = renderer.$isMousePressed = false; |
| 4353 |
if (renderer.$keepTextAreaAtCursor) |
| 4354 |
renderer.$moveTextAreaToCursor(); |
| 4355 |
self.$onCaptureMouseMove = self.releaseMouse = null; |
| 4356 |
e && self.onMouseEvent("mouseup", e); |
| 4357 |
editor.endOperation(); |
| 4358 |
}; |
| 4359 |
var onCaptureInterval = function () { |
| 4360 |
self[self.state] && self[self.state](); |
| 4361 |
self.$mouseMoved = false; |
| 4362 |
}; |
| 4363 |
if (useragent.isOldIE && ev.domEvent.type == "dblclick") { |
| 4364 |
return setTimeout(function () { onCaptureEnd(ev); }); |
| 4365 |
} |
| 4366 |
var onOperationEnd = function (e) { |
| 4367 |
if (!self.releaseMouse) |
| 4368 |
return; |
| 4369 |
if (editor.curOp.command.name && editor.curOp.selectionChanged) { |
| 4370 |
self[self.state + "End"] && self[self.state + "End"](); |
| 4371 |
self.state = ""; |
| 4372 |
self.releaseMouse(); |
| 4373 |
} |
| 4374 |
}; |
| 4375 |
editor.on("beforeEndOperation", onOperationEnd); |
| 4376 |
editor.startOperation({ command: { name: "mouse" } }); |
| 4377 |
self.$onCaptureMouseMove = onMouseMove; |
| 4378 |
self.releaseMouse = event.capture(this.editor.container, onMouseMove, onCaptureEnd); |
| 4379 |
var timerId = setInterval(onCaptureInterval, 20); |
| 4380 |
}; |
| 4381 |
MouseHandler.prototype.cancelContextMenu = function () { |
| 4382 |
var stop = function (e) { |
| 4383 |
if (e && e.domEvent && e.domEvent.type != "contextmenu") |
| 4384 |
return; |
| 4385 |
this.editor.off("nativecontextmenu", stop); |
| 4386 |
if (e && e.domEvent) |
| 4387 |
event.stopEvent(e.domEvent); |
| 4388 |
}.bind(this); |
| 4389 |
setTimeout(stop, 10); |
| 4390 |
this.editor.on("nativecontextmenu", stop); |
| 4391 |
}; |
| 4392 |
MouseHandler.prototype.destroy = function () { |
| 4393 |
if (this.releaseMouse) |
| 4394 |
this.releaseMouse(); |
| 4395 |
}; |
| 4396 |
return MouseHandler; |
| 4397 |
}()); |
| 4398 |
MouseHandler.prototype.releaseMouse = null; |
| 4399 |
config.defineOptions(MouseHandler.prototype, "mouseHandler", { |
| 4400 |
scrollSpeed: { initialValue: 2 }, |
| 4401 |
dragDelay: { initialValue: (useragent.isMac ? 150 : 0) }, |
| 4402 |
dragEnabled: { initialValue: true }, |
| 4403 |
focusTimeout: { initialValue: 0 }, |
| 4404 |
tooltipFollowsMouse: { initialValue: true } |
| 4405 |
}); |
| 4406 |
exports.MouseHandler = MouseHandler; |
| 4407 |
|
| 4408 |
}); |
| 4409 |
|
| 4410 |
ace.define("ace/mouse/fold_handler",["require","exports","module","ace/lib/dom"], function(require, exports, module){"use strict"; |
| 4411 |
var dom = require("../lib/dom"); |
| 4412 |
var FoldHandler = (function () { |
| 4413 |
function FoldHandler(editor) { |
| 4414 |
editor.on("click", function (e) { |
| 4415 |
var position = e.getDocumentPosition(); |
| 4416 |
var session = editor.session; |
| 4417 |
var fold = session.getFoldAt(position.row, position.column, 1); |
| 4418 |
if (fold) { |
| 4419 |
if (e.getAccelKey()) |
| 4420 |
session.removeFold(fold); |
| 4421 |
else |
| 4422 |
session.expandFold(fold); |
| 4423 |
e.stop(); |
| 4424 |
} |
| 4425 |
var target = e.domEvent && e.domEvent.target; |
| 4426 |
if (target && dom.hasCssClass(target, "ace_inline_button")) { |
| 4427 |
if (dom.hasCssClass(target, "ace_toggle_wrap")) { |
| 4428 |
session.setOption("wrap", !session.getUseWrapMode()); |
| 4429 |
editor.renderer.scrollCursorIntoView(); |
| 4430 |
} |
| 4431 |
} |
| 4432 |
}); |
| 4433 |
editor.on("gutterclick", function (e) { |
| 4434 |
var gutterRegion = editor.renderer.$gutterLayer.getRegion(e); |
| 4435 |
if (gutterRegion == "foldWidgets") { |
| 4436 |
var row = e.getDocumentPosition().row; |
| 4437 |
var session = editor.session; |
| 4438 |
if (session.foldWidgets && session.foldWidgets[row]) |
| 4439 |
editor.session.onFoldWidgetClick(row, e); |
| 4440 |
if (!editor.isFocused()) |
| 4441 |
editor.focus(); |
| 4442 |
e.stop(); |
| 4443 |
} |
| 4444 |
}); |
| 4445 |
editor.on("gutterdblclick", function (e) { |
| 4446 |
var gutterRegion = editor.renderer.$gutterLayer.getRegion(e); |
| 4447 |
if (gutterRegion == "foldWidgets") { |
| 4448 |
var row = e.getDocumentPosition().row; |
| 4449 |
var session = editor.session; |
| 4450 |
var data = session.getParentFoldRangeData(row, true); |
| 4451 |
var range = data.range || data.firstRange; |
| 4452 |
if (range) { |
| 4453 |
row = range.start.row; |
| 4454 |
var fold = session.getFoldAt(row, session.getLine(row).length, 1); |
| 4455 |
if (fold) { |
| 4456 |
session.removeFold(fold); |
| 4457 |
} |
| 4458 |
else { |
| 4459 |
session.addFold("...", range); |
| 4460 |
editor.renderer.scrollCursorIntoView({ row: range.start.row, column: 0 }); |
| 4461 |
} |
| 4462 |
} |
| 4463 |
e.stop(); |
| 4464 |
} |
| 4465 |
}); |
| 4466 |
} |
| 4467 |
return FoldHandler; |
| 4468 |
}()); |
| 4469 |
exports.FoldHandler = FoldHandler; |
| 4470 |
|
| 4471 |
}); |
| 4472 |
|
| 4473 |
ace.define("ace/keyboard/keybinding",["require","exports","module","ace/lib/keys","ace/lib/event"], function(require, exports, module){"use strict"; |
| 4474 |
var keyUtil = require("../lib/keys"); |
| 4475 |
var event = require("../lib/event"); |
| 4476 |
var KeyBinding = (function () { |
| 4477 |
function KeyBinding(editor) { |
| 4478 |
this.$editor = editor; |
| 4479 |
this.$data = { editor: editor }; |
| 4480 |
this.$handlers = []; |
| 4481 |
this.setDefaultHandler(editor.commands); |
| 4482 |
} |
| 4483 |
KeyBinding.prototype.setDefaultHandler = function (kb) { |
| 4484 |
this.removeKeyboardHandler(this.$defaultHandler); |
| 4485 |
this.$defaultHandler = kb; |
| 4486 |
this.addKeyboardHandler(kb, 0); |
| 4487 |
}; |
| 4488 |
KeyBinding.prototype.setKeyboardHandler = function (kb) { |
| 4489 |
var h = this.$handlers; |
| 4490 |
if (h[h.length - 1] == kb) |
| 4491 |
return; |
| 4492 |
while (h[h.length - 1] && h[h.length - 1] != this.$defaultHandler) |
| 4493 |
this.removeKeyboardHandler(h[h.length - 1]); |
| 4494 |
this.addKeyboardHandler(kb, 1); |
| 4495 |
}; |
| 4496 |
KeyBinding.prototype.addKeyboardHandler = function (kb, pos) { |
| 4497 |
if (!kb) |
| 4498 |
return; |
| 4499 |
if (typeof kb == "function" && !kb.handleKeyboard) |
| 4500 |
kb.handleKeyboard = kb; |
| 4501 |
var i = this.$handlers.indexOf(kb); |
| 4502 |
if (i != -1) |
| 4503 |
this.$handlers.splice(i, 1); |
| 4504 |
if (pos == undefined) |
| 4505 |
this.$handlers.push(kb); |
| 4506 |
else |
| 4507 |
this.$handlers.splice(pos, 0, kb); |
| 4508 |
if (i == -1 && kb.attach) |
| 4509 |
kb.attach(this.$editor); |
| 4510 |
}; |
| 4511 |
KeyBinding.prototype.removeKeyboardHandler = function (kb) { |
| 4512 |
var i = this.$handlers.indexOf(kb); |
| 4513 |
if (i == -1) |
| 4514 |
return false; |
| 4515 |
this.$handlers.splice(i, 1); |
| 4516 |
kb.detach && kb.detach(this.$editor); |
| 4517 |
return true; |
| 4518 |
}; |
| 4519 |
KeyBinding.prototype.getKeyboardHandler = function () { |
| 4520 |
return this.$handlers[this.$handlers.length - 1]; |
| 4521 |
}; |
| 4522 |
KeyBinding.prototype.getStatusText = function () { |
| 4523 |
var data = this.$data; |
| 4524 |
var editor = data.editor; |
| 4525 |
return this.$handlers.map(function (h) { |
| 4526 |
return h.getStatusText && h.getStatusText(editor, data) || ""; |
| 4527 |
}).filter(Boolean).join(" "); |
| 4528 |
}; |
| 4529 |
KeyBinding.prototype.$callKeyboardHandlers = function (hashId, keyString, keyCode, e) { |
| 4530 |
var toExecute; |
| 4531 |
var success = false; |
| 4532 |
var commands = this.$editor.commands; |
| 4533 |
for (var i = this.$handlers.length; i--;) { |
| 4534 |
toExecute = this.$handlers[i].handleKeyboard( |
| 4535 |
this.$data, hashId, keyString, keyCode, e); |
| 4536 |
if (!toExecute || !toExecute.command) |
| 4537 |
continue; |
| 4538 |
if (toExecute.command == "null") { |
| 4539 |
success = true; |
| 4540 |
} |
| 4541 |
else { |
| 4542 |
success = commands.exec(toExecute.command, this.$editor, toExecute.args, e); |
| 4543 |
} |
| 4544 |
if (success && e && hashId != -1 && |
| 4545 |
toExecute["passEvent"] != true && toExecute.command["passEvent"] != true) { |
| 4546 |
event.stopEvent(e); |
| 4547 |
} |
| 4548 |
if (success) |
| 4549 |
break; |
| 4550 |
} |
| 4551 |
if (!success && hashId == -1) { |
| 4552 |
toExecute = { command: "insertstring" }; |
| 4553 |
success = commands.exec("insertstring", this.$editor, keyString); |
| 4554 |
} |
| 4555 |
if (success && this.$editor._signal) |
| 4556 |
this.$editor._signal("keyboardActivity", toExecute); |
| 4557 |
return success; |
| 4558 |
}; |
| 4559 |
KeyBinding.prototype.onCommandKey = function (e, hashId, keyCode) { |
| 4560 |
var keyString = keyUtil.keyCodeToString(keyCode); |
| 4561 |
return this.$callKeyboardHandlers(hashId, keyString, keyCode, e); |
| 4562 |
}; |
| 4563 |
KeyBinding.prototype.onTextInput = function (text) { |
| 4564 |
return this.$callKeyboardHandlers(-1, text); |
| 4565 |
}; |
| 4566 |
return KeyBinding; |
| 4567 |
}()); |
| 4568 |
exports.KeyBinding = KeyBinding; |
| 4569 |
|
| 4570 |
}); |
| 4571 |
|
| 4572 |
ace.define("ace/lib/bidiutil",["require","exports","module"], function(require, exports, module){"use strict"; |
| 4573 |
var ArabicAlefBetIntervalsBegine = ['\u0621', '\u0641']; |
| 4574 |
var ArabicAlefBetIntervalsEnd = ['\u063A', '\u064a']; |
| 4575 |
var dir = 0, hiLevel = 0; |
| 4576 |
var lastArabic = false, hasUBAT_AL = false, hasUBAT_B = false, hasUBAT_S = false, hasBlockSep = false, hasSegSep = false; |
| 4577 |
var impTab_LTR = [ [0, 3, 0, 1, 0, 0, 0], [0, 3, 0, 1, 2, 2, 0], [0, 3, 0, 0x11, 2, 0, 1], [0, 3, 5, 5, 4, 1, 0], [0, 3, 0x15, 0x15, 4, 0, 1], [0, 3, 5, 5, 4, 2, 0] |
| 4578 |
]; |
| 4579 |
var impTab_RTL = [ [2, 0, 1, 1, 0, 1, 0], [2, 0, 1, 1, 0, 2, 0], [2, 0, 2, 1, 3, 2, 0], [2, 0, 2, 0x21, 3, 1, 1] |
| 4580 |
]; |
| 4581 |
var LTR = 0, RTL = 1; |
| 4582 |
var L = 0; |
| 4583 |
var R = 1; |
| 4584 |
var EN = 2; |
| 4585 |
var AN = 3; |
| 4586 |
var ON = 4; |
| 4587 |
var B = 5; |
| 4588 |
var S = 6; |
| 4589 |
var AL = 7; |
| 4590 |
var WS = 8; |
| 4591 |
var CS = 9; |
| 4592 |
var ES = 10; |
| 4593 |
var ET = 11; |
| 4594 |
var NSM = 12; |
| 4595 |
var LRE = 13; |
| 4596 |
var RLE = 14; |
| 4597 |
var PDF = 15; |
| 4598 |
var LRO = 16; |
| 4599 |
var RLO = 17; |
| 4600 |
var BN = 18; |
| 4601 |
var UnicodeTBL00 = [ |
| 4602 |
BN, BN, BN, BN, BN, BN, BN, BN, BN, S, B, S, WS, B, BN, BN, |
| 4603 |
BN, BN, BN, BN, BN, BN, BN, BN, BN, BN, BN, BN, B, B, B, S, |
| 4604 |
WS, ON, ON, ET, ET, ET, ON, ON, ON, ON, ON, ES, CS, ES, CS, CS, |
| 4605 |
EN, EN, EN, EN, EN, EN, EN, EN, EN, EN, CS, ON, ON, ON, ON, ON, |
| 4606 |
ON, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, |
| 4607 |
L, L, L, L, L, L, L, L, L, L, L, ON, ON, ON, ON, ON, |
| 4608 |
ON, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, |
| 4609 |
L, L, L, L, L, L, L, L, L, L, L, ON, ON, ON, ON, BN, |
| 4610 |
BN, BN, BN, BN, BN, B, BN, BN, BN, BN, BN, BN, BN, BN, BN, BN, |
| 4611 |
BN, BN, BN, BN, BN, BN, BN, BN, BN, BN, BN, BN, BN, BN, BN, BN, |
| 4612 |
CS, ON, ET, ET, ET, ET, ON, ON, ON, ON, L, ON, ON, BN, ON, ON, |
| 4613 |
ET, ET, EN, EN, ON, L, ON, ON, ON, EN, L, ON, ON, ON, ON, ON |
| 4614 |
]; |
| 4615 |
var UnicodeTBL20 = [ |
| 4616 |
WS, WS, WS, WS, WS, WS, WS, WS, WS, WS, WS, BN, BN, BN, L, R, |
| 4617 |
ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, |
| 4618 |
ON, ON, ON, ON, ON, ON, ON, ON, WS, B, LRE, RLE, PDF, LRO, RLO, CS, |
| 4619 |
ET, ET, ET, ET, ET, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, |
| 4620 |
ON, ON, ON, ON, CS, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, |
| 4621 |
ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, ON, WS |
| 4622 |
]; |
| 4623 |
function _computeLevels(chars, levels, len, charTypes) { |
| 4624 |
var impTab = dir ? impTab_RTL : impTab_LTR, prevState = null, newClass = null, newLevel = null, newState = 0, action = null, cond = null, condPos = -1, i = null, ix = null, classes = []; |
| 4625 |
if (!charTypes) { |
| 4626 |
for (i = 0, charTypes = []; i < len; i++) { |
| 4627 |
charTypes[i] = _getCharacterType(chars[i]); |
| 4628 |
} |
| 4629 |
} |
| 4630 |
hiLevel = dir; |
| 4631 |
lastArabic = false; |
| 4632 |
hasUBAT_AL = false; |
| 4633 |
hasUBAT_B = false; |
| 4634 |
hasUBAT_S = false; |
| 4635 |
for (ix = 0; ix < len; ix++) { |
| 4636 |
prevState = newState; |
| 4637 |
classes[ix] = newClass = _getCharClass(chars, charTypes, classes, ix); |
| 4638 |
newState = impTab[prevState][newClass]; |
| 4639 |
action = newState & 0xF0; |
| 4640 |
newState &= 0x0F; |
| 4641 |
levels[ix] = newLevel = impTab[newState][5]; |
| 4642 |
if (action > 0) { |
| 4643 |
if (action == 0x10) { |
| 4644 |
for (i = condPos; i < ix; i++) { |
| 4645 |
levels[i] = 1; |
| 4646 |
} |
| 4647 |
condPos = -1; |
| 4648 |
} |
| 4649 |
else { |
| 4650 |
condPos = -1; |
| 4651 |
} |
| 4652 |
} |
| 4653 |
cond = impTab[newState][6]; |
| 4654 |
if (cond) { |
| 4655 |
if (condPos == -1) { |
| 4656 |
condPos = ix; |
| 4657 |
} |
| 4658 |
} |
| 4659 |
else { |
| 4660 |
if (condPos > -1) { |
| 4661 |
for (i = condPos; i < ix; i++) { |
| 4662 |
levels[i] = newLevel; |
| 4663 |
} |
| 4664 |
condPos = -1; |
| 4665 |
} |
| 4666 |
} |
| 4667 |
if (charTypes[ix] == B) { |
| 4668 |
levels[ix] = 0; |
| 4669 |
} |
| 4670 |
hiLevel |= newLevel; |
| 4671 |
} |
| 4672 |
if (hasUBAT_S) { |
| 4673 |
for (i = 0; i < len; i++) { |
| 4674 |
if (charTypes[i] == S) { |
| 4675 |
levels[i] = dir; |
| 4676 |
for (var j = i - 1; j >= 0; j--) { |
| 4677 |
if (charTypes[j] == WS) { |
| 4678 |
levels[j] = dir; |
| 4679 |
} |
| 4680 |
else { |
| 4681 |
break; |
| 4682 |
} |
| 4683 |
} |
| 4684 |
} |
| 4685 |
} |
| 4686 |
} |
| 4687 |
} |
| 4688 |
function _invertLevel(lev, levels, _array) { |
| 4689 |
if (hiLevel < lev) { |
| 4690 |
return; |
| 4691 |
} |
| 4692 |
if (lev == 1 && dir == RTL && !hasUBAT_B) { |
| 4693 |
_array.reverse(); |
| 4694 |
return; |
| 4695 |
} |
| 4696 |
var len = _array.length, start = 0, end, lo, hi, tmp; |
| 4697 |
while (start < len) { |
| 4698 |
if (levels[start] >= lev) { |
| 4699 |
end = start + 1; |
| 4700 |
while (end < len && levels[end] >= lev) { |
| 4701 |
end++; |
| 4702 |
} |
| 4703 |
for (lo = start, hi = end - 1; lo < hi; lo++, hi--) { |
| 4704 |
tmp = _array[lo]; |
| 4705 |
_array[lo] = _array[hi]; |
| 4706 |
_array[hi] = tmp; |
| 4707 |
} |
| 4708 |
start = end; |
| 4709 |
} |
| 4710 |
start++; |
| 4711 |
} |
| 4712 |
} |
| 4713 |
function _getCharClass(chars, types, classes, ix) { |
| 4714 |
var cType = types[ix], wType, nType, len, i; |
| 4715 |
switch (cType) { |
| 4716 |
case L: |
| 4717 |
case R: |
| 4718 |
lastArabic = false; |
| 4719 |
case ON: |
| 4720 |
case AN: |
| 4721 |
return cType; |
| 4722 |
case EN: |
| 4723 |
return lastArabic ? AN : EN; |
| 4724 |
case AL: |
| 4725 |
lastArabic = true; |
| 4726 |
hasUBAT_AL = true; |
| 4727 |
return R; |
| 4728 |
case WS: |
| 4729 |
return ON; |
| 4730 |
case CS: |
| 4731 |
if (ix < 1 || (ix + 1) >= types.length || |
| 4732 |
((wType = classes[ix - 1]) != EN && wType != AN) || |
| 4733 |
((nType = types[ix + 1]) != EN && nType != AN)) { |
| 4734 |
return ON; |
| 4735 |
} |
| 4736 |
if (lastArabic) { |
| 4737 |
nType = AN; |
| 4738 |
} |
| 4739 |
return nType == wType ? nType : ON; |
| 4740 |
case ES: |
| 4741 |
wType = ix > 0 ? classes[ix - 1] : B; |
| 4742 |
if (wType == EN && (ix + 1) < types.length && types[ix + 1] == EN) { |
| 4743 |
return EN; |
| 4744 |
} |
| 4745 |
return ON; |
| 4746 |
case ET: |
| 4747 |
if (ix > 0 && classes[ix - 1] == EN) { |
| 4748 |
return EN; |
| 4749 |
} |
| 4750 |
if (lastArabic) { |
| 4751 |
return ON; |
| 4752 |
} |
| 4753 |
i = ix + 1; |
| 4754 |
len = types.length; |
| 4755 |
while (i < len && types[i] == ET) { |
| 4756 |
i++; |
| 4757 |
} |
| 4758 |
if (i < len && types[i] == EN) { |
| 4759 |
return EN; |
| 4760 |
} |
| 4761 |
return ON; |
| 4762 |
case NSM: |
| 4763 |
len = types.length; |
| 4764 |
i = ix + 1; |
| 4765 |
while (i < len && types[i] == NSM) { |
| 4766 |
i++; |
| 4767 |
} |
| 4768 |
if (i < len) { |
| 4769 |
var c = chars[ix], rtlCandidate = (c >= 0x0591 && c <= 0x08FF) || c == 0xFB1E; |
| 4770 |
wType = types[i]; |
| 4771 |
if (rtlCandidate && (wType == R || wType == AL)) { |
| 4772 |
return R; |
| 4773 |
} |
| 4774 |
} |
| 4775 |
if (ix < 1 || (wType = types[ix - 1]) == B) { |
| 4776 |
return ON; |
| 4777 |
} |
| 4778 |
return classes[ix - 1]; |
| 4779 |
case B: |
| 4780 |
lastArabic = false; |
| 4781 |
hasUBAT_B = true; |
| 4782 |
return dir; |
| 4783 |
case S: |
| 4784 |
hasUBAT_S = true; |
| 4785 |
return ON; |
| 4786 |
case LRE: |
| 4787 |
case RLE: |
| 4788 |
case LRO: |
| 4789 |
case RLO: |
| 4790 |
case PDF: |
| 4791 |
lastArabic = false; |
| 4792 |
case BN: |
| 4793 |
return ON; |
| 4794 |
} |
| 4795 |
} |
| 4796 |
function _getCharacterType(ch) { |
| 4797 |
var uc = ch.charCodeAt(0), hi = uc >> 8; |
| 4798 |
if (hi == 0) { |
| 4799 |
return ((uc > 0x00BF) ? L : UnicodeTBL00[uc]); |
| 4800 |
} |
| 4801 |
else if (hi == 5) { |
| 4802 |
return (/[\u0591-\u05f4]/.test(ch) ? R : L); |
| 4803 |
} |
| 4804 |
else if (hi == 6) { |
| 4805 |
if (/[\u0610-\u061a\u064b-\u065f\u06d6-\u06e4\u06e7-\u06ed]/.test(ch)) |
| 4806 |
return NSM; |
| 4807 |
else if (/[\u0660-\u0669\u066b-\u066c]/.test(ch)) |
| 4808 |
return AN; |
| 4809 |
else if (uc == 0x066A) |
| 4810 |
return ET; |
| 4811 |
else if (/[\u06f0-\u06f9]/.test(ch)) |
| 4812 |
return EN; |
| 4813 |
else |
| 4814 |
return AL; |
| 4815 |
} |
| 4816 |
else if (hi == 0x20 && uc <= 0x205F) { |
| 4817 |
return UnicodeTBL20[uc & 0xFF]; |
| 4818 |
} |
| 4819 |
else if (hi == 0xFE) { |
| 4820 |
return (uc >= 0xFE70 ? AL : ON); |
| 4821 |
} |
| 4822 |
return ON; |
| 4823 |
} |
| 4824 |
function _isArabicDiacritics(ch) { |
| 4825 |
return (ch >= '\u064b' && ch <= '\u0655'); |
| 4826 |
} |
| 4827 |
exports.L = L; |
| 4828 |
exports.R = R; |
| 4829 |
exports.EN = EN; |
| 4830 |
exports.ON_R = 3; |
| 4831 |
exports.AN = 4; |
| 4832 |
exports.R_H = 5; |
| 4833 |
exports.B = 6; |
| 4834 |
exports.RLE = 7; |
| 4835 |
exports.DOT = "\xB7"; |
| 4836 |
exports.doBidiReorder = function (text, textCharTypes, isRtl) { |
| 4837 |
if (text.length < 2) |
| 4838 |
return {}; |
| 4839 |
var chars = text.split(""), logicalFromVisual = new Array(chars.length), bidiLevels = new Array(chars.length), levels = []; |
| 4840 |
dir = isRtl ? RTL : LTR; |
| 4841 |
_computeLevels(chars, levels, chars.length, textCharTypes); |
| 4842 |
for (var i = 0; i < logicalFromVisual.length; logicalFromVisual[i] = i, i++) |
| 4843 |
; |
| 4844 |
_invertLevel(2, levels, logicalFromVisual); |
| 4845 |
_invertLevel(1, levels, logicalFromVisual); |
| 4846 |
for (var i = 0; i < logicalFromVisual.length - 1; i++) { |
| 4847 |
if (textCharTypes[i] === AN) { |
| 4848 |
levels[i] = exports.AN; |
| 4849 |
} |
| 4850 |
else if (levels[i] === R && ((textCharTypes[i] > AL && textCharTypes[i] < LRE) |
| 4851 |
|| textCharTypes[i] === ON || textCharTypes[i] === BN)) { |
| 4852 |
levels[i] = exports.ON_R; |
| 4853 |
} |
| 4854 |
else if ((i > 0 && chars[i - 1] === '\u0644') && /\u0622|\u0623|\u0625|\u0627/.test(chars[i])) { |
| 4855 |
levels[i - 1] = levels[i] = exports.R_H; |
| 4856 |
i++; |
| 4857 |
} |
| 4858 |
} |
| 4859 |
if (chars[chars.length - 1] === exports.DOT) |
| 4860 |
levels[chars.length - 1] = exports.B; |
| 4861 |
if (chars[0] === '\u202B') |
| 4862 |
levels[0] = exports.RLE; |
| 4863 |
for (var i = 0; i < logicalFromVisual.length; i++) { |
| 4864 |
bidiLevels[i] = levels[logicalFromVisual[i]]; |
| 4865 |
} |
| 4866 |
return { 'logicalFromVisual': logicalFromVisual, 'bidiLevels': bidiLevels }; |
| 4867 |
}; |
| 4868 |
exports.hasBidiCharacters = function (text, textCharTypes) { |
| 4869 |
var ret = false; |
| 4870 |
for (var i = 0; i < text.length; i++) { |
| 4871 |
textCharTypes[i] = _getCharacterType(text.charAt(i)); |
| 4872 |
if (!ret && (textCharTypes[i] == R || textCharTypes[i] == AL || textCharTypes[i] == AN)) |
| 4873 |
ret = true; |
| 4874 |
} |
| 4875 |
return ret; |
| 4876 |
}; |
| 4877 |
exports.getVisualFromLogicalIdx = function (logIdx, rowMap) { |
| 4878 |
for (var i = 0; i < rowMap.logicalFromVisual.length; i++) { |
| 4879 |
if (rowMap.logicalFromVisual[i] == logIdx) |
| 4880 |
return i; |
| 4881 |
} |
| 4882 |
return 0; |
| 4883 |
}; |
| 4884 |
|
| 4885 |
}); |
| 4886 |
|
| 4887 |
ace.define("ace/bidihandler",["require","exports","module","ace/lib/bidiutil","ace/lib/lang"], function(require, exports, module){"use strict"; |
| 4888 |
var bidiUtil = require("./lib/bidiutil"); |
| 4889 |
var lang = require("./lib/lang"); |
| 4890 |
var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\u202B]/; |
| 4891 |
var BidiHandler = (function () { |
| 4892 |
function BidiHandler(session) { |
| 4893 |
this.session = session; |
| 4894 |
this.bidiMap = {}; |
| 4895 |
this.currentRow = null; |
| 4896 |
this.bidiUtil = bidiUtil; |
| 4897 |
this.charWidths = []; |
| 4898 |
this.EOL = "\xAC"; |
| 4899 |
this.showInvisibles = true; |
| 4900 |
this.isRtlDir = false; |
| 4901 |
this.$isRtl = false; |
| 4902 |
this.line = ""; |
| 4903 |
this.wrapIndent = 0; |
| 4904 |
this.EOF = "\xB6"; |
| 4905 |
this.RLE = "\u202B"; |
| 4906 |
this.contentWidth = 0; |
| 4907 |
this.fontMetrics = null; |
| 4908 |
this.rtlLineOffset = 0; |
| 4909 |
this.wrapOffset = 0; |
| 4910 |
this.isMoveLeftOperation = false; |
| 4911 |
this.seenBidi = bidiRE.test(session.getValue()); |
| 4912 |
} |
| 4913 |
BidiHandler.prototype.isBidiRow = function (screenRow, docRow, splitIndex) { |
| 4914 |
if (!this.seenBidi) |
| 4915 |
return false; |
| 4916 |
if (screenRow !== this.currentRow) { |
| 4917 |
this.currentRow = screenRow; |
| 4918 |
this.updateRowLine(docRow, splitIndex); |
| 4919 |
this.updateBidiMap(); |
| 4920 |
} |
| 4921 |
return this.bidiMap.bidiLevels; |
| 4922 |
}; |
| 4923 |
BidiHandler.prototype.onChange = function (delta) { |
| 4924 |
if (!this.seenBidi) { |
| 4925 |
if (delta.action == "insert" && bidiRE.test(delta.lines.join("\n"))) { |
| 4926 |
this.seenBidi = true; |
| 4927 |
this.currentRow = null; |
| 4928 |
} |
| 4929 |
} |
| 4930 |
else { |
| 4931 |
this.currentRow = null; |
| 4932 |
} |
| 4933 |
}; |
| 4934 |
BidiHandler.prototype.getDocumentRow = function () { |
| 4935 |
var docRow = 0; |
| 4936 |
var rowCache = this.session.$screenRowCache; |
| 4937 |
if (rowCache.length) { |
| 4938 |
var index = this.session.$getRowCacheIndex(rowCache, this.currentRow); |
| 4939 |
if (index >= 0) |
| 4940 |
docRow = this.session.$docRowCache[index]; |
| 4941 |
} |
| 4942 |
return docRow; |
| 4943 |
}; |
| 4944 |
BidiHandler.prototype.getSplitIndex = function () { |
| 4945 |
var splitIndex = 0; |
| 4946 |
var rowCache = this.session.$screenRowCache; |
| 4947 |
if (rowCache.length) { |
| 4948 |
var currentIndex, prevIndex = this.session.$getRowCacheIndex(rowCache, this.currentRow); |
| 4949 |
while (this.currentRow - splitIndex > 0) { |
| 4950 |
currentIndex = this.session.$getRowCacheIndex(rowCache, this.currentRow - splitIndex - 1); |
| 4951 |
if (currentIndex !== prevIndex) |
| 4952 |
break; |
| 4953 |
prevIndex = currentIndex; |
| 4954 |
splitIndex++; |
| 4955 |
} |
| 4956 |
} |
| 4957 |
else { |
| 4958 |
splitIndex = this.currentRow; |
| 4959 |
} |
| 4960 |
return splitIndex; |
| 4961 |
}; |
| 4962 |
BidiHandler.prototype.updateRowLine = function (docRow, splitIndex) { |
| 4963 |
if (docRow === undefined) |
| 4964 |
docRow = this.getDocumentRow(); |
| 4965 |
var isLastRow = (docRow === this.session.getLength() - 1), endOfLine = isLastRow ? this.EOF : this.EOL; |
| 4966 |
this.wrapIndent = 0; |
| 4967 |
this.line = this.session.getLine(docRow); |
| 4968 |
this.isRtlDir = this.$isRtl || this.line.charAt(0) === this.RLE; |
| 4969 |
if (this.session.$useWrapMode) { |
| 4970 |
var splits = this.session.$wrapData[docRow]; |
| 4971 |
if (splits) { |
| 4972 |
if (splitIndex === undefined) |
| 4973 |
splitIndex = this.getSplitIndex(); |
| 4974 |
if (splitIndex > 0 && splits.length) { |
| 4975 |
this.wrapIndent = splits.indent; |
| 4976 |
this.wrapOffset = this.wrapIndent * this.charWidths[bidiUtil.L]; |
| 4977 |
this.line = (splitIndex < splits.length) ? |
| 4978 |
this.line.substring(splits[splitIndex - 1], splits[splitIndex]) : |
| 4979 |
this.line.substring(splits[splits.length - 1]); |
| 4980 |
} |
| 4981 |
else { |
| 4982 |
this.line = this.line.substring(0, splits[splitIndex]); |
| 4983 |
} |
| 4984 |
if (splitIndex == splits.length) { |
| 4985 |
this.line += (this.showInvisibles) ? endOfLine : bidiUtil.DOT; |
| 4986 |
} |
| 4987 |
} |
| 4988 |
} |
| 4989 |
else { |
| 4990 |
this.line += this.showInvisibles ? endOfLine : bidiUtil.DOT; |
| 4991 |
} |
| 4992 |
var session = this.session, shift = 0, size; |
| 4993 |
this.line = this.line.replace(/\t|[\u1100-\u2029, \u202F-\uFFE6]/g, function (ch, i) { |
| 4994 |
if (ch === '\t' || session.isFullWidth(ch.charCodeAt(0))) { |
| 4995 |
size = (ch === '\t') ? session.getScreenTabSize(i + shift) : 2; |
| 4996 |
shift += size - 1; |
| 4997 |
return lang.stringRepeat(bidiUtil.DOT, size); |
| 4998 |
} |
| 4999 |
return ch; |
| 5000 |
}); |
| 5001 |
if (this.isRtlDir) { |
| 5002 |
this.fontMetrics.$main.textContent = (this.line.charAt(this.line.length - 1) == bidiUtil.DOT) ? this.line.substr(0, this.line.length - 1) : this.line; |
| 5003 |
this.rtlLineOffset = this.contentWidth - this.fontMetrics.$main.getBoundingClientRect().width; |
| 5004 |
} |
| 5005 |
}; |
| 5006 |
BidiHandler.prototype.updateBidiMap = function () { |
| 5007 |
var textCharTypes = []; |
| 5008 |
if (bidiUtil.hasBidiCharacters(this.line, textCharTypes) || this.isRtlDir) { |
| 5009 |
this.bidiMap = bidiUtil.doBidiReorder(this.line, textCharTypes, this.isRtlDir); |
| 5010 |
} |
| 5011 |
else { |
| 5012 |
this.bidiMap = {}; |
| 5013 |
} |
| 5014 |
}; |
| 5015 |
BidiHandler.prototype.markAsDirty = function () { |
| 5016 |
this.currentRow = null; |
| 5017 |
}; |
| 5018 |
BidiHandler.prototype.updateCharacterWidths = function (fontMetrics) { |
| 5019 |
if (this.characterWidth === fontMetrics.$characterSize.width) |
| 5020 |
return; |
| 5021 |
this.fontMetrics = fontMetrics; |
| 5022 |
var characterWidth = this.characterWidth = fontMetrics.$characterSize.width; |
| 5023 |
var bidiCharWidth = fontMetrics.$measureCharWidth("\u05d4"); |
| 5024 |
this.charWidths[bidiUtil.L] = this.charWidths[bidiUtil.EN] = this.charWidths[bidiUtil.ON_R] = characterWidth; |
| 5025 |
this.charWidths[bidiUtil.R] = this.charWidths[bidiUtil.AN] = bidiCharWidth; |
| 5026 |
this.charWidths[bidiUtil.R_H] = bidiCharWidth * 0.45; |
| 5027 |
this.charWidths[bidiUtil.B] = this.charWidths[bidiUtil.RLE] = 0; |
| 5028 |
this.currentRow = null; |
| 5029 |
}; |
| 5030 |
BidiHandler.prototype.setShowInvisibles = function (showInvisibles) { |
| 5031 |
this.showInvisibles = showInvisibles; |
| 5032 |
this.currentRow = null; |
| 5033 |
}; |
| 5034 |
BidiHandler.prototype.setEolChar = function (eolChar) { |
| 5035 |
this.EOL = eolChar; |
| 5036 |
}; |
| 5037 |
BidiHandler.prototype.setContentWidth = function (width) { |
| 5038 |
this.contentWidth = width; |
| 5039 |
}; |
| 5040 |
BidiHandler.prototype.isRtlLine = function (row) { |
| 5041 |
if (this.$isRtl) |
| 5042 |
return true; |
| 5043 |
if (row != undefined) |
| 5044 |
return (this.session.getLine(row).charAt(0) == this.RLE); |
| 5045 |
else |
| 5046 |
return this.isRtlDir; |
| 5047 |
}; |
| 5048 |
BidiHandler.prototype.setRtlDirection = function (editor, isRtlDir) { |
| 5049 |
var cursor = editor.getCursorPosition(); |
| 5050 |
for (var row = editor.selection.getSelectionAnchor().row; row <= cursor.row; row++) { |
| 5051 |
if (!isRtlDir && editor.session.getLine(row).charAt(0) === editor.session.$bidiHandler.RLE) |
| 5052 |
editor.session.doc.removeInLine(row, 0, 1); |
| 5053 |
else if (isRtlDir && editor.session.getLine(row).charAt(0) !== editor.session.$bidiHandler.RLE) |
| 5054 |
editor.session.doc.insert({ column: 0, row: row }, editor.session.$bidiHandler.RLE); |
| 5055 |
} |
| 5056 |
}; |
| 5057 |
BidiHandler.prototype.getPosLeft = function (col) { |
| 5058 |
col -= this.wrapIndent; |
| 5059 |
var leftBoundary = (this.line.charAt(0) === this.RLE) ? 1 : 0; |
| 5060 |
var logicalIdx = (col > leftBoundary) ? (this.session.getOverwrite() ? col : col - 1) : leftBoundary; |
| 5061 |
var visualIdx = bidiUtil.getVisualFromLogicalIdx(logicalIdx, this.bidiMap), levels = this.bidiMap.bidiLevels, left = 0; |
| 5062 |
if (!this.session.getOverwrite() && col <= leftBoundary && levels[visualIdx] % 2 !== 0) |
| 5063 |
visualIdx++; |
| 5064 |
for (var i = 0; i < visualIdx; i++) { |
| 5065 |
left += this.charWidths[levels[i]]; |
| 5066 |
} |
| 5067 |
if (!this.session.getOverwrite() && (col > leftBoundary) && (levels[visualIdx] % 2 === 0)) |
| 5068 |
left += this.charWidths[levels[visualIdx]]; |
| 5069 |
if (this.wrapIndent) |
| 5070 |
left += this.isRtlDir ? (-1 * this.wrapOffset) : this.wrapOffset; |
| 5071 |
if (this.isRtlDir) |
| 5072 |
left += this.rtlLineOffset; |
| 5073 |
return left; |
| 5074 |
}; |
| 5075 |
BidiHandler.prototype.getSelections = function (startCol, endCol) { |
| 5076 |
var map = this.bidiMap, levels = map.bidiLevels, level, selections = [], offset = 0, selColMin = Math.min(startCol, endCol) - this.wrapIndent, selColMax = Math.max(startCol, endCol) - this.wrapIndent, isSelected = false, isSelectedPrev = false, selectionStart = 0; |
| 5077 |
if (this.wrapIndent) |
| 5078 |
offset += this.isRtlDir ? (-1 * this.wrapOffset) : this.wrapOffset; |
| 5079 |
for (var logIdx, visIdx = 0; visIdx < levels.length; visIdx++) { |
| 5080 |
logIdx = map.logicalFromVisual[visIdx]; |
| 5081 |
level = levels[visIdx]; |
| 5082 |
isSelected = (logIdx >= selColMin) && (logIdx < selColMax); |
| 5083 |
if (isSelected && !isSelectedPrev) { |
| 5084 |
selectionStart = offset; |
| 5085 |
} |
| 5086 |
else if (!isSelected && isSelectedPrev) { |
| 5087 |
selections.push({ left: selectionStart, width: offset - selectionStart }); |
| 5088 |
} |
| 5089 |
offset += this.charWidths[level]; |
| 5090 |
isSelectedPrev = isSelected; |
| 5091 |
} |
| 5092 |
if (isSelected && (visIdx === levels.length)) { |
| 5093 |
selections.push({ left: selectionStart, width: offset - selectionStart }); |
| 5094 |
} |
| 5095 |
if (this.isRtlDir) { |
| 5096 |
for (var i = 0; i < selections.length; i++) { |
| 5097 |
selections[i].left += this.rtlLineOffset; |
| 5098 |
} |
| 5099 |
} |
| 5100 |
return selections; |
| 5101 |
}; |
| 5102 |
BidiHandler.prototype.offsetToCol = function (posX) { |
| 5103 |
if (this.isRtlDir) |
| 5104 |
posX -= this.rtlLineOffset; |
| 5105 |
var logicalIdx = 0, posX = Math.max(posX, 0), offset = 0, visualIdx = 0, levels = this.bidiMap.bidiLevels, charWidth = this.charWidths[levels[visualIdx]]; |
| 5106 |
if (this.wrapIndent) |
| 5107 |
posX -= this.isRtlDir ? (-1 * this.wrapOffset) : this.wrapOffset; |
| 5108 |
while (posX > offset + charWidth / 2) { |
| 5109 |
offset += charWidth; |
| 5110 |
if (visualIdx === levels.length - 1) { |
| 5111 |
charWidth = 0; |
| 5112 |
break; |
| 5113 |
} |
| 5114 |
charWidth = this.charWidths[levels[++visualIdx]]; |
| 5115 |
} |
| 5116 |
if (visualIdx > 0 && (levels[visualIdx - 1] % 2 !== 0) && (levels[visualIdx] % 2 === 0)) { |
| 5117 |
if (posX < offset) |
| 5118 |
visualIdx--; |
| 5119 |
logicalIdx = this.bidiMap.logicalFromVisual[visualIdx]; |
| 5120 |
} |
| 5121 |
else if (visualIdx > 0 && (levels[visualIdx - 1] % 2 === 0) && (levels[visualIdx] % 2 !== 0)) { |
| 5122 |
logicalIdx = 1 + ((posX > offset) ? this.bidiMap.logicalFromVisual[visualIdx] |
| 5123 |
: this.bidiMap.logicalFromVisual[visualIdx - 1]); |
| 5124 |
} |
| 5125 |
else if ((this.isRtlDir && visualIdx === levels.length - 1 && charWidth === 0 && (levels[visualIdx - 1] % 2 === 0)) |
| 5126 |
|| (!this.isRtlDir && visualIdx === 0 && (levels[visualIdx] % 2 !== 0))) { |
| 5127 |
logicalIdx = 1 + this.bidiMap.logicalFromVisual[visualIdx]; |
| 5128 |
} |
| 5129 |
else { |
| 5130 |
if (visualIdx > 0 && (levels[visualIdx - 1] % 2 !== 0) && charWidth !== 0) |
| 5131 |
visualIdx--; |
| 5132 |
logicalIdx = this.bidiMap.logicalFromVisual[visualIdx]; |
| 5133 |
} |
| 5134 |
if (logicalIdx === 0 && this.isRtlDir) |
| 5135 |
logicalIdx++; |
| 5136 |
return (logicalIdx + this.wrapIndent); |
| 5137 |
}; |
| 5138 |
return BidiHandler; |
| 5139 |
}()); |
| 5140 |
exports.BidiHandler = BidiHandler; |
| 5141 |
|
| 5142 |
}); |
| 5143 |
|
| 5144 |
ace.define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"], function(require, exports, module){"use strict"; |
| 5145 |
var oop = require("./lib/oop"); |
| 5146 |
var lang = require("./lib/lang"); |
| 5147 |
var EventEmitter = require("./lib/event_emitter").EventEmitter; |
| 5148 |
var Range = require("./range").Range; |
| 5149 |
var Selection = (function () { |
| 5150 |
function Selection(session) { |
| 5151 |
this.session = session; |
| 5152 |
this.doc = session.getDocument(); |
| 5153 |
this.clearSelection(); |
| 5154 |
this.cursor = this.lead = this.doc.createAnchor(0, 0); |
| 5155 |
this.anchor = this.doc.createAnchor(0, 0); |
| 5156 |
this.$silent = false; |
| 5157 |
var self = this; |
| 5158 |
this.cursor.on("change", function (e) { |
| 5159 |
self.$cursorChanged = true; |
| 5160 |
if (!self.$silent) |
| 5161 |
self._emit("changeCursor"); |
| 5162 |
if (!self.$isEmpty && !self.$silent) |
| 5163 |
self._emit("changeSelection"); |
| 5164 |
if (!self.$keepDesiredColumnOnChange && e.old.column != e.value.column) |
| 5165 |
self.$desiredColumn = null; |
| 5166 |
}); |
| 5167 |
this.anchor.on("change", function () { |
| 5168 |
self.$anchorChanged = true; |
| 5169 |
if (!self.$isEmpty && !self.$silent) |
| 5170 |
self._emit("changeSelection"); |
| 5171 |
}); |
| 5172 |
} |
| 5173 |
Selection.prototype.isEmpty = function () { |
| 5174 |
return this.$isEmpty || (this.anchor.row == this.lead.row && |
| 5175 |
this.anchor.column == this.lead.column); |
| 5176 |
}; |
| 5177 |
Selection.prototype.isMultiLine = function () { |
| 5178 |
return !this.$isEmpty && this.anchor.row != this.cursor.row; |
| 5179 |
}; |
| 5180 |
Selection.prototype.getCursor = function () { |
| 5181 |
return this.lead.getPosition(); |
| 5182 |
}; |
| 5183 |
Selection.prototype.setAnchor = function (row, column) { |
| 5184 |
this.$isEmpty = false; |
| 5185 |
this.anchor.setPosition(row, column); |
| 5186 |
}; |
| 5187 |
Selection.prototype.getAnchor = function () { |
| 5188 |
if (this.$isEmpty) |
| 5189 |
return this.getSelectionLead(); |
| 5190 |
return this.anchor.getPosition(); |
| 5191 |
}; |
| 5192 |
Selection.prototype.getSelectionLead = function () { |
| 5193 |
return this.lead.getPosition(); |
| 5194 |
}; |
| 5195 |
Selection.prototype.isBackwards = function () { |
| 5196 |
var anchor = this.anchor; |
| 5197 |
var lead = this.lead; |
| 5198 |
return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column)); |
| 5199 |
}; |
| 5200 |
Selection.prototype.getRange = function () { |
| 5201 |
var anchor = this.anchor; |
| 5202 |
var lead = this.lead; |
| 5203 |
if (this.$isEmpty) |
| 5204 |
return Range.fromPoints(lead, lead); |
| 5205 |
return this.isBackwards() |
| 5206 |
? Range.fromPoints(lead, anchor) |
| 5207 |
: Range.fromPoints(anchor, lead); |
| 5208 |
}; |
| 5209 |
Selection.prototype.clearSelection = function () { |
| 5210 |
if (!this.$isEmpty) { |
| 5211 |
this.$isEmpty = true; |
| 5212 |
this._emit("changeSelection"); |
| 5213 |
} |
| 5214 |
}; |
| 5215 |
Selection.prototype.selectAll = function () { |
| 5216 |
this.$setSelection(0, 0, Number.MAX_VALUE, Number.MAX_VALUE); |
| 5217 |
}; |
| 5218 |
Selection.prototype.setRange = function (range, reverse) { |
| 5219 |
var start = reverse ? range.end : range.start; |
| 5220 |
var end = reverse ? range.start : range.end; |
| 5221 |
this.$setSelection(start.row, start.column, end.row, end.column); |
| 5222 |
}; |
| 5223 |
Selection.prototype.$setSelection = function (anchorRow, anchorColumn, cursorRow, cursorColumn) { |
| 5224 |
if (this.$silent) |
| 5225 |
return; |
| 5226 |
var wasEmpty = this.$isEmpty; |
| 5227 |
var wasMultiselect = this.inMultiSelectMode; |
| 5228 |
this.$silent = true; |
| 5229 |
this.$cursorChanged = this.$anchorChanged = false; |
| 5230 |
this.anchor.setPosition(anchorRow, anchorColumn); |
| 5231 |
this.cursor.setPosition(cursorRow, cursorColumn); |
| 5232 |
this.$isEmpty = !Range.comparePoints(this.anchor, this.cursor); |
| 5233 |
this.$silent = false; |
| 5234 |
if (this.$cursorChanged) |
| 5235 |
this._emit("changeCursor"); |
| 5236 |
if (this.$cursorChanged || this.$anchorChanged || wasEmpty != this.$isEmpty || wasMultiselect) |
| 5237 |
this._emit("changeSelection"); |
| 5238 |
}; |
| 5239 |
Selection.prototype.$moveSelection = function (mover) { |
| 5240 |
var lead = this.lead; |
| 5241 |
if (this.$isEmpty) |
| 5242 |
this.setSelectionAnchor(lead.row, lead.column); |
| 5243 |
mover.call(this); |
| 5244 |
}; |
| 5245 |
Selection.prototype.selectTo = function (row, column) { |
| 5246 |
this.$moveSelection(function () { |
| 5247 |
this.moveCursorTo(row, column); |
| 5248 |
}); |
| 5249 |
}; |
| 5250 |
Selection.prototype.selectToPosition = function (pos) { |
| 5251 |
this.$moveSelection(function () { |
| 5252 |
this.moveCursorToPosition(pos); |
| 5253 |
}); |
| 5254 |
}; |
| 5255 |
Selection.prototype.moveTo = function (row, column) { |
| 5256 |
this.clearSelection(); |
| 5257 |
this.moveCursorTo(row, column); |
| 5258 |
}; |
| 5259 |
Selection.prototype.moveToPosition = function (pos) { |
| 5260 |
this.clearSelection(); |
| 5261 |
this.moveCursorToPosition(pos); |
| 5262 |
}; |
| 5263 |
Selection.prototype.selectUp = function () { |
| 5264 |
this.$moveSelection(this.moveCursorUp); |
| 5265 |
}; |
| 5266 |
Selection.prototype.selectDown = function () { |
| 5267 |
this.$moveSelection(this.moveCursorDown); |
| 5268 |
}; |
| 5269 |
Selection.prototype.selectRight = function () { |
| 5270 |
this.$moveSelection(this.moveCursorRight); |
| 5271 |
}; |
| 5272 |
Selection.prototype.selectLeft = function () { |
| 5273 |
this.$moveSelection(this.moveCursorLeft); |
| 5274 |
}; |
| 5275 |
Selection.prototype.selectLineStart = function () { |
| 5276 |
this.$moveSelection(this.moveCursorLineStart); |
| 5277 |
}; |
| 5278 |
Selection.prototype.selectLineEnd = function () { |
| 5279 |
this.$moveSelection(this.moveCursorLineEnd); |
| 5280 |
}; |
| 5281 |
Selection.prototype.selectFileEnd = function () { |
| 5282 |
this.$moveSelection(this.moveCursorFileEnd); |
| 5283 |
}; |
| 5284 |
Selection.prototype.selectFileStart = function () { |
| 5285 |
this.$moveSelection(this.moveCursorFileStart); |
| 5286 |
}; |
| 5287 |
Selection.prototype.selectWordRight = function () { |
| 5288 |
this.$moveSelection(this.moveCursorWordRight); |
| 5289 |
}; |
| 5290 |
Selection.prototype.selectWordLeft = function () { |
| 5291 |
this.$moveSelection(this.moveCursorWordLeft); |
| 5292 |
}; |
| 5293 |
Selection.prototype.getWordRange = function (row, column) { |
| 5294 |
if (typeof column == "undefined") { |
| 5295 |
var cursor = row || this.lead; |
| 5296 |
row = cursor.row; |
| 5297 |
column = cursor.column; |
| 5298 |
} |
| 5299 |
return this.session.getWordRange(row, column); |
| 5300 |
}; |
| 5301 |
Selection.prototype.selectWord = function () { |
| 5302 |
this.setSelectionRange(this.getWordRange()); |
| 5303 |
}; |
| 5304 |
Selection.prototype.selectAWord = function () { |
| 5305 |
var cursor = this.getCursor(); |
| 5306 |
var range = this.session.getAWordRange(cursor.row, cursor.column); |
| 5307 |
this.setSelectionRange(range); |
| 5308 |
}; |
| 5309 |
Selection.prototype.getLineRange = function (row, excludeLastChar) { |
| 5310 |
var rowStart = typeof row == "number" ? row : this.lead.row; |
| 5311 |
var rowEnd; |
| 5312 |
var foldLine = this.session.getFoldLine(rowStart); |
| 5313 |
if (foldLine) { |
| 5314 |
rowStart = foldLine.start.row; |
| 5315 |
rowEnd = foldLine.end.row; |
| 5316 |
} |
| 5317 |
else { |
| 5318 |
rowEnd = rowStart; |
| 5319 |
} |
| 5320 |
if (excludeLastChar === true) |
| 5321 |
return new Range(rowStart, 0, rowEnd, this.session.getLine(rowEnd).length); |
| 5322 |
else |
| 5323 |
return new Range(rowStart, 0, rowEnd + 1, 0); |
| 5324 |
}; |
| 5325 |
Selection.prototype.selectLine = function () { |
| 5326 |
this.setSelectionRange(this.getLineRange()); |
| 5327 |
}; |
| 5328 |
Selection.prototype.moveCursorUp = function () { |
| 5329 |
this.moveCursorBy(-1, 0); |
| 5330 |
}; |
| 5331 |
Selection.prototype.moveCursorDown = function () { |
| 5332 |
this.moveCursorBy(1, 0); |
| 5333 |
}; |
| 5334 |
Selection.prototype.wouldMoveIntoSoftTab = function (cursor, tabSize, direction) { |
| 5335 |
var start = cursor.column; |
| 5336 |
var end = cursor.column + tabSize; |
| 5337 |
if (direction < 0) { |
| 5338 |
start = cursor.column - tabSize; |
| 5339 |
end = cursor.column; |
| 5340 |
} |
| 5341 |
return this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(start, end).split(" ").length - 1 == tabSize; |
| 5342 |
}; |
| 5343 |
Selection.prototype.moveCursorLeft = function () { |
| 5344 |
var cursor = this.lead.getPosition(), fold; |
| 5345 |
if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) { |
| 5346 |
this.moveCursorTo(fold.start.row, fold.start.column); |
| 5347 |
} |
| 5348 |
else if (cursor.column === 0) { |
| 5349 |
if (cursor.row > 0) { |
| 5350 |
this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length); |
| 5351 |
} |
| 5352 |
} |
| 5353 |
else { |
| 5354 |
var tabSize = this.session.getTabSize(); |
| 5355 |
if (this.wouldMoveIntoSoftTab(cursor, tabSize, -1) && !this.session.getNavigateWithinSoftTabs()) { |
| 5356 |
this.moveCursorBy(0, -tabSize); |
| 5357 |
} |
| 5358 |
else { |
| 5359 |
this.moveCursorBy(0, -1); |
| 5360 |
} |
| 5361 |
} |
| 5362 |
}; |
| 5363 |
Selection.prototype.moveCursorRight = function () { |
| 5364 |
var cursor = this.lead.getPosition(), fold; |
| 5365 |
if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) { |
| 5366 |
this.moveCursorTo(fold.end.row, fold.end.column); |
| 5367 |
} |
| 5368 |
else if (this.lead.column == this.doc.getLine(this.lead.row).length) { |
| 5369 |
if (this.lead.row < this.doc.getLength() - 1) { |
| 5370 |
this.moveCursorTo(this.lead.row + 1, 0); |
| 5371 |
} |
| 5372 |
} |
| 5373 |
else { |
| 5374 |
var tabSize = this.session.getTabSize(); |
| 5375 |
var cursor = this.lead; |
| 5376 |
if (this.wouldMoveIntoSoftTab(cursor, tabSize, 1) && !this.session.getNavigateWithinSoftTabs()) { |
| 5377 |
this.moveCursorBy(0, tabSize); |
| 5378 |
} |
| 5379 |
else { |
| 5380 |
this.moveCursorBy(0, 1); |
| 5381 |
} |
| 5382 |
} |
| 5383 |
}; |
| 5384 |
Selection.prototype.moveCursorLineStart = function () { |
| 5385 |
var row = this.lead.row; |
| 5386 |
var column = this.lead.column; |
| 5387 |
var screenRow = this.session.documentToScreenRow(row, column); |
| 5388 |
var firstColumnPosition = this.session.screenToDocumentPosition(screenRow, 0); |
| 5389 |
var beforeCursor = this.session.getDisplayLine(row, null, firstColumnPosition.row, firstColumnPosition.column); |
| 5390 |
var leadingSpace = beforeCursor.match(/^\s*/); |
| 5391 |
if (leadingSpace[0].length != column && !this.session.$useEmacsStyleLineStart) |
| 5392 |
firstColumnPosition.column += leadingSpace[0].length; |
| 5393 |
this.moveCursorToPosition(firstColumnPosition); |
| 5394 |
}; |
| 5395 |
Selection.prototype.moveCursorLineEnd = function () { |
| 5396 |
var lead = this.lead; |
| 5397 |
var lineEnd = this.session.getDocumentLastRowColumnPosition(lead.row, lead.column); |
| 5398 |
if (this.lead.column == lineEnd.column) { |
| 5399 |
var line = this.session.getLine(lineEnd.row); |
| 5400 |
if (lineEnd.column == line.length) { |
| 5401 |
var textEnd = line.search(/\s+$/); |
| 5402 |
if (textEnd > 0) |
| 5403 |
lineEnd.column = textEnd; |
| 5404 |
} |
| 5405 |
} |
| 5406 |
this.moveCursorTo(lineEnd.row, lineEnd.column); |
| 5407 |
}; |
| 5408 |
Selection.prototype.moveCursorFileEnd = function () { |
| 5409 |
var row = this.doc.getLength() - 1; |
| 5410 |
var column = this.doc.getLine(row).length; |
| 5411 |
this.moveCursorTo(row, column); |
| 5412 |
}; |
| 5413 |
Selection.prototype.moveCursorFileStart = function () { |
| 5414 |
this.moveCursorTo(0, 0); |
| 5415 |
}; |
| 5416 |
Selection.prototype.moveCursorLongWordRight = function () { |
| 5417 |
var row = this.lead.row; |
| 5418 |
var column = this.lead.column; |
| 5419 |
var line = this.doc.getLine(row); |
| 5420 |
var rightOfCursor = line.substring(column); |
| 5421 |
this.session.nonTokenRe.lastIndex = 0; |
| 5422 |
this.session.tokenRe.lastIndex = 0; |
| 5423 |
var fold = this.session.getFoldAt(row, column, 1); |
| 5424 |
if (fold) { |
| 5425 |
this.moveCursorTo(fold.end.row, fold.end.column); |
| 5426 |
return; |
| 5427 |
} |
| 5428 |
if (this.session.nonTokenRe.exec(rightOfCursor)) { |
| 5429 |
column += this.session.nonTokenRe.lastIndex; |
| 5430 |
this.session.nonTokenRe.lastIndex = 0; |
| 5431 |
rightOfCursor = line.substring(column); |
| 5432 |
} |
| 5433 |
if (column >= line.length) { |
| 5434 |
this.moveCursorTo(row, line.length); |
| 5435 |
this.moveCursorRight(); |
| 5436 |
if (row < this.doc.getLength() - 1) |
| 5437 |
this.moveCursorWordRight(); |
| 5438 |
return; |
| 5439 |
} |
| 5440 |
if (this.session.tokenRe.exec(rightOfCursor)) { |
| 5441 |
column += this.session.tokenRe.lastIndex; |
| 5442 |
this.session.tokenRe.lastIndex = 0; |
| 5443 |
} |
| 5444 |
this.moveCursorTo(row, column); |
| 5445 |
}; |
| 5446 |
Selection.prototype.moveCursorLongWordLeft = function () { |
| 5447 |
var row = this.lead.row; |
| 5448 |
var column = this.lead.column; |
| 5449 |
var fold; |
| 5450 |
if (fold = this.session.getFoldAt(row, column, -1)) { |
| 5451 |
this.moveCursorTo(fold.start.row, fold.start.column); |
| 5452 |
return; |
| 5453 |
} |
| 5454 |
var str = this.session.getFoldStringAt(row, column, -1); |
| 5455 |
if (str == null) { |
| 5456 |
str = this.doc.getLine(row).substring(0, column); |
| 5457 |
} |
| 5458 |
var leftOfCursor = lang.stringReverse(str); |
| 5459 |
this.session.nonTokenRe.lastIndex = 0; |
| 5460 |
this.session.tokenRe.lastIndex = 0; |
| 5461 |
if (this.session.nonTokenRe.exec(leftOfCursor)) { |
| 5462 |
column -= this.session.nonTokenRe.lastIndex; |
| 5463 |
leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex); |
| 5464 |
this.session.nonTokenRe.lastIndex = 0; |
| 5465 |
} |
| 5466 |
if (column <= 0) { |
| 5467 |
this.moveCursorTo(row, 0); |
| 5468 |
this.moveCursorLeft(); |
| 5469 |
if (row > 0) |
| 5470 |
this.moveCursorWordLeft(); |
| 5471 |
return; |
| 5472 |
} |
| 5473 |
if (this.session.tokenRe.exec(leftOfCursor)) { |
| 5474 |
column -= this.session.tokenRe.lastIndex; |
| 5475 |
this.session.tokenRe.lastIndex = 0; |
| 5476 |
} |
| 5477 |
this.moveCursorTo(row, column); |
| 5478 |
}; |
| 5479 |
Selection.prototype.$shortWordEndIndex = function (rightOfCursor) { |
| 5480 |
var index = 0, ch; |
| 5481 |
var whitespaceRe = /\s/; |
| 5482 |
var tokenRe = this.session.tokenRe; |
| 5483 |
tokenRe.lastIndex = 0; |
| 5484 |
if (this.session.tokenRe.exec(rightOfCursor)) { |
| 5485 |
index = this.session.tokenRe.lastIndex; |
| 5486 |
} |
| 5487 |
else { |
| 5488 |
while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch)) |
| 5489 |
index++; |
| 5490 |
if (index < 1) { |
| 5491 |
tokenRe.lastIndex = 0; |
| 5492 |
while ((ch = rightOfCursor[index]) && !tokenRe.test(ch)) { |
| 5493 |
tokenRe.lastIndex = 0; |
| 5494 |
index++; |
| 5495 |
if (whitespaceRe.test(ch)) { |
| 5496 |
if (index > 2) { |
| 5497 |
index--; |
| 5498 |
break; |
| 5499 |
} |
| 5500 |
else { |
| 5501 |
while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch)) |
| 5502 |
index++; |
| 5503 |
if (index > 2) |
| 5504 |
break; |
| 5505 |
} |
| 5506 |
} |
| 5507 |
} |
| 5508 |
} |
| 5509 |
} |
| 5510 |
tokenRe.lastIndex = 0; |
| 5511 |
return index; |
| 5512 |
}; |
| 5513 |
Selection.prototype.moveCursorShortWordRight = function () { |
| 5514 |
var row = this.lead.row; |
| 5515 |
var column = this.lead.column; |
| 5516 |
var line = this.doc.getLine(row); |
| 5517 |
var rightOfCursor = line.substring(column); |
| 5518 |
var fold = this.session.getFoldAt(row, column, 1); |
| 5519 |
if (fold) |
| 5520 |
return this.moveCursorTo(fold.end.row, fold.end.column); |
| 5521 |
if (column == line.length) { |
| 5522 |
var l = this.doc.getLength(); |
| 5523 |
do { |
| 5524 |
row++; |
| 5525 |
rightOfCursor = this.doc.getLine(row); |
| 5526 |
} while (row < l && /^\s*$/.test(rightOfCursor)); |
| 5527 |
if (!/^\s+/.test(rightOfCursor)) |
| 5528 |
rightOfCursor = ""; |
| 5529 |
column = 0; |
| 5530 |
} |
| 5531 |
var index = this.$shortWordEndIndex(rightOfCursor); |
| 5532 |
this.moveCursorTo(row, column + index); |
| 5533 |
}; |
| 5534 |
Selection.prototype.moveCursorShortWordLeft = function () { |
| 5535 |
var row = this.lead.row; |
| 5536 |
var column = this.lead.column; |
| 5537 |
var fold; |
| 5538 |
if (fold = this.session.getFoldAt(row, column, -1)) |
| 5539 |
return this.moveCursorTo(fold.start.row, fold.start.column); |
| 5540 |
var line = this.session.getLine(row).substring(0, column); |
| 5541 |
if (column === 0) { |
| 5542 |
do { |
| 5543 |
row--; |
| 5544 |
line = this.doc.getLine(row); |
| 5545 |
} while (row > 0 && /^\s*$/.test(line)); |
| 5546 |
column = line.length; |
| 5547 |
if (!/\s+$/.test(line)) |
| 5548 |
line = ""; |
| 5549 |
} |
| 5550 |
var leftOfCursor = lang.stringReverse(line); |
| 5551 |
var index = this.$shortWordEndIndex(leftOfCursor); |
| 5552 |
return this.moveCursorTo(row, column - index); |
| 5553 |
}; |
| 5554 |
Selection.prototype.moveCursorWordRight = function () { |
| 5555 |
if (this.session.$selectLongWords) |
| 5556 |
this.moveCursorLongWordRight(); |
| 5557 |
else |
| 5558 |
this.moveCursorShortWordRight(); |
| 5559 |
}; |
| 5560 |
Selection.prototype.moveCursorWordLeft = function () { |
| 5561 |
if (this.session.$selectLongWords) |
| 5562 |
this.moveCursorLongWordLeft(); |
| 5563 |
else |
| 5564 |
this.moveCursorShortWordLeft(); |
| 5565 |
}; |
| 5566 |
Selection.prototype.moveCursorBy = function (rows, chars) { |
| 5567 |
var screenPos = this.session.documentToScreenPosition(this.lead.row, this.lead.column); |
| 5568 |
var offsetX; |
| 5569 |
if (chars === 0) { |
| 5570 |
if (rows !== 0) { |
| 5571 |
if (this.session.$bidiHandler.isBidiRow(screenPos.row, this.lead.row)) { |
| 5572 |
offsetX = this.session.$bidiHandler.getPosLeft(screenPos.column); |
| 5573 |
screenPos.column = Math.round(offsetX / this.session.$bidiHandler.charWidths[0]); |
| 5574 |
} |
| 5575 |
else { |
| 5576 |
offsetX = screenPos.column * this.session.$bidiHandler.charWidths[0]; |
| 5577 |
} |
| 5578 |
} |
| 5579 |
if (this.$desiredColumn) |
| 5580 |
screenPos.column = this.$desiredColumn; |
| 5581 |
else |
| 5582 |
this.$desiredColumn = screenPos.column; |
| 5583 |
} |
| 5584 |
if (rows != 0 && this.session.lineWidgets && this.session.lineWidgets[this.lead.row]) { |
| 5585 |
var widget = this.session.lineWidgets[this.lead.row]; |
| 5586 |
if (rows < 0) |
| 5587 |
rows -= widget.rowsAbove || 0; |
| 5588 |
else if (rows > 0) |
| 5589 |
rows += widget.rowCount - (widget.rowsAbove || 0); |
| 5590 |
} |
| 5591 |
var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column, offsetX); |
| 5592 |
if (rows !== 0 && chars === 0 && docPos.row === this.lead.row && docPos.column === this.lead.column) { |
| 5593 |
} |
| 5594 |
this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0); |
| 5595 |
}; |
| 5596 |
Selection.prototype.moveCursorToPosition = function (position) { |
| 5597 |
this.moveCursorTo(position.row, position.column); |
| 5598 |
}; |
| 5599 |
Selection.prototype.moveCursorTo = function (row, column, keepDesiredColumn) { |
| 5600 |
var fold = this.session.getFoldAt(row, column, 1); |
| 5601 |
if (fold) { |
| 5602 |
row = fold.start.row; |
| 5603 |
column = fold.start.column; |
| 5604 |
} |
| 5605 |
this.$keepDesiredColumnOnChange = true; |
| 5606 |
var line = this.session.getLine(row); |
| 5607 |
if (/[\uDC00-\uDFFF]/.test(line.charAt(column)) && line.charAt(column - 1)) { |
| 5608 |
if (this.lead.row == row && this.lead.column == column + 1) |
| 5609 |
column = column - 1; |
| 5610 |
else |
| 5611 |
column = column + 1; |
| 5612 |
} |
| 5613 |
this.lead.setPosition(row, column); |
| 5614 |
this.$keepDesiredColumnOnChange = false; |
| 5615 |
if (!keepDesiredColumn) |
| 5616 |
this.$desiredColumn = null; |
| 5617 |
}; |
| 5618 |
Selection.prototype.moveCursorToScreen = function (row, column, keepDesiredColumn) { |
| 5619 |
var pos = this.session.screenToDocumentPosition(row, column); |
| 5620 |
this.moveCursorTo(pos.row, pos.column, keepDesiredColumn); |
| 5621 |
}; |
| 5622 |
Selection.prototype.detach = function () { |
| 5623 |
this.lead.detach(); |
| 5624 |
this.anchor.detach(); |
| 5625 |
}; |
| 5626 |
Selection.prototype.fromOrientedRange = function (range) { |
| 5627 |
this.setSelectionRange(range, range.cursor == range.start); |
| 5628 |
this.$desiredColumn = range.desiredColumn || this.$desiredColumn; |
| 5629 |
}; |
| 5630 |
Selection.prototype.toOrientedRange = function (range) { |
| 5631 |
var r = this.getRange(); |
| 5632 |
if (range) { |
| 5633 |
range.start.column = r.start.column; |
| 5634 |
range.start.row = r.start.row; |
| 5635 |
range.end.column = r.end.column; |
| 5636 |
range.end.row = r.end.row; |
| 5637 |
} |
| 5638 |
else { |
| 5639 |
range = r; |
| 5640 |
} |
| 5641 |
range.cursor = this.isBackwards() ? range.start : range.end; |
| 5642 |
range.desiredColumn = this.$desiredColumn; |
| 5643 |
return range; |
| 5644 |
}; |
| 5645 |
Selection.prototype.getRangeOfMovements = function (func) { |
| 5646 |
var start = this.getCursor(); |
| 5647 |
try { |
| 5648 |
func(this); |
| 5649 |
var end = this.getCursor(); |
| 5650 |
return Range.fromPoints(start, end); |
| 5651 |
} |
| 5652 |
catch (e) { |
| 5653 |
return Range.fromPoints(start, start); |
| 5654 |
} |
| 5655 |
finally { |
| 5656 |
this.moveCursorToPosition(start); |
| 5657 |
} |
| 5658 |
}; |
| 5659 |
Selection.prototype.toJSON = function () { |
| 5660 |
if (this.rangeCount) { var data = this.ranges.map(function (r) { |
| 5661 |
var r1 = r.clone(); |
| 5662 |
r1.isBackwards = r.cursor == r.start; |
| 5663 |
return r1; |
| 5664 |
}); |
| 5665 |
} |
| 5666 |
else { var data = this.getRange(); |
| 5667 |
data.isBackwards = this.isBackwards(); |
| 5668 |
} |
| 5669 |
return data; |
| 5670 |
}; |
| 5671 |
Selection.prototype.fromJSON = function (data) { |
| 5672 |
if (data.start == undefined) { |
| 5673 |
if (this.rangeList && data.length > 1) { |
| 5674 |
this.toSingleRange(data[0]); |
| 5675 |
for (var i = data.length; i--;) { |
| 5676 |
var r = Range.fromPoints(data[i].start, data[i].end); |
| 5677 |
if (data[i].isBackwards) |
| 5678 |
r.cursor = r.start; |
| 5679 |
this.addRange(r, true); |
| 5680 |
} |
| 5681 |
return; |
| 5682 |
} |
| 5683 |
else { |
| 5684 |
data = data[0]; |
| 5685 |
} |
| 5686 |
} |
| 5687 |
if (this.rangeList) |
| 5688 |
this.toSingleRange(data); |
| 5689 |
this.setSelectionRange(data, data.isBackwards); |
| 5690 |
}; |
| 5691 |
Selection.prototype.isEqual = function (data) { |
| 5692 |
if ((data.length || this.rangeCount) && data.length != this.rangeCount) |
| 5693 |
return false; |
| 5694 |
if (!data.length || !this.ranges) |
| 5695 |
return this.getRange().isEqual(data); |
| 5696 |
for (var i = this.ranges.length; i--;) { |
| 5697 |
if (!this.ranges[i].isEqual(data[i])) |
| 5698 |
return false; |
| 5699 |
} |
| 5700 |
return true; |
| 5701 |
}; |
| 5702 |
return Selection; |
| 5703 |
}()); |
| 5704 |
Selection.prototype.setSelectionAnchor = Selection.prototype.setAnchor; |
| 5705 |
Selection.prototype.getSelectionAnchor = Selection.prototype.getAnchor; |
| 5706 |
Selection.prototype.setSelectionRange = Selection.prototype.setRange; |
| 5707 |
oop.implement(Selection.prototype, EventEmitter); |
| 5708 |
exports.Selection = Selection; |
| 5709 |
|
| 5710 |
}); |
| 5711 |
|
| 5712 |
ace.define("ace/tokenizer",["require","exports","module","ace/lib/report_error"], function(require, exports, module){"use strict"; |
| 5713 |
var reportError = require("./lib/report_error").reportError; |
| 5714 |
var MAX_TOKEN_COUNT = 2000; |
| 5715 |
var Tokenizer = (function () { |
| 5716 |
function Tokenizer(rules) { |
| 5717 |
this.splitRegex; |
| 5718 |
this.states = rules; |
| 5719 |
this.regExps = {}; |
| 5720 |
this.matchMappings = {}; |
| 5721 |
for (var key in this.states) { |
| 5722 |
var state = this.states[key]; |
| 5723 |
var ruleRegExps = []; |
| 5724 |
var matchTotal = 0; |
| 5725 |
var mapping = this.matchMappings[key] = { defaultToken: "text" }; |
| 5726 |
var flag = "g"; |
| 5727 |
var splitterRurles = []; |
| 5728 |
for (var i = 0; i < state.length; i++) { |
| 5729 |
var rule = state[i]; |
| 5730 |
if (rule.defaultToken) |
| 5731 |
mapping.defaultToken = rule.defaultToken; |
| 5732 |
if (rule.caseInsensitive && flag.indexOf("i") === -1) |
| 5733 |
flag += "i"; |
| 5734 |
if (rule.unicode && flag.indexOf("u") === -1) |
| 5735 |
flag += "u"; |
| 5736 |
if (rule.regex == null) |
| 5737 |
continue; |
| 5738 |
if (rule.regex instanceof RegExp) |
| 5739 |
rule.regex = rule.regex.toString().slice(1, -1); |
| 5740 |
var adjustedregex = rule.regex; |
| 5741 |
var matchcount = new RegExp("(?:(" + adjustedregex + ")|(.))").exec("a").length - 2; |
| 5742 |
if (Array.isArray(rule.token)) { |
| 5743 |
if (rule.token.length == 1 || matchcount == 1) { |
| 5744 |
rule.token = rule.token[0]; |
| 5745 |
} |
| 5746 |
else if (matchcount - 1 != rule.token.length) { |
| 5747 |
this.reportError("number of classes and regexp groups doesn't match", { |
| 5748 |
rule: rule, |
| 5749 |
groupCount: matchcount - 1 |
| 5750 |
}); |
| 5751 |
rule.token = rule.token[0]; |
| 5752 |
} |
| 5753 |
else { |
| 5754 |
rule.tokenArray = rule.token; |
| 5755 |
rule.token = null; |
| 5756 |
rule.onMatch = this.$arrayTokens; |
| 5757 |
} |
| 5758 |
} |
| 5759 |
else if (typeof rule.token == "function" && !rule.onMatch) { |
| 5760 |
if (matchcount > 1) |
| 5761 |
rule.onMatch = this.$applyToken; |
| 5762 |
else |
| 5763 |
rule.onMatch = rule.token; |
| 5764 |
} |
| 5765 |
if (matchcount > 1) { |
| 5766 |
if (/\\\d/.test(rule.regex)) { |
| 5767 |
adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function (match, digit) { |
| 5768 |
return "\\" + (parseInt(digit, 10) + matchTotal + 1); |
| 5769 |
}); |
| 5770 |
} |
| 5771 |
else { |
| 5772 |
matchcount = 1; |
| 5773 |
adjustedregex = this.removeCapturingGroups(rule.regex); |
| 5774 |
} |
| 5775 |
if (!rule.splitRegex && typeof rule.token != "string") |
| 5776 |
splitterRurles.push(rule); |
| 5777 |
} |
| 5778 |
mapping[matchTotal] = i; |
| 5779 |
matchTotal += matchcount; |
| 5780 |
ruleRegExps.push(adjustedregex); |
| 5781 |
if (!rule.onMatch) |
| 5782 |
rule.onMatch = null; |
| 5783 |
} |
| 5784 |
if (!ruleRegExps.length) { |
| 5785 |
mapping[0] = 0; |
| 5786 |
ruleRegExps.push("$"); |
| 5787 |
} |
| 5788 |
splitterRurles.forEach(function (rule) { |
| 5789 |
rule.splitRegex = this.createSplitterRegexp(rule.regex, flag); |
| 5790 |
}, this); |
| 5791 |
this.regExps[key] = new RegExp("(" + ruleRegExps.join(")|(") + ")|($)", flag); |
| 5792 |
} |
| 5793 |
} |
| 5794 |
Tokenizer.prototype.$setMaxTokenCount = function (m) { |
| 5795 |
MAX_TOKEN_COUNT = m | 0; |
| 5796 |
}; |
| 5797 |
Tokenizer.prototype.$applyToken = function (str) { |
| 5798 |
var values = this.splitRegex.exec(str).slice(1); |
| 5799 |
var types = this.token.apply(this, values); |
| 5800 |
if (typeof types === "string") |
| 5801 |
return [{ type: types, value: str }]; |
| 5802 |
var tokens = []; |
| 5803 |
for (var i = 0, l = types.length; i < l; i++) { |
| 5804 |
if (values[i]) |
| 5805 |
tokens[tokens.length] = { |
| 5806 |
type: types[i], |
| 5807 |
value: values[i] |
| 5808 |
}; |
| 5809 |
} |
| 5810 |
return tokens; |
| 5811 |
}; |
| 5812 |
Tokenizer.prototype.$arrayTokens = function (str) { |
| 5813 |
if (!str) |
| 5814 |
return []; |
| 5815 |
var values = this.splitRegex.exec(str); |
| 5816 |
if (!values) |
| 5817 |
return "text"; |
| 5818 |
var tokens = []; |
| 5819 |
var types = this.tokenArray; |
| 5820 |
for (var i = 0, l = types.length; i < l; i++) { |
| 5821 |
if (values[i + 1]) |
| 5822 |
tokens[tokens.length] = { |
| 5823 |
type: types[i], |
| 5824 |
value: values[i + 1] |
| 5825 |
}; |
| 5826 |
} |
| 5827 |
return tokens; |
| 5828 |
}; |
| 5829 |
Tokenizer.prototype.removeCapturingGroups = function (src) { |
| 5830 |
var r = src.replace(/\\.|\[(?:\\.|[^\\\]])*|\(\?[:=!<]|(\()/g, function (x, y) { return y ? "(?:" : x; }); |
| 5831 |
return r; |
| 5832 |
}; |
| 5833 |
Tokenizer.prototype.createSplitterRegexp = function (src, flag) { |
| 5834 |
if (src.indexOf("(?=") != -1) { |
| 5835 |
var stack = 0; |
| 5836 |
var inChClass = false; |
| 5837 |
var lastCapture = {}; |
| 5838 |
src.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g, function (m, esc, parenOpen, parenClose, square, index) { |
| 5839 |
if (inChClass) { |
| 5840 |
inChClass = square != "]"; |
| 5841 |
} |
| 5842 |
else if (square) { |
| 5843 |
inChClass = true; |
| 5844 |
} |
| 5845 |
else if (parenClose) { |
| 5846 |
if (stack == lastCapture.stack) { |
| 5847 |
lastCapture.end = index + 1; |
| 5848 |
lastCapture.stack = -1; |
| 5849 |
} |
| 5850 |
stack--; |
| 5851 |
} |
| 5852 |
else if (parenOpen) { |
| 5853 |
stack++; |
| 5854 |
if (parenOpen.length != 1) { |
| 5855 |
lastCapture.stack = stack; |
| 5856 |
lastCapture.start = index; |
| 5857 |
} |
| 5858 |
} |
| 5859 |
return m; |
| 5860 |
}); |
| 5861 |
if (lastCapture.end != null && /^\)*$/.test(src.substr(lastCapture.end))) |
| 5862 |
src = src.substring(0, lastCapture.start) + src.substr(lastCapture.end); |
| 5863 |
} |
| 5864 |
if (src.charAt(0) != "^") |
| 5865 |
src = "^" + src; |
| 5866 |
if (src.charAt(src.length - 1) != "$") |
| 5867 |
src += "$"; |
| 5868 |
return new RegExp(src, (flag || "").replace("g", "")); |
| 5869 |
}; |
| 5870 |
Tokenizer.prototype.getLineTokens = function (line, startState) { |
| 5871 |
if (startState && typeof startState != "string") { |
| 5872 |
var stack = startState.slice(0); |
| 5873 |
startState = stack[0]; |
| 5874 |
if (startState === "#tmp") { |
| 5875 |
stack.shift(); |
| 5876 |
startState = stack.shift(); |
| 5877 |
} |
| 5878 |
} |
| 5879 |
else |
| 5880 |
var stack = []; |
| 5881 |
var currentState = (startState) || "start"; |
| 5882 |
var state = this.states[currentState]; |
| 5883 |
if (!state) { |
| 5884 |
currentState = "start"; |
| 5885 |
state = this.states[currentState]; |
| 5886 |
} |
| 5887 |
var mapping = this.matchMappings[currentState]; |
| 5888 |
var re = this.regExps[currentState]; |
| 5889 |
re.lastIndex = 0; |
| 5890 |
var match, tokens = []; |
| 5891 |
var lastIndex = 0; |
| 5892 |
var matchAttempts = 0; |
| 5893 |
var token = { type: null, value: "" }; |
| 5894 |
while (match = re.exec(line)) { |
| 5895 |
var type = mapping.defaultToken; |
| 5896 |
var rule = null; |
| 5897 |
var value = match[0]; |
| 5898 |
var index = re.lastIndex; |
| 5899 |
if (index - value.length > lastIndex) { |
| 5900 |
var skipped = line.substring(lastIndex, index - value.length); |
| 5901 |
if (token.type == type) { |
| 5902 |
token.value += skipped; |
| 5903 |
} |
| 5904 |
else { |
| 5905 |
if (token.type) |
| 5906 |
tokens.push(token); |
| 5907 |
token = { type: type, value: skipped }; |
| 5908 |
} |
| 5909 |
} |
| 5910 |
for (var i = 0; i < match.length - 2; i++) { |
| 5911 |
if (match[i + 1] === undefined) |
| 5912 |
continue; |
| 5913 |
rule = state[mapping[i]]; |
| 5914 |
if (rule.onMatch) |
| 5915 |
type = rule.onMatch(value, currentState, stack, line); |
| 5916 |
else |
| 5917 |
type = rule.token; |
| 5918 |
if (rule.next) { |
| 5919 |
if (typeof rule.next == "string") { |
| 5920 |
currentState = rule.next; |
| 5921 |
} |
| 5922 |
else { |
| 5923 |
currentState = rule.next(currentState, stack); |
| 5924 |
} |
| 5925 |
state = this.states[currentState]; |
| 5926 |
if (!state) { |
| 5927 |
this.reportError("state doesn't exist", currentState); |
| 5928 |
currentState = "start"; |
| 5929 |
state = this.states[currentState]; |
| 5930 |
} |
| 5931 |
mapping = this.matchMappings[currentState]; |
| 5932 |
lastIndex = index; |
| 5933 |
re = this.regExps[currentState]; |
| 5934 |
re.lastIndex = index; |
| 5935 |
} |
| 5936 |
if (rule.consumeLineEnd) |
| 5937 |
lastIndex = index; |
| 5938 |
break; |
| 5939 |
} |
| 5940 |
if (value) { |
| 5941 |
if (typeof type === "string") { |
| 5942 |
if ((!rule || rule.merge !== false) && token.type === type) { |
| 5943 |
token.value += value; |
| 5944 |
} |
| 5945 |
else { |
| 5946 |
if (token.type) |
| 5947 |
tokens.push(token); |
| 5948 |
token = { type: type, value: value }; |
| 5949 |
} |
| 5950 |
} |
| 5951 |
else if (type) { |
| 5952 |
if (token.type) |
| 5953 |
tokens.push(token); |
| 5954 |
token = { type: null, value: "" }; |
| 5955 |
for (var i = 0; i < type.length; i++) |
| 5956 |
tokens.push(type[i]); |
| 5957 |
} |
| 5958 |
} |
| 5959 |
if (lastIndex == line.length) |
| 5960 |
break; |
| 5961 |
lastIndex = index; |
| 5962 |
if (matchAttempts++ > MAX_TOKEN_COUNT) { |
| 5963 |
if (matchAttempts > 2 * line.length) { |
| 5964 |
this.reportError("infinite loop with in ace tokenizer", { |
| 5965 |
startState: startState, |
| 5966 |
line: line |
| 5967 |
}); |
| 5968 |
} |
| 5969 |
while (lastIndex < line.length) { |
| 5970 |
if (token.type) |
| 5971 |
tokens.push(token); |
| 5972 |
token = { |
| 5973 |
value: line.substring(lastIndex, lastIndex += 500), |
| 5974 |
type: "overflow" |
| 5975 |
}; |
| 5976 |
} |
| 5977 |
currentState = "start"; |
| 5978 |
stack = []; |
| 5979 |
break; |
| 5980 |
} |
| 5981 |
} |
| 5982 |
if (token.type) |
| 5983 |
tokens.push(token); |
| 5984 |
if (stack.length > 1) { |
| 5985 |
if (stack[0] !== currentState) |
| 5986 |
stack.unshift("#tmp", currentState); |
| 5987 |
} |
| 5988 |
return { |
| 5989 |
tokens: tokens, |
| 5990 |
state: stack.length ? stack : currentState |
| 5991 |
}; |
| 5992 |
}; |
| 5993 |
return Tokenizer; |
| 5994 |
}()); |
| 5995 |
Tokenizer.prototype.reportError = reportError; |
| 5996 |
exports.Tokenizer = Tokenizer; |
| 5997 |
|
| 5998 |
}); |
| 5999 |
|
| 6000 |
ace.define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/deep_copy"], function(require, exports, module){"use strict"; |
| 6001 |
var deepCopy = require("../lib/deep_copy").deepCopy; |
| 6002 |
var TextHighlightRules; |
| 6003 |
TextHighlightRules = function () { |
| 6004 |
this.$rules = { |
| 6005 |
"start": [{ |
| 6006 |
token: "empty_line", |
| 6007 |
regex: '^$' |
| 6008 |
}, { |
| 6009 |
defaultToken: "text" |
| 6010 |
}] |
| 6011 |
}; |
| 6012 |
}; |
| 6013 |
(function () { |
| 6014 |
this.addRules = function (rules, prefix) { |
| 6015 |
if (!prefix) { |
| 6016 |
for (var key in rules) |
| 6017 |
this.$rules[key] = rules[key]; |
| 6018 |
return; |
| 6019 |
} |
| 6020 |
for (var key in rules) { |
| 6021 |
var state = rules[key]; |
| 6022 |
for (var i = 0; i < state.length; i++) { |
| 6023 |
var rule = state[i]; |
| 6024 |
if (rule.next || rule.onMatch) { |
| 6025 |
if (typeof rule.next == "string") { |
| 6026 |
if (rule.next.indexOf(prefix) !== 0) |
| 6027 |
rule.next = prefix + rule.next; |
| 6028 |
} |
| 6029 |
if (rule.nextState && rule.nextState.indexOf(prefix) !== 0) |
| 6030 |
rule.nextState = prefix + rule.nextState; |
| 6031 |
} |
| 6032 |
} |
| 6033 |
this.$rules[prefix + key] = state; |
| 6034 |
} |
| 6035 |
}; |
| 6036 |
this.getRules = function () { |
| 6037 |
return this.$rules; |
| 6038 |
}; |
| 6039 |
this.embedRules = function (HighlightRules, prefix, escapeRules, states, append) { |
| 6040 |
var embedRules = typeof HighlightRules == "function" |
| 6041 |
? new HighlightRules().getRules() |
| 6042 |
: HighlightRules; |
| 6043 |
if (states) { |
| 6044 |
for (var i = 0; i < states.length; i++) |
| 6045 |
states[i] = prefix + states[i]; |
| 6046 |
} |
| 6047 |
else { |
| 6048 |
states = []; |
| 6049 |
for (var key in embedRules) |
| 6050 |
states.push(prefix + key); |
| 6051 |
} |
| 6052 |
this.addRules(embedRules, prefix); |
| 6053 |
if (escapeRules) { |
| 6054 |
var addRules = Array.prototype[append ? "push" : "unshift"]; |
| 6055 |
for (var i = 0; i < states.length; i++) |
| 6056 |
addRules.apply(this.$rules[states[i]], deepCopy(escapeRules)); |
| 6057 |
} |
| 6058 |
if (!this.$embeds) |
| 6059 |
this.$embeds = []; |
| 6060 |
this.$embeds.push(prefix); |
| 6061 |
}; |
| 6062 |
this.getEmbeds = function () { |
| 6063 |
return this.$embeds; |
| 6064 |
}; |
| 6065 |
var pushState = function (currentState, stack) { |
| 6066 |
if (currentState != "start" || stack.length) |
| 6067 |
stack.unshift(this.nextState, currentState); |
| 6068 |
return this.nextState; |
| 6069 |
}; |
| 6070 |
var popState = function (currentState, stack) { |
| 6071 |
stack.shift(); |
| 6072 |
return stack.shift() || "start"; |
| 6073 |
}; |
| 6074 |
this.normalizeRules = function () { |
| 6075 |
var id = 0; |
| 6076 |
var rules = this.$rules; |
| 6077 |
function processState(key) { |
| 6078 |
var state = rules[key]; |
| 6079 |
state["processed"] = true; |
| 6080 |
for (var i = 0; i < state.length; i++) { |
| 6081 |
var rule = state[i]; |
| 6082 |
var toInsert = null; |
| 6083 |
if (Array.isArray(rule)) { |
| 6084 |
toInsert = rule; |
| 6085 |
rule = {}; |
| 6086 |
} |
| 6087 |
if (!rule.regex && rule.start) { |
| 6088 |
rule.regex = rule.start; |
| 6089 |
if (!rule.next) |
| 6090 |
rule.next = []; |
| 6091 |
rule.next.push({ |
| 6092 |
defaultToken: rule.token |
| 6093 |
}, { |
| 6094 |
token: rule.token + ".end", |
| 6095 |
regex: rule.end || rule.start, |
| 6096 |
next: "pop" |
| 6097 |
}); |
| 6098 |
rule.token = rule.token + ".start"; |
| 6099 |
rule.push = true; |
| 6100 |
} |
| 6101 |
var next = rule.next || rule.push; |
| 6102 |
if (next && Array.isArray(next)) { |
| 6103 |
var stateName = rule.stateName; |
| 6104 |
if (!stateName) { |
| 6105 |
stateName = rule.token; |
| 6106 |
if (typeof stateName != "string") |
| 6107 |
stateName = stateName[0] || ""; |
| 6108 |
if (rules[stateName]) |
| 6109 |
stateName += id++; |
| 6110 |
} |
| 6111 |
rules[stateName] = next; |
| 6112 |
rule.next = stateName; |
| 6113 |
processState(stateName); |
| 6114 |
} |
| 6115 |
else if (next == "pop") { |
| 6116 |
rule.next = popState; |
| 6117 |
} |
| 6118 |
if (rule.push) { |
| 6119 |
rule.nextState = rule.next || rule.push; |
| 6120 |
rule.next = pushState; |
| 6121 |
delete rule.push; |
| 6122 |
} |
| 6123 |
if (rule.rules) { |
| 6124 |
for (var r in rule.rules) { |
| 6125 |
if (rules[r]) { |
| 6126 |
if (rules[r].push) |
| 6127 |
rules[r].push.apply(rules[r], rule.rules[r]); |
| 6128 |
} |
| 6129 |
else { |
| 6130 |
rules[r] = rule.rules[r]; |
| 6131 |
} |
| 6132 |
} |
| 6133 |
} |
| 6134 |
var includeName = typeof rule == "string" ? rule : rule.include; |
| 6135 |
if (includeName) { |
| 6136 |
if (includeName === "$self") |
| 6137 |
includeName = "start"; |
| 6138 |
if (Array.isArray(includeName)) |
| 6139 |
toInsert = includeName.map(function (x) { return rules[x]; }); |
| 6140 |
else |
| 6141 |
toInsert = rules[includeName]; |
| 6142 |
} |
| 6143 |
if (toInsert) { |
| 6144 |
var args = [i, 1].concat(toInsert); |
| 6145 |
if (rule.noEscape) |
| 6146 |
args = args.filter(function (x) { return !x.next; }); |
| 6147 |
state.splice.apply(state, args); |
| 6148 |
i--; |
| 6149 |
} |
| 6150 |
if (rule.keywordMap) { |
| 6151 |
rule.token = this.createKeywordMapper(rule.keywordMap, rule.defaultToken || "text", rule.caseInsensitive); |
| 6152 |
delete rule.defaultToken; |
| 6153 |
} |
| 6154 |
} |
| 6155 |
} |
| 6156 |
Object.keys(rules).forEach(processState, this); |
| 6157 |
}; |
| 6158 |
this.createKeywordMapper = function (map, defaultToken, ignoreCase, splitChar) { |
| 6159 |
var keywords = Object.create(null); |
| 6160 |
this.$keywordList = []; |
| 6161 |
Object.keys(map).forEach(function (className) { |
| 6162 |
var a = map[className]; |
| 6163 |
var list = a.split(splitChar || "|"); |
| 6164 |
for (var i = list.length; i--;) { |
| 6165 |
var word = list[i]; |
| 6166 |
this.$keywordList.push(word); |
| 6167 |
if (ignoreCase) |
| 6168 |
word = word.toLowerCase(); |
| 6169 |
keywords[word] = className; |
| 6170 |
} |
| 6171 |
}, this); |
| 6172 |
map = null; |
| 6173 |
return ignoreCase |
| 6174 |
? function (value) { return keywords[value.toLowerCase()] || defaultToken; } |
| 6175 |
: function (value) { return keywords[value] || defaultToken; }; |
| 6176 |
}; |
| 6177 |
this.getKeywords = function () { |
| 6178 |
return this.$keywords; |
| 6179 |
}; |
| 6180 |
}).call(TextHighlightRules.prototype); |
| 6181 |
exports.TextHighlightRules = TextHighlightRules; |
| 6182 |
|
| 6183 |
}); |
| 6184 |
|
| 6185 |
ace.define("ace/mode/behaviour",["require","exports","module"], function(require, exports, module){"use strict"; |
| 6186 |
var Behaviour; |
| 6187 |
Behaviour = function () { |
| 6188 |
this.$behaviours = {}; |
| 6189 |
}; |
| 6190 |
(function () { |
| 6191 |
this.add = function (name, action, callback) { |
| 6192 |
switch (undefined) { |
| 6193 |
case this.$behaviours: |
| 6194 |
this.$behaviours = {}; |
| 6195 |
case this.$behaviours[name]: |
| 6196 |
this.$behaviours[name] = {}; |
| 6197 |
} |
| 6198 |
this.$behaviours[name][action] = callback; |
| 6199 |
}; |
| 6200 |
this.addBehaviours = function (behaviours) { |
| 6201 |
for (var key in behaviours) { |
| 6202 |
for (var action in behaviours[key]) { |
| 6203 |
this.add(key, action, behaviours[key][action]); |
| 6204 |
} |
| 6205 |
} |
| 6206 |
}; |
| 6207 |
this.remove = function (name) { |
| 6208 |
if (this.$behaviours && this.$behaviours[name]) { |
| 6209 |
delete this.$behaviours[name]; |
| 6210 |
} |
| 6211 |
}; |
| 6212 |
this.inherit = function (mode, filter) { |
| 6213 |
if (typeof mode === "function") { |
| 6214 |
var behaviours = new mode().getBehaviours(filter); |
| 6215 |
} |
| 6216 |
else { |
| 6217 |
var behaviours = mode.getBehaviours(filter); |
| 6218 |
} |
| 6219 |
this.addBehaviours(behaviours); |
| 6220 |
}; |
| 6221 |
this.getBehaviours = function (filter) { |
| 6222 |
if (!filter) { |
| 6223 |
return this.$behaviours; |
| 6224 |
} |
| 6225 |
else { |
| 6226 |
var ret = {}; |
| 6227 |
for (var i = 0; i < filter.length; i++) { |
| 6228 |
if (this.$behaviours[filter[i]]) { |
| 6229 |
ret[filter[i]] = this.$behaviours[filter[i]]; |
| 6230 |
} |
| 6231 |
} |
| 6232 |
return ret; |
| 6233 |
} |
| 6234 |
}; |
| 6235 |
}).call(Behaviour.prototype); |
| 6236 |
exports.Behaviour = Behaviour; |
| 6237 |
|
| 6238 |
}); |
| 6239 |
|
| 6240 |
ace.define("ace/token_iterator",["require","exports","module","ace/range"], function(require, exports, module){"use strict"; |
| 6241 |
var Range = require("./range").Range; |
| 6242 |
var TokenIterator = (function () { |
| 6243 |
function TokenIterator(session, initialRow, initialColumn) { |
| 6244 |
this.$session = session; |
| 6245 |
this.$row = initialRow; |
| 6246 |
this.$rowTokens = session.getTokens(initialRow); |
| 6247 |
var token = session.getTokenAt(initialRow, initialColumn); |
| 6248 |
this.$tokenIndex = token ? token.index : -1; |
| 6249 |
} |
| 6250 |
TokenIterator.prototype.stepBackward = function () { |
| 6251 |
this.$tokenIndex -= 1; |
| 6252 |
while (this.$tokenIndex < 0) { |
| 6253 |
this.$row -= 1; |
| 6254 |
if (this.$row < 0) { |
| 6255 |
this.$row = 0; |
| 6256 |
return null; |
| 6257 |
} |
| 6258 |
this.$rowTokens = this.$session.getTokens(this.$row); |
| 6259 |
this.$tokenIndex = this.$rowTokens.length - 1; |
| 6260 |
} |
| 6261 |
return this.$rowTokens[this.$tokenIndex]; |
| 6262 |
}; |
| 6263 |
TokenIterator.prototype.stepForward = function () { |
| 6264 |
this.$tokenIndex += 1; |
| 6265 |
var rowCount; |
| 6266 |
while (this.$tokenIndex >= this.$rowTokens.length) { |
| 6267 |
this.$row += 1; |
| 6268 |
if (!rowCount) |
| 6269 |
rowCount = this.$session.getLength(); |
| 6270 |
if (this.$row >= rowCount) { |
| 6271 |
this.$row = rowCount - 1; |
| 6272 |
return null; |
| 6273 |
} |
| 6274 |
this.$rowTokens = this.$session.getTokens(this.$row); |
| 6275 |
this.$tokenIndex = 0; |
| 6276 |
} |
| 6277 |
return this.$rowTokens[this.$tokenIndex]; |
| 6278 |
}; |
| 6279 |
TokenIterator.prototype.getCurrentToken = function () { |
| 6280 |
return this.$rowTokens[this.$tokenIndex]; |
| 6281 |
}; |
| 6282 |
TokenIterator.prototype.getCurrentTokenRow = function () { |
| 6283 |
return this.$row; |
| 6284 |
}; |
| 6285 |
TokenIterator.prototype.getCurrentTokenColumn = function () { |
| 6286 |
var rowTokens = this.$rowTokens; |
| 6287 |
var tokenIndex = this.$tokenIndex; |
| 6288 |
var column = rowTokens[tokenIndex].start; |
| 6289 |
if (column !== undefined) |
| 6290 |
return column; |
| 6291 |
column = 0; |
| 6292 |
while (tokenIndex > 0) { |
| 6293 |
tokenIndex -= 1; |
| 6294 |
column += rowTokens[tokenIndex].value.length; |
| 6295 |
} |
| 6296 |
return column; |
| 6297 |
}; |
| 6298 |
TokenIterator.prototype.getCurrentTokenPosition = function () { |
| 6299 |
return { row: this.$row, column: this.getCurrentTokenColumn() }; |
| 6300 |
}; |
| 6301 |
TokenIterator.prototype.getCurrentTokenRange = function () { |
| 6302 |
var token = this.$rowTokens[this.$tokenIndex]; |
| 6303 |
var column = this.getCurrentTokenColumn(); |
| 6304 |
return new Range(this.$row, column, this.$row, column + token.value.length); |
| 6305 |
}; |
| 6306 |
return TokenIterator; |
| 6307 |
}()); |
| 6308 |
exports.TokenIterator = TokenIterator; |
| 6309 |
|
| 6310 |
}); |
| 6311 |
|
| 6312 |
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){"use strict"; |
| 6313 |
var oop = require("../../lib/oop"); |
| 6314 |
var Behaviour = require("../behaviour").Behaviour; |
| 6315 |
var TokenIterator = require("../../token_iterator").TokenIterator; |
| 6316 |
var lang = require("../../lib/lang"); |
| 6317 |
var SAFE_INSERT_IN_TOKENS = ["text", "paren.rparen", "rparen", "paren", "punctuation.operator"]; |
| 6318 |
var SAFE_INSERT_BEFORE_TOKENS = ["text", "paren.rparen", "rparen", "paren", "punctuation.operator", "comment"]; |
| 6319 |
var context; |
| 6320 |
var contextCache = {}; |
| 6321 |
var defaultQuotes = { '"': '"', "'": "'" }; |
| 6322 |
var initContext = function (editor) { |
| 6323 |
var id = -1; |
| 6324 |
if (editor.multiSelect) { |
| 6325 |
id = editor.selection.index; |
| 6326 |
if (contextCache.rangeCount != editor.multiSelect.rangeCount) |
| 6327 |
contextCache = { rangeCount: editor.multiSelect.rangeCount }; |
| 6328 |
} |
| 6329 |
if (contextCache[id]) |
| 6330 |
return context = contextCache[id]; |
| 6331 |
context = contextCache[id] = { |
| 6332 |
autoInsertedBrackets: 0, |
| 6333 |
autoInsertedRow: -1, |
| 6334 |
autoInsertedLineEnd: "", |
| 6335 |
maybeInsertedBrackets: 0, |
| 6336 |
maybeInsertedRow: -1, |
| 6337 |
maybeInsertedLineStart: "", |
| 6338 |
maybeInsertedLineEnd: "" |
| 6339 |
}; |
| 6340 |
}; |
| 6341 |
var getWrapped = function (selection, selected, opening, closing) { |
| 6342 |
var rowDiff = selection.end.row - selection.start.row; |
| 6343 |
return { |
| 6344 |
text: opening + selected + closing, |
| 6345 |
selection: [ |
| 6346 |
0, |
| 6347 |
selection.start.column + 1, |
| 6348 |
rowDiff, |
| 6349 |
selection.end.column + (rowDiff ? 0 : 1) |
| 6350 |
] |
| 6351 |
}; |
| 6352 |
}; |
| 6353 |
var CstyleBehaviour; |
| 6354 |
CstyleBehaviour = function (options) { |
| 6355 |
options = options || {}; |
| 6356 |
this.add("braces", "insertion", function (state, action, editor, session, text) { |
| 6357 |
var cursor = editor.getCursorPosition(); |
| 6358 |
var line = session.doc.getLine(cursor.row); |
| 6359 |
if (text == '{') { |
| 6360 |
initContext(editor); |
| 6361 |
var selection = editor.getSelectionRange(); |
| 6362 |
var selected = session.doc.getTextRange(selection); |
| 6363 |
if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) { |
| 6364 |
return getWrapped(selection, selected, '{', '}'); |
| 6365 |
} |
| 6366 |
else if (CstyleBehaviour.isSaneInsertion(editor, session)) { |
| 6367 |
if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode || options.braces) { |
| 6368 |
CstyleBehaviour.recordAutoInsert(editor, session, "}"); |
| 6369 |
return { |
| 6370 |
text: '{}', |
| 6371 |
selection: [1, 1] |
| 6372 |
}; |
| 6373 |
} |
| 6374 |
else { |
| 6375 |
CstyleBehaviour.recordMaybeInsert(editor, session, "{"); |
| 6376 |
return { |
| 6377 |
text: '{', |
| 6378 |
selection: [1, 1] |
| 6379 |
}; |
| 6380 |
} |
| 6381 |
} |
| 6382 |
} |
| 6383 |
else if (text == '}') { |
| 6384 |
initContext(editor); |
| 6385 |
var rightChar = line.substring(cursor.column, cursor.column + 1); |
| 6386 |
if (rightChar == '}') { |
| 6387 |
var matching = session.$findOpeningBracket('}', { column: cursor.column + 1, row: cursor.row }); |
| 6388 |
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { |
| 6389 |
CstyleBehaviour.popAutoInsertedClosing(); |
| 6390 |
return { |
| 6391 |
text: '', |
| 6392 |
selection: [1, 1] |
| 6393 |
}; |
| 6394 |
} |
| 6395 |
} |
| 6396 |
} |
| 6397 |
else if (text == "\n" || text == "\r\n") { |
| 6398 |
initContext(editor); |
| 6399 |
var closing = ""; |
| 6400 |
if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) { |
| 6401 |
closing = lang.stringRepeat("}", context.maybeInsertedBrackets); |
| 6402 |
CstyleBehaviour.clearMaybeInsertedClosing(); |
| 6403 |
} |
| 6404 |
var rightChar = line.substring(cursor.column, cursor.column + 1); |
| 6405 |
if (rightChar === '}') { |
| 6406 |
var openBracePos = session.findMatchingBracket({ row: cursor.row, column: cursor.column + 1 }, '}'); |
| 6407 |
if (!openBracePos) |
| 6408 |
return null; |
| 6409 |
var next_indent = this.$getIndent(session.getLine(openBracePos.row)); |
| 6410 |
} |
| 6411 |
else if (closing) { |
| 6412 |
var next_indent = this.$getIndent(line); |
| 6413 |
} |
| 6414 |
else { |
| 6415 |
CstyleBehaviour.clearMaybeInsertedClosing(); |
| 6416 |
return; |
| 6417 |
} |
| 6418 |
var indent = next_indent + session.getTabString(); |
| 6419 |
return { |
| 6420 |
text: '\n' + indent + '\n' + next_indent + closing, |
| 6421 |
selection: [1, indent.length, 1, indent.length] |
| 6422 |
}; |
| 6423 |
} |
| 6424 |
else { |
| 6425 |
CstyleBehaviour.clearMaybeInsertedClosing(); |
| 6426 |
} |
| 6427 |
}); |
| 6428 |
this.add("braces", "deletion", function (state, action, editor, session, range) { |
| 6429 |
var selected = session.doc.getTextRange(range); |
| 6430 |
if (!range.isMultiLine() && selected == '{') { |
| 6431 |
initContext(editor); |
| 6432 |
var line = session.doc.getLine(range.start.row); |
| 6433 |
var rightChar = line.substring(range.end.column, range.end.column + 1); |
| 6434 |
if (rightChar == '}') { |
| 6435 |
range.end.column++; |
| 6436 |
return range; |
| 6437 |
} |
| 6438 |
else { |
| 6439 |
context.maybeInsertedBrackets--; |
| 6440 |
} |
| 6441 |
} |
| 6442 |
}); |
| 6443 |
this.add("parens", "insertion", function (state, action, editor, session, text) { |
| 6444 |
if (text == '(') { |
| 6445 |
initContext(editor); |
| 6446 |
var selection = editor.getSelectionRange(); |
| 6447 |
var selected = session.doc.getTextRange(selection); |
| 6448 |
if (selected !== "" && editor.getWrapBehavioursEnabled()) { |
| 6449 |
return getWrapped(selection, selected, '(', ')'); |
| 6450 |
} |
| 6451 |
else if (CstyleBehaviour.isSaneInsertion(editor, session)) { |
| 6452 |
CstyleBehaviour.recordAutoInsert(editor, session, ")"); |
| 6453 |
return { |
| 6454 |
text: '()', |
| 6455 |
selection: [1, 1] |
| 6456 |
}; |
| 6457 |
} |
| 6458 |
} |
| 6459 |
else if (text == ')') { |
| 6460 |
initContext(editor); |
| 6461 |
var cursor = editor.getCursorPosition(); |
| 6462 |
var line = session.doc.getLine(cursor.row); |
| 6463 |
var rightChar = line.substring(cursor.column, cursor.column + 1); |
| 6464 |
if (rightChar == ')') { |
| 6465 |
var matching = session.$findOpeningBracket(')', { column: cursor.column + 1, row: cursor.row }); |
| 6466 |
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { |
| 6467 |
CstyleBehaviour.popAutoInsertedClosing(); |
| 6468 |
return { |
| 6469 |
text: '', |
| 6470 |
selection: [1, 1] |
| 6471 |
}; |
| 6472 |
} |
| 6473 |
} |
| 6474 |
} |
| 6475 |
}); |
| 6476 |
this.add("parens", "deletion", function (state, action, editor, session, range) { |
| 6477 |
var selected = session.doc.getTextRange(range); |
| 6478 |
if (!range.isMultiLine() && selected == '(') { |
| 6479 |
initContext(editor); |
| 6480 |
var line = session.doc.getLine(range.start.row); |
| 6481 |
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); |
| 6482 |
if (rightChar == ')') { |
| 6483 |
range.end.column++; |
| 6484 |
return range; |
| 6485 |
} |
| 6486 |
} |
| 6487 |
}); |
| 6488 |
this.add("brackets", "insertion", function (state, action, editor, session, text) { |
| 6489 |
if (text == '[') { |
| 6490 |
initContext(editor); |
| 6491 |
var selection = editor.getSelectionRange(); |
| 6492 |
var selected = session.doc.getTextRange(selection); |
| 6493 |
if (selected !== "" && editor.getWrapBehavioursEnabled()) { |
| 6494 |
return getWrapped(selection, selected, '[', ']'); |
| 6495 |
} |
| 6496 |
else if (CstyleBehaviour.isSaneInsertion(editor, session)) { |
| 6497 |
CstyleBehaviour.recordAutoInsert(editor, session, "]"); |
| 6498 |
return { |
| 6499 |
text: '[]', |
| 6500 |
selection: [1, 1] |
| 6501 |
}; |
| 6502 |
} |
| 6503 |
} |
| 6504 |
else if (text == ']') { |
| 6505 |
initContext(editor); |
| 6506 |
var cursor = editor.getCursorPosition(); |
| 6507 |
var line = session.doc.getLine(cursor.row); |
| 6508 |
var rightChar = line.substring(cursor.column, cursor.column + 1); |
| 6509 |
if (rightChar == ']') { |
| 6510 |
var matching = session.$findOpeningBracket(']', { column: cursor.column + 1, row: cursor.row }); |
| 6511 |
if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) { |
| 6512 |
CstyleBehaviour.popAutoInsertedClosing(); |
| 6513 |
return { |
| 6514 |
text: '', |
| 6515 |
selection: [1, 1] |
| 6516 |
}; |
| 6517 |
} |
| 6518 |
} |
| 6519 |
} |
| 6520 |
}); |
| 6521 |
this.add("brackets", "deletion", function (state, action, editor, session, range) { |
| 6522 |
var selected = session.doc.getTextRange(range); |
| 6523 |
if (!range.isMultiLine() && selected == '[') { |
| 6524 |
initContext(editor); |
| 6525 |
var line = session.doc.getLine(range.start.row); |
| 6526 |
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); |
| 6527 |
if (rightChar == ']') { |
| 6528 |
range.end.column++; |
| 6529 |
return range; |
| 6530 |
} |
| 6531 |
} |
| 6532 |
}); |
| 6533 |
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { |
| 6534 |
var quotes = session.$mode.$quotes || defaultQuotes; |
| 6535 |
if (text.length == 1 && quotes[text]) { |
| 6536 |
if (this.lineCommentStart && this.lineCommentStart.indexOf(text) != -1) |
| 6537 |
return; |
| 6538 |
initContext(editor); |
| 6539 |
var quote = text; |
| 6540 |
var selection = editor.getSelectionRange(); |
| 6541 |
var selected = session.doc.getTextRange(selection); |
| 6542 |
if (selected !== "" && (selected.length != 1 || !quotes[selected]) && editor.getWrapBehavioursEnabled()) { |
| 6543 |
return getWrapped(selection, selected, quote, quote); |
| 6544 |
} |
| 6545 |
else if (!selected) { |
| 6546 |
var cursor = editor.getCursorPosition(); |
| 6547 |
var line = session.doc.getLine(cursor.row); |
| 6548 |
var leftChar = line.substring(cursor.column - 1, cursor.column); |
| 6549 |
var rightChar = line.substring(cursor.column, cursor.column + 1); |
| 6550 |
var token = session.getTokenAt(cursor.row, cursor.column); |
| 6551 |
var rightToken = session.getTokenAt(cursor.row, cursor.column + 1); |
| 6552 |
if (leftChar == "\\" && token && /escape/.test(token.type)) |
| 6553 |
return null; |
| 6554 |
var stringBefore = token && /string|escape/.test(token.type); |
| 6555 |
var stringAfter = !rightToken || /string|escape/.test(rightToken.type); |
| 6556 |
var pair; |
| 6557 |
if (rightChar == quote) { |
| 6558 |
pair = stringBefore !== stringAfter; |
| 6559 |
if (pair && /string\.end/.test(rightToken.type)) |
| 6560 |
pair = false; |
| 6561 |
} |
| 6562 |
else { |
| 6563 |
if (stringBefore && !stringAfter) |
| 6564 |
return null; |
| 6565 |
if (stringBefore && stringAfter) |
| 6566 |
return null; |
| 6567 |
var wordRe = session.$mode.tokenRe; |
| 6568 |
wordRe.lastIndex = 0; |
| 6569 |
var isWordBefore = wordRe.test(leftChar); |
| 6570 |
wordRe.lastIndex = 0; |
| 6571 |
var isWordAfter = wordRe.test(rightChar); |
| 6572 |
var pairQuotesAfter = session.$mode.$pairQuotesAfter; |
| 6573 |
var shouldPairQuotes = pairQuotesAfter && pairQuotesAfter[quote] && pairQuotesAfter[quote].test(leftChar); |
| 6574 |
if ((!shouldPairQuotes && isWordBefore) || isWordAfter) |
| 6575 |
return null; |
| 6576 |
if (rightChar && !/[\s;,.})\]\\]/.test(rightChar)) |
| 6577 |
return null; |
| 6578 |
var charBefore = line[cursor.column - 2]; |
| 6579 |
if (leftChar == quote && (charBefore == quote || wordRe.test(charBefore))) |
| 6580 |
return null; |
| 6581 |
pair = true; |
| 6582 |
} |
| 6583 |
return { |
| 6584 |
text: pair ? quote + quote : "", |
| 6585 |
selection: [1, 1] |
| 6586 |
}; |
| 6587 |
} |
| 6588 |
} |
| 6589 |
}); |
| 6590 |
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) { |
| 6591 |
var quotes = session.$mode.$quotes || defaultQuotes; |
| 6592 |
var selected = session.doc.getTextRange(range); |
| 6593 |
if (!range.isMultiLine() && quotes.hasOwnProperty(selected)) { |
| 6594 |
initContext(editor); |
| 6595 |
var line = session.doc.getLine(range.start.row); |
| 6596 |
var rightChar = line.substring(range.start.column + 1, range.start.column + 2); |
| 6597 |
if (rightChar == selected) { |
| 6598 |
range.end.column++; |
| 6599 |
return range; |
| 6600 |
} |
| 6601 |
} |
| 6602 |
}); |
| 6603 |
if (options.closeDocComment !== false) { |
| 6604 |
this.add("doc comment end", "insertion", function (state, action, editor, session, text) { |
| 6605 |
if (state === "doc-start" && (text === "\n" || text === "\r\n") && editor.selection.isEmpty()) { |
| 6606 |
var cursor = editor.getCursorPosition(); |
| 6607 |
var line = session.doc.getLine(cursor.row); |
| 6608 |
var nextLine = session.doc.getLine(cursor.row + 1); |
| 6609 |
var indent = this.$getIndent(line); |
| 6610 |
if (/\s*\*/.test(nextLine)) { |
| 6611 |
if (/^\s*\*/.test(line)) { |
| 6612 |
return { |
| 6613 |
text: text + indent + "* ", |
| 6614 |
selection: [1, 3 + indent.length, 1, 3 + indent.length] |
| 6615 |
}; |
| 6616 |
} |
| 6617 |
else { |
| 6618 |
return { |
| 6619 |
text: text + indent + " * ", |
| 6620 |
selection: [1, 3 + indent.length, 1, 3 + indent.length] |
| 6621 |
}; |
| 6622 |
} |
| 6623 |
} |
| 6624 |
if (/\/\*\*/.test(line.substring(0, cursor.column))) { |
| 6625 |
return { |
| 6626 |
text: text + indent + " * " + text + " " + indent + "*/", |
| 6627 |
selection: [1, 4 + indent.length, 1, 4 + indent.length] |
| 6628 |
}; |
| 6629 |
} |
| 6630 |
} |
| 6631 |
}); |
| 6632 |
} |
| 6633 |
}; |
| 6634 |
CstyleBehaviour.isSaneInsertion = function (editor, session) { |
| 6635 |
var cursor = editor.getCursorPosition(); |
| 6636 |
var iterator = new TokenIterator(session, cursor.row, cursor.column); |
| 6637 |
if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) { |
| 6638 |
if (/[)}\]]/.test(editor.session.getLine(cursor.row)[cursor.column])) |
| 6639 |
return true; |
| 6640 |
var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1); |
| 6641 |
if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) |
| 6642 |
return false; |
| 6643 |
} |
| 6644 |
iterator.stepForward(); |
| 6645 |
return iterator.getCurrentTokenRow() !== cursor.row || |
| 6646 |
this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS); |
| 6647 |
}; |
| 6648 |
CstyleBehaviour["$matchTokenType"] = function (token, types) { |
| 6649 |
return types.indexOf(token.type || token) > -1; |
| 6650 |
}; |
| 6651 |
CstyleBehaviour["recordAutoInsert"] = function (editor, session, bracket) { |
| 6652 |
var cursor = editor.getCursorPosition(); |
| 6653 |
var line = session.doc.getLine(cursor.row); |
| 6654 |
if (!this["isAutoInsertedClosing"](cursor, line, context.autoInsertedLineEnd[0])) |
| 6655 |
context.autoInsertedBrackets = 0; |
| 6656 |
context.autoInsertedRow = cursor.row; |
| 6657 |
context.autoInsertedLineEnd = bracket + line.substr(cursor.column); |
| 6658 |
context.autoInsertedBrackets++; |
| 6659 |
}; |
| 6660 |
CstyleBehaviour["recordMaybeInsert"] = function (editor, session, bracket) { |
| 6661 |
var cursor = editor.getCursorPosition(); |
| 6662 |
var line = session.doc.getLine(cursor.row); |
| 6663 |
if (!this["isMaybeInsertedClosing"](cursor, line)) |
| 6664 |
context.maybeInsertedBrackets = 0; |
| 6665 |
context.maybeInsertedRow = cursor.row; |
| 6666 |
context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket; |
| 6667 |
context.maybeInsertedLineEnd = line.substr(cursor.column); |
| 6668 |
context.maybeInsertedBrackets++; |
| 6669 |
}; |
| 6670 |
CstyleBehaviour["isAutoInsertedClosing"] = function (cursor, line, bracket) { |
| 6671 |
return context.autoInsertedBrackets > 0 && |
| 6672 |
cursor.row === context.autoInsertedRow && |
| 6673 |
bracket === context.autoInsertedLineEnd[0] && |
| 6674 |
line.substr(cursor.column) === context.autoInsertedLineEnd; |
| 6675 |
}; |
| 6676 |
CstyleBehaviour["isMaybeInsertedClosing"] = function (cursor, line) { |
| 6677 |
return context.maybeInsertedBrackets > 0 && |
| 6678 |
cursor.row === context.maybeInsertedRow && |
| 6679 |
line.substr(cursor.column) === context.maybeInsertedLineEnd && |
| 6680 |
line.substr(0, cursor.column) == context.maybeInsertedLineStart; |
| 6681 |
}; |
| 6682 |
CstyleBehaviour["popAutoInsertedClosing"] = function () { |
| 6683 |
context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1); |
| 6684 |
context.autoInsertedBrackets--; |
| 6685 |
}; |
| 6686 |
CstyleBehaviour["clearMaybeInsertedClosing"] = function () { |
| 6687 |
if (context) { |
| 6688 |
context.maybeInsertedBrackets = 0; |
| 6689 |
context.maybeInsertedRow = -1; |
| 6690 |
} |
| 6691 |
}; |
| 6692 |
oop.inherits(CstyleBehaviour, Behaviour); |
| 6693 |
exports.CstyleBehaviour = CstyleBehaviour; |
| 6694 |
|
| 6695 |
}); |
| 6696 |
|
| 6697 |
ace.define("ace/unicode",["require","exports","module"], function(require, exports, module){"use strict"; |
| 6698 |
var wordChars = [48, 9, 8, 25, 5, 0, 2, 25, 48, 0, 11, 0, 5, 0, 6, 22, 2, 30, 2, 457, 5, 11, 15, 4, 8, 0, 2, 0, 18, 116, 2, 1, 3, 3, 9, 0, 2, 2, 2, 0, 2, 19, 2, 82, 2, 138, 2, 4, 3, 155, 12, 37, 3, 0, 8, 38, 10, 44, 2, 0, 2, 1, 2, 1, 2, 0, 9, 26, 6, 2, 30, 10, 7, 61, 2, 9, 5, 101, 2, 7, 3, 9, 2, 18, 3, 0, 17, 58, 3, 100, 15, 53, 5, 0, 6, 45, 211, 57, 3, 18, 2, 5, 3, 11, 3, 9, 2, 1, 7, 6, 2, 2, 2, 7, 3, 1, 3, 21, 2, 6, 2, 0, 4, 3, 3, 8, 3, 1, 3, 3, 9, 0, 5, 1, 2, 4, 3, 11, 16, 2, 2, 5, 5, 1, 3, 21, 2, 6, 2, 1, 2, 1, 2, 1, 3, 0, 2, 4, 5, 1, 3, 2, 4, 0, 8, 3, 2, 0, 8, 15, 12, 2, 2, 8, 2, 2, 2, 21, 2, 6, 2, 1, 2, 4, 3, 9, 2, 2, 2, 2, 3, 0, 16, 3, 3, 9, 18, 2, 2, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 3, 8, 3, 1, 3, 2, 9, 1, 5, 1, 2, 4, 3, 9, 2, 0, 17, 1, 2, 5, 4, 2, 2, 3, 4, 1, 2, 0, 2, 1, 4, 1, 4, 2, 4, 11, 5, 4, 4, 2, 2, 3, 3, 0, 7, 0, 15, 9, 18, 2, 2, 7, 2, 2, 2, 22, 2, 9, 2, 4, 4, 7, 2, 2, 2, 3, 8, 1, 2, 1, 7, 3, 3, 9, 19, 1, 2, 7, 2, 2, 2, 22, 2, 9, 2, 4, 3, 8, 2, 2, 2, 3, 8, 1, 8, 0, 2, 3, 3, 9, 19, 1, 2, 7, 2, 2, 2, 22, 2, 15, 4, 7, 2, 2, 2, 3, 10, 0, 9, 3, 3, 9, 11, 5, 3, 1, 2, 17, 4, 23, 2, 8, 2, 0, 3, 6, 4, 0, 5, 5, 2, 0, 2, 7, 19, 1, 14, 57, 6, 14, 2, 9, 40, 1, 2, 0, 3, 1, 2, 0, 3, 0, 7, 3, 2, 6, 2, 2, 2, 0, 2, 0, 3, 1, 2, 12, 2, 2, 3, 4, 2, 0, 2, 5, 3, 9, 3, 1, 35, 0, 24, 1, 7, 9, 12, 0, 2, 0, 2, 0, 5, 9, 2, 35, 5, 19, 2, 5, 5, 7, 2, 35, 10, 0, 58, 73, 7, 77, 3, 37, 11, 42, 2, 0, 4, 328, 2, 3, 3, 6, 2, 0, 2, 3, 3, 40, 2, 3, 3, 32, 2, 3, 3, 6, 2, 0, 2, 3, 3, 14, 2, 56, 2, 3, 3, 66, 5, 0, 33, 15, 17, 84, 13, 619, 3, 16, 2, 25, 6, 74, 22, 12, 2, 6, 12, 20, 12, 19, 13, 12, 2, 2, 2, 1, 13, 51, 3, 29, 4, 0, 5, 1, 3, 9, 34, 2, 3, 9, 7, 87, 9, 42, 6, 69, 11, 28, 4, 11, 5, 11, 11, 39, 3, 4, 12, 43, 5, 25, 7, 10, 38, 27, 5, 62, 2, 28, 3, 10, 7, 9, 14, 0, 89, 75, 5, 9, 18, 8, 13, 42, 4, 11, 71, 55, 9, 9, 4, 48, 83, 2, 2, 30, 14, 230, 23, 280, 3, 5, 3, 37, 3, 5, 3, 7, 2, 0, 2, 0, 2, 0, 2, 30, 3, 52, 2, 6, 2, 0, 4, 2, 2, 6, 4, 3, 3, 5, 5, 12, 6, 2, 2, 6, 67, 1, 20, 0, 29, 0, 14, 0, 17, 4, 60, 12, 5, 0, 4, 11, 18, 0, 5, 0, 3, 9, 2, 0, 4, 4, 7, 0, 2, 0, 2, 0, 2, 3, 2, 10, 3, 3, 6, 4, 5, 0, 53, 1, 2684, 46, 2, 46, 2, 132, 7, 6, 15, 37, 11, 53, 10, 0, 17, 22, 10, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 6, 2, 31, 48, 0, 470, 1, 36, 5, 2, 4, 6, 1, 5, 85, 3, 1, 3, 2, 2, 89, 2, 3, 6, 40, 4, 93, 18, 23, 57, 15, 513, 6581, 75, 20939, 53, 1164, 68, 45, 3, 268, 4, 27, 21, 31, 3, 13, 13, 1, 2, 24, 9, 69, 11, 1, 38, 8, 3, 102, 3, 1, 111, 44, 25, 51, 13, 68, 12, 9, 7, 23, 4, 0, 5, 45, 3, 35, 13, 28, 4, 64, 15, 10, 39, 54, 10, 13, 3, 9, 7, 22, 4, 1, 5, 66, 25, 2, 227, 42, 2, 1, 3, 9, 7, 11171, 13, 22, 5, 48, 8453, 301, 3, 61, 3, 105, 39, 6, 13, 4, 6, 11, 2, 12, 2, 4, 2, 0, 2, 1, 2, 1, 2, 107, 34, 362, 19, 63, 3, 53, 41, 11, 5, 15, 17, 6, 13, 1, 25, 2, 33, 4, 2, 134, 20, 9, 8, 25, 5, 0, 2, 25, 12, 88, 4, 5, 3, 5, 3, 5, 3, 2]; |
| 6699 |
var code = 0; |
| 6700 |
var str = []; |
| 6701 |
for (var i = 0; i < wordChars.length; i += 2) { |
| 6702 |
str.push(code += wordChars[i]); |
| 6703 |
if (wordChars[i + 1]) |
| 6704 |
str.push(45, code += wordChars[i + 1]); |
| 6705 |
} |
| 6706 |
exports.wordChars = String.fromCharCode.apply(null, str); |
| 6707 |
|
| 6708 |
}); |
| 6709 |
|
| 6710 |
ace.define("ace/mode/text",["require","exports","module","ace/config","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour/cstyle","ace/unicode","ace/lib/lang","ace/token_iterator","ace/range"], function(require, exports, module){"use strict"; |
| 6711 |
var config = require("../config"); |
| 6712 |
var Tokenizer = require("../tokenizer").Tokenizer; |
| 6713 |
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
| 6714 |
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; |
| 6715 |
var unicode = require("../unicode"); |
| 6716 |
var lang = require("../lib/lang"); |
| 6717 |
var TokenIterator = require("../token_iterator").TokenIterator; |
| 6718 |
var Range = require("../range").Range; |
| 6719 |
var Mode; |
| 6720 |
Mode = function () { |
| 6721 |
this.HighlightRules = TextHighlightRules; |
| 6722 |
}; |
| 6723 |
(function () { |
| 6724 |
this.$defaultBehaviour = new CstyleBehaviour(); |
| 6725 |
this.tokenRe = new RegExp("^[" + unicode.wordChars + "\\$_]+", "g"); |
| 6726 |
this.nonTokenRe = new RegExp("^(?:[^" + unicode.wordChars + "\\$_]|\\s])+", "g"); |
| 6727 |
this.getTokenizer = function () { |
| 6728 |
if (!this.$tokenizer) { |
| 6729 |
this.$highlightRules = this.$highlightRules || new this.HighlightRules(this.$highlightRuleConfig); |
| 6730 |
this.$tokenizer = new Tokenizer(this.$highlightRules.getRules()); |
| 6731 |
} |
| 6732 |
return this.$tokenizer; |
| 6733 |
}; |
| 6734 |
this.lineCommentStart = ""; |
| 6735 |
this.blockComment = ""; |
| 6736 |
this.toggleCommentLines = function (state, session, startRow, endRow) { |
| 6737 |
var doc = session.doc; |
| 6738 |
var ignoreBlankLines = true; |
| 6739 |
var shouldRemove = true; |
| 6740 |
var minIndent = Infinity; |
| 6741 |
var tabSize = session.getTabSize(); |
| 6742 |
var insertAtTabStop = false; |
| 6743 |
if (!this.lineCommentStart) { |
| 6744 |
if (!this.blockComment) |
| 6745 |
return false; |
| 6746 |
var lineCommentStart = this.blockComment.start; |
| 6747 |
var lineCommentEnd = this.blockComment.end; |
| 6748 |
var regexpStart = new RegExp("^(\\s*)(?:" + lang.escapeRegExp(lineCommentStart) + ")"); |
| 6749 |
var regexpEnd = new RegExp("(?:" + lang.escapeRegExp(lineCommentEnd) + ")\\s*$"); |
| 6750 |
var comment = function (line, i) { |
| 6751 |
if (testRemove(line, i)) |
| 6752 |
return; |
| 6753 |
if (!ignoreBlankLines || /\S/.test(line)) { |
| 6754 |
doc.insertInLine({ row: i, column: line.length }, lineCommentEnd); |
| 6755 |
doc.insertInLine({ row: i, column: minIndent }, lineCommentStart); |
| 6756 |
} |
| 6757 |
}; |
| 6758 |
var uncomment = function (line, i) { |
| 6759 |
var m; |
| 6760 |
if (m = line.match(regexpEnd)) |
| 6761 |
doc.removeInLine(i, line.length - m[0].length, line.length); |
| 6762 |
if (m = line.match(regexpStart)) |
| 6763 |
doc.removeInLine(i, m[1].length, m[0].length); |
| 6764 |
}; |
| 6765 |
var testRemove = function (line, row) { |
| 6766 |
if (regexpStart.test(line)) |
| 6767 |
return true; |
| 6768 |
var tokens = session.getTokens(row); |
| 6769 |
for (var i = 0; i < tokens.length; i++) { |
| 6770 |
if (tokens[i].type === "comment") |
| 6771 |
return true; |
| 6772 |
} |
| 6773 |
}; |
| 6774 |
} |
| 6775 |
else { |
| 6776 |
if (Array.isArray(this.lineCommentStart)) { |
| 6777 |
var regexpStart = this.lineCommentStart.map(lang.escapeRegExp).join("|"); |
| 6778 |
var lineCommentStart = this.lineCommentStart[0]; |
| 6779 |
} |
| 6780 |
else { |
| 6781 |
var regexpStart = lang.escapeRegExp(this.lineCommentStart); |
| 6782 |
var lineCommentStart = this.lineCommentStart; |
| 6783 |
} |
| 6784 |
regexpStart = new RegExp("^(\\s*)(?:" + regexpStart + ") ?"); |
| 6785 |
insertAtTabStop = session.getUseSoftTabs(); |
| 6786 |
var uncomment = function (line, i) { |
| 6787 |
var m = line.match(regexpStart); |
| 6788 |
if (!m) |
| 6789 |
return; |
| 6790 |
var start = m[1].length, end = m[0].length; |
| 6791 |
if (!shouldInsertSpace(line, start, end) && m[0][end - 1] == " ") |
| 6792 |
end--; |
| 6793 |
doc.removeInLine(i, start, end); |
| 6794 |
}; |
| 6795 |
var commentWithSpace = lineCommentStart + " "; |
| 6796 |
var comment = function (line, i) { |
| 6797 |
if (!ignoreBlankLines || /\S/.test(line)) { |
| 6798 |
if (shouldInsertSpace(line, minIndent, minIndent)) |
| 6799 |
doc.insertInLine({ row: i, column: minIndent }, commentWithSpace); |
| 6800 |
else |
| 6801 |
doc.insertInLine({ row: i, column: minIndent }, lineCommentStart); |
| 6802 |
} |
| 6803 |
}; |
| 6804 |
var testRemove = function (line, i) { |
| 6805 |
return regexpStart.test(line); |
| 6806 |
}; |
| 6807 |
var shouldInsertSpace = function (line, before, after) { |
| 6808 |
var spaces = 0; |
| 6809 |
while (before-- && line.charAt(before) == " ") |
| 6810 |
spaces++; |
| 6811 |
if (spaces % tabSize != 0) |
| 6812 |
return false; |
| 6813 |
var spaces = 0; |
| 6814 |
while (line.charAt(after++) == " ") |
| 6815 |
spaces++; |
| 6816 |
if (tabSize > 2) |
| 6817 |
return spaces % tabSize != tabSize - 1; |
| 6818 |
else |
| 6819 |
return spaces % tabSize == 0; |
| 6820 |
}; |
| 6821 |
} |
| 6822 |
function iter(fun) { |
| 6823 |
for (var i = startRow; i <= endRow; i++) |
| 6824 |
fun(doc.getLine(i), i); |
| 6825 |
} |
| 6826 |
var minEmptyLength = Infinity; |
| 6827 |
iter(function (line, i) { |
| 6828 |
var indent = line.search(/\S/); |
| 6829 |
if (indent !== -1) { |
| 6830 |
if (indent < minIndent) |
| 6831 |
minIndent = indent; |
| 6832 |
if (shouldRemove && !testRemove(line, i)) |
| 6833 |
shouldRemove = false; |
| 6834 |
} |
| 6835 |
else if (minEmptyLength > line.length) { |
| 6836 |
minEmptyLength = line.length; |
| 6837 |
} |
| 6838 |
}); |
| 6839 |
if (minIndent == Infinity) { |
| 6840 |
minIndent = minEmptyLength; |
| 6841 |
ignoreBlankLines = false; |
| 6842 |
shouldRemove = false; |
| 6843 |
} |
| 6844 |
if (insertAtTabStop && minIndent % tabSize != 0) |
| 6845 |
minIndent = Math.floor(minIndent / tabSize) * tabSize; |
| 6846 |
iter(shouldRemove ? uncomment : comment); |
| 6847 |
}; |
| 6848 |
this.toggleBlockComment = function (state, session, range, cursor) { |
| 6849 |
var comment = this.blockComment; |
| 6850 |
if (!comment) |
| 6851 |
return; |
| 6852 |
if (!comment.start && comment[0]) |
| 6853 |
comment = comment[0]; |
| 6854 |
var iterator = new TokenIterator(session, cursor.row, cursor.column); |
| 6855 |
var token = iterator.getCurrentToken(); |
| 6856 |
var sel = session.selection; |
| 6857 |
var initialRange = session.selection.toOrientedRange(); |
| 6858 |
var startRow, colDiff; |
| 6859 |
if (token && /comment/.test(token.type)) { |
| 6860 |
var startRange, endRange; |
| 6861 |
while (token && /comment/.test(token.type)) { |
| 6862 |
var i = token.value.indexOf(comment.start); |
| 6863 |
if (i != -1) { |
| 6864 |
var row = iterator.getCurrentTokenRow(); |
| 6865 |
var column = iterator.getCurrentTokenColumn() + i; |
| 6866 |
startRange = new Range(row, column, row, column + comment.start.length); |
| 6867 |
break; |
| 6868 |
} |
| 6869 |
token = iterator.stepBackward(); |
| 6870 |
} |
| 6871 |
var iterator = new TokenIterator(session, cursor.row, cursor.column); |
| 6872 |
var token = iterator.getCurrentToken(); |
| 6873 |
while (token && /comment/.test(token.type)) { |
| 6874 |
var i = token.value.indexOf(comment.end); |
| 6875 |
if (i != -1) { |
| 6876 |
var row = iterator.getCurrentTokenRow(); |
| 6877 |
var column = iterator.getCurrentTokenColumn() + i; |
| 6878 |
endRange = new Range(row, column, row, column + comment.end.length); |
| 6879 |
break; |
| 6880 |
} |
| 6881 |
token = iterator.stepForward(); |
| 6882 |
} |
| 6883 |
if (endRange) |
| 6884 |
session.remove(endRange); |
| 6885 |
if (startRange) { |
| 6886 |
session.remove(startRange); |
| 6887 |
startRow = startRange.start.row; |
| 6888 |
colDiff = -comment.start.length; |
| 6889 |
} |
| 6890 |
} |
| 6891 |
else { |
| 6892 |
colDiff = comment.start.length; |
| 6893 |
startRow = range.start.row; |
| 6894 |
session.insert(range.end, comment.end); |
| 6895 |
session.insert(range.start, comment.start); |
| 6896 |
} |
| 6897 |
if (initialRange.start.row == startRow) |
| 6898 |
initialRange.start.column += colDiff; |
| 6899 |
if (initialRange.end.row == startRow) |
| 6900 |
initialRange.end.column += colDiff; |
| 6901 |
session.selection.fromOrientedRange(initialRange); |
| 6902 |
}; |
| 6903 |
this.getNextLineIndent = function (state, line, tab) { |
| 6904 |
return this.$getIndent(line); |
| 6905 |
}; |
| 6906 |
this.checkOutdent = function (state, line, input) { |
| 6907 |
return false; |
| 6908 |
}; |
| 6909 |
this.autoOutdent = function (state, doc, row) { |
| 6910 |
}; |
| 6911 |
this.$getIndent = function (line) { |
| 6912 |
return line.match(/^\s*/)[0]; |
| 6913 |
}; |
| 6914 |
this.createWorker = function (session) { |
| 6915 |
return null; |
| 6916 |
}; |
| 6917 |
this.createModeDelegates = function (mapping) { |
| 6918 |
this.$embeds = []; |
| 6919 |
this.$modes = {}; |
| 6920 |
for (var i in mapping) { |
| 6921 |
if (mapping[i]) { |
| 6922 |
var Mode = mapping[i]; |
| 6923 |
var id = Mode.prototype.$id; |
| 6924 |
var mode = config.$modes[id]; |
| 6925 |
if (!mode) |
| 6926 |
config.$modes[id] = mode = new Mode(); |
| 6927 |
if (!config.$modes[i]) |
| 6928 |
config.$modes[i] = mode; |
| 6929 |
this.$embeds.push(i); |
| 6930 |
this.$modes[i] = mode; |
| 6931 |
} |
| 6932 |
} |
| 6933 |
var delegations = ["toggleBlockComment", "toggleCommentLines", "getNextLineIndent", |
| 6934 |
"checkOutdent", "autoOutdent", "transformAction", "getCompletions"]; |
| 6935 |
var _loop_1 = function (i) { |
| 6936 |
(function (scope) { |
| 6937 |
var functionName = delegations[i]; |
| 6938 |
var defaultHandler = scope[functionName]; |
| 6939 |
scope[delegations[i]] = |
| 6940 |
function () { |
| 6941 |
return this.$delegator(functionName, arguments, defaultHandler); |
| 6942 |
}; |
| 6943 |
}(this_1)); |
| 6944 |
}; |
| 6945 |
var this_1 = this; |
| 6946 |
for (var i = 0; i < delegations.length; i++) { |
| 6947 |
_loop_1(i); |
| 6948 |
} |
| 6949 |
}; |
| 6950 |
this.$delegator = function (method, args, defaultHandler) { |
| 6951 |
var state = args[0] || "start"; |
| 6952 |
if (typeof state != "string") { |
| 6953 |
if (Array.isArray(state[2])) { |
| 6954 |
var language = state[2][state[2].length - 1]; |
| 6955 |
var mode = this.$modes[language]; |
| 6956 |
if (mode) |
| 6957 |
return mode[method].apply(mode, [state[1]].concat([].slice.call(args, 1))); |
| 6958 |
} |
| 6959 |
state = state[0] || "start"; |
| 6960 |
} |
| 6961 |
for (var i = 0; i < this.$embeds.length; i++) { |
| 6962 |
if (!this.$modes[this.$embeds[i]]) |
| 6963 |
continue; |
| 6964 |
var split = state.split(this.$embeds[i]); |
| 6965 |
if (!split[0] && split[1]) { |
| 6966 |
args[0] = split[1]; |
| 6967 |
var mode = this.$modes[this.$embeds[i]]; |
| 6968 |
return mode[method].apply(mode, args); |
| 6969 |
} |
| 6970 |
} |
| 6971 |
var ret = defaultHandler.apply(this, args); |
| 6972 |
return defaultHandler ? ret : undefined; |
| 6973 |
}; |
| 6974 |
this.transformAction = function (state, action, editor, session, param) { |
| 6975 |
if (this.$behaviour) { |
| 6976 |
var behaviours = this.$behaviour.getBehaviours(); |
| 6977 |
for (var key in behaviours) { |
| 6978 |
if (behaviours[key][action]) { |
| 6979 |
var ret = behaviours[key][action].apply(this, arguments); |
| 6980 |
if (ret) { |
| 6981 |
return ret; |
| 6982 |
} |
| 6983 |
} |
| 6984 |
} |
| 6985 |
} |
| 6986 |
}; |
| 6987 |
this.getKeywords = function (append) { |
| 6988 |
if (!this.completionKeywords) { |
| 6989 |
var rules = this.$tokenizer["rules"]; |
| 6990 |
var completionKeywords = []; |
| 6991 |
for (var rule in rules) { |
| 6992 |
var ruleItr = rules[rule]; |
| 6993 |
for (var r = 0, l = ruleItr.length; r < l; r++) { |
| 6994 |
if (typeof ruleItr[r].token === "string") { |
| 6995 |
if (/keyword|support|storage/.test(ruleItr[r].token)) |
| 6996 |
completionKeywords.push(ruleItr[r].regex); |
| 6997 |
} |
| 6998 |
else if (typeof ruleItr[r].token === "object") { |
| 6999 |
for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) { |
| 7000 |
if (/keyword|support|storage/.test(ruleItr[r].token[a])) { |
| 7001 |
var rule = ruleItr[r].regex.match(/\(.+?\)/g)[a]; |
| 7002 |
completionKeywords.push(rule.substr(1, rule.length - 2)); |
| 7003 |
} |
| 7004 |
} |
| 7005 |
} |
| 7006 |
} |
| 7007 |
} |
| 7008 |
this.completionKeywords = completionKeywords; |
| 7009 |
} |
| 7010 |
if (!append) |
| 7011 |
return this.$keywordList; |
| 7012 |
return completionKeywords.concat(this.$keywordList || []); |
| 7013 |
}; |
| 7014 |
this.$createKeywordList = function () { |
| 7015 |
if (!this.$highlightRules) |
| 7016 |
this.getTokenizer(); |
| 7017 |
return this.$keywordList = this.$highlightRules.$keywordList || []; |
| 7018 |
}; |
| 7019 |
this.getCompletions = function (state, session, pos, prefix) { |
| 7020 |
var keywords = this.$keywordList || this.$createKeywordList(); |
| 7021 |
return keywords.map(function (word) { |
| 7022 |
return { |
| 7023 |
name: word, |
| 7024 |
value: word, |
| 7025 |
score: 0, |
| 7026 |
meta: "keyword" |
| 7027 |
}; |
| 7028 |
}); |
| 7029 |
}; |
| 7030 |
this.$id = "ace/mode/text"; |
| 7031 |
}).call(Mode.prototype); |
| 7032 |
exports.Mode = Mode; |
| 7033 |
|
| 7034 |
}); |
| 7035 |
|
| 7036 |
ace.define("ace/apply_delta",["require","exports","module"], function(require, exports, module){"use strict"; |
| 7037 |
function throwDeltaError(delta, errorText) { |
| 7038 |
console.log("Invalid Delta:", delta); |
| 7039 |
throw "Invalid Delta: " + errorText; |
| 7040 |
} |
| 7041 |
function positionInDocument(docLines, position) { |
| 7042 |
return position.row >= 0 && position.row < docLines.length && |
| 7043 |
position.column >= 0 && position.column <= docLines[position.row].length; |
| 7044 |
} |
| 7045 |
function validateDelta(docLines, delta) { |
| 7046 |
if (delta.action != "insert" && delta.action != "remove") |
| 7047 |
throwDeltaError(delta, "delta.action must be 'insert' or 'remove'"); |
| 7048 |
if (!(delta.lines instanceof Array)) |
| 7049 |
throwDeltaError(delta, "delta.lines must be an Array"); |
| 7050 |
if (!delta.start || !delta.end) |
| 7051 |
throwDeltaError(delta, "delta.start/end must be an present"); |
| 7052 |
var start = delta.start; |
| 7053 |
if (!positionInDocument(docLines, delta.start)) |
| 7054 |
throwDeltaError(delta, "delta.start must be contained in document"); |
| 7055 |
var end = delta.end; |
| 7056 |
if (delta.action == "remove" && !positionInDocument(docLines, end)) |
| 7057 |
throwDeltaError(delta, "delta.end must contained in document for 'remove' actions"); |
| 7058 |
var numRangeRows = end.row - start.row; |
| 7059 |
var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0)); |
| 7060 |
if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars) |
| 7061 |
throwDeltaError(delta, "delta.range must match delta lines"); |
| 7062 |
} |
| 7063 |
exports.applyDelta = function (docLines, delta, doNotValidate) { |
| 7064 |
var row = delta.start.row; |
| 7065 |
var startColumn = delta.start.column; |
| 7066 |
var line = docLines[row] || ""; |
| 7067 |
switch (delta.action) { |
| 7068 |
case "insert": |
| 7069 |
var lines = delta.lines; |
| 7070 |
if (lines.length === 1) { |
| 7071 |
docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn); |
| 7072 |
} |
| 7073 |
else { |
| 7074 |
var args = [row, 1].concat(delta.lines); |
| 7075 |
docLines.splice.apply(docLines, args); |
| 7076 |
docLines[row] = line.substring(0, startColumn) + docLines[row]; |
| 7077 |
docLines[row + delta.lines.length - 1] += line.substring(startColumn); |
| 7078 |
} |
| 7079 |
break; |
| 7080 |
case "remove": |
| 7081 |
var endColumn = delta.end.column; |
| 7082 |
var endRow = delta.end.row; |
| 7083 |
if (row === endRow) { |
| 7084 |
docLines[row] = line.substring(0, startColumn) + line.substring(endColumn); |
| 7085 |
} |
| 7086 |
else { |
| 7087 |
docLines.splice(row, endRow - row + 1, line.substring(0, startColumn) + docLines[endRow].substring(endColumn)); |
| 7088 |
} |
| 7089 |
break; |
| 7090 |
} |
| 7091 |
}; |
| 7092 |
|
| 7093 |
}); |
| 7094 |
|
| 7095 |
ace.define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module){"use strict"; |
| 7096 |
var oop = require("./lib/oop"); |
| 7097 |
var EventEmitter = require("./lib/event_emitter").EventEmitter; |
| 7098 |
var Anchor = (function () { |
| 7099 |
function Anchor(doc, row, column) { |
| 7100 |
this.$onChange = this.onChange.bind(this); |
| 7101 |
this.attach(doc); |
| 7102 |
if (typeof row != "number") |
| 7103 |
this.setPosition(row.row, row.column); |
| 7104 |
else |
| 7105 |
this.setPosition(row, column); |
| 7106 |
} |
| 7107 |
Anchor.prototype.getPosition = function () { |
| 7108 |
return this.$clipPositionToDocument(this.row, this.column); |
| 7109 |
}; |
| 7110 |
Anchor.prototype.getDocument = function () { |
| 7111 |
return this.document; |
| 7112 |
}; |
| 7113 |
Anchor.prototype.onChange = function (delta) { |
| 7114 |
if (delta.start.row == delta.end.row && delta.start.row != this.row) |
| 7115 |
return; |
| 7116 |
if (delta.start.row > this.row) |
| 7117 |
return; |
| 7118 |
var point = $getTransformedPoint(delta, { row: this.row, column: this.column }, this.$insertRight); |
| 7119 |
this.setPosition(point.row, point.column, true); |
| 7120 |
}; |
| 7121 |
Anchor.prototype.setPosition = function (row, column, noClip) { |
| 7122 |
var pos; |
| 7123 |
if (noClip) { |
| 7124 |
pos = { |
| 7125 |
row: row, |
| 7126 |
column: column |
| 7127 |
}; |
| 7128 |
} |
| 7129 |
else { |
| 7130 |
pos = this.$clipPositionToDocument(row, column); |
| 7131 |
} |
| 7132 |
if (this.row == pos.row && this.column == pos.column) |
| 7133 |
return; |
| 7134 |
var old = { |
| 7135 |
row: this.row, |
| 7136 |
column: this.column |
| 7137 |
}; |
| 7138 |
this.row = pos.row; |
| 7139 |
this.column = pos.column; |
| 7140 |
this._signal("change", { |
| 7141 |
old: old, |
| 7142 |
value: pos |
| 7143 |
}); |
| 7144 |
}; |
| 7145 |
Anchor.prototype.detach = function () { |
| 7146 |
this.document.off("change", this.$onChange); |
| 7147 |
}; |
| 7148 |
Anchor.prototype.attach = function (doc) { |
| 7149 |
this.document = doc || this.document; |
| 7150 |
this.document.on("change", this.$onChange); |
| 7151 |
}; |
| 7152 |
Anchor.prototype.$clipPositionToDocument = function (row, column) { |
| 7153 |
var pos = {}; |
| 7154 |
if (row >= this.document.getLength()) { |
| 7155 |
pos.row = Math.max(0, this.document.getLength() - 1); |
| 7156 |
pos.column = this.document.getLine(pos.row).length; |
| 7157 |
} |
| 7158 |
else if (row < 0) { |
| 7159 |
pos.row = 0; |
| 7160 |
pos.column = 0; |
| 7161 |
} |
| 7162 |
else { |
| 7163 |
pos.row = row; |
| 7164 |
pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column)); |
| 7165 |
} |
| 7166 |
if (column < 0) |
| 7167 |
pos.column = 0; |
| 7168 |
return pos; |
| 7169 |
}; |
| 7170 |
return Anchor; |
| 7171 |
}()); |
| 7172 |
Anchor.prototype.$insertRight = false; |
| 7173 |
oop.implement(Anchor.prototype, EventEmitter); |
| 7174 |
function $pointsInOrder(point1, point2, equalPointsInOrder) { |
| 7175 |
var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column; |
| 7176 |
return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter); |
| 7177 |
} |
| 7178 |
function $getTransformedPoint(delta, point, moveIfEqual) { |
| 7179 |
var deltaIsInsert = delta.action == "insert"; |
| 7180 |
var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row); |
| 7181 |
var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column); |
| 7182 |
var deltaStart = delta.start; |
| 7183 |
var deltaEnd = deltaIsInsert ? deltaStart : delta.end; |
| 7184 |
if ($pointsInOrder(point, deltaStart, moveIfEqual)) { |
| 7185 |
return { |
| 7186 |
row: point.row, |
| 7187 |
column: point.column |
| 7188 |
}; |
| 7189 |
} |
| 7190 |
if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) { |
| 7191 |
return { |
| 7192 |
row: point.row + deltaRowShift, |
| 7193 |
column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0) |
| 7194 |
}; |
| 7195 |
} |
| 7196 |
return { |
| 7197 |
row: deltaStart.row, |
| 7198 |
column: deltaStart.column |
| 7199 |
}; |
| 7200 |
} |
| 7201 |
exports.Anchor = Anchor; |
| 7202 |
|
| 7203 |
}); |
| 7204 |
|
| 7205 |
ace.define("ace/document",["require","exports","module","ace/lib/oop","ace/apply_delta","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module){"use strict"; |
| 7206 |
var oop = require("./lib/oop"); |
| 7207 |
var applyDelta = require("./apply_delta").applyDelta; |
| 7208 |
var EventEmitter = require("./lib/event_emitter").EventEmitter; |
| 7209 |
var Range = require("./range").Range; |
| 7210 |
var Anchor = require("./anchor").Anchor; |
| 7211 |
var Document = (function () { |
| 7212 |
function Document(textOrLines) { |
| 7213 |
this.$lines = [""]; |
| 7214 |
if (textOrLines.length === 0) { |
| 7215 |
this.$lines = [""]; |
| 7216 |
} |
| 7217 |
else if (Array.isArray(textOrLines)) { |
| 7218 |
this.insertMergedLines({ row: 0, column: 0 }, textOrLines); |
| 7219 |
} |
| 7220 |
else { |
| 7221 |
this.insert({ row: 0, column: 0 }, textOrLines); |
| 7222 |
} |
| 7223 |
} |
| 7224 |
Document.prototype.setValue = function (text) { |
| 7225 |
var len = this.getLength() - 1; |
| 7226 |
this.remove(new Range(0, 0, len, this.getLine(len).length)); |
| 7227 |
this.insert({ row: 0, column: 0 }, text || ""); |
| 7228 |
}; |
| 7229 |
Document.prototype.getValue = function () { |
| 7230 |
return this.getAllLines().join(this.getNewLineCharacter()); |
| 7231 |
}; |
| 7232 |
Document.prototype.createAnchor = function (row, column) { |
| 7233 |
return new Anchor(this, row, column); |
| 7234 |
}; |
| 7235 |
Document.prototype.$detectNewLine = function (text) { |
| 7236 |
var match = text.match(/^.*?(\r\n|\r|\n)/m); |
| 7237 |
this.$autoNewLine = match ? match[1] : "\n"; |
| 7238 |
this._signal("changeNewLineMode"); |
| 7239 |
}; |
| 7240 |
Document.prototype.getNewLineCharacter = function () { |
| 7241 |
switch (this.$newLineMode) { |
| 7242 |
case "windows": |
| 7243 |
return "\r\n"; |
| 7244 |
case "unix": |
| 7245 |
return "\n"; |
| 7246 |
default: |
| 7247 |
return this.$autoNewLine || "\n"; |
| 7248 |
} |
| 7249 |
}; |
| 7250 |
Document.prototype.setNewLineMode = function (newLineMode) { |
| 7251 |
if (this.$newLineMode === newLineMode) |
| 7252 |
return; |
| 7253 |
this.$newLineMode = newLineMode; |
| 7254 |
this._signal("changeNewLineMode"); |
| 7255 |
}; |
| 7256 |
Document.prototype.getNewLineMode = function () { |
| 7257 |
return this.$newLineMode; |
| 7258 |
}; |
| 7259 |
Document.prototype.isNewLine = function (text) { |
| 7260 |
return (text == "\r\n" || text == "\r" || text == "\n"); |
| 7261 |
}; |
| 7262 |
Document.prototype.getLine = function (row) { |
| 7263 |
return this.$lines[row] || ""; |
| 7264 |
}; |
| 7265 |
Document.prototype.getLines = function (firstRow, lastRow) { |
| 7266 |
return this.$lines.slice(firstRow, lastRow + 1); |
| 7267 |
}; |
| 7268 |
Document.prototype.getAllLines = function () { |
| 7269 |
return this.getLines(0, this.getLength()); |
| 7270 |
}; |
| 7271 |
Document.prototype.getLength = function () { |
| 7272 |
return this.$lines.length; |
| 7273 |
}; |
| 7274 |
Document.prototype.getTextRange = function (range) { |
| 7275 |
return this.getLinesForRange(range).join(this.getNewLineCharacter()); |
| 7276 |
}; |
| 7277 |
Document.prototype.getLinesForRange = function (range) { |
| 7278 |
var lines; |
| 7279 |
if (range.start.row === range.end.row) { |
| 7280 |
lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)]; |
| 7281 |
} |
| 7282 |
else { |
| 7283 |
lines = this.getLines(range.start.row, range.end.row); |
| 7284 |
lines[0] = (lines[0] || "").substring(range.start.column); |
| 7285 |
var l = lines.length - 1; |
| 7286 |
if (range.end.row - range.start.row == l) |
| 7287 |
lines[l] = lines[l].substring(0, range.end.column); |
| 7288 |
} |
| 7289 |
return lines; |
| 7290 |
}; |
| 7291 |
Document.prototype.insertLines = function (row, lines) { |
| 7292 |
console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead."); |
| 7293 |
return this.insertFullLines(row, lines); |
| 7294 |
}; |
| 7295 |
Document.prototype.removeLines = function (firstRow, lastRow) { |
| 7296 |
console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead."); |
| 7297 |
return this.removeFullLines(firstRow, lastRow); |
| 7298 |
}; |
| 7299 |
Document.prototype.insertNewLine = function (position) { |
| 7300 |
console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead."); |
| 7301 |
return this.insertMergedLines(position, ["", ""]); |
| 7302 |
}; |
| 7303 |
Document.prototype.insert = function (position, text) { |
| 7304 |
if (this.getLength() <= 1) |
| 7305 |
this.$detectNewLine(text); |
| 7306 |
return this.insertMergedLines(position, this.$split(text)); |
| 7307 |
}; |
| 7308 |
Document.prototype.insertInLine = function (position, text) { |
| 7309 |
var start = this.clippedPos(position.row, position.column); |
| 7310 |
var end = this.pos(position.row, position.column + text.length); |
| 7311 |
this.applyDelta({ |
| 7312 |
start: start, |
| 7313 |
end: end, |
| 7314 |
action: "insert", |
| 7315 |
lines: [text] |
| 7316 |
}, true); |
| 7317 |
return this.clonePos(end); |
| 7318 |
}; |
| 7319 |
Document.prototype.clippedPos = function (row, column) { |
| 7320 |
var length = this.getLength(); |
| 7321 |
if (row === undefined) { |
| 7322 |
row = length; |
| 7323 |
} |
| 7324 |
else if (row < 0) { |
| 7325 |
row = 0; |
| 7326 |
} |
| 7327 |
else if (row >= length) { |
| 7328 |
row = length - 1; |
| 7329 |
column = undefined; |
| 7330 |
} |
| 7331 |
var line = this.getLine(row); |
| 7332 |
if (column == undefined) |
| 7333 |
column = line.length; |
| 7334 |
column = Math.min(Math.max(column, 0), line.length); |
| 7335 |
return { row: row, column: column }; |
| 7336 |
}; |
| 7337 |
Document.prototype.clonePos = function (pos) { |
| 7338 |
return { row: pos.row, column: pos.column }; |
| 7339 |
}; |
| 7340 |
Document.prototype.pos = function (row, column) { |
| 7341 |
return { row: row, column: column }; |
| 7342 |
}; |
| 7343 |
Document.prototype.$clipPosition = function (position) { |
| 7344 |
var length = this.getLength(); |
| 7345 |
if (position.row >= length) { |
| 7346 |
position.row = Math.max(0, length - 1); |
| 7347 |
position.column = this.getLine(length - 1).length; |
| 7348 |
} |
| 7349 |
else { |
| 7350 |
position.row = Math.max(0, position.row); |
| 7351 |
position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length); |
| 7352 |
} |
| 7353 |
return position; |
| 7354 |
}; |
| 7355 |
Document.prototype.insertFullLines = function (row, lines) { |
| 7356 |
row = Math.min(Math.max(row, 0), this.getLength()); |
| 7357 |
var column = 0; |
| 7358 |
if (row < this.getLength()) { |
| 7359 |
lines = lines.concat([""]); |
| 7360 |
column = 0; |
| 7361 |
} |
| 7362 |
else { |
| 7363 |
lines = [""].concat(lines); |
| 7364 |
row--; |
| 7365 |
column = this.$lines[row].length; |
| 7366 |
} |
| 7367 |
this.insertMergedLines({ row: row, column: column }, lines); |
| 7368 |
}; |
| 7369 |
Document.prototype.insertMergedLines = function (position, lines) { |
| 7370 |
var start = this.clippedPos(position.row, position.column); |
| 7371 |
var end = { |
| 7372 |
row: start.row + lines.length - 1, |
| 7373 |
column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length |
| 7374 |
}; |
| 7375 |
this.applyDelta({ |
| 7376 |
start: start, |
| 7377 |
end: end, |
| 7378 |
action: "insert", |
| 7379 |
lines: lines |
| 7380 |
}); |
| 7381 |
return this.clonePos(end); |
| 7382 |
}; |
| 7383 |
Document.prototype.remove = function (range) { |
| 7384 |
var start = this.clippedPos(range.start.row, range.start.column); |
| 7385 |
var end = this.clippedPos(range.end.row, range.end.column); |
| 7386 |
this.applyDelta({ |
| 7387 |
start: start, |
| 7388 |
end: end, |
| 7389 |
action: "remove", |
| 7390 |
lines: this.getLinesForRange({ start: start, end: end }) |
| 7391 |
}); |
| 7392 |
return this.clonePos(start); |
| 7393 |
}; |
| 7394 |
Document.prototype.removeInLine = function (row, startColumn, endColumn) { |
| 7395 |
var start = this.clippedPos(row, startColumn); |
| 7396 |
var end = this.clippedPos(row, endColumn); |
| 7397 |
this.applyDelta({ |
| 7398 |
start: start, |
| 7399 |
end: end, |
| 7400 |
action: "remove", |
| 7401 |
lines: this.getLinesForRange({ start: start, end: end }) |
| 7402 |
}, true); |
| 7403 |
return this.clonePos(start); |
| 7404 |
}; |
| 7405 |
Document.prototype.removeFullLines = function (firstRow, lastRow) { |
| 7406 |
firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1); |
| 7407 |
lastRow = Math.min(Math.max(0, lastRow), this.getLength() - 1); |
| 7408 |
var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0; |
| 7409 |
var deleteLastNewLine = lastRow < this.getLength() - 1; |
| 7410 |
var startRow = (deleteFirstNewLine ? firstRow - 1 : firstRow); |
| 7411 |
var startCol = (deleteFirstNewLine ? this.getLine(startRow).length : 0); |
| 7412 |
var endRow = (deleteLastNewLine ? lastRow + 1 : lastRow); |
| 7413 |
var endCol = (deleteLastNewLine ? 0 : this.getLine(endRow).length); |
| 7414 |
var range = new Range(startRow, startCol, endRow, endCol); |
| 7415 |
var deletedLines = this.$lines.slice(firstRow, lastRow + 1); |
| 7416 |
this.applyDelta({ |
| 7417 |
start: range.start, |
| 7418 |
end: range.end, |
| 7419 |
action: "remove", |
| 7420 |
lines: this.getLinesForRange(range) |
| 7421 |
}); |
| 7422 |
return deletedLines; |
| 7423 |
}; |
| 7424 |
Document.prototype.removeNewLine = function (row) { |
| 7425 |
if (row < this.getLength() - 1 && row >= 0) { |
| 7426 |
this.applyDelta({ |
| 7427 |
start: this.pos(row, this.getLine(row).length), |
| 7428 |
end: this.pos(row + 1, 0), |
| 7429 |
action: "remove", |
| 7430 |
lines: ["", ""] |
| 7431 |
}); |
| 7432 |
} |
| 7433 |
}; |
| 7434 |
Document.prototype.replace = function (range, text) { |
| 7435 |
if (!(range instanceof Range)) |
| 7436 |
range = Range.fromPoints(range.start, range.end); |
| 7437 |
if (text.length === 0 && range.isEmpty()) |
| 7438 |
return range.start; |
| 7439 |
if (text == this.getTextRange(range)) |
| 7440 |
return range.end; |
| 7441 |
this.remove(range); |
| 7442 |
var end; |
| 7443 |
if (text) { |
| 7444 |
end = this.insert(range.start, text); |
| 7445 |
} |
| 7446 |
else { |
| 7447 |
end = range.start; |
| 7448 |
} |
| 7449 |
return end; |
| 7450 |
}; |
| 7451 |
Document.prototype.applyDeltas = function (deltas) { |
| 7452 |
for (var i = 0; i < deltas.length; i++) { |
| 7453 |
this.applyDelta(deltas[i]); |
| 7454 |
} |
| 7455 |
}; |
| 7456 |
Document.prototype.revertDeltas = function (deltas) { |
| 7457 |
for (var i = deltas.length - 1; i >= 0; i--) { |
| 7458 |
this.revertDelta(deltas[i]); |
| 7459 |
} |
| 7460 |
}; |
| 7461 |
Document.prototype.applyDelta = function (delta, doNotValidate) { |
| 7462 |
var isInsert = delta.action == "insert"; |
| 7463 |
if (isInsert ? delta.lines.length <= 1 && !delta.lines[0] |
| 7464 |
: !Range.comparePoints(delta.start, delta.end)) { |
| 7465 |
return; |
| 7466 |
} |
| 7467 |
if (isInsert && delta.lines.length > 20000) { |
| 7468 |
this.$splitAndapplyLargeDelta(delta, 20000); |
| 7469 |
} |
| 7470 |
else { |
| 7471 |
applyDelta(this.$lines, delta, doNotValidate); |
| 7472 |
this._signal("change", delta); |
| 7473 |
} |
| 7474 |
}; |
| 7475 |
Document.prototype.$safeApplyDelta = function (delta) { |
| 7476 |
var docLength = this.$lines.length; |
| 7477 |
if (delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength |
| 7478 |
|| delta.action == "insert" && delta.start.row <= docLength) { |
| 7479 |
this.applyDelta(delta); |
| 7480 |
} |
| 7481 |
}; |
| 7482 |
Document.prototype.$splitAndapplyLargeDelta = function (delta, MAX) { |
| 7483 |
var lines = delta.lines; |
| 7484 |
var l = lines.length - MAX + 1; |
| 7485 |
var row = delta.start.row; |
| 7486 |
var column = delta.start.column; |
| 7487 |
for (var from = 0, to = 0; from < l; from = to) { |
| 7488 |
to += MAX - 1; |
| 7489 |
var chunk = lines.slice(from, to); |
| 7490 |
chunk.push(""); |
| 7491 |
this.applyDelta({ |
| 7492 |
start: this.pos(row + from, column), |
| 7493 |
end: this.pos(row + to, column = 0), |
| 7494 |
action: delta.action, |
| 7495 |
lines: chunk |
| 7496 |
}, true); |
| 7497 |
} |
| 7498 |
delta.lines = lines.slice(from); |
| 7499 |
delta.start.row = row + from; |
| 7500 |
delta.start.column = column; |
| 7501 |
this.applyDelta(delta, true); |
| 7502 |
}; |
| 7503 |
Document.prototype.revertDelta = function (delta) { |
| 7504 |
this.$safeApplyDelta({ |
| 7505 |
start: this.clonePos(delta.start), |
| 7506 |
end: this.clonePos(delta.end), |
| 7507 |
action: (delta.action == "insert" ? "remove" : "insert"), |
| 7508 |
lines: delta.lines.slice() |
| 7509 |
}); |
| 7510 |
}; |
| 7511 |
Document.prototype.indexToPosition = function (index, startRow) { |
| 7512 |
var lines = this.$lines || this.getAllLines(); |
| 7513 |
var newlineLength = this.getNewLineCharacter().length; |
| 7514 |
for (var i = startRow || 0, l = lines.length; i < l; i++) { |
| 7515 |
index -= lines[i].length + newlineLength; |
| 7516 |
if (index < 0) |
| 7517 |
return { row: i, column: index + lines[i].length + newlineLength }; |
| 7518 |
} |
| 7519 |
return { row: l - 1, column: index + lines[l - 1].length + newlineLength }; |
| 7520 |
}; |
| 7521 |
Document.prototype.positionToIndex = function (pos, startRow) { |
| 7522 |
var lines = this.$lines || this.getAllLines(); |
| 7523 |
var newlineLength = this.getNewLineCharacter().length; |
| 7524 |
var index = 0; |
| 7525 |
var row = Math.min(pos.row, lines.length); |
| 7526 |
for (var i = startRow || 0; i < row; ++i) |
| 7527 |
index += lines[i].length + newlineLength; |
| 7528 |
return index + pos.column; |
| 7529 |
}; |
| 7530 |
Document.prototype.$split = function (text) { |
| 7531 |
return text.split(/\r\n|\r|\n/); |
| 7532 |
}; |
| 7533 |
return Document; |
| 7534 |
}()); |
| 7535 |
Document.prototype.$autoNewLine = ""; |
| 7536 |
Document.prototype.$newLineMode = "auto"; |
| 7537 |
oop.implement(Document.prototype, EventEmitter); |
| 7538 |
exports.Document = Document; |
| 7539 |
|
| 7540 |
}); |
| 7541 |
|
| 7542 |
ace.define("ace/background_tokenizer",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module){"use strict"; |
| 7543 |
var oop = require("./lib/oop"); |
| 7544 |
var EventEmitter = require("./lib/event_emitter").EventEmitter; |
| 7545 |
var BackgroundTokenizer = (function () { |
| 7546 |
function BackgroundTokenizer(tokenizer, session) { |
| 7547 |
this.running = false; |
| 7548 |
this.lines = []; |
| 7549 |
this.states = []; |
| 7550 |
this.currentLine = 0; |
| 7551 |
this.tokenizer = tokenizer; |
| 7552 |
var self = this; |
| 7553 |
this.$worker = function () { |
| 7554 |
if (!self.running) { |
| 7555 |
return; |
| 7556 |
} |
| 7557 |
var workerStart = new Date(); |
| 7558 |
var currentLine = self.currentLine; |
| 7559 |
var endLine = -1; |
| 7560 |
var doc = self.doc; |
| 7561 |
var startLine = currentLine; |
| 7562 |
while (self.lines[currentLine]) |
| 7563 |
currentLine++; |
| 7564 |
var len = doc.getLength(); |
| 7565 |
var processedLines = 0; |
| 7566 |
self.running = false; |
| 7567 |
while (currentLine < len) { |
| 7568 |
self.$tokenizeRow(currentLine); |
| 7569 |
endLine = currentLine; |
| 7570 |
do { |
| 7571 |
currentLine++; |
| 7572 |
} while (self.lines[currentLine]); |
| 7573 |
processedLines++; |
| 7574 |
if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) { |
| 7575 |
self.running = setTimeout(self.$worker, 20); |
| 7576 |
break; |
| 7577 |
} |
| 7578 |
} |
| 7579 |
self.currentLine = currentLine; |
| 7580 |
if (endLine == -1) |
| 7581 |
endLine = currentLine; |
| 7582 |
if (startLine <= endLine) |
| 7583 |
self.fireUpdateEvent(startLine, endLine); |
| 7584 |
}; |
| 7585 |
} |
| 7586 |
BackgroundTokenizer.prototype.setTokenizer = function (tokenizer) { |
| 7587 |
this.tokenizer = tokenizer; |
| 7588 |
this.lines = []; |
| 7589 |
this.states = []; |
| 7590 |
this.start(0); |
| 7591 |
}; |
| 7592 |
BackgroundTokenizer.prototype.setDocument = function (doc) { |
| 7593 |
this.doc = doc; |
| 7594 |
this.lines = []; |
| 7595 |
this.states = []; |
| 7596 |
this.stop(); |
| 7597 |
}; |
| 7598 |
BackgroundTokenizer.prototype.fireUpdateEvent = function (firstRow, lastRow) { |
| 7599 |
var data = { |
| 7600 |
first: firstRow, |
| 7601 |
last: lastRow |
| 7602 |
}; |
| 7603 |
this._signal("update", { data: data }); |
| 7604 |
}; |
| 7605 |
BackgroundTokenizer.prototype.start = function (startRow) { |
| 7606 |
this.currentLine = Math.min(startRow || 0, this.currentLine, this.doc.getLength()); |
| 7607 |
this.lines.splice(this.currentLine, this.lines.length); |
| 7608 |
this.states.splice(this.currentLine, this.states.length); |
| 7609 |
this.stop(); |
| 7610 |
this.running = setTimeout(this.$worker, 700); |
| 7611 |
}; |
| 7612 |
BackgroundTokenizer.prototype.scheduleStart = function () { |
| 7613 |
if (!this.running) |
| 7614 |
this.running = setTimeout(this.$worker, 700); |
| 7615 |
}; |
| 7616 |
BackgroundTokenizer.prototype.$updateOnChange = function (delta) { |
| 7617 |
var startRow = delta.start.row; |
| 7618 |
var len = delta.end.row - startRow; |
| 7619 |
if (len === 0) { |
| 7620 |
this.lines[startRow] = null; |
| 7621 |
} |
| 7622 |
else if (delta.action == "remove") { |
| 7623 |
this.lines.splice(startRow, len + 1, null); |
| 7624 |
this.states.splice(startRow, len + 1, null); |
| 7625 |
} |
| 7626 |
else { |
| 7627 |
var args = Array(len + 1); |
| 7628 |
args.unshift(startRow, 1); |
| 7629 |
this.lines.splice.apply(this.lines, args); |
| 7630 |
this.states.splice.apply(this.states, args); |
| 7631 |
} |
| 7632 |
this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength()); |
| 7633 |
this.stop(); |
| 7634 |
}; |
| 7635 |
BackgroundTokenizer.prototype.stop = function () { |
| 7636 |
if (this.running) |
| 7637 |
clearTimeout(this.running); |
| 7638 |
this.running = false; |
| 7639 |
}; |
| 7640 |
BackgroundTokenizer.prototype.getTokens = function (row) { |
| 7641 |
return this.lines[row] || this.$tokenizeRow(row); |
| 7642 |
}; |
| 7643 |
BackgroundTokenizer.prototype.getState = function (row) { |
| 7644 |
if (this.currentLine == row) |
| 7645 |
this.$tokenizeRow(row); |
| 7646 |
return this.states[row] || "start"; |
| 7647 |
}; |
| 7648 |
BackgroundTokenizer.prototype.$tokenizeRow = function (row) { |
| 7649 |
var line = this.doc.getLine(row); |
| 7650 |
var state = this.states[row - 1]; |
| 7651 |
var data = this.tokenizer.getLineTokens(line, state, row); |
| 7652 |
if (this.states[row] + "" !== data.state + "") { |
| 7653 |
this.states[row] = data.state; |
| 7654 |
this.lines[row + 1] = null; |
| 7655 |
if (this.currentLine > row + 1) |
| 7656 |
this.currentLine = row + 1; |
| 7657 |
} |
| 7658 |
else if (this.currentLine == row) { |
| 7659 |
this.currentLine = row + 1; |
| 7660 |
} |
| 7661 |
return this.lines[row] = data.tokens; |
| 7662 |
}; |
| 7663 |
BackgroundTokenizer.prototype.cleanup = function () { |
| 7664 |
this.running = false; |
| 7665 |
this.lines = []; |
| 7666 |
this.states = []; |
| 7667 |
this.currentLine = 0; |
| 7668 |
this.removeAllListeners(); |
| 7669 |
}; |
| 7670 |
return BackgroundTokenizer; |
| 7671 |
}()); |
| 7672 |
oop.implement(BackgroundTokenizer.prototype, EventEmitter); |
| 7673 |
exports.BackgroundTokenizer = BackgroundTokenizer; |
| 7674 |
|
| 7675 |
}); |
| 7676 |
|
| 7677 |
ace.define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/range"], function(require, exports, module){"use strict"; |
| 7678 |
var lang = require("./lib/lang"); |
| 7679 |
var Range = require("./range").Range; |
| 7680 |
var SearchHighlight = (function () { |
| 7681 |
function SearchHighlight(regExp, clazz, type) { |
| 7682 |
if (type === void 0) { type = "text"; } |
| 7683 |
this.setRegexp(regExp); |
| 7684 |
this.clazz = clazz; |
| 7685 |
this.type = type; |
| 7686 |
} |
| 7687 |
SearchHighlight.prototype.setRegexp = function (regExp) { |
| 7688 |
if (this.regExp + "" == regExp + "") |
| 7689 |
return; |
| 7690 |
this.regExp = regExp; |
| 7691 |
this.cache = []; |
| 7692 |
}; |
| 7693 |
SearchHighlight.prototype.update = function (html, markerLayer, session, config) { |
| 7694 |
if (!this.regExp) |
| 7695 |
return; |
| 7696 |
var start = config.firstRow, end = config.lastRow; |
| 7697 |
var renderedMarkerRanges = {}; |
| 7698 |
for (var i = start; i <= end; i++) { |
| 7699 |
var ranges = this.cache[i]; |
| 7700 |
if (ranges == null) { |
| 7701 |
ranges = lang.getMatchOffsets(session.getLine(i), this.regExp); |
| 7702 |
if (ranges.length > this.MAX_RANGES) |
| 7703 |
ranges = ranges.slice(0, this.MAX_RANGES); |
| 7704 |
ranges = ranges.map(function (match) { |
| 7705 |
return new Range(i, match.offset, i, match.offset + match.length); |
| 7706 |
}); |
| 7707 |
this.cache[i] = ranges.length ? ranges : ""; |
| 7708 |
} |
| 7709 |
for (var j = ranges.length; j--;) { |
| 7710 |
var rangeToAddMarkerTo = ranges[j].toScreenRange(session); |
| 7711 |
var rangeAsString = rangeToAddMarkerTo.toString(); |
| 7712 |
if (renderedMarkerRanges[rangeAsString]) |
| 7713 |
continue; |
| 7714 |
renderedMarkerRanges[rangeAsString] = true; |
| 7715 |
markerLayer.drawSingleLineMarker(html, rangeToAddMarkerTo, this.clazz, config); |
| 7716 |
} |
| 7717 |
} |
| 7718 |
}; |
| 7719 |
return SearchHighlight; |
| 7720 |
}()); |
| 7721 |
SearchHighlight.prototype.MAX_RANGES = 500; |
| 7722 |
exports.SearchHighlight = SearchHighlight; |
| 7723 |
|
| 7724 |
}); |
| 7725 |
|
| 7726 |
ace.define("ace/undomanager",["require","exports","module","ace/range"], function(require, exports, module){"use strict"; |
| 7727 |
var UndoManager = (function () { |
| 7728 |
function UndoManager() { |
| 7729 |
this.$keepRedoStack; |
| 7730 |
this.$maxRev = 0; |
| 7731 |
this.$fromUndo = false; |
| 7732 |
this.$undoDepth = Infinity; |
| 7733 |
this.reset(); |
| 7734 |
} |
| 7735 |
UndoManager.prototype.addSession = function (session) { |
| 7736 |
this.$session = session; |
| 7737 |
}; |
| 7738 |
UndoManager.prototype.add = function (delta, allowMerge, session) { |
| 7739 |
if (this.$fromUndo) |
| 7740 |
return; |
| 7741 |
if (delta == this.$lastDelta) |
| 7742 |
return; |
| 7743 |
if (!this.$keepRedoStack) |
| 7744 |
this.$redoStack.length = 0; |
| 7745 |
if (allowMerge === false || !this.lastDeltas) { |
| 7746 |
this.lastDeltas = []; |
| 7747 |
var undoStackLength = this.$undoStack.length; |
| 7748 |
if (undoStackLength > this.$undoDepth - 1) { |
| 7749 |
this.$undoStack.splice(0, undoStackLength - this.$undoDepth + 1); |
| 7750 |
} |
| 7751 |
this.$undoStack.push(this.lastDeltas); |
| 7752 |
delta.id = this.$rev = ++this.$maxRev; |
| 7753 |
} |
| 7754 |
if (delta.action == "remove" || delta.action == "insert") |
| 7755 |
this.$lastDelta = delta; |
| 7756 |
this.lastDeltas.push(delta); |
| 7757 |
}; |
| 7758 |
UndoManager.prototype.addSelection = function (selection, rev) { |
| 7759 |
this.selections.push({ |
| 7760 |
value: selection, |
| 7761 |
rev: rev || this.$rev |
| 7762 |
}); |
| 7763 |
}; |
| 7764 |
UndoManager.prototype.startNewGroup = function () { |
| 7765 |
this.lastDeltas = null; |
| 7766 |
return this.$rev; |
| 7767 |
}; |
| 7768 |
UndoManager.prototype.markIgnored = function (from, to) { |
| 7769 |
if (to == null) |
| 7770 |
to = this.$rev + 1; |
| 7771 |
var stack = this.$undoStack; |
| 7772 |
for (var i = stack.length; i--;) { |
| 7773 |
var delta = stack[i][0]; |
| 7774 |
if (delta.id <= from) |
| 7775 |
break; |
| 7776 |
if (delta.id < to) |
| 7777 |
delta.ignore = true; |
| 7778 |
} |
| 7779 |
this.lastDeltas = null; |
| 7780 |
}; |
| 7781 |
UndoManager.prototype.getSelection = function (rev, after) { |
| 7782 |
var stack = this.selections; |
| 7783 |
for (var i = stack.length; i--;) { |
| 7784 |
var selection = stack[i]; |
| 7785 |
if (selection.rev < rev) { |
| 7786 |
if (after) |
| 7787 |
selection = stack[i + 1]; |
| 7788 |
return selection; |
| 7789 |
} |
| 7790 |
} |
| 7791 |
}; |
| 7792 |
UndoManager.prototype.getRevision = function () { |
| 7793 |
return this.$rev; |
| 7794 |
}; |
| 7795 |
UndoManager.prototype.getDeltas = function (from, to) { |
| 7796 |
if (to == null) |
| 7797 |
to = this.$rev + 1; |
| 7798 |
var stack = this.$undoStack; |
| 7799 |
var end = null, start = 0; |
| 7800 |
for (var i = stack.length; i--;) { |
| 7801 |
var delta = stack[i][0]; |
| 7802 |
if (delta.id < to && !end) |
| 7803 |
end = i + 1; |
| 7804 |
if (delta.id <= from) { |
| 7805 |
start = i + 1; |
| 7806 |
break; |
| 7807 |
} |
| 7808 |
} |
| 7809 |
return stack.slice(start, end); |
| 7810 |
}; |
| 7811 |
UndoManager.prototype.getChangedRanges = function (from, to) { |
| 7812 |
if (to == null) |
| 7813 |
to = this.$rev + 1; |
| 7814 |
}; |
| 7815 |
UndoManager.prototype.getChangedLines = function (from, to) { |
| 7816 |
if (to == null) |
| 7817 |
to = this.$rev + 1; |
| 7818 |
}; |
| 7819 |
UndoManager.prototype.undo = function (session, dontSelect) { |
| 7820 |
this.lastDeltas = null; |
| 7821 |
var stack = this.$undoStack; |
| 7822 |
if (!rearrangeUndoStack(stack, stack.length)) |
| 7823 |
return; |
| 7824 |
if (!session) |
| 7825 |
session = this.$session; |
| 7826 |
if (this.$redoStackBaseRev !== this.$rev && this.$redoStack.length) |
| 7827 |
this.$redoStack = []; |
| 7828 |
this.$fromUndo = true; |
| 7829 |
var deltaSet = stack.pop(); |
| 7830 |
var undoSelectionRange = null; |
| 7831 |
if (deltaSet) { |
| 7832 |
undoSelectionRange = session.undoChanges(deltaSet, dontSelect); |
| 7833 |
this.$redoStack.push(deltaSet); |
| 7834 |
this.$syncRev(); |
| 7835 |
} |
| 7836 |
this.$fromUndo = false; |
| 7837 |
return undoSelectionRange; |
| 7838 |
}; |
| 7839 |
UndoManager.prototype.redo = function (session, dontSelect) { |
| 7840 |
this.lastDeltas = null; |
| 7841 |
if (!session) |
| 7842 |
session = this.$session; |
| 7843 |
this.$fromUndo = true; |
| 7844 |
if (this.$redoStackBaseRev != this.$rev) { |
| 7845 |
var diff = this.getDeltas(this.$redoStackBaseRev, this.$rev + 1); |
| 7846 |
rebaseRedoStack(this.$redoStack, diff); |
| 7847 |
this.$redoStackBaseRev = this.$rev; |
| 7848 |
this.$redoStack.forEach(function (x) { |
| 7849 |
x[0].id = ++this.$maxRev; |
| 7850 |
}, this); |
| 7851 |
} |
| 7852 |
var deltaSet = this.$redoStack.pop(); |
| 7853 |
var redoSelectionRange = null; |
| 7854 |
if (deltaSet) { |
| 7855 |
redoSelectionRange = session.redoChanges(deltaSet, dontSelect); |
| 7856 |
this.$undoStack.push(deltaSet); |
| 7857 |
this.$syncRev(); |
| 7858 |
} |
| 7859 |
this.$fromUndo = false; |
| 7860 |
return redoSelectionRange; |
| 7861 |
}; |
| 7862 |
UndoManager.prototype.$syncRev = function () { |
| 7863 |
var stack = this.$undoStack; |
| 7864 |
var nextDelta = stack[stack.length - 1]; |
| 7865 |
var id = nextDelta && nextDelta[0].id || 0; |
| 7866 |
this.$redoStackBaseRev = id; |
| 7867 |
this.$rev = id; |
| 7868 |
}; |
| 7869 |
UndoManager.prototype.reset = function () { |
| 7870 |
this.lastDeltas = null; |
| 7871 |
this.$lastDelta = null; |
| 7872 |
this.$undoStack = []; |
| 7873 |
this.$redoStack = []; |
| 7874 |
this.$rev = 0; |
| 7875 |
this.mark = 0; |
| 7876 |
this.$redoStackBaseRev = this.$rev; |
| 7877 |
this.selections = []; |
| 7878 |
}; |
| 7879 |
UndoManager.prototype.canUndo = function () { |
| 7880 |
return this.$undoStack.length > 0; |
| 7881 |
}; |
| 7882 |
UndoManager.prototype.canRedo = function () { |
| 7883 |
return this.$redoStack.length > 0; |
| 7884 |
}; |
| 7885 |
UndoManager.prototype.bookmark = function (rev) { |
| 7886 |
if (rev == undefined) |
| 7887 |
rev = this.$rev; |
| 7888 |
this.mark = rev; |
| 7889 |
}; |
| 7890 |
UndoManager.prototype.isAtBookmark = function () { |
| 7891 |
return this.$rev === this.mark; |
| 7892 |
}; |
| 7893 |
UndoManager.prototype.toJSON = function () { |
| 7894 |
return { |
| 7895 |
$redoStack: this.$redoStack, |
| 7896 |
$undoStack: this.$undoStack |
| 7897 |
}; |
| 7898 |
}; |
| 7899 |
UndoManager.prototype.fromJSON = function (json) { |
| 7900 |
this.reset(); |
| 7901 |
this.$undoStack = json.$undoStack; |
| 7902 |
this.$redoStack = json.$redoStack; |
| 7903 |
}; |
| 7904 |
UndoManager.prototype.$prettyPrint = function (delta) { |
| 7905 |
if (delta) |
| 7906 |
return stringifyDelta(delta); |
| 7907 |
return stringifyDelta(this.$undoStack) + "\n---\n" + stringifyDelta(this.$redoStack); |
| 7908 |
}; |
| 7909 |
return UndoManager; |
| 7910 |
}()); |
| 7911 |
UndoManager.prototype.hasUndo = UndoManager.prototype.canUndo; |
| 7912 |
UndoManager.prototype.hasRedo = UndoManager.prototype.canRedo; |
| 7913 |
UndoManager.prototype.isClean = UndoManager.prototype.isAtBookmark; |
| 7914 |
UndoManager.prototype.markClean = UndoManager.prototype.bookmark; |
| 7915 |
function rearrangeUndoStack(stack, pos) { |
| 7916 |
for (var i = pos; i--;) { |
| 7917 |
var deltaSet = stack[i]; |
| 7918 |
if (deltaSet && !deltaSet[0].ignore) { |
| 7919 |
while (i < pos - 1) { |
| 7920 |
var swapped = swapGroups(stack[i], stack[i + 1]); |
| 7921 |
stack[i] = swapped[0]; |
| 7922 |
stack[i + 1] = swapped[1]; |
| 7923 |
i++; |
| 7924 |
} |
| 7925 |
return true; |
| 7926 |
} |
| 7927 |
} |
| 7928 |
} |
| 7929 |
var Range = require("./range").Range; |
| 7930 |
var cmp = Range.comparePoints; |
| 7931 |
var comparePoints = Range.comparePoints; |
| 7932 |
function $updateMarkers(delta) { |
| 7933 |
var isInsert = delta.action == "insert"; |
| 7934 |
var start = delta.start; |
| 7935 |
var end = delta.end; |
| 7936 |
var rowShift = (end.row - start.row) * (isInsert ? 1 : -1); |
| 7937 |
var colShift = (end.column - start.column) * (isInsert ? 1 : -1); |
| 7938 |
if (isInsert) |
| 7939 |
end = start; |
| 7940 |
for (var i in this.marks) { |
| 7941 |
var point = this.marks[i]; |
| 7942 |
var cmp = comparePoints(point, start); |
| 7943 |
if (cmp < 0) { |
| 7944 |
continue; |
| 7945 |
} |
| 7946 |
if (cmp === 0) { |
| 7947 |
if (isInsert) { |
| 7948 |
if (point.bias == 1) { |
| 7949 |
cmp = 1; |
| 7950 |
} |
| 7951 |
else { |
| 7952 |
point.bias == -1; |
| 7953 |
continue; |
| 7954 |
} |
| 7955 |
} |
| 7956 |
} |
| 7957 |
var cmp2 = isInsert ? cmp : comparePoints(point, end); |
| 7958 |
if (cmp2 > 0) { |
| 7959 |
point.row += rowShift; |
| 7960 |
point.column += point.row == end.row ? colShift : 0; |
| 7961 |
continue; |
| 7962 |
} |
| 7963 |
if (!isInsert && cmp2 <= 0) { |
| 7964 |
point.row = start.row; |
| 7965 |
point.column = start.column; |
| 7966 |
if (cmp2 === 0) |
| 7967 |
point.bias = 1; |
| 7968 |
} |
| 7969 |
} |
| 7970 |
} |
| 7971 |
function clonePos(pos) { |
| 7972 |
return { row: pos.row, column: pos.column }; |
| 7973 |
} |
| 7974 |
function cloneDelta(d) { |
| 7975 |
return { |
| 7976 |
start: clonePos(d.start), |
| 7977 |
end: clonePos(d.end), |
| 7978 |
action: d.action, |
| 7979 |
lines: d.lines.slice() |
| 7980 |
}; |
| 7981 |
} |
| 7982 |
function stringifyDelta(d) { |
| 7983 |
d = d || this; |
| 7984 |
if (Array.isArray(d)) { |
| 7985 |
return d.map(stringifyDelta).join("\n"); |
| 7986 |
} |
| 7987 |
var type = ""; |
| 7988 |
if (d.action) { |
| 7989 |
type = d.action == "insert" ? "+" : "-"; |
| 7990 |
type += "[" + d.lines + "]"; |
| 7991 |
} |
| 7992 |
else if (d.value) { |
| 7993 |
if (Array.isArray(d.value)) { |
| 7994 |
type = d.value.map(stringifyRange).join("\n"); |
| 7995 |
} |
| 7996 |
else { |
| 7997 |
type = stringifyRange(d.value); |
| 7998 |
} |
| 7999 |
} |
| 8000 |
if (d.start) { |
| 8001 |
type += stringifyRange(d); |
| 8002 |
} |
| 8003 |
if (d.id || d.rev) { |
| 8004 |
type += "\t(" + (d.id || d.rev) + ")"; |
| 8005 |
} |
| 8006 |
return type; |
| 8007 |
} |
| 8008 |
function stringifyRange(r) { |
| 8009 |
return r.start.row + ":" + r.start.column |
| 8010 |
+ "=>" + r.end.row + ":" + r.end.column; |
| 8011 |
} |
| 8012 |
function swap(d1, d2) { |
| 8013 |
var i1 = d1.action == "insert"; |
| 8014 |
var i2 = d2.action == "insert"; |
| 8015 |
if (i1 && i2) { |
| 8016 |
if (cmp(d2.start, d1.end) >= 0) { |
| 8017 |
shift(d2, d1, -1); |
| 8018 |
} |
| 8019 |
else if (cmp(d2.start, d1.start) <= 0) { |
| 8020 |
shift(d1, d2, +1); |
| 8021 |
} |
| 8022 |
else { |
| 8023 |
return null; |
| 8024 |
} |
| 8025 |
} |
| 8026 |
else if (i1 && !i2) { |
| 8027 |
if (cmp(d2.start, d1.end) >= 0) { |
| 8028 |
shift(d2, d1, -1); |
| 8029 |
} |
| 8030 |
else if (cmp(d2.end, d1.start) <= 0) { |
| 8031 |
shift(d1, d2, -1); |
| 8032 |
} |
| 8033 |
else { |
| 8034 |
return null; |
| 8035 |
} |
| 8036 |
} |
| 8037 |
else if (!i1 && i2) { |
| 8038 |
if (cmp(d2.start, d1.start) >= 0) { |
| 8039 |
shift(d2, d1, +1); |
| 8040 |
} |
| 8041 |
else if (cmp(d2.start, d1.start) <= 0) { |
| 8042 |
shift(d1, d2, +1); |
| 8043 |
} |
| 8044 |
else { |
| 8045 |
return null; |
| 8046 |
} |
| 8047 |
} |
| 8048 |
else if (!i1 && !i2) { |
| 8049 |
if (cmp(d2.start, d1.start) >= 0) { |
| 8050 |
shift(d2, d1, +1); |
| 8051 |
} |
| 8052 |
else if (cmp(d2.end, d1.start) <= 0) { |
| 8053 |
shift(d1, d2, -1); |
| 8054 |
} |
| 8055 |
else { |
| 8056 |
return null; |
| 8057 |
} |
| 8058 |
} |
| 8059 |
return [d2, d1]; |
| 8060 |
} |
| 8061 |
function swapGroups(ds1, ds2) { |
| 8062 |
for (var i = ds1.length; i--;) { |
| 8063 |
for (var j = 0; j < ds2.length; j++) { |
| 8064 |
if (!swap(ds1[i], ds2[j])) { |
| 8065 |
while (i < ds1.length) { |
| 8066 |
while (j--) { |
| 8067 |
swap(ds2[j], ds1[i]); |
| 8068 |
} |
| 8069 |
j = ds2.length; |
| 8070 |
i++; |
| 8071 |
} |
| 8072 |
return [ds1, ds2]; |
| 8073 |
} |
| 8074 |
} |
| 8075 |
} |
| 8076 |
ds1.selectionBefore = ds2.selectionBefore = |
| 8077 |
ds1.selectionAfter = ds2.selectionAfter = null; |
| 8078 |
return [ds2, ds1]; |
| 8079 |
} |
| 8080 |
function xform(d1, c1) { |
| 8081 |
var i1 = d1.action == "insert"; |
| 8082 |
var i2 = c1.action == "insert"; |
| 8083 |
if (i1 && i2) { |
| 8084 |
if (cmp(d1.start, c1.start) < 0) { |
| 8085 |
shift(c1, d1, 1); |
| 8086 |
} |
| 8087 |
else { |
| 8088 |
shift(d1, c1, 1); |
| 8089 |
} |
| 8090 |
} |
| 8091 |
else if (i1 && !i2) { |
| 8092 |
if (cmp(d1.start, c1.end) >= 0) { |
| 8093 |
shift(d1, c1, -1); |
| 8094 |
} |
| 8095 |
else if (cmp(d1.start, c1.start) <= 0) { |
| 8096 |
shift(c1, d1, +1); |
| 8097 |
} |
| 8098 |
else { |
| 8099 |
shift(d1, Range.fromPoints(c1.start, d1.start), -1); |
| 8100 |
shift(c1, d1, +1); |
| 8101 |
} |
| 8102 |
} |
| 8103 |
else if (!i1 && i2) { |
| 8104 |
if (cmp(c1.start, d1.end) >= 0) { |
| 8105 |
shift(c1, d1, -1); |
| 8106 |
} |
| 8107 |
else if (cmp(c1.start, d1.start) <= 0) { |
| 8108 |
shift(d1, c1, +1); |
| 8109 |
} |
| 8110 |
else { |
| 8111 |
shift(c1, Range.fromPoints(d1.start, c1.start), -1); |
| 8112 |
shift(d1, c1, +1); |
| 8113 |
} |
| 8114 |
} |
| 8115 |
else if (!i1 && !i2) { |
| 8116 |
if (cmp(c1.start, d1.end) >= 0) { |
| 8117 |
shift(c1, d1, -1); |
| 8118 |
} |
| 8119 |
else if (cmp(c1.end, d1.start) <= 0) { |
| 8120 |
shift(d1, c1, -1); |
| 8121 |
} |
| 8122 |
else { |
| 8123 |
var before, after; |
| 8124 |
if (cmp(d1.start, c1.start) < 0) { |
| 8125 |
before = d1; |
| 8126 |
d1 = splitDelta(d1, c1.start); |
| 8127 |
} |
| 8128 |
if (cmp(d1.end, c1.end) > 0) { |
| 8129 |
after = splitDelta(d1, c1.end); |
| 8130 |
} |
| 8131 |
shiftPos(c1.end, d1.start, d1.end, -1); |
| 8132 |
if (after && !before) { |
| 8133 |
d1.lines = after.lines; |
| 8134 |
d1.start = after.start; |
| 8135 |
d1.end = after.end; |
| 8136 |
after = d1; |
| 8137 |
} |
| 8138 |
return [c1, before, after].filter(Boolean); |
| 8139 |
} |
| 8140 |
} |
| 8141 |
return [c1, d1]; |
| 8142 |
} |
| 8143 |
function shift(d1, d2, dir) { |
| 8144 |
shiftPos(d1.start, d2.start, d2.end, dir); |
| 8145 |
shiftPos(d1.end, d2.start, d2.end, dir); |
| 8146 |
} |
| 8147 |
function shiftPos(pos, start, end, dir) { |
| 8148 |
if (pos.row == (dir == 1 ? start : end).row) { |
| 8149 |
pos.column += dir * (end.column - start.column); |
| 8150 |
} |
| 8151 |
pos.row += dir * (end.row - start.row); |
| 8152 |
} |
| 8153 |
function splitDelta(c, pos) { |
| 8154 |
var lines = c.lines; |
| 8155 |
var end = c.end; |
| 8156 |
c.end = clonePos(pos); |
| 8157 |
var rowsBefore = c.end.row - c.start.row; |
| 8158 |
var otherLines = lines.splice(rowsBefore, lines.length); |
| 8159 |
var col = rowsBefore ? pos.column : pos.column - c.start.column; |
| 8160 |
lines.push(otherLines[0].substring(0, col)); |
| 8161 |
otherLines[0] = otherLines[0].substr(col); |
| 8162 |
var rest = { |
| 8163 |
start: clonePos(pos), |
| 8164 |
end: end, |
| 8165 |
lines: otherLines, |
| 8166 |
action: c.action |
| 8167 |
}; |
| 8168 |
return rest; |
| 8169 |
} |
| 8170 |
function moveDeltasByOne(redoStack, d) { |
| 8171 |
d = cloneDelta(d); |
| 8172 |
for (var j = redoStack.length; j--;) { |
| 8173 |
var deltaSet = redoStack[j]; |
| 8174 |
for (var i = 0; i < deltaSet.length; i++) { |
| 8175 |
var x = deltaSet[i]; |
| 8176 |
var xformed = xform(x, d); |
| 8177 |
d = xformed[0]; |
| 8178 |
if (xformed.length != 2) { |
| 8179 |
if (xformed[2]) { |
| 8180 |
deltaSet.splice(i + 1, 1, xformed[1], xformed[2]); |
| 8181 |
i++; |
| 8182 |
} |
| 8183 |
else if (!xformed[1]) { |
| 8184 |
deltaSet.splice(i, 1); |
| 8185 |
i--; |
| 8186 |
} |
| 8187 |
} |
| 8188 |
} |
| 8189 |
if (!deltaSet.length) { |
| 8190 |
redoStack.splice(j, 1); |
| 8191 |
} |
| 8192 |
} |
| 8193 |
return redoStack; |
| 8194 |
} |
| 8195 |
function rebaseRedoStack(redoStack, deltaSets) { |
| 8196 |
for (var i = 0; i < deltaSets.length; i++) { |
| 8197 |
var deltas = deltaSets[i]; |
| 8198 |
for (var j = 0; j < deltas.length; j++) { |
| 8199 |
moveDeltasByOne(redoStack, deltas[j]); |
| 8200 |
} |
| 8201 |
} |
| 8202 |
} |
| 8203 |
exports.UndoManager = UndoManager; |
| 8204 |
|
| 8205 |
}); |
| 8206 |
|
| 8207 |
ace.define("ace/edit_session/fold_line",["require","exports","module","ace/range"], function(require, exports, module){"use strict"; |
| 8208 |
var Range = require("../range").Range; |
| 8209 |
var FoldLine = (function () { |
| 8210 |
function FoldLine(foldData, folds) { |
| 8211 |
this.foldData = foldData; |
| 8212 |
if (Array.isArray(folds)) { |
| 8213 |
this.folds = folds; |
| 8214 |
} |
| 8215 |
else { |
| 8216 |
folds = this.folds = [folds]; |
| 8217 |
} |
| 8218 |
var last = folds[folds.length - 1]; |
| 8219 |
this.range = new Range(folds[0].start.row, folds[0].start.column, last.end.row, last.end.column); |
| 8220 |
this.start = this.range.start; |
| 8221 |
this.end = this.range.end; |
| 8222 |
this.folds.forEach(function (fold) { |
| 8223 |
fold.setFoldLine(this); |
| 8224 |
}, this); |
| 8225 |
} |
| 8226 |
FoldLine.prototype.shiftRow = function (shift) { |
| 8227 |
this.start.row += shift; |
| 8228 |
this.end.row += shift; |
| 8229 |
this.folds.forEach(function (fold) { |
| 8230 |
fold.start.row += shift; |
| 8231 |
fold.end.row += shift; |
| 8232 |
}); |
| 8233 |
}; |
| 8234 |
FoldLine.prototype.addFold = function (fold) { |
| 8235 |
if (fold.sameRow) { |
| 8236 |
if (fold.start.row < this.startRow || fold.endRow > this.endRow) { |
| 8237 |
throw new Error("Can't add a fold to this FoldLine as it has no connection"); |
| 8238 |
} |
| 8239 |
this.folds.push(fold); |
| 8240 |
this.folds.sort(function (a, b) { |
| 8241 |
return -a.range.compareEnd(b.start.row, b.start.column); |
| 8242 |
}); |
| 8243 |
if (this.range.compareEnd(fold.start.row, fold.start.column) > 0) { |
| 8244 |
this.end.row = fold.end.row; |
| 8245 |
this.end.column = fold.end.column; |
| 8246 |
} |
| 8247 |
else if (this.range.compareStart(fold.end.row, fold.end.column) < 0) { |
| 8248 |
this.start.row = fold.start.row; |
| 8249 |
this.start.column = fold.start.column; |
| 8250 |
} |
| 8251 |
} |
| 8252 |
else if (fold.start.row == this.end.row) { |
| 8253 |
this.folds.push(fold); |
| 8254 |
this.end.row = fold.end.row; |
| 8255 |
this.end.column = fold.end.column; |
| 8256 |
} |
| 8257 |
else if (fold.end.row == this.start.row) { |
| 8258 |
this.folds.unshift(fold); |
| 8259 |
this.start.row = fold.start.row; |
| 8260 |
this.start.column = fold.start.column; |
| 8261 |
} |
| 8262 |
else { |
| 8263 |
throw new Error("Trying to add fold to FoldRow that doesn't have a matching row"); |
| 8264 |
} |
| 8265 |
fold.foldLine = this; |
| 8266 |
}; |
| 8267 |
FoldLine.prototype.containsRow = function (row) { |
| 8268 |
return row >= this.start.row && row <= this.end.row; |
| 8269 |
}; |
| 8270 |
FoldLine.prototype.walk = function (callback, endRow, endColumn) { |
| 8271 |
var lastEnd = 0, folds = this.folds, fold, cmp, stop, isNewRow = true; |
| 8272 |
if (endRow == null) { |
| 8273 |
endRow = this.end.row; |
| 8274 |
endColumn = this.end.column; |
| 8275 |
} |
| 8276 |
for (var i = 0; i < folds.length; i++) { |
| 8277 |
fold = folds[i]; |
| 8278 |
cmp = fold.range.compareStart(endRow, endColumn); |
| 8279 |
if (cmp == -1) { |
| 8280 |
callback(null, endRow, endColumn, lastEnd, isNewRow); |
| 8281 |
return; |
| 8282 |
} |
| 8283 |
stop = callback(null, fold.start.row, fold.start.column, lastEnd, isNewRow); |
| 8284 |
stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd); |
| 8285 |
if (stop || cmp === 0) { |
| 8286 |
return; |
| 8287 |
} |
| 8288 |
isNewRow = !fold.sameRow; |
| 8289 |
lastEnd = fold.end.column; |
| 8290 |
} |
| 8291 |
callback(null, endRow, endColumn, lastEnd, isNewRow); |
| 8292 |
}; |
| 8293 |
FoldLine.prototype.getNextFoldTo = function (row, column) { |
| 8294 |
var fold, cmp; |
| 8295 |
for (var i = 0; i < this.folds.length; i++) { |
| 8296 |
fold = this.folds[i]; |
| 8297 |
cmp = fold.range.compareEnd(row, column); |
| 8298 |
if (cmp == -1) { |
| 8299 |
return { |
| 8300 |
fold: fold, |
| 8301 |
kind: "after" |
| 8302 |
}; |
| 8303 |
} |
| 8304 |
else if (cmp === 0) { |
| 8305 |
return { |
| 8306 |
fold: fold, |
| 8307 |
kind: "inside" |
| 8308 |
}; |
| 8309 |
} |
| 8310 |
} |
| 8311 |
return null; |
| 8312 |
}; |
| 8313 |
FoldLine.prototype.addRemoveChars = function (row, column, len) { |
| 8314 |
var ret = this.getNextFoldTo(row, column), fold, folds; |
| 8315 |
if (ret) { |
| 8316 |
fold = ret.fold; |
| 8317 |
if (ret.kind == "inside" |
| 8318 |
&& fold.start.column != column |
| 8319 |
&& fold.start.row != row) { |
| 8320 |
window.console && window.console.log(row, column, fold); |
| 8321 |
} |
| 8322 |
else if (fold.start.row == row) { |
| 8323 |
folds = this.folds; |
| 8324 |
var i = folds.indexOf(fold); |
| 8325 |
if (i === 0) { |
| 8326 |
this.start.column += len; |
| 8327 |
} |
| 8328 |
for (i; i < folds.length; i++) { |
| 8329 |
fold = folds[i]; |
| 8330 |
fold.start.column += len; |
| 8331 |
if (!fold.sameRow) { |
| 8332 |
return; |
| 8333 |
} |
| 8334 |
fold.end.column += len; |
| 8335 |
} |
| 8336 |
this.end.column += len; |
| 8337 |
} |
| 8338 |
} |
| 8339 |
}; |
| 8340 |
FoldLine.prototype.split = function (row, column) { |
| 8341 |
var pos = this.getNextFoldTo(row, column); |
| 8342 |
if (!pos || pos.kind == "inside") |
| 8343 |
return null; |
| 8344 |
var fold = pos.fold; |
| 8345 |
var folds = this.folds; |
| 8346 |
var foldData = this.foldData; |
| 8347 |
var i = folds.indexOf(fold); |
| 8348 |
var foldBefore = folds[i - 1]; |
| 8349 |
this.end.row = foldBefore.end.row; |
| 8350 |
this.end.column = foldBefore.end.column; |
| 8351 |
folds = folds.splice(i, folds.length - i); |
| 8352 |
var newFoldLine = new FoldLine(foldData, folds); |
| 8353 |
foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine); |
| 8354 |
return newFoldLine; |
| 8355 |
}; |
| 8356 |
FoldLine.prototype.merge = function (foldLineNext) { |
| 8357 |
var folds = foldLineNext.folds; |
| 8358 |
for (var i = 0; i < folds.length; i++) { |
| 8359 |
this.addFold(folds[i]); |
| 8360 |
} |
| 8361 |
var foldData = this.foldData; |
| 8362 |
foldData.splice(foldData.indexOf(foldLineNext), 1); |
| 8363 |
}; |
| 8364 |
FoldLine.prototype.toString = function () { |
| 8365 |
var ret = [this.range.toString() + ": ["]; |
| 8366 |
this.folds.forEach(function (fold) { |
| 8367 |
ret.push(" " + fold.toString()); |
| 8368 |
}); |
| 8369 |
ret.push("]"); |
| 8370 |
return ret.join("\n"); |
| 8371 |
}; |
| 8372 |
FoldLine.prototype.idxToPosition = function (idx) { |
| 8373 |
var lastFoldEndColumn = 0; |
| 8374 |
for (var i = 0; i < this.folds.length; i++) { |
| 8375 |
var fold = this.folds[i]; |
| 8376 |
idx -= fold.start.column - lastFoldEndColumn; |
| 8377 |
if (idx < 0) { |
| 8378 |
return { |
| 8379 |
row: fold.start.row, |
| 8380 |
column: fold.start.column + idx |
| 8381 |
}; |
| 8382 |
} |
| 8383 |
idx -= fold.placeholder.length; |
| 8384 |
if (idx < 0) { |
| 8385 |
return fold.start; |
| 8386 |
} |
| 8387 |
lastFoldEndColumn = fold.end.column; |
| 8388 |
} |
| 8389 |
return { |
| 8390 |
row: this.end.row, |
| 8391 |
column: this.end.column + idx |
| 8392 |
}; |
| 8393 |
}; |
| 8394 |
return FoldLine; |
| 8395 |
}()); |
| 8396 |
exports.FoldLine = FoldLine; |
| 8397 |
|
| 8398 |
}); |
| 8399 |
|
| 8400 |
ace.define("ace/range_list",["require","exports","module","ace/range"], function(require, exports, module){"use strict"; |
| 8401 |
var Range = require("./range").Range; |
| 8402 |
var comparePoints = Range.comparePoints; |
| 8403 |
var RangeList = (function () { |
| 8404 |
function RangeList() { |
| 8405 |
this.ranges = []; |
| 8406 |
this.$bias = 1; |
| 8407 |
} |
| 8408 |
RangeList.prototype.pointIndex = function (pos, excludeEdges, startIndex) { |
| 8409 |
var list = this.ranges; |
| 8410 |
for (var i = startIndex || 0; i < list.length; i++) { |
| 8411 |
var range = list[i]; |
| 8412 |
var cmpEnd = comparePoints(pos, range.end); |
| 8413 |
if (cmpEnd > 0) |
| 8414 |
continue; |
| 8415 |
var cmpStart = comparePoints(pos, range.start); |
| 8416 |
if (cmpEnd === 0) |
| 8417 |
return excludeEdges && cmpStart !== 0 ? -i - 2 : i; |
| 8418 |
if (cmpStart > 0 || (cmpStart === 0 && !excludeEdges)) |
| 8419 |
return i; |
| 8420 |
return -i - 1; |
| 8421 |
} |
| 8422 |
return -i - 1; |
| 8423 |
}; |
| 8424 |
RangeList.prototype.add = function (range) { |
| 8425 |
var excludeEdges = !range.isEmpty(); |
| 8426 |
var startIndex = this.pointIndex(range.start, excludeEdges); |
| 8427 |
if (startIndex < 0) |
| 8428 |
startIndex = -startIndex - 1; |
| 8429 |
var endIndex = this.pointIndex(range.end, excludeEdges, startIndex); |
| 8430 |
if (endIndex < 0) |
| 8431 |
endIndex = -endIndex - 1; |
| 8432 |
else |
| 8433 |
endIndex++; |
| 8434 |
return this.ranges.splice(startIndex, endIndex - startIndex, range); |
| 8435 |
}; |
| 8436 |
RangeList.prototype.addList = function (list) { |
| 8437 |
var removed = []; |
| 8438 |
for (var i = list.length; i--;) { |
| 8439 |
removed.push.apply(removed, this.add(list[i])); |
| 8440 |
} |
| 8441 |
return removed; |
| 8442 |
}; |
| 8443 |
RangeList.prototype.substractPoint = function (pos) { |
| 8444 |
var i = this.pointIndex(pos); |
| 8445 |
if (i >= 0) |
| 8446 |
return this.ranges.splice(i, 1); |
| 8447 |
}; |
| 8448 |
RangeList.prototype.merge = function () { |
| 8449 |
var removed = []; |
| 8450 |
var list = this.ranges; |
| 8451 |
list = list.sort(function (a, b) { |
| 8452 |
return comparePoints(a.start, b.start); |
| 8453 |
}); |
| 8454 |
var next = list[0], range; |
| 8455 |
for (var i = 1; i < list.length; i++) { |
| 8456 |
range = next; |
| 8457 |
next = list[i]; |
| 8458 |
var cmp = comparePoints(range.end, next.start); |
| 8459 |
if (cmp < 0) |
| 8460 |
continue; |
| 8461 |
if (cmp == 0 && !range.isEmpty() && !next.isEmpty()) |
| 8462 |
continue; |
| 8463 |
if (comparePoints(range.end, next.end) < 0) { |
| 8464 |
range.end.row = next.end.row; |
| 8465 |
range.end.column = next.end.column; |
| 8466 |
} |
| 8467 |
list.splice(i, 1); |
| 8468 |
removed.push(next); |
| 8469 |
next = range; |
| 8470 |
i--; |
| 8471 |
} |
| 8472 |
this.ranges = list; |
| 8473 |
return removed; |
| 8474 |
}; |
| 8475 |
RangeList.prototype.contains = function (row, column) { |
| 8476 |
return this.pointIndex({ row: row, column: column }) >= 0; |
| 8477 |
}; |
| 8478 |
RangeList.prototype.containsPoint = function (pos) { |
| 8479 |
return this.pointIndex(pos) >= 0; |
| 8480 |
}; |
| 8481 |
RangeList.prototype.rangeAtPoint = function (pos) { |
| 8482 |
var i = this.pointIndex(pos); |
| 8483 |
if (i >= 0) |
| 8484 |
return this.ranges[i]; |
| 8485 |
}; |
| 8486 |
RangeList.prototype.clipRows = function (startRow, endRow) { |
| 8487 |
var list = this.ranges; |
| 8488 |
if (list[0].start.row > endRow || list[list.length - 1].start.row < startRow) |
| 8489 |
return []; |
| 8490 |
var startIndex = this.pointIndex({ row: startRow, column: 0 }); |
| 8491 |
if (startIndex < 0) |
| 8492 |
startIndex = -startIndex - 1; |
| 8493 |
var endIndex = this.pointIndex({ row: endRow, column: 0 }, startIndex); |
| 8494 |
if (endIndex < 0) |
| 8495 |
endIndex = -endIndex - 1; |
| 8496 |
var clipped = []; |
| 8497 |
for (var i = startIndex; i < endIndex; i++) { |
| 8498 |
clipped.push(list[i]); |
| 8499 |
} |
| 8500 |
return clipped; |
| 8501 |
}; |
| 8502 |
RangeList.prototype.removeAll = function () { |
| 8503 |
return this.ranges.splice(0, this.ranges.length); |
| 8504 |
}; |
| 8505 |
RangeList.prototype.attach = function (session) { |
| 8506 |
if (this.session) |
| 8507 |
this.detach(); |
| 8508 |
this.session = session; |
| 8509 |
this.onChange = this.$onChange.bind(this); |
| 8510 |
this.session.on('change', this.onChange); |
| 8511 |
}; |
| 8512 |
RangeList.prototype.detach = function () { |
| 8513 |
if (!this.session) |
| 8514 |
return; |
| 8515 |
this.session.removeListener('change', this.onChange); |
| 8516 |
this.session = null; |
| 8517 |
}; |
| 8518 |
RangeList.prototype.$onChange = function (delta) { |
| 8519 |
var start = delta.start; |
| 8520 |
var end = delta.end; |
| 8521 |
var startRow = start.row; |
| 8522 |
var endRow = end.row; |
| 8523 |
var ranges = this.ranges; |
| 8524 |
for (var i = 0, n = ranges.length; i < n; i++) { |
| 8525 |
var r = ranges[i]; |
| 8526 |
if (r.end.row >= startRow) |
| 8527 |
break; |
| 8528 |
} |
| 8529 |
if (delta.action == "insert") { |
| 8530 |
var lineDif = endRow - startRow; |
| 8531 |
var colDiff = -start.column + end.column; |
| 8532 |
for (; i < n; i++) { |
| 8533 |
var r = ranges[i]; |
| 8534 |
if (r.start.row > startRow) |
| 8535 |
break; |
| 8536 |
if (r.start.row == startRow && r.start.column >= start.column) { |
| 8537 |
if (r.start.column == start.column && this.$bias <= 0) { |
| 8538 |
} |
| 8539 |
else { |
| 8540 |
r.start.column += colDiff; |
| 8541 |
r.start.row += lineDif; |
| 8542 |
} |
| 8543 |
} |
| 8544 |
if (r.end.row == startRow && r.end.column >= start.column) { |
| 8545 |
if (r.end.column == start.column && this.$bias < 0) { |
| 8546 |
continue; |
| 8547 |
} |
| 8548 |
if (r.end.column == start.column && colDiff > 0 && i < n - 1) { |
| 8549 |
if (r.end.column > r.start.column && r.end.column == ranges[i + 1].start.column) |
| 8550 |
r.end.column -= colDiff; |
| 8551 |
} |
| 8552 |
r.end.column += colDiff; |
| 8553 |
r.end.row += lineDif; |
| 8554 |
} |
| 8555 |
} |
| 8556 |
} |
| 8557 |
else { |
| 8558 |
var lineDif = startRow - endRow; |
| 8559 |
var colDiff = start.column - end.column; |
| 8560 |
for (; i < n; i++) { |
| 8561 |
var r = ranges[i]; |
| 8562 |
if (r.start.row > endRow) |
| 8563 |
break; |
| 8564 |
if (r.end.row < endRow |
| 8565 |
&& (startRow < r.end.row |
| 8566 |
|| startRow == r.end.row && start.column < r.end.column)) { |
| 8567 |
r.end.row = startRow; |
| 8568 |
r.end.column = start.column; |
| 8569 |
} |
| 8570 |
else if (r.end.row == endRow) { |
| 8571 |
if (r.end.column <= end.column) { |
| 8572 |
if (lineDif || r.end.column > start.column) { |
| 8573 |
r.end.column = start.column; |
| 8574 |
r.end.row = start.row; |
| 8575 |
} |
| 8576 |
} |
| 8577 |
else { |
| 8578 |
r.end.column += colDiff; |
| 8579 |
r.end.row += lineDif; |
| 8580 |
} |
| 8581 |
} |
| 8582 |
else if (r.end.row > endRow) { |
| 8583 |
r.end.row += lineDif; |
| 8584 |
} |
| 8585 |
if (r.start.row < endRow |
| 8586 |
&& (startRow < r.start.row |
| 8587 |
|| startRow == r.start.row && start.column < r.start.column)) { |
| 8588 |
r.start.row = startRow; |
| 8589 |
r.start.column = start.column; |
| 8590 |
} |
| 8591 |
else if (r.start.row == endRow) { |
| 8592 |
if (r.start.column <= end.column) { |
| 8593 |
if (lineDif || r.start.column > start.column) { |
| 8594 |
r.start.column = start.column; |
| 8595 |
r.start.row = start.row; |
| 8596 |
} |
| 8597 |
} |
| 8598 |
else { |
| 8599 |
r.start.column += colDiff; |
| 8600 |
r.start.row += lineDif; |
| 8601 |
} |
| 8602 |
} |
| 8603 |
else if (r.start.row > endRow) { |
| 8604 |
r.start.row += lineDif; |
| 8605 |
} |
| 8606 |
} |
| 8607 |
} |
| 8608 |
if (lineDif != 0 && i < n) { |
| 8609 |
for (; i < n; i++) { |
| 8610 |
var r = ranges[i]; |
| 8611 |
r.start.row += lineDif; |
| 8612 |
r.end.row += lineDif; |
| 8613 |
} |
| 8614 |
} |
| 8615 |
}; |
| 8616 |
return RangeList; |
| 8617 |
}()); |
| 8618 |
RangeList.prototype.comparePoints = comparePoints; |
| 8619 |
exports.RangeList = RangeList; |
| 8620 |
|
| 8621 |
}); |
| 8622 |
|
| 8623 |
ace.define("ace/edit_session/fold",["require","exports","module","ace/range_list"], function(require, exports, module){"use strict"; |
| 8624 |
var __extends = (this && this.__extends) || (function () { |
| 8625 |
var extendStatics = function (d, b) { |
| 8626 |
extendStatics = Object.setPrototypeOf || |
| 8627 |
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
| 8628 |
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; |
| 8629 |
return extendStatics(d, b); |
| 8630 |
}; |
| 8631 |
return function (d, b) { |
| 8632 |
if (typeof b !== "function" && b !== null) |
| 8633 |
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); |
| 8634 |
extendStatics(d, b); |
| 8635 |
function __() { this.constructor = d; } |
| 8636 |
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
| 8637 |
}; |
| 8638 |
})(); |
| 8639 |
var RangeList = require("../range_list").RangeList; |
| 8640 |
var Fold = (function (_super) { |
| 8641 |
__extends(Fold, _super); |
| 8642 |
function Fold(range, placeholder) { |
| 8643 |
var _this = _super.call(this) || this; |
| 8644 |
_this.foldLine = null; |
| 8645 |
_this.placeholder = placeholder; |
| 8646 |
_this.range = range; |
| 8647 |
_this.start = range.start; |
| 8648 |
_this.end = range.end; |
| 8649 |
_this.sameRow = range.start.row == range.end.row; |
| 8650 |
_this.subFolds = _this.ranges = []; |
| 8651 |
return _this; |
| 8652 |
} |
| 8653 |
Fold.prototype.toString = function () { |
| 8654 |
return '"' + this.placeholder + '" ' + this.range.toString(); |
| 8655 |
}; |
| 8656 |
Fold.prototype.setFoldLine = function (foldLine) { |
| 8657 |
this.foldLine = foldLine; |
| 8658 |
this.subFolds.forEach(function (fold) { |
| 8659 |
fold.setFoldLine(foldLine); |
| 8660 |
}); |
| 8661 |
}; |
| 8662 |
Fold.prototype.clone = function () { |
| 8663 |
var range = this.range.clone(); |
| 8664 |
var fold = new Fold(range, this.placeholder); |
| 8665 |
this.subFolds.forEach(function (subFold) { |
| 8666 |
fold.subFolds.push(subFold.clone()); |
| 8667 |
}); |
| 8668 |
fold.collapseChildren = this.collapseChildren; |
| 8669 |
return fold; |
| 8670 |
}; |
| 8671 |
Fold.prototype.addSubFold = function (fold) { |
| 8672 |
if (this.range.isEqual(fold)) |
| 8673 |
return; |
| 8674 |
consumeRange(fold, this.start); |
| 8675 |
var row = fold.start.row, column = fold.start.column; |
| 8676 |
for (var i = 0, cmp = -1; i < this.subFolds.length; i++) { |
| 8677 |
cmp = this.subFolds[i].range.compare(row, column); |
| 8678 |
if (cmp != 1) |
| 8679 |
break; |
| 8680 |
} |
| 8681 |
var afterStart = this.subFolds[i]; |
| 8682 |
var firstConsumed = 0; |
| 8683 |
if (cmp == 0) { |
| 8684 |
if (afterStart.range.containsRange(fold)) |
| 8685 |
return afterStart.addSubFold(fold); |
| 8686 |
else |
| 8687 |
firstConsumed = 1; |
| 8688 |
} |
| 8689 |
var row = fold.range.end.row, column = fold.range.end.column; |
| 8690 |
for (var j = i, cmp = -1; j < this.subFolds.length; j++) { |
| 8691 |
cmp = this.subFolds[j].range.compare(row, column); |
| 8692 |
if (cmp != 1) |
| 8693 |
break; |
| 8694 |
} |
| 8695 |
if (cmp == 0) |
| 8696 |
j++; |
| 8697 |
var consumedFolds = this.subFolds.splice(i, j - i, fold); |
| 8698 |
var last = cmp == 0 ? consumedFolds.length - 1 : consumedFolds.length; |
| 8699 |
for (var k = firstConsumed; k < last; k++) { |
| 8700 |
fold.addSubFold(consumedFolds[k]); |
| 8701 |
} |
| 8702 |
fold.setFoldLine(this.foldLine); |
| 8703 |
return fold; |
| 8704 |
}; |
| 8705 |
Fold.prototype.restoreRange = function (range) { |
| 8706 |
return restoreRange(range, this.start); |
| 8707 |
}; |
| 8708 |
return Fold; |
| 8709 |
}(RangeList)); |
| 8710 |
function consumePoint(point, anchor) { |
| 8711 |
point.row -= anchor.row; |
| 8712 |
if (point.row == 0) |
| 8713 |
point.column -= anchor.column; |
| 8714 |
} |
| 8715 |
function consumeRange(range, anchor) { |
| 8716 |
consumePoint(range.start, anchor); |
| 8717 |
consumePoint(range.end, anchor); |
| 8718 |
} |
| 8719 |
function restorePoint(point, anchor) { |
| 8720 |
if (point.row == 0) |
| 8721 |
point.column += anchor.column; |
| 8722 |
point.row += anchor.row; |
| 8723 |
} |
| 8724 |
function restoreRange(range, anchor) { |
| 8725 |
restorePoint(range.start, anchor); |
| 8726 |
restorePoint(range.end, anchor); |
| 8727 |
} |
| 8728 |
exports.Fold = Fold; |
| 8729 |
|
| 8730 |
}); |
| 8731 |
|
| 8732 |
ace.define("ace/edit_session/folding",["require","exports","module","ace/range","ace/edit_session/fold_line","ace/edit_session/fold","ace/token_iterator","ace/mouse/mouse_event"], function(require, exports, module){ |
| 8733 |
"use strict"; |
| 8734 |
var Range = require("../range").Range; |
| 8735 |
var FoldLine = require("./fold_line").FoldLine; |
| 8736 |
var Fold = require("./fold").Fold; |
| 8737 |
var TokenIterator = require("../token_iterator").TokenIterator; |
| 8738 |
var MouseEvent = require("../mouse/mouse_event").MouseEvent; |
| 8739 |
function Folding() { |
| 8740 |
this.getFoldAt = function (row, column, side) { |
| 8741 |
var foldLine = this.getFoldLine(row); |
| 8742 |
if (!foldLine) |
| 8743 |
return null; |
| 8744 |
var folds = foldLine.folds; |
| 8745 |
for (var i = 0; i < folds.length; i++) { |
| 8746 |
var range = folds[i].range; |
| 8747 |
if (range.contains(row, column)) { |
| 8748 |
if (side == 1 && range.isEnd(row, column) && !range.isEmpty()) { |
| 8749 |
continue; |
| 8750 |
} |
| 8751 |
else if (side == -1 && range.isStart(row, column) && !range.isEmpty()) { |
| 8752 |
continue; |
| 8753 |
} |
| 8754 |
return folds[i]; |
| 8755 |
} |
| 8756 |
} |
| 8757 |
}; |
| 8758 |
this.getFoldsInRange = function (range) { |
| 8759 |
var start = range.start; |
| 8760 |
var end = range.end; |
| 8761 |
var foldLines = this.$foldData; |
| 8762 |
var foundFolds = []; |
| 8763 |
start.column += 1; |
| 8764 |
end.column -= 1; |
| 8765 |
for (var i = 0; i < foldLines.length; i++) { |
| 8766 |
var cmp = foldLines[i].range.compareRange(range); |
| 8767 |
if (cmp == 2) { |
| 8768 |
continue; |
| 8769 |
} |
| 8770 |
else if (cmp == -2) { |
| 8771 |
break; |
| 8772 |
} |
| 8773 |
var folds = foldLines[i].folds; |
| 8774 |
for (var j = 0; j < folds.length; j++) { |
| 8775 |
var fold = folds[j]; |
| 8776 |
cmp = fold.range.compareRange(range); |
| 8777 |
if (cmp == -2) { |
| 8778 |
break; |
| 8779 |
} |
| 8780 |
else if (cmp == 2) { |
| 8781 |
continue; |
| 8782 |
} |
| 8783 |
else |
| 8784 |
if (cmp == 42) { |
| 8785 |
break; |
| 8786 |
} |
| 8787 |
foundFolds.push(fold); |
| 8788 |
} |
| 8789 |
} |
| 8790 |
start.column -= 1; |
| 8791 |
end.column += 1; |
| 8792 |
return foundFolds; |
| 8793 |
}; |
| 8794 |
this.getFoldsInRangeList = function (ranges) { |
| 8795 |
if (Array.isArray(ranges)) { |
| 8796 |
var folds = []; |
| 8797 |
ranges.forEach(function (range) { |
| 8798 |
folds = folds.concat(this.getFoldsInRange(range)); |
| 8799 |
}, this); |
| 8800 |
} |
| 8801 |
else { |
| 8802 |
var folds = this.getFoldsInRange(ranges); |
| 8803 |
} |
| 8804 |
return folds; |
| 8805 |
}; |
| 8806 |
this.getAllFolds = function () { |
| 8807 |
var folds = []; |
| 8808 |
var foldLines = this.$foldData; |
| 8809 |
for (var i = 0; i < foldLines.length; i++) |
| 8810 |
for (var j = 0; j < foldLines[i].folds.length; j++) |
| 8811 |
folds.push(foldLines[i].folds[j]); |
| 8812 |
return folds; |
| 8813 |
}; |
| 8814 |
this.getFoldStringAt = function (row, column, trim, foldLine) { |
| 8815 |
foldLine = foldLine || this.getFoldLine(row); |
| 8816 |
if (!foldLine) |
| 8817 |
return null; |
| 8818 |
var lastFold = { |
| 8819 |
end: { column: 0 } |
| 8820 |
}; |
| 8821 |
var str, fold; |
| 8822 |
for (var i = 0; i < foldLine.folds.length; i++) { |
| 8823 |
fold = foldLine.folds[i]; |
| 8824 |
var cmp = fold.range.compareEnd(row, column); |
| 8825 |
if (cmp == -1) { |
| 8826 |
str = this |
| 8827 |
.getLine(fold.start.row) |
| 8828 |
.substring(lastFold.end.column, fold.start.column); |
| 8829 |
break; |
| 8830 |
} |
| 8831 |
else if (cmp === 0) { |
| 8832 |
return null; |
| 8833 |
} |
| 8834 |
lastFold = fold; |
| 8835 |
} |
| 8836 |
if (!str) |
| 8837 |
str = this.getLine(fold.start.row).substring(lastFold.end.column); |
| 8838 |
if (trim == -1) |
| 8839 |
return str.substring(0, column - lastFold.end.column); |
| 8840 |
else if (trim == 1) |
| 8841 |
return str.substring(column - lastFold.end.column); |
| 8842 |
else |
| 8843 |
return str; |
| 8844 |
}; |
| 8845 |
this.getFoldLine = function (docRow, startFoldLine) { |
| 8846 |
var foldData = this.$foldData; |
| 8847 |
var i = 0; |
| 8848 |
if (startFoldLine) |
| 8849 |
i = foldData.indexOf(startFoldLine); |
| 8850 |
if (i == -1) |
| 8851 |
i = 0; |
| 8852 |
for (i; i < foldData.length; i++) { |
| 8853 |
var foldLine = foldData[i]; |
| 8854 |
if (foldLine.start.row <= docRow && foldLine.end.row >= docRow) { |
| 8855 |
return foldLine; |
| 8856 |
} |
| 8857 |
else if (foldLine.end.row > docRow) { |
| 8858 |
return null; |
| 8859 |
} |
| 8860 |
} |
| 8861 |
return null; |
| 8862 |
}; |
| 8863 |
this.getNextFoldLine = function (docRow, startFoldLine) { |
| 8864 |
var foldData = this.$foldData; |
| 8865 |
var i = 0; |
| 8866 |
if (startFoldLine) |
| 8867 |
i = foldData.indexOf(startFoldLine); |
| 8868 |
if (i == -1) |
| 8869 |
i = 0; |
| 8870 |
for (i; i < foldData.length; i++) { |
| 8871 |
var foldLine = foldData[i]; |
| 8872 |
if (foldLine.end.row >= docRow) { |
| 8873 |
return foldLine; |
| 8874 |
} |
| 8875 |
} |
| 8876 |
return null; |
| 8877 |
}; |
| 8878 |
this.getFoldedRowCount = function (first, last) { |
| 8879 |
var foldData = this.$foldData, rowCount = last - first + 1; |
| 8880 |
for (var i = 0; i < foldData.length; i++) { |
| 8881 |
var foldLine = foldData[i], end = foldLine.end.row, start = foldLine.start.row; |
| 8882 |
if (end >= last) { |
| 8883 |
if (start < last) { |
| 8884 |
if (start >= first) |
| 8885 |
rowCount -= last - start; |
| 8886 |
else |
| 8887 |
rowCount = 0; |
| 8888 |
} |
| 8889 |
break; |
| 8890 |
} |
| 8891 |
else if (end >= first) { |
| 8892 |
if (start >= first) |
| 8893 |
rowCount -= end - start; |
| 8894 |
else |
| 8895 |
rowCount -= end - first + 1; |
| 8896 |
} |
| 8897 |
} |
| 8898 |
return rowCount; |
| 8899 |
}; |
| 8900 |
this.$addFoldLine = function (foldLine) { |
| 8901 |
this.$foldData.push(foldLine); |
| 8902 |
this.$foldData.sort(function (a, b) { |
| 8903 |
return a.start.row - b.start.row; |
| 8904 |
}); |
| 8905 |
return foldLine; |
| 8906 |
}; |
| 8907 |
this.addFold = function (placeholder, range) { |
| 8908 |
var foldData = this.$foldData; |
| 8909 |
var added = false; |
| 8910 |
var fold; |
| 8911 |
if (placeholder instanceof Fold) |
| 8912 |
fold = placeholder; |
| 8913 |
else { |
| 8914 |
fold = new Fold(range, placeholder); |
| 8915 |
fold.collapseChildren = range.collapseChildren; |
| 8916 |
} |
| 8917 |
this.$clipRangeToDocument(fold.range); |
| 8918 |
var startRow = fold.start.row; |
| 8919 |
var startColumn = fold.start.column; |
| 8920 |
var endRow = fold.end.row; |
| 8921 |
var endColumn = fold.end.column; |
| 8922 |
var startFold = this.getFoldAt(startRow, startColumn, 1); |
| 8923 |
var endFold = this.getFoldAt(endRow, endColumn, -1); |
| 8924 |
if (startFold && endFold == startFold) |
| 8925 |
return startFold.addSubFold(fold); |
| 8926 |
if (startFold && !startFold.range.isStart(startRow, startColumn)) |
| 8927 |
this.removeFold(startFold); |
| 8928 |
if (endFold && !endFold.range.isEnd(endRow, endColumn)) |
| 8929 |
this.removeFold(endFold); |
| 8930 |
var folds = this.getFoldsInRange(fold.range); |
| 8931 |
if (folds.length > 0) { |
| 8932 |
this.removeFolds(folds); |
| 8933 |
if (!fold.collapseChildren) { |
| 8934 |
folds.forEach(function (subFold) { |
| 8935 |
fold.addSubFold(subFold); |
| 8936 |
}); |
| 8937 |
} |
| 8938 |
} |
| 8939 |
for (var i = 0; i < foldData.length; i++) { |
| 8940 |
var foldLine = foldData[i]; |
| 8941 |
if (endRow == foldLine.start.row) { |
| 8942 |
foldLine.addFold(fold); |
| 8943 |
added = true; |
| 8944 |
break; |
| 8945 |
} |
| 8946 |
else if (startRow == foldLine.end.row) { |
| 8947 |
foldLine.addFold(fold); |
| 8948 |
added = true; |
| 8949 |
if (!fold.sameRow) { |
| 8950 |
var foldLineNext = foldData[i + 1]; |
| 8951 |
if (foldLineNext && foldLineNext.start.row == endRow) { |
| 8952 |
foldLine.merge(foldLineNext); |
| 8953 |
break; |
| 8954 |
} |
| 8955 |
} |
| 8956 |
break; |
| 8957 |
} |
| 8958 |
else if (endRow <= foldLine.start.row) { |
| 8959 |
break; |
| 8960 |
} |
| 8961 |
} |
| 8962 |
if (!added) |
| 8963 |
foldLine = this.$addFoldLine(new FoldLine(this.$foldData, fold)); |
| 8964 |
if (this.$useWrapMode) |
| 8965 |
this.$updateWrapData(foldLine.start.row, foldLine.start.row); |
| 8966 |
else |
| 8967 |
this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row); |
| 8968 |
this.$modified = true; |
| 8969 |
this._signal("changeFold", { data: fold, action: "add" }); |
| 8970 |
return fold; |
| 8971 |
}; |
| 8972 |
this.addFolds = function (folds) { |
| 8973 |
folds.forEach(function (fold) { |
| 8974 |
this.addFold(fold); |
| 8975 |
}, this); |
| 8976 |
}; |
| 8977 |
this.removeFold = function (fold) { |
| 8978 |
var foldLine = fold.foldLine; |
| 8979 |
var startRow = foldLine.start.row; |
| 8980 |
var endRow = foldLine.end.row; |
| 8981 |
var foldLines = this.$foldData; |
| 8982 |
var folds = foldLine.folds; |
| 8983 |
if (folds.length == 1) { |
| 8984 |
foldLines.splice(foldLines.indexOf(foldLine), 1); |
| 8985 |
} |
| 8986 |
else |
| 8987 |
if (foldLine.range.isEnd(fold.end.row, fold.end.column)) { |
| 8988 |
folds.pop(); |
| 8989 |
foldLine.end.row = folds[folds.length - 1].end.row; |
| 8990 |
foldLine.end.column = folds[folds.length - 1].end.column; |
| 8991 |
} |
| 8992 |
else |
| 8993 |
if (foldLine.range.isStart(fold.start.row, fold.start.column)) { |
| 8994 |
folds.shift(); |
| 8995 |
foldLine.start.row = folds[0].start.row; |
| 8996 |
foldLine.start.column = folds[0].start.column; |
| 8997 |
} |
| 8998 |
else |
| 8999 |
if (fold.sameRow) { |
| 9000 |
folds.splice(folds.indexOf(fold), 1); |
| 9001 |
} |
| 9002 |
else |
| 9003 |
{ |
| 9004 |
var newFoldLine = foldLine.split(fold.start.row, fold.start.column); |
| 9005 |
folds = newFoldLine.folds; |
| 9006 |
folds.shift(); |
| 9007 |
newFoldLine.start.row = folds[0].start.row; |
| 9008 |
newFoldLine.start.column = folds[0].start.column; |
| 9009 |
} |
| 9010 |
if (!this.$updating) { |
| 9011 |
if (this.$useWrapMode) |
| 9012 |
this.$updateWrapData(startRow, endRow); |
| 9013 |
else |
| 9014 |
this.$updateRowLengthCache(startRow, endRow); |
| 9015 |
} |
| 9016 |
this.$modified = true; |
| 9017 |
this._signal("changeFold", { data: fold, action: "remove" }); |
| 9018 |
}; |
| 9019 |
this.removeFolds = function (folds) { |
| 9020 |
var cloneFolds = []; |
| 9021 |
for (var i = 0; i < folds.length; i++) { |
| 9022 |
cloneFolds.push(folds[i]); |
| 9023 |
} |
| 9024 |
cloneFolds.forEach(function (fold) { |
| 9025 |
this.removeFold(fold); |
| 9026 |
}, this); |
| 9027 |
this.$modified = true; |
| 9028 |
}; |
| 9029 |
this.expandFold = function (fold) { |
| 9030 |
this.removeFold(fold); |
| 9031 |
fold.subFolds.forEach(function (subFold) { |
| 9032 |
fold.restoreRange(subFold); |
| 9033 |
this.addFold(subFold); |
| 9034 |
}, this); |
| 9035 |
if (fold.collapseChildren > 0) { |
| 9036 |
this.foldAll(fold.start.row + 1, fold.end.row, fold.collapseChildren - 1); |
| 9037 |
} |
| 9038 |
fold.subFolds = []; |
| 9039 |
}; |
| 9040 |
this.expandFolds = function (folds) { |
| 9041 |
folds.forEach(function (fold) { |
| 9042 |
this.expandFold(fold); |
| 9043 |
}, this); |
| 9044 |
}; |
| 9045 |
this.unfold = function (location, expandInner) { |
| 9046 |
var range, folds; |
| 9047 |
if (location == null) { |
| 9048 |
range = new Range(0, 0, this.getLength(), 0); |
| 9049 |
if (expandInner == null) |
| 9050 |
expandInner = true; |
| 9051 |
} |
| 9052 |
else if (typeof location == "number") { |
| 9053 |
range = new Range(location, 0, location, this.getLine(location).length); |
| 9054 |
} |
| 9055 |
else if ("row" in location) { |
| 9056 |
range = Range.fromPoints(location, location); |
| 9057 |
} |
| 9058 |
else if (Array.isArray(location)) { |
| 9059 |
folds = []; |
| 9060 |
location.forEach(function (range) { |
| 9061 |
folds = folds.concat(this.unfold(range)); |
| 9062 |
}, this); |
| 9063 |
return folds; |
| 9064 |
} |
| 9065 |
else { |
| 9066 |
range = location; |
| 9067 |
} |
| 9068 |
folds = this.getFoldsInRangeList(range); |
| 9069 |
var outermostFolds = folds; |
| 9070 |
while (folds.length == 1 |
| 9071 |
&& Range.comparePoints(folds[0].start, range.start) < 0 |
| 9072 |
&& Range.comparePoints(folds[0].end, range.end) > 0) { |
| 9073 |
this.expandFolds(folds); |
| 9074 |
folds = this.getFoldsInRangeList(range); |
| 9075 |
} |
| 9076 |
if (expandInner != false) { |
| 9077 |
this.removeFolds(folds); |
| 9078 |
} |
| 9079 |
else { |
| 9080 |
this.expandFolds(folds); |
| 9081 |
} |
| 9082 |
if (outermostFolds.length) |
| 9083 |
return outermostFolds; |
| 9084 |
}; |
| 9085 |
this.isRowFolded = function (docRow, startFoldRow) { |
| 9086 |
return !!this.getFoldLine(docRow, startFoldRow); |
| 9087 |
}; |
| 9088 |
this.getRowFoldEnd = function (docRow, startFoldRow) { |
| 9089 |
var foldLine = this.getFoldLine(docRow, startFoldRow); |
| 9090 |
return foldLine ? foldLine.end.row : docRow; |
| 9091 |
}; |
| 9092 |
this.getRowFoldStart = function (docRow, startFoldRow) { |
| 9093 |
var foldLine = this.getFoldLine(docRow, startFoldRow); |
| 9094 |
return foldLine ? foldLine.start.row : docRow; |
| 9095 |
}; |
| 9096 |
this.getFoldDisplayLine = function (foldLine, endRow, endColumn, startRow, startColumn) { |
| 9097 |
if (startRow == null) |
| 9098 |
startRow = foldLine.start.row; |
| 9099 |
if (startColumn == null) |
| 9100 |
startColumn = 0; |
| 9101 |
if (endRow == null) |
| 9102 |
endRow = foldLine.end.row; |
| 9103 |
if (endColumn == null) |
| 9104 |
endColumn = this.getLine(endRow).length; |
| 9105 |
var doc = this.doc; |
| 9106 |
var textLine = ""; |
| 9107 |
foldLine.walk(function (placeholder, row, column, lastColumn) { |
| 9108 |
if (row < startRow) |
| 9109 |
return; |
| 9110 |
if (row == startRow) { |
| 9111 |
if (column < startColumn) |
| 9112 |
return; |
| 9113 |
lastColumn = Math.max(startColumn, lastColumn); |
| 9114 |
} |
| 9115 |
if (placeholder != null) { |
| 9116 |
textLine += placeholder; |
| 9117 |
} |
| 9118 |
else { |
| 9119 |
textLine += doc.getLine(row).substring(lastColumn, column); |
| 9120 |
} |
| 9121 |
}, endRow, endColumn); |
| 9122 |
return textLine; |
| 9123 |
}; |
| 9124 |
this.getDisplayLine = function (row, endColumn, startRow, startColumn) { |
| 9125 |
var foldLine = this.getFoldLine(row); |
| 9126 |
if (!foldLine) { |
| 9127 |
var line; |
| 9128 |
line = this.doc.getLine(row); |
| 9129 |
return line.substring(startColumn || 0, endColumn || line.length); |
| 9130 |
} |
| 9131 |
else { |
| 9132 |
return this.getFoldDisplayLine(foldLine, row, endColumn, startRow, startColumn); |
| 9133 |
} |
| 9134 |
}; |
| 9135 |
this.$cloneFoldData = function () { |
| 9136 |
var fd = []; |
| 9137 |
fd = this.$foldData.map(function (foldLine) { |
| 9138 |
var folds = foldLine.folds.map(function (fold) { |
| 9139 |
return fold.clone(); |
| 9140 |
}); |
| 9141 |
return new FoldLine(fd, folds); |
| 9142 |
}); |
| 9143 |
return fd; |
| 9144 |
}; |
| 9145 |
this.toggleFold = function (tryToUnfold) { |
| 9146 |
var selection = this.selection; |
| 9147 |
var range = selection.getRange(); |
| 9148 |
var fold; |
| 9149 |
var bracketPos; |
| 9150 |
if (range.isEmpty()) { |
| 9151 |
var cursor = range.start; |
| 9152 |
fold = this.getFoldAt(cursor.row, cursor.column); |
| 9153 |
if (fold) { |
| 9154 |
this.expandFold(fold); |
| 9155 |
return; |
| 9156 |
} |
| 9157 |
else if (bracketPos = this.findMatchingBracket(cursor)) { |
| 9158 |
if (range.comparePoint(bracketPos) == 1) { |
| 9159 |
range.end = bracketPos; |
| 9160 |
} |
| 9161 |
else { |
| 9162 |
range.start = bracketPos; |
| 9163 |
range.start.column++; |
| 9164 |
range.end.column--; |
| 9165 |
} |
| 9166 |
} |
| 9167 |
else if (bracketPos = this.findMatchingBracket({ row: cursor.row, column: cursor.column + 1 })) { |
| 9168 |
if (range.comparePoint(bracketPos) == 1) |
| 9169 |
range.end = bracketPos; |
| 9170 |
else |
| 9171 |
range.start = bracketPos; |
| 9172 |
range.start.column++; |
| 9173 |
} |
| 9174 |
else { |
| 9175 |
range = this.getCommentFoldRange(cursor.row, cursor.column) || range; |
| 9176 |
} |
| 9177 |
} |
| 9178 |
else { |
| 9179 |
var folds = this.getFoldsInRange(range); |
| 9180 |
if (tryToUnfold && folds.length) { |
| 9181 |
this.expandFolds(folds); |
| 9182 |
return; |
| 9183 |
} |
| 9184 |
else if (folds.length == 1) { |
| 9185 |
fold = folds[0]; |
| 9186 |
} |
| 9187 |
} |
| 9188 |
if (!fold) |
| 9189 |
fold = this.getFoldAt(range.start.row, range.start.column); |
| 9190 |
if (fold && fold.range.toString() == range.toString()) { |
| 9191 |
this.expandFold(fold); |
| 9192 |
return; |
| 9193 |
} |
| 9194 |
var placeholder = "..."; |
| 9195 |
if (!range.isMultiLine()) { |
| 9196 |
placeholder = this.getTextRange(range); |
| 9197 |
if (placeholder.length < 4) |
| 9198 |
return; |
| 9199 |
placeholder = placeholder.trim().substring(0, 2) + ".."; |
| 9200 |
} |
| 9201 |
this.addFold(placeholder, range); |
| 9202 |
}; |
| 9203 |
this.getCommentFoldRange = function (row, column, dir) { |
| 9204 |
var iterator = new TokenIterator(this, row, column); |
| 9205 |
var token = iterator.getCurrentToken(); |
| 9206 |
var type = token && token.type; |
| 9207 |
if (token && /^comment|string/.test(type)) { |
| 9208 |
type = type.match(/comment|string/)[0]; |
| 9209 |
if (type == "comment") |
| 9210 |
type += "|doc-start|\\.doc"; |
| 9211 |
var re = new RegExp(type); |
| 9212 |
var range = new Range(); |
| 9213 |
if (dir != 1) { |
| 9214 |
do { |
| 9215 |
token = iterator.stepBackward(); |
| 9216 |
} while (token && re.test(token.type) && !/^comment.end/.test(token.type)); |
| 9217 |
token = iterator.stepForward(); |
| 9218 |
} |
| 9219 |
range.start.row = iterator.getCurrentTokenRow(); |
| 9220 |
range.start.column = iterator.getCurrentTokenColumn() + (/^comment.start/.test(token.type) ? token.value.length : 2); |
| 9221 |
iterator = new TokenIterator(this, row, column); |
| 9222 |
if (dir != -1) { |
| 9223 |
var lastRow = -1; |
| 9224 |
do { |
| 9225 |
token = iterator.stepForward(); |
| 9226 |
if (lastRow == -1) { |
| 9227 |
var state = this.getState(iterator.$row); |
| 9228 |
if (!re.test(state)) |
| 9229 |
lastRow = iterator.$row; |
| 9230 |
} |
| 9231 |
else if (iterator.$row > lastRow) { |
| 9232 |
break; |
| 9233 |
} |
| 9234 |
} while (token && re.test(token.type) && !/^comment.start/.test(token.type)); |
| 9235 |
token = iterator.stepBackward(); |
| 9236 |
} |
| 9237 |
else |
| 9238 |
token = iterator.getCurrentToken(); |
| 9239 |
range.end.row = iterator.getCurrentTokenRow(); |
| 9240 |
range.end.column = iterator.getCurrentTokenColumn(); |
| 9241 |
if (!/^comment.end/.test(token.type)) { |
| 9242 |
range.end.column += token.value.length - 2; |
| 9243 |
} |
| 9244 |
return range; |
| 9245 |
} |
| 9246 |
}; |
| 9247 |
this.foldAll = function (startRow, endRow, depth, test) { |
| 9248 |
if (depth == undefined) |
| 9249 |
depth = 100000; |
| 9250 |
var foldWidgets = this.foldWidgets; |
| 9251 |
if (!foldWidgets) |
| 9252 |
return; |
| 9253 |
endRow = endRow || this.getLength(); |
| 9254 |
startRow = startRow || 0; |
| 9255 |
for (var row = startRow; row < endRow; row++) { |
| 9256 |
if (foldWidgets[row] == null) |
| 9257 |
foldWidgets[row] = this.getFoldWidget(row); |
| 9258 |
if (foldWidgets[row] != "start") |
| 9259 |
continue; |
| 9260 |
if (test && !test(row)) |
| 9261 |
continue; |
| 9262 |
var range = this.getFoldWidgetRange(row); |
| 9263 |
if (range && range.isMultiLine() |
| 9264 |
&& range.end.row <= endRow |
| 9265 |
&& range.start.row >= startRow) { |
| 9266 |
row = range.end.row; |
| 9267 |
range.collapseChildren = depth; |
| 9268 |
this.addFold("...", range); |
| 9269 |
} |
| 9270 |
} |
| 9271 |
}; |
| 9272 |
this.foldToLevel = function (level) { |
| 9273 |
this.foldAll(); |
| 9274 |
while (level-- > 0) |
| 9275 |
this.unfold(null, false); |
| 9276 |
}; |
| 9277 |
this.foldAllComments = function () { |
| 9278 |
var session = this; |
| 9279 |
this.foldAll(null, null, null, function (row) { |
| 9280 |
var tokens = session.getTokens(row); |
| 9281 |
for (var i = 0; i < tokens.length; i++) { |
| 9282 |
var token = tokens[i]; |
| 9283 |
if (token.type == "text" && /^\s+$/.test(token.value)) |
| 9284 |
continue; |
| 9285 |
if (/comment/.test(token.type)) |
| 9286 |
return true; |
| 9287 |
return false; |
| 9288 |
} |
| 9289 |
}); |
| 9290 |
}; |
| 9291 |
this.$foldStyles = { |
| 9292 |
"manual": 1, |
| 9293 |
"markbegin": 1, |
| 9294 |
"markbeginend": 1 |
| 9295 |
}; |
| 9296 |
this.$foldStyle = "markbegin"; |
| 9297 |
this.setFoldStyle = function (style) { |
| 9298 |
if (!this.$foldStyles[style]) |
| 9299 |
throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]"); |
| 9300 |
if (this.$foldStyle == style) |
| 9301 |
return; |
| 9302 |
this.$foldStyle = style; |
| 9303 |
if (style == "manual") |
| 9304 |
this.unfold(); |
| 9305 |
var mode = this.$foldMode; |
| 9306 |
this.$setFolding(null); |
| 9307 |
this.$setFolding(mode); |
| 9308 |
}; |
| 9309 |
this.$setFolding = function (foldMode) { |
| 9310 |
if (this.$foldMode == foldMode) |
| 9311 |
return; |
| 9312 |
this.$foldMode = foldMode; |
| 9313 |
this.off('change', this.$updateFoldWidgets); |
| 9314 |
this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets); |
| 9315 |
this._signal("changeAnnotation"); |
| 9316 |
if (!foldMode || this.$foldStyle == "manual") { |
| 9317 |
this.foldWidgets = null; |
| 9318 |
return; |
| 9319 |
} |
| 9320 |
this.foldWidgets = []; |
| 9321 |
this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle); |
| 9322 |
this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle); |
| 9323 |
this.$updateFoldWidgets = this.updateFoldWidgets.bind(this); |
| 9324 |
this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind(this); |
| 9325 |
this.on('change', this.$updateFoldWidgets); |
| 9326 |
this.on('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets); |
| 9327 |
}; |
| 9328 |
this.getParentFoldRangeData = function (row, ignoreCurrent) { |
| 9329 |
var fw = this.foldWidgets; |
| 9330 |
if (!fw || (ignoreCurrent && fw[row])) |
| 9331 |
return {}; |
| 9332 |
var i = row - 1, firstRange; |
| 9333 |
while (i >= 0) { |
| 9334 |
var c = fw[i]; |
| 9335 |
if (c == null) |
| 9336 |
c = fw[i] = this.getFoldWidget(i); |
| 9337 |
if (c == "start") { |
| 9338 |
var range = this.getFoldWidgetRange(i); |
| 9339 |
if (!firstRange) |
| 9340 |
firstRange = range; |
| 9341 |
if (range && range.end.row >= row) |
| 9342 |
break; |
| 9343 |
} |
| 9344 |
i--; |
| 9345 |
} |
| 9346 |
return { |
| 9347 |
range: i !== -1 && range, |
| 9348 |
firstRange: firstRange |
| 9349 |
}; |
| 9350 |
}; |
| 9351 |
this.onFoldWidgetClick = function (row, e) { |
| 9352 |
if (e instanceof MouseEvent) |
| 9353 |
e = e.domEvent; |
| 9354 |
var options = { |
| 9355 |
children: e.shiftKey, |
| 9356 |
all: e.ctrlKey || e.metaKey, |
| 9357 |
siblings: e.altKey |
| 9358 |
}; |
| 9359 |
var range = this.$toggleFoldWidget(row, options); |
| 9360 |
if (!range) { |
| 9361 |
var el = (e.target || e.srcElement); |
| 9362 |
if (el && /ace_fold-widget/.test(el.className)) |
| 9363 |
el.className += " ace_invalid"; |
| 9364 |
} |
| 9365 |
}; |
| 9366 |
this.$toggleFoldWidget = function (row, options) { |
| 9367 |
if (!this.getFoldWidget) |
| 9368 |
return; |
| 9369 |
var type = this.getFoldWidget(row); |
| 9370 |
var line = this.getLine(row); |
| 9371 |
var dir = type === "end" ? -1 : 1; |
| 9372 |
var fold = this.getFoldAt(row, dir === -1 ? 0 : line.length, dir); |
| 9373 |
if (fold) { |
| 9374 |
if (options.children || options.all) |
| 9375 |
this.removeFold(fold); |
| 9376 |
else |
| 9377 |
this.expandFold(fold); |
| 9378 |
return fold; |
| 9379 |
} |
| 9380 |
var range = this.getFoldWidgetRange(row, true); |
| 9381 |
if (range && !range.isMultiLine()) { |
| 9382 |
fold = this.getFoldAt(range.start.row, range.start.column, 1); |
| 9383 |
if (fold && range.isEqual(fold.range)) { |
| 9384 |
this.removeFold(fold); |
| 9385 |
return fold; |
| 9386 |
} |
| 9387 |
} |
| 9388 |
if (options.siblings) { |
| 9389 |
var data = this.getParentFoldRangeData(row); |
| 9390 |
if (data.range) { |
| 9391 |
var startRow = data.range.start.row + 1; |
| 9392 |
var endRow = data.range.end.row; |
| 9393 |
} |
| 9394 |
this.foldAll(startRow, endRow, options.all ? 10000 : 0); |
| 9395 |
} |
| 9396 |
else if (options.children) { |
| 9397 |
endRow = range ? range.end.row : this.getLength(); |
| 9398 |
this.foldAll(row + 1, endRow, options.all ? 10000 : 0); |
| 9399 |
} |
| 9400 |
else if (range) { |
| 9401 |
if (options.all) |
| 9402 |
range.collapseChildren = 10000; |
| 9403 |
this.addFold("...", range); |
| 9404 |
} |
| 9405 |
return range; |
| 9406 |
}; |
| 9407 |
this.toggleFoldWidget = function (toggleParent) { |
| 9408 |
var row = this.selection.getCursor().row; |
| 9409 |
row = this.getRowFoldStart(row); |
| 9410 |
var range = this.$toggleFoldWidget(row, {}); |
| 9411 |
if (range) |
| 9412 |
return; |
| 9413 |
var data = this.getParentFoldRangeData(row, true); |
| 9414 |
range = data.range || data.firstRange; |
| 9415 |
if (range) { |
| 9416 |
row = range.start.row; |
| 9417 |
var fold = this.getFoldAt(row, this.getLine(row).length, 1); |
| 9418 |
if (fold) { |
| 9419 |
this.removeFold(fold); |
| 9420 |
} |
| 9421 |
else { |
| 9422 |
this.addFold("...", range); |
| 9423 |
} |
| 9424 |
} |
| 9425 |
}; |
| 9426 |
this.updateFoldWidgets = function (delta) { |
| 9427 |
var firstRow = delta.start.row; |
| 9428 |
var len = delta.end.row - firstRow; |
| 9429 |
if (len === 0) { |
| 9430 |
this.foldWidgets[firstRow] = null; |
| 9431 |
} |
| 9432 |
else if (delta.action == 'remove') { |
| 9433 |
this.foldWidgets.splice(firstRow, len + 1, null); |
| 9434 |
} |
| 9435 |
else { |
| 9436 |
var args = Array(len + 1); |
| 9437 |
args.unshift(firstRow, 1); |
| 9438 |
this.foldWidgets.splice.apply(this.foldWidgets, args); |
| 9439 |
} |
| 9440 |
}; |
| 9441 |
this.tokenizerUpdateFoldWidgets = function (e) { |
| 9442 |
var rows = e.data; |
| 9443 |
if (rows.first != rows.last) { |
| 9444 |
if (this.foldWidgets.length > rows.first) |
| 9445 |
this.foldWidgets.splice(rows.first, this.foldWidgets.length); |
| 9446 |
} |
| 9447 |
}; |
| 9448 |
} |
| 9449 |
exports.Folding = Folding; |
| 9450 |
|
| 9451 |
}); |
| 9452 |
|
| 9453 |
ace.define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"], function(require, exports, module){"use strict"; |
| 9454 |
var TokenIterator = require("../token_iterator").TokenIterator; |
| 9455 |
var Range = require("../range").Range; |
| 9456 |
function BracketMatch() { |
| 9457 |
this.findMatchingBracket = function (position, chr) { |
| 9458 |
if (position.column == 0) |
| 9459 |
return null; |
| 9460 |
var charBeforeCursor = chr || this.getLine(position.row).charAt(position.column - 1); |
| 9461 |
if (charBeforeCursor == "") |
| 9462 |
return null; |
| 9463 |
var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/); |
| 9464 |
if (!match) |
| 9465 |
return null; |
| 9466 |
if (match[1]) |
| 9467 |
return this.$findClosingBracket(match[1], position); |
| 9468 |
else |
| 9469 |
return this.$findOpeningBracket(match[2], position); |
| 9470 |
}; |
| 9471 |
this.getBracketRange = function (pos) { |
| 9472 |
var line = this.getLine(pos.row); |
| 9473 |
var before = true, range; |
| 9474 |
var chr = line.charAt(pos.column - 1); |
| 9475 |
var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/); |
| 9476 |
if (!match) { |
| 9477 |
chr = line.charAt(pos.column); |
| 9478 |
pos = { row: pos.row, column: pos.column + 1 }; |
| 9479 |
match = chr && chr.match(/([\(\[\{])|([\)\]\}])/); |
| 9480 |
before = false; |
| 9481 |
} |
| 9482 |
if (!match) |
| 9483 |
return null; |
| 9484 |
if (match[1]) { |
| 9485 |
var bracketPos = this.$findClosingBracket(match[1], pos); |
| 9486 |
if (!bracketPos) |
| 9487 |
return null; |
| 9488 |
range = Range.fromPoints(pos, bracketPos); |
| 9489 |
if (!before) { |
| 9490 |
range.end.column++; |
| 9491 |
range.start.column--; |
| 9492 |
} |
| 9493 |
range.cursor = range.end; |
| 9494 |
} |
| 9495 |
else { |
| 9496 |
var bracketPos = this.$findOpeningBracket(match[2], pos); |
| 9497 |
if (!bracketPos) |
| 9498 |
return null; |
| 9499 |
range = Range.fromPoints(bracketPos, pos); |
| 9500 |
if (!before) { |
| 9501 |
range.start.column++; |
| 9502 |
range.end.column--; |
| 9503 |
} |
| 9504 |
range.cursor = range.start; |
| 9505 |
} |
| 9506 |
return range; |
| 9507 |
}; |
| 9508 |
this.getMatchingBracketRanges = function (pos, isBackwards) { |
| 9509 |
var line = this.getLine(pos.row); |
| 9510 |
var bracketsRegExp = /([\(\[\{])|([\)\]\}])/; |
| 9511 |
var chr = !isBackwards && line.charAt(pos.column - 1); |
| 9512 |
var match = chr && chr.match(bracketsRegExp); |
| 9513 |
if (!match) { |
| 9514 |
chr = (isBackwards === undefined || isBackwards) && line.charAt(pos.column); |
| 9515 |
pos = { |
| 9516 |
row: pos.row, |
| 9517 |
column: pos.column + 1 |
| 9518 |
}; |
| 9519 |
match = chr && chr.match(bracketsRegExp); |
| 9520 |
} |
| 9521 |
if (!match) |
| 9522 |
return null; |
| 9523 |
var startRange = new Range(pos.row, pos.column - 1, pos.row, pos.column); |
| 9524 |
var bracketPos = match[1] ? this.$findClosingBracket(match[1], pos) |
| 9525 |
: this.$findOpeningBracket(match[2], pos); |
| 9526 |
if (!bracketPos) |
| 9527 |
return [startRange]; |
| 9528 |
var endRange = new Range(bracketPos.row, bracketPos.column, bracketPos.row, bracketPos.column + 1); |
| 9529 |
return [startRange, endRange]; |
| 9530 |
}; |
| 9531 |
this.$brackets = { |
| 9532 |
")": "(", |
| 9533 |
"(": ")", |
| 9534 |
"]": "[", |
| 9535 |
"[": "]", |
| 9536 |
"{": "}", |
| 9537 |
"}": "{", |
| 9538 |
"<": ">", |
| 9539 |
">": "<" |
| 9540 |
}; |
| 9541 |
this.$findOpeningBracket = function (bracket, position, typeRe) { |
| 9542 |
var openBracket = this.$brackets[bracket]; |
| 9543 |
var depth = 1; |
| 9544 |
var iterator = new TokenIterator(this, position.row, position.column); |
| 9545 |
var token = iterator.getCurrentToken(); |
| 9546 |
if (!token) |
| 9547 |
token = iterator.stepForward(); |
| 9548 |
if (!token) |
| 9549 |
return; |
| 9550 |
if (!typeRe) { |
| 9551 |
typeRe = new RegExp("(\\.?" + |
| 9552 |
token.type.replace(".", "\\.").replace("rparen", ".paren") |
| 9553 |
.replace(/\b(?:end)\b/, "(?:start|begin|end)") |
| 9554 |
.replace(/-close\b/, "-(close|open)") |
| 9555 |
+ ")+"); |
| 9556 |
} |
| 9557 |
var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2; |
| 9558 |
var value = token.value; |
| 9559 |
while (true) { |
| 9560 |
while (valueIndex >= 0) { |
| 9561 |
var chr = value.charAt(valueIndex); |
| 9562 |
if (chr == openBracket) { |
| 9563 |
depth -= 1; |
| 9564 |
if (depth == 0) { |
| 9565 |
return { row: iterator.getCurrentTokenRow(), |
| 9566 |
column: valueIndex + iterator.getCurrentTokenColumn() }; |
| 9567 |
} |
| 9568 |
} |
| 9569 |
else if (chr == bracket) { |
| 9570 |
depth += 1; |
| 9571 |
} |
| 9572 |
valueIndex -= 1; |
| 9573 |
} |
| 9574 |
do { |
| 9575 |
token = iterator.stepBackward(); |
| 9576 |
} while (token && !typeRe.test(token.type)); |
| 9577 |
if (token == null) |
| 9578 |
break; |
| 9579 |
value = token.value; |
| 9580 |
valueIndex = value.length - 1; |
| 9581 |
} |
| 9582 |
return null; |
| 9583 |
}; |
| 9584 |
this.$findClosingBracket = function (bracket, position, typeRe) { |
| 9585 |
var closingBracket = this.$brackets[bracket]; |
| 9586 |
var depth = 1; |
| 9587 |
var iterator = new TokenIterator(this, position.row, position.column); |
| 9588 |
var token = iterator.getCurrentToken(); |
| 9589 |
if (!token) |
| 9590 |
token = iterator.stepForward(); |
| 9591 |
if (!token) |
| 9592 |
return; |
| 9593 |
if (!typeRe) { |
| 9594 |
typeRe = new RegExp("(\\.?" + |
| 9595 |
token.type.replace(".", "\\.").replace("lparen", ".paren") |
| 9596 |
.replace(/\b(?:start|begin)\b/, "(?:start|begin|end)") |
| 9597 |
.replace(/-open\b/, "-(close|open)") |
| 9598 |
+ ")+"); |
| 9599 |
} |
| 9600 |
var valueIndex = position.column - iterator.getCurrentTokenColumn(); |
| 9601 |
while (true) { |
| 9602 |
var value = token.value; |
| 9603 |
var valueLength = value.length; |
| 9604 |
while (valueIndex < valueLength) { |
| 9605 |
var chr = value.charAt(valueIndex); |
| 9606 |
if (chr == closingBracket) { |
| 9607 |
depth -= 1; |
| 9608 |
if (depth == 0) { |
| 9609 |
return { row: iterator.getCurrentTokenRow(), |
| 9610 |
column: valueIndex + iterator.getCurrentTokenColumn() }; |
| 9611 |
} |
| 9612 |
} |
| 9613 |
else if (chr == bracket) { |
| 9614 |
depth += 1; |
| 9615 |
} |
| 9616 |
valueIndex += 1; |
| 9617 |
} |
| 9618 |
do { |
| 9619 |
token = iterator.stepForward(); |
| 9620 |
} while (token && !typeRe.test(token.type)); |
| 9621 |
if (token == null) |
| 9622 |
break; |
| 9623 |
valueIndex = 0; |
| 9624 |
} |
| 9625 |
return null; |
| 9626 |
}; |
| 9627 |
this.getMatchingTags = function (pos) { |
| 9628 |
var iterator = new TokenIterator(this, pos.row, pos.column); |
| 9629 |
var token = this.$findTagName(iterator); |
| 9630 |
if (!token) |
| 9631 |
return; |
| 9632 |
var prevToken = iterator.stepBackward(); |
| 9633 |
if (prevToken.value === '<') { |
| 9634 |
return this.$findClosingTag(iterator, token); |
| 9635 |
} |
| 9636 |
else { |
| 9637 |
return this.$findOpeningTag(iterator, token); |
| 9638 |
} |
| 9639 |
}; |
| 9640 |
this.$findTagName = function (iterator) { |
| 9641 |
var token = iterator.getCurrentToken(); |
| 9642 |
var found = false; |
| 9643 |
var backward = false; |
| 9644 |
if (token && token.type.indexOf('tag-name') === -1) { |
| 9645 |
do { |
| 9646 |
if (backward) |
| 9647 |
token = iterator.stepBackward(); |
| 9648 |
else |
| 9649 |
token = iterator.stepForward(); |
| 9650 |
if (token) { |
| 9651 |
if (token.value === "/>") { |
| 9652 |
backward = true; |
| 9653 |
} |
| 9654 |
else if (token.type.indexOf('tag-name') !== -1) { |
| 9655 |
found = true; |
| 9656 |
} |
| 9657 |
} |
| 9658 |
} while (token && !found); |
| 9659 |
} |
| 9660 |
return token; |
| 9661 |
}; |
| 9662 |
this.$findClosingTag = function (iterator, token) { |
| 9663 |
var prevToken; |
| 9664 |
var currentTag = token.value; |
| 9665 |
var tag = token.value; |
| 9666 |
var depth = 0; |
| 9667 |
var openTagStart = new Range(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn(), iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1); |
| 9668 |
token = iterator.stepForward(); |
| 9669 |
var openTagName = new Range(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn(), iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + token.value.length); |
| 9670 |
var foundOpenTagEnd = false; |
| 9671 |
do { |
| 9672 |
prevToken = token; |
| 9673 |
token = iterator.stepForward(); |
| 9674 |
if (token) { |
| 9675 |
if (token.value === '>' && !foundOpenTagEnd) { |
| 9676 |
var openTagEnd = new Range(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn(), iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1); |
| 9677 |
foundOpenTagEnd = true; |
| 9678 |
} |
| 9679 |
if (token.type.indexOf('tag-name') !== -1) { |
| 9680 |
currentTag = token.value; |
| 9681 |
if (tag === currentTag) { |
| 9682 |
if (prevToken.value === '<') { |
| 9683 |
depth++; |
| 9684 |
} |
| 9685 |
else if (prevToken.value === '</') { |
| 9686 |
depth--; |
| 9687 |
if (depth < 0) { |
| 9688 |
iterator.stepBackward(); |
| 9689 |
var closeTagStart = new Range(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn(), iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 2); |
| 9690 |
token = iterator.stepForward(); |
| 9691 |
var closeTagName = new Range(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn(), iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + token.value.length); |
| 9692 |
token = iterator.stepForward(); |
| 9693 |
if (token && token.value === '>') { |
| 9694 |
var closeTagEnd = new Range(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn(), iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1); |
| 9695 |
} |
| 9696 |
else { |
| 9697 |
return; |
| 9698 |
} |
| 9699 |
} |
| 9700 |
} |
| 9701 |
} |
| 9702 |
} |
| 9703 |
else if (tag === currentTag && token.value === '/>') { |
| 9704 |
depth--; |
| 9705 |
if (depth < 0) { |
| 9706 |
var closeTagStart = new Range(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn(), iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 2); |
| 9707 |
var closeTagName = closeTagStart; |
| 9708 |
var closeTagEnd = closeTagName; |
| 9709 |
var openTagEnd = new Range(openTagName.end.row, openTagName.end.column, openTagName.end.row, openTagName.end.column + 1); |
| 9710 |
} |
| 9711 |
} |
| 9712 |
} |
| 9713 |
} while (token && depth >= 0); |
| 9714 |
if (openTagStart && openTagEnd && closeTagStart && closeTagEnd && openTagName && closeTagName) { |
| 9715 |
return { |
| 9716 |
openTag: new Range(openTagStart.start.row, openTagStart.start.column, openTagEnd.end.row, openTagEnd.end.column), |
| 9717 |
closeTag: new Range(closeTagStart.start.row, closeTagStart.start.column, closeTagEnd.end.row, closeTagEnd.end.column), |
| 9718 |
openTagName: openTagName, |
| 9719 |
closeTagName: closeTagName |
| 9720 |
}; |
| 9721 |
} |
| 9722 |
}; |
| 9723 |
this.$findOpeningTag = function (iterator, token) { |
| 9724 |
var prevToken = iterator.getCurrentToken(); |
| 9725 |
var tag = token.value; |
| 9726 |
var depth = 0; |
| 9727 |
var startRow = iterator.getCurrentTokenRow(); |
| 9728 |
var startColumn = iterator.getCurrentTokenColumn(); |
| 9729 |
var endColumn = startColumn + 2; |
| 9730 |
var closeTagStart = new Range(startRow, startColumn, startRow, endColumn); |
| 9731 |
iterator.stepForward(); |
| 9732 |
var closeTagName = new Range(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn(), iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + token.value.length); |
| 9733 |
token = iterator.stepForward(); |
| 9734 |
if (!token || token.value !== ">") |
| 9735 |
return; |
| 9736 |
var closeTagEnd = new Range(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn(), iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1); |
| 9737 |
iterator.stepBackward(); |
| 9738 |
iterator.stepBackward(); |
| 9739 |
do { |
| 9740 |
token = prevToken; |
| 9741 |
startRow = iterator.getCurrentTokenRow(); |
| 9742 |
startColumn = iterator.getCurrentTokenColumn(); |
| 9743 |
endColumn = startColumn + token.value.length; |
| 9744 |
prevToken = iterator.stepBackward(); |
| 9745 |
if (token) { |
| 9746 |
if (token.type.indexOf('tag-name') !== -1) { |
| 9747 |
if (tag === token.value) { |
| 9748 |
if (prevToken.value === '<') { |
| 9749 |
depth++; |
| 9750 |
if (depth > 0) { |
| 9751 |
var openTagName = new Range(startRow, startColumn, startRow, endColumn); |
| 9752 |
var openTagStart = new Range(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn(), iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1); |
| 9753 |
do { |
| 9754 |
token = iterator.stepForward(); |
| 9755 |
} while (token && token.value !== '>'); |
| 9756 |
var openTagEnd = new Range(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn(), iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1); |
| 9757 |
} |
| 9758 |
} |
| 9759 |
else if (prevToken.value === '</') { |
| 9760 |
depth--; |
| 9761 |
} |
| 9762 |
} |
| 9763 |
} |
| 9764 |
else if (token.value === '/>') { |
| 9765 |
var stepCount = 0; |
| 9766 |
var tmpToken = prevToken; |
| 9767 |
while (tmpToken) { |
| 9768 |
if (tmpToken.type.indexOf('tag-name') !== -1 && tmpToken.value === tag) { |
| 9769 |
depth--; |
| 9770 |
break; |
| 9771 |
} |
| 9772 |
else if (tmpToken.value === '<') { |
| 9773 |
break; |
| 9774 |
} |
| 9775 |
tmpToken = iterator.stepBackward(); |
| 9776 |
stepCount++; |
| 9777 |
} |
| 9778 |
for (var i = 0; i < stepCount; i++) { |
| 9779 |
iterator.stepForward(); |
| 9780 |
} |
| 9781 |
} |
| 9782 |
} |
| 9783 |
} while (prevToken && depth <= 0); |
| 9784 |
if (openTagStart && openTagEnd && closeTagStart && closeTagEnd && openTagName && closeTagName) { |
| 9785 |
return { |
| 9786 |
openTag: new Range(openTagStart.start.row, openTagStart.start.column, openTagEnd.end.row, openTagEnd.end.column), |
| 9787 |
closeTag: new Range(closeTagStart.start.row, closeTagStart.start.column, closeTagEnd.end.row, closeTagEnd.end.column), |
| 9788 |
openTagName: openTagName, |
| 9789 |
closeTagName: closeTagName |
| 9790 |
}; |
| 9791 |
} |
| 9792 |
}; |
| 9793 |
} |
| 9794 |
exports.BracketMatch = BracketMatch; |
| 9795 |
|
| 9796 |
}); |
| 9797 |
|
| 9798 |
ace.define("ace/edit_session",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/bidihandler","ace/config","ace/lib/event_emitter","ace/selection","ace/mode/text","ace/range","ace/document","ace/background_tokenizer","ace/search_highlight","ace/undomanager","ace/edit_session/folding","ace/edit_session/bracket_match"], function(require, exports, module){"use strict"; |
| 9799 |
var oop = require("./lib/oop"); |
| 9800 |
var lang = require("./lib/lang"); |
| 9801 |
var BidiHandler = require("./bidihandler").BidiHandler; |
| 9802 |
var config = require("./config"); |
| 9803 |
var EventEmitter = require("./lib/event_emitter").EventEmitter; |
| 9804 |
var Selection = require("./selection").Selection; |
| 9805 |
var TextMode = require("./mode/text").Mode; |
| 9806 |
var Range = require("./range").Range; |
| 9807 |
var Document = require("./document").Document; |
| 9808 |
var BackgroundTokenizer = require("./background_tokenizer").BackgroundTokenizer; |
| 9809 |
var SearchHighlight = require("./search_highlight").SearchHighlight; |
| 9810 |
var UndoManager = require("./undomanager").UndoManager; |
| 9811 |
var EditSession = (function () { |
| 9812 |
function EditSession(text, mode) { this.doc; |
| 9813 |
this.$breakpoints = []; |
| 9814 |
this.$decorations = []; |
| 9815 |
this.$frontMarkers = {}; |
| 9816 |
this.$backMarkers = {}; |
| 9817 |
this.$markerId = 1; |
| 9818 |
this.$undoSelect = true; |
| 9819 |
this.$foldData = []; |
| 9820 |
this.id = "session" + (++EditSession.$uid); |
| 9821 |
this.$foldData.toString = function () { |
| 9822 |
return this.join("\n"); |
| 9823 |
}; |
| 9824 |
this.bgTokenizer = new BackgroundTokenizer((new TextMode()).getTokenizer(), this); |
| 9825 |
var _self = this; |
| 9826 |
this.bgTokenizer.on("update", function (e) { |
| 9827 |
_self._signal("tokenizerUpdate", e); |
| 9828 |
}); |
| 9829 |
this.on("changeFold", this.onChangeFold.bind(this)); |
| 9830 |
this.$onChange = this.onChange.bind(this); |
| 9831 |
if (typeof text != "object" || !text.getLine) |
| 9832 |
text = new Document( (text)); |
| 9833 |
this.setDocument(text); |
| 9834 |
this.selection = new Selection(this); |
| 9835 |
this.$bidiHandler = new BidiHandler(this); |
| 9836 |
config.resetOptions(this); |
| 9837 |
this.setMode(mode); |
| 9838 |
config._signal("session", this); |
| 9839 |
this.destroyed = false; |
| 9840 |
} |
| 9841 |
EditSession.prototype.setDocument = function (doc) { |
| 9842 |
if (this.doc) |
| 9843 |
this.doc.off("change", this.$onChange); |
| 9844 |
this.doc = doc; |
| 9845 |
doc.on("change", this.$onChange, true); |
| 9846 |
this.bgTokenizer.setDocument(this.getDocument()); |
| 9847 |
this.resetCaches(); |
| 9848 |
}; |
| 9849 |
EditSession.prototype.getDocument = function () { |
| 9850 |
return this.doc; |
| 9851 |
}; |
| 9852 |
EditSession.prototype.$resetRowCache = function (docRow) { |
| 9853 |
if (!docRow) { |
| 9854 |
this.$docRowCache = []; |
| 9855 |
this.$screenRowCache = []; |
| 9856 |
return; |
| 9857 |
} |
| 9858 |
var l = this.$docRowCache.length; |
| 9859 |
var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1; |
| 9860 |
if (l > i) { |
| 9861 |
this.$docRowCache.splice(i, l); |
| 9862 |
this.$screenRowCache.splice(i, l); |
| 9863 |
} |
| 9864 |
}; |
| 9865 |
EditSession.prototype.$getRowCacheIndex = function (cacheArray, val) { |
| 9866 |
var low = 0; |
| 9867 |
var hi = cacheArray.length - 1; |
| 9868 |
while (low <= hi) { |
| 9869 |
var mid = (low + hi) >> 1; |
| 9870 |
var c = cacheArray[mid]; |
| 9871 |
if (val > c) |
| 9872 |
low = mid + 1; |
| 9873 |
else if (val < c) |
| 9874 |
hi = mid - 1; |
| 9875 |
else |
| 9876 |
return mid; |
| 9877 |
} |
| 9878 |
return low - 1; |
| 9879 |
}; |
| 9880 |
EditSession.prototype.resetCaches = function () { |
| 9881 |
this.$modified = true; |
| 9882 |
this.$wrapData = []; |
| 9883 |
this.$rowLengthCache = []; |
| 9884 |
this.$resetRowCache(0); |
| 9885 |
if (!this.destroyed) |
| 9886 |
this.bgTokenizer.start(0); |
| 9887 |
}; |
| 9888 |
EditSession.prototype.onChangeFold = function (e) { |
| 9889 |
var fold = e.data; |
| 9890 |
this.$resetRowCache(fold.start.row); |
| 9891 |
}; |
| 9892 |
EditSession.prototype.onChange = function (delta) { |
| 9893 |
this.$modified = true; |
| 9894 |
this.$bidiHandler.onChange(delta); |
| 9895 |
this.$resetRowCache(delta.start.row); |
| 9896 |
var removedFolds = this.$updateInternalDataOnChange(delta); |
| 9897 |
if (!this.$fromUndo && this.$undoManager) { |
| 9898 |
if (removedFolds && removedFolds.length) { |
| 9899 |
this.$undoManager.add({ |
| 9900 |
action: "removeFolds", |
| 9901 |
folds: removedFolds |
| 9902 |
}, this.mergeUndoDeltas); |
| 9903 |
this.mergeUndoDeltas = true; |
| 9904 |
} |
| 9905 |
this.$undoManager.add(delta, this.mergeUndoDeltas); |
| 9906 |
this.mergeUndoDeltas = true; |
| 9907 |
this.$informUndoManager.schedule(); |
| 9908 |
} |
| 9909 |
this.bgTokenizer.$updateOnChange(delta); |
| 9910 |
this._signal("change", delta); |
| 9911 |
}; |
| 9912 |
EditSession.prototype.setValue = function (text) { |
| 9913 |
this.doc.setValue(text); |
| 9914 |
this.selection.moveTo(0, 0); |
| 9915 |
this.$resetRowCache(0); |
| 9916 |
this.setUndoManager(this.$undoManager); |
| 9917 |
this.getUndoManager().reset(); |
| 9918 |
}; |
| 9919 |
EditSession.fromJSON = function (session) { |
| 9920 |
if (typeof session == "string") |
| 9921 |
session = JSON.parse(session); |
| 9922 |
var undoManager = new UndoManager(); |
| 9923 |
undoManager.$undoStack = session.history.undo; |
| 9924 |
undoManager.$redoStack = session.history.redo; |
| 9925 |
undoManager.mark = session.history.mark; |
| 9926 |
undoManager.$rev = session.history.rev; |
| 9927 |
var editSession = new EditSession(session.value); |
| 9928 |
session.folds.forEach(function (fold) { |
| 9929 |
editSession.addFold("...", Range.fromPoints(fold.start, fold.end)); |
| 9930 |
}); |
| 9931 |
editSession.setAnnotations(session.annotations); |
| 9932 |
editSession.setBreakpoints(session.breakpoints); |
| 9933 |
editSession.setMode(session.mode); |
| 9934 |
editSession.setScrollLeft(session.scrollLeft); |
| 9935 |
editSession.setScrollTop(session.scrollTop); |
| 9936 |
editSession.setUndoManager(undoManager); |
| 9937 |
editSession.selection.fromJSON(session.selection); |
| 9938 |
return editSession; |
| 9939 |
}; |
| 9940 |
EditSession.prototype.toJSON = function () { |
| 9941 |
return { |
| 9942 |
annotations: this.$annotations, |
| 9943 |
breakpoints: this.$breakpoints, |
| 9944 |
folds: this.getAllFolds().map(function (fold) { |
| 9945 |
return fold.range; |
| 9946 |
}), |
| 9947 |
history: this.getUndoManager(), |
| 9948 |
mode: this.$mode.$id, |
| 9949 |
scrollLeft: this.$scrollLeft, |
| 9950 |
scrollTop: this.$scrollTop, |
| 9951 |
selection: this.selection.toJSON(), |
| 9952 |
value: this.doc.getValue() |
| 9953 |
}; |
| 9954 |
}; |
| 9955 |
EditSession.prototype.toString = function () { |
| 9956 |
return this.doc.getValue(); |
| 9957 |
}; |
| 9958 |
EditSession.prototype.getSelection = function () { |
| 9959 |
return this.selection; |
| 9960 |
}; |
| 9961 |
EditSession.prototype.getState = function (row) { |
| 9962 |
return this.bgTokenizer.getState(row); |
| 9963 |
}; |
| 9964 |
EditSession.prototype.getTokens = function (row) { |
| 9965 |
return this.bgTokenizer.getTokens(row); |
| 9966 |
}; |
| 9967 |
EditSession.prototype.getTokenAt = function (row, column) { |
| 9968 |
var tokens = this.bgTokenizer.getTokens(row); |
| 9969 |
var token, c = 0; |
| 9970 |
if (column == null) { |
| 9971 |
var i = tokens.length - 1; |
| 9972 |
c = this.getLine(row).length; |
| 9973 |
} |
| 9974 |
else { |
| 9975 |
for (var i = 0; i < tokens.length; i++) { |
| 9976 |
c += tokens[i].value.length; |
| 9977 |
if (c >= column) |
| 9978 |
break; |
| 9979 |
} |
| 9980 |
} |
| 9981 |
token = tokens[i]; |
| 9982 |
if (!token) |
| 9983 |
return null; |
| 9984 |
token.index = i; |
| 9985 |
token.start = c - token.value.length; |
| 9986 |
return token; |
| 9987 |
}; |
| 9988 |
EditSession.prototype.setUndoManager = function (undoManager) { |
| 9989 |
this.$undoManager = undoManager; |
| 9990 |
if (this.$informUndoManager) |
| 9991 |
this.$informUndoManager.cancel(); |
| 9992 |
if (undoManager) { |
| 9993 |
var self = this; |
| 9994 |
undoManager.addSession(this); |
| 9995 |
this.$syncInformUndoManager = function () { |
| 9996 |
self.$informUndoManager.cancel(); |
| 9997 |
self.mergeUndoDeltas = false; |
| 9998 |
}; |
| 9999 |
this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager); |
| 10000 |
} |
| 10001 |
else { |
| 10002 |
this.$syncInformUndoManager = function () { }; |
| 10003 |
} |
| 10004 |
}; |
| 10005 |
EditSession.prototype.markUndoGroup = function () { |
| 10006 |
if (this.$syncInformUndoManager) |
| 10007 |
this.$syncInformUndoManager(); |
| 10008 |
}; |
| 10009 |
EditSession.prototype.getUndoManager = function () { |
| 10010 |
return this.$undoManager || this.$defaultUndoManager; |
| 10011 |
}; |
| 10012 |
EditSession.prototype.getTabString = function () { |
| 10013 |
if (this.getUseSoftTabs()) { |
| 10014 |
return lang.stringRepeat(" ", this.getTabSize()); |
| 10015 |
} |
| 10016 |
else { |
| 10017 |
return "\t"; |
| 10018 |
} |
| 10019 |
}; |
| 10020 |
EditSession.prototype.setUseSoftTabs = function (val) { |
| 10021 |
this.setOption("useSoftTabs", val); |
| 10022 |
}; |
| 10023 |
EditSession.prototype.getUseSoftTabs = function () { |
| 10024 |
return this.$useSoftTabs && !this.$mode.$indentWithTabs; |
| 10025 |
}; |
| 10026 |
EditSession.prototype.setTabSize = function (tabSize) { |
| 10027 |
this.setOption("tabSize", tabSize); |
| 10028 |
}; |
| 10029 |
EditSession.prototype.getTabSize = function () { |
| 10030 |
return this.$tabSize; |
| 10031 |
}; |
| 10032 |
EditSession.prototype.isTabStop = function (position) { |
| 10033 |
return this.$useSoftTabs && (position.column % this.$tabSize === 0); |
| 10034 |
}; |
| 10035 |
EditSession.prototype.setNavigateWithinSoftTabs = function (navigateWithinSoftTabs) { |
| 10036 |
this.setOption("navigateWithinSoftTabs", navigateWithinSoftTabs); |
| 10037 |
}; |
| 10038 |
EditSession.prototype.getNavigateWithinSoftTabs = function () { |
| 10039 |
return this.$navigateWithinSoftTabs; |
| 10040 |
}; |
| 10041 |
EditSession.prototype.setOverwrite = function (overwrite) { |
| 10042 |
this.setOption("overwrite", overwrite); |
| 10043 |
}; |
| 10044 |
EditSession.prototype.getOverwrite = function () { |
| 10045 |
return this.$overwrite; |
| 10046 |
}; |
| 10047 |
EditSession.prototype.toggleOverwrite = function () { |
| 10048 |
this.setOverwrite(!this.$overwrite); |
| 10049 |
}; |
| 10050 |
EditSession.prototype.addGutterDecoration = function (row, className) { |
| 10051 |
if (!this.$decorations[row]) |
| 10052 |
this.$decorations[row] = ""; |
| 10053 |
this.$decorations[row] += " " + className; |
| 10054 |
this._signal("changeBreakpoint", {}); |
| 10055 |
}; |
| 10056 |
EditSession.prototype.removeGutterDecoration = function (row, className) { |
| 10057 |
this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, ""); |
| 10058 |
this._signal("changeBreakpoint", {}); |
| 10059 |
}; |
| 10060 |
EditSession.prototype.getBreakpoints = function () { |
| 10061 |
return this.$breakpoints; |
| 10062 |
}; |
| 10063 |
EditSession.prototype.setBreakpoints = function (rows) { |
| 10064 |
this.$breakpoints = []; |
| 10065 |
for (var i = 0; i < rows.length; i++) { |
| 10066 |
this.$breakpoints[rows[i]] = "ace_breakpoint"; |
| 10067 |
} |
| 10068 |
this._signal("changeBreakpoint", {}); |
| 10069 |
}; |
| 10070 |
EditSession.prototype.clearBreakpoints = function () { |
| 10071 |
this.$breakpoints = []; |
| 10072 |
this._signal("changeBreakpoint", {}); |
| 10073 |
}; |
| 10074 |
EditSession.prototype.setBreakpoint = function (row, className) { |
| 10075 |
if (className === undefined) |
| 10076 |
className = "ace_breakpoint"; |
| 10077 |
if (className) |
| 10078 |
this.$breakpoints[row] = className; |
| 10079 |
else |
| 10080 |
delete this.$breakpoints[row]; |
| 10081 |
this._signal("changeBreakpoint", {}); |
| 10082 |
}; |
| 10083 |
EditSession.prototype.clearBreakpoint = function (row) { |
| 10084 |
delete this.$breakpoints[row]; |
| 10085 |
this._signal("changeBreakpoint", {}); |
| 10086 |
}; |
| 10087 |
EditSession.prototype.addMarker = function (range, clazz, type, inFront) { |
| 10088 |
var id = this.$markerId++; |
| 10089 |
var marker = { |
| 10090 |
range: range, |
| 10091 |
type: type || "line", |
| 10092 |
renderer: typeof type == "function" ? type : null, |
| 10093 |
clazz: clazz, |
| 10094 |
inFront: !!inFront, |
| 10095 |
id: id |
| 10096 |
}; |
| 10097 |
if (inFront) { |
| 10098 |
this.$frontMarkers[id] = marker; |
| 10099 |
this._signal("changeFrontMarker"); |
| 10100 |
} |
| 10101 |
else { |
| 10102 |
this.$backMarkers[id] = marker; |
| 10103 |
this._signal("changeBackMarker"); |
| 10104 |
} |
| 10105 |
return id; |
| 10106 |
}; |
| 10107 |
EditSession.prototype.addDynamicMarker = function (marker, inFront) { |
| 10108 |
if (!marker.update) |
| 10109 |
return; |
| 10110 |
var id = this.$markerId++; |
| 10111 |
marker.id = id; |
| 10112 |
marker.inFront = !!inFront; |
| 10113 |
if (inFront) { |
| 10114 |
this.$frontMarkers[id] = marker; |
| 10115 |
this._signal("changeFrontMarker"); |
| 10116 |
} |
| 10117 |
else { |
| 10118 |
this.$backMarkers[id] = marker; |
| 10119 |
this._signal("changeBackMarker"); |
| 10120 |
} |
| 10121 |
return marker; |
| 10122 |
}; |
| 10123 |
EditSession.prototype.removeMarker = function (markerId) { |
| 10124 |
var marker = this.$frontMarkers[markerId] || this.$backMarkers[markerId]; |
| 10125 |
if (!marker) |
| 10126 |
return; |
| 10127 |
var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers; |
| 10128 |
delete (markers[markerId]); |
| 10129 |
this._signal(marker.inFront ? "changeFrontMarker" : "changeBackMarker"); |
| 10130 |
}; |
| 10131 |
EditSession.prototype.getMarkers = function (inFront) { |
| 10132 |
return inFront ? this.$frontMarkers : this.$backMarkers; |
| 10133 |
}; |
| 10134 |
EditSession.prototype.highlight = function (re) { |
| 10135 |
if (!this.$searchHighlight) { |
| 10136 |
var highlight = new SearchHighlight(null, "ace_selected-word", "text"); |
| 10137 |
this.$searchHighlight = this.addDynamicMarker(highlight); |
| 10138 |
} |
| 10139 |
this.$searchHighlight.setRegexp(re); |
| 10140 |
}; |
| 10141 |
EditSession.prototype.highlightLines = function (startRow, endRow, clazz, inFront) { |
| 10142 |
if (typeof endRow != "number") { |
| 10143 |
clazz = endRow; |
| 10144 |
endRow = startRow; |
| 10145 |
} |
| 10146 |
if (!clazz) |
| 10147 |
clazz = "ace_step"; |
| 10148 |
var range = new Range(startRow, 0, endRow, Infinity); |
| 10149 |
range.id = this.addMarker(range, clazz, "fullLine", inFront); |
| 10150 |
return range; |
| 10151 |
}; |
| 10152 |
EditSession.prototype.setAnnotations = function (annotations) { |
| 10153 |
this.$annotations = annotations; |
| 10154 |
this._signal("changeAnnotation", {}); |
| 10155 |
}; |
| 10156 |
EditSession.prototype.getAnnotations = function () { |
| 10157 |
return this.$annotations || []; |
| 10158 |
}; |
| 10159 |
EditSession.prototype.clearAnnotations = function () { |
| 10160 |
this.setAnnotations([]); |
| 10161 |
}; |
| 10162 |
EditSession.prototype.$detectNewLine = function (text) { |
| 10163 |
var match = text.match(/^.*?(\r?\n)/m); |
| 10164 |
if (match) { |
| 10165 |
this.$autoNewLine = match[1]; |
| 10166 |
} |
| 10167 |
else { |
| 10168 |
this.$autoNewLine = "\n"; |
| 10169 |
} |
| 10170 |
}; |
| 10171 |
EditSession.prototype.getWordRange = function (row, column) { |
| 10172 |
var line = this.getLine(row); |
| 10173 |
var inToken = false; |
| 10174 |
if (column > 0) |
| 10175 |
inToken = !!line.charAt(column - 1).match(this.tokenRe); |
| 10176 |
if (!inToken) |
| 10177 |
inToken = !!line.charAt(column).match(this.tokenRe); |
| 10178 |
if (inToken) |
| 10179 |
var re = this.tokenRe; |
| 10180 |
else if (/^\s+$/.test(line.slice(column - 1, column + 1))) |
| 10181 |
var re = /\s/; |
| 10182 |
else |
| 10183 |
var re = this.nonTokenRe; |
| 10184 |
var start = column; |
| 10185 |
if (start > 0) { |
| 10186 |
do { |
| 10187 |
start--; |
| 10188 |
} while (start >= 0 && line.charAt(start).match(re)); |
| 10189 |
start++; |
| 10190 |
} |
| 10191 |
var end = column; |
| 10192 |
while (end < line.length && line.charAt(end).match(re)) { |
| 10193 |
end++; |
| 10194 |
} |
| 10195 |
return new Range(row, start, row, end); |
| 10196 |
}; |
| 10197 |
EditSession.prototype.getAWordRange = function (row, column) { |
| 10198 |
var wordRange = this.getWordRange(row, column); |
| 10199 |
var line = this.getLine(wordRange.end.row); |
| 10200 |
while (line.charAt(wordRange.end.column).match(/[ \t]/)) { |
| 10201 |
wordRange.end.column += 1; |
| 10202 |
} |
| 10203 |
return wordRange; |
| 10204 |
}; |
| 10205 |
EditSession.prototype.setNewLineMode = function (newLineMode) { |
| 10206 |
this.doc.setNewLineMode(newLineMode); |
| 10207 |
}; |
| 10208 |
EditSession.prototype.getNewLineMode = function () { |
| 10209 |
return this.doc.getNewLineMode(); |
| 10210 |
}; |
| 10211 |
EditSession.prototype.setUseWorker = function (useWorker) { this.setOption("useWorker", useWorker); }; |
| 10212 |
EditSession.prototype.getUseWorker = function () { return this.$useWorker; }; |
| 10213 |
EditSession.prototype.onReloadTokenizer = function (e) { |
| 10214 |
var rows = e.data; |
| 10215 |
this.bgTokenizer.start(rows.first); |
| 10216 |
this._signal("tokenizerUpdate", e); |
| 10217 |
}; |
| 10218 |
EditSession.prototype.setMode = function (mode, cb) { |
| 10219 |
if (mode && typeof mode === "object") { |
| 10220 |
if (mode.getTokenizer) |
| 10221 |
return this.$onChangeMode(mode); |
| 10222 |
var options = mode; |
| 10223 |
var path = options.path; |
| 10224 |
} |
| 10225 |
else { |
| 10226 |
path = (mode) || "ace/mode/text"; |
| 10227 |
} |
| 10228 |
if (!this.$modes["ace/mode/text"]) |
| 10229 |
this.$modes["ace/mode/text"] = new TextMode(); |
| 10230 |
if (this.$modes[path] && !options) { |
| 10231 |
this.$onChangeMode(this.$modes[path]); |
| 10232 |
cb && cb(); |
| 10233 |
return; |
| 10234 |
} |
| 10235 |
this.$modeId = path; |
| 10236 |
config.loadModule(["mode", path], function (m) { |
| 10237 |
if (this.$modeId !== path) |
| 10238 |
return cb && cb(); |
| 10239 |
if (this.$modes[path] && !options) { |
| 10240 |
this.$onChangeMode(this.$modes[path]); |
| 10241 |
} |
| 10242 |
else if (m && m.Mode) { |
| 10243 |
m = new m.Mode(options); |
| 10244 |
if (!options) { |
| 10245 |
this.$modes[path] = m; |
| 10246 |
m.$id = path; |
| 10247 |
} |
| 10248 |
this.$onChangeMode(m); |
| 10249 |
} |
| 10250 |
cb && cb(); |
| 10251 |
}.bind(this)); |
| 10252 |
if (!this.$mode) |
| 10253 |
this.$onChangeMode(this.$modes["ace/mode/text"], true); |
| 10254 |
}; |
| 10255 |
EditSession.prototype.$onChangeMode = function (mode, $isPlaceholder) { |
| 10256 |
if (!$isPlaceholder) |
| 10257 |
this.$modeId = mode.$id; |
| 10258 |
if (this.$mode === mode) |
| 10259 |
return; |
| 10260 |
var oldMode = this.$mode; |
| 10261 |
this.$mode = mode; |
| 10262 |
this.$stopWorker(); |
| 10263 |
if (this.$useWorker) |
| 10264 |
this.$startWorker(); |
| 10265 |
var tokenizer = mode.getTokenizer(); |
| 10266 |
if (tokenizer.on !== undefined) { |
| 10267 |
var onReloadTokenizer = this.onReloadTokenizer.bind(this); |
| 10268 |
tokenizer.on("update", onReloadTokenizer); |
| 10269 |
} |
| 10270 |
this.bgTokenizer.setTokenizer(tokenizer); |
| 10271 |
this.bgTokenizer.setDocument(this.getDocument()); |
| 10272 |
this.tokenRe = mode.tokenRe; |
| 10273 |
this.nonTokenRe = mode.nonTokenRe; |
| 10274 |
if (!$isPlaceholder) { |
| 10275 |
if (mode.attachToSession) |
| 10276 |
mode.attachToSession(this); |
| 10277 |
this.$options.wrapMethod.set.call(this, this.$wrapMethod); |
| 10278 |
this.$setFolding(mode.foldingRules); |
| 10279 |
this.bgTokenizer.start(0); |
| 10280 |
this._emit("changeMode", { oldMode: oldMode, mode: mode }); |
| 10281 |
} |
| 10282 |
}; |
| 10283 |
EditSession.prototype.$stopWorker = function () { |
| 10284 |
if (this.$worker) { |
| 10285 |
this.$worker.terminate(); |
| 10286 |
this.$worker = null; |
| 10287 |
} |
| 10288 |
}; |
| 10289 |
EditSession.prototype.$startWorker = function () { |
| 10290 |
try { |
| 10291 |
this.$worker = this.$mode.createWorker(this); |
| 10292 |
} |
| 10293 |
catch (e) { |
| 10294 |
config.warn("Could not load worker", e); |
| 10295 |
this.$worker = null; |
| 10296 |
} |
| 10297 |
}; |
| 10298 |
EditSession.prototype.getMode = function () { |
| 10299 |
return this.$mode; |
| 10300 |
}; |
| 10301 |
EditSession.prototype.setScrollTop = function (scrollTop) { |
| 10302 |
if (this.$scrollTop === scrollTop || isNaN(scrollTop)) |
| 10303 |
return; |
| 10304 |
this.$scrollTop = scrollTop; |
| 10305 |
this._signal("changeScrollTop", scrollTop); |
| 10306 |
}; |
| 10307 |
EditSession.prototype.getScrollTop = function () { |
| 10308 |
return this.$scrollTop; |
| 10309 |
}; |
| 10310 |
EditSession.prototype.setScrollLeft = function (scrollLeft) { |
| 10311 |
if (this.$scrollLeft === scrollLeft || isNaN(scrollLeft)) |
| 10312 |
return; |
| 10313 |
this.$scrollLeft = scrollLeft; |
| 10314 |
this._signal("changeScrollLeft", scrollLeft); |
| 10315 |
}; |
| 10316 |
EditSession.prototype.getScrollLeft = function () { |
| 10317 |
return this.$scrollLeft; |
| 10318 |
}; |
| 10319 |
EditSession.prototype.getScreenWidth = function () { |
| 10320 |
this.$computeWidth(); |
| 10321 |
if (this.lineWidgets) |
| 10322 |
return Math.max(this.getLineWidgetMaxWidth(), this.screenWidth); |
| 10323 |
return this.screenWidth; |
| 10324 |
}; |
| 10325 |
EditSession.prototype.getLineWidgetMaxWidth = function () { |
| 10326 |
if (this.lineWidgetsWidth != null) |
| 10327 |
return this.lineWidgetsWidth; |
| 10328 |
var width = 0; |
| 10329 |
this.lineWidgets.forEach(function (w) { |
| 10330 |
if (w && w.screenWidth > width) |
| 10331 |
width = w.screenWidth; |
| 10332 |
}); |
| 10333 |
return this.lineWidgetWidth = width; |
| 10334 |
}; |
| 10335 |
EditSession.prototype.$computeWidth = function (force) { |
| 10336 |
if (this.$modified || force) { |
| 10337 |
this.$modified = false; |
| 10338 |
if (this.$useWrapMode) |
| 10339 |
return this.screenWidth = this.$wrapLimit; |
| 10340 |
var lines = this.doc.getAllLines(); |
| 10341 |
var cache = this.$rowLengthCache; |
| 10342 |
var longestScreenLine = 0; |
| 10343 |
var foldIndex = 0; |
| 10344 |
var foldLine = this.$foldData[foldIndex]; |
| 10345 |
var foldStart = foldLine ? foldLine.start.row : Infinity; |
| 10346 |
var len = lines.length; |
| 10347 |
for (var i = 0; i < len; i++) { |
| 10348 |
if (i > foldStart) { |
| 10349 |
i = foldLine.end.row + 1; |
| 10350 |
if (i >= len) |
| 10351 |
break; |
| 10352 |
foldLine = this.$foldData[foldIndex++]; |
| 10353 |
foldStart = foldLine ? foldLine.start.row : Infinity; |
| 10354 |
} |
| 10355 |
if (cache[i] == null) |
| 10356 |
cache[i] = this.$getStringScreenWidth(lines[i])[0]; |
| 10357 |
if (cache[i] > longestScreenLine) |
| 10358 |
longestScreenLine = cache[i]; |
| 10359 |
} |
| 10360 |
this.screenWidth = longestScreenLine; |
| 10361 |
} |
| 10362 |
}; |
| 10363 |
EditSession.prototype.getLine = function (row) { |
| 10364 |
return this.doc.getLine(row); |
| 10365 |
}; |
| 10366 |
EditSession.prototype.getLines = function (firstRow, lastRow) { |
| 10367 |
return this.doc.getLines(firstRow, lastRow); |
| 10368 |
}; |
| 10369 |
EditSession.prototype.getLength = function () { |
| 10370 |
return this.doc.getLength(); |
| 10371 |
}; |
| 10372 |
EditSession.prototype.getTextRange = function (range) { |
| 10373 |
return this.doc.getTextRange(range || this.selection.getRange()); |
| 10374 |
}; |
| 10375 |
EditSession.prototype.insert = function (position, text) { |
| 10376 |
return this.doc.insert(position, text); |
| 10377 |
}; |
| 10378 |
EditSession.prototype.remove = function (range) { |
| 10379 |
return this.doc.remove(range); |
| 10380 |
}; |
| 10381 |
EditSession.prototype.removeFullLines = function (firstRow, lastRow) { |
| 10382 |
return this.doc.removeFullLines(firstRow, lastRow); |
| 10383 |
}; |
| 10384 |
EditSession.prototype.undoChanges = function (deltas, dontSelect) { |
| 10385 |
if (!deltas.length) |
| 10386 |
return; |
| 10387 |
this.$fromUndo = true; |
| 10388 |
for (var i = deltas.length - 1; i != -1; i--) { |
| 10389 |
var delta = deltas[i]; |
| 10390 |
if (delta.action == "insert" || delta.action == "remove") { |
| 10391 |
this.doc.revertDelta(delta); |
| 10392 |
} |
| 10393 |
else if (delta.folds) { |
| 10394 |
this.addFolds(delta.folds); |
| 10395 |
} |
| 10396 |
} |
| 10397 |
if (!dontSelect && this.$undoSelect) { |
| 10398 |
if (deltas.selectionBefore) |
| 10399 |
this.selection.fromJSON(deltas.selectionBefore); |
| 10400 |
else |
| 10401 |
this.selection.setRange(this.$getUndoSelection(deltas, true)); |
| 10402 |
} |
| 10403 |
this.$fromUndo = false; |
| 10404 |
}; |
| 10405 |
EditSession.prototype.redoChanges = function (deltas, dontSelect) { |
| 10406 |
if (!deltas.length) |
| 10407 |
return; |
| 10408 |
this.$fromUndo = true; |
| 10409 |
for (var i = 0; i < deltas.length; i++) { |
| 10410 |
var delta = deltas[i]; |
| 10411 |
if (delta.action == "insert" || delta.action == "remove") { |
| 10412 |
this.doc.$safeApplyDelta(delta); |
| 10413 |
} |
| 10414 |
} |
| 10415 |
if (!dontSelect && this.$undoSelect) { |
| 10416 |
if (deltas.selectionAfter) |
| 10417 |
this.selection.fromJSON(deltas.selectionAfter); |
| 10418 |
else |
| 10419 |
this.selection.setRange(this.$getUndoSelection(deltas, false)); |
| 10420 |
} |
| 10421 |
this.$fromUndo = false; |
| 10422 |
}; |
| 10423 |
EditSession.prototype.setUndoSelect = function (enable) { |
| 10424 |
this.$undoSelect = enable; |
| 10425 |
}; |
| 10426 |
EditSession.prototype.$getUndoSelection = function (deltas, isUndo) { |
| 10427 |
function isInsert(delta) { |
| 10428 |
return isUndo ? delta.action !== "insert" : delta.action === "insert"; |
| 10429 |
} |
| 10430 |
var range, point; |
| 10431 |
for (var i = 0; i < deltas.length; i++) { |
| 10432 |
var delta = deltas[i]; |
| 10433 |
if (!delta.start) |
| 10434 |
continue; |
| 10435 |
if (!range) { |
| 10436 |
if (isInsert(delta)) { |
| 10437 |
range = Range.fromPoints(delta.start, delta.end); |
| 10438 |
} |
| 10439 |
else { |
| 10440 |
range = Range.fromPoints(delta.start, delta.start); |
| 10441 |
} |
| 10442 |
continue; |
| 10443 |
} |
| 10444 |
if (isInsert(delta)) { |
| 10445 |
point = delta.start; |
| 10446 |
if (range.compare(point.row, point.column) == -1) { |
| 10447 |
range.setStart(point); |
| 10448 |
} |
| 10449 |
point = delta.end; |
| 10450 |
if (range.compare(point.row, point.column) == 1) { |
| 10451 |
range.setEnd(point); |
| 10452 |
} |
| 10453 |
} |
| 10454 |
else { |
| 10455 |
point = delta.start; |
| 10456 |
if (range.compare(point.row, point.column) == -1) { |
| 10457 |
range = Range.fromPoints(delta.start, delta.start); |
| 10458 |
} |
| 10459 |
} |
| 10460 |
} |
| 10461 |
return range; |
| 10462 |
}; |
| 10463 |
EditSession.prototype.replace = function (range, text) { |
| 10464 |
return this.doc.replace(range, text); |
| 10465 |
}; |
| 10466 |
EditSession.prototype.moveText = function (fromRange, toPosition, copy) { |
| 10467 |
var text = this.getTextRange(fromRange); |
| 10468 |
var folds = this.getFoldsInRange(fromRange); |
| 10469 |
var toRange = Range.fromPoints(toPosition, toPosition); |
| 10470 |
if (!copy) { |
| 10471 |
this.remove(fromRange); |
| 10472 |
var rowDiff = fromRange.start.row - fromRange.end.row; |
| 10473 |
var collDiff = rowDiff ? -fromRange.end.column : fromRange.start.column - fromRange.end.column; |
| 10474 |
if (collDiff) { |
| 10475 |
if (toRange.start.row == fromRange.end.row && toRange.start.column > fromRange.end.column) |
| 10476 |
toRange.start.column += collDiff; |
| 10477 |
if (toRange.end.row == fromRange.end.row && toRange.end.column > fromRange.end.column) |
| 10478 |
toRange.end.column += collDiff; |
| 10479 |
} |
| 10480 |
if (rowDiff && toRange.start.row >= fromRange.end.row) { |
| 10481 |
toRange.start.row += rowDiff; |
| 10482 |
toRange.end.row += rowDiff; |
| 10483 |
} |
| 10484 |
} |
| 10485 |
toRange.end = this.insert(toRange.start, text); |
| 10486 |
if (folds.length) { |
| 10487 |
var oldStart = fromRange.start; |
| 10488 |
var newStart = toRange.start; |
| 10489 |
var rowDiff = newStart.row - oldStart.row; |
| 10490 |
var collDiff = newStart.column - oldStart.column; |
| 10491 |
this.addFolds(folds.map(function (x) { |
| 10492 |
x = x.clone(); |
| 10493 |
if (x.start.row == oldStart.row) |
| 10494 |
x.start.column += collDiff; |
| 10495 |
if (x.end.row == oldStart.row) |
| 10496 |
x.end.column += collDiff; |
| 10497 |
x.start.row += rowDiff; |
| 10498 |
x.end.row += rowDiff; |
| 10499 |
return x; |
| 10500 |
})); |
| 10501 |
} |
| 10502 |
return toRange; |
| 10503 |
}; |
| 10504 |
EditSession.prototype.indentRows = function (startRow, endRow, indentString) { |
| 10505 |
indentString = indentString.replace(/\t/g, this.getTabString()); |
| 10506 |
for (var row = startRow; row <= endRow; row++) |
| 10507 |
this.doc.insertInLine({ row: row, column: 0 }, indentString); |
| 10508 |
}; |
| 10509 |
EditSession.prototype.outdentRows = function (range) { |
| 10510 |
var rowRange = range.collapseRows(); |
| 10511 |
var deleteRange = new Range(0, 0, 0, 0); |
| 10512 |
var size = this.getTabSize(); |
| 10513 |
for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) { |
| 10514 |
var line = this.getLine(i); |
| 10515 |
deleteRange.start.row = i; |
| 10516 |
deleteRange.end.row = i; |
| 10517 |
for (var j = 0; j < size; ++j) |
| 10518 |
if (line.charAt(j) != ' ') |
| 10519 |
break; |
| 10520 |
if (j < size && line.charAt(j) == '\t') { |
| 10521 |
deleteRange.start.column = j; |
| 10522 |
deleteRange.end.column = j + 1; |
| 10523 |
} |
| 10524 |
else { |
| 10525 |
deleteRange.start.column = 0; |
| 10526 |
deleteRange.end.column = j; |
| 10527 |
} |
| 10528 |
this.remove(deleteRange); |
| 10529 |
} |
| 10530 |
}; |
| 10531 |
EditSession.prototype.$moveLines = function (firstRow, lastRow, dir) { |
| 10532 |
firstRow = this.getRowFoldStart(firstRow); |
| 10533 |
lastRow = this.getRowFoldEnd(lastRow); |
| 10534 |
if (dir < 0) { |
| 10535 |
var row = this.getRowFoldStart(firstRow + dir); |
| 10536 |
if (row < 0) |
| 10537 |
return 0; |
| 10538 |
var diff = row - firstRow; |
| 10539 |
} |
| 10540 |
else if (dir > 0) { |
| 10541 |
var row = this.getRowFoldEnd(lastRow + dir); |
| 10542 |
if (row > this.doc.getLength() - 1) |
| 10543 |
return 0; |
| 10544 |
var diff = row - lastRow; |
| 10545 |
} |
| 10546 |
else { |
| 10547 |
firstRow = this.$clipRowToDocument(firstRow); |
| 10548 |
lastRow = this.$clipRowToDocument(lastRow); |
| 10549 |
var diff = lastRow - firstRow + 1; |
| 10550 |
} |
| 10551 |
var range = new Range(firstRow, 0, lastRow, Number.MAX_VALUE); |
| 10552 |
var folds = this.getFoldsInRange(range).map(function (x) { |
| 10553 |
x = x.clone(); |
| 10554 |
x.start.row += diff; |
| 10555 |
x.end.row += diff; |
| 10556 |
return x; |
| 10557 |
}); |
| 10558 |
var lines = dir == 0 |
| 10559 |
? this.doc.getLines(firstRow, lastRow) |
| 10560 |
: this.doc.removeFullLines(firstRow, lastRow); |
| 10561 |
this.doc.insertFullLines(firstRow + diff, lines); |
| 10562 |
folds.length && this.addFolds(folds); |
| 10563 |
return diff; |
| 10564 |
}; |
| 10565 |
EditSession.prototype.moveLinesUp = function (firstRow, lastRow) { |
| 10566 |
return this.$moveLines(firstRow, lastRow, -1); |
| 10567 |
}; |
| 10568 |
EditSession.prototype.moveLinesDown = function (firstRow, lastRow) { |
| 10569 |
return this.$moveLines(firstRow, lastRow, 1); |
| 10570 |
}; |
| 10571 |
EditSession.prototype.duplicateLines = function (firstRow, lastRow) { |
| 10572 |
return this.$moveLines(firstRow, lastRow, 0); |
| 10573 |
}; |
| 10574 |
EditSession.prototype.$clipRowToDocument = function (row) { |
| 10575 |
return Math.max(0, Math.min(row, this.doc.getLength() - 1)); |
| 10576 |
}; |
| 10577 |
EditSession.prototype.$clipColumnToRow = function (row, column) { |
| 10578 |
if (column < 0) |
| 10579 |
return 0; |
| 10580 |
return Math.min(this.doc.getLine(row).length, column); |
| 10581 |
}; |
| 10582 |
EditSession.prototype.$clipPositionToDocument = function (row, column) { |
| 10583 |
column = Math.max(0, column); |
| 10584 |
if (row < 0) { |
| 10585 |
row = 0; |
| 10586 |
column = 0; |
| 10587 |
} |
| 10588 |
else { |
| 10589 |
var len = this.doc.getLength(); |
| 10590 |
if (row >= len) { |
| 10591 |
row = len - 1; |
| 10592 |
column = this.doc.getLine(len - 1).length; |
| 10593 |
} |
| 10594 |
else { |
| 10595 |
column = Math.min(this.doc.getLine(row).length, column); |
| 10596 |
} |
| 10597 |
} |
| 10598 |
return { |
| 10599 |
row: row, |
| 10600 |
column: column |
| 10601 |
}; |
| 10602 |
}; |
| 10603 |
EditSession.prototype.$clipRangeToDocument = function (range) { |
| 10604 |
if (range.start.row < 0) { |
| 10605 |
range.start.row = 0; |
| 10606 |
range.start.column = 0; |
| 10607 |
} |
| 10608 |
else { |
| 10609 |
range.start.column = this.$clipColumnToRow(range.start.row, range.start.column); |
| 10610 |
} |
| 10611 |
var len = this.doc.getLength() - 1; |
| 10612 |
if (range.end.row > len) { |
| 10613 |
range.end.row = len; |
| 10614 |
range.end.column = this.doc.getLine(len).length; |
| 10615 |
} |
| 10616 |
else { |
| 10617 |
range.end.column = this.$clipColumnToRow(range.end.row, range.end.column); |
| 10618 |
} |
| 10619 |
return range; |
| 10620 |
}; |
| 10621 |
EditSession.prototype.setUseWrapMode = function (useWrapMode) { |
| 10622 |
if (useWrapMode != this.$useWrapMode) { |
| 10623 |
this.$useWrapMode = useWrapMode; |
| 10624 |
this.$modified = true; |
| 10625 |
this.$resetRowCache(0); |
| 10626 |
if (useWrapMode) { |
| 10627 |
var len = this.getLength(); |
| 10628 |
this.$wrapData = Array(len); |
| 10629 |
this.$updateWrapData(0, len - 1); |
| 10630 |
} |
| 10631 |
this._signal("changeWrapMode"); |
| 10632 |
} |
| 10633 |
}; |
| 10634 |
EditSession.prototype.getUseWrapMode = function () { |
| 10635 |
return this.$useWrapMode; |
| 10636 |
}; |
| 10637 |
EditSession.prototype.setWrapLimitRange = function (min, max) { |
| 10638 |
if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) { |
| 10639 |
this.$wrapLimitRange = { min: min, max: max }; |
| 10640 |
this.$modified = true; |
| 10641 |
this.$bidiHandler.markAsDirty(); |
| 10642 |
if (this.$useWrapMode) |
| 10643 |
this._signal("changeWrapMode"); |
| 10644 |
} |
| 10645 |
}; |
| 10646 |
EditSession.prototype.adjustWrapLimit = function (desiredLimit, $printMargin) { |
| 10647 |
var limits = this.$wrapLimitRange; |
| 10648 |
if (limits.max < 0) |
| 10649 |
limits = { min: $printMargin, max: $printMargin }; |
| 10650 |
var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max); |
| 10651 |
if (wrapLimit != this.$wrapLimit && wrapLimit > 1) { |
| 10652 |
this.$wrapLimit = wrapLimit; |
| 10653 |
this.$modified = true; |
| 10654 |
if (this.$useWrapMode) { |
| 10655 |
this.$updateWrapData(0, this.getLength() - 1); |
| 10656 |
this.$resetRowCache(0); |
| 10657 |
this._signal("changeWrapLimit"); |
| 10658 |
} |
| 10659 |
return true; |
| 10660 |
} |
| 10661 |
return false; |
| 10662 |
}; |
| 10663 |
EditSession.prototype.$constrainWrapLimit = function (wrapLimit, min, max) { |
| 10664 |
if (min) |
| 10665 |
wrapLimit = Math.max(min, wrapLimit); |
| 10666 |
if (max) |
| 10667 |
wrapLimit = Math.min(max, wrapLimit); |
| 10668 |
return wrapLimit; |
| 10669 |
}; |
| 10670 |
EditSession.prototype.getWrapLimit = function () { |
| 10671 |
return this.$wrapLimit; |
| 10672 |
}; |
| 10673 |
EditSession.prototype.setWrapLimit = function (limit) { |
| 10674 |
this.setWrapLimitRange(limit, limit); |
| 10675 |
}; |
| 10676 |
EditSession.prototype.getWrapLimitRange = function () { |
| 10677 |
return { |
| 10678 |
min: this.$wrapLimitRange.min, |
| 10679 |
max: this.$wrapLimitRange.max |
| 10680 |
}; |
| 10681 |
}; |
| 10682 |
EditSession.prototype.$updateInternalDataOnChange = function (delta) { |
| 10683 |
var useWrapMode = this.$useWrapMode; |
| 10684 |
var action = delta.action; |
| 10685 |
var start = delta.start; |
| 10686 |
var end = delta.end; |
| 10687 |
var firstRow = start.row; |
| 10688 |
var lastRow = end.row; |
| 10689 |
var len = lastRow - firstRow; |
| 10690 |
var removedFolds = null; |
| 10691 |
this.$updating = true; |
| 10692 |
if (len != 0) { |
| 10693 |
if (action === "remove") { |
| 10694 |
this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len); |
| 10695 |
var foldLines = this.$foldData; |
| 10696 |
removedFolds = this.getFoldsInRange(delta); |
| 10697 |
this.removeFolds(removedFolds); |
| 10698 |
var foldLine = this.getFoldLine(end.row); |
| 10699 |
var idx = 0; |
| 10700 |
if (foldLine) { |
| 10701 |
foldLine.addRemoveChars(end.row, end.column, start.column - end.column); |
| 10702 |
foldLine.shiftRow(-len); |
| 10703 |
var foldLineBefore = this.getFoldLine(firstRow); |
| 10704 |
if (foldLineBefore && foldLineBefore !== foldLine) { |
| 10705 |
foldLineBefore.merge(foldLine); |
| 10706 |
foldLine = foldLineBefore; |
| 10707 |
} |
| 10708 |
idx = foldLines.indexOf(foldLine) + 1; |
| 10709 |
} |
| 10710 |
for (idx; idx < foldLines.length; idx++) { |
| 10711 |
var foldLine = foldLines[idx]; |
| 10712 |
if (foldLine.start.row >= end.row) { |
| 10713 |
foldLine.shiftRow(-len); |
| 10714 |
} |
| 10715 |
} |
| 10716 |
lastRow = firstRow; |
| 10717 |
} |
| 10718 |
else { |
| 10719 |
var args = Array(len); |
| 10720 |
args.unshift(firstRow, 0); |
| 10721 |
var arr = useWrapMode ? this.$wrapData : this.$rowLengthCache; |
| 10722 |
arr.splice.apply(arr, args); |
| 10723 |
var foldLines = this.$foldData; |
| 10724 |
var foldLine = this.getFoldLine(firstRow); |
| 10725 |
var idx = 0; |
| 10726 |
if (foldLine) { |
| 10727 |
var cmp = foldLine.range.compareInside(start.row, start.column); |
| 10728 |
if (cmp == 0) { |
| 10729 |
foldLine = foldLine.split(start.row, start.column); |
| 10730 |
if (foldLine) { |
| 10731 |
foldLine.shiftRow(len); |
| 10732 |
foldLine.addRemoveChars(lastRow, 0, end.column - start.column); |
| 10733 |
} |
| 10734 |
} |
| 10735 |
else |
| 10736 |
if (cmp == -1) { |
| 10737 |
foldLine.addRemoveChars(firstRow, 0, end.column - start.column); |
| 10738 |
foldLine.shiftRow(len); |
| 10739 |
} |
| 10740 |
idx = foldLines.indexOf(foldLine) + 1; |
| 10741 |
} |
| 10742 |
for (idx; idx < foldLines.length; idx++) { |
| 10743 |
var foldLine = foldLines[idx]; |
| 10744 |
if (foldLine.start.row >= firstRow) { |
| 10745 |
foldLine.shiftRow(len); |
| 10746 |
} |
| 10747 |
} |
| 10748 |
} |
| 10749 |
} |
| 10750 |
else { |
| 10751 |
len = Math.abs(delta.start.column - delta.end.column); |
| 10752 |
if (action === "remove") { |
| 10753 |
removedFolds = this.getFoldsInRange(delta); |
| 10754 |
this.removeFolds(removedFolds); |
| 10755 |
len = -len; |
| 10756 |
} |
| 10757 |
var foldLine = this.getFoldLine(firstRow); |
| 10758 |
if (foldLine) { |
| 10759 |
foldLine.addRemoveChars(firstRow, start.column, len); |
| 10760 |
} |
| 10761 |
} |
| 10762 |
if (useWrapMode && this.$wrapData.length != this.doc.getLength()) { |
| 10763 |
console.error("doc.getLength() and $wrapData.length have to be the same!"); |
| 10764 |
} |
| 10765 |
this.$updating = false; |
| 10766 |
if (useWrapMode) |
| 10767 |
this.$updateWrapData(firstRow, lastRow); |
| 10768 |
else |
| 10769 |
this.$updateRowLengthCache(firstRow, lastRow); |
| 10770 |
return removedFolds; |
| 10771 |
}; |
| 10772 |
EditSession.prototype.$updateRowLengthCache = function (firstRow, lastRow) { |
| 10773 |
this.$rowLengthCache[firstRow] = null; |
| 10774 |
this.$rowLengthCache[lastRow] = null; |
| 10775 |
}; |
| 10776 |
EditSession.prototype.$updateWrapData = function (firstRow, lastRow) { |
| 10777 |
var lines = this.doc.getAllLines(); |
| 10778 |
var tabSize = this.getTabSize(); |
| 10779 |
var wrapData = this.$wrapData; |
| 10780 |
var wrapLimit = this.$wrapLimit; |
| 10781 |
var tokens; |
| 10782 |
var foldLine; |
| 10783 |
var row = firstRow; |
| 10784 |
lastRow = Math.min(lastRow, lines.length - 1); |
| 10785 |
while (row <= lastRow) { |
| 10786 |
foldLine = this.getFoldLine(row, foldLine); |
| 10787 |
if (!foldLine) { |
| 10788 |
tokens = this.$getDisplayTokens(lines[row]); |
| 10789 |
wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize); |
| 10790 |
row++; |
| 10791 |
} |
| 10792 |
else { |
| 10793 |
tokens = []; |
| 10794 |
foldLine.walk(function (placeholder, row, column, lastColumn) { |
| 10795 |
var walkTokens; |
| 10796 |
if (placeholder != null) { |
| 10797 |
walkTokens = this.$getDisplayTokens(placeholder, tokens.length); |
| 10798 |
walkTokens[0] = PLACEHOLDER_START; |
| 10799 |
for (var i = 1; i < walkTokens.length; i++) { |
| 10800 |
walkTokens[i] = PLACEHOLDER_BODY; |
| 10801 |
} |
| 10802 |
} |
| 10803 |
else { |
| 10804 |
walkTokens = this.$getDisplayTokens(lines[row].substring(lastColumn, column), tokens.length); |
| 10805 |
} |
| 10806 |
tokens = tokens.concat(walkTokens); |
| 10807 |
}.bind(this), foldLine.end.row, lines[foldLine.end.row].length + 1); |
| 10808 |
wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize); |
| 10809 |
row = foldLine.end.row + 1; |
| 10810 |
} |
| 10811 |
} |
| 10812 |
}; |
| 10813 |
EditSession.prototype.$computeWrapSplits = function (tokens, wrapLimit, tabSize) { |
| 10814 |
if (tokens.length == 0) { |
| 10815 |
return []; |
| 10816 |
} |
| 10817 |
var splits = []; |
| 10818 |
var displayLength = tokens.length; |
| 10819 |
var lastSplit = 0, lastDocSplit = 0; |
| 10820 |
var isCode = this.$wrapAsCode; |
| 10821 |
var indentedSoftWrap = this.$indentedSoftWrap; |
| 10822 |
var maxIndent = wrapLimit <= Math.max(2 * tabSize, 8) |
| 10823 |
|| indentedSoftWrap === false ? 0 : Math.floor(wrapLimit / 2); |
| 10824 |
function getWrapIndent() { |
| 10825 |
var indentation = 0; |
| 10826 |
if (maxIndent === 0) |
| 10827 |
return indentation; |
| 10828 |
if (indentedSoftWrap) { |
| 10829 |
for (var i = 0; i < tokens.length; i++) { |
| 10830 |
var token = tokens[i]; |
| 10831 |
if (token == SPACE) |
| 10832 |
indentation += 1; |
| 10833 |
else if (token == TAB) |
| 10834 |
indentation += tabSize; |
| 10835 |
else if (token == TAB_SPACE) |
| 10836 |
continue; |
| 10837 |
else |
| 10838 |
break; |
| 10839 |
} |
| 10840 |
} |
| 10841 |
if (isCode && indentedSoftWrap !== false) |
| 10842 |
indentation += tabSize; |
| 10843 |
return Math.min(indentation, maxIndent); |
| 10844 |
} |
| 10845 |
function addSplit(screenPos) { |
| 10846 |
var len = screenPos - lastSplit; |
| 10847 |
for (var i = lastSplit; i < screenPos; i++) { |
| 10848 |
var ch = tokens[i]; |
| 10849 |
if (ch === 12 || ch === 2) |
| 10850 |
len -= 1; |
| 10851 |
} |
| 10852 |
if (!splits.length) { |
| 10853 |
indent = getWrapIndent(); |
| 10854 |
splits.indent = indent; |
| 10855 |
} |
| 10856 |
lastDocSplit += len; |
| 10857 |
splits.push(lastDocSplit); |
| 10858 |
lastSplit = screenPos; |
| 10859 |
} |
| 10860 |
var indent = 0; |
| 10861 |
while (displayLength - lastSplit > wrapLimit - indent) { |
| 10862 |
var split = lastSplit + wrapLimit - indent; |
| 10863 |
if (tokens[split - 1] >= SPACE && tokens[split] >= SPACE) { |
| 10864 |
addSplit(split); |
| 10865 |
continue; |
| 10866 |
} |
| 10867 |
if (tokens[split] == PLACEHOLDER_START || tokens[split] == PLACEHOLDER_BODY) { |
| 10868 |
for (split; split != lastSplit - 1; split--) { |
| 10869 |
if (tokens[split] == PLACEHOLDER_START) { |
| 10870 |
break; |
| 10871 |
} |
| 10872 |
} |
| 10873 |
if (split > lastSplit) { |
| 10874 |
addSplit(split); |
| 10875 |
continue; |
| 10876 |
} |
| 10877 |
split = lastSplit + wrapLimit; |
| 10878 |
for (split; split < tokens.length; split++) { |
| 10879 |
if (tokens[split] != PLACEHOLDER_BODY) { |
| 10880 |
break; |
| 10881 |
} |
| 10882 |
} |
| 10883 |
if (split == tokens.length) { |
| 10884 |
break; |
| 10885 |
} |
| 10886 |
addSplit(split); |
| 10887 |
continue; |
| 10888 |
} |
| 10889 |
var minSplit = Math.max(split - (wrapLimit - (wrapLimit >> 2)), lastSplit - 1); |
| 10890 |
while (split > minSplit && tokens[split] < PLACEHOLDER_START) { |
| 10891 |
split--; |
| 10892 |
} |
| 10893 |
if (isCode) { |
| 10894 |
while (split > minSplit && tokens[split] < PLACEHOLDER_START) { |
| 10895 |
split--; |
| 10896 |
} |
| 10897 |
while (split > minSplit && tokens[split] == PUNCTUATION) { |
| 10898 |
split--; |
| 10899 |
} |
| 10900 |
} |
| 10901 |
else { |
| 10902 |
while (split > minSplit && tokens[split] < SPACE) { |
| 10903 |
split--; |
| 10904 |
} |
| 10905 |
} |
| 10906 |
if (split > minSplit) { |
| 10907 |
addSplit(++split); |
| 10908 |
continue; |
| 10909 |
} |
| 10910 |
split = lastSplit + wrapLimit; |
| 10911 |
if (tokens[split] == CHAR_EXT) |
| 10912 |
split--; |
| 10913 |
addSplit(split - indent); |
| 10914 |
} |
| 10915 |
return splits; |
| 10916 |
}; |
| 10917 |
EditSession.prototype.$getDisplayTokens = function (str, offset) { |
| 10918 |
var arr = []; |
| 10919 |
var tabSize; |
| 10920 |
offset = offset || 0; |
| 10921 |
for (var i = 0; i < str.length; i++) { |
| 10922 |
var c = str.charCodeAt(i); |
| 10923 |
if (c == 9) { |
| 10924 |
tabSize = this.getScreenTabSize(arr.length + offset); |
| 10925 |
arr.push(TAB); |
| 10926 |
for (var n = 1; n < tabSize; n++) { |
| 10927 |
arr.push(TAB_SPACE); |
| 10928 |
} |
| 10929 |
} |
| 10930 |
else if (c == 32) { |
| 10931 |
arr.push(SPACE); |
| 10932 |
} |
| 10933 |
else if ((c > 39 && c < 48) || (c > 57 && c < 64)) { |
| 10934 |
arr.push(PUNCTUATION); |
| 10935 |
} |
| 10936 |
else if (c >= 0x1100 && isFullWidth(c)) { |
| 10937 |
arr.push(CHAR, CHAR_EXT); |
| 10938 |
} |
| 10939 |
else { |
| 10940 |
arr.push(CHAR); |
| 10941 |
} |
| 10942 |
} |
| 10943 |
return arr; |
| 10944 |
}; |
| 10945 |
EditSession.prototype.$getStringScreenWidth = function (str, maxScreenColumn, screenColumn) { |
| 10946 |
if (maxScreenColumn == 0) |
| 10947 |
return [0, 0]; |
| 10948 |
if (maxScreenColumn == null) |
| 10949 |
maxScreenColumn = Infinity; |
| 10950 |
screenColumn = screenColumn || 0; |
| 10951 |
var c, column; |
| 10952 |
for (column = 0; column < str.length; column++) { |
| 10953 |
c = str.charCodeAt(column); |
| 10954 |
if (c == 9) { |
| 10955 |
screenColumn += this.getScreenTabSize(screenColumn); |
| 10956 |
} |
| 10957 |
else if (c >= 0x1100 && isFullWidth(c)) { |
| 10958 |
screenColumn += 2; |
| 10959 |
} |
| 10960 |
else { |
| 10961 |
screenColumn += 1; |
| 10962 |
} |
| 10963 |
if (screenColumn > maxScreenColumn) { |
| 10964 |
break; |
| 10965 |
} |
| 10966 |
} |
| 10967 |
return [screenColumn, column]; |
| 10968 |
}; |
| 10969 |
EditSession.prototype.getRowLength = function (row) { |
| 10970 |
var h = 1; |
| 10971 |
if (this.lineWidgets) |
| 10972 |
h += this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0; |
| 10973 |
if (!this.$useWrapMode || !this.$wrapData[row]) |
| 10974 |
return h; |
| 10975 |
else |
| 10976 |
return this.$wrapData[row].length + h; |
| 10977 |
}; |
| 10978 |
EditSession.prototype.getRowLineCount = function (row) { |
| 10979 |
if (!this.$useWrapMode || !this.$wrapData[row]) { |
| 10980 |
return 1; |
| 10981 |
} |
| 10982 |
else { |
| 10983 |
return this.$wrapData[row].length + 1; |
| 10984 |
} |
| 10985 |
}; |
| 10986 |
EditSession.prototype.getRowWrapIndent = function (screenRow) { |
| 10987 |
if (this.$useWrapMode) { |
| 10988 |
var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE); |
| 10989 |
var splits = this.$wrapData[pos.row]; |
| 10990 |
return splits.length && splits[0] < pos.column ? splits.indent : 0; |
| 10991 |
} |
| 10992 |
else { |
| 10993 |
return 0; |
| 10994 |
} |
| 10995 |
}; |
| 10996 |
EditSession.prototype.getScreenLastRowColumn = function (screenRow) { |
| 10997 |
var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE); |
| 10998 |
return this.documentToScreenColumn(pos.row, pos.column); |
| 10999 |
}; |
| 11000 |
EditSession.prototype.getDocumentLastRowColumn = function (docRow, docColumn) { |
| 11001 |
var screenRow = this.documentToScreenRow(docRow, docColumn); |
| 11002 |
return this.getScreenLastRowColumn(screenRow); |
| 11003 |
}; |
| 11004 |
EditSession.prototype.getDocumentLastRowColumnPosition = function (docRow, docColumn) { |
| 11005 |
var screenRow = this.documentToScreenRow(docRow, docColumn); |
| 11006 |
return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10); |
| 11007 |
}; |
| 11008 |
EditSession.prototype.getRowSplitData = function (row) { |
| 11009 |
if (!this.$useWrapMode) { |
| 11010 |
return undefined; |
| 11011 |
} |
| 11012 |
else { |
| 11013 |
return this.$wrapData[row]; |
| 11014 |
} |
| 11015 |
}; |
| 11016 |
EditSession.prototype.getScreenTabSize = function (screenColumn) { |
| 11017 |
return this.$tabSize - (screenColumn % this.$tabSize | 0); |
| 11018 |
}; |
| 11019 |
EditSession.prototype.screenToDocumentRow = function (screenRow, screenColumn) { |
| 11020 |
return this.screenToDocumentPosition(screenRow, screenColumn).row; |
| 11021 |
}; |
| 11022 |
EditSession.prototype.screenToDocumentColumn = function (screenRow, screenColumn) { |
| 11023 |
return this.screenToDocumentPosition(screenRow, screenColumn).column; |
| 11024 |
}; |
| 11025 |
EditSession.prototype.screenToDocumentPosition = function (screenRow, screenColumn, offsetX) { |
| 11026 |
if (screenRow < 0) |
| 11027 |
return { row: 0, column: 0 }; |
| 11028 |
var line; |
| 11029 |
var docRow = 0; |
| 11030 |
var docColumn = 0; |
| 11031 |
var column; |
| 11032 |
var row = 0; |
| 11033 |
var rowLength = 0; |
| 11034 |
var rowCache = this.$screenRowCache; |
| 11035 |
var i = this.$getRowCacheIndex(rowCache, screenRow); |
| 11036 |
var l = rowCache.length; |
| 11037 |
if (l && i >= 0) { |
| 11038 |
var row = rowCache[i]; |
| 11039 |
var docRow = this.$docRowCache[i]; |
| 11040 |
var doCache = screenRow > rowCache[l - 1]; |
| 11041 |
} |
| 11042 |
else { |
| 11043 |
var doCache = !l; |
| 11044 |
} |
| 11045 |
var maxRow = this.getLength() - 1; |
| 11046 |
var foldLine = this.getNextFoldLine(docRow); |
| 11047 |
var foldStart = foldLine ? foldLine.start.row : Infinity; |
| 11048 |
while (row <= screenRow) { |
| 11049 |
rowLength = this.getRowLength(docRow); |
| 11050 |
if (row + rowLength > screenRow || docRow >= maxRow) { |
| 11051 |
break; |
| 11052 |
} |
| 11053 |
else { |
| 11054 |
row += rowLength; |
| 11055 |
docRow++; |
| 11056 |
if (docRow > foldStart) { |
| 11057 |
docRow = foldLine.end.row + 1; |
| 11058 |
foldLine = this.getNextFoldLine(docRow, foldLine); |
| 11059 |
foldStart = foldLine ? foldLine.start.row : Infinity; |
| 11060 |
} |
| 11061 |
} |
| 11062 |
if (doCache) { |
| 11063 |
this.$docRowCache.push(docRow); |
| 11064 |
this.$screenRowCache.push(row); |
| 11065 |
} |
| 11066 |
} |
| 11067 |
if (foldLine && foldLine.start.row <= docRow) { |
| 11068 |
line = this.getFoldDisplayLine(foldLine); |
| 11069 |
docRow = foldLine.start.row; |
| 11070 |
} |
| 11071 |
else if (row + rowLength <= screenRow || docRow > maxRow) { |
| 11072 |
return { |
| 11073 |
row: maxRow, |
| 11074 |
column: this.getLine(maxRow).length |
| 11075 |
}; |
| 11076 |
} |
| 11077 |
else { |
| 11078 |
line = this.getLine(docRow); |
| 11079 |
foldLine = null; |
| 11080 |
} |
| 11081 |
var wrapIndent = 0, splitIndex = Math.floor(screenRow - row); |
| 11082 |
if (this.$useWrapMode) { |
| 11083 |
var splits = this.$wrapData[docRow]; |
| 11084 |
if (splits) { |
| 11085 |
column = splits[splitIndex]; |
| 11086 |
if (splitIndex > 0 && splits.length) { |
| 11087 |
wrapIndent = splits.indent; |
| 11088 |
docColumn = splits[splitIndex - 1] || splits[splits.length - 1]; |
| 11089 |
line = line.substring(docColumn); |
| 11090 |
} |
| 11091 |
} |
| 11092 |
} |
| 11093 |
if (offsetX !== undefined && this.$bidiHandler.isBidiRow(row + splitIndex, docRow, splitIndex)) |
| 11094 |
screenColumn = this.$bidiHandler.offsetToCol(offsetX); |
| 11095 |
docColumn += this.$getStringScreenWidth(line, screenColumn - wrapIndent)[1]; |
| 11096 |
if (this.$useWrapMode && docColumn >= column) |
| 11097 |
docColumn = column - 1; |
| 11098 |
if (foldLine) |
| 11099 |
return foldLine.idxToPosition(docColumn); |
| 11100 |
return { row: docRow, column: docColumn }; |
| 11101 |
}; |
| 11102 |
EditSession.prototype.documentToScreenPosition = function (docRow, docColumn) { |
| 11103 |
if (typeof docColumn === "undefined") |
| 11104 |
var pos = this.$clipPositionToDocument( (docRow).row, (docRow).column); |
| 11105 |
else |
| 11106 |
pos = this.$clipPositionToDocument( (docRow), docColumn); |
| 11107 |
docRow = pos.row; |
| 11108 |
docColumn = pos.column; |
| 11109 |
var screenRow = 0; |
| 11110 |
var foldStartRow = null; |
| 11111 |
var fold = null; |
| 11112 |
fold = this.getFoldAt(docRow, docColumn, 1); |
| 11113 |
if (fold) { |
| 11114 |
docRow = fold.start.row; |
| 11115 |
docColumn = fold.start.column; |
| 11116 |
} |
| 11117 |
var rowEnd, row = 0; |
| 11118 |
var rowCache = this.$docRowCache; |
| 11119 |
var i = this.$getRowCacheIndex(rowCache, docRow); |
| 11120 |
var l = rowCache.length; |
| 11121 |
if (l && i >= 0) { |
| 11122 |
var row = rowCache[i]; |
| 11123 |
var screenRow = this.$screenRowCache[i]; |
| 11124 |
var doCache = docRow > rowCache[l - 1]; |
| 11125 |
} |
| 11126 |
else { |
| 11127 |
var doCache = !l; |
| 11128 |
} |
| 11129 |
var foldLine = this.getNextFoldLine(row); |
| 11130 |
var foldStart = foldLine ? foldLine.start.row : Infinity; |
| 11131 |
while (row < docRow) { |
| 11132 |
if (row >= foldStart) { |
| 11133 |
rowEnd = foldLine.end.row + 1; |
| 11134 |
if (rowEnd > docRow) |
| 11135 |
break; |
| 11136 |
foldLine = this.getNextFoldLine(rowEnd, foldLine); |
| 11137 |
foldStart = foldLine ? foldLine.start.row : Infinity; |
| 11138 |
} |
| 11139 |
else { |
| 11140 |
rowEnd = row + 1; |
| 11141 |
} |
| 11142 |
screenRow += this.getRowLength(row); |
| 11143 |
row = rowEnd; |
| 11144 |
if (doCache) { |
| 11145 |
this.$docRowCache.push(row); |
| 11146 |
this.$screenRowCache.push(screenRow); |
| 11147 |
} |
| 11148 |
} |
| 11149 |
var textLine = ""; |
| 11150 |
if (foldLine && row >= foldStart) { |
| 11151 |
textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn); |
| 11152 |
foldStartRow = foldLine.start.row; |
| 11153 |
} |
| 11154 |
else { |
| 11155 |
textLine = this.getLine(docRow).substring(0, docColumn); |
| 11156 |
foldStartRow = docRow; |
| 11157 |
} |
| 11158 |
var wrapIndent = 0; |
| 11159 |
if (this.$useWrapMode) { |
| 11160 |
var wrapRow = this.$wrapData[foldStartRow]; |
| 11161 |
if (wrapRow) { |
| 11162 |
var screenRowOffset = 0; |
| 11163 |
while (textLine.length >= wrapRow[screenRowOffset]) { |
| 11164 |
screenRow++; |
| 11165 |
screenRowOffset++; |
| 11166 |
} |
| 11167 |
textLine = textLine.substring(wrapRow[screenRowOffset - 1] || 0, textLine.length); |
| 11168 |
wrapIndent = screenRowOffset > 0 ? wrapRow.indent : 0; |
| 11169 |
} |
| 11170 |
} |
| 11171 |
if (this.lineWidgets && this.lineWidgets[row] && this.lineWidgets[row].rowsAbove) |
| 11172 |
screenRow += this.lineWidgets[row].rowsAbove; |
| 11173 |
return { |
| 11174 |
row: screenRow, |
| 11175 |
column: wrapIndent + this.$getStringScreenWidth(textLine)[0] |
| 11176 |
}; |
| 11177 |
}; |
| 11178 |
EditSession.prototype.documentToScreenColumn = function (row, docColumn) { |
| 11179 |
return this.documentToScreenPosition(row, docColumn).column; |
| 11180 |
}; |
| 11181 |
EditSession.prototype.documentToScreenRow = function (docRow, docColumn) { |
| 11182 |
return this.documentToScreenPosition(docRow, docColumn).row; |
| 11183 |
}; |
| 11184 |
EditSession.prototype.getScreenLength = function () { |
| 11185 |
var screenRows = 0; |
| 11186 |
var fold = null; |
| 11187 |
if (!this.$useWrapMode) { |
| 11188 |
screenRows = this.getLength(); |
| 11189 |
var foldData = this.$foldData; |
| 11190 |
for (var i = 0; i < foldData.length; i++) { |
| 11191 |
fold = foldData[i]; |
| 11192 |
screenRows -= fold.end.row - fold.start.row; |
| 11193 |
} |
| 11194 |
} |
| 11195 |
else { |
| 11196 |
var lastRow = this.$wrapData.length; |
| 11197 |
var row = 0, i = 0; |
| 11198 |
var fold = this.$foldData[i++]; |
| 11199 |
var foldStart = fold ? fold.start.row : Infinity; |
| 11200 |
while (row < lastRow) { |
| 11201 |
var splits = this.$wrapData[row]; |
| 11202 |
screenRows += splits ? splits.length + 1 : 1; |
| 11203 |
row++; |
| 11204 |
if (row > foldStart) { |
| 11205 |
row = fold.end.row + 1; |
| 11206 |
fold = this.$foldData[i++]; |
| 11207 |
foldStart = fold ? fold.start.row : Infinity; |
| 11208 |
} |
| 11209 |
} |
| 11210 |
} |
| 11211 |
if (this.lineWidgets) |
| 11212 |
screenRows += this.$getWidgetScreenLength(); |
| 11213 |
return screenRows; |
| 11214 |
}; |
| 11215 |
EditSession.prototype.$setFontMetrics = function (fm) { |
| 11216 |
if (!this.$enableVarChar) |
| 11217 |
return; |
| 11218 |
this.$getStringScreenWidth = function (str, maxScreenColumn, screenColumn) { |
| 11219 |
if (maxScreenColumn === 0) |
| 11220 |
return [0, 0]; |
| 11221 |
if (!maxScreenColumn) |
| 11222 |
maxScreenColumn = Infinity; |
| 11223 |
screenColumn = screenColumn || 0; |
| 11224 |
var c, column; |
| 11225 |
for (column = 0; column < str.length; column++) { |
| 11226 |
c = str.charAt(column); |
| 11227 |
if (c === "\t") { |
| 11228 |
screenColumn += this.getScreenTabSize(screenColumn); |
| 11229 |
} |
| 11230 |
else { |
| 11231 |
screenColumn += fm.getCharacterWidth(c); |
| 11232 |
} |
| 11233 |
if (screenColumn > maxScreenColumn) { |
| 11234 |
break; |
| 11235 |
} |
| 11236 |
} |
| 11237 |
return [screenColumn, column]; |
| 11238 |
}; |
| 11239 |
}; |
| 11240 |
EditSession.prototype.destroy = function () { |
| 11241 |
if (!this.destroyed) { |
| 11242 |
this.bgTokenizer.setDocument(null); |
| 11243 |
this.bgTokenizer.cleanup(); |
| 11244 |
this.destroyed = true; |
| 11245 |
} |
| 11246 |
this.$stopWorker(); |
| 11247 |
this.removeAllListeners(); |
| 11248 |
if (this.doc) { |
| 11249 |
this.doc.off("change", this.$onChange); |
| 11250 |
} |
| 11251 |
this.selection.detach(); |
| 11252 |
}; |
| 11253 |
return EditSession; |
| 11254 |
}()); |
| 11255 |
EditSession.$uid = 0; |
| 11256 |
EditSession.prototype.$modes = config.$modes; |
| 11257 |
EditSession.prototype.getValue = EditSession.prototype.toString; |
| 11258 |
EditSession.prototype.$defaultUndoManager = { |
| 11259 |
undo: function () { }, |
| 11260 |
redo: function () { }, |
| 11261 |
hasUndo: function () { }, |
| 11262 |
hasRedo: function () { }, |
| 11263 |
reset: function () { }, |
| 11264 |
add: function () { }, |
| 11265 |
addSelection: function () { }, |
| 11266 |
startNewGroup: function () { }, |
| 11267 |
addSession: function () { } |
| 11268 |
}; |
| 11269 |
EditSession.prototype.$overwrite = false; |
| 11270 |
EditSession.prototype.$mode = null; |
| 11271 |
EditSession.prototype.$modeId = null; |
| 11272 |
EditSession.prototype.$scrollTop = 0; |
| 11273 |
EditSession.prototype.$scrollLeft = 0; |
| 11274 |
EditSession.prototype.$wrapLimit = 80; |
| 11275 |
EditSession.prototype.$useWrapMode = false; |
| 11276 |
EditSession.prototype.$wrapLimitRange = { |
| 11277 |
min: null, |
| 11278 |
max: null |
| 11279 |
}; |
| 11280 |
EditSession.prototype.lineWidgets = null; |
| 11281 |
EditSession.prototype.isFullWidth = isFullWidth; |
| 11282 |
oop.implement(EditSession.prototype, EventEmitter); |
| 11283 |
var CHAR = 1, CHAR_EXT = 2, PLACEHOLDER_START = 3, PLACEHOLDER_BODY = 4, PUNCTUATION = 9, SPACE = 10, TAB = 11, TAB_SPACE = 12; |
| 11284 |
function isFullWidth(c) { |
| 11285 |
if (c < 0x1100) |
| 11286 |
return false; |
| 11287 |
return c >= 0x1100 && c <= 0x115F || |
| 11288 |
c >= 0x11A3 && c <= 0x11A7 || |
| 11289 |
c >= 0x11FA && c <= 0x11FF || |
| 11290 |
c >= 0x2329 && c <= 0x232A || |
| 11291 |
c >= 0x2E80 && c <= 0x2E99 || |
| 11292 |
c >= 0x2E9B && c <= 0x2EF3 || |
| 11293 |
c >= 0x2F00 && c <= 0x2FD5 || |
| 11294 |
c >= 0x2FF0 && c <= 0x2FFB || |
| 11295 |
c >= 0x3000 && c <= 0x303E || |
| 11296 |
c >= 0x3041 && c <= 0x3096 || |
| 11297 |
c >= 0x3099 && c <= 0x30FF || |
| 11298 |
c >= 0x3105 && c <= 0x312D || |
| 11299 |
c >= 0x3131 && c <= 0x318E || |
| 11300 |
c >= 0x3190 && c <= 0x31BA || |
| 11301 |
c >= 0x31C0 && c <= 0x31E3 || |
| 11302 |
c >= 0x31F0 && c <= 0x321E || |
| 11303 |
c >= 0x3220 && c <= 0x3247 || |
| 11304 |
c >= 0x3250 && c <= 0x32FE || |
| 11305 |
c >= 0x3300 && c <= 0x4DBF || |
| 11306 |
c >= 0x4E00 && c <= 0xA48C || |
| 11307 |
c >= 0xA490 && c <= 0xA4C6 || |
| 11308 |
c >= 0xA960 && c <= 0xA97C || |
| 11309 |
c >= 0xAC00 && c <= 0xD7A3 || |
| 11310 |
c >= 0xD7B0 && c <= 0xD7C6 || |
| 11311 |
c >= 0xD7CB && c <= 0xD7FB || |
| 11312 |
c >= 0xF900 && c <= 0xFAFF || |
| 11313 |
c >= 0xFE10 && c <= 0xFE19 || |
| 11314 |
c >= 0xFE30 && c <= 0xFE52 || |
| 11315 |
c >= 0xFE54 && c <= 0xFE66 || |
| 11316 |
c >= 0xFE68 && c <= 0xFE6B || |
| 11317 |
c >= 0xFF01 && c <= 0xFF60 || |
| 11318 |
c >= 0xFFE0 && c <= 0xFFE6; |
| 11319 |
} |
| 11320 |
require("./edit_session/folding").Folding.call(EditSession.prototype); |
| 11321 |
require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype); |
| 11322 |
config.defineOptions(EditSession.prototype, "session", { |
| 11323 |
wrap: { |
| 11324 |
set: function (value) { |
| 11325 |
if (!value || value == "off") |
| 11326 |
value = false; |
| 11327 |
else if (value == "free") |
| 11328 |
value = true; |
| 11329 |
else if (value == "printMargin") |
| 11330 |
value = -1; |
| 11331 |
else if (typeof value == "string") |
| 11332 |
value = parseInt(value, 10) || false; |
| 11333 |
if (this.$wrap == value) |
| 11334 |
return; |
| 11335 |
this.$wrap = value; |
| 11336 |
if (!value) { |
| 11337 |
this.setUseWrapMode(false); |
| 11338 |
} |
| 11339 |
else { |
| 11340 |
var col = typeof value == "number" ? value : null; |
| 11341 |
this.setWrapLimitRange(col, col); |
| 11342 |
this.setUseWrapMode(true); |
| 11343 |
} |
| 11344 |
}, |
| 11345 |
get: function () { |
| 11346 |
if (this.getUseWrapMode()) { |
| 11347 |
if (this.$wrap == -1) |
| 11348 |
return "printMargin"; |
| 11349 |
if (!this.getWrapLimitRange().min) |
| 11350 |
return "free"; |
| 11351 |
return this.$wrap; |
| 11352 |
} |
| 11353 |
return "off"; |
| 11354 |
}, |
| 11355 |
handlesSet: true |
| 11356 |
}, |
| 11357 |
wrapMethod: { |
| 11358 |
set: function (val) { |
| 11359 |
val = val == "auto" |
| 11360 |
? this.$mode.type != "text" |
| 11361 |
: val != "text"; |
| 11362 |
if (val != this.$wrapAsCode) { |
| 11363 |
this.$wrapAsCode = val; |
| 11364 |
if (this.$useWrapMode) { |
| 11365 |
this.$useWrapMode = false; |
| 11366 |
this.setUseWrapMode(true); |
| 11367 |
} |
| 11368 |
} |
| 11369 |
}, |
| 11370 |
initialValue: "auto" |
| 11371 |
}, |
| 11372 |
indentedSoftWrap: { |
| 11373 |
set: function () { |
| 11374 |
if (this.$useWrapMode) { |
| 11375 |
this.$useWrapMode = false; |
| 11376 |
this.setUseWrapMode(true); |
| 11377 |
} |
| 11378 |
}, |
| 11379 |
initialValue: true |
| 11380 |
}, |
| 11381 |
firstLineNumber: { |
| 11382 |
set: function () { this._signal("changeBreakpoint"); }, |
| 11383 |
initialValue: 1 |
| 11384 |
}, |
| 11385 |
useWorker: { |
| 11386 |
set: function (useWorker) { |
| 11387 |
this.$useWorker = useWorker; |
| 11388 |
this.$stopWorker(); |
| 11389 |
if (useWorker) |
| 11390 |
this.$startWorker(); |
| 11391 |
}, |
| 11392 |
initialValue: true |
| 11393 |
}, |
| 11394 |
useSoftTabs: { initialValue: true }, |
| 11395 |
tabSize: { |
| 11396 |
set: function (tabSize) { |
| 11397 |
tabSize = parseInt(tabSize); |
| 11398 |
if (tabSize > 0 && this.$tabSize !== tabSize) { |
| 11399 |
this.$modified = true; |
| 11400 |
this.$rowLengthCache = []; |
| 11401 |
this.$tabSize = tabSize; |
| 11402 |
this._signal("changeTabSize"); |
| 11403 |
} |
| 11404 |
}, |
| 11405 |
initialValue: 4, |
| 11406 |
handlesSet: true |
| 11407 |
}, |
| 11408 |
navigateWithinSoftTabs: { initialValue: false }, |
| 11409 |
foldStyle: { |
| 11410 |
set: function (val) { this.setFoldStyle(val); }, |
| 11411 |
handlesSet: true |
| 11412 |
}, |
| 11413 |
overwrite: { |
| 11414 |
set: function (val) { this._signal("changeOverwrite"); }, |
| 11415 |
initialValue: false |
| 11416 |
}, |
| 11417 |
newLineMode: { |
| 11418 |
set: function (val) { this.doc.setNewLineMode(val); }, |
| 11419 |
get: function () { return this.doc.getNewLineMode(); }, |
| 11420 |
handlesSet: true |
| 11421 |
}, |
| 11422 |
mode: { |
| 11423 |
set: function (val) { this.setMode(val); }, |
| 11424 |
get: function () { return this.$modeId; }, |
| 11425 |
handlesSet: true |
| 11426 |
} |
| 11427 |
}); |
| 11428 |
exports.EditSession = EditSession; |
| 11429 |
|
| 11430 |
}); |
| 11431 |
|
| 11432 |
ace.define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module){"use strict"; |
| 11433 |
var lang = require("./lib/lang"); |
| 11434 |
var oop = require("./lib/oop"); |
| 11435 |
var Range = require("./range").Range; |
| 11436 |
var Search = (function () { |
| 11437 |
function Search() { |
| 11438 |
this.$options = {}; |
| 11439 |
} |
| 11440 |
Search.prototype.set = function (options) { |
| 11441 |
oop.mixin(this.$options, options); |
| 11442 |
return this; |
| 11443 |
}; |
| 11444 |
Search.prototype.getOptions = function () { |
| 11445 |
return lang.copyObject(this.$options); |
| 11446 |
}; |
| 11447 |
Search.prototype.setOptions = function (options) { |
| 11448 |
this.$options = options; |
| 11449 |
}; |
| 11450 |
Search.prototype.find = function (session) { |
| 11451 |
var options = this.$options; |
| 11452 |
var iterator = this.$matchIterator(session, options); |
| 11453 |
if (!iterator) |
| 11454 |
return false; |
| 11455 |
var firstRange = null; |
| 11456 |
iterator.forEach(function (sr, sc, er, ec) { |
| 11457 |
firstRange = new Range(sr, sc, er, ec); |
| 11458 |
if (sc == ec && options.start && (options.start).start |
| 11459 |
&& options.skipCurrent != false && firstRange.isEqual( (options.start))) { |
| 11460 |
firstRange = null; |
| 11461 |
return false; |
| 11462 |
} |
| 11463 |
return true; |
| 11464 |
}); |
| 11465 |
return firstRange; |
| 11466 |
}; |
| 11467 |
Search.prototype.findAll = function (session) { |
| 11468 |
var options = this.$options; |
| 11469 |
if (!options.needle) |
| 11470 |
return []; |
| 11471 |
this.$assembleRegExp(options); |
| 11472 |
var range = options.range; |
| 11473 |
var lines = range |
| 11474 |
? session.getLines(range.start.row, range.end.row) |
| 11475 |
: session.doc.getAllLines(); |
| 11476 |
var ranges = []; |
| 11477 |
var re = options.re; |
| 11478 |
if (options.$isMultiLine) { |
| 11479 |
var len = re.length; |
| 11480 |
var maxRow = lines.length - len; |
| 11481 |
var prevRange; |
| 11482 |
outer: for (var row = re.offset || 0; row <= maxRow; row++) { |
| 11483 |
for (var j = 0; j < len; j++) |
| 11484 |
if (lines[row + j].search(re[j]) == -1) |
| 11485 |
continue outer; |
| 11486 |
var startLine = lines[row]; |
| 11487 |
var line = lines[row + len - 1]; |
| 11488 |
var startIndex = startLine.length - startLine.match(re[0])[0].length; |
| 11489 |
var endIndex = line.match(re[len - 1])[0].length; |
| 11490 |
if (prevRange && prevRange.end.row === row && |
| 11491 |
prevRange.end.column > startIndex) { |
| 11492 |
continue; |
| 11493 |
} |
| 11494 |
ranges.push(prevRange = new Range(row, startIndex, row + len - 1, endIndex)); |
| 11495 |
if (len > 2) |
| 11496 |
row = row + len - 2; |
| 11497 |
} |
| 11498 |
} |
| 11499 |
else { |
| 11500 |
for (var i = 0; i < lines.length; i++) { |
| 11501 |
var matches = lang.getMatchOffsets(lines[i], re); |
| 11502 |
for (var j = 0; j < matches.length; j++) { |
| 11503 |
var match = matches[j]; |
| 11504 |
ranges.push(new Range(i, match.offset, i, match.offset + match.length)); |
| 11505 |
} |
| 11506 |
} |
| 11507 |
} |
| 11508 |
if (range) { |
| 11509 |
var startColumn = range.start.column; |
| 11510 |
var endColumn = range.end.column; |
| 11511 |
var i = 0, j = ranges.length - 1; |
| 11512 |
while (i < j && ranges[i].start.column < startColumn && ranges[i].start.row == 0) |
| 11513 |
i++; |
| 11514 |
var endRow = range.end.row - range.start.row; |
| 11515 |
while (i < j && ranges[j].end.column > endColumn && ranges[j].end.row == endRow) |
| 11516 |
j--; |
| 11517 |
ranges = ranges.slice(i, j + 1); |
| 11518 |
for (i = 0, j = ranges.length; i < j; i++) { |
| 11519 |
ranges[i].start.row += range.start.row; |
| 11520 |
ranges[i].end.row += range.start.row; |
| 11521 |
} |
| 11522 |
} |
| 11523 |
return ranges; |
| 11524 |
}; |
| 11525 |
Search.prototype.replace = function (input, replacement) { |
| 11526 |
var options = this.$options; |
| 11527 |
var re = this.$assembleRegExp(options); |
| 11528 |
if (options.$isMultiLine) |
| 11529 |
return replacement; |
| 11530 |
if (!re) |
| 11531 |
return; |
| 11532 |
var match = re.exec(input); |
| 11533 |
if (!match || match[0].length != input.length) |
| 11534 |
return null; |
| 11535 |
if (!options.regExp) { |
| 11536 |
replacement = replacement.replace(/\$/g, "$$$$"); |
| 11537 |
} |
| 11538 |
replacement = input.replace(re, replacement); |
| 11539 |
if (options.preserveCase) { |
| 11540 |
replacement = replacement.split(""); |
| 11541 |
for (var i = Math.min(input.length, input.length); i--;) { |
| 11542 |
var ch = input[i]; |
| 11543 |
if (ch && ch.toLowerCase() != ch) |
| 11544 |
replacement[i] = replacement[i].toUpperCase(); |
| 11545 |
else |
| 11546 |
replacement[i] = replacement[i].toLowerCase(); |
| 11547 |
} |
| 11548 |
replacement = replacement.join(""); |
| 11549 |
} |
| 11550 |
return replacement; |
| 11551 |
}; |
| 11552 |
Search.prototype.$assembleRegExp = function (options, $disableFakeMultiline) { |
| 11553 |
if (options.needle instanceof RegExp) |
| 11554 |
return options.re = options.needle; |
| 11555 |
var needle = options.needle; |
| 11556 |
if (!options.needle) |
| 11557 |
return options.re = false; |
| 11558 |
if (!options.regExp) |
| 11559 |
needle = lang.escapeRegExp(needle); |
| 11560 |
var modifier = options.caseSensitive ? "gm" : "gmi"; |
| 11561 |
try { |
| 11562 |
new RegExp(needle, "u"); |
| 11563 |
options.$supportsUnicodeFlag = true; |
| 11564 |
modifier += "u"; |
| 11565 |
} |
| 11566 |
catch (e) { |
| 11567 |
options.$supportsUnicodeFlag = false; |
| 11568 |
} |
| 11569 |
if (options.wholeWord) |
| 11570 |
needle = addWordBoundary(needle, options); |
| 11571 |
options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle); |
| 11572 |
if (options.$isMultiLine) |
| 11573 |
return options.re = this.$assembleMultilineRegExp(needle, modifier); |
| 11574 |
try { |
| 11575 |
var re = new RegExp(needle, modifier); |
| 11576 |
} |
| 11577 |
catch (e) { |
| 11578 |
re = false; |
| 11579 |
} |
| 11580 |
return options.re = re; |
| 11581 |
}; |
| 11582 |
Search.prototype.$assembleMultilineRegExp = function (needle, modifier) { |
| 11583 |
var parts = needle.replace(/\r\n|\r|\n/g, "$\n^").split("\n"); |
| 11584 |
var re = []; |
| 11585 |
for (var i = 0; i < parts.length; i++) |
| 11586 |
try { |
| 11587 |
re.push(new RegExp(parts[i], modifier)); |
| 11588 |
} |
| 11589 |
catch (e) { |
| 11590 |
return false; |
| 11591 |
} |
| 11592 |
return re; |
| 11593 |
}; |
| 11594 |
Search.prototype.$matchIterator = function (session, options) { |
| 11595 |
var re = this.$assembleRegExp(options); |
| 11596 |
if (!re) |
| 11597 |
return false; |
| 11598 |
var backwards = options.backwards == true; |
| 11599 |
var skipCurrent = options.skipCurrent != false; |
| 11600 |
var supportsUnicodeFlag = re.unicode; |
| 11601 |
var range = options.range; |
| 11602 |
var start = options.start; |
| 11603 |
if (!start) |
| 11604 |
start = range ? range[backwards ? "end" : "start"] : session.selection.getRange(); |
| 11605 |
if (start.start) |
| 11606 |
start = start[skipCurrent != backwards ? "end" : "start"]; |
| 11607 |
var firstRow = range ? range.start.row : 0; |
| 11608 |
var lastRow = range ? range.end.row : session.getLength() - 1; |
| 11609 |
if (backwards) { |
| 11610 |
var forEach = function (callback) { |
| 11611 |
var row = start.row; |
| 11612 |
if (forEachInLine(row, start.column, callback)) |
| 11613 |
return; |
| 11614 |
for (row--; row >= firstRow; row--) |
| 11615 |
if (forEachInLine(row, Number.MAX_VALUE, callback)) |
| 11616 |
return; |
| 11617 |
if (options.wrap == false) |
| 11618 |
return; |
| 11619 |
for (row = lastRow, firstRow = start.row; row >= firstRow; row--) |
| 11620 |
if (forEachInLine(row, Number.MAX_VALUE, callback)) |
| 11621 |
return; |
| 11622 |
}; |
| 11623 |
} |
| 11624 |
else { |
| 11625 |
var forEach = function (callback) { |
| 11626 |
var row = start.row; |
| 11627 |
if (forEachInLine(row, start.column, callback)) |
| 11628 |
return; |
| 11629 |
for (row = row + 1; row <= lastRow; row++) |
| 11630 |
if (forEachInLine(row, 0, callback)) |
| 11631 |
return; |
| 11632 |
if (options.wrap == false) |
| 11633 |
return; |
| 11634 |
for (row = firstRow, lastRow = start.row; row <= lastRow; row++) |
| 11635 |
if (forEachInLine(row, 0, callback)) |
| 11636 |
return; |
| 11637 |
}; |
| 11638 |
} |
| 11639 |
if (options.$isMultiLine) { |
| 11640 |
var len = re.length; |
| 11641 |
var forEachInLine = function (row, offset, callback) { |
| 11642 |
var startRow = backwards ? row - len + 1 : row; |
| 11643 |
if (startRow < 0 || startRow + len > session.getLength()) |
| 11644 |
return; |
| 11645 |
var line = session.getLine(startRow); |
| 11646 |
var startIndex = line.search(re[0]); |
| 11647 |
if (!backwards && startIndex < offset || startIndex === -1) |
| 11648 |
return; |
| 11649 |
for (var i = 1; i < len; i++) { |
| 11650 |
line = session.getLine(startRow + i); |
| 11651 |
if (line.search(re[i]) == -1) |
| 11652 |
return; |
| 11653 |
} |
| 11654 |
var endIndex = line.match(re[len - 1])[0].length; |
| 11655 |
if (backwards && endIndex > offset) |
| 11656 |
return; |
| 11657 |
if (callback(startRow, startIndex, startRow + len - 1, endIndex)) |
| 11658 |
return true; |
| 11659 |
}; |
| 11660 |
} |
| 11661 |
else if (backwards) { |
| 11662 |
var forEachInLine = function (row, endIndex, callback) { |
| 11663 |
var line = session.getLine(row); |
| 11664 |
var matches = []; |
| 11665 |
var m, last = 0; |
| 11666 |
re.lastIndex = 0; |
| 11667 |
while ((m = re.exec(line))) { |
| 11668 |
var length = m[0].length; |
| 11669 |
last = m.index; |
| 11670 |
if (!length) { |
| 11671 |
if (last >= line.length) |
| 11672 |
break; |
| 11673 |
re.lastIndex = last += lang.skipEmptyMatch(line, last, supportsUnicodeFlag); |
| 11674 |
} |
| 11675 |
if (m.index + length > endIndex) |
| 11676 |
break; |
| 11677 |
matches.push(m.index, length); |
| 11678 |
} |
| 11679 |
for (var i = matches.length - 1; i >= 0; i -= 2) { |
| 11680 |
var column = matches[i - 1]; |
| 11681 |
var length = matches[i]; |
| 11682 |
if (callback(row, column, row, column + length)) |
| 11683 |
return true; |
| 11684 |
} |
| 11685 |
}; |
| 11686 |
} |
| 11687 |
else { |
| 11688 |
var forEachInLine = function (row, startIndex, callback) { |
| 11689 |
var line = session.getLine(row); |
| 11690 |
var last; |
| 11691 |
var m; |
| 11692 |
re.lastIndex = startIndex; |
| 11693 |
while ((m = re.exec(line))) { |
| 11694 |
var length = m[0].length; |
| 11695 |
last = m.index; |
| 11696 |
if (callback(row, last, row, last + length)) |
| 11697 |
return true; |
| 11698 |
if (!length) { |
| 11699 |
re.lastIndex = last += lang.skipEmptyMatch(line, last, supportsUnicodeFlag); |
| 11700 |
if (last >= line.length) |
| 11701 |
return false; |
| 11702 |
} |
| 11703 |
} |
| 11704 |
}; |
| 11705 |
} |
| 11706 |
return { forEach: forEach }; |
| 11707 |
}; |
| 11708 |
return Search; |
| 11709 |
}()); |
| 11710 |
function addWordBoundary(needle, options) { |
| 11711 |
var supportsLookbehind = lang.supportsLookbehind(); |
| 11712 |
function wordBoundary(c, firstChar) { |
| 11713 |
if (firstChar === void 0) { firstChar = true; } |
| 11714 |
var wordRegExp = supportsLookbehind && options.$supportsUnicodeFlag ? new RegExp("[\\p{L}\\p{N}_]", "u") : new RegExp("\\w"); |
| 11715 |
if (wordRegExp.test(c) || options.regExp) { |
| 11716 |
if (supportsLookbehind && options.$supportsUnicodeFlag) { |
| 11717 |
if (firstChar) |
| 11718 |
return "(?<=^|[^\\p{L}\\p{N}_])"; |
| 11719 |
return "(?=[^\\p{L}\\p{N}_]|$)"; |
| 11720 |
} |
| 11721 |
return "\\b"; |
| 11722 |
} |
| 11723 |
return ""; |
| 11724 |
} |
| 11725 |
var needleArray = Array.from(needle); |
| 11726 |
var firstChar = needleArray[0]; |
| 11727 |
var lastChar = needleArray[needleArray.length - 1]; |
| 11728 |
return wordBoundary(firstChar) + needle + wordBoundary(lastChar, false); |
| 11729 |
} |
| 11730 |
exports.Search = Search; |
| 11731 |
|
| 11732 |
}); |
| 11733 |
|
| 11734 |
ace.define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module){"use strict"; |
| 11735 |
var __extends = (this && this.__extends) || (function () { |
| 11736 |
var extendStatics = function (d, b) { |
| 11737 |
extendStatics = Object.setPrototypeOf || |
| 11738 |
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
| 11739 |
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; |
| 11740 |
return extendStatics(d, b); |
| 11741 |
}; |
| 11742 |
return function (d, b) { |
| 11743 |
if (typeof b !== "function" && b !== null) |
| 11744 |
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); |
| 11745 |
extendStatics(d, b); |
| 11746 |
function __() { this.constructor = d; } |
| 11747 |
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
| 11748 |
}; |
| 11749 |
})(); var keyUtil = require("../lib/keys"); |
| 11750 |
var useragent = require("../lib/useragent"); |
| 11751 |
var KEY_MODS = keyUtil.KEY_MODS; |
| 11752 |
var MultiHashHandler = (function () { |
| 11753 |
function MultiHashHandler(config, platform) { |
| 11754 |
this.$init(config, platform, false); |
| 11755 |
} |
| 11756 |
MultiHashHandler.prototype.$init = function (config, platform, $singleCommand) { |
| 11757 |
this.platform = platform || (useragent.isMac ? "mac" : "win"); |
| 11758 |
this.commands = {}; |
| 11759 |
this.commandKeyBinding = {}; |
| 11760 |
this.addCommands(config); |
| 11761 |
this.$singleCommand = $singleCommand; |
| 11762 |
}; |
| 11763 |
MultiHashHandler.prototype.addCommand = function (command) { |
| 11764 |
if (this.commands[command.name]) |
| 11765 |
this.removeCommand(command); |
| 11766 |
this.commands[command.name] = command; |
| 11767 |
if (command.bindKey) |
| 11768 |
this._buildKeyHash(command); |
| 11769 |
}; |
| 11770 |
MultiHashHandler.prototype.removeCommand = function (command, keepCommand) { |
| 11771 |
var name = command && (typeof command === 'string' ? command : command.name); |
| 11772 |
command = this.commands[name]; |
| 11773 |
if (!keepCommand) |
| 11774 |
delete this.commands[name]; |
| 11775 |
var ckb = this.commandKeyBinding; |
| 11776 |
for (var keyId in ckb) { |
| 11777 |
var cmdGroup = ckb[keyId]; |
| 11778 |
if (cmdGroup == command) { |
| 11779 |
delete ckb[keyId]; |
| 11780 |
} |
| 11781 |
else if (Array.isArray(cmdGroup)) { |
| 11782 |
var i = cmdGroup.indexOf(command); |
| 11783 |
if (i != -1) { |
| 11784 |
cmdGroup.splice(i, 1); |
| 11785 |
if (cmdGroup.length == 1) |
| 11786 |
ckb[keyId] = cmdGroup[0]; |
| 11787 |
} |
| 11788 |
} |
| 11789 |
} |
| 11790 |
}; |
| 11791 |
MultiHashHandler.prototype.bindKey = function (key, command, position) { |
| 11792 |
if (typeof key == "object" && key) { |
| 11793 |
if (position == undefined) |
| 11794 |
position = key.position; |
| 11795 |
key = key[this.platform]; |
| 11796 |
} |
| 11797 |
if (!key) |
| 11798 |
return; |
| 11799 |
if (typeof command == "function") |
| 11800 |
return this.addCommand({ exec: command, bindKey: key, name: command.name || (key) }); (key).split("|").forEach(function (keyPart) { |
| 11801 |
var chain = ""; |
| 11802 |
if (keyPart.indexOf(" ") != -1) { |
| 11803 |
var parts = keyPart.split(/\s+/); |
| 11804 |
keyPart = parts.pop(); |
| 11805 |
parts.forEach(function (keyPart) { |
| 11806 |
var binding = this.parseKeys(keyPart); |
| 11807 |
var id = KEY_MODS[binding.hashId] + binding.key; |
| 11808 |
chain += (chain ? " " : "") + id; |
| 11809 |
this._addCommandToBinding(chain, "chainKeys"); |
| 11810 |
}, this); |
| 11811 |
chain += " "; |
| 11812 |
} |
| 11813 |
var binding = this.parseKeys(keyPart); |
| 11814 |
var id = KEY_MODS[binding.hashId] + binding.key; |
| 11815 |
this._addCommandToBinding(chain + id, command, position); |
| 11816 |
}, this); |
| 11817 |
}; |
| 11818 |
MultiHashHandler.prototype._addCommandToBinding = function (keyId, command, position) { |
| 11819 |
var ckb = this.commandKeyBinding, i; |
| 11820 |
if (!command) { |
| 11821 |
delete ckb[keyId]; |
| 11822 |
} |
| 11823 |
else if (!ckb[keyId] || this.$singleCommand) { |
| 11824 |
ckb[keyId] = command; |
| 11825 |
} |
| 11826 |
else { |
| 11827 |
if (!Array.isArray(ckb[keyId])) { |
| 11828 |
ckb[keyId] = [ckb[keyId]]; |
| 11829 |
} |
| 11830 |
else if ((i = ckb[keyId].indexOf(command)) != -1) { |
| 11831 |
ckb[keyId].splice(i, 1); |
| 11832 |
} |
| 11833 |
if (typeof position != "number") { |
| 11834 |
position = getPosition(command); |
| 11835 |
} |
| 11836 |
var commands = ckb[keyId]; |
| 11837 |
for (i = 0; i < commands.length; i++) { |
| 11838 |
var other = commands[i]; |
| 11839 |
var otherPos = getPosition(other); |
| 11840 |
if (otherPos > position) |
| 11841 |
break; |
| 11842 |
} |
| 11843 |
commands.splice(i, 0, command); |
| 11844 |
} |
| 11845 |
}; |
| 11846 |
MultiHashHandler.prototype.addCommands = function (commands) { |
| 11847 |
commands && Object.keys(commands).forEach(function (name) { |
| 11848 |
var command = commands[name]; |
| 11849 |
if (!command) |
| 11850 |
return; |
| 11851 |
if (typeof command === "string") |
| 11852 |
return this.bindKey(command, name); |
| 11853 |
if (typeof command === "function") |
| 11854 |
command = { exec: command }; |
| 11855 |
if (typeof command !== "object") |
| 11856 |
return; |
| 11857 |
if (!command.name) |
| 11858 |
command.name = name; |
| 11859 |
this.addCommand(command); |
| 11860 |
}, this); |
| 11861 |
}; |
| 11862 |
MultiHashHandler.prototype.removeCommands = function (commands) { |
| 11863 |
Object.keys(commands).forEach(function (name) { |
| 11864 |
this.removeCommand(commands[name]); |
| 11865 |
}, this); |
| 11866 |
}; |
| 11867 |
MultiHashHandler.prototype.bindKeys = function (keyList) { |
| 11868 |
Object.keys(keyList).forEach(function (key) { |
| 11869 |
this.bindKey(key, keyList[key]); |
| 11870 |
}, this); |
| 11871 |
}; |
| 11872 |
MultiHashHandler.prototype._buildKeyHash = function (command) { |
| 11873 |
this.bindKey(command.bindKey, command); |
| 11874 |
}; |
| 11875 |
MultiHashHandler.prototype.parseKeys = function (keys) { |
| 11876 |
var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function (x) { return x; }); |
| 11877 |
var key = parts.pop(); |
| 11878 |
var keyCode = keyUtil[key]; |
| 11879 |
if (keyUtil.FUNCTION_KEYS[keyCode]) |
| 11880 |
key = keyUtil.FUNCTION_KEYS[keyCode].toLowerCase(); |
| 11881 |
else if (!parts.length) |
| 11882 |
return { key: key, hashId: -1 }; |
| 11883 |
else if (parts.length == 1 && parts[0] == "shift") |
| 11884 |
return { key: key.toUpperCase(), hashId: -1 }; |
| 11885 |
var hashId = 0; |
| 11886 |
for (var i = parts.length; i--;) { |
| 11887 |
var modifier = keyUtil.KEY_MODS[parts[i]]; |
| 11888 |
if (modifier == null) { |
| 11889 |
if (typeof console != "undefined") |
| 11890 |
console.error("invalid modifier " + parts[i] + " in " + keys); |
| 11891 |
return false; |
| 11892 |
} |
| 11893 |
hashId |= modifier; |
| 11894 |
} |
| 11895 |
return { key: key, hashId: hashId }; |
| 11896 |
}; |
| 11897 |
MultiHashHandler.prototype.findKeyCommand = function (hashId, keyString) { |
| 11898 |
var key = KEY_MODS[hashId] + keyString; |
| 11899 |
return this.commandKeyBinding[key]; |
| 11900 |
}; |
| 11901 |
MultiHashHandler.prototype.handleKeyboard = function (data, hashId, keyString, keyCode) { |
| 11902 |
if (keyCode < 0) |
| 11903 |
return; |
| 11904 |
var key = KEY_MODS[hashId] + keyString; |
| 11905 |
var command = this.commandKeyBinding[key]; |
| 11906 |
if (data.$keyChain) { |
| 11907 |
data.$keyChain += " " + key; |
| 11908 |
command = this.commandKeyBinding[data.$keyChain] || command; |
| 11909 |
} |
| 11910 |
if (command) { |
| 11911 |
if (command == "chainKeys" || command[command.length - 1] == "chainKeys") { |
| 11912 |
data.$keyChain = data.$keyChain || key; |
| 11913 |
return { command: "null" }; |
| 11914 |
} |
| 11915 |
} |
| 11916 |
if (data.$keyChain) { |
| 11917 |
if ((!hashId || hashId == 4) && keyString.length == 1) |
| 11918 |
data.$keyChain = data.$keyChain.slice(0, -key.length - 1); |
| 11919 |
else if (hashId == -1 || keyCode > 0) |
| 11920 |
data.$keyChain = ""; |
| 11921 |
} |
| 11922 |
return { command: command }; |
| 11923 |
}; |
| 11924 |
MultiHashHandler.prototype.getStatusText = function (editor, data) { |
| 11925 |
return data.$keyChain || ""; |
| 11926 |
}; |
| 11927 |
return MultiHashHandler; |
| 11928 |
}()); |
| 11929 |
function getPosition(command) { |
| 11930 |
return typeof command == "object" && command.bindKey |
| 11931 |
&& command.bindKey.position |
| 11932 |
|| (command.isDefault ? -100 : 0); |
| 11933 |
} |
| 11934 |
var HashHandler = (function (_super) { |
| 11935 |
__extends(HashHandler, _super); |
| 11936 |
function HashHandler(config, platform) { |
| 11937 |
var _this = _super.call(this, config, platform) || this; |
| 11938 |
_this.$singleCommand = true; |
| 11939 |
return _this; |
| 11940 |
} |
| 11941 |
return HashHandler; |
| 11942 |
}(MultiHashHandler)); |
| 11943 |
HashHandler.call = function (thisArg, config, platform) { |
| 11944 |
MultiHashHandler.prototype.$init.call(thisArg, config, platform, true); |
| 11945 |
}; |
| 11946 |
MultiHashHandler.call = function (thisArg, config, platform) { |
| 11947 |
MultiHashHandler.prototype.$init.call(thisArg, config, platform, false); |
| 11948 |
}; |
| 11949 |
exports.HashHandler = HashHandler; |
| 11950 |
exports.MultiHashHandler = MultiHashHandler; |
| 11951 |
|
| 11952 |
}); |
| 11953 |
|
| 11954 |
ace.define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"], function(require, exports, module){"use strict"; |
| 11955 |
var __extends = (this && this.__extends) || (function () { |
| 11956 |
var extendStatics = function (d, b) { |
| 11957 |
extendStatics = Object.setPrototypeOf || |
| 11958 |
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
| 11959 |
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; |
| 11960 |
return extendStatics(d, b); |
| 11961 |
}; |
| 11962 |
return function (d, b) { |
| 11963 |
if (typeof b !== "function" && b !== null) |
| 11964 |
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); |
| 11965 |
extendStatics(d, b); |
| 11966 |
function __() { this.constructor = d; } |
| 11967 |
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
| 11968 |
}; |
| 11969 |
})(); |
| 11970 |
var oop = require("../lib/oop"); |
| 11971 |
var MultiHashHandler = require("../keyboard/hash_handler").MultiHashHandler; |
| 11972 |
var EventEmitter = require("../lib/event_emitter").EventEmitter; |
| 11973 |
var CommandManager = (function (_super) { |
| 11974 |
__extends(CommandManager, _super); |
| 11975 |
function CommandManager(platform, commands) { |
| 11976 |
var _this = _super.call(this, commands, platform) || this; |
| 11977 |
_this.byName = _this.commands; |
| 11978 |
_this.setDefaultHandler("exec", function (e) { |
| 11979 |
if (!e.args) { |
| 11980 |
return e.command.exec(e.editor, {}, e.event, true); |
| 11981 |
} |
| 11982 |
return e.command.exec(e.editor, e.args, e.event, false); |
| 11983 |
}); |
| 11984 |
return _this; |
| 11985 |
} |
| 11986 |
CommandManager.prototype.exec = function (command, editor, args) { |
| 11987 |
if (Array.isArray(command)) { |
| 11988 |
for (var i = command.length; i--;) { |
| 11989 |
if (this.exec(command[i], editor, args)) |
| 11990 |
return true; |
| 11991 |
} |
| 11992 |
return false; |
| 11993 |
} |
| 11994 |
if (typeof command === "string") |
| 11995 |
command = this.commands[command]; |
| 11996 |
if (!command) |
| 11997 |
return false; |
| 11998 |
if (editor && editor.$readOnly && !command.readOnly) |
| 11999 |
return false; |
| 12000 |
if (this.$checkCommandState != false && command.isAvailable && !command.isAvailable(editor)) |
| 12001 |
return false; |
| 12002 |
var e = { editor: editor, command: command, args: args }; |
| 12003 |
e.returnValue = this._emit("exec", e); |
| 12004 |
this._signal("afterExec", e); |
| 12005 |
return e.returnValue === false ? false : true; |
| 12006 |
}; |
| 12007 |
CommandManager.prototype.toggleRecording = function (editor) { |
| 12008 |
if (this.$inReplay) |
| 12009 |
return; |
| 12010 |
editor && editor._emit("changeStatus"); |
| 12011 |
if (this.recording) { |
| 12012 |
this.macro.pop(); |
| 12013 |
this.off("exec", this.$addCommandToMacro); |
| 12014 |
if (!this.macro.length) |
| 12015 |
this.macro = this.oldMacro; |
| 12016 |
return this.recording = false; |
| 12017 |
} |
| 12018 |
if (!this.$addCommandToMacro) { |
| 12019 |
this.$addCommandToMacro = function (e) { |
| 12020 |
this.macro.push([e.command, e.args]); |
| 12021 |
}.bind(this); |
| 12022 |
} |
| 12023 |
this.oldMacro = this.macro; |
| 12024 |
this.macro = []; |
| 12025 |
this.on("exec", this.$addCommandToMacro); |
| 12026 |
return this.recording = true; |
| 12027 |
}; |
| 12028 |
CommandManager.prototype.replay = function (editor) { |
| 12029 |
if (this.$inReplay || !this.macro) |
| 12030 |
return; |
| 12031 |
if (this.recording) |
| 12032 |
return this.toggleRecording(editor); |
| 12033 |
try { |
| 12034 |
this.$inReplay = true; |
| 12035 |
this.macro.forEach(function (x) { |
| 12036 |
if (typeof x == "string") |
| 12037 |
this.exec(x, editor); |
| 12038 |
else |
| 12039 |
this.exec(x[0], editor, x[1]); |
| 12040 |
}, this); |
| 12041 |
} |
| 12042 |
finally { |
| 12043 |
this.$inReplay = false; |
| 12044 |
} |
| 12045 |
}; |
| 12046 |
CommandManager.prototype.trimMacro = function (m) { |
| 12047 |
return m.map(function (x) { |
| 12048 |
if (typeof x[0] != "string") |
| 12049 |
x[0] = x[0].name; |
| 12050 |
if (!x[1]) |
| 12051 |
x = x[0]; |
| 12052 |
return x; |
| 12053 |
}); |
| 12054 |
}; |
| 12055 |
return CommandManager; |
| 12056 |
}(MultiHashHandler)); |
| 12057 |
oop.implement(CommandManager.prototype, EventEmitter); |
| 12058 |
exports.CommandManager = CommandManager; |
| 12059 |
|
| 12060 |
}); |
| 12061 |
|
| 12062 |
ace.define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"], function(require, exports, module){"use strict"; |
| 12063 |
var lang = require("../lib/lang"); |
| 12064 |
var config = require("../config"); |
| 12065 |
var Range = require("../range").Range; |
| 12066 |
function bindKey(win, mac) { |
| 12067 |
return { win: win, mac: mac }; |
| 12068 |
} |
| 12069 |
exports.commands = [{ |
| 12070 |
name: "showSettingsMenu", |
| 12071 |
description: "Show settings menu", |
| 12072 |
bindKey: bindKey("Ctrl-,", "Command-,"), |
| 12073 |
exec: function (editor) { |
| 12074 |
config.loadModule("ace/ext/settings_menu", function (module) { |
| 12075 |
module.init(editor); |
| 12076 |
editor.showSettingsMenu(); |
| 12077 |
}); |
| 12078 |
}, |
| 12079 |
readOnly: true |
| 12080 |
}, { |
| 12081 |
name: "goToNextError", |
| 12082 |
description: "Go to next error", |
| 12083 |
bindKey: bindKey("Alt-E", "F4"), |
| 12084 |
exec: function (editor) { |
| 12085 |
config.loadModule("ace/ext/error_marker", function (module) { |
| 12086 |
module.showErrorMarker(editor, 1); |
| 12087 |
}); |
| 12088 |
}, |
| 12089 |
scrollIntoView: "animate", |
| 12090 |
readOnly: true |
| 12091 |
}, { |
| 12092 |
name: "goToPreviousError", |
| 12093 |
description: "Go to previous error", |
| 12094 |
bindKey: bindKey("Alt-Shift-E", "Shift-F4"), |
| 12095 |
exec: function (editor) { |
| 12096 |
config.loadModule("ace/ext/error_marker", function (module) { |
| 12097 |
module.showErrorMarker(editor, -1); |
| 12098 |
}); |
| 12099 |
}, |
| 12100 |
scrollIntoView: "animate", |
| 12101 |
readOnly: true |
| 12102 |
}, { |
| 12103 |
name: "selectall", |
| 12104 |
description: "Select all", |
| 12105 |
bindKey: bindKey("Ctrl-A", "Command-A"), |
| 12106 |
exec: function (editor) { editor.selectAll(); }, |
| 12107 |
readOnly: true |
| 12108 |
}, { |
| 12109 |
name: "centerselection", |
| 12110 |
description: "Center selection", |
| 12111 |
bindKey: bindKey(null, "Ctrl-L"), |
| 12112 |
exec: function (editor) { editor.centerSelection(); }, |
| 12113 |
readOnly: true |
| 12114 |
}, { |
| 12115 |
name: "gotoline", |
| 12116 |
description: "Go to line...", |
| 12117 |
bindKey: bindKey("Ctrl-L", "Command-L"), |
| 12118 |
exec: function (editor, line) { |
| 12119 |
if (typeof line === "number" && !isNaN(line)) |
| 12120 |
editor.gotoLine(line); |
| 12121 |
editor.prompt({ $type: "gotoLine" }); |
| 12122 |
}, |
| 12123 |
readOnly: true |
| 12124 |
}, { |
| 12125 |
name: "fold", |
| 12126 |
bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"), |
| 12127 |
exec: function (editor) { editor.session.toggleFold(false); }, |
| 12128 |
multiSelectAction: "forEach", |
| 12129 |
scrollIntoView: "center", |
| 12130 |
readOnly: true |
| 12131 |
}, { |
| 12132 |
name: "unfold", |
| 12133 |
bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"), |
| 12134 |
exec: function (editor) { editor.session.toggleFold(true); }, |
| 12135 |
multiSelectAction: "forEach", |
| 12136 |
scrollIntoView: "center", |
| 12137 |
readOnly: true |
| 12138 |
}, { |
| 12139 |
name: "toggleFoldWidget", |
| 12140 |
description: "Toggle fold widget", |
| 12141 |
bindKey: bindKey("F2", "F2"), |
| 12142 |
exec: function (editor) { editor.session.toggleFoldWidget(); }, |
| 12143 |
multiSelectAction: "forEach", |
| 12144 |
scrollIntoView: "center", |
| 12145 |
readOnly: true |
| 12146 |
}, { |
| 12147 |
name: "toggleParentFoldWidget", |
| 12148 |
description: "Toggle parent fold widget", |
| 12149 |
bindKey: bindKey("Alt-F2", "Alt-F2"), |
| 12150 |
exec: function (editor) { editor.session.toggleFoldWidget(true); }, |
| 12151 |
multiSelectAction: "forEach", |
| 12152 |
scrollIntoView: "center", |
| 12153 |
readOnly: true |
| 12154 |
}, { |
| 12155 |
name: "foldall", |
| 12156 |
description: "Fold all", |
| 12157 |
bindKey: bindKey(null, "Ctrl-Command-Option-0"), |
| 12158 |
exec: function (editor) { editor.session.foldAll(); }, |
| 12159 |
scrollIntoView: "center", |
| 12160 |
readOnly: true |
| 12161 |
}, { |
| 12162 |
name: "foldAllComments", |
| 12163 |
description: "Fold all comments", |
| 12164 |
bindKey: bindKey(null, "Ctrl-Command-Option-0"), |
| 12165 |
exec: function (editor) { editor.session.foldAllComments(); }, |
| 12166 |
scrollIntoView: "center", |
| 12167 |
readOnly: true |
| 12168 |
}, { |
| 12169 |
name: "foldOther", |
| 12170 |
description: "Fold other", |
| 12171 |
bindKey: bindKey("Alt-0", "Command-Option-0"), |
| 12172 |
exec: function (editor) { |
| 12173 |
editor.session.foldAll(); |
| 12174 |
editor.session.unfold(editor.selection.getAllRanges()); |
| 12175 |
}, |
| 12176 |
scrollIntoView: "center", |
| 12177 |
readOnly: true |
| 12178 |
}, { |
| 12179 |
name: "unfoldall", |
| 12180 |
description: "Unfold all", |
| 12181 |
bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"), |
| 12182 |
exec: function (editor) { editor.session.unfold(); }, |
| 12183 |
scrollIntoView: "center", |
| 12184 |
readOnly: true |
| 12185 |
}, { |
| 12186 |
name: "findnext", |
| 12187 |
description: "Find next", |
| 12188 |
bindKey: bindKey("Ctrl-K", "Command-G"), |
| 12189 |
exec: function (editor) { editor.findNext(); }, |
| 12190 |
multiSelectAction: "forEach", |
| 12191 |
scrollIntoView: "center", |
| 12192 |
readOnly: true |
| 12193 |
}, { |
| 12194 |
name: "findprevious", |
| 12195 |
description: "Find previous", |
| 12196 |
bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"), |
| 12197 |
exec: function (editor) { editor.findPrevious(); }, |
| 12198 |
multiSelectAction: "forEach", |
| 12199 |
scrollIntoView: "center", |
| 12200 |
readOnly: true |
| 12201 |
}, { |
| 12202 |
name: "selectOrFindNext", |
| 12203 |
description: "Select or find next", |
| 12204 |
bindKey: bindKey("Alt-K", "Ctrl-G"), |
| 12205 |
exec: function (editor) { |
| 12206 |
if (editor.selection.isEmpty()) |
| 12207 |
editor.selection.selectWord(); |
| 12208 |
else |
| 12209 |
editor.findNext(); |
| 12210 |
}, |
| 12211 |
readOnly: true |
| 12212 |
}, { |
| 12213 |
name: "selectOrFindPrevious", |
| 12214 |
description: "Select or find previous", |
| 12215 |
bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"), |
| 12216 |
exec: function (editor) { |
| 12217 |
if (editor.selection.isEmpty()) |
| 12218 |
editor.selection.selectWord(); |
| 12219 |
else |
| 12220 |
editor.findPrevious(); |
| 12221 |
}, |
| 12222 |
readOnly: true |
| 12223 |
}, { |
| 12224 |
name: "find", |
| 12225 |
description: "Find", |
| 12226 |
bindKey: bindKey("Ctrl-F", "Command-F"), |
| 12227 |
exec: function (editor) { |
| 12228 |
config.loadModule("ace/ext/searchbox", function (e) { e.Search(editor); }); |
| 12229 |
}, |
| 12230 |
readOnly: true |
| 12231 |
}, { |
| 12232 |
name: "overwrite", |
| 12233 |
description: "Overwrite", |
| 12234 |
bindKey: "Insert", |
| 12235 |
exec: function (editor) { editor.toggleOverwrite(); }, |
| 12236 |
readOnly: true |
| 12237 |
}, { |
| 12238 |
name: "selecttostart", |
| 12239 |
description: "Select to start", |
| 12240 |
bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Home|Command-Shift-Up"), |
| 12241 |
exec: function (editor) { editor.getSelection().selectFileStart(); }, |
| 12242 |
multiSelectAction: "forEach", |
| 12243 |
readOnly: true, |
| 12244 |
scrollIntoView: "animate", |
| 12245 |
aceCommandGroup: "fileJump" |
| 12246 |
}, { |
| 12247 |
name: "gotostart", |
| 12248 |
description: "Go to start", |
| 12249 |
bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"), |
| 12250 |
exec: function (editor) { editor.navigateFileStart(); }, |
| 12251 |
multiSelectAction: "forEach", |
| 12252 |
readOnly: true, |
| 12253 |
scrollIntoView: "animate", |
| 12254 |
aceCommandGroup: "fileJump" |
| 12255 |
}, { |
| 12256 |
name: "selectup", |
| 12257 |
description: "Select up", |
| 12258 |
bindKey: bindKey("Shift-Up", "Shift-Up|Ctrl-Shift-P"), |
| 12259 |
exec: function (editor) { editor.getSelection().selectUp(); }, |
| 12260 |
multiSelectAction: "forEach", |
| 12261 |
scrollIntoView: "cursor", |
| 12262 |
readOnly: true |
| 12263 |
}, { |
| 12264 |
name: "golineup", |
| 12265 |
description: "Go line up", |
| 12266 |
bindKey: bindKey("Up", "Up|Ctrl-P"), |
| 12267 |
exec: function (editor, args) { editor.navigateUp(args.times); }, |
| 12268 |
multiSelectAction: "forEach", |
| 12269 |
scrollIntoView: "cursor", |
| 12270 |
readOnly: true |
| 12271 |
}, { |
| 12272 |
name: "selecttoend", |
| 12273 |
description: "Select to end", |
| 12274 |
bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-End|Command-Shift-Down"), |
| 12275 |
exec: function (editor) { editor.getSelection().selectFileEnd(); }, |
| 12276 |
multiSelectAction: "forEach", |
| 12277 |
readOnly: true, |
| 12278 |
scrollIntoView: "animate", |
| 12279 |
aceCommandGroup: "fileJump" |
| 12280 |
}, { |
| 12281 |
name: "gotoend", |
| 12282 |
description: "Go to end", |
| 12283 |
bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"), |
| 12284 |
exec: function (editor) { editor.navigateFileEnd(); }, |
| 12285 |
multiSelectAction: "forEach", |
| 12286 |
readOnly: true, |
| 12287 |
scrollIntoView: "animate", |
| 12288 |
aceCommandGroup: "fileJump" |
| 12289 |
}, { |
| 12290 |
name: "selectdown", |
| 12291 |
description: "Select down", |
| 12292 |
bindKey: bindKey("Shift-Down", "Shift-Down|Ctrl-Shift-N"), |
| 12293 |
exec: function (editor) { editor.getSelection().selectDown(); }, |
| 12294 |
multiSelectAction: "forEach", |
| 12295 |
scrollIntoView: "cursor", |
| 12296 |
readOnly: true |
| 12297 |
}, { |
| 12298 |
name: "golinedown", |
| 12299 |
description: "Go line down", |
| 12300 |
bindKey: bindKey("Down", "Down|Ctrl-N"), |
| 12301 |
exec: function (editor, args) { editor.navigateDown(args.times); }, |
| 12302 |
multiSelectAction: "forEach", |
| 12303 |
scrollIntoView: "cursor", |
| 12304 |
readOnly: true |
| 12305 |
}, { |
| 12306 |
name: "selectwordleft", |
| 12307 |
description: "Select word left", |
| 12308 |
bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"), |
| 12309 |
exec: function (editor) { editor.getSelection().selectWordLeft(); }, |
| 12310 |
multiSelectAction: "forEach", |
| 12311 |
scrollIntoView: "cursor", |
| 12312 |
readOnly: true |
| 12313 |
}, { |
| 12314 |
name: "gotowordleft", |
| 12315 |
description: "Go to word left", |
| 12316 |
bindKey: bindKey("Ctrl-Left", "Option-Left"), |
| 12317 |
exec: function (editor) { editor.navigateWordLeft(); }, |
| 12318 |
multiSelectAction: "forEach", |
| 12319 |
scrollIntoView: "cursor", |
| 12320 |
readOnly: true |
| 12321 |
}, { |
| 12322 |
name: "selecttolinestart", |
| 12323 |
description: "Select to line start", |
| 12324 |
bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left|Ctrl-Shift-A"), |
| 12325 |
exec: function (editor) { editor.getSelection().selectLineStart(); }, |
| 12326 |
multiSelectAction: "forEach", |
| 12327 |
scrollIntoView: "cursor", |
| 12328 |
readOnly: true |
| 12329 |
}, { |
| 12330 |
name: "gotolinestart", |
| 12331 |
description: "Go to line start", |
| 12332 |
bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"), |
| 12333 |
exec: function (editor) { editor.navigateLineStart(); }, |
| 12334 |
multiSelectAction: "forEach", |
| 12335 |
scrollIntoView: "cursor", |
| 12336 |
readOnly: true |
| 12337 |
}, { |
| 12338 |
name: "selectleft", |
| 12339 |
description: "Select left", |
| 12340 |
bindKey: bindKey("Shift-Left", "Shift-Left|Ctrl-Shift-B"), |
| 12341 |
exec: function (editor) { editor.getSelection().selectLeft(); }, |
| 12342 |
multiSelectAction: "forEach", |
| 12343 |
scrollIntoView: "cursor", |
| 12344 |
readOnly: true |
| 12345 |
}, { |
| 12346 |
name: "gotoleft", |
| 12347 |
description: "Go to left", |
| 12348 |
bindKey: bindKey("Left", "Left|Ctrl-B"), |
| 12349 |
exec: function (editor, args) { editor.navigateLeft(args.times); }, |
| 12350 |
multiSelectAction: "forEach", |
| 12351 |
scrollIntoView: "cursor", |
| 12352 |
readOnly: true |
| 12353 |
}, { |
| 12354 |
name: "selectwordright", |
| 12355 |
description: "Select word right", |
| 12356 |
bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"), |
| 12357 |
exec: function (editor) { editor.getSelection().selectWordRight(); }, |
| 12358 |
multiSelectAction: "forEach", |
| 12359 |
scrollIntoView: "cursor", |
| 12360 |
readOnly: true |
| 12361 |
}, { |
| 12362 |
name: "gotowordright", |
| 12363 |
description: "Go to word right", |
| 12364 |
bindKey: bindKey("Ctrl-Right", "Option-Right"), |
| 12365 |
exec: function (editor) { editor.navigateWordRight(); }, |
| 12366 |
multiSelectAction: "forEach", |
| 12367 |
scrollIntoView: "cursor", |
| 12368 |
readOnly: true |
| 12369 |
}, { |
| 12370 |
name: "selecttolineend", |
| 12371 |
description: "Select to line end", |
| 12372 |
bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right|Shift-End|Ctrl-Shift-E"), |
| 12373 |
exec: function (editor) { editor.getSelection().selectLineEnd(); }, |
| 12374 |
multiSelectAction: "forEach", |
| 12375 |
scrollIntoView: "cursor", |
| 12376 |
readOnly: true |
| 12377 |
}, { |
| 12378 |
name: "gotolineend", |
| 12379 |
description: "Go to line end", |
| 12380 |
bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"), |
| 12381 |
exec: function (editor) { editor.navigateLineEnd(); }, |
| 12382 |
multiSelectAction: "forEach", |
| 12383 |
scrollIntoView: "cursor", |
| 12384 |
readOnly: true |
| 12385 |
}, { |
| 12386 |
name: "selectright", |
| 12387 |
description: "Select right", |
| 12388 |
bindKey: bindKey("Shift-Right", "Shift-Right"), |
| 12389 |
exec: function (editor) { editor.getSelection().selectRight(); }, |
| 12390 |
multiSelectAction: "forEach", |
| 12391 |
scrollIntoView: "cursor", |
| 12392 |
readOnly: true |
| 12393 |
}, { |
| 12394 |
name: "gotoright", |
| 12395 |
description: "Go to right", |
| 12396 |
bindKey: bindKey("Right", "Right|Ctrl-F"), |
| 12397 |
exec: function (editor, args) { editor.navigateRight(args.times); }, |
| 12398 |
multiSelectAction: "forEach", |
| 12399 |
scrollIntoView: "cursor", |
| 12400 |
readOnly: true |
| 12401 |
}, { |
| 12402 |
name: "selectpagedown", |
| 12403 |
description: "Select page down", |
| 12404 |
bindKey: "Shift-PageDown", |
| 12405 |
exec: function (editor) { editor.selectPageDown(); }, |
| 12406 |
readOnly: true |
| 12407 |
}, { |
| 12408 |
name: "pagedown", |
| 12409 |
description: "Page down", |
| 12410 |
bindKey: bindKey(null, "Option-PageDown"), |
| 12411 |
exec: function (editor) { editor.scrollPageDown(); }, |
| 12412 |
readOnly: true |
| 12413 |
}, { |
| 12414 |
name: "gotopagedown", |
| 12415 |
description: "Go to page down", |
| 12416 |
bindKey: bindKey("PageDown", "PageDown|Ctrl-V"), |
| 12417 |
exec: function (editor) { editor.gotoPageDown(); }, |
| 12418 |
readOnly: true |
| 12419 |
}, { |
| 12420 |
name: "selectpageup", |
| 12421 |
description: "Select page up", |
| 12422 |
bindKey: "Shift-PageUp", |
| 12423 |
exec: function (editor) { editor.selectPageUp(); }, |
| 12424 |
readOnly: true |
| 12425 |
}, { |
| 12426 |
name: "pageup", |
| 12427 |
description: "Page up", |
| 12428 |
bindKey: bindKey(null, "Option-PageUp"), |
| 12429 |
exec: function (editor) { editor.scrollPageUp(); }, |
| 12430 |
readOnly: true |
| 12431 |
}, { |
| 12432 |
name: "gotopageup", |
| 12433 |
description: "Go to page up", |
| 12434 |
bindKey: "PageUp", |
| 12435 |
exec: function (editor) { editor.gotoPageUp(); }, |
| 12436 |
readOnly: true |
| 12437 |
}, { |
| 12438 |
name: "scrollup", |
| 12439 |
description: "Scroll up", |
| 12440 |
bindKey: bindKey("Ctrl-Up", null), |
| 12441 |
exec: function (e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); }, |
| 12442 |
readOnly: true |
| 12443 |
}, { |
| 12444 |
name: "scrolldown", |
| 12445 |
description: "Scroll down", |
| 12446 |
bindKey: bindKey("Ctrl-Down", null), |
| 12447 |
exec: function (e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); }, |
| 12448 |
readOnly: true |
| 12449 |
}, { |
| 12450 |
name: "selectlinestart", |
| 12451 |
description: "Select line start", |
| 12452 |
bindKey: "Shift-Home", |
| 12453 |
exec: function (editor) { editor.getSelection().selectLineStart(); }, |
| 12454 |
multiSelectAction: "forEach", |
| 12455 |
scrollIntoView: "cursor", |
| 12456 |
readOnly: true |
| 12457 |
}, { |
| 12458 |
name: "selectlineend", |
| 12459 |
description: "Select line end", |
| 12460 |
bindKey: "Shift-End", |
| 12461 |
exec: function (editor) { editor.getSelection().selectLineEnd(); }, |
| 12462 |
multiSelectAction: "forEach", |
| 12463 |
scrollIntoView: "cursor", |
| 12464 |
readOnly: true |
| 12465 |
}, { |
| 12466 |
name: "togglerecording", |
| 12467 |
description: "Toggle recording", |
| 12468 |
bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"), |
| 12469 |
exec: function (editor) { editor.commands.toggleRecording(editor); }, |
| 12470 |
readOnly: true |
| 12471 |
}, { |
| 12472 |
name: "replaymacro", |
| 12473 |
description: "Replay macro", |
| 12474 |
bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"), |
| 12475 |
exec: function (editor) { editor.commands.replay(editor); }, |
| 12476 |
readOnly: true |
| 12477 |
}, { |
| 12478 |
name: "jumptomatching", |
| 12479 |
description: "Jump to matching", |
| 12480 |
bindKey: bindKey("Ctrl-\\|Ctrl-P", "Command-\\"), |
| 12481 |
exec: function (editor) { editor.jumpToMatching(); }, |
| 12482 |
multiSelectAction: "forEach", |
| 12483 |
scrollIntoView: "animate", |
| 12484 |
readOnly: true |
| 12485 |
}, { |
| 12486 |
name: "selecttomatching", |
| 12487 |
description: "Select to matching", |
| 12488 |
bindKey: bindKey("Ctrl-Shift-\\|Ctrl-Shift-P", "Command-Shift-\\"), |
| 12489 |
exec: function (editor) { editor.jumpToMatching(true); }, |
| 12490 |
multiSelectAction: "forEach", |
| 12491 |
scrollIntoView: "animate", |
| 12492 |
readOnly: true |
| 12493 |
}, { |
| 12494 |
name: "expandToMatching", |
| 12495 |
description: "Expand to matching", |
| 12496 |
bindKey: bindKey("Ctrl-Shift-M", "Ctrl-Shift-M"), |
| 12497 |
exec: function (editor) { editor.jumpToMatching(true, true); }, |
| 12498 |
multiSelectAction: "forEach", |
| 12499 |
scrollIntoView: "animate", |
| 12500 |
readOnly: true |
| 12501 |
}, { |
| 12502 |
name: "passKeysToBrowser", |
| 12503 |
description: "Pass keys to browser", |
| 12504 |
bindKey: bindKey(null, null), |
| 12505 |
exec: function () { }, |
| 12506 |
passEvent: true, |
| 12507 |
readOnly: true |
| 12508 |
}, { |
| 12509 |
name: "copy", |
| 12510 |
description: "Copy", |
| 12511 |
exec: function (editor) { |
| 12512 |
}, |
| 12513 |
readOnly: true |
| 12514 |
}, |
| 12515 |
{ |
| 12516 |
name: "cut", |
| 12517 |
description: "Cut", |
| 12518 |
exec: function (editor) { |
| 12519 |
var cutLine = editor.$copyWithEmptySelection && editor.selection.isEmpty(); |
| 12520 |
var range = cutLine ? editor.selection.getLineRange() : editor.selection.getRange(); |
| 12521 |
editor._emit("cut", range); |
| 12522 |
if (!range.isEmpty()) |
| 12523 |
editor.session.remove(range); |
| 12524 |
editor.clearSelection(); |
| 12525 |
}, |
| 12526 |
scrollIntoView: "cursor", |
| 12527 |
multiSelectAction: "forEach" |
| 12528 |
}, { |
| 12529 |
name: "paste", |
| 12530 |
description: "Paste", |
| 12531 |
exec: function (editor, args) { |
| 12532 |
editor.$handlePaste(args); |
| 12533 |
}, |
| 12534 |
scrollIntoView: "cursor" |
| 12535 |
}, { |
| 12536 |
name: "removeline", |
| 12537 |
description: "Remove line", |
| 12538 |
bindKey: bindKey("Ctrl-D", "Command-D"), |
| 12539 |
exec: function (editor) { editor.removeLines(); }, |
| 12540 |
scrollIntoView: "cursor", |
| 12541 |
multiSelectAction: "forEachLine" |
| 12542 |
}, { |
| 12543 |
name: "duplicateSelection", |
| 12544 |
description: "Duplicate selection", |
| 12545 |
bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"), |
| 12546 |
exec: function (editor) { editor.duplicateSelection(); }, |
| 12547 |
scrollIntoView: "cursor", |
| 12548 |
multiSelectAction: "forEach" |
| 12549 |
}, { |
| 12550 |
name: "sortlines", |
| 12551 |
description: "Sort lines", |
| 12552 |
bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"), |
| 12553 |
exec: function (editor) { editor.sortLines(); }, |
| 12554 |
scrollIntoView: "selection", |
| 12555 |
multiSelectAction: "forEachLine" |
| 12556 |
}, { |
| 12557 |
name: "togglecomment", |
| 12558 |
description: "Toggle comment", |
| 12559 |
bindKey: bindKey("Ctrl-/", "Command-/"), |
| 12560 |
exec: function (editor) { editor.toggleCommentLines(); }, |
| 12561 |
multiSelectAction: "forEachLine", |
| 12562 |
scrollIntoView: "selectionPart" |
| 12563 |
}, { |
| 12564 |
name: "toggleBlockComment", |
| 12565 |
description: "Toggle block comment", |
| 12566 |
bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"), |
| 12567 |
exec: function (editor) { editor.toggleBlockComment(); }, |
| 12568 |
multiSelectAction: "forEach", |
| 12569 |
scrollIntoView: "selectionPart" |
| 12570 |
}, { |
| 12571 |
name: "modifyNumberUp", |
| 12572 |
description: "Modify number up", |
| 12573 |
bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"), |
| 12574 |
exec: function (editor) { editor.modifyNumber(1); }, |
| 12575 |
scrollIntoView: "cursor", |
| 12576 |
multiSelectAction: "forEach" |
| 12577 |
}, { |
| 12578 |
name: "modifyNumberDown", |
| 12579 |
description: "Modify number down", |
| 12580 |
bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"), |
| 12581 |
exec: function (editor) { editor.modifyNumber(-1); }, |
| 12582 |
scrollIntoView: "cursor", |
| 12583 |
multiSelectAction: "forEach" |
| 12584 |
}, { |
| 12585 |
name: "replace", |
| 12586 |
description: "Replace", |
| 12587 |
bindKey: bindKey("Ctrl-H", "Command-Option-F"), |
| 12588 |
exec: function (editor) { |
| 12589 |
config.loadModule("ace/ext/searchbox", function (e) { e.Search(editor, true); }); |
| 12590 |
} |
| 12591 |
}, { |
| 12592 |
name: "undo", |
| 12593 |
description: "Undo", |
| 12594 |
bindKey: bindKey("Ctrl-Z", "Command-Z"), |
| 12595 |
exec: function (editor) { editor.undo(); } |
| 12596 |
}, { |
| 12597 |
name: "redo", |
| 12598 |
description: "Redo", |
| 12599 |
bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"), |
| 12600 |
exec: function (editor) { editor.redo(); } |
| 12601 |
}, { |
| 12602 |
name: "copylinesup", |
| 12603 |
description: "Copy lines up", |
| 12604 |
bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"), |
| 12605 |
exec: function (editor) { editor.copyLinesUp(); }, |
| 12606 |
scrollIntoView: "cursor" |
| 12607 |
}, { |
| 12608 |
name: "movelinesup", |
| 12609 |
description: "Move lines up", |
| 12610 |
bindKey: bindKey("Alt-Up", "Option-Up"), |
| 12611 |
exec: function (editor) { editor.moveLinesUp(); }, |
| 12612 |
scrollIntoView: "cursor" |
| 12613 |
}, { |
| 12614 |
name: "copylinesdown", |
| 12615 |
description: "Copy lines down", |
| 12616 |
bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"), |
| 12617 |
exec: function (editor) { editor.copyLinesDown(); }, |
| 12618 |
scrollIntoView: "cursor" |
| 12619 |
}, { |
| 12620 |
name: "movelinesdown", |
| 12621 |
description: "Move lines down", |
| 12622 |
bindKey: bindKey("Alt-Down", "Option-Down"), |
| 12623 |
exec: function (editor) { editor.moveLinesDown(); }, |
| 12624 |
scrollIntoView: "cursor" |
| 12625 |
}, { |
| 12626 |
name: "del", |
| 12627 |
description: "Delete", |
| 12628 |
bindKey: bindKey("Delete", "Delete|Ctrl-D|Shift-Delete"), |
| 12629 |
exec: function (editor) { editor.remove("right"); }, |
| 12630 |
multiSelectAction: "forEach", |
| 12631 |
scrollIntoView: "cursor" |
| 12632 |
}, { |
| 12633 |
name: "backspace", |
| 12634 |
description: "Backspace", |
| 12635 |
bindKey: bindKey("Shift-Backspace|Backspace", "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"), |
| 12636 |
exec: function (editor) { editor.remove("left"); }, |
| 12637 |
multiSelectAction: "forEach", |
| 12638 |
scrollIntoView: "cursor" |
| 12639 |
}, { |
| 12640 |
name: "cut_or_delete", |
| 12641 |
description: "Cut or delete", |
| 12642 |
bindKey: bindKey("Shift-Delete", null), |
| 12643 |
exec: function (editor) { |
| 12644 |
if (editor.selection.isEmpty()) { |
| 12645 |
editor.remove("left"); |
| 12646 |
} |
| 12647 |
else { |
| 12648 |
return false; |
| 12649 |
} |
| 12650 |
}, |
| 12651 |
multiSelectAction: "forEach", |
| 12652 |
scrollIntoView: "cursor" |
| 12653 |
}, { |
| 12654 |
name: "removetolinestart", |
| 12655 |
description: "Remove to line start", |
| 12656 |
bindKey: bindKey("Alt-Backspace", "Command-Backspace"), |
| 12657 |
exec: function (editor) { editor.removeToLineStart(); }, |
| 12658 |
multiSelectAction: "forEach", |
| 12659 |
scrollIntoView: "cursor" |
| 12660 |
}, { |
| 12661 |
name: "removetolineend", |
| 12662 |
description: "Remove to line end", |
| 12663 |
bindKey: bindKey("Alt-Delete", "Ctrl-K|Command-Delete"), |
| 12664 |
exec: function (editor) { editor.removeToLineEnd(); }, |
| 12665 |
multiSelectAction: "forEach", |
| 12666 |
scrollIntoView: "cursor" |
| 12667 |
}, { |
| 12668 |
name: "removetolinestarthard", |
| 12669 |
description: "Remove to line start hard", |
| 12670 |
bindKey: bindKey("Ctrl-Shift-Backspace", null), |
| 12671 |
exec: function (editor) { |
| 12672 |
var range = editor.selection.getRange(); |
| 12673 |
range.start.column = 0; |
| 12674 |
editor.session.remove(range); |
| 12675 |
}, |
| 12676 |
multiSelectAction: "forEach", |
| 12677 |
scrollIntoView: "cursor" |
| 12678 |
}, { |
| 12679 |
name: "removetolineendhard", |
| 12680 |
description: "Remove to line end hard", |
| 12681 |
bindKey: bindKey("Ctrl-Shift-Delete", null), |
| 12682 |
exec: function (editor) { |
| 12683 |
var range = editor.selection.getRange(); |
| 12684 |
range.end.column = Number.MAX_VALUE; |
| 12685 |
editor.session.remove(range); |
| 12686 |
}, |
| 12687 |
multiSelectAction: "forEach", |
| 12688 |
scrollIntoView: "cursor" |
| 12689 |
}, { |
| 12690 |
name: "removewordleft", |
| 12691 |
description: "Remove word left", |
| 12692 |
bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"), |
| 12693 |
exec: function (editor) { editor.removeWordLeft(); }, |
| 12694 |
multiSelectAction: "forEach", |
| 12695 |
scrollIntoView: "cursor" |
| 12696 |
}, { |
| 12697 |
name: "removewordright", |
| 12698 |
description: "Remove word right", |
| 12699 |
bindKey: bindKey("Ctrl-Delete", "Alt-Delete"), |
| 12700 |
exec: function (editor) { editor.removeWordRight(); }, |
| 12701 |
multiSelectAction: "forEach", |
| 12702 |
scrollIntoView: "cursor" |
| 12703 |
}, { |
| 12704 |
name: "outdent", |
| 12705 |
description: "Outdent", |
| 12706 |
bindKey: bindKey("Shift-Tab", "Shift-Tab"), |
| 12707 |
exec: function (editor) { editor.blockOutdent(); }, |
| 12708 |
multiSelectAction: "forEach", |
| 12709 |
scrollIntoView: "selectionPart" |
| 12710 |
}, { |
| 12711 |
name: "indent", |
| 12712 |
description: "Indent", |
| 12713 |
bindKey: bindKey("Tab", "Tab"), |
| 12714 |
exec: function (editor) { editor.indent(); }, |
| 12715 |
multiSelectAction: "forEach", |
| 12716 |
scrollIntoView: "selectionPart" |
| 12717 |
}, { |
| 12718 |
name: "blockoutdent", |
| 12719 |
description: "Block outdent", |
| 12720 |
bindKey: bindKey("Ctrl-[", "Ctrl-["), |
| 12721 |
exec: function (editor) { editor.blockOutdent(); }, |
| 12722 |
multiSelectAction: "forEachLine", |
| 12723 |
scrollIntoView: "selectionPart" |
| 12724 |
}, { |
| 12725 |
name: "blockindent", |
| 12726 |
description: "Block indent", |
| 12727 |
bindKey: bindKey("Ctrl-]", "Ctrl-]"), |
| 12728 |
exec: function (editor) { editor.blockIndent(); }, |
| 12729 |
multiSelectAction: "forEachLine", |
| 12730 |
scrollIntoView: "selectionPart" |
| 12731 |
}, { |
| 12732 |
name: "insertstring", |
| 12733 |
description: "Insert string", |
| 12734 |
exec: function (editor, str) { editor.insert(str); }, |
| 12735 |
multiSelectAction: "forEach", |
| 12736 |
scrollIntoView: "cursor" |
| 12737 |
}, { |
| 12738 |
name: "inserttext", |
| 12739 |
description: "Insert text", |
| 12740 |
exec: function (editor, args) { |
| 12741 |
editor.insert(lang.stringRepeat(args.text || "", args.times || 1)); |
| 12742 |
}, |
| 12743 |
multiSelectAction: "forEach", |
| 12744 |
scrollIntoView: "cursor" |
| 12745 |
}, { |
| 12746 |
name: "splitline", |
| 12747 |
description: "Split line", |
| 12748 |
bindKey: bindKey(null, "Ctrl-O"), |
| 12749 |
exec: function (editor) { editor.splitLine(); }, |
| 12750 |
multiSelectAction: "forEach", |
| 12751 |
scrollIntoView: "cursor" |
| 12752 |
}, { |
| 12753 |
name: "transposeletters", |
| 12754 |
description: "Transpose letters", |
| 12755 |
bindKey: bindKey("Alt-Shift-X", "Ctrl-T"), |
| 12756 |
exec: function (editor) { editor.transposeLetters(); }, |
| 12757 |
multiSelectAction: function (editor) { editor.transposeSelections(1); }, |
| 12758 |
scrollIntoView: "cursor" |
| 12759 |
}, { |
| 12760 |
name: "touppercase", |
| 12761 |
description: "To uppercase", |
| 12762 |
bindKey: bindKey("Ctrl-U", "Ctrl-U"), |
| 12763 |
exec: function (editor) { editor.toUpperCase(); }, |
| 12764 |
multiSelectAction: "forEach", |
| 12765 |
scrollIntoView: "cursor" |
| 12766 |
}, { |
| 12767 |
name: "tolowercase", |
| 12768 |
description: "To lowercase", |
| 12769 |
bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"), |
| 12770 |
exec: function (editor) { editor.toLowerCase(); }, |
| 12771 |
multiSelectAction: "forEach", |
| 12772 |
scrollIntoView: "cursor" |
| 12773 |
}, { |
| 12774 |
name: "autoindent", |
| 12775 |
description: "Auto Indent", |
| 12776 |
bindKey: bindKey(null, null), |
| 12777 |
exec: function (editor) { editor.autoIndent(); }, |
| 12778 |
scrollIntoView: "animate" |
| 12779 |
}, { |
| 12780 |
name: "expandtoline", |
| 12781 |
description: "Expand to line", |
| 12782 |
bindKey: bindKey("Ctrl-Shift-L", "Command-Shift-L"), |
| 12783 |
exec: function (editor) { |
| 12784 |
var range = editor.selection.getRange(); |
| 12785 |
range.start.column = range.end.column = 0; |
| 12786 |
range.end.row++; |
| 12787 |
editor.selection.setRange(range, false); |
| 12788 |
}, |
| 12789 |
multiSelectAction: "forEach", |
| 12790 |
scrollIntoView: "cursor", |
| 12791 |
readOnly: true |
| 12792 |
}, { |
| 12793 |
name: "openlink", |
| 12794 |
bindKey: bindKey("Ctrl+F3", "F3"), |
| 12795 |
exec: function (editor) { editor.openLink(); } |
| 12796 |
}, { |
| 12797 |
name: "joinlines", |
| 12798 |
description: "Join lines", |
| 12799 |
bindKey: bindKey(null, null), |
| 12800 |
exec: function (editor) { |
| 12801 |
var isBackwards = editor.selection.isBackwards(); |
| 12802 |
var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor(); |
| 12803 |
var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead(); |
| 12804 |
var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length; |
| 12805 |
var selectedText = editor.session.doc.getTextRange(editor.selection.getRange()); |
| 12806 |
var selectedCount = selectedText.replace(/\n\s*/, " ").length; |
| 12807 |
var insertLine = editor.session.doc.getLine(selectionStart.row); |
| 12808 |
for (var i = selectionStart.row + 1; i <= selectionEnd.row + 1; i++) { |
| 12809 |
var curLine = lang.stringTrimLeft(lang.stringTrimRight(editor.session.doc.getLine(i))); |
| 12810 |
if (curLine.length !== 0) { |
| 12811 |
curLine = " " + curLine; |
| 12812 |
} |
| 12813 |
insertLine += curLine; |
| 12814 |
} |
| 12815 |
if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) { |
| 12816 |
insertLine += editor.session.doc.getNewLineCharacter(); |
| 12817 |
} |
| 12818 |
editor.clearSelection(); |
| 12819 |
editor.session.doc.replace(new Range(selectionStart.row, 0, selectionEnd.row + 2, 0), insertLine); |
| 12820 |
if (selectedCount > 0) { |
| 12821 |
editor.selection.moveCursorTo(selectionStart.row, selectionStart.column); |
| 12822 |
editor.selection.selectTo(selectionStart.row, selectionStart.column + selectedCount); |
| 12823 |
} |
| 12824 |
else { |
| 12825 |
firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length > firstLineEndCol ? (firstLineEndCol + 1) : firstLineEndCol; |
| 12826 |
editor.selection.moveCursorTo(selectionStart.row, firstLineEndCol); |
| 12827 |
} |
| 12828 |
}, |
| 12829 |
multiSelectAction: "forEach", |
| 12830 |
readOnly: true |
| 12831 |
}, { |
| 12832 |
name: "invertSelection", |
| 12833 |
description: "Invert selection", |
| 12834 |
bindKey: bindKey(null, null), |
| 12835 |
exec: function (editor) { |
| 12836 |
var endRow = editor.session.doc.getLength() - 1; |
| 12837 |
var endCol = editor.session.doc.getLine(endRow).length; |
| 12838 |
var ranges = editor.selection.rangeList.ranges; |
| 12839 |
var newRanges = []; |
| 12840 |
if (ranges.length < 1) { |
| 12841 |
ranges = [editor.selection.getRange()]; |
| 12842 |
} |
| 12843 |
for (var i = 0; i < ranges.length; i++) { |
| 12844 |
if (i == (ranges.length - 1)) { |
| 12845 |
if (!(ranges[i].end.row === endRow && ranges[i].end.column === endCol)) { |
| 12846 |
newRanges.push(new Range(ranges[i].end.row, ranges[i].end.column, endRow, endCol)); |
| 12847 |
} |
| 12848 |
} |
| 12849 |
if (i === 0) { |
| 12850 |
if (!(ranges[i].start.row === 0 && ranges[i].start.column === 0)) { |
| 12851 |
newRanges.push(new Range(0, 0, ranges[i].start.row, ranges[i].start.column)); |
| 12852 |
} |
| 12853 |
} |
| 12854 |
else { |
| 12855 |
newRanges.push(new Range(ranges[i - 1].end.row, ranges[i - 1].end.column, ranges[i].start.row, ranges[i].start.column)); |
| 12856 |
} |
| 12857 |
} |
| 12858 |
editor.exitMultiSelectMode(); |
| 12859 |
editor.clearSelection(); |
| 12860 |
for (var i = 0; i < newRanges.length; i++) { |
| 12861 |
editor.selection.addRange(newRanges[i], false); |
| 12862 |
} |
| 12863 |
}, |
| 12864 |
readOnly: true, |
| 12865 |
scrollIntoView: "none" |
| 12866 |
}, { |
| 12867 |
name: "addLineAfter", |
| 12868 |
description: "Add new line after the current line", |
| 12869 |
exec: function (editor) { |
| 12870 |
editor.selection.clearSelection(); |
| 12871 |
editor.navigateLineEnd(); |
| 12872 |
editor.insert("\n"); |
| 12873 |
}, |
| 12874 |
multiSelectAction: "forEach", |
| 12875 |
scrollIntoView: "cursor" |
| 12876 |
}, { |
| 12877 |
name: "addLineBefore", |
| 12878 |
description: "Add new line before the current line", |
| 12879 |
exec: function (editor) { |
| 12880 |
editor.selection.clearSelection(); |
| 12881 |
var cursor = editor.getCursorPosition(); |
| 12882 |
editor.selection.moveTo(cursor.row - 1, Number.MAX_VALUE); |
| 12883 |
editor.insert("\n"); |
| 12884 |
if (cursor.row === 0) |
| 12885 |
editor.navigateUp(); |
| 12886 |
}, |
| 12887 |
multiSelectAction: "forEach", |
| 12888 |
scrollIntoView: "cursor" |
| 12889 |
}, { |
| 12890 |
name: "openCommandPallete", |
| 12891 |
exec: function (editor) { |
| 12892 |
console.warn("This is an obsolete command. Please use `openCommandPalette` instead."); |
| 12893 |
editor.prompt({ $type: "commands" }); |
| 12894 |
}, |
| 12895 |
readOnly: true |
| 12896 |
}, { |
| 12897 |
name: "openCommandPalette", |
| 12898 |
description: "Open command palette", |
| 12899 |
bindKey: bindKey("F1", "F1"), |
| 12900 |
exec: function (editor) { |
| 12901 |
editor.prompt({ $type: "commands" }); |
| 12902 |
}, |
| 12903 |
readOnly: true |
| 12904 |
}, { |
| 12905 |
name: "modeSelect", |
| 12906 |
description: "Change language mode...", |
| 12907 |
bindKey: bindKey(null, null), |
| 12908 |
exec: function (editor) { |
| 12909 |
editor.prompt({ $type: "modes" }); |
| 12910 |
}, |
| 12911 |
readOnly: true |
| 12912 |
}]; |
| 12913 |
for (var i = 1; i < 9; i++) { |
| 12914 |
exports.commands.push({ |
| 12915 |
name: "foldToLevel" + i, |
| 12916 |
description: "Fold To Level " + i, |
| 12917 |
level: i, |
| 12918 |
exec: function (editor) { editor.session.foldToLevel(this.level); }, |
| 12919 |
scrollIntoView: "center", |
| 12920 |
readOnly: true |
| 12921 |
}); |
| 12922 |
} |
| 12923 |
|
| 12924 |
}); |
| 12925 |
|
| 12926 |
ace.define("ace/line_widgets",["require","exports","module","ace/lib/dom"], function(require, exports, module){"use strict"; |
| 12927 |
var dom = require("./lib/dom"); |
| 12928 |
var LineWidgets = (function () { |
| 12929 |
function LineWidgets(session) { |
| 12930 |
this.session = session; |
| 12931 |
this.session.widgetManager = this; |
| 12932 |
this.session.getRowLength = this.getRowLength; |
| 12933 |
this.session.$getWidgetScreenLength = this.$getWidgetScreenLength; |
| 12934 |
this.updateOnChange = this.updateOnChange.bind(this); |
| 12935 |
this.renderWidgets = this.renderWidgets.bind(this); |
| 12936 |
this.measureWidgets = this.measureWidgets.bind(this); |
| 12937 |
this.session._changedWidgets = []; |
| 12938 |
this.$onChangeEditor = this.$onChangeEditor.bind(this); |
| 12939 |
this.session.on("change", this.updateOnChange); |
| 12940 |
this.session.on("changeFold", this.updateOnFold); |
| 12941 |
this.session.on("changeEditor", this.$onChangeEditor); |
| 12942 |
} |
| 12943 |
LineWidgets.prototype.getRowLength = function (row) { |
| 12944 |
var h; |
| 12945 |
if (this.lineWidgets) |
| 12946 |
h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0; |
| 12947 |
else |
| 12948 |
h = 0; |
| 12949 |
if (!this["$useWrapMode"] || !this["$wrapData"][row]) { |
| 12950 |
return 1 + h; |
| 12951 |
} |
| 12952 |
else { |
| 12953 |
return this["$wrapData"][row].length + 1 + h; |
| 12954 |
} |
| 12955 |
}; |
| 12956 |
LineWidgets.prototype.$getWidgetScreenLength = function () { |
| 12957 |
var screenRows = 0; |
| 12958 |
this.lineWidgets.forEach(function (w) { |
| 12959 |
if (w && w.rowCount && !w.hidden) |
| 12960 |
screenRows += w.rowCount; |
| 12961 |
}); |
| 12962 |
return screenRows; |
| 12963 |
}; |
| 12964 |
LineWidgets.prototype.$onChangeEditor = function (e) { |
| 12965 |
this.attach(e.editor); |
| 12966 |
}; |
| 12967 |
LineWidgets.prototype.attach = function (editor) { |
| 12968 |
if (editor && editor.widgetManager && editor.widgetManager != this) |
| 12969 |
editor.widgetManager.detach(); |
| 12970 |
if (this.editor == editor) |
| 12971 |
return; |
| 12972 |
this.detach(); |
| 12973 |
this.editor = editor; |
| 12974 |
if (editor) { |
| 12975 |
editor.widgetManager = this; |
| 12976 |
editor.renderer.on("beforeRender", this.measureWidgets); |
| 12977 |
editor.renderer.on("afterRender", this.renderWidgets); |
| 12978 |
} |
| 12979 |
}; |
| 12980 |
LineWidgets.prototype.detach = function (e) { |
| 12981 |
var editor = this.editor; |
| 12982 |
if (!editor) |
| 12983 |
return; |
| 12984 |
this.editor = null; |
| 12985 |
editor.widgetManager = null; |
| 12986 |
editor.renderer.off("beforeRender", this.measureWidgets); |
| 12987 |
editor.renderer.off("afterRender", this.renderWidgets); |
| 12988 |
var lineWidgets = this.session.lineWidgets; |
| 12989 |
lineWidgets && lineWidgets.forEach(function (w) { |
| 12990 |
if (w && w.el && w.el.parentNode) { |
| 12991 |
w._inDocument = false; |
| 12992 |
w.el.parentNode.removeChild(w.el); |
| 12993 |
} |
| 12994 |
}); |
| 12995 |
}; |
| 12996 |
LineWidgets.prototype.updateOnFold = function (e, session) { |
| 12997 |
var lineWidgets = session.lineWidgets; |
| 12998 |
if (!lineWidgets || !e.action) |
| 12999 |
return; |
| 13000 |
var fold = e.data; |
| 13001 |
var start = fold.start.row; |
| 13002 |
var end = fold.end.row; |
| 13003 |
var hide = e.action == "add"; |
| 13004 |
for (var i = start + 1; i < end; i++) { |
| 13005 |
if (lineWidgets[i]) |
| 13006 |
lineWidgets[i].hidden = hide; |
| 13007 |
} |
| 13008 |
if (lineWidgets[end]) { |
| 13009 |
if (hide) { |
| 13010 |
if (!lineWidgets[start]) |
| 13011 |
lineWidgets[start] = lineWidgets[end]; |
| 13012 |
else |
| 13013 |
lineWidgets[end].hidden = hide; |
| 13014 |
} |
| 13015 |
else { |
| 13016 |
if (lineWidgets[start] == lineWidgets[end]) |
| 13017 |
lineWidgets[start] = undefined; |
| 13018 |
lineWidgets[end].hidden = hide; |
| 13019 |
} |
| 13020 |
} |
| 13021 |
}; |
| 13022 |
LineWidgets.prototype.updateOnChange = function (delta) { |
| 13023 |
var lineWidgets = this.session.lineWidgets; |
| 13024 |
if (!lineWidgets) |
| 13025 |
return; |
| 13026 |
var startRow = delta.start.row; |
| 13027 |
var len = delta.end.row - startRow; |
| 13028 |
if (len === 0) { |
| 13029 |
} |
| 13030 |
else if (delta.action == "remove") { |
| 13031 |
var removed = lineWidgets.splice(startRow + 1, len); |
| 13032 |
if (!lineWidgets[startRow] && removed[removed.length - 1]) { |
| 13033 |
lineWidgets[startRow] = removed.pop(); |
| 13034 |
} |
| 13035 |
removed.forEach(function (w) { |
| 13036 |
w && this.removeLineWidget(w); |
| 13037 |
}, this); |
| 13038 |
this.$updateRows(); |
| 13039 |
} |
| 13040 |
else { |
| 13041 |
var args = new Array(len); |
| 13042 |
if (lineWidgets[startRow] && lineWidgets[startRow].column != null) { |
| 13043 |
if (delta.start.column > lineWidgets[startRow].column) |
| 13044 |
startRow++; |
| 13045 |
} |
| 13046 |
args.unshift(startRow, 0); |
| 13047 |
lineWidgets.splice.apply(lineWidgets, args); |
| 13048 |
this.$updateRows(); |
| 13049 |
} |
| 13050 |
}; |
| 13051 |
LineWidgets.prototype.$updateRows = function () { |
| 13052 |
var lineWidgets = this.session.lineWidgets; |
| 13053 |
if (!lineWidgets) |
| 13054 |
return; |
| 13055 |
var noWidgets = true; |
| 13056 |
lineWidgets.forEach(function (w, i) { |
| 13057 |
if (w) { |
| 13058 |
noWidgets = false; |
| 13059 |
w.row = i; |
| 13060 |
while (w.$oldWidget) { |
| 13061 |
w.$oldWidget.row = i; |
| 13062 |
w = w.$oldWidget; |
| 13063 |
} |
| 13064 |
} |
| 13065 |
}); |
| 13066 |
if (noWidgets) |
| 13067 |
this.session.lineWidgets = null; |
| 13068 |
}; |
| 13069 |
LineWidgets.prototype.$registerLineWidget = function (w) { |
| 13070 |
if (!this.session.lineWidgets) |
| 13071 |
this.session.lineWidgets = new Array(this.session.getLength()); |
| 13072 |
var old = this.session.lineWidgets[w.row]; |
| 13073 |
if (old) { |
| 13074 |
w.$oldWidget = old; |
| 13075 |
if (old.el && old.el.parentNode) { |
| 13076 |
old.el.parentNode.removeChild(old.el); |
| 13077 |
old._inDocument = false; |
| 13078 |
} |
| 13079 |
} |
| 13080 |
this.session.lineWidgets[w.row] = w; |
| 13081 |
return w; |
| 13082 |
}; |
| 13083 |
LineWidgets.prototype.addLineWidget = function (w) { |
| 13084 |
this.$registerLineWidget(w); |
| 13085 |
w.session = this.session; |
| 13086 |
if (!this.editor) |
| 13087 |
return w; |
| 13088 |
var renderer = this.editor.renderer; |
| 13089 |
if (w.html && !w.el) { |
| 13090 |
w.el = dom.createElement("div"); |
| 13091 |
w.el.innerHTML = w.html; |
| 13092 |
} |
| 13093 |
if (w.text && !w.el) { |
| 13094 |
w.el = dom.createElement("div"); |
| 13095 |
w.el.textContent = w.text; |
| 13096 |
} |
| 13097 |
if (w.el) { |
| 13098 |
dom.addCssClass(w.el, "ace_lineWidgetContainer"); |
| 13099 |
if (w.className) { |
| 13100 |
dom.addCssClass(w.el, w.className); |
| 13101 |
} |
| 13102 |
w.el.style.position = "absolute"; |
| 13103 |
w.el.style.zIndex = "5"; |
| 13104 |
renderer.container.appendChild(w.el); |
| 13105 |
w._inDocument = true; |
| 13106 |
if (!w.coverGutter) { |
| 13107 |
w.el.style.zIndex = "3"; |
| 13108 |
} |
| 13109 |
if (w.pixelHeight == null) { |
| 13110 |
w.pixelHeight = w.el.offsetHeight; |
| 13111 |
} |
| 13112 |
} |
| 13113 |
if (w.rowCount == null) { |
| 13114 |
w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight; |
| 13115 |
} |
| 13116 |
var fold = this.session.getFoldAt(w.row, 0); |
| 13117 |
w.$fold = fold; |
| 13118 |
if (fold) { |
| 13119 |
var lineWidgets = this.session.lineWidgets; |
| 13120 |
if (w.row == fold.end.row && !lineWidgets[fold.start.row]) |
| 13121 |
lineWidgets[fold.start.row] = w; |
| 13122 |
else |
| 13123 |
w.hidden = true; |
| 13124 |
} |
| 13125 |
this.session._emit("changeFold", { data: { start: { row: w.row } } }); |
| 13126 |
this.$updateRows(); |
| 13127 |
this.renderWidgets(null, renderer); |
| 13128 |
this.onWidgetChanged(w); |
| 13129 |
return w; |
| 13130 |
}; |
| 13131 |
LineWidgets.prototype.removeLineWidget = function (w) { |
| 13132 |
w._inDocument = false; |
| 13133 |
w.session = null; |
| 13134 |
if (w.el && w.el.parentNode) |
| 13135 |
w.el.parentNode.removeChild(w.el); |
| 13136 |
if (w.editor && w.editor.destroy) |
| 13137 |
try { |
| 13138 |
w.editor.destroy(); |
| 13139 |
} |
| 13140 |
catch (e) { } |
| 13141 |
if (this.session.lineWidgets) { |
| 13142 |
var w1 = this.session.lineWidgets[w.row]; |
| 13143 |
if (w1 == w) { |
| 13144 |
this.session.lineWidgets[w.row] = w.$oldWidget; |
| 13145 |
if (w.$oldWidget) |
| 13146 |
this.onWidgetChanged(w.$oldWidget); |
| 13147 |
} |
| 13148 |
else { |
| 13149 |
while (w1) { |
| 13150 |
if (w1.$oldWidget == w) { |
| 13151 |
w1.$oldWidget = w.$oldWidget; |
| 13152 |
break; |
| 13153 |
} |
| 13154 |
w1 = w1.$oldWidget; |
| 13155 |
} |
| 13156 |
} |
| 13157 |
} |
| 13158 |
this.session._emit("changeFold", { data: { start: { row: w.row } } }); |
| 13159 |
this.$updateRows(); |
| 13160 |
}; |
| 13161 |
LineWidgets.prototype.getWidgetsAtRow = function (row) { |
| 13162 |
var lineWidgets = this.session.lineWidgets; |
| 13163 |
var w = lineWidgets && lineWidgets[row]; |
| 13164 |
var list = []; |
| 13165 |
while (w) { |
| 13166 |
list.push(w); |
| 13167 |
w = w.$oldWidget; |
| 13168 |
} |
| 13169 |
return list; |
| 13170 |
}; |
| 13171 |
LineWidgets.prototype.onWidgetChanged = function (w) { |
| 13172 |
this.session._changedWidgets.push(w); |
| 13173 |
this.editor && this.editor.renderer.updateFull(); |
| 13174 |
}; |
| 13175 |
LineWidgets.prototype.measureWidgets = function (e, renderer) { |
| 13176 |
var changedWidgets = this.session._changedWidgets; |
| 13177 |
var config = renderer.layerConfig; |
| 13178 |
if (!changedWidgets || !changedWidgets.length) |
| 13179 |
return; |
| 13180 |
var min = Infinity; |
| 13181 |
for (var i = 0; i < changedWidgets.length; i++) { |
| 13182 |
var w = changedWidgets[i]; |
| 13183 |
if (!w || !w.el) |
| 13184 |
continue; |
| 13185 |
if (w.session != this.session) |
| 13186 |
continue; |
| 13187 |
if (!w._inDocument) { |
| 13188 |
if (this.session.lineWidgets[w.row] != w) |
| 13189 |
continue; |
| 13190 |
w._inDocument = true; |
| 13191 |
renderer.container.appendChild(w.el); |
| 13192 |
} |
| 13193 |
w.h = w.el.offsetHeight; |
| 13194 |
if (!w.fixedWidth) { |
| 13195 |
w.w = w.el.offsetWidth; |
| 13196 |
w.screenWidth = Math.ceil(w.w / config.characterWidth); |
| 13197 |
} |
| 13198 |
var rowCount = w.h / config.lineHeight; |
| 13199 |
if (w.coverLine) { |
| 13200 |
rowCount -= this.session.getRowLineCount(w.row); |
| 13201 |
if (rowCount < 0) |
| 13202 |
rowCount = 0; |
| 13203 |
} |
| 13204 |
if (w.rowCount != rowCount) { |
| 13205 |
w.rowCount = rowCount; |
| 13206 |
if (w.row < min) |
| 13207 |
min = w.row; |
| 13208 |
} |
| 13209 |
} |
| 13210 |
if (min != Infinity) { |
| 13211 |
this.session._emit("changeFold", { data: { start: { row: min } } }); |
| 13212 |
this.session.lineWidgetWidth = null; |
| 13213 |
} |
| 13214 |
this.session._changedWidgets = []; |
| 13215 |
}; |
| 13216 |
LineWidgets.prototype.renderWidgets = function (e, renderer) { |
| 13217 |
var config = renderer.layerConfig; |
| 13218 |
var lineWidgets = this.session.lineWidgets; |
| 13219 |
if (!lineWidgets) |
| 13220 |
return; |
| 13221 |
var first = Math.min(this.firstRow, config.firstRow); |
| 13222 |
var last = Math.max(this.lastRow, config.lastRow, lineWidgets.length); |
| 13223 |
while (first > 0 && !lineWidgets[first]) |
| 13224 |
first--; |
| 13225 |
this.firstRow = config.firstRow; |
| 13226 |
this.lastRow = config.lastRow; |
| 13227 |
renderer.$cursorLayer.config = config; |
| 13228 |
for (var i = first; i <= last; i++) { |
| 13229 |
var w = lineWidgets[i]; |
| 13230 |
if (!w || !w.el) |
| 13231 |
continue; |
| 13232 |
if (w.hidden) { |
| 13233 |
w.el.style.top = -100 - (w.pixelHeight || 0) + "px"; |
| 13234 |
continue; |
| 13235 |
} |
| 13236 |
if (!w._inDocument) { |
| 13237 |
w._inDocument = true; |
| 13238 |
renderer.container.appendChild(w.el); |
| 13239 |
} |
| 13240 |
var top = renderer.$cursorLayer.getPixelPosition({ row: i, column: 0 }, true).top; |
| 13241 |
if (!w.coverLine) |
| 13242 |
top += config.lineHeight * this.session.getRowLineCount(w.row); |
| 13243 |
w.el.style.top = top - config.offset + "px"; |
| 13244 |
var left = w.coverGutter ? 0 : renderer.gutterWidth; |
| 13245 |
if (!w.fixedWidth) |
| 13246 |
left -= renderer.scrollLeft; |
| 13247 |
w.el.style.left = left + "px"; |
| 13248 |
if (w.fullWidth && w.screenWidth) { |
| 13249 |
w.el.style.minWidth = config.width + 2 * config.padding + "px"; |
| 13250 |
} |
| 13251 |
if (w.fixedWidth) { |
| 13252 |
w.el.style.right = renderer.scrollBar.getWidth() + "px"; |
| 13253 |
} |
| 13254 |
else { |
| 13255 |
w.el.style.right = ""; |
| 13256 |
} |
| 13257 |
} |
| 13258 |
}; |
| 13259 |
return LineWidgets; |
| 13260 |
}()); |
| 13261 |
exports.LineWidgets = LineWidgets; |
| 13262 |
|
| 13263 |
}); |
| 13264 |
|
| 13265 |
ace.define("ace/keyboard/gutter_handler",["require","exports","module","ace/lib/keys","ace/mouse/default_gutter_handler"], function(require, exports, module){"use strict"; |
| 13266 |
var keys = require('../lib/keys'); |
| 13267 |
var GutterTooltip = require("../mouse/default_gutter_handler").GutterTooltip; |
| 13268 |
var GutterKeyboardHandler = (function () { |
| 13269 |
function GutterKeyboardHandler(editor) { |
| 13270 |
this.editor = editor; |
| 13271 |
this.gutterLayer = editor.renderer.$gutterLayer; |
| 13272 |
this.element = editor.renderer.$gutter; |
| 13273 |
this.lines = editor.renderer.$gutterLayer.$lines; |
| 13274 |
this.activeRowIndex = null; |
| 13275 |
this.activeLane = null; |
| 13276 |
this.annotationTooltip = new GutterTooltip(this.editor); |
| 13277 |
} |
| 13278 |
GutterKeyboardHandler.prototype.addListener = function () { |
| 13279 |
this.element.addEventListener("keydown", this.$onGutterKeyDown.bind(this)); |
| 13280 |
this.element.addEventListener("focusout", this.$blurGutter.bind(this)); |
| 13281 |
this.editor.on("mousewheel", this.$blurGutter.bind(this)); |
| 13282 |
}; |
| 13283 |
GutterKeyboardHandler.prototype.removeListener = function () { |
| 13284 |
this.element.removeEventListener("keydown", this.$onGutterKeyDown.bind(this)); |
| 13285 |
this.element.removeEventListener("focusout", this.$blurGutter.bind(this)); |
| 13286 |
this.editor.off("mousewheel", this.$blurGutter.bind(this)); |
| 13287 |
}; |
| 13288 |
GutterKeyboardHandler.prototype.$onGutterKeyDown = function (e) { |
| 13289 |
if (this.annotationTooltip.isOpen) { |
| 13290 |
e.preventDefault(); |
| 13291 |
if (e.keyCode === keys["escape"]) |
| 13292 |
this.annotationTooltip.hideTooltip(); |
| 13293 |
return; |
| 13294 |
} |
| 13295 |
if (e.target === this.element) { |
| 13296 |
if (e.keyCode != keys["enter"]) { |
| 13297 |
return; |
| 13298 |
} |
| 13299 |
e.preventDefault(); |
| 13300 |
var row = this.editor.getCursorPosition().row; |
| 13301 |
if (!this.editor.isRowVisible(row)) |
| 13302 |
this.editor.scrollToLine(row, true, true); |
| 13303 |
setTimeout( |
| 13304 |
function () { |
| 13305 |
var index = this.$rowToRowIndex(this.gutterLayer.$cursorCell.row); |
| 13306 |
var nearestFoldIndex = this.$findNearestFoldWidget(index); |
| 13307 |
var nearestAnnotationIndex = this.$findNearestAnnotation(index); |
| 13308 |
if (nearestFoldIndex === null && nearestAnnotationIndex === null) |
| 13309 |
return; |
| 13310 |
if (nearestFoldIndex === null && nearestAnnotationIndex !== null) { |
| 13311 |
this.activeRowIndex = nearestAnnotationIndex; |
| 13312 |
this.activeLane = "annotation"; |
| 13313 |
this.$focusAnnotation(this.activeRowIndex); |
| 13314 |
return; |
| 13315 |
} |
| 13316 |
if (nearestFoldIndex !== null && nearestAnnotationIndex === null) { |
| 13317 |
this.activeRowIndex = nearestFoldIndex; |
| 13318 |
this.activeLane = "fold"; |
| 13319 |
this.$focusFoldWidget(this.activeRowIndex); |
| 13320 |
return; |
| 13321 |
} |
| 13322 |
if (Math.abs(nearestAnnotationIndex - index) < Math.abs(nearestFoldIndex - index)) { |
| 13323 |
this.activeRowIndex = nearestAnnotationIndex; |
| 13324 |
this.activeLane = "annotation"; |
| 13325 |
this.$focusAnnotation(this.activeRowIndex); |
| 13326 |
return; |
| 13327 |
} |
| 13328 |
else { |
| 13329 |
this.activeRowIndex = nearestFoldIndex; |
| 13330 |
this.activeLane = "fold"; |
| 13331 |
this.$focusFoldWidget(this.activeRowIndex); |
| 13332 |
return; |
| 13333 |
} |
| 13334 |
}.bind(this), 10); |
| 13335 |
return; |
| 13336 |
} |
| 13337 |
this.$handleGutterKeyboardInteraction(e); |
| 13338 |
setTimeout(function () { |
| 13339 |
this.editor._signal("gutterkeydown", new GutterKeyboardEvent(e, this)); |
| 13340 |
}.bind(this), 10); |
| 13341 |
}; |
| 13342 |
GutterKeyboardHandler.prototype.$handleGutterKeyboardInteraction = function (e) { |
| 13343 |
if (e.keyCode === keys["tab"]) { |
| 13344 |
e.preventDefault(); |
| 13345 |
return; |
| 13346 |
} |
| 13347 |
if (e.keyCode === keys["escape"]) { |
| 13348 |
e.preventDefault(); |
| 13349 |
this.$blurGutter(); |
| 13350 |
this.element.focus(); |
| 13351 |
this.lane = null; |
| 13352 |
return; |
| 13353 |
} |
| 13354 |
if (e.keyCode === keys["up"]) { |
| 13355 |
e.preventDefault(); |
| 13356 |
switch (this.activeLane) { |
| 13357 |
case "fold": |
| 13358 |
this.$moveFoldWidgetUp(); |
| 13359 |
break; |
| 13360 |
case "annotation": |
| 13361 |
this.$moveAnnotationUp(); |
| 13362 |
break; |
| 13363 |
} |
| 13364 |
return; |
| 13365 |
} |
| 13366 |
if (e.keyCode === keys["down"]) { |
| 13367 |
e.preventDefault(); |
| 13368 |
switch (this.activeLane) { |
| 13369 |
case "fold": |
| 13370 |
this.$moveFoldWidgetDown(); |
| 13371 |
break; |
| 13372 |
case "annotation": |
| 13373 |
this.$moveAnnotationDown(); |
| 13374 |
break; |
| 13375 |
} |
| 13376 |
return; |
| 13377 |
} |
| 13378 |
if (e.keyCode === keys["left"]) { |
| 13379 |
e.preventDefault(); |
| 13380 |
this.$switchLane("annotation"); |
| 13381 |
return; |
| 13382 |
} |
| 13383 |
if (e.keyCode === keys["right"]) { |
| 13384 |
e.preventDefault(); |
| 13385 |
this.$switchLane("fold"); |
| 13386 |
return; |
| 13387 |
} |
| 13388 |
if (e.keyCode === keys["enter"] || e.keyCode === keys["space"]) { |
| 13389 |
e.preventDefault(); |
| 13390 |
switch (this.activeLane) { |
| 13391 |
case "fold": |
| 13392 |
if (this.gutterLayer.session.foldWidgets[this.$rowIndexToRow(this.activeRowIndex)] === 'start') { |
| 13393 |
var rowFoldingWidget = this.$rowIndexToRow(this.activeRowIndex); |
| 13394 |
this.editor.session.onFoldWidgetClick(this.$rowIndexToRow(this.activeRowIndex), e); |
| 13395 |
setTimeout( |
| 13396 |
function () { |
| 13397 |
if (this.$rowIndexToRow(this.activeRowIndex) !== rowFoldingWidget) { |
| 13398 |
this.$blurFoldWidget(this.activeRowIndex); |
| 13399 |
this.activeRowIndex = this.$rowToRowIndex(rowFoldingWidget); |
| 13400 |
this.$focusFoldWidget(this.activeRowIndex); |
| 13401 |
} |
| 13402 |
}.bind(this), 10); |
| 13403 |
break; |
| 13404 |
} |
| 13405 |
else if (this.gutterLayer.session.foldWidgets[this.$rowIndexToRow(this.activeRowIndex)] === 'end') { |
| 13406 |
break; |
| 13407 |
} |
| 13408 |
return; |
| 13409 |
case "annotation": |
| 13410 |
var gutterElement = this.lines.cells[this.activeRowIndex].element.childNodes[2]; |
| 13411 |
var rect = gutterElement.getBoundingClientRect(); |
| 13412 |
var style = this.annotationTooltip.getElement().style; |
| 13413 |
style.left = rect.right + "px"; |
| 13414 |
style.top = rect.bottom + "px"; |
| 13415 |
this.annotationTooltip.showTooltip(this.$rowIndexToRow(this.activeRowIndex)); |
| 13416 |
break; |
| 13417 |
} |
| 13418 |
return; |
| 13419 |
} |
| 13420 |
}; |
| 13421 |
GutterKeyboardHandler.prototype.$blurGutter = function () { |
| 13422 |
if (this.activeRowIndex !== null) { |
| 13423 |
switch (this.activeLane) { |
| 13424 |
case "fold": |
| 13425 |
this.$blurFoldWidget(this.activeRowIndex); |
| 13426 |
break; |
| 13427 |
case "annotation": |
| 13428 |
this.$blurAnnotation(this.activeRowIndex); |
| 13429 |
break; |
| 13430 |
} |
| 13431 |
} |
| 13432 |
if (this.annotationTooltip.isOpen) |
| 13433 |
this.annotationTooltip.hideTooltip(); |
| 13434 |
return; |
| 13435 |
}; |
| 13436 |
GutterKeyboardHandler.prototype.$isFoldWidgetVisible = function (index) { |
| 13437 |
var isRowFullyVisible = this.editor.isRowFullyVisible(this.$rowIndexToRow(index)); |
| 13438 |
var isIconVisible = this.$getFoldWidget(index).style.display !== "none"; |
| 13439 |
return isRowFullyVisible && isIconVisible; |
| 13440 |
}; |
| 13441 |
GutterKeyboardHandler.prototype.$isAnnotationVisible = function (index) { |
| 13442 |
var isRowFullyVisible = this.editor.isRowFullyVisible(this.$rowIndexToRow(index)); |
| 13443 |
var isIconVisible = this.$getAnnotation(index).style.display !== "none"; |
| 13444 |
return isRowFullyVisible && isIconVisible; |
| 13445 |
}; |
| 13446 |
GutterKeyboardHandler.prototype.$getFoldWidget = function (index) { |
| 13447 |
var cell = this.lines.get(index); |
| 13448 |
var element = cell.element; |
| 13449 |
return element.childNodes[1]; |
| 13450 |
}; |
| 13451 |
GutterKeyboardHandler.prototype.$getAnnotation = function (index) { |
| 13452 |
var cell = this.lines.get(index); |
| 13453 |
var element = cell.element; |
| 13454 |
return element.childNodes[2]; |
| 13455 |
}; |
| 13456 |
GutterKeyboardHandler.prototype.$findNearestFoldWidget = function (index) { |
| 13457 |
if (this.$isFoldWidgetVisible(index)) |
| 13458 |
return index; |
| 13459 |
var i = 0; |
| 13460 |
while (index - i > 0 || index + i < this.lines.getLength() - 1) { |
| 13461 |
i++; |
| 13462 |
if (index - i >= 0 && this.$isFoldWidgetVisible(index - i)) |
| 13463 |
return index - i; |
| 13464 |
if (index + i <= this.lines.getLength() - 1 && this.$isFoldWidgetVisible(index + i)) |
| 13465 |
return index + i; |
| 13466 |
} |
| 13467 |
return null; |
| 13468 |
}; |
| 13469 |
GutterKeyboardHandler.prototype.$findNearestAnnotation = function (index) { |
| 13470 |
if (this.$isAnnotationVisible(index)) |
| 13471 |
return index; |
| 13472 |
var i = 0; |
| 13473 |
while (index - i > 0 || index + i < this.lines.getLength() - 1) { |
| 13474 |
i++; |
| 13475 |
if (index - i >= 0 && this.$isAnnotationVisible(index - i)) |
| 13476 |
return index - i; |
| 13477 |
if (index + i <= this.lines.getLength() - 1 && this.$isAnnotationVisible(index + i)) |
| 13478 |
return index + i; |
| 13479 |
} |
| 13480 |
return null; |
| 13481 |
}; |
| 13482 |
GutterKeyboardHandler.prototype.$focusFoldWidget = function (index) { |
| 13483 |
if (index == null) |
| 13484 |
return; |
| 13485 |
var foldWidget = this.$getFoldWidget(index); |
| 13486 |
foldWidget.classList.add(this.editor.renderer.keyboardFocusClassName); |
| 13487 |
foldWidget.focus(); |
| 13488 |
}; |
| 13489 |
GutterKeyboardHandler.prototype.$focusAnnotation = function (index) { |
| 13490 |
if (index == null) |
| 13491 |
return; |
| 13492 |
var annotation = this.$getAnnotation(index); |
| 13493 |
annotation.classList.add(this.editor.renderer.keyboardFocusClassName); |
| 13494 |
annotation.focus(); |
| 13495 |
}; |
| 13496 |
GutterKeyboardHandler.prototype.$blurFoldWidget = function (index) { |
| 13497 |
var foldWidget = this.$getFoldWidget(index); |
| 13498 |
foldWidget.classList.remove(this.editor.renderer.keyboardFocusClassName); |
| 13499 |
foldWidget.blur(); |
| 13500 |
}; |
| 13501 |
GutterKeyboardHandler.prototype.$blurAnnotation = function (index) { |
| 13502 |
var annotation = this.$getAnnotation(index); |
| 13503 |
annotation.classList.remove(this.editor.renderer.keyboardFocusClassName); |
| 13504 |
annotation.blur(); |
| 13505 |
}; |
| 13506 |
GutterKeyboardHandler.prototype.$moveFoldWidgetUp = function () { |
| 13507 |
var index = this.activeRowIndex; |
| 13508 |
while (index > 0) { |
| 13509 |
index--; |
| 13510 |
if (this.$isFoldWidgetVisible(index)) { |
| 13511 |
this.$blurFoldWidget(this.activeRowIndex); |
| 13512 |
this.activeRowIndex = index; |
| 13513 |
this.$focusFoldWidget(this.activeRowIndex); |
| 13514 |
return; |
| 13515 |
} |
| 13516 |
} |
| 13517 |
return; |
| 13518 |
}; |
| 13519 |
GutterKeyboardHandler.prototype.$moveFoldWidgetDown = function () { |
| 13520 |
var index = this.activeRowIndex; |
| 13521 |
while (index < this.lines.getLength() - 1) { |
| 13522 |
index++; |
| 13523 |
if (this.$isFoldWidgetVisible(index)) { |
| 13524 |
this.$blurFoldWidget(this.activeRowIndex); |
| 13525 |
this.activeRowIndex = index; |
| 13526 |
this.$focusFoldWidget(this.activeRowIndex); |
| 13527 |
return; |
| 13528 |
} |
| 13529 |
} |
| 13530 |
return; |
| 13531 |
}; |
| 13532 |
GutterKeyboardHandler.prototype.$moveAnnotationUp = function () { |
| 13533 |
var index = this.activeRowIndex; |
| 13534 |
while (index > 0) { |
| 13535 |
index--; |
| 13536 |
if (this.$isAnnotationVisible(index)) { |
| 13537 |
this.$blurAnnotation(this.activeRowIndex); |
| 13538 |
this.activeRowIndex = index; |
| 13539 |
this.$focusAnnotation(this.activeRowIndex); |
| 13540 |
return; |
| 13541 |
} |
| 13542 |
} |
| 13543 |
return; |
| 13544 |
}; |
| 13545 |
GutterKeyboardHandler.prototype.$moveAnnotationDown = function () { |
| 13546 |
var index = this.activeRowIndex; |
| 13547 |
while (index < this.lines.getLength() - 1) { |
| 13548 |
index++; |
| 13549 |
if (this.$isAnnotationVisible(index)) { |
| 13550 |
this.$blurAnnotation(this.activeRowIndex); |
| 13551 |
this.activeRowIndex = index; |
| 13552 |
this.$focusAnnotation(this.activeRowIndex); |
| 13553 |
return; |
| 13554 |
} |
| 13555 |
} |
| 13556 |
return; |
| 13557 |
}; |
| 13558 |
GutterKeyboardHandler.prototype.$switchLane = function (desinationLane) { |
| 13559 |
switch (desinationLane) { |
| 13560 |
case "annotation": |
| 13561 |
if (this.activeLane === "annotation") { |
| 13562 |
break; |
| 13563 |
} |
| 13564 |
var annotationIndex = this.$findNearestAnnotation(this.activeRowIndex); |
| 13565 |
if (annotationIndex == null) { |
| 13566 |
break; |
| 13567 |
} |
| 13568 |
this.activeLane = "annotation"; |
| 13569 |
this.$blurFoldWidget(this.activeRowIndex); |
| 13570 |
this.activeRowIndex = annotationIndex; |
| 13571 |
this.$focusAnnotation(this.activeRowIndex); |
| 13572 |
break; |
| 13573 |
case "fold": |
| 13574 |
if (this.activeLane === "fold") { |
| 13575 |
break; |
| 13576 |
} |
| 13577 |
var foldWidgetIndex = this.$findNearestFoldWidget(this.activeRowIndex); |
| 13578 |
if (foldWidgetIndex == null) { |
| 13579 |
break; |
| 13580 |
} |
| 13581 |
this.activeLane = "fold"; |
| 13582 |
this.$blurAnnotation(this.activeRowIndex); |
| 13583 |
this.activeRowIndex = foldWidgetIndex; |
| 13584 |
this.$focusFoldWidget(this.activeRowIndex); |
| 13585 |
break; |
| 13586 |
} |
| 13587 |
return; |
| 13588 |
}; |
| 13589 |
GutterKeyboardHandler.prototype.$rowIndexToRow = function (index) { |
| 13590 |
var cell = this.lines.get(index); |
| 13591 |
if (cell) |
| 13592 |
return cell.row; |
| 13593 |
return null; |
| 13594 |
}; |
| 13595 |
GutterKeyboardHandler.prototype.$rowToRowIndex = function (row) { |
| 13596 |
for (var i = 0; i < this.lines.getLength(); i++) { |
| 13597 |
var cell = this.lines.get(i); |
| 13598 |
if (cell.row == row) |
| 13599 |
return i; |
| 13600 |
} |
| 13601 |
return null; |
| 13602 |
}; |
| 13603 |
return GutterKeyboardHandler; |
| 13604 |
}()); |
| 13605 |
exports.GutterKeyboardHandler = GutterKeyboardHandler; |
| 13606 |
var GutterKeyboardEvent = (function () { |
| 13607 |
function GutterKeyboardEvent(domEvent, gutterKeyboardHandler) { |
| 13608 |
this.gutterKeyboardHandler = gutterKeyboardHandler; |
| 13609 |
this.domEvent = domEvent; |
| 13610 |
} |
| 13611 |
GutterKeyboardEvent.prototype.getKey = function () { |
| 13612 |
return keys.keyCodeToString(this.domEvent.keyCode); |
| 13613 |
}; |
| 13614 |
GutterKeyboardEvent.prototype.getRow = function () { |
| 13615 |
return this.gutterKeyboardHandler.$rowIndexToRow(this.gutterKeyboardHandler.activeRowIndex); |
| 13616 |
}; |
| 13617 |
GutterKeyboardEvent.prototype.isInAnnotationLane = function () { |
| 13618 |
return this.gutterKeyboardHandler.activeLane === "annotation"; |
| 13619 |
}; |
| 13620 |
GutterKeyboardEvent.prototype.isInFoldLane = function () { |
| 13621 |
return this.gutterKeyboardHandler.activeLane === "fold"; |
| 13622 |
}; |
| 13623 |
return GutterKeyboardEvent; |
| 13624 |
}()); |
| 13625 |
exports.GutterKeyboardEvent = GutterKeyboardEvent; |
| 13626 |
|
| 13627 |
}); |
| 13628 |
|
| 13629 |
ace.define("ace/editor",["require","exports","module","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","ace/token_iterator","ace/line_widgets","ace/keyboard/gutter_handler","ace/config","ace/clipboard","ace/lib/keys"], function(require, exports, module){"use strict"; |
| 13630 |
var __values = (this && this.__values) || function(o) { |
| 13631 |
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; |
| 13632 |
if (m) return m.call(o); |
| 13633 |
if (o && typeof o.length === "number") return { |
| 13634 |
next: function () { |
| 13635 |
if (o && i >= o.length) o = void 0; |
| 13636 |
return { value: o && o[i++], done: !o }; |
| 13637 |
} |
| 13638 |
}; |
| 13639 |
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); |
| 13640 |
}; |
| 13641 |
var oop = require("./lib/oop"); |
| 13642 |
var dom = require("./lib/dom"); |
| 13643 |
var lang = require("./lib/lang"); |
| 13644 |
var useragent = require("./lib/useragent"); |
| 13645 |
var TextInput = require("./keyboard/textinput").TextInput; |
| 13646 |
var MouseHandler = require("./mouse/mouse_handler").MouseHandler; |
| 13647 |
var FoldHandler = require("./mouse/fold_handler").FoldHandler; |
| 13648 |
var KeyBinding = require("./keyboard/keybinding").KeyBinding; |
| 13649 |
var EditSession = require("./edit_session").EditSession; |
| 13650 |
var Search = require("./search").Search; |
| 13651 |
var Range = require("./range").Range; |
| 13652 |
var EventEmitter = require("./lib/event_emitter").EventEmitter; |
| 13653 |
var CommandManager = require("./commands/command_manager").CommandManager; |
| 13654 |
var defaultCommands = require("./commands/default_commands").commands; |
| 13655 |
var config = require("./config"); |
| 13656 |
var TokenIterator = require("./token_iterator").TokenIterator; |
| 13657 |
var LineWidgets = require("./line_widgets").LineWidgets; |
| 13658 |
var GutterKeyboardHandler = require("./keyboard/gutter_handler").GutterKeyboardHandler; |
| 13659 |
var nls = require("./config").nls; |
| 13660 |
var clipboard = require("./clipboard"); |
| 13661 |
var keys = require('./lib/keys'); |
| 13662 |
var Editor = (function () { |
| 13663 |
function Editor(renderer, session, options) { this.session; |
| 13664 |
this.$toDestroy = []; |
| 13665 |
var container = renderer.getContainerElement(); |
| 13666 |
this.container = container; |
| 13667 |
this.renderer = renderer; |
| 13668 |
this.id = "editor" + (++Editor.$uid); |
| 13669 |
this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands); |
| 13670 |
if (typeof document == "object") { |
| 13671 |
this.textInput = new TextInput(renderer.getTextAreaContainer(), this); |
| 13672 |
this.renderer.textarea = this.textInput.getElement(); |
| 13673 |
this.$mouseHandler = new MouseHandler(this); |
| 13674 |
new FoldHandler(this); |
| 13675 |
} |
| 13676 |
this.keyBinding = new KeyBinding(this); |
| 13677 |
this.$search = new Search().set({ |
| 13678 |
wrap: true |
| 13679 |
}); |
| 13680 |
this.$historyTracker = this.$historyTracker.bind(this); |
| 13681 |
this.commands.on("exec", this.$historyTracker); |
| 13682 |
this.$initOperationListeners(); |
| 13683 |
this._$emitInputEvent = lang.delayedCall(function () { |
| 13684 |
this._signal("input", {}); |
| 13685 |
if (this.session && !this.session.destroyed) |
| 13686 |
this.session.bgTokenizer.scheduleStart(); |
| 13687 |
}.bind(this)); |
| 13688 |
this.on("change", function (_, _self) { |
| 13689 |
_self._$emitInputEvent.schedule(31); |
| 13690 |
}); |
| 13691 |
this.setSession(session || options && options.session || new EditSession("")); |
| 13692 |
config.resetOptions(this); |
| 13693 |
if (options) |
| 13694 |
this.setOptions(options); |
| 13695 |
config._signal("editor", this); |
| 13696 |
} |
| 13697 |
Editor.prototype.$initOperationListeners = function () { |
| 13698 |
this.commands.on("exec", this.startOperation.bind(this), true); |
| 13699 |
this.commands.on("afterExec", this.endOperation.bind(this), true); |
| 13700 |
this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this, true)); |
| 13701 |
this.on("change", function () { |
| 13702 |
if (!this.curOp) { |
| 13703 |
this.startOperation(); |
| 13704 |
this.curOp.selectionBefore = this.$lastSel; |
| 13705 |
} |
| 13706 |
this.curOp.docChanged = true; |
| 13707 |
}.bind(this), true); |
| 13708 |
this.on("changeSelection", function () { |
| 13709 |
if (!this.curOp) { |
| 13710 |
this.startOperation(); |
| 13711 |
this.curOp.selectionBefore = this.$lastSel; |
| 13712 |
} |
| 13713 |
this.curOp.selectionChanged = true; |
| 13714 |
}.bind(this), true); |
| 13715 |
}; |
| 13716 |
Editor.prototype.startOperation = function (commandEvent) { |
| 13717 |
if (this.curOp) { |
| 13718 |
if (!commandEvent || this.curOp.command) |
| 13719 |
return; |
| 13720 |
this.prevOp = this.curOp; |
| 13721 |
} |
| 13722 |
if (!commandEvent) { |
| 13723 |
this.previousCommand = null; |
| 13724 |
commandEvent = {}; |
| 13725 |
} |
| 13726 |
this.$opResetTimer.schedule(); |
| 13727 |
this.curOp = this.session.curOp = { |
| 13728 |
command: commandEvent.command || {}, |
| 13729 |
args: commandEvent.args, |
| 13730 |
scrollTop: this.renderer.scrollTop |
| 13731 |
}; |
| 13732 |
this.curOp.selectionBefore = this.selection.toJSON(); |
| 13733 |
}; |
| 13734 |
Editor.prototype.endOperation = function (e) { |
| 13735 |
if (this.curOp && this.session) { |
| 13736 |
if (e && e.returnValue === false || !this.session) |
| 13737 |
return (this.curOp = null); |
| 13738 |
if (e == true && this.curOp.command && this.curOp.command.name == "mouse") |
| 13739 |
return; |
| 13740 |
this._signal("beforeEndOperation"); |
| 13741 |
if (!this.curOp) |
| 13742 |
return; |
| 13743 |
var command = this.curOp.command; |
| 13744 |
var scrollIntoView = command && command.scrollIntoView; |
| 13745 |
if (scrollIntoView) { |
| 13746 |
switch (scrollIntoView) { |
| 13747 |
case "center-animate": |
| 13748 |
scrollIntoView = "animate"; |
| 13749 |
case "center": |
| 13750 |
this.renderer.scrollCursorIntoView(null, 0.5); |
| 13751 |
break; |
| 13752 |
case "animate": |
| 13753 |
case "cursor": |
| 13754 |
this.renderer.scrollCursorIntoView(); |
| 13755 |
break; |
| 13756 |
case "selectionPart": |
| 13757 |
var range = this.selection.getRange(); |
| 13758 |
var config = this.renderer.layerConfig; |
| 13759 |
if (range.start.row >= config.lastRow || range.end.row <= config.firstRow) { |
| 13760 |
this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead); |
| 13761 |
} |
| 13762 |
break; |
| 13763 |
default: |
| 13764 |
break; |
| 13765 |
} |
| 13766 |
if (scrollIntoView == "animate") |
| 13767 |
this.renderer.animateScrolling(this.curOp.scrollTop); |
| 13768 |
} |
| 13769 |
var sel = this.selection.toJSON(); |
| 13770 |
this.curOp.selectionAfter = sel; |
| 13771 |
this.$lastSel = this.selection.toJSON(); |
| 13772 |
this.session.getUndoManager().addSelection(sel); |
| 13773 |
this.prevOp = this.curOp; |
| 13774 |
this.curOp = null; |
| 13775 |
} |
| 13776 |
}; |
| 13777 |
Editor.prototype.$historyTracker = function (e) { |
| 13778 |
if (!this.$mergeUndoDeltas) |
| 13779 |
return; |
| 13780 |
var prev = this.prevOp; |
| 13781 |
var mergeableCommands = this.$mergeableCommands; |
| 13782 |
var shouldMerge = prev.command && (e.command.name == prev.command.name); |
| 13783 |
if (e.command.name == "insertstring") { |
| 13784 |
var text = e.args; |
| 13785 |
if (this.mergeNextCommand === undefined) |
| 13786 |
this.mergeNextCommand = true; |
| 13787 |
shouldMerge = shouldMerge |
| 13788 |
&& this.mergeNextCommand |
| 13789 |
&& (!/\s/.test(text) || /\s/.test(prev.args)); |
| 13790 |
this.mergeNextCommand = true; |
| 13791 |
} |
| 13792 |
else { |
| 13793 |
shouldMerge = shouldMerge |
| 13794 |
&& mergeableCommands.indexOf(e.command.name) !== -1; |
| 13795 |
} |
| 13796 |
if (this.$mergeUndoDeltas != "always" |
| 13797 |
&& Date.now() - this.sequenceStartTime > 2000) { |
| 13798 |
shouldMerge = false; |
| 13799 |
} |
| 13800 |
if (shouldMerge) |
| 13801 |
this.session.mergeUndoDeltas = true; |
| 13802 |
else if (mergeableCommands.indexOf(e.command.name) !== -1) |
| 13803 |
this.sequenceStartTime = Date.now(); |
| 13804 |
}; |
| 13805 |
Editor.prototype.setKeyboardHandler = function (keyboardHandler, cb) { |
| 13806 |
if (keyboardHandler && typeof keyboardHandler === "string" && keyboardHandler != "ace") { |
| 13807 |
this.$keybindingId = keyboardHandler; |
| 13808 |
var _self = this; |
| 13809 |
config.loadModule(["keybinding", keyboardHandler], function (module) { |
| 13810 |
if (_self.$keybindingId == keyboardHandler) |
| 13811 |
_self.keyBinding.setKeyboardHandler(module && module.handler); |
| 13812 |
cb && cb(); |
| 13813 |
}); |
| 13814 |
} |
| 13815 |
else { |
| 13816 |
this.$keybindingId = null; |
| 13817 |
this.keyBinding.setKeyboardHandler(keyboardHandler); |
| 13818 |
cb && cb(); |
| 13819 |
} |
| 13820 |
}; |
| 13821 |
Editor.prototype.getKeyboardHandler = function () { |
| 13822 |
return this.keyBinding.getKeyboardHandler(); |
| 13823 |
}; |
| 13824 |
Editor.prototype.setSession = function (session) { |
| 13825 |
if (this.session == session) |
| 13826 |
return; |
| 13827 |
if (this.curOp) |
| 13828 |
this.endOperation(); |
| 13829 |
this.curOp = {}; |
| 13830 |
var oldSession = this.session; |
| 13831 |
if (oldSession) { |
| 13832 |
this.session.off("change", this.$onDocumentChange); |
| 13833 |
this.session.off("changeMode", this.$onChangeMode); |
| 13834 |
this.session.off("tokenizerUpdate", this.$onTokenizerUpdate); |
| 13835 |
this.session.off("changeTabSize", this.$onChangeTabSize); |
| 13836 |
this.session.off("changeWrapLimit", this.$onChangeWrapLimit); |
| 13837 |
this.session.off("changeWrapMode", this.$onChangeWrapMode); |
| 13838 |
this.session.off("changeFold", this.$onChangeFold); |
| 13839 |
this.session.off("changeFrontMarker", this.$onChangeFrontMarker); |
| 13840 |
this.session.off("changeBackMarker", this.$onChangeBackMarker); |
| 13841 |
this.session.off("changeBreakpoint", this.$onChangeBreakpoint); |
| 13842 |
this.session.off("changeAnnotation", this.$onChangeAnnotation); |
| 13843 |
this.session.off("changeOverwrite", this.$onCursorChange); |
| 13844 |
this.session.off("changeScrollTop", this.$onScrollTopChange); |
| 13845 |
this.session.off("changeScrollLeft", this.$onScrollLeftChange); |
| 13846 |
var selection = this.session.getSelection(); |
| 13847 |
selection.off("changeCursor", this.$onCursorChange); |
| 13848 |
selection.off("changeSelection", this.$onSelectionChange); |
| 13849 |
} |
| 13850 |
this.session = session; |
| 13851 |
if (session) { |
| 13852 |
this.$onDocumentChange = this.onDocumentChange.bind(this); |
| 13853 |
session.on("change", this.$onDocumentChange); |
| 13854 |
this.renderer.setSession(session); |
| 13855 |
this.$onChangeMode = this.onChangeMode.bind(this); |
| 13856 |
session.on("changeMode", this.$onChangeMode); |
| 13857 |
this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this); |
| 13858 |
session.on("tokenizerUpdate", this.$onTokenizerUpdate); |
| 13859 |
this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer); |
| 13860 |
session.on("changeTabSize", this.$onChangeTabSize); |
| 13861 |
this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this); |
| 13862 |
session.on("changeWrapLimit", this.$onChangeWrapLimit); |
| 13863 |
this.$onChangeWrapMode = this.onChangeWrapMode.bind(this); |
| 13864 |
session.on("changeWrapMode", this.$onChangeWrapMode); |
| 13865 |
this.$onChangeFold = this.onChangeFold.bind(this); |
| 13866 |
session.on("changeFold", this.$onChangeFold); |
| 13867 |
this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this); |
| 13868 |
this.session.on("changeFrontMarker", this.$onChangeFrontMarker); |
| 13869 |
this.$onChangeBackMarker = this.onChangeBackMarker.bind(this); |
| 13870 |
this.session.on("changeBackMarker", this.$onChangeBackMarker); |
| 13871 |
this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this); |
| 13872 |
this.session.on("changeBreakpoint", this.$onChangeBreakpoint); |
| 13873 |
this.$onChangeAnnotation = this.onChangeAnnotation.bind(this); |
| 13874 |
this.session.on("changeAnnotation", this.$onChangeAnnotation); |
| 13875 |
this.$onCursorChange = this.onCursorChange.bind(this); |
| 13876 |
this.session.on("changeOverwrite", this.$onCursorChange); |
| 13877 |
this.$onScrollTopChange = this.onScrollTopChange.bind(this); |
| 13878 |
this.session.on("changeScrollTop", this.$onScrollTopChange); |
| 13879 |
this.$onScrollLeftChange = this.onScrollLeftChange.bind(this); |
| 13880 |
this.session.on("changeScrollLeft", this.$onScrollLeftChange); |
| 13881 |
this.selection = session.getSelection(); |
| 13882 |
this.selection.on("changeCursor", this.$onCursorChange); |
| 13883 |
this.$onSelectionChange = this.onSelectionChange.bind(this); |
| 13884 |
this.selection.on("changeSelection", this.$onSelectionChange); |
| 13885 |
this.onChangeMode(); |
| 13886 |
this.onCursorChange(); |
| 13887 |
this.onScrollTopChange(); |
| 13888 |
this.onScrollLeftChange(); |
| 13889 |
this.onSelectionChange(); |
| 13890 |
this.onChangeFrontMarker(); |
| 13891 |
this.onChangeBackMarker(); |
| 13892 |
this.onChangeBreakpoint(); |
| 13893 |
this.onChangeAnnotation(); |
| 13894 |
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit(); |
| 13895 |
this.renderer.updateFull(); |
| 13896 |
} |
| 13897 |
else { |
| 13898 |
this.selection = null; |
| 13899 |
this.renderer.setSession(session); |
| 13900 |
} |
| 13901 |
this._signal("changeSession", { |
| 13902 |
session: session, |
| 13903 |
oldSession: oldSession |
| 13904 |
}); |
| 13905 |
this.curOp = null; |
| 13906 |
oldSession && oldSession._signal("changeEditor", { oldEditor: this }); |
| 13907 |
session && session._signal("changeEditor", { editor: this }); |
| 13908 |
if (session && !session.destroyed) |
| 13909 |
session.bgTokenizer.scheduleStart(); |
| 13910 |
}; |
| 13911 |
Editor.prototype.getSession = function () { |
| 13912 |
return this.session; |
| 13913 |
}; |
| 13914 |
Editor.prototype.setValue = function (val, cursorPos) { |
| 13915 |
this.session.doc.setValue(val); |
| 13916 |
if (!cursorPos) |
| 13917 |
this.selectAll(); |
| 13918 |
else if (cursorPos == 1) |
| 13919 |
this.navigateFileEnd(); |
| 13920 |
else if (cursorPos == -1) |
| 13921 |
this.navigateFileStart(); |
| 13922 |
return val; |
| 13923 |
}; |
| 13924 |
Editor.prototype.getValue = function () { |
| 13925 |
return this.session.getValue(); |
| 13926 |
}; |
| 13927 |
Editor.prototype.getSelection = function () { |
| 13928 |
return this.selection; |
| 13929 |
}; |
| 13930 |
Editor.prototype.resize = function (force) { |
| 13931 |
this.renderer.onResize(force); |
| 13932 |
}; |
| 13933 |
Editor.prototype.setTheme = function (theme, cb) { |
| 13934 |
this.renderer.setTheme(theme, cb); |
| 13935 |
}; |
| 13936 |
Editor.prototype.getTheme = function () { |
| 13937 |
return this.renderer.getTheme(); |
| 13938 |
}; |
| 13939 |
Editor.prototype.setStyle = function (style) { |
| 13940 |
this.renderer.setStyle(style); |
| 13941 |
}; |
| 13942 |
Editor.prototype.unsetStyle = function (style) { |
| 13943 |
this.renderer.unsetStyle(style); |
| 13944 |
}; |
| 13945 |
Editor.prototype.getFontSize = function () { |
| 13946 |
return this.getOption("fontSize") || |
| 13947 |
dom.computedStyle(this.container).fontSize; |
| 13948 |
}; |
| 13949 |
Editor.prototype.setFontSize = function (size) { |
| 13950 |
this.setOption("fontSize", size); |
| 13951 |
}; |
| 13952 |
Editor.prototype.$highlightBrackets = function () { |
| 13953 |
if (this.$highlightPending) { |
| 13954 |
return; |
| 13955 |
} |
| 13956 |
var self = this; |
| 13957 |
this.$highlightPending = true; |
| 13958 |
setTimeout(function () { |
| 13959 |
self.$highlightPending = false; |
| 13960 |
var session = self.session; |
| 13961 |
if (!session || session.destroyed) |
| 13962 |
return; |
| 13963 |
if (session.$bracketHighlight) { |
| 13964 |
session.$bracketHighlight.markerIds.forEach(function (id) { |
| 13965 |
session.removeMarker(id); |
| 13966 |
}); |
| 13967 |
session.$bracketHighlight = null; |
| 13968 |
} |
| 13969 |
var pos = self.getCursorPosition(); |
| 13970 |
var handler = self.getKeyboardHandler(); |
| 13971 |
var isBackwards = handler && handler.$getDirectionForHighlight && handler.$getDirectionForHighlight(self); |
| 13972 |
var ranges = session.getMatchingBracketRanges(pos, isBackwards); |
| 13973 |
if (!ranges) { |
| 13974 |
var iterator = new TokenIterator(session, pos.row, pos.column); |
| 13975 |
var token = iterator.getCurrentToken(); |
| 13976 |
if (token && /\b(?:tag-open|tag-name)/.test(token.type)) { |
| 13977 |
var tagNamesRanges = session.getMatchingTags(pos); |
| 13978 |
if (tagNamesRanges) |
| 13979 |
ranges = [tagNamesRanges.openTagName, tagNamesRanges.closeTagName]; |
| 13980 |
} |
| 13981 |
} |
| 13982 |
if (!ranges && session.$mode.getMatching) |
| 13983 |
ranges = session.$mode.getMatching(self.session); |
| 13984 |
if (!ranges) { |
| 13985 |
if (self.getHighlightIndentGuides()) |
| 13986 |
self.renderer.$textLayer.$highlightIndentGuide(); |
| 13987 |
return; |
| 13988 |
} |
| 13989 |
var markerType = "ace_bracket"; |
| 13990 |
if (!Array.isArray(ranges)) { |
| 13991 |
ranges = [ranges]; |
| 13992 |
} |
| 13993 |
else if (ranges.length == 1) { |
| 13994 |
markerType = "ace_error_bracket"; |
| 13995 |
} |
| 13996 |
if (ranges.length == 2) { |
| 13997 |
if (Range.comparePoints(ranges[0].end, ranges[1].start) == 0) |
| 13998 |
ranges = [Range.fromPoints(ranges[0].start, ranges[1].end)]; |
| 13999 |
else if (Range.comparePoints(ranges[0].start, ranges[1].end) == 0) |
| 14000 |
ranges = [Range.fromPoints(ranges[1].start, ranges[0].end)]; |
| 14001 |
} |
| 14002 |
session.$bracketHighlight = { |
| 14003 |
ranges: ranges, |
| 14004 |
markerIds: ranges.map(function (range) { |
| 14005 |
return session.addMarker(range, markerType, "text"); |
| 14006 |
}) |
| 14007 |
}; |
| 14008 |
if (self.getHighlightIndentGuides()) |
| 14009 |
self.renderer.$textLayer.$highlightIndentGuide(); |
| 14010 |
}, 50); |
| 14011 |
}; |
| 14012 |
Editor.prototype.focus = function () { |
| 14013 |
this.textInput.focus(); |
| 14014 |
}; |
| 14015 |
Editor.prototype.isFocused = function () { |
| 14016 |
return this.textInput.isFocused(); |
| 14017 |
}; |
| 14018 |
Editor.prototype.blur = function () { |
| 14019 |
this.textInput.blur(); |
| 14020 |
}; |
| 14021 |
Editor.prototype.onFocus = function (e) { |
| 14022 |
if (this.$isFocused) |
| 14023 |
return; |
| 14024 |
this.$isFocused = true; |
| 14025 |
this.renderer.showCursor(); |
| 14026 |
this.renderer.visualizeFocus(); |
| 14027 |
this._emit("focus", e); |
| 14028 |
}; |
| 14029 |
Editor.prototype.onBlur = function (e) { |
| 14030 |
if (!this.$isFocused) |
| 14031 |
return; |
| 14032 |
this.$isFocused = false; |
| 14033 |
this.renderer.hideCursor(); |
| 14034 |
this.renderer.visualizeBlur(); |
| 14035 |
this._emit("blur", e); |
| 14036 |
}; |
| 14037 |
Editor.prototype.$cursorChange = function () { |
| 14038 |
this.renderer.updateCursor(); |
| 14039 |
this.$highlightBrackets(); |
| 14040 |
this.$updateHighlightActiveLine(); |
| 14041 |
}; |
| 14042 |
Editor.prototype.onDocumentChange = function (delta) { |
| 14043 |
var wrap = this.session.$useWrapMode; |
| 14044 |
var lastRow = (delta.start.row == delta.end.row ? delta.end.row : Infinity); |
| 14045 |
this.renderer.updateLines(delta.start.row, lastRow, wrap); |
| 14046 |
this._signal("change", delta); |
| 14047 |
this.$cursorChange(); |
| 14048 |
}; |
| 14049 |
Editor.prototype.onTokenizerUpdate = function (e) { |
| 14050 |
var rows = e.data; |
| 14051 |
this.renderer.updateLines(rows.first, rows.last); |
| 14052 |
}; |
| 14053 |
Editor.prototype.onScrollTopChange = function () { |
| 14054 |
this.renderer.scrollToY(this.session.getScrollTop()); |
| 14055 |
}; |
| 14056 |
Editor.prototype.onScrollLeftChange = function () { |
| 14057 |
this.renderer.scrollToX(this.session.getScrollLeft()); |
| 14058 |
}; |
| 14059 |
Editor.prototype.onCursorChange = function () { |
| 14060 |
this.$cursorChange(); |
| 14061 |
this._signal("changeSelection"); |
| 14062 |
}; |
| 14063 |
Editor.prototype.$updateHighlightActiveLine = function () { |
| 14064 |
var session = this.getSession(); |
| 14065 |
var highlight; |
| 14066 |
if (this.$highlightActiveLine) { |
| 14067 |
if (this.$selectionStyle != "line" || !this.selection.isMultiLine()) |
| 14068 |
highlight = this.getCursorPosition(); |
| 14069 |
if (this.renderer.theme && this.renderer.theme.$selectionColorConflict && !this.selection.isEmpty()) |
| 14070 |
highlight = false; |
| 14071 |
if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1)) |
| 14072 |
highlight = false; |
| 14073 |
} |
| 14074 |
if (session.$highlightLineMarker && !highlight) { |
| 14075 |
session.removeMarker(session.$highlightLineMarker.id); |
| 14076 |
session.$highlightLineMarker = null; |
| 14077 |
} |
| 14078 |
else if (!session.$highlightLineMarker && highlight) { |
| 14079 |
var range = new Range(highlight.row, highlight.column, highlight.row, Infinity); |
| 14080 |
range.id = session.addMarker(range, "ace_active-line", "screenLine"); |
| 14081 |
session.$highlightLineMarker = range; |
| 14082 |
} |
| 14083 |
else if (highlight) { |
| 14084 |
session.$highlightLineMarker.start.row = highlight.row; |
| 14085 |
session.$highlightLineMarker.end.row = highlight.row; |
| 14086 |
session.$highlightLineMarker.start.column = highlight.column; |
| 14087 |
session._signal("changeBackMarker"); |
| 14088 |
} |
| 14089 |
}; |
| 14090 |
Editor.prototype.onSelectionChange = function (e) { |
| 14091 |
var session = this.session; |
| 14092 |
if (session.$selectionMarker) { |
| 14093 |
session.removeMarker(session.$selectionMarker); |
| 14094 |
} |
| 14095 |
session.$selectionMarker = null; |
| 14096 |
if (!this.selection.isEmpty()) { |
| 14097 |
var range = this.selection.getRange(); |
| 14098 |
var style = this.getSelectionStyle(); |
| 14099 |
session.$selectionMarker = session.addMarker(range, "ace_selection", style); |
| 14100 |
} |
| 14101 |
else { |
| 14102 |
this.$updateHighlightActiveLine(); |
| 14103 |
} |
| 14104 |
var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp(); |
| 14105 |
this.session.highlight(re); |
| 14106 |
this._signal("changeSelection"); |
| 14107 |
}; |
| 14108 |
Editor.prototype.$getSelectionHighLightRegexp = function () { |
| 14109 |
var session = this.session; |
| 14110 |
var selection = this.getSelectionRange(); |
| 14111 |
if (selection.isEmpty() || selection.isMultiLine()) |
| 14112 |
return; |
| 14113 |
var startColumn = selection.start.column; |
| 14114 |
var endColumn = selection.end.column; |
| 14115 |
var line = session.getLine(selection.start.row); |
| 14116 |
var needle = line.substring(startColumn, endColumn); |
| 14117 |
if (needle.length > 5000 || !/[\w\d]/.test(needle)) |
| 14118 |
return; |
| 14119 |
var re = this.$search.$assembleRegExp({ |
| 14120 |
wholeWord: true, |
| 14121 |
caseSensitive: true, |
| 14122 |
needle: needle |
| 14123 |
}); |
| 14124 |
var wordWithBoundary = line.substring(startColumn - 1, endColumn + 1); |
| 14125 |
if (!re.test(wordWithBoundary)) |
| 14126 |
return; |
| 14127 |
return re; |
| 14128 |
}; |
| 14129 |
Editor.prototype.onChangeFrontMarker = function () { |
| 14130 |
this.renderer.updateFrontMarkers(); |
| 14131 |
}; |
| 14132 |
Editor.prototype.onChangeBackMarker = function () { |
| 14133 |
this.renderer.updateBackMarkers(); |
| 14134 |
}; |
| 14135 |
Editor.prototype.onChangeBreakpoint = function () { |
| 14136 |
this.renderer.updateBreakpoints(); |
| 14137 |
}; |
| 14138 |
Editor.prototype.onChangeAnnotation = function () { |
| 14139 |
this.renderer.setAnnotations(this.session.getAnnotations()); |
| 14140 |
}; |
| 14141 |
Editor.prototype.onChangeMode = function (e) { |
| 14142 |
this.renderer.updateText(); |
| 14143 |
this._emit("changeMode", e); |
| 14144 |
}; |
| 14145 |
Editor.prototype.onChangeWrapLimit = function () { |
| 14146 |
this.renderer.updateFull(); |
| 14147 |
}; |
| 14148 |
Editor.prototype.onChangeWrapMode = function () { |
| 14149 |
this.renderer.onResize(true); |
| 14150 |
}; |
| 14151 |
Editor.prototype.onChangeFold = function () { |
| 14152 |
this.$updateHighlightActiveLine(); |
| 14153 |
this.renderer.updateFull(); |
| 14154 |
}; |
| 14155 |
Editor.prototype.getSelectedText = function () { |
| 14156 |
return this.session.getTextRange(this.getSelectionRange()); |
| 14157 |
}; |
| 14158 |
Editor.prototype.getCopyText = function () { |
| 14159 |
var text = this.getSelectedText(); |
| 14160 |
var nl = this.session.doc.getNewLineCharacter(); |
| 14161 |
var copyLine = false; |
| 14162 |
if (!text && this.$copyWithEmptySelection) { |
| 14163 |
copyLine = true; |
| 14164 |
var ranges = this.selection.getAllRanges(); |
| 14165 |
for (var i = 0; i < ranges.length; i++) { |
| 14166 |
var range = ranges[i]; |
| 14167 |
if (i && ranges[i - 1].start.row == range.start.row) |
| 14168 |
continue; |
| 14169 |
text += this.session.getLine(range.start.row) + nl; |
| 14170 |
} |
| 14171 |
} |
| 14172 |
var e = { text: text }; |
| 14173 |
this._signal("copy", e); |
| 14174 |
clipboard.lineMode = copyLine ? e.text : false; |
| 14175 |
return e.text; |
| 14176 |
}; |
| 14177 |
Editor.prototype.onCopy = function () { |
| 14178 |
this.commands.exec("copy", this); |
| 14179 |
}; |
| 14180 |
Editor.prototype.onCut = function () { |
| 14181 |
this.commands.exec("cut", this); |
| 14182 |
}; |
| 14183 |
Editor.prototype.onPaste = function (text, event) { |
| 14184 |
var e = { text: text, event: event }; |
| 14185 |
this.commands.exec("paste", this, e); |
| 14186 |
}; |
| 14187 |
Editor.prototype.$handlePaste = function (e) { |
| 14188 |
if (typeof e == "string") |
| 14189 |
e = { text: e }; |
| 14190 |
this._signal("paste", e); |
| 14191 |
var text = e.text; |
| 14192 |
var lineMode = text === clipboard.lineMode; |
| 14193 |
var session = this.session; |
| 14194 |
if (!this.inMultiSelectMode || this.inVirtualSelectionMode) { |
| 14195 |
if (lineMode) |
| 14196 |
session.insert({ row: this.selection.lead.row, column: 0 }, text); |
| 14197 |
else |
| 14198 |
this.insert(text); |
| 14199 |
} |
| 14200 |
else if (lineMode) { |
| 14201 |
this.selection.rangeList.ranges.forEach(function (range) { |
| 14202 |
session.insert({ row: range.start.row, column: 0 }, text); |
| 14203 |
}); |
| 14204 |
} |
| 14205 |
else { |
| 14206 |
var lines = text.split(/\r\n|\r|\n/); |
| 14207 |
var ranges = this.selection.rangeList.ranges; |
| 14208 |
var isFullLine = lines.length == 2 && (!lines[0] || !lines[1]); |
| 14209 |
if (lines.length != ranges.length || isFullLine) |
| 14210 |
return this.commands.exec("insertstring", this, text); |
| 14211 |
for (var i = ranges.length; i--;) { |
| 14212 |
var range = ranges[i]; |
| 14213 |
if (!range.isEmpty()) |
| 14214 |
session.remove(range); |
| 14215 |
session.insert(range.start, lines[i]); |
| 14216 |
} |
| 14217 |
} |
| 14218 |
}; |
| 14219 |
Editor.prototype.execCommand = function (command, args) { |
| 14220 |
return this.commands.exec(command, this, args); |
| 14221 |
}; |
| 14222 |
Editor.prototype.insert = function (text, pasted) { |
| 14223 |
var session = this.session; |
| 14224 |
var mode = session.getMode(); |
| 14225 |
var cursor = this.getCursorPosition(); |
| 14226 |
if (this.getBehavioursEnabled() && !pasted) { |
| 14227 |
var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text); |
| 14228 |
if (transform) { |
| 14229 |
if (text !== transform.text) { |
| 14230 |
if (!this.inVirtualSelectionMode) { |
| 14231 |
this.session.mergeUndoDeltas = false; |
| 14232 |
this.mergeNextCommand = false; |
| 14233 |
} |
| 14234 |
} |
| 14235 |
text = transform.text; |
| 14236 |
} |
| 14237 |
} |
| 14238 |
if (text == "\t") |
| 14239 |
text = this.session.getTabString(); |
| 14240 |
if (!this.selection.isEmpty()) { |
| 14241 |
var range = this.getSelectionRange(); |
| 14242 |
cursor = this.session.remove(range); |
| 14243 |
this.clearSelection(); |
| 14244 |
} |
| 14245 |
else if (this.session.getOverwrite() && text.indexOf("\n") == -1) { |
| 14246 |
var range = Range.fromPoints(cursor, cursor); |
| 14247 |
range.end.column += text.length; |
| 14248 |
this.session.remove(range); |
| 14249 |
} |
| 14250 |
if (text == "\n" || text == "\r\n") { |
| 14251 |
var line = session.getLine(cursor.row); |
| 14252 |
if (cursor.column > line.search(/\S|$/)) { |
| 14253 |
var d = line.substr(cursor.column).search(/\S|$/); |
| 14254 |
session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d); |
| 14255 |
} |
| 14256 |
} |
| 14257 |
this.clearSelection(); |
| 14258 |
var start = cursor.column; |
| 14259 |
var lineState = session.getState(cursor.row); |
| 14260 |
var line = session.getLine(cursor.row); |
| 14261 |
var shouldOutdent = mode.checkOutdent(lineState, line, text); |
| 14262 |
session.insert(cursor, text); |
| 14263 |
if (transform && transform.selection) { |
| 14264 |
if (transform.selection.length == 2) { |
| 14265 |
this.selection.setSelectionRange(new Range(cursor.row, start + transform.selection[0], cursor.row, start + transform.selection[1])); |
| 14266 |
} |
| 14267 |
else { |
| 14268 |
this.selection.setSelectionRange(new Range(cursor.row + transform.selection[0], transform.selection[1], cursor.row + transform.selection[2], transform.selection[3])); |
| 14269 |
} |
| 14270 |
} |
| 14271 |
if (this.$enableAutoIndent) { |
| 14272 |
if (session.getDocument().isNewLine(text)) { |
| 14273 |
var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString()); |
| 14274 |
session.insert({ row: cursor.row + 1, column: 0 }, lineIndent); |
| 14275 |
} |
| 14276 |
if (shouldOutdent) |
| 14277 |
mode.autoOutdent(lineState, session, cursor.row); |
| 14278 |
} |
| 14279 |
}; |
| 14280 |
Editor.prototype.autoIndent = function () { |
| 14281 |
var session = this.session; |
| 14282 |
var mode = session.getMode(); |
| 14283 |
var ranges = this.selection.isEmpty() |
| 14284 |
? [new Range(0, 0, session.doc.getLength() - 1, 0)] |
| 14285 |
: this.selection.getAllRanges(); |
| 14286 |
var prevLineState = ""; |
| 14287 |
var prevLine = ""; |
| 14288 |
var lineIndent = ""; |
| 14289 |
var tab = session.getTabString(); |
| 14290 |
for (var i = 0; i < ranges.length; i++) { |
| 14291 |
var startRow = ranges[i].start.row; |
| 14292 |
var endRow = ranges[i].end.row; |
| 14293 |
for (var row = startRow; row <= endRow; row++) { |
| 14294 |
if (row > 0) { |
| 14295 |
prevLineState = session.getState(row - 1); |
| 14296 |
prevLine = session.getLine(row - 1); |
| 14297 |
lineIndent = mode.getNextLineIndent(prevLineState, prevLine, tab); |
| 14298 |
} |
| 14299 |
var line = session.getLine(row); |
| 14300 |
var currIndent = mode.$getIndent(line); |
| 14301 |
if (lineIndent !== currIndent) { |
| 14302 |
if (currIndent.length > 0) { |
| 14303 |
var range = new Range(row, 0, row, currIndent.length); |
| 14304 |
session.remove(range); |
| 14305 |
} |
| 14306 |
if (lineIndent.length > 0) { |
| 14307 |
session.insert({ row: row, column: 0 }, lineIndent); |
| 14308 |
} |
| 14309 |
} |
| 14310 |
mode.autoOutdent(prevLineState, session, row); |
| 14311 |
} |
| 14312 |
} |
| 14313 |
}; |
| 14314 |
Editor.prototype.onTextInput = function (text, composition) { |
| 14315 |
if (!composition) |
| 14316 |
return this.keyBinding.onTextInput(text); |
| 14317 |
this.startOperation({ command: { name: "insertstring" } }); |
| 14318 |
var applyComposition = this.applyComposition.bind(this, text, composition); |
| 14319 |
if (this.selection.rangeCount) |
| 14320 |
this.forEachSelection(applyComposition); |
| 14321 |
else |
| 14322 |
applyComposition(); |
| 14323 |
this.endOperation(); |
| 14324 |
}; |
| 14325 |
Editor.prototype.applyComposition = function (text, composition) { |
| 14326 |
if (composition.extendLeft || composition.extendRight) { |
| 14327 |
var r = this.selection.getRange(); |
| 14328 |
r.start.column -= composition.extendLeft; |
| 14329 |
r.end.column += composition.extendRight; |
| 14330 |
if (r.start.column < 0) { |
| 14331 |
r.start.row--; |
| 14332 |
r.start.column += this.session.getLine(r.start.row).length + 1; |
| 14333 |
} |
| 14334 |
this.selection.setRange(r); |
| 14335 |
if (!text && !r.isEmpty()) |
| 14336 |
this.remove(); |
| 14337 |
} |
| 14338 |
if (text || !this.selection.isEmpty()) |
| 14339 |
this.insert(text, true); |
| 14340 |
if (composition.restoreStart || composition.restoreEnd) { |
| 14341 |
var r = this.selection.getRange(); |
| 14342 |
r.start.column -= composition.restoreStart; |
| 14343 |
r.end.column -= composition.restoreEnd; |
| 14344 |
this.selection.setRange(r); |
| 14345 |
} |
| 14346 |
}; |
| 14347 |
Editor.prototype.onCommandKey = function (e, hashId, keyCode) { |
| 14348 |
return this.keyBinding.onCommandKey(e, hashId, keyCode); |
| 14349 |
}; |
| 14350 |
Editor.prototype.setOverwrite = function (overwrite) { |
| 14351 |
this.session.setOverwrite(overwrite); |
| 14352 |
}; |
| 14353 |
Editor.prototype.getOverwrite = function () { |
| 14354 |
return this.session.getOverwrite(); |
| 14355 |
}; |
| 14356 |
Editor.prototype.toggleOverwrite = function () { |
| 14357 |
this.session.toggleOverwrite(); |
| 14358 |
}; |
| 14359 |
Editor.prototype.setScrollSpeed = function (speed) { |
| 14360 |
this.setOption("scrollSpeed", speed); |
| 14361 |
}; |
| 14362 |
Editor.prototype.getScrollSpeed = function () { |
| 14363 |
return this.getOption("scrollSpeed"); |
| 14364 |
}; |
| 14365 |
Editor.prototype.setDragDelay = function (dragDelay) { |
| 14366 |
this.setOption("dragDelay", dragDelay); |
| 14367 |
}; |
| 14368 |
Editor.prototype.getDragDelay = function () { |
| 14369 |
return this.getOption("dragDelay"); |
| 14370 |
}; |
| 14371 |
Editor.prototype.setSelectionStyle = function (val) { |
| 14372 |
this.setOption("selectionStyle", val); |
| 14373 |
}; |
| 14374 |
Editor.prototype.getSelectionStyle = function () { |
| 14375 |
return this.getOption("selectionStyle"); |
| 14376 |
}; |
| 14377 |
Editor.prototype.setHighlightActiveLine = function (shouldHighlight) { |
| 14378 |
this.setOption("highlightActiveLine", shouldHighlight); |
| 14379 |
}; |
| 14380 |
Editor.prototype.getHighlightActiveLine = function () { |
| 14381 |
return this.getOption("highlightActiveLine"); |
| 14382 |
}; |
| 14383 |
Editor.prototype.setHighlightGutterLine = function (shouldHighlight) { |
| 14384 |
this.setOption("highlightGutterLine", shouldHighlight); |
| 14385 |
}; |
| 14386 |
Editor.prototype.getHighlightGutterLine = function () { |
| 14387 |
return this.getOption("highlightGutterLine"); |
| 14388 |
}; |
| 14389 |
Editor.prototype.setHighlightSelectedWord = function (shouldHighlight) { |
| 14390 |
this.setOption("highlightSelectedWord", shouldHighlight); |
| 14391 |
}; |
| 14392 |
Editor.prototype.getHighlightSelectedWord = function () { |
| 14393 |
return this.$highlightSelectedWord; |
| 14394 |
}; |
| 14395 |
Editor.prototype.setAnimatedScroll = function (shouldAnimate) { |
| 14396 |
this.renderer.setAnimatedScroll(shouldAnimate); |
| 14397 |
}; |
| 14398 |
Editor.prototype.getAnimatedScroll = function () { |
| 14399 |
return this.renderer.getAnimatedScroll(); |
| 14400 |
}; |
| 14401 |
Editor.prototype.setShowInvisibles = function (showInvisibles) { |
| 14402 |
this.renderer.setShowInvisibles(showInvisibles); |
| 14403 |
}; |
| 14404 |
Editor.prototype.getShowInvisibles = function () { |
| 14405 |
return this.renderer.getShowInvisibles(); |
| 14406 |
}; |
| 14407 |
Editor.prototype.setDisplayIndentGuides = function (display) { |
| 14408 |
this.renderer.setDisplayIndentGuides(display); |
| 14409 |
}; |
| 14410 |
Editor.prototype.getDisplayIndentGuides = function () { |
| 14411 |
return this.renderer.getDisplayIndentGuides(); |
| 14412 |
}; |
| 14413 |
Editor.prototype.setHighlightIndentGuides = function (highlight) { |
| 14414 |
this.renderer.setHighlightIndentGuides(highlight); |
| 14415 |
}; |
| 14416 |
Editor.prototype.getHighlightIndentGuides = function () { |
| 14417 |
return this.renderer.getHighlightIndentGuides(); |
| 14418 |
}; |
| 14419 |
Editor.prototype.setShowPrintMargin = function (showPrintMargin) { |
| 14420 |
this.renderer.setShowPrintMargin(showPrintMargin); |
| 14421 |
}; |
| 14422 |
Editor.prototype.getShowPrintMargin = function () { |
| 14423 |
return this.renderer.getShowPrintMargin(); |
| 14424 |
}; |
| 14425 |
Editor.prototype.setPrintMarginColumn = function (showPrintMargin) { |
| 14426 |
this.renderer.setPrintMarginColumn(showPrintMargin); |
| 14427 |
}; |
| 14428 |
Editor.prototype.getPrintMarginColumn = function () { |
| 14429 |
return this.renderer.getPrintMarginColumn(); |
| 14430 |
}; |
| 14431 |
Editor.prototype.setReadOnly = function (readOnly) { |
| 14432 |
this.setOption("readOnly", readOnly); |
| 14433 |
}; |
| 14434 |
Editor.prototype.getReadOnly = function () { |
| 14435 |
return this.getOption("readOnly"); |
| 14436 |
}; |
| 14437 |
Editor.prototype.setBehavioursEnabled = function (enabled) { |
| 14438 |
this.setOption("behavioursEnabled", enabled); |
| 14439 |
}; |
| 14440 |
Editor.prototype.getBehavioursEnabled = function () { |
| 14441 |
return this.getOption("behavioursEnabled"); |
| 14442 |
}; |
| 14443 |
Editor.prototype.setWrapBehavioursEnabled = function (enabled) { |
| 14444 |
this.setOption("wrapBehavioursEnabled", enabled); |
| 14445 |
}; |
| 14446 |
Editor.prototype.getWrapBehavioursEnabled = function () { |
| 14447 |
return this.getOption("wrapBehavioursEnabled"); |
| 14448 |
}; |
| 14449 |
Editor.prototype.setShowFoldWidgets = function (show) { |
| 14450 |
this.setOption("showFoldWidgets", show); |
| 14451 |
}; |
| 14452 |
Editor.prototype.getShowFoldWidgets = function () { |
| 14453 |
return this.getOption("showFoldWidgets"); |
| 14454 |
}; |
| 14455 |
Editor.prototype.setFadeFoldWidgets = function (fade) { |
| 14456 |
this.setOption("fadeFoldWidgets", fade); |
| 14457 |
}; |
| 14458 |
Editor.prototype.getFadeFoldWidgets = function () { |
| 14459 |
return this.getOption("fadeFoldWidgets"); |
| 14460 |
}; |
| 14461 |
Editor.prototype.remove = function (dir) { |
| 14462 |
if (this.selection.isEmpty()) { |
| 14463 |
if (dir == "left") |
| 14464 |
this.selection.selectLeft(); |
| 14465 |
else |
| 14466 |
this.selection.selectRight(); |
| 14467 |
} |
| 14468 |
var range = this.getSelectionRange(); |
| 14469 |
if (this.getBehavioursEnabled()) { |
| 14470 |
var session = this.session; |
| 14471 |
var state = session.getState(range.start.row); |
| 14472 |
var new_range = session.getMode().transformAction(state, 'deletion', this, session, range); |
| 14473 |
if (range.end.column === 0) { |
| 14474 |
var text = session.getTextRange(range); |
| 14475 |
if (text[text.length - 1] == "\n") { |
| 14476 |
var line = session.getLine(range.end.row); |
| 14477 |
if (/^\s+$/.test(line)) { |
| 14478 |
range.end.column = line.length; |
| 14479 |
} |
| 14480 |
} |
| 14481 |
} |
| 14482 |
if (new_range) |
| 14483 |
range = new_range; |
| 14484 |
} |
| 14485 |
this.session.remove(range); |
| 14486 |
this.clearSelection(); |
| 14487 |
}; |
| 14488 |
Editor.prototype.removeWordRight = function () { |
| 14489 |
if (this.selection.isEmpty()) |
| 14490 |
this.selection.selectWordRight(); |
| 14491 |
this.session.remove(this.getSelectionRange()); |
| 14492 |
this.clearSelection(); |
| 14493 |
}; |
| 14494 |
Editor.prototype.removeWordLeft = function () { |
| 14495 |
if (this.selection.isEmpty()) |
| 14496 |
this.selection.selectWordLeft(); |
| 14497 |
this.session.remove(this.getSelectionRange()); |
| 14498 |
this.clearSelection(); |
| 14499 |
}; |
| 14500 |
Editor.prototype.removeToLineStart = function () { |
| 14501 |
if (this.selection.isEmpty()) |
| 14502 |
this.selection.selectLineStart(); |
| 14503 |
if (this.selection.isEmpty()) |
| 14504 |
this.selection.selectLeft(); |
| 14505 |
this.session.remove(this.getSelectionRange()); |
| 14506 |
this.clearSelection(); |
| 14507 |
}; |
| 14508 |
Editor.prototype.removeToLineEnd = function () { |
| 14509 |
if (this.selection.isEmpty()) |
| 14510 |
this.selection.selectLineEnd(); |
| 14511 |
var range = this.getSelectionRange(); |
| 14512 |
if (range.start.column == range.end.column && range.start.row == range.end.row) { |
| 14513 |
range.end.column = 0; |
| 14514 |
range.end.row++; |
| 14515 |
} |
| 14516 |
this.session.remove(range); |
| 14517 |
this.clearSelection(); |
| 14518 |
}; |
| 14519 |
Editor.prototype.splitLine = function () { |
| 14520 |
if (!this.selection.isEmpty()) { |
| 14521 |
this.session.remove(this.getSelectionRange()); |
| 14522 |
this.clearSelection(); |
| 14523 |
} |
| 14524 |
var cursor = this.getCursorPosition(); |
| 14525 |
this.insert("\n"); |
| 14526 |
this.moveCursorToPosition(cursor); |
| 14527 |
}; |
| 14528 |
Editor.prototype.setGhostText = function (text, position) { |
| 14529 |
if (!this.session.widgetManager) { |
| 14530 |
this.session.widgetManager = new LineWidgets(this.session); |
| 14531 |
this.session.widgetManager.attach(this); |
| 14532 |
} |
| 14533 |
this.renderer.setGhostText(text, position); |
| 14534 |
}; |
| 14535 |
Editor.prototype.removeGhostText = function () { |
| 14536 |
if (!this.session.widgetManager) |
| 14537 |
return; |
| 14538 |
this.renderer.removeGhostText(); |
| 14539 |
}; |
| 14540 |
Editor.prototype.transposeLetters = function () { |
| 14541 |
if (!this.selection.isEmpty()) { |
| 14542 |
return; |
| 14543 |
} |
| 14544 |
var cursor = this.getCursorPosition(); |
| 14545 |
var column = cursor.column; |
| 14546 |
if (column === 0) |
| 14547 |
return; |
| 14548 |
var line = this.session.getLine(cursor.row); |
| 14549 |
var swap, range; |
| 14550 |
if (column < line.length) { |
| 14551 |
swap = line.charAt(column) + line.charAt(column - 1); |
| 14552 |
range = new Range(cursor.row, column - 1, cursor.row, column + 1); |
| 14553 |
} |
| 14554 |
else { |
| 14555 |
swap = line.charAt(column - 1) + line.charAt(column - 2); |
| 14556 |
range = new Range(cursor.row, column - 2, cursor.row, column); |
| 14557 |
} |
| 14558 |
this.session.replace(range, swap); |
| 14559 |
this.session.selection.moveToPosition(range.end); |
| 14560 |
}; |
| 14561 |
Editor.prototype.toLowerCase = function () { |
| 14562 |
var originalRange = this.getSelectionRange(); |
| 14563 |
if (this.selection.isEmpty()) { |
| 14564 |
this.selection.selectWord(); |
| 14565 |
} |
| 14566 |
var range = this.getSelectionRange(); |
| 14567 |
var text = this.session.getTextRange(range); |
| 14568 |
this.session.replace(range, text.toLowerCase()); |
| 14569 |
this.selection.setSelectionRange(originalRange); |
| 14570 |
}; |
| 14571 |
Editor.prototype.toUpperCase = function () { |
| 14572 |
var originalRange = this.getSelectionRange(); |
| 14573 |
if (this.selection.isEmpty()) { |
| 14574 |
this.selection.selectWord(); |
| 14575 |
} |
| 14576 |
var range = this.getSelectionRange(); |
| 14577 |
var text = this.session.getTextRange(range); |
| 14578 |
this.session.replace(range, text.toUpperCase()); |
| 14579 |
this.selection.setSelectionRange(originalRange); |
| 14580 |
}; |
| 14581 |
Editor.prototype.indent = function () { |
| 14582 |
var session = this.session; |
| 14583 |
var range = this.getSelectionRange(); |
| 14584 |
if (range.start.row < range.end.row) { |
| 14585 |
var rows = this.$getSelectedRows(); |
| 14586 |
session.indentRows(rows.first, rows.last, "\t"); |
| 14587 |
return; |
| 14588 |
} |
| 14589 |
else if (range.start.column < range.end.column) { |
| 14590 |
var text = session.getTextRange(range); |
| 14591 |
if (!/^\s+$/.test(text)) { |
| 14592 |
var rows = this.$getSelectedRows(); |
| 14593 |
session.indentRows(rows.first, rows.last, "\t"); |
| 14594 |
return; |
| 14595 |
} |
| 14596 |
} |
| 14597 |
var line = session.getLine(range.start.row); |
| 14598 |
var position = range.start; |
| 14599 |
var size = session.getTabSize(); |
| 14600 |
var column = session.documentToScreenColumn(position.row, position.column); |
| 14601 |
if (this.session.getUseSoftTabs()) { |
| 14602 |
var count = (size - column % size); |
| 14603 |
var indentString = lang.stringRepeat(" ", count); |
| 14604 |
} |
| 14605 |
else { |
| 14606 |
var count = column % size; |
| 14607 |
while (line[range.start.column - 1] == " " && count) { |
| 14608 |
range.start.column--; |
| 14609 |
count--; |
| 14610 |
} |
| 14611 |
this.selection.setSelectionRange(range); |
| 14612 |
indentString = "\t"; |
| 14613 |
} |
| 14614 |
return this.insert(indentString); |
| 14615 |
}; |
| 14616 |
Editor.prototype.blockIndent = function () { |
| 14617 |
var rows = this.$getSelectedRows(); |
| 14618 |
this.session.indentRows(rows.first, rows.last, "\t"); |
| 14619 |
}; |
| 14620 |
Editor.prototype.blockOutdent = function () { |
| 14621 |
var selection = this.session.getSelection(); |
| 14622 |
this.session.outdentRows(selection.getRange()); |
| 14623 |
}; |
| 14624 |
Editor.prototype.sortLines = function () { |
| 14625 |
var rows = this.$getSelectedRows(); |
| 14626 |
var session = this.session; |
| 14627 |
var lines = []; |
| 14628 |
for (var i = rows.first; i <= rows.last; i++) |
| 14629 |
lines.push(session.getLine(i)); |
| 14630 |
lines.sort(function (a, b) { |
| 14631 |
if (a.toLowerCase() < b.toLowerCase()) |
| 14632 |
return -1; |
| 14633 |
if (a.toLowerCase() > b.toLowerCase()) |
| 14634 |
return 1; |
| 14635 |
return 0; |
| 14636 |
}); |
| 14637 |
var deleteRange = new Range(0, 0, 0, 0); |
| 14638 |
for (var i = rows.first; i <= rows.last; i++) { |
| 14639 |
var line = session.getLine(i); |
| 14640 |
deleteRange.start.row = i; |
| 14641 |
deleteRange.end.row = i; |
| 14642 |
deleteRange.end.column = line.length; |
| 14643 |
session.replace(deleteRange, lines[i - rows.first]); |
| 14644 |
} |
| 14645 |
}; |
| 14646 |
Editor.prototype.toggleCommentLines = function () { |
| 14647 |
var state = this.session.getState(this.getCursorPosition().row); |
| 14648 |
var rows = this.$getSelectedRows(); |
| 14649 |
this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last); |
| 14650 |
}; |
| 14651 |
Editor.prototype.toggleBlockComment = function () { |
| 14652 |
var cursor = this.getCursorPosition(); |
| 14653 |
var state = this.session.getState(cursor.row); |
| 14654 |
var range = this.getSelectionRange(); |
| 14655 |
this.session.getMode().toggleBlockComment(state, this.session, range, cursor); |
| 14656 |
}; |
| 14657 |
Editor.prototype.getNumberAt = function (row, column) { |
| 14658 |
var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g; |
| 14659 |
_numberRx.lastIndex = 0; |
| 14660 |
var s = this.session.getLine(row); |
| 14661 |
while (_numberRx.lastIndex < column) { |
| 14662 |
var m = _numberRx.exec(s); |
| 14663 |
if (m.index <= column && m.index + m[0].length >= column) { |
| 14664 |
var number = { |
| 14665 |
value: m[0], |
| 14666 |
start: m.index, |
| 14667 |
end: m.index + m[0].length |
| 14668 |
}; |
| 14669 |
return number; |
| 14670 |
} |
| 14671 |
} |
| 14672 |
return null; |
| 14673 |
}; |
| 14674 |
Editor.prototype.modifyNumber = function (amount) { |
| 14675 |
var row = this.selection.getCursor().row; |
| 14676 |
var column = this.selection.getCursor().column; |
| 14677 |
var charRange = new Range(row, column - 1, row, column); |
| 14678 |
var c = this.session.getTextRange(charRange); |
| 14679 |
if (!isNaN(parseFloat(c)) && isFinite(c)) { |
| 14680 |
var nr = this.getNumberAt(row, column); |
| 14681 |
if (nr) { |
| 14682 |
var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end; |
| 14683 |
var decimals = nr.start + nr.value.length - fp; |
| 14684 |
var t = parseFloat(nr.value); |
| 14685 |
t *= Math.pow(10, decimals); |
| 14686 |
if (fp !== nr.end && column < fp) { |
| 14687 |
amount *= Math.pow(10, nr.end - column - 1); |
| 14688 |
} |
| 14689 |
else { |
| 14690 |
amount *= Math.pow(10, nr.end - column); |
| 14691 |
} |
| 14692 |
t += amount; |
| 14693 |
t /= Math.pow(10, decimals); |
| 14694 |
var nnr = t.toFixed(decimals); |
| 14695 |
var replaceRange = new Range(row, nr.start, row, nr.end); |
| 14696 |
this.session.replace(replaceRange, nnr); |
| 14697 |
this.moveCursorTo(row, Math.max(nr.start + 1, column + nnr.length - nr.value.length)); |
| 14698 |
} |
| 14699 |
} |
| 14700 |
else { |
| 14701 |
this.toggleWord(); |
| 14702 |
} |
| 14703 |
}; |
| 14704 |
Editor.prototype.toggleWord = function () { |
| 14705 |
var row = this.selection.getCursor().row; |
| 14706 |
var column = this.selection.getCursor().column; |
| 14707 |
this.selection.selectWord(); |
| 14708 |
var currentState = this.getSelectedText(); |
| 14709 |
var currWordStart = this.selection.getWordRange().start.column; |
| 14710 |
var wordParts = currentState.replace(/([a-z]+|[A-Z]+)(?=[A-Z_]|$)/g, '$1 ').split(/\s/); |
| 14711 |
var delta = column - currWordStart - 1; |
| 14712 |
if (delta < 0) |
| 14713 |
delta = 0; |
| 14714 |
var curLength = 0, itLength = 0; |
| 14715 |
var that = this; |
| 14716 |
if (currentState.match(/[A-Za-z0-9_]+/)) { |
| 14717 |
wordParts.forEach(function (item, i) { |
| 14718 |
itLength = curLength + item.length; |
| 14719 |
if (delta >= curLength && delta <= itLength) { |
| 14720 |
currentState = item; |
| 14721 |
that.selection.clearSelection(); |
| 14722 |
that.moveCursorTo(row, curLength + currWordStart); |
| 14723 |
that.selection.selectTo(row, itLength + currWordStart); |
| 14724 |
} |
| 14725 |
curLength = itLength; |
| 14726 |
}); |
| 14727 |
} |
| 14728 |
var wordPairs = this.$toggleWordPairs; |
| 14729 |
var reg; |
| 14730 |
for (var i = 0; i < wordPairs.length; i++) { |
| 14731 |
var item = wordPairs[i]; |
| 14732 |
for (var j = 0; j <= 1; j++) { |
| 14733 |
var negate = +!j; |
| 14734 |
var firstCondition = currentState.match(new RegExp('^\\s?_?(' + lang.escapeRegExp(item[j]) + ')\\s?$', 'i')); |
| 14735 |
if (firstCondition) { |
| 14736 |
var secondCondition = currentState.match(new RegExp('([_]|^|\\s)(' + lang.escapeRegExp(firstCondition[1]) + ')($|\\s)', 'g')); |
| 14737 |
if (secondCondition) { |
| 14738 |
reg = currentState.replace(new RegExp(lang.escapeRegExp(item[j]), 'i'), function (result) { |
| 14739 |
var res = item[negate]; |
| 14740 |
if (result.toUpperCase() == result) { |
| 14741 |
res = res.toUpperCase(); |
| 14742 |
} |
| 14743 |
else if (result.charAt(0).toUpperCase() == result.charAt(0)) { |
| 14744 |
res = res.substr(0, 0) + item[negate].charAt(0).toUpperCase() + res.substr(1); |
| 14745 |
} |
| 14746 |
return res; |
| 14747 |
}); |
| 14748 |
this.insert(reg); |
| 14749 |
reg = ""; |
| 14750 |
} |
| 14751 |
} |
| 14752 |
} |
| 14753 |
} |
| 14754 |
}; |
| 14755 |
Editor.prototype.findLinkAt = function (row, column) { |
| 14756 |
var e_1, _a; |
| 14757 |
var line = this.session.getLine(row); |
| 14758 |
var wordParts = line.split(/((?:https?|ftp):\/\/[\S]+)/); |
| 14759 |
var columnPosition = column; |
| 14760 |
if (columnPosition < 0) |
| 14761 |
columnPosition = 0; |
| 14762 |
var previousPosition = 0, currentPosition = 0, match; |
| 14763 |
try { |
| 14764 |
for (var wordParts_1 = __values(wordParts), wordParts_1_1 = wordParts_1.next(); !wordParts_1_1.done; wordParts_1_1 = wordParts_1.next()) { |
| 14765 |
var item = wordParts_1_1.value; |
| 14766 |
currentPosition = previousPosition + item.length; |
| 14767 |
if (columnPosition >= previousPosition && columnPosition <= currentPosition) { |
| 14768 |
if (item.match(/((?:https?|ftp):\/\/[\S]+)/)) { |
| 14769 |
match = item.replace(/[\s:.,'";}\]]+$/, ""); |
| 14770 |
break; |
| 14771 |
} |
| 14772 |
} |
| 14773 |
previousPosition = currentPosition; |
| 14774 |
} |
| 14775 |
} |
| 14776 |
catch (e_1_1) { e_1 = { error: e_1_1 }; } |
| 14777 |
finally { |
| 14778 |
try { |
| 14779 |
if (wordParts_1_1 && !wordParts_1_1.done && (_a = wordParts_1.return)) _a.call(wordParts_1); |
| 14780 |
} |
| 14781 |
finally { if (e_1) throw e_1.error; } |
| 14782 |
} |
| 14783 |
return match; |
| 14784 |
}; |
| 14785 |
Editor.prototype.openLink = function () { |
| 14786 |
var cursor = this.selection.getCursor(); |
| 14787 |
var url = this.findLinkAt(cursor.row, cursor.column); |
| 14788 |
if (url) |
| 14789 |
window.open(url, '_blank'); |
| 14790 |
return url != null; |
| 14791 |
}; |
| 14792 |
Editor.prototype.removeLines = function () { |
| 14793 |
var rows = this.$getSelectedRows(); |
| 14794 |
this.session.removeFullLines(rows.first, rows.last); |
| 14795 |
this.clearSelection(); |
| 14796 |
}; |
| 14797 |
Editor.prototype.duplicateSelection = function () { |
| 14798 |
var sel = this.selection; |
| 14799 |
var doc = this.session; |
| 14800 |
var range = sel.getRange(); |
| 14801 |
var reverse = sel.isBackwards(); |
| 14802 |
if (range.isEmpty()) { |
| 14803 |
var row = range.start.row; |
| 14804 |
doc.duplicateLines(row, row); |
| 14805 |
} |
| 14806 |
else { |
| 14807 |
var point = reverse ? range.start : range.end; |
| 14808 |
var endPoint = doc.insert(point, doc.getTextRange(range)); |
| 14809 |
range.start = point; |
| 14810 |
range.end = endPoint; |
| 14811 |
sel.setSelectionRange(range, reverse); |
| 14812 |
} |
| 14813 |
}; |
| 14814 |
Editor.prototype.moveLinesDown = function () { |
| 14815 |
this.$moveLines(1, false); |
| 14816 |
}; |
| 14817 |
Editor.prototype.moveLinesUp = function () { |
| 14818 |
this.$moveLines(-1, false); |
| 14819 |
}; |
| 14820 |
Editor.prototype.moveText = function (range, toPosition, copy) { |
| 14821 |
return this.session.moveText(range, toPosition, copy); |
| 14822 |
}; |
| 14823 |
Editor.prototype.copyLinesUp = function () { |
| 14824 |
this.$moveLines(-1, true); |
| 14825 |
}; |
| 14826 |
Editor.prototype.copyLinesDown = function () { |
| 14827 |
this.$moveLines(1, true); |
| 14828 |
}; |
| 14829 |
Editor.prototype.$moveLines = function (dir, copy) { |
| 14830 |
var rows, moved; |
| 14831 |
var selection = this.selection; |
| 14832 |
if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) { |
| 14833 |
var range = selection.toOrientedRange(); |
| 14834 |
rows = this.$getSelectedRows(range); |
| 14835 |
moved = this.session.$moveLines(rows.first, rows.last, copy ? 0 : dir); |
| 14836 |
if (copy && dir == -1) |
| 14837 |
moved = 0; |
| 14838 |
range.moveBy(moved, 0); |
| 14839 |
selection.fromOrientedRange(range); |
| 14840 |
} |
| 14841 |
else { |
| 14842 |
var ranges = selection.rangeList.ranges; |
| 14843 |
selection.rangeList.detach(this.session); |
| 14844 |
this.inVirtualSelectionMode = true; |
| 14845 |
var diff = 0; |
| 14846 |
var totalDiff = 0; |
| 14847 |
var l = ranges.length; |
| 14848 |
for (var i = 0; i < l; i++) { |
| 14849 |
var rangeIndex = i; |
| 14850 |
ranges[i].moveBy(diff, 0); |
| 14851 |
rows = this.$getSelectedRows(ranges[i]); |
| 14852 |
var first = rows.first; |
| 14853 |
var last = rows.last; |
| 14854 |
while (++i < l) { |
| 14855 |
if (totalDiff) |
| 14856 |
ranges[i].moveBy(totalDiff, 0); |
| 14857 |
var subRows = this.$getSelectedRows(ranges[i]); |
| 14858 |
if (copy && subRows.first != last) |
| 14859 |
break; |
| 14860 |
else if (!copy && subRows.first > last + 1) |
| 14861 |
break; |
| 14862 |
last = subRows.last; |
| 14863 |
} |
| 14864 |
i--; |
| 14865 |
diff = this.session.$moveLines(first, last, copy ? 0 : dir); |
| 14866 |
if (copy && dir == -1) |
| 14867 |
rangeIndex = i + 1; |
| 14868 |
while (rangeIndex <= i) { |
| 14869 |
ranges[rangeIndex].moveBy(diff, 0); |
| 14870 |
rangeIndex++; |
| 14871 |
} |
| 14872 |
if (!copy) |
| 14873 |
diff = 0; |
| 14874 |
totalDiff += diff; |
| 14875 |
} |
| 14876 |
selection.fromOrientedRange(selection.ranges[0]); |
| 14877 |
selection.rangeList.attach(this.session); |
| 14878 |
this.inVirtualSelectionMode = false; |
| 14879 |
} |
| 14880 |
}; |
| 14881 |
Editor.prototype.$getSelectedRows = function (range) { |
| 14882 |
range = (range || this.getSelectionRange()).collapseRows(); |
| 14883 |
return { |
| 14884 |
first: this.session.getRowFoldStart(range.start.row), |
| 14885 |
last: this.session.getRowFoldEnd(range.end.row) |
| 14886 |
}; |
| 14887 |
}; |
| 14888 |
Editor.prototype.onCompositionStart = function (compositionState) { |
| 14889 |
this.renderer.showComposition(compositionState); |
| 14890 |
}; |
| 14891 |
Editor.prototype.onCompositionUpdate = function (text) { |
| 14892 |
this.renderer.setCompositionText(text); |
| 14893 |
}; |
| 14894 |
Editor.prototype.onCompositionEnd = function () { |
| 14895 |
this.renderer.hideComposition(); |
| 14896 |
}; |
| 14897 |
Editor.prototype.getFirstVisibleRow = function () { |
| 14898 |
return this.renderer.getFirstVisibleRow(); |
| 14899 |
}; |
| 14900 |
Editor.prototype.getLastVisibleRow = function () { |
| 14901 |
return this.renderer.getLastVisibleRow(); |
| 14902 |
}; |
| 14903 |
Editor.prototype.isRowVisible = function (row) { |
| 14904 |
return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow()); |
| 14905 |
}; |
| 14906 |
Editor.prototype.isRowFullyVisible = function (row) { |
| 14907 |
return (row >= this.renderer.getFirstFullyVisibleRow() && row <= this.renderer.getLastFullyVisibleRow()); |
| 14908 |
}; |
| 14909 |
Editor.prototype.$getVisibleRowCount = function () { |
| 14910 |
return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1; |
| 14911 |
}; |
| 14912 |
Editor.prototype.$moveByPage = function (dir, select) { |
| 14913 |
var renderer = this.renderer; |
| 14914 |
var config = this.renderer.layerConfig; |
| 14915 |
var rows = dir * Math.floor(config.height / config.lineHeight); |
| 14916 |
if (select === true) { |
| 14917 |
this.selection.$moveSelection(function () { |
| 14918 |
this.moveCursorBy(rows, 0); |
| 14919 |
}); |
| 14920 |
} |
| 14921 |
else if (select === false) { |
| 14922 |
this.selection.moveCursorBy(rows, 0); |
| 14923 |
this.selection.clearSelection(); |
| 14924 |
} |
| 14925 |
var scrollTop = renderer.scrollTop; |
| 14926 |
renderer.scrollBy(0, rows * config.lineHeight); |
| 14927 |
if (select != null) |
| 14928 |
renderer.scrollCursorIntoView(null, 0.5); |
| 14929 |
renderer.animateScrolling(scrollTop); |
| 14930 |
}; |
| 14931 |
Editor.prototype.selectPageDown = function () { |
| 14932 |
this.$moveByPage(1, true); |
| 14933 |
}; |
| 14934 |
Editor.prototype.selectPageUp = function () { |
| 14935 |
this.$moveByPage(-1, true); |
| 14936 |
}; |
| 14937 |
Editor.prototype.gotoPageDown = function () { |
| 14938 |
this.$moveByPage(1, false); |
| 14939 |
}; |
| 14940 |
Editor.prototype.gotoPageUp = function () { |
| 14941 |
this.$moveByPage(-1, false); |
| 14942 |
}; |
| 14943 |
Editor.prototype.scrollPageDown = function () { |
| 14944 |
this.$moveByPage(1); |
| 14945 |
}; |
| 14946 |
Editor.prototype.scrollPageUp = function () { |
| 14947 |
this.$moveByPage(-1); |
| 14948 |
}; |
| 14949 |
Editor.prototype.scrollToRow = function (row) { |
| 14950 |
this.renderer.scrollToRow(row); |
| 14951 |
}; |
| 14952 |
Editor.prototype.scrollToLine = function (line, center, animate, callback) { |
| 14953 |
this.renderer.scrollToLine(line, center, animate, callback); |
| 14954 |
}; |
| 14955 |
Editor.prototype.centerSelection = function () { |
| 14956 |
var range = this.getSelectionRange(); |
| 14957 |
var pos = { |
| 14958 |
row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2), |
| 14959 |
column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2) |
| 14960 |
}; |
| 14961 |
this.renderer.alignCursor(pos, 0.5); |
| 14962 |
}; |
| 14963 |
Editor.prototype.getCursorPosition = function () { |
| 14964 |
return this.selection.getCursor(); |
| 14965 |
}; |
| 14966 |
Editor.prototype.getCursorPositionScreen = function () { |
| 14967 |
return this.session.documentToScreenPosition(this.getCursorPosition()); |
| 14968 |
}; |
| 14969 |
Editor.prototype.getSelectionRange = function () { |
| 14970 |
return this.selection.getRange(); |
| 14971 |
}; |
| 14972 |
Editor.prototype.selectAll = function () { |
| 14973 |
this.selection.selectAll(); |
| 14974 |
}; |
| 14975 |
Editor.prototype.clearSelection = function () { |
| 14976 |
this.selection.clearSelection(); |
| 14977 |
}; |
| 14978 |
Editor.prototype.moveCursorTo = function (row, column) { |
| 14979 |
this.selection.moveCursorTo(row, column); |
| 14980 |
}; |
| 14981 |
Editor.prototype.moveCursorToPosition = function (pos) { |
| 14982 |
this.selection.moveCursorToPosition(pos); |
| 14983 |
}; |
| 14984 |
Editor.prototype.jumpToMatching = function (select, expand) { |
| 14985 |
var cursor = this.getCursorPosition(); |
| 14986 |
var iterator = new TokenIterator(this.session, cursor.row, cursor.column); |
| 14987 |
var prevToken = iterator.getCurrentToken(); |
| 14988 |
var tokenCount = 0; |
| 14989 |
if (prevToken && prevToken.type.indexOf('tag-name') !== -1) { |
| 14990 |
prevToken = iterator.stepBackward(); |
| 14991 |
} |
| 14992 |
var token = prevToken || iterator.stepForward(); |
| 14993 |
if (!token) |
| 14994 |
return; |
| 14995 |
var matchType; |
| 14996 |
var found = false; |
| 14997 |
var depth = {}; |
| 14998 |
var i = cursor.column - token.start; |
| 14999 |
var bracketType; |
| 15000 |
var brackets = { |
| 15001 |
")": "(", |
| 15002 |
"(": "(", |
| 15003 |
"]": "[", |
| 15004 |
"[": "[", |
| 15005 |
"{": "{", |
| 15006 |
"}": "{" |
| 15007 |
}; |
| 15008 |
do { |
| 15009 |
if (token.value.match(/[{}()\[\]]/g)) { |
| 15010 |
for (; i < token.value.length && !found; i++) { |
| 15011 |
if (!brackets[token.value[i]]) { |
| 15012 |
continue; |
| 15013 |
} |
| 15014 |
bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen"); |
| 15015 |
if (isNaN(depth[bracketType])) { |
| 15016 |
depth[bracketType] = 0; |
| 15017 |
} |
| 15018 |
switch (token.value[i]) { |
| 15019 |
case '(': |
| 15020 |
case '[': |
| 15021 |
case '{': |
| 15022 |
depth[bracketType]++; |
| 15023 |
break; |
| 15024 |
case ')': |
| 15025 |
case ']': |
| 15026 |
case '}': |
| 15027 |
depth[bracketType]--; |
| 15028 |
if (depth[bracketType] === -1) { |
| 15029 |
matchType = 'bracket'; |
| 15030 |
found = true; |
| 15031 |
} |
| 15032 |
break; |
| 15033 |
} |
| 15034 |
} |
| 15035 |
} |
| 15036 |
else if (token.type.indexOf('tag-name') !== -1) { |
| 15037 |
if (isNaN(depth[token.value])) { |
| 15038 |
depth[token.value] = 0; |
| 15039 |
} |
| 15040 |
if (prevToken.value === '<' && tokenCount > 1) { |
| 15041 |
depth[token.value]++; |
| 15042 |
} |
| 15043 |
else if (prevToken.value === '</') { |
| 15044 |
depth[token.value]--; |
| 15045 |
} |
| 15046 |
if (depth[token.value] === -1) { |
| 15047 |
matchType = 'tag'; |
| 15048 |
found = true; |
| 15049 |
} |
| 15050 |
} |
| 15051 |
if (!found) { |
| 15052 |
prevToken = token; |
| 15053 |
tokenCount++; |
| 15054 |
token = iterator.stepForward(); |
| 15055 |
i = 0; |
| 15056 |
} |
| 15057 |
} while (token && !found); |
| 15058 |
if (!matchType) |
| 15059 |
return; |
| 15060 |
var range, pos; |
| 15061 |
if (matchType === 'bracket') { |
| 15062 |
range = this.session.getBracketRange(cursor); |
| 15063 |
if (!range) { |
| 15064 |
range = new Range(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + i - 1, iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + i - 1); |
| 15065 |
pos = range.start; |
| 15066 |
if (expand || pos.row === cursor.row && Math.abs(pos.column - cursor.column) |
| 15067 |
< 2) |
| 15068 |
range = this.session.getBracketRange(pos); |
| 15069 |
} |
| 15070 |
} |
| 15071 |
else if (matchType === 'tag') { |
| 15072 |
if (!token || token.type.indexOf('tag-name') === -1) |
| 15073 |
return; |
| 15074 |
range = new Range(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() - 2, iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() - 2); |
| 15075 |
if (range.compare(cursor.row, cursor.column) === 0) { |
| 15076 |
var tagsRanges = this.session.getMatchingTags(cursor); |
| 15077 |
if (tagsRanges) { |
| 15078 |
if (tagsRanges.openTag.contains(cursor.row, cursor.column)) { |
| 15079 |
range = tagsRanges.closeTag; |
| 15080 |
pos = range.start; |
| 15081 |
} |
| 15082 |
else { |
| 15083 |
range = tagsRanges.openTag; |
| 15084 |
if (tagsRanges.closeTag.start.row === cursor.row && tagsRanges.closeTag.start.column |
| 15085 |
=== cursor.column) |
| 15086 |
pos = range.end; |
| 15087 |
else |
| 15088 |
pos = range.start; |
| 15089 |
} |
| 15090 |
} |
| 15091 |
} |
| 15092 |
pos = pos || range.start; |
| 15093 |
} |
| 15094 |
pos = range && range.cursor || pos; |
| 15095 |
if (pos) { |
| 15096 |
if (select) { |
| 15097 |
if (range && expand) { |
| 15098 |
this.selection.setRange(range); |
| 15099 |
} |
| 15100 |
else if (range && range.isEqual(this.getSelectionRange())) { |
| 15101 |
this.clearSelection(); |
| 15102 |
} |
| 15103 |
else { |
| 15104 |
this.selection.selectTo(pos.row, pos.column); |
| 15105 |
} |
| 15106 |
} |
| 15107 |
else { |
| 15108 |
this.selection.moveTo(pos.row, pos.column); |
| 15109 |
} |
| 15110 |
} |
| 15111 |
}; |
| 15112 |
Editor.prototype.gotoLine = function (lineNumber, column, animate) { |
| 15113 |
this.selection.clearSelection(); |
| 15114 |
this.session.unfold({ row: lineNumber - 1, column: column || 0 }); |
| 15115 |
this.exitMultiSelectMode && this.exitMultiSelectMode(); |
| 15116 |
this.moveCursorTo(lineNumber - 1, column || 0); |
| 15117 |
if (!this.isRowFullyVisible(lineNumber - 1)) |
| 15118 |
this.scrollToLine(lineNumber - 1, true, animate); |
| 15119 |
}; |
| 15120 |
Editor.prototype.navigateTo = function (row, column) { |
| 15121 |
this.selection.moveTo(row, column); |
| 15122 |
}; |
| 15123 |
Editor.prototype.navigateUp = function (times) { |
| 15124 |
if (this.selection.isMultiLine() && !this.selection.isBackwards()) { |
| 15125 |
var selectionStart = this.selection.anchor.getPosition(); |
| 15126 |
return this.moveCursorToPosition(selectionStart); |
| 15127 |
} |
| 15128 |
this.selection.clearSelection(); |
| 15129 |
this.selection.moveCursorBy(-times || -1, 0); |
| 15130 |
}; |
| 15131 |
Editor.prototype.navigateDown = function (times) { |
| 15132 |
if (this.selection.isMultiLine() && this.selection.isBackwards()) { |
| 15133 |
var selectionEnd = this.selection.anchor.getPosition(); |
| 15134 |
return this.moveCursorToPosition(selectionEnd); |
| 15135 |
} |
| 15136 |
this.selection.clearSelection(); |
| 15137 |
this.selection.moveCursorBy(times || 1, 0); |
| 15138 |
}; |
| 15139 |
Editor.prototype.navigateLeft = function (times) { |
| 15140 |
if (!this.selection.isEmpty()) { |
| 15141 |
var selectionStart = this.getSelectionRange().start; |
| 15142 |
this.moveCursorToPosition(selectionStart); |
| 15143 |
} |
| 15144 |
else { |
| 15145 |
times = times || 1; |
| 15146 |
while (times--) { |
| 15147 |
this.selection.moveCursorLeft(); |
| 15148 |
} |
| 15149 |
} |
| 15150 |
this.clearSelection(); |
| 15151 |
}; |
| 15152 |
Editor.prototype.navigateRight = function (times) { |
| 15153 |
if (!this.selection.isEmpty()) { |
| 15154 |
var selectionEnd = this.getSelectionRange().end; |
| 15155 |
this.moveCursorToPosition(selectionEnd); |
| 15156 |
} |
| 15157 |
else { |
| 15158 |
times = times || 1; |
| 15159 |
while (times--) { |
| 15160 |
this.selection.moveCursorRight(); |
| 15161 |
} |
| 15162 |
} |
| 15163 |
this.clearSelection(); |
| 15164 |
}; |
| 15165 |
Editor.prototype.navigateLineStart = function () { |
| 15166 |
this.selection.moveCursorLineStart(); |
| 15167 |
this.clearSelection(); |
| 15168 |
}; |
| 15169 |
Editor.prototype.navigateLineEnd = function () { |
| 15170 |
this.selection.moveCursorLineEnd(); |
| 15171 |
this.clearSelection(); |
| 15172 |
}; |
| 15173 |
Editor.prototype.navigateFileEnd = function () { |
| 15174 |
this.selection.moveCursorFileEnd(); |
| 15175 |
this.clearSelection(); |
| 15176 |
}; |
| 15177 |
Editor.prototype.navigateFileStart = function () { |
| 15178 |
this.selection.moveCursorFileStart(); |
| 15179 |
this.clearSelection(); |
| 15180 |
}; |
| 15181 |
Editor.prototype.navigateWordRight = function () { |
| 15182 |
this.selection.moveCursorWordRight(); |
| 15183 |
this.clearSelection(); |
| 15184 |
}; |
| 15185 |
Editor.prototype.navigateWordLeft = function () { |
| 15186 |
this.selection.moveCursorWordLeft(); |
| 15187 |
this.clearSelection(); |
| 15188 |
}; |
| 15189 |
Editor.prototype.replace = function (replacement, options) { |
| 15190 |
if (options) |
| 15191 |
this.$search.set(options); |
| 15192 |
var range = this.$search.find(this.session); |
| 15193 |
var replaced = 0; |
| 15194 |
if (!range) |
| 15195 |
return replaced; |
| 15196 |
if (this.$tryReplace(range, replacement)) { |
| 15197 |
replaced = 1; |
| 15198 |
} |
| 15199 |
this.selection.setSelectionRange(range); |
| 15200 |
this.renderer.scrollSelectionIntoView(range.start, range.end); |
| 15201 |
return replaced; |
| 15202 |
}; |
| 15203 |
Editor.prototype.replaceAll = function (replacement, options) { |
| 15204 |
if (options) { |
| 15205 |
this.$search.set(options); |
| 15206 |
} |
| 15207 |
var ranges = this.$search.findAll(this.session); |
| 15208 |
var replaced = 0; |
| 15209 |
if (!ranges.length) |
| 15210 |
return replaced; |
| 15211 |
var selection = this.getSelectionRange(); |
| 15212 |
this.selection.moveTo(0, 0); |
| 15213 |
for (var i = ranges.length - 1; i >= 0; --i) { |
| 15214 |
if (this.$tryReplace(ranges[i], replacement)) { |
| 15215 |
replaced++; |
| 15216 |
} |
| 15217 |
} |
| 15218 |
this.selection.setSelectionRange(selection); |
| 15219 |
return replaced; |
| 15220 |
}; |
| 15221 |
Editor.prototype.$tryReplace = function (range, replacement) { |
| 15222 |
var input = this.session.getTextRange(range); |
| 15223 |
replacement = this.$search.replace(input, replacement); |
| 15224 |
if (replacement !== null) { |
| 15225 |
range.end = this.session.replace(range, replacement); |
| 15226 |
return range; |
| 15227 |
} |
| 15228 |
else { |
| 15229 |
return null; |
| 15230 |
} |
| 15231 |
}; |
| 15232 |
Editor.prototype.getLastSearchOptions = function () { |
| 15233 |
return this.$search.getOptions(); |
| 15234 |
}; |
| 15235 |
Editor.prototype.find = function (needle, options, animate) { |
| 15236 |
if (!options) |
| 15237 |
options = {}; |
| 15238 |
if (typeof needle == "string" || needle instanceof RegExp) |
| 15239 |
options.needle = needle; |
| 15240 |
else if (typeof needle == "object") |
| 15241 |
oop.mixin(options, needle); |
| 15242 |
var range = this.selection.getRange(); |
| 15243 |
if (options.needle == null) { |
| 15244 |
needle = this.session.getTextRange(range) |
| 15245 |
|| this.$search.$options.needle; |
| 15246 |
if (!needle) { |
| 15247 |
range = this.session.getWordRange(range.start.row, range.start.column); |
| 15248 |
needle = this.session.getTextRange(range); |
| 15249 |
} |
| 15250 |
this.$search.set({ needle: needle }); |
| 15251 |
} |
| 15252 |
this.$search.set(options); |
| 15253 |
if (!options.start) |
| 15254 |
this.$search.set({ start: range }); |
| 15255 |
var newRange = this.$search.find(this.session); |
| 15256 |
if (options.preventScroll) |
| 15257 |
return newRange; |
| 15258 |
if (newRange) { |
| 15259 |
this.revealRange(newRange, animate); |
| 15260 |
return newRange; |
| 15261 |
} |
| 15262 |
if (options.backwards) |
| 15263 |
range.start = range.end; |
| 15264 |
else |
| 15265 |
range.end = range.start; |
| 15266 |
this.selection.setRange(range); |
| 15267 |
}; |
| 15268 |
Editor.prototype.findNext = function (options, animate) { |
| 15269 |
this.find({ skipCurrent: true, backwards: false }, options, animate); |
| 15270 |
}; |
| 15271 |
Editor.prototype.findPrevious = function (options, animate) { |
| 15272 |
this.find(options, { skipCurrent: true, backwards: true }, animate); |
| 15273 |
}; |
| 15274 |
Editor.prototype.revealRange = function (range, animate) { |
| 15275 |
this.session.unfold(range); |
| 15276 |
this.selection.setSelectionRange(range); |
| 15277 |
var scrollTop = this.renderer.scrollTop; |
| 15278 |
this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5); |
| 15279 |
if (animate !== false) |
| 15280 |
this.renderer.animateScrolling(scrollTop); |
| 15281 |
}; |
| 15282 |
Editor.prototype.undo = function () { |
| 15283 |
this.session.getUndoManager().undo(this.session); |
| 15284 |
this.renderer.scrollCursorIntoView(null, 0.5); |
| 15285 |
}; |
| 15286 |
Editor.prototype.redo = function () { |
| 15287 |
this.session.getUndoManager().redo(this.session); |
| 15288 |
this.renderer.scrollCursorIntoView(null, 0.5); |
| 15289 |
}; |
| 15290 |
Editor.prototype.destroy = function () { |
| 15291 |
if (this.$toDestroy) { |
| 15292 |
this.$toDestroy.forEach(function (el) { |
| 15293 |
el.destroy(); |
| 15294 |
}); |
| 15295 |
this.$toDestroy = null; |
| 15296 |
} |
| 15297 |
if (this.$mouseHandler) |
| 15298 |
this.$mouseHandler.destroy(); |
| 15299 |
this.renderer.destroy(); |
| 15300 |
this._signal("destroy", this); |
| 15301 |
if (this.session) |
| 15302 |
this.session.destroy(); |
| 15303 |
if (this._$emitInputEvent) |
| 15304 |
this._$emitInputEvent.cancel(); |
| 15305 |
this.removeAllListeners(); |
| 15306 |
}; |
| 15307 |
Editor.prototype.setAutoScrollEditorIntoView = function (enable) { |
| 15308 |
if (!enable) |
| 15309 |
return; |
| 15310 |
var rect; |
| 15311 |
var self = this; |
| 15312 |
var shouldScroll = false; |
| 15313 |
if (!this.$scrollAnchor) |
| 15314 |
this.$scrollAnchor = document.createElement("div"); |
| 15315 |
var scrollAnchor = this.$scrollAnchor; |
| 15316 |
scrollAnchor.style.cssText = "position:absolute"; |
| 15317 |
this.container.insertBefore(scrollAnchor, this.container.firstChild); |
| 15318 |
var onChangeSelection = this.on("changeSelection", function () { |
| 15319 |
shouldScroll = true; |
| 15320 |
}); |
| 15321 |
var onBeforeRender = this.renderer.on("beforeRender", function () { |
| 15322 |
if (shouldScroll) |
| 15323 |
rect = self.renderer.container.getBoundingClientRect(); |
| 15324 |
}); |
| 15325 |
var onAfterRender = this.renderer.on("afterRender", function () { |
| 15326 |
if (shouldScroll && rect && (self.isFocused() |
| 15327 |
|| self.searchBox && self.searchBox.isFocused())) { |
| 15328 |
var renderer = self.renderer; |
| 15329 |
var pos = renderer.$cursorLayer.$pixelPos; |
| 15330 |
var config = renderer.layerConfig; |
| 15331 |
var top = pos.top - config.offset; |
| 15332 |
if (pos.top >= 0 && top + rect.top < 0) { |
| 15333 |
shouldScroll = true; |
| 15334 |
} |
| 15335 |
else if (pos.top < config.height && |
| 15336 |
pos.top + rect.top + config.lineHeight > window.innerHeight) { |
| 15337 |
shouldScroll = false; |
| 15338 |
} |
| 15339 |
else { |
| 15340 |
shouldScroll = null; |
| 15341 |
} |
| 15342 |
if (shouldScroll != null) { |
| 15343 |
scrollAnchor.style.top = top + "px"; |
| 15344 |
scrollAnchor.style.left = pos.left + "px"; |
| 15345 |
scrollAnchor.style.height = config.lineHeight + "px"; |
| 15346 |
scrollAnchor.scrollIntoView(shouldScroll); |
| 15347 |
} |
| 15348 |
shouldScroll = rect = null; |
| 15349 |
} |
| 15350 |
}); |
| 15351 |
this.setAutoScrollEditorIntoView = function (enable) { |
| 15352 |
if (enable) |
| 15353 |
return; |
| 15354 |
delete this.setAutoScrollEditorIntoView; |
| 15355 |
this.off("changeSelection", onChangeSelection); |
| 15356 |
this.renderer.off("afterRender", onAfterRender); |
| 15357 |
this.renderer.off("beforeRender", onBeforeRender); |
| 15358 |
}; |
| 15359 |
}; |
| 15360 |
Editor.prototype.$resetCursorStyle = function () { |
| 15361 |
var style = this.$cursorStyle || "ace"; |
| 15362 |
var cursorLayer = this.renderer.$cursorLayer; |
| 15363 |
if (!cursorLayer) |
| 15364 |
return; |
| 15365 |
cursorLayer.setSmoothBlinking(/smooth/.test(style)); |
| 15366 |
cursorLayer.isBlinking = !this.$readOnly && style != "wide"; |
| 15367 |
dom.setCssClass(cursorLayer.element, "ace_slim-cursors", /slim/.test(style)); |
| 15368 |
}; |
| 15369 |
Editor.prototype.prompt = function (message, options, callback) { |
| 15370 |
var editor = this; |
| 15371 |
config.loadModule("ace/ext/prompt", function (module) { |
| 15372 |
module.prompt(editor, message, options, callback); |
| 15373 |
}); |
| 15374 |
}; |
| 15375 |
return Editor; |
| 15376 |
}()); |
| 15377 |
Editor.$uid = 0; |
| 15378 |
Editor.prototype.curOp = null; |
| 15379 |
Editor.prototype.prevOp = {}; |
| 15380 |
Editor.prototype.$mergeableCommands = ["backspace", "del", "insertstring"]; |
| 15381 |
Editor.prototype.$toggleWordPairs = [ |
| 15382 |
["first", "last"], |
| 15383 |
["true", "false"], |
| 15384 |
["yes", "no"], |
| 15385 |
["width", "height"], |
| 15386 |
["top", "bottom"], |
| 15387 |
["right", "left"], |
| 15388 |
["on", "off"], |
| 15389 |
["x", "y"], |
| 15390 |
["get", "set"], |
| 15391 |
["max", "min"], |
| 15392 |
["horizontal", "vertical"], |
| 15393 |
["show", "hide"], |
| 15394 |
["add", "remove"], |
| 15395 |
["up", "down"], |
| 15396 |
["before", "after"], |
| 15397 |
["even", "odd"], |
| 15398 |
["in", "out"], |
| 15399 |
["inside", "outside"], |
| 15400 |
["next", "previous"], |
| 15401 |
["increase", "decrease"], |
| 15402 |
["attach", "detach"], |
| 15403 |
["&&", "||"], |
| 15404 |
["==", "!="] |
| 15405 |
]; |
| 15406 |
oop.implement(Editor.prototype, EventEmitter); |
| 15407 |
config.defineOptions(Editor.prototype, "editor", { |
| 15408 |
selectionStyle: { |
| 15409 |
set: function (style) { |
| 15410 |
this.onSelectionChange(); |
| 15411 |
this._signal("changeSelectionStyle", { data: style }); |
| 15412 |
}, |
| 15413 |
initialValue: "line" |
| 15414 |
}, |
| 15415 |
highlightActiveLine: { |
| 15416 |
set: function () { this.$updateHighlightActiveLine(); }, |
| 15417 |
initialValue: true |
| 15418 |
}, |
| 15419 |
highlightSelectedWord: { |
| 15420 |
set: function (shouldHighlight) { this.$onSelectionChange(); }, |
| 15421 |
initialValue: true |
| 15422 |
}, |
| 15423 |
readOnly: { |
| 15424 |
set: function (readOnly) { |
| 15425 |
this.textInput.setReadOnly(readOnly); |
| 15426 |
this.$resetCursorStyle(); |
| 15427 |
}, |
| 15428 |
initialValue: false |
| 15429 |
}, |
| 15430 |
copyWithEmptySelection: { |
| 15431 |
set: function (value) { |
| 15432 |
this.textInput.setCopyWithEmptySelection(value); |
| 15433 |
}, |
| 15434 |
initialValue: false |
| 15435 |
}, |
| 15436 |
cursorStyle: { |
| 15437 |
set: function (val) { this.$resetCursorStyle(); }, |
| 15438 |
values: ["ace", "slim", "smooth", "wide"], |
| 15439 |
initialValue: "ace" |
| 15440 |
}, |
| 15441 |
mergeUndoDeltas: { |
| 15442 |
values: [false, true, "always"], |
| 15443 |
initialValue: true |
| 15444 |
}, |
| 15445 |
behavioursEnabled: { initialValue: true }, |
| 15446 |
wrapBehavioursEnabled: { initialValue: true }, |
| 15447 |
enableAutoIndent: { initialValue: true }, |
| 15448 |
autoScrollEditorIntoView: { |
| 15449 |
set: function (val) { this.setAutoScrollEditorIntoView(val); } |
| 15450 |
}, |
| 15451 |
keyboardHandler: { |
| 15452 |
set: function (val) { this.setKeyboardHandler(val); }, |
| 15453 |
get: function () { return this.$keybindingId; }, |
| 15454 |
handlesSet: true |
| 15455 |
}, |
| 15456 |
value: { |
| 15457 |
set: function (val) { this.session.setValue(val); }, |
| 15458 |
get: function () { return this.getValue(); }, |
| 15459 |
handlesSet: true, |
| 15460 |
hidden: true |
| 15461 |
}, |
| 15462 |
session: { |
| 15463 |
set: function (val) { this.setSession(val); }, |
| 15464 |
get: function () { return this.session; }, |
| 15465 |
handlesSet: true, |
| 15466 |
hidden: true |
| 15467 |
}, |
| 15468 |
showLineNumbers: { |
| 15469 |
set: function (show) { |
| 15470 |
this.renderer.$gutterLayer.setShowLineNumbers(show); |
| 15471 |
this.renderer.$loop.schedule(this.renderer.CHANGE_GUTTER); |
| 15472 |
if (show && this.$relativeLineNumbers) |
| 15473 |
relativeNumberRenderer.attach(this); |
| 15474 |
else |
| 15475 |
relativeNumberRenderer.detach(this); |
| 15476 |
}, |
| 15477 |
initialValue: true |
| 15478 |
}, |
| 15479 |
relativeLineNumbers: { |
| 15480 |
set: function (value) { |
| 15481 |
if (this.$showLineNumbers && value) |
| 15482 |
relativeNumberRenderer.attach(this); |
| 15483 |
else |
| 15484 |
relativeNumberRenderer.detach(this); |
| 15485 |
} |
| 15486 |
}, |
| 15487 |
placeholder: { |
| 15488 |
set: function (message) { |
| 15489 |
if (!this.$updatePlaceholder) { |
| 15490 |
this.$updatePlaceholder = function () { |
| 15491 |
var hasValue = this.session && (this.renderer.$composition || |
| 15492 |
this.session.getLength() > 1 || this.session.getLine(0).length > 0); |
| 15493 |
if (hasValue && this.renderer.placeholderNode) { |
| 15494 |
this.renderer.off("afterRender", this.$updatePlaceholder); |
| 15495 |
dom.removeCssClass(this.container, "ace_hasPlaceholder"); |
| 15496 |
this.renderer.placeholderNode.remove(); |
| 15497 |
this.renderer.placeholderNode = null; |
| 15498 |
} |
| 15499 |
else if (!hasValue && !this.renderer.placeholderNode) { |
| 15500 |
this.renderer.on("afterRender", this.$updatePlaceholder); |
| 15501 |
dom.addCssClass(this.container, "ace_hasPlaceholder"); |
| 15502 |
var el = dom.createElement("div"); |
| 15503 |
el.className = "ace_placeholder"; |
| 15504 |
el.textContent = this.$placeholder || ""; |
| 15505 |
this.renderer.placeholderNode = el; |
| 15506 |
this.renderer.content.appendChild(this.renderer.placeholderNode); |
| 15507 |
} |
| 15508 |
else if (!hasValue && this.renderer.placeholderNode) { |
| 15509 |
this.renderer.placeholderNode.textContent = this.$placeholder || ""; |
| 15510 |
} |
| 15511 |
}.bind(this); |
| 15512 |
this.on("input", this.$updatePlaceholder); |
| 15513 |
} |
| 15514 |
this.$updatePlaceholder(); |
| 15515 |
} |
| 15516 |
}, |
| 15517 |
enableKeyboardAccessibility: { |
| 15518 |
set: function (value) { |
| 15519 |
var blurCommand = { |
| 15520 |
name: "blurTextInput", |
| 15521 |
description: "Set focus to the editor content div to allow tabbing through the page", |
| 15522 |
bindKey: "Esc", |
| 15523 |
exec: function (editor) { |
| 15524 |
editor.blur(); |
| 15525 |
editor.renderer.scroller.focus(); |
| 15526 |
}, |
| 15527 |
readOnly: true |
| 15528 |
}; |
| 15529 |
var focusOnEnterKeyup = function (e) { |
| 15530 |
if (e.target == this.renderer.scroller && e.keyCode === keys['enter']) { |
| 15531 |
e.preventDefault(); |
| 15532 |
var row = this.getCursorPosition().row; |
| 15533 |
if (!this.isRowVisible(row)) |
| 15534 |
this.scrollToLine(row, true, true); |
| 15535 |
this.focus(); |
| 15536 |
} |
| 15537 |
}; |
| 15538 |
var gutterKeyboardHandler; |
| 15539 |
if (value) { |
| 15540 |
this.renderer.enableKeyboardAccessibility = true; |
| 15541 |
this.renderer.keyboardFocusClassName = "ace_keyboard-focus"; |
| 15542 |
this.textInput.getElement().setAttribute("tabindex", -1); |
| 15543 |
this.textInput.setNumberOfExtraLines(useragent.isWin ? 3 : 0); |
| 15544 |
this.renderer.scroller.setAttribute("tabindex", 0); |
| 15545 |
this.renderer.scroller.setAttribute("role", "group"); |
| 15546 |
this.renderer.scroller.setAttribute("aria-roledescription", nls("editor")); |
| 15547 |
this.renderer.scroller.classList.add(this.renderer.keyboardFocusClassName); |
| 15548 |
this.renderer.scroller.setAttribute("aria-label", nls("Editor content, press Enter to start editing, press Escape to exit")); |
| 15549 |
this.renderer.scroller.addEventListener("keyup", focusOnEnterKeyup.bind(this)); |
| 15550 |
this.commands.addCommand(blurCommand); |
| 15551 |
this.renderer.$gutter.setAttribute("tabindex", 0); |
| 15552 |
this.renderer.$gutter.setAttribute("aria-hidden", false); |
| 15553 |
this.renderer.$gutter.setAttribute("role", "group"); |
| 15554 |
this.renderer.$gutter.setAttribute("aria-roledescription", nls("editor")); |
| 15555 |
this.renderer.$gutter.setAttribute("aria-label", nls("Editor gutter, press Enter to interact with controls using arrow keys, press Escape to exit")); |
| 15556 |
this.renderer.$gutter.classList.add(this.renderer.keyboardFocusClassName); |
| 15557 |
this.renderer.content.setAttribute("aria-hidden", true); |
| 15558 |
if (!gutterKeyboardHandler) |
| 15559 |
gutterKeyboardHandler = new GutterKeyboardHandler(this); |
| 15560 |
gutterKeyboardHandler.addListener(); |
| 15561 |
} |
| 15562 |
else { |
| 15563 |
this.renderer.enableKeyboardAccessibility = false; |
| 15564 |
this.textInput.getElement().setAttribute("tabindex", 0); |
| 15565 |
this.textInput.setNumberOfExtraLines(0); |
| 15566 |
this.renderer.scroller.setAttribute("tabindex", -1); |
| 15567 |
this.renderer.scroller.removeAttribute("role"); |
| 15568 |
this.renderer.scroller.removeAttribute("aria-roledescription"); |
| 15569 |
this.renderer.scroller.classList.remove(this.renderer.keyboardFocusClassName); |
| 15570 |
this.renderer.scroller.removeAttribute("aria-label"); |
| 15571 |
this.renderer.scroller.removeEventListener("keyup", focusOnEnterKeyup.bind(this)); |
| 15572 |
this.commands.removeCommand(blurCommand); |
| 15573 |
this.renderer.content.removeAttribute("aria-hidden"); |
| 15574 |
this.renderer.$gutter.setAttribute("tabindex", -1); |
| 15575 |
this.renderer.$gutter.setAttribute("aria-hidden", true); |
| 15576 |
this.renderer.$gutter.removeAttribute("role"); |
| 15577 |
this.renderer.$gutter.removeAttribute("aria-roledescription"); |
| 15578 |
this.renderer.$gutter.removeAttribute("aria-label"); |
| 15579 |
this.renderer.$gutter.classList.remove(this.renderer.keyboardFocusClassName); |
| 15580 |
if (gutterKeyboardHandler) |
| 15581 |
gutterKeyboardHandler.removeListener(); |
| 15582 |
} |
| 15583 |
}, |
| 15584 |
initialValue: false |
| 15585 |
}, |
| 15586 |
customScrollbar: "renderer", |
| 15587 |
hScrollBarAlwaysVisible: "renderer", |
| 15588 |
vScrollBarAlwaysVisible: "renderer", |
| 15589 |
highlightGutterLine: "renderer", |
| 15590 |
animatedScroll: "renderer", |
| 15591 |
showInvisibles: "renderer", |
| 15592 |
showPrintMargin: "renderer", |
| 15593 |
printMarginColumn: "renderer", |
| 15594 |
printMargin: "renderer", |
| 15595 |
fadeFoldWidgets: "renderer", |
| 15596 |
showFoldWidgets: "renderer", |
| 15597 |
displayIndentGuides: "renderer", |
| 15598 |
highlightIndentGuides: "renderer", |
| 15599 |
showGutter: "renderer", |
| 15600 |
fontSize: "renderer", |
| 15601 |
fontFamily: "renderer", |
| 15602 |
maxLines: "renderer", |
| 15603 |
minLines: "renderer", |
| 15604 |
scrollPastEnd: "renderer", |
| 15605 |
fixedWidthGutter: "renderer", |
| 15606 |
theme: "renderer", |
| 15607 |
hasCssTransforms: "renderer", |
| 15608 |
maxPixelHeight: "renderer", |
| 15609 |
useTextareaForIME: "renderer", |
| 15610 |
useResizeObserver: "renderer", |
| 15611 |
useSvgGutterIcons: "renderer", |
| 15612 |
showFoldedAnnotations: "renderer", |
| 15613 |
scrollSpeed: "$mouseHandler", |
| 15614 |
dragDelay: "$mouseHandler", |
| 15615 |
dragEnabled: "$mouseHandler", |
| 15616 |
focusTimeout: "$mouseHandler", |
| 15617 |
tooltipFollowsMouse: "$mouseHandler", |
| 15618 |
firstLineNumber: "session", |
| 15619 |
overwrite: "session", |
| 15620 |
newLineMode: "session", |
| 15621 |
useWorker: "session", |
| 15622 |
useSoftTabs: "session", |
| 15623 |
navigateWithinSoftTabs: "session", |
| 15624 |
tabSize: "session", |
| 15625 |
wrap: "session", |
| 15626 |
indentedSoftWrap: "session", |
| 15627 |
foldStyle: "session", |
| 15628 |
mode: "session" |
| 15629 |
}); |
| 15630 |
var relativeNumberRenderer = { |
| 15631 |
getText: function ( session, row) { |
| 15632 |
return (Math.abs(session.selection.lead.row - row) || (row + 1 + (row < 9 ? "\xb7" : ""))) + ""; |
| 15633 |
}, |
| 15634 |
getWidth: function (session, lastLineNumber, config) { |
| 15635 |
return Math.max(lastLineNumber.toString().length, (config.lastRow + 1).toString().length, 2) * config.characterWidth; |
| 15636 |
}, |
| 15637 |
update: function (e, editor) { |
| 15638 |
editor.renderer.$loop.schedule(editor.renderer.CHANGE_GUTTER); |
| 15639 |
}, |
| 15640 |
attach: function ( editor) { |
| 15641 |
editor.renderer.$gutterLayer.$renderer = this; |
| 15642 |
editor.on("changeSelection", this.update); |
| 15643 |
this.update(null, editor); |
| 15644 |
}, |
| 15645 |
detach: function ( editor) { |
| 15646 |
if (editor.renderer.$gutterLayer.$renderer == this) |
| 15647 |
editor.renderer.$gutterLayer.$renderer = null; |
| 15648 |
editor.off("changeSelection", this.update); |
| 15649 |
this.update(null, editor); |
| 15650 |
} |
| 15651 |
}; |
| 15652 |
exports.Editor = Editor; |
| 15653 |
|
| 15654 |
}); |
| 15655 |
|
| 15656 |
ace.define("ace/layer/lines",["require","exports","module","ace/lib/dom"], function(require, exports, module){"use strict"; |
| 15657 |
var dom = require("../lib/dom"); |
| 15658 |
var Lines = (function () { |
| 15659 |
function Lines(element, canvasHeight) { |
| 15660 |
this.element = element; |
| 15661 |
this.canvasHeight = canvasHeight || 500000; |
| 15662 |
this.element.style.height = (this.canvasHeight * 2) + "px"; |
| 15663 |
this.cells = []; |
| 15664 |
this.cellCache = []; |
| 15665 |
this.$offsetCoefficient = 0; |
| 15666 |
} |
| 15667 |
Lines.prototype.moveContainer = function (config) { |
| 15668 |
dom.translate(this.element, 0, -((config.firstRowScreen * config.lineHeight) % this.canvasHeight) - config.offset * this.$offsetCoefficient); |
| 15669 |
}; |
| 15670 |
Lines.prototype.pageChanged = function (oldConfig, newConfig) { |
| 15671 |
return (Math.floor((oldConfig.firstRowScreen * oldConfig.lineHeight) / this.canvasHeight) !== |
| 15672 |
Math.floor((newConfig.firstRowScreen * newConfig.lineHeight) / this.canvasHeight)); |
| 15673 |
}; |
| 15674 |
Lines.prototype.computeLineTop = function (row, config, session) { |
| 15675 |
var screenTop = config.firstRowScreen * config.lineHeight; |
| 15676 |
var screenPage = Math.floor(screenTop / this.canvasHeight); |
| 15677 |
var lineTop = session.documentToScreenRow(row, 0) * config.lineHeight; |
| 15678 |
return lineTop - (screenPage * this.canvasHeight); |
| 15679 |
}; |
| 15680 |
Lines.prototype.computeLineHeight = function (row, config, session) { |
| 15681 |
return config.lineHeight * session.getRowLineCount(row); |
| 15682 |
}; |
| 15683 |
Lines.prototype.getLength = function () { |
| 15684 |
return this.cells.length; |
| 15685 |
}; |
| 15686 |
Lines.prototype.get = function (index) { |
| 15687 |
return this.cells[index]; |
| 15688 |
}; |
| 15689 |
Lines.prototype.shift = function () { |
| 15690 |
this.$cacheCell(this.cells.shift()); |
| 15691 |
}; |
| 15692 |
Lines.prototype.pop = function () { |
| 15693 |
this.$cacheCell(this.cells.pop()); |
| 15694 |
}; |
| 15695 |
Lines.prototype.push = function (cell) { |
| 15696 |
if (Array.isArray(cell)) { |
| 15697 |
this.cells.push.apply(this.cells, cell); |
| 15698 |
var fragment = dom.createFragment(this.element); |
| 15699 |
for (var i = 0; i < cell.length; i++) { |
| 15700 |
fragment.appendChild(cell[i].element); |
| 15701 |
} |
| 15702 |
this.element.appendChild(fragment); |
| 15703 |
} |
| 15704 |
else { |
| 15705 |
this.cells.push(cell); |
| 15706 |
this.element.appendChild(cell.element); |
| 15707 |
} |
| 15708 |
}; |
| 15709 |
Lines.prototype.unshift = function (cell) { |
| 15710 |
if (Array.isArray(cell)) { |
| 15711 |
this.cells.unshift.apply(this.cells, cell); |
| 15712 |
var fragment = dom.createFragment(this.element); |
| 15713 |
for (var i = 0; i < cell.length; i++) { |
| 15714 |
fragment.appendChild(cell[i].element); |
| 15715 |
} |
| 15716 |
if (this.element.firstChild) |
| 15717 |
this.element.insertBefore(fragment, this.element.firstChild); |
| 15718 |
else |
| 15719 |
this.element.appendChild(fragment); |
| 15720 |
} |
| 15721 |
else { |
| 15722 |
this.cells.unshift(cell); |
| 15723 |
this.element.insertAdjacentElement("afterbegin", cell.element); |
| 15724 |
} |
| 15725 |
}; |
| 15726 |
Lines.prototype.last = function () { |
| 15727 |
if (this.cells.length) |
| 15728 |
return this.cells[this.cells.length - 1]; |
| 15729 |
else |
| 15730 |
return null; |
| 15731 |
}; |
| 15732 |
Lines.prototype.$cacheCell = function (cell) { |
| 15733 |
if (!cell) |
| 15734 |
return; |
| 15735 |
cell.element.remove(); |
| 15736 |
this.cellCache.push(cell); |
| 15737 |
}; |
| 15738 |
Lines.prototype.createCell = function (row, config, session, initElement) { |
| 15739 |
var cell = this.cellCache.pop(); |
| 15740 |
if (!cell) { |
| 15741 |
var element = dom.createElement("div"); |
| 15742 |
if (initElement) |
| 15743 |
initElement(element); |
| 15744 |
this.element.appendChild(element); |
| 15745 |
cell = { |
| 15746 |
element: element, |
| 15747 |
text: "", |
| 15748 |
row: row |
| 15749 |
}; |
| 15750 |
} |
| 15751 |
cell.row = row; |
| 15752 |
return cell; |
| 15753 |
}; |
| 15754 |
return Lines; |
| 15755 |
}()); |
| 15756 |
exports.Lines = Lines; |
| 15757 |
|
| 15758 |
}); |
| 15759 |
|
| 15760 |
ace.define("ace/layer/gutter",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/layer/lines","ace/config"], function(require, exports, module){"use strict"; |
| 15761 |
var dom = require("../lib/dom"); |
| 15762 |
var oop = require("../lib/oop"); |
| 15763 |
var lang = require("../lib/lang"); |
| 15764 |
var EventEmitter = require("../lib/event_emitter").EventEmitter; |
| 15765 |
var Lines = require("./lines").Lines; |
| 15766 |
var nls = require("../config").nls; |
| 15767 |
var Gutter = (function () { |
| 15768 |
function Gutter(parentEl) { |
| 15769 |
this.element = dom.createElement("div"); |
| 15770 |
this.element.className = "ace_layer ace_gutter-layer"; |
| 15771 |
parentEl.appendChild(this.element); |
| 15772 |
this.setShowFoldWidgets(this.$showFoldWidgets); |
| 15773 |
this.gutterWidth = 0; |
| 15774 |
this.$annotations = []; |
| 15775 |
this.$updateAnnotations = this.$updateAnnotations.bind(this); |
| 15776 |
this.$lines = new Lines(this.element); |
| 15777 |
this.$lines.$offsetCoefficient = 1; |
| 15778 |
} |
| 15779 |
Gutter.prototype.setSession = function (session) { |
| 15780 |
if (this.session) |
| 15781 |
this.session.off("change", this.$updateAnnotations); |
| 15782 |
this.session = session; |
| 15783 |
if (session) |
| 15784 |
session.on("change", this.$updateAnnotations); |
| 15785 |
}; |
| 15786 |
Gutter.prototype.addGutterDecoration = function (row, className) { |
| 15787 |
if (window.console) |
| 15788 |
console.warn && console.warn("deprecated use session.addGutterDecoration"); |
| 15789 |
this.session.addGutterDecoration(row, className); |
| 15790 |
}; |
| 15791 |
Gutter.prototype.removeGutterDecoration = function (row, className) { |
| 15792 |
if (window.console) |
| 15793 |
console.warn && console.warn("deprecated use session.removeGutterDecoration"); |
| 15794 |
this.session.removeGutterDecoration(row, className); |
| 15795 |
}; |
| 15796 |
Gutter.prototype.setAnnotations = function (annotations) { |
| 15797 |
this.$annotations = []; |
| 15798 |
for (var i = 0; i < annotations.length; i++) { |
| 15799 |
var annotation = annotations[i]; |
| 15800 |
var row = annotation.row; |
| 15801 |
var rowInfo = this.$annotations[row]; |
| 15802 |
if (!rowInfo) |
| 15803 |
rowInfo = this.$annotations[row] = { text: [], type: [] }; |
| 15804 |
var annoText = annotation.text; |
| 15805 |
var annoType = annotation.type; |
| 15806 |
annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || ""; |
| 15807 |
if (rowInfo.text.indexOf(annoText) === -1) { |
| 15808 |
rowInfo.text.push(annoText); |
| 15809 |
rowInfo.type.push(annoType); |
| 15810 |
} |
| 15811 |
var className = annotation.className; |
| 15812 |
if (className) |
| 15813 |
rowInfo.className = className; |
| 15814 |
else if (annoType == "error") |
| 15815 |
rowInfo.className = " ace_error"; |
| 15816 |
else if (annoType == "warning" && rowInfo.className != " ace_error") |
| 15817 |
rowInfo.className = " ace_warning"; |
| 15818 |
else if (annoType == "info" && (!rowInfo.className)) |
| 15819 |
rowInfo.className = " ace_info"; |
| 15820 |
} |
| 15821 |
}; |
| 15822 |
Gutter.prototype.$updateAnnotations = function (delta) { |
| 15823 |
if (!this.$annotations.length) |
| 15824 |
return; |
| 15825 |
var firstRow = delta.start.row; |
| 15826 |
var len = delta.end.row - firstRow; |
| 15827 |
if (len === 0) { |
| 15828 |
} |
| 15829 |
else if (delta.action == 'remove') { |
| 15830 |
this.$annotations.splice(firstRow, len + 1, null); |
| 15831 |
} |
| 15832 |
else { |
| 15833 |
var args = new Array(len + 1); |
| 15834 |
args.unshift(firstRow, 1); |
| 15835 |
this.$annotations.splice.apply(this.$annotations, args); |
| 15836 |
} |
| 15837 |
}; |
| 15838 |
Gutter.prototype.update = function (config) { |
| 15839 |
this.config = config; |
| 15840 |
var session = this.session; |
| 15841 |
var firstRow = config.firstRow; |
| 15842 |
var lastRow = Math.min(config.lastRow + config.gutterOffset, |
| 15843 |
session.getLength() - 1); |
| 15844 |
this.oldLastRow = lastRow; |
| 15845 |
this.config = config; |
| 15846 |
this.$lines.moveContainer(config); |
| 15847 |
this.$updateCursorRow(); |
| 15848 |
var fold = session.getNextFoldLine(firstRow); |
| 15849 |
var foldStart = fold ? fold.start.row : Infinity; |
| 15850 |
var cell = null; |
| 15851 |
var index = -1; |
| 15852 |
var row = firstRow; |
| 15853 |
while (true) { |
| 15854 |
if (row > foldStart) { |
| 15855 |
row = fold.end.row + 1; |
| 15856 |
fold = session.getNextFoldLine(row, fold); |
| 15857 |
foldStart = fold ? fold.start.row : Infinity; |
| 15858 |
} |
| 15859 |
if (row > lastRow) { |
| 15860 |
while (this.$lines.getLength() > index + 1) |
| 15861 |
this.$lines.pop(); |
| 15862 |
break; |
| 15863 |
} |
| 15864 |
cell = this.$lines.get(++index); |
| 15865 |
if (cell) { |
| 15866 |
cell.row = row; |
| 15867 |
} |
| 15868 |
else { |
| 15869 |
cell = this.$lines.createCell(row, config, this.session, onCreateCell); |
| 15870 |
this.$lines.push(cell); |
| 15871 |
} |
| 15872 |
this.$renderCell(cell, config, fold, row); |
| 15873 |
row++; |
| 15874 |
} |
| 15875 |
this._signal("afterRender"); |
| 15876 |
this.$updateGutterWidth(config); |
| 15877 |
}; |
| 15878 |
Gutter.prototype.$updateGutterWidth = function (config) { |
| 15879 |
var session = this.session; |
| 15880 |
var gutterRenderer = session.gutterRenderer || this.$renderer; |
| 15881 |
var firstLineNumber = session.$firstLineNumber; |
| 15882 |
var lastLineText = this.$lines.last() ? this.$lines.last().text : ""; |
| 15883 |
if (this.$fixedWidth || session.$useWrapMode) |
| 15884 |
lastLineText = session.getLength() + firstLineNumber - 1; |
| 15885 |
var gutterWidth = gutterRenderer |
| 15886 |
? gutterRenderer.getWidth(session, lastLineText, config) |
| 15887 |
: lastLineText.toString().length * config.characterWidth; |
| 15888 |
var padding = this.$padding || this.$computePadding(); |
| 15889 |
gutterWidth += padding.left + padding.right; |
| 15890 |
if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) { |
| 15891 |
this.gutterWidth = gutterWidth; (this.element.parentNode).style.width = |
| 15892 |
this.element.style.width = Math.ceil(this.gutterWidth) + "px"; |
| 15893 |
this._signal("changeGutterWidth", gutterWidth); |
| 15894 |
} |
| 15895 |
}; |
| 15896 |
Gutter.prototype.$updateCursorRow = function () { |
| 15897 |
if (!this.$highlightGutterLine) |
| 15898 |
return; |
| 15899 |
var position = this.session.selection.getCursor(); |
| 15900 |
if (this.$cursorRow === position.row) |
| 15901 |
return; |
| 15902 |
this.$cursorRow = position.row; |
| 15903 |
}; |
| 15904 |
Gutter.prototype.updateLineHighlight = function () { |
| 15905 |
if (!this.$highlightGutterLine) |
| 15906 |
return; |
| 15907 |
var row = this.session.selection.cursor.row; |
| 15908 |
this.$cursorRow = row; |
| 15909 |
if (this.$cursorCell && this.$cursorCell.row == row) |
| 15910 |
return; |
| 15911 |
if (this.$cursorCell) |
| 15912 |
this.$cursorCell.element.className = this.$cursorCell.element.className.replace("ace_gutter-active-line ", ""); |
| 15913 |
var cells = this.$lines.cells; |
| 15914 |
this.$cursorCell = null; |
| 15915 |
for (var i = 0; i < cells.length; i++) { |
| 15916 |
var cell = cells[i]; |
| 15917 |
if (cell.row >= this.$cursorRow) { |
| 15918 |
if (cell.row > this.$cursorRow) { |
| 15919 |
var fold = this.session.getFoldLine(this.$cursorRow); |
| 15920 |
if (i > 0 && fold && fold.start.row == cells[i - 1].row) |
| 15921 |
cell = cells[i - 1]; |
| 15922 |
else |
| 15923 |
break; |
| 15924 |
} |
| 15925 |
cell.element.className = "ace_gutter-active-line " + cell.element.className; |
| 15926 |
this.$cursorCell = cell; |
| 15927 |
break; |
| 15928 |
} |
| 15929 |
} |
| 15930 |
}; |
| 15931 |
Gutter.prototype.scrollLines = function (config) { |
| 15932 |
var oldConfig = this.config; |
| 15933 |
this.config = config; |
| 15934 |
this.$updateCursorRow(); |
| 15935 |
if (this.$lines.pageChanged(oldConfig, config)) |
| 15936 |
return this.update(config); |
| 15937 |
this.$lines.moveContainer(config); |
| 15938 |
var lastRow = Math.min(config.lastRow + config.gutterOffset, |
| 15939 |
this.session.getLength() - 1); |
| 15940 |
var oldLastRow = this.oldLastRow; |
| 15941 |
this.oldLastRow = lastRow; |
| 15942 |
if (!oldConfig || oldLastRow < config.firstRow) |
| 15943 |
return this.update(config); |
| 15944 |
if (lastRow < oldConfig.firstRow) |
| 15945 |
return this.update(config); |
| 15946 |
if (oldConfig.firstRow < config.firstRow) |
| 15947 |
for (var row = this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row > 0; row--) |
| 15948 |
this.$lines.shift(); |
| 15949 |
if (oldLastRow > lastRow) |
| 15950 |
for (var row = this.session.getFoldedRowCount(lastRow + 1, oldLastRow); row > 0; row--) |
| 15951 |
this.$lines.pop(); |
| 15952 |
if (config.firstRow < oldConfig.firstRow) { |
| 15953 |
this.$lines.unshift(this.$renderLines(config, config.firstRow, oldConfig.firstRow - 1)); |
| 15954 |
} |
| 15955 |
if (lastRow > oldLastRow) { |
| 15956 |
this.$lines.push(this.$renderLines(config, oldLastRow + 1, lastRow)); |
| 15957 |
} |
| 15958 |
this.updateLineHighlight(); |
| 15959 |
this._signal("afterRender"); |
| 15960 |
this.$updateGutterWidth(config); |
| 15961 |
}; |
| 15962 |
Gutter.prototype.$renderLines = function (config, firstRow, lastRow) { |
| 15963 |
var fragment = []; |
| 15964 |
var row = firstRow; |
| 15965 |
var foldLine = this.session.getNextFoldLine(row); |
| 15966 |
var foldStart = foldLine ? foldLine.start.row : Infinity; |
| 15967 |
while (true) { |
| 15968 |
if (row > foldStart) { |
| 15969 |
row = foldLine.end.row + 1; |
| 15970 |
foldLine = this.session.getNextFoldLine(row, foldLine); |
| 15971 |
foldStart = foldLine ? foldLine.start.row : Infinity; |
| 15972 |
} |
| 15973 |
if (row > lastRow) |
| 15974 |
break; |
| 15975 |
var cell = this.$lines.createCell(row, config, this.session, onCreateCell); |
| 15976 |
this.$renderCell(cell, config, foldLine, row); |
| 15977 |
fragment.push(cell); |
| 15978 |
row++; |
| 15979 |
} |
| 15980 |
return fragment; |
| 15981 |
}; |
| 15982 |
Gutter.prototype.$renderCell = function (cell, config, fold, row) { |
| 15983 |
var element = cell.element; |
| 15984 |
var session = this.session; |
| 15985 |
var textNode = element.childNodes[0]; |
| 15986 |
var foldWidget = element.childNodes[1]; |
| 15987 |
var annotationNode = element.childNodes[2]; |
| 15988 |
var annotationIconNode = annotationNode.firstChild; |
| 15989 |
var firstLineNumber = session.$firstLineNumber; |
| 15990 |
var breakpoints = session.$breakpoints; |
| 15991 |
var decorations = session.$decorations; |
| 15992 |
var gutterRenderer = session.gutterRenderer || this.$renderer; |
| 15993 |
var foldWidgets = this.$showFoldWidgets && session.foldWidgets; |
| 15994 |
var foldStart = fold ? fold.start.row : Number.MAX_VALUE; |
| 15995 |
var lineHeight = config.lineHeight + "px"; |
| 15996 |
var className = this.$useSvgGutterIcons ? "ace_gutter-cell_svg-icons " : "ace_gutter-cell "; |
| 15997 |
var iconClassName = this.$useSvgGutterIcons ? "ace_icon_svg" : "ace_icon"; |
| 15998 |
var rowText = (gutterRenderer |
| 15999 |
? gutterRenderer.getText(session, row) |
| 16000 |
: row + firstLineNumber).toString(); |
| 16001 |
if (this.$highlightGutterLine) { |
| 16002 |
if (row == this.$cursorRow || (fold && row < this.$cursorRow && row >= foldStart && this.$cursorRow <= fold.end.row)) { |
| 16003 |
className += "ace_gutter-active-line "; |
| 16004 |
if (this.$cursorCell != cell) { |
| 16005 |
if (this.$cursorCell) |
| 16006 |
this.$cursorCell.element.className = this.$cursorCell.element.className.replace("ace_gutter-active-line ", ""); |
| 16007 |
this.$cursorCell = cell; |
| 16008 |
} |
| 16009 |
} |
| 16010 |
} |
| 16011 |
if (breakpoints[row]) |
| 16012 |
className += breakpoints[row]; |
| 16013 |
if (decorations[row]) |
| 16014 |
className += decorations[row]; |
| 16015 |
if (this.$annotations[row] && row !== foldStart) |
| 16016 |
className += this.$annotations[row].className; |
| 16017 |
if (foldWidgets) { |
| 16018 |
var c = foldWidgets[row]; |
| 16019 |
if (c == null) |
| 16020 |
c = foldWidgets[row] = session.getFoldWidget(row); |
| 16021 |
} |
| 16022 |
if (c) { |
| 16023 |
var foldClass = "ace_fold-widget ace_" + c; |
| 16024 |
var isClosedFold = c == "start" && row == foldStart && row < fold.end.row; |
| 16025 |
if (isClosedFold) { |
| 16026 |
foldClass += " ace_closed"; |
| 16027 |
var foldAnnotationClass = ''; |
| 16028 |
var annotationInFold = false; |
| 16029 |
for (var i = row + 1; i <= fold.end.row; i++) { |
| 16030 |
if (!this.$annotations[i]) |
| 16031 |
continue; |
| 16032 |
if (this.$annotations[i].className === " ace_error") { |
| 16033 |
annotationInFold = true; |
| 16034 |
foldAnnotationClass = " ace_error_fold"; |
| 16035 |
break; |
| 16036 |
} |
| 16037 |
if (this.$annotations[i].className === " ace_warning") { |
| 16038 |
annotationInFold = true; |
| 16039 |
foldAnnotationClass = " ace_warning_fold"; |
| 16040 |
continue; |
| 16041 |
} |
| 16042 |
} |
| 16043 |
className += foldAnnotationClass; |
| 16044 |
} |
| 16045 |
else |
| 16046 |
foldClass += " ace_open"; |
| 16047 |
if (foldWidget.className != foldClass) |
| 16048 |
foldWidget.className = foldClass; |
| 16049 |
dom.setStyle(foldWidget.style, "height", lineHeight); |
| 16050 |
dom.setStyle(foldWidget.style, "display", "inline-block"); |
| 16051 |
foldWidget.setAttribute("role", "button"); |
| 16052 |
foldWidget.setAttribute("tabindex", "-1"); |
| 16053 |
var foldRange = session.getFoldWidgetRange(row); |
| 16054 |
if (foldRange) |
| 16055 |
foldWidget.setAttribute("aria-label", nls("Toggle code folding, rows $0 through $1", [foldRange.start.row + 1, foldRange.end.row + 1])); |
| 16056 |
else { |
| 16057 |
if (fold) |
| 16058 |
foldWidget.setAttribute("aria-label", nls("Toggle code folding, rows $0 through $1", [fold.start.row + 1, fold.end.row + 1])); |
| 16059 |
else |
| 16060 |
foldWidget.setAttribute("aria-label", nls("Toggle code folding, row $0", [row + 1])); |
| 16061 |
} |
| 16062 |
if (isClosedFold) { |
| 16063 |
foldWidget.setAttribute("aria-expanded", "false"); |
| 16064 |
foldWidget.setAttribute("title", nls("Unfold code")); |
| 16065 |
} |
| 16066 |
else { |
| 16067 |
foldWidget.setAttribute("aria-expanded", "true"); |
| 16068 |
foldWidget.setAttribute("title", nls("Fold code")); |
| 16069 |
} |
| 16070 |
} |
| 16071 |
else { |
| 16072 |
if (foldWidget) { |
| 16073 |
dom.setStyle(foldWidget.style, "display", "none"); |
| 16074 |
foldWidget.setAttribute("tabindex", "0"); |
| 16075 |
foldWidget.removeAttribute("role"); |
| 16076 |
foldWidget.removeAttribute("aria-label"); |
| 16077 |
} |
| 16078 |
} |
| 16079 |
if (annotationInFold && this.$showFoldedAnnotations) { |
| 16080 |
annotationNode.className = "ace_gutter_annotation"; |
| 16081 |
annotationIconNode.className = iconClassName; |
| 16082 |
annotationIconNode.className += foldAnnotationClass; |
| 16083 |
dom.setStyle(annotationIconNode.style, "height", lineHeight); |
| 16084 |
dom.setStyle(annotationNode.style, "display", "block"); |
| 16085 |
dom.setStyle(annotationNode.style, "height", lineHeight); |
| 16086 |
annotationNode.setAttribute("aria-label", nls("Read annotations row $0", [rowText])); |
| 16087 |
annotationNode.setAttribute("tabindex", "-1"); |
| 16088 |
annotationNode.setAttribute("role", "button"); |
| 16089 |
} |
| 16090 |
else if (this.$annotations[row]) { |
| 16091 |
annotationNode.className = "ace_gutter_annotation"; |
| 16092 |
annotationIconNode.className = iconClassName; |
| 16093 |
if (this.$useSvgGutterIcons) |
| 16094 |
annotationIconNode.className += this.$annotations[row].className; |
| 16095 |
else |
| 16096 |
element.classList.add(this.$annotations[row].className.replace(" ", "")); |
| 16097 |
dom.setStyle(annotationIconNode.style, "height", lineHeight); |
| 16098 |
dom.setStyle(annotationNode.style, "display", "block"); |
| 16099 |
dom.setStyle(annotationNode.style, "height", lineHeight); |
| 16100 |
annotationNode.setAttribute("aria-label", nls("Read annotations row $0", [rowText])); |
| 16101 |
annotationNode.setAttribute("tabindex", "-1"); |
| 16102 |
annotationNode.setAttribute("role", "button"); |
| 16103 |
} |
| 16104 |
else { |
| 16105 |
dom.setStyle(annotationNode.style, "display", "none"); |
| 16106 |
annotationNode.removeAttribute("aria-label"); |
| 16107 |
annotationNode.removeAttribute("role"); |
| 16108 |
annotationNode.setAttribute("tabindex", "0"); |
| 16109 |
} |
| 16110 |
if (rowText !== textNode.data) { |
| 16111 |
textNode.data = rowText; |
| 16112 |
} |
| 16113 |
if (element.className != className) |
| 16114 |
element.className = className; |
| 16115 |
dom.setStyle(cell.element.style, "height", this.$lines.computeLineHeight(row, config, session) + "px"); |
| 16116 |
dom.setStyle(cell.element.style, "top", this.$lines.computeLineTop(row, config, session) + "px"); |
| 16117 |
cell.text = rowText; |
| 16118 |
if (annotationNode.style.display === "none" && foldWidget.style.display === "none") |
| 16119 |
cell.element.setAttribute("aria-hidden", true); |
| 16120 |
else |
| 16121 |
cell.element.setAttribute("aria-hidden", false); |
| 16122 |
return cell; |
| 16123 |
}; |
| 16124 |
Gutter.prototype.setHighlightGutterLine = function (highlightGutterLine) { |
| 16125 |
this.$highlightGutterLine = highlightGutterLine; |
| 16126 |
}; |
| 16127 |
Gutter.prototype.setShowLineNumbers = function (show) { |
| 16128 |
this.$renderer = !show && { |
| 16129 |
getWidth: function () { return 0; }, |
| 16130 |
getText: function () { return ""; } |
| 16131 |
}; |
| 16132 |
}; |
| 16133 |
Gutter.prototype.getShowLineNumbers = function () { |
| 16134 |
return this.$showLineNumbers; |
| 16135 |
}; |
| 16136 |
Gutter.prototype.setShowFoldWidgets = function (show) { |
| 16137 |
if (show) |
| 16138 |
dom.addCssClass(this.element, "ace_folding-enabled"); |
| 16139 |
else |
| 16140 |
dom.removeCssClass(this.element, "ace_folding-enabled"); |
| 16141 |
this.$showFoldWidgets = show; |
| 16142 |
this.$padding = null; |
| 16143 |
}; |
| 16144 |
Gutter.prototype.getShowFoldWidgets = function () { |
| 16145 |
return this.$showFoldWidgets; |
| 16146 |
}; |
| 16147 |
Gutter.prototype.$computePadding = function () { |
| 16148 |
if (!this.element.firstChild) |
| 16149 |
return { left: 0, right: 0 }; |
| 16150 |
var style = dom.computedStyle( (this.element.firstChild)); |
| 16151 |
this.$padding = {}; |
| 16152 |
this.$padding.left = (parseInt(style.borderLeftWidth) || 0) |
| 16153 |
+ (parseInt(style.paddingLeft) || 0) + 1; |
| 16154 |
this.$padding.right = (parseInt(style.borderRightWidth) || 0) |
| 16155 |
+ (parseInt(style.paddingRight) || 0); |
| 16156 |
return this.$padding; |
| 16157 |
}; |
| 16158 |
Gutter.prototype.getRegion = function (point) { |
| 16159 |
var padding = this.$padding || this.$computePadding(); |
| 16160 |
var rect = this.element.getBoundingClientRect(); |
| 16161 |
if (point.x < padding.left + rect.left) |
| 16162 |
return "markers"; |
| 16163 |
if (this.$showFoldWidgets && point.x > rect.right - padding.right) |
| 16164 |
return "foldWidgets"; |
| 16165 |
}; |
| 16166 |
return Gutter; |
| 16167 |
}()); |
| 16168 |
Gutter.prototype.$fixedWidth = false; |
| 16169 |
Gutter.prototype.$highlightGutterLine = true; |
| 16170 |
Gutter.prototype.$renderer = ""; |
| 16171 |
Gutter.prototype.$showLineNumbers = true; |
| 16172 |
Gutter.prototype.$showFoldWidgets = true; |
| 16173 |
oop.implement(Gutter.prototype, EventEmitter); |
| 16174 |
function onCreateCell(element) { |
| 16175 |
var textNode = document.createTextNode(''); |
| 16176 |
element.appendChild(textNode); |
| 16177 |
var foldWidget = dom.createElement("span"); |
| 16178 |
element.appendChild(foldWidget); |
| 16179 |
var annotationNode = dom.createElement("span"); |
| 16180 |
element.appendChild(annotationNode); |
| 16181 |
var annotationIconNode = dom.createElement("span"); |
| 16182 |
annotationNode.appendChild(annotationIconNode); |
| 16183 |
return element; |
| 16184 |
} |
| 16185 |
exports.Gutter = Gutter; |
| 16186 |
|
| 16187 |
}); |
| 16188 |
|
| 16189 |
ace.define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"], function(require, exports, module){"use strict"; |
| 16190 |
var Range = require("../range").Range; |
| 16191 |
var dom = require("../lib/dom"); |
| 16192 |
var Marker = (function () { |
| 16193 |
function Marker(parentEl) { |
| 16194 |
this.element = dom.createElement("div"); |
| 16195 |
this.element.className = "ace_layer ace_marker-layer"; |
| 16196 |
parentEl.appendChild(this.element); |
| 16197 |
} |
| 16198 |
Marker.prototype.setPadding = function (padding) { |
| 16199 |
this.$padding = padding; |
| 16200 |
}; |
| 16201 |
Marker.prototype.setSession = function (session) { |
| 16202 |
this.session = session; |
| 16203 |
}; |
| 16204 |
Marker.prototype.setMarkers = function (markers) { |
| 16205 |
this.markers = markers; |
| 16206 |
}; |
| 16207 |
Marker.prototype.elt = function (className, css) { |
| 16208 |
var x = this.i != -1 && this.element.childNodes[this.i]; |
| 16209 |
if (!x) { |
| 16210 |
x = document.createElement("div"); |
| 16211 |
this.element.appendChild(x); |
| 16212 |
this.i = -1; |
| 16213 |
} |
| 16214 |
else { |
| 16215 |
this.i++; |
| 16216 |
} |
| 16217 |
x.style.cssText = css; |
| 16218 |
x.className = className; |
| 16219 |
}; |
| 16220 |
Marker.prototype.update = function (config) { |
| 16221 |
if (!config) |
| 16222 |
return; |
| 16223 |
this.config = config; |
| 16224 |
this.i = 0; |
| 16225 |
var html; |
| 16226 |
for (var key in this.markers) { |
| 16227 |
var marker = this.markers[key]; |
| 16228 |
if (!marker.range) { |
| 16229 |
marker.update(html, this, this.session, config); |
| 16230 |
continue; |
| 16231 |
} |
| 16232 |
var range = marker.range.clipRows(config.firstRow, config.lastRow); |
| 16233 |
if (range.isEmpty()) |
| 16234 |
continue; |
| 16235 |
range = range.toScreenRange(this.session); |
| 16236 |
if (marker.renderer) { |
| 16237 |
var top = this.$getTop(range.start.row, config); |
| 16238 |
var left = this.$padding + range.start.column * config.characterWidth; |
| 16239 |
marker.renderer(html, range, left, top, config); |
| 16240 |
} |
| 16241 |
else if (marker.type == "fullLine") { |
| 16242 |
this.drawFullLineMarker(html, range, marker.clazz, config); |
| 16243 |
} |
| 16244 |
else if (marker.type == "screenLine") { |
| 16245 |
this.drawScreenLineMarker(html, range, marker.clazz, config); |
| 16246 |
} |
| 16247 |
else if (range.isMultiLine()) { |
| 16248 |
if (marker.type == "text") |
| 16249 |
this.drawTextMarker(html, range, marker.clazz, config); |
| 16250 |
else |
| 16251 |
this.drawMultiLineMarker(html, range, marker.clazz, config); |
| 16252 |
} |
| 16253 |
else { |
| 16254 |
this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config); |
| 16255 |
} |
| 16256 |
} |
| 16257 |
if (this.i != -1) { |
| 16258 |
while (this.i < this.element.childElementCount) |
| 16259 |
this.element.removeChild(this.element.lastChild); |
| 16260 |
} |
| 16261 |
}; |
| 16262 |
Marker.prototype.$getTop = function (row, layerConfig) { |
| 16263 |
return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight; |
| 16264 |
}; |
| 16265 |
Marker.prototype.drawTextMarker = function (stringBuilder, range, clazz, layerConfig, extraStyle) { |
| 16266 |
var session = this.session; |
| 16267 |
var start = range.start.row; |
| 16268 |
var end = range.end.row; |
| 16269 |
var row = start; |
| 16270 |
var prev = 0; |
| 16271 |
var curr = 0; |
| 16272 |
var next = session.getScreenLastRowColumn(row); |
| 16273 |
var lineRange = new Range(row, range.start.column, row, curr); |
| 16274 |
for (; row <= end; row++) { |
| 16275 |
lineRange.start.row = lineRange.end.row = row; |
| 16276 |
lineRange.start.column = row == start ? range.start.column : session.getRowWrapIndent(row); |
| 16277 |
lineRange.end.column = next; |
| 16278 |
prev = curr; |
| 16279 |
curr = next; |
| 16280 |
next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column; |
| 16281 |
this.drawSingleLineMarker(stringBuilder, lineRange, clazz + (row == start ? " ace_start" : "") + " ace_br" |
| 16282 |
+ getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end), layerConfig, row == end ? 0 : 1, extraStyle); |
| 16283 |
} |
| 16284 |
}; |
| 16285 |
Marker.prototype.drawMultiLineMarker = function (stringBuilder, range, clazz, config, extraStyle) { |
| 16286 |
var padding = this.$padding; |
| 16287 |
var height = config.lineHeight; |
| 16288 |
var top = this.$getTop(range.start.row, config); |
| 16289 |
var left = padding + range.start.column * config.characterWidth; |
| 16290 |
extraStyle = extraStyle || ""; |
| 16291 |
if (this.session.$bidiHandler.isBidiRow(range.start.row)) { |
| 16292 |
var range1 = range.clone(); |
| 16293 |
range1.end.row = range1.start.row; |
| 16294 |
range1.end.column = this.session.getLine(range1.start.row).length; |
| 16295 |
this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br1 ace_start", config, null, extraStyle); |
| 16296 |
} |
| 16297 |
else { |
| 16298 |
this.elt(clazz + " ace_br1 ace_start", "height:" + height + "px;" + "right:0;" + "top:" + top + "px;left:" + left + "px;" + (extraStyle || "")); |
| 16299 |
} |
| 16300 |
if (this.session.$bidiHandler.isBidiRow(range.end.row)) { |
| 16301 |
var range1 = range.clone(); |
| 16302 |
range1.start.row = range1.end.row; |
| 16303 |
range1.start.column = 0; |
| 16304 |
this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br12", config, null, extraStyle); |
| 16305 |
} |
| 16306 |
else { |
| 16307 |
top = this.$getTop(range.end.row, config); |
| 16308 |
var width = range.end.column * config.characterWidth; |
| 16309 |
this.elt(clazz + " ace_br12", "height:" + height + "px;" + |
| 16310 |
"width:" + width + "px;" + |
| 16311 |
"top:" + top + "px;" + |
| 16312 |
"left:" + padding + "px;" + (extraStyle || "")); |
| 16313 |
} |
| 16314 |
height = (range.end.row - range.start.row - 1) * config.lineHeight; |
| 16315 |
if (height <= 0) |
| 16316 |
return; |
| 16317 |
top = this.$getTop(range.start.row + 1, config); |
| 16318 |
var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8); |
| 16319 |
this.elt(clazz + (radiusClass ? " ace_br" + radiusClass : ""), "height:" + height + "px;" + |
| 16320 |
"right:0;" + |
| 16321 |
"top:" + top + "px;" + |
| 16322 |
"left:" + padding + "px;" + (extraStyle || "")); |
| 16323 |
}; |
| 16324 |
Marker.prototype.drawSingleLineMarker = function (stringBuilder, range, clazz, config, extraLength, extraStyle) { |
| 16325 |
if (this.session.$bidiHandler.isBidiRow(range.start.row)) |
| 16326 |
return this.drawBidiSingleLineMarker(stringBuilder, range, clazz, config, extraLength, extraStyle); |
| 16327 |
var height = config.lineHeight; |
| 16328 |
var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth; |
| 16329 |
var top = this.$getTop(range.start.row, config); |
| 16330 |
var left = this.$padding + range.start.column * config.characterWidth; |
| 16331 |
this.elt(clazz, "height:" + height + "px;" + |
| 16332 |
"width:" + width + "px;" + |
| 16333 |
"top:" + top + "px;" + |
| 16334 |
"left:" + left + "px;" + (extraStyle || "")); |
| 16335 |
}; |
| 16336 |
Marker.prototype.drawBidiSingleLineMarker = function (stringBuilder, range, clazz, config, extraLength, extraStyle) { |
| 16337 |
var height = config.lineHeight, top = this.$getTop(range.start.row, config), padding = this.$padding; |
| 16338 |
var selections = this.session.$bidiHandler.getSelections(range.start.column, range.end.column); |
| 16339 |
selections.forEach(function (selection) { |
| 16340 |
this.elt(clazz, "height:" + height + "px;" + |
| 16341 |
"width:" + (selection.width + (extraLength || 0)) + "px;" + |
| 16342 |
"top:" + top + "px;" + |
| 16343 |
"left:" + (padding + selection.left) + "px;" + (extraStyle || "")); |
| 16344 |
}, this); |
| 16345 |
}; |
| 16346 |
Marker.prototype.drawFullLineMarker = function (stringBuilder, range, clazz, config, extraStyle) { |
| 16347 |
var top = this.$getTop(range.start.row, config); |
| 16348 |
var height = config.lineHeight; |
| 16349 |
if (range.start.row != range.end.row) |
| 16350 |
height += this.$getTop(range.end.row, config) - top; |
| 16351 |
this.elt(clazz, "height:" + height + "px;" + |
| 16352 |
"top:" + top + "px;" + |
| 16353 |
"left:0;right:0;" + (extraStyle || "")); |
| 16354 |
}; |
| 16355 |
Marker.prototype.drawScreenLineMarker = function (stringBuilder, range, clazz, config, extraStyle) { |
| 16356 |
var top = this.$getTop(range.start.row, config); |
| 16357 |
var height = config.lineHeight; |
| 16358 |
this.elt(clazz, "height:" + height + "px;" + |
| 16359 |
"top:" + top + "px;" + |
| 16360 |
"left:0;right:0;" + (extraStyle || "")); |
| 16361 |
}; |
| 16362 |
return Marker; |
| 16363 |
}()); |
| 16364 |
Marker.prototype.$padding = 0; |
| 16365 |
function getBorderClass(tl, tr, br, bl) { |
| 16366 |
return (tl ? 1 : 0) | (tr ? 2 : 0) | (br ? 4 : 0) | (bl ? 8 : 0); |
| 16367 |
} |
| 16368 |
exports.Marker = Marker; |
| 16369 |
|
| 16370 |
}); |
| 16371 |
|
| 16372 |
ace.define("ace/layer/text_util",["require","exports","module"], function(require, exports, module){ |
| 16373 |
var textTokens = new Set(["text", "rparen", "lparen"]); |
| 16374 |
exports.isTextToken = function (tokenType) { |
| 16375 |
return textTokens.has(tokenType); |
| 16376 |
}; |
| 16377 |
|
| 16378 |
}); |
| 16379 |
|
| 16380 |
ace.define("ace/layer/text",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/layer/lines","ace/lib/event_emitter","ace/config","ace/layer/text_util"], function(require, exports, module){"use strict"; |
| 16381 |
var oop = require("../lib/oop"); |
| 16382 |
var dom = require("../lib/dom"); |
| 16383 |
var lang = require("../lib/lang"); |
| 16384 |
var Lines = require("./lines").Lines; |
| 16385 |
var EventEmitter = require("../lib/event_emitter").EventEmitter; |
| 16386 |
var nls = require("../config").nls; |
| 16387 |
var isTextToken = require("./text_util").isTextToken; |
| 16388 |
var Text = (function () { |
| 16389 |
function Text(parentEl) { |
| 16390 |
this.dom = dom; |
| 16391 |
this.element = this.dom.createElement("div"); |
| 16392 |
this.element.className = "ace_layer ace_text-layer"; |
| 16393 |
parentEl.appendChild(this.element); |
| 16394 |
this.$updateEolChar = this.$updateEolChar.bind(this); |
| 16395 |
this.$lines = new Lines(this.element); |
| 16396 |
} |
| 16397 |
Text.prototype.$updateEolChar = function () { |
| 16398 |
var doc = this.session.doc; |
| 16399 |
var unixMode = doc.getNewLineCharacter() == "\n" && doc.getNewLineMode() != "windows"; |
| 16400 |
var EOL_CHAR = unixMode ? this.EOL_CHAR_LF : this.EOL_CHAR_CRLF; |
| 16401 |
if (this.EOL_CHAR != EOL_CHAR) { |
| 16402 |
this.EOL_CHAR = EOL_CHAR; |
| 16403 |
return true; |
| 16404 |
} |
| 16405 |
}; |
| 16406 |
Text.prototype.setPadding = function (padding) { |
| 16407 |
this.$padding = padding; |
| 16408 |
this.element.style.margin = "0 " + padding + "px"; |
| 16409 |
}; |
| 16410 |
Text.prototype.getLineHeight = function () { |
| 16411 |
return this.$fontMetrics.$characterSize.height || 0; |
| 16412 |
}; |
| 16413 |
Text.prototype.getCharacterWidth = function () { |
| 16414 |
return this.$fontMetrics.$characterSize.width || 0; |
| 16415 |
}; |
| 16416 |
Text.prototype.$setFontMetrics = function (measure) { |
| 16417 |
this.$fontMetrics = measure; |
| 16418 |
this.$fontMetrics.on("changeCharacterSize", |
| 16419 |
function (e) { |
| 16420 |
this._signal("changeCharacterSize", e); |
| 16421 |
}.bind(this)); |
| 16422 |
this.$pollSizeChanges(); |
| 16423 |
}; |
| 16424 |
Text.prototype.checkForSizeChanges = function () { |
| 16425 |
this.$fontMetrics.checkForSizeChanges(); |
| 16426 |
}; |
| 16427 |
Text.prototype.$pollSizeChanges = function () { |
| 16428 |
return this.$pollSizeChangesTimer = this.$fontMetrics.$pollSizeChanges(); |
| 16429 |
}; |
| 16430 |
Text.prototype.setSession = function (session) { |
| 16431 |
this.session = session; |
| 16432 |
if (session) |
| 16433 |
this.$computeTabString(); |
| 16434 |
}; |
| 16435 |
Text.prototype.setShowInvisibles = function (showInvisibles) { |
| 16436 |
if (this.showInvisibles == showInvisibles) |
| 16437 |
return false; |
| 16438 |
this.showInvisibles = showInvisibles; |
| 16439 |
if (typeof showInvisibles == "string") { |
| 16440 |
this.showSpaces = /tab/i.test(showInvisibles); |
| 16441 |
this.showTabs = /space/i.test(showInvisibles); |
| 16442 |
this.showEOL = /eol/i.test(showInvisibles); |
| 16443 |
} |
| 16444 |
else { |
| 16445 |
this.showSpaces = this.showTabs = this.showEOL = showInvisibles; |
| 16446 |
} |
| 16447 |
this.$computeTabString(); |
| 16448 |
return true; |
| 16449 |
}; |
| 16450 |
Text.prototype.setDisplayIndentGuides = function (display) { |
| 16451 |
if (this.displayIndentGuides == display) |
| 16452 |
return false; |
| 16453 |
this.displayIndentGuides = display; |
| 16454 |
this.$computeTabString(); |
| 16455 |
return true; |
| 16456 |
}; |
| 16457 |
Text.prototype.setHighlightIndentGuides = function (highlight) { |
| 16458 |
if (this.$highlightIndentGuides === highlight) |
| 16459 |
return false; |
| 16460 |
this.$highlightIndentGuides = highlight; |
| 16461 |
return highlight; |
| 16462 |
}; |
| 16463 |
Text.prototype.$computeTabString = function () { |
| 16464 |
var tabSize = this.session.getTabSize(); |
| 16465 |
this.tabSize = tabSize; var tabStr = this.$tabStrings = [0]; |
| 16466 |
for (var i = 1; i < tabSize + 1; i++) { |
| 16467 |
if (this.showTabs) { |
| 16468 |
var span = this.dom.createElement("span"); |
| 16469 |
span.className = "ace_invisible ace_invisible_tab"; |
| 16470 |
span.textContent = lang.stringRepeat(this.TAB_CHAR, i); |
| 16471 |
tabStr.push(span); |
| 16472 |
} |
| 16473 |
else { |
| 16474 |
tabStr.push(this.dom.createTextNode(lang.stringRepeat(" ", i), this.element)); |
| 16475 |
} |
| 16476 |
} |
| 16477 |
if (this.displayIndentGuides) { |
| 16478 |
this.$indentGuideRe = /\s\S| \t|\t |\s$/; |
| 16479 |
var className = "ace_indent-guide"; |
| 16480 |
var spaceClass = this.showSpaces ? " ace_invisible ace_invisible_space" : ""; |
| 16481 |
var spaceContent = this.showSpaces |
| 16482 |
? lang.stringRepeat(this.SPACE_CHAR, this.tabSize) |
| 16483 |
: lang.stringRepeat(" ", this.tabSize); |
| 16484 |
var tabClass = this.showTabs ? " ace_invisible ace_invisible_tab" : ""; |
| 16485 |
var tabContent = this.showTabs |
| 16486 |
? lang.stringRepeat(this.TAB_CHAR, this.tabSize) |
| 16487 |
: spaceContent; |
| 16488 |
var span = this.dom.createElement("span"); |
| 16489 |
span.className = className + spaceClass; |
| 16490 |
span.textContent = spaceContent; |
| 16491 |
this.$tabStrings[" "] = span; |
| 16492 |
var span = this.dom.createElement("span"); |
| 16493 |
span.className = className + tabClass; |
| 16494 |
span.textContent = tabContent; |
| 16495 |
this.$tabStrings["\t"] = span; |
| 16496 |
} |
| 16497 |
}; |
| 16498 |
Text.prototype.updateLines = function (config, firstRow, lastRow) { |
| 16499 |
if (this.config.lastRow != config.lastRow || |
| 16500 |
this.config.firstRow != config.firstRow) { |
| 16501 |
return this.update(config); |
| 16502 |
} |
| 16503 |
this.config = config; |
| 16504 |
var first = Math.max(firstRow, config.firstRow); |
| 16505 |
var last = Math.min(lastRow, config.lastRow); |
| 16506 |
var lineElements = this.element.childNodes; |
| 16507 |
var lineElementsIdx = 0; |
| 16508 |
for (var row = config.firstRow; row < first; row++) { |
| 16509 |
var foldLine = this.session.getFoldLine(row); |
| 16510 |
if (foldLine) { |
| 16511 |
if (foldLine.containsRow(first)) { |
| 16512 |
first = foldLine.start.row; |
| 16513 |
break; |
| 16514 |
} |
| 16515 |
else { |
| 16516 |
row = foldLine.end.row; |
| 16517 |
} |
| 16518 |
} |
| 16519 |
lineElementsIdx++; |
| 16520 |
} |
| 16521 |
var heightChanged = false; |
| 16522 |
var row = first; |
| 16523 |
var foldLine = this.session.getNextFoldLine(row); |
| 16524 |
var foldStart = foldLine ? foldLine.start.row : Infinity; |
| 16525 |
while (true) { |
| 16526 |
if (row > foldStart) { |
| 16527 |
row = foldLine.end.row + 1; |
| 16528 |
foldLine = this.session.getNextFoldLine(row, foldLine); |
| 16529 |
foldStart = foldLine ? foldLine.start.row : Infinity; |
| 16530 |
} |
| 16531 |
if (row > last) |
| 16532 |
break; var lineElement = lineElements[lineElementsIdx++]; |
| 16533 |
if (lineElement) { |
| 16534 |
this.dom.removeChildren(lineElement); |
| 16535 |
this.$renderLine(lineElement, row, row == foldStart ? foldLine : false); |
| 16536 |
if (heightChanged) |
| 16537 |
lineElement.style.top = this.$lines.computeLineTop(row, config, this.session) + "px"; |
| 16538 |
var height = (config.lineHeight * this.session.getRowLength(row)) + "px"; |
| 16539 |
if (lineElement.style.height != height) { |
| 16540 |
heightChanged = true; |
| 16541 |
lineElement.style.height = height; |
| 16542 |
} |
| 16543 |
} |
| 16544 |
row++; |
| 16545 |
} |
| 16546 |
if (heightChanged) { |
| 16547 |
while (lineElementsIdx < this.$lines.cells.length) { |
| 16548 |
var cell = this.$lines.cells[lineElementsIdx++]; |
| 16549 |
cell.element.style.top = this.$lines.computeLineTop(cell.row, config, this.session) + "px"; |
| 16550 |
} |
| 16551 |
} |
| 16552 |
}; |
| 16553 |
Text.prototype.scrollLines = function (config) { |
| 16554 |
var oldConfig = this.config; |
| 16555 |
this.config = config; |
| 16556 |
if (this.$lines.pageChanged(oldConfig, config)) |
| 16557 |
return this.update(config); |
| 16558 |
this.$lines.moveContainer(config); |
| 16559 |
var lastRow = config.lastRow; |
| 16560 |
var oldLastRow = oldConfig ? oldConfig.lastRow : -1; |
| 16561 |
if (!oldConfig || oldLastRow < config.firstRow) |
| 16562 |
return this.update(config); |
| 16563 |
if (lastRow < oldConfig.firstRow) |
| 16564 |
return this.update(config); |
| 16565 |
if (!oldConfig || oldConfig.lastRow < config.firstRow) |
| 16566 |
return this.update(config); |
| 16567 |
if (config.lastRow < oldConfig.firstRow) |
| 16568 |
return this.update(config); |
| 16569 |
if (oldConfig.firstRow < config.firstRow) |
| 16570 |
for (var row = this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row > 0; row--) |
| 16571 |
this.$lines.shift(); |
| 16572 |
if (oldConfig.lastRow > config.lastRow) |
| 16573 |
for (var row = this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row > 0; row--) |
| 16574 |
this.$lines.pop(); |
| 16575 |
if (config.firstRow < oldConfig.firstRow) { |
| 16576 |
this.$lines.unshift(this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1)); |
| 16577 |
} |
| 16578 |
if (config.lastRow > oldConfig.lastRow) { |
| 16579 |
this.$lines.push(this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow)); |
| 16580 |
} |
| 16581 |
this.$highlightIndentGuide(); |
| 16582 |
}; |
| 16583 |
Text.prototype.$renderLinesFragment = function (config, firstRow, lastRow) { |
| 16584 |
var fragment = []; |
| 16585 |
var row = firstRow; |
| 16586 |
var foldLine = this.session.getNextFoldLine(row); |
| 16587 |
var foldStart = foldLine ? foldLine.start.row : Infinity; |
| 16588 |
while (true) { |
| 16589 |
if (row > foldStart) { |
| 16590 |
row = foldLine.end.row + 1; |
| 16591 |
foldLine = this.session.getNextFoldLine(row, foldLine); |
| 16592 |
foldStart = foldLine ? foldLine.start.row : Infinity; |
| 16593 |
} |
| 16594 |
if (row > lastRow) |
| 16595 |
break; |
| 16596 |
var line = this.$lines.createCell(row, config, this.session); |
| 16597 |
var lineEl = line.element; |
| 16598 |
this.dom.removeChildren(lineEl); |
| 16599 |
dom.setStyle(lineEl.style, "height", this.$lines.computeLineHeight(row, config, this.session) + "px"); |
| 16600 |
dom.setStyle(lineEl.style, "top", this.$lines.computeLineTop(row, config, this.session) + "px"); |
| 16601 |
this.$renderLine(lineEl, row, row == foldStart ? foldLine : false); |
| 16602 |
if (this.$useLineGroups()) { |
| 16603 |
lineEl.className = "ace_line_group"; |
| 16604 |
} |
| 16605 |
else { |
| 16606 |
lineEl.className = "ace_line"; |
| 16607 |
} |
| 16608 |
fragment.push(line); |
| 16609 |
row++; |
| 16610 |
} |
| 16611 |
return fragment; |
| 16612 |
}; |
| 16613 |
Text.prototype.update = function (config) { |
| 16614 |
this.$lines.moveContainer(config); |
| 16615 |
this.config = config; |
| 16616 |
var firstRow = config.firstRow; |
| 16617 |
var lastRow = config.lastRow; |
| 16618 |
var lines = this.$lines; |
| 16619 |
while (lines.getLength()) |
| 16620 |
lines.pop(); |
| 16621 |
lines.push(this.$renderLinesFragment(config, firstRow, lastRow)); |
| 16622 |
}; |
| 16623 |
Text.prototype.$renderToken = function (parent, screenColumn, token, value) { |
| 16624 |
var self = this; |
| 16625 |
var re = /(\t)|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\uFEFF\uFFF9-\uFFFC\u2066\u2067\u2068\u202A\u202B\u202D\u202E\u202C\u2069]+)|(\u3000)|([\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3001-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]|[\uD800-\uDBFF][\uDC00-\uDFFF])/g; |
| 16626 |
var valueFragment = this.dom.createFragment(this.element); |
| 16627 |
var m; |
| 16628 |
var i = 0; |
| 16629 |
while (m = re.exec(value)) { |
| 16630 |
var tab = m[1]; |
| 16631 |
var simpleSpace = m[2]; |
| 16632 |
var controlCharacter = m[3]; |
| 16633 |
var cjkSpace = m[4]; |
| 16634 |
var cjk = m[5]; |
| 16635 |
if (!self.showSpaces && simpleSpace) |
| 16636 |
continue; |
| 16637 |
var before = i != m.index ? value.slice(i, m.index) : ""; |
| 16638 |
i = m.index + m[0].length; |
| 16639 |
if (before) { |
| 16640 |
valueFragment.appendChild(this.dom.createTextNode(before, this.element)); |
| 16641 |
} |
| 16642 |
if (tab) { |
| 16643 |
var tabSize = self.session.getScreenTabSize(screenColumn + m.index); |
| 16644 |
valueFragment.appendChild(self.$tabStrings[tabSize].cloneNode(true)); |
| 16645 |
screenColumn += tabSize - 1; |
| 16646 |
} |
| 16647 |
else if (simpleSpace) { |
| 16648 |
if (self.showSpaces) { |
| 16649 |
var span = this.dom.createElement("span"); |
| 16650 |
span.className = "ace_invisible ace_invisible_space"; |
| 16651 |
span.textContent = lang.stringRepeat(self.SPACE_CHAR, simpleSpace.length); |
| 16652 |
valueFragment.appendChild(span); |
| 16653 |
} |
| 16654 |
else { |
| 16655 |
valueFragment.appendChild(this.dom.createTextNode(simpleSpace, this.element)); |
| 16656 |
} |
| 16657 |
} |
| 16658 |
else if (controlCharacter) { |
| 16659 |
var span = this.dom.createElement("span"); |
| 16660 |
span.className = "ace_invisible ace_invisible_space ace_invalid"; |
| 16661 |
span.textContent = lang.stringRepeat(self.SPACE_CHAR, controlCharacter.length); |
| 16662 |
valueFragment.appendChild(span); |
| 16663 |
} |
| 16664 |
else if (cjkSpace) { |
| 16665 |
screenColumn += 1; |
| 16666 |
var span = this.dom.createElement("span"); |
| 16667 |
span.style.width = (self.config.characterWidth * 2) + "px"; |
| 16668 |
span.className = self.showSpaces ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk"; |
| 16669 |
span.textContent = self.showSpaces ? self.SPACE_CHAR : cjkSpace; |
| 16670 |
valueFragment.appendChild(span); |
| 16671 |
} |
| 16672 |
else if (cjk) { |
| 16673 |
screenColumn += 1; |
| 16674 |
var span = this.dom.createElement("span"); |
| 16675 |
span.style.width = (self.config.characterWidth * 2) + "px"; |
| 16676 |
span.className = "ace_cjk"; |
| 16677 |
span.textContent = cjk; |
| 16678 |
valueFragment.appendChild(span); |
| 16679 |
} |
| 16680 |
} |
| 16681 |
valueFragment.appendChild(this.dom.createTextNode(i ? value.slice(i) : value, this.element)); |
| 16682 |
if (!isTextToken(token.type)) { |
| 16683 |
var classes = "ace_" + token.type.replace(/\./g, " ace_"); |
| 16684 |
var span = this.dom.createElement("span"); |
| 16685 |
if (token.type == "fold") { |
| 16686 |
span.style.width = (token.value.length * this.config.characterWidth) + "px"; |
| 16687 |
span.setAttribute("title", nls("Unfold code")); |
| 16688 |
} |
| 16689 |
span.className = classes; |
| 16690 |
span.appendChild(valueFragment); |
| 16691 |
parent.appendChild(span); |
| 16692 |
} |
| 16693 |
else { |
| 16694 |
parent.appendChild(valueFragment); |
| 16695 |
} |
| 16696 |
return screenColumn + value.length; |
| 16697 |
}; |
| 16698 |
Text.prototype.renderIndentGuide = function (parent, value, max) { |
| 16699 |
var cols = value.search(this.$indentGuideRe); |
| 16700 |
if (cols <= 0 || cols >= max) |
| 16701 |
return value; |
| 16702 |
if (value[0] == " ") { |
| 16703 |
cols -= cols % this.tabSize; |
| 16704 |
var count = cols / this.tabSize; |
| 16705 |
for (var i = 0; i < count; i++) { |
| 16706 |
parent.appendChild(this.$tabStrings[" "].cloneNode(true)); |
| 16707 |
} |
| 16708 |
this.$highlightIndentGuide(); |
| 16709 |
return value.substr(cols); |
| 16710 |
} |
| 16711 |
else if (value[0] == "\t") { |
| 16712 |
for (var i = 0; i < cols; i++) { |
| 16713 |
parent.appendChild(this.$tabStrings["\t"].cloneNode(true)); |
| 16714 |
} |
| 16715 |
this.$highlightIndentGuide(); |
| 16716 |
return value.substr(cols); |
| 16717 |
} |
| 16718 |
this.$highlightIndentGuide(); |
| 16719 |
return value; |
| 16720 |
}; |
| 16721 |
Text.prototype.$highlightIndentGuide = function () { |
| 16722 |
if (!this.$highlightIndentGuides || !this.displayIndentGuides) |
| 16723 |
return; |
| 16724 |
this.$highlightIndentGuideMarker = { |
| 16725 |
indentLevel: undefined, |
| 16726 |
start: undefined, |
| 16727 |
end: undefined, |
| 16728 |
dir: undefined |
| 16729 |
}; |
| 16730 |
var lines = this.session.doc.$lines; |
| 16731 |
if (!lines) |
| 16732 |
return; |
| 16733 |
var cursor = this.session.selection.getCursor(); |
| 16734 |
var initialIndent = /^\s*/.exec(this.session.doc.getLine(cursor.row))[0].length; |
| 16735 |
var elementIndentLevel = Math.floor(initialIndent / this.tabSize); |
| 16736 |
this.$highlightIndentGuideMarker = { |
| 16737 |
indentLevel: elementIndentLevel, |
| 16738 |
start: cursor.row |
| 16739 |
}; |
| 16740 |
var bracketHighlight = this.session.$bracketHighlight; |
| 16741 |
if (bracketHighlight) { |
| 16742 |
var ranges = this.session.$bracketHighlight.ranges; |
| 16743 |
for (var i = 0; i < ranges.length; i++) { |
| 16744 |
if (cursor.row !== ranges[i].start.row) { |
| 16745 |
this.$highlightIndentGuideMarker.end = ranges[i].start.row; |
| 16746 |
if (cursor.row > ranges[i].start.row) { |
| 16747 |
this.$highlightIndentGuideMarker.dir = -1; |
| 16748 |
} |
| 16749 |
else { |
| 16750 |
this.$highlightIndentGuideMarker.dir = 1; |
| 16751 |
} |
| 16752 |
break; |
| 16753 |
} |
| 16754 |
} |
| 16755 |
} |
| 16756 |
if (!this.$highlightIndentGuideMarker.end) { |
| 16757 |
if (lines[cursor.row] !== '' && cursor.column === lines[cursor.row].length) { |
| 16758 |
this.$highlightIndentGuideMarker.dir = 1; |
| 16759 |
for (var i = cursor.row + 1; i < lines.length; i++) { |
| 16760 |
var line = lines[i]; |
| 16761 |
var currentIndent = /^\s*/.exec(line)[0].length; |
| 16762 |
if (line !== '') { |
| 16763 |
this.$highlightIndentGuideMarker.end = i; |
| 16764 |
if (currentIndent <= initialIndent) |
| 16765 |
break; |
| 16766 |
} |
| 16767 |
} |
| 16768 |
} |
| 16769 |
} |
| 16770 |
this.$renderHighlightIndentGuide(); |
| 16771 |
}; |
| 16772 |
Text.prototype.$clearActiveIndentGuide = function () { |
| 16773 |
var cells = this.$lines.cells; |
| 16774 |
for (var i = 0; i < cells.length; i++) { |
| 16775 |
var cell = cells[i]; |
| 16776 |
var childNodes = cell.element.childNodes; |
| 16777 |
if (childNodes.length > 0) { |
| 16778 |
for (var j = 0; j < childNodes.length; j++) { |
| 16779 |
if (childNodes[j].classList && childNodes[j].classList.contains("ace_indent-guide-active")) { |
| 16780 |
childNodes[j].classList.remove("ace_indent-guide-active"); |
| 16781 |
break; |
| 16782 |
} |
| 16783 |
} |
| 16784 |
} |
| 16785 |
} |
| 16786 |
}; |
| 16787 |
Text.prototype.$setIndentGuideActive = function (cell, indentLevel) { |
| 16788 |
var line = this.session.doc.getLine(cell.row); |
| 16789 |
if (line !== "") { |
| 16790 |
var childNodes = cell.element.childNodes; |
| 16791 |
if (childNodes) { |
| 16792 |
var node = childNodes[indentLevel - 1]; |
| 16793 |
if (node && node.classList && node.classList.contains("ace_indent-guide")) |
| 16794 |
node.classList.add("ace_indent-guide-active"); |
| 16795 |
} |
| 16796 |
} |
| 16797 |
}; |
| 16798 |
Text.prototype.$renderHighlightIndentGuide = function () { |
| 16799 |
if (!this.$lines) |
| 16800 |
return; |
| 16801 |
var cells = this.$lines.cells; |
| 16802 |
this.$clearActiveIndentGuide(); |
| 16803 |
var indentLevel = this.$highlightIndentGuideMarker.indentLevel; |
| 16804 |
if (indentLevel !== 0) { |
| 16805 |
if (this.$highlightIndentGuideMarker.dir === 1) { |
| 16806 |
for (var i = 0; i < cells.length; i++) { |
| 16807 |
var cell = cells[i]; |
| 16808 |
if (this.$highlightIndentGuideMarker.end && cell.row >= this.$highlightIndentGuideMarker.start |
| 16809 |
+ 1) { |
| 16810 |
if (cell.row >= this.$highlightIndentGuideMarker.end) |
| 16811 |
break; |
| 16812 |
this.$setIndentGuideActive(cell, indentLevel); |
| 16813 |
} |
| 16814 |
} |
| 16815 |
} |
| 16816 |
else { |
| 16817 |
for (var i = cells.length - 1; i >= 0; i--) { |
| 16818 |
var cell = cells[i]; |
| 16819 |
if (this.$highlightIndentGuideMarker.end && cell.row < this.$highlightIndentGuideMarker.start) { |
| 16820 |
if (cell.row <= this.$highlightIndentGuideMarker.end) |
| 16821 |
break; |
| 16822 |
this.$setIndentGuideActive(cell, indentLevel); |
| 16823 |
} |
| 16824 |
} |
| 16825 |
} |
| 16826 |
} |
| 16827 |
}; |
| 16828 |
Text.prototype.$createLineElement = function (parent) { |
| 16829 |
var lineEl = this.dom.createElement("div"); |
| 16830 |
lineEl.className = "ace_line"; |
| 16831 |
lineEl.style.height = this.config.lineHeight + "px"; |
| 16832 |
return lineEl; |
| 16833 |
}; |
| 16834 |
Text.prototype.$renderWrappedLine = function (parent, tokens, splits) { |
| 16835 |
var chars = 0; |
| 16836 |
var split = 0; |
| 16837 |
var splitChars = splits[0]; |
| 16838 |
var screenColumn = 0; |
| 16839 |
var lineEl = this.$createLineElement(); |
| 16840 |
parent.appendChild(lineEl); |
| 16841 |
for (var i = 0; i < tokens.length; i++) { |
| 16842 |
var token = tokens[i]; |
| 16843 |
var value = token.value; |
| 16844 |
if (i == 0 && this.displayIndentGuides) { |
| 16845 |
chars = value.length; |
| 16846 |
value = this.renderIndentGuide(lineEl, value, splitChars); |
| 16847 |
if (!value) |
| 16848 |
continue; |
| 16849 |
chars -= value.length; |
| 16850 |
} |
| 16851 |
if (chars + value.length < splitChars) { |
| 16852 |
screenColumn = this.$renderToken(lineEl, screenColumn, token, value); |
| 16853 |
chars += value.length; |
| 16854 |
} |
| 16855 |
else { |
| 16856 |
while (chars + value.length >= splitChars) { |
| 16857 |
screenColumn = this.$renderToken(lineEl, screenColumn, token, value.substring(0, splitChars - chars)); |
| 16858 |
value = value.substring(splitChars - chars); |
| 16859 |
chars = splitChars; |
| 16860 |
lineEl = this.$createLineElement(); |
| 16861 |
parent.appendChild(lineEl); |
| 16862 |
lineEl.appendChild(this.dom.createTextNode(lang.stringRepeat("\xa0", splits.indent), this.element)); |
| 16863 |
split++; |
| 16864 |
screenColumn = 0; |
| 16865 |
splitChars = splits[split] || Number.MAX_VALUE; |
| 16866 |
} |
| 16867 |
if (value.length != 0) { |
| 16868 |
chars += value.length; |
| 16869 |
screenColumn = this.$renderToken(lineEl, screenColumn, token, value); |
| 16870 |
} |
| 16871 |
} |
| 16872 |
} |
| 16873 |
if (splits[splits.length - 1] > this.MAX_LINE_LENGTH) |
| 16874 |
this.$renderOverflowMessage(lineEl, screenColumn, null, "", true); |
| 16875 |
}; |
| 16876 |
Text.prototype.$renderSimpleLine = function (parent, tokens) { |
| 16877 |
var screenColumn = 0; |
| 16878 |
for (var i = 0; i < tokens.length; i++) { |
| 16879 |
var token = tokens[i]; |
| 16880 |
var value = token.value; |
| 16881 |
if (i == 0 && this.displayIndentGuides) { |
| 16882 |
value = this.renderIndentGuide(parent, value); |
| 16883 |
if (!value) |
| 16884 |
continue; |
| 16885 |
} |
| 16886 |
if (screenColumn + value.length > this.MAX_LINE_LENGTH) |
| 16887 |
return this.$renderOverflowMessage(parent, screenColumn, token, value); |
| 16888 |
screenColumn = this.$renderToken(parent, screenColumn, token, value); |
| 16889 |
} |
| 16890 |
}; |
| 16891 |
Text.prototype.$renderOverflowMessage = function (parent, screenColumn, token, value, hide) { |
| 16892 |
token && this.$renderToken(parent, screenColumn, token, value.slice(0, this.MAX_LINE_LENGTH - screenColumn)); |
| 16893 |
var overflowEl = this.dom.createElement("span"); |
| 16894 |
overflowEl.className = "ace_inline_button ace_keyword ace_toggle_wrap"; |
| 16895 |
overflowEl.textContent = hide ? "<hide>" : "<click to see more...>"; |
| 16896 |
parent.appendChild(overflowEl); |
| 16897 |
}; |
| 16898 |
Text.prototype.$renderLine = function (parent, row, foldLine) { |
| 16899 |
if (!foldLine && foldLine != false) |
| 16900 |
foldLine = this.session.getFoldLine(row); |
| 16901 |
if (foldLine) |
| 16902 |
var tokens = this.$getFoldLineTokens(row, foldLine); |
| 16903 |
else |
| 16904 |
var tokens = this.session.getTokens(row); |
| 16905 |
var lastLineEl = parent; |
| 16906 |
if (tokens.length) { |
| 16907 |
var splits = this.session.getRowSplitData(row); |
| 16908 |
if (splits && splits.length) { |
| 16909 |
this.$renderWrappedLine(parent, tokens, splits); |
| 16910 |
var lastLineEl = parent.lastChild; |
| 16911 |
} |
| 16912 |
else { |
| 16913 |
var lastLineEl = parent; |
| 16914 |
if (this.$useLineGroups()) { |
| 16915 |
lastLineEl = this.$createLineElement(); |
| 16916 |
parent.appendChild(lastLineEl); |
| 16917 |
} |
| 16918 |
this.$renderSimpleLine(lastLineEl, tokens); |
| 16919 |
} |
| 16920 |
} |
| 16921 |
else if (this.$useLineGroups()) { |
| 16922 |
lastLineEl = this.$createLineElement(); |
| 16923 |
parent.appendChild(lastLineEl); |
| 16924 |
} |
| 16925 |
if (this.showEOL && lastLineEl) { |
| 16926 |
if (foldLine) |
| 16927 |
row = foldLine.end.row; |
| 16928 |
var invisibleEl = this.dom.createElement("span"); |
| 16929 |
invisibleEl.className = "ace_invisible ace_invisible_eol"; |
| 16930 |
invisibleEl.textContent = row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR; |
| 16931 |
lastLineEl.appendChild(invisibleEl); |
| 16932 |
} |
| 16933 |
}; |
| 16934 |
Text.prototype.$getFoldLineTokens = function (row, foldLine) { |
| 16935 |
var session = this.session; |
| 16936 |
var renderTokens = []; |
| 16937 |
function addTokens(tokens, from, to) { |
| 16938 |
var idx = 0, col = 0; |
| 16939 |
while ((col + tokens[idx].value.length) < from) { |
| 16940 |
col += tokens[idx].value.length; |
| 16941 |
idx++; |
| 16942 |
if (idx == tokens.length) |
| 16943 |
return; |
| 16944 |
} |
| 16945 |
if (col != from) { |
| 16946 |
var value = tokens[idx].value.substring(from - col); |
| 16947 |
if (value.length > (to - from)) |
| 16948 |
value = value.substring(0, to - from); |
| 16949 |
renderTokens.push({ |
| 16950 |
type: tokens[idx].type, |
| 16951 |
value: value |
| 16952 |
}); |
| 16953 |
col = from + value.length; |
| 16954 |
idx += 1; |
| 16955 |
} |
| 16956 |
while (col < to && idx < tokens.length) { |
| 16957 |
var value = tokens[idx].value; |
| 16958 |
if (value.length + col > to) { |
| 16959 |
renderTokens.push({ |
| 16960 |
type: tokens[idx].type, |
| 16961 |
value: value.substring(0, to - col) |
| 16962 |
}); |
| 16963 |
} |
| 16964 |
else |
| 16965 |
renderTokens.push(tokens[idx]); |
| 16966 |
col += value.length; |
| 16967 |
idx += 1; |
| 16968 |
} |
| 16969 |
} |
| 16970 |
var tokens = session.getTokens(row); |
| 16971 |
foldLine.walk(function (placeholder, row, column, lastColumn, isNewRow) { |
| 16972 |
if (placeholder != null) { |
| 16973 |
renderTokens.push({ |
| 16974 |
type: "fold", |
| 16975 |
value: placeholder |
| 16976 |
}); |
| 16977 |
} |
| 16978 |
else { |
| 16979 |
if (isNewRow) |
| 16980 |
tokens = session.getTokens(row); |
| 16981 |
if (tokens.length) |
| 16982 |
addTokens(tokens, lastColumn, column); |
| 16983 |
} |
| 16984 |
}, foldLine.end.row, this.session.getLine(foldLine.end.row).length); |
| 16985 |
return renderTokens; |
| 16986 |
}; |
| 16987 |
Text.prototype.$useLineGroups = function () { |
| 16988 |
return this.session.getUseWrapMode(); |
| 16989 |
}; |
| 16990 |
return Text; |
| 16991 |
}()); |
| 16992 |
Text.prototype.EOF_CHAR = "\xB6"; |
| 16993 |
Text.prototype.EOL_CHAR_LF = "\xAC"; |
| 16994 |
Text.prototype.EOL_CHAR_CRLF = "\xa4"; |
| 16995 |
Text.prototype.EOL_CHAR = Text.prototype.EOL_CHAR_LF; |
| 16996 |
Text.prototype.TAB_CHAR = "\u2014"; |
| 16997 |
Text.prototype.SPACE_CHAR = "\xB7"; |
| 16998 |
Text.prototype.$padding = 0; |
| 16999 |
Text.prototype.MAX_LINE_LENGTH = 10000; |
| 17000 |
Text.prototype.showInvisibles = false; |
| 17001 |
Text.prototype.showSpaces = false; |
| 17002 |
Text.prototype.showTabs = false; |
| 17003 |
Text.prototype.showEOL = false; |
| 17004 |
Text.prototype.displayIndentGuides = true; |
| 17005 |
Text.prototype.$highlightIndentGuides = true; |
| 17006 |
Text.prototype.$tabStrings = []; |
| 17007 |
Text.prototype.destroy = {}; |
| 17008 |
Text.prototype.onChangeTabSize = Text.prototype.$computeTabString; |
| 17009 |
oop.implement(Text.prototype, EventEmitter); |
| 17010 |
exports.Text = Text; |
| 17011 |
|
| 17012 |
}); |
| 17013 |
|
| 17014 |
ace.define("ace/layer/cursor",["require","exports","module","ace/lib/dom"], function(require, exports, module){"use strict"; |
| 17015 |
var dom = require("../lib/dom"); |
| 17016 |
var Cursor = (function () { |
| 17017 |
function Cursor(parentEl) { |
| 17018 |
this.element = dom.createElement("div"); |
| 17019 |
this.element.className = "ace_layer ace_cursor-layer"; |
| 17020 |
parentEl.appendChild(this.element); |
| 17021 |
this.isVisible = false; |
| 17022 |
this.isBlinking = true; |
| 17023 |
this.blinkInterval = 1000; |
| 17024 |
this.smoothBlinking = false; |
| 17025 |
this.cursors = []; |
| 17026 |
this.cursor = this.addCursor(); |
| 17027 |
dom.addCssClass(this.element, "ace_hidden-cursors"); |
| 17028 |
this.$updateCursors = this.$updateOpacity.bind(this); |
| 17029 |
} |
| 17030 |
Cursor.prototype.$updateOpacity = function (val) { |
| 17031 |
var cursors = this.cursors; |
| 17032 |
for (var i = cursors.length; i--;) |
| 17033 |
dom.setStyle(cursors[i].style, "opacity", val ? "" : "0"); |
| 17034 |
}; |
| 17035 |
Cursor.prototype.$startCssAnimation = function () { |
| 17036 |
var cursors = this.cursors; |
| 17037 |
for (var i = cursors.length; i--;) |
| 17038 |
cursors[i].style.animationDuration = this.blinkInterval + "ms"; |
| 17039 |
this.$isAnimating = true; |
| 17040 |
setTimeout(function () { |
| 17041 |
if (this.$isAnimating) { |
| 17042 |
dom.addCssClass(this.element, "ace_animate-blinking"); |
| 17043 |
} |
| 17044 |
}.bind(this)); |
| 17045 |
}; |
| 17046 |
Cursor.prototype.$stopCssAnimation = function () { |
| 17047 |
this.$isAnimating = false; |
| 17048 |
dom.removeCssClass(this.element, "ace_animate-blinking"); |
| 17049 |
}; |
| 17050 |
Cursor.prototype.setPadding = function (padding) { |
| 17051 |
this.$padding = padding; |
| 17052 |
}; |
| 17053 |
Cursor.prototype.setSession = function (session) { |
| 17054 |
this.session = session; |
| 17055 |
}; |
| 17056 |
Cursor.prototype.setBlinking = function (blinking) { |
| 17057 |
if (blinking != this.isBlinking) { |
| 17058 |
this.isBlinking = blinking; |
| 17059 |
this.restartTimer(); |
| 17060 |
} |
| 17061 |
}; |
| 17062 |
Cursor.prototype.setBlinkInterval = function (blinkInterval) { |
| 17063 |
if (blinkInterval != this.blinkInterval) { |
| 17064 |
this.blinkInterval = blinkInterval; |
| 17065 |
this.restartTimer(); |
| 17066 |
} |
| 17067 |
}; |
| 17068 |
Cursor.prototype.setSmoothBlinking = function (smoothBlinking) { |
| 17069 |
if (smoothBlinking != this.smoothBlinking) { |
| 17070 |
this.smoothBlinking = smoothBlinking; |
| 17071 |
dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking); |
| 17072 |
this.$updateCursors(true); |
| 17073 |
this.restartTimer(); |
| 17074 |
} |
| 17075 |
}; |
| 17076 |
Cursor.prototype.addCursor = function () { |
| 17077 |
var el = dom.createElement("div"); |
| 17078 |
el.className = "ace_cursor"; |
| 17079 |
this.element.appendChild(el); |
| 17080 |
this.cursors.push(el); |
| 17081 |
return el; |
| 17082 |
}; |
| 17083 |
Cursor.prototype.removeCursor = function () { |
| 17084 |
if (this.cursors.length > 1) { |
| 17085 |
var el = this.cursors.pop(); |
| 17086 |
el.parentNode.removeChild(el); |
| 17087 |
return el; |
| 17088 |
} |
| 17089 |
}; |
| 17090 |
Cursor.prototype.hideCursor = function () { |
| 17091 |
this.isVisible = false; |
| 17092 |
dom.addCssClass(this.element, "ace_hidden-cursors"); |
| 17093 |
this.restartTimer(); |
| 17094 |
}; |
| 17095 |
Cursor.prototype.showCursor = function () { |
| 17096 |
this.isVisible = true; |
| 17097 |
dom.removeCssClass(this.element, "ace_hidden-cursors"); |
| 17098 |
this.restartTimer(); |
| 17099 |
}; |
| 17100 |
Cursor.prototype.restartTimer = function () { |
| 17101 |
var update = this.$updateCursors; |
| 17102 |
clearInterval(this.intervalId); |
| 17103 |
clearTimeout(this.timeoutId); |
| 17104 |
this.$stopCssAnimation(); |
| 17105 |
if (this.smoothBlinking) { |
| 17106 |
this.$isSmoothBlinking = false; |
| 17107 |
dom.removeCssClass(this.element, "ace_smooth-blinking"); |
| 17108 |
} |
| 17109 |
update(true); |
| 17110 |
if (!this.isBlinking || !this.blinkInterval || !this.isVisible) { |
| 17111 |
this.$stopCssAnimation(); |
| 17112 |
return; |
| 17113 |
} |
| 17114 |
if (this.smoothBlinking) { |
| 17115 |
this.$isSmoothBlinking = true; |
| 17116 |
setTimeout(function () { |
| 17117 |
if (this.$isSmoothBlinking) { |
| 17118 |
dom.addCssClass(this.element, "ace_smooth-blinking"); |
| 17119 |
} |
| 17120 |
}.bind(this)); |
| 17121 |
} |
| 17122 |
if (dom.HAS_CSS_ANIMATION) { |
| 17123 |
this.$startCssAnimation(); |
| 17124 |
} |
| 17125 |
else { |
| 17126 |
var blink = function () { |
| 17127 |
this.timeoutId = setTimeout(function () { |
| 17128 |
update(false); |
| 17129 |
}, 0.6 * this.blinkInterval); |
| 17130 |
}.bind(this); |
| 17131 |
this.intervalId = setInterval(function () { |
| 17132 |
update(true); |
| 17133 |
blink(); |
| 17134 |
}, this.blinkInterval); |
| 17135 |
blink(); |
| 17136 |
} |
| 17137 |
}; |
| 17138 |
Cursor.prototype.getPixelPosition = function (position, onScreen) { |
| 17139 |
if (!this.config || !this.session) |
| 17140 |
return { left: 0, top: 0 }; |
| 17141 |
if (!position) |
| 17142 |
position = this.session.selection.getCursor(); |
| 17143 |
var pos = this.session.documentToScreenPosition(position); |
| 17144 |
var cursorLeft = this.$padding + (this.session.$bidiHandler.isBidiRow(pos.row, position.row) |
| 17145 |
? this.session.$bidiHandler.getPosLeft(pos.column) |
| 17146 |
: pos.column * this.config.characterWidth); |
| 17147 |
var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) * |
| 17148 |
this.config.lineHeight; |
| 17149 |
return { left: cursorLeft, top: cursorTop }; |
| 17150 |
}; |
| 17151 |
Cursor.prototype.isCursorInView = function (pixelPos, config) { |
| 17152 |
return pixelPos.top >= 0 && pixelPos.top < config.maxHeight; |
| 17153 |
}; |
| 17154 |
Cursor.prototype.update = function (config) { |
| 17155 |
this.config = config; |
| 17156 |
var selections = this.session.$selectionMarkers; |
| 17157 |
var i = 0, cursorIndex = 0; |
| 17158 |
if (selections === undefined || selections.length === 0) { |
| 17159 |
selections = [{ cursor: null }]; |
| 17160 |
} |
| 17161 |
for (var i = 0, n = selections.length; i < n; i++) { |
| 17162 |
var pixelPos = this.getPixelPosition(selections[i].cursor, true); |
| 17163 |
if ((pixelPos.top > config.height + config.offset || |
| 17164 |
pixelPos.top < 0) && i > 1) { |
| 17165 |
continue; |
| 17166 |
} |
| 17167 |
var element = this.cursors[cursorIndex++] || this.addCursor(); |
| 17168 |
var style = element.style; |
| 17169 |
if (!this.drawCursor) { |
| 17170 |
if (!this.isCursorInView(pixelPos, config)) { |
| 17171 |
dom.setStyle(style, "display", "none"); |
| 17172 |
} |
| 17173 |
else { |
| 17174 |
dom.setStyle(style, "display", "block"); |
| 17175 |
dom.translate(element, pixelPos.left, pixelPos.top); |
| 17176 |
dom.setStyle(style, "width", Math.round(config.characterWidth) + "px"); |
| 17177 |
dom.setStyle(style, "height", config.lineHeight + "px"); |
| 17178 |
} |
| 17179 |
} |
| 17180 |
else { |
| 17181 |
this.drawCursor(element, pixelPos, config, selections[i], this.session); |
| 17182 |
} |
| 17183 |
} |
| 17184 |
while (this.cursors.length > cursorIndex) |
| 17185 |
this.removeCursor(); |
| 17186 |
var overwrite = this.session.getOverwrite(); |
| 17187 |
this.$setOverwrite(overwrite); |
| 17188 |
this.$pixelPos = pixelPos; |
| 17189 |
this.restartTimer(); |
| 17190 |
}; |
| 17191 |
Cursor.prototype.$setOverwrite = function (overwrite) { |
| 17192 |
if (overwrite != this.overwrite) { |
| 17193 |
this.overwrite = overwrite; |
| 17194 |
if (overwrite) |
| 17195 |
dom.addCssClass(this.element, "ace_overwrite-cursors"); |
| 17196 |
else |
| 17197 |
dom.removeCssClass(this.element, "ace_overwrite-cursors"); |
| 17198 |
} |
| 17199 |
}; |
| 17200 |
Cursor.prototype.destroy = function () { |
| 17201 |
clearInterval(this.intervalId); |
| 17202 |
clearTimeout(this.timeoutId); |
| 17203 |
}; |
| 17204 |
return Cursor; |
| 17205 |
}()); |
| 17206 |
Cursor.prototype.$padding = 0; |
| 17207 |
Cursor.prototype.drawCursor = null; |
| 17208 |
exports.Cursor = Cursor; |
| 17209 |
|
| 17210 |
}); |
| 17211 |
|
| 17212 |
ace.define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"], function(require, exports, module){"use strict"; |
| 17213 |
var __extends = (this && this.__extends) || (function () { |
| 17214 |
var extendStatics = function (d, b) { |
| 17215 |
extendStatics = Object.setPrototypeOf || |
| 17216 |
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
| 17217 |
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; |
| 17218 |
return extendStatics(d, b); |
| 17219 |
}; |
| 17220 |
return function (d, b) { |
| 17221 |
if (typeof b !== "function" && b !== null) |
| 17222 |
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); |
| 17223 |
extendStatics(d, b); |
| 17224 |
function __() { this.constructor = d; } |
| 17225 |
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
| 17226 |
}; |
| 17227 |
})(); |
| 17228 |
var oop = require("./lib/oop"); |
| 17229 |
var dom = require("./lib/dom"); |
| 17230 |
var event = require("./lib/event"); |
| 17231 |
var EventEmitter = require("./lib/event_emitter").EventEmitter; |
| 17232 |
var MAX_SCROLL_H = 0x8000; |
| 17233 |
var Scrollbar = (function () { |
| 17234 |
function Scrollbar(parent, classSuffix) { |
| 17235 |
this.element = dom.createElement("div"); |
| 17236 |
this.element.className = "ace_scrollbar ace_scrollbar" + classSuffix; |
| 17237 |
this.inner = dom.createElement("div"); |
| 17238 |
this.inner.className = "ace_scrollbar-inner"; |
| 17239 |
this.inner.textContent = "\xa0"; |
| 17240 |
this.element.appendChild(this.inner); |
| 17241 |
parent.appendChild(this.element); |
| 17242 |
this.setVisible(false); |
| 17243 |
this.skipEvent = false; |
| 17244 |
event.addListener(this.element, "scroll", this.onScroll.bind(this)); |
| 17245 |
event.addListener(this.element, "mousedown", event.preventDefault); |
| 17246 |
} |
| 17247 |
Scrollbar.prototype.setVisible = function (isVisible) { |
| 17248 |
this.element.style.display = isVisible ? "" : "none"; |
| 17249 |
this.isVisible = isVisible; |
| 17250 |
this.coeff = 1; |
| 17251 |
}; |
| 17252 |
return Scrollbar; |
| 17253 |
}()); |
| 17254 |
oop.implement(Scrollbar.prototype, EventEmitter); |
| 17255 |
var VScrollBar = (function (_super) { |
| 17256 |
__extends(VScrollBar, _super); |
| 17257 |
function VScrollBar(parent, renderer) { |
| 17258 |
var _this = _super.call(this, parent, '-v') || this; |
| 17259 |
_this.scrollTop = 0; |
| 17260 |
_this.scrollHeight = 0; |
| 17261 |
renderer.$scrollbarWidth = |
| 17262 |
_this.width = dom.scrollbarWidth(parent.ownerDocument); |
| 17263 |
_this.inner.style.width = |
| 17264 |
_this.element.style.width = (_this.width || 15) + 5 + "px"; |
| 17265 |
_this.$minWidth = 0; |
| 17266 |
return _this; |
| 17267 |
} |
| 17268 |
VScrollBar.prototype.onScroll = function () { |
| 17269 |
if (!this.skipEvent) { |
| 17270 |
this.scrollTop = this.element.scrollTop; |
| 17271 |
if (this.coeff != 1) { |
| 17272 |
var h = this.element.clientHeight / this.scrollHeight; |
| 17273 |
this.scrollTop = this.scrollTop * (1 - h) / (this.coeff - h); |
| 17274 |
} |
| 17275 |
this._emit("scroll", { data: this.scrollTop }); |
| 17276 |
} |
| 17277 |
this.skipEvent = false; |
| 17278 |
}; |
| 17279 |
VScrollBar.prototype.getWidth = function () { |
| 17280 |
return Math.max(this.isVisible ? this.width : 0, this.$minWidth || 0); |
| 17281 |
}; |
| 17282 |
VScrollBar.prototype.setHeight = function (height) { |
| 17283 |
this.element.style.height = height + "px"; |
| 17284 |
}; |
| 17285 |
VScrollBar.prototype.setScrollHeight = function (height) { |
| 17286 |
this.scrollHeight = height; |
| 17287 |
if (height > MAX_SCROLL_H) { |
| 17288 |
this.coeff = MAX_SCROLL_H / height; |
| 17289 |
height = MAX_SCROLL_H; |
| 17290 |
} |
| 17291 |
else if (this.coeff != 1) { |
| 17292 |
this.coeff = 1; |
| 17293 |
} |
| 17294 |
this.inner.style.height = height + "px"; |
| 17295 |
}; |
| 17296 |
VScrollBar.prototype.setScrollTop = function (scrollTop) { |
| 17297 |
if (this.scrollTop != scrollTop) { |
| 17298 |
this.skipEvent = true; |
| 17299 |
this.scrollTop = scrollTop; |
| 17300 |
this.element.scrollTop = scrollTop * this.coeff; |
| 17301 |
} |
| 17302 |
}; |
| 17303 |
return VScrollBar; |
| 17304 |
}(Scrollbar)); |
| 17305 |
VScrollBar.prototype.setInnerHeight = VScrollBar.prototype.setScrollHeight; |
| 17306 |
var HScrollBar = (function (_super) { |
| 17307 |
__extends(HScrollBar, _super); |
| 17308 |
function HScrollBar(parent, renderer) { |
| 17309 |
var _this = _super.call(this, parent, '-h') || this; |
| 17310 |
_this.scrollLeft = 0; |
| 17311 |
_this.height = renderer.$scrollbarWidth; |
| 17312 |
_this.inner.style.height = |
| 17313 |
_this.element.style.height = (_this.height || 15) + 5 + "px"; |
| 17314 |
return _this; |
| 17315 |
} |
| 17316 |
HScrollBar.prototype.onScroll = function () { |
| 17317 |
if (!this.skipEvent) { |
| 17318 |
this.scrollLeft = this.element.scrollLeft; |
| 17319 |
this._emit("scroll", { data: this.scrollLeft }); |
| 17320 |
} |
| 17321 |
this.skipEvent = false; |
| 17322 |
}; |
| 17323 |
HScrollBar.prototype.getHeight = function () { |
| 17324 |
return this.isVisible ? this.height : 0; |
| 17325 |
}; |
| 17326 |
HScrollBar.prototype.setWidth = function (width) { |
| 17327 |
this.element.style.width = width + "px"; |
| 17328 |
}; |
| 17329 |
HScrollBar.prototype.setInnerWidth = function (width) { |
| 17330 |
this.inner.style.width = width + "px"; |
| 17331 |
}; |
| 17332 |
HScrollBar.prototype.setScrollWidth = function (width) { |
| 17333 |
this.inner.style.width = width + "px"; |
| 17334 |
}; |
| 17335 |
HScrollBar.prototype.setScrollLeft = function (scrollLeft) { |
| 17336 |
if (this.scrollLeft != scrollLeft) { |
| 17337 |
this.skipEvent = true; |
| 17338 |
this.scrollLeft = this.element.scrollLeft = scrollLeft; |
| 17339 |
} |
| 17340 |
}; |
| 17341 |
return HScrollBar; |
| 17342 |
}(Scrollbar)); |
| 17343 |
exports.ScrollBar = VScrollBar; |
| 17344 |
exports.ScrollBarV = VScrollBar; |
| 17345 |
exports.ScrollBarH = HScrollBar; |
| 17346 |
exports.VScrollBar = VScrollBar; |
| 17347 |
exports.HScrollBar = HScrollBar; |
| 17348 |
|
| 17349 |
}); |
| 17350 |
|
| 17351 |
ace.define("ace/scrollbar_custom",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"], function(require, exports, module){"use strict"; |
| 17352 |
var __extends = (this && this.__extends) || (function () { |
| 17353 |
var extendStatics = function (d, b) { |
| 17354 |
extendStatics = Object.setPrototypeOf || |
| 17355 |
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
| 17356 |
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; |
| 17357 |
return extendStatics(d, b); |
| 17358 |
}; |
| 17359 |
return function (d, b) { |
| 17360 |
if (typeof b !== "function" && b !== null) |
| 17361 |
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); |
| 17362 |
extendStatics(d, b); |
| 17363 |
function __() { this.constructor = d; } |
| 17364 |
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
| 17365 |
}; |
| 17366 |
})(); |
| 17367 |
var oop = require("./lib/oop"); |
| 17368 |
var dom = require("./lib/dom"); |
| 17369 |
var event = require("./lib/event"); |
| 17370 |
var EventEmitter = require("./lib/event_emitter").EventEmitter; |
| 17371 |
dom.importCssString(".ace_editor>.ace_sb-v div, .ace_editor>.ace_sb-h div{\n position: absolute;\n background: rgba(128, 128, 128, 0.6);\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n border: 1px solid #bbb;\n border-radius: 2px;\n z-index: 8;\n}\n.ace_editor>.ace_sb-v, .ace_editor>.ace_sb-h {\n position: absolute;\n z-index: 6;\n background: none;\n overflow: hidden!important;\n}\n.ace_editor>.ace_sb-v {\n z-index: 6;\n right: 0;\n top: 0;\n width: 12px;\n}\n.ace_editor>.ace_sb-v div {\n z-index: 8;\n right: 0;\n width: 100%;\n}\n.ace_editor>.ace_sb-h {\n bottom: 0;\n left: 0;\n height: 12px;\n}\n.ace_editor>.ace_sb-h div {\n bottom: 0;\n height: 100%;\n}\n.ace_editor>.ace_sb_grabbed {\n z-index: 8;\n background: #000;\n}", "ace_scrollbar.css", false); |
| 17372 |
var ScrollBar = (function () { |
| 17373 |
function ScrollBar(parent, classSuffix) { |
| 17374 |
this.element = dom.createElement("div"); |
| 17375 |
this.element.className = "ace_sb" + classSuffix; |
| 17376 |
this.inner = dom.createElement("div"); |
| 17377 |
this.inner.className = ""; |
| 17378 |
this.element.appendChild(this.inner); |
| 17379 |
this.VScrollWidth = 12; |
| 17380 |
this.HScrollHeight = 12; |
| 17381 |
parent.appendChild(this.element); |
| 17382 |
this.setVisible(false); |
| 17383 |
this.skipEvent = false; |
| 17384 |
event.addMultiMouseDownListener(this.element, [500, 300, 300], this, "onMouseDown"); |
| 17385 |
} |
| 17386 |
ScrollBar.prototype.setVisible = function (isVisible) { |
| 17387 |
this.element.style.display = isVisible ? "" : "none"; |
| 17388 |
this.isVisible = isVisible; |
| 17389 |
this.coeff = 1; |
| 17390 |
}; |
| 17391 |
return ScrollBar; |
| 17392 |
}()); |
| 17393 |
oop.implement(ScrollBar.prototype, EventEmitter); |
| 17394 |
var VScrollBar = (function (_super) { |
| 17395 |
__extends(VScrollBar, _super); |
| 17396 |
function VScrollBar(parent, renderer) { |
| 17397 |
var _this = _super.call(this, parent, '-v') || this; |
| 17398 |
_this.scrollTop = 0; |
| 17399 |
_this.scrollHeight = 0; |
| 17400 |
_this.parent = parent; |
| 17401 |
_this.width = _this.VScrollWidth; |
| 17402 |
_this.renderer = renderer; |
| 17403 |
_this.inner.style.width = _this.element.style.width = (_this.width || 15) + "px"; |
| 17404 |
_this.$minWidth = 0; |
| 17405 |
return _this; |
| 17406 |
} |
| 17407 |
VScrollBar.prototype.onMouseDown = function (eType, e) { |
| 17408 |
if (eType !== "mousedown") |
| 17409 |
return; |
| 17410 |
if (event.getButton(e) !== 0 || e.detail === 2) { |
| 17411 |
return; |
| 17412 |
} |
| 17413 |
if (e.target === this.inner) { |
| 17414 |
var self = this; |
| 17415 |
var mousePageY = e.clientY; |
| 17416 |
var onMouseMove = function (e) { |
| 17417 |
mousePageY = e.clientY; |
| 17418 |
}; |
| 17419 |
var onMouseUp = function () { |
| 17420 |
clearInterval(timerId); |
| 17421 |
}; |
| 17422 |
var startY = e.clientY; |
| 17423 |
var startTop = this.thumbTop; |
| 17424 |
var onScrollInterval = function () { |
| 17425 |
if (mousePageY === undefined) |
| 17426 |
return; |
| 17427 |
var scrollTop = self.scrollTopFromThumbTop(startTop + mousePageY - startY); |
| 17428 |
if (scrollTop === self.scrollTop) |
| 17429 |
return; |
| 17430 |
self._emit("scroll", { data: scrollTop }); |
| 17431 |
}; |
| 17432 |
event.capture(this.inner, onMouseMove, onMouseUp); |
| 17433 |
var timerId = setInterval(onScrollInterval, 20); |
| 17434 |
return event.preventDefault(e); |
| 17435 |
} |
| 17436 |
var top = e.clientY - this.element.getBoundingClientRect().top - this.thumbHeight / 2; |
| 17437 |
this._emit("scroll", { data: this.scrollTopFromThumbTop(top) }); |
| 17438 |
return event.preventDefault(e); |
| 17439 |
}; |
| 17440 |
VScrollBar.prototype.getHeight = function () { |
| 17441 |
return this.height; |
| 17442 |
}; |
| 17443 |
VScrollBar.prototype.scrollTopFromThumbTop = function (thumbTop) { |
| 17444 |
var scrollTop = thumbTop * (this.pageHeight - this.viewHeight) / (this.slideHeight - this.thumbHeight); |
| 17445 |
scrollTop = scrollTop >> 0; |
| 17446 |
if (scrollTop < 0) { |
| 17447 |
scrollTop = 0; |
| 17448 |
} |
| 17449 |
else if (scrollTop > this.pageHeight - this.viewHeight) { |
| 17450 |
scrollTop = this.pageHeight - this.viewHeight; |
| 17451 |
} |
| 17452 |
return scrollTop; |
| 17453 |
}; |
| 17454 |
VScrollBar.prototype.getWidth = function () { |
| 17455 |
return Math.max(this.isVisible ? this.width : 0, this.$minWidth || 0); |
| 17456 |
}; |
| 17457 |
VScrollBar.prototype.setHeight = function (height) { |
| 17458 |
this.height = Math.max(0, height); |
| 17459 |
this.slideHeight = this.height; |
| 17460 |
this.viewHeight = this.height; |
| 17461 |
this.setScrollHeight(this.pageHeight, true); |
| 17462 |
}; |
| 17463 |
VScrollBar.prototype.setScrollHeight = function (height, force) { |
| 17464 |
if (this.pageHeight === height && !force) |
| 17465 |
return; |
| 17466 |
this.pageHeight = height; |
| 17467 |
this.thumbHeight = this.slideHeight * this.viewHeight / this.pageHeight; |
| 17468 |
if (this.thumbHeight > this.slideHeight) |
| 17469 |
this.thumbHeight = this.slideHeight; |
| 17470 |
if (this.thumbHeight < 15) |
| 17471 |
this.thumbHeight = 15; |
| 17472 |
this.inner.style.height = this.thumbHeight + "px"; |
| 17473 |
if (this.scrollTop > (this.pageHeight - this.viewHeight)) { |
| 17474 |
this.scrollTop = (this.pageHeight - this.viewHeight); |
| 17475 |
if (this.scrollTop < 0) |
| 17476 |
this.scrollTop = 0; |
| 17477 |
this._emit("scroll", { data: this.scrollTop }); |
| 17478 |
} |
| 17479 |
}; |
| 17480 |
VScrollBar.prototype.setScrollTop = function (scrollTop) { |
| 17481 |
this.scrollTop = scrollTop; |
| 17482 |
if (scrollTop < 0) |
| 17483 |
scrollTop = 0; |
| 17484 |
this.thumbTop = scrollTop * (this.slideHeight - this.thumbHeight) / (this.pageHeight - this.viewHeight); |
| 17485 |
this.inner.style.top = this.thumbTop + "px"; |
| 17486 |
}; |
| 17487 |
return VScrollBar; |
| 17488 |
}(ScrollBar)); |
| 17489 |
VScrollBar.prototype.setInnerHeight = VScrollBar.prototype.setScrollHeight; |
| 17490 |
var HScrollBar = (function (_super) { |
| 17491 |
__extends(HScrollBar, _super); |
| 17492 |
function HScrollBar(parent, renderer) { |
| 17493 |
var _this = _super.call(this, parent, '-h') || this; |
| 17494 |
_this.scrollLeft = 0; |
| 17495 |
_this.scrollWidth = 0; |
| 17496 |
_this.height = _this.HScrollHeight; |
| 17497 |
_this.inner.style.height = _this.element.style.height = (_this.height || 12) + "px"; |
| 17498 |
_this.renderer = renderer; |
| 17499 |
return _this; |
| 17500 |
} |
| 17501 |
HScrollBar.prototype.onMouseDown = function (eType, e) { |
| 17502 |
if (eType !== "mousedown") |
| 17503 |
return; |
| 17504 |
if (event.getButton(e) !== 0 || e.detail === 2) { |
| 17505 |
return; |
| 17506 |
} |
| 17507 |
if (e.target === this.inner) { |
| 17508 |
var self = this; |
| 17509 |
var mousePageX = e.clientX; |
| 17510 |
var onMouseMove = function (e) { |
| 17511 |
mousePageX = e.clientX; |
| 17512 |
}; |
| 17513 |
var onMouseUp = function () { |
| 17514 |
clearInterval(timerId); |
| 17515 |
}; |
| 17516 |
var startX = e.clientX; |
| 17517 |
var startLeft = this.thumbLeft; |
| 17518 |
var onScrollInterval = function () { |
| 17519 |
if (mousePageX === undefined) |
| 17520 |
return; |
| 17521 |
var scrollLeft = self.scrollLeftFromThumbLeft(startLeft + mousePageX - startX); |
| 17522 |
if (scrollLeft === self.scrollLeft) |
| 17523 |
return; |
| 17524 |
self._emit("scroll", { data: scrollLeft }); |
| 17525 |
}; |
| 17526 |
event.capture(this.inner, onMouseMove, onMouseUp); |
| 17527 |
var timerId = setInterval(onScrollInterval, 20); |
| 17528 |
return event.preventDefault(e); |
| 17529 |
} |
| 17530 |
var left = e.clientX - this.element.getBoundingClientRect().left - this.thumbWidth / 2; |
| 17531 |
this._emit("scroll", { data: this.scrollLeftFromThumbLeft(left) }); |
| 17532 |
return event.preventDefault(e); |
| 17533 |
}; |
| 17534 |
HScrollBar.prototype.getHeight = function () { |
| 17535 |
return this.isVisible ? this.height : 0; |
| 17536 |
}; |
| 17537 |
HScrollBar.prototype.scrollLeftFromThumbLeft = function (thumbLeft) { |
| 17538 |
var scrollLeft = thumbLeft * (this.pageWidth - this.viewWidth) / (this.slideWidth - this.thumbWidth); |
| 17539 |
scrollLeft = scrollLeft >> 0; |
| 17540 |
if (scrollLeft < 0) { |
| 17541 |
scrollLeft = 0; |
| 17542 |
} |
| 17543 |
else if (scrollLeft > this.pageWidth - this.viewWidth) { |
| 17544 |
scrollLeft = this.pageWidth - this.viewWidth; |
| 17545 |
} |
| 17546 |
return scrollLeft; |
| 17547 |
}; |
| 17548 |
HScrollBar.prototype.setWidth = function (width) { |
| 17549 |
this.width = Math.max(0, width); |
| 17550 |
this.element.style.width = this.width + "px"; |
| 17551 |
this.slideWidth = this.width; |
| 17552 |
this.viewWidth = this.width; |
| 17553 |
this.setScrollWidth(this.pageWidth, true); |
| 17554 |
}; |
| 17555 |
HScrollBar.prototype.setScrollWidth = function (width, force) { |
| 17556 |
if (this.pageWidth === width && !force) |
| 17557 |
return; |
| 17558 |
this.pageWidth = width; |
| 17559 |
this.thumbWidth = this.slideWidth * this.viewWidth / this.pageWidth; |
| 17560 |
if (this.thumbWidth > this.slideWidth) |
| 17561 |
this.thumbWidth = this.slideWidth; |
| 17562 |
if (this.thumbWidth < 15) |
| 17563 |
this.thumbWidth = 15; |
| 17564 |
this.inner.style.width = this.thumbWidth + "px"; |
| 17565 |
if (this.scrollLeft > (this.pageWidth - this.viewWidth)) { |
| 17566 |
this.scrollLeft = (this.pageWidth - this.viewWidth); |
| 17567 |
if (this.scrollLeft < 0) |
| 17568 |
this.scrollLeft = 0; |
| 17569 |
this._emit("scroll", { data: this.scrollLeft }); |
| 17570 |
} |
| 17571 |
}; |
| 17572 |
HScrollBar.prototype.setScrollLeft = function (scrollLeft) { |
| 17573 |
this.scrollLeft = scrollLeft; |
| 17574 |
if (scrollLeft < 0) |
| 17575 |
scrollLeft = 0; |
| 17576 |
this.thumbLeft = scrollLeft * (this.slideWidth - this.thumbWidth) / (this.pageWidth - this.viewWidth); |
| 17577 |
this.inner.style.left = (this.thumbLeft) + "px"; |
| 17578 |
}; |
| 17579 |
return HScrollBar; |
| 17580 |
}(ScrollBar)); |
| 17581 |
HScrollBar.prototype.setInnerWidth = HScrollBar.prototype.setScrollWidth; |
| 17582 |
exports.ScrollBar = VScrollBar; |
| 17583 |
exports.ScrollBarV = VScrollBar; |
| 17584 |
exports.ScrollBarH = HScrollBar; |
| 17585 |
exports.VScrollBar = VScrollBar; |
| 17586 |
exports.HScrollBar = HScrollBar; |
| 17587 |
|
| 17588 |
}); |
| 17589 |
|
| 17590 |
ace.define("ace/renderloop",["require","exports","module","ace/lib/event"], function(require, exports, module){"use strict"; |
| 17591 |
var event = require("./lib/event"); |
| 17592 |
var RenderLoop = (function () { |
| 17593 |
function RenderLoop(onRender, win) { |
| 17594 |
this.onRender = onRender; |
| 17595 |
this.pending = false; |
| 17596 |
this.changes = 0; |
| 17597 |
this.$recursionLimit = 2; |
| 17598 |
this.window = win || window; |
| 17599 |
var _self = this; |
| 17600 |
this._flush = function (ts) { |
| 17601 |
_self.pending = false; |
| 17602 |
var changes = _self.changes; |
| 17603 |
if (changes) { |
| 17604 |
event.blockIdle(100); |
| 17605 |
_self.changes = 0; |
| 17606 |
_self.onRender(changes); |
| 17607 |
} |
| 17608 |
if (_self.changes) { |
| 17609 |
if (_self.$recursionLimit-- < 0) |
| 17610 |
return; |
| 17611 |
_self.schedule(); |
| 17612 |
} |
| 17613 |
else { |
| 17614 |
_self.$recursionLimit = 2; |
| 17615 |
} |
| 17616 |
}; |
| 17617 |
} |
| 17618 |
RenderLoop.prototype.schedule = function (change) { |
| 17619 |
this.changes = this.changes | change; |
| 17620 |
if (this.changes && !this.pending) { |
| 17621 |
event.nextFrame(this._flush); |
| 17622 |
this.pending = true; |
| 17623 |
} |
| 17624 |
}; |
| 17625 |
RenderLoop.prototype.clear = function (change) { |
| 17626 |
var changes = this.changes; |
| 17627 |
this.changes = 0; |
| 17628 |
return changes; |
| 17629 |
}; |
| 17630 |
return RenderLoop; |
| 17631 |
}()); |
| 17632 |
exports.RenderLoop = RenderLoop; |
| 17633 |
|
| 17634 |
}); |
| 17635 |
|
| 17636 |
ace.define("ace/layer/font_metrics",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/event","ace/lib/useragent","ace/lib/event_emitter"], function(require, exports, module){var oop = require("../lib/oop"); |
| 17637 |
var dom = require("../lib/dom"); |
| 17638 |
var lang = require("../lib/lang"); |
| 17639 |
var event = require("../lib/event"); |
| 17640 |
var useragent = require("../lib/useragent"); |
| 17641 |
var EventEmitter = require("../lib/event_emitter").EventEmitter; |
| 17642 |
var CHAR_COUNT = 512; |
| 17643 |
var USE_OBSERVER = typeof ResizeObserver == "function"; |
| 17644 |
var L = 200; |
| 17645 |
var FontMetrics = (function () { |
| 17646 |
function FontMetrics(parentEl) { |
| 17647 |
this.el = dom.createElement("div"); |
| 17648 |
this.$setMeasureNodeStyles(this.el.style, true); |
| 17649 |
this.$main = dom.createElement("div"); |
| 17650 |
this.$setMeasureNodeStyles(this.$main.style); |
| 17651 |
this.$measureNode = dom.createElement("div"); |
| 17652 |
this.$setMeasureNodeStyles(this.$measureNode.style); |
| 17653 |
this.el.appendChild(this.$main); |
| 17654 |
this.el.appendChild(this.$measureNode); |
| 17655 |
parentEl.appendChild(this.el); |
| 17656 |
this.$measureNode.textContent = lang.stringRepeat("X", CHAR_COUNT); |
| 17657 |
this.$characterSize = { width: 0, height: 0 }; |
| 17658 |
if (USE_OBSERVER) |
| 17659 |
this.$addObserver(); |
| 17660 |
else |
| 17661 |
this.checkForSizeChanges(); |
| 17662 |
} |
| 17663 |
FontMetrics.prototype.$setMeasureNodeStyles = function (style, isRoot) { |
| 17664 |
style.width = style.height = "auto"; |
| 17665 |
style.left = style.top = "0px"; |
| 17666 |
style.visibility = "hidden"; |
| 17667 |
style.position = "absolute"; |
| 17668 |
style.whiteSpace = "pre"; |
| 17669 |
if (useragent.isIE < 8) { |
| 17670 |
style["font-family"] = "inherit"; |
| 17671 |
} |
| 17672 |
else { |
| 17673 |
style.font = "inherit"; |
| 17674 |
} |
| 17675 |
style.overflow = isRoot ? "hidden" : "visible"; |
| 17676 |
}; |
| 17677 |
FontMetrics.prototype.checkForSizeChanges = function (size) { |
| 17678 |
if (size === undefined) |
| 17679 |
size = this.$measureSizes(); |
| 17680 |
if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) { |
| 17681 |
this.$measureNode.style.fontWeight = "bold"; |
| 17682 |
var boldSize = this.$measureSizes(); |
| 17683 |
this.$measureNode.style.fontWeight = ""; |
| 17684 |
this.$characterSize = size; |
| 17685 |
this.charSizes = Object.create(null); |
| 17686 |
this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height; |
| 17687 |
this._emit("changeCharacterSize", { data: size }); |
| 17688 |
} |
| 17689 |
}; |
| 17690 |
FontMetrics.prototype.$addObserver = function () { |
| 17691 |
var self = this; |
| 17692 |
this.$observer = new window.ResizeObserver(function (e) { |
| 17693 |
self.checkForSizeChanges(); |
| 17694 |
}); |
| 17695 |
this.$observer.observe(this.$measureNode); |
| 17696 |
}; |
| 17697 |
FontMetrics.prototype.$pollSizeChanges = function () { |
| 17698 |
if (this.$pollSizeChangesTimer || this.$observer) |
| 17699 |
return this.$pollSizeChangesTimer; |
| 17700 |
var self = this; |
| 17701 |
return this.$pollSizeChangesTimer = event.onIdle(function cb() { |
| 17702 |
self.checkForSizeChanges(); |
| 17703 |
event.onIdle(cb, 500); |
| 17704 |
}, 500); |
| 17705 |
}; |
| 17706 |
FontMetrics.prototype.setPolling = function (val) { |
| 17707 |
if (val) { |
| 17708 |
this.$pollSizeChanges(); |
| 17709 |
} |
| 17710 |
else if (this.$pollSizeChangesTimer) { |
| 17711 |
clearInterval(this.$pollSizeChangesTimer); |
| 17712 |
this.$pollSizeChangesTimer = 0; |
| 17713 |
} |
| 17714 |
}; |
| 17715 |
FontMetrics.prototype.$measureSizes = function (node) { |
| 17716 |
var size = { |
| 17717 |
height: (node || this.$measureNode).clientHeight, |
| 17718 |
width: (node || this.$measureNode).clientWidth / CHAR_COUNT |
| 17719 |
}; |
| 17720 |
if (size.width === 0 || size.height === 0) |
| 17721 |
return null; |
| 17722 |
return size; |
| 17723 |
}; |
| 17724 |
FontMetrics.prototype.$measureCharWidth = function (ch) { |
| 17725 |
this.$main.textContent = lang.stringRepeat(ch, CHAR_COUNT); |
| 17726 |
var rect = this.$main.getBoundingClientRect(); |
| 17727 |
return rect.width / CHAR_COUNT; |
| 17728 |
}; |
| 17729 |
FontMetrics.prototype.getCharacterWidth = function (ch) { |
| 17730 |
var w = this.charSizes[ch]; |
| 17731 |
if (w === undefined) { |
| 17732 |
w = this.charSizes[ch] = this.$measureCharWidth(ch) / this.$characterSize.width; |
| 17733 |
} |
| 17734 |
return w; |
| 17735 |
}; |
| 17736 |
FontMetrics.prototype.destroy = function () { |
| 17737 |
clearInterval(this.$pollSizeChangesTimer); |
| 17738 |
if (this.$observer) |
| 17739 |
this.$observer.disconnect(); |
| 17740 |
if (this.el && this.el.parentNode) |
| 17741 |
this.el.parentNode.removeChild(this.el); |
| 17742 |
}; |
| 17743 |
FontMetrics.prototype.$getZoom = function (element) { |
| 17744 |
if (!element || !element.parentElement) |
| 17745 |
return 1; |
| 17746 |
return (window.getComputedStyle(element)["zoom"] || 1) * this.$getZoom(element.parentElement); |
| 17747 |
}; |
| 17748 |
FontMetrics.prototype.$initTransformMeasureNodes = function () { |
| 17749 |
var t = function (t, l) { |
| 17750 |
return ["div", { |
| 17751 |
style: "position: absolute;top:" + t + "px;left:" + l + "px;" |
| 17752 |
}]; |
| 17753 |
}; |
| 17754 |
this.els = dom.buildDom([t(0, 0), t(L, 0), t(0, L), t(L, L)], this.el); |
| 17755 |
}; |
| 17756 |
FontMetrics.prototype.transformCoordinates = function (clientPos, elPos) { |
| 17757 |
if (clientPos) { |
| 17758 |
var zoom = this.$getZoom(this.el); |
| 17759 |
clientPos = mul(1 / zoom, clientPos); |
| 17760 |
} |
| 17761 |
function solve(l1, l2, r) { |
| 17762 |
var det = l1[1] * l2[0] - l1[0] * l2[1]; |
| 17763 |
return [ |
| 17764 |
(-l2[1] * r[0] + l2[0] * r[1]) / det, |
| 17765 |
(+l1[1] * r[0] - l1[0] * r[1]) / det |
| 17766 |
]; |
| 17767 |
} |
| 17768 |
function sub(a, b) { return [a[0] - b[0], a[1] - b[1]]; } |
| 17769 |
function add(a, b) { return [a[0] + b[0], a[1] + b[1]]; } |
| 17770 |
function mul(a, b) { return [a * b[0], a * b[1]]; } |
| 17771 |
if (!this.els) |
| 17772 |
this.$initTransformMeasureNodes(); |
| 17773 |
function p(el) { |
| 17774 |
var r = el.getBoundingClientRect(); |
| 17775 |
return [r.left, r.top]; |
| 17776 |
} |
| 17777 |
var a = p(this.els[0]); |
| 17778 |
var b = p(this.els[1]); |
| 17779 |
var c = p(this.els[2]); |
| 17780 |
var d = p(this.els[3]); |
| 17781 |
var h = solve(sub(d, b), sub(d, c), sub(add(b, c), add(d, a))); |
| 17782 |
var m1 = mul(1 + h[0], sub(b, a)); |
| 17783 |
var m2 = mul(1 + h[1], sub(c, a)); |
| 17784 |
if (elPos) { |
| 17785 |
var x = elPos; |
| 17786 |
var k = h[0] * x[0] / L + h[1] * x[1] / L + 1; |
| 17787 |
var ut = add(mul(x[0], m1), mul(x[1], m2)); |
| 17788 |
return add(mul(1 / k / L, ut), a); |
| 17789 |
} |
| 17790 |
var u = sub(clientPos, a); |
| 17791 |
var f = solve(sub(m1, mul(h[0], u)), sub(m2, mul(h[1], u)), u); |
| 17792 |
return mul(L, f); |
| 17793 |
}; |
| 17794 |
return FontMetrics; |
| 17795 |
}()); |
| 17796 |
FontMetrics.prototype.$characterSize = { width: 0, height: 0 }; |
| 17797 |
oop.implement(FontMetrics.prototype, EventEmitter); |
| 17798 |
exports.FontMetrics = FontMetrics; |
| 17799 |
|
| 17800 |
}); |
| 17801 |
|
| 17802 |
ace.define("ace/css/editor-css",["require","exports","module"], function(require, exports, module){ |
| 17803 |
|
| 17804 |
|
| 17805 |
|
| 17806 |
|
| 17807 |
|
| 17808 |
|
| 17809 |
|
| 17810 |
|
| 17811 |
|
| 17812 |
|
| 17813 |
module.exports = "\n.ace_br1 {border-top-left-radius : 3px;}\n.ace_br2 {border-top-right-radius : 3px;}\n.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}\n.ace_br4 {border-bottom-right-radius: 3px;}\n.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}\n.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}\n.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}\n.ace_br8 {border-bottom-left-radius : 3px;}\n.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}\n.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}\n.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\n\n\n.ace_editor {\n position: relative;\n overflow: hidden;\n padding: 0;\n font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Source Code Pro', 'source-code-pro', monospace;\n direction: ltr;\n text-align: left;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n}\n\n.ace_scroller {\n position: absolute;\n overflow: hidden;\n top: 0;\n bottom: 0;\n background-color: inherit;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n cursor: text;\n}\n\n.ace_content {\n position: absolute;\n box-sizing: border-box;\n min-width: 100%;\n contain: style size layout;\n font-variant-ligatures: no-common-ligatures;\n}\n\n.ace_keyboard-focus:focus {\n box-shadow: inset 0 0 0 2px #5E9ED6;\n outline: none;\n}\n\n.ace_dragging .ace_scroller:before{\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n content: '';\n background: rgba(250, 250, 250, 0.01);\n z-index: 1000;\n}\n.ace_dragging.ace_dark .ace_scroller:before{\n background: rgba(0, 0, 0, 0.01);\n}\n\n.ace_gutter {\n position: absolute;\n overflow : hidden;\n width: auto;\n top: 0;\n bottom: 0;\n left: 0;\n cursor: default;\n z-index: 4;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n contain: style size layout;\n}\n\n.ace_gutter-active-line {\n position: absolute;\n left: 0;\n right: 0;\n}\n\n.ace_scroller.ace_scroll-left:after {\n content: \"\";\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\n pointer-events: none;\n}\n\n.ace_gutter-cell, .ace_gutter-cell_svg-icons {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n padding-left: 19px;\n padding-right: 6px;\n background-repeat: no-repeat;\n}\n\n.ace_gutter-cell_svg-icons .ace_gutter_annotation {\n margin-left: -14px;\n float: left;\n}\n\n.ace_gutter-cell .ace_gutter_annotation {\n margin-left: -19px;\n float: left;\n}\n\n.ace_gutter-cell.ace_error, .ace_icon.ace_error, .ace_icon.ace_error_fold {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==\");\n background-repeat: no-repeat;\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_warning, .ace_icon.ace_warning, .ace_icon.ace_warning_fold {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==\");\n background-repeat: no-repeat;\n background-position: 2px center;\n}\n\n.ace_gutter-cell.ace_info, .ace_icon.ace_info {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\n background-repeat: no-repeat;\n background-position: 2px center;\n}\n.ace_dark .ace_gutter-cell.ace_info, .ace_dark .ace_icon.ace_info {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\n}\n\n.ace_icon_svg.ace_error {\n -webkit-mask-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAxNiI+CjxnIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlPSJyZWQiIHNoYXBlLXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIj4KPGNpcmNsZSBmaWxsPSJub25lIiBjeD0iOCIgY3k9IjgiIHI9IjciIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPGxpbmUgeDE9IjExIiB5MT0iNSIgeDI9IjUiIHkyPSIxMSIvPgo8bGluZSB4MT0iMTEiIHkxPSIxMSIgeDI9IjUiIHkyPSI1Ii8+CjwvZz4KPC9zdmc+\");\n background-color: crimson;\n}\n.ace_icon_svg.ace_warning {\n -webkit-mask-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAxNiI+CjxnIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlPSJkYXJrb3JhbmdlIiBzaGFwZS1yZW5kZXJpbmc9Imdlb21ldHJpY1ByZWNpc2lvbiI+Cjxwb2x5Z29uIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGZpbGw9Im5vbmUiIHBvaW50cz0iOCAxIDE1IDE1IDEgMTUgOCAxIi8+CjxyZWN0IHg9IjgiIHk9IjEyIiB3aWR0aD0iMC4wMSIgaGVpZ2h0PSIwLjAxIi8+CjxsaW5lIHgxPSI4IiB5MT0iNiIgeDI9IjgiIHkyPSIxMCIvPgo8L2c+Cjwvc3ZnPg==\");\n background-color: darkorange;\n}\n.ace_icon_svg.ace_info {\n -webkit-mask-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAxNiI+CjxnIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlPSJibHVlIiBzaGFwZS1yZW5kZXJpbmc9Imdlb21ldHJpY1ByZWNpc2lvbiI+CjxjaXJjbGUgZmlsbD0ibm9uZSIgY3g9IjgiIGN5PSI4IiByPSI3IiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjxwb2x5bGluZSBwb2ludHM9IjggMTEgOCA4Ii8+Cjxwb2x5bGluZSBwb2ludHM9IjkgOCA2IDgiLz4KPGxpbmUgeDE9IjEwIiB5MT0iMTEiIHgyPSI2IiB5Mj0iMTEiLz4KPHJlY3QgeD0iOCIgeT0iNSIgd2lkdGg9IjAuMDEiIGhlaWdodD0iMC4wMSIvPgo8L2c+Cjwvc3ZnPg==\");\n background-color: royalblue;\n}\n\n.ace_icon_svg.ace_error_fold {\n -webkit-mask-image: url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMCAxNiIgZmlsbD0ibm9uZSI+CiAgPHBhdGggZD0ibSAxOC45Mjk4NTEsNy44Mjk4MDc2IGMgMC4xNDYzNTMsNi4zMzc0NjA0IC02LjMyMzE0Nyw3Ljc3Nzg0NDQgLTcuNDc3OTEyLDcuNzc3ODQ0NCAtMi4xMDcyNzI2LC0wLjEyODc1IDUuMTE3Njc4LDAuMzU2MjQ5IDUuMDUxNjk4LC03Ljg3MDA2MTggLTAuNjA0NjcyLC04LjAwMzk3MzQ5IC03LjA3NzI3MDYsLTcuNTYzMTE4OSAtNC44NTczLC03LjQzMDM5NTU2IDEuNjA2LC0wLjExNTE0MjI1IDYuODk3NDg1LDEuMjYyNTQ1OTYgNy4yODM1MTQsNy41MjI2MTI5NiB6IiBmaWxsPSJjcmltc29uIiBzdHJva2Utd2lkdGg9IjIiLz4KICA8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0ibSA4LjExNDc1NjIsMi4wNTI5ODI4IGMgMy4zNDkxNjk4LDAgNi4wNjQxMzI4LDIuNjc2ODYyNyA2LjA2NDEzMjgsNS45Nzg5NTMgMCwzLjMwMjExMjIgLTIuNzE0OTYzLDUuOTc4OTIwMiAtNi4wNjQxMzI4LDUuOTc4OTIwMiAtMy4zNDkxNDczLDAgLTYuMDY0MTc3MiwtMi42NzY4MDggLTYuMDY0MTc3MiwtNS45Nzg5MjAyIDAuMDA1MzksLTMuMjk5ODg2MSAyLjcxNzI2NTYsLTUuOTczNjQwOCA2LjA2NDE3NzIsLTUuOTc4OTUzIHogbSAwLC0xLjczNTgyNzE5IGMgLTQuMzIxNDgzNiwwIC03LjgyNDc0MDM4LDMuNDU0MDE4NDkgLTcuODI0NzQwMzgsNy43MTQ3ODAxOSAwLDQuMjYwNzI4MiAzLjUwMzI1Njc4LDcuNzE0NzQ1MiA3LjgyNDc0MDM4LDcuNzE0NzQ1MiA0LjMyMTQ0OTgsMCA3LjgyNDY5OTgsLTMuNDU0MDE3IDcuODI0Njk5OCwtNy43MTQ3NDUyIDAsLTIuMDQ2MDkxNCAtMC44MjQzOTIsLTQuMDA4MzY3MiAtMi4yOTE3NTYsLTUuNDU1MTc0NiBDIDEyLjE4MDIyNSwxLjEyOTk2NDggMTAuMTkwMDEzLDAuMzE3MTU1NjEgOC4xMTQ3NTYyLDAuMzE3MTU1NjEgWiBNIDYuOTM3NDU2Myw4LjI0MDU5ODUgNC42NzE4Njg1LDEwLjQ4NTg1MiA2LjAwODY4MTQsMTEuODc2NzI4IDguMzE3MDAzNSw5LjYwMDc5MTEgMTAuNjI1MzM3LDExLjg3NjcyOCAxMS45NjIxMzgsMTAuNDg1ODUyIDkuNjk2NTUwOCw4LjI0MDU5ODUgMTEuOTYyMTM4LDYuMDA2ODA2NiAxMC41NzMyNDYsNC42Mzc0MzM1IDguMzE3MDAzNSw2Ljg3MzQyOTcgNi4wNjA3NjA3LDQuNjM3NDMzNSA0LjY3MTg2ODUsNi4wMDY4MDY2IFoiIGZpbGw9ImNyaW1zb24iIHN0cm9rZS13aWR0aD0iMiIvPgo8L3N2Zz4=\");\n background-color: crimson;\n}\n.ace_icon_svg.ace_warning_fold {\n -webkit-mask-image: url(\"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAyMCAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNC43NzY5IDE0LjczMzdMOC42NTE5MiAyLjQ4MzY5QzguMzI5NDYgMS44Mzg3NyA3LjQwOTEzIDEuODM4NzcgNy4wODY2NyAyLjQ4MzY5TDAuOTYxNjY5IDE0LjczMzdDMC42NzA3NzUgMTUuMzE1NSAxLjA5MzgzIDE2IDEuNzQ0MjkgMTZIMTMuOTk0M0MxNC42NDQ4IDE2IDE1LjA2NzggMTUuMzE1NSAxNC43NzY5IDE0LjczMzdaTTMuMTYwMDcgMTQuMjVMNy44NjkyOSA0LjgzMTU2TDEyLjU3ODUgMTQuMjVIMy4xNjAwN1pNOC43NDQyOSAxMS42MjVWMTMuMzc1SDYuOTk0MjlWMTEuNjI1SDguNzQ0MjlaTTYuOTk0MjkgMTAuNzVWNy4yNUg4Ljc0NDI5VjEwLjc1SDYuOTk0MjlaIiBmaWxsPSIjRUM3MjExIi8+CjxwYXRoIGQ9Ik0xMS4xOTkxIDIuOTUyMzhDMTAuODgwOSAyLjMxNDY3IDEwLjM1MzcgMS44MDUyNiA5LjcwNTUgMS41MDlMMTEuMDQxIDEuMDY5NzhDMTEuNjg4MyAwLjk0OTgxNCAxMi4zMzcgMS4yNzI2MyAxMi42MzE3IDEuODYxNDFMMTcuNjEzNiAxMS44MTYxQzE4LjM1MjcgMTMuMjkyOSAxNy41OTM4IDE1LjA4MDQgMTYuMDE4IDE1LjU3NDVDMTYuNDA0NCAxNC40NTA3IDE2LjMyMzEgMTMuMjE4OCAxNS43OTI0IDEyLjE1NTVMMTEuMTk5MSAyLjk1MjM4WiIgZmlsbD0iI0VDNzIxMSIvPgo8L3N2Zz4=\");\n background-color: darkorange;\n}\n\n.ace_scrollbar {\n contain: strict;\n position: absolute;\n right: 0;\n bottom: 0;\n z-index: 6;\n}\n\n.ace_scrollbar-inner {\n position: absolute;\n cursor: text;\n left: 0;\n top: 0;\n}\n\n.ace_scrollbar-v{\n overflow-x: hidden;\n overflow-y: scroll;\n top: 0;\n}\n\n.ace_scrollbar-h {\n overflow-x: scroll;\n overflow-y: hidden;\n left: 0;\n}\n\n.ace_print-margin {\n position: absolute;\n height: 100%;\n}\n\n.ace_text-input {\n position: absolute;\n z-index: 0;\n width: 0.5em;\n height: 1em;\n opacity: 0;\n background: transparent;\n -moz-appearance: none;\n appearance: none;\n border: none;\n resize: none;\n outline: none;\n overflow: hidden;\n font: inherit;\n padding: 0 1px;\n margin: 0 -1px;\n contain: strict;\n -ms-user-select: text;\n -moz-user-select: text;\n -webkit-user-select: text;\n user-select: text;\n /*with `pre-line` chrome inserts instead of space*/\n white-space: pre!important;\n}\n.ace_text-input.ace_composition {\n background: transparent;\n color: inherit;\n z-index: 1000;\n opacity: 1;\n}\n.ace_composition_placeholder { color: transparent }\n.ace_composition_marker { \n border-bottom: 1px solid;\n position: absolute;\n border-radius: 0;\n margin-top: 1px;\n}\n\n[ace_nocontext=true] {\n transform: none!important;\n filter: none!important;\n clip-path: none!important;\n mask : none!important;\n contain: none!important;\n perspective: none!important;\n mix-blend-mode: initial!important;\n z-index: auto;\n}\n\n.ace_layer {\n z-index: 1;\n position: absolute;\n overflow: hidden;\n /* workaround for chrome bug https://github.com/ajaxorg/ace/issues/2312*/\n word-wrap: normal;\n white-space: pre;\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n /* setting pointer-events: auto; on node under the mouse, which changes\n during scroll, will break mouse wheel scrolling in Safari */\n pointer-events: none;\n}\n\n.ace_gutter-layer {\n position: relative;\n width: auto;\n text-align: right;\n pointer-events: auto;\n height: 1000000px;\n contain: style size layout;\n}\n\n.ace_text-layer {\n font: inherit !important;\n position: absolute;\n height: 1000000px;\n width: 1000000px;\n contain: style size layout;\n}\n\n.ace_text-layer > .ace_line, .ace_text-layer > .ace_line_group {\n contain: style size layout;\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n}\n\n.ace_hidpi .ace_text-layer,\n.ace_hidpi .ace_gutter-layer,\n.ace_hidpi .ace_content,\n.ace_hidpi .ace_gutter {\n contain: strict;\n}\n.ace_hidpi .ace_text-layer > .ace_line, \n.ace_hidpi .ace_text-layer > .ace_line_group {\n contain: strict;\n}\n\n.ace_cjk {\n display: inline-block;\n text-align: center;\n}\n\n.ace_cursor-layer {\n z-index: 4;\n}\n\n.ace_cursor {\n z-index: 4;\n position: absolute;\n box-sizing: border-box;\n border-left: 2px solid;\n /* workaround for smooth cursor repaintng whole screen in chrome */\n transform: translatez(0);\n}\n\n.ace_multiselect .ace_cursor {\n border-left-width: 1px;\n}\n\n.ace_slim-cursors .ace_cursor {\n border-left-width: 1px;\n}\n\n.ace_overwrite-cursors .ace_cursor {\n border-left-width: 0;\n border-bottom: 1px solid;\n}\n\n.ace_hidden-cursors .ace_cursor {\n opacity: 0.2;\n}\n\n.ace_hasPlaceholder .ace_hidden-cursors .ace_cursor {\n opacity: 0;\n}\n\n.ace_smooth-blinking .ace_cursor {\n transition: opacity 0.18s;\n}\n\n.ace_animate-blinking .ace_cursor {\n animation-duration: 1000ms;\n animation-timing-function: step-end;\n animation-name: blink-ace-animate;\n animation-iteration-count: infinite;\n}\n\n.ace_animate-blinking.ace_smooth-blinking .ace_cursor {\n animation-duration: 1000ms;\n animation-timing-function: ease-in-out;\n animation-name: blink-ace-animate-smooth;\n}\n \n@keyframes blink-ace-animate {\n from, to { opacity: 1; }\n 60% { opacity: 0; }\n}\n\n@keyframes blink-ace-animate-smooth {\n from, to { opacity: 1; }\n 45% { opacity: 1; }\n 60% { opacity: 0; }\n 85% { opacity: 0; }\n}\n\n.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\n position: absolute;\n z-index: 3;\n}\n\n.ace_marker-layer .ace_selection {\n position: absolute;\n z-index: 5;\n}\n\n.ace_marker-layer .ace_bracket {\n position: absolute;\n z-index: 6;\n}\n\n.ace_marker-layer .ace_error_bracket {\n position: absolute;\n border-bottom: 1px solid #DE5555;\n border-radius: 0;\n}\n\n.ace_marker-layer .ace_active-line {\n position: absolute;\n z-index: 2;\n}\n\n.ace_marker-layer .ace_selected-word {\n position: absolute;\n z-index: 4;\n box-sizing: border-box;\n}\n\n.ace_line .ace_fold {\n box-sizing: border-box;\n\n display: inline-block;\n height: 11px;\n margin-top: -2px;\n vertical-align: middle;\n\n background-image:\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\n background-repeat: no-repeat, repeat-x;\n background-position: center center, top left;\n color: transparent;\n\n border: 1px solid black;\n border-radius: 2px;\n\n cursor: pointer;\n pointer-events: auto;\n}\n\n.ace_dark .ace_fold {\n}\n\n.ace_fold:hover{\n background-image:\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\n url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\n}\n\n.ace_tooltip {\n background-color: #f5f5f5;\n border: 1px solid gray;\n border-radius: 1px;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\n color: black;\n max-width: 100%;\n padding: 3px 4px;\n position: fixed;\n z-index: 999999;\n box-sizing: border-box;\n cursor: default;\n white-space: pre-wrap;\n word-wrap: break-word;\n line-height: normal;\n font-style: normal;\n font-weight: normal;\n letter-spacing: normal;\n pointer-events: none;\n overflow: auto;\n max-width: min(60em, 66vw);\n overscroll-behavior: contain;\n}\n.ace_tooltip pre {\n white-space: pre-wrap;\n}\n\n.ace_tooltip.ace_dark {\n background-color: #636363;\n color: #fff;\n}\n\n.ace_tooltip:focus {\n outline: 1px solid #5E9ED6;\n}\n\n.ace_icon {\n display: inline-block;\n width: 18px;\n vertical-align: top;\n}\n\n.ace_icon_svg {\n display: inline-block;\n width: 12px;\n vertical-align: top;\n -webkit-mask-repeat: no-repeat;\n -webkit-mask-size: 12px;\n -webkit-mask-position: center;\n}\n\n.ace_folding-enabled > .ace_gutter-cell, .ace_folding-enabled > .ace_gutter-cell_svg-icons {\n padding-right: 13px;\n}\n\n.ace_fold-widget {\n box-sizing: border-box;\n\n margin: 0 -12px 0 1px;\n display: none;\n width: 11px;\n vertical-align: top;\n\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\n background-repeat: no-repeat;\n background-position: center;\n\n border-radius: 3px;\n \n border: 1px solid transparent;\n cursor: pointer;\n}\n\n.ace_folding-enabled .ace_fold-widget {\n display: inline-block; \n}\n\n.ace_fold-widget.ace_end {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\n}\n\n.ace_fold-widget.ace_closed {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\n}\n\n.ace_fold-widget:hover {\n border: 1px solid rgba(0, 0, 0, 0.3);\n background-color: rgba(255, 255, 255, 0.2);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\n}\n\n.ace_fold-widget:active {\n border: 1px solid rgba(0, 0, 0, 0.4);\n background-color: rgba(0, 0, 0, 0.05);\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\n}\n/**\n * Dark version for fold widgets\n */\n.ace_dark .ace_fold-widget {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\n}\n.ace_dark .ace_fold-widget.ace_end {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\n}\n.ace_dark .ace_fold-widget.ace_closed {\n background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\n}\n.ace_dark .ace_fold-widget:hover {\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n background-color: rgba(255, 255, 255, 0.1);\n}\n.ace_dark .ace_fold-widget:active {\n box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\n}\n\n.ace_inline_button {\n border: 1px solid lightgray;\n display: inline-block;\n margin: -1px 8px;\n padding: 0 5px;\n pointer-events: auto;\n cursor: pointer;\n}\n.ace_inline_button:hover {\n border-color: gray;\n background: rgba(200,200,200,0.2);\n display: inline-block;\n pointer-events: auto;\n}\n\n.ace_fold-widget.ace_invalid {\n background-color: #FFB4B4;\n border-color: #DE5555;\n}\n\n.ace_fade-fold-widgets .ace_fold-widget {\n transition: opacity 0.4s ease 0.05s;\n opacity: 0;\n}\n\n.ace_fade-fold-widgets:hover .ace_fold-widget {\n transition: opacity 0.05s ease 0.05s;\n opacity:1;\n}\n\n.ace_underline {\n text-decoration: underline;\n}\n\n.ace_bold {\n font-weight: bold;\n}\n\n.ace_nobold .ace_bold {\n font-weight: normal;\n}\n\n.ace_italic {\n font-style: italic;\n}\n\n\n.ace_error-marker {\n background-color: rgba(255, 0, 0,0.2);\n position: absolute;\n z-index: 9;\n}\n\n.ace_highlight-marker {\n background-color: rgba(255, 255, 0,0.2);\n position: absolute;\n z-index: 8;\n}\n\n.ace_mobile-menu {\n position: absolute;\n line-height: 1.5;\n border-radius: 4px;\n -ms-user-select: none;\n -moz-user-select: none;\n -webkit-user-select: none;\n user-select: none;\n background: white;\n box-shadow: 1px 3px 2px grey;\n border: 1px solid #dcdcdc;\n color: black;\n}\n.ace_dark > .ace_mobile-menu {\n background: #333;\n color: #ccc;\n box-shadow: 1px 3px 2px grey;\n border: 1px solid #444;\n\n}\n.ace_mobile-button {\n padding: 2px;\n cursor: pointer;\n overflow: hidden;\n}\n.ace_mobile-button:hover {\n background-color: #eee;\n opacity:1;\n}\n.ace_mobile-button:active {\n background-color: #ddd;\n}\n\n.ace_placeholder {\n font-family: arial;\n transform: scale(0.9);\n transform-origin: left;\n white-space: pre;\n opacity: 0.7;\n margin: 0 10px;\n}\n\n.ace_ghost_text {\n opacity: 0.5;\n font-style: italic;\n white-space: pre;\n}\n\n.ace_screenreader-only {\n position:absolute;\n left:-10000px;\n top:auto;\n width:1px;\n height:1px;\n overflow:hidden;\n}"; |
| 17814 |
|
| 17815 |
}); |
| 17816 |
|
| 17817 |
ace.define("ace/layer/decorators",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module){"use strict"; |
| 17818 |
var dom = require("../lib/dom"); |
| 17819 |
var oop = require("../lib/oop"); |
| 17820 |
var EventEmitter = require("../lib/event_emitter").EventEmitter; |
| 17821 |
var Decorator = (function () { |
| 17822 |
function Decorator(parent, renderer) { |
| 17823 |
this.canvas = dom.createElement("canvas"); |
| 17824 |
this.renderer = renderer; |
| 17825 |
this.pixelRatio = 1; |
| 17826 |
this.maxHeight = renderer.layerConfig.maxHeight; |
| 17827 |
this.lineHeight = renderer.layerConfig.lineHeight; |
| 17828 |
this.canvasHeight = parent.parent.scrollHeight; |
| 17829 |
this.heightRatio = this.canvasHeight / this.maxHeight; |
| 17830 |
this.canvasWidth = parent.width; |
| 17831 |
this.minDecorationHeight = (2 * this.pixelRatio) | 0; |
| 17832 |
this.halfMinDecorationHeight = (this.minDecorationHeight / 2) | 0; |
| 17833 |
this.canvas.width = this.canvasWidth; |
| 17834 |
this.canvas.height = this.canvasHeight; |
| 17835 |
this.canvas.style.top = 0 + "px"; |
| 17836 |
this.canvas.style.right = 0 + "px"; |
| 17837 |
this.canvas.style.zIndex = 7 + "px"; |
| 17838 |
this.canvas.style.position = "absolute"; |
| 17839 |
this.colors = {}; |
| 17840 |
this.colors.dark = { |
| 17841 |
"error": "rgba(255, 18, 18, 1)", |
| 17842 |
"warning": "rgba(18, 136, 18, 1)", |
| 17843 |
"info": "rgba(18, 18, 136, 1)" |
| 17844 |
}; |
| 17845 |
this.colors.light = { |
| 17846 |
"error": "rgb(255,51,51)", |
| 17847 |
"warning": "rgb(32,133,72)", |
| 17848 |
"info": "rgb(35,68,138)" |
| 17849 |
}; |
| 17850 |
parent.element.appendChild(this.canvas); |
| 17851 |
} |
| 17852 |
Decorator.prototype.$updateDecorators = function (config) { |
| 17853 |
var colors = (this.renderer.theme.isDark === true) ? this.colors.dark : this.colors.light; |
| 17854 |
if (config) { |
| 17855 |
this.maxHeight = config.maxHeight; |
| 17856 |
this.lineHeight = config.lineHeight; |
| 17857 |
this.canvasHeight = config.height; |
| 17858 |
var allLineHeight = (config.lastRow + 1) * this.lineHeight; |
| 17859 |
if (allLineHeight < this.canvasHeight) { |
| 17860 |
this.heightRatio = 1; |
| 17861 |
} |
| 17862 |
else { |
| 17863 |
this.heightRatio = this.canvasHeight / this.maxHeight; |
| 17864 |
} |
| 17865 |
} |
| 17866 |
var ctx = this.canvas.getContext("2d"); |
| 17867 |
function compare(a, b) { |
| 17868 |
if (a.priority < b.priority) |
| 17869 |
return -1; |
| 17870 |
if (a.priority > b.priority) |
| 17871 |
return 1; |
| 17872 |
return 0; |
| 17873 |
} |
| 17874 |
var annotations = this.renderer.session.$annotations; |
| 17875 |
ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); |
| 17876 |
if (annotations) { |
| 17877 |
var priorities = { |
| 17878 |
"info": 1, |
| 17879 |
"warning": 2, |
| 17880 |
"error": 3 |
| 17881 |
}; |
| 17882 |
annotations.forEach(function (item) { |
| 17883 |
item.priority = priorities[item.type] || null; |
| 17884 |
}); |
| 17885 |
annotations = annotations.sort(compare); |
| 17886 |
var foldData = this.renderer.session.$foldData; |
| 17887 |
for (var i = 0; i < annotations.length; i++) { |
| 17888 |
var row = annotations[i].row; |
| 17889 |
var compensateFold = this.compensateFoldRows(row, foldData); |
| 17890 |
var currentY = Math.round((row - compensateFold) * this.lineHeight * this.heightRatio); |
| 17891 |
var y1 = Math.round(((row - compensateFold) * this.lineHeight * this.heightRatio)); |
| 17892 |
var y2 = Math.round((((row - compensateFold) * this.lineHeight + this.lineHeight) * this.heightRatio)); |
| 17893 |
var height = y2 - y1; |
| 17894 |
if (height < this.minDecorationHeight) { |
| 17895 |
var yCenter = ((y1 + y2) / 2) | 0; |
| 17896 |
if (yCenter < this.halfMinDecorationHeight) { |
| 17897 |
yCenter = this.halfMinDecorationHeight; |
| 17898 |
} |
| 17899 |
else if (yCenter + this.halfMinDecorationHeight > this.canvasHeight) { |
| 17900 |
yCenter = this.canvasHeight - this.halfMinDecorationHeight; |
| 17901 |
} |
| 17902 |
y1 = Math.round(yCenter - this.halfMinDecorationHeight); |
| 17903 |
y2 = Math.round(yCenter + this.halfMinDecorationHeight); |
| 17904 |
} |
| 17905 |
ctx.fillStyle = colors[annotations[i].type] || null; |
| 17906 |
ctx.fillRect(0, currentY, this.canvasWidth, y2 - y1); |
| 17907 |
} |
| 17908 |
} |
| 17909 |
var cursor = this.renderer.session.selection.getCursor(); |
| 17910 |
if (cursor) { |
| 17911 |
var compensateFold = this.compensateFoldRows(cursor.row, foldData); |
| 17912 |
var currentY = Math.round((cursor.row - compensateFold) * this.lineHeight * this.heightRatio); |
| 17913 |
ctx.fillStyle = "rgba(0, 0, 0, 0.5)"; |
| 17914 |
ctx.fillRect(0, currentY, this.canvasWidth, 2); |
| 17915 |
} |
| 17916 |
}; |
| 17917 |
Decorator.prototype.compensateFoldRows = function (row, foldData) { |
| 17918 |
var compensateFold = 0; |
| 17919 |
if (foldData && foldData.length > 0) { |
| 17920 |
for (var j = 0; j < foldData.length; j++) { |
| 17921 |
if (row > foldData[j].start.row && row < foldData[j].end.row) { |
| 17922 |
compensateFold += row - foldData[j].start.row; |
| 17923 |
} |
| 17924 |
else if (row >= foldData[j].end.row) { |
| 17925 |
compensateFold += foldData[j].end.row - foldData[j].start.row; |
| 17926 |
} |
| 17927 |
} |
| 17928 |
} |
| 17929 |
return compensateFold; |
| 17930 |
}; |
| 17931 |
return Decorator; |
| 17932 |
}()); |
| 17933 |
oop.implement(Decorator.prototype, EventEmitter); |
| 17934 |
exports.Decorator = Decorator; |
| 17935 |
|
| 17936 |
}); |
| 17937 |
|
| 17938 |
ace.define("ace/virtual_renderer",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/config","ace/layer/gutter","ace/layer/marker","ace/layer/text","ace/layer/cursor","ace/scrollbar","ace/scrollbar","ace/scrollbar_custom","ace/scrollbar_custom","ace/renderloop","ace/layer/font_metrics","ace/lib/event_emitter","ace/css/editor-css","ace/layer/decorators","ace/lib/useragent"], function(require, exports, module){"use strict"; |
| 17939 |
var oop = require("./lib/oop"); |
| 17940 |
var dom = require("./lib/dom"); |
| 17941 |
var lang = require("./lib/lang"); |
| 17942 |
var config = require("./config"); |
| 17943 |
var GutterLayer = require("./layer/gutter").Gutter; |
| 17944 |
var MarkerLayer = require("./layer/marker").Marker; |
| 17945 |
var TextLayer = require("./layer/text").Text; |
| 17946 |
var CursorLayer = require("./layer/cursor").Cursor; |
| 17947 |
var HScrollBar = require("./scrollbar").HScrollBar; |
| 17948 |
var VScrollBar = require("./scrollbar").VScrollBar; |
| 17949 |
var HScrollBarCustom = require("./scrollbar_custom").HScrollBar; |
| 17950 |
var VScrollBarCustom = require("./scrollbar_custom").VScrollBar; |
| 17951 |
var RenderLoop = require("./renderloop").RenderLoop; |
| 17952 |
var FontMetrics = require("./layer/font_metrics").FontMetrics; |
| 17953 |
var EventEmitter = require("./lib/event_emitter").EventEmitter; |
| 17954 |
var editorCss = require("./css/editor-css"); |
| 17955 |
var Decorator = require("./layer/decorators").Decorator; |
| 17956 |
var useragent = require("./lib/useragent"); |
| 17957 |
dom.importCssString(editorCss, "ace_editor.css", false); |
| 17958 |
var VirtualRenderer = (function () { |
| 17959 |
function VirtualRenderer(container, theme) { |
| 17960 |
var _self = this; |
| 17961 |
this.container = container || dom.createElement("div"); |
| 17962 |
dom.addCssClass(this.container, "ace_editor"); |
| 17963 |
if (dom.HI_DPI) |
| 17964 |
dom.addCssClass(this.container, "ace_hidpi"); |
| 17965 |
this.setTheme(theme); |
| 17966 |
if (config.get("useStrictCSP") == null) |
| 17967 |
config.set("useStrictCSP", false); |
| 17968 |
this.$gutter = dom.createElement("div"); |
| 17969 |
this.$gutter.className = "ace_gutter"; |
| 17970 |
this.container.appendChild(this.$gutter); |
| 17971 |
this.$gutter.setAttribute("aria-hidden", "true"); |
| 17972 |
this.scroller = dom.createElement("div"); |
| 17973 |
this.scroller.className = "ace_scroller"; |
| 17974 |
this.container.appendChild(this.scroller); |
| 17975 |
this.content = dom.createElement("div"); |
| 17976 |
this.content.className = "ace_content"; |
| 17977 |
this.scroller.appendChild(this.content); |
| 17978 |
this.$gutterLayer = new GutterLayer(this.$gutter); |
| 17979 |
this.$gutterLayer.on("changeGutterWidth", this.onGutterResize.bind(this)); |
| 17980 |
this.$markerBack = new MarkerLayer(this.content); |
| 17981 |
var textLayer = this.$textLayer = new TextLayer(this.content); |
| 17982 |
this.canvas = textLayer.element; |
| 17983 |
this.$markerFront = new MarkerLayer(this.content); |
| 17984 |
this.$cursorLayer = new CursorLayer(this.content); |
| 17985 |
this.$horizScroll = false; |
| 17986 |
this.$vScroll = false; |
| 17987 |
this.scrollBar = |
| 17988 |
this.scrollBarV = new VScrollBar(this.container, this); |
| 17989 |
this.scrollBarH = new HScrollBar(this.container, this); |
| 17990 |
this.scrollBarV.on("scroll", function (e) { |
| 17991 |
if (!_self.$scrollAnimation) |
| 17992 |
_self.session.setScrollTop(e.data - _self.scrollMargin.top); |
| 17993 |
}); |
| 17994 |
this.scrollBarH.on("scroll", function (e) { |
| 17995 |
if (!_self.$scrollAnimation) |
| 17996 |
_self.session.setScrollLeft(e.data - _self.scrollMargin.left); |
| 17997 |
}); |
| 17998 |
this.scrollTop = 0; |
| 17999 |
this.scrollLeft = 0; |
| 18000 |
this.cursorPos = { |
| 18001 |
row: 0, |
| 18002 |
column: 0 |
| 18003 |
}; |
| 18004 |
this.$fontMetrics = new FontMetrics(this.container); |
| 18005 |
this.$textLayer.$setFontMetrics(this.$fontMetrics); |
| 18006 |
this.$textLayer.on("changeCharacterSize", function (e) { |
| 18007 |
_self.updateCharacterSize(); |
| 18008 |
_self.onResize(true, _self.gutterWidth, _self.$size.width, _self.$size.height); |
| 18009 |
_self._signal("changeCharacterSize", e); |
| 18010 |
}); |
| 18011 |
this.$size = { |
| 18012 |
width: 0, |
| 18013 |
height: 0, |
| 18014 |
scrollerHeight: 0, |
| 18015 |
scrollerWidth: 0, |
| 18016 |
$dirty: true |
| 18017 |
}; |
| 18018 |
this.layerConfig = { |
| 18019 |
width: 1, |
| 18020 |
padding: 0, |
| 18021 |
firstRow: 0, |
| 18022 |
firstRowScreen: 0, |
| 18023 |
lastRow: 0, |
| 18024 |
lineHeight: 0, |
| 18025 |
characterWidth: 0, |
| 18026 |
minHeight: 1, |
| 18027 |
maxHeight: 1, |
| 18028 |
offset: 0, |
| 18029 |
height: 1, |
| 18030 |
gutterOffset: 1 |
| 18031 |
}; |
| 18032 |
this.scrollMargin = { |
| 18033 |
left: 0, |
| 18034 |
right: 0, |
| 18035 |
top: 0, |
| 18036 |
bottom: 0, |
| 18037 |
v: 0, |
| 18038 |
h: 0 |
| 18039 |
}; |
| 18040 |
this.margin = { |
| 18041 |
left: 0, |
| 18042 |
right: 0, |
| 18043 |
top: 0, |
| 18044 |
bottom: 0, |
| 18045 |
v: 0, |
| 18046 |
h: 0 |
| 18047 |
}; |
| 18048 |
this.$keepTextAreaAtCursor = !useragent.isIOS; |
| 18049 |
this.$loop = new RenderLoop(this.$renderChanges.bind(this), this.container.ownerDocument.defaultView); |
| 18050 |
this.$loop.schedule(this.CHANGE_FULL); |
| 18051 |
this.updateCharacterSize(); |
| 18052 |
this.setPadding(4); |
| 18053 |
this.$addResizeObserver(); |
| 18054 |
config.resetOptions(this); |
| 18055 |
config._signal("renderer", this); |
| 18056 |
} |
| 18057 |
VirtualRenderer.prototype.updateCharacterSize = function () { |
| 18058 |
if (this.$textLayer.allowBoldFonts != this.$allowBoldFonts) { |
| 18059 |
this.$allowBoldFonts = this.$textLayer.allowBoldFonts; |
| 18060 |
this.setStyle("ace_nobold", !this.$allowBoldFonts); |
| 18061 |
} |
| 18062 |
this.layerConfig.characterWidth = |
| 18063 |
this.characterWidth = this.$textLayer.getCharacterWidth(); |
| 18064 |
this.layerConfig.lineHeight = |
| 18065 |
this.lineHeight = this.$textLayer.getLineHeight(); |
| 18066 |
this.$updatePrintMargin(); |
| 18067 |
dom.setStyle(this.scroller.style, "line-height", this.lineHeight + "px"); |
| 18068 |
}; |
| 18069 |
VirtualRenderer.prototype.setSession = function (session) { |
| 18070 |
if (this.session) |
| 18071 |
this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode); |
| 18072 |
this.session = session; |
| 18073 |
if (session && this.scrollMargin.top && session.getScrollTop() <= 0) |
| 18074 |
session.setScrollTop(-this.scrollMargin.top); |
| 18075 |
this.$cursorLayer.setSession(session); |
| 18076 |
this.$markerBack.setSession(session); |
| 18077 |
this.$markerFront.setSession(session); |
| 18078 |
this.$gutterLayer.setSession(session); |
| 18079 |
this.$textLayer.setSession(session); |
| 18080 |
if (!session) |
| 18081 |
return; |
| 18082 |
this.$loop.schedule(this.CHANGE_FULL); |
| 18083 |
this.session.$setFontMetrics(this.$fontMetrics); |
| 18084 |
this.scrollBarH.scrollLeft = this.scrollBarV.scrollTop = null; |
| 18085 |
this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this); |
| 18086 |
this.onChangeNewLineMode(); |
| 18087 |
this.session.doc.on("changeNewLineMode", this.onChangeNewLineMode); |
| 18088 |
}; |
| 18089 |
VirtualRenderer.prototype.updateLines = function (firstRow, lastRow, force) { |
| 18090 |
if (lastRow === undefined) |
| 18091 |
lastRow = Infinity; |
| 18092 |
if (!this.$changedLines) { |
| 18093 |
this.$changedLines = { |
| 18094 |
firstRow: firstRow, |
| 18095 |
lastRow: lastRow |
| 18096 |
}; |
| 18097 |
} |
| 18098 |
else { |
| 18099 |
if (this.$changedLines.firstRow > firstRow) |
| 18100 |
this.$changedLines.firstRow = firstRow; |
| 18101 |
if (this.$changedLines.lastRow < lastRow) |
| 18102 |
this.$changedLines.lastRow = lastRow; |
| 18103 |
} |
| 18104 |
if (this.$changedLines.lastRow < this.layerConfig.firstRow) { |
| 18105 |
if (force) |
| 18106 |
this.$changedLines.lastRow = this.layerConfig.lastRow; |
| 18107 |
else |
| 18108 |
return; |
| 18109 |
} |
| 18110 |
if (this.$changedLines.firstRow > this.layerConfig.lastRow) |
| 18111 |
return; |
| 18112 |
this.$loop.schedule(this.CHANGE_LINES); |
| 18113 |
}; |
| 18114 |
VirtualRenderer.prototype.onChangeNewLineMode = function () { |
| 18115 |
this.$loop.schedule(this.CHANGE_TEXT); |
| 18116 |
this.$textLayer.$updateEolChar(); |
| 18117 |
this.session.$bidiHandler.setEolChar(this.$textLayer.EOL_CHAR); |
| 18118 |
}; |
| 18119 |
VirtualRenderer.prototype.onChangeTabSize = function () { |
| 18120 |
this.$loop.schedule(this.CHANGE_TEXT | this.CHANGE_MARKER); |
| 18121 |
this.$textLayer.onChangeTabSize(); |
| 18122 |
}; |
| 18123 |
VirtualRenderer.prototype.updateText = function () { |
| 18124 |
this.$loop.schedule(this.CHANGE_TEXT); |
| 18125 |
}; |
| 18126 |
VirtualRenderer.prototype.updateFull = function (force) { |
| 18127 |
if (force) |
| 18128 |
this.$renderChanges(this.CHANGE_FULL, true); |
| 18129 |
else |
| 18130 |
this.$loop.schedule(this.CHANGE_FULL); |
| 18131 |
}; |
| 18132 |
VirtualRenderer.prototype.updateFontSize = function () { |
| 18133 |
this.$textLayer.checkForSizeChanges(); |
| 18134 |
}; |
| 18135 |
VirtualRenderer.prototype.$updateSizeAsync = function () { |
| 18136 |
if (this.$loop.pending) |
| 18137 |
this.$size.$dirty = true; |
| 18138 |
else |
| 18139 |
this.onResize(); |
| 18140 |
}; |
| 18141 |
VirtualRenderer.prototype.onResize = function (force, gutterWidth, width, height) { |
| 18142 |
if (this.resizing > 2) |
| 18143 |
return; |
| 18144 |
else if (this.resizing > 0) |
| 18145 |
this.resizing++; |
| 18146 |
else |
| 18147 |
this.resizing = force ? 1 : 0; |
| 18148 |
var el = this.container; |
| 18149 |
if (!height) |
| 18150 |
height = el.clientHeight || el.scrollHeight; |
| 18151 |
if (!width) |
| 18152 |
width = el.clientWidth || el.scrollWidth; |
| 18153 |
var changes = this.$updateCachedSize(force, gutterWidth, width, height); |
| 18154 |
if (this.$resizeTimer) |
| 18155 |
this.$resizeTimer.cancel(); |
| 18156 |
if (!this.$size.scrollerHeight || (!width && !height)) |
| 18157 |
return this.resizing = 0; |
| 18158 |
if (force) |
| 18159 |
this.$gutterLayer.$padding = null; |
| 18160 |
if (force) |
| 18161 |
this.$renderChanges(changes | this.$changes, true); |
| 18162 |
else |
| 18163 |
this.$loop.schedule(changes | this.$changes); |
| 18164 |
if (this.resizing) |
| 18165 |
this.resizing = 0; |
| 18166 |
this.scrollBarH.scrollLeft = this.scrollBarV.scrollTop = null; |
| 18167 |
if (this.$customScrollbar) { |
| 18168 |
this.$updateCustomScrollbar(true); |
| 18169 |
} |
| 18170 |
}; |
| 18171 |
VirtualRenderer.prototype.$updateCachedSize = function (force, gutterWidth, width, height) { |
| 18172 |
height -= (this.$extraHeight || 0); |
| 18173 |
var changes = 0; |
| 18174 |
var size = this.$size; |
| 18175 |
var oldSize = { |
| 18176 |
width: size.width, |
| 18177 |
height: size.height, |
| 18178 |
scrollerHeight: size.scrollerHeight, |
| 18179 |
scrollerWidth: size.scrollerWidth |
| 18180 |
}; |
| 18181 |
if (height && (force || size.height != height)) { |
| 18182 |
size.height = height; |
| 18183 |
changes |= this.CHANGE_SIZE; |
| 18184 |
size.scrollerHeight = size.height; |
| 18185 |
if (this.$horizScroll) |
| 18186 |
size.scrollerHeight -= this.scrollBarH.getHeight(); |
| 18187 |
this.scrollBarV.setHeight(size.scrollerHeight); |
| 18188 |
this.scrollBarV.element.style.bottom = this.scrollBarH.getHeight() + "px"; |
| 18189 |
changes = changes | this.CHANGE_SCROLL; |
| 18190 |
} |
| 18191 |
if (width && (force || size.width != width)) { |
| 18192 |
changes |= this.CHANGE_SIZE; |
| 18193 |
size.width = width; |
| 18194 |
if (gutterWidth == null) |
| 18195 |
gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0; |
| 18196 |
this.gutterWidth = gutterWidth; |
| 18197 |
dom.setStyle(this.scrollBarH.element.style, "left", gutterWidth + "px"); |
| 18198 |
dom.setStyle(this.scroller.style, "left", gutterWidth + this.margin.left + "px"); |
| 18199 |
size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth() - this.margin.h); |
| 18200 |
dom.setStyle(this.$gutter.style, "left", this.margin.left + "px"); |
| 18201 |
var right = this.scrollBarV.getWidth() + "px"; |
| 18202 |
dom.setStyle(this.scrollBarH.element.style, "right", right); |
| 18203 |
dom.setStyle(this.scroller.style, "right", right); |
| 18204 |
dom.setStyle(this.scroller.style, "bottom", this.scrollBarH.getHeight()); |
| 18205 |
this.scrollBarH.setWidth(size.scrollerWidth); |
| 18206 |
if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force) { |
| 18207 |
changes |= this.CHANGE_FULL; |
| 18208 |
} |
| 18209 |
} |
| 18210 |
size.$dirty = !width || !height; |
| 18211 |
if (changes) |
| 18212 |
this._signal("resize", oldSize); |
| 18213 |
return changes; |
| 18214 |
}; |
| 18215 |
VirtualRenderer.prototype.onGutterResize = function (width) { |
| 18216 |
var gutterWidth = this.$showGutter ? width : 0; |
| 18217 |
if (gutterWidth != this.gutterWidth) |
| 18218 |
this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height); |
| 18219 |
if (this.session.getUseWrapMode() && this.adjustWrapLimit()) { |
| 18220 |
this.$loop.schedule(this.CHANGE_FULL); |
| 18221 |
} |
| 18222 |
else if (this.$size.$dirty) { |
| 18223 |
this.$loop.schedule(this.CHANGE_FULL); |
| 18224 |
} |
| 18225 |
else { |
| 18226 |
this.$computeLayerConfig(); |
| 18227 |
} |
| 18228 |
}; |
| 18229 |
VirtualRenderer.prototype.adjustWrapLimit = function () { |
| 18230 |
var availableWidth = this.$size.scrollerWidth - this.$padding * 2; |
| 18231 |
var limit = Math.floor(availableWidth / this.characterWidth); |
| 18232 |
return this.session.adjustWrapLimit(limit, this.$showPrintMargin && this.$printMarginColumn); |
| 18233 |
}; |
| 18234 |
VirtualRenderer.prototype.setAnimatedScroll = function (shouldAnimate) { |
| 18235 |
this.setOption("animatedScroll", shouldAnimate); |
| 18236 |
}; |
| 18237 |
VirtualRenderer.prototype.getAnimatedScroll = function () { |
| 18238 |
return this.$animatedScroll; |
| 18239 |
}; |
| 18240 |
VirtualRenderer.prototype.setShowInvisibles = function (showInvisibles) { |
| 18241 |
this.setOption("showInvisibles", showInvisibles); |
| 18242 |
this.session.$bidiHandler.setShowInvisibles(showInvisibles); |
| 18243 |
}; |
| 18244 |
VirtualRenderer.prototype.getShowInvisibles = function () { |
| 18245 |
return this.getOption("showInvisibles"); |
| 18246 |
}; |
| 18247 |
VirtualRenderer.prototype.getDisplayIndentGuides = function () { |
| 18248 |
return this.getOption("displayIndentGuides"); |
| 18249 |
}; |
| 18250 |
VirtualRenderer.prototype.setDisplayIndentGuides = function (display) { |
| 18251 |
this.setOption("displayIndentGuides", display); |
| 18252 |
}; |
| 18253 |
VirtualRenderer.prototype.getHighlightIndentGuides = function () { |
| 18254 |
return this.getOption("highlightIndentGuides"); |
| 18255 |
}; |
| 18256 |
VirtualRenderer.prototype.setHighlightIndentGuides = function (highlight) { |
| 18257 |
this.setOption("highlightIndentGuides", highlight); |
| 18258 |
}; |
| 18259 |
VirtualRenderer.prototype.setShowPrintMargin = function (showPrintMargin) { |
| 18260 |
this.setOption("showPrintMargin", showPrintMargin); |
| 18261 |
}; |
| 18262 |
VirtualRenderer.prototype.getShowPrintMargin = function () { |
| 18263 |
return this.getOption("showPrintMargin"); |
| 18264 |
}; |
| 18265 |
VirtualRenderer.prototype.setPrintMarginColumn = function (printMarginColumn) { |
| 18266 |
this.setOption("printMarginColumn", printMarginColumn); |
| 18267 |
}; |
| 18268 |
VirtualRenderer.prototype.getPrintMarginColumn = function () { |
| 18269 |
return this.getOption("printMarginColumn"); |
| 18270 |
}; |
| 18271 |
VirtualRenderer.prototype.getShowGutter = function () { |
| 18272 |
return this.getOption("showGutter"); |
| 18273 |
}; |
| 18274 |
VirtualRenderer.prototype.setShowGutter = function (show) { |
| 18275 |
return this.setOption("showGutter", show); |
| 18276 |
}; |
| 18277 |
VirtualRenderer.prototype.getFadeFoldWidgets = function () { |
| 18278 |
return this.getOption("fadeFoldWidgets"); |
| 18279 |
}; |
| 18280 |
VirtualRenderer.prototype.setFadeFoldWidgets = function (show) { |
| 18281 |
this.setOption("fadeFoldWidgets", show); |
| 18282 |
}; |
| 18283 |
VirtualRenderer.prototype.setHighlightGutterLine = function (shouldHighlight) { |
| 18284 |
this.setOption("highlightGutterLine", shouldHighlight); |
| 18285 |
}; |
| 18286 |
VirtualRenderer.prototype.getHighlightGutterLine = function () { |
| 18287 |
return this.getOption("highlightGutterLine"); |
| 18288 |
}; |
| 18289 |
VirtualRenderer.prototype.$updatePrintMargin = function () { |
| 18290 |
if (!this.$showPrintMargin && !this.$printMarginEl) |
| 18291 |
return; |
| 18292 |
if (!this.$printMarginEl) { |
| 18293 |
var containerEl = dom.createElement("div"); |
| 18294 |
containerEl.className = "ace_layer ace_print-margin-layer"; |
| 18295 |
this.$printMarginEl = dom.createElement("div"); |
| 18296 |
this.$printMarginEl.className = "ace_print-margin"; |
| 18297 |
containerEl.appendChild(this.$printMarginEl); |
| 18298 |
this.content.insertBefore(containerEl, this.content.firstChild); |
| 18299 |
} |
| 18300 |
var style = this.$printMarginEl.style; |
| 18301 |
style.left = Math.round(this.characterWidth * this.$printMarginColumn + this.$padding) + "px"; |
| 18302 |
style.visibility = this.$showPrintMargin ? "visible" : "hidden"; |
| 18303 |
if (this.session && this.session.$wrap == -1) |
| 18304 |
this.adjustWrapLimit(); |
| 18305 |
}; |
| 18306 |
VirtualRenderer.prototype.getContainerElement = function () { |
| 18307 |
return this.container; |
| 18308 |
}; |
| 18309 |
VirtualRenderer.prototype.getMouseEventTarget = function () { |
| 18310 |
return this.scroller; |
| 18311 |
}; |
| 18312 |
VirtualRenderer.prototype.getTextAreaContainer = function () { |
| 18313 |
return this.container; |
| 18314 |
}; |
| 18315 |
VirtualRenderer.prototype.$moveTextAreaToCursor = function () { |
| 18316 |
if (this.$isMousePressed) |
| 18317 |
return; |
| 18318 |
var style = this.textarea.style; |
| 18319 |
var composition = this.$composition; |
| 18320 |
if (!this.$keepTextAreaAtCursor && !composition) { |
| 18321 |
dom.translate(this.textarea, -100, 0); |
| 18322 |
return; |
| 18323 |
} |
| 18324 |
var pixelPos = this.$cursorLayer.$pixelPos; |
| 18325 |
if (!pixelPos) |
| 18326 |
return; |
| 18327 |
if (composition && composition.markerRange) |
| 18328 |
pixelPos = this.$cursorLayer.getPixelPosition(composition.markerRange.start, true); |
| 18329 |
var config = this.layerConfig; |
| 18330 |
var posTop = pixelPos.top; |
| 18331 |
var posLeft = pixelPos.left; |
| 18332 |
posTop -= config.offset; |
| 18333 |
var h = composition && composition.useTextareaForIME || useragent.isMobile ? this.lineHeight : 1; |
| 18334 |
if (posTop < 0 || posTop > config.height - h) { |
| 18335 |
dom.translate(this.textarea, 0, 0); |
| 18336 |
return; |
| 18337 |
} |
| 18338 |
var w = 1; |
| 18339 |
var maxTop = this.$size.height - h; |
| 18340 |
if (!composition) { |
| 18341 |
posTop += this.lineHeight; |
| 18342 |
} |
| 18343 |
else { |
| 18344 |
if (composition.useTextareaForIME) { |
| 18345 |
var val = this.textarea.value; |
| 18346 |
w = this.characterWidth * (this.session.$getStringScreenWidth(val)[0]); |
| 18347 |
} |
| 18348 |
else { |
| 18349 |
posTop += this.lineHeight + 2; |
| 18350 |
} |
| 18351 |
} |
| 18352 |
posLeft -= this.scrollLeft; |
| 18353 |
if (posLeft > this.$size.scrollerWidth - w) |
| 18354 |
posLeft = this.$size.scrollerWidth - w; |
| 18355 |
posLeft += this.gutterWidth + this.margin.left; |
| 18356 |
dom.setStyle(style, "height", h + "px"); |
| 18357 |
dom.setStyle(style, "width", w + "px"); |
| 18358 |
dom.translate(this.textarea, Math.min(posLeft, this.$size.scrollerWidth - w), Math.min(posTop, maxTop)); |
| 18359 |
}; |
| 18360 |
VirtualRenderer.prototype.getFirstVisibleRow = function () { |
| 18361 |
return this.layerConfig.firstRow; |
| 18362 |
}; |
| 18363 |
VirtualRenderer.prototype.getFirstFullyVisibleRow = function () { |
| 18364 |
return this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1); |
| 18365 |
}; |
| 18366 |
VirtualRenderer.prototype.getLastFullyVisibleRow = function () { |
| 18367 |
var config = this.layerConfig; |
| 18368 |
var lastRow = config.lastRow; |
| 18369 |
var top = this.session.documentToScreenRow(lastRow, 0) * config.lineHeight; |
| 18370 |
if (top - this.session.getScrollTop() > config.height - config.lineHeight) |
| 18371 |
return lastRow - 1; |
| 18372 |
return lastRow; |
| 18373 |
}; |
| 18374 |
VirtualRenderer.prototype.getLastVisibleRow = function () { |
| 18375 |
return this.layerConfig.lastRow; |
| 18376 |
}; |
| 18377 |
VirtualRenderer.prototype.setPadding = function (padding) { |
| 18378 |
this.$padding = padding; |
| 18379 |
this.$textLayer.setPadding(padding); |
| 18380 |
this.$cursorLayer.setPadding(padding); |
| 18381 |
this.$markerFront.setPadding(padding); |
| 18382 |
this.$markerBack.setPadding(padding); |
| 18383 |
this.$loop.schedule(this.CHANGE_FULL); |
| 18384 |
this.$updatePrintMargin(); |
| 18385 |
}; |
| 18386 |
VirtualRenderer.prototype.setScrollMargin = function (top, bottom, left, right) { |
| 18387 |
var sm = this.scrollMargin; |
| 18388 |
sm.top = top | 0; |
| 18389 |
sm.bottom = bottom | 0; |
| 18390 |
sm.right = right | 0; |
| 18391 |
sm.left = left | 0; |
| 18392 |
sm.v = sm.top + sm.bottom; |
| 18393 |
sm.h = sm.left + sm.right; |
| 18394 |
if (sm.top && this.scrollTop <= 0 && this.session) |
| 18395 |
this.session.setScrollTop(-sm.top); |
| 18396 |
this.updateFull(); |
| 18397 |
}; |
| 18398 |
VirtualRenderer.prototype.setMargin = function (top, bottom, left, right) { |
| 18399 |
var sm = this.margin; |
| 18400 |
sm.top = top | 0; |
| 18401 |
sm.bottom = bottom | 0; |
| 18402 |
sm.right = right | 0; |
| 18403 |
sm.left = left | 0; |
| 18404 |
sm.v = sm.top + sm.bottom; |
| 18405 |
sm.h = sm.left + sm.right; |
| 18406 |
this.$updateCachedSize(true, this.gutterWidth, this.$size.width, this.$size.height); |
| 18407 |
this.updateFull(); |
| 18408 |
}; |
| 18409 |
VirtualRenderer.prototype.getHScrollBarAlwaysVisible = function () { |
| 18410 |
return this.$hScrollBarAlwaysVisible; |
| 18411 |
}; |
| 18412 |
VirtualRenderer.prototype.setHScrollBarAlwaysVisible = function (alwaysVisible) { |
| 18413 |
this.setOption("hScrollBarAlwaysVisible", alwaysVisible); |
| 18414 |
}; |
| 18415 |
VirtualRenderer.prototype.getVScrollBarAlwaysVisible = function () { |
| 18416 |
return this.$vScrollBarAlwaysVisible; |
| 18417 |
}; |
| 18418 |
VirtualRenderer.prototype.setVScrollBarAlwaysVisible = function (alwaysVisible) { |
| 18419 |
this.setOption("vScrollBarAlwaysVisible", alwaysVisible); |
| 18420 |
}; |
| 18421 |
VirtualRenderer.prototype.$updateScrollBarV = function () { |
| 18422 |
var scrollHeight = this.layerConfig.maxHeight; |
| 18423 |
var scrollerHeight = this.$size.scrollerHeight; |
| 18424 |
if (!this.$maxLines && this.$scrollPastEnd) { |
| 18425 |
scrollHeight -= (scrollerHeight - this.lineHeight) * this.$scrollPastEnd; |
| 18426 |
if (this.scrollTop > scrollHeight - scrollerHeight) { |
| 18427 |
scrollHeight = this.scrollTop + scrollerHeight; |
| 18428 |
this.scrollBarV.scrollTop = null; |
| 18429 |
} |
| 18430 |
} |
| 18431 |
this.scrollBarV.setScrollHeight(scrollHeight + this.scrollMargin.v); |
| 18432 |
this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top); |
| 18433 |
}; |
| 18434 |
VirtualRenderer.prototype.$updateScrollBarH = function () { |
| 18435 |
this.scrollBarH.setScrollWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h); |
| 18436 |
this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left); |
| 18437 |
}; |
| 18438 |
VirtualRenderer.prototype.freeze = function () { |
| 18439 |
this.$frozen = true; |
| 18440 |
}; |
| 18441 |
VirtualRenderer.prototype.unfreeze = function () { |
| 18442 |
this.$frozen = false; |
| 18443 |
}; |
| 18444 |
VirtualRenderer.prototype.$renderChanges = function (changes, force) { |
| 18445 |
if (this.$changes) { |
| 18446 |
changes |= this.$changes; |
| 18447 |
this.$changes = 0; |
| 18448 |
} |
| 18449 |
if ((!this.session || !this.container.offsetWidth || this.$frozen) || (!changes && !force)) { |
| 18450 |
this.$changes |= changes; |
| 18451 |
return; |
| 18452 |
} |
| 18453 |
if (this.$size.$dirty) { |
| 18454 |
this.$changes |= changes; |
| 18455 |
return this.onResize(true); |
| 18456 |
} |
| 18457 |
if (!this.lineHeight) { |
| 18458 |
this.$textLayer.checkForSizeChanges(); |
| 18459 |
} |
| 18460 |
this._signal("beforeRender", changes); |
| 18461 |
if (this.session && this.session.$bidiHandler) |
| 18462 |
this.session.$bidiHandler.updateCharacterWidths(this.$fontMetrics); |
| 18463 |
var config = this.layerConfig; |
| 18464 |
if (changes & this.CHANGE_FULL || |
| 18465 |
changes & this.CHANGE_SIZE || |
| 18466 |
changes & this.CHANGE_TEXT || |
| 18467 |
changes & this.CHANGE_LINES || |
| 18468 |
changes & this.CHANGE_SCROLL || |
| 18469 |
changes & this.CHANGE_H_SCROLL) { |
| 18470 |
changes |= this.$computeLayerConfig() | this.$loop.clear(); |
| 18471 |
if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) { |
| 18472 |
var st = this.scrollTop + (config.firstRow - Math.max(this.layerConfig.firstRow, 0)) * this.lineHeight; |
| 18473 |
if (st > 0) { |
| 18474 |
this.scrollTop = st; |
| 18475 |
changes = changes | this.CHANGE_SCROLL; |
| 18476 |
changes |= this.$computeLayerConfig() | this.$loop.clear(); |
| 18477 |
} |
| 18478 |
} |
| 18479 |
config = this.layerConfig; |
| 18480 |
this.$updateScrollBarV(); |
| 18481 |
if (changes & this.CHANGE_H_SCROLL) |
| 18482 |
this.$updateScrollBarH(); |
| 18483 |
dom.translate(this.content, -this.scrollLeft, -config.offset); |
| 18484 |
var width = config.width + 2 * this.$padding + "px"; |
| 18485 |
var height = config.minHeight + "px"; |
| 18486 |
dom.setStyle(this.content.style, "width", width); |
| 18487 |
dom.setStyle(this.content.style, "height", height); |
| 18488 |
} |
| 18489 |
if (changes & this.CHANGE_H_SCROLL) { |
| 18490 |
dom.translate(this.content, -this.scrollLeft, -config.offset); |
| 18491 |
this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller " : "ace_scroller ace_scroll-left "; |
| 18492 |
if (this.enableKeyboardAccessibility) |
| 18493 |
this.scroller.className += this.keyboardFocusClassName; |
| 18494 |
} |
| 18495 |
if (changes & this.CHANGE_FULL) { |
| 18496 |
this.$changedLines = null; |
| 18497 |
this.$textLayer.update(config); |
| 18498 |
if (this.$showGutter) |
| 18499 |
this.$gutterLayer.update(config); |
| 18500 |
if (this.$customScrollbar) { |
| 18501 |
this.$scrollDecorator.$updateDecorators(config); |
| 18502 |
} |
| 18503 |
this.$markerBack.update(config); |
| 18504 |
this.$markerFront.update(config); |
| 18505 |
this.$cursorLayer.update(config); |
| 18506 |
this.$moveTextAreaToCursor(); |
| 18507 |
this._signal("afterRender", changes); |
| 18508 |
return; |
| 18509 |
} |
| 18510 |
if (changes & this.CHANGE_SCROLL) { |
| 18511 |
this.$changedLines = null; |
| 18512 |
if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES) |
| 18513 |
this.$textLayer.update(config); |
| 18514 |
else |
| 18515 |
this.$textLayer.scrollLines(config); |
| 18516 |
if (this.$showGutter) { |
| 18517 |
if (changes & this.CHANGE_GUTTER || changes & this.CHANGE_LINES) |
| 18518 |
this.$gutterLayer.update(config); |
| 18519 |
else |
| 18520 |
this.$gutterLayer.scrollLines(config); |
| 18521 |
} |
| 18522 |
if (this.$customScrollbar) { |
| 18523 |
this.$scrollDecorator.$updateDecorators(config); |
| 18524 |
} |
| 18525 |
this.$markerBack.update(config); |
| 18526 |
this.$markerFront.update(config); |
| 18527 |
this.$cursorLayer.update(config); |
| 18528 |
this.$moveTextAreaToCursor(); |
| 18529 |
this._signal("afterRender", changes); |
| 18530 |
return; |
| 18531 |
} |
| 18532 |
if (changes & this.CHANGE_TEXT) { |
| 18533 |
this.$changedLines = null; |
| 18534 |
this.$textLayer.update(config); |
| 18535 |
if (this.$showGutter) |
| 18536 |
this.$gutterLayer.update(config); |
| 18537 |
if (this.$customScrollbar) { |
| 18538 |
this.$scrollDecorator.$updateDecorators(config); |
| 18539 |
} |
| 18540 |
} |
| 18541 |
else if (changes & this.CHANGE_LINES) { |
| 18542 |
if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter) |
| 18543 |
this.$gutterLayer.update(config); |
| 18544 |
if (this.$customScrollbar) { |
| 18545 |
this.$scrollDecorator.$updateDecorators(config); |
| 18546 |
} |
| 18547 |
} |
| 18548 |
else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) { |
| 18549 |
if (this.$showGutter) |
| 18550 |
this.$gutterLayer.update(config); |
| 18551 |
if (this.$customScrollbar) { |
| 18552 |
this.$scrollDecorator.$updateDecorators(config); |
| 18553 |
} |
| 18554 |
} |
| 18555 |
else if (changes & this.CHANGE_CURSOR) { |
| 18556 |
if (this.$highlightGutterLine) |
| 18557 |
this.$gutterLayer.updateLineHighlight(config); |
| 18558 |
if (this.$customScrollbar) { |
| 18559 |
this.$scrollDecorator.$updateDecorators(config); |
| 18560 |
} |
| 18561 |
} |
| 18562 |
if (changes & this.CHANGE_CURSOR) { |
| 18563 |
this.$cursorLayer.update(config); |
| 18564 |
this.$moveTextAreaToCursor(); |
| 18565 |
} |
| 18566 |
if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) { |
| 18567 |
this.$markerFront.update(config); |
| 18568 |
} |
| 18569 |
if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) { |
| 18570 |
this.$markerBack.update(config); |
| 18571 |
} |
| 18572 |
this._signal("afterRender", changes); |
| 18573 |
}; |
| 18574 |
VirtualRenderer.prototype.$autosize = function () { |
| 18575 |
var height = this.session.getScreenLength() * this.lineHeight; |
| 18576 |
var maxHeight = this.$maxLines * this.lineHeight; |
| 18577 |
var desiredHeight = Math.min(maxHeight, Math.max((this.$minLines || 1) * this.lineHeight, height)) + this.scrollMargin.v + (this.$extraHeight || 0); |
| 18578 |
if (this.$horizScroll) |
| 18579 |
desiredHeight += this.scrollBarH.getHeight(); |
| 18580 |
if (this.$maxPixelHeight && desiredHeight > this.$maxPixelHeight) |
| 18581 |
desiredHeight = this.$maxPixelHeight; |
| 18582 |
var hideScrollbars = desiredHeight <= 2 * this.lineHeight; |
| 18583 |
var vScroll = !hideScrollbars && height > maxHeight; |
| 18584 |
if (desiredHeight != this.desiredHeight || |
| 18585 |
this.$size.height != this.desiredHeight || vScroll != this.$vScroll) { |
| 18586 |
if (vScroll != this.$vScroll) { |
| 18587 |
this.$vScroll = vScroll; |
| 18588 |
this.scrollBarV.setVisible(vScroll); |
| 18589 |
} |
| 18590 |
var w = this.container.clientWidth; |
| 18591 |
this.container.style.height = desiredHeight + "px"; |
| 18592 |
this.$updateCachedSize(true, this.$gutterWidth, w, desiredHeight); |
| 18593 |
this.desiredHeight = desiredHeight; |
| 18594 |
this._signal("autosize"); |
| 18595 |
} |
| 18596 |
}; |
| 18597 |
VirtualRenderer.prototype.$computeLayerConfig = function () { |
| 18598 |
var session = this.session; |
| 18599 |
var size = this.$size; |
| 18600 |
var hideScrollbars = size.height <= 2 * this.lineHeight; |
| 18601 |
var screenLines = this.session.getScreenLength(); |
| 18602 |
var maxHeight = screenLines * this.lineHeight; |
| 18603 |
var longestLine = this.$getLongestLine(); |
| 18604 |
var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible || |
| 18605 |
size.scrollerWidth - longestLine - 2 * this.$padding < 0); |
| 18606 |
var hScrollChanged = this.$horizScroll !== horizScroll; |
| 18607 |
if (hScrollChanged) { |
| 18608 |
this.$horizScroll = horizScroll; |
| 18609 |
this.scrollBarH.setVisible(horizScroll); |
| 18610 |
} |
| 18611 |
var vScrollBefore = this.$vScroll; |
| 18612 |
if (this.$maxLines && this.lineHeight > 1) |
| 18613 |
this.$autosize(); |
| 18614 |
var minHeight = size.scrollerHeight + this.lineHeight; |
| 18615 |
var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd |
| 18616 |
? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd |
| 18617 |
: 0; |
| 18618 |
maxHeight += scrollPastEnd; |
| 18619 |
var sm = this.scrollMargin; |
| 18620 |
this.session.setScrollTop(Math.max(-sm.top, Math.min(this.scrollTop, maxHeight - size.scrollerHeight + sm.bottom))); |
| 18621 |
this.session.setScrollLeft(Math.max(-sm.left, Math.min(this.scrollLeft, longestLine + 2 * this.$padding - size.scrollerWidth + sm.right))); |
| 18622 |
var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible || |
| 18623 |
size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop > sm.top); |
| 18624 |
var vScrollChanged = vScrollBefore !== vScroll; |
| 18625 |
if (vScrollChanged) { |
| 18626 |
this.$vScroll = vScroll; |
| 18627 |
this.scrollBarV.setVisible(vScroll); |
| 18628 |
} |
| 18629 |
var offset = this.scrollTop % this.lineHeight; |
| 18630 |
var lineCount = Math.ceil(minHeight / this.lineHeight) - 1; |
| 18631 |
var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight)); |
| 18632 |
var lastRow = firstRow + lineCount; |
| 18633 |
var firstRowScreen, firstRowHeight; |
| 18634 |
var lineHeight = this.lineHeight; |
| 18635 |
firstRow = session.screenToDocumentRow(firstRow, 0); |
| 18636 |
var foldLine = session.getFoldLine(firstRow); |
| 18637 |
if (foldLine) { |
| 18638 |
firstRow = foldLine.start.row; |
| 18639 |
} |
| 18640 |
firstRowScreen = session.documentToScreenRow(firstRow, 0); |
| 18641 |
firstRowHeight = session.getRowLength(firstRow) * lineHeight; |
| 18642 |
lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1); |
| 18643 |
minHeight = size.scrollerHeight + session.getRowLength(lastRow) * lineHeight + |
| 18644 |
firstRowHeight; |
| 18645 |
offset = this.scrollTop - firstRowScreen * lineHeight; |
| 18646 |
var changes = 0; |
| 18647 |
if (this.layerConfig.width != longestLine || hScrollChanged) |
| 18648 |
changes = this.CHANGE_H_SCROLL; |
| 18649 |
if (hScrollChanged || vScrollChanged) { |
| 18650 |
changes |= this.$updateCachedSize(true, this.gutterWidth, size.width, size.height); |
| 18651 |
this._signal("scrollbarVisibilityChanged"); |
| 18652 |
if (vScrollChanged) |
| 18653 |
longestLine = this.$getLongestLine(); |
| 18654 |
} |
| 18655 |
this.layerConfig = { |
| 18656 |
width: longestLine, |
| 18657 |
padding: this.$padding, |
| 18658 |
firstRow: firstRow, |
| 18659 |
firstRowScreen: firstRowScreen, |
| 18660 |
lastRow: lastRow, |
| 18661 |
lineHeight: lineHeight, |
| 18662 |
characterWidth: this.characterWidth, |
| 18663 |
minHeight: minHeight, |
| 18664 |
maxHeight: maxHeight, |
| 18665 |
offset: offset, |
| 18666 |
gutterOffset: lineHeight ? Math.max(0, Math.ceil((offset + size.height - size.scrollerHeight) / lineHeight)) : 0, |
| 18667 |
height: this.$size.scrollerHeight |
| 18668 |
}; |
| 18669 |
if (this.session.$bidiHandler) |
| 18670 |
this.session.$bidiHandler.setContentWidth(longestLine - this.$padding); |
| 18671 |
return changes; |
| 18672 |
}; |
| 18673 |
VirtualRenderer.prototype.$updateLines = function () { |
| 18674 |
if (!this.$changedLines) |
| 18675 |
return; |
| 18676 |
var firstRow = this.$changedLines.firstRow; |
| 18677 |
var lastRow = this.$changedLines.lastRow; |
| 18678 |
this.$changedLines = null; |
| 18679 |
var layerConfig = this.layerConfig; |
| 18680 |
if (firstRow > layerConfig.lastRow + 1) { |
| 18681 |
return; |
| 18682 |
} |
| 18683 |
if (lastRow < layerConfig.firstRow) { |
| 18684 |
return; |
| 18685 |
} |
| 18686 |
if (lastRow === Infinity) { |
| 18687 |
if (this.$showGutter) |
| 18688 |
this.$gutterLayer.update(layerConfig); |
| 18689 |
this.$textLayer.update(layerConfig); |
| 18690 |
return; |
| 18691 |
} |
| 18692 |
this.$textLayer.updateLines(layerConfig, firstRow, lastRow); |
| 18693 |
return true; |
| 18694 |
}; |
| 18695 |
VirtualRenderer.prototype.$getLongestLine = function () { |
| 18696 |
var charCount = this.session.getScreenWidth(); |
| 18697 |
if (this.showInvisibles && !this.session.$useWrapMode) |
| 18698 |
charCount += 1; |
| 18699 |
if (this.$textLayer && charCount > this.$textLayer.MAX_LINE_LENGTH) |
| 18700 |
charCount = this.$textLayer.MAX_LINE_LENGTH + 30; |
| 18701 |
return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth)); |
| 18702 |
}; |
| 18703 |
VirtualRenderer.prototype.updateFrontMarkers = function () { |
| 18704 |
this.$markerFront.setMarkers(this.session.getMarkers(true)); |
| 18705 |
this.$loop.schedule(this.CHANGE_MARKER_FRONT); |
| 18706 |
}; |
| 18707 |
VirtualRenderer.prototype.updateBackMarkers = function () { |
| 18708 |
this.$markerBack.setMarkers(this.session.getMarkers()); |
| 18709 |
this.$loop.schedule(this.CHANGE_MARKER_BACK); |
| 18710 |
}; |
| 18711 |
VirtualRenderer.prototype.addGutterDecoration = function (row, className) { |
| 18712 |
this.$gutterLayer.addGutterDecoration(row, className); |
| 18713 |
}; |
| 18714 |
VirtualRenderer.prototype.removeGutterDecoration = function (row, className) { |
| 18715 |
this.$gutterLayer.removeGutterDecoration(row, className); |
| 18716 |
}; |
| 18717 |
VirtualRenderer.prototype.updateBreakpoints = function (rows) { |
| 18718 |
this._rows = rows; |
| 18719 |
this.$loop.schedule(this.CHANGE_GUTTER); |
| 18720 |
}; |
| 18721 |
VirtualRenderer.prototype.setAnnotations = function (annotations) { |
| 18722 |
this.$gutterLayer.setAnnotations(annotations); |
| 18723 |
this.$loop.schedule(this.CHANGE_GUTTER); |
| 18724 |
}; |
| 18725 |
VirtualRenderer.prototype.updateCursor = function () { |
| 18726 |
this.$loop.schedule(this.CHANGE_CURSOR); |
| 18727 |
}; |
| 18728 |
VirtualRenderer.prototype.hideCursor = function () { |
| 18729 |
this.$cursorLayer.hideCursor(); |
| 18730 |
}; |
| 18731 |
VirtualRenderer.prototype.showCursor = function () { |
| 18732 |
this.$cursorLayer.showCursor(); |
| 18733 |
}; |
| 18734 |
VirtualRenderer.prototype.scrollSelectionIntoView = function (anchor, lead, offset) { |
| 18735 |
this.scrollCursorIntoView(anchor, offset); |
| 18736 |
this.scrollCursorIntoView(lead, offset); |
| 18737 |
}; |
| 18738 |
VirtualRenderer.prototype.scrollCursorIntoView = function (cursor, offset, $viewMargin) { |
| 18739 |
if (this.$size.scrollerHeight === 0) |
| 18740 |
return; |
| 18741 |
var pos = this.$cursorLayer.getPixelPosition(cursor); |
| 18742 |
var newLeft = pos.left; |
| 18743 |
var newTop = pos.top; |
| 18744 |
var topMargin = $viewMargin && $viewMargin.top || 0; |
| 18745 |
var bottomMargin = $viewMargin && $viewMargin.bottom || 0; |
| 18746 |
if (this.$scrollAnimation) { |
| 18747 |
this.$stopAnimation = true; |
| 18748 |
} |
| 18749 |
var currentTop = this.$scrollAnimation ? this.session.getScrollTop() : this.scrollTop; |
| 18750 |
if (currentTop + topMargin > newTop) { |
| 18751 |
if (offset && currentTop + topMargin > newTop + this.lineHeight) |
| 18752 |
newTop -= offset * this.$size.scrollerHeight; |
| 18753 |
if (newTop === 0) |
| 18754 |
newTop = -this.scrollMargin.top; |
| 18755 |
this.session.setScrollTop(newTop); |
| 18756 |
} |
| 18757 |
else if (currentTop + this.$size.scrollerHeight - bottomMargin < newTop + this.lineHeight) { |
| 18758 |
if (offset && currentTop + this.$size.scrollerHeight - bottomMargin < newTop - this.lineHeight) |
| 18759 |
newTop += offset * this.$size.scrollerHeight; |
| 18760 |
this.session.setScrollTop(newTop + this.lineHeight + bottomMargin - this.$size.scrollerHeight); |
| 18761 |
} |
| 18762 |
var currentLeft = this.scrollLeft; |
| 18763 |
var twoCharsWidth = 2 * this.layerConfig.characterWidth; |
| 18764 |
if (newLeft - twoCharsWidth < currentLeft) { |
| 18765 |
newLeft -= twoCharsWidth; |
| 18766 |
if (newLeft < this.$padding + twoCharsWidth) { |
| 18767 |
newLeft = -this.scrollMargin.left; |
| 18768 |
} |
| 18769 |
this.session.setScrollLeft(newLeft); |
| 18770 |
} |
| 18771 |
else { |
| 18772 |
newLeft += twoCharsWidth; |
| 18773 |
if (currentLeft + this.$size.scrollerWidth < newLeft + this.characterWidth) { |
| 18774 |
this.session.setScrollLeft(Math.round(newLeft + this.characterWidth - this.$size.scrollerWidth)); |
| 18775 |
} |
| 18776 |
else if (currentLeft <= this.$padding && newLeft - currentLeft < this.characterWidth) { |
| 18777 |
this.session.setScrollLeft(0); |
| 18778 |
} |
| 18779 |
} |
| 18780 |
}; |
| 18781 |
VirtualRenderer.prototype.getScrollTop = function () { |
| 18782 |
return this.session.getScrollTop(); |
| 18783 |
}; |
| 18784 |
VirtualRenderer.prototype.getScrollLeft = function () { |
| 18785 |
return this.session.getScrollLeft(); |
| 18786 |
}; |
| 18787 |
VirtualRenderer.prototype.getScrollTopRow = function () { |
| 18788 |
return this.scrollTop / this.lineHeight; |
| 18789 |
}; |
| 18790 |
VirtualRenderer.prototype.getScrollBottomRow = function () { |
| 18791 |
return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1); |
| 18792 |
}; |
| 18793 |
VirtualRenderer.prototype.scrollToRow = function (row) { |
| 18794 |
this.session.setScrollTop(row * this.lineHeight); |
| 18795 |
}; |
| 18796 |
VirtualRenderer.prototype.alignCursor = function (cursor, alignment) { |
| 18797 |
if (typeof cursor == "number") |
| 18798 |
cursor = { row: cursor, column: 0 }; |
| 18799 |
var pos = this.$cursorLayer.getPixelPosition(cursor); |
| 18800 |
var h = this.$size.scrollerHeight - this.lineHeight; |
| 18801 |
var offset = pos.top - h * (alignment || 0); |
| 18802 |
this.session.setScrollTop(offset); |
| 18803 |
return offset; |
| 18804 |
}; |
| 18805 |
VirtualRenderer.prototype.$calcSteps = function (fromValue, toValue) { |
| 18806 |
var i = 0; |
| 18807 |
var l = this.STEPS; |
| 18808 |
var steps = []; |
| 18809 |
var func = function (t, x_min, dx) { |
| 18810 |
return dx * (Math.pow(t - 1, 3) + 1) + x_min; |
| 18811 |
}; |
| 18812 |
for (i = 0; i < l; ++i) |
| 18813 |
steps.push(func(i / this.STEPS, fromValue, toValue - fromValue)); |
| 18814 |
return steps; |
| 18815 |
}; |
| 18816 |
VirtualRenderer.prototype.scrollToLine = function (line, center, animate, callback) { |
| 18817 |
var pos = this.$cursorLayer.getPixelPosition({ row: line, column: 0 }); |
| 18818 |
var offset = pos.top; |
| 18819 |
if (center) |
| 18820 |
offset -= this.$size.scrollerHeight / 2; |
| 18821 |
var initialScroll = this.scrollTop; |
| 18822 |
this.session.setScrollTop(offset); |
| 18823 |
if (animate !== false) |
| 18824 |
this.animateScrolling(initialScroll, callback); |
| 18825 |
}; |
| 18826 |
VirtualRenderer.prototype.animateScrolling = function (fromValue, callback) { |
| 18827 |
var toValue = this.scrollTop; |
| 18828 |
if (!this.$animatedScroll) |
| 18829 |
return; |
| 18830 |
var _self = this; |
| 18831 |
if (fromValue == toValue) |
| 18832 |
return; |
| 18833 |
if (this.$scrollAnimation) { |
| 18834 |
var oldSteps = this.$scrollAnimation.steps; |
| 18835 |
if (oldSteps.length) { |
| 18836 |
fromValue = oldSteps[0]; |
| 18837 |
if (fromValue == toValue) |
| 18838 |
return; |
| 18839 |
} |
| 18840 |
} |
| 18841 |
var steps = _self.$calcSteps(fromValue, toValue); |
| 18842 |
this.$scrollAnimation = { from: fromValue, to: toValue, steps: steps }; |
| 18843 |
clearInterval(this.$timer); |
| 18844 |
_self.session.setScrollTop(steps.shift()); |
| 18845 |
_self.session.$scrollTop = toValue; |
| 18846 |
function endAnimation() { |
| 18847 |
_self.$timer = clearInterval(_self.$timer); |
| 18848 |
_self.$scrollAnimation = null; |
| 18849 |
_self.$stopAnimation = false; |
| 18850 |
callback && callback(); |
| 18851 |
} |
| 18852 |
this.$timer = setInterval(function () { |
| 18853 |
if (_self.$stopAnimation) { |
| 18854 |
endAnimation(); |
| 18855 |
return; |
| 18856 |
} |
| 18857 |
if (!_self.session) |
| 18858 |
return clearInterval(_self.$timer); |
| 18859 |
if (steps.length) { |
| 18860 |
_self.session.setScrollTop(steps.shift()); |
| 18861 |
_self.session.$scrollTop = toValue; |
| 18862 |
} |
| 18863 |
else if (toValue != null) { |
| 18864 |
_self.session.$scrollTop = -1; |
| 18865 |
_self.session.setScrollTop(toValue); |
| 18866 |
toValue = null; |
| 18867 |
} |
| 18868 |
else { |
| 18869 |
endAnimation(); |
| 18870 |
} |
| 18871 |
}, 10); |
| 18872 |
}; |
| 18873 |
VirtualRenderer.prototype.scrollToY = function (scrollTop) { |
| 18874 |
if (this.scrollTop !== scrollTop) { |
| 18875 |
this.$loop.schedule(this.CHANGE_SCROLL); |
| 18876 |
this.scrollTop = scrollTop; |
| 18877 |
} |
| 18878 |
}; |
| 18879 |
VirtualRenderer.prototype.scrollToX = function (scrollLeft) { |
| 18880 |
if (this.scrollLeft !== scrollLeft) |
| 18881 |
this.scrollLeft = scrollLeft; |
| 18882 |
this.$loop.schedule(this.CHANGE_H_SCROLL); |
| 18883 |
}; |
| 18884 |
VirtualRenderer.prototype.scrollTo = function (x, y) { |
| 18885 |
this.session.setScrollTop(y); |
| 18886 |
this.session.setScrollLeft(x); |
| 18887 |
}; |
| 18888 |
VirtualRenderer.prototype.scrollBy = function (deltaX, deltaY) { |
| 18889 |
deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY); |
| 18890 |
deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX); |
| 18891 |
}; |
| 18892 |
VirtualRenderer.prototype.isScrollableBy = function (deltaX, deltaY) { |
| 18893 |
if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top) |
| 18894 |
return true; |
| 18895 |
if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight |
| 18896 |
- this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom) |
| 18897 |
return true; |
| 18898 |
if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left) |
| 18899 |
return true; |
| 18900 |
if (deltaX > 0 && this.session.getScrollLeft() + this.$size.scrollerWidth |
| 18901 |
- this.layerConfig.width < -1 + this.scrollMargin.right) |
| 18902 |
return true; |
| 18903 |
}; |
| 18904 |
VirtualRenderer.prototype.pixelToScreenCoordinates = function (x, y) { |
| 18905 |
var canvasPos; |
| 18906 |
if (this.$hasCssTransforms) { |
| 18907 |
canvasPos = { top: 0, left: 0 }; |
| 18908 |
var p = this.$fontMetrics.transformCoordinates([x, y]); |
| 18909 |
x = p[1] - this.gutterWidth - this.margin.left; |
| 18910 |
y = p[0]; |
| 18911 |
} |
| 18912 |
else { |
| 18913 |
canvasPos = this.scroller.getBoundingClientRect(); |
| 18914 |
} |
| 18915 |
var offsetX = x + this.scrollLeft - canvasPos.left - this.$padding; |
| 18916 |
var offset = offsetX / this.characterWidth; |
| 18917 |
var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight); |
| 18918 |
var col = this.$blockCursor ? Math.floor(offset) : Math.round(offset); |
| 18919 |
return { row: row, column: col, side: offset - col > 0 ? 1 : -1, offsetX: offsetX }; |
| 18920 |
}; |
| 18921 |
VirtualRenderer.prototype.screenToTextCoordinates = function (x, y) { |
| 18922 |
var canvasPos; |
| 18923 |
if (this.$hasCssTransforms) { |
| 18924 |
canvasPos = { top: 0, left: 0 }; |
| 18925 |
var p = this.$fontMetrics.transformCoordinates([x, y]); |
| 18926 |
x = p[1] - this.gutterWidth - this.margin.left; |
| 18927 |
y = p[0]; |
| 18928 |
} |
| 18929 |
else { |
| 18930 |
canvasPos = this.scroller.getBoundingClientRect(); |
| 18931 |
} |
| 18932 |
var offsetX = x + this.scrollLeft - canvasPos.left - this.$padding; |
| 18933 |
var offset = offsetX / this.characterWidth; |
| 18934 |
var col = this.$blockCursor ? Math.floor(offset) : Math.round(offset); |
| 18935 |
var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight); |
| 18936 |
return this.session.screenToDocumentPosition(row, Math.max(col, 0), offsetX); |
| 18937 |
}; |
| 18938 |
VirtualRenderer.prototype.textToScreenCoordinates = function (row, column) { |
| 18939 |
var canvasPos = this.scroller.getBoundingClientRect(); |
| 18940 |
var pos = this.session.documentToScreenPosition(row, column); |
| 18941 |
var x = this.$padding + (this.session.$bidiHandler.isBidiRow(pos.row, row) |
| 18942 |
? this.session.$bidiHandler.getPosLeft(pos.column) |
| 18943 |
: Math.round(pos.column * this.characterWidth)); |
| 18944 |
var y = pos.row * this.lineHeight; |
| 18945 |
return { |
| 18946 |
pageX: canvasPos.left + x - this.scrollLeft, |
| 18947 |
pageY: canvasPos.top + y - this.scrollTop |
| 18948 |
}; |
| 18949 |
}; |
| 18950 |
VirtualRenderer.prototype.visualizeFocus = function () { |
| 18951 |
dom.addCssClass(this.container, "ace_focus"); |
| 18952 |
}; |
| 18953 |
VirtualRenderer.prototype.visualizeBlur = function () { |
| 18954 |
dom.removeCssClass(this.container, "ace_focus"); |
| 18955 |
}; |
| 18956 |
VirtualRenderer.prototype.showComposition = function (composition) { |
| 18957 |
this.$composition = composition; |
| 18958 |
if (!composition.cssText) { |
| 18959 |
composition.cssText = this.textarea.style.cssText; |
| 18960 |
} |
| 18961 |
if (composition.useTextareaForIME == undefined) |
| 18962 |
composition.useTextareaForIME = this.$useTextareaForIME; |
| 18963 |
if (this.$useTextareaForIME) { |
| 18964 |
dom.addCssClass(this.textarea, "ace_composition"); |
| 18965 |
this.textarea.style.cssText = ""; |
| 18966 |
this.$moveTextAreaToCursor(); |
| 18967 |
this.$cursorLayer.element.style.display = "none"; |
| 18968 |
} |
| 18969 |
else { |
| 18970 |
composition.markerId = this.session.addMarker(composition.markerRange, "ace_composition_marker", "text"); |
| 18971 |
} |
| 18972 |
}; |
| 18973 |
VirtualRenderer.prototype.setCompositionText = function (text) { |
| 18974 |
var cursor = this.session.selection.cursor; |
| 18975 |
this.addToken(text, "composition_placeholder", cursor.row, cursor.column); |
| 18976 |
this.$moveTextAreaToCursor(); |
| 18977 |
}; |
| 18978 |
VirtualRenderer.prototype.hideComposition = function () { |
| 18979 |
if (!this.$composition) |
| 18980 |
return; |
| 18981 |
if (this.$composition.markerId) |
| 18982 |
this.session.removeMarker(this.$composition.markerId); |
| 18983 |
dom.removeCssClass(this.textarea, "ace_composition"); |
| 18984 |
this.textarea.style.cssText = this.$composition.cssText; |
| 18985 |
var cursor = this.session.selection.cursor; |
| 18986 |
this.removeExtraToken(cursor.row, cursor.column); |
| 18987 |
this.$composition = null; |
| 18988 |
this.$cursorLayer.element.style.display = ""; |
| 18989 |
}; |
| 18990 |
VirtualRenderer.prototype.setGhostText = function (text, position) { |
| 18991 |
var cursor = this.session.selection.cursor; |
| 18992 |
var insertPosition = position || { row: cursor.row, column: cursor.column }; |
| 18993 |
this.removeGhostText(); |
| 18994 |
var textLines = text.split("\n"); |
| 18995 |
this.addToken(textLines[0], "ghost_text", insertPosition.row, insertPosition.column); |
| 18996 |
this.$ghostText = { |
| 18997 |
text: text, |
| 18998 |
position: { |
| 18999 |
row: insertPosition.row, |
| 19000 |
column: insertPosition.column |
| 19001 |
} |
| 19002 |
}; |
| 19003 |
if (textLines.length > 1) { |
| 19004 |
this.$ghostTextWidget = { |
| 19005 |
text: textLines.slice(1).join("\n"), |
| 19006 |
row: insertPosition.row, |
| 19007 |
column: insertPosition.column, |
| 19008 |
className: "ace_ghost_text" |
| 19009 |
}; |
| 19010 |
this.session.widgetManager.addLineWidget(this.$ghostTextWidget); |
| 19011 |
var pixelPosition = this.$cursorLayer.getPixelPosition(insertPosition, true); |
| 19012 |
var el = this.container; |
| 19013 |
var height = el.getBoundingClientRect().height; |
| 19014 |
var ghostTextHeight = textLines.length * this.lineHeight; |
| 19015 |
var fitsY = ghostTextHeight < height - pixelPosition.top; |
| 19016 |
if (fitsY) |
| 19017 |
return; |
| 19018 |
if (ghostTextHeight < height) { |
| 19019 |
this.scrollBy(0, (textLines.length - 1) * this.lineHeight); |
| 19020 |
} |
| 19021 |
else { |
| 19022 |
this.scrollBy(0, pixelPosition.top); |
| 19023 |
} |
| 19024 |
} |
| 19025 |
}; |
| 19026 |
VirtualRenderer.prototype.removeGhostText = function () { |
| 19027 |
if (!this.$ghostText) |
| 19028 |
return; |
| 19029 |
var position = this.$ghostText.position; |
| 19030 |
this.removeExtraToken(position.row, position.column); |
| 19031 |
if (this.$ghostTextWidget) { |
| 19032 |
this.session.widgetManager.removeLineWidget(this.$ghostTextWidget); |
| 19033 |
this.$ghostTextWidget = null; |
| 19034 |
} |
| 19035 |
this.$ghostText = null; |
| 19036 |
}; |
| 19037 |
VirtualRenderer.prototype.addToken = function (text, type, row, column) { |
| 19038 |
var session = this.session; |
| 19039 |
session.bgTokenizer.lines[row] = null; |
| 19040 |
var newToken = { type: type, value: text }; |
| 19041 |
var tokens = session.getTokens(row); |
| 19042 |
if (column == null || !tokens.length) { |
| 19043 |
tokens.push(newToken); |
| 19044 |
} |
| 19045 |
else { |
| 19046 |
var l = 0; |
| 19047 |
for (var i = 0; i < tokens.length; i++) { |
| 19048 |
var token = tokens[i]; |
| 19049 |
l += token.value.length; |
| 19050 |
if (column <= l) { |
| 19051 |
var diff = token.value.length - (l - column); |
| 19052 |
var before = token.value.slice(0, diff); |
| 19053 |
var after = token.value.slice(diff); |
| 19054 |
tokens.splice(i, 1, { type: token.type, value: before }, newToken, { type: token.type, value: after }); |
| 19055 |
break; |
| 19056 |
} |
| 19057 |
} |
| 19058 |
} |
| 19059 |
this.updateLines(row, row); |
| 19060 |
}; |
| 19061 |
VirtualRenderer.prototype.removeExtraToken = function (row, column) { |
| 19062 |
this.session.bgTokenizer.lines[row] = null; |
| 19063 |
this.updateLines(row, row); |
| 19064 |
}; |
| 19065 |
VirtualRenderer.prototype.setTheme = function (theme, cb) { |
| 19066 |
var _self = this; |
| 19067 |
this.$themeId = theme; |
| 19068 |
_self._dispatchEvent('themeChange', { theme: theme }); |
| 19069 |
if (!theme || typeof theme == "string") { |
| 19070 |
var moduleName = theme || this.$options.theme.initialValue; |
| 19071 |
config.loadModule(["theme", moduleName], afterLoad); |
| 19072 |
} |
| 19073 |
else { |
| 19074 |
afterLoad(theme); |
| 19075 |
} |
| 19076 |
function afterLoad(module) { |
| 19077 |
if (_self.$themeId != theme) |
| 19078 |
return cb && cb(); |
| 19079 |
if (!module || !module.cssClass) |
| 19080 |
throw new Error("couldn't load module " + theme + " or it didn't call define"); |
| 19081 |
if (module.$id) |
| 19082 |
_self.$themeId = module.$id; |
| 19083 |
dom.importCssString(module.cssText, module.cssClass, _self.container); |
| 19084 |
if (_self.theme) |
| 19085 |
dom.removeCssClass(_self.container, _self.theme.cssClass); |
| 19086 |
var padding = "padding" in module ? module.padding |
| 19087 |
: "padding" in (_self.theme || {}) ? 4 : _self.$padding; |
| 19088 |
if (_self.$padding && padding != _self.$padding) |
| 19089 |
_self.setPadding(padding); |
| 19090 |
_self.$theme = module.cssClass; |
| 19091 |
_self.theme = module; |
| 19092 |
dom.addCssClass(_self.container, module.cssClass); |
| 19093 |
dom.setCssClass(_self.container, "ace_dark", module.isDark); |
| 19094 |
if (_self.$size) { |
| 19095 |
_self.$size.width = 0; |
| 19096 |
_self.$updateSizeAsync(); |
| 19097 |
} |
| 19098 |
_self._dispatchEvent('themeLoaded', { theme: module }); |
| 19099 |
cb && cb(); |
| 19100 |
} |
| 19101 |
}; |
| 19102 |
VirtualRenderer.prototype.getTheme = function () { |
| 19103 |
return this.$themeId; |
| 19104 |
}; |
| 19105 |
VirtualRenderer.prototype.setStyle = function (style, include) { |
| 19106 |
dom.setCssClass(this.container, style, include !== false); |
| 19107 |
}; |
| 19108 |
VirtualRenderer.prototype.unsetStyle = function (style) { |
| 19109 |
dom.removeCssClass(this.container, style); |
| 19110 |
}; |
| 19111 |
VirtualRenderer.prototype.setCursorStyle = function (style) { |
| 19112 |
dom.setStyle(this.scroller.style, "cursor", style); |
| 19113 |
}; |
| 19114 |
VirtualRenderer.prototype.setMouseCursor = function (cursorStyle) { |
| 19115 |
dom.setStyle(this.scroller.style, "cursor", cursorStyle); |
| 19116 |
}; |
| 19117 |
VirtualRenderer.prototype.attachToShadowRoot = function () { |
| 19118 |
dom.importCssString(editorCss, "ace_editor.css", this.container); |
| 19119 |
}; |
| 19120 |
VirtualRenderer.prototype.destroy = function () { |
| 19121 |
this.freeze(); |
| 19122 |
this.$fontMetrics.destroy(); |
| 19123 |
this.$cursorLayer.destroy(); |
| 19124 |
this.removeAllListeners(); |
| 19125 |
this.container.textContent = ""; |
| 19126 |
this.setOption("useResizeObserver", false); |
| 19127 |
}; |
| 19128 |
VirtualRenderer.prototype.$updateCustomScrollbar = function (val) { |
| 19129 |
var _self = this; |
| 19130 |
this.$horizScroll = this.$vScroll = null; |
| 19131 |
this.scrollBarV.element.remove(); |
| 19132 |
this.scrollBarH.element.remove(); |
| 19133 |
if (this.$scrollDecorator) { |
| 19134 |
delete this.$scrollDecorator; |
| 19135 |
} |
| 19136 |
if (val === true) { |
| 19137 |
this.scrollBarV = new VScrollBarCustom(this.container, this); |
| 19138 |
this.scrollBarH = new HScrollBarCustom(this.container, this); |
| 19139 |
this.scrollBarV.setHeight(this.$size.scrollerHeight); |
| 19140 |
this.scrollBarH.setWidth(this.$size.scrollerWidth); |
| 19141 |
this.scrollBarV.addEventListener("scroll", function (e) { |
| 19142 |
if (!_self.$scrollAnimation) |
| 19143 |
_self.session.setScrollTop(e.data - _self.scrollMargin.top); |
| 19144 |
}); |
| 19145 |
this.scrollBarH.addEventListener("scroll", function (e) { |
| 19146 |
if (!_self.$scrollAnimation) |
| 19147 |
_self.session.setScrollLeft(e.data - _self.scrollMargin.left); |
| 19148 |
}); |
| 19149 |
this.$scrollDecorator = new Decorator(this.scrollBarV, this); |
| 19150 |
this.$scrollDecorator.$updateDecorators(); |
| 19151 |
} |
| 19152 |
else { |
| 19153 |
this.scrollBarV = new VScrollBar(this.container, this); |
| 19154 |
this.scrollBarH = new HScrollBar(this.container, this); |
| 19155 |
this.scrollBarV.addEventListener("scroll", function (e) { |
| 19156 |
if (!_self.$scrollAnimation) |
| 19157 |
_self.session.setScrollTop(e.data - _self.scrollMargin.top); |
| 19158 |
}); |
| 19159 |
this.scrollBarH.addEventListener("scroll", function (e) { |
| 19160 |
if (!_self.$scrollAnimation) |
| 19161 |
_self.session.setScrollLeft(e.data - _self.scrollMargin.left); |
| 19162 |
}); |
| 19163 |
} |
| 19164 |
}; |
| 19165 |
VirtualRenderer.prototype.$addResizeObserver = function () { |
| 19166 |
if (!window.ResizeObserver || this.$resizeObserver) |
| 19167 |
return; |
| 19168 |
var self = this; |
| 19169 |
this.$resizeTimer = lang.delayedCall(function () { |
| 19170 |
if (!self.destroyed) |
| 19171 |
self.onResize(); |
| 19172 |
}, 50); |
| 19173 |
this.$resizeObserver = new window.ResizeObserver(function (e) { |
| 19174 |
var w = e[0].contentRect.width; |
| 19175 |
var h = e[0].contentRect.height; |
| 19176 |
if (Math.abs(self.$size.width - w) > 1 |
| 19177 |
|| Math.abs(self.$size.height - h) > 1) { |
| 19178 |
self.$resizeTimer.delay(); |
| 19179 |
} |
| 19180 |
else { |
| 19181 |
self.$resizeTimer.cancel(); |
| 19182 |
} |
| 19183 |
}); |
| 19184 |
this.$resizeObserver.observe(this.container); |
| 19185 |
}; |
| 19186 |
return VirtualRenderer; |
| 19187 |
}()); |
| 19188 |
VirtualRenderer.prototype.CHANGE_CURSOR = 1; |
| 19189 |
VirtualRenderer.prototype.CHANGE_MARKER = 2; |
| 19190 |
VirtualRenderer.prototype.CHANGE_GUTTER = 4; |
| 19191 |
VirtualRenderer.prototype.CHANGE_SCROLL = 8; |
| 19192 |
VirtualRenderer.prototype.CHANGE_LINES = 16; |
| 19193 |
VirtualRenderer.prototype.CHANGE_TEXT = 32; |
| 19194 |
VirtualRenderer.prototype.CHANGE_SIZE = 64; |
| 19195 |
VirtualRenderer.prototype.CHANGE_MARKER_BACK = 128; |
| 19196 |
VirtualRenderer.prototype.CHANGE_MARKER_FRONT = 256; |
| 19197 |
VirtualRenderer.prototype.CHANGE_FULL = 512; |
| 19198 |
VirtualRenderer.prototype.CHANGE_H_SCROLL = 1024; |
| 19199 |
VirtualRenderer.prototype.$changes = 0; |
| 19200 |
VirtualRenderer.prototype.$padding = null; |
| 19201 |
VirtualRenderer.prototype.$frozen = false; |
| 19202 |
VirtualRenderer.prototype.STEPS = 8; |
| 19203 |
oop.implement(VirtualRenderer.prototype, EventEmitter); |
| 19204 |
config.defineOptions(VirtualRenderer.prototype, "renderer", { |
| 19205 |
useResizeObserver: { |
| 19206 |
set: function (value) { |
| 19207 |
if (!value && this.$resizeObserver) { |
| 19208 |
this.$resizeObserver.disconnect(); |
| 19209 |
this.$resizeTimer.cancel(); |
| 19210 |
this.$resizeTimer = this.$resizeObserver = null; |
| 19211 |
} |
| 19212 |
else if (value && !this.$resizeObserver) { |
| 19213 |
this.$addResizeObserver(); |
| 19214 |
} |
| 19215 |
} |
| 19216 |
}, |
| 19217 |
animatedScroll: { initialValue: false }, |
| 19218 |
showInvisibles: { |
| 19219 |
set: function (value) { |
| 19220 |
if (this.$textLayer.setShowInvisibles(value)) |
| 19221 |
this.$loop.schedule(this.CHANGE_TEXT); |
| 19222 |
}, |
| 19223 |
initialValue: false |
| 19224 |
}, |
| 19225 |
showPrintMargin: { |
| 19226 |
set: function () { this.$updatePrintMargin(); }, |
| 19227 |
initialValue: true |
| 19228 |
}, |
| 19229 |
printMarginColumn: { |
| 19230 |
set: function () { this.$updatePrintMargin(); }, |
| 19231 |
initialValue: 80 |
| 19232 |
}, |
| 19233 |
printMargin: { |
| 19234 |
set: function (val) { |
| 19235 |
if (typeof val == "number") |
| 19236 |
this.$printMarginColumn = val; |
| 19237 |
this.$showPrintMargin = !!val; |
| 19238 |
this.$updatePrintMargin(); |
| 19239 |
}, |
| 19240 |
get: function () { |
| 19241 |
return this.$showPrintMargin && this.$printMarginColumn; |
| 19242 |
} |
| 19243 |
}, |
| 19244 |
showGutter: { |
| 19245 |
set: function (show) { |
| 19246 |
this.$gutter.style.display = show ? "block" : "none"; |
| 19247 |
this.$loop.schedule(this.CHANGE_FULL); |
| 19248 |
this.onGutterResize(); |
| 19249 |
}, |
| 19250 |
initialValue: true |
| 19251 |
}, |
| 19252 |
useSvgGutterIcons: { |
| 19253 |
set: function (value) { |
| 19254 |
this.$gutterLayer.$useSvgGutterIcons = value; |
| 19255 |
}, |
| 19256 |
initialValue: false |
| 19257 |
}, |
| 19258 |
showFoldedAnnotations: { |
| 19259 |
set: function (value) { |
| 19260 |
this.$gutterLayer.$showFoldedAnnotations = value; |
| 19261 |
}, |
| 19262 |
initialValue: false |
| 19263 |
}, |
| 19264 |
fadeFoldWidgets: { |
| 19265 |
set: function (show) { |
| 19266 |
dom.setCssClass(this.$gutter, "ace_fade-fold-widgets", show); |
| 19267 |
}, |
| 19268 |
initialValue: false |
| 19269 |
}, |
| 19270 |
showFoldWidgets: { |
| 19271 |
set: function (show) { |
| 19272 |
this.$gutterLayer.setShowFoldWidgets(show); |
| 19273 |
this.$loop.schedule(this.CHANGE_GUTTER); |
| 19274 |
}, |
| 19275 |
initialValue: true |
| 19276 |
}, |
| 19277 |
displayIndentGuides: { |
| 19278 |
set: function (show) { |
| 19279 |
if (this.$textLayer.setDisplayIndentGuides(show)) |
| 19280 |
this.$loop.schedule(this.CHANGE_TEXT); |
| 19281 |
}, |
| 19282 |
initialValue: true |
| 19283 |
}, |
| 19284 |
highlightIndentGuides: { |
| 19285 |
set: function (show) { |
| 19286 |
if (this.$textLayer.setHighlightIndentGuides(show) == true) { |
| 19287 |
this.$textLayer.$highlightIndentGuide(); |
| 19288 |
} |
| 19289 |
else { |
| 19290 |
this.$textLayer.$clearActiveIndentGuide(this.$textLayer.$lines.cells); |
| 19291 |
} |
| 19292 |
}, |
| 19293 |
initialValue: true |
| 19294 |
}, |
| 19295 |
highlightGutterLine: { |
| 19296 |
set: function (shouldHighlight) { |
| 19297 |
this.$gutterLayer.setHighlightGutterLine(shouldHighlight); |
| 19298 |
this.$loop.schedule(this.CHANGE_GUTTER); |
| 19299 |
}, |
| 19300 |
initialValue: true |
| 19301 |
}, |
| 19302 |
hScrollBarAlwaysVisible: { |
| 19303 |
set: function (val) { |
| 19304 |
if (!this.$hScrollBarAlwaysVisible || !this.$horizScroll) |
| 19305 |
this.$loop.schedule(this.CHANGE_SCROLL); |
| 19306 |
}, |
| 19307 |
initialValue: false |
| 19308 |
}, |
| 19309 |
vScrollBarAlwaysVisible: { |
| 19310 |
set: function (val) { |
| 19311 |
if (!this.$vScrollBarAlwaysVisible || !this.$vScroll) |
| 19312 |
this.$loop.schedule(this.CHANGE_SCROLL); |
| 19313 |
}, |
| 19314 |
initialValue: false |
| 19315 |
}, |
| 19316 |
fontSize: { |
| 19317 |
set: function (size) { |
| 19318 |
if (typeof size == "number") |
| 19319 |
size = size + "px"; |
| 19320 |
this.container.style.fontSize = size; |
| 19321 |
this.updateFontSize(); |
| 19322 |
}, |
| 19323 |
initialValue: 12 |
| 19324 |
}, |
| 19325 |
fontFamily: { |
| 19326 |
set: function (name) { |
| 19327 |
this.container.style.fontFamily = name; |
| 19328 |
this.updateFontSize(); |
| 19329 |
} |
| 19330 |
}, |
| 19331 |
maxLines: { |
| 19332 |
set: function (val) { |
| 19333 |
this.updateFull(); |
| 19334 |
} |
| 19335 |
}, |
| 19336 |
minLines: { |
| 19337 |
set: function (val) { |
| 19338 |
if (!(this.$minLines < 0x1ffffffffffff)) |
| 19339 |
this.$minLines = 0; |
| 19340 |
this.updateFull(); |
| 19341 |
} |
| 19342 |
}, |
| 19343 |
maxPixelHeight: { |
| 19344 |
set: function (val) { |
| 19345 |
this.updateFull(); |
| 19346 |
}, |
| 19347 |
initialValue: 0 |
| 19348 |
}, |
| 19349 |
scrollPastEnd: { |
| 19350 |
set: function (val) { |
| 19351 |
val = +val || 0; |
| 19352 |
if (this.$scrollPastEnd == val) |
| 19353 |
return; |
| 19354 |
this.$scrollPastEnd = val; |
| 19355 |
this.$loop.schedule(this.CHANGE_SCROLL); |
| 19356 |
}, |
| 19357 |
initialValue: 0, |
| 19358 |
handlesSet: true |
| 19359 |
}, |
| 19360 |
fixedWidthGutter: { |
| 19361 |
set: function (val) { |
| 19362 |
this.$gutterLayer.$fixedWidth = !!val; |
| 19363 |
this.$loop.schedule(this.CHANGE_GUTTER); |
| 19364 |
} |
| 19365 |
}, |
| 19366 |
customScrollbar: { |
| 19367 |
set: function (val) { |
| 19368 |
this.$updateCustomScrollbar(val); |
| 19369 |
}, |
| 19370 |
initialValue: false |
| 19371 |
}, |
| 19372 |
theme: { |
| 19373 |
set: function (val) { this.setTheme(val); }, |
| 19374 |
get: function () { return this.$themeId || this.theme; }, |
| 19375 |
initialValue: "./theme/textmate", |
| 19376 |
handlesSet: true |
| 19377 |
}, |
| 19378 |
hasCssTransforms: {}, |
| 19379 |
useTextareaForIME: { |
| 19380 |
initialValue: !useragent.isMobile && !useragent.isIE |
| 19381 |
} |
| 19382 |
}); |
| 19383 |
exports.VirtualRenderer = VirtualRenderer; |
| 19384 |
|
| 19385 |
}); |
| 19386 |
|
| 19387 |
ace.define("ace/worker/worker_client",["require","exports","module","ace/lib/oop","ace/lib/net","ace/lib/event_emitter","ace/config"], function(require, exports, module) { |
| 19388 |
"use strict"; |
| 19389 |
|
| 19390 |
var oop = require("../lib/oop"); |
| 19391 |
var net = require("../lib/net"); |
| 19392 |
var EventEmitter = require("../lib/event_emitter").EventEmitter; |
| 19393 |
var config = require("../config"); |
| 19394 |
|
| 19395 |
function $workerBlob(workerUrl) { |
| 19396 |
var script = "importScripts('" + net.qualifyURL(workerUrl) + "');"; |
| 19397 |
try { |
| 19398 |
return new Blob([script], {"type": "application/javascript"}); |
| 19399 |
} catch (e) { |
| 19400 |
var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder; |
| 19401 |
var blobBuilder = new BlobBuilder(); |
| 19402 |
blobBuilder.append(script); |
| 19403 |
return blobBuilder.getBlob("application/javascript"); |
| 19404 |
} |
| 19405 |
} |
| 19406 |
|
| 19407 |
function createWorker(workerUrl) { |
| 19408 |
if (typeof Worker == "undefined") |
| 19409 |
return { postMessage: function() {}, terminate: function() {} }; |
| 19410 |
if (config.get("loadWorkerFromBlob")) { |
| 19411 |
var blob = $workerBlob(workerUrl); |
| 19412 |
var URL = window.URL || window.webkitURL; |
| 19413 |
var blobURL = URL.createObjectURL(blob); |
| 19414 |
return new Worker(blobURL); |
| 19415 |
} |
| 19416 |
return new Worker(workerUrl); |
| 19417 |
} |
| 19418 |
|
| 19419 |
var WorkerClient = function(worker) { |
| 19420 |
if (!worker.postMessage) |
| 19421 |
worker = this.$createWorkerFromOldConfig.apply(this, arguments); |
| 19422 |
|
| 19423 |
this.$worker = worker; |
| 19424 |
this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this); |
| 19425 |
this.changeListener = this.changeListener.bind(this); |
| 19426 |
this.onMessage = this.onMessage.bind(this); |
| 19427 |
|
| 19428 |
this.callbackId = 1; |
| 19429 |
this.callbacks = {}; |
| 19430 |
|
| 19431 |
this.$worker.onmessage = this.onMessage; |
| 19432 |
}; |
| 19433 |
|
| 19434 |
(function(){ |
| 19435 |
|
| 19436 |
oop.implement(this, EventEmitter); |
| 19437 |
|
| 19438 |
this.$createWorkerFromOldConfig = function(topLevelNamespaces, mod, classname, workerUrl, importScripts) { |
| 19439 |
if (require.nameToUrl && !require.toUrl) |
| 19440 |
require.toUrl = require.nameToUrl; |
| 19441 |
|
| 19442 |
if (config.get("packaged") || !require.toUrl) { |
| 19443 |
workerUrl = workerUrl || config.moduleUrl(mod, "worker"); |
| 19444 |
} else { |
| 19445 |
var normalizePath = this.$normalizePath; |
| 19446 |
workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_")); |
| 19447 |
|
| 19448 |
var tlns = {}; |
| 19449 |
topLevelNamespaces.forEach(function(ns) { |
| 19450 |
tlns[ns] = normalizePath(require.toUrl(ns, null, "_").replace(/(\.js)?(\?.*)?$/, "")); |
| 19451 |
}); |
| 19452 |
} |
| 19453 |
|
| 19454 |
this.$worker = createWorker(workerUrl); |
| 19455 |
if (importScripts) { |
| 19456 |
this.send("importScripts", importScripts); |
| 19457 |
} |
| 19458 |
this.$worker.postMessage({ |
| 19459 |
init : true, |
| 19460 |
tlns : tlns, |
| 19461 |
module : mod, |
| 19462 |
classname : classname |
| 19463 |
}); |
| 19464 |
return this.$worker; |
| 19465 |
}; |
| 19466 |
|
| 19467 |
this.onMessage = function(e) { |
| 19468 |
var msg = e.data; |
| 19469 |
switch (msg.type) { |
| 19470 |
case "event": |
| 19471 |
this._signal(msg.name, {data: msg.data}); |
| 19472 |
break; |
| 19473 |
case "call": |
| 19474 |
var callback = this.callbacks[msg.id]; |
| 19475 |
if (callback) { |
| 19476 |
callback(msg.data); |
| 19477 |
delete this.callbacks[msg.id]; |
| 19478 |
} |
| 19479 |
break; |
| 19480 |
case "error": |
| 19481 |
this.reportError(msg.data); |
| 19482 |
break; |
| 19483 |
case "log": |
| 19484 |
window.console && console.log && console.log.apply(console, msg.data); |
| 19485 |
break; |
| 19486 |
} |
| 19487 |
}; |
| 19488 |
|
| 19489 |
this.reportError = function(err) { |
| 19490 |
window.console && console.error && console.error(err); |
| 19491 |
}; |
| 19492 |
|
| 19493 |
this.$normalizePath = function(path) { |
| 19494 |
return net.qualifyURL(path); |
| 19495 |
}; |
| 19496 |
|
| 19497 |
this.terminate = function() { |
| 19498 |
this._signal("terminate", {}); |
| 19499 |
this.deltaQueue = null; |
| 19500 |
this.$worker.terminate(); |
| 19501 |
this.$worker.onerror = function(e) { |
| 19502 |
e.preventDefault(); |
| 19503 |
}; |
| 19504 |
this.$worker = null; |
| 19505 |
if (this.$doc) |
| 19506 |
this.$doc.off("change", this.changeListener); |
| 19507 |
this.$doc = null; |
| 19508 |
}; |
| 19509 |
|
| 19510 |
this.send = function(cmd, args) { |
| 19511 |
this.$worker.postMessage({command: cmd, args: args}); |
| 19512 |
}; |
| 19513 |
|
| 19514 |
this.call = function(cmd, args, callback) { |
| 19515 |
if (callback) { |
| 19516 |
var id = this.callbackId++; |
| 19517 |
this.callbacks[id] = callback; |
| 19518 |
args.push(id); |
| 19519 |
} |
| 19520 |
this.send(cmd, args); |
| 19521 |
}; |
| 19522 |
|
| 19523 |
this.emit = function(event, data) { |
| 19524 |
try { |
| 19525 |
if (data.data && data.data.err) |
| 19526 |
data.data.err = {message: data.data.err.message, stack: data.data.err.stack, code: data.data.err.code}; |
| 19527 |
this.$worker && this.$worker.postMessage({event: event, data: {data: data.data}}); |
| 19528 |
} |
| 19529 |
catch(ex) { |
| 19530 |
console.error(ex.stack); |
| 19531 |
} |
| 19532 |
}; |
| 19533 |
|
| 19534 |
this.attachToDocument = function(doc) { |
| 19535 |
if (this.$doc) |
| 19536 |
this.terminate(); |
| 19537 |
|
| 19538 |
this.$doc = doc; |
| 19539 |
this.call("setValue", [doc.getValue()]); |
| 19540 |
doc.on("change", this.changeListener, true); |
| 19541 |
}; |
| 19542 |
|
| 19543 |
this.changeListener = function(delta) { |
| 19544 |
if (!this.deltaQueue) { |
| 19545 |
this.deltaQueue = []; |
| 19546 |
setTimeout(this.$sendDeltaQueue, 0); |
| 19547 |
} |
| 19548 |
if (delta.action == "insert") |
| 19549 |
this.deltaQueue.push(delta.start, delta.lines); |
| 19550 |
else |
| 19551 |
this.deltaQueue.push(delta.start, delta.end); |
| 19552 |
}; |
| 19553 |
|
| 19554 |
this.$sendDeltaQueue = function() { |
| 19555 |
var q = this.deltaQueue; |
| 19556 |
if (!q) return; |
| 19557 |
this.deltaQueue = null; |
| 19558 |
if (q.length > 50 && q.length > this.$doc.getLength() >> 1) { |
| 19559 |
this.call("setValue", [this.$doc.getValue()]); |
| 19560 |
} else |
| 19561 |
this.emit("change", {data: q}); |
| 19562 |
}; |
| 19563 |
|
| 19564 |
}).call(WorkerClient.prototype); |
| 19565 |
|
| 19566 |
|
| 19567 |
var UIWorkerClient = function(topLevelNamespaces, mod, classname) { |
| 19568 |
var main = null; |
| 19569 |
var emitSync = false; |
| 19570 |
var sender = Object.create(EventEmitter); |
| 19571 |
|
| 19572 |
var messageBuffer = []; |
| 19573 |
var workerClient = new WorkerClient({ |
| 19574 |
messageBuffer: messageBuffer, |
| 19575 |
terminate: function() {}, |
| 19576 |
postMessage: function(e) { |
| 19577 |
messageBuffer.push(e); |
| 19578 |
if (!main) return; |
| 19579 |
if (emitSync) |
| 19580 |
setTimeout(processNext); |
| 19581 |
else |
| 19582 |
processNext(); |
| 19583 |
} |
| 19584 |
}); |
| 19585 |
|
| 19586 |
workerClient.setEmitSync = function(val) { emitSync = val; }; |
| 19587 |
|
| 19588 |
var processNext = function() { |
| 19589 |
var msg = messageBuffer.shift(); |
| 19590 |
if (msg.command) |
| 19591 |
main[msg.command].apply(main, msg.args); |
| 19592 |
else if (msg.event) |
| 19593 |
sender._signal(msg.event, msg.data); |
| 19594 |
}; |
| 19595 |
|
| 19596 |
sender.postMessage = function(msg) { |
| 19597 |
workerClient.onMessage({data: msg}); |
| 19598 |
}; |
| 19599 |
sender.callback = function(data, callbackId) { |
| 19600 |
this.postMessage({type: "call", id: callbackId, data: data}); |
| 19601 |
}; |
| 19602 |
sender.emit = function(name, data) { |
| 19603 |
this.postMessage({type: "event", name: name, data: data}); |
| 19604 |
}; |
| 19605 |
|
| 19606 |
config.loadModule(["worker", mod], function(Main) { |
| 19607 |
main = new Main[classname](sender); |
| 19608 |
while (messageBuffer.length) |
| 19609 |
processNext(); |
| 19610 |
}); |
| 19611 |
|
| 19612 |
return workerClient; |
| 19613 |
}; |
| 19614 |
|
| 19615 |
exports.UIWorkerClient = UIWorkerClient; |
| 19616 |
exports.WorkerClient = WorkerClient; |
| 19617 |
exports.createWorker = createWorker; |
| 19618 |
|
| 19619 |
|
| 19620 |
}); |
| 19621 |
|
| 19622 |
ace.define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"], function(require, exports, module){"use strict"; |
| 19623 |
var Range = require("./range").Range; |
| 19624 |
var EventEmitter = require("./lib/event_emitter").EventEmitter; |
| 19625 |
var oop = require("./lib/oop"); |
| 19626 |
var PlaceHolder = (function () { |
| 19627 |
function PlaceHolder(session, length, pos, others, mainClass, othersClass) { |
| 19628 |
var _self = this; |
| 19629 |
this.length = length; |
| 19630 |
this.session = session; |
| 19631 |
this.doc = session.getDocument(); |
| 19632 |
this.mainClass = mainClass; |
| 19633 |
this.othersClass = othersClass; |
| 19634 |
this.$onUpdate = this.onUpdate.bind(this); |
| 19635 |
this.doc.on("change", this.$onUpdate, true); |
| 19636 |
this.$others = others; |
| 19637 |
this.$onCursorChange = function () { |
| 19638 |
setTimeout(function () { |
| 19639 |
_self.onCursorChange(); |
| 19640 |
}); |
| 19641 |
}; |
| 19642 |
this.$pos = pos; |
| 19643 |
var undoStack = session.getUndoManager().$undoStack || session.getUndoManager()["$undostack"] || { length: -1 }; |
| 19644 |
this.$undoStackDepth = undoStack.length; |
| 19645 |
this.setup(); |
| 19646 |
session.selection.on("changeCursor", this.$onCursorChange); |
| 19647 |
} |
| 19648 |
PlaceHolder.prototype.setup = function () { |
| 19649 |
var _self = this; |
| 19650 |
var doc = this.doc; |
| 19651 |
var session = this.session; |
| 19652 |
this.selectionBefore = session.selection.toJSON(); |
| 19653 |
if (session.selection.inMultiSelectMode) |
| 19654 |
session.selection.toSingleRange(); |
| 19655 |
this.pos = doc.createAnchor(this.$pos.row, this.$pos.column); |
| 19656 |
var pos = this.pos; |
| 19657 |
pos.$insertRight = true; |
| 19658 |
pos.detach(); |
| 19659 |
pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false); |
| 19660 |
this.others = []; |
| 19661 |
this.$others.forEach(function (other) { |
| 19662 |
var anchor = doc.createAnchor(other.row, other.column); |
| 19663 |
anchor.$insertRight = true; |
| 19664 |
anchor.detach(); |
| 19665 |
_self.others.push(anchor); |
| 19666 |
}); |
| 19667 |
session.setUndoSelect(false); |
| 19668 |
}; |
| 19669 |
PlaceHolder.prototype.showOtherMarkers = function () { |
| 19670 |
if (this.othersActive) |
| 19671 |
return; |
| 19672 |
var session = this.session; |
| 19673 |
var _self = this; |
| 19674 |
this.othersActive = true; |
| 19675 |
this.others.forEach(function (anchor) { |
| 19676 |
anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column + _self.length), _self.othersClass, null, false); |
| 19677 |
}); |
| 19678 |
}; |
| 19679 |
PlaceHolder.prototype.hideOtherMarkers = function () { |
| 19680 |
if (!this.othersActive) |
| 19681 |
return; |
| 19682 |
this.othersActive = false; |
| 19683 |
for (var i = 0; i < this.others.length; i++) { |
| 19684 |
this.session.removeMarker(this.others[i].markerId); |
| 19685 |
} |
| 19686 |
}; |
| 19687 |
PlaceHolder.prototype.onUpdate = function (delta) { |
| 19688 |
if (this.$updating) |
| 19689 |
return this.updateAnchors(delta); |
| 19690 |
var range = delta; |
| 19691 |
if (range.start.row !== range.end.row) |
| 19692 |
return; |
| 19693 |
if (range.start.row !== this.pos.row) |
| 19694 |
return; |
| 19695 |
this.$updating = true; |
| 19696 |
var lengthDiff = delta.action === "insert" ? range.end.column - range.start.column : range.start.column - range.end.column; |
| 19697 |
var inMainRange = range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1; |
| 19698 |
var distanceFromStart = range.start.column - this.pos.column; |
| 19699 |
this.updateAnchors(delta); |
| 19700 |
if (inMainRange) |
| 19701 |
this.length += lengthDiff; |
| 19702 |
if (inMainRange && !this.session.$fromUndo) { |
| 19703 |
if (delta.action === 'insert') { |
| 19704 |
for (var i = this.others.length - 1; i >= 0; i--) { |
| 19705 |
var otherPos = this.others[i]; |
| 19706 |
var newPos = { row: otherPos.row, column: otherPos.column + distanceFromStart }; |
| 19707 |
this.doc.insertMergedLines(newPos, delta.lines); |
| 19708 |
} |
| 19709 |
} |
| 19710 |
else if (delta.action === 'remove') { |
| 19711 |
for (var i = this.others.length - 1; i >= 0; i--) { |
| 19712 |
var otherPos = this.others[i]; |
| 19713 |
var newPos = { row: otherPos.row, column: otherPos.column + distanceFromStart }; |
| 19714 |
this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff)); |
| 19715 |
} |
| 19716 |
} |
| 19717 |
} |
| 19718 |
this.$updating = false; |
| 19719 |
this.updateMarkers(); |
| 19720 |
}; |
| 19721 |
PlaceHolder.prototype.updateAnchors = function (delta) { |
| 19722 |
this.pos.onChange(delta); |
| 19723 |
for (var i = this.others.length; i--;) |
| 19724 |
this.others[i].onChange(delta); |
| 19725 |
this.updateMarkers(); |
| 19726 |
}; |
| 19727 |
PlaceHolder.prototype.updateMarkers = function () { |
| 19728 |
if (this.$updating) |
| 19729 |
return; |
| 19730 |
var _self = this; |
| 19731 |
var session = this.session; |
| 19732 |
var updateMarker = function (pos, className) { |
| 19733 |
session.removeMarker(pos.markerId); |
| 19734 |
pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + _self.length), className, null, false); |
| 19735 |
}; |
| 19736 |
updateMarker(this.pos, this.mainClass); |
| 19737 |
for (var i = this.others.length; i--;) |
| 19738 |
updateMarker(this.others[i], this.othersClass); |
| 19739 |
}; |
| 19740 |
PlaceHolder.prototype.onCursorChange = function (event) { |
| 19741 |
if (this.$updating || !this.session) |
| 19742 |
return; |
| 19743 |
var pos = this.session.selection.getCursor(); |
| 19744 |
if (pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) { |
| 19745 |
this.showOtherMarkers(); |
| 19746 |
this._emit("cursorEnter", event); |
| 19747 |
} |
| 19748 |
else { |
| 19749 |
this.hideOtherMarkers(); |
| 19750 |
this._emit("cursorLeave", event); |
| 19751 |
} |
| 19752 |
}; |
| 19753 |
PlaceHolder.prototype.detach = function () { |
| 19754 |
this.session.removeMarker(this.pos && this.pos.markerId); |
| 19755 |
this.hideOtherMarkers(); |
| 19756 |
this.doc.off("change", this.$onUpdate); |
| 19757 |
this.session.selection.off("changeCursor", this.$onCursorChange); |
| 19758 |
this.session.setUndoSelect(true); |
| 19759 |
this.session = null; |
| 19760 |
}; |
| 19761 |
PlaceHolder.prototype.cancel = function () { |
| 19762 |
if (this.$undoStackDepth === -1) |
| 19763 |
return; |
| 19764 |
var undoManager = this.session.getUndoManager(); |
| 19765 |
var undosRequired = (undoManager.$undoStack || undoManager["$undostack"]).length - this.$undoStackDepth; |
| 19766 |
for (var i = 0; i < undosRequired; i++) { |
| 19767 |
undoManager.undo(this.session, true); |
| 19768 |
} |
| 19769 |
if (this.selectionBefore) |
| 19770 |
this.session.selection.fromJSON(this.selectionBefore); |
| 19771 |
}; |
| 19772 |
return PlaceHolder; |
| 19773 |
}()); |
| 19774 |
oop.implement(PlaceHolder.prototype, EventEmitter); |
| 19775 |
exports.PlaceHolder = PlaceHolder; |
| 19776 |
|
| 19777 |
}); |
| 19778 |
|
| 19779 |
ace.define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module){var event = require("../lib/event"); |
| 19780 |
var useragent = require("../lib/useragent"); |
| 19781 |
function isSamePoint(p1, p2) { |
| 19782 |
return p1.row == p2.row && p1.column == p2.column; |
| 19783 |
} |
| 19784 |
function onMouseDown(e) { |
| 19785 |
var ev = e.domEvent; |
| 19786 |
var alt = ev.altKey; |
| 19787 |
var shift = ev.shiftKey; |
| 19788 |
var ctrl = ev.ctrlKey; |
| 19789 |
var accel = e.getAccelKey(); |
| 19790 |
var button = e.getButton(); |
| 19791 |
if (ctrl && useragent.isMac) |
| 19792 |
button = ev.button; |
| 19793 |
if (e.editor.inMultiSelectMode && button == 2) { |
| 19794 |
e.editor.textInput.onContextMenu(e.domEvent); |
| 19795 |
return; |
| 19796 |
} |
| 19797 |
if (!ctrl && !alt && !accel) { |
| 19798 |
if (button === 0 && e.editor.inMultiSelectMode) |
| 19799 |
e.editor.exitMultiSelectMode(); |
| 19800 |
return; |
| 19801 |
} |
| 19802 |
if (button !== 0) |
| 19803 |
return; |
| 19804 |
var editor = e.editor; |
| 19805 |
var selection = editor.selection; |
| 19806 |
var isMultiSelect = editor.inMultiSelectMode; |
| 19807 |
var pos = e.getDocumentPosition(); |
| 19808 |
var cursor = selection.getCursor(); |
| 19809 |
var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor)); |
| 19810 |
var mouseX = e.x, mouseY = e.y; |
| 19811 |
var onMouseSelection = function (e) { |
| 19812 |
mouseX = e.clientX; |
| 19813 |
mouseY = e.clientY; |
| 19814 |
}; |
| 19815 |
var session = editor.session; |
| 19816 |
var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY); |
| 19817 |
var screenCursor = screenAnchor; |
| 19818 |
var selectionMode; |
| 19819 |
if (editor.$mouseHandler.$enableJumpToDef) { |
| 19820 |
if (ctrl && alt || accel && alt) |
| 19821 |
selectionMode = shift ? "block" : "add"; |
| 19822 |
else if (alt && editor.$blockSelectEnabled) |
| 19823 |
selectionMode = "block"; |
| 19824 |
} |
| 19825 |
else { |
| 19826 |
if (accel && !alt) { |
| 19827 |
selectionMode = "add"; |
| 19828 |
if (!isMultiSelect && shift) |
| 19829 |
return; |
| 19830 |
} |
| 19831 |
else if (alt && editor.$blockSelectEnabled) { |
| 19832 |
selectionMode = "block"; |
| 19833 |
} |
| 19834 |
} |
| 19835 |
if (selectionMode && useragent.isMac && ev.ctrlKey) { |
| 19836 |
editor.$mouseHandler.cancelContextMenu(); |
| 19837 |
} |
| 19838 |
if (selectionMode == "add") { |
| 19839 |
if (!isMultiSelect && inSelection) |
| 19840 |
return; |
| 19841 |
if (!isMultiSelect) { |
| 19842 |
var range = selection.toOrientedRange(); |
| 19843 |
editor.addSelectionMarker(range); |
| 19844 |
} |
| 19845 |
var oldRange = selection.rangeList.rangeAtPoint(pos); |
| 19846 |
editor.inVirtualSelectionMode = true; |
| 19847 |
if (shift) { |
| 19848 |
oldRange = null; |
| 19849 |
range = selection.ranges[0] || range; |
| 19850 |
editor.removeSelectionMarker(range); |
| 19851 |
} |
| 19852 |
editor.once("mouseup", function () { |
| 19853 |
var tmpSel = selection.toOrientedRange(); |
| 19854 |
if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor)) |
| 19855 |
selection.substractPoint(tmpSel.cursor); |
| 19856 |
else { |
| 19857 |
if (shift) { |
| 19858 |
selection.substractPoint(range.cursor); |
| 19859 |
} |
| 19860 |
else if (range) { |
| 19861 |
editor.removeSelectionMarker(range); |
| 19862 |
selection.addRange(range); |
| 19863 |
} |
| 19864 |
selection.addRange(tmpSel); |
| 19865 |
} |
| 19866 |
editor.inVirtualSelectionMode = false; |
| 19867 |
}); |
| 19868 |
} |
| 19869 |
else if (selectionMode == "block") { |
| 19870 |
e.stop(); |
| 19871 |
editor.inVirtualSelectionMode = true; |
| 19872 |
var initialRange; |
| 19873 |
var rectSel = []; |
| 19874 |
var blockSelect = function () { |
| 19875 |
var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY); |
| 19876 |
var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column, newCursor.offsetX); |
| 19877 |
if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead)) |
| 19878 |
return; |
| 19879 |
screenCursor = newCursor; |
| 19880 |
editor.selection.moveToPosition(cursor); |
| 19881 |
editor.renderer.scrollCursorIntoView(); |
| 19882 |
editor.removeSelectionMarkers(rectSel); |
| 19883 |
rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor); |
| 19884 |
if (editor.$mouseHandler.$clickSelection && rectSel.length == 1 && rectSel[0].isEmpty()) |
| 19885 |
rectSel[0] = editor.$mouseHandler.$clickSelection.clone(); |
| 19886 |
rectSel.forEach(editor.addSelectionMarker, editor); |
| 19887 |
editor.updateSelectionMarkers(); |
| 19888 |
}; |
| 19889 |
if (isMultiSelect && !accel) { |
| 19890 |
selection.toSingleRange(); |
| 19891 |
} |
| 19892 |
else if (!isMultiSelect && accel) { |
| 19893 |
initialRange = selection.toOrientedRange(); |
| 19894 |
editor.addSelectionMarker(initialRange); |
| 19895 |
} |
| 19896 |
if (shift) |
| 19897 |
screenAnchor = session.documentToScreenPosition(selection.lead); |
| 19898 |
else |
| 19899 |
selection.moveToPosition(pos); |
| 19900 |
screenCursor = { row: -1, column: -1 }; |
| 19901 |
var onMouseSelectionEnd = function (e) { |
| 19902 |
blockSelect(); |
| 19903 |
clearInterval(timerId); |
| 19904 |
editor.removeSelectionMarkers(rectSel); |
| 19905 |
if (!rectSel.length) |
| 19906 |
rectSel = [selection.toOrientedRange()]; |
| 19907 |
if (initialRange) { |
| 19908 |
editor.removeSelectionMarker(initialRange); |
| 19909 |
selection.toSingleRange(initialRange); |
| 19910 |
} |
| 19911 |
for (var i = 0; i < rectSel.length; i++) |
| 19912 |
selection.addRange(rectSel[i]); |
| 19913 |
editor.inVirtualSelectionMode = false; |
| 19914 |
editor.$mouseHandler.$clickSelection = null; |
| 19915 |
}; |
| 19916 |
var onSelectionInterval = blockSelect; |
| 19917 |
event.capture(editor.container, onMouseSelection, onMouseSelectionEnd); |
| 19918 |
var timerId = setInterval(function () { onSelectionInterval(); }, 20); |
| 19919 |
return e.preventDefault(); |
| 19920 |
} |
| 19921 |
} |
| 19922 |
exports.onMouseDown = onMouseDown; |
| 19923 |
|
| 19924 |
}); |
| 19925 |
|
| 19926 |
ace.define("ace/commands/multi_select_commands",["require","exports","module","ace/keyboard/hash_handler"], function(require, exports, module){ |
| 19927 |
|
| 19928 |
|
| 19929 |
|
| 19930 |
exports.defaultCommands = [{ |
| 19931 |
name: "addCursorAbove", |
| 19932 |
description: "Add cursor above", |
| 19933 |
exec: function (editor) { editor.selectMoreLines(-1); }, |
| 19934 |
bindKey: { win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up" }, |
| 19935 |
scrollIntoView: "cursor", |
| 19936 |
readOnly: true |
| 19937 |
}, { |
| 19938 |
name: "addCursorBelow", |
| 19939 |
description: "Add cursor below", |
| 19940 |
exec: function (editor) { editor.selectMoreLines(1); }, |
| 19941 |
bindKey: { win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down" }, |
| 19942 |
scrollIntoView: "cursor", |
| 19943 |
readOnly: true |
| 19944 |
}, { |
| 19945 |
name: "addCursorAboveSkipCurrent", |
| 19946 |
description: "Add cursor above (skip current)", |
| 19947 |
exec: function (editor) { editor.selectMoreLines(-1, true); }, |
| 19948 |
bindKey: { win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up" }, |
| 19949 |
scrollIntoView: "cursor", |
| 19950 |
readOnly: true |
| 19951 |
}, { |
| 19952 |
name: "addCursorBelowSkipCurrent", |
| 19953 |
description: "Add cursor below (skip current)", |
| 19954 |
exec: function (editor) { editor.selectMoreLines(1, true); }, |
| 19955 |
bindKey: { win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down" }, |
| 19956 |
scrollIntoView: "cursor", |
| 19957 |
readOnly: true |
| 19958 |
}, { |
| 19959 |
name: "selectMoreBefore", |
| 19960 |
description: "Select more before", |
| 19961 |
exec: function (editor) { editor.selectMore(-1); }, |
| 19962 |
bindKey: { win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left" }, |
| 19963 |
scrollIntoView: "cursor", |
| 19964 |
readOnly: true |
| 19965 |
}, { |
| 19966 |
name: "selectMoreAfter", |
| 19967 |
description: "Select more after", |
| 19968 |
exec: function (editor) { editor.selectMore(1); }, |
| 19969 |
bindKey: { win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right" }, |
| 19970 |
scrollIntoView: "cursor", |
| 19971 |
readOnly: true |
| 19972 |
}, { |
| 19973 |
name: "selectNextBefore", |
| 19974 |
description: "Select next before", |
| 19975 |
exec: function (editor) { editor.selectMore(-1, true); }, |
| 19976 |
bindKey: { win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left" }, |
| 19977 |
scrollIntoView: "cursor", |
| 19978 |
readOnly: true |
| 19979 |
}, { |
| 19980 |
name: "selectNextAfter", |
| 19981 |
description: "Select next after", |
| 19982 |
exec: function (editor) { editor.selectMore(1, true); }, |
| 19983 |
bindKey: { win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right" }, |
| 19984 |
scrollIntoView: "cursor", |
| 19985 |
readOnly: true |
| 19986 |
}, { |
| 19987 |
name: "toggleSplitSelectionIntoLines", |
| 19988 |
description: "Split selection into lines", |
| 19989 |
exec: function (editor) { |
| 19990 |
if (editor.multiSelect.rangeCount > 1) |
| 19991 |
editor.multiSelect.joinSelections(); |
| 19992 |
else |
| 19993 |
editor.multiSelect.splitIntoLines(); |
| 19994 |
}, |
| 19995 |
bindKey: { win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L" }, |
| 19996 |
readOnly: true |
| 19997 |
}, { |
| 19998 |
name: "splitSelectionIntoLines", |
| 19999 |
description: "Split into lines", |
| 20000 |
exec: function (editor) { editor.multiSelect.splitIntoLines(); }, |
| 20001 |
readOnly: true |
| 20002 |
}, { |
| 20003 |
name: "alignCursors", |
| 20004 |
description: "Align cursors", |
| 20005 |
exec: function (editor) { editor.alignCursors(); }, |
| 20006 |
bindKey: { win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A" }, |
| 20007 |
scrollIntoView: "cursor" |
| 20008 |
}, { |
| 20009 |
name: "findAll", |
| 20010 |
description: "Find all", |
| 20011 |
exec: function (editor) { editor.findAll(); }, |
| 20012 |
bindKey: { win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G" }, |
| 20013 |
scrollIntoView: "cursor", |
| 20014 |
readOnly: true |
| 20015 |
}]; |
| 20016 |
exports.multiSelectCommands = [{ |
| 20017 |
name: "singleSelection", |
| 20018 |
description: "Single selection", |
| 20019 |
bindKey: "esc", |
| 20020 |
exec: function (editor) { editor.exitMultiSelectMode(); }, |
| 20021 |
scrollIntoView: "cursor", |
| 20022 |
readOnly: true, |
| 20023 |
isAvailable: function (editor) { return editor && editor.inMultiSelectMode; } |
| 20024 |
}]; |
| 20025 |
var HashHandler = require("../keyboard/hash_handler").HashHandler; |
| 20026 |
exports.keyboardHandler = new HashHandler(exports.multiSelectCommands); |
| 20027 |
|
| 20028 |
}); |
| 20029 |
|
| 20030 |
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){ |
| 20031 |
|
| 20032 |
|
| 20033 |
|
| 20034 |
|
| 20035 |
var RangeList = require("./range_list").RangeList; |
| 20036 |
var Range = require("./range").Range; |
| 20037 |
var Selection = require("./selection").Selection; |
| 20038 |
var onMouseDown = require("./mouse/multi_select_handler").onMouseDown; |
| 20039 |
var event = require("./lib/event"); |
| 20040 |
var lang = require("./lib/lang"); |
| 20041 |
var commands = require("./commands/multi_select_commands"); |
| 20042 |
exports.commands = commands.defaultCommands.concat(commands.multiSelectCommands); |
| 20043 |
var Search = require("./search").Search; |
| 20044 |
var search = new Search(); |
| 20045 |
function find(session, needle, dir) { |
| 20046 |
search.$options.wrap = true; |
| 20047 |
search.$options.needle = needle; |
| 20048 |
search.$options.backwards = dir == -1; |
| 20049 |
return search.find(session); |
| 20050 |
} |
| 20051 |
var EditSession = require("./edit_session").EditSession; |
| 20052 |
(function () { |
| 20053 |
this.getSelectionMarkers = function () { |
| 20054 |
return this.$selectionMarkers; |
| 20055 |
}; |
| 20056 |
}).call(EditSession.prototype); |
| 20057 |
(function () { |
| 20058 |
this.ranges = null; |
| 20059 |
this.rangeList = null; |
| 20060 |
this.addRange = function (range, $blockChangeEvents) { |
| 20061 |
if (!range) |
| 20062 |
return; |
| 20063 |
if (!this.inMultiSelectMode && this.rangeCount === 0) { |
| 20064 |
var oldRange = this.toOrientedRange(); |
| 20065 |
this.rangeList.add(oldRange); |
| 20066 |
this.rangeList.add(range); |
| 20067 |
if (this.rangeList.ranges.length != 2) { |
| 20068 |
this.rangeList.removeAll(); |
| 20069 |
return $blockChangeEvents || this.fromOrientedRange(range); |
| 20070 |
} |
| 20071 |
this.rangeList.removeAll(); |
| 20072 |
this.rangeList.add(oldRange); |
| 20073 |
this.$onAddRange(oldRange); |
| 20074 |
} |
| 20075 |
if (!range.cursor) |
| 20076 |
range.cursor = range.end; |
| 20077 |
var removed = this.rangeList.add(range); |
| 20078 |
this.$onAddRange(range); |
| 20079 |
if (removed.length) |
| 20080 |
this.$onRemoveRange(removed); |
| 20081 |
if (this.rangeCount > 1 && !this.inMultiSelectMode) { |
| 20082 |
this._signal("multiSelect"); |
| 20083 |
this.inMultiSelectMode = true; |
| 20084 |
this.session.$undoSelect = false; |
| 20085 |
this.rangeList.attach(this.session); |
| 20086 |
} |
| 20087 |
return $blockChangeEvents || this.fromOrientedRange(range); |
| 20088 |
}; |
| 20089 |
this.toSingleRange = function (range) { |
| 20090 |
range = range || this.ranges[0]; |
| 20091 |
var removed = this.rangeList.removeAll(); |
| 20092 |
if (removed.length) |
| 20093 |
this.$onRemoveRange(removed); |
| 20094 |
range && this.fromOrientedRange(range); |
| 20095 |
}; |
| 20096 |
this.substractPoint = function (pos) { |
| 20097 |
var removed = this.rangeList.substractPoint(pos); |
| 20098 |
if (removed) { |
| 20099 |
this.$onRemoveRange(removed); |
| 20100 |
return removed[0]; |
| 20101 |
} |
| 20102 |
}; |
| 20103 |
this.mergeOverlappingRanges = function () { |
| 20104 |
var removed = this.rangeList.merge(); |
| 20105 |
if (removed.length) |
| 20106 |
this.$onRemoveRange(removed); |
| 20107 |
}; |
| 20108 |
this.$onAddRange = function (range) { |
| 20109 |
this.rangeCount = this.rangeList.ranges.length; |
| 20110 |
this.ranges.unshift(range); |
| 20111 |
this._signal("addRange", { range: range }); |
| 20112 |
}; |
| 20113 |
this.$onRemoveRange = function (removed) { |
| 20114 |
this.rangeCount = this.rangeList.ranges.length; |
| 20115 |
if (this.rangeCount == 1 && this.inMultiSelectMode) { |
| 20116 |
var lastRange = this.rangeList.ranges.pop(); |
| 20117 |
removed.push(lastRange); |
| 20118 |
this.rangeCount = 0; |
| 20119 |
} |
| 20120 |
for (var i = removed.length; i--;) { |
| 20121 |
var index = this.ranges.indexOf(removed[i]); |
| 20122 |
this.ranges.splice(index, 1); |
| 20123 |
} |
| 20124 |
this._signal("removeRange", { ranges: removed }); |
| 20125 |
if (this.rangeCount === 0 && this.inMultiSelectMode) { |
| 20126 |
this.inMultiSelectMode = false; |
| 20127 |
this._signal("singleSelect"); |
| 20128 |
this.session.$undoSelect = true; |
| 20129 |
this.rangeList.detach(this.session); |
| 20130 |
} |
| 20131 |
lastRange = lastRange || this.ranges[0]; |
| 20132 |
if (lastRange && !lastRange.isEqual(this.getRange())) |
| 20133 |
this.fromOrientedRange(lastRange); |
| 20134 |
}; |
| 20135 |
this.$initRangeList = function () { |
| 20136 |
if (this.rangeList) |
| 20137 |
return; |
| 20138 |
this.rangeList = new RangeList(); |
| 20139 |
this.ranges = []; |
| 20140 |
this.rangeCount = 0; |
| 20141 |
}; |
| 20142 |
this.getAllRanges = function () { |
| 20143 |
return this.rangeCount ? this.rangeList.ranges.concat() : [this.getRange()]; |
| 20144 |
}; |
| 20145 |
this.splitIntoLines = function () { |
| 20146 |
var ranges = this.ranges.length ? this.ranges : [this.getRange()]; |
| 20147 |
var newRanges = []; |
| 20148 |
for (var i = 0; i < ranges.length; i++) { |
| 20149 |
var range = ranges[i]; |
| 20150 |
var row = range.start.row; |
| 20151 |
var endRow = range.end.row; |
| 20152 |
if (row === endRow) { |
| 20153 |
newRanges.push(range.clone()); |
| 20154 |
} |
| 20155 |
else { |
| 20156 |
newRanges.push(new Range(row, range.start.column, row, this.session.getLine(row).length)); |
| 20157 |
while (++row < endRow) |
| 20158 |
newRanges.push(this.getLineRange(row, true)); |
| 20159 |
newRanges.push(new Range(endRow, 0, endRow, range.end.column)); |
| 20160 |
} |
| 20161 |
if (i == 0 && !this.isBackwards()) |
| 20162 |
newRanges = newRanges.reverse(); |
| 20163 |
} |
| 20164 |
this.toSingleRange(); |
| 20165 |
for (var i = newRanges.length; i--;) |
| 20166 |
this.addRange(newRanges[i]); |
| 20167 |
}; |
| 20168 |
this.joinSelections = function () { |
| 20169 |
var ranges = this.rangeList.ranges; |
| 20170 |
var lastRange = ranges[ranges.length - 1]; |
| 20171 |
var range = Range.fromPoints(ranges[0].start, lastRange.end); |
| 20172 |
this.toSingleRange(); |
| 20173 |
this.setSelectionRange(range, lastRange.cursor == lastRange.start); |
| 20174 |
}; |
| 20175 |
this.toggleBlockSelection = function () { |
| 20176 |
if (this.rangeCount > 1) { |
| 20177 |
var ranges = this.rangeList.ranges; |
| 20178 |
var lastRange = ranges[ranges.length - 1]; |
| 20179 |
var range = Range.fromPoints(ranges[0].start, lastRange.end); |
| 20180 |
this.toSingleRange(); |
| 20181 |
this.setSelectionRange(range, lastRange.cursor == lastRange.start); |
| 20182 |
} |
| 20183 |
else { |
| 20184 |
var cursor = this.session.documentToScreenPosition(this.cursor); |
| 20185 |
var anchor = this.session.documentToScreenPosition(this.anchor); |
| 20186 |
var rectSel = this.rectangularRangeBlock(cursor, anchor); |
| 20187 |
rectSel.forEach(this.addRange, this); |
| 20188 |
} |
| 20189 |
}; |
| 20190 |
this.rectangularRangeBlock = function (screenCursor, screenAnchor, includeEmptyLines) { |
| 20191 |
var rectSel = []; |
| 20192 |
var xBackwards = screenCursor.column < screenAnchor.column; |
| 20193 |
if (xBackwards) { |
| 20194 |
var startColumn = screenCursor.column; |
| 20195 |
var endColumn = screenAnchor.column; |
| 20196 |
var startOffsetX = screenCursor.offsetX; |
| 20197 |
var endOffsetX = screenAnchor.offsetX; |
| 20198 |
} |
| 20199 |
else { |
| 20200 |
var startColumn = screenAnchor.column; |
| 20201 |
var endColumn = screenCursor.column; |
| 20202 |
var startOffsetX = screenAnchor.offsetX; |
| 20203 |
var endOffsetX = screenCursor.offsetX; |
| 20204 |
} |
| 20205 |
var yBackwards = screenCursor.row < screenAnchor.row; |
| 20206 |
if (yBackwards) { |
| 20207 |
var startRow = screenCursor.row; |
| 20208 |
var endRow = screenAnchor.row; |
| 20209 |
} |
| 20210 |
else { |
| 20211 |
var startRow = screenAnchor.row; |
| 20212 |
var endRow = screenCursor.row; |
| 20213 |
} |
| 20214 |
if (startColumn < 0) |
| 20215 |
startColumn = 0; |
| 20216 |
if (startRow < 0) |
| 20217 |
startRow = 0; |
| 20218 |
if (startRow == endRow) |
| 20219 |
includeEmptyLines = true; |
| 20220 |
var docEnd; |
| 20221 |
for (var row = startRow; row <= endRow; row++) { |
| 20222 |
var range = Range.fromPoints(this.session.screenToDocumentPosition(row, startColumn, startOffsetX), this.session.screenToDocumentPosition(row, endColumn, endOffsetX)); |
| 20223 |
if (range.isEmpty()) { |
| 20224 |
if (docEnd && isSamePoint(range.end, docEnd)) |
| 20225 |
break; |
| 20226 |
docEnd = range.end; |
| 20227 |
} |
| 20228 |
range.cursor = xBackwards ? range.start : range.end; |
| 20229 |
rectSel.push(range); |
| 20230 |
} |
| 20231 |
if (yBackwards) |
| 20232 |
rectSel.reverse(); |
| 20233 |
if (!includeEmptyLines) { |
| 20234 |
var end = rectSel.length - 1; |
| 20235 |
while (rectSel[end].isEmpty() && end > 0) |
| 20236 |
end--; |
| 20237 |
if (end > 0) { |
| 20238 |
var start = 0; |
| 20239 |
while (rectSel[start].isEmpty()) |
| 20240 |
start++; |
| 20241 |
} |
| 20242 |
for (var i = end; i >= start; i--) { |
| 20243 |
if (rectSel[i].isEmpty()) |
| 20244 |
rectSel.splice(i, 1); |
| 20245 |
} |
| 20246 |
} |
| 20247 |
return rectSel; |
| 20248 |
}; |
| 20249 |
}).call(Selection.prototype); |
| 20250 |
var Editor = require("./editor").Editor; |
| 20251 |
(function () { |
| 20252 |
this.updateSelectionMarkers = function () { |
| 20253 |
this.renderer.updateCursor(); |
| 20254 |
this.renderer.updateBackMarkers(); |
| 20255 |
}; |
| 20256 |
this.addSelectionMarker = function (orientedRange) { |
| 20257 |
if (!orientedRange.cursor) |
| 20258 |
orientedRange.cursor = orientedRange.end; |
| 20259 |
var style = this.getSelectionStyle(); |
| 20260 |
orientedRange.marker = this.session.addMarker(orientedRange, "ace_selection", style); |
| 20261 |
this.session.$selectionMarkers.push(orientedRange); |
| 20262 |
this.session.selectionMarkerCount = this.session.$selectionMarkers.length; |
| 20263 |
return orientedRange; |
| 20264 |
}; |
| 20265 |
this.removeSelectionMarker = function (range) { |
| 20266 |
if (!range.marker) |
| 20267 |
return; |
| 20268 |
this.session.removeMarker(range.marker); |
| 20269 |
var index = this.session.$selectionMarkers.indexOf(range); |
| 20270 |
if (index != -1) |
| 20271 |
this.session.$selectionMarkers.splice(index, 1); |
| 20272 |
this.session.selectionMarkerCount = this.session.$selectionMarkers.length; |
| 20273 |
}; |
| 20274 |
this.removeSelectionMarkers = function (ranges) { |
| 20275 |
var markerList = this.session.$selectionMarkers; |
| 20276 |
for (var i = ranges.length; i--;) { |
| 20277 |
var range = ranges[i]; |
| 20278 |
if (!range.marker) |
| 20279 |
continue; |
| 20280 |
this.session.removeMarker(range.marker); |
| 20281 |
var index = markerList.indexOf(range); |
| 20282 |
if (index != -1) |
| 20283 |
markerList.splice(index, 1); |
| 20284 |
} |
| 20285 |
this.session.selectionMarkerCount = markerList.length; |
| 20286 |
}; |
| 20287 |
this.$onAddRange = function (e) { |
| 20288 |
this.addSelectionMarker(e.range); |
| 20289 |
this.renderer.updateCursor(); |
| 20290 |
this.renderer.updateBackMarkers(); |
| 20291 |
}; |
| 20292 |
this.$onRemoveRange = function (e) { |
| 20293 |
this.removeSelectionMarkers(e.ranges); |
| 20294 |
this.renderer.updateCursor(); |
| 20295 |
this.renderer.updateBackMarkers(); |
| 20296 |
}; |
| 20297 |
this.$onMultiSelect = function (e) { |
| 20298 |
if (this.inMultiSelectMode) |
| 20299 |
return; |
| 20300 |
this.inMultiSelectMode = true; |
| 20301 |
this.setStyle("ace_multiselect"); |
| 20302 |
this.keyBinding.addKeyboardHandler(commands.keyboardHandler); |
| 20303 |
this.commands.setDefaultHandler("exec", this.$onMultiSelectExec); |
| 20304 |
this.renderer.updateCursor(); |
| 20305 |
this.renderer.updateBackMarkers(); |
| 20306 |
}; |
| 20307 |
this.$onSingleSelect = function (e) { |
| 20308 |
if (this.session.multiSelect.inVirtualMode) |
| 20309 |
return; |
| 20310 |
this.inMultiSelectMode = false; |
| 20311 |
this.unsetStyle("ace_multiselect"); |
| 20312 |
this.keyBinding.removeKeyboardHandler(commands.keyboardHandler); |
| 20313 |
this.commands.removeDefaultHandler("exec", this.$onMultiSelectExec); |
| 20314 |
this.renderer.updateCursor(); |
| 20315 |
this.renderer.updateBackMarkers(); |
| 20316 |
this._emit("changeSelection"); |
| 20317 |
}; |
| 20318 |
this.$onMultiSelectExec = function (e) { |
| 20319 |
var command = e.command; |
| 20320 |
var editor = e.editor; |
| 20321 |
if (!editor.multiSelect) |
| 20322 |
return; |
| 20323 |
if (!command.multiSelectAction) { |
| 20324 |
var result = command.exec(editor, e.args || {}); |
| 20325 |
editor.multiSelect.addRange(editor.multiSelect.toOrientedRange()); |
| 20326 |
editor.multiSelect.mergeOverlappingRanges(); |
| 20327 |
} |
| 20328 |
else if (command.multiSelectAction == "forEach") { |
| 20329 |
result = editor.forEachSelection(command, e.args); |
| 20330 |
} |
| 20331 |
else if (command.multiSelectAction == "forEachLine") { |
| 20332 |
result = editor.forEachSelection(command, e.args, true); |
| 20333 |
} |
| 20334 |
else if (command.multiSelectAction == "single") { |
| 20335 |
editor.exitMultiSelectMode(); |
| 20336 |
result = command.exec(editor, e.args || {}); |
| 20337 |
} |
| 20338 |
else { |
| 20339 |
result = command.multiSelectAction(editor, e.args || {}); |
| 20340 |
} |
| 20341 |
return result; |
| 20342 |
}; |
| 20343 |
this.forEachSelection = function (cmd, args, options) { |
| 20344 |
if (this.inVirtualSelectionMode) |
| 20345 |
return; |
| 20346 |
var keepOrder = options && options.keepOrder; |
| 20347 |
var $byLines = options == true || options && options.$byLines; |
| 20348 |
var session = this.session; |
| 20349 |
var selection = this.selection; |
| 20350 |
var rangeList = selection.rangeList; |
| 20351 |
var ranges = (keepOrder ? selection : rangeList).ranges; |
| 20352 |
var result; |
| 20353 |
if (!ranges.length) |
| 20354 |
return cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {}); |
| 20355 |
var reg = selection._eventRegistry; |
| 20356 |
selection._eventRegistry = {}; |
| 20357 |
var tmpSel = new Selection(session); |
| 20358 |
this.inVirtualSelectionMode = true; |
| 20359 |
for (var i = ranges.length; i--;) { |
| 20360 |
if ($byLines) { |
| 20361 |
while (i > 0 && ranges[i].start.row == ranges[i - 1].end.row) |
| 20362 |
i--; |
| 20363 |
} |
| 20364 |
tmpSel.fromOrientedRange(ranges[i]); |
| 20365 |
tmpSel.index = i; |
| 20366 |
this.selection = session.selection = tmpSel; |
| 20367 |
var cmdResult = cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {}); |
| 20368 |
if (!result && cmdResult !== undefined) |
| 20369 |
result = cmdResult; |
| 20370 |
tmpSel.toOrientedRange(ranges[i]); |
| 20371 |
} |
| 20372 |
tmpSel.detach(); |
| 20373 |
this.selection = session.selection = selection; |
| 20374 |
this.inVirtualSelectionMode = false; |
| 20375 |
selection._eventRegistry = reg; |
| 20376 |
selection.mergeOverlappingRanges(); |
| 20377 |
if (selection.ranges[0]) |
| 20378 |
selection.fromOrientedRange(selection.ranges[0]); |
| 20379 |
var anim = this.renderer.$scrollAnimation; |
| 20380 |
this.onCursorChange(); |
| 20381 |
this.onSelectionChange(); |
| 20382 |
if (anim && anim.from == anim.to) |
| 20383 |
this.renderer.animateScrolling(anim.from); |
| 20384 |
return result; |
| 20385 |
}; |
| 20386 |
this.exitMultiSelectMode = function () { |
| 20387 |
if (!this.inMultiSelectMode || this.inVirtualSelectionMode) |
| 20388 |
return; |
| 20389 |
this.multiSelect.toSingleRange(); |
| 20390 |
}; |
| 20391 |
this.getSelectedText = function () { |
| 20392 |
var text = ""; |
| 20393 |
if (this.inMultiSelectMode && !this.inVirtualSelectionMode) { |
| 20394 |
var ranges = this.multiSelect.rangeList.ranges; |
| 20395 |
var buf = []; |
| 20396 |
for (var i = 0; i < ranges.length; i++) { |
| 20397 |
buf.push(this.session.getTextRange(ranges[i])); |
| 20398 |
} |
| 20399 |
var nl = this.session.getDocument().getNewLineCharacter(); |
| 20400 |
text = buf.join(nl); |
| 20401 |
if (text.length == (buf.length - 1) * nl.length) |
| 20402 |
text = ""; |
| 20403 |
} |
| 20404 |
else if (!this.selection.isEmpty()) { |
| 20405 |
text = this.session.getTextRange(this.getSelectionRange()); |
| 20406 |
} |
| 20407 |
return text; |
| 20408 |
}; |
| 20409 |
this.$checkMultiselectChange = function (e, anchor) { |
| 20410 |
if (this.inMultiSelectMode && !this.inVirtualSelectionMode) { |
| 20411 |
var range = this.multiSelect.ranges[0]; |
| 20412 |
if (this.multiSelect.isEmpty() && anchor == this.multiSelect.anchor) |
| 20413 |
return; |
| 20414 |
var pos = anchor == this.multiSelect.anchor |
| 20415 |
? range.cursor == range.start ? range.end : range.start |
| 20416 |
: range.cursor; |
| 20417 |
if (pos.row != anchor.row |
| 20418 |
|| this.session.$clipPositionToDocument(pos.row, pos.column).column != anchor.column) |
| 20419 |
this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange()); |
| 20420 |
else |
| 20421 |
this.multiSelect.mergeOverlappingRanges(); |
| 20422 |
} |
| 20423 |
}; |
| 20424 |
this.findAll = function (needle, options, additive) { |
| 20425 |
options = options || {}; |
| 20426 |
options.needle = needle || options.needle; |
| 20427 |
if (options.needle == undefined) { |
| 20428 |
var range = this.selection.isEmpty() |
| 20429 |
? this.selection.getWordRange() |
| 20430 |
: this.selection.getRange(); |
| 20431 |
options.needle = this.session.getTextRange(range); |
| 20432 |
} |
| 20433 |
this.$search.set(options); |
| 20434 |
var ranges = this.$search.findAll(this.session); |
| 20435 |
if (!ranges.length) |
| 20436 |
return 0; |
| 20437 |
var selection = this.multiSelect; |
| 20438 |
if (!additive) |
| 20439 |
selection.toSingleRange(ranges[0]); |
| 20440 |
for (var i = ranges.length; i--;) |
| 20441 |
selection.addRange(ranges[i], true); |
| 20442 |
if (range && selection.rangeList.rangeAtPoint(range.start)) |
| 20443 |
selection.addRange(range, true); |
| 20444 |
return ranges.length; |
| 20445 |
}; |
| 20446 |
this.selectMoreLines = function (dir, skip) { |
| 20447 |
var range = this.selection.toOrientedRange(); |
| 20448 |
var isBackwards = range.cursor == range.end; |
| 20449 |
var screenLead = this.session.documentToScreenPosition(range.cursor); |
| 20450 |
if (this.selection.$desiredColumn) |
| 20451 |
screenLead.column = this.selection.$desiredColumn; |
| 20452 |
var lead = this.session.screenToDocumentPosition(screenLead.row + dir, screenLead.column); |
| 20453 |
if (!range.isEmpty()) { |
| 20454 |
var screenAnchor = this.session.documentToScreenPosition(isBackwards ? range.end : range.start); |
| 20455 |
var anchor = this.session.screenToDocumentPosition(screenAnchor.row + dir, screenAnchor.column); |
| 20456 |
} |
| 20457 |
else { |
| 20458 |
var anchor = lead; |
| 20459 |
} |
| 20460 |
if (isBackwards) { |
| 20461 |
var newRange = Range.fromPoints(lead, anchor); |
| 20462 |
newRange.cursor = newRange.start; |
| 20463 |
} |
| 20464 |
else { |
| 20465 |
var newRange = Range.fromPoints(anchor, lead); |
| 20466 |
newRange.cursor = newRange.end; |
| 20467 |
} |
| 20468 |
newRange.desiredColumn = screenLead.column; |
| 20469 |
if (!this.selection.inMultiSelectMode) { |
| 20470 |
this.selection.addRange(range); |
| 20471 |
} |
| 20472 |
else { |
| 20473 |
if (skip) |
| 20474 |
var toRemove = range.cursor; |
| 20475 |
} |
| 20476 |
this.selection.addRange(newRange); |
| 20477 |
if (toRemove) |
| 20478 |
this.selection.substractPoint(toRemove); |
| 20479 |
}; |
| 20480 |
this.transposeSelections = function (dir) { |
| 20481 |
var session = this.session; |
| 20482 |
var sel = session.multiSelect; |
| 20483 |
var all = sel.ranges; |
| 20484 |
for (var i = all.length; i--;) { |
| 20485 |
var range = all[i]; |
| 20486 |
if (range.isEmpty()) { |
| 20487 |
var tmp_1 = session.getWordRange(range.start.row, range.start.column); |
| 20488 |
range.start.row = tmp_1.start.row; |
| 20489 |
range.start.column = tmp_1.start.column; |
| 20490 |
range.end.row = tmp_1.end.row; |
| 20491 |
range.end.column = tmp_1.end.column; |
| 20492 |
} |
| 20493 |
} |
| 20494 |
sel.mergeOverlappingRanges(); |
| 20495 |
var words = []; |
| 20496 |
for (var i = all.length; i--;) { |
| 20497 |
var range = all[i]; |
| 20498 |
words.unshift(session.getTextRange(range)); |
| 20499 |
} |
| 20500 |
if (dir < 0) |
| 20501 |
words.unshift(words.pop()); |
| 20502 |
else |
| 20503 |
words.push(words.shift()); |
| 20504 |
for (var i = all.length; i--;) { |
| 20505 |
var range = all[i]; |
| 20506 |
var tmp = range.clone(); |
| 20507 |
session.replace(range, words[i]); |
| 20508 |
range.start.row = tmp.start.row; |
| 20509 |
range.start.column = tmp.start.column; |
| 20510 |
} |
| 20511 |
sel.fromOrientedRange(sel.ranges[0]); |
| 20512 |
}; |
| 20513 |
this.selectMore = function (dir, skip, stopAtFirst) { |
| 20514 |
var session = this.session; |
| 20515 |
var sel = session.multiSelect; |
| 20516 |
var range = sel.toOrientedRange(); |
| 20517 |
if (range.isEmpty()) { |
| 20518 |
range = session.getWordRange(range.start.row, range.start.column); |
| 20519 |
range.cursor = dir == -1 ? range.start : range.end; |
| 20520 |
this.multiSelect.addRange(range); |
| 20521 |
if (stopAtFirst) |
| 20522 |
return; |
| 20523 |
} |
| 20524 |
var needle = session.getTextRange(range); |
| 20525 |
var newRange = find(session, needle, dir); |
| 20526 |
if (newRange) { |
| 20527 |
newRange.cursor = dir == -1 ? newRange.start : newRange.end; |
| 20528 |
this.session.unfold(newRange); |
| 20529 |
this.multiSelect.addRange(newRange); |
| 20530 |
this.renderer.scrollCursorIntoView(null, 0.5); |
| 20531 |
} |
| 20532 |
if (skip) |
| 20533 |
this.multiSelect.substractPoint(range.cursor); |
| 20534 |
}; |
| 20535 |
this.alignCursors = function () { |
| 20536 |
var session = this.session; |
| 20537 |
var sel = session.multiSelect; |
| 20538 |
var ranges = sel.ranges; |
| 20539 |
var row = -1; |
| 20540 |
var sameRowRanges = ranges.filter(function (r) { |
| 20541 |
if (r.cursor.row == row) |
| 20542 |
return true; |
| 20543 |
row = r.cursor.row; |
| 20544 |
}); |
| 20545 |
if (!ranges.length || sameRowRanges.length == ranges.length - 1) { |
| 20546 |
var range = this.selection.getRange(); |
| 20547 |
var fr = range.start.row, lr = range.end.row; |
| 20548 |
var guessRange = fr == lr; |
| 20549 |
if (guessRange) { |
| 20550 |
var max = this.session.getLength(); |
| 20551 |
var line; |
| 20552 |
do { |
| 20553 |
line = this.session.getLine(lr); |
| 20554 |
} while (/[=:]/.test(line) && ++lr < max); |
| 20555 |
do { |
| 20556 |
line = this.session.getLine(fr); |
| 20557 |
} while (/[=:]/.test(line) && --fr > 0); |
| 20558 |
if (fr < 0) |
| 20559 |
fr = 0; |
| 20560 |
if (lr >= max) |
| 20561 |
lr = max - 1; |
| 20562 |
} |
| 20563 |
var lines = this.session.removeFullLines(fr, lr); |
| 20564 |
lines = this.$reAlignText(lines, guessRange); |
| 20565 |
this.session.insert({ row: fr, column: 0 }, lines.join("\n") + "\n"); |
| 20566 |
if (!guessRange) { |
| 20567 |
range.start.column = 0; |
| 20568 |
range.end.column = lines[lines.length - 1].length; |
| 20569 |
} |
| 20570 |
this.selection.setRange(range); |
| 20571 |
} |
| 20572 |
else { |
| 20573 |
sameRowRanges.forEach(function (r) { |
| 20574 |
sel.substractPoint(r.cursor); |
| 20575 |
}); |
| 20576 |
var maxCol = 0; |
| 20577 |
var minSpace = Infinity; |
| 20578 |
var spaceOffsets = ranges.map(function (r) { |
| 20579 |
var p = r.cursor; |
| 20580 |
var line = session.getLine(p.row); |
| 20581 |
var spaceOffset = line.substr(p.column).search(/\S/g); |
| 20582 |
if (spaceOffset == -1) |
| 20583 |
spaceOffset = 0; |
| 20584 |
if (p.column > maxCol) |
| 20585 |
maxCol = p.column; |
| 20586 |
if (spaceOffset < minSpace) |
| 20587 |
minSpace = spaceOffset; |
| 20588 |
return spaceOffset; |
| 20589 |
}); |
| 20590 |
ranges.forEach(function (r, i) { |
| 20591 |
var p = r.cursor; |
| 20592 |
var l = maxCol - p.column; |
| 20593 |
var d = spaceOffsets[i] - minSpace; |
| 20594 |
if (l > d) |
| 20595 |
session.insert(p, lang.stringRepeat(" ", l - d)); |
| 20596 |
else |
| 20597 |
session.remove(new Range(p.row, p.column, p.row, p.column - l + d)); |
| 20598 |
r.start.column = r.end.column = maxCol; |
| 20599 |
r.start.row = r.end.row = p.row; |
| 20600 |
r.cursor = r.end; |
| 20601 |
}); |
| 20602 |
sel.fromOrientedRange(ranges[0]); |
| 20603 |
this.renderer.updateCursor(); |
| 20604 |
this.renderer.updateBackMarkers(); |
| 20605 |
} |
| 20606 |
}; |
| 20607 |
this.$reAlignText = function (lines, forceLeft) { |
| 20608 |
var isLeftAligned = true, isRightAligned = true; |
| 20609 |
var startW, textW, endW; |
| 20610 |
return lines.map(function (line) { |
| 20611 |
var m = line.match(/(\s*)(.*?)(\s*)([=:].*)/); |
| 20612 |
if (!m) |
| 20613 |
return [line]; |
| 20614 |
if (startW == null) { |
| 20615 |
startW = m[1].length; |
| 20616 |
textW = m[2].length; |
| 20617 |
endW = m[3].length; |
| 20618 |
return m; |
| 20619 |
} |
| 20620 |
if (startW + textW + endW != m[1].length + m[2].length + m[3].length) |
| 20621 |
isRightAligned = false; |
| 20622 |
if (startW != m[1].length) |
| 20623 |
isLeftAligned = false; |
| 20624 |
if (startW > m[1].length) |
| 20625 |
startW = m[1].length; |
| 20626 |
if (textW < m[2].length) |
| 20627 |
textW = m[2].length; |
| 20628 |
if (endW > m[3].length) |
| 20629 |
endW = m[3].length; |
| 20630 |
return m; |
| 20631 |
}).map(forceLeft ? alignLeft : |
| 20632 |
isLeftAligned ? isRightAligned ? alignRight : alignLeft : unAlign); |
| 20633 |
function spaces(n) { |
| 20634 |
return lang.stringRepeat(" ", n); |
| 20635 |
} |
| 20636 |
function alignLeft(m) { |
| 20637 |
return !m[2] ? m[0] : spaces(startW) + m[2] |
| 20638 |
+ spaces(textW - m[2].length + endW) |
| 20639 |
+ m[4].replace(/^([=:])\s+/, "$1 "); |
| 20640 |
} |
| 20641 |
function alignRight(m) { |
| 20642 |
return !m[2] ? m[0] : spaces(startW + textW - m[2].length) + m[2] |
| 20643 |
+ spaces(endW) |
| 20644 |
+ m[4].replace(/^([=:])\s+/, "$1 "); |
| 20645 |
} |
| 20646 |
function unAlign(m) { |
| 20647 |
return !m[2] ? m[0] : spaces(startW) + m[2] |
| 20648 |
+ spaces(endW) |
| 20649 |
+ m[4].replace(/^([=:])\s+/, "$1 "); |
| 20650 |
} |
| 20651 |
}; |
| 20652 |
}).call(Editor.prototype); |
| 20653 |
function isSamePoint(p1, p2) { |
| 20654 |
return p1.row == p2.row && p1.column == p2.column; |
| 20655 |
} |
| 20656 |
exports.onSessionChange = function (e) { |
| 20657 |
var session = e.session; |
| 20658 |
if (session && !session.multiSelect) { |
| 20659 |
session.$selectionMarkers = []; |
| 20660 |
session.selection.$initRangeList(); |
| 20661 |
session.multiSelect = session.selection; |
| 20662 |
} |
| 20663 |
this.multiSelect = session && session.multiSelect; |
| 20664 |
var oldSession = e.oldSession; |
| 20665 |
if (oldSession) { |
| 20666 |
oldSession.multiSelect.off("addRange", this.$onAddRange); |
| 20667 |
oldSession.multiSelect.off("removeRange", this.$onRemoveRange); |
| 20668 |
oldSession.multiSelect.off("multiSelect", this.$onMultiSelect); |
| 20669 |
oldSession.multiSelect.off("singleSelect", this.$onSingleSelect); |
| 20670 |
oldSession.multiSelect.lead.off("change", this.$checkMultiselectChange); |
| 20671 |
oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange); |
| 20672 |
} |
| 20673 |
if (session) { |
| 20674 |
session.multiSelect.on("addRange", this.$onAddRange); |
| 20675 |
session.multiSelect.on("removeRange", this.$onRemoveRange); |
| 20676 |
session.multiSelect.on("multiSelect", this.$onMultiSelect); |
| 20677 |
session.multiSelect.on("singleSelect", this.$onSingleSelect); |
| 20678 |
session.multiSelect.lead.on("change", this.$checkMultiselectChange); |
| 20679 |
session.multiSelect.anchor.on("change", this.$checkMultiselectChange); |
| 20680 |
} |
| 20681 |
if (session && this.inMultiSelectMode != session.selection.inMultiSelectMode) { |
| 20682 |
if (session.selection.inMultiSelectMode) |
| 20683 |
this.$onMultiSelect(); |
| 20684 |
else |
| 20685 |
this.$onSingleSelect(); |
| 20686 |
} |
| 20687 |
}; |
| 20688 |
function MultiSelect(editor) { |
| 20689 |
if (editor.$multiselectOnSessionChange) |
| 20690 |
return; |
| 20691 |
editor.$onAddRange = editor.$onAddRange.bind(editor); |
| 20692 |
editor.$onRemoveRange = editor.$onRemoveRange.bind(editor); |
| 20693 |
editor.$onMultiSelect = editor.$onMultiSelect.bind(editor); |
| 20694 |
editor.$onSingleSelect = editor.$onSingleSelect.bind(editor); |
| 20695 |
editor.$multiselectOnSessionChange = exports.onSessionChange.bind(editor); |
| 20696 |
editor.$checkMultiselectChange = editor.$checkMultiselectChange.bind(editor); |
| 20697 |
editor.$multiselectOnSessionChange(editor); |
| 20698 |
editor.on("changeSession", editor.$multiselectOnSessionChange); |
| 20699 |
editor.on("mousedown", onMouseDown); |
| 20700 |
editor.commands.addCommands(commands.defaultCommands); |
| 20701 |
addAltCursorListeners(editor); |
| 20702 |
} |
| 20703 |
function addAltCursorListeners(editor) { |
| 20704 |
if (!editor.textInput) |
| 20705 |
return; |
| 20706 |
var el = editor.textInput.getElement(); |
| 20707 |
var altCursor = false; |
| 20708 |
event.addListener(el, "keydown", function (e) { |
| 20709 |
var altDown = e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey); |
| 20710 |
if (editor.$blockSelectEnabled && altDown) { |
| 20711 |
if (!altCursor) { |
| 20712 |
editor.renderer.setMouseCursor("crosshair"); |
| 20713 |
altCursor = true; |
| 20714 |
} |
| 20715 |
} |
| 20716 |
else if (altCursor) { |
| 20717 |
reset(); |
| 20718 |
} |
| 20719 |
}, editor); |
| 20720 |
event.addListener(el, "keyup", reset, editor); |
| 20721 |
event.addListener(el, "blur", reset, editor); |
| 20722 |
function reset(e) { |
| 20723 |
if (altCursor) { |
| 20724 |
editor.renderer.setMouseCursor(""); |
| 20725 |
altCursor = false; |
| 20726 |
} |
| 20727 |
} |
| 20728 |
} |
| 20729 |
exports.MultiSelect = MultiSelect; |
| 20730 |
require("./config").defineOptions(Editor.prototype, "editor", { |
| 20731 |
enableMultiselect: { |
| 20732 |
set: function (val) { |
| 20733 |
MultiSelect(this); |
| 20734 |
if (val) { |
| 20735 |
this.on("mousedown", onMouseDown); |
| 20736 |
} |
| 20737 |
else { |
| 20738 |
this.off("mousedown", onMouseDown); |
| 20739 |
} |
| 20740 |
}, |
| 20741 |
value: true |
| 20742 |
}, |
| 20743 |
enableBlockSelect: { |
| 20744 |
set: function (val) { |
| 20745 |
this.$blockSelectEnabled = val; |
| 20746 |
}, |
| 20747 |
value: true |
| 20748 |
} |
| 20749 |
}); |
| 20750 |
|
| 20751 |
}); |
| 20752 |
|
| 20753 |
ace.define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"], function(require, exports, module){"use strict"; |
| 20754 |
var Range = require("../../range").Range; |
| 20755 |
var FoldMode = exports.FoldMode = function () { }; |
| 20756 |
(function () { |
| 20757 |
this.foldingStartMarker = null; |
| 20758 |
this.foldingStopMarker = null; |
| 20759 |
this.getFoldWidget = function (session, foldStyle, row) { |
| 20760 |
var line = session.getLine(row); |
| 20761 |
if (this.foldingStartMarker.test(line)) |
| 20762 |
return "start"; |
| 20763 |
if (foldStyle == "markbeginend" |
| 20764 |
&& this.foldingStopMarker |
| 20765 |
&& this.foldingStopMarker.test(line)) |
| 20766 |
return "end"; |
| 20767 |
return ""; |
| 20768 |
}; |
| 20769 |
this.getFoldWidgetRange = function (session, foldStyle, row) { |
| 20770 |
return null; |
| 20771 |
}; |
| 20772 |
this.indentationBlock = function (session, row, column) { |
| 20773 |
var re = /\S/; |
| 20774 |
var line = session.getLine(row); |
| 20775 |
var startLevel = line.search(re); |
| 20776 |
if (startLevel == -1) |
| 20777 |
return; |
| 20778 |
var startColumn = column || line.length; |
| 20779 |
var maxRow = session.getLength(); |
| 20780 |
var startRow = row; |
| 20781 |
var endRow = row; |
| 20782 |
while (++row < maxRow) { |
| 20783 |
var level = session.getLine(row).search(re); |
| 20784 |
if (level == -1) |
| 20785 |
continue; |
| 20786 |
if (level <= startLevel) { |
| 20787 |
var token = session.getTokenAt(row, 0); |
| 20788 |
if (!token || token.type !== "string") |
| 20789 |
break; |
| 20790 |
} |
| 20791 |
endRow = row; |
| 20792 |
} |
| 20793 |
if (endRow > startRow) { |
| 20794 |
var endColumn = session.getLine(endRow).length; |
| 20795 |
return new Range(startRow, startColumn, endRow, endColumn); |
| 20796 |
} |
| 20797 |
}; |
| 20798 |
this.openingBracketBlock = function (session, bracket, row, column, typeRe) { |
| 20799 |
var start = { row: row, column: column + 1 }; |
| 20800 |
var end = session.$findClosingBracket(bracket, start, typeRe); |
| 20801 |
if (!end) |
| 20802 |
return; |
| 20803 |
var fw = session.foldWidgets[end.row]; |
| 20804 |
if (fw == null) |
| 20805 |
fw = session.getFoldWidget(end.row); |
| 20806 |
if (fw == "start" && end.row > start.row) { |
| 20807 |
end.row--; |
| 20808 |
end.column = session.getLine(end.row).length; |
| 20809 |
} |
| 20810 |
return Range.fromPoints(start, end); |
| 20811 |
}; |
| 20812 |
this.closingBracketBlock = function (session, bracket, row, column, typeRe) { |
| 20813 |
var end = { row: row, column: column }; |
| 20814 |
var start = session.$findOpeningBracket(bracket, end); |
| 20815 |
if (!start) |
| 20816 |
return; |
| 20817 |
start.column++; |
| 20818 |
end.column--; |
| 20819 |
return Range.fromPoints(start, end); |
| 20820 |
}; |
| 20821 |
}).call(FoldMode.prototype); |
| 20822 |
|
| 20823 |
}); |
| 20824 |
|
| 20825 |
ace.define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range","ace/config"], function(require, exports, module){"use strict"; |
| 20826 |
var LineWidgets = require("../line_widgets").LineWidgets; |
| 20827 |
var dom = require("../lib/dom"); |
| 20828 |
var Range = require("../range").Range; |
| 20829 |
var nls = require("../config").nls; |
| 20830 |
function binarySearch(array, needle, comparator) { |
| 20831 |
var first = 0; |
| 20832 |
var last = array.length - 1; |
| 20833 |
while (first <= last) { |
| 20834 |
var mid = (first + last) >> 1; |
| 20835 |
var c = comparator(needle, array[mid]); |
| 20836 |
if (c > 0) |
| 20837 |
first = mid + 1; |
| 20838 |
else if (c < 0) |
| 20839 |
last = mid - 1; |
| 20840 |
else |
| 20841 |
return mid; |
| 20842 |
} |
| 20843 |
return -(first + 1); |
| 20844 |
} |
| 20845 |
function findAnnotations(session, row, dir) { |
| 20846 |
var annotations = session.getAnnotations().sort(Range.comparePoints); |
| 20847 |
if (!annotations.length) |
| 20848 |
return; |
| 20849 |
var i = binarySearch(annotations, { row: row, column: -1 }, Range.comparePoints); |
| 20850 |
if (i < 0) |
| 20851 |
i = -i - 1; |
| 20852 |
if (i >= annotations.length) |
| 20853 |
i = dir > 0 ? 0 : annotations.length - 1; |
| 20854 |
else if (i === 0 && dir < 0) |
| 20855 |
i = annotations.length - 1; |
| 20856 |
var annotation = annotations[i]; |
| 20857 |
if (!annotation || !dir) |
| 20858 |
return; |
| 20859 |
if (annotation.row === row) { |
| 20860 |
do { |
| 20861 |
annotation = annotations[i += dir]; |
| 20862 |
} while (annotation && annotation.row === row); |
| 20863 |
if (!annotation) |
| 20864 |
return annotations.slice(); |
| 20865 |
} |
| 20866 |
var matched = []; |
| 20867 |
row = annotation.row; |
| 20868 |
do { |
| 20869 |
matched[dir < 0 ? "unshift" : "push"](annotation); |
| 20870 |
annotation = annotations[i += dir]; |
| 20871 |
} while (annotation && annotation.row == row); |
| 20872 |
return matched.length && matched; |
| 20873 |
} |
| 20874 |
exports.showErrorMarker = function (editor, dir) { |
| 20875 |
var session = editor.session; |
| 20876 |
if (!session.widgetManager) { |
| 20877 |
session.widgetManager = new LineWidgets(session); |
| 20878 |
session.widgetManager.attach(editor); |
| 20879 |
} |
| 20880 |
var pos = editor.getCursorPosition(); |
| 20881 |
var row = pos.row; |
| 20882 |
var oldWidget = session.widgetManager.getWidgetsAtRow(row).filter(function (w) { |
| 20883 |
return w.type == "errorMarker"; |
| 20884 |
})[0]; |
| 20885 |
if (oldWidget) { |
| 20886 |
oldWidget.destroy(); |
| 20887 |
} |
| 20888 |
else { |
| 20889 |
row -= dir; |
| 20890 |
} |
| 20891 |
var annotations = findAnnotations(session, row, dir); |
| 20892 |
var gutterAnno; |
| 20893 |
if (annotations) { |
| 20894 |
var annotation = annotations[0]; |
| 20895 |
pos.column = (annotation.pos && typeof annotation.column != "number" |
| 20896 |
? annotation.pos.sc |
| 20897 |
: annotation.column) || 0; |
| 20898 |
pos.row = annotation.row; |
| 20899 |
gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row]; |
| 20900 |
} |
| 20901 |
else if (oldWidget) { |
| 20902 |
return; |
| 20903 |
} |
| 20904 |
else { |
| 20905 |
gutterAnno = { |
| 20906 |
text: [nls("Looks good!")], |
| 20907 |
className: "ace_ok" |
| 20908 |
}; |
| 20909 |
} |
| 20910 |
editor.session.unfold(pos.row); |
| 20911 |
editor.selection.moveToPosition(pos); |
| 20912 |
var w = { |
| 20913 |
row: pos.row, |
| 20914 |
fixedWidth: true, |
| 20915 |
coverGutter: true, |
| 20916 |
el: dom.createElement("div"), |
| 20917 |
type: "errorMarker" |
| 20918 |
}; |
| 20919 |
var el = w.el.appendChild(dom.createElement("div")); |
| 20920 |
var arrow = w.el.appendChild(dom.createElement("div")); |
| 20921 |
arrow.className = "error_widget_arrow " + gutterAnno.className; |
| 20922 |
var left = editor.renderer.$cursorLayer |
| 20923 |
.getPixelPosition(pos).left; |
| 20924 |
arrow.style.left = left + editor.renderer.gutterWidth - 5 + "px"; |
| 20925 |
w.el.className = "error_widget_wrapper"; |
| 20926 |
el.className = "error_widget " + gutterAnno.className; |
| 20927 |
el.innerHTML = gutterAnno.text.join("<br>"); |
| 20928 |
el.appendChild(dom.createElement("div")); |
| 20929 |
var kb = function (_, hashId, keyString) { |
| 20930 |
if (hashId === 0 && (keyString === "esc" || keyString === "return")) { |
| 20931 |
w.destroy(); |
| 20932 |
return { command: "null" }; |
| 20933 |
} |
| 20934 |
}; |
| 20935 |
w.destroy = function () { |
| 20936 |
if (editor.$mouseHandler.isMousePressed) |
| 20937 |
return; |
| 20938 |
editor.keyBinding.removeKeyboardHandler(kb); |
| 20939 |
session.widgetManager.removeLineWidget(w); |
| 20940 |
editor.off("changeSelection", w.destroy); |
| 20941 |
editor.off("changeSession", w.destroy); |
| 20942 |
editor.off("mouseup", w.destroy); |
| 20943 |
editor.off("change", w.destroy); |
| 20944 |
}; |
| 20945 |
editor.keyBinding.addKeyboardHandler(kb); |
| 20946 |
editor.on("changeSelection", w.destroy); |
| 20947 |
editor.on("changeSession", w.destroy); |
| 20948 |
editor.on("mouseup", w.destroy); |
| 20949 |
editor.on("change", w.destroy); |
| 20950 |
editor.session.widgetManager.addLineWidget(w); |
| 20951 |
w.el.onmousedown = editor.focus.bind(editor); |
| 20952 |
editor.renderer.scrollCursorIntoView(null, 0.5, { bottom: w.el.offsetHeight }); |
| 20953 |
}; |
| 20954 |
dom.importCssString("\n .error_widget_wrapper {\n background: inherit;\n color: inherit;\n border:none\n }\n .error_widget {\n border-top: solid 2px;\n border-bottom: solid 2px;\n margin: 5px 0;\n padding: 10px 40px;\n white-space: pre-wrap;\n }\n .error_widget.ace_error, .error_widget_arrow.ace_error{\n border-color: #ff5a5a\n }\n .error_widget.ace_warning, .error_widget_arrow.ace_warning{\n border-color: #F1D817\n }\n .error_widget.ace_info, .error_widget_arrow.ace_info{\n border-color: #5a5a5a\n }\n .error_widget.ace_ok, .error_widget_arrow.ace_ok{\n border-color: #5aaa5a\n }\n .error_widget_arrow {\n position: absolute;\n border: solid 5px;\n border-top-color: transparent!important;\n border-right-color: transparent!important;\n border-left-color: transparent!important;\n top: -5px;\n }\n", "error_marker.css", false); |
| 20955 |
|
| 20956 |
}); |
| 20957 |
|
| 20958 |
ace.define("ace/ace",["require","exports","module","ace/lib/dom","ace/range","ace/editor","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/worker/worker_client","ace/keyboard/hash_handler","ace/placeholder","ace/multi_select","ace/mode/folding/fold_mode","ace/theme/textmate","ace/ext/error_marker","ace/config","ace/loader_build"], function(require, exports, module){ |
| 20959 |
|
| 20960 |
|
| 20961 |
|
| 20962 |
|
| 20963 |
"use strict"; |
| 20964 |
require("./loader_build")(exports) |
| 20965 |
var dom = require("./lib/dom"); |
| 20966 |
var Range = require("./range").Range; |
| 20967 |
var Editor = require("./editor").Editor; |
| 20968 |
var EditSession = require("./edit_session").EditSession; |
| 20969 |
var UndoManager = require("./undomanager").UndoManager; |
| 20970 |
var Renderer = require("./virtual_renderer").VirtualRenderer; |
| 20971 |
require("./worker/worker_client"); |
| 20972 |
require("./keyboard/hash_handler"); |
| 20973 |
require("./placeholder"); |
| 20974 |
require("./multi_select"); |
| 20975 |
require("./mode/folding/fold_mode"); |
| 20976 |
require("./theme/textmate"); |
| 20977 |
require("./ext/error_marker"); |
| 20978 |
exports.config = require("./config"); |
| 20979 |
exports.edit = function (el, options) { |
| 20980 |
if (typeof el == "string") { |
| 20981 |
var _id = el; |
| 20982 |
el = document.getElementById(_id); |
| 20983 |
if (!el) |
| 20984 |
throw new Error("ace.edit can't find div #" + _id); |
| 20985 |
} |
| 20986 |
if (el && el.env && el.env.editor instanceof Editor) |
| 20987 |
return el.env.editor; |
| 20988 |
var value = ""; |
| 20989 |
if (el && /input|textarea/i.test(el.tagName)) { |
| 20990 |
var oldNode = el; |
| 20991 |
value = oldNode.value; |
| 20992 |
el = dom.createElement("pre"); |
| 20993 |
oldNode.parentNode.replaceChild(el, oldNode); |
| 20994 |
} |
| 20995 |
else if (el) { |
| 20996 |
value = el.textContent; |
| 20997 |
el.innerHTML = ""; |
| 20998 |
} |
| 20999 |
var doc = exports.createEditSession(value); |
| 21000 |
var editor = new Editor(new Renderer(el), doc, options); |
| 21001 |
var env = { |
| 21002 |
document: doc, |
| 21003 |
editor: editor, |
| 21004 |
onResize: editor.resize.bind(editor, null) |
| 21005 |
}; |
| 21006 |
if (oldNode) |
| 21007 |
env.textarea = oldNode; |
| 21008 |
editor.on("destroy", function () { |
| 21009 |
env.editor.container.env = null; |
| 21010 |
}); |
| 21011 |
editor.container.env = editor.env = env; |
| 21012 |
return editor; |
| 21013 |
}; |
| 21014 |
exports.createEditSession = function (text, mode) { |
| 21015 |
var doc = new EditSession(text, mode); |
| 21016 |
doc.setUndoManager(new UndoManager()); |
| 21017 |
return doc; |
| 21018 |
}; |
| 21019 |
exports.Range = Range; |
| 21020 |
exports.Editor = Editor; |
| 21021 |
exports.EditSession = EditSession; |
| 21022 |
exports.UndoManager = UndoManager; |
| 21023 |
exports.VirtualRenderer = Renderer; |
| 21024 |
exports.version = exports.config.version; |
| 21025 |
|
| 21026 |
}); (function() { |
| 21027 |
ace.require(["ace/ace"], function(a) { |
| 21028 |
if (a) { |
| 21029 |
a.config.init(true); |
| 21030 |
a.define = ace.define; |
| 21031 |
} |
| 21032 |
var global = (function () { |
| 21033 |
return this; |
| 21034 |
})(); |
| 21035 |
if (!global && typeof window != "undefined") global = window; |
| 21036 |
if (!global && typeof self != "undefined") global = self; |
| 21037 |
|
| 21038 |
if (!global.ace) |
| 21039 |
global.ace = a; |
| 21040 |
for (var key in a) if (a.hasOwnProperty(key)) |
| 21041 |
global.ace[key] = a[key]; |
| 21042 |
global.ace["default"] = global.ace; |
| 21043 |
if (typeof module == "object" && typeof exports == "object" && module) { |
| 21044 |
module.exports = global.ace; |
| 21045 |
} |
| 21046 |
}); |
| 21047 |
})(); |
| 21048 |
|