mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
1110 lines
374 KiB
JavaScript
1110 lines
374 KiB
JavaScript
/*
|
|
|
|
Copyright (c) 2014 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2013 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2010, 2012 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2012 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
Felipe Heidrich (IBM Corporation) - initial API and implementation
|
|
Silenio Quarti (IBM Corporation) - initial API and implementation
|
|
|
|
Copyright (c) 2010, 2012 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
Felipe Heidrich (IBM Corporation) - initial API and implementation
|
|
Silenio Quarti (IBM Corporation) - initial API and implementation
|
|
|
|
Copyright (c) 2012 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2010, 2012 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
Felipe Heidrich (IBM Corporation) - initial API and implementation
|
|
Silenio Quarti (IBM Corporation) - initial API and implementation
|
|
|
|
Copyright (c) 2010, 2013 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
Felipe Heidrich (IBM Corporation) - initial API and implementation
|
|
Silenio Quarti (IBM Corporation) - initial API and implementation
|
|
|
|
Copyright (c) 2013 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2013,2014 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2013 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2010, 2014 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
Felipe Heidrich (IBM Corporation) - initial API and implementation
|
|
Silenio Quarti (IBM Corporation) - initial API and implementation
|
|
Mihai Sucan (Mozilla Foundation) - fix for Bug#334583 Bug#348471 Bug#349485 Bug#350595 Bug#360726 Bug#361180 Bug#362835 Bug#362428 Bug#362286 Bug#354270 Bug#361474 Bug#363945 Bug#366312 Bug#370584
|
|
|
|
Copyright (c) 2010, 2012 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
Felipe Heidrich (IBM Corporation) - initial API and implementation
|
|
Silenio Quarti (IBM Corporation) - initial API and implementation
|
|
|
|
Copyright (c) 2010, 2012 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
Felipe Heidrich (IBM Corporation) - initial API and implementation
|
|
Silenio Quarti (IBM Corporation) - initial API and implementation
|
|
|
|
Copyright (c) 2010, 2014 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2013 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2010, 2012 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2010, 2012 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2010, 2012 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
Felipe Heidrich (IBM Corporation) - initial API and implementation
|
|
Silenio Quarti (IBM Corporation) - initial API and implementation
|
|
|
|
Copyright (c) 2009, 2014 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2013 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2014 IBM Corporation and others. All rights reserved.
|
|
This program and the accompanying materials are made available under the
|
|
terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2013 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2010, 2014 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2013 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2013 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2011, 2013 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2012 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2012 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2011, 2014 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2014 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2014 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2011, 2014 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2011, 2014 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2011, 2012 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2011, 2013 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2011, 2012 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2011, 2014 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2010, 2012 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
Alex Lakatos - fix for bug#369781
|
|
|
|
Copyright (c) 2014 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2014 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2014 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors: IBM Corporation - initial API and implementation
|
|
|
|
Copyright (c) 2013 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
IBM Corporation - initial API and implementation
|
|
RequireJS i18n 2.0.2 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
|
|
Available via the MIT or new BSD license.
|
|
see: http://github.com/requirejs/i18n for details
|
|
|
|
Copyright (c) 2011, 2013 IBM Corporation and others.
|
|
All rights reserved. This program and the accompanying materials are made
|
|
available under the terms of the Eclipse Public License v1.0
|
|
(http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
|
|
License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
|
|
|
|
Contributors:
|
|
IBM Corporation - initial API and implementation
|
|
*/
|
|
var requirejs,require,define;
|
|
(function(p){function t(a,b){var c,l,m,w,n,f,d,s,g,h=b&&b.split("/"),u=e.map,q=u&&u["*"]||{};if(a&&"."===a.charAt(0))if(b){h=h.slice(0,h.length-1);a=h.concat(a.split("/"));for(s=0;s<a.length;s+=1)if(c=a[s],"."===c)a.splice(s,1),s-=1;else if(".."===c)if(1===s&&(".."===a[2]||".."===a[0]))break;else 0<s&&(a.splice(s-1,2),s-=2);a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((h||q)&&u){c=a.split("/");for(s=c.length;0<s;s-=1){l=c.slice(0,s).join("/");if(h)for(g=h.length;0<g;g-=1)if(m=u[h.slice(0,
|
|
g).join("/")])if(m=m[l]){w=m;n=s;break}if(w)break;!f&&(q&&q[l])&&(f=q[l],d=s)}!w&&f&&(w=f,n=d);w&&(c.splice(0,n,w),a=c.join("/"))}return a}function r(a,b){return function(){return c.apply(p,x.call(arguments,0).concat([a,b]))}}function k(a){return function(b){return t(b,a)}}function g(a){return function(b){l[a]=b}}function h(a){if(u.call(n,a)){var b=n[a];delete n[a];s[a]=!0;d.apply(p,b)}if(!u.call(l,a)&&!u.call(s,a))throw Error("No "+a);return l[a]}function f(a){var b,e=a?a.indexOf("!"):-1;-1<e&&(b=
|
|
a.substring(0,e),a=a.substring(e+1,a.length));return[b,a]}function q(a){return function(){return e&&e.config&&e.config[a]||{}}}var d,c,a,b,l={},n={},e={},s={},u=Object.prototype.hasOwnProperty,x=[].slice;a=function(a,b){var e,c=f(a),m=c[0];a=c[1];m&&(m=t(m,b),e=h(m));m?a=e&&e.normalize?e.normalize(a,k(b)):t(a,b):(a=t(a,b),c=f(a),m=c[0],a=c[1],m&&(e=h(m)));return{f:m?m+"!"+a:a,n:a,pr:m,p:e}};b={require:function(a){return r(a)},exports:function(a){var b=l[a];return"undefined"!==typeof b?b:l[a]={}},
|
|
module:function(a){return{id:a,uri:"",exports:l[a],config:q(a)}}};d=function(e,c,f,d){var m,w,B,A,D=[],q;d=d||e;if("function"===typeof f){c=!c.length&&f.length?["require","exports","module"]:c;for(A=0;A<c.length;A+=1)if(B=a(c[A],d),w=B.f,"require"===w)D[A]=b.require(e);else if("exports"===w)D[A]=b.exports(e),q=!0;else if("module"===w)m=D[A]=b.module(e);else if(u.call(l,w)||u.call(n,w)||u.call(s,w))D[A]=h(w);else if(B.p)B.p.load(B.n,r(d,!0),g(w),{}),D[A]=l[w];else throw Error(e+" missing "+w);c=f.apply(l[e],
|
|
D);if(e)if(m&&m.exports!==p&&m.exports!==l[e])l[e]=m.exports;else if(c!==p||!q)l[e]=c}else e&&(l[e]=f)};requirejs=require=c=function(l,n,f,s,m){if("string"===typeof l)return b[l]?b[l](n):h(a(l,n).f);l.splice||(e=l,n.splice?(l=n,n=f,f=null):l=p);n=n||function(){};"function"===typeof f&&(f=s,s=m);s?d(p,l,n,f):setTimeout(function(){d(p,l,n,f)},4);return c};c.config=function(a){e=a;return c};define=function(a,b,e){b.splice||(e=b,b=[]);!u.call(l,a)&&!u.call(n,a)&&(n[a]=[a,b,e])};define.amd={jQuery:!0}})();
|
|
define("almond",function(){});define("orion/editor/config",[],function(){return{languages:{}}});
|
|
define("orion/editor/shim",[],function(){Object.create||(Object.create=function(p,t){function r(){}r.prototype=p;var k=new r;if(t)for(var g in t)t.hasOwnProperty(g)&&(t[g].hasOwnProperty("value")?k[g]=t[g].value:k[g]=function(){if(0<arguments.length)return t[g].get();t[g].set(arguments)});return k});Object.keys||(Object.keys=function(p){var t=Object.prototype.hasOwnProperty,r=[],k;for(k in p)t.call(p,k)&&r.push(k);return r});Function.prototype.bind||(Function.prototype.bind=function(p){var t=this,
|
|
r=Array.prototype.slice.call(arguments,1);return r.length?function(){return arguments.length?t.apply(p,r.concat(Array.prototype.slice.call(arguments))):t.apply(p,r)}:function(){return arguments.length?t.apply(p,arguments):t.call(p)}});Array.isArray||(Array.isArray=function(p){return"[object Array]"===Object.prototype.toString.call(p)});Array.prototype.indexOf||(Array.prototype.indexOf=function(p){for(var t=0;t<this.length;t++)if(this[t]===p)return t;return-1});Array.prototype.forEach||(Array.prototype.forEach=
|
|
function(p){for(var t=0;t<this.length;t++)p(this[t],t)});Array.prototype.map||(Array.prototype.map=function(p){for(var t=Array(this.length),r=0;r<this.length;r++)t[r]=p(this[r]);return t});Array.prototype.reduce||(Array.prototype.reduce=function(p,t){var r,k=!1;1<arguments.length&&(r=t,k=!0);for(var g=0;this.length>g;++g)k?r=p(r,this[g],g,this):(r=this[g],k=!0);return r});String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});String.prototype.trimLeft||(String.prototype.trimLeft=
|
|
function(){return this.replace(/^\s+/g,"")});String.prototype.trimRight||(String.prototype.trimRight=function(){return this.replace(/\s+$/g,"")});return{}});
|
|
(function(){function p(g,h,f,q,d,c){h[g]&&(f.push(g),(!0===h[g]||1===h[g])&&q.push(d+g+"/"+c))}function t(g,h,f,q,d){h=q+h+"/"+d;require._fileExists(g.toUrl(h+".js"))&&f.push(h)}function r(g,h,f){for(var q in h)h.hasOwnProperty(q)&&(!g.hasOwnProperty(q)||f)?g[q]=h[q]:"object"===typeof h[q]&&r(g[q],h[q],f)}var k=/(^.*(^|\/)nls(\/|$))([^\/]*)\/?([^\/]*)/;define("i18n",["module"],function(g){var h=g.config?g.config():{},h=h||{};return{version:"2.0.1+",load:function(f,g,d,c){c=c||{};c.locale&&(h.locale=
|
|
c.locale);var a=k.exec(f),b=a[1],l=a[4],n=a[5],e=l.split("-"),s=[],u={},x,v="";a[5]?(b=a[1],f=b+n):(n=a[4],l=h.locale,l||(l=h.locale="undefined"===typeof navigator?"root":(navigator.language||navigator.userLanguage||"root").toLowerCase()),e=l.split("-"));if(c.isBuild){s.push(f);t(g,"root",s,b,n);for(x=0;x<e.length;x++)c=e[x],v+=(v?"-":"")+c,t(g,v,s,b,n);g(s,function(){d()})}else g([f],function(a){var c=[],l;p("root",a,c,s,b,n);for(x=0;x<e.length;x++)l=e[x],v+=(v?"-":"")+l,p(v,a,c,s,b,n);g(s,function(){var m,
|
|
w,e;for(m=c.length-1;-1<m&&c[m];m--){e=c[m];w=a[e];if(!0===w||1===w)w=g(b+e+"/"+n);r(u,w)}d(u)})})}}})})();define("orion/editor/i18n",{load:function(p,t,r,k){t.specified&&t.specified("orion/bootstrap")?t(["orion/i18n!"+p],function(g){r(g)}):t(["orion/editor/config"],function(g){r(g&&g.languages||{})})}});
|
|
define("orion/editor/nls/root/messages",{multipleAnnotations:"Multiple annotations:",line:"Line: ${0}",breakpoint:"Breakpoint",bookmark:"Bookmark",task:"Task",error:"Error",warning:"Warning",matchingSearch:"Matching Search",currentSearch:"Current Search",currentLine:"Current Line",matchingBracket:"Matching Bracket",currentBracket:"Current Bracket",lineUp:"Line Up",lineDown:"Line Down",lineStart:"Line Start",lineEnd:"Line End",charPrevious:"Previous Character",charNext:"Next Character",pageUp:"Page Up",
|
|
pageDown:"Page Down",scrollPageUp:"Scroll Page Up",scrollPageDown:"Scroll Page Down",scrollLineUp:"Scroll Line Up",scrollLineDown:"Scroll Line Down",wordPrevious:"Previous Word",wordNext:"Next Word",textStart:"Document Start",textEnd:"Document End",scrollTextStart:"Scroll Document Start",scrollTextEnd:"Scroll Document End",centerLine:"Center Line",selectLineUp:"Select Line Up",selectLineDown:"Select Line Down",selectWholeLineUp:" Select Whole Line Up",selectWholeLineDown:"Select Whole Line Down",
|
|
selectLineStart:"Select Line Start",selectLineEnd:"Select Line End",selectCharPrevious:"Select Previous Character",selectCharNext:"Select Next Character",selectPageUp:"Select Page Up",selectPageDown:"Select Page Down",selectWordPrevious:"Select Previous Word",selectWordNext:"Select Next Word",selectTextStart:"Select Document Start",selectTextEnd:"Select Document End",deletePrevious:"Delete Previous Character",deleteNext:"Delete Next Character",deleteWordPrevious:"Delete Previous Word",deleteWordNext:"Delete Next Word",
|
|
deleteLineStart:"Delete Line Start",deleteLineEnd:"Delete Line End",tab:"Insert Tab",enter:"Insert Line Delimiter",enterNoCursor:"Insert Line Delimiter",selectAll:"Select All",copy:"Copy",cut:"Cut",paste:"Paste",uppercase:"To Upper Case",lowercase:"To Lower Case",capitalize:"Capitalize",reversecase:"Reverse Case",toggleWrapMode:"Toggle Wrap Mode",toggleTabMode:"Toggle Tab Mode",toggleOverwriteMode:"Toggle Overwrite Mode",committerOnTime:"${0} on ${1}",emacs:"Emacs",exchangeMarkPoint:"Exchange Mark and Point",
|
|
setMarkCommand:"Set Mark",clearMark:"Clear Mark",digitArgument:"Digit Argument ${0}",negativeArgument:"Negative Argument",Comment:"Comment","Flat outline":"Flat outline",incrementalFindStr:"Incremental find: ${0}",incrementalFindStrNotFound:"Incremental find: ${0} (not found)",incrementalFindReverseStr:"Reverse Incremental find: ${0}",incrementalFindReverseStrNotFound:"Reverse Incremental find: ${0} (not found)",find:"Find...",undo:"Undo",redo:"Redo",cancelMode:"Cancel Current Mode",findNext:"Find Next Occurrence",
|
|
findPrevious:"Find Previous Occurrence",incrementalFind:"Incremental Find",incrementalFindReverse:"Incremental Find Reverse",indentLines:"Indent Lines",unindentLines:"Unindent Lines",moveLinesUp:"Move Lines Up",moveLinesDown:"Move Lines Down",copyLinesUp:"Copy Lines Up",copyLinesDown:"Copy Lines Down",deleteLines:"Delete Lines",gotoLine:"Goto Line...",gotoLinePrompty:"Goto Line:",nextAnnotation:"Next Annotation",prevAnnotation:"Previous Annotation",expand:"Expand",collapse:"Collapse",expandAll:"Expand All",
|
|
collapseAll:"Collapse All",lastEdit:"Last Edit Location",trimTrailingWhitespaces:"Trim Trailing Whitespaces",toggleLineComment:"Toggle Line Comment",addBlockComment:"Add Block Comment",removeBlockComment:"Remove Block Comment",linkedModeEntered:"Linked Mode entered",linkedModeExited:"Linked Mode exited",syntaxError:"Syntax Error",contentAssist:"Content Assist",lineColumn:"Line ${0} : Col ${1}",vi:"vi",vimove:"(Move)",viyank:"(Yank)",videlete:"(Delete)",vichange:"(Change)",viLeft:"${0} Left",viRight:"${0} Right",
|
|
viUp:"${0} Up",viDown:"${0} Down",viw:"${0} Next Word",vib:"${0} Beginning of Word",viW:"${0} Next Word (ws stop)",viB:"${0} Beginning of Word (ws stop)",vie:"${0} End of Word",viE:"${0} End of Word (ws stop)",vi$:"${0} End of the line","vi^_":"${0} First non-blank Char Current Line","vi+":"${0} First Char Next Line","vi-":"${0} First Char Previous Line","vi|":"${0} nth Column in Line",viH:"${0} Top of Page",viM:"${0} Middle of Page",viL:"${0} Bottom of Page","vi/":"${0} Search Forward","vi?":"${0} Search Backward",
|
|
vin:"${0} Next Search",viN:"${0} Previous Search",vif:"${0} Search Char Fwd",viF:"${0} Search Char Bckwd",vit:"${0} Search Before Char Fwd",viT:"${0} Search Before Char Bckwd","vi,":"${0} Repeat Reverse Char Search","vi;":"${0} Repeat Char Search",viG:"${0} Go to Line",viycd:"${0} Current Line",via:"Append After Cursor",viA:"Append to End of Line",vii:"Insert Before Cursor",viI:"Insert at Beginning of Line",viO:"Insert Line Above",vio:"Insert Line Below",viR:"Begin Overwriting Text",vis:"Substitute a Character",
|
|
viS:"Substitute Entire Line",viC:"Change Text Until Line End",vip:"Paste After Char or Line",viP:"Paste Before Char or Line",viStar:"Search Word Under Cursor",next:"Next",previous:"Previous",replace:"Replace",replaceAll:"Replace All",findWith:"Find With",replaceWith:"Replace With",caseInsensitive:"Aa",regex:"/.*/",wholeWord:"\\b",caseInsensitiveTooltip:"Toggle Case Insensitive",regexTooltip:"Toggle Regex",wholeWordTooltip:"Toggle Whole Word",closeTooltip:"Close",replacingAll:"Replacing all...",replacedMatches:"Replaced ${0} matches",
|
|
nothingReplaced:"Nothing replaced",notFound:"Not found"});define("orion/editor/nls/messages",["orion/editor/i18n!orion/editor/nls/messages","orion/editor/nls/root/messages"],function(p,t){var r={root:t},k;for(k in p)p.hasOwnProperty(k)&&"undefined"===typeof r[k]&&(r[k]=p[k]);return r});
|
|
define("orion/editor/eventTarget",[],function(){function p(){}p.addMixin=function(t){var r=p.prototype,k;for(k in r)r.hasOwnProperty(k)&&(t[k]=r[k])};p.prototype={addEventListener:function(p,r,k){this._eventTypes||(this._eventTypes={});var g=this._eventTypes[p];g||(g=this._eventTypes[p]={level:0,listeners:[]});g.listeners.push({listener:r,useCapture:k})},dispatchEvent:function(p){var r=p.type;this._dispatchEvent("pre"+r,p);this._dispatchEvent(r,p);this._dispatchEvent("post"+r,p)},_dispatchEvent:function(p,
|
|
r){var k=this._eventTypes?this._eventTypes[p]:null;if(k){var g=k.listeners;try{if(k.level++,g)for(var h=0,f=g.length;h<f;h++)if(g[h]){var q=g[h].listener;"function"===typeof q?q.call(this,r):q.handleEvent&&"function"===typeof q.handleEvent&&q.handleEvent(r)}}finally{if(k.level--,k.compact&&0===k.level){for(h=g.length-1;0<=h;h--)g[h]||g.splice(h,1);0===g.length&&delete this._eventTypes[p];k.compact=!1}}}},isListening:function(p){return!this._eventTypes?!1:void 0!==this._eventTypes[p]},removeEventListener:function(p,
|
|
r,k){if(this._eventTypes){var g=this._eventTypes[p];if(g){for(var h=g.listeners,f=0,q=h.length;f<q;f++){var d=h[f];if(d&&d.listener===r&&d.useCapture===k){0!==g.level?(h[f]=null,g.compact=!0):h.splice(f,1);break}}0===h.length&&delete this._eventTypes[p]}}}};return{EventTarget:p}});define("orion/regex",[],function(){return{escape:function(p){return p.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$\x26")},parse:function(p){return(p=/^\s*\/(.+)\/([gim]{0,3})\s*$/.exec(p))?{pattern:p[1],flags:p[2]}:null}}});
|
|
define("orion/util",[],function(){var p=navigator.userAgent,t=-1!==p.indexOf("MSIE")||-1!==p.indexOf("Trident")?document.documentMode:void 0,r=parseFloat(p.split("Firefox/")[1]||p.split("Minefield/")[1])||void 0,k=-1!==p.indexOf("Opera")?parseFloat(p.split("Version/")[1]):void 0,g=parseFloat(p.split("Chrome/")[1])||void 0,h=-1!==p.indexOf("Safari")&&!g,f=parseFloat(p.split("WebKit/")[1])||void 0,q=-1!==p.indexOf("Android"),d=-1!==p.indexOf("iPad"),p=-1!==p.indexOf("iPhone"),c=d||p,a=-1!==navigator.platform.indexOf("Mac"),
|
|
b=-1!==navigator.platform.indexOf("Win"),l=-1!==navigator.platform.indexOf("Linux"),n="undefined"!==typeof document&&"ontouchstart"in document.createElement("input");return{formatMessage:function(a){var b=arguments;return a.replace(/\$\{([^\}]+)\}/g,function(a,e){return b[(e<<0)+1]})},createElement:function(a,b){return a.createElementNS?a.createElementNS("http://www.w3.org/1999/xhtml",b):a.createElement(b)},isIE:t,isFirefox:r,isOpera:k,isChrome:g,isSafari:h,isWebkit:f,isAndroid:q,isIPad:d,isIPhone:p,
|
|
isIOS:c,isMac:a,isWindows:b,isLinux:l,isTouch:n,platformDelimiter:b?"\r\n":"\n"}});
|
|
define("orion/editor/textModel",["orion/editor/eventTarget","orion/regex","orion/util"],function(p,t,r){function k(g,h){this._lastLineIndex=-1;this._text=[""];this._lineOffsets=[0];this.setText(g);this.setLineDelimiter(h)}k.prototype={destroy:function(){},find:function(g){1<this._text.length&&(this._text=[this._text.join("")]);var h=g.string,f=g.regex,q=h,d="",c=g.caseInsensitive;if(q)if(f){if(h=t.parse(q))q=h.pattern,d=h.flags}else q=h.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$\x26"),c&&(q=q.replace(/[iI\u0130\u0131]/g,
|
|
"[Ii\u0130\u0131]"));var a=null,b;if(q){var h=g.reverse,l=g.wrap,f=g.wholeWord,n=g.start||0;g=g.end;var e=null!==g&&void 0!==g;-1===d.indexOf("g")&&(d+="g");-1===d.indexOf("m")&&(d+="m");c&&-1===d.indexOf("i")&&(d+="i");f&&(q="\\b"+q+"\\b");var s=this._text[0],u,x,k=0;e&&(c=n<g?n:g,s=s.substring(c,n<g?g:n),k=c);var p=RegExp(q,d);h?b=function(){var a=null;for(p.lastIndex=0;;){x=p.lastIndex;u=p.exec(s);if(x===p.lastIndex)return null;if(u){if(!(u.index+k<n)){if(!l||a)break;n=s.length+k}a={start:u.index+
|
|
k,end:p.lastIndex+k}}else break}a&&(n=a.start);return a}:(e||(p.lastIndex=n),b=function(){for(;;){x=p.lastIndex;u=p.exec(s);if(x===p.lastIndex)break;if(u)return{start:u.index+k,end:p.lastIndex+k};if(!(0!==x&&l))break}return null});a=b()}return{next:function(){var e=a;e&&(a=b());return e},hasNext:function(){return null!==a}}},getCharCount:function(){for(var g=0,h=0;h<this._text.length;h++)g+=this._text[h].length;return g},getLine:function(g,h){var f=this.getLineCount();if(!(0<=g&&g<f))return null;
|
|
var q=this._lineOffsets[g];if(g+1<f){f=this.getText(q,this._lineOffsets[g+1]);if(h)return f;for(var q=f.length,d;10===(d=f.charCodeAt(q-1))||13===d;)q--;return f.substring(0,q)}return this.getText(q)},getLineAtOffset:function(g){var h=this.getCharCount();if(!(0<=g&&g<=h))return-1;var f=this.getLineCount();if(g===h)return f-1;var q,d,c=this._lastLineIndex;if(0<=c&&c<f&&(q=this._lineOffsets[c],d=c+1<f?this._lineOffsets[c+1]:h,q<=g&&g<d))return c;for(var a=f,b=-1;1<a-b;)if(c=Math.floor((a+b)/2),q=this._lineOffsets[c],
|
|
d=c+1<f?this._lineOffsets[c+1]:h,g<=q)a=c;else if(g<d){a=c;break}else b=c;return this._lastLineIndex=a},getLineCount:function(){return this._lineOffsets.length},getLineDelimiter:function(){return this._lineDelimiter},getLineEnd:function(g,h){var f=this.getLineCount();if(!(0<=g&&g<f))return-1;if(g+1<f){f=this._lineOffsets[g+1];if(h)return f;for(var q=this.getText(Math.max(this._lineOffsets[g],f-2),f),d=q.length,c;10===(c=q.charCodeAt(d-1))||13===c;)d--;return f-(q.length-d)}return this.getCharCount()},
|
|
getLineStart:function(g){return!(0<=g&&g<this.getLineCount())?-1:this._lineOffsets[g]},getText:function(g,h){void 0===g&&(g=0);void 0===h&&(h=this.getCharCount());if(g===h)return"";for(var f=0,q=0,d;q<this._text.length;){d=this._text[q].length;if(g<=f+d)break;f+=d;q++}for(var c=f,a=q;q<this._text.length;){d=this._text[q].length;if(h<=f+d)break;f+=d;q++}if(a===q)return this._text[a].substring(g-c,h-f);c=this._text[a].substring(g-c);f=this._text[q].substring(0,h-f);return c+this._text.slice(a+1,q).join("")+
|
|
f},onChanging:function(g){return this.dispatchEvent(g)},onChanged:function(g){return this.dispatchEvent(g)},setLineDelimiter:function(g,h){"auto"===g&&(g=void 0,1<this.getLineCount()&&(g=this.getText(this.getLineEnd(0),this.getLineEnd(0,!0))));this._lineDelimiter=g?g:r.platformDelimiter;if(h){var f=this.getLineCount();if(1<f){for(var q=Array(f),d=0;d<f;d++)q[d]=this.getLine(d);this.setText(q.join(this._lineDelimiter))}}},setText:function(g,h,f){void 0===g&&(g="");void 0===h&&(h=0);void 0===f&&(f=
|
|
this.getCharCount());if(!(h===f&&""===g)){for(var q=this.getLineAtOffset(h),d=this.getLineAtOffset(f),c=h,a=f-h,b=d-q,l=g.length,n=0,e=this.getLineCount(),s=0,u=0,x=0,k=[];;){-1!==s&&s<=x&&(s=g.indexOf("\r",x));-1!==u&&u<=x&&(u=g.indexOf("\n",x));if(-1===u&&-1===s)break;x=-1!==s&&-1!==u?s+1===u?u+1:(s<u?s:u)+1:-1!==s?s+1:u+1;k.push(h+x);n++}this.onChanging({type:"Changing",text:g,start:c,removedCharCount:a,addedCharCount:l,removedLineCount:b,addedLineCount:n});0===k.length&&(x=this.getLineStart(q),
|
|
d=d+1<e?this.getLineStart(d+1):this.getCharCount(),h!==x&&(g=this.getText(x,h)+g,h=x),f!==d&&(g+=this.getText(f,d),f=d));x=l-a;for(d=q+b+1;d<e;d++)this._lineOffsets[d]+=x;if(5E4>k.length)q=[q+1,b].concat(k),Array.prototype.splice.apply(this._lineOffsets,q);else{x=q+1;this._lineOffsets.splice(x,b);for(e=0;e<k.length;e+=5E4)q=[x,0].concat(k.slice(e,Math.min(k.length,e+5E4))),Array.prototype.splice.apply(this._lineOffsets,q),x+=5E4}for(x=e=0;x<this._text.length;){d=this._text[x].length;if(h<=e+d)break;
|
|
e+=d;x++}q=e;for(k=x;x<this._text.length;){d=this._text[x].length;if(f<=e+d)break;e+=d;x++}d=this._text[x];h=this._text[k].substring(0,h-q);f=d.substring(f-e);k=[k,x-k+1];h&&k.push(h);g&&k.push(g);f&&k.push(f);Array.prototype.splice.apply(this._text,k);0===this._text.length&&(this._text=[""]);this.onChanged({type:"Changed",start:c,removedCharCount:a,addedCharCount:l,removedLineCount:b,addedLineCount:n})}}};p.EventTarget.addMixin(k.prototype);return{TextModel:k}});
|
|
define("orion/keyBinding",["orion/util"],function(p){function t(k,g,h,f,q,d){this.type=d||"keydown";this.keyCode="string"===typeof k&&"keydown"===this.type?k.toUpperCase().charCodeAt(0):k;this.mod1=void 0!==g&&null!==g?g:!1;this.mod2=void 0!==h&&null!==h?h:!1;this.mod3=void 0!==f&&null!==f?f:!1;this.mod4=void 0!==q&&null!==q?q:!1}function r(k){this.keys=k}t.prototype={getKeys:function(){return[this]},match:function(k,g){if(void 0!==g){if(0!==g)return!1}else if(k instanceof Array){if(1<k.length)return!1;
|
|
k=k[0]}return k.type!==this.type?!1:this.keyCode===k.keyCode||this.keyCode===String.fromCharCode(p.isOpera?k.which:void 0!==k.charCode?k.charCode:k.keyCode)?this.mod1!==(p.isMac?k.metaKey:k.ctrlKey)||"keydown"===this.type&&this.mod2!==k.shiftKey||this.mod3!==k.altKey||p.isMac&&this.mod4!==k.ctrlKey?!1:!0:!1},equals:function(k){return!k||this.keyCode!==k.keyCode||this.mod1!==k.mod1||this.mod2!==k.mod2||this.mod3!==k.mod3||this.mod4!==k.mod4||this.type!==k.type?!1:!0}};r.prototype={getKeys:function(){return this.keys.slice(0)},
|
|
match:function(k,g){var h=this.keys;if(void 0!==g)return g>h.length?!1:h[g].match(k)?g===h.length-1?!0:g+1:!1;k instanceof Array||(k=[k]);if(k.length>h.length)return!1;var f;for(f=0;f<k.length;f++)if(!h[f].match(k[f]))return!1;return f===h.length?!0:f},equals:function(k){if(!k.keys||k.keys.length!==this.keys.length)return!1;for(var g=0;g<k.keys.length;g++)if(!k.keys[g].equals(this.keys[g]))return!1;return!0}};return{KeyBinding:t,KeyStroke:t,KeySequence:r}});
|
|
define("orion/editor/keyModes",["orion/keyBinding","orion/util"],function(p,t){function r(g){g&&(this._view=g,this._keyBindings=this.createKeyBindings(),this._keyBindingIndex=0)}function k(g){r.call(this,g)}r.prototype={createKeyBindings:function(){return[]},getKeyBindings:function(g){for(var h=[],f=this._keyBindings,q=0;q<f.length;q++)f[q].actionID===g&&h.push(f[q].keyBinding);return h},getView:function(){return this._view},isActive:function(){return-1!==this._view.getKeyModes().indexOf(this)},match:function(g){if("keydown"===
|
|
g.type)switch(g.keyCode){case 16:case 17:case 18:case 91:return}for(var h=this._keyBindingIndex,f=this._matchingKeyBindings||this._keyBindings,q=[],d=0;d<f.length;d++){var c=f[d],a=c.keyBinding.match(g,h);if(!0===a)return this._keyBindingIndex=0,this._matchingKeyBindings=null,c.actionID;"number"===typeof a&&q.push(c)}if(0===q.length)this._keyBindingIndex=0,this._matchingKeyBindings=null;else return this._keyBindingIndex++,this._matchingKeyBindings=q,"noop"},setKeyBinding:function(g,h){for(var f=this._keyBindings,
|
|
q=0;q<f.length;q++){var d=f[q];if(d.keyBinding.equals(g)){h?d.actionID=h:d.predefined?d.actionID="noop":f.splice(q,1);return}}h&&f.push({keyBinding:g,actionID:h})},setView:function(g){this._view=g}};k.prototype=new r;k.prototype.createKeyBindings=function(){var g=p.KeyBinding,h=[];h.push({actionID:"lineUp",keyBinding:new g(38),predefined:!0});h.push({actionID:"lineDown",keyBinding:new g(40),predefined:!0});h.push({actionID:"charPrevious",keyBinding:new g(37),predefined:!0});h.push({actionID:"charNext",
|
|
keyBinding:new g(39),predefined:!0});t.isMac?(h.push({actionID:"scrollPageUp",keyBinding:new g(33),predefined:!0}),h.push({actionID:"scrollPageDown",keyBinding:new g(34),predefined:!0}),h.push({actionID:"pageUp",keyBinding:new g(33,null,null,!0),predefined:!0}),h.push({actionID:"pageDown",keyBinding:new g(34,null,null,!0),predefined:!0}),h.push({actionID:"lineStart",keyBinding:new g(37,!0),predefined:!0}),h.push({actionID:"lineEnd",keyBinding:new g(39,!0),predefined:!0}),h.push({actionID:"wordPrevious",
|
|
keyBinding:new g(37,null,null,!0),predefined:!0}),h.push({actionID:"wordNext",keyBinding:new g(39,null,null,!0),predefined:!0}),h.push({actionID:"scrollTextStart",keyBinding:new g(36),predefined:!0}),h.push({actionID:"scrollTextEnd",keyBinding:new g(35),predefined:!0}),h.push({actionID:"textStart",keyBinding:new g(38,!0),predefined:!0}),h.push({actionID:"textEnd",keyBinding:new g(40,!0),predefined:!0}),h.push({actionID:"scrollPageUp",keyBinding:new g(38,null,null,null,!0),predefined:!0}),h.push({actionID:"scrollPageDown",
|
|
keyBinding:new g(40,null,null,null,!0),predefined:!0}),h.push({actionID:"lineStart",keyBinding:new g(37,null,null,null,!0),predefined:!0}),h.push({actionID:"lineEnd",keyBinding:new g(39,null,null,null,!0),predefined:!0}),h.push({actionID:"lineStart",keyBinding:new g(38,null,null,!0),predefined:!0}),h.push({actionID:"lineEnd",keyBinding:new g(40,null,null,!0),predefined:!0})):(h.push({actionID:"pageUp",keyBinding:new g(33),predefined:!0}),h.push({actionID:"pageDown",keyBinding:new g(34),predefined:!0}),
|
|
h.push({actionID:"lineStart",keyBinding:new g(36),predefined:!0}),h.push({actionID:"lineEnd",keyBinding:new g(35),predefined:!0}),h.push({actionID:"wordPrevious",keyBinding:new g(37,!0),predefined:!0}),h.push({actionID:"wordNext",keyBinding:new g(39,!0),predefined:!0}),h.push({actionID:"textStart",keyBinding:new g(36,!0),predefined:!0}),h.push({actionID:"textEnd",keyBinding:new g(35,!0),predefined:!0}));t.isFirefox&&t.isLinux&&(h.push({actionID:"lineUp",keyBinding:new g(38,!0),predefined:!0}),h.push({actionID:"lineDown",
|
|
keyBinding:new g(40,!0),predefined:!0}));t.isWindows&&(h.push({actionID:"scrollLineUp",keyBinding:new g(38,!0),predefined:!0}),h.push({actionID:"scrollLineDown",keyBinding:new g(40,!0),predefined:!0}));h.push({actionID:"selectLineUp",keyBinding:new g(38,null,!0),predefined:!0});h.push({actionID:"selectLineDown",keyBinding:new g(40,null,!0),predefined:!0});h.push({actionID:"selectCharPrevious",keyBinding:new g(37,null,!0),predefined:!0});h.push({actionID:"selectCharNext",keyBinding:new g(39,null,!0),
|
|
predefined:!0});h.push({actionID:"selectPageUp",keyBinding:new g(33,null,!0),predefined:!0});h.push({actionID:"selectPageDown",keyBinding:new g(34,null,!0),predefined:!0});t.isMac?(h.push({actionID:"selectLineStart",keyBinding:new g(37,!0,!0),predefined:!0}),h.push({actionID:"selectLineEnd",keyBinding:new g(39,!0,!0),predefined:!0}),h.push({actionID:"selectWordPrevious",keyBinding:new g(37,null,!0,!0),predefined:!0}),h.push({actionID:"selectWordNext",keyBinding:new g(39,null,!0,!0),predefined:!0}),
|
|
h.push({actionID:"selectTextStart",keyBinding:new g(36,null,!0),predefined:!0}),h.push({actionID:"selectTextEnd",keyBinding:new g(35,null,!0),predefined:!0}),h.push({actionID:"selectTextStart",keyBinding:new g(38,!0,!0),predefined:!0}),h.push({actionID:"selectTextEnd",keyBinding:new g(40,!0,!0),predefined:!0}),h.push({actionID:"selectLineStart",keyBinding:new g(37,null,!0,null,!0),predefined:!0}),h.push({actionID:"selectLineEnd",keyBinding:new g(39,null,!0,null,!0),predefined:!0}),h.push({actionID:"selectLineStart",
|
|
keyBinding:new g(38,null,!0,!0),predefined:!0}),h.push({actionID:"selectLineEnd",keyBinding:new g(40,null,!0,!0),predefined:!0})):(t.isLinux&&(h.push({actionID:"selectWholeLineUp",keyBinding:new g(38,!0,!0),predefined:!0}),h.push({actionID:"selectWholeLineDown",keyBinding:new g(40,!0,!0),predefined:!0})),h.push({actionID:"selectLineStart",keyBinding:new g(36,null,!0),predefined:!0}),h.push({actionID:"selectLineEnd",keyBinding:new g(35,null,!0),predefined:!0}),h.push({actionID:"selectWordPrevious",
|
|
keyBinding:new g(37,!0,!0),predefined:!0}),h.push({actionID:"selectWordNext",keyBinding:new g(39,!0,!0),predefined:!0}),h.push({actionID:"selectTextStart",keyBinding:new g(36,!0,!0),predefined:!0}),h.push({actionID:"selectTextEnd",keyBinding:new g(35,!0,!0),predefined:!0}));h.push({actionID:"undo",keyBinding:new p.KeyBinding("z",!0),predefined:!0});t.isMac?h.push({actionID:"redo",keyBinding:new p.KeyBinding("z",!0,!0),predefined:!0}):h.push({actionID:"redo",keyBinding:new p.KeyBinding("y",!0),predefined:!0});
|
|
h.push({actionID:"deletePrevious",keyBinding:new g(8),predefined:!0});h.push({actionID:"deletePrevious",keyBinding:new g(8,null,!0),predefined:!0});h.push({actionID:"deleteNext",keyBinding:new g(46),predefined:!0});h.push({actionID:"deleteWordPrevious",keyBinding:new g(8,!0),predefined:!0});h.push({actionID:"deleteWordPrevious",keyBinding:new g(8,!0,!0),predefined:!0});h.push({actionID:"deleteWordNext",keyBinding:new g(46,!0),predefined:!0});h.push({actionID:"tab",keyBinding:new g(9),predefined:!0});
|
|
h.push({actionID:"shiftTab",keyBinding:new g(9,null,!0),predefined:!0});h.push({actionID:"enter",keyBinding:new g(13),predefined:!0});h.push({actionID:"enter",keyBinding:new g(13,null,!0),predefined:!0});h.push({actionID:"selectAll",keyBinding:new g("a",!0),predefined:!0});h.push({actionID:"toggleTabMode",keyBinding:new g("m",!0),predefined:!0});t.isMac&&(h.push({actionID:"deleteNext",keyBinding:new g(46,null,!0),predefined:!0}),h.push({actionID:"deleteWordPrevious",keyBinding:new g(8,null,null,!0),
|
|
predefined:!0}),h.push({actionID:"deleteWordNext",keyBinding:new g(46,null,null,!0),predefined:!0}));h.push({actionID:"toggleWrapMode",keyBinding:new p.KeyBinding("w",!0,!1,!0)});h.push({actionID:"toggleOverwriteMode",keyBinding:new p.KeyBinding(45)});if(!t.isFirefox){var f=t.isMac&&t.isChrome;h.push({actionID:"noop",keyBinding:new g("u",!f,!1,!1,f),predefined:!0});h.push({actionID:"noop",keyBinding:new g("i",!f,!1,!1,f),predefined:!0});h.push({actionID:"noop",keyBinding:new g("b",!f,!1,!1,f),predefined:!0})}t.isFirefox&&
|
|
(h.push({actionID:"copy",keyBinding:new g(45,!0),predefined:!0}),h.push({actionID:"paste",keyBinding:new g(45,null,!0),predefined:!0}),h.push({actionID:"cut",keyBinding:new g(46,null,!0),predefined:!0}));t.isMac&&(h.push({actionID:"lineStart",keyBinding:new g("a",!1,!1,!1,!0),predefined:!0}),h.push({actionID:"lineEnd",keyBinding:new g("e",!1,!1,!1,!0),predefined:!0}),h.push({actionID:"lineUp",keyBinding:new g("p",!1,!1,!1,!0),predefined:!0}),h.push({actionID:"lineDown",keyBinding:new g("n",!1,!1,
|
|
!1,!0),predefined:!0}),h.push({actionID:"charPrevious",keyBinding:new g("b",!1,!1,!1,!0),predefined:!0}),h.push({actionID:"charNext",keyBinding:new g("f",!1,!1,!1,!0),predefined:!0}),h.push({actionID:"deletePrevious",keyBinding:new g("h",!1,!1,!1,!0),predefined:!0}),h.push({actionID:"deleteNext",keyBinding:new g("d",!1,!1,!1,!0),predefined:!0}),h.push({actionID:"deleteLineEnd",keyBinding:new g("k",!1,!1,!1,!0),predefined:!0}),t.isFirefox?(h.push({actionID:"scrollPageDown",keyBinding:new g("v",!1,
|
|
!1,!1,!0),predefined:!0}),h.push({actionID:"deleteLineStart",keyBinding:new g("u",!1,!1,!1,!0),predefined:!0}),h.push({actionID:"deleteWordPrevious",keyBinding:new g("w",!1,!1,!1,!0),predefined:!0})):(h.push({actionID:"pageDown",keyBinding:new g("v",!1,!1,!1,!0),predefined:!0}),h.push({actionID:"centerLine",keyBinding:new g("l",!1,!1,!1,!0),predefined:!0}),h.push({actionID:"enterNoCursor",keyBinding:new g("o",!1,!1,!1,!0),predefined:!0})));return h};return{KeyMode:r,DefaultKeyMode:k}});
|
|
define("orion/editor/textTheme",["require","orion/editor/eventTarget","orion/util"],function(p,t,r){function k(g){g=g||{};this._document=g.document||document}var g={};k.getTheme=function(h){h=h||"default";var f=g[h];f||(f=g[h]=new k);return f};k.prototype={getThemeClass:function(){return this._themeClass},setThemeClass:function(g,f){var q=this,d=q._themeClass;q._themeClass=g;this._load(g,f,function(){q.onThemeChanged({type:"ThemeChanged",oldValue:d,newValue:q.getThemeClass()})})},onThemeChanged:function(g){return this.dispatchEvent(g)},
|
|
buildStyleSheet:function(g,f){var q=function(a){return a.replace(this._capitalRegEx,function(a){return"-"+a}.bind(this)).toLowerCase()}.bind(this),d=function(a,b,c,n,e){var f=[];Object.keys(a).forEach(function(g){var h=a[g];"string"===typeof h?f.push("\t"+q(g)+": "+h+";"):d(h,c===g?b:b+(n?" .":".")+g,c,!1,e)});f.length&&(e.push(b+(n?".textview":"")+" {"),e.push.apply(e,f),e.push("}"))},c=[""];d(f.styles,"."+g,f.className,!0,c);return c.join("\n")},_createStyle:function(g,f,q,d){var c=this._document;
|
|
g="orion-theme-"+g;var a=c.getElementById(g);if(a){if(d||a.firstChild.data===f)return;a.removeChild(a.firstChild);a.appendChild(c.createTextNode(f))}else d?(a=r.createElement(c,"link"),a.rel="stylesheet",a.type="text/css",a.href=f,a.addEventListener("load",function(){q()})):(a=r.createElement(c,"style"),a.appendChild(c.createTextNode(f))),a.id=g,(c.getElementsByTagName("head")[0]||c.documentElement).appendChild(a);d||q()},_load:function(g,f,q){if(g)if("string"===typeof f)this._createStyle(g,f,q);
|
|
else if(f=f.href,".css"!==f.substring(f.length-4)&&(f+=".css"),/^\//.test(f)||/[a-zA-Z0-9]+:\/\//i.test(f)||!p.toUrl)this._createStyle(g,f,q,!0);else{var d=this;p(["text!"+f],function(c){d._createStyle(g,c,q,!1)})}else q()},_capitalRegEx:/[A-Z]/g};t.EventTarget.addMixin(k.prototype);return{TextTheme:k}});
|
|
define("orion/editor/util",[],function(){return{contains:function(p,t){if(!t)return!1;if(!p.compareDocumentPosition){for(var r=t;r;){if(p===r)return!0;r=r.parentNode}return!1}return p===t||0!==(p.compareDocumentPosition(t)&16)},getNodeStyle:function(p,t,r){var k;if(p&&(k=p.style[t],!k))if(p.currentStyle){for(k=0;-1!==(k=t.indexOf("-",k));)t=t.substring(0,k)+t.substring(k+1,k+2).toUpperCase()+t.substring(k+2);k=p.currentStyle[t]}else k=(p=p.ownerDocument.defaultView.getComputedStyle(p,null))?p.getPropertyValue(t):
|
|
null;return k||r},addEventListener:function(p,t,r,k){"function"===typeof p.addEventListener?p.addEventListener(t,r,!0===k):p.attachEvent("on"+t,r)},removeEventListener:function(p,t,r,k){"function"===typeof p.removeEventListener?p.removeEventListener(t,r,!0===k):p.detachEvent("on"+t,r)},Animation:function(){function p(p){this.options=p}p.prototype.play=function(){var p="number"===typeof this.options.duration?this.options.duration:350,r=this.options.easing||this.defaultEasing,k=this.options.onAnimate||
|
|
function(){},g=this.options.curve[0],h=this.options.curve[1],f=h-g,q=-1,d,c=this;this.interval=this.options.window.setInterval(function(){q=-1===q?(new Date).getTime():q;var a=((new Date).getTime()-q)/p;1>a?(a=r(a),d=g+a*f,k(d)):(k(h),c.stop())},"number"===typeof this.options.rate?this.options.rate:20)};p.prototype.stop=function(){this.options.window.clearInterval(this.interval);(this.options.onEnd||function(){})()};p.prototype.defaultEasing=function(p){return Math.sin(p*(Math.PI/2))};return p}()}});
|
|
define("orion/editor/textView","i18n!orion/editor/nls/messages orion/editor/textModel orion/editor/keyModes orion/editor/eventTarget orion/editor/textTheme orion/editor/util orion/util".split(" "),function(p,t,r,k,g,h,f){function q(m,w,a){if(a){w.className="";a=w.attributes;for(var b=a.length;0<b--;)(!f.isIE||9<=f.isIE||9>f.isIE&&a[b].specified)&&w.removeAttribute(a[b].name)}if(m){m.styleClass&&(w.className=m.styleClass);if(a=m.style)for(var e in a)a.hasOwnProperty(e)&&(w.style[e]=a[e]);if(m=m.attributes)for(var c in m)m.hasOwnProperty(c)&&
|
|
w.setAttribute(c,m[c])}}function d(m){return m instanceof Array?m.slice(0):m}function c(m,a){if(!m)return a;if(!a)return m;for(var b in a)a.hasOwnProperty(b)&&(m.hasOwnProperty(b)||(m[b]=a[b]));return m}function a(m,w){if(m===w)return!0;if(m&&!w||!m&&w||m&&m.constructor===String||w&&w.constructor===String)return!1;if(m instanceof Array||w instanceof Array){if(!(m instanceof Array&&w instanceof Array)||m.length!==w.length)return!1;for(var b=0;b<m.length;b++)if(!a(m[b],w[b]))return!1;return!0}if(!(m instanceof
|
|
Object)||!(w instanceof Object))return!1;for(b in m)if(m.hasOwnProperty(b)&&(!w.hasOwnProperty(b)||!a(m[b],w[b])))return!1;for(b in w)if(!m.hasOwnProperty(b))return!1;return!0}function b(m,a,b){for(var e=0,c=0,l=0,n=m.length;l<n;){-1!==e&&e<=l&&(e=m.indexOf("\r",l));-1!==c&&c<=l&&(c=m.indexOf("\n",l));var f=l,d;if(-1===c&&-1===e){a(m.substring(l));break}-1!==e&&-1!==c?e+1===c?(d=e,l=c+1):(d=e<c?e:c,l=(e<c?e:c)+1):-1!==e?(d=e,l=e+1):(d=c,l=c+1);a(m.substring(f,d));b()}}function l(m){var a,b,e,c,l=
|
|
m.ownerDocument.defaultView||m.ownerDocument.parentWindow;l.getComputedStyle?(m=l.getComputedStyle(m,null),a=m.getPropertyValue("padding-left"),b=m.getPropertyValue("padding-top"),e=m.getPropertyValue("padding-right"),c=m.getPropertyValue("padding-bottom")):m.currentStyle&&(a=m.currentStyle.paddingLeft,b=m.currentStyle.paddingTop,e=m.currentStyle.paddingRight,c=m.currentStyle.paddingBottom);return{left:parseInt(a,10)||0,top:parseInt(b,10)||0,right:parseInt(e,10)||0,bottom:parseInt(c,10)||0}}function n(m){var a,
|
|
b,e,c,n=m._trim;if(!n){var n=l(m),f=m.ownerDocument.defaultView||m.ownerDocument.parentWindow;f.getComputedStyle?(c=f.getComputedStyle(m,null),a=c.getPropertyValue("border-left-width"),b=c.getPropertyValue("border-top-width"),e=c.getPropertyValue("border-right-width"),c=c.getPropertyValue("border-bottom-width")):m.currentStyle&&(a=m.currentStyle.borderLeftWidth,b=m.currentStyle.borderTopWidth,e=m.currentStyle.borderRightWidth,c=m.currentStyle.borderBottomWidth);a=parseInt(a,10)||0;b=parseInt(b,10)||
|
|
0;e=parseInt(e,10)||0;c=parseInt(c,10)||0;n.left+=a;n.top+=b;n.right+=e;n.bottom+=c;m._trim=n}return n}function e(m,a,b,e){function c(a){if(a.animationName===n){var w=a.target;"function"===typeof w.__DOMReady&&(m.defaultView||m.parentWindow).setTimeout(function(){w.__DOMReady()},0)}}function l(m,a){for(var w=["","-webkit-","-moz-","-ms-","-o-"],b="",e="body ."+m+" {\n",c=0;c<w.length;c++)b+="@"+w[c]+"keyframes "+a+" {\nfrom { opacity: 0.99; }\nto { opacity: 1; }\n}\n",e+=w[c]+"animation-duration: 0.001s;\n"+
|
|
w[c]+"animation-name: "+a+";\n";return b+(e+"}")}b="_"+b+"DOMReady";a.className=a.className?a.className+" "+b:b;a.__DOMReady=e;e=b+"Style";if(!m.getElementById(e)){var n=b+"Animation";y(m,"animationstart",c,!1);y(m,"MSAnimationStart",c,!1);y(m,"webkitAnimationStart",c,!1);a=m.createElement("style");a.id=e;e=m.getElementsByTagName("head")[0]||m.documentElement;a.appendChild(m.createTextNode(l(b,n)));e.insertBefore(a,e.firstChild)}}function s(m,a,b){this.start=m;this.end=a;this.caret=b}function u(m){this.left=
|
|
m.left;this.top=m.top;this.right=m.right;this.bottom=m.bottom}function x(m,a,b){this.view=m;this.lineIndex=a;this._lineDiv=b}function v(m){this._init(m||{})}var y=h.addEventListener,z=h.removeEventListener,C=h.Animation;s.prototype={clone:function(){return new s(this.start,this.end,this.caret)},collapse:function(){this.caret?this.end=this.start:this.start=this.end},extend:function(m){this.caret?this.start=m:this.end=m;this.start>this.end&&(m=this.start,this.start=this.end,this.end=m,this.caret=!this.caret)},
|
|
setCaret:function(m){this.end=this.start=m;this.caret=!1},getCaret:function(){return this.caret?this.start:this.end},toString:function(){return"start\x3d"+this.start+" end\x3d"+this.end+(this.caret?" caret is at start":" caret is at end")},isEmpty:function(){return this.start===this.end},equals:function(m){return this.caret===m.caret&&this.start===m.start&&this.end===m.end}};u.prototype={toString:function(){return"{l\x3d"+this.left+", t\x3d"+this.top+", r\x3d"+this.right+", b\x3d"+this.bottom+"}"}};
|
|
x.prototype={create:function(m,a){if(!this._lineDiv){var b=this._lineDiv=this._createLine(m,a,this.lineIndex);b._line=this;return b}},_createLine:function(m,w,b){var e=this.view,c=e._model,l=c.getLine(b),n=c.getLineStart(b),d={type:"LineStyle",textView:e,lineIndex:b,lineText:l,lineStart:n};e.onLineStyle(d);var s=m.ownerDocument,c=w||f.createElement(s,"div");if(!w||!a(w.viewStyle,d.style))q(d.style,c,w),w&&(w._trim=null),c.viewStyle=d.style,c.setAttribute("role","presentation");c.lineIndex=b;if(w&&
|
|
c.viewLineText===l&&a(d.ranges,c.viewRanges))return c;c.viewRanges=d.ranges;c.viewLineText=l;b=[];this._createRanges(d.ranges,l,0,l.length,n,{tabOffset:0,ranges:b});d=" ";!e._fullSelection&&9>f.isIE&&(d="\ufeff");e={text:d,style:e._metrics.largestFontStyle,ignoreChars:1};0===b.length||!b[b.length-1].style||"div"!==b[b.length-1].style.tagName?b.push(e):b.splice(b.length-1,0,e);var g,h,u,k=d=0;if(f.isFirefox&&2E3<l.length){w&&(c.innerHTML="",w.lineWidth=void 0);w=s.createDocumentFragment();for(l=0;l<
|
|
b.length;l++)e=b[l],n=e.text,g=e.style,g=this._createSpan(c,n,g,e.ignoreChars),w.appendChild(g);c.appendChild(w)}else{var x,v;if(w){if(h=w.modelChangedEvent)0===h.removedLineCount&&0===h.addedLineCount?(v=h.start-n,x=h.addedCharCount-h.removedCharCount):v=-1,w.modelChangedEvent=void 0;h=w.firstChild}for(l=0;l<b.length;l++){e=b[l];n=e.text;d+=n.length;g=e.style;if(h)if(u=h.firstChild.data,s=h.viewStyle,u===n&&a(g,s)){k+=u.length;h._rectsCache=void 0;g=h=h.nextSibling;continue}else for(;h;){if(-1!==
|
|
v){s=d;s>=v&&(s-=x);u=(u=h.firstChild.data)?u.length:0;if(k+u>s)break;k+=u}s=h.nextSibling;c.removeChild(h);h=s}g=this._createSpan(c,n,g,e.ignoreChars);h?c.insertBefore(g,h):c.appendChild(g);w&&(w.lineWidth=void 0)}if(w)for(x=g?g.nextSibling:null;x;)s=x.nextSibling,w.removeChild(x),x=s}c.parentNode||m.appendChild(c);return c},_createRanges:function(m,w,b,e,c,l){if(!(b>e)){if(m)for(var n=0;n<m.length;n++){var f=m[n];if(!(f.end<c+b)){var d=Math.max(c+b,f.start)-c;if(d>e)break;var s=Math.min(c+e,f.end)-
|
|
c;if(d<=s){d=Math.max(b,d);s=Math.min(e,s);b<d&&this._createRange(w,b,d,null,l);if(!f.style||!f.style.unmergeable)for(;n+1<m.length&&m[n+1].start-c===s&&a(f.style,m[n+1].style);)f=m[n+1],s=Math.min(c+e,f.end)-c,n++;this._createRange(w,d,s,f.style,l);b=s}}}b<e&&this._createRange(w,b,e,null,l)}},_createRange:function(m,a,b,e,c){if(!(a>b)){var l=this.view._customTabSize;if(l&&8!==l)for(var n=m.indexOf("\t",a);-1!==n&&n<b;){a<n&&(a={text:m.substring(a,n),style:e},c.ranges.push(a),c.tabOffset+=a.text.length);
|
|
a=l-c.tabOffset%l;if(0<a){for(var f="\u00a0",d=1;d<a;d++)f+=" ";a={text:f,style:e,ignoreChars:a-1};c.ranges.push(a);c.tabOffset+=a.text.length}a=n+1;if(a===b)return;n=m.indexOf("\t",a)}a<=b&&(a={text:m.substring(a,b),style:e},c.ranges.push(a),c.tabOffset+=a.text.length)}},_createSpan:function(m,a,b,e){var c=this.view,l="span";b&&b.tagName&&(l=b.tagName.toLowerCase());var n="a"===l;n&&(this.hasLink=!0);n&&!c._linksVisible&&(l="span");n=m.ownerDocument;m=f.createElement(m.ownerDocument,l);m.appendChild(n.createTextNode(b&&
|
|
b.text?b.text:a));b&&b.html?(m.innerHTML=b.html,m.ignore=!0):b&&b.node&&(m.appendChild(b.node),m.ignore=!0);q(b,m);if("a"===l){var d=c._getWindow();y(m,"click",function(m){return c._handleLinkClick(m?m:d.event)},!1)}m.viewStyle=b;e&&(m.ignoreChars=e);return m},_ensureCreated:function(){return this._lineDiv?this._lineDiv:this._createdDiv=this.create(this.view._clientDiv,null)},getBoundingClientRect:function(m,a){var b=this._ensureCreated(),e=this.view;if(void 0===m)return this._getLineBoundingClientRect(b,
|
|
!0);var c=e._model,l=b.ownerDocument,n=this.lineIndex,d=null;if(m<c.getLineEnd(n)){var s=c.getLineStart(n);this.forEach(function(a){var w=a.firstChild,c=this._nodeLength(a);if(s+c>m){var n=m-s;if(1===w.length)d=new u(a.getBoundingClientRect());else if(e._isRangeRects)c=l.createRange(),c.setStart(w,n),c.setEnd(w,n+1),d=new u(c.getBoundingClientRect());else if(f.isIE)c=l.body.createTextRange(),c.moveToElementText(a),c.collapse(),(w=0===n&&8===f.isIE)&&(n=1),c.moveEnd("character",n+1),c.moveStart("character",
|
|
n),d=new u(c.getBoundingClientRect()),w&&(d.left=a.getClientRects()[0].left);else{var g=w.data;a.removeChild(w);a.appendChild(l.createTextNode(g.substring(0,n)));var h=f.createElement(l,"span");h.appendChild(l.createTextNode(g.substring(n,n+1)));a.appendChild(h);a.appendChild(l.createTextNode(g.substring(n+1)));d=new u(h.getBoundingClientRect());a.innerHTML="";a.appendChild(w);this._createdDiv||(a=e._getSelection(),(s<=a.start&&a.start<s+c||s<=a.end&&a.end<s+c)&&e._updateDOMSelection())}f.isIE&&(n=
|
|
b.ownerDocument.defaultView||b.ownerDocument.parentWindow,a=n.screen.logicalXDPI/n.screen.deviceXDPI,n=n.screen.logicalYDPI/n.screen.deviceYDPI,d.left*=a,d.right*=a,d.top*=n,d.bottom*=n);return!1}s+=c;return!0})}c=this.getBoundingClientRect();d||(e._wrapMode?(n=this.getClientRects(),d=n[n.length-1],d.left=d.right,d.left+=c.left,d.top+=c.top,d.right+=c.left,d.bottom+=c.top):(d=new u(c),d.left=d.right));if(a||void 0===a)d.left-=c.left,d.top-=c.top,d.right-=c.left,d.bottom-=c.top;return d},forEach:function(m){for(var a=
|
|
this._ensureCreated().firstChild;a;){var b=a.nextSibling;if(!a.ignore&&!m.call(this,a))break;a=b}},_getClientRects:function(m,a){var b,c,e,n;if(!m._rectsCache){b=m.getClientRects();c=Array(b.length);for(n=0;n<b.length;n++)e=c[n]=new u(b[n]),e.left-=a.left,e.top-=a.top,e.right-=a.left,e.bottom-=a.top;m._rectsCache=c}b=m._rectsCache;c=[b.length];for(n=0;n<b.length;n++)c[n]=new u(b[n]);return c},getClientRects:function(m){if(!this.view._wrapMode)return[this.getBoundingClientRect()];var a=[],b=this._ensureCreated().getBoundingClientRect();
|
|
this.forEach(function(m){m=this._getClientRects(m,b);for(var c=0;c<m.length;c++){var e=m[c],n,l;if(e.top!==e.bottom){var d=e.top+(e.bottom-e.top)/2;for(n=0;n<a.length&&!(l=a[n],l.top<=d&&d<l.bottom);n++);n===a.length?a.push(e):(e.left<l.left&&(l.left=e.left),e.top<l.top&&(l.top=e.top),e.right>l.right&&(l.right=e.right),e.bottom>l.bottom&&(l.bottom=e.bottom))}}return!0});return void 0!==m?a[m]:a},_getLineBoundingClientRect:function(m,a){var b=new u(m.getBoundingClientRect());if(!this.view._wrapMode){b.right=
|
|
b.left;for(var e=m.lastChild;e&&e.ignoreChars===e.firstChild.length;)e=e.previousSibling;e&&(e=e.getBoundingClientRect(),b.right=e.right+n(m).right)}a&&(e=n(m),b.left+=e.left,b.right-=e.right);return b},getLineCount:function(){return!this.view._wrapMode?1:this.getClientRects().length},getLineIndex:function(m){if(!this.view._wrapMode)return 0;var a=this.getClientRects();m=this.getBoundingClientRect(m);m=m.top+(m.bottom-m.top)/2;for(var b=0;b<a.length;b++)if(a[b].top<=m&&m<a[b].bottom)return b;return a.length-
|
|
1},getLineStart:function(m){if(!this.view._wrapMode||0===m)return this.view._model.getLineStart(this.lineIndex);var a=this.getClientRects();return this.getOffset(a[m].left+1,a[m].top+1)},_nodeLength:function(m){if(!m||m.ignore)return 0;var a=m.firstChild.length;m.ignoreChars&&(a-=m.ignoreChars);return a},getModelOffset:function(m,a){if(!m)return 0;var b=0;this.forEach(function(e){var c=e.firstChild;if(c===m)return e.ignoreChars&&(b-=e.ignoreChars),b+=a,!1;e.ignoreChars&&(b-=e.ignoreChars);b+=c.data.length;
|
|
return!0});return Math.max(0,b)+this.view._model.getLineStart(this.lineIndex)},getNodeOffset:function(m){var a=0,b,e,c=this.view._model,n=c.getLineStart(this.lineIndex),l=m-n,d=c.getLineEnd(this.lineIndex)-n;this.forEach(function(m){var c=m.firstChild,n=this._nodeLength(m);if(n+a>l||a+n>=d)return b=c,e=l-a,m.ignoreChars&&(0<n&&e===n)&&(e+=m.ignoreChars),!1;a+=n;return!0});return{node:b,offset:e}},getText:function(m){var a="",b=0;this.forEach(function(e){var c;if(e.ignoreChars){c=e.lastChild;for(var n=
|
|
0,l=[],d=-1;c;){var f=c.data;if(f)for(var s=f.length-1;0<=s;s--){var g=f.substring(s,s+1);n<e.ignoreChars&&(" "===g||"\ufeff"===g)?n++:l.push("\u00a0"===g?"\t":g)}m===c&&(d=l.length);c=c.previousSibling}l=l.reverse().join("");-1!==d&&(b=a.length+l.length-d);a+=l}else for(c=e.firstChild;c;)m===c&&(b=a.length),a+=c.data,c=c.nextSibling;return!0});return{text:a,offset:b}},getOffset:function(m,a){function b(e,s,B){var q=e.firstChild,k=u._nodeLength(e),A=g.ownerDocument,x=A.defaultView||A.parentWindow,
|
|
v=f.isIE?x.screen.logicalXDPI/x.screen.deviceXDPI:1,p=f.isIE?x.screen.logicalYDPI/x.screen.deviceYDPI:1,y,r,z,x=B.left+h.left,t,C;if(f.isIE||c._isRangeRects){for(var A=c._isRangeRects?A.createRange():A.body.createTextRange(),O=k,G=-1;1<O-G;){var L=Math.floor((O+G)/2);B=G+1;y=L===k-1&&e.ignoreChars?q.length:L+1;t=0===B&&8===f.isIE;c._isRangeRects?(A.setStart(q,B),A.setEnd(q,y)):(t&&(B=1),A.moveToElementText(e),A.move("character",B),A.moveEnd("character",y-B));C=A.getClientRects();for(var R=!1,N=0;N<
|
|
C.length;N++)if(B=C[N],y=(t?x:B.left)*v-h.left,z=B.right*v-h.left,r=B.top*p-h.top,B=B.bottom*p-h.top,y<=m&&m<z&&(!c._wrapMode||r<=a&&a<B)){R=!0;break}R?O=L:G=L}s+=O;B=O;y=O===k-1&&e.ignoreChars?q.length:Math.min(O+1,q.length);c._isRangeRects?(A.setStart(q,B),A.setEnd(q,y)):(A.moveToElementText(e),A.move("character",B),A.moveEnd("character",y-B));C=A.getClientRects();k=!1;0<C.length&&(B=C[0],y=(t?x:B.left)*v-h.left,z=B.right*v-h.left,k=m>y+(z-y)/2);e=s-d;q=n.getLine(l);v=q.charCodeAt(e);55296<=v&&
|
|
56319>=v&&k?e<q.length&&(v=q.charCodeAt(e+1),56320<=v&&57343>=v&&(s+=1)):56320<=v&&(57343>=v&&!k)&&0<e&&(v=q.charCodeAt(e-1),55296<=v&&56319>=v&&(s-=1));k&&s++}else{v=[];for(t=0;t<k;t++)v.push("\x3cspan\x3e"),t===k-1?v.push(q.data.substring(t)):v.push(q.data.substring(t,t+1)),v.push("\x3c/span\x3e");e.innerHTML=v.join("");for(v=e.firstChild;v;){B=v.getBoundingClientRect();y=B.left-h.left;z=B.right-h.left;if(y<=m&&m<z){m>y+(z-y)/2&&s++;break}s++;v=v.nextSibling}u._createdDiv||(e.innerHTML="",e.appendChild(q),
|
|
e=c._getSelection(),(s<=e.start&&e.start<s+k||s<=e.end&&e.end<s+k)&&c._updateDOMSelection())}return s}function e(b){if(b.ignore)return null;b=u._getClientRects(b,h);for(var n=0;n<b.length;n++){var l=b[n];if(l.left<=m&&m<l.right&&(!c._wrapMode||l.top<=a&&a<l.bottom))return l}return null}var c=this.view,n=c._model,l=this.lineIndex,d=n.getLineStart(l),s=n.getLineEnd(l);if(d===s)return d;var g=this._ensureCreated(),h=this.getBoundingClientRect(),u=this,q,k;if(c._wrapMode){q=this.getClientRects();a<q[0].top&&
|
|
(a=q[0].top);for(var x=0;x<q.length&&!(k=q[x],k.top<=a&&a<k.bottom);x++);m<k.left&&(m=k.left);m>k.right&&(m=k.right-1)}else 0>m&&(m=0),m>h.right-h.left&&(m=h.right-h.left);var v,p;if(this._lastHitChild&&this._lastHitChild.parentNode){if(v=this._lastHitOffset,p=this._lastHitChild,k=e(p),!k){q=v;for(var x=v+this._nodeLength(p),y=p.previousSibling,r=p.nextSibling;y||r;){if(y){q-=this._nodeLength(y);if(k=e(y)){p=y;v=q;break}y=y.previousSibling}if(r){if(k=e(r)){p=r;v=x;break}x+=this._nodeLength(r);r=r.nextSibling}}}}else v=
|
|
d,this.forEach(function(m){p=m;if(k=e(p))return!1;v+=this._nodeLength(p);return!0});p&&k&&(this._lastHitChild=p,this._lastHitOffset=v,v=b(p,v,k));return Math.min(s,Math.max(d,v))},getNextOffset:function(m,a){if("line"===a.unit){var b=this.view._model,e=b.getLineAtOffset(m);if(0<a.count)return a.count--,b.getLineEnd(e);a.count++;return b.getLineStart(e)}return"wordend"===a.unit||"wordWS"===a.unit||"wordendWS"===a.unit?this._getNextOffset_W3C(m,a):f.isIE?this._getNextOffset_IE(m,a):this._getNextOffset_W3C(m,
|
|
a)},_getNextOffset_W3C:function(m,a){function b(m){return 33<=m&&47>=m||58<=m&&64>=m||91<=m&&94>=m||96===m||123<=m&&126>=m}function e(m){return 32===m||9===m}var c=this.view._model,n=c.getLineAtOffset(m),l=c.getLine(n),d=c.getLineStart(n),c=c.getLineEnd(n),n=l.length,f=m-d,s,g=0>a.count?-1:1;if("word"===a.unit||"wordend"===a.unit||"wordWS"===a.unit||"wordendWS"===a.unit)for(var h,u,q;0!==a.count;){if(0<a.count){if(f===n)return c;s=l.charCodeAt(f);h=b(s);u=!h&&!e(s);for(f++;f<n;){s=l.charCodeAt(f);
|
|
if("wordWS"!==a.unit&&"wordendWS"!==a.unit){q=b(s);if("wordend"===a.unit){if(!q&&h)break}else if(q&&!h)break;s=!q&&!e(s)}else s=!e(s);if("wordend"===a.unit||"wordendWS"===a.unit){if(!s&&u)break}else if(s&&!u)break;u=s;h=q;f++}}else{if(0===f)return d;f--;s=l.charCodeAt(f);h=b(s);for(u=!h&&!e(s);0<f;){s=l.charCodeAt(f-1);if("wordWS"!==a.unit&&"wordendWS"!==a.unit){q=b(s);if("wordend"===a.unit){if(q&&!h)break}else if(!q&&h)break;s=!q&&!e(s)}else s=!e(s);if("wordend"===a.unit||"wordendWS"===a.unit){if(s&&
|
|
!u)break}else if(!s&&u)break;u=s;h=q;f--}}a.count-=g}else for(;0!==a.count&&0<=f+g&&f+g<=n;)f+=g,s=l.charCodeAt(f),56320<=s&&57343>=s&&0<f&&(s=l.charCodeAt(f-1),55296<=s&&56319>=s&&(f+=g)),a.count-=g;return d+f},_getNextOffset_IE:function(m,a){var b=this._ensureCreated(),e=this.view._model,c=this.lineIndex,n=0,l;l=e.getLineStart(c);var d=e.getLine(c),f=e.getLineStart(c),s=b.ownerDocument,g=0>a.count?-1:1;if(m===e.getLineEnd(c)){for(b=b.lastChild;b&&b.ignoreChars===b.firstChild.length;)b=b.previousSibling;
|
|
if(!b)return l;n=s.body.createTextRange();n.moveToElementText(b);l=n.text.length;n.moveEnd(a.unit,g);n=m+n.text.length-l}else if(m===l&&0>a.count)n=l;else for(b=b.firstChild;b;){e=this._nodeLength(b);if(l+e>m){n=s.body.createTextRange();if(m===l&&0>a.count){for(l=b.previousSibling;l&&(!l.firstChild||!l.firstChild.length);)l=l.previousSibling;n.moveToElementText(l?l:b.previousSibling)}else n.moveToElementText(b),n.collapse(),n.moveEnd("character",m-l);l=n.text.length;n.moveEnd(a.unit,g);n=m+n.text.length-
|
|
l;break}l=e+l;b=b.nextSibling}l=n-f;n=d.charCodeAt(l);56320<=n&&57343>=n&&0<l&&(n=d.charCodeAt(l-1),55296<=n&&56319>=n&&(l+=g));a.count-=g;return l+f},updateLinks:function(){var m=this._ensureCreated();if(this.hasLink){var a=this;this.forEach(function(b){var e=b.viewStyle;e&&(e.tagName&&"a"===e.tagName.toLowerCase())&&m.replaceChild(a._createSpan(m,b.firstChild.data,e),b);return!0})}},destroy:function(){var m=this._createdDiv;m&&(m.parentNode.removeChild(m),this._createdDiv=null)}};v.prototype={addKeyMode:function(m,
|
|
a){var b=this._keyModes;void 0!==a?b.splice(a,0,m):b.push(m);m._modeAdded&&m._modeAdded()},addRuler:function(m,a){var b=this._rulers;if(void 0!==a){var e,c;for(c=e=0;e<b.length&&c<a;e++)m.getLocation()===b[e].getLocation()&&c++;b.splice(c,0,m);a=c}else b.push(m);this._createRuler(m,a);m.setView(this);this._update()},computeSize:function(){var m=0,a=0,b=this._model,e=this._clientDiv;if(!e)return{width:m,height:a};var c=e.style.width;f.isWebkit&&(e.style.width="0x7fffffffpx");for(var b=b.getLineCount(),
|
|
n=0;n<b;n++){var l=this._getLine(n),d=l.getBoundingClientRect(),m=Math.max(m,d.right-d.left),a=a+(d.bottom-d.top);l.destroy()}f.isWebkit&&(e.style.width=c);e=this._getViewPadding();m+=e.right+e.left+this._metrics.scrollWidth;a+=e.bottom+e.top+this._metrics.scrollWidth;return{width:m,height:a}},convert:function(m,a,b){if(!this._clientDiv)return m;var e=this._getScroll(),c=this._getViewPadding(),n=this._viewDiv.getBoundingClientRect();"document"===a&&(void 0!==m.x&&(m.x+=-e.x+n.left+c.left),void 0!==
|
|
m.y&&(m.y+=-e.y+n.top+c.top));"document"===b&&(void 0!==m.x&&(m.x+=e.x-n.left-c.left),void 0!==m.y&&(m.y+=e.y-n.top-c.top));return m},destroy:function(){for(var m=0;m<this._rulers.length;m++)this._rulers[m].setView(null);this.rulers=null;this._destroyView();this.onDestroy({type:"Destroy"});this._parent=null;this._model&&this._model.destroy&&this._model.destroy();this._actions=this._keyModes=this._doubleClickSelection=this._selection=this._theme=this._model=null},focus:function(){this._clientDiv&&
|
|
(this._updateDOMSelection(),this._clientDiv.focus(),this._updateDOMSelection())},hasFocus:function(){return this._hasFocus},getActionDescription:function(m){if(m=this._actions[m])return m.actionDescription},getActions:function(m){var a=[],b=this._actions,e;for(e in b)b.hasOwnProperty(e)&&(m||!b[e].defaultHandler)&&a.push(e);return a},getBottomIndex:function(m){return!this._clientDiv?0:this._getBottomIndex(m)},getBottomPixel:function(){return!this._clientDiv?0:this._getScroll().y+this._getClientHeight()},
|
|
getCaretOffset:function(){return this._getSelection().getCaret()},getClientArea:function(){if(!this._clientDiv)return{x:0,y:0,width:0,height:0};var m=this._getScroll();return{x:m.x,y:m.y,width:this._getClientWidth(),height:this._getClientHeight()}},getHorizontalPixel:function(){return!this._clientDiv?0:this._getScroll().x},getKeyBindings:function(m){for(var a=[],b=this._keyModes,e=0;e<b.length;e++)a=a.concat(b[e].getKeyBindings(m));return a},getKeyModes:function(){return this._keyModes.slice(0)},
|
|
getLineHeight:function(m){return!this._clientDiv?0:this._getLineHeight(m)},getLineIndex:function(m){return!this._clientDiv?0:this._getLineIndex(m)},getLinePixel:function(m){return!this._clientDiv?0:this._getLinePixel(m)},getLocationAtOffset:function(m){if(!this._clientDiv)return{x:0,y:0};var a=this._model;m=Math.min(Math.max(0,m),a.getCharCount());var a=a.getLineAtOffset(m),b=this._getLine(a);m=b.getBoundingClientRect(m);b.destroy();b=m.left;a=this._getLinePixel(a)+m.top;return{x:b,y:a}},getNextOffset:function(m,
|
|
a){var b=new s(m,m,!1);this._doMove(a,b);return b.getCaret()},getOptions:function(){var m;if(0===arguments.length)m=this._defaultOptions();else if(1===arguments.length){if(m=arguments[0],"string"===typeof m)return d(this["_"+m])}else{m={};for(var a in arguments)arguments.hasOwnProperty(a)&&(m[arguments[a]]=void 0)}for(var b in m)m.hasOwnProperty(b)&&(m[b]=d(this["_"+b]));return m},getModel:function(){return this._model},getOffsetAtLocation:function(m,a){if(!this._clientDiv)return 0;var b=this._getLineIndex(a),
|
|
e=this._getLine(b),b=e.getOffset(m,a-this._getLinePixel(b));e.destroy();return b},getLineAtOffset:function(m){return this.getModel().getLineAtOffset(m)},getLineStart:function(m){this.getModel().getLineStart(m)},getRulers:function(){return this._rulers.slice(0)},getSelection:function(){var m=this._getSelection();return{start:m.start,end:m.end}},getText:function(m,a){return this._model.getText(m,a)},getTopIndex:function(m){return!this._clientDiv?0:this._getTopIndex(m)},getTopPixel:function(){return!this._clientDiv?
|
|
0:this._getScroll().y},invokeAction:function(m,a,b){if(this._clientDiv){if(m=this._actions[m]){if(!a&&m.handler&&m.handler(b))return!0;if(m.defaultHandler)return"boolean"===typeof m.defaultHandler(b)}return!1}},isDestroyed:function(){return!this._clientDiv},onContextMenu:function(m){return this.dispatchEvent(m)},onDragStart:function(m){return this.dispatchEvent(m)},onDrag:function(m){return this.dispatchEvent(m)},onDragEnd:function(m){return this.dispatchEvent(m)},onDragEnter:function(m){return this.dispatchEvent(m)},
|
|
onDragOver:function(m){return this.dispatchEvent(m)},onDragLeave:function(m){return this.dispatchEvent(m)},onDrop:function(m){return this.dispatchEvent(m)},onDestroy:function(m){return this.dispatchEvent(m)},onLineStyle:function(m){return this.dispatchEvent(m)},onKeyDown:function(m){return this.dispatchEvent(m)},onKeyPress:function(m){return this.dispatchEvent(m)},onKeyUp:function(m){return this.dispatchEvent(m)},onModelChanged:function(m){return this.dispatchEvent(m)},onModelChanging:function(m){return this.dispatchEvent(m)},
|
|
onModify:function(m){return this.dispatchEvent(m)},onMouseDown:function(m){return this.dispatchEvent(m)},onMouseUp:function(m){return this.dispatchEvent(m)},onMouseMove:function(m){return this.dispatchEvent(m)},onMouseOver:function(m){return this.dispatchEvent(m)},onMouseOut:function(m){return this.dispatchEvent(m)},onTouchStart:function(m){return this.dispatchEvent(m)},onTouchMove:function(m){return this.dispatchEvent(m)},onTouchEnd:function(m){return this.dispatchEvent(m)},onOptions:function(m){return this.dispatchEvent(m)},
|
|
onSelection:function(m){return this.dispatchEvent(m)},onScroll:function(m){return this.dispatchEvent(m)},onVerify:function(m){return this.dispatchEvent(m)},onFocus:function(m){return this.dispatchEvent(m)},onBlur:function(m){return this.dispatchEvent(m)},redraw:function(){if(!(0<this._redrawCount)){var m=this._model.getLineCount();this.redrawRulers(0,m);this.redrawLines(0,m)}},redrawRulers:function(m,a){if(!(0<this._redrawCount))for(var b=this.getRulers(),e=0;e<b.length;e++)this.redrawLines(m,a,b[e])},
|
|
redrawLines:function(m,a,b){if(!(0<this._redrawCount)&&(void 0===m&&(m=0),void 0===a&&(a=this._model.getLineCount()),m!==a)){var e=this._clientDiv;if(e){if(b)for(e=this._getRulerParent(b).firstChild;e&&e._ruler!==b;)e=e.nextSibling;b?e.rulerChanged=!0:this._lineHeight&&this._resetLineHeight(m,a);if(!b||"page"===b.getOverview())for(e=e.firstChild;e;){var c=e.lineIndex;m<=c&&c<a&&(e.lineChanged=!0);e=e.nextSibling}!b&&(!this._wrapMode&&m<=this._maxLineIndex&&this._maxLineIndex<a)&&(this._checkMaxLineIndex=
|
|
this._maxLineIndex,this._maxLineIndex=-1,this._maxLineWidth=0);this.dispatchEvent({type:"Redraw",startLine:m,endLine:a,ruler:b});this._queueUpdate()}}},redrawRange:function(m,a){if(!(0<this._redrawCount)){var b=this._model;void 0===m&&(m=0);void 0===a&&(a=b.getCharCount());var e=b.getLineAtOffset(m),b=b.getLineAtOffset(Math.max(m,a-1))+1;this.redrawLines(e,b)}},removeKeyMode:function(m){for(var a=this._keyModes,b=0;b<a.length;b++)if(a[b]===m){a.splice(b,1);break}m._modeRemoved&&m._modeRemoved()},
|
|
removeRuler:function(m){for(var a=this._rulers,b=0;b<a.length;b++)if(a[b]===m){a.splice(b,1);m.setView(null);this._destroyRuler(m);this._update();break}},resize:function(){this._clientDiv&&this._handleResize(null)},setAction:function(m,a,b){if(m){var e=this._actions,c=e[m];c||(c=e[m]={});c.handler=a;void 0!==b&&(c.actionDescription=b)}},setKeyBinding:function(m,a){this._keyModes[0].setKeyBinding(m,a)},setCaretOffset:function(m,a,b){var e=this._model.getCharCount();m=Math.max(0,Math.min(m,e));m=new s(m,
|
|
m,!1);this._setSelection(m,void 0===a||a,!0,b)},setHorizontalPixel:function(m){this._clientDiv&&(m=Math.max(0,m),this._scrollView(m-this._getScroll().x,0))},setRedraw:function(m){m?0===--this._redrawCount&&this.redraw():this._redrawCount++},setModel:function(m){if(m!==this._model){m=m||new t.TextModel;this._model.removeEventListener("preChanging",this._modelListener.onChanging);this._model.removeEventListener("postChanged",this._modelListener.onChanged);var a=this._model.getLineCount(),b=this._model.getCharCount(),
|
|
e=m.getLineCount(),c=m.getCharCount(),n={type:"ModelChanging",text:m.getText(),start:0,removedCharCount:b,addedCharCount:c,removedLineCount:a,addedLineCount:e};this.onModelChanging(n);this._model=m;n={type:"ModelChanged",start:0,removedCharCount:b,addedCharCount:c,removedLineCount:a,addedLineCount:e};this.onModelChanged(n);this._model.addEventListener("preChanging",this._modelListener.onChanging);this._model.addEventListener("postChanged",this._modelListener.onChanged);this._reset();this._update()}},
|
|
setOptions:function(m){var b=this._defaultOptions(),e;for(e in m)if(m.hasOwnProperty(e)){var c=m[e];if(!a(this["_"+e],c)){var n=b[e]?b[e].update:null;n?n.call(this,c):this["_"+e]=d(c)}}this.onOptions({type:"Options",options:m})},setSelection:function(m,a,b,e){var c=m>a;if(c){var n=m;m=a;a=n}n=this._model.getCharCount();m=Math.max(0,Math.min(m,n));a=Math.max(0,Math.min(a,n));m=new s(m,a,c);this._setSelection(m,void 0===b||b,!0,e)},setText:function(m,a,b){var e=void 0===a&&void 0===b;void 0===a&&(a=
|
|
0);void 0===b&&(b=this._model.getCharCount());e&&(this._variableLineHeight=!1);this._modifyContent({text:m,start:a,end:b,_code:!0},!e);e&&(this._columnX=-1,this._setSelection(new s(0,0,!1),!0),13>f.isFirefox&&this._fixCaret())},setTopIndex:function(m,a){this._clientDiv&&this._scrollViewAnimated(0,this._getLinePixel(Math.max(0,m))-this._getScroll().y,a)},setTopPixel:function(m,a){this._clientDiv&&this._scrollViewAnimated(0,Math.max(0,m)-this._getScroll().y,a)},showSelection:function(m,a){return this._showCaret(m?
|
|
!1:!0,a,m)},update:function(m,a){this._clientDiv&&((m||this._metrics.invalid)&&this._updateStyle(),void 0===a||a?this._update():this._queueUpdate())},_handleRootMouseDown:function(m){this._cancelCheckSelection();if(!this._ignoreEvent(m)){13>f.isFirefox&&1===m.which&&(this._clientDiv.contentEditable=!1,this._ignoreBlur=(this._overlayDiv||this._clientDiv).draggable=!0);var a=this._overlayDiv||this._clientDiv;9>f.isIE&&(a=this._viewDiv);for(var b=m.target?m.target:m.srcElement;b;){if(a===b||b.className&&
|
|
-1!==b.className.indexOf("textViewFind"))return;b=b.parentNode}m.preventDefault&&m.preventDefault();m.stopPropagation&&m.stopPropagation();if(!this._isW3CEvents){var e=this;this._getWindow().setTimeout(function(){e._clientDiv.focus()},0)}}},_handleRootMouseUp:function(m){this._ignoreEvent(m)||(13>f.isFirefox&&1===m.which&&(this._clientDiv.contentEditable=!0,(this._overlayDiv||this._clientDiv).draggable=!1),f.isFirefox&&1===m.which&&(this._fixCaret(),this._ignoreBlur=!1))},_handleBlur:function(){this._cancelCheckSelection();
|
|
if(!this._ignoreBlur){this._commitIME();this._hasFocus=!1;if(9>f.isIE&&!this._getSelection().isEmpty()){var m=this._rootDiv,a=f.createElement(m.ownerDocument,"div");m.appendChild(a);m.removeChild(a)}this._cursorDiv&&(this._cursorDiv.style.display="none");if(this._selDiv1)if(this._selDiv1.style.background="lightgray",this._selDiv2.style.background="lightgray",this._selDiv3.style.background="lightgray",m=this._getWindow(),a=this._selDiv1.ownerDocument,m.getSelection){a=m.getSelection();for(m=a.anchorNode;m;){if(m===
|
|
this._clientDiv){0<a.rangeCount&&a.removeAllRanges();break}m=m.parentNode}}else if(a.selection){this._ignoreSelect=!1;for(m=a.selection.createRange().parentElement();m;){if(m===this._clientDiv){a.selection.empty();break}m=m.parentNode}this._ignoreSelect=!0}if(!this._ignoreFocus)this.onBlur({type:"Blur"})}},_handleCompositionStart:function(m){this._ignoreEvent(m)||(this._startIME(),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null))},_handleCompositionEnd:function(m){this._ignoreEvent(m)||
|
|
this._commitIME(m.data)},_handleContextMenu:function(m){if(!this._ignoreEvent(m)){f.isIE&&3===this._lastMouseButton&&this._updateDOMSelection();var a=!1;this.isListening("ContextMenu")?(a=this._createMouseEvent("ContextMenu",m),a.screenX=m.screenX,a.screenY=m.screenY,this.onContextMenu(a),a=a.defaultPrevented):f.isMac&&(f.isFirefox&&0===m.button)&&(a=!0);if(a)return m.preventDefault&&m.preventDefault(),!1;this._contextMenuOpen=!0;f.isFirefox&&(this._checkSelectionChange=!0,this._pollSelectionChange(!0))}},
|
|
_handleCopy:function(m){this._cancelCheckSelection();if(!this._ignoreEvent(m)&&!this._ignoreCopy&&this._doCopy(m))return m.preventDefault&&m.preventDefault(),!1},_handleCut:function(m){this._cancelCheckSelection();if(!this._ignoreEvent(m)&&this._doCut(m))return m.preventDefault&&m.preventDefault(),!1},_handleDataModified:function(m){this._ignoreEvent(m)||this._startIME()},_handleDblclick:function(m){this._ignoreEvent(m)||(this._lastMouseTime=m.timeStamp?m.timeStamp:(new Date).getTime(),2!==this._clickCount&&
|
|
(this._clickCount=2,this._handleMouse(m)))},_handleDragStart:function(m){if(!this._ignoreEvent(m)){if(13>f.isFirefox){var a=this;this._getWindow().setTimeout(function(){a._clientDiv.contentEditable=!0;a._clientDiv.draggable=!1;a._ignoreBlur=!1},0)}if(this.isListening("DragStart")&&-1!==this._dragOffset)this._isMouseDown=!1,this.onDragStart(this._createMouseEvent("DragStart",m)),this._dragOffset=-1;else return m.preventDefault&&m.preventDefault(),!1}},_handleDrag:function(m){if(!this._ignoreEvent(m)&&
|
|
this.isListening("Drag"))this.onDrag(this._createMouseEvent("Drag",m))},_handleDragEnd:function(m){if(!this._ignoreEvent(m)){this._dropTarget=!1;this._dragOffset=-1;if(this.isListening("DragEnd"))this.onDragEnd(this._createMouseEvent("DragEnd",m));13>f.isFirefox&&(this._fixCaret(),"none"===m.dataTransfer.dropEffect&&!m.dataTransfer.mozUserCancelled&&this._fixCaret())}},_handleDragEnter:function(m){if(!this._ignoreEvent(m)){var a=!0;this._dropTarget=!0;this.isListening("DragEnter")&&(a=!1,this.onDragEnter(this._createMouseEvent("DragEnter",
|
|
m)));if(f.isWebkit||a)return m.preventDefault&&m.preventDefault(),!1}},_handleDragOver:function(m){if(!this._ignoreEvent(m)){var a=!0;this.isListening("DragOver")&&(a=!1,this.onDragOver(this._createMouseEvent("DragOver",m)));if(f.isWebkit||a)return a&&(m.dataTransfer.dropEffect="none"),m.preventDefault&&m.preventDefault(),!1}},_handleDragLeave:function(m){if(!this._ignoreEvent(m)&&(this._dropTarget=!1,this.isListening("DragLeave")))this.onDragLeave(this._createMouseEvent("DragLeave",m))},_handleDrop:function(m){if(!this._ignoreEvent(m)){this._dropTarget=
|
|
!1;if(this.isListening("Drop"))this.onDrop(this._createMouseEvent("Drop",m));m.preventDefault&&m.preventDefault();return!1}},_handleFocus:function(){this._hasFocus=!0;f.isIOS&&void 0!==this._lastTouchOffset?(this.setCaretOffset(this._lastTouchOffset,!0),this._lastTouchOffset=void 0):this._updateDOMSelection();this._cursorDiv&&(this._cursorDiv.style.display="block");if(this._selDiv1){var m=this._highlightRGB;this._selDiv1.style.background=m;this._selDiv2.style.background=m;this._selDiv3.style.background=
|
|
m}if(!this._ignoreFocus)this.onFocus({type:"Focus"})},_handleKeyDown:function(m){this._cancelCheckSelection();if(!this._ignoreEvent(m)){if(this.isListening("KeyDown")){var a=this._createKeyEvent("KeyDown",m);this.onKeyDown(a);if(a.defaultPrevented){f.isFirefox&&(this._keyDownPrevented=!0);m.preventDefault();return}}a=!1;switch(m.keyCode){case 16:case 17:case 18:case 91:a=!0;break;default:this._setLinksVisible(!1)}if(229===m.keyCode){if(this._readonly)return m.preventDefault&&m.preventDefault(),!1;
|
|
a=!0;f.isSafari&&f.isMac&&m.ctrlKey&&(a=!1,m.keyCode=129);a&&this._startIME()}else a||this._commitIME();if((f.isMac||f.isLinux)&&4>f.isFirefox||12.16>f.isOpera)return this._keyDownEvent=m,!0;if(this._doAction(m))return m.preventDefault?(m.preventDefault(),m.stopPropagation()):(m.cancelBubble=!0,m.returnValue=!1,m.keyCode=0),!1}},_handleKeyPress:function(m){if(!this._ignoreEvent(m))if(this._keyDownPrevented)m.preventDefault&&(m.preventDefault(),m.stopPropagation()),this._keyDownPrevented=void 0;else{if(f.isMac&&
|
|
f.isWebkit&&(63232<=m.keyCode&&63487>=m.keyCode||13===m.keyCode||8===m.keyCode)||((f.isMac||f.isLinux)&&4>f.isFirefox||12.16>f.isOpera)&&this._doAction(this._keyDownEvent))return m.preventDefault&&m.preventDefault(),!1;var a=f.isMac?m.metaKey:m.ctrlKey;if(void 0!==m.charCode&&a)switch(m.charCode){case 99:case 118:case 120:return!0}if(this.isListening("KeyPress")&&(a=this._createKeyEvent("KeyPress",m),this.onKeyPress(a),a.defaultPrevented)){m.preventDefault();return}if(this._doAction(m))return m.preventDefault?
|
|
(m.preventDefault(),m.stopPropagation()):(m.cancelBubble=!0,m.returnValue=!1,m.keyCode=0),!1;a=!1;if(f.isMac){if(m.ctrlKey||m.metaKey)a=!0}else if(f.isFirefox){if(m.ctrlKey||m.altKey)a=!0}else m.ctrlKey^m.altKey&&(a=!0);if(!a&&(a=f.isOpera?m.which:void 0!==m.charCode?m.charCode:m.keyCode,31<a))return this._doContent(String.fromCharCode(a)),m.preventDefault&&m.preventDefault(),!1}},_handleDocKeyUp:function(m){(f.isMac?m.metaKey:m.ctrlKey)||this._setLinksVisible(!1)},_handleKeyUp:function(m){if(!this._ignoreEvent(m)){if(this.isListening("KeyUp")){var a=
|
|
this._createKeyEvent("KeyUp",m);this.onKeyUp(a);if(a.defaultPrevented){m.preventDefault();return}}this._handleDocKeyUp(m);13===m.keyCode&&this._commitIME()}},_handleLinkClick:function(m){if(!(f.isMac?m.metaKey:m.ctrlKey))return m.preventDefault&&m.preventDefault(),!1},_handleMouse:function(m){var a=this._getWindow(),b=!0,e=a;if(f.isIE||f.isFirefox&&!this._overlayDiv)e=this._clientDiv;if(this._overlayDiv){this._hasFocus&&(this._ignoreFocus=!0);var c=this;a.setTimeout(function(){c.focus();c._ignoreFocus=
|
|
!1},0)}1===this._clickCount?(b=this._setSelectionTo(m.clientX,m.clientY,m.shiftKey,(!f.isOpera||12.16<=f.isOpera)&&this._hasFocus&&this.isListening("DragStart")))&&this._setGrab(e):(this._isW3CEvents&&this._setGrab(e),this._doubleClickSelection=null,this._setSelectionTo(m.clientX,m.clientY,m.shiftKey),this._doubleClickSelection=this._getSelection());return b},_handleMouseDown:function(a){if(!this._ignoreEvent(a)){if(this._linksVisible)if("A"!==(a.target||a.srcElement).tagName)this._setLinksVisible(!1);
|
|
else return;this._commitIME();var b=a.which;b||(4===a.button&&(b=2),2===a.button&&(b=3),1===a.button&&(b=1));var e=2!==b&&a.timeStamp?a.timeStamp:(new Date).getTime(),c=e-this._lastMouseTime,n=Math.abs(this._lastMouseX-a.clientX),l=Math.abs(this._lastMouseY-a.clientY),d=this._lastMouseButton===b;this._lastMouseX=a.clientX;this._lastMouseY=a.clientY;this._lastMouseTime=e;this._lastMouseButton=b;1===b&&(this._isMouseDown=!0,d&&c<=this._clickTime&&n<=this._clickDist&&l<=this._clickDist?this._clickCount++:
|
|
this._clickCount=1);if(this.isListening("MouseDown")&&(e=this._createMouseEvent("MouseDown",a),this.onMouseDown(e),e.defaultPrevented)){a.preventDefault();return}if(1===b&&this._handleMouse(a)&&(9<=f.isIE||f.isOpera||f.isChrome||f.isSafari||f.isFirefox&&!this._overlayDiv))this._hasFocus||this.focus(),a.preventDefault();f.isFirefox&&3===this._lastMouseButton&&this._updateDOMSelection()}},_handleMouseOver:function(a){if(!this._ignoreEvent(a)&&!this._animation&&this.isListening("MouseOver"))this.onMouseOver(this._createMouseEvent("MouseOver",
|
|
a))},_handleMouseOut:function(a){if(!this._ignoreEvent(a)&&!this._animation&&this.isListening("MouseOut"))this.onMouseOut(this._createMouseEvent("MouseOut",a))},_handleMouseMove:function(a){if(!this._animation){var b=this._isClientDiv(a);if(this.isListening("MouseMove")&&(b||this._isMouseDown)){var e=this._createMouseEvent("MouseMove",a);this.onMouseMove(e);if(e.defaultPrevented){a.preventDefault();return}}if(!this._dropTarget){e=this._linksVisible||this._lastMouseMoveX!==a.clientX||this._lastMouseMoveY!==
|
|
a.clientY;this._lastMouseMoveX=a.clientX;this._lastMouseMoveY=a.clientY;this._setLinksVisible(e&&!this._isMouseDown&&(f.isMac?a.metaKey:a.ctrlKey));this._checkOverlayScroll();if(!this._isW3CEvents){if(0===a.button)return this._setGrab(null),!0;if(!this._isMouseDown&&1===a.button&&0!==(this._clickCount&1)&&b)return this._clickCount=2,this._handleMouse(a,this._clickCount)}if(this._isMouseDown&&-1===this._dragOffset){b=a.clientX;a=a.clientY;var c=this._getViewPadding(),n=this._viewDiv.getBoundingClientRect(),
|
|
l=this._getClientWidth(),d=this._getClientHeight(),e=n.left+c.left,s=n.top+c.top,l=n.left+c.left+l,c=n.top+c.top+d;a<s?this._doAutoScroll("up",b,a-s):a>c?this._doAutoScroll("down",b,a-c):b<e&&!this._wrapMode?this._doAutoScroll("left",b-e,a):b>l&&!this._wrapMode?this._doAutoScroll("right",b-l,a):(this._endAutoScroll(),this._setSelectionTo(b,a,!0))}}}},_isClientDiv:function(a){var b=this._overlayDiv||this._clientDiv;for(a=a.target?a.target:a.srcElement;a;){if(b===a)return!0;a=a.parentNode}return!1},
|
|
_createKeyEvent:function(a,b){return{type:a,event:b,preventDefault:function(){this.defaultPrevented=!0}}},_createMouseEvent:function(a,b){var e=this.convert({x:b.clientX,y:b.clientY},"page","document");return{type:a,event:b,clickCount:this._clickCount,x:e.x,y:e.y,preventDefault:function(){this.defaultPrevented=!0}}},_createTouchEvent:function(a,b){var e=b.touches.length?this.convert({x:b.touches[0].clientX,y:b.touches[0].clientY},"page","document"):{};return{type:a,event:b,touchCount:b.touches.length,
|
|
x:e.x,y:e.y,preventDefault:function(){this.defaultPrevented=!0}}},_handleMouseUp:function(a){var b=a.which?0===a.button:1===a.button;if(this.isListening("MouseUp")&&(this._isClientDiv(a)||b&&this._isMouseDown)){var e=this._createMouseEvent("MouseUp",a);this.onMouseUp(e);if(e.defaultPrevented){a.preventDefault();this._isMouseDown=!1;return}}this._linksVisible||(b&&this._isMouseDown&&(-1!==this._dragOffset&&(e=this._getSelection(),e.extend(this._dragOffset),e.collapse(),this._setSelection(e,!0,!0),
|
|
this._dragOffset=-1),this._isMouseDown=!1,this._endAutoScroll(),this._isW3CEvents&&this._setGrab(null)),b&&f.isFirefox&&(this._updateDOMSelection(),a.preventDefault()))},_handleMouseWheel:function(a){if(!this._noScroll){var b=this._getLineHeight(),e=0,c=0;f.isIE||f.isOpera?c=-a.wheelDelta/40*b:f.isFirefox?"wheel"===a.type?a.deltaMode?(e=Math.max(-256,Math.min(256,a.deltaX))*b,c=Math.max(-256,Math.min(256,a.deltaY))*b):(e=a.deltaX,c=a.deltaY):(b=f.isMac?3*a.detail:Math.max(-256,Math.min(256,a.detail))*
|
|
b,a.axis===a.HORIZONTAL_AXIS?e=b:c=b):f.isMac?(c=a.timeStamp-this._wheelTimeStamp,this._wheelTimeStamp=a.timeStamp,e=0!==a.wheelDeltaX%120?1:40>c?40/(40-c):40,c=0!==a.wheelDeltaY%120?1:40>c?40/(40-c):40,e=Math.ceil(-a.wheelDeltaX/e),-1<e&&0>e&&(e=-1),0<e&&1>e&&(e=1),c=Math.ceil(-a.wheelDeltaY/c),-1<c&&0>c&&(c=-1),0<c&&1>c&&(c=1)):(e=-a.wheelDeltaX,c=8*(-a.wheelDeltaY/120)*b);if(f.isSafari||f.isChrome&&f.isMac){for(b=a.target;b&&void 0===b.lineIndex;)b=b.parentNode;this._mouseWheelLine=b}b=this._getScroll();
|
|
this._scrollView(e,c);e=this._getScroll();if(b.x!==e.x||b.y!==e.y)return a.preventDefault&&a.preventDefault(),!1}},_handlePaste:function(a){this._cancelCheckSelection();if(!this._ignoreEvent(a)&&!this._ignorePaste&&this._doPaste(a)){if(f.isIE){var b=this;this._ignoreFocus=!0;this._getWindow().setTimeout(function(){b._updateDOMSelection();b._ignoreFocus=!1},0)}a.preventDefault&&a.preventDefault();return!1}},_handleResize:function(){var m=this._rootDiv.clientWidth,b=this._rootDiv.clientHeight;if(this._rootWidth!==
|
|
m||this._rootHeight!==b)this._rootWidth!==m&&this._wrapMode&&this._resetLineHeight(),this._rootWidth=m,this._rootHeight=b,m=9>f.isIE,b=this._calculateMetrics(),a(b,this._metrics)||(this._variableLineHeight&&(this._variableLineHeight=!1,this._resetLineHeight()),this._metrics=b,m=!0),m?this._queueUpdate():this._update(),this.dispatchEvent({type:"Resize"})},_handleRulerEvent:function(a){for(var b=a.target?a.target:a.srcElement,e=b.lineIndex;b&&!b._ruler;)void 0===e&&void 0!==b.lineIndex&&(e=b.lineIndex),
|
|
b=b.parentNode;var c=b?b._ruler:null;if(void 0===e&&c&&"document"===c.getOverview()){var e=this._getClientHeight(),n=this._model.getLineCount(),l=this._getViewPadding(),d=this._viewDiv.getBoundingClientRect(),e=Math.floor((a.clientY-d.top-this._metrics.scrollWidth)*n/(e+l.top+l.bottom-2*this._metrics.scrollWidth));0<=e&&e<n||(e=void 0)}if(c)switch(a.type){case "click":if(c.onClick)c.onClick(e,a);break;case "dblclick":if(c.onDblClick)c.onDblClick(e,a);break;case "mousemove":if(c.onMouseMove)c.onMouseMove(e,
|
|
a);break;case "mouseover":if(c.onMouseOver)c.onMouseOver(e,a);break;case "mouseout":if(c.onMouseOut){for(n=a.relatedTarget;n&&n!==this._rootDiv;){if(n===b)return;n=n.parentNode}c.onMouseOut(e,a)}}},_handleScroll:function(){this._lastScrollTime=(new Date).getTime();var a=this._getScroll(!1),b=this._hScroll,e=this._vScroll;if(b!==a.x||e!==a.y)this._hScroll=a.x,this._vScroll=a.y,this._commitIME(),this._update(e===a.y),this.onScroll({type:"Scroll",oldValue:{x:b,y:e},newValue:a})},_handleSelectStart:function(a){var b=
|
|
this._contextMenuOpen;this._contextMenuOpen=!1;if(b)this._checkSelectionChange=!0;else if(this._ignoreSelect)return a&&a.preventDefault&&a.preventDefault(),!1},_getModelOffset:function(a,b){if(a){var e;e="DIV"===a.tagName?a:a.parentNode.parentNode;return!e._line?0:e._line.getModelOffset(a,b)}},_updateSelectionFromDOM:function(){if(!f.isIOS&&!f.isAndroid&&!this._checkSelectionChange)return!1;var a=this._getWindow().getSelection(),b=this._getModelOffset(a.anchorNode,a.anchorOffset),e=this._getModelOffset(a.focusNode,
|
|
a.focusOffset),c=this._getSelection();if(void 0===b||void 0===e||c.start===b&&c.end===e)return!1;if(this._checkSelectionChange){var c=this._getLineNext(),n=this._getLinePrevious();if(a.anchorNode===c.firstChild.firstChild&&0===a.anchorOffset&&a.focusNode===n.firstChild.firstChild&&0===a.focusOffset)return!1;if(a.anchorNode===c.firstChild.firstChild&&0===a.anchorOffset&&a.focusNode===n.lastChild.firstChild||a.anchorNode===this._clientDiv&&a.focusNode===this._clientDiv)b=0,e=this.getModel().getCharCount()}this._setSelection(new s(b,
|
|
e),!1,!1);this._checkSelectionChange=!1;return!0},_cancelCheckSelection:function(){this._checkSelectionChange&&(this._checkSelectionChange=!1,this._cancelPollSelectionChange())},_cancelPollSelectionChange:function(){this._selPollTimer&&(this._getWindow().clearTimeout(this._selPollTimer),this._selPollTimer=null)},_pollSelectionChange:function(a){var b=this,e=this._getWindow();this._cancelPollSelectionChange();this._selPollTimer=e.setTimeout(function(){b._selPollTimer=null;b._clientDiv&&!b._updateSelectionFromDOM()&&
|
|
a&&b._pollSelectionChange(a)},100)},_handleSelectionChange:function(){-1===this._imeOffset&&(f.isAndroid?this._pollSelectionChange():this._updateSelectionFromDOM())},_handleTextInput:function(a){if(!this._ignoreEvent(a)){this._imeOffset=-1;var b=this._getWindow().getSelection();if(b.anchorNode!==this._anchorNode||b.focusNode!==this._focusNode||b.anchorOffset!==this._anchorOffset||b.focusOffset!==this._focusOffset){for(var e=b.anchorNode;e&&void 0===e.lineIndex;)e=e.parentNode;if(e){var c=this._model,
|
|
n=e.lineIndex,l=c.getLine(n),d=l,s=0,c=c.getLineStart(n);0<b.rangeCount&&(b.getRangeAt(0).deleteContents(),n=e.ownerDocument.createTextNode(a.data),b.getRangeAt(0).insertNode(n),s=this._getDOMText(e,n),d=s.text,s=s.offset,n.parentNode.removeChild(n));e.lineRemoved=!0;for(e=0;l.charCodeAt(e)===d.charCodeAt(e)&&e<s;)e++;b=l.length-1;for(n=d.length-l.length;l.charCodeAt(b)===d.charCodeAt(b+n)&&b+n>=s+a.data.length;)b--;b++;l=d.substring(e,b+n);this._ignoreQueueUpdate=f.isSafari;this._modifyContent({text:l,
|
|
start:e+c,end:b+c,_ignoreDOMSelection:!0,_ignoreDOMSelection1:f.isChrome},!0);this._ignoreQueueUpdate=!1}}else this._doContent(a.data);a.preventDefault()}},_handleTouchStart:function(a){if(this.isListening("TouchStart")){var b=this._createTouchEvent("TouchStart",a);this.onTouchStart(b);if(b.defaultPrevented){a.preventDefault();return}if(this._noScroll)return}this._commitIME();b=this._getWindow();this._touchScrollTimer&&(this._vScrollDiv.style.display="none",this._hScrollDiv.style.display="none",b.clearInterval(this._touchScrollTimer),
|
|
this._touchScrollTimer=null);var e=a.touches;if(1===e.length){var e=e[0],c=e.clientX,n=e.clientY;this._touchStartX=c;this._touchStartY=n;if(f.isAndroid&&(n<e.pageY-b.pageYOffset||c<e.pageX-b.pageXOffset))c=e.pageX-b.pageXOffset,n=e.pageY-b.pageYOffset;b=this.convert({x:c,y:n},"page","document");this._lastTouchOffset=this.getOffsetAtLocation(b.x,b.y);this._touchStartTime=a.timeStamp;this._touching=!0}},_handleTouchMove:function(a){if(this.isListening("TouchMove")){var b=this._createTouchEvent("TouchMove",
|
|
a);this.onTouchMove(b);if(b.defaultPrevented){a.preventDefault();return}if(this._noScroll)return}b=a.touches;if(1===b.length){b=b[0];this._touchCurrentX=b.clientX;this._touchCurrentY=b.clientY;if(!this._touchScrollTimer&&200>a.timeStamp-this._touchStartTime){this._vScrollDiv.style.display="block";this._wrapMode||(this._hScrollDiv.style.display="block");var e=this,c=this._getWindow();this._touchScrollTimer=c.setInterval(function(){var a=0,b=0;if(e._touching)a=e._touchStartX-e._touchCurrentX,b=e._touchStartY-
|
|
e._touchCurrentY,e._touchSpeedX=a/10,e._touchSpeedY=b/10,e._touchStartX=e._touchCurrentX,e._touchStartY=e._touchCurrentY;else{if(0.1>Math.abs(e._touchSpeedX)&&0.1>Math.abs(e._touchSpeedY)){e._vScrollDiv.style.display="none";e._hScrollDiv.style.display="none";c.clearInterval(e._touchScrollTimer);e._touchScrollTimer=null;return}a=10*e._touchSpeedX;b=10*e._touchSpeedY;e._touchSpeedX*=0.95;e._touchSpeedY*=0.95}e._scrollView(a,b)},10)}this._touchScrollTimer&&a.preventDefault()}},_handleTouchEnd:function(a){if(this.isListening("TouchEnd")){var b=
|
|
this._createTouchEvent("TouchEnd",a);this.onTouchEnd(b);if(b.defaultPrevented){a.preventDefault();return}if(this._noScroll)return}0===a.touches.length&&(this._touching=!1)},_doAction:function(a){var b,e,c=this._keyModes;for(e=c.length-1;0<=e;e--)if(b=c[e],"function"===typeof b.match&&(b=b.match(a),void 0!==b))return this.invokeAction(b);return!1},_doMove:function(a,b){var e=this._model,c=b.getCaret(),n=e.getLineAtOffset(c);a.count||(a.count=1);for(;0!==a.count;){var l=e.getLineStart(n);if(0>a.count&&
|
|
c===l)if(0<n)"character"===a.unit&&a.count++,n--,b.extend(e.getLineEnd(n));else break;else if(0<a.count&&c===e.getLineEnd(n))if(n+1<e.getLineCount())"character"===a.unit&&a.count--,n++,b.extend(e.getLineStart(n));else break;else{var d=!1;a.expandTab&&("character"===a.unit&&0===(c-l)%this._tabSize)&&(l=e.getText(l,c),d=!/[^ ]/.test(l));d?(b.extend(c-this._tabSize),a.count+=0>a.count?1:-1):(l=this._getLine(n),b.extend(l.getNextOffset(c,a)),l.destroy())}c=b.getCaret()}return b},_doBackspace:function(a){var b=
|
|
this._getSelection();b.isEmpty()&&(a.count||(a.count=1),a.count*=-1,a.expandTab=this._expandTab,this._doMove(a,b));this._modifyContent({text:"",start:b.start,end:b.end},!0);return!0},_doCase:function(a){var b=this._getSelection();this._doMove(a,b);var e=this.getText(b.start,b.end);this._setSelection(b,!0);switch(a.type){case "lower":e=e.toLowerCase();break;case "capitalize":e=e.replace(/(?:^|\s)\S/g,function(a){return a.toUpperCase()});break;case "reverse":a="";for(b=0;b<e.length;b++){var c=e[b],
|
|
n=c.toLowerCase(),c=n!==c?n:c.toUpperCase();a+=c}e=a;break;default:e=e.toUpperCase()}this._doContent(e);return!0},_doContent:function(a){var b=this._getSelection();if(this._overwriteMode&&b.isEmpty()){var e=this._model,c=e.getLineAtOffset(b.end);b.end<e.getLineEnd(c)&&(e=this._getLine(c),b.extend(e.getNextOffset(b.getCaret(),{unit:"character",count:1})),e.destroy())}return this._modifyContent({text:a,start:b.start,end:b.end,_ignoreDOMSelection:!0},!0)},_doCopy:function(a){var b=this._getSelection();
|
|
return!b.isEmpty()?(b=this._getBaseText(b.start,b.end),this._setClipboardText(b,a)):!0},_doCursorNext:function(a){var b=this._getSelection();!b.isEmpty()&&!a.select?b.start=b.end:this._doMove(a,b);a.select||b.collapse();this._setSelection(b,!0);return!0},_doCursorPrevious:function(a){var b=this._getSelection();!b.isEmpty()&&!a.select?b.end=b.start:(a.count||(a.count=1),a.count*=-1,this._doMove(a,b));a.select||b.collapse();this._setSelection(b,!0);return!0},_doCut:function(a){var b=this._getSelection();
|
|
return!b.isEmpty()?(b=this._getBaseText(b.start,b.end),this._doContent(""),this._setClipboardText(b,a)):!0},_doDelete:function(a){var b=this._getSelection();b.isEmpty()&&this._doMove(a,b);this._modifyContent({text:"",start:b.start,end:b.end},!0);return!0},_doEnd:function(a){var b=this._getSelection(),e=this._model,c;if(a.ctrl)b.extend(e.getCharCount()),c=function(){};else{var n=b.getCaret(),l=e.getLineAtOffset(n);if(this._wrapMode){var d=this._getLine(l),n=d.getLineIndex(n),n=n===d.getLineCount()-
|
|
1?e.getLineEnd(l):d.getLineStart(n+1)-1;d.destroy()}else a.count&&0<a.count&&(l=Math.min(l+a.count-1,e.getLineCount()-1)),n=e.getLineEnd(l);b.extend(n)}a.select||b.collapse();this._setSelection(b,!0,!0,c);return!0},_doEnter:function(a){if(this._singleMode)return!0;var b=this._model,e=this._getSelection();this._doContent(b.getLineDelimiter());a&&a.noCursor&&(e.end=e.start,this._setSelection(e,!0));return!0},_doHome:function(a){var b=this._getSelection(),e=this._model,c;if(a.ctrl)b.extend(0),c=function(){};
|
|
else{var n=b.getCaret(),l=e.getLineAtOffset(n);this._wrapMode?(e=this._getLine(l),n=e.getLineIndex(n),n=e.getLineStart(n),e.destroy()):n=e.getLineStart(l);b.extend(n)}a.select||b.collapse();this._setSelection(b,!0,!0,c);return!0},_doLineDown:function(a){var b=this._model,e=this._getSelection(),c=e.getCaret(),n=b.getLineAtOffset(c),l=this._getLine(n),d=this._columnX,s=1,g=!1;if(-1===d||a.wholeLine||a.select&&f.isIE)d=a.wholeLine?b.getLineEnd(n+1):c,d=l.getBoundingClientRect(d).left;(c=l.getLineIndex(c))<
|
|
l.getLineCount()-1?s=l.getClientRects(c+1).top+1:(c=b.getLineCount()-1,g=n===c,a.count&&0<a.count?n=Math.min(n+a.count,c):n++);c=!1;if(g){if(a.select||f.isMac||f.isLinux)e.extend(b.getCharCount()),c=!0}else l.lineIndex!==n&&(l.destroy(),l=this._getLine(n)),e.extend(l.getOffset(d,s)),c=!0;c&&(a.select||e.collapse(),this._setSelection(e,!0,!0));this._columnX=d;l.destroy();return!0},_doLineUp:function(a){var b=this._model,e=this._getSelection(),c=e.getCaret(),n=b.getLineAtOffset(c),l=this._getLine(n),
|
|
d=this._columnX,s=!1,g;if(-1===d||a.wholeLine||a.select&&f.isIE)d=a.wholeLine?b.getLineStart(n-1):c,d=l.getBoundingClientRect(d).left;0<(c=l.getLineIndex(c))?g=l.getClientRects(c-1).top+1:(s=0===n,s||(a.count&&0<a.count?n=Math.max(n-a.count,0):n--,g=this._getLineHeight(n)-1));c=!1;if(s){if(a.select||f.isMac||f.isLinux)e.extend(0),c=!0}else l.lineIndex!==n&&(l.destroy(),l=this._getLine(n)),e.extend(l.getOffset(d,g)),c=!0;c&&(a.select||e.collapse(),this._setSelection(e,!0,!0));this._columnX=d;l.destroy();
|
|
return!0},_doNoop:function(){return!0},_doPageDown:function(a){var b=this,e=this._model,c=this._getSelection(),n=c.getCaret(),l=e.getLineAtOffset(n),d=e.getLineCount(),s=this._getScroll(),e=this._getClientHeight(),g,h;if(this._lineHeight){g=this._columnX;s=this._getBoundsAtOffset(n);if(-1===g||a.select&&f.isIE)g=s.left;n=this._getLineIndex(s.top+e);h=this._getLine(n);l=this._getLinePixel(n);n=h.getOffset(g,s.top+e-l);e=h.getBoundingClientRect(n);h.destroy();c.extend(n);a.select||c.collapse();this._setSelection(c,
|
|
!0,!0,function(){b._columnX=g},e.top+l-s.top);return!0}if(l<d-1){var u=this._getLineHeight(),q=Math.min(d-l-1,Math.floor(e/u)),q=Math.max(1,q);g=this._columnX;if(-1===g||a.select&&f.isIE)h=this._getLine(l),g=h.getBoundingClientRect(n).left,h.destroy();h=this._getLine(l+q);c.extend(h.getOffset(g,0));h.destroy();a.select||c.collapse();a=d*u;n=s.y+q*u;n+e>a&&(n=a-e);this._setSelection(c,!0,!0,function(){b._columnX=g},n-s.y)}return!0},_doPageUp:function(a){var b=this,e=this._model,c=this._getSelection(),
|
|
n=c.getCaret(),l=e.getLineAtOffset(n),d=this._getScroll(),s=this._getClientHeight(),g;if(this._lineHeight){g=this._columnX;d=this._getBoundsAtOffset(n);if(-1===g||a.select&&f.isIE)g=d.left;n=this._getLineIndex(d.bottom-s);e=this._getLine(n);l=this._getLinePixel(n);n=e.getOffset(g,d.bottom-s-l);s=e.getBoundingClientRect(n);e.destroy();c.extend(n);a.select||c.collapse();this._setSelection(c,!0,!0,function(){b._columnX=g},s.top+l-d.top);return!0}if(0<l){var h=this._getLineHeight(),s=Math.max(1,Math.min(l,
|
|
Math.floor(s/h)));g=this._columnX;if(-1===g||a.select&&f.isIE)e=this._getLine(l),g=e.getBoundingClientRect(n).left,e.destroy();e=this._getLine(l-s);c.extend(e.getOffset(g,this._getLineHeight(l-s)-1));e.destroy();a.select||c.collapse();a=Math.max(0,d.y-s*h);this._setSelection(c,!0,!0,function(){b._columnX=g},a-d.y)}return!0},_doPaste:function(a){var b=this;return null!==this._getClipboardText(a,function(a){a&&(f.isLinux&&2===b._lastMouseButton&&(new Date).getTime()-b._lastMouseTime<=b._clickTime&&
|
|
b._setSelectionTo(b._lastMouseX,b._lastMouseY),b._doContent(a))})},_doScroll:function(a){var b=a.type,e=this._model,c=e.getLineCount();a=this._getClientHeight();var n=this._getLineHeight(),c=this._lineHeight?this._scrollHeight:c*n,l=this._getScroll().y,d;switch(b){case "textStart":d=0;break;case "textEnd":d=c-a;break;case "pageDown":d=l+a;break;case "pageUp":d=l-a;break;case "lineDown":d=l+n;break;case "lineUp":d=l-n;break;case "centerLine":b=this._getSelection(),d=e.getLineAtOffset(b.start),e=(e.getLineAtOffset(b.end)-
|
|
d+1)*n,d=d*n-a/2+e/2}void 0!==d&&(d=Math.min(Math.max(0,d),c-a),this._scrollViewAnimated(0,d-l,function(){}));return!0},_doSelectAll:function(){var a=this._model,b=this._getSelection();b.setCaret(0);b.extend(a.getCharCount());this._setSelection(b,!1);return!0},_doTab:function(){if(this._tabMode&&!this._readonly){var a="\t";if(this._expandTab)var b=this._model,a=this._getSelection().getCaret(),e=b.getLineAtOffset(a),b=b.getLineStart(e),a=Array(this._tabSize-(a-b)%this._tabSize+1).join(" ");this._doContent(a);
|
|
return!0}},_doShiftTab:function(){if(this._tabMode&&!this._readonly)return!0},_doOverwriteMode:function(){if(!this._readonly)return this.setOptions({overwriteMode:!this.getOptions("overwriteMode")}),!0},_doTabMode:function(){this._tabMode=!this._tabMode;return!0},_doWrapMode:function(){this.setOptions({wrapMode:!this.getOptions("wrapMode")});return!0},_autoScroll:function(){var a=this._model,b=this._getSelection(),e=this.convert({x:this._autoScrollX,y:this._autoScrollY},"page","document"),c=b.getCaret(),
|
|
n=a.getLineCount(),l=a.getLineAtOffset(c),d;if("up"===this._autoScrollDir||"down"===this._autoScrollDir)c=this._autoScrollY/this._getLineHeight(),c=0>c?Math.floor(c):Math.ceil(c),d=Math.max(0,Math.min(n-1,l+c));else if("left"===this._autoScrollDir||"right"===this._autoScrollDir)d=this._getLineIndex(e.y),l=this._getLine(l),e.x+=l.getBoundingClientRect(c,!1).left,l.destroy();0===d&&(f.isMac||f.isLinux)?b.extend(0):d===n-1&&(f.isMac||f.isLinux)?b.extend(a.getCharCount()):(l=this._getLine(d),b.extend(l.getOffset(e.x,
|
|
e.y-this._getLinePixel(d))),l.destroy());this._setSelection(b,!0)},_autoScrollTimer:function(){this._autoScroll();var a=this;this._autoScrollTimerID=this._getWindow().setTimeout(function(){a._autoScrollTimer()},this._AUTO_SCROLL_RATE)},_calculateLineHeightTimer:function(a){if(this._lineHeight&&!this._calculateLHTimer){var b=this._model.getLineCount(),e=0;if(a){a=0;for(var c=(new Date).getTime(),n=0;e<b&&!(this._lineHeight[e]||(a++,n||(n=e),this._lineHeight[e]=this._calculateLineHeight(e)),e++,100<
|
|
(new Date).getTime()-c););this.redrawRulers(0,b);this._queueUpdate()}a=this._getWindow();if(e!==b){var l=this;this._calculateLHTimer=a.setTimeout(function(){l._calculateLHTimer=null;l._calculateLineHeightTimer(!0)},0)}else this._calculateLHTimer&&(a.clearTimeout(this._calculateLHTimer),this._calculateLHTimer=void 0)}},_calculateLineHeight:function(a){a=this._getLine(a);var b=a.getBoundingClientRect();a.destroy();return Math.max(1,b.bottom-b.top)},_calculateMetrics:function(){var a=this._clientDiv,
|
|
b=a.ownerDocument,e=f.createElement(b,"div");e.style.lineHeight="normal";var c={type:"LineStyle",textView:this,0:0,lineText:this._model.getLine(0),lineStart:0};this.onLineStyle(c);q(c.style,e);e.style.position="fixed";e.style.left="-1000px";var d=f.createElement(b,"span");d.appendChild(b.createTextNode(" "));e.appendChild(d);var s=f.createElement(b,"span");s.style.fontStyle="italic";s.appendChild(b.createTextNode(" "));e.appendChild(s);var g=f.createElement(b,"span");g.style.fontWeight="bold";g.appendChild(b.createTextNode(" "));
|
|
e.appendChild(g);c=f.createElement(b,"span");c.style.fontWeight="bold";c.style.fontStyle="italic";c.appendChild(b.createTextNode(" "));e.appendChild(c);a.appendChild(e);var h=e.getBoundingClientRect(),d=d.getBoundingClientRect(),s=s.getBoundingClientRect(),g=g.getBoundingClientRect(),c=c.getBoundingClientRect(),d=d.bottom-d.top,s=s.bottom-s.top,g=g.bottom-g.top,u=c.bottom-c.top,k=0,c=0>=h.bottom-h.top,h=Math.max(1,h.bottom-h.top);s>d&&(k=1);g>s&&(k=2);u>g&&(k=3);var x;0!==k&&(x={style:{}},0!==(k&
|
|
1)&&(x.style.fontStyle="italic"),0!==(k&2)&&(x.style.fontWeight="bold"));d=n(e);a.removeChild(e);k=l(this._viewDiv);e=f.createElement(b,"div");e.style.position="fixed";e.style.left="-1000px";e.style.paddingLeft=k.left+"px";e.style.paddingTop=k.top+"px";e.style.paddingRight=k.right+"px";e.style.paddingBottom=k.bottom+"px";e.style.width="100px";e.style.height="100px";k=f.createElement(b,"div");k.style.width="100%";k.style.height="100%";e.appendChild(k);a.appendChild(e);s=e.getBoundingClientRect();g=
|
|
k.getBoundingClientRect();u=0;!this._singleMode&&!this._noScroll&&(e.style.overflow="hidden",k.style.height="200px",u=e.clientWidth,e.style.overflow="scroll",u-=e.clientWidth);a.removeChild(e);var k={left:g.left-s.left,top:g.top-s.top,right:s.right-g.right,bottom:s.bottom-g.bottom},v=0,p=g=0;if(!c){e=f.createElement(b,"div");e.style.position="fixed";e.style.left="-1000px";a.appendChild(e);e.innerHTML=Array(2).join("a");s=e.getBoundingClientRect();p=Math.ceil(s.right-s.left);if(this._wrapOffset||this._marginOffset)e.innerHTML=
|
|
Array(this._wrapOffset+1+(f.isWebkit?0:1)).join(" "),s=e.getBoundingClientRect(),v=Math.ceil(s.right-s.left),e.innerHTML=Array(this._marginOffset+1).join(" "),g=e.getBoundingClientRect(),g=Math.ceil(g.right-g.left);a.removeChild(e)}return{lineHeight:h,largestFontStyle:x,lineTrim:d,viewPadding:k,scrollWidth:u,wrapWidth:v,marginWidth:g,charWidth:p,invalid:c}},_cancelAnimation:function(){this._animation&&(this._animation.stop(),this._animation=null)},_clearSelection:function(a){var b=this._getSelection();
|
|
if(b.isEmpty())return!1;"next"===a?b.start=b.end:b.end=b.start;this._setSelection(b,!0);return!0},_commitIME:function(a){if(-1!==this._imeOffset){var b=this._model,e=b.getLineAtOffset(this._imeOffset),c=b.getLineStart(e),n=this._getLineNode(e);if(!a){this._scrollDiv.focus();this._clientDiv.focus();var l=this._getDOMText(n).text,b=b.getLine(e),c=this._imeOffset-c,b=c+l.length-b.length;c!==b&&(a=l.substring(c,b))}a&&(!this._doContent(a)&&!f.isWebkit)&&(n.lineRemoved=!0,this._queueUpdate());this._imeOffset=
|
|
-1}},_createActions:function(){this.addKeyMode(new r.DefaultKeyMode(this));var a=this;this._actions={noop:{defaultHandler:function(){return a._doNoop()}},lineUp:{defaultHandler:function(b){return a._doLineUp(c(b,{select:!1}))},actionDescription:{name:p.lineUp}},lineDown:{defaultHandler:function(b){return a._doLineDown(c(b,{select:!1}))},actionDescription:{name:p.lineDown}},lineStart:{defaultHandler:function(b){return a._doHome(c(b,{select:!1,ctrl:!1}))},actionDescription:{name:p.lineStart}},lineEnd:{defaultHandler:function(b){return a._doEnd(c(b,
|
|
{select:!1,ctrl:!1}))},actionDescription:{name:p.lineEnd}},charPrevious:{defaultHandler:function(b){return a._doCursorPrevious(c(b,{select:!1,unit:"character"}))},actionDescription:{name:p.charPrevious}},charNext:{defaultHandler:function(b){return a._doCursorNext(c(b,{select:!1,unit:"character"}))},actionDescription:{name:p.charNext}},pageUp:{defaultHandler:function(b){return a._doPageUp(c(b,{select:!1}))},actionDescription:{name:p.pageUp}},pageDown:{defaultHandler:function(b){return a._doPageDown(c(b,
|
|
{select:!1}))},actionDescription:{name:p.pageDown}},scrollPageUp:{defaultHandler:function(b){return a._doScroll(c(b,{type:"pageUp"}))},actionDescription:{name:p.scrollPageUp}},scrollPageDown:{defaultHandler:function(b){return a._doScroll(c(b,{type:"pageDown"}))},actionDescription:{name:p.scrollPageDown}},scrollLineUp:{defaultHandler:function(b){return a._doScroll(c(b,{type:"lineUp"}))},actionDescription:{name:p.scrollLineUp}},scrollLineDown:{defaultHandler:function(b){return a._doScroll(c(b,{type:"lineDown"}))},
|
|
actionDescription:{name:p.scrollLineDown}},wordPrevious:{defaultHandler:function(b){return a._doCursorPrevious(c(b,{select:!1,unit:"word"}))},actionDescription:{name:p.wordPrevious}},wordNext:{defaultHandler:function(b){return a._doCursorNext(c(b,{select:!1,unit:"word"}))},actionDescription:{name:p.wordNext}},textStart:{defaultHandler:function(b){return a._doHome(c(b,{select:!1,ctrl:!0}))},actionDescription:{name:p.textStart}},textEnd:{defaultHandler:function(b){return a._doEnd(c(b,{select:!1,ctrl:!0}))},
|
|
actionDescription:{name:p.textEnd}},scrollTextStart:{defaultHandler:function(b){return a._doScroll(c(b,{type:"textStart"}))},actionDescription:{name:p.scrollTextStart}},scrollTextEnd:{defaultHandler:function(b){return a._doScroll(c(b,{type:"textEnd"}))},actionDescription:{name:p.scrollTextEnd}},centerLine:{defaultHandler:function(b){return a._doScroll(c(b,{type:"centerLine"}))},actionDescription:{name:p.centerLine}},selectLineUp:{defaultHandler:function(b){return a._doLineUp(c(b,{select:!0}))},actionDescription:{name:p.selectLineUp}},
|
|
selectLineDown:{defaultHandler:function(b){return a._doLineDown(c(b,{select:!0}))},actionDescription:{name:p.selectLineDown}},selectWholeLineUp:{defaultHandler:function(b){return a._doLineUp(c(b,{select:!0,wholeLine:!0}))},actionDescription:{name:p.selectWholeLineUp}},selectWholeLineDown:{defaultHandler:function(b){return a._doLineDown(c(b,{select:!0,wholeLine:!0}))},actionDescription:{name:p.selectWholeLineDown}},selectLineStart:{defaultHandler:function(b){return a._doHome(c(b,{select:!0,ctrl:!1}))},
|
|
actionDescription:{name:p.selectLineStart}},selectLineEnd:{defaultHandler:function(b){return a._doEnd(c(b,{select:!0,ctrl:!1}))},actionDescription:{name:p.selectLineEnd}},selectCharPrevious:{defaultHandler:function(b){return a._doCursorPrevious(c(b,{select:!0,unit:"character"}))},actionDescription:{name:p.selectCharPrevious}},selectCharNext:{defaultHandler:function(b){return a._doCursorNext(c(b,{select:!0,unit:"character"}))},actionDescription:{name:p.selectCharNext}},selectPageUp:{defaultHandler:function(b){return a._doPageUp(c(b,
|
|
{select:!0}))},actionDescription:{name:p.selectPageUp}},selectPageDown:{defaultHandler:function(b){return a._doPageDown(c(b,{select:!0}))},actionDescription:{name:p.selectPageDown}},selectWordPrevious:{defaultHandler:function(b){return a._doCursorPrevious(c(b,{select:!0,unit:"word"}))},actionDescription:{name:p.selectWordPrevious}},selectWordNext:{defaultHandler:function(b){return a._doCursorNext(c(b,{select:!0,unit:"word"}))},actionDescription:{name:p.selectWordNext}},selectTextStart:{defaultHandler:function(b){return a._doHome(c(b,
|
|
{select:!0,ctrl:!0}))},actionDescription:{name:p.selectTextStart}},selectTextEnd:{defaultHandler:function(b){return a._doEnd(c(b,{select:!0,ctrl:!0}))},actionDescription:{name:p.selectTextEnd}},deletePrevious:{defaultHandler:function(b){return a._doBackspace(c(b,{unit:"character"}))},actionDescription:{name:p.deletePrevious}},deleteNext:{defaultHandler:function(b){return a._doDelete(c(b,{unit:"character"}))},actionDescription:{name:p.deleteNext}},deleteWordPrevious:{defaultHandler:function(b){return a._doBackspace(c(b,
|
|
{unit:"word"}))},actionDescription:{name:p.deleteWordPrevious}},deleteWordNext:{defaultHandler:function(b){return a._doDelete(c(b,{unit:"word"}))},actionDescription:{name:p.deleteWordNext}},deleteLineStart:{defaultHandler:function(b){return a._doBackspace(c(b,{unit:"line"}))},actionDescription:{name:p.deleteLineStart}},deleteLineEnd:{defaultHandler:function(b){return a._doDelete(c(b,{unit:"line"}))},actionDescription:{name:p.deleteLineEnd}},tab:{defaultHandler:function(b){return a._doTab(c(b,{}))},
|
|
actionDescription:{name:p.tab}},shiftTab:{defaultHandler:function(b){return a._doShiftTab(c(b,{}))},actionDescription:{name:p.shiftTab}},enter:{defaultHandler:function(b){return a._doEnter(c(b,{}))},actionDescription:{name:p.enter}},enterNoCursor:{defaultHandler:function(b){return a._doEnter(c(b,{noCursor:!0}))},actionDescription:{name:p.enterNoCursor}},selectAll:{defaultHandler:function(b){return a._doSelectAll(c(b,{}))},actionDescription:{name:p.selectAll}},copy:{defaultHandler:function(b){return a._doCopy(c(b,
|
|
{}))},actionDescription:{name:p.copy}},cut:{defaultHandler:function(b){return a._doCut(c(b,{}))},actionDescription:{name:p.cut}},paste:{defaultHandler:function(b){return a._doPaste(c(b,{}))},actionDescription:{name:p.paste}},uppercase:{defaultHandler:function(b){return a._doCase(c(b,{type:"upper"}))},actionDescription:{name:p.uppercase}},lowercase:{defaultHandler:function(b){return a._doCase(c(b,{type:"lower"}))},actionDescription:{name:p.lowercase}},capitalize:{defaultHandler:function(b){return a._doCase(c(b,
|
|
{unit:"word",type:"capitalize"}))},actionDescription:{name:p.capitalize}},reversecase:{defaultHandler:function(b){return a._doCase(c(b,{type:"reverse"}))},actionDescription:{name:p.reversecase}},toggleOverwriteMode:{defaultHandler:function(b){return a._doOverwriteMode(c(b,{}))},actionDescription:{name:p.toggleOverwriteMode}},toggleTabMode:{defaultHandler:function(b){return a._doTabMode(c(b,{}))},actionDescription:{name:p.toggleTabMode}},toggleWrapMode:{defaultHandler:function(b){return a._doWrapMode(c(b,
|
|
{}))},actionDescription:{name:p.toggleWrapMode}}}},_createRulerParent:function(a,b){var e=f.createElement(a,"div");e.className=b;e.tabIndex=-1;e.style.overflow="hidden";e.style.MozUserSelect="none";e.style.WebkitUserSelect="none";e.style.position="absolute";e.style.top="0px";e.style.bottom="0px";e.style.cursor="default";e.style.display="none";e.setAttribute("aria-hidden","true");this._rootDiv.appendChild(e);return e},_createRuler:function(a,b){if(this._clientDiv){var e=this._getRulerParent(a);if(e){if(e!==
|
|
this._marginDiv||this._marginOffset)e.style.display="block";e.rulerWidth=void 0;var c=f.createElement(e.ownerDocument,"div");c._ruler=a;a.node=c;c.rulerChanged=!0;c.style.position="relative";c.style.cssFloat="left";c.style.styleFloat="left";c.style.outline="none";if(void 0===b||0>b||b>=e.children.length)e.appendChild(c);else{for(var n=e.firstChild;n&&0<b--;)n=n.nextSibling;e.insertBefore(c,n)}}}},_createView:function(){function a(){d._rootDiv&&(d.update(!0),d._metrics.invalid&&d._getWindow().setTimeout(function(){a()},
|
|
100))}if(!this._clientDiv){for(var b=this._parent;b.hasChildNodes();)b.removeChild(b.lastChild);var c=b.ownerDocument,n=f.createElement(c,"div");this._rootDiv=n;n.tabIndex=-1;n.style.position="relative";n.style.overflow="hidden";n.style.width="100%";n.style.height="100%";n.style.overflow="hidden";n.style.WebkitTextSizeAdjust="100%";n.setAttribute("role","application");b.appendChild(n);this._leftDiv=this._createRulerParent(c,"textviewLeftRuler");b=f.createElement(c,"div");b.className="textviewScroll";
|
|
this._viewDiv=b;b.tabIndex=-1;b.style.position="absolute";b.style.top="0px";b.style.bottom="0px";b.style.borderWidth="0px";b.style.margin="0px";b.style.outline="none";b.style.background="transparent";n.appendChild(b);var l=this._createRulerParent(c,"textviewRightRuler");this._rightDiv=l;l.style.right="0px";this._innerRightDiv=l=this._createRulerParent(c,"textviewInnerRightRuler");l.style.zIndex="1";this._scrollDiv=l=f.createElement(c,"div");l.style.margin="0px";l.style.borderWidth="0px";l.style.padding=
|
|
"0px";b.appendChild(l);(this._marginDiv=this._createRulerParent(c,"textviewMarginRuler")).style.zIndex="4";!f.isIE&&!f.isIOS&&(this._clipDiv=b=f.createElement(c,"div"),b.style.position="absolute",b.style.overflow="hidden",b.style.margin="0px",b.style.borderWidth="0px",b.style.padding="0px",b.style.background="transparent",n.appendChild(b),this._clipScrollDiv=l=f.createElement(c,"div"),l.style.position="absolute",l.style.height="1px",l.style.top="-1000px",l.style.background="transparent",b.appendChild(l));
|
|
this._setFullSelection(this._fullSelection,!0);b=f.createElement(c,"div");b.className="textviewContent";this._clientDiv=b;b.tabIndex=0;b.style.position="absolute";b.style.borderWidth="0px";b.style.margin="0px";b.style.padding="0px";b.style.outline="none";b.style.zIndex="1";b.style.WebkitUserSelect="text";b.setAttribute("spellcheck","false");if(f.isIOS||f.isAndroid)b.style.WebkitTapHighlightColor="transparent";(this._clipDiv||n).appendChild(b);if(f.isIOS||f.isAndroid)this._vScrollDiv=l=f.createElement(c,
|
|
"div"),l.style.position="absolute",l.style.borderWidth="1px",l.style.borderColor="white",l.style.borderStyle="solid",l.style.borderRadius="4px",l.style.backgroundColor="black",l.style.opacity="0.5",l.style.margin="0px",l.style.padding="0px",l.style.outline="none",l.style.zIndex="3",l.style.width="8px",l.style.display="none",n.appendChild(l),this._hScrollDiv=l=f.createElement(c,"div"),l.style.position="absolute",l.style.borderWidth="1px",l.style.borderColor="white",l.style.borderStyle="solid",l.style.borderRadius=
|
|
"4px",l.style.backgroundColor="black",l.style.opacity="0.5",l.style.margin="0px",l.style.padding="0px",l.style.outline="none",l.style.zIndex="3",l.style.height="8px",l.style.display="none",n.appendChild(l);f.isFirefox&&!b.setCapture&&(this._overlayDiv=l=f.createElement(c,"div"),l.style.position=b.style.position,l.style.borderWidth=b.style.borderWidth,l.style.margin=b.style.margin,l.style.padding=b.style.padding,l.style.cursor="text",l.style.zIndex="2",(this._clipDiv||n).appendChild(l));b.contentEditable=
|
|
"true";b.setAttribute("role","textbox");b.setAttribute("aria-multiline","true");this._setWrapMode(this._wrapMode,!0);this._setReadOnly(this._readonly);this._setThemeClass(this._themeClass,!0);this._setTabSize(this._tabSize,!0);this._setMarginOffset(this._marginOffset,!0);this._hookEvents();b=this._rulers;for(l=0;l<b.length;l++)this._createRuler(b[l]);this._update();var d=this;e(c,n,"textview",a)}},_defaultOptions:function(){return{parent:{value:void 0,update:null},model:{value:void 0,update:this.setModel},
|
|
scrollAnimation:{value:0,update:null},readonly:{value:!1,update:this._setReadOnly},fullSelection:{value:!0,update:this._setFullSelection},tabMode:{value:!0,update:null},tabSize:{value:8,update:this._setTabSize},expandTab:{value:!1,update:null},singleMode:{value:!1,update:this._setSingleMode},noScroll:{value:!1,update:this._setNoScroll},overwriteMode:{value:!1,update:this._setOverwriteMode},blockCursorVisible:{value:!1,update:this._setBlockCursor},marginOffset:{value:0,update:this._setMarginOffset},
|
|
wrapOffset:{value:0,update:this._setWrapOffset},wrapMode:{value:!1,update:this._setWrapMode},wrappable:{value:!1,update:null},theme:{value:g.TextTheme.getTheme(),update:this._setTheme},themeClass:{value:void 0,update:this._setThemeClass}}},_destroyRuler:function(a){var b=this._getRulerParent(a);if(b)for(var e=b.firstChild;e;){if(e._ruler===a){e._ruler=void 0;b.removeChild(e);if(0===b.children.length&&(b!==this._marginDiv||!this._marginOffset))b.style.display="none";b.rulerWidth=void 0;break}e=e.nextSibling}},
|
|
_destroyView:function(){if(this._clientDiv){this._setGrab(null);this._unhookEvents();var a=this._getWindow();this._autoScrollTimerID&&(a.clearTimeout(this._autoScrollTimerID),this._autoScrollTimerID=null);this._updateTimer&&(a.clearTimeout(this._updateTimer),this._updateTimer=null);this._calculateLHTimer&&(a.clearTimeout(this._calculateLHTimer),this._calculateLHTimer=null);a=this._rootDiv;a.parentNode.removeChild(a);this._hScrollDiv=this._vScrollDiv=this._cursorDiv=this._marginDiv=this._innerRightDiv=
|
|
this._rightDiv=this._leftDiv=this._overlayDiv=this._clientDiv=this._clipScrollDiv=this._clipDiv=this._viewDiv=this._scrollDiv=this._rootDiv=this._clipboardDiv=this._selDiv3=this._selDiv2=this._selDiv1=null}},_doAutoScroll:function(a,b,e){this._autoScrollDir=a;this._autoScrollX=b;this._autoScrollY=e;this._autoScrollTimerID||this._autoScrollTimer()},_endAutoScroll:function(){this._autoScrollTimerID&&this._getWindow().clearTimeout(this._autoScrollTimerID);this._autoScrollTimerID=this._autoScrollDir=
|
|
void 0},_fixCaret:function(){var a=this._clientDiv;if(a){var b=this._hasFocus;this._ignoreFocus=!0;b&&a.blur();a.contentEditable=!1;a.contentEditable=!0;b&&a.focus();this._ignoreFocus=!1}},_getBaseText:function(a,b){var e=this._model;e.getBaseModel&&(a=e.mapOffset(a),b=e.mapOffset(b),e=e.getBaseModel());return e.getText(a,b)},_getBottomIndex:function(a){var b=this._bottomChild;if(a&&this._getClientHeight()>this._getLineHeight()){a=b.getBoundingClientRect();var e=this._clientDiv.getBoundingClientRect();
|
|
a.bottom>e.bottom&&(b=this._getLinePrevious(b)||b)}return b.lineIndex},_getBoundsAtOffset:function(a){var b=this._getLine(this._model.getLineAtOffset(a));a=b.getBoundingClientRect(a);var e=this._getLinePixel(b.lineIndex);a.top+=e;a.bottom+=e;b.destroy();return a},_getClientHeight:function(){var a=this._getViewPadding();return Math.max(0,this._viewDiv.clientHeight-a.top-a.bottom)},_getInnerRightWidth:function(){var a=this._innerRightDiv.rulerWidth;void 0===a&&(a=this._innerRightDiv.getBoundingClientRect(),
|
|
this._innerRightDiv.rulerWidth=a=a.right-a.left);return a},_getClientWidth:function(){var a=this._getViewPadding(),b=this._getInnerRightWidth();return Math.max(0,this._viewDiv.clientWidth-a.left-a.right-b)},_getClipboardText:function(a,e){var c=this._singleMode?"":this._model.getLineDelimiter(),n,l,d=this._getWindow(),s=d.clipboardData;!s&&a&&(s=a.clipboardData);if(s)return n=[],l=s.getData(f.isIE?"Text":"text/plain"),b(l,function(a){n.push(a)},function(){n.push(c)}),l=n.join(""),e&&e(l),l;if(f.isFirefox){this._ignoreFocus=
|
|
!0;var g=this._clipboardDiv,s=this._rootDiv.ownerDocument;g||(this._clipboardDiv=g=f.createElement(s,"div"),g.style.position="fixed",g.style.whiteSpace="pre",g.style.left="-1000px",this._rootDiv.appendChild(g));g.innerHTML="\x3cpre contenteditable\x3d''\x3e\x3c/pre\x3e";g.firstChild.focus();var h=this,u=function(){var a=h._getTextFromElement(g);g.innerHTML="";n=[];b(a,function(a){n.push(a)},function(){n.push(c)});return n.join("")},q=!1;this._ignorePaste=!0;if(!f.isLinux||2!==this._lastMouseButton)try{q=
|
|
s.execCommand("paste",!1,null)}catch(k){q=1<g.childNodes.length||g.firstChild&&0<g.firstChild.childNodes.length}this._ignorePaste=!1;if(!q){if(a)return d.setTimeout(function(){h.focus();(l=u())&&e&&e(l);h._ignoreFocus=!1},0),null;this.focus();this._ignoreFocus=!1;return""}this.focus();this._ignoreFocus=!1;(l=u())&&e&&e(l);return l}return""},_getDOMText:function(a,b){return a._line.getText(b)},_getTextFromElement:function(a){var b=a.ownerDocument,e=b.defaultView;if(!e.getSelection)return a.innerText||
|
|
a.textContent;b=b.createRange();b.selectNode(a);a=e.getSelection();var e=[],c;for(c=0;c<a.rangeCount;c++)e.push(a.getRangeAt(c));this._ignoreSelect=!0;a.removeAllRanges();a.addRange(b);b=a.toString();a.removeAllRanges();for(c=0;c<e.length;c++)a.addRange(e[c]);this._ignoreSelect=!1;return b},_getViewPadding:function(){return this._metrics.viewPadding},_getLine:function(a){var b=this._getLineNode(a);return b&&!b.lineChanged&&!b.lineRemoved?b._line:new x(this,a)},_getLineHeight:function(a,b){if(void 0!==
|
|
a&&this._lineHeight){var e=this._lineHeight[a];if(e)return e;if(b||void 0===b)return this._lineHeight[a]=this._calculateLineHeight(a)}return this._metrics.lineHeight},_getLineNode:function(a){for(var b=this._clientDiv.firstChild;b;){if(a===b.lineIndex)return b;b=b.nextSibling}},_getLineNext:function(a){for(a=a?a.nextSibling:this._clientDiv.firstChild;a&&(-1===a.lineIndex||!a._line);)a=a.nextSibling;return a},_getLinePrevious:function(a){for(a=a?a.previousSibling:this._clientDiv.lastChild;a&&(-1===
|
|
a.lineIndex||!a._line);)a=a.previousSibling;return a},_getLinePixel:function(a){a=Math.min(Math.max(0,a),this._model.getLineCount());if(this._lineHeight){var b=this._getTopIndex(),e=-this._topIndexY+this._getScroll().y;if(a>b)for(;b<a;b++)e+=this._getLineHeight(b);else for(b-=1;b>=a;b--)e-=this._getLineHeight(b);return e}return this._getLineHeight()*a},_getLineIndex:function(a){var b,e=0,c=this._model.getLineCount();if(this._lineHeight){var e=this._getTopIndex(),n=-this._topIndexY+this._getScroll().y;
|
|
if(a!==n)if(a<n)for(;a<n&&0<e;)a+=this._getLineHeight(--e);else for(b=this._getLineHeight(e);a-b>=n&&e<c-1;)a-=b,b=this._getLineHeight(++e)}else b=this._getLineHeight(),e=Math.floor(a/b);return Math.max(0,Math.min(c-1,e))},_getRulerParent:function(a){switch(a.getLocation()){case "left":return this._leftDiv;case "right":return this._rightDiv;case "innerRight":return this._innerRightDiv;case "margin":return this._marginDiv}return null},_getScroll:function(a){(void 0===a||a)&&this._cancelAnimation();
|
|
a=this._viewDiv;return{x:a.scrollLeft,y:a.scrollTop}},_getSelection:function(){return this._selection.clone()},_getTopIndex:function(a){var b=this._topChild;if(a&&this._getClientHeight()>this._getLineHeight()){a=b.getBoundingClientRect();var e=this._getViewPadding(),c=this._viewDiv.getBoundingClientRect();a.top<c.top+e.top&&(b=this._getLineNext(b)||b)}return b.lineIndex},_hookEvents:function(){var a=this;this._modelListener={onChanging:function(b){a._onModelChanging(b)},onChanged:function(b){a._onModelChanged(b)}};
|
|
this._model.addEventListener("preChanging",this._modelListener.onChanging);this._model.addEventListener("postChanged",this._modelListener.onChanged);this._themeListener={onChanged:function(){a._setThemeClass(a._themeClass)}};this._theme.addEventListener("ThemeChanged",this._themeListener.onChanged);var b=this._handlers=[],e=this._clientDiv,c=this._viewDiv,n=this._rootDiv,l=this._overlayDiv||e,d=e.ownerDocument,s=this._getWindow(),g=f.isIE?d:s;b.push({target:s,type:"resize",handler:function(b){return a._handleResize(b?
|
|
b:s.event)}});b.push({target:e,type:"blur",handler:function(b){return a._handleBlur(b?b:s.event)}});b.push({target:e,type:"focus",handler:function(b){return a._handleFocus(b?b:s.event)}});b.push({target:c,type:"focus",handler:function(){e.focus()}});b.push({target:c,type:"scroll",handler:function(b){return a._handleScroll(b?b:s.event)}});b.push({target:e,type:"textInput",handler:function(b){return a._handleTextInput(b?b:s.event)}});b.push({target:e,type:"keydown",handler:function(b){return a._handleKeyDown(b?
|
|
b:s.event)}});b.push({target:e,type:"keypress",handler:function(b){return a._handleKeyPress(b?b:s.event)}});b.push({target:e,type:"keyup",handler:function(b){return a._handleKeyUp(b?b:s.event)}});f.isIE&&b.push({target:d,type:"keyup",handler:function(b){return a._handleDocKeyUp(b?b:s.event)}});b.push({target:e,type:"contextmenu",handler:function(b){return a._handleContextMenu(b?b:s.event)}});b.push({target:e,type:"copy",handler:function(b){return a._handleCopy(b?b:s.event)}});b.push({target:e,type:"cut",
|
|
handler:function(b){return a._handleCut(b?b:s.event)}});b.push({target:e,type:"paste",handler:function(b){return a._handlePaste(b?b:s.event)}});b.push({target:d,type:"selectionchange",handler:function(b){return a._handleSelectionChange(b?b:s.event)}});if(f.isIOS||f.isAndroid)b.push({target:e,type:"touchstart",handler:function(b){return a._handleTouchStart(b?b:s.event)}}),b.push({target:e,type:"touchmove",handler:function(b){return a._handleTouchMove(b?b:s.event)}}),b.push({target:e,type:"touchend",
|
|
handler:function(b){return a._handleTouchEnd(b?b:s.event)}});else{b.push({target:e,type:"selectstart",handler:function(b){return a._handleSelectStart(b?b:s.event)}});b.push({target:e,type:"mousedown",handler:function(b){return a._handleMouseDown(b?b:s.event)}});b.push({target:e,type:"mouseover",handler:function(b){return a._handleMouseOver(b?b:s.event)}});b.push({target:e,type:"mouseout",handler:function(b){return a._handleMouseOut(b?b:s.event)}});b.push({target:g,type:"mouseup",handler:function(b){return a._handleMouseUp(b?
|
|
b:s.event)}});b.push({target:g,type:"mousemove",handler:function(b){return a._handleMouseMove(b?b:s.event)}});b.push({target:n,type:"mousedown",handler:function(b){return a._handleRootMouseDown(b?b:s.event)}});b.push({target:n,type:"mouseup",handler:function(b){return a._handleRootMouseUp(b?b:s.event)}});b.push({target:l,type:"dragstart",handler:function(b){return a._handleDragStart(b?b:s.event)}});b.push({target:l,type:"drag",handler:function(b){return a._handleDrag(b?b:s.event)}});b.push({target:l,
|
|
type:"dragend",handler:function(b){return a._handleDragEnd(b?b:s.event)}});b.push({target:l,type:"dragenter",handler:function(b){return a._handleDragEnter(b?b:s.event)}});b.push({target:l,type:"dragover",handler:function(b){return a._handleDragOver(b?b:s.event)}});b.push({target:l,type:"dragleave",handler:function(b){return a._handleDragLeave(b?b:s.event)}});b.push({target:l,type:"drop",handler:function(b){return a._handleDrop(b?b:s.event)}});b.push({target:this._clientDiv,type:26<f.isFirefox?"wheel":
|
|
f.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(b){return a._handleMouseWheel(b?b:s.event)}});this._clipDiv&&b.push({target:this._clipDiv,type:26<f.isFirefox?"wheel":f.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(b){return a._handleMouseWheel(b?b:s.event)}});if(f.isFirefox&&(!f.isWindows||15<=f.isFirefox))(c=s.MutationObserver||s.MozMutationObserver)?(this._mutationObserver=new c(function(b){a._handleDataModified(b)}),this._mutationObserver.observe(e,{subtree:!0,characterData:!0})):
|
|
b.push({target:this._clientDiv,type:"DOMCharacterDataModified",handler:function(b){return a._handleDataModified(b?b:s.event)}});if(f.isFirefox&&(!f.isWindows||15<=f.isFirefox)||f.isIE)b.push({target:this._clientDiv,type:"compositionstart",handler:function(b){return a._handleCompositionStart(b?b:s.event)}}),b.push({target:this._clientDiv,type:"compositionend",handler:function(b){return a._handleCompositionEnd(b?b:s.event)}});this._overlayDiv&&(b.push({target:this._overlayDiv,type:"mousedown",handler:function(b){return a._handleMouseDown(b?
|
|
b:s.event)}}),b.push({target:this._overlayDiv,type:"mouseover",handler:function(b){return a._handleMouseOver(b?b:s.event)}}),b.push({target:this._overlayDiv,type:"mouseout",handler:function(b){return a._handleMouseOut(b?b:s.event)}}),b.push({target:this._overlayDiv,type:"contextmenu",handler:function(b){return a._handleContextMenu(b?b:s.event)}}));this._isW3CEvents||b.push({target:this._clientDiv,type:"dblclick",handler:function(b){return a._handleDblclick(b?b:s.event)}})}this._hookRulerEvents(this._leftDiv,
|
|
b);this._hookRulerEvents(this._rightDiv,b);this._hookRulerEvents(this._innerRightDiv,b);this._hookRulerEvents(this._marginDiv,b);for(c=0;c<b.length;c++)n=b[c],y(n.target,n.type,n.handler,n.capture)},_hookRulerEvents:function(a,b){if(a){var e=this,c=this._getWindow();f.isIE&&b.push({target:a,type:"selectstart",handler:function(){return!1}});b.push({target:a,type:26<f.isFirefox?"wheel":f.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(a){return e._handleMouseWheel(a?a:c.event)}});b.push({target:a,
|
|
type:"click",handler:function(a){e._handleRulerEvent(a?a:c.event)}});b.push({target:a,type:"dblclick",handler:function(a){e._handleRulerEvent(a?a:c.event)}});b.push({target:a,type:"mousemove",handler:function(a){e._handleRulerEvent(a?a:c.event)}});b.push({target:a,type:"mouseover",handler:function(a){e._handleRulerEvent(a?a:c.event)}});b.push({target:a,type:"mouseout",handler:function(a){e._handleRulerEvent(a?a:c.event)}})}},_getWindow:function(){return this._parent.ownerDocument.defaultView||this._parent.ownerDocument.parentWindow},
|
|
_ignoreEvent:function(a){for(a=a.target;a&&a!==this._clientDiv;){if(a.ignore)return!0;a=a.parentNode}return!1},_init:function(a){var b=a.parent;"string"===typeof b&&(b=(a.document||document).getElementById(b));if(!b)throw Error("no parent");a.parent=b;a.model=a.model||new t.TextModel;var e=this._defaultOptions(),c;for(c in e)e.hasOwnProperty(c)&&(this["_"+c]=void 0!==a[c]?a[c]:e[c].value);this._keyModes=[];this._rulers=[];this._selection=new s(0,0,!1);this._linksVisible=!1;this._maxLineWidth=this._redrawCount=
|
|
0;this._maxLineIndex=-1;this._ignoreSelect=!0;this._hasFocus=this._ignoreFocus=!1;this._dragOffset=this._columnX=-1;this._isRangeRects=(!f.isIE||9<=f.isIE)&&"function"===typeof b.ownerDocument.createRange().getBoundingClientRect;this._isW3CEvents=b.addEventListener;this._autoScrollTimerID=this._autoScrollY=this._autoScrollX=null;this._AUTO_SCROLL_RATE=50;this._mouseUpClosure=this._moseMoveClosure=this._grabControl=null;this._clickCount=this._lastMouseTime=this._lastMouseY=this._lastMouseX=0;this._clickTime=
|
|
250;this._clickDist=5;this._isMouseDown=!1;this._doubleClickSelection=null;this._vScroll=this._hScroll=0;this._imeOffset=-1;this._createActions();this._createView()},_checkOverlayScroll:function(){if(f.isMac&&f.isWebkit&&!this._metrics.invalid&&0===this._metrics.scrollWidth){var a=this._viewDiv,b=this._isOverOverlayScroll();a.style.pointerEvents=b.vertical||b.horizontal?"":"none"}},_isOverOverlayScroll:function(){if(!(200>(new Date).getTime()-this._lastScrollTime))return{};var a=this._viewDiv.getBoundingClientRect(),
|
|
b=this._lastMouseMoveX,e=this._lastMouseMoveY;return{vertical:a.top<=e&&e<a.bottom&&a.right-15<=b&&b<a.right,horizontal:a.bottom-15<=e&&e<a.bottom&&a.left<=b&&b<a.right}},_modifyContent:function(a,b){if(this._readonly&&!a._code)return!1;a.type="Verify";this.onVerify(a);if(null===a.text||void 0===a.text)return!1;var e=this._model;try{a._ignoreDOMSelection&&(this._ignoreDOMSelection=!0),e.setText(a.text,a.start,a.end)}finally{a._ignoreDOMSelection&&(this._ignoreDOMSelection=!1)}if(b){e=this._getSelection();
|
|
e.setCaret(a.start+a.text.length);try{a._ignoreDOMSelection1&&(this._ignoreDOMSelection=!0),this._setSelection(e,!0)}finally{a._ignoreDOMSelection1&&(this._ignoreDOMSelection=!1)}}this.onModify({type:"Modify"});return!0},_onModelChanged:function(a){a.type="ModelChanged";this.onModelChanged(a);a.type="Changed";var b=a.start,e=a.addedCharCount,c=a.removedCharCount,n=a.addedLineCount,l=a.removedLineCount,d=this._getSelection();d.end>b&&(d.end>b&&d.start<b+c?d.setCaret(b+e):(d.start+=e-c,d.end+=e-c),
|
|
this._setSelection(d,!1,!1));b=this._model.getLineAtOffset(b);for(e=this._getLineNext();e;)c=e.lineIndex,b<=c&&c<=b+l&&(b===c&&!e.modelChangedEvent&&!e.lineRemoved?(e.modelChangedEvent=a,e.lineChanged=!0):(e.lineRemoved=!0,e.lineChanged=!1,e.modelChangedEvent=null)),c>b+l&&(e.lineIndex=c+n-l,e._line.lineIndex=e.lineIndex),e=this._getLineNext(e);this._lineHeight&&(a=[b,l].concat(Array(n)),Array.prototype.splice.apply(this._lineHeight,a));!this._wrapMode&&(b<=this._maxLineIndex&&this._maxLineIndex<=
|
|
b+l)&&(this._checkMaxLineIndex=this._maxLineIndex,this._maxLineIndex=-1,this._maxLineWidth=0);this._update()},_onModelChanging:function(a){a.type="ModelChanging";this.onModelChanging(a);a.type="Changing"},_queueUpdate:function(){if(!this._updateTimer&&!this._ignoreQueueUpdate){var a=this;this._updateTimer=this._getWindow().setTimeout(function(){a._updateTimer=null;a._update()},0)}},_resetLineHeight:function(a,b){if(this._wrapMode||this._variableLineHeight){if(void 0!==a&&void 0!==b)for(var e=a;e<
|
|
b;e++)this._lineHeight[e]=void 0;else e=this._model.getLineCount(),this._lineHeight=Array(e);this._calculateLineHeightTimer()}else this._lineHeight=null},_resetLineWidth:function(){var a=this._clientDiv;if(a)for(a=a.firstChild;a;)a.lineWidth=void 0,a=a.nextSibling},_reset:function(){this._maxLineIndex=-1;this._maxLineWidth=0;this._columnX=-1;this._bottomChild=this._topChild=null;this._topIndexY=0;this._variableLineHeight=!1;this._resetLineHeight();this._setSelection(new s(0,0,!1),!1,!1);this._viewDiv&&
|
|
(this._viewDiv.scrollLeft=0,this._viewDiv.scrollTop=0);var a=this._clientDiv;if(a){for(a=a.firstChild;a;)a.lineRemoved=!0,a=a.nextSibling;13>f.isFirefox&&this._fixCaret()}},_scrollViewAnimated:function(a,b,e){var c=this._getWindow();if(e&&this._scrollAnimation){var n=this;this._animation=new C({window:c,duration:this._scrollAnimation,curve:[b,0],onAnimate:function(a){a=b-Math.floor(a);n._scrollView(0,a);b-=a},onEnd:function(){n._animation=null;n._scrollView(a,b);e&&c.setTimeout(e,0)}});this._animation.play()}else this._scrollView(a,
|
|
b),e&&c.setTimeout(e,0)},_scrollView:function(a,b){this._ensureCaretVisible=!1;var e=this._viewDiv;a&&(e.scrollLeft+=a);b&&(e.scrollTop+=b)},_setClipboardText:function(a,e){var c,n=this._getWindow(),l=n.clipboardData;!l&&e&&(l=e.clipboardData);if(l&&(c=[],b(a,function(a){c.push(a)},function(){c.push(f.platformDelimiter)}),l.setData(f.isIE?"Text":"text/plain",c.join(""))||21<f.isFirefox))return!0;var d=this._parent.ownerDocument,s=f.createElement(d,"pre");s.style.position="fixed";s.style.left="-1000px";
|
|
b(a,function(a){s.appendChild(d.createTextNode(a))},function(){s.appendChild(f.createElement(d,"br"))});s.appendChild(d.createTextNode(" "));this._clientDiv.appendChild(s);l=d.createRange();l.setStart(s.firstChild,0);l.setEndBefore(s.lastChild);var g=n.getSelection();0<g.rangeCount&&g.removeAllRanges();g.addRange(l);var h=this,l=function(){s&&s.parentNode===h._clientDiv&&h._clientDiv.removeChild(s);h._updateDOMSelection()},g=!1;this._ignoreCopy=!0;try{g=d.execCommand("copy",!1,null)}catch(u){}this._ignoreCopy=
|
|
!1;if(!g&&e)return n.setTimeout(l,0),!1;l();return!0},_setDOMSelection:function(a,b,e,c,n){this._setDOMFullSelection(a,b,e,c);a=a._line.getNodeOffset(b);e=e._line.getNodeOffset(c);c=this._getWindow();b=this._parent.ownerDocument;if(c.getSelection){var l=c.getSelection();c=b.createRange();c.setStart(a.node,a.offset);c.setEnd(e.node,e.offset);if(this._hasFocus&&(l.anchorNode!==a.node||l.anchorOffset!==a.offset||l.focusNode!==e.node||l.focusOffset!==e.offset||l.anchorNode!==e.node||l.anchorOffset!==
|
|
e.offset||l.focusNode!==a.node||l.focusOffset!==a.offset))this._anchorNode=a.node,this._anchorOffset=a.offset,this._focusNode=e.node,this._focusOffset=e.offset,this._ignoreSelect=!1,0<l.rangeCount&&l.removeAllRanges(),l.addRange(c),this._ignoreSelect=!0;this._cursorDiv&&(c=b.createRange(),n?(c.setStart(a.node,a.offset),c.setEnd(a.node,a.offset)):(c.setStart(e.node,e.offset),c.setEnd(e.node,e.offset)),n=c.getClientRects()[0],a=this._cursorDiv.parentNode,e=a.getBoundingClientRect(),n&&e&&(this._cursorDiv.style.top=
|
|
n.top-e.top+a.scrollTop+"px",this._cursorDiv.style.left=n.left-e.left+a.scrollLeft+"px"))}else b.selection&&this._hasFocus&&(n=b.body,c=f.createElement(b,"div"),n.appendChild(c),n.removeChild(c),c=n.createTextRange(),c.moveToElementText(a.node.parentNode),c.moveStart("character",a.offset),n=n.createTextRange(),n.moveToElementText(e.node.parentNode),n.moveStart("character",e.offset),c.setEndPoint("EndToStart",n),this._ignoreSelect=!1,c.select(),this._ignoreSelect=!0)},_setDOMFullSelection:function(a,
|
|
b,e,c){if(this._selDiv1){var n=this._selDiv1;n.style.width="0px";n.style.height="0px";n=this._selDiv2;n.style.width="0px";n.style.height="0px";n=this._selDiv3;n.style.width="0px";n.style.height="0px";if(!(a===e&&b===c)){var l=this._getViewPadding(),d=this._clientDiv.getBoundingClientRect(),s=this._viewDiv.getBoundingClientRect(),n=s.left+l.left,f=d.right,l=s.top+l.top,g=d.bottom,s=d=0;this._clipDiv?(s=this._clipDiv.getBoundingClientRect(),d=s.left-this._clipDiv.scrollLeft):(s=this._rootDiv.getBoundingClientRect(),
|
|
d=s.left);s=s.top;this._ignoreDOMSelection=!0;var h=(new x(this,a.lineIndex,a)).getBoundingClientRect(b,!1),u=h.left;b=(new x(this,e.lineIndex,e)).getBoundingClientRect(c,!1);var q=b.left;this._ignoreDOMSelection=!1;var k=this._selDiv1,u=Math.min(f,Math.max(n,u)),v=Math.min(g,Math.max(l,h.top)),p=f;c=Math.min(g,Math.max(l,h.bottom));k.style.left=u-d+"px";k.style.top=v-s+"px";k.style.width=Math.max(0,p-u)+"px";k.style.height=Math.max(0,c-v)+"px";a.lineIndex===e.lineIndex?(p=Math.min(q,f),k.style.width=
|
|
Math.max(0,p-u)+"px"):(h=Math.min(g,Math.max(l,b.top)),q=Math.min(f,Math.max(n,q)),l=Math.min(g,Math.max(l,b.bottom)),g=this._selDiv3,g.style.left=n-d+"px",g.style.top=h-s+"px",g.style.width=Math.max(0,q-n)+"px",g.style.height=Math.max(0,l-h)+"px",1<Math.abs(a.lineIndex-e.lineIndex)&&(a=this._selDiv2,a.style.left=n-d+"px",a.style.top=c-s+"px",a.style.width=Math.max(0,f-n)+"px",a.style.height=Math.max(0,h-c)+"px"))}}},_setGrab:function(a){a!==this._grabControl&&(a?(a.setCapture&&a.setCapture(),this._grabControl=
|
|
a):(this._grabControl.releaseCapture&&this._grabControl.releaseCapture(),this._grabControl=null))},_setLinksVisible:function(a){if(this._linksVisible!==a){this._linksVisible=a;f.isIE&&a&&(this._hadFocus=this._hasFocus);var b=this._clientDiv;b.contentEditable=!a;this._hadFocus&&!a&&b.focus();this._overlayDiv&&(this._overlayDiv.style.zIndex=a?"-1":"1");for(a=this._getLineNext();a;)a._line.updateLinks(),a=this._getLineNext(a);this._updateDOMSelection()}},_setSelection:function(a,b,e,c,n){if(a){this._columnX=
|
|
-1;void 0===e&&(e=!0);var l=this._selection;this._selection=a;!1!==b&&this._showCaret(!1,c,b,n);e&&this._updateDOMSelection();if(!l.equals(a))this.onSelection({type:"Selection",oldValue:{start:l.start,end:l.end},newValue:{start:a.start,end:a.end}})}},_setSelectionTo:function(a,b,e,c){var n=this._model,l=this._getSelection();b=this.convert({x:a,y:b},"page","document");a=this._getLineIndex(b.y);if(1===this._clickCount){n=this._getLine(a);a=n.getOffset(b.x,b.y-this._getLinePixel(a));n.destroy();if(c&&
|
|
!e&&l.start<=a&&a<l.end)return this._dragOffset=a,!1;l.extend(a);e||l.collapse()}else 0===(this._clickCount&1)?(n=this._getLine(a),a=n.getOffset(b.x,b.y-this._getLinePixel(a)),this._doubleClickSelection?a>=this._doubleClickSelection.start?(e=this._doubleClickSelection.start,c=n.getNextOffset(a,{unit:"wordend",count:1})):(e=n.getNextOffset(a,{unit:"word",count:-1}),c=this._doubleClickSelection.end):(e=n.getNextOffset(a,{unit:"word",count:-1}),c=n.getNextOffset(e,{unit:"wordend",count:1})),n.destroy()):
|
|
this._doubleClickSelection?(c=n.getLineAtOffset(this._doubleClickSelection.start),a>=c?(e=n.getLineStart(c),c=n.getLineEnd(a)):(e=n.getLineStart(a),c=n.getLineEnd(c))):(e=n.getLineStart(a),c=n.getLineEnd(a)),l.setCaret(e),l.extend(c);this._setSelection(l,!0,!0);return!0},_setFullSelection:function(a,b){this._fullSelection=a;f.isWebkit&&(this._fullSelection=!0);var e=this._clipDiv||this._rootDiv;if(e)if(this._fullSelection){if(!this._selDiv1&&this._fullSelection&&!f.isIOS){var c=e.ownerDocument;this._highlightRGB=
|
|
f.isWebkit?"transparent":"Highlight";var n=f.createElement(c,"div");this._selDiv1=n;n.style.position="absolute";n.style.borderWidth="0px";n.style.margin="0px";n.style.padding="0px";n.style.outline="none";n.style.background=this._highlightRGB;n.style.width="0px";n.style.height="0px";n.style.zIndex="0";e.appendChild(n);var l=f.createElement(c,"div");this._selDiv2=l;l.style.position="absolute";l.style.borderWidth="0px";l.style.margin="0px";l.style.padding="0px";l.style.outline="none";l.style.background=
|
|
this._highlightRGB;l.style.width="0px";l.style.height="0px";l.style.zIndex="0";e.appendChild(l);this._selDiv3=c=f.createElement(c,"div");c.style.position="absolute";c.style.borderWidth="0px";c.style.margin="0px";c.style.padding="0px";c.style.outline="none";c.style.background=this._highlightRGB;c.style.width="0px";c.style.height="0px";c.style.zIndex="0";e.appendChild(c);if(f.isFirefox&&f.isMac){e=this._getWindow().getComputedStyle(c,null).getPropertyValue("background-color");switch(e){case "rgb(119, 141, 168)":e=
|
|
"rgb(199, 208, 218)";break;case "rgb(127, 127, 127)":e="rgb(198, 198, 198)";break;case "rgb(255, 193, 31)":e="rgb(250, 236, 115)";break;case "rgb(243, 70, 72)":e="rgb(255, 176, 139)";break;case "rgb(255, 138, 34)":e="rgb(255, 209, 129)";break;case "rgb(102, 197, 71)":e="rgb(194, 249, 144)";break;case "rgb(140, 78, 184)":e="rgb(232, 184, 255)";break;default:e="rgb(180, 213, 255)"}this._highlightRGB=e;n.style.background=e;l.style.background=e;c.style.background=e}b||this._updateDOMSelection()}}else this._selDiv1&&
|
|
(e.removeChild(this._selDiv1),this._selDiv1=null),this._selDiv2&&(e.removeChild(this._selDiv2),this._selDiv2=null),this._selDiv3&&(e.removeChild(this._selDiv3),this._selDiv3=null)},_setBlockCursor:function(a){this._blockCursorVisible=a;this._updateBlockCursorVisible()},_setOverwriteMode:function(a){this._overwriteMode=a;this._updateBlockCursorVisible()},_updateBlockCursorVisible:function(){if(this._blockCursorVisible||this._overwriteMode){if(!this._cursorDiv){var a=this._viewDiv,b=f.createElement(a.ownerDocument,
|
|
"div");b.className="textviewBlockCursor";this._cursorDiv=b;b.tabIndex=-1;b.style.zIndex="2";b.style.color="transparent";b.style.position="absolute";b.style.pointerEvents="none";b.innerHTML="\x26nbsp;";a.appendChild(b);this._updateDOMSelection()}}else this._cursorDiv&&(this._cursorDiv.parentNode.removeChild(this._cursorDiv),this._cursorDiv=null)},_setMarginOffset:function(a,b){this._marginOffset=a;this._marginDiv.style.display=a?"block":"none";b||(this._metrics=this._calculateMetrics(),this._queueUpdate())},
|
|
_setWrapOffset:function(a,b){this._wrapOffset=a;b||(this._metrics=this._calculateMetrics(),this._queueUpdate())},_setReadOnly:function(a){this._readonly=a;this._clientDiv.setAttribute("aria-readonly",a?"true":"false")},_setSingleMode:function(a,b){this._singleMode=a;this._updateOverflow();this._updateStyle(b)},_setNoScroll:function(a,b){this._noScroll=a;this._updateOverflow();this._updateStyle(b)},_setTabSize:function(a,b){this._tabSize=a;this._customTabSize=void 0;var e=this._clientDiv;f.isOpera?
|
|
e&&(e.style.OTabSize=this._tabSize+""):537.1<=f.isWebkit?e&&(e.style.tabSize=this._tabSize+""):4<=f.isFirefox?e&&(e.style.MozTabSize=this._tabSize+""):8!==this._tabSize&&(this._customTabSize=this._tabSize);b||(this.redrawLines(),this._resetLineWidth())},_setTheme:function(a){this._theme&&this._theme.removeEventListener("ThemeChanged",this._themeListener.onChanged);(this._theme=a)&&this._theme.addEventListener("ThemeChanged",this._themeListener.onChanged);this._setThemeClass(this._themeClass)},_setThemeClass:function(a,
|
|
b){this._themeClass=a;var e="textview",c=this._theme.getThemeClass();c&&(e+=" "+c);this._themeClass&&c!==this._themeClass&&(e+=" "+this._themeClass);this._rootDiv.className=e;this._updateStyle(b)},_setWrapMode:function(a,b){this._wrapMode=a&&this._wrappable;var e=this._clientDiv;this._wrapMode?(e.style.whiteSpace="pre-wrap",e.style.wordWrap="break-word"):(e.style.whiteSpace="pre",e.style.wordWrap="normal");this._updateOverflow();b||(this.redraw(),this._resetLineWidth());this._resetLineHeight()},_showCaret:function(a,
|
|
b,e,c){if(this._clientDiv&&!(0<this._redrawCount)&&!this._ignoreDOMSelection){var n=this._model,l=this._getSelection(),d=this._getScroll(),s=l.getCaret(),f=l.start,g=l.end,h=n.getLineAtOffset(f),u=n.getLineAtOffset(g),q=Math.max(Math.max(f,n.getLineStart(u)),g-1),n=this._getClientWidth(),k=this._getClientHeight(),x=n/4,v=this._getBoundsAtOffset(s===f?f:q),p=v.left,y=v.right,r=v.top,z=v.bottom,t=0,C="object"===typeof e;if((a||C)&&!l.isEmpty())v=this._getBoundsAtOffset(s===g?f:q),t=(v.bottom>z?v.bottom:
|
|
z)-(v.top<r?v.top:r),a&&(v.top===r?s===f?y=p+Math.min(v.right-p,n):p=y-Math.min(y-v.left,n):s===f?z=r+Math.min(v.bottom-r,k):r=z-Math.min(z-v.top,k));a=0;p<d.x&&(a=Math.min(p-d.x,-x));y>d.x+n&&(a=Math.max(y-d.x-n,x));l=0;r<d.y?l=r-d.y:z>d.y+k&&(l=z-d.y-k);c&&(0<c?0<l&&(l=Math.max(l,c)):0>l&&(l=Math.min(l,c)));c=C&&"always"===e.scrollPolicy;if(0!==a||0!==l||c)return C?(c=0<l,0===l&&(l=r-d.y),d=e.viewAnchor,r=e.selectionAnchor,e=Math.min(Math.max(0,e.viewAnchorOffset||0)),l="top"===d?l+Math.floor(c?
|
|
(1-e)*k:-e*k):"bottom"===d?l+Math.floor(c?e*k:-(1-e)*k):"center"===d?l+Math.floor(c?k/2+e*k:k/2-(1-e)*k):l+Math.floor(c?e*k:-e*k),h!==u&&("top"===r&&s!==f?l+=Math.floor(-t):"bottom"===r&&s!==g?l+=Math.floor(t):"center"===r&&(l+=Math.floor(t/2)))):0!==l&&"number"===typeof e&&(0>e&&(e=0),1<e&&(e=1),l+=Math.floor(0<l?e*k:-e*k)),this._scrollViewAnimated(a,l,b),k!==this._getClientHeight()||n!==this._getClientWidth()?this._showCaret():this._ensureCaretVisible=!0,!0;b&&b();return!1}},_startIME:function(){if(-1===
|
|
this._imeOffset){var a=this._getSelection();a.isEmpty()||this._modifyContent({text:"",start:a.start,end:a.end},!0);this._imeOffset=a.start}},_unhookEvents:function(){this._model.removeEventListener("preChanging",this._modelListener.onChanging);this._model.removeEventListener("postChanged",this._modelListener.onChanged);this._theme.removeEventListener("ThemeChanged",this._themeListener.onChanged);this._modelListener=null;for(var a=0;a<this._handlers.length;a++){var b=this._handlers[a];z(b.target,b.type,
|
|
b.handler)}this._handlers=null;this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null)},_updateDOMSelection:function(){if(!(0<this._redrawCount)&&!this._ignoreDOMSelection&&this._clientDiv){var a=this._getSelection(),b=this._model,e=b.getLineAtOffset(a.start),c=b.getLineAtOffset(a.end),n=this._getLineNext();if(n){var l=this._getLinePrevious(),d;e<n.lineIndex?(e=n,d=b.getLineStart(n.lineIndex)):e>l.lineIndex?(e=l,d=b.getLineStart(l.lineIndex)):(e=this._getLineNode(e),
|
|
d=a.start);c<n.lineIndex?(c=n,b=b.getLineStart(n.lineIndex)):c>l.lineIndex?(c=l,b=b.getLineStart(l.lineIndex)):(c=this._getLineNode(c),b=a.end);this._setDOMSelection(e,d,c,b,a.caret)}}},_update:function(a){if(!(0<this._redrawCount)){this._updateTimer&&(this._getWindow().clearTimeout(this._updateTimer),this._updateTimer=null,a=!1);var b=this._clientDiv,e=this._viewDiv;if(b){this._metrics.invalid&&(this._ignoreQueueUpdate=!0,this._updateStyle(),this._ignoreQueueUpdate=!1);var c=this._model,n=this._getScroll(!1),
|
|
l=this._getViewPadding(),d=c.getLineCount(),s=this._getLineHeight(),g=!1,h=!1,u=!1,q=this._metrics.scrollWidth;this._wrapMode&&(b.style.width=(this._metrics.wrapWidth||this._getClientWidth())+"px");var k,v,p,y,r=0,z=0,t;if(this._lineHeight){for(;z<d;){t=this._getLineHeight(z);if(r+t>n.y)break;r+=t;z++}k=z;v=Math.max(0,k-1);p=c=n.y-r;0<k&&(c+=this._getLineHeight(k-1))}else y=Math.max(0,n.y)/s,k=Math.floor(y),v=Math.max(0,k-1),c=Math.round((y-v)*s),p=Math.round((y-k)*s);this._topIndexY=p;y=this._rootDiv;
|
|
var C=y.clientWidth,J=y.clientHeight;if(a){s=0;this._leftDiv&&(k=this._leftDiv.getBoundingClientRect(),s=k.right-k.left);k=this._getClientWidth();y=this._getClientHeight();h=k;this._wrapMode?this._metrics.wrapWidth&&(h=this._metrics.wrapWidth):h=Math.max(this._maxLineWidth,h);for(;z<d;)t=this._getLineHeight(z,!1),r+=t,z++;d=r}else{y=this._getClientHeight();p=Math.min(k+Math.floor((y+p)/s),d-1);var n=Math.min(p+1,d-1),E;for(t=b.firstChild;t;){E=t.lineIndex;var F=t.nextSibling;if(!(v<=E&&E<=n)||t.lineRemoved||
|
|
-1===t.lineIndex)this._mouseWheelLine===t?(t.style.display="none",t.lineIndex=-1):b.removeChild(t);t=F}t=this._getLineNext();var F=e.ownerDocument,I=F.createDocumentFragment();for(E=v;E<=n;E++)!t||t.lineIndex>E?(new x(this,E)).create(I,null):(I.firstChild&&(b.insertBefore(I,t),I=F.createDocumentFragment()),t&&t.lineChanged&&(t=(new x(this,E)).create(I,t),t.lineChanged=!1),t=this._getLineNext(t));I.firstChild&&b.insertBefore(I,t);f.isWebkit&&!this._wrapMode&&(b.style.width="0x7fffffffpx");t=this._getLineNext();
|
|
E=y+c;for(I=!1;t;)v=t.lineWidth,void 0===v&&(F=t._line.getBoundingClientRect(),v=t.lineWidth=Math.ceil(F.right-F.left),F=F.bottom-F.top,this._lineHeight?this._lineHeight[t.lineIndex]=F:0!==s&&(0!==F&&Math.ceil(s)!==Math.ceil(F))&&(this._variableLineHeight=!0,this._lineHeight=[],this._lineHeight[t.lineIndex]=F)),this._lineHeight&&!I&&(E-=this._lineHeight[t.lineIndex],0>E&&(p=t.lineIndex,I=!0)),this._wrapMode||(v>=this._maxLineWidth&&(this._maxLineWidth=v,this._maxLineIndex=t.lineIndex),this._checkMaxLineIndex===
|
|
t.lineIndex&&(this._checkMaxLineIndex=-1)),t.lineIndex===k&&(this._topChild=t),t.lineIndex===p&&(this._bottomChild=t),t=this._getLineNext(t);-1!==this._checkMaxLineIndex&&(E=this._checkMaxLineIndex,this._checkMaxLineIndex=-1,0<=E&&E<d&&(s=new x(this,E),F=s.getBoundingClientRect(),v=F.right-F.left,v>=this._maxLineWidth&&(this._maxLineWidth=v,this._maxLineIndex=E),s.destroy()));for(;z<d;)t=this._getLineHeight(z,z<=p),r+=t,z++;d=r;this._updateRuler(this._leftDiv,k,n,J);this._updateRuler(this._rightDiv,
|
|
k,n,J);this._updateRuler(this._innerRightDiv,k,n,J);this._updateRuler(this._marginDiv,k,n,J);s=0;this._leftDiv&&(k=this._leftDiv.getBoundingClientRect(),s=k.right-k.left);r=0;this._rightDiv&&(n=this._rightDiv.getBoundingClientRect(),r=n.right-n.left);e.style.left=s+"px";e.style.right=r+"px";n=this._scrollDiv;n.style.height=d+"px";k=this._getClientWidth();!this._singleMode&&(!this._wrapMode&&!this._noScroll)&&(z=g=y,(p="scroll"===e.style.overflowX)?g+=q:z-=q,v=t=k,(E="scroll"===e.style.overflowY)?
|
|
t+=q:v-=q,y=g,k=t,d>y&&(u=!0,k=v),this._maxLineWidth>k&&(h=!0,y=z,d>y&&(u=!0,k=v)),p!==h&&(e.style.overflowX=h?"scroll":"hidden"),E!==u&&(e.style.overflowY=u?"scroll":"hidden"),g=p!==h||E!==u);u=k;this._wrapMode?this._metrics.wrapWidth&&(u=this._metrics.wrapWidth):u=Math.max(this._maxLineWidth+this._getInnerRightWidth(),u);h=u;if((!f.isIE||9<=f.isIE)&&this._maxLineWidth>k)u+=l.right+l.left;n.style.width=u+"px";this._clipScrollDiv&&(this._clipScrollDiv.style.width=u+"px");n=this._getScroll(!1);if(u=
|
|
this._innerRightDiv)u.style.right=r+("scroll"===e.style.overflowY?this._metrics.scrollWidth:0)+"px",u.style.bottom=("scroll"===e.style.overflowX?q:0)+"px"}this._scrollHeight=d;this._vScrollDiv&&(u=y-8,r=Math.max(15,Math.ceil(Math.min(1,u/(d+l.top+l.bottom))*u)),this._vScrollDiv.style.left=s+k-8+"px",this._vScrollDiv.style.top=Math.floor(Math.max(0,n.y*u/d))+"px",this._vScrollDiv.style.height=r+"px");!this._wrapMode&&this._hScrollDiv&&(u=k-8,r=Math.max(15,Math.ceil(Math.min(1,u/(this._maxLineWidth+
|
|
l.left+l.right))*u)),this._hScrollDiv.style.left=s+Math.floor(Math.max(0,Math.floor(n.x*u/this._maxLineWidth)))+"px",this._hScrollDiv.style.top=y-9+"px",this._hScrollDiv.style.width=r+"px");z=n.x;r=this._clipDiv;u=this._overlayDiv;if(p=this._marginDiv)p.style.left=-z+s+this._metrics.marginWidth+l.left+"px",p.style.bottom=("scroll"===e.style.overflowX?q:0)+"px";r?(r.scrollLeft=z,r.scrollTop=0,e=s+l.left,q=l.top,a=k,s=y,z=0,p=-c,0===n.x&&(e-=l.left,a+=l.left,z=l.left),n.x+k===h&&(a+=l.right),0===n.y&&
|
|
(q-=l.top,s+=l.top,p+=l.top),n.y+y===d&&(s+=l.bottom),r.style.left=e+"px",r.style.top=q+"px",r.style.right=C-a-e+"px",r.style.bottom=J-s-q+"px",b.style.left=z+"px",b.style.top=p+"px",b.style.width=h+"px",b.style.height=y+c+"px",u&&(u.style.left=b.style.left,u.style.top=b.style.top,u.style.width=b.style.width,u.style.height=b.style.height)):(e=z,q=c,C=z+k,J=c+y,0===e&&(e-=l.left),0===q&&(q-=l.top),C===h&&(C+=l.right),n.y+y===d&&(J+=l.bottom),b.style.clip="rect("+q+"px,"+C+"px,"+J+"px,"+e+"px)",b.style.left=
|
|
-z+s+l.left+"px",b.style.width=(this._wrapMode||f.isWebkit?h:k+z)+"px",a||(b.style.top=-c+l.top+"px",b.style.height=y+c+"px"),u&&(u.style.clip=b.style.clip,u.style.left=b.style.left,u.style.width=b.style.width,a||(u.style.top=b.style.top,u.style.height=b.style.height)));this._updateDOMSelection();g&&(b=this._ensureCaretVisible,this._ensureCaretVisible=!1,b&&this._showCaret(),this._queueUpdate())}}},_updateOverflow:function(){var a=this._viewDiv;this._noScroll?a.style.overflow="hidden":this._wrapMode?
|
|
(a.style.overflowX="hidden",a.style.overflowY="scroll"):a.style.overflow="hidden"},_updateRuler:function(a,b,e,c){if(a)for(var n=this._parent.ownerDocument,l=this._getLineHeight(),d=this._getViewPadding(),s=a.firstChild;s;){var g=s._ruler,h=g.getOverview();s.rulerChanged&&(q(g.getRulerStyle(),s),a.rulerWidth=void 0);if("fixed"!==h){var u=l;"page"===h&&(u+=this._topIndexY);s.style.top=-u+"px";s.style.height=c+u+"px";var k,x=s.firstChild;x?(k=x,x=x.nextSibling):(k=f.createElement(n,"div"),k.style.visibility=
|
|
"hidden",s.appendChild(k));var v;if(s.rulerChanged&&k){u=-1;if(v=g.getWidestAnnotation())q(v.style,k),v.html&&(k.innerHTML=v.html);k.lineIndex=u;k.style.height=l+d.top+"px"}var p;if("page"===h){for(g=g.getAnnotations(b,e+1);x;)u=x.lineIndex,v=x.nextSibling,(!(b<=u&&u<=e)||x.lineChanged)&&s.removeChild(x),x=v;x=s.firstChild.nextSibling;p=n.createDocumentFragment();for(u=b;u<=e;u++)if(!x||x.lineIndex>u){k=f.createElement(n,"div");if(v=g[u])q(v.style,k),v.html&&(k.innerHTML=v.html),k.annotation=v;k.lineIndex=
|
|
u;k.style.height=this._getLineHeight(u)+"px";p.appendChild(k)}else p.firstChild&&(s.insertBefore(p,x),p=n.createDocumentFragment()),x&&(x=x.nextSibling);p.firstChild&&s.insertBefore(p,x)}else{v=this._getClientHeight();u=this._model.getLineCount();x=v+d.top+d.bottom-2*this._metrics.scrollWidth;h=l*u<x?l:x/u;if(s.rulerChanged){for(v=s.childNodes.length;1<v;)s.removeChild(s.lastChild),v--;g=g.getAnnotations(0,u);p=n.createDocumentFragment();for(var y in g)u=y>>>0,0>u||(k=f.createElement(n,"div"),v=g[y],
|
|
q(v.style,k),k.style.position="absolute",k.style.top=this._metrics.scrollWidth+l+Math.floor(u*h)+"px",v.html&&(k.innerHTML=v.html),k.annotation=v,k.lineIndex=u,p.appendChild(k));s.appendChild(p)}else if(s._oldTrackHeight!==x)for(k=s.firstChild?s.firstChild.nextSibling:null;k;)k.style.top=this._metrics.scrollWidth+l+Math.floor(k.lineIndex*h)+"px",k=k.nextSibling;s._oldTrackHeight=x}}s.rulerChanged=!1;s=s.nextSibling}},_updateStyleSheet:function(){var a="";f.isWebkit&&0<this._metrics.scrollWidth&&(a+=
|
|
"\n.textview ::-webkit-scrollbar-corner {background: #eeeeee;}");f.isFirefox&&(f.isMac&&this._highlightRGB&&"Highlight"!==this._highlightRGB)&&(a+="\n.textview ::-moz-selection {background: "+this._highlightRGB+";}");if(a){var b=this._clientDiv.ownerDocument,e=b.getElementById("_textviewStyle");if(e)e.removeChild(e.firstChild),e.appendChild(b.createTextNode(a));else{e=f.createElement(b,"style");e.id="_textviewStyle";var c=b.getElementsByTagName("head")[0]||b.documentElement;e.appendChild(b.createTextNode(a));
|
|
c.insertBefore(e,c.firstChild)}}},_updateStyle:function(a){!a&&f.isIE&&(this._rootDiv.style.lineHeight="normal");var b=this._metrics=this._calculateMetrics();this._variableLineHeight&&(this._variableLineHeight=!1,this._resetLineHeight());this._rootDiv.style.lineHeight=f.isIE?b.lineHeight-(b.lineTrim.top+b.lineTrim.bottom)+"px":"normal";this._updateStyleSheet();if(f.isMac&&f.isWebkit){var e=this._viewDiv;!b.invalid&&0===b.scrollWidth?(e.style.pointerEvents="none",e.style.zIndex="2"):(e.style.pointerEvents=
|
|
"",e.style.zIndex="")}a||(this.redraw(),this._resetLineWidth())}};k.EventTarget.addMixin(v.prototype);return{TextView:v}});
|
|
define("orion/editor/projectionTextModel",["orion/editor/textModel","orion/editor/eventTarget"],function(p,t){function r(k){this._model=k;this._projections=[];var g=this;this._listener={onChanged:function(h){g._onChanged(h)},onChanging:function(h){g._onChanging(h)}};k.addEventListener("postChanged",this._listener.onChanged);k.addEventListener("preChanging",this._listener.onChanging)}r.prototype={destroy:function(){this._model&&(this._model.removeEventListener("postChanged",this._listener.onChanged),
|
|
this._model.removeEventListener("preChanging",this._listener.onChanging),this._model=null)},addProjection:function(k){if(k){var g=this._model,h=this._projections;k._lineIndex=g.getLineAtOffset(k.start);k._lineCount=g.getLineAtOffset(k.end)-k._lineIndex;var f=k.text;f||(f="");k._model="string"===typeof f?new p.TextModel(f,g.getLineDelimiter()):f;var g=this.mapOffset(k.start,!0),f=k.end-k.start,q=k._lineCount,d=k._model.getCharCount(),c=k._model.getLineCount()-1,a={type:"Changing",text:k._model.getText(),
|
|
start:g,removedCharCount:f,addedCharCount:d,removedLineCount:q,addedLineCount:c};this.onChanging(a);a=this._binarySearch(h,k.start);h.splice(a,0,k);this.onChanged({type:"Changed",start:g,removedCharCount:f,addedCharCount:d,removedLineCount:q,addedLineCount:c})}},getProjections:function(){return this._projections.slice(0)},getBaseModel:function(){return this._model},mapOffset:function(k,g){var h=this._projections,f=0,q,d;if(g){for(q=0;q<h.length;q++){d=h[q];if(d.start>k)break;if(d.end>k)return-1;f+=
|
|
d._model.getCharCount()-(d.end-d.start)}return k+f}for(q=0;q<h.length;q++){d=h[q];if(d.start>k-f)break;var c=d._model.getCharCount();if(d.start+c>k-f)return-1;f+=c-(d.end-d.start)}return k-f},removeProjection:function(k){this._removeProjection(k)},_removeProjection:function(k,g){var h,f=0;for(h=0;h<this._projections.length;h++){var q=this._projections[h];if(q===k){k=q;break}f+=q._model.getCharCount()-(q.end-q.start)}if(h<this._projections.length){var q=this._model,f=k.start+f,d=k.end-k.start,c=k._lineCount,
|
|
a=k._model.getCharCount(),b=k._model.getLineCount()-1;g||(q={type:"Changing",text:q.getText(k.start,k.end),start:f,removedCharCount:a,addedCharCount:d,removedLineCount:b,addedLineCount:c},this.onChanging(q));this._projections.splice(h,1);if(!g)this.onChanged({type:"Changed",start:f,removedCharCount:a,addedCharCount:d,removedLineCount:b,addedLineCount:c})}},_binarySearch:function(k,g){for(var h=k.length,f=-1,q;1<h-f;)q=Math.floor((h+f)/2),g<=k[q].start?h=q:f=q;return h},getCharCount:function(){for(var k=
|
|
this._model.getCharCount(),g=this._projections,h=0;h<g.length;h++)var f=g[h],k=k+(f._model.getCharCount()-(f.end-f.start));return k},getLine:function(k,g){if(0>k)return null;var h=this._model,f=this._projections,q=0,d=[],c=0,a,b,l;for(a=0;a<f.length;a++){l=f[a];if(l._lineIndex>=k-q)break;b=l._model.getLineCount()-1;if(l._lineIndex+b>=k-q){c=k-(l._lineIndex+q);if(c<b)return l._model.getLine(c,g);d.push(l._model.getLine(b))}c=l.end;q+=b-l._lineCount}for(c=Math.max(c,h.getLineStart(k-q));a<f.length;a++){l=
|
|
f[a];if(l._lineIndex>k-q)break;d.push(h.getText(c,l.start));b=l._model.getLineCount()-1;if(l._lineIndex+b>k-q)return d.push(l._model.getLine(0,g)),d.join("");d.push(l._model.getText());c=l.end;q+=b-l._lineCount}f=h.getLineEnd(k-q,g);c<f&&d.push(h.getText(c,f));return d.join("")},getLineAtOffset:function(k){for(var g=this._model,h=this._projections,f=0,q=0,d=0;d<h.length;d++){var c=h[d];if(c.start>k-f)break;var a=c._model.getCharCount();if(c.start+a>k-f){h=k-(c.start+f);q+=c._model.getLineAtOffset(h);
|
|
f+=h;break}q+=c._model.getLineCount()-1-c._lineCount;f+=a-(c.end-c.start)}return g.getLineAtOffset(k-f)+q},getLineCount:function(){for(var k=this._projections,g=this._model.getLineCount(),h=0;h<k.length;h++)var f=k[h],g=g+(f._model.getLineCount()-1-f._lineCount);return g},getLineDelimiter:function(){return this._model.getLineDelimiter()},getLineEnd:function(k,g){if(0>k)return-1;for(var h=this._model,f=this._projections,q=0,d=0,c=0;c<f.length;c++){var a=f[c];if(a._lineIndex>k-q)break;var b=a._model.getLineCount()-
|
|
1;if(a._lineIndex+b>k-q)return a._model.getLineEnd(k-(a._lineIndex+q),g)+a.start+d;d+=a._model.getCharCount()-(a.end-a.start);q+=b-a._lineCount}return h.getLineEnd(k-q,g)+d},getLineStart:function(k){if(0>k)return-1;for(var g=this._model,h=this._projections,f=0,q=0,d=0;d<h.length;d++){var c=h[d];if(c._lineIndex>=k-f)break;var a=c._model.getLineCount()-1;if(c._lineIndex+a>=k-f)return c._model.getLineStart(k-(c._lineIndex+f))+c.start+q;q+=c._model.getCharCount()-(c.end-c.start);f+=a-c._lineCount}return g.getLineStart(k-
|
|
f)+q},getText:function(k,g){void 0===k&&(k=0);var h=this._model,f=this._projections,q=0,d=[],c,a,b;for(c=0;c<f.length;c++){a=f[c];if(a.start>k-q)break;b=a._model.getCharCount();if(a.start+b>k-q){if(void 0!==g&&a.start+b>g-q)return a._model.getText(k-(a.start+q),g-(a.start+q));d.push(a._model.getText(k-(a.start+q)));k=a.end+q+b-(a.end-a.start)}q+=b-(a.end-a.start)}var l=k-q;if(void 0!==g){for(;c<f.length;c++){a=f[c];if(a.start>g-q)break;d.push(h.getText(l,a.start));b=a._model.getCharCount();if(a.start+
|
|
b>g-q)return d.push(a._model.getText(0,g-(a.start+q))),d.join("");d.push(a._model.getText());l=a.end;q+=b-(a.end-a.start)}d.push(h.getText(l,g-q))}else{for(;c<f.length;c++)a=f[c],d.push(h.getText(l,a.start)),d.push(a._model.getText()),l=a.end;d.push(h.getText(l))}return d.join("")},_onChanged:function(k){k=this._change;var g=k.baseStart,h=k.baseEnd,f,q,d=this._projections;for(f=0;f<d.length&&!(q=d[f],q.end>g);f++);var c=f;for(f=0;f<d.length&&!(q=d[f],q.start>=h);f++);var a=f,b=this._model,g=k.baseText.length-
|
|
(h-g);for(f=a;f<d.length;f++)q=d[f],q.start+=g,q.end+=g,q._lineIndex=b.getLineAtOffset(q.start);q=d.splice(c,a-c);for(f=0;f<q.length;f++)q[f].annotation&&q[f].annotation._expand();this.onChanged({type:"Changed",start:k.start,removedCharCount:k.removedCharCount,addedCharCount:k.addedCharCount,removedLineCount:k.removedLineCount,addedLineCount:k.addedLineCount});this._change=void 0},_onChanging:function(k){var g=!!this._change,h=this._change||{},f=k.start,q=f+k.removedCharCount;h.baseStart=f;h.baseEnd=
|
|
q;h.baseText=k.text;h.addedLineCount=k.addedLineCount;if(!g){this._change=h;h.text=k.text;var d=this._projections,c,a,b;k=function(l){for(c=a=0;a<d.length;a++){b=d[a];if(b.start>l)break;if(b.end>l)return-1;c+=b._model.getCharCount()-(b.end-b.start)}return l+c};h.start=k(f);-1===h.start&&(h.text=this._model.getText(b.start,f)+h.text,h.addedLineCount+=this._model.getLineAtOffset(f)-this._model.getLineAtOffset(b.start),h.start=b.start+c);h.end=k(q);-1===h.end&&(h.text+=this._model.getText(q,b.end),h.addedLineCount+=
|
|
this._model.getLineAtOffset(b.end)-this._model.getLineAtOffset(q),h.end=b.start+c)}h.addedCharCount=h.text.length;h.removedCharCount=h.end-h.start;h.removedLineCount=this.getLineAtOffset(h.end)-this.getLineAtOffset(h.start);this.onChanging({type:"Changing",text:h.text,start:h.start,removedCharCount:h.removedCharCount,addedCharCount:h.addedCharCount,removedLineCount:h.removedLineCount,addedLineCount:h.addedLineCount})},onChanging:function(k){return this.dispatchEvent(k)},onChanged:function(k){return this.dispatchEvent(k)},
|
|
setLineDelimiter:function(k){this._model.setLineDelimiter(k)},setText:function(k,g,h){function f(b){for(d=c=0;c<q.length;c++){a=q[c];if(a.start>b-d)break;var e=a._model.getCharCount();if(a.start+e>b-d)return-1;d+=e-(a.end-a.start)}return b-d}this._change={text:k||"",start:g||0,end:void 0===h?this.getCharCount():h};var q=this._projections,d,c,a,b,l;k=f(this._change.start);-1===k&&(b={projection:a,start:this._change.start-(a.start+d)},k=a.end);g=f(this._change.end);-1===g&&(l={projection:a,end:this._change.end-
|
|
(a.start+d)},g=a.start);b&&l&&b.projection===l.projection?a._model.setText(this._change.text,b.start,l.end):(this._model.setText(this._change.text,k,g),b&&(a=b.projection,a._model.setText("",b.start)),l&&(a=l.projection,a._model.setText("",0,l.end),a.start=a.end,a._lineCount=0));this._change=void 0}};t.EventTarget.addMixin(r.prototype);return{ProjectionTextModel:r}});
|
|
define("orion/editor/annotations",["i18n!orion/editor/nls/messages","orion/editor/eventTarget"],function(p,t){function r(){}function k(a,b,c){this.start=a;this.end=b;this._projectionModel=c;this.html=this._expandedHTML;this.style=this._expandedStyle;this.expanded=!0}function g(a,b){var c=a.lastIndexOf("."),c=a.substring(c+1),n={title:p[c],style:{styleClass:"annotation "+c},html:"\x3cdiv class\x3d'annotationHTML "+c+"'\x3e\x3c/div\x3e",overviewStyle:{styleClass:"annotationOverview "+c}};b?n.lineStyle=
|
|
{styleClass:"annotationLine "+c}:n.rangeStyle={styleClass:"annotationRange "+c};r.registerType(a,n)}function h(){}function f(a,b,c,n,e){var s;void 0===n&&(n=-1);void 0===e&&(e=a.length);for(;1<e-n;)if(s=Math.floor((e+n)/2),b<=a[s].start)e=s;else if(c&&b<a[s].end){e=s;break}else n=s;return e}function q(a){this._annotations=[];var b=this;this._listener={onChanged:function(a){b._onChanged(a)}};this.setTextModel(a)}function d(a,b){this._view=a;this._annotationModel=b;var c=this;this._listener={onDestroy:function(a){c._onDestroy(a)},
|
|
onLineStyle:function(a){c._onLineStyle(a)},onChanged:function(a){c._onAnnotationModelChanged(a)}};a.addEventListener("Destroy",this._listener.onDestroy);a.addEventListener("postLineStyle",this._listener.onLineStyle);b.addEventListener("Changed",this._listener.onChanged)}k.prototype={_expandedHTML:"\x3cdiv class\x3d'annotationHTML expanded'\x3e\x3c/div\x3e",_expandedStyle:{styleClass:"annotation expanded"},_collapsedHTML:"\x3cdiv class\x3d'annotationHTML collapsed'\x3e\x3c/div\x3e",_collapsedStyle:{styleClass:"annotation collapsed"},
|
|
_collapse:function(){if(!this.expanded)return!1;this.expanded=!1;this.html=this._collapsedHTML;this.style=this._collapsedStyle;this._annotationModel&&this._annotationModel.modifyAnnotation(this);return!0},_expand:function(){if(this.expanded)return!1;this.expanded=!0;this.html=this._expandedHTML;this.style=this._expandedStyle;this._annotationModel&&this._annotationModel.modifyAnnotation(this);return!0},_collapseImpl:function(a){if(this._collapse()){a&&this._forEachOverlaping(function(a){a.expanded||
|
|
(a._expandImpl(!1),a._recollapse=!0)});a=this._projectionModel;var b=a.getBaseModel();this._projection={annotation:this,start:b.getLineStart(b.getLineAtOffset(this.start)+1),end:b.getLineEnd(b.getLineAtOffset(this.end),!0)};a.addProjection(this._projection)}},_expandImpl:function(a){this._expand()&&(this._projectionModel._removeProjection(this._projection,!this._annotationModel),a&&this._forEachOverlaping(function(a){a._recollapse&&(a._collapseImpl(!1),a._recollapse=!1)}))},_forEachOverlaping:function(a){if(this._annotationModel)for(var b=
|
|
this._annotationModel.getAnnotations(this.start,this.end);b.hasNext();){var c=b.next();c!==this&&c.type===r.ANNOTATION_FOLDING&&a.call(this,c)}},collapse:function(){this._recollapse=!1;this._collapseImpl(!0)},expand:function(){this._recollapse=!1;this._expandImpl(!0)}};r.ANNOTATION_ERROR="orion.annotation.error";r.ANNOTATION_WARNING="orion.annotation.warning";r.ANNOTATION_TASK="orion.annotation.task";r.ANNOTATION_BREAKPOINT="orion.annotation.breakpoint";r.ANNOTATION_BOOKMARK="orion.annotation.bookmark";
|
|
r.ANNOTATION_FOLDING="orion.annotation.folding";r.ANNOTATION_CURRENT_BRACKET="orion.annotation.currentBracket";r.ANNOTATION_MATCHING_BRACKET="orion.annotation.matchingBracket";r.ANNOTATION_CURRENT_LINE="orion.annotation.currentLine";r.ANNOTATION_CURRENT_SEARCH="orion.annotation.currentSearch";r.ANNOTATION_MATCHING_SEARCH="orion.annotation.matchingSearch";r.ANNOTATION_READ_OCCURRENCE="orion.annotation.readOccurrence";r.ANNOTATION_WRITE_OCCURRENCE="orion.annotation.writeOccurrence";r.ANNOTATION_SELECTED_LINKED_GROUP=
|
|
"orion.annotation.selectedLinkedGroup";r.ANNOTATION_CURRENT_LINKED_GROUP="orion.annotation.currentLinkedGroup";r.ANNOTATION_LINKED_GROUP="orion.annotation.linkedGroup";r.ANNOTATION_BLAME="orion.annotation.blame";r.ANNOTATION_CURRENT_BLAME="orion.annotation.currentBlame";var c={};r.registerType=function(a,b){var l=b;"function"!==typeof l&&(l=function(a,b,c){this.start=a;this.end=b;void 0!==c&&(this.title=c)},l.prototype=b);l.prototype.type=a;c[a]=l;return a};r.createAnnotation=function(a,b,c,n){return new (this.getType(a))(b,
|
|
c,n)};r.getType=function(a){return c[a]};g(r.ANNOTATION_ERROR);g(r.ANNOTATION_WARNING);g(r.ANNOTATION_TASK);g(r.ANNOTATION_BREAKPOINT);g(r.ANNOTATION_BOOKMARK);g(r.ANNOTATION_CURRENT_BRACKET);g(r.ANNOTATION_MATCHING_BRACKET);g(r.ANNOTATION_CURRENT_SEARCH);g(r.ANNOTATION_MATCHING_SEARCH);g(r.ANNOTATION_READ_OCCURRENCE);g(r.ANNOTATION_WRITE_OCCURRENCE);g(r.ANNOTATION_SELECTED_LINKED_GROUP);g(r.ANNOTATION_CURRENT_LINKED_GROUP);g(r.ANNOTATION_LINKED_GROUP);g(r.ANNOTATION_CURRENT_LINE,!0);g(r.ANNOTATION_BLAME,
|
|
!0);g(r.ANNOTATION_CURRENT_BLAME,!0);r.registerType(r.ANNOTATION_FOLDING,k);h.addMixin=function(a){var b=h.prototype,c;for(c in b)b.hasOwnProperty(c)&&(a[c]=b[c])};h.prototype={addAnnotationType:function(a,b){this._annotationTypes||(this._annotationTypes=[]);var c=b-1;void 0==b||!(0<=c&&c<this._annotationTypes.length)?this._annotationTypes.push(a):this._annotationTypes.splice(c,0,a)},getAnnotationTypePriority:function(a){if(this._annotationTypes)for(var b=0;b<this._annotationTypes.length;b++)if(this._annotationTypes[b]===
|
|
a)return b+1;return 0},getAnnotationsByType:function(a,b,c){a=a.getAnnotations(b,c);for(c=[];a.hasNext();)b=a.next(),0!==this.getAnnotationTypePriority(b.type)&&c.push(b);var n=this;c.sort(function(a,b){return n.getAnnotationTypePriority(a.type)-n.getAnnotationTypePriority(b.type)});return c},isAnnotationTypeVisible:function(a){return 0!==this.getAnnotationTypePriority(a)},removeAnnotationType:function(a){if(this._annotationTypes)for(var b=0;b<this._annotationTypes.length;b++)if(this._annotationTypes[b]===
|
|
a){this._annotationTypes.splice(b,1);break}}};q.prototype={addAnnotation:function(a){if(a){var b=this._annotations,c=f(b,a.start);b.splice(c,0,a);a._annotationModel=this;this.onChanged({type:"Changed",added:[a],removed:[],changed:[]})}},getTextModel:function(){return this._model},getAnnotations:function(a,b){var c=this._annotations,n,e=0,s;s=void 0===a&&void 0===b?function(){return e<c.length?c[e++]:null}:function(){for(;e<c.length;){var n=c[e++];if(a===n.start||(a>n.start?a<n.end:n.start<b))return n;
|
|
if(n.start>=b)break}return null};n=s();return{next:function(){var a=n;a&&(n=s());return a},hasNext:function(){return null!==n}}},modifyAnnotation:function(a){if(a&&!(0>this._getAnnotationIndex(a)))this.onChanged({type:"Changed",added:[],removed:[],changed:[a]})},onChanged:function(a){return this.dispatchEvent(a)},removeAnnotations:function(a){var b=this._annotations,c,n;if(a){c=[];for(n=b.length-1;0<=n;n--){var e=b[n];e.type===a&&(b.splice(n,1),c.splice(0,0,e),e._annotationModel=null)}}else c=b;this.onChanged({type:"Changed",
|
|
removed:c,added:[],changed:[]})},removeAnnotation:function(a){if(a){var b=this._getAnnotationIndex(a);0>b||(a._annotationModel=null,a={type:"Changed",removed:this._annotations.splice(b,1),added:[],changed:[]},this.onChanged(a))}},replaceAnnotations:function(a,b){var c=this._annotations,n,e,s,d=[];if(a)for(n=a.length-1;0<=n;n--)s=a[n],e=this._getAnnotationIndex(s),0>e||(s._annotationModel=null,c.splice(e,1),d.splice(0,0,s));b||(b=[]);for(n=0;n<b.length;n++)s=b[n],e=f(c,s.start),s._annotationModel=
|
|
this,c.splice(e,0,s);this.onChanged({type:"Changed",removed:d,added:b,changed:[]})},setTextModel:function(a){this._model&&this._model.removeEventListener("Changed",this._listener.onChanged);(this._model=a)&&this._model.addEventListener("Changed",this._listener.onChanged)},_getAnnotationIndex:function(a){for(var b=this._annotations,c=f(b,a.start);c<b.length&&b[c].start===a.start;){if(b[c]===a)return c;c++}return-1},_onChanged:function(a){var b=a.start,c=a.addedCharCount,n=a.removedCharCount,e=this._annotations,
|
|
s=b+n;if(0<e.length){a={type:"Changed",added:[],removed:[],changed:[],textModelChangedEvent:a};c-=n;for(n=0;n<e.length;n++){var d=e[n];d.start>=s?(d._oldStart=d.start,d._oldEnd=d.end,d.start+=c,d.end+=c,a.changed.push(d)):d.end<=b||(d.start<b&&s<d.end?(d._oldStart=d.start,d._oldEnd=d.end,d.end+=c,a.changed.push(d)):(e.splice(n,1),a.removed.push(d),d._annotationModel=null,d.expand&&d.expand(),n--))}if(0<a.added.length||0<a.removed.length||0<a.changed.length)this.onChanged(a)}}};t.EventTarget.addMixin(q.prototype);
|
|
d.prototype={destroy:function(){var a=this._view;a&&(a.removeEventListener("Destroy",this._listener.onDestroy),a.removeEventListener("LineStyle",this._listener.onLineStyle),this.view=null);(a=this._annotationModel)&&a.removeEventListener("Changed",this._listener.onChanged)},_mergeStyle:function(a,b){if(b){a||(a={});a.styleClass=a.styleClass&&b.styleClass&&a.styleClass!==b.styleClass?a.styleClass+(" "+b.styleClass):b.styleClass;var c;b.tagName&&!a.tagName&&(a.tagName=b.tagName);if(b.style)for(c in a.style||
|
|
(a.style={}),b.style)a.style[c]||(a.style[c]=b.style[c]);if(b.attributes)for(c in a.attributes||(a.attributes={}),b.attributes)a.attributes[c]||(a.attributes[c]=b.attributes[c])}return a},_mergeStyleRanges:function(a,b){a||(a=[]);for(var c,n=f(a,b.start,!0);n<a.length&&b;n++){var e=a[n];if(b.end<=e.start)break;if(!(b.start>=e.end)){c=this._mergeStyle({},e.style);c=this._mergeStyle(c,b.style);var d=[];d.push(n,1);b.start<e.start&&d.push({start:b.start,end:e.start,style:b.style});b.start>e.start&&d.push({start:e.start,
|
|
end:b.start,style:e.style});d.push({start:Math.max(e.start,b.start),end:Math.min(e.end,b.end),style:c});b.end<e.end&&d.push({start:b.end,end:e.end,style:e.style});b=b.end>e.end?{start:e.end,end:b.end,style:b.style}:null;Array.prototype.splice.apply(a,d)}}b&&(c=this._mergeStyle({},b.style),a.splice(n,0,{start:b.start,end:b.end,style:c}));return a},_onAnnotationModelChanged:function(a){function b(a,b){d.getBaseModel&&(a=d.mapOffset(a,!0),b=d.mapOffset(b,!0));-1!==a&&-1!==b&&n.redrawRange(a,b)}function c(a,
|
|
n){for(var l=0;l<a.length;l++)if(e.isAnnotationTypeVisible(a[l].type)){var d=a[l];b(d.start,d.end);n&&(void 0!==d._oldStart&&d._oldEnd)&&b(d._oldStart,d._oldEnd)}}var n=this._view;if(n){var e=this,d=n.getModel();c(a.added);c(a.removed);c(a.changed,!0)}},_onDestroy:function(a){this.destroy()},_onLineStyle:function(a){var b=this._annotationModel,c=a.textView.getModel(),n=b.getTextModel(),e=a.lineStart,d=a.lineStart+a.lineText.length;n!==c&&(e=c.mapOffset(e),d=c.mapOffset(d));for(b=b.getAnnotations(e,
|
|
d);b.hasNext();)if(e=b.next(),this.isAnnotationTypeVisible(e.type)){if(e.rangeStyle){var d=e.start,f=e.end;n!==c&&(d=c.mapOffset(d,!0),f=c.mapOffset(f,!0));a.ranges=this._mergeStyleRanges(a.ranges,{start:d,end:f,style:e.rangeStyle})}e.lineStyle&&(a.style=this._mergeStyle({},a.style),a.style=this._mergeStyle(a.style,e.lineStyle))}}};h.addMixin(d.prototype);return{FoldingAnnotation:k,AnnotationType:r,AnnotationTypeList:h,AnnotationModel:q,AnnotationStyler:d}});
|
|
define("orion/editor/tooltip",["i18n!orion/editor/nls/messages","orion/editor/textView","orion/editor/projectionTextModel","orion/editor/util","orion/util"],function(p,t,r,k,g){function h(f){this._view=f;this._fadeDelay=500;this._hideDelay=200;this._showDelay=500;this._autoHideDelay=5E3;this._create(f.getOptions("parent").ownerDocument)}h.getTooltip=function(f){f._tooltip||(f._tooltip=new h(f));return f._tooltip};h.prototype={_create:function(f){if(!this._tooltipDiv){var h=this._tooltipDiv=g.createElement(f,
|
|
"div");h.tabIndex=0;h.className="textviewTooltip";h.setAttribute("aria-live","assertive");h.setAttribute("aria-atomic","true");var d=this._tooltipContents=g.createElement(f,"div");h.appendChild(d);f.body.appendChild(h);var c=this;k.addEventListener(h,"mouseover",function(a){c._hideDelay&&(a=c._getWindow(),c._delayedHideTimeout&&(a.clearTimeout(c._delayedHideTimeout),c._delayedHideTimeout=null),c._hideTimeout&&(a.clearTimeout(c._hideTimeout),c._hideTimeout=null),c._nextTarget=null)},!1);k.addEventListener(h,
|
|
"mouseout",function(a){a=a.relatedTarget||a.toElement;!(a===h||c._hasFocus())&&(!a||!k.contains(h,a))&&c._hide()},!1);k.addEventListener(h,"keydown",function(a){27===a.keyCode&&c._hide()},!1);k.addEventListener(f,"mousedown",this._mouseDownHandler=function(a){c.isVisible()&&(k.contains(h,a.target||a.srcElement)||c._hide())},!0);this._view.addEventListener("Destroy",function(){c.destroy()});this._hide()}},_getWindow:function(){var f=this._tooltipDiv.ownerDocument;return f.defaultView||f.parentWindow},
|
|
destroy:function(){if(this._tooltipDiv){this._hide();var f=this._tooltipDiv.parentNode;f&&f.removeChild(this._tooltipDiv);k.removeEventListener(this._tooltipDiv.ownerDocument,"mousedown",this._mouseDownHandler,!0);this._tooltipDiv=null}},_hasFocus:function(){var f=this._tooltipDiv;return!f?!1:k.contains(f,f.ownerDocument.activeElement)},hide:function(f){void 0===f&&(f=this._hideDelay);var g=this._getWindow();this._delayedHideTimeout&&(g.clearTimeout(this._delayedHideTimeout),this._delayedHideTimeout=
|
|
null);var d=this;f?d._delayedHideTimeout=g.setTimeout(function(){d._delayedHideTimeout=null;d._hide();d.setTarget(d._nextTarget,0)},f):(d._hide(),d.setTarget(d._nextTarget,0))},_hide:function(){var f=this._tooltipDiv;f&&(this._hasFocus()&&this._view.focus(),this._contentsView&&(this._contentsView.destroy(),this._contentsView=null),this._tooltipContents&&(this._tooltipContents.innerHTML=""),f.style.visibility="hidden",f=this._getWindow(),this._showTimeout&&(f.clearTimeout(this._showTimeout),this._showTimeout=
|
|
null),this._delayedHideTimeout&&(f.clearTimeout(this._delayedHideTimeout),this._delayedHideTimeout=null),this._hideTimeout&&(f.clearTimeout(this._hideTimeout),this._hideTimeout=null),this._fadeTimeout&&(f.clearInterval(this._fadeTimeout),this._fadeTimeout=null))},isVisible:function(){return this._tooltipDiv&&"visible"===this._tooltipDiv.style.visibility},setTarget:function(f,g,d){if(this.isVisible())this._hasFocus()||(this._nextTarget=f,this.hide(d));else if(this._target=f){var c=this;f=c._getWindow();
|
|
c._showTimeout&&(f.clearTimeout(c._showTimeout),c._showTimeout=null);0===g?c.show(!0):c._showTimeout=f.setTimeout(function(){c._showTimeout=null;c.show(!0)},g?g:c._showDelay)}},show:function(f){if(this._target){var g=this._target.getTooltipInfo();if(g){var d=this._tooltipDiv,c=this._tooltipContents;d.style.left=d.style.right=d.style.width=d.style.height=c.style.width=c.style.height="auto";var a=d.ownerDocument,b=a.documentElement,l=g.contents;l instanceof Array&&(l=this._getAnnotationContents(l));
|
|
if("string"===typeof l)c.innerHTML=l;else if(this._isNode(l))c.appendChild(l);else if(l instanceof r.ProjectionTextModel){var n=this._view,e=n.getOptions();e.wrapMode=!1;e.parent=c;var s=e.themeClass;s?((s=s.replace("tooltipTheme",""))&&(s=" "+s),s="tooltipTheme"+s):s="tooltipTheme";e.themeClass=s;e=this._contentsView=new t.TextView(e);e.addEventListener("LineStyle",function(a){n.onLineStyle(a)});e.setModel(l);s=e.computeSize();c.style.width=s.width+"px";c.style.height=s.height+"px";e.resize()}else if(!g.deferredInfo)return;
|
|
if(e=g.deferredInfo){var h=this;e.forEach(function(b){b.promise.then(function(e){e&&(e.content&&h._renderContent(a,c,e,b),d.style.visibility="visible")},function(a){console.error("Problem computing hover tooltip",a)})})}"right"===g.anchor?(e=b.clientWidth-g.x,d.style.right=e+"px"):(e=parseInt(this._getNodeStyle(d,"padding-left","0"),10),e+=parseInt(this._getNodeStyle(d,"border-left-width","0"),10),e=g.x-e,d.style.left=e+"px");d.style.maxWidth=b.clientWidth-e-10+"px";e=parseInt(this._getNodeStyle(d,
|
|
"padding-top","0"),10);e+=parseInt(this._getNodeStyle(d,"border-top-width","0"),10);e=g.y-e;d.style.top=e+"px";d.style.maxHeight=b.clientHeight-e-10+"px";d.style.opacity="1";l&&(d.style.visibility="visible");if(f){var h=this,k=this._getWindow();h._hideTimeout=k.setTimeout(function(){h._hideTimeout=null;var a=parseFloat(h._getNodeStyle(d,"opacity","1"));h._fadeTimeout=k.setInterval(function(){"visible"===d.style.visibility&&0<a?(a-=0.1,d.style.opacity=a):h._hide()},h._fadeDelay/10)},h._autoHideDelay)}}}},
|
|
_renderContent:function(f,h,d,c){var a=null,b=null;d.title&&(a=g.createElement(f,"div"),a.innerHTML=c.renderMarkDown(d.title),h.appendChild(a));switch(d.type){case "markdown":d.content&&(b=g.createElement(f,"div"),b.innerHTML=c.renderMarkDown(d.content),a.appendChild(b));break;case "proposal":var l=d.content,a=g.createElement(f,"button");a.textContent=l.label;h.appendChild(a);var n=this;a.addEventListener("click",function(){n._view.setText(l.text,l.start,l.end);n._hide()});break;default:d.title&&
|
|
(a=g.createElement(f,"div"),a.textContent=d.title),d.content&&(h.appendChild(a),b=g.createElement(f,"div"),b.appendChild(f.createTextNode(d.content)),a.appendChild(b))}},_getAnnotationContents:function(f){function h(a,b){var e=u.getLineStart(u.getLineAtOffset(a)),c=u.getLineEnd(u.getLineAtOffset(b),!0);return u.getText(e,c)}function d(a){var b=a.title,c=g.createElement(n,"div");c.className="tooltipRow";a.html&&(c.innerHTML=a.html,c.lastChild&&k.addEventListener(c.lastChild,"click",function(b){b=a.start;
|
|
var c=a.end;s.getBaseModel&&(b=s.mapOffset(b,!0),c=s.mapOffset(c,!0));e.setSelection(b,c,1/3,function(){l._hide()})},!1),c.appendChild(n.createTextNode("\u00a0")));b||(b=h(a.start,a.end));"function"===typeof b&&(b=a.title());if("string"===typeof b){var d=g.createElement(n,"span");d.appendChild(n.createTextNode(b));b=d}c.appendChild(b);return c}for(var c,a=[],b=0;b<f.length;b++)c=f[b],""!==c.title&&!c.groupAnnotation&&a.push(c);f=a;if(0===f.length)return null;var l=this,n=this._tooltipDiv.ownerDocument,
|
|
e=this._view,s=e.getModel(),u=s.getBaseModel?s.getBaseModel():s;if(1===f.length){c=f[0];if(void 0!==c.title)return c=d(c),c.firstChild&&((f=c.firstChild.className)&&(f+=" "),c.firstChild.className=f+"single"),c;f=new r.ProjectionTextModel(u);a=u.getLineStart(u.getLineAtOffset(c.start));b=u.getCharCount();c.end!==b&&f.addProjection({start:c.end,end:b});0<a&&f.addProjection({start:0,end:a});return f}a=g.createElement(n,"div");c=g.createElement(n,"em");c.appendChild(n.createTextNode(p.multipleAnnotations));
|
|
a.appendChild(c);for(b=0;b<f.length;b++)c=f[b],(c=d(c))&&a.appendChild(c);return a},_getNodeStyle:function(f,g,d){return k.getNodeStyle(f,g,d)},_isNode:function(f){return"object"===typeof Node?f instanceof Node:f&&"object"===typeof f&&"number"===typeof f.nodeType&&"string"===typeof f.nodeName}};return{Tooltip:h}});
|
|
define("orion/objects",[],function(){function p(p){for(var r=Object.prototype.hasOwnProperty,k=1,g=arguments.length;k<g;k++){var h=arguments[k],f;for(f in h)r.call(h,f)&&(p[f]=h[f])}return p}return{clone:function(t){if(Array.isArray(t))return Array.prototype.slice.call(t);var r=Object.create(Object.getPrototypeOf(t));p(r,t);return r},mixin:p,toArray:function(p){return Array.isArray(p)?p:[p]}}});
|
|
define("orion/editor/rulers","i18n!orion/editor/nls/messages orion/editor/textView orion/editor/annotations orion/editor/tooltip orion/objects orion/editor/util orion/util".split(" "),function(p,t,r,k,g,h,f){function q(a,b,c){this._location=a||"left";this._overview=b||"page";this._rulerStyle=c;this._view=null}function d(a,b,c,l){q.call(this,b,c,l);var d=this;this._listener={onTextModelChanged:function(a){d._onTextModelChanged(a)},onAnnotationModelChanged:function(a){d._onAnnotationModelChanged(a)}};
|
|
this.setAnnotationModel(a)}function c(a,b,c,l,f){d.call(this,a,b,"page",c);this._oddStyle=l||{style:{backgroundColor:"white"}};this._evenStyle=f||{style:{backgroundColor:"white"}};this._numOfDigits=0;this._firstLine=1}function a(a,b,c){d.call(this,a,b,"page",c)}function b(a,b,c){d.call(this,a,b,"document",c)}function l(b,e,c){a.call(this,b,e,c)}q.prototype={getLocation:function(){return this._location},getOverview:function(){return this._overview},getRulerStyle:function(){return this._rulerStyle},
|
|
getView:function(){return this._view},setView:function(a){this._onTextModelChanged&&this._view&&this._view.removeEventListener("ModelChanged",this._listener.onTextModelChanged);this._view=a;this._onTextModelChanged&&this._view&&this._view.addEventListener("ModelChanged",this._listener.onTextModelChanged)}};d.prototype=g.mixin(new q,{getAnnotations:function(a,b){var c=this._annotationModel;if(!c)return[];var l=this._view.getModel(),d=l.getLineStart(a),f=l.getLineEnd(b-1),g=l;l.getBaseModel&&(g=l.getBaseModel(),
|
|
d=l.mapOffset(d),f=l.mapOffset(f));for(var h=[],c=this.getAnnotationsByType(c,d,f),d=0;d<c.length;d++)for(var f=c[d],k=g.getLineAtOffset(f.start),m=g.getLineAtOffset(Math.max(f.start,f.end-1)),q=k;q<=m;q++){var p=q;if(l!==g){p=g.getLineStart(q);p=l.mapOffset(p,!0);if(-1===p)continue;p=l.getLineAtOffset(p)}if(a<=p&&p<b){var r=this._mergeAnnotation(h[p],f,q-k,m-k+1);r&&(h[p]=r)}}if(!this._multiAnnotation&&this._multiAnnotationOverlay)for(var t in h)h[t]._multiple&&(h[t].html+=this._multiAnnotationOverlay.html);
|
|
return h},getAnnotationModel:function(){return this._annotationModel},getWidestAnnotation:function(){return null},setAnnotationModel:function(a){this._annotationModel&&this._annotationModel.removEventListener("Changed",this._listener.onAnnotationModelChanged);(this._annotationModel=a)&&this._annotationModel.addEventListener("Changed",this._listener.onAnnotationModelChanged)},setMultiAnnotation:function(a){this._multiAnnotation=a},setMultiAnnotationOverlay:function(a){this._multiAnnotationOverlay=
|
|
a},onClick:function(a,b){if(void 0!==a){var c=this._view,l=c.getModel(),d=l,f=l.getLineStart(a),g=f,h=f,q=this._annotationModel;if(q){c=c.getSelection();h=l.getLineEnd(a,!0);f<=c.start&&c.start<h&&(f=c.start);l.getBaseModel&&(f=l.mapOffset(f),h=l.mapOffset(h),d=l.getBaseModel());for(var m,h=q.getAnnotations(f,h),q=null;!m&&h.hasNext();)c=h.next(),this.isAnnotationTypeVisible(c.type)&&(q=c,c.start<=f||(m=c));q&&void 0!==q.groupId&&(this._currentClickGroup=this._currentClickGroup===q.groupId?null:q.groupId,
|
|
this._setCurrentGroup(a));m&&d.getLineAtOffset(m.start)===d.getLineAtOffset(f)?(f=m.start,h=m.end):h=f=g;l.getBaseModel&&(f=l.mapOffset(f,!0),h=l.mapOffset(h,!0))}(l=k.Tooltip.getTooltip(this._view))&&l.setTarget(null);this._view.setSelection(h,f,1/3,function(){})}},onDblClick:function(a,b){},onMouseMove:function(a,b){var c=k.Tooltip.getTooltip(this._view);if(c&&!(c.isVisible()&&this._tooltipLineIndex===a)){this._tooltipLineIndex=a;var l=this;c.setTarget({y:b.clientY,getTooltipInfo:function(){return l._getTooltipInfo(l._tooltipLineIndex,
|
|
this.y)}})}},onMouseOver:function(a,b){this.onMouseMove(a,b);this._currentClickGroup||this._setCurrentGroup(a)},onMouseOut:function(a,b){this._currentClickGroup||this._setCurrentGroup(-1);var c=k.Tooltip.getTooltip(this._view);c&&c.setTarget(null)},_getTooltipInfo:function(a,b){if(void 0!==a){var c=this._view,l=c.getModel(),d=this._annotationModel,f=[];if(d){var f=l.getLineStart(a),g=l.getLineEnd(a);l.getBaseModel&&(f=l.mapOffset(f),g=l.mapOffset(g));f=this.getAnnotationsByType(d,f,g)}d=this._getTooltipContents(a,
|
|
f);if(!d)return null;d={contents:d,anchor:this.getLocation()};f=c.getClientArea();"document"===this.getOverview()?f.y=c.convert({y:b},"view","document").y:f.y=c.getLocationAtOffset(l.getLineStart(a)).y;c.convert(f,"document","page");d.x=f.x;d.y=f.y;"right"===d.anchor&&(d.x+=f.width);return d}},_getTooltipContents:function(a,b){return b},_onAnnotationModelChanged:function(a){function b(a){for(var e=0;e<a.length;e++)if(d.isAnnotationTypeVisible(a[e].type)){var n=a[e].start,f=a[e].end;l.getBaseModel&&
|
|
(n=l.mapOffset(n,!0),f=l.mapOffset(f,!0));-1!==n&&-1!==f&&c.redrawLines(l.getLineAtOffset(n),l.getLineAtOffset(Math.max(n,f-1))+1,d)}}var c=this._view;if(c){var l=c.getModel(),d=this,f=l.getLineCount();a.textModelChangedEvent?(a=a.textModelChangedEvent.start,l.getBaseModel&&(a=l.mapOffset(a,!0)),a=l.getLineAtOffset(a),c.redrawLines(a,f,d)):(b(a.added),b(a.removed),b(a.changed))}},_mergeAnnotation:function(a,b,c,l){a||(a={});0===c&&(a.html&&b.html?(b.html!==a.html&&(!a._multiple&&this._multiAnnotation)&&
|
|
(a.html=this._multiAnnotation.html),a._multiple=!0):a.html=b.html);a.style=this._mergeStyle(a.style,b.style);return a},_mergeStyle:function(a,b){if(b){a||(a={});a.styleClass=a.styleClass&&b.styleClass&&a.styleClass!==b.styleClass?a.styleClass+(" "+b.styleClass):b.styleClass;var c;if(b.style)for(c in a.style||(a.style={}),b.style)void 0===a.style[c]&&(a.style[c]=b.style[c]);if(b.attributes)for(c in a.attributes||(a.attributes={}),b.attributes)void 0===a.attributes[c]&&(a.attributes[c]=b.attributes[c])}return a},
|
|
_setCurrentGroup:function(a){var b=this._annotationModel,c=null,l=b.getTextModel(),d,f=this._currentGroupAnnotation;if(-1!==a){var g=l.getLineStart(a),h=l.getLineEnd(a);l.getBaseModel&&(g=l.mapOffset(g),h=l.mapOffset(h));for(d=b.getAnnotations(g,h);d.hasNext();)if(l=d.next(),this.isAnnotationTypeVisible(l.type)&&l.start<=g&&l.end>=h&&void 0!==l.groupId){c=l;break}if(f&&c&&f.groupId===c.groupId)return}this._currentGroupAnnotation=null;f&&b.removeAnnotations(f.groupType);if(c&&-1!==a){this._currentGroupAnnotation=
|
|
c;d=b.getAnnotations();for(a=[];d.hasNext();)l=d.next(),delete l.groupAnnotation,l.groupId===c.groupId&&(l=l.createGroupAnnotation(),a.push(l));b.replaceAnnotations(null,a)}}});r.AnnotationTypeList.addMixin(d.prototype);c.prototype=new d;c.prototype.getAnnotations=function(a,b){for(var c=d.prototype.getAnnotations.call(this,a,b),l=this._view.getModel(),f=a;f<b;f++){var g=f-this._firstLine&1?this._oddStyle:this._evenStyle,h=f;l.getBaseModel&&(h=l.getLineStart(h),h=l.getBaseModel().getLineAtOffset(l.mapOffset(h)));
|
|
c[f]||(c[f]={});c[f].html=this._firstLine+h+"";c[f].style||(c[f].style=g)}return c};c.prototype.getWidestAnnotation=function(){var a=this._view.getModel().getLineCount();return this.getAnnotations(a-1,a)[a-1]};c.prototype.setFirstLine=function(a){this._firstLine=void 0!==a?a:1};c.prototype._onTextModelChanged=function(a){var b=a.start;a=this._view.getModel();var c=a.getBaseModel?a.getBaseModel().getLineCount():a.getLineCount(),c=(this._firstLine+c-1+"").length;this._numOfDigits!==c&&(this._numOfDigits=
|
|
c,b=a.getLineAtOffset(b),this._view.redrawLines(b,a.getLineCount(),this))};a.prototype=new d;b.prototype=new d;b.prototype.getRulerStyle=function(){var a={style:{lineHeight:"1px",fontSize:"1px"}};return a=this._mergeStyle(a,this._rulerStyle)};b.prototype._getTooltipContents=function(a,b){if(0===b.length){var c=this._view.getModel(),l=a;c.getBaseModel&&(l=c.getLineStart(l),l=c.getBaseModel().getLineAtOffset(c.mapOffset(l)));return f.formatMessage(p.line,l+1)}return d.prototype._getTooltipContents.call(this,
|
|
a,b)};b.prototype._mergeAnnotation=function(a,b,c,l){if(0===c)return a||(a={html:"\x26nbsp;",style:{style:{height:3*l+"px"}}},a.style=this._mergeStyle(a.style,b.overviewStyle)),a};l.prototype=new a;l.prototype.onClick=function(a,b){if(void 0!==a){var c=this._annotationModel;if(c){var l=this._view.getModel(),d=l.getLineStart(a),f=l.getLineEnd(a,!0);l.getBaseModel&&(d=l.mapOffset(d),f=l.mapOffset(f),l=l.getBaseModel());for(var g,c=c.getAnnotations(d,f);!g&&c.hasNext();)f=c.next(),this.isAnnotationTypeVisible(f.type)&&
|
|
l.getLineAtOffset(f.start)===l.getLineAtOffset(d)&&(g=f);g&&((l=k.Tooltip.getTooltip(this._view))&&l.setTarget(null),g.expanded?g.collapse():g.expand())}}};l.prototype._getTooltipContents=function(b,e){if(0<e.length){var c=this._view.getModel(),l=c.getLineStart(b);c.getBaseModel&&(l=c.mapOffset(l),c=c.getBaseModel());for(var l=c.getLineAtOffset(l),d=0;d<e.length;d++){var f=e[d];if(this.isAnnotationTypeVisible(f.type)&&c.getLineAtOffset(f.start)===l){if(e[d].expanded)break;return a.prototype._getTooltipContents.call(this,
|
|
b,[f])}}}return null};l.prototype._onAnnotationModelChanged=function(b){function e(a){for(f=0;f<a.length;f++)if(d.isAnnotationTypeVisible(a[f].type)){var b=a[f].start;l.getBaseModel&&(b=l.mapOffset(b,!0));-1!==b&&(h=Math.min(h,l.getLineAtOffset(b)))}}if(b.textModelChangedEvent)a.prototype._onAnnotationModelChanged.call(this,b);else{var c=this._view;if(c){var l=c.getModel(),d=this,f,g=l.getLineCount(),h=g;e(b.added);e(b.removed);e(b.changed);b=c.getRulers();for(f=0;f<b.length;f++)c.redrawLines(h,g,
|
|
b[f])}}};r=function(a,b){q.call(this,a,"fixed",b)};r.prototype=g.mixin(new q,{setView:function(a){this._destroy();q.prototype.setView.call(this,a);this._create()},_create:function(){function a(b){var e=b.themeClass;e?((e=e.replace("textviewZoom",""))&&(e=" "+e),e="textviewZoom"+e):e="textviewZoom";b.themeClass=e;b.noScroll=!0;b.readonly=!0;return b}function b(){var a=k._metrics.viewPadding,e=k._metrics.viewPadding,c=k.getLineHeight(),l=p.getLineHeight(),n=k.getModel().getLineCount(),c=k._lineHeight?
|
|
k._scrollHeight:n*c,l=p._lineHeight?p._scrollHeight:n*l,n=l/c,d=k.getClientArea().height+a.top+a.bottom,e=p.getClientArea().height+e.top+e.bottom;return{zoomFactor:n,documentHeight:c,zoomDocumentHeight:l,clientHeight:d,zoomClientHeight:e,scrollWidth:k._metrics.scrollWidth,windowHeight:d*n,padding:a}}function c(a){a=a||{y:k.getTopPixel()};var l=b();p.setTopPixel(a.y*(l.zoomFactor+(l.windowHeight-l.clientHeight-l.scrollWidth)/l.documentHeight));a=a.y*l.zoomFactor;l=l.clientHeight*l.zoomFactor;A.top=
|
|
a;A.bottom=a+l;a=p.convert({y:a},"document","page").y;a-=A.node.getBoundingClientRect().top;r.style.top=a+"px";r.style.height=l-B+"px"}function l(a){a.wrapMode&&!a.wrapOffset&&k._metrics.charWidth?(a=f.createElement(m,"div"),a.style.position="fixed",a.style.left="-1000px",p._clientDiv.appendChild(a),a.innerHTML=Array(Math.ceil(k.getClientArea().width/k._metrics.charWidth)+1).join("a"),a=a.getBoundingClientRect(),a=Math.min(150,Math.ceil(a.right-a.left))+"px"):a="";var b=A.node.style.width;A.node.style.width=
|
|
a;return b!==a}function d(a,b,e){e||A.top<=a.y&&a.y<=A.bottom?(A.mouseDown=!0,A.delta=b-r.getBoundingClientRect().top+A.node.getBoundingClientRect().top):(a=p.getOffsetAtLocation(a.x,a.y),k.setSelection(a,a,0.5,function(){}))}function g(a){if(A.mouseDown){var c=b();a=Math.min(c.zoomClientHeight-c.windowHeight,Math.max(0,a-A.delta));k.setTopPixel(a*(c.documentHeight-c.clientHeight)/Math.min(c.zoomDocumentHeight,c.zoomClientHeight-c.windowHeight))}}var k=this.getView();if(k){var q=a(k.getOptions());
|
|
q.parent=this.node;var p=this._zoomView=new t.TextView(q);p._clientDiv.contentEditable=!1;p.setModel(k.getModel());var m=k.getOptions("parent").ownerDocument,r=this._windowDiv=f.createElement(m,"div");r.className="rulerZoomWindow";this.node.appendChild(r);var B=parseInt(h.getNodeStyle(r,"border-top-width",0))+parseInt(h.getNodeStyle(r,"border-bottom-width",0)),A=this;k.addEventListener("Scroll",this._scrollListener=function(a){c(a.newValue)});k.addEventListener("Resize",this._resizeListener=function(){l(p.getOptions());
|
|
c()});k.addEventListener("Redraw",this._redrawListener=function(a){a.ruler||p.redrawLines(a.startLine,a.endLine)});k.addEventListener("Options",this._optionsListener=function(b){b=a(b.options);p.setOptions(b);l(p.getOptions())});p.addEventListener("LineStyle",this._lineListener=function(a){k.onLineStyle(a)});f.isIOS||f.isAndroid?(r.addEventListener("touchstart",function(a){1===a.touches.length&&(d(a,a.touches[0].clientY,!0),a.preventDefault())}),r.addEventListener("touchend",function(a){0===a.touches.length&&
|
|
(A.mouseDown=!1)}),r.addEventListener("touchmove",function(a){1===a.touches.length&&g(a.touches[0].clientY)}),p.addEventListener("TouchStart",function(a){1===a.touchCount&&(d(a,a.event.touches[0].clientY),a.preventDefault())})):(r.style.pointerEvents="none",p.addEventListener("MouseDown",function(a){var b=a.event;(b.which?0===b.button:1===b.button)&&d(a,b.clientY);a.preventDefault()}),p.addEventListener("MouseUp",function(a){A.mouseDown=!1;a.preventDefault()}),p.addEventListener("MouseMove",function(a){g(a.event.clientY);
|
|
a.preventDefault()}));(m.defaultView||m.parentWindow).setTimeout(function(){c()},0)}},_destroy:function(){var a=this.getView();a&&(a.removeEventListener("Scroll",this._scrollListener),this._scrollListener=null,a.removeEventListener("Resize",this._resizeListener),this._resizeListener=null,a.removeEventListener("Redraw",this._redrawListener),this._redrawListener=null,a.removeEventListener("Options",this._optionsListener),this._optionsListener=null);if(a=this._zoomView)a.removeEventListener("LineStyle",
|
|
this._lineListener),a.setModel(null),a.destroy(),this._zoomView=null}});return{BaseRuler:q,Ruler:d,AnnotationRuler:a,LineNumberRuler:c,OverviewRuler:b,FoldingRuler:l,ZoomRuler:r}});
|
|
define("orion/editor/undoStack",[],function(){function p(k,g,h,f,q){this.model=k;this.offset=g;this.text=h;this.previousText=f;this.type=q}function t(k){this.owner=k;this.changes=[]}function r(k,g){this.size=void 0!==g?g:100;this.reset();var h=this;this._listener={onChanging:function(f){h._onChanging(f)},onDestroy:function(f){h._onDestroy(f)}};if(k.getModel){var f=k.getModel();f.getBaseModel&&(f=f.getBaseModel());this.model=f;this.setView(k)}else this.shared=!0,this.model=k;this.model.addEventListener("Changing",
|
|
this._listener.onChanging)}p.prototype={getRedoChanges:function(){return[{start:this.offset,end:this.offset+this.previousText.length,text:this.text}]},getUndoChanges:function(){return[{start:this.offset,end:this.offset+this.text.length,text:this.previousText}]},undo:function(k,g){this._doUndoRedo(this.offset,this.previousText,this.text,k,g);return!0},redo:function(k,g){this._doUndoRedo(this.offset,this.text,this.previousText,k,g);return!0},merge:function(k,g,h,f,q){if(f===this.type){if(1===f&&k===
|
|
this.offset+this.text.length)return this.text+=g,!0;if(-1===f&&q===this.offset)return this.offset=k,this.previousText=h+this.previousText,!0;if(-1===f&&k===this.offset)return this.previousText+=h,!0}return!1},_doUndoRedo:function(k,g,h,f,q){this.model.setText(g,k,k+h.length);q&&f&&(h=f.getModel(),h!==this.model&&(k=h.mapOffset(k,!0)),f.setSelection(k,k+g.length))}};t.prototype={getRedoChanges:function(){for(var k=[],g=0;g<this.changes.length;g++)k=k.concat(this.changes[g].getRedoChanges());return k},
|
|
getUndoChanges:function(){for(var k=[],g=this.changes.length-1;0<=g;g--)k=k.concat(this.changes[g].getUndoChanges());return k},add:function(k){this.changes.push(k)},end:function(k){k&&(this.endSelection=k.getSelection(),this.endCaret=k.getCaretOffset());(k=this.owner)&&k.end&&k.end()},undo:function(k,g){1<this.changes.length&&k&&k.setRedraw(!1);for(var h=this.changes.length-1;0<=h;h--)this.changes[h].undo(k,!1);if(g&&k){var h=this.startSelection.start,f=this.startSelection.end;k.setSelection(this.startCaret?
|
|
h:f,this.startCaret?f:h)}1<this.changes.length&&k&&k.setRedraw(!0);(h=this.owner)&&h.undo&&h.undo();return 0<this.changes.length},redo:function(k,g){1<this.changes.length&&k&&k.setRedraw(!1);for(var h=0;h<this.changes.length;h++)this.changes[h].redo(k,!1);(1<this.changes.length,k)&&k.setRedraw(!0);if(g&&k){var h=this.endSelection.start,f=this.endSelection.end;k.setSelection(this.endCaret?h:f,this.endCaret?f:h)}(h=this.owner)&&h.redo&&h.redo();return 0<this.changes.length},merge:function(k,g,h,f,q){var d=
|
|
this.changes.length;return 0<d?this.changes[d-1].merge(k,g,h,f,q):!1},start:function(k){k&&(this.startSelection=k.getSelection(),this.startCaret=k.getCaretOffset());(k=this.owner)&&k.start&&k.start()}};r.prototype={destroy:function(){this._onDestroy()},add:function(k){this.compoundChange?this.compoundChange.add(k):(this.stack.splice(this.index,this.stack.length-this.index,k),this.index++,this.stack.length>this.size&&(this.stack.shift(),this.index--))},markClean:function(){this._commitUndo();if(this.cleanChange=
|
|
this.stack[this.index-1])this.cleanChange.type=2},isClean:function(){return this.cleanChange===this.stack[this.index-1]},canUndo:function(){return 0<this.index},canRedo:function(){return 0<this.stack.length-this.index},endCompoundChange:function(){this.compoundChange&&this.compoundChange.end(this.view);this.compoundChange=void 0},getSize:function(){return{undo:this.index,redo:this.stack.length-this.index}},getRedoChanges:function(){this._commitUndo();for(var k=[],g=this.index;g<this.stack.length;g++)k=
|
|
k.concat(this.stack[g].getRedoChanges());return k},getUndoChanges:function(){this._commitUndo();for(var k=[],g=this.index;0<=g;g--)k=k.concat(this.stack[g].getUndoChanges());return k},undo:function(){this._commitUndo();var k;k=!1;this._ignoreUndo=!0;do{if(0>=this.index)break;k=this.stack[--this.index]}while(!(k=k.undo(this.view,!0)));this._ignoreUndo=!1;return k},redo:function(){this._commitUndo();var k;this._ignoreUndo=!0;do{if(this.index>=this.stack.length)break;k=this.stack[this.index++]}while(!k.redo(this.view,
|
|
!0));this._ignoreUndo=!1;return!0},reset:function(){this.index=0;this.cleanChange=void 0;this.stack=[];this._ignoreUndo=!1;this._compoundChange=void 0},setView:function(k){this.view!==k&&(this.view&&k.removeEventListener("Destroy",this._listener.onDestroy),(this.view=k)&&k.addEventListener("Destroy",this._listener.onDestroy))},startCompoundChange:function(k){this._commitUndo();k=new t(k);this.add(k);this.compoundChange=k;this.compoundChange.start(this.view);return this.compoundChange},_commitUndo:function(){this.endCompoundChange()},
|
|
_onDestroy:function(k){(!k||!this.shared)&&this.model.removeEventListener("Changing",this._listener.onChanging);this.view&&(this.view.removeEventListener("Destroy",this._listener.onDestroy),this.view=null)},_onChanging:function(k){if(!this._ignoreUndo){var g=k.text,h=k.start,f=k.addedCharCount,q=k.removedCharCount;k=h+q;var d=0;0===f&&1===q?d=-1:1===f&&0===q&&(d=1);f=this.stack.length;q=this.model.getText(h,k);(!(0<f&&this.index===f)||!this.stack[f-1].merge(h,g,q,d,k))&&this.add(new p(this.model,
|
|
h,g,q,d))}}};return{UndoStack:r}});
|
|
define("orion/editor/textDND",["orion/util"],function(p){function t(p,k){this._view=p;this._undoStack=k;this._dragSelection=null;this._dropOffset=-1;this._dropText=null;var g=this;this._listener={onDragStart:function(h){g._onDragStart(h)},onDragEnd:function(h){g._onDragEnd(h)},onDragEnter:function(h){g._onDragEnter(h)},onDragOver:function(h){g._onDragOver(h)},onDrop:function(h){g._onDrop(h)},onDestroy:function(h){g._onDestroy(h)}};p.addEventListener("DragStart",this._listener.onDragStart);p.addEventListener("DragEnd",
|
|
this._listener.onDragEnd);p.addEventListener("DragEnter",this._listener.onDragEnter);p.addEventListener("DragOver",this._listener.onDragOver);p.addEventListener("Drop",this._listener.onDrop);p.addEventListener("Destroy",this._listener.onDestroy)}t.prototype={destroy:function(){var p=this._view;p&&(p.removeEventListener("DragStart",this._listener.onDragStart),p.removeEventListener("DragEnd",this._listener.onDragEnd),p.removeEventListener("DragEnter",this._listener.onDragEnter),p.removeEventListener("DragOver",
|
|
this._listener.onDragOver),p.removeEventListener("Drop",this._listener.onDrop),p.removeEventListener("Destroy",this._listener.onDestroy),this._view=null)},_onDestroy:function(p){this.destroy()},_onDragStart:function(p){var k=this._view,g=k.getSelection(),k=k.getModel();k.getBaseModel&&(g.start=k.mapOffset(g.start),g.end=k.mapOffset(g.end),k=k.getBaseModel());if(k=k.getText(g.start,g.end))this._dragSelection=g,p.event.dataTransfer.effectAllowed="copyMove",p.event.dataTransfer.setData("Text",k)},_onDragEnd:function(r){if(this._dragSelection){var k=
|
|
this._view,g=r.event.dataTransfer.dropEffect;if(!p.isFirefox&&("none"!==g||this._dropText))g=r.event.dataTransfer.dropEffect=this._dropEffect;this._undoStack&&this._undoStack.startCompoundChange();(r="move"===g)&&k.setText("",this._dragSelection.start,this._dragSelection.end);if(this._dropText){var g=this._dropText,h=this._dropOffset;r&&(h>=this._dragSelection.end?h-=this._dragSelection.end-this._dragSelection.start:h>=this._dragSelection.start&&(h=this._dragSelection.start));k.setText(g,h,h);k.setSelection(h,
|
|
h+g.length);this._dropText=null;this._dropOffset=-1}this._undoStack&&this._undoStack.endCompoundChange()}this._dragSelection=null},_onDragEnter:function(p){this._onDragOver(p)},_onDragOver:function(r){var k=r.event.dataTransfer.types,g=!this._view.getOptions("readonly");g&&k&&(g=k.contains?k.contains("text/plain")||k.contains("Text"):-1!==k.indexOf("text/plain")||-1!==k.indexOf("Text"));g?p.isFirefox||(this._dropEffect=r.event.dataTransfer.dropEffect=(p.isMac?r.event.altKey:r.event.ctrlKey)?"copy":
|
|
"move"):r.event.dataTransfer.dropEffect="none"},_onDrop:function(r){var k=this._view,g=r.event.dataTransfer.getData("Text");g&&(p.isFirefox||(r.event.dataTransfer.dropEffect=this._dropEffect),r=k.getOffsetAtLocation(r.x,r.y),this._dragSelection?(this._dropOffset=r,this._dropText=g):(k.setText(g,r,r),k.setSelection(r,r+g.length)))}};return{TextDND:t}});
|
|
define("orion/editor/editor","i18n!orion/editor/nls/messages orion/editor/eventTarget orion/editor/tooltip orion/editor/annotations orion/objects orion/util".split(" "),function(p,t,r,k,g,h){function f(c){c=c||{};this._domNode=c.domNode;this._model=c.model;this._undoStack=c.undoStack;this._statusReporter=c.statusReporter;this._title=null;var a=this;this._listener={onChanged:function(b){a.onChanged(b)}};this._model&&this._model.addEventListener("Changed",this._listener.onChanged);this.checkDirty()}
|
|
function q(c){c=c||{};f.call(this,c);this._textViewFactory=c.textViewFactory;this._undoStackFactory=c.undoStackFactory;this._textDNDFactory=c.textDNDFactory;this._annotationFactory=c.annotationFactory;this._zoomRulerFactory=c.zoomRulerFactory;this._foldingRulerFactory=c.foldingRulerFactory;this._lineNumberRulerFactory=c.lineNumberRulerFactory;this._contentAssistFactory=c.contentAssistFactory;this._keyBindingFactory=c.keyBindingFactory;this._hoverFactory=c.hoverFactory;this._contentAssist=this._foldingRuler=
|
|
this._zoomRuler=this._overviewRuler=this._lineNumberRuler=this._annotationRuler=this._annotationModel=this._annotationStyler=null}var d=k.AnnotationType;f.prototype={destroy:function(){this.uninstall();this._statusReporter=this._domNode=null;this._model&&this._model.removeEventListener("Changed",this._listener.onChanged)},checkDirty:function(){this.setDirty(this._undoStack&&!this._undoStack.isClean())},focus:function(){},getModel:function(){return this._model},getText:function(c,a){return this.getModel().getText(c,
|
|
a)},getTitle:function(){return this._title},getUndoStack:function(){return this._undoStack},install:function(){this.installed=!0},isDirty:function(){return this._dirty},markClean:function(){this.getUndoStack().markClean();this.setDirty(!1)},onDirtyChanged:function(c){return this.dispatchEvent(c)},onInputChanged:function(c){return this.dispatchEvent(c)},onChanged:function(c){this.checkDirty()},reportStatus:function(c,a,b){this._statusReporter&&this._statusReporter(c,a,b)},resize:function(){},setDirty:function(c){this._dirty!==
|
|
c&&(this._dirty=c,this.onDirtyChanged({type:"DirtyChanged"}))},_setModelText:function(c){this._model&&this._model.setText(c)},setInput:function(c,a,b,l){this._title=c;l||(a?this.reportStatus(a,"error"):null!==b&&(void 0!==b&&"string"===typeof b)&&this._setModelText(b),this._undoStack&&this._undoStack.reset());this.checkDirty();this.onInputChanged({type:"InputChanged",title:c,message:a,contents:b,contentsSaved:l})},setText:function(c,a,b){this.getModel().setText(c,a,b)},uninstall:function(){this.installed=
|
|
!1}};t.EventTarget.addMixin(f.prototype);q.prototype=new f;g.mixin(q.prototype,{destroy:function(){f.prototype.destroy.call(this);this._textViewFactory=this._undoStackFactory=this._textDNDFactory=this._annotationFactory=this._foldingRulerFactory=this._lineNumberRulerFactory=this._contentAssistFactory=this._keyBindingFactory=this._hoverFactory=this._zoomRulerFactory=null},getAnnotationModel:function(){return this._annotationModel},getAnnotationRuler:function(){return this._annotationRuler},getAnnotationStyler:function(){return this._annotationStyler},
|
|
getContentAssist:function(){return this._contentAssist},getFoldingRuler:function(){return this._foldingRuler},getLineNumberRuler:function(){return this._lineNumberRuler},getZoomRuler:function(){return this._zoomRuler},getModel:function(){if(!this._textView)return null;var c=this._textView.getModel();c.getBaseModel&&(c=c.getBaseModel());return c},getOverviewRuler:function(){return this._overviewRuler},getTextView:function(){return this._textView},getKeyModes:function(){return this._textView.getKeyModes()},
|
|
getSourceCodeActions:function(){return this._sourceCodeActions},getLinkedMode:function(){return this._linkedMode},getTextActions:function(){return this._textActions},focus:function(){this._textView&&this._textView.focus()},resize:function(){this._textView&&this._textView.resize()},setAnnotationRulerVisible:function(c,a){if(this._annotationRulerVisible!==c||a)if(this._annotationRulerVisible=c,this._annotationRuler){var b=this._textView;c?b.addRuler(this._annotationRuler,0):b.removeRuler(this._annotationRuler)}},
|
|
setFoldingRulerVisible:function(c,a){if(this._foldingRulerVisible!==c||a)if(this._foldingRulerVisible=c,this._foldingRuler){var b=this._textView;b.getModel().getBaseModel&&(c?b.addRuler(this._foldingRuler):b.removeRuler(this._foldingRuler))}},setLineNumberRulerVisible:function(c,a){if(this._lineNumberRulerVisible!==c||a)if(this._lineNumberRulerVisible=c,this._lineNumberRuler){var b=this._textView;c?b.addRuler(this._lineNumberRuler,!this._annotationRulerVisible?0:1):b.removeRuler(this._lineNumberRuler)}},
|
|
setOverviewRulerVisible:function(c,a){if(this._overviewRulerVisible!==c||a)if(this._overviewRulerVisible=c,this._overviewRuler){var b=this._textView;c?b.addRuler(this._overviewRuler):b.removeRuler(this._overviewRuler)}},setZoomRulerVisible:function(c,a){if(this._zoomRulerVisible!==c||a)if(this._zoomRulerVisible=c,this._zoomRuler){var b=this._textView;c?b.addRuler(this._zoomRuler):b.removeRuler(this._zoomRuler)}},mapOffset:function(c,a){var b=this._textView.getModel();b.getBaseModel&&(c=b.mapOffset(c,
|
|
a));return c},getLineAtOffset:function(c){return this.getModel().getLineAtOffset(this.mapOffset(c))},getLineStart:function(c){return this.getModel().getLineStart(c)},getCaretOffset:function(){return this.mapOffset(this._textView.getCaretOffset())},getSelection:function(){var c=this._textView,a=c.getSelection(),c=c.getModel();c.getBaseModel&&(a.start=c.mapOffset(a.start),a.end=c.mapOffset(a.end));return a},_expandOffset:function(c){var a=this._textView.getModel(),b=this._annotationModel;if(b&&a.getBaseModel)for(c=
|
|
b.getAnnotations(c,c+1);c.hasNext();)a=c.next(),a.type===d.ANNOTATION_FOLDING&&a.expand&&a.expand()},setCaretOffset:function(c,a,b){var l=this._textView,n=l.getModel();n.getBaseModel&&(this._expandOffset(c),c=n.mapOffset(c,!0));l.setCaretOffset(c,a,b)},setText:function(c,a,b){var l=this._textView,n=l.getModel();n.getBaseModel&&(void 0!==a&&(this._expandOffset(a),a=n.mapOffset(a,!0)),void 0!==b&&(this._expandOffset(b),b=n.mapOffset(b,!0)));l.setText(c,a,b)},setSelection:function(c,a,b,l){var n=this._textView,
|
|
e=n.getModel();e.getBaseModel&&(this._expandOffset(c),this._expandOffset(a),c=e.mapOffset(c,!0),a=e.mapOffset(a,!0));n.setSelection(c,a,b,l)},moveSelection:function(c,a,b,l){var n=this._textView;this.setSelection(c,a||c,1/3,function(){(void 0===l||l)&&n.focus();b&&b()})},_getTooltipInfo:function(c,a){var b=this._textView,l=this.getAnnotationModel();if(!l)return null;var n=this._annotationStyler;if(!n)return null;var e=b.getOffsetAtLocation(c,a);if(-1===e)return null;for(var e=this.mapOffset(e),d=
|
|
n.getAnnotationsByType(l,e,e+1),l=[],n=[],f=0;f<d.length;f++)d[f].rangeStyle&&(l.push(d[f]),n.push(d[f].title));d=[];this._hover&&(d=this._hover.computeHoverInfo({offset:e,annotations:n}));if(0===l.length&&0===d.length)return null;b=b.convert({x:c,y:a},"document","page");return{deferredInfo:d,contents:l,anchor:"left",x:b.x+10,y:b.y+20}},_highlightCurrentLine:function(c,a){var b=this._annotationModel;if(b){var l=this._textView;if(!l.getOptions("singleMode")){var n=l.getModel(),e=a?n.getLineAtOffset(a.start):
|
|
-1,f=n.getLineAtOffset(c.start),l=c.start===c.end,g=!a||a.start===a.end,h=n.getLineStart(f),k=n.getLineEnd(f);n.getBaseModel&&(h=n.mapOffset(h),k=n.mapOffset(k));n=this._currentLineAnnotation;if(!(e===f&&g&&l&&n&&n.start===h&&n.end===k)){var e=n?[n]:null,q;l&&(n=d.createAnnotation(d.ANNOTATION_CURRENT_LINE,h,k),q=[n]);this._currentLineAnnotation=n;b.replaceAnnotations(e,q)}}}},installTextView:function(){this.install()},install:function(){if(!this._textView){this._textView=this._textViewFactory();
|
|
this._undoStackFactory&&(this._undoStack=this._undoStackFactory.createUndoStack(this),this.checkDirty());this._textDNDFactory&&(this._textDND=this._textDNDFactory.createTextDND(this,this._undoStack));this._contentAssistFactory&&(this._contentAssist=this._contentAssistFactory.createContentAssistMode(this).getContentAssist());this._hoverFactory&&(this._hover=this._hoverFactory.createHover(this));var c=this,a=this._textView,b=this;this._listener={onModelChanged:function(a){b.checkDirty()},onMouseOver:function(a){b._listener.onMouseMove(a)},
|
|
onMouseMove:function(e){var c=r.Tooltip.getTooltip(a);c&&!(b._listener.lastMouseX===e.event.clientX&&b._listener.lastMouseY===e.event.clientY)&&(b._listener.lastMouseX=e.event.clientX,b._listener.lastMouseY=e.event.clientY,c.setTarget({x:e.x,y:e.y,getTooltipInfo:function(){return b._getTooltipInfo(this.x,this.y)}}))},onMouseOut:function(e){var c=r.Tooltip.getTooltip(a);c&&!(b._listener.lastMouseX===e.event.clientX&&b._listener.lastMouseY===e.event.clientY)&&(b._listener.lastMouseX=e.event.clientX,
|
|
b._listener.lastMouseY=e.event.clientY,c.setTarget(null))},onScroll:function(b){(b=r.Tooltip.getTooltip(a))&&b.setTarget(null,0,0)},onSelection:function(a){b._updateCursorStatus();b._highlightCurrentLine(a.newValue,a.oldValue)}};a.addEventListener("ModelChanged",this._listener.onModelChanged);a.addEventListener("Selection",this._listener.onSelection);a.addEventListener("MouseOver",this._listener.onMouseOver);a.addEventListener("MouseOut",this._listener.onMouseOut);a.addEventListener("MouseMove",this._listener.onMouseMove);
|
|
a.addEventListener("Scroll",this._listener.onScroll);if(this._keyBindingFactory){var l;if(l="function"===typeof this._keyBindingFactory?this._keyBindingFactory(this,this.getKeyModes(),this._undoStack,this._contentAssist):this._keyBindingFactory.createKeyBindings(c,this._undoStack,this._contentAssist))this._textActions=l.textActions,this._linkedMode=l.linkedMode,this._sourceCodeActions=l.sourceCodeActions}l=function(a,b){if(void 0!==a&&-1!==a){for(var e=this.getView().getModel(),l=this.getAnnotationModel(),
|
|
n=c.mapOffset(e.getLineStart(a)),e=c.mapOffset(e.getLineEnd(a)),f=l.getAnnotations(n,e),g=null;f.hasNext();){var h=f.next();if(h.type===d.ANNOTATION_BOOKMARK){g=h;break}}g?l.removeAnnotation(g):(g=d.createAnnotation(d.ANNOTATION_BOOKMARK,n,e),g.title=void 0,l.addAnnotation(g))}};if(this._annotationFactory){var n=a.getModel();n.getBaseModel&&(n=n.getBaseModel());if(this._annotationModel=this._annotationFactory.createAnnotationModel(n))if(n=this._annotationStyler=this._annotationFactory.createAnnotationStyler(a,
|
|
this._annotationModel))n.addAnnotationType(d.ANNOTATION_CURRENT_SEARCH),n.addAnnotationType(d.ANNOTATION_MATCHING_SEARCH),n.addAnnotationType(d.ANNOTATION_ERROR),n.addAnnotationType(d.ANNOTATION_WARNING),n.addAnnotationType(d.ANNOTATION_MATCHING_BRACKET),n.addAnnotationType(d.ANNOTATION_CURRENT_BRACKET),n.addAnnotationType(d.ANNOTATION_CURRENT_LINE),n.addAnnotationType(d.ANNOTATION_READ_OCCURRENCE),n.addAnnotationType(d.ANNOTATION_WRITE_OCCURRENCE),n.addAnnotationType(d.ANNOTATION_SELECTED_LINKED_GROUP),
|
|
n.addAnnotationType(d.ANNOTATION_CURRENT_LINKED_GROUP),n.addAnnotationType(d.ANNOTATION_LINKED_GROUP),n.addAnnotationType("orion.annotation.highlightError");var n=this._annotationFactory.createAnnotationRulers(this._annotationModel),e=this._annotationRuler=n.annotationRuler;e&&(e.onDblClick=l,e.setMultiAnnotationOverlay({html:"\x3cdiv class\x3d'annotationHTML overlay'\x3e\x3c/div\x3e"}),e.addAnnotationType(d.ANNOTATION_ERROR),e.addAnnotationType(d.ANNOTATION_WARNING),e.addAnnotationType(d.ANNOTATION_TASK),
|
|
e.addAnnotationType(d.ANNOTATION_BOOKMARK));this.setAnnotationRulerVisible(this._annotationRulerVisible||void 0===this._annotationRulerVisible,!0);if(e=this._overviewRuler=n.overviewRuler)e.addAnnotationType(d.ANNOTATION_CURRENT_SEARCH),e.addAnnotationType(d.ANNOTATION_MATCHING_SEARCH),e.addAnnotationType(d.ANNOTATION_READ_OCCURRENCE),e.addAnnotationType(d.ANNOTATION_WRITE_OCCURRENCE),e.addAnnotationType(d.ANNOTATION_CURRENT_BLAME),e.addAnnotationType(d.ANNOTATION_ERROR),e.addAnnotationType(d.ANNOTATION_WARNING),
|
|
e.addAnnotationType(d.ANNOTATION_TASK),e.addAnnotationType(d.ANNOTATION_BOOKMARK),e.addAnnotationType(d.ANNOTATION_MATCHING_BRACKET),e.addAnnotationType(d.ANNOTATION_CURRENT_BRACKET),e.addAnnotationType(d.ANNOTATION_CURRENT_LINE);this.setOverviewRulerVisible(this._overviewRulerVisible||void 0===this._overviewRulerVisible,!0)}this._zoomRulerFactory&&(this._zoomRuler=this._zoomRulerFactory.createZoomRuler(this._annotationModel),this.setZoomRulerVisible(this._zoomRulerVisible||void 0===this._zoomRulerVisible,
|
|
!0));this._lineNumberRulerFactory&&(this._lineNumberRuler=this._lineNumberRulerFactory.createLineNumberRuler(this._annotationModel),this._lineNumberRuler.addAnnotationType(d.ANNOTATION_CURRENT_BLAME),this._lineNumberRuler.addAnnotationType(d.ANNOTATION_BLAME),this._lineNumberRuler.onDblClick=l,this.setLineNumberRulerVisible(this._lineNumberRulerVisible||void 0===this._lineNumberRulerVisible,!0));this._foldingRulerFactory&&(this._foldingRuler=this._foldingRulerFactory.createFoldingRuler(this._annotationModel),
|
|
this._foldingRuler.addAnnotationType(d.ANNOTATION_FOLDING),this.setFoldingRulerVisible(this._foldingRulerVisible||void 0===this._foldingRulerVisible,!0));this.dispatchEvent({type:"TextViewInstalled",textView:a});f.prototype.install.call(this)}},uninstallTextView:function(){this.uninstall()},uninstall:function(){var c=this._textView;c&&(c.destroy(),this._annotationModel&&this._annotationModel.setTextModel(null),this._textView=this._undoStack=this._textDND=this._contentAssist=this._listener=this._annotationModel=
|
|
this._annotationStyler=this._annotationRuler=this._overviewRuler=this._zoomRuler=this._lineNumberRuler=this._foldingRuler=this._currentLineAnnotation=this._title=null,this._dirty=!1,this._foldingRulerVisible=this._overviewRulerVisible=this._zoomRulerVisible=this._lineNumberRulerVisible=this._annotationRulerVisible=void 0,this.dispatchEvent({type:"TextViewUninstalled",textView:c}),f.prototype.uninstall.call(this))},_updateCursorStatus:function(){for(var c=this.getModel(),a=this.getCaretOffset(),b=
|
|
c.getLineAtOffset(a),c=c.getLineStart(b),a=a-c,c=this.getKeyModes(),l=0;l<c.length;l++){var n=c[l];if(n.isActive()&&n.isStatusActive&&n.isStatusActive())return}this.reportStatus(h.formatMessage(p.lineColumn,b+1,a+1))},showAnnotations:function(c,a,b,l){var n=this._annotationModel;if(n){for(var e=[],f=[],g=n.getTextModel(),h=n.getAnnotations(),k;h.hasNext();)k=h.next(),-1!==a.indexOf(k.type)&&k.creatorID===this&&e.push(k);if(c)for(a=0;a<c.length;a++)if(k=c[a]){if(b)k=b(k);else{var q;"number"===typeof k.line?
|
|
(q=g.getLineStart(k.line-1),h=q+k.start-1,q=q+k.end-1):(h=k.start,q=k.end);var p=l(k);if(!p)continue;k=d.createAnnotation(p,h,q,k.description)}k.creatorID=this;f.push(k)}n.replaceAnnotations(e,f)}},showProblems:function(c){this.showAnnotations(c,[d.ANNOTATION_ERROR,d.ANNOTATION_WARNING,d.ANNOTATION_TASK],null,function(a){switch(a.severity){case "error":return d.ANNOTATION_ERROR;case "warning":return d.ANNOTATION_WARNING;case "task":return d.ANNOTATION_TASK}return null})},showOccurrences:function(c){this.showAnnotations(c,
|
|
[d.ANNOTATION_READ_OCCURRENCE,d.ANNOTATION_WRITE_OCCURRENCE],null,function(a){return a.readAccess?d.ANNOTATION_READ_OCCURRENCE:d.ANNOTATION_WRITE_OCCURRENCE})},showBlame:function(c){var a=this._blameRGB,b=this.getTextView().getOptions("parent").ownerDocument;if(!a){var l=h.createElement(b,"div");l.className="annotation blame";b.body.appendChild(l);var n=(b.defaultView||b.parentWindow).getComputedStyle(l).getPropertyValue("background-color");l.parentNode.removeChild(l);var l=n.indexOf("("),e=n.indexOf(")"),
|
|
n=n.substring(l+1,e);this._blameRGB=a=n.split(",").slice(0,3)}var f=function(){var a=k.AnnotationType.createAnnotation(this.groupType,this.start,this.end,this.title);a.style=g.mixin({},a.style);a.style.style=g.mixin({},a.style.style);a.style.style.backgroundColor="";this.groupAnnotation=a;a.blame=this.blame;a.html=this.html;a.creatorID=this.creatorID;return a},q=function(){var a=h.createElement(b,"div");a.className="tooltipTitle";var e=this.blame.Message.indexOf("\n");-1===e&&(e=this.blame.Message.length);
|
|
var c=h.createElement(b,"a");c.href=this.blame.CommitLink;c.appendChild(b.createTextNode(this.blame.Message.substring(0,e)));a.appendChild(c);a.appendChild(h.createElement(b,"br"));a.appendChild(b.createTextNode(h.formatMessage(p.committerOnTime,this.blame.AuthorName,this.blame.Time)));return a},x=this.getModel();this.showAnnotations(c,[d.ANNOTATION_BLAME,d.ANNOTATION_CURRENT_BLAME],function(b){var e=x.getLineStart(b.Start-1),c=x.getLineEnd(b.End-1,!0),e=k.AnnotationType.createAnnotation(d.ANNOTATION_BLAME,
|
|
e,c,q),c=a.slice(0);c.push(b.Shade);e.style=g.mixin({},e.style);e.style.style=g.mixin({},e.style.style);e.style.style.backgroundColor="rgba("+c.join()+")";e.groupId=b.Name;e.groupType=d.ANNOTATION_CURRENT_BLAME;e.createGroupAnnotation=f;e.html='\x3cimg class\x3d"annotationHTML blame" src\x3d"'+b.AuthorImage+'"/\x3e';e.blame=b;return e})},showSelection:function(c,a,b,l,n){"number"===typeof c?("number"!==typeof a&&(a=c),this.moveSelection(c,a)):"number"===typeof b&&(c=this.getModel().getLineStart(b-
|
|
1),"number"===typeof l&&(c+=l),"number"!==typeof n&&(n=0),this.moveSelection(c,c+n))},_setModelText:function(c){this._textView&&(this._textView.setText(c),this._textView.getModel().setLineDelimiter("auto"),this._highlightCurrentLine(this._textView.getSelection()))},setInput:function(c,a,b,l,n){f.prototype.setInput.call(this,c,a,b,l);this._textView&&(!l&&!n)&&this._textView.focus()},onGotoLine:function(c,a,b,l){if(this._textView){var n=this.getModel();c=Math.max(0,Math.min(c,n.getLineCount()-1));var e=
|
|
n.getLineStart(c),d=0;void 0===b&&(b=0);"string"===typeof a?(c=n.getLine(c).indexOf(a),-1!==c&&(d=c,b=d+a.length)):(d=a,a=n.getLineEnd(c)-e,d=Math.min(d,a),b=Math.min(b,a));this.moveSelection(e+d,e+b,l)}}});return{BaseEditor:f,Editor:q}});
|
|
define("orion/editor/find","i18n!orion/editor/nls/messages orion/keyBinding orion/editor/keyModes orion/editor/annotations orion/regex orion/objects orion/util".split(" "),function(p,t,r,k,g,h,f){function q(a){var b=a.getTextView();r.KeyMode.call(this,b);this.editor=a;this._active=!1;this._success=!0;this._ignoreSelection=!1;this._prefix="";b.setAction("incrementalFindCancel",function(){this.setActive(!1);return!0}.bind(this));b.setAction("incrementalFindBackspace",function(){return this._backspace()}.bind(this));
|
|
var c=this;this._listener={onVerify:function(a){var b=c.editor,d=b.getModel(),f=b.mapOffset(a.start),b=b.mapOffset(a.end),d=d.getText(f,b);if((d=c._prefix.match(RegExp("^"+g.escape(d),"i")))&&0<d.length)c._prefix+=a.text,c._success=!0,c._status(),c.find(c._forward,!0),a.text=null},onSelection:function(){c._ignoreSelection||c.setActive(!1)}}}function d(a,b,c){if(a){this._editor=a;this._undoStack=b;this._showAll=!0;this._visible=!1;this._wrap=this._caseInsensitive=!0;this._wholeWord=!1;this._incremental=
|
|
!0;this._regex=!1;this._findAfterReplace=!0;this._reverse=this._hideAfterFind=!1;this._timer=this._end=this._start=void 0;this._lastString="";var n=this;this._listeners={onEditorFocus:function(a){n._removeCurrentAnnotation(a)}};this.setOptions(c)}}var c={};q.prototype=new r.KeyMode;h.mixin(q.prototype,{createKeyBindings:function(){var a=t.KeyBinding,b=[];b.push({actionID:"incrementalFindBackspace",keyBinding:new a(8)});b.push({actionID:"incrementalFindCancel",keyBinding:new a(13)});b.push({actionID:"incrementalFindCancel",
|
|
keyBinding:new a(27)});b.push({actionID:"incrementalFindReverse",keyBinding:new a(38)});b.push({actionID:"incrementalFind",keyBinding:new a(40)});b.push({actionID:"incrementalFindReverse",keyBinding:new a("k",!0,!0)});b.push({actionID:"incrementalFind",keyBinding:new a("k",!0)});return b},find:function(a,b){this._forward=a;if(!this.isActive())return this.setActive(!0),!1;var c=this._prefix;if(0===c.length)return!1;var n=this.editor,e=n.getModel(),e=a?this._success?b?this._start:n.getCaretOffset()+
|
|
1:0:this._success?b?this._start:n.getCaretOffset():e.getCharCount()-1;(c=n.getModel().find({string:c,start:e,reverse:!a,caseInsensitive:c.toLowerCase()===c}).next())?(b||(this._start=e),this._ignoreSelection=this._success=!0,n.moveSelection(a?c.start:c.end,a?c.end:c.start),this._ignoreSelection=!1):this._success=!1;this._status();return!0},isActive:function(){return this._active},isStatusActive:function(){return this.isActive()},setActive:function(a){this._active!==a&&(this._active=a,this._prefix=
|
|
"",this._success=!0,a=this.editor.getTextView(),this._start=this.editor.getCaretOffset(),this.editor.setCaretOffset(this._start),this._active?(a.addEventListener("Verify",this._listener.onVerify),a.addEventListener("Selection",this._listener.onSelection),a.addKeyMode(this)):(a.removeEventListener("Verify",this._listener.onVerify),a.removeEventListener("Selection",this._listener.onSelection),a.removeKeyMode(this)),this._status())},_backspace:function(){var a=this._prefix,a=this._prefix=a.substring(0,
|
|
a.length-1);return 0===a.length?(this._ignoreSelection=this._success=!0,this.editor.setCaretOffset(this.editor.getSelection().start),this._ignoreSelection=!1,this._status(),!0):this.find(this._forward,!0)},_status:function(){if(this.isActive()){var a;a=this._forward?this._success?p.incrementalFindStr:p.incrementalFindStrNotFound:this._success?p.incrementalFindReverseStr:p.incrementalFindReverseStrNotFound;a=f.formatMessage(a,this._prefix);this.editor.reportStatus(a,this._success?"":"error")}else this.editor.reportStatus("")}});
|
|
c.IncrementalFind=q;d.prototype={find:function(a,b,c){this.setOptions({reverse:!a});var n=this.getFindString(),e;b&&(n=b.findString||n,e=b.count);a=this.getOptions();this.setOptions(b);b=c?this._startOffset:this.getStartOffset();if((e=this._doFind(n,b,e))&&!c)this._startOffset=e.start;this.setOptions(a);this._hideAfterFind&&this.hide();return e},getStartOffset:function(){return void 0!==this._start?this._start:this._reverse?this._editor.getSelection().start-1:this._editor.getCaretOffset()},getFindString:function(){var a=
|
|
this._editor.getSelection(),a=this._editor.getText(a.start,a.end);this._regex&&(a=g.escape(a));return a||this._lastString},getOptions:function(){return{showAll:this._showAll,caseInsensitive:this._caseInsensitive,wrap:this._wrap,wholeWord:this._wholeWord,incremental:this._incremental,regex:this._regex,findAfterReplace:this._findAfterReplace,hideAfterFind:this._hideAfterFind,reverse:this._reverse,findCallback:this._findCallback,start:this._start,end:this._end}},getReplaceString:function(){return""},
|
|
hide:function(){this._visible=!1;this._savedOptions&&(this.setOptions(this._savedOptions.pop()),0===this._savedOptions.length&&(this._savedOptions=null));this._removeAllAnnotations();var a=this._editor.getTextView();a&&(a.removeEventListener("Focus",this._listeners.onEditorFocus),a.focus())},_processReplaceString:function(a){var b=a;if(this._regex){for(var b="",c=!1,n=this._editor.getModel().getLineDelimiter(),e=0;e<a.length;e++){var d=a.substring(e,e+1);if(c){switch(d){case "R":b+=n;break;case "r":b+=
|
|
"\r";break;case "n":b+="\n";break;case "t":b+="\t";break;case "\\":b+="\\";break;default:b+="\\"+d}c=!1}else"\\"===d?c=!0:b+=d}c&&(b+="\\")}return b},isVisible:function(){return this._visible},replace:function(){var a=this.getFindString();if(a){var b=this._editor,c=this._processReplaceString(this.getReplaceString()),d=b.getSelection().start;if(b=b.getModel().find({string:a,start:d,reverse:!1,wrap:this._wrap,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive}).next())this.startUndo(),
|
|
this._doReplace(b.start,b.end,a,c),this.endUndo()}this._findAfterReplace&&a&&this._doFind(a,this.getStartOffset())},replaceAll:function(){var a=this.getFindString();if(a){this._replacingAll=!0;var b=this._editor,c=b.getTextView();b.reportStatus(p.replacingAll);var d=this._processReplaceString(this.getReplaceString()),e=this;window.setTimeout(function(){for(var g=0,h=0;;){var k=e._doFind(a,g,null,!0);if(!k)break;h++;1===h&&(c.setRedraw(!1),e.startUndo());e._doReplace(k.start,k.end,a,d);g=e.getStartOffset()}0<
|
|
h&&(e.endUndo(),c.setRedraw(!0));0<g?b.reportStatus(f.formatMessage(p.replacedMatches,h)):b.reportStatus(p.nothingReplaced,"error");e._replacingAll=!1},100)}},setOptions:function(a){if(a){if((!0===a.showAll||!1===a.showAll)&&this._showAll!==a.showAll)if(this._showAll=a.showAll,this.isVisible())if(this._showAll)this._markAllOccurrences();else{var b=this._editor.getAnnotationModel();b&&b.removeAnnotations(k.AnnotationType.ANNOTATION_MATCHING_SEARCH)}if(!0===a.caseInsensitive||!1===a.caseInsensitive)this._caseInsensitive=
|
|
a.caseInsensitive;if(!0===a.wrap||!1===a.wrap)this._wrap=a.wrap;if(!0===a.wholeWord||!1===a.wholeWord)this._wholeWord=a.wholeWord;if(!0===a.incremental||!1===a.incremental)this._incremental=a.incremental;if(!0===a.regex||!1===a.regex)this._regex=a.regex;if(!0===a.findAfterReplace||!1===a.findAfterReplace)this._findAfterReplace=a.findAfterReplace;if(!0===a.hideAfterFind||!1===a.hideAfterFind)this._hideAfterFind=a.hideAfterFind;if(!0===a.reverse||!1===a.reverse)this._reverse=a.reverse;a.hasOwnProperty("findCallback")&&
|
|
(this._findCallback=a.findCallback);a.hasOwnProperty("start")&&(this._start=a.start);a.hasOwnProperty("end")&&(this._end=a.end)}},show:function(a){this._visible=!0;a&&(this._savedOptions||(this._savedOptions=[]),this._savedOptions.push(this.getOptions()),this.setOptions(a));this._startOffset=this._editor.getSelection().start;this._editor.getTextView().addEventListener("Focus",this._listeners.onEditorFocus);var b=this;window.setTimeout(function(){b._incremental&&b.find(!0,null,!0)},0)},startUndo:function(){this._undoStack&&
|
|
this._undoStack.startCompoundChange()},endUndo:function(){this._undoStack&&this._undoStack.endCompoundChange()},_find:function(a,b,c){return this._editor.getModel().find({string:a,start:b,end:this._end,reverse:this._reverse,wrap:c?!1:this._wrap,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive})},_doFind:function(a,b,c,d){c=c||1;var e=this._editor;if(!a)return this._removeAllAnnotations(),null;this._lastString=a;var f,g;if(this._regex)try{g=this._find(a,b,d)}catch(h){e.reportStatus(h.message,
|
|
"error");return}else g=this._find(a,b,d);for(a=0;a<c&&g.hasNext();a++)f=g.next();if(!this._replacingAll){f?this._editor.reportStatus(""):this._editor.reportStatus(p.notFound,"error");if(this.isVisible()){c=k.AnnotationType.ANNOTATION_CURRENT_SEARCH;if(g=e.getAnnotationModel())g.removeAnnotations(c),f&&g.addAnnotation(k.AnnotationType.createAnnotation(c,f.start,f.end));if(this._showAll){this._timer&&window.clearTimeout(this._timer);var q=this;this._timer=window.setTimeout(function(){q._markAllOccurrences();
|
|
q._timer=null},500)}}this._findCallback?this._findCallback(f):f&&e.moveSelection(f.start,f.end,null,!1)}return f},_doReplace:function(a,b,c,d){var e=this._editor;this._regex&&(d=e.getText(a,b).replace(RegExp(c,this._caseInsensitive?"i":""),d));e.setText(d,a,b);e.setSelection(a,a+d.length,!0)},_markAllOccurrences:function(){var a=this._editor.getAnnotationModel();if(a){for(var b=k.AnnotationType.ANNOTATION_MATCHING_SEARCH,c=a.getAnnotations(),d=[],e;c.hasNext();){var f=c.next();f.type===b&&d.push(f)}if(this.isVisible()){c=
|
|
this.getFindString();c=this._editor.getModel().find({string:c,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive});for(e=[];c.hasNext();)f=c.next(),e.push(k.AnnotationType.createAnnotation(b,f.start,f.end))}a.replaceAnnotations(d,e)}},_removeAllAnnotations:function(){var a=this._editor.getAnnotationModel();a&&(a.removeAnnotations(k.AnnotationType.ANNOTATION_CURRENT_SEARCH),a.removeAnnotations(k.AnnotationType.ANNOTATION_MATCHING_SEARCH))},_removeCurrentAnnotation:function(a){(a=
|
|
this._editor.getAnnotationModel())&&a.removeAnnotations(k.AnnotationType.ANNOTATION_CURRENT_SEARCH)}};c.Find=d;return c});
|
|
define("orion/editor/findUI",["i18n!orion/editor/nls/messages","orion/editor/find","orion/objects","orion/editor/util","orion/util"],function(p,t,r,k,g){function h(f,g,d){t.Find.call(this,f,g,d)}h.prototype=new t.Find;r.mixin(h.prototype,{getFindString:function(){var f=this._findInput;return!f?t.Find.prototype.getFindString.call(this):f.value},getReplaceString:function(){var f=this._replaceInput;return!f?t.Find.prototype.getReplaceString(this):f.value},hide:function(){var f=this.isVisible();t.Find.prototype.hide.call(this);
|
|
f&&(this._rootDiv.className="textViewFind")},show:function(f){t.Find.prototype.show.call(this,f);var g=f.findString;f=f.replaceString;var d=this._findInput;d||(this._create(),d=this._findInput);g&&(d.value=g);f&&(this._replaceInput.value=f);var c=this;window.setTimeout(function(){c._rootDiv.className="textViewFind show";d.select();d.focus()},0)},_create:function(){var f=this,h=this._editor.getTextView(),d=h.getOptions("parent").ownerDocument,c=g.createElement(d,"div");c.className="textViewFind";k.addEventListener(c,
|
|
"keydown",function(a){f._handleKeyDown(a)});this._rootDiv=c;this._createContents(d,c);h._rootDiv.insertBefore(c,h._rootDiv.firstChild)},_createContents:function(f,h){var d=this,c=g.createElement(f,"input");c.className="textViewFindInput";this._findInput=c;c.type="text";c.placeholder=p.findWith;k.addEventListener(c,"input",function(a){return d._handleInput(a)});h.appendChild(c);c=g.createElement(f,"span");d._createButton(f,c,p.next,function(){d.find(!0)});d._createButton(f,c,p.previous,function(){d.find(!1)});
|
|
h.appendChild(c);d._editor.getTextView().getOptions("readonly")||(c=g.createElement(f,"input"),c.className="textViewReplaceInput",this._replaceInput=c,c.type="text",c.placeholder=p.replaceWith,h.appendChild(c),c=g.createElement(f,"span"),d._createButton(f,c,p.replace,function(){d.replace()}),d._createButton(f,c,p.replaceAll,function(){d.replaceAll()}),h.appendChild(c));c=g.createElement(f,"span");d._createButton(f,c,p.regex,function(a){d._toggle("regex",a.target)},this._regex,p.regexTooltip);d._createButton(f,
|
|
c,p.caseInsensitive,function(a){d._toggle("caseInsensitive",a.target)},this._caseInsensitive,p.caseInsensitiveTooltip);d._createButton(f,c,p.wholeWord,function(a){d._toggle("wholeWord",a.target)},this._wholeWord,p.wholeWordTooltip);h.appendChild(c);c=d._createButton(f,h,"",function(){d.hide()});c.className="textViewFindCloseButton";c.title=p.closeTooltip},_createButton:function(f,g,d,c,a,b){var l=f.createElement("button");this._checked(a,l);b&&(l.title=b);k.addEventListener(l,"click",function(a){c.call(this,
|
|
a)},!1);d&&l.appendChild(f.createTextNode(d));g.appendChild(l);return l},_toggle:function(f,g){var d={};d[f]=!this["_"+f];this.setOptions(d);this._checked(d[f],g)},_checked:function(f,g){g.className="textViewFindButton";f&&(g.className+=" checked")},_handleInput:function(){this._incremental&&this.find(!0,null,!0);return!0},_handleKeyDown:function(f){var h,d=(g.isMac?f.metaKey:f.ctrlKey)&&!f.altKey&&!f.shiftKey;d&&70===f.keyCode&&(h=!0);if((g.isMac?f.metaKey:f.ctrlKey)&&!f.altKey&&75===f.keyCode||
|
|
13===f.keyCode)13===f.keyCode?this.find(this._reverse?f.shiftKey:!f.shiftKey):this.find(!f.shiftKey),h=!0;d&&82===f.keyCode&&(this.replace(),h=!0);27===f.keyCode&&(this.hide(),h=!0);return h?(f.stopPropagation&&f.stopPropagation(),f.preventDefault&&f.preventDefault(),f.cancelBubble=!0,!1):!0}});return{FindUI:h}});
|
|
define("orion/editor/actions","i18n!orion/editor/nls/messages orion/keyBinding orion/editor/annotations orion/editor/tooltip orion/editor/find orion/editor/findUI orion/util".split(" "),function(p,t,r,k,g,h,f){function q(a,c,d){this.editor=a;this.undoStack=c;this._incrementalFind=new g.IncrementalFind(a);this._find=d?d:new h.FindUI(a,c);this._lastEditLocation=null;this.init()}function d(a,c,d,e){this.editor=a;this.undoStack=c;this.contentAssist=d;this.linkedMode=e;this.contentAssist&&this.contentAssist.addEventListener("ProposalApplied",
|
|
this.contentAssistProposalApplied.bind(this));this.init()}var c=r.AnnotationType,a={};q.prototype={init:function(){var a=this.editor.getTextView();this._lastEditListener={onModelChanged:function(a){this.editor.isDirty()&&(this._lastEditLocation=a.start+a.addedCharCount)}.bind(this)};a.addEventListener("ModelChanged",this._lastEditListener.onModelChanged);a.setAction("undo",function(a){if(this.undoStack){var b=1;a&&a.count&&(b=a.count);for(;0<b;)this.undoStack.undo(),--b;return!0}return!1}.bind(this),
|
|
{name:p.undo});a.setAction("redo",function(a){if(this.undoStack){var b=1;a&&a.count&&(b=a.count);for(;0<b;)this.undoStack.redo(),--b;return!0}return!1}.bind(this),{name:p.redo});a.setKeyBinding(new t.KeyBinding("f",!0),"find");a.setAction("find",function(){if(this._find){var a=this.editor.getSelection();this._find.show({findString:this.editor.getText(a.start,a.end)});return!0}return!1}.bind(this),{name:p.find});a.setKeyBinding(new t.KeyBinding("k",!0),"findNext");a.setAction("findNext",function(a){return this._find?
|
|
(this._find.find(!0,a),!0):!1}.bind(this),{name:p.findNext});a.setKeyBinding(new t.KeyBinding("k",!0,!0),"findPrevious");a.setAction("findPrevious",function(a){return this._find?(this._find.find(!1,a),!0):!1}.bind(this),{name:p.findPrevious});a.setKeyBinding(new t.KeyBinding("j",!0),"incrementalFind");a.setAction("incrementalFind",function(){this._incrementalFind&&this._incrementalFind.find(!0);return!0}.bind(this),{name:p.incrementalFind});a.setKeyBinding(new t.KeyBinding("j",!0,!0),"incrementalFindReverse");
|
|
a.setAction("incrementalFindReverse",function(){this._incrementalFind&&this._incrementalFind.find(!1);return!0}.bind(this),{name:p.incrementalFindReverse});a.setAction("tab",function(){return this.indentLines()}.bind(this));a.setAction("shiftTab",function(){return this.unindentLines()}.bind(this),{name:p.unindentLines});a.setKeyBinding(new t.KeyBinding(38,!1,!1,!0),"moveLinesUp");a.setAction("moveLinesUp",function(){return this.moveLinesUp()}.bind(this),{name:p.moveLinesUp});a.setKeyBinding(new t.KeyBinding(40,
|
|
!1,!1,!0),"moveLinesDown");a.setAction("moveLinesDown",function(){return this.moveLinesDown()}.bind(this),{name:p.moveLinesDown});a.setKeyBinding(new t.KeyBinding(38,!0,!1,!0),"copyLinesUp");a.setAction("copyLinesUp",function(){return this.copyLinesUp()}.bind(this),{name:p.copyLinesUp});a.setKeyBinding(new t.KeyBinding(40,!0,!1,!0),"copyLinesDown");a.setAction("copyLinesDown",function(){return this.copyLinesDown()}.bind(this),{name:p.copyLinesDown});a.setKeyBinding(new t.KeyBinding("d",!0,!1,!1),
|
|
"deleteLines");a.setAction("deleteLines",function(a){return this.deleteLines(a)}.bind(this),{name:p.deleteLines});a.setKeyBinding(new t.KeyBinding("l",!f.isMac,!1,!1,f.isMac),"gotoLine");a.setAction("gotoLine",function(){return this.gotoLine()}.bind(this),{name:p.gotoLine});a.setKeyBinding(new t.KeyBinding(190,!0),"nextAnnotation");a.setAction("nextAnnotation",function(){return this.nextAnnotation(!0)}.bind(this),{name:p.nextAnnotation});a.setKeyBinding(new t.KeyBinding(188,!0),"previousAnnotation");
|
|
a.setAction("previousAnnotation",function(){return this.nextAnnotation(!1)}.bind(this),{name:p.prevAnnotation});a.setKeyBinding(new t.KeyBinding("e",!0,!1,!0,!1),"expand");a.setAction("expand",function(){return this.expandAnnotation(!0)}.bind(this),{name:p.expand});a.setKeyBinding(new t.KeyBinding("c",!0,!1,!0,!1),"collapse");a.setAction("collapse",function(){return this.expandAnnotation(!1)}.bind(this),{name:p.collapse});a.setKeyBinding(new t.KeyBinding("e",!0,!0,!0,!1),"expandAll");a.setAction("expandAll",
|
|
function(){return this.expandAnnotations(!0)}.bind(this),{name:p.expandAll});a.setKeyBinding(new t.KeyBinding("c",!0,!0,!0,!1),"collapseAll");a.setAction("collapseAll",function(){return this.expandAnnotations(!1)}.bind(this),{name:p.collapseAll});a.setKeyBinding(new t.KeyBinding("q",!f.isMac,!1,!1,f.isMac),"lastEdit");a.setAction("lastEdit",function(){return this.gotoLastEdit()}.bind(this),{name:p.lastEdit})},copyLinesDown:function(){var a=this.editor;if(a.getTextView().getOptions("readonly"))return!1;
|
|
var c=a.getModel(),d=a.getSelection(),e=c.getLineAtOffset(d.start),d=c.getLineAtOffset(d.end>d.start?d.end-1:d.end),f=c.getLineStart(e),e=c.getLineEnd(d,!0),g=c.getLineCount(),h="",f=c.getText(f,e);d===g-1&&(f=(h=c.getLineDelimiter())+f);a.setText(f,e,e);a.setSelection(e+h.length,e+f.length);return!0},copyLinesUp:function(){var a=this.editor;if(a.getTextView().getOptions("readonly"))return!1;var c=a.getModel(),d=a.getSelection(),e=c.getLineAtOffset(d.start),d=c.getLineAtOffset(d.end>d.start?d.end-
|
|
1:d.end),e=c.getLineStart(e),f=c.getLineEnd(d,!0),g=c.getLineCount(),h="",f=c.getText(e,f);d===g-1&&(f+=h=c.getLineDelimiter());a.setText(f,e,e);a.setSelection(e,e+f.length-h.length);return!0},deleteLines:function(a){var c=this.editor;if(c.getTextView().getOptions("readonly"))return!1;var d=1;a&&a.count&&(d=a.count);var e=c.getSelection(),f=c.getModel(),g=f.getLineAtOffset(e.start);a=f.getLineStart(g);d=e.start!==e.end||1===d?f.getLineAtOffset(e.end>e.start?e.end-1:e.end):Math.min(g+d-1,f.getLineCount()-
|
|
1);d=f.getLineEnd(d,!0);c.setText("",a,d);return!0},expandAnnotation:function(a){var c=this.editor,d=c.getAnnotationModel();if(!d)return!0;var e=c.getModel(),f=c.getCaretOffset(),g=e.getLineAtOffset(f),f=e.getLineStart(g),g=e.getLineEnd(g,!0);e.getBaseModel&&(f=e.mapOffset(f),g=e.mapOffset(g),e.getBaseModel());for(var h,d=d.getAnnotations(f,g);!h&&d.hasNext();)e=d.next(),e.type===r.AnnotationType.ANNOTATION_FOLDING&&(h=e);h&&a!==h.expanded&&(a?h.expand():(c.setCaretOffset(h.start),h.collapse()));
|
|
return!0},expandAnnotations:function(a){var c=this.editor,d=c.getTextView(),c=c.getAnnotationModel();if(!c)return!0;var e=c.getAnnotations();for(d.setRedraw(!1);e.hasNext();)c=e.next(),c.type===r.AnnotationType.ANNOTATION_FOLDING&&a!==c.expanded&&(a?c.expand():c.collapse());d.setRedraw(!0);return!0},indentLines:function(){var a=this.editor,c=a.getTextView();if(c.getOptions("readonly"))return!1;if(c.getOptions("tabMode")){var d=a.getModel(),e=a.getSelection(),f=d.getLineAtOffset(e.start),g=d.getLineAtOffset(e.end>
|
|
e.start?e.end-1:e.end);if(f!==g){var h=[];h.push("");for(var k=f;k<=g;k++)h.push(d.getLine(k,!0));k=d.getLineStart(f);d=d.getLineEnd(g,!0);c=c.getOptions("tabSize","expandTab");c=c.expandTab?Array(c.tabSize+1).join(" "):"\t";a.setText(h.join(c),k,d);a.setSelection(k===e.start?e.start:e.start+c.length,e.end+(g-f+1)*c.length);return!0}return!1}},gotoLastEdit:function(){"number"===typeof this._lastEditLocation&&this.editor.showSelection(this._lastEditLocation);return!0},gotoLine:function(){var a=this.editor,
|
|
c=a.getModel().getLineAtOffset(a.getCaretOffset());if(c=prompt(p.gotoLinePrompty,c+1))c=parseInt(c,10),a.onGotoLine(c-1,0);return!0},moveLinesDown:function(){var a=this.editor;if(a.getTextView().getOptions("readonly"))return!1;var c=a.getModel(),d=a.getSelection(),e=c.getLineAtOffset(d.start),f=c.getLineAtOffset(d.end>d.start?d.end-1:d.end),g=c.getLineCount();if(f===g-1)return!0;var e=c.getLineStart(e),d=c.getLineEnd(f,!0),h=c.getLineEnd(f+1,!0)-(d-e),k=0;f!==g-2?c=c.getText(e,d):(f=c.getLineEnd(f),
|
|
c=c.getText(f,d)+c.getText(e,f),k+=d-f);this.startUndo();a.setText("",e,d);a.setText(c,h,h);a.setSelection(h+k,h+k+c.length);this.endUndo();return!0},moveLinesUp:function(){var a=this.editor;if(a.getTextView().getOptions("readonly"))return!1;var c=a.getModel(),d=a.getSelection(),e=c.getLineAtOffset(d.start);if(0===e)return!0;var f=c.getLineAtOffset(d.end>d.start?d.end-1:d.end),g=c.getLineCount(),d=c.getLineStart(e-1),h=c.getLineStart(e),k=c.getLineEnd(f,!0),q=c.getText(h,k),p=0;f===g-1&&(f=c.getLineEnd(e-
|
|
1),e=c.getLineEnd(e-1,!0),q+=c.getText(f,e),h=f,p=e-f);this.startUndo();a.setText("",h,k);a.setText(q,d,d);a.setSelection(d,d+q.length-p);this.endUndo();return!0},nextAnnotation:function(a){function d(a){return!!a.lineStyle||a.type===c.ANNOTATION_MATCHING_BRACKET||a.type===c.ANNOTATION_CURRENT_BRACKET||!f.isAnnotationTypeVisible(a.type)}var n=this.editor,e=n.getAnnotationModel();if(!e)return!0;var f=n.getOverviewRuler()||n.getAnnotationStyler();if(!f)return!0;for(var g=n.getModel(),h=n.getCaretOffset(),
|
|
q=e.getAnnotations(a?h:0,a?g.getCharCount():h),p=null;q.hasNext();){var r=q.next();if(a){if(r.start<=h)continue}else if(r.start>=h)continue;if(!d(r)&&(p=r,a))break}if(p){for(var t=[p],q=e.getAnnotations(p.start,p.start);q.hasNext();)r=q.next(),r!==p&&!d(r)&&t.push(r);var m=n.getTextView(),w=g.getLineAtOffset(p.start),B=k.Tooltip.getTooltip(m);if(!B)return n.moveSelection(p.start),!0;n.moveSelection(p.start,p.start,function(){B.setTarget({getTooltipInfo:function(){var a=m.convert({x:m.getLocationAtOffset(p.start).x,
|
|
y:m.getLocationAtOffset(g.getLineStart(w)).y},"document","page");return{contents:t,x:a.x,y:a.y+Math.floor(1.33*m.getLineHeight(w))}}},0)})}return!0},unindentLines:function(){var a=this.editor,c=a.getTextView();if(c.getOptions("readonly"))return!1;if(c.getOptions("tabMode")){for(var d=a.getModel(),e=a.getSelection(),f=d.getLineAtOffset(e.start),g=d.getLineAtOffset(e.end>e.start?e.end-1:e.end),h=c.getOptions("tabSize"),k=Array(h+1).join(" "),q=[],p=c=0,r=f;r<=g;r++){var m=d.getLine(r,!0);if(d.getLineStart(r)!==
|
|
d.getLineEnd(r))if(0===m.indexOf("\t"))m=m.substring(1),c++;else if(0===m.indexOf(k))m=m.substring(h),c+=h;else return!0;r===f&&(p=c);q.push(m)}f=d.getLineStart(f);h=d.getLineEnd(g,!0);d=d.getLineStart(g);a.setText(q.join(""),f,h);g=f===e.start?e.start:e.start-p;e=Math.max(g,e.end-c+(e.end===d+1&&e.start!==e.end?1:0));a.setSelection(g,e);return!0}},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()}};a.TextActions=
|
|
q;d.prototype={init:function(){var a=this.editor.getTextView();a.setAction("lineStart",function(){return this.lineStart()}.bind(this));a.setAction("enter",function(){return this.autoIndent()}.bind(this));a.setKeyBinding(new t.KeyBinding("t",!0,!1,!0),"trimTrailingWhitespaces");a.setAction("trimTrailingWhitespaces",function(){return this.trimTrailingWhitespaces()}.bind(this),{name:p.trimTrailingWhitespaces});a.setKeyBinding(new t.KeyBinding(191,!0),"toggleLineComment");a.setAction("toggleLineComment",
|
|
function(){return this.toggleLineComment()}.bind(this),{name:p.toggleLineComment});a.setKeyBinding(new t.KeyBinding(191,!0,!f.isMac,!1,f.isMac),"addBlockComment");a.setAction("addBlockComment",function(){return this.addBlockComment()}.bind(this),{name:p.addBlockComment});a.setKeyBinding(new t.KeyBinding(220,!0,!f.isMac,!1,f.isMac),"removeBlockComment");a.setAction("removeBlockComment",function(){return this.removeBlockComment()}.bind(this),{name:p.removeBlockComment});a.setKeyBinding(new t.KeyBinding("[",
|
|
!1,!1,!1,!1,"keypress"),"autoPairSquareBracket");a.setAction("autoPairSquareBracket",function(){return this.autoPairBrackets("[","]")}.bind(this));a.setKeyBinding(new t.KeyBinding("]",!1,!1,!1,!1,"keypress"),"skipClosingSquareBracket");a.setAction("skipClosingSquareBracket",function(){return this.skipClosingBracket("]")}.bind(this));a.setKeyBinding(new t.KeyBinding("\x3c",!1,!1,!1,!1,"keypress"),"autoPairAngleBracket");a.setAction("autoPairAngleBracket",function(){return this.autoPairBrackets("\x3c",
|
|
"\x3e")}.bind(this));a.setKeyBinding(new t.KeyBinding("\x3e",!1,!1,!1,!1,"keypress"),"skipClosingAngleBracket");a.setAction("skipClosingAngleBracket",function(){return this.skipClosingBracket("\x3e")}.bind(this));a.setKeyBinding(new t.KeyBinding("(",!1,!1,!1,!1,"keypress"),"autoPairParentheses");a.setAction("autoPairParentheses",function(){return this.autoPairBrackets("(",")")}.bind(this));a.setKeyBinding(new t.KeyBinding(")",!1,!1,!1,!1,"keypress"),"skipClosingParenthesis");a.setAction("skipClosingParenthesis",
|
|
function(){return this.skipClosingBracket(")")}.bind(this));a.setKeyBinding(new t.KeyBinding("{",!1,!1,!1,!1,"keypress"),"autoPairBraces");a.setAction("autoPairBraces",function(){return this.autoPairBrackets("{","}")}.bind(this));a.setKeyBinding(new t.KeyBinding("}",!1,!1,!1,!1,"keypress"),"skipClosingBrace");a.setAction("skipClosingBrace",function(){return this.skipClosingBracket("}")}.bind(this));a.setKeyBinding(new t.KeyBinding("'",!1,!1,!1,!1,"keypress"),"autoPairSingleQuotation");a.setAction("autoPairSingleQuotation",
|
|
function(){return this.autoPairQuotations("'")}.bind(this));a.setKeyBinding(new t.KeyBinding('"',!1,!1,!1,!1,"keypress"),"autoPairDblQuotation");a.setAction("autoPairDblQuotation",function(){return this.autoPairQuotations('"')}.bind(this));a.setAction("deletePrevious",function(){return this.deletePrevious()}.bind(this))},autoIndent:function(){var a=this.editor,c=a.getTextView();if(c.getOptions("readonly")||c.getOptions("singleMode"))return!1;var d=a.getSelection();if(d.start===d.end){for(var e=a.getModel(),
|
|
f=e.getLineAtOffset(d.start),g=e.getLine(f,!1),h=e.getLineStart(f),k=0,q=d.start-h,p;k<q&&(32===(p=g.charCodeAt(k))||9===p);)k++;var h=g.substring(0,k),c=c.getOptions("tabSize","expandTab"),r=c.expandTab?Array(c.tabSize+1).join(" "):"\t",c=e.getLineDelimiter(),m=/^[\s]*\/\*[\*]*[\s]*$/,t=/^[\s]*\*/,B=/\*\/[\s]*$/,A=g.substring(0,q),D=g.substring(q),H;if(this.smartIndentation&&123===g.charCodeAt(H=A.trimRight().length-1))return e=q-H-1,D=D.length-D.trimLeft().length,g=125===g.charCodeAt(q+D)?c+h+r+
|
|
c+h:c+h+r,a.setText(g,d.start-e,d.end+D),a.setCaretOffset(d.start+c.length+h.length+r.length-e),!0;if(this.autoCompleteComments&&!B.test(A)&&(m.test(A)||t.test(A))){if(k=m.exec(A)){g=c+h+" * ";g=B.test(D)?g+D.substring(0,D.length-2).trim():g+D.trim();if(e.getLineCount()===f+1||!t.test(e.getLine(f+1)))g+=c+h+" */";a.setText(g,d.start,d.end+D.length);a.setCaretOffset(d.start+c.length+h.length+3);return!0}if(k=t.exec(A))for(f-=1;0<=f;f--){k=e.getLine(f,!1);if(m.test(k))return B.test(D)||47===g.charCodeAt(q)?
|
|
(g=c+h+"*"+D,h=d.start+c.length+h.length+1):(g=c+h+"* "+D,h=d.start+c.length+h.length+2),a.setText(g,d.start,d.end+D.length),a.setCaretOffset(h),!0;if(!t.test(k))break}}else{if(B.test(A)&&32===h.charCodeAt(h.length-1))return g=c+h.substring(0,h.length-1),a.setText(g,d.start,d.end),a.setCaretOffset(d.start+g.length),!0;if(0<k){for(k=q;k<g.length&&(32===(p=g.charCodeAt(k++))||9===p);)d.end++;a.setText(e.getLineDelimiter()+h,d.start,d.end);return!0}}}return!1},addBlockComment:function(){var a=this.editor;
|
|
if(a.getTextView().getOptions("readonly"))return!1;var c=a.getModel(),d=a.getSelection(),e=this._findEnclosingComment(c,d.start,d.end);if(void 0!==e.commentStart&&void 0!==e.commentEnd)return!0;c=c.getText(d.start,d.end);if(0===c.length)return!0;var e=c.length,c=c.replace(/\/\*|\*\//g,""),f=c.length;a.setText("/*"+c+"*/",d.start,d.end);a.setSelection(d.start+2,d.end+2+(f-e));return!0},autoPairBrackets:function(a,c){if("["===a&&!this.autoPairSquareBrackets||"{"===a&&!this.autoPairBraces||"("===a&&
|
|
!this.autoPairParentheses||"\x3c"===a&&!this.autoPairAngleBrackets)return!1;var d=this.editor;if(d.getTextView().getOptions("readonly"))return!1;var e=d.getSelection(),f=d.getModel(),g=d.getCaretOffset()===f.getCharCount()?"":f.getText(e.start,e.start+1).trim(),h=/^$|[)}\]>]/;return e.start===e.end&&h.test(g)?(d.setText(a+c,e.start,e.start),d.setCaretOffset(e.start+1),!0):e.start!==e.end?(f=f.getText(e.start,e.end),d.setText(a+f+c,e.start,e.end),d.setSelection(e.start+1,e.end+1),!0):!1},autoPairQuotations:function(a){if(!this.autoPairQuotation)return!1;
|
|
var c=this.editor;if(c.getTextView().getOptions("readonly"))return!1;var d=c.getSelection(),e=c.getModel(),f=c.getCaretOffset(),g=0===f?"":e.getText(d.start-1,d.start).trim(),h=f===e.getCharCount()?"":e.getText(d.start,d.start+1).trim(),f=/^"$|^'$/,k=/\w/,q=/^$|[)}\]>]/;if(d.start!==d.end){e=e.getText(d.start,d.end);if(f.test(e))return!1;c.setText(a+e+a,d.start,d.end);c.setSelection(d.start+1,d.end+1)}else{if(h!==a){if(g===a||f.test(h)||k.test(g)||!q.test(h))return!1;c.setText(a+a,d.start,d.start)}c.setCaretOffset(d.start+
|
|
1)}return!0},contentAssistProposalApplied:function(a){function c(){return"number"===typeof d.escapePosition?d.escapePosition:a.data.start+d.proposal.length}var d=a.data.proposal;if(d.positions&&0<d.positions.length&&this.linkedMode){for(var e=[],f=0;f<d.positions.length;++f)e[f]={positions:[{offset:d.positions[f].offset,length:d.positions[f].length}]};this.linkedMode.enterLinkedMode({groups:e,escapePosition:c()})}else d.groups&&0<d.groups.length&&this.linkedMode?this.linkedMode.enterLinkedMode({groups:d.groups,
|
|
escapePosition:c()}):"number"===typeof d.escapePosition&&this.editor.getTextView().setCaretOffset(d.escapePosition);return!0},deletePrevious:function(){var a=this.editor;if(a.getTextView().getOptions("readonly"))return!1;var c=a.getSelection();if(c.start!==c.end)return!1;var d=a.getModel(),e=a.getCaretOffset(),f=0===e?"":d.getText(c.start-1,c.start),d=e===d.getCharCount()?"":d.getText(c.start,c.start+1);("("===f&&")"===d||"["===f&&"]"===d||"{"===f&&"}"===d||"\x3c"===f&&"\x3e"===d||'"'===f&&'"'===
|
|
d||"'"===f&&"'"===d)&&a.setText("",c.start,c.start+1);return!1},_findEnclosingComment:function(a,c,d){var e=a.getLineAtOffset(c),f=a.getLineAtOffset(d),g,h,k,q,p,r;for(g=e;0<=g&&!(h=a.getLine(g),k=g===e?c-a.getLineStart(e):h.length,q=h.lastIndexOf("/*",k),h=h.lastIndexOf("*/",k),h>q);g--)if(-1!==q){p=a.getLineStart(g)+q;break}for(g=f;g<a.getLineCount()&&!(h=a.getLine(g),k=g===f?d-a.getLineStart(f):0,q=h.indexOf("/*",k),h=h.indexOf("*/",k),-1!==q&&q<h);g++)if(-1!==h){r=a.getLineStart(g)+h;break}return{commentStart:p,
|
|
commentEnd:r}},lineStart:function(){for(var a=this.editor,c=a.getModel(),d=a.getCaretOffset(),e=c.getLineAtOffset(d),f=c.getLineStart(e),c=c.getLine(e),e=0;e<c.length;e++){var g=c.charCodeAt(e);if(!(32===g||9===g))break}e+=f;return d!==e?(a.setSelection(e,e),!0):!1},removeBlockComment:function(){var a=this.editor;if(a.getTextView().getOptions("readonly"))return!1;var c=a.getModel(),d=a.getSelection(),e=c.getText(d.start,d.end),f,g,h;for(h=0;h<e.length;h++)if("/*"===e.substring(h,h+2)){f=d.start+h;
|
|
break}for(;h<e.length;h++)if("*/"===e.substring(h,h+2)){g=d.start+h;break}if(void 0!==f&&void 0!==g)a.setText(c.getText(f+2,g),f,g+2),a.setSelection(f,g);else{e=this._findEnclosingComment(c,d.start,d.end);if(void 0===e.commentStart||void 0===e.commentEnd)return!0;c=c.getText(e.commentStart+2,e.commentEnd);a.setText(c,e.commentStart,e.commentEnd+2);a.setSelection(d.start-2,d.end-2)}return!0},toggleLineComment:function(){var a=this.editor,c=a.getTextView();if(c.getOptions("readonly"))return!1;for(var d=
|
|
this.lineComment||"//",e=a.getModel(),f=a.getSelection(),g=e.getLineAtOffset(f.start),h=e.getLineAtOffset(f.end>f.start?f.end-1:f.end),k=!0,q=[],p,r=g;r<=h;r++){var m=e.getLine(r,!0);p=m.indexOf(d);q.push(p);if(!k||-1===p)k=!1;else if(0!==p){for(k=0;k<p;k++){var t=m.charCodeAt(k);if(!(32===t||9===t))break}k=k===p}}r=d.length;m=e.getLineStart(g);c.setRedraw(!1);this.startUndo();if(k){for(k=q.length-1;0<=k;k--)p=q[k]+e.getLineStart(g+k),a.setText("",p,p+r);e=e.getLineStart(h);d=m===f.start?f.start:
|
|
f.start-r;f=f.end-r*(h-g+1)+(f.end===e+1?r:0)}else{for(k=q.length-1;0<=k;k--)p=e.getLineStart(g+k),a.setText(d,p,p);d=m===f.start?f.start:f.start+r;f=f.end+r*(h-g+1)}this.endUndo();a.setSelection(d,f);c.setRedraw(!0);return!0},trimTrailingWhitespaces:function(){var a=this.editor,c=a.getModel(),d=a.getSelection();a.getTextView().setRedraw(!1);a.getUndoStack().startCompoundChange();for(var e=/(\s+$)/,f=c.getLineCount(),g=0;g<f;g++){var h=c.getLine(g),k=e.exec(h);if(k){var q=c.getLineStart(g),h=k[0].length,
|
|
k=q+k.index;c.setText("",k,k+h);d.start>k&&(d.start=Math.max(k,d.start-h));d.start!==d.end&&d.end>k&&(d.end=Math.max(k,d.end-h))}}a.getUndoStack().endCompoundChange();a.setSelection(d.start,d.end,!1);a.getTextView().setRedraw(!0)},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},skipClosingBracket:function(a){var c=this.editor;if(c.getTextView().getOptions("readonly"))return!1;var d=c.getSelection(),e=c.getModel();return(c.getCaretOffset()===e.getCharCount()?"":e.getText(d.start,
|
|
d.start+1))===a?(c.setCaretOffset(d.start+1),!0):!1},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},setAutoPairParentheses:function(a){this.autoPairParentheses=a},setAutoPairBraces:function(a){this.autoPairBraces=a},setAutoPairSquareBrackets:function(a){this.autoPairSquareBrackets=a},setAutoPairAngleBrackets:function(a){this.autoPairAngleBrackets=a},setAutoPairQuotations:function(a){this.autoPairQuotation=a},setAutoCompleteComments:function(a){this.autoCompleteComments=a},
|
|
setLineComment:function(a){this.lineComment=a},setSmartIndentation:function(a){this.smartIndentation=a}};a.SourceCodeActions=d;String.prototype.trimLeft||(String.prototype.trimLeft=function(){return this.replace(/^\s+/g,"")});String.prototype.trimRight||(String.prototype.trimRight=function(){return this.replace(/\s+$/g,"")});return a});
|
|
define("orion/editor/templates",[],function(){function p(p,k,g,h){this.prefix=p;this.description=k;this.template=g;this.name=h;this._parse()}function t(p,k){this._keywords=p||[];this._templates=[];this.addTemplates(k||[])}p.prototype={getProposal:function(p,k,g){p=k-p.length;k={};var h,f=void 0!==g.delimiter?g.delimiter:"\n";g.indentation&&(f+=g.indentation);var q=void 0!==g.tab?g.tab:"\t",d=0,c=this.variables,a=this.segments;g=[];for(var b=0;b<a.length;b++){var l=a[b],n=c[l];if(void 0!==n)switch(l){case "${tab}":l=
|
|
q;break;case "${delimiter}":l=f;break;case "${cursor}":l="";h=d;break;default:var e=k[l];e||(e=k[l]={data:n.data,positions:[]});l=n.substitution;e.data&&e.data.values&&(l=e.data.values[0]);e.positions.push({offset:p+d,length:l.length})}g.push(l);d+=l.length}var f=[],s;for(s in k)k.hasOwnProperty(s)&&f.push(k[s]);g=g.join("");void 0===h&&(h=g.length);return{proposal:g,name:this.name,description:this.description,groups:f,escapePosition:p+h,style:"noemphasis"}},match:function(p){return 0===this.prefix.indexOf(p)},
|
|
_parse:function(){var p=this.template,k=[],g={},h,f=0,p=p.replace(/\n/g,"${delimiter}"),p=p.replace(/\t/g,"${tab}");p.replace(/\$\{((?:[^\\}]+|\\.))*\}/g,function(q,d,c){var a=q.substring(2,q.length-1);d=q;var b=a,l=null,n=b.indexOf(":");-1!==n&&(b=b.substring(0,n),d="${"+b+"}",l=JSON.parse(a.substring(n+1).replace("\\}","}").trim()));(a=g[d])||(a=g[d]={});a.substitution=b;l&&(a.data=l);(h=p.substring(f,c))&&k.push(h);k.push(d);f=c+q.length;return b});(h=p.substring(f,p.length))&&k.push(h);this.segments=
|
|
k;this.variables=g}};t.prototype={addTemplates:function(r){for(var k=this.getTemplates(),g=0;g<r.length;g++)k.push(new p(r[g].prefix,r[g].description,r[g].template,r[g].name))},initialize:function(){},computeProposals:function(p,k,g){var h=this.getPrefix(p,k,g),f=[];this.isValid(h,p,k,g)&&(f=f.concat(this.getTemplateProposals(h,k,g)),f=f.concat(this.getKeywordProposals(h)));return f},getKeywords:function(){return this._keywords},getKeywordProposals:function(p){var k=[],g=this.getKeywords();if(g){for(var h=
|
|
0;h<g.length;h++)0===g[h].indexOf(p)&&k.push({proposal:g[h].substring(p.length),description:g[h],style:"noemphasis_keyword"});0<k.length&&k.splice(0,0,{proposal:"",description:"Keywords",style:"noemphasis_title_keywords",unselectable:!0})}return k},getPrefix:function(p,k,g){return g.prefix},getTemplates:function(){return this._templates},getTemplateProposals:function(p,k,g){for(var h=[],f=this.getTemplates(),q=0;q<f.length;q++){var d=f[q];d.match(p)&&(d=d.getProposal(p,k,g),this.removePrefix(p,d),
|
|
h.push(d))}0<h.length&&(h.sort(function(c,a){return c.name<a.name?-1:c.name>a.name?1:0}),h.splice(0,0,{proposal:"",description:"Templates",style:"noemphasis_title",unselectable:!0}));return h},removePrefix:function(p,k){if(!(k.overwrite=k.proposal.substring(0,p.length)!==p))k.proposal=k.proposal.substring(p.length)},isValid:function(p,k,g,h){return!0}};return{Template:p,TemplateContentAssist:t}});
|
|
define("orion/editor/linkedMode","i18n!orion/editor/nls/messages orion/keyBinding orion/editor/keyModes orion/editor/annotations orion/editor/templates orion/objects orion/util".split(" "),function(p,t,r,k,g,h){function f(d,c,a){var b=d.getTextView();r.KeyMode.call(this,b);this.editor=d;this.undoStack=c;this.contentAssist=a;this.linkedModeModel=null;b.setAction("linkedModeEnter",function(){this.exitLinkedMode(!0);return!0}.bind(this));b.setAction("linkedModeCancel",function(){this.exitLinkedMode(!1);
|
|
return!0}.bind(this));b.setAction("linkedModeNextGroup",function(){var a=this.linkedModeModel;this.selectLinkedGroup((a.selectedGroupIndex+1)%a.groups.length);return!0}.bind(this));b.setAction("linkedModePreviousGroup",function(){var a=this.linkedModeModel;this.selectLinkedGroup(0<a.selectedGroupIndex?a.selectedGroupIndex-1:a.groups.length-1);return!0}.bind(this));this.linkedModeListener={onActivating:function(a){this._groupContentAssistProvider&&(this.contentAssist.setProviders([this._groupContentAssistProvider]),
|
|
this.contentAssist.setProgress(null))}.bind(this),onModelChanged:function(a){if(!this.ignoreVerify){for(var b=this.editor.mapOffset(a.start),c=this.linkedModeModel,d,f;c;)if(d=this._getPositionChanged(c,b,b+a.removedCharCount),f=d.position,void 0===f||f.model!==c)this.exitLinkedMode(!1),c=this.linkedModeModel;else break;if(c){c=0;a=a.addedCharCount-a.removedCharCount;d=d.positions;for(var g,h=0;h<d.length;++h){g=d[h];f=g.position;var k=f.offset<=b&&b<=f.offset+f.length;k&&!g.ansestor?(f.offset+=c,
|
|
f.length+=a,c+=a):(f.offset+=c,g.ansestor&&k&&(f.length+=a));g.escape&&(g.model.escapePosition=f.offset)}this._updateAnnotations(d)}}}.bind(this),onVerify:function(a){if(!this.ignoreVerify){for(var b=this.editor,c=b.mapOffset(a.start),d=this.editor.mapOffset(a.end),f=this.linkedModeModel,g,h;f;)if(g=this._getPositionChanged(f,c,d),h=g.position,void 0===h||h.model!==f)this.exitLinkedMode(!1),f=this.linkedModeModel;else break;if(f){var k=this._compoundChange;k?k.owner.model===f&&k.owner.group===h.group||
|
|
(this.endUndo(),this.startUndo()):this.startUndo();f.selectedGroupIndex=h.group;var k=0,q=a.text.length-(d-c);g=g.positions;for(var p,c=c-h.position.offset,m=d-h.position.offset,r=0;r<g.length;++r)p=g[r],d=p.position,p.oldOffset=d.offset,p.model===f&&p.group===h.group?(d.offset+=k,d.length+=q,k+=q):(d.offset+=k,p.ansestor&&(d.length+=h.count*q)),p.escape&&(p.model.escapePosition=d.offset);this.ignoreVerify=!0;for(r=g.length-1;0<=r;r--)p=g[r],p.model===f&&p.group===h.group&&b.setText(a.text,p.oldOffset+
|
|
c,p.oldOffset+m);this.ignoreVerify=!1;a.text=null;this._updateAnnotations(g)}}}.bind(this)}}var q={};f.prototype=new r.KeyMode;h.mixin(f.prototype,{createKeyBindings:function(){var d=t.KeyBinding,c=[];c.push({actionID:"linkedModeEnter",keyBinding:new d(13)});c.push({actionID:"linkedModeCancel",keyBinding:new d(27)});c.push({actionID:"linkedModeNextGroup",keyBinding:new d(9)});c.push({actionID:"linkedModePreviousGroup",keyBinding:new d(9,!1,!0)});return c},enterLinkedMode:function(d){if(!this.linkedModeModel){var c=
|
|
this.editor.getTextView();c.addKeyMode(this);c.addEventListener("Verify",this.linkedModeListener.onVerify);c.addEventListener("ModelChanged",this.linkedModeListener.onModelChanged);this.contentAssist.addEventListener("Activating",this.linkedModeListener.onActivating);this.editor.reportStatus(p.linkedModeEntered,null,!0)}this._sortedPositions=null;this.linkedModeModel&&(d.previousModel=this.linkedModeModel,d.parentGroup=this.linkedModeModel.selectedGroupIndex,this.linkedModeModel.nextModel=d);this.linkedModeModel=
|
|
d;this.selectLinkedGroup(0)},exitLinkedMode:function(d){if(this.isActive()){this._compoundChange&&(this.endUndo(),this._compoundChange=null);this._sortedPositions=null;var c=this.linkedModeModel;this.linkedModeModel=c.previousModel;c.parentGroup=c.previousModel=void 0;this.linkedModeModel&&(this.linkedModeModel.nextModel=void 0);if(!this.linkedModeModel){var a=this.editor,b=a.getTextView();b.removeKeyMode(this);b.removeEventListener("Verify",this.linkedModeListener.onVerify);b.removeEventListener("ModelChanged",
|
|
this.linkedModeListener.onModelChanged);b=this.contentAssist;b.removeEventListener("Activating",this.linkedModeListener.onActivating);b.offset=void 0;this.editor.reportStatus(p.linkedModeExited,null,!0);d&&"number"===typeof c.escapePosition&&a.setCaretOffset(c.escapePosition,!1)}this.selectLinkedGroup(0)}},startUndo:function(){if(this.undoStack){var d=this,c=this.linkedModeModel;this._compoundChange=this.undoStack.startCompoundChange({model:c,group:c.selectedGroupIndex,end:function(){d._compoundChange=
|
|
null}})}},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},isActive:function(){return!!this.linkedModeModel},isStatusActive:function(){return!!this.linkedModeModel},selectLinkedGroup:function(d){var c=this.linkedModeModel;if(c){c.selectedGroupIndex=d;d=c.groups[d];var a=d.positions[0],b=this.editor;b.setSelection(a.offset,a.offset+a.length);if(c=this.contentAssist)c.offset=void 0,d.data&&"link"===d.data.type&&d.data.values?((this._groupContentAssistProvider=new g.TemplateContentAssist(d.data.values)).getPrefix=
|
|
function(){var c=b.getSelection();return c.start===c.end&&(c=b.getCaretOffset(),a.offset<=c&&c<=a.offset+a.length)?b.getText(a.offset,c):""},c.offset=a.offset,c.deactivate(),c.activate()):this._groupContentAssistProvider&&(this._groupContentAssistProvider=null,c.deactivate())}this._updateAnnotations()},_getModelPositions:function(d,c,a){for(var b=c.groups,f=0;f<b.length;f++)for(var g=b[f].positions,e=0;e<g.length;e++){var h=g[e];a&&(h={offset:h.offset+a,length:h.length});h={index:e,group:f,count:g.length,
|
|
model:c,position:h};d.push(h);c.nextModel&&c.nextModel.parentGroup===f&&(h.ansestor=!0,this._getModelPositions(d,c.nextModel,(a||0)+g[e].offset-g[0].offset))}},_getSortedPositions:function(d){var c=this._sortedPositions;if(!c){for(c=[];d.previousModel;)d=d.previousModel;for(this._getModelPositions(c,d);d;)"number"===typeof d.escapePosition&&c.push({escape:!0,model:d,position:{offset:d.escapePosition,length:0}}),d=d.nextModel;c.sort(function(a,b){return a.position.offset-b.position.offset});this._sortedPositions=
|
|
c}return c},_getPositionChanged:function(d,c,a){var b;d=this._getSortedPositions(d);for(var f=d.length-1;0<=f;f--){var g=d[f].position;if(g.offset<=c&&a<=g.offset+g.length){b=d[f];break}}return{position:b,positions:d}},_updateAnnotations:function(d){var c=this.editor.getAnnotationModel();if(c){for(var a=[],b=[],f=c.getAnnotations(),g;f.hasNext();)switch(g=f.next(),g.type){case k.AnnotationType.ANNOTATION_LINKED_GROUP:case k.AnnotationType.ANNOTATION_CURRENT_LINKED_GROUP:case k.AnnotationType.ANNOTATION_SELECTED_LINKED_GROUP:a.push(g)}if(f=
|
|
this.linkedModeModel){d=d||this._getSortedPositions(f);for(var e=0;e<d.length;e++)if(g=d[e],g.model===f&&!g.escape){var h=k.AnnotationType.ANNOTATION_LINKED_GROUP;g.group===f.selectedGroupIndex&&(h=0===g.index?k.AnnotationType.ANNOTATION_SELECTED_LINKED_GROUP:k.AnnotationType.ANNOTATION_CURRENT_LINKED_GROUP);g=g.position;g=k.AnnotationType.createAnnotation(h,g.offset,g.offset+g.length,"");b.push(g)}}c.replaceAnnotations(a,b)}}});q.LinkedMode=f;return q});
|
|
define("orion/editor/factories","orion/editor/actions orion/editor/undoStack orion/editor/rulers orion/editor/annotations orion/editor/textDND orion/editor/linkedMode orion/util".split(" "),function(p,t,r,k,g,h,f){function q(){}function d(){}function c(){}function a(){}function b(){}function l(){}function n(){}var e={};q.prototype={createKeyBindings:function(a,b,c,e){e=new p.TextActions(a,b,e);var d=new h.LinkedMode(a,b,c);a=new p.SourceCodeActions(a,b,c,d);return{textActions:e,linkedMode:d,sourceCodeActions:a}}};
|
|
e.KeyBindingsFactory=q;d.prototype={createUndoStack:function(a){a=a.getTextView();return new t.UndoStack(a,200)}};e.UndoFactory=d;c.prototype={createLineNumberRuler:function(a){return new r.LineNumberRuler(a,"left",{styleClass:"ruler lines"},{styleClass:"rulerLines odd"},{styleClass:"rulerLines even"})}};e.LineNumberRulerFactory=c;a.prototype={createFoldingRuler:function(a){return new r.FoldingRuler(a,"left",{styleClass:"ruler folding"})}};e.FoldingRulerFactory=a;b.prototype={createZoomRuler:function(a){return new r.ZoomRuler(f.isIOS||
|
|
f.isAndroid?"right":"innerRight",{styleClass:"ruler zoom"})}};e.ZoomRulerFactory=b;l.prototype={createAnnotationModel:function(a){return new k.AnnotationModel(a)},createAnnotationStyler:function(a,b){return new k.AnnotationStyler(a,b)},createAnnotationRulers:function(a){var b=new r.AnnotationRuler(a,"left",{styleClass:"ruler annotations"});a=new r.OverviewRuler(a,"right",{styleClass:"ruler overview"});return{annotationRuler:b,overviewRuler:a}}};e.AnnotationFactory=l;n.prototype={createTextDND:function(a,
|
|
b){return new g.TextDND(a.getTextView(),b)}};e.TextDNDFactory=n;return e});define("orion/editor/editorFeatures",["orion/editor/factories","orion/editor/actions","orion/editor/linkedMode","orion/objects"],function(p,t,r,k){return k.mixin({},p,t,r)});
|
|
(function(p,t){"function"===typeof define&&define.amd?define("orion/Deferred",t):"object"===typeof exports?module.exports=t():(p.orion=p.orion||{},p.orion.Deferred=t())})(this,function(){function p(){for(var f;f=g.shift();)f();h=!1}function t(k){g.push(k);h||(h=!0,f())}function r(f){return function(d){f(d)}}function k(){function f(){for(var a;a=h.shift();){var c=a.deferred,e="fulfilled"===g?"resolve":"reject";a=a[e];if("function"===typeof a)try{var d=a(b),k=d&&("object"===typeof d||"function"===typeof d)&&
|
|
d.then;if("function"===typeof k)if(d===c.promise)c.reject(new TypeError);else{var q=d.cancel;"function"===typeof q?c._parentCancel=q.bind(d):delete c._parentCancel;k.call(d,r(c.resolve),r(c.reject),r(c.progress))}else c.resolve(d)}catch(p){c.reject(p)}else c[e](b)}}function d(a){delete e._parentCancel;g="rejected";b=a;h.length&&t(f)}function c(a){function p(a){return function(b){(!g||"assumed"===g)&&a(b)}}delete e._parentCancel;try{var x=a&&("object"===typeof a||"function"===typeof a)&&a.then;if("function"===
|
|
typeof x)if(a===e)d(new TypeError);else{g="assumed";var r=a&&a.cancel;if("function"!==typeof r){var y=new k;a=y.promise;try{x(y.resolve,y.reject,y.progress)}catch(z){y.reject(z)}r=a.cancel;x=a.then}b=a;x.call(a,p(c),p(d));e._parentCancel=r.bind(a)}else g="fulfilled",b=a,h.length&&t(f)}catch(C){p(d)(C)}}function a(){var a=e._parentCancel;a?(delete e._parentCancel,a()):g||(a=Error("Cancel"),a.name="Cancel",d(a))}var b,g,h=[],e=this;this.resolve=function(a){g||c(a);return e};this.reject=function(a){g||
|
|
d(a);return e};this.progress=function(a){g||h.forEach(function(b){if(b.progress)try{b.progress(a)}catch(c){}});return e.promise};this.cancel=function(){e._parentCancel?setTimeout(a,0):a();return e};this.then=function(a,b,c){var d=new k;d._parentCancel=e.promise.cancel;h.push({resolve:a,reject:b,progress:c,deferred:d});("fulfilled"===g||"rejected"===g)&&t(f);return d.promise};this.promise={then:e.then,cancel:e.cancel}}var g=[],h=!1,f=function(){if("undefined"!==typeof process&&"function"===typeof process.nextTick){var f=
|
|
process.nextTick;return function(){f(p)}}if("function"===typeof MutationObserver){var d=document.createElement("div");(new MutationObserver(p)).observe(d,{attributes:!0});return function(){d.setAttribute("class","_tick")}}return function(){setTimeout(p,0)}}();k.all=function(f,d){function c(a,c){h||(g[a]=c,0===--b&&e.resolve(g))}function a(a,b){if(!h){if(d)try{c(a,d(b));return}catch(f){b=f}e.reject(b)}}var b=f.length,g=[],h=!1,e=new k;e.then(void 0,function(){h=!0;f.forEach(function(a){a.cancel&&a.cancel()})});
|
|
0===b?e.resolve(g):f.forEach(function(b,e){b.then(c.bind(void 0,e),a.bind(void 0,e))});return e.promise};k.when=function(f,d,c,a){var b;f&&"function"===typeof f.then||(b=new k,b.resolve(f),f=b.promise);return f.then(d,c,a)};return k});
|
|
define("orion/webui/littlelib",["orion/util"],function(p){function t(a,b){b||(b=document);return b.querySelectorAll(a)}function r(a){var b=a.tabIndex;0===b&&p.isIE&&!{a:!0,body:!0,button:!0,frame:!0,iframe:!0,img:!0,input:!0,isindex:!0,object:!0,select:!0,textarea:!0}[a.nodeName.toLowerCase()]&&!a.attributes.tabIndex&&(b=-1);return b}function k(a){if(0<=r(a))return a;if(a.hasChildNodes())for(var b=0;b<a.childNodes.length;b++){var c=k(a.childNodes[b]);if(c)return c}return null}function g(a){if(0<=
|
|
r(a))return a;if(a.hasChildNodes())for(var b=a.childNodes.length-1;0<=b;b--){var c=g(a.childNodes[b]);if(c)return c}return null}function h(a,b){if(3===a.nodeType){var c=f.exec(a.nodeValue);c&&1<c.length&&b(a,c)}if(a.hasChildNodes())for(c=0;c<a.childNodes.length;c++)h(a.childNodes[c],b)}var f=/\$\{([^\}]+)\}/,q=null,d={BKSPC:8,TAB:9,ENTER:13,ESCAPE:27,SPACE:32,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,INSERT:45,DEL:46},c=Object.create(null);Object.keys(d).forEach(function(a){c[d[a]]=
|
|
a});return{$:function(a,b){b||(b=document);return b.querySelector(a)},$$:t,$$array:function(a,b){return Array.prototype.slice.call(t(a,b))},node:function(a){var b=a;"string"===typeof a&&(b=document.getElementById(a));return b},contains:function(a,b){if(!a||!b)return!1;if(a===b)return!0;var c=a.compareDocumentPosition(b);return Boolean(c&16)},bounds:function(a){a=a.getBoundingClientRect();return{left:a.left+document.documentElement.scrollLeft,top:a.top+document.documentElement.scrollTop,width:a.width,
|
|
height:a.height}},empty:function(a){for(;a.hasChildNodes();)a.removeChild(a.firstChild)},firstTabbable:k,lastTabbable:g,stop:function(a){window.document.all&&(a.keyCode=0);a.preventDefault&&(a.preventDefault(),a.stopPropagation())},processTextNodes:function(a,b){h(a,function(a,c){a.parentNode.replaceChild(document.createTextNode(b[c[1]]||c[1]),a)})},processDOMNodes:function(a,b){h(a,function(a,c){var e=b[c[1]];if(e){var d=document.createRange(),f=c.index;d.setStart(a,f);d.setEnd(a,f+c[0].length);
|
|
d.deleteContents();d.insertNode(e)}})},addAutoDismiss:function(a,b){function c(a){q.forEach(function(b){var c=!1,d=b.excludeNodes.some(function(b){return document.body.contains(b)?(c=!0,b.contains(a.target)):!1});if(c&&!d)try{b.dismiss(a)}catch(f){"undefined"!==typeof console&&console&&console.error(f&&f.message)}});q=q.filter(function(a){return a.excludeNodes.some(function(a){return document.body.contains(a)})})}null===q&&(q=[],document.addEventListener("click",c,!0),p.isIOS&&document.addEventListener("touchend",
|
|
function(a){function b(){a.target.removeEventListener("click",b)}0===a.touches.length&&a.target.addEventListener("click",b)},!1));q.push({excludeNodes:a,dismiss:b})},setFramesEnabled:function(a){for(var b=document.getElementsByTagName("iframe"),c=0;c<b.length;c++)b[c].parentNode.style.pointerEvents=a?"":"none"},removeAutoDismiss:function(a){q=q.filter(function(b){return a!==b.dismiss})},keyName:function(a){return c[a]||null},KEY:d}});
|
|
define("orion/editor/contentAssist","i18n!orion/editor/nls/messages orion/keyBinding orion/editor/keyModes orion/editor/eventTarget orion/Deferred orion/objects orion/editor/util orion/util orion/webui/littlelib".split(" "),function(p,t,r,k,g,h,f,q,d){function c(a){this.textView=a;this.state=l.INACTIVE;this.clearProviders();var b=this;this._textViewListeners={onModelChanging:function(a){(this._latestModelChangingEvent=a)&&this._updateFilterText(a)}.bind(this),onSelection:function(a){this.isDeactivatingChange(this._latestModelChangingEvent,
|
|
a)?this.setState(l.INACTIVE):this.isActive()&&(this.state===l.ACTIVE&&this.setState(l.FILTERING),this.filterProposals());this._latestModelChangingEvent=null}.bind(this),onScroll:function(a){this.setState(l.INACTIVE)}.bind(this)};a.setKeyBinding(q.isMac?new t.KeyBinding(" ",!1,!1,!1,!0):new t.KeyBinding(" ",!0),"contentAssist");a.setKeyBinding(q.isMac?new t.KeyBinding(" ",!1,!1,!0,!0):new t.KeyBinding(" ",!0,!1,!0),"contentAssist");a.setAction("contentAssist",function(){a.getOptions("readonly")||b.activate();
|
|
return!0},{name:p.contentAssist})}function a(a,b){var c=a.textView;r.KeyMode.call(this,c);this.contentAssist=a;this.widget=b;this.proposals=[];var d=this;this.contentAssist.addEventListener("ProposalsComputed",function(a){d.proposals=a.data.proposals;if(0===d.proposals.length)d.selectedIndex=-1,d.cancel();else{for(d.selectedIndex=0;d.proposals[d.selectedIndex]&&d.proposals[d.selectedIndex].unselectable;)d.selectedIndex++;if(d.proposals[d.selectedIndex]){if(d.widget){var b=!0;if(a.autoApply){for(a=
|
|
d.selectedIndex+1;d.proposals[a]&&d.proposals[a].unselectable;)a++;d.proposals[a]||(b=!1,d.contentAssist.apply(d.proposals[d.selectedIndex]))}b&&(d.widget.show(),d.widget.selectNode(d.selectedIndex))}}else d.selectedIndex=-1,d.cancel()}});c.setAction("contentAssistApply",function(){return this.enter()}.bind(this));c.setAction("contentAssistCancel",function(){return this.cancel()}.bind(this));c.setAction("contentAssistNextProposal",function(){return this.lineDown()}.bind(this));c.setAction("contentAssistPreviousProposal",
|
|
function(){return this.lineUp()}.bind(this));c.setAction("contentAssistNextPage",function(){return this.pageDown()}.bind(this));c.setAction("contentAssistPreviousPage",function(){return this.pageUp()}.bind(this));c.setAction("contentAssistHome",function(){this.widget&&this.widget.scrollIndex(0,!0);return this.lineDown(0)}.bind(this));c.setAction("contentAssistEnd",function(){return this.lineUp(this.proposals.length-1)}.bind(this));c.setAction("contentAssistTab",function(){return this.tab()}.bind(this));
|
|
this.widget&&(this.widget.setContentAssistMode(this),this.widget.createAccessible())}function b(a,b){this.contentAssist=a;this.textView=this.contentAssist.getTextView();this.isShowing=this.textViewListenerAdded=!1;var c=this.textView.getOptions("parent").ownerDocument;this.parentNode="string"===typeof b?c.getElementById(b):b;if(!this.parentNode){this.parentNode=q.createElement(c,"div");this.parentNode.className="contentassist";var d=c.getElementsByTagName("body")[0];if(d)d.appendChild(this.parentNode);
|
|
else throw Error("parentNode is required");}f.addEventListener(this.parentNode,"scroll",this.onScroll.bind(this));var g=this;this.textViewListener={onMouseDown:function(a){(a.event.target||a.event.srcElement).parentElement!==g.parentNode&&g.contentAssist.deactivate()}};this.contentAssist.addEventListener("Deactivating",function(a){g.hide()});this.scrollListener=function(a){g.isShowing&&g.position()};f.addEventListener(c,"scroll",this.scrollListener)}var l={INACTIVE:1,ACTIVE:2,FILTERING:3},n={selected:"selected",
|
|
hr:"proposal-hr",emphasis:"proposal-emphasis",noemphasis:"proposal-noemphasis",noemphasis_keyword:"proposal-noemphasis-keyword",noemphasis_title:"proposal-noemphasis-title",noemphasis_title_keywords:"proposal-noemphasis-title-keywords",dfault:"proposal-default"};c.prototype={apply:function(a){if(!a)return!1;var b=this.textView,c=b.getSelection(),d=this._initialCaretOffset,f=d,g=c=Math.max(c.start,c.end),h=b.getModel();h.getBaseModel&&(f=h.mapOffset(f),g=h.mapOffset(g),h=h.getBaseModel());a.overwrite&&
|
|
(d="string"===typeof a.prefix?f-a.prefix.length:this.getPrefixStart(h,f));f={proposal:a,start:f,end:g};this.setState(l.INACTIVE);b.setText("string"===typeof a?a:a.proposal,d,c);this.dispatchEvent({type:"ProposalApplied",data:f});return!0},activate:function(a,b){this.state===l.INACTIVE&&(this._autoTriggered=b?!0:!1,this.setState(l.ACTIVE,a))},deactivate:function(){this.setState(l.INACTIVE)},getTextView:function(){return this.textView},isActive:function(){return this.state===l.ACTIVE||this.state===
|
|
l.FILTERING},isDeactivatingChange:function(a,b){var c=!1;b.newValue.start<this._initialCaretOffset||!a?c=!0:a&&(c=0<a.removedLineCount||0<a.addedLineCount);return c},setState:function(a,b){var c;a===l.ACTIVE?(c="Activating",this._mode&&this._mode.setActive(!0)):a===l.INACTIVE&&(c="Deactivating",this._mode&&this._mode.setActive(!1));c&&this.dispatchEvent({type:c,providers:b});this.state=a;this.onStateChange(a)},setMode:function(a){this._mode=a},onStateChange:function(a){a===l.INACTIVE?(this._removeTextViewListeners(),
|
|
this._filterText="",this._initialCaretOffset=-1,this._computedProposals=null):a===l.ACTIVE&&(this._filterText="",this._addTextViewListeners(),this.computeProposals())},computeProposals:function(){var a=this.textView.getCaretOffset(),b=this.textView.getSelection(),b=Math.min(b.start,b.end);this._initialCaretOffset=Math.min(a,b);this._computedProposals=null;this._computeProposals(this._initialCaretOffset).then(function(a){if(this.isActive()){var b=this._flatten(a);b&&(Array.isArray(b)&&0<b.length)&&
|
|
(this._computedProposals=a);this.dispatchEvent({type:"ProposalsComputed",data:{proposals:b},autoApply:!this._autoTriggered});this._computedProposals&&this._filterText&&this.filterProposals(!0)}}.bind(this))},getPrefixStart:function(a,b){for(var c=b;0<c&&/[A-Za-z0-9_]/.test(a.getText(c-1,c));)c--;return c},handleError:function(a){"undefined"!==typeof console&&(console.log("Error retrieving content assist proposals"),console.log(a&&a.stack))},initialize:function(){this._providers.forEach(function(a){a=
|
|
a.provider;"function"===typeof a.initialize&&a.initialize()})},_computeProposals:function(a){var b=this._providers,c=this.textView,d=c.getSelection(),f=c.getModel(),l=a;f.getBaseModel&&(l=f.mapOffset(l),d.start=f.mapOffset(d.start),d.end=f.mapOffset(d.end),f=f.getBaseModel());a=f.getLine(f.getLineAtOffset(l));for(var n=0;n<a.length&&/\s/.test(a.charAt(n));)n++;var n=a.substring(0,n),c=c.getOptions("tabSize","expandTab"),c=c.expandTab?Array(c.tabSize+1).join(" "):"\t",k={line:a,offset:l,prefix:f.getText(this.getPrefixStart(f,
|
|
l),l),selection:d,delimiter:f.getLineDelimiter(),tab:c,indentation:n},m=this,b=b.map(function(a){a=a.provider;var b;try{var c,e;if(c=a.computeContentAssist){var d=m.editorContextProvider,n=d.getEditorContext();k=h.mixin(k,d.getOptions());e=c.apply(a,[n,k])}else if(c=a.getProposals||a.computeProposals)e=c.apply(a,[f.getText(),l,k]);b=m.progress?m.progress.progress(e,"Generating content assist proposal"):e}catch(s){return(new g).reject(s)}return g.when(b)});return g.all(b,this.handleError)},filterProposals:function(a){if(this._computedProposals&&
|
|
(this._latestModelChangingEvent||a)){a=this.textView.getModel();a.getBaseModel&&(a=a.getBaseModel());a=this.getPrefixStart(a,this._initialCaretOffset);var b=this.textView.getText(a,this._initialCaretOffset),c=b,d=[];this._computedProposals.forEach(function(a){a&&Array.isArray(a)&&(a=a.filter(function(a){if(!a)return!1;c="string"===typeof a.prefix?a.prefix:b;if(n[a.style]===n.hr||n[a.style]===n.noemphasis_title)return!0;var e="";if(a.overwrite){if(a.name)e=a.name;else if(a.proposal)e=a.proposal;else return!1;
|
|
return 0===e.indexOf(c+this._filterText)}return a.name||a.proposal?(e=!1,a.name&&(e=0===a.name.indexOf(c+this._filterText)),!e&&a.proposal&&(e=0===a.proposal.indexOf(this._filterText)),e):"string"===typeof a?0===a.indexOf(this._filterText):!1},this),0<a.length&&d.push(a))},this);a=[];d&&(d=this._removeExtraUnselectableElements(d),a=this._flatten(d));this.dispatchEvent({type:"ProposalsComputed",data:{proposals:a},autoApply:!1})}},_removeExtraUnselectableElements:function(a){return a.map(function(a){return a.filter(function(b,
|
|
c){var e=!0;if(n[b.style]===n.hr)0===c||a.length-1===c?e=!1:n.hr===n[a[c-1].style]&&(e=!1);else if(n[b.style]===n.noemphasis_title){var d=a[c+1];d?n[d.style]===n.noemphasis_title&&(e=!1):e=!1}return e})})},setEditorContextProvider:function(a){this.editorContextProvider=a},_generateProviderId:function(){this._idcount?this._idcount++:this._idcount=0;return"ContentAssistGeneratedID_"+this._idcount},setAutoTriggerEnabled:function(a){this._autoTriggerEnabled=a;this._updateAutoTriggerListenerState()},setProviders:function(a){var b=
|
|
this;this.setProviderInfoArray(a.map(function(a){return a.id?a:{provider:a,id:b._generateProviderId()}}))},setProviderInfoArray:function(a){this.clearProviders();this._providers=a;this._charTriggersInstalled=a.some(function(a){return a.charTriggers});this._updateAutoTriggerListenerState()},getProviders:function(){return this._providers.slice()},clearProviders:function(){this._providers=[];this._charTriggersInstalled=!1;this._updateAutoTriggerListenerState()},setProgress:function(a){this.progress=
|
|
a},setStyleAccessor:function(a){this._styleAccessor=a},_flatten:function(a){return a.reduce(function(a,b){var c=a,e=null;b&&Array.isArray(b)&&(e=b.filter(function(a){return a}));if(e&&Array.isArray(e)&&0<e.length){var c=e,d=a,f=e[0].style;f&&0===n[f].indexOf(n.noemphasis)&&(c=a,d=e);0<c.length&&(e=c[c.length-1].style)&&n.hr!==n[e]&&(c=c.concat({proposal:"",name:"",description:"---------------------------------",style:"hr",unselectable:!0}));c=c.concat(d)}return c},[])},_triggerListener:function(){var a=
|
|
this.textView.getCaretOffset(),b=null,c=[];if(this._charTriggersInstalled){var d=this.textView.getText(a-1,a);this._providers.forEach(function(f){var g=f.charTriggers;if(g&&g.test(d)){var g=!1,l=f.excludedStyles;this._styleAccessor&&l&&(b||(b=this._styleAccessor.getStyles(a-1)),g=b.some(function(a){return l.test(a.style)}));g||c.push(f)}},this);0<c.length&&this.activate(c,!0)}},_updateAutoTriggerListenerState:function(){this._boundTriggerListener||(this._boundTriggerListener=this._triggerListener.bind(this));
|
|
if(this._triggerListenerInstalled){if(!this._autoTriggerEnabled||!this._charTriggersInstalled)this.textView.removeEventListener("Modify",this._boundTriggerListener),this._triggerListenerInstalled=!1}else this._autoTriggerEnabled&&this._charTriggersInstalled&&(this.textView.addEventListener("Modify",this._boundTriggerListener),this._triggerListenerInstalled=!0)},_addTextViewListeners:function(){this._textViewListenersAdded||(this.textView.addEventListener("ModelChanging",this._textViewListeners.onModelChanging),
|
|
this.textView.addEventListener("Scroll",this._textViewListeners.onScroll),this.textView.addEventListener("Selection",this._textViewListeners.onSelection),this._textViewListenersAdded=!0)},_removeTextViewListeners:function(){this._textViewListenersAdded&&(this._latestModelChangingEvent=null,this.textView.removeEventListener("ModelChanging",this._textViewListeners.onModelChanging),this.textView.removeEventListener("Scroll",this._textViewListeners.onScroll),this.textView.removeEventListener("Selection",
|
|
this._textViewListeners.onSelection),this._textViewListenersAdded=!1)},_updateFilterText:function(a){var b=a.removedCharCount;b&&(this._filterText=this._filterText.substring(0,this._filterText.length-b));if(a=a.text)this._filterText=this._filterText.concat(a)}};k.EventTarget.addMixin(c.prototype);a.prototype=new r.KeyMode;h.mixin(a.prototype,{createKeyBindings:function(){var a=t.KeyBinding,b=[];b.push({actionID:"contentAssistApply",keyBinding:new a(13)});b.push({actionID:"contentAssistCancel",keyBinding:new a(27)});
|
|
b.push({actionID:"contentAssistNextProposal",keyBinding:new a(40)});b.push({actionID:"contentAssistPreviousProposal",keyBinding:new a(38)});b.push({actionID:"contentAssistNextPage",keyBinding:new a(34)});b.push({actionID:"contentAssistPreviousPage",keyBinding:new a(33)});b.push({actionID:"contentAssistHome",keyBinding:new a(d.KEY.HOME)});b.push({actionID:"contentAssistEnd",keyBinding:new a(d.KEY.END)});b.push({actionID:"contentAssistTab",keyBinding:new a(9)});return b},cancel:function(){this.getContentAssist().deactivate()},
|
|
getContentAssist:function(){return this.contentAssist},getProposals:function(){return this.proposals},isActive:function(){return this.getContentAssist().isActive()},setActive:function(a){a?this.contentAssist.textView.addKeyMode(this):this.contentAssist.textView.removeKeyMode(this)},lineUp:function(a,b){return this.selectNew(a,b,!1)},lineDown:function(a,b){return this.selectNew(a,b,!0)},selectNew:function(a,b,c){if(c){if(void 0===a&&(a=this.selectedIndex+1),a>=this.proposals.length){if(b)return!0;
|
|
a=0}}else if(void 0===a&&(a=this.selectedIndex-1),0>a){if(b)return!0;a=this.proposals.length-1}for(var d=a;this.proposals[a]&&this.proposals[a].unselectable;){if(c){if(a++,a>=this.proposals.length){if(b)return!0;a=0}}else if(a--,0>a){if(b)return!0;a=this.proposals.length-1}if(a===d){a=-1;break}}this.selectedIndex=a;this.widget&&this.widget.selectNode(a);return!0},pageUp:function(){if(this.widget){var a=this.widget.getTopIndex();a===this.selectedIndex&&(this.widget.scrollIndex(a,!1),a=this.widget.getTopIndex());
|
|
return 0===a?this.lineDown(a,!0):this.lineUp(a,!0)}return this.lineUp()},pageDown:function(){if(this.widget){var a=this.widget.getBottomIndex();a===this.selectedIndex&&(this.widget.scrollIndex(a,!0),a=this.widget.getBottomIndex());return this.lineDown(a,!0)}return this.lineDown()},enter:function(){return this.contentAssist.apply(this.proposals[this.selectedIndex]||null)},tab:function(){return this.widget?(this.widget.parentNode.focus(),!0):!1}});b.prototype={onClick:function(a){a||(a=window.event);
|
|
this.contentAssist.apply(this.getProposal(a.target||a.srcElement));this.textView.focus()},onScroll:function(a){this.previousCloneNode&&!this.preserveCloneThroughScroll&&(this._removeCloneNode(),this.previousSelectedNode.classList.add(n.selected));this.preserveCloneThroughScroll=!1},createDiv:function(a,b,c){var d=b.ownerDocument,f=q.createElement(d,"div");f.id="contentoption"+c;f.setAttribute("role","option");f.className=n[a.style]?n[a.style]:n.dfault;"hr"===a.style?a=q.createElement(d,"hr"):(a=this._createDisplayNode(f,
|
|
a,c),f.contentAssistProposalIndex=c);f.appendChild(a);b.appendChild(f)},createAccessible:function(){var a=this._contentAssistMode,b=this;f.addEventListener(this.parentNode,"keydown",function(c){c||(c=window.event);c.preventDefault&&c.preventDefault();return c.keyCode===d.KEY.ESCAPE?a.cancel():c.keyCode===d.KEY.UP?a.lineUp():c.keyCode===d.KEY.DOWN?a.lineDown():c.keyCode===d.KEY.ENTER?a.enter():c.keyCode===d.KEY.PAGEDOWN?a.pageDown():c.keyCode===d.KEY.PAGEUP?a.pageUp():c.keyCode===d.KEY.HOME?(b.scrollIndex(0,
|
|
!0),a.lineDown(0)):c.keyCode===d.KEY.END?a.lineUp(a.getProposals().length-1):!1})},_createDisplayNode:function(a,b,c){var d=null,f=null;if("string"===typeof b)f=b;else if(b.description&&"string"===typeof b.description)if(b.name&&"string"===typeof b.name){var g=this._createNameNode(b.name);g.contentAssistProposalIndex=c;d=document.createElement("span");d.appendChild(g);g=document.createTextNode(b.description);d.appendChild(g);a.setAttribute("title",b.name+b.description)}else f=b.description;else f=
|
|
b.proposal;f&&(d=this._createNameNode(f),a.setAttribute("title",f));d.contentAssistProposalIndex=c;return d},_createNameNode:function(a){var b=document.createElement("span");b.classList.add("proposal-name");b.appendChild(document.createTextNode(a));return b},getProposal:function(a){var b=null;a=a.contentAssistProposalIndex;void 0!==a&&(b=this._contentAssistMode.getProposals()[a]||null);return b},getTopIndex:function(){for(var a=this.parentNode.childNodes,b=0;b<a.length;b++)if(a[b].offsetTop>=this.parentNode.scrollTop)return b;
|
|
return 0},getBottomIndex:function(){for(var a=this.parentNode.childNodes,b=0;b<a.length;b++){var c=a[b];if(c.offsetTop+c.offsetHeight>this.parentNode.scrollTop+this.parentNode.clientHeight)return Math.max(0,b-1)}return a.length-1},scrollIndex:function(a,b){this.parentNode.childNodes[a].scrollIntoView(b);this.preserveCloneThroughScroll=!0},selectNode:function(a){var b=null;this.previousSelectedNode&&(this.previousSelectedNode.classList.remove(n.selected),this.previousSelectedNode=null,this.previousCloneNode&&
|
|
this._removeCloneNode());if(-1!==a){b=this.parentNode.childNodes[a];b.classList.add(n.selected);this.parentNode.setAttribute("aria-activedescendant",b.id);b.focus();b.offsetTop<this.parentNode.scrollTop?(b.scrollIntoView(!0),this.preserveCloneThroughScroll=!0):b.offsetTop+b.offsetHeight>this.parentNode.scrollTop+this.parentNode.clientHeight&&(b.scrollIntoView(!1),this.preserveCloneThroughScroll=!0);var c=d.bounds(b.firstChild||b),f=d.bounds(this.parentNode);a=window.getComputedStyle(this.parentNode);
|
|
var g=window.getComputedStyle(b),g=parseInt(a.paddingLeft)+parseInt(a.paddingRight)+parseInt(g.paddingLeft)+parseInt(g.paddingRight);if(c.width>=f.width-g){g=parseInt(a.top);f=b.cloneNode(!0);f.classList.add("cloneProposal");f.style.top=g+b.offsetTop-this.parentNode.scrollTop+"px";f.style.left=a.left;f.setAttribute("id",f.id+"_clone");c=c.left+c.width-parseInt(document.documentElement.clientWidth);0<c&&(a=parseInt(a.left)-c,0>a&&(a=0),f.style.left=a+"px");a=document.createElement("div");a.id="clone_contentassist";
|
|
a.classList.add("contentassist");a.classList.add("cloneWrapper");a.appendChild(f);a.onclick=this.parentNode.onclick;this.parentNode.parentNode.insertBefore(a,this.parentNode);var l=function(a){a.contentAssistProposalIndex=b.contentAssistProposalIndex;if(a.hasChildNodes())for(var c=0;c<a.childNodes.length;c++)l(a.childNodes[c])};l(a);b.classList.remove(n.selected);this.previousCloneNode=a}}this.previousSelectedNode=b},setContentAssistMode:function(a){this._contentAssistMode=a},show:function(){var a=
|
|
this._contentAssistMode.getProposals();if(0===a.length)this.hide();else{this.parentNode.innerHTML="";for(var b=0;b<a.length;b++)this.createDiv(a[b],this.parentNode,b);this.position();this.parentNode.onclick=this.onClick.bind(this);this.isShowing=!0;this.textViewListenerAdded||(this.textView.addEventListener("MouseDown",this.textViewListener.onMouseDown),this.textViewListenerAdded=!0)}},hide:function(){this.parentNode.ownerDocument.activeElement===this.parentNode&&this.textView.focus();this.parentNode.style.display=
|
|
"none";this.parentNode.onclick=null;this.isShowing=!1;this.textViewListenerAdded&&(this.textView.removeEventListener("MouseDown",this.textViewListener.onMouseDown),this.textViewListenerAdded=!1);this.previousSelectedNode&&(this.previousSelectedNode=null,this.previousCloneNode&&this._removeCloneNode())},position:function(){var a=this.contentAssist,b=this.textView;if(void 0!==a.offset){var a=a.offset,c=b.getModel();c.getBaseModel&&(a=c.mapOffset(a,!0))}else a=this.textView.getCaretOffset();a=b.getLocationAtOffset(a);
|
|
a.y+=b.getLineHeight();this.textView.convert(a,"document","page");this.parentNode.style.position="fixed";this.parentNode.style.left=a.x+"px";this.parentNode.style.top=a.y+"px";this.parentNode.style.display="block";this.parentNode.scrollTop=0;c=this.parentNode.ownerDocument;b=c.documentElement.clientWidth;c=c.documentElement.clientHeight-a.y;if(this.parentNode.offsetHeight>c){var d=a.y-this.textView.getLineHeight();this.parentNode.offsetHeight>d?c>d?this.parentNode.style.maxHeight=c+"px":(this.parentNode.style.maxHeight=
|
|
d+"px",this.parentNode.style.top="0"):(this.parentNode.style.top=a.y-this.parentNode.offsetHeight-this.textView.getLineHeight()+"px",this.parentNode.style.maxHeight=d+"px")}else this.parentNode.style.maxHeight=c+"px";a.x+this.parentNode.offsetWidth>b?(a=b-this.parentNode.offsetWidth,0>a&&(a=0),this.parentNode.style.left=a+"px",this.parentNode.style.maxWidth=b-a):this.parentNode.style.maxWidth=b+a.x+"px"},_removeCloneNode:function(){this.parentNode.parentNode.contains(this.previousCloneNode)&&this.parentNode.parentNode.removeChild(this.previousCloneNode);
|
|
this.previousCloneNode=null}};return{ContentAssist:c,ContentAssistMode:a,ContentAssistWidget:b}});
|
|
define("orion/editor/stylers/lib/syntax",[],function(){return{id:"orion.lib",grammars:[{id:"orion.lib",repository:{brace_open:{match:"{",name:"punctuation.section.block.begin"},brace_close:{match:"}",name:"punctuation.section.block.end"},bracket_open:{match:"\\[",name:"punctuation.section.bracket.begin"},bracket_close:{match:"\\]",name:"punctuation.section.bracket.end"},parenthesis_open:{match:"\\(",name:"punctuation.section.parens.begin"},parenthesis_close:{match:"\\)",name:"punctuation.section.parens.end"},
|
|
doc_block:{begin:{match:"/\\*\\*",literal:"/**"},end:{match:"\\*/",literal:"*/"},name:"comment.block.documentation",patterns:[{match:"@(?:(?!\\*/)\\S)*",name:"meta.documentation.annotation"},{match:"\\\x3c\\S*\\\x3e",name:"meta.documentation.tag"},{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},number_decimal:{match:"\\b-?(?:\\.\\d+|\\d+\\.?\\d*)(?:[eE][+-]?\\d+)?\\b",name:"constant.numeric.number"},
|
|
number_hex:{match:"\\b0[xX][0-9A-Fa-f]+\\b",name:"constant.numeric.hex"},string_doubleQuote:{match:'"(?:\\\\.|[^"])*"?',name:"string.quoted.double"},string_singleQuote:{match:"'(?:\\\\.|[^'])*'?",name:"string.quoted.single"},todo_comment_singleLine:{match:"(\\b)(TODO)(\\b)(.*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.line"}}}}},{id:"orion.c-like",repository:{comment_singleLine:{match:{match:"//.*",literal:"//"},name:"comment.line.double-slash",
|
|
patterns:[{include:"orion.lib#todo_comment_singleLine"}]},comment_block:{begin:{match:"/\\*",literal:"/*"},end:{match:"\\*/",literal:"*/"},name:"comment.block",patterns:[{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]}}}],keywords:[]}});
|
|
define("orion/editor/stylers/text_css/syntax",["orion/editor/stylers/lib/syntax"],function(p){var t="alignment-adjust alignment-baseline animation-delay animation-direction animation-duration animation-iteration-count animation-name animation-play-state animation-timing-function animation appearance azimuth backface-visibility background-attachment background-clip background-color background-image background-origin background-position background-repeat background-size background baseline-shift binding bleed bookmark-label bookmark-level bookmark-state bookmark-target border-bottom-color border-bottom-left-radius border-bottom-right-radius border-bottom-style border-bottom-width border-bottom border-collapse border-color border-image-outset border-image-repeat border-image-slice border-image-source border-image-width border-image border-left-color border-left-style border-left-width border-left border-radius border-right-color border-right-style border-right-width border-right border-spacing border-style border-top-color border-top-left-radius border-top-right-radius border-top-style border-top-width border-top border-width border bottom box-align box-decoration-break box-direction box-flex-group box-flex box-lines box-ordinal-group box-orient box-pack box-shadow box-sizing break-after break-before break-inside caption-side clear clip color-profile color column-count column-fill column-gap column-rule-color column-rule-style column-rule-width column-rule column-span column-width columns content counter-increment counter-reset crop cue-after cue-before cue cursor direction display dominant-baseline drop-initial-after-adjust drop-initial-after-align drop-initial-before-adjust drop-initial-before-align drop-initial-size drop-initial-value elevation empty-cells fit-position fit flex-align flex-flow flex-inline-pack flex-order flex-pack float-offset float font-family font-size font-size-adjust font-stretch font-style font-variant font-weight font grid-columns grid-rows hanging-punctuation height hyphenate-after hyphenate-before hyphenate-character hyphenate-lines hyphenate-resource hyphens icon image-orientation image-rendering image-resolution inline-box-align left letter-spacing line-height line-stacking-ruby line-stacking-shift line-stacking-strategy line-stacking list-style-image list-style-position list-style-type list-style margin-bottom margin-left margin-right margin-top margin mark-after mark-before mark marker-offset marks marquee-direction marquee-loop marquee-play-count marquee-speed marquee-style max-height max-width min-height min-width move-to nav-down nav-index nav-left nav-right nav-up opacity orphans outline-color outline-offset outline-style outline-width outline overflow-style overflow-x overflow-y overflow padding-bottom padding-left padding-right padding-top padding page-break-after page-break-before page-break-inside page-policy page pause-after pause-before pause perspective-origin perspective phonemes pitch-range pitch play-during position presentation-level punctuation-trim quotes rendering-intent resize rest-after rest-before rest richness right rotation-point rotation ruby-align ruby-overhang ruby-position ruby-span size speak-header speak-numeral speak-punctuation speak speech-rate stress string-set table-layout target-name target-new target-position target text-align-last text-align text-decoration text-emphasis text-height text-indent text-justify text-outline text-shadow text-transform text-wrap top transform-origin transform-style transform transition-delay transition-duration transition-property transition-timing-function transition unicode-bidi vertical-align visibility voice-balance voice-duration voice-family voice-pitch-range voice-pitch voice-rate voice-stress voice-volume volume white-space-collapse white-space widows width word-break word-spacing word-wrap z-index".split(" ");p=
|
|
p.grammars;p.push({id:"orion.css",contentTypes:["text/css"],patterns:[{begin:"'(?:\\\\.|[^\\\\'])*\\\\$",end:"^(?:$|(?:\\\\.|[^\\\\'])*('|[^\\\\]$))",name:"string.quoted.single.css"},{begin:'"(?:\\\\.|[^\\\\"])*\\\\$',end:'^(?:$|(?:\\\\.|[^\\\\"])*("|[^\\\\]$))',name:"string.quoted.double.css"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_block"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},
|
|
{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#number_decimal"},{include:"#number_hex"},{match:"(?i)\\b-?(?:\\.\\d+|\\d+\\.?\\d*)(?:%|em|ex|ch|rem|vw|vh|vmin|vmax|in|cm|mm|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?\\b",name:"constant.numeric.value.css"},{match:"(?:-webkit-|-moz-|-ms-|-o-|\\b)(?:"+t.join("|")+")\\b",name:"support.type.propertyName.css"}],repository:{number_hex:{match:"#[0-9A-Fa-f]+\\b",
|
|
name:"constant.numeric.hex.css"}}});return{id:p[p.length-1].id,grammars:p,keywords:t}});
|
|
define("webtools/cssContentAssist",["orion/editor/templates","orion/editor/stylers/text_css/syntax"],function(p,t){function r(a){return JSON.stringify(a).replace("}","\\}")}function k(){}for(var g={type:"link",values:"visible hidden scroll auto no-display no-content".split(" ")},h={type:"link",values:"solid dashed dotted double groove ridge inset outset".split(" ")},f={type:"link",values:[]},q=0;10>q;q++)f.values.push(q.toString());for(var d={type:"link",values:"black white red green blue magenta yellow cyan grey darkred darkgreen darkblue darkmagenta darkcyan darkyellow darkgray lightgray".split(" ")},
|
|
c=[{prefix:"rule",description:"rule - class selector rule",template:".${class} {\n\t${cursor}\n}"},{prefix:"rule",description:"rule - id selector rule",template:"#${id} {\n\t${cursor}\n}"},{prefix:"outline",description:"outline - outline style",template:"outline: ${color:"+r(d)+"} ${style:"+r(h)+"} ${width:"+r(f)+"}px;"},{prefix:"background-image",description:"background-image - image style",template:'background-image: url("${uri}");'},{prefix:"url",description:"url - url image",template:'url("${uri}");'},
|
|
{prefix:"rgb",description:"rgb - rgb color",template:"rgb(${red},${green},${blue});"},{prefix:"@import",description:"import - import style sheet",template:'@import "${uri}";'},{prefix:"csslint",description:"csslint - add embedded rule severity",template:"/*csslint ${:"+r({type:"link",values:"adjoining-classes box-model box-sizing bulletproof-font-face compatible-vendor-prefixes display-property-grouping duplicate-background-images duplicate-properties empty-rules fallback-colors floats font-faces font-sizes gradients ids import important known-properties outline-none overqualified-elements qualified-headings regex-selectors rules-count selector-max-approaching selector-max shorthand star-property-hack text-indent underscore-property-hack unique-headings universal-selector unqualified-attributes vendor-prefix zero-units".split(" ")})+
|
|
"}: ${a:"+r({type:"link",values:["false","true","0","1","2"]})+"} */"}],a=[{prop:"display",values:{type:"link",values:"none block box flex inline inline-block inline-flex inline-table list-item table table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group inherit".split(" ")}},{prop:"overflow",values:g},{prop:"overflow-x",values:g},{prop:"overflow-y",values:g},{prop:"float",values:{type:"link",values:["left","right","none","inherit"]}},
|
|
{prop:"position",values:{type:"link",values:["absolute","fixed","relative","static","inherit"]}},{prop:"cursor",values:{type:"link",values:"auto crosshair default e-resize help move n-resize ne-resize nw-resize pointer progress s-resize se-resize sw-resize text w-resize wait inherit".split(" ")}},{prop:"color",values:d},{prop:"border-top-color",values:d},{prop:"border-bottom-color",values:d},{prop:"border-right-color",values:d},{prop:"border-left-color",values:d},{prop:"background-color",values:d},
|
|
{prop:"font-style",values:{type:"link",values:["italic","normal","oblique","inherit"]}},{prop:"font-weight",values:{type:"link",values:"bold normal bolder lighter 100 200 300 400 500 600 700 800 900 inherit".split(" ")}},{prop:"white-space",values:{type:"link",values:"pre pre-line pre-wrap nowrap normal inherit".split(" ")}},{prop:"word-wrap",values:{type:"link",values:["normal","break-word"]}},{prop:"visibility",values:{type:"link",values:["hidden","visible","collapse","inherit"]}}],q=0;q<a.length;q++)g=
|
|
a[q],c.push({prefix:g.prop,description:g.prop+" - "+g.prop+" style",template:g.prop+": ${value:"+r(g.values)+"};"});a="width height top bottom left right min-width min-height max-width max-height margin padding padding-left padding-right padding-top padding-bottom margin-left margin-top margin-bottom margin-right".split(" ");for(q=0;q<a.length;q++)g=a[q],c.push({prefix:g,description:g+" - "+g+" pixel style",template:g+": ${value}px;"});a=["padding","margin"];for(q=0;q<a.length;q++)g=a[q],c.push({prefix:g,
|
|
description:g+" - "+g+" top right bottom left style",template:g+": ${top}px ${left}px ${bottom}px ${right}px;"}),c.push({prefix:g,description:g+" - "+g+" top right,left bottom style",template:g+": ${top}px ${right_left}px ${bottom}px;"}),c.push({prefix:g,description:g+" - "+g+" top,bottom right,left style",template:g+": ${top_bottom}px ${right_left}px"});a=["border","border-top","border-bottom","border-left","border-right"];for(q=0;q<a.length;q++)g=a[q],c.push({prefix:g,description:g+" - "+g+" style",
|
|
template:g+": ${width:"+r(f)+"}px ${style:"+r(h)+"} ${color:"+r(d)+"};"});k.prototype=new p.TemplateContentAssist(t.keywords,c);k.prototype.getPrefix=function(a,c,d){for(d=c;d&&/[A-Za-z\-\@]/.test(a.charAt(d-1));)d--;return 0<=d?a.substring(d,c):""};return{CssContentAssistProvider:k}});
|
|
define("webtools/htmlContentAssist",["orion/editor/templates"],function(p){function t(){}var r=new p.Template("","Simple HTML document",'\x3c!DOCTYPE html\x3e\n\x3chtml lang\x3d"en"\x3e\n\t\x3chead\x3e\n\t\t\x3cmeta charset\x3dutf-8\x3e\n\t\t\x3ctitle\x3e${title}\x3c/title\x3e\n\t\x3c/head\x3e\n\t\x3cbody\x3e\n\t\t\x3ch1\x3e${header}\x3c/h1\x3e\n\t\t\x3cp\x3e\n\t\t\t${cursor}\n\t\t\x3c/p\x3e\n\t\x3c/body\x3e\n\x3c/html\x3e'),k=[{prefix:"\x3cimg",name:"\x3cimg\x3e",description:" - HTML image element",
|
|
template:'\x3cimg src\x3d"${URI}" alt\x3d"${Image}"/\x3e'},{prefix:"\x3ca",name:"\x3ca\x3e",description:" - HTML anchor element",template:'\x3ca href\x3d"${cursor}"\x3e\x3c/a\x3e'},{prefix:"\x3cul",name:"\x3cul\x3e",description:" - HTML unordered list",template:"\x3cul\x3e\n\t\x3cli\x3e${cursor}\x3c/li\x3e\n\x3c/ul\x3e"},{prefix:"\x3col",name:"\x3col\x3e",description:" - HTML ordered list",template:"\x3col\x3e\n\t\x3cli\x3e${cursor}\x3c/li\x3e\n\x3c/ol\x3e"},{prefix:"\x3cdl",name:"\x3cdl\x3e",description:" - HTML definition list",
|
|
template:"\x3cdl\x3e\n\t\x3cdt\x3e${cursor}\x3c/dt\x3e\n\t\x3cdd\x3e\x3c/dd\x3e\n\x3c/dl\x3e"},{prefix:"\x3ctable",name:"\x3ctable\x3e",description:" - basic HTML table",template:"\x3ctable\x3e\n\t\x3ctr\x3e\n\t\t\x3ctd\x3e${cursor}\x3c/td\x3e\n\t\x3c/tr\x3e\n\x3c/table\x3e"},{prefix:"\x3c!--",name:"\x3c!-- --\x3e",description:" - HTML comment",template:"\x3c!-- ${cursor} --\x3e"}],g,h,f,q,d="abbr b button canvas cite command dd del dfn dt em embed font h1 h2 h3 h4 h5 h6 i ins kbd label li mark meter object option output progress q rp rt samp small strong sub sup td time title tt u var".split(" ");
|
|
for(q=0;q<d.length;q++)g=d[q],f="\x3c"+g+"\x3e\x3c/"+g+"\x3e",h="\x3c"+g+"\x3e${cursor}\x3c/"+g+"\x3e",k.push({prefix:"\x3c"+g,description:f,template:h});d="address article aside audio bdo blockquote body caption code colgroup datalist details div fieldset figure footer form head header hgroup iframe legend map menu nav noframes noscript optgroup p pre ruby script section select span style tbody textarea tfoot th thead tr video".split(" ");for(q=0;q<d.length;q++)g=d[q],f="\x3c"+g+"\x3e\x3c/"+g+"\x3e",
|
|
h="\x3c"+g+"\x3e\n\t${cursor}\n\x3c/"+g+"\x3e",k.push({prefix:"\x3c"+g,description:f,template:h});d="area base br col hr input link meta param keygen source".split(" ");for(q=0;q<d.length;q++)g=d[q],h=f="\x3c"+g+"/\x3e",k.push({prefix:"\x3c"+g,description:f,template:h});t.prototype=new p.TemplateContentAssist([],k);t.prototype.getPrefix=function(c,a,b){b="";for(var d=a;d&&/[A-Za-z0-9<!-]/.test(c.charAt(d-1));)if(d--,"\x3c"===c.charAt(d)){b=c.substring(d,a);break}return b};t.prototype.computeProposals=
|
|
function(c,a,b){return 0===c.length?[r.getProposal("",a,b)]:p.TemplateContentAssist.prototype.computeProposals.call(this,c,a,b).sort(function(a,b){var c=a.prefix||a.proposal,d=b.prefix||b.proposal;if(c){if(!d)return 1}else return-1;return c.toLowerCase().localeCompare(d.toLowerCase())})};return{HTMLContentAssistProvider:t}});
|
|
define("orion/editor/AsyncStyler",["i18n!orion/editor/nls/messages","orion/editor/annotations"],function(p,t){function r(f){return-1!==f.getProperty("objectClass").indexOf(g)&&"highlighter"===f.getProperty("type")}function k(f,g,d){this.initialize(f,g,d);this.lineStyles=[]}var g="orion.edit.highlighter",h=g+" service must be an event emitter";t.AnnotationType.registerType("orion.annotation.highlightError",{title:p.syntaxError,html:"\x3cdiv class\x3d'annotationHTML error'\x3e\x3c/div\x3e",rangeStyle:{styleClass:"annotationRange error"}});
|
|
k.prototype={initialize:function(f,h,d){this.textView=f;this.serviceRegistry=h;this.annotationModel=d;this.services=[];var c=this;this.listener={onModelChanging:function(a){c.onModelChanging(a)},onModelChanged:function(a){c.onModelChanged(a)},onDestroy:function(a){c.onDestroy(a)},onLineStyle:function(a){c.onLineStyle(a)},onStyleReady:function(a){c.onStyleReady(a)},onServiceAdded:function(a){c.onServiceAdded(a.serviceReference,c.serviceRegistry.getService(a.serviceReference))},onServiceRemoved:function(a){c.onServiceRemoved(a.serviceReference,
|
|
c.serviceRegistry.getService(a.serviceReference))}};f.addEventListener("ModelChanging",this.listener.onModelChanging);f.addEventListener("ModelChanged",this.listener.onModelChanged);f.addEventListener("Destroy",this.listener.onDestroy);f.addEventListener("LineStyle",this.listener.onLineStyle);h.addEventListener("registered",this.listener.onServiceAdded);h.addEventListener("unregistering",this.listener.onServiceRemoved);f=h.getServiceReferences(g);for(d=0;d<f.length;d++){var a=f[d];r(a)&&this.addServiceListener(h.getService(a))}},
|
|
onDestroy:function(f){this.destroy()},destroy:function(){this.textView&&(this.textView.removeEventListener("ModelChanging",this.listener.onModelChanging),this.textView.removeEventListener("ModelChanged",this.listener.onModelChanged),this.textView.removeEventListener("Destroy",this.listener.onDestroy),this.textView.removeEventListener("LineStyle",this.listener.onLineStyle),this.textView=null);if(this.services){for(var f=0;f<this.services.length;f++)this.removeServiceListener(this.services[f]);this.services=
|
|
null}this.serviceRegistry&&(this.serviceRegistry.removeEventListener("registered",this.listener.onServiceAdded),this.serviceRegistry.removeEventListener("unregistering",this.listener.onServiceRemoved),this.serviceRegistry=null);this.lineStyles=this.listener=null},onModelChanging:function(f){this.startLine=this.textView.getModel().getLineAtOffset(f.start)},onModelChanged:function(f){var g=this.startLine;(f.addedLineCount||f.removedLineCount)&&Array.prototype.splice.apply(this.lineStyles,[g,f.removedLineCount].concat(this._getEmptyStyle(f.addedLineCount)))},
|
|
onStyleReady:function(f){var g=f.lineStyles||f.style;f=Number.MAX_VALUE;var d=-1,c=this.textView.getModel(),a;for(a in g)Object.prototype.hasOwnProperty.call(g,a)&&(this.lineStyles[a]=g[a],f=Math.min(f,a),d=Math.max(d,a));f=Math.max(f,0);d=Math.min(d,c.getLineCount());if(g=this.annotationModel){for(var b=g.getAnnotations(c.getLineStart(f),c.getLineEnd(d)),l=[];b.hasNext();){var h=b.next();"orion.annotation.highlightError"===h.type&&l.push(h)}b=[];for(h=f;h<=d;h++){a=h;var e=this.lineStyles[a],e=e&&
|
|
e.errors;a=c.getLineStart(a);if(e)for(var k=0;k<e.length;k++){var p=e[k];b.push(t.AnnotationType.createAnnotation("orion.annotation.highlightError",p.start+a,p.end+a))}}g.replaceAnnotations(l,b)}this.textView.redrawLines(f,d+1)},onLineStyle:function(f){var g=this.lineStyles[f.lineIndex];if(g)if(g.ranges){for(var g=g.ranges,d=f.lineStart,c=g.length,a=[],b=0;b<c;b++){var l=g[b];a.push({start:l.start+d,end:l.end+d,style:l.style})}f.ranges=a}else g.style&&(f.style=g.style)},_getEmptyStyle:function(f){for(var g=
|
|
[],d=0;d<f;d++)g.push(null);return g},setContentType:function(f){this.contentType=f;if(this.services)for(f=0;f<this.services.length;f++){var g=this.services[f];if(g.setContentType){var d=this.serviceRegistry.getService("orion.page.progress");d?d.progress(g.setContentType(this.contentType),"Styling content type: "+this.contentType.id?this.contentType.id:this.contentType):g.setContentType(this.contentType)}}},onServiceAdded:function(f,g){r(f)&&this.addServiceListener(g)},onServiceRemoved:function(f,
|
|
g){-1!==this.services.indexOf(g)&&this.removeServiceListener(g)},addServiceListener:function(f){if("function"===typeof f.addEventListener){if(f.addEventListener("orion.edit.highlighter.styleReady",this.listener.onStyleReady),this.services.push(f),f.setContentType&&this.contentType){var g=this.serviceRegistry.getService("orion.page.progress");g?g.progress(f.setContentType(this.contentType),"Styling content type: "+this.contentType.id?this.contentType.id:this.contentType):f.setContentType(this.contentType)}}else"undefined"!==
|
|
typeof console&&console.log(Error(h))},removeServiceListener:function(f){"function"===typeof f.removeEventListener?(f.removeEventListener("orion.edit.highlighter.styleReady",this.listener.onStyleReady),f=this.services.indexOf(f),-1!==f&&this.services.splice(f,1)):"undefined"!==typeof console&&console.log(Error(h))}};return k});
|
|
define("orion/editor/mirror",["i18n!orion/editor/nls/messages","orion/editor/eventTarget","orion/editor/annotations"],function(p,t,r){function k(c){this.string=c;this.tokenStart=this.pos=0}function g(c,a){return{token:function(a,c){return a.skipToEnd()}}}function h(c){this._modes={};this.mimeModes={};this.options={};this.StringStream=k;this.defineMode("null",g);this.defineMIME("text/plain","null")}function f(c){var a=[],b;for(b in c)Object.prototype.hasOwnProperty.call(c,b)&&a.push(b);return a}function q(c,
|
|
a,b){b=b||{};this.model=c;this.codeMirror=a;this.isWhitespaceVisible="undefined"===typeof b.whitespacesVisible?!1:b.whitespacesVisible;this.mode=null;this.isModeLoaded=!1;this.lines=[];this.dirtyLines=[];this.startLine=Number.MAX_VALUE;this.endLine=-1;this.timer=null;this.initialize(c)}function d(c,a,b){this.init(c,a,b)}k.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return 0===this.pos},peek:function(){return this.string[this.pos]},next:function(){return this.string[this.pos++]},
|
|
eat:function(c){var a=this.string[this.pos];return"string"===typeof a&&(a===c||c.test&&c.test(a)||"function"===typeof c&&c(a))?this.string[this.pos++]:void 0},eatWhile:function(c){for(var a=!1;void 0!==this.eat(c);)a=!0;return a},eatSpace:function(){return this.eatWhile(/\s/)},skipToEnd:function(){this.pos=this.string.length},skipTo:function(c){c=this.string.indexOf(c,this.pos);return-1!==c?(this.pos=c,!0):!1},match:function(c,a,b){a=!0===a||"undefined"===typeof a;if("string"===typeof c){var d=b?
|
|
this.string.toLowerCase():this.string;c=b?c.toLowerCase():c;b=d.indexOf(c,this.pos);-1!==b&&a&&(this.pos=b+c.length);return-1!==b}if((c=this.string.substring(this.pos).match(c))&&a&&"string"===typeof c[0])this.pos+=c.index+c[0].length;return c},backUp:function(c){this.pos-=c},column:function(){for(var c=0,a=0;a<this.tokenStart;)c+="\t"===this.string[a++]?4:1;return c},indentation:function(){for(var c=this.string.search(/\S/),a=0,b=0;b<c;)a+="\t"===this.string[b++]?4:1;return a},current:function(){return this.string.substring(this.tokenStart,
|
|
this.pos)},advance:function(){this.tokenStart=this.pos}};h.prototype={options:{},setOption:function(c,a){this.options[c]=a},getOption:function(c){return this.options[c]},copyState:function(c,a){if("function"===typeof c.copyState)return c.copyState(a);var b={},d;for(d in a){var f=a[d];b[d]=f instanceof Array?f.slice():f}return b},startState:function(c,a){return c.startState(a)},defineMode:function(c,a){this._modes[c]=a},defineMIME:function(c,a){this.mimeModes[c]=a},getMode:function(c,a){var b={},d;
|
|
"string"===typeof a&&this.mimeModes[a]&&(a=this.mimeModes[a]);"object"===typeof a&&(b=a,d=this._modes[a.name]);d=d||this._modes[a];return"function"!==typeof d?("undefined"!==typeof console&&console&&console.log("Mode not found: "+a),this.getMode(c,"null")):d(c,b)},listModes:function(){return f(this._modes)},listMIMEs:function(){return f(this.mimeModes)},_getModeName:function(c){c=this.mimeModes[c];"object"===typeof c&&(c=c.name);return c}};q.prototype={initialize:function(c){var a=this;this.listener=
|
|
{onModelChanging:function(b){a._onModelChanging(b)},onModelChanged:function(b){a._onModelChanged(b)},onDestroy:function(b){a._onDestroy(b)}};this.model.addEventListener("Changing",this.listener.onModelChanging);this.model.addEventListener("Changed",this.listener.onModelChanged);this.model.addEventListener("Destroy",this.listener.onDestroy)},destroy:function(){this.model&&(this.model.removeEventListener("Changing",this.listener.onModelChanging),this.model.removeEventListener("Changed",this.listener.onModelChanged),
|
|
this.model.removeEventListener("Destroy",this.listener.onDestroy));this.dirtyLines=this.lines=this.mode=this.codeMirror=this.model=null;clearTimeout(this.timer);this.timer=null},_onModelChanging:function(c){this.startLine=this.model.getLineAtOffset(c.start)},_onModelChanged:function(c){this._dbgEvent(c);var a=this.startLine;(c.removedLineCount||c.addedLineCount)&&Array.prototype.splice.apply(this.lines,[a+1,c.removedLineCount].concat(this._newLines(c.addedLineCount)));this.mode&&(c=Math.max(c.addedLineCount,
|
|
c.removedLineCount),c=a+Math.min(c,500),this.highlight(a,c),this.highlightLater(c+1))},_onDestroy:function(c){this.destroy()},setViewportIndex:function(c){this.viewportIndex=c},_dbgEvent:function(c){},_dbgStyle:function(){},_newLines:function(c,a){for(var b=[],d=0;d<c;d++)b.push({style:null,eolState:null});return b},setMode:function(c,a){c&&(this.mode=this.codeMirror.getMode(this.codeMirror.options,c),this.lines=this._newLines(this.model.getLineCount()),a&&this.highlight())},highlight:function(c,
|
|
a,b){if(this.mode){var d=this.model.getLineCount();c="undefined"===typeof c?0:c;a="undefined"===typeof a?d-1:Math.min(a,d-1);for(var d=this.mode,f=this.getState(c),e=c;e<=a;e++){var g=this.lines[e];this.highlightLine(e,g,f);g.eolState=this.codeMirror.copyState(d,f)}this._expandRange(c,a);if(!b)this.onHighlightDone()}},highlightLater:function(c){this.dirtyLines.push(c);var a=this;this.timer=setTimeout(function(){a._highlightJob()},50)},_highlightJob:function(){for(var c=+new Date+30,a=this.mode.compareStates,
|
|
b=this.model.getLineCount();this.dirtyLines.length;){var d=this.viewportIndex,f=this.lines[d],d=f&&!f.eolState?d:this.dirtyLines.pop();if(d>=b)break;this._expandRange(d,d);for(var f=this._getResumeLineIndex(d),d=f+1,f=(f=0<=f&&this.lines[f].eolState)?this.codeMirror.copyState(this.mode,f):this.mode.startState(),e=0,g=d;g<b;g++){var h=this.lines[g],k=h.eolState,q=this.highlightLine(g,h,f);h.eolState=this.codeMirror.copyState(this.mode,f);q&&this._expandRange(d,g+1);var h=a&&k&&a(k,h.eolState),p=!a&&
|
|
!q&&3<e++;if(h||p)break;else if(!k||q)e=0;k=g<b||this.dirtyLines.length;if(+new Date>c&&k){this.highlightLater(g+1);this.onHighlightDone();return}}}this.onHighlightDone()},onHighlightDone:function(){this.startLine!==Number.MAX_VALUE&&-1!==this.endLine&&this.dispatchEvent({type:"Highlight",start:this.startLine,end:this.endLine});this.startLine=Number.MAX_VALUE;this.endLine=-1},_getResumeLineIndex:function(c){for(var a=this.lines,b=c-1;0<=b;b--)if(a[b].eolState||40<c-b)return b;return-1},getState:function(c){var a=
|
|
this.mode,b=this.lines,d,f;for(d=c-1;0<=d&&!(f=b[d],f.eolState||40<c-d);d--);var e=0<=d&&b[d].eolState;if(e){e=this.codeMirror.copyState(a,e);for(d=Math.max(0,d);d<c-1;d++)f=b[d],this.highlightLine(d,f,e),f.eolState=this.codeMirror.copyState(a,e);return e}return a.startState()},highlightLine:function(c,a,b){if(this.mode){var d=this.model;d.getLineStart(c)===d.getLineEnd(c)&&this.mode.blankLine&&this.mode.blankLine(b);var f=a.style||[];c=d.getLine(c);c=new k(c);for(var d=!a.style,e=[],g=0;!c.eol();g++){var h=
|
|
this.mode.token(c,b)||null,q=c.current();this._whitespaceStyle(h,q,c.tokenStart);h=[c.tokenStart,c.pos,h];q=f[g];e.push(h);d=d||!q||q[0]!==h[0]||q[1]!==h[1]||q[2]!==h[2];c.advance()}if(d=d||e.length!==f.length)a.style=e.length?e:null;return d}},_whitespaceStyle:function(c,a,b){if(!c&&this.isWhitespaceVisible&&/\s+/.test(a)){c=[];for(var d,f,e=0;e<a.length;e++){var g=a[e];g!==f&&(f&&c.push([b+d,b+e,"\t"===f?"punctuation separator tab":"punctuation separator space"]),d=e,f=g)}c.push([b+d,b+e,"\t"===
|
|
f?"punctuation separator tab":"punctuation separator space"]);return c}return null},_expandRange:function(c,a){this.startLine=Math.min(this.startLine,c);this.endLine=Math.max(this.endLine,a)},toStyleRangesAndErrors:function(c,a){var b=c.style;if(!b)return null;for(var d=[],f=[],e="undefined"===typeof a?0:this.model.getLineStart(a),g=0;g<b.length;g++){var h=b[g],k;k=(k=h[2])?"punctuation separator tab"===k||"punctuation separator space"===k?k:"cm-"+k:null;k&&(h={start:e+h[0],end:e+h[1],style:{styleClass:k}},
|
|
d.push(h),"cm-error"===k&&f.push(h))}return[d,f]},getLineStyle:function(c){return this.lines[c]},getLineStyles:function(){return this.lines}};t.EventTarget.addMixin(q.prototype);r.AnnotationType.registerType("orion.annotation.highlightError",{title:p.syntaxError,html:"\x3cdiv class\x3d'annotationHTML error'\x3e\x3c/div\x3e",rangeStyle:{styleClass:"annotationRange error"}});d.prototype={init:function(c,a,b){this.textView=c;this.annotationModel=b;this.modeApplier=new q(c.getModel(),a);var d=this;this.listener=
|
|
{onLineStyle:function(a){d.onLineStyle(a)},onDestroy:function(a){d.onDestroy(a)},onHighlight:function(a){d.onHighlight(a)}};c.addEventListener("LineStyle",this.listener.onLineStyle);c.addEventListener("Destroy",this.listener.onDestroy);this.modeApplier.addEventListener("Highlight",this.listener.onHighlight)},destroy:function(){this.modeApplier&&(this.modeApplier.removeEventListener("Highlight",this.listener.onHighlight),this.modeApplier.destroy());this.textView&&(this.textView.removeEventListener("LineStyle",
|
|
this.listener.onLineStyle),this.textView.removeEventListener("Destroy",this.listener.onDestroy));this.listener=this.modeApplier=this.annotationModel=this.textView=null},setMode:function(c){this.modeApplier.setMode(c)},onLineStyle:function(c){var a=c.lineIndex,b=this.modeApplier,d=b.getLineStyle(a);if(!d||!d.eolState){var f=this.textView.getModel().getLineCount();b.highlight(a,Math.min(a+20,f-1),!0);d=b.getLineStyle(a)}f=this.textView.getModel();if(d){var e=b.toStyleRangesAndErrors(d,a);if(e&&(c.ranges=
|
|
e[0],c=this.annotationModel)){b=[];d=[];if(e=e[1])for(var g=0;g<e.length;g++){var h=e[g];"cm-error"===h.style.styleClass&&d.push(r.AnnotationType.createAnnotation("orion.annotation.highlightError",h.start,h.end))}for(a=c.getAnnotations(f.getLineStart(a),f.getLineEnd(a));a.hasNext();)f=a.next(),"orion.annotation.highlightError"===f.type&&b.push(f);c.replaceAnnotations(b,d)}}},onHighlight:function(c){this.textView.redrawLines(c.start,c.end)},onDestroy:function(c){this.destroy()}};return{Mirror:h,ModeApplier:q,
|
|
CodeMirrorStyler:d}});
|
|
define("orion/editor/textMateStyler",["orion/regex"],function(p){function t(g){var h;if(g instanceof Array){h=Array(g.length);for(var f=0;f<g.length;f++)h[f]=t(g[f])}else for(f in h={},g)if(Object.prototype.hasOwnProperty.call(g,f)){var k=g[f];h[f]="object"===typeof k&&null!==k?t(k):k}return h}function r(g,h,f){this.initialize(g);this.grammar=t(h);this.externalGrammars=f?t(f):[];this._styles={};this._tree=null;this._allGrammars={};this.preprocess(this.grammar)}var k={unsupported:[{regex:/\(\?[ims\-]:/,func:function(g){return"option on/off for subexp"}},
|
|
{regex:/\(\?<([=!])/,func:function(g){return"\x3d"===g[1]?"lookbehind":"negative lookbehind"}},{regex:/\(\?>/,func:function(g){return"atomic group"}}],toRegExp:function(g){function h(c,a){throw Error('Unsupported regex feature "'+c+'": "'+a[0]+'" at index: '+a.index+" in "+a.input);}var f="",q;g=k.processGlobalFlag("x",g,function(c){for(var a="",b=!1,d=c.length,f=0;f<d;){var e=c.charAt(f);if(!b&&"#"===e)for(;f<d&&"\r"!==e&&"\n"!==e;)e=c.charAt(++f);else if(!b&&/\s/.test(e))for(;f<d&&/\s/.test(e);)e=
|
|
c.charAt(++f);else"\\"===e?(a+=e,/\s/.test(c.charAt(f+1))||(a+=c.charAt(f+1),f+=1)):("["===e?b=!0:"]"===e&&(b=!1),a+=e),f+=1}return a});g=k.processGlobalFlag("i",g,function(c){f+="i";return c});for(q=0;q<this.unsupported.length;q++){var d;(d=this.unsupported[q].regex.exec(g))&&h(this.unsupported[q].func(d),d)}return RegExp(g,f)},processGlobalFlag:function(g,h,f){var k="(?"+g+")";g="(?"+g+":";if(h.substring(0,k.length)===k)return f(h.substring(k.length));if(h.substring(0,g.length)===g){for(var k=0,
|
|
d=h.length,c=-1,a=0;a<d&&-1===c;a++)switch(h.charAt(a)){case "\\":a++;break;case "(":k++;break;case ")":k--,0===k&&(c=a)}k=c;if(k<h.length-1)throw Error("Only a "+g+") group that encloses the entire regex is supported in: "+h);return f(h.substring(g.length,k))}return h},hasBackReference:function(g){return/\\\d+/.test(g.source)},getSubstitutedRegex:function(g,h,f){f="undefined"===typeof f?!0:!1;g=g.source.split(/(\\\d+)/g);for(var k=[],d=0;d<g.length;d++){var c=g[d],a=/\\(\d+)/.exec(c);a?(c=h[a[1]]||
|
|
"",k.push(f?p.escape(c):c)):k.push(c)}return RegExp(k.join(""))},groupify:function(g,h){for(var f=g.source,k=f.length,d=[],c=0,a=[],b=1,l=1,n=[],e={},p={},r=0;r<k;r++){var t=d[d.length-1],v=f.charAt(r);switch(v){case "(":4===t&&(d.pop(),n.push(")"),a[a.length-1].end=r);var y=r+2<k?f.charAt(r+1)+""+f.charAt(r+2):null;if("?:"===y||"?\x3d"===y||"?!"===y){var z;"?:"===y?z=1:(z=3,c++);d.push(z);a.push({start:r,end:-1,type:z});n.push(v);n.push(y);r+=y.length}else d.push(2),a.push({start:r,end:-1,type:2,
|
|
oldNum:b,num:l}),n.push(v),0===c&&(p[l]=null),e[b]=l,b++,l++;break;case ")":t=d.pop();3===t&&c--;a[a.length-1].end=r;n.push(v);break;case "*":case "+":case "?":case "}":var C=v,m=f.charAt(r-1),y=r-1;if("}"===v){for(z=r-1;"{"!==f.charAt(z)&&0<=z;z--);m=f.charAt(z-1);y=z-1;C=f.substring(z,r+1)}z=a[a.length-1];if(")"===m&&(2===z.type||4===z.type)){n.splice(z.start,0,"(");n.push(C);n.push(")");v={start:z.start,end:n.length-1,type:4,num:z.num};for(m=0;m<a.length;m++)if(t=a[m],(2===t.type||4===t.type)&&
|
|
t.start>=z.start&&t.end<=y)t.start+=1,t.end+=1,t.num+=1,2===t.type&&(e[t.oldNum]=t.num);a.push(v);l++;break}default:"|"!==v&&(2!==t&&4!==t)&&0===c&&(d.push(4),a.push({start:r,end:-1,type:4,num:l}),n.push("("),p[l]=null,l++),n.push(v),"\\"===v&&(v=f.charAt(r+1),n.push(v),r+=1)}}for(;d.length;)d.pop(),n.push(")");f=RegExp(n.join(""));k={};h=h||e;for(var w in h)h.hasOwnProperty(w)&&(k[w]="\\"+h[w]);f=this.getSubstitutedRegex(f,k,!1);return[f,e,p]},complexCaptures:function(g){if(!g)return!1;for(var h in g)if(g.hasOwnProperty(h)&&
|
|
"0"!==h)return!0;return!1}};r.prototype={initialize:function(g){this.textView=g;this.textView.stylerOptions=this;var h=this;this._listener={onModelChanged:function(f){h.onModelChanged(f)},onDestroy:function(f){h.onDestroy(f)},onLineStyle:function(f){h.onLineStyle(f)},onStorage:function(f){h.onStorage(f)}};g.addEventListener("ModelChanged",this._listener.onModelChanged);g.addEventListener("Destroy",this._listener.onDestroy);g.addEventListener("LineStyle",this._listener.onLineStyle);g.redrawLines()},
|
|
onDestroy:function(g){this.destroy()},destroy:function(){this.textView&&(this.textView.removeEventListener("ModelChanged",this._listener.onModelChanged),this.textView.removeEventListener("Destroy",this._listener.onDestroy),this.textView.removeEventListener("LineStyle",this._listener.onLineStyle),this.textView=null);this._listener=this._tree=this._styles=this.grammar=null},preprocess:function(g){for(g=[g];0!==g.length;){var h=g.pop();if(!h._resolvedRule||!h._typedRule)if(h._resolvedRule=this._resolve(h),
|
|
h._typedRule=this._createTypedRule(h),this.addStyles(h.name),this.addStyles(h.contentName),this.addStylesForCaptures(h.captures),this.addStylesForCaptures(h.beginCaptures),this.addStylesForCaptures(h.endCaptures),h._resolvedRule!==h&&g.push(h._resolvedRule),h.patterns)for(var f=0;f<h.patterns.length;f++)g.push(h.patterns[f])}},addStyles:function(g){if(g&&!this._styles[g]){this._styles[g]=[];for(var h=g.split("."),f=0;f<h.length;f++)this._styles[g].push(h.slice(0,f+1).join("-"))}},addStylesForCaptures:function(g){for(var h in g)g.hasOwnProperty(h)&&
|
|
this.addStyles(g[h].name)},ContainerRule:function(){function g(g){this.rule=g;this.subrules=g.patterns}g.prototype.valueOf=function(){return"aa"};return g}(),BeginEndRule:function(){function g(g){this.rule=g;this.beginRegex=k.toRegExp(g.begin);this.endRegex=k.toRegExp(g.end);this.subrules=g.patterns||[];this.endRegexHasBackRef=k.hasBackReference(this.endRegex);var f=k.complexCaptures(g.captures);g=k.complexCaptures(g.beginCaptures)||k.complexCaptures(g.endCaptures);if(this.isComplex=f||g)f=k.groupify(this.beginRegex),
|
|
this.beginRegex=f[0],this.beginOld2New=f[1],this.beginConsuming=f[2],f=k.groupify(this.endRegex,this.beginOld2New),this.endRegex=f[0],this.endOld2New=f[1],this.endConsuming=f[2]}g.prototype.valueOf=function(){return this.beginRegex};return g}(),MatchRule:function(){function g(g){this.rule=g;this.matchRegex=k.toRegExp(g.match);if(this.isComplex=k.complexCaptures(g.captures))g=k.groupify(this.matchRegex),this.matchRegex=g[0],this.matchOld2New=g[1],this.matchConsuming=g[2]}g.prototype.valueOf=function(){return this.matchRegex};
|
|
return g}(),_createTypedRule:function(g){return g.match?new this.MatchRule(g):g.begin?new this.BeginEndRule(g):new this.ContainerRule(g)},_resolve:function(g){var h=g;if(g.include){if(g.begin||g.end||g.match)throw Error('Unexpected regex pattern in "include" rule '+g.include);g=g.include;if("#"===g.charAt(0)){if(h=this.grammar.repository&&this.grammar.repository[g.substring(1)],!h)throw Error("Couldn't find included rule "+g+" in grammar repository");}else if("$self"===g)h=this.grammar;else{if("$base"===
|
|
g)throw Error('Include "$base" is not supported');h=this._allGrammars[g];if(!h)for(var f=0;f<this.externalGrammars.length;f++){var k=this.externalGrammars[f];if(k.scopeName===g){this.preprocess(k);h=this._allGrammars[g]=k;break}}}}return h},ContainerNode:function(){function g(g,f){this.parent=g;this.rule=f;this.children=[];this.end=this.start=null}g.prototype.addChild=function(g){this.children.push(g)};g.prototype.valueOf=function(){var g=this.rule;return"ContainerNode { "+(g.include||"")+" "+(g.name||
|
|
"")+(g.comment||"")+"}"};return g}(),BeginEndNode:function(){function g(g,f,q){this.parent=g;this.rule=f;this.children=[];this.setStart(q);this.endMatch=this.end=null;this.endRegexSubstituted=f.endRegexHasBackRef?k.getSubstitutedRegex(f.endRegex,q):null}g.prototype.addChild=function(g){this.children.push(g)};g.prototype.getIndexInParent=function(g){return this.parent?this.parent.children.indexOf(this):-1};g.prototype.setStart=function(g){this.start=g.index;this.beginMatch=g};g.prototype.setEnd=function(g){g&&
|
|
"object"===typeof g?(this.endMatch=g,this.end=g.index+g[0].length):(this.endMatch=null,this.end=g)};g.prototype.shiftStart=function(g){this.start+=g;this.beginMatch.index+=g};g.prototype.shiftEnd=function(g){this.end+=g;this.endMatch&&(this.endMatch.index+=g)};g.prototype.valueOf=function(){return"{"+this.rule.beginRegex+" range\x3d"+this.start+".."+this.end+"}"};return g}(),push:function(g,h){if(h)for(var f=h.length;0<f;)g.push(h[--f])},exec:function(g,h,f){if(h=g.exec(h))h.index+=f;g.lastIndex=
|
|
0;return h},afterMatch:function(g){return g.index+g[0].length},getEndMatch:function(g,h,f){if(g instanceof this.BeginEndNode){var k=g.rule;g=g.endRegexSubstituted||k.endRegex;return!g?null:this.exec(g,h,f)}return null},initialParse:function(){this.textView.getModel().getCharCount();this._tree=new this.ContainerNode(null,this.grammar._typedRule);this.parse(this._tree,!1,0)},onModelChanged:function(g){var h=g.addedCharCount,f=g.removedCharCount;g=g.start;if(this._tree){var k=this.textView.getModel(),
|
|
d=k.getCharCount(),k=k.getLineEnd(k.getLineAtOffset(g)-1),c=this.getFirstDamaged(k,k),k=-1===k?0:k,h=c?this.parse(c,!0,k,g,h,f):d;this.textView.redrawRange(k,h)}else this.initialParse()},getFirstDamaged:function(g,h){if(0>g)return this._tree;for(var f=[this._tree],k=null;f.length;){var d=f.pop();if(!d.parent||this.isDamaged(d,g,h)){d instanceof this.BeginEndNode&&(k=d);for(var c=0;c<d.children.length;c++)f.push(d.children[c])}}return k||this._tree},isDamaged:function(g,h,f){return g.start<=f&&g.end>
|
|
h},parse:function(g,h,f,k,d,c){var a=this.textView.getModel(),b=a.getLineStart(a.getLineCount()-1),l=a.getCharCount(),n=this.getInitialExpected(g,f),e=-1;h&&(g.repaired=!0,g.endNeedsUpdate=!0,e=(e=g.children[g.children.length-1])?a.getLineEnd(a.getLineAtOffset(e.end+(d-c))):-1,k=a.getLineEnd(a.getLineAtOffset(k+c)),e=Math.max(e,k));e=-1===e?l:e;k=n;for(var p=g,r=!1,t=f,v=-1;p&&(!h||t<e);){var y=this.getNextMatch(a,p,t);y||(t=t>=b?l:a.getLineStart(a.getLineAtOffset(t)+1));var z=y&&y.match,C=y&&y.rule,
|
|
m=y&&y.isEnd;if(y&&y.isSub)t=this.afterMatch(z),C instanceof this.BeginEndRule&&(r=!0,h&&C===k.rule&&p===k.parent?(p=k,p.setStart(z),p.repaired=!0,p.endNeedsUpdate=!0,k=this.getNextExpected(k,"begin")):(h&&(this.prune(p,k),h=!1),z=new this.BeginEndNode(p,C,z),p.addChild(z),p=z));else if(m||t===l)p instanceof this.BeginEndNode&&(z?(r=!0,v=Math.max(v,p.end),p.setEnd(z),t=this.afterMatch(z),h&&p===k&&p.parent===k.parent?(p.repaired=!0,delete p.endNeedsUpdate,k=this.getNextExpected(k,"end")):h&&(this.prune(p,
|
|
k),h=!1)):(p.setEnd(l),delete p.endNeedsUpdate)),p=p.parent;h&&(t>=e&&!r)&&(this.prune(g,n),h=!1)}this.removeUnrepairedChildren(g,h,f);this.cleanup(h,g,f,e,l,d,c);return h?Math.max(v,t):t},removeUnrepairedChildren:function(g,h,f){if(h){h=g.children;for(var k=-1,d=0;d<h.length;d++){var c=h[d];if(!c.repaired&&this.isDamaged(c,f,Number.MAX_VALUE)){k=d;break}}-1!==k&&(g.children.length=k)}},cleanup:function(g,h,f,k,d,c,a){if(g){g=c-a;d=this.getIntersecting(k-g+1,d);h=this.getIntersecting(f,k);for(f=0;f<
|
|
d.length;f++)k=d[f],!k.repaired&&k instanceof this.BeginEndNode&&(k.shiftEnd(g),k.shiftStart(g));for(f=0;f<h.length;f++)k=h[f],k.repaired&&k.endNeedsUpdate&&k.shiftEnd(g),delete k.endNeedsUpdate,delete k.repaired}else{h=this.getIntersecting(f,k);for(f=0;f<h.length;f++)delete h[f].repaired}},getNextMatch:function(g,h,f,k){var d=g.getLineAtOffset(f),d=g.getLineEnd(d),c=g.getText(f,d),a=[],b=[];g=[];d=[];for(this.push(a,h.rule.subrules);a.length;){var l=a.length?a.pop():null,l=l&&l._resolvedRule._typedRule;
|
|
if(l instanceof this.ContainerRule&&-1===b.indexOf(l))b.push(l),this.push(a,l.subrules);else if(!l||!k||l.matchRegex){var n=l&&this.exec(l.matchRegex||l.beginRegex,c,f);n&&(g.push(n),d.push(l))}}a=Number.MAX_VALUE;b=-1;for(l=0;l<g.length;l++)n=g[l],n.index<a&&(a=n.index,b=l);if(!k&&(f=this.getEndMatch(h,c,f)))if(k=h.rule.applyEndPatternLast,-1===b||f.index<a||!k&&f.index===a)return{isEnd:!0,rule:h.rule,match:f};return-1===b?null:{isSub:!0,rule:d[b],match:g[b]}},getInitialExpected:function(g,h){var f,
|
|
k;if(g===this._tree)for(f=0;f<g.children.length;f++){if(k=g.children[f],k.start>=h)return k}else if(g instanceof this.BeginEndNode&&g.endMatch){var d=g.endMatch.index;for(f=0;f<g.children.length&&!(k=g.children[f],k.start>=h);f++);if(k&&k.start<d)return k}return g},getNextExpected:function(g,h){if("begin"===h){var f=g.children[0];return f?f:g}if("end"===h&&(f=g.parent)){var k=f.children[f.children.indexOf(g)+1];return k?k:f}return null},prune:function(g,h){h.parent===g?g.children.length=h.getIndexInParent():
|
|
g instanceof this.BeginEndNode&&(g.endMatch=null,g.end=null);g.parent&&(g.parent.children.length=g.getIndexInParent()+1)},onLineStyle:function(g){this._tree||this.initialParse();var h=g.lineStart,f=this.textView.getModel(),k=f.getLineEnd(g.lineIndex),d=f.getLineEnd(f.getLineAtOffset(h)-1),d=this.getFirstDamaged(d,d),h=this.getLineScope(f,d,h,k);g.ranges=this.toStyleRanges(h);g.ranges.sort(function(c,a){return c.start-a.start})},getLineScope:function(g,h,f,k){for(var d=f,c=this.getInitialExpected(h,
|
|
f),a=[],b=[];h&&d<k;){var l=this.getNextMatch(g,h,d);if(!l)break;var n=l&&l.match,e=l&&l.rule,p=l&&l.isSub,l=l&&l.isEnd;n.index!==d&&b.push({start:d,end:n.index,node:h});p?(d=this.afterMatch(n),e instanceof this.BeginEndRule?(this.addBeginScope(a,n,e),h=c,c=this.getNextExpected(c,"begin")):this.addMatchScope(a,n,e)):l&&(d=this.afterMatch(n),this.addEndScope(a,n,e),c=this.getNextExpected(c,"end"),h=h.parent)}d<k&&b.push({start:d,end:k,node:h});g=this.getInheritedLineScope(b,f,k);return a.concat(g)},
|
|
getInheritedLineScope:function(g,h,f){h=[];for(f=0;f<g.length;f++)for(var k=g[f],d=k.node;d;){var c=d.rule.rule,a=c.name;if(c=c.contentName||a){this.addScopeRange(h,k.start,k.end,c);break}d=d.parent}return h},addBeginScope:function(g,h,f){var k=f.rule;this.addCapturesScope(g,h,k.beginCaptures||k.captures,f.isComplex,f.beginOld2New,f.beginConsuming)},addEndScope:function(g,h,f){var k=f.rule;this.addCapturesScope(g,h,k.endCaptures||k.captures,f.isComplex,f.endOld2New,f.endConsuming)},addMatchScope:function(g,
|
|
h,f){var k=f.rule,d=k.name;(k=k.captures)?this.addCapturesScope(g,h,k,f.isComplex,f.matchOld2New,f.matchConsuming):this.addScope(g,h,d)},addScope:function(g,h,f){f&&g.push({start:h.index,end:this.afterMatch(h),scope:f})},addScopeRange:function(g,h,f,k){k&&g.push({start:h,end:f,scope:k})},addCapturesScope:function(g,h,f,k,d,c){if(f)if(k){k={1:0};for(var a=0,b=1;void 0!==h[b];b++)void 0!==c[b]&&(a+=h[b].length),void 0!==h[b+1]&&(k[b+1]=a);c=h.index;for(a=1;f[a];a++){var b=f[a].name,l=d[a],n=c+k[l];
|
|
"undefined"!==typeof h[l]&&this.addScopeRange(g,n,n+h[l].length,b)}}else this.addScope(g,h,f[0]&&f[0].name)},getIntersecting:function(g,h){for(var f=[],k=this._tree?[this._tree]:[];k.length;){var d=k.pop(),c=!1;d instanceof this.ContainerNode?c=!0:this.isDamaged(d,g,h)&&(c=!0,f.push(d));if(c)for(var c=d.children.length,a=0;a<c;a++)k.push(d.children[a])}return f.reverse()},toStyleRanges:function(g){for(var h=[],f=0;f<g.length;f++){var k=g[f],d=this._styles[k.scope];if(!d)throw Error("styles not found for "+
|
|
k.scope);d=d.join(" ");h.push({start:k.start,end:k.end,style:{styleClass:d}})}return h}};return{RegexUtil:k,TextMateStyler:r}});
|
|
define("orion/editor/htmlGrammar",[],function(){return{HtmlGrammar:function(){return{scopeName:"source.html",uuid:"3B5C76FB-EBB5-D930-F40C-047D082CE99B",patterns:[{begin:"\x3c!(doctype|DOCTYPE)",end:"\x3e",contentName:"entity.name.tag.doctype.html",beginCaptures:{0:{name:"entity.name.tag.doctype.html"}},endCaptures:{0:{name:"entity.name.tag.doctype.html"}}},{begin:"\x3c!--",end:"--\x3e",beginCaptures:{0:{name:"punctuation.definition.comment.html"}},endCaptures:{0:{name:"punctuation.definition.comment.html"}},
|
|
patterns:[{match:"--",name:"invalid.illegal.badcomment.html"}],contentName:"comment.block.html"},{match:"\x3c[A-Za-z0-9_\\-:]+(?\x3d ?)",name:"entity.name.tag.html"},{include:"#attrName"},{include:"#qString"},{include:"#qqString"},{include:"#entity"},{match:"\x3c/[A-Za-z0-9_\\-:]+\x3e",name:"entity.name.tag.html"},{match:"\x3e",name:"entity.name.tag.html"}],repository:{attrName:{match:"[A-Za-z\\-:]+(?\x3d\\s*\x3d\\s*['\"])",name:"entity.other.attribute.name.html"},qqString:{match:'(")[^"]+(")',name:"string.quoted.double.html"},
|
|
qString:{match:"(')[^']+(')",name:"string.quoted.single.html"},entity:{match:"\x26[A-Za-z0-9]+;",name:"constant.character.entity.html"}}}}}});
|
|
define("orion/editor/textStyler",["orion/editor/annotations","orion/editor/eventTarget"],function(p,t){function r(d,c){this._patternManager=new k(d,c)}function k(d,c){this._unnamedCounter=0;this._patterns=[];this._rootId=c;d.forEach(function(a){this._addRepositoryPatterns(a.repository||{},a.id);this._addPatterns(a.patterns||[],a.id)}.bind(this))}function g(d,c,a,b,f,g,e){this.start=d.start;this.end=d.end;this.contentStart=d.contentStart;this.contentEnd=d.contentEnd;this.name=c;this.typeId=a;this.styler=
|
|
b;this.parent=g;e&&e(this);this._subBlocks=b.computeBlocks(f,f.getText(this.contentStart,this.end),this,this.contentStart,null,null,null)}function h(d){this._styler=d}function f(d,c,a){this._highlightCaretLine=this._whitespacesVisible=!1;this._detectTasks=this._foldingEnabled=!0;this._view=d;this._annotationModel=c;this._stylerAdapter=a;this._stylerAdapter.setStyler(this);this._accessor=new h(this);this._bracketAnnotations;var b=this;this._listener={onChanged:function(a){b._onModelChanged(a)},onDestroy:function(a){b._onDestroy(a)},
|
|
onLineStyle:function(a){b._onLineStyle(a)},onMouseDown:function(a){b._onMouseDown(a)},onSelection:function(a){b._onSelection(a)}};a=d.getModel();a.getBaseModel&&(a=a.getBaseModel());a.addEventListener("Changed",this._listener.onChanged);d.addEventListener("MouseDown",this._listener.onMouseDown);d.addEventListener("Selection",this._listener.onSelection);d.addEventListener("Destroy",this._listener.onDestroy);d.addEventListener("LineStyle",this._listener.onLineStyle);var f=a.getCharCount();this._rootBlock=
|
|
this._stylerAdapter.createBlock({start:0,contentStart:0,end:f,contentEnd:f},this,a,null);c&&(f=[],c.removeAnnotations(p.AnnotationType.ANNOTATION_FOLDING),this._computeFolding(this._rootBlock.getBlocks(),d.getModel(),f),this._detectTasks&&(c.removeAnnotations(p.AnnotationType.ANNOTATION_TASK),this._computeTasks(this._rootBlock,a,f)),c.replaceAnnotations([],f));d.redrawLines()}var q=function(d,c,a,b,f){var g;void 0===b&&(b=-1);void 0===f&&(f=d.length);for(;1<f-b;)if(g=Math.floor((f+b)/2),c<=d[g].start)f=
|
|
g;else if(a&&c<d[g].end){f=g;break}else b=g;return f};r.prototype={blockSpansBeyondEnd:function(d){return d.pattern.regexEnd===this._eolRegex},computeBlocks:function(d,c,a,b,f,g,e){if(!c)return[];var h=[],k=[];f=f||0;g=g||Infinity;e=e||Infinity;a.blockPatterns.forEach(function(a){var b=this._findMatch(a.regexBegin||a.regex,c,f);b&&k.push({result:b,pattern:a})}.bind(this));if(!k.length)return h;k.sort(function(a,b){return a.result.index<b.result.index?-1:a.result.index>b.result.index?1:a.pattern.pattern.index<
|
|
b.pattern.pattern.index?-1:1});for(var p=0;0<k.length;){var q=k[0];k.splice(0,1);if(g<q.result.index)break;if(!(q.result.index<p)){var p=b+q.result.index,r=q.result.index,t=null,C=q.pattern.regexEnd;if(C){var r=r+q.result[0].length,m=q.pattern,w=this._substituteCaptureValues(C,q.result);w!==C&&(m={pattern:m.pattern,regexBegin:m.regexBegin,regexEnd:w},C=w);for(w=r;!t;){w=this._findMatch(C,c,w);w||(this._eolRegex.lastIndex=0,w=this._eolRegex.exec(c),m={pattern:m.pattern,regexBegin:m.regexBegin,regexEnd:this._eolRegex});
|
|
var B=this.createBlock({start:p,end:b+w.index+w[0].length,contentStart:b+r,contentEnd:b+w.index},a.styler,d,a,m),A=B.getBlocks();if(!A.length||A[A.length-1].end<=w.index+b)t=B;w=w.index+w[0].length}}else t=this.createBlock({start:p,end:p+q.result[0].length,contentStart:p,contentEnd:p+q.result[0].length},a.styler,d,a,q.pattern);h.push(t);if(h.length===e||g<=t.end)break;p=t.end-b}this._updateMatch(q,c,k,p,g)}return h},computeStyle:function(d,c,a){if(!d.pattern)return null;var b={start:d.start,end:d.end,
|
|
style:d.pattern.pattern.name};if(d.contentStart<=a&&a<d.contentEnd)return d.pattern.pattern.contentName?{start:d.contentStart,end:d.contentEnd,style:d.pattern.pattern.contentName}:b;var f,g;if(a<d.contentStart){g=d.pattern.pattern.beginCaptures||d.pattern.pattern.captures;if(!g)return b;f=d.pattern.regexBegin;c=c.getText(d.start,d.contentStart);d=d.start}else{g=d.pattern.pattern.endCaptures||d.pattern.pattern.captures;if(!g)return b;f=d.pattern.regexEnd;c=c.getText(d.contentEnd,d.end);d=d.contentEnd}f.lastIndex=
|
|
0;if(f=f.exec(c))if(c=[],this._getCaptureStyles(f,g,d,c),(g=c[q(c,a,!0)])&&g.start<=a&&a<g.end)return g;return b},createBlock:function(d,c,a,b,f){return new g(d,f?f.pattern.name:null,f?f.pattern.id:null,c,a,b,function(a){a.pattern=f;a.linePatterns=[];a.blockPatterns=[];a.enclosurePatterns={};this._initPatterns(this._patternManager,a)}.bind(this))},getBlockContentStyleName:function(d){return d.pattern.pattern.contentName||d.pattern.pattern.name},getBlockEndStyle:function(d,c,a,b){var f;if(d.pattern.regexEnd&&
|
|
(f=this._findMatch(d.pattern.regexEnd,c,0)))(c=d.pattern.pattern.endCaptures||d.pattern.pattern.captures)?this._getCaptureStyles(f,c,a-f[0].length,b):d.pattern.pattern.name&&b.push({start:a-f[0].length,end:a,style:d.pattern.pattern.name});return f?f[0]:null},getBlockStartStyle:function(d,c,a,b){var f;if(d.pattern.regexBegin&&(f=this._findMatch(d.pattern.regexBegin,c,0)))(c=d.pattern.pattern.beginCaptures||d.pattern.pattern.captures)?this._getCaptureStyles(f,c,a,b):b.push({start:a,end:a+f[0].length,
|
|
style:d.pattern.pattern.name});return f?f[0]:null},getBracketMatch:function(d,c){for(var a,b=Object.keys(d.enclosurePatterns),f=0;f<b.length;f++){var g=d.enclosurePatterns[b[f]],e=this._findMatch(g.regex,c,0);if(e&&0===e.index){a=g;break}}if(!a)return null;f=!1;-1!==a.pattern.name.indexOf(this._PUNCTUATION_SECTION_BEGIN)?(f=!0,b=a.pattern.name.replace(this._PUNCTUATION_SECTION_BEGIN,this._PUNCTUATION_SECTION_END)):b=a.pattern.name.replace(this._PUNCTUATION_SECTION_END,this._PUNCTUATION_SECTION_BEGIN);
|
|
return!d.enclosurePatterns[b]?null:{beginName:a.pattern.name,endName:b,atStart:f}},parse:function(d,c,a,b,f){if(d&&(a=a.linePatterns)){var g=[];a.forEach(function(a){var b=a.regex||a.regexBegin;b.oldLastIndex=b.lastIndex;(b=this._findMatch(b,d,0))&&g.push({result:b,pattern:a})}.bind(this));g.sort(function(a,b){return a.result.index<b.result.index?-1:a.result.index>b.result.index?1:a.pattern.pattern.index<b.pattern.pattern.index?-1:1});for(var e=0;0<g.length;){var h=g[0];g.splice(0,1);if(!(h.result.index<
|
|
e)){var k=h.result.index,p,q=[];if(h.pattern.regex){e=h.result;p=k+e[0].length;p={start:c+k,end:c+p,style:h.pattern.pattern.name};if(!f){h.pattern.pattern.captures&&this._getCaptureStyles(e,h.pattern.pattern.captures,c+k,q);q.sort(function(a,b){return a.start<b.start?-1:a.start>b.start?1:0});for(k=0;k<q.length-1;k++)if(q[k+1].start<q[k].end){var r={start:q[k+1].end,end:q[k].end,style:q[k].style};q[k].end=q[k+1].start;q.splice(k+2,0,r)}}this._mergeStyles(p,q,b)}else e=h.pattern.regexEnd,e=this._substituteCaptureValues(e,
|
|
h.result),e=this._findMatch(e,d,h.result.index+h.result[0].length),e||(this._eolRegex.lastIndex=0,e=this._eolRegex.exec(d)),p=e.index+e[0].length,b.push({start:c+k,end:c+p,style:h.pattern.pattern.name});e=e.index+e[0].length}this._updateMatch(h,d,g,e)}a.forEach(function(a){a=a.regex||a.regexBegin;a.lastIndex=a.oldLastIndex})}},setStyler:function(){},verifyBlock:function(d,c,a,b){var f=null,g=[];a.parent.blockPatterns.forEach(function(a){var b=this._findMatch(a.regexBegin||a.regex,c,0);b&&g.push({result:b,
|
|
pattern:a})}.bind(this));g.sort(function(a,b){return!a.result.index&&b.result.index?-1:a.result.index&&!b.result.index?1:!a.result.index&&!b.result.index?a.pattern.pattern.index<b.pattern.pattern.index?-1:1:0});if(!g.length||0!==g[0].result.index||g[0].pattern.pattern.id!==a.pattern.pattern.id)f=!1;else{var e=g[0],h=e.pattern.regexEnd;if(h){for(var h=this._substituteCaptureValues(h,e.result),e=e.result[0].length,k=this._findMatch(h,c,e);null===f&&k&&a.start+k.index!==a.contentEnd+b;){var p=this.computeBlocks(d,
|
|
c,a,a.start,e,k.index+1,null);!p.length||p[p.length-1].end<=a.start+k.index?f=!1:p.length?(e=p[p.length-1].end-a.start,k=this._findMatch(h,c,e)):k=null}k||(this._eolRegex.lastIndex=0,k=this._eolRegex.exec(c),f=a.start+k.index===a.end+b)}else f=a.start+e.result[0].length===a.end+b}return null!==f?f:!0},_findMatch:function(d,c,a,b){var f=a,g=d.lastIndex;this._linebreakRegex.lastIndex=a;a=this._linebreakRegex.exec(c);var e,h;d.lastIndex=0;if(a){for(h=a.index;0<=--h&&!(e=c.charAt(h),e===this._NEWLINE||
|
|
e===this._CR););e=c.substring(h+1,a.index+a[1].length);d.lastIndex=h=a.index-h-1}for(;a&&a.index<c.length;){var k;if(b){var p=d.lastIndex;d.test(e)&&(d.lastIndex=p,k=d.exec(e))}else k=d.exec(e);if(k)return k.index+=f,k.index-=h,d.lastIndex=g,k;h=0;f+=a[0].length;if(a=this._linebreakRegex.exec(c))e=a[1],d.lastIndex=0}d.lastIndex=g;return null},_getCaptureStyles:function(d,c,a,b){if(c[0])b.push({start:a,end:a+d[0].length,style:c[0].name});else for(var f=0,g=1;g<d.length;g++)if(d[g]){var e=c[g];if(e){var h=
|
|
a+f;b.push({start:h,end:h+d[g].length,style:e.name})}f+=d[g].length}},_initPatterns:function(d,c){if(c.pattern&&c.pattern.pattern.linePatterns)c.linePatterns=c.pattern.pattern.linePatterns,c.blockPatterns=c.pattern.pattern.blockPatterns,c.enclosurePatterns=c.pattern.pattern.enclosurePatterns;else{var a=d.getPatterns(c.pattern?c.pattern.pattern:null),b=function(a){a="string"===typeof a?a:a.match;var b=this._ignoreCaseRegex.exec(a),c=this._FLAGS;b&&(a=a.substring(b[0].length),c+="i");return RegExp(a,
|
|
c)}.bind(this),f=-1,g=0;a.forEach(function(a){var d;if(a.match&&!a.begin&&!a.end){if(d={regex:b(a.match),pattern:a},c.linePatterns.push(d),a.name&&0===a.name.indexOf("punctuation.section")&&(-1!==a.name.indexOf(this._PUNCTUATION_SECTION_BEGIN)||-1!==a.name.indexOf(this._PUNCTUATION_SECTION_END)))c.enclosurePatterns[a.name]=d}else!a.match&&(a.begin&&a.end)&&(f=g,d={regexBegin:b(a.begin),regexEnd:b(a.end),pattern:a},c.linePatterns.push(d));g++}.bind(this));c.blockPatterns=c.linePatterns.slice(0,f+1);
|
|
c.pattern&&(c.pattern.pattern.enclosurePatterns=c.enclosurePatterns,c.pattern.pattern.linePatterns=c.linePatterns,c.pattern.pattern.blockPatterns=c.blockPatterns)}},_mergeStyles:function(d,c,a){var b=d.start;c.forEach(function(c){b<=c.start&&a.push({start:b,end:c.start,style:d.style});a.push(c);b=c.end});b<d.end&&a.push({start:b,end:d.end,style:d.style})},_substituteCaptureValues:function(d,c){var a=d.toString();this._captureReferenceRegex.lastIndex=0;if(!this._captureReferenceRegex.test(a))return d;
|
|
this._captureReferenceRegex.lastIndex=0;for(var b=this._captureReferenceRegex.exec(a);b;)a=a.replace(b[0],c[b[1]]||""),this._captureReferenceRegex.lastIndex=0,b=this._captureReferenceRegex.exec(a);return RegExp(a.substring(1,a.length-1-this._FLAGS.length),this._FLAGS)},_updateMatch:function(d,c,a,b,f){var g=d.pattern.regex?d.pattern.regex:d.pattern.regexBegin;f=f||Infinity;if((c=this._findMatch(g,c,b,!0))&&c.index<f){d.result=c;for(f=0;f<a.length;f++)if(c.index<a[f].result.index||c.index===a[f].result.index&&
|
|
d.pattern.pattern.index<a[f].pattern.pattern.index){a.splice(f,0,d);return}a.push(d)}},_captureReferenceRegex:/\\(\d)/g,_eolRegex:/$/,_ignoreCaseRegex:/^\(\?i\)\s*/,_linebreakRegex:/(.*)(?:[\r\n]|$)/g,_CR:"\r",_FLAGS:"g",_NEWLINE:"\n",_PUNCTUATION_SECTION_BEGIN:".begin",_PUNCTUATION_SECTION_END:".end"};k.prototype={getPatterns:function(d){d?(d="string"===typeof d?d:d.qualifiedId,d+="#"):d=this._rootId+"#"+this._NO_ID;var c=[0],a={},b=RegExp("^"+d+"[^#]+$");this._patterns.forEach(function(d){b.test(d.qualifiedId)&&
|
|
(d.include?this._processInclude(d,c,a):(d.index=c[0]++,a[d.id]=d))}.bind(this));var f=[];Object.keys(a).forEach(function(b){f.push(a[b])});return f},_addPattern:function(d,c,a){d.parentId=a;d.id=c;d.qualifiedId=d.parentId+"#"+d.id;this._patterns.push(d);d.patterns&&!d.include&&this._addPatterns(d.patterns,d.qualifiedId)},_addPatterns:function(d,c){d.forEach(function(a){this._addPattern(a,this._NO_ID+this._unnamedCounter++,c)}.bind(this))},_addRepositoryPatterns:function(d,c){Object.keys(d).forEach(function(a){this._addPattern(d[a],
|
|
a,c)}.bind(this))},_processInclude:function(d,c,a){var b,f=d.include.indexOf("#");b=0===f?RegExp("^"+d.qualifiedId.substring(0,d.qualifiedId.indexOf("#"))+d.include+"$"):-1===f?RegExp("^"+d.include+"#"+this._NO_ID+"[^#]+$"):RegExp("^"+d.include+"$");this._patterns.forEach(function(d){b.test(d.qualifiedId)&&(d.include?this._processInclude(d,c,a):a[d.id]||(d.index=c[0]++,a[d.id]=d))}.bind(this))},_NO_ID:"NoID"};g.prototype={adjustBounds:function(d,c){d<this.start&&(this.start+=c);d<this.contentStart&&
|
|
(this.contentStart+=c);d<=this.end&&(this.end+=c);d<=this.contentEnd&&(this.contentEnd+=c);this._subBlocks.forEach(function(a){d<=a.end&&a.adjustBounds(d,c)})},getBlocks:function(){return this._subBlocks},getBlockAtIndex:function(d){return q(this.getBlocks(),d,!0)},isRenderingWhitespace:function(){return this.styler._isRenderingWhitespace()}};h.prototype={getStyles:function(d){return this._styler.getStyles(d)}};f.prototype={addAnnotationProvider:function(d){"function"===typeof d&&this._annotationProviders.push(d)},
|
|
computeBlocks:function(d,c,a,b,f,g,e){return this._stylerAdapter.computeBlocks(d,c,a,b,f,g,e)},destroy:function(){if(this._view){var d=this._view.getModel();d.getBaseModel&&(d=d.getBaseModel());d.removeEventListener("Changed",this._listener.onChanged);this._view.removeEventListener("MouseDown",this._listener.onMouseDown);this._view.removeEventListener("Selection",this._listener.onSelection);this._view.removeEventListener("Destroy",this._listener.onDestroy);this._view.removeEventListener("LineStyle",
|
|
this._listener.onLineStyle);this._view=null}},getBlockAtIndex:function(d){return this._findBlock(this._rootBlock,d)},getRootBlock:function(){return this._rootBlock},getStyleAccessor:function(){return this._accessor},getStyles:function(d){var c=[],a=this._view.getModel();a.getBaseModel&&(a=a.getBaseModel());var b=this._findBlock(this._rootBlock,d),f=a.getLineAtOffset(d),g=a.getLine(f),e=[];this._stylerAdapter.parse(g,a.getLineStart(f),b,e);for((f=e[q(e,d,!0)])&&(f.start<=d&&d<f.end)&&c.push(f);b;)(f=
|
|
this._stylerAdapter.computeStyle(b,a,d))&&c.splice(0,0,f),b=b.parent;return c},removeAnnotationProvider:function(d){"function"===typeof d&&(d=this._annotationProviders.indexOf(d),-1!==d&&this._annotationProviders.splice(d,1))},setDetectHyperlinks:function(){},setDetectTasks:function(d){this._detectTasks=d},setFoldingEnabled:function(d){this._foldingEnabled=d},setHighlightCaretLine:function(d){this._highlightCaretLine=d},setWhitespacesVisible:function(d,c){this._whitespacesVisible!==d&&(this._whitespacesVisible=
|
|
d,c&&this._view.redraw())},_computeFolding:function(d,c,a){if(c.getBaseModel){var b=c.getBaseModel();d.forEach(function(d){var f=this._createFoldingAnnotation(c,b,d.start,d.end);f&&a.push(f);this._computeFolding(d.getBlocks(),c,a)}.bind(this))}},_computeTasks:function(d,c,a,b,f){b=b||d.start;f=f||d.end;if(d.start<=f&&b<=d.end&&this._annotationModel){var g=p.AnnotationType.ANNOTATION_TASK;if(d.name&&0===d.name.indexOf("comment")){var e=[];this._stylerAdapter.parse(c.getText(d.contentStart,d.end),d.contentStart,
|
|
d,e,!0);for(var h=0;h<e.length;h++)"meta.annotation.task.todo"===e[h].style&&(b<=e[h].start&&e[h].end<=f)&&a.push(p.AnnotationType.createAnnotation(g,e[h].start,e[h].end,c.getText(e[h].start,e[h].end)))}d.getBlocks().forEach(function(d){this._computeTasks(d,c,a,b,f)}.bind(this))}},_createFoldingAnnotation:function(d,c,a,b){var f=c.getLineAtOffset(a),g=c.getLineAtOffset(b);return f===g||f+1===g&&c.getLineStart(g)===c.getLineEnd(g)?null:new (p.AnnotationType.getType(p.AnnotationType.ANNOTATION_FOLDING))(a,
|
|
b,d)},_findBlock:function(d,c){var a=d.getBlocks();if(!a.length)return d;var b=q(a,c,!0);return b<a.length&&a[b].start<=c&&c<a[b].end?this._findBlock(a[b],c):d},_findBrackets:function(d,c,a,b,f){for(var g=[],e=[],h=b,k=c.getBlocks(),p=q(k,b,!0);p<k.length&&!(k[p].start>=f);p++){var r=k[p].start,t=k[p].end;h<r&&(this._stylerAdapter.parse(a.substring(h-b,r-b),h,c,e),e.forEach(function(a){a.style&&(0===a.style.indexOf(d.beginName)?g.push(a.start+1):0===a.style.indexOf(d.endName)&&g.push(-(a.start+1)))}),
|
|
e=[]);h=t}h<f&&(this._stylerAdapter.parse(a.substring(h-b,f-b),h,c,e),e.forEach(function(a){a.style&&(0===a.style.indexOf(d.beginName)?g.push(a.start+1):0===a.style.indexOf(d.endName)&&g.push(-(a.start+1)))}));return g},_findMatchingBracket:function(d,c,a){var b=d.getLineAtOffset(a),f=d.getLineEnd(b),g=d.getText(a,f),g=this._stylerAdapter.getBracketMatch(c,g);if(!g)return-1;for(var e=d.getLine(b),h=d.getLineStart(b),f=this._findBrackets(g,c,e,h,f),k=0;k<f.length;k++)if(e=0<=f[k]?1:-1,f[k]*e-1===a){a=
|
|
1;if(g.atStart){for(k++;k<f.length;k++)if(e=0<=f[k]?1:-1,a+=e,0===a)return f[k]*e-1;b+=1;for(k=d.getLineCount();b<k;){e=d.getLine(b);h=d.getLineStart(b);f=d.getLineEnd(b);f=this._findBrackets(g,c,e,h,f);for(h=0;h<f.length;h++)if(e=0<=f[h]?1:-1,a+=e,0===a)return f[h]*e-1;b++}}else{for(k--;0<=k;k--)if(e=0<=f[k]?1:-1,a+=e,0===a)return f[k]*e-1;for(b-=1;0<=b;){e=d.getLine(b);h=d.getLineStart(b);f=d.getLineEnd(b);f=this._findBrackets(g,c,e,h,f);for(k=f.length-1;0<=k;k--)if(e=0<=f[k]?1:-1,a+=e,0===a)return f[k]*
|
|
e-1;b--}}break}return-1},_getLineStyle:function(d){if(this._highlightCaretLine){var c=this._view.getModel(),a=this._view.getSelection();if(a.start===a.end&&c.getLineAtOffset(a.start)===d)return this._caretLineStyle}return null},_getStyles:function(d,c,a,b){c.getBaseModel&&(b=c.mapOffset(b));for(var f=b+a.length,g=[],e=b,h=d.getBlocks(),k=q(h,b,!0);k<h.length&&!(h[k].start>=f);k++){var p=h[k].start,r=h[k].end;e<p&&this._stylerAdapter.parse(a.substring(e-b,p-b),e,d,g);var t=Math.max(e,p);t===p&&(p=
|
|
this._stylerAdapter.getBlockStartStyle(h[k],a.substring(t-b),t,g))&&(t+=p.length);var p=Math.min(f,r),z=[];p===r&&(e=a.substring(p-e-(h[k].end-h[k].contentEnd)),(e=this._stylerAdapter.getBlockEndStyle(h[k],e,p,z))&&(p-=e.length));var e=this._getStyles(h[k],c,a.substring(t-b,p-b),t),C=this._stylerAdapter.getBlockContentStyleName(h[k]);if(C){var m=t;e.forEach(function(a){a.start-m&&g.push({start:m,end:a.start,style:C});a.mergeable&&(a.style+=","+C);g.push(a);m=a.end});p-m&&g.push({start:m,end:p,style:C})}else g=
|
|
g.concat(e);g=g.concat(z);e=r}e<f&&this._stylerAdapter.parse(a.substring(e-b,f-b),e,d,g);if(c.getBaseModel)for(d=0;d<g.length;d++)a=g[d].end-g[d].start,g[d].start=c.mapOffset(g[d].start,!0),g[d].end=g[d].start+a;return g},_isRenderingWhitespace:function(){return this._whitespacesVisible},_onDestroy:function(){this.destroy()},_onLineStyle:function(d){d.textView===this._view&&(d.style=this._getLineStyle(d.lineIndex));d.ranges=this._getStyles(this._rootBlock,d.textView.getModel(),d.lineText,d.lineStart);
|
|
d.ranges.forEach(function(c){c.style&&(c.style={styleClass:c.style.replace(/\./g," ")})});this._isRenderingWhitespace()&&(this._spliceStyles(this._spacePattern,d.ranges,d.lineText,d.lineStart),this._spliceStyles(this._tabPattern,d.ranges,d.lineText,d.lineStart))},_onModelChanged:function(d){var c=d.start,a=d.removedCharCount;d=d.addedCharCount-a;var b=this._view.getModel(),f=b.getBaseModel?b.getBaseModel():b,a=c+a,g=f.getCharCount(),e=f.getLineStart(f.getLineAtOffset(c)),h=this._findBlock(this._rootBlock,
|
|
c),k,r,t,y,z,C,m;do{t=h.parent;if(!k&&t){if(0>d&&h.end-c<=-d){h=t;continue}z=f.getText(h.start,Math.min(g,h.end+d+1));if(!this._stylerAdapter.verifyBlock(f,z,h,d)){h=t;continue}}r=h.getBlocks();var w=r.length,B=q(r,e,!0),A=q(r,a,!1,B-1,w);k=!1;if(B&&r.length&&r[B-1].end===c){z=f.getText(r[B-1].start,Math.min(g,c+1));var D=this.computeBlocks(f,z,h,r[B-1].start,null,null,null);D.length&&D[0].end!==r[B-1].end&&(B--,k=!0)}B<w&&r[B].start<=e&&(e<r[B].end||k)?(m=r[B].start,m>c&&(m+=d)):B===w&&0<w&&h.end-
|
|
d===r[w-1].end?(m=r[--B].start,m>c&&(m+=d)):m=Math.max(e,h.contentStart);C=A<w?r[A].end:h.contentEnd;c<=C&&(C+=d);C=Math.min(C,g-1);z=f.getText(m,C+1);D=this.computeBlocks(f,z,h,m,null,null,null);if(A<w){if(D.length&&D[D.length-1].end===C&&D[D.length-1].typeId===r[A].typeId)break;if(D.length&&this._stylerAdapter.blockSpansBeyondEnd(D[D.length-1])){A++;for(var H=D[D.length-1].getBlocks(),H=(H.length?H[H.length-1]:D[D.length-1]).typeId;A<w;){if(r[A].typeId===H){var M=r[A].end+d,M=Math.min(M,g-1);z=
|
|
f.getText(m,M+1);z=this.computeBlocks(f,z,h,m,null,null,null);if(z.length&&z[z.length-1].end===M){C=M;D=z;break}}A++}if(A<w)break}}else if(!D.length||D[D.length-1].end<=h.contentEnd+d)break;if(!t){C=g;A=w;z=f.getText(m,C);D=this.computeBlocks(f,z,h,m,null,null,null);break}h=t;y=!0}while(1);this._rootBlock.adjustBounds(c,d);A=Math.min(A+1,w);y||(y=A-B!==D.length);if(!y)for(w=0;w<D.length;w++)if(k=r[B+w],g=D[w],k.start!==g.start||k.end!==g.end||k.typeId!==g.typeId){y=!0;break}!r.length&&!D.length?this.dispatchEvent({type:"BlocksChanged",
|
|
oldBlocks:[h],newBlocks:[h]}):this.dispatchEvent({type:"BlocksChanged",oldBlocks:r.slice(B,A),newBlocks:D});B=[B,A-B].concat(D);Array.prototype.splice.apply(r,B);y&&(r=m,y=C,b!==f&&(r=b.mapOffset(r,!0),y=b.mapOffset(y,!0)),this._view.redrawRange(r,y));if(this._annotationModel){var K=[],G=[],P=[];r=this._annotationModel.getAnnotations(m,C);y=this._foldingEnabled&&f!==b;for(B=h.parent||h;r.hasNext();)A=r.next(),y&&A.type===p.AnnotationType.ANNOTATION_FOLDING?(P.push(A),k=this._findBlock(B,A.start),
|
|
!k||!(A.start===k.start&&A.end===k.end)?(K.push(A),A.expand()):(D=A.start,k=A.end,D>c&&(D-=d),k>c&&(k-=d),D<=c&&(c<k&&D<=a&&a<k)&&(D=f.getLineAtOffset(A.start),k=f.getLineAtOffset(A.end),D!==k?A.expanded||A.expand():K.push(A)))):A.type===p.AnnotationType.ANNOTATION_TASK&&h.start<=A.start&&A.end<=h.end&&K.push(A);y&&B.getBlocks().forEach(function(a){this._updateFolding(a,f,b,P,G,m,C)}.bind(this));this._detectTasks&&this._computeTasks(h,f,G,m,C);this._annotationProviders.forEach(function(a){var b=[],
|
|
c=[];a(this._annotationModel,f,h,m,C,b,c);K=K.concat(b);G=G.concat(c)}.bind(this));this._annotationModel.replaceAnnotations(K,G)}},_onMouseDown:function(d){if(2===d.clickCount){var c=this._view.getModel(),a=this._view.getOffsetAtLocation(d.x,d.y);if(0<a){var b=a-1,f=c;c.getBaseModel&&(b=c.mapOffset(b),f=c.getBaseModel());var g=this._findBlock(this._rootBlock,b),b=this._findMatchingBracket(f,g,b);-1!==b&&(d.preventDefault(),d=b,c.getBaseModel&&(d=c.mapOffset(d,!0)),a>d&&(a--,d++),this._view.setSelection(d,
|
|
a))}}},_onSelection:function(d){var c=d.oldValue,a=d.newValue;d=this._view.getModel();var b;if(this._highlightCaretLine){var f=d.getLineAtOffset(c.start);b=d.getLineAtOffset(a.start);var g=a.start===a.end,c=c.start===c.end;f===b&&c&&g||(c&&this._view.redrawLines(f,f+1),(f!==b||!c)&&g&&this._view.redrawLines(b,b+1))}if(this._annotationModel){var c=this._bracketAnnotations,e,h;if(a.start===a.end&&0<(h=this._view.getCaretOffset()))h-=1,d.getBaseModel&&(h=d.mapOffset(h),d=d.getBaseModel()),a=this._findBlock(this._rootBlock,
|
|
h),d=this._findMatchingBracket(d,a,h),-1!==d&&(e=[p.AnnotationType.createAnnotation(p.AnnotationType.ANNOTATION_MATCHING_BRACKET,d,d+1),p.AnnotationType.createAnnotation(p.AnnotationType.ANNOTATION_CURRENT_BRACKET,h,h+1)]);this._bracketAnnotations=e;this._annotationModel.replaceAnnotations(c,e)}},_spliceStyles:function(d,c,a,b){for(var f=d.regex,g=f.lastIndex=0,e=f.exec(a);e;){for(e=b+e.index;g<c.length&&!(e<c[g].end);)g++;var h={start:e,end:e+1,style:d.style};if(g<c.length&&c[g].start<=e){var k=
|
|
{start:e+1,end:c[g].end,style:c[g].style};c[g].end=e;c.splice(g+1,0,k);c.splice(g+1,0,h);g+=2}else c.splice(g,0,h),g++;e=f.exec(a)}},_updateFolding:function(d,c,a,b,f,g,e){g=g||d.start;e=e||d.end;if(!d.doNotFold&&d.start<=e&&g<=d.end){var h=q(b,d.start,!0);h<b.length&&b[h].start===d.start&&b[h].end===d.end||(h=this._createFoldingAnnotation(a,c,d.start,d.end))&&f.push(h);d.getBlocks().forEach(function(d){this._updateFolding(d,c,a,b,f,g,e)}.bind(this))}},_annotationProviders:[],_caretLineStyle:{styleClass:"meta annotation currentLine"},
|
|
_spacePattern:{regex:/[ ]/g,style:{styleClass:"punctuation separator space",unmergeable:!0}},_tabPattern:{regex:/\t/g,style:{styleClass:"punctuation separator tab",unmergeable:!0}}};t.EventTarget.addMixin(f.prototype);return{TextStyler:f,Block:g,createPatternBasedAdapter:function(d,c){return new r(d,c)}}});
|
|
define("orion/editor/stylers/application_javascript/syntax",["orion/editor/stylers/lib/syntax"],function(p){var t="class const debugger delete enum export extends function implements import in instanceof interface let new package private protected public static super typeof var void with".split(" "),r="break case catch continue default do else finally for if return switch throw try while yield".split(" ");p=p.grammars;p.push({id:"orion.js",contentTypes:["application/javascript"],patterns:[{begin:"'(?:\\\\.|[^\\\\'])*\\\\$",
|
|
end:"^(?:$|(?:\\\\.|[^\\\\'])*('|[^\\\\]$))",name:"string.quoted.single.js"},{begin:'"(?:\\\\.|[^\\\\"])*\\\\$',end:'^(?:$|(?:\\\\.|[^\\\\"])*("|[^\\\\]$))',name:"string.quoted.double.js"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{match:"/(?![\\s\\*])(?:\\\\.|[^/])+/(?:[gim]{0,3})",name:"string.regexp.js"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{include:"#jsFunctionDef"},{include:"orion.lib#brace_open"},
|
|
{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.js"},{match:"\\b(?:"+r.join("|")+")\\b",name:"keyword.control.js"},{match:"\\b(?:false|null|true|undefined)\\b",name:"constant.language.js"},{match:"\\bthis\\b",name:"variable.language.js"}],
|
|
repository:{jsFunctionDef:{begin:"(function)(\\s+[_$a-zA-Z\\xA0-\\uFFFF][_$a-zA-Z0-9\\xA0-\\uFFFF]*)?\\s*\\(",end:"\\)",captures:{1:{name:"keyword.operator.js"},2:{name:"entity.name.function.js"}},patterns:[{include:"orion.c-like#comment_singleLine"},{include:"orion.c-like#comment_block"},{match:"[^\\s,]+",name:"variable.parameter.js"}]}}});return{id:p[p.length-1].id,grammars:p,keywords:t.concat(r)}});
|
|
define("orion/editor/stylers/application_xml/syntax",["orion/editor/stylers/lib/syntax"],function(p){p=p.grammars;p.push({id:"orion.xml",contentTypes:["application/xml","application/xhtml+xml"],patterns:[{include:"#comment"},{include:"#doctype"},{include:"#xmlDeclaration"},{include:"#tag"},{include:"#ampersandEscape"}],repository:{ampersandEscape:{match:"\x26lt;|\x26gt;|\x26amp;",name:"constant.character"},comment:{begin:{match:"\x3c!--",literal:"\x3c!--"},end:{match:"--\x3e",literal:"--\x3e"},name:"comment.block.xml",
|
|
patterns:[{match:"(\\b)(TODO)(\\b)(((?!--\x3e).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.line"}}}]},doctype:{begin:"\x3c!(?:doctype|DOCTYPE)",end:"\x3e",name:"meta.tag.doctype.xml",captures:{0:{name:"meta.tag.doctype.xml"}},patterns:[{include:"#comment"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},tag:{begin:"\x3c/?[A-Za-z0-9]+",end:"/?\x3e",captures:{0:{name:"meta.tag.xml"}},name:"meta.tag.xml",
|
|
patterns:[{include:"#comment"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},xmlDeclaration:{begin:"\x3c\\?xml",end:"\\?\x3e",captures:{0:{name:"meta.tag.declaration.xml"}},patterns:[{include:"#comment"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}],name:"meta.tag.declaration.xml"}}});return{id:p[p.length-1].id,grammars:p,keywords:[]}});
|
|
define("orion/editor/stylers/text_html/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/application_javascript/syntax","orion/editor/stylers/text_css/syntax","orion/editor/stylers/application_xml/syntax"],function(p,t,r,k){p=p.grammars.concat(t.grammars).concat(r.grammars).concat(k.grammars);p.push({id:"orion.html",contentTypes:["text/html"],patterns:[{begin:"(?i)(\x3cstyle)([^\x3e]*)(\x3e)",end:"(?i)(\x3c/style\x3e)",captures:{1:{name:"meta.tag.html"},3:{name:"meta.tag.html"}},contentName:"source.css.embedded.html",
|
|
patterns:[{include:"orion.css"}]},{begin:"(?i)\x3cscript\\s*\x3e|\x3cscript\\s.*?(?:language\\s*\x3d\\s*(['\"])javascript\\1|type\\s*\x3d\\s*(['\"])(?:text|application)/(?:javascript|ecmascript)\\2).*?\x3e",end:"(?i)\x3c/script\x3e",captures:{0:{name:"meta.tag.html"}},contentName:"source.js.embedded.html",patterns:[{include:"orion.js"}]},{include:"orion.xml#comment"},{include:"orion.xml#doctype"},{include:"orion.xml#tag"},{include:"orion.xml#ampersandEscape"}]});return{id:p[p.length-1].id,grammars:p,
|
|
keywords:[]}});
|
|
define("orion/editor/edit","require orion/editor/config orion/editor/shim orion/editor/textView orion/editor/textModel orion/editor/textTheme orion/editor/projectionTextModel orion/editor/eventTarget orion/keyBinding orion/editor/rulers orion/editor/annotations orion/editor/tooltip orion/editor/undoStack orion/editor/textDND orion/editor/editor orion/editor/editorFeatures orion/editor/contentAssist webtools/cssContentAssist webtools/htmlContentAssist orion/editor/AsyncStyler orion/editor/mirror orion/editor/textMateStyler orion/editor/htmlGrammar orion/editor/textStyler orion/editor/stylers/application_javascript/syntax orion/editor/stylers/text_css/syntax orion/editor/stylers/text_html/syntax".split(" "),function(p,
|
|
t,r,k,g,h,f,q,d,c,a,b,l,n,e,s,u,x,v,y,z,C,m,w,B,A,D){function H(a,b,c){for(var d;c&&c!==b&&"none"!==d;)d=a.getComputedStyle?a.getComputedStyle(c,null).getPropertyValue("display"):c.currentStyle.display,c=c.parentNode;return!c||!d?"none":d}function M(a){var b=a.firstChild;if(b&&"TEXTAREA"===b.tagName)return b.value;var c=a.ownerDocument,d=c.defaultView||c.parentWindow;if(!d.getSelection||1===a.childNodes.length&&b.nodeType===Node.TEXT_NODE||"none"===H(d,c,a))return a.innerText||a.textContent;b=c.createRange();
|
|
b.selectNode(a);a=d.getSelection();d=[];for(c=0;c<a.rangeCount;c++)d.push(a.getRangeAt(c));a.removeAllRanges();a.addRange(b);b=a.toString();a.removeAllRanges();for(c=0;c<d.length;c++)a.addRange(d[c]);return b}function K(a){if("data-editor-"===a.substring(0,12))return a=a.substring(12),a=a.replace(/-([a-z])/ig,function(a,b){return b.toUpperCase()})}function G(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])}function P(a,b){var c={};G(c,b);for(var d,e=0,f=a.attributes,g=f.length;e<g;e++){d=f.item(e);
|
|
var h=K(d.nodeName);if(h){d=d.nodeValue;if("true"===d||"false"===d)d="true"===d;c[h]=d}}return c}function S(a,b){if(a.getElementsByClassName)return a.getElementsByClassName(b);b=b.replace(/ *$/,"");return a.querySelectorAll?a.querySelectorAll((" "+b).replace(/ +/g,".")):null}function Q(a){var b=a.document||document,c=a.parent;c||(c="editor");"string"===typeof c&&(c=b.getElementById(c));if(!c&&a.className){var d=S(b,a.className);if(d){a.className=void 0;1<d.length&&void 0===a.noFocus&&(a.noFocus=!0);
|
|
for(var b=[],l=d.length-1;0<=l;l--)a.parent=d[l],b.push(Q(a));return b}}if(!c)throw"no parent";a=P(c,a);if("string"===typeof a.theme){var d=h.TextTheme.getTheme(a.theme),n=a.theme.lastIndexOf("/"),m=a.theme;-1!==n&&(m=m.substring(n+1));".css"===m.substring(m.length-4)&&(m=m.substring(0,m.length-4));d.setThemeClass(m,{href:a.theme});a.theme=d}var q;a.readonly||(l={createContentAssistMode:function(a){q=new u.ContentAssist(a.getTextView());a=new u.ContentAssistWidget(q);a=new u.ContentAssistMode(q,a);
|
|
q.setMode(a);return a}});var r=new e.Editor({textViewFactory:function(){return new k.TextView({parent:c,model:new f.ProjectionTextModel(a.model?a.model:new g.TextModel("")),tabSize:a.tabSize?a.tabSize:4,readonly:a.readonly,fullSelection:a.fullSelection,tabMode:a.tabMode,expandTab:a.expandTab,singleMode:a.singleMode,themeClass:a.themeClass,theme:a.theme,wrapMode:a.wrapMode,wrappable:a.wrappable})},undoStackFactory:new s.UndoFactory,annotationFactory:new s.AnnotationFactory,lineNumberRulerFactory:new s.LineNumberRulerFactory,
|
|
foldingRulerFactory:new s.FoldingRulerFactory,textDNDFactory:new s.TextDNDFactory,contentAssistFactory:l,keyBindingFactory:new s.KeyBindingsFactory,statusReporter:a.statusReporter,domNode:c});r.addEventListener("TextViewInstalled",function(){var b=r.getLineNumberRuler();b&&void 0!==a.firstLineIndex&&b.setFirstLine(a.firstLineIndex);if(b=r.getSourceCodeActions())b.setAutoPairParentheses(a.autoPairParentheses),b.setAutoPairBraces(a.autoPairBraces),b.setAutoPairSquareBrackets(a.autoPairSquareBrackets),
|
|
b.setAutoPairAngleBrackets(a.autoPairAngleBrackets),b.setAutoPairQuotations(a.autoPairQuotations),b.setAutoCompleteComments(a.autoCompleteComments),b.setSmartIndentation(a.smartIndentation)});l=a.contents;void 0===l&&(l=M(c));l||(l="");r.installTextView();r.setLineNumberRulerVisible(void 0===a.showLinesRuler||a.showLinesRuler);r.setAnnotationRulerVisible(void 0===a.showAnnotationRuler||a.showFoldingRuler);r.setOverviewRulerVisible(void 0===a.showOverviewRuler||a.showOverviewRuler);r.setZoomRulerVisible(void 0===
|
|
a.showZoomRuler||a.showZoomRuler);r.setFoldingRulerVisible(void 0===a.showFoldingRuler||a.showFoldingRuler);r.setInput(a.title,null,l,!1,a.noFocus);({styler:null,highlight:function(b,c){this.styler&&this.styler.destroy&&this.styler.destroy();this.styler=null;"js"===b?b="application/javascript":"css"===b?b="text/css":"html"===b?b="text/html":"java"===b&&(b="text/x-java-source");var d=c.getTextView(),e=c.getAnnotationModel();b&&(b=b.replace(/[*|:/".<>?+]/g,"_"),p(["./stylers/"+b+"/syntax"],function(a){a=
|
|
new w.createPatternBasedAdapter(a.grammars,a.id);this.styler=new w.TextStyler(d,e,a)},function(a){}));"text/css"===b&&c.setFoldingRulerVisible(void 0===a.showFoldingRuler||a.showFoldingRuler)}}).highlight(a.contentType||a.lang,r);if(q){var t=new x.CssContentAssistProvider,y=new v.HTMLContentAssistProvider;q.addEventListener("Activating",function(){/css$/.test(a.lang)?q.setProviders([t]):/html$/.test(a.lang)&&q.setProviders([y])})}l=b.defaultView||b.parentWindow;!a.noComputeSize&&("none"!==H(l,b,c)&&
|
|
50>=c.clientHeight)&&(b=r.getTextView().computeSize().height,c.style.height=b+"px");return r}var L=this.orion?this.orion.editor:void 0;if(L){for(var N=0;N<arguments.length;N++)G(L,arguments[N]);L.edit=Q}return Q});var orion=this.orion||(this.orion={}),editor=orion.editor||(orion.editor={}); |