/* 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 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 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, 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: 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, 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) 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) 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) 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) 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) 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) 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, 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, 2012 IBM Corporation and others. Copyright (c) 2012 VMware, Inc. 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 Andrew Eisenberg - rename to jsTemplateContentAssist.js 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, 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, 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, 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 Alex Lakatos - fix for bug#369781 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 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(l){function p(a,g){var u,c,s,d,b,i,f,m,n,h=g&&g.split("/"),e=j.map,k=e&&e["*"]||{};if(a&&a.charAt(0)===".")if(g){h=h.slice(0,h.length-1);a=h.concat(a.split("/"));for(m=0;m0&&(a.splice(m-1,2),m-=2);a=a.join("/")}else a.indexOf("./")===0&&(a=a.substring(2));if((h||k)&&e){u=a.split("/");for(m=u.length;m>0;m-=1){c=u.slice(0,m).join("/");if(h)for(n=h.length;n>0;n-=1)if(s=e[h.slice(0, n).join("/")])if(s=s[c]){d=s;b=m;break}if(d)break;!i&&k&&k[c]&&(i=k[c],f=m)}!d&&i&&(d=i,b=f);d&&(u.splice(0,b,d),a=u.join("/"))}return a}function o(c,g){return function(){return a.apply(l,t.call(arguments,0).concat([c,g]))}}function e(a){return function(g){return p(g,a)}}function b(a){return function(g){m[a]=g}}function d(a){if(r.call(n,a)){var g=n[a];delete n[a];q[a]=!0;f.apply(l,g)}if(!r.call(m,a)&&!r.call(q,a))throw Error("No "+a);return m[a]}function h(a){var g,u=a?a.indexOf("!"):-1;u>-1&&(g= a.substring(0,u),a=a.substring(u+1,a.length));return[g,a]}function k(a){return function(){return j&&j.config&&j.config[a]||{}}}var f,a,c,i,m={},n={},j={},q={},r=Object.prototype.hasOwnProperty,t=[].slice;c=function(a,g){var u,c=h(a),s=c[0],a=c[1];s&&(s=p(s,g),u=d(s));s?a=u&&u.normalize?u.normalize(a,e(g)):p(a,g):(a=p(a,g),c=h(a),s=c[0],a=c[1],s&&(u=d(s)));return{f:s?s+"!"+a:a,n:a,pr:s,p:u}};i={require:function(a){return o(a)},exports:function(a){var g=m[a];return typeof g!=="undefined"?g:m[a]={}}, module:function(a){return{id:a,uri:"",exports:m[a],config:k(a)}}};f=function(a,g,u,x){var s,f,h,j,e=[],k,x=x||a;if(typeof u==="function"){g=!g.length&&u.length?["require","exports","module"]:g;for(j=0;j-1&&u[a];a--){x=u[a];c=g[x];if(c===!0||c===1)c=k(i+x+"/"+n);o(r,c)}f(r)})})}}})})();define("orion/editor/i18n",{load:function(l,p,o){p.specified&&p.specified("orion/bootstrap")?p(["orion/i18n!"+l],function(e){o(e)}):o({})}}); 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",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", 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",replaceAll:"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(l,p){var o={root:p},e;for(e in l)l.hasOwnProperty(e)&&typeof o[e]==="undefined"&&(o[e]=l[e]);return o}); define("orion/editor/eventTarget",[],function(){function l(){}l.addMixin=function(p){var o=l.prototype,e;for(e in o)o.hasOwnProperty(e)&&(p[e]=o[e])};l.prototype={addEventListener:function(l,o,e){if(!this._eventTypes)this._eventTypes={};var b=this._eventTypes[l];b||(b=this._eventTypes[l]={level:0,listeners:[]});b.listeners.push({listener:o,useCapture:e})},dispatchEvent:function(l){var o=l.type;this._dispatchEvent("pre"+o,l);this._dispatchEvent(o,l);this._dispatchEvent("post"+o,l)},_dispatchEvent:function(l, o){var e=this._eventTypes?this._eventTypes[l]:null;if(e){var b=e.listeners;try{if(e.level++,b)for(var d=0,h=b.length;d=0;d--)b[d]||b.splice(d,1);b.length===0&&delete this._eventTypes[l];e.compact=!1}}}},isListening:function(l){return!this._eventTypes?!1:this._eventTypes[l]!==void 0},removeEventListener:function(l, o,e){if(this._eventTypes){var b=this._eventTypes[l];if(b){for(var d=b.listeners,h=0,k=d.length;h1)this._text=[this._text.join("")];var b=e.string,d=b,h=e.caseInsensitive;!e.regex&&b&&(d=b.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&"),h&&(d=d.replace(/[iI\u0130\u0131]/g,"[Ii\u0130\u0131]")));var k=null,f;if(d){var b=e.reverse,a=e.wrap,c=e.wholeWord, i=e.start||0,e=e.end,m=e!==null&&e!==void 0,n="";n.indexOf("g")===-1&&(n+="g");h&&n.indexOf("i")===-1&&(n+="i");c&&(d="\\b"+d+"\\b");var j=this._text[0],q,r,l=0;m&&(h=i1;)if(f=Math.floor((a+c)/2),h=this._lineOffsets[f],k=f+11&&(e=this.getText(this.getLineEnd(0),this.getLineEnd(0,!0))));this._lineDelimiter=e?e:p.platformDelimiter;if(b){var d=this.getLineCount();if(d>1){for(var h=Array(d),k=0;k1)return!1; e=e[0]}return e.type!==this.type?!1:this.keyCode===e.keyCode||this.keyCode===String.fromCharCode(l.isOpera?e.which:e.charCode!==void 0?e.charCode:e.keyCode)?this.mod1!==(l.isMac?e.metaKey:e.ctrlKey)?!1:this.type==="keydown"&&this.mod2!==e.shiftKey?!1:this.mod3!==e.altKey?!1:l.isMac&&this.mod4!==e.ctrlKey?!1:!0:!1},equals:function(e){return!e?!1:this.keyCode!==e.keyCode?!1:this.mod1!==e.mod1?!1:this.mod2!==e.mod2?!1:this.mod3!==e.mod3?!1:this.mod4!==e.mod4?!1:this.type!==e.type?!1:!0}};o.prototype= {getKeys:function(){return this.keys.slice(0)},match:function(e,b){var d=this.keys;if(b!==void 0)return b>d.length?!1:d[b].match(e)?b===d.length-1?!0:b+1:!1;else{e instanceof Array||(e=[e]);if(e.length>d.length)return!1;var h;for(h=0;h0;)(!d.isIE||d.isIE>=9||d.isIE<9&&c[s].specified)&&a.removeAttribute(c[s].name)}if(g){if(g.styleClass)a.className= g.styleClass;if(c=g.style)for(var b in c)c.hasOwnProperty(b)&&(a.style[b]=c[b]);if(g=g.attributes)for(var i in g)g.hasOwnProperty(i)&&a.setAttribute(i,g[i])}}function f(g){return g instanceof Array?g.slice(0):g}function a(g,a){if(!g)return a;if(!a)return g;for(var c in a)a.hasOwnProperty(c)&&(g.hasOwnProperty(c)||(g[c]=a[c]));return g}function c(g,a){if(g===a)return!0;if(g&&!a||!g&&a)return!1;if(g&&g.constructor===String||a&&a.constructor===String)return!1;if(g instanceof Array||a instanceof Array){if(!(g instanceof Array&&a instanceof Array))return!1;if(g.length!==a.length)return!1;for(var d=0;dthis.end)g=this.start,this.start=this.end,this.end=g,this.caret=!this.caret},setCaret:function(g){this.end=this.start=g;this.caret=!1},getCaret:function(){return this.caret? this.start:this.end},toString:function(){return"start="+this.start+" end="+this.end+(this.caret?" caret is at start":" caret is at end")},isEmpty:function(){return this.start===this.end},equals:function(g){return this.caret===g.caret&&this.start===g.start&&this.end===g.end}};q.prototype={toString:function(){return"{l="+this.left+", t="+this.top+", r="+this.right+", b="+this.bottom+"}"}};r.prototype={create:function(g,a){if(!this._lineDiv){var c=this._lineDiv=this._createLine(g,a,this.lineIndex);c._line= this;return c}},_createLine:function(g,a,b){var s=this.view,i=s._model,f=i.getLine(b),m=i.getLineStart(b),n={type:"LineStyle",textView:s,lineIndex:b,lineText:f,lineStart:m};if(f.length<2E3)s.onLineStyle(n);i=a||d.createElement(g.ownerDocument,"div");if(!a||!c(a.viewStyle,n.style)){k(n.style,i,a);if(a)a._trim=null;i.viewStyle=n.style;i.setAttribute("role","presentation")}i.lineIndex=b;b=[];this._createRanges(n.ranges,f,0,f.length,m,{tabOffset:0,ranges:b});f=" ";!s._fullSelection&&d.isIE<9&&(f="\ufeff"); d.isWebkit&&(f="\u200c");n={text:f,style:s._metrics.largestFontStyle,ignoreChars:1};b.length===0||!b[b.length-1].style||b[b.length-1].style.tagName!=="div"?b.push(n):b.splice(b.length-1,0,n);var j,e,h,q,r,f=s=0,l,o;if(a){if(e=a.modelChangedEvent)e.removedLineCount===0&&e.addedLineCount===0?(o=e.start-m,l=e.addedCharCount-e.removedCharCount):o=-1,a.modelChangedEvent=void 0;e=a.firstChild}for(m=0;m=o&&(h-=l);r=(r=e.firstChild.data)?r.length:0;if(f+r>h)break;f+=r}h=e.nextSibling;i.removeChild(e);e=h}j=this._createSpan(i,q,j,n.ignoreChars);e?i.insertBefore(j,e):i.appendChild(j);if(a)a.lineWidth=void 0}if(a)for(g=j?j.nextSibling:null;g;)h=g.nextSibling,a.removeChild(g),g=h;else g.appendChild(i);return i},_createRanges:function(g,a,d,s,b,i){if(!(d>s)){if(g)for(var f=0;fs)break;var j=Math.min(b+s,m.end)-b;if(n<=j){n=Math.max(d,n);j=Math.min(s,j);for(dc)){var b=this.view._customTabSize;if(b&&b!==8)for(var i=g.indexOf("\t",a);i!==-1;){a0){for(var f="\u00a0",m=1;mg){m=g-b;if(s._isRangeRects)i=i.createRange(),i.setStart(n,m),i.setEnd(n,m+1),m=new q(i.getBoundingClientRect());else if(d.isIE)i=i.body.createTextRange(),i.moveToElementText(f),i.collapse(),i.moveEnd("character",m+1),i.moveStart("character",m),m=new q(i.getBoundingClientRect());else{var e= n.data;f.removeChild(n);f.appendChild(i.createTextNode(e.substring(0,m)));var h=d.createElement(i,"span");h.appendChild(i.createTextNode(e.substring(m,m+1)));f.appendChild(h);f.appendChild(i.createTextNode(e.substring(m+1)));m=new q(h.getBoundingClientRect());f.innerHTML="";f.appendChild(n);this._createdDiv||(i=s._getSelection(),(b<=i.start&&i.startd.right)d.right=f.right;if(f.bottom>d.bottom)d.bottom=f.bottom}}}s=s.nextSibling}return g!==void 0?c[g]:c},_getLineBoundingClientRect:function(g,a){var c=new q(g.getBoundingClientRect());if(!this.view._wrapMode){c.right=c.left;for(var d=g.lastChild;d&&d.ignoreChars===d.firstChild.length;)d=d.previousSibling;if(d)d=d.getBoundingClientRect(),c.right= d.right+n(g).right}a&&(d=n(g),c.left+=d.left,c.right-=d.right);return c},getLineCount:function(){return!this.view._wrapMode?1:this.getClientRects().length},getLineIndex:function(g){if(!this.view._wrapMode)return 0;for(var a=this.getClientRects(),g=this.getBoundingClientRect(g),g=g.top+(g.bottom-g.top)/2,c=0;ce.right&&(g=e.right-1)}else g<0&&(g=0),g>n.right-n.left&&(g=n.right-n.left);var k=m.ownerDocument,h=k.defaultView|| k.parentWindow,q=d.isIE?h.screen.logicalXDPI/h.screen.deviceXDPI:1,r=d.isIE?h.screen.logicalYDPI/h.screen.deviceYDPI:1,h=i,l=m.firstChild;a:for(;l;){if(!l.ignore){var o=l.firstChild,m=o.length;l.ignoreChars&&(m-=l.ignoreChars);var t,p,v;j=this._getClientRects(l,n);for(var z=0;z1;){var E=Math.floor((z+D)/2);j= D+1;e=E===m-1&&l.ignoreChars?o.length:E+1;c._isRangeRects?(k.setStart(o,j),k.setEnd(o,e)):(k.moveToElementText(l),k.move("character",j),k.moveEnd("character",e-j));j=k.getClientRects();for(var J=!1,G=0;Gt+(v-t)/2;n=h-i;s=s.getLine(b);b=s.charCodeAt(n);55296<=b&&b<=56319&&c?n0&&(b=s.charCodeAt(n-1),55296<=b&&b<=56319&&(h-=1));c&&h++}else{s=[];for(b=0;b"),b===m-1?s.push(o.data.substring(b)):s.push(o.data.substring(b,b+1)),s.push("");l.innerHTML=s.join("");for(s=l.firstChild;s;){e=s.getBoundingClientRect(); t=e.left-n.left;v=e.right-n.left;if(t<=g&&gt+(v-t)/2&&h++;break}h++;s=s.nextSibling}if(!this._createdDiv)l.innerHTML="",l.appendChild(o),n=c._getSelection(),(h<=n.start&&n.start0)return a.count--,c.getLineEnd(b);a.count++;return c.getLineStart(b)}return a.unit==="wordend"||a.unit=== "wordWS"||a.unit==="wordendWS"?this._getNextOffset_W3C(g,a):d.isIE?this._getNextOffset_IE(g,a):this._getNextOffset_W3C(g,a)},_getNextOffset_W3C:function(g,a){function c(g){return 33<=g&&g<=47||58<=g&&g<=64||91<=g&&g<=94||g===96||123<=g&&g<=126}function d(g){return g===32||g===9}var b=this.view._model,i=b.getLineAtOffset(g),f=b.getLine(i),m=b.getLineStart(i),b=b.getLineEnd(i),i=f.length,n=g-m,j,e=a.count<0?-1:1;if(a.unit==="word"||a.unit==="wordend"||a.unit==="wordWS"||a.unit==="wordendWS")for(var h, k,q;a.count!==0;){if(a.count>0){if(n===i)return b;j=f.charCodeAt(n);h=c(j);k=!h&&!d(j);for(n++;n0&&(j=f.charCodeAt(n-1),55296<=j&&j<=56319&&(n+=e)),a.count-=e;return m+n},_getNextOffset_IE:function(g,a){var c=this._ensureCreated(),d=this.view._model,b=this.lineIndex,i=0,f;f=d.getLineStart(b);var m=c.ownerDocument,n=a.count<0?-1:1;if(g=== d.getLineEnd(b)){for(c=c.lastChild;c&&c.ignoreChars;)c=c.previousSibling;if(!c)return f;i=m.body.createTextRange();i.moveToElementText(c);f=i.text.length;i.moveEnd(a.unit,n);i=g+i.text.length-f}else if(g===f&&a.count<0)i=f;else for(c=c.firstChild;c;){d=c.firstChild.length;c.ignoreChars&&(d-=c.ignoreChars);if(f+d>g){i=m.body.createTextRange();g===f&&a.count<0?i.moveToElementText(c.previousSibling):(i.moveToElementText(c),i.collapse(),i.moveEnd("character",g-f));f=i.text.length;i.moveEnd(a.unit,n); i=g+i.text.length-f;break}f=d+f;c=c.nextSibling}a.count-=n;return i},destroy:function(){var g=this._createdDiv;if(g)g.parentNode.removeChild(g),this._createdDiv=null}};t.prototype={addKeyMode:function(g,a){var c=this._keyModes;a!==void 0?c.splice(a,0,g):c.push(g);g._modeAdded&&g._modeAdded()},addRuler:function(g,a){g.setView(this);var c=this._rulers;if(a!==void 0){var d,b;for(d=0,b=0;d 0)){var g=this._model.getLineCount();this.redrawRulers(0,g);this.redrawLines(0,g)}},redrawRulers:function(g,a){if(!(this._redrawCount>0))for(var c=this.getRulers(),d=0;d0)&&(g===void 0&&(g=0),a===void 0&&(a=this._model.getLineCount()),g!==a)){var d=this._clientDiv;if(d){if(c)for(d=(c.getLocation()==="left"?this._leftDiv:this._rightDiv).firstChild;d;){if(d._ruler===c)break;d=d.nextSibling}c?d.rulerChanged= !0:this._lineHeight&&this._resetLineHeight(g,a);if(!c||c.getOverview()==="page")for(d=d.firstChild;d;){var b=d.lineIndex;if(g<=b&&b0)){var c=this._model;g===void 0&&(g=0);a===void 0&&(a=c.getCharCount());var d=c.getLineAtOffset(g),c=c.getLineAtOffset(Math.max(g, a-1))+1;this.redrawLines(d,c)}},removeKeyMode:function(g){for(var a=this._keyModes,c=0;ca;if(b)var i=g,g=a,a=i;i=this._model.getCharCount();g=Math.max(0,Math.min(g,i));a=Math.max(0,Math.min(a,i));this._setSelection(new j(g,a,b), c===void 0||c,!0,d)},setText:function(g,a,c){var b=a===void 0&&c===void 0;a===void 0&&(a=0);c===void 0&&(c=this._model.getCharCount());if(b)this._variableLineHeight=!1;this._modifyContent({text:g,start:a,end:c,_code:!0},!b);if(b)this._columnX=-1,this._setSelection(new j(0,0,!1),!0),d.isFirefox&&this._fixCaret()},setTopIndex:function(g){this._clientDiv&&this._scrollView(0,this._getLinePixel(Math.max(0,g))-this._getScroll().y)},setTopPixel:function(g){this._clientDiv&&this._scrollView(0,Math.max(0, g)-this._getScroll().y)},showSelection:function(){return this._showCaret(!0)},update:function(g,a){this._clientDiv&&(g&&this._updateStyle(),a===void 0||a?this._update():this._queueUpdate())},_handleRootMouseDown:function(g){if(!this._ignoreEvent(g)){if(d.isFirefox&&g.which===1)this._clientDiv.contentEditable=!1,this._ignoreBlur=(this._overlayDiv||this._clientDiv).draggable=!0;var a=this._overlayDiv||this._clientDiv;if(d.isIE<9)a=this._viewDiv;for(var c=g.target?g.target:g.srcElement;c;){if(a===c)return; c=c.parentNode}g.preventDefault&&g.preventDefault();g.stopPropagation&&g.stopPropagation();if(!this._isW3CEvents){var b=this;this._getWindow().setTimeout(function(){b._clientDiv.focus()},0)}}},_handleRootMouseUp:function(g){if(!this._ignoreEvent(g)&&d.isFirefox&&g.which===1)this._clientDiv.contentEditable=!0,(this._overlayDiv||this._clientDiv).draggable=!1,this._fixCaret(),this._ignoreBlur=!1},_handleBlur:function(){if(!this._ignoreBlur){this._hasFocus=!1;if(d.isIE<9&&!this._getSelection().isEmpty()){var g= this._rootDiv,a=d.createElement(g.ownerDocument,"div");g.appendChild(a);g.removeChild(a)}if(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",g=this._getWindow(),a=this._selDiv1.ownerDocument,g.getSelection){a=g.getSelection();for(g=a.anchorNode;g;){if(g===this._clientDiv){a.rangeCount>0&&a.removeAllRanges();break}g=g.parentNode}}else if(a.selection){this._ignoreSelect= !1;for(g=a.selection.createRange().parentElement();g;){if(g===this._clientDiv){a.selection.empty();break}g=g.parentNode}this._ignoreSelect=!0}if(!this._ignoreFocus)this.onBlur({type:"Blur"})}},_handleContextMenu:function(g){if(!this._ignoreEvent(g)){d.isIE&&this._lastMouseButton===3&&this._updateDOMSelection();var a=!1;this.isListening("ContextMenu")?(a=this._createMouseEvent("ContextMenu",g),a.screenX=g.screenX,a.screenY=g.screenY,this.onContextMenu(a),a=a.defaultPrevented):d.isMac&&d.isFirefox&& g.button===0&&(a=!0);if(a)return g.preventDefault&&g.preventDefault(),!1}},_handleCopy:function(g){if(!this._ignoreEvent(g)&&!this._ignoreCopy&&this._doCopy(g))return g.preventDefault&&g.preventDefault(),!1},_handleCut:function(g){if(!this._ignoreEvent(g)&&this._doCut(g))return g.preventDefault&&g.preventDefault(),!1},_handleDataModified:function(g){this._ignoreEvent(g)||this._startIME()},_handleDblclick:function(g){if(!this._ignoreEvent(g)&&(this._lastMouseTime=g.timeStamp?g.timeStamp:(new Date).getTime(), this._clickCount!==2))this._clickCount=2,this._handleMouse(g)},_handleDragStart:function(g){if(!this._ignoreEvent(g)){if(d.isFirefox){var a=this;this._getWindow().setTimeout(function(){a._clientDiv.contentEditable=!0;a._clientDiv.draggable=!1;a._ignoreBlur=!1},0)}if(this.isListening("DragStart")&&this._dragOffset!==-1)this._isMouseDown=!1,this.onDragStart(this._createMouseEvent("DragStart",g)),this._dragOffset=-1;else return g.preventDefault&&g.preventDefault(),!1}},_handleDrag:function(g){if(!this._ignoreEvent(g)&& this.isListening("Drag"))this.onDrag(this._createMouseEvent("Drag",g))},_handleDragEnd:function(g){if(!this._ignoreEvent(g)){this._dropTarget=!1;this._dragOffset=-1;if(this.isListening("DragEnd"))this.onDragEnd(this._createMouseEvent("DragEnd",g));d.isFirefox&&(this._fixCaret(),g.dataTransfer.dropEffect==="none"&&!g.dataTransfer.mozUserCancelled&&this._fixCaret())}},_handleDragEnter:function(g){if(!this._ignoreEvent(g)){var a=!0;this._dropTarget=!0;this.isListening("DragEnter")&&(a=!1,this.onDragEnter(this._createMouseEvent("DragEnter", g)));if(d.isWebkit||a)return g.preventDefault&&g.preventDefault(),!1}},_handleDragOver:function(g){if(!this._ignoreEvent(g)){var a=!0;this.isListening("DragOver")&&(a=!1,this.onDragOver(this._createMouseEvent("DragOver",g)));if(d.isWebkit||a){if(a)g.dataTransfer.dropEffect="none";g.preventDefault&&g.preventDefault();return!1}}},_handleDragLeave:function(g){if(!this._ignoreEvent(g)&&(this._dropTarget=!1,this.isListening("DragLeave")))this.onDragLeave(this._createMouseEvent("DragLeave",g))},_handleDrop:function(g){if(!this._ignoreEvent(g)){this._dropTarget= !1;if(this.isListening("Drop"))this.onDrop(this._createMouseEvent("Drop",g));g.preventDefault&&g.preventDefault();return!1}},_handleFocus:function(){this._hasFocus=!0;d.isIOS&&this._lastTouchOffset!==void 0?(this.setCaretOffset(this._lastTouchOffset,!0),this._lastTouchOffset=void 0):this._updateDOMSelection();if(this._cursorDiv)this._cursorDiv.style.display="block";if(this._selDiv1){var g=this._highlightRGB;this._selDiv1.style.background=g;this._selDiv2.style.background=g;this._selDiv3.style.background= g}if(!this._ignoreFocus)this.onFocus({type:"Focus"})},_handleKeyDown:function(g){if(!this._ignoreEvent(g)){if(this.isListening("KeyDown")){var a=this._createKeyEvent("KeyDown",g);this.onKeyDown(a);if(a.defaultPrevented){if(d.isFirefox)this._keyDownPrevented=!0;g.preventDefault();return}}a=!1;switch(g.keyCode){case 16:case 17:case 18:case 91:a=!0;break;default:this._setLinksVisible(!1)}if(g.keyCode===229){if(this._readonly)return g.preventDefault&&g.preventDefault(),!1;a=!0;if(d.isSafari&&d.isMac&& g.ctrlKey)a=!1,g.keyCode=129;a&&this._startIME()}else a||this._commitIME();if((d.isMac||d.isLinux)&&d.isFirefox<4||d.isOpera)return this._keyDownEvent=g,!0;if(this._doAction(g))return g.preventDefault?(g.preventDefault(),g.stopPropagation()):(g.cancelBubble=!0,g.returnValue=!1,g.keyCode=0),!1}},_handleKeyPress:function(g){if(!this._ignoreEvent(g))if(this._keyDownPrevented)g.preventDefault&&(g.preventDefault(),g.stopPropagation()),this._keyDownPrevented=void 0;else{if(d.isMac&&d.isWebkit&&(63232<= g.keyCode&&g.keyCode<=63487||g.keyCode===13||g.keyCode===8))return g.preventDefault&&g.preventDefault(),!1;if(((d.isMac||d.isLinux)&&d.isFirefox<4||d.isOpera)&&this._doAction(this._keyDownEvent))return g.preventDefault&&g.preventDefault(),!1;var a=d.isMac?g.metaKey:g.ctrlKey;if(g.charCode!==void 0&&a)switch(g.charCode){case 99:case 118:case 120:return!0}if(this.isListening("KeyPress")&&(a=this._createKeyEvent("KeyPress",g),this.onKeyPress(a),a.defaultPrevented)){g.preventDefault();return}if(this._doAction(g))return g.preventDefault? (g.preventDefault(),g.stopPropagation()):(g.cancelBubble=!0,g.returnValue=!1,g.keyCode=0),!1;a=!1;if(d.isMac){if(g.ctrlKey||g.metaKey)a=!0}else if(d.isFirefox){if(g.ctrlKey||g.altKey)a=!0}else g.ctrlKey^g.altKey&&(a=!0);if(!a&&(a=d.isOpera?g.which:g.charCode!==void 0?g.charCode:g.keyCode,a>31))return this._doContent(String.fromCharCode(a)),g.preventDefault&&g.preventDefault(),!1}},_handleKeyUp:function(g){if(!this._ignoreEvent(g)){if(this.isListening("KeyUp")){var a=this._createKeyEvent("KeyUp",g); this.onKeyUp(a);if(a.defaultPrevented){g.preventDefault();return}}(d.isMac?g.metaKey:g.ctrlKey)||this._setLinksVisible(!1);g.keyCode===13&&this._commitIME()}},_handleLinkClick:function(g){if(!(d.isMac?g.metaKey:g.ctrlKey))return g.preventDefault&&g.preventDefault(),!1},_handleMouse:function(g){var a=this._getWindow(),c=!0,b=a;if(d.isIE||d.isFirefox&&!this._overlayDiv)b=this._clientDiv;if(this._overlayDiv){if(this._hasFocus)this._ignoreFocus=!0;var i=this;a.setTimeout(function(){i.focus();i._ignoreFocus= !1},0)}this._clickCount===1?(c=this._setSelectionTo(g.clientX,g.clientY,g.shiftKey,!d.isOpera&&this._hasFocus&&this.isListening("DragStart")))&&this._setGrab(b):(this._isW3CEvents&&this._setGrab(b),this._doubleClickSelection=null,this._setSelectionTo(g.clientX,g.clientY,g.shiftKey),this._doubleClickSelection=this._getSelection());return c},_handleMouseDown:function(g){if(!this._ignoreEvent(g)){if(this._linksVisible)if((g.target||g.srcElement).tagName!=="A")this._setLinksVisible(!1);else return;this._commitIME(); var a=g.which;a||(g.button===4&&(a=2),g.button===2&&(a=3),g.button===1&&(a=1));var c=a!==2&&g.timeStamp?g.timeStamp:(new Date).getTime(),b=c-this._lastMouseTime,i=Math.abs(this._lastMouseX-g.clientX),f=Math.abs(this._lastMouseY-g.clientY),m=this._lastMouseButton===a;this._lastMouseX=g.clientX;this._lastMouseY=g.clientY;this._lastMouseTime=c;this._lastMouseButton=a;if(a===1)this._isMouseDown=!0,m&&b<=this._clickTime&&i<=this._clickDist&&f<=this._clickDist?this._clickCount++:this._clickCount=1;if(this.isListening("MouseDown")&& (c=this._createMouseEvent("MouseDown",g),this.onMouseDown(c),c.defaultPrevented)){g.preventDefault();return}if(a===1&&this._handleMouse(g)&&(d.isIE>=9||d.isOpera||d.isChrome||d.isSafari||d.isFirefox&&!this._overlayDiv))this._hasFocus||this.focus(),g.preventDefault();d.isFirefox&&this._lastMouseButton===3&&this._updateDOMSelection()}},_handleMouseOver:function(g){if(!this._ignoreEvent(g)&&!this._animation&&this.isListening("MouseOver"))this.onMouseOver(this._createMouseEvent("MouseOver",g))},_handleMouseOut:function(g){if(!this._ignoreEvent(g)&& !this._animation&&this.isListening("MouseOut"))this.onMouseOut(this._createMouseEvent("MouseOut",g))},_handleMouseMove:function(g){if(!this._animation){var a=this._isClientDiv(g);if(this.isListening("MouseMove")&&a)this.onMouseMove(this._createMouseEvent("MouseMove",g));if(!this._dropTarget){var c=this._linksVisible||this._lastMouseMoveX!==g.clientX||this._lastMouseMoveY!==g.clientY;this._lastMouseMoveX=g.clientX;this._lastMouseMoveY=g.clientY;this._setLinksVisible(c&&!this._isMouseDown&&(d.isMac? g.metaKey:g.ctrlKey));if(!this._isW3CEvents){if(g.button===0)return this._setGrab(null),!0;if(!this._isMouseDown&&g.button===1&&(this._clickCount&1)!==0&&a)return this._clickCount=2,this._handleMouse(g,this._clickCount)}if(this._isMouseDown&&this._dragOffset===-1){var a=g.clientX,g=g.clientY,b=this._getViewPadding(),i=this._viewDiv.getBoundingClientRect(),f=this._getClientWidth(),m=this._getClientHeight(),c=i.left+b.left,n=i.top+b.top,f=i.left+b.left+f,b=i.top+b.top+m;gb?this._doAutoScroll("down",a,g-b):af&&!this._wrapMode?this._doAutoScroll("right",a-f,g):(this._endAutoScroll(),this._setSelectionTo(a,g,!0))}}}},_isClientDiv:function(g){for(var a=this._overlayDiv||this._clientDiv,g=g.target?g.target:g.srcElement;g;){if(a===g)return!0;g=g.parentNode}return!1},_createKeyEvent:function(g,a){return{type:g,event:a,preventDefault:function(){this.defaultPrevented=!0}}},_createMouseEvent:function(g,a){var c= this.convert({x:a.clientX,y:a.clientY},"page","document");return{type:g,event:a,clickCount:this._clickCount,x:c.x,y:c.y,preventDefault:function(){this.defaultPrevented=!0}}},_handleMouseUp:function(g){var a=g.which?g.button===0:g.button===1;if(this.isListening("MouseUp")&&(this._isClientDiv(g)||a&&this._isMouseDown))this.onMouseUp(this._createMouseEvent("MouseUp",g));if(!this._linksVisible&&a&&this._isMouseDown){if(this._dragOffset!==-1)a=this._getSelection(),a.extend(this._dragOffset),a.collapse(), this._setSelection(a,!0,!0),this._dragOffset=-1;this._isMouseDown=!1;this._endAutoScroll();this._isW3CEvents&&this._setGrab(null);d.isFirefox&&g.preventDefault()}},_handleMouseWheel:function(g){var a=this._getLineHeight(),c=0,b=0;d.isIE||d.isOpera?b=-g.wheelDelta/40*a:d.isFirefox?(a=d.isMac?g.detail*3:Math.max(-256,Math.min(256,g.detail))*a,g.axis===g.HORIZONTAL_AXIS?c=a:b=a):d.isMac?(b=g.timeStamp-this._wheelTimeStamp,this._wheelTimeStamp=g.timeStamp,c=g.wheelDeltaX%120!==0?1:b<40?40/(40-b):40,b= g.wheelDeltaY%120!==0?1:b<40?40/(40-b):40,c=Math.ceil(-g.wheelDeltaX/c),-10)a.getRangeAt(0).deleteContents(),i=c.ownerDocument.createTextNode(g.data),a.getRangeAt(0).insertNode(i),n=this._getDOMText(c,i),m=n.text,n=n.offset,i.parentNode.removeChild(i);c.lineRemoved=!0;for(c=0;f.charCodeAt(c)===m.charCodeAt(c)&&c=n+g.data.length;)a--;a++;f=m.substring(c,a+i);c+=b;a+=b;this._modifyContent({text:f,start:c,end:a,_ignoreDOMSelection:!0},!0)}}else this._doContent(g.data);g.preventDefault()}},_handleTouchStart:function(g){this._commitIME();var a=this._getWindow();if(this._touchScrollTimer)this._vScrollDiv.style.display="none",this._hScrollDiv.style.display="none",a.clearInterval(this._touchScrollTimer),this._touchScrollTimer=null;var c=g.touches;if(c.length===1){var c=c[0],b=c.clientX,i=c.clientY;this._touchStartX= b;this._touchStartY=i;if(d.isAndroid&&(i=0;c--)if(a=d[c],typeof a.match==="function"&&(a=a.match(g),a!==void 0))return this.invokeAction(a);return!1},_doMove:function(g,a){var c=this._model,d=a.getCaret(),b=c.getLineAtOffset(d); if(!g.count)g.count=1;for(;g.count!==0;){var i=c.getLineStart(b);if(g.count<0&&d===i)if(b>0)g.unit==="character"&&g.count++,b--,a.extend(c.getLineEnd(b));else break;else if(g.count>0&&d===c.getLineEnd(b))if(b+10&&(f=Math.min(f+a.count-1,d.getLineCount()-1)),i=d.getLineEnd(f);c.extend(i)}a.select||c.collapse();this._setSelection(c,!0,!0,b);return!0},_doEnter:function(a){var c=this._model,d=this._getSelection();this._doContent(c.getLineDelimiter());if(a&&a.noCursor)d.end=d.start,this._setSelection(d,!0);return!0},_doHome:function(a){var c=this._getSelection(),d=this._model,b;if(a.ctrl)c.extend(0), b=function(){};else{var i=c.getCaret(),f=d.getLineAtOffset(i);this._wrapMode?(d=this._getLine(f),i=d.getLineIndex(i),i=d.getLineStart(i),d.destroy()):i=d.getLineStart(f);c.extend(i)}a.select||c.collapse();this._setSelection(c,!0,!0,b);return!0},_doLineDown:function(a){var c=this._model,b=this._getSelection(),i=b.getCaret(),f=c.getLineAtOffset(i),m=this._getLine(f),n=this._columnX,j=1,e=!1;if(n===-1||a.wholeLine||a.select&&d.isIE)n=a.wholeLine?c.getLineEnd(f+1):i,n=m.getBoundingClientRect(n).left; (i=m.getLineIndex(i))0?f=Math.min(f+a.count,i):f++);i=!1;if(e){if(a.select||d.isMac||d.isLinux)b.extend(c.getCharCount()),i=!0}else m.lineIndex!==f&&(m.destroy(),m=this._getLine(f)),b.extend(m.getOffset(n,j)),i=!0;i&&(a.select||b.collapse(),this._setSelection(b,!0,!0));this._columnX=n;m.destroy();return!0},_doLineUp:function(a){var c=this._model,b=this._getSelection(),i=b.getCaret(),f=c.getLineAtOffset(i), m=this._getLine(f),n=this._columnX,j=!1,e;if(n===-1||a.wholeLine||a.select&&d.isIE)n=a.wholeLine?c.getLineStart(f-1):i,n=m.getBoundingClientRect(n).left;(i=m.getLineIndex(i))>0?e=m.getClientRects(i-1).top+1:(j=f===0,j||(a.count&&a.count>0?f=Math.max(f-a.count,0):f--,e=this._getLineHeight(f)-1));i=!1;if(j){if(a.select||d.isMac||d.isLinux)b.extend(0),i=!0}else m.lineIndex!==f&&(m.destroy(),m=this._getLine(f)),b.extend(m.getOffset(n,e)),i=!0;i&&(a.select||b.collapse(),this._setSelection(b,!0,!0));this._columnX= n;m.destroy();return!0},_doNoop:function(){return!0},_doPageDown:function(a){var c=this,b=this._model,i=this._getSelection(),f=i.getCaret(),m=b.getLineAtOffset(f),n=b.getLineCount(),j=this._getScroll(),b=this._getClientHeight(),e,h;if(this._lineHeight){e=this._columnX;j=this._getBoundsAtOffset(f);if(e===-1||a.select&&d.isIE)e=j.left;f=this._getLineIndex(j.top+b);h=this._getLine(f);m=this._getLinePixel(f);f=h.getOffset(e,j.top+b-m);b=h.getBoundingClientRect(f);h.destroy();i.extend(f);a.select||i.collapse(); this._setSelection(i,!0,!0,function(){c._columnX=e},b.top+m-j.top);return!0}if(ma&&(f=a-b);this._setSelection(i,!0,!0,function(){c._columnX=e},f-j.y)}return!0},_doPageUp:function(a){var c=this,b=this._model, i=this._getSelection(),f=i.getCaret(),m=b.getLineAtOffset(f),n=this._getScroll(),j=this._getClientHeight(),e;if(this._lineHeight){e=this._columnX;n=this._getBoundsAtOffset(f);if(e===-1||a.select&&d.isIE)e=n.left;f=this._getLineIndex(n.bottom-j);b=this._getLine(f);m=this._getLinePixel(f);f=b.getOffset(e,n.bottom-j-m);j=b.getBoundingClientRect(f);b.destroy();i.extend(f);a.select||i.collapse();this._setSelection(i,!0,!0,function(){c._columnX=e},j.top+m-n.top);return!0}if(m>0){var h=this._getLineHeight(), j=Math.max(1,Math.min(m,Math.floor(j/h)));e=this._columnX;if(e===-1||a.select&&d.isIE)b=this._getLine(m),e=b.getBoundingClientRect(f).left,b.destroy();b=this._getLine(m-j);i.extend(b.getOffset(e,this._getLineHeight(m-j)-1));b.destroy();a.select||i.collapse();a=Math.max(0,n.y-j*h);this._setSelection(i,!0,!0,function(){c._columnX=e},a-n.y)}return!0},_doPaste:function(a){var c=this;return this._getClipboardText(a,function(a){a&&(d.isLinux&&c._lastMouseButton===2&&(new Date).getTime()-c._lastMouseTime<= c._clickTime&&c._setSelectionTo(c._lastMouseX,c._lastMouseY),c._doContent(a))})!==null},_doScroll:function(a){var c=a.type,b=this._model,d=b.getLineCount(),a=this._getClientHeight(),i=this._getLineHeight();d*=i;var f=this._getScroll().y,m;switch(c){case "textStart":m=0;break;case "textEnd":m=d-a;break;case "pageDown":m=f+a;break;case "pageUp":m=f-a;break;case "lineDown":m=f+i;break;case "lineUp":m=f-i;break;case "centerLine":c=this._getSelection(),m=b.getLineAtOffset(c.start),b=(b.getLineAtOffset(c.end)- m+1)*i,m=m*i-a/2+b/2}m!==void 0&&(m=Math.min(Math.max(0,m),d-a),this._scrollViewAnimated(0,m-f,function(){}));return!0},_doSelectAll:function(){var a=this._model,c=this._getSelection();c.setCaret(0);c.extend(a.getCharCount());this._setSelection(c,!1);return!0},_doTab:function(){if(this._tabMode&&!this._readonly){var a="\t";if(this._expandTab)var c=this._model,a=this._getSelection().getCaret(),b=c.getLineAtOffset(a),c=c.getLineStart(b),a=Array(this._tabSize-(a-c)%this._tabSize+1).join(" ");this._doContent(a); return!0}},_doShiftTab:function(){return!this._tabMode||this._readonly?void 0:!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,c=this._getSelection(),b=this.convert({x:this._autoScrollX,y:this._autoScrollY},"page","document"),i=c.getCaret(), f=a.getLineCount(),m=a.getLineAtOffset(i),n;if(this._autoScrollDir==="up"||this._autoScrollDir==="down")i=this._autoScrollY/this._getLineHeight(),i=i<0?Math.floor(i):Math.ceil(i),n=Math.max(0,Math.min(f-1,m+i));else if(this._autoScrollDir==="left"||this._autoScrollDir==="right")n=this._getLineIndex(b.y),m=this._getLine(m),b.x+=m.getBoundingClientRect(i,!1).left,m.destroy();n===0&&(d.isMac||d.isLinux)?c.extend(0):n===f-1&&(d.isMac||d.isLinux)?c.extend(a.getCharCount()):(m=this._getLine(n),c.extend(m.getOffset(b.x, b.y-this._getLinePixel(n))),m.destroy());this._setSelection(c,!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 c=this._model.getLineCount(),b=0;if(a){for(var a=0,d=(new Date).getTime(),i=0;b100)break;this.redrawRulers(0,c);this._queueUpdate()}a=this._getWindow();if(b!==c){var f=this;this._calculateLHTimer=a.setTimeout(function(){f._calculateLHTimer=null;f._calculateLineHeightTimer(!0)},0)}else if(this._calculateLHTimer)a.clearTimeout(this._calculateLHTimer),this._calculateLHTimer=void 0}},_calculateLineHeight:function(a){var a=this._getLine(a),c=a.getBoundingClientRect();a.destroy();return Math.max(1,c.bottom-c.top)},_calculateMetrics:function(){var a=this._clientDiv,c=a.ownerDocument, b=d.createElement(c,"div");b.style.lineHeight="normal";var i={type:"LineStyle",textView:this,0:0,lineText:this._model.getLine(0),lineStart:0};this.onLineStyle(i);k(i.style,b);b.style.position="fixed";b.style.left="-1000px";var f=d.createElement(c,"span");f.appendChild(c.createTextNode(" "));b.appendChild(f);var j=d.createElement(c,"span");j.style.fontStyle="italic";j.appendChild(c.createTextNode(" "));b.appendChild(j);var e=d.createElement(c,"span");e.style.fontWeight="bold";e.appendChild(c.createTextNode(" ")); b.appendChild(e);i=d.createElement(c,"span");i.style.fontWeight="bold";i.style.fontStyle="italic";i.appendChild(c.createTextNode(" "));b.appendChild(i);a.appendChild(b);var h=b.getBoundingClientRect(),f=f.getBoundingClientRect(),j=j.getBoundingClientRect(),e=e.getBoundingClientRect(),i=i.getBoundingClientRect(),f=f.bottom-f.top,j=j.bottom-j.top,e=e.bottom-e.top,q=i.bottom-i.top,B=0,i=h.bottom-h.top<=0,h=Math.max(1,h.bottom-h.top);j>f&&(B=1);e>j&&(B=2);q>e&&(B=3);var r;if(B!==0){r={style:{}};if((B& 1)!==0)r.style.fontStyle="italic";if((B&2)!==0)r.style.fontWeight="bold"}f=n(b);a.removeChild(b);j=m(this._viewDiv);b=d.createElement(c,"div");b.style.position="fixed";b.style.left="-1000px";b.style.paddingLeft=j.left+"px";b.style.paddingTop=j.top+"px";b.style.paddingRight=j.right+"px";b.style.paddingBottom=j.bottom+"px";b.style.width="100px";b.style.height="100px";e=d.createElement(c,"div");e.style.width="100%";e.style.height="100%";b.appendChild(e);a.appendChild(b);c=b.getBoundingClientRect();j= e.getBoundingClientRect();b.style.overflow="hidden";e.style.height="200px";e=b.clientWidth;b.style.overflow="scroll";q=b.clientWidth;a.removeChild(b);j={left:j.left-c.left,top:j.top-c.top,right:c.right-j.right,bottom:c.bottom-j.bottom};return{lineHeight:h,largestFontStyle:r,lineTrim:f,viewPadding:j,scrollWidth:e-q,invalid:i}},_cancelAnimation:function(){if(this._animation)this._animation.stop(),this._animation=null},_clearSelection:function(a){var c=this._getSelection();if(c.isEmpty())return!1;a=== "next"?c.start=c.end:c.end=c.start;this._setSelection(c,!0);return!0},_commitIME:function(){if(this._imeOffset!==-1){this._scrollDiv.focus();this._clientDiv.focus();var a=this._model,c=a.getLineAtOffset(this._imeOffset),b=a.getLineStart(c),d=this._getDOMText(this._getLineNode(c)).text,a=a.getLine(c),b=this._imeOffset-b,a=b+d.length-a.length;b!==a&&this._doContent(d.substring(b,a));this._imeOffset=-1}},_createActions:function(){this.addKeyMode(new o.DefaultKeyMode(this));var c=this;this._actions={noop:{defaultHandler:function(){return c._doNoop()}}, lineUp:{defaultHandler:function(b){return c._doLineUp(a(b,{select:!1}))},actionDescription:{name:l.lineUp}},lineDown:{defaultHandler:function(b){return c._doLineDown(a(b,{select:!1}))},actionDescription:{name:l.lineDown}},lineStart:{defaultHandler:function(b){return c._doHome(a(b,{select:!1,ctrl:!1}))},actionDescription:{name:l.lineStart}},lineEnd:{defaultHandler:function(b){return c._doEnd(a(b,{select:!1,ctrl:!1}))},actionDescription:{name:l.lineEnd}},charPrevious:{defaultHandler:function(b){return c._doCursorPrevious(a(b, {select:!1,unit:"character"}))},actionDescription:{name:l.charPrevious}},charNext:{defaultHandler:function(b){return c._doCursorNext(a(b,{select:!1,unit:"character"}))},actionDescription:{name:l.charNext}},pageUp:{defaultHandler:function(b){return c._doPageUp(a(b,{select:!1}))},actionDescription:{name:l.pageUp}},pageDown:{defaultHandler:function(b){return c._doPageDown(a(b,{select:!1}))},actionDescription:{name:l.pageDown}},scrollPageUp:{defaultHandler:function(b){return c._doScroll(a(b,{type:"pageUp"}))}, actionDescription:{name:l.scrollPageUp}},scrollPageDown:{defaultHandler:function(b){return c._doScroll(a(b,{type:"pageDown"}))},actionDescription:{name:l.scrollPageDown}},scrollLineUp:{defaultHandler:function(b){return c._doScroll(a(b,{type:"lineUp"}))},actionDescription:{name:l.scrollLineUp}},scrollLineDown:{defaultHandler:function(b){return c._doScroll(a(b,{type:"lineDown"}))},actionDescription:{name:l.scrollLineDown}},wordPrevious:{defaultHandler:function(b){return c._doCursorPrevious(a(b,{select:!1, unit:"word"}))},actionDescription:{name:l.wordPrevious}},wordNext:{defaultHandler:function(b){return c._doCursorNext(a(b,{select:!1,unit:"word"}))},actionDescription:{name:l.wordNext}},textStart:{defaultHandler:function(b){return c._doHome(a(b,{select:!1,ctrl:!0}))},actionDescription:{name:l.textStart}},textEnd:{defaultHandler:function(b){return c._doEnd(a(b,{select:!1,ctrl:!0}))},actionDescription:{name:l.textEnd}},scrollTextStart:{defaultHandler:function(b){return c._doScroll(a(b,{type:"textStart"}))}, actionDescription:{name:l.scrollTextStart}},scrollTextEnd:{defaultHandler:function(b){return c._doScroll(a(b,{type:"textEnd"}))},actionDescription:{name:l.scrollTextEnd}},centerLine:{defaultHandler:function(b){return c._doScroll(a(b,{type:"centerLine"}))},actionDescription:{name:l.centerLine}},selectLineUp:{defaultHandler:function(b){return c._doLineUp(a(b,{select:!0}))},actionDescription:{name:l.selectLineUp}},selectLineDown:{defaultHandler:function(b){return c._doLineDown(a(b,{select:!0}))},actionDescription:{name:l.selectLineDown}}, selectWholeLineUp:{defaultHandler:function(b){return c._doLineUp(a(b,{select:!0,wholeLine:!0}))},actionDescription:{name:l.selectWholeLineUp}},selectWholeLineDown:{defaultHandler:function(b){return c._doLineDown(a(b,{select:!0,wholeLine:!0}))},actionDescription:{name:l.selectWholeLineDown}},selectLineStart:{defaultHandler:function(b){return c._doHome(a(b,{select:!0,ctrl:!1}))},actionDescription:{name:l.selectLineStart}},selectLineEnd:{defaultHandler:function(b){return c._doEnd(a(b,{select:!0,ctrl:!1}))}, actionDescription:{name:l.selectLineEnd}},selectCharPrevious:{defaultHandler:function(b){return c._doCursorPrevious(a(b,{select:!0,unit:"character"}))},actionDescription:{name:l.selectCharPrevious}},selectCharNext:{defaultHandler:function(b){return c._doCursorNext(a(b,{select:!0,unit:"character"}))},actionDescription:{name:l.selectCharNext}},selectPageUp:{defaultHandler:function(b){return c._doPageUp(a(b,{select:!0}))},actionDescription:{name:l.selectPageUp}},selectPageDown:{defaultHandler:function(b){return c._doPageDown(a(b, {select:!0}))},actionDescription:{name:l.selectPageDown}},selectWordPrevious:{defaultHandler:function(b){return c._doCursorPrevious(a(b,{select:!0,unit:"word"}))},actionDescription:{name:l.selectWordPrevious}},selectWordNext:{defaultHandler:function(b){return c._doCursorNext(a(b,{select:!0,unit:"word"}))},actionDescription:{name:l.selectWordNext}},selectTextStart:{defaultHandler:function(b){return c._doHome(a(b,{select:!0,ctrl:!0}))},actionDescription:{name:l.selectTextStart}},selectTextEnd:{defaultHandler:function(b){return c._doEnd(a(b, {select:!0,ctrl:!0}))},actionDescription:{name:l.selectTextEnd}},deletePrevious:{defaultHandler:function(b){return c._doBackspace(a(b,{unit:"character"}))},actionDescription:{name:l.deletePrevious}},deleteNext:{defaultHandler:function(b){return c._doDelete(a(b,{unit:"character"}))},actionDescription:{name:l.deleteNext}},deleteWordPrevious:{defaultHandler:function(b){return c._doBackspace(a(b,{unit:"word"}))},actionDescription:{name:l.deleteWordPrevious}},deleteWordNext:{defaultHandler:function(b){return c._doDelete(a(b, {unit:"word"}))},actionDescription:{name:l.deleteWordNext}},deleteLineStart:{defaultHandler:function(b){return c._doBackspace(a(b,{unit:"line"}))},actionDescription:{name:l.deleteLineStart}},deleteLineEnd:{defaultHandler:function(b){return c._doDelete(a(b,{unit:"line"}))},actionDescription:{name:l.deleteLineEnd}},tab:{defaultHandler:function(){return c._doTab()},actionDescription:{name:l.tab}},shiftTab:{defaultHandler:function(){return c._doShiftTab()},actionDescription:{name:l.shiftTab}},enter:{defaultHandler:function(){return c._doEnter()}, actionDescription:{name:l.enter}},enterNoCursor:{defaultHandler:function(b){return c._doEnter(a(b,{noCursor:!0}))},actionDescription:{name:l.enterNoCursor}},selectAll:{defaultHandler:function(){return c._doSelectAll()},actionDescription:{name:l.selectAll}},copy:{defaultHandler:function(){return c._doCopy()},actionDescription:{name:l.copy}},cut:{defaultHandler:function(){return c._doCut()},actionDescription:{name:l.cut}},paste:{defaultHandler:function(){return c._doPaste()},actionDescription:{name:l.paste}}, uppercase:{defaultHandler:function(b){return c._doCase(a(b,{type:"upper"}))},actionDescription:{name:l.uppercase}},lowercase:{defaultHandler:function(b){return c._doCase(a(b,{type:"lower"}))},actionDescription:{name:l.lowercase}},capitalize:{defaultHandler:function(b){return c._doCase(a(b,{unit:"word",type:"capitalize"}))},actionDescription:{name:l.capitalize}},reversecase:{defaultHandler:function(b){return c._doCase(a(b,{type:"reverse"}))},actionDescription:{name:l.reversecase}},toggleOverwriteMode:{defaultHandler:function(){return c._doOverwriteMode()}, actionDescription:{name:l.toggleOverwriteMode}},toggleTabMode:{defaultHandler:function(){return c._doTabMode()},actionDescription:{name:l.toggleTabMode}},toggleWrapMode:{defaultHandler:function(){return c._doWrapMode()},actionDescription:{name:l.toggleWrapMode}}}},_createRuler:function(a,c){if(this._clientDiv){var b=a.getLocation()==="left"?this._leftDiv:this._rightDiv;b.style.display="block";var i=d.createElement(b.ownerDocument,"div");i._ruler=a;i.rulerChanged=!0;i.style.position="relative";i.style.cssFloat= "left";i.style.styleFloat="left";i.style.borderWidth="0px";i.style.margin="0px";i.style.padding="0px";i.style.outline="none";if(c===void 0||c<0||c>=b.children.length)b.appendChild(i);else{for(var f=b.firstChild;f&&--c>0;)f=f.nextSibling;b.insertBefore(i,f)}}},_createView:function(){if(!this._clientDiv){for(var a=this._parent;a.hasChildNodes();)a.removeChild(a.lastChild);var c=a.ownerDocument,b=d.createElement(c,"div");this._rootDiv=b;b.tabIndex=-1;b.style.position="relative";b.style.overflow="hidden"; b.style.width="100%";b.style.height="100%";b.style.overflow="hidden";b.style.WebkitTextSizeAdjust="100%";b.setAttribute("role","application");a.appendChild(b);a=d.createElement(c,"div");a.className="textviewLeftRuler";this._leftDiv=a;a.tabIndex=-1;a.style.overflow="hidden";a.style.MozUserSelect="none";a.style.WebkitUserSelect="none";a.style.position="absolute";a.style.top="0px";a.style.bottom="0px";a.style.cursor="default";a.style.display="none";a.setAttribute("aria-hidden","true");b.appendChild(a); a=d.createElement(c,"div");a.className="textviewScroll";this._viewDiv=a;a.tabIndex=-1;a.style.overflow="auto";a.style.position="absolute";a.style.top="0px";a.style.bottom="0px";a.style.borderWidth="0px";a.style.margin="0px";a.style.outline="none";a.style.background="transparent";if(d.isMac&&d.isWebkit)a.style.pointerEvents="none",a.style.zIndex="2";b.appendChild(a);var i=d.createElement(c,"div");i.className="textviewRightRuler";this._rightDiv=i;i.tabIndex=-1;i.style.display="none";i.style.overflow= "hidden";i.style.MozUserSelect="none";i.style.WebkitUserSelect="none";i.style.position="absolute";i.style.top="0px";i.style.bottom="0px";i.style.cursor="default";i.style.right="0px";i.setAttribute("aria-hidden","true");b.appendChild(i);this._scrollDiv=i=d.createElement(c,"div");i.style.margin="0px";i.style.borderWidth="0px";i.style.padding="0px";a.appendChild(i);if(d.isFirefox)this._clipboardDiv=a=d.createElement(c,"div"),a.style.position="fixed",a.style.whiteSpace="pre",a.style.left="-1000px",b.appendChild(a); if(!d.isIE&&!d.isIOS)this._clipDiv=a=d.createElement(c,"div"),a.style.position="absolute",a.style.overflow="hidden",a.style.margin="0px",a.style.borderWidth="0px",a.style.padding="0px",a.style.background="transparent",b.appendChild(a),this._clipScrollDiv=i=d.createElement(c,"div"),i.style.position="absolute",i.style.height="1px",i.style.top="-1000px",i.style.background="transparent",a.appendChild(i);this._setFullSelection(this._fullSelection,!0);a=d.createElement(c,"div");a.className="textviewContent"; this._clientDiv=a;a.style.position="absolute";a.style.borderWidth="0px";a.style.margin="0px";a.style.padding="0px";a.style.outline="none";a.style.zIndex="1";a.style.WebkitUserSelect="text";a.setAttribute("spellcheck","false");if(d.isIOS||d.isAndroid)a.style.WebkitTapHighlightColor="transparent";(this._clipDiv||b).appendChild(a);if(d.isIOS||d.isAndroid)this._vScrollDiv=i=d.createElement(c,"div"),i.style.position="absolute",i.style.borderWidth="1px",i.style.borderColor="white",i.style.borderStyle="solid", i.style.borderRadius="4px",i.style.backgroundColor="black",i.style.opacity="0.5",i.style.margin="0px",i.style.padding="0px",i.style.outline="none",i.style.zIndex="3",i.style.width="8px",i.style.display="none",b.appendChild(i),this._hScrollDiv=i=d.createElement(c,"div"),i.style.position="absolute",i.style.borderWidth="1px",i.style.borderColor="white",i.style.borderStyle="solid",i.style.borderRadius="4px",i.style.backgroundColor="black",i.style.opacity="0.5",i.style.margin="0px",i.style.padding="0px", i.style.outline="none",i.style.zIndex="3",i.style.height="8px",i.style.display="none",b.appendChild(i);if(d.isFirefox&&!a.setCapture)this._overlayDiv=c=d.createElement(c,"div"),c.style.position=a.style.position,c.style.borderWidth=a.style.borderWidth,c.style.margin=a.style.margin,c.style.padding=a.style.padding,c.style.cursor="text",c.style.zIndex="2",(this._clipDiv||b).appendChild(c);a.contentEditable="true";a.setAttribute("role","textbox");a.setAttribute("aria-multiline","true");this._setWrapMode(this._wrapMode, !0);this._setReadOnly(this._readonly);this._setThemeClass(this._themeClass,!0);this._setTabSize(this._tabSize,!0);this._hookEvents();b=this._rulers;for(c=0;cthis._getLineHeight()){var a=c.getBoundingClientRect(),b=this._clientDiv.getBoundingClientRect();a.bottom>b.bottom&&(c=this._getLinePrevious(c)|| c)}return c.lineIndex},_getBoundsAtOffset:function(a){var c=this._getLine(this._model.getLineAtOffset(a)),a=c.getBoundingClientRect(a),b=this._getLinePixel(c.lineIndex);a.top+=b;a.bottom+=b;c.destroy();return a},_getClientHeight:function(){var a=this._getViewPadding();return Math.max(0,this._viewDiv.clientHeight-a.top-a.bottom)},_getClientWidth:function(){var a=this._getViewPadding();return Math.max(0,this._viewDiv.clientWidth-a.left-a.right)},_getClipboardText:function(a,c){var b=this._model.getLineDelimiter(), f,m,n=this._getWindow();if(n.clipboardData)return f=[],m=n.clipboardData.getData("Text"),i(m,function(a){f.push(a)},function(){f.push(b)}),m=f.join(""),c&&c(m),m;if(d.isFirefox){this._ignoreFocus=!0;var j=this._clipboardDiv;j.innerHTML="
";j.firstChild.focus();var e=this,h=function(){var a=e._getTextFromElement(j);j.innerHTML="";f=[];i(a,function(a){f.push(a)},function(){f.push(b)});return f.join("")},k=!1;this._ignorePaste=!0;if(!d.isLinux||this._lastMouseButton!==2)try{k=
j.ownerDocument.execCommand("paste",!1,null)}catch(q){k=j.childNodes.length>1||j.firstChild&&j.firstChild.childNodes.length>0}this._ignorePaste=!1;if(!k)return a?(n.setTimeout(function(){e.focus();(m=h())&&c&&c(m);e._ignoreFocus=!1},0),null):(this.focus(),this._ignoreFocus=!1,"");this.focus();this._ignoreFocus=!1;(m=h())&&c&&c(m);return m}return a&&a.clipboardData?(f=[],m=a.clipboardData.getData("text/plain"),i(m,function(a){f.push(a)},function(){f.push(b)}),(m=f.join(""))&&c&&c(m),m):""},_getDOMText:function(a,
c){for(var b=a.firstChild,d="",i=0;b;){var f;if(!b.ignore)if(b.ignoreChars){f=b.lastChild;for(var m=0,n=[],j=-1;f;){for(var e=f.data,h=e.length-1;h>=0;h--){var k=e.substring(h,h+1);mc)for(;c=a;c--)b-=this._getLineHeight(c);return b}return this._getLineHeight()*a},_getLineIndex:function(a){var c,b=0,d=this._model.getLineCount();if(this._lineHeight){var b=this._getTopIndex(),
i=-this._topIndexY+this._getScroll().y;if(a!==i)if(a0;)a+=this._getLineHeight(--b);else for(c=this._getLineHeight(b);a-c>=i&&b
this._getLineHeight()){var a=c.getBoundingClientRect(),b=this._getViewPadding(),d=this._viewDiv.getBoundingClientRect();a.top=15))(i=j.MutationObserver||j.MozMutationObserver)?(this._mutationObserver=new i(function(c){a._handleDataModified(c)}),this._mutationObserver.observe(b,{subtree:!0,characterData:!0})):
c.push({target:this._clientDiv,type:"DOMCharacterDataModified",handler:function(c){return a._handleDataModified(c?c:j.event)}});this._overlayDiv&&(c.push({target:this._overlayDiv,type:"mousedown",handler:function(c){return a._handleMouseDown(c?c:j.event)}}),c.push({target:this._overlayDiv,type:"mouseover",handler:function(c){return a._handleMouseOver(c?c:j.event)}}),c.push({target:this._overlayDiv,type:"mouseout",handler:function(c){return a._handleMouseOut(c?c:j.event)}}),c.push({target:this._overlayDiv,
type:"contextmenu",handler:function(c){return a._handleContextMenu(c?c:j.event)}}));this._isW3CEvents||c.push({target:this._clientDiv,type:"dblclick",handler:function(c){return a._handleDblclick(c?c:j.event)}})}i=this._leftDiv;f=this._rightDiv;d.isIE&&c.push({target:i,type:"selectstart",handler:function(){return!1}});c.push({target:i,type:d.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(c){return a._handleMouseWheel(c?c:j.event)}});c.push({target:i,type:"click",handler:function(c){a._handleRulerEvent(c?
c:j.event)}});c.push({target:i,type:"dblclick",handler:function(c){a._handleRulerEvent(c?c:j.event)}});c.push({target:i,type:"mousemove",handler:function(c){a._handleRulerEvent(c?c:j.event)}});c.push({target:i,type:"mouseover",handler:function(c){a._handleRulerEvent(c?c:j.event)}});c.push({target:i,type:"mouseout",handler:function(c){a._handleRulerEvent(c?c:j.event)}});d.isIE&&c.push({target:f,type:"selectstart",handler:function(){return!1}});c.push({target:f,type:d.isFirefox?"DOMMouseScroll":"mousewheel",
handler:function(c){return a._handleMouseWheel(c?c:j.event)}});c.push({target:f,type:"click",handler:function(c){a._handleRulerEvent(c?c:j.event)}});c.push({target:f,type:"dblclick",handler:function(c){a._handleRulerEvent(c?c:j.event)}});c.push({target:f,type:"mousemove",handler:function(c){a._handleRulerEvent(c?c:j.event)}});c.push({target:f,type:"mouseover",handler:function(c){a._handleRulerEvent(c?c:j.event)}});c.push({target:f,type:"mouseout",handler:function(c){a._handleRulerEvent(c?c:j.event)}});
for(i=0;i=9)&&typeof c.ownerDocument.createRange().getBoundingClientRect==="function";this._isW3CEvents=c.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()},_modifyContent:function(a,c){if(!this._readonly||a._code)if(a.type="Verify",this.onVerify(a),!(a.text===null||a.text===void 0)){var b=this._model;try{if(a._ignoreDOMSelection)this._ignoreDOMSelection=
!0;b.setText(a.text,a.start,a.end)}finally{if(a._ignoreDOMSelection)this._ignoreDOMSelection=!1}c&&(b=this._getSelection(),b.setCaret(a.start+a.text.length),this._setSelection(b,!0));this.onModify({type:"Modify"})}},_onModelChanged:function(a){a.type="ModelChanged";this.onModelChanged(a);a.type="Changed";var c=a.start,b=a.addedCharCount,d=a.removedCharCount,i=a.addedLineCount,f=a.removedLineCount,m=this._getSelection();m.end>c&&(m.end>c&&m.startc+f)b.lineIndex=d+i-f,b._line.lineIndex=b.lineIndex;b=this._getLineNext(b)}this._lineHeight&&(a=[c,f].concat(Array(i)),Array.prototype.splice.apply(this._lineHeight,a));if(!this._wrapMode&&c<=this._maxLineIndex&&this._maxLineIndex<=c+f)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,c){if(this._wrapMode||this._variableLineHeight){if(a!==void 0&&c!==void 0)for(var b=a;b0&&e.removeAllRanges();e.addRange(n);var h=this,n=function(){j&&j.parentNode===
h._clientDiv&&h._clientDiv.removeChild(j);h._updateDOMSelection()},e=!1;this._ignoreCopy=!0;try{e=f.execCommand("copy",!1,null)}catch(k){}this._ignoreCopy=!1;if(!e&&c)return m.setTimeout(n,0),!1;n();return!0},_setDOMSelection:function(a,c,b,i,f){for(var m,j,n,e,h=0,k=a.firstChild,q,r,l=this._model.getLine(a.lineIndex).length;k;){if(!k.ignore){q=k.firstChild;r=q.length;k.ignoreChars&&(r-=k.ignoreChars);if(h+r>c||h+r>=l){m=q;j=c-h;k.ignoreChars&&r>0&&j===r&&(j+=k.ignoreChars);break}h+=r}k=k.nextSibling}for(var h=
0,k=b.firstChild,o=this._model.getLine(b.lineIndex).length;k;){if(!k.ignore){q=k.firstChild;r=q.length;k.ignoreChars&&(r-=k.ignoreChars);if(r+h>i||h+r>=o){n=q;e=i-h;k.ignoreChars&&r>0&&e===r&&(e+=k.ignoreChars);break}h+=r}k=k.nextSibling}this._setDOMFullSelection(a,c,l,b,i,o);a=this._getWindow();c=this._parent.ownerDocument;if(a.getSelection){b=a.getSelection();a=c.createRange();a.setStart(m,j);a.setEnd(n,e);if(this._hasFocus&&(b.anchorNode!==m||b.anchorOffset!==j||b.focusNode!==n||b.focusOffset!==
e||b.anchorNode!==n||b.anchorOffset!==e||b.focusNode!==m||b.focusOffset!==j))this._ignoreSelect=!1,b.rangeCount>0&&b.removeAllRanges(),b.addRange(a),this._ignoreSelect=!0;if(this._cursorDiv&&(a=c.createRange(),f?(a.setStart(m,j),a.setEnd(m,j)):(a.setStart(n,e),a.setEnd(n,e)),n=a.getClientRects()[0],e=this._cursorDiv.parentNode,m=e.getBoundingClientRect(),n&&m))this._cursorDiv.style.top=n.top-m.top+e.scrollTop+"px",this._cursorDiv.style.left=n.left-m.left+e.scrollLeft+"px"}else if(c.selection&&this._hasFocus)f=
c.body,a=d.createElement(c,"div"),f.appendChild(a),f.removeChild(a),a=f.createTextRange(),a.moveToElementText(m.parentNode),a.moveStart("character",j),m=f.createTextRange(),m.moveToElementText(n.parentNode),m.moveStart("character",e),a.setEndPoint("EndToStart",m),this._ignoreSelect=!1,a.select(),this._ignoreSelect=!0},_setDOMFullSelection:function(a,c,b,d,i){if(this._selDiv1&&(b=this._selDiv1,b.style.width="0px",b.style.height="0px",b=this._selDiv2,b.style.width="0px",b.style.height="0px",b=this._selDiv3,
b.style.width="0px",b.style.height="0px",!(a===d&&c===i))){var f=this._model,m=this._getViewPadding(),j=this._clientDiv.getBoundingClientRect(),n=this._viewDiv.getBoundingClientRect(),b=n.left+m.left,e=j.right,m=n.top+m.top,h=j.bottom,n=j=0;this._clipDiv?(n=this._clipDiv.getBoundingClientRect(),j=n.left-this._clipDiv.scrollLeft):(n=this._rootDiv.getBoundingClientRect(),j=n.left);n=n.top;this._ignoreDOMSelection=!0;var a=(new r(this,a.lineIndex,a)).getBoundingClientRect(f.getLineStart(a.lineIndex)+
c,!1),k=a.left,i=(new r(this,d.lineIndex,d)).getBoundingClientRect(f.getLineStart(d.lineIndex)+i,!1),c=i.left;this._ignoreDOMSelection=!1;var f=this._selDiv1,k=Math.min(e,Math.max(b,k)),q=Math.min(h,Math.max(m,a.top)),l=e,d=Math.min(h,Math.max(m,a.bottom));f.style.left=k-j+"px";f.style.top=q-n+"px";f.style.width=Math.max(0,l-k)+"px";f.style.height=Math.max(0,d-q)+"px";if(a.top===i.top)l=Math.min(c,e),f.style.width=Math.max(0,l-k)+"px";else if(a=Math.min(h,Math.max(m,i.top)),c=Math.min(e,Math.max(b,
c)),m=Math.min(h,Math.max(m,i.bottom)),h=this._selDiv3,h.style.left=b-j+"px",h.style.top=a-n+"px",h.style.width=Math.max(0,c-b)+"px",h.style.height=Math.max(0,m-a)+"px",a-d>0)m=this._selDiv2,m.style.left=b-j+"px",m.style.top=d-n+"px",m.style.width=Math.max(0,e-b)+"px",m.style.height=Math.max(0,a-d)+"px"}},_setGrab:function(a){if(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;if(d.isIE&&a)this._hadFocus=this._hasFocus;var c=this._clientDiv;c.contentEditable=!a;this._hadFocus&&!a&&c.focus();if(this._overlayDiv)this._overlayDiv.style.zIndex=a?"-1":"1";for(a=this._getLineNext();a;){if(a.hasLink)for(c=a.firstChild;c;)if(c.ignore)c=c.nextSibling;else{var b=c.nextSibling,i=c.viewStyle;i&&i.tagName&&i.tagName.toLowerCase()==="a"&&a.replaceChild(a._line._createSpan(a,c.firstChild.data,i),c);c=b}a=this._getLineNext(a)}this._updateDOMSelection()}},
_setSelection:function(a,c,b,d,i){if(a){this._columnX=-1;b===void 0&&(b=!0);var f=this._selection;this._selection=a;c!==!1&&this._showCaret(!1,d,c,i);b&&this._updateDOMSelection();if(!f.equals(a))this.onSelection({type:"Selection",oldValue:{start:f.start,end:f.end},newValue:{start:a.start,end:a.end}})}},_setSelectionTo:function(a,c,b,d){var i=this._model,f=this._getSelection(),c=this.convert({x:a,y:c},"page","document"),a=this._getLineIndex(c.y);if(this._clickCount===1){i=this._getLine(a);a=i.getOffset(c.x,
c.y-this._getLinePixel(a));i.destroy();if(d&&!b&&f.start<=a&&a=this._doubleClickSelection.start?(b=this._doubleClickSelection.start,d=i.getNextOffset(a,{unit:"wordend",count:1})):(b=i.getNextOffset(a,{unit:"word",count:-1}),d=this._doubleClickSelection.end):(b=i.getNextOffset(a,{unit:"word",count:-1}),d=i.getNextOffset(b,
{unit:"wordend",count:1})),i.destroy()):this._doubleClickSelection?(d=i.getLineAtOffset(this._doubleClickSelection.start),a>=d?(b=i.getLineStart(d),d=i.getLineEnd(a)):(b=i.getLineStart(a),d=i.getLineEnd(d))):(b=i.getLineStart(a),d=i.getLineEnd(a)),f.setCaret(b),f.extend(d);this._setSelection(f,!0,!0);return!0},_setFullSelection:function(a,c){this._fullSelection=a;if(d.isWebkit)this._fullSelection=!0;var b=this._clipDiv||this._rootDiv;if(b)if(this._fullSelection){if(!this._selDiv1&&this._fullSelection&&
!d.isIOS){var i=b.ownerDocument;this._highlightRGB=d.isWebkit?"transparent":"Highlight";var f=d.createElement(i,"div");this._selDiv1=f;f.style.position="absolute";f.style.borderWidth="0px";f.style.margin="0px";f.style.padding="0px";f.style.outline="none";f.style.background=this._highlightRGB;f.style.width="0px";f.style.height="0px";f.style.zIndex="0";b.appendChild(f);var m=d.createElement(i,"div");this._selDiv2=m;m.style.position="absolute";m.style.borderWidth="0px";m.style.margin="0px";m.style.padding=
"0px";m.style.outline="none";m.style.background=this._highlightRGB;m.style.width="0px";m.style.height="0px";m.style.zIndex="0";b.appendChild(m);this._selDiv3=i=d.createElement(i,"div");i.style.position="absolute";i.style.borderWidth="0px";i.style.margin="0px";i.style.padding="0px";i.style.outline="none";i.style.background=this._highlightRGB;i.style.width="0px";i.style.height="0px";i.style.zIndex="0";b.appendChild(i);if(d.isFirefox&&d.isMac){b=this._getWindow().getComputedStyle(i,null).getPropertyValue("background-color");
switch(b){case "rgb(119, 141, 168)":b="rgb(199, 208, 218)";break;case "rgb(127, 127, 127)":b="rgb(198, 198, 198)";break;case "rgb(255, 193, 31)":b="rgb(250, 236, 115)";break;case "rgb(243, 70, 72)":b="rgb(255, 176, 139)";break;case "rgb(255, 138, 34)":b="rgb(255, 209, 129)";break;case "rgb(102, 197, 71)":b="rgb(194, 249, 144)";break;case "rgb(140, 78, 184)":b="rgb(232, 184, 255)";break;default:b="rgb(180, 213, 255)"}this._highlightRGB=b;f.style.background=b;m.style.background=b;i.style.background=
b}c||this._updateDOMSelection()}}else{if(this._selDiv1)b.removeChild(this._selDiv1),this._selDiv1=null;if(this._selDiv2)b.removeChild(this._selDiv2),this._selDiv2=null;if(this._selDiv3)b.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=
d.createElement(document,"div");a.className="textviewBlockCursor";this._cursorDiv=a;a.tabIndex=-1;a.style.zIndex="2";a.style.color="transparent";a.style.position="absolute";a.style.pointerEvents="none";a.innerHTML=" ";this._viewDiv.appendChild(a);this._updateDOMSelection()}}else if(this._cursorDiv)this._cursorDiv.parentNode.removeChild(this._cursorDiv),this._cursorDiv=null},_setReadOnly:function(a){this._readonly=a;this._clientDiv.setAttribute("aria-readonly",a?"true":"false")},_setTabSize:function(a,
c){this._tabSize=a;this._customTabSize=void 0;var b=this._clientDiv;if(d.isOpera){if(b)b.style.OTabSize=this._tabSize+""}else if(d.isWebkit>=537.1){if(b)b.style.tabSize=this._tabSize+""}else if(d.isFirefox>=4){if(b)b.style.MozTabSize=this._tabSize+""}else if(this._tabSize!==8)this._customTabSize=this._tabSize;c||(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,c){this._themeClass=a;var b="textview",i=this._theme.getThemeClass();i&&(b+=" "+i);this._themeClass&&i!==this._themeClass&&(b+=" "+this._themeClass);this._rootDiv.className=b;this._updateStyle(c)},_setWrapMode:function(a,c){this._wrapMode=a&&this._wrappable;var b=this._clientDiv,i=this._viewDiv;a?(b.style.whiteSpace="pre-wrap",b.style.wordWrap="break-word",i.style.overflowX="hidden",i.style.overflowY="scroll"):
(b.style.whiteSpace="pre",b.style.wordWrap="normal",i.style.overflowX="auto",i.style.overflowY="auto");c||(this.redraw(),this._resetLineWidth());this._resetLineHeight()},_showCaret:function(a,c,b,i){if(this._clientDiv){var d=this._model,f=this._getSelection(),m=this._getScroll(),j=f.getCaret(),n=f.start,e=f.end,h=d.getLineAtOffset(e),k=Math.max(Math.max(n,d.getLineStart(h)),e-1),d=this._getClientWidth(),h=this._getClientHeight(),q=d/4,r=this._getBoundsAtOffset(j===n?n:k),l=r.left,o=r.right,t=r.top,
p=r.bottom;a&&!f.isEmpty()&&(r=this._getBoundsAtOffset(j===e?n:k),r.top===t?j===n?o=l+Math.min(r.right-l,d):l=o-Math.min(o-r.left,d):j===n?p=t+Math.min(r.bottom-t,h):t=p-Math.min(p-r.top,h));a=0;lm.x+d&&(a=Math.max(o-m.x-d,q));f=0;tm.y+h&&(f=p-m.y-h);i&&(i>0?f>0&&(f=Math.max(f,i)):f<0&&(f=Math.min(f,i)));if(a!==0||f!==0)return f!==0&&typeof b==="number"&&(b<0&&(b=0),b>1&&(b=1),f+=Math.floor(f>0?b*h:-b*h)),this._scrollViewAnimated(a,f,c),h!==this._getClientHeight()||
d!==this._getClientWidth()?this._showCaret():this._ensureCaretVisible=!0,!0;else c&&c();return!1}},_startIME:function(){if(this._imeOffset===-1){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;af.lineIndex?(m=f,b=0):(m=this._getLineNode(b),b=a.start-c.getLineStart(b));if.lineIndex?(d=f,c=0):(d=this._getLineNode(i),c=a.end-c.getLineStart(i));this._setDOMSelection(m,b,d,c,a.caret)}}},_update:function(a){if(!(this._redrawCount>0)){if(this._updateTimer)this._getWindow().clearTimeout(this._updateTimer),this._updateTimer=null,a=!1;var c=this._clientDiv;if(c){if(this._metrics.invalid)this._ignoreQueueUpdate=
!0,this._updateStyle(),this._ignoreQueueUpdate=!1;var b=this._model,i=this._getScroll(!1),f=this._getViewPadding(),m=b.getLineCount(),j=this._getLineHeight(),n=this._getClientWidth();if(this._wrapMode)c.style.width=n+"px";var e,h,k,q,l=0,o=0;if(this._lineHeight){for(;oi.y)break;l+=h;o++}e=o;h=Math.max(0,e-1);k=b=i.y-l;e>0&&(b+=this._getLineHeight(e-1))}else q=Math.max(0,i.y)/j,e=Math.floor(q),h=Math.max(0,e-1),b=Math.round((q-h)*j),k=Math.round((q-e)*j);this._topIndexY=
k;q=this._parent;var t=q.clientWidth,p=q.clientHeight;q=this._getClientHeight();if(a){j=0;this._leftDiv&&(e=this._leftDiv.getBoundingClientRect(),j=e.right-e.left);e=n;for(this._wrapMode||(e=Math.max(this._maxLineWidth,e));ov)(new r(this,v)).create(A,null);else{A.firstChild&&(c.insertBefore(A,w),A=y.createDocumentFragment());if(w&&w.lineChanged)w=(new r(this,v)).create(A,w),w.lineChanged=!1;w=this._getLineNext(w)}A.firstChild&&c.insertBefore(A,w);if(d.isWebkit&&!this._wrapMode)c.style.width="0x7fffffffpx";w=this._getLineNext();v=q+b;for(A=!1;w;){h=w.lineWidth;if(h===
void 0)if(y=w._line.getBoundingClientRect(),h=w.lineWidth=Math.ceil(y.right-y.left),y=y.bottom-y.top,this._lineHeight)this._lineHeight[w.lineIndex]=y;else if(j!==0&&y!==0&&Math.ceil(j)!==Math.ceil(y))this._variableLineHeight=!0,this._lineHeight=[],this._lineHeight[w.lineIndex]=y;if(this._lineHeight&&!A&&(v-=this._lineHeight[w.lineIndex],v<0))k=w.lineIndex,A=!0;if(!this._wrapMode){if(h>=this._maxLineWidth)this._maxLineWidth=h,this._maxLineIndex=w.lineIndex;if(this._checkMaxLineIndex===w.lineIndex)this._checkMaxLineIndex=
-1}if(w.lineIndex===e)this._topChild=w;if(w.lineIndex===k)this._bottomChild=w;w=this._getLineNext(w)}if(this._checkMaxLineIndex!==-1&&(v=this._checkMaxLineIndex,this._checkMaxLineIndex=-1,0<=v&&v=this._maxLineWidth)this._maxLineWidth=h,this._maxLineIndex=v;j.destroy()}for(;o=9)&&this._maxLineWidth>n)l+=f.right+f.left;i.style.width=l+"px";if(this._clipScrollDiv)this._clipScrollDiv.style.width=l+"px";i=this._getScroll(!1)}if(this._vScrollDiv)l=q-8,o=Math.max(15,Math.ceil(Math.min(1,l/(m+f.top+
f.bottom))*l)),this._vScrollDiv.style.left=j+n-8+"px",this._vScrollDiv.style.top=Math.floor(Math.max(0,i.y*l/m))+"px",this._vScrollDiv.style.height=o+"px";if(!this._wrapMode&&this._hScrollDiv)l=n-8,o=Math.max(15,Math.ceil(Math.min(1,l/(this._maxLineWidth+f.left+f.right))*l)),this._hScrollDiv.style.left=j+Math.floor(Math.max(0,Math.floor(i.x*l/this._maxLineWidth)))+"px",this._hScrollDiv.style.top=q-9+"px",this._hScrollDiv.style.width=o+"px";w=i.x;h=this._clipDiv;l=this._overlayDiv;if(h){h.scrollLeft=
w;h.scrollTop=0;o=j+f.left;k=f.top;a=n;j=q;w=0;v=-b;if(i.x===0)o-=f.left,a+=f.left,w=f.left;i.x+n===e&&(a+=f.right);i.y===0&&(k-=f.top,j+=f.top,v+=f.top);i.y+q===m&&(j+=f.bottom);h.style.left=o+"px";h.style.top=k+"px";h.style.right=t-a-o+"px";h.style.bottom=p-j-k+"px";c.style.left=w+"px";c.style.top=v+"px";c.style.width=e+"px";c.style.height=q+b+"px";if(l)l.style.left=c.style.left,l.style.top=c.style.top,l.style.width=c.style.width,l.style.height=c.style.height}else{o=w;k=b;t=w+n;p=b+q;o===0&&(o-=
f.left);k===0&&(k-=f.top);t===e&&(t+=f.right);i.y+q===m&&(p+=f.bottom);c.style.clip="rect("+k+"px,"+t+"px,"+p+"px,"+o+"px)";c.style.left=-w+j+f.left+"px";c.style.width=(d.isWebkit?e:n+w)+"px";if(!a)c.style.top=-b+f.top+"px",c.style.height=q+b+"px";if(l&&(l.style.clip=c.style.clip,l.style.left=c.style.left,l.style.width=c.style.width,!a))l.style.top=c.style.top,l.style.height=c.style.height}this._updateDOMSelection();c=this._ensureCaretVisible;this._ensureCaretVisible=!1;q!==this._getClientHeight()&&
(this._update(),c&&this._showCaret())}}},_updateRuler:function(a,c,b,i){if(a)for(var f=this._parent.ownerDocument,m=this._getLineHeight(),j=this._getViewPadding(),a=a.firstChild;a;){var n=a._ruler,e=m,h=n.getOverview();h==="page"&&(e+=this._topIndexY);a.style.top=-e+"px";a.style.height=i+e+"px";a.rulerChanged&&k(n.getRulerStyle(),a);var q,r=a.firstChild;r?(q=r,r=r.nextSibling):(q=d.createElement(f,"div"),q.style.visibility="hidden",a.appendChild(q));var l;if(a.rulerChanged&&q){e=-1;if(l=n.getWidestAnnotation())if(k(l.style,
q),l.html)q.innerHTML=l.html;q.lineIndex=e;q.style.height=m+j.top+"px"}var o;if(h==="page"){for(n=n.getAnnotations(c,b+1);r;)e=r.lineIndex,l=r.nextSibling,(!(c<=e&&e<=b)||r.lineChanged)&&a.removeChild(r),r=l;r=a.firstChild.nextSibling;o=f.createDocumentFragment();for(e=c;e<=b;e++)if(!r||r.lineIndex>e){q=d.createElement(f,"div");if(l=n[e]){k(l.style,q);if(l.html)q.innerHTML=l.html;q.annotation=l}q.lineIndex=e;q.style.height=this._getLineHeight(e)+"px";o.appendChild(q)}else if(o.firstChild&&(a.insertBefore(o,
r),o=f.createDocumentFragment()),r)r=r.nextSibling;o.firstChild&&a.insertBefore(o,r)}else{l=this._getClientHeight();e=this._model.getLineCount();r=l+j.top+j.bottom-2*this._metrics.scrollWidth;h=m*e1;)a.removeChild(a.lastChild),l--;n=n.getAnnotations(0,e);o=f.createDocumentFragment();for(var t in n)if(e=t>>>0,!(e<0)){q=d.createElement(f,"div");l=n[t];k(l.style,q);q.style.position="absolute";q.style.top=this._metrics.scrollWidth+m+Math.floor(e*
h)+"px";if(l.html)q.innerHTML=l.html;q.annotation=l;q.lineIndex=e;o.appendChild(q)}a.appendChild(o)}else if(a._oldTrackHeight!==r)for(q=a.firstChild?a.firstChild.nextSibling:null;q;)q.style.top=this._metrics.scrollWidth+m+Math.floor(q.lineIndex*h)+"px",q=q.nextSibling;a._oldTrackHeight=r}a.rulerChanged=!1;a=a.nextSibling}},_updateStyleSheet:function(){var a="";d.isWebkit&&this._metrics.scrollWidth>0&&(a+="\n.textview ::-webkit-scrollbar-corner {background: #eeeeee;}");d.isFirefox&&d.isMac&&this._highlightRGB&&
this._highlightRGB!=="Highlight"&&(a+="\n.textview ::-moz-selection {background: "+this._highlightRGB+";}");if(a){var c=document.getElementById("_textviewStyle");if(c)c.removeChild(c.firstChild),c.appendChild(document.createTextNode(a));else{c=d.createElement(document,"style");c.id="_textviewStyle";var b=document.getElementsByTagName("head")[0]||document.documentElement;c.appendChild(document.createTextNode(a));b.insertBefore(c,b.firstChild)}}},_updateStyle:function(a){if(!a&&d.isIE)this._rootDiv.style.lineHeight=
"normal";var c=this._metrics=this._calculateMetrics();this._rootDiv.style.lineHeight=d.isIE?c.lineHeight-(c.lineTrim.top+c.lineTrim.bottom)+"px":"normal";this._updateStyleSheet();a||(this.redraw(),this._resetLineWidth())}};e.EventTarget.addMixin(t.prototype);return{TextView:t}});
define("orion/editor/projectionTextModel",["orion/editor/textModel","orion/editor/eventTarget"],function(l,p){function o(e){this._model=e;this._projections=[]}o.prototype={addProjection:function(e){if(e){var b=this._model,d=this._projections;e._lineIndex=b.getLineAtOffset(e.start);e._lineCount=b.getLineAtOffset(e.end)-e._lineIndex;var h=e.text;h||(h="");e._model=typeof h==="string"?new l.TextModel(h,b.getLineDelimiter()):h;var b=this.mapOffset(e.start,!0),h=e.end-e.start,k=e._lineCount,f=e._model.getCharCount(),
a=e._model.getLineCount()-1;this.onChanging({type:"Changing",text:e._model.getText(),start:b,removedCharCount:h,addedCharCount:f,removedLineCount:k,addedLineCount:a});var c=this._binarySearch(d,e.start);d.splice(c,0,e);this.onChanged({type:"Changed",start:b,removedCharCount:h,addedCharCount:f,removedLineCount:k,addedLineCount:a})}},getProjections:function(){return this._projections.slice(0)},getBaseModel:function(){return this._model},mapOffset:function(e,b){var d=this._projections,h=0,k,f;if(b){for(k=
0;ke)break;if(f.end>e)return-1;h+=f._model.getCharCount()-(f.end-f.start)}return e+h}for(k=0;ke-h)break;var a=f._model.getCharCount();if(f.start+a>e-h)return-1;h+=a-(f.end-f.start)}return e-h},removeProjection:function(e){var b,d=0;for(b=0;b1;)k=Math.floor((d+h)/2),b<=e[k].start?d=k:h=k;return d},getCharCount:function(){for(var e=
this._model.getCharCount(),b=this._projections,d=0;d=e-k)break;i=m._model.getLineCount()-1;if(m._lineIndex+i>=e-k)if(a=e-(m._lineIndex+k),ae-k)break;f.push(d.getText(a,m.start));i=m._model.getLineCount()-1;if(m._lineIndex+i>e-k)return f.push(m._model.getLine(0,b)),f.join("");f.push(m._model.getText());a=m.end;k+=i-m._lineCount}h=d.getLineEnd(e-k,b);ae-h)break;var c=a._model.getCharCount();if(a.start+c>e-h){d=e-(a.start+h);k+=a._model.getLineAtOffset(d);
h+=d;break}k+=a._model.getLineCount()-1-a._lineCount;h+=c-(a.end-a.start)}return b.getLineAtOffset(e-h)+k},getLineCount:function(){for(var e=this._projections,b=this._model.getLineCount(),d=0;de-k)break;var i=c._model.getLineCount()-
1;if(c._lineIndex+i>e-k)return c._model.getLineEnd(e-(c._lineIndex+k),b)+c.start+f;f+=c._model.getCharCount()-(c.end-c.start);k+=i-c._lineCount}return d.getLineEnd(e-k,b)+f},getLineStart:function(e){if(e<0)return-1;for(var b=this._model,d=this._projections,h=0,k=0,f=0;f=e-h)break;var c=a._model.getLineCount()-1;if(a._lineIndex+c>=e-h)return a._model.getLineStart(e-(a._lineIndex+h))+a.start+k;k+=a._model.getCharCount()-(a.end-a.start);h+=c-a._lineCount}return b.getLineStart(e-
h)+k},getText:function(e,b){e===void 0&&(e=0);var d=this._model,h=this._projections,k=0,f=[],a,c,i;for(a=0;ae-k)break;i=c._model.getCharCount();if(c.start+i>e-k)if(b!==void 0&&c.start+i>b-k)return c._model.getText(e-(c.start+k),b-(c.start+k));else f.push(c._model.getText(e-(c.start+k))),e=c.end+k+i-(c.end-c.start);k+=i-(c.end-c.start)}var m=e-k;if(b!==void 0){for(;ab-k)break;f.push(d.getText(m,c.start));i=c._model.getCharCount();if(c.start+
i>b-k)return f.push(c._model.getText(0,b-(c.start+k))),f.join("");f.push(c._model.getText());m=c.end;k+=i-(c.end-c.start)}f.push(d.getText(m,b-k))}else{for(;ab)break;m+=d._model.getCharCount()-(d.end-d.start)}b+=m;for(var q=i;i
j)break;m+=d._model.getCharCount()-(d.end-d.start);n+=d._model.getLineCount()-1-d._lineCount}d=j+m;m=i;this.onChanging(b,d-b,h,k+n,f);c.splice(c,m-q);for(e=e.length-(d-b);ib-c)break;j=n._model.getCharCount();if(n.start+j>b-c)if(d!==void 0&&n.start+j>d-c){n._model.setText(e,b-(n.start+c),d-(n.start+c));return}else l=n._model.getLineCount()-1-n._model.getLineAtOffset(b-(n.start+c)),q={projection:n,start:b-(n.start+c)},b=n.end+c+j-(n.end-n.start);i+=n._model.getLineCount()-1-n._lineCount;c+=j-(n.end-n.start)}b-=c;var o=m,l=f.getLineAtOffset(b)+i-l;if(d!==void 0)for(;md-c)break;j=n._model.getCharCount();if(n.start+j>d-c){i+=n._model.getLineAtOffset(d-(n.start+c));j=d-(n.start+c);d=n.end+c;r={projection:n,end:j};break}i+=n._model.getLineCount()-1-n._lineCount;c+=j-(n.end-n.start)}else{for(;m",overviewStyle:{styleClass:"annotationOverview "+b}};c?d.lineStyle={styleClass:"annotationLine "+
b}:d.rangeStyle={styleClass:"annotationRange "+b};e.registerType(a,d)}function d(){}function h(a){this._annotations=[];var c=this;this._listener={onChanged:function(a){c._onChanged(a)}};this.setTextModel(a)}function k(a,c){this._view=a;this._annotationModel=c;var b=this;this._listener={onDestroy:function(a){b._onDestroy(a)},onLineStyle:function(a){b._onLineStyle(a)},onChanged:function(a){b._onAnnotationModelChanged(a)}};a.addEventListener("Destroy",this._listener.onDestroy);a.addEventListener("postLineStyle",
this._listener.onLineStyle);c.addEventListener("Changed",this._listener.onChanged)}o.prototype={_expandedHTML:"
",_expandedStyle:{styleClass:"annotation expanded"},_collapsedHTML:"",_collapsedStyle:{styleClass:"annotation collapsed"},collapse:function(){if(this.expanded){this.expanded=!1;this.html=this._collapsedHTML;this.style=this._collapsedStyle;var a=this._projectionModel,c=a.getBaseModel();this._projection= {start:c.getLineStart(c.getLineAtOffset(this.start)+1),end:c.getLineEnd(c.getLineAtOffset(this.end),!0)};a.addProjection(this._projection)}},expand:function(){if(!this.expanded)this.expanded=!0,this.html=this._expandedHTML,this.style=this._expandedStyle,this._projectionModel.removeProjection(this._projection)}};e.ANNOTATION_ERROR="orion.annotation.error";e.ANNOTATION_WARNING="orion.annotation.warning";e.ANNOTATION_TASK="orion.annotation.task";e.ANNOTATION_BREAKPOINT="orion.annotation.breakpoint"; e.ANNOTATION_BOOKMARK="orion.annotation.bookmark";e.ANNOTATION_FOLDING="orion.annotation.folding";e.ANNOTATION_CURRENT_BRACKET="orion.annotation.currentBracket";e.ANNOTATION_MATCHING_BRACKET="orion.annotation.matchingBracket";e.ANNOTATION_CURRENT_LINE="orion.annotation.currentLine";e.ANNOTATION_CURRENT_SEARCH="orion.annotation.currentSearch";e.ANNOTATION_MATCHING_SEARCH="orion.annotation.matchingSearch";e.ANNOTATION_READ_OCCURRENCE="orion.annotation.readOccurrence";e.ANNOTATION_WRITE_OCCURRENCE="orion.annotation.writeOccurrence"; e.ANNOTATION_SELECTED_LINKED_GROUP="orion.annotation.selectedLinkedGroup";e.ANNOTATION_CURRENT_LINKED_GROUP="orion.annotation.currentLinkedGroup";e.ANNOTATION_LINKED_GROUP="orion.annotation.linkedGroup";var f={};e.registerType=function(a,c){var b=c;if(typeof b!=="function")b=function(a,c,b){this.start=a;this.end=c;if(b!==void 0)this.title=b},b.prototype=c;b.prototype.type=a;f[a]=b;return a};e.createAnnotation=function(a,c,b,d){return new (this.getType(a))(c,b,d)};e.getType=function(a){return f[a]}; b(e.ANNOTATION_ERROR);b(e.ANNOTATION_WARNING);b(e.ANNOTATION_TASK);b(e.ANNOTATION_BREAKPOINT);b(e.ANNOTATION_BOOKMARK);b(e.ANNOTATION_CURRENT_BRACKET);b(e.ANNOTATION_MATCHING_BRACKET);b(e.ANNOTATION_CURRENT_SEARCH);b(e.ANNOTATION_MATCHING_SEARCH);b(e.ANNOTATION_READ_OCCURRENCE);b(e.ANNOTATION_WRITE_OCCURRENCE);b(e.ANNOTATION_SELECTED_LINKED_GROUP);b(e.ANNOTATION_CURRENT_LINKED_GROUP);b(e.ANNOTATION_LINKED_GROUP);b(e.ANNOTATION_CURRENT_LINE,!0);e.registerType(e.ANNOTATION_FOLDING,o);d.addMixin=function(a){var c= d.prototype,b;for(b in c)c.hasOwnProperty(b)&&(a[b]=c[b])};d.prototype={addAnnotationType:function(a){if(!this._annotationTypes)this._annotationTypes=[];this._annotationTypes.push(a)},getAnnotationTypePriority:function(a){if(this._annotationTypes)for(var c=0;cd.start?a=c)break}return null};d=j();return{next:function(){var a=d;a&&(d=j());return a},hasNext:function(){return d!==null}}},modifyAnnotation:function(a){if(a&&!(this._getAnnotationIndex(a)<0))this.onChanged({type:"Changed",added:[],removed:[],changed:[a]})}, onChanged:function(a){return this.dispatchEvent(a)},removeAnnotations:function(a){var c=this._annotations,b,d;if(a){b=[];for(d=c.length-1;d>=0;d--){var f=c[d];f.type===a&&c.splice(d,1);b.splice(0,0,f)}}else b=c;this.onChanged({type:"Changed",removed:b,added:[],changed:[]})},removeAnnotation:function(a){if(a&&(a=this._getAnnotationIndex(a),!(a<0)))this.onChanged({type:"Changed",removed:this._annotations.splice(a,1),added:[],changed:[]})},replaceAnnotations:function(a,c){var b=this._annotations,d,f, j,e=[];if(a)for(d=a.length-1;d>=0;d--)j=a[d],f=this._getAnnotationIndex(j),f<0||(b.splice(f,1),e.splice(0,0,j));c||(c=[]);for(d=0;d1;)f=Math.floor((b+d)/2),c<=a[f].start?b=f:d=f;return b},_getAnnotationIndex:function(a){for(var c=this._annotations,b=this._binarySearch(c,a.start);b=f?(e.start+=a,e.end+=a,j.changed.push(e)): e.end<=c||(e.start0||j.removed.length>0||j.changed.length>0)this.onChanged(j)}}};p.EventTarget.addMixin(h.prototype);k.prototype={destroy:function(){var a=this._view;if(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, c){if(c){a||(a={});a.styleClass&&c.styleClass&&a.styleClass!==c.styleClass?a.styleClass+=" "+c.styleClass:a.styleClass=c.styleClass;var b;if(c.tagName&&!a.tagName)a.tagName=c.tagName;if(c.style){if(!a.style)a.style={};for(b in c.style)a.style[b]||(a.style[b]=c.style[b])}if(c.attributes){if(!a.attributes)a.attributes={};for(b in c.attributes)a.attributes[b]||(a.attributes[b]=c.attributes[b])}}return a},_mergeStyleRanges:function(a,c){a||(a=[]);var b,d;for(d=0;d=f.end)){b=this._mergeStyle({},f.style);b=this._mergeStyle(b,c.style);var j=[];j.push(d,1);c.startf.start&&j.push({start:f.start,end:c.start,style:f.style});j.push({start:Math.max(f.start,c.start),end:Math.min(f.end,c.end),style:b});c.endf.end?{start:f.end,end:c.end,style:c.style}:null;Array.prototype.splice.apply(a,j)}}c&&(b=this._mergeStyle({}, c.style),a.splice(d,0,{start:c.start,end:c.end,style:b}));return a},_onAnnotationModelChanged:function(a){function c(a){for(var c=0;c0?(a-=0.1,f.style.opacity=a):j.hide()},50)},5E3)}}}},_getAnnotationContents:function(b){function d(c){var b=c.title;if(b==="")return null;var f="
";c.html&&(f+=c.html+" ");if(!b)b=c.end,c=a.getLineStart(a.getLineAtOffset(c.start)),b=a.getLineEnd(a.getLineAtOffset(b),!0),b=a.getText(c,b);b=b.replace(//g, ">");f+=""+b+"
";return f}if(b.length===0)return null;var f=this._view.getModel(),a=f.getBaseModel?f.getBaseModel():f;if(b.length===1)if(f=b[0],f.title!==void 0)return d(f);else{var b=new e.ProjectionTextModel(a),c=a.getLineStart(a.getLineAtOffset(f.start)),i=a.getCharCount();f.end!==i&&b.addProjection({start:f.end,end:i});c>0&&b.addProjection({start:0,end:c});return b}else{c="
"+l.multipleAnnotations+"
";for(i=0;i1&&e.setRedraw(!1);for(var d=this.changes.length-1;d>=0;d--)this.changes[d].undo(e,!1);this.changes.length>1&&e.setRedraw(!0);if(b){var d=this.startSelection.start,h=this.startSelection.end;e.setSelection(this.startCaret?d:h,this.startCaret?h:d)}(d= this.owner)&&d.undo&&d.undo();return this.changes.length>0},redo:function(e,b){this.changes.length>1&&e.setRedraw(!1);for(var d=0;d1&&e.setRedraw(!0);if(b){var d=this.endSelection.start,h=this.endSelection.end;e.setSelection(this.endCaret?d:h,this.endCaret?h:d)}(d=this.owner)&&d.redo&&d.redo();return this.changes.length>0},start:function(e){this.startSelection=e.getSelection();this.startCaret=e.getCaretOffset();(e=this.owner)&& e.start&&e.start()}};o.prototype={add:function(e){this.compoundChange?this.compoundChange.add(e):(this.stack.splice(this.index,this.stack.length-this.index,e),this.index++,this.stack.length>this.size&&(this.stack.shift(),this.index--,this.cleanIndex--))},markClean:function(){this.endCompoundChange();this._commitUndo();this.cleanIndex=this.index},isClean:function(){return this.cleanIndex===this.getSize().undo},canUndo:function(){return this.getSize().undo>0},canRedo:function(){return this.getSize().redo> 0},endCompoundChange:function(){this.compoundChange&&this.compoundChange.end(this.view);this.compoundChange=void 0},getSize:function(){var e=this.index,b=this.stack.length;this._undoStart!==void 0&&e++;return{undo:e,redo:b-e}},undo:function(){this._commitUndo();var e;e=!1;this._ignoreUndo=!0;do{if(this.index<=0)break;e=this.stack[--this.index]}while(!(e=e.undo(this.view,!0)));this._ignoreUndo=!1;return e},redo:function(){this._commitUndo();var e;this._ignoreUndo=!0;do{if(this.index>=this.stack.length)break; e=this.stack[this.index++]}while(!e.redo(this.view,!0));this._ignoreUndo=!1;return!0},reset:function(){this.index=this.cleanIndex=0;this.stack=[];this._undoStart=void 0;this._undoText="";this._undoType=0;this._ignoreUndo=!1;this._compoundChange=void 0},startCompoundChange:function(e){this._commitUndo();e=new p(e);this.add(e);this.compoundChange=e;this.compoundChange.start(this.view);return this.compoundChange},_commitUndo:function(){if(this._undoStart!==void 0)this._undoType===-1?this.add(new l(this._undoStart, "",this._undoText)):this.add(new l(this._undoStart,this._undoText,"")),this._undoStart=void 0,this._undoText="",this._undoType=0;this.endCompoundChange()},_onDestroy:function(){this.model.removeEventListener("Changing",this._listener.onChanging);this.view.removeEventListener("Destroy",this._listener.onDestroy)},_onChanging:function(e){var b=e.text,d=e.start,h=e.removedCharCount,e=e.addedCharCount;if(!this._ignoreUndo){this._undoStart!==void 0&&!(e===1&&h===0&&this._undoType===1&&d===this._undoStart+ this._undoText.length||e===0&&h===1&&this._undoType===-1&&(d+1===this._undoStart||d===this._undoStart))&&this._commitUndo();if(!this.compoundChange)if(e===1&&h===0){if(this._undoStart===void 0)this._undoStart=d;this._undoText+=b;this._undoType=1;return}else if(e===0&&h===1){b=this._undoText.length>0&&this._undoStart===d;this._undoStart=d;this._undoType=-1;b?this._undoText+=this.model.getText(d,d+h):this._undoText=this.model.getText(d,d+h)+this._undoText;return}this.add(new l(d,b,this.model.getText(d, d+h)))}}};return{UndoStack:o}}); define("orion/editor/textDND",[],function(){function l(l,o){this._view=l;this._undoStack=o;this._dragSelection=null;this._dropOffset=-1;this._dropText=null;var e=this;this._listener={onDragStart:function(b){e._onDragStart(b)},onDragEnd:function(b){e._onDragEnd(b)},onDragEnter:function(b){e._onDragEnter(b)},onDragOver:function(b){e._onDragOver(b)},onDrop:function(b){e._onDrop(b)},onDestroy:function(b){e._onDestroy(b)}};l.addEventListener("DragStart",this._listener.onDragStart);l.addEventListener("DragEnd", this._listener.onDragEnd);l.addEventListener("DragEnter",this._listener.onDragEnter);l.addEventListener("DragOver",this._listener.onDragOver);l.addEventListener("Drop",this._listener.onDrop);l.addEventListener("Destroy",this._listener.onDestroy)}l.prototype={destroy:function(){var l=this._view;if(l)l.removeEventListener("DragStart",this._listener.onDragStart),l.removeEventListener("DragEnd",this._listener.onDragEnd),l.removeEventListener("DragEnter",this._listener.onDragEnter),l.removeEventListener("DragOver", this._listener.onDragOver),l.removeEventListener("Drop",this._listener.onDrop),l.removeEventListener("Destroy",this._listener.onDestroy),this._view=null},_onDestroy:function(){this.destroy()},_onDragStart:function(l){var o=this._view,e=o.getSelection(),o=o.getModel();if(o.getBaseModel)e.start=o.mapOffset(e.start),e.end=o.mapOffset(e.end),o=o.getBaseModel();if(o=o.getText(e.start,e.end))this._dragSelection=e,l.event.dataTransfer.effectAllowed="copyMove",l.event.dataTransfer.setData("Text",o)},_onDragEnd:function(l){var o= this._view;if(this._dragSelection){this._undoStack&&this._undoStack.startCompoundChange();(l=l.event.dataTransfer.dropEffect==="move")&&o.setText("",this._dragSelection.start,this._dragSelection.end);if(this._dropText){var e=this._dropText,b=this._dropOffset;if(l)if(b>=this._dragSelection.end)b-=this._dragSelection.end-this._dragSelection.start;else if(b>=this._dragSelection.start)b=this._dragSelection.start;o.setText(e,b,b);o.setSelection(b,b+e.length);this._dropText=null;this._dropOffset=-1}this._undoStack&& this._undoStack.endCompoundChange()}this._dragSelection=null},_onDragEnter:function(l){this._onDragOver(l)},_onDragOver:function(l){var o=l.event.dataTransfer.types;if(o){var e=!this._view.getOptions("readonly");e&&(e=o.contains?o.contains("text/plain"):o.indexOf("text/plain")!==-1);if(!e)l.event.dataTransfer.dropEffect="none"}},_onDrop:function(l){var o=this._view,e=l.event.dataTransfer.getData("Text");if(e)l=o.getOffsetAtLocation(l.x,l.y),this._dragSelection?(this._dropOffset=l,this._dropText=e): (o.setText(e,l,l),o.setSelection(l,l+e.length))}};return{TextDND:l}}); define("orion/editor/editor","i18n!orion/editor/nls/messages,orion/keyBinding,orion/editor/eventTarget,orion/editor/tooltip,orion/editor/annotations,orion/util".split(","),function(l,p,o,e,b,d){function h(b){this._textViewFactory=b.textViewFactory;this._undoStackFactory=b.undoStackFactory;this._textDNDFactory=b.textDNDFactory;this._annotationFactory=b.annotationFactory;this._foldingRulerFactory=b.foldingRulerFactory;this._lineNumberRulerFactory=b.lineNumberRulerFactory;this._contentAssistFactory= b.contentAssistFactory;this._keyBindingFactory=b.keyBindingFactory;this._statusReporter=b.statusReporter;this._domNode=b.domNode;this._foldingRuler=this._overviewRuler=this._lineNumberRuler=this._annotationRuler=this._annotationModel=this._annotationStyler=null;this._dirty=!1;this._title=this._contentAssist=null}function k(b){var a=this,c=Array.prototype.slice.call(arguments,1);return c.length?function(){return arguments.length?a.apply(b,c.concat(Array.prototype.slice.call(arguments))):a.apply(b, c)}:function(){return arguments.length?a.apply(b,arguments):a.call(b)}}h.prototype={destroy:function(){this.uninstallTextView();this._textViewFactory=this._undoStackFactory=this._textDNDFactory=this._annotationFactory=this._foldingRulerFactory=this._lineNumberRulerFactory=this._contentAssistFactory=this._keyBindingFactory=this._statusReporter=this._domNode=null},getAnnotationModel:function(){return this._annotationModel},getAnnotationRuler:function(){return this._annotationRuler},getAnnotationStyler:function(){return this._annotationStyler}, getFoldingRuler:function(){return this._foldingRuler},getLineNumberRuler:function(){return this._lineNumberRuler},getModel:function(){var b=this._textView.getModel();b.getBaseModel&&(b=b.getBaseModel());return b},getOverviewRuler:function(){return this._overviewRuler},getTextView:function(){return this._textView},getTitle:function(){return this._title},getKeyModes:function(){return this._textView.getKeyModes()},isDirty:function(){return this._dirty},setAnnotationRulerVisible:function(b){if(this._annotationRulerVisible!== b&&(this._annotationRulerVisible=b,this._annotationRuler)){var a=this._textView;b?a.addRuler(this._annotationRuler,0):a.removeRuler(this._annotationRuler)}},setFoldingRulerVisible:function(b){if(this._foldingRulerVisible!==b&&(this._foldingRulerVisible=b,this._foldingRuler)){var a=this._textView;a.getModel().getBaseModel&&(b?a.addRuler(this._foldingRuler,100):a.removeRuler(this._foldingRuler))}},setDirty:function(b){if(this._dirty!==b)this._dirty=b,this.onDirtyChanged({type:"DirtyChanged"})},setLineNumberRulerVisible:function(b){if(this._lineNumberRulerVisible!== b&&(this._lineNumberRulerVisible=b,this._lineNumberRuler)){var a=this._textView;b?a.addRuler(this._lineNumberRuler,1):a.removeRuler(this._lineNumberRuler)}},setOverviewRulerVisible:function(b){if(this._overviewRulerVisible!==b&&(this._overviewRulerVisible=b,this._overviewRuler)){var a=this._textView;b?a.addRuler(this._overviewRuler):a.removeRuler(this._overviewRuler)}},mapOffset:function(b,a){var c=this._textView.getModel();c.getBaseModel&&(b=c.mapOffset(b,a));return b},getCaretOffset:function(){return this.mapOffset(this._textView.getCaretOffset())}, getSelection:function(){var b=this._textView,a=b.getSelection(),b=b.getModel();if(b.getBaseModel)a.start=b.mapOffset(a.start),a.end=b.mapOffset(a.end);return a},getText:function(b,a){var c=this._textView.getModel();c.getBaseModel&&(c=c.getBaseModel());return c.getText(b,a)},_expandOffset:function(d){var a=this._textView.getModel(),c=this._annotationModel;if(c&&a.getBaseModel)for(d=c.getAnnotations(d,d+1);d.hasNext();)a=d.next(),a.type===b.AnnotationType.ANNOTATION_FOLDING&&a.expand&&(a.expand(),c.modifyAnnotation(a))}, setCaretOffset:function(b,a,c){var d=this._textView,e=d.getModel();e.getBaseModel&&(this._expandOffset(b),b=e.mapOffset(b,!0));d.setCaretOffset(b,a,c)},setText:function(b,a,c){var d=this._textView,e=d.getModel();e.getBaseModel&&(a!==void 0&&(this._expandOffset(a),a=e.mapOffset(a,!0)),c!==void 0&&(this._expandOffset(c),c=e.mapOffset(c,!0)));d.setText(b,a,c)},setFoldingEnabled:function(b){this.setFoldingRulerVisible(b)},setSelection:function(b,a,c,d){var e=this._textView,n=e.getModel();n.getBaseModel&& (this._expandOffset(b),this._expandOffset(a),b=n.mapOffset(b,!0),a=n.mapOffset(a,!0));e.setSelection(b,a,c,d)},moveSelection:function(b,a,c,d){var e=this._textView;this.setSelection(b,a||b,1/3,function(){(d===void 0||d)&&e.focus();c&&c()})},checkDirty:function(){this.setDirty(!this._undoStack.isClean())},reportStatus:function(b,a,c){this._statusReporter&&this._statusReporter(b,a,c)},_getTooltipInfo:function(b,a){var c=this._textView,d=this.getAnnotationModel();if(!d)return null;var e=this._annotationStyler; if(!e)return null;var n=c.getOffsetAtLocation(b,a);if(n===-1)return null;n=this.mapOffset(n);e=e.getAnnotationsByType(d,n,n+1);d=[];for(n=0;n
"}),n.addAnnotationType(b.AnnotationType.ANNOTATION_ERROR),n.addAnnotationType(b.AnnotationType.ANNOTATION_WARNING),n.addAnnotationType(b.AnnotationType.ANNOTATION_TASK),n.addAnnotationType(b.AnnotationType.ANNOTATION_BOOKMARK);this.setAnnotationRulerVisible(!0); if(n=this._overviewRuler=m.overviewRuler)n.addAnnotationType(b.AnnotationType.ANNOTATION_CURRENT_SEARCH),n.addAnnotationType(b.AnnotationType.ANNOTATION_MATCHING_SEARCH),n.addAnnotationType(b.AnnotationType.ANNOTATION_ERROR),n.addAnnotationType(b.AnnotationType.ANNOTATION_WARNING),n.addAnnotationType(b.AnnotationType.ANNOTATION_TASK),n.addAnnotationType(b.AnnotationType.ANNOTATION_BOOKMARK),n.addAnnotationType(b.AnnotationType.ANNOTATION_MATCHING_BRACKET),n.addAnnotationType(b.AnnotationType.ANNOTATION_CURRENT_BRACKET), n.addAnnotationType(b.AnnotationType.ANNOTATION_CURRENT_LINE),n.addAnnotationType(b.AnnotationType.ANNOTATION_READ_OCCURRENCE),n.addAnnotationType(b.AnnotationType.ANNOTATION_WRITE_OCCURRENCE);this.setOverviewRulerVisible(!0)}if(this._lineNumberRulerFactory)this._lineNumberRuler=this._lineNumberRulerFactory.createLineNumberRuler(this._annotationModel),this._lineNumberRuler.onDblClick=i,this.setLineNumberRulerVisible(!0);if(this._foldingRulerFactory)this._foldingRuler=this._foldingRulerFactory.createFoldingRuler(this._annotationModel), this._foldingRuler.addAnnotationType(b.AnnotationType.ANNOTATION_FOLDING),this.setFoldingRulerVisible(!1);this.dispatchEvent({type:"TextViewInstalled",textView:a})},uninstallTextView:function(){var b=this._textView;if(b)b.destroy(),this._textView=this._undoStack=this._textDND=this._contentAssist=this._listener=this._annotationModel=this._annotationStyler=this._annotationRuler=this._overviewRuler=this._lineNumberRuler=this._foldingRuler=this._currentLineAnnotation=this._title=null,this._dirty=!1,this.dispatchEvent({type:"TextViewUninstalled", textView:b})},_updateCursorStatus:function(){var b=this.getModel(),a=this.getCaretOffset(),c=b.getLineAtOffset(a),b=b.getLineStart(c);a-=b;for(var b=this.getKeyModes(),i=0;i0)f._prefix+=a.text,f._success=!0,f._status(),f.find(f._forward,!0),a.text=null},onSelection:function(){f._ignoreSelection||f.setActive(!1)}}}function f(a,b,d){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 f=this;this._listeners={onEditorFocus:function(a){f._removeCurrentAnnotation(a)}};this.setOptions(d)}}var a={};k.prototype=new o.KeyMode;d.mixin(k.prototype,{createKeyBindings:function(){var a=p.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 d=this._prefix;if(d.length===0)return!1;var f=this.editor,e=f.getModel(),e=a?this._success?b?this._start:f.getCaretOffset()+ 1:0:this._success?b?this._start:f.getCaretOffset():e.getCharCount()-1;if(d=f.getModel().find({string:d,start:e,reverse:!a,caseInsensitive:d.toLowerCase()===d}).next()){if(!b)this._start=e;this._ignoreSelection=this._success=!0;f.moveSelection(a?d.start:d.end,a?d.end:d.start);this._ignoreSelection=!1}else this._success=!1;this._status();return!0},isActive:function(){return this._active},isStatusActive:function(){return this.isActive()},setActive:function(a){if(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 a.length===0?(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?l.incrementalFindStr:l.incrementalFindStrNotFound:this._success?l.incrementalFindReverseStr:l.incrementalFindReverseStrNotFound;a=h.formatMessage(a,this._prefix);this.editor.reportStatus(a,this._success?"":"error")}else this.editor.reportStatus("")}}); a.IncrementalFind=k;f.prototype={find:function(a,b,d){this.setOptions({reverse:!a});var f=this.getFindString(),e;if(b)f=b.findString||f,e=b.count;a=this.getOptions();this.setOptions(b);b=d?this._startOffset:this.getStartOffset();if((e=this._doFind(f,b,e))&&!d)this._startOffset=e.start;this.setOptions(a);this._hideAfterFind&&this.hide();return e},getStartOffset:function(){return this._start!==void 0?this._start:this._reverse?this._editor.getSelection().start-1:this._editor.getCaretOffset()},getFindString:function(){var a= this._editor.getSelection();return this._editor.getText(a.start,a.end)||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; if(this._savedOptions&&(this.setOptions(this._savedOptions.pop()),this._savedOptions.length===0))this._savedOptions=null;this._removeAllAnnotations();this._editor.getTextView().removeEventListener("Focus",this._listeners.onEditorFocus);this._editor.getTextView().focus()},isVisible:function(){return this._visible},replace:function(){var a=this.getFindString();if(a){var b=this._editor,d=this.getReplaceString(),f=b.getSelection().start;if(b=b.getModel().find({string:a,start:f,reverse:!1,wrap:this._wrap, regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive}).next())this.startUndo(),this._doReplace(b.start,b.end,a,d),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,d=b.getTextView();b.reportStatus(l.replaceAll);var f=this.getReplaceString(),e=this;window.setTimeout(function(){for(var k=0,r=0;;){var o=e._doFind(a,k);if(!o)break;r++;r===1&&(d.setRedraw(!1), e.startUndo());e._doReplace(o.start,o.end,a,f);k=e.getStartOffset()}r>0&&(e.endUndo(),d.setRedraw(!0));k>0?b.reportStatus(h.formatMessage(l.replacedMatches,r)):b.reportStatus(l.nothingReplaced,"error");e._replacingAll=!1},100)}},setOptions:function(a){if(a){if((a.showAll===!0||a.showAll===!1)&&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(e.AnnotationType.ANNOTATION_MATCHING_SEARCH)}if(a.caseInsensitive=== !0||a.caseInsensitive===!1)this._caseInsensitive=a.caseInsensitive;if(a.wrap===!0||a.wrap===!1)this._wrap=a.wrap;if(a.wholeWord===!0||a.wholeWord===!1)this._wholeWord=a.wholeWord;if(a.incremental===!0||a.incremental===!1)this._incremental=a.incremental;if(a.regex===!0||a.regex===!1)this._regex=a.regex;if(a.findAfterReplace===!0||a.findAfterReplace===!1)this._findAfterReplace=a.findAfterReplace;if(a.hideAfterFind===!0||a.hideAfterFind===!1)this._hideAfterFind=a.hideAfterFind;if(a.reverse===!0||a.reverse=== !1)this._reverse=a.reverse;if(a.hasOwnProperty("findCallback"))this._findCallback=a.findCallback;if(a.hasOwnProperty("start"))this._start=a.start;if(a.hasOwnProperty("end"))this._end=a.end}},show:function(a){this._visible=!0;if(a){if(!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()},_doFind:function(a,b,d){var d=d||1,f=this._editor;if(!a)return this._removeAllAnnotations(),null;this._lastString=a;for(var a=f.getModel().find({string:a,start:b,end:this._end,reverse:this._reverse,wrap:this._wrap,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive}),j,b=0;bb.start?b.end-1:b.end),f=c.getLineStart(d), d=c.getLineEnd(b,!0),e=c.getLineCount(),h="",f=c.getText(f,d);b===e-1&&(f=(h=c.getLineDelimiter())+f);a.setText(f,d,d);a.setSelection(d+h.length,d+f.length);return!0},copyLinesUp:function(){var a=this.editor;if(a.getTextView().getOptions("readonly"))return!1;var c=a.getModel(),b=a.getSelection(),d=c.getLineAtOffset(b.start),b=c.getLineAtOffset(b.end>b.start?b.end-1:b.end),d=c.getLineStart(d),f=c.getLineEnd(b,!0),e=c.getLineCount(),h="",f=c.getText(d,f);b===e-1&&(f+=h=c.getLineDelimiter());a.setText(f, d,d);a.setSelection(d,d+f.length-h.length);return!0},deleteLines:function(a){var b=this.editor;if(b.getTextView().getOptions("readonly"))return!1;var d=1;if(a&&a.count)d=a.count;var f=b.getSelection(),e=b.getModel(),j=e.getLineAtOffset(f.start),a=e.getLineStart(j),d=f.start!==f.end||d===1?e.getLineAtOffset(f.end>f.start?f.end-1:f.end):Math.min(j+d-1,e.getLineCount()-1),d=e.getLineEnd(d,!0);b.setText("",a,d);return!0},expandAnnotation:function(a){var b=this.editor,d=b.getAnnotationModel();if(!d)return!0; var f=b.getModel(),e=b.getCaretOffset(),j=f.getLineAtOffset(e),e=f.getLineStart(j),j=f.getLineEnd(j,!0);f.getBaseModel&&(e=f.mapOffset(e),j=f.mapOffset(j),f.getBaseModel());for(var h,f=d.getAnnotations(e,j);!h&&f.hasNext();)e=f.next(),e.type===o.AnnotationType.ANNOTATION_FOLDING&&(h=e);h&&a!==h.expanded&&(a?h.expand():(b.setCaretOffset(h.start),h.collapse()),d.modifyAnnotation(h));return!0},expandAnnotations:function(a){var b=this.editor,d=b.getTextView(),f=b.getAnnotationModel();if(!f)return!0;var b= b.getModel(),e=f.getAnnotations(0,b.getCharCount());for(d.setRedraw(!1);e.hasNext();)b=e.next(),b.type===o.AnnotationType.ANNOTATION_FOLDING&&a!==b.expanded&&(a?b.expand():b.collapse(),f.modifyAnnotation(b));d.setRedraw(!0);return!0},indentLines:function(){var a=this.editor,b=a.getTextView();if(b.getOptions("readonly"))return!1;if(b.getOptions("tabMode")){var d=a.getModel(),f=a.getSelection(),e=d.getLineAtOffset(f.start),j=d.getLineAtOffset(f.end>f.start?f.end-1:f.end);if(e!==j){var h=[];h.push(""); for(var k=e;k<=j;k++)h.push(d.getLine(k,!0));k=d.getLineStart(e);d=d.getLineEnd(j,!0);b=b.getOptions("tabSize","expandTab");b=b.expandTab?Array(b.tabSize+1).join(" "):"\t";a.setText(h.join(b),k,d);a.setSelection(k===f.start?f.start:f.start+b.length,f.end+(j-e+1)*b.length);return!0}return!1}},gotoLastEdit:function(){typeof this._lastEditLocation==="number"&&this.editor.showSelection(this._lastEditLocation);return!0},gotoLine:function(){var a=this.editor,b=a.getModel().getLineAtOffset(a.getCaretOffset()); if(b=prompt(l.gotoLinePrompty,b+1))b=parseInt(b,10),a.onGotoLine(b-1,0);return!0},moveLinesDown:function(){var a=this.editor;if(a.getTextView().getOptions("readonly"))return!1;var b=a.getModel(),d=a.getSelection(),f=b.getLineAtOffset(d.start),e=b.getLineAtOffset(d.end>d.start?d.end-1:d.end),j=b.getLineCount();if(e===j-1)return!0;var f=b.getLineStart(f),d=b.getLineEnd(e,!0),h=b.getLineEnd(e+1,!0)-(d-f),k=0;e!==j-2?b=b.getText(f,d):(e=b.getLineEnd(e),b=b.getText(e,d)+b.getText(f,e),k+=d-e);this.startUndo(); a.setText("",f,d);a.setText(b,h,h);a.setSelection(h+k,h+k+b.length);this.endUndo();return!0},moveLinesUp:function(){var a=this.editor;if(a.getTextView().getOptions("readonly"))return!1;var b=a.getModel(),d=a.getSelection(),f=b.getLineAtOffset(d.start);if(f===0)return!0;var e=b.getLineAtOffset(d.end>d.start?d.end-1:d.end),j=b.getLineCount(),d=b.getLineStart(f-1),h=b.getLineStart(f),k=b.getLineEnd(e,!0),l=b.getText(h,k),o=0;e===j-1&&(e=b.getLineEnd(f-1),f=b.getLineEnd(f-1,!0),l+=b.getText(e,f),h=e, o=f-e);this.startUndo();a.setText("",h,k);a.setText(l,d,d);a.setSelection(d,d+l.length-o);this.endUndo();return!0},nextAnnotation:function(a){var b=this.editor,d=b.getAnnotationModel();if(!d)return!0;for(var f=b.getModel(),h=b.getCaretOffset(),d=d.getAnnotations(a?h:0,a?f.getCharCount():h),j=null;d.hasNext();){var k=d.next();if(a){if(k.start<=h)continue}else if(k.start>=h)continue;switch(k.type){case o.AnnotationType.ANNOTATION_ERROR:case o.AnnotationType.ANNOTATION_WARNING:case o.AnnotationType.ANNOTATION_TASK:case o.AnnotationType.ANNOTATION_BOOKMARK:break; default:continue}j=k;if(a)break}if(j){var l=b.getTextView(),t=f.getLineAtOffset(j.start),p=e.Tooltip.getTooltip(l);if(!p)return b.moveSelection(j.start),!0;b.moveSelection(j.start,j.start,function(){p.setTarget({getTooltipInfo:function(){var a=l.convert({x:l.getLocationAtOffset(j.start).x,y:l.getLocationAtOffset(f.getLineStart(t)).y},"document","page");return{contents:[j],x:a.x,y:a.y+Math.floor(l.getLineHeight(t)*1.33)}}},0)})}return!0},unindentLines:function(){var a=this.editor,b=a.getTextView(); if(b.getOptions("readonly"))return!1;if(b.getOptions("tabMode")){for(var d=a.getModel(),f=a.getSelection(),e=d.getLineAtOffset(f.start),j=d.getLineAtOffset(f.end>f.start?f.end-1:f.end),h=b.getOptions("tabSize"),k=Array(h+1).join(" "),l=[],o=b=0,g=e;g<=j;g++){var p=d.getLine(g,!0);if(d.getLineStart(g)!==d.getLineEnd(g))if(p.indexOf("\t")===0)p=p.substring(1),b++;else if(p.indexOf(k)===0)p=p.substring(h),b+=h;else return!0;g===e&&(o=b);l.push(p)}e=d.getLineStart(e);h=d.getLineEnd(j,!0);d=d.getLineStart(j); a.setText(l.join(""),e,h);j=e===f.start?f.start:f.start-o;f=Math.max(j,f.end-b+(f.end===d+1&&f.start!==f.end?1:0));a.setSelection(j,f);return!0}},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()}};f.TextActions=h;k.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 p.KeyBinding(191,!0),"toggleLineComment");a.setAction("toggleLineComment",function(){return this.toggleLineComment()}.bind(this),{name:l.toggleLineComment});a.setKeyBinding(new p.KeyBinding(191,!0,!d.isMac,!1,d.isMac),"addBlockComment");a.setAction("addBlockComment",function(){return this.addBlockComment()}.bind(this),{name:l.addBlockComment});a.setKeyBinding(new p.KeyBinding(220,!0,!d.isMac,!1,d.isMac),"removeBlockComment");a.setAction("removeBlockComment",function(){return this.removeBlockComment()}.bind(this), {name:l.removeBlockComment})},autoIndent:function(){var a=this.editor;if(a.getTextView().getOptions("readonly"))return!1;var b=a.getSelection();if(b.start===b.end){for(var d=a.getModel(),f=d.getLineAtOffset(b.start),e=d.getLine(f,!0),j=d.getLineStart(f),f=0,j=b.start-j,h;f0){for(var k=e.substring(0,f),f=j;f0&&this.linkedMode){for(var b= [],d=0;d0&&this.linkedMode?this.linkedMode.enterLinkedMode({groups:a.groups,escapePosition:a.escapePosition}):a.escapePosition&&this.editor.getTextView().setCaretOffset(a.escapePosition);return!0},_findEnclosingComment:function(a,b,d){var f=a.getLineAtOffset(b),e=a.getLineAtOffset(d),j,h,k, l,o,g;for(j=f;j>=0;j--)if(h=a.getLine(j),k=j===f?b-a.getLineStart(f):h.length,l=h.lastIndexOf("/*",k),h=h.lastIndexOf("*/",k),h>l)break;else if(l!==-1){o=a.getLineStart(j)+l;break}for(j=e;jd.start?d.end-1:d.end),j=!0,h=[],k, l,o=f;o<=e;o++)if(k=b.getLine(o,!0),h.push(k),!j||(l=k.indexOf("//"))===-1)j=!1;else if(l!==0){var g;for(g=0;g0?a.selectedGroupIndex-1:a.groups.length-1);return!0}.bind(this));this.linkedModeListener={onActivating:function(){this._groupContentAssistProvider&&(this.contentAssist.setProviders([this._groupContentAssistProvider]),this.contentAssist.setProgress(null))}.bind(this), onModelChanged:function(a){if(!this.ignoreVerify){for(var b=this.linkedModeModel,c,d;b;)if(c=this._getPositionChanged(b,a.start,a.start+a.removedCharCount),d=c.position,d===void 0||d.model!==b)this.exitLinkedMode(!1),b=this.linkedModeModel;else break;if(b){b=0;d=a.addedCharCount-a.removedCharCount;c=c.positions;for(var f,e,h=0;h=0;l--)g=c[l],g.model===b&&g.group===d.group&&f.setText(a.text,g.oldOffset+i,g.oldOffset+k);this.ignoreVerify=!1;a.text=null;this._updateAnnotations(c)}}}.bind(this)}} var k={};h.prototype=new o.KeyMode;d.mixin(h.prototype,{createKeyBindings:function(){var b=p.KeyBinding,a=[];a.push({actionID:"linkedModeEnter",keyBinding:new b(13)});a.push({actionID:"linkedModeCancel",keyBinding:new b(27)});a.push({actionID:"linkedModeNextGroup",keyBinding:new b(9)});a.push({actionID:"linkedModePreviousGroup",keyBinding:new b(9,!1,!0)});return a},enterLinkedMode:function(b){if(!this.linkedModeModel){var a=this.editor.getTextView();a.addKeyMode(this);a.addEventListener("Verify", this.linkedModeListener.onVerify);a.addEventListener("ModelChanged",this.linkedModeListener.onModelChanged);this.contentAssist.addEventListener("Activating",this.linkedModeListener.onActivating);this.editor.reportStatus(l.linkedModeEntered,null,!0)}this._sortedPositions=null;if(this.linkedModeModel)b.previousModel=this.linkedModeModel,b.parentGroup=this.linkedModeModel.selectedGroupIndex,this.linkedModeModel.nextModel=b;this.linkedModeModel=b;this.selectLinkedGroup(0)},exitLinkedMode:function(b){if(this.isActive()){if(this._compoundChange)this.endUndo(), this._compoundChange=null;this._sortedPositions=null;var a=this.linkedModeModel;this.linkedModeModel=a.previousModel;a.parentGroup=a.previousModel=void 0;if(this.linkedModeModel)this.linkedModeModel.nextModel=void 0;if(!this.linkedModeModel){var c=this.editor.getTextView();c.removeKeyMode(this);c.removeEventListener("Verify",this.linkedModeListener.onVerify);c.removeEventListener("ModelChanged",this.linkedModeListener.onModelChanged);var d=this.contentAssist;d.removeEventListener("Activating",this.linkedModeListener.onActivating); d.offset=void 0;this.editor.reportStatus(l.linkedModeExited,null,!0);b&&c.setCaretOffset(a.escapePosition,!1)}this.selectLinkedGroup(0)}},startUndo:function(){if(this.undoStack){var b=this,a=this.linkedModeModel;this._compoundChange=this.undoStack.startCompoundChange({model:a,group:a.selectedGroupIndex,end:function(){b._compoundChange=null}})}},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},isActive:function(){return!!this.linkedModeModel},isStatusActive:function(){return!!this.linkedModeModel}, selectLinkedGroup:function(d){var a=this.linkedModeModel;if(a){a.selectedGroupIndex=d;var d=a.groups[d],c=d.positions[0],e=this.editor.getTextView();e.setSelection(c.offset,c.offset+c.length);if(a=this.contentAssist)if(a.offset=void 0,d.data&&d.data.type==="link"&&d.data.values)(this._groupContentAssistProvider=new b.TemplateContentAssist(d.data.values)).getPrefix=function(){var a=e.getSelection();return a.start===a.end&&(a=e.getCaretOffset(),c.offset<=a&&a<=c.offset+c.length)?e.getText(c.offset, a):""},a.offset=c.offset,a.deactivate(),a.activate();else if(this._groupContentAssistProvider)this._groupContentAssistProvider=null,a.deactivate()}this._updateAnnotations()},_getModelPositions:function(b,a,c){for(var d=a.groups,e=0;e=0;e--){var h=b[e].position; if(h.offset<=a&&c<=h.offset+h.length){d=b[e];break}}return{position:d,positions:b}},_updateAnnotations:function(b){var a=this.editor.getAnnotationModel();if(a){for(var c=[],d=[],h=a.getTextModel(),h=a.getAnnotations(0,h.getCharCount()),k;h.hasNext();)switch(k=h.next(),k.type){case e.AnnotationType.ANNOTATION_LINKED_GROUP:case e.AnnotationType.ANNOTATION_CURRENT_LINKED_GROUP:case e.AnnotationType.ANNOTATION_SELECTED_LINKED_GROUP:c.push(k)}if(h=this.linkedModeModel)for(var b=b||this._getSortedPositions(h), j=0;j0&&a.addedCharCount===0,c=this.textView,c=a.start+1<=c.getModel().getCharCount()&&/^\s*$/.test(c.getText(a.start,a.start+1));return a.removedLineCount>0||a.addedLineCount>0||b&&c},setState:function(a){var b;a===f?(b="Activating",this._mode&&this._mode.setActive(!0)):a===k&&(b="Deactivating", this._mode&&this._mode.setActive(!1));b&&this.dispatchEvent({type:b});this.state=a;this.onStateChange(a)},setMode:function(a){this._mode=a},onStateChange:function(a){if(a===k){if(this.listenerAdded)this.textView.removeEventListener("ModelChanging",this.contentAssistListener.onModelChanging),this.textView.removeEventListener("Scroll",this.contentAssistListener.onScroll),this.textView.removeEventListener("Selection",this.contentAssistListener.onSelection),this.listenerAdded=!1}else if(a===f){if(!this.listenerAdded)this.textView.addEventListener("ModelChanging", this.contentAssistListener.onModelChanging),this.textView.addEventListener("Scroll",this.contentAssistListener.onScroll),this.textView.addEventListener("Selection",this.contentAssistListener.onSelection),this.listenerAdded=!0;this.computeProposals()}},computeProposals:function(){var a=this;this._computeProposals(this.textView.getCaretOffset()).then(function(b){a.isActive()&&a.dispatchEvent({type:"ProposalsComputed",data:{proposals:b}})})},getPrefixStart:function(a){for(;a>0&&/[A-Za-z0-9_]/.test(this.textView.getText(a- 1,a));)a--;return a},handleError:function(a){typeof console!=="undefined"&&(console.log("Error retrieving content assist proposals"),console.log(a))},_computeProposals:function(a){for(var c=this.providers,d=this.textView,f=d.getModel(),e=d.getText(),g=f.getLine(f.getLineAtOffset(a)),h=0;h0;)a--;this.selectedIndex=a;this.widget&&this.widget.setSelectedIndex(this.selectedIndex);return!0},lineDown:function(){for(var a=this.selectedIndex=== this.proposals.length-1?0:this.selectedIndex+1;this.proposals[a].unselectable&&a=0)d.className=d.className.substring(0,f)+d.className.substring(f+n.selected.length);d===a&&(d.className+=n.selected,this.parentNode.setAttribute("aria-activedescendant",d.id),d.focus(),d.offsetTopthis.parentNode.scrollTop+this.parentNode.clientHeight&&d.scrollIntoView(!1))}},setProposals:function(a){this.proposals=a},show:function(){if(this.proposals.length===0)this.hide();else{this.parentNode.innerHTML="";for(var a=0;ab.documentElement.clientHeight)this.parentNode.style.top=a.y-this.parentNode.offsetHeight-this.textView.getLineHeight()+"px";if(a.x+this.parentNode.offsetWidth>c)this.parentNode.style.left=c-this.parentNode.offsetWidth+"px"}};return{ContentAssist:c,ContentAssistMode:i,ContentAssistWidget:m}}); define("orion/editor/keywords",[],function(){return{JSKeywords:"break,case,class,catch,continue,const,debugger,default,delete,do,else,enum,export,extends,false,finally,for,function,if,implements,import,in,instanceof,interface,let,new,null,package,private,protected,public,return,static,super,switch,this,throw,true,try,typeof,undefined,var,void,while,with,yield".split(","),CSSKeywords:"alignment-adjust,alignment-baseline,animation,animation-delay,animation-direction,animation-duration,animation-iteration-count,animation-name,animation-play-state,animation-timing-function,appearance,azimuth,backface-visibility,background,background-attachment,background-clip,background-color,background-image,background-origin,background-position,background-repeat,background-size,baseline-shift,binding,bleed,bookmark-label,bookmark-level,bookmark-state,bookmark-target,border,border-bottom,border-bottom-color,border-bottom-left-radius,border-bottom-right-radius,border-bottom-style,border-bottom-width,border-collapse,border-color,border-image,border-image-outset,border-image-repeat,border-image-slice,border-image-source,border-image-width,border-left,border-left-color,border-left-style,border-left-width,border-radius,border-right,border-right-color,border-right-style,border-right-width,border-spacing,border-style,border-top,border-top-color,border-top-left-radius,border-top-right-radius,border-top-style,border-top-width,border-width,bottom,box-align,box-decoration-break,box-direction,box-flex,box-flex-group,box-lines,box-ordinal-group,box-orient,box-pack,box-shadow,box-sizing,break-after,break-before,break-inside,caption-side,clear,clip,color,color-profile,column-count,column-fill,column-gap,column-rule,column-rule-color,column-rule-style,column-rule-width,column-span,column-width,columns,content,counter-increment,counter-reset,crop,cue,cue-after,cue-before,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,fit-position,flex-align,flex-flow,flex-inline-pack,flex-order,flex-pack,float,float-offset,font,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,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,line-stacking-ruby,line-stacking-shift,line-stacking-strategy,list-style,list-style-image,list-style-position,list-style-type,margin,margin-bottom,margin-left,margin-right,margin-top,mark,mark-after,mark-before,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,outline-color,outline-offset,outline-style,outline-width,overflow,overflow-style,overflow-x,overflow-y,padding,padding-bottom,padding-left,padding-right,padding-top,page,page-break-after,page-break-before,page-break-inside,page-policy,pause,pause-after,pause-before,perspective,perspective-origin,phonemes,pitch,pitch-range,play-during,position,presentation-level,punctuation-trim,quotes,rendering-intent,resize,rest,rest-after,rest-before,richness,right,rotation,rotation-point,ruby-align,ruby-overhang,ruby-position,ruby-span,size,speak,speak-header,speak-numeral,speak-punctuation,speech-rate,stress,string-set,table-layout,target,target-name,target-new,target-position,text-align,text-align-last,text-decoration,text-emphasis,text-height,text-indent,text-justify,text-outline,text-shadow,text-transform,text-wrap,top,transform,transform-origin,transform-style,transition,transition-delay,transition-duration,transition-property,transition-timing-function,unicode-bidi,vertical-align,visibility,voice-balance,voice-duration,voice-family,voice-pitch,voice-pitch-range,voice-rate,voice-stress,voice-volume,volume,white-space,white-space-collapse,widows,width,word-break,word-spacing,word-wrap,z-index".split(","), JAVAKeywords:"abstract,boolean,break,byte,case,catch,char,class,continue,default,do,double,else,extends,false,final,finally,float,for,if,implements,import,instanceof,int,interface,long,native,new,null,package,private,protected,public,return,short,static,super,switch,synchronized,this,throw,throws,transient,true,try,void,volatile,while".split(",")}}); define("orion/editor/cssContentAssist",["orion/editor/templates","orion/editor/keywords"],function(l,p){function o(a){return JSON.stringify(a).replace("}","\\}")}function e(){}for(var b={type:"link",values:"visible,hidden,scroll,auto,no-display,no-content".split(",")},d={type:"link",values:"solid,dashed,dotted,double,groove,ridge,inset,outset".split(",")},h={type:"link",values:[]},k=0;k<10;k++)h.values.push(k.toString());for(var f={type:"link",values:"black,white,red,green,blue,magenta,yellow,cyan,grey,darkred,darkgreen,darkblue,darkmagenta,darkcyan,darkyellow,darkgray,lightgray".split(",")}, a=[{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:"+o(f)+"} ${style:"+o(d)+"} ${width:"+o(h)+"}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:"@",description:"import - import style sheet",template:'@import "${uri}";'}],c=[{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:b},{prop:"overflow-x",values:b},{prop:"overflow-y", values:b},{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:f},{prop:"border-top-color",values:f},{prop:"border-bottom-color",values:f},{prop:"border-right-color", values:f},{prop:"border-left-color",values:f},{prop:"background-color",values:f},{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"]}}],k=0;k\n\n\t\n\t\t\n\t\t${title}\n\t\n\t\n\t\t

