UNPKG

743 kBJavaScriptView Raw
1/*!
2 * fei-editor v0.0.2
3 * (c) 2023 yangmengfei
4 * @license MIT
5 */
6var FeiEditor = (function (exports, vue) {
7 'use strict';
8
9 /* ***** BEGIN LICENSE BLOCK *****
10 * Distributed under the BSD license:
11 *
12 * Copyright (c) 2010, Ajax.org B.V.
13 * All rights reserved.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions are met:
17 * * Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * * Neither the name of Ajax.org B.V. nor the
23 * names of its contributors may be used to endorse or promote products
24 * derived from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29 * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
30 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39 /**
40 * Define a module along with a payload
41 * @param module a name for the payload
42 * @param payload a function to call with (acequire, exports, module) params
43 */
44
45 (function() {
46
47 var ACE_NAMESPACE = "ace";
48
49 var global = (function() { return this; })();
50 if (!global && typeof window != "undefined") global = window; // strict mode
51
52
53 var define = function(module, deps, payload) {
54 if (typeof module !== "string") {
55 if (define.original)
56 define.original.apply(this, arguments);
57 else {
58 console.error("dropping module because define wasn\'t a string.");
59 console.trace();
60 }
61 return;
62 }
63 if (arguments.length == 2)
64 payload = deps;
65 if (!define.modules[module]) {
66 define.payloads[module] = payload;
67 define.modules[module] = null;
68 }
69 };
70
71 define.modules = {};
72 define.payloads = {};
73
74 /**
75 * Get at functionality define()ed using the function above
76 */
77 var _acequire = function(parentId, module, callback) {
78 if (typeof module === "string") {
79 var payload = lookup(parentId, module);
80 if (payload != undefined) {
81 callback && callback();
82 return payload;
83 }
84 } else if (Object.prototype.toString.call(module) === "[object Array]") {
85 var params = [];
86 for (var i = 0, l = module.length; i < l; ++i) {
87 var dep = lookup(parentId, module[i]);
88 if (dep == undefined && acequire.original)
89 return;
90 params.push(dep);
91 }
92 return callback && callback.apply(null, params) || true;
93 }
94 };
95
96 var acequire = function(module, callback) {
97 var packagedModule = _acequire("", module, callback);
98 if (packagedModule == undefined && acequire.original)
99 return acequire.original.apply(this, arguments);
100 return packagedModule;
101 };
102
103 var normalizeModule = function(parentId, moduleName) {
104 // normalize plugin acequires
105 if (moduleName.indexOf("!") !== -1) {
106 var chunks = moduleName.split("!");
107 return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
108 }
109 // normalize relative acequires
110 if (moduleName.charAt(0) == ".") {
111 var base = parentId.split("/").slice(0, -1).join("/");
112 moduleName = base + "/" + moduleName;
113
114 while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
115 var previous = moduleName;
116 moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
117 }
118 }
119 return moduleName;
120 };
121
122 /**
123 * Internal function to lookup moduleNames and resolve them by calling the
124 * definition function if needed.
125 */
126 var lookup = function(parentId, moduleName) {
127 moduleName = normalizeModule(parentId, moduleName);
128
129 var module = define.modules[moduleName];
130 if (!module) {
131 module = define.payloads[moduleName];
132 if (typeof module === 'function') {
133 var exports = {};
134 var mod = {
135 id: moduleName,
136 uri: '',
137 exports: exports,
138 packaged: true
139 };
140
141 var req = function(module, callback) {
142 return _acequire(moduleName, module, callback);
143 };
144
145 var returnValue = module(req, exports, mod);
146 exports = returnValue || mod.exports;
147 define.modules[moduleName] = exports;
148 delete define.payloads[moduleName];
149 }
150 module = define.modules[moduleName] = exports || module;
151 }
152 return module;
153 };
154
155 function exportAce(ns) {
156 var root = global;
157 if (ns) {
158 if (!global[ns])
159 global[ns] = {};
160 root = global[ns];
161 }
162
163 if (!root.define || !root.define.packaged) {
164 define.original = root.define;
165 root.define = define;
166 root.define.packaged = true;
167 }
168
169 if (!root.acequire || !root.acequire.packaged) {
170 acequire.original = root.acequire;
171 root.acequire = acequire;
172 root.acequire.packaged = true;
173 }
174 }
175
176 exportAce(ACE_NAMESPACE);
177
178 })();
179
180 ace.define("ace/lib/regexp",["require","exports","module"], function(acequire, exports, module) {
181
182 var real = {
183 exec: RegExp.prototype.exec,
184 test: RegExp.prototype.test,
185 match: String.prototype.match,
186 replace: String.prototype.replace,
187 split: String.prototype.split
188 },
189 compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
190 compliantLastIndexIncrement = function () {
191 var x = /^/g;
192 real.test.call(x, "");
193 return !x.lastIndex;
194 }();
195
196 if (compliantLastIndexIncrement && compliantExecNpcg)
197 return;
198 RegExp.prototype.exec = function (str) {
199 var match = real.exec.apply(this, arguments),
200 name, r2;
201 if ( typeof(str) == 'string' && match) {
202 if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
203 r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
204 real.replace.call(str.slice(match.index), r2, function () {
205 for (var i = 1; i < arguments.length - 2; i++) {
206 if (arguments[i] === undefined)
207 match[i] = undefined;
208 }
209 });
210 }
211 if (this._xregexp && this._xregexp.captureNames) {
212 for (var i = 1; i < match.length; i++) {
213 name = this._xregexp.captureNames[i - 1];
214 if (name)
215 match[name] = match[i];
216 }
217 }
218 if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
219 this.lastIndex--;
220 }
221 return match;
222 };
223 if (!compliantLastIndexIncrement) {
224 RegExp.prototype.test = function (str) {
225 var match = real.exec.call(this, str);
226 if (match && this.global && !match[0].length && (this.lastIndex > match.index))
227 this.lastIndex--;
228 return !!match;
229 };
230 }
231
232 function getNativeFlags (regex) {
233 return (regex.global ? "g" : "") +
234 (regex.ignoreCase ? "i" : "") +
235 (regex.multiline ? "m" : "") +
236 (regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
237 (regex.sticky ? "y" : "");
238 }
239
240 function indexOf (array, item, from) {
241 if (Array.prototype.indexOf) // Use the native array method if available
242 return array.indexOf(item, from);
243 for (var i = from || 0; i < array.length; i++) {
244 if (array[i] === item)
245 return i;
246 }
247 return -1;
248 }
249
250 });
251
252 ace.define("ace/lib/es5-shim",["require","exports","module"], function(acequire, exports, module) {
253
254 function Empty() {}
255
256 if (!Function.prototype.bind) {
257 Function.prototype.bind = function bind(that) { // .length is 1
258 var target = this;
259 if (typeof target != "function") {
260 throw new TypeError("Function.prototype.bind called on incompatible " + target);
261 }
262 var args = slice.call(arguments, 1); // for normal call
263 var bound = function () {
264
265 if (this instanceof bound) {
266
267 var result = target.apply(
268 this,
269 args.concat(slice.call(arguments))
270 );
271 if (Object(result) === result) {
272 return result;
273 }
274 return this;
275
276 } else {
277 return target.apply(
278 that,
279 args.concat(slice.call(arguments))
280 );
281
282 }
283
284 };
285 if(target.prototype) {
286 Empty.prototype = target.prototype;
287 bound.prototype = new Empty();
288 Empty.prototype = null;
289 }
290 return bound;
291 };
292 }
293 var call = Function.prototype.call;
294 var prototypeOfArray = Array.prototype;
295 var prototypeOfObject = Object.prototype;
296 var slice = prototypeOfArray.slice;
297 var _toString = call.bind(prototypeOfObject.toString);
298 var owns = call.bind(prototypeOfObject.hasOwnProperty);
299 var defineGetter;
300 var defineSetter;
301 var lookupGetter;
302 var lookupSetter;
303 var supportsAccessors;
304 if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
305 defineGetter = call.bind(prototypeOfObject.__defineGetter__);
306 defineSetter = call.bind(prototypeOfObject.__defineSetter__);
307 lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
308 lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
309 }
310 if ([1,2].splice(0).length != 2) {
311 if(function() { // test IE < 9 to splice bug - see issue #138
312 function makeArray(l) {
313 var a = new Array(l+2);
314 a[0] = a[1] = 0;
315 return a;
316 }
317 var array = [], lengthBefore;
318
319 array.splice.apply(array, makeArray(20));
320 array.splice.apply(array, makeArray(26));
321
322 lengthBefore = array.length; //46
323 array.splice(5, 0, "XXX"); // add one element
324
325 if (lengthBefore + 1 == array.length) {
326 return true;// has right splice implementation without bugs
327 }
328 }()) {//IE 6/7
329 var array_splice = Array.prototype.splice;
330 Array.prototype.splice = function(start, deleteCount) {
331 if (!arguments.length) {
332 return [];
333 } else {
334 return array_splice.apply(this, [
335 start === void 0 ? 0 : start,
336 deleteCount === void 0 ? (this.length - start) : deleteCount
337 ].concat(slice.call(arguments, 2)))
338 }
339 };
340 } else {//IE8
341 Array.prototype.splice = function(pos, removeCount){
342 var length = this.length;
343 if (pos > 0) {
344 if (pos > length)
345 pos = length;
346 } else if (pos == void 0) {
347 pos = 0;
348 } else if (pos < 0) {
349 pos = Math.max(length + pos, 0);
350 }
351
352 if (!(pos+removeCount < length))
353 removeCount = length - pos;
354
355 var removed = this.slice(pos, pos+removeCount);
356 var insert = slice.call(arguments, 2);
357 var add = insert.length;
358 if (pos === length) {
359 if (add) {
360 this.push.apply(this, insert);
361 }
362 } else {
363 var remove = Math.min(removeCount, length - pos);
364 var tailOldPos = pos + remove;
365 var tailNewPos = tailOldPos + add - remove;
366 var tailCount = length - tailOldPos;
367 var lengthAfterRemove = length - remove;
368
369 if (tailNewPos < tailOldPos) { // case A
370 for (var i = 0; i < tailCount; ++i) {
371 this[tailNewPos+i] = this[tailOldPos+i];
372 }
373 } else if (tailNewPos > tailOldPos) { // case B
374 for (i = tailCount; i--; ) {
375 this[tailNewPos+i] = this[tailOldPos+i];
376 }
377 } // else, add == remove (nothing to do)
378
379 if (add && pos === lengthAfterRemove) {
380 this.length = lengthAfterRemove; // truncate array
381 this.push.apply(this, insert);
382 } else {
383 this.length = lengthAfterRemove + add; // reserves space
384 for (i = 0; i < add; ++i) {
385 this[pos+i] = insert[i];
386 }
387 }
388 }
389 return removed;
390 };
391 }
392 }
393 if (!Array.isArray) {
394 Array.isArray = function isArray(obj) {
395 return _toString(obj) == "[object Array]";
396 };
397 }
398 var boxedString = Object("a"),
399 splitString = boxedString[0] != "a" || !(0 in boxedString);
400
401 if (!Array.prototype.forEach) {
402 Array.prototype.forEach = function forEach(fun /*, thisp*/) {
403 var object = toObject(this),
404 self = splitString && _toString(this) == "[object String]" ?
405 this.split("") :
406 object,
407 thisp = arguments[1],
408 i = -1,
409 length = self.length >>> 0;
410 if (_toString(fun) != "[object Function]") {
411 throw new TypeError(); // TODO message
412 }
413
414 while (++i < length) {
415 if (i in self) {
416 fun.call(thisp, self[i], i, object);
417 }
418 }
419 };
420 }
421 if (!Array.prototype.map) {
422 Array.prototype.map = function map(fun /*, thisp*/) {
423 var object = toObject(this),
424 self = splitString && _toString(this) == "[object String]" ?
425 this.split("") :
426 object,
427 length = self.length >>> 0,
428 result = Array(length),
429 thisp = arguments[1];
430 if (_toString(fun) != "[object Function]") {
431 throw new TypeError(fun + " is not a function");
432 }
433
434 for (var i = 0; i < length; i++) {
435 if (i in self)
436 result[i] = fun.call(thisp, self[i], i, object);
437 }
438 return result;
439 };
440 }
441 if (!Array.prototype.filter) {
442 Array.prototype.filter = function filter(fun /*, thisp */) {
443 var object = toObject(this),
444 self = splitString && _toString(this) == "[object String]" ?
445 this.split("") :
446 object,
447 length = self.length >>> 0,
448 result = [],
449 value,
450 thisp = arguments[1];
451 if (_toString(fun) != "[object Function]") {
452 throw new TypeError(fun + " is not a function");
453 }
454
455 for (var i = 0; i < length; i++) {
456 if (i in self) {
457 value = self[i];
458 if (fun.call(thisp, value, i, object)) {
459 result.push(value);
460 }
461 }
462 }
463 return result;
464 };
465 }
466 if (!Array.prototype.every) {
467 Array.prototype.every = function every(fun /*, thisp */) {
468 var object = toObject(this),
469 self = splitString && _toString(this) == "[object String]" ?
470 this.split("") :
471 object,
472 length = self.length >>> 0,
473 thisp = arguments[1];
474 if (_toString(fun) != "[object Function]") {
475 throw new TypeError(fun + " is not a function");
476 }
477
478 for (var i = 0; i < length; i++) {
479 if (i in self && !fun.call(thisp, self[i], i, object)) {
480 return false;
481 }
482 }
483 return true;
484 };
485 }
486 if (!Array.prototype.some) {
487 Array.prototype.some = function some(fun /*, thisp */) {
488 var object = toObject(this),
489 self = splitString && _toString(this) == "[object String]" ?
490 this.split("") :
491 object,
492 length = self.length >>> 0,
493 thisp = arguments[1];
494 if (_toString(fun) != "[object Function]") {
495 throw new TypeError(fun + " is not a function");
496 }
497
498 for (var i = 0; i < length; i++) {
499 if (i in self && fun.call(thisp, self[i], i, object)) {
500 return true;
501 }
502 }
503 return false;
504 };
505 }
506 if (!Array.prototype.reduce) {
507 Array.prototype.reduce = function reduce(fun /*, initial*/) {
508 var object = toObject(this),
509 self = splitString && _toString(this) == "[object String]" ?
510 this.split("") :
511 object,
512 length = self.length >>> 0;
513 if (_toString(fun) != "[object Function]") {
514 throw new TypeError(fun + " is not a function");
515 }
516 if (!length && arguments.length == 1) {
517 throw new TypeError("reduce of empty array with no initial value");
518 }
519
520 var i = 0;
521 var result;
522 if (arguments.length >= 2) {
523 result = arguments[1];
524 } else {
525 do {
526 if (i in self) {
527 result = self[i++];
528 break;
529 }
530 if (++i >= length) {
531 throw new TypeError("reduce of empty array with no initial value");
532 }
533 } while (true);
534 }
535
536 for (; i < length; i++) {
537 if (i in self) {
538 result = fun.call(void 0, result, self[i], i, object);
539 }
540 }
541
542 return result;
543 };
544 }
545 if (!Array.prototype.reduceRight) {
546 Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
547 var object = toObject(this),
548 self = splitString && _toString(this) == "[object String]" ?
549 this.split("") :
550 object,
551 length = self.length >>> 0;
552 if (_toString(fun) != "[object Function]") {
553 throw new TypeError(fun + " is not a function");
554 }
555 if (!length && arguments.length == 1) {
556 throw new TypeError("reduceRight of empty array with no initial value");
557 }
558
559 var result, i = length - 1;
560 if (arguments.length >= 2) {
561 result = arguments[1];
562 } else {
563 do {
564 if (i in self) {
565 result = self[i--];
566 break;
567 }
568 if (--i < 0) {
569 throw new TypeError("reduceRight of empty array with no initial value");
570 }
571 } while (true);
572 }
573
574 do {
575 if (i in this) {
576 result = fun.call(void 0, result, self[i], i, object);
577 }
578 } while (i--);
579
580 return result;
581 };
582 }
583 if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
584 Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
585 var self = splitString && _toString(this) == "[object String]" ?
586 this.split("") :
587 toObject(this),
588 length = self.length >>> 0;
589
590 if (!length) {
591 return -1;
592 }
593
594 var i = 0;
595 if (arguments.length > 1) {
596 i = toInteger(arguments[1]);
597 }
598 i = i >= 0 ? i : Math.max(0, length + i);
599 for (; i < length; i++) {
600 if (i in self && self[i] === sought) {
601 return i;
602 }
603 }
604 return -1;
605 };
606 }
607 if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
608 Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
609 var self = splitString && _toString(this) == "[object String]" ?
610 this.split("") :
611 toObject(this),
612 length = self.length >>> 0;
613
614 if (!length) {
615 return -1;
616 }
617 var i = length - 1;
618 if (arguments.length > 1) {
619 i = Math.min(i, toInteger(arguments[1]));
620 }
621 i = i >= 0 ? i : length - Math.abs(i);
622 for (; i >= 0; i--) {
623 if (i in self && sought === self[i]) {
624 return i;
625 }
626 }
627 return -1;
628 };
629 }
630 if (!Object.getPrototypeOf) {
631 Object.getPrototypeOf = function getPrototypeOf(object) {
632 return object.__proto__ || (
633 object.constructor ?
634 object.constructor.prototype :
635 prototypeOfObject
636 );
637 };
638 }
639 if (!Object.getOwnPropertyDescriptor) {
640 var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
641 "non-object: ";
642 Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
643 if ((typeof object != "object" && typeof object != "function") || object === null)
644 throw new TypeError(ERR_NON_OBJECT + object);
645 if (!owns(object, property))
646 return;
647
648 var descriptor, getter, setter;
649 descriptor = { enumerable: true, configurable: true };
650 if (supportsAccessors) {
651 var prototype = object.__proto__;
652 object.__proto__ = prototypeOfObject;
653
654 var getter = lookupGetter(object, property);
655 var setter = lookupSetter(object, property);
656 object.__proto__ = prototype;
657
658 if (getter || setter) {
659 if (getter) descriptor.get = getter;
660 if (setter) descriptor.set = setter;
661 return descriptor;
662 }
663 }
664 descriptor.value = object[property];
665 return descriptor;
666 };
667 }
668 if (!Object.getOwnPropertyNames) {
669 Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
670 return Object.keys(object);
671 };
672 }
673 if (!Object.create) {
674 var createEmpty;
675 if (Object.prototype.__proto__ === null) {
676 createEmpty = function () {
677 return { "__proto__": null };
678 };
679 } else {
680 createEmpty = function () {
681 var empty = {};
682 for (var i in empty)
683 empty[i] = null;
684 empty.constructor =
685 empty.hasOwnProperty =
686 empty.propertyIsEnumerable =
687 empty.isPrototypeOf =
688 empty.toLocaleString =
689 empty.toString =
690 empty.valueOf =
691 empty.__proto__ = null;
692 return empty;
693 };
694 }
695
696 Object.create = function create(prototype, properties) {
697 var object;
698 if (prototype === null) {
699 object = createEmpty();
700 } else {
701 if (typeof prototype != "object")
702 throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
703 var Type = function () {};
704 Type.prototype = prototype;
705 object = new Type();
706 object.__proto__ = prototype;
707 }
708 if (properties !== void 0)
709 Object.defineProperties(object, properties);
710 return object;
711 };
712 }
713
714 function doesDefinePropertyWork(object) {
715 try {
716 Object.defineProperty(object, "sentinel", {});
717 return "sentinel" in object;
718 } catch (exception) {
719 }
720 }
721 if (Object.defineProperty) {
722 var definePropertyWorksOnObject = doesDefinePropertyWork({});
723 var definePropertyWorksOnDom = typeof document == "undefined" ||
724 doesDefinePropertyWork(document.createElement("div"));
725 if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
726 var definePropertyFallback = Object.defineProperty;
727 }
728 }
729
730 if (!Object.defineProperty || definePropertyFallback) {
731 var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
732 var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: ";
733 var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
734 "on this javascript engine";
735
736 Object.defineProperty = function defineProperty(object, property, descriptor) {
737 if ((typeof object != "object" && typeof object != "function") || object === null)
738 throw new TypeError(ERR_NON_OBJECT_TARGET + object);
739 if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
740 throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
741 if (definePropertyFallback) {
742 try {
743 return definePropertyFallback.call(Object, object, property, descriptor);
744 } catch (exception) {
745 }
746 }
747 if (owns(descriptor, "value")) {
748
749 if (supportsAccessors && (lookupGetter(object, property) ||
750 lookupSetter(object, property)))
751 {
752 var prototype = object.__proto__;
753 object.__proto__ = prototypeOfObject;
754 delete object[property];
755 object[property] = descriptor.value;
756 object.__proto__ = prototype;
757 } else {
758 object[property] = descriptor.value;
759 }
760 } else {
761 if (!supportsAccessors)
762 throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
763 if (owns(descriptor, "get"))
764 defineGetter(object, property, descriptor.get);
765 if (owns(descriptor, "set"))
766 defineSetter(object, property, descriptor.set);
767 }
768
769 return object;
770 };
771 }
772 if (!Object.defineProperties) {
773 Object.defineProperties = function defineProperties(object, properties) {
774 for (var property in properties) {
775 if (owns(properties, property))
776 Object.defineProperty(object, property, properties[property]);
777 }
778 return object;
779 };
780 }
781 if (!Object.seal) {
782 Object.seal = function seal(object) {
783 return object;
784 };
785 }
786 if (!Object.freeze) {
787 Object.freeze = function freeze(object) {
788 return object;
789 };
790 }
791 try {
792 Object.freeze(function () {});
793 } catch (exception) {
794 Object.freeze = (function freeze(freezeObject) {
795 return function freeze(object) {
796 if (typeof object == "function") {
797 return object;
798 } else {
799 return freezeObject(object);
800 }
801 };
802 })(Object.freeze);
803 }
804 if (!Object.preventExtensions) {
805 Object.preventExtensions = function preventExtensions(object) {
806 return object;
807 };
808 }
809 if (!Object.isSealed) {
810 Object.isSealed = function isSealed(object) {
811 return false;
812 };
813 }
814 if (!Object.isFrozen) {
815 Object.isFrozen = function isFrozen(object) {
816 return false;
817 };
818 }
819 if (!Object.isExtensible) {
820 Object.isExtensible = function isExtensible(object) {
821 if (Object(object) === object) {
822 throw new TypeError(); // TODO message
823 }
824 var name = '';
825 while (owns(object, name)) {
826 name += '?';
827 }
828 object[name] = true;
829 var returnValue = owns(object, name);
830 delete object[name];
831 return returnValue;
832 };
833 }
834 if (!Object.keys) {
835 var hasDontEnumBug = true,
836 dontEnums = [
837 "toString",
838 "toLocaleString",
839 "valueOf",
840 "hasOwnProperty",
841 "isPrototypeOf",
842 "propertyIsEnumerable",
843 "constructor"
844 ],
845 dontEnumsLength = dontEnums.length;
846
847 for (var key in {"toString": null}) {
848 hasDontEnumBug = false;
849 }
850
851 Object.keys = function keys(object) {
852
853 if (
854 (typeof object != "object" && typeof object != "function") ||
855 object === null
856 ) {
857 throw new TypeError("Object.keys called on a non-object");
858 }
859
860 var keys = [];
861 for (var name in object) {
862 if (owns(object, name)) {
863 keys.push(name);
864 }
865 }
866
867 if (hasDontEnumBug) {
868 for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
869 var dontEnum = dontEnums[i];
870 if (owns(object, dontEnum)) {
871 keys.push(dontEnum);
872 }
873 }
874 }
875 return keys;
876 };
877
878 }
879 if (!Date.now) {
880 Date.now = function now() {
881 return new Date().getTime();
882 };
883 }
884 var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
885 "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
886 "\u2029\uFEFF";
887 if (!String.prototype.trim || ws.trim()) {
888 ws = "[" + ws + "]";
889 var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
890 trimEndRegexp = new RegExp(ws + ws + "*$");
891 String.prototype.trim = function trim() {
892 return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
893 };
894 }
895
896 function toInteger(n) {
897 n = +n;
898 if (n !== n) { // isNaN
899 n = 0;
900 } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
901 n = (n > 0 || -1) * Math.floor(Math.abs(n));
902 }
903 return n;
904 }
905 var toObject = function (o) {
906 if (o == null) { // this matches both null and undefined
907 throw new TypeError("can't convert "+o+" to object");
908 }
909 return Object(o);
910 };
911
912 });
913
914 ace.define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/regexp","ace/lib/es5-shim"], function(acequire, exports, module) {
915
916 acequire("./regexp");
917 acequire("./es5-shim");
918
919 });
920
921 ace.define("ace/lib/dom",["require","exports","module"], function(acequire, exports, module) {
922
923 var XHTML_NS = "http://www.w3.org/1999/xhtml";
924
925 exports.getDocumentHead = function(doc) {
926 if (!doc)
927 doc = document;
928 return doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement;
929 };
930
931 exports.createElement = function(tag, ns) {
932 return document.createElementNS ?
933 document.createElementNS(ns || XHTML_NS, tag) :
934 document.createElement(tag);
935 };
936
937 exports.hasCssClass = function(el, name) {
938 var classes = (el.className + "").split(/\s+/g);
939 return classes.indexOf(name) !== -1;
940 };
941 exports.addCssClass = function(el, name) {
942 if (!exports.hasCssClass(el, name)) {
943 el.className += " " + name;
944 }
945 };
946 exports.removeCssClass = function(el, name) {
947 var classes = el.className.split(/\s+/g);
948 while (true) {
949 var index = classes.indexOf(name);
950 if (index == -1) {
951 break;
952 }
953 classes.splice(index, 1);
954 }
955 el.className = classes.join(" ");
956 };
957
958 exports.toggleCssClass = function(el, name) {
959 var classes = el.className.split(/\s+/g), add = true;
960 while (true) {
961 var index = classes.indexOf(name);
962 if (index == -1) {
963 break;
964 }
965 add = false;
966 classes.splice(index, 1);
967 }
968 if (add)
969 classes.push(name);
970
971 el.className = classes.join(" ");
972 return add;
973 };
974 exports.setCssClass = function(node, className, include) {
975 if (include) {
976 exports.addCssClass(node, className);
977 } else {
978 exports.removeCssClass(node, className);
979 }
980 };
981
982 exports.hasCssString = function(id, doc) {
983 var index = 0, sheets;
984 doc = doc || document;
985
986 if (doc.createStyleSheet && (sheets = doc.styleSheets)) {
987 while (index < sheets.length)
988 if (sheets[index++].owningElement.id === id) return true;
989 } else if ((sheets = doc.getElementsByTagName("style"))) {
990 while (index < sheets.length)
991 if (sheets[index++].id === id) return true;
992 }
993
994 return false;
995 };
996
997 exports.importCssString = function importCssString(cssText, id, doc) {
998 doc = doc || document;
999 if (id && exports.hasCssString(id, doc))
1000 return null;
1001
1002 var style;
1003
1004 if (id)
1005 cssText += "\n/*# sourceURL=ace/css/" + id + " */";
1006
1007 if (doc.createStyleSheet) {
1008 style = doc.createStyleSheet();
1009 style.cssText = cssText;
1010 if (id)
1011 style.owningElement.id = id;
1012 } else {
1013 style = exports.createElement("style");
1014 style.appendChild(doc.createTextNode(cssText));
1015 if (id)
1016 style.id = id;
1017
1018 exports.getDocumentHead(doc).appendChild(style);
1019 }
1020 };
1021
1022 exports.importCssStylsheet = function(uri, doc) {
1023 if (doc.createStyleSheet) {
1024 doc.createStyleSheet(uri);
1025 } else {
1026 var link = exports.createElement('link');
1027 link.rel = 'stylesheet';
1028 link.href = uri;
1029
1030 exports.getDocumentHead(doc).appendChild(link);
1031 }
1032 };
1033
1034 exports.getInnerWidth = function(element) {
1035 return (
1036 parseInt(exports.computedStyle(element, "paddingLeft"), 10) +
1037 parseInt(exports.computedStyle(element, "paddingRight"), 10) +
1038 element.clientWidth
1039 );
1040 };
1041
1042 exports.getInnerHeight = function(element) {
1043 return (
1044 parseInt(exports.computedStyle(element, "paddingTop"), 10) +
1045 parseInt(exports.computedStyle(element, "paddingBottom"), 10) +
1046 element.clientHeight
1047 );
1048 };
1049
1050 exports.scrollbarWidth = function(document) {
1051 var inner = exports.createElement("ace_inner");
1052 inner.style.width = "100%";
1053 inner.style.minWidth = "0px";
1054 inner.style.height = "200px";
1055 inner.style.display = "block";
1056
1057 var outer = exports.createElement("ace_outer");
1058 var style = outer.style;
1059
1060 style.position = "absolute";
1061 style.left = "-10000px";
1062 style.overflow = "hidden";
1063 style.width = "200px";
1064 style.minWidth = "0px";
1065 style.height = "150px";
1066 style.display = "block";
1067
1068 outer.appendChild(inner);
1069
1070 var body = document.documentElement;
1071 body.appendChild(outer);
1072
1073 var noScrollbar = inner.offsetWidth;
1074
1075 style.overflow = "scroll";
1076 var withScrollbar = inner.offsetWidth;
1077
1078 if (noScrollbar == withScrollbar) {
1079 withScrollbar = outer.clientWidth;
1080 }
1081
1082 body.removeChild(outer);
1083
1084 return noScrollbar-withScrollbar;
1085 };
1086
1087 if (typeof document == "undefined") {
1088 exports.importCssString = function() {};
1089 return;
1090 }
1091
1092 if (window.pageYOffset !== undefined) {
1093 exports.getPageScrollTop = function() {
1094 return window.pageYOffset;
1095 };
1096
1097 exports.getPageScrollLeft = function() {
1098 return window.pageXOffset;
1099 };
1100 }
1101 else {
1102 exports.getPageScrollTop = function() {
1103 return document.body.scrollTop;
1104 };
1105
1106 exports.getPageScrollLeft = function() {
1107 return document.body.scrollLeft;
1108 };
1109 }
1110
1111 if (window.getComputedStyle)
1112 exports.computedStyle = function(element, style) {
1113 if (style)
1114 return (window.getComputedStyle(element, "") || {})[style] || "";
1115 return window.getComputedStyle(element, "") || {};
1116 };
1117 else
1118 exports.computedStyle = function(element, style) {
1119 if (style)
1120 return element.currentStyle[style];
1121 return element.currentStyle;
1122 };
1123 exports.setInnerHtml = function(el, innerHtml) {
1124 var element = el.cloneNode(false);//document.createElement("div");
1125 element.innerHTML = innerHtml;
1126 el.parentNode.replaceChild(element, el);
1127 return element;
1128 };
1129
1130 if ("textContent" in document.documentElement) {
1131 exports.setInnerText = function(el, innerText) {
1132 el.textContent = innerText;
1133 };
1134
1135 exports.getInnerText = function(el) {
1136 return el.textContent;
1137 };
1138 }
1139 else {
1140 exports.setInnerText = function(el, innerText) {
1141 el.innerText = innerText;
1142 };
1143
1144 exports.getInnerText = function(el) {
1145 return el.innerText;
1146 };
1147 }
1148
1149 exports.getParentWindow = function(document) {
1150 return document.defaultView || document.parentWindow;
1151 };
1152
1153 });
1154
1155 ace.define("ace/lib/oop",["require","exports","module"], function(acequire, exports, module) {
1156
1157 exports.inherits = function(ctor, superCtor) {
1158 ctor.super_ = superCtor;
1159 ctor.prototype = Object.create(superCtor.prototype, {
1160 constructor: {
1161 value: ctor,
1162 enumerable: false,
1163 writable: true,
1164 configurable: true
1165 }
1166 });
1167 };
1168
1169 exports.mixin = function(obj, mixin) {
1170 for (var key in mixin) {
1171 obj[key] = mixin[key];
1172 }
1173 return obj;
1174 };
1175
1176 exports.implement = function(proto, mixin) {
1177 exports.mixin(proto, mixin);
1178 };
1179
1180 });
1181
1182 ace.define("ace/lib/keys",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop"], function(acequire, exports, module) {
1183
1184 acequire("./fixoldbrowsers");
1185
1186 var oop = acequire("./oop");
1187 var Keys = (function() {
1188 var ret = {
1189 MODIFIER_KEYS: {
1190 16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta'
1191 },
1192
1193 KEY_MODS: {
1194 "ctrl": 1, "alt": 2, "option" : 2, "shift": 4,
1195 "super": 8, "meta": 8, "command": 8, "cmd": 8
1196 },
1197
1198 FUNCTION_KEYS : {
1199 8 : "Backspace",
1200 9 : "Tab",
1201 13 : "Return",
1202 19 : "Pause",
1203 27 : "Esc",
1204 32 : "Space",
1205 33 : "PageUp",
1206 34 : "PageDown",
1207 35 : "End",
1208 36 : "Home",
1209 37 : "Left",
1210 38 : "Up",
1211 39 : "Right",
1212 40 : "Down",
1213 44 : "Print",
1214 45 : "Insert",
1215 46 : "Delete",
1216 96 : "Numpad0",
1217 97 : "Numpad1",
1218 98 : "Numpad2",
1219 99 : "Numpad3",
1220 100: "Numpad4",
1221 101: "Numpad5",
1222 102: "Numpad6",
1223 103: "Numpad7",
1224 104: "Numpad8",
1225 105: "Numpad9",
1226 '-13': "NumpadEnter",
1227 112: "F1",
1228 113: "F2",
1229 114: "F3",
1230 115: "F4",
1231 116: "F5",
1232 117: "F6",
1233 118: "F7",
1234 119: "F8",
1235 120: "F9",
1236 121: "F10",
1237 122: "F11",
1238 123: "F12",
1239 144: "Numlock",
1240 145: "Scrolllock"
1241 },
1242
1243 PRINTABLE_KEYS: {
1244 32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
1245 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
1246 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
1247 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
1248 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
1249 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
1250 186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`',
1251 219: '[', 220: '\\',221: ']', 222: "'", 111: '/', 106: '*'
1252 }
1253 };
1254 var name, i;
1255 for (i in ret.FUNCTION_KEYS) {
1256 name = ret.FUNCTION_KEYS[i].toLowerCase();
1257 ret[name] = parseInt(i, 10);
1258 }
1259 for (i in ret.PRINTABLE_KEYS) {
1260 name = ret.PRINTABLE_KEYS[i].toLowerCase();
1261 ret[name] = parseInt(i, 10);
1262 }
1263 oop.mixin(ret, ret.MODIFIER_KEYS);
1264 oop.mixin(ret, ret.PRINTABLE_KEYS);
1265 oop.mixin(ret, ret.FUNCTION_KEYS);
1266 ret.enter = ret["return"];
1267 ret.escape = ret.esc;
1268 ret.del = ret["delete"];
1269 ret[173] = '-';
1270
1271 (function() {
1272 var mods = ["cmd", "ctrl", "alt", "shift"];
1273 for (var i = Math.pow(2, mods.length); i--;) {
1274 ret.KEY_MODS[i] = mods.filter(function(x) {
1275 return i & ret.KEY_MODS[x];
1276 }).join("-") + "-";
1277 }
1278 })();
1279
1280 ret.KEY_MODS[0] = "";
1281 ret.KEY_MODS[-1] = "input-";
1282
1283 return ret;
1284 })();
1285 oop.mixin(exports, Keys);
1286
1287 exports.keyCodeToString = function(keyCode) {
1288 var keyString = Keys[keyCode];
1289 if (typeof keyString != "string")
1290 keyString = String.fromCharCode(keyCode);
1291 return keyString.toLowerCase();
1292 };
1293
1294 });
1295
1296 ace.define("ace/lib/useragent",["require","exports","module"], function(acequire, exports, module) {
1297 exports.OS = {
1298 LINUX: "LINUX",
1299 MAC: "MAC",
1300 WINDOWS: "WINDOWS"
1301 };
1302 exports.getOS = function() {
1303 if (exports.isMac) {
1304 return exports.OS.MAC;
1305 } else if (exports.isLinux) {
1306 return exports.OS.LINUX;
1307 } else {
1308 return exports.OS.WINDOWS;
1309 }
1310 };
1311 if (typeof navigator != "object")
1312 return;
1313
1314 var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
1315 var ua = navigator.userAgent;
1316 exports.isWin = (os == "win");
1317 exports.isMac = (os == "mac");
1318 exports.isLinux = (os == "linux");
1319 exports.isIE =
1320 (navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0)
1321 ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1])
1322 : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie
1323
1324 exports.isOldIE = exports.isIE && exports.isIE < 9;
1325 exports.isGecko = exports.isMozilla = (window.Controllers || window.controllers) && window.navigator.product === "Gecko";
1326 exports.isOldGecko = exports.isGecko && parseInt((ua.match(/rv:(\d+)/)||[])[1], 10) < 4;
1327 exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
1328 exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
1329
1330 exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
1331
1332 exports.isAIR = ua.indexOf("AdobeAIR") >= 0;
1333
1334 exports.isIPad = ua.indexOf("iPad") >= 0;
1335
1336 exports.isChromeOS = ua.indexOf(" CrOS ") >= 0;
1337
1338 exports.isIOS = /iPad|iPhone|iPod/.test(ua) && !window.MSStream;
1339
1340 if (exports.isIOS) exports.isMac = true;
1341
1342 });
1343
1344 ace.define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(acequire, exports, module) {
1345
1346 var keys = acequire("./keys");
1347 var useragent = acequire("./useragent");
1348
1349 var pressedKeys = null;
1350 var ts = 0;
1351
1352 exports.addListener = function(elem, type, callback) {
1353 if (elem.addEventListener) {
1354 return elem.addEventListener(type, callback, false);
1355 }
1356 if (elem.attachEvent) {
1357 var wrapper = function() {
1358 callback.call(elem, window.event);
1359 };
1360 callback._wrapper = wrapper;
1361 elem.attachEvent("on" + type, wrapper);
1362 }
1363 };
1364
1365 exports.removeListener = function(elem, type, callback) {
1366 if (elem.removeEventListener) {
1367 return elem.removeEventListener(type, callback, false);
1368 }
1369 if (elem.detachEvent) {
1370 elem.detachEvent("on" + type, callback._wrapper || callback);
1371 }
1372 };
1373 exports.stopEvent = function(e) {
1374 exports.stopPropagation(e);
1375 exports.preventDefault(e);
1376 return false;
1377 };
1378
1379 exports.stopPropagation = function(e) {
1380 if (e.stopPropagation)
1381 e.stopPropagation();
1382 else
1383 e.cancelBubble = true;
1384 };
1385
1386 exports.preventDefault = function(e) {
1387 if (e.preventDefault)
1388 e.preventDefault();
1389 else
1390 e.returnValue = false;
1391 };
1392 exports.getButton = function(e) {
1393 if (e.type == "dblclick")
1394 return 0;
1395 if (e.type == "contextmenu" || (useragent.isMac && (e.ctrlKey && !e.altKey && !e.shiftKey)))
1396 return 2;
1397 if (e.preventDefault) {
1398 return e.button;
1399 }
1400 else {
1401 return {1:0, 2:2, 4:1}[e.button];
1402 }
1403 };
1404
1405 exports.capture = function(el, eventHandler, releaseCaptureHandler) {
1406 function onMouseUp(e) {
1407 eventHandler && eventHandler(e);
1408 releaseCaptureHandler && releaseCaptureHandler(e);
1409
1410 exports.removeListener(document, "mousemove", eventHandler, true);
1411 exports.removeListener(document, "mouseup", onMouseUp, true);
1412 exports.removeListener(document, "dragstart", onMouseUp, true);
1413 }
1414
1415 exports.addListener(document, "mousemove", eventHandler, true);
1416 exports.addListener(document, "mouseup", onMouseUp, true);
1417 exports.addListener(document, "dragstart", onMouseUp, true);
1418
1419 return onMouseUp;
1420 };
1421
1422 exports.addTouchMoveListener = function (el, callback) {
1423 var startx, starty;
1424 exports.addListener(el, "touchstart", function (e) {
1425 var touches = e.touches;
1426 var touchObj = touches[0];
1427 startx = touchObj.clientX;
1428 starty = touchObj.clientY;
1429 });
1430 exports.addListener(el, "touchmove", function (e) {
1431 var touches = e.touches;
1432 if (touches.length > 1) return;
1433
1434 var touchObj = touches[0];
1435
1436 e.wheelX = startx - touchObj.clientX;
1437 e.wheelY = starty - touchObj.clientY;
1438
1439 startx = touchObj.clientX;
1440 starty = touchObj.clientY;
1441
1442 callback(e);
1443 });
1444 };
1445
1446 exports.addMouseWheelListener = function(el, callback) {
1447 if ("onmousewheel" in el) {
1448 exports.addListener(el, "mousewheel", function(e) {
1449 var factor = 8;
1450 if (e.wheelDeltaX !== undefined) {
1451 e.wheelX = -e.wheelDeltaX / factor;
1452 e.wheelY = -e.wheelDeltaY / factor;
1453 } else {
1454 e.wheelX = 0;
1455 e.wheelY = -e.wheelDelta / factor;
1456 }
1457 callback(e);
1458 });
1459 } else if ("onwheel" in el) {
1460 exports.addListener(el, "wheel", function(e) {
1461 var factor = 0.35;
1462 switch (e.deltaMode) {
1463 case e.DOM_DELTA_PIXEL:
1464 e.wheelX = e.deltaX * factor || 0;
1465 e.wheelY = e.deltaY * factor || 0;
1466 break;
1467 case e.DOM_DELTA_LINE:
1468 case e.DOM_DELTA_PAGE:
1469 e.wheelX = (e.deltaX || 0) * 5;
1470 e.wheelY = (e.deltaY || 0) * 5;
1471 break;
1472 }
1473
1474 callback(e);
1475 });
1476 } else {
1477 exports.addListener(el, "DOMMouseScroll", function(e) {
1478 if (e.axis && e.axis == e.HORIZONTAL_AXIS) {
1479 e.wheelX = (e.detail || 0) * 5;
1480 e.wheelY = 0;
1481 } else {
1482 e.wheelX = 0;
1483 e.wheelY = (e.detail || 0) * 5;
1484 }
1485 callback(e);
1486 });
1487 }
1488 };
1489
1490 exports.addMultiMouseDownListener = function(elements, timeouts, eventHandler, callbackName) {
1491 var clicks = 0;
1492 var startX, startY, timer;
1493 var eventNames = {
1494 2: "dblclick",
1495 3: "tripleclick",
1496 4: "quadclick"
1497 };
1498
1499 function onMousedown(e) {
1500 if (exports.getButton(e) !== 0) {
1501 clicks = 0;
1502 } else if (e.detail > 1) {
1503 clicks++;
1504 if (clicks > 4)
1505 clicks = 1;
1506 } else {
1507 clicks = 1;
1508 }
1509 if (useragent.isIE) {
1510 var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5;
1511 if (!timer || isNewClick)
1512 clicks = 1;
1513 if (timer)
1514 clearTimeout(timer);
1515 timer = setTimeout(function() {timer = null;}, timeouts[clicks - 1] || 600);
1516
1517 if (clicks == 1) {
1518 startX = e.clientX;
1519 startY = e.clientY;
1520 }
1521 }
1522
1523 e._clicks = clicks;
1524
1525 eventHandler[callbackName]("mousedown", e);
1526
1527 if (clicks > 4)
1528 clicks = 0;
1529 else if (clicks > 1)
1530 return eventHandler[callbackName](eventNames[clicks], e);
1531 }
1532 function onDblclick(e) {
1533 clicks = 2;
1534 if (timer)
1535 clearTimeout(timer);
1536 timer = setTimeout(function() {timer = null;}, timeouts[clicks - 1] || 600);
1537 eventHandler[callbackName]("mousedown", e);
1538 eventHandler[callbackName](eventNames[clicks], e);
1539 }
1540 if (!Array.isArray(elements))
1541 elements = [elements];
1542 elements.forEach(function(el) {
1543 exports.addListener(el, "mousedown", onMousedown);
1544 if (useragent.isOldIE)
1545 exports.addListener(el, "dblclick", onDblclick);
1546 });
1547 };
1548
1549 var getModifierHash = useragent.isMac && useragent.isOpera && !("KeyboardEvent" in window)
1550 ? function(e) {
1551 return 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0);
1552 }
1553 : function(e) {
1554 return 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
1555 };
1556
1557 exports.getModifierString = function(e) {
1558 return keys.KEY_MODS[getModifierHash(e)];
1559 };
1560
1561 function normalizeCommandKeys(callback, e, keyCode) {
1562 var hashId = getModifierHash(e);
1563
1564 if (!useragent.isMac && pressedKeys) {
1565 if (e.getModifierState && (e.getModifierState("OS") || e.getModifierState("Win")))
1566 hashId |= 8;
1567 if (pressedKeys.altGr) {
1568 if ((3 & hashId) != 3)
1569 pressedKeys.altGr = 0;
1570 else
1571 return;
1572 }
1573 if (keyCode === 18 || keyCode === 17) {
1574 var location = "location" in e ? e.location : e.keyLocation;
1575 if (keyCode === 17 && location === 1) {
1576 if (pressedKeys[keyCode] == 1)
1577 ts = e.timeStamp;
1578 } else if (keyCode === 18 && hashId === 3 && location === 2) {
1579 var dt = e.timeStamp - ts;
1580 if (dt < 50)
1581 pressedKeys.altGr = true;
1582 }
1583 }
1584 }
1585
1586 if (keyCode in keys.MODIFIER_KEYS) {
1587 keyCode = -1;
1588 }
1589 if (hashId & 8 && (keyCode >= 91 && keyCode <= 93)) {
1590 keyCode = -1;
1591 }
1592
1593 if (!hashId && keyCode === 13) {
1594 var location = "location" in e ? e.location : e.keyLocation;
1595 if (location === 3) {
1596 callback(e, hashId, -keyCode);
1597 if (e.defaultPrevented)
1598 return;
1599 }
1600 }
1601
1602 if (useragent.isChromeOS && hashId & 8) {
1603 callback(e, hashId, keyCode);
1604 if (e.defaultPrevented)
1605 return;
1606 else
1607 hashId &= ~8;
1608 }
1609 if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) {
1610 return false;
1611 }
1612
1613 return callback(e, hashId, keyCode);
1614 }
1615
1616
1617 exports.addCommandKeyListener = function(el, callback) {
1618 var addListener = exports.addListener;
1619 if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) {
1620 var lastKeyDownKeyCode = null;
1621 addListener(el, "keydown", function(e) {
1622 lastKeyDownKeyCode = e.keyCode;
1623 });
1624 addListener(el, "keypress", function(e) {
1625 return normalizeCommandKeys(callback, e, lastKeyDownKeyCode);
1626 });
1627 } else {
1628 var lastDefaultPrevented = null;
1629
1630 addListener(el, "keydown", function(e) {
1631 pressedKeys[e.keyCode] = (pressedKeys[e.keyCode] || 0) + 1;
1632 var result = normalizeCommandKeys(callback, e, e.keyCode);
1633 lastDefaultPrevented = e.defaultPrevented;
1634 return result;
1635 });
1636
1637 addListener(el, "keypress", function(e) {
1638 if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
1639 exports.stopEvent(e);
1640 lastDefaultPrevented = null;
1641 }
1642 });
1643
1644 addListener(el, "keyup", function(e) {
1645 pressedKeys[e.keyCode] = null;
1646 });
1647
1648 if (!pressedKeys) {
1649 resetPressedKeys();
1650 addListener(window, "focus", resetPressedKeys);
1651 }
1652 }
1653 };
1654 function resetPressedKeys() {
1655 pressedKeys = Object.create(null);
1656 }
1657
1658 if (typeof window == "object" && window.postMessage && !useragent.isOldIE) {
1659 var postMessageId = 1;
1660 exports.nextTick = function(callback, win) {
1661 win = win || window;
1662 var messageName = "zero-timeout-message-" + postMessageId;
1663 exports.addListener(win, "message", function listener(e) {
1664 if (e.data == messageName) {
1665 exports.stopPropagation(e);
1666 exports.removeListener(win, "message", listener);
1667 callback();
1668 }
1669 });
1670 win.postMessage(messageName, "*");
1671 };
1672 }
1673
1674
1675 exports.nextFrame = typeof window == "object" && (window.requestAnimationFrame
1676 || window.mozRequestAnimationFrame
1677 || window.webkitRequestAnimationFrame
1678 || window.msRequestAnimationFrame
1679 || window.oRequestAnimationFrame);
1680
1681 if (exports.nextFrame)
1682 exports.nextFrame = exports.nextFrame.bind(window);
1683 else
1684 exports.nextFrame = function(callback) {
1685 setTimeout(callback, 17);
1686 };
1687 });
1688
1689 ace.define("ace/lib/lang",["require","exports","module"], function(acequire, exports, module) {
1690
1691 exports.last = function(a) {
1692 return a[a.length - 1];
1693 };
1694
1695 exports.stringReverse = function(string) {
1696 return string.split("").reverse().join("");
1697 };
1698
1699 exports.stringRepeat = function (string, count) {
1700 var result = '';
1701 while (count > 0) {
1702 if (count & 1)
1703 result += string;
1704
1705 if (count >>= 1)
1706 string += string;
1707 }
1708 return result;
1709 };
1710
1711 var trimBeginRegexp = /^\s\s*/;
1712 var trimEndRegexp = /\s\s*$/;
1713
1714 exports.stringTrimLeft = function (string) {
1715 return string.replace(trimBeginRegexp, '');
1716 };
1717
1718 exports.stringTrimRight = function (string) {
1719 return string.replace(trimEndRegexp, '');
1720 };
1721
1722 exports.copyObject = function(obj) {
1723 var copy = {};
1724 for (var key in obj) {
1725 copy[key] = obj[key];
1726 }
1727 return copy;
1728 };
1729
1730 exports.copyArray = function(array){
1731 var copy = [];
1732 for (var i=0, l=array.length; i<l; i++) {
1733 if (array[i] && typeof array[i] == "object")
1734 copy[i] = this.copyObject(array[i]);
1735 else
1736 copy[i] = array[i];
1737 }
1738 return copy;
1739 };
1740
1741 exports.deepCopy = function deepCopy(obj) {
1742 if (typeof obj !== "object" || !obj)
1743 return obj;
1744 var copy;
1745 if (Array.isArray(obj)) {
1746 copy = [];
1747 for (var key = 0; key < obj.length; key++) {
1748 copy[key] = deepCopy(obj[key]);
1749 }
1750 return copy;
1751 }
1752 if (Object.prototype.toString.call(obj) !== "[object Object]")
1753 return obj;
1754
1755 copy = {};
1756 for (var key in obj)
1757 copy[key] = deepCopy(obj[key]);
1758 return copy;
1759 };
1760
1761 exports.arrayToMap = function(arr) {
1762 var map = {};
1763 for (var i=0; i<arr.length; i++) {
1764 map[arr[i]] = 1;
1765 }
1766 return map;
1767
1768 };
1769
1770 exports.createMap = function(props) {
1771 var map = Object.create(null);
1772 for (var i in props) {
1773 map[i] = props[i];
1774 }
1775 return map;
1776 };
1777 exports.arrayRemove = function(array, value) {
1778 for (var i = 0; i <= array.length; i++) {
1779 if (value === array[i]) {
1780 array.splice(i, 1);
1781 }
1782 }
1783 };
1784
1785 exports.escapeRegExp = function(str) {
1786 return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
1787 };
1788
1789 exports.escapeHTML = function(str) {
1790 return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
1791 };
1792
1793 exports.getMatchOffsets = function(string, regExp) {
1794 var matches = [];
1795
1796 string.replace(regExp, function(str) {
1797 matches.push({
1798 offset: arguments[arguments.length-2],
1799 length: str.length
1800 });
1801 });
1802
1803 return matches;
1804 };
1805 exports.deferredCall = function(fcn) {
1806 var timer = null;
1807 var callback = function() {
1808 timer = null;
1809 fcn();
1810 };
1811
1812 var deferred = function(timeout) {
1813 deferred.cancel();
1814 timer = setTimeout(callback, timeout || 0);
1815 return deferred;
1816 };
1817
1818 deferred.schedule = deferred;
1819
1820 deferred.call = function() {
1821 this.cancel();
1822 fcn();
1823 return deferred;
1824 };
1825
1826 deferred.cancel = function() {
1827 clearTimeout(timer);
1828 timer = null;
1829 return deferred;
1830 };
1831
1832 deferred.isPending = function() {
1833 return timer;
1834 };
1835
1836 return deferred;
1837 };
1838
1839
1840 exports.delayedCall = function(fcn, defaultTimeout) {
1841 var timer = null;
1842 var callback = function() {
1843 timer = null;
1844 fcn();
1845 };
1846
1847 var _self = function(timeout) {
1848 if (timer == null)
1849 timer = setTimeout(callback, timeout || defaultTimeout);
1850 };
1851
1852 _self.delay = function(timeout) {
1853 timer && clearTimeout(timer);
1854 timer = setTimeout(callback, timeout || defaultTimeout);
1855 };
1856 _self.schedule = _self;
1857
1858 _self.call = function() {
1859 this.cancel();
1860 fcn();
1861 };
1862
1863 _self.cancel = function() {
1864 timer && clearTimeout(timer);
1865 timer = null;
1866 };
1867
1868 _self.isPending = function() {
1869 return timer;
1870 };
1871
1872 return _self;
1873 };
1874 });
1875
1876 ace.define("ace/keyboard/textinput_ios",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom","ace/lib/lang","ace/lib/keys"], function(acequire, exports, module) {
1877
1878 var event = acequire("../lib/event");
1879 var useragent = acequire("../lib/useragent");
1880 var dom = acequire("../lib/dom");
1881 var lang = acequire("../lib/lang");
1882 var KEYS = acequire("../lib/keys");
1883 var MODS = KEYS.KEY_MODS;
1884 var BROKEN_SETDATA = useragent.isChrome < 18;
1885 var USE_IE_MIME_TYPE = useragent.isIE;
1886
1887 var TextInput = function(parentNode, host) {
1888 var text = dom.createElement("textarea");
1889 text.className = useragent.isIOS ? "ace_text-input ace_text-input-ios" : "ace_text-input";
1890
1891 if (useragent.isTouchPad)
1892 text.setAttribute("x-palm-disable-auto-cap", true);
1893
1894 text.setAttribute("wrap", "off");
1895 text.setAttribute("autocorrect", "off");
1896 text.setAttribute("autocapitalize", "off");
1897 text.setAttribute("spellcheck", false);
1898
1899 text.style.opacity = "0";
1900 parentNode.insertBefore(text, parentNode.firstChild);
1901
1902 var PLACEHOLDER = "\n aaaa a\n";
1903
1904 var copied = false;
1905 var cut = false;
1906 var pasted = false;
1907 var inComposition = false;
1908 var tempStyle = '';
1909 var isSelectionEmpty = true;
1910 try { var isFocused = document.activeElement === text; } catch(e) {}
1911
1912 event.addListener(text, "blur", function(e) {
1913 host.onBlur(e);
1914 isFocused = false;
1915 });
1916 event.addListener(text, "focus", function(e) {
1917 isFocused = true;
1918 host.onFocus(e);
1919 resetSelection();
1920 });
1921 this.focus = function() {
1922 if (tempStyle) return text.focus();
1923 text.style.position = "fixed";
1924 text.focus();
1925 };
1926 this.blur = function() {
1927 text.blur();
1928 };
1929 this.isFocused = function() {
1930 return isFocused;
1931 };
1932 var syncSelection = lang.delayedCall(function() {
1933 isFocused && resetSelection(isSelectionEmpty);
1934 });
1935 var syncValue = lang.delayedCall(function() {
1936 if (!inComposition) {
1937 text.value = PLACEHOLDER;
1938 isFocused && resetSelection();
1939 }
1940 });
1941
1942 function resetSelection(isEmpty) {
1943 if (inComposition)
1944 return;
1945 inComposition = true;
1946
1947 if (inputHandler) {
1948 selectionStart = 0;
1949 selectionEnd = isEmpty ? 0 : text.value.length - 1;
1950 } else {
1951 var selectionStart = 4;
1952 var selectionEnd = 5;
1953 }
1954 try {
1955 text.setSelectionRange(selectionStart, selectionEnd);
1956 } catch(e) {}
1957
1958 inComposition = false;
1959 }
1960
1961 function resetValue() {
1962 if (inComposition)
1963 return;
1964 text.value = PLACEHOLDER;
1965 if (useragent.isWebKit)
1966 syncValue.schedule();
1967 }
1968
1969 useragent.isWebKit || host.addEventListener('changeSelection', function() {
1970 if (host.selection.isEmpty() != isSelectionEmpty) {
1971 isSelectionEmpty = !isSelectionEmpty;
1972 syncSelection.schedule();
1973 }
1974 });
1975
1976 resetValue();
1977 if (isFocused)
1978 host.onFocus();
1979
1980
1981 var isAllSelected = function(text) {
1982 return text.selectionStart === 0 && text.selectionEnd === text.value.length;
1983 };
1984
1985 var onSelect = function(e) {
1986 if (isAllSelected(text)) {
1987 host.selectAll();
1988 resetSelection();
1989 } else if (inputHandler) {
1990 resetSelection(host.selection.isEmpty());
1991 }
1992 };
1993
1994 var inputHandler = null;
1995 this.setInputHandler = function(cb) {inputHandler = cb;};
1996 this.getInputHandler = function() {return inputHandler;};
1997 var afterContextMenu = false;
1998
1999 var sendText = function(data) {
2000 if (text.selectionStart === 4 && text.selectionEnd === 5) {
2001 return;
2002 }
2003 if (inputHandler) {
2004 data = inputHandler(data);
2005 inputHandler = null;
2006 }
2007 if (pasted) {
2008 resetSelection();
2009 if (data)
2010 host.onPaste(data);
2011 pasted = false;
2012 } else if (data == PLACEHOLDER.substr(0) && text.selectionStart === 4) {
2013 if (afterContextMenu)
2014 host.execCommand("del", {source: "ace"});
2015 else // some versions of android do not fire keydown when pressing backspace
2016 host.execCommand("backspace", {source: "ace"});
2017 } else if (!copied) {
2018 if (data.substring(0, 9) == PLACEHOLDER && data.length > PLACEHOLDER.length)
2019 data = data.substr(9);
2020 else if (data.substr(0, 4) == PLACEHOLDER.substr(0, 4))
2021 data = data.substr(4, data.length - PLACEHOLDER.length + 1);
2022 else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
2023 data = data.slice(0, -1);
2024 if (data == PLACEHOLDER.charAt(0)) ; else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
2025 data = data.slice(0, -1);
2026
2027 if (data)
2028 host.onTextInput(data);
2029 }
2030 if (copied) {
2031 copied = false;
2032 }
2033 if (afterContextMenu)
2034 afterContextMenu = false;
2035 };
2036 var onInput = function(e) {
2037 if (inComposition)
2038 return;
2039 var data = text.value;
2040 sendText(data);
2041 resetValue();
2042 };
2043
2044 var handleClipboardData = function(e, data, forceIEMime) {
2045 var clipboardData = e.clipboardData || window.clipboardData;
2046 if (!clipboardData || BROKEN_SETDATA)
2047 return;
2048 var mime = USE_IE_MIME_TYPE || forceIEMime ? "Text" : "text/plain";
2049 try {
2050 if (data) {
2051 return clipboardData.setData(mime, data) !== false;
2052 } else {
2053 return clipboardData.getData(mime);
2054 }
2055 } catch(e) {
2056 if (!forceIEMime)
2057 return handleClipboardData(e, data, true);
2058 }
2059 };
2060
2061 var doCopy = function(e, isCut) {
2062 var data = host.getCopyText();
2063 if (!data)
2064 return event.preventDefault(e);
2065
2066 if (handleClipboardData(e, data)) {
2067 if (useragent.isIOS) {
2068 cut = isCut;
2069 text.value = "\n aa" + data + "a a\n";
2070 text.setSelectionRange(4, 4 + data.length);
2071 copied = {
2072 value: data
2073 };
2074 }
2075 isCut ? host.onCut() : host.onCopy();
2076 if (!useragent.isIOS) event.preventDefault(e);
2077 } else {
2078 copied = true;
2079 text.value = data;
2080 text.select();
2081 setTimeout(function(){
2082 copied = false;
2083 resetValue();
2084 resetSelection();
2085 isCut ? host.onCut() : host.onCopy();
2086 });
2087 }
2088 };
2089
2090 var onCut = function(e) {
2091 doCopy(e, true);
2092 };
2093
2094 var onCopy = function(e) {
2095 doCopy(e, false);
2096 };
2097
2098 var onPaste = function(e) {
2099 var data = handleClipboardData(e);
2100 if (typeof data == "string") {
2101 if (data)
2102 host.onPaste(data, e);
2103 if (useragent.isIE)
2104 setTimeout(resetSelection);
2105 event.preventDefault(e);
2106 }
2107 else {
2108 text.value = "";
2109 pasted = true;
2110 }
2111 };
2112
2113 event.addCommandKeyListener(text, host.onCommandKey.bind(host));
2114
2115 event.addListener(text, "select", onSelect);
2116
2117 event.addListener(text, "input", onInput);
2118
2119 event.addListener(text, "cut", onCut);
2120 event.addListener(text, "copy", onCopy);
2121 event.addListener(text, "paste", onPaste);
2122 var onCompositionStart = function(e) {
2123 if (inComposition || !host.onCompositionStart || host.$readOnly)
2124 return;
2125 inComposition = {};
2126 inComposition.canUndo = host.session.$undoManager;
2127 host.onCompositionStart();
2128 setTimeout(onCompositionUpdate, 0);
2129 host.on("mousedown", onCompositionEnd);
2130 if (inComposition.canUndo && !host.selection.isEmpty()) {
2131 host.insert("");
2132 host.session.markUndoGroup();
2133 host.selection.clearSelection();
2134 }
2135 host.session.markUndoGroup();
2136 };
2137
2138 var onCompositionUpdate = function() {
2139 if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
2140 return;
2141 var val = text.value.replace(/\x01/g, "");
2142 if (inComposition.lastValue === val) return;
2143
2144 host.onCompositionUpdate(val);
2145 if (inComposition.lastValue)
2146 host.undo();
2147 if (inComposition.canUndo)
2148 inComposition.lastValue = val;
2149 if (inComposition.lastValue) {
2150 var r = host.selection.getRange();
2151 host.insert(inComposition.lastValue);
2152 host.session.markUndoGroup();
2153 inComposition.range = host.selection.getRange();
2154 host.selection.setRange(r);
2155 host.selection.clearSelection();
2156 }
2157 };
2158
2159 var onCompositionEnd = function(e) {
2160 if (!host.onCompositionEnd || host.$readOnly) return;
2161 var c = inComposition;
2162 inComposition = false;
2163 var timer = setTimeout(function() {
2164 timer = null;
2165 var str = text.value.replace(/\x01/g, "");
2166 if (inComposition)
2167 return;
2168 else if (str == c.lastValue)
2169 resetValue();
2170 else if (!c.lastValue && str) {
2171 resetValue();
2172 sendText(str);
2173 }
2174 });
2175 inputHandler = function compositionInputHandler(str) {
2176 if (timer)
2177 clearTimeout(timer);
2178 str = str.replace(/\x01/g, "");
2179 if (str == c.lastValue)
2180 return "";
2181 if (c.lastValue && timer)
2182 host.undo();
2183 return str;
2184 };
2185 host.onCompositionEnd();
2186 host.removeListener("mousedown", onCompositionEnd);
2187 if (e.type == "compositionend" && c.range) {
2188 host.selection.setRange(c.range);
2189 }
2190 var needsOnInput =
2191 (!!useragent.isChrome && useragent.isChrome >= 53) ||
2192 (!!useragent.isWebKit && useragent.isWebKit >= 603);
2193
2194 if (needsOnInput) {
2195 onInput();
2196 }
2197 };
2198
2199
2200
2201 var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
2202
2203 event.addListener(text, "compositionstart", onCompositionStart);
2204 if (useragent.isGecko) {
2205 event.addListener(text, "text", function(){syncComposition.schedule();});
2206 } else {
2207 event.addListener(text, "keyup", function(){syncComposition.schedule();});
2208 event.addListener(text, "keydown", function(){syncComposition.schedule();});
2209 }
2210 event.addListener(text, "compositionend", onCompositionEnd);
2211
2212 this.getElement = function() {
2213 return text;
2214 };
2215
2216 this.setReadOnly = function(readOnly) {
2217 text.readOnly = readOnly;
2218 };
2219
2220 this.onContextMenu = function(e) {
2221 afterContextMenu = true;
2222 resetSelection(host.selection.isEmpty());
2223 host._emit("nativecontextmenu", {target: host, domEvent: e});
2224 this.moveToMouse(e, true);
2225 };
2226
2227 this.moveToMouse = function(e, bringToFront) {
2228 if (!tempStyle)
2229 tempStyle = text.style.cssText;
2230 text.style.cssText = (bringToFront ? "z-index:100000;" : "")
2231 + "height:" + text.style.height + ";"
2232 + (useragent.isIE ? "opacity:0.1;" : "");
2233
2234 var rect = host.container.getBoundingClientRect();
2235 var style = dom.computedStyle(host.container);
2236 var top = rect.top + (parseInt(style.borderTopWidth) || 0);
2237 var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
2238 var maxTop = rect.bottom - top - text.clientHeight -2;
2239 var move = function(e) {
2240 text.style.left = e.clientX - left - 2 + "px";
2241 text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
2242 };
2243 move(e);
2244
2245 if (e.type != "mousedown")
2246 return;
2247
2248 if (host.renderer.$keepTextAreaAtCursor)
2249 host.renderer.$keepTextAreaAtCursor = null;
2250
2251 clearTimeout(closeTimeout);
2252 if (useragent.isWin)
2253 event.capture(host.container, move, onContextMenuClose);
2254 };
2255
2256 this.onContextMenuClose = onContextMenuClose;
2257 var closeTimeout;
2258 function onContextMenuClose() {
2259 clearTimeout(closeTimeout);
2260 closeTimeout = setTimeout(function () {
2261 if (tempStyle) {
2262 text.style.cssText = tempStyle;
2263 tempStyle = '';
2264 }
2265 if (host.renderer.$keepTextAreaAtCursor == null) {
2266 host.renderer.$keepTextAreaAtCursor = true;
2267 host.renderer.$moveTextAreaToCursor();
2268 }
2269 }, 0);
2270 }
2271
2272 var onContextMenu = function(e) {
2273 host.textInput.onContextMenu(e);
2274 onContextMenuClose();
2275 };
2276 event.addListener(text, "mouseup", onContextMenu);
2277 event.addListener(text, "mousedown", function(e) {
2278 e.preventDefault();
2279 onContextMenuClose();
2280 });
2281 event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
2282 event.addListener(text, "contextmenu", onContextMenu);
2283
2284 if (useragent.isIOS) {
2285 var typingResetTimeout = null;
2286 var typing = false;
2287
2288 parentNode.addEventListener("keydown", function (e) {
2289 if (typingResetTimeout) clearTimeout(typingResetTimeout);
2290 typing = true;
2291 });
2292
2293 parentNode.addEventListener("keyup", function (e) {
2294 typingResetTimeout = setTimeout(function () {
2295 typing = false;
2296 }, 100);
2297 });
2298 var detectArrowKeys = function(e) {
2299 if (document.activeElement !== text) return;
2300 if (typing) return;
2301
2302 if (cut) {
2303 return setTimeout(function () {
2304 cut = false;
2305 }, 100);
2306 }
2307 var selectionStart = text.selectionStart;
2308 var selectionEnd = text.selectionEnd;
2309 text.setSelectionRange(4, 5);
2310 if (selectionStart == selectionEnd) {
2311 switch (selectionStart) {
2312 case 0: host.onCommandKey(null, 0, KEYS.up); break;
2313 case 1: host.onCommandKey(null, 0, KEYS.home); break;
2314 case 2: host.onCommandKey(null, MODS.option, KEYS.left); break;
2315 case 4: host.onCommandKey(null, 0, KEYS.left); break;
2316 case 5: host.onCommandKey(null, 0, KEYS.right); break;
2317 case 7: host.onCommandKey(null, MODS.option, KEYS.right); break;
2318 case 8: host.onCommandKey(null, 0, KEYS.end); break;
2319 case 9: host.onCommandKey(null, 0, KEYS.down); break;
2320 }
2321 } else {
2322 switch (selectionEnd) {
2323 case 6: host.onCommandKey(null, MODS.shift, KEYS.right); break;
2324 case 7: host.onCommandKey(null, MODS.shift | MODS.option, KEYS.right); break;
2325 case 8: host.onCommandKey(null, MODS.shift, KEYS.end); break;
2326 case 9: host.onCommandKey(null, MODS.shift, KEYS.down); break;
2327 }
2328 switch (selectionStart) {
2329 case 0: host.onCommandKey(null, MODS.shift, KEYS.up); break;
2330 case 1: host.onCommandKey(null, MODS.shift, KEYS.home); break;
2331 case 2: host.onCommandKey(null, MODS.shift | MODS.option, KEYS.left); break;
2332 case 3: host.onCommandKey(null, MODS.shift, KEYS.left); break;
2333 }
2334 }
2335 };
2336 document.addEventListener("selectionchange", detectArrowKeys);
2337 host.on("destroy", function() {
2338 document.removeEventListener("selectionchange", detectArrowKeys);
2339 });
2340 }
2341 };
2342
2343 exports.TextInput = TextInput;
2344 });
2345
2346 ace.define("ace/keyboard/textinput",["require","exports","module","ace/lib/event","ace/lib/useragent","ace/lib/dom","ace/lib/lang","ace/keyboard/textinput_ios"], function(acequire, exports, module) {
2347
2348 var event = acequire("../lib/event");
2349 var useragent = acequire("../lib/useragent");
2350 var dom = acequire("../lib/dom");
2351 var lang = acequire("../lib/lang");
2352 var BROKEN_SETDATA = useragent.isChrome < 18;
2353 var USE_IE_MIME_TYPE = useragent.isIE;
2354
2355 var TextInputIOS = acequire("./textinput_ios").TextInput;
2356 var TextInput = function(parentNode, host) {
2357 if (useragent.isIOS)
2358 return TextInputIOS.call(this, parentNode, host);
2359
2360 var text = dom.createElement("textarea");
2361 text.className = "ace_text-input";
2362
2363 text.setAttribute("wrap", "off");
2364 text.setAttribute("autocorrect", "off");
2365 text.setAttribute("autocapitalize", "off");
2366 text.setAttribute("spellcheck", false);
2367
2368 text.style.opacity = "0";
2369 parentNode.insertBefore(text, parentNode.firstChild);
2370
2371 var PLACEHOLDER = "\u2028\u2028";
2372
2373 var copied = false;
2374 var pasted = false;
2375 var inComposition = false;
2376 var tempStyle = '';
2377 var isSelectionEmpty = true;
2378 try { var isFocused = document.activeElement === text; } catch(e) {}
2379
2380 event.addListener(text, "blur", function(e) {
2381 host.onBlur(e);
2382 isFocused = false;
2383 });
2384 event.addListener(text, "focus", function(e) {
2385 isFocused = true;
2386 host.onFocus(e);
2387 resetSelection();
2388 });
2389 this.focus = function() {
2390 if (tempStyle) return text.focus();
2391 var top = text.style.top;
2392 text.style.position = "fixed";
2393 text.style.top = "0px";
2394 text.focus();
2395 setTimeout(function() {
2396 text.style.position = "";
2397 if (text.style.top == "0px")
2398 text.style.top = top;
2399 }, 0);
2400 };
2401 this.blur = function() {
2402 text.blur();
2403 };
2404 this.isFocused = function() {
2405 return isFocused;
2406 };
2407 var syncSelection = lang.delayedCall(function() {
2408 isFocused && resetSelection(isSelectionEmpty);
2409 });
2410 var syncValue = lang.delayedCall(function() {
2411 if (!inComposition) {
2412 text.value = PLACEHOLDER;
2413 isFocused && resetSelection();
2414 }
2415 });
2416
2417 function resetSelection(isEmpty) {
2418 if (inComposition)
2419 return;
2420 inComposition = true;
2421
2422 if (inputHandler) {
2423 var selectionStart = 0;
2424 var selectionEnd = isEmpty ? 0 : text.value.length - 1;
2425 } else {
2426 var selectionStart = isEmpty ? 2 : 1;
2427 var selectionEnd = 2;
2428 }
2429 try {
2430 text.setSelectionRange(selectionStart, selectionEnd);
2431 } catch(e){}
2432
2433 inComposition = false;
2434 }
2435
2436 function resetValue() {
2437 if (inComposition)
2438 return;
2439 text.value = PLACEHOLDER;
2440 if (useragent.isWebKit)
2441 syncValue.schedule();
2442 }
2443
2444 useragent.isWebKit || host.addEventListener('changeSelection', function() {
2445 if (host.selection.isEmpty() != isSelectionEmpty) {
2446 isSelectionEmpty = !isSelectionEmpty;
2447 syncSelection.schedule();
2448 }
2449 });
2450
2451 resetValue();
2452 if (isFocused)
2453 host.onFocus();
2454
2455
2456 var isAllSelected = function(text) {
2457 return text.selectionStart === 0 && text.selectionEnd === text.value.length;
2458 };
2459
2460 var onSelect = function(e) {
2461 if (copied) {
2462 copied = false;
2463 } else if (isAllSelected(text)) {
2464 host.selectAll();
2465 resetSelection();
2466 } else if (inputHandler) {
2467 resetSelection(host.selection.isEmpty());
2468 }
2469 };
2470
2471 var inputHandler = null;
2472 this.setInputHandler = function(cb) {inputHandler = cb;};
2473 this.getInputHandler = function() {return inputHandler;};
2474 var afterContextMenu = false;
2475
2476 var sendText = function(data) {
2477 if (inputHandler) {
2478 data = inputHandler(data);
2479 inputHandler = null;
2480 }
2481 if (pasted) {
2482 resetSelection();
2483 if (data)
2484 host.onPaste(data);
2485 pasted = false;
2486 } else if (data == PLACEHOLDER.charAt(0)) {
2487 if (afterContextMenu)
2488 host.execCommand("del", {source: "ace"});
2489 else // some versions of android do not fire keydown when pressing backspace
2490 host.execCommand("backspace", {source: "ace"});
2491 } else {
2492 if (data.substring(0, 2) == PLACEHOLDER)
2493 data = data.substr(2);
2494 else if (data.charAt(0) == PLACEHOLDER.charAt(0))
2495 data = data.substr(1);
2496 else if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
2497 data = data.slice(0, -1);
2498 if (data.charAt(data.length - 1) == PLACEHOLDER.charAt(0))
2499 data = data.slice(0, -1);
2500
2501 if (data)
2502 host.onTextInput(data);
2503 }
2504 if (afterContextMenu)
2505 afterContextMenu = false;
2506 };
2507 var onInput = function(e) {
2508 if (inComposition)
2509 return;
2510 var data = text.value;
2511 sendText(data);
2512 resetValue();
2513 };
2514
2515 var handleClipboardData = function(e, data, forceIEMime) {
2516 var clipboardData = e.clipboardData || window.clipboardData;
2517 if (!clipboardData || BROKEN_SETDATA)
2518 return;
2519 var mime = USE_IE_MIME_TYPE || forceIEMime ? "Text" : "text/plain";
2520 try {
2521 if (data) {
2522 return clipboardData.setData(mime, data) !== false;
2523 } else {
2524 return clipboardData.getData(mime);
2525 }
2526 } catch(e) {
2527 if (!forceIEMime)
2528 return handleClipboardData(e, data, true);
2529 }
2530 };
2531
2532 var doCopy = function(e, isCut) {
2533 var data = host.getCopyText();
2534 if (!data)
2535 return event.preventDefault(e);
2536
2537 if (handleClipboardData(e, data)) {
2538 isCut ? host.onCut() : host.onCopy();
2539 event.preventDefault(e);
2540 } else {
2541 copied = true;
2542 text.value = data;
2543 text.select();
2544 setTimeout(function(){
2545 copied = false;
2546 resetValue();
2547 resetSelection();
2548 isCut ? host.onCut() : host.onCopy();
2549 });
2550 }
2551 };
2552
2553 var onCut = function(e) {
2554 doCopy(e, true);
2555 };
2556
2557 var onCopy = function(e) {
2558 doCopy(e, false);
2559 };
2560
2561 var onPaste = function(e) {
2562 var data = handleClipboardData(e);
2563 if (typeof data == "string") {
2564 if (data)
2565 host.onPaste(data, e);
2566 if (useragent.isIE)
2567 setTimeout(resetSelection);
2568 event.preventDefault(e);
2569 }
2570 else {
2571 text.value = "";
2572 pasted = true;
2573 }
2574 };
2575
2576 event.addCommandKeyListener(text, host.onCommandKey.bind(host));
2577
2578 event.addListener(text, "select", onSelect);
2579
2580 event.addListener(text, "input", onInput);
2581
2582 event.addListener(text, "cut", onCut);
2583 event.addListener(text, "copy", onCopy);
2584 event.addListener(text, "paste", onPaste);
2585 if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)) {
2586 event.addListener(parentNode, "keydown", function(e) {
2587 if ((useragent.isMac && !e.metaKey) || !e.ctrlKey)
2588 return;
2589
2590 switch (e.keyCode) {
2591 case 67:
2592 onCopy(e);
2593 break;
2594 case 86:
2595 onPaste(e);
2596 break;
2597 case 88:
2598 onCut(e);
2599 break;
2600 }
2601 });
2602 }
2603 var onCompositionStart = function(e) {
2604 if (inComposition || !host.onCompositionStart || host.$readOnly)
2605 return;
2606 inComposition = {};
2607 inComposition.canUndo = host.session.$undoManager;
2608 host.onCompositionStart();
2609 setTimeout(onCompositionUpdate, 0);
2610 host.on("mousedown", onCompositionEnd);
2611 if (inComposition.canUndo && !host.selection.isEmpty()) {
2612 host.insert("");
2613 host.session.markUndoGroup();
2614 host.selection.clearSelection();
2615 }
2616 host.session.markUndoGroup();
2617 };
2618
2619 var onCompositionUpdate = function() {
2620 if (!inComposition || !host.onCompositionUpdate || host.$readOnly)
2621 return;
2622 var val = text.value.replace(/\u2028/g, "");
2623 if (inComposition.lastValue === val) return;
2624
2625 host.onCompositionUpdate(val);
2626 if (inComposition.lastValue)
2627 host.undo();
2628 if (inComposition.canUndo)
2629 inComposition.lastValue = val;
2630 if (inComposition.lastValue) {
2631 var r = host.selection.getRange();
2632 host.insert(inComposition.lastValue);
2633 host.session.markUndoGroup();
2634 inComposition.range = host.selection.getRange();
2635 host.selection.setRange(r);
2636 host.selection.clearSelection();
2637 }
2638 };
2639
2640 var onCompositionEnd = function(e) {
2641 if (!host.onCompositionEnd || host.$readOnly) return;
2642 var c = inComposition;
2643 inComposition = false;
2644 var timer = setTimeout(function() {
2645 timer = null;
2646 var str = text.value.replace(/\u2028/g, "");
2647 if (inComposition)
2648 return;
2649 else if (str == c.lastValue)
2650 resetValue();
2651 else if (!c.lastValue && str) {
2652 resetValue();
2653 sendText(str);
2654 }
2655 });
2656 inputHandler = function compositionInputHandler(str) {
2657 if (timer)
2658 clearTimeout(timer);
2659 str = str.replace(/\u2028/g, "");
2660 if (str == c.lastValue)
2661 return "";
2662 if (c.lastValue && timer)
2663 host.undo();
2664 return str;
2665 };
2666 host.onCompositionEnd();
2667 host.removeListener("mousedown", onCompositionEnd);
2668 if (e.type == "compositionend" && c.range) {
2669 host.selection.setRange(c.range);
2670 }
2671 var needsOnInput =
2672 (!!useragent.isChrome && useragent.isChrome >= 53) ||
2673 (!!useragent.isWebKit && useragent.isWebKit >= 603);
2674
2675 if (needsOnInput) {
2676 onInput();
2677 }
2678 };
2679
2680
2681
2682 var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
2683
2684 event.addListener(text, "compositionstart", onCompositionStart);
2685 if (useragent.isGecko) {
2686 event.addListener(text, "text", function(){syncComposition.schedule();});
2687 } else {
2688 event.addListener(text, "keyup", function(){syncComposition.schedule();});
2689 event.addListener(text, "keydown", function(){syncComposition.schedule();});
2690 }
2691 event.addListener(text, "compositionend", onCompositionEnd);
2692
2693 this.getElement = function() {
2694 return text;
2695 };
2696
2697 this.setReadOnly = function(readOnly) {
2698 text.readOnly = readOnly;
2699 };
2700
2701 this.onContextMenu = function(e) {
2702 afterContextMenu = true;
2703 resetSelection(host.selection.isEmpty());
2704 host._emit("nativecontextmenu", {target: host, domEvent: e});
2705 this.moveToMouse(e, true);
2706 };
2707
2708 this.moveToMouse = function(e, bringToFront) {
2709 if (!tempStyle)
2710 tempStyle = text.style.cssText;
2711 text.style.cssText = (bringToFront ? "z-index:100000;" : "")
2712 + "height:" + text.style.height + ";"
2713 + (useragent.isIE ? "opacity:0.1;" : "");
2714
2715 var rect = host.container.getBoundingClientRect();
2716 var style = dom.computedStyle(host.container);
2717 var top = rect.top + (parseInt(style.borderTopWidth) || 0);
2718 var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
2719 var maxTop = rect.bottom - top - text.clientHeight -2;
2720 var move = function(e) {
2721 text.style.left = e.clientX - left - 2 + "px";
2722 text.style.top = Math.min(e.clientY - top - 2, maxTop) + "px";
2723 };
2724 move(e);
2725
2726 if (e.type != "mousedown")
2727 return;
2728
2729 if (host.renderer.$keepTextAreaAtCursor)
2730 host.renderer.$keepTextAreaAtCursor = null;
2731
2732 clearTimeout(closeTimeout);
2733 if (useragent.isWin)
2734 event.capture(host.container, move, onContextMenuClose);
2735 };
2736
2737 this.onContextMenuClose = onContextMenuClose;
2738 var closeTimeout;
2739 function onContextMenuClose() {
2740 clearTimeout(closeTimeout);
2741 closeTimeout = setTimeout(function () {
2742 if (tempStyle) {
2743 text.style.cssText = tempStyle;
2744 tempStyle = '';
2745 }
2746 if (host.renderer.$keepTextAreaAtCursor == null) {
2747 host.renderer.$keepTextAreaAtCursor = true;
2748 host.renderer.$moveTextAreaToCursor();
2749 }
2750 }, 0);
2751 }
2752
2753 var onContextMenu = function(e) {
2754 host.textInput.onContextMenu(e);
2755 onContextMenuClose();
2756 };
2757 event.addListener(text, "mouseup", onContextMenu);
2758 event.addListener(text, "mousedown", function(e) {
2759 e.preventDefault();
2760 onContextMenuClose();
2761 });
2762 event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
2763 event.addListener(text, "contextmenu", onContextMenu);
2764 };
2765
2766 exports.TextInput = TextInput;
2767 });
2768
2769 ace.define("ace/mouse/default_handlers",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(acequire, exports, module) {
2770
2771 acequire("../lib/dom");
2772 acequire("../lib/event");
2773 var useragent = acequire("../lib/useragent");
2774
2775 var DRAG_OFFSET = 0; // pixels
2776 var SCROLL_COOLDOWN_T = 250; // milliseconds
2777
2778 function DefaultHandlers(mouseHandler) {
2779 mouseHandler.$clickSelection = null;
2780
2781 var editor = mouseHandler.editor;
2782 editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler));
2783 editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(mouseHandler));
2784 editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(mouseHandler));
2785 editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler));
2786 editor.setDefaultHandler("mousewheel", this.onMouseWheel.bind(mouseHandler));
2787 editor.setDefaultHandler("touchmove", this.onTouchMove.bind(mouseHandler));
2788
2789 var exports = ["select", "startSelect", "selectEnd", "selectAllEnd", "selectByWordsEnd",
2790 "selectByLinesEnd", "dragWait", "dragWaitEnd", "focusWait"];
2791
2792 exports.forEach(function(x) {
2793 mouseHandler[x] = this[x];
2794 }, this);
2795
2796 mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
2797 mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
2798 }
2799
2800 (function() {
2801
2802 this.onMouseDown = function(ev) {
2803 var inSelection = ev.inSelection();
2804 var pos = ev.getDocumentPosition();
2805 this.mousedownEvent = ev;
2806 var editor = this.editor;
2807
2808 var button = ev.getButton();
2809 if (button !== 0) {
2810 var selectionRange = editor.getSelectionRange();
2811 var selectionEmpty = selectionRange.isEmpty();
2812 editor.$blockScrolling++;
2813 if (selectionEmpty || button == 1)
2814 editor.selection.moveToPosition(pos);
2815 editor.$blockScrolling--;
2816 if (button == 2) {
2817 editor.textInput.onContextMenu(ev.domEvent);
2818 if (!useragent.isMozilla)
2819 ev.preventDefault();
2820 }
2821 return;
2822 }
2823
2824 this.mousedownEvent.time = Date.now();
2825 if (inSelection && !editor.isFocused()) {
2826 editor.focus();
2827 if (this.$focusTimout && !this.$clickSelection && !editor.inMultiSelectMode) {
2828 this.setState("focusWait");
2829 this.captureMouse(ev);
2830 return;
2831 }
2832 }
2833
2834 this.captureMouse(ev);
2835 this.startSelect(pos, ev.domEvent._clicks > 1);
2836 return ev.preventDefault();
2837 };
2838
2839 this.startSelect = function(pos, waitForClickSelection) {
2840 pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
2841 var editor = this.editor;
2842 editor.$blockScrolling++;
2843 if (this.mousedownEvent.getShiftKey())
2844 editor.selection.selectToPosition(pos);
2845 else if (!waitForClickSelection)
2846 editor.selection.moveToPosition(pos);
2847 if (!waitForClickSelection)
2848 this.select();
2849 if (editor.renderer.scroller.setCapture) {
2850 editor.renderer.scroller.setCapture();
2851 }
2852 editor.setStyle("ace_selecting");
2853 this.setState("select");
2854 editor.$blockScrolling--;
2855 };
2856
2857 this.select = function() {
2858 var anchor, editor = this.editor;
2859 var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
2860 editor.$blockScrolling++;
2861 if (this.$clickSelection) {
2862 var cmp = this.$clickSelection.comparePoint(cursor);
2863
2864 if (cmp == -1) {
2865 anchor = this.$clickSelection.end;
2866 } else if (cmp == 1) {
2867 anchor = this.$clickSelection.start;
2868 } else {
2869 var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
2870 cursor = orientedRange.cursor;
2871 anchor = orientedRange.anchor;
2872 }
2873 editor.selection.setSelectionAnchor(anchor.row, anchor.column);
2874 }
2875 editor.selection.selectToPosition(cursor);
2876 editor.$blockScrolling--;
2877 editor.renderer.scrollCursorIntoView();
2878 };
2879
2880 this.extendSelectionBy = function(unitName) {
2881 var anchor, editor = this.editor;
2882 var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
2883 var range = editor.selection[unitName](cursor.row, cursor.column);
2884 editor.$blockScrolling++;
2885 if (this.$clickSelection) {
2886 var cmpStart = this.$clickSelection.comparePoint(range.start);
2887 var cmpEnd = this.$clickSelection.comparePoint(range.end);
2888
2889 if (cmpStart == -1 && cmpEnd <= 0) {
2890 anchor = this.$clickSelection.end;
2891 if (range.end.row != cursor.row || range.end.column != cursor.column)
2892 cursor = range.start;
2893 } else if (cmpEnd == 1 && cmpStart >= 0) {
2894 anchor = this.$clickSelection.start;
2895 if (range.start.row != cursor.row || range.start.column != cursor.column)
2896 cursor = range.end;
2897 } else if (cmpStart == -1 && cmpEnd == 1) {
2898 cursor = range.end;
2899 anchor = range.start;
2900 } else {
2901 var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
2902 cursor = orientedRange.cursor;
2903 anchor = orientedRange.anchor;
2904 }
2905 editor.selection.setSelectionAnchor(anchor.row, anchor.column);
2906 }
2907 editor.selection.selectToPosition(cursor);
2908 editor.$blockScrolling--;
2909 editor.renderer.scrollCursorIntoView();
2910 };
2911
2912 this.selectEnd =
2913 this.selectAllEnd =
2914 this.selectByWordsEnd =
2915 this.selectByLinesEnd = function() {
2916 this.$clickSelection = null;
2917 this.editor.unsetStyle("ace_selecting");
2918 if (this.editor.renderer.scroller.releaseCapture) {
2919 this.editor.renderer.scroller.releaseCapture();
2920 }
2921 };
2922
2923 this.focusWait = function() {
2924 var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
2925 var time = Date.now();
2926
2927 if (distance > DRAG_OFFSET || time - this.mousedownEvent.time > this.$focusTimout)
2928 this.startSelect(this.mousedownEvent.getDocumentPosition());
2929 };
2930
2931 this.onDoubleClick = function(ev) {
2932 var pos = ev.getDocumentPosition();
2933 var editor = this.editor;
2934 var session = editor.session;
2935
2936 var range = session.getBracketRange(pos);
2937 if (range) {
2938 if (range.isEmpty()) {
2939 range.start.column--;
2940 range.end.column++;
2941 }
2942 this.setState("select");
2943 } else {
2944 range = editor.selection.getWordRange(pos.row, pos.column);
2945 this.setState("selectByWords");
2946 }
2947 this.$clickSelection = range;
2948 this.select();
2949 };
2950
2951 this.onTripleClick = function(ev) {
2952 var pos = ev.getDocumentPosition();
2953 var editor = this.editor;
2954
2955 this.setState("selectByLines");
2956 var range = editor.getSelectionRange();
2957 if (range.isMultiLine() && range.contains(pos.row, pos.column)) {
2958 this.$clickSelection = editor.selection.getLineRange(range.start.row);
2959 this.$clickSelection.end = editor.selection.getLineRange(range.end.row).end;
2960 } else {
2961 this.$clickSelection = editor.selection.getLineRange(pos.row);
2962 }
2963 this.select();
2964 };
2965
2966 this.onQuadClick = function(ev) {
2967 var editor = this.editor;
2968
2969 editor.selectAll();
2970 this.$clickSelection = editor.getSelectionRange();
2971 this.setState("selectAll");
2972 };
2973
2974 this.onMouseWheel = function(ev) {
2975 if (ev.getAccelKey())
2976 return;
2977 if (ev.getShiftKey() && ev.wheelY && !ev.wheelX) {
2978 ev.wheelX = ev.wheelY;
2979 ev.wheelY = 0;
2980 }
2981
2982 var editor = this.editor;
2983
2984 if (!this.$lastScroll)
2985 this.$lastScroll = { t: 0, vx: 0, vy: 0, allowed: 0 };
2986
2987 var prevScroll = this.$lastScroll;
2988 var t = ev.domEvent.timeStamp;
2989 var dt = t - prevScroll.t;
2990 var vx = ev.wheelX / dt;
2991 var vy = ev.wheelY / dt;
2992 if (dt < SCROLL_COOLDOWN_T) {
2993 vx = (vx + prevScroll.vx) / 2;
2994 vy = (vy + prevScroll.vy) / 2;
2995 }
2996
2997 var direction = Math.abs(vx / vy);
2998
2999 var canScroll = false;
3000 if (direction >= 1 && editor.renderer.isScrollableBy(ev.wheelX * ev.speed, 0))
3001 canScroll = true;
3002 if (direction <= 1 && editor.renderer.isScrollableBy(0, ev.wheelY * ev.speed))
3003 canScroll = true;
3004
3005 if (canScroll) {
3006 prevScroll.allowed = t;
3007 } else if (t - prevScroll.allowed < SCROLL_COOLDOWN_T) {
3008 var isSlower = Math.abs(vx) <= 1.1 * Math.abs(prevScroll.vx)
3009 && Math.abs(vy) <= 1.1 * Math.abs(prevScroll.vy);
3010 if (isSlower) {
3011 canScroll = true;
3012 prevScroll.allowed = t;
3013 }
3014 else {
3015 prevScroll.allowed = 0;
3016 }
3017 }
3018
3019 prevScroll.t = t;
3020 prevScroll.vx = vx;
3021 prevScroll.vy = vy;
3022
3023 if (canScroll) {
3024 editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
3025 return ev.stop();
3026 }
3027 };
3028
3029 this.onTouchMove = function(ev) {
3030 this.editor._emit("mousewheel", ev);
3031 };
3032
3033 }).call(DefaultHandlers.prototype);
3034
3035 exports.DefaultHandlers = DefaultHandlers;
3036
3037 function calcDistance(ax, ay, bx, by) {
3038 return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
3039 }
3040
3041 function calcRangeOrientation(range, cursor) {
3042 if (range.start.row == range.end.row)
3043 var cmp = 2 * cursor.column - range.start.column - range.end.column;
3044 else if (range.start.row == range.end.row - 1 && !range.start.column && !range.end.column)
3045 var cmp = cursor.column - 4;
3046 else
3047 var cmp = 2 * cursor.row - range.start.row - range.end.row;
3048
3049 if (cmp < 0)
3050 return {cursor: range.start, anchor: range.end};
3051 else
3052 return {cursor: range.end, anchor: range.start};
3053 }
3054
3055 });
3056
3057 ace.define("ace/tooltip",["require","exports","module","ace/lib/oop","ace/lib/dom"], function(acequire, exports, module) {
3058
3059 acequire("./lib/oop");
3060 var dom = acequire("./lib/dom");
3061 function Tooltip (parentNode) {
3062 this.isOpen = false;
3063 this.$element = null;
3064 this.$parentNode = parentNode;
3065 }
3066
3067 (function() {
3068 this.$init = function() {
3069 this.$element = dom.createElement("div");
3070 this.$element.className = "ace_tooltip";
3071 this.$element.style.display = "none";
3072 this.$parentNode.appendChild(this.$element);
3073 return this.$element;
3074 };
3075 this.getElement = function() {
3076 return this.$element || this.$init();
3077 };
3078 this.setText = function(text) {
3079 dom.setInnerText(this.getElement(), text);
3080 };
3081 this.setHtml = function(html) {
3082 this.getElement().innerHTML = html;
3083 };
3084 this.setPosition = function(x, y) {
3085 this.getElement().style.left = x + "px";
3086 this.getElement().style.top = y + "px";
3087 };
3088 this.setClassName = function(className) {
3089 dom.addCssClass(this.getElement(), className);
3090 };
3091 this.show = function(text, x, y) {
3092 if (text != null)
3093 this.setText(text);
3094 if (x != null && y != null)
3095 this.setPosition(x, y);
3096 if (!this.isOpen) {
3097 this.getElement().style.display = "block";
3098 this.isOpen = true;
3099 }
3100 };
3101
3102 this.hide = function() {
3103 if (this.isOpen) {
3104 this.getElement().style.display = "none";
3105 this.isOpen = false;
3106 }
3107 };
3108 this.getHeight = function() {
3109 return this.getElement().offsetHeight;
3110 };
3111 this.getWidth = function() {
3112 return this.getElement().offsetWidth;
3113 };
3114
3115 this.destroy = function() {
3116 this.isOpen = false;
3117 if (this.$element && this.$element.parentNode) {
3118 this.$element.parentNode.removeChild(this.$element);
3119 }
3120 };
3121
3122 }).call(Tooltip.prototype);
3123
3124 exports.Tooltip = Tooltip;
3125 });
3126
3127 ace.define("ace/mouse/default_gutter_handler",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event","ace/tooltip"], function(acequire, exports, module) {
3128 var dom = acequire("../lib/dom");
3129 var oop = acequire("../lib/oop");
3130 var event = acequire("../lib/event");
3131 var Tooltip = acequire("../tooltip").Tooltip;
3132
3133 function GutterHandler(mouseHandler) {
3134 var editor = mouseHandler.editor;
3135 var gutter = editor.renderer.$gutterLayer;
3136 var tooltip = new GutterTooltip(editor.container);
3137
3138 mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
3139 if (!editor.isFocused() || e.getButton() != 0)
3140 return;
3141 var gutterRegion = gutter.getRegion(e);
3142
3143 if (gutterRegion == "foldWidgets")
3144 return;
3145
3146 var row = e.getDocumentPosition().row;
3147 var selection = editor.session.selection;
3148
3149 if (e.getShiftKey())
3150 selection.selectTo(row, 0);
3151 else {
3152 if (e.domEvent.detail == 2) {
3153 editor.selectAll();
3154 return e.preventDefault();
3155 }
3156 mouseHandler.$clickSelection = editor.selection.getLineRange(row);
3157 }
3158 mouseHandler.setState("selectByLines");
3159 mouseHandler.captureMouse(e);
3160 return e.preventDefault();
3161 });
3162
3163
3164 var tooltipTimeout, mouseEvent, tooltipAnnotation;
3165
3166 function showTooltip() {
3167 var row = mouseEvent.getDocumentPosition().row;
3168 var annotation = gutter.$annotations[row];
3169 if (!annotation)
3170 return hideTooltip();
3171
3172 var maxRow = editor.session.getLength();
3173 if (row == maxRow) {
3174 var screenRow = editor.renderer.pixelToScreenCoordinates(0, mouseEvent.y).row;
3175 var pos = mouseEvent.$pos;
3176 if (screenRow > editor.session.documentToScreenRow(pos.row, pos.column))
3177 return hideTooltip();
3178 }
3179
3180 if (tooltipAnnotation == annotation)
3181 return;
3182 tooltipAnnotation = annotation.text.join("<br/>");
3183
3184 tooltip.setHtml(tooltipAnnotation);
3185 tooltip.show();
3186 editor._signal("showGutterTooltip", tooltip);
3187 editor.on("mousewheel", hideTooltip);
3188
3189 if (mouseHandler.$tooltipFollowsMouse) {
3190 moveTooltip(mouseEvent);
3191 } else {
3192 var gutterElement = mouseEvent.domEvent.target;
3193 var rect = gutterElement.getBoundingClientRect();
3194 var style = tooltip.getElement().style;
3195 style.left = rect.right + "px";
3196 style.top = rect.bottom + "px";
3197 }
3198 }
3199
3200 function hideTooltip() {
3201 if (tooltipTimeout)
3202 tooltipTimeout = clearTimeout(tooltipTimeout);
3203 if (tooltipAnnotation) {
3204 tooltip.hide();
3205 tooltipAnnotation = null;
3206 editor._signal("hideGutterTooltip", tooltip);
3207 editor.removeEventListener("mousewheel", hideTooltip);
3208 }
3209 }
3210
3211 function moveTooltip(e) {
3212 tooltip.setPosition(e.x, e.y);
3213 }
3214
3215 mouseHandler.editor.setDefaultHandler("guttermousemove", function(e) {
3216 var target = e.domEvent.target || e.domEvent.srcElement;
3217 if (dom.hasCssClass(target, "ace_fold-widget"))
3218 return hideTooltip();
3219
3220 if (tooltipAnnotation && mouseHandler.$tooltipFollowsMouse)
3221 moveTooltip(e);
3222
3223 mouseEvent = e;
3224 if (tooltipTimeout)
3225 return;
3226 tooltipTimeout = setTimeout(function() {
3227 tooltipTimeout = null;
3228 if (mouseEvent && !mouseHandler.isMousePressed)
3229 showTooltip();
3230 else
3231 hideTooltip();
3232 }, 50);
3233 });
3234
3235 event.addListener(editor.renderer.$gutter, "mouseout", function(e) {
3236 mouseEvent = null;
3237 if (!tooltipAnnotation || tooltipTimeout)
3238 return;
3239
3240 tooltipTimeout = setTimeout(function() {
3241 tooltipTimeout = null;
3242 hideTooltip();
3243 }, 50);
3244 });
3245
3246 editor.on("changeSession", hideTooltip);
3247 }
3248
3249 function GutterTooltip(parentNode) {
3250 Tooltip.call(this, parentNode);
3251 }
3252
3253 oop.inherits(GutterTooltip, Tooltip);
3254
3255 (function(){
3256 this.setPosition = function(x, y) {
3257 var windowWidth = window.innerWidth || document.documentElement.clientWidth;
3258 var windowHeight = window.innerHeight || document.documentElement.clientHeight;
3259 var width = this.getWidth();
3260 var height = this.getHeight();
3261 x += 15;
3262 y += 15;
3263 if (x + width > windowWidth) {
3264 x -= (x + width) - windowWidth;
3265 }
3266 if (y + height > windowHeight) {
3267 y -= 20 + height;
3268 }
3269 Tooltip.prototype.setPosition.call(this, x, y);
3270 };
3271
3272 }).call(GutterTooltip.prototype);
3273
3274
3275
3276 exports.GutterHandler = GutterHandler;
3277
3278 });
3279
3280 ace.define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(acequire, exports, module) {
3281
3282 var event = acequire("../lib/event");
3283 var useragent = acequire("../lib/useragent");
3284 var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
3285 this.domEvent = domEvent;
3286 this.editor = editor;
3287
3288 this.x = this.clientX = domEvent.clientX;
3289 this.y = this.clientY = domEvent.clientY;
3290
3291 this.$pos = null;
3292 this.$inSelection = null;
3293
3294 this.propagationStopped = false;
3295 this.defaultPrevented = false;
3296 };
3297
3298 (function() {
3299
3300 this.stopPropagation = function() {
3301 event.stopPropagation(this.domEvent);
3302 this.propagationStopped = true;
3303 };
3304
3305 this.preventDefault = function() {
3306 event.preventDefault(this.domEvent);
3307 this.defaultPrevented = true;
3308 };
3309
3310 this.stop = function() {
3311 this.stopPropagation();
3312 this.preventDefault();
3313 };
3314 this.getDocumentPosition = function() {
3315 if (this.$pos)
3316 return this.$pos;
3317
3318 this.$pos = this.editor.renderer.screenToTextCoordinates(this.clientX, this.clientY);
3319 return this.$pos;
3320 };
3321 this.inSelection = function() {
3322 if (this.$inSelection !== null)
3323 return this.$inSelection;
3324
3325 var editor = this.editor;
3326
3327
3328 var selectionRange = editor.getSelectionRange();
3329 if (selectionRange.isEmpty())
3330 this.$inSelection = false;
3331 else {
3332 var pos = this.getDocumentPosition();
3333 this.$inSelection = selectionRange.contains(pos.row, pos.column);
3334 }
3335
3336 return this.$inSelection;
3337 };
3338 this.getButton = function() {
3339 return event.getButton(this.domEvent);
3340 };
3341 this.getShiftKey = function() {
3342 return this.domEvent.shiftKey;
3343 };
3344
3345 this.getAccelKey = useragent.isMac
3346 ? function() { return this.domEvent.metaKey; }
3347 : function() { return this.domEvent.ctrlKey; };
3348
3349 }).call(MouseEvent.prototype);
3350
3351 });
3352
3353 ace.define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(acequire, exports, module) {
3354
3355 var dom = acequire("../lib/dom");
3356 var event = acequire("../lib/event");
3357 var useragent = acequire("../lib/useragent");
3358
3359 var AUTOSCROLL_DELAY = 200;
3360 var SCROLL_CURSOR_DELAY = 200;
3361 var SCROLL_CURSOR_HYSTERESIS = 5;
3362
3363 function DragdropHandler(mouseHandler) {
3364
3365 var editor = mouseHandler.editor;
3366
3367 var blankImage = dom.createElement("img");
3368 blankImage.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
3369 if (useragent.isOpera)
3370 blankImage.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;";
3371
3372 var exports = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"];
3373
3374 exports.forEach(function(x) {
3375 mouseHandler[x] = this[x];
3376 }, this);
3377 editor.addEventListener("mousedown", this.onMouseDown.bind(mouseHandler));
3378
3379
3380 var mouseTarget = editor.container;
3381 var dragSelectionMarker, x, y;
3382 var timerId, range;
3383 var dragCursor, counter = 0;
3384 var dragOperation;
3385 var isInternal;
3386 var autoScrollStartTime;
3387 var cursorMovedTime;
3388 var cursorPointOnCaretMoved;
3389
3390 this.onDragStart = function(e) {
3391 if (this.cancelDrag || !mouseTarget.draggable) {
3392 var self = this;
3393 setTimeout(function(){
3394 self.startSelect();
3395 self.captureMouse(e);
3396 }, 0);
3397 return e.preventDefault();
3398 }
3399 range = editor.getSelectionRange();
3400
3401 var dataTransfer = e.dataTransfer;
3402 dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove";
3403 if (useragent.isOpera) {
3404 editor.container.appendChild(blankImage);
3405 blankImage.scrollTop = 0;
3406 }
3407 dataTransfer.setDragImage && dataTransfer.setDragImage(blankImage, 0, 0);
3408 if (useragent.isOpera) {
3409 editor.container.removeChild(blankImage);
3410 }
3411 dataTransfer.clearData();
3412 dataTransfer.setData("Text", editor.session.getTextRange());
3413
3414 isInternal = true;
3415 this.setState("drag");
3416 };
3417
3418 this.onDragEnd = function(e) {
3419 mouseTarget.draggable = false;
3420 isInternal = false;
3421 this.setState(null);
3422 if (!editor.getReadOnly()) {
3423 var dropEffect = e.dataTransfer.dropEffect;
3424 if (!dragOperation && dropEffect == "move")
3425 editor.session.remove(editor.getSelectionRange());
3426 editor.renderer.$cursorLayer.setBlinking(true);
3427 }
3428 this.editor.unsetStyle("ace_dragging");
3429 this.editor.renderer.setCursorStyle("");
3430 };
3431
3432 this.onDragEnter = function(e) {
3433 if (editor.getReadOnly() || !canAccept(e.dataTransfer))
3434 return;
3435 x = e.clientX;
3436 y = e.clientY;
3437 if (!dragSelectionMarker)
3438 addDragMarker();
3439 counter++;
3440 e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
3441 return event.preventDefault(e);
3442 };
3443
3444 this.onDragOver = function(e) {
3445 if (editor.getReadOnly() || !canAccept(e.dataTransfer))
3446 return;
3447 x = e.clientX;
3448 y = e.clientY;
3449 if (!dragSelectionMarker) {
3450 addDragMarker();
3451 counter++;
3452 }
3453 if (onMouseMoveTimer !== null)
3454 onMouseMoveTimer = null;
3455
3456 e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
3457 return event.preventDefault(e);
3458 };
3459
3460 this.onDragLeave = function(e) {
3461 counter--;
3462 if (counter <= 0 && dragSelectionMarker) {
3463 clearDragMarker();
3464 dragOperation = null;
3465 return event.preventDefault(e);
3466 }
3467 };
3468
3469 this.onDrop = function(e) {
3470 if (!dragCursor)
3471 return;
3472 var dataTransfer = e.dataTransfer;
3473 if (isInternal) {
3474 switch (dragOperation) {
3475 case "move":
3476 if (range.contains(dragCursor.row, dragCursor.column)) {
3477 range = {
3478 start: dragCursor,
3479 end: dragCursor
3480 };
3481 } else {
3482 range = editor.moveText(range, dragCursor);
3483 }
3484 break;
3485 case "copy":
3486 range = editor.moveText(range, dragCursor, true);
3487 break;
3488 }
3489 } else {
3490 var dropData = dataTransfer.getData('Text');
3491 range = {
3492 start: dragCursor,
3493 end: editor.session.insert(dragCursor, dropData)
3494 };
3495 editor.focus();
3496 dragOperation = null;
3497 }
3498 clearDragMarker();
3499 return event.preventDefault(e);
3500 };
3501
3502 event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler));
3503 event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler));
3504 event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler));
3505 event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler));
3506 event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler));
3507 event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler));
3508
3509 function scrollCursorIntoView(cursor, prevCursor) {
3510 var now = Date.now();
3511 var vMovement = !prevCursor || cursor.row != prevCursor.row;
3512 var hMovement = !prevCursor || cursor.column != prevCursor.column;
3513 if (!cursorMovedTime || vMovement || hMovement) {
3514 editor.$blockScrolling += 1;
3515 editor.moveCursorToPosition(cursor);
3516 editor.$blockScrolling -= 1;
3517 cursorMovedTime = now;
3518 cursorPointOnCaretMoved = {x: x, y: y};
3519 } else {
3520 var distance = calcDistance(cursorPointOnCaretMoved.x, cursorPointOnCaretMoved.y, x, y);
3521 if (distance > SCROLL_CURSOR_HYSTERESIS) {
3522 cursorMovedTime = null;
3523 } else if (now - cursorMovedTime >= SCROLL_CURSOR_DELAY) {
3524 editor.renderer.scrollCursorIntoView();
3525 cursorMovedTime = null;
3526 }
3527 }
3528 }
3529
3530 function autoScroll(cursor, prevCursor) {
3531 var now = Date.now();
3532 var lineHeight = editor.renderer.layerConfig.lineHeight;
3533 var characterWidth = editor.renderer.layerConfig.characterWidth;
3534 var editorRect = editor.renderer.scroller.getBoundingClientRect();
3535 var offsets = {
3536 x: {
3537 left: x - editorRect.left,
3538 right: editorRect.right - x
3539 },
3540 y: {
3541 top: y - editorRect.top,
3542 bottom: editorRect.bottom - y
3543 }
3544 };
3545 var nearestXOffset = Math.min(offsets.x.left, offsets.x.right);
3546 var nearestYOffset = Math.min(offsets.y.top, offsets.y.bottom);
3547 var scrollCursor = {row: cursor.row, column: cursor.column};
3548 if (nearestXOffset / characterWidth <= 2) {
3549 scrollCursor.column += (offsets.x.left < offsets.x.right ? -3 : +2);
3550 }
3551 if (nearestYOffset / lineHeight <= 1) {
3552 scrollCursor.row += (offsets.y.top < offsets.y.bottom ? -1 : +1);
3553 }
3554 var vScroll = cursor.row != scrollCursor.row;
3555 var hScroll = cursor.column != scrollCursor.column;
3556 var vMovement = !prevCursor || cursor.row != prevCursor.row;
3557 if (vScroll || (hScroll && !vMovement)) {
3558 if (!autoScrollStartTime)
3559 autoScrollStartTime = now;
3560 else if (now - autoScrollStartTime >= AUTOSCROLL_DELAY)
3561 editor.renderer.scrollCursorIntoView(scrollCursor);
3562 } else {
3563 autoScrollStartTime = null;
3564 }
3565 }
3566
3567 function onDragInterval() {
3568 var prevCursor = dragCursor;
3569 dragCursor = editor.renderer.screenToTextCoordinates(x, y);
3570 scrollCursorIntoView(dragCursor, prevCursor);
3571 autoScroll(dragCursor, prevCursor);
3572 }
3573
3574 function addDragMarker() {
3575 range = editor.selection.toOrientedRange();
3576 dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle());
3577 editor.clearSelection();
3578 if (editor.isFocused())
3579 editor.renderer.$cursorLayer.setBlinking(false);
3580 clearInterval(timerId);
3581 onDragInterval();
3582 timerId = setInterval(onDragInterval, 20);
3583 counter = 0;
3584 event.addListener(document, "mousemove", onMouseMove);
3585 }
3586
3587 function clearDragMarker() {
3588 clearInterval(timerId);
3589 editor.session.removeMarker(dragSelectionMarker);
3590 dragSelectionMarker = null;
3591 editor.$blockScrolling += 1;
3592 editor.selection.fromOrientedRange(range);
3593 editor.$blockScrolling -= 1;
3594 if (editor.isFocused() && !isInternal)
3595 editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly());
3596 range = null;
3597 dragCursor = null;
3598 counter = 0;
3599 autoScrollStartTime = null;
3600 cursorMovedTime = null;
3601 event.removeListener(document, "mousemove", onMouseMove);
3602 }
3603 var onMouseMoveTimer = null;
3604 function onMouseMove() {
3605 if (onMouseMoveTimer == null) {
3606 onMouseMoveTimer = setTimeout(function() {
3607 if (onMouseMoveTimer != null && dragSelectionMarker)
3608 clearDragMarker();
3609 }, 20);
3610 }
3611 }
3612
3613 function canAccept(dataTransfer) {
3614 var types = dataTransfer.types;
3615 return !types || Array.prototype.some.call(types, function(type) {
3616 return type == 'text/plain' || type == 'Text';
3617 });
3618 }
3619
3620 function getDropEffect(e) {
3621 var copyAllowed = ['copy', 'copymove', 'all', 'uninitialized'];
3622 var moveAllowed = ['move', 'copymove', 'linkmove', 'all', 'uninitialized'];
3623
3624 var copyModifierState = useragent.isMac ? e.altKey : e.ctrlKey;
3625 var effectAllowed = "uninitialized";
3626 try {
3627 effectAllowed = e.dataTransfer.effectAllowed.toLowerCase();
3628 } catch (e) {}
3629 var dropEffect = "none";
3630
3631 if (copyModifierState && copyAllowed.indexOf(effectAllowed) >= 0)
3632 dropEffect = "copy";
3633 else if (moveAllowed.indexOf(effectAllowed) >= 0)
3634 dropEffect = "move";
3635 else if (copyAllowed.indexOf(effectAllowed) >= 0)
3636 dropEffect = "copy";
3637
3638 return dropEffect;
3639 }
3640 }
3641
3642 (function() {
3643
3644 this.dragWait = function() {
3645 var interval = Date.now() - this.mousedownEvent.time;
3646 if (interval > this.editor.getDragDelay())
3647 this.startDrag();
3648 };
3649
3650 this.dragWaitEnd = function() {
3651 var target = this.editor.container;
3652 target.draggable = false;
3653 this.startSelect(this.mousedownEvent.getDocumentPosition());
3654 this.selectEnd();
3655 };
3656
3657 this.dragReadyEnd = function(e) {
3658 this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly());
3659 this.editor.unsetStyle("ace_dragging");
3660 this.editor.renderer.setCursorStyle("");
3661 this.dragWaitEnd();
3662 };
3663
3664 this.startDrag = function(){
3665 this.cancelDrag = false;
3666 var editor = this.editor;
3667 var target = editor.container;
3668 target.draggable = true;
3669 editor.renderer.$cursorLayer.setBlinking(false);
3670 editor.setStyle("ace_dragging");
3671 var cursorStyle = useragent.isWin ? "default" : "move";
3672 editor.renderer.setCursorStyle(cursorStyle);
3673 this.setState("dragReady");
3674 };
3675
3676 this.onMouseDrag = function(e) {
3677 var target = this.editor.container;
3678 if (useragent.isIE && this.state == "dragReady") {
3679 var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
3680 if (distance > 3)
3681 target.dragDrop();
3682 }
3683 if (this.state === "dragWait") {
3684 var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
3685 if (distance > 0) {
3686 target.draggable = false;
3687 this.startSelect(this.mousedownEvent.getDocumentPosition());
3688 }
3689 }
3690 };
3691
3692 this.onMouseDown = function(e) {
3693 if (!this.$dragEnabled)
3694 return;
3695 this.mousedownEvent = e;
3696 var editor = this.editor;
3697
3698 var inSelection = e.inSelection();
3699 var button = e.getButton();
3700 var clickCount = e.domEvent.detail || 1;
3701 if (clickCount === 1 && button === 0 && inSelection) {
3702 if (e.editor.inMultiSelectMode && (e.getAccelKey() || e.getShiftKey()))
3703 return;
3704 this.mousedownEvent.time = Date.now();
3705 var eventTarget = e.domEvent.target || e.domEvent.srcElement;
3706 if ("unselectable" in eventTarget)
3707 eventTarget.unselectable = "on";
3708 if (editor.getDragDelay()) {
3709 if (useragent.isWebKit) {
3710 this.cancelDrag = true;
3711 var mouseTarget = editor.container;
3712 mouseTarget.draggable = true;
3713 }
3714 this.setState("dragWait");
3715 } else {
3716 this.startDrag();
3717 }
3718 this.captureMouse(e, this.onMouseDrag.bind(this));
3719 e.defaultPrevented = true;
3720 }
3721 };
3722
3723 }).call(DragdropHandler.prototype);
3724
3725
3726 function calcDistance(ax, ay, bx, by) {
3727 return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
3728 }
3729
3730 exports.DragdropHandler = DragdropHandler;
3731
3732 });
3733
3734 ace.define("ace/lib/net",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) {
3735 var dom = acequire("./dom");
3736
3737 exports.get = function (url, callback) {
3738 var xhr = new XMLHttpRequest();
3739 xhr.open('GET', url, true);
3740 xhr.onreadystatechange = function () {
3741 if (xhr.readyState === 4) {
3742 callback(xhr.responseText);
3743 }
3744 };
3745 xhr.send(null);
3746 };
3747
3748 exports.loadScript = function(path, callback) {
3749 var head = dom.getDocumentHead();
3750 var s = document.createElement('script');
3751
3752 s.src = path;
3753 head.appendChild(s);
3754
3755 s.onload = s.onreadystatechange = function(_, isAbort) {
3756 if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
3757 s = s.onload = s.onreadystatechange = null;
3758 if (!isAbort)
3759 callback();
3760 }
3761 };
3762 };
3763 exports.qualifyURL = function(url) {
3764 var a = document.createElement('a');
3765 a.href = url;
3766 return a.href;
3767 };
3768
3769 });
3770
3771 ace.define("ace/lib/event_emitter",["require","exports","module"], function(acequire, exports, module) {
3772
3773 var EventEmitter = {};
3774 var stopPropagation = function() { this.propagationStopped = true; };
3775 var preventDefault = function() { this.defaultPrevented = true; };
3776
3777 EventEmitter._emit =
3778 EventEmitter._dispatchEvent = function(eventName, e) {
3779 this._eventRegistry || (this._eventRegistry = {});
3780 this._defaultHandlers || (this._defaultHandlers = {});
3781
3782 var listeners = this._eventRegistry[eventName] || [];
3783 var defaultHandler = this._defaultHandlers[eventName];
3784 if (!listeners.length && !defaultHandler)
3785 return;
3786
3787 if (typeof e != "object" || !e)
3788 e = {};
3789
3790 if (!e.type)
3791 e.type = eventName;
3792 if (!e.stopPropagation)
3793 e.stopPropagation = stopPropagation;
3794 if (!e.preventDefault)
3795 e.preventDefault = preventDefault;
3796
3797 listeners = listeners.slice();
3798 for (var i=0; i<listeners.length; i++) {
3799 listeners[i](e, this);
3800 if (e.propagationStopped)
3801 break;
3802 }
3803
3804 if (defaultHandler && !e.defaultPrevented)
3805 return defaultHandler(e, this);
3806 };
3807
3808
3809 EventEmitter._signal = function(eventName, e) {
3810 var listeners = (this._eventRegistry || {})[eventName];
3811 if (!listeners)
3812 return;
3813 listeners = listeners.slice();
3814 for (var i=0; i<listeners.length; i++)
3815 listeners[i](e, this);
3816 };
3817
3818 EventEmitter.once = function(eventName, callback) {
3819 var _self = this;
3820 callback && this.addEventListener(eventName, function newCallback() {
3821 _self.removeEventListener(eventName, newCallback);
3822 callback.apply(null, arguments);
3823 });
3824 };
3825
3826
3827 EventEmitter.setDefaultHandler = function(eventName, callback) {
3828 var handlers = this._defaultHandlers;
3829 if (!handlers)
3830 handlers = this._defaultHandlers = {_disabled_: {}};
3831
3832 if (handlers[eventName]) {
3833 var old = handlers[eventName];
3834 var disabled = handlers._disabled_[eventName];
3835 if (!disabled)
3836 handlers._disabled_[eventName] = disabled = [];
3837 disabled.push(old);
3838 var i = disabled.indexOf(callback);
3839 if (i != -1)
3840 disabled.splice(i, 1);
3841 }
3842 handlers[eventName] = callback;
3843 };
3844 EventEmitter.removeDefaultHandler = function(eventName, callback) {
3845 var handlers = this._defaultHandlers;
3846 if (!handlers)
3847 return;
3848 var disabled = handlers._disabled_[eventName];
3849
3850 if (handlers[eventName] == callback) {
3851 handlers[eventName];
3852 if (disabled)
3853 this.setDefaultHandler(eventName, disabled.pop());
3854 } else if (disabled) {
3855 var i = disabled.indexOf(callback);
3856 if (i != -1)
3857 disabled.splice(i, 1);
3858 }
3859 };
3860
3861 EventEmitter.on =
3862 EventEmitter.addEventListener = function(eventName, callback, capturing) {
3863 this._eventRegistry = this._eventRegistry || {};
3864
3865 var listeners = this._eventRegistry[eventName];
3866 if (!listeners)
3867 listeners = this._eventRegistry[eventName] = [];
3868
3869 if (listeners.indexOf(callback) == -1)
3870 listeners[capturing ? "unshift" : "push"](callback);
3871 return callback;
3872 };
3873
3874 EventEmitter.off =
3875 EventEmitter.removeListener =
3876 EventEmitter.removeEventListener = function(eventName, callback) {
3877 this._eventRegistry = this._eventRegistry || {};
3878
3879 var listeners = this._eventRegistry[eventName];
3880 if (!listeners)
3881 return;
3882
3883 var index = listeners.indexOf(callback);
3884 if (index !== -1)
3885 listeners.splice(index, 1);
3886 };
3887
3888 EventEmitter.removeAllListeners = function(eventName) {
3889 if (this._eventRegistry) this._eventRegistry[eventName] = [];
3890 };
3891
3892 exports.EventEmitter = EventEmitter;
3893
3894 });
3895
3896 ace.define("ace/lib/app_config",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(acequire, exports, module) {
3897 "no use strict";
3898
3899 var oop = acequire("./oop");
3900 var EventEmitter = acequire("./event_emitter").EventEmitter;
3901
3902 var optionsProvider = {
3903 setOptions: function(optList) {
3904 Object.keys(optList).forEach(function(key) {
3905 this.setOption(key, optList[key]);
3906 }, this);
3907 },
3908 getOptions: function(optionNames) {
3909 var result = {};
3910 if (!optionNames) {
3911 optionNames = Object.keys(this.$options);
3912 } else if (!Array.isArray(optionNames)) {
3913 result = optionNames;
3914 optionNames = Object.keys(result);
3915 }
3916 optionNames.forEach(function(key) {
3917 result[key] = this.getOption(key);
3918 }, this);
3919 return result;
3920 },
3921 setOption: function(name, value) {
3922 if (this["$" + name] === value)
3923 return;
3924 var opt = this.$options[name];
3925 if (!opt) {
3926 return warn('misspelled option "' + name + '"');
3927 }
3928 if (opt.forwardTo)
3929 return this[opt.forwardTo] && this[opt.forwardTo].setOption(name, value);
3930
3931 if (!opt.handlesSet)
3932 this["$" + name] = value;
3933 if (opt && opt.set)
3934 opt.set.call(this, value);
3935 },
3936 getOption: function(name) {
3937 var opt = this.$options[name];
3938 if (!opt) {
3939 return warn('misspelled option "' + name + '"');
3940 }
3941 if (opt.forwardTo)
3942 return this[opt.forwardTo] && this[opt.forwardTo].getOption(name);
3943 return opt && opt.get ? opt.get.call(this) : this["$" + name];
3944 }
3945 };
3946
3947 function warn(message) {
3948 if (typeof console != "undefined" && console.warn)
3949 console.warn.apply(console, arguments);
3950 }
3951
3952 function reportError(msg, data) {
3953 var e = new Error(msg);
3954 e.data = data;
3955 if (typeof console == "object" && console.error)
3956 console.error(e);
3957 setTimeout(function() { throw e; });
3958 }
3959
3960 var AppConfig = function() {
3961 this.$defaultOptions = {};
3962 };
3963
3964 (function() {
3965 oop.implement(this, EventEmitter);
3966 this.defineOptions = function(obj, path, options) {
3967 if (!obj.$options)
3968 this.$defaultOptions[path] = obj.$options = {};
3969
3970 Object.keys(options).forEach(function(key) {
3971 var opt = options[key];
3972 if (typeof opt == "string")
3973 opt = {forwardTo: opt};
3974
3975 opt.name || (opt.name = key);
3976 obj.$options[opt.name] = opt;
3977 if ("initialValue" in opt)
3978 obj["$" + opt.name] = opt.initialValue;
3979 });
3980 oop.implement(obj, optionsProvider);
3981
3982 return this;
3983 };
3984
3985 this.resetOptions = function(obj) {
3986 Object.keys(obj.$options).forEach(function(key) {
3987 var opt = obj.$options[key];
3988 if ("value" in opt)
3989 obj.setOption(key, opt.value);
3990 });
3991 };
3992
3993 this.setDefaultValue = function(path, name, value) {
3994 var opts = this.$defaultOptions[path] || (this.$defaultOptions[path] = {});
3995 if (opts[name]) {
3996 if (opts.forwardTo)
3997 this.setDefaultValue(opts.forwardTo, name, value);
3998 else
3999 opts[name].value = value;
4000 }
4001 };
4002
4003 this.setDefaultValues = function(path, optionHash) {
4004 Object.keys(optionHash).forEach(function(key) {
4005 this.setDefaultValue(path, key, optionHash[key]);
4006 }, this);
4007 };
4008
4009 this.warn = warn;
4010 this.reportError = reportError;
4011
4012 }).call(AppConfig.prototype);
4013
4014 exports.AppConfig = AppConfig;
4015
4016 });
4017
4018 ace.define("ace/config",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/lib/net","ace/lib/app_config"], function(acequire, exports, module) {
4019 "no use strict";
4020
4021 var lang = acequire("./lib/lang");
4022 acequire("./lib/oop");
4023 var net = acequire("./lib/net");
4024 var AppConfig = acequire("./lib/app_config").AppConfig;
4025
4026 module.exports = exports = new AppConfig();
4027
4028 var global = (function() {
4029 return this || typeof window != "undefined" && window;
4030 })();
4031
4032 var options = {
4033 packaged: false,
4034 workerPath: null,
4035 modePath: null,
4036 themePath: null,
4037 basePath: "",
4038 suffix: ".js",
4039 $moduleUrls: {}
4040 };
4041
4042 exports.get = function(key) {
4043 if (!options.hasOwnProperty(key))
4044 throw new Error("Unknown config key: " + key);
4045
4046 return options[key];
4047 };
4048
4049 exports.set = function(key, value) {
4050 if (!options.hasOwnProperty(key))
4051 throw new Error("Unknown config key: " + key);
4052
4053 options[key] = value;
4054 };
4055
4056 exports.all = function() {
4057 return lang.copyObject(options);
4058 };
4059 exports.moduleUrl = function(name, component) {
4060 if (options.$moduleUrls[name])
4061 return options.$moduleUrls[name];
4062
4063 var parts = name.split("/");
4064 component = component || parts[parts.length - 2] || "";
4065 var sep = component == "snippets" ? "/" : "-";
4066 var base = parts[parts.length - 1];
4067 if (component == "worker" && sep == "-") {
4068 var re = new RegExp("^" + component + "[\\-_]|[\\-_]" + component + "$", "g");
4069 base = base.replace(re, "");
4070 }
4071
4072 if ((!base || base == component) && parts.length > 1)
4073 base = parts[parts.length - 2];
4074 var path = options[component + "Path"];
4075 if (path == null) {
4076 path = options.basePath;
4077 } else if (sep == "/") {
4078 component = sep = "";
4079 }
4080 if (path && path.slice(-1) != "/")
4081 path += "/";
4082 return path + component + sep + base + this.get("suffix");
4083 };
4084
4085 exports.setModuleUrl = function(name, subst) {
4086 return options.$moduleUrls[name] = subst;
4087 };
4088
4089 exports.$loading = {};
4090 exports.loadModule = function(moduleName, onLoad) {
4091 var module, moduleType;
4092 if (Array.isArray(moduleName)) {
4093 moduleType = moduleName[0];
4094 moduleName = moduleName[1];
4095 }
4096
4097 try {
4098 module = acequire(moduleName);
4099 } catch (e) {}
4100 if (module && !exports.$loading[moduleName])
4101 return onLoad && onLoad(module);
4102
4103 if (!exports.$loading[moduleName])
4104 exports.$loading[moduleName] = [];
4105
4106 exports.$loading[moduleName].push(onLoad);
4107
4108 if (exports.$loading[moduleName].length > 1)
4109 return;
4110
4111 var afterLoad = function() {
4112 acequire([moduleName], function(module) {
4113 exports._emit("load.module", {name: moduleName, module: module});
4114 var listeners = exports.$loading[moduleName];
4115 exports.$loading[moduleName] = null;
4116 listeners.forEach(function(onLoad) {
4117 onLoad && onLoad(module);
4118 });
4119 });
4120 };
4121
4122 if (!exports.get("packaged"))
4123 return afterLoad();
4124 net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
4125 };
4126 init(true);function init(packaged) {
4127
4128 if (!global || !global.document)
4129 return;
4130
4131 options.packaged = packaged || acequire.packaged || module.packaged || (global.define && undefined.packaged);
4132
4133 var scriptOptions = {};
4134 var scriptUrl = "";
4135 var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
4136 var currentDocument = currentScript && currentScript.ownerDocument || document;
4137
4138 var scripts = currentDocument.getElementsByTagName("script");
4139 for (var i=0; i<scripts.length; i++) {
4140 var script = scripts[i];
4141
4142 var src = script.src || script.getAttribute("src");
4143 if (!src)
4144 continue;
4145
4146 var attributes = script.attributes;
4147 for (var j=0, l=attributes.length; j < l; j++) {
4148 var attr = attributes[j];
4149 if (attr.name.indexOf("data-ace-") === 0) {
4150 scriptOptions[deHyphenate(attr.name.replace(/^data-ace-/, ""))] = attr.value;
4151 }
4152 }
4153
4154 var m = src.match(/^(.*)\/ace(\-\w+)?\.js(\?|$)/);
4155 if (m)
4156 scriptUrl = m[1];
4157 }
4158
4159 if (scriptUrl) {
4160 scriptOptions.base = scriptOptions.base || scriptUrl;
4161 scriptOptions.packaged = true;
4162 }
4163
4164 scriptOptions.basePath = scriptOptions.base;
4165 scriptOptions.workerPath = scriptOptions.workerPath || scriptOptions.base;
4166 scriptOptions.modePath = scriptOptions.modePath || scriptOptions.base;
4167 scriptOptions.themePath = scriptOptions.themePath || scriptOptions.base;
4168 delete scriptOptions.base;
4169
4170 for (var key in scriptOptions)
4171 if (typeof scriptOptions[key] !== "undefined")
4172 exports.set(key, scriptOptions[key]);
4173 }
4174
4175 exports.init = init;
4176
4177 function deHyphenate(str) {
4178 return str.replace(/-(.)/g, function(m, m1) { return m1.toUpperCase(); });
4179 }
4180
4181 });
4182
4183 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/config"], function(acequire, exports, module) {
4184
4185 var event = acequire("../lib/event");
4186 var useragent = acequire("../lib/useragent");
4187 var DefaultHandlers = acequire("./default_handlers").DefaultHandlers;
4188 var DefaultGutterHandler = acequire("./default_gutter_handler").GutterHandler;
4189 var MouseEvent = acequire("./mouse_event").MouseEvent;
4190 var DragdropHandler = acequire("./dragdrop_handler").DragdropHandler;
4191 var config = acequire("../config");
4192
4193 var MouseHandler = function(editor) {
4194 var _self = this;
4195 this.editor = editor;
4196
4197 new DefaultHandlers(this);
4198 new DefaultGutterHandler(this);
4199 new DragdropHandler(this);
4200
4201 var focusEditor = function(e) {
4202 var windowBlurred = !document.hasFocus || !document.hasFocus()
4203 || !editor.isFocused() && document.activeElement == (editor.textInput && editor.textInput.getElement());
4204 if (windowBlurred)
4205 window.focus();
4206 editor.focus();
4207 };
4208
4209 var mouseTarget = editor.renderer.getMouseEventTarget();
4210 event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
4211 event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
4212 event.addMultiMouseDownListener([
4213 mouseTarget,
4214 editor.renderer.scrollBarV && editor.renderer.scrollBarV.inner,
4215 editor.renderer.scrollBarH && editor.renderer.scrollBarH.inner,
4216 editor.textInput && editor.textInput.getElement()
4217 ].filter(Boolean), [400, 300, 250], this, "onMouseEvent");
4218 event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
4219 event.addTouchMoveListener(editor.container, this.onTouchMove.bind(this, "touchmove"));
4220
4221 var gutterEl = editor.renderer.$gutter;
4222 event.addListener(gutterEl, "mousedown", this.onMouseEvent.bind(this, "guttermousedown"));
4223 event.addListener(gutterEl, "click", this.onMouseEvent.bind(this, "gutterclick"));
4224 event.addListener(gutterEl, "dblclick", this.onMouseEvent.bind(this, "gutterdblclick"));
4225 event.addListener(gutterEl, "mousemove", this.onMouseEvent.bind(this, "guttermousemove"));
4226
4227 event.addListener(mouseTarget, "mousedown", focusEditor);
4228 event.addListener(gutterEl, "mousedown", focusEditor);
4229 if (useragent.isIE && editor.renderer.scrollBarV) {
4230 event.addListener(editor.renderer.scrollBarV.element, "mousedown", focusEditor);
4231 event.addListener(editor.renderer.scrollBarH.element, "mousedown", focusEditor);
4232 }
4233
4234 editor.on("mousemove", function(e){
4235 if (_self.state || _self.$dragDelay || !_self.$dragEnabled)
4236 return;
4237
4238 var character = editor.renderer.screenToTextCoordinates(e.x, e.y);
4239 var range = editor.session.selection.getRange();
4240 var renderer = editor.renderer;
4241
4242 if (!range.isEmpty() && range.insideStart(character.row, character.column)) {
4243 renderer.setCursorStyle("default");
4244 } else {
4245 renderer.setCursorStyle("");
4246 }
4247 });
4248 };
4249
4250 (function() {
4251 this.onMouseEvent = function(name, e) {
4252 this.editor._emit(name, new MouseEvent(e, this.editor));
4253 };
4254
4255 this.onMouseMove = function(name, e) {
4256 var listeners = this.editor._eventRegistry && this.editor._eventRegistry.mousemove;
4257 if (!listeners || !listeners.length)
4258 return;
4259
4260 this.editor._emit(name, new MouseEvent(e, this.editor));
4261 };
4262
4263 this.onMouseWheel = function(name, e) {
4264 var mouseEvent = new MouseEvent(e, this.editor);
4265 mouseEvent.speed = this.$scrollSpeed * 2;
4266 mouseEvent.wheelX = e.wheelX;
4267 mouseEvent.wheelY = e.wheelY;
4268
4269 this.editor._emit(name, mouseEvent);
4270 };
4271
4272 this.onTouchMove = function (name, e) {
4273 var mouseEvent = new MouseEvent(e, this.editor);
4274 mouseEvent.speed = 1;//this.$scrollSpeed * 2;
4275 mouseEvent.wheelX = e.wheelX;
4276 mouseEvent.wheelY = e.wheelY;
4277 this.editor._emit(name, mouseEvent);
4278 };
4279
4280 this.setState = function(state) {
4281 this.state = state;
4282 };
4283
4284 this.captureMouse = function(ev, mouseMoveHandler) {
4285 this.x = ev.x;
4286 this.y = ev.y;
4287
4288 this.isMousePressed = true;
4289 var renderer = this.editor.renderer;
4290 if (renderer.$keepTextAreaAtCursor)
4291 renderer.$keepTextAreaAtCursor = null;
4292
4293 var self = this;
4294 var onMouseMove = function(e) {
4295 if (!e) return;
4296 if (useragent.isWebKit && !e.which && self.releaseMouse)
4297 return self.releaseMouse();
4298
4299 self.x = e.clientX;
4300 self.y = e.clientY;
4301 mouseMoveHandler && mouseMoveHandler(e);
4302 self.mouseEvent = new MouseEvent(e, self.editor);
4303 self.$mouseMoved = true;
4304 };
4305
4306 var onCaptureEnd = function(e) {
4307 clearInterval(timerId);
4308 onCaptureInterval();
4309 self[self.state + "End"] && self[self.state + "End"](e);
4310 self.state = "";
4311 if (renderer.$keepTextAreaAtCursor == null) {
4312 renderer.$keepTextAreaAtCursor = true;
4313 renderer.$moveTextAreaToCursor();
4314 }
4315 self.isMousePressed = false;
4316 self.$onCaptureMouseMove = self.releaseMouse = null;
4317 e && self.onMouseEvent("mouseup", e);
4318 };
4319
4320 var onCaptureInterval = function() {
4321 self[self.state] && self[self.state]();
4322 self.$mouseMoved = false;
4323 };
4324
4325 if (useragent.isOldIE && ev.domEvent.type == "dblclick") {
4326 return setTimeout(function() {onCaptureEnd(ev);});
4327 }
4328
4329 self.$onCaptureMouseMove = onMouseMove;
4330 self.releaseMouse = event.capture(this.editor.container, onMouseMove, onCaptureEnd);
4331 var timerId = setInterval(onCaptureInterval, 20);
4332 };
4333 this.releaseMouse = null;
4334 this.cancelContextMenu = function() {
4335 var stop = function(e) {
4336 if (e && e.domEvent && e.domEvent.type != "contextmenu")
4337 return;
4338 this.editor.off("nativecontextmenu", stop);
4339 if (e && e.domEvent)
4340 event.stopEvent(e.domEvent);
4341 }.bind(this);
4342 setTimeout(stop, 10);
4343 this.editor.on("nativecontextmenu", stop);
4344 };
4345 }).call(MouseHandler.prototype);
4346
4347 config.defineOptions(MouseHandler.prototype, "mouseHandler", {
4348 scrollSpeed: {initialValue: 2},
4349 dragDelay: {initialValue: (useragent.isMac ? 150 : 0)},
4350 dragEnabled: {initialValue: true},
4351 focusTimout: {initialValue: 0},
4352 tooltipFollowsMouse: {initialValue: true}
4353 });
4354
4355
4356 exports.MouseHandler = MouseHandler;
4357 });
4358
4359 ace.define("ace/mouse/fold_handler",["require","exports","module"], function(acequire, exports, module) {
4360
4361 function FoldHandler(editor) {
4362
4363 editor.on("click", function(e) {
4364 var position = e.getDocumentPosition();
4365 var session = editor.session;
4366 var fold = session.getFoldAt(position.row, position.column, 1);
4367 if (fold) {
4368 if (e.getAccelKey())
4369 session.removeFold(fold);
4370 else
4371 session.expandFold(fold);
4372
4373 e.stop();
4374 }
4375 });
4376
4377 editor.on("gutterclick", function(e) {
4378 var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
4379
4380 if (gutterRegion == "foldWidgets") {
4381 var row = e.getDocumentPosition().row;
4382 var session = editor.session;
4383 if (session.foldWidgets && session.foldWidgets[row])
4384 editor.session.onFoldWidgetClick(row, e);
4385 if (!editor.isFocused())
4386 editor.focus();
4387 e.stop();
4388 }
4389 });
4390
4391 editor.on("gutterdblclick", function(e) {
4392 var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
4393
4394 if (gutterRegion == "foldWidgets") {
4395 var row = e.getDocumentPosition().row;
4396 var session = editor.session;
4397 var data = session.getParentFoldRangeData(row, true);
4398 var range = data.range || data.firstRange;
4399
4400 if (range) {
4401 row = range.start.row;
4402 var fold = session.getFoldAt(row, session.getLine(row).length, 1);
4403
4404 if (fold) {
4405 session.removeFold(fold);
4406 } else {
4407 session.addFold("...", range);
4408 editor.renderer.scrollCursorIntoView({row: range.start.row, column: 0});
4409 }
4410 }
4411 e.stop();
4412 }
4413 });
4414 }
4415
4416 exports.FoldHandler = FoldHandler;
4417
4418 });
4419
4420 ace.define("ace/keyboard/keybinding",["require","exports","module","ace/lib/keys","ace/lib/event"], function(acequire, exports, module) {
4421
4422 var keyUtil = acequire("../lib/keys");
4423 var event = acequire("../lib/event");
4424
4425 var KeyBinding = function(editor) {
4426 this.$editor = editor;
4427 this.$data = {editor: editor};
4428 this.$handlers = [];
4429 this.setDefaultHandler(editor.commands);
4430 };
4431
4432 (function() {
4433 this.setDefaultHandler = function(kb) {
4434 this.removeKeyboardHandler(this.$defaultHandler);
4435 this.$defaultHandler = kb;
4436 this.addKeyboardHandler(kb, 0);
4437 };
4438
4439 this.setKeyboardHandler = function(kb) {
4440 var h = this.$handlers;
4441 if (h[h.length - 1] == kb)
4442 return;
4443
4444 while (h[h.length - 1] && h[h.length - 1] != this.$defaultHandler)
4445 this.removeKeyboardHandler(h[h.length - 1]);
4446
4447 this.addKeyboardHandler(kb, 1);
4448 };
4449
4450 this.addKeyboardHandler = function(kb, pos) {
4451 if (!kb)
4452 return;
4453 if (typeof kb == "function" && !kb.handleKeyboard)
4454 kb.handleKeyboard = kb;
4455 var i = this.$handlers.indexOf(kb);
4456 if (i != -1)
4457 this.$handlers.splice(i, 1);
4458
4459 if (pos == undefined)
4460 this.$handlers.push(kb);
4461 else
4462 this.$handlers.splice(pos, 0, kb);
4463
4464 if (i == -1 && kb.attach)
4465 kb.attach(this.$editor);
4466 };
4467
4468 this.removeKeyboardHandler = function(kb) {
4469 var i = this.$handlers.indexOf(kb);
4470 if (i == -1)
4471 return false;
4472 this.$handlers.splice(i, 1);
4473 kb.detach && kb.detach(this.$editor);
4474 return true;
4475 };
4476
4477 this.getKeyboardHandler = function() {
4478 return this.$handlers[this.$handlers.length - 1];
4479 };
4480
4481 this.getStatusText = function() {
4482 var data = this.$data;
4483 var editor = data.editor;
4484 return this.$handlers.map(function(h) {
4485 return h.getStatusText && h.getStatusText(editor, data) || "";
4486 }).filter(Boolean).join(" ");
4487 };
4488
4489 this.$callKeyboardHandlers = function(hashId, keyString, keyCode, e) {
4490 var toExecute;
4491 var success = false;
4492 var commands = this.$editor.commands;
4493
4494 for (var i = this.$handlers.length; i--;) {
4495 toExecute = this.$handlers[i].handleKeyboard(
4496 this.$data, hashId, keyString, keyCode, e
4497 );
4498 if (!toExecute || !toExecute.command)
4499 continue;
4500 if (toExecute.command == "null") {
4501 success = true;
4502 } else {
4503 success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
4504 }
4505 if (success && e && hashId != -1 &&
4506 toExecute.passEvent != true && toExecute.command.passEvent != true
4507 ) {
4508 event.stopEvent(e);
4509 }
4510 if (success)
4511 break;
4512 }
4513
4514 if (!success && hashId == -1) {
4515 toExecute = {command: "insertstring"};
4516 success = commands.exec("insertstring", this.$editor, keyString);
4517 }
4518
4519 if (success && this.$editor._signal)
4520 this.$editor._signal("keyboardActivity", toExecute);
4521
4522 return success;
4523 };
4524
4525 this.onCommandKey = function(e, hashId, keyCode) {
4526 var keyString = keyUtil.keyCodeToString(keyCode);
4527 this.$callKeyboardHandlers(hashId, keyString, keyCode, e);
4528 };
4529
4530 this.onTextInput = function(text) {
4531 this.$callKeyboardHandlers(-1, text);
4532 };
4533
4534 }).call(KeyBinding.prototype);
4535
4536 exports.KeyBinding = KeyBinding;
4537 });
4538
4539 ace.define("ace/lib/bidiutil",["require","exports","module"], function(acequire, exports, module) {
4540 var dir = 0, hiLevel = 0;
4541 var lastArabic = false, hasUBAT_B = false, hasUBAT_S = false;
4542
4543 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 ]
4544 ];
4545
4546 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 ]
4547 ];
4548
4549 var LTR = 0, RTL = 1;
4550
4551 var L = 0;
4552 var R = 1;
4553 var EN = 2;
4554 var AN = 3;
4555 var ON = 4;
4556 var B = 5;
4557 var S = 6;
4558 var AL = 7;
4559 var WS = 8;
4560 var CS = 9;
4561 var ES = 10;
4562 var ET = 11;
4563 var NSM = 12;
4564 var LRE = 13;
4565 var RLE = 14;
4566 var PDF = 15;
4567 var LRO = 16;
4568 var RLO = 17;
4569 var BN = 18;
4570
4571 var UnicodeTBL00 = [
4572 BN,BN,BN,BN,BN,BN,BN,BN,BN,S,B,S,WS,B,BN,BN,
4573 BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,B,B,B,S,
4574 WS,ON,ON,ET,ET,ET,ON,ON,ON,ON,ON,ES,CS,ES,CS,CS,
4575 EN,EN,EN,EN,EN,EN,EN,EN,EN,EN,CS,ON,ON,ON,ON,ON,
4576 ON,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,
4577 L,L,L,L,L,L,L,L,L,L,L,ON,ON,ON,ON,ON,
4578 ON,L,L,L,L,L,L,L,L,L,L,L,L,L,L,L,
4579 L,L,L,L,L,L,L,L,L,L,L,ON,ON,ON,ON,BN,
4580 BN,BN,BN,BN,BN,B,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,
4581 BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,BN,
4582 CS,ON,ET,ET,ET,ET,ON,ON,ON,ON,L,ON,ON,BN,ON,ON,
4583 ET,ET,EN,EN,ON,L,ON,ON,ON,EN,L,ON,ON,ON,ON,ON
4584 ];
4585
4586 var UnicodeTBL20 = [
4587 WS,WS,WS,WS,WS,WS,WS,WS,WS,WS,WS,BN,BN,BN,L,R ,
4588 ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,
4589 ON,ON,ON,ON,ON,ON,ON,ON,WS,B,LRE,RLE,PDF,LRO,RLO,CS,
4590 ET,ET,ET,ET,ET,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,
4591 ON,ON,ON,ON,CS,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,
4592 ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,ON,WS
4593 ];
4594
4595 function _computeLevels(chars, levels, len, charTypes) {
4596 var impTab = dir ? impTab_RTL : impTab_LTR
4597 , prevState = null, newClass = null, newLevel = null, newState = 0
4598 , action = null, cond = null, condPos = -1, i = null, ix = null, classes = [];
4599
4600 if (!charTypes) {
4601 for (i = 0, charTypes = []; i < len; i++) {
4602 charTypes[i] = _getCharacterType(chars[i]);
4603 }
4604 }
4605 hiLevel = dir;
4606 lastArabic = false;
4607 hasUBAT_B = false;
4608 hasUBAT_S = false;
4609 for (ix = 0; ix < len; ix++){
4610 prevState = newState;
4611 classes[ix] = newClass = _getCharClass(chars, charTypes, classes, ix);
4612 newState = impTab[prevState][newClass];
4613 action = newState & 0xF0;
4614 newState &= 0x0F;
4615 levels[ix] = newLevel = impTab[newState][5];
4616 if (action > 0){
4617 if (action == 0x10){
4618 for(i = condPos; i < ix; i++){
4619 levels[i] = 1;
4620 }
4621 condPos = -1;
4622 } else {
4623 condPos = -1;
4624 }
4625 }
4626 cond = impTab[newState][6];
4627 if (cond){
4628 if(condPos == -1){
4629 condPos = ix;
4630 }
4631 }else {
4632 if (condPos > -1){
4633 for(i = condPos; i < ix; i++){
4634 levels[i] = newLevel;
4635 }
4636 condPos = -1;
4637 }
4638 }
4639 if (charTypes[ix] == B){
4640 levels[ix] = 0;
4641 }
4642 hiLevel |= newLevel;
4643 }
4644 if (hasUBAT_S){
4645 for(i = 0; i < len; i++){
4646 if(charTypes[i] == S){
4647 levels[i] = dir;
4648 for(var j = i - 1; j >= 0; j--){
4649 if(charTypes[j] == WS){
4650 levels[j] = dir;
4651 }else {
4652 break;
4653 }
4654 }
4655 }
4656 }
4657 }
4658 }
4659
4660 function _invertLevel(lev, levels, _array) {
4661 if (hiLevel < lev){
4662 return;
4663 }
4664 if (lev == 1 && dir == RTL && !hasUBAT_B){
4665 _array.reverse();
4666 return;
4667 }
4668 var len = _array.length, start = 0, end, lo, hi, tmp;
4669 while(start < len){
4670 if (levels[start] >= lev){
4671 end = start + 1;
4672 while(end < len && levels[end] >= lev){
4673 end++;
4674 }
4675 for(lo = start, hi = end - 1 ; lo < hi; lo++, hi--){
4676 tmp = _array[lo];
4677 _array[lo] = _array[hi];
4678 _array[hi] = tmp;
4679 }
4680 start = end;
4681 }
4682 start++;
4683 }
4684 }
4685
4686 function _getCharClass(chars, types, classes, ix) {
4687 var cType = types[ix], wType, nType, len, i;
4688 switch(cType){
4689 case L:
4690 case R:
4691 lastArabic = false;
4692 case ON:
4693 case AN:
4694 return cType;
4695 case EN:
4696 return lastArabic ? AN : EN;
4697 case AL:
4698 lastArabic = true;
4699 return R;
4700 case WS:
4701 return ON;
4702 case CS:
4703 if (ix < 1 || (ix + 1) >= types.length ||
4704 ((wType = classes[ix - 1]) != EN && wType != AN) ||
4705 ((nType = types[ix + 1]) != EN && nType != AN)){
4706 return ON;
4707 }
4708 if (lastArabic){nType = AN;}
4709 return nType == wType ? nType : ON;
4710 case ES:
4711 wType = ix > 0 ? classes[ix - 1] : B;
4712 if (wType == EN && (ix + 1) < types.length && types[ix + 1] == EN){
4713 return EN;
4714 }
4715 return ON;
4716 case ET:
4717 if (ix > 0 && classes[ix - 1] == EN){
4718 return EN;
4719 }
4720 if (lastArabic){
4721 return ON;
4722 }
4723 i = ix + 1;
4724 len = types.length;
4725 while (i < len && types[i] == ET){
4726 i++;
4727 }
4728 if (i < len && types[i] == EN){
4729 return EN;
4730 }
4731 return ON;
4732 case NSM:
4733 len = types.length;
4734 i = ix + 1;
4735 while (i < len && types[i] == NSM){
4736 i++;
4737 }
4738 if (i < len){
4739 var c = chars[ix], rtlCandidate = (c >= 0x0591 && c <= 0x08FF) || c == 0xFB1E;
4740
4741 wType = types[i];
4742 if (rtlCandidate && (wType == R || wType == AL)){
4743 return R;
4744 }
4745 }
4746
4747 if (ix < 1 || (wType = types[ix - 1]) == B){
4748 return ON;
4749 }
4750 return classes[ix - 1];
4751 case B:
4752 lastArabic = false;
4753 hasUBAT_B = true;
4754 return dir;
4755 case S:
4756 hasUBAT_S = true;
4757 return ON;
4758 case LRE:
4759 case RLE:
4760 case LRO:
4761 case RLO:
4762 case PDF:
4763 lastArabic = false;
4764 case BN:
4765 return ON;
4766 }
4767 }
4768
4769 function _getCharacterType( ch ) {
4770 var uc = ch.charCodeAt(0), hi = uc >> 8;
4771
4772 if (hi == 0) {
4773 return ((uc > 0x00BF) ? L : UnicodeTBL00[uc]);
4774 } else if (hi == 5) {
4775 return (/[\u0591-\u05f4]/.test(ch) ? R : L);
4776 } else if (hi == 6) {
4777 if (/[\u0610-\u061a\u064b-\u065f\u06d6-\u06e4\u06e7-\u06ed]/.test(ch))
4778 return NSM;
4779 else if (/[\u0660-\u0669\u066b-\u066c]/.test(ch))
4780 return AN;
4781 else if (uc == 0x066A)
4782 return ET;
4783 else if (/[\u06f0-\u06f9]/.test(ch))
4784 return EN;
4785 else
4786 return AL;
4787 } else if (hi == 0x20 && uc <= 0x205F) {
4788 return UnicodeTBL20[uc & 0xFF];
4789 } else if (hi == 0xFE) {
4790 return (uc >= 0xFE70 ? AL : ON);
4791 }
4792 return ON;
4793 }
4794 exports.L = L;
4795 exports.R = R;
4796 exports.EN = EN;
4797 exports.ON_R = 3;
4798 exports.AN = 4;
4799 exports.R_H = 5;
4800 exports.B = 6;
4801
4802 exports.DOT = "\xB7";
4803 exports.doBidiReorder = function(text, textCharTypes, isRtl) {
4804 if (text.length < 2)
4805 return {};
4806
4807 var chars = text.split(""), logicalFromVisual = new Array(chars.length),
4808 bidiLevels = new Array(chars.length), levels = [];
4809
4810 dir = isRtl ? RTL : LTR;
4811
4812 _computeLevels(chars, levels, chars.length, textCharTypes);
4813
4814 for (var i = 0; i < logicalFromVisual.length; logicalFromVisual[i] = i, i++);
4815
4816 _invertLevel(2, levels, logicalFromVisual);
4817 _invertLevel(1, levels, logicalFromVisual);
4818
4819 for (var i = 0; i < logicalFromVisual.length - 1; i++) { //fix levels to reflect character width
4820 if (textCharTypes[i] === AN) {
4821 levels[i] = exports.AN;
4822 } else if (levels[i] === R && ((textCharTypes[i] > AL && textCharTypes[i] < LRE)
4823 || textCharTypes[i] === ON || textCharTypes[i] === BN)) {
4824 levels[i] = exports.ON_R;
4825 } else if ((i > 0 && chars[i - 1] === '\u0644') && /\u0622|\u0623|\u0625|\u0627/.test(chars[i])) {
4826 levels[i - 1] = levels[i] = exports.R_H;
4827 i++;
4828 }
4829 }
4830 if (chars[chars.length - 1] === exports.DOT)
4831 levels[chars.length - 1] = exports.B;
4832
4833 for (var i = 0; i < logicalFromVisual.length; i++) {
4834 bidiLevels[i] = levels[logicalFromVisual[i]];
4835 }
4836
4837 return {'logicalFromVisual': logicalFromVisual, 'bidiLevels': bidiLevels};
4838 };
4839 exports.hasBidiCharacters = function(text, textCharTypes){
4840 var ret = false;
4841 for (var i = 0; i < text.length; i++){
4842 textCharTypes[i] = _getCharacterType(text.charAt(i));
4843 if (!ret && (textCharTypes[i] == R || textCharTypes[i] == AL))
4844 ret = true;
4845 }
4846 return ret;
4847 };
4848 exports.getVisualFromLogicalIdx = function(logIdx, rowMap) {
4849 for (var i = 0; i < rowMap.logicalFromVisual.length; i++) {
4850 if (rowMap.logicalFromVisual[i] == logIdx)
4851 return i;
4852 }
4853 return 0;
4854 };
4855
4856 });
4857
4858 ace.define("ace/bidihandler",["require","exports","module","ace/lib/bidiutil","ace/lib/lang","ace/lib/useragent"], function(acequire, exports, module) {
4859
4860 var bidiUtil = acequire("./lib/bidiutil");
4861 var lang = acequire("./lib/lang");
4862 var useragent = acequire("./lib/useragent");
4863 var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
4864 var BidiHandler = function(session) {
4865 this.session = session;
4866 this.bidiMap = {};
4867 this.currentRow = null;
4868 this.bidiUtil = bidiUtil;
4869 this.charWidths = [];
4870 this.EOL = "\xAC";
4871 this.showInvisibles = true;
4872 this.isRtlDir = false;
4873 this.line = "";
4874 this.wrapIndent = 0;
4875 this.isLastRow = false;
4876 this.EOF = "\xB6";
4877 this.seenBidi = false;
4878 };
4879
4880 (function() {
4881 this.isBidiRow = function(screenRow, docRow, splitIndex) {
4882 if (!this.seenBidi)
4883 return false;
4884 if (screenRow !== this.currentRow) {
4885 this.currentRow = screenRow;
4886 this.updateRowLine(docRow, splitIndex);
4887 this.updateBidiMap();
4888 }
4889 return this.bidiMap.bidiLevels;
4890 };
4891
4892 this.onChange = function(delta) {
4893 if (!this.seenBidi) {
4894 if (delta.action == "insert" && bidiRE.test(delta.lines.join("\n"))) {
4895 this.seenBidi = true;
4896 this.currentRow = null;
4897 }
4898 }
4899 else {
4900 this.currentRow = null;
4901 }
4902 };
4903
4904 this.getDocumentRow = function() {
4905 var docRow = 0;
4906 var rowCache = this.session.$screenRowCache;
4907 if (rowCache.length) {
4908 var index = this.session.$getRowCacheIndex(rowCache, this.currentRow);
4909 if (index >= 0)
4910 docRow = this.session.$docRowCache[index];
4911 }
4912
4913 return docRow;
4914 };
4915
4916 this.getSplitIndex = function() {
4917 var splitIndex = 0;
4918 var rowCache = this.session.$screenRowCache;
4919 if (rowCache.length) {
4920 var currentIndex, prevIndex = this.session.$getRowCacheIndex(rowCache, this.currentRow);
4921 while (this.currentRow - splitIndex > 0) {
4922 currentIndex = this.session.$getRowCacheIndex(rowCache, this.currentRow - splitIndex - 1);
4923 if (currentIndex !== prevIndex)
4924 break;
4925
4926 prevIndex = currentIndex;
4927 splitIndex++;
4928 }
4929 }
4930
4931 return splitIndex;
4932 };
4933
4934 this.updateRowLine = function(docRow, splitIndex) {
4935 if (docRow === undefined)
4936 docRow = this.getDocumentRow();
4937
4938 this.wrapIndent = 0;
4939 this.isLastRow = (docRow === this.session.getLength() - 1);
4940 this.line = this.session.getLine(docRow);
4941 if (this.session.$useWrapMode) {
4942 var splits = this.session.$wrapData[docRow];
4943 if (splits) {
4944 if (splitIndex === undefined)
4945 splitIndex = this.getSplitIndex();
4946
4947 if(splitIndex > 0 && splits.length) {
4948 this.wrapIndent = splits.indent;
4949 this.line = (splitIndex < splits.length) ?
4950 this.line.substring(splits[splitIndex - 1], splits[splits.length - 1]) :
4951 this.line.substring(splits[splits.length - 1]);
4952 } else {
4953 this.line = this.line.substring(0, splits[splitIndex]);
4954 }
4955 }
4956 }
4957 var session = this.session, shift = 0, size;
4958 this.line = this.line.replace(/\t|[\u1100-\u2029, \u202F-\uFFE6]/g, function(ch, i){
4959 if (ch === '\t' || session.isFullWidth(ch.charCodeAt(0))) {
4960 size = (ch === '\t') ? session.getScreenTabSize(i + shift) : 2;
4961 shift += size - 1;
4962 return lang.stringRepeat(bidiUtil.DOT, size);
4963 }
4964 return ch;
4965 });
4966 };
4967
4968 this.updateBidiMap = function() {
4969 var textCharTypes = [], endOfLine = this.isLastRow ? this.EOF : this.EOL;
4970 var line = this.line + (this.showInvisibles ? endOfLine : bidiUtil.DOT);
4971 if (bidiUtil.hasBidiCharacters(line, textCharTypes)) {
4972 this.bidiMap = bidiUtil.doBidiReorder(line, textCharTypes, this.isRtlDir);
4973 } else {
4974 this.bidiMap = {};
4975 }
4976 };
4977 this.markAsDirty = function() {
4978 this.currentRow = null;
4979 };
4980 this.updateCharacterWidths = function(fontMetrics) {
4981 if (!this.seenBidi)
4982 return;
4983 if (this.characterWidth === fontMetrics.$characterSize.width)
4984 return;
4985
4986 var characterWidth = this.characterWidth = fontMetrics.$characterSize.width;
4987 var bidiCharWidth = fontMetrics.$measureCharWidth("\u05d4");
4988
4989 this.charWidths[bidiUtil.L] = this.charWidths[bidiUtil.EN] = this.charWidths[bidiUtil.ON_R] = characterWidth;
4990 this.charWidths[bidiUtil.R] = this.charWidths[bidiUtil.AN] = bidiCharWidth;
4991 this.charWidths[bidiUtil.R_H] = useragent.isChrome ? bidiCharWidth : bidiCharWidth * 0.45;
4992 this.charWidths[bidiUtil.B] = 0;
4993
4994 this.currentRow = null;
4995 };
4996
4997 this.getShowInvisibles = function() {
4998 return this.showInvisibles;
4999 };
5000
5001 this.setShowInvisibles = function(showInvisibles) {
5002 this.showInvisibles = showInvisibles;
5003 this.currentRow = null;
5004 };
5005
5006 this.setEolChar = function(eolChar) {
5007 this.EOL = eolChar;
5008 };
5009
5010 this.setTextDir = function(isRtlDir) {
5011 this.isRtlDir = isRtlDir;
5012 };
5013 this.getPosLeft = function(col) {
5014 col -= this.wrapIndent;
5015 var visualIdx = bidiUtil.getVisualFromLogicalIdx(col > 0 ? col - 1 : 0, this.bidiMap),
5016 levels = this.bidiMap.bidiLevels, left = 0;
5017
5018 if (col === 0 && levels[visualIdx] % 2 !== 0)
5019 visualIdx++;
5020
5021 for (var i = 0; i < visualIdx; i++) {
5022 left += this.charWidths[levels[i]];
5023 }
5024
5025 if (col !== 0 && levels[visualIdx] % 2 === 0)
5026 left += this.charWidths[levels[visualIdx]];
5027
5028 if (this.wrapIndent)
5029 left += this.wrapIndent * this.charWidths[bidiUtil.L];
5030
5031 return left;
5032 };
5033 this.getSelections = function(startCol, endCol) {
5034 var map = this.bidiMap, levels = map.bidiLevels, level, offset = this.wrapIndent * this.charWidths[bidiUtil.L], selections = [],
5035 selColMin = Math.min(startCol, endCol) - this.wrapIndent, selColMax = Math.max(startCol, endCol) - this.wrapIndent,
5036 isSelected = false, isSelectedPrev = false, selectionStart = 0;
5037
5038 for (var logIdx, visIdx = 0; visIdx < levels.length; visIdx++) {
5039 logIdx = map.logicalFromVisual[visIdx];
5040 level = levels[visIdx];
5041 isSelected = (logIdx >= selColMin) && (logIdx < selColMax);
5042 if (isSelected && !isSelectedPrev) {
5043 selectionStart = offset;
5044 } else if (!isSelected && isSelectedPrev) {
5045 selections.push({left: selectionStart, width: offset - selectionStart});
5046 }
5047 offset += this.charWidths[level];
5048 isSelectedPrev = isSelected;
5049 }
5050
5051 if (isSelected && (visIdx === levels.length)) {
5052 selections.push({left: selectionStart, width: offset - selectionStart});
5053 }
5054
5055 return selections;
5056 };
5057 this.offsetToCol = function(posX) {
5058 var logicalIdx = 0, posX = Math.max(posX, 0),
5059 offset = 0, visualIdx = 0, levels = this.bidiMap.bidiLevels,
5060 charWidth = this.charWidths[levels[visualIdx]];
5061
5062 if (this.wrapIndent) {
5063 posX -= this.wrapIndent * this.charWidths[bidiUtil.L];
5064 }
5065
5066 while(posX > offset + charWidth/2) {
5067 offset += charWidth;
5068 if(visualIdx === levels.length - 1) {
5069 charWidth = 0;
5070 break;
5071 }
5072 charWidth = this.charWidths[levels[++visualIdx]];
5073 }
5074
5075 if (visualIdx > 0 && (levels[visualIdx - 1] % 2 !== 0) && (levels[visualIdx] % 2 === 0)){
5076 if(posX < offset)
5077 visualIdx--;
5078 logicalIdx = this.bidiMap.logicalFromVisual[visualIdx];
5079
5080 } else if (visualIdx > 0 && (levels[visualIdx - 1] % 2 === 0) && (levels[visualIdx] % 2 !== 0)){
5081 logicalIdx = 1 + ((posX > offset) ? this.bidiMap.logicalFromVisual[visualIdx]
5082 : this.bidiMap.logicalFromVisual[visualIdx - 1]);
5083
5084 } else if ((this.isRtlDir && visualIdx === levels.length - 1 && charWidth === 0 && (levels[visualIdx - 1] % 2 === 0))
5085 || (!this.isRtlDir && visualIdx === 0 && (levels[visualIdx] % 2 !== 0))){
5086 logicalIdx = 1 + this.bidiMap.logicalFromVisual[visualIdx];
5087 } else {
5088 if (visualIdx > 0 && (levels[visualIdx - 1] % 2 !== 0) && charWidth !== 0)
5089 visualIdx--;
5090 logicalIdx = this.bidiMap.logicalFromVisual[visualIdx];
5091 }
5092
5093 return (logicalIdx + this.wrapIndent);
5094 };
5095
5096 }).call(BidiHandler.prototype);
5097
5098 exports.BidiHandler = BidiHandler;
5099 });
5100
5101 ace.define("ace/range",["require","exports","module"], function(acequire, exports, module) {
5102 var comparePoints = function(p1, p2) {
5103 return p1.row - p2.row || p1.column - p2.column;
5104 };
5105 var Range = function(startRow, startColumn, endRow, endColumn) {
5106 this.start = {
5107 row: startRow,
5108 column: startColumn
5109 };
5110
5111 this.end = {
5112 row: endRow,
5113 column: endColumn
5114 };
5115 };
5116
5117 (function() {
5118 this.isEqual = function(range) {
5119 return this.start.row === range.start.row &&
5120 this.end.row === range.end.row &&
5121 this.start.column === range.start.column &&
5122 this.end.column === range.end.column;
5123 };
5124 this.toString = function() {
5125 return ("Range: [" + this.start.row + "/" + this.start.column +
5126 "] -> [" + this.end.row + "/" + this.end.column + "]");
5127 };
5128
5129 this.contains = function(row, column) {
5130 return this.compare(row, column) == 0;
5131 };
5132 this.compareRange = function(range) {
5133 var cmp,
5134 end = range.end,
5135 start = range.start;
5136
5137 cmp = this.compare(end.row, end.column);
5138 if (cmp == 1) {
5139 cmp = this.compare(start.row, start.column);
5140 if (cmp == 1) {
5141 return 2;
5142 } else if (cmp == 0) {
5143 return 1;
5144 } else {
5145 return 0;
5146 }
5147 } else if (cmp == -1) {
5148 return -2;
5149 } else {
5150 cmp = this.compare(start.row, start.column);
5151 if (cmp == -1) {
5152 return -1;
5153 } else if (cmp == 1) {
5154 return 42;
5155 } else {
5156 return 0;
5157 }
5158 }
5159 };
5160 this.comparePoint = function(p) {
5161 return this.compare(p.row, p.column);
5162 };
5163 this.containsRange = function(range) {
5164 return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
5165 };
5166 this.intersects = function(range) {
5167 var cmp = this.compareRange(range);
5168 return (cmp == -1 || cmp == 0 || cmp == 1);
5169 };
5170 this.isEnd = function(row, column) {
5171 return this.end.row == row && this.end.column == column;
5172 };
5173 this.isStart = function(row, column) {
5174 return this.start.row == row && this.start.column == column;
5175 };
5176 this.setStart = function(row, column) {
5177 if (typeof row == "object") {
5178 this.start.column = row.column;
5179 this.start.row = row.row;
5180 } else {
5181 this.start.row = row;
5182 this.start.column = column;
5183 }
5184 };
5185 this.setEnd = function(row, column) {
5186 if (typeof row == "object") {
5187 this.end.column = row.column;
5188 this.end.row = row.row;
5189 } else {
5190 this.end.row = row;
5191 this.end.column = column;
5192 }
5193 };
5194 this.inside = function(row, column) {
5195 if (this.compare(row, column) == 0) {
5196 if (this.isEnd(row, column) || this.isStart(row, column)) {
5197 return false;
5198 } else {
5199 return true;
5200 }
5201 }
5202 return false;
5203 };
5204 this.insideStart = function(row, column) {
5205 if (this.compare(row, column) == 0) {
5206 if (this.isEnd(row, column)) {
5207 return false;
5208 } else {
5209 return true;
5210 }
5211 }
5212 return false;
5213 };
5214 this.insideEnd = function(row, column) {
5215 if (this.compare(row, column) == 0) {
5216 if (this.isStart(row, column)) {
5217 return false;
5218 } else {
5219 return true;
5220 }
5221 }
5222 return false;
5223 };
5224 this.compare = function(row, column) {
5225 if (!this.isMultiLine()) {
5226 if (row === this.start.row) {
5227 return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
5228 }
5229 }
5230
5231 if (row < this.start.row)
5232 return -1;
5233
5234 if (row > this.end.row)
5235 return 1;
5236
5237 if (this.start.row === row)
5238 return column >= this.start.column ? 0 : -1;
5239
5240 if (this.end.row === row)
5241 return column <= this.end.column ? 0 : 1;
5242
5243 return 0;
5244 };
5245 this.compareStart = function(row, column) {
5246 if (this.start.row == row && this.start.column == column) {
5247 return -1;
5248 } else {
5249 return this.compare(row, column);
5250 }
5251 };
5252 this.compareEnd = function(row, column) {
5253 if (this.end.row == row && this.end.column == column) {
5254 return 1;
5255 } else {
5256 return this.compare(row, column);
5257 }
5258 };
5259 this.compareInside = function(row, column) {
5260 if (this.end.row == row && this.end.column == column) {
5261 return 1;
5262 } else if (this.start.row == row && this.start.column == column) {
5263 return -1;
5264 } else {
5265 return this.compare(row, column);
5266 }
5267 };
5268 this.clipRows = function(firstRow, lastRow) {
5269 if (this.end.row > lastRow)
5270 var end = {row: lastRow + 1, column: 0};
5271 else if (this.end.row < firstRow)
5272 var end = {row: firstRow, column: 0};
5273
5274 if (this.start.row > lastRow)
5275 var start = {row: lastRow + 1, column: 0};
5276 else if (this.start.row < firstRow)
5277 var start = {row: firstRow, column: 0};
5278
5279 return Range.fromPoints(start || this.start, end || this.end);
5280 };
5281 this.extend = function(row, column) {
5282 var cmp = this.compare(row, column);
5283
5284 if (cmp == 0)
5285 return this;
5286 else if (cmp == -1)
5287 var start = {row: row, column: column};
5288 else
5289 var end = {row: row, column: column};
5290
5291 return Range.fromPoints(start || this.start, end || this.end);
5292 };
5293
5294 this.isEmpty = function() {
5295 return (this.start.row === this.end.row && this.start.column === this.end.column);
5296 };
5297 this.isMultiLine = function() {
5298 return (this.start.row !== this.end.row);
5299 };
5300 this.clone = function() {
5301 return Range.fromPoints(this.start, this.end);
5302 };
5303 this.collapseRows = function() {
5304 if (this.end.column == 0)
5305 return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0);
5306 else
5307 return new Range(this.start.row, 0, this.end.row, 0);
5308 };
5309 this.toScreenRange = function(session) {
5310 var screenPosStart = session.documentToScreenPosition(this.start);
5311 var screenPosEnd = session.documentToScreenPosition(this.end);
5312
5313 return new Range(
5314 screenPosStart.row, screenPosStart.column,
5315 screenPosEnd.row, screenPosEnd.column
5316 );
5317 };
5318 this.moveBy = function(row, column) {
5319 this.start.row += row;
5320 this.start.column += column;
5321 this.end.row += row;
5322 this.end.column += column;
5323 };
5324
5325 }).call(Range.prototype);
5326 Range.fromPoints = function(start, end) {
5327 return new Range(start.row, start.column, end.row, end.column);
5328 };
5329 Range.comparePoints = comparePoints;
5330
5331 Range.comparePoints = function(p1, p2) {
5332 return p1.row - p2.row || p1.column - p2.column;
5333 };
5334
5335
5336 exports.Range = Range;
5337 });
5338
5339 ace.define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"], function(acequire, exports, module) {
5340
5341 var oop = acequire("./lib/oop");
5342 var lang = acequire("./lib/lang");
5343 var EventEmitter = acequire("./lib/event_emitter").EventEmitter;
5344 var Range = acequire("./range").Range;
5345 var Selection = function(session) {
5346 this.session = session;
5347 this.doc = session.getDocument();
5348
5349 this.clearSelection();
5350 this.lead = this.selectionLead = this.doc.createAnchor(0, 0);
5351 this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0);
5352
5353 var self = this;
5354 this.lead.on("change", function(e) {
5355 self._emit("changeCursor");
5356 if (!self.$isEmpty)
5357 self._emit("changeSelection");
5358 if (!self.$keepDesiredColumnOnChange && e.old.column != e.value.column)
5359 self.$desiredColumn = null;
5360 });
5361
5362 this.selectionAnchor.on("change", function() {
5363 if (!self.$isEmpty)
5364 self._emit("changeSelection");
5365 });
5366 };
5367
5368 (function() {
5369
5370 oop.implement(this, EventEmitter);
5371 this.isEmpty = function() {
5372 return (this.$isEmpty || (
5373 this.anchor.row == this.lead.row &&
5374 this.anchor.column == this.lead.column
5375 ));
5376 };
5377 this.isMultiLine = function() {
5378 if (this.isEmpty()) {
5379 return false;
5380 }
5381
5382 return this.getRange().isMultiLine();
5383 };
5384 this.getCursor = function() {
5385 return this.lead.getPosition();
5386 };
5387 this.setSelectionAnchor = function(row, column) {
5388 this.anchor.setPosition(row, column);
5389
5390 if (this.$isEmpty) {
5391 this.$isEmpty = false;
5392 this._emit("changeSelection");
5393 }
5394 };
5395 this.getSelectionAnchor = function() {
5396 if (this.$isEmpty)
5397 return this.getSelectionLead();
5398 else
5399 return this.anchor.getPosition();
5400 };
5401 this.getSelectionLead = function() {
5402 return this.lead.getPosition();
5403 };
5404 this.shiftSelection = function(columns) {
5405 if (this.$isEmpty) {
5406 this.moveCursorTo(this.lead.row, this.lead.column + columns);
5407 return;
5408 }
5409
5410 var anchor = this.getSelectionAnchor();
5411 var lead = this.getSelectionLead();
5412
5413 var isBackwards = this.isBackwards();
5414
5415 if (!isBackwards || anchor.column !== 0)
5416 this.setSelectionAnchor(anchor.row, anchor.column + columns);
5417
5418 if (isBackwards || lead.column !== 0) {
5419 this.$moveSelection(function() {
5420 this.moveCursorTo(lead.row, lead.column + columns);
5421 });
5422 }
5423 };
5424 this.isBackwards = function() {
5425 var anchor = this.anchor;
5426 var lead = this.lead;
5427 return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column));
5428 };
5429 this.getRange = function() {
5430 var anchor = this.anchor;
5431 var lead = this.lead;
5432
5433 if (this.isEmpty())
5434 return Range.fromPoints(lead, lead);
5435
5436 if (this.isBackwards()) {
5437 return Range.fromPoints(lead, anchor);
5438 }
5439 else {
5440 return Range.fromPoints(anchor, lead);
5441 }
5442 };
5443 this.clearSelection = function() {
5444 if (!this.$isEmpty) {
5445 this.$isEmpty = true;
5446 this._emit("changeSelection");
5447 }
5448 };
5449 this.selectAll = function() {
5450 var lastRow = this.doc.getLength() - 1;
5451 this.setSelectionAnchor(0, 0);
5452 this.moveCursorTo(lastRow, this.doc.getLine(lastRow).length);
5453 };
5454 this.setRange =
5455 this.setSelectionRange = function(range, reverse) {
5456 if (reverse) {
5457 this.setSelectionAnchor(range.end.row, range.end.column);
5458 this.selectTo(range.start.row, range.start.column);
5459 } else {
5460 this.setSelectionAnchor(range.start.row, range.start.column);
5461 this.selectTo(range.end.row, range.end.column);
5462 }
5463 if (this.getRange().isEmpty())
5464 this.$isEmpty = true;
5465 this.$desiredColumn = null;
5466 };
5467
5468 this.$moveSelection = function(mover) {
5469 var lead = this.lead;
5470 if (this.$isEmpty)
5471 this.setSelectionAnchor(lead.row, lead.column);
5472
5473 mover.call(this);
5474 };
5475 this.selectTo = function(row, column) {
5476 this.$moveSelection(function() {
5477 this.moveCursorTo(row, column);
5478 });
5479 };
5480 this.selectToPosition = function(pos) {
5481 this.$moveSelection(function() {
5482 this.moveCursorToPosition(pos);
5483 });
5484 };
5485 this.moveTo = function(row, column) {
5486 this.clearSelection();
5487 this.moveCursorTo(row, column);
5488 };
5489 this.moveToPosition = function(pos) {
5490 this.clearSelection();
5491 this.moveCursorToPosition(pos);
5492 };
5493 this.selectUp = function() {
5494 this.$moveSelection(this.moveCursorUp);
5495 };
5496 this.selectDown = function() {
5497 this.$moveSelection(this.moveCursorDown);
5498 };
5499 this.selectRight = function() {
5500 this.$moveSelection(this.moveCursorRight);
5501 };
5502 this.selectLeft = function() {
5503 this.$moveSelection(this.moveCursorLeft);
5504 };
5505 this.selectLineStart = function() {
5506 this.$moveSelection(this.moveCursorLineStart);
5507 };
5508 this.selectLineEnd = function() {
5509 this.$moveSelection(this.moveCursorLineEnd);
5510 };
5511 this.selectFileEnd = function() {
5512 this.$moveSelection(this.moveCursorFileEnd);
5513 };
5514 this.selectFileStart = function() {
5515 this.$moveSelection(this.moveCursorFileStart);
5516 };
5517 this.selectWordRight = function() {
5518 this.$moveSelection(this.moveCursorWordRight);
5519 };
5520 this.selectWordLeft = function() {
5521 this.$moveSelection(this.moveCursorWordLeft);
5522 };
5523 this.getWordRange = function(row, column) {
5524 if (typeof column == "undefined") {
5525 var cursor = row || this.lead;
5526 row = cursor.row;
5527 column = cursor.column;
5528 }
5529 return this.session.getWordRange(row, column);
5530 };
5531 this.selectWord = function() {
5532 this.setSelectionRange(this.getWordRange());
5533 };
5534 this.selectAWord = function() {
5535 var cursor = this.getCursor();
5536 var range = this.session.getAWordRange(cursor.row, cursor.column);
5537 this.setSelectionRange(range);
5538 };
5539
5540 this.getLineRange = function(row, excludeLastChar) {
5541 var rowStart = typeof row == "number" ? row : this.lead.row;
5542 var rowEnd;
5543
5544 var foldLine = this.session.getFoldLine(rowStart);
5545 if (foldLine) {
5546 rowStart = foldLine.start.row;
5547 rowEnd = foldLine.end.row;
5548 } else {
5549 rowEnd = rowStart;
5550 }
5551 if (excludeLastChar === true)
5552 return new Range(rowStart, 0, rowEnd, this.session.getLine(rowEnd).length);
5553 else
5554 return new Range(rowStart, 0, rowEnd + 1, 0);
5555 };
5556 this.selectLine = function() {
5557 this.setSelectionRange(this.getLineRange());
5558 };
5559 this.moveCursorUp = function() {
5560 this.moveCursorBy(-1, 0);
5561 };
5562 this.moveCursorDown = function() {
5563 this.moveCursorBy(1, 0);
5564 };
5565 this.wouldMoveIntoSoftTab = function(cursor, tabSize, direction) {
5566 var start = cursor.column;
5567 var end = cursor.column + tabSize;
5568
5569 if (direction < 0) {
5570 start = cursor.column - tabSize;
5571 end = cursor.column;
5572 }
5573 return this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(start, end).split(" ").length-1 == tabSize;
5574 };
5575 this.moveCursorLeft = function() {
5576 var cursor = this.lead.getPosition(),
5577 fold;
5578
5579 if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) {
5580 this.moveCursorTo(fold.start.row, fold.start.column);
5581 } else if (cursor.column === 0) {
5582 if (cursor.row > 0) {
5583 this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length);
5584 }
5585 }
5586 else {
5587 var tabSize = this.session.getTabSize();
5588 if (this.wouldMoveIntoSoftTab(cursor, tabSize, -1) && !this.session.getNavigateWithinSoftTabs()) {
5589 this.moveCursorBy(0, -tabSize);
5590 } else {
5591 this.moveCursorBy(0, -1);
5592 }
5593 }
5594 };
5595 this.moveCursorRight = function() {
5596 var cursor = this.lead.getPosition(),
5597 fold;
5598 if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) {
5599 this.moveCursorTo(fold.end.row, fold.end.column);
5600 }
5601 else if (this.lead.column == this.doc.getLine(this.lead.row).length) {
5602 if (this.lead.row < this.doc.getLength() - 1) {
5603 this.moveCursorTo(this.lead.row + 1, 0);
5604 }
5605 }
5606 else {
5607 var tabSize = this.session.getTabSize();
5608 var cursor = this.lead;
5609 if (this.wouldMoveIntoSoftTab(cursor, tabSize, 1) && !this.session.getNavigateWithinSoftTabs()) {
5610 this.moveCursorBy(0, tabSize);
5611 } else {
5612 this.moveCursorBy(0, 1);
5613 }
5614 }
5615 };
5616 this.moveCursorLineStart = function() {
5617 var row = this.lead.row;
5618 var column = this.lead.column;
5619 var screenRow = this.session.documentToScreenRow(row, column);
5620 var firstColumnPosition = this.session.screenToDocumentPosition(screenRow, 0);
5621 var beforeCursor = this.session.getDisplayLine(
5622 row, null, firstColumnPosition.row,
5623 firstColumnPosition.column
5624 );
5625
5626 var leadingSpace = beforeCursor.match(/^\s*/);
5627 if (leadingSpace[0].length != column && !this.session.$useEmacsStyleLineStart)
5628 firstColumnPosition.column += leadingSpace[0].length;
5629 this.moveCursorToPosition(firstColumnPosition);
5630 };
5631 this.moveCursorLineEnd = function() {
5632 var lead = this.lead;
5633 var lineEnd = this.session.getDocumentLastRowColumnPosition(lead.row, lead.column);
5634 if (this.lead.column == lineEnd.column) {
5635 var line = this.session.getLine(lineEnd.row);
5636 if (lineEnd.column == line.length) {
5637 var textEnd = line.search(/\s+$/);
5638 if (textEnd > 0)
5639 lineEnd.column = textEnd;
5640 }
5641 }
5642
5643 this.moveCursorTo(lineEnd.row, lineEnd.column);
5644 };
5645 this.moveCursorFileEnd = function() {
5646 var row = this.doc.getLength() - 1;
5647 var column = this.doc.getLine(row).length;
5648 this.moveCursorTo(row, column);
5649 };
5650 this.moveCursorFileStart = function() {
5651 this.moveCursorTo(0, 0);
5652 };
5653 this.moveCursorLongWordRight = function() {
5654 var row = this.lead.row;
5655 var column = this.lead.column;
5656 var line = this.doc.getLine(row);
5657 var rightOfCursor = line.substring(column);
5658 this.session.nonTokenRe.lastIndex = 0;
5659 this.session.tokenRe.lastIndex = 0;
5660 var fold = this.session.getFoldAt(row, column, 1);
5661 if (fold) {
5662 this.moveCursorTo(fold.end.row, fold.end.column);
5663 return;
5664 }
5665 if (this.session.nonTokenRe.exec(rightOfCursor)) {
5666 column += this.session.nonTokenRe.lastIndex;
5667 this.session.nonTokenRe.lastIndex = 0;
5668 rightOfCursor = line.substring(column);
5669 }
5670 if (column >= line.length) {
5671 this.moveCursorTo(row, line.length);
5672 this.moveCursorRight();
5673 if (row < this.doc.getLength() - 1)
5674 this.moveCursorWordRight();
5675 return;
5676 }
5677 if (this.session.tokenRe.exec(rightOfCursor)) {
5678 column += this.session.tokenRe.lastIndex;
5679 this.session.tokenRe.lastIndex = 0;
5680 }
5681
5682 this.moveCursorTo(row, column);
5683 };
5684 this.moveCursorLongWordLeft = function() {
5685 var row = this.lead.row;
5686 var column = this.lead.column;
5687 var fold;
5688 if (fold = this.session.getFoldAt(row, column, -1)) {
5689 this.moveCursorTo(fold.start.row, fold.start.column);
5690 return;
5691 }
5692
5693 var str = this.session.getFoldStringAt(row, column, -1);
5694 if (str == null) {
5695 str = this.doc.getLine(row).substring(0, column);
5696 }
5697
5698 var leftOfCursor = lang.stringReverse(str);
5699 this.session.nonTokenRe.lastIndex = 0;
5700 this.session.tokenRe.lastIndex = 0;
5701 if (this.session.nonTokenRe.exec(leftOfCursor)) {
5702 column -= this.session.nonTokenRe.lastIndex;
5703 leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
5704 this.session.nonTokenRe.lastIndex = 0;
5705 }
5706 if (column <= 0) {
5707 this.moveCursorTo(row, 0);
5708 this.moveCursorLeft();
5709 if (row > 0)
5710 this.moveCursorWordLeft();
5711 return;
5712 }
5713 if (this.session.tokenRe.exec(leftOfCursor)) {
5714 column -= this.session.tokenRe.lastIndex;
5715 this.session.tokenRe.lastIndex = 0;
5716 }
5717
5718 this.moveCursorTo(row, column);
5719 };
5720
5721 this.$shortWordEndIndex = function(rightOfCursor) {
5722 var index = 0, ch;
5723 var whitespaceRe = /\s/;
5724 var tokenRe = this.session.tokenRe;
5725
5726 tokenRe.lastIndex = 0;
5727 if (this.session.tokenRe.exec(rightOfCursor)) {
5728 index = this.session.tokenRe.lastIndex;
5729 } else {
5730 while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
5731 index ++;
5732
5733 if (index < 1) {
5734 tokenRe.lastIndex = 0;
5735 while ((ch = rightOfCursor[index]) && !tokenRe.test(ch)) {
5736 tokenRe.lastIndex = 0;
5737 index ++;
5738 if (whitespaceRe.test(ch)) {
5739 if (index > 2) {
5740 index--;
5741 break;
5742 } else {
5743 while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
5744 index ++;
5745 if (index > 2)
5746 break;
5747 }
5748 }
5749 }
5750 }
5751 }
5752 tokenRe.lastIndex = 0;
5753
5754 return index;
5755 };
5756
5757 this.moveCursorShortWordRight = function() {
5758 var row = this.lead.row;
5759 var column = this.lead.column;
5760 var line = this.doc.getLine(row);
5761 var rightOfCursor = line.substring(column);
5762
5763 var fold = this.session.getFoldAt(row, column, 1);
5764 if (fold)
5765 return this.moveCursorTo(fold.end.row, fold.end.column);
5766
5767 if (column == line.length) {
5768 var l = this.doc.getLength();
5769 do {
5770 row++;
5771 rightOfCursor = this.doc.getLine(row);
5772 } while (row < l && /^\s*$/.test(rightOfCursor));
5773
5774 if (!/^\s+/.test(rightOfCursor))
5775 rightOfCursor = "";
5776 column = 0;
5777 }
5778
5779 var index = this.$shortWordEndIndex(rightOfCursor);
5780
5781 this.moveCursorTo(row, column + index);
5782 };
5783
5784 this.moveCursorShortWordLeft = function() {
5785 var row = this.lead.row;
5786 var column = this.lead.column;
5787
5788 var fold;
5789 if (fold = this.session.getFoldAt(row, column, -1))
5790 return this.moveCursorTo(fold.start.row, fold.start.column);
5791
5792 var line = this.session.getLine(row).substring(0, column);
5793 if (column === 0) {
5794 do {
5795 row--;
5796 line = this.doc.getLine(row);
5797 } while (row > 0 && /^\s*$/.test(line));
5798
5799 column = line.length;
5800 if (!/\s+$/.test(line))
5801 line = "";
5802 }
5803
5804 var leftOfCursor = lang.stringReverse(line);
5805 var index = this.$shortWordEndIndex(leftOfCursor);
5806
5807 return this.moveCursorTo(row, column - index);
5808 };
5809
5810 this.moveCursorWordRight = function() {
5811 if (this.session.$selectLongWords)
5812 this.moveCursorLongWordRight();
5813 else
5814 this.moveCursorShortWordRight();
5815 };
5816
5817 this.moveCursorWordLeft = function() {
5818 if (this.session.$selectLongWords)
5819 this.moveCursorLongWordLeft();
5820 else
5821 this.moveCursorShortWordLeft();
5822 };
5823 this.moveCursorBy = function(rows, chars) {
5824 var screenPos = this.session.documentToScreenPosition(
5825 this.lead.row,
5826 this.lead.column
5827 );
5828
5829 var offsetX;
5830
5831 if (chars === 0) {
5832 if (rows !== 0) {
5833 if (this.session.$bidiHandler.isBidiRow(screenPos.row, this.lead.row)) {
5834 offsetX = this.session.$bidiHandler.getPosLeft(screenPos.column);
5835 screenPos.column = Math.round(offsetX / this.session.$bidiHandler.charWidths[0]);
5836 } else {
5837 offsetX = screenPos.column * this.session.$bidiHandler.charWidths[0];
5838 }
5839 }
5840
5841 if (this.$desiredColumn)
5842 screenPos.column = this.$desiredColumn;
5843 else
5844 this.$desiredColumn = screenPos.column;
5845 }
5846
5847 var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column, offsetX);
5848
5849 if (rows !== 0 && chars === 0 && docPos.row === this.lead.row && docPos.column === this.lead.column) {
5850 if (this.session.lineWidgets && this.session.lineWidgets[docPos.row]) {
5851 if (docPos.row > 0 || rows > 0)
5852 docPos.row++;
5853 }
5854 }
5855 this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
5856 };
5857 this.moveCursorToPosition = function(position) {
5858 this.moveCursorTo(position.row, position.column);
5859 };
5860 this.moveCursorTo = function(row, column, keepDesiredColumn) {
5861 var fold = this.session.getFoldAt(row, column, 1);
5862 if (fold) {
5863 row = fold.start.row;
5864 column = fold.start.column;
5865 }
5866
5867 this.$keepDesiredColumnOnChange = true;
5868 var line = this.session.getLine(row);
5869 if (/[\uDC00-\uDFFF]/.test(line.charAt(column)) && line.charAt(column - 1)) {
5870 if (this.lead.row == row && this.lead.column == column + 1)
5871 column = column - 1;
5872 else
5873 column = column + 1;
5874 }
5875 this.lead.setPosition(row, column);
5876 this.$keepDesiredColumnOnChange = false;
5877
5878 if (!keepDesiredColumn)
5879 this.$desiredColumn = null;
5880 };
5881 this.moveCursorToScreen = function(row, column, keepDesiredColumn) {
5882 var pos = this.session.screenToDocumentPosition(row, column);
5883 this.moveCursorTo(pos.row, pos.column, keepDesiredColumn);
5884 };
5885 this.detach = function() {
5886 this.lead.detach();
5887 this.anchor.detach();
5888 this.session = this.doc = null;
5889 };
5890
5891 this.fromOrientedRange = function(range) {
5892 this.setSelectionRange(range, range.cursor == range.start);
5893 this.$desiredColumn = range.desiredColumn || this.$desiredColumn;
5894 };
5895
5896 this.toOrientedRange = function(range) {
5897 var r = this.getRange();
5898 if (range) {
5899 range.start.column = r.start.column;
5900 range.start.row = r.start.row;
5901 range.end.column = r.end.column;
5902 range.end.row = r.end.row;
5903 } else {
5904 range = r;
5905 }
5906
5907 range.cursor = this.isBackwards() ? range.start : range.end;
5908 range.desiredColumn = this.$desiredColumn;
5909 return range;
5910 };
5911 this.getRangeOfMovements = function(func) {
5912 var start = this.getCursor();
5913 try {
5914 func(this);
5915 var end = this.getCursor();
5916 return Range.fromPoints(start,end);
5917 } catch(e) {
5918 return Range.fromPoints(start,start);
5919 } finally {
5920 this.moveCursorToPosition(start);
5921 }
5922 };
5923
5924 this.toJSON = function() {
5925 if (this.rangeCount) {
5926 var data = this.ranges.map(function(r) {
5927 var r1 = r.clone();
5928 r1.isBackwards = r.cursor == r.start;
5929 return r1;
5930 });
5931 } else {
5932 var data = this.getRange();
5933 data.isBackwards = this.isBackwards();
5934 }
5935 return data;
5936 };
5937
5938 this.fromJSON = function(data) {
5939 if (data.start == undefined) {
5940 if (this.rangeList) {
5941 this.toSingleRange(data[0]);
5942 for (var i = data.length; i--; ) {
5943 var r = Range.fromPoints(data[i].start, data[i].end);
5944 if (data[i].isBackwards)
5945 r.cursor = r.start;
5946 this.addRange(r, true);
5947 }
5948 return;
5949 } else
5950 data = data[0];
5951 }
5952 if (this.rangeList)
5953 this.toSingleRange(data);
5954 this.setSelectionRange(data, data.isBackwards);
5955 };
5956
5957 this.isEqual = function(data) {
5958 if ((data.length || this.rangeCount) && data.length != this.rangeCount)
5959 return false;
5960 if (!data.length || !this.ranges)
5961 return this.getRange().isEqual(data);
5962
5963 for (var i = this.ranges.length; i--; ) {
5964 if (!this.ranges[i].isEqual(data[i]))
5965 return false;
5966 }
5967 return true;
5968 };
5969
5970 }).call(Selection.prototype);
5971
5972 exports.Selection = Selection;
5973 });
5974
5975 ace.define("ace/tokenizer",["require","exports","module","ace/config"], function(acequire, exports, module) {
5976
5977 var config = acequire("./config");
5978 var MAX_TOKEN_COUNT = 2000;
5979 var Tokenizer = function(rules) {
5980 this.states = rules;
5981
5982 this.regExps = {};
5983 this.matchMappings = {};
5984 for (var key in this.states) {
5985 var state = this.states[key];
5986 var ruleRegExps = [];
5987 var matchTotal = 0;
5988 var mapping = this.matchMappings[key] = {defaultToken: "text"};
5989 var flag = "g";
5990
5991 var splitterRurles = [];
5992 for (var i = 0; i < state.length; i++) {
5993 var rule = state[i];
5994 if (rule.defaultToken)
5995 mapping.defaultToken = rule.defaultToken;
5996 if (rule.caseInsensitive)
5997 flag = "gi";
5998 if (rule.regex == null)
5999 continue;
6000
6001 if (rule.regex instanceof RegExp)
6002 rule.regex = rule.regex.toString().slice(1, -1);
6003 var adjustedregex = rule.regex;
6004 var matchcount = new RegExp("(?:(" + adjustedregex + ")|(.))").exec("a").length - 2;
6005 if (Array.isArray(rule.token)) {
6006 if (rule.token.length == 1 || matchcount == 1) {
6007 rule.token = rule.token[0];
6008 } else if (matchcount - 1 != rule.token.length) {
6009 this.reportError("number of classes and regexp groups doesn't match", {
6010 rule: rule,
6011 groupCount: matchcount - 1
6012 });
6013 rule.token = rule.token[0];
6014 } else {
6015 rule.tokenArray = rule.token;
6016 rule.token = null;
6017 rule.onMatch = this.$arrayTokens;
6018 }
6019 } else if (typeof rule.token == "function" && !rule.onMatch) {
6020 if (matchcount > 1)
6021 rule.onMatch = this.$applyToken;
6022 else
6023 rule.onMatch = rule.token;
6024 }
6025
6026 if (matchcount > 1) {
6027 if (/\\\d/.test(rule.regex)) {
6028 adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function(match, digit) {
6029 return "\\" + (parseInt(digit, 10) + matchTotal + 1);
6030 });
6031 } else {
6032 matchcount = 1;
6033 adjustedregex = this.removeCapturingGroups(rule.regex);
6034 }
6035 if (!rule.splitRegex && typeof rule.token != "string")
6036 splitterRurles.push(rule); // flag will be known only at the very end
6037 }
6038
6039 mapping[matchTotal] = i;
6040 matchTotal += matchcount;
6041
6042 ruleRegExps.push(adjustedregex);
6043 if (!rule.onMatch)
6044 rule.onMatch = null;
6045 }
6046
6047 if (!ruleRegExps.length) {
6048 mapping[0] = 0;
6049 ruleRegExps.push("$");
6050 }
6051
6052 splitterRurles.forEach(function(rule) {
6053 rule.splitRegex = this.createSplitterRegexp(rule.regex, flag);
6054 }, this);
6055
6056 this.regExps[key] = new RegExp("(" + ruleRegExps.join(")|(") + ")|($)", flag);
6057 }
6058 };
6059
6060 (function() {
6061 this.$setMaxTokenCount = function(m) {
6062 MAX_TOKEN_COUNT = m | 0;
6063 };
6064
6065 this.$applyToken = function(str) {
6066 var values = this.splitRegex.exec(str).slice(1);
6067 var types = this.token.apply(this, values);
6068 if (typeof types === "string")
6069 return [{type: types, value: str}];
6070
6071 var tokens = [];
6072 for (var i = 0, l = types.length; i < l; i++) {
6073 if (values[i])
6074 tokens[tokens.length] = {
6075 type: types[i],
6076 value: values[i]
6077 };
6078 }
6079 return tokens;
6080 };
6081
6082 this.$arrayTokens = function(str) {
6083 if (!str)
6084 return [];
6085 var values = this.splitRegex.exec(str);
6086 if (!values)
6087 return "text";
6088 var tokens = [];
6089 var types = this.tokenArray;
6090 for (var i = 0, l = types.length; i < l; i++) {
6091 if (values[i + 1])
6092 tokens[tokens.length] = {
6093 type: types[i],
6094 value: values[i + 1]
6095 };
6096 }
6097 return tokens;
6098 };
6099
6100 this.removeCapturingGroups = function(src) {
6101 var r = src.replace(
6102 /\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g,
6103 function(x, y) {return y ? "(?:" : x;}
6104 );
6105 return r;
6106 };
6107
6108 this.createSplitterRegexp = function(src, flag) {
6109 if (src.indexOf("(?=") != -1) {
6110 var stack = 0;
6111 var inChClass = false;
6112 var lastCapture = {};
6113 src.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g, function(
6114 m, esc, parenOpen, parenClose, square, index
6115 ) {
6116 if (inChClass) {
6117 inChClass = square != "]";
6118 } else if (square) {
6119 inChClass = true;
6120 } else if (parenClose) {
6121 if (stack == lastCapture.stack) {
6122 lastCapture.end = index+1;
6123 lastCapture.stack = -1;
6124 }
6125 stack--;
6126 } else if (parenOpen) {
6127 stack++;
6128 if (parenOpen.length != 1) {
6129 lastCapture.stack = stack;
6130 lastCapture.start = index;
6131 }
6132 }
6133 return m;
6134 });
6135
6136 if (lastCapture.end != null && /^\)*$/.test(src.substr(lastCapture.end)))
6137 src = src.substring(0, lastCapture.start) + src.substr(lastCapture.end);
6138 }
6139 if (src.charAt(0) != "^") src = "^" + src;
6140 if (src.charAt(src.length - 1) != "$") src += "$";
6141
6142 return new RegExp(src, (flag||"").replace("g", ""));
6143 };
6144 this.getLineTokens = function(line, startState) {
6145 if (startState && typeof startState != "string") {
6146 var stack = startState.slice(0);
6147 startState = stack[0];
6148 if (startState === "#tmp") {
6149 stack.shift();
6150 startState = stack.shift();
6151 }
6152 } else
6153 var stack = [];
6154
6155 var currentState = startState || "start";
6156 var state = this.states[currentState];
6157 if (!state) {
6158 currentState = "start";
6159 state = this.states[currentState];
6160 }
6161 var mapping = this.matchMappings[currentState];
6162 var re = this.regExps[currentState];
6163 re.lastIndex = 0;
6164
6165 var match, tokens = [];
6166 var lastIndex = 0;
6167 var matchAttempts = 0;
6168
6169 var token = {type: null, value: ""};
6170
6171 while (match = re.exec(line)) {
6172 var type = mapping.defaultToken;
6173 var rule = null;
6174 var value = match[0];
6175 var index = re.lastIndex;
6176
6177 if (index - value.length > lastIndex) {
6178 var skipped = line.substring(lastIndex, index - value.length);
6179 if (token.type == type) {
6180 token.value += skipped;
6181 } else {
6182 if (token.type)
6183 tokens.push(token);
6184 token = {type: type, value: skipped};
6185 }
6186 }
6187
6188 for (var i = 0; i < match.length-2; i++) {
6189 if (match[i + 1] === undefined)
6190 continue;
6191
6192 rule = state[mapping[i]];
6193
6194 if (rule.onMatch)
6195 type = rule.onMatch(value, currentState, stack, line);
6196 else
6197 type = rule.token;
6198
6199 if (rule.next) {
6200 if (typeof rule.next == "string") {
6201 currentState = rule.next;
6202 } else {
6203 currentState = rule.next(currentState, stack);
6204 }
6205
6206 state = this.states[currentState];
6207 if (!state) {
6208 this.reportError("state doesn't exist", currentState);
6209 currentState = "start";
6210 state = this.states[currentState];
6211 }
6212 mapping = this.matchMappings[currentState];
6213 lastIndex = index;
6214 re = this.regExps[currentState];
6215 re.lastIndex = index;
6216 }
6217 if (rule.consumeLineEnd)
6218 lastIndex = index;
6219 break;
6220 }
6221
6222 if (value) {
6223 if (typeof type === "string") {
6224 if ((!rule || rule.merge !== false) && token.type === type) {
6225 token.value += value;
6226 } else {
6227 if (token.type)
6228 tokens.push(token);
6229 token = {type: type, value: value};
6230 }
6231 } else if (type) {
6232 if (token.type)
6233 tokens.push(token);
6234 token = {type: null, value: ""};
6235 for (var i = 0; i < type.length; i++)
6236 tokens.push(type[i]);
6237 }
6238 }
6239
6240 if (lastIndex == line.length)
6241 break;
6242
6243 lastIndex = index;
6244
6245 if (matchAttempts++ > MAX_TOKEN_COUNT) {
6246 if (matchAttempts > 2 * line.length) {
6247 this.reportError("infinite loop with in ace tokenizer", {
6248 startState: startState,
6249 line: line
6250 });
6251 }
6252 while (lastIndex < line.length) {
6253 if (token.type)
6254 tokens.push(token);
6255 token = {
6256 value: line.substring(lastIndex, lastIndex += 2000),
6257 type: "overflow"
6258 };
6259 }
6260 currentState = "start";
6261 stack = [];
6262 break;
6263 }
6264 }
6265
6266 if (token.type)
6267 tokens.push(token);
6268
6269 if (stack.length > 1) {
6270 if (stack[0] !== currentState)
6271 stack.unshift("#tmp", currentState);
6272 }
6273 return {
6274 tokens : tokens,
6275 state : stack.length ? stack : currentState
6276 };
6277 };
6278
6279 this.reportError = config.reportError;
6280
6281 }).call(Tokenizer.prototype);
6282
6283 exports.Tokenizer = Tokenizer;
6284 });
6285
6286 ace.define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"], function(acequire, exports, module) {
6287
6288 var lang = acequire("../lib/lang");
6289
6290 var TextHighlightRules = function() {
6291
6292 this.$rules = {
6293 "start" : [{
6294 token : "empty_line",
6295 regex : '^$'
6296 }, {
6297 defaultToken : "text"
6298 }]
6299 };
6300 };
6301
6302 (function() {
6303
6304 this.addRules = function(rules, prefix) {
6305 if (!prefix) {
6306 for (var key in rules)
6307 this.$rules[key] = rules[key];
6308 return;
6309 }
6310 for (var key in rules) {
6311 var state = rules[key];
6312 for (var i = 0; i < state.length; i++) {
6313 var rule = state[i];
6314 if (rule.next || rule.onMatch) {
6315 if (typeof rule.next == "string") {
6316 if (rule.next.indexOf(prefix) !== 0)
6317 rule.next = prefix + rule.next;
6318 }
6319 if (rule.nextState && rule.nextState.indexOf(prefix) !== 0)
6320 rule.nextState = prefix + rule.nextState;
6321 }
6322 }
6323 this.$rules[prefix + key] = state;
6324 }
6325 };
6326
6327 this.getRules = function() {
6328 return this.$rules;
6329 };
6330
6331 this.embedRules = function (HighlightRules, prefix, escapeRules, states, append) {
6332 var embedRules = typeof HighlightRules == "function"
6333 ? new HighlightRules().getRules()
6334 : HighlightRules;
6335 if (states) {
6336 for (var i = 0; i < states.length; i++)
6337 states[i] = prefix + states[i];
6338 } else {
6339 states = [];
6340 for (var key in embedRules)
6341 states.push(prefix + key);
6342 }
6343
6344 this.addRules(embedRules, prefix);
6345
6346 if (escapeRules) {
6347 var addRules = Array.prototype[append ? "push" : "unshift"];
6348 for (var i = 0; i < states.length; i++)
6349 addRules.apply(this.$rules[states[i]], lang.deepCopy(escapeRules));
6350 }
6351
6352 if (!this.$embeds)
6353 this.$embeds = [];
6354 this.$embeds.push(prefix);
6355 };
6356
6357 this.getEmbeds = function() {
6358 return this.$embeds;
6359 };
6360
6361 var pushState = function(currentState, stack) {
6362 if (currentState != "start" || stack.length)
6363 stack.unshift(this.nextState, currentState);
6364 return this.nextState;
6365 };
6366 var popState = function(currentState, stack) {
6367 stack.shift();
6368 return stack.shift() || "start";
6369 };
6370
6371 this.normalizeRules = function() {
6372 var id = 0;
6373 var rules = this.$rules;
6374 function processState(key) {
6375 var state = rules[key];
6376 state.processed = true;
6377 for (var i = 0; i < state.length; i++) {
6378 var rule = state[i];
6379 var toInsert = null;
6380 if (Array.isArray(rule)) {
6381 toInsert = rule;
6382 rule = {};
6383 }
6384 if (!rule.regex && rule.start) {
6385 rule.regex = rule.start;
6386 if (!rule.next)
6387 rule.next = [];
6388 rule.next.push({
6389 defaultToken: rule.token
6390 }, {
6391 token: rule.token + ".end",
6392 regex: rule.end || rule.start,
6393 next: "pop"
6394 });
6395 rule.token = rule.token + ".start";
6396 rule.push = true;
6397 }
6398 var next = rule.next || rule.push;
6399 if (next && Array.isArray(next)) {
6400 var stateName = rule.stateName;
6401 if (!stateName) {
6402 stateName = rule.token;
6403 if (typeof stateName != "string")
6404 stateName = stateName[0] || "";
6405 if (rules[stateName])
6406 stateName += id++;
6407 }
6408 rules[stateName] = next;
6409 rule.next = stateName;
6410 processState(stateName);
6411 } else if (next == "pop") {
6412 rule.next = popState;
6413 }
6414
6415 if (rule.push) {
6416 rule.nextState = rule.next || rule.push;
6417 rule.next = pushState;
6418 delete rule.push;
6419 }
6420
6421 if (rule.rules) {
6422 for (var r in rule.rules) {
6423 if (rules[r]) {
6424 if (rules[r].push)
6425 rules[r].push.apply(rules[r], rule.rules[r]);
6426 } else {
6427 rules[r] = rule.rules[r];
6428 }
6429 }
6430 }
6431 var includeName = typeof rule == "string" ? rule : rule.include;
6432 if (includeName) {
6433 if (Array.isArray(includeName))
6434 toInsert = includeName.map(function(x) { return rules[x]; });
6435 else
6436 toInsert = rules[includeName];
6437 }
6438
6439 if (toInsert) {
6440 var args = [i, 1].concat(toInsert);
6441 if (rule.noEscape)
6442 args = args.filter(function(x) {return !x.next;});
6443 state.splice.apply(state, args);
6444 i--;
6445 }
6446
6447 if (rule.keywordMap) {
6448 rule.token = this.createKeywordMapper(
6449 rule.keywordMap, rule.defaultToken || "text", rule.caseInsensitive
6450 );
6451 delete rule.defaultToken;
6452 }
6453 }
6454 }
6455 Object.keys(rules).forEach(processState, this);
6456 };
6457
6458 this.createKeywordMapper = function(map, defaultToken, ignoreCase, splitChar) {
6459 var keywords = Object.create(null);
6460 Object.keys(map).forEach(function(className) {
6461 var a = map[className];
6462 if (ignoreCase)
6463 a = a.toLowerCase();
6464 var list = a.split(splitChar || "|");
6465 for (var i = list.length; i--; )
6466 keywords[list[i]] = className;
6467 });
6468 if (Object.getPrototypeOf(keywords)) {
6469 keywords.__proto__ = null;
6470 }
6471 this.$keywordList = Object.keys(keywords);
6472 map = null;
6473 return ignoreCase
6474 ? function(value) {return keywords[value.toLowerCase()] || defaultToken; }
6475 : function(value) {return keywords[value] || defaultToken; };
6476 };
6477
6478 this.getKeywords = function() {
6479 return this.$keywords;
6480 };
6481
6482 }).call(TextHighlightRules.prototype);
6483
6484 exports.TextHighlightRules = TextHighlightRules;
6485 });
6486
6487 ace.define("ace/mode/behaviour",["require","exports","module"], function(acequire, exports, module) {
6488
6489 var Behaviour = function() {
6490 this.$behaviours = {};
6491 };
6492
6493 (function () {
6494
6495 this.add = function (name, action, callback) {
6496 switch (undefined) {
6497 case this.$behaviours:
6498 this.$behaviours = {};
6499 case this.$behaviours[name]:
6500 this.$behaviours[name] = {};
6501 }
6502 this.$behaviours[name][action] = callback;
6503 };
6504
6505 this.addBehaviours = function (behaviours) {
6506 for (var key in behaviours) {
6507 for (var action in behaviours[key]) {
6508 this.add(key, action, behaviours[key][action]);
6509 }
6510 }
6511 };
6512
6513 this.remove = function (name) {
6514 if (this.$behaviours && this.$behaviours[name]) {
6515 delete this.$behaviours[name];
6516 }
6517 };
6518
6519 this.inherit = function (mode, filter) {
6520 if (typeof mode === "function") {
6521 var behaviours = new mode().getBehaviours(filter);
6522 } else {
6523 var behaviours = mode.getBehaviours(filter);
6524 }
6525 this.addBehaviours(behaviours);
6526 };
6527
6528 this.getBehaviours = function (filter) {
6529 if (!filter) {
6530 return this.$behaviours;
6531 } else {
6532 var ret = {};
6533 for (var i = 0; i < filter.length; i++) {
6534 if (this.$behaviours[filter[i]]) {
6535 ret[filter[i]] = this.$behaviours[filter[i]];
6536 }
6537 }
6538 return ret;
6539 }
6540 };
6541
6542 }).call(Behaviour.prototype);
6543
6544 exports.Behaviour = Behaviour;
6545 });
6546
6547 ace.define("ace/token_iterator",["require","exports","module","ace/range"], function(acequire, exports, module) {
6548
6549 var Range = acequire("./range").Range;
6550 var TokenIterator = function(session, initialRow, initialColumn) {
6551 this.$session = session;
6552 this.$row = initialRow;
6553 this.$rowTokens = session.getTokens(initialRow);
6554
6555 var token = session.getTokenAt(initialRow, initialColumn);
6556 this.$tokenIndex = token ? token.index : -1;
6557 };
6558
6559 (function() {
6560 this.stepBackward = function() {
6561 this.$tokenIndex -= 1;
6562
6563 while (this.$tokenIndex < 0) {
6564 this.$row -= 1;
6565 if (this.$row < 0) {
6566 this.$row = 0;
6567 return null;
6568 }
6569
6570 this.$rowTokens = this.$session.getTokens(this.$row);
6571 this.$tokenIndex = this.$rowTokens.length - 1;
6572 }
6573
6574 return this.$rowTokens[this.$tokenIndex];
6575 };
6576 this.stepForward = function() {
6577 this.$tokenIndex += 1;
6578 var rowCount;
6579 while (this.$tokenIndex >= this.$rowTokens.length) {
6580 this.$row += 1;
6581 if (!rowCount)
6582 rowCount = this.$session.getLength();
6583 if (this.$row >= rowCount) {
6584 this.$row = rowCount - 1;
6585 return null;
6586 }
6587
6588 this.$rowTokens = this.$session.getTokens(this.$row);
6589 this.$tokenIndex = 0;
6590 }
6591
6592 return this.$rowTokens[this.$tokenIndex];
6593 };
6594 this.getCurrentToken = function () {
6595 return this.$rowTokens[this.$tokenIndex];
6596 };
6597 this.getCurrentTokenRow = function () {
6598 return this.$row;
6599 };
6600 this.getCurrentTokenColumn = function() {
6601 var rowTokens = this.$rowTokens;
6602 var tokenIndex = this.$tokenIndex;
6603 var column = rowTokens[tokenIndex].start;
6604 if (column !== undefined)
6605 return column;
6606
6607 column = 0;
6608 while (tokenIndex > 0) {
6609 tokenIndex -= 1;
6610 column += rowTokens[tokenIndex].value.length;
6611 }
6612
6613 return column;
6614 };
6615 this.getCurrentTokenPosition = function() {
6616 return {row: this.$row, column: this.getCurrentTokenColumn()};
6617 };
6618 this.getCurrentTokenRange = function() {
6619 var token = this.$rowTokens[this.$tokenIndex];
6620 var column = this.getCurrentTokenColumn();
6621 return new Range(this.$row, column, this.$row, column + token.value.length);
6622 };
6623
6624 }).call(TokenIterator.prototype);
6625
6626 exports.TokenIterator = TokenIterator;
6627 });
6628
6629 ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(acequire, exports, module) {
6630
6631 var oop = acequire("../../lib/oop");
6632 var Behaviour = acequire("../behaviour").Behaviour;
6633 var TokenIterator = acequire("../../token_iterator").TokenIterator;
6634 var lang = acequire("../../lib/lang");
6635
6636 var SAFE_INSERT_IN_TOKENS =
6637 ["text", "paren.rparen", "punctuation.operator"];
6638 var SAFE_INSERT_BEFORE_TOKENS =
6639 ["text", "paren.rparen", "punctuation.operator", "comment"];
6640
6641 var context;
6642 var contextCache = {};
6643 var defaultQuotes = {'"' : '"', "'" : "'"};
6644
6645 var initContext = function(editor) {
6646 var id = -1;
6647 if (editor.multiSelect) {
6648 id = editor.selection.index;
6649 if (contextCache.rangeCount != editor.multiSelect.rangeCount)
6650 contextCache = {rangeCount: editor.multiSelect.rangeCount};
6651 }
6652 if (contextCache[id])
6653 return context = contextCache[id];
6654 context = contextCache[id] = {
6655 autoInsertedBrackets: 0,
6656 autoInsertedRow: -1,
6657 autoInsertedLineEnd: "",
6658 maybeInsertedBrackets: 0,
6659 maybeInsertedRow: -1,
6660 maybeInsertedLineStart: "",
6661 maybeInsertedLineEnd: ""
6662 };
6663 };
6664
6665 var getWrapped = function(selection, selected, opening, closing) {
6666 var rowDiff = selection.end.row - selection.start.row;
6667 return {
6668 text: opening + selected + closing,
6669 selection: [
6670 0,
6671 selection.start.column + 1,
6672 rowDiff,
6673 selection.end.column + (rowDiff ? 0 : 1)
6674 ]
6675 };
6676 };
6677
6678 var CstyleBehaviour = function(options) {
6679 this.add("braces", "insertion", function(state, action, editor, session, text) {
6680 var cursor = editor.getCursorPosition();
6681 var line = session.doc.getLine(cursor.row);
6682 if (text == '{') {
6683 initContext(editor);
6684 var selection = editor.getSelectionRange();
6685 var selected = session.doc.getTextRange(selection);
6686 if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
6687 return getWrapped(selection, selected, '{', '}');
6688 } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
6689 if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode || options && options.braces) {
6690 CstyleBehaviour.recordAutoInsert(editor, session, "}");
6691 return {
6692 text: '{}',
6693 selection: [1, 1]
6694 };
6695 } else {
6696 CstyleBehaviour.recordMaybeInsert(editor, session, "{");
6697 return {
6698 text: '{',
6699 selection: [1, 1]
6700 };
6701 }
6702 }
6703 } else if (text == '}') {
6704 initContext(editor);
6705 var rightChar = line.substring(cursor.column, cursor.column + 1);
6706 if (rightChar == '}') {
6707 var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
6708 if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
6709 CstyleBehaviour.popAutoInsertedClosing();
6710 return {
6711 text: '',
6712 selection: [1, 1]
6713 };
6714 }
6715 }
6716 } else if (text == "\n" || text == "\r\n") {
6717 initContext(editor);
6718 var closing = "";
6719 if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
6720 closing = lang.stringRepeat("}", context.maybeInsertedBrackets);
6721 CstyleBehaviour.clearMaybeInsertedClosing();
6722 }
6723 var rightChar = line.substring(cursor.column, cursor.column + 1);
6724 if (rightChar === '}') {
6725 var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
6726 if (!openBracePos)
6727 return null;
6728 var next_indent = this.$getIndent(session.getLine(openBracePos.row));
6729 } else if (closing) {
6730 var next_indent = this.$getIndent(line);
6731 } else {
6732 CstyleBehaviour.clearMaybeInsertedClosing();
6733 return;
6734 }
6735 var indent = next_indent + session.getTabString();
6736
6737 return {
6738 text: '\n' + indent + '\n' + next_indent + closing,
6739 selection: [1, indent.length, 1, indent.length]
6740 };
6741 } else {
6742 CstyleBehaviour.clearMaybeInsertedClosing();
6743 }
6744 });
6745
6746 this.add("braces", "deletion", function(state, action, editor, session, range) {
6747 var selected = session.doc.getTextRange(range);
6748 if (!range.isMultiLine() && selected == '{') {
6749 initContext(editor);
6750 var line = session.doc.getLine(range.start.row);
6751 var rightChar = line.substring(range.end.column, range.end.column + 1);
6752 if (rightChar == '}') {
6753 range.end.column++;
6754 return range;
6755 } else {
6756 context.maybeInsertedBrackets--;
6757 }
6758 }
6759 });
6760
6761 this.add("parens", "insertion", function(state, action, editor, session, text) {
6762 if (text == '(') {
6763 initContext(editor);
6764 var selection = editor.getSelectionRange();
6765 var selected = session.doc.getTextRange(selection);
6766 if (selected !== "" && editor.getWrapBehavioursEnabled()) {
6767 return getWrapped(selection, selected, '(', ')');
6768 } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
6769 CstyleBehaviour.recordAutoInsert(editor, session, ")");
6770 return {
6771 text: '()',
6772 selection: [1, 1]
6773 };
6774 }
6775 } else if (text == ')') {
6776 initContext(editor);
6777 var cursor = editor.getCursorPosition();
6778 var line = session.doc.getLine(cursor.row);
6779 var rightChar = line.substring(cursor.column, cursor.column + 1);
6780 if (rightChar == ')') {
6781 var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
6782 if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
6783 CstyleBehaviour.popAutoInsertedClosing();
6784 return {
6785 text: '',
6786 selection: [1, 1]
6787 };
6788 }
6789 }
6790 }
6791 });
6792
6793 this.add("parens", "deletion", function(state, action, editor, session, range) {
6794 var selected = session.doc.getTextRange(range);
6795 if (!range.isMultiLine() && selected == '(') {
6796 initContext(editor);
6797 var line = session.doc.getLine(range.start.row);
6798 var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
6799 if (rightChar == ')') {
6800 range.end.column++;
6801 return range;
6802 }
6803 }
6804 });
6805
6806 this.add("brackets", "insertion", function(state, action, editor, session, text) {
6807 if (text == '[') {
6808 initContext(editor);
6809 var selection = editor.getSelectionRange();
6810 var selected = session.doc.getTextRange(selection);
6811 if (selected !== "" && editor.getWrapBehavioursEnabled()) {
6812 return getWrapped(selection, selected, '[', ']');
6813 } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
6814 CstyleBehaviour.recordAutoInsert(editor, session, "]");
6815 return {
6816 text: '[]',
6817 selection: [1, 1]
6818 };
6819 }
6820 } else if (text == ']') {
6821 initContext(editor);
6822 var cursor = editor.getCursorPosition();
6823 var line = session.doc.getLine(cursor.row);
6824 var rightChar = line.substring(cursor.column, cursor.column + 1);
6825 if (rightChar == ']') {
6826 var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
6827 if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
6828 CstyleBehaviour.popAutoInsertedClosing();
6829 return {
6830 text: '',
6831 selection: [1, 1]
6832 };
6833 }
6834 }
6835 }
6836 });
6837
6838 this.add("brackets", "deletion", function(state, action, editor, session, range) {
6839 var selected = session.doc.getTextRange(range);
6840 if (!range.isMultiLine() && selected == '[') {
6841 initContext(editor);
6842 var line = session.doc.getLine(range.start.row);
6843 var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
6844 if (rightChar == ']') {
6845 range.end.column++;
6846 return range;
6847 }
6848 }
6849 });
6850
6851 this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
6852 var quotes = session.$mode.$quotes || defaultQuotes;
6853 if (text.length == 1 && quotes[text]) {
6854 if (this.lineCommentStart && this.lineCommentStart.indexOf(text) != -1)
6855 return;
6856 initContext(editor);
6857 var quote = text;
6858 var selection = editor.getSelectionRange();
6859 var selected = session.doc.getTextRange(selection);
6860 if (selected !== "" && (selected.length != 1 || !quotes[selected]) && editor.getWrapBehavioursEnabled()) {
6861 return getWrapped(selection, selected, quote, quote);
6862 } else if (!selected) {
6863 var cursor = editor.getCursorPosition();
6864 var line = session.doc.getLine(cursor.row);
6865 var leftChar = line.substring(cursor.column-1, cursor.column);
6866 var rightChar = line.substring(cursor.column, cursor.column + 1);
6867
6868 var token = session.getTokenAt(cursor.row, cursor.column);
6869 var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
6870 if (leftChar == "\\" && token && /escape/.test(token.type))
6871 return null;
6872
6873 var stringBefore = token && /string|escape/.test(token.type);
6874 var stringAfter = !rightToken || /string|escape/.test(rightToken.type);
6875
6876 var pair;
6877 if (rightChar == quote) {
6878 pair = stringBefore !== stringAfter;
6879 if (pair && /string\.end/.test(rightToken.type))
6880 pair = false;
6881 } else {
6882 if (stringBefore && !stringAfter)
6883 return null; // wrap string with different quote
6884 if (stringBefore && stringAfter)
6885 return null; // do not pair quotes inside strings
6886 var wordRe = session.$mode.tokenRe;
6887 wordRe.lastIndex = 0;
6888 var isWordBefore = wordRe.test(leftChar);
6889 wordRe.lastIndex = 0;
6890 var isWordAfter = wordRe.test(leftChar);
6891 if (isWordBefore || isWordAfter)
6892 return null; // before or after alphanumeric
6893 if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
6894 return null; // there is rightChar and it isn't closing
6895 pair = true;
6896 }
6897 return {
6898 text: pair ? quote + quote : "",
6899 selection: [1,1]
6900 };
6901 }
6902 }
6903 });
6904
6905 this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
6906 var selected = session.doc.getTextRange(range);
6907 if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
6908 initContext(editor);
6909 var line = session.doc.getLine(range.start.row);
6910 var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
6911 if (rightChar == selected) {
6912 range.end.column++;
6913 return range;
6914 }
6915 }
6916 });
6917
6918 };
6919
6920
6921 CstyleBehaviour.isSaneInsertion = function(editor, session) {
6922 var cursor = editor.getCursorPosition();
6923 var iterator = new TokenIterator(session, cursor.row, cursor.column);
6924 if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
6925 var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
6926 if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
6927 return false;
6928 }
6929 iterator.stepForward();
6930 return iterator.getCurrentTokenRow() !== cursor.row ||
6931 this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
6932 };
6933
6934 CstyleBehaviour.$matchTokenType = function(token, types) {
6935 return types.indexOf(token.type || token) > -1;
6936 };
6937
6938 CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
6939 var cursor = editor.getCursorPosition();
6940 var line = session.doc.getLine(cursor.row);
6941 if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0]))
6942 context.autoInsertedBrackets = 0;
6943 context.autoInsertedRow = cursor.row;
6944 context.autoInsertedLineEnd = bracket + line.substr(cursor.column);
6945 context.autoInsertedBrackets++;
6946 };
6947
6948 CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
6949 var cursor = editor.getCursorPosition();
6950 var line = session.doc.getLine(cursor.row);
6951 if (!this.isMaybeInsertedClosing(cursor, line))
6952 context.maybeInsertedBrackets = 0;
6953 context.maybeInsertedRow = cursor.row;
6954 context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
6955 context.maybeInsertedLineEnd = line.substr(cursor.column);
6956 context.maybeInsertedBrackets++;
6957 };
6958
6959 CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
6960 return context.autoInsertedBrackets > 0 &&
6961 cursor.row === context.autoInsertedRow &&
6962 bracket === context.autoInsertedLineEnd[0] &&
6963 line.substr(cursor.column) === context.autoInsertedLineEnd;
6964 };
6965
6966 CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
6967 return context.maybeInsertedBrackets > 0 &&
6968 cursor.row === context.maybeInsertedRow &&
6969 line.substr(cursor.column) === context.maybeInsertedLineEnd &&
6970 line.substr(0, cursor.column) == context.maybeInsertedLineStart;
6971 };
6972
6973 CstyleBehaviour.popAutoInsertedClosing = function() {
6974 context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1);
6975 context.autoInsertedBrackets--;
6976 };
6977
6978 CstyleBehaviour.clearMaybeInsertedClosing = function() {
6979 if (context) {
6980 context.maybeInsertedBrackets = 0;
6981 context.maybeInsertedRow = -1;
6982 }
6983 };
6984
6985
6986
6987 oop.inherits(CstyleBehaviour, Behaviour);
6988
6989 exports.CstyleBehaviour = CstyleBehaviour;
6990 });
6991
6992 ace.define("ace/unicode",["require","exports","module"], function(acequire, exports, module) {
6993 exports.packages = {};
6994
6995 addUnicodePackage({
6996 L: "0041-005A0061-007A00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D102E0-02E402EC02EE0370-037403760377037A-037D03860388-038A038C038E-03A103A3-03F503F7-0481048A-05250531-055605590561-058705D0-05EA05F0-05F20621-064A066E066F0671-06D306D506E506E606EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA07F407F507FA0800-0815081A082408280904-0939093D09500958-0961097109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E460E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EC60EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10A0-10C510D0-10FA10FC1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317D717DC1820-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541AA71B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C7D1CE9-1CEC1CEE-1CF11D00-1DBF1E00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FBC1FBE1FC2-1FC41FC6-1FCC1FD0-1FD31FD6-1FDB1FE0-1FEC1FF2-1FF41FF6-1FFC2071207F2090-209421022107210A-211321152119-211D212421262128212A-212D212F-2139213C-213F2145-2149214E218321842C00-2C2E2C30-2C5E2C60-2CE42CEB-2CEE2D00-2D252D30-2D652D6F2D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE2E2F300530063031-3035303B303C3041-3096309D-309F30A1-30FA30FC-30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A48CA4D0-A4FDA500-A60CA610-A61FA62AA62BA640-A65FA662-A66EA67F-A697A6A0-A6E5A717-A71FA722-A788A78BA78CA7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2A9CFAA00-AA28AA40-AA42AA44-AA4BAA60-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADB-AADDABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB00-FB06FB13-FB17FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF21-FF3AFF41-FF5AFF66-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",
6997 Ll: "0061-007A00AA00B500BA00DF-00F600F8-00FF01010103010501070109010B010D010F01110113011501170119011B011D011F01210123012501270129012B012D012F01310133013501370138013A013C013E014001420144014601480149014B014D014F01510153015501570159015B015D015F01610163016501670169016B016D016F0171017301750177017A017C017E-0180018301850188018C018D019201950199-019B019E01A101A301A501A801AA01AB01AD01B001B401B601B901BA01BD-01BF01C601C901CC01CE01D001D201D401D601D801DA01DC01DD01DF01E101E301E501E701E901EB01ED01EF01F001F301F501F901FB01FD01FF02010203020502070209020B020D020F02110213021502170219021B021D021F02210223022502270229022B022D022F02310233-0239023C023F0240024202470249024B024D024F-02930295-02AF037103730377037B-037D039003AC-03CE03D003D103D5-03D703D903DB03DD03DF03E103E303E503E703E903EB03ED03EF-03F303F503F803FB03FC0430-045F04610463046504670469046B046D046F04710473047504770479047B047D047F0481048B048D048F04910493049504970499049B049D049F04A104A304A504A704A904AB04AD04AF04B104B304B504B704B904BB04BD04BF04C204C404C604C804CA04CC04CE04CF04D104D304D504D704D904DB04DD04DF04E104E304E504E704E904EB04ED04EF04F104F304F504F704F904FB04FD04FF05010503050505070509050B050D050F05110513051505170519051B051D051F0521052305250561-05871D00-1D2B1D62-1D771D79-1D9A1E011E031E051E071E091E0B1E0D1E0F1E111E131E151E171E191E1B1E1D1E1F1E211E231E251E271E291E2B1E2D1E2F1E311E331E351E371E391E3B1E3D1E3F1E411E431E451E471E491E4B1E4D1E4F1E511E531E551E571E591E5B1E5D1E5F1E611E631E651E671E691E6B1E6D1E6F1E711E731E751E771E791E7B1E7D1E7F1E811E831E851E871E891E8B1E8D1E8F1E911E931E95-1E9D1E9F1EA11EA31EA51EA71EA91EAB1EAD1EAF1EB11EB31EB51EB71EB91EBB1EBD1EBF1EC11EC31EC51EC71EC91ECB1ECD1ECF1ED11ED31ED51ED71ED91EDB1EDD1EDF1EE11EE31EE51EE71EE91EEB1EED1EEF1EF11EF31EF51EF71EF91EFB1EFD1EFF-1F071F10-1F151F20-1F271F30-1F371F40-1F451F50-1F571F60-1F671F70-1F7D1F80-1F871F90-1F971FA0-1FA71FB0-1FB41FB61FB71FBE1FC2-1FC41FC61FC71FD0-1FD31FD61FD71FE0-1FE71FF2-1FF41FF61FF7210A210E210F2113212F21342139213C213D2146-2149214E21842C30-2C5E2C612C652C662C682C6A2C6C2C712C732C742C76-2C7C2C812C832C852C872C892C8B2C8D2C8F2C912C932C952C972C992C9B2C9D2C9F2CA12CA32CA52CA72CA92CAB2CAD2CAF2CB12CB32CB52CB72CB92CBB2CBD2CBF2CC12CC32CC52CC72CC92CCB2CCD2CCF2CD12CD32CD52CD72CD92CDB2CDD2CDF2CE12CE32CE42CEC2CEE2D00-2D25A641A643A645A647A649A64BA64DA64FA651A653A655A657A659A65BA65DA65FA663A665A667A669A66BA66DA681A683A685A687A689A68BA68DA68FA691A693A695A697A723A725A727A729A72BA72DA72F-A731A733A735A737A739A73BA73DA73FA741A743A745A747A749A74BA74DA74FA751A753A755A757A759A75BA75DA75FA761A763A765A767A769A76BA76DA76FA771-A778A77AA77CA77FA781A783A785A787A78CFB00-FB06FB13-FB17FF41-FF5A",
6998 Lu: "0041-005A00C0-00D600D8-00DE01000102010401060108010A010C010E01100112011401160118011A011C011E01200122012401260128012A012C012E01300132013401360139013B013D013F0141014301450147014A014C014E01500152015401560158015A015C015E01600162016401660168016A016C016E017001720174017601780179017B017D018101820184018601870189-018B018E-0191019301940196-0198019C019D019F01A001A201A401A601A701A901AC01AE01AF01B1-01B301B501B701B801BC01C401C701CA01CD01CF01D101D301D501D701D901DB01DE01E001E201E401E601E801EA01EC01EE01F101F401F6-01F801FA01FC01FE02000202020402060208020A020C020E02100212021402160218021A021C021E02200222022402260228022A022C022E02300232023A023B023D023E02410243-02460248024A024C024E03700372037603860388-038A038C038E038F0391-03A103A3-03AB03CF03D2-03D403D803DA03DC03DE03E003E203E403E603E803EA03EC03EE03F403F703F903FA03FD-042F04600462046404660468046A046C046E04700472047404760478047A047C047E0480048A048C048E04900492049404960498049A049C049E04A004A204A404A604A804AA04AC04AE04B004B204B404B604B804BA04BC04BE04C004C104C304C504C704C904CB04CD04D004D204D404D604D804DA04DC04DE04E004E204E404E604E804EA04EC04EE04F004F204F404F604F804FA04FC04FE05000502050405060508050A050C050E05100512051405160518051A051C051E0520052205240531-055610A0-10C51E001E021E041E061E081E0A1E0C1E0E1E101E121E141E161E181E1A1E1C1E1E1E201E221E241E261E281E2A1E2C1E2E1E301E321E341E361E381E3A1E3C1E3E1E401E421E441E461E481E4A1E4C1E4E1E501E521E541E561E581E5A1E5C1E5E1E601E621E641E661E681E6A1E6C1E6E1E701E721E741E761E781E7A1E7C1E7E1E801E821E841E861E881E8A1E8C1E8E1E901E921E941E9E1EA01EA21EA41EA61EA81EAA1EAC1EAE1EB01EB21EB41EB61EB81EBA1EBC1EBE1EC01EC21EC41EC61EC81ECA1ECC1ECE1ED01ED21ED41ED61ED81EDA1EDC1EDE1EE01EE21EE41EE61EE81EEA1EEC1EEE1EF01EF21EF41EF61EF81EFA1EFC1EFE1F08-1F0F1F18-1F1D1F28-1F2F1F38-1F3F1F48-1F4D1F591F5B1F5D1F5F1F68-1F6F1FB8-1FBB1FC8-1FCB1FD8-1FDB1FE8-1FEC1FF8-1FFB21022107210B-210D2110-211221152119-211D212421262128212A-212D2130-2133213E213F214521832C00-2C2E2C602C62-2C642C672C692C6B2C6D-2C702C722C752C7E-2C802C822C842C862C882C8A2C8C2C8E2C902C922C942C962C982C9A2C9C2C9E2CA02CA22CA42CA62CA82CAA2CAC2CAE2CB02CB22CB42CB62CB82CBA2CBC2CBE2CC02CC22CC42CC62CC82CCA2CCC2CCE2CD02CD22CD42CD62CD82CDA2CDC2CDE2CE02CE22CEB2CEDA640A642A644A646A648A64AA64CA64EA650A652A654A656A658A65AA65CA65EA662A664A666A668A66AA66CA680A682A684A686A688A68AA68CA68EA690A692A694A696A722A724A726A728A72AA72CA72EA732A734A736A738A73AA73CA73EA740A742A744A746A748A74AA74CA74EA750A752A754A756A758A75AA75CA75EA760A762A764A766A768A76AA76CA76EA779A77BA77DA77EA780A782A784A786A78BFF21-FF3A",
6999 Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",
7000 Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",
7001 Lo: "01BB01C0-01C3029405D0-05EA05F0-05F20621-063F0641-064A066E066F0671-06D306D506EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA0800-08150904-0939093D09500958-096109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E450E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10D0-10FA1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317DC1820-18421844-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C771CE9-1CEC1CEE-1CF12135-21382D30-2D652D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE3006303C3041-3096309F30A1-30FA30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A014A016-A48CA4D0-A4F7A500-A60BA610-A61FA62AA62BA66EA6A0-A6E5A7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2AA00-AA28AA40-AA42AA44-AA4BAA60-AA6FAA71-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADBAADCABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF66-FF6FFF71-FF9DFFA0-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",
7002 M: "0300-036F0483-04890591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DE-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0903093C093E-094E0951-0955096209630981-098309BC09BE-09C409C709C809CB-09CD09D709E209E30A01-0A030A3C0A3E-0A420A470A480A4B-0A4D0A510A700A710A750A81-0A830ABC0ABE-0AC50AC7-0AC90ACB-0ACD0AE20AE30B01-0B030B3C0B3E-0B440B470B480B4B-0B4D0B560B570B620B630B820BBE-0BC20BC6-0BC80BCA-0BCD0BD70C01-0C030C3E-0C440C46-0C480C4A-0C4D0C550C560C620C630C820C830CBC0CBE-0CC40CC6-0CC80CCA-0CCD0CD50CD60CE20CE30D020D030D3E-0D440D46-0D480D4A-0D4D0D570D620D630D820D830DCA0DCF-0DD40DD60DD8-0DDF0DF20DF30E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F3E0F3F0F71-0F840F860F870F90-0F970F99-0FBC0FC6102B-103E1056-1059105E-10601062-10641067-106D1071-10741082-108D108F109A-109D135F1712-17141732-1734175217531772177317B6-17D317DD180B-180D18A91920-192B1930-193B19B0-19C019C819C91A17-1A1B1A55-1A5E1A60-1A7C1A7F1B00-1B041B34-1B441B6B-1B731B80-1B821BA1-1BAA1C24-1C371CD0-1CD21CD4-1CE81CED1CF21DC0-1DE61DFD-1DFF20D0-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66F-A672A67CA67DA6F0A6F1A802A806A80BA823-A827A880A881A8B4-A8C4A8E0-A8F1A926-A92DA947-A953A980-A983A9B3-A9C0AA29-AA36AA43AA4CAA4DAA7BAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE3-ABEAABECABEDFB1EFE00-FE0FFE20-FE26",
7003 Mn: "0300-036F0483-04870591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DF-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0902093C0941-0948094D0951-095509620963098109BC09C1-09C409CD09E209E30A010A020A3C0A410A420A470A480A4B-0A4D0A510A700A710A750A810A820ABC0AC1-0AC50AC70AC80ACD0AE20AE30B010B3C0B3F0B41-0B440B4D0B560B620B630B820BC00BCD0C3E-0C400C46-0C480C4A-0C4D0C550C560C620C630CBC0CBF0CC60CCC0CCD0CE20CE30D41-0D440D4D0D620D630DCA0DD2-0DD40DD60E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F71-0F7E0F80-0F840F860F870F90-0F970F99-0FBC0FC6102D-10301032-10371039103A103D103E10581059105E-10601071-1074108210851086108D109D135F1712-17141732-1734175217531772177317B7-17BD17C617C9-17D317DD180B-180D18A91920-19221927192819321939-193B1A171A181A561A58-1A5E1A601A621A65-1A6C1A73-1A7C1A7F1B00-1B031B341B36-1B3A1B3C1B421B6B-1B731B801B811BA2-1BA51BA81BA91C2C-1C331C361C371CD0-1CD21CD4-1CE01CE2-1CE81CED1DC0-1DE61DFD-1DFF20D0-20DC20E120E5-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66FA67CA67DA6F0A6F1A802A806A80BA825A826A8C4A8E0-A8F1A926-A92DA947-A951A980-A982A9B3A9B6-A9B9A9BCAA29-AA2EAA31AA32AA35AA36AA43AA4CAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE5ABE8ABEDFB1EFE00-FE0FFE20-FE26",
7004 Mc: "0903093E-09400949-094C094E0982098309BE-09C009C709C809CB09CC09D70A030A3E-0A400A830ABE-0AC00AC90ACB0ACC0B020B030B3E0B400B470B480B4B0B4C0B570BBE0BBF0BC10BC20BC6-0BC80BCA-0BCC0BD70C01-0C030C41-0C440C820C830CBE0CC0-0CC40CC70CC80CCA0CCB0CD50CD60D020D030D3E-0D400D46-0D480D4A-0D4C0D570D820D830DCF-0DD10DD8-0DDF0DF20DF30F3E0F3F0F7F102B102C10311038103B103C105610571062-10641067-106D108310841087-108C108F109A-109C17B617BE-17C517C717C81923-19261929-192B193019311933-193819B0-19C019C819C91A19-1A1B1A551A571A611A631A641A6D-1A721B041B351B3B1B3D-1B411B431B441B821BA11BA61BA71BAA1C24-1C2B1C341C351CE11CF2A823A824A827A880A881A8B4-A8C3A952A953A983A9B4A9B5A9BAA9BBA9BD-A9C0AA2FAA30AA33AA34AA4DAA7BABE3ABE4ABE6ABE7ABE9ABEAABEC",
7005 Me: "0488048906DE20DD-20E020E2-20E4A670-A672",
7006 N: "0030-003900B200B300B900BC-00BE0660-066906F0-06F907C0-07C90966-096F09E6-09EF09F4-09F90A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BF20C66-0C6F0C78-0C7E0CE6-0CEF0D66-0D750E50-0E590ED0-0ED90F20-0F331040-10491090-10991369-137C16EE-16F017E0-17E917F0-17F91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C5920702074-20792080-20892150-21822185-21892460-249B24EA-24FF2776-27932CFD30073021-30293038-303A3192-31953220-32293251-325F3280-328932B1-32BFA620-A629A6E6-A6EFA830-A835A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",
7007 Nd: "0030-00390660-066906F0-06F907C0-07C90966-096F09E6-09EF0A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BEF0C66-0C6F0CE6-0CEF0D66-0D6F0E50-0E590ED0-0ED90F20-0F291040-10491090-109917E0-17E91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C59A620-A629A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",
7008 Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",
7009 No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",
7010 P: "0021-00230025-002A002C-002F003A003B003F0040005B-005D005F007B007D00A100AB00B700BB00BF037E0387055A-055F0589058A05BE05C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F3A-0F3D0F850FD0-0FD4104A-104F10FB1361-13681400166D166E169B169C16EB-16ED1735173617D4-17D617D8-17DA1800-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD32010-20272030-20432045-20512053-205E207D207E208D208E2329232A2768-277527C527C627E6-27EF2983-299829D8-29DB29FC29FD2CF9-2CFC2CFE2CFF2E00-2E2E2E302E313001-30033008-30113014-301F3030303D30A030FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFD3EFD3FFE10-FE19FE30-FE52FE54-FE61FE63FE68FE6AFE6BFF01-FF03FF05-FF0AFF0C-FF0FFF1AFF1BFF1FFF20FF3B-FF3DFF3FFF5BFF5DFF5F-FF65",
7011 Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",
7012 Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",
7013 Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",
7014 Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",
7015 Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21",
7016 Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F",
7017 Po: "0021-00230025-0027002A002C002E002F003A003B003F0040005C00A100B700BF037E0387055A-055F058905C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F850FD0-0FD4104A-104F10FB1361-1368166D166E16EB-16ED1735173617D4-17D617D8-17DA1800-18051807-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD3201620172020-20272030-2038203B-203E2041-20432047-205120532055-205E2CF9-2CFC2CFE2CFF2E002E012E06-2E082E0B2E0E-2E162E182E192E1B2E1E2E1F2E2A-2E2E2E302E313001-3003303D30FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFE10-FE16FE19FE30FE45FE46FE49-FE4CFE50-FE52FE54-FE57FE5F-FE61FE68FE6AFE6BFF01-FF03FF05-FF07FF0AFF0CFF0EFF0FFF1AFF1BFF1FFF20FF3CFF61FF64FF65",
7018 S: "0024002B003C-003E005E0060007C007E00A2-00A900AC00AE-00B100B400B600B800D700F702C2-02C502D2-02DF02E5-02EB02ED02EF-02FF03750384038503F604820606-0608060B060E060F06E906FD06FE07F609F209F309FA09FB0AF10B700BF3-0BFA0C7F0CF10CF20D790E3F0F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-139917DB194019E0-19FF1B61-1B6A1B74-1B7C1FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE20442052207A-207C208A-208C20A0-20B8210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B2140-2144214A-214D214F2190-2328232B-23E82400-24262440-244A249C-24E92500-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE27C0-27C427C7-27CA27CC27D0-27E527F0-29822999-29D729DC-29FB29FE-2B4C2B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F309B309C319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A700-A716A720A721A789A78AA828-A82BA836-A839AA77-AA79FB29FDFCFDFDFE62FE64-FE66FE69FF04FF0BFF1C-FF1EFF3EFF40FF5CFF5EFFE0-FFE6FFE8-FFEEFFFCFFFD",
7019 Sm: "002B003C-003E007C007E00AC00B100D700F703F60606-060820442052207A-207C208A-208C2140-2144214B2190-2194219A219B21A021A321A621AE21CE21CF21D221D421F4-22FF2308-230B23202321237C239B-23B323DC-23E125B725C125F8-25FF266F27C0-27C427C7-27CA27CC27D0-27E527F0-27FF2900-29822999-29D729DC-29FB29FE-2AFF2B30-2B442B47-2B4CFB29FE62FE64-FE66FF0BFF1C-FF1EFF5CFF5EFFE2FFE9-FFEC",
7020 Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",
7021 Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",
7022 So: "00A600A700A900AE00B000B60482060E060F06E906FD06FE07F609FA0B700BF3-0BF80BFA0C7F0CF10CF20D790F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-1399194019E0-19FF1B61-1B6A1B74-1B7C210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B214A214C214D214F2195-2199219C-219F21A121A221A421A521A7-21AD21AF-21CD21D021D121D321D5-21F32300-2307230C-231F2322-2328232B-237B237D-239A23B4-23DB23E2-23E82400-24262440-244A249C-24E92500-25B625B8-25C025C2-25F72600-266E2670-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE2800-28FF2B00-2B2F2B452B462B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A828-A82BA836A837A839AA77-AA79FDFDFFE4FFE8FFEDFFEEFFFCFFFD",
7023 Z: "002000A01680180E2000-200A20282029202F205F3000",
7024 Zs: "002000A01680180E2000-200A202F205F3000",
7025 Zl: "2028",
7026 Zp: "2029",
7027 C: "0000-001F007F-009F00AD03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-0605061C061D0620065F06DD070E070F074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17B417B517DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF200B-200F202A-202E2060-206F20722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-F8FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFD-FF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFFBFFFEFFFF",
7028 Cc: "0000-001F007F-009F",
7029 Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",
7030 Co: "E000-F8FF",
7031 Cs: "D800-DFFF",
7032 Cn: "03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-05FF06040605061C061D0620065F070E074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF2065-206920722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-D7FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFDFEFEFF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFF8FFFEFFFF"
7033 });
7034
7035 function addUnicodePackage (pack) {
7036 var codePoint = /\w{4}/g;
7037 for (var name in pack)
7038 exports.packages[name] = pack[name].replace(codePoint, "\\u$&");
7039 }
7040
7041 });
7042
7043 ace.define("ace/mode/text",["require","exports","module","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour/cstyle","ace/unicode","ace/lib/lang","ace/token_iterator","ace/range"], function(acequire, exports, module) {
7044
7045 var Tokenizer = acequire("../tokenizer").Tokenizer;
7046 var TextHighlightRules = acequire("./text_highlight_rules").TextHighlightRules;
7047 var CstyleBehaviour = acequire("./behaviour/cstyle").CstyleBehaviour;
7048 var unicode = acequire("../unicode");
7049 var lang = acequire("../lib/lang");
7050 var TokenIterator = acequire("../token_iterator").TokenIterator;
7051 var Range = acequire("../range").Range;
7052
7053 var Mode = function() {
7054 this.HighlightRules = TextHighlightRules;
7055 };
7056
7057 (function() {
7058 this.$defaultBehaviour = new CstyleBehaviour();
7059
7060 this.tokenRe = new RegExp("^["
7061 + unicode.packages.L
7062 + unicode.packages.Mn + unicode.packages.Mc
7063 + unicode.packages.Nd
7064 + unicode.packages.Pc + "\\$_]+", "g"
7065 );
7066
7067 this.nonTokenRe = new RegExp("^(?:[^"
7068 + unicode.packages.L
7069 + unicode.packages.Mn + unicode.packages.Mc
7070 + unicode.packages.Nd
7071 + unicode.packages.Pc + "\\$_]|\\s])+", "g"
7072 );
7073
7074 this.getTokenizer = function() {
7075 if (!this.$tokenizer) {
7076 this.$highlightRules = this.$highlightRules || new this.HighlightRules(this.$highlightRuleConfig);
7077 this.$tokenizer = new Tokenizer(this.$highlightRules.getRules());
7078 }
7079 return this.$tokenizer;
7080 };
7081
7082 this.lineCommentStart = "";
7083 this.blockComment = "";
7084
7085 this.toggleCommentLines = function(state, session, startRow, endRow) {
7086 var doc = session.doc;
7087
7088 var ignoreBlankLines = true;
7089 var shouldRemove = true;
7090 var minIndent = Infinity;
7091 var tabSize = session.getTabSize();
7092 var insertAtTabStop = false;
7093
7094 if (!this.lineCommentStart) {
7095 if (!this.blockComment)
7096 return false;
7097 var lineCommentStart = this.blockComment.start;
7098 var lineCommentEnd = this.blockComment.end;
7099 var regexpStart = new RegExp("^(\\s*)(?:" + lang.escapeRegExp(lineCommentStart) + ")");
7100 var regexpEnd = new RegExp("(?:" + lang.escapeRegExp(lineCommentEnd) + ")\\s*$");
7101
7102 var comment = function(line, i) {
7103 if (testRemove(line, i))
7104 return;
7105 if (!ignoreBlankLines || /\S/.test(line)) {
7106 doc.insertInLine({row: i, column: line.length}, lineCommentEnd);
7107 doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
7108 }
7109 };
7110
7111 var uncomment = function(line, i) {
7112 var m;
7113 if (m = line.match(regexpEnd))
7114 doc.removeInLine(i, line.length - m[0].length, line.length);
7115 if (m = line.match(regexpStart))
7116 doc.removeInLine(i, m[1].length, m[0].length);
7117 };
7118
7119 var testRemove = function(line, row) {
7120 if (regexpStart.test(line))
7121 return true;
7122 var tokens = session.getTokens(row);
7123 for (var i = 0; i < tokens.length; i++) {
7124 if (tokens[i].type === "comment")
7125 return true;
7126 }
7127 };
7128 } else {
7129 if (Array.isArray(this.lineCommentStart)) {
7130 var regexpStart = this.lineCommentStart.map(lang.escapeRegExp).join("|");
7131 var lineCommentStart = this.lineCommentStart[0];
7132 } else {
7133 var regexpStart = lang.escapeRegExp(this.lineCommentStart);
7134 var lineCommentStart = this.lineCommentStart;
7135 }
7136 regexpStart = new RegExp("^(\\s*)(?:" + regexpStart + ") ?");
7137
7138 insertAtTabStop = session.getUseSoftTabs();
7139
7140 var uncomment = function(line, i) {
7141 var m = line.match(regexpStart);
7142 if (!m) return;
7143 var start = m[1].length, end = m[0].length;
7144 if (!shouldInsertSpace(line, start, end) && m[0][end - 1] == " ")
7145 end--;
7146 doc.removeInLine(i, start, end);
7147 };
7148 var commentWithSpace = lineCommentStart + " ";
7149 var comment = function(line, i) {
7150 if (!ignoreBlankLines || /\S/.test(line)) {
7151 if (shouldInsertSpace(line, minIndent, minIndent))
7152 doc.insertInLine({row: i, column: minIndent}, commentWithSpace);
7153 else
7154 doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
7155 }
7156 };
7157 var testRemove = function(line, i) {
7158 return regexpStart.test(line);
7159 };
7160
7161 var shouldInsertSpace = function(line, before, after) {
7162 var spaces = 0;
7163 while (before-- && line.charAt(before) == " ")
7164 spaces++;
7165 if (spaces % tabSize != 0)
7166 return false;
7167 var spaces = 0;
7168 while (line.charAt(after++) == " ")
7169 spaces++;
7170 if (tabSize > 2)
7171 return spaces % tabSize != tabSize - 1;
7172 else
7173 return spaces % tabSize == 0;
7174 };
7175 }
7176
7177 function iter(fun) {
7178 for (var i = startRow; i <= endRow; i++)
7179 fun(doc.getLine(i), i);
7180 }
7181
7182
7183 var minEmptyLength = Infinity;
7184 iter(function(line, i) {
7185 var indent = line.search(/\S/);
7186 if (indent !== -1) {
7187 if (indent < minIndent)
7188 minIndent = indent;
7189 if (shouldRemove && !testRemove(line, i))
7190 shouldRemove = false;
7191 } else if (minEmptyLength > line.length) {
7192 minEmptyLength = line.length;
7193 }
7194 });
7195
7196 if (minIndent == Infinity) {
7197 minIndent = minEmptyLength;
7198 ignoreBlankLines = false;
7199 shouldRemove = false;
7200 }
7201
7202 if (insertAtTabStop && minIndent % tabSize != 0)
7203 minIndent = Math.floor(minIndent / tabSize) * tabSize;
7204
7205 iter(shouldRemove ? uncomment : comment);
7206 };
7207
7208 this.toggleBlockComment = function(state, session, range, cursor) {
7209 var comment = this.blockComment;
7210 if (!comment)
7211 return;
7212 if (!comment.start && comment[0])
7213 comment = comment[0];
7214
7215 var iterator = new TokenIterator(session, cursor.row, cursor.column);
7216 var token = iterator.getCurrentToken();
7217
7218 session.selection;
7219 var initialRange = session.selection.toOrientedRange();
7220 var startRow, colDiff;
7221
7222 if (token && /comment/.test(token.type)) {
7223 var startRange, endRange;
7224 while (token && /comment/.test(token.type)) {
7225 var i = token.value.indexOf(comment.start);
7226 if (i != -1) {
7227 var row = iterator.getCurrentTokenRow();
7228 var column = iterator.getCurrentTokenColumn() + i;
7229 startRange = new Range(row, column, row, column + comment.start.length);
7230 break;
7231 }
7232 token = iterator.stepBackward();
7233 }
7234
7235 var iterator = new TokenIterator(session, cursor.row, cursor.column);
7236 var token = iterator.getCurrentToken();
7237 while (token && /comment/.test(token.type)) {
7238 var i = token.value.indexOf(comment.end);
7239 if (i != -1) {
7240 var row = iterator.getCurrentTokenRow();
7241 var column = iterator.getCurrentTokenColumn() + i;
7242 endRange = new Range(row, column, row, column + comment.end.length);
7243 break;
7244 }
7245 token = iterator.stepForward();
7246 }
7247 if (endRange)
7248 session.remove(endRange);
7249 if (startRange) {
7250 session.remove(startRange);
7251 startRow = startRange.start.row;
7252 colDiff = -comment.start.length;
7253 }
7254 } else {
7255 colDiff = comment.start.length;
7256 startRow = range.start.row;
7257 session.insert(range.end, comment.end);
7258 session.insert(range.start, comment.start);
7259 }
7260 if (initialRange.start.row == startRow)
7261 initialRange.start.column += colDiff;
7262 if (initialRange.end.row == startRow)
7263 initialRange.end.column += colDiff;
7264 session.selection.fromOrientedRange(initialRange);
7265 };
7266
7267 this.getNextLineIndent = function(state, line, tab) {
7268 return this.$getIndent(line);
7269 };
7270
7271 this.checkOutdent = function(state, line, input) {
7272 return false;
7273 };
7274
7275 this.autoOutdent = function(state, doc, row) {
7276 };
7277
7278 this.$getIndent = function(line) {
7279 return line.match(/^\s*/)[0];
7280 };
7281
7282 this.createWorker = function(session) {
7283 return null;
7284 };
7285
7286 this.createModeDelegates = function (mapping) {
7287 this.$embeds = [];
7288 this.$modes = {};
7289 for (var i in mapping) {
7290 if (mapping[i]) {
7291 this.$embeds.push(i);
7292 this.$modes[i] = new mapping[i]();
7293 }
7294 }
7295
7296 var delegations = ["toggleBlockComment", "toggleCommentLines", "getNextLineIndent",
7297 "checkOutdent", "autoOutdent", "transformAction", "getCompletions"];
7298
7299 for (var i = 0; i < delegations.length; i++) {
7300 (function(scope) {
7301 var functionName = delegations[i];
7302 var defaultHandler = scope[functionName];
7303 scope[delegations[i]] = function() {
7304 return this.$delegator(functionName, arguments, defaultHandler);
7305 };
7306 }(this));
7307 }
7308 };
7309
7310 this.$delegator = function(method, args, defaultHandler) {
7311 var state = args[0];
7312 if (typeof state != "string")
7313 state = state[0];
7314 for (var i = 0; i < this.$embeds.length; i++) {
7315 if (!this.$modes[this.$embeds[i]]) continue;
7316
7317 var split = state.split(this.$embeds[i]);
7318 if (!split[0] && split[1]) {
7319 args[0] = split[1];
7320 var mode = this.$modes[this.$embeds[i]];
7321 return mode[method].apply(mode, args);
7322 }
7323 }
7324 var ret = defaultHandler.apply(this, args);
7325 return defaultHandler ? ret : undefined;
7326 };
7327
7328 this.transformAction = function(state, action, editor, session, param) {
7329 if (this.$behaviour) {
7330 var behaviours = this.$behaviour.getBehaviours();
7331 for (var key in behaviours) {
7332 if (behaviours[key][action]) {
7333 var ret = behaviours[key][action].apply(this, arguments);
7334 if (ret) {
7335 return ret;
7336 }
7337 }
7338 }
7339 }
7340 };
7341
7342 this.getKeywords = function(append) {
7343 if (!this.completionKeywords) {
7344 var rules = this.$tokenizer.rules;
7345 var completionKeywords = [];
7346 for (var rule in rules) {
7347 var ruleItr = rules[rule];
7348 for (var r = 0, l = ruleItr.length; r < l; r++) {
7349 if (typeof ruleItr[r].token === "string") {
7350 if (/keyword|support|storage/.test(ruleItr[r].token))
7351 completionKeywords.push(ruleItr[r].regex);
7352 }
7353 else if (typeof ruleItr[r].token === "object") {
7354 for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) {
7355 if (/keyword|support|storage/.test(ruleItr[r].token[a])) {
7356 var rule = ruleItr[r].regex.match(/\(.+?\)/g)[a];
7357 completionKeywords.push(rule.substr(1, rule.length - 2));
7358 }
7359 }
7360 }
7361 }
7362 }
7363 this.completionKeywords = completionKeywords;
7364 }
7365 if (!append)
7366 return this.$keywordList;
7367 return completionKeywords.concat(this.$keywordList || []);
7368 };
7369
7370 this.$createKeywordList = function() {
7371 if (!this.$highlightRules)
7372 this.getTokenizer();
7373 return this.$keywordList = this.$highlightRules.$keywordList || [];
7374 };
7375
7376 this.getCompletions = function(state, session, pos, prefix) {
7377 var keywords = this.$keywordList || this.$createKeywordList();
7378 return keywords.map(function(word) {
7379 return {
7380 name: word,
7381 value: word,
7382 score: 0,
7383 meta: "keyword"
7384 };
7385 });
7386 };
7387
7388 this.$id = "ace/mode/text";
7389 }).call(Mode.prototype);
7390
7391 exports.Mode = Mode;
7392 });
7393
7394 ace.define("ace/apply_delta",["require","exports","module"], function(acequire, exports, module) {
7395
7396 exports.applyDelta = function(docLines, delta, doNotValidate) {
7397
7398 var row = delta.start.row;
7399 var startColumn = delta.start.column;
7400 var line = docLines[row] || "";
7401 switch (delta.action) {
7402 case "insert":
7403 var lines = delta.lines;
7404 if (lines.length === 1) {
7405 docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
7406 } else {
7407 var args = [row, 1].concat(delta.lines);
7408 docLines.splice.apply(docLines, args);
7409 docLines[row] = line.substring(0, startColumn) + docLines[row];
7410 docLines[row + delta.lines.length - 1] += line.substring(startColumn);
7411 }
7412 break;
7413 case "remove":
7414 var endColumn = delta.end.column;
7415 var endRow = delta.end.row;
7416 if (row === endRow) {
7417 docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
7418 } else {
7419 docLines.splice(
7420 row, endRow - row + 1,
7421 line.substring(0, startColumn) + docLines[endRow].substring(endColumn)
7422 );
7423 }
7424 break;
7425 }
7426 };
7427 });
7428
7429 ace.define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(acequire, exports, module) {
7430
7431 var oop = acequire("./lib/oop");
7432 var EventEmitter = acequire("./lib/event_emitter").EventEmitter;
7433
7434 var Anchor = exports.Anchor = function(doc, row, column) {
7435 this.$onChange = this.onChange.bind(this);
7436 this.attach(doc);
7437
7438 if (typeof column == "undefined")
7439 this.setPosition(row.row, row.column);
7440 else
7441 this.setPosition(row, column);
7442 };
7443
7444 (function() {
7445
7446 oop.implement(this, EventEmitter);
7447 this.getPosition = function() {
7448 return this.$clipPositionToDocument(this.row, this.column);
7449 };
7450 this.getDocument = function() {
7451 return this.document;
7452 };
7453 this.$insertRight = false;
7454 this.onChange = function(delta) {
7455 if (delta.start.row == delta.end.row && delta.start.row != this.row)
7456 return;
7457
7458 if (delta.start.row > this.row)
7459 return;
7460
7461 var point = $getTransformedPoint(delta, {row: this.row, column: this.column}, this.$insertRight);
7462 this.setPosition(point.row, point.column, true);
7463 };
7464
7465 function $pointsInOrder(point1, point2, equalPointsInOrder) {
7466 var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
7467 return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
7468 }
7469
7470 function $getTransformedPoint(delta, point, moveIfEqual) {
7471 var deltaIsInsert = delta.action == "insert";
7472 var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
7473 var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
7474 var deltaStart = delta.start;
7475 var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
7476 if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
7477 return {
7478 row: point.row,
7479 column: point.column
7480 };
7481 }
7482 if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
7483 return {
7484 row: point.row + deltaRowShift,
7485 column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
7486 };
7487 }
7488
7489 return {
7490 row: deltaStart.row,
7491 column: deltaStart.column
7492 };
7493 }
7494 this.setPosition = function(row, column, noClip) {
7495 var pos;
7496 if (noClip) {
7497 pos = {
7498 row: row,
7499 column: column
7500 };
7501 } else {
7502 pos = this.$clipPositionToDocument(row, column);
7503 }
7504
7505 if (this.row == pos.row && this.column == pos.column)
7506 return;
7507
7508 var old = {
7509 row: this.row,
7510 column: this.column
7511 };
7512
7513 this.row = pos.row;
7514 this.column = pos.column;
7515 this._signal("change", {
7516 old: old,
7517 value: pos
7518 });
7519 };
7520 this.detach = function() {
7521 this.document.removeEventListener("change", this.$onChange);
7522 };
7523 this.attach = function(doc) {
7524 this.document = doc || this.document;
7525 this.document.on("change", this.$onChange);
7526 };
7527 this.$clipPositionToDocument = function(row, column) {
7528 var pos = {};
7529
7530 if (row >= this.document.getLength()) {
7531 pos.row = Math.max(0, this.document.getLength() - 1);
7532 pos.column = this.document.getLine(pos.row).length;
7533 }
7534 else if (row < 0) {
7535 pos.row = 0;
7536 pos.column = 0;
7537 }
7538 else {
7539 pos.row = row;
7540 pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
7541 }
7542
7543 if (column < 0)
7544 pos.column = 0;
7545
7546 return pos;
7547 };
7548
7549 }).call(Anchor.prototype);
7550
7551 });
7552
7553 ace.define("ace/document",["require","exports","module","ace/lib/oop","ace/apply_delta","ace/lib/event_emitter","ace/range","ace/anchor"], function(acequire, exports, module) {
7554
7555 var oop = acequire("./lib/oop");
7556 var applyDelta = acequire("./apply_delta").applyDelta;
7557 var EventEmitter = acequire("./lib/event_emitter").EventEmitter;
7558 var Range = acequire("./range").Range;
7559 var Anchor = acequire("./anchor").Anchor;
7560
7561 var Document = function(textOrLines) {
7562 this.$lines = [""];
7563 if (textOrLines.length === 0) {
7564 this.$lines = [""];
7565 } else if (Array.isArray(textOrLines)) {
7566 this.insertMergedLines({row: 0, column: 0}, textOrLines);
7567 } else {
7568 this.insert({row: 0, column:0}, textOrLines);
7569 }
7570 };
7571
7572 (function() {
7573
7574 oop.implement(this, EventEmitter);
7575 this.setValue = function(text) {
7576 var len = this.getLength() - 1;
7577 this.remove(new Range(0, 0, len, this.getLine(len).length));
7578 this.insert({row: 0, column: 0}, text);
7579 };
7580 this.getValue = function() {
7581 return this.getAllLines().join(this.getNewLineCharacter());
7582 };
7583 this.createAnchor = function(row, column) {
7584 return new Anchor(this, row, column);
7585 };
7586 if ("aaa".split(/a/).length === 0) {
7587 this.$split = function(text) {
7588 return text.replace(/\r\n|\r/g, "\n").split("\n");
7589 };
7590 } else {
7591 this.$split = function(text) {
7592 return text.split(/\r\n|\r|\n/);
7593 };
7594 }
7595
7596
7597 this.$detectNewLine = function(text) {
7598 var match = text.match(/^.*?(\r\n|\r|\n)/m);
7599 this.$autoNewLine = match ? match[1] : "\n";
7600 this._signal("changeNewLineMode");
7601 };
7602 this.getNewLineCharacter = function() {
7603 switch (this.$newLineMode) {
7604 case "windows":
7605 return "\r\n";
7606 case "unix":
7607 return "\n";
7608 default:
7609 return this.$autoNewLine || "\n";
7610 }
7611 };
7612
7613 this.$autoNewLine = "";
7614 this.$newLineMode = "auto";
7615 this.setNewLineMode = function(newLineMode) {
7616 if (this.$newLineMode === newLineMode)
7617 return;
7618
7619 this.$newLineMode = newLineMode;
7620 this._signal("changeNewLineMode");
7621 };
7622 this.getNewLineMode = function() {
7623 return this.$newLineMode;
7624 };
7625 this.isNewLine = function(text) {
7626 return (text == "\r\n" || text == "\r" || text == "\n");
7627 };
7628 this.getLine = function(row) {
7629 return this.$lines[row] || "";
7630 };
7631 this.getLines = function(firstRow, lastRow) {
7632 return this.$lines.slice(firstRow, lastRow + 1);
7633 };
7634 this.getAllLines = function() {
7635 return this.getLines(0, this.getLength());
7636 };
7637 this.getLength = function() {
7638 return this.$lines.length;
7639 };
7640 this.getTextRange = function(range) {
7641 return this.getLinesForRange(range).join(this.getNewLineCharacter());
7642 };
7643 this.getLinesForRange = function(range) {
7644 var lines;
7645 if (range.start.row === range.end.row) {
7646 lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
7647 } else {
7648 lines = this.getLines(range.start.row, range.end.row);
7649 lines[0] = (lines[0] || "").substring(range.start.column);
7650 var l = lines.length - 1;
7651 if (range.end.row - range.start.row == l)
7652 lines[l] = lines[l].substring(0, range.end.column);
7653 }
7654 return lines;
7655 };
7656 this.insertLines = function(row, lines) {
7657 console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
7658 return this.insertFullLines(row, lines);
7659 };
7660 this.removeLines = function(firstRow, lastRow) {
7661 console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
7662 return this.removeFullLines(firstRow, lastRow);
7663 };
7664 this.insertNewLine = function(position) {
7665 console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
7666 return this.insertMergedLines(position, ["", ""]);
7667 };
7668 this.insert = function(position, text) {
7669 if (this.getLength() <= 1)
7670 this.$detectNewLine(text);
7671
7672 return this.insertMergedLines(position, this.$split(text));
7673 };
7674 this.insertInLine = function(position, text) {
7675 var start = this.clippedPos(position.row, position.column);
7676 var end = this.pos(position.row, position.column + text.length);
7677
7678 this.applyDelta({
7679 start: start,
7680 end: end,
7681 action: "insert",
7682 lines: [text]
7683 }, true);
7684
7685 return this.clonePos(end);
7686 };
7687
7688 this.clippedPos = function(row, column) {
7689 var length = this.getLength();
7690 if (row === undefined) {
7691 row = length;
7692 } else if (row < 0) {
7693 row = 0;
7694 } else if (row >= length) {
7695 row = length - 1;
7696 column = undefined;
7697 }
7698 var line = this.getLine(row);
7699 if (column == undefined)
7700 column = line.length;
7701 column = Math.min(Math.max(column, 0), line.length);
7702 return {row: row, column: column};
7703 };
7704
7705 this.clonePos = function(pos) {
7706 return {row: pos.row, column: pos.column};
7707 };
7708
7709 this.pos = function(row, column) {
7710 return {row: row, column: column};
7711 };
7712
7713 this.$clipPosition = function(position) {
7714 var length = this.getLength();
7715 if (position.row >= length) {
7716 position.row = Math.max(0, length - 1);
7717 position.column = this.getLine(length - 1).length;
7718 } else {
7719 position.row = Math.max(0, position.row);
7720 position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
7721 }
7722 return position;
7723 };
7724 this.insertFullLines = function(row, lines) {
7725 row = Math.min(Math.max(row, 0), this.getLength());
7726 var column = 0;
7727 if (row < this.getLength()) {
7728 lines = lines.concat([""]);
7729 column = 0;
7730 } else {
7731 lines = [""].concat(lines);
7732 row--;
7733 column = this.$lines[row].length;
7734 }
7735 this.insertMergedLines({row: row, column: column}, lines);
7736 };
7737 this.insertMergedLines = function(position, lines) {
7738 var start = this.clippedPos(position.row, position.column);
7739 var end = {
7740 row: start.row + lines.length - 1,
7741 column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
7742 };
7743
7744 this.applyDelta({
7745 start: start,
7746 end: end,
7747 action: "insert",
7748 lines: lines
7749 });
7750
7751 return this.clonePos(end);
7752 };
7753 this.remove = function(range) {
7754 var start = this.clippedPos(range.start.row, range.start.column);
7755 var end = this.clippedPos(range.end.row, range.end.column);
7756 this.applyDelta({
7757 start: start,
7758 end: end,
7759 action: "remove",
7760 lines: this.getLinesForRange({start: start, end: end})
7761 });
7762 return this.clonePos(start);
7763 };
7764 this.removeInLine = function(row, startColumn, endColumn) {
7765 var start = this.clippedPos(row, startColumn);
7766 var end = this.clippedPos(row, endColumn);
7767
7768 this.applyDelta({
7769 start: start,
7770 end: end,
7771 action: "remove",
7772 lines: this.getLinesForRange({start: start, end: end})
7773 }, true);
7774
7775 return this.clonePos(start);
7776 };
7777 this.removeFullLines = function(firstRow, lastRow) {
7778 firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
7779 lastRow = Math.min(Math.max(0, lastRow ), this.getLength() - 1);
7780 var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
7781 var deleteLastNewLine = lastRow < this.getLength() - 1;
7782 var startRow = ( deleteFirstNewLine ? firstRow - 1 : firstRow );
7783 var startCol = ( deleteFirstNewLine ? this.getLine(startRow).length : 0 );
7784 var endRow = ( deleteLastNewLine ? lastRow + 1 : lastRow );
7785 var endCol = ( deleteLastNewLine ? 0 : this.getLine(endRow).length );
7786 var range = new Range(startRow, startCol, endRow, endCol);
7787 var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
7788
7789 this.applyDelta({
7790 start: range.start,
7791 end: range.end,
7792 action: "remove",
7793 lines: this.getLinesForRange(range)
7794 });
7795 return deletedLines;
7796 };
7797 this.removeNewLine = function(row) {
7798 if (row < this.getLength() - 1 && row >= 0) {
7799 this.applyDelta({
7800 start: this.pos(row, this.getLine(row).length),
7801 end: this.pos(row + 1, 0),
7802 action: "remove",
7803 lines: ["", ""]
7804 });
7805 }
7806 };
7807 this.replace = function(range, text) {
7808 if (!(range instanceof Range))
7809 range = Range.fromPoints(range.start, range.end);
7810 if (text.length === 0 && range.isEmpty())
7811 return range.start;
7812 if (text == this.getTextRange(range))
7813 return range.end;
7814
7815 this.remove(range);
7816 var end;
7817 if (text) {
7818 end = this.insert(range.start, text);
7819 }
7820 else {
7821 end = range.start;
7822 }
7823
7824 return end;
7825 };
7826 this.applyDeltas = function(deltas) {
7827 for (var i=0; i<deltas.length; i++) {
7828 this.applyDelta(deltas[i]);
7829 }
7830 };
7831 this.revertDeltas = function(deltas) {
7832 for (var i=deltas.length-1; i>=0; i--) {
7833 this.revertDelta(deltas[i]);
7834 }
7835 };
7836 this.applyDelta = function(delta, doNotValidate) {
7837 var isInsert = delta.action == "insert";
7838 if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
7839 : !Range.comparePoints(delta.start, delta.end)) {
7840 return;
7841 }
7842
7843 if (isInsert && delta.lines.length > 20000)
7844 this.$splitAndapplyLargeDelta(delta, 20000);
7845 applyDelta(this.$lines, delta, doNotValidate);
7846 this._signal("change", delta);
7847 };
7848
7849 this.$splitAndapplyLargeDelta = function(delta, MAX) {
7850 var lines = delta.lines;
7851 var l = lines.length;
7852 var row = delta.start.row;
7853 var column = delta.start.column;
7854 var from = 0, to = 0;
7855 do {
7856 from = to;
7857 to += MAX - 1;
7858 var chunk = lines.slice(from, to);
7859 if (to > l) {
7860 delta.lines = chunk;
7861 delta.start.row = row + from;
7862 delta.start.column = column;
7863 break;
7864 }
7865 chunk.push("");
7866 this.applyDelta({
7867 start: this.pos(row + from, column),
7868 end: this.pos(row + to, column = 0),
7869 action: delta.action,
7870 lines: chunk
7871 }, true);
7872 } while(true);
7873 };
7874 this.revertDelta = function(delta) {
7875 this.applyDelta({
7876 start: this.clonePos(delta.start),
7877 end: this.clonePos(delta.end),
7878 action: (delta.action == "insert" ? "remove" : "insert"),
7879 lines: delta.lines.slice()
7880 });
7881 };
7882 this.indexToPosition = function(index, startRow) {
7883 var lines = this.$lines || this.getAllLines();
7884 var newlineLength = this.getNewLineCharacter().length;
7885 for (var i = startRow || 0, l = lines.length; i < l; i++) {
7886 index -= lines[i].length + newlineLength;
7887 if (index < 0)
7888 return {row: i, column: index + lines[i].length + newlineLength};
7889 }
7890 return {row: l-1, column: lines[l-1].length};
7891 };
7892 this.positionToIndex = function(pos, startRow) {
7893 var lines = this.$lines || this.getAllLines();
7894 var newlineLength = this.getNewLineCharacter().length;
7895 var index = 0;
7896 var row = Math.min(pos.row, lines.length);
7897 for (var i = startRow || 0; i < row; ++i)
7898 index += lines[i].length + newlineLength;
7899
7900 return index + pos.column;
7901 };
7902
7903 }).call(Document.prototype);
7904
7905 exports.Document = Document;
7906 });
7907
7908 ace.define("ace/background_tokenizer",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(acequire, exports, module) {
7909
7910 var oop = acequire("./lib/oop");
7911 var EventEmitter = acequire("./lib/event_emitter").EventEmitter;
7912
7913 var BackgroundTokenizer = function(tokenizer, editor) {
7914 this.running = false;
7915 this.lines = [];
7916 this.states = [];
7917 this.currentLine = 0;
7918 this.tokenizer = tokenizer;
7919
7920 var self = this;
7921
7922 this.$worker = function() {
7923 if (!self.running) { return; }
7924
7925 var workerStart = new Date();
7926 var currentLine = self.currentLine;
7927 var endLine = -1;
7928 var doc = self.doc;
7929
7930 var startLine = currentLine;
7931 while (self.lines[currentLine])
7932 currentLine++;
7933
7934 var len = doc.getLength();
7935 var processedLines = 0;
7936 self.running = false;
7937 while (currentLine < len) {
7938 self.$tokenizeRow(currentLine);
7939 endLine = currentLine;
7940 do {
7941 currentLine++;
7942 } while (self.lines[currentLine]);
7943 processedLines ++;
7944 if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
7945 self.running = setTimeout(self.$worker, 20);
7946 break;
7947 }
7948 }
7949 self.currentLine = currentLine;
7950
7951 if (endLine == -1)
7952 endLine = currentLine;
7953
7954 if (startLine <= endLine)
7955 self.fireUpdateEvent(startLine, endLine);
7956 };
7957 };
7958
7959 (function(){
7960
7961 oop.implement(this, EventEmitter);
7962 this.setTokenizer = function(tokenizer) {
7963 this.tokenizer = tokenizer;
7964 this.lines = [];
7965 this.states = [];
7966
7967 this.start(0);
7968 };
7969 this.setDocument = function(doc) {
7970 this.doc = doc;
7971 this.lines = [];
7972 this.states = [];
7973
7974 this.stop();
7975 };
7976 this.fireUpdateEvent = function(firstRow, lastRow) {
7977 var data = {
7978 first: firstRow,
7979 last: lastRow
7980 };
7981 this._signal("update", {data: data});
7982 };
7983 this.start = function(startRow) {
7984 this.currentLine = Math.min(startRow || 0, this.currentLine, this.doc.getLength());
7985 this.lines.splice(this.currentLine, this.lines.length);
7986 this.states.splice(this.currentLine, this.states.length);
7987
7988 this.stop();
7989 this.running = setTimeout(this.$worker, 700);
7990 };
7991
7992 this.scheduleStart = function() {
7993 if (!this.running)
7994 this.running = setTimeout(this.$worker, 700);
7995 };
7996
7997 this.$updateOnChange = function(delta) {
7998 var startRow = delta.start.row;
7999 var len = delta.end.row - startRow;
8000
8001 if (len === 0) {
8002 this.lines[startRow] = null;
8003 } else if (delta.action == "remove") {
8004 this.lines.splice(startRow, len + 1, null);
8005 this.states.splice(startRow, len + 1, null);
8006 } else {
8007 var args = Array(len + 1);
8008 args.unshift(startRow, 1);
8009 this.lines.splice.apply(this.lines, args);
8010 this.states.splice.apply(this.states, args);
8011 }
8012
8013 this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength());
8014
8015 this.stop();
8016 };
8017 this.stop = function() {
8018 if (this.running)
8019 clearTimeout(this.running);
8020 this.running = false;
8021 };
8022 this.getTokens = function(row) {
8023 return this.lines[row] || this.$tokenizeRow(row);
8024 };
8025 this.getState = function(row) {
8026 if (this.currentLine == row)
8027 this.$tokenizeRow(row);
8028 return this.states[row] || "start";
8029 };
8030
8031 this.$tokenizeRow = function(row) {
8032 var line = this.doc.getLine(row);
8033 var state = this.states[row - 1];
8034
8035 var data = this.tokenizer.getLineTokens(line, state, row);
8036
8037 if (this.states[row] + "" !== data.state + "") {
8038 this.states[row] = data.state;
8039 this.lines[row + 1] = null;
8040 if (this.currentLine > row + 1)
8041 this.currentLine = row + 1;
8042 } else if (this.currentLine == row) {
8043 this.currentLine = row + 1;
8044 }
8045
8046 return this.lines[row] = data.tokens;
8047 };
8048
8049 }).call(BackgroundTokenizer.prototype);
8050
8051 exports.BackgroundTokenizer = BackgroundTokenizer;
8052 });
8053
8054 ace.define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(acequire, exports, module) {
8055
8056 var lang = acequire("./lib/lang");
8057 acequire("./lib/oop");
8058 var Range = acequire("./range").Range;
8059
8060 var SearchHighlight = function(regExp, clazz, type) {
8061 this.setRegexp(regExp);
8062 this.clazz = clazz;
8063 this.type = type || "text";
8064 };
8065
8066 (function() {
8067 this.MAX_RANGES = 500;
8068
8069 this.setRegexp = function(regExp) {
8070 if (this.regExp+"" == regExp+"")
8071 return;
8072 this.regExp = regExp;
8073 this.cache = [];
8074 };
8075
8076 this.update = function(html, markerLayer, session, config) {
8077 if (!this.regExp)
8078 return;
8079 var start = config.firstRow, end = config.lastRow;
8080
8081 for (var i = start; i <= end; i++) {
8082 var ranges = this.cache[i];
8083 if (ranges == null) {
8084 ranges = lang.getMatchOffsets(session.getLine(i), this.regExp);
8085 if (ranges.length > this.MAX_RANGES)
8086 ranges = ranges.slice(0, this.MAX_RANGES);
8087 ranges = ranges.map(function(match) {
8088 return new Range(i, match.offset, i, match.offset + match.length);
8089 });
8090 this.cache[i] = ranges.length ? ranges : "";
8091 }
8092
8093 for (var j = ranges.length; j --; ) {
8094 markerLayer.drawSingleLineMarker(
8095 html, ranges[j].toScreenRange(session), this.clazz, config);
8096 }
8097 }
8098 };
8099
8100 }).call(SearchHighlight.prototype);
8101
8102 exports.SearchHighlight = SearchHighlight;
8103 });
8104
8105 ace.define("ace/edit_session/fold_line",["require","exports","module","ace/range"], function(acequire, exports, module) {
8106
8107 var Range = acequire("../range").Range;
8108 function FoldLine(foldData, folds) {
8109 this.foldData = foldData;
8110 if (Array.isArray(folds)) {
8111 this.folds = folds;
8112 } else {
8113 folds = this.folds = [ folds ];
8114 }
8115
8116 var last = folds[folds.length - 1];
8117 this.range = new Range(folds[0].start.row, folds[0].start.column,
8118 last.end.row, last.end.column);
8119 this.start = this.range.start;
8120 this.end = this.range.end;
8121
8122 this.folds.forEach(function(fold) {
8123 fold.setFoldLine(this);
8124 }, this);
8125 }
8126
8127 (function() {
8128 this.shiftRow = function(shift) {
8129 this.start.row += shift;
8130 this.end.row += shift;
8131 this.folds.forEach(function(fold) {
8132 fold.start.row += shift;
8133 fold.end.row += shift;
8134 });
8135 };
8136
8137 this.addFold = function(fold) {
8138 if (fold.sameRow) {
8139 if (fold.start.row < this.startRow || fold.endRow > this.endRow) {
8140 throw new Error("Can't add a fold to this FoldLine as it has no connection");
8141 }
8142 this.folds.push(fold);
8143 this.folds.sort(function(a, b) {
8144 return -a.range.compareEnd(b.start.row, b.start.column);
8145 });
8146 if (this.range.compareEnd(fold.start.row, fold.start.column) > 0) {
8147 this.end.row = fold.end.row;
8148 this.end.column = fold.end.column;
8149 } else if (this.range.compareStart(fold.end.row, fold.end.column) < 0) {
8150 this.start.row = fold.start.row;
8151 this.start.column = fold.start.column;
8152 }
8153 } else if (fold.start.row == this.end.row) {
8154 this.folds.push(fold);
8155 this.end.row = fold.end.row;
8156 this.end.column = fold.end.column;
8157 } else if (fold.end.row == this.start.row) {
8158 this.folds.unshift(fold);
8159 this.start.row = fold.start.row;
8160 this.start.column = fold.start.column;
8161 } else {
8162 throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");
8163 }
8164 fold.foldLine = this;
8165 };
8166
8167 this.containsRow = function(row) {
8168 return row >= this.start.row && row <= this.end.row;
8169 };
8170
8171 this.walk = function(callback, endRow, endColumn) {
8172 var lastEnd = 0,
8173 folds = this.folds,
8174 fold,
8175 cmp, stop, isNewRow = true;
8176
8177 if (endRow == null) {
8178 endRow = this.end.row;
8179 endColumn = this.end.column;
8180 }
8181
8182 for (var i = 0; i < folds.length; i++) {
8183 fold = folds[i];
8184
8185 cmp = fold.range.compareStart(endRow, endColumn);
8186 if (cmp == -1) {
8187 callback(null, endRow, endColumn, lastEnd, isNewRow);
8188 return;
8189 }
8190
8191 stop = callback(null, fold.start.row, fold.start.column, lastEnd, isNewRow);
8192 stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
8193 if (stop || cmp === 0) {
8194 return;
8195 }
8196 isNewRow = !fold.sameRow;
8197 lastEnd = fold.end.column;
8198 }
8199 callback(null, endRow, endColumn, lastEnd, isNewRow);
8200 };
8201
8202 this.getNextFoldTo = function(row, column) {
8203 var fold, cmp;
8204 for (var i = 0; i < this.folds.length; i++) {
8205 fold = this.folds[i];
8206 cmp = fold.range.compareEnd(row, column);
8207 if (cmp == -1) {
8208 return {
8209 fold: fold,
8210 kind: "after"
8211 };
8212 } else if (cmp === 0) {
8213 return {
8214 fold: fold,
8215 kind: "inside"
8216 };
8217 }
8218 }
8219 return null;
8220 };
8221
8222 this.addRemoveChars = function(row, column, len) {
8223 var ret = this.getNextFoldTo(row, column),
8224 fold, folds;
8225 if (ret) {
8226 fold = ret.fold;
8227 if (ret.kind == "inside"
8228 && fold.start.column != column
8229 && fold.start.row != row)
8230 {
8231 window.console && window.console.log(row, column, fold);
8232 } else if (fold.start.row == row) {
8233 folds = this.folds;
8234 var i = folds.indexOf(fold);
8235 if (i === 0) {
8236 this.start.column += len;
8237 }
8238 for (i; i < folds.length; i++) {
8239 fold = folds[i];
8240 fold.start.column += len;
8241 if (!fold.sameRow) {
8242 return;
8243 }
8244 fold.end.column += len;
8245 }
8246 this.end.column += len;
8247 }
8248 }
8249 };
8250
8251 this.split = function(row, column) {
8252 var pos = this.getNextFoldTo(row, column);
8253
8254 if (!pos || pos.kind == "inside")
8255 return null;
8256
8257 var fold = pos.fold;
8258 var folds = this.folds;
8259 var foldData = this.foldData;
8260
8261 var i = folds.indexOf(fold);
8262 var foldBefore = folds[i - 1];
8263 this.end.row = foldBefore.end.row;
8264 this.end.column = foldBefore.end.column;
8265 folds = folds.splice(i, folds.length - i);
8266
8267 var newFoldLine = new FoldLine(foldData, folds);
8268 foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
8269 return newFoldLine;
8270 };
8271
8272 this.merge = function(foldLineNext) {
8273 var folds = foldLineNext.folds;
8274 for (var i = 0; i < folds.length; i++) {
8275 this.addFold(folds[i]);
8276 }
8277 var foldData = this.foldData;
8278 foldData.splice(foldData.indexOf(foldLineNext), 1);
8279 };
8280
8281 this.toString = function() {
8282 var ret = [this.range.toString() + ": [" ];
8283
8284 this.folds.forEach(function(fold) {
8285 ret.push(" " + fold.toString());
8286 });
8287 ret.push("]");
8288 return ret.join("\n");
8289 };
8290
8291 this.idxToPosition = function(idx) {
8292 var lastFoldEndColumn = 0;
8293
8294 for (var i = 0; i < this.folds.length; i++) {
8295 var fold = this.folds[i];
8296
8297 idx -= fold.start.column - lastFoldEndColumn;
8298 if (idx < 0) {
8299 return {
8300 row: fold.start.row,
8301 column: fold.start.column + idx
8302 };
8303 }
8304
8305 idx -= fold.placeholder.length;
8306 if (idx < 0) {
8307 return fold.start;
8308 }
8309
8310 lastFoldEndColumn = fold.end.column;
8311 }
8312
8313 return {
8314 row: this.end.row,
8315 column: this.end.column + idx
8316 };
8317 };
8318 }).call(FoldLine.prototype);
8319
8320 exports.FoldLine = FoldLine;
8321 });
8322
8323 ace.define("ace/range_list",["require","exports","module","ace/range"], function(acequire, exports, module) {
8324 var Range = acequire("./range").Range;
8325 var comparePoints = Range.comparePoints;
8326
8327 var RangeList = function() {
8328 this.ranges = [];
8329 };
8330
8331 (function() {
8332 this.comparePoints = comparePoints;
8333
8334 this.pointIndex = function(pos, excludeEdges, startIndex) {
8335 var list = this.ranges;
8336
8337 for (var i = startIndex || 0; i < list.length; i++) {
8338 var range = list[i];
8339 var cmpEnd = comparePoints(pos, range.end);
8340 if (cmpEnd > 0)
8341 continue;
8342 var cmpStart = comparePoints(pos, range.start);
8343 if (cmpEnd === 0)
8344 return excludeEdges && cmpStart !== 0 ? -i-2 : i;
8345 if (cmpStart > 0 || (cmpStart === 0 && !excludeEdges))
8346 return i;
8347
8348 return -i-1;
8349 }
8350 return -i - 1;
8351 };
8352
8353 this.add = function(range) {
8354 var excludeEdges = !range.isEmpty();
8355 var startIndex = this.pointIndex(range.start, excludeEdges);
8356 if (startIndex < 0)
8357 startIndex = -startIndex - 1;
8358
8359 var endIndex = this.pointIndex(range.end, excludeEdges, startIndex);
8360
8361 if (endIndex < 0)
8362 endIndex = -endIndex - 1;
8363 else
8364 endIndex++;
8365 return this.ranges.splice(startIndex, endIndex - startIndex, range);
8366 };
8367
8368 this.addList = function(list) {
8369 var removed = [];
8370 for (var i = list.length; i--; ) {
8371 removed.push.apply(removed, this.add(list[i]));
8372 }
8373 return removed;
8374 };
8375
8376 this.substractPoint = function(pos) {
8377 var i = this.pointIndex(pos);
8378
8379 if (i >= 0)
8380 return this.ranges.splice(i, 1);
8381 };
8382 this.merge = function() {
8383 var removed = [];
8384 var list = this.ranges;
8385
8386 list = list.sort(function(a, b) {
8387 return comparePoints(a.start, b.start);
8388 });
8389
8390 var next = list[0], range;
8391 for (var i = 1; i < list.length; i++) {
8392 range = next;
8393 next = list[i];
8394 var cmp = comparePoints(range.end, next.start);
8395 if (cmp < 0)
8396 continue;
8397
8398 if (cmp == 0 && !range.isEmpty() && !next.isEmpty())
8399 continue;
8400
8401 if (comparePoints(range.end, next.end) < 0) {
8402 range.end.row = next.end.row;
8403 range.end.column = next.end.column;
8404 }
8405
8406 list.splice(i, 1);
8407 removed.push(next);
8408 next = range;
8409 i--;
8410 }
8411
8412 this.ranges = list;
8413
8414 return removed;
8415 };
8416
8417 this.contains = function(row, column) {
8418 return this.pointIndex({row: row, column: column}) >= 0;
8419 };
8420
8421 this.containsPoint = function(pos) {
8422 return this.pointIndex(pos) >= 0;
8423 };
8424
8425 this.rangeAtPoint = function(pos) {
8426 var i = this.pointIndex(pos);
8427 if (i >= 0)
8428 return this.ranges[i];
8429 };
8430
8431
8432 this.clipRows = function(startRow, endRow) {
8433 var list = this.ranges;
8434 if (list[0].start.row > endRow || list[list.length - 1].start.row < startRow)
8435 return [];
8436
8437 var startIndex = this.pointIndex({row: startRow, column: 0});
8438 if (startIndex < 0)
8439 startIndex = -startIndex - 1;
8440 var endIndex = this.pointIndex({row: endRow, column: 0}, startIndex);
8441 if (endIndex < 0)
8442 endIndex = -endIndex - 1;
8443
8444 var clipped = [];
8445 for (var i = startIndex; i < endIndex; i++) {
8446 clipped.push(list[i]);
8447 }
8448 return clipped;
8449 };
8450
8451 this.removeAll = function() {
8452 return this.ranges.splice(0, this.ranges.length);
8453 };
8454
8455 this.attach = function(session) {
8456 if (this.session)
8457 this.detach();
8458
8459 this.session = session;
8460 this.onChange = this.$onChange.bind(this);
8461
8462 this.session.on('change', this.onChange);
8463 };
8464
8465 this.detach = function() {
8466 if (!this.session)
8467 return;
8468 this.session.removeListener('change', this.onChange);
8469 this.session = null;
8470 };
8471
8472 this.$onChange = function(delta) {
8473 if (delta.action == "insert"){
8474 var start = delta.start;
8475 var end = delta.end;
8476 } else {
8477 var end = delta.start;
8478 var start = delta.end;
8479 }
8480 var startRow = start.row;
8481 var endRow = end.row;
8482 var lineDif = endRow - startRow;
8483
8484 var colDiff = -start.column + end.column;
8485 var ranges = this.ranges;
8486
8487 for (var i = 0, n = ranges.length; i < n; i++) {
8488 var r = ranges[i];
8489 if (r.end.row < startRow)
8490 continue;
8491 if (r.start.row > startRow)
8492 break;
8493
8494 if (r.start.row == startRow && r.start.column >= start.column ) {
8495 if (r.start.column == start.column && this.$insertRight) ; else {
8496 r.start.column += colDiff;
8497 r.start.row += lineDif;
8498 }
8499 }
8500 if (r.end.row == startRow && r.end.column >= start.column) {
8501 if (r.end.column == start.column && this.$insertRight) {
8502 continue;
8503 }
8504 if (r.end.column == start.column && colDiff > 0 && i < n - 1) {
8505 if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column)
8506 r.end.column -= colDiff;
8507 }
8508 r.end.column += colDiff;
8509 r.end.row += lineDif;
8510 }
8511 }
8512
8513 if (lineDif != 0 && i < n) {
8514 for (; i < n; i++) {
8515 var r = ranges[i];
8516 r.start.row += lineDif;
8517 r.end.row += lineDif;
8518 }
8519 }
8520 };
8521
8522 }).call(RangeList.prototype);
8523
8524 exports.RangeList = RangeList;
8525 });
8526
8527 ace.define("ace/edit_session/fold",["require","exports","module","ace/range","ace/range_list","ace/lib/oop"], function(acequire, exports, module) {
8528
8529 acequire("../range").Range;
8530 var RangeList = acequire("../range_list").RangeList;
8531 var oop = acequire("../lib/oop");
8532 var Fold = exports.Fold = function(range, placeholder) {
8533 this.foldLine = null;
8534 this.placeholder = placeholder;
8535 this.range = range;
8536 this.start = range.start;
8537 this.end = range.end;
8538
8539 this.sameRow = range.start.row == range.end.row;
8540 this.subFolds = this.ranges = [];
8541 };
8542
8543 oop.inherits(Fold, RangeList);
8544
8545 (function() {
8546
8547 this.toString = function() {
8548 return '"' + this.placeholder + '" ' + this.range.toString();
8549 };
8550
8551 this.setFoldLine = function(foldLine) {
8552 this.foldLine = foldLine;
8553 this.subFolds.forEach(function(fold) {
8554 fold.setFoldLine(foldLine);
8555 });
8556 };
8557
8558 this.clone = function() {
8559 var range = this.range.clone();
8560 var fold = new Fold(range, this.placeholder);
8561 this.subFolds.forEach(function(subFold) {
8562 fold.subFolds.push(subFold.clone());
8563 });
8564 fold.collapseChildren = this.collapseChildren;
8565 return fold;
8566 };
8567
8568 this.addSubFold = function(fold) {
8569 if (this.range.isEqual(fold))
8570 return;
8571
8572 if (!this.range.containsRange(fold))
8573 throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
8574 consumeRange(fold, this.start);
8575
8576 var row = fold.start.row, column = fold.start.column;
8577 for (var i = 0, cmp = -1; i < this.subFolds.length; i++) {
8578 cmp = this.subFolds[i].range.compare(row, column);
8579 if (cmp != 1)
8580 break;
8581 }
8582 var afterStart = this.subFolds[i];
8583
8584 if (cmp == 0)
8585 return afterStart.addSubFold(fold);
8586 var row = fold.range.end.row, column = fold.range.end.column;
8587 for (var j = i, cmp = -1; j < this.subFolds.length; j++) {
8588 cmp = this.subFolds[j].range.compare(row, column);
8589 if (cmp != 1)
8590 break;
8591 }
8592 this.subFolds[j];
8593
8594 if (cmp == 0)
8595 throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
8596
8597 this.subFolds.splice(i, j - i, fold);
8598 fold.setFoldLine(this.foldLine);
8599
8600 return fold;
8601 };
8602
8603 this.restoreRange = function(range) {
8604 return restoreRange(range, this.start);
8605 };
8606
8607 }).call(Fold.prototype);
8608
8609 function consumePoint(point, anchor) {
8610 point.row -= anchor.row;
8611 if (point.row == 0)
8612 point.column -= anchor.column;
8613 }
8614 function consumeRange(range, anchor) {
8615 consumePoint(range.start, anchor);
8616 consumePoint(range.end, anchor);
8617 }
8618 function restorePoint(point, anchor) {
8619 if (point.row == 0)
8620 point.column += anchor.column;
8621 point.row += anchor.row;
8622 }
8623 function restoreRange(range, anchor) {
8624 restorePoint(range.start, anchor);
8625 restorePoint(range.end, anchor);
8626 }
8627
8628 });
8629
8630 ace.define("ace/edit_session/folding",["require","exports","module","ace/range","ace/edit_session/fold_line","ace/edit_session/fold","ace/token_iterator"], function(acequire, exports, module) {
8631
8632 var Range = acequire("../range").Range;
8633 var FoldLine = acequire("./fold_line").FoldLine;
8634 var Fold = acequire("./fold").Fold;
8635 var TokenIterator = acequire("../token_iterator").TokenIterator;
8636
8637 function Folding() {
8638 this.getFoldAt = function(row, column, side) {
8639 var foldLine = this.getFoldLine(row);
8640 if (!foldLine)
8641 return null;
8642
8643 var folds = foldLine.folds;
8644 for (var i = 0; i < folds.length; i++) {
8645 var fold = folds[i];
8646 if (fold.range.contains(row, column)) {
8647 if (side == 1 && fold.range.isEnd(row, column)) {
8648 continue;
8649 } else if (side == -1 && fold.range.isStart(row, column)) {
8650 continue;
8651 }
8652 return fold;
8653 }
8654 }
8655 };
8656 this.getFoldsInRange = function(range) {
8657 var start = range.start;
8658 var end = range.end;
8659 var foldLines = this.$foldData;
8660 var foundFolds = [];
8661
8662 start.column += 1;
8663 end.column -= 1;
8664
8665 for (var i = 0; i < foldLines.length; i++) {
8666 var cmp = foldLines[i].range.compareRange(range);
8667 if (cmp == 2) {
8668 continue;
8669 }
8670 else if (cmp == -2) {
8671 break;
8672 }
8673
8674 var folds = foldLines[i].folds;
8675 for (var j = 0; j < folds.length; j++) {
8676 var fold = folds[j];
8677 cmp = fold.range.compareRange(range);
8678 if (cmp == -2) {
8679 break;
8680 } else if (cmp == 2) {
8681 continue;
8682 } else
8683 if (cmp == 42) {
8684 break;
8685 }
8686 foundFolds.push(fold);
8687 }
8688 }
8689 start.column -= 1;
8690 end.column += 1;
8691
8692 return foundFolds;
8693 };
8694
8695 this.getFoldsInRangeList = function(ranges) {
8696 if (Array.isArray(ranges)) {
8697 var folds = [];
8698 ranges.forEach(function(range) {
8699 folds = folds.concat(this.getFoldsInRange(range));
8700 }, this);
8701 } else {
8702 var folds = this.getFoldsInRange(ranges);
8703 }
8704 return folds;
8705 };
8706 this.getAllFolds = function() {
8707 var folds = [];
8708 var foldLines = this.$foldData;
8709
8710 for (var i = 0; i < foldLines.length; i++)
8711 for (var j = 0; j < foldLines[i].folds.length; j++)
8712 folds.push(foldLines[i].folds[j]);
8713
8714 return folds;
8715 };
8716 this.getFoldStringAt = function(row, column, trim, foldLine) {
8717 foldLine = foldLine || this.getFoldLine(row);
8718 if (!foldLine)
8719 return null;
8720
8721 var lastFold = {
8722 end: { column: 0 }
8723 };
8724 var str, fold;
8725 for (var i = 0; i < foldLine.folds.length; i++) {
8726 fold = foldLine.folds[i];
8727 var cmp = fold.range.compareEnd(row, column);
8728 if (cmp == -1) {
8729 str = this
8730 .getLine(fold.start.row)
8731 .substring(lastFold.end.column, fold.start.column);
8732 break;
8733 }
8734 else if (cmp === 0) {
8735 return null;
8736 }
8737 lastFold = fold;
8738 }
8739 if (!str)
8740 str = this.getLine(fold.start.row).substring(lastFold.end.column);
8741
8742 if (trim == -1)
8743 return str.substring(0, column - lastFold.end.column);
8744 else if (trim == 1)
8745 return str.substring(column - lastFold.end.column);
8746 else
8747 return str;
8748 };
8749
8750 this.getFoldLine = function(docRow, startFoldLine) {
8751 var foldData = this.$foldData;
8752 var i = 0;
8753 if (startFoldLine)
8754 i = foldData.indexOf(startFoldLine);
8755 if (i == -1)
8756 i = 0;
8757 for (i; i < foldData.length; i++) {
8758 var foldLine = foldData[i];
8759 if (foldLine.start.row <= docRow && foldLine.end.row >= docRow) {
8760 return foldLine;
8761 } else if (foldLine.end.row > docRow) {
8762 return null;
8763 }
8764 }
8765 return null;
8766 };
8767 this.getNextFoldLine = function(docRow, startFoldLine) {
8768 var foldData = this.$foldData;
8769 var i = 0;
8770 if (startFoldLine)
8771 i = foldData.indexOf(startFoldLine);
8772 if (i == -1)
8773 i = 0;
8774 for (i; i < foldData.length; i++) {
8775 var foldLine = foldData[i];
8776 if (foldLine.end.row >= docRow) {
8777 return foldLine;
8778 }
8779 }
8780 return null;
8781 };
8782
8783 this.getFoldedRowCount = function(first, last) {
8784 var foldData = this.$foldData, rowCount = last-first+1;
8785 for (var i = 0; i < foldData.length; i++) {
8786 var foldLine = foldData[i],
8787 end = foldLine.end.row,
8788 start = foldLine.start.row;
8789 if (end >= last) {
8790 if (start < last) {
8791 if (start >= first)
8792 rowCount -= last-start;
8793 else
8794 rowCount = 0; // in one fold
8795 }
8796 break;
8797 } else if (end >= first){
8798 if (start >= first) // fold inside range
8799 rowCount -= end-start;
8800 else
8801 rowCount -= end-first+1;
8802 }
8803 }
8804 return rowCount;
8805 };
8806
8807 this.$addFoldLine = function(foldLine) {
8808 this.$foldData.push(foldLine);
8809 this.$foldData.sort(function(a, b) {
8810 return a.start.row - b.start.row;
8811 });
8812 return foldLine;
8813 };
8814 this.addFold = function(placeholder, range) {
8815 var foldData = this.$foldData;
8816 var added = false;
8817 var fold;
8818
8819 if (placeholder instanceof Fold)
8820 fold = placeholder;
8821 else {
8822 fold = new Fold(range, placeholder);
8823 fold.collapseChildren = range.collapseChildren;
8824 }
8825 this.$clipRangeToDocument(fold.range);
8826
8827 var startRow = fold.start.row;
8828 var startColumn = fold.start.column;
8829 var endRow = fold.end.row;
8830 var endColumn = fold.end.column;
8831 if (!(startRow < endRow ||
8832 startRow == endRow && startColumn <= endColumn - 2))
8833 throw new Error("The range has to be at least 2 characters width");
8834
8835 var startFold = this.getFoldAt(startRow, startColumn, 1);
8836 var endFold = this.getFoldAt(endRow, endColumn, -1);
8837 if (startFold && endFold == startFold)
8838 return startFold.addSubFold(fold);
8839
8840 if (startFold && !startFold.range.isStart(startRow, startColumn))
8841 this.removeFold(startFold);
8842
8843 if (endFold && !endFold.range.isEnd(endRow, endColumn))
8844 this.removeFold(endFold);
8845 var folds = this.getFoldsInRange(fold.range);
8846 if (folds.length > 0) {
8847 this.removeFolds(folds);
8848 folds.forEach(function(subFold) {
8849 fold.addSubFold(subFold);
8850 });
8851 }
8852
8853 for (var i = 0; i < foldData.length; i++) {
8854 var foldLine = foldData[i];
8855 if (endRow == foldLine.start.row) {
8856 foldLine.addFold(fold);
8857 added = true;
8858 break;
8859 } else if (startRow == foldLine.end.row) {
8860 foldLine.addFold(fold);
8861 added = true;
8862 if (!fold.sameRow) {
8863 var foldLineNext = foldData[i + 1];
8864 if (foldLineNext && foldLineNext.start.row == endRow) {
8865 foldLine.merge(foldLineNext);
8866 break;
8867 }
8868 }
8869 break;
8870 } else if (endRow <= foldLine.start.row) {
8871 break;
8872 }
8873 }
8874
8875 if (!added)
8876 foldLine = this.$addFoldLine(new FoldLine(this.$foldData, fold));
8877
8878 if (this.$useWrapMode)
8879 this.$updateWrapData(foldLine.start.row, foldLine.start.row);
8880 else
8881 this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row);
8882 this.$modified = true;
8883 this._signal("changeFold", { data: fold, action: "add" });
8884
8885 return fold;
8886 };
8887
8888 this.addFolds = function(folds) {
8889 folds.forEach(function(fold) {
8890 this.addFold(fold);
8891 }, this);
8892 };
8893
8894 this.removeFold = function(fold) {
8895 var foldLine = fold.foldLine;
8896 var startRow = foldLine.start.row;
8897 var endRow = foldLine.end.row;
8898
8899 var foldLines = this.$foldData;
8900 var folds = foldLine.folds;
8901 if (folds.length == 1) {
8902 foldLines.splice(foldLines.indexOf(foldLine), 1);
8903 } else
8904 if (foldLine.range.isEnd(fold.end.row, fold.end.column)) {
8905 folds.pop();
8906 foldLine.end.row = folds[folds.length - 1].end.row;
8907 foldLine.end.column = folds[folds.length - 1].end.column;
8908 } else
8909 if (foldLine.range.isStart(fold.start.row, fold.start.column)) {
8910 folds.shift();
8911 foldLine.start.row = folds[0].start.row;
8912 foldLine.start.column = folds[0].start.column;
8913 } else
8914 if (fold.sameRow) {
8915 folds.splice(folds.indexOf(fold), 1);
8916 } else
8917 {
8918 var newFoldLine = foldLine.split(fold.start.row, fold.start.column);
8919 folds = newFoldLine.folds;
8920 folds.shift();
8921 newFoldLine.start.row = folds[0].start.row;
8922 newFoldLine.start.column = folds[0].start.column;
8923 }
8924
8925 if (!this.$updating) {
8926 if (this.$useWrapMode)
8927 this.$updateWrapData(startRow, endRow);
8928 else
8929 this.$updateRowLengthCache(startRow, endRow);
8930 }
8931 this.$modified = true;
8932 this._signal("changeFold", { data: fold, action: "remove" });
8933 };
8934
8935 this.removeFolds = function(folds) {
8936 var cloneFolds = [];
8937 for (var i = 0; i < folds.length; i++) {
8938 cloneFolds.push(folds[i]);
8939 }
8940
8941 cloneFolds.forEach(function(fold) {
8942 this.removeFold(fold);
8943 }, this);
8944 this.$modified = true;
8945 };
8946
8947 this.expandFold = function(fold) {
8948 this.removeFold(fold);
8949 fold.subFolds.forEach(function(subFold) {
8950 fold.restoreRange(subFold);
8951 this.addFold(subFold);
8952 }, this);
8953 if (fold.collapseChildren > 0) {
8954 this.foldAll(fold.start.row+1, fold.end.row, fold.collapseChildren-1);
8955 }
8956 fold.subFolds = [];
8957 };
8958
8959 this.expandFolds = function(folds) {
8960 folds.forEach(function(fold) {
8961 this.expandFold(fold);
8962 }, this);
8963 };
8964
8965 this.unfold = function(location, expandInner) {
8966 var range, folds;
8967 if (location == null) {
8968 range = new Range(0, 0, this.getLength(), 0);
8969 expandInner = true;
8970 } else if (typeof location == "number")
8971 range = new Range(location, 0, location, this.getLine(location).length);
8972 else if ("row" in location)
8973 range = Range.fromPoints(location, location);
8974 else
8975 range = location;
8976
8977 folds = this.getFoldsInRangeList(range);
8978 if (expandInner) {
8979 this.removeFolds(folds);
8980 } else {
8981 var subFolds = folds;
8982 while (subFolds.length) {
8983 this.expandFolds(subFolds);
8984 subFolds = this.getFoldsInRangeList(range);
8985 }
8986 }
8987 if (folds.length)
8988 return folds;
8989 };
8990 this.isRowFolded = function(docRow, startFoldRow) {
8991 return !!this.getFoldLine(docRow, startFoldRow);
8992 };
8993
8994 this.getRowFoldEnd = function(docRow, startFoldRow) {
8995 var foldLine = this.getFoldLine(docRow, startFoldRow);
8996 return foldLine ? foldLine.end.row : docRow;
8997 };
8998
8999 this.getRowFoldStart = function(docRow, startFoldRow) {
9000 var foldLine = this.getFoldLine(docRow, startFoldRow);
9001 return foldLine ? foldLine.start.row : docRow;
9002 };
9003
9004 this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
9005 if (startRow == null)
9006 startRow = foldLine.start.row;
9007 if (startColumn == null)
9008 startColumn = 0;
9009 if (endRow == null)
9010 endRow = foldLine.end.row;
9011 if (endColumn == null)
9012 endColumn = this.getLine(endRow).length;
9013 var doc = this.doc;
9014 var textLine = "";
9015
9016 foldLine.walk(function(placeholder, row, column, lastColumn) {
9017 if (row < startRow)
9018 return;
9019 if (row == startRow) {
9020 if (column < startColumn)
9021 return;
9022 lastColumn = Math.max(startColumn, lastColumn);
9023 }
9024
9025 if (placeholder != null) {
9026 textLine += placeholder;
9027 } else {
9028 textLine += doc.getLine(row).substring(lastColumn, column);
9029 }
9030 }, endRow, endColumn);
9031 return textLine;
9032 };
9033
9034 this.getDisplayLine = function(row, endColumn, startRow, startColumn) {
9035 var foldLine = this.getFoldLine(row);
9036
9037 if (!foldLine) {
9038 var line;
9039 line = this.doc.getLine(row);
9040 return line.substring(startColumn || 0, endColumn || line.length);
9041 } else {
9042 return this.getFoldDisplayLine(
9043 foldLine, row, endColumn, startRow, startColumn);
9044 }
9045 };
9046
9047 this.$cloneFoldData = function() {
9048 var fd = [];
9049 fd = this.$foldData.map(function(foldLine) {
9050 var folds = foldLine.folds.map(function(fold) {
9051 return fold.clone();
9052 });
9053 return new FoldLine(fd, folds);
9054 });
9055
9056 return fd;
9057 };
9058
9059 this.toggleFold = function(tryToUnfold) {
9060 var selection = this.selection;
9061 var range = selection.getRange();
9062 var fold;
9063 var bracketPos;
9064
9065 if (range.isEmpty()) {
9066 var cursor = range.start;
9067 fold = this.getFoldAt(cursor.row, cursor.column);
9068
9069 if (fold) {
9070 this.expandFold(fold);
9071 return;
9072 } else if (bracketPos = this.findMatchingBracket(cursor)) {
9073 if (range.comparePoint(bracketPos) == 1) {
9074 range.end = bracketPos;
9075 } else {
9076 range.start = bracketPos;
9077 range.start.column++;
9078 range.end.column--;
9079 }
9080 } else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
9081 if (range.comparePoint(bracketPos) == 1)
9082 range.end = bracketPos;
9083 else
9084 range.start = bracketPos;
9085
9086 range.start.column++;
9087 } else {
9088 range = this.getCommentFoldRange(cursor.row, cursor.column) || range;
9089 }
9090 } else {
9091 var folds = this.getFoldsInRange(range);
9092 if (tryToUnfold && folds.length) {
9093 this.expandFolds(folds);
9094 return;
9095 } else if (folds.length == 1 ) {
9096 fold = folds[0];
9097 }
9098 }
9099
9100 if (!fold)
9101 fold = this.getFoldAt(range.start.row, range.start.column);
9102
9103 if (fold && fold.range.toString() == range.toString()) {
9104 this.expandFold(fold);
9105 return;
9106 }
9107
9108 var placeholder = "...";
9109 if (!range.isMultiLine()) {
9110 placeholder = this.getTextRange(range);
9111 if (placeholder.length < 4)
9112 return;
9113 placeholder = placeholder.trim().substring(0, 2) + "..";
9114 }
9115
9116 this.addFold(placeholder, range);
9117 };
9118
9119 this.getCommentFoldRange = function(row, column, dir) {
9120 var iterator = new TokenIterator(this, row, column);
9121 var token = iterator.getCurrentToken();
9122 var type = token.type;
9123 if (token && /^comment|string/.test(type)) {
9124 type = type.match(/comment|string/)[0];
9125 if (type == "comment")
9126 type += "|doc-start";
9127 var re = new RegExp(type);
9128 var range = new Range();
9129 if (dir != 1) {
9130 do {
9131 token = iterator.stepBackward();
9132 } while (token && re.test(token.type));
9133 iterator.stepForward();
9134 }
9135
9136 range.start.row = iterator.getCurrentTokenRow();
9137 range.start.column = iterator.getCurrentTokenColumn() + 2;
9138
9139 iterator = new TokenIterator(this, row, column);
9140
9141 if (dir != -1) {
9142 var lastRow = -1;
9143 do {
9144 token = iterator.stepForward();
9145 if (lastRow == -1) {
9146 var state = this.getState(iterator.$row);
9147 if (!re.test(state))
9148 lastRow = iterator.$row;
9149 } else if (iterator.$row > lastRow) {
9150 break;
9151 }
9152 } while (token && re.test(token.type));
9153 token = iterator.stepBackward();
9154 } else
9155 token = iterator.getCurrentToken();
9156
9157 range.end.row = iterator.getCurrentTokenRow();
9158 range.end.column = iterator.getCurrentTokenColumn() + token.value.length - 2;
9159 return range;
9160 }
9161 };
9162
9163 this.foldAll = function(startRow, endRow, depth) {
9164 if (depth == undefined)
9165 depth = 100000; // JSON.stringify doesn't hanle Infinity
9166 var foldWidgets = this.foldWidgets;
9167 if (!foldWidgets)
9168 return; // mode doesn't support folding
9169 endRow = endRow || this.getLength();
9170 startRow = startRow || 0;
9171 for (var row = startRow; row < endRow; row++) {
9172 if (foldWidgets[row] == null)
9173 foldWidgets[row] = this.getFoldWidget(row);
9174 if (foldWidgets[row] != "start")
9175 continue;
9176
9177 var range = this.getFoldWidgetRange(row);
9178 if (range && range.isMultiLine()
9179 && range.end.row <= endRow
9180 && range.start.row >= startRow
9181 ) {
9182 row = range.end.row;
9183 try {
9184 var fold = this.addFold("...", range);
9185 if (fold)
9186 fold.collapseChildren = depth;
9187 } catch(e) {}
9188 }
9189 }
9190 };
9191 this.$foldStyles = {
9192 "manual": 1,
9193 "markbegin": 1,
9194 "markbeginend": 1
9195 };
9196 this.$foldStyle = "markbegin";
9197 this.setFoldStyle = function(style) {
9198 if (!this.$foldStyles[style])
9199 throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]");
9200
9201 if (this.$foldStyle == style)
9202 return;
9203
9204 this.$foldStyle = style;
9205
9206 if (style == "manual")
9207 this.unfold();
9208 var mode = this.$foldMode;
9209 this.$setFolding(null);
9210 this.$setFolding(mode);
9211 };
9212
9213 this.$setFolding = function(foldMode) {
9214 if (this.$foldMode == foldMode)
9215 return;
9216
9217 this.$foldMode = foldMode;
9218
9219 this.off('change', this.$updateFoldWidgets);
9220 this.off('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
9221 this._signal("changeAnnotation");
9222
9223 if (!foldMode || this.$foldStyle == "manual") {
9224 this.foldWidgets = null;
9225 return;
9226 }
9227
9228 this.foldWidgets = [];
9229 this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle);
9230 this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
9231
9232 this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
9233 this.$tokenizerUpdateFoldWidgets = this.tokenizerUpdateFoldWidgets.bind(this);
9234 this.on('change', this.$updateFoldWidgets);
9235 this.on('tokenizerUpdate', this.$tokenizerUpdateFoldWidgets);
9236 };
9237
9238 this.getParentFoldRangeData = function (row, ignoreCurrent) {
9239 var fw = this.foldWidgets;
9240 if (!fw || (ignoreCurrent && fw[row]))
9241 return {};
9242
9243 var i = row - 1, firstRange;
9244 while (i >= 0) {
9245 var c = fw[i];
9246 if (c == null)
9247 c = fw[i] = this.getFoldWidget(i);
9248
9249 if (c == "start") {
9250 var range = this.getFoldWidgetRange(i);
9251 if (!firstRange)
9252 firstRange = range;
9253 if (range && range.end.row >= row)
9254 break;
9255 }
9256 i--;
9257 }
9258
9259 return {
9260 range: i !== -1 && range,
9261 firstRange: firstRange
9262 };
9263 };
9264
9265 this.onFoldWidgetClick = function(row, e) {
9266 e = e.domEvent;
9267 var options = {
9268 children: e.shiftKey,
9269 all: e.ctrlKey || e.metaKey,
9270 siblings: e.altKey
9271 };
9272
9273 var range = this.$toggleFoldWidget(row, options);
9274 if (!range) {
9275 var el = (e.target || e.srcElement);
9276 if (el && /ace_fold-widget/.test(el.className))
9277 el.className += " ace_invalid";
9278 }
9279 };
9280
9281 this.$toggleFoldWidget = function(row, options) {
9282 if (!this.getFoldWidget)
9283 return;
9284 var type = this.getFoldWidget(row);
9285 var line = this.getLine(row);
9286
9287 var dir = type === "end" ? -1 : 1;
9288 var fold = this.getFoldAt(row, dir === -1 ? 0 : line.length, dir);
9289
9290 if (fold) {
9291 if (options.children || options.all)
9292 this.removeFold(fold);
9293 else
9294 this.expandFold(fold);
9295 return fold;
9296 }
9297
9298 var range = this.getFoldWidgetRange(row, true);
9299 if (range && !range.isMultiLine()) {
9300 fold = this.getFoldAt(range.start.row, range.start.column, 1);
9301 if (fold && range.isEqual(fold.range)) {
9302 this.removeFold(fold);
9303 return fold;
9304 }
9305 }
9306
9307 if (options.siblings) {
9308 var data = this.getParentFoldRangeData(row);
9309 if (data.range) {
9310 var startRow = data.range.start.row + 1;
9311 var endRow = data.range.end.row;
9312 }
9313 this.foldAll(startRow, endRow, options.all ? 10000 : 0);
9314 } else if (options.children) {
9315 endRow = range ? range.end.row : this.getLength();
9316 this.foldAll(row + 1, endRow, options.all ? 10000 : 0);
9317 } else if (range) {
9318 if (options.all)
9319 range.collapseChildren = 10000;
9320 this.addFold("...", range);
9321 }
9322
9323 return range;
9324 };
9325
9326
9327
9328 this.toggleFoldWidget = function(toggleParent) {
9329 var row = this.selection.getCursor().row;
9330 row = this.getRowFoldStart(row);
9331 var range = this.$toggleFoldWidget(row, {});
9332
9333 if (range)
9334 return;
9335 var data = this.getParentFoldRangeData(row, true);
9336 range = data.range || data.firstRange;
9337
9338 if (range) {
9339 row = range.start.row;
9340 var fold = this.getFoldAt(row, this.getLine(row).length, 1);
9341
9342 if (fold) {
9343 this.removeFold(fold);
9344 } else {
9345 this.addFold("...", range);
9346 }
9347 }
9348 };
9349
9350 this.updateFoldWidgets = function(delta) {
9351 var firstRow = delta.start.row;
9352 var len = delta.end.row - firstRow;
9353
9354 if (len === 0) {
9355 this.foldWidgets[firstRow] = null;
9356 } else if (delta.action == 'remove') {
9357 this.foldWidgets.splice(firstRow, len + 1, null);
9358 } else {
9359 var args = Array(len + 1);
9360 args.unshift(firstRow, 1);
9361 this.foldWidgets.splice.apply(this.foldWidgets, args);
9362 }
9363 };
9364 this.tokenizerUpdateFoldWidgets = function(e) {
9365 var rows = e.data;
9366 if (rows.first != rows.last) {
9367 if (this.foldWidgets.length > rows.first)
9368 this.foldWidgets.splice(rows.first, this.foldWidgets.length);
9369 }
9370 };
9371 }
9372
9373 exports.Folding = Folding;
9374
9375 });
9376
9377 ace.define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"], function(acequire, exports, module) {
9378
9379 var TokenIterator = acequire("../token_iterator").TokenIterator;
9380 var Range = acequire("../range").Range;
9381
9382
9383 function BracketMatch() {
9384
9385 this.findMatchingBracket = function(position, chr) {
9386 if (position.column == 0) return null;
9387
9388 var charBeforeCursor = chr || this.getLine(position.row).charAt(position.column-1);
9389 if (charBeforeCursor == "") return null;
9390
9391 var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
9392 if (!match)
9393 return null;
9394
9395 if (match[1])
9396 return this.$findClosingBracket(match[1], position);
9397 else
9398 return this.$findOpeningBracket(match[2], position);
9399 };
9400
9401 this.getBracketRange = function(pos) {
9402 var line = this.getLine(pos.row);
9403 var before = true, range;
9404
9405 var chr = line.charAt(pos.column-1);
9406 var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
9407 if (!match) {
9408 chr = line.charAt(pos.column);
9409 pos = {row: pos.row, column: pos.column + 1};
9410 match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
9411 before = false;
9412 }
9413 if (!match)
9414 return null;
9415
9416 if (match[1]) {
9417 var bracketPos = this.$findClosingBracket(match[1], pos);
9418 if (!bracketPos)
9419 return null;
9420 range = Range.fromPoints(pos, bracketPos);
9421 if (!before) {
9422 range.end.column++;
9423 range.start.column--;
9424 }
9425 range.cursor = range.end;
9426 } else {
9427 var bracketPos = this.$findOpeningBracket(match[2], pos);
9428 if (!bracketPos)
9429 return null;
9430 range = Range.fromPoints(bracketPos, pos);
9431 if (!before) {
9432 range.start.column++;
9433 range.end.column--;
9434 }
9435 range.cursor = range.start;
9436 }
9437
9438 return range;
9439 };
9440
9441 this.$brackets = {
9442 ")": "(",
9443 "(": ")",
9444 "]": "[",
9445 "[": "]",
9446 "{": "}",
9447 "}": "{"
9448 };
9449
9450 this.$findOpeningBracket = function(bracket, position, typeRe) {
9451 var openBracket = this.$brackets[bracket];
9452 var depth = 1;
9453
9454 var iterator = new TokenIterator(this, position.row, position.column);
9455 var token = iterator.getCurrentToken();
9456 if (!token)
9457 token = iterator.stepForward();
9458 if (!token)
9459 return;
9460
9461 if (!typeRe){
9462 typeRe = new RegExp(
9463 "(\\.?" +
9464 token.type.replace(".", "\\.").replace("rparen", ".paren")
9465 .replace(/\b(?:end)\b/, "(?:start|begin|end)")
9466 + ")+"
9467 );
9468 }
9469 var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2;
9470 var value = token.value;
9471
9472 while (true) {
9473
9474 while (valueIndex >= 0) {
9475 var chr = value.charAt(valueIndex);
9476 if (chr == openBracket) {
9477 depth -= 1;
9478 if (depth == 0) {
9479 return {row: iterator.getCurrentTokenRow(),
9480 column: valueIndex + iterator.getCurrentTokenColumn()};
9481 }
9482 }
9483 else if (chr == bracket) {
9484 depth += 1;
9485 }
9486 valueIndex -= 1;
9487 }
9488 do {
9489 token = iterator.stepBackward();
9490 } while (token && !typeRe.test(token.type));
9491
9492 if (token == null)
9493 break;
9494
9495 value = token.value;
9496 valueIndex = value.length - 1;
9497 }
9498
9499 return null;
9500 };
9501
9502 this.$findClosingBracket = function(bracket, position, typeRe) {
9503 var closingBracket = this.$brackets[bracket];
9504 var depth = 1;
9505
9506 var iterator = new TokenIterator(this, position.row, position.column);
9507 var token = iterator.getCurrentToken();
9508 if (!token)
9509 token = iterator.stepForward();
9510 if (!token)
9511 return;
9512
9513 if (!typeRe){
9514 typeRe = new RegExp(
9515 "(\\.?" +
9516 token.type.replace(".", "\\.").replace("lparen", ".paren")
9517 .replace(/\b(?:start|begin)\b/, "(?:start|begin|end)")
9518 + ")+"
9519 );
9520 }
9521 var valueIndex = position.column - iterator.getCurrentTokenColumn();
9522
9523 while (true) {
9524
9525 var value = token.value;
9526 var valueLength = value.length;
9527 while (valueIndex < valueLength) {
9528 var chr = value.charAt(valueIndex);
9529 if (chr == closingBracket) {
9530 depth -= 1;
9531 if (depth == 0) {
9532 return {row: iterator.getCurrentTokenRow(),
9533 column: valueIndex + iterator.getCurrentTokenColumn()};
9534 }
9535 }
9536 else if (chr == bracket) {
9537 depth += 1;
9538 }
9539 valueIndex += 1;
9540 }
9541 do {
9542 token = iterator.stepForward();
9543 } while (token && !typeRe.test(token.type));
9544
9545 if (token == null)
9546 break;
9547
9548 valueIndex = 0;
9549 }
9550
9551 return null;
9552 };
9553 }
9554 exports.BracketMatch = BracketMatch;
9555
9556 });
9557
9558 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/edit_session/folding","ace/edit_session/bracket_match"], function(acequire, exports, module) {
9559
9560 var oop = acequire("./lib/oop");
9561 var lang = acequire("./lib/lang");
9562 var BidiHandler = acequire("./bidihandler").BidiHandler;
9563 var config = acequire("./config");
9564 var EventEmitter = acequire("./lib/event_emitter").EventEmitter;
9565 var Selection = acequire("./selection").Selection;
9566 var TextMode = acequire("./mode/text").Mode;
9567 var Range = acequire("./range").Range;
9568 var Document = acequire("./document").Document;
9569 var BackgroundTokenizer = acequire("./background_tokenizer").BackgroundTokenizer;
9570 var SearchHighlight = acequire("./search_highlight").SearchHighlight;
9571
9572 var EditSession = function(text, mode) {
9573 this.$breakpoints = [];
9574 this.$decorations = [];
9575 this.$frontMarkers = {};
9576 this.$backMarkers = {};
9577 this.$markerId = 1;
9578 this.$undoSelect = true;
9579
9580 this.$foldData = [];
9581 this.id = "session" + (++EditSession.$uid);
9582 this.$foldData.toString = function() {
9583 return this.join("\n");
9584 };
9585 this.on("changeFold", this.onChangeFold.bind(this));
9586 this.$onChange = this.onChange.bind(this);
9587
9588 if (typeof text != "object" || !text.getLine)
9589 text = new Document(text);
9590
9591 this.$bidiHandler = new BidiHandler(this);
9592 this.setDocument(text);
9593 this.selection = new Selection(this);
9594
9595 config.resetOptions(this);
9596 this.setMode(mode);
9597 config._signal("session", this);
9598 };
9599
9600
9601 EditSession.$uid = 0;
9602
9603 (function() {
9604
9605 oop.implement(this, EventEmitter);
9606 this.setDocument = function(doc) {
9607 if (this.doc)
9608 this.doc.removeListener("change", this.$onChange);
9609
9610 this.doc = doc;
9611 doc.on("change", this.$onChange);
9612
9613 if (this.bgTokenizer)
9614 this.bgTokenizer.setDocument(this.getDocument());
9615
9616 this.resetCaches();
9617 };
9618 this.getDocument = function() {
9619 return this.doc;
9620 };
9621 this.$resetRowCache = function(docRow) {
9622 if (!docRow) {
9623 this.$docRowCache = [];
9624 this.$screenRowCache = [];
9625 return;
9626 }
9627 var l = this.$docRowCache.length;
9628 var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
9629 if (l > i) {
9630 this.$docRowCache.splice(i, l);
9631 this.$screenRowCache.splice(i, l);
9632 }
9633 };
9634
9635 this.$getRowCacheIndex = function(cacheArray, val) {
9636 var low = 0;
9637 var hi = cacheArray.length - 1;
9638
9639 while (low <= hi) {
9640 var mid = (low + hi) >> 1;
9641 var c = cacheArray[mid];
9642
9643 if (val > c)
9644 low = mid + 1;
9645 else if (val < c)
9646 hi = mid - 1;
9647 else
9648 return mid;
9649 }
9650
9651 return low -1;
9652 };
9653
9654 this.resetCaches = function() {
9655 this.$modified = true;
9656 this.$wrapData = [];
9657 this.$rowLengthCache = [];
9658 this.$resetRowCache(0);
9659 if (this.bgTokenizer)
9660 this.bgTokenizer.start(0);
9661 };
9662
9663 this.onChangeFold = function(e) {
9664 var fold = e.data;
9665 this.$resetRowCache(fold.start.row);
9666 };
9667
9668 this.onChange = function(delta) {
9669 this.$modified = true;
9670 this.$bidiHandler.onChange(delta);
9671 this.$resetRowCache(delta.start.row);
9672
9673 var removedFolds = this.$updateInternalDataOnChange(delta);
9674 if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
9675 this.$deltasDoc.push(delta);
9676 if (removedFolds && removedFolds.length != 0) {
9677 this.$deltasFold.push({
9678 action: "removeFolds",
9679 folds: removedFolds
9680 });
9681 }
9682
9683 this.$informUndoManager.schedule();
9684 }
9685
9686 this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
9687 this._signal("change", delta);
9688 };
9689 this.setValue = function(text) {
9690 this.doc.setValue(text);
9691 this.selection.moveTo(0, 0);
9692
9693 this.$resetRowCache(0);
9694 this.$deltas = [];
9695 this.$deltasDoc = [];
9696 this.$deltasFold = [];
9697 this.setUndoManager(this.$undoManager);
9698 this.getUndoManager().reset();
9699 };
9700 this.getValue =
9701 this.toString = function() {
9702 return this.doc.getValue();
9703 };
9704 this.getSelection = function() {
9705 return this.selection;
9706 };
9707 this.getState = function(row) {
9708 return this.bgTokenizer.getState(row);
9709 };
9710 this.getTokens = function(row) {
9711 return this.bgTokenizer.getTokens(row);
9712 };
9713 this.getTokenAt = function(row, column) {
9714 var tokens = this.bgTokenizer.getTokens(row);
9715 var token, c = 0;
9716 if (column == null) {
9717 var i = tokens.length - 1;
9718 c = this.getLine(row).length;
9719 } else {
9720 for (var i = 0; i < tokens.length; i++) {
9721 c += tokens[i].value.length;
9722 if (c >= column)
9723 break;
9724 }
9725 }
9726 token = tokens[i];
9727 if (!token)
9728 return null;
9729 token.index = i;
9730 token.start = c - token.value.length;
9731 return token;
9732 };
9733 this.setUndoManager = function(undoManager) {
9734 this.$undoManager = undoManager;
9735 this.$deltas = [];
9736 this.$deltasDoc = [];
9737 this.$deltasFold = [];
9738
9739 if (this.$informUndoManager)
9740 this.$informUndoManager.cancel();
9741
9742 if (undoManager) {
9743 var self = this;
9744
9745 this.$syncInformUndoManager = function() {
9746 self.$informUndoManager.cancel();
9747
9748 if (self.$deltasFold.length) {
9749 self.$deltas.push({
9750 group: "fold",
9751 deltas: self.$deltasFold
9752 });
9753 self.$deltasFold = [];
9754 }
9755
9756 if (self.$deltasDoc.length) {
9757 self.$deltas.push({
9758 group: "doc",
9759 deltas: self.$deltasDoc
9760 });
9761 self.$deltasDoc = [];
9762 }
9763
9764 if (self.$deltas.length > 0) {
9765 undoManager.execute({
9766 action: "aceupdate",
9767 args: [self.$deltas, self],
9768 merge: self.mergeUndoDeltas
9769 });
9770 }
9771 self.mergeUndoDeltas = false;
9772 self.$deltas = [];
9773 };
9774 this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager);
9775 }
9776 };
9777 this.markUndoGroup = function() {
9778 if (this.$syncInformUndoManager)
9779 this.$syncInformUndoManager();
9780 };
9781
9782 this.$defaultUndoManager = {
9783 undo: function() {},
9784 redo: function() {},
9785 reset: function() {}
9786 };
9787 this.getUndoManager = function() {
9788 return this.$undoManager || this.$defaultUndoManager;
9789 };
9790 this.getTabString = function() {
9791 if (this.getUseSoftTabs()) {
9792 return lang.stringRepeat(" ", this.getTabSize());
9793 } else {
9794 return "\t";
9795 }
9796 };
9797 this.setUseSoftTabs = function(val) {
9798 this.setOption("useSoftTabs", val);
9799 };
9800 this.getUseSoftTabs = function() {
9801 return this.$useSoftTabs && !this.$mode.$indentWithTabs;
9802 };
9803 this.setTabSize = function(tabSize) {
9804 this.setOption("tabSize", tabSize);
9805 };
9806 this.getTabSize = function() {
9807 return this.$tabSize;
9808 };
9809 this.isTabStop = function(position) {
9810 return this.$useSoftTabs && (position.column % this.$tabSize === 0);
9811 };
9812 this.setNavigateWithinSoftTabs = function (navigateWithinSoftTabs) {
9813 this.setOption("navigateWithinSoftTabs", navigateWithinSoftTabs);
9814 };
9815 this.getNavigateWithinSoftTabs = function() {
9816 return this.$navigateWithinSoftTabs;
9817 };
9818
9819 this.$overwrite = false;
9820 this.setOverwrite = function(overwrite) {
9821 this.setOption("overwrite", overwrite);
9822 };
9823 this.getOverwrite = function() {
9824 return this.$overwrite;
9825 };
9826 this.toggleOverwrite = function() {
9827 this.setOverwrite(!this.$overwrite);
9828 };
9829 this.addGutterDecoration = function(row, className) {
9830 if (!this.$decorations[row])
9831 this.$decorations[row] = "";
9832 this.$decorations[row] += " " + className;
9833 this._signal("changeBreakpoint", {});
9834 };
9835 this.removeGutterDecoration = function(row, className) {
9836 this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, "");
9837 this._signal("changeBreakpoint", {});
9838 };
9839 this.getBreakpoints = function() {
9840 return this.$breakpoints;
9841 };
9842 this.setBreakpoints = function(rows) {
9843 this.$breakpoints = [];
9844 for (var i=0; i<rows.length; i++) {
9845 this.$breakpoints[rows[i]] = "ace_breakpoint";
9846 }
9847 this._signal("changeBreakpoint", {});
9848 };
9849 this.clearBreakpoints = function() {
9850 this.$breakpoints = [];
9851 this._signal("changeBreakpoint", {});
9852 };
9853 this.setBreakpoint = function(row, className) {
9854 if (className === undefined)
9855 className = "ace_breakpoint";
9856 if (className)
9857 this.$breakpoints[row] = className;
9858 else
9859 delete this.$breakpoints[row];
9860 this._signal("changeBreakpoint", {});
9861 };
9862 this.clearBreakpoint = function(row) {
9863 delete this.$breakpoints[row];
9864 this._signal("changeBreakpoint", {});
9865 };
9866 this.addMarker = function(range, clazz, type, inFront) {
9867 var id = this.$markerId++;
9868
9869 var marker = {
9870 range : range,
9871 type : type || "line",
9872 renderer: typeof type == "function" ? type : null,
9873 clazz : clazz,
9874 inFront: !!inFront,
9875 id: id
9876 };
9877
9878 if (inFront) {
9879 this.$frontMarkers[id] = marker;
9880 this._signal("changeFrontMarker");
9881 } else {
9882 this.$backMarkers[id] = marker;
9883 this._signal("changeBackMarker");
9884 }
9885
9886 return id;
9887 };
9888 this.addDynamicMarker = function(marker, inFront) {
9889 if (!marker.update)
9890 return;
9891 var id = this.$markerId++;
9892 marker.id = id;
9893 marker.inFront = !!inFront;
9894
9895 if (inFront) {
9896 this.$frontMarkers[id] = marker;
9897 this._signal("changeFrontMarker");
9898 } else {
9899 this.$backMarkers[id] = marker;
9900 this._signal("changeBackMarker");
9901 }
9902
9903 return marker;
9904 };
9905 this.removeMarker = function(markerId) {
9906 var marker = this.$frontMarkers[markerId] || this.$backMarkers[markerId];
9907 if (!marker)
9908 return;
9909
9910 var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
9911 if (marker) {
9912 delete (markers[markerId]);
9913 this._signal(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
9914 }
9915 };
9916 this.getMarkers = function(inFront) {
9917 return inFront ? this.$frontMarkers : this.$backMarkers;
9918 };
9919
9920 this.highlight = function(re) {
9921 if (!this.$searchHighlight) {
9922 var highlight = new SearchHighlight(null, "ace_selected-word", "text");
9923 this.$searchHighlight = this.addDynamicMarker(highlight);
9924 }
9925 this.$searchHighlight.setRegexp(re);
9926 };
9927 this.highlightLines = function(startRow, endRow, clazz, inFront) {
9928 if (typeof endRow != "number") {
9929 clazz = endRow;
9930 endRow = startRow;
9931 }
9932 if (!clazz)
9933 clazz = "ace_step";
9934
9935 var range = new Range(startRow, 0, endRow, Infinity);
9936 range.id = this.addMarker(range, clazz, "fullLine", inFront);
9937 return range;
9938 };
9939 this.setAnnotations = function(annotations) {
9940 this.$annotations = annotations;
9941 this._signal("changeAnnotation", {});
9942 };
9943 this.getAnnotations = function() {
9944 return this.$annotations || [];
9945 };
9946 this.clearAnnotations = function() {
9947 this.setAnnotations([]);
9948 };
9949 this.$detectNewLine = function(text) {
9950 var match = text.match(/^.*?(\r?\n)/m);
9951 if (match) {
9952 this.$autoNewLine = match[1];
9953 } else {
9954 this.$autoNewLine = "\n";
9955 }
9956 };
9957 this.getWordRange = function(row, column) {
9958 var line = this.getLine(row);
9959
9960 var inToken = false;
9961 if (column > 0)
9962 inToken = !!line.charAt(column - 1).match(this.tokenRe);
9963
9964 if (!inToken)
9965 inToken = !!line.charAt(column).match(this.tokenRe);
9966
9967 if (inToken)
9968 var re = this.tokenRe;
9969 else if (/^\s+$/.test(line.slice(column-1, column+1)))
9970 var re = /\s/;
9971 else
9972 var re = this.nonTokenRe;
9973
9974 var start = column;
9975 if (start > 0) {
9976 do {
9977 start--;
9978 }
9979 while (start >= 0 && line.charAt(start).match(re));
9980 start++;
9981 }
9982
9983 var end = column;
9984 while (end < line.length && line.charAt(end).match(re)) {
9985 end++;
9986 }
9987
9988 return new Range(row, start, row, end);
9989 };
9990 this.getAWordRange = function(row, column) {
9991 var wordRange = this.getWordRange(row, column);
9992 var line = this.getLine(wordRange.end.row);
9993
9994 while (line.charAt(wordRange.end.column).match(/[ \t]/)) {
9995 wordRange.end.column += 1;
9996 }
9997 return wordRange;
9998 };
9999 this.setNewLineMode = function(newLineMode) {
10000 this.doc.setNewLineMode(newLineMode);
10001 };
10002 this.getNewLineMode = function() {
10003 return this.doc.getNewLineMode();
10004 };
10005 this.setUseWorker = function(useWorker) { this.setOption("useWorker", useWorker); };
10006 this.getUseWorker = function() { return this.$useWorker; };
10007 this.onReloadTokenizer = function(e) {
10008 var rows = e.data;
10009 this.bgTokenizer.start(rows.first);
10010 this._signal("tokenizerUpdate", e);
10011 };
10012
10013 this.$modes = {};
10014 this.$mode = null;
10015 this.$modeId = null;
10016 this.setMode = function(mode, cb) {
10017 if (mode && typeof mode === "object") {
10018 if (mode.getTokenizer)
10019 return this.$onChangeMode(mode);
10020 var options = mode;
10021 var path = options.path;
10022 } else {
10023 path = mode || "ace/mode/text";
10024 }
10025 if (!this.$modes["ace/mode/text"])
10026 this.$modes["ace/mode/text"] = new TextMode();
10027
10028 if (this.$modes[path] && !options) {
10029 this.$onChangeMode(this.$modes[path]);
10030 cb && cb();
10031 return;
10032 }
10033 this.$modeId = path;
10034 config.loadModule(["mode", path], function(m) {
10035 if (this.$modeId !== path)
10036 return cb && cb();
10037 if (this.$modes[path] && !options) {
10038 this.$onChangeMode(this.$modes[path]);
10039 } else if (m && m.Mode) {
10040 m = new m.Mode(options);
10041 if (!options) {
10042 this.$modes[path] = m;
10043 m.$id = path;
10044 }
10045 this.$onChangeMode(m);
10046 }
10047 cb && cb();
10048 }.bind(this));
10049 if (!this.$mode)
10050 this.$onChangeMode(this.$modes["ace/mode/text"], true);
10051 };
10052
10053 this.$onChangeMode = function(mode, $isPlaceholder) {
10054 if (!$isPlaceholder)
10055 this.$modeId = mode.$id;
10056 if (this.$mode === mode)
10057 return;
10058
10059 this.$mode = mode;
10060
10061 this.$stopWorker();
10062
10063 if (this.$useWorker)
10064 this.$startWorker();
10065
10066 var tokenizer = mode.getTokenizer();
10067
10068 if(tokenizer.addEventListener !== undefined) {
10069 var onReloadTokenizer = this.onReloadTokenizer.bind(this);
10070 tokenizer.addEventListener("update", onReloadTokenizer);
10071 }
10072
10073 if (!this.bgTokenizer) {
10074 this.bgTokenizer = new BackgroundTokenizer(tokenizer);
10075 var _self = this;
10076 this.bgTokenizer.addEventListener("update", function(e) {
10077 _self._signal("tokenizerUpdate", e);
10078 });
10079 } else {
10080 this.bgTokenizer.setTokenizer(tokenizer);
10081 }
10082
10083 this.bgTokenizer.setDocument(this.getDocument());
10084
10085 this.tokenRe = mode.tokenRe;
10086 this.nonTokenRe = mode.nonTokenRe;
10087
10088
10089 if (!$isPlaceholder) {
10090 if (mode.attachToSession)
10091 mode.attachToSession(this);
10092 this.$options.wrapMethod.set.call(this, this.$wrapMethod);
10093 this.$setFolding(mode.foldingRules);
10094 this.bgTokenizer.start(0);
10095 this._emit("changeMode");
10096 }
10097 };
10098
10099 this.$stopWorker = function() {
10100 if (this.$worker) {
10101 this.$worker.terminate();
10102 this.$worker = null;
10103 }
10104 };
10105
10106 this.$startWorker = function() {
10107 try {
10108 this.$worker = this.$mode.createWorker(this);
10109 } catch (e) {
10110 config.warn("Could not load worker", e);
10111 this.$worker = null;
10112 }
10113 };
10114 this.getMode = function() {
10115 return this.$mode;
10116 };
10117
10118 this.$scrollTop = 0;
10119 this.setScrollTop = function(scrollTop) {
10120 if (this.$scrollTop === scrollTop || isNaN(scrollTop))
10121 return;
10122
10123 this.$scrollTop = scrollTop;
10124 this._signal("changeScrollTop", scrollTop);
10125 };
10126 this.getScrollTop = function() {
10127 return this.$scrollTop;
10128 };
10129
10130 this.$scrollLeft = 0;
10131 this.setScrollLeft = function(scrollLeft) {
10132 if (this.$scrollLeft === scrollLeft || isNaN(scrollLeft))
10133 return;
10134
10135 this.$scrollLeft = scrollLeft;
10136 this._signal("changeScrollLeft", scrollLeft);
10137 };
10138 this.getScrollLeft = function() {
10139 return this.$scrollLeft;
10140 };
10141 this.getScreenWidth = function() {
10142 this.$computeWidth();
10143 if (this.lineWidgets)
10144 return Math.max(this.getLineWidgetMaxWidth(), this.screenWidth);
10145 return this.screenWidth;
10146 };
10147
10148 this.getLineWidgetMaxWidth = function() {
10149 if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth;
10150 var width = 0;
10151 this.lineWidgets.forEach(function(w) {
10152 if (w && w.screenWidth > width)
10153 width = w.screenWidth;
10154 });
10155 return this.lineWidgetWidth = width;
10156 };
10157
10158 this.$computeWidth = function(force) {
10159 if (this.$modified || force) {
10160 this.$modified = false;
10161
10162 if (this.$useWrapMode)
10163 return this.screenWidth = this.$wrapLimit;
10164
10165 var lines = this.doc.getAllLines();
10166 var cache = this.$rowLengthCache;
10167 var longestScreenLine = 0;
10168 var foldIndex = 0;
10169 var foldLine = this.$foldData[foldIndex];
10170 var foldStart = foldLine ? foldLine.start.row : Infinity;
10171 var len = lines.length;
10172
10173 for (var i = 0; i < len; i++) {
10174 if (i > foldStart) {
10175 i = foldLine.end.row + 1;
10176 if (i >= len)
10177 break;
10178 foldLine = this.$foldData[foldIndex++];
10179 foldStart = foldLine ? foldLine.start.row : Infinity;
10180 }
10181
10182 if (cache[i] == null)
10183 cache[i] = this.$getStringScreenWidth(lines[i])[0];
10184
10185 if (cache[i] > longestScreenLine)
10186 longestScreenLine = cache[i];
10187 }
10188 this.screenWidth = longestScreenLine;
10189 }
10190 };
10191 this.getLine = function(row) {
10192 return this.doc.getLine(row);
10193 };
10194 this.getLines = function(firstRow, lastRow) {
10195 return this.doc.getLines(firstRow, lastRow);
10196 };
10197 this.getLength = function() {
10198 return this.doc.getLength();
10199 };
10200 this.getTextRange = function(range) {
10201 return this.doc.getTextRange(range || this.selection.getRange());
10202 };
10203 this.insert = function(position, text) {
10204 return this.doc.insert(position, text);
10205 };
10206 this.remove = function(range) {
10207 return this.doc.remove(range);
10208 };
10209 this.removeFullLines = function(firstRow, lastRow){
10210 return this.doc.removeFullLines(firstRow, lastRow);
10211 };
10212 this.undoChanges = function(deltas, dontSelect) {
10213 if (!deltas.length)
10214 return;
10215
10216 this.$fromUndo = true;
10217 var lastUndoRange = null;
10218 for (var i = deltas.length - 1; i != -1; i--) {
10219 var delta = deltas[i];
10220 if (delta.group == "doc") {
10221 this.doc.revertDeltas(delta.deltas);
10222 lastUndoRange =
10223 this.$getUndoSelection(delta.deltas, true, lastUndoRange);
10224 } else {
10225 delta.deltas.forEach(function(foldDelta) {
10226 this.addFolds(foldDelta.folds);
10227 }, this);
10228 }
10229 }
10230 this.$fromUndo = false;
10231 lastUndoRange &&
10232 this.$undoSelect &&
10233 !dontSelect &&
10234 this.selection.setSelectionRange(lastUndoRange);
10235 return lastUndoRange;
10236 };
10237 this.redoChanges = function(deltas, dontSelect) {
10238 if (!deltas.length)
10239 return;
10240
10241 this.$fromUndo = true;
10242 var lastUndoRange = null;
10243 for (var i = 0; i < deltas.length; i++) {
10244 var delta = deltas[i];
10245 if (delta.group == "doc") {
10246 this.doc.applyDeltas(delta.deltas);
10247 lastUndoRange =
10248 this.$getUndoSelection(delta.deltas, false, lastUndoRange);
10249 }
10250 }
10251 this.$fromUndo = false;
10252 lastUndoRange &&
10253 this.$undoSelect &&
10254 !dontSelect &&
10255 this.selection.setSelectionRange(lastUndoRange);
10256 return lastUndoRange;
10257 };
10258 this.setUndoSelect = function(enable) {
10259 this.$undoSelect = enable;
10260 };
10261
10262 this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
10263 function isInsert(delta) {
10264 return isUndo ? delta.action !== "insert" : delta.action === "insert";
10265 }
10266
10267 var delta = deltas[0];
10268 var range, point;
10269 if (isInsert(delta)) {
10270 range = Range.fromPoints(delta.start, delta.end);
10271 } else {
10272 range = Range.fromPoints(delta.start, delta.start);
10273 }
10274
10275 for (var i = 1; i < deltas.length; i++) {
10276 delta = deltas[i];
10277 if (isInsert(delta)) {
10278 point = delta.start;
10279 if (range.compare(point.row, point.column) == -1) {
10280 range.setStart(point);
10281 }
10282 point = delta.end;
10283 if (range.compare(point.row, point.column) == 1) {
10284 range.setEnd(point);
10285 }
10286 } else {
10287 point = delta.start;
10288 if (range.compare(point.row, point.column) == -1) {
10289 range = Range.fromPoints(delta.start, delta.start);
10290 }
10291 }
10292 }
10293 if (lastUndoRange != null) {
10294 if (Range.comparePoints(lastUndoRange.start, range.start) === 0) {
10295 lastUndoRange.start.column += range.end.column - range.start.column;
10296 lastUndoRange.end.column += range.end.column - range.start.column;
10297 }
10298
10299 var cmp = lastUndoRange.compareRange(range);
10300 if (cmp == 1) {
10301 range.setStart(lastUndoRange.start);
10302 } else if (cmp == -1) {
10303 range.setEnd(lastUndoRange.end);
10304 }
10305 }
10306
10307 return range;
10308 };
10309 this.replace = function(range, text) {
10310 return this.doc.replace(range, text);
10311 };
10312 this.moveText = function(fromRange, toPosition, copy) {
10313 var text = this.getTextRange(fromRange);
10314 var folds = this.getFoldsInRange(fromRange);
10315
10316 var toRange = Range.fromPoints(toPosition, toPosition);
10317 if (!copy) {
10318 this.remove(fromRange);
10319 var rowDiff = fromRange.start.row - fromRange.end.row;
10320 var collDiff = rowDiff ? -fromRange.end.column : fromRange.start.column - fromRange.end.column;
10321 if (collDiff) {
10322 if (toRange.start.row == fromRange.end.row && toRange.start.column > fromRange.end.column)
10323 toRange.start.column += collDiff;
10324 if (toRange.end.row == fromRange.end.row && toRange.end.column > fromRange.end.column)
10325 toRange.end.column += collDiff;
10326 }
10327 if (rowDiff && toRange.start.row >= fromRange.end.row) {
10328 toRange.start.row += rowDiff;
10329 toRange.end.row += rowDiff;
10330 }
10331 }
10332
10333 toRange.end = this.insert(toRange.start, text);
10334 if (folds.length) {
10335 var oldStart = fromRange.start;
10336 var newStart = toRange.start;
10337 var rowDiff = newStart.row - oldStart.row;
10338 var collDiff = newStart.column - oldStart.column;
10339 this.addFolds(folds.map(function(x) {
10340 x = x.clone();
10341 if (x.start.row == oldStart.row)
10342 x.start.column += collDiff;
10343 if (x.end.row == oldStart.row)
10344 x.end.column += collDiff;
10345 x.start.row += rowDiff;
10346 x.end.row += rowDiff;
10347 return x;
10348 }));
10349 }
10350
10351 return toRange;
10352 };
10353 this.indentRows = function(startRow, endRow, indentString) {
10354 indentString = indentString.replace(/\t/g, this.getTabString());
10355 for (var row=startRow; row<=endRow; row++)
10356 this.doc.insertInLine({row: row, column: 0}, indentString);
10357 };
10358 this.outdentRows = function (range) {
10359 var rowRange = range.collapseRows();
10360 var deleteRange = new Range(0, 0, 0, 0);
10361 var size = this.getTabSize();
10362
10363 for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) {
10364 var line = this.getLine(i);
10365
10366 deleteRange.start.row = i;
10367 deleteRange.end.row = i;
10368 for (var j = 0; j < size; ++j)
10369 if (line.charAt(j) != ' ')
10370 break;
10371 if (j < size && line.charAt(j) == '\t') {
10372 deleteRange.start.column = j;
10373 deleteRange.end.column = j + 1;
10374 } else {
10375 deleteRange.start.column = 0;
10376 deleteRange.end.column = j;
10377 }
10378 this.remove(deleteRange);
10379 }
10380 };
10381
10382 this.$moveLines = function(firstRow, lastRow, dir) {
10383 firstRow = this.getRowFoldStart(firstRow);
10384 lastRow = this.getRowFoldEnd(lastRow);
10385 if (dir < 0) {
10386 var row = this.getRowFoldStart(firstRow + dir);
10387 if (row < 0) return 0;
10388 var diff = row-firstRow;
10389 } else if (dir > 0) {
10390 var row = this.getRowFoldEnd(lastRow + dir);
10391 if (row > this.doc.getLength()-1) return 0;
10392 var diff = row-lastRow;
10393 } else {
10394 firstRow = this.$clipRowToDocument(firstRow);
10395 lastRow = this.$clipRowToDocument(lastRow);
10396 var diff = lastRow - firstRow + 1;
10397 }
10398
10399 var range = new Range(firstRow, 0, lastRow, Number.MAX_VALUE);
10400 var folds = this.getFoldsInRange(range).map(function(x){
10401 x = x.clone();
10402 x.start.row += diff;
10403 x.end.row += diff;
10404 return x;
10405 });
10406
10407 var lines = dir == 0
10408 ? this.doc.getLines(firstRow, lastRow)
10409 : this.doc.removeFullLines(firstRow, lastRow);
10410 this.doc.insertFullLines(firstRow+diff, lines);
10411 folds.length && this.addFolds(folds);
10412 return diff;
10413 };
10414 this.moveLinesUp = function(firstRow, lastRow) {
10415 return this.$moveLines(firstRow, lastRow, -1);
10416 };
10417 this.moveLinesDown = function(firstRow, lastRow) {
10418 return this.$moveLines(firstRow, lastRow, 1);
10419 };
10420 this.duplicateLines = function(firstRow, lastRow) {
10421 return this.$moveLines(firstRow, lastRow, 0);
10422 };
10423
10424
10425 this.$clipRowToDocument = function(row) {
10426 return Math.max(0, Math.min(row, this.doc.getLength()-1));
10427 };
10428
10429 this.$clipColumnToRow = function(row, column) {
10430 if (column < 0)
10431 return 0;
10432 return Math.min(this.doc.getLine(row).length, column);
10433 };
10434
10435
10436 this.$clipPositionToDocument = function(row, column) {
10437 column = Math.max(0, column);
10438
10439 if (row < 0) {
10440 row = 0;
10441 column = 0;
10442 } else {
10443 var len = this.doc.getLength();
10444 if (row >= len) {
10445 row = len - 1;
10446 column = this.doc.getLine(len-1).length;
10447 } else {
10448 column = Math.min(this.doc.getLine(row).length, column);
10449 }
10450 }
10451
10452 return {
10453 row: row,
10454 column: column
10455 };
10456 };
10457
10458 this.$clipRangeToDocument = function(range) {
10459 if (range.start.row < 0) {
10460 range.start.row = 0;
10461 range.start.column = 0;
10462 } else {
10463 range.start.column = this.$clipColumnToRow(
10464 range.start.row,
10465 range.start.column
10466 );
10467 }
10468
10469 var len = this.doc.getLength() - 1;
10470 if (range.end.row > len) {
10471 range.end.row = len;
10472 range.end.column = this.doc.getLine(len).length;
10473 } else {
10474 range.end.column = this.$clipColumnToRow(
10475 range.end.row,
10476 range.end.column
10477 );
10478 }
10479 return range;
10480 };
10481 this.$wrapLimit = 80;
10482 this.$useWrapMode = false;
10483 this.$wrapLimitRange = {
10484 min : null,
10485 max : null
10486 };
10487 this.setUseWrapMode = function(useWrapMode) {
10488 if (useWrapMode != this.$useWrapMode) {
10489 this.$useWrapMode = useWrapMode;
10490 this.$modified = true;
10491 this.$resetRowCache(0);
10492 if (useWrapMode) {
10493 var len = this.getLength();
10494 this.$wrapData = Array(len);
10495 this.$updateWrapData(0, len - 1);
10496 }
10497
10498 this._signal("changeWrapMode");
10499 }
10500 };
10501 this.getUseWrapMode = function() {
10502 return this.$useWrapMode;
10503 };
10504 this.setWrapLimitRange = function(min, max) {
10505 if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) {
10506 this.$wrapLimitRange = { min: min, max: max };
10507 this.$modified = true;
10508 this.$bidiHandler.markAsDirty();
10509 if (this.$useWrapMode)
10510 this._signal("changeWrapMode");
10511 }
10512 };
10513 this.adjustWrapLimit = function(desiredLimit, $printMargin) {
10514 var limits = this.$wrapLimitRange;
10515 if (limits.max < 0)
10516 limits = {min: $printMargin, max: $printMargin};
10517 var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max);
10518 if (wrapLimit != this.$wrapLimit && wrapLimit > 1) {
10519 this.$wrapLimit = wrapLimit;
10520 this.$modified = true;
10521 if (this.$useWrapMode) {
10522 this.$updateWrapData(0, this.getLength() - 1);
10523 this.$resetRowCache(0);
10524 this._signal("changeWrapLimit");
10525 }
10526 return true;
10527 }
10528 return false;
10529 };
10530
10531 this.$constrainWrapLimit = function(wrapLimit, min, max) {
10532 if (min)
10533 wrapLimit = Math.max(min, wrapLimit);
10534
10535 if (max)
10536 wrapLimit = Math.min(max, wrapLimit);
10537
10538 return wrapLimit;
10539 };
10540 this.getWrapLimit = function() {
10541 return this.$wrapLimit;
10542 };
10543 this.setWrapLimit = function (limit) {
10544 this.setWrapLimitRange(limit, limit);
10545 };
10546 this.getWrapLimitRange = function() {
10547 return {
10548 min : this.$wrapLimitRange.min,
10549 max : this.$wrapLimitRange.max
10550 };
10551 };
10552
10553 this.$updateInternalDataOnChange = function(delta) {
10554 var useWrapMode = this.$useWrapMode;
10555 var action = delta.action;
10556 var start = delta.start;
10557 var end = delta.end;
10558 var firstRow = start.row;
10559 var lastRow = end.row;
10560 var len = lastRow - firstRow;
10561 var removedFolds = null;
10562
10563 this.$updating = true;
10564 if (len != 0) {
10565 if (action === "remove") {
10566 this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
10567
10568 var foldLines = this.$foldData;
10569 removedFolds = this.getFoldsInRange(delta);
10570 this.removeFolds(removedFolds);
10571
10572 var foldLine = this.getFoldLine(end.row);
10573 var idx = 0;
10574 if (foldLine) {
10575 foldLine.addRemoveChars(end.row, end.column, start.column - end.column);
10576 foldLine.shiftRow(-len);
10577
10578 var foldLineBefore = this.getFoldLine(firstRow);
10579 if (foldLineBefore && foldLineBefore !== foldLine) {
10580 foldLineBefore.merge(foldLine);
10581 foldLine = foldLineBefore;
10582 }
10583 idx = foldLines.indexOf(foldLine) + 1;
10584 }
10585
10586 for (idx; idx < foldLines.length; idx++) {
10587 var foldLine = foldLines[idx];
10588 if (foldLine.start.row >= end.row) {
10589 foldLine.shiftRow(-len);
10590 }
10591 }
10592
10593 lastRow = firstRow;
10594 } else {
10595 var args = Array(len);
10596 args.unshift(firstRow, 0);
10597 var arr = useWrapMode ? this.$wrapData : this.$rowLengthCache;
10598 arr.splice.apply(arr, args);
10599 var foldLines = this.$foldData;
10600 var foldLine = this.getFoldLine(firstRow);
10601 var idx = 0;
10602 if (foldLine) {
10603 var cmp = foldLine.range.compareInside(start.row, start.column);
10604 if (cmp == 0) {
10605 foldLine = foldLine.split(start.row, start.column);
10606 if (foldLine) {
10607 foldLine.shiftRow(len);
10608 foldLine.addRemoveChars(lastRow, 0, end.column - start.column);
10609 }
10610 } else
10611 if (cmp == -1) {
10612 foldLine.addRemoveChars(firstRow, 0, end.column - start.column);
10613 foldLine.shiftRow(len);
10614 }
10615 idx = foldLines.indexOf(foldLine) + 1;
10616 }
10617
10618 for (idx; idx < foldLines.length; idx++) {
10619 var foldLine = foldLines[idx];
10620 if (foldLine.start.row >= firstRow) {
10621 foldLine.shiftRow(len);
10622 }
10623 }
10624 }
10625 } else {
10626 len = Math.abs(delta.start.column - delta.end.column);
10627 if (action === "remove") {
10628 removedFolds = this.getFoldsInRange(delta);
10629 this.removeFolds(removedFolds);
10630
10631 len = -len;
10632 }
10633 var foldLine = this.getFoldLine(firstRow);
10634 if (foldLine) {
10635 foldLine.addRemoveChars(firstRow, start.column, len);
10636 }
10637 }
10638
10639 if (useWrapMode && this.$wrapData.length != this.doc.getLength()) {
10640 console.error("doc.getLength() and $wrapData.length have to be the same!");
10641 }
10642 this.$updating = false;
10643
10644 if (useWrapMode)
10645 this.$updateWrapData(firstRow, lastRow);
10646 else
10647 this.$updateRowLengthCache(firstRow, lastRow);
10648
10649 return removedFolds;
10650 };
10651
10652 this.$updateRowLengthCache = function(firstRow, lastRow, b) {
10653 this.$rowLengthCache[firstRow] = null;
10654 this.$rowLengthCache[lastRow] = null;
10655 };
10656
10657 this.$updateWrapData = function(firstRow, lastRow) {
10658 var lines = this.doc.getAllLines();
10659 var tabSize = this.getTabSize();
10660 var wrapData = this.$wrapData;
10661 var wrapLimit = this.$wrapLimit;
10662 var tokens;
10663 var foldLine;
10664
10665 var row = firstRow;
10666 lastRow = Math.min(lastRow, lines.length - 1);
10667 while (row <= lastRow) {
10668 foldLine = this.getFoldLine(row, foldLine);
10669 if (!foldLine) {
10670 tokens = this.$getDisplayTokens(lines[row]);
10671 wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
10672 row ++;
10673 } else {
10674 tokens = [];
10675 foldLine.walk(function(placeholder, row, column, lastColumn) {
10676 var walkTokens;
10677 if (placeholder != null) {
10678 walkTokens = this.$getDisplayTokens(
10679 placeholder, tokens.length);
10680 walkTokens[0] = PLACEHOLDER_START;
10681 for (var i = 1; i < walkTokens.length; i++) {
10682 walkTokens[i] = PLACEHOLDER_BODY;
10683 }
10684 } else {
10685 walkTokens = this.$getDisplayTokens(
10686 lines[row].substring(lastColumn, column),
10687 tokens.length);
10688 }
10689 tokens = tokens.concat(walkTokens);
10690 }.bind(this),
10691 foldLine.end.row,
10692 lines[foldLine.end.row].length + 1
10693 );
10694
10695 wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
10696 row = foldLine.end.row + 1;
10697 }
10698 }
10699 };
10700 var CHAR = 1,
10701 CHAR_EXT = 2,
10702 PLACEHOLDER_START = 3,
10703 PLACEHOLDER_BODY = 4,
10704 PUNCTUATION = 9,
10705 SPACE = 10,
10706 TAB = 11,
10707 TAB_SPACE = 12;
10708
10709
10710 this.$computeWrapSplits = function(tokens, wrapLimit, tabSize) {
10711 if (tokens.length == 0) {
10712 return [];
10713 }
10714
10715 var splits = [];
10716 var displayLength = tokens.length;
10717 var lastSplit = 0, lastDocSplit = 0;
10718
10719 var isCode = this.$wrapAsCode;
10720
10721 var indentedSoftWrap = this.$indentedSoftWrap;
10722 var maxIndent = wrapLimit <= Math.max(2 * tabSize, 8)
10723 || indentedSoftWrap === false ? 0 : Math.floor(wrapLimit / 2);
10724
10725 function getWrapIndent() {
10726 var indentation = 0;
10727 if (maxIndent === 0)
10728 return indentation;
10729 if (indentedSoftWrap) {
10730 for (var i = 0; i < tokens.length; i++) {
10731 var token = tokens[i];
10732 if (token == SPACE)
10733 indentation += 1;
10734 else if (token == TAB)
10735 indentation += tabSize;
10736 else if (token == TAB_SPACE)
10737 continue;
10738 else
10739 break;
10740 }
10741 }
10742 if (isCode && indentedSoftWrap !== false)
10743 indentation += tabSize;
10744 return Math.min(indentation, maxIndent);
10745 }
10746 function addSplit(screenPos) {
10747 var displayed = tokens.slice(lastSplit, screenPos);
10748 var len = displayed.length;
10749 displayed.join("")
10750 .replace(/12/g, function() {
10751 len -= 1;
10752 })
10753 .replace(/2/g, function() {
10754 len -= 1;
10755 });
10756
10757 if (!splits.length) {
10758 indent = getWrapIndent();
10759 splits.indent = indent;
10760 }
10761 lastDocSplit += len;
10762 splits.push(lastDocSplit);
10763 lastSplit = screenPos;
10764 }
10765 var indent = 0;
10766 while (displayLength - lastSplit > wrapLimit - indent) {
10767 var split = lastSplit + wrapLimit - indent;
10768 if (tokens[split - 1] >= SPACE && tokens[split] >= SPACE) {
10769 addSplit(split);
10770 continue;
10771 }
10772 if (tokens[split] == PLACEHOLDER_START || tokens[split] == PLACEHOLDER_BODY) {
10773 for (split; split != lastSplit - 1; split--) {
10774 if (tokens[split] == PLACEHOLDER_START) {
10775 break;
10776 }
10777 }
10778 if (split > lastSplit) {
10779 addSplit(split);
10780 continue;
10781 }
10782 split = lastSplit + wrapLimit;
10783 for (split; split < tokens.length; split++) {
10784 if (tokens[split] != PLACEHOLDER_BODY) {
10785 break;
10786 }
10787 }
10788 if (split == tokens.length) {
10789 break; // Breaks the while-loop.
10790 }
10791 addSplit(split);
10792 continue;
10793 }
10794 var minSplit = Math.max(split - (wrapLimit -(wrapLimit>>2)), lastSplit - 1);
10795 while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
10796 split --;
10797 }
10798 if (isCode) {
10799 while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
10800 split --;
10801 }
10802 while (split > minSplit && tokens[split] == PUNCTUATION) {
10803 split --;
10804 }
10805 } else {
10806 while (split > minSplit && tokens[split] < SPACE) {
10807 split --;
10808 }
10809 }
10810 if (split > minSplit) {
10811 addSplit(++split);
10812 continue;
10813 }
10814 split = lastSplit + wrapLimit;
10815 if (tokens[split] == CHAR_EXT)
10816 split--;
10817 addSplit(split - indent);
10818 }
10819 return splits;
10820 };
10821 this.$getDisplayTokens = function(str, offset) {
10822 var arr = [];
10823 var tabSize;
10824 offset = offset || 0;
10825
10826 for (var i = 0; i < str.length; i++) {
10827 var c = str.charCodeAt(i);
10828 if (c == 9) {
10829 tabSize = this.getScreenTabSize(arr.length + offset);
10830 arr.push(TAB);
10831 for (var n = 1; n < tabSize; n++) {
10832 arr.push(TAB_SPACE);
10833 }
10834 }
10835 else if (c == 32) {
10836 arr.push(SPACE);
10837 } else if((c > 39 && c < 48) || (c > 57 && c < 64)) {
10838 arr.push(PUNCTUATION);
10839 }
10840 else if (c >= 0x1100 && isFullWidth(c)) {
10841 arr.push(CHAR, CHAR_EXT);
10842 } else {
10843 arr.push(CHAR);
10844 }
10845 }
10846 return arr;
10847 };
10848 this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
10849 if (maxScreenColumn == 0)
10850 return [0, 0];
10851 if (maxScreenColumn == null)
10852 maxScreenColumn = Infinity;
10853 screenColumn = screenColumn || 0;
10854
10855 var c, column;
10856 for (column = 0; column < str.length; column++) {
10857 c = str.charCodeAt(column);
10858 if (c == 9) {
10859 screenColumn += this.getScreenTabSize(screenColumn);
10860 }
10861 else if (c >= 0x1100 && isFullWidth(c)) {
10862 screenColumn += 2;
10863 } else {
10864 screenColumn += 1;
10865 }
10866 if (screenColumn > maxScreenColumn) {
10867 break;
10868 }
10869 }
10870
10871 return [screenColumn, column];
10872 };
10873
10874 this.lineWidgets = null;
10875 this.getRowLength = function(row) {
10876 if (this.lineWidgets)
10877 var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
10878 else
10879 h = 0;
10880 if (!this.$useWrapMode || !this.$wrapData[row]) {
10881 return 1 + h;
10882 } else {
10883 return this.$wrapData[row].length + 1 + h;
10884 }
10885 };
10886 this.getRowLineCount = function(row) {
10887 if (!this.$useWrapMode || !this.$wrapData[row]) {
10888 return 1;
10889 } else {
10890 return this.$wrapData[row].length + 1;
10891 }
10892 };
10893
10894 this.getRowWrapIndent = function(screenRow) {
10895 if (this.$useWrapMode) {
10896 var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
10897 var splits = this.$wrapData[pos.row];
10898 return splits.length && splits[0] < pos.column ? splits.indent : 0;
10899 } else {
10900 return 0;
10901 }
10902 };
10903 this.getScreenLastRowColumn = function(screenRow) {
10904 var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
10905 return this.documentToScreenColumn(pos.row, pos.column);
10906 };
10907 this.getDocumentLastRowColumn = function(docRow, docColumn) {
10908 var screenRow = this.documentToScreenRow(docRow, docColumn);
10909 return this.getScreenLastRowColumn(screenRow);
10910 };
10911 this.getDocumentLastRowColumnPosition = function(docRow, docColumn) {
10912 var screenRow = this.documentToScreenRow(docRow, docColumn);
10913 return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10);
10914 };
10915 this.getRowSplitData = function(row) {
10916 if (!this.$useWrapMode) {
10917 return undefined;
10918 } else {
10919 return this.$wrapData[row];
10920 }
10921 };
10922 this.getScreenTabSize = function(screenColumn) {
10923 return this.$tabSize - screenColumn % this.$tabSize;
10924 };
10925
10926
10927 this.screenToDocumentRow = function(screenRow, screenColumn) {
10928 return this.screenToDocumentPosition(screenRow, screenColumn).row;
10929 };
10930
10931
10932 this.screenToDocumentColumn = function(screenRow, screenColumn) {
10933 return this.screenToDocumentPosition(screenRow, screenColumn).column;
10934 };
10935 this.screenToDocumentPosition = function(screenRow, screenColumn, offsetX) {
10936 if (screenRow < 0)
10937 return {row: 0, column: 0};
10938
10939 var line;
10940 var docRow = 0;
10941 var docColumn = 0;
10942 var column;
10943 var row = 0;
10944 var rowLength = 0;
10945
10946 var rowCache = this.$screenRowCache;
10947 var i = this.$getRowCacheIndex(rowCache, screenRow);
10948 var l = rowCache.length;
10949 if (l && i >= 0) {
10950 var row = rowCache[i];
10951 var docRow = this.$docRowCache[i];
10952 var doCache = screenRow > rowCache[l - 1];
10953 } else {
10954 var doCache = !l;
10955 }
10956
10957 var maxRow = this.getLength() - 1;
10958 var foldLine = this.getNextFoldLine(docRow);
10959 var foldStart = foldLine ? foldLine.start.row : Infinity;
10960
10961 while (row <= screenRow) {
10962 rowLength = this.getRowLength(docRow);
10963 if (row + rowLength > screenRow || docRow >= maxRow) {
10964 break;
10965 } else {
10966 row += rowLength;
10967 docRow++;
10968 if (docRow > foldStart) {
10969 docRow = foldLine.end.row+1;
10970 foldLine = this.getNextFoldLine(docRow, foldLine);
10971 foldStart = foldLine ? foldLine.start.row : Infinity;
10972 }
10973 }
10974
10975 if (doCache) {
10976 this.$docRowCache.push(docRow);
10977 this.$screenRowCache.push(row);
10978 }
10979 }
10980
10981 if (foldLine && foldLine.start.row <= docRow) {
10982 line = this.getFoldDisplayLine(foldLine);
10983 docRow = foldLine.start.row;
10984 } else if (row + rowLength <= screenRow || docRow > maxRow) {
10985 return {
10986 row: maxRow,
10987 column: this.getLine(maxRow).length
10988 };
10989 } else {
10990 line = this.getLine(docRow);
10991 foldLine = null;
10992 }
10993 var wrapIndent = 0, splitIndex = Math.floor(screenRow - row);
10994 if (this.$useWrapMode) {
10995 var splits = this.$wrapData[docRow];
10996 if (splits) {
10997 column = splits[splitIndex];
10998 if(splitIndex > 0 && splits.length) {
10999 wrapIndent = splits.indent;
11000 docColumn = splits[splitIndex - 1] || splits[splits.length - 1];
11001 line = line.substring(docColumn);
11002 }
11003 }
11004 }
11005
11006 if (offsetX !== undefined && this.$bidiHandler.isBidiRow(row + splitIndex, docRow, splitIndex))
11007 screenColumn = this.$bidiHandler.offsetToCol(offsetX);
11008
11009 docColumn += this.$getStringScreenWidth(line, screenColumn - wrapIndent)[1];
11010 if (this.$useWrapMode && docColumn >= column)
11011 docColumn = column - 1;
11012
11013 if (foldLine)
11014 return foldLine.idxToPosition(docColumn);
11015
11016 return {row: docRow, column: docColumn};
11017 };
11018 this.documentToScreenPosition = function(docRow, docColumn) {
11019 if (typeof docColumn === "undefined")
11020 var pos = this.$clipPositionToDocument(docRow.row, docRow.column);
11021 else
11022 pos = this.$clipPositionToDocument(docRow, docColumn);
11023
11024 docRow = pos.row;
11025 docColumn = pos.column;
11026
11027 var screenRow = 0;
11028 var foldStartRow = null;
11029 var fold = null;
11030 fold = this.getFoldAt(docRow, docColumn, 1);
11031 if (fold) {
11032 docRow = fold.start.row;
11033 docColumn = fold.start.column;
11034 }
11035
11036 var rowEnd, row = 0;
11037
11038
11039 var rowCache = this.$docRowCache;
11040 var i = this.$getRowCacheIndex(rowCache, docRow);
11041 var l = rowCache.length;
11042 if (l && i >= 0) {
11043 var row = rowCache[i];
11044 var screenRow = this.$screenRowCache[i];
11045 var doCache = docRow > rowCache[l - 1];
11046 } else {
11047 var doCache = !l;
11048 }
11049
11050 var foldLine = this.getNextFoldLine(row);
11051 var foldStart = foldLine ?foldLine.start.row :Infinity;
11052
11053 while (row < docRow) {
11054 if (row >= foldStart) {
11055 rowEnd = foldLine.end.row + 1;
11056 if (rowEnd > docRow)
11057 break;
11058 foldLine = this.getNextFoldLine(rowEnd, foldLine);
11059 foldStart = foldLine ?foldLine.start.row :Infinity;
11060 }
11061 else {
11062 rowEnd = row + 1;
11063 }
11064
11065 screenRow += this.getRowLength(row);
11066 row = rowEnd;
11067
11068 if (doCache) {
11069 this.$docRowCache.push(row);
11070 this.$screenRowCache.push(screenRow);
11071 }
11072 }
11073 var textLine = "";
11074 if (foldLine && row >= foldStart) {
11075 textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn);
11076 foldStartRow = foldLine.start.row;
11077 } else {
11078 textLine = this.getLine(docRow).substring(0, docColumn);
11079 foldStartRow = docRow;
11080 }
11081 var wrapIndent = 0;
11082 if (this.$useWrapMode) {
11083 var wrapRow = this.$wrapData[foldStartRow];
11084 if (wrapRow) {
11085 var screenRowOffset = 0;
11086 while (textLine.length >= wrapRow[screenRowOffset]) {
11087 screenRow ++;
11088 screenRowOffset++;
11089 }
11090 textLine = textLine.substring(
11091 wrapRow[screenRowOffset - 1] || 0, textLine.length
11092 );
11093 wrapIndent = screenRowOffset > 0 ? wrapRow.indent : 0;
11094 }
11095 }
11096
11097 return {
11098 row: screenRow,
11099 column: wrapIndent + this.$getStringScreenWidth(textLine)[0]
11100 };
11101 };
11102 this.documentToScreenColumn = function(row, docColumn) {
11103 return this.documentToScreenPosition(row, docColumn).column;
11104 };
11105 this.documentToScreenRow = function(docRow, docColumn) {
11106 return this.documentToScreenPosition(docRow, docColumn).row;
11107 };
11108 this.getScreenLength = function() {
11109 var screenRows = 0;
11110 var fold = null;
11111 if (!this.$useWrapMode) {
11112 screenRows = this.getLength();
11113 var foldData = this.$foldData;
11114 for (var i = 0; i < foldData.length; i++) {
11115 fold = foldData[i];
11116 screenRows -= fold.end.row - fold.start.row;
11117 }
11118 } else {
11119 var lastRow = this.$wrapData.length;
11120 var row = 0, i = 0;
11121 var fold = this.$foldData[i++];
11122 var foldStart = fold ? fold.start.row :Infinity;
11123
11124 while (row < lastRow) {
11125 var splits = this.$wrapData[row];
11126 screenRows += splits ? splits.length + 1 : 1;
11127 row ++;
11128 if (row > foldStart) {
11129 row = fold.end.row+1;
11130 fold = this.$foldData[i++];
11131 foldStart = fold ?fold.start.row :Infinity;
11132 }
11133 }
11134 }
11135 if (this.lineWidgets)
11136 screenRows += this.$getWidgetScreenLength();
11137
11138 return screenRows;
11139 };
11140 this.$setFontMetrics = function(fm) {
11141 if (!this.$enableVarChar) return;
11142 this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
11143 if (maxScreenColumn === 0)
11144 return [0, 0];
11145 if (!maxScreenColumn)
11146 maxScreenColumn = Infinity;
11147 screenColumn = screenColumn || 0;
11148
11149 var c, column;
11150 for (column = 0; column < str.length; column++) {
11151 c = str.charAt(column);
11152 if (c === "\t") {
11153 screenColumn += this.getScreenTabSize(screenColumn);
11154 } else {
11155 screenColumn += fm.getCharacterWidth(c);
11156 }
11157 if (screenColumn > maxScreenColumn) {
11158 break;
11159 }
11160 }
11161
11162 return [screenColumn, column];
11163 };
11164 };
11165
11166 this.destroy = function() {
11167 if (this.bgTokenizer) {
11168 this.bgTokenizer.setDocument(null);
11169 this.bgTokenizer = null;
11170 }
11171 this.$stopWorker();
11172 };
11173
11174 this.isFullWidth = isFullWidth;
11175 function isFullWidth(c) {
11176 if (c < 0x1100)
11177 return false;
11178 return c >= 0x1100 && c <= 0x115F ||
11179 c >= 0x11A3 && c <= 0x11A7 ||
11180 c >= 0x11FA && c <= 0x11FF ||
11181 c >= 0x2329 && c <= 0x232A ||
11182 c >= 0x2E80 && c <= 0x2E99 ||
11183 c >= 0x2E9B && c <= 0x2EF3 ||
11184 c >= 0x2F00 && c <= 0x2FD5 ||
11185 c >= 0x2FF0 && c <= 0x2FFB ||
11186 c >= 0x3000 && c <= 0x303E ||
11187 c >= 0x3041 && c <= 0x3096 ||
11188 c >= 0x3099 && c <= 0x30FF ||
11189 c >= 0x3105 && c <= 0x312D ||
11190 c >= 0x3131 && c <= 0x318E ||
11191 c >= 0x3190 && c <= 0x31BA ||
11192 c >= 0x31C0 && c <= 0x31E3 ||
11193 c >= 0x31F0 && c <= 0x321E ||
11194 c >= 0x3220 && c <= 0x3247 ||
11195 c >= 0x3250 && c <= 0x32FE ||
11196 c >= 0x3300 && c <= 0x4DBF ||
11197 c >= 0x4E00 && c <= 0xA48C ||
11198 c >= 0xA490 && c <= 0xA4C6 ||
11199 c >= 0xA960 && c <= 0xA97C ||
11200 c >= 0xAC00 && c <= 0xD7A3 ||
11201 c >= 0xD7B0 && c <= 0xD7C6 ||
11202 c >= 0xD7CB && c <= 0xD7FB ||
11203 c >= 0xF900 && c <= 0xFAFF ||
11204 c >= 0xFE10 && c <= 0xFE19 ||
11205 c >= 0xFE30 && c <= 0xFE52 ||
11206 c >= 0xFE54 && c <= 0xFE66 ||
11207 c >= 0xFE68 && c <= 0xFE6B ||
11208 c >= 0xFF01 && c <= 0xFF60 ||
11209 c >= 0xFFE0 && c <= 0xFFE6;
11210 }
11211
11212 }).call(EditSession.prototype);
11213
11214 acequire("./edit_session/folding").Folding.call(EditSession.prototype);
11215 acequire("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype);
11216
11217
11218 config.defineOptions(EditSession.prototype, "session", {
11219 wrap: {
11220 set: function(value) {
11221 if (!value || value == "off")
11222 value = false;
11223 else if (value == "free")
11224 value = true;
11225 else if (value == "printMargin")
11226 value = -1;
11227 else if (typeof value == "string")
11228 value = parseInt(value, 10) || false;
11229
11230 if (this.$wrap == value)
11231 return;
11232 this.$wrap = value;
11233 if (!value) {
11234 this.setUseWrapMode(false);
11235 } else {
11236 var col = typeof value == "number" ? value : null;
11237 this.setWrapLimitRange(col, col);
11238 this.setUseWrapMode(true);
11239 }
11240 },
11241 get: function() {
11242 if (this.getUseWrapMode()) {
11243 if (this.$wrap == -1)
11244 return "printMargin";
11245 if (!this.getWrapLimitRange().min)
11246 return "free";
11247 return this.$wrap;
11248 }
11249 return "off";
11250 },
11251 handlesSet: true
11252 },
11253 wrapMethod: {
11254 set: function(val) {
11255 val = val == "auto"
11256 ? this.$mode.type != "text"
11257 : val != "text";
11258 if (val != this.$wrapAsCode) {
11259 this.$wrapAsCode = val;
11260 if (this.$useWrapMode) {
11261 this.$modified = true;
11262 this.$resetRowCache(0);
11263 this.$updateWrapData(0, this.getLength() - 1);
11264 }
11265 }
11266 },
11267 initialValue: "auto"
11268 },
11269 indentedSoftWrap: { initialValue: true },
11270 firstLineNumber: {
11271 set: function() {this._signal("changeBreakpoint");},
11272 initialValue: 1
11273 },
11274 useWorker: {
11275 set: function(useWorker) {
11276 this.$useWorker = useWorker;
11277
11278 this.$stopWorker();
11279 if (useWorker)
11280 this.$startWorker();
11281 },
11282 initialValue: true
11283 },
11284 useSoftTabs: {initialValue: true},
11285 tabSize: {
11286 set: function(tabSize) {
11287 if (isNaN(tabSize) || this.$tabSize === tabSize) return;
11288
11289 this.$modified = true;
11290 this.$rowLengthCache = [];
11291 this.$tabSize = tabSize;
11292 this._signal("changeTabSize");
11293 },
11294 initialValue: 4,
11295 handlesSet: true
11296 },
11297 navigateWithinSoftTabs: {initialValue: false},
11298 overwrite: {
11299 set: function(val) {this._signal("changeOverwrite");},
11300 initialValue: false
11301 },
11302 newLineMode: {
11303 set: function(val) {this.doc.setNewLineMode(val);},
11304 get: function() {return this.doc.getNewLineMode();},
11305 handlesSet: true
11306 },
11307 mode: {
11308 set: function(val) { this.setMode(val); },
11309 get: function() { return this.$modeId; }
11310 }
11311 });
11312
11313 exports.EditSession = EditSession;
11314 });
11315
11316 ace.define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(acequire, exports, module) {
11317
11318 var lang = acequire("./lib/lang");
11319 var oop = acequire("./lib/oop");
11320 var Range = acequire("./range").Range;
11321
11322 var Search = function() {
11323 this.$options = {};
11324 };
11325
11326 (function() {
11327 this.set = function(options) {
11328 oop.mixin(this.$options, options);
11329 return this;
11330 };
11331 this.getOptions = function() {
11332 return lang.copyObject(this.$options);
11333 };
11334 this.setOptions = function(options) {
11335 this.$options = options;
11336 };
11337 this.find = function(session) {
11338 var options = this.$options;
11339 var iterator = this.$matchIterator(session, options);
11340 if (!iterator)
11341 return false;
11342
11343 var firstRange = null;
11344 iterator.forEach(function(sr, sc, er, ec) {
11345 firstRange = new Range(sr, sc, er, ec);
11346 if (sc == ec && options.start && options.start.start
11347 && options.skipCurrent != false && firstRange.isEqual(options.start)
11348 ) {
11349 firstRange = null;
11350 return false;
11351 }
11352
11353 return true;
11354 });
11355
11356 return firstRange;
11357 };
11358 this.findAll = function(session) {
11359 var options = this.$options;
11360 if (!options.needle)
11361 return [];
11362 this.$assembleRegExp(options);
11363
11364 var range = options.range;
11365 var lines = range
11366 ? session.getLines(range.start.row, range.end.row)
11367 : session.doc.getAllLines();
11368
11369 var ranges = [];
11370 var re = options.re;
11371 if (options.$isMultiLine) {
11372 var len = re.length;
11373 var maxRow = lines.length - len;
11374 var prevRange;
11375 outer: for (var row = re.offset || 0; row <= maxRow; row++) {
11376 for (var j = 0; j < len; j++)
11377 if (lines[row + j].search(re[j]) == -1)
11378 continue outer;
11379
11380 var startLine = lines[row];
11381 var line = lines[row + len - 1];
11382 var startIndex = startLine.length - startLine.match(re[0])[0].length;
11383 var endIndex = line.match(re[len - 1])[0].length;
11384
11385 if (prevRange && prevRange.end.row === row &&
11386 prevRange.end.column > startIndex
11387 ) {
11388 continue;
11389 }
11390 ranges.push(prevRange = new Range(
11391 row, startIndex, row + len - 1, endIndex
11392 ));
11393 if (len > 2)
11394 row = row + len - 2;
11395 }
11396 } else {
11397 for (var i = 0; i < lines.length; i++) {
11398 var matches = lang.getMatchOffsets(lines[i], re);
11399 for (var j = 0; j < matches.length; j++) {
11400 var match = matches[j];
11401 ranges.push(new Range(i, match.offset, i, match.offset + match.length));
11402 }
11403 }
11404 }
11405
11406 if (range) {
11407 var startColumn = range.start.column;
11408 var endColumn = range.start.column;
11409 var i = 0, j = ranges.length - 1;
11410 while (i < j && ranges[i].start.column < startColumn && ranges[i].start.row == range.start.row)
11411 i++;
11412
11413 while (i < j && ranges[j].end.column > endColumn && ranges[j].end.row == range.end.row)
11414 j--;
11415
11416 ranges = ranges.slice(i, j + 1);
11417 for (i = 0, j = ranges.length; i < j; i++) {
11418 ranges[i].start.row += range.start.row;
11419 ranges[i].end.row += range.start.row;
11420 }
11421 }
11422
11423 return ranges;
11424 };
11425 this.replace = function(input, replacement) {
11426 var options = this.$options;
11427
11428 var re = this.$assembleRegExp(options);
11429 if (options.$isMultiLine)
11430 return replacement;
11431
11432 if (!re)
11433 return;
11434
11435 var match = re.exec(input);
11436 if (!match || match[0].length != input.length)
11437 return null;
11438
11439 replacement = input.replace(re, replacement);
11440 if (options.preserveCase) {
11441 replacement = replacement.split("");
11442 for (var i = Math.min(input.length, input.length); i--; ) {
11443 var ch = input[i];
11444 if (ch && ch.toLowerCase() != ch)
11445 replacement[i] = replacement[i].toUpperCase();
11446 else
11447 replacement[i] = replacement[i].toLowerCase();
11448 }
11449 replacement = replacement.join("");
11450 }
11451
11452 return replacement;
11453 };
11454
11455 this.$assembleRegExp = function(options, $disableFakeMultiline) {
11456 if (options.needle instanceof RegExp)
11457 return options.re = options.needle;
11458
11459 var needle = options.needle;
11460
11461 if (!options.needle)
11462 return options.re = false;
11463
11464 if (!options.regExp)
11465 needle = lang.escapeRegExp(needle);
11466
11467 if (options.wholeWord)
11468 needle = addWordBoundary(needle, options);
11469
11470 var modifier = options.caseSensitive ? "gm" : "gmi";
11471
11472 options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle);
11473 if (options.$isMultiLine)
11474 return options.re = this.$assembleMultilineRegExp(needle, modifier);
11475
11476 try {
11477 var re = new RegExp(needle, modifier);
11478 } catch(e) {
11479 re = false;
11480 }
11481 return options.re = re;
11482 };
11483
11484 this.$assembleMultilineRegExp = function(needle, modifier) {
11485 var parts = needle.replace(/\r\n|\r|\n/g, "$\n^").split("\n");
11486 var re = [];
11487 for (var i = 0; i < parts.length; i++) try {
11488 re.push(new RegExp(parts[i], modifier));
11489 } catch(e) {
11490 return false;
11491 }
11492 return re;
11493 };
11494
11495 this.$matchIterator = function(session, options) {
11496 var re = this.$assembleRegExp(options);
11497 if (!re)
11498 return false;
11499 var backwards = options.backwards == true;
11500 var skipCurrent = options.skipCurrent != false;
11501
11502 var range = options.range;
11503 var start = options.start;
11504 if (!start)
11505 start = range ? range[backwards ? "end" : "start"] : session.selection.getRange();
11506
11507 if (start.start)
11508 start = start[skipCurrent != backwards ? "end" : "start"];
11509
11510 var firstRow = range ? range.start.row : 0;
11511 var lastRow = range ? range.end.row : session.getLength() - 1;
11512
11513 if (backwards) {
11514 var forEach = function(callback) {
11515 var row = start.row;
11516 if (forEachInLine(row, start.column, callback))
11517 return;
11518 for (row--; row >= firstRow; row--)
11519 if (forEachInLine(row, Number.MAX_VALUE, callback))
11520 return;
11521 if (options.wrap == false)
11522 return;
11523 for (row = lastRow, firstRow = start.row; row >= firstRow; row--)
11524 if (forEachInLine(row, Number.MAX_VALUE, callback))
11525 return;
11526 };
11527 }
11528 else {
11529 var forEach = function(callback) {
11530 var row = start.row;
11531 if (forEachInLine(row, start.column, callback))
11532 return;
11533 for (row = row + 1; row <= lastRow; row++)
11534 if (forEachInLine(row, 0, callback))
11535 return;
11536 if (options.wrap == false)
11537 return;
11538 for (row = firstRow, lastRow = start.row; row <= lastRow; row++)
11539 if (forEachInLine(row, 0, callback))
11540 return;
11541 };
11542 }
11543
11544 if (options.$isMultiLine) {
11545 var len = re.length;
11546 var forEachInLine = function(row, offset, callback) {
11547 var startRow = backwards ? row - len + 1 : row;
11548 if (startRow < 0) return;
11549 var line = session.getLine(startRow);
11550 var startIndex = line.search(re[0]);
11551 if (!backwards && startIndex < offset || startIndex === -1) return;
11552 for (var i = 1; i < len; i++) {
11553 line = session.getLine(startRow + i);
11554 if (line.search(re[i]) == -1)
11555 return;
11556 }
11557 var endIndex = line.match(re[len - 1])[0].length;
11558 if (backwards && endIndex > offset) return;
11559 if (callback(startRow, startIndex, startRow + len - 1, endIndex))
11560 return true;
11561 };
11562 }
11563 else if (backwards) {
11564 var forEachInLine = function(row, endIndex, callback) {
11565 var line = session.getLine(row);
11566 var matches = [];
11567 var m, last = 0;
11568 re.lastIndex = 0;
11569 while((m = re.exec(line))) {
11570 var length = m[0].length;
11571 last = m.index;
11572 if (!length) {
11573 if (last >= line.length) break;
11574 re.lastIndex = last += 1;
11575 }
11576 if (m.index + length > endIndex)
11577 break;
11578 matches.push(m.index, length);
11579 }
11580 for (var i = matches.length - 1; i >= 0; i -= 2) {
11581 var column = matches[i - 1];
11582 var length = matches[i];
11583 if (callback(row, column, row, column + length))
11584 return true;
11585 }
11586 };
11587 }
11588 else {
11589 var forEachInLine = function(row, startIndex, callback) {
11590 var line = session.getLine(row);
11591 var m;
11592 var last = startIndex;
11593 re.lastIndex = startIndex;
11594 while((m = re.exec(line))) {
11595 var length = m[0].length;
11596 last = m.index;
11597 if (callback(row, last, row,last + length))
11598 return true;
11599 if (!length) {
11600 re.lastIndex = last += 1;
11601 if (last >= line.length) return false;
11602 }
11603 }
11604 };
11605 }
11606 return {forEach: forEach};
11607 };
11608
11609 }).call(Search.prototype);
11610
11611 function addWordBoundary(needle, options) {
11612 function wordBoundary(c) {
11613 if (/\w/.test(c) || options.regExp) return "\\b";
11614 return "";
11615 }
11616 return wordBoundary(needle[0]) + needle
11617 + wordBoundary(needle[needle.length - 1]);
11618 }
11619
11620 exports.Search = Search;
11621 });
11622
11623 ace.define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(acequire, exports, module) {
11624
11625 var keyUtil = acequire("../lib/keys");
11626 var useragent = acequire("../lib/useragent");
11627 var KEY_MODS = keyUtil.KEY_MODS;
11628
11629 function HashHandler(config, platform) {
11630 this.platform = platform || (useragent.isMac ? "mac" : "win");
11631 this.commands = {};
11632 this.commandKeyBinding = {};
11633 this.addCommands(config);
11634 this.$singleCommand = true;
11635 }
11636
11637 function MultiHashHandler(config, platform) {
11638 HashHandler.call(this, config, platform);
11639 this.$singleCommand = false;
11640 }
11641
11642 MultiHashHandler.prototype = HashHandler.prototype;
11643
11644 (function() {
11645
11646
11647 this.addCommand = function(command) {
11648 if (this.commands[command.name])
11649 this.removeCommand(command);
11650
11651 this.commands[command.name] = command;
11652
11653 if (command.bindKey)
11654 this._buildKeyHash(command);
11655 };
11656
11657 this.removeCommand = function(command, keepCommand) {
11658 var name = command && (typeof command === 'string' ? command : command.name);
11659 command = this.commands[name];
11660 if (!keepCommand)
11661 delete this.commands[name];
11662 var ckb = this.commandKeyBinding;
11663 for (var keyId in ckb) {
11664 var cmdGroup = ckb[keyId];
11665 if (cmdGroup == command) {
11666 delete ckb[keyId];
11667 } else if (Array.isArray(cmdGroup)) {
11668 var i = cmdGroup.indexOf(command);
11669 if (i != -1) {
11670 cmdGroup.splice(i, 1);
11671 if (cmdGroup.length == 1)
11672 ckb[keyId] = cmdGroup[0];
11673 }
11674 }
11675 }
11676 };
11677
11678 this.bindKey = function(key, command, position) {
11679 if (typeof key == "object" && key) {
11680 if (position == undefined)
11681 position = key.position;
11682 key = key[this.platform];
11683 }
11684 if (!key)
11685 return;
11686 if (typeof command == "function")
11687 return this.addCommand({exec: command, bindKey: key, name: command.name || key});
11688
11689 key.split("|").forEach(function(keyPart) {
11690 var chain = "";
11691 if (keyPart.indexOf(" ") != -1) {
11692 var parts = keyPart.split(/\s+/);
11693 keyPart = parts.pop();
11694 parts.forEach(function(keyPart) {
11695 var binding = this.parseKeys(keyPart);
11696 var id = KEY_MODS[binding.hashId] + binding.key;
11697 chain += (chain ? " " : "") + id;
11698 this._addCommandToBinding(chain, "chainKeys");
11699 }, this);
11700 chain += " ";
11701 }
11702 var binding = this.parseKeys(keyPart);
11703 var id = KEY_MODS[binding.hashId] + binding.key;
11704 this._addCommandToBinding(chain + id, command, position);
11705 }, this);
11706 };
11707
11708 function getPosition(command) {
11709 return typeof command == "object" && command.bindKey
11710 && command.bindKey.position
11711 || (command.isDefault ? -100 : 0);
11712 }
11713 this._addCommandToBinding = function(keyId, command, position) {
11714 var ckb = this.commandKeyBinding, i;
11715 if (!command) {
11716 delete ckb[keyId];
11717 } else if (!ckb[keyId] || this.$singleCommand) {
11718 ckb[keyId] = command;
11719 } else {
11720 if (!Array.isArray(ckb[keyId])) {
11721 ckb[keyId] = [ckb[keyId]];
11722 } else if ((i = ckb[keyId].indexOf(command)) != -1) {
11723 ckb[keyId].splice(i, 1);
11724 }
11725
11726 if (typeof position != "number") {
11727 position = getPosition(command);
11728 }
11729
11730 var commands = ckb[keyId];
11731 for (i = 0; i < commands.length; i++) {
11732 var other = commands[i];
11733 var otherPos = getPosition(other);
11734 if (otherPos > position)
11735 break;
11736 }
11737 commands.splice(i, 0, command);
11738 }
11739 };
11740
11741 this.addCommands = function(commands) {
11742 commands && Object.keys(commands).forEach(function(name) {
11743 var command = commands[name];
11744 if (!command)
11745 return;
11746
11747 if (typeof command === "string")
11748 return this.bindKey(command, name);
11749
11750 if (typeof command === "function")
11751 command = { exec: command };
11752
11753 if (typeof command !== "object")
11754 return;
11755
11756 if (!command.name)
11757 command.name = name;
11758
11759 this.addCommand(command);
11760 }, this);
11761 };
11762
11763 this.removeCommands = function(commands) {
11764 Object.keys(commands).forEach(function(name) {
11765 this.removeCommand(commands[name]);
11766 }, this);
11767 };
11768
11769 this.bindKeys = function(keyList) {
11770 Object.keys(keyList).forEach(function(key) {
11771 this.bindKey(key, keyList[key]);
11772 }, this);
11773 };
11774
11775 this._buildKeyHash = function(command) {
11776 this.bindKey(command.bindKey, command);
11777 };
11778 this.parseKeys = function(keys) {
11779 var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x;});
11780 var key = parts.pop();
11781
11782 var keyCode = keyUtil[key];
11783 if (keyUtil.FUNCTION_KEYS[keyCode])
11784 key = keyUtil.FUNCTION_KEYS[keyCode].toLowerCase();
11785 else if (!parts.length)
11786 return {key: key, hashId: -1};
11787 else if (parts.length == 1 && parts[0] == "shift")
11788 return {key: key.toUpperCase(), hashId: -1};
11789
11790 var hashId = 0;
11791 for (var i = parts.length; i--;) {
11792 var modifier = keyUtil.KEY_MODS[parts[i]];
11793 if (modifier == null) {
11794 if (typeof console != "undefined")
11795 console.error("invalid modifier " + parts[i] + " in " + keys);
11796 return false;
11797 }
11798 hashId |= modifier;
11799 }
11800 return {key: key, hashId: hashId};
11801 };
11802
11803 this.findKeyCommand = function findKeyCommand(hashId, keyString) {
11804 var key = KEY_MODS[hashId] + keyString;
11805 return this.commandKeyBinding[key];
11806 };
11807
11808 this.handleKeyboard = function(data, hashId, keyString, keyCode) {
11809 if (keyCode < 0) return;
11810 var key = KEY_MODS[hashId] + keyString;
11811 var command = this.commandKeyBinding[key];
11812 if (data.$keyChain) {
11813 data.$keyChain += " " + key;
11814 command = this.commandKeyBinding[data.$keyChain] || command;
11815 }
11816
11817 if (command) {
11818 if (command == "chainKeys" || command[command.length - 1] == "chainKeys") {
11819 data.$keyChain = data.$keyChain || key;
11820 return {command: "null"};
11821 }
11822 }
11823
11824 if (data.$keyChain) {
11825 if ((!hashId || hashId == 4) && keyString.length == 1)
11826 data.$keyChain = data.$keyChain.slice(0, -key.length - 1); // wait for input
11827 else if (hashId == -1 || keyCode > 0)
11828 data.$keyChain = ""; // reset keyChain
11829 }
11830 return {command: command};
11831 };
11832
11833 this.getStatusText = function(editor, data) {
11834 return data.$keyChain || "";
11835 };
11836
11837 }).call(HashHandler.prototype);
11838
11839 exports.HashHandler = HashHandler;
11840 exports.MultiHashHandler = MultiHashHandler;
11841 });
11842
11843 ace.define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"], function(acequire, exports, module) {
11844
11845 var oop = acequire("../lib/oop");
11846 var MultiHashHandler = acequire("../keyboard/hash_handler").MultiHashHandler;
11847 var EventEmitter = acequire("../lib/event_emitter").EventEmitter;
11848
11849 var CommandManager = function(platform, commands) {
11850 MultiHashHandler.call(this, commands, platform);
11851 this.byName = this.commands;
11852 this.setDefaultHandler("exec", function(e) {
11853 return e.command.exec(e.editor, e.args || {});
11854 });
11855 };
11856
11857 oop.inherits(CommandManager, MultiHashHandler);
11858
11859 (function() {
11860
11861 oop.implement(this, EventEmitter);
11862
11863 this.exec = function(command, editor, args) {
11864 if (Array.isArray(command)) {
11865 for (var i = command.length; i--; ) {
11866 if (this.exec(command[i], editor, args)) return true;
11867 }
11868 return false;
11869 }
11870
11871 if (typeof command === "string")
11872 command = this.commands[command];
11873
11874 if (!command)
11875 return false;
11876
11877 if (editor && editor.$readOnly && !command.readOnly)
11878 return false;
11879
11880 if (command.isAvailable && !command.isAvailable(editor))
11881 return false;
11882
11883 var e = {editor: editor, command: command, args: args};
11884 e.returnValue = this._emit("exec", e);
11885 this._signal("afterExec", e);
11886
11887 return e.returnValue === false ? false : true;
11888 };
11889
11890 this.toggleRecording = function(editor) {
11891 if (this.$inReplay)
11892 return;
11893
11894 editor && editor._emit("changeStatus");
11895 if (this.recording) {
11896 this.macro.pop();
11897 this.removeEventListener("exec", this.$addCommandToMacro);
11898
11899 if (!this.macro.length)
11900 this.macro = this.oldMacro;
11901
11902 return this.recording = false;
11903 }
11904 if (!this.$addCommandToMacro) {
11905 this.$addCommandToMacro = function(e) {
11906 this.macro.push([e.command, e.args]);
11907 }.bind(this);
11908 }
11909
11910 this.oldMacro = this.macro;
11911 this.macro = [];
11912 this.on("exec", this.$addCommandToMacro);
11913 return this.recording = true;
11914 };
11915
11916 this.replay = function(editor) {
11917 if (this.$inReplay || !this.macro)
11918 return;
11919
11920 if (this.recording)
11921 return this.toggleRecording(editor);
11922
11923 try {
11924 this.$inReplay = true;
11925 this.macro.forEach(function(x) {
11926 if (typeof x == "string")
11927 this.exec(x, editor);
11928 else
11929 this.exec(x[0], editor, x[1]);
11930 }, this);
11931 } finally {
11932 this.$inReplay = false;
11933 }
11934 };
11935
11936 this.trimMacro = function(m) {
11937 return m.map(function(x){
11938 if (typeof x[0] != "string")
11939 x[0] = x[0].name;
11940 if (!x[1])
11941 x = x[0];
11942 return x;
11943 });
11944 };
11945
11946 }).call(CommandManager.prototype);
11947
11948 exports.CommandManager = CommandManager;
11949
11950 });
11951
11952 ace.define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"], function(acequire, exports, module) {
11953
11954 var lang = acequire("../lib/lang");
11955 var config = acequire("../config");
11956 var Range = acequire("../range").Range;
11957
11958 function bindKey(win, mac) {
11959 return {win: win, mac: mac};
11960 }
11961 exports.commands = [{
11962 name: "showSettingsMenu",
11963 bindKey: bindKey("Ctrl-,", "Command-,"),
11964 exec: function(editor) {
11965 config.loadModule("ace/ext/settings_menu", function(module) {
11966 module.init(editor);
11967 editor.showSettingsMenu();
11968 });
11969 },
11970 readOnly: true
11971 }, {
11972 name: "goToNextError",
11973 bindKey: bindKey("Alt-E", "F4"),
11974 exec: function(editor) {
11975 config.loadModule("ace/ext/error_marker", function(module) {
11976 module.showErrorMarker(editor, 1);
11977 });
11978 },
11979 scrollIntoView: "animate",
11980 readOnly: true
11981 }, {
11982 name: "goToPreviousError",
11983 bindKey: bindKey("Alt-Shift-E", "Shift-F4"),
11984 exec: function(editor) {
11985 config.loadModule("ace/ext/error_marker", function(module) {
11986 module.showErrorMarker(editor, -1);
11987 });
11988 },
11989 scrollIntoView: "animate",
11990 readOnly: true
11991 }, {
11992 name: "selectall",
11993 bindKey: bindKey("Ctrl-A", "Command-A"),
11994 exec: function(editor) { editor.selectAll(); },
11995 readOnly: true
11996 }, {
11997 name: "centerselection",
11998 bindKey: bindKey(null, "Ctrl-L"),
11999 exec: function(editor) { editor.centerSelection(); },
12000 readOnly: true
12001 }, {
12002 name: "gotoline",
12003 bindKey: bindKey("Ctrl-L", "Command-L"),
12004 exec: function(editor) {
12005 var line = parseInt(prompt("Enter line number:"), 10);
12006 if (!isNaN(line)) {
12007 editor.gotoLine(line);
12008 }
12009 },
12010 readOnly: true
12011 }, {
12012 name: "fold",
12013 bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
12014 exec: function(editor) { editor.session.toggleFold(false); },
12015 multiSelectAction: "forEach",
12016 scrollIntoView: "center",
12017 readOnly: true
12018 }, {
12019 name: "unfold",
12020 bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
12021 exec: function(editor) { editor.session.toggleFold(true); },
12022 multiSelectAction: "forEach",
12023 scrollIntoView: "center",
12024 readOnly: true
12025 }, {
12026 name: "toggleFoldWidget",
12027 bindKey: bindKey("F2", "F2"),
12028 exec: function(editor) { editor.session.toggleFoldWidget(); },
12029 multiSelectAction: "forEach",
12030 scrollIntoView: "center",
12031 readOnly: true
12032 }, {
12033 name: "toggleParentFoldWidget",
12034 bindKey: bindKey("Alt-F2", "Alt-F2"),
12035 exec: function(editor) { editor.session.toggleFoldWidget(true); },
12036 multiSelectAction: "forEach",
12037 scrollIntoView: "center",
12038 readOnly: true
12039 }, {
12040 name: "foldall",
12041 bindKey: bindKey(null, "Ctrl-Command-Option-0"),
12042 exec: function(editor) { editor.session.foldAll(); },
12043 scrollIntoView: "center",
12044 readOnly: true
12045 }, {
12046 name: "foldOther",
12047 bindKey: bindKey("Alt-0", "Command-Option-0"),
12048 exec: function(editor) {
12049 editor.session.foldAll();
12050 editor.session.unfold(editor.selection.getAllRanges());
12051 },
12052 scrollIntoView: "center",
12053 readOnly: true
12054 }, {
12055 name: "unfoldall",
12056 bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"),
12057 exec: function(editor) { editor.session.unfold(); },
12058 scrollIntoView: "center",
12059 readOnly: true
12060 }, {
12061 name: "findnext",
12062 bindKey: bindKey("Ctrl-K", "Command-G"),
12063 exec: function(editor) { editor.findNext(); },
12064 multiSelectAction: "forEach",
12065 scrollIntoView: "center",
12066 readOnly: true
12067 }, {
12068 name: "findprevious",
12069 bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
12070 exec: function(editor) { editor.findPrevious(); },
12071 multiSelectAction: "forEach",
12072 scrollIntoView: "center",
12073 readOnly: true
12074 }, {
12075 name: "selectOrFindNext",
12076 bindKey: bindKey("Alt-K", "Ctrl-G"),
12077 exec: function(editor) {
12078 if (editor.selection.isEmpty())
12079 editor.selection.selectWord();
12080 else
12081 editor.findNext();
12082 },
12083 readOnly: true
12084 }, {
12085 name: "selectOrFindPrevious",
12086 bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"),
12087 exec: function(editor) {
12088 if (editor.selection.isEmpty())
12089 editor.selection.selectWord();
12090 else
12091 editor.findPrevious();
12092 },
12093 readOnly: true
12094 }, {
12095 name: "find",
12096 bindKey: bindKey("Ctrl-F", "Command-F"),
12097 exec: function(editor) {
12098 config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor);});
12099 },
12100 readOnly: true
12101 }, {
12102 name: "overwrite",
12103 bindKey: "Insert",
12104 exec: function(editor) { editor.toggleOverwrite(); },
12105 readOnly: true
12106 }, {
12107 name: "selecttostart",
12108 bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Home|Command-Shift-Up"),
12109 exec: function(editor) { editor.getSelection().selectFileStart(); },
12110 multiSelectAction: "forEach",
12111 readOnly: true,
12112 scrollIntoView: "animate",
12113 aceCommandGroup: "fileJump"
12114 }, {
12115 name: "gotostart",
12116 bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
12117 exec: function(editor) { editor.navigateFileStart(); },
12118 multiSelectAction: "forEach",
12119 readOnly: true,
12120 scrollIntoView: "animate",
12121 aceCommandGroup: "fileJump"
12122 }, {
12123 name: "selectup",
12124 bindKey: bindKey("Shift-Up", "Shift-Up|Ctrl-Shift-P"),
12125 exec: function(editor) { editor.getSelection().selectUp(); },
12126 multiSelectAction: "forEach",
12127 scrollIntoView: "cursor",
12128 readOnly: true
12129 }, {
12130 name: "golineup",
12131 bindKey: bindKey("Up", "Up|Ctrl-P"),
12132 exec: function(editor, args) { editor.navigateUp(args.times); },
12133 multiSelectAction: "forEach",
12134 scrollIntoView: "cursor",
12135 readOnly: true
12136 }, {
12137 name: "selecttoend",
12138 bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-End|Command-Shift-Down"),
12139 exec: function(editor) { editor.getSelection().selectFileEnd(); },
12140 multiSelectAction: "forEach",
12141 readOnly: true,
12142 scrollIntoView: "animate",
12143 aceCommandGroup: "fileJump"
12144 }, {
12145 name: "gotoend",
12146 bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
12147 exec: function(editor) { editor.navigateFileEnd(); },
12148 multiSelectAction: "forEach",
12149 readOnly: true,
12150 scrollIntoView: "animate",
12151 aceCommandGroup: "fileJump"
12152 }, {
12153 name: "selectdown",
12154 bindKey: bindKey("Shift-Down", "Shift-Down|Ctrl-Shift-N"),
12155 exec: function(editor) { editor.getSelection().selectDown(); },
12156 multiSelectAction: "forEach",
12157 scrollIntoView: "cursor",
12158 readOnly: true
12159 }, {
12160 name: "golinedown",
12161 bindKey: bindKey("Down", "Down|Ctrl-N"),
12162 exec: function(editor, args) { editor.navigateDown(args.times); },
12163 multiSelectAction: "forEach",
12164 scrollIntoView: "cursor",
12165 readOnly: true
12166 }, {
12167 name: "selectwordleft",
12168 bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
12169 exec: function(editor) { editor.getSelection().selectWordLeft(); },
12170 multiSelectAction: "forEach",
12171 scrollIntoView: "cursor",
12172 readOnly: true
12173 }, {
12174 name: "gotowordleft",
12175 bindKey: bindKey("Ctrl-Left", "Option-Left"),
12176 exec: function(editor) { editor.navigateWordLeft(); },
12177 multiSelectAction: "forEach",
12178 scrollIntoView: "cursor",
12179 readOnly: true
12180 }, {
12181 name: "selecttolinestart",
12182 bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left|Ctrl-Shift-A"),
12183 exec: function(editor) { editor.getSelection().selectLineStart(); },
12184 multiSelectAction: "forEach",
12185 scrollIntoView: "cursor",
12186 readOnly: true
12187 }, {
12188 name: "gotolinestart",
12189 bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
12190 exec: function(editor) { editor.navigateLineStart(); },
12191 multiSelectAction: "forEach",
12192 scrollIntoView: "cursor",
12193 readOnly: true
12194 }, {
12195 name: "selectleft",
12196 bindKey: bindKey("Shift-Left", "Shift-Left|Ctrl-Shift-B"),
12197 exec: function(editor) { editor.getSelection().selectLeft(); },
12198 multiSelectAction: "forEach",
12199 scrollIntoView: "cursor",
12200 readOnly: true
12201 }, {
12202 name: "gotoleft",
12203 bindKey: bindKey("Left", "Left|Ctrl-B"),
12204 exec: function(editor, args) { editor.navigateLeft(args.times); },
12205 multiSelectAction: "forEach",
12206 scrollIntoView: "cursor",
12207 readOnly: true
12208 }, {
12209 name: "selectwordright",
12210 bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
12211 exec: function(editor) { editor.getSelection().selectWordRight(); },
12212 multiSelectAction: "forEach",
12213 scrollIntoView: "cursor",
12214 readOnly: true
12215 }, {
12216 name: "gotowordright",
12217 bindKey: bindKey("Ctrl-Right", "Option-Right"),
12218 exec: function(editor) { editor.navigateWordRight(); },
12219 multiSelectAction: "forEach",
12220 scrollIntoView: "cursor",
12221 readOnly: true
12222 }, {
12223 name: "selecttolineend",
12224 bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right|Shift-End|Ctrl-Shift-E"),
12225 exec: function(editor) { editor.getSelection().selectLineEnd(); },
12226 multiSelectAction: "forEach",
12227 scrollIntoView: "cursor",
12228 readOnly: true
12229 }, {
12230 name: "gotolineend",
12231 bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
12232 exec: function(editor) { editor.navigateLineEnd(); },
12233 multiSelectAction: "forEach",
12234 scrollIntoView: "cursor",
12235 readOnly: true
12236 }, {
12237 name: "selectright",
12238 bindKey: bindKey("Shift-Right", "Shift-Right"),
12239 exec: function(editor) { editor.getSelection().selectRight(); },
12240 multiSelectAction: "forEach",
12241 scrollIntoView: "cursor",
12242 readOnly: true
12243 }, {
12244 name: "gotoright",
12245 bindKey: bindKey("Right", "Right|Ctrl-F"),
12246 exec: function(editor, args) { editor.navigateRight(args.times); },
12247 multiSelectAction: "forEach",
12248 scrollIntoView: "cursor",
12249 readOnly: true
12250 }, {
12251 name: "selectpagedown",
12252 bindKey: "Shift-PageDown",
12253 exec: function(editor) { editor.selectPageDown(); },
12254 readOnly: true
12255 }, {
12256 name: "pagedown",
12257 bindKey: bindKey(null, "Option-PageDown"),
12258 exec: function(editor) { editor.scrollPageDown(); },
12259 readOnly: true
12260 }, {
12261 name: "gotopagedown",
12262 bindKey: bindKey("PageDown", "PageDown|Ctrl-V"),
12263 exec: function(editor) { editor.gotoPageDown(); },
12264 readOnly: true
12265 }, {
12266 name: "selectpageup",
12267 bindKey: "Shift-PageUp",
12268 exec: function(editor) { editor.selectPageUp(); },
12269 readOnly: true
12270 }, {
12271 name: "pageup",
12272 bindKey: bindKey(null, "Option-PageUp"),
12273 exec: function(editor) { editor.scrollPageUp(); },
12274 readOnly: true
12275 }, {
12276 name: "gotopageup",
12277 bindKey: "PageUp",
12278 exec: function(editor) { editor.gotoPageUp(); },
12279 readOnly: true
12280 }, {
12281 name: "scrollup",
12282 bindKey: bindKey("Ctrl-Up", null),
12283 exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); },
12284 readOnly: true
12285 }, {
12286 name: "scrolldown",
12287 bindKey: bindKey("Ctrl-Down", null),
12288 exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); },
12289 readOnly: true
12290 }, {
12291 name: "selectlinestart",
12292 bindKey: "Shift-Home",
12293 exec: function(editor) { editor.getSelection().selectLineStart(); },
12294 multiSelectAction: "forEach",
12295 scrollIntoView: "cursor",
12296 readOnly: true
12297 }, {
12298 name: "selectlineend",
12299 bindKey: "Shift-End",
12300 exec: function(editor) { editor.getSelection().selectLineEnd(); },
12301 multiSelectAction: "forEach",
12302 scrollIntoView: "cursor",
12303 readOnly: true
12304 }, {
12305 name: "togglerecording",
12306 bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
12307 exec: function(editor) { editor.commands.toggleRecording(editor); },
12308 readOnly: true
12309 }, {
12310 name: "replaymacro",
12311 bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
12312 exec: function(editor) { editor.commands.replay(editor); },
12313 readOnly: true
12314 }, {
12315 name: "jumptomatching",
12316 bindKey: bindKey("Ctrl-P", "Ctrl-P"),
12317 exec: function(editor) { editor.jumpToMatching(); },
12318 multiSelectAction: "forEach",
12319 scrollIntoView: "animate",
12320 readOnly: true
12321 }, {
12322 name: "selecttomatching",
12323 bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
12324 exec: function(editor) { editor.jumpToMatching(true); },
12325 multiSelectAction: "forEach",
12326 scrollIntoView: "animate",
12327 readOnly: true
12328 }, {
12329 name: "expandToMatching",
12330 bindKey: bindKey("Ctrl-Shift-M", "Ctrl-Shift-M"),
12331 exec: function(editor) { editor.jumpToMatching(true, true); },
12332 multiSelectAction: "forEach",
12333 scrollIntoView: "animate",
12334 readOnly: true
12335 }, {
12336 name: "passKeysToBrowser",
12337 bindKey: bindKey(null, null),
12338 exec: function() {},
12339 passEvent: true,
12340 readOnly: true
12341 }, {
12342 name: "copy",
12343 exec: function(editor) {
12344 },
12345 readOnly: true
12346 },
12347 {
12348 name: "cut",
12349 exec: function(editor) {
12350 var range = editor.getSelectionRange();
12351 editor._emit("cut", range);
12352
12353 if (!editor.selection.isEmpty()) {
12354 editor.session.remove(range);
12355 editor.clearSelection();
12356 }
12357 },
12358 scrollIntoView: "cursor",
12359 multiSelectAction: "forEach"
12360 }, {
12361 name: "paste",
12362 exec: function(editor, args) {
12363 editor.$handlePaste(args);
12364 },
12365 scrollIntoView: "cursor"
12366 }, {
12367 name: "removeline",
12368 bindKey: bindKey("Ctrl-D", "Command-D"),
12369 exec: function(editor) { editor.removeLines(); },
12370 scrollIntoView: "cursor",
12371 multiSelectAction: "forEachLine"
12372 }, {
12373 name: "duplicateSelection",
12374 bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
12375 exec: function(editor) { editor.duplicateSelection(); },
12376 scrollIntoView: "cursor",
12377 multiSelectAction: "forEach"
12378 }, {
12379 name: "sortlines",
12380 bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
12381 exec: function(editor) { editor.sortLines(); },
12382 scrollIntoView: "selection",
12383 multiSelectAction: "forEachLine"
12384 }, {
12385 name: "togglecomment",
12386 bindKey: bindKey("Ctrl-/", "Command-/"),
12387 exec: function(editor) { editor.toggleCommentLines(); },
12388 multiSelectAction: "forEachLine",
12389 scrollIntoView: "selectionPart"
12390 }, {
12391 name: "toggleBlockComment",
12392 bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"),
12393 exec: function(editor) { editor.toggleBlockComment(); },
12394 multiSelectAction: "forEach",
12395 scrollIntoView: "selectionPart"
12396 }, {
12397 name: "modifyNumberUp",
12398 bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
12399 exec: function(editor) { editor.modifyNumber(1); },
12400 scrollIntoView: "cursor",
12401 multiSelectAction: "forEach"
12402 }, {
12403 name: "modifyNumberDown",
12404 bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
12405 exec: function(editor) { editor.modifyNumber(-1); },
12406 scrollIntoView: "cursor",
12407 multiSelectAction: "forEach"
12408 }, {
12409 name: "replace",
12410 bindKey: bindKey("Ctrl-H", "Command-Option-F"),
12411 exec: function(editor) {
12412 config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor, true);});
12413 }
12414 }, {
12415 name: "undo",
12416 bindKey: bindKey("Ctrl-Z", "Command-Z"),
12417 exec: function(editor) { editor.undo(); }
12418 }, {
12419 name: "redo",
12420 bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
12421 exec: function(editor) { editor.redo(); }
12422 }, {
12423 name: "copylinesup",
12424 bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"),
12425 exec: function(editor) { editor.copyLinesUp(); },
12426 scrollIntoView: "cursor"
12427 }, {
12428 name: "movelinesup",
12429 bindKey: bindKey("Alt-Up", "Option-Up"),
12430 exec: function(editor) { editor.moveLinesUp(); },
12431 scrollIntoView: "cursor"
12432 }, {
12433 name: "copylinesdown",
12434 bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"),
12435 exec: function(editor) { editor.copyLinesDown(); },
12436 scrollIntoView: "cursor"
12437 }, {
12438 name: "movelinesdown",
12439 bindKey: bindKey("Alt-Down", "Option-Down"),
12440 exec: function(editor) { editor.moveLinesDown(); },
12441 scrollIntoView: "cursor"
12442 }, {
12443 name: "del",
12444 bindKey: bindKey("Delete", "Delete|Ctrl-D|Shift-Delete"),
12445 exec: function(editor) { editor.remove("right"); },
12446 multiSelectAction: "forEach",
12447 scrollIntoView: "cursor"
12448 }, {
12449 name: "backspace",
12450 bindKey: bindKey(
12451 "Shift-Backspace|Backspace",
12452 "Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"
12453 ),
12454 exec: function(editor) { editor.remove("left"); },
12455 multiSelectAction: "forEach",
12456 scrollIntoView: "cursor"
12457 }, {
12458 name: "cut_or_delete",
12459 bindKey: bindKey("Shift-Delete", null),
12460 exec: function(editor) {
12461 if (editor.selection.isEmpty()) {
12462 editor.remove("left");
12463 } else {
12464 return false;
12465 }
12466 },
12467 multiSelectAction: "forEach",
12468 scrollIntoView: "cursor"
12469 }, {
12470 name: "removetolinestart",
12471 bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
12472 exec: function(editor) { editor.removeToLineStart(); },
12473 multiSelectAction: "forEach",
12474 scrollIntoView: "cursor"
12475 }, {
12476 name: "removetolineend",
12477 bindKey: bindKey("Alt-Delete", "Ctrl-K|Command-Delete"),
12478 exec: function(editor) { editor.removeToLineEnd(); },
12479 multiSelectAction: "forEach",
12480 scrollIntoView: "cursor"
12481 }, {
12482 name: "removetolinestarthard",
12483 bindKey: bindKey("Ctrl-Shift-Backspace", null),
12484 exec: function(editor) {
12485 var range = editor.selection.getRange();
12486 range.start.column = 0;
12487 editor.session.remove(range);
12488 },
12489 multiSelectAction: "forEach",
12490 scrollIntoView: "cursor"
12491 }, {
12492 name: "removetolineendhard",
12493 bindKey: bindKey("Ctrl-Shift-Delete", null),
12494 exec: function(editor) {
12495 var range = editor.selection.getRange();
12496 range.end.column = Number.MAX_VALUE;
12497 editor.session.remove(range);
12498 },
12499 multiSelectAction: "forEach",
12500 scrollIntoView: "cursor"
12501 }, {
12502 name: "removewordleft",
12503 bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
12504 exec: function(editor) { editor.removeWordLeft(); },
12505 multiSelectAction: "forEach",
12506 scrollIntoView: "cursor"
12507 }, {
12508 name: "removewordright",
12509 bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
12510 exec: function(editor) { editor.removeWordRight(); },
12511 multiSelectAction: "forEach",
12512 scrollIntoView: "cursor"
12513 }, {
12514 name: "outdent",
12515 bindKey: bindKey("Shift-Tab", "Shift-Tab"),
12516 exec: function(editor) { editor.blockOutdent(); },
12517 multiSelectAction: "forEach",
12518 scrollIntoView: "selectionPart"
12519 }, {
12520 name: "indent",
12521 bindKey: bindKey("Tab", "Tab"),
12522 exec: function(editor) { editor.indent(); },
12523 multiSelectAction: "forEach",
12524 scrollIntoView: "selectionPart"
12525 }, {
12526 name: "blockoutdent",
12527 bindKey: bindKey("Ctrl-[", "Ctrl-["),
12528 exec: function(editor) { editor.blockOutdent(); },
12529 multiSelectAction: "forEachLine",
12530 scrollIntoView: "selectionPart"
12531 }, {
12532 name: "blockindent",
12533 bindKey: bindKey("Ctrl-]", "Ctrl-]"),
12534 exec: function(editor) { editor.blockIndent(); },
12535 multiSelectAction: "forEachLine",
12536 scrollIntoView: "selectionPart"
12537 }, {
12538 name: "insertstring",
12539 exec: function(editor, str) { editor.insert(str); },
12540 multiSelectAction: "forEach",
12541 scrollIntoView: "cursor"
12542 }, {
12543 name: "inserttext",
12544 exec: function(editor, args) {
12545 editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
12546 },
12547 multiSelectAction: "forEach",
12548 scrollIntoView: "cursor"
12549 }, {
12550 name: "splitline",
12551 bindKey: bindKey(null, "Ctrl-O"),
12552 exec: function(editor) { editor.splitLine(); },
12553 multiSelectAction: "forEach",
12554 scrollIntoView: "cursor"
12555 }, {
12556 name: "transposeletters",
12557 bindKey: bindKey("Alt-Shift-X", "Ctrl-T"),
12558 exec: function(editor) { editor.transposeLetters(); },
12559 multiSelectAction: function(editor) {editor.transposeSelections(1); },
12560 scrollIntoView: "cursor"
12561 }, {
12562 name: "touppercase",
12563 bindKey: bindKey("Ctrl-U", "Ctrl-U"),
12564 exec: function(editor) { editor.toUpperCase(); },
12565 multiSelectAction: "forEach",
12566 scrollIntoView: "cursor"
12567 }, {
12568 name: "tolowercase",
12569 bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
12570 exec: function(editor) { editor.toLowerCase(); },
12571 multiSelectAction: "forEach",
12572 scrollIntoView: "cursor"
12573 }, {
12574 name: "expandtoline",
12575 bindKey: bindKey("Ctrl-Shift-L", "Command-Shift-L"),
12576 exec: function(editor) {
12577 var range = editor.selection.getRange();
12578
12579 range.start.column = range.end.column = 0;
12580 range.end.row++;
12581 editor.selection.setRange(range, false);
12582 },
12583 multiSelectAction: "forEach",
12584 scrollIntoView: "cursor",
12585 readOnly: true
12586 }, {
12587 name: "joinlines",
12588 bindKey: bindKey(null, null),
12589 exec: function(editor) {
12590 var isBackwards = editor.selection.isBackwards();
12591 var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor();
12592 var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead();
12593 var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length;
12594 var selectedText = editor.session.doc.getTextRange(editor.selection.getRange());
12595 var selectedCount = selectedText.replace(/\n\s*/, " ").length;
12596 var insertLine = editor.session.doc.getLine(selectionStart.row);
12597
12598 for (var i = selectionStart.row + 1; i <= selectionEnd.row + 1; i++) {
12599 var curLine = lang.stringTrimLeft(lang.stringTrimRight(editor.session.doc.getLine(i)));
12600 if (curLine.length !== 0) {
12601 curLine = " " + curLine;
12602 }
12603 insertLine += curLine;
12604 }
12605
12606 if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) {
12607 insertLine += editor.session.doc.getNewLineCharacter();
12608 }
12609
12610 editor.clearSelection();
12611 editor.session.doc.replace(new Range(selectionStart.row, 0, selectionEnd.row + 2, 0), insertLine);
12612
12613 if (selectedCount > 0) {
12614 editor.selection.moveCursorTo(selectionStart.row, selectionStart.column);
12615 editor.selection.selectTo(selectionStart.row, selectionStart.column + selectedCount);
12616 } else {
12617 firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length > firstLineEndCol ? (firstLineEndCol + 1) : firstLineEndCol;
12618 editor.selection.moveCursorTo(selectionStart.row, firstLineEndCol);
12619 }
12620 },
12621 multiSelectAction: "forEach",
12622 readOnly: true
12623 }, {
12624 name: "invertSelection",
12625 bindKey: bindKey(null, null),
12626 exec: function(editor) {
12627 var endRow = editor.session.doc.getLength() - 1;
12628 var endCol = editor.session.doc.getLine(endRow).length;
12629 var ranges = editor.selection.rangeList.ranges;
12630 var newRanges = [];
12631 if (ranges.length < 1) {
12632 ranges = [editor.selection.getRange()];
12633 }
12634
12635 for (var i = 0; i < ranges.length; i++) {
12636 if (i == (ranges.length - 1)) {
12637 if (!(ranges[i].end.row === endRow && ranges[i].end.column === endCol)) {
12638 newRanges.push(new Range(ranges[i].end.row, ranges[i].end.column, endRow, endCol));
12639 }
12640 }
12641
12642 if (i === 0) {
12643 if (!(ranges[i].start.row === 0 && ranges[i].start.column === 0)) {
12644 newRanges.push(new Range(0, 0, ranges[i].start.row, ranges[i].start.column));
12645 }
12646 } else {
12647 newRanges.push(new Range(ranges[i-1].end.row, ranges[i-1].end.column, ranges[i].start.row, ranges[i].start.column));
12648 }
12649 }
12650
12651 editor.exitMultiSelectMode();
12652 editor.clearSelection();
12653
12654 for(var i = 0; i < newRanges.length; i++) {
12655 editor.selection.addRange(newRanges[i], false);
12656 }
12657 },
12658 readOnly: true,
12659 scrollIntoView: "none"
12660 }];
12661
12662 });
12663
12664 ace.define("ace/editor",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/keyboard/textinput","ace/mouse/mouse_handler","ace/mouse/fold_handler","ace/keyboard/keybinding","ace/edit_session","ace/search","ace/range","ace/lib/event_emitter","ace/commands/command_manager","ace/commands/default_commands","ace/config","ace/token_iterator"], function(acequire, exports, module) {
12665
12666 acequire("./lib/fixoldbrowsers");
12667
12668 var oop = acequire("./lib/oop");
12669 var dom = acequire("./lib/dom");
12670 var lang = acequire("./lib/lang");
12671 var useragent = acequire("./lib/useragent");
12672 var TextInput = acequire("./keyboard/textinput").TextInput;
12673 var MouseHandler = acequire("./mouse/mouse_handler").MouseHandler;
12674 var FoldHandler = acequire("./mouse/fold_handler").FoldHandler;
12675 var KeyBinding = acequire("./keyboard/keybinding").KeyBinding;
12676 var EditSession = acequire("./edit_session").EditSession;
12677 var Search = acequire("./search").Search;
12678 var Range = acequire("./range").Range;
12679 var EventEmitter = acequire("./lib/event_emitter").EventEmitter;
12680 var CommandManager = acequire("./commands/command_manager").CommandManager;
12681 var defaultCommands = acequire("./commands/default_commands").commands;
12682 var config = acequire("./config");
12683 var TokenIterator = acequire("./token_iterator").TokenIterator;
12684 var Editor = function(renderer, session) {
12685 var container = renderer.getContainerElement();
12686 this.container = container;
12687 this.renderer = renderer;
12688 this.id = "editor" + (++Editor.$uid);
12689
12690 this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands);
12691 if (typeof document == "object") {
12692 this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
12693 this.renderer.textarea = this.textInput.getElement();
12694 this.$mouseHandler = new MouseHandler(this);
12695 new FoldHandler(this);
12696 }
12697
12698 this.keyBinding = new KeyBinding(this);
12699
12700 this.$blockScrolling = 0;
12701 this.$search = new Search().set({
12702 wrap: true
12703 });
12704
12705 this.$historyTracker = this.$historyTracker.bind(this);
12706 this.commands.on("exec", this.$historyTracker);
12707
12708 this.$initOperationListeners();
12709
12710 this._$emitInputEvent = lang.delayedCall(function() {
12711 this._signal("input", {});
12712 if (this.session && this.session.bgTokenizer)
12713 this.session.bgTokenizer.scheduleStart();
12714 }.bind(this));
12715
12716 this.on("change", function(_, _self) {
12717 _self._$emitInputEvent.schedule(31);
12718 });
12719
12720 this.setSession(session || new EditSession(""));
12721 config.resetOptions(this);
12722 config._signal("editor", this);
12723 };
12724
12725 Editor.$uid = 0;
12726
12727 (function(){
12728
12729 oop.implement(this, EventEmitter);
12730
12731 this.$initOperationListeners = function() {
12732
12733 this.selections = [];
12734 this.commands.on("exec", this.startOperation.bind(this), true);
12735 this.commands.on("afterExec", this.endOperation.bind(this), true);
12736
12737 this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this));
12738
12739 this.on("change", function() {
12740 this.curOp || this.startOperation();
12741 this.curOp.docChanged = true;
12742 }.bind(this), true);
12743
12744 this.on("changeSelection", function() {
12745 this.curOp || this.startOperation();
12746 this.curOp.selectionChanged = true;
12747 }.bind(this), true);
12748 };
12749
12750 this.curOp = null;
12751 this.prevOp = {};
12752 this.startOperation = function(commadEvent) {
12753 if (this.curOp) {
12754 if (!commadEvent || this.curOp.command)
12755 return;
12756 this.prevOp = this.curOp;
12757 }
12758 if (!commadEvent) {
12759 this.previousCommand = null;
12760 commadEvent = {};
12761 }
12762
12763 this.$opResetTimer.schedule();
12764 this.curOp = {
12765 command: commadEvent.command || {},
12766 args: commadEvent.args,
12767 scrollTop: this.renderer.scrollTop
12768 };
12769 if (this.curOp.command.name && this.curOp.command.scrollIntoView !== undefined)
12770 this.$blockScrolling++;
12771 };
12772
12773 this.endOperation = function(e) {
12774 if (this.curOp) {
12775 if (e && e.returnValue === false)
12776 return this.curOp = null;
12777 this._signal("beforeEndOperation");
12778 var command = this.curOp.command;
12779 if (command.name && this.$blockScrolling > 0)
12780 this.$blockScrolling--;
12781 var scrollIntoView = command && command.scrollIntoView;
12782 if (scrollIntoView) {
12783 switch (scrollIntoView) {
12784 case "center-animate":
12785 scrollIntoView = "animate";
12786 case "center":
12787 this.renderer.scrollCursorIntoView(null, 0.5);
12788 break;
12789 case "animate":
12790 case "cursor":
12791 this.renderer.scrollCursorIntoView();
12792 break;
12793 case "selectionPart":
12794 var range = this.selection.getRange();
12795 var config = this.renderer.layerConfig;
12796 if (range.start.row >= config.lastRow || range.end.row <= config.firstRow) {
12797 this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead);
12798 }
12799 break;
12800 }
12801 if (scrollIntoView == "animate")
12802 this.renderer.animateScrolling(this.curOp.scrollTop);
12803 }
12804
12805 this.prevOp = this.curOp;
12806 this.curOp = null;
12807 }
12808 };
12809 this.$mergeableCommands = ["backspace", "del", "insertstring"];
12810 this.$historyTracker = function(e) {
12811 if (!this.$mergeUndoDeltas)
12812 return;
12813
12814 var prev = this.prevOp;
12815 var mergeableCommands = this.$mergeableCommands;
12816 var shouldMerge = prev.command && (e.command.name == prev.command.name);
12817 if (e.command.name == "insertstring") {
12818 var text = e.args;
12819 if (this.mergeNextCommand === undefined)
12820 this.mergeNextCommand = true;
12821
12822 shouldMerge = shouldMerge
12823 && this.mergeNextCommand // previous command allows to coalesce with
12824 && (!/\s/.test(text) || /\s/.test(prev.args)); // previous insertion was of same type
12825
12826 this.mergeNextCommand = true;
12827 } else {
12828 shouldMerge = shouldMerge
12829 && mergeableCommands.indexOf(e.command.name) !== -1; // the command is mergeable
12830 }
12831
12832 if (
12833 this.$mergeUndoDeltas != "always"
12834 && Date.now() - this.sequenceStartTime > 2000
12835 ) {
12836 shouldMerge = false; // the sequence is too long
12837 }
12838
12839 if (shouldMerge)
12840 this.session.mergeUndoDeltas = true;
12841 else if (mergeableCommands.indexOf(e.command.name) !== -1)
12842 this.sequenceStartTime = Date.now();
12843 };
12844 this.setKeyboardHandler = function(keyboardHandler, cb) {
12845 if (keyboardHandler && typeof keyboardHandler === "string") {
12846 this.$keybindingId = keyboardHandler;
12847 var _self = this;
12848 config.loadModule(["keybinding", keyboardHandler], function(module) {
12849 if (_self.$keybindingId == keyboardHandler)
12850 _self.keyBinding.setKeyboardHandler(module && module.handler);
12851 cb && cb();
12852 });
12853 } else {
12854 this.$keybindingId = null;
12855 this.keyBinding.setKeyboardHandler(keyboardHandler);
12856 cb && cb();
12857 }
12858 };
12859 this.getKeyboardHandler = function() {
12860 return this.keyBinding.getKeyboardHandler();
12861 };
12862 this.setSession = function(session) {
12863 if (this.session == session)
12864 return;
12865 if (this.curOp) this.endOperation();
12866 this.curOp = {};
12867
12868 var oldSession = this.session;
12869 if (oldSession) {
12870 this.session.off("change", this.$onDocumentChange);
12871 this.session.off("changeMode", this.$onChangeMode);
12872 this.session.off("tokenizerUpdate", this.$onTokenizerUpdate);
12873 this.session.off("changeTabSize", this.$onChangeTabSize);
12874 this.session.off("changeWrapLimit", this.$onChangeWrapLimit);
12875 this.session.off("changeWrapMode", this.$onChangeWrapMode);
12876 this.session.off("changeFold", this.$onChangeFold);
12877 this.session.off("changeFrontMarker", this.$onChangeFrontMarker);
12878 this.session.off("changeBackMarker", this.$onChangeBackMarker);
12879 this.session.off("changeBreakpoint", this.$onChangeBreakpoint);
12880 this.session.off("changeAnnotation", this.$onChangeAnnotation);
12881 this.session.off("changeOverwrite", this.$onCursorChange);
12882 this.session.off("changeScrollTop", this.$onScrollTopChange);
12883 this.session.off("changeScrollLeft", this.$onScrollLeftChange);
12884
12885 var selection = this.session.getSelection();
12886 selection.off("changeCursor", this.$onCursorChange);
12887 selection.off("changeSelection", this.$onSelectionChange);
12888 }
12889
12890 this.session = session;
12891 if (session) {
12892 this.$onDocumentChange = this.onDocumentChange.bind(this);
12893 session.on("change", this.$onDocumentChange);
12894 this.renderer.setSession(session);
12895
12896 this.$onChangeMode = this.onChangeMode.bind(this);
12897 session.on("changeMode", this.$onChangeMode);
12898
12899 this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this);
12900 session.on("tokenizerUpdate", this.$onTokenizerUpdate);
12901
12902 this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer);
12903 session.on("changeTabSize", this.$onChangeTabSize);
12904
12905 this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this);
12906 session.on("changeWrapLimit", this.$onChangeWrapLimit);
12907
12908 this.$onChangeWrapMode = this.onChangeWrapMode.bind(this);
12909 session.on("changeWrapMode", this.$onChangeWrapMode);
12910
12911 this.$onChangeFold = this.onChangeFold.bind(this);
12912 session.on("changeFold", this.$onChangeFold);
12913
12914 this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
12915 this.session.on("changeFrontMarker", this.$onChangeFrontMarker);
12916
12917 this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
12918 this.session.on("changeBackMarker", this.$onChangeBackMarker);
12919
12920 this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this);
12921 this.session.on("changeBreakpoint", this.$onChangeBreakpoint);
12922
12923 this.$onChangeAnnotation = this.onChangeAnnotation.bind(this);
12924 this.session.on("changeAnnotation", this.$onChangeAnnotation);
12925
12926 this.$onCursorChange = this.onCursorChange.bind(this);
12927 this.session.on("changeOverwrite", this.$onCursorChange);
12928
12929 this.$onScrollTopChange = this.onScrollTopChange.bind(this);
12930 this.session.on("changeScrollTop", this.$onScrollTopChange);
12931
12932 this.$onScrollLeftChange = this.onScrollLeftChange.bind(this);
12933 this.session.on("changeScrollLeft", this.$onScrollLeftChange);
12934
12935 this.selection = session.getSelection();
12936 this.selection.on("changeCursor", this.$onCursorChange);
12937
12938 this.$onSelectionChange = this.onSelectionChange.bind(this);
12939 this.selection.on("changeSelection", this.$onSelectionChange);
12940
12941 this.onChangeMode();
12942
12943 this.$blockScrolling += 1;
12944 this.onCursorChange();
12945 this.$blockScrolling -= 1;
12946
12947 this.onScrollTopChange();
12948 this.onScrollLeftChange();
12949 this.onSelectionChange();
12950 this.onChangeFrontMarker();
12951 this.onChangeBackMarker();
12952 this.onChangeBreakpoint();
12953 this.onChangeAnnotation();
12954 this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
12955 this.renderer.updateFull();
12956 } else {
12957 this.selection = null;
12958 this.renderer.setSession(session);
12959 }
12960
12961 this._signal("changeSession", {
12962 session: session,
12963 oldSession: oldSession
12964 });
12965
12966 this.curOp = null;
12967
12968 oldSession && oldSession._signal("changeEditor", {oldEditor: this});
12969 session && session._signal("changeEditor", {editor: this});
12970
12971 if (session && session.bgTokenizer)
12972 session.bgTokenizer.scheduleStart();
12973 };
12974 this.getSession = function() {
12975 return this.session;
12976 };
12977 this.setValue = function(val, cursorPos) {
12978 this.session.doc.setValue(val);
12979
12980 if (!cursorPos)
12981 this.selectAll();
12982 else if (cursorPos == 1)
12983 this.navigateFileEnd();
12984 else if (cursorPos == -1)
12985 this.navigateFileStart();
12986
12987 return val;
12988 };
12989 this.getValue = function() {
12990 return this.session.getValue();
12991 };
12992 this.getSelection = function() {
12993 return this.selection;
12994 };
12995 this.resize = function(force) {
12996 this.renderer.onResize(force);
12997 };
12998 this.setTheme = function(theme, cb) {
12999 this.renderer.setTheme(theme, cb);
13000 };
13001 this.getTheme = function() {
13002 return this.renderer.getTheme();
13003 };
13004 this.setStyle = function(style) {
13005 this.renderer.setStyle(style);
13006 };
13007 this.unsetStyle = function(style) {
13008 this.renderer.unsetStyle(style);
13009 };
13010 this.getFontSize = function () {
13011 return this.getOption("fontSize") ||
13012 dom.computedStyle(this.container, "fontSize");
13013 };
13014 this.setFontSize = function(size) {
13015 this.setOption("fontSize", size);
13016 };
13017
13018 this.$highlightBrackets = function() {
13019 if (this.session.$bracketHighlight) {
13020 this.session.removeMarker(this.session.$bracketHighlight);
13021 this.session.$bracketHighlight = null;
13022 }
13023
13024 if (this.$highlightPending) {
13025 return;
13026 }
13027 var self = this;
13028 this.$highlightPending = true;
13029 setTimeout(function() {
13030 self.$highlightPending = false;
13031 var session = self.session;
13032 if (!session || !session.bgTokenizer) return;
13033 var pos = session.findMatchingBracket(self.getCursorPosition());
13034 if (pos) {
13035 var range = new Range(pos.row, pos.column, pos.row, pos.column + 1);
13036 } else if (session.$mode.getMatching) {
13037 var range = session.$mode.getMatching(self.session);
13038 }
13039 if (range)
13040 session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text");
13041 }, 50);
13042 };
13043 this.$highlightTags = function() {
13044 if (this.$highlightTagPending)
13045 return;
13046 var self = this;
13047 this.$highlightTagPending = true;
13048 setTimeout(function() {
13049 self.$highlightTagPending = false;
13050
13051 var session = self.session;
13052 if (!session || !session.bgTokenizer) return;
13053
13054 var pos = self.getCursorPosition();
13055 var iterator = new TokenIterator(self.session, pos.row, pos.column);
13056 var token = iterator.getCurrentToken();
13057
13058 if (!token || !/\b(?:tag-open|tag-name)/.test(token.type)) {
13059 session.removeMarker(session.$tagHighlight);
13060 session.$tagHighlight = null;
13061 return;
13062 }
13063
13064 if (token.type.indexOf("tag-open") != -1) {
13065 token = iterator.stepForward();
13066 if (!token)
13067 return;
13068 }
13069
13070 var tag = token.value;
13071 var depth = 0;
13072 var prevToken = iterator.stepBackward();
13073
13074 if (prevToken.value == '<'){
13075 do {
13076 prevToken = token;
13077 token = iterator.stepForward();
13078
13079 if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
13080 if (prevToken.value === '<'){
13081 depth++;
13082 } else if (prevToken.value === '</'){
13083 depth--;
13084 }
13085 }
13086
13087 } while (token && depth >= 0);
13088 } else {
13089 do {
13090 token = prevToken;
13091 prevToken = iterator.stepBackward();
13092
13093 if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
13094 if (prevToken.value === '<') {
13095 depth++;
13096 } else if (prevToken.value === '</') {
13097 depth--;
13098 }
13099 }
13100 } while (prevToken && depth <= 0);
13101 iterator.stepForward();
13102 }
13103
13104 if (!token) {
13105 session.removeMarker(session.$tagHighlight);
13106 session.$tagHighlight = null;
13107 return;
13108 }
13109
13110 var row = iterator.getCurrentTokenRow();
13111 var column = iterator.getCurrentTokenColumn();
13112 var range = new Range(row, column, row, column+token.value.length);
13113 var sbm = session.$backMarkers[session.$tagHighlight];
13114 if (session.$tagHighlight && sbm != undefined && range.compareRange(sbm.range) !== 0) {
13115 session.removeMarker(session.$tagHighlight);
13116 session.$tagHighlight = null;
13117 }
13118
13119 if (range && !session.$tagHighlight)
13120 session.$tagHighlight = session.addMarker(range, "ace_bracket", "text");
13121 }, 50);
13122 };
13123 this.focus = function() {
13124 var _self = this;
13125 setTimeout(function() {
13126 _self.textInput.focus();
13127 });
13128 this.textInput.focus();
13129 };
13130 this.isFocused = function() {
13131 return this.textInput.isFocused();
13132 };
13133 this.blur = function() {
13134 this.textInput.blur();
13135 };
13136 this.onFocus = function(e) {
13137 if (this.$isFocused)
13138 return;
13139 this.$isFocused = true;
13140 this.renderer.showCursor();
13141 this.renderer.visualizeFocus();
13142 this._emit("focus", e);
13143 };
13144 this.onBlur = function(e) {
13145 if (!this.$isFocused)
13146 return;
13147 this.$isFocused = false;
13148 this.renderer.hideCursor();
13149 this.renderer.visualizeBlur();
13150 this._emit("blur", e);
13151 };
13152
13153 this.$cursorChange = function() {
13154 this.renderer.updateCursor();
13155 };
13156 this.onDocumentChange = function(delta) {
13157 var wrap = this.session.$useWrapMode;
13158 var lastRow = (delta.start.row == delta.end.row ? delta.end.row : Infinity);
13159 this.renderer.updateLines(delta.start.row, lastRow, wrap);
13160
13161 this._signal("change", delta);
13162 this.$cursorChange();
13163 this.$updateHighlightActiveLine();
13164 };
13165
13166 this.onTokenizerUpdate = function(e) {
13167 var rows = e.data;
13168 this.renderer.updateLines(rows.first, rows.last);
13169 };
13170
13171
13172 this.onScrollTopChange = function() {
13173 this.renderer.scrollToY(this.session.getScrollTop());
13174 };
13175
13176 this.onScrollLeftChange = function() {
13177 this.renderer.scrollToX(this.session.getScrollLeft());
13178 };
13179 this.onCursorChange = function() {
13180 this.$cursorChange();
13181
13182 if (!this.$blockScrolling) {
13183 config.warn("Automatically scrolling cursor into view after selection change",
13184 "this will be disabled in the next version",
13185 "set editor.$blockScrolling = Infinity to disable this message"
13186 );
13187 this.renderer.scrollCursorIntoView();
13188 }
13189
13190 this.$highlightBrackets();
13191 this.$highlightTags();
13192 this.$updateHighlightActiveLine();
13193 this._signal("changeSelection");
13194 };
13195
13196 this.$updateHighlightActiveLine = function() {
13197 var session = this.getSession();
13198
13199 var highlight;
13200 if (this.$highlightActiveLine) {
13201 if ((this.$selectionStyle != "line" || !this.selection.isMultiLine()))
13202 highlight = this.getCursorPosition();
13203 if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1))
13204 highlight = false;
13205 }
13206
13207 if (session.$highlightLineMarker && !highlight) {
13208 session.removeMarker(session.$highlightLineMarker.id);
13209 session.$highlightLineMarker = null;
13210 } else if (!session.$highlightLineMarker && highlight) {
13211 var range = new Range(highlight.row, highlight.column, highlight.row, Infinity);
13212 range.id = session.addMarker(range, "ace_active-line", "screenLine");
13213 session.$highlightLineMarker = range;
13214 } else if (highlight) {
13215 session.$highlightLineMarker.start.row = highlight.row;
13216 session.$highlightLineMarker.end.row = highlight.row;
13217 session.$highlightLineMarker.start.column = highlight.column;
13218 session._signal("changeBackMarker");
13219 }
13220 };
13221
13222 this.onSelectionChange = function(e) {
13223 var session = this.session;
13224
13225 if (session.$selectionMarker) {
13226 session.removeMarker(session.$selectionMarker);
13227 }
13228 session.$selectionMarker = null;
13229
13230 if (!this.selection.isEmpty()) {
13231 var range = this.selection.getRange();
13232 var style = this.getSelectionStyle();
13233 session.$selectionMarker = session.addMarker(range, "ace_selection", style);
13234 } else {
13235 this.$updateHighlightActiveLine();
13236 }
13237
13238 var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp();
13239 this.session.highlight(re);
13240
13241 this._signal("changeSelection");
13242 };
13243
13244 this.$getSelectionHighLightRegexp = function() {
13245 var session = this.session;
13246
13247 var selection = this.getSelectionRange();
13248 if (selection.isEmpty() || selection.isMultiLine())
13249 return;
13250
13251 var startOuter = selection.start.column - 1;
13252 var endOuter = selection.end.column + 1;
13253 var line = session.getLine(selection.start.row);
13254 var lineCols = line.length;
13255 var needle = line.substring(Math.max(startOuter, 0),
13256 Math.min(endOuter, lineCols));
13257 if ((startOuter >= 0 && /^[\w\d]/.test(needle)) ||
13258 (endOuter <= lineCols && /[\w\d]$/.test(needle)))
13259 return;
13260
13261 needle = line.substring(selection.start.column, selection.end.column);
13262 if (!/^[\w\d]+$/.test(needle))
13263 return;
13264
13265 var re = this.$search.$assembleRegExp({
13266 wholeWord: true,
13267 caseSensitive: true,
13268 needle: needle
13269 });
13270
13271 return re;
13272 };
13273
13274
13275 this.onChangeFrontMarker = function() {
13276 this.renderer.updateFrontMarkers();
13277 };
13278
13279 this.onChangeBackMarker = function() {
13280 this.renderer.updateBackMarkers();
13281 };
13282
13283
13284 this.onChangeBreakpoint = function() {
13285 this.renderer.updateBreakpoints();
13286 };
13287
13288 this.onChangeAnnotation = function() {
13289 this.renderer.setAnnotations(this.session.getAnnotations());
13290 };
13291
13292
13293 this.onChangeMode = function(e) {
13294 this.renderer.updateText();
13295 this._emit("changeMode", e);
13296 };
13297
13298
13299 this.onChangeWrapLimit = function() {
13300 this.renderer.updateFull();
13301 };
13302
13303 this.onChangeWrapMode = function() {
13304 this.renderer.onResize(true);
13305 };
13306
13307
13308 this.onChangeFold = function() {
13309 this.$updateHighlightActiveLine();
13310 this.renderer.updateFull();
13311 };
13312 this.getSelectedText = function() {
13313 return this.session.getTextRange(this.getSelectionRange());
13314 };
13315 this.getCopyText = function() {
13316 var text = this.getSelectedText();
13317 this._signal("copy", text);
13318 return text;
13319 };
13320 this.onCopy = function() {
13321 this.commands.exec("copy", this);
13322 };
13323 this.onCut = function() {
13324 this.commands.exec("cut", this);
13325 };
13326 this.onPaste = function(text, event) {
13327 var e = {text: text, event: event};
13328 this.commands.exec("paste", this, e);
13329 };
13330
13331 this.$handlePaste = function(e) {
13332 if (typeof e == "string")
13333 e = {text: e};
13334 this._signal("paste", e);
13335 var text = e.text;
13336 if (!this.inMultiSelectMode || this.inVirtualSelectionMode) {
13337 this.insert(text);
13338 } else {
13339 var lines = text.split(/\r\n|\r|\n/);
13340 var ranges = this.selection.rangeList.ranges;
13341
13342 if (lines.length > ranges.length || lines.length < 2 || !lines[1])
13343 return this.commands.exec("insertstring", this, text);
13344
13345 for (var i = ranges.length; i--;) {
13346 var range = ranges[i];
13347 if (!range.isEmpty())
13348 this.session.remove(range);
13349
13350 this.session.insert(range.start, lines[i]);
13351 }
13352 }
13353 };
13354
13355 this.execCommand = function(command, args) {
13356 return this.commands.exec(command, this, args);
13357 };
13358 this.insert = function(text, pasted) {
13359 var session = this.session;
13360 var mode = session.getMode();
13361 var cursor = this.getCursorPosition();
13362
13363 if (this.getBehavioursEnabled() && !pasted) {
13364 var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
13365 if (transform) {
13366 if (text !== transform.text) {
13367 this.session.mergeUndoDeltas = false;
13368 this.$mergeNextCommand = false;
13369 }
13370 text = transform.text;
13371
13372 }
13373 }
13374
13375 if (text == "\t")
13376 text = this.session.getTabString();
13377 if (!this.selection.isEmpty()) {
13378 var range = this.getSelectionRange();
13379 cursor = this.session.remove(range);
13380 this.clearSelection();
13381 }
13382 else if (this.session.getOverwrite() && text.indexOf("\n") == -1) {
13383 var range = new Range.fromPoints(cursor, cursor);
13384 range.end.column += text.length;
13385 this.session.remove(range);
13386 }
13387
13388 if (text == "\n" || text == "\r\n") {
13389 var line = session.getLine(cursor.row);
13390 if (cursor.column > line.search(/\S|$/)) {
13391 var d = line.substr(cursor.column).search(/\S|$/);
13392 session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d);
13393 }
13394 }
13395 this.clearSelection();
13396
13397 var start = cursor.column;
13398 var lineState = session.getState(cursor.row);
13399 var line = session.getLine(cursor.row);
13400 var shouldOutdent = mode.checkOutdent(lineState, line, text);
13401 session.insert(cursor, text);
13402
13403 if (transform && transform.selection) {
13404 if (transform.selection.length == 2) { // Transform relative to the current column
13405 this.selection.setSelectionRange(
13406 new Range(cursor.row, start + transform.selection[0],
13407 cursor.row, start + transform.selection[1]));
13408 } else { // Transform relative to the current row.
13409 this.selection.setSelectionRange(
13410 new Range(cursor.row + transform.selection[0],
13411 transform.selection[1],
13412 cursor.row + transform.selection[2],
13413 transform.selection[3]));
13414 }
13415 }
13416
13417 if (session.getDocument().isNewLine(text)) {
13418 var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
13419
13420 session.insert({row: cursor.row+1, column: 0}, lineIndent);
13421 }
13422 if (shouldOutdent)
13423 mode.autoOutdent(lineState, session, cursor.row);
13424 };
13425
13426 this.onTextInput = function(text) {
13427 this.keyBinding.onTextInput(text);
13428 };
13429
13430 this.onCommandKey = function(e, hashId, keyCode) {
13431 this.keyBinding.onCommandKey(e, hashId, keyCode);
13432 };
13433 this.setOverwrite = function(overwrite) {
13434 this.session.setOverwrite(overwrite);
13435 };
13436 this.getOverwrite = function() {
13437 return this.session.getOverwrite();
13438 };
13439 this.toggleOverwrite = function() {
13440 this.session.toggleOverwrite();
13441 };
13442 this.setScrollSpeed = function(speed) {
13443 this.setOption("scrollSpeed", speed);
13444 };
13445 this.getScrollSpeed = function() {
13446 return this.getOption("scrollSpeed");
13447 };
13448 this.setDragDelay = function(dragDelay) {
13449 this.setOption("dragDelay", dragDelay);
13450 };
13451 this.getDragDelay = function() {
13452 return this.getOption("dragDelay");
13453 };
13454 this.setSelectionStyle = function(val) {
13455 this.setOption("selectionStyle", val);
13456 };
13457 this.getSelectionStyle = function() {
13458 return this.getOption("selectionStyle");
13459 };
13460 this.setHighlightActiveLine = function(shouldHighlight) {
13461 this.setOption("highlightActiveLine", shouldHighlight);
13462 };
13463 this.getHighlightActiveLine = function() {
13464 return this.getOption("highlightActiveLine");
13465 };
13466 this.setHighlightGutterLine = function(shouldHighlight) {
13467 this.setOption("highlightGutterLine", shouldHighlight);
13468 };
13469
13470 this.getHighlightGutterLine = function() {
13471 return this.getOption("highlightGutterLine");
13472 };
13473 this.setHighlightSelectedWord = function(shouldHighlight) {
13474 this.setOption("highlightSelectedWord", shouldHighlight);
13475 };
13476 this.getHighlightSelectedWord = function() {
13477 return this.$highlightSelectedWord;
13478 };
13479
13480 this.setAnimatedScroll = function(shouldAnimate){
13481 this.renderer.setAnimatedScroll(shouldAnimate);
13482 };
13483
13484 this.getAnimatedScroll = function(){
13485 return this.renderer.getAnimatedScroll();
13486 };
13487 this.setShowInvisibles = function(showInvisibles) {
13488 this.renderer.setShowInvisibles(showInvisibles);
13489 };
13490 this.getShowInvisibles = function() {
13491 return this.renderer.getShowInvisibles();
13492 };
13493
13494 this.setDisplayIndentGuides = function(display) {
13495 this.renderer.setDisplayIndentGuides(display);
13496 };
13497
13498 this.getDisplayIndentGuides = function() {
13499 return this.renderer.getDisplayIndentGuides();
13500 };
13501 this.setShowPrintMargin = function(showPrintMargin) {
13502 this.renderer.setShowPrintMargin(showPrintMargin);
13503 };
13504 this.getShowPrintMargin = function() {
13505 return this.renderer.getShowPrintMargin();
13506 };
13507 this.setPrintMarginColumn = function(showPrintMargin) {
13508 this.renderer.setPrintMarginColumn(showPrintMargin);
13509 };
13510 this.getPrintMarginColumn = function() {
13511 return this.renderer.getPrintMarginColumn();
13512 };
13513 this.setReadOnly = function(readOnly) {
13514 this.setOption("readOnly", readOnly);
13515 };
13516 this.getReadOnly = function() {
13517 return this.getOption("readOnly");
13518 };
13519 this.setBehavioursEnabled = function (enabled) {
13520 this.setOption("behavioursEnabled", enabled);
13521 };
13522 this.getBehavioursEnabled = function () {
13523 return this.getOption("behavioursEnabled");
13524 };
13525 this.setWrapBehavioursEnabled = function (enabled) {
13526 this.setOption("wrapBehavioursEnabled", enabled);
13527 };
13528 this.getWrapBehavioursEnabled = function () {
13529 return this.getOption("wrapBehavioursEnabled");
13530 };
13531 this.setShowFoldWidgets = function(show) {
13532 this.setOption("showFoldWidgets", show);
13533
13534 };
13535 this.getShowFoldWidgets = function() {
13536 return this.getOption("showFoldWidgets");
13537 };
13538
13539 this.setFadeFoldWidgets = function(fade) {
13540 this.setOption("fadeFoldWidgets", fade);
13541 };
13542
13543 this.getFadeFoldWidgets = function() {
13544 return this.getOption("fadeFoldWidgets");
13545 };
13546 this.remove = function(dir) {
13547 if (this.selection.isEmpty()){
13548 if (dir == "left")
13549 this.selection.selectLeft();
13550 else
13551 this.selection.selectRight();
13552 }
13553
13554 var range = this.getSelectionRange();
13555 if (this.getBehavioursEnabled()) {
13556 var session = this.session;
13557 var state = session.getState(range.start.row);
13558 var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
13559
13560 if (range.end.column === 0) {
13561 var text = session.getTextRange(range);
13562 if (text[text.length - 1] == "\n") {
13563 var line = session.getLine(range.end.row);
13564 if (/^\s+$/.test(line)) {
13565 range.end.column = line.length;
13566 }
13567 }
13568 }
13569 if (new_range)
13570 range = new_range;
13571 }
13572
13573 this.session.remove(range);
13574 this.clearSelection();
13575 };
13576 this.removeWordRight = function() {
13577 if (this.selection.isEmpty())
13578 this.selection.selectWordRight();
13579
13580 this.session.remove(this.getSelectionRange());
13581 this.clearSelection();
13582 };
13583 this.removeWordLeft = function() {
13584 if (this.selection.isEmpty())
13585 this.selection.selectWordLeft();
13586
13587 this.session.remove(this.getSelectionRange());
13588 this.clearSelection();
13589 };
13590 this.removeToLineStart = function() {
13591 if (this.selection.isEmpty())
13592 this.selection.selectLineStart();
13593
13594 this.session.remove(this.getSelectionRange());
13595 this.clearSelection();
13596 };
13597 this.removeToLineEnd = function() {
13598 if (this.selection.isEmpty())
13599 this.selection.selectLineEnd();
13600
13601 var range = this.getSelectionRange();
13602 if (range.start.column == range.end.column && range.start.row == range.end.row) {
13603 range.end.column = 0;
13604 range.end.row++;
13605 }
13606
13607 this.session.remove(range);
13608 this.clearSelection();
13609 };
13610 this.splitLine = function() {
13611 if (!this.selection.isEmpty()) {
13612 this.session.remove(this.getSelectionRange());
13613 this.clearSelection();
13614 }
13615
13616 var cursor = this.getCursorPosition();
13617 this.insert("\n");
13618 this.moveCursorToPosition(cursor);
13619 };
13620 this.transposeLetters = function() {
13621 if (!this.selection.isEmpty()) {
13622 return;
13623 }
13624
13625 var cursor = this.getCursorPosition();
13626 var column = cursor.column;
13627 if (column === 0)
13628 return;
13629
13630 var line = this.session.getLine(cursor.row);
13631 var swap, range;
13632 if (column < line.length) {
13633 swap = line.charAt(column) + line.charAt(column-1);
13634 range = new Range(cursor.row, column-1, cursor.row, column+1);
13635 }
13636 else {
13637 swap = line.charAt(column-1) + line.charAt(column-2);
13638 range = new Range(cursor.row, column-2, cursor.row, column);
13639 }
13640 this.session.replace(range, swap);
13641 this.session.selection.moveToPosition(range.end);
13642 };
13643 this.toLowerCase = function() {
13644 var originalRange = this.getSelectionRange();
13645 if (this.selection.isEmpty()) {
13646 this.selection.selectWord();
13647 }
13648
13649 var range = this.getSelectionRange();
13650 var text = this.session.getTextRange(range);
13651 this.session.replace(range, text.toLowerCase());
13652 this.selection.setSelectionRange(originalRange);
13653 };
13654 this.toUpperCase = function() {
13655 var originalRange = this.getSelectionRange();
13656 if (this.selection.isEmpty()) {
13657 this.selection.selectWord();
13658 }
13659
13660 var range = this.getSelectionRange();
13661 var text = this.session.getTextRange(range);
13662 this.session.replace(range, text.toUpperCase());
13663 this.selection.setSelectionRange(originalRange);
13664 };
13665 this.indent = function() {
13666 var session = this.session;
13667 var range = this.getSelectionRange();
13668
13669 if (range.start.row < range.end.row) {
13670 var rows = this.$getSelectedRows();
13671 session.indentRows(rows.first, rows.last, "\t");
13672 return;
13673 } else if (range.start.column < range.end.column) {
13674 var text = session.getTextRange(range);
13675 if (!/^\s+$/.test(text)) {
13676 var rows = this.$getSelectedRows();
13677 session.indentRows(rows.first, rows.last, "\t");
13678 return;
13679 }
13680 }
13681
13682 var line = session.getLine(range.start.row);
13683 var position = range.start;
13684 var size = session.getTabSize();
13685 var column = session.documentToScreenColumn(position.row, position.column);
13686
13687 if (this.session.getUseSoftTabs()) {
13688 var count = (size - column % size);
13689 var indentString = lang.stringRepeat(" ", count);
13690 } else {
13691 var count = column % size;
13692 while (line[range.start.column - 1] == " " && count) {
13693 range.start.column--;
13694 count--;
13695 }
13696 this.selection.setSelectionRange(range);
13697 indentString = "\t";
13698 }
13699 return this.insert(indentString);
13700 };
13701 this.blockIndent = function() {
13702 var rows = this.$getSelectedRows();
13703 this.session.indentRows(rows.first, rows.last, "\t");
13704 };
13705 this.blockOutdent = function() {
13706 var selection = this.session.getSelection();
13707 this.session.outdentRows(selection.getRange());
13708 };
13709 this.sortLines = function() {
13710 var rows = this.$getSelectedRows();
13711 var session = this.session;
13712
13713 var lines = [];
13714 for (var i = rows.first; i <= rows.last; i++)
13715 lines.push(session.getLine(i));
13716
13717 lines.sort(function(a, b) {
13718 if (a.toLowerCase() < b.toLowerCase()) return -1;
13719 if (a.toLowerCase() > b.toLowerCase()) return 1;
13720 return 0;
13721 });
13722
13723 var deleteRange = new Range(0, 0, 0, 0);
13724 for (var i = rows.first; i <= rows.last; i++) {
13725 var line = session.getLine(i);
13726 deleteRange.start.row = i;
13727 deleteRange.end.row = i;
13728 deleteRange.end.column = line.length;
13729 session.replace(deleteRange, lines[i-rows.first]);
13730 }
13731 };
13732 this.toggleCommentLines = function() {
13733 var state = this.session.getState(this.getCursorPosition().row);
13734 var rows = this.$getSelectedRows();
13735 this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last);
13736 };
13737
13738 this.toggleBlockComment = function() {
13739 var cursor = this.getCursorPosition();
13740 var state = this.session.getState(cursor.row);
13741 var range = this.getSelectionRange();
13742 this.session.getMode().toggleBlockComment(state, this.session, range, cursor);
13743 };
13744 this.getNumberAt = function(row, column) {
13745 var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g;
13746 _numberRx.lastIndex = 0;
13747
13748 var s = this.session.getLine(row);
13749 while (_numberRx.lastIndex < column) {
13750 var m = _numberRx.exec(s);
13751 if(m.index <= column && m.index+m[0].length >= column){
13752 var number = {
13753 value: m[0],
13754 start: m.index,
13755 end: m.index+m[0].length
13756 };
13757 return number;
13758 }
13759 }
13760 return null;
13761 };
13762 this.modifyNumber = function(amount) {
13763 var row = this.selection.getCursor().row;
13764 var column = this.selection.getCursor().column;
13765 var charRange = new Range(row, column-1, row, column);
13766
13767 var c = this.session.getTextRange(charRange);
13768 if (!isNaN(parseFloat(c)) && isFinite(c)) {
13769 var nr = this.getNumberAt(row, column);
13770 if (nr) {
13771 var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end;
13772 var decimals = nr.start + nr.value.length - fp;
13773
13774 var t = parseFloat(nr.value);
13775 t *= Math.pow(10, decimals);
13776
13777
13778 if(fp !== nr.end && column < fp){
13779 amount *= Math.pow(10, nr.end - column - 1);
13780 } else {
13781 amount *= Math.pow(10, nr.end - column);
13782 }
13783
13784 t += amount;
13785 t /= Math.pow(10, decimals);
13786 var nnr = t.toFixed(decimals);
13787 var replaceRange = new Range(row, nr.start, row, nr.end);
13788 this.session.replace(replaceRange, nnr);
13789 this.moveCursorTo(row, Math.max(nr.start +1, column + nnr.length - nr.value.length));
13790
13791 }
13792 }
13793 };
13794 this.removeLines = function() {
13795 var rows = this.$getSelectedRows();
13796 this.session.removeFullLines(rows.first, rows.last);
13797 this.clearSelection();
13798 };
13799
13800 this.duplicateSelection = function() {
13801 var sel = this.selection;
13802 var doc = this.session;
13803 var range = sel.getRange();
13804 var reverse = sel.isBackwards();
13805 if (range.isEmpty()) {
13806 var row = range.start.row;
13807 doc.duplicateLines(row, row);
13808 } else {
13809 var point = reverse ? range.start : range.end;
13810 var endPoint = doc.insert(point, doc.getTextRange(range), false);
13811 range.start = point;
13812 range.end = endPoint;
13813
13814 sel.setSelectionRange(range, reverse);
13815 }
13816 };
13817 this.moveLinesDown = function() {
13818 this.$moveLines(1, false);
13819 };
13820 this.moveLinesUp = function() {
13821 this.$moveLines(-1, false);
13822 };
13823 this.moveText = function(range, toPosition, copy) {
13824 return this.session.moveText(range, toPosition, copy);
13825 };
13826 this.copyLinesUp = function() {
13827 this.$moveLines(-1, true);
13828 };
13829 this.copyLinesDown = function() {
13830 this.$moveLines(1, true);
13831 };
13832 this.$moveLines = function(dir, copy) {
13833 var rows, moved;
13834 var selection = this.selection;
13835 if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
13836 var range = selection.toOrientedRange();
13837 rows = this.$getSelectedRows(range);
13838 moved = this.session.$moveLines(rows.first, rows.last, copy ? 0 : dir);
13839 if (copy && dir == -1) moved = 0;
13840 range.moveBy(moved, 0);
13841 selection.fromOrientedRange(range);
13842 } else {
13843 var ranges = selection.rangeList.ranges;
13844 selection.rangeList.detach(this.session);
13845 this.inVirtualSelectionMode = true;
13846
13847 var diff = 0;
13848 var totalDiff = 0;
13849 var l = ranges.length;
13850 for (var i = 0; i < l; i++) {
13851 var rangeIndex = i;
13852 ranges[i].moveBy(diff, 0);
13853 rows = this.$getSelectedRows(ranges[i]);
13854 var first = rows.first;
13855 var last = rows.last;
13856 while (++i < l) {
13857 if (totalDiff) ranges[i].moveBy(totalDiff, 0);
13858 var subRows = this.$getSelectedRows(ranges[i]);
13859 if (copy && subRows.first != last)
13860 break;
13861 else if (!copy && subRows.first > last + 1)
13862 break;
13863 last = subRows.last;
13864 }
13865 i--;
13866 diff = this.session.$moveLines(first, last, copy ? 0 : dir);
13867 if (copy && dir == -1) rangeIndex = i + 1;
13868 while (rangeIndex <= i) {
13869 ranges[rangeIndex].moveBy(diff, 0);
13870 rangeIndex++;
13871 }
13872 if (!copy) diff = 0;
13873 totalDiff += diff;
13874 }
13875
13876 selection.fromOrientedRange(selection.ranges[0]);
13877 selection.rangeList.attach(this.session);
13878 this.inVirtualSelectionMode = false;
13879 }
13880 };
13881 this.$getSelectedRows = function(range) {
13882 range = (range || this.getSelectionRange()).collapseRows();
13883
13884 return {
13885 first: this.session.getRowFoldStart(range.start.row),
13886 last: this.session.getRowFoldEnd(range.end.row)
13887 };
13888 };
13889
13890 this.onCompositionStart = function(text) {
13891 this.renderer.showComposition(this.getCursorPosition());
13892 };
13893
13894 this.onCompositionUpdate = function(text) {
13895 this.renderer.setCompositionText(text);
13896 };
13897
13898 this.onCompositionEnd = function() {
13899 this.renderer.hideComposition();
13900 };
13901 this.getFirstVisibleRow = function() {
13902 return this.renderer.getFirstVisibleRow();
13903 };
13904 this.getLastVisibleRow = function() {
13905 return this.renderer.getLastVisibleRow();
13906 };
13907 this.isRowVisible = function(row) {
13908 return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow());
13909 };
13910 this.isRowFullyVisible = function(row) {
13911 return (row >= this.renderer.getFirstFullyVisibleRow() && row <= this.renderer.getLastFullyVisibleRow());
13912 };
13913 this.$getVisibleRowCount = function() {
13914 return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1;
13915 };
13916
13917 this.$moveByPage = function(dir, select) {
13918 var renderer = this.renderer;
13919 var config = this.renderer.layerConfig;
13920 var rows = dir * Math.floor(config.height / config.lineHeight);
13921
13922 this.$blockScrolling++;
13923 if (select === true) {
13924 this.selection.$moveSelection(function(){
13925 this.moveCursorBy(rows, 0);
13926 });
13927 } else if (select === false) {
13928 this.selection.moveCursorBy(rows, 0);
13929 this.selection.clearSelection();
13930 }
13931 this.$blockScrolling--;
13932
13933 var scrollTop = renderer.scrollTop;
13934
13935 renderer.scrollBy(0, rows * config.lineHeight);
13936 if (select != null)
13937 renderer.scrollCursorIntoView(null, 0.5);
13938
13939 renderer.animateScrolling(scrollTop);
13940 };
13941 this.selectPageDown = function() {
13942 this.$moveByPage(1, true);
13943 };
13944 this.selectPageUp = function() {
13945 this.$moveByPage(-1, true);
13946 };
13947 this.gotoPageDown = function() {
13948 this.$moveByPage(1, false);
13949 };
13950 this.gotoPageUp = function() {
13951 this.$moveByPage(-1, false);
13952 };
13953 this.scrollPageDown = function() {
13954 this.$moveByPage(1);
13955 };
13956 this.scrollPageUp = function() {
13957 this.$moveByPage(-1);
13958 };
13959 this.scrollToRow = function(row) {
13960 this.renderer.scrollToRow(row);
13961 };
13962 this.scrollToLine = function(line, center, animate, callback) {
13963 this.renderer.scrollToLine(line, center, animate, callback);
13964 };
13965 this.centerSelection = function() {
13966 var range = this.getSelectionRange();
13967 var pos = {
13968 row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2),
13969 column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2)
13970 };
13971 this.renderer.alignCursor(pos, 0.5);
13972 };
13973 this.getCursorPosition = function() {
13974 return this.selection.getCursor();
13975 };
13976 this.getCursorPositionScreen = function() {
13977 return this.session.documentToScreenPosition(this.getCursorPosition());
13978 };
13979 this.getSelectionRange = function() {
13980 return this.selection.getRange();
13981 };
13982 this.selectAll = function() {
13983 this.$blockScrolling += 1;
13984 this.selection.selectAll();
13985 this.$blockScrolling -= 1;
13986 };
13987 this.clearSelection = function() {
13988 this.selection.clearSelection();
13989 };
13990 this.moveCursorTo = function(row, column) {
13991 this.selection.moveCursorTo(row, column);
13992 };
13993 this.moveCursorToPosition = function(pos) {
13994 this.selection.moveCursorToPosition(pos);
13995 };
13996 this.jumpToMatching = function(select, expand) {
13997 var cursor = this.getCursorPosition();
13998 var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
13999 var prevToken = iterator.getCurrentToken();
14000 var token = prevToken || iterator.stepForward();
14001
14002 if (!token) return;
14003 var matchType;
14004 var found = false;
14005 var depth = {};
14006 var i = cursor.column - token.start;
14007 var bracketType;
14008 var brackets = {
14009 ")": "(",
14010 "(": "(",
14011 "]": "[",
14012 "[": "[",
14013 "{": "{",
14014 "}": "{"
14015 };
14016
14017 do {
14018 if (token.value.match(/[{}()\[\]]/g)) {
14019 for (; i < token.value.length && !found; i++) {
14020 if (!brackets[token.value[i]]) {
14021 continue;
14022 }
14023
14024 bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen");
14025
14026 if (isNaN(depth[bracketType])) {
14027 depth[bracketType] = 0;
14028 }
14029
14030 switch (token.value[i]) {
14031 case '(':
14032 case '[':
14033 case '{':
14034 depth[bracketType]++;
14035 break;
14036 case ')':
14037 case ']':
14038 case '}':
14039 depth[bracketType]--;
14040
14041 if (depth[bracketType] === -1) {
14042 matchType = 'bracket';
14043 found = true;
14044 }
14045 break;
14046 }
14047 }
14048 }
14049 else if (token && token.type.indexOf('tag-name') !== -1) {
14050 if (isNaN(depth[token.value])) {
14051 depth[token.value] = 0;
14052 }
14053
14054 if (prevToken.value === '<') {
14055 depth[token.value]++;
14056 }
14057 else if (prevToken.value === '</') {
14058 depth[token.value]--;
14059 }
14060
14061 if (depth[token.value] === -1) {
14062 matchType = 'tag';
14063 found = true;
14064 }
14065 }
14066
14067 if (!found) {
14068 prevToken = token;
14069 token = iterator.stepForward();
14070 i = 0;
14071 }
14072 } while (token && !found);
14073 if (!matchType)
14074 return;
14075
14076 var range, pos;
14077 if (matchType === 'bracket') {
14078 range = this.session.getBracketRange(cursor);
14079 if (!range) {
14080 range = new Range(
14081 iterator.getCurrentTokenRow(),
14082 iterator.getCurrentTokenColumn() + i - 1,
14083 iterator.getCurrentTokenRow(),
14084 iterator.getCurrentTokenColumn() + i - 1
14085 );
14086 pos = range.start;
14087 if (expand || pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
14088 range = this.session.getBracketRange(pos);
14089 }
14090 }
14091 else if (matchType === 'tag') {
14092 if (token && token.type.indexOf('tag-name') !== -1)
14093 var tag = token.value;
14094 else
14095 return;
14096
14097 range = new Range(
14098 iterator.getCurrentTokenRow(),
14099 iterator.getCurrentTokenColumn() - 2,
14100 iterator.getCurrentTokenRow(),
14101 iterator.getCurrentTokenColumn() - 2
14102 );
14103 if (range.compare(cursor.row, cursor.column) === 0) {
14104 found = false;
14105 do {
14106 token = prevToken;
14107 prevToken = iterator.stepBackward();
14108
14109 if (prevToken) {
14110 if (prevToken.type.indexOf('tag-close') !== -1) {
14111 range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1);
14112 }
14113
14114 if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
14115 if (prevToken.value === '<') {
14116 depth[tag]++;
14117 }
14118 else if (prevToken.value === '</') {
14119 depth[tag]--;
14120 }
14121
14122 if (depth[tag] === 0)
14123 found = true;
14124 }
14125 }
14126 } while (prevToken && !found);
14127 }
14128 if (token && token.type.indexOf('tag-name')) {
14129 pos = range.start;
14130 if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
14131 pos = range.end;
14132 }
14133 }
14134
14135 pos = range && range.cursor || pos;
14136 if (pos) {
14137 if (select) {
14138 if (range && expand) {
14139 this.selection.setRange(range);
14140 } else if (range && range.isEqual(this.getSelectionRange())) {
14141 this.clearSelection();
14142 } else {
14143 this.selection.selectTo(pos.row, pos.column);
14144 }
14145 } else {
14146 this.selection.moveTo(pos.row, pos.column);
14147 }
14148 }
14149 };
14150 this.gotoLine = function(lineNumber, column, animate) {
14151 this.selection.clearSelection();
14152 this.session.unfold({row: lineNumber - 1, column: column || 0});
14153
14154 this.$blockScrolling += 1;
14155 this.exitMultiSelectMode && this.exitMultiSelectMode();
14156 this.moveCursorTo(lineNumber - 1, column || 0);
14157 this.$blockScrolling -= 1;
14158
14159 if (!this.isRowFullyVisible(lineNumber - 1))
14160 this.scrollToLine(lineNumber - 1, true, animate);
14161 };
14162 this.navigateTo = function(row, column) {
14163 this.selection.moveTo(row, column);
14164 };
14165 this.navigateUp = function(times) {
14166 if (this.selection.isMultiLine() && !this.selection.isBackwards()) {
14167 var selectionStart = this.selection.anchor.getPosition();
14168 return this.moveCursorToPosition(selectionStart);
14169 }
14170 this.selection.clearSelection();
14171 this.selection.moveCursorBy(-times || -1, 0);
14172 };
14173 this.navigateDown = function(times) {
14174 if (this.selection.isMultiLine() && this.selection.isBackwards()) {
14175 var selectionEnd = this.selection.anchor.getPosition();
14176 return this.moveCursorToPosition(selectionEnd);
14177 }
14178 this.selection.clearSelection();
14179 this.selection.moveCursorBy(times || 1, 0);
14180 };
14181 this.navigateLeft = function(times) {
14182 if (!this.selection.isEmpty()) {
14183 var selectionStart = this.getSelectionRange().start;
14184 this.moveCursorToPosition(selectionStart);
14185 }
14186 else {
14187 times = times || 1;
14188 while (times--) {
14189 this.selection.moveCursorLeft();
14190 }
14191 }
14192 this.clearSelection();
14193 };
14194 this.navigateRight = function(times) {
14195 if (!this.selection.isEmpty()) {
14196 var selectionEnd = this.getSelectionRange().end;
14197 this.moveCursorToPosition(selectionEnd);
14198 }
14199 else {
14200 times = times || 1;
14201 while (times--) {
14202 this.selection.moveCursorRight();
14203 }
14204 }
14205 this.clearSelection();
14206 };
14207 this.navigateLineStart = function() {
14208 this.selection.moveCursorLineStart();
14209 this.clearSelection();
14210 };
14211 this.navigateLineEnd = function() {
14212 this.selection.moveCursorLineEnd();
14213 this.clearSelection();
14214 };
14215 this.navigateFileEnd = function() {
14216 this.selection.moveCursorFileEnd();
14217 this.clearSelection();
14218 };
14219 this.navigateFileStart = function() {
14220 this.selection.moveCursorFileStart();
14221 this.clearSelection();
14222 };
14223 this.navigateWordRight = function() {
14224 this.selection.moveCursorWordRight();
14225 this.clearSelection();
14226 };
14227 this.navigateWordLeft = function() {
14228 this.selection.moveCursorWordLeft();
14229 this.clearSelection();
14230 };
14231 this.replace = function(replacement, options) {
14232 if (options)
14233 this.$search.set(options);
14234
14235 var range = this.$search.find(this.session);
14236 var replaced = 0;
14237 if (!range)
14238 return replaced;
14239
14240 if (this.$tryReplace(range, replacement)) {
14241 replaced = 1;
14242 }
14243 if (range !== null) {
14244 this.selection.setSelectionRange(range);
14245 this.renderer.scrollSelectionIntoView(range.start, range.end);
14246 }
14247
14248 return replaced;
14249 };
14250 this.replaceAll = function(replacement, options) {
14251 if (options) {
14252 this.$search.set(options);
14253 }
14254
14255 var ranges = this.$search.findAll(this.session);
14256 var replaced = 0;
14257 if (!ranges.length)
14258 return replaced;
14259
14260 this.$blockScrolling += 1;
14261
14262 var selection = this.getSelectionRange();
14263 this.selection.moveTo(0, 0);
14264
14265 for (var i = ranges.length - 1; i >= 0; --i) {
14266 if(this.$tryReplace(ranges[i], replacement)) {
14267 replaced++;
14268 }
14269 }
14270
14271 this.selection.setSelectionRange(selection);
14272 this.$blockScrolling -= 1;
14273
14274 return replaced;
14275 };
14276
14277 this.$tryReplace = function(range, replacement) {
14278 var input = this.session.getTextRange(range);
14279 replacement = this.$search.replace(input, replacement);
14280 if (replacement !== null) {
14281 range.end = this.session.replace(range, replacement);
14282 return range;
14283 } else {
14284 return null;
14285 }
14286 };
14287 this.getLastSearchOptions = function() {
14288 return this.$search.getOptions();
14289 };
14290 this.find = function(needle, options, animate) {
14291 if (!options)
14292 options = {};
14293
14294 if (typeof needle == "string" || needle instanceof RegExp)
14295 options.needle = needle;
14296 else if (typeof needle == "object")
14297 oop.mixin(options, needle);
14298
14299 var range = this.selection.getRange();
14300 if (options.needle == null) {
14301 needle = this.session.getTextRange(range)
14302 || this.$search.$options.needle;
14303 if (!needle) {
14304 range = this.session.getWordRange(range.start.row, range.start.column);
14305 needle = this.session.getTextRange(range);
14306 }
14307 this.$search.set({needle: needle});
14308 }
14309
14310 this.$search.set(options);
14311 if (!options.start)
14312 this.$search.set({start: range});
14313
14314 var newRange = this.$search.find(this.session);
14315 if (options.preventScroll)
14316 return newRange;
14317 if (newRange) {
14318 this.revealRange(newRange, animate);
14319 return newRange;
14320 }
14321 if (options.backwards)
14322 range.start = range.end;
14323 else
14324 range.end = range.start;
14325 this.selection.setRange(range);
14326 };
14327 this.findNext = function(options, animate) {
14328 this.find({skipCurrent: true, backwards: false}, options, animate);
14329 };
14330 this.findPrevious = function(options, animate) {
14331 this.find(options, {skipCurrent: true, backwards: true}, animate);
14332 };
14333
14334 this.revealRange = function(range, animate) {
14335 this.$blockScrolling += 1;
14336 this.session.unfold(range);
14337 this.selection.setSelectionRange(range);
14338 this.$blockScrolling -= 1;
14339
14340 var scrollTop = this.renderer.scrollTop;
14341 this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
14342 if (animate !== false)
14343 this.renderer.animateScrolling(scrollTop);
14344 };
14345 this.undo = function() {
14346 this.$blockScrolling++;
14347 this.session.getUndoManager().undo();
14348 this.$blockScrolling--;
14349 this.renderer.scrollCursorIntoView(null, 0.5);
14350 };
14351 this.redo = function() {
14352 this.$blockScrolling++;
14353 this.session.getUndoManager().redo();
14354 this.$blockScrolling--;
14355 this.renderer.scrollCursorIntoView(null, 0.5);
14356 };
14357 this.destroy = function() {
14358 this.renderer.destroy();
14359 this._signal("destroy", this);
14360 if (this.session) {
14361 this.session.destroy();
14362 }
14363 };
14364 this.setAutoScrollEditorIntoView = function(enable) {
14365 if (!enable)
14366 return;
14367 var rect;
14368 var self = this;
14369 var shouldScroll = false;
14370 if (!this.$scrollAnchor)
14371 this.$scrollAnchor = document.createElement("div");
14372 var scrollAnchor = this.$scrollAnchor;
14373 scrollAnchor.style.cssText = "position:absolute";
14374 this.container.insertBefore(scrollAnchor, this.container.firstChild);
14375 var onChangeSelection = this.on("changeSelection", function() {
14376 shouldScroll = true;
14377 });
14378 var onBeforeRender = this.renderer.on("beforeRender", function() {
14379 if (shouldScroll)
14380 rect = self.renderer.container.getBoundingClientRect();
14381 });
14382 var onAfterRender = this.renderer.on("afterRender", function() {
14383 if (shouldScroll && rect && (self.isFocused()
14384 || self.searchBox && self.searchBox.isFocused())
14385 ) {
14386 var renderer = self.renderer;
14387 var pos = renderer.$cursorLayer.$pixelPos;
14388 var config = renderer.layerConfig;
14389 var top = pos.top - config.offset;
14390 if (pos.top >= 0 && top + rect.top < 0) {
14391 shouldScroll = true;
14392 } else if (pos.top < config.height &&
14393 pos.top + rect.top + config.lineHeight > window.innerHeight) {
14394 shouldScroll = false;
14395 } else {
14396 shouldScroll = null;
14397 }
14398 if (shouldScroll != null) {
14399 scrollAnchor.style.top = top + "px";
14400 scrollAnchor.style.left = pos.left + "px";
14401 scrollAnchor.style.height = config.lineHeight + "px";
14402 scrollAnchor.scrollIntoView(shouldScroll);
14403 }
14404 shouldScroll = rect = null;
14405 }
14406 });
14407 this.setAutoScrollEditorIntoView = function(enable) {
14408 if (enable)
14409 return;
14410 delete this.setAutoScrollEditorIntoView;
14411 this.off("changeSelection", onChangeSelection);
14412 this.renderer.off("afterRender", onAfterRender);
14413 this.renderer.off("beforeRender", onBeforeRender);
14414 };
14415 };
14416
14417
14418 this.$resetCursorStyle = function() {
14419 var style = this.$cursorStyle || "ace";
14420 var cursorLayer = this.renderer.$cursorLayer;
14421 if (!cursorLayer)
14422 return;
14423 cursorLayer.setSmoothBlinking(/smooth/.test(style));
14424 cursorLayer.isBlinking = !this.$readOnly && style != "wide";
14425 dom.setCssClass(cursorLayer.element, "ace_slim-cursors", /slim/.test(style));
14426 };
14427
14428 }).call(Editor.prototype);
14429
14430
14431
14432 config.defineOptions(Editor.prototype, "editor", {
14433 selectionStyle: {
14434 set: function(style) {
14435 this.onSelectionChange();
14436 this._signal("changeSelectionStyle", {data: style});
14437 },
14438 initialValue: "line"
14439 },
14440 highlightActiveLine: {
14441 set: function() {this.$updateHighlightActiveLine();},
14442 initialValue: true
14443 },
14444 highlightSelectedWord: {
14445 set: function(shouldHighlight) {this.$onSelectionChange();},
14446 initialValue: true
14447 },
14448 readOnly: {
14449 set: function(readOnly) {
14450 this.$resetCursorStyle();
14451 },
14452 initialValue: false
14453 },
14454 cursorStyle: {
14455 set: function(val) { this.$resetCursorStyle(); },
14456 values: ["ace", "slim", "smooth", "wide"],
14457 initialValue: "ace"
14458 },
14459 mergeUndoDeltas: {
14460 values: [false, true, "always"],
14461 initialValue: true
14462 },
14463 behavioursEnabled: {initialValue: true},
14464 wrapBehavioursEnabled: {initialValue: true},
14465 autoScrollEditorIntoView: {
14466 set: function(val) {this.setAutoScrollEditorIntoView(val);}
14467 },
14468 keyboardHandler: {
14469 set: function(val) { this.setKeyboardHandler(val); },
14470 get: function() { return this.keybindingId; },
14471 handlesSet: true
14472 },
14473
14474 hScrollBarAlwaysVisible: "renderer",
14475 vScrollBarAlwaysVisible: "renderer",
14476 highlightGutterLine: "renderer",
14477 animatedScroll: "renderer",
14478 showInvisibles: "renderer",
14479 showPrintMargin: "renderer",
14480 printMarginColumn: "renderer",
14481 printMargin: "renderer",
14482 fadeFoldWidgets: "renderer",
14483 showFoldWidgets: "renderer",
14484 showLineNumbers: "renderer",
14485 showGutter: "renderer",
14486 displayIndentGuides: "renderer",
14487 fontSize: "renderer",
14488 fontFamily: "renderer",
14489 maxLines: "renderer",
14490 minLines: "renderer",
14491 scrollPastEnd: "renderer",
14492 fixedWidthGutter: "renderer",
14493 theme: "renderer",
14494
14495 scrollSpeed: "$mouseHandler",
14496 dragDelay: "$mouseHandler",
14497 dragEnabled: "$mouseHandler",
14498 focusTimout: "$mouseHandler",
14499 tooltipFollowsMouse: "$mouseHandler",
14500
14501 firstLineNumber: "session",
14502 overwrite: "session",
14503 newLineMode: "session",
14504 useWorker: "session",
14505 useSoftTabs: "session",
14506 tabSize: "session",
14507 wrap: "session",
14508 indentedSoftWrap: "session",
14509 foldStyle: "session",
14510 mode: "session"
14511 });
14512
14513 exports.Editor = Editor;
14514 });
14515
14516 ace.define("ace/undomanager",["require","exports","module"], function(acequire, exports, module) {
14517 var UndoManager = function() {
14518 this.reset();
14519 };
14520
14521 (function() {
14522 this.execute = function(options) {
14523 var deltaSets = options.args[0];
14524 this.$doc = options.args[1];
14525 if (options.merge && this.hasUndo()){
14526 this.dirtyCounter--;
14527 deltaSets = this.$undoStack.pop().concat(deltaSets);
14528 }
14529 this.$undoStack.push(deltaSets);
14530 this.$redoStack = [];
14531 if (this.dirtyCounter < 0) {
14532 this.dirtyCounter = NaN;
14533 }
14534 this.dirtyCounter++;
14535 };
14536 this.undo = function(dontSelect) {
14537 var deltaSets = this.$undoStack.pop();
14538 var undoSelectionRange = null;
14539 if (deltaSets) {
14540 undoSelectionRange = this.$doc.undoChanges(deltaSets, dontSelect);
14541 this.$redoStack.push(deltaSets);
14542 this.dirtyCounter--;
14543 }
14544
14545 return undoSelectionRange;
14546 };
14547 this.redo = function(dontSelect) {
14548 var deltaSets = this.$redoStack.pop();
14549 var redoSelectionRange = null;
14550 if (deltaSets) {
14551 redoSelectionRange =
14552 this.$doc.redoChanges(this.$deserializeDeltas(deltaSets), dontSelect);
14553 this.$undoStack.push(deltaSets);
14554 this.dirtyCounter++;
14555 }
14556 return redoSelectionRange;
14557 };
14558 this.reset = function() {
14559 this.$undoStack = [];
14560 this.$redoStack = [];
14561 this.dirtyCounter = 0;
14562 };
14563 this.hasUndo = function() {
14564 return this.$undoStack.length > 0;
14565 };
14566 this.hasRedo = function() {
14567 return this.$redoStack.length > 0;
14568 };
14569 this.markClean = function() {
14570 this.dirtyCounter = 0;
14571 };
14572 this.isClean = function() {
14573 return this.dirtyCounter === 0;
14574 };
14575 this.$serializeDeltas = function(deltaSets) {
14576 return cloneDeltaSetsObj(deltaSets, $serializeDelta);
14577 };
14578 this.$deserializeDeltas = function(deltaSets) {
14579 return cloneDeltaSetsObj(deltaSets, $deserializeDelta);
14580 };
14581
14582 function $serializeDelta(delta){
14583 return {
14584 action: delta.action,
14585 start: delta.start,
14586 end: delta.end,
14587 lines: delta.lines.length == 1 ? null : delta.lines,
14588 text: delta.lines.length == 1 ? delta.lines[0] : null
14589 };
14590 }
14591
14592 function $deserializeDelta(delta) {
14593 return {
14594 action: delta.action,
14595 start: delta.start,
14596 end: delta.end,
14597 lines: delta.lines || [delta.text]
14598 };
14599 }
14600
14601 function cloneDeltaSetsObj(deltaSets_old, fnGetModifiedDelta) {
14602 var deltaSets_new = new Array(deltaSets_old.length);
14603 for (var i = 0; i < deltaSets_old.length; i++) {
14604 var deltaSet_old = deltaSets_old[i];
14605 var deltaSet_new = { group: deltaSet_old.group, deltas: new Array(deltaSet_old.length)};
14606
14607 for (var j = 0; j < deltaSet_old.deltas.length; j++) {
14608 var delta_old = deltaSet_old.deltas[j];
14609 deltaSet_new.deltas[j] = fnGetModifiedDelta(delta_old);
14610 }
14611
14612 deltaSets_new[i] = deltaSet_new;
14613 }
14614 return deltaSets_new;
14615 }
14616
14617 }).call(UndoManager.prototype);
14618
14619 exports.UndoManager = UndoManager;
14620 });
14621
14622 ace.define("ace/layer/gutter",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter"], function(acequire, exports, module) {
14623
14624 var dom = acequire("../lib/dom");
14625 var oop = acequire("../lib/oop");
14626 var lang = acequire("../lib/lang");
14627 var EventEmitter = acequire("../lib/event_emitter").EventEmitter;
14628
14629 var Gutter = function(parentEl) {
14630 this.element = dom.createElement("div");
14631 this.element.className = "ace_layer ace_gutter-layer";
14632 parentEl.appendChild(this.element);
14633 this.setShowFoldWidgets(this.$showFoldWidgets);
14634
14635 this.gutterWidth = 0;
14636
14637 this.$annotations = [];
14638 this.$updateAnnotations = this.$updateAnnotations.bind(this);
14639
14640 this.$cells = [];
14641 };
14642
14643 (function() {
14644
14645 oop.implement(this, EventEmitter);
14646
14647 this.setSession = function(session) {
14648 if (this.session)
14649 this.session.removeEventListener("change", this.$updateAnnotations);
14650 this.session = session;
14651 if (session)
14652 session.on("change", this.$updateAnnotations);
14653 };
14654
14655 this.addGutterDecoration = function(row, className){
14656 if (window.console)
14657 console.warn && console.warn("deprecated use session.addGutterDecoration");
14658 this.session.addGutterDecoration(row, className);
14659 };
14660
14661 this.removeGutterDecoration = function(row, className){
14662 if (window.console)
14663 console.warn && console.warn("deprecated use session.removeGutterDecoration");
14664 this.session.removeGutterDecoration(row, className);
14665 };
14666
14667 this.setAnnotations = function(annotations) {
14668 this.$annotations = [];
14669 for (var i = 0; i < annotations.length; i++) {
14670 var annotation = annotations[i];
14671 var row = annotation.row;
14672 var rowInfo = this.$annotations[row];
14673 if (!rowInfo)
14674 rowInfo = this.$annotations[row] = {text: []};
14675
14676 var annoText = annotation.text;
14677 annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
14678
14679 if (rowInfo.text.indexOf(annoText) === -1)
14680 rowInfo.text.push(annoText);
14681
14682 var type = annotation.type;
14683 if (type == "error")
14684 rowInfo.className = " ace_error";
14685 else if (type == "warning" && rowInfo.className != " ace_error")
14686 rowInfo.className = " ace_warning";
14687 else if (type == "info" && (!rowInfo.className))
14688 rowInfo.className = " ace_info";
14689 }
14690 };
14691
14692 this.$updateAnnotations = function (delta) {
14693 if (!this.$annotations.length)
14694 return;
14695 var firstRow = delta.start.row;
14696 var len = delta.end.row - firstRow;
14697 if (len === 0) ; else if (delta.action == 'remove') {
14698 this.$annotations.splice(firstRow, len + 1, null);
14699 } else {
14700 var args = new Array(len + 1);
14701 args.unshift(firstRow, 1);
14702 this.$annotations.splice.apply(this.$annotations, args);
14703 }
14704 };
14705
14706 this.update = function(config) {
14707 var session = this.session;
14708 var firstRow = config.firstRow;
14709 var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar
14710 session.getLength() - 1);
14711 var fold = session.getNextFoldLine(firstRow);
14712 var foldStart = fold ? fold.start.row : Infinity;
14713 var foldWidgets = this.$showFoldWidgets && session.foldWidgets;
14714 var breakpoints = session.$breakpoints;
14715 var decorations = session.$decorations;
14716 var firstLineNumber = session.$firstLineNumber;
14717 var lastLineNumber = 0;
14718
14719 var gutterRenderer = session.gutterRenderer || this.$renderer;
14720
14721 var cell = null;
14722 var index = -1;
14723 var row = firstRow;
14724 while (true) {
14725 if (row > foldStart) {
14726 row = fold.end.row + 1;
14727 fold = session.getNextFoldLine(row, fold);
14728 foldStart = fold ? fold.start.row : Infinity;
14729 }
14730 if (row > lastRow) {
14731 while (this.$cells.length > index + 1) {
14732 cell = this.$cells.pop();
14733 this.element.removeChild(cell.element);
14734 }
14735 break;
14736 }
14737
14738 cell = this.$cells[++index];
14739 if (!cell) {
14740 cell = {element: null, textNode: null, foldWidget: null};
14741 cell.element = dom.createElement("div");
14742 cell.textNode = document.createTextNode('');
14743 cell.element.appendChild(cell.textNode);
14744 this.element.appendChild(cell.element);
14745 this.$cells[index] = cell;
14746 }
14747
14748 var className = "ace_gutter-cell ";
14749 if (breakpoints[row])
14750 className += breakpoints[row];
14751 if (decorations[row])
14752 className += decorations[row];
14753 if (this.$annotations[row])
14754 className += this.$annotations[row].className;
14755 if (cell.element.className != className)
14756 cell.element.className = className;
14757
14758 var height = session.getRowLength(row) * config.lineHeight + "px";
14759 if (height != cell.element.style.height)
14760 cell.element.style.height = height;
14761
14762 if (foldWidgets) {
14763 var c = foldWidgets[row];
14764 if (c == null)
14765 c = foldWidgets[row] = session.getFoldWidget(row);
14766 }
14767
14768 if (c) {
14769 if (!cell.foldWidget) {
14770 cell.foldWidget = dom.createElement("span");
14771 cell.element.appendChild(cell.foldWidget);
14772 }
14773 var className = "ace_fold-widget ace_" + c;
14774 if (c == "start" && row == foldStart && row < fold.end.row)
14775 className += " ace_closed";
14776 else
14777 className += " ace_open";
14778 if (cell.foldWidget.className != className)
14779 cell.foldWidget.className = className;
14780
14781 var height = config.lineHeight + "px";
14782 if (cell.foldWidget.style.height != height)
14783 cell.foldWidget.style.height = height;
14784 } else {
14785 if (cell.foldWidget) {
14786 cell.element.removeChild(cell.foldWidget);
14787 cell.foldWidget = null;
14788 }
14789 }
14790
14791 var text = lastLineNumber = gutterRenderer
14792 ? gutterRenderer.getText(session, row)
14793 : row + firstLineNumber;
14794 if (text !== cell.textNode.data)
14795 cell.textNode.data = text;
14796
14797 row++;
14798 }
14799
14800 this.element.style.height = config.minHeight + "px";
14801
14802 if (this.$fixedWidth || session.$useWrapMode)
14803 lastLineNumber = session.getLength() + firstLineNumber;
14804
14805 var gutterWidth = gutterRenderer
14806 ? gutterRenderer.getWidth(session, lastLineNumber, config)
14807 : lastLineNumber.toString().length * config.characterWidth;
14808
14809 var padding = this.$padding || this.$computePadding();
14810 gutterWidth += padding.left + padding.right;
14811 if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) {
14812 this.gutterWidth = gutterWidth;
14813 this.element.style.width = Math.ceil(this.gutterWidth) + "px";
14814 this._emit("changeGutterWidth", gutterWidth);
14815 }
14816 };
14817
14818 this.$fixedWidth = false;
14819
14820 this.$showLineNumbers = true;
14821 this.$renderer = "";
14822 this.setShowLineNumbers = function(show) {
14823 this.$renderer = !show && {
14824 getWidth: function() {return "";},
14825 getText: function() {return "";}
14826 };
14827 };
14828
14829 this.getShowLineNumbers = function() {
14830 return this.$showLineNumbers;
14831 };
14832
14833 this.$showFoldWidgets = true;
14834 this.setShowFoldWidgets = function(show) {
14835 if (show)
14836 dom.addCssClass(this.element, "ace_folding-enabled");
14837 else
14838 dom.removeCssClass(this.element, "ace_folding-enabled");
14839
14840 this.$showFoldWidgets = show;
14841 this.$padding = null;
14842 };
14843
14844 this.getShowFoldWidgets = function() {
14845 return this.$showFoldWidgets;
14846 };
14847
14848 this.$computePadding = function() {
14849 if (!this.element.firstChild)
14850 return {left: 0, right: 0};
14851 var style = dom.computedStyle(this.element.firstChild);
14852 this.$padding = {};
14853 this.$padding.left = parseInt(style.paddingLeft) + 1 || 0;
14854 this.$padding.right = parseInt(style.paddingRight) || 0;
14855 return this.$padding;
14856 };
14857
14858 this.getRegion = function(point) {
14859 var padding = this.$padding || this.$computePadding();
14860 var rect = this.element.getBoundingClientRect();
14861 if (point.x < padding.left + rect.left)
14862 return "markers";
14863 if (this.$showFoldWidgets && point.x > rect.right - padding.right)
14864 return "foldWidgets";
14865 };
14866
14867 }).call(Gutter.prototype);
14868
14869 exports.Gutter = Gutter;
14870
14871 });
14872
14873 ace.define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"], function(acequire, exports, module) {
14874
14875 var Range = acequire("../range").Range;
14876 var dom = acequire("../lib/dom");
14877
14878 var Marker = function(parentEl) {
14879 this.element = dom.createElement("div");
14880 this.element.className = "ace_layer ace_marker-layer";
14881 parentEl.appendChild(this.element);
14882 };
14883
14884 (function() {
14885
14886 this.$padding = 0;
14887
14888 this.setPadding = function(padding) {
14889 this.$padding = padding;
14890 };
14891 this.setSession = function(session) {
14892 this.session = session;
14893 };
14894
14895 this.setMarkers = function(markers) {
14896 this.markers = markers;
14897 };
14898
14899 this.update = function(config) {
14900 if (!config) return;
14901
14902 this.config = config;
14903
14904
14905 var html = [];
14906 for (var key in this.markers) {
14907 var marker = this.markers[key];
14908
14909 if (!marker.range) {
14910 marker.update(html, this, this.session, config);
14911 continue;
14912 }
14913
14914 var range = marker.range.clipRows(config.firstRow, config.lastRow);
14915 if (range.isEmpty()) continue;
14916
14917 range = range.toScreenRange(this.session);
14918 if (marker.renderer) {
14919 var top = this.$getTop(range.start.row, config);
14920 var left = this.$padding + (this.session.$bidiHandler.isBidiRow(range.start.row)
14921 ? this.session.$bidiHandler.getPosLeft(range.start.column)
14922 : range.start.column * config.characterWidth);
14923 marker.renderer(html, range, left, top, config);
14924 } else if (marker.type == "fullLine") {
14925 this.drawFullLineMarker(html, range, marker.clazz, config);
14926 } else if (marker.type == "screenLine") {
14927 this.drawScreenLineMarker(html, range, marker.clazz, config);
14928 } else if (range.isMultiLine()) {
14929 if (marker.type == "text")
14930 this.drawTextMarker(html, range, marker.clazz, config);
14931 else
14932 this.drawMultiLineMarker(html, range, marker.clazz, config);
14933 } else {
14934 if (this.session.$bidiHandler.isBidiRow(range.start.row)) {
14935 this.drawBidiSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config);
14936 } else {
14937 this.drawSingleLineMarker(html, range, marker.clazz + " ace_start" + " ace_br15", config);
14938 }
14939 }
14940 }
14941 this.element.innerHTML = html.join("");
14942 };
14943
14944 this.$getTop = function(row, layerConfig) {
14945 return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
14946 };
14947
14948 function getBorderClass(tl, tr, br, bl) {
14949 return (tl ? 1 : 0) | (tr ? 2 : 0) | (br ? 4 : 0) | (bl ? 8 : 0);
14950 }
14951 this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
14952 var session = this.session;
14953 var start = range.start.row;
14954 var end = range.end.row;
14955 var row = start;
14956 var prev = 0;
14957 var curr = 0;
14958 var next = session.getScreenLastRowColumn(row);
14959 var clazzModified = null;
14960 var lineRange = new Range(row, range.start.column, row, curr);
14961 for (; row <= end; row++) {
14962 lineRange.start.row = lineRange.end.row = row;
14963 lineRange.start.column = row == start ? range.start.column : session.getRowWrapIndent(row);
14964 lineRange.end.column = next;
14965 prev = curr;
14966 curr = next;
14967 next = row + 1 < end ? session.getScreenLastRowColumn(row + 1) : row == end ? 0 : range.end.column;
14968 clazzModified = clazz + (row == start ? " ace_start" : "") + " ace_br"
14969 + getBorderClass(row == start || row == start + 1 && range.start.column, prev < curr, curr > next, row == end);
14970
14971 if (this.session.$bidiHandler.isBidiRow(row)) {
14972 this.drawBidiSingleLineMarker(stringBuilder, lineRange, clazzModified,
14973 layerConfig, row == end ? 0 : 1, extraStyle);
14974 } else {
14975 this.drawSingleLineMarker(stringBuilder, lineRange, clazzModified,
14976 layerConfig, row == end ? 0 : 1, extraStyle);
14977 }
14978 }
14979 };
14980 this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
14981 var padding = this.$padding;
14982 var height, top, left;
14983 extraStyle = extraStyle || "";
14984 if (this.session.$bidiHandler.isBidiRow(range.start.row)) {
14985 var range1 = range.clone();
14986 range1.end.row = range1.start.row;
14987 range1.end.column = this.session.getLine(range1.start.row).length;
14988 this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br1 ace_start", config, null, extraStyle);
14989 } else {
14990 height = config.lineHeight;
14991 top = this.$getTop(range.start.row, config);
14992 left = padding + range.start.column * config.characterWidth;
14993 stringBuilder.push(
14994 "<div class='", clazz, " ace_br1 ace_start' style='",
14995 "height:", height, "px;",
14996 "right:0;",
14997 "top:", top, "px;",
14998 "left:", left, "px;", extraStyle, "'></div>"
14999 );
15000 }
15001 if (this.session.$bidiHandler.isBidiRow(range.end.row)) {
15002 var range1 = range.clone();
15003 range1.start.row = range1.end.row;
15004 range1.start.column = 0;
15005 this.drawBidiSingleLineMarker(stringBuilder, range1, clazz + " ace_br12", config, null, extraStyle);
15006 } else {
15007 var width = range.end.column * config.characterWidth;
15008 height = config.lineHeight;
15009 top = this.$getTop(range.end.row, config);
15010 stringBuilder.push(
15011 "<div class='", clazz, " ace_br12' style='",
15012 "height:", height, "px;",
15013 "width:", width, "px;",
15014 "top:", top, "px;",
15015 "left:", padding, "px;", extraStyle, "'></div>"
15016 );
15017 }
15018 height = (range.end.row - range.start.row - 1) * config.lineHeight;
15019 if (height <= 0)
15020 return;
15021 top = this.$getTop(range.start.row + 1, config);
15022
15023 var radiusClass = (range.start.column ? 1 : 0) | (range.end.column ? 0 : 8);
15024
15025 stringBuilder.push(
15026 "<div class='", clazz, (radiusClass ? " ace_br" + radiusClass : ""), "' style='",
15027 "height:", height, "px;",
15028 "right:0;",
15029 "top:", top, "px;",
15030 "left:", padding, "px;", extraStyle, "'></div>"
15031 );
15032 };
15033 this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
15034 var height = config.lineHeight;
15035 var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth;
15036
15037 var top = this.$getTop(range.start.row, config);
15038 var left = this.$padding + range.start.column * config.characterWidth;
15039
15040 stringBuilder.push(
15041 "<div class='", clazz, "' style='",
15042 "height:", height, "px;",
15043 "width:", width, "px;",
15044 "top:", top, "px;",
15045 "left:", left, "px;", extraStyle || "", "'></div>"
15046 );
15047 };
15048 this.drawBidiSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
15049 var height = config.lineHeight, top = this.$getTop(range.start.row, config), padding = this.$padding;
15050 var selections = this.session.$bidiHandler.getSelections(range.start.column, range.end.column);
15051
15052 selections.forEach(function(selection) {
15053 stringBuilder.push(
15054 "<div class='", clazz, "' style='",
15055 "height:", height, "px;",
15056 "width:", selection.width + (extraLength || 0), "px;",
15057 "top:", top, "px;",
15058 "left:", padding + selection.left, "px;", extraStyle || "", "'></div>"
15059 );
15060 });
15061 };
15062
15063 this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
15064 var top = this.$getTop(range.start.row, config);
15065 var height = config.lineHeight;
15066 if (range.start.row != range.end.row)
15067 height += this.$getTop(range.end.row, config) - top;
15068
15069 stringBuilder.push(
15070 "<div class='", clazz, "' style='",
15071 "height:", height, "px;",
15072 "top:", top, "px;",
15073 "left:0;right:0;", extraStyle || "", "'></div>"
15074 );
15075 };
15076
15077 this.drawScreenLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
15078 var top = this.$getTop(range.start.row, config);
15079 var height = config.lineHeight;
15080
15081 stringBuilder.push(
15082 "<div class='", clazz, "' style='",
15083 "height:", height, "px;",
15084 "top:", top, "px;",
15085 "left:0;right:0;", extraStyle || "", "'></div>"
15086 );
15087 };
15088
15089 }).call(Marker.prototype);
15090
15091 exports.Marker = Marker;
15092
15093 });
15094
15095 ace.define("ace/layer/text",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"], function(acequire, exports, module) {
15096
15097 var oop = acequire("../lib/oop");
15098 var dom = acequire("../lib/dom");
15099 var lang = acequire("../lib/lang");
15100 acequire("../lib/useragent");
15101 var EventEmitter = acequire("../lib/event_emitter").EventEmitter;
15102
15103 var Text = function(parentEl) {
15104 this.element = dom.createElement("div");
15105 this.element.className = "ace_layer ace_text-layer";
15106 parentEl.appendChild(this.element);
15107 this.$updateEolChar = this.$updateEolChar.bind(this);
15108 };
15109
15110 (function() {
15111
15112 oop.implement(this, EventEmitter);
15113
15114 this.EOF_CHAR = "\xB6";
15115 this.EOL_CHAR_LF = "\xAC";
15116 this.EOL_CHAR_CRLF = "\xa4";
15117 this.EOL_CHAR = this.EOL_CHAR_LF;
15118 this.TAB_CHAR = "\u2014"; //"\u21E5";
15119 this.SPACE_CHAR = "\xB7";
15120 this.$padding = 0;
15121
15122 this.$updateEolChar = function() {
15123 var EOL_CHAR = this.session.doc.getNewLineCharacter() == "\n"
15124 ? this.EOL_CHAR_LF
15125 : this.EOL_CHAR_CRLF;
15126 if (this.EOL_CHAR != EOL_CHAR) {
15127 this.EOL_CHAR = EOL_CHAR;
15128 return true;
15129 }
15130 };
15131
15132 this.setPadding = function(padding) {
15133 this.$padding = padding;
15134 this.element.style.padding = "0 " + padding + "px";
15135 };
15136
15137 this.getLineHeight = function() {
15138 return this.$fontMetrics.$characterSize.height || 0;
15139 };
15140
15141 this.getCharacterWidth = function() {
15142 return this.$fontMetrics.$characterSize.width || 0;
15143 };
15144
15145 this.$setFontMetrics = function(measure) {
15146 this.$fontMetrics = measure;
15147 this.$fontMetrics.on("changeCharacterSize", function(e) {
15148 this._signal("changeCharacterSize", e);
15149 }.bind(this));
15150 this.$pollSizeChanges();
15151 };
15152
15153 this.checkForSizeChanges = function() {
15154 this.$fontMetrics.checkForSizeChanges();
15155 };
15156 this.$pollSizeChanges = function() {
15157 return this.$pollSizeChangesTimer = this.$fontMetrics.$pollSizeChanges();
15158 };
15159 this.setSession = function(session) {
15160 this.session = session;
15161 if (session)
15162 this.$computeTabString();
15163 };
15164
15165 this.showInvisibles = false;
15166 this.setShowInvisibles = function(showInvisibles) {
15167 if (this.showInvisibles == showInvisibles)
15168 return false;
15169
15170 this.showInvisibles = showInvisibles;
15171 this.$computeTabString();
15172 return true;
15173 };
15174
15175 this.displayIndentGuides = true;
15176 this.setDisplayIndentGuides = function(display) {
15177 if (this.displayIndentGuides == display)
15178 return false;
15179
15180 this.displayIndentGuides = display;
15181 this.$computeTabString();
15182 return true;
15183 };
15184
15185 this.$tabStrings = [];
15186 this.onChangeTabSize =
15187 this.$computeTabString = function() {
15188 var tabSize = this.session.getTabSize();
15189 this.tabSize = tabSize;
15190 var tabStr = this.$tabStrings = [0];
15191 for (var i = 1; i < tabSize + 1; i++) {
15192 if (this.showInvisibles) {
15193 tabStr.push("<span class='ace_invisible ace_invisible_tab'>"
15194 + lang.stringRepeat(this.TAB_CHAR, i)
15195 + "</span>");
15196 } else {
15197 tabStr.push(lang.stringRepeat(" ", i));
15198 }
15199 }
15200 if (this.displayIndentGuides) {
15201 this.$indentGuideRe = /\s\S| \t|\t |\s$/;
15202 var className = "ace_indent-guide";
15203 var spaceClass = "";
15204 var tabClass = "";
15205 if (this.showInvisibles) {
15206 className += " ace_invisible";
15207 spaceClass = " ace_invisible_space";
15208 tabClass = " ace_invisible_tab";
15209 var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
15210 var tabContent = lang.stringRepeat(this.TAB_CHAR, this.tabSize);
15211 } else {
15212 var spaceContent = lang.stringRepeat(" ", this.tabSize);
15213 var tabContent = spaceContent;
15214 }
15215
15216 this.$tabStrings[" "] = "<span class='" + className + spaceClass + "'>" + spaceContent + "</span>";
15217 this.$tabStrings["\t"] = "<span class='" + className + tabClass + "'>" + tabContent + "</span>";
15218 }
15219 };
15220
15221 this.updateLines = function(config, firstRow, lastRow) {
15222 if (this.config.lastRow != config.lastRow ||
15223 this.config.firstRow != config.firstRow) {
15224 this.scrollLines(config);
15225 }
15226 this.config = config;
15227
15228 var first = Math.max(firstRow, config.firstRow);
15229 var last = Math.min(lastRow, config.lastRow);
15230
15231 var lineElements = this.element.childNodes;
15232 var lineElementsIdx = 0;
15233
15234 for (var row = config.firstRow; row < first; row++) {
15235 var foldLine = this.session.getFoldLine(row);
15236 if (foldLine) {
15237 if (foldLine.containsRow(first)) {
15238 first = foldLine.start.row;
15239 break;
15240 } else {
15241 row = foldLine.end.row;
15242 }
15243 }
15244 lineElementsIdx ++;
15245 }
15246
15247 var row = first;
15248 var foldLine = this.session.getNextFoldLine(row);
15249 var foldStart = foldLine ? foldLine.start.row : Infinity;
15250
15251 while (true) {
15252 if (row > foldStart) {
15253 row = foldLine.end.row+1;
15254 foldLine = this.session.getNextFoldLine(row, foldLine);
15255 foldStart = foldLine ? foldLine.start.row :Infinity;
15256 }
15257 if (row > last)
15258 break;
15259
15260 var lineElement = lineElements[lineElementsIdx++];
15261 if (lineElement) {
15262 var html = [];
15263 this.$renderLine(
15264 html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
15265 );
15266 lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
15267 lineElement.innerHTML = html.join("");
15268 }
15269 row++;
15270 }
15271 };
15272
15273 this.scrollLines = function(config) {
15274 var oldConfig = this.config;
15275 this.config = config;
15276
15277 if (!oldConfig || oldConfig.lastRow < config.firstRow)
15278 return this.update(config);
15279
15280 if (config.lastRow < oldConfig.firstRow)
15281 return this.update(config);
15282
15283 var el = this.element;
15284 if (oldConfig.firstRow < config.firstRow)
15285 for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--)
15286 el.removeChild(el.firstChild);
15287
15288 if (oldConfig.lastRow > config.lastRow)
15289 for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--)
15290 el.removeChild(el.lastChild);
15291
15292 if (config.firstRow < oldConfig.firstRow) {
15293 var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1);
15294 if (el.firstChild)
15295 el.insertBefore(fragment, el.firstChild);
15296 else
15297 el.appendChild(fragment);
15298 }
15299
15300 if (config.lastRow > oldConfig.lastRow) {
15301 var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow);
15302 el.appendChild(fragment);
15303 }
15304 };
15305
15306 this.$renderLinesFragment = function(config, firstRow, lastRow) {
15307 var fragment = this.element.ownerDocument.createDocumentFragment();
15308 var row = firstRow;
15309 var foldLine = this.session.getNextFoldLine(row);
15310 var foldStart = foldLine ? foldLine.start.row : Infinity;
15311
15312 while (true) {
15313 if (row > foldStart) {
15314 row = foldLine.end.row+1;
15315 foldLine = this.session.getNextFoldLine(row, foldLine);
15316 foldStart = foldLine ? foldLine.start.row : Infinity;
15317 }
15318 if (row > lastRow)
15319 break;
15320
15321 var container = dom.createElement("div");
15322
15323 var html = [];
15324 this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
15325 container.innerHTML = html.join("");
15326 if (this.$useLineGroups()) {
15327 container.className = 'ace_line_group';
15328 fragment.appendChild(container);
15329 container.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
15330
15331 } else {
15332 while(container.firstChild)
15333 fragment.appendChild(container.firstChild);
15334 }
15335
15336 row++;
15337 }
15338 return fragment;
15339 };
15340
15341 this.update = function(config) {
15342 this.config = config;
15343
15344 var html = [];
15345 var firstRow = config.firstRow, lastRow = config.lastRow;
15346
15347 var row = firstRow;
15348 var foldLine = this.session.getNextFoldLine(row);
15349 var foldStart = foldLine ? foldLine.start.row : Infinity;
15350
15351 while (true) {
15352 if (row > foldStart) {
15353 row = foldLine.end.row+1;
15354 foldLine = this.session.getNextFoldLine(row, foldLine);
15355 foldStart = foldLine ? foldLine.start.row :Infinity;
15356 }
15357 if (row > lastRow)
15358 break;
15359
15360 if (this.$useLineGroups())
15361 html.push("<div class='ace_line_group' style='height:", config.lineHeight*this.session.getRowLength(row), "px'>");
15362
15363 this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
15364
15365 if (this.$useLineGroups())
15366 html.push("</div>"); // end the line group
15367
15368 row++;
15369 }
15370 this.element.innerHTML = html.join("");
15371 };
15372
15373 this.$textToken = {
15374 "text": true,
15375 "rparen": true,
15376 "lparen": true
15377 };
15378
15379 this.$renderToken = function(stringBuilder, screenColumn, token, value) {
15380 var self = this;
15381 var replaceReg = /\t|&|<|>|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF\uFFF9-\uFFFC])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\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;
15382 var replaceFunc = function(c, a, b, tabIdx, idx4) {
15383 if (a) {
15384 return self.showInvisibles
15385 ? "<span class='ace_invisible ace_invisible_space'>" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "</span>"
15386 : c;
15387 } else if (c == "&") {
15388 return "&#38;";
15389 } else if (c == "<") {
15390 return "&#60;";
15391 } else if (c == ">") {
15392 return "&#62;";
15393 } else if (c == "\t") {
15394 var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
15395 screenColumn += tabSize - 1;
15396 return self.$tabStrings[tabSize];
15397 } else if (c == "\u3000") {
15398 var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
15399 var space = self.showInvisibles ? self.SPACE_CHAR : "";
15400 screenColumn += 1;
15401 return "<span class='" + classToUse + "' style='width:" +
15402 (self.config.characterWidth * 2) +
15403 "px'>" + space + "</span>";
15404 } else if (b) {
15405 return "<span class='ace_invisible ace_invisible_space ace_invalid'>" + self.SPACE_CHAR + "</span>";
15406 } else {
15407 screenColumn += 1;
15408 return "<span class='ace_cjk' style='width:" +
15409 (self.config.characterWidth * 2) +
15410 "px'>" + c + "</span>";
15411 }
15412 };
15413
15414 var output = value.replace(replaceReg, replaceFunc);
15415
15416 if (!this.$textToken[token.type]) {
15417 var classes = "ace_" + token.type.replace(/\./g, " ace_");
15418 var style = "";
15419 if (token.type == "fold")
15420 style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' ";
15421 stringBuilder.push("<span class='", classes, "'", style, ">", output, "</span>");
15422 }
15423 else {
15424 stringBuilder.push(output);
15425 }
15426 return screenColumn + value.length;
15427 };
15428
15429 this.renderIndentGuide = function(stringBuilder, value, max) {
15430 var cols = value.search(this.$indentGuideRe);
15431 if (cols <= 0 || cols >= max)
15432 return value;
15433 if (value[0] == " ") {
15434 cols -= cols % this.tabSize;
15435 stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize));
15436 return value.substr(cols);
15437 } else if (value[0] == "\t") {
15438 stringBuilder.push(lang.stringRepeat(this.$tabStrings["\t"], cols));
15439 return value.substr(cols);
15440 }
15441 return value;
15442 };
15443
15444 this.$renderWrappedLine = function(stringBuilder, tokens, splits, onlyContents) {
15445 var chars = 0;
15446 var split = 0;
15447 var splitChars = splits[0];
15448 var screenColumn = 0;
15449
15450 for (var i = 0; i < tokens.length; i++) {
15451 var token = tokens[i];
15452 var value = token.value;
15453 if (i == 0 && this.displayIndentGuides) {
15454 chars = value.length;
15455 value = this.renderIndentGuide(stringBuilder, value, splitChars);
15456 if (!value)
15457 continue;
15458 chars -= value.length;
15459 }
15460
15461 if (chars + value.length < splitChars) {
15462 screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
15463 chars += value.length;
15464 } else {
15465 while (chars + value.length >= splitChars) {
15466 screenColumn = this.$renderToken(
15467 stringBuilder, screenColumn,
15468 token, value.substring(0, splitChars - chars)
15469 );
15470 value = value.substring(splitChars - chars);
15471 chars = splitChars;
15472
15473 if (!onlyContents) {
15474 stringBuilder.push("</div>",
15475 "<div class='ace_line' style='height:",
15476 this.config.lineHeight, "px'>"
15477 );
15478 }
15479
15480 stringBuilder.push(lang.stringRepeat("\xa0", splits.indent));
15481
15482 split ++;
15483 screenColumn = 0;
15484 splitChars = splits[split] || Number.MAX_VALUE;
15485 }
15486 if (value.length != 0) {
15487 chars += value.length;
15488 screenColumn = this.$renderToken(
15489 stringBuilder, screenColumn, token, value
15490 );
15491 }
15492 }
15493 }
15494 };
15495
15496 this.$renderSimpleLine = function(stringBuilder, tokens) {
15497 var screenColumn = 0;
15498 var token = tokens[0];
15499 var value = token.value;
15500 if (this.displayIndentGuides)
15501 value = this.renderIndentGuide(stringBuilder, value);
15502 if (value)
15503 screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
15504 for (var i = 1; i < tokens.length; i++) {
15505 token = tokens[i];
15506 value = token.value;
15507 screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
15508 }
15509 };
15510 this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) {
15511 if (!foldLine && foldLine != false)
15512 foldLine = this.session.getFoldLine(row);
15513
15514 if (foldLine)
15515 var tokens = this.$getFoldLineTokens(row, foldLine);
15516 else
15517 var tokens = this.session.getTokens(row);
15518
15519
15520 if (!onlyContents) {
15521 stringBuilder.push(
15522 "<div class='ace_line' style='height:",
15523 this.config.lineHeight * (
15524 this.$useLineGroups() ? 1 :this.session.getRowLength(row)
15525 ), "px'>"
15526 );
15527 }
15528
15529 if (tokens.length) {
15530 var splits = this.session.getRowSplitData(row);
15531 if (splits && splits.length)
15532 this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents);
15533 else
15534 this.$renderSimpleLine(stringBuilder, tokens);
15535 }
15536
15537 if (this.showInvisibles) {
15538 if (foldLine)
15539 row = foldLine.end.row;
15540
15541 stringBuilder.push(
15542 "<span class='ace_invisible ace_invisible_eol'>",
15543 row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR,
15544 "</span>"
15545 );
15546 }
15547 if (!onlyContents)
15548 stringBuilder.push("</div>");
15549 };
15550
15551 this.$getFoldLineTokens = function(row, foldLine) {
15552 var session = this.session;
15553 var renderTokens = [];
15554
15555 function addTokens(tokens, from, to) {
15556 var idx = 0, col = 0;
15557 while ((col + tokens[idx].value.length) < from) {
15558 col += tokens[idx].value.length;
15559 idx++;
15560
15561 if (idx == tokens.length)
15562 return;
15563 }
15564 if (col != from) {
15565 var value = tokens[idx].value.substring(from - col);
15566 if (value.length > (to - from))
15567 value = value.substring(0, to - from);
15568
15569 renderTokens.push({
15570 type: tokens[idx].type,
15571 value: value
15572 });
15573
15574 col = from + value.length;
15575 idx += 1;
15576 }
15577
15578 while (col < to && idx < tokens.length) {
15579 var value = tokens[idx].value;
15580 if (value.length + col > to) {
15581 renderTokens.push({
15582 type: tokens[idx].type,
15583 value: value.substring(0, to - col)
15584 });
15585 } else
15586 renderTokens.push(tokens[idx]);
15587 col += value.length;
15588 idx += 1;
15589 }
15590 }
15591
15592 var tokens = session.getTokens(row);
15593 foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
15594 if (placeholder != null) {
15595 renderTokens.push({
15596 type: "fold",
15597 value: placeholder
15598 });
15599 } else {
15600 if (isNewRow)
15601 tokens = session.getTokens(row);
15602
15603 if (tokens.length)
15604 addTokens(tokens, lastColumn, column);
15605 }
15606 }, foldLine.end.row, this.session.getLine(foldLine.end.row).length);
15607
15608 return renderTokens;
15609 };
15610
15611 this.$useLineGroups = function() {
15612 return this.session.getUseWrapMode();
15613 };
15614
15615 this.destroy = function() {
15616 clearInterval(this.$pollSizeChangesTimer);
15617 if (this.$measureNode)
15618 this.$measureNode.parentNode.removeChild(this.$measureNode);
15619 delete this.$measureNode;
15620 };
15621
15622 }).call(Text.prototype);
15623
15624 exports.Text = Text;
15625
15626 });
15627
15628 ace.define("ace/layer/cursor",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) {
15629
15630 var dom = acequire("../lib/dom");
15631 var isIE8;
15632
15633 var Cursor = function(parentEl) {
15634 this.element = dom.createElement("div");
15635 this.element.className = "ace_layer ace_cursor-layer";
15636 parentEl.appendChild(this.element);
15637
15638 if (isIE8 === undefined)
15639 isIE8 = !("opacity" in this.element.style);
15640
15641 this.isVisible = false;
15642 this.isBlinking = true;
15643 this.blinkInterval = 1000;
15644 this.smoothBlinking = false;
15645
15646 this.cursors = [];
15647 this.cursor = this.addCursor();
15648 dom.addCssClass(this.element, "ace_hidden-cursors");
15649 this.$updateCursors = (isIE8
15650 ? this.$updateVisibility
15651 : this.$updateOpacity).bind(this);
15652 };
15653
15654 (function() {
15655
15656 this.$updateVisibility = function(val) {
15657 var cursors = this.cursors;
15658 for (var i = cursors.length; i--; )
15659 cursors[i].style.visibility = val ? "" : "hidden";
15660 };
15661 this.$updateOpacity = function(val) {
15662 var cursors = this.cursors;
15663 for (var i = cursors.length; i--; )
15664 cursors[i].style.opacity = val ? "" : "0";
15665 };
15666
15667
15668 this.$padding = 0;
15669 this.setPadding = function(padding) {
15670 this.$padding = padding;
15671 };
15672
15673 this.setSession = function(session) {
15674 this.session = session;
15675 };
15676
15677 this.setBlinking = function(blinking) {
15678 if (blinking != this.isBlinking){
15679 this.isBlinking = blinking;
15680 this.restartTimer();
15681 }
15682 };
15683
15684 this.setBlinkInterval = function(blinkInterval) {
15685 if (blinkInterval != this.blinkInterval){
15686 this.blinkInterval = blinkInterval;
15687 this.restartTimer();
15688 }
15689 };
15690
15691 this.setSmoothBlinking = function(smoothBlinking) {
15692 if (smoothBlinking != this.smoothBlinking && !isIE8) {
15693 this.smoothBlinking = smoothBlinking;
15694 dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking);
15695 this.$updateCursors(true);
15696 this.$updateCursors = (this.$updateOpacity).bind(this);
15697 this.restartTimer();
15698 }
15699 };
15700
15701 this.addCursor = function() {
15702 var el = dom.createElement("div");
15703 el.className = "ace_cursor";
15704 this.element.appendChild(el);
15705 this.cursors.push(el);
15706 return el;
15707 };
15708
15709 this.removeCursor = function() {
15710 if (this.cursors.length > 1) {
15711 var el = this.cursors.pop();
15712 el.parentNode.removeChild(el);
15713 return el;
15714 }
15715 };
15716
15717 this.hideCursor = function() {
15718 this.isVisible = false;
15719 dom.addCssClass(this.element, "ace_hidden-cursors");
15720 this.restartTimer();
15721 };
15722
15723 this.showCursor = function() {
15724 this.isVisible = true;
15725 dom.removeCssClass(this.element, "ace_hidden-cursors");
15726 this.restartTimer();
15727 };
15728
15729 this.restartTimer = function() {
15730 var update = this.$updateCursors;
15731 clearInterval(this.intervalId);
15732 clearTimeout(this.timeoutId);
15733 if (this.smoothBlinking) {
15734 dom.removeCssClass(this.element, "ace_smooth-blinking");
15735 }
15736
15737 update(true);
15738
15739 if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
15740 return;
15741
15742 if (this.smoothBlinking) {
15743 setTimeout(function(){
15744 dom.addCssClass(this.element, "ace_smooth-blinking");
15745 }.bind(this));
15746 }
15747
15748 var blink = function(){
15749 this.timeoutId = setTimeout(function() {
15750 update(false);
15751 }, 0.6 * this.blinkInterval);
15752 }.bind(this);
15753
15754 this.intervalId = setInterval(function() {
15755 update(true);
15756 blink();
15757 }, this.blinkInterval);
15758
15759 blink();
15760 };
15761
15762 this.getPixelPosition = function(position, onScreen) {
15763 if (!this.config || !this.session)
15764 return {left : 0, top : 0};
15765
15766 if (!position)
15767 position = this.session.selection.getCursor();
15768 var pos = this.session.documentToScreenPosition(position);
15769 var cursorLeft = this.$padding + (this.session.$bidiHandler.isBidiRow(pos.row, position.row)
15770 ? this.session.$bidiHandler.getPosLeft(pos.column)
15771 : pos.column * this.config.characterWidth);
15772
15773 var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
15774 this.config.lineHeight;
15775
15776 return {left : cursorLeft, top : cursorTop};
15777 };
15778
15779 this.update = function(config) {
15780 this.config = config;
15781
15782 var selections = this.session.$selectionMarkers;
15783 var i = 0, cursorIndex = 0;
15784
15785 if (selections === undefined || selections.length === 0){
15786 selections = [{cursor: null}];
15787 }
15788
15789 for (var i = 0, n = selections.length; i < n; i++) {
15790 var pixelPos = this.getPixelPosition(selections[i].cursor, true);
15791 if ((pixelPos.top > config.height + config.offset ||
15792 pixelPos.top < 0) && i > 1) {
15793 continue;
15794 }
15795
15796 var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
15797
15798 if (!this.drawCursor) {
15799 style.left = pixelPos.left + "px";
15800 style.top = pixelPos.top + "px";
15801 style.width = config.characterWidth + "px";
15802 style.height = config.lineHeight + "px";
15803 } else {
15804 this.drawCursor(style, pixelPos, config, selections[i], this.session);
15805 }
15806 }
15807 while (this.cursors.length > cursorIndex)
15808 this.removeCursor();
15809
15810 var overwrite = this.session.getOverwrite();
15811 this.$setOverwrite(overwrite);
15812 this.$pixelPos = pixelPos;
15813 this.restartTimer();
15814 };
15815
15816 this.drawCursor = null;
15817
15818 this.$setOverwrite = function(overwrite) {
15819 if (overwrite != this.overwrite) {
15820 this.overwrite = overwrite;
15821 if (overwrite)
15822 dom.addCssClass(this.element, "ace_overwrite-cursors");
15823 else
15824 dom.removeCssClass(this.element, "ace_overwrite-cursors");
15825 }
15826 };
15827
15828 this.destroy = function() {
15829 clearInterval(this.intervalId);
15830 clearTimeout(this.timeoutId);
15831 };
15832
15833 }).call(Cursor.prototype);
15834
15835 exports.Cursor = Cursor;
15836
15837 });
15838
15839 ace.define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"], function(acequire, exports, module) {
15840
15841 var oop = acequire("./lib/oop");
15842 var dom = acequire("./lib/dom");
15843 var event = acequire("./lib/event");
15844 var EventEmitter = acequire("./lib/event_emitter").EventEmitter;
15845 var MAX_SCROLL_H = 0x8000;
15846 var ScrollBar = function(parent) {
15847 this.element = dom.createElement("div");
15848 this.element.className = "ace_scrollbar ace_scrollbar" + this.classSuffix;
15849
15850 this.inner = dom.createElement("div");
15851 this.inner.className = "ace_scrollbar-inner";
15852 this.element.appendChild(this.inner);
15853
15854 parent.appendChild(this.element);
15855
15856 this.setVisible(false);
15857 this.skipEvent = false;
15858
15859 event.addListener(this.element, "scroll", this.onScroll.bind(this));
15860 event.addListener(this.element, "mousedown", event.preventDefault);
15861 };
15862
15863 (function() {
15864 oop.implement(this, EventEmitter);
15865
15866 this.setVisible = function(isVisible) {
15867 this.element.style.display = isVisible ? "" : "none";
15868 this.isVisible = isVisible;
15869 this.coeff = 1;
15870 };
15871 }).call(ScrollBar.prototype);
15872 var VScrollBar = function(parent, renderer) {
15873 ScrollBar.call(this, parent);
15874 this.scrollTop = 0;
15875 this.scrollHeight = 0;
15876 renderer.$scrollbarWidth =
15877 this.width = dom.scrollbarWidth(parent.ownerDocument);
15878 this.inner.style.width =
15879 this.element.style.width = (this.width || 15) + 5 + "px";
15880 this.$minWidth = 0;
15881 };
15882
15883 oop.inherits(VScrollBar, ScrollBar);
15884
15885 (function() {
15886
15887 this.classSuffix = '-v';
15888 this.onScroll = function() {
15889 if (!this.skipEvent) {
15890 this.scrollTop = this.element.scrollTop;
15891 if (this.coeff != 1) {
15892 var h = this.element.clientHeight / this.scrollHeight;
15893 this.scrollTop = this.scrollTop * (1 - h) / (this.coeff - h);
15894 }
15895 this._emit("scroll", {data: this.scrollTop});
15896 }
15897 this.skipEvent = false;
15898 };
15899 this.getWidth = function() {
15900 return Math.max(this.isVisible ? this.width : 0, this.$minWidth || 0);
15901 };
15902 this.setHeight = function(height) {
15903 this.element.style.height = height + "px";
15904 };
15905 this.setInnerHeight =
15906 this.setScrollHeight = function(height) {
15907 this.scrollHeight = height;
15908 if (height > MAX_SCROLL_H) {
15909 this.coeff = MAX_SCROLL_H / height;
15910 height = MAX_SCROLL_H;
15911 } else if (this.coeff != 1) {
15912 this.coeff = 1;
15913 }
15914 this.inner.style.height = height + "px";
15915 };
15916 this.setScrollTop = function(scrollTop) {
15917 if (this.scrollTop != scrollTop) {
15918 this.skipEvent = true;
15919 this.scrollTop = scrollTop;
15920 this.element.scrollTop = scrollTop * this.coeff;
15921 }
15922 };
15923
15924 }).call(VScrollBar.prototype);
15925 var HScrollBar = function(parent, renderer) {
15926 ScrollBar.call(this, parent);
15927 this.scrollLeft = 0;
15928 this.height = renderer.$scrollbarWidth;
15929 this.inner.style.height =
15930 this.element.style.height = (this.height || 15) + 5 + "px";
15931 };
15932
15933 oop.inherits(HScrollBar, ScrollBar);
15934
15935 (function() {
15936
15937 this.classSuffix = '-h';
15938 this.onScroll = function() {
15939 if (!this.skipEvent) {
15940 this.scrollLeft = this.element.scrollLeft;
15941 this._emit("scroll", {data: this.scrollLeft});
15942 }
15943 this.skipEvent = false;
15944 };
15945 this.getHeight = function() {
15946 return this.isVisible ? this.height : 0;
15947 };
15948 this.setWidth = function(width) {
15949 this.element.style.width = width + "px";
15950 };
15951 this.setInnerWidth = function(width) {
15952 this.inner.style.width = width + "px";
15953 };
15954 this.setScrollWidth = function(width) {
15955 this.inner.style.width = width + "px";
15956 };
15957 this.setScrollLeft = function(scrollLeft) {
15958 if (this.scrollLeft != scrollLeft) {
15959 this.skipEvent = true;
15960 this.scrollLeft = this.element.scrollLeft = scrollLeft;
15961 }
15962 };
15963
15964 }).call(HScrollBar.prototype);
15965
15966
15967 exports.ScrollBar = VScrollBar; // backward compatibility
15968 exports.ScrollBarV = VScrollBar; // backward compatibility
15969 exports.ScrollBarH = HScrollBar; // backward compatibility
15970
15971 exports.VScrollBar = VScrollBar;
15972 exports.HScrollBar = HScrollBar;
15973 });
15974
15975 ace.define("ace/renderloop",["require","exports","module","ace/lib/event"], function(acequire, exports, module) {
15976
15977 var event = acequire("./lib/event");
15978
15979
15980 var RenderLoop = function(onRender, win) {
15981 this.onRender = onRender;
15982 this.pending = false;
15983 this.changes = 0;
15984 this.window = win || window;
15985 };
15986
15987 (function() {
15988
15989
15990 this.schedule = function(change) {
15991 this.changes = this.changes | change;
15992 if (!this.pending && this.changes) {
15993 this.pending = true;
15994 var _self = this;
15995 event.nextFrame(function() {
15996 _self.pending = false;
15997 var changes;
15998 while (changes = _self.changes) {
15999 _self.changes = 0;
16000 _self.onRender(changes);
16001 }
16002 }, this.window);
16003 }
16004 };
16005
16006 }).call(RenderLoop.prototype);
16007
16008 exports.RenderLoop = RenderLoop;
16009 });
16010
16011 ace.define("ace/layer/font_metrics",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"], function(acequire, exports, module) {
16012
16013 var oop = acequire("../lib/oop");
16014 var dom = acequire("../lib/dom");
16015 var lang = acequire("../lib/lang");
16016 var useragent = acequire("../lib/useragent");
16017 var EventEmitter = acequire("../lib/event_emitter").EventEmitter;
16018
16019 var CHAR_COUNT = 0;
16020
16021 var FontMetrics = exports.FontMetrics = function(parentEl) {
16022 this.el = dom.createElement("div");
16023 this.$setMeasureNodeStyles(this.el.style, true);
16024
16025 this.$main = dom.createElement("div");
16026 this.$setMeasureNodeStyles(this.$main.style);
16027
16028 this.$measureNode = dom.createElement("div");
16029 this.$setMeasureNodeStyles(this.$measureNode.style);
16030
16031
16032 this.el.appendChild(this.$main);
16033 this.el.appendChild(this.$measureNode);
16034 parentEl.appendChild(this.el);
16035
16036 if (!CHAR_COUNT)
16037 this.$testFractionalRect();
16038 this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT);
16039
16040 this.$characterSize = {width: 0, height: 0};
16041 this.checkForSizeChanges();
16042 };
16043
16044 (function() {
16045
16046 oop.implement(this, EventEmitter);
16047
16048 this.$characterSize = {width: 0, height: 0};
16049
16050 this.$testFractionalRect = function() {
16051 var el = dom.createElement("div");
16052 this.$setMeasureNodeStyles(el.style);
16053 el.style.width = "0.2px";
16054 document.documentElement.appendChild(el);
16055 var w = el.getBoundingClientRect().width;
16056 if (w > 0 && w < 1)
16057 CHAR_COUNT = 50;
16058 else
16059 CHAR_COUNT = 100;
16060 el.parentNode.removeChild(el);
16061 };
16062
16063 this.$setMeasureNodeStyles = function(style, isRoot) {
16064 style.width = style.height = "auto";
16065 style.left = style.top = "0px";
16066 style.visibility = "hidden";
16067 style.position = "absolute";
16068 style.whiteSpace = "pre";
16069
16070 if (useragent.isIE < 8) {
16071 style["font-family"] = "inherit";
16072 } else {
16073 style.font = "inherit";
16074 }
16075 style.overflow = isRoot ? "hidden" : "visible";
16076 };
16077
16078 this.checkForSizeChanges = function() {
16079 var size = this.$measureSizes();
16080 if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
16081 this.$measureNode.style.fontWeight = "bold";
16082 var boldSize = this.$measureSizes();
16083 this.$measureNode.style.fontWeight = "";
16084 this.$characterSize = size;
16085 this.charSizes = Object.create(null);
16086 this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height;
16087 this._emit("changeCharacterSize", {data: size});
16088 }
16089 };
16090
16091 this.$pollSizeChanges = function() {
16092 if (this.$pollSizeChangesTimer)
16093 return this.$pollSizeChangesTimer;
16094 var self = this;
16095 return this.$pollSizeChangesTimer = setInterval(function() {
16096 self.checkForSizeChanges();
16097 }, 500);
16098 };
16099
16100 this.setPolling = function(val) {
16101 if (val) {
16102 this.$pollSizeChanges();
16103 } else if (this.$pollSizeChangesTimer) {
16104 clearInterval(this.$pollSizeChangesTimer);
16105 this.$pollSizeChangesTimer = 0;
16106 }
16107 };
16108
16109 this.$measureSizes = function() {
16110 if (CHAR_COUNT === 50) {
16111 var rect = null;
16112 try {
16113 rect = this.$measureNode.getBoundingClientRect();
16114 } catch(e) {
16115 rect = {width: 0, height:0 };
16116 }
16117 var size = {
16118 height: rect.height,
16119 width: rect.width / CHAR_COUNT
16120 };
16121 } else {
16122 var size = {
16123 height: this.$measureNode.clientHeight,
16124 width: this.$measureNode.clientWidth / CHAR_COUNT
16125 };
16126 }
16127 if (size.width === 0 || size.height === 0)
16128 return null;
16129 return size;
16130 };
16131
16132 this.$measureCharWidth = function(ch) {
16133 this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT);
16134 var rect = this.$main.getBoundingClientRect();
16135 return rect.width / CHAR_COUNT;
16136 };
16137
16138 this.getCharacterWidth = function(ch) {
16139 var w = this.charSizes[ch];
16140 if (w === undefined) {
16141 w = this.charSizes[ch] = this.$measureCharWidth(ch) / this.$characterSize.width;
16142 }
16143 return w;
16144 };
16145
16146 this.destroy = function() {
16147 clearInterval(this.$pollSizeChangesTimer);
16148 if (this.el && this.el.parentNode)
16149 this.el.parentNode.removeChild(this.el);
16150 };
16151
16152 }).call(FontMetrics.prototype);
16153
16154 });
16155
16156 ace.define("ace/virtual_renderer",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/config","ace/lib/useragent","ace/layer/gutter","ace/layer/marker","ace/layer/text","ace/layer/cursor","ace/scrollbar","ace/scrollbar","ace/renderloop","ace/layer/font_metrics","ace/lib/event_emitter"], function(acequire, exports, module) {
16157
16158 var oop = acequire("./lib/oop");
16159 var dom = acequire("./lib/dom");
16160 var config = acequire("./config");
16161 var useragent = acequire("./lib/useragent");
16162 var GutterLayer = acequire("./layer/gutter").Gutter;
16163 var MarkerLayer = acequire("./layer/marker").Marker;
16164 var TextLayer = acequire("./layer/text").Text;
16165 var CursorLayer = acequire("./layer/cursor").Cursor;
16166 var HScrollBar = acequire("./scrollbar").HScrollBar;
16167 var VScrollBar = acequire("./scrollbar").VScrollBar;
16168 var RenderLoop = acequire("./renderloop").RenderLoop;
16169 var FontMetrics = acequire("./layer/font_metrics").FontMetrics;
16170 var EventEmitter = acequire("./lib/event_emitter").EventEmitter;
16171 var editorCss = ".ace_editor {\
16172position: relative;\
16173overflow: hidden;\
16174font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\
16175direction: ltr;\
16176text-align: left;\
16177-webkit-tap-highlight-color: rgba(0, 0, 0, 0);\
16178}\
16179.ace_scroller {\
16180position: absolute;\
16181overflow: hidden;\
16182top: 0;\
16183bottom: 0;\
16184background-color: inherit;\
16185-ms-user-select: none;\
16186-moz-user-select: none;\
16187-webkit-user-select: none;\
16188user-select: none;\
16189cursor: text;\
16190}\
16191.ace_content {\
16192position: absolute;\
16193-moz-box-sizing: border-box;\
16194-webkit-box-sizing: border-box;\
16195box-sizing: border-box;\
16196min-width: 100%;\
16197}\
16198.ace_dragging .ace_scroller:before{\
16199position: absolute;\
16200top: 0;\
16201left: 0;\
16202right: 0;\
16203bottom: 0;\
16204content: '';\
16205background: rgba(250, 250, 250, 0.01);\
16206z-index: 1000;\
16207}\
16208.ace_dragging.ace_dark .ace_scroller:before{\
16209background: rgba(0, 0, 0, 0.01);\
16210}\
16211.ace_selecting, .ace_selecting * {\
16212cursor: text !important;\
16213}\
16214.ace_gutter {\
16215position: absolute;\
16216overflow : hidden;\
16217width: auto;\
16218top: 0;\
16219bottom: 0;\
16220left: 0;\
16221cursor: default;\
16222z-index: 4;\
16223-ms-user-select: none;\
16224-moz-user-select: none;\
16225-webkit-user-select: none;\
16226user-select: none;\
16227}\
16228.ace_gutter-active-line {\
16229position: absolute;\
16230left: 0;\
16231right: 0;\
16232}\
16233.ace_scroller.ace_scroll-left {\
16234box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\
16235}\
16236.ace_gutter-cell {\
16237padding-left: 19px;\
16238padding-right: 6px;\
16239background-repeat: no-repeat;\
16240}\
16241.ace_gutter-cell.ace_error {\
16242background-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==\");\
16243background-repeat: no-repeat;\
16244background-position: 2px center;\
16245}\
16246.ace_gutter-cell.ace_warning {\
16247background-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==\");\
16248background-position: 2px center;\
16249}\
16250.ace_gutter-cell.ace_info {\
16251background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\
16252background-position: 2px center;\
16253}\
16254.ace_dark .ace_gutter-cell.ace_info {\
16255background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\
16256}\
16257.ace_scrollbar {\
16258position: absolute;\
16259right: 0;\
16260bottom: 0;\
16261z-index: 6;\
16262}\
16263.ace_scrollbar-inner {\
16264position: absolute;\
16265cursor: text;\
16266left: 0;\
16267top: 0;\
16268}\
16269.ace_scrollbar-v{\
16270overflow-x: hidden;\
16271overflow-y: scroll;\
16272top: 0;\
16273}\
16274.ace_scrollbar-h {\
16275overflow-x: scroll;\
16276overflow-y: hidden;\
16277left: 0;\
16278}\
16279.ace_print-margin {\
16280position: absolute;\
16281height: 100%;\
16282}\
16283.ace_text-input {\
16284position: absolute;\
16285z-index: 0;\
16286width: 0.5em;\
16287height: 1em;\
16288opacity: 0;\
16289background: transparent;\
16290-moz-appearance: none;\
16291appearance: none;\
16292border: none;\
16293resize: none;\
16294outline: none;\
16295overflow: hidden;\
16296font: inherit;\
16297padding: 0 1px;\
16298margin: 0 -1px;\
16299text-indent: -1em;\
16300-ms-user-select: text;\
16301-moz-user-select: text;\
16302-webkit-user-select: text;\
16303user-select: text;\
16304white-space: pre!important;\
16305}\
16306.ace_text-input.ace_composition {\
16307background: inherit;\
16308color: inherit;\
16309z-index: 1000;\
16310opacity: 1;\
16311text-indent: 0;\
16312}\
16313.ace_layer {\
16314z-index: 1;\
16315position: absolute;\
16316overflow: hidden;\
16317word-wrap: normal;\
16318white-space: pre;\
16319height: 100%;\
16320width: 100%;\
16321-moz-box-sizing: border-box;\
16322-webkit-box-sizing: border-box;\
16323box-sizing: border-box;\
16324pointer-events: none;\
16325}\
16326.ace_gutter-layer {\
16327position: relative;\
16328width: auto;\
16329text-align: right;\
16330pointer-events: auto;\
16331}\
16332.ace_text-layer {\
16333font: inherit !important;\
16334}\
16335.ace_cjk {\
16336display: inline-block;\
16337text-align: center;\
16338}\
16339.ace_cursor-layer {\
16340z-index: 4;\
16341}\
16342.ace_cursor {\
16343z-index: 4;\
16344position: absolute;\
16345-moz-box-sizing: border-box;\
16346-webkit-box-sizing: border-box;\
16347box-sizing: border-box;\
16348border-left: 2px solid;\
16349transform: translatez(0);\
16350}\
16351.ace_multiselect .ace_cursor {\
16352border-left-width: 1px;\
16353}\
16354.ace_slim-cursors .ace_cursor {\
16355border-left-width: 1px;\
16356}\
16357.ace_overwrite-cursors .ace_cursor {\
16358border-left-width: 0;\
16359border-bottom: 1px solid;\
16360}\
16361.ace_hidden-cursors .ace_cursor {\
16362opacity: 0.2;\
16363}\
16364.ace_smooth-blinking .ace_cursor {\
16365-webkit-transition: opacity 0.18s;\
16366transition: opacity 0.18s;\
16367}\
16368.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\
16369position: absolute;\
16370z-index: 3;\
16371}\
16372.ace_marker-layer .ace_selection {\
16373position: absolute;\
16374z-index: 5;\
16375}\
16376.ace_marker-layer .ace_bracket {\
16377position: absolute;\
16378z-index: 6;\
16379}\
16380.ace_marker-layer .ace_active-line {\
16381position: absolute;\
16382z-index: 2;\
16383}\
16384.ace_marker-layer .ace_selected-word {\
16385position: absolute;\
16386z-index: 4;\
16387-moz-box-sizing: border-box;\
16388-webkit-box-sizing: border-box;\
16389box-sizing: border-box;\
16390}\
16391.ace_line .ace_fold {\
16392-moz-box-sizing: border-box;\
16393-webkit-box-sizing: border-box;\
16394box-sizing: border-box;\
16395display: inline-block;\
16396height: 11px;\
16397margin-top: -2px;\
16398vertical-align: middle;\
16399background-image:\
16400url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
16401url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\
16402background-repeat: no-repeat, repeat-x;\
16403background-position: center center, top left;\
16404color: transparent;\
16405border: 1px solid black;\
16406border-radius: 2px;\
16407cursor: pointer;\
16408pointer-events: auto;\
16409}\
16410.ace_dark .ace_fold {\
16411}\
16412.ace_fold:hover{\
16413background-image:\
16414url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
16415url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\
16416}\
16417.ace_tooltip {\
16418background-color: #FFF;\
16419background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));\
16420background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\
16421border: 1px solid gray;\
16422border-radius: 1px;\
16423box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\
16424color: black;\
16425max-width: 100%;\
16426padding: 3px 4px;\
16427position: fixed;\
16428z-index: 999999;\
16429-moz-box-sizing: border-box;\
16430-webkit-box-sizing: border-box;\
16431box-sizing: border-box;\
16432cursor: default;\
16433white-space: pre;\
16434word-wrap: break-word;\
16435line-height: normal;\
16436font-style: normal;\
16437font-weight: normal;\
16438letter-spacing: normal;\
16439pointer-events: none;\
16440}\
16441.ace_folding-enabled > .ace_gutter-cell {\
16442padding-right: 13px;\
16443}\
16444.ace_fold-widget {\
16445-moz-box-sizing: border-box;\
16446-webkit-box-sizing: border-box;\
16447box-sizing: border-box;\
16448margin: 0 -12px 0 1px;\
16449display: none;\
16450width: 11px;\
16451vertical-align: top;\
16452background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\
16453background-repeat: no-repeat;\
16454background-position: center;\
16455border-radius: 3px;\
16456border: 1px solid transparent;\
16457cursor: pointer;\
16458}\
16459.ace_folding-enabled .ace_fold-widget {\
16460display: inline-block; \
16461}\
16462.ace_fold-widget.ace_end {\
16463background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\
16464}\
16465.ace_fold-widget.ace_closed {\
16466background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\
16467}\
16468.ace_fold-widget:hover {\
16469border: 1px solid rgba(0, 0, 0, 0.3);\
16470background-color: rgba(255, 255, 255, 0.2);\
16471box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\
16472}\
16473.ace_fold-widget:active {\
16474border: 1px solid rgba(0, 0, 0, 0.4);\
16475background-color: rgba(0, 0, 0, 0.05);\
16476box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\
16477}\
16478.ace_dark .ace_fold-widget {\
16479background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\
16480}\
16481.ace_dark .ace_fold-widget.ace_end {\
16482background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\
16483}\
16484.ace_dark .ace_fold-widget.ace_closed {\
16485background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\
16486}\
16487.ace_dark .ace_fold-widget:hover {\
16488box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
16489background-color: rgba(255, 255, 255, 0.1);\
16490}\
16491.ace_dark .ace_fold-widget:active {\
16492box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
16493}\
16494.ace_fold-widget.ace_invalid {\
16495background-color: #FFB4B4;\
16496border-color: #DE5555;\
16497}\
16498.ace_fade-fold-widgets .ace_fold-widget {\
16499-webkit-transition: opacity 0.4s ease 0.05s;\
16500transition: opacity 0.4s ease 0.05s;\
16501opacity: 0;\
16502}\
16503.ace_fade-fold-widgets:hover .ace_fold-widget {\
16504-webkit-transition: opacity 0.05s ease 0.05s;\
16505transition: opacity 0.05s ease 0.05s;\
16506opacity:1;\
16507}\
16508.ace_underline {\
16509text-decoration: underline;\
16510}\
16511.ace_bold {\
16512font-weight: bold;\
16513}\
16514.ace_nobold .ace_bold {\
16515font-weight: normal;\
16516}\
16517.ace_italic {\
16518font-style: italic;\
16519}\
16520.ace_error-marker {\
16521background-color: rgba(255, 0, 0,0.2);\
16522position: absolute;\
16523z-index: 9;\
16524}\
16525.ace_highlight-marker {\
16526background-color: rgba(255, 255, 0,0.2);\
16527position: absolute;\
16528z-index: 8;\
16529}\
16530.ace_br1 {border-top-left-radius : 3px;}\
16531.ace_br2 {border-top-right-radius : 3px;}\
16532.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}\
16533.ace_br4 {border-bottom-right-radius: 3px;}\
16534.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}\
16535.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}\
16536.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}\
16537.ace_br8 {border-bottom-left-radius : 3px;}\
16538.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}\
16539.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}\
16540.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}\
16541.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
16542.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
16543.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
16544.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}\
16545.ace_text-input-ios {\
16546position: absolute !important;\
16547top: -100000px !important;\
16548left: -100000px !important;\
16549}\
16550";
16551
16552 dom.importCssString(editorCss, "ace_editor.css");
16553
16554 var VirtualRenderer = function(container, theme) {
16555 var _self = this;
16556
16557 this.container = container || dom.createElement("div");
16558 this.$keepTextAreaAtCursor = !useragent.isOldIE;
16559
16560 dom.addCssClass(this.container, "ace_editor");
16561
16562 this.setTheme(theme);
16563
16564 this.$gutter = dom.createElement("div");
16565 this.$gutter.className = "ace_gutter";
16566 this.container.appendChild(this.$gutter);
16567 this.$gutter.setAttribute("aria-hidden", true);
16568
16569 this.scroller = dom.createElement("div");
16570 this.scroller.className = "ace_scroller";
16571 this.container.appendChild(this.scroller);
16572
16573 this.content = dom.createElement("div");
16574 this.content.className = "ace_content";
16575 this.scroller.appendChild(this.content);
16576
16577 this.$gutterLayer = new GutterLayer(this.$gutter);
16578 this.$gutterLayer.on("changeGutterWidth", this.onGutterResize.bind(this));
16579
16580 this.$markerBack = new MarkerLayer(this.content);
16581
16582 var textLayer = this.$textLayer = new TextLayer(this.content);
16583 this.canvas = textLayer.element;
16584
16585 this.$markerFront = new MarkerLayer(this.content);
16586
16587 this.$cursorLayer = new CursorLayer(this.content);
16588 this.$horizScroll = false;
16589 this.$vScroll = false;
16590
16591 this.scrollBar =
16592 this.scrollBarV = new VScrollBar(this.container, this);
16593 this.scrollBarH = new HScrollBar(this.container, this);
16594 this.scrollBarV.addEventListener("scroll", function(e) {
16595 if (!_self.$scrollAnimation)
16596 _self.session.setScrollTop(e.data - _self.scrollMargin.top);
16597 });
16598 this.scrollBarH.addEventListener("scroll", function(e) {
16599 if (!_self.$scrollAnimation)
16600 _self.session.setScrollLeft(e.data - _self.scrollMargin.left);
16601 });
16602
16603 this.scrollTop = 0;
16604 this.scrollLeft = 0;
16605
16606 this.cursorPos = {
16607 row : 0,
16608 column : 0
16609 };
16610
16611 this.$fontMetrics = new FontMetrics(this.container);
16612 this.$textLayer.$setFontMetrics(this.$fontMetrics);
16613 this.$textLayer.addEventListener("changeCharacterSize", function(e) {
16614 _self.updateCharacterSize();
16615 _self.onResize(true, _self.gutterWidth, _self.$size.width, _self.$size.height);
16616 _self._signal("changeCharacterSize", e);
16617 });
16618
16619 this.$size = {
16620 width: 0,
16621 height: 0,
16622 scrollerHeight: 0,
16623 scrollerWidth: 0,
16624 $dirty: true
16625 };
16626
16627 this.layerConfig = {
16628 width : 1,
16629 padding : 0,
16630 firstRow : 0,
16631 firstRowScreen: 0,
16632 lastRow : 0,
16633 lineHeight : 0,
16634 characterWidth : 0,
16635 minHeight : 1,
16636 maxHeight : 1,
16637 offset : 0,
16638 height : 1,
16639 gutterOffset: 1
16640 };
16641
16642 this.scrollMargin = {
16643 left: 0,
16644 right: 0,
16645 top: 0,
16646 bottom: 0,
16647 v: 0,
16648 h: 0
16649 };
16650
16651 this.$loop = new RenderLoop(
16652 this.$renderChanges.bind(this),
16653 this.container.ownerDocument.defaultView
16654 );
16655 this.$loop.schedule(this.CHANGE_FULL);
16656
16657 this.updateCharacterSize();
16658 this.setPadding(4);
16659 config.resetOptions(this);
16660 config._emit("renderer", this);
16661 };
16662
16663 (function() {
16664
16665 this.CHANGE_CURSOR = 1;
16666 this.CHANGE_MARKER = 2;
16667 this.CHANGE_GUTTER = 4;
16668 this.CHANGE_SCROLL = 8;
16669 this.CHANGE_LINES = 16;
16670 this.CHANGE_TEXT = 32;
16671 this.CHANGE_SIZE = 64;
16672 this.CHANGE_MARKER_BACK = 128;
16673 this.CHANGE_MARKER_FRONT = 256;
16674 this.CHANGE_FULL = 512;
16675 this.CHANGE_H_SCROLL = 1024;
16676
16677 oop.implement(this, EventEmitter);
16678
16679 this.updateCharacterSize = function() {
16680 if (this.$textLayer.allowBoldFonts != this.$allowBoldFonts) {
16681 this.$allowBoldFonts = this.$textLayer.allowBoldFonts;
16682 this.setStyle("ace_nobold", !this.$allowBoldFonts);
16683 }
16684
16685 this.layerConfig.characterWidth =
16686 this.characterWidth = this.$textLayer.getCharacterWidth();
16687 this.layerConfig.lineHeight =
16688 this.lineHeight = this.$textLayer.getLineHeight();
16689 this.$updatePrintMargin();
16690 };
16691 this.setSession = function(session) {
16692 if (this.session)
16693 this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode);
16694
16695 this.session = session;
16696 if (session && this.scrollMargin.top && session.getScrollTop() <= 0)
16697 session.setScrollTop(-this.scrollMargin.top);
16698
16699 this.$cursorLayer.setSession(session);
16700 this.$markerBack.setSession(session);
16701 this.$markerFront.setSession(session);
16702 this.$gutterLayer.setSession(session);
16703 this.$textLayer.setSession(session);
16704 if (!session)
16705 return;
16706
16707 this.$loop.schedule(this.CHANGE_FULL);
16708 this.session.$setFontMetrics(this.$fontMetrics);
16709 this.scrollBarH.scrollLeft = this.scrollBarV.scrollTop = null;
16710
16711 this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this);
16712 this.onChangeNewLineMode();
16713 this.session.doc.on("changeNewLineMode", this.onChangeNewLineMode);
16714 };
16715 this.updateLines = function(firstRow, lastRow, force) {
16716 if (lastRow === undefined)
16717 lastRow = Infinity;
16718
16719 if (!this.$changedLines) {
16720 this.$changedLines = {
16721 firstRow: firstRow,
16722 lastRow: lastRow
16723 };
16724 }
16725 else {
16726 if (this.$changedLines.firstRow > firstRow)
16727 this.$changedLines.firstRow = firstRow;
16728
16729 if (this.$changedLines.lastRow < lastRow)
16730 this.$changedLines.lastRow = lastRow;
16731 }
16732 if (this.$changedLines.lastRow < this.layerConfig.firstRow) {
16733 if (force)
16734 this.$changedLines.lastRow = this.layerConfig.lastRow;
16735 else
16736 return;
16737 }
16738 if (this.$changedLines.firstRow > this.layerConfig.lastRow)
16739 return;
16740 this.$loop.schedule(this.CHANGE_LINES);
16741 };
16742
16743 this.onChangeNewLineMode = function() {
16744 this.$loop.schedule(this.CHANGE_TEXT);
16745 this.$textLayer.$updateEolChar();
16746 this.session.$bidiHandler.setEolChar(this.$textLayer.EOL_CHAR);
16747 };
16748
16749 this.onChangeTabSize = function() {
16750 this.$loop.schedule(this.CHANGE_TEXT | this.CHANGE_MARKER);
16751 this.$textLayer.onChangeTabSize();
16752 };
16753 this.updateText = function() {
16754 this.$loop.schedule(this.CHANGE_TEXT);
16755 };
16756 this.updateFull = function(force) {
16757 if (force)
16758 this.$renderChanges(this.CHANGE_FULL, true);
16759 else
16760 this.$loop.schedule(this.CHANGE_FULL);
16761 };
16762 this.updateFontSize = function() {
16763 this.$textLayer.checkForSizeChanges();
16764 };
16765
16766 this.$changes = 0;
16767 this.$updateSizeAsync = function() {
16768 if (this.$loop.pending)
16769 this.$size.$dirty = true;
16770 else
16771 this.onResize();
16772 };
16773 this.onResize = function(force, gutterWidth, width, height) {
16774 if (this.resizing > 2)
16775 return;
16776 else if (this.resizing > 0)
16777 this.resizing++;
16778 else
16779 this.resizing = force ? 1 : 0;
16780 var el = this.container;
16781 if (!height)
16782 height = el.clientHeight || el.scrollHeight;
16783 if (!width)
16784 width = el.clientWidth || el.scrollWidth;
16785 var changes = this.$updateCachedSize(force, gutterWidth, width, height);
16786
16787
16788 if (!this.$size.scrollerHeight || (!width && !height))
16789 return this.resizing = 0;
16790
16791 if (force)
16792 this.$gutterLayer.$padding = null;
16793
16794 if (force)
16795 this.$renderChanges(changes | this.$changes, true);
16796 else
16797 this.$loop.schedule(changes | this.$changes);
16798
16799 if (this.resizing)
16800 this.resizing = 0;
16801 this.scrollBarV.scrollLeft = this.scrollBarV.scrollTop = null;
16802 };
16803
16804 this.$updateCachedSize = function(force, gutterWidth, width, height) {
16805 height -= (this.$extraHeight || 0);
16806 var changes = 0;
16807 var size = this.$size;
16808 var oldSize = {
16809 width: size.width,
16810 height: size.height,
16811 scrollerHeight: size.scrollerHeight,
16812 scrollerWidth: size.scrollerWidth
16813 };
16814 if (height && (force || size.height != height)) {
16815 size.height = height;
16816 changes |= this.CHANGE_SIZE;
16817
16818 size.scrollerHeight = size.height;
16819 if (this.$horizScroll)
16820 size.scrollerHeight -= this.scrollBarH.getHeight();
16821 this.scrollBarV.element.style.bottom = this.scrollBarH.getHeight() + "px";
16822
16823 changes = changes | this.CHANGE_SCROLL;
16824 }
16825
16826 if (width && (force || size.width != width)) {
16827 changes |= this.CHANGE_SIZE;
16828 size.width = width;
16829
16830 if (gutterWidth == null)
16831 gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
16832
16833 this.gutterWidth = gutterWidth;
16834
16835 this.scrollBarH.element.style.left =
16836 this.scroller.style.left = gutterWidth + "px";
16837 size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth());
16838
16839 this.scrollBarH.element.style.right =
16840 this.scroller.style.right = this.scrollBarV.getWidth() + "px";
16841 this.scroller.style.bottom = this.scrollBarH.getHeight() + "px";
16842
16843 if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
16844 changes |= this.CHANGE_FULL;
16845 }
16846
16847 size.$dirty = !width || !height;
16848
16849 if (changes)
16850 this._signal("resize", oldSize);
16851
16852 return changes;
16853 };
16854
16855 this.onGutterResize = function() {
16856 var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
16857 if (gutterWidth != this.gutterWidth)
16858 this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height);
16859
16860 if (this.session.getUseWrapMode() && this.adjustWrapLimit()) {
16861 this.$loop.schedule(this.CHANGE_FULL);
16862 } else if (this.$size.$dirty) {
16863 this.$loop.schedule(this.CHANGE_FULL);
16864 } else {
16865 this.$computeLayerConfig();
16866 this.$loop.schedule(this.CHANGE_MARKER);
16867 }
16868 };
16869 this.adjustWrapLimit = function() {
16870 var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
16871 var limit = Math.floor(availableWidth / this.characterWidth);
16872 return this.session.adjustWrapLimit(limit, this.$showPrintMargin && this.$printMarginColumn);
16873 };
16874 this.setAnimatedScroll = function(shouldAnimate){
16875 this.setOption("animatedScroll", shouldAnimate);
16876 };
16877 this.getAnimatedScroll = function() {
16878 return this.$animatedScroll;
16879 };
16880 this.setShowInvisibles = function(showInvisibles) {
16881 this.setOption("showInvisibles", showInvisibles);
16882 this.session.$bidiHandler.setShowInvisibles(showInvisibles);
16883 };
16884 this.getShowInvisibles = function() {
16885 return this.getOption("showInvisibles");
16886 };
16887 this.getDisplayIndentGuides = function() {
16888 return this.getOption("displayIndentGuides");
16889 };
16890
16891 this.setDisplayIndentGuides = function(display) {
16892 this.setOption("displayIndentGuides", display);
16893 };
16894 this.setShowPrintMargin = function(showPrintMargin) {
16895 this.setOption("showPrintMargin", showPrintMargin);
16896 };
16897 this.getShowPrintMargin = function() {
16898 return this.getOption("showPrintMargin");
16899 };
16900 this.setPrintMarginColumn = function(showPrintMargin) {
16901 this.setOption("printMarginColumn", showPrintMargin);
16902 };
16903 this.getPrintMarginColumn = function() {
16904 return this.getOption("printMarginColumn");
16905 };
16906 this.getShowGutter = function(){
16907 return this.getOption("showGutter");
16908 };
16909 this.setShowGutter = function(show){
16910 return this.setOption("showGutter", show);
16911 };
16912
16913 this.getFadeFoldWidgets = function(){
16914 return this.getOption("fadeFoldWidgets");
16915 };
16916
16917 this.setFadeFoldWidgets = function(show) {
16918 this.setOption("fadeFoldWidgets", show);
16919 };
16920
16921 this.setHighlightGutterLine = function(shouldHighlight) {
16922 this.setOption("highlightGutterLine", shouldHighlight);
16923 };
16924
16925 this.getHighlightGutterLine = function() {
16926 return this.getOption("highlightGutterLine");
16927 };
16928
16929 this.$updateGutterLineHighlight = function() {
16930 var pos = this.$cursorLayer.$pixelPos;
16931 var height = this.layerConfig.lineHeight;
16932 if (this.session.getUseWrapMode()) {
16933 var cursor = this.session.selection.getCursor();
16934 cursor.column = 0;
16935 pos = this.$cursorLayer.getPixelPosition(cursor, true);
16936 height *= this.session.getRowLength(cursor.row);
16937 }
16938 this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px";
16939 this.$gutterLineHighlight.style.height = height + "px";
16940 };
16941
16942 this.$updatePrintMargin = function() {
16943 if (!this.$showPrintMargin && !this.$printMarginEl)
16944 return;
16945
16946 if (!this.$printMarginEl) {
16947 var containerEl = dom.createElement("div");
16948 containerEl.className = "ace_layer ace_print-margin-layer";
16949 this.$printMarginEl = dom.createElement("div");
16950 this.$printMarginEl.className = "ace_print-margin";
16951 containerEl.appendChild(this.$printMarginEl);
16952 this.content.insertBefore(containerEl, this.content.firstChild);
16953 }
16954
16955 var style = this.$printMarginEl.style;
16956 style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
16957 style.visibility = this.$showPrintMargin ? "visible" : "hidden";
16958
16959 if (this.session && this.session.$wrap == -1)
16960 this.adjustWrapLimit();
16961 };
16962 this.getContainerElement = function() {
16963 return this.container;
16964 };
16965 this.getMouseEventTarget = function() {
16966 return this.scroller;
16967 };
16968 this.getTextAreaContainer = function() {
16969 return this.container;
16970 };
16971 this.$moveTextAreaToCursor = function() {
16972 if (!this.$keepTextAreaAtCursor)
16973 return;
16974 var config = this.layerConfig;
16975 var posTop = this.$cursorLayer.$pixelPos.top;
16976 var posLeft = this.$cursorLayer.$pixelPos.left;
16977 posTop -= config.offset;
16978
16979 var style = this.textarea.style;
16980 var h = this.lineHeight;
16981 if (posTop < 0 || posTop > config.height - h) {
16982 style.top = style.left = "0";
16983 return;
16984 }
16985
16986 var w = this.characterWidth;
16987 if (this.$composition) {
16988 var val = this.textarea.value.replace(/^\x01+/, "");
16989 w *= (this.session.$getStringScreenWidth(val)[0]+2);
16990 h += 2;
16991 }
16992 posLeft -= this.scrollLeft;
16993 if (posLeft > this.$size.scrollerWidth - w)
16994 posLeft = this.$size.scrollerWidth - w;
16995
16996 posLeft += this.gutterWidth;
16997 style.height = h + "px";
16998 style.width = w + "px";
16999 style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px";
17000 style.top = Math.min(posTop, this.$size.height - h) + "px";
17001 };
17002 this.getFirstVisibleRow = function() {
17003 return this.layerConfig.firstRow;
17004 };
17005 this.getFirstFullyVisibleRow = function() {
17006 return this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1);
17007 };
17008 this.getLastFullyVisibleRow = function() {
17009 var config = this.layerConfig;
17010 var lastRow = config.lastRow;
17011 var top = this.session.documentToScreenRow(lastRow, 0) * config.lineHeight;
17012 if (top - this.session.getScrollTop() > config.height - config.lineHeight)
17013 return lastRow - 1;
17014 return lastRow;
17015 };
17016 this.getLastVisibleRow = function() {
17017 return this.layerConfig.lastRow;
17018 };
17019
17020 this.$padding = null;
17021 this.setPadding = function(padding) {
17022 this.$padding = padding;
17023 this.$textLayer.setPadding(padding);
17024 this.$cursorLayer.setPadding(padding);
17025 this.$markerFront.setPadding(padding);
17026 this.$markerBack.setPadding(padding);
17027 this.$loop.schedule(this.CHANGE_FULL);
17028 this.$updatePrintMargin();
17029 };
17030
17031 this.setScrollMargin = function(top, bottom, left, right) {
17032 var sm = this.scrollMargin;
17033 sm.top = top|0;
17034 sm.bottom = bottom|0;
17035 sm.right = right|0;
17036 sm.left = left|0;
17037 sm.v = sm.top + sm.bottom;
17038 sm.h = sm.left + sm.right;
17039 if (sm.top && this.scrollTop <= 0 && this.session)
17040 this.session.setScrollTop(-sm.top);
17041 this.updateFull();
17042 };
17043 this.getHScrollBarAlwaysVisible = function() {
17044 return this.$hScrollBarAlwaysVisible;
17045 };
17046 this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
17047 this.setOption("hScrollBarAlwaysVisible", alwaysVisible);
17048 };
17049 this.getVScrollBarAlwaysVisible = function() {
17050 return this.$vScrollBarAlwaysVisible;
17051 };
17052 this.setVScrollBarAlwaysVisible = function(alwaysVisible) {
17053 this.setOption("vScrollBarAlwaysVisible", alwaysVisible);
17054 };
17055
17056 this.$updateScrollBarV = function() {
17057 var scrollHeight = this.layerConfig.maxHeight;
17058 var scrollerHeight = this.$size.scrollerHeight;
17059 if (!this.$maxLines && this.$scrollPastEnd) {
17060 scrollHeight -= (scrollerHeight - this.lineHeight) * this.$scrollPastEnd;
17061 if (this.scrollTop > scrollHeight - scrollerHeight) {
17062 scrollHeight = this.scrollTop + scrollerHeight;
17063 this.scrollBarV.scrollTop = null;
17064 }
17065 }
17066 this.scrollBarV.setScrollHeight(scrollHeight + this.scrollMargin.v);
17067 this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top);
17068 };
17069 this.$updateScrollBarH = function() {
17070 this.scrollBarH.setScrollWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h);
17071 this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left);
17072 };
17073
17074 this.$frozen = false;
17075 this.freeze = function() {
17076 this.$frozen = true;
17077 };
17078
17079 this.unfreeze = function() {
17080 this.$frozen = false;
17081 };
17082
17083 this.$renderChanges = function(changes, force) {
17084 if (this.$changes) {
17085 changes |= this.$changes;
17086 this.$changes = 0;
17087 }
17088 if ((!this.session || !this.container.offsetWidth || this.$frozen) || (!changes && !force)) {
17089 this.$changes |= changes;
17090 return;
17091 }
17092 if (this.$size.$dirty) {
17093 this.$changes |= changes;
17094 return this.onResize(true);
17095 }
17096 if (!this.lineHeight) {
17097 this.$textLayer.checkForSizeChanges();
17098 }
17099
17100 this._signal("beforeRender");
17101
17102 if (this.session && this.session.$bidiHandler)
17103 this.session.$bidiHandler.updateCharacterWidths(this.$fontMetrics);
17104
17105 var config = this.layerConfig;
17106 if (changes & this.CHANGE_FULL ||
17107 changes & this.CHANGE_SIZE ||
17108 changes & this.CHANGE_TEXT ||
17109 changes & this.CHANGE_LINES ||
17110 changes & this.CHANGE_SCROLL ||
17111 changes & this.CHANGE_H_SCROLL
17112 ) {
17113 changes |= this.$computeLayerConfig();
17114 if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) {
17115 var st = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
17116 if (st > 0) {
17117 this.scrollTop = st;
17118 changes = changes | this.CHANGE_SCROLL;
17119 changes |= this.$computeLayerConfig();
17120 }
17121 }
17122 config = this.layerConfig;
17123 this.$updateScrollBarV();
17124 if (changes & this.CHANGE_H_SCROLL)
17125 this.$updateScrollBarH();
17126 this.$gutterLayer.element.style.marginTop = (-config.offset) + "px";
17127 this.content.style.marginTop = (-config.offset) + "px";
17128 this.content.style.width = config.width + 2 * this.$padding + "px";
17129 this.content.style.height = config.minHeight + "px";
17130 }
17131 if (changes & this.CHANGE_H_SCROLL) {
17132 this.content.style.marginLeft = -this.scrollLeft + "px";
17133 this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left";
17134 }
17135 if (changes & this.CHANGE_FULL) {
17136 this.$textLayer.update(config);
17137 if (this.$showGutter)
17138 this.$gutterLayer.update(config);
17139 this.$markerBack.update(config);
17140 this.$markerFront.update(config);
17141 this.$cursorLayer.update(config);
17142 this.$moveTextAreaToCursor();
17143 this.$highlightGutterLine && this.$updateGutterLineHighlight();
17144 this._signal("afterRender");
17145 return;
17146 }
17147 if (changes & this.CHANGE_SCROLL) {
17148 if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
17149 this.$textLayer.update(config);
17150 else
17151 this.$textLayer.scrollLines(config);
17152
17153 if (this.$showGutter)
17154 this.$gutterLayer.update(config);
17155 this.$markerBack.update(config);
17156 this.$markerFront.update(config);
17157 this.$cursorLayer.update(config);
17158 this.$highlightGutterLine && this.$updateGutterLineHighlight();
17159 this.$moveTextAreaToCursor();
17160 this._signal("afterRender");
17161 return;
17162 }
17163
17164 if (changes & this.CHANGE_TEXT) {
17165 this.$textLayer.update(config);
17166 if (this.$showGutter)
17167 this.$gutterLayer.update(config);
17168 }
17169 else if (changes & this.CHANGE_LINES) {
17170 if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter)
17171 this.$gutterLayer.update(config);
17172 }
17173 else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) {
17174 if (this.$showGutter)
17175 this.$gutterLayer.update(config);
17176 }
17177
17178 if (changes & this.CHANGE_CURSOR) {
17179 this.$cursorLayer.update(config);
17180 this.$moveTextAreaToCursor();
17181 this.$highlightGutterLine && this.$updateGutterLineHighlight();
17182 }
17183
17184 if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
17185 this.$markerFront.update(config);
17186 }
17187
17188 if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) {
17189 this.$markerBack.update(config);
17190 }
17191
17192 this._signal("afterRender");
17193 };
17194
17195
17196 this.$autosize = function() {
17197 var height = this.session.getScreenLength() * this.lineHeight;
17198 var maxHeight = this.$maxLines * this.lineHeight;
17199 var desiredHeight = Math.min(maxHeight,
17200 Math.max((this.$minLines || 1) * this.lineHeight, height)
17201 ) + this.scrollMargin.v + (this.$extraHeight || 0);
17202 if (this.$horizScroll)
17203 desiredHeight += this.scrollBarH.getHeight();
17204 if (this.$maxPixelHeight && desiredHeight > this.$maxPixelHeight)
17205 desiredHeight = this.$maxPixelHeight;
17206 var vScroll = height > maxHeight;
17207
17208 if (desiredHeight != this.desiredHeight ||
17209 this.$size.height != this.desiredHeight || vScroll != this.$vScroll) {
17210 if (vScroll != this.$vScroll) {
17211 this.$vScroll = vScroll;
17212 this.scrollBarV.setVisible(vScroll);
17213 }
17214
17215 var w = this.container.clientWidth;
17216 this.container.style.height = desiredHeight + "px";
17217 this.$updateCachedSize(true, this.$gutterWidth, w, desiredHeight);
17218 this.desiredHeight = desiredHeight;
17219
17220 this._signal("autosize");
17221 }
17222 };
17223
17224 this.$computeLayerConfig = function() {
17225 var session = this.session;
17226 var size = this.$size;
17227
17228 var hideScrollbars = size.height <= 2 * this.lineHeight;
17229 var screenLines = this.session.getScreenLength();
17230 var maxHeight = screenLines * this.lineHeight;
17231
17232 var longestLine = this.$getLongestLine();
17233
17234 var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
17235 size.scrollerWidth - longestLine - 2 * this.$padding < 0);
17236
17237 var hScrollChanged = this.$horizScroll !== horizScroll;
17238 if (hScrollChanged) {
17239 this.$horizScroll = horizScroll;
17240 this.scrollBarH.setVisible(horizScroll);
17241 }
17242 var vScrollBefore = this.$vScroll; // autosize can change vscroll value in which case we need to update longestLine
17243 if (this.$maxLines && this.lineHeight > 1)
17244 this.$autosize();
17245
17246 var offset = this.scrollTop % this.lineHeight;
17247 var minHeight = size.scrollerHeight + this.lineHeight;
17248
17249 var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd
17250 ? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
17251 : 0;
17252 maxHeight += scrollPastEnd;
17253
17254 var sm = this.scrollMargin;
17255 this.session.setScrollTop(Math.max(-sm.top,
17256 Math.min(this.scrollTop, maxHeight - size.scrollerHeight + sm.bottom)));
17257
17258 this.session.setScrollLeft(Math.max(-sm.left, Math.min(this.scrollLeft,
17259 longestLine + 2 * this.$padding - size.scrollerWidth + sm.right)));
17260
17261 var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
17262 size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop > sm.top);
17263 var vScrollChanged = vScrollBefore !== vScroll;
17264 if (vScrollChanged) {
17265 this.$vScroll = vScroll;
17266 this.scrollBarV.setVisible(vScroll);
17267 }
17268
17269 var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
17270 var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
17271 var lastRow = firstRow + lineCount;
17272 var firstRowScreen, firstRowHeight;
17273 var lineHeight = this.lineHeight;
17274 firstRow = session.screenToDocumentRow(firstRow, 0);
17275 var foldLine = session.getFoldLine(firstRow);
17276 if (foldLine) {
17277 firstRow = foldLine.start.row;
17278 }
17279
17280 firstRowScreen = session.documentToScreenRow(firstRow, 0);
17281 firstRowHeight = session.getRowLength(firstRow) * lineHeight;
17282
17283 lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1);
17284 minHeight = size.scrollerHeight + session.getRowLength(lastRow) * lineHeight +
17285 firstRowHeight;
17286
17287 offset = this.scrollTop - firstRowScreen * lineHeight;
17288
17289 var changes = 0;
17290 if (this.layerConfig.width != longestLine)
17291 changes = this.CHANGE_H_SCROLL;
17292 if (hScrollChanged || vScrollChanged) {
17293 changes = this.$updateCachedSize(true, this.gutterWidth, size.width, size.height);
17294 this._signal("scrollbarVisibilityChanged");
17295 if (vScrollChanged)
17296 longestLine = this.$getLongestLine();
17297 }
17298
17299 this.layerConfig = {
17300 width : longestLine,
17301 padding : this.$padding,
17302 firstRow : firstRow,
17303 firstRowScreen: firstRowScreen,
17304 lastRow : lastRow,
17305 lineHeight : lineHeight,
17306 characterWidth : this.characterWidth,
17307 minHeight : minHeight,
17308 maxHeight : maxHeight,
17309 offset : offset,
17310 gutterOffset : lineHeight ? Math.max(0, Math.ceil((offset + size.height - size.scrollerHeight) / lineHeight)) : 0,
17311 height : this.$size.scrollerHeight
17312 };
17313
17314 return changes;
17315 };
17316
17317 this.$updateLines = function() {
17318 if (!this.$changedLines) return;
17319 var firstRow = this.$changedLines.firstRow;
17320 var lastRow = this.$changedLines.lastRow;
17321 this.$changedLines = null;
17322
17323 var layerConfig = this.layerConfig;
17324
17325 if (firstRow > layerConfig.lastRow + 1) { return; }
17326 if (lastRow < layerConfig.firstRow) { return; }
17327 if (lastRow === Infinity) {
17328 if (this.$showGutter)
17329 this.$gutterLayer.update(layerConfig);
17330 this.$textLayer.update(layerConfig);
17331 return;
17332 }
17333 this.$textLayer.updateLines(layerConfig, firstRow, lastRow);
17334 return true;
17335 };
17336
17337 this.$getLongestLine = function() {
17338 var charCount = this.session.getScreenWidth();
17339 if (this.showInvisibles && !this.session.$useWrapMode)
17340 charCount += 1;
17341
17342 return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth));
17343 };
17344 this.updateFrontMarkers = function() {
17345 this.$markerFront.setMarkers(this.session.getMarkers(true));
17346 this.$loop.schedule(this.CHANGE_MARKER_FRONT);
17347 };
17348 this.updateBackMarkers = function() {
17349 this.$markerBack.setMarkers(this.session.getMarkers());
17350 this.$loop.schedule(this.CHANGE_MARKER_BACK);
17351 };
17352 this.addGutterDecoration = function(row, className){
17353 this.$gutterLayer.addGutterDecoration(row, className);
17354 };
17355 this.removeGutterDecoration = function(row, className){
17356 this.$gutterLayer.removeGutterDecoration(row, className);
17357 };
17358 this.updateBreakpoints = function(rows) {
17359 this.$loop.schedule(this.CHANGE_GUTTER);
17360 };
17361 this.setAnnotations = function(annotations) {
17362 this.$gutterLayer.setAnnotations(annotations);
17363 this.$loop.schedule(this.CHANGE_GUTTER);
17364 };
17365 this.updateCursor = function() {
17366 this.$loop.schedule(this.CHANGE_CURSOR);
17367 };
17368 this.hideCursor = function() {
17369 this.$cursorLayer.hideCursor();
17370 };
17371 this.showCursor = function() {
17372 this.$cursorLayer.showCursor();
17373 };
17374
17375 this.scrollSelectionIntoView = function(anchor, lead, offset) {
17376 this.scrollCursorIntoView(anchor, offset);
17377 this.scrollCursorIntoView(lead, offset);
17378 };
17379 this.scrollCursorIntoView = function(cursor, offset, $viewMargin) {
17380 if (this.$size.scrollerHeight === 0)
17381 return;
17382
17383 var pos = this.$cursorLayer.getPixelPosition(cursor);
17384
17385 var left = pos.left;
17386 var top = pos.top;
17387
17388 var topMargin = $viewMargin && $viewMargin.top || 0;
17389 var bottomMargin = $viewMargin && $viewMargin.bottom || 0;
17390
17391 var scrollTop = this.$scrollAnimation ? this.session.getScrollTop() : this.scrollTop;
17392
17393 if (scrollTop + topMargin > top) {
17394 if (offset && scrollTop + topMargin > top + this.lineHeight)
17395 top -= offset * this.$size.scrollerHeight;
17396 if (top === 0)
17397 top = -this.scrollMargin.top;
17398 this.session.setScrollTop(top);
17399 } else if (scrollTop + this.$size.scrollerHeight - bottomMargin < top + this.lineHeight) {
17400 if (offset && scrollTop + this.$size.scrollerHeight - bottomMargin < top - this.lineHeight)
17401 top += offset * this.$size.scrollerHeight;
17402 this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
17403 }
17404
17405 var scrollLeft = this.scrollLeft;
17406
17407 if (scrollLeft > left) {
17408 if (left < this.$padding + 2 * this.layerConfig.characterWidth)
17409 left = -this.scrollMargin.left;
17410 this.session.setScrollLeft(left);
17411 } else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
17412 this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
17413 } else if (scrollLeft <= this.$padding && left - scrollLeft < this.characterWidth) {
17414 this.session.setScrollLeft(0);
17415 }
17416 };
17417 this.getScrollTop = function() {
17418 return this.session.getScrollTop();
17419 };
17420 this.getScrollLeft = function() {
17421 return this.session.getScrollLeft();
17422 };
17423 this.getScrollTopRow = function() {
17424 return this.scrollTop / this.lineHeight;
17425 };
17426 this.getScrollBottomRow = function() {
17427 return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1);
17428 };
17429 this.scrollToRow = function(row) {
17430 this.session.setScrollTop(row * this.lineHeight);
17431 };
17432
17433 this.alignCursor = function(cursor, alignment) {
17434 if (typeof cursor == "number")
17435 cursor = {row: cursor, column: 0};
17436
17437 var pos = this.$cursorLayer.getPixelPosition(cursor);
17438 var h = this.$size.scrollerHeight - this.lineHeight;
17439 var offset = pos.top - h * (alignment || 0);
17440
17441 this.session.setScrollTop(offset);
17442 return offset;
17443 };
17444
17445 this.STEPS = 8;
17446 this.$calcSteps = function(fromValue, toValue){
17447 var i = 0;
17448 var l = this.STEPS;
17449 var steps = [];
17450
17451 var func = function(t, x_min, dx) {
17452 return dx * (Math.pow(t - 1, 3) + 1) + x_min;
17453 };
17454
17455 for (i = 0; i < l; ++i)
17456 steps.push(func(i / this.STEPS, fromValue, toValue - fromValue));
17457
17458 return steps;
17459 };
17460 this.scrollToLine = function(line, center, animate, callback) {
17461 var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
17462 var offset = pos.top;
17463 if (center)
17464 offset -= this.$size.scrollerHeight / 2;
17465
17466 var initialScroll = this.scrollTop;
17467 this.session.setScrollTop(offset);
17468 if (animate !== false)
17469 this.animateScrolling(initialScroll, callback);
17470 };
17471
17472 this.animateScrolling = function(fromValue, callback) {
17473 var toValue = this.scrollTop;
17474 if (!this.$animatedScroll)
17475 return;
17476 var _self = this;
17477
17478 if (fromValue == toValue)
17479 return;
17480
17481 if (this.$scrollAnimation) {
17482 var oldSteps = this.$scrollAnimation.steps;
17483 if (oldSteps.length) {
17484 fromValue = oldSteps[0];
17485 if (fromValue == toValue)
17486 return;
17487 }
17488 }
17489
17490 var steps = _self.$calcSteps(fromValue, toValue);
17491 this.$scrollAnimation = {from: fromValue, to: toValue, steps: steps};
17492
17493 clearInterval(this.$timer);
17494
17495 _self.session.setScrollTop(steps.shift());
17496 _self.session.$scrollTop = toValue;
17497 this.$timer = setInterval(function() {
17498 if (steps.length) {
17499 _self.session.setScrollTop(steps.shift());
17500 _self.session.$scrollTop = toValue;
17501 } else if (toValue != null) {
17502 _self.session.$scrollTop = -1;
17503 _self.session.setScrollTop(toValue);
17504 toValue = null;
17505 } else {
17506 _self.$timer = clearInterval(_self.$timer);
17507 _self.$scrollAnimation = null;
17508 callback && callback();
17509 }
17510 }, 10);
17511 };
17512 this.scrollToY = function(scrollTop) {
17513 if (this.scrollTop !== scrollTop) {
17514 this.$loop.schedule(this.CHANGE_SCROLL);
17515 this.scrollTop = scrollTop;
17516 }
17517 };
17518 this.scrollToX = function(scrollLeft) {
17519 if (this.scrollLeft !== scrollLeft)
17520 this.scrollLeft = scrollLeft;
17521 this.$loop.schedule(this.CHANGE_H_SCROLL);
17522 };
17523 this.scrollTo = function(x, y) {
17524 this.session.setScrollTop(y);
17525 this.session.setScrollLeft(y);
17526 };
17527 this.scrollBy = function(deltaX, deltaY) {
17528 deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY);
17529 deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX);
17530 };
17531 this.isScrollableBy = function(deltaX, deltaY) {
17532 if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top)
17533 return true;
17534 if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight
17535 - this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom)
17536 return true;
17537 if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left)
17538 return true;
17539 if (deltaX > 0 && this.session.getScrollLeft() + this.$size.scrollerWidth
17540 - this.layerConfig.width < -1 + this.scrollMargin.right)
17541 return true;
17542 };
17543
17544 this.pixelToScreenCoordinates = function(x, y) {
17545 var canvasPos = this.scroller.getBoundingClientRect();
17546
17547 var offsetX = x + this.scrollLeft - canvasPos.left - this.$padding;
17548 var offset = offsetX / this.characterWidth;
17549 var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight);
17550 var col = Math.round(offset);
17551
17552 return {row: row, column: col, side: offset - col > 0 ? 1 : -1, offsetX: offsetX};
17553 };
17554
17555 this.screenToTextCoordinates = function(x, y) {
17556 var canvasPos = this.scroller.getBoundingClientRect();
17557 var offsetX = x + this.scrollLeft - canvasPos.left - this.$padding;
17558
17559 var col = Math.round(offsetX / this.characterWidth);
17560
17561 var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight;
17562
17563 return this.session.screenToDocumentPosition(row, Math.max(col, 0), offsetX);
17564 };
17565 this.textToScreenCoordinates = function(row, column) {
17566 var canvasPos = this.scroller.getBoundingClientRect();
17567 var pos = this.session.documentToScreenPosition(row, column);
17568
17569 var x = this.$padding + (this.session.$bidiHandler.isBidiRow(pos.row, row)
17570 ? this.session.$bidiHandler.getPosLeft(pos.column)
17571 : Math.round(pos.column * this.characterWidth));
17572
17573 var y = pos.row * this.lineHeight;
17574
17575 return {
17576 pageX: canvasPos.left + x - this.scrollLeft,
17577 pageY: canvasPos.top + y - this.scrollTop
17578 };
17579 };
17580 this.visualizeFocus = function() {
17581 dom.addCssClass(this.container, "ace_focus");
17582 };
17583 this.visualizeBlur = function() {
17584 dom.removeCssClass(this.container, "ace_focus");
17585 };
17586 this.showComposition = function(position) {
17587 if (!this.$composition)
17588 this.$composition = {
17589 keepTextAreaAtCursor: this.$keepTextAreaAtCursor,
17590 cssText: this.textarea.style.cssText
17591 };
17592
17593 this.$keepTextAreaAtCursor = true;
17594 dom.addCssClass(this.textarea, "ace_composition");
17595 this.textarea.style.cssText = "";
17596 this.$moveTextAreaToCursor();
17597 };
17598 this.setCompositionText = function(text) {
17599 this.$moveTextAreaToCursor();
17600 };
17601 this.hideComposition = function() {
17602 if (!this.$composition)
17603 return;
17604
17605 dom.removeCssClass(this.textarea, "ace_composition");
17606 this.$keepTextAreaAtCursor = this.$composition.keepTextAreaAtCursor;
17607 this.textarea.style.cssText = this.$composition.cssText;
17608 this.$composition = null;
17609 };
17610 this.setTheme = function(theme, cb) {
17611 var _self = this;
17612 this.$themeId = theme;
17613 _self._dispatchEvent('themeChange',{theme:theme});
17614
17615 if (!theme || typeof theme == "string") {
17616 var moduleName = theme || this.$options.theme.initialValue;
17617 config.loadModule(["theme", moduleName], afterLoad);
17618 } else {
17619 afterLoad(theme);
17620 }
17621
17622 function afterLoad(module) {
17623 if (_self.$themeId != theme)
17624 return cb && cb();
17625 if (!module || !module.cssClass)
17626 throw new Error("couldn't load module " + theme + " or it didn't call define");
17627 dom.importCssString(
17628 module.cssText,
17629 module.cssClass,
17630 _self.container.ownerDocument
17631 );
17632
17633 if (_self.theme)
17634 dom.removeCssClass(_self.container, _self.theme.cssClass);
17635
17636 var padding = "padding" in module ? module.padding
17637 : "padding" in (_self.theme || {}) ? 4 : _self.$padding;
17638 if (_self.$padding && padding != _self.$padding)
17639 _self.setPadding(padding);
17640 _self.$theme = module.cssClass;
17641
17642 _self.theme = module;
17643 dom.addCssClass(_self.container, module.cssClass);
17644 dom.setCssClass(_self.container, "ace_dark", module.isDark);
17645 if (_self.$size) {
17646 _self.$size.width = 0;
17647 _self.$updateSizeAsync();
17648 }
17649
17650 _self._dispatchEvent('themeLoaded', {theme:module});
17651 cb && cb();
17652 }
17653 };
17654 this.getTheme = function() {
17655 return this.$themeId;
17656 };
17657 this.setStyle = function(style, include) {
17658 dom.setCssClass(this.container, style, include !== false);
17659 };
17660 this.unsetStyle = function(style) {
17661 dom.removeCssClass(this.container, style);
17662 };
17663
17664 this.setCursorStyle = function(style) {
17665 if (this.scroller.style.cursor != style)
17666 this.scroller.style.cursor = style;
17667 };
17668 this.setMouseCursor = function(cursorStyle) {
17669 this.scroller.style.cursor = cursorStyle;
17670 };
17671 this.destroy = function() {
17672 this.$textLayer.destroy();
17673 this.$cursorLayer.destroy();
17674 };
17675
17676 }).call(VirtualRenderer.prototype);
17677
17678
17679 config.defineOptions(VirtualRenderer.prototype, "renderer", {
17680 animatedScroll: {initialValue: false},
17681 showInvisibles: {
17682 set: function(value) {
17683 if (this.$textLayer.setShowInvisibles(value))
17684 this.$loop.schedule(this.CHANGE_TEXT);
17685 },
17686 initialValue: false
17687 },
17688 showPrintMargin: {
17689 set: function() { this.$updatePrintMargin(); },
17690 initialValue: true
17691 },
17692 printMarginColumn: {
17693 set: function() { this.$updatePrintMargin(); },
17694 initialValue: 80
17695 },
17696 printMargin: {
17697 set: function(val) {
17698 if (typeof val == "number")
17699 this.$printMarginColumn = val;
17700 this.$showPrintMargin = !!val;
17701 this.$updatePrintMargin();
17702 },
17703 get: function() {
17704 return this.$showPrintMargin && this.$printMarginColumn;
17705 }
17706 },
17707 showGutter: {
17708 set: function(show){
17709 this.$gutter.style.display = show ? "block" : "none";
17710 this.$loop.schedule(this.CHANGE_FULL);
17711 this.onGutterResize();
17712 },
17713 initialValue: true
17714 },
17715 fadeFoldWidgets: {
17716 set: function(show) {
17717 dom.setCssClass(this.$gutter, "ace_fade-fold-widgets", show);
17718 },
17719 initialValue: false
17720 },
17721 showFoldWidgets: {
17722 set: function(show) {this.$gutterLayer.setShowFoldWidgets(show);},
17723 initialValue: true
17724 },
17725 showLineNumbers: {
17726 set: function(show) {
17727 this.$gutterLayer.setShowLineNumbers(show);
17728 this.$loop.schedule(this.CHANGE_GUTTER);
17729 },
17730 initialValue: true
17731 },
17732 displayIndentGuides: {
17733 set: function(show) {
17734 if (this.$textLayer.setDisplayIndentGuides(show))
17735 this.$loop.schedule(this.CHANGE_TEXT);
17736 },
17737 initialValue: true
17738 },
17739 highlightGutterLine: {
17740 set: function(shouldHighlight) {
17741 if (!this.$gutterLineHighlight) {
17742 this.$gutterLineHighlight = dom.createElement("div");
17743 this.$gutterLineHighlight.className = "ace_gutter-active-line";
17744 this.$gutter.appendChild(this.$gutterLineHighlight);
17745 return;
17746 }
17747
17748 this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none";
17749 if (this.$cursorLayer.$pixelPos)
17750 this.$updateGutterLineHighlight();
17751 },
17752 initialValue: false,
17753 value: true
17754 },
17755 hScrollBarAlwaysVisible: {
17756 set: function(val) {
17757 if (!this.$hScrollBarAlwaysVisible || !this.$horizScroll)
17758 this.$loop.schedule(this.CHANGE_SCROLL);
17759 },
17760 initialValue: false
17761 },
17762 vScrollBarAlwaysVisible: {
17763 set: function(val) {
17764 if (!this.$vScrollBarAlwaysVisible || !this.$vScroll)
17765 this.$loop.schedule(this.CHANGE_SCROLL);
17766 },
17767 initialValue: false
17768 },
17769 fontSize: {
17770 set: function(size) {
17771 if (typeof size == "number")
17772 size = size + "px";
17773 this.container.style.fontSize = size;
17774 this.updateFontSize();
17775 },
17776 initialValue: 12
17777 },
17778 fontFamily: {
17779 set: function(name) {
17780 this.container.style.fontFamily = name;
17781 this.updateFontSize();
17782 }
17783 },
17784 maxLines: {
17785 set: function(val) {
17786 this.updateFull();
17787 }
17788 },
17789 minLines: {
17790 set: function(val) {
17791 this.updateFull();
17792 }
17793 },
17794 maxPixelHeight: {
17795 set: function(val) {
17796 this.updateFull();
17797 },
17798 initialValue: 0
17799 },
17800 scrollPastEnd: {
17801 set: function(val) {
17802 val = +val || 0;
17803 if (this.$scrollPastEnd == val)
17804 return;
17805 this.$scrollPastEnd = val;
17806 this.$loop.schedule(this.CHANGE_SCROLL);
17807 },
17808 initialValue: 0,
17809 handlesSet: true
17810 },
17811 fixedWidthGutter: {
17812 set: function(val) {
17813 this.$gutterLayer.$fixedWidth = !!val;
17814 this.$loop.schedule(this.CHANGE_GUTTER);
17815 }
17816 },
17817 theme: {
17818 set: function(val) { this.setTheme(val); },
17819 get: function() { return this.$themeId || this.theme; },
17820 initialValue: "./theme/textmate",
17821 handlesSet: true
17822 }
17823 });
17824
17825 exports.VirtualRenderer = VirtualRenderer;
17826 });
17827
17828 ace.define("ace/worker/worker_client",["require","exports","module","ace/lib/oop","ace/lib/net","ace/lib/event_emitter","ace/config"], function(acequire, exports, module) {
17829
17830 var oop = acequire("../lib/oop");
17831 var net = acequire("../lib/net");
17832 var EventEmitter = acequire("../lib/event_emitter").EventEmitter;
17833 var config = acequire("../config");
17834
17835 function $workerBlob(workerUrl, mod) {
17836 var script = mod.src;"importScripts('" + net.qualifyURL(workerUrl) + "');";
17837 try {
17838 return new Blob([script], {"type": "application/javascript"});
17839 } catch (e) { // Backwards-compatibility
17840 var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
17841 var blobBuilder = new BlobBuilder();
17842 blobBuilder.append(script);
17843 return blobBuilder.getBlob("application/javascript");
17844 }
17845 }
17846
17847 function createWorker(workerUrl, mod) {
17848 var blob = $workerBlob(workerUrl, mod);
17849 var URL = window.URL || window.webkitURL;
17850 var blobURL = URL.createObjectURL(blob);
17851 return new Worker(blobURL);
17852 }
17853
17854 var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl, importScripts) {
17855 this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
17856 this.changeListener = this.changeListener.bind(this);
17857 this.onMessage = this.onMessage.bind(this);
17858 if (acequire.nameToUrl && !acequire.toUrl)
17859 acequire.toUrl = acequire.nameToUrl;
17860
17861 if (config.get("packaged") || !acequire.toUrl) {
17862 workerUrl = workerUrl || config.moduleUrl(mod.id, "worker");
17863 } else {
17864 var normalizePath = this.$normalizePath;
17865 workerUrl = workerUrl || normalizePath(acequire.toUrl("ace/worker/worker.js", null, "_"));
17866
17867 var tlns = {};
17868 topLevelNamespaces.forEach(function(ns) {
17869 tlns[ns] = normalizePath(acequire.toUrl(ns, null, "_").replace(/(\.js)?(\?.*)?$/, ""));
17870 });
17871 }
17872
17873 this.$worker = createWorker(workerUrl, mod);
17874 if (importScripts) {
17875 this.send("importScripts", importScripts);
17876 }
17877 this.$worker.postMessage({
17878 init : true,
17879 tlns : tlns,
17880 module : mod.id,
17881 classname : classname
17882 });
17883
17884 this.callbackId = 1;
17885 this.callbacks = {};
17886
17887 this.$worker.onmessage = this.onMessage;
17888 };
17889
17890 (function(){
17891
17892 oop.implement(this, EventEmitter);
17893
17894 this.onMessage = function(e) {
17895 var msg = e.data;
17896 switch (msg.type) {
17897 case "event":
17898 this._signal(msg.name, {data: msg.data});
17899 break;
17900 case "call":
17901 var callback = this.callbacks[msg.id];
17902 if (callback) {
17903 callback(msg.data);
17904 delete this.callbacks[msg.id];
17905 }
17906 break;
17907 case "error":
17908 this.reportError(msg.data);
17909 break;
17910 case "log":
17911 window.console && console.log && console.log.apply(console, msg.data);
17912 break;
17913 }
17914 };
17915
17916 this.reportError = function(err) {
17917 window.console && console.error && console.error(err);
17918 };
17919
17920 this.$normalizePath = function(path) {
17921 return net.qualifyURL(path);
17922 };
17923
17924 this.terminate = function() {
17925 this._signal("terminate", {});
17926 this.deltaQueue = null;
17927 this.$worker.terminate();
17928 this.$worker = null;
17929 if (this.$doc)
17930 this.$doc.off("change", this.changeListener);
17931 this.$doc = null;
17932 };
17933
17934 this.send = function(cmd, args) {
17935 this.$worker.postMessage({command: cmd, args: args});
17936 };
17937
17938 this.call = function(cmd, args, callback) {
17939 if (callback) {
17940 var id = this.callbackId++;
17941 this.callbacks[id] = callback;
17942 args.push(id);
17943 }
17944 this.send(cmd, args);
17945 };
17946
17947 this.emit = function(event, data) {
17948 try {
17949 this.$worker.postMessage({event: event, data: {data: data.data}});
17950 }
17951 catch(ex) {
17952 console.error(ex.stack);
17953 }
17954 };
17955
17956 this.attachToDocument = function(doc) {
17957 if (this.$doc)
17958 this.terminate();
17959
17960 this.$doc = doc;
17961 this.call("setValue", [doc.getValue()]);
17962 doc.on("change", this.changeListener);
17963 };
17964
17965 this.changeListener = function(delta) {
17966 if (!this.deltaQueue) {
17967 this.deltaQueue = [];
17968 setTimeout(this.$sendDeltaQueue, 0);
17969 }
17970 if (delta.action == "insert")
17971 this.deltaQueue.push(delta.start, delta.lines);
17972 else
17973 this.deltaQueue.push(delta.start, delta.end);
17974 };
17975
17976 this.$sendDeltaQueue = function() {
17977 var q = this.deltaQueue;
17978 if (!q) return;
17979 this.deltaQueue = null;
17980 if (q.length > 50 && q.length > this.$doc.getLength() >> 1) {
17981 this.call("setValue", [this.$doc.getValue()]);
17982 } else
17983 this.emit("change", {data: q});
17984 };
17985
17986 }).call(WorkerClient.prototype);
17987
17988
17989 var UIWorkerClient = function(topLevelNamespaces, mod, classname) {
17990 this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
17991 this.changeListener = this.changeListener.bind(this);
17992 this.callbackId = 1;
17993 this.callbacks = {};
17994 this.messageBuffer = [];
17995
17996 var main = null;
17997 var emitSync = false;
17998 var sender = Object.create(EventEmitter);
17999 var _self = this;
18000
18001 this.$worker = {};
18002 this.$worker.terminate = function() {};
18003 this.$worker.postMessage = function(e) {
18004 _self.messageBuffer.push(e);
18005 if (main) {
18006 if (emitSync)
18007 setTimeout(processNext);
18008 else
18009 processNext();
18010 }
18011 };
18012 this.setEmitSync = function(val) { emitSync = val; };
18013
18014 var processNext = function() {
18015 var msg = _self.messageBuffer.shift();
18016 if (msg.command)
18017 main[msg.command].apply(main, msg.args);
18018 else if (msg.event)
18019 sender._signal(msg.event, msg.data);
18020 };
18021
18022 sender.postMessage = function(msg) {
18023 _self.onMessage({data: msg});
18024 };
18025 sender.callback = function(data, callbackId) {
18026 this.postMessage({type: "call", id: callbackId, data: data});
18027 };
18028 sender.emit = function(name, data) {
18029 this.postMessage({type: "event", name: name, data: data});
18030 };
18031
18032 config.loadModule(["worker", mod], function(Main) {
18033 main = new Main[classname](sender);
18034 while (_self.messageBuffer.length)
18035 processNext();
18036 });
18037 };
18038
18039 UIWorkerClient.prototype = WorkerClient.prototype;
18040
18041 exports.UIWorkerClient = UIWorkerClient;
18042 exports.WorkerClient = WorkerClient;
18043 exports.createWorker = createWorker;
18044
18045
18046 });
18047
18048 ace.define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"], function(acequire, exports, module) {
18049
18050 var Range = acequire("./range").Range;
18051 var EventEmitter = acequire("./lib/event_emitter").EventEmitter;
18052 var oop = acequire("./lib/oop");
18053
18054 var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) {
18055 var _self = this;
18056 this.length = length;
18057 this.session = session;
18058 this.doc = session.getDocument();
18059 this.mainClass = mainClass;
18060 this.othersClass = othersClass;
18061 this.$onUpdate = this.onUpdate.bind(this);
18062 this.doc.on("change", this.$onUpdate);
18063 this.$others = others;
18064
18065 this.$onCursorChange = function() {
18066 setTimeout(function() {
18067 _self.onCursorChange();
18068 });
18069 };
18070
18071 this.$pos = pos;
18072 var undoStack = session.getUndoManager().$undoStack || session.getUndoManager().$undostack || {length: -1};
18073 this.$undoStackDepth = undoStack.length;
18074 this.setup();
18075
18076 session.selection.on("changeCursor", this.$onCursorChange);
18077 };
18078
18079 (function() {
18080
18081 oop.implement(this, EventEmitter);
18082 this.setup = function() {
18083 var _self = this;
18084 var doc = this.doc;
18085 var session = this.session;
18086
18087 this.selectionBefore = session.selection.toJSON();
18088 if (session.selection.inMultiSelectMode)
18089 session.selection.toSingleRange();
18090
18091 this.pos = doc.createAnchor(this.$pos.row, this.$pos.column);
18092 var pos = this.pos;
18093 pos.$insertRight = true;
18094 pos.detach();
18095 pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
18096 this.others = [];
18097 this.$others.forEach(function(other) {
18098 var anchor = doc.createAnchor(other.row, other.column);
18099 anchor.$insertRight = true;
18100 anchor.detach();
18101 _self.others.push(anchor);
18102 });
18103 session.setUndoSelect(false);
18104 };
18105 this.showOtherMarkers = function() {
18106 if (this.othersActive) return;
18107 var session = this.session;
18108 var _self = this;
18109 this.othersActive = true;
18110 this.others.forEach(function(anchor) {
18111 anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column+_self.length), _self.othersClass, null, false);
18112 });
18113 };
18114 this.hideOtherMarkers = function() {
18115 if (!this.othersActive) return;
18116 this.othersActive = false;
18117 for (var i = 0; i < this.others.length; i++) {
18118 this.session.removeMarker(this.others[i].markerId);
18119 }
18120 };
18121 this.onUpdate = function(delta) {
18122 if (this.$updating)
18123 return this.updateAnchors(delta);
18124
18125 var range = delta;
18126 if (range.start.row !== range.end.row) return;
18127 if (range.start.row !== this.pos.row) return;
18128 this.$updating = true;
18129 var lengthDiff = delta.action === "insert" ? range.end.column - range.start.column : range.start.column - range.end.column;
18130 var inMainRange = range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1;
18131 var distanceFromStart = range.start.column - this.pos.column;
18132
18133 this.updateAnchors(delta);
18134
18135 if (inMainRange)
18136 this.length += lengthDiff;
18137
18138 if (inMainRange && !this.session.$fromUndo) {
18139 if (delta.action === 'insert') {
18140 for (var i = this.others.length - 1; i >= 0; i--) {
18141 var otherPos = this.others[i];
18142 var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
18143 this.doc.insertMergedLines(newPos, delta.lines);
18144 }
18145 } else if (delta.action === 'remove') {
18146 for (var i = this.others.length - 1; i >= 0; i--) {
18147 var otherPos = this.others[i];
18148 var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
18149 this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff));
18150 }
18151 }
18152 }
18153
18154 this.$updating = false;
18155 this.updateMarkers();
18156 };
18157
18158 this.updateAnchors = function(delta) {
18159 this.pos.onChange(delta);
18160 for (var i = this.others.length; i--;)
18161 this.others[i].onChange(delta);
18162 this.updateMarkers();
18163 };
18164
18165 this.updateMarkers = function() {
18166 if (this.$updating)
18167 return;
18168 var _self = this;
18169 var session = this.session;
18170 var updateMarker = function(pos, className) {
18171 session.removeMarker(pos.markerId);
18172 pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column+_self.length), className, null, false);
18173 };
18174 updateMarker(this.pos, this.mainClass);
18175 for (var i = this.others.length; i--;)
18176 updateMarker(this.others[i], this.othersClass);
18177 };
18178
18179 this.onCursorChange = function(event) {
18180 if (this.$updating || !this.session) return;
18181 var pos = this.session.selection.getCursor();
18182 if (pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
18183 this.showOtherMarkers();
18184 this._emit("cursorEnter", event);
18185 } else {
18186 this.hideOtherMarkers();
18187 this._emit("cursorLeave", event);
18188 }
18189 };
18190 this.detach = function() {
18191 this.session.removeMarker(this.pos && this.pos.markerId);
18192 this.hideOtherMarkers();
18193 this.doc.removeEventListener("change", this.$onUpdate);
18194 this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
18195 this.session.setUndoSelect(true);
18196 this.session = null;
18197 };
18198 this.cancel = function() {
18199 if (this.$undoStackDepth === -1)
18200 return;
18201 var undoManager = this.session.getUndoManager();
18202 var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth;
18203 for (var i = 0; i < undosRequired; i++) {
18204 undoManager.undo(true);
18205 }
18206 if (this.selectionBefore)
18207 this.session.selection.fromJSON(this.selectionBefore);
18208 };
18209 }).call(PlaceHolder.prototype);
18210
18211
18212 exports.PlaceHolder = PlaceHolder;
18213 });
18214
18215 ace.define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(acequire, exports, module) {
18216
18217 var event = acequire("../lib/event");
18218 var useragent = acequire("../lib/useragent");
18219 function isSamePoint(p1, p2) {
18220 return p1.row == p2.row && p1.column == p2.column;
18221 }
18222
18223 function onMouseDown(e) {
18224 var ev = e.domEvent;
18225 var alt = ev.altKey;
18226 var shift = ev.shiftKey;
18227 var ctrl = ev.ctrlKey;
18228 var accel = e.getAccelKey();
18229 var button = e.getButton();
18230
18231 if (ctrl && useragent.isMac)
18232 button = ev.button;
18233
18234 if (e.editor.inMultiSelectMode && button == 2) {
18235 e.editor.textInput.onContextMenu(e.domEvent);
18236 return;
18237 }
18238
18239 if (!ctrl && !alt && !accel) {
18240 if (button === 0 && e.editor.inMultiSelectMode)
18241 e.editor.exitMultiSelectMode();
18242 return;
18243 }
18244
18245 if (button !== 0)
18246 return;
18247
18248 var editor = e.editor;
18249 var selection = editor.selection;
18250 var isMultiSelect = editor.inMultiSelectMode;
18251 var pos = e.getDocumentPosition();
18252 var cursor = selection.getCursor();
18253 var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
18254
18255 var mouseX = e.x, mouseY = e.y;
18256 var onMouseSelection = function(e) {
18257 mouseX = e.clientX;
18258 mouseY = e.clientY;
18259 };
18260
18261 var session = editor.session;
18262 var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
18263 var screenCursor = screenAnchor;
18264
18265 var selectionMode;
18266 if (editor.$mouseHandler.$enableJumpToDef) {
18267 if (ctrl && alt || accel && alt)
18268 selectionMode = shift ? "block" : "add";
18269 else if (alt && editor.$blockSelectEnabled)
18270 selectionMode = "block";
18271 } else {
18272 if (accel && !alt) {
18273 selectionMode = "add";
18274 if (!isMultiSelect && shift)
18275 return;
18276 } else if (alt && editor.$blockSelectEnabled) {
18277 selectionMode = "block";
18278 }
18279 }
18280
18281 if (selectionMode && useragent.isMac && ev.ctrlKey) {
18282 editor.$mouseHandler.cancelContextMenu();
18283 }
18284
18285 if (selectionMode == "add") {
18286 if (!isMultiSelect && inSelection)
18287 return; // dragging
18288
18289 if (!isMultiSelect) {
18290 var range = selection.toOrientedRange();
18291 editor.addSelectionMarker(range);
18292 }
18293
18294 var oldRange = selection.rangeList.rangeAtPoint(pos);
18295
18296
18297 editor.$blockScrolling++;
18298 editor.inVirtualSelectionMode = true;
18299
18300 if (shift) {
18301 oldRange = null;
18302 range = selection.ranges[0] || range;
18303 editor.removeSelectionMarker(range);
18304 }
18305 editor.once("mouseup", function() {
18306 var tmpSel = selection.toOrientedRange();
18307
18308 if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
18309 selection.substractPoint(tmpSel.cursor);
18310 else {
18311 if (shift) {
18312 selection.substractPoint(range.cursor);
18313 } else if (range) {
18314 editor.removeSelectionMarker(range);
18315 selection.addRange(range);
18316 }
18317 selection.addRange(tmpSel);
18318 }
18319 editor.$blockScrolling--;
18320 editor.inVirtualSelectionMode = false;
18321 });
18322
18323 } else if (selectionMode == "block") {
18324 e.stop();
18325 editor.inVirtualSelectionMode = true;
18326 var initialRange;
18327 var rectSel = [];
18328 var blockSelect = function() {
18329 var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
18330 var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column, newCursor.offsetX);
18331
18332 if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead))
18333 return;
18334 screenCursor = newCursor;
18335
18336 editor.$blockScrolling++;
18337 editor.selection.moveToPosition(cursor);
18338 editor.renderer.scrollCursorIntoView();
18339
18340 editor.removeSelectionMarkers(rectSel);
18341 rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
18342 if (editor.$mouseHandler.$clickSelection && rectSel.length == 1 && rectSel[0].isEmpty())
18343 rectSel[0] = editor.$mouseHandler.$clickSelection.clone();
18344 rectSel.forEach(editor.addSelectionMarker, editor);
18345 editor.updateSelectionMarkers();
18346 editor.$blockScrolling--;
18347 };
18348 editor.$blockScrolling++;
18349 if (isMultiSelect && !accel) {
18350 selection.toSingleRange();
18351 } else if (!isMultiSelect && accel) {
18352 initialRange = selection.toOrientedRange();
18353 editor.addSelectionMarker(initialRange);
18354 }
18355
18356 if (shift)
18357 screenAnchor = session.documentToScreenPosition(selection.lead);
18358 else
18359 selection.moveToPosition(pos);
18360 editor.$blockScrolling--;
18361
18362 screenCursor = {row: -1, column: -1};
18363
18364 var onMouseSelectionEnd = function(e) {
18365 clearInterval(timerId);
18366 editor.removeSelectionMarkers(rectSel);
18367 if (!rectSel.length)
18368 rectSel = [selection.toOrientedRange()];
18369 editor.$blockScrolling++;
18370 if (initialRange) {
18371 editor.removeSelectionMarker(initialRange);
18372 selection.toSingleRange(initialRange);
18373 }
18374 for (var i = 0; i < rectSel.length; i++)
18375 selection.addRange(rectSel[i]);
18376 editor.inVirtualSelectionMode = false;
18377 editor.$mouseHandler.$clickSelection = null;
18378 editor.$blockScrolling--;
18379 };
18380
18381 var onSelectionInterval = blockSelect;
18382
18383 event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
18384 var timerId = setInterval(function() {onSelectionInterval();}, 20);
18385
18386 return e.preventDefault();
18387 }
18388 }
18389
18390
18391 exports.onMouseDown = onMouseDown;
18392
18393 });
18394
18395 ace.define("ace/commands/multi_select_commands",["require","exports","module","ace/keyboard/hash_handler"], function(acequire, exports, module) {
18396 exports.defaultCommands = [{
18397 name: "addCursorAbove",
18398 exec: function(editor) { editor.selectMoreLines(-1); },
18399 bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
18400 scrollIntoView: "cursor",
18401 readOnly: true
18402 }, {
18403 name: "addCursorBelow",
18404 exec: function(editor) { editor.selectMoreLines(1); },
18405 bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
18406 scrollIntoView: "cursor",
18407 readOnly: true
18408 }, {
18409 name: "addCursorAboveSkipCurrent",
18410 exec: function(editor) { editor.selectMoreLines(-1, true); },
18411 bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
18412 scrollIntoView: "cursor",
18413 readOnly: true
18414 }, {
18415 name: "addCursorBelowSkipCurrent",
18416 exec: function(editor) { editor.selectMoreLines(1, true); },
18417 bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
18418 scrollIntoView: "cursor",
18419 readOnly: true
18420 }, {
18421 name: "selectMoreBefore",
18422 exec: function(editor) { editor.selectMore(-1); },
18423 bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
18424 scrollIntoView: "cursor",
18425 readOnly: true
18426 }, {
18427 name: "selectMoreAfter",
18428 exec: function(editor) { editor.selectMore(1); },
18429 bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
18430 scrollIntoView: "cursor",
18431 readOnly: true
18432 }, {
18433 name: "selectNextBefore",
18434 exec: function(editor) { editor.selectMore(-1, true); },
18435 bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
18436 scrollIntoView: "cursor",
18437 readOnly: true
18438 }, {
18439 name: "selectNextAfter",
18440 exec: function(editor) { editor.selectMore(1, true); },
18441 bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
18442 scrollIntoView: "cursor",
18443 readOnly: true
18444 }, {
18445 name: "splitIntoLines",
18446 exec: function(editor) { editor.multiSelect.splitIntoLines(); },
18447 bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"},
18448 readOnly: true
18449 }, {
18450 name: "alignCursors",
18451 exec: function(editor) { editor.alignCursors(); },
18452 bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"},
18453 scrollIntoView: "cursor"
18454 }, {
18455 name: "findAll",
18456 exec: function(editor) { editor.findAll(); },
18457 bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
18458 scrollIntoView: "cursor",
18459 readOnly: true
18460 }];
18461 exports.multiSelectCommands = [{
18462 name: "singleSelection",
18463 bindKey: "esc",
18464 exec: function(editor) { editor.exitMultiSelectMode(); },
18465 scrollIntoView: "cursor",
18466 readOnly: true,
18467 isAvailable: function(editor) {return editor && editor.inMultiSelectMode;}
18468 }];
18469
18470 var HashHandler = acequire("../keyboard/hash_handler").HashHandler;
18471 exports.keyboardHandler = new HashHandler(exports.multiSelectCommands);
18472
18473 });
18474
18475 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(acequire, exports, module) {
18476
18477 var RangeList = acequire("./range_list").RangeList;
18478 var Range = acequire("./range").Range;
18479 var Selection = acequire("./selection").Selection;
18480 var onMouseDown = acequire("./mouse/multi_select_handler").onMouseDown;
18481 var event = acequire("./lib/event");
18482 var lang = acequire("./lib/lang");
18483 var commands = acequire("./commands/multi_select_commands");
18484 exports.commands = commands.defaultCommands.concat(commands.multiSelectCommands);
18485 var Search = acequire("./search").Search;
18486 var search = new Search();
18487
18488 function find(session, needle, dir) {
18489 search.$options.wrap = true;
18490 search.$options.needle = needle;
18491 search.$options.backwards = dir == -1;
18492 return search.find(session);
18493 }
18494 var EditSession = acequire("./edit_session").EditSession;
18495 (function() {
18496 this.getSelectionMarkers = function() {
18497 return this.$selectionMarkers;
18498 };
18499 }).call(EditSession.prototype);
18500 (function() {
18501 this.ranges = null;
18502 this.rangeList = null;
18503 this.addRange = function(range, $blockChangeEvents) {
18504 if (!range)
18505 return;
18506
18507 if (!this.inMultiSelectMode && this.rangeCount === 0) {
18508 var oldRange = this.toOrientedRange();
18509 this.rangeList.add(oldRange);
18510 this.rangeList.add(range);
18511 if (this.rangeList.ranges.length != 2) {
18512 this.rangeList.removeAll();
18513 return $blockChangeEvents || this.fromOrientedRange(range);
18514 }
18515 this.rangeList.removeAll();
18516 this.rangeList.add(oldRange);
18517 this.$onAddRange(oldRange);
18518 }
18519
18520 if (!range.cursor)
18521 range.cursor = range.end;
18522
18523 var removed = this.rangeList.add(range);
18524
18525 this.$onAddRange(range);
18526
18527 if (removed.length)
18528 this.$onRemoveRange(removed);
18529
18530 if (this.rangeCount > 1 && !this.inMultiSelectMode) {
18531 this._signal("multiSelect");
18532 this.inMultiSelectMode = true;
18533 this.session.$undoSelect = false;
18534 this.rangeList.attach(this.session);
18535 }
18536
18537 return $blockChangeEvents || this.fromOrientedRange(range);
18538 };
18539
18540 this.toSingleRange = function(range) {
18541 range = range || this.ranges[0];
18542 var removed = this.rangeList.removeAll();
18543 if (removed.length)
18544 this.$onRemoveRange(removed);
18545
18546 range && this.fromOrientedRange(range);
18547 };
18548 this.substractPoint = function(pos) {
18549 var removed = this.rangeList.substractPoint(pos);
18550 if (removed) {
18551 this.$onRemoveRange(removed);
18552 return removed[0];
18553 }
18554 };
18555 this.mergeOverlappingRanges = function() {
18556 var removed = this.rangeList.merge();
18557 if (removed.length)
18558 this.$onRemoveRange(removed);
18559 else if(this.ranges[0])
18560 this.fromOrientedRange(this.ranges[0]);
18561 };
18562
18563 this.$onAddRange = function(range) {
18564 this.rangeCount = this.rangeList.ranges.length;
18565 this.ranges.unshift(range);
18566 this._signal("addRange", {range: range});
18567 };
18568
18569 this.$onRemoveRange = function(removed) {
18570 this.rangeCount = this.rangeList.ranges.length;
18571 if (this.rangeCount == 1 && this.inMultiSelectMode) {
18572 var lastRange = this.rangeList.ranges.pop();
18573 removed.push(lastRange);
18574 this.rangeCount = 0;
18575 }
18576
18577 for (var i = removed.length; i--; ) {
18578 var index = this.ranges.indexOf(removed[i]);
18579 this.ranges.splice(index, 1);
18580 }
18581
18582 this._signal("removeRange", {ranges: removed});
18583
18584 if (this.rangeCount === 0 && this.inMultiSelectMode) {
18585 this.inMultiSelectMode = false;
18586 this._signal("singleSelect");
18587 this.session.$undoSelect = true;
18588 this.rangeList.detach(this.session);
18589 }
18590
18591 lastRange = lastRange || this.ranges[0];
18592 if (lastRange && !lastRange.isEqual(this.getRange()))
18593 this.fromOrientedRange(lastRange);
18594 };
18595 this.$initRangeList = function() {
18596 if (this.rangeList)
18597 return;
18598
18599 this.rangeList = new RangeList();
18600 this.ranges = [];
18601 this.rangeCount = 0;
18602 };
18603 this.getAllRanges = function() {
18604 return this.rangeCount ? this.rangeList.ranges.concat() : [this.getRange()];
18605 };
18606
18607 this.splitIntoLines = function () {
18608 if (this.rangeCount > 1) {
18609 var ranges = this.rangeList.ranges;
18610 var lastRange = ranges[ranges.length - 1];
18611 var range = Range.fromPoints(ranges[0].start, lastRange.end);
18612
18613 this.toSingleRange();
18614 this.setSelectionRange(range, lastRange.cursor == lastRange.start);
18615 } else {
18616 var range = this.getRange();
18617 var isBackwards = this.isBackwards();
18618 var startRow = range.start.row;
18619 var endRow = range.end.row;
18620 if (startRow == endRow) {
18621 if (isBackwards)
18622 var start = range.end, end = range.start;
18623 else
18624 var start = range.start, end = range.end;
18625
18626 this.addRange(Range.fromPoints(end, end));
18627 this.addRange(Range.fromPoints(start, start));
18628 return;
18629 }
18630
18631 var rectSel = [];
18632 var r = this.getLineRange(startRow, true);
18633 r.start.column = range.start.column;
18634 rectSel.push(r);
18635
18636 for (var i = startRow + 1; i < endRow; i++)
18637 rectSel.push(this.getLineRange(i, true));
18638
18639 r = this.getLineRange(endRow, true);
18640 r.end.column = range.end.column;
18641 rectSel.push(r);
18642
18643 rectSel.forEach(this.addRange, this);
18644 }
18645 };
18646 this.toggleBlockSelection = function () {
18647 if (this.rangeCount > 1) {
18648 var ranges = this.rangeList.ranges;
18649 var lastRange = ranges[ranges.length - 1];
18650 var range = Range.fromPoints(ranges[0].start, lastRange.end);
18651
18652 this.toSingleRange();
18653 this.setSelectionRange(range, lastRange.cursor == lastRange.start);
18654 } else {
18655 var cursor = this.session.documentToScreenPosition(this.selectionLead);
18656 var anchor = this.session.documentToScreenPosition(this.selectionAnchor);
18657
18658 var rectSel = this.rectangularRangeBlock(cursor, anchor);
18659 rectSel.forEach(this.addRange, this);
18660 }
18661 };
18662 this.rectangularRangeBlock = function(screenCursor, screenAnchor, includeEmptyLines) {
18663 var rectSel = [];
18664
18665 var xBackwards = screenCursor.column < screenAnchor.column;
18666 if (xBackwards) {
18667 var startColumn = screenCursor.column;
18668 var endColumn = screenAnchor.column;
18669 var startOffsetX = screenCursor.offsetX;
18670 var endOffsetX = screenAnchor.offsetX;
18671 } else {
18672 var startColumn = screenAnchor.column;
18673 var endColumn = screenCursor.column;
18674 var startOffsetX = screenAnchor.offsetX;
18675 var endOffsetX = screenCursor.offsetX;
18676 }
18677
18678 var yBackwards = screenCursor.row < screenAnchor.row;
18679 if (yBackwards) {
18680 var startRow = screenCursor.row;
18681 var endRow = screenAnchor.row;
18682 } else {
18683 var startRow = screenAnchor.row;
18684 var endRow = screenCursor.row;
18685 }
18686
18687 if (startColumn < 0)
18688 startColumn = 0;
18689 if (startRow < 0)
18690 startRow = 0;
18691
18692 if (startRow == endRow)
18693 includeEmptyLines = true;
18694
18695 for (var row = startRow; row <= endRow; row++) {
18696 var range = Range.fromPoints(
18697 this.session.screenToDocumentPosition(row, startColumn, startOffsetX),
18698 this.session.screenToDocumentPosition(row, endColumn, endOffsetX)
18699 );
18700 if (range.isEmpty()) {
18701 if (docEnd && isSamePoint(range.end, docEnd))
18702 break;
18703 var docEnd = range.end;
18704 }
18705 range.cursor = xBackwards ? range.start : range.end;
18706 rectSel.push(range);
18707 }
18708
18709 if (yBackwards)
18710 rectSel.reverse();
18711
18712 if (!includeEmptyLines) {
18713 var end = rectSel.length - 1;
18714 while (rectSel[end].isEmpty() && end > 0)
18715 end--;
18716 if (end > 0) {
18717 var start = 0;
18718 while (rectSel[start].isEmpty())
18719 start++;
18720 }
18721 for (var i = end; i >= start; i--) {
18722 if (rectSel[i].isEmpty())
18723 rectSel.splice(i, 1);
18724 }
18725 }
18726
18727 return rectSel;
18728 };
18729 }).call(Selection.prototype);
18730 var Editor = acequire("./editor").Editor;
18731 (function() {
18732 this.updateSelectionMarkers = function() {
18733 this.renderer.updateCursor();
18734 this.renderer.updateBackMarkers();
18735 };
18736 this.addSelectionMarker = function(orientedRange) {
18737 if (!orientedRange.cursor)
18738 orientedRange.cursor = orientedRange.end;
18739
18740 var style = this.getSelectionStyle();
18741 orientedRange.marker = this.session.addMarker(orientedRange, "ace_selection", style);
18742
18743 this.session.$selectionMarkers.push(orientedRange);
18744 this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
18745 return orientedRange;
18746 };
18747 this.removeSelectionMarker = function(range) {
18748 if (!range.marker)
18749 return;
18750 this.session.removeMarker(range.marker);
18751 var index = this.session.$selectionMarkers.indexOf(range);
18752 if (index != -1)
18753 this.session.$selectionMarkers.splice(index, 1);
18754 this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
18755 };
18756
18757 this.removeSelectionMarkers = function(ranges) {
18758 var markerList = this.session.$selectionMarkers;
18759 for (var i = ranges.length; i--; ) {
18760 var range = ranges[i];
18761 if (!range.marker)
18762 continue;
18763 this.session.removeMarker(range.marker);
18764 var index = markerList.indexOf(range);
18765 if (index != -1)
18766 markerList.splice(index, 1);
18767 }
18768 this.session.selectionMarkerCount = markerList.length;
18769 };
18770
18771 this.$onAddRange = function(e) {
18772 this.addSelectionMarker(e.range);
18773 this.renderer.updateCursor();
18774 this.renderer.updateBackMarkers();
18775 };
18776
18777 this.$onRemoveRange = function(e) {
18778 this.removeSelectionMarkers(e.ranges);
18779 this.renderer.updateCursor();
18780 this.renderer.updateBackMarkers();
18781 };
18782
18783 this.$onMultiSelect = function(e) {
18784 if (this.inMultiSelectMode)
18785 return;
18786 this.inMultiSelectMode = true;
18787
18788 this.setStyle("ace_multiselect");
18789 this.keyBinding.addKeyboardHandler(commands.keyboardHandler);
18790 this.commands.setDefaultHandler("exec", this.$onMultiSelectExec);
18791
18792 this.renderer.updateCursor();
18793 this.renderer.updateBackMarkers();
18794 };
18795
18796 this.$onSingleSelect = function(e) {
18797 if (this.session.multiSelect.inVirtualMode)
18798 return;
18799 this.inMultiSelectMode = false;
18800
18801 this.unsetStyle("ace_multiselect");
18802 this.keyBinding.removeKeyboardHandler(commands.keyboardHandler);
18803
18804 this.commands.removeDefaultHandler("exec", this.$onMultiSelectExec);
18805 this.renderer.updateCursor();
18806 this.renderer.updateBackMarkers();
18807 this._emit("changeSelection");
18808 };
18809
18810 this.$onMultiSelectExec = function(e) {
18811 var command = e.command;
18812 var editor = e.editor;
18813 if (!editor.multiSelect)
18814 return;
18815 if (!command.multiSelectAction) {
18816 var result = command.exec(editor, e.args || {});
18817 editor.multiSelect.addRange(editor.multiSelect.toOrientedRange());
18818 editor.multiSelect.mergeOverlappingRanges();
18819 } else if (command.multiSelectAction == "forEach") {
18820 result = editor.forEachSelection(command, e.args);
18821 } else if (command.multiSelectAction == "forEachLine") {
18822 result = editor.forEachSelection(command, e.args, true);
18823 } else if (command.multiSelectAction == "single") {
18824 editor.exitMultiSelectMode();
18825 result = command.exec(editor, e.args || {});
18826 } else {
18827 result = command.multiSelectAction(editor, e.args || {});
18828 }
18829 return result;
18830 };
18831 this.forEachSelection = function(cmd, args, options) {
18832 if (this.inVirtualSelectionMode)
18833 return;
18834 var keepOrder = options && options.keepOrder;
18835 var $byLines = options == true || options && options.$byLines;
18836 var session = this.session;
18837 var selection = this.selection;
18838 var rangeList = selection.rangeList;
18839 var ranges = (keepOrder ? selection : rangeList).ranges;
18840 var result;
18841
18842 if (!ranges.length)
18843 return cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
18844
18845 var reg = selection._eventRegistry;
18846 selection._eventRegistry = {};
18847
18848 var tmpSel = new Selection(session);
18849 this.inVirtualSelectionMode = true;
18850 for (var i = ranges.length; i--;) {
18851 if ($byLines) {
18852 while (i > 0 && ranges[i].start.row == ranges[i - 1].end.row)
18853 i--;
18854 }
18855 tmpSel.fromOrientedRange(ranges[i]);
18856 tmpSel.index = i;
18857 this.selection = session.selection = tmpSel;
18858 var cmdResult = cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
18859 if (!result && cmdResult !== undefined)
18860 result = cmdResult;
18861 tmpSel.toOrientedRange(ranges[i]);
18862 }
18863 tmpSel.detach();
18864
18865 this.selection = session.selection = selection;
18866 this.inVirtualSelectionMode = false;
18867 selection._eventRegistry = reg;
18868 selection.mergeOverlappingRanges();
18869
18870 var anim = this.renderer.$scrollAnimation;
18871 this.onCursorChange();
18872 this.onSelectionChange();
18873 if (anim && anim.from == anim.to)
18874 this.renderer.animateScrolling(anim.from);
18875
18876 return result;
18877 };
18878 this.exitMultiSelectMode = function() {
18879 if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
18880 return;
18881 this.multiSelect.toSingleRange();
18882 };
18883
18884 this.getSelectedText = function() {
18885 var text = "";
18886 if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
18887 var ranges = this.multiSelect.rangeList.ranges;
18888 var buf = [];
18889 for (var i = 0; i < ranges.length; i++) {
18890 buf.push(this.session.getTextRange(ranges[i]));
18891 }
18892 var nl = this.session.getDocument().getNewLineCharacter();
18893 text = buf.join(nl);
18894 if (text.length == (buf.length - 1) * nl.length)
18895 text = "";
18896 } else if (!this.selection.isEmpty()) {
18897 text = this.session.getTextRange(this.getSelectionRange());
18898 }
18899 return text;
18900 };
18901
18902 this.$checkMultiselectChange = function(e, anchor) {
18903 if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
18904 var range = this.multiSelect.ranges[0];
18905 if (this.multiSelect.isEmpty() && anchor == this.multiSelect.anchor)
18906 return;
18907 var pos = anchor == this.multiSelect.anchor
18908 ? range.cursor == range.start ? range.end : range.start
18909 : range.cursor;
18910 if (pos.row != anchor.row
18911 || this.session.$clipPositionToDocument(pos.row, pos.column).column != anchor.column)
18912 this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange());
18913 }
18914 };
18915 this.findAll = function(needle, options, additive) {
18916 options = options || {};
18917 options.needle = needle || options.needle;
18918 if (options.needle == undefined) {
18919 var range = this.selection.isEmpty()
18920 ? this.selection.getWordRange()
18921 : this.selection.getRange();
18922 options.needle = this.session.getTextRange(range);
18923 }
18924 this.$search.set(options);
18925
18926 var ranges = this.$search.findAll(this.session);
18927 if (!ranges.length)
18928 return 0;
18929
18930 this.$blockScrolling += 1;
18931 var selection = this.multiSelect;
18932
18933 if (!additive)
18934 selection.toSingleRange(ranges[0]);
18935
18936 for (var i = ranges.length; i--; )
18937 selection.addRange(ranges[i], true);
18938 if (range && selection.rangeList.rangeAtPoint(range.start))
18939 selection.addRange(range, true);
18940
18941 this.$blockScrolling -= 1;
18942
18943 return ranges.length;
18944 };
18945 this.selectMoreLines = function(dir, skip) {
18946 var range = this.selection.toOrientedRange();
18947 var isBackwards = range.cursor == range.end;
18948
18949 var screenLead = this.session.documentToScreenPosition(range.cursor);
18950 if (this.selection.$desiredColumn)
18951 screenLead.column = this.selection.$desiredColumn;
18952
18953 var lead = this.session.screenToDocumentPosition(screenLead.row + dir, screenLead.column);
18954
18955 if (!range.isEmpty()) {
18956 var screenAnchor = this.session.documentToScreenPosition(isBackwards ? range.end : range.start);
18957 var anchor = this.session.screenToDocumentPosition(screenAnchor.row + dir, screenAnchor.column);
18958 } else {
18959 var anchor = lead;
18960 }
18961
18962 if (isBackwards) {
18963 var newRange = Range.fromPoints(lead, anchor);
18964 newRange.cursor = newRange.start;
18965 } else {
18966 var newRange = Range.fromPoints(anchor, lead);
18967 newRange.cursor = newRange.end;
18968 }
18969
18970 newRange.desiredColumn = screenLead.column;
18971 if (!this.selection.inMultiSelectMode) {
18972 this.selection.addRange(range);
18973 } else {
18974 if (skip)
18975 var toRemove = range.cursor;
18976 }
18977
18978 this.selection.addRange(newRange);
18979 if (toRemove)
18980 this.selection.substractPoint(toRemove);
18981 };
18982 this.transposeSelections = function(dir) {
18983 var session = this.session;
18984 var sel = session.multiSelect;
18985 var all = sel.ranges;
18986
18987 for (var i = all.length; i--; ) {
18988 var range = all[i];
18989 if (range.isEmpty()) {
18990 var tmp = session.getWordRange(range.start.row, range.start.column);
18991 range.start.row = tmp.start.row;
18992 range.start.column = tmp.start.column;
18993 range.end.row = tmp.end.row;
18994 range.end.column = tmp.end.column;
18995 }
18996 }
18997 sel.mergeOverlappingRanges();
18998
18999 var words = [];
19000 for (var i = all.length; i--; ) {
19001 var range = all[i];
19002 words.unshift(session.getTextRange(range));
19003 }
19004
19005 if (dir < 0)
19006 words.unshift(words.pop());
19007 else
19008 words.push(words.shift());
19009
19010 for (var i = all.length; i--; ) {
19011 var range = all[i];
19012 var tmp = range.clone();
19013 session.replace(range, words[i]);
19014 range.start.row = tmp.start.row;
19015 range.start.column = tmp.start.column;
19016 }
19017 };
19018 this.selectMore = function(dir, skip, stopAtFirst) {
19019 var session = this.session;
19020 var sel = session.multiSelect;
19021
19022 var range = sel.toOrientedRange();
19023 if (range.isEmpty()) {
19024 range = session.getWordRange(range.start.row, range.start.column);
19025 range.cursor = dir == -1 ? range.start : range.end;
19026 this.multiSelect.addRange(range);
19027 if (stopAtFirst)
19028 return;
19029 }
19030 var needle = session.getTextRange(range);
19031
19032 var newRange = find(session, needle, dir);
19033 if (newRange) {
19034 newRange.cursor = dir == -1 ? newRange.start : newRange.end;
19035 this.$blockScrolling += 1;
19036 this.session.unfold(newRange);
19037 this.multiSelect.addRange(newRange);
19038 this.$blockScrolling -= 1;
19039 this.renderer.scrollCursorIntoView(null, 0.5);
19040 }
19041 if (skip)
19042 this.multiSelect.substractPoint(range.cursor);
19043 };
19044 this.alignCursors = function() {
19045 var session = this.session;
19046 var sel = session.multiSelect;
19047 var ranges = sel.ranges;
19048 var row = -1;
19049 var sameRowRanges = ranges.filter(function(r) {
19050 if (r.cursor.row == row)
19051 return true;
19052 row = r.cursor.row;
19053 });
19054
19055 if (!ranges.length || sameRowRanges.length == ranges.length - 1) {
19056 var range = this.selection.getRange();
19057 var fr = range.start.row, lr = range.end.row;
19058 var guessRange = fr == lr;
19059 if (guessRange) {
19060 var max = this.session.getLength();
19061 var line;
19062 do {
19063 line = this.session.getLine(lr);
19064 } while (/[=:]/.test(line) && ++lr < max);
19065 do {
19066 line = this.session.getLine(fr);
19067 } while (/[=:]/.test(line) && --fr > 0);
19068
19069 if (fr < 0) fr = 0;
19070 if (lr >= max) lr = max - 1;
19071 }
19072 var lines = this.session.removeFullLines(fr, lr);
19073 lines = this.$reAlignText(lines, guessRange);
19074 this.session.insert({row: fr, column: 0}, lines.join("\n") + "\n");
19075 if (!guessRange) {
19076 range.start.column = 0;
19077 range.end.column = lines[lines.length - 1].length;
19078 }
19079 this.selection.setRange(range);
19080 } else {
19081 sameRowRanges.forEach(function(r) {
19082 sel.substractPoint(r.cursor);
19083 });
19084
19085 var maxCol = 0;
19086 var minSpace = Infinity;
19087 var spaceOffsets = ranges.map(function(r) {
19088 var p = r.cursor;
19089 var line = session.getLine(p.row);
19090 var spaceOffset = line.substr(p.column).search(/\S/g);
19091 if (spaceOffset == -1)
19092 spaceOffset = 0;
19093
19094 if (p.column > maxCol)
19095 maxCol = p.column;
19096 if (spaceOffset < minSpace)
19097 minSpace = spaceOffset;
19098 return spaceOffset;
19099 });
19100 ranges.forEach(function(r, i) {
19101 var p = r.cursor;
19102 var l = maxCol - p.column;
19103 var d = spaceOffsets[i] - minSpace;
19104 if (l > d)
19105 session.insert(p, lang.stringRepeat(" ", l - d));
19106 else
19107 session.remove(new Range(p.row, p.column, p.row, p.column - l + d));
19108
19109 r.start.column = r.end.column = maxCol;
19110 r.start.row = r.end.row = p.row;
19111 r.cursor = r.end;
19112 });
19113 sel.fromOrientedRange(ranges[0]);
19114 this.renderer.updateCursor();
19115 this.renderer.updateBackMarkers();
19116 }
19117 };
19118
19119 this.$reAlignText = function(lines, forceLeft) {
19120 var isLeftAligned = true, isRightAligned = true;
19121 var startW, textW, endW;
19122
19123 return lines.map(function(line) {
19124 var m = line.match(/(\s*)(.*?)(\s*)([=:].*)/);
19125 if (!m)
19126 return [line];
19127
19128 if (startW == null) {
19129 startW = m[1].length;
19130 textW = m[2].length;
19131 endW = m[3].length;
19132 return m;
19133 }
19134
19135 if (startW + textW + endW != m[1].length + m[2].length + m[3].length)
19136 isRightAligned = false;
19137 if (startW != m[1].length)
19138 isLeftAligned = false;
19139
19140 if (startW > m[1].length)
19141 startW = m[1].length;
19142 if (textW < m[2].length)
19143 textW = m[2].length;
19144 if (endW > m[3].length)
19145 endW = m[3].length;
19146
19147 return m;
19148 }).map(forceLeft ? alignLeft :
19149 isLeftAligned ? isRightAligned ? alignRight : alignLeft : unAlign);
19150
19151 function spaces(n) {
19152 return lang.stringRepeat(" ", n);
19153 }
19154
19155 function alignLeft(m) {
19156 return !m[2] ? m[0] : spaces(startW) + m[2]
19157 + spaces(textW - m[2].length + endW)
19158 + m[4].replace(/^([=:])\s+/, "$1 ");
19159 }
19160 function alignRight(m) {
19161 return !m[2] ? m[0] : spaces(startW + textW - m[2].length) + m[2]
19162 + spaces(endW)
19163 + m[4].replace(/^([=:])\s+/, "$1 ");
19164 }
19165 function unAlign(m) {
19166 return !m[2] ? m[0] : spaces(startW) + m[2]
19167 + spaces(endW)
19168 + m[4].replace(/^([=:])\s+/, "$1 ");
19169 }
19170 };
19171 }).call(Editor.prototype);
19172
19173
19174 function isSamePoint(p1, p2) {
19175 return p1.row == p2.row && p1.column == p2.column;
19176 }
19177 exports.onSessionChange = function(e) {
19178 var session = e.session;
19179 if (session && !session.multiSelect) {
19180 session.$selectionMarkers = [];
19181 session.selection.$initRangeList();
19182 session.multiSelect = session.selection;
19183 }
19184 this.multiSelect = session && session.multiSelect;
19185
19186 var oldSession = e.oldSession;
19187 if (oldSession) {
19188 oldSession.multiSelect.off("addRange", this.$onAddRange);
19189 oldSession.multiSelect.off("removeRange", this.$onRemoveRange);
19190 oldSession.multiSelect.off("multiSelect", this.$onMultiSelect);
19191 oldSession.multiSelect.off("singleSelect", this.$onSingleSelect);
19192 oldSession.multiSelect.lead.off("change", this.$checkMultiselectChange);
19193 oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
19194 }
19195
19196 if (session) {
19197 session.multiSelect.on("addRange", this.$onAddRange);
19198 session.multiSelect.on("removeRange", this.$onRemoveRange);
19199 session.multiSelect.on("multiSelect", this.$onMultiSelect);
19200 session.multiSelect.on("singleSelect", this.$onSingleSelect);
19201 session.multiSelect.lead.on("change", this.$checkMultiselectChange);
19202 session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
19203 }
19204
19205 if (session && this.inMultiSelectMode != session.selection.inMultiSelectMode) {
19206 if (session.selection.inMultiSelectMode)
19207 this.$onMultiSelect();
19208 else
19209 this.$onSingleSelect();
19210 }
19211 };
19212 function MultiSelect(editor) {
19213 if (editor.$multiselectOnSessionChange)
19214 return;
19215 editor.$onAddRange = editor.$onAddRange.bind(editor);
19216 editor.$onRemoveRange = editor.$onRemoveRange.bind(editor);
19217 editor.$onMultiSelect = editor.$onMultiSelect.bind(editor);
19218 editor.$onSingleSelect = editor.$onSingleSelect.bind(editor);
19219 editor.$multiselectOnSessionChange = exports.onSessionChange.bind(editor);
19220 editor.$checkMultiselectChange = editor.$checkMultiselectChange.bind(editor);
19221
19222 editor.$multiselectOnSessionChange(editor);
19223 editor.on("changeSession", editor.$multiselectOnSessionChange);
19224
19225 editor.on("mousedown", onMouseDown);
19226 editor.commands.addCommands(commands.defaultCommands);
19227
19228 addAltCursorListeners(editor);
19229 }
19230
19231 function addAltCursorListeners(editor){
19232 var el = editor.textInput.getElement();
19233 var altCursor = false;
19234 event.addListener(el, "keydown", function(e) {
19235 var altDown = e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey);
19236 if (editor.$blockSelectEnabled && altDown) {
19237 if (!altCursor) {
19238 editor.renderer.setMouseCursor("crosshair");
19239 altCursor = true;
19240 }
19241 } else if (altCursor) {
19242 reset();
19243 }
19244 });
19245
19246 event.addListener(el, "keyup", reset);
19247 event.addListener(el, "blur", reset);
19248 function reset(e) {
19249 if (altCursor) {
19250 editor.renderer.setMouseCursor("");
19251 altCursor = false;
19252 }
19253 }
19254 }
19255
19256 exports.MultiSelect = MultiSelect;
19257
19258
19259 acequire("./config").defineOptions(Editor.prototype, "editor", {
19260 enableMultiselect: {
19261 set: function(val) {
19262 MultiSelect(this);
19263 if (val) {
19264 this.on("changeSession", this.$multiselectOnSessionChange);
19265 this.on("mousedown", onMouseDown);
19266 } else {
19267 this.off("changeSession", this.$multiselectOnSessionChange);
19268 this.off("mousedown", onMouseDown);
19269 }
19270 },
19271 value: true
19272 },
19273 enableBlockSelect: {
19274 set: function(val) {
19275 this.$blockSelectEnabled = val;
19276 },
19277 value: true
19278 }
19279 });
19280
19281
19282
19283 });
19284
19285 ace.define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"], function(acequire, exports, module) {
19286
19287 var Range = acequire("../../range").Range;
19288
19289 var FoldMode = exports.FoldMode = function() {};
19290
19291 (function() {
19292
19293 this.foldingStartMarker = null;
19294 this.foldingStopMarker = null;
19295 this.getFoldWidget = function(session, foldStyle, row) {
19296 var line = session.getLine(row);
19297 if (this.foldingStartMarker.test(line))
19298 return "start";
19299 if (foldStyle == "markbeginend"
19300 && this.foldingStopMarker
19301 && this.foldingStopMarker.test(line))
19302 return "end";
19303 return "";
19304 };
19305
19306 this.getFoldWidgetRange = function(session, foldStyle, row) {
19307 return null;
19308 };
19309
19310 this.indentationBlock = function(session, row, column) {
19311 var re = /\S/;
19312 var line = session.getLine(row);
19313 var startLevel = line.search(re);
19314 if (startLevel == -1)
19315 return;
19316
19317 var startColumn = column || line.length;
19318 var maxRow = session.getLength();
19319 var startRow = row;
19320 var endRow = row;
19321
19322 while (++row < maxRow) {
19323 var level = session.getLine(row).search(re);
19324
19325 if (level == -1)
19326 continue;
19327
19328 if (level <= startLevel)
19329 break;
19330
19331 endRow = row;
19332 }
19333
19334 if (endRow > startRow) {
19335 var endColumn = session.getLine(endRow).length;
19336 return new Range(startRow, startColumn, endRow, endColumn);
19337 }
19338 };
19339
19340 this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
19341 var start = {row: row, column: column + 1};
19342 var end = session.$findClosingBracket(bracket, start, typeRe);
19343 if (!end)
19344 return;
19345
19346 var fw = session.foldWidgets[end.row];
19347 if (fw == null)
19348 fw = session.getFoldWidget(end.row);
19349
19350 if (fw == "start" && end.row > start.row) {
19351 end.row --;
19352 end.column = session.getLine(end.row).length;
19353 }
19354 return Range.fromPoints(start, end);
19355 };
19356
19357 this.closingBracketBlock = function(session, bracket, row, column, typeRe) {
19358 var end = {row: row, column: column};
19359 var start = session.$findOpeningBracket(bracket, end);
19360
19361 if (!start)
19362 return;
19363
19364 start.column++;
19365 end.column--;
19366
19367 return Range.fromPoints(start, end);
19368 };
19369 }).call(FoldMode.prototype);
19370
19371 });
19372
19373 ace.define("ace/theme/textmate",["require","exports","module","ace/lib/dom"], function(acequire, exports, module) {
19374
19375 exports.isDark = false;
19376 exports.cssClass = "ace-tm";
19377 exports.cssText = ".ace-tm .ace_gutter {\
19378background: #f0f0f0;\
19379color: #333;\
19380}\
19381.ace-tm .ace_print-margin {\
19382width: 1px;\
19383background: #e8e8e8;\
19384}\
19385.ace-tm .ace_fold {\
19386background-color: #6B72E6;\
19387}\
19388.ace-tm {\
19389background-color: #FFFFFF;\
19390color: black;\
19391}\
19392.ace-tm .ace_cursor {\
19393color: black;\
19394}\
19395.ace-tm .ace_invisible {\
19396color: rgb(191, 191, 191);\
19397}\
19398.ace-tm .ace_storage,\
19399.ace-tm .ace_keyword {\
19400color: blue;\
19401}\
19402.ace-tm .ace_constant {\
19403color: rgb(197, 6, 11);\
19404}\
19405.ace-tm .ace_constant.ace_buildin {\
19406color: rgb(88, 72, 246);\
19407}\
19408.ace-tm .ace_constant.ace_language {\
19409color: rgb(88, 92, 246);\
19410}\
19411.ace-tm .ace_constant.ace_library {\
19412color: rgb(6, 150, 14);\
19413}\
19414.ace-tm .ace_invalid {\
19415background-color: rgba(255, 0, 0, 0.1);\
19416color: red;\
19417}\
19418.ace-tm .ace_support.ace_function {\
19419color: rgb(60, 76, 114);\
19420}\
19421.ace-tm .ace_support.ace_constant {\
19422color: rgb(6, 150, 14);\
19423}\
19424.ace-tm .ace_support.ace_type,\
19425.ace-tm .ace_support.ace_class {\
19426color: rgb(109, 121, 222);\
19427}\
19428.ace-tm .ace_keyword.ace_operator {\
19429color: rgb(104, 118, 135);\
19430}\
19431.ace-tm .ace_string {\
19432color: rgb(3, 106, 7);\
19433}\
19434.ace-tm .ace_comment {\
19435color: rgb(76, 136, 107);\
19436}\
19437.ace-tm .ace_comment.ace_doc {\
19438color: rgb(0, 102, 255);\
19439}\
19440.ace-tm .ace_comment.ace_doc.ace_tag {\
19441color: rgb(128, 159, 191);\
19442}\
19443.ace-tm .ace_constant.ace_numeric {\
19444color: rgb(0, 0, 205);\
19445}\
19446.ace-tm .ace_variable {\
19447color: rgb(49, 132, 149);\
19448}\
19449.ace-tm .ace_xml-pe {\
19450color: rgb(104, 104, 91);\
19451}\
19452.ace-tm .ace_entity.ace_name.ace_function {\
19453color: #0000A2;\
19454}\
19455.ace-tm .ace_heading {\
19456color: rgb(12, 7, 255);\
19457}\
19458.ace-tm .ace_list {\
19459color:rgb(185, 6, 144);\
19460}\
19461.ace-tm .ace_meta.ace_tag {\
19462color:rgb(0, 22, 142);\
19463}\
19464.ace-tm .ace_string.ace_regex {\
19465color: rgb(255, 0, 0)\
19466}\
19467.ace-tm .ace_marker-layer .ace_selection {\
19468background: rgb(181, 213, 255);\
19469}\
19470.ace-tm.ace_multiselect .ace_selection.ace_start {\
19471box-shadow: 0 0 3px 0px white;\
19472}\
19473.ace-tm .ace_marker-layer .ace_step {\
19474background: rgb(252, 255, 0);\
19475}\
19476.ace-tm .ace_marker-layer .ace_stack {\
19477background: rgb(164, 229, 101);\
19478}\
19479.ace-tm .ace_marker-layer .ace_bracket {\
19480margin: -1px 0 0 -1px;\
19481border: 1px solid rgb(192, 192, 192);\
19482}\
19483.ace-tm .ace_marker-layer .ace_active-line {\
19484background: rgba(0, 0, 0, 0.07);\
19485}\
19486.ace-tm .ace_gutter-active-line {\
19487background-color : #dcdcdc;\
19488}\
19489.ace-tm .ace_marker-layer .ace_selected-word {\
19490background: rgb(250, 250, 255);\
19491border: 1px solid rgb(200, 200, 250);\
19492}\
19493.ace-tm .ace_indent-guide {\
19494background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
19495}\
19496";
19497
19498 var dom = acequire("../lib/dom");
19499 dom.importCssString(exports.cssText, exports.cssClass);
19500 });
19501
19502 ace.define("ace/line_widgets",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/range"], function(acequire, exports, module) {
19503
19504 acequire("./lib/oop");
19505 var dom = acequire("./lib/dom");
19506 acequire("./range").Range;
19507
19508
19509 function LineWidgets(session) {
19510 this.session = session;
19511 this.session.widgetManager = this;
19512 this.session.getRowLength = this.getRowLength;
19513 this.session.$getWidgetScreenLength = this.$getWidgetScreenLength;
19514 this.updateOnChange = this.updateOnChange.bind(this);
19515 this.renderWidgets = this.renderWidgets.bind(this);
19516 this.measureWidgets = this.measureWidgets.bind(this);
19517 this.session._changedWidgets = [];
19518 this.$onChangeEditor = this.$onChangeEditor.bind(this);
19519
19520 this.session.on("change", this.updateOnChange);
19521 this.session.on("changeFold", this.updateOnFold);
19522 this.session.on("changeEditor", this.$onChangeEditor);
19523 }
19524
19525 (function() {
19526 this.getRowLength = function(row) {
19527 var h;
19528 if (this.lineWidgets)
19529 h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
19530 else
19531 h = 0;
19532 if (!this.$useWrapMode || !this.$wrapData[row]) {
19533 return 1 + h;
19534 } else {
19535 return this.$wrapData[row].length + 1 + h;
19536 }
19537 };
19538
19539 this.$getWidgetScreenLength = function() {
19540 var screenRows = 0;
19541 this.lineWidgets.forEach(function(w){
19542 if (w && w.rowCount && !w.hidden)
19543 screenRows += w.rowCount;
19544 });
19545 return screenRows;
19546 };
19547
19548 this.$onChangeEditor = function(e) {
19549 this.attach(e.editor);
19550 };
19551
19552 this.attach = function(editor) {
19553 if (editor && editor.widgetManager && editor.widgetManager != this)
19554 editor.widgetManager.detach();
19555
19556 if (this.editor == editor)
19557 return;
19558
19559 this.detach();
19560 this.editor = editor;
19561
19562 if (editor) {
19563 editor.widgetManager = this;
19564 editor.renderer.on("beforeRender", this.measureWidgets);
19565 editor.renderer.on("afterRender", this.renderWidgets);
19566 }
19567 };
19568 this.detach = function(e) {
19569 var editor = this.editor;
19570 if (!editor)
19571 return;
19572
19573 this.editor = null;
19574 editor.widgetManager = null;
19575
19576 editor.renderer.off("beforeRender", this.measureWidgets);
19577 editor.renderer.off("afterRender", this.renderWidgets);
19578 var lineWidgets = this.session.lineWidgets;
19579 lineWidgets && lineWidgets.forEach(function(w) {
19580 if (w && w.el && w.el.parentNode) {
19581 w._inDocument = false;
19582 w.el.parentNode.removeChild(w.el);
19583 }
19584 });
19585 };
19586
19587 this.updateOnFold = function(e, session) {
19588 var lineWidgets = session.lineWidgets;
19589 if (!lineWidgets || !e.action)
19590 return;
19591 var fold = e.data;
19592 var start = fold.start.row;
19593 var end = fold.end.row;
19594 var hide = e.action == "add";
19595 for (var i = start + 1; i < end; i++) {
19596 if (lineWidgets[i])
19597 lineWidgets[i].hidden = hide;
19598 }
19599 if (lineWidgets[end]) {
19600 if (hide) {
19601 if (!lineWidgets[start])
19602 lineWidgets[start] = lineWidgets[end];
19603 else
19604 lineWidgets[end].hidden = hide;
19605 } else {
19606 if (lineWidgets[start] == lineWidgets[end])
19607 lineWidgets[start] = undefined;
19608 lineWidgets[end].hidden = hide;
19609 }
19610 }
19611 };
19612
19613 this.updateOnChange = function(delta) {
19614 var lineWidgets = this.session.lineWidgets;
19615 if (!lineWidgets) return;
19616
19617 var startRow = delta.start.row;
19618 var len = delta.end.row - startRow;
19619
19620 if (len === 0) ; else if (delta.action == 'remove') {
19621 var removed = lineWidgets.splice(startRow + 1, len);
19622 removed.forEach(function(w) {
19623 w && this.removeLineWidget(w);
19624 }, this);
19625 this.$updateRows();
19626 } else {
19627 var args = new Array(len);
19628 args.unshift(startRow, 0);
19629 lineWidgets.splice.apply(lineWidgets, args);
19630 this.$updateRows();
19631 }
19632 };
19633
19634 this.$updateRows = function() {
19635 var lineWidgets = this.session.lineWidgets;
19636 if (!lineWidgets) return;
19637 var noWidgets = true;
19638 lineWidgets.forEach(function(w, i) {
19639 if (w) {
19640 noWidgets = false;
19641 w.row = i;
19642 while (w.$oldWidget) {
19643 w.$oldWidget.row = i;
19644 w = w.$oldWidget;
19645 }
19646 }
19647 });
19648 if (noWidgets)
19649 this.session.lineWidgets = null;
19650 };
19651
19652 this.addLineWidget = function(w) {
19653 if (!this.session.lineWidgets)
19654 this.session.lineWidgets = new Array(this.session.getLength());
19655
19656 var old = this.session.lineWidgets[w.row];
19657 if (old) {
19658 w.$oldWidget = old;
19659 if (old.el && old.el.parentNode) {
19660 old.el.parentNode.removeChild(old.el);
19661 old._inDocument = false;
19662 }
19663 }
19664
19665 this.session.lineWidgets[w.row] = w;
19666
19667 w.session = this.session;
19668
19669 var renderer = this.editor.renderer;
19670 if (w.html && !w.el) {
19671 w.el = dom.createElement("div");
19672 w.el.innerHTML = w.html;
19673 }
19674 if (w.el) {
19675 dom.addCssClass(w.el, "ace_lineWidgetContainer");
19676 w.el.style.position = "absolute";
19677 w.el.style.zIndex = 5;
19678 renderer.container.appendChild(w.el);
19679 w._inDocument = true;
19680 }
19681
19682 if (!w.coverGutter) {
19683 w.el.style.zIndex = 3;
19684 }
19685 if (w.pixelHeight == null) {
19686 w.pixelHeight = w.el.offsetHeight;
19687 }
19688 if (w.rowCount == null) {
19689 w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight;
19690 }
19691
19692 var fold = this.session.getFoldAt(w.row, 0);
19693 w.$fold = fold;
19694 if (fold) {
19695 var lineWidgets = this.session.lineWidgets;
19696 if (w.row == fold.end.row && !lineWidgets[fold.start.row])
19697 lineWidgets[fold.start.row] = w;
19698 else
19699 w.hidden = true;
19700 }
19701
19702 this.session._emit("changeFold", {data:{start:{row: w.row}}});
19703
19704 this.$updateRows();
19705 this.renderWidgets(null, renderer);
19706 this.onWidgetChanged(w);
19707 return w;
19708 };
19709
19710 this.removeLineWidget = function(w) {
19711 w._inDocument = false;
19712 w.session = null;
19713 if (w.el && w.el.parentNode)
19714 w.el.parentNode.removeChild(w.el);
19715 if (w.editor && w.editor.destroy) try {
19716 w.editor.destroy();
19717 } catch(e){}
19718 if (this.session.lineWidgets) {
19719 var w1 = this.session.lineWidgets[w.row];
19720 if (w1 == w) {
19721 this.session.lineWidgets[w.row] = w.$oldWidget;
19722 if (w.$oldWidget)
19723 this.onWidgetChanged(w.$oldWidget);
19724 } else {
19725 while (w1) {
19726 if (w1.$oldWidget == w) {
19727 w1.$oldWidget = w.$oldWidget;
19728 break;
19729 }
19730 w1 = w1.$oldWidget;
19731 }
19732 }
19733 }
19734 this.session._emit("changeFold", {data:{start:{row: w.row}}});
19735 this.$updateRows();
19736 };
19737
19738 this.getWidgetsAtRow = function(row) {
19739 var lineWidgets = this.session.lineWidgets;
19740 var w = lineWidgets && lineWidgets[row];
19741 var list = [];
19742 while (w) {
19743 list.push(w);
19744 w = w.$oldWidget;
19745 }
19746 return list;
19747 };
19748
19749 this.onWidgetChanged = function(w) {
19750 this.session._changedWidgets.push(w);
19751 this.editor && this.editor.renderer.updateFull();
19752 };
19753
19754 this.measureWidgets = function(e, renderer) {
19755 var changedWidgets = this.session._changedWidgets;
19756 var config = renderer.layerConfig;
19757
19758 if (!changedWidgets || !changedWidgets.length) return;
19759 var min = Infinity;
19760 for (var i = 0; i < changedWidgets.length; i++) {
19761 var w = changedWidgets[i];
19762 if (!w || !w.el) continue;
19763 if (w.session != this.session) continue;
19764 if (!w._inDocument) {
19765 if (this.session.lineWidgets[w.row] != w)
19766 continue;
19767 w._inDocument = true;
19768 renderer.container.appendChild(w.el);
19769 }
19770
19771 w.h = w.el.offsetHeight;
19772
19773 if (!w.fixedWidth) {
19774 w.w = w.el.offsetWidth;
19775 w.screenWidth = Math.ceil(w.w / config.characterWidth);
19776 }
19777
19778 var rowCount = w.h / config.lineHeight;
19779 if (w.coverLine) {
19780 rowCount -= this.session.getRowLineCount(w.row);
19781 if (rowCount < 0)
19782 rowCount = 0;
19783 }
19784 if (w.rowCount != rowCount) {
19785 w.rowCount = rowCount;
19786 if (w.row < min)
19787 min = w.row;
19788 }
19789 }
19790 if (min != Infinity) {
19791 this.session._emit("changeFold", {data:{start:{row: min}}});
19792 this.session.lineWidgetWidth = null;
19793 }
19794 this.session._changedWidgets = [];
19795 };
19796
19797 this.renderWidgets = function(e, renderer) {
19798 var config = renderer.layerConfig;
19799 var lineWidgets = this.session.lineWidgets;
19800 if (!lineWidgets)
19801 return;
19802 var first = Math.min(this.firstRow, config.firstRow);
19803 var last = Math.max(this.lastRow, config.lastRow, lineWidgets.length);
19804
19805 while (first > 0 && !lineWidgets[first])
19806 first--;
19807
19808 this.firstRow = config.firstRow;
19809 this.lastRow = config.lastRow;
19810
19811 renderer.$cursorLayer.config = config;
19812 for (var i = first; i <= last; i++) {
19813 var w = lineWidgets[i];
19814 if (!w || !w.el) continue;
19815 if (w.hidden) {
19816 w.el.style.top = -100 - (w.pixelHeight || 0) + "px";
19817 continue;
19818 }
19819 if (!w._inDocument) {
19820 w._inDocument = true;
19821 renderer.container.appendChild(w.el);
19822 }
19823 var top = renderer.$cursorLayer.getPixelPosition({row: i, column:0}, true).top;
19824 if (!w.coverLine)
19825 top += config.lineHeight * this.session.getRowLineCount(w.row);
19826 w.el.style.top = top - config.offset + "px";
19827
19828 var left = w.coverGutter ? 0 : renderer.gutterWidth;
19829 if (!w.fixedWidth)
19830 left -= renderer.scrollLeft;
19831 w.el.style.left = left + "px";
19832
19833 if (w.fullWidth && w.screenWidth) {
19834 w.el.style.minWidth = config.width + 2 * config.padding + "px";
19835 }
19836
19837 if (w.fixedWidth) {
19838 w.el.style.right = renderer.scrollBar.getWidth() + "px";
19839 } else {
19840 w.el.style.right = "";
19841 }
19842 }
19843 };
19844
19845 }).call(LineWidgets.prototype);
19846
19847
19848 exports.LineWidgets = LineWidgets;
19849
19850 });
19851
19852 ace.define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range"], function(acequire, exports, module) {
19853 var LineWidgets = acequire("../line_widgets").LineWidgets;
19854 var dom = acequire("../lib/dom");
19855 var Range = acequire("../range").Range;
19856
19857 function binarySearch(array, needle, comparator) {
19858 var first = 0;
19859 var last = array.length - 1;
19860
19861 while (first <= last) {
19862 var mid = (first + last) >> 1;
19863 var c = comparator(needle, array[mid]);
19864 if (c > 0)
19865 first = mid + 1;
19866 else if (c < 0)
19867 last = mid - 1;
19868 else
19869 return mid;
19870 }
19871 return -(first + 1);
19872 }
19873
19874 function findAnnotations(session, row, dir) {
19875 var annotations = session.getAnnotations().sort(Range.comparePoints);
19876 if (!annotations.length)
19877 return;
19878
19879 var i = binarySearch(annotations, {row: row, column: -1}, Range.comparePoints);
19880 if (i < 0)
19881 i = -i - 1;
19882
19883 if (i >= annotations.length)
19884 i = dir > 0 ? 0 : annotations.length - 1;
19885 else if (i === 0 && dir < 0)
19886 i = annotations.length - 1;
19887
19888 var annotation = annotations[i];
19889 if (!annotation || !dir)
19890 return;
19891
19892 if (annotation.row === row) {
19893 do {
19894 annotation = annotations[i += dir];
19895 } while (annotation && annotation.row === row);
19896 if (!annotation)
19897 return annotations.slice();
19898 }
19899
19900
19901 var matched = [];
19902 row = annotation.row;
19903 do {
19904 matched[dir < 0 ? "unshift" : "push"](annotation);
19905 annotation = annotations[i += dir];
19906 } while (annotation && annotation.row == row);
19907 return matched.length && matched;
19908 }
19909
19910 exports.showErrorMarker = function(editor, dir) {
19911 var session = editor.session;
19912 if (!session.widgetManager) {
19913 session.widgetManager = new LineWidgets(session);
19914 session.widgetManager.attach(editor);
19915 }
19916
19917 var pos = editor.getCursorPosition();
19918 var row = pos.row;
19919 var oldWidget = session.widgetManager.getWidgetsAtRow(row).filter(function(w) {
19920 return w.type == "errorMarker";
19921 })[0];
19922 if (oldWidget) {
19923 oldWidget.destroy();
19924 } else {
19925 row -= dir;
19926 }
19927 var annotations = findAnnotations(session, row, dir);
19928 var gutterAnno;
19929 if (annotations) {
19930 var annotation = annotations[0];
19931 pos.column = (annotation.pos && typeof annotation.column != "number"
19932 ? annotation.pos.sc
19933 : annotation.column) || 0;
19934 pos.row = annotation.row;
19935 gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row];
19936 } else if (oldWidget) {
19937 return;
19938 } else {
19939 gutterAnno = {
19940 text: ["Looks good!"],
19941 className: "ace_ok"
19942 };
19943 }
19944 editor.session.unfold(pos.row);
19945 editor.selection.moveToPosition(pos);
19946
19947 var w = {
19948 row: pos.row,
19949 fixedWidth: true,
19950 coverGutter: true,
19951 el: dom.createElement("div"),
19952 type: "errorMarker"
19953 };
19954 var el = w.el.appendChild(dom.createElement("div"));
19955 var arrow = w.el.appendChild(dom.createElement("div"));
19956 arrow.className = "error_widget_arrow " + gutterAnno.className;
19957
19958 var left = editor.renderer.$cursorLayer
19959 .getPixelPosition(pos).left;
19960 arrow.style.left = left + editor.renderer.gutterWidth - 5 + "px";
19961
19962 w.el.className = "error_widget_wrapper";
19963 el.className = "error_widget " + gutterAnno.className;
19964 el.innerHTML = gutterAnno.text.join("<br>");
19965
19966 el.appendChild(dom.createElement("div"));
19967
19968 var kb = function(_, hashId, keyString) {
19969 if (hashId === 0 && (keyString === "esc" || keyString === "return")) {
19970 w.destroy();
19971 return {command: "null"};
19972 }
19973 };
19974
19975 w.destroy = function() {
19976 if (editor.$mouseHandler.isMousePressed)
19977 return;
19978 editor.keyBinding.removeKeyboardHandler(kb);
19979 session.widgetManager.removeLineWidget(w);
19980 editor.off("changeSelection", w.destroy);
19981 editor.off("changeSession", w.destroy);
19982 editor.off("mouseup", w.destroy);
19983 editor.off("change", w.destroy);
19984 };
19985
19986 editor.keyBinding.addKeyboardHandler(kb);
19987 editor.on("changeSelection", w.destroy);
19988 editor.on("changeSession", w.destroy);
19989 editor.on("mouseup", w.destroy);
19990 editor.on("change", w.destroy);
19991
19992 editor.session.widgetManager.addLineWidget(w);
19993
19994 w.el.onmousedown = editor.focus.bind(editor);
19995
19996 editor.renderer.scrollCursorIntoView(null, 0.5, {bottom: w.el.offsetHeight});
19997 };
19998
19999
20000 dom.importCssString("\
20001 .error_widget_wrapper {\
20002 background: inherit;\
20003 color: inherit;\
20004 border:none\
20005 }\
20006 .error_widget {\
20007 border-top: solid 2px;\
20008 border-bottom: solid 2px;\
20009 margin: 5px 0;\
20010 padding: 10px 40px;\
20011 white-space: pre-wrap;\
20012 }\
20013 .error_widget.ace_error, .error_widget_arrow.ace_error{\
20014 border-color: #ff5a5a\
20015 }\
20016 .error_widget.ace_warning, .error_widget_arrow.ace_warning{\
20017 border-color: #F1D817\
20018 }\
20019 .error_widget.ace_info, .error_widget_arrow.ace_info{\
20020 border-color: #5a5a5a\
20021 }\
20022 .error_widget.ace_ok, .error_widget_arrow.ace_ok{\
20023 border-color: #5aaa5a\
20024 }\
20025 .error_widget_arrow {\
20026 position: absolute;\
20027 border: solid 5px;\
20028 border-top-color: transparent!important;\
20029 border-right-color: transparent!important;\
20030 border-left-color: transparent!important;\
20031 top: -5px;\
20032 }\
20033", "");
20034
20035 });
20036
20037 ace.define("ace/ace",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/dom","ace/lib/event","ace/editor","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/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"], function(acequire, exports, module) {
20038
20039 acequire("./lib/fixoldbrowsers");
20040
20041 var dom = acequire("./lib/dom");
20042 var event = acequire("./lib/event");
20043
20044 var Editor = acequire("./editor").Editor;
20045 var EditSession = acequire("./edit_session").EditSession;
20046 var UndoManager = acequire("./undomanager").UndoManager;
20047 var Renderer = acequire("./virtual_renderer").VirtualRenderer;
20048 acequire("./worker/worker_client");
20049 acequire("./keyboard/hash_handler");
20050 acequire("./placeholder");
20051 acequire("./multi_select");
20052 acequire("./mode/folding/fold_mode");
20053 acequire("./theme/textmate");
20054 acequire("./ext/error_marker");
20055
20056 exports.config = acequire("./config");
20057 exports.acequire = acequire;
20058 exports.edit = function(el) {
20059 if (typeof el == "string") {
20060 var _id = el;
20061 el = document.getElementById(_id);
20062 if (!el)
20063 throw new Error("ace.edit can't find div #" + _id);
20064 }
20065
20066 if (el && el.env && el.env.editor instanceof Editor)
20067 return el.env.editor;
20068
20069 var value = "";
20070 if (el && /input|textarea/i.test(el.tagName)) {
20071 var oldNode = el;
20072 value = oldNode.value;
20073 el = dom.createElement("pre");
20074 oldNode.parentNode.replaceChild(el, oldNode);
20075 } else if (el) {
20076 value = dom.getInnerText(el);
20077 el.innerHTML = "";
20078 }
20079
20080 var doc = exports.createEditSession(value);
20081
20082 var editor = new Editor(new Renderer(el));
20083 editor.setSession(doc);
20084
20085 var env = {
20086 document: doc,
20087 editor: editor,
20088 onResize: editor.resize.bind(editor, null)
20089 };
20090 if (oldNode) env.textarea = oldNode;
20091 event.addListener(window, "resize", env.onResize);
20092 editor.on("destroy", function() {
20093 event.removeListener(window, "resize", env.onResize);
20094 env.editor.container.env = null; // prevent memory leak on old ie
20095 });
20096 editor.container.env = editor.env = env;
20097 return editor;
20098 };
20099 exports.createEditSession = function(text, mode) {
20100 var doc = new EditSession(text, mode);
20101 doc.setUndoManager(new UndoManager());
20102 return doc;
20103 };
20104 exports.EditSession = EditSession;
20105 exports.UndoManager = UndoManager;
20106 exports.version = "1.2.9";
20107 });
20108 (function() {
20109 ace.acequire(["ace/ace"], function(a) {
20110 if (a) {
20111 a.config.init(true);
20112 a.define = ace.define;
20113 }
20114 if (!window.ace)
20115 window.ace = a;
20116 for (var key in a) if (a.hasOwnProperty(key))
20117 window.ace[key] = a[key];
20118 });
20119 })();
20120
20121 var brace = window.ace.acequire("ace/ace");
20122
20123 var script = {
20124 name: 'FeiEditor',
20125 props: {
20126 modelValue: String,
20127 lang: {
20128 type: String,
20129 default: 'json'
20130 },
20131 theme: {
20132 type: String,
20133 default: 'chrome'
20134 },
20135 height: {
20136 type: String,
20137 default: '350'
20138 },
20139 width: {
20140 type: String,
20141 default: '100%'
20142 },
20143 fontSize: {
20144 type: Number,
20145 default: 12
20146 },
20147 options: Object,
20148 readonly: Boolean,
20149 wrap: {
20150 type: Boolean,
20151 default: false
20152 },
20153 snippets: {
20154 type: Boolean,
20155 default: true
20156 },
20157 styles: {
20158 type: Object
20159 }
20160 },
20161 data() {
20162 return {
20163 editor: null,
20164 contentBackup: ''
20165 };
20166 },
20167 emits: ['blur', 'init', 'update:modelValue', 'change'],
20168 computed: {
20169 wrapStyles() {
20170 return {
20171 width: this.width ? this.px(this.width) : '100%',
20172 height: this.height ? this.px(this.height) : '100%',
20173 border: '1px solid #e8e8e8',
20174 ...this.styles
20175 };
20176 }
20177 },
20178 methods: {
20179 px(n) {
20180 return /^\d*$/.test(n) ? `${n}px` : n;
20181 },
20182 getValue() {
20183 return this.editor.getValue();
20184 },
20185 handleBlur(event) {
20186 this.$emit('blur', event);
20187 }
20188 },
20189 watch: {
20190 modelValue(val) {
20191 if (this.contentBackup !== val) {
20192 this.editor.session.setValue(val, 1);
20193 this.contentBackup = val;
20194 }
20195 },
20196 theme(newTheme) {
20197 this.editor.setTheme('ace/theme/' + newTheme);
20198 },
20199 lang(newLang) {
20200 this.editor.getSession().setMode('ace/mode/' + newLang);
20201 },
20202 options(newOption) {
20203 this.editor.setOptions(newOption);
20204 },
20205 fontSize(newSize) {
20206 this.editor.setFontSize(newSize); // 设置文字大小
20207 },
20208
20209 readonly(val) {
20210 this.editor.setReadOnly(val); // 设置只读
20211 },
20212
20213 height() {
20214 this.$nextTick(() => {
20215 this.editor.resize();
20216 });
20217 },
20218 width() {
20219 this.$nextTick(() => {
20220 this.editor.resize();
20221 });
20222 }
20223 },
20224 beforeUnmount() {
20225 this.editor.destroy();
20226 this.editor.container.remove();
20227 },
20228 mounted() {
20229 let vm = this;
20230 let lang = this.lang;
20231 let theme = this.theme;
20232 let editor = vm.editor = brace.edit(this.$el);
20233 editor.getSession().setMode('ace/mode/' + lang);
20234 editor.setTheme('ace/theme/' + theme);
20235 editor.$blockScrolling = Infinity;
20236 editor.setFontSize(this.fontSize); // 设置文字大小
20237 editor.setReadOnly(this.readonly); // 设置只读
20238 editor.getSession().setUseWrapMode(this.wrap);
20239 editor.setShowPrintMargin(false);
20240 editor.getSession().setTabSize(2);
20241 editor.setOptions({
20242 enableBasicAutocompletion: this.snippets,
20243 enableSnippets: this.snippets,
20244 enableLiveAutocompletion: this.snippets
20245 });
20246 this.$emit('init', editor);
20247 if (this.modelValue) {
20248 editor.setValue(this.modelValue, 1);
20249 editor.gotoLine(0, 0, false);
20250 }
20251 this.contentBackup = this.modelValue;
20252 editor.on('change', function () {
20253 let content = editor.getValue();
20254 vm.$emit('update:modelValue', content);
20255 vm.$emit('change', content);
20256 vm.contentBackup = content;
20257 });
20258 editor.on('blur', this.handleBlur);
20259 if (vm.options) {
20260 editor.setOptions(vm.options);
20261 }
20262 }
20263 };
20264
20265 function render(_ctx, _cache, $props, $setup, $data, $options) {
20266 return vue.openBlock(), vue.createElementBlock("div", {
20267 class: "fei-editor",
20268 style: vue.normalizeStyle($options.wrapStyles)
20269 }, null, 4 /* STYLE */);
20270 }
20271
20272 script.render = render;
20273 script.__file = "src/components/editor/index.vue";
20274
20275 /**
20276 * @description 返回这个样式的颜色值
20277 * @param {String} type 样式名称 [ primary | success | warning | danger | text ]
20278 */
20279 function typeColor(type) {
20280 if (type === void 0) {
20281 type = 'default';
20282 }
20283 let color = '';
20284 switch (type) {
20285 case 'primary':
20286 color = '#1089ff';
20287 break;
20288 case 'success':
20289 color = '#52c41a';
20290 break;
20291 case 'warning':
20292 color = '#fa8c16';
20293 break;
20294 case 'danger':
20295 color = '#f5222d';
20296 break;
20297 case 'default':
20298 color = '#35495E';
20299 break;
20300 default:
20301 color = type;
20302 break;
20303 }
20304 return color;
20305 }
20306 const print = function (text, type, back) {
20307 if (type === void 0) {
20308 type = 'default';
20309 }
20310 if (back === void 0) {
20311 back = false;
20312 }
20313 if (typeof text === 'object') {
20314 // 如果是对象则调用打印对象方式
20315 console.dir(text);
20316 return;
20317 }
20318 if (back) {
20319 // 如果是打印带背景图的
20320 console.log(`%c ${text} `, `background:${typeColor(type)}; padding: 2px; border-radius: 2px;color: #fff;`);
20321 } else {
20322 console.log(`%c ${text} `, `color: ${typeColor(type)};`);
20323 }
20324 };
20325 const pretty = function (title, text, type) {
20326 if (type === void 0) {
20327 type = 'primary';
20328 }
20329 console.log(`%c ${title} %c ${text} %c`, `background:${typeColor(type)};border:1px solid ${typeColor(type)}; padding: 1px; border-radius: 2px 0 0 2px; color: #fff;`, `border:1px solid ${typeColor(type)}; padding: 1px; border-radius: 0 2px 2px 0; color: ${typeColor(type)};`, 'background:transparent');
20330 };
20331 const primary = function (text, back) {
20332 if (back === void 0) {
20333 back = false;
20334 }
20335 print(text, 'primary', back);
20336 };
20337 const success = function (text, back) {
20338 if (back === void 0) {
20339 back = false;
20340 }
20341 print(text, 'success', back);
20342 };
20343 const info = function (text, back) {
20344 if (back === void 0) {
20345 back = false;
20346 }
20347 print(text, 'info', back);
20348 };
20349 const warning = function (text, back) {
20350 if (back === void 0) {
20351 back = false;
20352 }
20353 print(text, 'warning', back);
20354 };
20355 const danger = function (text, back) {
20356 if (back === void 0) {
20357 back = false;
20358 }
20359 print(text, 'danger', back);
20360 };
20361 const printVersion = function (title, version, link, type, fontSize, versionColor) {
20362 if (type === void 0) {
20363 type = 'primary';
20364 }
20365 if (fontSize === void 0) {
20366 fontSize = '20px';
20367 }
20368 if (versionColor === void 0) {
20369 versionColor = '#999';
20370 }
20371 console.log(`%c${title.toUpperCase()} %cV${version} ${link}`, `color: ${typeColor(type)};font-weight: 500;font-size: ${fontSize};font-family: Source Sans Pro,Helvetica Neue,Arial,sans-serif;`, `color: ${versionColor};`);
20372 };
20373 const log = {
20374 print,
20375 pretty,
20376 primary,
20377 info,
20378 success,
20379 warning,
20380 danger,
20381 printVersion
20382 };
20383
20384 var name = "fei-editor";
20385 var description = "基于vue的代码编辑器插件";
20386 var version$1 = "0.0.2";
20387 var keywords = [
20388 "fei-editor",
20389 "vue3",
20390 "components"
20391 ];
20392 var author = "yangmengfei";
20393 var files = [
20394 "lib",
20395 "src"
20396 ];
20397 var main = "lib/fei-editor.common.js";
20398 var module = "src/components/editor/index.vue";
20399 var unpkg = "lib/fei-editor.js";
20400 var homepage = "https://ymf930.gitee.io/fei-editor/";
20401 var license = "MIT";
20402 var scripts = {
20403 dev: "webpack-dev-server --config build/webpack.dev.js",
20404 "build:demo": "rimraf docs && cross-env NODE_ENV=production webpack --config build/webpack.dev.js",
20405 build: "yarn clean-lib && yarn build:lib",
20406 "clean-lib": "rimraf lib",
20407 "build:lib": "rollup --config build/rollup.config.mjs --bundleConfigAsCjs",
20408 lint: "eslint ./src --ext .vue,.js,.ts",
20409 "lint-fix": "eslint --fix ./src --ext .vue,.js,.ts"
20410 };
20411 var dependencies = {
20412 brace: "^0.11.1"
20413 };
20414 var peerDependencies = {
20415 vue: "^3.2.47"
20416 };
20417 var devDependencies = {
20418 "@babel/cli": "^7.21.5",
20419 "@babel/core": "^7.21.8",
20420 "@babel/eslint-parser": "^7.21.8",
20421 "@babel/plugin-transform-runtime": "^7.21.4",
20422 "@babel/preset-env": "^7.21.5",
20423 "@babel/runtime": "^7.21.5",
20424 "@rollup/plugin-babel": "^6.0.3",
20425 "@rollup/plugin-commonjs": "^25.0.0",
20426 "@rollup/plugin-json": "^6.0.0",
20427 "@rollup/plugin-node-resolve": "^15.0.2",
20428 "@rollup/plugin-replace": "^5.0.2",
20429 "@rollup/plugin-terser": "^0.4.3",
20430 "@types/markdown-it": "^12.2.3",
20431 "@vue/babel-plugin-jsx": "^1.0.0",
20432 "@vue/compiler-sfc": "^3.3.4",
20433 "babel-loader": "^9.1.2",
20434 "babel-plugin-module-resolver": "^5.0.0",
20435 "babel-plugin-transform-class-properties": "^6.24.1",
20436 "cross-env": "^7.0.2",
20437 "css-loader": "^6.7.4",
20438 "css-minimizer-webpack-plugin": "^5.0.0",
20439 eslint: "^8.41.0",
20440 "eslint-plugin-vue": "^9.14.0",
20441 "f-ui-one": "^1.0.5",
20442 "file-loader": "^6.0.0",
20443 "file-save": "^0.2.0",
20444 gulp: "^4.0.2",
20445 "gulp-autoprefixer": "^8.0.0",
20446 "gulp-cssmin": "^0.2.0",
20447 "gulp-stylus": "^3.0.0",
20448 "highlight.js": "^11.8.0",
20449 "html-webpack-plugin": "^5.5.1",
20450 "markdown-it": "^13.0.1",
20451 "markdown-it-anchor": "^8.6.7",
20452 "markdown-it-chain": "^1.3.0",
20453 "markdown-it-container": "^3.0.0",
20454 "mini-css-extract-plugin": "^2.7.6",
20455 postcss: "^8.4.23",
20456 prettier: "^2.8.8",
20457 rimraf: "^5.0.1",
20458 rollup: "^3.23.0",
20459 "rollup-plugin-css-only": "^4.3.0",
20460 "rollup-plugin-peer-deps-external": "^2.2.4",
20461 "rollup-plugin-postcss": "^4.0.2",
20462 "rollup-plugin-vue": "^6.0.0-beta.11",
20463 "style-loader": "^3.3.3",
20464 stylus: "^0.59.0",
20465 "stylus-loader": "7.1.0",
20466 tinycolor2: "^1.4.2",
20467 transliteration: "^2.2.0",
20468 "url-loader": "^4.1.1",
20469 vue: "^3.3.4",
20470 "vue-loader": "^17.1.1",
20471 "vue-router": "^4.2.1",
20472 "vue-template-compiler": "^2.6.12",
20473 webpack: "^5.83.1",
20474 "webpack-bundle-analyzer": "^4.8.0",
20475 "webpack-cli": "^5.1.1",
20476 "webpack-dev-server": "^4.15.0"
20477 };
20478 var config = {
20479 name: name,
20480 description: description,
20481 version: version$1,
20482 keywords: keywords,
20483 author: author,
20484 files: files,
20485 main: main,
20486 module: module,
20487 unpkg: unpkg,
20488 homepage: homepage,
20489 "private": false,
20490 license: license,
20491 scripts: scripts,
20492 dependencies: dependencies,
20493 peerDependencies: peerDependencies,
20494 devDependencies: devDependencies
20495 };
20496
20497 const version = config.version; // version_ to fix tsc issue
20498
20499 const install = function (app, options) {
20500 if (options === void 0) {
20501 options = {};
20502 }
20503 app.component(script.name, script);
20504 if (!options.disabledDoc) {
20505 log.printVersion(config.name, config.version, config.homepage, '#722ed1');
20506 }
20507 return app;
20508 };
20509 var index = {
20510 version,
20511 install
20512 };
20513
20514 exports.Editor = script;
20515 exports.default = index;
20516
20517 Object.defineProperty(exports, '__esModule', { value: true });
20518
20519 return exports;
20520
20521})({}, Vue);