${header}

\n\t\t

\n\t\t\t${cursor}\n\t\t

\n\t\n'),e=[{prefix:" - HTML image element",template:'${Image}'},{prefix:" - HTML anchor element", template:''},{prefix:" - HTML unordered list",template:"
    \n\t
  • ${cursor}
  • \n
"},{prefix:" - HTML ordered list",template:"
    \n\t
  1. ${cursor}
  2. \n
"},{prefix:" - HTML definition list",template:"
\n\t
${cursor}
\n\t
\n
"},{prefix:" - basic HTML table",template:"\n\t\n\t\t\n\t\n
${cursor}
"}],b,d,h,k,f="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(k=0;k",d="<"+b+">${cursor}",e.push({prefix:"<"+b,description:h,template:d});f="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(k=0;k",d="<"+b+">\n\t${cursor}\n", e.push({prefix:"<"+b,description:h,template:d});f="area,base,br,col,hr,input,link,meta,param,keygen,source".split(",");for(k=0;k",e.push({prefix:"<"+b,description:h,template:d});p.prototype=new l.TemplateContentAssist([],e);p.prototype.getPrefix=function(a,b){for(var d=b;d&&/[A-Za-z<]/.test(a.charAt(d-1));)if(d--,a.charAt(d)==="<")break;return d?a.substring(d,b):""};p.prototype.computeProposals=function(a,b,d){return a.length===0?[o.getProposal("",b,d)]:l.TemplateContentAssist.prototype.computeProposals.call(this, a,b,d)};return{HTMLContentAssistProvider:p}}); define("orion/editor/jsTemplateContentAssist",["orion/editor/templates","orion/editor/keywords"],function(l,p){function o(){}var e=[{prefix:"if",description:"if - if statement",template:"if (${condition}) {\n\t${cursor}\n}"},{prefix:"if",description:"if - if else statement",template:"if (${condition}) {\n\t${cursor}\n} else {\n\t\n}"},{prefix:"for",description:"for - iterate over array",template:"for (var ${i}=0; ${i}<${array}.length; ${i}++) {\n\t${cursor}\n}"},{prefix:"for",description:"for - iterate over array with local var", template:"for (var ${i}=0; ${i}<${array}.length; ${i}++) {\n\tvar ${value} = ${array}[${i}];\n\t${cursor}\n}"},{prefix:"for",description:"for..in - iterate over properties of an object",template:"for (var ${property} in ${object}) {\n\tif (${object}.hasOwnProperty(${property})) {\n\t\t${cursor}\n\t}\n}"},{prefix:"while",description:"while - while loop with condition",template:"while (${condition}) {\n\t${cursor}\n}"},{prefix:"do",description:"do - do while loop with condition",template:"do {\n\t${cursor}\n} while (${condition});"}, {prefix:"switch",description:"switch - switch case statement",template:"switch (${expression}) {\n\tcase ${value1}:\n\t\t${cursor}\n\t\tbreak;\n\tdefault:\n}"},{prefix:"case",description:"case - case statement",template:"case ${value}:\n\t${cursor}\n\tbreak;"},{prefix:"try",description:"try - try..catch statement",template:"try {\n\t${cursor}\n} catch (${err}) {\n}"},{prefix:"try",description:"try - try..catch statement with finally block",template:"try {\n\t${cursor}\n} catch (${err}) {\n} finally {\n}"}, {prefix:"var",description:"var - variable declaration",template:"var ${name};"},{prefix:"var",description:"var - variable declaration with value",template:"var ${name} = ${value};"},{prefix:"let",description:"let - local scope variable declaration",template:"let ${name};"},{prefix:"let",description:"let - local scope variable declaration with value",template:"let ${name} = ${value};"},{prefix:"return",description:"return - return result",template:"return ${result};"},{prefix:"typeof",description:"typeof - typeof statement", template:'typeof ${object} === "${type:'+JSON.stringify({type:"link",values:"undefined,object,boolean,number,string,function,xml".split(",")}).replace("}","\\}")+'}"'},{prefix:"instanceof",description:"instanceof - instanceof statement",template:"${object} instanceof ${type}"},{prefix:"with",description:"with - with statement",template:"with (${object}) {\n\t${cursor}\n}"},{prefix:"function",description:"function - function declaration",template:"function ${name} (${parameter}) {\n\t${cursor}\n}"}, {prefix:"log",description:"log - console log",template:"console.log(${object});"}];o.prototype=new l.TemplateContentAssist(p.JSKeywords,e);o.prototype.isValid=function(b,d,e){b=e-b.length-1;for(e="";b>=0;)if(e=d[b],e==="\n"||e==="\r")break;else if(/\s/.test(e))b--;else break;return":!@#$^&*.?<>".indexOf(e)===-1};return{JSTemplateContentAssistProvider:o}}); define("orion/editor/AsyncStyler",["i18n!orion/editor/nls/messages","orion/editor/annotations"],function(l,p){function o(d){return d.getProperty("objectClass").indexOf(b)!==-1&&d.getProperty("type")==="highlighter"}function e(b,d,f){this.initialize(b,d,f);this.lineStyles=[]}var b="orion.edit.highlighter",d=b+" service must be an event emitter";p.AnnotationType.registerType("orion.annotation.highlightError",{title:l.syntaxError,html:"
",rangeStyle:{styleClass:"annotationRange error"}}); e.prototype={initialize:function(d,e,f){this.textView=d;this.serviceRegistry=e;this.annotationModel=f;this.services=[];var a=this;this.listener={onModelChanging:function(b){a.onModelChanging(b)},onModelChanged:function(b){a.onModelChanged(b)},onDestroy:function(b){a.onDestroy(b)},onLineStyle:function(b){a.onLineStyle(b)},onStyleReady:function(b){a.onStyleReady(b)},onServiceAdded:function(b){a.onServiceAdded(b.serviceReference,a.serviceRegistry.getService(b.serviceReference))},onServiceRemoved:function(b){a.onServiceRemoved(b.serviceReference, a.serviceRegistry.getService(b.serviceReference))}};d.addEventListener("ModelChanging",this.listener.onModelChanging);d.addEventListener("ModelChanged",this.listener.onModelChanged);d.addEventListener("Destroy",this.listener.onDestroy);d.addEventListener("LineStyle",this.listener.onLineStyle);e.addEventListener("registered",this.listener.onServiceAdded);e.addEventListener("unregistering",this.listener.onServiceRemoved);d=e.getServiceReferences(b);for(f=0;f=this.string.length},sol:function(){return this.pos===0},peek:function(){return this.string[this.pos]},next:function(){return this.string[this.pos++]},eat:function(b){var a=this.string[this.pos];return typeof a==="string"&&(a===b||b.test&&b.test(a)||typeof b==="function"&& b(a))?this.string[this.pos++]:void 0},eatWhile:function(b){for(var a=!1;this.eat(b)!==void 0;)a=!0;return a},eatSpace:function(){return this.eatWhile(/\s/)},skipToEnd:function(){this.pos=this.string.length},skipTo:function(b){b=this.string.indexOf(b,this.pos);return b!==-1?(this.pos=b,!0):!1},match:function(b,a,c){a=a===!0||typeof a==="undefined";if(typeof b==="string"){var d=c?this.string.toLowerCase():this.string,b=c?b.toLowerCase():b,c=d.indexOf(b,this.pos);if(c!==-1&&a)this.pos=c+b.length;return c!== -1}else return(b=this.string.substring(this.pos).match(b))&&a&&typeof b[0]==="string"&&(this.pos+=b.index+b[0].length),b},backUp:function(b){this.pos-=b},column:function(){for(var b=0,a=0;a=c)break;this._expandRange(d,d);for(var e=this._getResumeLineIndex(d),d=e+1,e=(e=e>= 0&&this.lines[e].eolState)?this.codeMirror.copyState(this.mode,e):this.mode.startState(),h=0,j=d;j3;if(k||p)break;else if(!l||o)h=0;l=jb&&l){this.highlightLater(j+1);this.onHighlightDone();return}}}this.onHighlightDone()},onHighlightDone:function(){this.startLine!==Number.MAX_VALUE&& this.endLine!==-1&&this.dispatchEvent({type:"Highlight",start:this.startLine,end:this.endLine});this.startLine=Number.MAX_VALUE;this.endLine=-1},_getResumeLineIndex:function(b){for(var a=this.lines,c=b-1;c>=0;c--)if(a[c].eolState||b-c>40)return c;return-1},getState:function(b){var a=this.mode,c=this.lines,d,e;for(d=b-1;d>=0;d--)if(e=c[d],e.eolState||b-d>40)break;var h=d>=0&&c[d].eolState;if(h){h=this.codeMirror.copyState(a,h);for(d=Math.max(0,d);d
", rangeStyle:{styleClass:"annotationRange error"}});k.prototype={init:function(b,a,c){this.textView=b;this.annotationModel=c;this.modeApplier=new h(b.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)}};b.addEventListener("LineStyle",this.listener.onLineStyle);b.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(b){this.modeApplier.setMode(b)},onLineStyle:function(b){var a=b.lineIndex,c=this.modeApplier,d=c.getLineStyle(a);if(!d||!d.eolState){var e=this.textView.getModel().getLineCount(); c.highlight(a,Math.min(a+20,e-1),!0);d=c.getLineStyle(a)}e=this.textView.getModel();if(d){var h=c.toStyleRangesAndErrors(d,a);if(h&&(b.ranges=h[0],b=this.annotationModel)){c=[];d=[];if(h=h[1])for(var j=0;j/,func:function(){return"atomic group"}}],toRegExp:function(b){function d(a,b){throw Error('Unsupported regex feature "'+a+'": "'+b[0]+'" at index: '+b.index+" in "+b.input);}var h="",k,b=e.processGlobalFlag("x",b,function(a){for(var b="",d=!1,e=a.length,f=0;f=0;u--);s=e.charAt(u-1);g=u-1;x=e.substring(u,p+1)}u=c[c.length-1];if(s===")"&&(u.type===2||u.type===4)){l.splice(u.start,0,"(");l.push(x);l.push(")");v={start:u.start,end:l.length-1,type:4,num:u.num}; for(s=0;s=u.start&&t.end<=g)if(t.start+=1,t.end+=1,t.num+=1,t.type===2)j[t.oldNum]=t.num;c.push(v);m++;break}default:v!=="|"&&t!==2&&t!==4&&a===0&&(f.push(4),c.push({start:p,end:-1,type:4,num:m}),l.push("("),o[m]=null,m++),l.push(v),v==="\\"&&(v=e.charAt(p+1),l.push(v),p+=1)}}for(;f.length;)f.pop(),l.push(")");var e=RegExp(l.join("")),k={},d=d||j,C;for(C in d)d.hasOwnProperty(C)&&(k[C]="\\"+d[C]);e=this.getSubstitutedRegex(e,k,!1);return[e, j,o]},complexCaptures:function(b){if(!b)return!1;for(var d in b)if(b.hasOwnProperty(d)&&d!=="0")return!0;return!1}};o.prototype={initialize:function(b){this.textView=b;this.textView.stylerOptions=this;var d=this;this._listener={onModelChanged:function(b){d.onModelChanged(b)},onDestroy:function(b){d.onDestroy(b)},onLineStyle:function(b){d.onLineStyle(b)},onStorage:function(b){d.onStorage(b)}};b.addEventListener("ModelChanged",this._listener.onModelChanged);b.addEventListener("Destroy",this._listener.onDestroy); b.addEventListener("LineStyle",this._listener.onLineStyle);b.redrawLines()},onDestroy:function(){this.destroy()},destroy:function(){if(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(b){for(b=[b];b.length!==0;){var d= b.pop();if(!d._resolvedRule||!d._typedRule)if(d._resolvedRule=this._resolve(d),d._typedRule=this._createTypedRule(d),this.addStyles(d.name),this.addStyles(d.contentName),this.addStylesForCaptures(d.captures),this.addStylesForCaptures(d.beginCaptures),this.addStylesForCaptures(d.endCaptures),d._resolvedRule!==d&&b.push(d._resolvedRule),d.patterns)for(var e=0;e0;)b.push(d[--e])},exec:function(b,d,e){(d=b.exec(d))&&(d.index+=e);b.lastIndex=0;return d},afterMatch:function(b){return b.index+b[0].length},getEndMatch:function(b,d,e){if(b instanceof this.BeginEndNode){var k=b.rule,b=b.endRegexSubstituted||k.endRegex;return!b?null:this.exec(b,d,e)}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(b){var d=b.addedCharCount,e=b.removedCharCount,b=b.start;if(this._tree){var k=this.textView.getModel(),f=k.getCharCount(),k=k.getLineEnd(k.getLineAtOffset(b)-1),a=this.getFirstDamaged(k,k),k=k===-1?0:k,d=a?this.parse(a,!0,k,b,d,e):f;this.textView.redrawRange(k,d)}else this.initialParse()},getFirstDamaged:function(b,d){if(b<0)return this._tree;for(var e=[this._tree],k=null;e.length;){var f=e.pop();if(!f.parent||this.isDamaged(f,b,d)){f instanceof this.BeginEndNode&&(k= f);for(var a=0;ad},parse:function(b,d,e,k,f,a){var c=this.textView.getModel(),i=c.getLineStart(c.getLineCount()-1),l=c.getCharCount(),n=this.getInitialExpected(b,e),j=-1;if(d)b.repaired=!0,b.endNeedsUpdate=!0,j=(j=b.children[b.children.length-1])?c.getLineEnd(c.getLineAtOffset(j.end+(f-a))):-1,k=c.getLineEnd(c.getLineAtOffset(k+a)),j=Math.max(j,k);for(var j=j===-1?l:j,k=n,o=b,p=!1, t=e,v=-1;o&&(!d||t=i?l:c.getLineStart(c.getLineAtOffset(t)+1));var u=g&&g.match,x=g&&g.rule,s=g&&g.isEnd;if(g&&g.isSub){if(t=this.afterMatch(u),x instanceof this.BeginEndRule)p=!0,d&&x===k.rule&&o===k.parent?(o=k,o.setStart(u),o.repaired=!0,o.endNeedsUpdate=!0,k=this.getNextExpected(k,"begin")):(d&&(this.prune(o,k),d=!1),u=new this.BeginEndNode(o,x,u),o.addChild(u),o=u)}else if(s||t===l){if(o instanceof this.BeginEndNode)u?(p=!0,v=Math.max(v,o.end),o.setEnd(u), t=this.afterMatch(u),d&&o===k&&o.parent===k.parent?(o.repaired=!0,delete o.endNeedsUpdate,k=this.getNextExpected(k,"end")):d&&(this.prune(o,k),d=!1)):(o.setEnd(l),delete o.endNeedsUpdate);o=o.parent}d&&t>=j&&!p&&(this.prune(b,n),d=!1)}this.removeUnrepairedChildren(b,d,e);this.cleanup(d,b,e,j,l,f,a);return d?Math.max(v,t):t},removeUnrepairedChildren:function(b,d,e){if(d){for(var d=b.children,k=-1,f=0;f=d)return k}else if(b instanceof this.BeginEndNode&&b.endMatch){var f=b.endMatch.index;for(e=0;e=d)break;if(k&&k.start",contentName:"entity.name.tag.doctype.html",beginCaptures:{0:{name:"entity.name.tag.doctype.html"}},endCaptures:{0:{name:"entity.name.tag.doctype.html"}}},{begin:"<\!--",end:"--\>",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:"<[A-Za-z0-9_\\-:]+(?= ?)",name:"entity.name.tag.html"},{include:"#attrName"},{include:"#qString"},{include:"#qqString"},{include:"#entity"},{match:"",name:"entity.name.tag.html"},{match:">",name:"entity.name.tag.html"}],repository:{attrName:{match:"[A-Za-z\\-:]+(?=\\s*=\\s*['\"])",name:"entity.other.attribute.name.html"},qqString:{match:'(")[^"]+(")',name:"string.quoted.double.html"}, qString:{match:"(')[^']+(')",name:"string.quoted.single.html"},entity:{match:"&[A-Za-z0-9]+;",name:"constant.character.entity.html"}}}}}}); define("examples/editor/textStyler",["orion/editor/annotations","orion/editor/keywords"],function(l,p){function o(a,b){this.keywords=a;this.whitespacesVisible=b;this.setText("")}function e(){o.call(this,null,!0)}function b(a){o.call(this,null,a)}function d(){o.call(this,null,!1)}function h(c,g,h){this.commentStart="/*";this.commentEnd="*/";var i=[];switch(g){case "java":i=f;break;case "js":i=k;break;case "css":i=a}this.whitespacesVisible=!1;this.detectHyperlinks=!0;this.highlightCaretLine=!1;this.detectTasks= this.foldingEnabled=!0;this._scanner=new o(i,this.whitespacesVisible);this._firstScanner=new d;this._commentScanner=new b(this.whitespacesVisible);this._whitespaceScanner=new e;if(g==="css")this._scanner.isCSS=!0,this._firstScanner.isCSS=!0;this.view=c;this.annotationModel=h;this._bracketAnnotations=void 0;var j=this;this._listener={onChanged:function(a){j._onModelChanged(a)},onDestroy:function(a){j._onDestroy(a)},onLineStyle:function(a){j._onLineStyle(a)},onMouseDown:function(a){j._onMouseDown(a)}, onSelection:function(a){j._onSelection(a)}};g=c.getModel();g.getBaseModel&&(g=g.getBaseModel());g.addEventListener("Changed",this._listener.onChanged);c.addEventListener("MouseDown",this._listener.onMouseDown);c.addEventListener("Selection",this._listener.onSelection);c.addEventListener("Destroy",this._listener.onDestroy);c.addEventListener("LineStyle",this._listener.onLineStyle);this._computeComments();this._computeFolding();c.redrawLines()}var k=p.JSKeywords,f=p.JAVAKeywords,a=p.CSSKeywords,c={styleClass:"token_singleline_comment"}, i={styleClass:"token_multiline_comment"},m={styleClass:"token_doc_comment"},n={styleClass:"token_doc_html_markup"},j={styleClass:"token_task_tag"},q={styleClass:"token_doc_tag"},r={styleClass:"token_string"},t={styleClass:"token_number"},v={styleClass:"token_keyword"},g={styleClass:"token_space"},u={styleClass:"token_tab"},x={styleClass:"line_caret"};o.prototype={getOffset:function(){return this.offset},getStartOffset:function(){return this.startOffset},getData:function(){return this.text.substring(this.startOffset, this.offset)},getDataLength:function(){return this.offset-this.startOffset},_default:function(a){switch(a){case 32:case 9:if(this.whitespacesVisible)return a===32?11:10;do a=this._read();while(a===32||a===9);this._unread(a);return 9;case 123:case 125:case 40:case 41:case 91:case 93:case 60:case 62:return a;default:var b=this.isCSS,c=this.offset-1;if(!b&&48<=a&&a<=57){var d=b=!1,e=!1,f=a;do if(a=this._read(),a===46&&!b)b=!0;else if(a===101&&!d)b=d=!0,a=this._read(),a!==45&&this._unread(a);else if(a=== 120&&f===48&&this.offset-c===2)b=d=e=!0;else if(!(48<=a&&a<=57||e&&(65<=a&&a<=70||97<=a&&a<=102)))break;while(1);this._unread(a);return 3}if(97<=a&&a<=122||65<=a&&a<=90||a===95||45===a&&b){do a=this._read();while(97<=a&&a<=122||65<=a&&a<=90||a===95||48<=a&&a<=57||45===a&&b);this._unread(a);a=this.keywords;if(a.length>0){c=this.text.substring(c,this.offset);for(b=0;b1;)if(f=Math.floor((e+d)/2),b<=a[f].start)e=f;else if(c&&b=d)break;var j=g[h].start,k=g[h].end;f0){for(var e=a,g=f;g>0;){f=e.charCodeAt(g-1);if(!(97<=f&&f<=122||65<=f&&f<=90||45===f||48<=f&&f<=57))break;g--}if(g>0&&(f="\"\"''(){}[]<>".indexOf(e.substring(g-1,g)),f!==-1&&(f&1)===0&&(f=e.lastIndexOf("\"\"''(){}[]<>".substring(f+1,f+2)))!==-1)){var h=f;f=this._clone(d);f.tagName="a";f.attributes={href:e.substring(g,h)};c.push({start:b,end:b+g,style:d});c.push({start:b+g,end:b+h,style:f});c.push({start:b+h,end:b+a.length,style:d}); return null}}else a.toLowerCase().indexOf("bug#")===0&&(e="https://bugs.eclipse.org/bugs/show_bug.cgi?id="+parseInt(a.substring(4),10));return e?(f=this._clone(d),f.tagName="a",f.attributes={href:e},f):d},_clone:function(a){if(!a)return a;var b={},c;for(c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b},_findComments:function(a,b){var b=b||0,c=this._firstScanner,d;c.setText(a);for(var e=[];d=c.nextToken();)(d===7||d===8||d===5)&&e.push({start:c.getStartOffset()+b,end:c.getOffset()+b,type:d}),(d=== 6||d===7||d===8)&&this._computeTasks(d,c.getStartOffset()+b,c.getOffset()+b);return e},_findMatchingBracket:function(a,b){var c="{}()[]<>",d=a.getText(b,b+1),e=c.indexOf(d,0);if(e===-1)return-1;var f;f=e&1?c.substring(e-1,e):c.substring(e+1,e+2);for(var g=a.getLineAtOffset(b),c=a.getLine(g),h=a.getLineStart(g),i=a.getLineEnd(g),c=this._findBrackets(d,f,c,h,h,i),i=0;i=0?1:-1,c[i]*h-1===b){var j=1;if(e&1){for(i--;i>=0;i--)if(h=c[i]>=0?1:-1,j+=h,j===0)return c[i]*h-1;for(g-=1;g>= 0;){c=a.getLine(g);h=a.getLineStart(g);i=a.getLineEnd(g);c=this._findBrackets(d,f,c,h,h,i);for(e=c.length-1;e>=0;e--)if(h=c[e]>=0?1:-1,j+=h,j===0)return c[e]*h-1;g--}}else{for(i++;i=0?1:-1,j+=h,j===0)return c[i]*h-1;g+=1;for(e=a.getLineCount();g=0?1:-1,j+=h,j===0)return c[i]*h-1;g++}}break}return-1},_findBrackets:function(a,b,c,d,e,f){for(var g=[],a= a.charCodeAt(0),b=b.charCodeAt(0),h=e,i=this._scanner,j,k=this.comments,l=this._binarySearch(k,e,!0);l=f)break;j=k[l].start;var m=k[l].end;if(h0)i-=1,a.getBaseModel&&(i=a.mapOffset(i),a=a.getBaseModel()),a=this._findMatchingBracket(a,i),a!==-1&&(h=[l.AnnotationType.createAnnotation(l.AnnotationType.ANNOTATION_MATCHING_BRACKET,a,a+1),l.AnnotationType.createAnnotation(l.AnnotationType.ANNOTATION_CURRENT_BRACKET,i,i+1)]);this._bracketAnnotations=h;this.annotationModel.replaceAnnotations(b,h)}},_onMouseDown:function(a){if(a.clickCount===2){var b=this.view,c=b.getModel(),d=b.getOffsetAtLocation(a.x, a.y);if(d>0){var e=d-1,f=c;c.getBaseModel&&(e=c.mapOffset(e),f=c.getBaseModel());e=this._findMatchingBracket(f,e);e!==-1&&(a.preventDefault(),a=e,c.getBaseModel&&(a=c.mapOffset(a,!0)),d>a&&(d--,a++),b.setSelection(a,d))}}},_onModelChanged:function(a){var b=a.start,c=a.removedCharCount,d=a.addedCharCount-c,e=this.view,a=e.getModel(),f=a.getBaseModel?a.getBaseModel():a,c=b+c,g=f.getCharCount(),h=this.comments.length,i=f.getLineStart(f.getLineAtOffset(b)),j=this._binarySearch(this.comments,i,!0),k=this._binarySearch(this.comments, c,!1,j-1,h);jb&&(i+=d)):i=j===h&&h>0&&g-d===this.comments[h-1].end?this.comments[h-1].start:i;var m;kb&&(m+=d),k+=1):(k=h,m=g);for(var n,g=this._findComments(f.getText(i,m),i),h=j;hb&&(n.start+=d),n.start>b&&(n.end+=d);var o=k-j!==g.length;if(!o)for(h=0;h b&&(h-=d),k>b&&(k-=d),h<=b&&b