From 1c7dbbc78fb7c9ae923ebaa2965b0975cf719353 Mon Sep 17 00:00:00 2001 From: Artem Zatsarynnyi Date: Tue, 6 Sep 2016 16:08:59 +0300 Subject: [PATCH 1/4] CHE-1900: Update editor to Orion 12 --- .../che-plugin-orion-compare/pom.xml | 2 +- .../eclipse/che/ide/orion/public/Compare.html | 2 +- .../built-compare-amd.min.js | 17 - .../OrionIconFont-Regular.eot | Bin .../OrionIconFont-Regular.svg | 0 .../OrionIconFont-Regular.ttf | Bin .../OrionIconFont-Regular.woff | Bin .../built-compare-amd.min.js | 18 + .../built-compare.css | 59 +- .../orion/public/built-compare-codenvy.css | 10 +- .../public/built-compare-dark-codenvy.css | 10 +- .../che-plugin-orion-editor/pom.xml | 12 +- .../orion/client/OrionEditorExtension.java | 4 +- .../inject/JavaHighlightingOrionPlugin.java | 24 + .../client/inject/OrionEditorGinModule.java | 2 + .../patches/embeddedToolingPlugin.js.diff | 12 - .../src/main/patches/fix_focus.diff | 15 - .../src/main/patches/fix_goto_line.diff | 10 +- ...eEdit-amd.js.diff => fix_linked_mode.diff} | 49 +- .../src/main/patches/fix_scrolling.diff | 13 + .../code_edit/built-codeEdit-amd.js | 20196 ++++++++-------- .../code_edit/built-codeEdit.css | 41 +- .../javascript/plugins/javascriptPlugin.html | 0 .../javascript/plugins/javascriptPlugin.js | 0 .../javascript/plugins/ternWorker.js | 0 .../javascript/plugins/ternWorkerCore.js | 0 .../orion/require-config.js | 0 .../plugins/embeddedToolingPlugin.html | 0 .../plugins/embeddedToolingPlugin.js | 0 .../requirejs/require.min.js | 0 .../webtools/plugins/webToolsPlugin.html | 0 .../webtools/plugins/webToolsPlugin.js | 0 .../cheJavaHighlightingPlugin/lib/plugin.js | 576 + .../cheJavaHighlightingPlugin/plugin.html | 117 + 34 files changed, 11569 insertions(+), 9620 deletions(-) delete mode 100644 plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-11.0/built-compare-amd.min.js rename plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/{built-compare-11.0 => built-compare-12.0}/OrionIconFont-Regular.eot (100%) rename plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/{built-compare-11.0 => built-compare-12.0}/OrionIconFont-Regular.svg (100%) rename plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/{built-compare-11.0 => built-compare-12.0}/OrionIconFont-Regular.ttf (100%) rename plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/{built-compare-11.0 => built-compare-12.0}/OrionIconFont-Regular.woff (100%) create mode 100644 plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-12.0/built-compare-amd.min.js rename plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/{built-compare-11.0 => built-compare-12.0}/built-compare.css (97%) create mode 100644 plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/inject/JavaHighlightingOrionPlugin.java delete mode 100644 plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/embeddedToolingPlugin.js.diff delete mode 100644 plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/fix_focus.diff rename plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/{built-codeEdit-amd.js.diff => fix_linked_mode.diff} (69%) create mode 100644 plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/fix_scrolling.diff rename plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/{built-codeEdit-11.0 => built-codeEdit-12.0}/code_edit/built-codeEdit-amd.js (95%) rename plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/{built-codeEdit-11.0 => built-codeEdit-12.0}/code_edit/built-codeEdit.css (97%) rename plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/{built-codeEdit-11.0 => built-codeEdit-12.0}/javascript/plugins/javascriptPlugin.html (100%) rename plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/{built-codeEdit-11.0 => built-codeEdit-12.0}/javascript/plugins/javascriptPlugin.js (100%) rename plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/{built-codeEdit-11.0 => built-codeEdit-12.0}/javascript/plugins/ternWorker.js (100%) rename plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/{built-codeEdit-11.0 => built-codeEdit-12.0}/javascript/plugins/ternWorkerCore.js (100%) rename plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/{built-codeEdit-11.0 => built-codeEdit-12.0}/orion/require-config.js (100%) rename plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/{built-codeEdit-11.0 => built-codeEdit-12.0}/plugins/embeddedToolingPlugin.html (100%) rename plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/{built-codeEdit-11.0 => built-codeEdit-12.0}/plugins/embeddedToolingPlugin.js (100%) rename plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/{built-codeEdit-11.0 => built-codeEdit-12.0}/requirejs/require.min.js (100%) rename plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/{built-codeEdit-11.0 => built-codeEdit-12.0}/webtools/plugins/webToolsPlugin.html (100%) rename plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/{built-codeEdit-11.0 => built-codeEdit-12.0}/webtools/plugins/webToolsPlugin.js (100%) create mode 100644 plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/cheJavaHighlightingPlugin/lib/plugin.js create mode 100644 plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/cheJavaHighlightingPlugin/plugin.html diff --git a/plugins/plugin-orion/che-plugin-orion-compare/pom.xml b/plugins/plugin-orion/che-plugin-orion-compare/pom.xml index 862c80a38d6..e02e05c5805 100644 --- a/plugins/plugin-orion/che-plugin-orion-compare/pom.xml +++ b/plugins/plugin-orion/che-plugin-orion-compare/pom.xml @@ -67,7 +67,7 @@ - **/orion/public/built-compare-11.0/* + **/orion/public/built-compare-12.0/* diff --git a/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/Compare.html b/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/Compare.html index 71ad5afb7bc..4965d5cf9b3 100644 --- a/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/Compare.html +++ b/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/Compare.html @@ -27,7 +27,7 @@ ",captures:{0:{name:"meta.tag.html"}},contentName:"source.js.embedded.html",patterns:[{include:"orion.js"}]},{begin:"",captures:{0:{name:"meta.tag.html"}},patterns:[{include:"orion.xml#comment"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"#attribute"}]},{include:"orion.xml#comment"},{include:"orion.xml#doctype"},{include:"orion.xml#ampersandEscape"}],repository:{attribute:{match:"\\b(?:"+n.join("|")+")\\b",name:"meta.tag.attribute.html"}}}),{id:o[o.length-1].id,grammars:o,keywords:[],attributes:n}}),define("orion/editor/stylers/application_x-jsp/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/text_x-java-source/syntax","orion/editor/stylers/text_html/syntax"],function(e,t,i){var n=["autoFlush","buffer","contentType","errorPage","extends","import","info","isErrorPage","isThreadSafe","language","pageEncoding","session"],o=[];return o.push.apply(o,e.grammars),o.push.apply(o,t.grammars),o.push.apply(o,i.grammars),o.push({id:"orion.jsp",contentTypes:["application/x-jsp"],patterns:[{include:"orion.html"},{include:"#jspComment"},{include:"#jspJavaFragment"},{include:"#jspDirectiveInclude"},{include:"#jspDirectivePage"},{include:"#jspDirectiveTaglib"}],repository:{jspComment:{begin:{match:"<%--",literal:"<%--"},end:{match:"--%>",literal:"<%--"},name:"comment.block.jsp",patterns:[{match:"(\\b)(TODO)(\\b)(((?!--%>).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.line"}}}]},jspDirectiveInclude:{begin:"<%@\\s+include(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.directive.include.jsp"}},patterns:[{match:"\\bfile\\b",name:"entity.other.attribute-name.jsp"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},jspDirectivePage:{begin:"<%@\\s+page(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.directive.page.jsp"}},patterns:[{match:"\\b(?:"+n.join("|")+")\\b",name:"entity.other.attribute-name.jsp"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},jspDirectiveTaglib:{begin:"<%@\\s+taglib(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.directive.taglib.jsp"}},patterns:[{match:"\\b(?:uri|prefix)\\b",name:"entity.other.attribute-name.jsp"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},jspJavaFragment:{begin:"<%(?:=|!)?(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.declaration.java"}},contentName:"source.java.embedded.jsp",patterns:[{include:"orion.java"}]}}}),{id:o[o.length-1].id,grammars:o,keywords:[]}}),define("orion/editor/stylers/application_xquery/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["zero-digit","xquery","window","where","when","version","variable","validate","unordered","union","typeswitch","type","tumbling","try","treat","to","then","text","switch","strip","strict","start","stable","some","sliding","self","schema-element","schema-attribute","schema","satisfies","return","processing-instruction","previous","preserve","preceding-sibling","preceding","percent","per-mille","pattern-separator","parent","ordering","order","or","option","only","of","node","no-preserve","no-inherit","next","ne","NaN","namespace-node","namespace","module","mod","minus-sign","lt","let","least","le","lax","item","is","intersect","instance","inherit","infinity","in","import","if","idiv","gt","grouping-separator","group","greatest","ge","function","for","following-sibling","following","external","except","every","eq","end","encoding","empty-sequence","empty","else","element","document-node","div","digit","descending","descendant-or-self","descendant","default","declare","decimal-separator","decimal-format","count","copy-namespaces","context","construction","comment","collation","child","catch","castable","cast","case","by","boundary-space","base-uri","attribute","at","ascending","as","and","ancestor-or-self","ancestor","allowing"],i=[];return i.push.apply(i,e.grammars),i.push({id:"orion.xquery",contentTypes:["application/xquery"],patterns:[{include:"#comment"},{include:"#variable"},{include:"#multiLineDoubleQuote"},{include:"#multiLineSingleQuote"},{include:"orion.xml#tag"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.js"}],repository:{comment:{begin:{match:"\\(:",literal:"(:"},end:{match:":\\)",literal:":)"},name:"comment.block.xquery",patterns:[{match:"(\\b)(TODO)(\\b)(((?!:\\)).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},variable:{match:"\\$[a-zA-z0-9_]+",name:"variable.other.xquery"},multiLineDoubleQuote:{begin:'"',end:'"',name:"string.quoted.double"},multiLineSingleQuote:{begin:"'",end:"'",name:"string.quoted.single"}}}),{id:i[i.length-1].id,grammars:i,keywords:t}}),define("orion/editor/stylers/text_jsx/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/application_javascript/syntax","orion/editor/stylers/application_xml/syntax"],function(e,t,i){var n=[];return n.push.apply(n,e.grammars),n.push.apply(n,t.grammars),n.push.apply(n,i.grammars),n.push({id:"orion.jsx",contentTypes:["text/jsx"],patterns:[{begin:"",captures:{0:{name:"meta.tag.jsx"}},patterns:[{include:"#jsExpression"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.c-like#comment_block"}]},{include:"orion.xml#ampersandEscape"},{include:"orion.js"}],repository:{jsExpression:{begin:"\\{",end:"\\}",contentName:"source.js.embedded.jsx",patterns:[{include:"orion.js"}]}}}),{id:n[n.length-1].id,grammars:n,keywords:[]}}),define("orion/editor/stylers/application_json/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["false","true"],i=[];return i.push.apply(i,e.grammars),i.push({id:"orion.json",contentTypes:["application/json"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.json"}]}),{id:i[i.length-1].id,grammars:i,keywords:t}}),define("orion/editor/stylers/text_x-csrc/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["auto","break","case","char","const","continue","default","double","do","else","enum","extern","float","for","goto","if","inline","int","long","register","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","_Bool","_Complex","_Imaginary"],i=["define","elif","else","endif","error","ifdef","ifndef","if","include","line","pragma","undef"],n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.c",contentTypes:["text/x-csrc","text/x-c"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{include:"#directive"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.c"}],repository:{directive:{match:"#\\s*(?:"+i.join("|")+")\\b[^$]*",name:"meta.preprocessor.c"}}}),{id:n[n.length-1].id,grammars:n,keywords:t.concat(i)}}),define("orion/editor/stylers/text_x-csharp/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["abstract","as","base","bool","break","byte","by","case","catch","char","checked","class","const","continue","decimal","default","delegate","descending","double","do","else","enum","event","explicit","extern","false","finally","fixed","float","foreach","for","from","goto","group","if","implicit","int","interface","internal","into","in","is","lock","long","namespace","new","null","object","operator","orderby","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","select","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","var","virtual","volatile","void","while","where","yield"],i=["define","elif","else","endif","endregion","error","if","line","pragma checksum","pragma warning","pragma","region","undef","warning"],n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.csharp",contentTypes:["text/x-csharp"],patterns:[{match:"^\\s*#(?:"+i.join("|")+")\\b[^$]*",name:"meta.preprocessor.csharp"},{include:"#string_verbatim"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"#doc_line"},{include:"orion.c-like#comment_singleLine"},{include:"#doc_block"},{include:"orion.c-like#comment_block"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.csharp"}],repository:{doc_block:{begin:"/\\*\\*",end:"\\*/",name:"comment.block.documentation.csharp",patterns:[{match:"<[^\\s>]*>",name:"meta.documentation.tag"},{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},doc_line:{match:"// /.*",name:"comment.line.documentation.csharp",patterns:[{match:"<[^\\s>]*>",name:"meta.documentation.tag"},{include:"orion.lib#todo_comment_singleLine"}]},string_verbatim:{begin:'@"',end:'^(?:""|[^"])*"(?!")',name:"string.quoted.verbatim.csharp"}}}),{id:n[n.length-1].id,grammars:n,keywords:t}}),define("orion/editor/stylers/text_x-cshtml/syntax",["orion/editor/stylers/application_xml/syntax","orion/editor/stylers/text_html/syntax","orion/editor/stylers/text_x-csharp/syntax"],function(e,t,i){var n=[];return n.push.apply(n,e.grammars),n.push.apply(n,t.grammars),n.push.apply(n,i.grammars),n.push({id:"orion.cshtml",contentTypes:["text/x-cshtml"],patterns:[{include:"#comment"},{include:"#codeBlock"},{include:"#expression"},{include:"#reference"},{include:"orion.html"}],repository:{comment:{begin:{match:"@\\*",literal:"@*"},end:{match:"\\*@",literal:"*@"},name:"comment.block.cshtml"},codeBlock:{begin:"(^\\s*)(@)(?=([^{]*){)",end:"}",captures:{2:{name:"entity.name.declaration.csharp"}},contentName:"source.csharp.embedded.cshtml",patterns:[{include:"orion.xml#tag"},{include:"#reference"},{include:"orion.csharp"}]},expression:{match:"^\\s*@[^{]*$",name:"source.csharp.embedded.cshtml",patterns:[{include:"#reference"},{include:"orion.csharp"}]},reference:{match:"@",name:"entity.name.declaration.csharp"}}}),{id:n[n.length-1].id,grammars:n,keywords:[]}}),define("orion/editor/stylers/text_x-c__src/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["alignas","alignof","asm","and_eq","and","auto","bitand","bitor","bool","break","case","catch","char16_t","char32_t","char","class","compl","constexpr","const_cast","const","continue","decltype","default","delete","double","do","dynamic_cast","else","enum","explicit","export","extern","false","float","for","friend","goto","if","inline","int","long","mutable","namespace","new","noexcept","not_eq","not","nullptr","operator","or_eq","or","private","protected","public","register","reinterpret_cast","return","short","signed","sizeof","static_assert","static_cast","static","struct","switch","template","this","thread_local","throw","true","try","typedef","typeid","typename","union","unsigned","using","virtual","void","volatile","wchar_t","while","xor_eq","xor","_Bool","_Complex","_Imaginary"],i=["define","elif","else","endif","error","ifdef","ifndef","if","include","line","pragma","undef"],n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.cpp",contentTypes:["text/x-c++src","text/x-c++"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{include:"#directive"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.cpp"}],repository:{directive:{match:"#\\s*(?:"+i.join("|")+")\\b[^$]*",name:"meta.preprocessor.cpp"}}}),{id:n[n.length-1].id,grammars:n,keywords:t}}),define("orion/editor/stylers/text_x-dockerfile/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["add","cmd","copy","entrypoint","env","expose","from","maintainer","onbuild","run","user","volume","workdir"],i="orion.dockerfile",n=[];return n.push.apply(n,e.grammars),n.push({id:i,contentTypes:["text/x-dockerfile"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"#numberSignComment"},{match:"\\b-?[0-9]+(\\.[0-9]+)?\\b",name:"constant.numeric.dockerfile"},{match:"(?i)^\\s*(?:"+t.join("|")+")\\b",name:"keyword.operator.dockerfile"}],repository:{numberSignComment:{begin:{match:"^\\s*#",literal:"#"},end:{match:"$",literal:""},name:"comment.line.number-sign.dockerfile",patterns:[{include:"orion.lib#todo_comment_singleLine"}]}}}),{id:i,grammars:n,keywords:t}}),define("orion/editor/stylers/text_x-erlang/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["xor","when","try","rem","receive","query","orelse","or","of","not","let","if","fun","end","div","cond","catch","case","bxor","bsr","bsl","bor","bnot","begin","band","andalso","and","after"],i=["vsn","undef","type","spec","record","on_load","opaque","module","include_lib","include","import","ifndef","ifdef","file","export_type","export","endif","else","define","callback","compile","behaviour"],n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.erlang",contentTypes:["text/x-erlang"],patterns:[{include:"#comment"},{include:"#stringSingleLine"},{include:"#stringMultiLine"},{include:"#method"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.erlang"},{match:"^\\s*-(?:"+i.join("|")+")\\b",name:"keyword.operator.erlang"}],repository:{comment:{match:{match:"%.*",literal:"%"},name:"comment.line.erlang",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},method:{match:"(^|\\s)[a-zA-Z0-9_.]+(?=\\(|\\s\\()",name:"entity.name.function.erlang"},stringMultiLine:{begin:'"(?:\\\\.|[^\\\\"])*$',end:'^(?:\\\\.|[^\\\\"])*"',name:"string.quoted.double.erlang"},stringSingleLine:{match:'"(?:\\\\.|[^\\\\"])*"',name:"string.quoted.double.erlang"}}}),{id:n[n.length-1].id,grammars:n,keywords:t}}),define("orion/editor/stylers/text_x-ruby/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["alias_method","alias","attr_accessor","attr_reader","attr_writer","attr","BEGIN","class","defined?","def","END","extend","gem","include","initialize","in","load","lambda","module_function","module","new","not","public","prepend","private","protected","require_relative","require","undef","__ENCODING__","__END__","__FILE__","__LINE__"],i=["and","begin","break","case","catch","do","else","elsif","end","ensure","fail","for","if","loop","next","or","raise","redo","rescue","retry","return","then","throw","unless","until","when","while","yield"],n=["false","nil","true"],o=["self","super"],r=[];return r.push.apply(r,e.grammars),r.push({id:"orion.ruby",contentTypes:["text/x-ruby"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"#symbol_quoted_single"},{include:"#symbol_quoted_double"},{include:"#symbol"},{include:"#classRef"},{match:"/(?![\\s])(?:\\\\.|[^/])+/(?:[ioxmuesn]\\b)?",name:"string.regexp.ruby"},{match:{match:"#.*",literal:"#"},name:"comment.line.number-sign.ruby",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},{begin:{match:"^=begin\\b",literal:"\n=begin "},end:{match:"^=end\\b",literal:"\n=end "},name:"comment.block.ruby",patterns:[{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{include:"#variable"},{match:"\\b0[bB][01]+\\b",name:"constant.numeric.binary.ruby"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.ruby"},{match:"\\b(?:"+i.join("|")+")\\b",name:"keyword.control.ruby"},{match:"\\b(?:"+n.join("|")+")\\b",name:"constant.language.ruby"},{match:"\\b(?:"+o.join("|")+")\\b",name:"variable.language.ruby"}],repository:{classRef:{match:"\\w+::\\w+"},symbol:{match:":\\w+",name:"entity.name.symbol.ruby"},symbol_quoted_single:{match:":'[^']*'",name:"entity.name.symbol.quoted.single.ruby"},symbol_quoted_double:{match:':"[^"]*"',name:"entity.name.symbol.quoted.double.ruby"},variable:{match:"@\\w+",name:"entity.name.variable.ruby"}}}),{id:r[r.length-1].id,grammars:r,keywords:t.concat(i).concat(n).concat(o)}}),define("orion/editor/stylers/text_x-haml/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/text_x-ruby/syntax"],function(e,t){var i=[];return i.push.apply(i,e.grammars),i.push.apply(i,t.grammars),i.push({id:"orion.haml",contentTypes:["text/x-haml"],patterns:[{include:"#inlineRuby"},{include:"#interpolatedRuby"},{include:"#tagWithRubySymbols"},{include:"#tagWithHTMLAttributes"},{include:"#doctype"},{include:"#tag"},{include:"#htmlComment"}],repository:{doctype:{match:"^!!!.*$",name:"meta.tag.doctype.haml"},htmlComment:{match:{match:"/[^[].*$",literal:"/"},name:"comment.line.html.haml"},inlineRuby:{begin:"(?:^|[^\\\\])(?:=|-|~|&==?|!==?)",end:"(?:^|[^,])$",contentName:"source.ruby.embedded.haml",patterns:[{include:"orion.ruby"}]},interpolatedRuby:{begin:"#{",end:"}",contentName:"source.ruby.embedded.haml",patterns:[{include:"orion.ruby"}]},tag:{match:"^\\s*%[^\\b]+?\\b",name:"meta.tag.haml"},tagWithHTMLAttributes:{begin:"(^\\s*)(%[^\\s(]+?)\\(",end:"\\)\\s*$",beginCaptures:{2:{name:"meta.tag.haml"}},patterns:[{match:"[^\\s=]+(?==)",name:"entity.name.attribute.html.haml"},{include:"orion.ruby#variable"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},tagWithRubySymbols:{begin:"(^\\s*)(%[^\\b]+?)\\b{",end:"}\\s*$",beginCaptures:{2:{name:"meta.tag.haml"}},patterns:[{include:"orion.ruby#symbol"},{include:"orion.ruby#variable"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]}}}),{id:i[i.length-1].id,grammars:i,keywords:[]}}),define("orion/editor/stylers/text_x-jade/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/application_javascript/syntax"],function(e,t){var i=["&attributes","block","case","default","doctype","each","else","extends","for","if","include","mixin","unless","when","while"],n=[];return n.push.apply(n,e.grammars),n.push.apply(n,t.grammars),n.push({id:"orion.jade",contentTypes:["text/x-jade"],patterns:[{include:"#comment_singleLine"},{include:"#code"},{include:"#control"},{include:"#caseBranch"},{include:"#mixinWithParameters"},{include:"#mixinRefWithArguments"},{include:"#tagWithAttributes"},{include:"#interpolatedJS"},{include:"#interpolatedTag"},{include:"#mixin"},{include:"#mixinRef"},{include:"#doctype"},{include:"#filter"},{include:"#case"},{include:"#andAttributes"},{include:"#otherKeywords"},{include:"#tag"}],repository:{andAttributes:{match:"&attributes\\b",name:"keyword.operator.jade"},"case":{match:"(^\\s*)(case)\\b",captures:{2:{name:"keyword.control.jade"}}},caseBranch:{begin:"(^\\s*)(when|default)\\s*",end:":|$",contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}],beginCaptures:{2:{name:"keyword.control.jade"}}},code:{match:"(^\\s*- |= |!= ).*$",name:"source.js.embedded.jade",patterns:[{include:"orion.js"}]},comment_singleLine:{match:{match:"^\\s*//.*",literal:"//"},name:"comment.line.double-slash.jade",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},control:{begin:"(^\\s*)(if|else( if)?|each|for|unless|while)\\b",end:"$",beginCaptures:{2:{name:"keyword.control.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]},doctype:{match:"(^\\s*)(doctype.+$)",captures:{2:{name:"meta.tag.doctype.jade"}}},filter:{match:"(^\\s*)(:\\w+)",captures:{2:{name:"entity.other.filter.jade"}}},interpolatedJS:{begin:"(#{)",end:"(})",captures:{1:{name:"string.interpolated.js.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]},interpolatedTag:{begin:"(#\\[)",end:"(\\])",captures:{1:{name:"string.interpolated.tag.jade"}},patterns:[{begin:"(\\.|\\w+)\\s*\\(",end:"(\\))(/)?",beginCaptures:{1:{name:"meta.tag.jade"}},endCaptures:{2:{name:"meta.tag.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]}]},mixin:{match:"(^\\s*)(mixin)(\\s+)(\\w+)",captures:{2:{name:"keyword.operator.jade"},4:{name:"entity.name.mixin.jade"}}},mixinRef:{match:"(^\\s*)(\\+\\w+)",captures:{2:{name:"entity.name.mixin.jade"}}},mixinRefWithArguments:{begin:"(^\\s*)(\\+\\w+)\\s*\\(",end:"\\)|$",captures:{2:{name:"entity.name.mixin.jade"}},patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.lib#number_decimal"}]},mixinWithParameters:{begin:"(^\\s*)(mixin)(\\s+)(\\w+)\\s*\\(",end:"\\)|$",beginCaptures:{2:{name:"keyword.operator.jade"},4:{name:"entity.name.mixin.jade"}},patterns:[{match:"[^\\s,]+",name:"variable.parameter.jade"}]},otherKeywords:{match:"(^\\s*)(block|extends|include)\\b",captures:{2:{name:"keyword.operator.jade"}}},tag:{match:"(^\\s*)(\\w+|(?=\\.)|(?=#))(#\\w*|\\.\\w*)*(/?)",captures:{2:{name:"meta.tag.jade"},4:{name:"meta.tag.jade"}}},tagWithAttributes:{begin:"(^\\s*)(\\w+|(?=\\.)|(?=#))(#\\w*|\\.\\w*)*\\s*\\(",end:"(\\))(/)?",beginCaptures:{2:{name:"meta.tag.jade"}},endCaptures:{2:{name:"meta.tag.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]}}}),{id:n[n.length-1].id,grammars:n,keywords:i}}),define("orion/editor/stylers/text_x-lua/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["and","break","do","else","elseif","end","false","for","function","if","in","local","nil","not","or","repeat","return","then","true","until","while"],i=["assert","arg","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load","loadfile","loadstring","next","pairs","pcall","print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall"],n=["_G","LUA_INIT","LUA_PATH","LUA_CPATH","_VERSION"],o=[];return o.push.apply(o,e.grammars),o.push({id:"orion.lua",contentTypes:["text/x-luasrc","text/x-lua"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"#comment_block_dash_dash"},{include:"#comment_singleLine_dash_dash"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{include:"#base_functions"},{include:"#base_variables"},{include:"#reserved_underscore_capital"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.lua"}],repository:{comment_block_dash_dash:{begin:{match:"--\\[\\[",literal:"--[["},end:{match:"\\]\\]",literal:"]]"},name:"comment.block.dash-dash.lua",patterns:[{match:"(\\b)(TODO)(\\b)(((?!\\]\\]).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},comment_singleLine_dash_dash:{begin:{match:"--",literal:"--"},end:{match:"$",literal:""},name:"comment.line.dash-dash.lua",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},base_functions:{match:"\\b(?:"+i.join("|")+")\\b",name:"support.function.lua"},base_variables:{match:"\\b(?:"+n.join("|")+")\\b",name:"support.variable.lua"},reserved_underscore_capital:{match:"\\b_[A-Z]*\\b",name:"constant.other.userdefined.lua"}}}),{id:o[o.length-1].id,grammars:o,keywords:t}}),define("orion/editor/stylers/text_x-php/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["abstract","and","array","as","callable","class","clone","const","declare","echo","empty","eval","extends","final","function","global","implements","include","include_once","insteadof","interface","instanceof","isset","list","namespace","new","or","parent","print","private","protected","public","require","require_once","static","trait","unset","use","var","xor","__halt_compiler","__CLASS__","__DIR__","__FILE__","__FUNCTION__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__"],i=["break","case","catch","continue","default","die","do","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","exit","finally","for","foreach","goto","if","return","switch","throw","try","while","yield"],n=["false","FALSE","null","NULL","true","TRUE"],o=["self"],r=[];return r.push.apply(r,e.grammars),r.push({id:"orion.php-core",patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{match:{match:"#.*",literal:"#"},name:"comment.line.number-sign.php",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},{begin:"<<<(\\w+)$",end:"^\\1;$",name:"string.unquoted.heredoc.php"},{begin:"<<<'(\\w+)'$",end:"^\\1;$",name:"string.unquoted.heredoc.nowdoc.php"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{match:"\\b0[bB][01]+\\b",name:"constant.numeric.binary.php"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.php"},{match:"\\b(?:"+i.join("|")+")\\b",name:"keyword.control.php"},{match:"\\b(?:"+n.join("|")+")\\b",name:"constant.language.php"},{match:"\\b(?:"+o.join("|")+")\\b",name:"variable.language.php"}]}),r.push({id:"orion.php",contentTypes:["text/x-php"],patterns:[{begin:"(?i)<(\\?|%(?!php))(?:=|php)?(?:\\s|$)",end:"[\\1]>",captures:{0:{name:"entity.name.declaration.php"}},contentName:"source.php.embedded",patterns:[{include:"orion.php-core"}]},{include:"orion.html"}]}),{id:r[r.length-1].id,grammars:r,keywords:t.concat(i).concat(n).concat(o)}}),define("orion/editor/stylers/text_x-python/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["and","as","assert","break","class","continue","def","del","exec","elif","else","except","Ellipsis","False","finally","for","from","global","if","import","in","is","lambda","not","None","NotImplemented","or","pass","print","raise","return","try","True","while","with","yield"],i=[];return i.push.apply(i,e.grammars),i.push({id:"orion.python",contentTypes:["text/x-python"],patterns:[{begin:"(['\"])\\1\\1",end:"\\1\\1\\1",name:"string.quoted.triple.python"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{begin:{match:"#",literal:"#"},end:{match:"$",literal:""},name:"comment.line.number-sign.python",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.python"}],repository:{number_decimal:{match:"\\b-?(?:\\.\\d+|\\d+\\.?\\d*)[lL]?\\b",name:"constant.numeric.number.python"}}}),{id:i[i.length-1].id,grammars:i,keywords:t} -}),define("orion/editor/stylers/text_x-go/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["break","case","const","continue","default","defer","else","fallthrough","false","for","func","goto","go","if","import","nil","package","range","return","select","switch","true","type","var"],i=[];return i.push.apply(i,e.grammars),i.push({id:"orion.go",contentTypes:["text/x-go"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{begin:"`",end:"`",name:"string.quoted.raw.go"},{include:"orion.c-like#comment_singleLine"},{include:"orion.c-like#comment_block"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.go"},{match:"\\b(?:len|cap|new|make|append|close|copy|delete|complex|real|imag|panic|recover)\\b",name:"support.function.go"},{match:"\\b(?:bool|chan|uint8|uint16|uint32|uint64|int8|int16|int32|int64|float32|float64|complex64|complex128|byte|map|rune|uint|interface|int|uintptr|string|struct|error)\\b",name:"support.function.type"}]}),{id:i[i.length-1].id,grammars:i,keywords:t}}),define("orion/editor/stylers/text_x-objective-c/syntax",["orion/editor/stylers/text_x-csrc/syntax"],function(e){var t=["atomic","BOOL","bycopy","byref","Class","id","IMP","inout","in","nil","nonatomic","NO","NULL","oneway","out","Protocol","retain","SEL","self","super","YES"],i=["@catch","@class","@dynamic","@end","@finally","@implementation","@interface","@private","@property","@protected","@protocol","@public","@selector","@synthesize","@throw","@try"],n=["import"],o=[];return o.push.apply(o,e.grammars),o.push({id:"orion.objectiveC",contentTypes:["text/x-objective-c"],patterns:[{include:"#objectiveCString"},{include:"orion.c"},{include:"#objectiveCDirective"},{include:"#objectiveCKeyword"}],repository:{objectiveCDirective:{match:"#\\s*(?:"+n.join("|")+")\\b[^$]*",name:"meta.preprocessor.objective-c"},objectiveCKeyword:{match:"(\\b(?:"+t.join("|")+")|(?:"+i.join("|")+"))\\b",name:"keyword.operator.objective-c"},objectiveCString:{match:'@"(?:\\\\.|[^"])*"?',name:"string.quoted.double.objective-c"}}}),{id:o[o.length-1].id,grammars:o,keywords:e.keywords.concat(t).concat(n).concat(i)}}),define("orion/editor/stylers/text_x-smarty/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/text_html/syntax","orion/editor/stylers/text_x-php/syntax"],function(e,t,i){var n=["false","no","off","on","true","yes"],o="{",r="}",s=[];return s.push.apply(s,e.grammars),s.push.apply(s,t.grammars),s.push.apply(s,i.grammars),s.push({id:"orion.smarty",contentTypes:["text/x-smarty"],patterns:[{include:"orion.html"},{include:"#smartyCommentBlock"},{include:"#literalBlock"},{include:"#phpBlock"},{include:"#smartyBlock"}],repository:{literalBlock:{begin:"({)literal(})",end:"({)/literal(})",captures:{1:"punctuation.brace.begin.smarty",2:"punctuation.brace.end.smarty"}},phpBlock:{begin:"({)php(})",end:"({)/php(})",captures:{1:"punctuation.brace.begin.smarty",2:"punctuation.brace.end.smarty"},contentName:"source.php.embedded.smarty",patterns:[{include:"orion.php-core"}]},smartyBlock:{begin:"("+o+")",end:"("+r+")",captures:{1:"punctuation.brace.begin.smarty",2:"punctuation.brace.end.smarty"},patterns:[{include:"orion.lib#string_singleQuote"},{include:"#smartyString_doubleQuote"},{include:"#smartyVariable"},{include:"#smartyConfigVariable"},{include:"#smartyConstant"},{include:"orion.lib#number_decimal"}]},smartyCommentBlock:{begin:{match:o+"\\*",literal:o+"*"},end:{match:"\\*"+r,literal:"*"+r},name:"comment.block.smarty"},smartyConfigVariable:{match:"#\\w+#",name:"variable.other.config.smarty"},smartyConstant:{match:"\\b(?:"+n.join("|")+")\\b",name:"constant.language.smarty"},smartyEscapedVariable:{match:"`\\$[^`]+`",name:"variable.other.escaped.smarty"},smartyString_doubleQuote:{begin:'"',end:'"',name:"string.quoted.double.smarty",patterns:[{include:"#smartyEscapedVariable"},{include:"#smartyVariable"},{include:"#smartyConfigVariable"}]},smartyVariable:{match:"\\$(?:smarty\\.(?:config|server)\\.)?\\w+",name:"variable.other.smarty"}}}),{id:s[s.length-1].id,grammars:s,keywords:[]}}),define("orion/editor/stylers/text_x-swift/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["associativity","as","class","convenience","deinit","didSet","dynamicType","dynamic","enum","extension","final","func","get","import","infix","init","inout","internal","in","is","lazy","left","let","mutating","none","nonmutating","operator","optional","override","postfix","precedence","prefix","private","protocol","Protocol","public","required","right","Self","set","static","struct","subscript","typealias","Type","unowned","var","weak","willSet","@objc"],i=["break","case","continue","default","do","else","fallthrough","for","if","return","switch","where","while"],n=["false","nil","true"],o=["self","super"],r=["__COLUMN__","__FILE__","__FUNCTION__","__LINE__"],s=[];return s.push.apply(s,e.grammars),s.push({id:"orion.swift",contentTypes:["text/x-swift"],patterns:[{include:"#string_doubleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"#comment_block"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"#number_binary"},{include:"#number_hex"},{include:"#number_octal"},{include:"#number_decimal"},{include:"#keywords_operator"},{include:"#keywords_control"},{include:"#constants"},{include:"#languageVars1"},{include:"#languageVars2"}],repository:{comment_block:{begin:{match:"/\\*",literal:"/*"},end:{match:"\\*/",literal:"*/"},name:"comment.block.swift",patterns:[{include:"#comment_block"},{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task.swift"},4:{name:"comment.block.swift"}}}]},constants:{match:"(^|[^\\w`])("+n.join("|")+")\\b",captures:{2:{name:"constant.language.swift"}}},keywords_operator:{match:"(^|[^\\w`])("+t.join("|")+")\\b",captures:{2:{name:"keyword.operator.swift"}}},keywords_control:{match:"(^|[^\\w`])("+i.join("|")+")\\b",captures:{2:{name:"keyword.control.swift"}}},languageVars1:{match:"(^|[^\\w`])("+o.join("|")+")\\b",captures:{2:{name:"variable.language.swift"}}},languageVars2:{match:"(^|[^\\w`])("+r.join("|")+")(?:$|[^\\w])",captures:{2:{name:"variable.language.swift"}}},number_binary:{match:"\\b0b[01]+\\b",name:"constant.numeric.binary.swift"},number_decimal:{match:"\\b-?(?:\\.\\d[\\d_]*|\\d[\\d_]*\\.?[\\d_]*)(?:[eE][+-]?\\d[\\d_]*)?\\b",name:"constant.numeric.decimal.swift"},number_hex:{match:"\\b0[xX](?:\\.[0-9A-Fa-f][0-9A-Fa-f_]*|[0-9A-Fa-f][0-9A-Fa-f_]*\\.?[0-9A-Fa-f_]*)(?:[pP][+-]?\\d[\\d_]*)?\\b",name:"constant.numeric.hex.swift"},number_octal:{match:"\\b0o[01234567][01234567_]*\\b",name:"constant.numeric.octal.swift"},segment:{begin:"\\(",end:"\\)",patterns:[{include:"#segment"},{include:"#comment_block"},{include:"#number_binary"},{include:"#number_hex"},{include:"#number_octal"},{include:"#number_decimal"},{include:"#keywords_operator"},{include:"#keywords_control"},{include:"#constants"},{include:"#languageVars1"},{include:"#languageVars2"}]},string_doubleQuote:{match:'"(?:\\\\.|[^"])*"?',name:"string.quoted.double.swift",patterns:[{begin:"\\\\\\(",end:"\\)",name:"string.interpolated.swift",patterns:[{include:"#segment"},{include:"#comment_block"},{include:"#number_binary"},{include:"#number_hex"},{include:"#number_octal"},{include:"#number_decimal"},{include:"#keywords_operator"},{include:"#keywords_control"},{include:"#constants"},{include:"#languageVars1"},{include:"#languageVars2"}]}]}}}),{id:s[s.length-1].id,grammars:s,keywords:t.concat(i).concat(n).concat(o).concat(r)}}),define("orion/editor/stylers/text_x-vb/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["AddHandler","AddressOf","Aggregate","Alias","AndAlso","And","Ansi","Assembly","Async","As","Auto","Await","Binary","Boolean","ByRef","Byte","ByVal","Call","Case","Catch","CBool","CByte","CChar","CDate","CDbl","CDec","Char","CInt","Class","CLng","CObj","Compare","Const","CShort","CSng","CStr","CType","Custom","Date","Decimal","Declare","Default","Delegate","Dim","DirectCast","Distinct","Double","Do","Each","ElseIf","Else","EndIf","End","Enum","Equals","Erase","Error","Event","Exit","Explicit","False","Finally","For","Friend","From","Function","GetType","Get","GoSub","GoTo","Group By","Group Join","Handles","If","Implements","Imports","Inherits","Integer","Interface","Into","In","IsFalse","IsTrue","Is","Iterator","Join","Key","Let","Lib","Like","Long","Loop","Me","Mid","Module","Mod","MustInherit","MustOverride","MyBase","MyClass","Namespace","New","Next","Nothing","NotInheritable","NotOverridable","Not","Object","Off","On","Optional","Option","Order By","OrElse","Or","Overloads","Overridable","Overrides","ParamArray","Preserve","Private","Property","Protected","Public","RaiseEvent","ReadOnly","ReDim","REM","RemoveHandler","Resume","Return","Select","Set","Shadows","Shared","Short","Single","Skip While","Skip","Static","Step","Stop","Strict","String","Structure","Sub","SyncLock","Take While","Take","Text","Then","Throw","To","True","Try","TypeOf","Unicode","Until","Variant","Wend","When","Where","While","WithEvents","With","WriteOnly","Xor","Yield"],i=["Const","ElseIf","Else","End","ExternalSource","If","Region"],n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.vb",contentTypes:["text/x-vb"],patterns:[{match:"^\\s*#(?:"+i.join("|")+")\\b[^$]*",name:"meta.preprocessor.vb"},{include:"orion.lib#string_doubleQuote"},{include:"#doc"},{include:"#comment"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.vb"}],repository:{comment:{begin:{match:"'",literal:"'"},end:{match:"$",literal:""},name:"comment.line.vb",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},doc:{match:{match:"'''.*",literal:"'''"},name:"comment.line.documentation.vb",patterns:[{match:"<[^\\s>]*>",name:"meta.documentation.tag"},{include:"orion.lib#todo_comment_singleLine"}]},number_hex:{match:"&[hH][0-9A-Fa-f]+\\b",name:"constant.numeric.hex.vb"}}}),{id:n[n.length-1].id,grammars:n,keywords:t}}),define("orion/editor/stylers/text_x-vbhtml/syntax",["orion/editor/stylers/application_xml/syntax","orion/editor/stylers/text_html/syntax","orion/editor/stylers/text_x-vb/syntax"],function(e,t,i){var n=[];return n.push.apply(n,e.grammars),n.push.apply(n,t.grammars),n.push.apply(n,i.grammars),n.push({id:"orion.vbhtml",contentTypes:["text/x-vbhtml"],patterns:[{include:"#vbhtmlComment"},{include:"#codeBlock"},{include:"#expression"},{include:"#reference"},{include:"orion.html"}],repository:{vbhtmlComment:{begin:{match:"@\\*",literal:"@*"},end:{match:"\\*@",literal:"*@"},name:"comment.block.vbhtml"},codeBlock:{begin:"(?i)^\\s*@code",end:"(?i)end code",captures:{0:{name:"entity.name.declaration.vb"}},contentName:"source.vb.embedded.vbhtml",patterns:[{include:"orion.xml#tag"},{include:"#reference"},{include:"orion.vb"}]},expression:{match:"(?i)^\\s*@(?!code)[^$]*",name:"source.vb.embedded.vbhtml",patterns:[{include:"#reference"},{include:"orion.vb"}]},reference:{match:"@",name:"entity.name.declaration.vb"}}}),{id:n[n.length-1].id,grammars:n,keywords:[]}}),define("orion/editor/stylers/application_x-ejs/syntax",["orion/editor/stylers/application_javascript/syntax","orion/editor/stylers/application_xml/syntax"],function(e,t){var i=[];return i.push.apply(i,e.grammars),i.push.apply(i,t.grammars),i.push({id:"orion.ejs",contentTypes:["application/x-ejs"],patterns:[{include:"orion.xml#comment"},{include:"orion.xml#doctype"},{begin:"<%=?(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.declaration.js"}},contentName:"source.js.embedded.ejs",patterns:[{include:"orion.js"}]},{include:"orion.xml#tag"},{include:"orion.xml#ampersandEscape"}]}),{id:i[i.length-1].id,grammars:i,keywords:[]}}),define("orion/editor/stylers/text_x-yaml/syntax",[],function(){var e=["false","null","true"],t=["!!bool","!!float","!!int","!!map","!!null","!!omap","!!seq","!!str"],i="orion.yaml",n={id:i,contentTypes:["text/x-yaml"],patterns:[{include:"#numberSignComment"},{match:"^%(?:YAML|TAG)\\s.*",name:"meta.directive.yaml"},{begin:"^.*?:(?:[\\t ]|$)",end:"$",contentName:"string.unquoted.yaml",beginCaptures:{0:{name:"entity.name.key.yaml"}},patterns:[{include:"#numberSignComment"},{match:"^\\s*[&*]\\s*$",name:"entity.name.tag.yaml"},{match:"(?i)^\\s*(?:"+e.join("|")+")\\s*$",name:"keyword.operator.yaml"},{match:"(?i)^\\s*(?:"+t.join("|")+")\\b",name:"keyword.operator.yaml"},{match:"(?i)^\\s*(?:-?[0-9]*(?:\\.[0-9]+)?(?:e[-+][1-9][0-9]*)?)\\s*$",name:"constant.numeric.yaml"},{match:"(?i)^\\s*(?:-?[1-9][0-9]*|0|-?\\.inf|\\.nan)\\s*$",name:"constant.numeric.yaml"}]},{match:"---|\\.\\.\\.",name:"meta.separator.yaml"}],repository:{numberSignComment:{begin:{match:"(?:^|\\s)#",literal:"#"},end:{match:"$",literal:""},name:"comment.line.number-sign.yaml",patterns:[{include:"orion.lib#todo_comment_singleLine"}]}}};return{id:i,grammars:[n],keywords:t.concat(e)}}),define("orion/staticDataSource",["orion/Deferred","orion/editor/textStyler","orion/editor/stylers/application_javascript/syntax","orion/editor/stylers/application_x-jsp/syntax","orion/editor/stylers/application_xquery/syntax","orion/editor/stylers/text_css/syntax","orion/editor/stylers/text_html/syntax","orion/editor/stylers/text_jsx/syntax","orion/editor/stylers/application_json/syntax","orion/editor/stylers/text_x-csrc/syntax","orion/editor/stylers/text_x-csharp/syntax","orion/editor/stylers/text_x-cshtml/syntax","orion/editor/stylers/text_x-c__src/syntax","orion/editor/stylers/text_x-dockerfile/syntax","orion/editor/stylers/text_x-erlang/syntax","orion/editor/stylers/text_x-haml/syntax","orion/editor/stylers/text_x-java-source/syntax","orion/editor/stylers/text_x-jade/syntax","orion/editor/stylers/text_x-lua/syntax","orion/editor/stylers/text_x-php/syntax","orion/editor/stylers/text_x-python/syntax","orion/editor/stylers/text_x-ruby/syntax","orion/editor/stylers/text_x-go/syntax","orion/editor/stylers/text_x-objective-c/syntax","orion/editor/stylers/text_x-smarty/syntax","orion/editor/stylers/text_x-swift/syntax","orion/editor/stylers/text_x-vb/syntax","orion/editor/stylers/text_x-vbhtml/syntax","orion/editor/stylers/application_x-ejs/syntax","orion/editor/stylers/application_xml/syntax","orion/editor/stylers/text_x-yaml/syntax"],function(e,t,i,n,o,r,s,a,l,d,h,c,u,p,f,g,_,m,v,y,x,b,C,w,T,L,k,D,A,S,E){function O(){this.styler=null}var N=[{id:"text/plain",name:"Text",extension:["txt"],imageClass:"file-sprite-text modelDecorationSprite"},{id:"application/javascript","extends":"text/plain",name:"JavaScript",extension:["js"],imageClass:"file-sprite-javascript modelDecorationSprite"},{id:"text/jsx","extends":"text/plain",name:"JSX",extension:["jsx"]},{id:"text/html","extends":"text/plain",name:"HTML",extension:["html","htm"],imageClass:"file-sprite-html modelDecorationSprite"},{id:"text/css","extends":"text/plain",name:"CSS",extension:["css"],imageClass:"file-sprite-css modelDecorationSprite"},{id:"application/json","extends":"text/plain",name:"JSON",extension:["json"],imageClass:"file-sprite-text modelDecorationSprite"},{id:"application/xml","extends":"text/plain",name:"XML",extension:["xml"],imageClass:"file-sprite-xml modelDecorationSprite"},{id:"application/x-ejs","extends":"text/plain",name:"Embedded Javascript",extension:["ejs"],imageClass:"file-sprite-javascript modelDecorationSprite"},{id:"text/x-java-source","extends":"text/plain",name:"Java",extension:["java"]},{id:"application/x-jsp","extends":"text/plain",name:"Java Server Page",extension:["jsp"]},{id:"text/x-jade","extends":"text/plain",name:"Jade",extension:["jade"]},{id:"text/x-python","extends":"text/plain",name:"Python",extension:["py","rpy","pyw","cpy","SConstruct","Sconstruct","sconstruct","SConscript","gyp","gypi"]},{id:"text/x-ruby","extends":"text/plain",name:"Ruby",extension:["rb","rbx","rjs","Rakefile","rake","cgi","fcgi","gemspec","irbrc","capfile","ru","prawn","Gemfile","Guardfile","Vagrantfile","Appraisals","Rantfile"]},{id:"text/x-go",name:"Go",extension:["go"],"extends":"text/plain"},{id:"text/x-launch","extends":"application/json",name:"Launch file",extension:["launch"]},{id:"text/x-objective-c","extends":"text/plain",name:"Objective-C",extension:["m","mm","h"]},{id:"text/x-php","extends":"text/plain",name:"PHP",extension:["php","php3","php4","php5","phpt","phtml","aw","ctp"]},{id:"text/x-smarty","extends":"text/plain",name:"Smarty",extension:["tpl"]},{id:"text/x-swift","extends":"text/plain",name:"Swift",extension:["swift"]},{id:"text/x-markdown","extends":"text/plain",name:"Markdown",extension:["md"]},{id:"text/x-yaml","extends":"text/plain",name:"YAML",extension:["yaml","yml"]},{id:"text/conf","extends":"text/plain",name:"Conf",extension:["conf"]},{id:"text/sh","extends":"text/plain",name:"sh",extension:["sh"]},{id:"application/browser-renderable",name:"browser-renderable"},{id:"application/pdf","extends":"application/browser-renderable",name:"PDF",extension:["pdf"]},{id:"application/octet-stream",name:"octet-stream",extension:["exe","bin","doc","ppt"]},{id:"application/zip","extends":"application/octet-stream",name:"ZIP",extension:["war","jar","zip","rar","gz","tar"]},{id:"text/x-arduino","extends":"text/x-csrc",name:"Arduino",extension:["ino","pde"]},{id:"text/x-csrc","extends":"text/plain",name:"C",extension:["c","h"]},{id:"text/x-csharp","extends":"text/plain",name:"C#",extension:["cs"]},{id:"text/x-cshtml","extends":"text/plain",name:"cshtml",extension:["cshtml"]},{id:"text/x-c++src","extends":"text/plain",name:"C++",extension:["cpp","hpp"]},{id:"text/x-dockerfile","extends":"text/plain",name:"dockerfile",filename:["dockerfile"]},{id:"text/x-erlang","extends":"text/plain",name:"Erlang",extension:["erl","hrl"]},{id:"text/x-haml","extends":"text/plain",name:"Haml",extension:["haml"]},{id:"text/x-lua","extends":"text/plain",name:"Lua",extension:["lua"]},{id:"application/xquery","extends":"text/plain",name:"XQuery",extension:["xq","xqy","xquery"]},{id:"text/x-vb","extends":"text/plain",name:"VB.NET",extension:["vb"]},{id:"text/x-vbhtml","extends":"text/plain",name:"vbhtml",extension:["vbhtml"]},{id:"image/gif",name:"GIF",extension:["gif"],imageClass:"file-sprite-image modelDecorationSprite"},{id:"image/jpeg",name:"JPG",extension:["jpg","jpeg","jpe"],imageClass:"file-sprite-image modelDecorationSprite"},{id:"image/ico",name:"ICO",extension:["ico"],imageClass:"file-sprite-image modelDecorationSprite"},{id:"image/png",name:"PNG",extension:["png"],imageClass:"file-sprite-image modelDecorationSprite"},{id:"image/tiff",name:"TIFF",extension:["tif","tiff"],imageClass:"file-sprite-image modelDecorationSprite"},{id:"image/svg",name:"SVG",extension:["svg"],imageClass:"file-sprite-image modelDecorationSprite"}];return O.prototype={setup:function(e,t,i){return this.styler&&(this.styler.destroy&&this.styler.destroy(),this.styler=null),this._highlight(e,t,i)},highlight:function(e,t,i){var n=i.getTextView(),o=i.getAnnotationModel();return this._highlight(t,n,o)},_highlight:function(O,N,M){this.styler&&(this.styler.destroy(),this.styler=null);var I=null;if(O)switch(O.id){case"application/javascript":I=new t.createPatternBasedAdapter(i.grammars,"orion.js",O.id);break;case"application/x-ejs":I=new t.createPatternBasedAdapter(A.grammars,"orion.ejs",O.id);break;case"text/css":I=new t.createPatternBasedAdapter(r.grammars,"orion.css",O.id);break;case"text/html":I=new t.createPatternBasedAdapter(s.grammars,"orion.html",O.id);break;case"text/jsx":I=new t.createPatternBasedAdapter(a.grammars,"orion.jsx",O.id);break;case"text/x-java-source":I=new t.createPatternBasedAdapter(_.grammars,"orion.java",O.id);break;case"application/x-jsp":I=new t.createPatternBasedAdapter(n.grammars,"orion.jsp",O.id);break;case"application/json":case"text/x-launch":I=new t.createPatternBasedAdapter(l.grammars,"orion.json",O.id);break;case"text/x-jade":I=new t.createPatternBasedAdapter(m.grammars,"orion.jade",O.id);break;case"text/x-python":I=new t.createPatternBasedAdapter(x.grammars,"orion.python",O.id);break;case"text/x-ruby":I=new t.createPatternBasedAdapter(b.grammars,"orion.ruby",O.id);break;case"text/x-go":I=new t.createPatternBasedAdapter(C.grammars,"orion.go",O.id);break;case"text/x-objective-c":I=new t.createPatternBasedAdapter(w.grammars,"orion.objectiveC",O.id);break;case"text/x-php":I=new t.createPatternBasedAdapter(y.grammars,"orion.php",O.id);break;case"text/x-smarty":I=new t.createPatternBasedAdapter(T.grammars,"orion.smarty",O.id);break;case"text/x-swift":I=new t.createPatternBasedAdapter(L.grammars,"orion.swift",O.id);break;case"application/xml":case"application/xhtml+xml":I=new t.createPatternBasedAdapter(S.grammars,"orion.xml",O.id);break;case"text/x-yaml":I=new t.createPatternBasedAdapter(E.grammars,"orion.yaml",O.id);break;case"text/x-arduino":case"text/x-csrc":case"text/x-c":I=new t.createPatternBasedAdapter(d.grammars,"orion.c",O.id);break;case"text/x-csharp":I=new t.createPatternBasedAdapter(h.grammars,"orion.csharp",O.id);break;case"text/x-cshtml":I=new t.createPatternBasedAdapter(c.grammars,"orion.cshtml",O.id);break;case"text/x-c++src":I=new t.createPatternBasedAdapter(u.grammars,"orion.cpp",O.id);break;case"text/x-dockerfile":I=new t.createPatternBasedAdapter(p.grammars,"orion.dockerfile",O.id);break;case"text/x-erlang":I=new t.createPatternBasedAdapter(f.grammars,"orion.erlang",O.id);break;case"text/x-haml":I=new t.createPatternBasedAdapter(g.grammars,"orion.haml",O.id);break;case"text/x-lua":I=new t.createPatternBasedAdapter(v.grammars,"orion.lua",O.id);break;case"application/xquery":I=new t.createPatternBasedAdapter(o.grammars,"orion.xquery",O.id);break;case"text/x-vb":I=new t.createPatternBasedAdapter(k.grammars,"orion.vb",O.id);break;case"text/x-vbhtml":I=new t.createPatternBasedAdapter(D.grammars,"orion.vbhtml",O.id)}return I&&(this.styler=new t.TextStyler(N,M,I)),(new e).resolve()},getStyler:function(){return this.styler}},{ContentTypes:N,SyntaxHighlighter:O}}),define("orion/serviceTracker",[],function(){function e(e,n){function o(e){var t=e.getProperty("service.id"),i=this.addingService(e);i&&(d[t]=e,h[t]=i)}function r(e){var t=e.getProperty("service.id"),i=h[t];delete d[t],delete h[t],this.removedService(e,i)}function s(e){return-1!==e.getProperty("objectClass").indexOf(n)}this.serviceRegistry=e;var a,l,d={},h={},c=t;this.close=function(){if(c!==i)throw new Error("Already closed");c=t,e.removeEventListener("registered",a),e.removeEventListener("unregistering",l),a=null,l=null;var n=this;this.getServiceReferences().forEach(function(e){r.call(n,e)}),"function"==typeof this.onClose&&this.onClose()},this.getServiceReferences=function(){var e=Object.keys(d);return e.length?e.map(function(e){return d[e]}):null},this.open=function(d){if("undefined"==typeof d&&(d=!0),c!==t)throw new Error("Already open");c=i;var h=this;a=function(e){return s(e.serviceReference)&&(o.call(h,e.serviceReference),"function"==typeof h.onServiceAdded)?h.onServiceAdded(e.serviceReference,h.serviceRegistry.getService(e.serviceReference)):void 0},l=function(e){s(e.serviceReference)&&r.call(h,e.serviceReference)},e.addEventListener("registered",a),e.addEventListener("unregistering",l),d&&e.getServiceReferences(n).forEach(function(t){return o.call(h,t),"function"==typeof h.onServiceAdded?h.onServiceAdded(t,e.getService(t)):void 0}),"function"==typeof this.onOpen&&this.onOpen()}}var t=0,i=1;return e.prototype={addingService:function(e){return this.serviceRegistry.getService(e)},onOpen:null,onClose:null,onServiceAdded:null,removedService:function(){}},e}),define("orion/contentTypes",["orion/serviceTracker"],function(e){function t(e,t){return-1!==e.indexOf(t)}function i(e){switch(e&&e.id){case"image/jpeg":case"image/png":case"image/gif":case"image/ico":case"image/tiff":case"image/svg":return!0}return!1}function n(e){return e?"application/octet-stream"===e.id||"application/octet-stream"===e["extends"]:!1}function o(e,i){if("string"!=typeof e)return null;var n,o=null,r=e.indexOf(".");r++;for(var s=e.substring(r).toLowerCase(),a=0;a=0){o=n;break}t(n.extension,s)&&(o=n)}if(!o)for(r=s.indexOf(".");!o&&r>=0;){for(r++,s=s.substring(r),a=0;as;s++){this._addFileModeProperties(this._diffContents[s],o);var a=this._parseHunkRange(s);a&&this._hunkRanges.push(a)}if(0===this._hunkRanges.length)return o.outPutFile=e,o;this._DEBUG&&(console.log("***Diff contents: \n"),this._diffContents.forEach(function(e){console.log(e)}),console.log("***Hunk ranges: \n"),console.log(JSON.stringify(this._hunkRanges)));for(var l=0;l0){console.log(" **Diff content on change/add: \n");for(var t=0;tc;c++)if(0!==this._diffContents[c].length){var u=this._diffContents[c][0];if("\\"!==u||i!==this._diffContents[c].substring(0,this._diffContents[c].length-1)&&i!==this._diffContents[c]){switch(u){case"-":case"+":case" ":break;default:continue}if(t!==u){switch("+"===u&&(d=c),"-"===u&&(h=c),t){case" ":a=this._hunkRanges[e][1]+r,l=this._hunkRanges[e][3]+s;break;case"-":this._createMinusBlock(a,l,this._hunkRanges[e][1]+r-a,h);break;case"+":this._createPlusBlock(a,l,this._hunkRanges[e][3]+s-l,d)}t=u}switch(u){case"-":r++;break;case"+":s++;break;case" ":r++,s++}}else"-"===t?this._oNewLineAtEnd=!1:" "===t?(this._nNewLineAtEnd=!1,this._oNewLineAtEnd=!1):this._nNewLineAtEnd=!1,c>n&&"\r"===this._diffContents[c-1][this._diffContents[c-1].length-1]&&(this._diffContents[c-1]=this._diffContents[c-1].substring(0,this._diffContents[c-1].length-1))}switch(t){case"-":this._createMinusBlock(a,l,this._hunkRanges[e][1]+r-a,h);break;case"+":this._createPlusBlock(a,l,this._hunkRanges[e][3]+s-l,d)}},_detectConflictes:function(e,t){if(0>e)return!1;for(var i=e+t,n=e;i>n;n++){var o=this._diffContents[n];if(o.indexOf("<<<<<")>-1||o.indexOf(">>>>>")>-1)return!0}return!1},_buildMap:function(e){for(var t,i=this._oBlocks.length,n=this._oFileContents.length,o=0,r=1,s=0;i>s;s++)t=this._oBlocks[s][0]-r,t>0&&(this._deltaMap.push([t,t,0]),o+=t),this._deltaMap.push(e&&this._detectConflictes(this._nBlocks[s][2],this._nBlocks[s][1])?[this._nBlocks[s][1],this._oBlocks[s][1],this._nBlocks[s][2]+1,1]:[this._nBlocks[s][1],this._oBlocks[s][1],this._nBlocks[s][2]+1]),o+=this._oBlocks[s][1],r=this._oBlocks[s][0]+this._oBlocks[s][1];if(n-r>0&&(this._deltaMap.push([n-r+1,n-r+1,0]),o+=n-r+1),n>o){t=n-o;var a=this._deltaMap[this._deltaMap.length-1];0===a[2]?(a[0]+=t,a[1]+=t):-1===a[2]?this._deltaMap.push([t,t,0]):this._nNewLineAtEnd===this._oNewLineAtEnd?this._deltaMap.push([t,t,0]):(this._nNewLineAtEnd&&(a[0]+=t),this._oNewLineAtEnd&&(a[1]+=t))}},_buildNewFile:function(){var e,t,i=1,n=!1,o=this._deltaMap.length;for(e=0;o>e;e++){if(n=!1,0===this._deltaMap[e][2]){for(t=0;t0)for(t=0;t=0?i:1)}else t.push(1)},_parseHunkRange:function(e){var t=this._diffContents[e],i=/^@@\s*-([\+|\-]*[\d]+)\s*,*\s*([\d]*)\s*\+([\+|\-]*[\d]+)\s*,*\s*([\d]*)\s*@@+/,n=/^@@\s*\+([\+|\-]*[\d]+)\s*,*\s*([\d]*)\s*-([\+|\-]*[\d]+)\s*,*\s*([\d]*)\s*@@+/,o=i.exec(t),r=null;return o&&5===o.length?(r=[e],this._converHRangeBody(o[1],r),this._converHRangeBody(o[2],r),this._converHRangeBody(o[3],r),this._converHRangeBody(o[4],r)):(o=n.exec(t),o&&5===o.length&&(r=[e],this._converHRangeBody(o[3],r),this._converHRangeBody(o[4],r),this._converHRangeBody(o[1],r),this._converHRangeBody(o[2],r))),r}},e}(),e}),define("orion/URITemplate",[],function(){function e(e){this._text=e}function t(e){return e.replace("%25","%")}function i(e,i){if("U"===i)return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()});if("U+R"===i)return encodeURI(e).replace(/%5B/g,"[").replace(/%5D/g,"]").replace(c,t);if("U+R-,"===i)return encodeURI(e).replace(/%5B/g,"[").replace(/%5D/g,"]").replace(/,/g,"%2C");throw new Error("Unknown allowed character set: "+i)}function n(e,t,n){for(var o=[],r=0;r=n&&n+r>i)return{mapperIndex:o,startFrom:n};if(o===e.length-1)break;n+=e[o][t]}return{mapperIndex:e.length-1,startFrom:n}},t.compareUtils.lookUpLineIndex=function(e,t,i){if(0===i)return 0;for(var n=0,o=0;i>o;o++)n+=e[o][t];return n},t.compareUtils.updateMapper=function(e,i,n,o,r){if(o!==r&&(o>0||r>0)){var s=t.compareUtils.lookUpMapper(e,i,n);if(s.mapperIndex<0)return;if(o>0)for(var a=o,l=n-s.startFrom,d=s.mapperIndex;d=a){e[d][i]-=a;break}e[d][i]-=h,a-=h,l=0}r>0&&(e[s.mapperIndex][i]+=r)}},t.compareUtils.overlapMapper=function(e,t,i,n,o){var r=i+e[t]-1;return i>r&&(r=i),n>o&&(o=n),n>r||i>o?!1:!0},t.compareUtils.findFirstDiff=function(e,i,n,o){for(var r=0,s=null,a=0;ao)&&(!t.compareUtils.overlapMapper(e[a],i,r,n,o)||(s={mapperIndex:a,startFrom:r},0===e[a][2]));a++)r+=e[a][i];return s},t.compareUtils.matchMapper=function(e,i,n,o){if(0===e.length)return n;var r=n+Math.round((o-n)/3),s=t.compareUtils.findFirstDiff(e,i,n,o),a=0===e[s.mapperIndex][i]?s.startFrom:s.startFrom+e[s.mapperIndex][i]-1,l=t.compareUtils.lookUpLineIndex(e,1-i,s.mapperIndex),d=s.startFrom-n;if(0===e[s.mapperIndex][2])return l-d;if(r>=s.startFrom&&a>=r)return l-Math.round((o-n)/3);if(rt?!1:e[t][3]?1===e[t][3]:!1},t.compareUtils.mergeDiffBlocks=function(e,t,i,n,o,r){for(var s=0;s0){for(var h="",c=0;c=p){var f=e.getLineEnd(p-1),g=e.getLineEnd(p-1,!0);f===g?(e.setText(r,f,f),a=p):a=p-1}var _=e.getLineStart(a);e.setText(h,_,_)}}},t.compareUtils.convertMergedLineNumber=function(e,i,n){var o=t.compareUtils.lookUpMapper(e,n?1:0,i),r=i;if(n||0===e[o.mapperIndex][2]||(r+=e[o.mapperIndex][1]),o.mapperIndex<0)return r;for(var s=0;s0)for(var r=n-1;r>-1;r--)t=""===o?"":"/",o=o+t+i[r].Name;return t=""===o?"":"/",o=o+t+e.Name},t.compareUtils}),define("orion/compare/compareRulers",["orion/compare/compareUtils"],function(e){var t=t||{};return t.CompareRuler=function(){function e(e,t,i){this._location=e||"left",this._overview=t||"page",this._rulerStyle=i,this._editor=null;var n=this;this._listener={onModelChanged:function(e){n._onModelChanged(e)}}}return e.prototype={setView:function(e){this._onModelChanged&&this._editor&&this._editor.removeEventListener("ModelChanged",this._listener.onModelChanged),this._editor=e,this._onModelChanged&&this._editor&&this._editor.addEventListener("ModelChanged",this._listener.onModelChanged)},getLocation:function(){return this._location},getOverview:function(){return this._overview},getAnnotationModel:function(){return null},addAnnotationType:function(){},isAnnotationTypeVisible:function(){return!1},removeAnnotationType:function(){},setAnnotationModel:function(){},getAnnotations:function(e,t){for(var i=[],n=e;t>n;n++){var o=this.getStyle(n);o&&(i[n]={html:this.getHTML(n),style:o})}return i},getWidestAnnotation:function(){return{html:this.getHTML(-1),style:this.getStyle(-1)}},getRulerStyle:function(){return this.getStyle(void 0)}},e}(),t.LineNumberCompareRuler=function(){function e(e,i,n,o,r,s){t.CompareRuler.call(this,n,"page",o),this._diffNavigator=e,this._oddStyle=r||{style:{backgroundColor:"white"}},this._evenStyle=s||{style:{backgroundColor:"white"}},this._numOfDigits=0,this._mapperColumnIndex=i}return e.prototype=new t.CompareRuler,e.prototype.getStyle=function(e){return void 0===e?this._rulerStyle:this._evenStyle},e.prototype.getHTML=function(e){var t=this._editor.getModel(),i=this._diffNavigator.getFeeder(0===this._mapperColumnIndex);if(!i)return"";if(-1===e)return t.getLineCount();if(i.getLineNumber){var n=i.getLineNumber(e);return-1===n?"":n+1}return e+1},e.prototype._onModelChanged=function(e){var t=e.start,i=this._editor.getModel(),n=i.getLineCount(),o=(n+"").length;if(this._numOfDigits!==o){this._numOfDigits=o;var r=i.getLineAtOffset(t);this._editor.redrawLines(r,n,this)}},e}(),t.CompareOverviewRuler=function(){function i(e,i,n,o){this._diffNavigator=n,this._onClick=o,t.CompareRuler.call(this,e,"document",i)}return i.prototype=new t.CompareRuler,i.prototype.getStyle=function(t){var i,n;if(void 0===t)i=this._rulerStyle||{},n=i.style||(i.style={}),n.lineHeight="1px",n.fontSize="1px",n.width="14px";else{if(i=-1!==t?{styleClass:"annotationOverview breakpoint"}||{}:{},n=i.style||(i.style={}),n.cursor="pointer",n.width="8px",n.left="2px",!(t>=0))return null;var o;if(!this._diffNavigator||!this._diffNavigator.getFeeder())return null;o=this._diffNavigator.getFeeder().getDiffBlocks();var r=e.getAnnotationIndex(o,t);if(-1===r)return null;var s,a=e.getAnnotationMapperIndex(o,r);s=this._diffNavigator.getMapper();var l=e.isMapperConflict(s,a);l&&(n.border="1px #FF0000 solid"),r===this._diffNavigator.getCurrentBlockIndex()&&(n.backgroundColor=l?"red":"blue");var d=this._diffNavigator.getFeeder().getDiffBlockH(r),h=this._diffNavigator.getFeeder().getOverviewLineCount();if(0>d)return null;var c=this._editor.getClientArea(),u=Math.floor(c.height*d/h);2>u&&(u=2),n.height=u+"px"}return i},i.prototype.setDiffNavigator=function(e){this._diffNavigator=e},i.prototype.getHTML=function(){return" "},i.prototype.onClick=function(e){void 0!==e&&this._onClick(e,this)},i.prototype._onModelChanged=function(){var e=this._editor.getModel(),t=e.getLineCount();t>0&&this._editor.redrawLines(0,1,this)},i}(),t.CompareCurveRuler=function(){function t(e){this._canvasDiv=e,this._mapper=void 0}return t.prototype={init:function(e,t,i,n){this._leftIniting=!0,this._rightIniting=!0,this._rightIniting=!0,this._mapper=e,this._leftEditor=t,this._rightEditor=i,this._leftTextView=t.getTextView(),this._rightTextView=i.getTextView(),this._diffNavigator=n,this.render()},matchPositionFrom:function(t){var i=t?this._leftTextView:this._rightTextView,n=t?this._rightTextView:this._leftTextView,o=i.getTopIndex(),r=i.getBottomIndex(),s=e.matchMapper(this._mapper,t?0:1,o,r);n.setTopIndex(s)},copyTo:function(e){if(this._diffNavigator.iterator){var t=this._diffNavigator.iterator.cursor();if(t){var i;if(i="word"===t.type?!t.copied&&!t.parent.copied:!t.copied,!i)return;var n=e?this._rightTextView.getText(t.oldA.start,t.oldA.end):this._leftTextView.getText(t.newA.start,t.newA.end),o=e?t.newA:t.oldA,r=e?this._leftTextView:this._rightTextView;r.setText(n,o.start,o.end),t.copied=!0}}},render:function(){if(this._mapper){var t=this._canvasDiv.getContext("2d");t.clearRect(0,0,this._canvasDiv.width,this._canvasDiv.height),t.strokeStyle="#AAAAAA",t.lineWidth=1,t.beginPath();var i=this._leftTextView.getTopIndex(),n=this._leftTextView.getBottomIndex(),o=this._rightTextView.getTopIndex(),r=this._rightTextView.getBottomIndex();this._leftLineH=this._leftTextView.getLineHeight(),this._rightLineH=this._rightTextView.getLineHeight();for(var s=0,a=0,l=!1,d=0;d0||t.addedLineCount>0)&&this.render()}return i?this._rightIniting=!1:this._leftIniting=!1,n}},t}(),t}),define("orion/regex",[],function(){function e(e){return e.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&")}function t(e){var t=/^\s*\/(.+)\/([gim]{0,3})\s*$/.exec(e);return t?{pattern:t[1],flags:t[2]}:null}return{escape:e,parse:t}}),define("orion/editor/textModel",["orion/editor/eventTarget","orion/regex","orion/util"],function(e,t,i){function n(e,t){this._lastLineIndex=-1,this._text=[""],this._lineOffsets=[0],this.setText(e),this.setLineDelimiter(t)}return n.prototype={destroy:function(){},find:function(e){this._text.length>1&&(this._text=[this._text.join("")]);var i=e.string,n=e.regex,o=i,r="",s=e.caseInsensitive;if(o)if(n){var a=t.parse(o);a&&(o=a.pattern,r=a.flags)}else o=i.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&"),s&&(o=o.replace(/[iI\u0130\u0131]/g,"[Iiİı]"));var l,d=null;if(o){var h=e.reverse,c=e.wrap,u=e.wholeWord,p=e.start||0,f=e.end,g=null!==f&&void 0!==f;-1===r.indexOf("g")&&(r+="g"),-1===r.indexOf("m")&&(r+="m"),s&&-1===r.indexOf("i")&&(r+="i"),u&&(o="\\b"+o+"\\b");var _,m,v=this._text[0],y=0;if(g){var x=f>p?p:f,b=f>p?f:p;v=v.substring(x,b),y=x}var C=new RegExp(o,r);h?l=function(){var e=null;for(C.lastIndex=0;;){if(m=C.lastIndex,_=C.exec(v),m===C.lastIndex)return null;if(!_)break;if(_.index+y=0&&i>e))return null;var n=this._lineOffsets[e];if(i>e+1){var o=this.getText(n,this._lineOffsets[e+1]);if(t)return o;for(var r,s=o.length;10===(r=o.charCodeAt(s-1))||13===r;)s--;return o.substring(0,s)}return this.getText(n)},getLineAtOffset:function(e){var t=this.getCharCount();if(!(e>=0&&t>=e))return-1;var i=this.getLineCount();if(e===t)return i-1;var n,o,r=this._lastLineIndex;if(r>=0&&i>r&&(n=this._lineOffsets[r],o=i>r+1?this._lineOffsets[r+1]:t,e>=n&&o>e))return r;for(var s=i,a=-1;s-a>1;)if(r=Math.floor((s+a)/2),n=this._lineOffsets[r],o=i>r+1?this._lineOffsets[r+1]:t,n>=e)s=r;else{if(o>e){s=r;break}a=r}return this._lastLineIndex=s,s},getLineCount:function(){return this._lineOffsets.length},getLineDelimiter:function(){return this._lineDelimiter},getLineEnd:function(e,t){var i=this.getLineCount();if(!(e>=0&&i>e))return-1;if(i>e+1){var n=this._lineOffsets[e+1];if(t)return n;for(var o,r=this.getText(Math.max(this._lineOffsets[e],n-2),n),s=r.length;10===(o=r.charCodeAt(s-1))||13===o;)s--;return n-(r.length-s)}return this.getCharCount()},getLineStart:function(e){return e>=0&&e=e));)n+=i,o++;for(var r=n,s=o;o=t));)n+=i,o++;var a=n,l=o;if(s>=this._text.length||l>=this._text.length||s>l)return"";if(s===l)return this._text[s].substring(e-r,t-a);var d=this._text[s].substring(e-r),h=this._text[l].substring(0,t-a);return d+this._text.slice(s+1,l).join("")+h},onChanging:function(e){return this.dispatchEvent(e)},onChanged:function(e){return this.dispatchEvent(e)},setLineDelimiter:function(e,t){if("auto"===e&&(e=void 0,this.getLineCount()>1&&(e=this.getText(this.getLineEnd(0),this.getLineEnd(0,!0)))),this._lineDelimiter=e?e:i.platformDelimiter,t){var n=this.getLineCount();if(n>1){for(var o=new Array(n),r=0;n>r;r++)o[r]=this.getLine(r);this.setText(o.join(this._lineDelimiter))}}},setText:function(e,t,i){if(void 0===e&&(e=""),void 0===t&&(t=0),void 0===i&&(i=this.getCharCount()),t!==i||""!==e){for(var n=this.getLineAtOffset(t),o=this.getLineAtOffset(i),r=t,s=i-t,a=o-n,l=e.length,d=0,h=this.getLineCount(),c=0,u=0,p=0,f=[];;){if(-1!==c&&p>=c&&(c=e.indexOf("\r",p)),-1!==u&&p>=u&&(u=e.indexOf("\n",p)),-1===u&&-1===c)break;p=-1!==c&&-1!==u?c+1===u?u+1:(u>c?c:u)+1:-1!==c?c+1:u+1,f.push(t+p),d++}var g={type:"Changing",text:e,start:r,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:d};if(this.onChanging(g),0===f.length){var _,m=this.getLineStart(n);_=h>o+1?this.getLineStart(o+1):this.getCharCount(),t!==m&&(e=this.getText(m,t)+e,t=m),i!==_&&(e+=this.getText(i,_),i=_)}for(var v=l-s,y=n+a+1;h>y;y++)this._lineOffsets[y]+=v;var x,b=5e4,C=b;if(f.length=t));)L+=T,k++;for(var D=L,A=k;k=i));)L+=T,k++;var S=L,E=k,O=this._text[A],N=this._text[E],M=O.substring(0,t-D),I=N.substring(i-S),B=[A,E-A+1];M&&B.push(M),e&&B.push(e),I&&B.push(I),Array.prototype.splice.apply(this._text,B),0===this._text.length&&(this._text=[""]);var R={type:"Changed",start:r,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:d};this.onChanged(R)}}},e.EventTarget.addMixin(n.prototype),{TextModel:n}}),define("orion/editor/keyModes",["orion/keyBinding","orion/util"],function(e,t){function i(e){e&&(this._view=e,this._keyBindings=this.createKeyBindings(),this._keyBindingIndex=0)}function n(e){i.call(this,e)}return i.prototype={createKeyBindings:function(){return[]},getKeyBindings:function(e){for(var t=[],i=this._keyBindings,n=0;nn){var c=o(n);t=s+c*l,r(t)}else r(a),h.stop()}var t,i="number"==typeof this.options.duration?this.options.duration:350,n="number"==typeof this.options.rate?this.options.rate:20,o=this.options.easing||this.defaultEasing,r=this.options.onAnimate||function(){},s=this.options.curve[0],a=this.options.curve[1],l=a-s,d=-1,h=this;this.interval=this.options.window.setInterval(e,n)},e.prototype.stop=function(){this.options.window.clearInterval(this.interval);var e=this.options.onEnd||function(){};e()},e.prototype.defaultEasing=function(e){return Math.sin(e*(Math.PI/2))},e}();return{contains:i,getNodeStyle:n,addEventListener:e,removeEventListener:t,Animation:o}}),define("orion/editor/textView",["i18n!orion/editor/nls/messages","orion/editor/textModel","orion/editor/keyModes","orion/editor/eventTarget","orion/editor/textTheme","orion/editor/util","orion/util","orion/metrics"],function(e,t,i,n,o,r,s,a){function l(e){return e.defaultView||e.parentWindow}function d(e){return new Array(e)}function h(e,t,i){if(i){t.className="";for(var n=t.attributes,o=n.length;o-->0;)(!s.isIE||s.isIE>=9||s.isIE<9&&n[o].specified)&&t.removeAttribute(n[o].name)}if(e){e.styleClass&&(t.className=e.styleClass);var r=e.style;if(r)for(var a in r)r.hasOwnProperty(a)&&(t.style[a]=r[a]);var l=e.attributes;if(l)for(var d in l)l.hasOwnProperty(d)&&t.setAttribute(d,l[d])}}function c(e){return e instanceof Array?e.slice(0):e}function u(e,t){if(!e)return t;if(!t)return e;for(var i in t)t.hasOwnProperty(i)&&(e.hasOwnProperty(i)||(e[i]=t[i]));return e}function p(e,t){if(e===t)return!0;if(e&&!t||!e&&t)return!1;if(e&&e.constructor===String||t&&t.constructor===String)return!1;if(e instanceof Array||t instanceof Array){if(!(e instanceof Array&&t instanceof Array))return!1;if(e.length!==t.length)return!1;for(var i=0;ir;){-1!==n&&r>=n&&(n=e.indexOf("\r",r)),-1!==o&&r>=o&&(o=e.indexOf("\n",r));var a,l=r;if(-1===o&&-1===n){t(e.substring(r));break}-1!==n&&-1!==o?n+1===o?(a=n,r=o+1):(a=o>n?n:o,r=(o>n?n:o)+1):-1!==n?(a=n,r=n+1):(a=o,r=o+1),t(e.substring(l,a)),i?i():r===s&&t("")}}function g(e){var t,i,n,o,r=l(e.ownerDocument);if(r.getComputedStyle){var s=r.getComputedStyle(e,null);t=s.getPropertyValue("border-left-width"),i=s.getPropertyValue("border-top-width"),n=s.getPropertyValue("border-right-width"),o=s.getPropertyValue("border-bottom-width")}else e.currentStyle&&(t=e.currentStyle.borderLeftWidth,i=e.currentStyle.borderTopWidth,n=e.currentStyle.borderRightWidth,o=e.currentStyle.borderBottomWidth);return{left:parseInt(t,10)||0,top:parseInt(i,10)||0,right:parseInt(n,10)||0,bottom:parseInt(o,10)||0}}function _(e){var t,i,n,o,r=l(e.ownerDocument);if(r.getComputedStyle){var s=r.getComputedStyle(e,null);t=s.getPropertyValue("padding-left"),i=s.getPropertyValue("padding-top"),n=s.getPropertyValue("padding-right"),o=s.getPropertyValue("padding-bottom")}else e.currentStyle&&(t=e.currentStyle.paddingLeft,i=e.currentStyle.paddingTop,n=e.currentStyle.paddingRight,o=e.currentStyle.paddingBottom);return{left:parseInt(t,10)||0,top:parseInt(i,10)||0,right:parseInt(n,10)||0,bottom:parseInt(o,10)||0}}function m(e){var t=e._trim;if(!t){t=_(e);var i=g(e);t.left+=i.left,t.top+=i.top,t.right+=i.right,t.bottom+=i.bottom,e._trim=t}return t}function v(e,t,i,n){function o(t){if(t.animationName===a){var i=t.target;"function"==typeof i.__DOMReady&&l(e).setTimeout(function(){i.__DOMReady()},0)}}function r(e,t){for(var i=["","-webkit-","-moz-","-ms-","-o-"],n="",o="body ."+e+" {\n",r=0;ri;i++){var n=e._createSelectionDiv();t.appendChild(n),this._divs.push(n)}}function b(e){this.left=e.left,this.top=e.top,this.right=e.right,this.bottom=e.bottom}function C(e,t,i){this.view=e,this.lineIndex=t,this._lineDiv=i}function w(e){this._init(e||{})}var T=r.addEventListener,L=r.removeEventListener,k=r.Animation;return y.compare=function(e,t){if(e.length!==t.length)return!1;for(var i=0;i=0;i--)if(e[i]._editing)return e[i];return e[e.length-1]}for(i=0;i=i.end||i._editing||e[n]._editing?(t.push(i),i=e[n]):i.end=Math.max(i.end,e[n].end);return t.push(i),t},y.prototype={clone:function(){var e=new y(this.start,this.end,this.caret);return e._columnX=this._columnX,e._editing=this._editing,e._docX=this._docX,e},contains:function(e){return this.start<=e&&ethis.end){var t=this.start;this.start=this.end,this.end=t,this.caret=!this.caret}},setCaret:function(e){this.start=e,this.end=e,this.caret=!1},getCaret:function(){return this.caret?this.start:this.end},getAnchor:function(){return this.caret?this.end:this.start},getOrientedSelection:function(){return{start:this.getAnchor(),end:this.getCaret()}},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(e){return this.caret===e.caret&&this.start===e.start&&this.end===e.end&&this._editing===e._editing}},x.prototype={destroy:function(){this._divs&&(this._divs.forEach(function(e){e.parentNode.removeChild(e)}),this._divs=null)},setPrimary:function(e){this.primary=e},update:function(){var e,t=this._view,i=this.primary,n=t._hasFocus,o=t._cursorVisible,r=!this.primary&&this._selection&&this._selection.isEmpty();e=r?"textviewSelectionCaret":n?"textviewSelection":"textviewSelectionUnfocused",this._divs[0].style.visibility=r&&o&&n||!r?"visible":"hidden",this._divs[0].style.zIndex=o&&r?"2":"0",this._divs.forEach(function(t){t.className=e,s.isWebkit<537.36&&i&&(t.style.background=n?"transparent":"")})},setSelection:function(e){this._selection=e,this.update();var t=this._view,i=t._model,n=i.getLineAtOffset(e.start),o=i.getLineAtOffset(e.end),r=t._getLineNext();if(r){var s,a,l,d,h=t._getLinePrevious();nh.lineIndex?(s=h,l=i.getLineStart(h.lineIndex)):(s=t._getLineNode(n),l=e.start),oh.lineIndex?(a=h,d=i.getLineStart(h.lineIndex)):(a=t._getLineNode(o),d=e.end),this._setDOMSelection(s,l,a,d,e.caret)}},_setDOMSelection:function(e,t,i,n,o){if(this._setDOMFullSelection(e,t,i,n),this.primary){var r=this._view,a=e._line.getNodeOffset(t),l=i._line.getNodeOffset(n);if(a.node&&l.node){var d,h=r._getWindow(),c=r._parent.ownerDocument;if(h.getSelection){var u=h.getSelection();if(d=c.createRange(),d.setStart(a.node,a.offset),d.setEnd(l.node,l.offset),!r._hasFocus||u.anchorNode===a.node&&u.anchorOffset===a.offset&&u.focusNode===l.node&&u.focusOffset===l.offset&&u.anchorNode===l.node&&u.anchorOffset===l.offset&&u.focusNode===a.node&&u.focusOffset===a.offset||(r._anchorNode=a.node,r._anchorOffset=a.offset,r._focusNode=l.node,r._focusOffset=l.offset,r._ignoreSelect=!1,u.rangeCount>0&&u.removeAllRanges(),u.addRange(d),r._ignoreSelect=!0),r._cursorDiv){d=c.createRange(),o?(d.setStart(a.node,a.offset),d.setEnd(a.node,a.offset)):(d.setStart(l.node,l.offset),d.setEnd(l.node,l.offset));var p=d.getClientRects()[0],f=r._cursorDiv.parentNode,g=f.getBoundingClientRect();p&&g&&(r._cursorDiv.style.top=p.top-g.top+f.scrollTop+"px",r._cursorDiv.style.left=p.left-g.left+f.scrollLeft+"px")}}else if(c.selection){if(!r._hasFocus)return;var _=c.body,m=s.createElement(c,"div");_.appendChild(m),_.removeChild(m),d=_.createTextRange(),d.moveToElementText(a.node.parentNode),d.moveStart("character",a.offset);var v=_.createTextRange();v.moveToElementText(l.node.parentNode),v.moveStart("character",l.offset),d.setEndPoint("EndToStart",v),r._ignoreSelect=!1,d.select(),r._ignoreSelect=!0}}}},_setDOMFullSelection:function(e,t,i,n){this._divs.forEach(function(e){e.style.width=e.style.height="0px"});var o=this._view;if(o._fullSelection&&!(s.isIOS||e===i&&t===n&&this.primary)){var r=o._getViewPadding(),a=o._clientDiv.getBoundingClientRect(),l=o._viewDiv.getBoundingClientRect(),d=l.left+r.left,h=a.right,c=l.top+r.top,u=a.bottom,p=0,f=0;if(o._clipDiv){var g=o._clipDiv.getBoundingClientRect();p=g.left-o._clipDiv.scrollLeft,f=g.top}else{var _=o._rootDiv.getBoundingClientRect();p=_.left,f=_.top}o._ignoreDOMSelection=!0;var m,v,y=new C(o,e.lineIndex,e),x=y.getBoundingClientRect(t,!1),b=x.left;e===i&&t===n?(m=y,v=x):(m=new C(o,i.lineIndex,i),v=m.getBoundingClientRect(n,!1));var w=v.left;o._ignoreDOMSelection=!1;var T=this._divs[0],L=Math.min(h,Math.max(d,b)),k=Math.min(u,Math.max(c,x.top)),D=h,A=Math.min(u,Math.max(c,x.bottom));if(T.style.left=L-p+"px",T.style.top=k-f+"px",T.style.width=Math.max(0,D-L)+"px",T.style.height=Math.max(0,A-k)+"px",e.lineIndex===i.lineIndex)D=Math.min(w,h),T.style.width=Math.max(this.primary?0:1,D-L)+"px";else{var S=d,E=Math.min(u,Math.max(c,v.top)),O=Math.min(h,Math.max(d,w)),N=Math.min(u,Math.max(c,v.bottom)),M=this._divs[2];if(M.style.left=S-p+"px",M.style.top=E-f+"px",M.style.width=Math.max(0,O-S)+"px",M.style.height=Math.max(0,N-E)+"px",Math.abs(e.lineIndex-i.lineIndex)>1){var I=this._divs[1];I.style.left=d-p+"px",I.style.top=A-f+"px",I.style.width=Math.max(0,h-d)+"px",I.style.height=Math.max(0,E-A)+"px"}}}}},b.prototype={toString:function(){return"{l="+this.left+", t="+this.top+", r="+this.right+", b="+this.bottom+"}"}},C.prototype={create:function(e,t){if(!this._lineDiv){var i=this._lineDiv=this._createLine(e,t,this.lineIndex);return i._line=this,i}},_createLine:function(e,t,i){var n=this.view,o=n._model,r=o.getLine(i),a=o.getLineStart(i),l={type:"LineStyle",textView:n,lineIndex:i,lineText:r,lineStart:a};n.onLineStyle(l);var d=e.ownerDocument,c=t||s.createElement(d,"div");if(t&&p(t.viewStyle,l.style)||(h(l.style,c,t),t&&(t._trim=null),c.viewStyle=l.style,c.setAttribute("role","presentation")),c.lineIndex=i,t&&c.viewLineText===r&&p(l.ranges,c.viewRanges))return c;c.viewRanges=l.ranges,c.viewLineText=r;var u=[],f={tabOffset:0,ranges:u};this._createRanges(l.ranges,r,0,r.length,a,f);var g=" ";!n._fullSelection&&s.isIE<9&&(g="");var _={text:g,style:n._metrics.largestFontStyle,ignoreChars:1};0!==u.length&&u[u.length-1].style&&"div"===u[u.length-1].style.tagName?u.splice(u.length-1,0,_):u.push(_);var m,v,y,x,b,C,w,T,L=0,k=0;if(s.isFirefox&&r.length>2e3){t&&(c.innerHTML="",t.lineWidth=void 0);var D=d.createDocumentFragment();for(T=0;T=S&&(O-=A);var N=y.firstChild.data,M=N?N.length:0;if(k+M>O)break;k+=M}w=y.nextSibling,c.removeChild(y),y=w}}m=this._createSpan(c,b,v,_.ignoreChars),y?c.insertBefore(m,y):c.appendChild(m),t&&(t.lineWidth=void 0)}if(t)for(var I=m?m.nextSibling:null;I;)w=I.nextSibling,t.removeChild(I),I=w}return c.parentNode||e.appendChild(c),c},_createRanges:function(e,t,i,n,o,r){if(!(i>n)){if(e)for(var s=0;sn)break;var d=Math.min(o+n,a.end)-o;if(d>=l){if(l=Math.max(i,l),d=Math.min(n,d),l>i&&this._createRange(t,i,l,null,r),!a.style||!a.style.unmergeable)for(;s+1i&&this._createRange(t,i,n,null,r)}},_createRange:function(e,t,i,n,o){if(!(t>i)){var r,s=this.view._customTabSize;if(s&&8!==s)for(var a=e.indexOf(" ",t);-1!==a&&i>a;){a>t&&(r={text:e.substring(t,a),style:n},o.ranges.push(r),o.tabOffset+=r.text.length);var l=s-o.tabOffset%s;if(l>0){for(var d=" ",h=1;l>h;h++)d+=" ";r={text:d,style:n,ignoreChars:l-1},o.ranges.push(r),o.tabOffset+=r.text.length}if(t=a+1,t===i)return;a=e.indexOf(" ",t)}i>=t&&(r={text:e.substring(t,i),style:n},o.ranges.push(r),o.tabOffset+=r.text.length)}},_createSpan:function(e,t,i,n){var o=this.view,r="span";i&&i.tagName&&(r=i.tagName.toLowerCase());var a="a"===r;a&&(this.hasLink=!0),a&&!o._linksVisible&&(r="span");var l=e.ownerDocument,d=s.createElement(e.ownerDocument,r);if(d.appendChild(l.createTextNode(i&&i.text?i.text:t)),i&&i.html?(d.innerHTML=i.html,d.ignore=!0):i&&i.node&&(d.appendChild(i.node),d.ignore=!0),h(i,d),"a"===r){var c=o._getWindow();T(d,"click",function(e){return o._handleLinkClick(e?e:c.event)},!1)}return d.viewStyle=i,n&&(d.ignoreChars=n),d},_ensureCreated:function(){return this._lineDiv?this._lineDiv:this._createdDiv=this.create(this.view._clientDiv,null)},getBoundingClientRect:function(e,t){var i=this._ensureCreated(),n=this.view;if(void 0===e)return this._getLineBoundingClientRect(i,!0);var o=n._model,r=i.ownerDocument,a=this.lineIndex,d=null;if(ee){var c,u=e-h;if(1===o.length)d=new b(t.getBoundingClientRect());else if(n._isRangeRects)c=r.createRange(),c.setStart(o,u),c.setEnd(o,u+1),d=new b(c.getBoundingClientRect());else if(s.isIE){c=r.body.createTextRange(),c.moveToElementText(t),c.collapse();var p=0===u&&8===s.isIE;p&&(u=1),c.moveEnd("character",u+1),c.moveStart("character",u),d=new b(c.getBoundingClientRect()),p&&(d.left=t.getClientRects()[0].left)}else{var f=o.data;t.removeChild(o),t.appendChild(r.createTextNode(f.substring(0,u)));var g=s.createElement(r,"span");if(g.appendChild(r.createTextNode(f.substring(u,u+1))),t.appendChild(g),t.appendChild(r.createTextNode(f.substring(u+1))),d=new b(g.getBoundingClientRect()),t.innerHTML="",t.appendChild(o),!this._createdDiv){var _=n._getSelections()[0];(h<=_.start&&_.starts.right&&(s.right=a.right),a.bottom>s.bottom&&(s.bottom=a.bottom))}}return!0}),void 0!==e?i[e]:i},_getLineBoundingClientRect:function(e,t){var i=new b(e.getBoundingClientRect());if(this.view._wrapMode);else{i.right=i.left;for(var n=e.lastChild;n&&n.ignoreChars===n.firstChild.length;)n=n.previousSibling;if(n){var o=n.getBoundingClientRect();i.right=o.right+m(e).right}}if(t){var r=m(e);i.left=i.left+r.left,i.right=i.right-r.right}return i},getLineCount:function(){return this.view._wrapMode?this.getClientRects().length:1},getLineIndex:function(e){if(!this.view._wrapMode)return 0;for(var t=this.getClientRects(),i=this.getBoundingClientRect(e),n=i.top+(i.bottom-i.top)/2,o=0;os||n+r>=a?(t=o,i=s-n,e.ignoreChars&&r>0&&i===r&&(i+=e.ignoreChars),!1):(n+=r,!0)}),{node:t,offset:i}},getText:function(e){var t="",i=0;return this.forEach(function(n){var o;if(n.ignoreChars){o=n.lastChild;for(var r=0,s=[],a=-1;o;){var l=o.data;if(l)for(var d=l.length-1;d>=0;d--){var h=l.substring(d,d+1);r1;){var N=Math.floor((E+O)/2);y=O+1,x=N===T-1&&i.ignoreChars?w.length:N+1,b=0===y&&8===s.isIE,o._isRangeRects?(v.setStart(w,y),v.setEnd(w,x)):(b&&(y=1),v.moveToElementText(i),v.move("character",y),v.moveEnd("character",x-y)),C=v.getClientRects();for(var M=!1,I=0;I=c&&_>e&&(!o._wrapMode||t>=u&&m>=t)){M=!0;break}M?E=N:O=N}n+=E,y=E,x=E===T-1&&i.ignoreChars?w.length:Math.min(E+1,w.length),o._isRangeRects?(v.setStart(w,y),v.setEnd(w,x)):(v.moveToElementText(i),v.move("character",y),v.moveEnd("character",x-y)),C=v.getClientRects();var B=!1;C.length>0&&(h=C[0],c=(b?S:h.left)*D-f.left,_=h.right*D-f.left,B=e>c+(_-c)/2);var R=n-d,F=r.getLine(a),P=F.charCodeAt(R);P>=55296&&56319>=P&&B?R=56320&&57343>=P&&(n+=1)):P>=56320&&57343>=P&&!B&&R>0&&(P=F.charCodeAt(R-1),P>=55296&&56319>=P&&(n-=1)),B&&n++}else{for(var W=[],V=0;T>V;V++)W.push(""),W.push(V===T-1?w.data.substring(V):w.data.substring(V,V+1)),W.push("");i.innerHTML=W.join("");for(var H=i.firstChild;H;){if(h=H.getBoundingClientRect(),c=h.left-f.left,_=h.right-f.left,e>=c&&_>e){e>c+(_-c)/2&&n++;break}n++,H=H.nextSibling}if(!g._createdDiv){i.innerHTML="",i.appendChild(w);var U=o._getSelections()[0];(n<=U.start&&U.startu.right&&(e=u.right-1)}else 0>e&&(e=0),e>f.right-f.left&&(e=f.right-f.left);var m,v;if(this._lastHitChild&&this._lastHitChild.parentNode){if(m=this._lastHitOffset,v=this._lastHitChild,u=n(v),!u)for(var y=m,x=m+this._nodeLength(v),b=v.previousSibling,C=v.nextSibling;b||C;){if(b){if(y-=this._nodeLength(b),u=n(b)){v=b,m=y;break}b=b.previousSibling}if(C){if(u=n(C)){v=C,m=x;break}x+=this._nodeLength(C),C=C.nextSibling}}}else m=d,this.forEach(function(e){return v=e,(u=n(v))?!1:(m+=this._nodeLength(v),!0)});return v&&u&&(this._lastHitChild=v,this._lastHitOffset=m,m=i(v,m,u)),Math.min(h,Math.max(d,m))},getNextOffset:function(e,t){if("line"===t.unit){var i=this.view,n=i._model,o=n.getLineAtOffset(e);return t.count>0?(t.count--,n.getLineEnd(o)):(t.count++,n.getLineStart(o))}return"wordend"===t.unit||"wordWS"===t.unit||"wordendWS"===t.unit?this._getNextOffset_W3C(e,t):s.isIE?this._getNextOffset_IE(e,t):this._getNextOffset_W3C(e,t)},_getNextOffset_W3C:function(e,t){function i(e){return e>=33&&47>=e||e>=58&&64>=e||e>=91&&94>=e||96===e||e>=123&&126>=e}function n(e){return 32===e||9===e}var o,r=this.view,s=r._model,a=s.getLineAtOffset(e),l=s.getLine(a),d=s.getLineStart(a),h=s.getLineEnd(a),c=l.length,u=e-d,p=t.count<0?-1:1;if("word"===t.unit||"wordend"===t.unit||"wordWS"===t.unit||"wordendWS"===t.unit)for(var f,g,_,m;0!==t.count;){if(t.count>0){if(u===c)return h;for(o=l.charCodeAt(u),f=i(o),g=!f&&!n(o),u++;c>u;){if(o=l.charCodeAt(u),"wordWS"!==t.unit&&"wordendWS"!==t.unit){if(_=i(o),"wordend"===t.unit){if(!_&&f)break}else if(_&&!f)break;m=!_&&!n(o)}else m=!n(o);if("wordend"===t.unit||"wordendWS"===t.unit){if(!m&&g)break}else if(m&&!g)break;g=m,f=_,u++}}else{if(0===u)return d;for(u--,o=l.charCodeAt(u),f=i(o),g=!f&&!n(o);u>0;){if(o=l.charCodeAt(u-1),"wordWS"!==t.unit&&"wordendWS"!==t.unit){if(_=i(o),"wordend"===t.unit){if(_&&!f)break}else if(!_&&f)break;m=!_&&!n(o)}else m=!n(o);if("wordend"===t.unit||"wordendWS"===t.unit){if(m&&!g)break}else if(!m&&g)break;g=m,f=_,u--}}t.count-=p}else for(;0!==t.count&&u+p>=0&&c>=u+p;)u+=p,o=l.charCodeAt(u),o>=56320&&57343>=o&&u>0&&(o=l.charCodeAt(u-1),o>=55296&&56319>=o&&(u+=p)),t.count-=p;return d+u},_getNextOffset_IE:function(e,t){var i,n,o,r=this._ensureCreated(),s=this.view,a=s._model,l=this.lineIndex,d=0,h=a.getLineStart(l),c=a.getLine(l),u=a.getLineStart(l),p=r.ownerDocument,f=t.count<0?-1:1;if(e===a.getLineEnd(l)){for(o=r.lastChild;o&&o.ignoreChars===o.firstChild.length;)o=o.previousSibling;if(!o)return h;i=p.body.createTextRange(),i.moveToElementText(o),n=i.text.length,i.moveEnd(t.unit,f),d=e+i.text.length-n}else if(e===h&&t.count<0)d=h;else for(o=r.firstChild;o;){var g=this._nodeLength(o);if(h+g>e){if(i=p.body.createTextRange(),e===h&&t.count<0){for(var _=o.previousSibling;_&&(!_.firstChild||!_.firstChild.length);)_=_.previousSibling;i.moveToElementText(_?_:o.previousSibling)}else i.moveToElementText(o),i.collapse(),i.moveEnd("character",e-h);n=i.text.length,i.moveEnd(t.unit,f),d=e+i.text.length-n;break}h=g+h,o=o.nextSibling}var m=d-u,v=c.charCodeAt(m);return v>=56320&&57343>=v&&m>0&&(v=c.charCodeAt(m-1),v>=55296&&56319>=v&&(m+=f)),d=m+u,t.count-=f,d},updateLinks:function(){var e=this._ensureCreated();if(this.hasLink){var t=this;this.forEach(function(i){var n=i.viewStyle;return n&&n.tagName&&"a"===n.tagName.toLowerCase()&&e.replaceChild(t._createSpan(e,i.firstChild.data,n),i),!0})}},destroy:function(){var e=this._createdDiv;e&&(e.parentNode.removeChild(e),this._createdDiv=null)}},w.prototype={addKeyMode:function(e,t){var i=this._keyModes;void 0!==t?i.splice(t,0,e):i.push(e),e._modeAdded&&e._modeAdded()},addRuler:function(e,t){var i=this._rulers;if(void 0!==t){var n,o;for(n=0,o=0;no;n++)e.getLocation()===i[n].getLocation()&&o++;i.splice(o,0,e),t=o}else i.push(e);this._createRuler(e,t),e.setView(this),this._update()},computeSize:function(){var e=0,t=0,i=this._model,n=this._clientDiv;if(!n)return{width:e,height:t};var o=n.style.width;s.isWebkit&&(n.style.width="0x7fffffffpx");for(var r=i.getLineCount(),a=0;r>a;a++){var l=this._getLine(a),d=l.getBoundingClientRect();e=Math.max(e,d.right-d.left),t+=d.bottom-d.top,l.destroy()}s.isWebkit&&(n.style.width=o);var h=this._getViewPadding();return e+=h.right+h.left+this._metrics.scrollWidth,t+=h.bottom+h.top+this._metrics.scrollWidth,{width:e,height:t}},convert:function(e,t,i){if(!this._clientDiv)return e;var n=this._getScroll(),o=this._getViewPadding(),r=this._viewDiv.getBoundingClientRect();return"document"===t&&(void 0!==e.x&&(e.x+=-n.x+r.left+o.left),void 0!==e.y&&(e.y+=-n.y+r.top+o.top)),"document"===i&&(void 0!==e.x&&(e.x+=n.x-r.left-o.left),void 0!==e.y&&(e.y+=n.y-r.top-o.top)),e},copy:function(){return this._clientDiv?this._doCopy():!1},cut:function(){return this._clientDiv?this._doCut():!1},destroy:function(){for(var e=0;ei)return!1;var n=this._getLine(i),o=this.getOffsetAtLocation(e,t),r=n.getBoundingClientRect(o);return n.destroy(),e>r.right?!1:!0},getLinePixel:function(e){return this._clientDiv?this._getLinePixel(e):0},getLocationAtOffset:function(e){if(!this._clientDiv)return{x:0,y:0};var t=this._model;e=Math.min(Math.max(0,e),t.getCharCount());var i=t.getLineAtOffset(e),n=this._getLine(i),o=n.getBoundingClientRect(e);n.destroy();var r=o.left,s=this._getLinePixel(i)+o.top;return{x:r,y:s}},getNextOffset:function(e,t){var i=new y(e,e,!1);return this._doMove(t,i),i.getCaret()},getOptions:function(){var e;if(0===arguments.length)e=this._defaultOptions();else if(1===arguments.length){var t=arguments[0];if("string"==typeof t)return c(this["_"+t]);e=t}else{e={};for(var i in arguments)arguments.hasOwnProperty(i)&&(e[arguments[i]]=void 0)}for(var n in e)e.hasOwnProperty(n)&&(e[n]=c(this["_"+n]));return e},getModel:function(){return this._model},getOffsetAtLocation:function(e,t){if(!this._clientDiv)return 0;var i=this._getLineIndex(t),n=this._getLine(i),o=n.getOffset(e,t-this._getLinePixel(i));return n.destroy(),o},getLineAtOffset:function(e){return this.getModel().getLineAtOffset(e)},getLineStart:function(e){return this.getModel().getLineStart(e)},getRulers:function(){return this._rulers.slice(0)},getSelection:function(){return this._getSelection()},getSelections:function(){return this._getSelections()},getSelectionText:function(e){var t=[],i=this,n=this._getSelections();return n.forEach(function(e){e.isEmpty()||t.push(i._getBaseText(e.start,e.end))}),t.join(void 0!==e?e:this._model.getLineDelimiter())},getText:function(e,t){var i=this._model;return i.getText(e,t)},getTopIndex:function(e){return this._clientDiv?this._getTopIndex(e):0},getTopPixel:function(){return this._clientDiv?this._getScroll().y:0},invokeAction:function(e,t,i){if(this._clientDiv){var n=this._actions[e];if(n){if(n.actionDescription&&n.actionDescription.id&&a.logEvent("editor","action",n.actionDescription.id),!t&&n.handler&&n.handler(i))return!0;if(n.defaultHandler)return"boolean"==typeof n.defaultHandler(i)}return!1}},isDestroyed:function(){return!this._clientDiv},onContextMenu:function(e){return this.dispatchEvent(e)},onDragStart:function(e){return this.dispatchEvent(e)},onDrag:function(e){return this.dispatchEvent(e)},onDragEnd:function(e){return this.dispatchEvent(e)},onDragEnter:function(e){return this.dispatchEvent(e) -},onDragOver:function(e){return this.dispatchEvent(e)},onDragLeave:function(e){return this.dispatchEvent(e)},onDrop:function(e){return this.dispatchEvent(e)},onDestroy:function(e){return this.dispatchEvent(e)},onSaving:function(e){return this.dispatchEvent(e)},onInputChanged:function(e){return this.dispatchEvent(e)},onLineStyle:function(e){return this.dispatchEvent(e)},onKeyDown:function(e){return this.dispatchEvent(e)},onKeyPress:function(e){return this.dispatchEvent(e)},onKeyUp:function(e){return this.dispatchEvent(e)},onModelChanged:function(e){return this.dispatchEvent(e)},onModelChanging:function(e){return this.dispatchEvent(e)},onModify:function(e){return this.dispatchEvent(e)},onMouseDown:function(e){return this.dispatchEvent(e)},onMouseUp:function(e){return this.dispatchEvent(e)},onMouseMove:function(e){return this.dispatchEvent(e)},onMouseOver:function(e){return this.dispatchEvent(e)},onMouseOut:function(e){return this.dispatchEvent(e)},onTouchStart:function(e){return this.dispatchEvent(e)},onTouchMove:function(e){return this.dispatchEvent(e)},onTouchEnd:function(e){return this.dispatchEvent(e)},onOptions:function(e){return this.dispatchEvent(e)},onSelection:function(e){return this.dispatchEvent(e)},onScroll:function(e){return this.dispatchEvent(e)},onVerify:function(e){return this.dispatchEvent(e)},onFocus:function(e){return this.dispatchEvent(e)},onBlur:function(e){return this.dispatchEvent(e)},paste:function(){return this._clientDiv?this._doPaste():!1},redraw:function(){if(!(this._redrawCount>0)){var e=this._model.getLineCount();this.redrawRulers(0,e),this.redrawLines(0,e)}},redrawRulers:function(e,t){if(!(this._redrawCount>0))for(var i=this.getRulers(),n=0;n0)&&(void 0===e&&(e=0),void 0===t&&(t=this._model.getLineCount()),e!==t)){var n=this._clientDiv;if(n){if(i){var o=this._getRulerParent(i);for(n=o.firstChild;n&&n._ruler!==i;)n=n.nextSibling}i?n.rulerChanged=!0:this._lineHeight&&this._resetLineHeight(e,t);var r=-1;if(i||-1===this._imeOffset||(r=this._model.getLineAtOffset(this._imeOffset)),!i||"page"===i.getOverview())for(var s=n.firstChild;s;){var a=s.lineIndex;a>=e&&t>a&&a!==r&&(s.lineChanged=!0),s=s.nextSibling}i||this._wrapMode||e<=this._maxLineIndex&&this._maxLineIndex0)){var i=this._model;void 0===e&&(e=0),void 0===t&&(t=i.getCharCount());var n=i.getLineAtOffset(e),o=i.getLineAtOffset(Math.max(e,t-1))+1;this.redrawLines(n,o)}},removeKeyMode:function(e){for(var t=this._keyModes,i=0;it;if(o){var r=e;e=t,t=r}var s=this._model.getCharCount();e=Math.max(0,Math.min(e,s)),t=Math.max(0,Math.min(t,s));var a=new y(e,t,o);this._setSelection(a,void 0===i||i,!0,n)},setSelections:function(e,t,i){var n=this._rangesToSelections(e);this._setSelection(n,void 0===t||t,!0,i)},setText:function(e,t,i,n,o){var r,a="string"==typeof e,l=void 0===t&&void 0===i&&a;a?(void 0===t&&(t=0),void 0===i&&(i=this._model.getCharCount()),r={text:e,selection:[new y(t,i,!1)]}):(r=e,r.selection=this._rangesToSelections(r.selection)),r._code=!0,l&&(this._variableLineHeight=!1),this._modifyContent(r,!l,void 0===n||n,o),l&&s.isFirefox<13&&this._fixCaret()},setTopIndex:function(e,t){this._clientDiv&&this._scrollViewAnimated(0,this._getLinePixel(Math.max(0,e))-this._getScroll().y,t)},setTopPixel:function(e,t){this._clientDiv&&this._scrollViewAnimated(0,Math.max(0,e)-this._getScroll().y,t)},showSelection:function(e,t){return this._showCaret(e?!1:!0,t,e)},update:function(e,t){this._clientDiv&&((e||this._metrics.invalid)&&this._updateStyle(),void 0===t||t?this._update():this._queueUpdate())},_handleRootMouseDown:function(e){if(this._cancelCheckSelection(),!this._ignoreEvent(e)){s.isFirefox<13&&1===e.which&&(this._clientDiv.contentEditable=!1,(this._overlayDiv||this._clientDiv).draggable=!0,this._ignoreBlur=!0);var t=this._overlayDiv||this._clientDiv;s.isIE<9&&(t=this._viewDiv);for(var i=e.target?e.target:e.srcElement;i;){if(t===i)return;if(i.className&&-1!==i.className.indexOf("textViewFind"))return;i=i.parentNode}if(e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!this._isW3CEvents){var n=this,o=this._getWindow();o.setTimeout(function(){n._clientDiv.focus()},0)}}},_handleRootMouseUp:function(e){this._ignoreEvent(e)||(s.isFirefox<13&&1===e.which&&(this._clientDiv.contentEditable=!0,(this._overlayDiv||this._clientDiv).draggable=!1),s.isFirefox&&1===e.which&&(this._fixCaret(),this._ignoreBlur=!1))},_handleBlur:function(){if(this._cancelCheckSelection(),!this._ignoreBlur){if(this._commitIME(),this._hasFocus=!1,s.isIE<9&&!this._getSelections()[0].isEmpty()){var e=this._rootDiv,t=s.createElement(e.ownerDocument,"div");e.appendChild(t),e.removeChild(t)}if(this._cursorDiv&&(this._cursorDiv.style.display="none"),this._domSelection){this._domSelection.forEach(function(e){e.update()});var i,n=this._getWindow(),o=this._parent.ownerDocument;if(n.getSelection){var r=n.getSelection();for(i=r.anchorNode;i;){if(i===this._clientDiv){r.rangeCount>0&&r.removeAllRanges();break}i=i.parentNode}}else if(o.selection){for(this._ignoreSelect=!1,i=o.selection.createRange().parentElement();i;){if(i===this._clientDiv){o.selection.empty();break}i=i.parentNode}this._ignoreSelect=!0}}this._ignoreFocus||this.onBlur({type:"Blur"})}},_handleCompositionStart:function(e){if(!this._ignoreEvent(e)){if(this._imeTimeout){var t=this._getWindow();t.clearTimeout(this._imeTimeout),this._imeTimeout=null}this._imeText&&(this._commitIME(this._imeText),this._imeText=null),this._startIME(),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null)}},_handleCompositionUpdate:function(e){this._ignoreEvent(e)||(this._imeText=e.data)},_handleCompositionEnd:function(e){if(!this._ignoreEvent(e)){this._imeText=e.data;var t=this._getWindow();this._imeTimeout=t.setTimeout(function(){this._commitIME(this._imeText),this._imeText=this._imeTimeout=null}.bind(this),0)}},_handleContextMenu:function(e){if(!this._ignoreEvent(e)){s.isIE&&3===this._lastMouseButton&&this._updateDOMSelection();var t=!1;if(this.isListening("ContextMenu")){var i=this._createMouseEvent("ContextMenu",e);i.screenX=e.screenX,i.screenY=e.screenY,this.onContextMenu(i),t=i.defaultPrevented}else s.isMac&&s.isFirefox&&0===e.button&&(t=!0);return t?(e.preventDefault&&e.preventDefault(),!1):(this._contextMenuOpen=!0,void(s.isFirefox&&(this._checkSelectionChange=!0,this._pollSelectionChange(!0))))}},_handleCopy:function(e){return this._cancelCheckSelection(),this._ignoreEvent(e)||this._ignoreCopy?void 0:this._doCopy(e)?(e.preventDefault&&e.preventDefault(),!1):void 0},_handleCut:function(e){return this._cancelCheckSelection(),this._ignoreEvent(e)?void 0:this._doCut(e)?(e.preventDefault&&e.preventDefault(),!1):void 0},_handleDataModified:function(e){this._ignoreEvent(e)||this._startIME()},_handleDblclick:function(e){if(!this._ignoreEvent(e)){var t=e.timeStamp?e.timeStamp:(new Date).getTime();this._lastMouseTime=t,2!==this._clickCount&&(this._clickCount=2,this._handleMouse(e))}},_handleDragStart:function(e){if(!this._ignoreEvent(e)){if(s.isFirefox<13){var t=this,i=this._getWindow();i.setTimeout(function(){t._clientDiv.contentEditable=!0,t._clientDiv.draggable=!1,t._ignoreBlur=!1},0)}return this.isListening("DragStart")&&-1!==this._dragOffset?(this._isMouseDown=!1,this.onDragStart(this._createMouseEvent("DragStart",e)),this._dragOffset=-1,void 0):(e.preventDefault&&e.preventDefault(),!1)}},_handleDrag:function(e){this._ignoreEvent(e)||this.isListening("Drag")&&this.onDrag(this._createMouseEvent("Drag",e))},_handleDragEnd:function(e){this._ignoreEvent(e)||(this._dropTarget=!1,this._dragOffset=-1,this.isListening("DragEnd")&&this.onDragEnd(this._createMouseEvent("DragEnd",e)),s.isFirefox<13&&(this._fixCaret(),"none"!==e.dataTransfer.dropEffect||e.dataTransfer.mozUserCancelled||this._fixCaret()))},_handleDragEnter:function(e){if(!this._ignoreEvent(e)){var t=!0;return this._dropTarget=!0,this.isListening("DragEnter")&&(t=!1,this.onDragEnter(this._createMouseEvent("DragEnter",e))),s.isWebkit||t?(e.preventDefault&&e.preventDefault(),!1):void 0}},_handleDragOver:function(e){if(!this._ignoreEvent(e)){var t=!0;return this.isListening("DragOver")&&(t=!1,this.onDragOver(this._createMouseEvent("DragOver",e))),s.isWebkit||t?(t&&(e.dataTransfer.dropEffect="none"),e.preventDefault&&e.preventDefault(),!1):void 0}},_handleDragLeave:function(e){this._ignoreEvent(e)||(this._dropTarget=!1,this.isListening("DragLeave")&&this.onDragLeave(this._createMouseEvent("DragLeave",e)))},_handleDrop:function(e){return this._ignoreEvent(e)?void 0:(this._dropTarget=!1,this.isListening("Drop")&&this.onDrop(this._createMouseEvent("Drop",e)),e.preventDefault&&e.preventDefault(),!1)},_handleFocus:function(){this._hasFocus=!0,s.isIOS&&void 0!==this._lastTouchOffset?(this.setCaretOffset(this._lastTouchOffset,!0),this._lastTouchOffset=void 0):this._updateDOMSelection(),this._cursorDiv&&(this._cursorDiv.style.display="block"),this._domSelection&&this._domSelection.forEach(function(e){e.update()}),this._ignoreFocus||this.onFocus({type:"Focus"})},_handleKeyDown:function(e){if(this._cancelCheckSelection(),!this._ignoreEvent(e)){if(this.isListening("KeyDown")){var t=this._createKeyEvent("KeyDown",e);if(this.onKeyDown(t),t.defaultPrevented)return s.isFirefox&&(this._keyDownPrevented=!0),void e.preventDefault()}var i=!1;switch(e.keyCode){case 16:case 17:case 18:case 91:i=!0;break;default:this._setLinksVisible(!1)}if(229===e.keyCode){if(this._readonly)return e.preventDefault&&e.preventDefault(),!1;var n=!0;s.isSafari&&s.isMac&&e.ctrlKey&&(n=!1,e.keyCode=129),n&&this._startIME()}else i||this._commitIME();return(s.isMac||s.isLinux)&&s.isFirefox<4||s.isOpera<12.16?(this._keyDownEvent=e,!0):this._doAction(e)?(e.preventDefault?(e.preventDefault(),e.stopPropagation()):(e.cancelBubble=!0,e.returnValue=!1,e.keyCode=0),!1):void 0}},_handleKeyPress:function(e){if(!this._ignoreEvent(e)){if(this._keyDownPrevented)return e.preventDefault&&(e.preventDefault(),e.stopPropagation()),void(this._keyDownPrevented=void 0);if(s.isMac&&s.isWebkit&&(63232<=e.keyCode&&e.keyCode<=63487||13===e.keyCode||8===e.keyCode))return e.preventDefault&&e.preventDefault(),!1;if(((s.isMac||s.isLinux)&&s.isFirefox<4||s.isOpera<12.16)&&this._doAction(this._keyDownEvent))return e.preventDefault&&e.preventDefault(),!1;var t=s.isMac?e.metaKey:e.ctrlKey;if(void 0!==e.charCode&&t)switch(e.charCode){case 99:case 118:case 120:return!0}if(this.isListening("KeyPress")){var i=this._createKeyEvent("KeyPress",e);if(this.onKeyPress(i),i.defaultPrevented)return void e.preventDefault()}if(this._doAction(e))return e.preventDefault?(e.preventDefault(),e.stopPropagation()):(e.cancelBubble=!0,e.returnValue=!1,e.keyCode=0),!1;var n=!1;if(s.isMac?(e.ctrlKey||e.metaKey)&&(n=!0):s.isFirefox?(e.ctrlKey||e.altKey)&&(n=!0):e.ctrlKey^e.altKey&&(n=!0),!n){var o=s.isOpera?e.which:void 0!==e.charCode?e.charCode:e.keyCode;if(o>31)return this._doContent(String.fromCharCode(o)),e.preventDefault&&e.preventDefault(),!1}}},_handleDocKeyUp:function(e){var t=s.isMac?e.metaKey:e.ctrlKey;t||this._setLinksVisible(!1)},_handleKeyUp:function(e){if(!this._ignoreEvent(e)){if(this.isListening("KeyUp")){var t=this._createKeyEvent("KeyUp",e);if(this.onKeyUp(t),t.defaultPrevented)return void e.preventDefault()}this._handleDocKeyUp(e),13===e.keyCode&&this._commitIME()}},_handleLinkClick:function(e){var t=s.isMac?e.metaKey:e.ctrlKey;return t?void 0:(e.preventDefault&&e.preventDefault(),!1)},_handleMouse:function(e){var t=this._getWindow(),i=!0,n=t;if((s.isIE||s.isFirefox&&!this._overlayDiv)&&(n=this._clientDiv),this._overlayDiv){this._hasFocus&&(this._ignoreFocus=!0);var o=this;t.setTimeout(function(){o.focus(),o._ignoreFocus=!1},0)}var r=e.shiftKey,a=e.altKey,l=s.isMac?e.metaKey:e.ctrlKey;if(this._blockSelection=this._doubleClickSelection=null,1===this._clickCount){var d=(!s.isOpera||s.isOpera>=12.16)&&this._hasFocus&&this.isListening("DragStart");i=this._setSelectionTo(e.clientX,e.clientY,!0,r,l,d),i&&this._setGrab(n)}else this._isW3CEvents&&this._setGrab(n),this._setSelectionTo(e.clientX,e.clientY,!0,r,l,!1),this._doubleClickSelection=y.editing(this._getSelections());return a&&(this._blockSelection=y.editing(this._getSelections())),i},_handleMouseDown:function(e){if(!this._ignoreEvent(e)){if(this._linksVisible){var t=e.target||e.srcElement;if("A"===t.tagName)return;this._setLinksVisible(!1)}this._commitIME();var i=e.which;i||(4===e.button&&(i=2),2===e.button&&(i=3),1===e.button&&(i=1));var n=2!==i&&e.timeStamp?e.timeStamp:(new Date).getTime(),o=n-this._lastMouseTime,r=Math.abs(this._lastMouseX-e.clientX),a=Math.abs(this._lastMouseY-e.clientY),l=this._lastMouseButton===i;if(this._lastMouseX=e.clientX,this._lastMouseY=e.clientY,this._lastMouseTime=n,this._lastMouseButton=i,1===i&&(this._isMouseDown=!0,l&&o<=this._clickTime&&r<=this._clickDist&&a<=this._clickDist?this._clickCount++:this._clickCount=1),this.isListening("MouseDown")){var d=this._createMouseEvent("MouseDown",e);if(this.onMouseDown(d),d.defaultPrevented)return void e.preventDefault()}1===i&&this._handleMouse(e)&&(s.isIE>=9||s.isOpera||s.isChrome||s.isSafari||s.isFirefox&&!this._overlayDiv)&&(this._hasFocus||this.focus(),e.preventDefault()),s.isFirefox&&3===this._lastMouseButton&&this._updateDOMSelection()}},_handleMouseOver:function(e){this._ignoreEvent(e)||this._animation||this.isListening("MouseOver")&&this.onMouseOver(this._createMouseEvent("MouseOver",e))},_handleMouseOut:function(e){this._ignoreEvent(e)||this._animation||this.isListening("MouseOut")&&this.onMouseOut(this._createMouseEvent("MouseOut",e))},_handleMouseMove:function(e){if(!this._animation){var t=this._isClientDiv(e);if(this.isListening("MouseMove")&&(t||this._isMouseDown)){var i=this._createMouseEvent("MouseMove",e);if(this.onMouseMove(i),i.defaultPrevented)return void e.preventDefault()}if(!this._dropTarget){var n=this._linksVisible||this._lastMouseMoveX!==e.clientX||this._lastMouseMoveY!==e.clientY;if(this._lastMouseMoveX=e.clientX,this._lastMouseMoveY=e.clientY,this._setLinksVisible(n&&!this._isMouseDown&&e.altKey&&(s.isMac?e.metaKey:e.ctrlKey)),this._checkOverlayScroll(),!this._isW3CEvents){if(0===e.button)return this._setGrab(null),!0;if(!this._isMouseDown&&1===e.button&&0!==(1&this._clickCount)&&t)return this._clickCount=2,this._handleMouse(e,this._clickCount)}if(this._isMouseDown&&-1===this._dragOffset){var o=e.clientX,r=e.clientY,a=this._getViewPadding(),l=this._viewDiv.getBoundingClientRect(),d=this._getClientWidth(),h=this._getClientHeight(),c=l.left+a.left,u=l.top+a.top,p=l.left+a.left+d,f=l.top+a.top+h;u>r?this._doAutoScroll("up",o,r-u):r>f?this._doAutoScroll("down",o,r-f):c>o&&!this._wrapMode?this._doAutoScroll("left",o-c,r):o>p&&!this._wrapMode?this._doAutoScroll("right",o-p,r):(this._endAutoScroll(),this._setSelectionTo(o,r,!1,!0))}}}},_isClientDiv:function(e){for(var t=this._overlayDiv||this._clientDiv,i=e.target?e.target:e.srcElement;i;){if(t===i)return!0;i=i.parentNode}return!1},_createKeyEvent:function(e,t){return{type:e,event:t,preventDefault:function(){this.defaultPrevented=!0}}},_createMouseEvent:function(e,t){var i=this.convert({x:t.clientX,y:t.clientY},"page","document");return{type:e,event:t,clickCount:this._clickCount,x:i.x,y:i.y,preventDefault:function(){this.defaultPrevented=!0}}},_createTouchEvent:function(e,t){var i=t.touches.length?this.convert({x:t.touches[0].clientX,y:t.touches[0].clientY},"page","document"):{};return{type:e,event:t,touchCount:t.touches.length,x:i.x,y:i.y,preventDefault:function(){this.defaultPrevented=!0}}},_handleMouseUp:function(e){var t=e.which?0===e.button:1===e.button;if(this.isListening("MouseUp")&&(this._isClientDiv(e)||t&&this._isMouseDown)){var i=this._createMouseEvent("MouseUp",e);if(this.onMouseUp(i),i.defaultPrevented)return e.preventDefault(),void(this._isMouseDown=!1)}if(!this._linksVisible){if(t&&this._isMouseDown){var n=this._getSelections(),o=y.editing(n);n.forEach(function(e){e._editing=!1}),-1!==this._dragOffset&&(o.extend(this._dragOffset),o.collapse(),n=o,this._dragOffset=-1),this._setSelection(n,!1),this._isMouseDown=!1,this._endAutoScroll(),this._isW3CEvents&&this._setGrab(null)}t&&this._isMouseDown&&s.isFirefox&&(this._updateDOMSelection(),e.preventDefault())}},_handleMouseWheel:function(e){if(!this._noScroll){var t=this._getLineHeight(),i=0,n=0;if(s.isIE||s.isOpera)n=-e.wheelDelta/40*t;else if(s.isFirefox){var o=256;if("wheel"===e.type)e.deltaMode?(i=Math.max(-o,Math.min(o,e.deltaX))*t,n=Math.max(-o,Math.min(o,e.deltaY))*t):(i=e.deltaX,n=e.deltaY);else{var r;r=s.isMac?3*e.detail:Math.max(-o,Math.min(o,e.detail))*t,e.axis===e.HORIZONTAL_AXIS?i=r:n=r}}else if(s.isMac){var a,l,d=e.timeStamp-this._wheelTimeStamp;this._wheelTimeStamp=e.timeStamp,a=e.wheelDeltaX%120!==0?1:40>d?40/(40-d):40,l=e.wheelDeltaY%120!==0?1:40>d?40/(40-d):40,i=Math.ceil(-e.wheelDeltaX/a),i>-1&&0>i&&(i=-1),i>0&&1>i&&(i=1),n=Math.ceil(-e.wheelDeltaY/l),n>-1&&0>n&&(n=-1),n>0&&1>n&&(n=1)}else{i=-e.wheelDeltaX;var h=8;n=-e.wheelDeltaY/120*h*t}if(s.isSafari||s.isChrome&&s.isMac){for(var c=e.target;c&&void 0===c.lineIndex;)c=c.parentNode;this._mouseWheelLine=c}var u=this._getScroll();this._scrollView(i,n);var p=this._getScroll();return u.x!==p.x||u.y!==p.y?(e.preventDefault&&e.preventDefault(),!1):void 0}},_handlePaste:function(e){if(this._cancelCheckSelection(),!this._ignoreEvent(e)&&!this._ignorePaste&&this._doPaste(e)){if(s.isIE){var t=this;this._ignoreFocus=!0;var i=this._getWindow();i.setTimeout(function(){t._updateDOMSelection(),t._ignoreFocus=!1},0)}return e.preventDefault&&e.preventDefault(),!1}},_handleResize:function(){var e=this._rootDiv.clientWidth,t=this._rootDiv.clientHeight;if(this._rootWidth!==e||this._rootHeight!==t){this._rootWidth!==e&&this._wrapMode&&this._resetLineHeight(),this._rootWidth=e,this._rootHeight=t;var i=s.isIE<9,n=this._calculateMetrics();p(n,this._metrics)||(this._metrics.invalid&&!n.invalid?this._updateStyle(!1,n):(this._variableLineHeight&&(this._variableLineHeight=!1,this._resetLineHeight()),this._metrics=n),i=!0),i?this._queueUpdate():this._update(),this.dispatchEvent({type:"Resize"})}},_handleRulerEvent:function(e){for(var t=e.target?e.target:e.srcElement,i=t.lineIndex,n=t;n&&!n._ruler;)void 0===i&&void 0!==n.lineIndex&&(i=n.lineIndex),n=n.parentNode;var o=n?n._ruler:null;if(void 0===i&&o&&"document"===o.getOverview()){var r,s,a=this._getClientHeight(),l=this._model.getLineCount(),d=this._getViewPadding(),h=this._viewDiv.getBoundingClientRect(),c=this._getLineHeight(),u=c*l,p=a+d.top+d.bottom-2*this._metrics.scrollWidth;p>u?(r=c,s=d.top):(r=p/l,s=this._metrics.scrollWidth),i=Math.floor((e.clientY-h.top-s)/r),i>=0&&l>i||(i=void 0)}if(o)switch(e.type){case"click":o.onClick&&o.onClick(i,e);break;case"dblclick":o.onDblClick&&o.onDblClick(i,e);break;case"mousemove":o.onMouseMove&&o.onMouseMove(i,e);break;case"mouseover":o.onMouseOver&&o.onMouseOver(i,e);break;case"mouseout":if(o.onMouseOut){for(var f=e.relatedTarget;f&&f!==this._rootDiv;){if(f===n)return;f=f.parentNode}o.onMouseOut(i,e)}}},_handleScroll:function(){this._lastScrollTime=(new Date).getTime();var e=this._getScroll(!1),t=this._hScroll,i=this._vScroll;if(t!==e.x||i!==e.y){this._hScroll=e.x,this._vScroll=e.y,this._commitIME(),this._update(i===e.y);var n={type:"Scroll",oldValue:{x:t,y:i},newValue:e};this.onScroll(n)}},_handleSelectStart:function(e){var t=this._contextMenuOpen;return this._contextMenuOpen=!1,t?void(this._checkSelectionChange=!0):this._ignoreSelect?(e&&e.preventDefault&&e.preventDefault(),!1):void 0},_getModelOffset:function(e,t){if(e){var i;return i="DIV"===e.tagName?e:e.parentNode.parentNode,i._line?i._line.getModelOffset(e,t):0}},_updateSelectionFromDOM:function(){if(!(s.isIOS||s.isAndroid||this._checkSelectionChange))return!1;var e=this._getWindow(),t=e.getSelection(),i=this._getModelOffset(t.anchorNode,t.anchorOffset),n=this._getModelOffset(t.focusNode,t.focusOffset),o=this._getSelections()[0];if(void 0===i||void 0===n||o.start===i&&o.end===n)return!1;if(this._checkSelectionChange){var r=this._getLineNext(),a=this._getLinePrevious();if(t.anchorNode===r.firstChild.firstChild&&0===t.anchorOffset&&t.focusNode===a.firstChild.firstChild&&0===t.focusOffset)return!1;(t.anchorNode===r.firstChild.firstChild&&0===t.anchorOffset&&t.focusNode===a.lastChild.firstChild||t.anchorNode===this._clientDiv&&t.focusNode===this._clientDiv)&&(i=0,n=this.getModel().getCharCount())}return this._setSelection(new y(i,n),!1,!1),this._checkSelectionChange=!1,!0},_cancelCheckSelection:function(){this._checkSelectionChange&&(this._checkSelectionChange=!1,this._cancelPollSelectionChange())},_cancelPollSelectionChange:function(){if(this._selPollTimer){var e=this._getWindow();e.clearTimeout(this._selPollTimer),this._selPollTimer=null}},_pollSelectionChange:function(e){var t=this,i=this._getWindow();this._cancelPollSelectionChange(),this._selPollTimer=i.setTimeout(function(){if(t._selPollTimer=null,t._clientDiv){var i=t._updateSelectionFromDOM();!i&&e&&t._pollSelectionChange(e)}},100)},_handleSelectionChange:function(){-1===this._imeOffset&&(s.isAndroid?this._pollSelectionChange():this._updateSelectionFromDOM())},_handleTextInput:function(e){if(!this._ignoreEvent(e)&&-1===this._imeOffset){var t=this._getWindow().getSelection();if(t.anchorNode!==this._anchorNode||t.focusNode!==this._focusNode||t.anchorOffset!==this._anchorOffset||t.focusOffset!==this._focusOffset){for(var i=t.anchorNode;i&&void 0===i.lineIndex;)i=i.parentNode;if(i){var n=this._model,o=i.lineIndex,r=n.getLine(o),s=r,a=0,l=n.getLineStart(o);if(t.rangeCount>0){t.getRangeAt(0).deleteContents();var d=i.ownerDocument.createTextNode(e.data);t.getRangeAt(0).insertNode(d);var h=this._getDOMText(i,d);s=h.text,a=h.offset,d.parentNode.removeChild(d)}i.lineRemoved=!0;for(var c=0;r.charCodeAt(c)===s.charCodeAt(c)&&a>c;)c++;for(var u=r.length-1,p=s.length-r.length;r.charCodeAt(u)===s.charCodeAt(u+p)&&u+p>=a+e.data.length;)u--;u++;var f=s.substring(c,u+p);c+=l,u+=l;var g=this._getSelections(),_=g[0].start-c,m=g[0].end-u;g[0].start=c,g[0].end=u;for(var v=1;v=0;i--)if(t=n[i],"function"==typeof t.match){var o=t.match(e);if(void 0!==o)return this.invokeAction(o)}return!1},_doMove:function(e,t){var i=this._model,n=t.getCaret(),o=i.getLineAtOffset(n);for(e.count||(e.count=1);0!==e.count;){var r=i.getLineStart(o);if(e.count<0&&n===r){if(!(o>0))break;"character"===e.unit&&e.count++,o--,t.extend(i.getLineEnd(o))}else if(e.count>0&&n===i.getLineEnd(o)){if(!(o+10&&(r=Math.min(r+e.count-1,t.getLineCount()-1)),o=t.getLineEnd(r);n.extend(o)}e.select||n.collapse()}),this._setSelection(n,!0,!0,e.ctrl?function(){}:null),!0},_doEnter:function(e){if(this._singleMode)return!0;var t=this._model,i=this._getSelections();return this._doContent(t.getLineDelimiter()),e&&e.noCursor&&(i.forEach(function(e){e.end=e.start}),this._setSelection(i,!0)),!0},_doEscape:function(){var e=this._getSelections();return e.length>1&&this._setSelection(e[0],!0),!0},_doHome:function(e){var t=this._model,i=this,n=this._getSelections();return n.forEach(function(n){if(e.ctrl)n.extend(0);else{var o=n.getCaret(),r=t.getLineAtOffset(o);if(i._wrapMode){var s=i._getLine(r),a=s.getLineIndex(o);o=s.getLineStart(a),s.destroy()}else o=t.getLineStart(r);n.extend(o)}e.select||n.collapse()}),this._setSelection(n,!0,!0,e.ctrl?function(){}:null),!0},_doLineDown:function(e){var t=this._model,i=this,n=this._getSelections();return n.forEach(function(n){var o,r=n.getCaret(),a=t.getLineAtOffset(r),l=i._getLine(a),d=n._columnX,h=1,c=!1;if(-1===d||e.wholeLine||e.select&&s.isIE){var u=e.wholeLine?t.getLineEnd(a+1):r;d=n._columnX=l.getBoundingClientRect(u).left}if((o=l.getLineIndex(r))0?a=Math.min(a+e.count,p):a++}var f=!1;c?(e.select||s.isMac||s.isLinux)&&(n.extend(t.getCharCount()),f=!0):(l.lineIndex!==a&&(l.destroy(),l=i._getLine(a)),n.extend(l.getOffset(d,h)),f=!0),f&&(e.select||n.collapse()),l.destroy()}),i._setSelection(n,!0,!0,null,0,!1,!0),!0},_doLineUp:function(e){var t=this._model,i=this,n=this._getSelections();return n.forEach(function(n){var o,r,a=n.getCaret(),l=t.getLineAtOffset(a),d=i._getLine(l),h=n._columnX,c=!1;if(-1===h||e.wholeLine||e.select&&s.isIE){var u=e.wholeLine?t.getLineStart(l-1):a;h=n._columnX=d.getBoundingClientRect(u).left}(o=d.getLineIndex(a))>0?r=d.getClientRects(o-1).top+1:(c=0===l,c||(e.count&&e.count>0?l=Math.max(l-e.count,0):l--,r=i._getLineHeight(l)-1));var p=!1;c?(e.select||s.isMac||s.isLinux)&&(n.extend(0),p=!0):(d.lineIndex!==l&&(d.destroy(),d=i._getLine(l)),n.extend(d.getOffset(h,r)),p=!0),p&&(e.select||n.collapse()),d.destroy()}),i._setSelection(n,!0,!0,null,0,!1,!0),!0},_doNoop:function(){return!0},_doPageDown:function(e){var t,i,n,o=this,r=this._model,a=this._getSelections(),l=r.getLineCount(),d=this._getScroll(),h=this._getClientHeight(),c=this._getLineHeight(),u=Math.floor(h/c); -return a.forEach(function(a){var p=a.getCaret(),f=r.getLineAtOffset(p);if(o._lineHeight){t=a._columnX;var g=o._getBoundsAtOffset(p);(-1===t||e.select&&s.isIE)&&(t=a._columnX=g.left);var _=o._getLineIndex(g.top+h);i=o._getLine(_);var m=o._getLinePixel(_),v=g.top+h-m;p=i.getOffset(t,v);var y=i.getBoundingClientRect(p);i.destroy(),a.extend(p),e.select||a.collapse(),n=void 0!==n?Math.min(n,y.top+m-g.top):y.top+m-g.top}else if(l-1>f){var x=Math.min(l-f-1,u);x=Math.max(1,x),t=a._columnX,(-1===t||e.select&&s.isIE)&&(i=o._getLine(f),t=a._columnX=i.getBoundingClientRect(p).left,i.destroy()),i=o._getLine(f+x),a.extend(i.getOffset(t,0)),i.destroy(),e.select||a.collapse();var b=l*c,C=d.y+x*c;C+h>b&&(C=b-h),n=void 0!==n?Math.min(n,C-d.y):C-d.y}}),this._setSelection(a,!0,!0,function(){},n,!1,!0),!0},_doPageUp:function(e){var t,i,n,o=this,r=this._model,a=this._getSelections(),l=this._getScroll(),d=this._getClientHeight(),h=this._getLineHeight(),c=Math.floor(d/h);return a.forEach(function(a){var u=a.getCaret(),p=r.getLineAtOffset(u);if(o._lineHeight){t=a._columnX;var f=o._getBoundsAtOffset(u);(-1===t||e.select&&s.isIE)&&(t=a._columnX=f.left);var g=o._getLineIndex(f.bottom-d);i=o._getLine(g);var _=o._getLinePixel(g),m=f.bottom-d-_;u=i.getOffset(t,m);var v=i.getBoundingClientRect(u);i.destroy(),a.extend(u),e.select||a.collapse(),n=void 0!==n?Math.max(n,v.top+_-f.top):v.top+_-f.top}else if(p>0){var y=Math.max(1,Math.min(p,c));t=a._columnX,(-1===t||e.select&&s.isIE)&&(i=o._getLine(p),t=a._columnX=i.getBoundingClientRect(u).left,i.destroy()),i=o._getLine(p-y),a.extend(i.getOffset(t,o._getLineHeight(p-y)-1)),i.destroy(),e.select||a.collapse();var x=Math.max(0,l.y-y*h);n=void 0!==n?Math.max(n,x-l.y):x-l.y}}),this._setSelection(a,!0,!0,function(){},n,!1,!0),!0},_doPaste:function(e){var t=this,i=this._getClipboardText(e,function(e){if(e.length){if(s.isLinux&&2===t._lastMouseButton){var i=(new Date).getTime()-t._lastMouseTime;i<=t._clickTime&&t._setSelectionTo(t._lastMouseX,t._lastMouseY,!0)}var n=t._getSelections(),o=t._singleMode?"":t._model.getLineDelimiter();t._doContent(n.length>1&&n.length===e.length?e:e.join(o))}});return null!==i},_doScroll:function(e){var t,i=e.type,n=this._model,o=n.getLineCount(),r=this._getClientHeight(),s=this._getLineHeight(),a=this._lineHeight?this._scrollHeight:o*s,l=this._getScroll().y;switch(i){case"textStart":t=0;break;case"textEnd":t=a-r;break;case"pageDown":t=l+r;break;case"pageUp":t=l-r;break;case"lineDown":t=l+s;break;case"lineUp":t=l-s;break;case"centerLine":var d=this._getSelections()[0],h=n.getLineAtOffset(d.start),c=n.getLineAtOffset(d.end),u=(c-h+1)*s;t=h*s-r/2+u/2}return void 0!==t&&(t=Math.min(Math.max(0,t),a-r),this._scrollViewAnimated(0,t-l,function(){})),!0},_doSelectAll:function(){var e=this._model;return this._setSelection(new y(0,e.getCharCount()),!1),!0},_doTab:function(){if(this._tabMode&&!this._readonly){var e=" ",t=this._getSelections();if(this._expandTab){e=[];var i=this._model,n=this._tabSize;t.forEach(function(t){var o=t.getCaret(),r=i.getLineAtOffset(o),s=i.getLineStart(r),a=n-(o-s)%n;e.push(d(a+1).join(" "))})}return this._modifyContent({text:e,selection:t,_ignoreDOMSelection:!0},!0)}},_doShiftTab:function(){return this._tabMode&&!this._readonly?!0:void 0},_doOverwriteMode:function(){return this._readonly?void 0:(this.setOptions({overwriteMode:!this.getOptions("overwriteMode")}),!0)},_doTabMode:function(){return this._tabMode=!this._tabMode,!0},_doWrapMode:function(){return this.setOptions({wrapMode:!this.getOptions("wrapMode")}),!0},_autoScroll:function(){var e,t,i=this._model,n=this._getSelections(),o=y.editing(n,"down"===this._autoScrollDir),r=this.convert({x:this._autoScrollX,y:this._autoScrollY},"page","document"),a=o.getCaret(),l=i.getLineCount(),d=i.getLineAtOffset(a);if("up"===this._autoScrollDir||"down"===this._autoScrollDir){var h=this._autoScrollY/this._getLineHeight();h=0>h?Math.floor(h):Math.ceil(h),e=d,e=Math.max(0,Math.min(l-1,e+h))}else("left"===this._autoScrollDir||"right"===this._autoScrollDir)&&(e=this._getLineIndex(r.y),t=this._getLine(d),r.x+=t.getBoundingClientRect(a,!1).left,t.destroy());this._blockSelection?n=this._getBlockSelections(n,e,r):0===e&&(s.isMac||s.isLinux)?o.extend(0):e===l-1&&(s.isMac||s.isLinux)?o.extend(i.getCharCount()):(t=this._getLine(e),o.extend(t.getOffset(r.x,r.y-this._getLinePixel(e))),t.destroy()),this._setSelection(n,!0)},_autoScrollTimer:function(){this._autoScroll();var e=this,t=this._getWindow();this._autoScrollTimerID=t.setTimeout(function(){e._autoScrollTimer()},this._AUTO_SCROLL_RATE)},_calculateLineHeightTimer:function(e){if(this._lineHeight&&!this._calculateLHTimer){var t=this._model.getLineCount(),i=0;if(e){for(var n=0,o=100,r=(new Date).getTime(),s=0;t>i&&(this._lineHeight[i]||(n++,s||(s=i),this._lineHeight[i]=this._calculateLineHeight(i)),i++,!((new Date).getTime()-r>o)););this.redrawRulers(0,t),this._queueUpdate()}var a=this._getWindow();if(i!==t){var l=this;return void(this._calculateLHTimer=a.setTimeout(function(){l._calculateLHTimer=null,l._calculateLineHeightTimer(!0)},0))}this._calculateLHTimer&&(a.clearTimeout(this._calculateLHTimer),this._calculateLHTimer=void 0)}},_calculateLineHeight:function(e){var t=this._getLine(e),i=t.getBoundingClientRect();return t.destroy(),Math.max(1,i.bottom-i.top)},_calculateMetrics:function(){var e=this._clientDiv,t=e.ownerDocument,i=" ",n=s.createElement(t,"div");n.style.lineHeight="normal";var o=this._model,r=o.getLine(0),a={type:"LineStyle",textView:this,0:0,lineText:r,lineStart:0};this.onLineStyle(a),h(a.style,n),n.style.position="fixed",n.style.left="-1000px";var l=s.createElement(t,"span");l.appendChild(t.createTextNode(i)),n.appendChild(l);var c=s.createElement(t,"span");c.style.fontStyle="italic",c.appendChild(t.createTextNode(i)),n.appendChild(c);var u=s.createElement(t,"span");u.style.fontWeight="bold",u.appendChild(t.createTextNode(i)),n.appendChild(u);var p=s.createElement(t,"span");p.style.fontWeight="bold",p.style.fontStyle="italic",p.appendChild(t.createTextNode(i)),n.appendChild(p),e.appendChild(n);var f=n.getBoundingClientRect(),g=l.getBoundingClientRect(),v=c.getBoundingClientRect(),y=u.getBoundingClientRect(),x=p.getBoundingClientRect(),b=g.bottom-g.top,C=v.bottom-v.top,w=y.bottom-y.top,T=x.bottom-x.top,L=0,k=f.bottom-f.top<=0,D=Math.max(1,f.bottom-f.top);C>b&&(L=1),w>C&&(L=2),T>w&&(L=3);var A;0!==L&&(A={style:{}},0!==(1&L)&&(A.style.fontStyle="italic"),0!==(2&L)&&(A.style.fontWeight="bold"));var S=m(n);e.removeChild(n);var E=_(this._viewDiv),O=s.createElement(t,"div");O.style.position="fixed",O.style.left="-1000px",O.style.paddingLeft=E.left+"px",O.style.paddingTop=E.top+"px",O.style.paddingRight=E.right+"px",O.style.paddingBottom=E.bottom+"px",O.style.width="100px",O.style.height="100px";var N=s.createElement(t,"div");N.style.width="100%",N.style.height="100%",O.appendChild(N),e.appendChild(O);var M=O.getBoundingClientRect(),I=N.getBoundingClientRect(),B=0;if(!this._singleMode&&!this._noScroll){O.style.overflow="hidden",N.style.height="200px";var R=O.clientWidth;O.style.overflow="scroll";var F=O.clientWidth;B=R-F}e.removeChild(O),E={left:I.left-M.left,top:I.top-M.top,right:M.right-I.right,bottom:M.bottom-I.bottom};var P=0,W=0,V=0;return k||(O=s.createElement(t,"div"),O.style.position="fixed",O.style.left="-1000px",e.appendChild(O),O.innerHTML=d(2).join("a"),M=O.getBoundingClientRect(),V=Math.ceil(M.right-M.left),(this._wrapOffset||this._marginOffset)&&(O.innerHTML=d(this._wrapOffset+1+(s.isWebkit?0:1)).join(" "),M=O.getBoundingClientRect(),P=Math.ceil(M.right-M.left),O.innerHTML=d(this._marginOffset+1).join(" "),I=O.getBoundingClientRect(),W=Math.ceil(I.right-I.left)),e.removeChild(O)),{lineHeight:D,largestFontStyle:A,lineTrim:S,viewPadding:E,scrollWidth:B,wrapWidth:P,marginWidth:W,charWidth:V,invalid:k}},_cancelAnimation:function(){this._animation&&(this._animation.stop(),this._animation=null)},_clearSelection:function(e){var t=this._getSelections();return t.forEach(function(t){"next"===e?t.start=t.end:t.end=t.start}),this._setSelection(t,!0),!0},_commitIME:function(e){if(-1!==this._imeOffset){var t=this._model,i=t.getLineAtOffset(this._imeOffset),n=t.getLineStart(i),o=this._getLineNode(i);if(!e){this._scrollDiv.focus(),this._clientDiv.focus();var r=this._getDOMText(o).text,a=t.getLine(i),l=this._imeOffset-n,d=l+r.length-a.length;l!==d&&(e=r.substring(l,d))}this._imeOffset=-1,e&&(this._doContent(e)||s.isWebkit||(o.lineRemoved=!0,this._queueUpdate()))}},_createActions:function(){this.addKeyMode(new i.DefaultKeyMode(this));var t=this;this._actions={noop:{defaultHandler:function(){return t._doNoop()}},lineUp:{defaultHandler:function(e){return t._doLineUp(u(e,{select:!1}))},actionDescription:{name:e.lineUp}},lineDown:{defaultHandler:function(e){return t._doLineDown(u(e,{select:!1}))},actionDescription:{name:e.lineDown}},lineStart:{defaultHandler:function(e){return t._doHome(u(e,{select:!1,ctrl:!1}))},actionDescription:{name:e.lineStart}},lineEnd:{defaultHandler:function(e){return t._doEnd(u(e,{select:!1,ctrl:!1}))},actionDescription:{name:e.lineEnd}},charPrevious:{defaultHandler:function(e){return t._doCursorPrevious(u(e,{select:!1,unit:"character"}))},actionDescription:{name:e.charPrevious}},charNext:{defaultHandler:function(e){return t._doCursorNext(u(e,{select:!1,unit:"character"}))},actionDescription:{name:e.charNext}},pageUp:{defaultHandler:function(e){return t._doPageUp(u(e,{select:!1}))},actionDescription:{name:e.pageUp}},pageDown:{defaultHandler:function(e){return t._doPageDown(u(e,{select:!1}))},actionDescription:{name:e.pageDown}},scrollPageUp:{defaultHandler:function(e){return t._doScroll(u(e,{type:"pageUp"}))},actionDescription:{name:e.scrollPageUp}},scrollPageDown:{defaultHandler:function(e){return t._doScroll(u(e,{type:"pageDown"}))},actionDescription:{name:e.scrollPageDown}},scrollLineUp:{defaultHandler:function(e){return t._doScroll(u(e,{type:"lineUp"}))},actionDescription:{name:e.scrollLineUp}},scrollLineDown:{defaultHandler:function(e){return t._doScroll(u(e,{type:"lineDown"}))},actionDescription:{name:e.scrollLineDown}},wordPrevious:{defaultHandler:function(e){return t._doCursorPrevious(u(e,{select:!1,unit:"word"}))},actionDescription:{name:e.wordPrevious}},wordNext:{defaultHandler:function(e){return t._doCursorNext(u(e,{select:!1,unit:"word"}))},actionDescription:{name:e.wordNext}},textStart:{defaultHandler:function(e){return t._doHome(u(e,{select:!1,ctrl:!0}))},actionDescription:{name:e.textStart}},textEnd:{defaultHandler:function(e){return t._doEnd(u(e,{select:!1,ctrl:!0}))},actionDescription:{name:e.textEnd}},scrollTextStart:{defaultHandler:function(e){return t._doScroll(u(e,{type:"textStart"}))},actionDescription:{name:e.scrollTextStart}},scrollTextEnd:{defaultHandler:function(e){return t._doScroll(u(e,{type:"textEnd"}))},actionDescription:{name:e.scrollTextEnd}},centerLine:{defaultHandler:function(e){return t._doScroll(u(e,{type:"centerLine"}))},actionDescription:{name:e.centerLine}},selectLineUp:{defaultHandler:function(e){return t._doLineUp(u(e,{select:!0}))},actionDescription:{name:e.selectLineUp}},selectLineDown:{defaultHandler:function(e){return t._doLineDown(u(e,{select:!0}))},actionDescription:{name:e.selectLineDown}},selectWholeLineUp:{defaultHandler:function(e){return t._doLineUp(u(e,{select:!0,wholeLine:!0}))},actionDescription:{name:e.selectWholeLineUp}},selectWholeLineDown:{defaultHandler:function(e){return t._doLineDown(u(e,{select:!0,wholeLine:!0}))},actionDescription:{name:e.selectWholeLineDown}},selectLineStart:{defaultHandler:function(e){return t._doHome(u(e,{select:!0,ctrl:!1}))},actionDescription:{name:e.selectLineStart}},selectLineEnd:{defaultHandler:function(e){return t._doEnd(u(e,{select:!0,ctrl:!1}))},actionDescription:{name:e.selectLineEnd}},selectCharPrevious:{defaultHandler:function(e){return t._doCursorPrevious(u(e,{select:!0,unit:"character"}))},actionDescription:{name:e.selectCharPrevious}},selectCharNext:{defaultHandler:function(e){return t._doCursorNext(u(e,{select:!0,unit:"character"}))},actionDescription:{name:e.selectCharNext}},selectPageUp:{defaultHandler:function(e){return t._doPageUp(u(e,{select:!0}))},actionDescription:{name:e.selectPageUp}},selectPageDown:{defaultHandler:function(e){return t._doPageDown(u(e,{select:!0}))},actionDescription:{name:e.selectPageDown}},selectWordPrevious:{defaultHandler:function(e){return t._doCursorPrevious(u(e,{select:!0,unit:"word"}))},actionDescription:{name:e.selectWordPrevious}},selectWordNext:{defaultHandler:function(e){return t._doCursorNext(u(e,{select:!0,unit:"word"}))},actionDescription:{name:e.selectWordNext}},selectTextStart:{defaultHandler:function(e){return t._doHome(u(e,{select:!0,ctrl:!0}))},actionDescription:{name:e.selectTextStart}},selectTextEnd:{defaultHandler:function(e){return t._doEnd(u(e,{select:!0,ctrl:!0}))},actionDescription:{name:e.selectTextEnd}},deletePrevious:{defaultHandler:function(e){return t._doBackspace(u(e,{unit:"character"}))},actionDescription:{name:e.deletePrevious}},deleteNext:{defaultHandler:function(e){return t._doDelete(u(e,{unit:"character"}))},actionDescription:{name:e.deleteNext}},deleteWordPrevious:{defaultHandler:function(e){return t._doBackspace(u(e,{unit:"word"}))},actionDescription:{name:e.deleteWordPrevious}},deleteWordNext:{defaultHandler:function(e){return t._doDelete(u(e,{unit:"word"}))},actionDescription:{name:e.deleteWordNext}},deleteLineStart:{defaultHandler:function(e){return t._doBackspace(u(e,{unit:"line"}))},actionDescription:{name:e.deleteLineStart}},deleteLineEnd:{defaultHandler:function(e){return t._doDelete(u(e,{unit:"line"}))},actionDescription:{name:e.deleteLineEnd}},tab:{defaultHandler:function(e){return t._doTab(u(e,{}))},actionDescription:{name:e.tab}},shiftTab:{defaultHandler:function(e){return t._doShiftTab(u(e,{}))},actionDescription:{name:e.shiftTab}},enter:{defaultHandler:function(e){return t._doEnter(u(e,{}))},actionDescription:{name:e.enter}},enterNoCursor:{defaultHandler:function(e){return t._doEnter(u(e,{noCursor:!0}))},actionDescription:{name:e.enterNoCursor}},escape:{defaultHandler:function(e){return t._doEscape(u(e,{}))},actionDescription:{name:e.escape}},selectAll:{defaultHandler:function(e){return t._doSelectAll(u(e,{}))},actionDescription:{name:e.selectAll}},copy:{defaultHandler:function(e){return t._doCopy(u(e,{}))},actionDescription:{name:e.copy}},cut:{defaultHandler:function(e){return t._doCut(u(e,{}))},actionDescription:{name:e.cut}},paste:{defaultHandler:function(e){return t._doPaste(u(e,{}))},actionDescription:{name:e.paste}},uppercase:{defaultHandler:function(e){return t._doCase(u(e,{type:"upper"}))},actionDescription:{name:e.uppercase}},lowercase:{defaultHandler:function(e){return t._doCase(u(e,{type:"lower"}))},actionDescription:{name:e.lowercase}},capitalize:{defaultHandler:function(e){return t._doCase(u(e,{unit:"word",type:"capitalize"}))},actionDescription:{name:e.capitalize}},reversecase:{defaultHandler:function(e){return t._doCase(u(e,{type:"reverse"}))},actionDescription:{name:e.reversecase}},toggleOverwriteMode:{defaultHandler:function(e){return t._doOverwriteMode(u(e,{}))},actionDescription:{name:e.toggleOverwriteMode}},toggleTabMode:{defaultHandler:function(e){return t._doTabMode(u(e,{}))},actionDescription:{name:e.toggleTabMode}},toggleWrapMode:{defaultHandler:function(e){return t._doWrapMode(u(e,{}))},actionDescription:{name:e.toggleWrapMode}}}},_createRulerParent:function(e,t){var i=s.createElement(e,"div");return i.className=t,i.tabIndex=-1,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.display="none",i.setAttribute("aria-hidden","true"),this._rootDiv.appendChild(i),i},_createRuler:function(e,t){if(this._clientDiv){var i=this._getRulerParent(e);if(i){(i!==this._marginDiv||this._marginOffset)&&(i.style.display="block"),i.rulerWidth=void 0;var n=s.createElement(i.ownerDocument,"div");if(n._ruler=e,e.node=n,n.rulerChanged=!0,n.style.position="relative",n.style.cssFloat="left",n.style.styleFloat="left",n.style.outline="none",void 0===t||0>t||t>=i.children.length)i.appendChild(n);else{for(var o=i.firstChild;o&&t-->0;)o=o.nextSibling;i.insertBefore(n,o)}}}},_createSelectionDiv:function(){var e=s.createElement(this._parent.ownerDocument,"div");return e.className="textviewSelection",e.style.position="absolute",e.style.borderWidth="0px",e.style.margin="0px",e.style.padding="0px",e.style.outline="none",e.style.width="0px",e.style.height="0px",e.style.zIndex="0",e},_createView:function(){function e(){x._rootDiv&&(x.update(!0),x._metrics.invalid&&x._getWindow().setTimeout(function(){e()},100))}if(!this._clientDiv){for(var t=this._parent;t.hasChildNodes();)t.removeChild(t.lastChild);var i=t.ownerDocument,n=s.createElement(i,"div");this._rootDiv=n,n.tabIndex=-1,n.style.position="relative",n.style.overflow="hidden",n.style.width="100%",n.style.height="100%",n.style.overflow="hidden",n.style.WebkitTextSizeAdjust="100%",n.setAttribute("role","application"),t.appendChild(n);var o=this._createRulerParent(i,"textviewLeftRuler");this._leftDiv=o;var r=s.createElement(i,"div");r.className="textviewScroll",this._viewDiv=r,r.tabIndex=-1,r.style.position="absolute",r.style.top="0px",r.style.bottom="0px",r.style.borderWidth="0px",r.style.margin="0px",r.style.outline="none",r.style.background="transparent",n.appendChild(r);var a=this._createRulerParent(i,"textviewRightRuler");this._rightDiv=a,"rtl"==document.dir?a.style.left="0px":a.style.right="0px";var l=this._createRulerParent(i,"textviewInnerRightRuler");this._innerRightDiv=l,l.style.zIndex="1";var d=s.createElement(i,"div");this._scrollDiv=d,d.style.margin="0px",d.style.borderWidth="0px",d.style.padding="0px",r.appendChild(d);var h=this._marginDiv=this._createRulerParent(i,"textviewMarginRuler");if(h.style.zIndex="4",!s.isIE&&!s.isIOS){var c=s.createElement(i,"div");this._clipDiv=c,c.style.position="absolute",c.style.overflow="hidden",c.style.margin="0px",c.style.borderWidth="0px",c.style.padding="0px",c.style.background="transparent",n.appendChild(c);var u=s.createElement(i,"div");this._clipScrollDiv=u,u.style.position="absolute",u.style.height="1px",u.style.top="-1000px",u.style.background="transparent",c.appendChild(u)}var p=s.createElement(i,"div");if(p.className="textviewContent",this._clientDiv=p,p.tabIndex=0,p.style.position="absolute",p.style.borderWidth="0px",p.style.margin="0px",p.style.padding="0px",p.style.outline="none",p.style.zIndex="1",p.style.WebkitUserSelect="text",p.setAttribute("spellcheck","false"),(s.isIOS||s.isAndroid)&&(p.style.WebkitTapHighlightColor="transparent"),(this._clipDiv||n).appendChild(p),this._setFullSelection(this._fullSelection,!0),s.isIOS||s.isAndroid){var f=s.createElement(i,"div");this._vScrollDiv=f,f.style.position="absolute",f.style.borderWidth="1px",f.style.borderColor="white",f.style.borderStyle="solid",f.style.borderRadius="4px",f.style.backgroundColor="black",f.style.opacity="0.5",f.style.margin="0px",f.style.padding="0px",f.style.outline="none",f.style.zIndex="3",f.style.width="8px",f.style.display="none",n.appendChild(f);var g=s.createElement(i,"div");this._hScrollDiv=g,g.style.position="absolute",g.style.borderWidth="1px",g.style.borderColor="white",g.style.borderStyle="solid",g.style.borderRadius="4px",g.style.backgroundColor="black",g.style.opacity="0.5",g.style.margin="0px",g.style.padding="0px",g.style.outline="none",g.style.zIndex="3",g.style.height="8px",g.style.display="none",n.appendChild(g)}if(s.isFirefox&&!p.setCapture){var _=s.createElement(i,"div");this._overlayDiv=_,_.style.position=p.style.position,_.style.borderWidth=p.style.borderWidth,_.style.margin=p.style.margin,_.style.padding=p.style.padding,_.style.cursor="text",_.style.zIndex="2",(this._clipDiv||n).appendChild(_)}p.contentEditable="true",p.setAttribute("role","textbox"),p.setAttribute("aria-multiline","true"),this._setWrapMode(this._wrapMode,!0),this._setReadOnly(this._readonly),this._setThemeClass(this._themeClass,!0),this._setTabSize(this._tabSize,!0),this._setMarginOffset(this._marginOffset,!0),this._hookEvents();for(var m=this._rulers,y=0;ythis._getLineHeight()){var i=t.getBoundingClientRect(),n=this._clientDiv.getBoundingClientRect();i.bottom>n.bottom&&(t=this._getLinePrevious(t)||t)}return t.lineIndex},_getBlockSelections:function(e,t,i){var n=this._model;e=e.filter(function(e){return!e._editing});var o,r=n.getLineAtOffset(this._blockSelection.getAnchor());t>r?o=t:(o=r,r=t);for(var s=r;o>=s;s++){var a=this._getLine(s),l=a.getOffset(i.x,1),d=a.getOffset(this._blockSelection._docX,1);if(a.destroy(),l!==d||l!==n.getLineEnd(s)){var h=d>l,c=new y(h?l:d,h?d:l,h);c._editing=!0,e.push(c)}}return e},_getBoundsAtOffset:function(e){var t=this._model,i=this._getLine(t.getLineAtOffset(e)),n=i.getBoundingClientRect(e),o=this._getLinePixel(i.lineIndex);return n.top+=o,n.bottom+=o,i.destroy(),n},_getClientHeight:function(){var e=this._getViewPadding();return Math.max(0,this._viewDiv.clientHeight-e.top-e.bottom)},_getInnerRightWidth:function(){var e=this._innerRightDiv.rulerWidth;if(void 0===e){var t=this._innerRightDiv.getBoundingClientRect();this._innerRightDiv.rulerWidth=e=t.right-t.left}return e},_getClientWidth:function(){var e=this._getViewPadding(),t=this._getInnerRightWidth();return Math.max(0,this._viewDiv.clientWidth-e.left-e.right-t)},_getClipboardText:function(e,t){function i(e){var i=[];return f(e,function(e){i.push(e)},null),t&&t(i),i}var n=this._getWindow(),o=n.clipboardData;if(!o&&e&&(o=e.clipboardData),o)return i(o.getData(s.isIE?"Text":"text/plain"));if(s.isFirefox){this._ignoreFocus=!0;var r=this._clipboardDiv,a=this._rootDiv.ownerDocument;r||(r=s.createElement(a,"div"),this._clipboardDiv=r,r.style.position="fixed",r.style.whiteSpace="pre",r.style.left="-1000px",this._rootDiv.appendChild(r)),r.innerHTML="
",r.firstChild.focus();var l=this,d=function(){var e=l._getTextFromElement(r);return r.innerHTML="",i(e)},h=!1;if(this._ignorePaste=!0,!s.isLinux||2!==this._lastMouseButton)try{h=a.execCommand("paste",!1,null)}catch(c){h=r.childNodes.length>1||r.firstChild&&r.firstChild.childNodes.length>0}return this._ignorePaste=!1,h?(this.focus(),this._ignoreFocus=!1,d()):e?(n.setTimeout(function(){l.focus(),d(),l._ignoreFocus=!1},0),null):(this.focus(),this._ignoreFocus=!1,"")}return""},_getDOMText:function(e,t){return e._line.getText(t)},_getTextFromElement:function(e){var t=e.ownerDocument,i=t.defaultView;if(!i.getSelection)return e.innerText||e.textContent;var n=t.createRange();n.selectNode(e);var o,r=i.getSelection(),s=[];for(o=0;oi)for(t=i;e>t;t++)n+=this._getLineHeight(t);else for(t=i-1;t>=e;t--)n-=this._getLineHeight(t);return n}var o=this._getLineHeight();return o*e},_getLineIndex:function(e,t){var i,n=0,o=this._model.getLineCount();if(this._lineHeight){n=this._getTopIndex();var r=-this._topIndexY+this._getScroll().y;if(e!==r)if(r>e)for(;r>e&&n>0;)e+=this._getLineHeight(--n);else for(i=this._getLineHeight(n);e-i>=r&&o-1>n;)e-=i,i=this._getLineHeight(++n)}else i=this._getLineHeight(),n=Math.floor(e/i);return t&&(0===o||0>n||n>o-1)?-1:Math.max(0,Math.min(o-1,n))},_getRulerParent:function(e){switch(e.getLocation()){case"left":return this._leftDiv;case"right":return this._rightDiv;case"innerRight":return this._innerRightDiv;case"margin":return this._marginDiv}return null},_getScroll:function(e){(void 0===e||e)&&this._cancelAnimation();var t=this._viewDiv;return{x:t.scrollLeft,y:t.scrollTop}},_getSelection:function(){return(Array.isArray(this._selection)?this._selection[0]:this._selection).clone()},_getSelections:function(){return(Array.isArray(this._selection)?this._selection:[this._selection]).map(function(e){return e.clone()})},_getTopIndex:function(e){var t=this._topChild;if(e&&this._getClientHeight()>this._getLineHeight()){var i=t.getBoundingClientRect(),n=this._getViewPadding(),o=this._viewDiv.getBoundingClientRect();i.top26?"wheel":s.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(t){return e._handleMouseWheel(t?t:l.event)}}),this._clipDiv&&t.push({target:this._clipDiv,type:s.isFirefox>26?"wheel":s.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(t){return e._handleMouseWheel(t?t:l.event)
-}}),s.isFirefox&&(!s.isWindows||s.isFirefox>=15)){var h=l.MutationObserver||l.MozMutationObserver;h?(this._mutationObserver=new h(function(t){e._handleDataModified(t)}),this._mutationObserver.observe(i,{subtree:!0,characterData:!0})):t.push({target:this._clientDiv,type:"DOMCharacterDataModified",handler:function(t){return e._handleDataModified(t?t:l.event)}})}(s.isFirefox&&(!s.isWindows||s.isFirefox>=15)||s.isIE||s.isWebkit)&&(t.push({target:this._clientDiv,type:"compositionstart",handler:function(t){return e._handleCompositionStart(t?t:l.event)}}),t.push({target:this._clientDiv,type:"compositionend",handler:function(t){return e._handleCompositionEnd(t?t:l.event)}}),t.push({target:this._clientDiv,type:"compositionupdate",handler:function(t){return e._handleCompositionUpdate(t?t:l.event)}})),this._overlayDiv&&(t.push({target:this._overlayDiv,type:"mousedown",handler:function(t){return e._handleMouseDown(t?t:l.event)}}),t.push({target:this._overlayDiv,type:"mouseover",handler:function(t){return e._handleMouseOver(t?t:l.event)}}),t.push({target:this._overlayDiv,type:"mouseout",handler:function(t){return e._handleMouseOut(t?t:l.event)}}),t.push({target:this._overlayDiv,type:"contextmenu",handler:function(t){return e._handleContextMenu(t?t:l.event)}})),this._isW3CEvents||t.push({target:this._clientDiv,type:"dblclick",handler:function(t){return e._handleDblclick(t?t:l.event)}})}this._hookRulerEvents(this._leftDiv,t),this._hookRulerEvents(this._rightDiv,t),this._hookRulerEvents(this._innerRightDiv,t),this._hookRulerEvents(this._marginDiv,t);for(var c=0;c26?"wheel":s.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(e){return i._handleMouseWheel(e?e:n.event)}}),t.push({target:e,type:"click",handler:function(e){i._handleRulerEvent(e?e:n.event)}}),t.push({target:e,type:"dblclick",handler:function(e){i._handleRulerEvent(e?e:n.event)}}),t.push({target:e,type:"mousemove",handler:function(e){i._handleRulerEvent(e?e:n.event)}}),t.push({target:e,type:"mouseover",handler:function(e){i._handleRulerEvent(e?e:n.event)}}),t.push({target:e,type:"mouseout",handler:function(e){i._handleRulerEvent(e?e:n.event)}})}},_getWindow:function(){return l(this._parent.ownerDocument)},_ignoreEvent:function(e){for(var t=e.target;t&&t!==this._clientDiv;){if(t.ignore)return!0;t=t.parentNode}return!1},_init:function(e){var i=e.parent;if("string"==typeof i&&(i=(e.document||document).getElementById(i)),!i)throw new Error("no parent");e.parent=i,e.model=e.model||new t.TextModel;var n=this._defaultOptions();for(var o in n)if(n.hasOwnProperty(o)){var r;r=void 0!==e[o]?e[o]:n[o].value,this["_"+o]=r}this._keyModes=[],this._rulers=[],this._selection=[new y(0,0,!1)],this._linksVisible=!1,this._redrawCount=0,this._maxLineWidth=0,this._maxLineIndex=-1,this._ignoreSelect=!0,this._ignoreFocus=!1,this._hasFocus=!1,this._dragOffset=-1,this._isRangeRects=(!s.isIE||s.isIE>=9)&&"function"==typeof i.ownerDocument.createRange().getBoundingClientRect,this._isW3CEvents=i.addEventListener,this._autoScrollX=null,this._autoScrollY=null,this._autoScrollTimerID=null,this._AUTO_SCROLL_RATE=50,this._grabControl=null,this._moseMoveClosure=null,this._mouseUpClosure=null,this._lastMouseX=0,this._lastMouseY=0,this._lastMouseTime=0,this._clickCount=0,this._clickTime=250,this._clickDist=5,this._isMouseDown=!1,this._doubleClickSelection=null,this._hScroll=0,this._vScroll=0,this._imeOffset=-1,this._createActions(),this._createView()},_checkOverlayScroll:function(){if(s.isMac&&s.isWebkit&&!this._metrics.invalid&&0===this._metrics.scrollWidth){var e=this._viewDiv,t=this._isOverOverlayScroll();e.style.pointerEvents=t.vertical||t.horizontal?"":"none"}},_isOverOverlayScroll:function(){var e=(new Date).getTime()-this._lastScrollTime<200;if(!e)return{};var t=this._viewDiv.getBoundingClientRect(),i=this._lastMouseMoveX,n=this._lastMouseMoveY,o=15;return{vertical:t.top<=n&&n1&&this.setRedraw(!1);var s=this._compoundChange;s?y.compare(this._getSelections(),s.owner.selection)||(this._endUndo(),e.selection.length>1&&this._startUndo()):e.selection.length>1&&this._startUndo();var a=this._model;try{e._ignoreDOMSelection&&(this._ignoreDOMSelection=!0);var l=0,d=0;e.selection.forEach(function(i){i.start+=l,i.end+=l;var n=Array.isArray(e.text)?e.text[d]:e.text;a.setText(n,i.start,i.end),l+=i.start-i.end+n.length,i.setCaret(t?i.start+n.length:i.start),d++})}finally{e._ignoreDOMSelection&&(this._ignoreDOMSelection=!1)}return this._setSelection(e.selection,i,!0,n),s=this._compoundChange,s&&(s.owner.selection=e.selection),e.selection.length>1&&this.setRedraw(!0),this.onModify({type:"Modify"}),!0},_onModelChanged:function(e){e.type="ModelChanged",this.onModelChanged(e),e.type="Changed";var t=e.start,i=e.addedCharCount,n=e.removedCharCount,o=e.addedLineCount,r=e.removedLineCount,s=this._getSelections();s.forEach(function(e){e.end>t&&(e.end>t&&e.start=l&&l+r>=c&&(l!==c||h.modelChangedEvent||h.lineRemoved?(h.lineRemoved=!0,h.lineChanged=!1,h.modelChangedEvent=null):(h.modelChangedEvent=e,h.lineChanged=!0)),c>l+r&&(h.lineIndex=c+o-r,h._line.lineIndex=h.lineIndex),h=this._getLineNext(h)}if(this._lineHeight){var u=[l,r].concat(d(o));Array.prototype.splice.apply(this._lineHeight,u)}this._wrapMode||l<=this._maxLineIndex&&this._maxLineIndex<=l+r&&(this._checkMaxLineIndex=this._maxLineIndex,this._maxLineIndex=-1,this._maxLineWidth=0),this._update()},_onModelChanging:function(e){e.type="ModelChanging",this.onModelChanging(e),e.type="Changing"},_queueUpdate:function(){if(!this._updateTimer&&!this._ignoreQueueUpdate){var e=this,t=this._getWindow();this._updateTimer=t.setTimeout(function(){e._updateTimer=null,e._update()},0)}},_rangesToSelections:function(e){var t=[],i=this._model.getCharCount();return e.forEach(function(e){var n;if(e instanceof y)n=e.clone();else{var o=e.start,r=e.end,s=o>r;if(s){var a=o;o=r,r=a}o=Math.max(0,Math.min(o,i)),r=Math.max(0,Math.min(r,i)),n=new y(o,r,s)}t.push(n)}),t},_resetLineHeight:function(e,t){if(this._wrapMode||this._variableLineHeight){if(void 0!==e&&void 0!==t)for(var i=e;t>i;i++)this._lineHeight[i]=void 0;else this._lineHeight=d(this._model.getLineCount());this._calculateLineHeightTimer()}else this._lineHeight=null},_resetLineWidth:function(){var e=this._clientDiv;if(e)for(var t=e.firstChild;t;)t.lineWidth=void 0,t=t.nextSibling},_reset:function(){this._maxLineIndex=-1,this._maxLineWidth=0,this._topChild=null,this._bottomChild=null,this._topIndexY=0,this._variableLineHeight=!1,this._resetLineHeight(),this._setSelection(new y(0,0,!1),!1,!1),this._viewDiv&&(this._viewDiv.scrollLeft=0,this._viewDiv.scrollTop=0);var e=this._clientDiv;if(e){for(var t=e.firstChild;t;)t.lineRemoved=!0,t=t.nextSibling;s.isFirefox<13&&this._fixCaret()}},_scrollViewAnimated:function(e,t,i){var n=this._getWindow();if(i&&this._scrollAnimation){var o=this;this._animation=new k({window:n,duration:this._scrollAnimation,curve:[t,0],onAnimate:function(e){var i=t-Math.floor(e);o._scrollView(0,i),t-=i},onEnd:function(){o._animation=null,o._scrollView(e,t),i&&n.setTimeout(i,0)}}),this._animation.play()}else this._scrollView(e,t),i&&n.setTimeout(i,0)},_scrollView:function(e,t){this._ensureCaretVisible=!1;var i=this._viewDiv;e&&(i.scrollLeft+=e),t&&(i.scrollTop+=t)},_setClipboardText:function(e,t){var i,n=this._getWindow(),o=n.clipboardData;if(!o&&t&&(o=t.clipboardData),o){i=[],f(e,function(e){i.push(e)},function(){i.push(s.platformDelimiter)});var r=o.setData(s.isIE?"Text":"text/plain",i.join(""));if(r||t&&(s.isFirefox>21||s.isWebkit))return!0;if(!t)return!1}var a=this._parent.ownerDocument,l=s.createElement(a,"pre");l.style.position="fixed",l.style.left="-1000px",f(e,function(e){l.appendChild(a.createTextNode(e))},function(){l.appendChild(s.createElement(a,"br"))}),l.appendChild(a.createTextNode(" ")),this._clientDiv.appendChild(l);var d=a.createRange();d.setStart(l.firstChild,0),d.setEndBefore(l.lastChild);var h=n.getSelection();h.rangeCount>0&&h.removeAllRanges(),h.addRange(d);var c=this,u=function(){l&&l.parentNode===c._clientDiv&&c._clientDiv.removeChild(l),c._updateDOMSelection()},p=!1;this._ignoreCopy=!0;try{p=a.execCommand("copy",!1,null)}catch(g){}return this._ignoreCopy=!1,!p&&t?(n.setTimeout(u,0),!1):(u(),!0)},_setGrab:function(e){e!==this._grabControl&&(e?(e.setCapture&&e.setCapture(),this._grabControl=e):(this._grabControl.releaseCapture&&this._grabControl.releaseCapture(),this._grabControl=null))},_setLinksVisible:function(e){if(this._linksVisible!==e){this._linksVisible=e,s.isIE&&e&&(this._hadFocus=this._hasFocus);var t=this._clientDiv;t.contentEditable=!e,this._hadFocus&&!e&&t.focus(),this._overlayDiv&&(this._overlayDiv.style.zIndex=e?"-1":"1");for(var i=this._getLineNext();i;)i._line.updateLinks(),i=this._getLineNext(i);this._updateDOMSelection()}},_setSelection:function(e,t,i,n,o,r,s){if(e){void 0===i&&(i=!0);var a,l=this._getSelections();if(a=Array.isArray(e)?e:r?l.concat([e]):[e],this._selection=y.merge(a),s||a.forEach(function(e){e._columnX=-1}),t!==!1&&this._showCaret(!1,n,t,o),i&&this._updateDOMSelection(),!y.compare(l,a)){var d={type:"Selection",oldValue:y.convert(l),newValue:y.convert(a)};this.onSelection(d)}}},_setSelectionTo:function(e,t,i,n,o,r){var s=this._model,a=this._getSelections(),l=this.convert({x:e,y:t},"page","document"),d=this._getLineIndex(l.y),h=this._getLine(d),c=h.getOffset(l.x,l.y-this._getLinePixel(d));if(r&&!n&&y.contains(a,c))return this._dragOffset=c,h.destroy(),!1;if(this._blockSelection)a=this._getBlockSelections(a,d,l);else{var u;if(i?n?(u=a[a.length-1],u._editing=!0):(u=new y(0,0),u._editing=!0,o?a.push(u):a=[u],u._docX=l.x):u=y.editing(a),1===this._clickCount)u.extend(c),n||u.collapse();else{var p,f,g=0===(1&this._clickCount);if(g)this._doubleClickSelection?c>=this._doubleClickSelection.start?(p=this._doubleClickSelection.start,f=h.getNextOffset(c,{unit:"wordend",count:1})):(p=h.getNextOffset(c,{unit:"word",count:-1}),f=this._doubleClickSelection.end):(p=h.getNextOffset(c,{unit:"word",count:-1}),f=h.getNextOffset(p,{unit:"wordend",count:1}));else if(this._doubleClickSelection){var _=s.getLineAtOffset(this._doubleClickSelection.start);d>=_?(p=s.getLineStart(_),f=s.getLineEnd(d)):(p=s.getLineStart(d),f=s.getLineEnd(_))}else p=s.getLineStart(d),f=s.getLineEnd(d);u.setCaret(p),u.extend(f)}}return this._setSelection(a,!0,!0,null,!1),h.destroy(),!0},_setFullSelection:function(e,t){this._fullSelection=e,s.isWebkit<537.36&&(this._fullSelection=e=!0),this._domSelection||(this._domSelection=[],this._cursorVisible=!0),t||this._updateDOMSelection()},_setBlockCursor:function(e){this._blockCursorVisible=e,this._updateBlockCursorVisible()},_setOverwriteMode:function(e){this._overwriteMode=e,this._updateBlockCursorVisible()},_updateBlockCursorVisible:function(){if(this._blockCursorVisible||this._overwriteMode){if(!this._cursorDiv){var e=this._viewDiv,t=s.createElement(e.ownerDocument,"div");t.className="textviewBlockCursor",this._cursorDiv=t,t.tabIndex=-1,t.style.zIndex="2",t.style.color="transparent",t.style.position="absolute",t.style.pointerEvents="none",t.innerHTML=" ",e.appendChild(t),this._updateDOMSelection()}}else this._cursorDiv&&(this._cursorDiv.parentNode.removeChild(this._cursorDiv),this._cursorDiv=null)},_setMarginOffset:function(e,t){this._marginOffset=e,this._marginDiv.style.display=e?"block":"none",t||(this._metrics=this._calculateMetrics(),this._queueUpdate())},_setWrapOffset:function(e,t){this._wrapOffset=e,t||(this._metrics=this._calculateMetrics(),this._queueUpdate())},_setReadOnly:function(e){this._readonly=e,this._clientDiv.setAttribute("aria-readonly",e?"true":"false")},_setSingleMode:function(e,t){this._singleMode=e,this._updateOverflow(),this._updateStyle(t)},_setNoScroll:function(e,t){this._noScroll=e,this._updateOverflow(),this._updateStyle(t)},_setTabSize:function(e,t){this._tabSize=e,this._customTabSize=void 0;var i=this._clientDiv;s.isOpera?i&&(i.style.OTabSize=this._tabSize+""):s.isWebkit>=537.1?i&&(i.style.tabSize=this._tabSize+""):s.isFirefox>=4?i&&(i.style.MozTabSize=this._tabSize+""):8!==this._tabSize&&(this._customTabSize=this._tabSize),t||(this.redrawLines(),this._resetLineWidth())},_setTheme:function(e){this._theme&&this._theme.removeEventListener("ThemeChanged",this._themeListener.onChanged),this._theme=e,this._theme&&this._theme.addEventListener("ThemeChanged",this._themeListener.onChanged),this._setThemeClass(this._themeClass)},_setThemeClass:function(e,t){this._themeClass=e;var i="textview",n=this._theme.getThemeClass();n&&(i+=" "+n),this._themeClass&&n!==this._themeClass&&(i+=" "+this._themeClass),this._rootDiv.className=i,this._updateStyle(t)},_setUndoStack:function(e){this._undoStack=e},_setWrapMode:function(e,t){this._wrapMode=e&&this._wrappable;var i=this._clientDiv;this._wrapMode?(i.style.whiteSpace="pre-wrap",i.style.wordWrap="break-word"):(i.style.whiteSpace="pre",i.style.wordWrap="normal"),this._updateOverflow(),t||(this.redraw(),this._resetLineWidth()),this._resetLineHeight()},_showCaret:function(e,t,i,n){if(this._clientDiv&&!(this._redrawCount>0||this._ignoreDOMSelection||-1!==this._imeOffset)){var o=this._model,r=this._getSelections(),s=y.editing(r,"down"===this._autoScrollDir),a=this._getScroll(),l=s.getCaret(),d=s.start,h=s.end,c=o.getLineAtOffset(d),u=o.getLineAtOffset(h),p=Math.max(Math.max(d,o.getLineStart(u)),h-1),f=this._getClientWidth(),g=this._getClientHeight(),_=f/4,m=this._getBoundsAtOffset(l===d?d:p),v=m.left,x=m.right,b=m.top,C=m.bottom,w=0,T="object"==typeof i;!e&&!T||s.isEmpty()||(m=this._getBoundsAtOffset(l===h?d:p),w=(m.bottom>C?m.bottom:C)-(m.topa.x+f&&(L=Math.max(x-a.x-f,_));var k=0;ba.y+g&&(k=C-a.y-g),n&&(n>0?k>0&&(k=Math.max(k,n)):0>k&&(k=Math.min(k,n)));var D=T&&"always"===i.scrollPolicy;if(0!==L||0!==k||D){if(T){var A=k>0;0===k&&(k=b-a.y);var S=i.viewAnchor,E=i.selectionAnchor,O=Math.min(Math.max(0,i.viewAnchorOffset||0));k+=Math.floor("top"===S?A?(1-O)*g:-O*g:"bottom"===S?A?O*g:-(1-O)*g:"center"===S?A?g/2+O*g:g/2-(1-O)*g:A?O*g:-O*g),c!==u&&("top"===E&&l!==d?k+=Math.floor(-w):"bottom"===E&&l!==h?k+=Math.floor(w):"center"===E&&(k+=Math.floor(w/2)))}else 0!==k&&"number"==typeof i&&(0>i&&(i=0),i>1&&(i=1),k+=Math.floor(k>0?i*g:-i*g));return this._scrollViewAnimated(L,k,t),g!==this._getClientHeight()||f!==this._getClientWidth()?this._showCaret():this._ensureCaretVisible=!0,!0}return t&&t(),!1}},_startIME:function(){if(-1===this._imeOffset){for(var e=!1,t=this._getSelections(),i=0;i0)&&!this._ignoreDOMSelection&&-1===this._imeOffset&&this._clientDiv){var e,t=this._getSelections(),i=this._domSelection;if(i.lengtht.length&&i.splice(t.length).forEach(function(e){e.destroy()});for(e=0;e1?this._cursorTimer||(this._cursorTimer=n.setInterval(function(){o._cursorVisible=!o._cursorVisible,o._domSelection.forEach(function(e){e.update()})},500)):this._cursorTimer&&(n.clearInterval(this._cursorTimer),this._cursorTimer=null)}},_update:function(e){if(!(this._redrawCount>0)){if(this._updateTimer){var t=this._getWindow();t.clearTimeout(this._updateTimer),this._updateTimer=null,e=!1}var i=this._clientDiv,n=this._viewDiv;if(i){this._metrics.invalid&&(this._ignoreQueueUpdate=!0,this._updateStyle(),this._ignoreQueueUpdate=!1);var o=this._model,r=this._getScroll(!1),a=this._getViewPadding(),l=o.getLineCount(),d=this._getLineHeight(),h=!1,c=!1,u=!1,p=this._metrics.scrollWidth;this._wrapMode&&(i.style.width=(this._metrics.wrapWidth||this._getClientWidth())+"px");var f,g,_,m,v,y,x,b,w,T,L,k=0,D=0;if(this._lineHeight){for(;l>D&&(L=this._getLineHeight(D),!(k+L>r.y));)k+=L,D++;f=D,g=Math.max(0,f-1),m=_=r.y-k,f>0&&(_+=this._getLineHeight(f-1))}else{var A=Math.max(0,r.y)/d;f=Math.floor(A),g=Math.max(0,f-1),_=Math.round((A-g)*d),m=Math.round((A-f)*d),T=l*d}this._topIndexY=m;var S=this._rootDiv,E=S.clientWidth,O=S.clientHeight;if(e){for(v=0,this._leftDiv&&(y=this._leftDiv.getBoundingClientRect(),v=y.right-y.left),x=this._getClientWidth(),b=this._getClientHeight(),w=x,this._wrapMode?this._metrics.wrapWidth&&(w=this._metrics.wrapWidth):w=Math.max(this._maxLineWidth,w);l>D;)L=this._getLineHeight(D,!1),k+=L,D++;T=k}else{b=this._getClientHeight();for(var N,M,I=Math.floor((b+m)/d),B=Math.min(f+I,l-1),R=Math.min(B+1,l-1),F=i.firstChild;F;){N=F.lineIndex;var P=F.nextSibling;N>=g&&R>=N&&!F.lineRemoved&&-1!==F.lineIndex||(this._mouseWheelLine===F?(F.style.display="none",F.lineIndex=-1):i.removeChild(F)),F=P}F=this._getLineNext();var W=n.ownerDocument,V=W.createDocumentFragment();for(N=g;R>=N;N++)!F||F.lineIndex>N?new C(this,N).create(V,null):(V.firstChild&&(i.insertBefore(V,F),V=W.createDocumentFragment()),F&&F.lineChanged&&(F=new C(this,N).create(V,F),F.lineChanged=!1),F=this._getLineNext(F));V.firstChild&&i.insertBefore(V,F),s.isWebkit&&!this._wrapMode&&(i.style.width="0x7fffffffpx");var H;F=this._getLineNext();for(var U=b+_,j=!1;F;){if(M=F.lineWidth,void 0===M){H=F._line.getBoundingClientRect(),M=F.lineWidth=Math.ceil(H.right-H.left);var K=H.bottom-H.top;this._lineHeight?this._lineHeight[F.lineIndex]=K:0!==d&&0!==K&&Math.ceil(d)!==Math.ceil(K)&&(this._variableLineHeight=!0,this._lineHeight=[],this._lineHeight[F.lineIndex]=K)}this._lineHeight&&!j&&(U-=this._lineHeight[F.lineIndex],0>U&&(B=F.lineIndex,j=!0)),this._wrapMode||(M>=this._maxLineWidth&&(this._maxLineWidth=M,this._maxLineIndex=F.lineIndex),this._checkMaxLineIndex===F.lineIndex&&(this._checkMaxLineIndex=-1)),F.lineIndex===f&&(this._topChild=F),F.lineIndex===B&&(this._bottomChild=F),F=this._getLineNext(F)}if(-1!==this._checkMaxLineIndex&&(N=this._checkMaxLineIndex,this._checkMaxLineIndex=-1,N>=0&&l>N)){var $=new C(this,N);H=$.getBoundingClientRect(),M=H.right-H.left,M>=this._maxLineWidth&&(this._maxLineWidth=M,this._maxLineIndex=N),$.destroy()}for(;l>D;)L=this._getLineHeight(D,B>=D),k+=L,D++;T=k,this._updateRuler(this._leftDiv,f,R,O),this._updateRuler(this._rightDiv,f,R,O),this._updateRuler(this._innerRightDiv,f,R,O),this._updateRuler(this._marginDiv,f,R,O),v=0,this._leftDiv&&(y=this._leftDiv.getBoundingClientRect(),v=y.right-y.left);var z=0;if(this._rightDiv){var G=this._rightDiv.getBoundingClientRect();z=G.right-G.left}n.style.left=v+"px",n.style.right=z+"px";var Y=this._scrollDiv;if(Y.style.height=T+(s.isWebkit?0:a.bottom)+"px",x=this._getClientWidth(),!this._singleMode&&!this._wrapMode&&!this._noScroll){var X=b,q=b,Q="scroll"===n.style.overflowX;Q?X+=p:q-=p;var J=x,Z=x,et="scroll"===n.style.overflowY;et?J+=p:Z-=p,b=X,x=J,T>b&&(u=!0,x=Z),this._maxLineWidth>x&&(c=!0,b=q,T>b&&(u=!0,x=Z)),Q!==c&&(n.style.overflowX=c?"scroll":"hidden"),et!==u&&(n.style.overflowY=u?"scroll":"hidden"),h=Q!==c||et!==u}var tt=x;this._wrapMode?this._metrics.wrapWidth&&(tt=this._metrics.wrapWidth):tt=Math.max(this._maxLineWidth+this._getInnerRightWidth(),tt),w=tt,(!s.isIE||s.isIE>=9)&&this._maxLineWidth>x&&(tt+=a.right+a.left),Y.style.width=tt+"px",this._clipScrollDiv&&(this._clipScrollDiv.style.width=tt+"px"),r=this._getScroll(!1);var it=this._innerRightDiv;it&&(it.style.right=z+("scroll"===n.style.overflowY?this._metrics.scrollWidth:0)+"px",it.style.bottom=("scroll"===n.style.overflowX?p:0)+"px")}if(this._scrollHeight=T,this._vScrollDiv){var nt=b-8,ot=Math.max(15,Math.ceil(Math.min(1,nt/(T+a.top+a.bottom))*nt));this._vScrollDiv.style.left=v+x-8+"px",this._vScrollDiv.style.top=Math.floor(Math.max(0,r.y*nt/T))+"px",this._vScrollDiv.style.height=ot+"px"}if(!this._wrapMode&&this._hScrollDiv){var rt=x-8,st=Math.max(15,Math.ceil(Math.min(1,rt/(this._maxLineWidth+a.left+a.right))*rt));this._hScrollDiv.style.left=v+Math.floor(Math.max(0,Math.floor(r.x*rt/this._maxLineWidth)))+"px",this._hScrollDiv.style.top=b-9+"px",this._hScrollDiv.style.width=st+"px"}var at,lt,dt=r.x,ht=this._clipDiv,ct=this._overlayDiv,ut=this._marginDiv;if(ut&&(ut.style.left=-dt+v+this._metrics.marginWidth+a.left+"px",ut.style.bottom=("scroll"===n.style.overflowX?p:0)+"px"),ht){ht.scrollLeft=dt,ht.scrollTop=0,at=v+a.left,lt=a.top;var pt=x,ft=b,gt=0,_t=-_;0===r.x&&(at-=a.left,pt+=a.left,gt=a.left),r.x+x===w&&(pt+=a.right),0===r.y&&(lt-=a.top,ft+=a.top,_t+=a.top),r.y+b===T&&(ft+=a.bottom),ht.style.left=at+"px",ht.style.top=lt+"px",ht.style.right=E-pt-at+"px",ht.style.bottom=O-ft-lt+"px",i.style.left=gt+"px",i.style.top=_t+"px",i.style.width=w+"px",i.style.height=b+_+"px",ct&&(ct.style.left=i.style.left,ct.style.top=i.style.top,ct.style.width=i.style.width,ct.style.height=i.style.height)}else{at=dt,lt=_;var mt=dt+x,vt=_+b;0===at&&(at-=a.left),0===lt&&(lt-=a.top),mt===w&&(mt+=a.right),r.y+b===T&&(vt+=a.bottom),i.style.clip="rect("+lt+"px,"+mt+"px,"+vt+"px,"+at+"px)","rtl"==document.dir?i.style.right=-dt+v+a.left+"px":i.style.left=-dt+v+a.left+"px",i.style.width=(this._wrapMode||s.isWebkit?w:x+dt)+"px",e||(i.style.top=-_+a.top+"px",i.style.height=b+_+"px"),ct&&(ct.style.clip=i.style.clip,ct.style.left=i.style.left,ct.style.width=i.style.width,e||(ct.style.top=i.style.top,ct.style.height=i.style.height))}if(this._updateDOMSelection(),h){var yt=this._ensureCaretVisible;this._ensureCaretVisible=!1,yt&&this._showCaret(),this._queueUpdate()}}}},_updateOverflow:function(){var e=this._viewDiv;this._noScroll?e.style.overflow="hidden":this._wrapMode?(e.style.overflowX="hidden",e.style.overflowY="scroll"):e.style.overflow="hidden"},_updateRuler:function(e,t,i,n){if(e)for(var o=this._parent.ownerDocument,r=this._getLineHeight(),a=this._getViewPadding(),l=e.firstChild;l;){var d=l._ruler,c=d.getOverview();if(l.rulerChanged&&(h(d.getRulerStyle(),l),e.rulerWidth=void 0),"fixed"!==c){var u=r;"page"===c&&(u+=this._topIndexY),l.style.top=-u+"px",l.style.height=n+u+"px";var p,f=l.firstChild;f?(p=f,f=f.nextSibling):(p=s.createElement(o,"div"),p.style.visibility="hidden",l.appendChild(p));var g,_;l.rulerChanged&&p&&(g=-1,_=d.getWidestAnnotation(),_&&(h(_.style,p),_.html&&(p.innerHTML=_.html)),p.lineIndex=g,p.style.height=r+a.top+"px");var m,v,y;if("page"===c){for(y=d.getAnnotations(t,i+1);f;){g=f.lineIndex;var x=f.nextSibling;g>=t&&i>=g&&!f.lineChanged||l.removeChild(f),f=x}for(f=l.firstChild.nextSibling,v=o.createDocumentFragment(),g=t;i>=g;g++)!f||f.lineIndex>g?(m=s.createElement(o,"div"),_=y[g],_&&(h(_.style,m),_.html&&(m.innerHTML=_.html),m.annotation=_),m.lineIndex=g,m.style.height=this._getLineHeight(g)+"px",v.appendChild(m)):(v.firstChild&&(l.insertBefore(v,f),v=o.createDocumentFragment()),f&&(f=f.nextSibling));v.firstChild&&l.insertBefore(v,f)}else{var b,C,w=this._getClientHeight(),T=this._model.getLineCount(),L=r*T,k=w+a.top+a.bottom-2*this._metrics.scrollWidth;if(k>L?(b=r,C=a.top):(b=k/T,C=this._metrics.scrollWidth),l.rulerChanged){for(var D=l.childNodes.length;D>1;)l.removeChild(l.lastChild),D--;y=d.getAnnotations(0,T),v=o.createDocumentFragment();for(var A in y)g=A>>>0,0>g||(m=s.createElement(o,"div"),_=y[A],h(_.style,m),m.style.position="absolute",m.style.top=C+r+Math.floor(g*b)+"px",_.html&&(m.innerHTML=_.html),m.annotation=_,m.lineIndex=g,v.appendChild(m));l.appendChild(v)}else if(l._oldTrackHeight!==k)for(m=l.firstChild?l.firstChild.nextSibling:null;m;)m.style.top=this._metrics.scrollWidth+r+Math.floor(m.lineIndex*b)+"px",m=m.nextSibling;l._oldTrackHeight=k}l.rulerChanged=!1,l=l.nextSibling}else l.rulerChanged=!1,l=l.nextSibling}},_updateStyleSheet:function(){var e="";if(s.isWebkit&&this._metrics.scrollWidth>0&&(e+="\n.textview ::-webkit-scrollbar-corner {background: #eeeeee;}"),e){var t=this._clientDiv.ownerDocument,i=t.getElementById("_textviewStyle");if(i)i.removeChild(i.firstChild),i.appendChild(t.createTextNode(e));else{i=s.createElement(t,"style"),i.id="_textviewStyle";var n=t.getElementsByTagName("head")[0]||t.documentElement;i.appendChild(t.createTextNode(e)),n.insertBefore(i,n.firstChild)}}},_updateStyle:function(e,t){if(!e&&s.isIE&&(this._rootDiv.style.lineHeight="normal"),t=this._metrics=t||this._calculateMetrics(),this._variableLineHeight&&(this._variableLineHeight=!1,this._resetLineHeight()),this._rootDiv.style.lineHeight=s.isIE?t.lineHeight-(t.lineTrim.top+t.lineTrim.bottom)+"px":"normal",this._updateStyleSheet(),s.isMac&&s.isWebkit){var i=this._viewDiv;t.invalid||0!==t.scrollWidth?(i.style.pointerEvents="",i.style.zIndex=""):(i.style.pointerEvents="none",i.style.zIndex="2")}e||(this.redraw(),this._resetLineWidth())}},n.EventTarget.addMixin(w.prototype),{TextView:w}}),define("orion/editor/projectionTextModel",["orion/editor/textModel","orion/editor/eventTarget"],function(e,t){function i(e){this._model=e,this._projections=[];var t=this;this._listener={onChanged:function(e){t._onChanged(e)},onChanging:function(e){t._onChanging(e)}},e.addEventListener("postChanged",this._listener.onChanged),e.addEventListener("preChanging",this._listener.onChanging)}return i.prototype={destroy:function(){this._model&&(this._model.removeEventListener("postChanged",this._listener.onChanged),this._model.removeEventListener("preChanging",this._listener.onChanging),this._model=null)},addProjection:function(t){if(t){var i=this._model,n=this._projections;t._lineIndex=i.getLineAtOffset(t.start),t._lineCount=i.getLineAtOffset(t.end)-t._lineIndex;var o=t.text;o||(o=""),t._model="string"==typeof o?new e.TextModel(o,i.getLineDelimiter()):o;var r=this.mapOffset(t.start,!0),s=t.end-t.start,a=t._lineCount,l=t._model.getCharCount(),d=t._model.getLineCount()-1,h={type:"Changing",text:t._model.getText(),start:r,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:d};this.onChanging(h);var c=this._binarySearch(n,t.start);n.splice(c,0,t);var u={type:"Changed",start:r,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:d};this.onChanged(u)}},getProjections:function(){return this._projections.slice(0)},getBaseModel:function(){return this._model},mapOffset:function(e,t){var i,n,o=this._projections,r=0;if(t){for(i=0;ie));i++){if(n.end>e)return-1;r+=n._model.getCharCount()-(n.end-n.start)}return e+r}for(i=0;ie-r));i++){var s=n._model.getCharCount();if(n.start+s>e-r)return-1;r+=s-(n.end-n.start)}return e-r},removeProjection:function(e){this._removeProjection(e)},_removeProjection:function(e,t){var i,n=0;for(i=0;i1;)i=Math.floor((n+o)/2),t<=e[i].start?n=i:o=i;return n},getCharCount:function(){for(var e=this._model.getCharCount(),t=this._projections,i=0;ie)return null;var i,n,o,r=this._model,s=this._projections,a=0,l=[],d=0;for(i=0;i=e-a));i++){if(n=o._model.getLineCount()-1,o._lineIndex+n>=e-a){var h=e-(o._lineIndex+a);if(n>h)return o._model.getLine(h,t);l.push(o._model.getLine(n))}d=o.end,a+=n-o._lineCount}for(d=Math.max(d,r.getLineStart(e-a));ie-a));i++){if(l.push(r.getText(d,o.start)),n=o._model.getLineCount()-1,o._lineIndex+n>e-a)return l.push(o._model.getLine(0,t)),l.join("");l.push(o._model.getText()),d=o.end,a+=n-o._lineCount}var c=r.getLineEnd(e-a,t);return c>d&&l.push(r.getText(d,c)),l.join("")},getLineAtOffset:function(e){for(var t=this._model,i=this._projections,n=0,o=0,r=0;re-n)break;var a=s._model.getCharCount();if(s.start+a>e-n){var l=e-(s.start+n);o+=s._model.getLineAtOffset(l),n+=l;break}o+=s._model.getLineCount()-1-s._lineCount,n+=a-(s.end-s.start)}return t.getLineAtOffset(e-n)+o},getLineCount:function(){for(var e=this._model,t=this._projections,i=e.getLineCount(),n=0;ne)return-1;for(var i=this._model,n=this._projections,o=0,r=0,s=0;se-o)break;var l=a._model.getLineCount()-1;if(a._lineIndex+l>e-o){var d=e-(a._lineIndex+o);return a._model.getLineEnd(d,t)+a.start+r}r+=a._model.getCharCount()-(a.end-a.start),o+=l-a._lineCount}return i.getLineEnd(e-o,t)+r},getLineStart:function(e){if(0>e)return-1;for(var t=this._model,i=this._projections,n=0,o=0,r=0;r=e-n)break;var a=s._model.getLineCount()-1;if(s._lineIndex+a>=e-n){var l=e-(s._lineIndex+n);return s._model.getLineStart(l)+s.start+o}o+=s._model.getCharCount()-(s.end-s.start),n+=a-s._lineCount}return t.getLineStart(e-n)+o},getText:function(e,t){void 0===e&&(e=0);var i,n,o,r=this._model,s=this._projections,a=0,l=[];for(i=0;ie-a));i++){if(o=n._model.getCharCount(),n.start+o>e-a){if(void 0!==t&&n.start+o>t-a)return n._model.getText(e-(n.start+a),t-(n.start+a));l.push(n._model.getText(e-(n.start+a))),e=n.end+a+o-(n.end-n.start)}a+=o-(n.end-n.start)}var d=e-a;if(void 0!==t){for(;it-a));i++){if(l.push(r.getText(d,n.start)),o=n._model.getCharCount(),n.start+o>t-a)return l.push(n._model.getText(0,t-(n.start+a))),l.join("");l.push(n._model.getText()),d=n.end,a+=o-(n.end-n.start)}l.push(r.getText(d,t-a))}else{for(;in));e++);var s=e;for(e=0;e=o));e++);var a=e,l=this._model,d=i.baseText.length-(o-n);for(e=a;ee));a++){if(l.end>e)return-1;s+=l._model.getCharCount()-(l.end-l.start)}return e+s}var i=!!this._change,n=this._change||{},o=e.start,r=o+e.removedCharCount;if(n.baseStart=o,n.baseEnd=r,n.baseText=e.text,n.addedLineCount=e.addedLineCount,!i){this._change=n,n.text=e.text;var s,a,l,d=this._projections;n.start=t(o),-1===n.start&&(n.text=this._model.getText(l.start,o)+n.text,n.addedLineCount+=this._model.getLineAtOffset(o)-this._model.getLineAtOffset(l.start),n.start=l.start+s),n.end=t(r),-1===n.end&&(n.text+=this._model.getText(r,l.end),n.addedLineCount+=this._model.getLineAtOffset(l.end)-this._model.getLineAtOffset(r),n.end=l.start+s)}n.addedCharCount=n.text.length,n.removedCharCount=n.end-n.start,n.removedLineCount=this.getLineAtOffset(n.end)-this.getLineAtOffset(n.start);var h={type:"Changing",text:n.text,start:n.start,removedCharCount:n.removedCharCount,addedCharCount:n.addedCharCount,removedLineCount:n.removedLineCount,addedLineCount:n.addedLineCount};this.onChanging(h)},onChanging:function(e){return this.dispatchEvent(e)},onChanged:function(e){return this.dispatchEvent(e)},setLineDelimiter:function(e){this._model.setLineDelimiter(e)},setText:function(e,t,i){function n(e){for(r=0,o=0;re-o));r++){var t=s._model.getCharCount();if(s.start+t>e-o)return-1;o+=t-(s.end-s.start)}return e-o}this._change={text:e||"",start:t||0,end:void 0===i?this.getCharCount():i};var o,r,s,a,l,d=this._projections,h=n(this._change.start);-1===h&&(a={projection:s,start:this._change.start-(s.start+o)},h=s.end);var c=n(this._change.end);-1===c&&(l={projection:s,end:this._change.end-(s.start+o)},c=s.start),a&&l&&a.projection===l.projection?s._model.setText(this._change.text,a.start,l.end):(this._model.setText(this._change.text,h,c),a&&(s=a.projection,s._model.setText("",a.start)),l&&(s=l.projection,s._model.setText("",0,l.end),s.start=s.end,s._lineCount=0)),this._change=void 0}},t.EventTarget.addMixin(i.prototype),{ProjectionTextModel:i}}),define("orion/editor/tooltip",["i18n!orion/editor/nls/messages","orion/editor/textView","orion/editor/projectionTextModel","orion/Deferred","orion/editor/util","orion/webui/littlelib","orion/util"],function(e,t,i,n,o,r,s){function a(e,t){this._view=e,this._editor=t;var i=e.getOptions("parent");this._create(i?i.ownerDocument:document)}return a.getTooltip=function(e,t){return e._tooltip||(e._tooltip=new a(e,t)),e._tooltip},a.prototype={_create:function(e){if(!this._tooltipDiv){var t=this._tooltipDiv=s.createElement(e,"div");t.tabIndex=0,t.className="textviewTooltip",t.setAttribute("aria-live","assertive"),t.setAttribute("aria-atomic","true"),this._tooltipDiv.style.visibility="hidden",this._tipShowing=!1,e.body.appendChild(t);var i=this;o.addEventListener(e,"mousedown",this._mouseDownHandler=function(e){i.isVisible()&&(o.contains(t,e.target||e.srcElement)||i._locked||i.hide())},!0),o.addEventListener(e,"scroll",this._scrollHandler=function(e){i.isVisible()&&(o.contains(t,e.target||e.srcElement)||(i._topPixel!==i._view.getTopPixel()||i._leftPixel!==i._view.getHorizontalPixel())&&i.hide())},!0),o.addEventListener(e,"mousemove",this._mouseMoveHandler=function(e){i._prevX&&i._prevX===e.clientX&&i._prevY&&i._prevY===e.clientY||(i._prevX=e.clientX,i._prevY=e.clientY,!i.isVisible()||i._locked||i._hasFocus()||i._isInRect(i._outerArea,e.clientX,e.clientY)||i.hide())},!0),o.addEventListener(t,"focus",function(){i._locked||i._tooltipDiv.classList.add("textViewTooltipOnFocus")},!1),o.addEventListener(t,"blur",function(){i._tooltipDiv.classList.remove("textViewTooltipOnFocus")},!1),o.addEventListener(t,"mouseenter",function(){i._locked||i._tooltipDiv.classList.add("textViewTooltipOnHover")},!1),o.addEventListener(t,"mouseleave",function(){i._hasFocus()||i._tooltipDiv.classList.remove("textViewTooltipOnHover")},!1),o.addEventListener(t,"keydown",function(e){27===e.keyCode&&(i._locked||i.hide())},!1),this._view.addEventListener("Destroy",function(){i.destroy()})}},destroy:function(){if(this._tooltipDiv){this.hide();var e=this._tooltipDiv.parentNode;e&&e.removeChild(this._tooltipDiv);var t=this._tooltipDiv.ownerDocument;o.removeEventListener(t,"mousedown",this._mouseDownHandler,!0),o.removeEventListener(t,"scroll",this._scrollHandler,!0),o.removeEventListener(t,"mousemove",this._mouseMoveHandler,!0),this._tooltipDiv=null}},show:function(e,t,i){this._locked=t,this._giveFocus=i,this._topPixel=this._view.getTopPixel(),this._leftPixel=this._view.getHorizontalPixel(),this._processInfo(e.getTooltipInfo())},update:function(e,t){e&&(t?this._showContents(null,e.getTooltipInfo(),!0):this._processInfo(e.getTooltipInfo(),!0))},onHover:function(e,t,i){e&&(this._isInRect(this._anchorArea,t,i)||this._isInRect(this._tooltipArea,t,i)||this._locked||this._hasFocus()||this._processInfo(e.getTooltipInfo()))},hide:function(e){e&&(this._locked=void 0),!this._locked&&this.isVisible()&&(this.hover&&this.hover.clearQuickFixes(),this._hasFocus()&&this._view.focus(),this._tooltipContents&&(this._tooltipDiv.removeChild(this._tooltipContents),this._tooltipContents=null),this._tooltipDiv.classList.remove("textviewTooltipCodeProjection"),this._tooltipDiv.classList.remove("textviewTooltipOnHover"),this._tooltipDiv.classList.remove("textviewTooltipOnFocus"),this._tooltipDiv.style.visibility="hidden",this._tipShowing=!1,this._tooltipDiv.style.left="",this._tooltipDiv.style.right="",this._tooltipDiv.style.top="",this._tooltipDiv.style.bottom="",this._tooltipDiv.style.width="auto",this._tooltipDiv.style.maxWidth="",this._tooltipDiv.style.height="auto",this._tooltipDiv.style.maxHeight="",this._tooltipDiv.style.overflowX="",this._tooltipDiv.style.overflowY="",this._giveFocus=void 0,this._anchorArea=void 0,this._tooltipArea=void 0,this._outerArea=void 0,this._hoverPromises&&this._hoverPromises.forEach(function(e){e.resolved||e.cancel()}),this._hoverPromises=void 0,this._tipRect=void 0)},isVisible:function(){return this._tipShowing},_processInfo:function(e,t){if(this._tooltipDiv){var i;if(t&&this._tooltipContents?(this._tooltipContents.innerHTML="",i=this._tooltipContents):i=s.createElement(this._tooltipDiv.ownerDocument,"div"),e){if(e.contents&&this._renderImmediateInfo(i,e.contents,e.context))return this._showContents(i,e,t),!0;if(this.hover&&e.context&&(this._hoverPromises=this.hover.computeHoverInfo(e.context),this._hoverPromises)){var o=this,r=this._hoverPromises.slice(0);return r.forEach(function(r){n.when(r,function(n){if(o._hoverPromises){var s=o._hoverPromises.indexOf(r);s>=0&&o._hoverPromises.splice(s,1)}n&&o._renderPluginContent(i,n)&&(n.offsetStart&&(e.context.offsetStart=n.offsetStart),n.offsetEnd&&(e.context.offsetEnd=n.offsetEnd),n.allowFullWidth&&(e.allowFullWidth=n.allowFullWidth),o._showContents(i,e,t))},function(e){console&&e&&"Cancel"!==e.name&&(console.log("Error computing hover tooltip"),console.log(e&&e.stack))})}),!0}}}},_showContents:function(e,t,i){i?this._tooltipArea&&t.tooltipArea&&(this._tooltipArea.left!==t.tooltipArea.left||this._tooltipArea.top!==t.tooltipArea.top||this._tooltipArea.width!==t.tooltipArea.width||this._tooltipArea.height!==t.tooltipArea.height)&&(this._anchorArea=null,this._tooltipArea=null,this._outerArea=null):this.hide(),e&&(this._tooltipContents&&this._tooltipDiv.removeChild(this._tooltipContents),this._tooltipContents=e,this._tooltipDiv.appendChild(e)),this._anchorArea||(this._anchorArea=this._computeAnchorArea(t)),this._tooltipArea||(this._tooltipArea=this._computeTooltipArea(t,this._anchorArea,this._tooltipDiv)),this._outerArea||(this._outerArea=this._computeOuterArea(this._anchorArea,this._tooltipArea)),this._tooltipDiv.style.visibility="visible",this._tipShowing=!0,this._giveFocus&&(this._setInitialFocus(this._tooltipDiv),this._giveFocus=void 0)},_computeAnchorArea:function(e){if(e.anchorArea&&e.anchorArea.top&&e.anchorArea.left&&e.anchorArea.height&&e.anchorArea.width)return e.anchorArea;if(e.context){if(e.context.offsetStart&&e.context.offsetEnd){var t=this.mapOffset(e.context.offsetStart,!1),i=this.mapOffset(e.context.offsetEnd,!1);return this._computeRectangleFromOffset(t,i)}if(e.context.offset>=0){var n=this.mapOffset(e.context.offset,!1),o=this._view.getNextOffset(n,{unit:"wordend",count:0}),r=this._view.getNextOffset(o,{unit:"word",count:-1});return this._computeRectangleFromOffset(r,o)}}return{top:0,left:0,height:0,width:0}},_computeTooltipArea:function(e,t,i){var n=i.ownerDocument.documentElement,o=16;if(e.tooltipArea&&e.tooltipArea.top&&e.tooltipArea.left&&e.tooltipArea.height&&e.tooltipArea.width)return i.style.overflowY="auto",i.style.resize="none",i.style.top=e.tooltipArea.top+"px",i.style.left=e.tooltipArea.left+"px",i.style.height=e.tooltipArea.height-o+"px",i.style.width=e.tooltipArea.width-o+"px",e.tooltipArea;var r=i.getBoundingClientRect(),s={width:r.width,height:r.height},a=i.getElementsByTagName("img")[0];a&&!a.complete&&0===a.width&&(s.width+=30);var l=e.position?e.position:"below",d=(this._view._rootDiv?this._view._rootDiv:n).getBoundingClientRect(),h=d.left,c=d.top,u=d.width,p=d.height,f=u,g=p;e.allowFullWidth?s.width>u&&(s.width=u):(f=Math.min(u/2,600),g=Math.min(p/2,400),s.width=Math.min(s.width,f),s.height=Math.min(s.height,g)),i.style.width=s.width-o+"px",s.height=Math.min(i.getBoundingClientRect().height,g),25+o>s.height&&s.width>f-o&&(s.height=40+o);var _=p-(t.top+t.height-c),m=t.top-c,v=u-(t.left+t.width-h);"above"===l&&s.height>m&&s.height<=_?l="below":"below"===l&&s.height>_&&s.height<=m&&(l="above");var y=e.tooltipOffsetX?e.tooltipOffsetX:0,x=e.tooltipOffsetY?e.tooltipOffsetY:0;switch(l){case"left":s.top=s.height+x>_+t.height?p+c-s.height:t.top+x,s.top=Math.max(s.top,c),s.left=Math.max(t.left-s.width+y,h);break;case"right":s.top=s.height+x>_+t.height?p+c-s.height:t.top+x,s.top=Math.max(s.top,c),s.left=Math.max(t.left+t.width+y,h);break;case"above":s.left=s.width+y>v+t.width?u+h-s.width:t.left+y,s.left=Math.max(s.left,h),s.top=Math.max(t.top-s.height+x,c);break;case"below":s.left=s.width+y>v+t.width?u+h-s.width:t.left+y,s.left=Math.max(s.left,h),s.top=Math.max(t.top+t.height+x,c)}return s.maxWidth=Math.min(u+h-s.left,u),s.maxHeight=Math.min(p+c-s.top,p),i.style.maxWidth=s.maxWidth-o+"px",i.style.maxHeight=s.maxHeight-o+"px",i.style.width=s.width-o+"px",i.style.height=s.height-o+"px",i.style.left=s.left+"px",i.style.top=s.top+"px",s},_computeOuterArea:function(e,t){var i=Math.min(e.left,t.left),n=Math.min(e.top,t.top),o=e.left+e.width,r=t.left+t.width,s=Math.max(o,r),a=e.top+e.height,l=t.top+t.height,d=Math.max(a,l);return{left:i,top:n,width:s-i,height:d-n}},_hasFocus:function(){var e=this._tooltipDiv;return e?o.contains(e,e.ownerDocument.activeElement):!1},_isNode:function(e){return"object"==typeof Node?e instanceof Node:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},_setInitialFocus:function(e){var t=r.$("button",e);if(t)return void t.focus();var i=r.$("a",e);if(i){i.focus();var n=this;return void i.addEventListener("click",function(){n.hide()})}var o=r.firstTabbable(e);o&&o.focus()},_isInRect:function(e,t,i){if(!e)return!1;var n=t>=e.left&&t<=e.left+e.width,o=i>=e.top&&i<=e.top+e.height;return n&&o},mapOffset:function(e){var t=this._view,i=t.getModel();return i.getBaseModel&&(e=i.mapOffset(e,!0)),e},_computeRectangleFromOffset:function(e,t){var i=this._view,n=i.getLineAtOffset(e),o=i.getLineAtOffset(t);n!==o&&(t=i.getModel().getLineEnd(n));var r=i.getLineHeight(n),s=i.getLocationAtOffset(e),a=i.getLocationAtOffset(t),l={x:s.x,y:s.y,width:a.x-s.x,height:r};return l=this._view.convert(l,"document","page"),{left:l.x,top:l.y,width:l.width,height:l.height}},_renderPluginContent:function(e,t){var i=this._tooltipDiv.ownerDocument;if("string"!=typeof t&&"undefined"==typeof t.content)return!1;var n=s.createElement(i,"div");if(t.title){var o=s.createElement(i,"div");this.hover.renderMarkDown?o.innerHTML=this.hover.renderMarkDown(t.title):o.textContent=t.title,o.classList.add("hoverTooltipTitle"),n.appendChild(o)}var r=s.createElement(i,"div");if("string"==typeof t)r.appendChild(i.createTextNode(t));else switch(t.type){case"delegatedUI":case"html":if(t.content){var a=i.createElement("iframe");a.id="HtmlHover",a.name="HTML Hover",a.type="text/html",a.sandbox="allow-scripts allow-same-origin allow-forms",a.style.border="none",a.style.width="100%",a.style.height="100%",this._tooltipDiv.style.paddingBottom="5px",a.srcdoc=t.content,t.width&&(a.style.width=t.width),t.height&&(a.style.height=t.height),n.style.height="100%",e.style.height="100%",n.appendChild(a)}break;case"markdown":this.hover.renderMarkDown&&(r.innerHTML=this.hover.renderMarkDown(t.content));break;default:r.appendChild(i.createTextNode(t.content))}return n.appendChild(r),e.appendChild(n),!0},_renderImmediateInfo:function(e,n,o){if(n instanceof Array&&(n=this._getAnnotationContents(n,o),!n))return!1;if("string"==typeof n)return e.textContent=n,!0;if(this._isNode(n))return e.appendChild(n),!0;if(n instanceof i.ProjectionTextModel){var r=this._view,s=r.getOptions();s.wrapMode=!1,s.parent=e;var a="tooltipTheme",l=s.themeClass;l?(l=l.replace(a,""),l&&(l=" "+l),l=a+l):l=a,s.themeClass=l;var d=this._contentsView=new t.TextView(s),h={onLineStyle:function(e){r.onLineStyle(e)}};d.addEventListener("LineStyle",h.onLineStyle),d.setModel(n),this._tooltipDiv.appendChild(e),this._tooltipDiv.classList.add("textviewTooltipCodeProjection");var c=d.computeSize();return e.style.width=c.width+8+"px",e.style.height=c.height+8+"px",d.resize(),this._tooltipDiv.removeChild(e),!0}return!1},_getAnnotationContents:function(t,n){function r(e,t,i){var r=e.title,l=s.createElement(p,"div");if(l.className="tooltipRow",e.html){var d=s.createElement(p,"div");d.className="tooltipImage",d.innerHTML=e.html,d.lastChild&&o.addEventListener(d.lastChild,"click",function(){var t=e.start,i=e.end;g.getBaseModel&&(t=g.mapOffset(t,!0),i=g.mapOffset(i,!0)),f.setSelection(t,i,1/3,function(){a.hide()})},!1),l.appendChild(d)}if(!r){var h=_.getLineStart(_.getLineAtOffset(e.start)),c=_.getLineEnd(_.getLineAtOffset(e.end),!0);r=_.getText(h,c)}if("function"==typeof r&&(r=e.title()),"string"==typeof r){var u=s.createElement(p,"span");u.className="tooltipTitle",u.appendChild(p.createTextNode(r)),r=u}return l.appendChild(r),i&&a.hover.renderQuickFixes(e,t,l),n&&(n.offsetStart=e.start,n.offsetEnd=e.end),l}var a=this,l=a.hover?!0:!1;l&&n&&n.source&&n.source.indexOf("ruler")>=0&&t.length>1&&(l=!1);for(var d,h=[],c=0;c0&&m.addProjection({start:0,end:v}),m}var x;if(t.length>0&&this._editor&&(x=this._editor.getAnnotationModel().getAnnotations()),1===t.length){if(u=r(t[0],x,l),u&&u.firstChild){var b=u.firstChild.className;b&&(b+=" "),b+="single",u.firstChild.className=b}return u}var C=s.createElement(p,"div"),w=s.createElement(p,"multi_anno");w.appendChild(p.createTextNode(e.multipleAnnotations)),C.appendChild(w);for(var T=0;Ti;i++){var o=arguments[i];for(var r in o)t.call(o,r)&&(e[r]=o[r])}return e}return{clone:function(t){if(Array.isArray(t))return Array.prototype.slice.call(t);var i=Object.create(Object.getPrototypeOf(t));return e(i,t),i},mixin:e,toArray:function(e){return Array.isArray(e)?e:[e]}}}),define("orion/editor/editor",["i18n!orion/editor/nls/messages","orion/editor/eventTarget","orion/editor/tooltip","orion/editor/annotations","orion/objects","orion/util"],function(e,t,i,n,o,r){function s(e){e=e||{},this._domNode=e.domNode,this._model=e.model,this._undoStack=e.undoStack,this._statusReporter=e.statusReporter,this._title=null;var t=this;this._listener={onChanged:function(e){t.onChanged(e)}},this._model&&this._model.addEventListener("Changed",this._listener.onChanged),this.checkDirty()}function a(e){e=e||{},s.call(this,e),this._textViewFactory=e.textViewFactory,this._undoStackFactory=e.undoStackFactory,this._textDNDFactory=e.textDNDFactory,this._annotationFactory=e.annotationFactory,this._zoomRulerFactory=e.zoomRulerFactory,this._foldingRulerFactory=e.foldingRulerFactory,this._lineNumberRulerFactory=e.lineNumberRulerFactory,this._contentAssistFactory=e.contentAssistFactory,this._keyBindingFactory=e.keyBindingFactory,this._hoverFactory=e.hoverFactory,this._syntaxHighlighter=e.syntaxHighlighter,this._annotationStyler=null,this._annotationModel=null,this._annotationRuler=null,this._lineNumberRuler=null,this._overviewRuler=null,this._zoomRuler=null,this._foldingRuler=null,this._contentAssist=null}var l=n.AnnotationType,d="orion.annotation.highlightError";return s.prototype={destroy:function(){this.uninstall(),this._statusReporter=this._domNode=null,this._model&&this._model.removeEventListener("Changed",this._listener.onChanged)},checkDirty:function(){this.setDirty(this._undoStack&&!this._undoStack.isClean())},focus:function(){},getModel:function(){return this._model},getText:function(e,t){return this.getModel().getText(e,t)},getTitle:function(){return this._title},getUndoStack:function(){return this._undoStack},install:function(){this.installed=!0},isDirty:function(){return this._undoStack?!this._undoStack.isClean():this._dirty},markClean:function(){this.getUndoStack().markClean(),this.setDirty(!1)},onDirtyChanged:function(e){return this.dispatchEvent(e)},onInputChanged:function(e){return this.dispatchEvent(e)},onChanged:function(){this.checkDirty()},reportStatus:function(e,t,i){this._statusReporter&&this._statusReporter(e,t,i)},resize:function(){},setDirty:function(e){this._dirty!==e&&(this._dirty=e,this.onDirtyChanged({type:"DirtyChanged"}))},_setModelText:function(e){this._model&&this._model.setText(e)},setInput:function(e,t,i,n){this._title=e,n||(t?this.reportStatus(t,"error"):null!==i&&void 0!==i&&("string"==typeof i&&this._setModelText(i),this._undoStack&&this._undoStack.reset())),this.checkDirty(),this.onInputChanged({type:"InputChanged",title:e,message:t,contents:i,contentsSaved:n})},setText:function(e,t,i){this.getModel().setText(e,t,i)},uninstall:function(){this.installed=!1}},t.EventTarget.addMixin(s.prototype),a.prototype=new s,o.mixin(a.prototype,{destroy:function(){s.prototype.destroy.call(this),this._textViewFactory=this._undoStackFactory=this._textDNDFactory=this._annotationFactory=this._foldingRulerFactory=this._lineNumberRulerFactory=this._contentAssistFactory=this._keyBindingFactory=this._hoverFactory=this._zoomRulerFactory=null},getAnnotationModel:function(){return this._annotationModel},getAnnotationRuler:function(){return this._annotationRuler},getAnnotationStyler:function(){return this._annotationStyler},getContentAssist:function(){return this._contentAssist},getFoldingRuler:function(){return this._foldingRuler},getLineNumberRuler:function(){return this._lineNumberRuler},getTooltip:function(){return i.Tooltip.getTooltip(this._textView,this)},getZoomRuler:function(){return this._zoomRuler},getModel:function(){if(!this._textView)return null;var e=this._textView.getModel();return e.getBaseModel&&(e=e.getBaseModel()),e},getOverviewRuler:function(){return this._overviewRuler},getTextView:function(){return this._textView},getKeyModes:function(){return this._textView.getKeyModes()},getSourceCodeActions:function(){return this._sourceCodeActions},getLinkedMode:function(){return this._linkedMode},getTextActions:function(){return this._textActions},focus:function(){this._textView&&this._textView.focus()},resize:function(){this._textView&&this._textView.resize()},setAnnotationRulerVisible:function(e,t){if((this._annotationRulerVisible!==e||t)&&(this._annotationRulerVisible=e,this._annotationRuler)){var i=this._textView;e?i.addRuler(this._annotationRuler,0):i.removeRuler(this._annotationRuler)}},setFoldingRulerVisible:function(e,t){if((this._foldingRulerVisible!==e||t)&&(this._foldingRulerVisible=e,this._foldingRuler)){var i=this._textView;i.getModel().getBaseModel&&(e?i.addRuler(this._foldingRuler):i.removeRuler(this._foldingRuler))}},setLineNumberRulerVisible:function(e,t){if((this._lineNumberRulerVisible!==e||t)&&(this._lineNumberRulerVisible=e,this._lineNumberRuler)){var i=this._textView;e?i.addRuler(this._lineNumberRuler,this._annotationRulerVisible?1:0):i.removeRuler(this._lineNumberRuler)}},setOverviewRulerVisible:function(e,t){if((this._overviewRulerVisible!==e||t)&&(this._overviewRulerVisible=e,this._overviewRuler)){var i=this._textView;e?i.addRuler(this._overviewRuler):i.removeRuler(this._overviewRuler)}},setZoomRulerVisible:function(e,t){if((this._zoomRulerVisible!==e||t)&&(this._zoomRulerVisible=e,this._zoomRuler)){var i=this._textView;e?i.addRuler(this._zoomRuler):i.removeRuler(this._zoomRuler)}},mapOffset:function(e,t){var i=this._textView,n=i.getModel();return n.getBaseModel&&(e=n.mapOffset(e,t)),e},getLineAtOffset:function(e){return this.getModel().getLineAtOffset(this.mapOffset(e))},getLineStart:function(e){return this.getModel().getLineStart(e)},getCaretOffset:function(){return this.mapOffset(this._textView.getCaretOffset())},getSelectionText:function(e){var t=this._textView;return t.getSelectionText(e)},getSelection:function(){var e=this._textView,t=e.getSelection(),i=e.getModel();return i.getBaseModel&&(t.start=i.mapOffset(t.start),t.end=i.mapOffset(t.end)),t},getSelections:function(){var e=this._textView,t=e.getModel(),i=e.getSelections();return i.forEach(function(e){t.getBaseModel&&(e.start=t.mapOffset(e.start),e.end=t.mapOffset(e.end))}),i},getStyleAccessor:function(){var e=null;if(this._syntaxHighlighter){var t=this._syntaxHighlighter.getStyler();t&&t.getStyleAccessor&&(e=t.getStyleAccessor())}return e},_expandOffset:function(e){var t=this._textView.getModel(),i=this._annotationModel;if(i&&t.getBaseModel)for(var n=i.getAnnotations(e,e+1);n.hasNext();){var o=n.next();o.type===l.ANNOTATION_FOLDING&&o.expand&&o.expand()}},setCaretOffset:function(e,t,i){var n=this._textView,o=n.getModel();o.getBaseModel&&(this._expandOffset(e),e=o.mapOffset(e,!0)),n.setCaretOffset(e,t,i)},setText:function(e,t,i,n,o){var r=this._textView,s=r.getModel();s.getBaseModel&&(void 0!==t&&(this._expandOffset(t),t=s.mapOffset(t,!0)),void 0!==i&&(this._expandOffset(i),i=s.mapOffset(i,!0))),r.setText(e,t,i,n,o)},setSelection:function(e,t,i,n){var o=this._textView,r=o.getModel();r.getBaseModel&&(this._expandOffset(e),this._expandOffset(t),e=r.mapOffset(e,!0),t=r.mapOffset(t,!0)),o.setSelection(e,t,i,n)},setSelections:function(e,t,i){var n=this,o=this._textView,r=o.getModel();e.forEach(function(e){var t=e.start,i=e.end;r.getBaseModel&&(n._expandOffset(t),n._expandOffset(i),t=r.mapOffset(t,!0),i=r.mapOffset(i,!0)),e.start=t,e.end=i}),o.setSelections(e,t,i)},moveSelection:function(e,t,i,n){t=t||e;var o=this._textView;this.setSelection(e,t,1/3,function(){(void 0===n||n)&&o.focus(),i&&i()})},_getTooltipInfo:function(e,t){var i=this._textView,n=this.getAnnotationModel();if(!n)return null;var o=this._annotationStyler;if(!o)return null;if(!i.isValidTextPosition(e,t))return null;var r=i.getOffsetAtLocation(e,t);if(-1===r)return null;r=this.mapOffset(r);for(var s=o.getAnnotationsByType(n,r,r+1),a=[],l=0;l>0,f=s.getLineStart(p),g=s.getLineEnd(p);s.getBaseModel&&(f=s.mapOffset(f),g=s.mapOffset(g));var _=l.ANNOTATION_CURRENT_LINE,m=l.createAnnotation(_,f,g);c.push(m)}this._currentLineAnnotations=c,o.replaceAnnotations(h,c)}}}},installTextView:function(){this.install()},install:function(){if(!this._textView){if(this._textView=this._textViewFactory(),this._undoStackFactory&&(this._undoStack=this._undoStackFactory.createUndoStack(this),this._textView.setOptions({undoStack:this._undoStack}),this.checkDirty()),this._textDNDFactory&&(this._textDND=this._textDNDFactory.createTextDND(this,this._undoStack)),this._contentAssistFactory){var e=this._contentAssistFactory.createContentAssistMode(this);this._contentAssist=e.getContentAssist()}var t=i.Tooltip.getTooltip(this._textView,this);this._hoverFactory&&(this._hover=this._hoverFactory.createHover(this),t.hover=this._hover);var n=this,o=this._textView,r=this;if(this._listener={onModelChanged:function(){r.checkDirty()},onMouseOver:function(e){r._listener.onMouseMove(e)},onMouseDown:function(){r._listener.mouseDown=!0},onMouseUp:function(){r._listener.mouseDown=!1},onMouseMove:function(e){t&&!r._listener.mouseDown&&(e.event.clientX!==r._listener.lastMouseX||e.event.clientY!==r._listener.lastMouseY)&&(r._listener.lastMouseX=e.event.clientX,r._listener.lastMouseY=e.event.clientY,r._hoverTimeout&&(window.clearTimeout(r._hoverTimeout),r._hoverTimeout=null),r._hoverTimeout=window.setTimeout(function(){r._hoverTimeout=null,r._listener&&t.onHover({y:e.y,x:e.x,getTooltipInfo:function(){return r._getTooltipInfo(this.x,this.y)}},e.x,e.y)},175))},onMouseOut:function(){r._hoverTimeout&&(window.clearTimeout(r._hoverTimeout),r._hoverTimeout=null)},onSelection:function(e){t&&t.hide(),r._updateCursorStatus(),r._highlightCurrentLine(e.newValue,e.oldValue)}},o.addEventListener("ModelChanged",this._listener.onModelChanged),o.addEventListener("Selection",this._listener.onSelection),o.addEventListener("MouseOver",this._listener.onMouseOver),o.addEventListener("MouseOut",this._listener.onMouseOut),o.addEventListener("MouseDown",this._listener.onMouseDown),o.addEventListener("MouseUp",this._listener.onMouseUp),o.addEventListener("MouseMove",this._listener.onMouseMove),this._keyBindingFactory){var a;a="function"==typeof this._keyBindingFactory?this._keyBindingFactory(this,this.getKeyModes(),this._undoStack,this._contentAssist):this._keyBindingFactory.createKeyBindings(n,this._undoStack,this._contentAssist),a&&(this._textActions=a.textActions,this._linkedMode=a.linkedMode,this._sourceCodeActions=a.sourceCodeActions)}var h=function(e){if(void 0!==e&&-1!==e){for(var t=this.getView(),i=t.getModel(),o=this.getAnnotationModel(),r=n.mapOffset(i.getLineStart(e)),s=n.mapOffset(i.getLineEnd(e)),a=o.getAnnotations(r,s),d=null;a.hasNext();){var h=a.next();if(h.type===l.ANNOTATION_BOOKMARK){d=h;break}}d?o.removeAnnotation(d):(d=l.createAnnotation(l.ANNOTATION_BOOKMARK,r,s,n.getText(r,s)),o.addAnnotation(d))}};if(this._annotationFactory){var c=o.getModel();if(c.getBaseModel&&(c=c.getBaseModel()),this._annotationModel=this._annotationFactory.createAnnotationModel(c),this._annotationModel){var u=this._annotationStyler=this._annotationFactory.createAnnotationStyler(o,this._annotationModel);u&&(u.addAnnotationType(l.ANNOTATION_CURRENT_SEARCH),u.addAnnotationType(l.ANNOTATION_MATCHING_SEARCH),u.addAnnotationType(l.ANNOTATION_ERROR),u.addAnnotationType(l.ANNOTATION_WARNING),u.addAnnotationType(l.ANNOTATION_MATCHING_BRACKET),u.addAnnotationType(l.ANNOTATION_CURRENT_BRACKET),u.addAnnotationType(l.ANNOTATION_CURRENT_LINE),u.addAnnotationType(l.ANNOTATION_READ_OCCURRENCE),u.addAnnotationType(l.ANNOTATION_WRITE_OCCURRENCE),u.addAnnotationType(l.ANNOTATION_SELECTED_LINKED_GROUP),u.addAnnotationType(l.ANNOTATION_CURRENT_LINKED_GROUP),u.addAnnotationType(l.ANNOTATION_LINKED_GROUP),u.addAnnotationType(d))}var p=this._annotationFactory.createAnnotationRulers(this._annotationModel),f=this._annotationRuler=p.annotationRuler;f&&(f.onDblClick=h,f.setMultiAnnotationOverlay({html:"
"}),f.addAnnotationType(l.ANNOTATION_ERROR),f.addAnnotationType(l.ANNOTATION_WARNING),f.addAnnotationType(l.ANNOTATION_TASK),f.addAnnotationType(l.ANNOTATION_BOOKMARK),f.addAnnotationType(l.ANNOTATION_DIFF_ADDED),f.addAnnotationType(l.ANNOTATION_DIFF_DELETED),f.addAnnotationType(l.ANNOTATION_DIFF_MODIFIED)),this.setAnnotationRulerVisible(this._annotationRulerVisible||void 0===this._annotationRulerVisible,!0),f=this._overviewRuler=p.overviewRuler,f&&(f.addAnnotationType(l.ANNOTATION_CURRENT_SEARCH),f.addAnnotationType(l.ANNOTATION_MATCHING_SEARCH),f.addAnnotationType(l.ANNOTATION_READ_OCCURRENCE),f.addAnnotationType(l.ANNOTATION_WRITE_OCCURRENCE),f.addAnnotationType(l.ANNOTATION_CURRENT_BLAME),f.addAnnotationType(l.ANNOTATION_ERROR),f.addAnnotationType(l.ANNOTATION_WARNING),f.addAnnotationType(l.ANNOTATION_TASK),f.addAnnotationType(l.ANNOTATION_BOOKMARK),f.addAnnotationType(l.ANNOTATION_MATCHING_BRACKET),f.addAnnotationType(l.ANNOTATION_CURRENT_BRACKET),f.addAnnotationType(l.ANNOTATION_CURRENT_LINE),f.addAnnotationType(l.ANNOTATION_DIFF_ADDED),f.addAnnotationType(l.ANNOTATION_DIFF_DELETED),f.addAnnotationType(l.ANNOTATION_DIFF_MODIFIED)),this.setOverviewRulerVisible(this._overviewRulerVisible||void 0===this._overviewRulerVisible,!0)}this._zoomRulerFactory&&(this._zoomRuler=this._zoomRulerFactory.createZoomRuler(this._annotationModel),this.setZoomRulerVisible(this._zoomRulerVisible,!0)),this._lineNumberRulerFactory&&(this._lineNumberRuler=this._lineNumberRulerFactory.createLineNumberRuler(this._annotationModel),this._lineNumberRuler.addAnnotationType(l.ANNOTATION_CURRENT_BLAME),this._lineNumberRuler.addAnnotationType(l.ANNOTATION_BLAME),this._lineNumberRuler.addAnnotationType(l.ANNOTATION_DIFF_ADDED),this._lineNumberRuler.addAnnotationType(l.ANNOTATION_DIFF_MODIFIED),this._lineNumberRuler.addAnnotationType(l.ANNOTATION_DIFF_DELETED),this._lineNumberRuler.onDblClick=h,this.setLineNumberRulerVisible(this._lineNumberRulerVisible||void 0===this._lineNumberRulerVisible,!0)),this._foldingRulerFactory&&(this._foldingRuler=this._foldingRulerFactory.createFoldingRuler(this._annotationModel),this._foldingRuler.addAnnotationType(l.ANNOTATION_FOLDING),this.setFoldingRulerVisible(this._foldingRulerVisible||void 0===this._foldingRulerVisible,!0));var g={type:"TextViewInstalled",textView:o};this.dispatchEvent(g),s.prototype.install.call(this)}},uninstallTextView:function(){this.uninstall()},uninstall:function(){var e=this._textView;if(e){e.destroy(),this._annotationModel&&this._annotationModel.setTextModel(null),this._textView=this._undoStack=this._textDND=this._contentAssist=this._listener=this._annotationModel=this._annotationStyler=this._annotationRuler=this._overviewRuler=this._zoomRuler=this._lineNumberRuler=this._foldingRuler=this._currentLineAnnotations=this._title=null,this._dirty=!1,this._foldingRulerVisible=this._overviewRulerVisible=this._zoomRulerVisible=this._lineNumberRulerVisible=this._annotationRulerVisible=void 0;var t={type:"TextViewUninstalled",textView:e};this.dispatchEvent(t),s.prototype.uninstall.call(this)}},_updateCursorStatus:function(){for(var t=this.getKeyModes(),i=0;i1)o=r.formatMessage(e.multiSelections,a.length);else{var l=a[0].getCaret(),d=s.getLineAtOffset(l),h=s.getLineStart(d),c=l-h;o=localStorage.languageTools?r.formatMessage(e.lineColumnOffset,d+1,c+1,l):r.formatMessage(e.lineColumn,d+1,c+1)}this.reportStatus(o)},showAnnotations:function(e,t,i,n){var o=this._annotationModel;if(o){for(var r,s=[],a=[],d=o.getTextModel(),h=o.getAnnotations();h.hasNext();)r=h.next(),-1!==t.indexOf(r.type)&&r.creatorID===this&&s.push(r); -if(e)for(var c=0;c',s.blame=e,s})},showDiffAnnotations:function(e){this.showAnnotations(e,[l.ANNOTATION_DIFF_ADDED,l.ANNOTATION_DIFF_MODIFIED,l.ANNOTATION_DIFF_DELETED],null,function(e){return"added"===e.type?l.ANNOTATION_DIFF_ADDED:"modified"===e.type?l.ANNOTATION_DIFF_MODIFIED:l.ANNOTATION_DIFF_DELETED})},showSelection:function(e,t,i,n,o){if("number"==typeof e)return"number"!=typeof t&&(t=e),this.moveSelection(e,t),!0;if("number"==typeof i){var r=this.getModel(),s=r.getLineStart(i-1);return"number"==typeof n&&(s+=n),"number"!=typeof o&&(o=0),this.moveSelection(s,s+o),!0}return!1},_setModelText:function(e){this._textView&&(this._textView.setText(e),this._textView.getModel().setLineDelimiter("auto"),this._highlightCurrentLine(this._textView.getSelections()))},setInput:function(e,t,i,n,o){s.prototype.setInput.call(this,e,t,i,n),!this._textView||n||o||this._textView.focus()},onGotoLine:function(e,t,i,n){if(this._textView){var o=this.getModel();e=Math.max(0,Math.min(e,o.getLineCount()-1));var r=o.getLineStart(e),s=0;if(void 0===i&&(i=0),"string"==typeof t){var a=o.getLine(e).indexOf(t);-1!==a&&(s=a,i=s+t.length)}else{s=t;var l=o.getLineEnd(e)-r;s=Math.min(s,l),i=Math.min(i,l)}this.moveSelection(r+s,r+i,n)}}}),{BaseEditor:s,Editor:a}}),define("orion/editor/find",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/keyModes","orion/editor/annotations","orion/regex","orion/objects","orion/util"],function(e,t,i,n,o,r,s){function a(e){var t=e.getTextView();i.KeyMode.call(this,t),this.editor=e,this._active=!1,this._success=!0,this._ignoreSelection=!1,this._prefix="",t.setAction("incrementalFindCancel",function(){return this.setActive(!1),!0}.bind(this)),t.setAction("incrementalFindBackspace",function(){return this._backspace()}.bind(this));var n=this;this._listener={onVerify:function(e){var t=n.editor,i=t.getModel(),r=t.mapOffset(e.start),s=t.mapOffset(e.end),a=i.getText(r,s),l=n._prefix,d=l.match(new RegExp("^"+o.escape(a),"i"));d&&d.length>0&&(l=n._prefix+=e.text,n._success=!0,n._status(),n.find(n._forward,!0),e.text=null)},onSelection:function(){n._ignoreSelection||n.setActive(!1)}}}function l(e,t,i){if(e){this._editor=e,this._undoStack=t,this._showAll=!0,this._visible=!1,this._caseInsensitive=!0,this._wrap=!0,this._wholeWord=!1,this._incremental=!0,this._regex=!1,this._findAfterReplace=!0,this._hideAfterFind=!1,this._reverse=!1,this._start=void 0,this._end=void 0,this._timer=void 0,this._lastString="";var n=this;this._listeners={onEditorFocus:function(e){n._removeCurrentAnnotation(e)}},this.setOptions(i)}}var d={};return a.prototype=new i.KeyMode,r.mixin(a.prototype,{createKeyBindings:function(){var e=t.KeyBinding,i=[];return i.push({actionID:"incrementalFindBackspace",keyBinding:new e(8)}),i.push({actionID:"incrementalFindCancel",keyBinding:new e(13)}),i.push({actionID:"incrementalFindCancel",keyBinding:new e(27)}),i.push({actionID:"incrementalFindReverse",keyBinding:new e(38)}),i.push({actionID:"incrementalFind",keyBinding:new e(40)}),i.push({actionID:"incrementalFindReverse",keyBinding:new e("k",!0,!0)}),i.push({actionID:"incrementalFind",keyBinding:new e("k",!0)}),i},find:function(e,t){if(this._forward=e,!this.isActive())return this.setActive(!0),!1;var i=this._prefix;if(0===i.length)return!1;var n,o=this.editor,r=o.getModel();n=e?this._success?t?this._start:o.getCaretOffset()+1:0:this._success?t?this._start:o.getCaretOffset():r.getCharCount()-1;var s=o.getModel().find({string:i,start:n,reverse:!e,caseInsensitive:i.toLowerCase()===i}).next();return s?(t||(this._start=n),this._success=!0,this._ignoreSelection=!0,o.moveSelection(e?s.start:s.end,e?s.end:s.start),this._ignoreSelection=!1):this._success=!1,this._status(),!0},isActive:function(){return this._active},isStatusActive:function(){return this.isActive()},setActive:function(e){if(this._active!==e){this._active=e,this._prefix="",this._success=!0;var t=this.editor,i=t.getTextView();this._start=this.editor.getCaretOffset(),this.editor.setCaretOffset(this._start),this._active?(i.addEventListener("Verify",this._listener.onVerify),i.addEventListener("Selection",this._listener.onSelection),i.addKeyMode(this)):(i.removeEventListener("Verify",this._listener.onVerify),i.removeEventListener("Selection",this._listener.onSelection),i.removeKeyMode(this)),this._status()}},_backspace:function(){var e=this._prefix;return e=this._prefix=e.substring(0,e.length-1),0===e.length?(this._success=!0,this._ignoreSelection=!0,this.editor.setCaretOffset(this.editor.getSelection().start),this._ignoreSelection=!1,this._status(),!0):this.find(this._forward,!0)},_status:function(){if(!this.isActive())return void this.editor.reportStatus("");var t;t=this._forward?this._success?e.incrementalFindStr:e.incrementalFindStrNotFound:this._success?e.incrementalFindReverseStr:e.incrementalFindReverseStrNotFound,t=s.formatMessage(t,this._prefix),this.editor.reportStatus(t,this._success?"":"error")}}),d.IncrementalFind=a,l.prototype={find:function(e,t,i){this.setOptions({reverse:!e});var n,o=this.getFindString();t&&(o=t.findString||o,n=t.count);var r=this.getOptions();this.setOptions(t);var s=i?this._startOffset:this.getStartOffset(),a=this._doFind(o,s,n);return a&&(i||(this._startOffset=a.start)),this.setOptions(r),this._hideAfterFind&&this.hide(),a},getStartOffset:function(){return void 0!==this._start?this._start:this._reverse?this._editor.getSelection().start-1:this._editor.getCaretOffset()},getFindString:function(){var e=this._editor.getSelection(),t=this._editor.getText(e.start,e.end);return this._regex&&(t=o.escape(t)),t||this._lastString},getOptions:function(){return{showAll:this._showAll,caseInsensitive:this._caseInsensitive,wrap:this._wrap,wholeWord:this._wholeWord,incremental:this._incremental,regex:this._regex,findAfterReplace:this._findAfterReplace,hideAfterFind:this._hideAfterFind,reverse:this._reverse,findCallback:this._findCallback,start:this._start,end:this._end}},getReplaceString:function(){return""},hide:function(){this._visible=!1,this._savedOptions&&(this.setOptions(this._savedOptions.pop()),0===this._savedOptions.length&&(this._savedOptions=null)),this._removeAllAnnotations();var e=this._editor.getTextView();e&&(e.removeEventListener("Focus",this._listeners.onEditorFocus),e.focus())},_processReplaceString:function(e){var t=e;if(this._regex){t="";for(var i=!1,n=this._editor.getModel().getLineDelimiter(),o=0;o0&&(r.endUndo(),n.setRedraw(!0)),a>0?i.reportStatus(s.formatMessage(e.replacedMatches,l)):i.reportStatus(e.nothingReplaced,"error"),r._replacingAll=!1},100)}},setOptions:function(e){if(e){if((e.showAll===!0||e.showAll===!1)&&this._showAll!==e.showAll&&(this._showAll=e.showAll,this.isVisible()))if(this._showAll)this._markAllOccurrences();else{var t=this._editor.getAnnotationModel();t&&t.removeAnnotations(n.AnnotationType.ANNOTATION_MATCHING_SEARCH)}(e.caseInsensitive===!0||e.caseInsensitive===!1)&&(this._caseInsensitive=e.caseInsensitive),(e.wrap===!0||e.wrap===!1)&&(this._wrap=e.wrap),(e.wholeWord===!0||e.wholeWord===!1)&&(this._wholeWord=e.wholeWord),(e.incremental===!0||e.incremental===!1)&&(this._incremental=e.incremental),(e.regex===!0||e.regex===!1)&&(this._regex=e.regex),(e.findAfterReplace===!0||e.findAfterReplace===!1)&&(this._findAfterReplace=e.findAfterReplace),(e.hideAfterFind===!0||e.hideAfterFind===!1)&&(this._hideAfterFind=e.hideAfterFind),(e.reverse===!0||e.reverse===!1)&&(this._reverse=e.reverse),e.hasOwnProperty("findCallback")&&(this._findCallback=e.findCallback),e.hasOwnProperty("start")&&(this._start=e.start),e.hasOwnProperty("end")&&(this._end=e.end)}},show:function(e){this._visible=!0,e&&(this._savedOptions||(this._savedOptions=[]),this._savedOptions.push(this.getOptions()),this.setOptions(e)),this._startOffset=this._editor.getSelection().start,this._editor.getTextView().addEventListener("Focus",this._listeners.onEditorFocus);var t=this;window.setTimeout(function(){t._incremental&&t.find(!0,null,!0)},0)},startUndo:function(){this._undoStack&&this._undoStack.startCompoundChange()},endUndo:function(){this._undoStack&&this._undoStack.endCompoundChange()},_find:function(e,t,i){return this._editor.getModel().find({string:e,start:t,end:this._end,reverse:this._reverse,wrap:i?!1:this._wrap,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive})},_doFind:function(t,i,o,r){o=o||1;var s=this._editor;if(!t)return this._removeAllAnnotations(),null;this._lastString=t;var a,l;if(this._regex)try{l=this._find(t,i,r)}catch(d){return void s.reportStatus(d.message,"error")}else l=this._find(t,i,r);for(var h=0;o>h&&l.hasNext();h++)a=l.next();if(!this._replacingAll){if(a?this._editor.reportStatus(""):this._editor.reportStatus(e.notFound,"error"),this.isVisible()){var c=n.AnnotationType.ANNOTATION_CURRENT_SEARCH,u=s.getAnnotationModel();if(u&&(u.removeAnnotations(c),a&&u.addAnnotation(n.AnnotationType.createAnnotation(c,a.start,a.end))),this._showAll){this._timer&&window.clearTimeout(this._timer);var p=this;this._timer=window.setTimeout(function(){p._markAllOccurrences(),p._timer=null},500)}}this._findCallback?this._findCallback(a):a&&s.moveSelection(a.start,a.end,null,!1)}return a},_doReplace:function(e,t,i,n){var o=this._editor;this._regex&&(n=o.getText(e,t).replace(new RegExp(i,this._caseInsensitive?"i":""),n)),o.setText(n,e,t),o.setSelection(e,e+n.length,!0)},_markAllOccurrences:function(){var e=this._editor.getAnnotationModel();if(e){for(var t,i=n.AnnotationType.ANNOTATION_MATCHING_SEARCH,o=e.getAnnotations(),r=[];o.hasNext();){var s=o.next();s.type===i&&r.push(s)}if(this.isVisible()){var a=this.getFindString();for(o=this._editor.getModel().find({string:a,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive}),t=[];o.hasNext();){var l=o.next();t.push(n.AnnotationType.createAnnotation(i,l.start,l.end))}}e.replaceAnnotations(r,t)}},_removeAllAnnotations:function(){var e=this._editor.getAnnotationModel();e&&(e.removeAnnotations(n.AnnotationType.ANNOTATION_CURRENT_SEARCH),e.removeAnnotations(n.AnnotationType.ANNOTATION_MATCHING_SEARCH))},_removeCurrentAnnotation:function(){var e=this._editor.getAnnotationModel();e&&e.removeAnnotations(n.AnnotationType.ANNOTATION_CURRENT_SEARCH)}},d.Find=l,d}),define("orion/editor/findUI",["i18n!orion/editor/nls/messages","orion/editor/find","orion/objects","orion/editor/util","orion/util"],function(e,t,i,n,o){function r(e,i,n){t.Find.call(this,e,i,n)}return r.prototype=new t.Find,i.mixin(r.prototype,{getFindString:function(){var e=this._findInput;return e?e.value:t.Find.prototype.getFindString.call(this)},getReplaceString:function(){var e=this._replaceInput;return e?e.value:t.Find.prototype.getReplaceString(this)},hide:function(){var e=this.isVisible();t.Find.prototype.hide.call(this),e&&(this._rootDiv.className="textViewFind")},show:function(e){t.Find.prototype.show.call(this,e);var i=e.findString,n=e.replaceString,o=this._findInput;if(o||(this._create(),o=this._findInput),i&&(o.value=i),n){var r=this._replaceInput;r.value=n}var s=this;window.setTimeout(function(){s._rootDiv.className="textViewFind show",o.select(),o.focus()},0)},_create:function(){var e=this,t=this._editor.getTextView(),i=t.getOptions("parent"),r=i.ownerDocument,s=o.createElement(r,"div");s.className="textViewFind",n.addEventListener(s,"keydown",function(t){e._handleKeyDown(t)}),this._rootDiv=s,this._createContents(r,s),t._rootDiv.insertBefore(s,t._rootDiv.firstChild)},_createContents:function(t,i){var r=this,s=o.createElement(t,"input");s.className="textViewFindInput",this._findInput=s,s.type="text",s.placeholder=e.findWith,n.addEventListener(s,"input",function(e){return r._handleInput(e)}),i.appendChild(s);var a=o.createElement(t,"span");r._createButton(t,a,e.next,function(){r.find(!0)}),r._createButton(t,a,e.previous,function(){r.find(!1)}),i.appendChild(a);var l=r._editor.getTextView().getOptions("readonly");if(!l){var d=o.createElement(t,"input");d.className="textViewReplaceInput",this._replaceInput=d,d.type="text",d.placeholder=e.replaceWith,i.appendChild(d),a=o.createElement(t,"span"),r._createButton(t,a,e.replace,function(){r.replace()}),r._createButton(t,a,e.replaceAll,function(){r.replaceAll()}),i.appendChild(a)}a=o.createElement(t,"span"),r._createButton(t,a,e.regex,function(e){r._toggle("regex",e.target)},this._regex,e.regexTooltip),r._createButton(t,a,e.caseInsensitive,function(e){r._toggle("caseInsensitive",e.target)},this._caseInsensitive,e.caseInsensitiveTooltip),r._createButton(t,a,e.wholeWord,function(e){r._toggle("wholeWord",e.target)},this._wholeWord,e.wholeWordTooltip),i.appendChild(a);var h=r._createButton(t,i,"",function(){r.hide()});h.className="textViewFindCloseButton",h.title=e.closeTooltip},_createButton:function(e,t,i,o,r,s){var a=e.createElement("button");return a.type="button",this._checked(r,a),s&&(a.title=s),n.addEventListener(a,"click",function(e){o.call(this,e)},!1),i&&a.appendChild(e.createTextNode(i)),t.appendChild(a),a},_toggle:function(e,t){var i={};i[e]=!this["_"+e],this.setOptions(i),this._checked(i[e],t)},_checked:function(e,t){t.className="textViewFindButton",e&&(t.className+=" checked")},_handleInput:function(){return this._incremental&&this.find(!0,null,!0),!0},_handleKeyDown:function(e){var t,i=(o.isMac?e.metaKey:e.ctrlKey)&&!e.altKey&&!e.shiftKey;return i&&70===e.keyCode&&(t=!0),((o.isMac?e.metaKey:e.ctrlKey)&&!e.altKey&&75===e.keyCode||13===e.keyCode)&&(this.find(13===e.keyCode?this._reverse?e.shiftKey:!e.shiftKey:!e.shiftKey),t=!0),i&&82===e.keyCode&&(this.replace(),t=!0),27===e.keyCode&&(this.hide(),t=!0),t?(e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.cancelBubble=!0,!1):!0}}),{FindUI:r}}),define("orion/editor/actions",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/annotations","orion/editor/tooltip","orion/editor/find","orion/editor/findUI","orion/util"],function(e,t,i,n,o,r,s){function a(e,t,i,n){function o(e,t,i){s.setText(e,t,i),r+=t-i+e.length}var r=0,s=e.editor,a=s.getSelections();!n&&(t||a.length>1)&&e.startUndo(),a.forEach(function(e){e.start+=r,e.end+=r,i(e,o)}),s.setSelections(a),!n&&(t||a.length>1)&&e.endUndo()}function l(e,t,i){this.editor=e,this.undoStack=t,this._incrementalFind=new o.IncrementalFind(e),this._find=i?i:new r.FindUI(e,t),this._lastEditLocation=null,this.init()}function d(e,t,i,n){this.editor=e,this.undoStack=t,this.contentAssist=i,this.linkedMode=n,this.contentAssist&&this.contentAssist.addEventListener("ProposalApplied",this.contentAssistProposalApplied.bind(this)),this.init()}var h=i.AnnotationType,c={};return l.prototype={init:function(){var i=this.editor.getTextView();this._lastEditListener={onModelChanged:function(e){this.editor.isDirty()&&(this._lastEditLocation=e.start+e.addedCharCount)}.bind(this)},i.addEventListener("ModelChanged",this._lastEditListener.onModelChanged),i.setAction("undo",function(e){if(this.undoStack){var t=1;for(e&&e.count&&(t=e.count);t>0;)this.undoStack.undo(),--t;return!0}return!1}.bind(this),{name:e.undo}),i.setAction("redo",function(e){if(this.undoStack){var t=1;for(e&&e.count&&(t=e.count);t>0;)this.undoStack.redo(),--t;return!0}return!1}.bind(this),{name:e.redo}),i.setKeyBinding(new t.KeyBinding("f",!0),"find"),i.setAction("find",function(){if(this._find){var e=this.editor.getSelection();return this._find.show({findString:this.editor.getText(e.start,e.end)}),!0}return!1}.bind(this),{name:e.find}),i.setKeyBinding(new t.KeyBinding("k",!0),"findNext"),i.setAction("findNext",function(e){return this._find?(this._find.find(!0,e),!0):!1}.bind(this),{name:e.findNext}),i.setKeyBinding(new t.KeyBinding("k",!0,!0),"findPrevious"),i.setAction("findPrevious",function(e){return this._find?(this._find.find(!1,e),!0):!1}.bind(this),{name:e.findPrevious}),i.setKeyBinding(new t.KeyBinding("j",!0),"incrementalFind"),i.setAction("incrementalFind",function(){return this._incrementalFind&&this._incrementalFind.find(!0),!0}.bind(this),{name:e.incrementalFind}),i.setKeyBinding(new t.KeyBinding("j",!0,!0),"incrementalFindReverse"),i.setAction("incrementalFindReverse",function(){return this._incrementalFind&&this._incrementalFind.find(!1),!0}.bind(this),{name:e.incrementalFindReverse}),i.setAction("tab",function(){return this.indentLines()}.bind(this)),i.setAction("shiftTab",function(){return this.unindentLines()}.bind(this),{name:e.unindentLines}),i.setKeyBinding(new t.KeyBinding(38,!1,!1,!0),"moveLinesUp"),i.setAction("moveLinesUp",function(){return this.moveLinesUp()}.bind(this),{name:e.moveLinesUp}),i.setKeyBinding(new t.KeyBinding(40,!1,!1,!0),"moveLinesDown"),i.setAction("moveLinesDown",function(){return this.moveLinesDown()}.bind(this),{name:e.moveLinesDown}),i.setKeyBinding(new t.KeyBinding(38,!0,!1,!0),"copyLinesUp"),i.setAction("copyLinesUp",function(){return this.copyLinesUp()}.bind(this),{name:e.copyLinesUp}),i.setKeyBinding(new t.KeyBinding(40,!0,!1,!0),"copyLinesDown"),i.setAction("copyLinesDown",function(){return this.copyLinesDown()}.bind(this),{name:e.copyLinesDown}),i.setKeyBinding(new t.KeyBinding("d",!0,!1,!1),"deleteLines"),i.setAction("deleteLines",function(e){return this.deleteLines(e)}.bind(this),{name:e.deleteLines}),i.setKeyBinding(new t.KeyBinding("l",!s.isMac,!1,!1,s.isMac),"gotoLine"),i.setAction("gotoLine",function(){return this.gotoLine()}.bind(this),{name:e.gotoLine}),i.setKeyBinding(new t.KeyBinding(190,!0),"nextAnnotation"),i.setAction("nextAnnotation",function(){return this.nextAnnotation(!0)}.bind(this),{name:e.nextAnnotation}),i.setKeyBinding(new t.KeyBinding(188,!0),"previousAnnotation"),i.setAction("previousAnnotation",function(){return this.nextAnnotation(!1)}.bind(this),{name:e.prevAnnotation}),i.setKeyBinding(new t.KeyBinding("e",!0,!1,!0,!1),"expand"),i.setAction("expand",function(){return this.expandAnnotation(!0)}.bind(this),{name:e.expand}),i.setKeyBinding(new t.KeyBinding("c",!0,!1,!0,!1),"collapse"),i.setAction("collapse",function(){return this.expandAnnotation(!1)}.bind(this),{name:e.collapse}),i.setKeyBinding(new t.KeyBinding("e",!0,!0,!0,!1),"expandAll"),i.setAction("expandAll",function(){return this.expandAnnotations(!0)}.bind(this),{name:e.expandAll}),i.setKeyBinding(new t.KeyBinding("c",!0,!0,!0,!1),"collapseAll"),i.setAction("collapseAll",function(){return this.expandAnnotations(!1)}.bind(this),{name:e.collapseAll}),i.setKeyBinding(new t.KeyBinding("q",!s.isMac,!1,!1,s.isMac),"lastEdit"),i.setAction("lastEdit",function(){return this.gotoLastEdit()}.bind(this),{name:e.lastEdit})},copyLinesDown:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var i=e.getModel();return a(this,!1,function(e,t){var n=i.getLineAtOffset(e.start),o=i.getLineAtOffset(e.end>e.start?e.end-1:e.end),r=i.getLineStart(n),s=i.getLineEnd(o,!0),a=i.getLineCount(),l="",d=i.getText(r,s);o===a-1&&(d=(l=i.getLineDelimiter())+d);var h=s;t(d,h,h),e.start=h+l.length,e.end=h+d.length}),!0},copyLinesUp:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var i=e.getModel();return a(this,!1,function(e,t){var n=i.getLineAtOffset(e.start),o=i.getLineAtOffset(e.end>e.start?e.end-1:e.end),r=i.getLineStart(n),s=i.getLineEnd(o,!0),a=i.getLineCount(),l="",d=i.getText(r,s);o===a-1&&(d+=l=i.getLineDelimiter());var h=r;t(d,h,h),e.start=h,e.end=h+d.length-l.length}),!0},deleteLines:function(e){var t=this.editor,i=t.getTextView();if(i.getOptions("readonly"))return!1;var n=1;e&&e.count&&(n=e.count);var o=t.getModel();return a(this,!1,function(e,t){var i,r=o.getLineAtOffset(e.start),s=o.getLineStart(r);i=e.start!==e.end||1===n?o.getLineAtOffset(e.end>e.start?e.end-1:e.end):Math.min(r+n-1,o.getLineCount()-1);var a=o.getLineEnd(i,!0);t("",s,a),e.start=e.end=s}),!0},expandAnnotation:function(e){var t=this.editor,n=t.getAnnotationModel();if(!n)return!0;var o=t.getModel(),r=t.getCaretOffset(),s=o.getLineAtOffset(r),a=o.getLineStart(s),l=o.getLineEnd(s,!0);o.getBaseModel&&(a=o.mapOffset(a),l=o.mapOffset(l),o=o.getBaseModel());for(var d,h=n.getAnnotations(a,l);!d&&h.hasNext();){var c=h.next();c.type===i.AnnotationType.ANNOTATION_FOLDING&&(d=c)}return d&&e!==d.expanded&&(e?d.expand():(t.setCaretOffset(d.start),d.collapse())),!0},expandAnnotations:function(e){var t=this.editor,n=t.getTextView(),o=t.getAnnotationModel();if(!o)return!0;var r,s=o.getAnnotations();for(n.setRedraw(!1);s.hasNext();)r=s.next(),r.type===i.AnnotationType.ANNOTATION_FOLDING&&e!==r.expanded&&(e?r.expand():r.collapse());return n.setRedraw(!0),!0},indentLines:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;if(t.getOptions("tabMode")){var i=e.getModel(),n=0,o=e.getSelections();return o.length>1&&this.startUndo(),o.some(function(r){r.start+=n,r.end+=n;var s=i.getLineAtOffset(r.start),a=i.getLineAtOffset(r.end>r.start?r.end-1:r.end);if(!(s!==a||o.length>1))return!0;var l=[];l.push("");for(var d=s;a>=d;d++)l.push(i.getLine(d,!0));var h=i.getLineStart(s),c=i.getLineEnd(a,!0),u=t.getOptions("tabSize","expandTab"),p=u.expandTab?new Array(u.tabSize+1).join(" "):" ",f=l.join(p);e.setText(f,h,c);var g=h===r.start?r.start:r.start+p.length,_=r.end+(a-s+1)*p.length;return n+=h-c+f.length,r.start=g,r.end=_,!1})?!1:(e.setSelections(o),o.length>1&&this.endUndo(),!0)}},gotoLastEdit:function(){return"number"==typeof this._lastEditLocation&&this.editor.showSelection(this._lastEditLocation),!0},gotoLine:function(){var t=this.editor,i=t.getModel(),n=i.getLineAtOffset(t.getCaretOffset());return n=prompt(e.gotoLinePrompty,n+1),n&&(n=parseInt(n,10),t.onGotoLine(n-1,0)),!0},moveLinesDown:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var i=e.getModel();return a(this,!0,function(e,t){var n=i.getLineAtOffset(e.start),o=i.getLineAtOffset(e.end>e.start?e.end-1:e.end),r=i.getLineCount();if(o!==r-1){var s,a=i.getLineStart(n),l=i.getLineEnd(o,!0),d=i.getLineEnd(o+1,!0)-(l-a),h=0;if(o!==r-2)s=i.getText(a,l);else{var c=i.getLineEnd(o);s=i.getText(c,l)+i.getText(a,c),h+=l-c}t("",a,l),t(s,d,d),e.start=d+h,e.end=d+h+s.length}}),!0},moveLinesUp:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var i=e.getModel();return a(this,!0,function(e,t){var n=i.getLineAtOffset(e.start);if(0!==n){var o=i.getLineAtOffset(e.end>e.start?e.end-1:e.end),r=i.getLineCount(),s=i.getLineStart(n-1),a=i.getLineStart(n),l=i.getLineEnd(o,!0),d=i.getText(a,l),h=0;if(o===r-1){var c=i.getLineEnd(n-1),u=i.getLineEnd(n-1,!0);d+=i.getText(c,u),a=c,h=u-c}t("",a,l),t(d,s,s),e.start=s,e.end=s+d.length-h}}),!0},nextAnnotation:function(e){function t(e){return!!e.lineStyle||e.type===h.ANNOTATION_MATCHING_BRACKET||e.type===h.ANNOTATION_CURRENT_BRACKET||!r.isAnnotationTypeVisible(e.type)}var i=this.editor,o=i.getAnnotationModel();if(!o)return!0;var r=i.getOverviewRuler()||i.getAnnotationStyler();if(!r)return!0;for(var s=i.getModel(),a=i.getCaretOffset(),l=o.getAnnotations(e?a:0,e?s.getCharCount():a),d=null;l.hasNext();){var c=l.next();if(e){if(c.start<=a)continue}else if(c.start>=a)continue;if(!t(c)&&(d=c,e))break}if(d){var u=[d];for(l=o.getAnnotations(d.start,d.start);l.hasNext();)c=l.next(),c===d||t(c)||u.push(c);var p=i.getTextView(),f=n.Tooltip.getTooltip(p,i);if(!f)return i.moveSelection(d.start),!0;i.moveSelection(d.start,d.start,function(){setTimeout(function(){var e=i.getTextView(),t=d.start,n=e.getLocationAtOffset(t);f.show({x:n.x,y:n.y,getTooltipInfo:function(){return i._getTooltipInfo(this.x,this.y)}},!1,!1)},0)})}return!0},unindentLines:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;if(t.getOptions("tabMode")){var i=e.getModel();return a(this,!1,function(e,n){for(var o=i.getLineAtOffset(e.start),r=i.getLineAtOffset(e.end>e.start?e.end-1:e.end),s=t.getOptions("tabSize"),a=new Array(s+1).join(" "),l=[],d=0,h=0,c=o;r>=c;c++){var u=i.getLine(c,!0);if(i.getLineStart(c)!==i.getLineEnd(c))if(0===u.indexOf(" "))u=u.substring(1),d++;else{if(0!==u.indexOf(a))return!0;u=u.substring(s),d+=s}c===o&&(h=d),l.push(u)}var p=i.getLineStart(o),f=i.getLineEnd(r,!0),g=i.getLineStart(r),_=l.join("");n(_,p,f);var m=p===e.start?e.start:e.start-h,v=Math.max(m,e.end-d+(e.end===g+1&&e.start!==e.end?1:0));e.start=m,e.end=v}),!0}},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()}},c.TextActions=l,d.prototype={init:function(){var i=this.editor.getTextView();i.setAction("lineStart",function(){return this.lineStart()}.bind(this)),i.setAction("enter",function(){return this.autoIndent()}.bind(this)),i.setKeyBinding(new t.KeyBinding("t",!0,!1,!0),"trimTrailingWhitespaces"),i.setAction("trimTrailingWhitespaces",function(){return this.trimTrailingWhitespaces()}.bind(this),{name:e.trimTrailingWhitespaces}),i.setKeyBinding(new t.KeyBinding(191,!0),"toggleLineComment"),i.setAction("toggleLineComment",function(){return this.toggleLineComment()}.bind(this),{name:e.toggleLineComment}),i.setKeyBinding(new t.KeyBinding(191,!0,!s.isMac,!1,s.isMac),"addBlockComment"),i.setAction("addBlockComment",function(){return this.addBlockComment()}.bind(this),{name:e.addBlockComment}),i.setKeyBinding(new t.KeyBinding(220,!0,!s.isMac,!1,s.isMac),"removeBlockComment"),i.setAction("removeBlockComment",function(){return this.removeBlockComment()}.bind(this),{name:e.removeBlockComment}),i.setKeyBinding(new t.KeyBinding("[",!1,!1,!1,!1,"keypress"),"autoPairSquareBracket"),i.setAction("autoPairSquareBracket",function(){return this.autoPairBrackets("[","]")}.bind(this)),i.setKeyBinding(new t.KeyBinding("]",!1,!1,!1,!1,"keypress"),"skipClosingSquareBracket"),i.setAction("skipClosingSquareBracket",function(){return this.handleClosingBracket("]")}.bind(this)),i.setKeyBinding(new t.KeyBinding("<",!1,!1,!1,!1,"keypress"),"autoPairAngleBracket"),i.setAction("autoPairAngleBracket",function(){return this.autoPairBrackets("<",">")}.bind(this)),i.setKeyBinding(new t.KeyBinding(">",!1,!1,!1,!1,"keypress"),"skipClosingAngleBracket"),i.setAction("skipClosingAngleBracket",function(){return this.handleClosingBracket(">")}.bind(this)),i.setKeyBinding(new t.KeyBinding("(",!1,!1,!1,!1,"keypress"),"autoPairParentheses"),i.setAction("autoPairParentheses",function(){return this.autoPairBrackets("(",")")}.bind(this)),i.setKeyBinding(new t.KeyBinding(")",!1,!1,!1,!1,"keypress"),"skipClosingParenthesis"),i.setAction("skipClosingParenthesis",function(){return this.handleClosingBracket(")")}.bind(this)),i.setKeyBinding(new t.KeyBinding("{",!1,!1,!1,!1,"keypress"),"autoPairBraces"),i.setAction("autoPairBraces",function(){return this.autoPairBrackets("{","}")}.bind(this)),i.setKeyBinding(new t.KeyBinding("}",!1,!1,!1,!1,"keypress"),"skipClosingBrace"),i.setAction("skipClosingBrace",function(){return this.handleClosingBracket("}")}.bind(this)),i.setKeyBinding(new t.KeyBinding("'",!1,!1,!1,!1,"keypress"),"autoPairSingleQuotation"),i.setAction("autoPairSingleQuotation",function(){return this.autoPairQuotations("'")}.bind(this)),i.setKeyBinding(new t.KeyBinding('"',!1,!1,!1,!1,"keypress"),"autoPairDblQuotation"),i.setAction("autoPairDblQuotation",function(){return this.autoPairQuotations('"')}.bind(this)),i.setAction("deletePrevious",function(){return this.deletePrevious()}.bind(this))},autoIndent:function(){function e(e,t){if(e.start===e.end){for(var i,o=n.getLineAtOffset(e.start),a=n.getLine(o,!1),u=n.getLineStart(o),p=0,f=e.start-u;f>p&&(32===(i=a.charCodeAt(p))||9===i);)p++;var g,_,m=a.substring(0,p),v=a.substring(0,f),y=a.substring(f);if(c.smartIndentation&&123===a.charCodeAt(_=v.trimRight().length-1)){var x=f-_-1,b=y.length-y.trimLeft().length;return g=125===a.charCodeAt(f+b)?s+m+r+s+m:s+m+r,t(g,e.start-x,e.end+b),e.start=e.end=e.start+s.length+m.length+r.length-x,!0}if(c.autoCompleteComments&&!h.test(v)&&(l.test(v)||d.test(v))){var C,w=l.exec(v);if(w)return g=s+m+" * ",g+=h.test(y)?y.substring(0,y.length-2).trim():y.trim(),n.getLineCount()!==o+1&&d.test(n.getLine(o+1))||(g+=s+m+" */"),t(g,e.start,e.end+y.length),e.start=e.end=e.start+s.length+m.length+3,!0;if(w=d.exec(v))for(var T=o-1;T>=0;T--){var L=n.getLine(T,!1);if(l.test(L))return h.test(y)||47===a.charCodeAt(f)?(g=s+m+"*"+y,C=e.start+s.length+m.length+1):(g=s+m+"* "+y,C=e.start+s.length+m.length+2),t(g,e.start,e.end+y.length),e.start=e.end=C,!0;if(!d.test(L))return!1}return!1}if(h.test(v)&&32===m.charCodeAt(m.length-1))return g=s+m.substring(0,m.length-1),t(g,e.start,e.end),e.start=e.end=e.start+g.length,!0; -if(p>0){for(p=f;p]"),r=i.getModel();return a(this,!1,function(i,n){var s,a=i.start===r.getCharCount()?"":r.getText(i.start,i.start+1).trim();i.start===i.end&&o.test(a)?(s=e+t,n(s,i.start,i.start),i.start=i.end=i.start+1):i.start!==i.end?(s=e+r.getText(i.start,i.end)+t,n(s,i.start,i.end),i.start+=1,i.end+=1):(n(e,i.start,i.end),i.start=i.end=i.start+e.length)}),!0},autoPairQuotations:function(e){if(!this.autoPairQuotation)return!1;var t=this.editor,i=t.getTextView();if(i.getOptions("readonly"))return!1;var n=new RegExp("^\"$|^'$"),o=new RegExp("\\w"),r=new RegExp("^$|[)}\\]>]"),s=t.getModel();return a(this,!1,function(t,i){function a(){i(e,t.start,t.end),t.start=t.end=t.start+e.length}var l=0===t.start?"":s.getText(t.start-1,t.start).trim(),d=t.start===s.getCharCount()?"":s.getText(t.start,t.start+1).trim();if(t.start!==t.end){var h=s.getText(t.start,t.end);n.test(h)?a():(i(e+h+e,t.start,t.end),t.start+=1,t.end+=1)}else d===e?t.start=t.end=t.start+1:l===e||n.test(d)||o.test(l)||!r.test(d)?a():(i(e+e,t.start,t.end),t.start=t.end=t.start+e.length)}),!0},contentAssistProposalApplied:function(e){function t(){return"number"==typeof i.escapePosition?i.escapePosition:e.data.start+i.proposal.length}var i=e.data.proposal;if(i.positions&&i.positions.length>0&&this.linkedMode){for(var n=[],o=0;o0&&this.linkedMode)this.linkedMode.enterLinkedMode({groups:i.groups,escapePosition:t()});else if("number"==typeof i.escapePosition){var r=this.editor.getTextView();r.setCaretOffset(i.escapePosition)}return!0},deletePrevious:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var i=e.getModel();return a(this,!1,function(e,t){if(e.start===e.end){var n=0===e.start?"":i.getText(e.start-1,e.start),o=e.start===i.getCharCount()?"":i.getText(e.start,e.start+1);("("===n&&")"===o||"["===n&&"]"===o||"{"===n&&"}"===o||"<"===n&&">"===o||'"'===n&&'"'===o||"'"===n&&"'"===o)&&t("",e.start,e.start+1)}},!0),!1},_findEnclosingComment:function(e,t,i,n,o){var r,s,a,l,d,h,c,u=e.getLineAtOffset(t),p=e.getLineAtOffset(i);for(r=u;r>=0&&(s=e.getLine(r),a=r===u?t-e.getLineStart(u):s.length,l=s.lastIndexOf(n,a),d=s.lastIndexOf(o,a),!(d>l));r--)if(-1!==l){h=e.getLineStart(r)+l;break}for(r=p;rl));r++)if(-1!==d){c=e.getLineStart(r)+d;break}return{commentStart:h,commentEnd:c}},lineStart:function(){var e=this.editor,t=e.getModel();return a(this,!1,function(e){var i,n=e.getCaret(),o=t.getLineAtOffset(n),r=t.getLineStart(o),s=t.getLine(o);for(i=0;ie.start?e.end-1:e.end);o=n?n.getLineCommentDelimiter(i.getLineStart(r)):"//";for(var a,l=!0,d=[],h=r;s>=h;h++){var c=i.getLine(h,!0);if(a=c.indexOf(o),d.push(a),l&&-1!==a){if(0!==a){var u;for(u=0;a>u;u++){var p=c.charCodeAt(u);if(32!==p&&9!==p)break}l=u===a}}else l=!1}var f,g,_,m=o.length,v=i.getLineStart(r);if(l){for(_=d.length-1;_>=0;_--)a=d[_]+i.getLineStart(r+_),t("",a,a+m);var y=i.getLineStart(s);f=v===e.start?e.start:e.start-m,g=e.end-m*(s-r+1)+(e.end===y+1?m:0)}else{for(_=d.length-1;_>=0;_--)a=i.getLineStart(r+_),t(o,a,a);f=v===e.start?e.start:e.start+m,g=e.end+m*(s-r+1)}e.start=f,e.end=g}),t.setRedraw(!0),!0},trimTrailingWhitespaces:function(){var e=this.editor,t=e.getModel(),i=e.getSelections();e.getTextView().setRedraw(!1),this.startUndo();for(var n=/(\s+$)/,o=t.getLineCount(),r=0;o>r;r++){var s=t.getLine(r),a=n.exec(s);if(a){var l=t.getLineStart(r),d=a[0].length,h=l+a.index;t.setText("",h,h+d),i.forEach(function(e){e.start>h&&(e.start=Math.max(h,e.start-d)),e.start!==e.end&&e.end>h&&(e.end=Math.max(h,e.end-d))})}}this.endUndo(),e.setSelections(i,!1),e.getTextView().setRedraw(!0)},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},handleClosingBracket:function(e){var t=this.editor,i=t.getTextView();if(i.getOptions("readonly"))return!1;var n=t.getModel(),o=t.getSelections();if(1===o.length&&o[0].start===o[0].end){var r=o[0].start===n.getCharCount()?"":n.getText(o[0].start,o[0].start+1);if(r===e)return o[0].start=o[0].end=o[0].start+1,t.setSelections(o),!0;var s=n.getLineAtOffset(o[0].start),a=n.getLine(s,!0);if(a.match(/^\s*$/)&&i.getOptions("tabMode")){var l=i.getOptions("tabSize"),d=new Array(l+1).join(" "),h=n.getLineStart(s),c=n.getLineEnd(s);if(h!==c){if(0===a.indexOf(" "))return a=a.substring(1),n.setText(a,h,c),t.setSelection(o[0].start-1,o[0].end-1),!1;if(0===a.indexOf(d))return a=a.substring(l),n.setText(a,h,c),t.setSelection(o[0].start-l,o[0].end-l),!1}}}return!1},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},setAutoPairParentheses:function(e){this.autoPairParentheses=e},setAutoPairBraces:function(e){this.autoPairBraces=e},setAutoPairSquareBrackets:function(e){this.autoPairSquareBrackets=e},setAutoPairAngleBrackets:function(e){this.autoPairAngleBrackets=e},setAutoPairQuotations:function(e){this.autoPairQuotation=e},setAutoCompleteComments:function(e){this.autoCompleteComments=e},setSmartIndentation:function(e){this.smartIndentation=e}},c.SourceCodeActions=d,String.prototype.trimLeft||(String.prototype.trimLeft=function(){return this.replace(/^\s+/g,"")}),String.prototype.trimRight||(String.prototype.trimRight=function(){return this.replace(/\s+$/g,"")}),c}),define("orion/editor/undoStack",[],function(){function e(e,t,i,n,o){this.model=e,this.offset=t,this.text=i,this.previousText=n,this.type=o}function t(e){this.owner=e,this.changes=[]}function i(e,t){this.size=void 0!==t?t:100,this.reset();var i=this;if(this._listener={onChanging:function(e){i._onChanging(e)},onDestroy:function(e){i._onDestroy(e)}},e.getModel){var n=e.getModel();n.getBaseModel&&(n=n.getBaseModel()),this.model=n,this.setView(e)}else this.shared=!0,this.model=e;this.model.addEventListener("Changing",this._listener.onChanging)}return e.prototype={getRedoChanges:function(){return[{start:this.offset,end:this.offset+this.previousText.length,text:this.text}]},getUndoChanges:function(){return[{start:this.offset,end:this.offset+this.text.length,text:this.previousText}]},undo:function(e,t){return this._doUndoRedo(this.offset,this.previousText,this.text,e,t),!0},redo:function(e,t){return this._doUndoRedo(this.offset,this.text,this.previousText,e,t),!0},merge:function(e,t,i,n,o){if(n===this.type){if(1===n&&e===this.offset+this.text.length)return this.text+=t,!0;if(-1===n&&o===this.offset)return this.offset=e,this.previousText=i+this.previousText,!0;if(-1===n&&e===this.offset)return this.previousText=this.previousText+i,!0}return!1},_doUndoRedo:function(e,t,i,n,o){if(this.model.setText(t,e,e+i.length),o&&n){var r=n.getModel();r!==this.model&&(e=r.mapOffset(e,!0)),n.setSelection(e,e+t.length)}}},t.prototype={getRedoChanges:function(){for(var e=[],t=0;t=0;t--)e=e.concat(this.changes[t].getUndoChanges());return e},add:function(e){this.changes.push(e)},end:function(e){e&&(this.endSelection=e.getSelections());var t=this.owner;t&&t.end&&t.end()},undo:function(e,t){this.changes.length>1&&e&&e.setRedraw(!1);for(var i=this.changes.length-1;i>=0;i--)this.changes[i].undo(e,!1);t&&e&&e.setSelections(this.startSelection),this.changes.length>1&&e&&e.setRedraw(!0);var n=this.owner;return n&&n.undo&&n.undo(),this.changes.length>0},redo:function(e,t){this.changes.length>1&&e&&e.setRedraw(!1);for(var i=0;i1,e&&e.setRedraw(!0);var n=this.owner;return n&&n.redo&&n.redo(),this.changes.length>0},merge:function(e,t,i,n,o,r){var s=this.changes.length;return s>0&&this===r?this.changes[s-1].merge(e,t,i,n,o):!1},start:function(e){e&&(this.startSelection=e.getSelections());var t=this.owner;t&&t.start&&t.start()}},i.prototype={destroy:function(){this._onDestroy()},add:function(e){if(this.compoundChange)this.compoundChange.add(e);else{var t=this.stack.length;this.stack.splice(this.index,t-this.index,e),this.index++,this.stack.length>this.size&&(this.stack.shift(),this.index--)}},markClean:function(){this._commitUndo(),this.cleanChange=this.stack[this.index-1],this.cleanChange&&(this.cleanChange.type=2)},isClean:function(){return this.cleanChange===this.stack[this.index-1]},canUndo:function(){return this.index>0},canRedo:function(){return this.stack.length-this.index>0},endCompoundChange:function(){this.compoundChange&&this.compoundChange.end(this.view),this.compoundChange=void 0},getSize:function(){return{undo:this.index,redo:this.stack.length-this.index}},getRedoChanges:function(){this._commitUndo();for(var e=[],t=this.index;t=0;t--)e=e.concat(this.stack[t].getUndoChanges());return e},undo:function(){this._commitUndo();var e,t=!1;this._ignoreUndo=!0;do{if(this.index<=0)break;e=this.stack[--this.index]}while(!(t=e.undo(this.view,!0)));return this._ignoreUndo=!1,t},redo:function(){this._commitUndo();var e,t=!1;this._ignoreUndo=!0;do{if(this.index>=this.stack.length)break;e=this.stack[this.index++]}while(!(t=e.redo(this.view,!0)));return this._ignoreUndo=!1,t},reset:function(){this.index=0,this.cleanChange=void 0,this.stack=[],this._ignoreUndo=!1,this._compoundChange=void 0},setView:function(e){this.view!==e&&(this.view&&e.removeEventListener("Destroy",this._listener.onDestroy),this.view=e,this.view&&e.addEventListener("Destroy",this._listener.onDestroy))},startCompoundChange:function(e){this._commitUndo();var i=new t(e);return this.add(i),this.compoundChange=i,this.compoundChange.start(this.view),this.compoundChange},_commitUndo:function(){this.endCompoundChange()},_onDestroy:function(e){e&&this.shared||this.model.removeEventListener("Changing",this._listener.onChanging),this.view&&(this.view.removeEventListener("Destroy",this._listener.onDestroy),this.view=null)},_trackUnsavedChanges:function(e){if(this._unsavedChanges){var t=this._unsavedChanges.length,i=e.addedCharCount,n=e.removedCharCount,o=e.start,r=e.start+n,s=0;if(0===i?s=-1:0===n&&(s=1),t>0&&s===this._previousChangeType){var a=this._unsavedChanges[t-1];if(0===n&&o===a.end+a.text.length)return void(a.text+=e.text);if(0===e.addedCharCount&&r===a.start)return void(a.start=o)}this._previousChangeType=s,this._unsavedChanges.push({start:o,end:r,text:e.text})}},_onChanging:function(t){if(this._trackUnsavedChanges(t),!this._ignoreUndo){var i=t.text,n=t.start,o=t.addedCharCount,r=t.removedCharCount,s=n+r,a=0;0===o&&1===r?a=-1:1===o&&0===r&&(a=1);var l=this.stack.length,d=this.model.getText(n,s);if(l>0&&this.index===l){var h=this.stack[l-1];if(h.merge(n,i,d,a,s,this.compoundChange))return}this.add(new e(this.model,n,i,d,a))}}},{UndoStack:i}}),define("orion/editor/rulers",["i18n!orion/editor/nls/messages","orion/editor/textView","orion/editor/annotations","orion/editor/tooltip","orion/objects","orion/editor/util","orion/util"],function(e,t,i,n,o,r,s){function a(e,t,i){this._location=e||"left",this._overview=t||"page",this._rulerStyle=i,this._view=null}function l(e,t,i,n){a.call(this,t,i,n);var o=this;this._listener={onTextModelChanged:function(e){o._onTextModelChanged(e)},onAnnotationModelChanged:function(e){o._onAnnotationModelChanged(e)}},this.setAnnotationModel(e)}function d(e,t,i,n,o){l.call(this,e,t,"page",i),this._oddStyle=n||{style:{backgroundColor:"white"}},this._evenStyle=o||{style:{backgroundColor:"white"}},this._numOfDigits=0,this._firstLine=1}function h(e,t,i){l.call(this,e,t,"page",i)}function c(e,t,i){l.call(this,e,t,"document",i)}function u(e,t,i){h.call(this,e,t,i)}a.prototype={getLocation:function(){return this._location},getOverview:function(){return this._overview},getRulerStyle:function(){return this._rulerStyle},getView:function(){return this._view},setView:function(e){this._onTextModelChanged&&this._view&&this._view.removeEventListener("ModelChanged",this._listener.onTextModelChanged),this._view=e,this._onTextModelChanged&&this._view&&this._view.addEventListener("ModelChanged",this._listener.onTextModelChanged)}},l.prototype=o.mixin(new a,{getAnnotations:function(e,t){var i=this._annotationModel;if(!i)return[];var n=this._view.getModel(),o=n.getLineStart(e),r=n.getLineEnd(t-1),s=n;n.getBaseModel&&(s=n.getBaseModel(),o=n.mapOffset(o),r=n.mapOffset(r));for(var a=[],l=this.getAnnotationsByType(i,o,r),d=0;d=p;p++){var f=p;if(n!==s){var g=s.getLineStart(p);if(g=n.mapOffset(g,!0),-1===g)continue;f=n.getLineAtOffset(g)}if(f>=e&&t>f){var _=this._mergeAnnotation(a[f],h,p-c,u-c+1);_&&(a[f]=_)}}if(!this._multiAnnotation&&this._multiAnnotationOverlay)for(var m in a)a[m]._multiple&&(a[m].html=a[m].html+this._multiAnnotationOverlay.html);return a},getAnnotationModel:function(){return this._annotationModel},getWidestAnnotation:function(){return null},setAnnotationModel:function(e){this._annotationModel&&this._annotationModel.removEventListener("Changed",this._listener.onAnnotationModelChanged),this._annotationModel=e,this._annotationModel&&this._annotationModel.addEventListener("Changed",this._listener.onAnnotationModelChanged)},setMultiAnnotation:function(e){this._multiAnnotation=e},setMultiAnnotationOverlay:function(e){this._multiAnnotationOverlay=e},onClick:function(e){if(void 0!==e){var t,i,o,r=this._view,s=r.getModel(),a=s.getLineStart(e),l=s.getLineEnd(e,!0),d=r.getSelection().start,h=r.getSelection().end,c=this._annotationModel;if(c){s.getBaseModel&&(a=s.mapOffset(a),l=s.mapOffset(l),d=s.mapOffset(d),h=s.mapOffset(h));var u=this;t=this._findNextAnnotation(c,a,l,d,h,function(e){return u.isAnnotationTypeVisible(e)}),i=t?t.start:a,o=t?t.end:a,s.getBaseModel&&(i=s.mapOffset(i,!0),o=s.mapOffset(o,!0)),t&&void 0!==t.groupId&&(this._currentClickGroup=this._currentClickGroup===t.groupId?null:t.groupId,this._setCurrentGroup(e))}this._view.setSelection(o,i,1/3,function(){});var p=n.Tooltip.getTooltip(this._view);p&&(t&&"left"===this.getLocation()?p.show({getTooltipInfo:function(){return u._getTooltipInfo([t])}},!1,!1):p.hide())}},onDblClick:function(){},onMouseMove:function(e,t){var i=n.Tooltip.getTooltip(this._view);if(i&&(!i.isVisible()||this._tooltipLineIndex!==e)&&(this._tooltipLineIndex=e,t.clientX!==this._lastMouseX||t.clientY!==this._lastMouseY)){this._lastMouseX=t.clientX,this._lastMouseY=t.clientY,this._hoverTimeout&&(window.clearTimeout(this._hoverTimeout),this._hoverTimeout=null);var o=t.target?t.target:t.srcElement,r=o.getBoundingClientRect();this._curElementBounds=Object.create(null),this._curElementBounds.top=r.top,this._curElementBounds.left=r.left,this._curElementBounds.height=r.height,this._curElementBounds.width=r.width,o===this.node&&(this._curElementBounds.top=t.clientY,this._curElementBounds.height=1);var s=this;s._hoverTimeout=window.setTimeout(function(){s._hoverTimeout=null,i.onHover({getTooltipInfo:function(){var e=s._getAnnotationsAtLineIndex(s._tooltipLineIndex),i=s._getTooltipContents(s._tooltipLineIndex,e);return s._getTooltipInfo(i,t.clientY,{source:"ruler",rulerLocation:s.getLocation()})}},t.clientX,t.clientY)},175)}},onMouseOver:function(e,t){this.onMouseMove(e,t),this._currentClickGroup||this._setCurrentGroup(e)},onMouseOut:function(){this._currentClickGroup||this._setCurrentGroup(-1),this._hoverTimeout&&(window.clearTimeout(this._hoverTimeout),this._hoverTimeout=null)},_findNextAnnotation:function(e,t,i,n,o,r){var s,a=null,l=t;if(n>=0&&o>=0&&n>=t&&i>n){l=n;for(var d=e.getAnnotations(n,o);!s&&d.hasNext();){var h=d.next();(!r||r(h.type))&&h.start===n&&h.end===o&&(s=h)}}for(var c,u=e.getAnnotations(l,i);u.hasNext();)if(h=u.next(),!r||r(h.type)){if(a||(a=h),!s){a=h;break}if(c&&(s.start!==h.start||s.end!==h.end)){c=!1,a=h;break}s&&s===h&&(c=!0)}return c&&(a=null),a},_getAnnotationsAtLineIndex:function(e){if(void 0!==e){var t,i=this._view,n=this._annotationModel,o=[];if(!i)return[];if(t=i.getModel(),n&&t){var r=t.getLineStart(e),s=t.getLineEnd(e);t.getBaseModel&&(r=t.mapOffset(r),s=t.mapOffset(s)),o=this.getAnnotationsByType(n,r,s)}return o}},_getTooltipInfo:function(e,t,i){if(!e)return null;var n=Object.create(null);n.top=this._curElementBounds.top,n.left=this._curElementBounds.left,n.height=this._curElementBounds.height,n.width=this._curElementBounds.width,"string"==typeof e&&t&&(n.top=t,n.height=1);var o=this.getLocation(),r=this.getRulerStyle(),s="left"===o?"right":"left",a=0,l=0;if(this._view){var d=this._view._clientDiv.getBoundingClientRect();a=d.left-(n.left+n.width)}else a=n.width;l=n.height,"left"===s&&(a=-25,1===n.height&&(a+=2)),r.styleClass.indexOf("folding")>=0&&(l-=14);var h={contents:e,position:s,tooltipOffsetX:a,tooltipOffsetY:l,anchorArea:n,context:i};return h},_getTooltipContents:function(e,t){return t},_getOnClickTooltipInfo:function(e){var t=this._view,i=Object.create(null);i.top=this._curElementBounds.top,i.left=this._curElementBounds.left,i.height=this._curElementBounds.height,i.width=this._curElementBounds.width;var n=this.getLocation(),o="left"===n?"right":"left",r={contents:[e],position:o,anchorArea:i};if(t){var s=t._clientDiv.getBoundingClientRect();r.offsetX=s.left-(i.left+i.width)}else r.offsetX=i.width;return r.offsetY=i.height,"left"===r.position&&(r.offsetX=20),r},_onAnnotationModelChanged:function(e){function t(e){for(var t=0;t=l&&void 0!==t.groupId){o=t;break}if(s&&o&&s.groupId===o.groupId)return}if(this._currentGroupAnnotation=null,s&&n.removeAnnotations(s.groupType),o&&-1!==e){this._currentGroupAnnotation=o,i=n.getAnnotations();for(var d=[];i.hasNext();)t=i.next(),delete t.groupAnnotation,t.groupId===o.groupId&&(t=t.createGroupAnnotation(),d.push(t));n.replaceAnnotations(null,d)}}}),i.AnnotationTypeList.addMixin(l.prototype),d.prototype=new l,d.prototype.getAnnotations=function(e,t){for(var i=l.prototype.getAnnotations.call(this,e,t),n=this._view.getModel(),o=e;t>o;o++){var r=o-this._firstLine&1?this._oddStyle:this._evenStyle,s=o;if(n.getBaseModel){var a=n.getLineStart(s);s=n.getBaseModel().getLineAtOffset(n.mapOffset(a))}i[o]||(i[o]={}),i[o].html=this._firstLine+s+"",i[o].style||(i[o].style=r)}return i},d.prototype.getWidestAnnotation=function(){var e=this._view.getModel().getLineCount();return this.getAnnotations(e-1,e)[e-1]},d.prototype.setFirstLine=function(e){this._firstLine=void 0!==e?e:1},d.prototype._onTextModelChanged=function(e){var t=e.start,i=this._view.getModel(),n=i.getBaseModel?i.getBaseModel().getLineCount():i.getLineCount(),o=(this._firstLine+n-1+"").length;if(this._numOfDigits!==o){this._numOfDigits=o;var r=i.getLineAtOffset(t);this._view.redrawLines(r,i.getLineCount(),this)}},h.prototype=new l,c.prototype=new l,c.prototype.getRulerStyle=function(){var e={style:{lineHeight:"1px",fontSize:"1px"}};return e=this._mergeStyle(e,this._rulerStyle)},c.prototype._getTooltipContents=function(t,i){if(i&&0===i.length){var n=this._view.getModel(),o=t;if(n.getBaseModel){var r=n.getLineStart(o);o=n.getBaseModel().getLineAtOffset(n.mapOffset(r))}return s.formatMessage(e.line,o+1)}return l.prototype._getTooltipContents.call(this,t,i)},c.prototype._mergeAnnotation=function(e,t,i,n){if(0!==i)return void 0;var o=e;if(!o){var r=3*n;o={html:" ",style:{style:{height:r+"px"}}},o.style=this._mergeStyle(o.style,t.overviewStyle)}return o},u.prototype=new h,u.prototype.onClick=function(e){if(void 0!==e){var t=this._annotationModel;if(t){var i=this._view,o=i.getModel(),r=o.getLineStart(e),s=o.getLineEnd(e,!0);o.getBaseModel&&(r=o.mapOffset(r),s=o.mapOffset(s),o=o.getBaseModel());for(var a,l=t.getAnnotations(r,s);!a&&l.hasNext();){var d=l.next();this.isAnnotationTypeVisible(d.type)&&o.getLineAtOffset(d.start)===o.getLineAtOffset(r)&&(a=d)}if(a){var h=n.Tooltip.getTooltip(this._view);h&&h.hide(),a.expanded?a.collapse():a.expand()}}}},u.prototype._getTooltipContents=function(e,t){if(t&&t.length>0){var i=this._view,n=i.getModel(),o=n.getLineStart(e);n.getBaseModel&&(o=n.mapOffset(o),n=n.getBaseModel());for(var r=n.getLineAtOffset(o),s=0;s=e.end?s-=e.end-e.start:s>=e.start&&(s=e.start)}),i.setText(r,s,s),i.setSelection(s,s+r.length),this._dropText=null,this._dropOffset=-1}this._undoStack&&this._undoStack.endCompoundChange(),this._dragSelection=null}},_onDragEnter:function(e){this._onDragOver(e)},_onDragOver:function(t){var i=t.event.dataTransfer.types,n=!this._view.getOptions("readonly");if(n&&i&&(n=i.contains?i.contains("text/plain")||i.contains("Text"):-1!==i.indexOf("text/plain")||-1!==i.indexOf("Text")),n){if(!e.isFirefox){var o=e.isMac?t.event.altKey:t.event.ctrlKey;this._dropEffect=t.event.dataTransfer.dropEffect=o?"copy":"move"}}else t.event.dataTransfer.dropEffect="none"},_onDrop:function(t){var i=this._view,n=t.event.dataTransfer.getData("Text");if(n){e.isFirefox||(t.event.dataTransfer.dropEffect=this._dropEffect); -var o=i.getOffsetAtLocation(t.x,t.y);this._dragSelection?(this._dropOffset=o,this._dropText=n):(i.setText(n,o,o),i.setSelection(o,o+n.length))}}},{TextDND:t}}),define("orion/editor/linkedMode",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/keyModes","orion/editor/annotations","orion/objects","orion/util"],function(e,t,i,n,o){function r(e){this._data=e}function s(e,t,n){var o=e.getTextView();i.KeyMode.call(this,o),this.editor=e,this.undoStack=t,this.contentAssist=n,this.linkedModeModel=null,o.setAction("linkedModeEnter",function(){return this.exitLinkedMode(!0),!0}.bind(this)),o.setAction("linkedModeCancel",function(){return this.exitLinkedMode(!1),!0}.bind(this)),o.setAction("linkedModeNextGroup",function(){var e=this.linkedModeModel;return this.selectLinkedGroup((e.selectedGroupIndex+1)%e.groups.length),!0}.bind(this)),o.setAction("linkedModePreviousGroup",function(){var e=this.linkedModeModel;return this.selectLinkedGroup(e.selectedGroupIndex>0?e.selectedGroupIndex-1:e.groups.length-1),!0}.bind(this)),this.linkedModeListener={onActivating:function(){this._groupContentAssistProvider&&(this.contentAssist.setProviders([this._groupContentAssistProvider]),this.contentAssist.setProgress(null))}.bind(this),onModelChanged:function(e){if(!this.ignoreVerify){for(var t,i,n=this.editor.mapOffset(e.start),o=this.linkedModeModel;o&&(t=this._getPositionChanged(o,n,n+e.removedCharCount),i=t.position,void 0===i||i.model!==o);)this.exitLinkedMode(!1),o=this.linkedModeModel;if(o){for(var r,s,a=0,l=e.addedCharCount-e.removedCharCount,d=t.positions,h=0;h=0;g--)d=u[g],d.model===s&&d.group===i.group&&n.setText(e.text,d.oldOffset+p,d.oldOffset+f,!1);this.ignoreVerify=!1,e.text=null,this._updateAnnotations(u)}}}.bind(this)}}var a={};return r.prototype={chop:function(e,t){return t.substring(e.length)},computeProposals:function(e,t,i){var n=i.prefix,o=[],r=this._data.style?this._data.style:null;r=r?r:"emphasis";for(var s=this._data.values,a=0;a=0;r--)if(!o[r].escape){var s=o[r].position;if(s.offset<=t&&i<=s.offset+s.length){n=o[r];break}}return{position:n,positions:o}},_updateAnnotations:function(e){var t=this.editor.getAnnotationModel();if(t){for(var i,o=[],r=[],s=t.getAnnotations();s.hasNext();)switch(i=s.next(),i.type){case n.AnnotationType.ANNOTATION_LINKED_GROUP:case n.AnnotationType.ANNOTATION_CURRENT_LINKED_GROUP:case n.AnnotationType.ANNOTATION_SELECTED_LINKED_GROUP:o.push(i)}var a=this.linkedModeModel;if(a){e=e||this._getSortedPositions(a);for(var l=0;l0?(localStorage.setItem(this._prefix+this._offsetStorageLabel,this._offset),this._closed=!1):this._closed=!0,e!==this._closed&&(localStorage.setItem(this._prefix+"/toggleState",this._closed?"closed":null),i.logEvent("preferenceChange","splitterClosed",this._prefix,this._closed?0:1))},_mouseDown:function(e){return e.target===this._thumb?(n.stop(e),this._thumbDown()):void(this._tracking||(this._down(e),this._tracking=this._mouseMove.bind(this),window.addEventListener("mousemove",this._tracking),n.setFramesEnabled(!1),n.stop(e)))},_mouseMove:function(e){this._tracking&&(this._move(e.clientX,e.clientY),this._resize())},_mouseUp:function(e){this._tracking&&(n.setFramesEnabled(!0),window.removeEventListener("mousemove",this._tracking),this._tracking=null,this._up(),n.stop(e))},_touchStart:function(e){var t=e.touches;if(1===t.length){if(n.stop(e),e.target===this._thumb)return this._thumbDown();this._down(e),this._touching=!0}},_touchMove:function(e){if(this._touching){var t=e.touches;if(1===t.length){var i=t[0];this._move(i.clientX,i.clientY)}}},_touchEnd:function(e){var t=e.touches;0===t.length&&(this._touching=!1,this._up())}},o.prototype.constructor=o,{Splitter:o,ORIENTATION_HORIZONTAL:r,ORIENTATION_VERTICAL:s}}),define("text!orion/compare/sideBySideTemplate.html",[],function(){return'
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n'}),define("orion/compare/compareUIFactory",["orion/webui/littlelib","orion/webui/splitter","text!orion/compare/sideBySideTemplate.html"],function(e,t,i){var n=n||{};return n.TwoWayCompareUIFactory=function(){function n(e){this._parentDivID=e.parentDivID,this._commandSpanId=e.commandSpanId,this._showTitle=e.showTitle,this._leftTitle=e.leftTitle,this._rightTitle=e.rightTitle,this._showLineStatus=e.showLineStatus}return n.prototype={_init:function(){var t=this._parentDivID+"_";this._topWidgetDiv=e.node("topWidget_id"),this._topWidgetDiv.id=t+"topWidget_id",this._leftEditorParentDiv=e.node("left_editor_id"),this._leftEditorParentDiv.id=t+"left_editor_id",this._rightEditorParentDiv=e.node("right_editor_id"),this._rightEditorParentDiv.id=t+"right_editor_id",this._rightEditorWrapperDiv=e.node("right_editor_wrapper_id"),this._rightEditorWrapperDiv.id=t+"right_editor_wrapper_id",this._leftActionDiv=e.node("left_action_id"),this._leftActionDiv.id=t+"left_action_id",this._rightActionDiv=e.node("right_action_id"),this._rightActionDiv.id=t+"right_action_id",this._leftTitleDiv=e.node("left_title_id"),this._leftTitleDiv.id=t+"left_title_id",this._rightTitleDiv=e.node("right_title_id"),this._rightTitleDiv.id=t+"right_title_id",this._leftStatusDiv=e.node("left_status_id"),this._leftStatusDiv.id=t+"left_status_id",this._rightStatusDiv=e.node("right_status_id"),this._rightStatusDiv.id=t+"right_status_id",this._diffCanvasDiv=e.node("diff_canvas_id"),this._diffCanvasDiv.id=t+"diff_canvas_id",this._splitterId=t+"orion_splitter",this._showTitle||this.disableTitle(),this._showLineStatus||this.disableLineStatus()},_createSplitter:function(){var i=e.$(".split",this._topWidgetDiv);i.id=this._splitterId;var n=e.$(".leftPanelLayout",this._topWidgetDiv),o=e.$(".rightPanelLayout",this._topWidgetDiv);i&&n&&o&&(this._splitter=new t.Splitter({node:i,sidePanel:n,mainPanel:o,proportional:!0}))},buildUI:function(){e.node(this._parentDivID).innerHTML=i,this._init(),this._createSplitter()},destroy:function(){},getSplitter:function(){return this._splitter},isLeftPane:function(t){var i=e.$(".leftPanelLayout",this._topWidgetDiv);return i===t},getEditorParentDiv:function(e){return e?this._leftEditorParentDiv:this._rightEditorParentDiv},getTitleDiv:function(e){return e?this._leftTitleDiv:this._rightTitleDiv},getActionDivId:function(e){return e?this._leftActionDiv.id:this._rightActionDiv.id},getStatusDiv:function(e){return e?this._leftStatusDiv:this._rightStatusDiv},getCommandSpanId:function(){return this._commandSpanId},getDiffCanvasDiv:function(){return this._diffCanvasDiv},disableTitle:function(){this._leftEditorParentDiv.style.top="0px",this._rightEditorWrapperDiv.style.top="0px",this._leftTitleDiv.style.height="0px",this._rightTitleDiv.style.height="0px"},disableLineStatus:function(){this._leftEditorParentDiv.style.marginBottom="0px",this._rightEditorWrapperDiv.style.marginBottom="0px",this._leftStatusDiv.style.height="0px",this._rightStatusDiv.style.height="0px"}},n}(),n});var JsDiff=function(){function e(e){return{newPos:e.newPos,components:e.components.slice(0)}}function t(e){for(var t=[],i=0;i/g,">"),t=t.replace(/"/g,""")}var n=function(e){this.ignoreWhitespace=e};n.prototype={diff:function(t,i,n){if(this.ignoreWhitespace=n,i===t)return[{value:i}];if(!i)return[{value:t,removed:!0}];if(!t)return[{value:i,added:!0}];i=this.tokenize(i),t=this.tokenize(t);var o=i.length,r=t.length,s=o+r,a=[{newPos:-1,components:[]}],l=this.extractCommon(a[0],i,t,0);if(a[0].newPos+1>=o&&l+1>=r)return a[0].components;for(var d=1;s>=d;d++)for(var h=-1*d;d>=h;h+=2){var c,u=a[h-1],p=a[h+1];l=(p?p.newPos:0)-h,u&&(a[h-1]=void 0);var f=u&&u.newPos+1=0&&r>l;if(f||g){!f||g&&u.newPos=o&&l+1>=r)return c.components;a[h]=c}else a[h]=void 0}},pushComponent:function(e,t,i,n,o){var r=e[e.length-1];r&&r.added===n&&r.removed===o?e[e.length-1]={value:this.join(r.value,t),helperValue:this.join(r.helperValue,i),added:n,removed:o}:e.push({value:t,helperValue:i,added:n,removed:o})},extractCommon:function(e,t,i,n){for(var o=t.length,r=i.length,s=e.newPos,a=s-n;o>s+1&&r>a+1&&this.equals(t[s+1],i[a+1]);)s++,a++,this.pushComponent(e.components,t[s],i[a],void 0,void 0);return e.newPos=s,a},equals:function(e,t){var i=/\S/;return!this.ignoreWhitespace||i.test(e)||i.test(t)?this._equals(e,t):!0},join:function(e,t){return e+t},tokenize:function(e){return e}};var o=new n;o._equals=function(e,t){return e===t};var r=new n(!1);r.tokenize=function(e){return t(e.split(/(\s+|\b)/))},r._equals=function(e,t){return e===t};var s=new n(!0);s.tokenize=function(e){return t(e.split(/([{}:;,]|\s+)/))},s._equals=function(e,t){return e===t};var a=new n;return a.tokenize=function(e){var t=e.split(/^/m);return t&&t.length>0&&!t[t.length-1]&&t.pop(),t},a._equals=function(e,t){if(this.ignoreWhitespace){var i=e.replace(/^\s+|\s+$|\s+(?=\s)/g,""),n=t.replace(/^\s+|\s+$|\s+(?=\s)/g,"");return i===n}return e===t},{diffChars:function(e,t,i){return o.diff(e,t,i)},diffWords:function(e,t,i){return r.diff(e,t,i)},diffLines:function(e,t,i){return a.diff(e,t,i)},diffCss:function(e,t){return s.diff(e,t)},createPatch:function(e,t,i,n,o){var r=[];r.push("Index: "+e),r.push("==================================================================="),r.push("--- "+e+" "+n),r.push("+++ "+e+" "+o);var s=a.diff(t,i);s.push({value:"",lines:[]});for(var l=0,d=0,h=[],c=1,u=1,p=0;p1&&!/\n$/.test(s[s.length-2].value)&&r.push("\\ No newline at end of file\n"),r.join("\n")},convertChangesToXML:function(e){for(var t=[],n=0;n"):o.removed&&t.push(""),t.push(i(o.value)),o.added?t.push(""):o.removed&&t.push("")}return t.join("")}}}();"undefined"!=typeof module&&(module.exports=JsDiff),"function"==typeof define&&define.amd&&define("jsdiff/diff",[],function(){return JsDiff}),define("orion/compare/jsdiffAdapter",["jsdiff/diff"],function(e){var t=t||{};return t.JSDiffAdapter=function(){function t(e){this._ignoreWhitespace=e}return t.prototype={_specialLine:function(e,t,i){return t.value===e&&i!==e},adapt:function(t,i,n){n||(n="\n");for(var o=t.split(n),r=i.split(n),s=""===o[o.length-1],a=""===r[r.length-1],l=e.diffLines(t,i,this._ignoreWhitespace),d=[],h=[],c=0,u=0,p=-1,f=0,g=!0,_=n,m=0;m1&&""===y[y.length-1]&&x--,x>1&&!g&&""===y[0]&&(x--,b++),v.lines=y,v.added||v.removed)if(v.added){-1===p&&(p=h.length+1),c+=x;for(var C=b;x+b>C;C++)h.push(v.lines[C])}else u+=x;else this._specialLine(n,v,_)||((c||u)&&(d.push([c,u,p]),c=0,u=0,p=-1,f+=u),d.push([x,x,0]),f+=x);g=!1,y.length>1&&""===y[y.length-1]&&(g=!0),_=v.value?v.value[v.value.length-1]:n}if((c||u)&&(d.push([c,u,p]),f+=u),f1){var w=d[d.length-1];0===w[2]?(w[0]+=1,w[1]+=1):-1===w[2]?d.push([1,1,0]):s===a?d.push([1,1,0]):(a&&(w[0]+=1),s&&(w[1]+=1))}return{mapper:d,changContents:{array:h,index:0}}},adaptCharDiff:function(t,i,n){for(var o=n?e.diffWords(t,i,this._ignoreWhitespace):e.diffChars(t,i,this._ignoreWhitespace),r=[],s=0,a=0,l=0,d=0,h=0;h0||d>0)&&(r.push([a,a+l,s,s+d]),a+=l,s+=d,l=0,d=0),a+=c.value.length,s+=c.helperValue?c.helperValue.length:c.value.length)}return(l>0||d>0)&&r.push([a,a+l,s,s+d]),r}},t}(),t}),define("orion/treeModelIterator",[],function(){var e={};return e.TreeModelIterator=function(){function e(e,t){this.firstLevelChildren=e,this.reset(),this._init(t)}return e.prototype={_init:function(e){e&&(this.isExpanded=e.isExpanded,this.isExpandable=e.isExpandable,this.forceExpandFunc=e.forceExpandFunc,this.getChildrenFunc=e.getChildrenFunc)},topLevel:function(e){return e.parent?e.parent===this.root:!0},_getChildren:function(e){return"function"==typeof this.getChildrenFunc?this.getChildrenFunc(e):e?e.children:null},_expanded:function(e){if(!e)return!0;var t=this._getChildren(e),i=t&&t.length>0;return this.isExpanded&&i&&(i=this.isExpanded(e)),i},_expandable:function(e){return e?this.isExpandable?this.isExpandable(e):!1:!0},_diveIn:function(e){if(this._expanded(e)){var t=this._getChildren(e);return this.setCursor(t[0]),this.cursor()}return null},_drillToLast:function(e){if(this._expanded(e)){var t=this._getChildren(e);return this._drillToLast(t[t.length-1])}return e},_forward:function(e){if(!this._cursor)return null;var t=this._diveIn(this._cursor);if(!t){if(e&&this._expandable(this._cursor)&&this.forceExpandFunc){var i=this;return this.forceExpandFunc(this._cursor,"first",function(e){e&&i.setCursor(e)})}t=this._findSibling(this._cursor,!0),t&&this.setCursor(t)}return t},_backward:function(e){if(!this._cursor)return null;var t=this._findSibling(this._cursor,!1);if(t&&t!==this._cursor.parent&&(t=this._drillToLast(t)),e&&t&&this._expandable(t)&&this.forceExpandFunc&&t!==this._cursor.parent){var i=this;return this.forceExpandFunc(t,"last",function(e){e&&i.setCursor(e)})}return t&&this.setCursor(t),t},_findSibling:function(e,t){for(var i=this.topLevel(e),n=this._getChildren(e.parent),o=i?this.firstLevelChildren:n,r=0;r0&&(this.root=this.firstLevelChildren[0].parent)},scan:function(e,t){var i=this.cursor(),n=this._scan(!0,e,t);return n||(n=this._scan(!1,e,t)),this.setCursor(i),n},iterate:function(e,t){return e?this._forward(t):this._backward(t)},iterateOnTop:function(e,t){var i=this._findSibling(this._getTopLevelParent(this.cursor()),e); -i?this.setCursor(i):t&&this.firstLevelChildren.length>0&&this.setCursor(e?this.firstLevelChildren[0]:this.firstLevelChildren[this.firstLevelChildren.length-1])},collapse:function(e){return this._cursor&&this._inParentChain(this._cursor,e)?(this.setCursor(e),this._cursor):null},reset:function(){this._cursor=null,this._prevCursor=null,this.root=null,this.firstLevelChildren.length>0&&(this._cursor=this.firstLevelChildren[0],this.root=this.firstLevelChildren[0].parent)},cursorMoved:function(){return this._cursor!==this._prevCursor},cursor:function(){return this._cursor},prevCursor:function(){return this._prevCursor}},e}(),e}),define("orion/compare/diffTreeNavigator",["i18n!orion/compare/nls/messages","orion/treeModelIterator","orion/compare/compareUtils","orion/editor/annotations","orion/compare/jsdiffAdapter"],function(e,t,i,n,o){var r={},s={};return r.DiffTreeNavigator=function(){function r(e,t,i,n,o,r){this._root={type:"root",children:[]},this._initialized=!1,this.initAll(e,t,i,n,o,r)}s.ANNO_DIFF_ADDED_BLOCK="orion.annotation.diff.addedBlock",s.ANNO_DIFF_CURRENT_ADDED_BLOCK="orion.annotation.diff.currentAddedBlock",s.ANNO_DIFF_DELETED_BLOCK="orion.annotation.diff.deletedBlock",s.ANNO_DIFF_CURRENT_DELETED_BLOCK="orion.annotation.diff.currentDeletedBlock",s.ANNO_DIFF_BLOCK_TOPONLY="orion.annotation.diff.blockTop",s.ANNO_DIFF_CURRENT_BLOCK_TOPONLY="orion.annotation.diff.currentBlockTop",s.ANNO_DIFF_BLOCK_CONFLICT="orion.annotation.diff.blockConflict",s.ANNO_DIFF_CURRENT_BLOCK_CONFLICT="orion.annotation.diff.currentBlockConflict",s.ANNO_DIFF_ADDED_WORD="orion.annotation.diff.addedWord",s.ANNO_DIFF_CURRENT_ADDED_WORD="orion.annotation.diff.currentAddedWord",s.ANNO_DIFF_DELETED_WORD="orion.annotation.diff.deletedWord",s.ANNO_DIFF_CURRENT_DELETED_WORD="orion.annotation.diff.currentDeletedWord",s.ANNO_DIFF_EMPTY_DELETED_WORD_LEFT="orion.annotation.diff.emptyDeletedWordLeft",s.ANNO_DIFF_EMPTY_DELETED_WORD_RIGHT="orion.annotation.diff.emptyDeletedWordRight",s.ANNO_DIFF_EMPTY_ADDED_WORD_LEFT="orion.annotation.diff.emptyAddedWordLeft",s.ANNO_DIFF_EMPTY_ADDED_WORD_RIGHT="orion.annotation.diff.emptyAddedWordRight",n.AnnotationType.registerType(s.ANNO_DIFF_ADDED_BLOCK,{title:"",html:"",lineStyle:{styleClass:"annotationLine addedBlockDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_ADDED_BLOCK,{title:"",html:"",lineStyle:{styleClass:"annotationLine currentAddedBlockDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_DELETED_BLOCK,{title:"",html:"",lineStyle:{styleClass:"annotationLine deletedBlockDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_DELETED_BLOCK,{title:"",html:"",lineStyle:{styleClass:"annotationLine currentDeletedBlockDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_BLOCK_TOPONLY,{title:"",html:"",lineStyle:{styleClass:"annotationLine blockDiffTopOnly"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_BLOCK_TOPONLY,{title:"",html:"",lineStyle:{styleClass:"annotationLine currentBlockDiffTopOnly"}}),n.AnnotationType.registerType(s.ANNO_DIFF_BLOCK_CONFLICT,{title:"",html:"",lineStyle:{styleClass:"annotationLine blockDiffConflict"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_BLOCK_CONFLICT,{title:"",html:"",lineStyle:{styleClass:"annotationLine currentBlockDiffConflict"}}),n.AnnotationType.registerType(s.ANNO_DIFF_ADDED_WORD,{title:e["word added"],html:"",rangeStyle:{styleClass:"annotationRange addedWordDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_ADDED_WORD,{title:"",html:"",rangeStyle:{styleClass:"annotationRange currentAddedWordDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_DELETED_WORD,{title:e["word deleted"],html:"",rangeStyle:{styleClass:"annotationRange deletedWordDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_DELETED_WORD,{title:"",html:"",rangeStyle:{styleClass:"annotationRange currentDeletedWordDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_EMPTY_DELETED_WORD_LEFT,{title:"",html:"",rangeStyle:{styleClass:"annotationRange emptyDeletedWordDiffLeft"}}),n.AnnotationType.registerType(s.ANNO_DIFF_EMPTY_DELETED_WORD_RIGHT,{title:"",html:"",rangeStyle:{styleClass:"annotationRange emptyDeletedWordDiffRight"}}),n.AnnotationType.registerType(s.ANNO_DIFF_EMPTY_ADDED_WORD_LEFT,{title:"",html:"",rangeStyle:{styleClass:"annotationRange emptyAddedWordDiffLeft"}}),n.AnnotationType.registerType(s.ANNO_DIFF_EMPTY_ADDED_WORD_RIGHT,{title:"",html:"",rangeStyle:{styleClass:"annotationRange emptyAddedWordDiffRight"}});var a=5e3;return r.prototype={initAll:function(e,t,i,n,o,r,s){this._charOrWordDiff=e?e:"word",t&&(this._initialized=!0),this.editorWrapper=[{editor:t,diffFeeder:n},{editor:i,diffFeeder:o}],this._curveRuler=s,this._overviewRuler=r,this._overviewRuler&&this._overviewRuler.setDiffNavigator(this)},initMapper:function(e){if(e)for(var t=0;t0&&this.iterator.iterate(e),this.updateCurrentAnnotation(!0)}return t},gotoChangeUsingIndex:function(e){var t=0,i=0;if(e>=0)for(;it+n-1)){var o=e-t;return this.gotoBlock(i,o)}t+=n,i++}},gotoBlock:function(e,t){this.iterator&&((0>e||e>=this._root.children.length||0===this._root.children.length)&&(e=0),this.iterator.setCursor(void 0!==t&&t>=0&&this._root.children[e].children&&t=r.start&&t<=r.end){var s=o;if(o.children&&o.children.length>0)for(var a=0;a=d.start&&t<=d.end){s=l;break}}return s}}return null}},gotoChange:function(e,t){for(var i=0;ie&&(e=0);var t=this.getFeeder().getDiffBlocks();return t&&0!==t.length?(e>t.length-1&&(e=0),t[e][1]):-1},replaceDiffAnnotations:function(e,t,i,n){if(t&&i){var o=e.getAnnotationModel();if(o){for(var r=o.getAnnotations(),s=[];n&&r.hasNext();){var a=r.next();a.type===i&&s.push(a)}o.replaceAnnotations(s,t)}}},updateCurrentAnnotation:function(e,t){if(this.replaceAllAnnotations(!0,0,"block",!1,[]),this.replaceAllAnnotations(!0,1,"block",!1,[]),this.replaceAllAnnotations(!0,0,"word",!1,[]),this.replaceAllAnnotations(!0,1,"word",!1,[]),this.iterator){var i=this.iterator.cursor();if(i){var o,r,s={start:i.oldA.start,end:i.oldA.end},a={start:i.newA.start,end:i.newA.end};"word"===i.type?(o=this.editorWrapper[0].diffFeeder.getCurrentWordAnnoType(s,this.editorWrapper[0].editor.getTextView().getModel()),r=this.editorWrapper[1].diffFeeder.getCurrentWordAnnoType(a,this.editorWrapper[1].editor.getTextView().getModel())):(o=this.editorWrapper[0].diffFeeder.getCurrentBlockAnnoType(i.index),r=this.editorWrapper[1].diffFeeder.getCurrentBlockAnnoType(i.index)),o&&this.replaceDiffAnnotations(this.editorWrapper[0].editor,[new(n.AnnotationType.getType(o.current))(s.start,s.end)],o,!0),r&&this.replaceDiffAnnotations(this.editorWrapper[1].editor,[new(n.AnnotationType.getType(r.current))(a.start,a.end)],r,!0),e?(this.autoSelecting=!0,this.editorWrapper[0].editor.setSelection(i.oldA.start,i.oldA.end,!0),this.editorWrapper[1].editor.setSelection(i.newA.start,i.newA.end,!0),this.autoSelecting=!1):t&&(this.autoSelecting=!0,t!==this.editorWrapper[0].editor.getTextView()&&this.editorWrapper[0].editor.setSelection(i.oldA.start,i.oldA.end,!0),t!==this.editorWrapper[1].editor.getTextView()&&this.editorWrapper[1].editor.setSelection(i.newA.start,i.newA.end,!0),this.autoSelecting=!1)}}},generatePairBlockAnnotations:function(e,t){var i=this.generateBlockDiffAnnotations(0,t),n=this.generateBlockDiffAnnotations(1,t);return{parent:e,index:t,type:"block",oldA:i,newA:n}},generatePairWordAnnotations:function(e,t,i){var n=this.editorWrapper[0].diffFeeder.getTextOnBlock(t),o=this.editorWrapper[1].diffFeeder.getTextOnBlock(t),r=null,s=0,l=0;if(!(n&&o&&n.text&&o.text&&n.text.length<=a&&o.text.length<=a))return null;r=i.adaptCharDiff(n.text,o.text,"word"===this._charOrWordDiff),l=o.start,s=n.start;var d=[],h=[];this.generateWordDiffAnnotations(0,d,s,r,2,3),this.generateWordDiffAnnotations(1,h,l,r,0,1);for(var c=[],u=0;u0?t-o:0)},_positionDiffBlock:function(){var e=this.getCurrentBlockIndex();0>e&&(e=0);var t=this.getFeeder().getDiffBlocks();if(0!==t.length){if(this._setTextViewPosition(this.editorWrapper[0].editor.getTextView(),t[e][0]),this.editorWrapper[0].editor!==this.editorWrapper[1].editor){var n=i.lookUpLineIndex(this.getMapper(),0,t[e][1]);this._setTextViewPosition(this.editorWrapper[1].editor.getTextView(),n)}this._updateOverviewRuler(),this._updateCurveRuler()}},matchPositionFromOverview:function(e){if(this._initialized){var t;t=0>e?0:i.getAnnotationIndex(this.getFeeder().getDiffBlocks(),e),this.gotoBlock(t)}},gotoDiff:function(e,t){this.gotoChange(e,t)&&(this._updateOverviewRuler(),this._updateCurveRuler())},nextDiff:function(){this.iterateOnBlock(!0,!0),this._positionDiffBlock()},prevDiff:function(){this.iterateOnBlock(!1,!0),this._positionDiffBlock()},nextChange:function(){var e=this.iterateOnChange(!0);return this._positionDiffBlock(),e},prevChange:function(){this.iterateOnChange(!1),this._positionDiffBlock()}},r}(),r.DiffBlockFeeder=function(){function e(){}return e.prototype={_isAddedSide:function(){return 0===this._mapperColumnIndex},getWordAnnoTypes:function(e){e.push(this._isAddedSide()?{type:"word",current:s.ANNO_DIFF_CURRENT_ADDED_WORD,normal:s.ANNO_DIFF_ADDED_WORD,list:[]}:{type:"word",current:s.ANNO_DIFF_CURRENT_DELETED_WORD,normal:s.ANNO_DIFF_DELETED_WORD,list:[]}),e.push({type:"word",current:s.ANNO_DIFF_EMPTY_DELETED_WORD_LEFT}),e.push({type:"word",current:s.ANNO_DIFF_EMPTY_DELETED_WORD_RIGHT}),e.push({type:"word",current:s.ANNO_DIFF_EMPTY_ADDED_WORD_LEFT}),e.push({type:"word",current:s.ANNO_DIFF_EMPTY_ADDED_WORD_RIGHT})},getCurrentWordAnnoType:function(e,t){return e.start===e.end&&t?this._isAddedSide()?{current:this._repositionEmptyWord(e,t),normal:s.ANNO_DIFF_ADDED_WORD}:{current:this._repositionEmptyWord(e,t),normal:s.ANNO_DIFF_DELETED_WORD}:this._isAddedSide()?{current:s.ANNO_DIFF_CURRENT_ADDED_WORD,normal:s.ANNO_DIFF_ADDED_WORD}:{current:s.ANNO_DIFF_CURRENT_DELETED_WORD,normal:s.ANNO_DIFF_DELETED_WORD}},_repositionEmptyWord:function(e,t){var i=t.getLineAtOffset(e.start),n=t.getLineStart(i),o=t.getLineEnd(i);return n!==o?e.start===o?(e.start--,this._isAddedSide()?s.ANNO_DIFF_EMPTY_ADDED_WORD_RIGHT:s.ANNO_DIFF_EMPTY_DELETED_WORD_RIGHT):(e.end++,this._isAddedSide()?s.ANNO_DIFF_EMPTY_ADDED_WORD_LEFT:s.ANNO_DIFF_EMPTY_DELETED_WORD_LEFT):i>0&&(i--,n=t.getLineStart(i),o=t.getLineEnd(i),n!==o)?(e.start=o-1,e.end=o,this._isAddedSide()?s.ANNO_DIFF_EMPTY_ADDED_WORD_RIGHT:s.ANNO_DIFF_EMPTY_DELETED_WORD_RIGHT):this._isAddedSide()?s.ANNO_DIFF_EMPTY_ADDED_WORD_LEFT:s.ANNO_DIFF_EMPTY_DELETED_WORD_LEFT},getMapper:function(){return this._mapper},getDiffBlocks:function(){return this._diffBlocks},getDiffBlockH:function(e){if(!this._diffBlocks||0===this._diffBlocks.length)return-1;var t=this._diffBlocks[e][1];return-1===t?0:this._mapper[t][this._mapperColumnIndex]},getOverviewLineCount:function(){return this._textModel.getLineCount()},getLineNumber:function(e){return e},getCharRange:function(e){if(!this._diffBlocks||0===this._diffBlocks.length)return null;var t=this._diffBlocks[e][1],i=this._diffBlocks[e][0],n=i+this._mapper[t][this._mapperColumnIndex]-1,o=this._textModel.getLineStart(i);if(i>n)return{start:o,end:o};var r=this._textModel.getLineEnd(n,!0);return{start:o,end:r}},getTextOnBlock:function(e){if(!this._diffBlocks||0===this._diffBlocks.length)return null;var t=this._diffBlocks[e][1];0===this._mapper[t][0]||0===this._mapper[t][1]||0===this._mapper[t][2];var i=this.getCharRange(e);return{start:i.start,text:this._textModel.getText(i.start,i.end)}},isMapperEmpty:function(){return 0===this._mapper.length}},e}(),r.TwoWayDiffBlockFeeder=function(){function e(e,t,i,n){this._mapperColumnIndex=i,this._reverseAnnotation=n,this.init(e,t)}return e.prototype=new r.DiffBlockFeeder,e.prototype._isAddedSide=function(){return this._reverseAnnotation?0!==this._mapperColumnIndex:0===this._mapperColumnIndex},e.prototype.init=function(e,t){if(this._textModel=e,this._diffBlocks=void 0,t){this._mapper=t,this._diffBlocks=[];for(var i=0,n=0;n=this._gapBlocks[t][0]&&e0){if(e.length<1||e.length>2)return;this._syntaxHighlighters=[{highlighter:this.options.highlighters[0],target:e[0]}],2===e.length&&2===this.options.highlighters.length&&this._syntaxHighlighters.push({highlighter:this.options.highlighters[1],target:e[1]})}},_highlightSyntax:function(){if(this._syntaxHighlighters){var e=[];this._syntaxHighlighters.forEach(function(t){e.push(t.highlighter.highlight(t.target.fileName,t.target.contentType,t.target.editor))}.bind(this)),t.all(e,function(e){return{_error:e}}).then(function(){this._diffNavigator.renderAnnotations(this.isWhitespaceIgnored()),this._diffNavigator.gotoBlock(this.options.blockNumber-1,this.options.changeNumber-1),this.dispatchEvent({type:"contentLoaded"}),this.options.toggler&&this.options.toggler.dispatchEvent({type:"contentLoaded"})}.bind(this))}else window.setTimeout(function(){this._diffNavigator.renderAnnotations(this.isWhitespaceIgnored()),this._diffNavigator.gotoBlock(this.options.blockNumber-1,this.options.changeNumber-1),this.dispatchEvent({type:"contentLoaded"}),this.options.toggler&&this.options.toggler.dispatchEvent({type:"contentLoaded"})}.bind(this),50)},isWhitespaceIgnored:function(){return this.getWidget().options.ignoreWhitespace},ignoreWhitespace:function(e){var t=this.getWidget().options;if(t.ignoreWhitespace=e,t.diffProvider&&t.diffContent){var i=e?"true":"false";t.diffProvider._diffProvider.getDiffContent(t.resource,{ignoreWS:i}).then(function(e){t.diffContent=t.hasConflicts?e.split("diff --git")[1]:e,this.getWidget().refresh(!0,!0)}.bind(this),function(){})}else this.getWidget().refresh(!0,!0)},setOptions:function(e,t){if(t&&this._clearOptions(),this.options||(this.options={}),e&&Object.keys(e).forEach(function(t){this.options[t]=e[t]}.bind(this)),e.newFileOnRight){var i=this.options.newFile;this.options.newFile=this.options.oldFile,this.options.oldFile=i}},getOptions:function(){return this.options},getCurrentDiffPos:function(){return this._diffNavigator.getCurrentPosition()},initDiffNav:function(){this._diffNavigator.gotoBlock(0,0)},nextDiff:function(){this._diffNavigator.nextDiff()},prevDiff:function(){this._diffNavigator.prevDiff()},nextChange:function(){return this._diffNavigator.nextChange()},prevChange:function(){this._diffNavigator.prevChange()},getWidget:function(){return this},startup:function(){this.initEditors(),this.refresh(!0)},initEditors:function(){},initImageMode:function(){}},e}(),f.TwoWayCompareView=function(){function i(e){f.CompareView.call(this,e),this.setOptions(e,!0),this._diffNavigator=new p.DiffTreeNavigator("word"),this.type="twoWay",this._uiFactory=this.options.uiFactory,this._uiFactory||(this._uiFactory=new h.TwoWayCompareUIFactory({parentDivID:this.options.parentDivId,showTitle:this.options.showTitle?this.options.showTitle:!1,showLineStatus:this.options.showLineStatus?this.options.showLineStatus:!1}),this._uiFactory.buildUI()),this._viewLoadedCounter=0,this.options.commandProvider&&this.options.commandProvider.initCommands(this),this._curveRuler=new r.CompareCurveRuler(this._uiFactory.getDiffCanvasDiv())}return i.prototype=Object.create(f.CompareView.prototype),i.prototype.initEditors=function(t){this.options.preCreate&&this.options.preCreate(),this._editors=[],this._editors.push(this._createEditor(t,this._uiFactory.getEditorParentDiv(!1),this._uiFactory.getStatusDiv(!1),this.options.oldFile)),this._editors.push(this._createEditor(t,this._uiFactory.getEditorParentDiv(!0),this._uiFactory.getStatusDiv(!0),this.options.newFile,!0)),this._overviewRuler=new r.CompareOverviewRuler("right",{styleClass:"ruler overview"},null,function(e){this._diffNavigator.matchPositionFromOverview(e)}.bind(this)),this.options.postCreate&&this.options.postCreate(),window.onbeforeunload=function(){return this.isDirty()?e["There are unsaved changes."]:void 0}.bind(this)},i.prototype.disableAnnoBookMark=function(){this._disableAnnoBookMark(this._editors)},i.prototype.initImageMode=function(){this._editors&&(this._editors.forEach(function(e){e.destroy()}),this._editors=null),this._uiFactory.getEditorParentDiv(!0).classList.add("compareEditorParentImageMode"),this._uiFactory.getEditorParentDiv().classList.add("compareEditorParentImageMode"),this._uiFactory.disableTitle(),this._uiFactory.disableLineStatus(),this._imageMode=!0},i.prototype.getImageMode=function(){return this._imageMode},i.prototype.getEditors=function(){return this._editors},i.prototype.gotoDiff=function(e,t,i){var n=i?this._editors[1].getTextView():this._editors[0].getTextView(),o=n.getModel().getLineStart(e)+t;this._diffNavigator.gotoDiff(o,n)},i.prototype.copyToLeft=function(){this._curveRuler.copyTo(!0)},i.prototype.copyToRight=function(){this._curveRuler.copyTo(!1)},i.prototype.resizeEditors=function(){this._editors.forEach(function(e){e.getTextView().resize()})},i.prototype.getSplitter=function(){return this._uiFactory.getSplitter()},i.prototype._createEditor=function(t,i,n,o,r){var l="undefined"==typeof o.readonly?!0:o.readonly,h=function(){var e=new d.TextView({parent:i,readonly:l,tabSize:4});this._viewLoadedCounter++,2===this._viewLoadedCounter&&this._diffNavigator.matchPositionFromOverview(-1),this.onLoad&&this.onLoad();var t=this.getSplitter();return t&&t.addResizeListener(function(t){if(t){var i=!1;i=this._uiFactory.isLeftPane(t)?r:!r,i&&e.resize()}}.bind(this)),e}.bind(this),c=o.keyBindingFactory;c||(c=new a.KeyBindingsFactory);var u=null;if(n){var p="",f="";u=function(t,i){n&&(f=i?e["ERROR: "]+t:t,n.textContent=p+f)}}var g=new s.Editor({textViewFactory:h,undoStackFactory:new a.UndoFactory,annotationFactory:new a.AnnotationFactory,keyBindingFactory:c,statusReporter:u,domNode:i});g.installTextView(),g.setInput(null,null,o.Content?o.Content:t),g.setOverviewRulerVisible(!1);var _=g.getTextView();return _.addEventListener("Selection",function(e){var t=Array.isArray(e.newValue)?e.newValue:[e.newValue];t.length>1||!t[0].isEmpty()||!this._diffNavigator.autoSelecting&&this._diffNavigator.editorWrapper[0].diffFeeder&&this._diffNavigator.gotoDiff(t[0].getCaret(),_)}.bind(this)),_.getModel().addEventListener("Changed",function(e){this._curveRuler.onChanged(e,!r)||(this.options.mapper=null)}.bind(this)),r?_.addEventListener("Scroll",function(){this._curveRuler&&(this._curveRuler.matchPositionFrom(!0),this._curveRuler.render()),this.onScroll&&this.onScroll()}.bind(this)):_.addEventListener("Scroll",function(){this._curveRuler&&this._curveRuler.render()}.bind(this)),g},i.prototype.isDirty=function(){return this._editors?this._editors.some(function(e){return e.isDirty()}):!1},i.prototype._destroy=function(){this._editors&&(this._diffNavigator.destroy(),this._editors.forEach(function(e){e.destroy()}),this._uiFactory.destroy())},i.prototype.destroy=function(){this._destroyed=!0,this._destroy()},i.prototype.addRulers=function(){if(this._editors&&!this._hasRuler){var e=new r.LineNumberCompareRuler(this._diffNavigator,0,"left",{styleClass:"ruler lines"},{styleClass:"rulerLines odd"},{styleClass:"rulerLines even"}),t=new r.LineNumberCompareRuler(this._diffNavigator,0,"left",{styleClass:"ruler lines"},{styleClass:"rulerLines odd"},{styleClass:"rulerLines even"});this._editors[1].getTextView().addRuler(e),this._editors[0].getTextView().addRuler(t),this._editors[0].getTextView().addRuler(this._overviewRuler),this._hasRuler=!0}},i.prototype.refresh=function(e,i,n){if(!this._destroyed){if(this._imageMode){this.options.commandProvider&&this.options.commandProvider.renderCommands(this);var o=this;return this._loadImageFile(this.options.newFile.URL,this._uiFactory.getEditorParentDiv(!0)).then(function(e){return o._loadImageFile(o.options.oldFile.URL,o._uiFactory.getEditorParentDiv()).then(function(i){return(new t).resolve(e>i?e:i)})})}var r=this._generateMapper(i,this.options.oldFile.Content,this.options.newFile.Content,this.options.diffContent,this.options.hasConflicts,!this.options.toggler),s=this.options.oldFile.Content,a=this.options.newFile.Content;"string"!=typeof a&&(a=r.output);var l=new p.TwoWayDiffBlockFeeder(this._editors[0].getTextView().getModel(),r.mapper,1,this.options.newFileOnRight),d=new p.TwoWayDiffBlockFeeder(this._editors[1].getTextView().getModel(),r.mapper,0,this.options.newFileOnRight);this._diffNavigator.initAll(this.options.charDiff?"char":"word",this._editors[0],this._editors[1],l,d,this._overviewRuler,this._curveRuler),this._curveRuler.init(r.mapper,this._editors[1],this._editors[0],this._diffNavigator),e&&("number"==typeof n?1===n?this._editors[1].setInput(this.options.newFile.Name,null,a):this._editors[0].setInput(this.options.oldFile.Name,null,s):(this._editors[1].setInput(this.options.newFile.Name,null,a),this._editors[0].setInput(this.options.oldFile.Name,null,s))),this._initSyntaxHighlighter([{fileName:this.options.newFile.Name,contentType:this.options.newFile.Type,editor:this._editors[1]},{fileName:this.options.oldFile.Name,contentType:this.options.oldFile.Type,editor:this._editors[0]}]),this._highlightSyntax(),this.options.commandProvider&&this.options.commandProvider.renderCommands(this),this.addRulers(),2===this._viewLoadedCounter&&this._diffNavigator.gotoBlock(this.options.blockNumber-1,this.options.changeNumber-1),this.refreshTitle(0),this.refreshTitle(1);var h=this._editors[1].getTextView().getModel().getLineCount()*this._editors[1].getTextView().getLineHeight()+5,c=this._editors[0].getTextView().getModel().getLineCount()*this._editors[0].getTextView().getLineHeight()+5;return h>c?h:c}},i.prototype.refreshTitle=function(e,t){var i,o=this.options.newFile.Name,r=this.options.oldFile.Name,s="/",a=" ... ",l=o.split(s),d=r.split(s),h=[],c=[],u=!1;for(i=0;i1||!t[0].isEmpty()||!this._diffNavigator.autoSelecting&&this._diffNavigator.editorWrapper[0].diffFeeder&&this._diffNavigator.gotoDiff(t[0].getCaret(),this._textView)}.bind(this))},i.prototype.disableAnnoBookMark=function(){this._disableAnnoBookMark([this._editor])},i.prototype.initImageMode=function(){this._editor&&(this._editor.destroy(),this._editor=null),n.node(this._editorDiv).classList.add("compareEditorParentImageMode"),this._imageMode=!0},i.prototype.getImageMode=function(){return this._imageMode},i.prototype._initDiffPosition=function(e){var t=e.getModel();if(t&&t.getAnnotations){var i=t.getAnnotations();if(i.length>0){var n=i[0][0],o=e.getLineHeight(),r=e.getClientArea(),s=Math.floor(r.height/o/3);e.setTopIndex(n-s>0?n-s:0)}}},i.prototype.refresh=function(i,o){if(!this._destroyed){if(this._imageMode){this.options.commandProvider&&this.options.commandProvider.renderCommands(this);var r=this;return this._loadImageFile(this.options.newFile.URL,n.node(this._editorDiv),!0).then(function(e){return r._loadImageFile(r.options.oldFile.URL,n.node(r._editorDiv)).then(function(i){return(new t).resolve(e+i+20)})})}var s=this._generateMapper(o,this.options.oldFile.Content,this.options.newFile.Content,this.options.diffContent,this.options.hasConflicts,!this.options.toggler);if(s.submoduleChanged)switch(s.submoduleChanged){case"removed":this._textView.getModel().setText(e["Removed Submodule Message"]);break;case"added":this._textView.getModel().setText(e["Added Submodule Message"])}else{this._mapper=s.mapper,this._textView.getModel().setText(this.options.oldFile.Content);var a=new p.inlineDiffBlockFeeder(s.mapper,1),l=new p.inlineDiffBlockFeeder(s.mapper,0);c.mergeDiffBlocks(this._textView.getModel(),l.getDiffBlocks(),s.mapper,s.diffArray.array,s.diffArray.index,this._diffParser._lineDelimiter),a.setModel(this._textView.getModel()),l.setModel(this._textView.getModel()),this._diffNavigator.initAll(this.options.charDiff?"char":"word",this._editor,this._editor,a,l,this._overviewRuler),this._initSyntaxHighlighter([{fileName:this.options.oldFile.Name,contentType:this.options.oldFile.Type,editor:this._editor}]),this._highlightSyntax(),this.options.commandProvider&&this.options.commandProvider.renderCommands(this),this.removeRulers(),this.addRulers();var d=this._textView.getTopIndex();this._textView.redrawLines(d,d+1,this._overviewRuler),this._textView.redrawLines(d,d+1,this._rulerOrigin),this._textView.redrawLines(d,d+1,this._rulerNew),this._diffNavigator.gotoBlock(this.options.blockNumber-1,this.options.changeNumber-1)}return this._textView.getLineHeight()*this._textView.getModel().getLineCount()+5}},i.prototype.setConflicting=function(e){this._conflcit=e},i.prototype.gotoDiff=function(e){this._diffNavigator.gotoChangeUsingIndex(e)},i.prototype.gotoLine=function(e,t,i,n){"number"!=typeof t&&(t=0);var o=c.convertMergedLineNumber(this._mapper,e),r=function(){n(o)}.bind(this);this._editor.onGotoLine(o,t,i,r)},i.prototype.getMainEditor=function(){return this._editor?this._editor:null},i.prototype.getLineNumber=function(e,t,i){if(t){var n=this._diffNavigator.getFeeder(i?!1:!0);return n?n.getLineNumber(e):e}var o=c.convertMergedLineNumber(this._mapper,e,i);return o},i}(),f.toggleableCompareView=function(){function e(e,t){i.attach(this),t&&(t.toggler=this),this._widget="inline"===e?new f.InlineCompareView(t):new f.TwoWayCompareView(t)}return e.prototype={startup:function(){this._widget.startup()},initImageMode:function(){this._imageMode=!0,this._widget.initImageMode()},_toggle:function(e){this._widget.destroy(),n.empty(n.node(e.parentDivId)),this._widget="inline"===this._widget.type?new f.TwoWayCompareView(e):new f.InlineCompareView(e),this._imageMode?this._widget.initImageMode():this._widget.initEditors(),this._widget.refresh(!0),e.onInputChanged&&"twoWay"===this._widget.type&&e.onInputChanged()},toggle:function(){var e=this._widget.options;if(!this._imageMode){var t=this._widget.getCurrentDiffPos();e.blockNumber=t.block,e.changeNumber=t.change}this._toggle(e)},isDirty:function(){return this._widget.isDirty()},destroy:function(){return this._widget.destroy()},getWidget:function(){return this._widget}},e}(),f}),define("orion/compare/compareCommands",["i18n!orion/compare/nls/messages","orion/commands","orion/Deferred","orion/keyBinding","orion/webui/littlelib","orion/EventTarget"],function(e,t,i,n,o,r){var s={};return s.CompareCommandFactory=function(){function s(e){r.attach(this),this.setOptions(e,!0)}return s.prototype={setOptions:function(e,t){t&&(this.options={}),this.options||(this.options={}),e&&Object.keys(e).forEach(function(t){this.options[t]=e[t]}.bind(this))},getOptions:function(){return this.options},initCommands:function(o){var r=this.options.commandSpanId,s=this.options.toggleCommandSpanId,a=this.options.commandService;if(a&&(r||s)){var l=new t.Command({name:e.CpCurChangeRightToLeft,tooltip:e.CpCurChangeRightToLeft,imageClass:"core-sprite-leftarrow",id:"orion.compare.copyToLeft",groupId:"orion.compareGroup",visibleWhen:function(){return"twoWay"===o.type&&!o.getImageMode()&&o.options.newFile&&!o.options.newFile.readonly}.bind(this),callback:function(e){e.items.copyToLeft()}}),d=new t.Command({name:e.CpCurChangeLeftToRight,tooltip:e.CpCurChangeLeftToRight,imageClass:"core-sprite-rightarrow",id:"orion.compare.copyToRight",groupId:"orion.compareGroup",visibleWhen:function(){return"twoWay"===o.type&&!o.getImageMode()&&o.options.oldFile&&!o.options.oldFile.readonly}.bind(this),callback:function(e){e.items.copyToRight()}}),h=new t.Command({tooltip:e.IgnoreWhitespaceTooltip,name:e.IgnoreWhitespace,imageClass:"core-sprite-whitespace",id:"orion.compare.ignoreWhitespace",groupId:"orion.compareGroup",type:"toggle",visibleWhen:function(t){var i=t.isWhitespaceIgnored();return h.checked=i,h.name=i?e.UseWhitespace:e.IgnoreWhitespace,h.tooltip=i?e.UseWhitespaceTooltip:e.IgnoreWhitespaceTooltip,!0},preCallback:function(t){var n=t.handler.getWidget();if("function"==typeof n.options.onSave&&n.isDirty()){var o=window.confirm(e.confirmUnsavedChanges);return o?n.options.onSave(o):(new i).resolve()}return(new i).resolve(!0)},callback:function(e){e.items.ignoreWhitespace(h.checked),this.dispatchEvent({type:"compareConfigChanged",name:"ignoreWhiteSpace",value:h.checked})}.bind(this)}),c=new t.Command({tooltip:e["Switch to unified diff"],name:e.Unified,imageClass:"compare-sprite-inline-2way",id:"orion.compare.toggleInline2Way",groupId:"orion.compareGroup",type:"switch",visibleWhen:function(t){if(!t.options.toggler)return!1;var i="twoWay"===t.options.toggler.getWidget().type;return c.checked=!i,c.name=i?e.Unified:e["Side by side"],c.tooltip=i?e["Switch to unified diff"]:e["Switch to side by side diff"],!0},preCallback:function(t){var n=t.handler.getWidget();if("function"==typeof n.options.onSave&&n.isDirty()){var o=window.confirm(e.confirmUnsavedChanges);return o?n.options.onSave(o):(new i).resolve()}return(new i).resolve(!0)},callback:function(e){this.dispatchEvent({type:"compareConfigChanged",name:"mode",value:"twoWay"===e.items.options.toggler.getWidget().type?"inline":"twoWay"}),e.items.options.toggler.toggle()}.bind(this)}),u=new t.Command({name:e["Next diff block"],tooltip:e["Next diff block"],imageClass:"core-sprite-move-down",id:"orion.compare.nextDiff",groupId:"orion.compareGroup",visibleWhen:function(){return!o.getImageMode()},callback:function(e){e.items.nextDiff()}}),p=new t.Command({name:e["Previous diff block"],tooltip:e["Previous diff block"],imageClass:"core-sprite-move-up",id:"orion.compare.prevDiff",groupId:"orion.compareGroup",visibleWhen:function(){return!o.getImageMode()},callback:function(e){e.items.prevDiff()}}),f=new t.Command({name:e["Next diff change"],tooltip:e["Next diff change"],imageClass:"core-sprite-move-down",id:"orion.compare.nextChange",groupId:"orion.compareGroup",visibleWhen:function(){return!o.getImageMode()},callback:function(e){e.items.nextChange()}}),g=new t.Command({name:e["Previous diff change"],tooltip:e["Previous diff change"],imageClass:"core-sprite-move-up",id:"orion.compare.prevChange",groupId:"orion.compareGroup",visibleWhen:function(){return!o.getImageMode()},callback:function(e){e.items.prevChange(e)}});a.addCommand(l),a.addCommand(d),a.addCommand(h),a.addCommand(c),a.addCommand(u),a.addCommand(p),a.addCommand(f),a.addCommand(g),s?a.registerCommandContribution(s,"orion.compare.toggleInline2Way",108):r&&a.registerCommandContribution(r,"orion.compare.toggleInline2Way",108),r&&(a.registerCommandContribution(r,"orion.compare.copyToLeft",110,null,!1,new n.KeyBinding(37,!0,!1,!0)),a.registerCommandContribution(r,"orion.compare.copyToRight",111,null,!1,new n.KeyBinding(39,!0,!1,!0)),a.registerCommandContribution(r,"orion.compare.nextDiff",112,null,!1,new n.KeyBinding(40,!0)),a.registerCommandContribution(r,"orion.compare.prevDiff",113,null,!1,new n.KeyBinding(38,!0)),o.options.wordLevelNav?(a.registerCommandContribution(r,"orion.compare.nextChange",114,null,!1,new n.KeyBinding(40,!0,!0)),a.registerCommandContribution(r,"orion.compare.prevChange",115,null,!1,new n.KeyBinding(38,!0,!0))):(a.registerCommandContribution(r,"orion.compare.nextChange",114,null,!0,new n.KeyBinding(40,!0,!0)),a.registerCommandContribution(r,"orion.compare.prevChange",115,null,!0,new n.KeyBinding(38,!0,!0))),a.registerCommandContribution(r,"orion.compare.ignoreWhitespace",109))}},renderCommands:function(e){var t=this.options.commandSpanId,i=this.options.toggleCommandSpanId,n=this.options.commandService;n&&(t||i)&&(i&&(o.empty(o.node(i)),n.renderCommands(i,i,e,e,"tool",null)),t&&(o.empty(o.node(t)),this.options.gridRenderer&&this.options.gridRenderer.navGridHolder?(this.options.gridRenderer.navGridHolder.splice(0,this.options.gridRenderer.navGridHolder.length),this.options.gridRenderer.additionalCmdRender?this.options.gridRenderer.before?(this.options.gridRenderer.additionalCmdRender(this.options.gridRenderer.navGridHolder),n.renderCommands(t,t,e,e,"tool",null,this.options.gridRenderer.navGridHolder)):(n.renderCommands(t,t,e,e,"tool",null,this.options.gridRenderer.navGridHolder),this.options.gridRenderer.additionalCmdRender(this.options.gridRenderer.navGridHolder)):n.renderCommands(t,t,e,e,"tool",null,this.options.gridRenderer.navGridHolder)):n.renderCommands(t,t,e,e,"tool",null)))}},s}(),s}),define("compare/builder/compare",["orion/commandRegistry","orion/staticDataSource","orion/contentTypes","orion/Deferred","orion/webui/littlelib","orion/compare/compareView","orion/compare/compareCommands"],function(e,t,i,n,o,r,s){function a(e){return u.getFilenameContentType(e)}function l(e){var t=new n,i=new XMLHttpRequest;return i.open("GET",e,!0),i.onreadystatechange=function(){if(4===i.readyState){var e="undefined"!=typeof i.response?i.response:i.responseText,n="string"==typeof e?e:null,o=i.status;o>=200&&400>o?t.resolve(n):t.reject(n)}},i.send(),t}function d(e){if(!e)return e;var t=o.node(e);if(t){if("ul"!==t.nodeName.toLowerCase()){var i=document.createElement("ul");return i.id=e+"__compareCmdUL",i.classList.add("layoutLeft"),i.classList.add("commandList"),t.appendChild(i),i.id}t.classList.add("commandList")}return e}function h(e,i,n,o,l){var h=e;if(!h.highlighters&&h.oldFile&&h.oldFile.Name&&h.newFile&&h.newFile.Name&&(h.highlighters=[new t.SyntaxHighlighter,new t.SyntaxHighlighter]),h.oldFile&&h.oldFile.Name&&(h.oldFile.Type=a(h.oldFile.Name)),h.newFile&&h.newFile.Name&&(h.newFile.Type=a(h.newFile.Name)),i||l){var u=new s.CompareCommandFactory({commandService:c,commandSpanId:d(i),toggleCommandSpanId:d(l)});h.commandProvider=u}var p="inline"===n?"inline":"twoWay";this.compareView=o?new r.toggleableCompareView(p,h):"inline"===p?new r.inlineCompareView(h):new r.TwoWayCompareView(h),this.compareView.startup()}var c=new e.CommandRegistry({}),u=new i.ContentTypeRegistry(t.ContentTypes);return h.prototype={getCompareView:function(){return this.compareView},setFileNames:function(e,t){var i=this.getCompareView().getWidget().options;i.newFile&&e&&(i.newFile.Name=e,i.newFile.Type=a(e)),i.oldFile&&t&&(i.oldFile.Name=t,i.oldFile.Type=a(t))},refresh:function(){var e=this.getCompareView().getWidget().options;if(e.oldFile.URL&&e.newFile.URL){var t=[];t.push(l(e.oldFile.URL)),t.push(l(e.newFile.URL)),n.all(t,function(e){return{_error:e}}).then(function(e){this.getCompareView().getWidget().options.oldFile.Content=e[0],this.getCompareView().getWidget().options.newFile.Content=e[1],this.getCompareView().getWidget().refresh(!0)}.bind(this))}else this.getCompareView().getWidget().refresh(!0)}},h}),define(["compare/builder/compare"],function(e){return e}); \ No newline at end of file diff --git a/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-11.0/OrionIconFont-Regular.eot b/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-12.0/OrionIconFont-Regular.eot similarity index 100% rename from plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-11.0/OrionIconFont-Regular.eot rename to plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-12.0/OrionIconFont-Regular.eot diff --git a/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-11.0/OrionIconFont-Regular.svg b/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-12.0/OrionIconFont-Regular.svg similarity index 100% rename from plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-11.0/OrionIconFont-Regular.svg rename to plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-12.0/OrionIconFont-Regular.svg diff --git a/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-11.0/OrionIconFont-Regular.ttf b/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-12.0/OrionIconFont-Regular.ttf similarity index 100% rename from plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-11.0/OrionIconFont-Regular.ttf rename to plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-12.0/OrionIconFont-Regular.ttf diff --git a/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-11.0/OrionIconFont-Regular.woff b/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-12.0/OrionIconFont-Regular.woff similarity index 100% rename from plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-11.0/OrionIconFont-Regular.woff rename to plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-12.0/OrionIconFont-Regular.woff diff --git a/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-12.0/built-compare-amd.min.js b/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-12.0/built-compare-amd.min.js new file mode 100644 index 00000000000..658a2c7ef95 --- /dev/null +++ b/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-12.0/built-compare-amd.min.js @@ -0,0 +1,18 @@ +!function(){"use strict";function e(e,t,i,n,o,r){t[e]&&(i.push(e),(t[e]===!0||1===t[e])&&n.push(o+e+"/"+r))}function t(e,t,i,n,o){var r=n+t+"/"+o;require._fileExists(e.toUrl(r+".js"))&&i.push(r)}function i(e,t,n){var o;for(o in t)!t.hasOwnProperty(o)||e.hasOwnProperty(o)&&!n?"object"==typeof t[o]&&(!e[o]&&t[o]&&(e[o]={}),i(e[o],t[o],n)):e[o]=t[o]}var n=/(^.*(^|\/)nls(\/|$))([^\/]*)\/?([^\/]*)/;define("i18n",["module"],function(o){var r=o.config?o.config():{};return r=r||{},{version:"2.0.4",load:function(o,s,a,l){l=l||{},l.locale&&(r.locale=l.locale);var d,c,h,u=n.exec(o),p=u[1],f=u[4],g=u[5],_=f.split("-"),m=[],v={},y="";if(u[5]?(p=u[1],d=p+g):(d=o,g=u[4],f=r.locale,f||(f=r.locale="undefined"==typeof navigator?"root":(navigator.language||navigator.userLanguage||"root").toLowerCase()),_=f.split("-")),l.isBuild){for(m.push(d),t(s,"root",m,p,g),c=0;c<_.length;c++)h=_[c],y+=(y?"-":"")+h,t(s,y,m,p,g);if(l.locales){var x,b;for(x=0;x-1&&o[e];e--)r=o[e],n=t[r],(n===!0||1===n)&&(n=s(p+r+"/"+g)),i(v,n);a(v)})})}}})}(),define("orion/nls/messages",{root:!0}),define("orion/nls/root/messages",{Navigator:"Navigator",Sites:"Sites",Shell:"Shell","Get Plugins":"Get Plug-ins",Global:"Global",Editor:"Editor",EditorRelatedLink:"Show Current Folder",EditorRelatedLinkParent:"Show Enclosing Folder",EditorLinkWorkspace:"Edit",EditorRelatedLinkProj:"Show Project",sidebar:"Sidebar","Filter bindings":"Filter bindings",BindingPrompt:"Enter the new binding",NoBinding:"---",orionClientLabel:"Orion client repository","Orion Editor":"Text Editor","Orion Image Viewer":"Image Viewer","Orion Markdown Editor":"Markdown Editor","Orion Markdown Viewer":"Markdown Viewer","Orion JSON Editor":"JSON Editor","View on Site":"View on Site","View this file or folder on a web site hosted by Orion":"View this file or folder on a web site hosted by Orion.",ShowAllKeyBindings:"Show a list of all the keybindings on this page","Show Keys":"Show Keys",HideShowBannerFooter:"Hide or show the page banner","Toggle banner and footer":"Toggle banner",ChooseFileOpenEditor:"Choose a file by name and open an editor on it",FindFile:"Open File...","System Configuration Details":"System Configuration Details","System Config Tooltip":"Go to the System Configuration Details page","Background Operations":"Background Operations","Background Operations Tooltip":"Go to the Background Operations page","Operation status is unknown":"Operation status is unknown","Unknown item":"Unknown item",NoSearchAvailableErr:"Can't search: no search service is available",Related:"Related",Options:"Options","LOG: ":"LOG: ",View:"View",SplashTitle:"Setting up Workspace",SplashTitleSettings:"Loading Settings",SplashTitleGit:"Loading Git Repositories",LoadingPage:"Loading Page",LoadingPlugins:"Loading Plugins",LoadingResources:"Loading Resources",plugin_started:'"${0}" started',"plugin_lazy activation":'"${0}" lazily activated',plugin_starting:'"${0}" starting',"no parent":"no parent","no tree model":"no tree model","no renderer":"no renderer","could not find table row ":"could not find table row ",Operations:"Operations","Operations running":"Operations running",SomeOpWarning:"Some operations finished with warning",SomeOpErr:"Some operations finished with error","no service registry":"no service registry",Tasks:"Tasks",Close:"Close","Expand all":"Expand all","Collapse all":"Collapse all",Search:"Search","Advanced search":"Advanced search",Submit:"Submit",More:"More","Recent searches":"Recent searches","Regular expression":"Regular expression","Search options":"Search options","Global search":"Global search","Orion Home":"Home","Close notification":"Close notification",OpPressSpaceMsg:"Operations - Press spacebar to show current operations","Toggle side panel":"Toggle side panel","Open or close the side panel":"Open or close the side panel",Projects:"Projects","Toggle Sidebar":"Toggle Sidebar","Sample HTML5 Site":"Sample HTML5 Site","Generate an HTML5 'Hello World' website, including JavaScript, HTML, and CSS files.":"Generate an HTML5 'Hello World' website, including JavaScript, HTML, and CSS files.","Sample Orion Plugin":"Sample Orion Plug-in","Generate a sample plugin for integrating with Orion.":"Generate a sample plug-in for integrating with Orion.",Browser:"Web Browser",OutlineProgress:"Getting outline for ${0} from ${1}",outlineTimeout:"Outline service timed out. Try reloading the page and opening the outline again.",UnknownError:"An unknown error occurred.",Filter:"Filter (* = any string, ? = any character)",TemplateExplorerLabel:"Templates",OpenTemplateExplorer:"Open Template Explorer",Edit:"Edit",CentralNavTooltip:"Toggle Navigation Menu","Wrote: ${0}":"Wrote: ${0}",GenerateHTML:"Generate HTML file",GenerateHTMLTooltip:"Write an HTML file generated from the current Markdown editor content","alt text":"alt text",blockquote:"blockquote",code:"code","code (block)":"code (block)","code (span)":"code (span)",emphasis:"emphasis","fenced code (${0})":"fenced code (${0})","header (${0})":"header (${0})","horizontal rule":"horizontal rule",label:"label","link (auto)":"link (auto)","link (image)":"link (image)","link (inline)":"link (inline)","link label":"link label","link label (optional)":"link label (optional)","link (ref)":"link (ref)","list item (bullet)":"list item (bullet)","list item (numbered)":"list item (numbered)","strikethrough (${0})":"strikethrough (${0})",strong:"strong","table (${0})":"table (${0})",text:"text","title (optional)":"title (optional)",url:"url",workedProgress:"${0} (${1}/${2})",TogglePaneOrientationTooltip:"Toggle split pane orientation",WarningDuplicateLinkId:"Duplicate link ID: ${0} (link IDs are not case-sensitive)",WarningHeaderTooDeep:"Header level cannot exceed 6",WarningLinkHasNoText:"Link has no text",WarningLinkHasNoURL:"Link has no URL",WarningOrderedListItem:"Ordered list item within unordered list",WarningOrderedListShouldStartAt1:"The first item in an ordered list should have index 1",WarningUndefinedLinkId:"Undefined link ID: ${0}",WarningUnorderedListItem:"Unordered list item within ordered list",PageTitleFormat:"${0} - ${1}",KeyCTRL:"Ctrl",KeySHIFT:"Shift",KeyALT:"Alt",KeyBKSPC:"Backspace",KeyDEL:"Del",KeyEND:"End",KeyENTER:"Enter",KeyESCAPE:"Esc",KeyHOME:"Home",KeyINSERT:"Ins",KeyPAGEDOWN:"Page Down",KeyPAGEUP:"Page Up",KeySPACE:"Space",KeyTAB:"Tab","a year":"a year",years:"${0} years","a month":"a month",months:"${0} months","a day":"a day",days:"${0} days","an hour":"an hour",hours:"${0} hours","a minute":"a minute",minutes:"${0} minutes",timeAgo:"${0} ago",justNow:"just now",fixAll:"Fix all"}),define("orion/util",[],function(){function e(e){var t=arguments;return e.replace(/\$\{([^\}]+)\}/g,function(e,i){return t[(i<<0)+1]})}function t(e,t){return e.createElementNS?e.createElementNS(x,t):e.createElement(t)}function i(e,t){t.addEventListener("keydown",function(t){9!==t.keyCode||t.shiftKey||(t.preventDefault(),e.focus())}),e.addEventListener("keydown",function(e){9===e.keyCode&&e.shiftKey&&(e.preventDefault(),t.focus())})}var n=navigator.userAgent,o=-1!==n.indexOf("MSIE")||-1!==n.indexOf("Trident")?document.documentMode:void 0,r=parseFloat(n.split("Firefox/")[1]||n.split("Minefield/")[1])||void 0,s=-1!==n.indexOf("Opera")?parseFloat(n.split("Version/")[1]):void 0,a=parseFloat(n.split("Chrome/")[1])||void 0,l=-1!==n.indexOf("Safari")&&!a,d=parseFloat(n.split("WebKit/")[1])||void 0,c=-1!==n.indexOf("Android"),h=-1!==n.indexOf("iPad"),u=-1!==n.indexOf("iPhone"),p=h||u,f=-1!==n.indexOf("Electron"),g=-1!==navigator.platform.indexOf("Mac"),_=-1!==navigator.platform.indexOf("Win"),m=-1!==navigator.platform.indexOf("Linux"),v="undefined"!=typeof document&&"ontouchstart"in document.createElement("input"),y=_?"\r\n":"\n",x="http://www.w3.org/1999/xhtml";return{formatMessage:e,createElement:t,confineDialogTab:i,isIE:o,isFirefox:r,isOpera:s,isChrome:a,isSafari:l,isWebkit:d,isAndroid:c,isIPad:h,isIPhone:u,isIOS:p,isElectron:f,isMac:g,isWindows:_,isLinux:m,isTouch:v,platformDelimiter:y}}),define("orion/webui/littlelib",["orion/util"],function(e){function t(e,t){return t||(t=document),t.querySelector(e)}function i(e,t){return t||(t=document),t.querySelectorAll(e)}function n(e,t){return Array.prototype.slice.call(i(e,t))}function o(e){var t=e;return"string"==typeof e&&(t=document.getElementById(e)),t}function r(e,t){if(!e||!t)return!1;if(e===t)return!0;var i=e.compareDocumentPosition(t);return Boolean(16&i)}function s(e){var t=e.getBoundingClientRect(),i=Math.max(document.documentElement.scrollLeft,document.body.scrollLeft),n=Math.max(document.documentElement.scrollTop,document.body.scrollTop);return{left:t.left+i,top:t.top+n,width:t.width,height:t.height}}function a(e){for(;e.hasChildNodes();){var t=e.firstChild;e.removeChild(t)}}function l(t){var i=t.tabIndex;if(0===i&&e.isIE){var n={a:!0,body:!0,button:!0,frame:!0,iframe:!0,img:!0,input:!0,isindex:!0,object:!0,select:!0,textarea:!0};n[t.nodeName.toLowerCase()]||t.attributes.tabIndex||(i=-1)}return i}function d(e){if(l(e)>=0)return e;if(e.hasChildNodes())for(var t=0;t=0)return e;if(e.hasChildNodes())for(var t=e.childNodes.length-1;t>=0;t--){var i=c(e.childNodes[t]);if(i)return i}return null}function h(e,t){if(3===e.nodeType){var i=w.exec(e.nodeValue);i&&i.length>1&&t(e,i)}if(e.hasChildNodes())for(var n=0;n2&&-1!==r.indexOf("px",r.length-2)){r=r.slice(0,-2);var s=parseInt(r,10);return s!==s?0:s}}return 0}function p(e,t){h(e,function(e,i){var n=t[i[1]]||i[1];e.parentNode.replaceChild(document.createTextNode(n),e)})}function f(e,t){h(e,function(e,i){var n=t[i[1]];if(n){var o=document.createRange(),r=i.index;o.setStart(e,r),o.setEnd(e,r+i[0].length),o.deleteContents(),o.insertNode(n)}})}function g(t,i){function n(e){C.forEach(function(t){var i=!1,n=t.excludeNodes.some(function(t){return document.body.contains(t)?(i=!0,t.contains(e.target)):!1});if(i&&!n)try{t.dismiss(e)}catch(o){"undefined"!=typeof console&&console&&console.error(o&&o.message)}}),C=C.filter(function(e){return e.excludeNodes.some(function(e){return document.body.contains(e)})})}null===C&&(C=[],document.addEventListener("click",n,!0),e.isIOS&&document.addEventListener("touchend",function(e){function t(){e.target.removeEventListener("click",t)}0===e.touches.length&&e.target.addEventListener("click",t)},!1)),C.push({excludeNodes:t,dismiss:i})}function _(e){C=C.filter(function(t){return e!==t.dismiss})}function m(e){for(var t=e.parentNode,i=document.documentElement;t&&t!==i;){var n=window.getComputedStyle(t,null);if(!n)break;var o=n.getPropertyValue("overflow-y");if("auto"===o||"scroll"===o)break;t=t.parentNode}return t}function v(e){window.document.all&&(e.keyCode=0),e.preventDefault&&(e.preventDefault(),e.stopPropagation())}function y(e){for(var t=document.getElementsByTagName("iframe"),i=0;i1?i.children:i.firstChild}var w=/\$\{([^\}]+)\}/,C=null,T={BKSPC:8,TAB:9,ENTER:13,SHIFT:16,CONTROL:17,ALT:18,ESCAPE:27,SPACE:32,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,INSERT:45,DEL:46,COMMAND:991},L=Object.create(null);return Object.keys(T).forEach(function(e){L[T[e]]=e}),{$:t,$$:i,$$array:n,node:o,contains:r,bounds:s,empty:a,firstTabbable:d,lastTabbable:c,pixelValueOf:u,stop:v,processTextNodes:p,processDOMNodes:f,addAutoDismiss:g,setFramesEnabled:y,getOffsetParent:m,removeAutoDismiss:_,keyName:x,KEY:T,createNodes:b}}),define("orion/commandsProxy",["orion/util","orion/webui/littlelib"],function(e,t){function i(t,i){function n(t){if(e.isMac){if(t.metaKey&&!t.altKey)return t.shiftKey||t.ctrlKey||65!==t.keyCode&&67!==t.keyCode&&86!==t.keyCode&&88!==t.keyCode&&90!==t.keyCode?!1:!0;if(t.ctrlKey)return!1}else{if(t.ctrlKey&&!t.altKey)return t.shiftKey||65!==t.keyCode&&67!==t.keyCode&&86!==t.keyCode&&88!==t.keyCode&&90!==t.keyCode?!1:!0;if(t.altKey&&!t.ctrlKey)return!1;if(t.ctrlKey&&t.altKey)return!1}if(t["char"])return t["char"].length>0;if(t.charCode||t.keyCode){var i=t.charCode||t.keyCode;switch(i){case 8:case 9:case 13:case 46:return!0;default:return i>=32&&112>i||i>123}}return!1}if(t=t||window.event,n(t)){if("true"===t.target.contentEditable)return;var o=t.target.nodeName.toLowerCase();if("input"===o){var r=t.target.type.toLowerCase();switch(r){case"text":case"password":case"search":case"color":case"date":case"datetime":case"datetime-local":case"email":case"month":case"number":case"range":case"tel":case"time":case"url":case"week":return}}else if("textarea"===o)return}i(t)}function n(){this._init()}return n.prototype={destroy:function(){this._listener&&(document.removeEventListener("keydown",this._listener),this._listener=null)},setProxy:function(e){this.proxy=e},setKeyBindings:function(e){this.bindings=e},_init:function(){var e=this;document.addEventListener("keydown",this._listener=function(n){return i(n,function(i){var n=e.proxy,o=e.bindings;if(o&&n)for(var r=0;r0){e.setFramesEnabled(!1),this._boundAutoDismiss&&e.removeAutoDismiss(this._boundAutoDismiss),this._boundAutoDismiss=this._autoDismiss.bind(this);var o=e.$$array(".dropdownSubMenu",this._dropdownNode);e.addAutoDismiss([this._triggerNode].concat(o),this._boundAutoDismiss),this._triggerNode.classList.add("dropdownTriggerOpen"),this._selectionClass&&this._triggerNode.classList.add(this._selectionClass),this._dropdownNode.classList.add("dropdownMenuOpen"),this._isVisible=!0,this._positionDropdown(t),this._focusDropdownNode(),i=!0,this._parentDropdown&&this._parentDropdown.submenuOpen(this)}}return i},_focusDropdownNode:function(){this._dropdownNode.focus()},_autoDismiss:function(e){if(this.close(!1)&&this._dropdownNode.contains(e.target))for(var t=this._parentDropdown;t;)t.close(!1),t=t._parentDropdown},_positionDropdown:function(){if(this._dropdownNode.style.left="",this._dropdownNode.style.top="",this._positioningNode)return void(this._dropdownNode.style.left=this._positioningNode.offsetLeft+"px");var t=e.bounds(this._dropdownNode),i=e.bounds(document.body);if(t.left+t.width>i.left+i.width)if(this._triggerNode.classList.contains("dropdownMenuItem"))this._dropdownNode.style.left=-t.width+"px";else{var n=e.bounds(this._boundingNode(this._triggerNode)),o=e.bounds(this._triggerNode);this._dropdownNode.style.left=o.left-n.left-t.width+o.width+"px"}var r=t.top+t.height-(i.top+i.height);r>0&&(this._dropdownNode.style.top=Math.floor(this._dropdownNode.style.top-r)+"px")},_boundingNode:function(e){var t=window.getComputedStyle(e,null);if(null===t)return e;var i=t.getPropertyValue("position");return"absolute"!==i&&e.parentNode&&e!==document.body?this._boundingNode(e.parentNode):e},close:function(t){var i=!1;return this.isVisible()&&(this._triggerNode.classList.remove("dropdownTriggerOpen"),this._selectionClass&&this._triggerNode.classList.remove(this._selectionClass),this._dropdownNode.classList.remove("dropdownMenuOpen"),e.setFramesEnabled(!0),t&&this._triggerNode.focus(),this._isVisible=!1,this._selectedItem&&(this._selectedItem.classList.remove("dropdownMenuItemSelected"),this._selectedItem=null),this._boundAutoDismiss&&(e.removeAutoDismiss(this._boundAutoDismiss),this._boundAutoDismiss=null),i=!0),i},getItems:function(){var t=e.$$array("li:not(.dropdownSeparator) > .dropdownMenuItem",this._dropdownNode,!0),i=[],n=this;return t.forEach(function(e){e.parentNode.parentNode===n._dropdownNode&&i.push(e)}),i.forEach(function(t){t._hasDropdownMouseover||(t.addEventListener("mouseover",function(i){t.dropdown?t.dropdown.open(i):(n._closeSelectedSubmenu(),e.stop(i)),n._selectItem(t)}),t._hasDropdownMouseover=!0)}),i},empty:function(){var t=e.$$array("li",this._dropdownNode),i=this;t.forEach(function(e){e.parentNode===i._dropdownNode&&e.parentNode.removeChild(e)})},_dropdownKeyDown:function(t){if(t.keyCode===e.KEY.UP||t.keyCode===e.KEY.DOWN||t.keyCode===e.KEY.RIGHT||t.keyCode===e.KEY.ENTER||t.keyCode===e.KEY.LEFT){var i=this.getItems();if(i.length&&i.length>0){if(this._selectedItem){var n=i.indexOf(this._selectedItem);0>n&&(n=i.indexOf(this._selectedItem.parentNode)),n>=0&&(t.keyCode===e.KEY.UP&&n>0?(n--,this._selectItem(i[n])):t.keyCode===e.KEY.DOWN&&n/im,l=/]*>\s*([\s\S]+)\s*<\/body>/im,d="undefined"!=typeof location&&location.href,c=d&&location.protocol&&location.protocol.replace(/\:/,""),h=d&&location.hostname,u=d&&(location.port||void 0),p={},f=e.config&&e.config()||{};return t={version:"2.0.12",strip:function(e){if(e){e=e.replace(a,"");var t=e.match(l);t&&(e=t[1])}else e="";return e},jsEscape:function(e){return e.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r").replace(/[\u2028]/g,"\\u2028").replace(/[\u2029]/g,"\\u2029")},createXhr:f.createXhr||function(){var e,t,i;if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;if("undefined"!=typeof ActiveXObject)for(t=0;3>t;t+=1){i=s[t];try{e=new ActiveXObject(i)}catch(n){}if(e){s=[i];break}}return e},parseName:function(e){var t,i,n,o=!1,r=e.indexOf("."),s=0===e.indexOf("./")||0===e.indexOf("../");return-1!==r&&(!s||r>1)?(t=e.substring(0,r),i=e.substring(r+1,e.length)):t=e,n=i||t,r=n.indexOf("!"),-1!==r&&(o="strip"===n.substring(r+1),n=n.substring(0,r),i?i=n:t=n),{moduleName:t,ext:i,strip:o}},xdRegExp:/^((\w+)\:)?\/\/([^\/\\]+)/,useXhr:function(e,i,n,o){var r,s,a,l=t.xdRegExp.exec(e);return l?(r=l[2],s=l[3],s=s.split(":"),a=s[1],s=s[0],!(r&&r!==i||s&&s.toLowerCase()!==n.toLowerCase()||(a||s)&&a!==o)):!0},finishLoad:function(e,i,n,o){n=i?t.strip(n):n,f.isBuild&&(p[e]=n),o(n)},load:function(e,i,n,o){if(o&&o.isBuild&&!o.inlineText)return void n();f.isBuild=o&&o.isBuild;var r=t.parseName(e),s=r.moduleName+(r.ext?"."+r.ext:""),a=i.toUrl(s),l=f.useXhr||t.useXhr;return 0===a.indexOf("empty:")?void n():void(!d||l(a,c,h,u)?t.get(a,function(i){t.finishLoad(e,r.strip,i,n)},function(e){n.error&&n.error(e)}):i([s],function(e){t.finishLoad(r.moduleName+"."+r.ext,r.strip,e,n)}))},write:function(e,i,n){if(p.hasOwnProperty(i)){var o=t.jsEscape(p[i]);n.asModule(e+"!"+i,"define(function () { return '"+o+"';});\n")}},writeFile:function(e,i,n,o,r){var s=t.parseName(i),a=s.ext?"."+s.ext:"",l=s.moduleName+a,d=n.toUrl(s.moduleName+a)+".js";t.load(l,n,function(){var i=function(e){return o(d,e)};i.asModule=function(e,t){return o.asModule(e,d,t)},t.write(e,l,i,r)},r)}},"node"===f.env||!f.env&&"undefined"!=typeof process&&process.versions&&process.versions.node&&!process.versions["node-webkit"]?(i=require.nodeRequire("fs"),t.get=function(e,t,n){try{var o=i.readFileSync(e,"utf8");0===o.indexOf("")&&(o=o.substring(1)),t(o)}catch(r){n&&n(r)}}):"xhr"===f.env||!f.env&&t.createXhr()?t.get=function(e,i,n,o){var r,s=t.createXhr();if(s.open("GET",e,!0),o)for(r in o)o.hasOwnProperty(r)&&s.setRequestHeader(r.toLowerCase(),o[r]);f.onXhr&&f.onXhr(s,e),s.onreadystatechange=function(){var t,o;4===s.readyState&&(t=s.status||0,t>399&&600>t?(o=new Error(e+" HTTP status: "+t),o.xhr=s,n&&n(o)):i(s.responseText),f.onXhrComplete&&f.onXhrComplete(s,e))},s.send(null)}:"rhino"===f.env||!f.env&&"undefined"!=typeof Packages&&"undefined"!=typeof java?t.get=function(e,t){var i,n,o="utf-8",r=new java.io.File(e),s=java.lang.System.getProperty("line.separator"),a=new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(r),o)),l="";try{for(i=new java.lang.StringBuffer,n=a.readLine(),n&&n.length()&&65279===n.charAt(0)&&(n=n.substring(1)),null!==n&&i.append(n);null!==(n=a.readLine());)i.append(s),i.append(n);l=String(i.toString())}finally{a.close()}t(l)}:("xpconnect"===f.env||!f.env&&"undefined"!=typeof Components&&Components.classes&&Components.interfaces)&&(n=Components.classes,o=Components.interfaces,Components.utils["import"]("resource://gre/modules/FileUtils.jsm"),r="@mozilla.org/windows-registry-key;1"in n,t.get=function(e,t){var i,s,a,l={};r&&(e=e.replace(/\//g,"\\")),a=new FileUtils.File(e);try{i=n["@mozilla.org/network/file-input-stream;1"].createInstance(o.nsIFileInputStream),i.init(a,1,0,!1),s=n["@mozilla.org/intl/converter-input-stream;1"].createInstance(o.nsIConverterInputStream),s.init(i,"utf-8",i.available(),o.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER),s.readString(i.available(),l),s.close(),i.close(),t(l.value)}catch(d){throw new Error((a&&a.path||"")+": "+d)}}),t}),define("text!orion/webui/dropdowntriggerbutton.html",[],function(){return''}),define("text!orion/webui/dropdowntriggerbuttonwitharrow.html",[],function(){return''}),define("text!orion/webui/checkedmenuitem.html",[],function(){return'
  • '}),define("orion/webui/tooltip",["orion/webui/littlelib"],function(e){function t(e){this._init(e)}return t.prototype={_init:function(t){if(this._node=e.node(t.node),!this._node)throw"no dom node for tooltip found";this._position=t.position||["right","above","below","left"],this._text=t.text,this._hideDelay=void 0===t.hideDelay?200:t.hideDelay,this._tailSize=t.tailSize||10,this._trigger=t.trigger||"mouseover",this._afterShowing=t.afterShowing,this._afterHiding=t.afterHiding;var i=this;if("click"===this._trigger)this._showDelay=0,this._node.addEventListener("click",this._clickHandler=function(t){t.target===i._node&&(i.show(),e.stop(t))},!1);else if("mouseover"===this._trigger){this._showDelay=void 0===t.showDelay?500:t.showDelay;var n=["mouseout","click"];this._node.addEventListener("mouseover",this._mouseoverHandler=function(t){e.contains(i._node,t.target)&&(i.show(),e.stop(t))},!1),this._leaveHandler=function(t){e.contains(i._node,t.target)&&i.hide()};for(var o=0;op){if(!i)return!1;r=p-a.height-1}if(s+a.width>u){if(!i)return!1;s=u-a.width-1}if(c>s){if(!i)return!1;s=c+4}if(h>r){if(!i)return!1;r=h+4}return this._tail&&this._tail.previousPosition!==t&&(this._tip.removeChild(this._tail),this._tail=null),this._tail||(this._tail=document.createElement("span"),this._tail.classList.add("tooltipTailFrom"+t),"above"===t||"left"===t?this._tip.appendChild(this._tail):this._tip.insertBefore(this._tail,this._tipInner),this._tail.previousPosition=t),this._tip.style.top=r+"px",this._tip.style.left=s+"px",!0},contentContainer:function(){return this._makeTipNode(),this._tipInner},isShowing:function(){return this._tip&&this._tip.classList.contains("tooltipShowing")},show:function(){this.isShowing()||(this._timeout&&(window.clearTimeout(this._timeout),this._timeout=null),this._showDelay?this._timeout=window.setTimeout(this._showImmediately.bind(this),this._showDelay):this._showImmediately())},_showImmediately:function(){for(var e=!1,t=0;!e&&t"+n.name),n.callback.call(n,i)}.bind(this),!1),s.addEventListener("keydown",function(e){(e.keyCode===t.KEY.ENTER||e.keyCode===t.KEY.SPACE)&&(l.logEvent("command","invoke",this.id+">"+n.name),n.callback.call(n,i))}.bind(this),!1)}else r._generateMenuSeparator(e)}.bind(this))},getChoices:function(e,t,i){return this.choiceCallback?this.choiceCallback.call(t,e,i):null},makeChoiceCallback:function(e,t){return function(i){e.callback&&e.callback.call(e,t,i)}},hasImage:function(){return this.imageClass||this.image!==w}},b.prototype.constructor=b,{Command:b,CommandInvocation:x,createDropdownMenu:g,createCheckedMenuItem:_,createQuickfixItem:m,createCommandItem:v,createCommandMenuItem:y,executeBinding:c,setKeyBindingProvider:d,localKeyBindings:T,getKeyBindings:u,processKey:p,NO_IMAGE:w,_testMethodProcessKey:h}}),define("orion/keyBinding",["orion/util"],function(e){function t(e,t,i,n,o,r){this.type=r||"keydown",this.keyCode="string"==typeof e&&"keydown"===this.type?e.toUpperCase().charCodeAt(0):e,this.mod1=void 0!==t&&null!==t?t:!1,this.mod2=void 0!==i&&null!==i?i:!1,this.mod3=void 0!==n&&null!==n?n:!1,this.mod4=void 0!==o&&null!==o?o:!1}function i(e){this.keys=e}return t.prototype={getKeys:function(){return[this]},match:function(t,i){if(void 0!==i){if(0!==i)return!1}else if(t instanceof Array){if(t.length>1)return!1;t=t[0]}if(t.type!==this.type)return!1;if(this.keyCode===t.keyCode||this.keyCode===String.fromCharCode(e.isOpera?t.which:void 0!==t.charCode?t.charCode:t.keyCode)){var n=e.isMac?t.metaKey:t.ctrlKey;return this.mod1!==n?!1:"keydown"===this.type&&this.mod2!==t.shiftKey?!1:this.mod3!==t.altKey?!1:e.isMac&&this.mod4!==t.ctrlKey?!1:!0}return!1},equals:function(e){return e?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:!1}},i.prototype={getKeys:function(){return this.keys.slice(0)},match:function(e,t){var i=this.keys;if(void 0!==t)return t>i.length?!1:i[t].match(e)?t===i.length-1?!0:t+1:!1;if(e instanceof Array||(e=[e]),e.length>i.length)return!1;var n;for(n=0;n":".";break;case 191:l=i.mod2?"?":"/";break;case 192:l=i.mod2?"~":"`";break;case 219:l=i.mod2?"{":"[";break;case 220:l=i.mod2?"|":"\\";break;case 221:l=i.mod2?"}":"]";break;case 222:l=i.mod2?'"':"'"}return l?n+l:i.keyCode>=112&&i.keyCode<=123?n+"F"+(i.keyCode-111):n+String.fromCharCode(i.keyCode)}function o(e){for(var t="",i=e.getKeys(),o=0;o0)if(e.createTextRange){var o=e.createTextRange();o.collapse(!0),o.moveStart("character",0),o.moveEnd("character",n),o.select()}else e.setSelectionRange?e.setSelectionRange(0,n):void 0!==e.selectionStart&&(e.selectionStart=0,e.selectionEnd=n);else e.select()}},0)}function s(e){var t=-1!==window.navigator.platform.indexOf("Mac");return t&&e.metaKey||!t&&e.ctrlKey}function a(e,t){t&&s(t)?window.open(e):window.location=e}function l(e,i){var n=document.createElement("button");return n.className="orionButton commandButton commandMargins",n.addEventListener("click",function(e){i(),t.stop(e)},!1),e&&n.appendChild(document.createTextNode(e)),n}function d(){}function c(e,t){if(!e||!e.tagName)return!1;switch(e.tagName.toLowerCase()){case"button":case"fieldset":case"form":case"input":case"keygen":case"label":case"legend":case"meter":case"optgroup":case"output":case"progress":case"select":case"textarea":return!0}return e.parentNode===t?!1:e.parentNode&&c(e.parentNode,t)}function h(e,t,i){var n=i?0:1;return e.substring(0,e.length-encodeURIComponent(t).length-n)}function u(e){var t=new Date,i=new Date(e),n=t.getTime()-i.getTime(),o=Math.floor(n/1e3/60/60/24/365);n-=1e3*o*60*60*24*365;var r=Math.floor(n/1e3/60/60/24/30);n-=1e3*r*60*60*24*30;var s=Math.floor(n/1e3/60/60/24);n-=1e3*s*60*60*24;var a=Math.floor(n/1e3/60/60);n-=1e3*a*60*60;var l=Math.floor(n/1e3/60);n-=1e3*l*60;var d=Math.floor(n/1e3);return{year:o,month:r,day:s,hour:a,minute:l,second:d}}function p(t,n,o){return t>0?1===t?e[n]:i.formatMessage(e[o],t):""}function f(e){var t=u(e),i=p(t.year,"a year","years"),n=p(t.month,"a month","months"),o=p(t.day,"a day","days"),r=p(t.hour,"an hour","hours"),s=p(t.minute,"a minute","minutes"),a="";return i?a=t.year>0?i:i+n:n?a=t.month>0?n:n+o:o?a=t.day>0?o:o+r:r?a=t.hour>0?r:r+s:s&&(a=s),a}function g(t){var n=f(t);return n?i.formatMessage(e.timeAgo,n):e.justNow}var _=-1!==navigator.platform.indexOf("Mac"),m=Object.create(null);return m[t.KEY.DOWN]="↓",m[t.KEY.UP]="↑",m[t.KEY.RIGHT]="→",m[t.KEY.LEFT]="←",_&&(m[t.KEY.BKSPC]="⌫",m[t.KEY.DEL]="⌦",m[t.KEY.END]="⇲",m[t.KEY.ENTER]="⏎",m[t.KEY.ESCAPE]="⎋",m[t.KEY.HOME]="⇱",m[t.KEY.PAGEDOWN]="⇟",m[t.KEY.PAGEUP]="⇞",m[t.KEY.SPACE]="␣",m[t.KEY.TAB]="⇥"),{getUserKeyString:o,getUserText:r,openInNewWindow:s,followLink:a,createButton:l,createDropdownButton:d,isFormElement:c,path2FolderName:h,timeElapsed:f,displayableTimeElapsed:g}}),define("text!orion/webui/submenutriggerbutton.html",[],function(){return''}),function(e,t){"function"==typeof define&&define.amd?define("orion/Deferred",t):"object"==typeof exports?module.exports=t():(e.orion=e.orion||{},e.orion.Deferred=t())}(this,function(){function e(){for(var e;e=r.shift();)e();s=!1}function t(e){r.push(e),s||(s=!0,a())}function i(e){return function(t){e(t)}}function n(e,t,n){try{var o=e(t),r=o&&("object"==typeof o||"function"==typeof o)&&o.then;if("function"==typeof r)if(o===n.promise)n.reject(new TypeError);else{var s=o.cancel;"function"==typeof s?n._parentCancel=s.bind(o):delete n._parentCancel,r.call(o,i(n.resolve),i(n.reject),i(n.progress))}else n.resolve(o)}catch(a){n.reject(a)}}function o(){function e(){for(var e;e=d.shift();){var t=e.deferred,i="fulfilled"===l?"resolve":"reject",o=e[i];"function"==typeof o?n(o,a,t):t[i](a)}}function i(i){delete c._parentCancel,l="rejected",a=i,d.length&&t(e)}function r(n){function s(e){return function(t){l&&"assumed"!==l||e(t)}}delete c._parentCancel;try{var h=n&&("object"==typeof n||"function"==typeof n)&&n.then;if("function"==typeof h)if(n===c)i(new TypeError);else{l="assumed";var u=n&&n.cancel;if("function"!=typeof u){var p=new o;n=p.promise;try{h(p.resolve,p.reject,p.progress)}catch(f){p.reject(f)}u=n.cancel,h=n.then}a=n,h.call(n,s(r),s(i)),c._parentCancel=u.bind(n)}else l="fulfilled",a=n,d.length&&t(e)}catch(g){s(i)(g)}}function s(){var e=c._parentCancel;if(e)delete c._parentCancel,e();else if(!l){var t=new Error("Cancel");t.name="Cancel",i(t)}}var a,l,d=[],c=this;this.resolve=function(e){return l||r(e),c},this.reject=function(e){return l||i(e),c},this.progress=function(e){return l||d.forEach(function(t){if(t.progress)try{t.progress(e)}catch(i){}}),c.promise},this.cancel=function(){return c._parentCancel?setTimeout(s,0):s(),c},this.then=function(i,n,r){var s=new o;return s._parentCancel=c.promise.cancel,d.push({resolve:i,reject:n,progress:r,deferred:s}),("fulfilled"===l||"rejected"===l)&&t(e),s.promise},this.promise={then:c.then,cancel:c.cancel}}var r=[],s=!1,a=function(){if("undefined"!=typeof process&&"function"==typeof process.nextTick){var t=process.nextTick;return function(){t(e)}}if("function"==typeof MutationObserver){var i=document.createElement("div"),n=new MutationObserver(e);return n.observe(i,{attributes:!0}),function(){i.setAttribute("class","_tick")}}return function(){setTimeout(e,0)}}();return o.all=function(e,t){function i(e,t){a||(s[e]=t,0===--r&&l.resolve(s))}function n(e,n){if(!a){if(t)try{return void i(e,t(n))}catch(o){n=o}l.reject(n)}}var r=e.length,s=[],a=!1,l=new o;return l.then(void 0,function(){a=!0,e.forEach(function(e){e.cancel&&e.cancel()})}),0===r?l.resolve(s):e.forEach(function(e,t){e.then(i.bind(void 0,t),n.bind(void 0,t))}),l.promise},o.when=function(e,t,i,n){var r,s;return e&&"function"==typeof e.then?r=e:(s=new o,s.resolve(e),r=s.promise),r.then(t,i,n)},o}),define("orion/commandRegistry",["orion/commands","orion/keyBinding","orion/explorers/navigationUtils","orion/i18nUtil","orion/PageUtil","orion/uiUtils","orion/webui/littlelib","orion/webui/dropdown","orion/webui/tooltip","text!orion/webui/submenutriggerbutton.html","orion/metrics","orion/Deferred","orion/EventTarget"],function(e,t,i,n,o,r,s,a,l,d,c,h,u){function p(e){this._commandList={},this._contributionsByScopeId={},this._activeBindings={},this._urlBindings={},this._pendingBindings={},this._parameterCollector=null,this._init(e||{})}function f(e,t){this.token=e,this.parameterName=t}function g(e,t,i){this.event=e,this.handler=t,this.capture=i||!1}function _(e,t,i,n,o,r,s){this.name=e,this.type=t,this.label=i,this.value=n,this.lines=o||1,this.validator=s,this.eventListeners=Array.isArray(r)?r:r?[r]:[]}function m(e,t,i){this._storeParameters(e),this._hasOptionalParameters=t&&t.hasOptionalParameters,this._options=t,this.optionsRequested=!1,this.getParameters=i,this.clientCollect=t&&t.clientCollect,this.getParameterElement=t&&t.getParameterElement,this.getSubmitName=t&&t.getSubmitName,this.getCancelName=t&&t.getCancelName,this.message=t&&t.message}return p.prototype={_init:function(t){this._selectionService=t.selection;var i=this;e.setKeyBindingProvider(function(){return i._activeBindings}),u.attach(p.prototype),this.addEventListener("bindingChanged",function(e){this._handleBindingChanges(e)}.bind(this)),this.addEventListener=function(e,t){this._bindingOverrides&&"bindingChanged"===e&&this._updateBindingOverrides(t),p.prototype.addEventListener.call(this,e,t)}},processURL:function(e){for(var t in this._urlBindings)if(this._urlBindings[t]&&this._urlBindings[t].urlBinding&&this._urlBindings[t].command){var i=this._urlBindings[t].urlBinding.match(e);if(i){var n=this._urlBindings[t],o=n.command,r=n.invocation;if(r&&r.parameters&&o.callback){r.parameters.setValue(i.parameterName,i.parameterValue);var s=this;return void window.setTimeout(function(){s._invoke(r)},0)}}}},findCommand:function(e){return this._commandList[e]},runCommand:function(t,i,n,o,r,s){var a=this;if(i){var l=this._commandList[t],d=l&&(l.visibleWhen?l.visibleWhen(i):!0);if(d&&l.callback){var c=new e.CommandInvocation(n,i,r,l,a);return c.domParent=s,a._invoke(c,o)}}else{var h=this._urlBindings[t];if(h&&h.command&&h.command.callback)return a._invoke(h.invocation,o)}},getSelectionService:function(){return this._selectionService},setParameterCollector:function(e){this._parameterCollector=e},openParameterCollector:function(e,t,i){this._parameterCollector&&(this._parameterCollector.close(),this._parameterCollector.open(e,t,i))},confirm:function(e,t,i,n,o,r){var s=!1;if(!this._parameterCollector||o)s=window.confirm(t),r(s);else{var a=this,d=function(){r(s)},c=function(){a._parameterCollector.close()},h=function(e,o){var r=document.createElement("span");r.classList.add("parameterPrompt"),r.textContent=t,e.appendChild(r);var a=document.createElement("button");a.addEventListener("click",function(){s=!0,d(),c()},!1),o.appendChild(a),a.appendChild(document.createTextNode(i)),a.className="dismissButton";var l=document.createElement("button");return l.addEventListener("click",function(){s=!1,c()},!1),o.appendChild(l),l.appendChild(document.createTextNode(n)),l.className="dismissButton",a};this._parameterCollector.close();var u=this._parameterCollector.open(e,h,function(){});if(!u){var p=new l.Tooltip({node:e,afterHiding:function(){this.destroy()},trigger:"click",position:["below","right","above","left"]}),f=p.contentContainer();f.classList.add("parameterPopup");var g=window.document.activeElement;c=function(){g&&g.focus(),p.destroy()};var _=document.createElement("div");_.classList.add("parameterMessage"),f.appendChild(_);var m=document.createElement("div");f.appendChild(m),m.classList.add("layoutRight"),m.classList.add("parametersDismiss");var v=h(_,m);p.show(),v&&window.setTimeout(function(){v.focus(),v.select&&v.select()},0)}}},closeParameterCollector:function(){this._parameterCollector&&this._parameterCollector.close()},collectsParameters:function(){return this._parameterCollector},_invoke:function(e,t){return this._collectAndInvoke(e.makeCopy(t),!1)},_collectAndInvoke:function(e,t,i){if(e){if(!(this._parameterCollector&&e.parameters&&e.parameters.hasParameters()&&(t||e.parameters.shouldCollectParameters())))return c.logEvent("command","invoke",e.command.id),e.command.callback.call(e.handler||window,e);var n=!1;if(e.parameters.updateParameters(e),e.parameters.shouldCollectParameters()&&(n=this._parameterCollector.collectParameters(e,i),!n)){var o=new l.Tooltip({node:e.domNode||e.domParent,afterHiding:function(){this.destroy(),e.domParent&&e.domParent.classList.remove("parameterPopupOpen")},trigger:"click",position:["below","right","above","left"]}),r=o.contentContainer();r.classList.add("parameterPopup");var s=window.document.activeElement,a=this._parameterCollector.getFillFunction(e,function(){s&&s.focus(),o.destroy(),e.domParent&&e.domParent.classList.remove("parameterPopupOpen")},i)(r);o.show(),e.domParent&&e.domParent.classList.add("parameterPopupOpen"),a&&window.setTimeout(function(){a.focus(),a.select&&a.select()},0),n=!0}if(!n)return c.logEvent("command","invoke",e.command.id),e.command.callback.call(e.handler||window,e)}else window.console.log("Client attempted to invoke command without an available (rendered) command invocation")},collectParameters:function(e,t){this._collectAndInvoke(e,!0,t)},showKeyBindings:function(t){function i(t){return function(){e.executeBinding(t)}}var n,o={},r=[];for(var s in this._activeBindings)n=this._activeBindings[s],n&&n.keyBinding&&n.command&&(n.command.name||n.command.tooltip)&&r.push(n);r.sort(function(e,t){var i=e.command.name||e.command.tooltip,n=t.command.name||t.command.tooltip;return i.localeCompare(n)});for(var a=0;a0&&(t.createHeader(l),o[l].forEach(function(e){t.createItem(e.keyBinding,e.command.name||e.command.tooltip,e.command.id,i(e))}))},_handleBindingChanges:function(t){var i=this.findCommand(t.id);if(i){var n=this._activeBindings[t.id];n?n.keyBinding=t.newBinding:this._addBinding(i,"key",t.newBinding)}if(this._renderedCommands&&this._renderedCommands[t.id])for(var o=this._renderedCommands[t.id],s=Object.keys(o),a=0;a=0;t--){var i=this._bindingOverrides[t];if(i.id===e)return i.newBinding}return null},addCommand:function(e){this._commandList[e.id]=e;var t=this._pendingBindings[e.id];if(t){var i=this;t.forEach(function(t){i._addBinding(e,t.type,t.binding,t.bindingOnly)}),delete this._pendingBindings[e.id]}},addCommandGroup:function(e,t,i,n,o,r,s,a,l,d,c){this._contributionsByScopeId[e]||(this._contributionsByScopeId[e]={});var h=this._contributionsByScopeId[e];o&&(h=this._createEntryForPath(h,o)),h[t]?(n&&(h[t].title=n),i&&(h[t].position=i),s&&(h[t].imageClass=s),a&&(h[t].tooltip=a),l&&(h[t].selectionClass=l),c&&(h[t].extraClass=c),d===!0?h[t].pretendDefaultActionId=!0:h[t].defaultActionId=d,h[t].emptyGroupMessage=r):(h[t]={title:n,position:i,emptyGroupMessage:r,imageClass:s,tooltip:a,selectionClass:l,defaultActionId:d===!0?null:d,pretendDefaultActionId:d===!0,children:{},extraClasses:c},h.sortedContributions=null)},_createEntryForPath:function(e,t){if(t){var i=t.split("/");i.forEach(function(t){t.length>1&&(e[t]||(e[t]={position:0,children:{}},e.sortedContributions=null),e=e[t].children)})}return e},registerSelectionService:function(e,t){this._contributionsByScopeId[e]||(this._contributionsByScopeId[e]={}),this._contributionsByScopeId[e].localSelectionService=t},setServiceRegistry:function(e){this._serviceRegistry=e,this._prefService=e.getService("orion.core.preference"),this._prefService&&(this._getBindingOverrides().then(function(e){this._bindingOverrides=e,this._updateBindingOverrides()}.bind(this)),this._prefService.addEventListener("changed",function(e){"/KeyBindings"===e.namespace&&this._getBindingOverrides().then(function(e){if(e.length>this._bindingOverrides.length)for(var t=this._bindingOverrides.length;t1){if(!n[e])return;n=n[e].children}})}delete n[t],n.sortedContributions=null}},_addBinding:function(e,t,i,n){if(!e.id)throw new Error("No command id: "+e);"key"===t?this._activeBindings[e.id]={command:e,keyBinding:i,bindingOnly:n}:"url"===t&&(this._urlBindings[e.id]={command:e,urlBinding:i,bindingOnly:n})},_addPendingBinding:function(e,t,i,n){this._pendingBindings[e]=this._pendingBindings[e]||[],this._pendingBindings[e].push({type:t,binding:i,bindingOnly:n})},_checkForTrailingSeparator:function(e,t,i){var n;if(("tool"===t||"button"===t)&&(n=e.childNodes.length>0?e.childNodes[e.childNodes.length-1]:null,n&&n.classList.contains("commandSeparator")))return i?(e.removeChild(n),!1):!0;if("menu"===t){var o=s.$$array("li > *",e);if(o.length>0&&o[o.length-1].classList.contains("dropdownSeparator"))return n=o[o.length-1],i?(n.parentNode.parentNode.removeChild(n.parentNode),!1):!0}return!1},renderCommands:function(e,t,i,n,o,r,a){if("string"!=typeof e)throw"a scope id for rendering must be specified";if(t=s.node(t),!t)throw"no parent";var l=this._contributionsByScopeId[e];if(!i&&l){var d=l.localSelectionService||this._selectionService,c=this;return void(d&&d.getSelections(function(i){c.renderCommands(e,t,i,n,o,r)}))}l&&(this._render(e,l,t,i,n,o||"button",r,a),this._checkForTrailingSeparator(t,o,!0))},destroy:function(e){if(e=s.node(e),!e)throw"no parent";for(;e.hasChildNodes();){var t=e.firstChild;t.commandTooltip&&t.commandTooltip.destroy(),t.emptyGroupTooltip&&t.emptyGroupTooltip.destroy(),this.destroy(t),e.removeChild(t)}},_render:function(t,n,o,s,a,d,c,h){var u=n.sortedContributions;if(!u){u=[];var p=!1;for(var f in n)if(Object.prototype.hasOwnProperty.call(n,f)){var g=n[f];g&&"number"==typeof g.position&&(g.id=f,u.push(g),p=!0)}p&&(u.sort(function(e,t){return e.position-t.position}),n.sortedContributions=u)}var _=0,m=this;u.forEach(function(n){function u(e){e&&e.parentNode&&e.parentNode.removeChild(e)}var p,f;if(n.imageClass||(n.imageClass=null),n.children&&Object.getOwnPropertyNames(n.children).length>0){var g,v=n.children;if("tool"===d||"button"===d)if(n.title){var y;if(n.defaultActionId){n.pretendDefaultActionId=n.defaultActionId===!0;var x=m._commandList[n.defaultActionId];x&&(x.visibleWhen?x.visibleWhen(s):!0)?(y=new e.CommandInvocation(a,s,c,x,m),y.domParent=o):n.pretendDefaultActionId=!0}g=m._createDropdownMenu(o,n.title,null,null,n.imageClass,n.tooltip,n.selectionClass,null,y,n.pretendDefaultActionId,n.extraClasses),h&&i.generateNavGrid(h,g.menuButton),g&&(m._render(t,n.children,g.menu,s,a,"menu",c,h),m._checkForTrailingSeparator(g.menu,"menu",!0),0===g.menu.childNodes.length?n.emptyGroupMessage?g.menuButton.emptyGroupTooltip||(g.menuButton.emptyGroupTooltip=new l.Tooltip({node:g.menuButton,text:n.emptyGroupMessage,trigger:"click",position:["below","right","above","left"]})):(h&&i.removeNavGrid(h,g.menuButton),u(g.menu),u(g.menuButton),u(g.destroyButton)):g.menuButton.style.visibility="visible")}else{var b;if(o.childNodes.length>0&&!m._checkForTrailingSeparator(o,d)&&(b=m.generateSeparatorImage(o)),m._render(t,v,o,s,a,d,c,h),o.childNodes.length>0){var w=o.childNodes[o.childNodes.length-1];w!==b&&(b=m.generateSeparatorImage(o))}}else if(n.title){var C=m._createDropdownMenu(o,n.title,!0,null,null,n.imageClass);C&&(m._render(t,v,C.menu,s,a,"menu",c,h),m._checkForTrailingSeparator(C.menu,"menu",!0),0===C.menu.childNodes.length&&C.destroyButton&&o.removeChild(C.destroyButton))}else o.childNodes.length>0&&m._generateMenuSeparator(o),m._render(t,v,o,s,a,d,c,h),o.childNodes.length>0&&m._generateMenuSeparator(o)}else{var T=m._commandList[n.id],L=T?!0:!1,k=null,D=null;if(T){f=new e.CommandInvocation(n.handler||a,s,c,T,m),f.domParent=o;var A=!1;try{A=L&&(T.visibleWhen?T.visibleWhen(s,f):!0)}catch(S){throw console.log(S),S}m._activeBindings[T.id]&&m._activeBindings[T.id].keyBinding&&(k=m._activeBindings[T.id],k.invocation=A?f:null,k.bindingOnly&&(L=!1)),m._urlBindings[T.id]&&m._urlBindings[T.id].urlBinding&&(D=m._urlBindings[T.id],D.invocation=A?f:null,D.bindingOnly&&(L=!1)),L=L&&A}if(L)if(T.choiceCallback){var E,O;"tool"===d||"button"===d?(E=o,O=!1,"ul"===o.nodeName.toLowerCase()&&(E=document.createElement("li"),o.appendChild(E))):(E=o,O=!0);var N=function(e){T.populateChoicesMenu(e,s,a,c,m)};m._createDropdownMenu(E,T.name,O,N.bind(T),T.imageClass,T.tooltip||T.title,T.selectionClass,T.positioningNode)}else{f.handler=f.handler||this,f.domParent=o;var M,I=function(){m._invoke(f)};if("menu"===d){var B=null;k&&k.keyBinding&&(B=r.getUserKeyString(k.keyBinding)),M=e.createCommandMenuItem(o,T,f,null,I,B),f.onClick=I,m._registerRenderedCommand(T.id,t,f)}else if("quickfix"===d){p=d+T.id+_;var R=document.createElement("div");o.appendChild(R),o.classList.add("quickFixList"),M=e.createQuickfixItem(R,T,f,I,m._prefService)}else p=d+T.id+_,M=e.createCommandItem(o,T,f,p,null,"tool"===d,I);i.generateNavGrid(h,M),f.domNode=M,_++}}})},_createDropdownMenu:function(t,i,n,o,r,c,h,u,p,f,g){if(t=s.node(t),!t||!s.contains(document.body,t))return null;var _,m,v,y,x=t;if(n){var b=document.createRange();b.selectNode(t);var w=b.createContextualFragment(d);s.processTextNodes(w,{ButtonText:i}),t.appendChild(w),y=t.lastChild,m=y.lastChild,_=m.previousSibling,_.dropdown=new a.Dropdown({dropdown:m,populate:o,parentDropdown:t.dropdown}),m.dropdown=_.dropdown}else{"ul"===t.nodeName.toLowerCase()&&(x=document.createElement("li"),t.appendChild(x),y=x);var C=null;r&&(C="dropdownButtonWithIcon",c=c||i),c=r?c||i:c;var T=e.createDropdownMenu(x,i,o,C,r,!1,h,u,p||f,g);if(v=T.dropdownArrow,_=T.menuButton,v){p&&(p.domNode=T.menuButton);var L=this;_.onclick=function(e){var t=s.bounds(v);(e.clientX>=t.left||f===!0)&&T.dropdown?T.dropdown.toggle(e):L._invoke(p)},T.dropdown&&(_.onkeydown=function(e){s.KEY.DOWN===e.keyCode&&(T.dropdown.toggle(e),s.stop(e))})}m=T.menu;var k,D=p&&p.command&&(p.command.tooltip||p.command.name);k=D?p.command.tooltip||p.command.name:c,k&&(_.commandTooltip=new l.Tooltip({node:_,text:k,position:["above","below","right","left"]}))}return{menuButton:_,menu:m,dropdown:_.dropdown,destroyButton:y,dropdownArrow:v}},_generateMenuSeparator:function(e){if(!this._checkForTrailingSeparator(e,"menu")){var t=document.createElement("li");t.classList.add("dropdownSeparator");var i=document.createElement("span");i.classList.add("dropdownSeparator"),t.appendChild(i),e.appendChild(t)}},generateSeparatorImage:function(e){var t;return"ul"===e.nodeName.toLowerCase()?(t=document.createElement("li"),e.appendChild(t)):(t=document.createElement("span"),e.appendChild(t)),t.classList.add("core-sprite-sep"),t.classList.add("imageSprite"),t.classList.add("commandSeparator"),t}},p.prototype.constructor=p,f.prototype={match:function(e){var t=o.matchResourceParameters(e);return"undefined"!=typeof t[this.token]?(this.parameterValue=t[this.token],this):null}},f.prototype.constructor=f,g.prototype.constructor=g,_.prototype={optionsRequested:function(){return this.optionsRequested}},_.prototype.constructor=_,m.prototype={_storeParameters:function(e){if(this.parameterTable=null,e){var t=this.parameterTable={};e.forEach(function(e){t[e.name]=e})}},updateParameters:function(e){"function"==typeof this.getParameters&&this._storeParameters(this.getParameters(e))},hasParameters:function(){return null!==this.parameterTable},shouldCollectParameters:function(){return!this.clientCollect&&this.hasParameters()},parameterNamed:function(e){return this.parameterTable[e]},valueFor:function(e){var t=this.parameterTable[e];return t?t.value:null},setValue:function(e,t){var i=this.parameterTable[e];i&&(i.value=t)},forEach:function(e){for(var t in this.parameterTable)this.parameterTable[t].type&&this.parameterTable[t].name&&e(this.parameterTable[t])},validate:function(e,t){var i=this.parameterTable[e];return i&&i.validator?i.validator(t):!0},makeCopy:function(){var e=[];this.forEach(function(t){var i=new _(t.name,t.type,t.label,t.value,t.lines,t.eventListeners,t.validator);e.push(i)});var t=new m(e,this._options,this.getParameters);return t.clientCollect=this.clientCollect,t.message=this.message,t},hasOptionalParameters:function(){return this._hasOptionalParameters}},m.prototype.constructor=m,{CommandRegistry:p,URLBinding:f,ParametersDescription:m,CommandParameter:_,CommandEventListener:g}}),define("orion/editor/nls/messages",{root:!0}),define("orion/editor/nls/root/messages",{multipleAnnotations:"Multiple annotations:",line:"Line: ${0}",breakpoint:"Breakpoint",bookmark:"Bookmark",task:"Task",error:"Error",warning:"Warning",currentSearch:"Current Search",currentLine:"Current Line",matchingBracket:"Matching Bracket",currentBracket:"Current Bracket",diffAdded:"Diff Added Lines",diffDeleted:"Diff Deleted Lines",diffModified:"Diff Modified Lines",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",escape:"Escape",selectAll:"Select All",copy:"Copy",cut:"Cut",paste:"Paste",uppercase:"To Upper Case",lowercase:"To Lower Case",capitalize:"Capitalize",reversecase:"Reverse Case",toggleWrapMode:"Toggle Wrap Mode",toggleTabMode:"Toggle Tab Mode",toggleOverwriteMode:"Toggle Overwrite Mode",committerOnTime:"${0} on ${1}",emacs:"Emacs",exchangeMarkPoint:"Exchange Mark and Point",setMarkCommand:"Set Mark",clearMark:"Clear Mark",digitArgument:"Digit Argument ${0}",negativeArgument:"Negative Argument",Comment:"Comment","Flat outline":"Flat outline",incrementalFindStr:"Incremental find: ${0}",incrementalFindStrNotFound:"Incremental find: ${0} (not found)",incrementalFindReverseStr:"Reverse Incremental find: ${0}",incrementalFindReverseStrNotFound:"Reverse Incremental find: ${0} (not found)",findReplace:"Find/Replace",find:"Find...",undo:"Undo",redo:"Redo",cancelMode:"Cancel Current Mode",findNext:"Find Next Occurrence",findPrevious:"Find Previous Occurrence",incrementalFind:"Incremental Find",incrementalFindReverse:"Incremental Find Reverse",indentLines:"Indent Lines",unindentLines:"Unindent Lines",moveLinesUp:"Move Lines Up",moveLinesDown:"Move Lines Down",copyLinesUp:"Copy Lines Up",copyLinesDown:"Copy Lines Down",deleteLines:"Delete Lines",gotoLine:"Goto Line...",gotoLinePrompty:"Goto Line:",nextAnnotation:"Next Annotation",prevAnnotation:"Previous Annotation",expand:"Expand",collapse:"Collapse",expandAll:"Expand All",collapseAll:"Collapse All",lastEdit:"Last Edit Location",trimTrailingWhitespaces:"Trim Trailing Whitespaces",toggleLineComment:"Toggle Line Comment",addBlockComment:"Add Block Comment",removeBlockComment:"Remove Block Comment",linkedModeEntered:"Linked Mode: Enter or ESC to exit",linkedModeExited:"Linked Mode exited",syntaxError:"Syntax Error",contentAssist:"Content Assist",noProposals:"No proposals found",computingProposals:"Computing content assist proposals...",lineColumn:"Line ${0} : Column ${1}",lineColumnOffset:"Line ${0} : Column ${1} : Offset ${2}",multiSelections:"${0} selection regions",vi:"vi",vimove:"(Move)",viyank:"(Yank)",videlete:"(Delete)",vichange:"(Change)",viLeft:"${0} Left",viRight:"${0} Right",viUp:"${0} Up",viDown:"${0} Down",viw:"${0} Next Word",vib:"${0} Beginning of Word",viW:"${0} Next Word (ws stop)",viB:"${0} Beginning of Word (ws stop)",vie:"${0} End of Word",viE:"${0} End of Word (ws stop)",vi$:"${0} End of the line","vi^_":"${0} First non-blank Char Current Line","vi+":"${0} First Char Next Line","vi-":"${0} First Char Previous Line","vi|":"${0} nth Column in Line",viH:"${0} Top of Page",viM:"${0} Middle of Page",viL:"${0} Bottom of Page","vi/":"${0} Search Forward","vi?":"${0} Search Backward",vin:"${0} Next Search",viN:"${0} Previous Search",vif:"${0} Search Char Fwd",viF:"${0} Search Char Bckwd",vit:"${0} Search Before Char Fwd",viT:"${0} Search Before Char Bckwd","vi,":"${0} Repeat Reverse Char Search","vi;":"${0} Repeat Char Search",viG:"${0} Go to Line",viycd:"${0} Current Line",via:"Append After Cursor",viA:"Append to End of Line",vii:"Insert Before Cursor",viI:"Insert at Beginning of Line",viO:"Insert Line Above",vio:"Insert Line Below",viR:"Begin Overwriting Text",vis:"Substitute a Character",viS:"Substitute Entire Line",viC:"Change Text Until Line End",vip:"Paste After Char or Line",viP:"Paste Before Char or Line",viStar:"Search Word Under Cursor",next:"Next",previous:"Previous",replace:"Replace",replaceAll:"Replace All",findWith:"Find With",replaceWith:"Replace With",caseInsensitive:"Aa",regex:"/.*/",wholeWord:"\\b",caseInsensitiveTooltip:"Toggle Case Insensitive",regexTooltip:"Toggle Regular Expression",wholeWordTooltip:"Toggle Whole Word",closeTooltip:"Close",replacingAll:"Replacing all...",replacedMatches:"Replaced ${0} matches",nothingReplaced:"Nothing replaced",notFound:"Not found"}),define("orion/editor/eventTarget",[],function(){function e(){}return e.addMixin=function(t){var i=e.prototype;for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},e.prototype={addEventListener:function(e,t,i){this._eventTypes||(this._eventTypes={});var n=this._eventTypes[e];n||(n=this._eventTypes[e]={level:0,listeners:[]});var o=n.listeners;o.push({listener:t,useCapture:i})},dispatchEvent:function(e){var t=e.type;this._dispatchEvent("pre"+t,e),this._dispatchEvent(t,e),this._dispatchEvent("post"+t,e)},_dispatchEvent:function(e,t){var i=this._eventTypes?this._eventTypes[e]:null;if(i){var n=i.listeners;try{if(i.level++,n)for(var o=0,r=n.length;r>o;o++)if(n[o]){var s=n[o].listener;"function"==typeof s?s.call(this,t):s.handleEvent&&"function"==typeof s.handleEvent&&s.handleEvent(t)}}finally{if(i.level--,i.compact&&0===i.level){for(var a=n.length-1;a>=0;a--)n[a]||n.splice(a,1);0===n.length&&delete this._eventTypes[e],i.compact=!1}}}},isListening:function(e){return this._eventTypes?void 0!==this._eventTypes[e]:!1},removeEventListener:function(e,t,i){if(this._eventTypes){var n=this._eventTypes[e];if(n){for(var o=n.listeners,r=0,s=o.length;s>r;r++){var a=o[r];if(a&&a.listener===t&&a.useCapture===i){0!==n.level?(o[r]=null,n.compact=!0):o.splice(r,1);break}}0===o.length&&delete this._eventTypes[e]}}}},{EventTarget:e}}),define("orion/editor/annotations",["i18n!orion/editor/nls/messages","orion/editor/eventTarget"],function(e,t){function i(){}function n(e,t,i){this.start=e,this.end=t,this._projectionModel=i,this.html=this._expandedHTML,this.style=this._expandedStyle,this.expanded=!0}function o(t,n){var o=t.lastIndexOf("."),r=t.substring(o+1),s={title:e[r],style:{styleClass:"annotation "+r},html:"
    ",overviewStyle:{styleClass:"annotationOverview "+r}};n?s.lineStyle={styleClass:"annotationLine "+r}:s.rangeStyle={styleClass:"annotationRange "+r},i.registerType(t,s)}function r(){}function s(e,t,i,n,o){var r;for(void 0===n&&(n=-1),void 0===o&&(o=e.length);o-n>1;)if(r=Math.floor((o+n)/2),t<=e[r].start)o=r;else{if(i&&t",_expandedStyle:{styleClass:"annotation expanded"},_collapsedHTML:"",_collapsedStyle:{styleClass:"annotation collapsed"},_collapse:function(){return this.expanded?(this.expanded=!1,this.html=this._collapsedHTML,this.style=this._collapsedStyle,this._annotationModel&&this._annotationModel.modifyAnnotation(this),!0):!1},_expand:function(){return this.expanded?!1:(this.expanded=!0,this.html=this._expandedHTML,this.style=this._expandedStyle,this._annotationModel&&this._annotationModel.modifyAnnotation(this),!0)},_collapseImpl:function(e){if(this._collapse()){e&&this._forEachOverlaping(function(e){e.expanded||(e._expandImpl(!1),e._recollapse=!0)});var t=this._projectionModel,i=t.getBaseModel();this._projection={annotation:this,start:i.getLineStart(i.getLineAtOffset(this.start)+1),end:i.getLineEnd(i.getLineAtOffset(this.end),!0)},t.addProjection(this._projection)}},_expandImpl:function(e){this._expand()&&(this._projectionModel._removeProjection(this._projection,!this._annotationModel),e&&this._forEachOverlaping(function(e){e._recollapse&&(e._collapseImpl(!1),e._recollapse=!1)}))},_forEachOverlaping:function(e){if(this._annotationModel)for(var t=this._annotationModel.getAnnotations(this.start,this.end);t.hasNext();){var n=t.next();n!==this&&n.type===i.ANNOTATION_FOLDING&&e.call(this,n)}},collapse:function(){this._recollapse=!1,this._collapseImpl(!0)},expand:function(){this._recollapse=!1,this._expandImpl(!0)}},i.ANNOTATION_ERROR="orion.annotation.error",i.ANNOTATION_WARNING="orion.annotation.warning",i.ANNOTATION_TASK="orion.annotation.task",i.ANNOTATION_BREAKPOINT="orion.annotation.breakpoint",i.ANNOTATION_BOOKMARK="orion.annotation.bookmark",i.ANNOTATION_FOLDING="orion.annotation.folding",i.ANNOTATION_CURRENT_BRACKET="orion.annotation.currentBracket",i.ANNOTATION_MATCHING_BRACKET="orion.annotation.matchingBracket",i.ANNOTATION_CURRENT_LINE="orion.annotation.currentLine",i.ANNOTATION_CURRENT_SEARCH="orion.annotation.currentSearch",i.ANNOTATION_MATCHING_SEARCH="orion.annotation.matchingSearch",i.ANNOTATION_READ_OCCURRENCE="orion.annotation.readOccurrence",i.ANNOTATION_WRITE_OCCURRENCE="orion.annotation.writeOccurrence",i.ANNOTATION_SELECTED_LINKED_GROUP="orion.annotation.selectedLinkedGroup",i.ANNOTATION_CURRENT_LINKED_GROUP="orion.annotation.currentLinkedGroup",i.ANNOTATION_LINKED_GROUP="orion.annotation.linkedGroup",i.ANNOTATION_BLAME="orion.annotation.blame",i.ANNOTATION_CURRENT_BLAME="orion.annotation.currentBlame",i.ANNOTATION_DIFF_ADDED="orion.annotation.diffAdded",i.ANNOTATION_DIFF_DELETED="orion.annotation.diffDeleted",i.ANNOTATION_DIFF_MODIFIED="orion.annotation.diffModified";var d={};return i.registerType=function(e,t){var i=t;return"function"!=typeof i&&(i=function(e,t,i){this.start=e,this.end=t,void 0!==i&&(this.title=i)},i.prototype=t),i.prototype.type=e,d[e]=i,e},i.createAnnotation=function(e,t,i,n){return new(this.getType(e))(t,i,n)},i.getType=function(e){return d[e]},o(i.ANNOTATION_ERROR),o(i.ANNOTATION_WARNING),o(i.ANNOTATION_TASK),o(i.ANNOTATION_BREAKPOINT),o(i.ANNOTATION_BOOKMARK),o(i.ANNOTATION_CURRENT_BRACKET),o(i.ANNOTATION_MATCHING_BRACKET),o(i.ANNOTATION_CURRENT_SEARCH),o(i.ANNOTATION_MATCHING_SEARCH),o(i.ANNOTATION_READ_OCCURRENCE),o(i.ANNOTATION_WRITE_OCCURRENCE),o(i.ANNOTATION_SELECTED_LINKED_GROUP),o(i.ANNOTATION_CURRENT_LINKED_GROUP),o(i.ANNOTATION_LINKED_GROUP),o(i.ANNOTATION_CURRENT_LINE,!0),o(i.ANNOTATION_BLAME,!0),o(i.ANNOTATION_CURRENT_BLAME,!0),o(i.ANNOTATION_DIFF_ADDED),o(i.ANNOTATION_DIFF_DELETED),o(i.ANNOTATION_DIFF_MODIFIED),i.registerType(i.ANNOTATION_FOLDING,n),r.addMixin=function(e){var t=r.prototype;for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])},r.prototype={addAnnotationType:function(e,t){this._annotationTypes||(this._annotationTypes=[]);var i=t-1;void 0!=t&&i>=0&&ii.start?e=t)break}return null},i=n(),{next:function(){var e=i;return e&&(i=n()),e},hasNext:function(){return null!==i}}},modifyAnnotation:function(e){if(e){var t=this._getAnnotationIndex(e);if(!(0>t)){var i={type:"Changed",added:[],removed:[],changed:[e]};this.onChanged(i)}}},onChanged:function(e){return this.dispatchEvent(e)},removeAnnotations:function(e){var t,i,n=this._annotations;if(e)for(t=[],i=n.length-1;i>=0;i--){var o=n[i];o.type===e&&(n.splice(i,1),t.splice(0,0,o),o._annotationModel=null)}else t=n,n=[];var r={type:"Changed",removed:t,added:[],changed:[]};this.onChanged(r)},removeAnnotation:function(e){if(e){var t=this._getAnnotationIndex(e);if(!(0>t)){e._annotationModel=null;var i={type:"Changed",removed:this._annotations.splice(t,1),added:[],changed:[]};this.onChanged(i)}}},replaceAnnotations:function(e,t){var i,n,o,r=this._annotations,a=[];if(e)for(i=e.length-1;i>=0;i--)o=e[i],n=this._getAnnotationIndex(o),0>n||(o._annotationModel=null,r.splice(n,1),a.splice(0,0,o));for(t||(t=[]),i=0;i=0&&s=r?(c._oldStart=c.start,c._oldEnd=c.end,c.start+=d,c.end+=d,l.changed.push(c)):c.end<=t||(c.start0||l.removed.length>0||l.changed.length>0)&&this.onChanged(l)}}},t.EventTarget.addMixin(a.prototype),l.prototype={destroy:function(){var e=this._view;e&&(e.removeEventListener("Destroy",this._listener.onDestroy),e.removeEventListener("LineStyle",this._listener.onLineStyle),this.view=null);var t=this._annotationModel;t&&(t.removeEventListener("Changed",this._listener.onChanged),t=null)},_mergeStyle:function(e,t){if(t){e||(e={}),e.styleClass&&t.styleClass&&e.styleClass!==t.styleClass?e.styleClass+=" "+t.styleClass:e.styleClass=t.styleClass;var i;if(t.tagName&&(e.tagName||(e.tagName=t.tagName)),t.style){e.style||(e.style={});for(i in t.style)e.style[i]||(e.style[i]=t.style[i])}if(t.attributes){e.attributes||(e.attributes={});for(i in t.attributes)e.attributes[i]||(e.attributes[i]=t.attributes[i])}}return e},_mergeStyleRanges:function(e,t){e||(e=[]);for(var i,n=s(e,t.start,!0);n=o.end)){i=this._mergeStyle({},o.style),i=this._mergeStyle(i,t.style);var r=[];r.push(n,1),t.starto.start&&r.push({start:o.start,end:t.start,style:o.style}),r.push({start:Math.max(o.start,t.start),end:Math.min(o.end,t.end),style:i}),t.endo.end?{start:o.end,end:t.end,style:t.style}:null,Array.prototype.splice.apply(e,r)}}return t&&(i=this._mergeStyle({},t.style),e.splice(n,0,{start:t.start,end:t.end,style:i})),e},_onAnnotationModelChanged:function(e){function t(e,t){r.getBaseModel&&(e=r.mapOffset(e,!0),t=r.mapOffset(t,!0)),-1!==e&&-1!==t&&n.redrawRange(e,t)}function i(e,i){for(var n=0;n=5e4)var c=(new Date).getTime();if(this._rootBlock=this._stylerAdapter.createBlock(d,this,s,null),c){var h=(new Date).getTime()-c;h>10&&i.logTiming("editor","styler compute blocks (ms/50000 chars)",5e4*h/l,o.getContentType())}if(n){var u=[];n.removeAnnotations(e.AnnotationType.ANNOTATION_FOLDING),this._computeFolding(this._rootBlock.getBlocks(),t.getModel(),u),this._detectTasks&&(n.removeAnnotations(e.AnnotationType.ANNOTATION_TASK),this._computeTasks(this._rootBlock,s,u)),n.replaceAnnotations([],u)}t.redrawLines()}var d=function(e,t,i,n,o){var r;for(void 0===n&&(n=-1),void 0===o&&(o=e.length);o-n>1;)if(r=Math.floor((o+n)/2),t<=e[r].start)o=r;else{if(i&&tt.result.index?1:e.pattern.pattern.index0;){var h=d[0];if(d.splice(0,1),rt.result.index?1:e.pattern.pattern.index0;){var c=l[0];if(l.splice(0,1),c.result.indext.start?1:0});for(var g=0;g=r);u++){var p=c[u].start,f=c[u].end;if(p>l){var g=e.getLineAtOffset(l),_=e.getLineStart(g);this._stylerAdapter.parse(n.substring(_-o,p-o),_,l-_,i,a),a.forEach(function(e){e.style&&(0===e.style.indexOf(t.beginName)?s.push(e.start+1):0===e.style.indexOf(t.endName)&&s.push(-(e.start+1)))}),a=[]}l=f}return r>l&&(g=e.getLineAtOffset(l),_=e.getLineStart(g),this._stylerAdapter.parse(n.substring(_-o,r-o),_,l-_,i,a),a.forEach(function(e){e.style&&(0===e.style.indexOf(t.beginName)?s.push(e.start+1):0===e.style.indexOf(t.endName)&&s.push(-(e.start+1)))})),s},_findMatchingBracket:function(e,t,i){var n=e.getLineAtOffset(i),o=e.getLineEnd(n),r=e.getText(i,o),s=this._stylerAdapter.getBracketMatch(t,r);if(!s)return-1;for(var a=e.getLine(n),l=e.getLineStart(n),d=this._findBrackets(e,s,t,a,l,o),c=0;c=0?1:-1;if(d[c]*h-1===i){var u=1;if(s.atStart){for(c++;c=0?1:-1,u+=h,0===u)return d[c]*h-1;n+=1;for(var p=e.getLineCount();p>n;){a=e.getLine(n),l=e.getLineStart(n),o=e.getLineEnd(n),d=this._findBrackets(e,s,t,a,l,o);for(var f=0;f=0?1:-1,u+=h,0===u)return d[f]*h-1;n++}}else{for(c--;c>=0;c--)if(h=d[c]>=0?1:-1,u+=h,0===u)return d[c]*h-1;for(n-=1;n>=0;){a=e.getLine(n),l=e.getLineStart(n),o=e.getLineEnd(n),d=this._findBrackets(e,s,t,a,l,o);for(var g=d.length-1;g>=0;g--)if(h=d[g]>=0?1:-1,u+=h,0===u)return d[g]*h-1;n--}}break}}return-1},_getLineStyle:function(e){if(this._highlightCaretLine){var t=this._view,i=t.getModel(),n=t.getSelections(),o=!1;if(!n.some(function(t){return t.start===t.end?(o=o||i.getLineAtOffset(t.start)===e,!1):!0})&&o)return this._caretLineStyle}return null},_getStyles:function(e,t,i,n,o){for(var r=n+i.length,s=[],a=n+o,l=e.getBlocks(),c=d(l,a,!0),h=c;h=r);h++){var u=l[h].start,p=l[h].end;if(u>a){var f=t.getLineAtOffset(a),g=t.getLineStart(f);this._stylerAdapter.parse(i.substring(g-n,u-n),g,a-g,e,s)}var _=Math.max(a,u);if(_===u){var m=this._stylerAdapter.getBlockStartStyle(l[h],i.substring(_-n),_,s);m&&(_+=m.length)}var v=Math.min(r,p),y=[];if(v===p){var x=i.substring(v-a-(l[h].end-l[h].contentEnd)),b=this._stylerAdapter.getBlockEndStyle(l[h],x,v,y);b&&(v-=b.length)}f=t.getLineAtOffset(_),g=t.getLineStart(f);var w=this._getStyles(l[h],t,i.substring(g-n,v-n),g,_-g),C=this._stylerAdapter.getBlockContentStyleName(l[h]);if(C){var T=_;w.forEach(function(e){e.start-T&&s.push({start:T,end:e.start,style:C}),e.mergeable&&(e.style+=","+C),s.push(e),T=e.end}),v-T&&s.push({start:T,end:v,style:C})}else s=s.concat(w);s=s.concat(y),a=p}return r>a&&(f=t.getLineAtOffset(a),g=t.getLineStart(f),this._stylerAdapter.parse(i.substring(g-n,r-n),g,a-g,e,s)),s},_isRenderingWhitespace:function(){return this._whitespacesVisible},_onDestroy:function(){this.destroy()},_onLineStyle:function(e){e.textView===this._view&&(e.style=this._getLineStyle(e.lineIndex));var t=e.lineStart,i=e.textView.getModel();if(i.getBaseModel){t=i.mapOffset(t);var n=i.getBaseModel()}e.ranges=this._getStyles(this._rootBlock,n||i,e.lineText,t,0);for(var o=e.ranges.length-1;o>=0;o--){var r=e.ranges[o];if(r.style){if(r.style={styleClass:r.style.replace(/\./g," ")},n){var s=r.end-r.start;r.start=i.mapOffset(r.start,!0),r.end=r.start+s}}else e.ranges.splice(o,1)}this._isRenderingWhitespace()&&(this._spliceStyles(this._spacePattern,e.ranges,e.lineText,e.lineStart),this._spliceStyles(this._tabPattern,e.ranges,e.lineText,e.lineStart))},_onModelChanged:function(t){for(var i,n,o,r,s,a,l,c=t.start,h=t.removedCharCount,u=t.addedCharCount,p=u-h,f=this._view.getModel(),g=f.getBaseModel?f.getBaseModel():f,_=c+h,m=g.getCharCount(),v=g.getLineStart(g.getLineAtOffset(c)),y=this._findBlock(this._rootBlock,c);;){if(o=y.parent,!i&&o){if(0>p&&y.end-c<=-p){y=o;continue}if(s=g.getText(y.start,Math.min(m,y.end+p+1)),!this._stylerAdapter.verifyBlock(g,s,y,p)){y=o;continue}}n=y.getBlocks();var x=n.length,b=d(n,v,!0),w=d(n,_,!1,b-1,x);if(i=!1,b&&n.length&&n[b-1].end===c){s=g.getText(n[b-1].start,Math.min(m,c+1));var C=this.computeBlocks(g,s,y,n[b-1].start,null,null,null);C.length&&C[0].end!==n[b-1].end&&(b--,i=!0)}x>b&&n[b].start<=v&&(vc&&(l+=p)):b===x&&x>0&&y.end-p===n[x-1].end?(l=n[--b].start,l>c&&(l+=p)):l=Math.max(v,y.contentStart),a=x>w?n[w].end:y.contentEnd,a>=c&&(a+=p),a=Math.min(a,m-1),s=g.getText(l,a+1);var T=this.computeBlocks(g,s,y,l,null,null,null);if(x>w){if(T.length&&T[T.length-1].end===a&&T[T.length-1].typeId===n[w].typeId)break;if(T.length&&this._stylerAdapter.blockSpansBeyondEnd(T[T.length-1])){w++;for(var L=T[T.length-1].getBlocks(),k=(L.length?L[L.length-1]:T[T.length-1]).typeId;x>w;){if(n[w].typeId===k){var D=n[w].end+p;D=Math.min(D,m-1),s=g.getText(l,D+1);var A=this.computeBlocks(g,s,y,l,null,null,null);if(A.length&&A[A.length-1].end===D){a=D,T=A;break}}w++}if(x>w)break}}else if(!T.length||T[T.length-1].end<=y.contentEnd+p)break;if(!o){a=m,w=x,s=g.getText(l,a),T=this.computeBlocks(g,s,y,l,null,null,null);break}y=o,r=!0}this._rootBlock.adjustBounds(c,p),w=Math.min(w+1,x);var S;if(r||(r=w-b!==T.length),!r)for(var E=0;Ec&&($-=p),G>c&&(G-=p),c>=$&&G>c&&_>=$&&G>_){var z=g.getLineAtOffset(H.start),Y=g.getLineAtOffset(H.end);z!==Y?H.expanded||H.expand():F.push(H)}}else F.push(H),H.expand()}else H.type===e.AnnotationType.ANNOTATION_TASK&&y.start<=H.start&&H.end<=y.end&&F.push(H)}j&&U.getBlocks().forEach(function(e){this._updateFolding(e,g,f,W,P,l,a)}.bind(this)),this._detectTasks&&this._computeTasks(y,g,P,l,a),this._annotationProviders.forEach(function(e){var t=[],i=[];e(this._annotationModel,g,y,l,a,t,i),F=F.concat(t),P=P.concat(i)}.bind(this)),this._annotationModel.replaceAnnotations(F,P)}},_onMouseDown:function(e){if(2===e.clickCount){var t=this._view.getModel(),i=this._view.getOffsetAtLocation(e.x,e.y);if(i>0){var n=i-1,o=t;t.getBaseModel&&(n=t.mapOffset(n),o=t.getBaseModel());var r=this._findBlock(this._rootBlock,n),s=this._findMatchingBracket(o,r,n);if(-1!==s){e.preventDefault();var a=s;t.getBaseModel&&(a=t.mapOffset(a,!0)),i>a&&(i--,a++),this._view.setSelection(a,i)}}}},_onSelection:function(t){function i(e){var t={};return e.some(function(e){return e.isEmpty()?(t[l.getLineAtOffset(e.start).toString()]=!0,!1):!0})?{}:t}function n(e,t){for(var i in e)t[i]||(o=i>>0,a.redrawLines(o,o+1))}var o,r=Array.isArray(t.oldValue)?t.oldValue:[t.oldValue],s=Array.isArray(t.newValue)?t.newValue:[t.newValue],a=this._view,l=a.getModel();if(this._highlightCaretLine){var d=i(r),c=i(s);n(d,c),n(c,d)}if(this._annotationModel){var h,u,p=this._bracketAnnotations;if(1===s.length&&s[0].isEmpty()&&(u=s[0].getCaret())>0){var f=u-1;l.getBaseModel&&(f=l.mapOffset(f),l=l.getBaseModel());var g=this._findBlock(this._rootBlock,f),_=this._findMatchingBracket(l,g,f);-1!==_&&(h=[e.AnnotationType.createAnnotation(e.AnnotationType.ANNOTATION_MATCHING_BRACKET,_,_+1),e.AnnotationType.createAnnotation(e.AnnotationType.ANNOTATION_CURRENT_BRACKET,f,f+1)])}this._bracketAnnotations=h,this._annotationModel.replaceAnnotations(p,h)}},_spliceStyles:function(e,t,i,o){var r=e.regex;r.lastIndex=0;for(var s=0,a=r.exec(i);a;){for(var l=o+a.index;s|<|&|(\\|\\|))+",name:"punctuation.operator"},doc_block:{begin:"/\\*\\*",end:"\\*/",name:"comment.block.documentation",patterns:[{match:"@(?:(?!\\*/)\\S)*",name:"meta.documentation.annotation"},{match:"<[^\\s>]*>",name:"meta.documentation.tag"},{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},number_decimal:{match:"\\b-?(?:\\.\\d+|\\d+\\.?\\d*)(?:[eE][+-]?\\d+)?\\b",name:"constant.numeric.number"},number_hex:{match:"\\b0[xX][0-9A-Fa-f]+\\b",name:"constant.numeric.hex"},string_doubleQuote:{match:'"(?:\\\\.|[^"])*"?',name:"string.quoted.double"},string_singleQuote:{match:"'(?:\\\\.|[^'])*'?",name:"string.quoted.single"},todo_comment_singleLine:{match:"(\\b)(TODO)(\\b)(.*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.line"}}}}},{id:"orion.c-like",repository:{comment_singleLine:{match:{match:"//.*",literal:"//"},name:"comment.line.double-slash",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},comment_block:{begin:{match:"/\\*",literal:"/*"},end:{match:"\\*/",literal:"*/"},name:"comment.block",patterns:[{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]}}}],keywords:[]}}),define("orion/editor/stylers/application_javascript/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["class","const","debugger","delete","enum","export","extends","function","implements","import","in","instanceof","interface","let","new","package","private","protected","public","static","super","typeof","var","void","with"],i=["break","case","catch","continue","default","do","else","finally","for","if","return","switch","throw","try","while","yield"],n=["this"],o=["false","null","true","undefined"],r=[];return r.push.apply(r,e.grammars),r.push({id:"orion.js",contentTypes:["application/javascript"],patterns:[{include:"#string_multiline_singleQuote"},{include:"#string_multiline_doubleQuote"},{include:"#templateLiteral"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"#regex"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{include:"#jsFunctionDef"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{include:"#keywordsOperator"},{include:"#keywordsControl"},{include:"#languageConstant"},{include:"#languageVariable"}],repository:{jsFunctionDef:{begin:"(function)(\\s+[_$a-zA-Z\\xA0-\\uFFFF][_$a-zA-Z0-9\\xA0-\\uFFFF]*)?\\s*\\(",end:"\\)",captures:{1:{name:"keyword.operator.js"},2:{name:"entity.name.function.js"}},patterns:[{include:"orion.c-like#comment_singleLine"},{include:"orion.c-like#comment_block"},{match:"[^\\s,]+",name:"variable.parameter.js"}]},keywordsControl:{match:"\\b(?:"+i.join("|")+")\\b",name:"keyword.control.js"},keywordsOperator:{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.js"},languageConstant:{match:"\\b(?:"+o.join("|")+")\\b",name:"constant.language.js"},languageVariable:{match:"\\b(?:"+n.join("|")+")\\b",name:"variable.language.js"},string_multiline_singleQuote:{begin:"'(?:\\\\.|[^\\\\'])*\\\\$",end:"^(?:$|(?:\\\\.|[^\\\\'])*('|[^\\\\]$))",name:"string.quoted.single.js"},string_multiline_doubleQuote:{begin:'"(?:\\\\.|[^\\\\"])*\\\\$',end:'^(?:$|(?:\\\\.|[^\\\\"])*("|[^\\\\]$))',name:"string.quoted.double.js"},regex:{match:"/(?![\\s\\*])(?:\\\\.|[^/])+/(?:[gim]{0,3})",name:"string.regexp.js"},templateLiteral:{begin:"`",end:"`",name:"string.quoted.backtick.js",patterns:[{begin:"\\$\\{",end:"\\}",name:"string.interpolated.js",patterns:[{include:"#string_multiline_singleQuote"},{include:"#string_multiline_doubleQuote"},{include:"#templateLiteral"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"#regex"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{include:"#jsFunctionDef"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{include:"#keywordsOperator"},{include:"#keywordsControl"},{include:"#languageConstant"},{include:"#languageVariable"}]}]}}}),{id:r[r.length-1].id,grammars:r,keywords:t.concat(i).concat(n).concat(o)}}),define("orion/editor/stylers/application_vnd.coffeescript/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/application_javascript/syntax"],function(e,t){var i=["break","case","catch","continue","default","do","else","finally","for","if","loop","return","switch","then","throw","try","unless","until","when","while","yield"],n=["and","arguments","by","class","const","debugger","delete","enum","eval","export","extends","function","implements","import","instanceof","interface","in","isnt","is","let","native","new","not","no","off","of","on","or","package","private","protected","public","static","super","typeof","var","void","with","yes","__bind","__extends","__hasProp","__indexOf","__slice"],o=["false","null","true","undefined"],r=["this"],s=[];return s.push.apply(s,e.grammars),s.push.apply(s,t.grammars),s.push({id:"orion.coffeescript",contentTypes:["application/vnd.coffeescript"],patterns:[{include:"#comment_block"},{include:"#embedded_js"},{include:"#string_singleline"},{include:"#string_multiline"},{include:"#heregex"},{include:"#regex"},{include:"orion.lib#string_singleQuote"},{include:"#comment_singleLine"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{include:"#reserved_words"},{include:"#keyword_control"},{include:"#keyword_operator"},{include:"#language_variable"},{include:"#constant"},{include:"#punctuation"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"}],repository:{comment_block:{begin:{match:"###(?!#)",literal:"###"},end:{match:"###",literal:"###"},name:"comment.block.coffeescript"},comment_singleLine:{match:{match:"#[^$]*",literal:"#"},name:"comment.line.coffeescript"},constant:{match:"\\b(?:"+o.join("|")+")\\b",name:"constant.language.coffeescript"},embedded_js:{begin:"`",end:"`",patterns:[{include:"orion.js"}]},heregex:{begin:"\\/{3}",end:"\\/{3}(?:[gim]{0,3})",name:"string.heregexp.coffeescript",patterns:[{match:"\\s#[^$]*",name:"comment.block.coffeescript"}]},keyword_control:{match:"\\b(?:"+i.join("|")+")\\b",name:"keyword.control.coffeescript"},keyword_operator:{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.coffeescript"},language_variable:{match:"\\b(?:"+r.join("|")+")\\b",name:"variable.language.coffeescript"},punctuation:{match:"[-=]?>|<|[-+*\\/%<>&|^!?=]?=|>>>=?|([-+*/%:])\\1|([&|<>])\\2=?|\\?\\.?|\\.{2,3}|%|@",name:"punctuation.operator.coffeescript"},regex:{match:"/(?![\\s\\*])(?:\\\\.|[^/])+/(?:[gim]{0,3})",name:"string.regexp.coffeescript"},string_singleline:{match:'"(?:\\\\.|[^"])*"',name:"string.quoted.double.coffeescript",patterns:[{begin:"#{",end:"}",name:"string.interpolated.coffeescript",patterns:[{include:"#comment_block"},{include:"#embedded_js"},{include:"#comment_singleLine"},{include:"#heregex"},{include:"#regex"},{include:"orion.lib#string_singleQuote"},{include:"orion.lib#number_decimal"},{include:"#reserved_words"},{include:"#keyword_control"},{include:"#keyword_operator"},{include:"#language_variable"},{include:"#constant"},{include:"#punctuation"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"}]}]},string_multiline:{begin:'("("")?)',end:"\\1",name:"string.quoted.multiline.coffeescript",patterns:[{begin:"#{",end:"}",name:"string.interpolated.coffeescript",patterns:[{include:"#comment_block"},{include:"#embedded_js"},{include:"#comment_singleLine"},{include:"#heregex"},{include:"#regex"},{include:"orion.lib#string_singleQuote"},{include:"orion.lib#number_decimal"},{include:"#reserved_words"},{include:"#keyword_control"},{include:"#keyword_operator"},{include:"#language_variable"},{include:"#constant"},{include:"#punctuation"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"}]}]}}}),{id:s[s.length-1].id,grammars:s,keywords:i.concat(o)}}),define("orion/editor/stylers/text_x-java-source/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["abstract","boolean","byte","char","class","double","extends","final","float","implements","import","instanceof","int","interface","long","native","new","package","private","protected","public","short","static","synchronized","throws","transient","void","volatile"],i=["break","case","catch","continue","default","do","else","finally","for","if","return","switch","throw","try","while"],n=["false","null","true"],o=["this","super"],r=[];return r.push.apply(r,e.grammars),r.push({id:"orion.java",contentTypes:["text/x-java-source"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.java"},{match:"\\b(?:"+i.join("|")+")\\b",name:"keyword.control.java"},{match:"\\b(?:"+n.join("|")+")\\b",name:"constant.language.java"},{match:"\\b(?:"+o.join("|")+")\\b",name:"variable.language.java"}]}),{id:r[r.length-1].id,grammars:r,keywords:t.concat(i).concat(n).concat(o)} +}),define("orion/editor/stylers/text_css/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["alignment-adjust","alignment-baseline","animation-delay","animation-direction","animation-duration","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","animation","appearance","azimuth","backface-visibility","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","background","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-bottom","border-collapse","border-color","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-image","border-left-color","border-left-style","border-left-width","border-left","border-radius","border-right-color","border-right-style","border-right-width","border-right","border-spacing","border-style","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-top","border-width","border","bottom","box-align","box-decoration-break","box-direction","box-flex-group","box-flex","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color-profile","color","column-count","column-fill","column-gap","column-rule-color","column-rule-style","column-rule-width","column-rule","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue-after","cue-before","cue","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit-position","fit","flex-align","flex-flow","flex-inline-pack","flex-order","flex-pack","float-offset","float","font-family","font-size-adjust","font-size","font-stretch","font-style","font-variant","font-weight","font","grid-columns","grid-rows","hanging-punctuation","height","hyphenate-after","hyphenate-before","hyphenate-character","hyphenate-lines","hyphenate-resource","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","left","letter-spacing","line-height","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","line-stacking","list-style-image","list-style-position","list-style-type","list-style","margin-bottom","margin-left","margin-right","margin-top","margin","mark-after","mark-before","mark","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","opacity","orphans","outline-color","outline-offset","outline-style","outline-width","outline","overflow-style","overflow-x","overflow-y","overflow","padding-bottom","padding-left","padding-right","padding-top","padding","page-break-after","page-break-before","page-break-inside","page-policy","page","pause-after","pause-before","pause","perspective-origin","perspective","phonemes","pitch-range","pitch","play-during","position","presentation-level","punctuation-trim","quotes","rendering-intent","resize","rest-after","rest-before","rest","richness","right","rotation-point","rotation","ruby-align","ruby-overhang","ruby-position","ruby-span","size","speak-header","speak-numeral","speak-punctuation","speak","speech-rate","stress","string-set","table-layout","target-name","target-new","target-position","target","text-align-last","text-align","text-decoration","text-emphasis","text-height","text-indent","text-justify","text-outline","text-shadow","text-transform","text-wrap","top","transform-origin","transform-style","transform","transition-delay","transition-duration","transition-property","transition-timing-function","transition","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch-range","voice-pitch","voice-rate","voice-stress","voice-volume","volume","white-space-collapse","white-space","widows","width","word-break","word-spacing","word-wrap","z-index"],i=["AliceBlue","AntiqueWhite","Aquamarine","Aqua","Azure","Beige","Bisque","Black","BlanchedAlmond","BlueViolet","Blue","Brown","BurlyWood","CadetBlue","Chartreuse","Chocolate","Coral","CornflowerBlue","Cornsilk","Crimson","Cyan","DarkBlue","DarkCyan","DarkGoldenRod","DarkGray","DarkGrey","DarkGreen","DarkKhaki","DarkMagenta","DarkOliveGreen","DarkOrange","DarkOrchid","DarkRed","DarkSalmon","DarkSeaGreen","DarkSlateBlue","DarkSlateGray","DarkSlateGrey","DarkTurquoise","DarkViolet","DeepPink","DeepSkyBlue","DimGray","DimGrey","DodgerBlue","FireBrick","FloralWhite","ForestGreen","Fuchsia","Gainsboro","GhostWhite","Gold","GoldenRod","Gray","Grey","GreenYellow","Green","HoneyDew","HotPink","IndianRed","Indigo","Ivory","Khaki","LavenderBlush","Lavender","LawnGreen","LemonChiffon","LightBlue","LightCoral","LightCyan","LightGoldenRodYellow","LightGray","LightGrey","LightGreen","LightPink","LightSalmon","LightSeaGreen","LightSkyBlue","LightSlateGray","LightSlateGrey","LightSteelBlue","LightYellow","LimeGreen","Lime","Linen","Magenta","Maroon","MediumAquaMarine","MediumBlue","MediumOrchid","MediumPurple","MediumSeaGreen","MediumSlateBlue","MediumSpringGreen","MediumTurquoise","MediumVioletRed","MidnightBlue","MintCream","MistyRose","Moccasin","NavajoWhite","Navy","OldLace","OliveDrab","Olive","OrangeRed","Orange","Orchid","PaleGoldenRod","PaleGreen","PaleTurquoise","PaleVioletRed","PapayaWhip","PeachPuff","Peru","Pink","Plum","PowderBlue","Purple","RebeccaPurple","Red","RosyBrown","RoyalBlue","SaddleBrown","Salmon","SandyBrown","SeaGreen","SeaShell","Sienna","Silver","SkyBlue","SlateBlue","SlateGray","SlateGrey","Snow","SpringGreen","SteelBlue","Tan","Teal","Thistle","Tomato","Turquoise","Violet","Wheat","WhiteSmoke","White","YellowGreen","Yellow"],n=["charset","document","font-face","import","keyframes","media","namespace","page","supports"],o=[];return o.push.apply(o,e.grammars),o.push({id:"orion.css",contentTypes:["text/css"],patterns:[{include:"#string_single_multiline"},{include:"#string_double_multiline"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_block"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#number_decimal"},{include:"#number_hex"},{include:"#numeric_value"},{include:"#color"},{include:"#keyword"},{include:"#directive"}],repository:{color:{match:"(?i)\\b(?:"+i.join("|")+")\\b",name:"constant.other.color.css"},directive:{match:"(^|\\s)(@("+n.join("|")+"))\\b",captures:{2:{name:"keyword.other.directive.css"}}},keyword:{match:"(?:-webkit-|-moz-|-ms-|-o-|\\b)(?:"+t.join("|")+")\\b",name:"support.type.propertyName.css"},number_hex:{match:"#[0-9A-Fa-f]+\\b",name:"constant.numeric.hex.css"},numeric_value:{match:"(?i)\\b-?(?:\\.\\d+|\\d+\\.?\\d*)(?:%|em|ex|ch|rem|vw|vh|vmin|vmax|in|cm|mm|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?\\b",name:"constant.numeric.value.css"},string_double_multiline:{begin:'"(?:\\\\.|[^\\\\"])*\\\\$',end:'^(?:$|(?:\\\\.|[^\\\\"])*("|[^\\\\]$))',name:"string.quoted.double.css"},string_single_multiline:{begin:"'(?:\\\\.|[^\\\\'])*\\\\$",end:"^(?:$|(?:\\\\.|[^\\\\'])*('|[^\\\\]$))",name:"string.quoted.single.css"}}}),{id:o[o.length-1].id,grammars:o,keywords:t}}),define("orion/editor/stylers/application_xml/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=[];return t.push.apply(t,e.grammars),t.push({id:"orion.xml",contentTypes:["application/xml","application/xhtml+xml"],patterns:[{include:"#comment"},{include:"#doctype"},{include:"#xmlDeclaration"},{include:"#tag"},{include:"#ampersandEscape"}],repository:{ampersandEscape:{match:"<|>|&",name:"constant.character"},comment:{begin:{match:"",literal:"-->"},name:"comment.block.xml",patterns:[{match:"(\\b)(TODO)(\\b)(((?!-->).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.line"}}}]},doctype:{begin:"",name:"meta.tag.doctype.xml",captures:{0:{name:"meta.tag.doctype.xml"}},patterns:[{include:"#comment"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},tag:{begin:"",captures:{0:{name:"meta.tag.xml"}},patterns:[{include:"#comment"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},xmlDeclaration:{begin:"<\\?xml",end:"\\?>",captures:{0:{name:"meta.tag.declaration.xml"}},patterns:[{include:"#comment"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}],name:"meta.tag.declaration.xml"}}}),{id:t[t.length-1].id,grammars:t,keywords:[]}}),define("orion/editor/stylers/text_html/syntax",["orion/editor/stylers/application_javascript/syntax","orion/editor/stylers/text_css/syntax","orion/editor/stylers/application_xml/syntax"],function(e,t,i){var n=["accept-charset","accept","accesskey","action","align","alt","async","autocomplete","autoplay","autosave","bgcolor","border","buffered","challenge","charset","checked","cite","class","codebase","code","color","colspan","cols","contenteditable","content","contextmenu","controls","coords","data-[A-Za-z_:][\\w.:-]*","data","datetime","default","defer","dirname","dir","disabled","download","draggable","dropzone","enctype","formaction","form","for","headers","height","hidden","high","hreflang","href","http-equiv","icon","id","ismap","itemprop","keytype","kind","label","language","lang","list","loop","low","manifest","maxlength","max","media","method","min","multiple","name","novalidate","open","optimum","pattern","ping","placeholder","poster","preload","pubdate","radiogroup","readonly","rel","required","reversed","rowspan","rows","sandbox","scoped","scope","seamless","selected","shape","sizes","size","span","spellcheck","srcdoc","srclang","srcset","src","start","step","style","summary","tabindex","target","title","type","usemap","value","width","wrap"],o=["activedescendant","atomic","autocomplete","busy","checked","controls","describedby","disabled","dropeffect","expanded","flowto","grabbed","haspopup","hidden","invalid","labelledby","label","level","live","multiline","multiselectable","orientation","owns","posinset","pressed","readonly","relevant","required","selected","setsize","sort","valuemax","valuemin","valuenow","valuetext"],r=[];return r.push.apply(r,e.grammars),r.push.apply(r,t.grammars),r.push.apply(r,i.grammars),r.push({id:"orion.html",contentTypes:["text/html"],patterns:[{begin:"(?i)(]*)(>)",end:"(?i)()",captures:{1:{name:"meta.tag.html"},3:{name:"meta.tag.html"}},contentName:"source.css.embedded.html",patterns:[{include:"orion.css"}]},{begin:"(?i)|",end:"(?i)",captures:{0:{name:"meta.tag.html"}},contentName:"source.js.embedded.html",patterns:[{include:"orion.js"}]},{begin:"",captures:{0:{name:"meta.tag.html"}},patterns:[{include:"orion.xml#comment"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"#attribute"}]},{include:"orion.xml#comment"},{include:"orion.xml#doctype"},{include:"orion.xml#ampersandEscape"}],repository:{attribute:{match:"\\b(?:"+n.join("|")+"|role|aria-("+o.join("|")+"))\\b",name:"meta.tag.attribute.html"}}}),{id:r[r.length-1].id,grammars:r,keywords:[],attributes:n}}),define("orion/editor/stylers/application_x-jsp/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/text_x-java-source/syntax","orion/editor/stylers/text_html/syntax"],function(e,t,i){var n=["autoFlush","buffer","contentType","errorPage","extends","import","info","isErrorPage","isThreadSafe","language","pageEncoding","session"],o=[];return o.push.apply(o,e.grammars),o.push.apply(o,t.grammars),o.push.apply(o,i.grammars),o.push({id:"orion.jsp",contentTypes:["application/x-jsp"],patterns:[{include:"orion.html"},{include:"#jspComment"},{include:"#jspJavaFragment"},{include:"#jspDirectiveInclude"},{include:"#jspDirectivePage"},{include:"#jspDirectiveTaglib"}],repository:{jspComment:{begin:{match:"<%--",literal:"<%--"},end:{match:"--%>",literal:"<%--"},name:"comment.block.jsp",patterns:[{match:"(\\b)(TODO)(\\b)(((?!--%>).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.line"}}}]},jspDirectiveInclude:{begin:"<%@\\s+include(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.directive.include.jsp"}},patterns:[{match:"\\bfile\\b",name:"entity.other.attribute-name.jsp"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},jspDirectivePage:{begin:"<%@\\s+page(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.directive.page.jsp"}},patterns:[{match:"\\b(?:"+n.join("|")+")\\b",name:"entity.other.attribute-name.jsp"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},jspDirectiveTaglib:{begin:"<%@\\s+taglib(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.directive.taglib.jsp"}},patterns:[{match:"\\b(?:uri|prefix)\\b",name:"entity.other.attribute-name.jsp"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},jspJavaFragment:{begin:"<%(?:=|!)?(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.declaration.java"}},contentName:"source.java.embedded.jsp",patterns:[{include:"orion.java"}]}}}),{id:o[o.length-1].id,grammars:o,keywords:[]}}),define("orion/editor/stylers/application_xquery/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["zero-digit","xquery","window","where","when","version","variable","validate","unordered","union","typeswitch","type","tumbling","try","treat","to","then","text","switch","strip","strict","start","stable","some","sliding","self","schema-element","schema-attribute","schema","satisfies","return","processing-instruction","previous","preserve","preceding-sibling","preceding","percent","per-mille","pattern-separator","parent","ordering","order","or","option","only","of","node","no-preserve","no-inherit","next","ne","NaN","namespace-node","namespace","module","mod","minus-sign","lt","let","least","le","lax","item","is","intersect","instance","inherit","infinity","in","import","if","idiv","gt","grouping-separator","group","greatest","ge","function","for","following-sibling","following","external","except","every","eq","end","encoding","empty-sequence","empty","else","element","document-node","div","digit","descending","descendant-or-self","descendant","default","declare","decimal-separator","decimal-format","count","copy-namespaces","context","construction","comment","collation","child","catch","castable","cast","case","by","boundary-space","base-uri","attribute","at","ascending","as","and","ancestor-or-self","ancestor","allowing"],i=[];return i.push.apply(i,e.grammars),i.push({id:"orion.xquery",contentTypes:["application/xquery"],patterns:[{include:"#comment"},{include:"#variable"},{include:"#multiLineDoubleQuote"},{include:"#multiLineSingleQuote"},{include:"orion.xml#tag"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.js"}],repository:{comment:{begin:{match:"\\(:",literal:"(:"},end:{match:":\\)",literal:":)"},name:"comment.block.xquery",patterns:[{match:"(\\b)(TODO)(\\b)(((?!:\\)).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},variable:{match:"\\$[a-zA-z0-9_]+",name:"variable.other.xquery"},multiLineDoubleQuote:{begin:'"',end:'"',name:"string.quoted.double"},multiLineSingleQuote:{begin:"'",end:"'",name:"string.quoted.single"}}}),{id:i[i.length-1].id,grammars:i,keywords:t}}),define("orion/editor/stylers/application_sql/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["ADD","ALTER\\s+TABLE","AND","ASC","BETWEEN","COMMIT","CREATE\\s+(TABLE|DATABASE)","CREATE\\s+(UNIQUE\\s+)?INDEX","DELETE\\s+FROM","DESC","DROP(\\s+(INDEX|TABLE|DATABASE))?","FROM","GROUP\\s+BY","HAVING","INSERT\\s+INTO","IN","LIKE","MODIFY","ON","ORDER\\s+BY","OR","PRIMARY\\s+KEY","ROLLBACK","SELECT(\\s+(COUNT|DISTINCT|SUM))?","SET","TO","TRUNCATE\\s+TABLE","UPDATE","USE","VALUES","WHERE"],i=[];return i.push.apply(i,e.grammars),i.push({id:"orion.sql",contentTypes:["application/sql"],patterns:[{include:"orion.lib#string_singleQuote"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#number_decimal"},{match:"(?i)\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.sql"},{match:"<>|>=?|<=?|=",name:"punctuation.operator.sql"}]}),{id:i[i.length-1].id,grammars:i,keywords:t}}),define("orion/editor/stylers/text_x-scss/syntax",["orion/editor/stylers/text_css/syntax","orion/editor/stylers/lib/syntax"],function(e,t){var i=["default","global","optional"],n=["false","null","true"],o=["at-root","content","debug","each","else","error","extend","for","function","if","include","mixin","return","warn","while"],r=[];return r.push.apply(r,e.grammars),r.push.apply(r,t.grammars),r.push({id:"orion.scss",contentTypes:["text/x-scss"],patterns:[{include:"orion.css#string_single_multiline"},{include:"orion.css#string_double_multiline"},{include:"orion.c-like#comment_block"},{include:"#eachin"},{include:"#forto"},{include:"orion.c-like#comment_singleLine"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"#variable"},{include:"#placeholder"},{include:"#flag"},{include:"#directive"},{include:"orion.css#directive"},{include:"#constant"},{include:"#interpolated"},{include:"#operator"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#number_decimal"},{include:"orion.css#number_hex"},{include:"orion.css#numeric_value"},{include:"orion.css#color"},{include:"orion.css#keyword"}],repository:{constant:{match:"\\b(?:"+n.join("|")+")\\b",name:"constant.language.scss"},directive:{match:"(^|\\s)(@("+o.join("|")+"))\\b",captures:{2:{name:"keyword.other.directive.scss"}}},eachin:{begin:"@each\\s",end:"\\sin\\b",captures:{0:{name:"keyword.other.directive.scss"}},patterns:[{include:"#variable"}]},flag:{match:"(^|\\s)(!("+i.join("|")+"))\\b",captures:{2:{name:"keyword.other.flag.scss"}}},forto:{begin:"@for\\s",end:"(^|\\s)(t(o|hrough))(\\s|$)",beginCaptures:{0:{name:"keyword.other.directive.scss"}},endCaptures:{2:{name:"keyword.other.directive.scss"}},patterns:[{include:"#variable"},{include:"orion.lib#number_decimal"},{match:"(^|\\s)(from)(\\s|$)",name:"keyword.other.directive.scss"}]},interpolated:{match:"#\\{[^}]*\\}",name:"string.interpolated.scss"},operator:{match:"\\+|\\*|\\/|%|==?|!=|&|<=?|=?>|!",name:"punctuation.operator.scss"},placeholder:{match:"%[\\w-]+",name:"variable.other.placeholder.sas"},variable:{match:"\\$[\\w-]+(\\.{3})?",name:"variable.other.scss"}}}),{id:r[r.length-1].id,grammars:r,keywords:o.concat(i)}}),define("orion/editor/stylers/text_x-less/syntax",["orion/editor/stylers/text_css/syntax","orion/editor/stylers/lib/syntax"],function(e,t){var i=["important"],n=["true"],o=["arguments"],r=["all","and","not","when"],s=["css","inline","less","multiple","once","optional","reference"],a=[];return a.push.apply(a,e.grammars),a.push.apply(a,t.grammars),a.push({id:"orion.less",contentTypes:["text/x-less"],patterns:[{include:"orion.css#string_single_multiline"},{include:"orion.css#string_double_multiline"},{include:"orion.c-like#comment_block"},{include:"#string_doubleQuote"},{include:"#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"#importDirective"},{include:"orion.css#directive"},{include:"#directive"},{include:"#variable"},{include:"#interpolated"},{include:"#constant"},{include:"#flag"},{include:"#operator"},{include:"#keyword"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#number_decimal"},{include:"orion.css#number_hex"},{include:"orion.css#numeric_value"},{include:"orion.css#color"},{include:"orion.css#keyword"}],repository:{constant:{match:"\\b(?:"+n.join("|")+")\\b",name:"constant.language.less"},directive:{match:"(^|\\s)(@("+o.join("|")+"))\\b",captures:{2:{name:"keyword.other.directive.less"}}},flag:{match:"(^|\\s)(!("+i.join("|")+"))\\b",captures:{2:{name:"keyword.other.flag.less"}}},importDirective:{begin:"(@import)\\s*\\(",end:"\\)",beginCaptures:{1:{name:"keyword.other.directive.less"}},patterns:[{match:"\\b(?:"+s.join("|")+")\\b",name:"keyword.operator.less"}]},interpolated:{match:"@\\{[^}]*\\}",name:"string.interpolated.less"},keyword:{match:"\\b(?:"+r.join("|")+")\\b",name:"keyword.operator.less"},operator:{match:"\\+_?|\\*|\\/|=|>=?|<=?|&",name:"punctuation.operator.less"},string_doubleQuote:{match:'~?"(?:\\\\.|[^"])*"?',name:"string.quoted.double"},string_singleQuote:{match:"~?'(?:\\\\.|[^'])*'?",name:"string.quoted.single"},variable:{match:"@[\\w-]+(\\.{3})?",name:"variable.other.less"}}}),{id:a[a.length-1].id,grammars:a,keywords:o.concat(i).concat(s).concat(r)}}),define("orion/editor/stylers/text_jsx/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/application_javascript/syntax","orion/editor/stylers/application_xml/syntax"],function(e,t,i){var n=[];return n.push.apply(n,e.grammars),n.push.apply(n,t.grammars),n.push.apply(n,i.grammars),n.push({id:"orion.jsx",contentTypes:["text/jsx"],patterns:[{begin:"",captures:{0:{name:"meta.tag.jsx"}},patterns:[{include:"#jsExpression"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.c-like#comment_block"}]},{include:"orion.xml#ampersandEscape"},{include:"orion.js"}],repository:{jsExpression:{begin:"\\{",end:"\\}",contentName:"source.js.embedded.jsx",patterns:[{include:"orion.js"}]}}}),{id:n[n.length-1].id,grammars:n,keywords:[]}}),define("orion/editor/stylers/application_json/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["false","true"],i=[];return i.push.apply(i,e.grammars),i.push({id:"orion.json",contentTypes:["application/json"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.json"}]}),{id:i[i.length-1].id,grammars:i,keywords:t}}),define("orion/editor/stylers/text_x-csrc/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["auto","break","case","char","const","continue","default","double","do","else","enum","extern","float","for","goto","if","inline","int","long","register","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","_Bool","_Complex","_Imaginary"],i=["define","elif","else","endif","error","ifdef","ifndef","if","include","line","pragma","undef"],n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.c",contentTypes:["text/x-csrc","text/x-c"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{include:"#directive"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.c"}],repository:{directive:{match:"#\\s*(?:"+i.join("|")+")\\b[^$]*",name:"meta.preprocessor.c"}}}),{id:n[n.length-1].id,grammars:n,keywords:t.concat(i)}}),define("orion/editor/stylers/text_x-csharp/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["abstract","as","base","bool","break","byte","by","case","catch","char","checked","class","const","continue","decimal","default","delegate","descending","double","do","else","enum","event","explicit","extern","false","finally","fixed","float","foreach","for","from","goto","group","if","implicit","int","interface","internal","into","in","is","lock","long","namespace","new","null","object","operator","orderby","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","select","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","var","virtual","volatile","void","while","where","yield"],i=["define","elif","else","endif","endregion","error","if","line","pragma checksum","pragma warning","pragma","region","undef","warning"],n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.csharp",contentTypes:["text/x-csharp"],patterns:[{match:"^\\s*#(?:"+i.join("|")+")\\b[^$]*",name:"meta.preprocessor.csharp"},{include:"#string_verbatim"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"#doc_line"},{include:"orion.c-like#comment_singleLine"},{include:"#doc_block"},{include:"orion.c-like#comment_block"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.csharp"}],repository:{doc_block:{begin:"/\\*\\*",end:"\\*/",name:"comment.block.documentation.csharp",patterns:[{match:"<[^\\s>]*>",name:"meta.documentation.tag"},{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},doc_line:{match:"// /.*",name:"comment.line.documentation.csharp",patterns:[{match:"<[^\\s>]*>",name:"meta.documentation.tag"},{include:"orion.lib#todo_comment_singleLine"}]},string_verbatim:{begin:'@"',end:'^(?:""|[^"])*"(?!")',name:"string.quoted.verbatim.csharp"}}}),{id:n[n.length-1].id,grammars:n,keywords:t}}),define("orion/editor/stylers/text_x-cshtml/syntax",["orion/editor/stylers/application_xml/syntax","orion/editor/stylers/text_html/syntax","orion/editor/stylers/text_x-csharp/syntax"],function(e,t,i){var n=[];return n.push.apply(n,e.grammars),n.push.apply(n,t.grammars),n.push.apply(n,i.grammars),n.push({id:"orion.cshtml",contentTypes:["text/x-cshtml"],patterns:[{include:"#comment"},{include:"#codeBlock"},{include:"#expression"},{include:"#reference"},{include:"orion.html"}],repository:{comment:{begin:{match:"@\\*",literal:"@*"},end:{match:"\\*@",literal:"*@"},name:"comment.block.cshtml"},codeBlock:{begin:"(^\\s*)(@)(?=([^{]*){)",end:"}",captures:{2:{name:"entity.name.declaration.csharp"}},contentName:"source.csharp.embedded.cshtml",patterns:[{include:"orion.xml#tag"},{include:"#reference"},{include:"orion.csharp"}]},expression:{match:"^\\s*@[^{]*$",name:"source.csharp.embedded.cshtml",patterns:[{include:"#reference"},{include:"orion.csharp"}]},reference:{match:"@",name:"entity.name.declaration.csharp"}}}),{id:n[n.length-1].id,grammars:n,keywords:[]}}),define("orion/editor/stylers/text_x-c__src/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["alignas","alignof","asm","and_eq","and","auto","bitand","bitor","bool","break","case","catch","char16_t","char32_t","char","class","compl","constexpr","const_cast","const","continue","decltype","default","delete","double","do","dynamic_cast","else","enum","explicit","export","extern","false","float","for","friend","goto","if","inline","int","long","mutable","namespace","new","noexcept","not_eq","not","nullptr","operator","or_eq","or","private","protected","public","register","reinterpret_cast","return","short","signed","sizeof","static_assert","static_cast","static","struct","switch","template","this","thread_local","throw","true","try","typedef","typeid","typename","union","unsigned","using","virtual","void","volatile","wchar_t","while","xor_eq","xor","_Bool","_Complex","_Imaginary"],i=["define","elif","else","endif","error","ifdef","ifndef","if","include","line","pragma","undef"],n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.cpp",contentTypes:["text/x-c++src","text/x-c++"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{include:"#directive"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.cpp"}],repository:{directive:{match:"#\\s*(?:"+i.join("|")+")\\b[^$]*",name:"meta.preprocessor.cpp"}}}),{id:n[n.length-1].id,grammars:n,keywords:t}}),define("orion/editor/stylers/text_x-dockerfile/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["add","cmd","copy","entrypoint","env","expose","from","maintainer","onbuild","run","user","volume","workdir"],i="orion.dockerfile",n=[];return n.push.apply(n,e.grammars),n.push({id:i,contentTypes:["text/x-dockerfile"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"#numberSignComment"},{match:"\\b-?[0-9]+(\\.[0-9]+)?\\b",name:"constant.numeric.dockerfile"},{match:"(?i)^\\s*(?:"+t.join("|")+")\\b",name:"keyword.operator.dockerfile"}],repository:{numberSignComment:{begin:{match:"^\\s*#",literal:"#"},end:{match:"$",literal:""},name:"comment.line.number-sign.dockerfile",patterns:[{include:"orion.lib#todo_comment_singleLine"}]}}}),{id:i,grammars:n,keywords:t}}),define("orion/editor/stylers/text_x-erlang/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["xor","when","try","rem","receive","query","orelse","or","of","not","let","if","fun","end","div","cond","catch","case","bxor","bsr","bsl","bor","bnot","begin","band","andalso","and","after"],i=["vsn","undef","type","spec","record","on_load","opaque","module","include_lib","include","import","ifndef","ifdef","file","export_type","export","endif","else","define","callback","compile","behaviour"],n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.erlang",contentTypes:["text/x-erlang"],patterns:[{include:"#comment"},{include:"#stringSingleLine"},{include:"#stringMultiLine"},{include:"#method"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.erlang"},{match:"^\\s*-(?:"+i.join("|")+")\\b",name:"keyword.operator.erlang"}],repository:{comment:{match:{match:"%.*",literal:"%"},name:"comment.line.erlang",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},method:{match:"(^|\\s)[a-zA-Z0-9_.]+(?=\\(|\\s\\()",name:"entity.name.function.erlang"},stringMultiLine:{begin:'"(?:\\\\.|[^\\\\"])*$',end:'^(?:\\\\.|[^\\\\"])*"',name:"string.quoted.double.erlang"},stringSingleLine:{match:'"(?:\\\\.|[^\\\\"])*"',name:"string.quoted.double.erlang"}}}),{id:n[n.length-1].id,grammars:n,keywords:t} +}),define("orion/editor/stylers/text_x-ruby/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["alias_method","alias","attr_accessor","attr_reader","attr_writer","attr","BEGIN","class","defined?","def","END","extend","gem","include","initialize","in","load","lambda","module_function","module","new","not","public","prepend","private","protected","require_relative","require","undef","__ENCODING__","__END__","__FILE__","__LINE__"],i=["and","begin","break","case","catch","do","else","elsif","end","ensure","fail","for","if","loop","next","or","raise","redo","rescue","retry","return","then","throw","unless","until","when","while","yield"],n=["false","nil","true"],o=["self","super"],r=[];return r.push.apply(r,e.grammars),r.push({id:"orion.ruby",contentTypes:["text/x-ruby"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"#symbol_quoted_single"},{include:"#symbol_quoted_double"},{include:"#symbol"},{include:"#classRef"},{match:"/(?![\\s])(?:\\\\.|[^/])+/(?:[ioxmuesn]\\b)?",name:"string.regexp.ruby"},{match:{match:"#.*",literal:"#"},name:"comment.line.number-sign.ruby",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},{begin:{match:"^=begin\\b",literal:"\n=begin "},end:{match:"^=end\\b",literal:"\n=end "},name:"comment.block.ruby",patterns:[{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{include:"#variable"},{match:"\\b0[bB][01]+\\b",name:"constant.numeric.binary.ruby"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.ruby"},{match:"\\b(?:"+i.join("|")+")\\b",name:"keyword.control.ruby"},{match:"\\b(?:"+n.join("|")+")\\b",name:"constant.language.ruby"},{match:"\\b(?:"+o.join("|")+")\\b",name:"variable.language.ruby"}],repository:{classRef:{match:"\\w+::\\w+"},symbol:{match:":\\w+",name:"entity.name.symbol.ruby"},symbol_quoted_single:{match:":'[^']*'",name:"entity.name.symbol.quoted.single.ruby"},symbol_quoted_double:{match:':"[^"]*"',name:"entity.name.symbol.quoted.double.ruby"},variable:{match:"@\\w+",name:"entity.name.variable.ruby"}}}),{id:r[r.length-1].id,grammars:r,keywords:t.concat(i).concat(n).concat(o)}}),define("orion/editor/stylers/text_x-haml/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/text_x-ruby/syntax"],function(e,t){var i=[];return i.push.apply(i,e.grammars),i.push.apply(i,t.grammars),i.push({id:"orion.haml",contentTypes:["text/x-haml"],patterns:[{include:"#inlineRuby"},{include:"#interpolatedRuby"},{include:"#tagWithRubySymbols"},{include:"#tagWithHTMLAttributes"},{include:"#doctype"},{include:"#tag"},{include:"#htmlComment"}],repository:{doctype:{match:"^!!!.*$",name:"meta.tag.doctype.haml"},htmlComment:{match:{match:"/[^[].*$",literal:"/"},name:"comment.line.html.haml"},inlineRuby:{begin:"(?:^|[^\\\\])(?:=|-|~|&==?|!==?)",end:"(?:^|[^,])$",contentName:"source.ruby.embedded.haml",patterns:[{include:"orion.ruby"}]},interpolatedRuby:{begin:"#{",end:"}",contentName:"source.ruby.embedded.haml",patterns:[{include:"orion.ruby"}]},tag:{match:"^\\s*%[^\\b]+?\\b",name:"meta.tag.haml"},tagWithHTMLAttributes:{begin:"(^\\s*)(%[^\\s(]+?)\\(",end:"\\)\\s*$",beginCaptures:{2:{name:"meta.tag.haml"}},patterns:[{match:"[^\\s=]+(?==)",name:"entity.name.attribute.html.haml"},{include:"orion.ruby#variable"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},tagWithRubySymbols:{begin:"(^\\s*)(%[^\\b]+?)\\b{",end:"}\\s*$",beginCaptures:{2:{name:"meta.tag.haml"}},patterns:[{include:"orion.ruby#symbol"},{include:"orion.ruby#variable"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]}}}),{id:i[i.length-1].id,grammars:i,keywords:[]}}),define("orion/editor/stylers/text_x-jade/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/application_javascript/syntax"],function(e,t){var i=["&attributes","block","case","default","doctype","each","else","extends","for","if","include","mixin","unless","when","while"],n=[];return n.push.apply(n,e.grammars),n.push.apply(n,t.grammars),n.push({id:"orion.jade",contentTypes:["text/x-jade"],patterns:[{include:"#comment_singleLine"},{include:"#code"},{include:"#control"},{include:"#caseBranch"},{include:"#mixinWithParameters"},{include:"#mixinRefWithArguments"},{include:"#tagWithAttributes"},{include:"#interpolatedJS"},{include:"#interpolatedTag"},{include:"#mixin"},{include:"#mixinRef"},{include:"#doctype"},{include:"#filter"},{include:"#case"},{include:"#andAttributes"},{include:"#otherKeywords"},{include:"#tag"}],repository:{andAttributes:{match:"&attributes\\b",name:"keyword.operator.jade"},"case":{match:"(^\\s*)(case)\\b",captures:{2:{name:"keyword.control.jade"}}},caseBranch:{begin:"(^\\s*)(when|default)\\s*",end:":|$",contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}],beginCaptures:{2:{name:"keyword.control.jade"}}},code:{match:"(^\\s*- |= |!= ).*$",name:"source.js.embedded.jade",patterns:[{include:"orion.js"}]},comment_singleLine:{match:{match:"^\\s*//.*",literal:"//"},name:"comment.line.double-slash.jade",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},control:{begin:"(^\\s*)(if|else( if)?|each|for|unless|while)\\b",end:"$",beginCaptures:{2:{name:"keyword.control.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]},doctype:{match:"(^\\s*)(doctype.+$)",captures:{2:{name:"meta.tag.doctype.jade"}}},filter:{match:"(^\\s*)(:\\w+)",captures:{2:{name:"entity.other.filter.jade"}}},interpolatedJS:{begin:"(#{)",end:"(})",captures:{1:{name:"string.interpolated.js.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]},interpolatedTag:{begin:"(#\\[)",end:"(\\])",captures:{1:{name:"string.interpolated.tag.jade"}},patterns:[{begin:"(\\.|\\w+)\\s*\\(",end:"(\\))(/)?",beginCaptures:{1:{name:"meta.tag.jade"}},endCaptures:{2:{name:"meta.tag.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]}]},mixin:{match:"(^\\s*)(mixin)(\\s+)(\\w+)",captures:{2:{name:"keyword.operator.jade"},4:{name:"entity.name.mixin.jade"}}},mixinRef:{match:"(^\\s*)(\\+\\w+)",captures:{2:{name:"entity.name.mixin.jade"}}},mixinRefWithArguments:{begin:"(^\\s*)(\\+\\w+)\\s*\\(",end:"\\)|$",captures:{2:{name:"entity.name.mixin.jade"}},patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.lib#number_decimal"}]},mixinWithParameters:{begin:"(^\\s*)(mixin)(\\s+)(\\w+)\\s*\\(",end:"\\)|$",beginCaptures:{2:{name:"keyword.operator.jade"},4:{name:"entity.name.mixin.jade"}},patterns:[{match:"[^\\s,]+",name:"variable.parameter.jade"}]},otherKeywords:{match:"(^\\s*)(block|extends|include)\\b",captures:{2:{name:"keyword.operator.jade"}}},tag:{match:"(^\\s*)(\\w+|(?=\\.)|(?=#))(#\\w*|\\.\\w*)*(/?)",captures:{2:{name:"meta.tag.jade"},4:{name:"meta.tag.jade"}}},tagWithAttributes:{begin:"(^\\s*)(\\w+|(?=\\.)|(?=#))(#\\w*|\\.\\w*)*\\s*\\(",end:"(\\))(/)?",beginCaptures:{2:{name:"meta.tag.jade"}},endCaptures:{2:{name:"meta.tag.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]}}}),{id:n[n.length-1].id,grammars:n,keywords:i}}),define("orion/editor/stylers/text_x-lua/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["and","break","do","else","elseif","end","false","for","function","if","in","local","nil","not","or","repeat","return","then","true","until","while"],i=["assert","arg","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load","loadfile","loadstring","next","pairs","pcall","print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall"],n=["_G","LUA_INIT","LUA_PATH","LUA_CPATH","_VERSION"],o=[];return o.push.apply(o,e.grammars),o.push({id:"orion.lua",contentTypes:["text/x-luasrc","text/x-lua"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"#comment_block_dash_dash"},{include:"#comment_singleLine_dash_dash"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{include:"#base_functions"},{include:"#base_variables"},{include:"#reserved_underscore_capital"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.lua"}],repository:{comment_block_dash_dash:{begin:{match:"--\\[\\[",literal:"--[["},end:{match:"\\]\\]",literal:"]]"},name:"comment.block.dash-dash.lua",patterns:[{match:"(\\b)(TODO)(\\b)(((?!\\]\\]).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},comment_singleLine_dash_dash:{begin:{match:"--",literal:"--"},end:{match:"$",literal:""},name:"comment.line.dash-dash.lua",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},base_functions:{match:"\\b(?:"+i.join("|")+")\\b",name:"support.function.lua"},base_variables:{match:"\\b(?:"+n.join("|")+")\\b",name:"support.variable.lua"},reserved_underscore_capital:{match:"\\b_[A-Z]*\\b",name:"constant.other.userdefined.lua"}}}),{id:o[o.length-1].id,grammars:o,keywords:t}}),define("orion/editor/stylers/text_x-php/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["abstract","and","array","as","callable","class","clone","const","declare","echo","empty","eval","extends","final","function","global","implements","include","include_once","insteadof","interface","instanceof","isset","list","namespace","new","or","parent","print","private","protected","public","require","require_once","static","trait","unset","use","var","xor","__halt_compiler","__CLASS__","__DIR__","__FILE__","__FUNCTION__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__"],i=["break","case","catch","continue","default","die","do","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","exit","finally","for","foreach","goto","if","return","switch","throw","try","while","yield"],n=["false","FALSE","null","NULL","true","TRUE"],o=["self"],r=[];return r.push.apply(r,e.grammars),r.push({id:"orion.php-core",patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{match:{match:"#.*",literal:"#"},name:"comment.line.number-sign.php",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},{begin:"<<<(\\w+)$",end:"^\\1;$",name:"string.unquoted.heredoc.php"},{begin:"<<<'(\\w+)'$",end:"^\\1;$",name:"string.unquoted.heredoc.nowdoc.php"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{match:"\\b0[bB][01]+\\b",name:"constant.numeric.binary.php"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.php"},{match:"\\b(?:"+i.join("|")+")\\b",name:"keyword.control.php"},{match:"\\b(?:"+n.join("|")+")\\b",name:"constant.language.php"},{match:"\\b(?:"+o.join("|")+")\\b",name:"variable.language.php"}]}),r.push({id:"orion.php",contentTypes:["text/x-php"],patterns:[{begin:"(?i)<(\\?|%(?!php))(?:=|php)?(?:\\s|$)",end:"[\\1]>",captures:{0:{name:"entity.name.declaration.php"}},contentName:"source.php.embedded",patterns:[{include:"orion.php-core"}]},{include:"orion.html"}]}),{id:r[r.length-1].id,grammars:r,keywords:t.concat(i).concat(n).concat(o)}}),define("orion/editor/stylers/text_x-python/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["and","as","assert","break","class","continue","def","del","exec","elif","else","except","Ellipsis","False","finally","for","from","global","if","import","in","is","lambda","not","None","NotImplemented","or","pass","print","raise","return","try","True","while","with","yield"],i=[];return i.push.apply(i,e.grammars),i.push({id:"orion.python",contentTypes:["text/x-python"],patterns:[{begin:"(['\"])\\1\\1",end:"\\1\\1\\1",name:"string.quoted.triple.python"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{begin:{match:"#",literal:"#"},end:{match:"$",literal:""},name:"comment.line.number-sign.python",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.python"}],repository:{number_decimal:{match:"\\b-?(?:\\.\\d+|\\d+\\.?\\d*)[lL]?\\b",name:"constant.numeric.number.python"}}}),{id:i[i.length-1].id,grammars:i,keywords:t}}),define("orion/editor/stylers/text_x-go/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["break","case","const","continue","default","defer","else","fallthrough","false","for","func","goto","go","if","import","nil","package","range","return","select","switch","true","type","var"],i=[];return i.push.apply(i,e.grammars),i.push({id:"orion.go",contentTypes:["text/x-go"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{begin:"`",end:"`",name:"string.quoted.raw.go"},{include:"orion.c-like#comment_singleLine"},{include:"orion.c-like#comment_block"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.go"},{match:"\\b(?:len|cap|new|make|append|close|copy|delete|complex|real|imag|panic|recover)\\b",name:"support.function.go"},{match:"\\b(?:bool|chan|uint8|uint16|uint32|uint64|int8|int16|int32|int64|float32|float64|complex64|complex128|byte|map|rune|uint|interface|int|uintptr|string|struct|error)\\b",name:"support.function.type"}]}),{id:i[i.length-1].id,grammars:i,keywords:t}}),define("orion/editor/stylers/text_x-objective-c/syntax",["orion/editor/stylers/text_x-csrc/syntax"],function(e){var t=["atomic","BOOL","bycopy","byref","Class","id","IMP","inout","in","nil","nonatomic","NO","NULL","oneway","out","Protocol","retain","SEL","self","super","YES"],i=["@catch","@class","@dynamic","@end","@finally","@implementation","@interface","@private","@property","@protected","@protocol","@public","@selector","@synthesize","@throw","@try"],n=["import"],o=[];return o.push.apply(o,e.grammars),o.push({id:"orion.objectiveC",contentTypes:["text/x-objective-c"],patterns:[{include:"#objectiveCString"},{include:"orion.c"},{include:"#objectiveCDirective"},{include:"#objectiveCKeyword"}],repository:{objectiveCDirective:{match:"#\\s*(?:"+n.join("|")+")\\b[^$]*",name:"meta.preprocessor.objective-c"},objectiveCKeyword:{match:"(\\b(?:"+t.join("|")+")|(?:"+i.join("|")+"))\\b",name:"keyword.operator.objective-c"},objectiveCString:{match:'@"(?:\\\\.|[^"])*"?',name:"string.quoted.double.objective-c"}}}),{id:o[o.length-1].id,grammars:o,keywords:e.keywords.concat(t).concat(n).concat(i)}}),define("orion/editor/stylers/text_x-properties/syntax",[],function(){var e=[];return e.push({id:"orion.properties",contentTypes:["text/x-properties"],patterns:[{match:"^\\s*#[^$]*",name:"comment.line.properties"},{begin:"(^[^=]*)(=)",end:".*[^\\\\]$",beginCaptures:{1:{name:"entity.name.properties"},2:{name:"punctuation.operator.properties"}},endCaptures:{0:{name:"string.unquoted.properties"}},contentName:"string.unquoted.properties"}]}),{id:e[e.length-1].id,grammars:e,keywords:[]}}),define("orion/editor/stylers/text_x-smarty/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/text_html/syntax","orion/editor/stylers/text_x-php/syntax"],function(e,t,i){var n=["false","no","off","on","true","yes"],o="{",r="}",s=[];return s.push.apply(s,e.grammars),s.push.apply(s,t.grammars),s.push.apply(s,i.grammars),s.push({id:"orion.smarty",contentTypes:["text/x-smarty"],patterns:[{include:"orion.html"},{include:"#smartyCommentBlock"},{include:"#literalBlock"},{include:"#phpBlock"},{include:"#smartyBlock"}],repository:{literalBlock:{begin:"({)literal(})",end:"({)/literal(})",captures:{1:"punctuation.brace.begin.smarty",2:"punctuation.brace.end.smarty"}},phpBlock:{begin:"({)php(})",end:"({)/php(})",captures:{1:"punctuation.brace.begin.smarty",2:"punctuation.brace.end.smarty"},contentName:"source.php.embedded.smarty",patterns:[{include:"orion.php-core"}]},smartyBlock:{begin:"("+o+")",end:"("+r+")",captures:{1:"punctuation.brace.begin.smarty",2:"punctuation.brace.end.smarty"},patterns:[{include:"orion.lib#string_singleQuote"},{include:"#smartyString_doubleQuote"},{include:"#smartyVariable"},{include:"#smartyConfigVariable"},{include:"#smartyConstant"},{include:"orion.lib#number_decimal"}]},smartyCommentBlock:{begin:{match:o+"\\*",literal:o+"*"},end:{match:"\\*"+r,literal:"*"+r},name:"comment.block.smarty"},smartyConfigVariable:{match:"#\\w+#",name:"variable.other.config.smarty"},smartyConstant:{match:"\\b(?:"+n.join("|")+")\\b",name:"constant.language.smarty"},smartyEscapedVariable:{match:"`\\$[^`]+`",name:"variable.other.escaped.smarty"},smartyString_doubleQuote:{begin:'"',end:'"',name:"string.quoted.double.smarty",patterns:[{include:"#smartyEscapedVariable"},{include:"#smartyVariable"},{include:"#smartyConfigVariable"}]},smartyVariable:{match:"\\$(?:smarty\\.(?:config|server)\\.)?\\w+",name:"variable.other.smarty"}}}),{id:s[s.length-1].id,grammars:s,keywords:[]}}),define("orion/editor/stylers/text_x-swift/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["associativity","as","class","convenience","deinit","didSet","dynamicType","dynamic","enum","extension","final","func","get","import","infix","init","inout","internal","in","is","lazy","left","let","mutating","none","nonmutating","operator","optional","override","postfix","precedence","prefix","private","protocol","Protocol","public","required","right","Self","set","static","struct","subscript","typealias","Type","unowned","var","weak","willSet","@objc"],i=["break","case","continue","default","do","else","fallthrough","for","if","return","switch","where","while"],n=["false","nil","true"],o=["self","super"],r=["__COLUMN__","__FILE__","__FUNCTION__","__LINE__"],s=[];return s.push.apply(s,e.grammars),s.push({id:"orion.swift",contentTypes:["text/x-swift"],patterns:[{include:"#string_doubleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"#comment_block"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"#number_binary"},{include:"#number_hex"},{include:"#number_octal"},{include:"#number_decimal"},{include:"#keywords_operator"},{include:"#keywords_control"},{include:"#constants"},{include:"#languageVars1"},{include:"#languageVars2"}],repository:{comment_block:{begin:{match:"/\\*",literal:"/*"},end:{match:"\\*/",literal:"*/"},name:"comment.block.swift",patterns:[{include:"#comment_block"},{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task.swift"},4:{name:"comment.block.swift"}}}]},constants:{match:"(^|[^\\w`])("+n.join("|")+")\\b",captures:{2:{name:"constant.language.swift"}}},keywords_operator:{match:"(^|[^\\w`])("+t.join("|")+")\\b",captures:{2:{name:"keyword.operator.swift"}}},keywords_control:{match:"(^|[^\\w`])("+i.join("|")+")\\b",captures:{2:{name:"keyword.control.swift"}}},languageVars1:{match:"(^|[^\\w`])("+o.join("|")+")\\b",captures:{2:{name:"variable.language.swift"}}},languageVars2:{match:"(^|[^\\w`])("+r.join("|")+")(?:$|[^\\w])",captures:{2:{name:"variable.language.swift"}}},number_binary:{match:"\\b0b[01]+\\b",name:"constant.numeric.binary.swift"},number_decimal:{match:"\\b-?(?:\\.\\d[\\d_]*|\\d[\\d_]*\\.?[\\d_]*)(?:[eE][+-]?\\d[\\d_]*)?\\b",name:"constant.numeric.decimal.swift"},number_hex:{match:"\\b0[xX](?:\\.[0-9A-Fa-f][0-9A-Fa-f_]*|[0-9A-Fa-f][0-9A-Fa-f_]*\\.?[0-9A-Fa-f_]*)(?:[pP][+-]?\\d[\\d_]*)?\\b",name:"constant.numeric.hex.swift"},number_octal:{match:"\\b0o[01234567][01234567_]*\\b",name:"constant.numeric.octal.swift"},segment:{begin:"\\(",end:"\\)",patterns:[{include:"#segment"},{include:"#comment_block"},{include:"#number_binary"},{include:"#number_hex"},{include:"#number_octal"},{include:"#number_decimal"},{include:"#keywords_operator"},{include:"#keywords_control"},{include:"#constants"},{include:"#languageVars1"},{include:"#languageVars2"}]},string_doubleQuote:{match:'"(?:\\\\.|[^"])*"?',name:"string.quoted.double.swift",patterns:[{begin:"\\\\\\(",end:"\\)",name:"string.interpolated.swift",patterns:[{include:"#segment"},{include:"#comment_block"},{include:"#number_binary"},{include:"#number_hex"},{include:"#number_octal"},{include:"#number_decimal"},{include:"#keywords_operator"},{include:"#keywords_control"},{include:"#constants"},{include:"#languageVars1"},{include:"#languageVars2"}]}]}}}),{id:s[s.length-1].id,grammars:s,keywords:t.concat(i).concat(n).concat(o).concat(r)}}),define("orion/editor/stylers/text_x-typescript/syntax",["orion/editor/stylers/application_javascript/syntax"],function(e){var t=["constructor","declare","module"],i=["any","boolean","number","string"],n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.typescript",contentTypes:["text/x-typescript"],patterns:[{include:"orion.js"},{include:"#keywords"},{include:"#types"}],repository:{keywords:{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.typescript"},types:{match:"\\b(?:"+i.join("|")+")\\b",name:"storage.type.typescript"}}}),{id:n[n.length-1].id,grammars:n,keywords:t.concat(i)}}),define("orion/editor/stylers/text_x-vb/syntax",["orion/editor/stylers/lib/syntax"],function(e){var t=["AddHandler","AddressOf","Aggregate","Alias","AndAlso","And","Ansi","Assembly","Async","As","Auto","Await","Binary","Boolean","ByRef","Byte","ByVal","Call","Case","Catch","CBool","CByte","CChar","CDate","CDbl","CDec","Char","CInt","Class","CLng","CObj","Compare","Const","CShort","CSng","CStr","CType","Custom","Date","Decimal","Declare","Default","Delegate","Dim","DirectCast","Distinct","Double","Do","Each","ElseIf","Else","EndIf","End","Enum","Equals","Erase","Error","Event","Exit","Explicit","False","Finally","For","Friend","From","Function","GetType","Get","GoSub","GoTo","Group By","Group Join","Handles","If","Implements","Imports","Inherits","Integer","Interface","Into","In","IsFalse","IsTrue","Is","Iterator","Join","Key","Let","Lib","Like","Long","Loop","Me","Mid","Module","Mod","MustInherit","MustOverride","MyBase","MyClass","Namespace","New","Next","Nothing","NotInheritable","NotOverridable","Not","Object","Off","On","Optional","Option","Order By","OrElse","Or","Overloads","Overridable","Overrides","ParamArray","Preserve","Private","Property","Protected","Public","RaiseEvent","ReadOnly","ReDim","REM","RemoveHandler","Resume","Return","Select","Set","Shadows","Shared","Short","Single","Skip While","Skip","Static","Step","Stop","Strict","String","Structure","Sub","SyncLock","Take While","Take","Text","Then","Throw","To","True","Try","TypeOf","Unicode","Until","Variant","Wend","When","Where","While","WithEvents","With","WriteOnly","Xor","Yield"],i=["Const","ElseIf","Else","End","ExternalSource","If","Region"],n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.vb",contentTypes:["text/x-vb"],patterns:[{match:"^\\s*#(?:"+i.join("|")+")\\b[^$]*",name:"meta.preprocessor.vb"},{include:"orion.lib#string_doubleQuote"},{include:"#doc"},{include:"#comment"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"#number_hex"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.operator.vb"}],repository:{comment:{begin:{match:"'",literal:"'"},end:{match:"$",literal:""},name:"comment.line.vb",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},doc:{match:{match:"'''.*",literal:"'''"},name:"comment.line.documentation.vb",patterns:[{match:"<[^\\s>]*>",name:"meta.documentation.tag"},{include:"orion.lib#todo_comment_singleLine"}]},number_hex:{match:"&[hH][0-9A-Fa-f]+\\b",name:"constant.numeric.hex.vb"}}}),{id:n[n.length-1].id,grammars:n,keywords:t}}),define("orion/editor/stylers/text_x-vbhtml/syntax",["orion/editor/stylers/application_xml/syntax","orion/editor/stylers/text_html/syntax","orion/editor/stylers/text_x-vb/syntax"],function(e,t,i){var n=[];return n.push.apply(n,e.grammars),n.push.apply(n,t.grammars),n.push.apply(n,i.grammars),n.push({id:"orion.vbhtml",contentTypes:["text/x-vbhtml"],patterns:[{include:"#vbhtmlComment"},{include:"#codeBlock"},{include:"#expression"},{include:"#reference"},{include:"orion.html"}],repository:{vbhtmlComment:{begin:{match:"@\\*",literal:"@*"},end:{match:"\\*@",literal:"*@"},name:"comment.block.vbhtml"},codeBlock:{begin:"(?i)^\\s*@code",end:"(?i)end code",captures:{0:{name:"entity.name.declaration.vb"}},contentName:"source.vb.embedded.vbhtml",patterns:[{include:"orion.xml#tag"},{include:"#reference"},{include:"orion.vb"}]},expression:{match:"(?i)^\\s*@(?!code)[^$]*",name:"source.vb.embedded.vbhtml",patterns:[{include:"#reference"},{include:"orion.vb"}]},reference:{match:"@",name:"entity.name.declaration.vb"}}}),{id:n[n.length-1].id,grammars:n,keywords:[]}}),define("orion/editor/stylers/application_x-ejs/syntax",["orion/editor/stylers/application_javascript/syntax","orion/editor/stylers/application_xml/syntax"],function(e,t){var i=[];return i.push.apply(i,e.grammars),i.push.apply(i,t.grammars),i.push({id:"orion.ejs",contentTypes:["application/x-ejs"],patterns:[{include:"orion.xml#comment"},{include:"orion.xml#doctype"},{begin:"<%=?(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.declaration.js"}},contentName:"source.js.embedded.ejs",patterns:[{include:"orion.js"}]},{include:"orion.xml#tag"},{include:"orion.xml#ampersandEscape"}]}),{id:i[i.length-1].id,grammars:i,keywords:[]}}),define("orion/editor/stylers/text_x-yaml/syntax",[],function(){var e=["false","null","true"],t=["!!bool","!!float","!!int","!!map","!!null","!!omap","!!seq","!!str"],i="orion.yaml",n={id:i,contentTypes:["text/x-yaml"],patterns:[{include:"#numberSignComment"},{match:"^%(?:YAML|TAG)\\s.*",name:"meta.directive.yaml"},{begin:"^.*?:(?:[\\t ]|$)",end:"$",contentName:"string.unquoted.yaml",beginCaptures:{0:{name:"entity.name.key.yaml"}},patterns:[{include:"#numberSignComment"},{match:"^\\s*[&*]\\s*$",name:"entity.name.tag.yaml"},{match:"(?i)^\\s*(?:"+e.join("|")+")\\s*$",name:"keyword.operator.yaml"},{match:"(?i)^\\s*(?:"+t.join("|")+")\\b",name:"keyword.operator.yaml"},{match:"(?i)^\\s*(?:-?[0-9]*(?:\\.[0-9]+)?(?:e[-+][1-9][0-9]*)?)\\s*$",name:"constant.numeric.yaml"},{match:"(?i)^\\s*(?:-?[1-9][0-9]*|0|-?\\.inf|\\.nan)\\s*$",name:"constant.numeric.yaml"}]},{match:"---|\\.\\.\\.",name:"meta.separator.yaml"}],repository:{numberSignComment:{begin:{match:"(?:^|\\s)#",literal:"#"},end:{match:"$",literal:""},name:"comment.line.number-sign.yaml",patterns:[{include:"orion.lib#todo_comment_singleLine"}]}}};return{id:i,grammars:[n],keywords:t.concat(e)}}),define("orion/staticDataSource",["orion/Deferred","orion/editor/textStyler","orion/editor/stylers/application_javascript/syntax","orion/editor/stylers/application_vnd.coffeescript/syntax","orion/editor/stylers/application_x-jsp/syntax","orion/editor/stylers/application_xquery/syntax","orion/editor/stylers/application_sql/syntax","orion/editor/stylers/text_css/syntax","orion/editor/stylers/text_x-scss/syntax","orion/editor/stylers/text_x-less/syntax","orion/editor/stylers/text_html/syntax","orion/editor/stylers/text_jsx/syntax","orion/editor/stylers/application_json/syntax","orion/editor/stylers/text_x-csrc/syntax","orion/editor/stylers/text_x-csharp/syntax","orion/editor/stylers/text_x-cshtml/syntax","orion/editor/stylers/text_x-c__src/syntax","orion/editor/stylers/text_x-dockerfile/syntax","orion/editor/stylers/text_x-erlang/syntax","orion/editor/stylers/text_x-haml/syntax","orion/editor/stylers/text_x-java-source/syntax","orion/editor/stylers/text_x-jade/syntax","orion/editor/stylers/text_x-lua/syntax","orion/editor/stylers/text_x-php/syntax","orion/editor/stylers/text_x-python/syntax","orion/editor/stylers/text_x-ruby/syntax","orion/editor/stylers/text_x-go/syntax","orion/editor/stylers/text_x-objective-c/syntax","orion/editor/stylers/text_x-properties/syntax","orion/editor/stylers/text_x-smarty/syntax","orion/editor/stylers/text_x-swift/syntax","orion/editor/stylers/text_x-typescript/syntax","orion/editor/stylers/text_x-vb/syntax","orion/editor/stylers/text_x-vbhtml/syntax","orion/editor/stylers/application_x-ejs/syntax","orion/editor/stylers/application_xml/syntax","orion/editor/stylers/text_x-yaml/syntax"],function(e,t,i,n,o,r,s,a,l,d,c,h,u,p,f,g,_,m,v,y,x,b,w,C,T,L,k,D,A,S,E,O,N,M,I,B,R){function F(){this.styler=null}var P=[{id:"text/plain",name:"Text",extension:["txt"],imageClass:"file-sprite-text modelDecorationSprite"},{id:"application/javascript","extends":"text/plain",name:"JavaScript",extension:["js"],imageClass:"file-sprite-javascript modelDecorationSprite"},{id:"application/vnd.coffeescript","extends":"text/plain",name:"CoffeeScript",extension:["coffee"]},{id:"text/jsx","extends":"text/plain",name:"JSX",extension:["jsx"]},{id:"text/html","extends":"text/plain",name:"HTML",extension:["html","htm"],imageClass:"file-sprite-html modelDecorationSprite"},{id:"text/css","extends":"text/plain",name:"CSS",extension:["css"],imageClass:"file-sprite-css modelDecorationSprite"},{id:"text/x-scss","extends":"text/plain",name:"SCSS",extension:["scss","sass"]},{id:"text/x-less","extends":"text/plain",name:"Less",extension:["less"]},{id:"application/json","extends":"text/plain",name:"JSON",extension:["json"],imageClass:"file-sprite-text modelDecorationSprite"},{id:"application/sql","extends":"text/plain",name:"SQL",extension:["sql"]},{id:"application/xml","extends":"text/plain",name:"XML",extension:["xml"],imageClass:"file-sprite-xml modelDecorationSprite"},{id:"application/x-ejs","extends":"text/plain",name:"Embedded Javascript",extension:["ejs"],imageClass:"file-sprite-javascript modelDecorationSprite"},{id:"text/x-java-source","extends":"text/plain",name:"Java",extension:["java"]},{id:"application/x-jsp","extends":"text/plain",name:"Java Server Page",extension:["jsp"]},{id:"text/x-jade","extends":"text/plain",name:"Jade",extension:["jade"]},{id:"text/x-python","extends":"text/plain",name:"Python",extension:["py","rpy","pyw","cpy","SConstruct","Sconstruct","sconstruct","SConscript","gyp","gypi"]},{id:"text/x-ruby","extends":"text/plain",name:"Ruby",extension:["rb","rbx","rjs","Rakefile","rake","cgi","fcgi","gemspec","irbrc","capfile","ru","prawn","Gemfile","Guardfile","Vagrantfile","Appraisals","Rantfile"]},{id:"text/x-go",name:"Go",extension:["go"],"extends":"text/plain"},{id:"text/x-launch","extends":"application/json",name:"Launch file",extension:["launch"]},{id:"text/x-objective-c","extends":"text/plain",name:"Objective-C",extension:["m","mm","h"]},{id:"text/x-php","extends":"text/plain",name:"PHP",extension:["php","php3","php4","php5","phpt","phtml","aw","ctp"]},{id:"text/x-properties","extends":"text/plain",name:"Properties",extension:["properties"]},{id:"text/x-smarty","extends":"text/plain",name:"Smarty",extension:["tpl"]},{id:"text/x-swift","extends":"text/plain",name:"Swift",extension:["swift"]},{id:"text/x-typescript","extends":"text/plain",name:"Typescript",extension:["ts"]},{id:"text/x-markdown","extends":"text/plain",name:"Markdown",extension:["md"]},{id:"text/x-yaml","extends":"text/plain",name:"YAML",extension:["yaml","yml"]},{id:"text/conf","extends":"text/plain",name:"Conf",extension:["conf"]},{id:"text/sh","extends":"text/plain",name:"sh",extension:["sh"]},{id:"application/browser-renderable",name:"browser-renderable"},{id:"application/pdf","extends":"application/browser-renderable",name:"PDF",extension:["pdf"]},{id:"application/octet-stream",name:"octet-stream",extension:["exe","bin","doc","ppt"]},{id:"application/zip","extends":"application/octet-stream",name:"ZIP",extension:["war","jar","zip","rar","gz","tar"]},{id:"text/x-arduino","extends":"text/x-csrc",name:"Arduino",extension:["ino","pde"]},{id:"text/x-csrc","extends":"text/plain",name:"C",extension:["c","h"]},{id:"text/x-csharp","extends":"text/plain",name:"C#",extension:["cs"]},{id:"text/x-cshtml","extends":"text/plain",name:"cshtml",extension:["cshtml"]},{id:"text/x-c++src","extends":"text/plain",name:"C++",extension:["cpp","hpp"]},{id:"text/x-dockerfile","extends":"text/plain",name:"dockerfile",filename:["dockerfile"]},{id:"text/x-erlang","extends":"text/plain",name:"Erlang",extension:["erl","hrl"]},{id:"text/x-haml","extends":"text/plain",name:"Haml",extension:["haml"]},{id:"text/x-lua","extends":"text/plain",name:"Lua",extension:["lua"]},{id:"application/xquery","extends":"text/plain",name:"XQuery",extension:["xq","xqy","xquery"]},{id:"text/x-vb","extends":"text/plain",name:"VB.NET",extension:["vb"]},{id:"text/x-vbhtml","extends":"text/plain",name:"vbhtml",extension:["vbhtml"]},{id:"image/gif",name:"GIF",extension:["gif"],imageClass:"file-sprite-image modelDecorationSprite"},{id:"image/jpeg",name:"JPG",extension:["jpg","jpeg","jpe"],imageClass:"file-sprite-image modelDecorationSprite"},{id:"image/ico",name:"ICO",extension:["ico"],imageClass:"file-sprite-image modelDecorationSprite"},{id:"image/png",name:"PNG",extension:["png"],imageClass:"file-sprite-image modelDecorationSprite"},{id:"image/tiff",name:"TIFF",extension:["tif","tiff"],imageClass:"file-sprite-image modelDecorationSprite"},{id:"image/svg",name:"SVG",extension:["svg"],imageClass:"file-sprite-image modelDecorationSprite"}]; +return F.prototype={setup:function(e,t,i){return this.styler&&(this.styler.destroy&&this.styler.destroy(),this.styler=null),this._highlight(e,t,i)},highlight:function(e,t,i){var n=i.getTextView(),o=i.getAnnotationModel();return this._highlight(t,n,o)},_highlight:function(F,P,W){this.styler&&(this.styler.destroy(),this.styler=null);var V=null;if(F)switch(F.id){case"application/javascript":V=new t.createPatternBasedAdapter(i.grammars,"orion.js",F.id);break;case"application/vnd.coffeescript":V=new t.createPatternBasedAdapter(n.grammars,"orion.coffeescript",F.id);break;case"application/x-ejs":V=new t.createPatternBasedAdapter(I.grammars,"orion.ejs",F.id);break;case"text/css":V=new t.createPatternBasedAdapter(a.grammars,"orion.css",F.id);break;case"text/x-scss":V=new t.createPatternBasedAdapter(l.grammars,"orion.scss",F.id);break;case"text/x-less":V=new t.createPatternBasedAdapter(d.grammars,"orion.less",F.id);break;case"text/html":V=new t.createPatternBasedAdapter(c.grammars,"orion.html",F.id);break;case"text/jsx":V=new t.createPatternBasedAdapter(h.grammars,"orion.jsx",F.id);break;case"text/x-java-source":V=new t.createPatternBasedAdapter(x.grammars,"orion.java",F.id);break;case"application/x-jsp":V=new t.createPatternBasedAdapter(o.grammars,"orion.jsp",F.id);break;case"application/json":case"text/x-launch":V=new t.createPatternBasedAdapter(u.grammars,"orion.json",F.id);break;case"application/sql":V=new t.createPatternBasedAdapter(s.grammars,"orion.sql",F.id);break;case"text/x-jade":V=new t.createPatternBasedAdapter(b.grammars,"orion.jade",F.id);break;case"text/x-python":V=new t.createPatternBasedAdapter(T.grammars,"orion.python",F.id);break;case"text/x-ruby":V=new t.createPatternBasedAdapter(L.grammars,"orion.ruby",F.id);break;case"text/x-go":V=new t.createPatternBasedAdapter(k.grammars,"orion.go",F.id);break;case"text/x-objective-c":V=new t.createPatternBasedAdapter(D.grammars,"orion.objectiveC",F.id);break;case"text/x-php":V=new t.createPatternBasedAdapter(C.grammars,"orion.php",F.id);break;case"text/x-properties":V=new t.createPatternBasedAdapter(A.grammars,"orion.properties",F.id);break;case"text/x-smarty":V=new t.createPatternBasedAdapter(S.grammars,"orion.smarty",F.id);break;case"text/x-swift":V=new t.createPatternBasedAdapter(E.grammars,"orion.swift",F.id);break;case"text/x-typescript":V=new t.createPatternBasedAdapter(O.grammars,"orion.typescript",F.id);break;case"application/xml":case"application/xhtml+xml":V=new t.createPatternBasedAdapter(B.grammars,"orion.xml",F.id);break;case"text/x-yaml":V=new t.createPatternBasedAdapter(R.grammars,"orion.yaml",F.id);break;case"text/x-arduino":case"text/x-csrc":case"text/x-c":V=new t.createPatternBasedAdapter(p.grammars,"orion.c",F.id);break;case"text/x-csharp":V=new t.createPatternBasedAdapter(f.grammars,"orion.csharp",F.id);break;case"text/x-cshtml":V=new t.createPatternBasedAdapter(g.grammars,"orion.cshtml",F.id);break;case"text/x-c++src":V=new t.createPatternBasedAdapter(_.grammars,"orion.cpp",F.id);break;case"text/x-dockerfile":V=new t.createPatternBasedAdapter(m.grammars,"orion.dockerfile",F.id);break;case"text/x-erlang":V=new t.createPatternBasedAdapter(v.grammars,"orion.erlang",F.id);break;case"text/x-haml":V=new t.createPatternBasedAdapter(y.grammars,"orion.haml",F.id);break;case"text/x-lua":V=new t.createPatternBasedAdapter(w.grammars,"orion.lua",F.id);break;case"application/xquery":V=new t.createPatternBasedAdapter(r.grammars,"orion.xquery",F.id);break;case"text/x-vb":V=new t.createPatternBasedAdapter(N.grammars,"orion.vb",F.id);break;case"text/x-vbhtml":V=new t.createPatternBasedAdapter(M.grammars,"orion.vbhtml",F.id)}return V&&(this.styler=new t.TextStyler(P,W,V)),(new e).resolve()},getStyler:function(){return this.styler}},{ContentTypes:P,SyntaxHighlighter:F}}),define("orion/serviceTracker",[],function(){function e(e,n){function o(e){var t=e.getProperty("service.id"),i=this.addingService(e);i&&(d[t]=e,c[t]=i)}function r(e){var t=e.getProperty("service.id"),i=c[t];delete d[t],delete c[t],this.removedService(e,i)}function s(e){return-1!==e.getProperty("objectClass").indexOf(n)}this.serviceRegistry=e;var a,l,d={},c={},h=t;this.close=function(){if(h!==i)throw new Error("Already closed");h=t,e.removeEventListener("registered",a),e.removeEventListener("unregistering",l),a=null,l=null;var n=this;this.getServiceReferences().forEach(function(e){r.call(n,e)}),"function"==typeof this.onClose&&this.onClose()},this.getServiceReferences=function(){var e=Object.keys(d);return e.length?e.map(function(e){return d[e]}):null},this.open=function(d){if("undefined"==typeof d&&(d=!0),h!==t)throw new Error("Already open");h=i;var c=this;a=function(e){return s(e.serviceReference)&&(o.call(c,e.serviceReference),"function"==typeof c.onServiceAdded)?c.onServiceAdded(e.serviceReference,c.serviceRegistry.getService(e.serviceReference)):void 0},l=function(e){s(e.serviceReference)&&r.call(c,e.serviceReference)},e.addEventListener("registered",a),e.addEventListener("unregistering",l),d&&e.getServiceReferences(n).forEach(function(t){return o.call(c,t),"function"==typeof c.onServiceAdded?c.onServiceAdded(t,e.getService(t)):void 0}),"function"==typeof this.onOpen&&this.onOpen()}}var t=0,i=1;return e.prototype={addingService:function(e){return this.serviceRegistry.getService(e)},onOpen:null,onClose:null,onServiceAdded:null,removedService:function(){}},e}),define("orion/contentTypes",["orion/serviceTracker"],function(e){function t(e,t){return-1!==e.indexOf(t)}function i(e){switch(e&&e.id){case"image/jpeg":case"image/png":case"image/gif":case"image/ico":case"image/tiff":case"image/svg":return!0}return!1}function n(e){return e?"application/octet-stream"===e.id||"application/octet-stream"===e["extends"]:!1}function o(e,i){if("string"!=typeof e)return null;var n,o=null,r=e.indexOf(".");r++;for(var s=e.substring(r).toLowerCase(),a=0;a=0){o=n;break}t(n.extension,s)&&(o=n)}if(!o)for(r=s.indexOf(".");!o&&r>=0;){for(r++,s=s.substring(r),a=0;as;s++){this._addFileModeProperties(this._diffContents[s],o);var a=this._parseHunkRange(s);a&&this._hunkRanges.push(a)}if(0===this._hunkRanges.length)return o.outPutFile=e,o;this._DEBUG&&(console.log("***Diff contents: \n"),this._diffContents.forEach(function(e){console.log(e)}),console.log("***Hunk ranges: \n"),console.log(JSON.stringify(this._hunkRanges)));for(var l=0;l0){console.log(" **Diff content on change/add: \n");for(var t=0;th;h++)if(0!==this._diffContents[h].length){var u=this._diffContents[h][0];if("\\"!==u||i!==this._diffContents[h].substring(0,this._diffContents[h].length-1)&&i!==this._diffContents[h]){switch(u){case"-":case"+":case" ":break;default:continue}if(t!==u){switch("+"===u&&(d=h),"-"===u&&(c=h),t){case" ":a=this._hunkRanges[e][1]+r,l=this._hunkRanges[e][3]+s;break;case"-":this._createMinusBlock(a,l,this._hunkRanges[e][1]+r-a,c);break;case"+":this._createPlusBlock(a,l,this._hunkRanges[e][3]+s-l,d)}t=u}switch(u){case"-":r++;break;case"+":s++;break;case" ":r++,s++}}else"-"===t?this._oNewLineAtEnd=!1:" "===t?(this._nNewLineAtEnd=!1,this._oNewLineAtEnd=!1):this._nNewLineAtEnd=!1,h>n&&"\r"===this._diffContents[h-1][this._diffContents[h-1].length-1]&&(this._diffContents[h-1]=this._diffContents[h-1].substring(0,this._diffContents[h-1].length-1))}switch(t){case"-":this._createMinusBlock(a,l,this._hunkRanges[e][1]+r-a,c);break;case"+":this._createPlusBlock(a,l,this._hunkRanges[e][3]+s-l,d)}},_detectConflictes:function(e,t){if(0>e)return!1;for(var i=e+t,n=e;i>n;n++){var o=this._diffContents[n];if(o.indexOf("<<<<<")>-1||o.indexOf(">>>>>")>-1)return!0}return!1},_buildMap:function(e){for(var t,i=this._oBlocks.length,n=this._oFileContents.length,o=0,r=1,s=0;i>s;s++)t=this._oBlocks[s][0]-r,t>0&&(this._deltaMap.push([t,t,0]),o+=t),this._deltaMap.push(e&&this._detectConflictes(this._nBlocks[s][2],this._nBlocks[s][1])?[this._nBlocks[s][1],this._oBlocks[s][1],this._nBlocks[s][2]+1,1]:[this._nBlocks[s][1],this._oBlocks[s][1],this._nBlocks[s][2]+1]),o+=this._oBlocks[s][1],r=this._oBlocks[s][0]+this._oBlocks[s][1];if(n-r>0&&(this._deltaMap.push([n-r+1,n-r+1,0]),o+=n-r+1),n>o){t=n-o;var a=this._deltaMap[this._deltaMap.length-1];0===a[2]?(a[0]+=t,a[1]+=t):-1===a[2]?this._deltaMap.push([t,t,0]):this._nNewLineAtEnd===this._oNewLineAtEnd?this._deltaMap.push([t,t,0]):(this._nNewLineAtEnd&&(a[0]+=t),this._oNewLineAtEnd&&(a[1]+=t))}},_buildNewFile:function(){var e,t,i=1,n=!1,o=this._deltaMap.length;for(e=0;o>e;e++){if(n=!1,0===this._deltaMap[e][2]){for(t=0;t0)for(t=0;t=0?i:1)}else t.push(1)},_parseHunkRange:function(e){var t=this._diffContents[e],i=/^@@\s*-([\+|\-]*[\d]+)\s*,*\s*([\d]*)\s*\+([\+|\-]*[\d]+)\s*,*\s*([\d]*)\s*@@+/,n=/^@@\s*\+([\+|\-]*[\d]+)\s*,*\s*([\d]*)\s*-([\+|\-]*[\d]+)\s*,*\s*([\d]*)\s*@@+/,o=i.exec(t),r=null;return o&&5===o.length?(r=[e],this._converHRangeBody(o[1],r),this._converHRangeBody(o[2],r),this._converHRangeBody(o[3],r),this._converHRangeBody(o[4],r)):(o=n.exec(t),o&&5===o.length&&(r=[e],this._converHRangeBody(o[3],r),this._converHRangeBody(o[4],r),this._converHRangeBody(o[1],r),this._converHRangeBody(o[2],r))),r}},e}(),e}),define("orion/URITemplate",[],function(){function e(e){this._text=e}function t(e){return e.replace("%25","%")}function i(e,i){if("U"===i)return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()});if("U+R"===i)return encodeURI(e).replace(/%5B/g,"[").replace(/%5D/g,"]").replace(h,t);if("U+R-,"===i)return encodeURI(e).replace(/%5B/g,"[").replace(/%5D/g,"]").replace(/,/g,"%2C");throw new Error("Unknown allowed character set: "+i)}function n(e,t,n){for(var o=[],r=0;r=n&&n+r>i)return{mapperIndex:o,startFrom:n};if(o===e.length-1)break;n+=e[o][t]}return{mapperIndex:e.length-1,startFrom:n}},t.compareUtils.lookUpLineIndex=function(e,t,i){if(0===i)return 0;for(var n=0,o=0;i>o;o++)n+=e[o][t];return n},t.compareUtils.updateMapper=function(e,i,n,o,r){if(o!==r&&(o>0||r>0)){var s=t.compareUtils.lookUpMapper(e,i,n);if(s.mapperIndex<0)return;if(o>0)for(var a=o,l=n-s.startFrom,d=s.mapperIndex;d=a){e[d][i]-=a;break}e[d][i]-=c,a-=c,l=0}r>0&&(e[s.mapperIndex][i]+=r)}},t.compareUtils.overlapMapper=function(e,t,i,n,o){var r=i+e[t]-1;return i>r&&(r=i),n>o&&(o=n),n>r||i>o?!1:!0},t.compareUtils.findFirstDiff=function(e,i,n,o){for(var r=0,s=null,a=0;ao)&&(!t.compareUtils.overlapMapper(e[a],i,r,n,o)||(s={mapperIndex:a,startFrom:r},0===e[a][2]));a++)r+=e[a][i];return s},t.compareUtils.matchMapper=function(e,i,n,o){if(0===e.length)return n;var r=n+Math.round((o-n)/3),s=t.compareUtils.findFirstDiff(e,i,n,o),a=0===e[s.mapperIndex][i]?s.startFrom:s.startFrom+e[s.mapperIndex][i]-1,l=t.compareUtils.lookUpLineIndex(e,1-i,s.mapperIndex),d=s.startFrom-n;if(0===e[s.mapperIndex][2])return l-d;if(r>=s.startFrom&&a>=r)return l-Math.round((o-n)/3);if(rt?!1:e[t][3]?1===e[t][3]:!1},t.compareUtils.mergeDiffBlocks=function(e,t,i,n,o,r){for(var s=0;s0){for(var c="",h=0;h=p){var f=e.getLineEnd(p-1),g=e.getLineEnd(p-1,!0);f===g?(e.setText(r,f,f),a=p):a=p-1}var _=e.getLineStart(a);e.setText(c,_,_)}}},t.compareUtils.convertMergedLineNumber=function(e,i,n){var o=t.compareUtils.lookUpMapper(e,n?1:0,i),r=i;if(n||0===e[o.mapperIndex][2]||(r+=e[o.mapperIndex][1]),o.mapperIndex<0)return r;for(var s=0;s0)for(var r=n-1;r>-1;r--)t=""===o?"":"/",o=o+t+i[r].Name;return t=""===o?"":"/",o=o+t+e.Name},t.compareUtils}),define("orion/compare/compareRulers",["orion/compare/compareUtils"],function(e){var t=t||{};return t.CompareRuler=function(){function e(e,t,i){this._location=e||"left",this._overview=t||"page",this._rulerStyle=i,this._editor=null;var n=this;this._listener={onModelChanged:function(e){n._onModelChanged(e)}}}return e.prototype={setView:function(e){this._onModelChanged&&this._editor&&this._editor.removeEventListener("ModelChanged",this._listener.onModelChanged),this._editor=e,this._onModelChanged&&this._editor&&this._editor.addEventListener("ModelChanged",this._listener.onModelChanged)},getLocation:function(){return this._location},getOverview:function(){return this._overview},getAnnotationModel:function(){return null},addAnnotationType:function(){},isAnnotationTypeVisible:function(){return!1},removeAnnotationType:function(){},setAnnotationModel:function(){},getAnnotations:function(e,t){for(var i=[],n=e;t>n;n++){var o=this.getStyle(n);o&&(i[n]={html:this.getHTML(n),style:o})}return i},getWidestAnnotation:function(){return{html:this.getHTML(-1),style:this.getStyle(-1)}},getRulerStyle:function(){return this.getStyle(void 0)}},e}(),t.LineNumberCompareRuler=function(){function e(e,i,n,o,r,s){t.CompareRuler.call(this,n,"page",o),this._diffNavigator=e,this._oddStyle=r||{style:{backgroundColor:"white"}},this._evenStyle=s||{style:{backgroundColor:"white"}},this._numOfDigits=0,this._mapperColumnIndex=i}return e.prototype=new t.CompareRuler,e.prototype.getStyle=function(e){return void 0===e?this._rulerStyle:this._evenStyle},e.prototype.getHTML=function(e){var t=this._editor.getModel(),i=this._diffNavigator.getFeeder(0===this._mapperColumnIndex);if(!i)return"";if(-1===e)return t.getLineCount();if(i.getLineNumber){var n=i.getLineNumber(e);return-1===n?"":n+1}return e+1},e.prototype._onModelChanged=function(e){var t=e.start,i=this._editor.getModel(),n=i.getLineCount(),o=(n+"").length;if(this._numOfDigits!==o){this._numOfDigits=o;var r=i.getLineAtOffset(t);this._editor.redrawLines(r,n,this)}},e}(),t.CompareOverviewRuler=function(){function i(e,i,n,o){this._diffNavigator=n,this._onClick=o,t.CompareRuler.call(this,e,"document",i)}return i.prototype=new t.CompareRuler,i.prototype.getStyle=function(t){var i,n;if(void 0===t)i=this._rulerStyle||{},n=i.style||(i.style={}),n.lineHeight="1px",n.fontSize="1px",n.width="14px";else{if(i=-1!==t?{styleClass:"annotationOverview breakpoint"}||{}:{},n=i.style||(i.style={}),n.cursor="pointer",n.width="8px",n.left="2px",!(t>=0))return null;var o;if(!this._diffNavigator||!this._diffNavigator.getFeeder())return null;o=this._diffNavigator.getFeeder().getDiffBlocks();var r=e.getAnnotationIndex(o,t);if(-1===r)return null;var s,a=e.getAnnotationMapperIndex(o,r);s=this._diffNavigator.getMapper();var l=e.isMapperConflict(s,a);l&&(n.border="1px #FF0000 solid"),r===this._diffNavigator.getCurrentBlockIndex()&&(n.backgroundColor=l?"red":"blue");var d=this._diffNavigator.getFeeder().getDiffBlockH(r),c=this._diffNavigator.getFeeder().getOverviewLineCount();if(0>d)return null;var h=this._editor.getClientArea(),u=Math.floor(h.height*d/c);2>u&&(u=2),n.height=u+"px"}return i},i.prototype.setDiffNavigator=function(e){this._diffNavigator=e},i.prototype.getHTML=function(){return" "},i.prototype.onClick=function(e){void 0!==e&&this._onClick(e,this)},i.prototype._onModelChanged=function(){var e=this._editor.getModel(),t=e.getLineCount();t>0&&this._editor.redrawLines(0,1,this)},i}(),t.CompareCurveRuler=function(){function t(e){this._canvasDiv=e,this._mapper=void 0}return t.prototype={init:function(e,t,i,n){this._leftIniting=!0,this._rightIniting=!0,this._rightIniting=!0,this._mapper=e,this._leftEditor=t,this._rightEditor=i,this._leftTextView=t.getTextView(),this._rightTextView=i.getTextView(),this._diffNavigator=n,this.render()},matchPositionFrom:function(t){var i=t?this._leftTextView:this._rightTextView,n=t?this._rightTextView:this._leftTextView,o=i.getTopIndex(),r=i.getBottomIndex(),s=e.matchMapper(this._mapper,t?0:1,o,r);n.setTopIndex(s)},copyTo:function(e){if(this._diffNavigator.iterator){var t=this._diffNavigator.iterator.cursor();if(t){var i;if(i="word"===t.type?!t.copied&&!t.parent.copied:!t.copied,!i)return;var n=e?this._rightTextView.getText(t.oldA.start,t.oldA.end):this._leftTextView.getText(t.newA.start,t.newA.end),o=e?t.newA:t.oldA,r=e?this._leftTextView:this._rightTextView;r.setText(n,o.start,o.end),t.copied=!0}}},render:function(){if(this._mapper){var t=this._canvasDiv.getContext("2d");t.clearRect(0,0,this._canvasDiv.width,this._canvasDiv.height),t.strokeStyle="#AAAAAA",t.lineWidth=1,t.beginPath();var i=this._leftTextView.getTopIndex(),n=this._leftTextView.getBottomIndex(),o=this._rightTextView.getTopIndex(),r=this._rightTextView.getBottomIndex();this._leftLineH=this._leftTextView.getLineHeight(),this._rightLineH=this._rightTextView.getLineHeight();for(var s=0,a=0,l=!1,d=0;d0||t.addedLineCount>0)&&this.render()}return i?this._rightIniting=!1:this._leftIniting=!1,n}},t}(),t}),define("orion/regex",[],function(){function e(e){return e.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&")}function t(e){var t=/^\s*\/(.+)\/([gim]{0,3})\s*$/.exec(e);return t?{pattern:t[1],flags:t[2]}:null}return{escape:e,parse:t}}),define("orion/editor/textModel",["orion/editor/eventTarget","orion/regex","orion/util"],function(e,t,i){function n(e,t){this._lastLineIndex=-1,this._text=[""],this._lineOffsets=[0],this.setText(e),this.setLineDelimiter(t)}return n.prototype={destroy:function(){},find:function(e){this._text.length>1&&(this._text=[this._text.join("")]);var i=e.string,n=e.regex,o=i,r="",s=e.caseInsensitive;if(o)if(n){var a=t.parse(o);a&&(o=a.pattern,r=a.flags)}else o=i.replace(/([\\$\^*\/+?\.\(\)|{}\[\]])/g,"\\$&"),s&&(o=o.replace(/[iI\u0130\u0131]/g,"[Iiİı]"));var l,d=null;if(o){var c=e.reverse,h=e.wrap,u=e.wholeWord,p=e.start||0,f=e.end,g=null!==f&&void 0!==f;-1===r.indexOf("g")&&(r+="g"),-1===r.indexOf("m")&&(r+="m"),s&&-1===r.indexOf("i")&&(r+="i"),u&&(o="\\b"+o+"\\b");var _,m,v=this._text[0],y=0;if(g){var x=f>p?p:f,b=f>p?f:p;v=v.substring(x,b),y=x}var w=new RegExp(o,r);c?l=function(){var e=null;for(w.lastIndex=0;;){if(m=w.lastIndex,_=w.exec(v),m===w.lastIndex)return null;if(!_)break;if(_.index+y=0&&i>e))return null;var n=this._lineOffsets[e];if(i>e+1){var o=this.getText(n,this._lineOffsets[e+1]);if(t)return o;for(var r,s=o.length;10===(r=o.charCodeAt(s-1))||13===r;)s--;return o.substring(0,s)}return this.getText(n)},getLineAtOffset:function(e){var t=this.getCharCount();if(!(e>=0&&t>=e))return-1; +var i=this.getLineCount();if(e===t)return i-1;var n,o,r=this._lastLineIndex;if(r>=0&&i>r&&(n=this._lineOffsets[r],o=i>r+1?this._lineOffsets[r+1]:t,e>=n&&o>e))return r;for(var s=i,a=-1;s-a>1;)if(r=Math.floor((s+a)/2),n=this._lineOffsets[r],o=i>r+1?this._lineOffsets[r+1]:t,n>=e)s=r;else{if(o>e){s=r;break}a=r}return this._lastLineIndex=s,s},getLineCount:function(){return this._lineOffsets.length},getLineDelimiter:function(){return this._lineDelimiter},getLineEnd:function(e,t){var i=this.getLineCount();if(!(e>=0&&i>e))return-1;if(i>e+1){var n=this._lineOffsets[e+1];if(t)return n;for(var o,r=this.getText(Math.max(this._lineOffsets[e],n-2),n),s=r.length;10===(o=r.charCodeAt(s-1))||13===o;)s--;return n-(r.length-s)}return this.getCharCount()},getLineStart:function(e){return e>=0&&e=e));)n+=i,o++;for(var r=n,s=o;o=t));)n+=i,o++;var a=n,l=o;if(s>=this._text.length||l>=this._text.length||s>l)return"";if(s===l)return this._text[s].substring(e-r,t-a);var d=this._text[s].substring(e-r),c=this._text[l].substring(0,t-a);return d+this._text.slice(s+1,l).join("")+c},onChanging:function(e){return this.dispatchEvent(e)},onChanged:function(e){return this.dispatchEvent(e)},setLineDelimiter:function(e,t){if("auto"===e&&(e=void 0,this.getLineCount()>1&&(e=this.getText(this.getLineEnd(0),this.getLineEnd(0,!0)))),this._lineDelimiter=e?e:i.platformDelimiter,t){var n=this.getLineCount();if(n>1){for(var o=new Array(n),r=0;n>r;r++)o[r]=this.getLine(r);this.setText(o.join(this._lineDelimiter))}}},setText:function(e,t,i){if(void 0===e&&(e=""),void 0===t&&(t=0),void 0===i&&(i=this.getCharCount()),t!==i||""!==e){for(var n=this.getLineAtOffset(t),o=this.getLineAtOffset(i),r=t,s=i-t,a=o-n,l=e.length,d=0,c=this.getLineCount(),h=0,u=0,p=0,f=[];;){if(-1!==h&&p>=h&&(h=e.indexOf("\r",p)),-1!==u&&p>=u&&(u=e.indexOf("\n",p)),-1===u&&-1===h)break;p=-1!==h&&-1!==u?h+1===u?u+1:(u>h?h:u)+1:-1!==h?h+1:u+1,f.push(t+p),d++}var g={type:"Changing",text:e,start:r,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:d};if(this.onChanging(g),0===f.length){var _,m=this.getLineStart(n);_=c>o+1?this.getLineStart(o+1):this.getCharCount(),t!==m&&(e=this.getText(m,t)+e,t=m),i!==_&&(e+=this.getText(i,_),i=_)}for(var v=l-s,y=n+a+1;c>y;y++)this._lineOffsets[y]+=v;var x,b=5e4,w=b;if(f.length=t));)L+=T,k++;for(var D=L,A=k;k=i));)L+=T,k++;var S=L,E=k,O=this._text[A],N=this._text[E],M=O.substring(0,t-D),I=N.substring(i-S),B=[A,E-A+1];M&&B.push(M),e&&B.push(e),I&&B.push(I),Array.prototype.splice.apply(this._text,B),0===this._text.length&&(this._text=[""]);var R={type:"Changed",start:r,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:d};this.onChanged(R)}}},e.EventTarget.addMixin(n.prototype),{TextModel:n}}),define("orion/editor/keyModes",["orion/keyBinding","orion/util"],function(e,t){function i(e){e&&(this._view=e,this._keyBindings=this.createKeyBindings(),this._keyBindingIndex=0)}function n(e){i.call(this,e)}return i.prototype={createKeyBindings:function(){return[]},getKeyBindings:function(e){for(var t=[],i=this._keyBindings,n=0;nn){var h=o(n);t=s+h*l,r(t)}else r(a),c.stop()}var t,i="number"==typeof this.options.duration?this.options.duration:350,n="number"==typeof this.options.rate?this.options.rate:20,o=this.options.easing||this.defaultEasing,r=this.options.onAnimate||function(){},s=this.options.curve[0],a=this.options.curve[1],l=a-s,d=-1,c=this;this.interval=this.options.window.setInterval(e,n)},e.prototype.stop=function(){this.options.window.clearInterval(this.interval);var e=this.options.onEnd||function(){};e()},e.prototype.defaultEasing=function(e){return Math.sin(e*(Math.PI/2))},e}();return{contains:i,getNodeStyle:n,addEventListener:e,removeEventListener:t,Animation:o}}),define("orion/bidiUtils",["orion/util"],function(e){function t(){var e;window.dojoConfig&&(e=window.dojoConfig.locale),e||(e=navigator.languages?navigator.languages[0]:navigator.language||navigator.userLanguage);var t=e&&-1!="ar iw he".indexOf(e.substring(0,2));if(t){var i=document.getElementsByTagName("html")[0];i&&i.setAttribute("dir","rtl")}}function i(){var e=localStorage.getItem(c);return e&&"true"==e?!0:!1}function n(){var e=localStorage.getItem(h);return!e||"rtl"!=e&&"ltr"!=e&&"auto"!=e?"ltr":e}function o(t){return g=n(),i()?"auto"==g&&e.isIE?s(t):g:""}function r(e){if(i()&&e.trim()){g=n();var t="auto"==g?s(e):g;return("ltr"==t?u:f)+e+p}return e}function s(e){var t=/[A-Za-z\u05d0-\u065f\u066a-\u06ef\u06fa-\u07ff\ufb1d-\ufdff\ufe70-\ufefc]/.exec(e);return t?t[0]<="z"?"ltr":"rtl":"ltr"}function a(e){if(!e._hasBidiEventListeners){e._hasBidiEventListeners=!0;for(var t=["keyup","cut","paste"],i=0;i0;)(!s.isIE||s.isIE>=9||s.isIE<9&&n[o].specified)&&t.removeAttribute(n[o].name)}if(e){e.styleClass&&(t.className=e.styleClass);var r=e.style;if(r)for(var a in r)r.hasOwnProperty(a)&&(t.style[a]=r[a]);var l=e.attributes;if(l)for(var d in l)l.hasOwnProperty(d)&&t.setAttribute(d,l[d])}}function u(e){return e instanceof Array?e.slice(0):e}function p(e,t){if(!e)return t;if(!t)return e;for(var i in t)t.hasOwnProperty(i)&&(e.hasOwnProperty(i)||(e[i]=t[i]));return e}function f(e,t){if(e===t)return!0;if(e&&!t||!e&&t)return!1;if(e&&e.constructor===String||t&&t.constructor===String)return!1;if(e instanceof Array||t instanceof Array){if(!(e instanceof Array&&t instanceof Array))return!1;if(e.length!==t.length)return!1;for(var i=0;ir;){-1!==n&&r>=n&&(n=e.indexOf("\r",r)),-1!==o&&r>=o&&(o=e.indexOf("\n",r));var a,l=r;if(-1===o&&-1===n){t(e.substring(r));break}-1!==n&&-1!==o?n+1===o?(a=n,r=o+1):(a=o>n?n:o,r=(o>n?n:o)+1):-1!==n?(a=n,r=n+1):(a=o,r=o+1),t(e.substring(l,a)),i?i():r===s&&t("")}}function _(e){var t,i,n,o,r=d(e.ownerDocument);if(r.getComputedStyle){var s=r.getComputedStyle(e,null);t=s.getPropertyValue("border-left-width"),i=s.getPropertyValue("border-top-width"),n=s.getPropertyValue("border-right-width"),o=s.getPropertyValue("border-bottom-width")}else e.currentStyle&&(t=e.currentStyle.borderLeftWidth,i=e.currentStyle.borderTopWidth,n=e.currentStyle.borderRightWidth,o=e.currentStyle.borderBottomWidth);return{left:parseInt(t,10)||0,top:parseInt(i,10)||0,right:parseInt(n,10)||0,bottom:parseInt(o,10)||0}}function m(e){var t,i,n,o,r=d(e.ownerDocument);if(r.getComputedStyle){var s=r.getComputedStyle(e,null);t=s.getPropertyValue("padding-left"),i=s.getPropertyValue("padding-top"),n=s.getPropertyValue("padding-right"),o=s.getPropertyValue("padding-bottom")}else e.currentStyle&&(t=e.currentStyle.paddingLeft,i=e.currentStyle.paddingTop,n=e.currentStyle.paddingRight,o=e.currentStyle.paddingBottom);return{left:parseInt(t,10)||0,top:parseInt(i,10)||0,right:parseInt(n,10)||0,bottom:parseInt(o,10)||0}}function v(e){var t=e._trim;if(!t){t=m(e);var i=_(e);t.left+=i.left,t.top+=i.top,t.right+=i.right,t.bottom+=i.bottom,e._trim=t}return t}function y(e,t,i,n){function o(t){if(t.animationName===a){var i=t.target;"function"==typeof i.__DOMReady&&d(e).setTimeout(function(){i.__DOMReady()},0)}}function r(e,t){for(var i=["","-webkit-","-moz-","-ms-","-o-"],n="",o="body ."+e+" {\n",r=0;ri;i++){var n=e._createSelectionDiv();t.appendChild(n),this._divs.push(n)}}function w(e){this.left=e.left,this.top=e.top,this.right=e.right,this.bottom=e.bottom}function C(e,t,i){this.view=e,this.lineIndex=t,this._lineDiv=i}function T(e){this._init(e||{})}var L=r.addEventListener,k=r.removeEventListener,D=r.Animation;return x.compare=function(e,t){if(e.length!==t.length)return!1;for(var i=0;i=0;i--)if(e[i]._editing)return e[i];return e[e.length-1]}for(i=0;i=i.end||i._editing||e[n]._editing?(t.push(i),i=e[n]):i.end=Math.max(i.end,e[n].end);return t.push(i),t},x.prototype={clone:function(){var e=new x(this.start,this.end,this.caret);return e._columnX=this._columnX,e._editing=this._editing,e._docX=this._docX,e},contains:function(e){return this.start<=e&&ethis.end){var t=this.start;this.start=this.end,this.end=t,this.caret=!this.caret}},setCaret:function(e){this.start=e,this.end=e,this.caret=!1},getCaret:function(){return this.caret?this.start:this.end},getAnchor:function(){return this.caret?this.end:this.start},getOrientedSelection:function(){return{start:this.getAnchor(),end:this.getCaret()}},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(e){return this.caret===e.caret&&this.start===e.start&&this.end===e.end&&this._editing===e._editing}},b.prototype={destroy:function(){this._divs&&(this._divs.forEach(function(e){e.parentNode.removeChild(e)}),this._divs=null)},setPrimary:function(e){this.primary=e},update:function(){var e,t=this._view,i=this.primary,n=t._hasFocus,o=t._cursorVisible,r=!this.primary&&this._selection&&this._selection.isEmpty();e=r?"textviewSelectionCaret":n?"textviewSelection":"textviewSelectionUnfocused",this._divs[0].style.visibility=r&&o&&n||!r?"visible":"hidden",this._divs[0].style.zIndex=o&&r?"2":"0",this._divs.forEach(function(t){t.className=e,s.isWebkit<537.36&&i&&(t.style.background=n?"transparent":"")})},setSelection:function(e){this._selection=e,this.update();var t=this._view,i=t._model,n=i.getLineAtOffset(e.start),o=i.getLineAtOffset(e.end),r=t._getLineNext();if(r){var s,a,l,d,c=t._getLinePrevious();nc.lineIndex?(s=c,l=i.getLineStart(c.lineIndex)):(s=t._getLineNode(n),l=e.start),oc.lineIndex?(a=c,d=i.getLineStart(c.lineIndex)):(a=t._getLineNode(o),d=e.end),this._setDOMSelection(s,l,a,d,e.caret)}},_setDOMSelection:function(e,t,i,n,o){if(this._setDOMFullSelection(e,t,i,n),this.primary){var r=this._view,a=e._line.getNodeOffset(t),l=i._line.getNodeOffset(n);if(a.node&&l.node){var d,c=r._getWindow(),h=r._parent.ownerDocument;if(c.getSelection){var u=c.getSelection();if(d=h.createRange(),d.setStart(a.node,a.offset),d.setEnd(l.node,l.offset),!r._hasFocus||u.anchorNode===a.node&&u.anchorOffset===a.offset&&u.focusNode===l.node&&u.focusOffset===l.offset&&u.anchorNode===l.node&&u.anchorOffset===l.offset&&u.focusNode===a.node&&u.focusOffset===a.offset||(r._anchorNode=a.node,r._anchorOffset=a.offset,r._focusNode=l.node,r._focusOffset=l.offset,r._ignoreSelect=!1,u.rangeCount>0&&u.removeAllRanges(),u.addRange(d),r._ignoreSelect=!0),r._cursorDiv){d=h.createRange(),o?(d.setStart(a.node,a.offset),d.setEnd(a.node,a.offset)):(d.setStart(l.node,l.offset),d.setEnd(l.node,l.offset));var p=d.getClientRects()[0],f=r._cursorDiv.parentNode,g=f.getBoundingClientRect();p&&g&&(r._cursorDiv.style.top=p.top-g.top+f.scrollTop+"px",r._cursorDiv.style.left=p.left-g.left+f.scrollLeft+"px")}}else if(h.selection){if(!r._hasFocus)return;var _=h.body,m=s.createElement(h,"div");_.appendChild(m),_.removeChild(m),d=_.createTextRange(),d.moveToElementText(a.node.parentNode),d.moveStart("character",a.offset);var v=_.createTextRange();v.moveToElementText(l.node.parentNode),v.moveStart("character",l.offset),d.setEndPoint("EndToStart",v),r._ignoreSelect=!1,d.select(),r._ignoreSelect=!0}}}},_setDOMFullSelection:function(e,t,i,n){this._divs.forEach(function(e){e.style.width=e.style.height="0px"});var o=this._view;if(o._fullSelection&&!(s.isIOS||e===i&&t===n&&this.primary)){var r=o._getViewPadding(),a=o._clientDiv.getBoundingClientRect(),l=o._viewDiv.getBoundingClientRect(),d=l.left+r.left,c=a.right,h=l.top+r.top,u=a.bottom,p=0,f=0;if(o._clipDiv){var g=o._clipDiv.getBoundingClientRect();p=g.left-o._clipDiv.scrollLeft,f=g.top}else{var _=o._rootDiv.getBoundingClientRect();p=_.left,f=_.top}o._ignoreDOMSelection=!0;var m,v,y=new C(o,e.lineIndex,e),x=y.getBoundingClientRect(t,!1),b=x.left;e===i&&t===n?(m=y,v=x):(m=new C(o,i.lineIndex,i),v=m.getBoundingClientRect(n,!1));var w=v.left;o._ignoreDOMSelection=!1;var T=this._divs[0],L=Math.min(c,Math.max(d,b)),k=Math.min(u,Math.max(h,x.top)),D=c,A=Math.min(u,Math.max(h,x.bottom));if(T.style.left=L-p+"px",T.style.top=k-f+"px",T.style.width=Math.max(0,D-L)+"px",T.style.height=Math.max(0,A-k)+"px",e.lineIndex===i.lineIndex)D=Math.min(w,c),T.style.width=Math.max(this.primary?0:1,D-L)+"px";else{var S=d,E=Math.min(u,Math.max(h,v.top)),O=Math.min(c,Math.max(d,w)),N=Math.min(u,Math.max(h,v.bottom)),M=this._divs[2];if(M.style.left=S-p+"px",M.style.top=E-f+"px",M.style.width=Math.max(0,O-S)+"px",M.style.height=Math.max(0,N-E)+"px",Math.abs(e.lineIndex-i.lineIndex)>1){var I=this._divs[1];I.style.left=d-p+"px",I.style.top=A-f+"px",I.style.width=Math.max(0,c-d)+"px",I.style.height=Math.max(0,E-A)+"px"}}}}},w.prototype={toString:function(){return"{l="+this.left+", t="+this.top+", r="+this.right+", b="+this.bottom+"}"}},C.prototype={create:function(e,t){if(!this._lineDiv){var i=this._lineDiv=this._createLine(e,t,this.lineIndex);return i._line=this,i}},_createLine:function(e,t,i){var n=this.view,o=n._model,r=o.getLine(i),a=o.getLineStart(i),l={type:"LineStyle",textView:n,lineIndex:i,lineText:r,lineStart:a};n.onLineStyle(l);var d=e.ownerDocument,c=t||s.createElement(d,"div");if(t&&f(t.viewStyle,l.style)||(h(l.style,c,t),t&&(t._trim=null),c.viewStyle=l.style),c.lineIndex=i,t&&c.viewLineText===r&&f(l.ranges,c.viewRanges))return c;c.viewRanges=l.ranges,c.viewLineText=r;var u=[],p={tabOffset:0,ranges:u};this._createRanges(l.ranges,r,0,r.length,a,p);var g=" ";!n._fullSelection&&s.isIE<9&&(g="");var _={text:g,style:n._metrics.largestFontStyle,ignoreChars:1};0!==u.length&&u[u.length-1].style&&"div"===u[u.length-1].style.tagName?u.splice(u.length-1,0,_):u.push(_);var m,v,y,x,b,w,C,T,L=0,k=0;if(s.isFirefox&&r.length>2e3){t&&(c.innerHTML="",t.lineWidth=void 0);var D=d.createDocumentFragment();for(T=0;T=S&&(O-=A);var N=y.firstChild.data,M=N?N.length:0;if(k+M>O)break;k+=M}C=y.nextSibling,c.removeChild(y),y=C}}m=this._createSpan(c,b,v,_.ignoreChars),y?c.insertBefore(m,y):c.appendChild(m),t&&(t.lineWidth=void 0)}if(t)for(var I=m?m.nextSibling:null;I;)C=I.nextSibling,t.removeChild(I),I=C}return c.parentNode||e.appendChild(c),c},_createRanges:function(e,t,i,n,o,r){if(!(i>n)){if(e)for(var s=0;sn)break;var d=Math.min(o+n,a.end)-o;if(d>=l){if(l=Math.max(i,l),d=Math.min(n,d),l>i&&this._createRange(t,i,l,null,r),!a.style||!a.style.unmergeable)for(;s+1i&&this._createRange(t,i,n,null,r)}},_createRange:function(e,t,i,n,o){if(!(t>i)){var r,s=this.view._customTabSize,l={tagName:"span",bidi:!0,style:{unicodeBidi:"embed",direction:"ltr"}},d={text:"‎",style:l};if(s&&8!==s)for(var c=e.indexOf(" ",t);-1!==c&&i>c;){c>t&&(r={text:e.substring(t,c),style:n},o.ranges.push(r),a.isBidiEnabled&&o.ranges.push(d),o.tabOffset+=r.text.length);var h=s-o.tabOffset%s;if(h>0){for(var u=" ",p=1;h>p;p++)u+=" ";r={text:u,style:n,ignoreChars:h-1},o.ranges.push(r),a.isBidiEnabled&&o.ranges.push(d),o.tabOffset+=r.text.length}if(t=c+1,t===i)return;c=e.indexOf(" ",t)}i>=t&&(r={text:e.substring(t,i),style:n},o.ranges.push(r),a.isBidiEnabled&&o.ranges.push(d),o.tabOffset+=r.text.length)}},_createSpan:function(e,t,i,n){var o=this.view,r="span";i&&i.tagName&&(r=i.tagName.toLowerCase());var a="a"===r;a&&(this.hasLink=!0),a&&!o._linksVisible&&(r="span");var l=e.ownerDocument,d=s.createElement(e.ownerDocument,r);if(d.appendChild(l.createTextNode(i&&i.text?i.text:t)),i&&i.html?(d.innerHTML=i.html,d.ignore=!0):i&&i.node?(d.appendChild(i.node),d.ignore=!0):i&&i.bidi&&(d.ignore=!0),h(i,d),"a"===r){var c=o._getWindow();L(d,"click",function(e){return o._handleLinkClick(e?e:c.event)},!1)}return d.viewStyle=i,n&&(d.ignoreChars=n),d},_ensureCreated:function(){return this._lineDiv?this._lineDiv:this._createdDiv=this.create(this.view._clientDiv,null)},getBoundingClientRect:function(e,t){var i=this._ensureCreated(),n=this.view;if(void 0===e)return this._getLineBoundingClientRect(i,!0);var o=n._model,r=i.ownerDocument,a=this.lineIndex,l=null;if(ee){var h,u=e-c;if(1===o.length)l=new w(t.getBoundingClientRect());else if(n._isRangeRects)h=r.createRange(),h.setStart(o,u),h.setEnd(o,u+1),l=new w(h.getBoundingClientRect());else if(s.isIE){h=r.body.createTextRange(),h.moveToElementText(t),h.collapse();var p=0===u&&8===s.isIE;p&&(u=1),h.moveEnd("character",u+1),h.moveStart("character",u),l=new w(h.getBoundingClientRect()),p&&(l.left=t.getClientRects()[0].left)}else{var f=o.data;t.removeChild(o),t.appendChild(r.createTextNode(f.substring(0,u)));var g=s.createElement(r,"span");if(g.appendChild(r.createTextNode(f.substring(u,u+1))),t.appendChild(g),t.appendChild(r.createTextNode(f.substring(u+1))),l=new w(g.getBoundingClientRect()),t.innerHTML="",t.appendChild(o),!this._createdDiv){var _=n._getSelections()[0]; +(c<=_.start&&_.starts.right&&(s.right=a.right),a.bottom>s.bottom&&(s.bottom=a.bottom))}}return!0}),void 0!==e?i[e]:i},_getLineBoundingClientRect:function(e,t){var i=new w(e.getBoundingClientRect());if(this.view._wrapMode);else{i.right=i.left;for(var n=e.lastChild;n&&n.ignoreChars===n.firstChild.length;)n=n.previousSibling;if(n){var o=n.getBoundingClientRect();i.right=o.right+v(e).right}}if(t){var r=v(e);i.left=i.left+r.left,i.right=i.right-r.right}return i},getLineCount:function(){return this.view._wrapMode?this.getClientRects().length:1},getLineIndex:function(e){if(!this.view._wrapMode)return 0;for(var t=this.getClientRects(),i=this.getBoundingClientRect(e),n=i.top+(i.bottom-i.top)/2,o=0;os||n+r>=a?(t=o,i=s-n,e.ignoreChars&&r>0&&i===r&&(i+=e.ignoreChars),!1):(n+=r,!0)}),{node:t,offset:i}},getText:function(e){var t="",i=0;return this.forEach(function(n){var o;if(n.ignoreChars){o=n.lastChild;for(var r=0,s=[],a=-1;o;){var l=o.data;if(l)for(var d=l.length-1;d>=0;d--){var c=l.substring(d,d+1);r1;){var N=Math.floor((E+O)/2);y=O+1,x=N===T-1&&i.ignoreChars?C.length:N+1,b=0===y&&8===s.isIE,o._isRangeRects?(v.setStart(C,y),v.setEnd(C,x)):(b&&(y=1),v.moveToElementText(i),v.move("character",y),v.moveEnd("character",x-y)),w=v.getClientRects();for(var M=!1,I=0;I=h&&_>e&&(!o._wrapMode||t>=u&&m>=t)){M=!0;break}M?E=N:O=N}n+=E,y=E,x=E===T-1&&i.ignoreChars?C.length:Math.min(E+1,C.length),o._isRangeRects?(v.setStart(C,y),v.setEnd(C,x)):(v.moveToElementText(i),v.move("character",y),v.moveEnd("character",x-y)),w=v.getClientRects();var B=!1;w.length>0&&(c=w[0],h=(b?S:c.left)*D-f.left,_=c.right*D-f.left,B=e>h+(_-h)/2);var R=n-l,F=r.getLine(a),P=F.charCodeAt(R);P>=55296&&56319>=P&&B?R=56320&&57343>=P&&(n+=1)):P>=56320&&57343>=P&&!B&&R>0&&(P=F.charCodeAt(R-1),P>=55296&&56319>=P&&(n-=1)),B&&n++}else{for(var W=[],V=0;T>V;V++)W.push(""),W.push(V===T-1?C.data.substring(V):C.data.substring(V,V+1)),W.push("");i.innerHTML=W.join("");for(var j=i.firstChild;j;){if(c=j.getBoundingClientRect(),h=c.left-f.left,_=c.right-f.left,e>=h&&_>e){e>h+(_-h)/2&&n++;break}n++,j=j.nextSibling}if(!g._createdDiv){i.innerHTML="",i.appendChild(C);var U=o._getSelections()[0];(n<=U.start&&U.startu.right&&(e=u.right-1)}else 0>e&&(e=0),e>f.right-f.left&&(e=f.right-f.left);var m,v;if(this._lastHitChild&&this._lastHitChild.parentNode){if(m=this._lastHitOffset,v=this._lastHitChild,u=n(v),!u)for(var y=m,x=m+this._nodeLength(v),b=v.previousSibling,w=v.nextSibling;b||w;){if(b){if(y-=this._nodeLength(b),u=n(b)){v=b,m=y;break}b=b.previousSibling}if(w){if(u=n(w)){v=w,m=x;break}x+=this._nodeLength(w),w=w.nextSibling}}}else m=l,this.forEach(function(e){return v=e,(u=n(v))?!1:(m+=this._nodeLength(v),!0)});return v&&u&&(this._lastHitChild=v,this._lastHitOffset=m,m=i(v,m,u)),Math.min(c,Math.max(l,m))},getNextOffset:function(e,t){if("line"===t.unit){var i=this.view,n=i._model,o=n.getLineAtOffset(e);return t.count>0?(t.count--,n.getLineEnd(o)):(t.count++,n.getLineStart(o))}return"wordend"===t.unit||"wordWS"===t.unit||"wordendWS"===t.unit?this._getNextOffset_W3C(e,t):s.isIE?this._getNextOffset_IE(e,t):this._getNextOffset_W3C(e,t)},_getNextOffset_W3C:function(e,t){function i(e){return e>=33&&47>=e||e>=58&&64>=e||e>=91&&94>=e||96===e||e>=123&&126>=e}function n(e){return 32===e||9===e}var o,r=this.view,s=r._model,a=s.getLineAtOffset(e),l=s.getLine(a),d=s.getLineStart(a),c=s.getLineEnd(a),h=l.length,u=e-d,p=t.count<0?-1:1;if("word"===t.unit||"wordend"===t.unit||"wordWS"===t.unit||"wordendWS"===t.unit)for(var f,g,_,m;0!==t.count;){if(t.count>0){if(u===h)return c;for(o=l.charCodeAt(u),f=i(o),g=!f&&!n(o),u++;h>u;){if(o=l.charCodeAt(u),"wordWS"!==t.unit&&"wordendWS"!==t.unit){if(_=i(o),"wordend"===t.unit){if(!_&&f)break}else if(_&&!f)break;m=!_&&!n(o)}else m=!n(o);if("wordend"===t.unit||"wordendWS"===t.unit){if(!m&&g)break}else if(m&&!g)break;g=m,f=_,u++}}else{if(0===u)return d;for(u--,o=l.charCodeAt(u),f=i(o),g=!f&&!n(o);u>0;){if(o=l.charCodeAt(u-1),"wordWS"!==t.unit&&"wordendWS"!==t.unit){if(_=i(o),"wordend"===t.unit){if(_&&!f)break}else if(!_&&f)break;m=!_&&!n(o)}else m=!n(o);if("wordend"===t.unit||"wordendWS"===t.unit){if(m&&!g)break}else if(!m&&g)break;g=m,f=_,u--}}t.count-=p}else for(;0!==t.count&&u+p>=0&&h>=u+p;)u+=p,o=l.charCodeAt(u),o>=56320&&57343>=o&&u>0&&(o=l.charCodeAt(u-1),o>=55296&&56319>=o&&(u+=p)),t.count-=p;return d+u},_getNextOffset_IE:function(e,t){var i,n,o,r=this._ensureCreated(),s=this.view,a=s._model,l=this.lineIndex,d=0,c=a.getLineStart(l),h=a.getLine(l),u=a.getLineStart(l),p=r.ownerDocument,f=t.count<0?-1:1;if(e===a.getLineEnd(l)){for(o=r.lastChild;o&&o.ignoreChars===o.firstChild.length;)o=o.previousSibling;if(!o)return c;i=p.body.createTextRange(),i.moveToElementText(o),n=i.text.length,i.moveEnd(t.unit,f),d=e+i.text.length-n}else if(e===c&&t.count<0)d=c;else for(o=r.firstChild;o;){var g=this._nodeLength(o);if(c+g>e){if(i=p.body.createTextRange(),e===c&&t.count<0){for(var _=o.previousSibling;_&&(!_.firstChild||!_.firstChild.length);)_=_.previousSibling;i.moveToElementText(_?_:o.previousSibling)}else i.moveToElementText(o),i.collapse(),i.moveEnd("character",e-c);n=i.text.length,i.moveEnd(t.unit,f),d=e+i.text.length-n;break}c=g+c,o=o.nextSibling}var m=d-u,v=h.charCodeAt(m);return v>=56320&&57343>=v&&m>0&&(v=h.charCodeAt(m-1),v>=55296&&56319>=v&&(m+=f)),d=m+u,t.count-=f,d},updateLinks:function(){var e=this._ensureCreated();if(this.hasLink){var t=this;this.forEach(function(i){var n=i.viewStyle;return n&&n.tagName&&"a"===n.tagName.toLowerCase()&&e.replaceChild(t._createSpan(e,i.firstChild.data,n),i),!0})}},destroy:function(){var e=this._createdDiv;e&&(e.parentNode.removeChild(e),this._createdDiv=null)}},T.prototype={addKeyMode:function(e,t){var i=this._keyModes;void 0!==t?i.splice(t,0,e):i.push(e),e._modeAdded&&e._modeAdded()},addRuler:function(e,t){var i=this._rulers;if(void 0!==t){var n,o;for(n=0,o=0;no;n++)e.getLocation()===i[n].getLocation()&&o++;i.splice(o,0,e),t=o}else i.push(e);this._createRuler(e,t),e.setView(this),this._update()},computeSize:function(){var e=0,t=0,i=this._model,n=this._clientDiv;if(!n)return{width:e,height:t};var o=n.style.width;s.isWebkit&&(n.style.width="0x7fffffffpx");for(var r=i.getLineCount(),a=0;r>a;a++){var l=this._getLine(a),d=l.getBoundingClientRect();e=Math.max(e,d.right-d.left),t+=d.bottom-d.top,l.destroy()}s.isWebkit&&(n.style.width=o);var c=this._getViewPadding();return e+=c.right+c.left+this._metrics.scrollWidth,t+=c.bottom+c.top+this._metrics.scrollWidth,{width:e,height:t}},convert:function(e,t,i){if(!this._clientDiv)return e;var n=this._getScroll(),o=this._getViewPadding(),r=this._viewDiv.getBoundingClientRect();return"document"===t&&(void 0!==e.x&&(e.x+=-n.x+r.left+o.left),void 0!==e.y&&(e.y+=-n.y+r.top+o.top)),"document"===i&&(void 0!==e.x&&(e.x+=n.x-r.left-o.left),void 0!==e.y&&(e.y+=n.y-r.top-o.top)),e},copy:function(){return this._clientDiv?this._doCopy():!1},cut:function(){return this._clientDiv?this._doCut():!1},destroy:function(){for(var e=0;ei)return!1;var n=this._getLine(i),o=this.getOffsetAtLocation(e,t),r=n.getBoundingClientRect(o);return n.destroy(),e>r.right?!1:!0},getLinePixel:function(e){return this._clientDiv?this._getLinePixel(e):0},getLocationAtOffset:function(e){if(!this._clientDiv)return{x:0,y:0};var t=this._model;e=Math.min(Math.max(0,e),t.getCharCount());var i=t.getLineAtOffset(e),n=this._getLine(i),o=n.getBoundingClientRect(e);n.destroy();var r=o.left,s=this._getLinePixel(i)+o.top;return{x:r,y:s}},getNextOffset:function(e,t){var i=new x(e,e,!1);return this._doMove(t,i),i.getCaret()},getOptions:function(){var e;if(0===arguments.length)e=this._defaultOptions();else if(1===arguments.length){var t=arguments[0];if("string"==typeof t)return u(this["_"+t]);e=t}else{e={};for(var i in arguments)arguments.hasOwnProperty(i)&&(e[arguments[i]]=void 0)}for(var n in e)e.hasOwnProperty(n)&&(e[n]=u(this["_"+n]));return e},getModel:function(){return this._model},getOffsetAtLocation:function(e,t){if(!this._clientDiv)return 0;var i=this._getLineIndex(t),n=this._getLine(i),o=n.getOffset(e,t-this._getLinePixel(i));return n.destroy(),o},getLineAtOffset:function(e){return this.getModel().getLineAtOffset(e)},getLineStart:function(e){return this.getModel().getLineStart(e)},getRulers:function(){return this._rulers.slice(0)},getSelection:function(){return this._getSelection()},getSelections:function(){return this._getSelections()},getSelectionText:function(e){var t=[],i=this,n=this._getSelections();return n.forEach(function(e){e.isEmpty()||t.push(i._getBaseText(e.start,e.end))}),t.join(void 0!==e?e:this._model.getLineDelimiter())},getText:function(e,t){var i=this._model;return i.getText(e,t)},getTopIndex:function(e){return this._clientDiv?this._getTopIndex(e):0},getTopPixel:function(){return this._clientDiv?this._getScroll().y:0},invokeAction:function(e,t,i){if(this._clientDiv){var n=this._actions[e];if(n){if(n.actionDescription&&n.actionDescription.id&&l.logEvent("editor","action",n.actionDescription.id),!t&&n.handler&&n.handler(i))return!0;if(n.defaultHandler)return"boolean"==typeof n.defaultHandler(i)}return!1}},isDestroyed:function(){return!this._clientDiv},onContextMenu:function(e){return this.dispatchEvent(e)},onDragStart:function(e){return this.dispatchEvent(e)},onDrag:function(e){return this.dispatchEvent(e)},onDragEnd:function(e){return this.dispatchEvent(e)},onDragEnter:function(e){return this.dispatchEvent(e)},onDragOver:function(e){return this.dispatchEvent(e)},onDragLeave:function(e){return this.dispatchEvent(e)},onDrop:function(e){return this.dispatchEvent(e)},onDestroy:function(e){return this.dispatchEvent(e)},onSaving:function(e){return this.dispatchEvent(e)},onInputChanged:function(e){return this.dispatchEvent(e)},onLineStyle:function(e){return this.dispatchEvent(e)},onKeyDown:function(e){return this.dispatchEvent(e)},onKeyPress:function(e){return this.dispatchEvent(e)},onKeyUp:function(e){return this.dispatchEvent(e)},onModelChanged:function(e){return this.dispatchEvent(e)},onModelChanging:function(e){return this.dispatchEvent(e)},onModify:function(e){return this.dispatchEvent(e)},onMouseDown:function(e){return this.dispatchEvent(e)},onMouseUp:function(e){return this.dispatchEvent(e)},onMouseMove:function(e){return this.dispatchEvent(e)},onMouseOver:function(e){return this.dispatchEvent(e)},onMouseOut:function(e){return this.dispatchEvent(e)},onTouchStart:function(e){return this.dispatchEvent(e)},onTouchMove:function(e){return this.dispatchEvent(e)},onTouchEnd:function(e){return this.dispatchEvent(e)},onOptions:function(e){return this.dispatchEvent(e)},onSelection:function(e){return this.dispatchEvent(e)},onScroll:function(e){return this.dispatchEvent(e)},onVerify:function(e){return this.dispatchEvent(e)},onFocus:function(e){return this.dispatchEvent(e)},onBlur:function(e){return this.dispatchEvent(e)},paste:function(){return this._clientDiv?this._doPaste():!1},redraw:function(){if(!(this._redrawCount>0)){var e=this._model.getLineCount();this.redrawRulers(0,e),this.redrawLines(0,e)}},redrawRulers:function(e,t){if(!(this._redrawCount>0))for(var i=this.getRulers(),n=0;n0)&&(void 0===e&&(e=0),void 0===t&&(t=this._model.getLineCount()),e!==t)){var n=this._clientDiv;if(n){if(i){var o=this._getRulerParent(i);for(n=o.firstChild;n&&n._ruler!==i;)n=n.nextSibling}i?n.rulerChanged=!0:this._lineHeight&&this._resetLineHeight(e,t);var r=-1;if(i||-1===this._imeOffset||(r=this._model.getLineAtOffset(this._imeOffset)),!i||"page"===i.getOverview())for(var s=n.firstChild;s;){var a=s.lineIndex;a>=e&&t>a&&a!==r&&(s.lineChanged=!0),s=s.nextSibling}i||this._wrapMode||e<=this._maxLineIndex&&this._maxLineIndex0)){var i=this._model;void 0===e&&(e=0),void 0===t&&(t=i.getCharCount());var n=i.getLineAtOffset(e),o=i.getLineAtOffset(Math.max(e,t-1))+1;this.redrawLines(n,o)}},removeKeyMode:function(e){for(var t=this._keyModes,i=0;it;if(o){var r=e;e=t,t=r}var s=this._model.getCharCount();e=Math.max(0,Math.min(e,s)),t=Math.max(0,Math.min(t,s));var a=new x(e,t,o);this._setSelection(a,void 0===i||i,!0,n)},setSelections:function(e,t,i){var n=this._rangesToSelections(e);this._setSelection(n,void 0===t||t,!0,i)},setText:function(e,t,i,n,o){var r,a="string"==typeof e,l=void 0===t&&void 0===i&&a;a?(void 0===t&&(t=0),void 0===i&&(i=this._model.getCharCount()),r={text:e,selection:[new x(t,i,!1)]}):(r=e,r.selection=this._rangesToSelections(r.selection)),r._code=!0,l&&(this._variableLineHeight=!1),this._modifyContent(r,!l,void 0===n||n,o),l&&s.isFirefox<13&&this._fixCaret()},setTopIndex:function(e,t){this._clientDiv&&this._scrollViewAnimated(0,this._getLinePixel(Math.max(0,e))-this._getScroll().y,t)},setTopPixel:function(e,t){this._clientDiv&&this._scrollViewAnimated(0,Math.max(0,e)-this._getScroll().y,t)},showSelection:function(e,t){return this._showCaret(e?!1:!0,t,e)},update:function(e,t){this._clientDiv&&((e||this._metrics.invalid)&&this._updateStyle(),void 0===t||t?this._update():this._queueUpdate())},_handleRootMouseDown:function(e){if(this._cancelCheckSelection(),!this._ignoreEvent(e)){s.isFirefox<13&&1===e.which&&(this._clientDiv.contentEditable=!1,(this._overlayDiv||this._clientDiv).draggable=!0,this._ignoreBlur=!0);var t=this._overlayDiv||this._clientDiv;s.isIE<9&&(t=this._viewDiv);for(var i=e.target?e.target:e.srcElement;i;){if(t===i)return;if(i.className&&-1!==i.className.indexOf("textViewFind"))return;i=i.parentNode}if(e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),!this._isW3CEvents){var n=this,o=this._getWindow();o.setTimeout(function(){n._clientDiv.focus()},0)}}},_handleRootMouseUp:function(e){this._ignoreEvent(e)||(s.isFirefox<13&&1===e.which&&(this._clientDiv.contentEditable=!0,(this._overlayDiv||this._clientDiv).draggable=!1),s.isFirefox&&1===e.which&&(this._fixCaret(),this._ignoreBlur=!1))},_handleBlur:function(){if(this._cancelCheckSelection(),!this._ignoreBlur){if(this._commitIME(),this._hasFocus=!1,s.isIE<9&&!this._getSelections()[0].isEmpty()){var e=this._rootDiv,t=s.createElement(e.ownerDocument,"div");e.appendChild(t),e.removeChild(t)}if(this._cursorDiv&&(this._cursorDiv.style.display="none"),this._domSelection){this._domSelection.forEach(function(e){e.update()});var i,n=this._getWindow(),o=this._parent.ownerDocument;if(n.getSelection){var r=n.getSelection();for(i=r.anchorNode;i;){if(i===this._clientDiv){r.rangeCount>0&&r.removeAllRanges();break}i=i.parentNode}}else if(o.selection){for(this._ignoreSelect=!1,i=o.selection.createRange().parentElement();i;){if(i===this._clientDiv){o.selection.empty();break}i=i.parentNode}this._ignoreSelect=!0}}this._ignoreFocus||this.onBlur({type:"Blur"})}},_handleCompositionStart:function(e){if(!this._ignoreEvent(e)){if(this._imeTimeout){var t=this._getWindow();t.clearTimeout(this._imeTimeout),this._imeTimeout=null}this._imeText&&(this._commitIME(this._imeText),this._imeText=null),this._startIME(),this._mutationObserver&&(this._mutationObserver.disconnect(),this._mutationObserver=null)}},_handleCompositionUpdate:function(e){this._ignoreEvent(e)||(this._imeText=e.data)},_handleCompositionEnd:function(e){if(!this._ignoreEvent(e)){this._imeText=e.data;var t=this._getWindow();this._imeTimeout=t.setTimeout(function(){this._commitIME(this._imeText),this._imeText=this._imeTimeout=null}.bind(this),0)}},_handleContextMenu:function(e){if(!this._ignoreEvent(e)){s.isIE&&3===this._lastMouseButton&&this._updateDOMSelection();var t=!1;if(this.isListening("ContextMenu")){var i=this._createMouseEvent("ContextMenu",e);i.screenX=e.screenX,i.screenY=e.screenY,this.onContextMenu(i),t=i.defaultPrevented}else s.isMac&&s.isFirefox&&0===e.button&&(t=!0);return t?(e.preventDefault&&e.preventDefault(),!1):(this._contextMenuOpen=!0,void(s.isFirefox&&(this._checkSelectionChange=!0,this._pollSelectionChange(!0))))}},_handleCopy:function(e){return this._cancelCheckSelection(),this._ignoreEvent(e)||this._ignoreCopy?void 0:this._doCopy(e)?(e.preventDefault&&e.preventDefault(),!1):void 0},_handleCut:function(e){return this._cancelCheckSelection(),this._ignoreEvent(e)?void 0:this._doCut(e)?(e.preventDefault&&e.preventDefault(),!1):void 0},_handleDataModified:function(e){this._ignoreEvent(e)||this._startIME()},_handleDblclick:function(e){if(!this._ignoreEvent(e)){var t=e.timeStamp?e.timeStamp:(new Date).getTime();this._lastMouseTime=t,2!==this._clickCount&&(this._clickCount=2,this._handleMouse(e))}},_handleDragStart:function(e){if(!this._ignoreEvent(e)){if(s.isFirefox<13){var t=this,i=this._getWindow();i.setTimeout(function(){t._clientDiv.contentEditable=!0,t._clientDiv.draggable=!1,t._ignoreBlur=!1},0)}return this.isListening("DragStart")&&-1!==this._dragOffset?(this._isMouseDown=!1,this.onDragStart(this._createMouseEvent("DragStart",e)),this._dragOffset=-1,void 0):(e.preventDefault&&e.preventDefault(),!1)}},_handleDrag:function(e){this._ignoreEvent(e)||this.isListening("Drag")&&this.onDrag(this._createMouseEvent("Drag",e))},_handleDragEnd:function(e){this._ignoreEvent(e)||(this._dropTarget=!1,this._dragOffset=-1,this.isListening("DragEnd")&&this.onDragEnd(this._createMouseEvent("DragEnd",e)),s.isFirefox<13&&(this._fixCaret(),"none"!==e.dataTransfer.dropEffect||e.dataTransfer.mozUserCancelled||this._fixCaret()))},_handleDragEnter:function(e){if(!this._ignoreEvent(e)){var t=!0;return this._dropTarget=!0,this.isListening("DragEnter")&&(t=!1,this.onDragEnter(this._createMouseEvent("DragEnter",e))),s.isWebkit||t?(e.preventDefault&&e.preventDefault(),!1):void 0}},_handleDragOver:function(e){if(!this._ignoreEvent(e)){var t=!0;return this.isListening("DragOver")&&(t=!1,this.onDragOver(this._createMouseEvent("DragOver",e))),s.isWebkit||t?(t&&(e.dataTransfer.dropEffect="none"),e.preventDefault&&e.preventDefault(),!1):void 0}},_handleDragLeave:function(e){this._ignoreEvent(e)||(this._dropTarget=!1,this.isListening("DragLeave")&&this.onDragLeave(this._createMouseEvent("DragLeave",e)))},_handleDrop:function(e){return this._ignoreEvent(e)?void 0:(this._dropTarget=!1,this.isListening("Drop")&&this.onDrop(this._createMouseEvent("Drop",e)),e.preventDefault&&e.preventDefault(),!1)},_handleFocus:function(){this._hasFocus=!0,s.isIOS&&void 0!==this._lastTouchOffset?(this.setCaretOffset(this._lastTouchOffset,!0),this._lastTouchOffset=void 0):this._updateDOMSelection(),this._cursorDiv&&(this._cursorDiv.style.display="block"),this._domSelection&&this._domSelection.forEach(function(e){e.update()}),this._ignoreFocus||this.onFocus({type:"Focus"})},_handleKeyDown:function(e){if(this._cancelCheckSelection(),!this._ignoreEvent(e)){if(this.isListening("KeyDown")){var t=this._createKeyEvent("KeyDown",e);if(this.onKeyDown(t),t.defaultPrevented)return s.isFirefox&&(this._keyDownPrevented=!0),void e.preventDefault()}var i=!1;switch(e.keyCode){case 16:case 17:case 18:case 91:i=!0;break;default:this._setLinksVisible(!1)}if(229===e.keyCode){if(this._readonly)return e.preventDefault&&e.preventDefault(),!1;var n=!0;s.isSafari&&s.isMac&&e.ctrlKey&&(n=!1,e.keyCode=129),n&&this._startIME()}else i||this._commitIME();return(s.isMac||s.isLinux)&&s.isFirefox<4||s.isOpera<12.16?(this._keyDownEvent=e,!0):this._doAction(e)?(e.preventDefault?(e.preventDefault(),e.stopPropagation()):(e.cancelBubble=!0,e.returnValue=!1,e.keyCode=0),!1):void 0}},_handleKeyPress:function(e){if(!this._ignoreEvent(e)){if(this._keyDownPrevented)return e.preventDefault&&(e.preventDefault(),e.stopPropagation()),void(this._keyDownPrevented=void 0);if(s.isMac&&s.isWebkit&&(63232<=e.keyCode&&e.keyCode<=63487||13===e.keyCode||8===e.keyCode))return e.preventDefault&&e.preventDefault(),!1;if(((s.isMac||s.isLinux)&&s.isFirefox<4||s.isOpera<12.16)&&this._doAction(this._keyDownEvent))return e.preventDefault&&e.preventDefault(),!1;var t=s.isMac?e.metaKey:e.ctrlKey;if(void 0!==e.charCode&&t)switch(e.charCode){case 99:case 118:case 120:return!0}if(this.isListening("KeyPress")){var i=this._createKeyEvent("KeyPress",e);if(this.onKeyPress(i),i.defaultPrevented)return void e.preventDefault()}if(this._doAction(e))return e.preventDefault?(e.preventDefault(),e.stopPropagation()):(e.cancelBubble=!0,e.returnValue=!1,e.keyCode=0),!1;var n=!1;if(s.isMac?(e.ctrlKey||e.metaKey)&&(n=!0):s.isFirefox?(e.ctrlKey||e.altKey)&&(n=!0):e.ctrlKey^e.altKey&&(n=!0),!n){var o=s.isOpera?e.which:void 0!==e.charCode?e.charCode:e.keyCode;if(o>31)return this._doContent(String.fromCharCode(o)),e.preventDefault&&e.preventDefault(),!1}}},_handleDocKeyUp:function(e){var t=s.isMac?e.metaKey:e.ctrlKey;t||this._setLinksVisible(!1)},_handleKeyUp:function(e){if(!this._ignoreEvent(e)){if(this.isListening("KeyUp")){var t=this._createKeyEvent("KeyUp",e);if(this.onKeyUp(t),t.defaultPrevented)return void e.preventDefault()}this._handleDocKeyUp(e),13===e.keyCode&&this._commitIME()}},_handleLinkClick:function(e){var t=s.isMac?e.metaKey:e.ctrlKey;return t?void 0:(e.preventDefault&&e.preventDefault(),!1)},_handleMouse:function(e){var t=this._getWindow(),i=!0,n=t;if((s.isIE||s.isFirefox&&!this._overlayDiv)&&(n=this._clientDiv),this._overlayDiv){this._hasFocus&&(this._ignoreFocus=!0);var o=this;t.setTimeout(function(){o.focus(),o._ignoreFocus=!1},0)}var r=e.shiftKey,a=e.altKey,l=s.isMac?e.metaKey:e.ctrlKey;if(this._blockSelection=this._doubleClickSelection=null,1===this._clickCount){var d=(!s.isOpera||s.isOpera>=12.16)&&this._hasFocus&&this.isListening("DragStart");i=this._setSelectionTo(e.clientX,e.clientY,!0,r,l,d),i&&this._setGrab(n)}else this._isW3CEvents&&this._setGrab(n),this._setSelectionTo(e.clientX,e.clientY,!0,r,l,!1),this._doubleClickSelection=x.editing(this._getSelections());return a&&(this._blockSelection=x.editing(this._getSelections())),i},_handleMouseDown:function(e){if(!this._ignoreEvent(e)){if(this._linksVisible){var t=e.target||e.srcElement;if("A"===t.tagName)return;this._setLinksVisible(!1)}this._commitIME();var i=e.which;i||(4===e.button&&(i=2),2===e.button&&(i=3),1===e.button&&(i=1));var n=2!==i&&e.timeStamp?e.timeStamp:(new Date).getTime(),o=n-this._lastMouseTime,r=Math.abs(this._lastMouseX-e.clientX),a=Math.abs(this._lastMouseY-e.clientY),l=this._lastMouseButton===i;if(this._lastMouseX=e.clientX,this._lastMouseY=e.clientY,this._lastMouseTime=n,this._lastMouseButton=i,1===i&&(this._isMouseDown=!0,l&&o<=this._clickTime&&r<=this._clickDist&&a<=this._clickDist?this._clickCount++:this._clickCount=1),this.isListening("MouseDown")){var d=this._createMouseEvent("MouseDown",e);if(this.onMouseDown(d),d.defaultPrevented)return void e.preventDefault()}1===i&&this._handleMouse(e)&&(s.isIE>=9||s.isOpera||s.isChrome||s.isSafari||s.isFirefox&&!this._overlayDiv)&&(this._hasFocus||this.focus(),e.preventDefault()),s.isFirefox&&3===this._lastMouseButton&&this._updateDOMSelection()}},_handleMouseOver:function(e){this._ignoreEvent(e)||this._animation||this.isListening("MouseOver")&&this.onMouseOver(this._createMouseEvent("MouseOver",e))},_handleMouseOut:function(e){this._ignoreEvent(e)||this._animation||this.isListening("MouseOut")&&this.onMouseOut(this._createMouseEvent("MouseOut",e))},_handleMouseMove:function(e){if(!this._animation){var t=this._isClientDiv(e);if(this.isListening("MouseMove")&&(t||this._isMouseDown)){var i=this._createMouseEvent("MouseMove",e);if(this.onMouseMove(i),i.defaultPrevented)return void e.preventDefault()}if(!this._dropTarget){var n=this._linksVisible||this._lastMouseMoveX!==e.clientX||this._lastMouseMoveY!==e.clientY;if(this._lastMouseMoveX=e.clientX,this._lastMouseMoveY=e.clientY,this._setLinksVisible(n&&!this._isMouseDown&&e.altKey&&(s.isMac?e.metaKey:e.ctrlKey)),this._checkOverlayScroll(),!this._isW3CEvents){if(0===e.button)return this._setGrab(null),!0;if(!this._isMouseDown&&1===e.button&&0!==(1&this._clickCount)&&t)return this._clickCount=2,this._handleMouse(e,this._clickCount)}if(this._isMouseDown&&-1===this._dragOffset){var o=e.clientX,r=e.clientY,a=this._getViewPadding(),l=this._viewDiv.getBoundingClientRect(),d=this._getClientWidth(),c=this._getClientHeight(),h=l.left+a.left,u=l.top+a.top,p=l.left+a.left+d,f=l.top+a.top+c;u>r?this._doAutoScroll("up",o,r-u):r>f?this._doAutoScroll("down",o,r-f):h>o&&!this._wrapMode?this._doAutoScroll("left",o-h,r):o>p&&!this._wrapMode?this._doAutoScroll("right",o-p,r):(this._endAutoScroll(),this._setSelectionTo(o,r,!1,!0))}}}},_isClientDiv:function(e){for(var t=this._overlayDiv||this._clientDiv,i=e.target?e.target:e.srcElement;i;){if(t===i)return!0;i=i.parentNode}return!1},_createKeyEvent:function(e,t){return{type:e,event:t,preventDefault:function(){this.defaultPrevented=!0}}},_createMouseEvent:function(e,t){var i=this.convert({x:t.clientX,y:t.clientY},"page","document"); +return{type:e,event:t,clickCount:this._clickCount,x:i.x,y:i.y,preventDefault:function(){this.defaultPrevented=!0}}},_createTouchEvent:function(e,t){var i=t.touches.length?this.convert({x:t.touches[0].clientX,y:t.touches[0].clientY},"page","document"):{};return{type:e,event:t,touchCount:t.touches.length,x:i.x,y:i.y,preventDefault:function(){this.defaultPrevented=!0}}},_handleMouseUp:function(e){var t=e.which?0===e.button:1===e.button;if(this.isListening("MouseUp")&&(this._isClientDiv(e)||t&&this._isMouseDown)){var i=this._createMouseEvent("MouseUp",e);if(this.onMouseUp(i),i.defaultPrevented)return e.preventDefault(),void(this._isMouseDown=!1)}if(!this._linksVisible){if(t&&this._isMouseDown){var n=this._getSelections(),o=x.editing(n);n.forEach(function(e){e._editing=!1}),-1!==this._dragOffset&&(o.extend(this._dragOffset),o.collapse(),n=o,this._dragOffset=-1),this._setSelection(n,!1),this._isMouseDown=!1,this._endAutoScroll(),this._isW3CEvents&&this._setGrab(null)}t&&this._isMouseDown&&s.isFirefox&&(this._updateDOMSelection(),e.preventDefault())}},_handleMouseWheel:function(e){if(!this._noScroll){var t=this._getLineHeight(),i=0,n=0;if(s.isIE||s.isOpera)n=-e.wheelDelta/40*t;else if(s.isFirefox){var o=256;if("wheel"===e.type)e.deltaMode?(i=Math.max(-o,Math.min(o,e.deltaX))*t,n=Math.max(-o,Math.min(o,e.deltaY))*t):(i=e.deltaX,n=e.deltaY);else{var r;r=s.isMac?3*e.detail:Math.max(-o,Math.min(o,e.detail))*t,e.axis===e.HORIZONTAL_AXIS?i=r:n=r}}else if(s.isMac){var a,l,d=e.timeStamp-this._wheelTimeStamp;this._wheelTimeStamp=e.timeStamp,a=e.wheelDeltaX%120!==0?1:40>d?40/(40-d):40,l=e.wheelDeltaY%120!==0?1:40>d?40/(40-d):40,i=Math.ceil(-e.wheelDeltaX/a),i>-1&&0>i&&(i=-1),i>0&&1>i&&(i=1),n=Math.ceil(-e.wheelDeltaY/l),n>-1&&0>n&&(n=-1),n>0&&1>n&&(n=1)}else{i=-e.wheelDeltaX;var c=8;n=-e.wheelDeltaY/120*c*t}if(s.isSafari||s.isChrome&&s.isMac){for(var h=e.target;h&&void 0===h.lineIndex;)h=h.parentNode;this._mouseWheelLine=h}var u=this._getScroll();this._scrollView(i,n);var p=this._getScroll();return u.x!==p.x||u.y!==p.y?(e.preventDefault&&e.preventDefault(),!1):void 0}},_handlePaste:function(e){if(this._cancelCheckSelection(),!this._ignoreEvent(e)&&!this._ignorePaste&&this._doPaste(e)){if(s.isIE){var t=this;this._ignoreFocus=!0;var i=this._getWindow();i.setTimeout(function(){t._updateDOMSelection(),t._ignoreFocus=!1},0)}return e.preventDefault&&e.preventDefault(),!1}},_handleResize:function(){var e=this._rootDiv.clientWidth,t=this._rootDiv.clientHeight;if(this._rootWidth!==e||this._rootHeight!==t){this._rootWidth!==e&&this._wrapMode&&this._resetLineHeight(),this._rootWidth=e,this._rootHeight=t;var i=s.isIE<9,n=this._calculateMetrics();f(n,this._metrics)||(this._metrics.invalid&&!n.invalid?this._updateStyle(!1,n):(this._variableLineHeight&&(this._variableLineHeight=!1,this._resetLineHeight()),this._metrics=n),i=!0),i?this._queueUpdate():this._update(),this.dispatchEvent({type:"Resize"})}},_handleRulerEvent:function(e){for(var t=e.target?e.target:e.srcElement,i=t.lineIndex,n=t;n&&!n._ruler;)void 0===i&&void 0!==n.lineIndex&&(i=n.lineIndex),n=n.parentNode;var o=n?n._ruler:null;if(void 0===i&&o&&"document"===o.getOverview()){var r,s,a=this._getClientHeight(),l=this._model.getLineCount(),d=this._getViewPadding(),c=this._viewDiv.getBoundingClientRect(),h=this._getLineHeight(),u=h*l,p=a+d.top+d.bottom-2*this._metrics.scrollWidth;p>u?(r=h,s=d.top):(r=p/l,s=this._metrics.scrollWidth),i=Math.floor((e.clientY-c.top-s)/r),i>=0&&l>i||(i=void 0)}if(o)switch(e.type){case"click":o.onClick&&o.onClick(i,e);break;case"dblclick":o.onDblClick&&o.onDblClick(i,e);break;case"mousemove":o.onMouseMove&&o.onMouseMove(i,e);break;case"mouseover":o.onMouseOver&&o.onMouseOver(i,e);break;case"mouseout":if(o.onMouseOut){for(var f=e.relatedTarget;f&&f!==this._rootDiv;){if(f===n)return;f=f.parentNode}o.onMouseOut(i,e)}}},_handleScroll:function(){this._lastScrollTime=(new Date).getTime();var e=this._getScroll(!1),t=this._hScroll,i=this._vScroll;if(t!==e.x||i!==e.y){this._hScroll=e.x,this._vScroll=e.y,this._commitIME(),this._update(i===e.y);var n={type:"Scroll",oldValue:{x:t,y:i},newValue:e};this.onScroll(n)}},_handleSelectStart:function(e){var t=this._contextMenuOpen;return this._contextMenuOpen=!1,t?void(this._checkSelectionChange=!0):this._ignoreSelect?(e&&e.preventDefault&&e.preventDefault(),!1):void 0},_getModelOffset:function(e,t){if(e){var i;return i="DIV"===e.tagName?e:e.parentNode.parentNode,i._line?i._line.getModelOffset(e,t):0}},_updateSelectionFromDOM:function(){if(!(s.isIOS||s.isAndroid||this._checkSelectionChange))return!1;var e=this._getWindow(),t=e.getSelection(),i=this._getModelOffset(t.anchorNode,t.anchorOffset),n=this._getModelOffset(t.focusNode,t.focusOffset),o=this._getSelections()[0];if(void 0===i||void 0===n||o.start===i&&o.end===n)return!1;if(this._checkSelectionChange){var r=this._getLineNext(),a=this._getLinePrevious();if(t.anchorNode===r.firstChild.firstChild&&0===t.anchorOffset&&t.focusNode===a.firstChild.firstChild&&0===t.focusOffset)return!1;(t.anchorNode===r.firstChild.firstChild&&0===t.anchorOffset&&t.focusNode===a.lastChild.firstChild||t.anchorNode===this._clientDiv&&t.focusNode===this._clientDiv)&&(i=0,n=this.getModel().getCharCount())}return this._setSelection(new x(i,n),!1,!1),this._checkSelectionChange=!1,!0},_cancelCheckSelection:function(){this._checkSelectionChange&&(this._checkSelectionChange=!1,this._cancelPollSelectionChange())},_cancelPollSelectionChange:function(){if(this._selPollTimer){var e=this._getWindow();e.clearTimeout(this._selPollTimer),this._selPollTimer=null}},_pollSelectionChange:function(e){var t=this,i=this._getWindow();this._cancelPollSelectionChange(),this._selPollTimer=i.setTimeout(function(){if(t._selPollTimer=null,t._clientDiv){var i=t._updateSelectionFromDOM();!i&&e&&t._pollSelectionChange(e)}},100)},_handleSelectionChange:function(){-1===this._imeOffset&&(s.isAndroid?this._pollSelectionChange():this._updateSelectionFromDOM())},_handleTextInput:function(e){if(!this._ignoreEvent(e)&&-1===this._imeOffset){var t=this._getWindow().getSelection();if(t.anchorNode!==this._anchorNode||t.focusNode!==this._focusNode||t.anchorOffset!==this._anchorOffset||t.focusOffset!==this._focusOffset){for(var i=t.anchorNode;i&&void 0===i.lineIndex;)i=i.parentNode;if(i){var n=this._model,o=i.lineIndex,r=n.getLine(o),s=r,a=0,l=n.getLineStart(o);if(t.rangeCount>0){t.getRangeAt(0).deleteContents();var d=i.ownerDocument.createTextNode(e.data);t.getRangeAt(0).insertNode(d);var c=this._getDOMText(i,d);s=c.text,a=c.offset,d.parentNode.removeChild(d)}i.lineRemoved=!0;for(var h=0;r.charCodeAt(h)===s.charCodeAt(h)&&a>h;)h++;for(var u=r.length-1,p=s.length-r.length;r.charCodeAt(u)===s.charCodeAt(u+p)&&u+p>=a+e.data.length;)u--;u++;var f=s.substring(h,u+p);h+=l,u+=l;var g=this._getSelections(),_=g[0].start-h,m=g[0].end-u;g[0].start=h,g[0].end=u;for(var v=1;v=0;i--)if(t=n[i],"function"==typeof t.match){var o=t.match(e);if(void 0!==o)return this.invokeAction(o)}return!1},_doMove:function(e,t){var i=this._model,n=t.getCaret(),o=i.getLineAtOffset(n);for(e.count||(e.count=1);0!==e.count;){var r=i.getLineStart(o);if(e.count<0&&n===r){if(!(o>0))break;"character"===e.unit&&e.count++,o--,t.extend(i.getLineEnd(o))}else if(e.count>0&&n===i.getLineEnd(o)){if(!(o+10&&(r=Math.min(r+e.count-1,t.getLineCount()-1)),o=t.getLineEnd(r);n.extend(o)}e.select||n.collapse()}),this._setSelection(n,!0,!0,e.ctrl?function(){}:null),!0},_doEnter:function(e){if(this._singleMode)return!0;var t=this._model,i=this._getSelections();return this._doContent(t.getLineDelimiter()),e&&e.noCursor&&(i.forEach(function(e){e.end=e.start}),this._setSelection(i,!0)),!0},_doEscape:function(){var e=this._getSelections();return e.length>1&&this._setSelection(e[0],!0),!0},_doHome:function(e){var t=this._model,i=this,n=this._getSelections();return n.forEach(function(n){if(e.ctrl)n.extend(0);else{var o=n.getCaret(),r=t.getLineAtOffset(o);if(i._wrapMode){var s=i._getLine(r),a=s.getLineIndex(o);o=s.getLineStart(a),s.destroy()}else o=t.getLineStart(r);n.extend(o)}e.select||n.collapse()}),this._setSelection(n,!0,!0,e.ctrl?function(){}:null),!0},_doLineDown:function(e){var t=this._model,i=this,n=this._getSelections();return n.forEach(function(n){var o,r=n.getCaret(),a=t.getLineAtOffset(r),l=i._getLine(a),d=n._columnX,c=1,h=!1;if(-1===d||e.wholeLine||e.select&&s.isIE){var u=e.wholeLine?t.getLineEnd(a+1):r;d=n._columnX=l.getBoundingClientRect(u).left}if((o=l.getLineIndex(r))0?a=Math.min(a+e.count,p):a++}var f=!1;h?(e.select||s.isMac||s.isLinux)&&(n.extend(t.getCharCount()),f=!0):(l.lineIndex!==a&&(l.destroy(),l=i._getLine(a)),n.extend(l.getOffset(d,c)),f=!0),f&&(e.select||n.collapse()),l.destroy()}),i._setSelection(n,!0,!0,null,0,!1,!0),!0},_doLineUp:function(e){var t=this._model,i=this,n=this._getSelections();return n.forEach(function(n){var o,r,a=n.getCaret(),l=t.getLineAtOffset(a),d=i._getLine(l),c=n._columnX,h=!1;if(-1===c||e.wholeLine||e.select&&s.isIE){var u=e.wholeLine?t.getLineStart(l-1):a;c=n._columnX=d.getBoundingClientRect(u).left}(o=d.getLineIndex(a))>0?r=d.getClientRects(o-1).top+1:(h=0===l,h||(e.count&&e.count>0?l=Math.max(l-e.count,0):l--,r=i._getLineHeight(l)-1));var p=!1;h?(e.select||s.isMac||s.isLinux)&&(n.extend(0),p=!0):(d.lineIndex!==l&&(d.destroy(),d=i._getLine(l)),n.extend(d.getOffset(c,r)),p=!0),p&&(e.select||n.collapse()),d.destroy()}),i._setSelection(n,!0,!0,null,0,!1,!0),!0},_doNoop:function(){return!0},_doPageDown:function(e){var t,i,n,o=this,r=this._model,a=this._getSelections(),l=r.getLineCount(),d=this._getScroll(),c=this._getClientHeight(),h=this._getLineHeight(),u=Math.floor(c/h);return a.forEach(function(a){var p=a.getCaret(),f=r.getLineAtOffset(p);if(o._lineHeight){t=a._columnX;var g=o._getBoundsAtOffset(p);(-1===t||e.select&&s.isIE)&&(t=a._columnX=g.left);var _=o._getLineIndex(g.top+c);i=o._getLine(_);var m=o._getLinePixel(_),v=g.top+c-m;p=i.getOffset(t,v);var y=i.getBoundingClientRect(p);i.destroy(),a.extend(p),e.select||a.collapse(),n=void 0!==n?Math.min(n,y.top+m-g.top):y.top+m-g.top}else if(l-1>f){var x=Math.min(l-f-1,u);x=Math.max(1,x),t=a._columnX,(-1===t||e.select&&s.isIE)&&(i=o._getLine(f),t=a._columnX=i.getBoundingClientRect(p).left,i.destroy()),i=o._getLine(f+x),a.extend(i.getOffset(t,0)),i.destroy(),e.select||a.collapse();var b=l*h,w=d.y+x*h;w+c>b&&(w=b-c),n=void 0!==n?Math.min(n,w-d.y):w-d.y}}),this._setSelection(a,!0,!0,function(){},n,!1,!0),!0},_doPageUp:function(e){var t,i,n,o=this,r=this._model,a=this._getSelections(),l=this._getScroll(),d=this._getClientHeight(),c=this._getLineHeight(),h=Math.floor(d/c);return a.forEach(function(a){var u=a.getCaret(),p=r.getLineAtOffset(u);if(o._lineHeight){t=a._columnX;var f=o._getBoundsAtOffset(u);(-1===t||e.select&&s.isIE)&&(t=a._columnX=f.left);var g=o._getLineIndex(f.bottom-d);i=o._getLine(g);var _=o._getLinePixel(g),m=f.bottom-d-_;u=i.getOffset(t,m);var v=i.getBoundingClientRect(u);i.destroy(),a.extend(u),e.select||a.collapse(),n=void 0!==n?Math.max(n,v.top+_-f.top):v.top+_-f.top}else if(p>0){var y=Math.max(1,Math.min(p,h));t=a._columnX,(-1===t||e.select&&s.isIE)&&(i=o._getLine(p),t=a._columnX=i.getBoundingClientRect(u).left,i.destroy()),i=o._getLine(p-y),a.extend(i.getOffset(t,o._getLineHeight(p-y)-1)),i.destroy(),e.select||a.collapse();var x=Math.max(0,l.y-y*c);n=void 0!==n?Math.max(n,x-l.y):x-l.y}}),this._setSelection(a,!0,!0,function(){},n,!1,!0),!0},_doPaste:function(e){var t=this,i=this._getClipboardText(e,function(e){if(e.length){if(s.isLinux&&2===t._lastMouseButton){var i=(new Date).getTime()-t._lastMouseTime;i<=t._clickTime&&t._setSelectionTo(t._lastMouseX,t._lastMouseY,!0)}var n=t._getSelections(),o=t._singleMode?"":t._model.getLineDelimiter();t._doContent(n.length>1&&n.length===e.length?e:e.join(o))}});return null!==i},_doScroll:function(e){var t,i=e.type,n=this._model,o=n.getLineCount(),r=this._getClientHeight(),s=this._getLineHeight(),a=this._lineHeight?this._scrollHeight:o*s,l=this._getScroll().y;switch(i){case"textStart":t=0;break;case"textEnd":t=a-r;break;case"pageDown":t=l+r;break;case"pageUp":t=l-r;break;case"lineDown":t=l+s;break;case"lineUp":t=l-s;break;case"centerLine":var d=this._getSelections()[0],c=n.getLineAtOffset(d.start),h=n.getLineAtOffset(d.end),u=(h-c+1)*s;t=c*s-r/2+u/2}return void 0!==t&&(t=Math.min(Math.max(0,t),a-r),this._scrollViewAnimated(0,t-l,function(){})),!0},_doSelectAll:function(){var e=this._model;return this._setSelection(new x(0,e.getCharCount()),!1),!0},_doTab:function(){if(this._tabMode&&!this._readonly){var e=" ",t=this._getSelections();if(this._expandTab){e=[];var i=this._model,n=this._tabSize;t.forEach(function(t){var o=t.getCaret(),r=i.getLineAtOffset(o),s=i.getLineStart(r),a=n-(o-s)%n;e.push(c(a+1).join(" "))})}return this._modifyContent({text:e,selection:t,_ignoreDOMSelection:!0},!0)}},_doShiftTab:function(){return this._tabMode&&!this._readonly?!0:void 0},_doOverwriteMode:function(){return this._readonly?void 0:(this.setOptions({overwriteMode:!this.getOptions("overwriteMode")}),!0)},_doTabMode:function(){return this.setOptions({tabMode:!this.getOptions("tabMode")}),!0},_doWrapMode:function(){return this.setOptions({wrapMode:!this.getOptions("wrapMode")}),!0},_autoScroll:function(){var e,t,i=this._model,n=this._getSelections(),o=x.editing(n,"down"===this._autoScrollDir),r=this.convert({x:this._autoScrollX,y:this._autoScrollY},"page","document"),a=o.getCaret(),l=i.getLineCount(),d=i.getLineAtOffset(a);if("up"===this._autoScrollDir||"down"===this._autoScrollDir){var c=this._autoScrollY/this._getLineHeight();c=0>c?Math.floor(c):Math.ceil(c),e=d,e=Math.max(0,Math.min(l-1,e+c))}else("left"===this._autoScrollDir||"right"===this._autoScrollDir)&&(e=this._getLineIndex(r.y),t=this._getLine(d),r.x+=t.getBoundingClientRect(a,!1).left,t.destroy());this._blockSelection?n=this._getBlockSelections(n,e,r):0===e&&(s.isMac||s.isLinux)?o.extend(0):e===l-1&&(s.isMac||s.isLinux)?o.extend(i.getCharCount()):(t=this._getLine(e),o.extend(t.getOffset(r.x,r.y-this._getLinePixel(e))),t.destroy()),this._setSelection(n,!0)},_autoScrollTimer:function(){this._autoScroll();var e=this,t=this._getWindow();this._autoScrollTimerID=t.setTimeout(function(){e._autoScrollTimer()},this._AUTO_SCROLL_RATE)},_calculateLineHeightTimer:function(e){if(this._lineHeight&&!this._calculateLHTimer){var t=this._model.getLineCount(),i=0;if(e){for(var n=0,o=100,r=(new Date).getTime(),s=0;t>i&&(this._lineHeight[i]||(n++,s||(s=i),this._lineHeight[i]=this._calculateLineHeight(i)),i++,!((new Date).getTime()-r>o)););this.redrawRulers(0,t),this._queueUpdate()}var a=this._getWindow();if(i!==t){var l=this;return void(this._calculateLHTimer=a.setTimeout(function(){l._calculateLHTimer=null,l._calculateLineHeightTimer(!0)},0))}this._calculateLHTimer&&(a.clearTimeout(this._calculateLHTimer),this._calculateLHTimer=void 0)}},_calculateLineHeight:function(e){var t=this._getLine(e),i=t.getBoundingClientRect();return t.destroy(),Math.max(1,i.bottom-i.top)},_calculateMetrics:function(){var e=this._clientDiv,t=e.ownerDocument,i=" ",n=s.createElement(t,"div");n.style.lineHeight="normal";var o=this._model,r=o.getLine(0),a={type:"LineStyle",textView:this,0:0,lineText:r,lineStart:0};this.onLineStyle(a),h(a.style,n),n.style.position="fixed",n.style.left="-1000px";var l=s.createElement(t,"span");l.appendChild(t.createTextNode(i)),n.appendChild(l);var d=s.createElement(t,"span");d.style.fontStyle="italic",d.appendChild(t.createTextNode(i)),n.appendChild(d);var u=s.createElement(t,"span");u.style.fontWeight="bold",u.appendChild(t.createTextNode(i)),n.appendChild(u);var p=s.createElement(t,"span");p.style.fontWeight="bold",p.style.fontStyle="italic",p.appendChild(t.createTextNode(i)),n.appendChild(p),e.appendChild(n);var f=n.getBoundingClientRect(),g=l.getBoundingClientRect(),_=d.getBoundingClientRect(),y=u.getBoundingClientRect(),x=p.getBoundingClientRect(),b=g.bottom-g.top,w=_.bottom-_.top,C=y.bottom-y.top,T=x.bottom-x.top,L=0,k=f.bottom-f.top<=0,D=Math.max(1,f.bottom-f.top);w>b&&(L=1),C>w&&(L=2),T>C&&(L=3);var A;0!==L&&(A={style:{}},0!==(1&L)&&(A.style.fontStyle="italic"),0!==(2&L)&&(A.style.fontWeight="bold"));var S=v(n);e.removeChild(n);var E=m(this._viewDiv),O=s.createElement(t,"div");O.style.position="fixed",O.style.left="-1000px",O.style.paddingLeft=E.left+"px",O.style.paddingTop=E.top+"px",O.style.paddingRight=E.right+"px",O.style.paddingBottom=E.bottom+"px",O.style.width="100px",O.style.height="100px";var N=s.createElement(t,"div");N.style.width="100%",N.style.height="100%",O.appendChild(N),e.appendChild(O);var M=O.getBoundingClientRect(),I=N.getBoundingClientRect(),B=0;if(!this._singleMode&&!this._noScroll){O.style.overflow="hidden",N.style.height="200px";var R=O.clientWidth;O.style.overflow="scroll";var F=O.clientWidth;B=R-F}e.removeChild(O),E={left:I.left-M.left,top:I.top-M.top,right:M.right-I.right,bottom:M.bottom-I.bottom};var P=0,W=0,V=0;return k||(O=s.createElement(t,"div"),O.style.position="fixed",O.style.left="-1000px",e.appendChild(O),O.innerHTML=c(2).join("a"),M=O.getBoundingClientRect(),V=Math.ceil(M.right-M.left),(this._wrapOffset||this._marginOffset)&&(O.innerHTML=c(this._wrapOffset+1+(s.isWebkit?0:1)).join(" "),M=O.getBoundingClientRect(),P=Math.ceil(M.right-M.left),O.innerHTML=c(this._marginOffset+1).join(" "),I=O.getBoundingClientRect(),W=Math.ceil(I.right-I.left)),e.removeChild(O)),{lineHeight:D,largestFontStyle:A,lineTrim:S,viewPadding:E,scrollWidth:B,wrapWidth:P,marginWidth:W,charWidth:V,invalid:k}},_cancelAnimation:function(){this._animation&&(this._animation.stop(),this._animation=null)},_clearSelection:function(e){var t=this._getSelections();return t.forEach(function(t){"next"===e?t.start=t.end:t.end=t.start}),this._setSelection(t,!0),!0},_commitIME:function(e){if(-1!==this._imeOffset){var t=this._model,i=t.getLineAtOffset(this._imeOffset),n=t.getLineStart(i),o=this._getLineNode(i);if(!e){this._scrollDiv.focus(),this._clientDiv.focus();var r=this._getDOMText(o).text,a=t.getLine(i),l=this._imeOffset-n,d=l+r.length-a.length;l!==d&&(e=r.substring(l,d))}this._imeOffset=-1,e&&(this._doContent(e)||s.isWebkit||(o.lineRemoved=!0,this._queueUpdate()))}},_createActions:function(){this.addKeyMode(new i.DefaultKeyMode(this));var t=this;this._actions={noop:{defaultHandler:function(){return t._doNoop()}},lineUp:{defaultHandler:function(e){return t._doLineUp(p(e,{select:!1}))},actionDescription:{name:e.lineUp}},lineDown:{defaultHandler:function(e){return t._doLineDown(p(e,{select:!1}))},actionDescription:{name:e.lineDown}},lineStart:{defaultHandler:function(e){return t._doHome(p(e,{select:!1,ctrl:!1}))},actionDescription:{name:e.lineStart}},lineEnd:{defaultHandler:function(e){return t._doEnd(p(e,{select:!1,ctrl:!1}))},actionDescription:{name:e.lineEnd}},charPrevious:{defaultHandler:function(e){return t._doCursorPrevious(p(e,{select:!1,unit:"character"}))},actionDescription:{name:e.charPrevious}},charNext:{defaultHandler:function(e){return t._doCursorNext(p(e,{select:!1,unit:"character"}))},actionDescription:{name:e.charNext}},pageUp:{defaultHandler:function(e){return t._doPageUp(p(e,{select:!1}))},actionDescription:{name:e.pageUp}},pageDown:{defaultHandler:function(e){return t._doPageDown(p(e,{select:!1}))},actionDescription:{name:e.pageDown}},scrollPageUp:{defaultHandler:function(e){return t._doScroll(p(e,{type:"pageUp"}))},actionDescription:{name:e.scrollPageUp}},scrollPageDown:{defaultHandler:function(e){return t._doScroll(p(e,{type:"pageDown"}))},actionDescription:{name:e.scrollPageDown}},scrollLineUp:{defaultHandler:function(e){return t._doScroll(p(e,{type:"lineUp"}))},actionDescription:{name:e.scrollLineUp}},scrollLineDown:{defaultHandler:function(e){return t._doScroll(p(e,{type:"lineDown"}))},actionDescription:{name:e.scrollLineDown}},wordPrevious:{defaultHandler:function(e){return t._doCursorPrevious(p(e,{select:!1,unit:"word"}))},actionDescription:{name:e.wordPrevious}},wordNext:{defaultHandler:function(e){return t._doCursorNext(p(e,{select:!1,unit:"word"}))},actionDescription:{name:e.wordNext}},textStart:{defaultHandler:function(e){return t._doHome(p(e,{select:!1,ctrl:!0}))},actionDescription:{name:e.textStart}},textEnd:{defaultHandler:function(e){return t._doEnd(p(e,{select:!1,ctrl:!0}))},actionDescription:{name:e.textEnd}},scrollTextStart:{defaultHandler:function(e){return t._doScroll(p(e,{type:"textStart"}))},actionDescription:{name:e.scrollTextStart}},scrollTextEnd:{defaultHandler:function(e){return t._doScroll(p(e,{type:"textEnd"}))},actionDescription:{name:e.scrollTextEnd}},centerLine:{defaultHandler:function(e){return t._doScroll(p(e,{type:"centerLine"}))},actionDescription:{name:e.centerLine}},selectLineUp:{defaultHandler:function(e){return t._doLineUp(p(e,{select:!0}))},actionDescription:{name:e.selectLineUp}},selectLineDown:{defaultHandler:function(e){return t._doLineDown(p(e,{select:!0}))},actionDescription:{name:e.selectLineDown}},selectWholeLineUp:{defaultHandler:function(e){return t._doLineUp(p(e,{select:!0,wholeLine:!0}))},actionDescription:{name:e.selectWholeLineUp}},selectWholeLineDown:{defaultHandler:function(e){return t._doLineDown(p(e,{select:!0,wholeLine:!0}))},actionDescription:{name:e.selectWholeLineDown}},selectLineStart:{defaultHandler:function(e){return t._doHome(p(e,{select:!0,ctrl:!1}))},actionDescription:{name:e.selectLineStart}},selectLineEnd:{defaultHandler:function(e){return t._doEnd(p(e,{select:!0,ctrl:!1}))},actionDescription:{name:e.selectLineEnd}},selectCharPrevious:{defaultHandler:function(e){return t._doCursorPrevious(p(e,{select:!0,unit:"character"}))},actionDescription:{name:e.selectCharPrevious}},selectCharNext:{defaultHandler:function(e){return t._doCursorNext(p(e,{select:!0,unit:"character"}))},actionDescription:{name:e.selectCharNext}},selectPageUp:{defaultHandler:function(e){return t._doPageUp(p(e,{select:!0}))},actionDescription:{name:e.selectPageUp}},selectPageDown:{defaultHandler:function(e){return t._doPageDown(p(e,{select:!0}))},actionDescription:{name:e.selectPageDown}},selectWordPrevious:{defaultHandler:function(e){return t._doCursorPrevious(p(e,{select:!0,unit:"word"}))},actionDescription:{name:e.selectWordPrevious}},selectWordNext:{defaultHandler:function(e){return t._doCursorNext(p(e,{select:!0,unit:"word"}))},actionDescription:{name:e.selectWordNext}},selectTextStart:{defaultHandler:function(e){return t._doHome(p(e,{select:!0,ctrl:!0}))},actionDescription:{name:e.selectTextStart}},selectTextEnd:{defaultHandler:function(e){return t._doEnd(p(e,{select:!0,ctrl:!0}))},actionDescription:{name:e.selectTextEnd}},deletePrevious:{defaultHandler:function(e){return t._doBackspace(p(e,{unit:"character"}))},actionDescription:{name:e.deletePrevious}},deleteNext:{defaultHandler:function(e){return t._doDelete(p(e,{unit:"character"}))},actionDescription:{name:e.deleteNext}},deleteWordPrevious:{defaultHandler:function(e){return t._doBackspace(p(e,{unit:"word"}))},actionDescription:{name:e.deleteWordPrevious}},deleteWordNext:{defaultHandler:function(e){return t._doDelete(p(e,{unit:"word"}))},actionDescription:{name:e.deleteWordNext}},deleteLineStart:{defaultHandler:function(e){return t._doBackspace(p(e,{unit:"line"}))},actionDescription:{name:e.deleteLineStart}},deleteLineEnd:{defaultHandler:function(e){return t._doDelete(p(e,{unit:"line"}))},actionDescription:{name:e.deleteLineEnd}},tab:{defaultHandler:function(e){return t._doTab(p(e,{}))},actionDescription:{name:e.tab}},shiftTab:{defaultHandler:function(e){return t._doShiftTab(p(e,{}))},actionDescription:{name:e.shiftTab}},enter:{defaultHandler:function(e){return t._doEnter(p(e,{}))},actionDescription:{name:e.enter}},enterNoCursor:{defaultHandler:function(e){return t._doEnter(p(e,{noCursor:!0}))},actionDescription:{name:e.enterNoCursor}},escape:{defaultHandler:function(e){return t._doEscape(p(e,{}))},actionDescription:{name:e.escape}},selectAll:{defaultHandler:function(e){return t._doSelectAll(p(e,{}))},actionDescription:{name:e.selectAll}},copy:{defaultHandler:function(e){return t._doCopy(p(e,{}))},actionDescription:{name:e.copy}},cut:{defaultHandler:function(e){return t._doCut(p(e,{}))},actionDescription:{name:e.cut}},paste:{defaultHandler:function(e){return t._doPaste(p(e,{}))},actionDescription:{name:e.paste}},uppercase:{defaultHandler:function(e){return t._doCase(p(e,{type:"upper"}))},actionDescription:{name:e.uppercase}},lowercase:{defaultHandler:function(e){return t._doCase(p(e,{type:"lower"}))},actionDescription:{name:e.lowercase}},capitalize:{defaultHandler:function(e){return t._doCase(p(e,{unit:"word",type:"capitalize"}))},actionDescription:{name:e.capitalize}},reversecase:{defaultHandler:function(e){return t._doCase(p(e,{type:"reverse"}))},actionDescription:{name:e.reversecase}},toggleOverwriteMode:{defaultHandler:function(e){return t._doOverwriteMode(p(e,{}))},actionDescription:{name:e.toggleOverwriteMode}},toggleTabMode:{defaultHandler:function(e){return t._doTabMode(p(e,{}))},actionDescription:{name:e.toggleTabMode}},toggleWrapMode:{defaultHandler:function(e){return t._doWrapMode(p(e,{}))},actionDescription:{name:e.toggleWrapMode}}}},_createRulerParent:function(e,t){var i=s.createElement(e,"div");return i.className=t,i.tabIndex=-1,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.display="none",i.setAttribute("aria-hidden","true"),this._rootDiv.appendChild(i),i},_createRuler:function(e,t){if(this._clientDiv){var i=this._getRulerParent(e);if(i){(i!==this._marginDiv||this._marginOffset)&&(i.style.display="block"),i.rulerWidth=void 0;var n=s.createElement(i.ownerDocument,"div");if(n._ruler=e,e.node=n,n.rulerChanged=!0,n.style.position="relative",n.style.cssFloat="left",n.style.styleFloat="left",n.style.outline="none",void 0===t||0>t||t>=i.children.length)i.appendChild(n);else{for(var o=i.firstChild;o&&t-->0;)o=o.nextSibling;i.insertBefore(n,o)}}}},_createSelectionDiv:function(){var e=s.createElement(this._parent.ownerDocument,"div");return e.className="textviewSelection",e.style.position="absolute",e.style.borderWidth="0px",e.style.margin="0px",e.style.padding="0px",e.style.outline="none",e.style.width="0px",e.style.height="0px",e.style.zIndex="0",e},_createView:function(){function e(){b._rootDiv&&(b.update(!0),b._metrics.invalid&&b._getWindow().setTimeout(function(){e()},100))}if(!this._clientDiv){for(var t=this._parent;t.hasChildNodes();)t.removeChild(t.lastChild);var i=t.ownerDocument,n=s.createElement(i,"div");this._rootDiv=n,n.tabIndex=-1,n.style.position="relative",n.style.overflow="hidden",n.style.width="100%",n.style.height="100%",n.style.overflow="hidden",n.style.WebkitTextSizeAdjust="100%",n.setAttribute("role","application"),t.appendChild(n);var o=this._createRulerParent(i,"textviewLeftRuler");this._leftDiv=o;var r=s.createElement(i,"div");r.className="textviewScroll",this._viewDiv=r,r.tabIndex=-1,r.style.position="absolute",r.style.top="0px",r.style.bottom="0px",r.style.borderWidth="0px",r.style.margin="0px",r.style.outline="none",r.style.background="transparent",n.appendChild(r); +var l=this._createRulerParent(i,"textviewRightRuler");this._rightDiv=l,"rtl"==document.dir?l.style.left="0px":l.style.right="0px";var d=this._createRulerParent(i,"textviewInnerRightRuler");this._innerRightDiv=d,d.style.zIndex="1";var c=s.createElement(i,"div");this._scrollDiv=c,c.style.margin="0px",c.style.borderWidth="0px",c.style.padding="0px",r.appendChild(c);var h=this._marginDiv=this._createRulerParent(i,"textviewMarginRuler");if(h.style.zIndex="4",!s.isIE&&!s.isIOS){var u=s.createElement(i,"div");this._clipDiv=u,u.style.position="absolute",u.style.overflow="hidden",u.style.margin="0px",u.style.borderWidth="0px",u.style.padding="0px",u.style.background="transparent",n.appendChild(u);var p=s.createElement(i,"div");this._clipScrollDiv=p,p.style.position="absolute",p.style.height="1px",p.style.top="-1000px",p.style.background="transparent",u.appendChild(p)}var f=s.createElement(i,"div");if(f.className="textviewContent",this._clientDiv=f,f.tabIndex=0,f.style.position="absolute",f.style.borderWidth="0px",f.style.margin="0px",f.style.padding="0px",f.style.outline="none",f.style.zIndex="1",f.style.WebkitUserSelect="text",f.setAttribute("spellcheck","false"),(s.isIOS||s.isAndroid)&&(f.style.WebkitTapHighlightColor="transparent"),(this._clipDiv||n).appendChild(f),this._setFullSelection(this._fullSelection,!0),s.isIOS||s.isAndroid){var g=s.createElement(i,"div");this._vScrollDiv=g,g.style.position="absolute",g.style.borderWidth="1px",g.style.borderColor="white",g.style.borderStyle="solid",g.style.borderRadius="4px",g.style.backgroundColor="black",g.style.opacity="0.5",g.style.margin="0px",g.style.padding="0px",g.style.outline="none",g.style.zIndex="3",g.style.width="8px",g.style.display="none",n.appendChild(g);var _=s.createElement(i,"div");this._hScrollDiv=_,_.style.position="absolute",_.style.borderWidth="1px",_.style.borderColor="white",_.style.borderStyle="solid",_.style.borderRadius="4px",_.style.backgroundColor="black",_.style.opacity="0.5",_.style.margin="0px",_.style.padding="0px",_.style.outline="none",_.style.zIndex="3",_.style.height="8px",_.style.display="none",n.appendChild(_)}if(s.isFirefox&&!f.setCapture){var m=s.createElement(i,"div");this._overlayDiv=m,m.style.position=f.style.position,m.style.borderWidth=f.style.borderWidth,m.style.margin=f.style.margin,m.style.padding=f.style.padding,m.style.cursor="text",m.style.zIndex="2",(this._clipDiv||n).appendChild(m)}f.contentEditable="true",this._setWrapMode(this._wrapMode,!0),this._setReadOnly(this._readonly),this._setThemeClass(this._themeClass,!0),this._setTabSize(this._tabSize,!0),this._setMarginOffset(this._marginOffset,!0),this._hookEvents(),a.initInputField(f);for(var v=this._rulers,x=0;xthis._getLineHeight()){var i=t.getBoundingClientRect(),n=this._clientDiv.getBoundingClientRect();i.bottom>n.bottom&&(t=this._getLinePrevious(t)||t)}return t.lineIndex},_getBlockSelections:function(e,t,i){var n=this._model;e=e.filter(function(e){return!e._editing});var o,r=n.getLineAtOffset(this._blockSelection.getAnchor());t>r?o=t:(o=r,r=t);for(var s=r;o>=s;s++){var a=this._getLine(s),l=a.getOffset(i.x,1),d=a.getOffset(this._blockSelection._docX,1);if(a.destroy(),l!==d||l!==n.getLineEnd(s)){var c=d>l,h=new x(c?l:d,c?d:l,c);h._editing=!0,e.push(h)}}return e},_getBoundsAtOffset:function(e){var t=this._model,i=this._getLine(t.getLineAtOffset(e)),n=i.getBoundingClientRect(e),o=this._getLinePixel(i.lineIndex);return n.top+=o,n.bottom+=o,i.destroy(),n},_getClientHeight:function(){var e=this._getViewPadding();return Math.max(0,this._viewDiv.clientHeight-e.top-e.bottom)},_getInnerRightWidth:function(){var e=this._innerRightDiv.rulerWidth;if(void 0===e){var t=this._innerRightDiv.getBoundingClientRect();this._innerRightDiv.rulerWidth=e=t.right-t.left}return e},_getClientWidth:function(){var e=this._getViewPadding(),t=this._getInnerRightWidth();return Math.max(0,this._viewDiv.clientWidth-e.left-e.right-t)},_getClipboardText:function(e,t){function i(e){var i=[];return g(e,function(e){i.push(e)},null),t&&t(i),i}var n=this._getWindow(),o=n.clipboardData;if(!o&&e&&(o=e.clipboardData),o)return i(o.getData(s.isIE?"Text":"text/plain"));if(s.isElectron&&!e)return i(window.__clipboardModule.readText());if(s.isFirefox){this._ignoreFocus=!0;var r=this._clipboardDiv,a=this._rootDiv.ownerDocument;r||(r=s.createElement(a,"div"),this._clipboardDiv=r,r.style.position="fixed",r.style.whiteSpace="pre",r.style.left="-1000px",this._rootDiv.appendChild(r)),r.innerHTML="
    ",r.firstChild.focus();var l=this,d=function(){var e=l._getTextFromElement(r);return r.innerHTML="",i(e)},c=!1;if(this._ignorePaste=!0,!s.isLinux||2!==this._lastMouseButton)try{c=a.execCommand("paste",!1,null)}catch(h){c=r.childNodes.length>1||r.firstChild&&r.firstChild.childNodes.length>0}return this._ignorePaste=!1,c?(this.focus(),this._ignoreFocus=!1,d()):e?(n.setTimeout(function(){l.focus(),d(),l._ignoreFocus=!1},0),null):(this.focus(),this._ignoreFocus=!1,"")}return""},_getDOMText:function(e,t){return e._line.getText(t)},_getTextFromElement:function(e){var t=e.ownerDocument,i=t.defaultView;if(!i.getSelection)return e.innerText||e.textContent;var n=t.createRange();n.selectNode(e);var o,r=i.getSelection(),s=[];for(o=0;oi)for(t=i;e>t;t++)n+=this._getLineHeight(t);else for(t=i-1;t>=e;t--)n-=this._getLineHeight(t);return n}var o=this._getLineHeight();return o*e},_getLineIndex:function(e,t){var i,n=0,o=this._model.getLineCount();if(this._lineHeight){n=this._getTopIndex();var r=-this._topIndexY+this._getScroll().y;if(e!==r)if(r>e)for(;r>e&&n>0;)e+=this._getLineHeight(--n);else for(i=this._getLineHeight(n);e-i>=r&&o-1>n;)e-=i,i=this._getLineHeight(++n)}else i=this._getLineHeight(),n=Math.floor(e/i);return t&&(0===o||0>n||n>o-1)?-1:Math.max(0,Math.min(o-1,n))},_getRulerParent:function(e){switch(e.getLocation()){case"left":return this._leftDiv;case"right":return this._rightDiv;case"innerRight":return this._innerRightDiv;case"margin":return this._marginDiv}return null},_getScroll:function(e){(void 0===e||e)&&this._cancelAnimation();var t=this._viewDiv;return{x:t.scrollLeft,y:t.scrollTop}},_getSelection:function(){return(Array.isArray(this._selection)?this._selection[0]:this._selection).clone()},_getSelections:function(){return(Array.isArray(this._selection)?this._selection:[this._selection]).map(function(e){return e.clone()})},_getTopIndex:function(e){var t=this._topChild;if(e&&this._getClientHeight()>this._getLineHeight()){var i=t.getBoundingClientRect(),n=this._getViewPadding(),o=this._viewDiv.getBoundingClientRect();i.top26?"wheel":s.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(t){return e._handleMouseWheel(t?t:l.event)}}),this._clipDiv&&t.push({target:this._clipDiv,type:s.isFirefox>26?"wheel":s.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(t){return e._handleMouseWheel(t?t:l.event)}}),s.isFirefox&&(!s.isWindows||s.isFirefox>=15)){var u=l.MutationObserver||l.MozMutationObserver;u?(this._mutationObserver=new u(function(t){e._handleDataModified(t)}),this._mutationObserver.observe(i,{subtree:!0,characterData:!0})):t.push({target:this._clientDiv,type:"DOMCharacterDataModified",handler:function(t){return e._handleDataModified(t?t:l.event)}})}(s.isFirefox&&(!s.isWindows||s.isFirefox>=15)||s.isIE||s.isWebkit)&&(t.push({target:this._clientDiv,type:"compositionstart",handler:function(t){return e._handleCompositionStart(t?t:l.event)}}),t.push({target:this._clientDiv,type:"compositionend",handler:function(t){return e._handleCompositionEnd(t?t:l.event)}}),t.push({target:this._clientDiv,type:"compositionupdate",handler:function(t){return e._handleCompositionUpdate(t?t:l.event)}})),this._overlayDiv&&(t.push({target:this._overlayDiv,type:"mousedown",handler:function(t){return e._handleMouseDown(t?t:l.event)}}),t.push({target:this._overlayDiv,type:"mouseover",handler:function(t){return e._handleMouseOver(t?t:l.event)}}),t.push({target:this._overlayDiv,type:"mouseout",handler:function(t){return e._handleMouseOut(t?t:l.event)}}),t.push({target:this._overlayDiv,type:"contextmenu",handler:function(t){return e._handleContextMenu(t?t:l.event)}})),this._isW3CEvents||t.push({target:this._clientDiv,type:"dblclick",handler:function(t){return e._handleDblclick(t?t:l.event)}})}this._hookRulerEvents(this._leftDiv,t),this._hookRulerEvents(this._rightDiv,t),this._hookRulerEvents(this._innerRightDiv,t),this._hookRulerEvents(this._marginDiv,t);for(var p=0;p26?"wheel":s.isFirefox?"DOMMouseScroll":"mousewheel",handler:function(e){return i._handleMouseWheel(e?e:n.event)}}),t.push({target:e,type:"click",handler:function(e){i._handleRulerEvent(e?e:n.event)}}),t.push({target:e,type:"dblclick",handler:function(e){i._handleRulerEvent(e?e:n.event)}}),t.push({target:e,type:"mousemove",handler:function(e){i._handleRulerEvent(e?e:n.event)}}),t.push({target:e,type:"mouseover",handler:function(e){i._handleRulerEvent(e?e:n.event)}}),t.push({target:e,type:"mouseout",handler:function(e){i._handleRulerEvent(e?e:n.event)}})}},_getWindow:function(){return d(this._parent.ownerDocument)},_ignoreEvent:function(e){for(var t=e.target;t&&t!==this._clientDiv;){if(t.ignore)return!0;t=t.parentNode}return!1},_init:function(e){var i=e.parent;if("string"==typeof i&&(i=(e.document||document).getElementById(i)),!i)throw new Error("no parent");e.parent=i,e.model=e.model||new t.TextModel;var n=this._defaultOptions();for(var o in n)if(n.hasOwnProperty(o)){var r;r=void 0!==e[o]?e[o]:n[o].value,this["_"+o]=r}this._keyModes=[],this._rulers=[],this._selection=[new x(0,0,!1)],this._linksVisible=!1,this._redrawCount=0,this._maxLineWidth=0,this._maxLineIndex=-1,this._ignoreSelect=!0,this._ignoreFocus=!1,this._hasFocus=!1,this._dragOffset=-1,this._isRangeRects=(!s.isIE||s.isIE>=9)&&"function"==typeof i.ownerDocument.createRange().getBoundingClientRect,this._isW3CEvents=i.addEventListener,this._autoScrollX=null,this._autoScrollY=null,this._autoScrollTimerID=null,this._AUTO_SCROLL_RATE=50,this._grabControl=null,this._moseMoveClosure=null,this._mouseUpClosure=null,this._lastMouseX=0,this._lastMouseY=0,this._lastMouseTime=0,this._clickCount=0,this._clickTime=250,this._clickDist=5,this._isMouseDown=!1,this._doubleClickSelection=null,this._hScroll=0,this._vScroll=0,this._imeOffset=-1,this._createActions(),this._createView()},_checkOverlayScroll:function(){if(s.isMac&&s.isWebkit&&!this._metrics.invalid&&0===this._metrics.scrollWidth){var e=this._viewDiv,t=this._isOverOverlayScroll();e.style.pointerEvents=t.vertical||t.horizontal?"":"none"}},_isOverOverlayScroll:function(){var e=(new Date).getTime()-this._lastScrollTime<200;if(!e)return{};var t=this._viewDiv.getBoundingClientRect(),i=this._lastMouseMoveX,n=this._lastMouseMoveY,o=15;return{vertical:t.top<=n&&n1&&this.setRedraw(!1);var s=this._compoundChange;s?x.compare(this._getSelections(),s.owner.selection)||(this._endUndo(),e.selection.length>1&&this._startUndo()):e.selection.length>1&&this._startUndo();var a=this._model;try{e._ignoreDOMSelection&&(this._ignoreDOMSelection=!0);var l=0,d=0;e.selection.forEach(function(i){i.start+=l,i.end+=l;var n=Array.isArray(e.text)?e.text[d]:e.text;a.setText(n,i.start,i.end),l+=i.start-i.end+n.length,i.setCaret(t?i.start+n.length:i.start),d++})}finally{e._ignoreDOMSelection&&(this._ignoreDOMSelection=!1)}return this._setSelection(e.selection,i,!0,n),s=this._compoundChange,s&&(s.owner.selection=e.selection),e.selection.length>1&&this.setRedraw(!0),this.onModify({type:"Modify"}),!0},_onModelChanged:function(e){e.type="ModelChanged",this.onModelChanged(e),e.type="Changed";var t=e.start,i=e.addedCharCount,n=e.removedCharCount,o=e.addedLineCount,r=e.removedLineCount,s=this._getSelections();s.forEach(function(e){e.end>t&&(e.end>t&&e.start=l&&l+r>=h&&(l!==h||d.modelChangedEvent||d.lineRemoved?(d.lineRemoved=!0,d.lineChanged=!1,d.modelChangedEvent=null):(d.modelChangedEvent=e,d.lineChanged=!0)),h>l+r&&(d.lineIndex=h+o-r,d._line.lineIndex=d.lineIndex),d=this._getLineNext(d)}if(this._lineHeight){var u=[l,r].concat(c(o));Array.prototype.splice.apply(this._lineHeight,u)}this._wrapMode||l<=this._maxLineIndex&&this._maxLineIndex<=l+r&&(this._checkMaxLineIndex=this._maxLineIndex,this._maxLineIndex=-1,this._maxLineWidth=0),this._update()},_onModelChanging:function(e){e.type="ModelChanging",this.onModelChanging(e),e.type="Changing"},_queueUpdate:function(){if(!this._updateTimer&&!this._ignoreQueueUpdate){var e=this,t=this._getWindow();this._updateTimer=t.setTimeout(function(){e._updateTimer=null,e._update()},0)}},_rangesToSelections:function(e){var t=[],i=this._model.getCharCount();return e.forEach(function(e){var n;if(e instanceof x)n=e.clone();else{var o=e.start,r=e.end,s=o>r;if(s){var a=o;o=r,r=a}o=Math.max(0,Math.min(o,i)),r=Math.max(0,Math.min(r,i)),n=new x(o,r,s)}t.push(n)}),t},_resetLineHeight:function(e,t){if(this._wrapMode||this._variableLineHeight){if(void 0!==e&&void 0!==t)for(var i=e;t>i;i++)this._lineHeight[i]=void 0;else this._lineHeight=c(this._model.getLineCount());this._calculateLineHeightTimer()}else this._lineHeight=null},_resetLineWidth:function(){var e=this._clientDiv;if(e)for(var t=e.firstChild;t;)t.lineWidth=void 0,t=t.nextSibling},_reset:function(){this._maxLineIndex=-1,this._maxLineWidth=0,this._topChild=null,this._bottomChild=null,this._topIndexY=0,this._variableLineHeight=!1,this._resetLineHeight(),this._setSelection(new x(0,0,!1),!1,!1),this._viewDiv&&(this._viewDiv.scrollLeft=0,this._viewDiv.scrollTop=0);var e=this._clientDiv;if(e){for(var t=e.firstChild;t;)t.lineRemoved=!0,t=t.nextSibling;s.isFirefox<13&&this._fixCaret()}},_scrollViewAnimated:function(e,t,i){var n=this._getWindow();if(i&&this._scrollAnimation){var o=this;this._animation=new D({window:n,duration:this._scrollAnimation,curve:[t,0],onAnimate:function(e){var i=t-Math.floor(e);o._scrollView(0,i),t-=i},onEnd:function(){o._animation=null,o._scrollView(e,t),i&&n.setTimeout(i,0)}}),this._animation.play()}else this._scrollView(e,t),i&&n.setTimeout(i,0)},_scrollView:function(e,t){this._ensureCaretVisible=!1;var i=this._viewDiv;e&&(i.scrollLeft+=e),t&&(i.scrollTop+=t)},_setClipboardText:function(e,t){if(s.isElectron&&!t)return window.__clipboardModule.writeText(e),!0;var i,n=this._getWindow(),o=n.clipboardData;if(!o&&t&&(o=t.clipboardData),o){i=[],g(e,function(e){i.push(e)},function(){i.push(s.platformDelimiter)});var r=o.setData(s.isIE?"Text":"text/plain",i.join(""));if(r||t&&(s.isFirefox>21||s.isWebkit))return!0;if(!t)return!1}var a=this._parent.ownerDocument,l=s.createElement(a,"pre");l.style.position="fixed",l.style.left="-1000px",g(e,function(e){l.appendChild(a.createTextNode(e))},function(){l.appendChild(s.createElement(a,"br"))}),l.appendChild(a.createTextNode(" ")),this._clientDiv.appendChild(l);var d=a.createRange();d.setStart(l.firstChild,0),d.setEndBefore(l.lastChild);var c=n.getSelection();c.rangeCount>0&&c.removeAllRanges(),c.addRange(d);var h=this,u=function(){l&&l.parentNode===h._clientDiv&&h._clientDiv.removeChild(l),h._updateDOMSelection()},p=!1;this._ignoreCopy=!0;try{p=a.execCommand("copy",!1,null)}catch(f){}return this._ignoreCopy=!1,!p&&t?(n.setTimeout(u,0),!1):(u(),!0)},_setGrab:function(e){e!==this._grabControl&&(e?(e.setCapture&&e.setCapture(),this._grabControl=e):(this._grabControl.releaseCapture&&this._grabControl.releaseCapture(),this._grabControl=null))},_setLinksVisible:function(e){if(this._linksVisible!==e){this._linksVisible=e,s.isIE&&e&&(this._hadFocus=this._hasFocus);var t=this._clientDiv;t.contentEditable=!e,this._hadFocus&&!e&&t.focus(),this._overlayDiv&&(this._overlayDiv.style.zIndex=e?"-1":"1");for(var i=this._getLineNext();i;)i._line.updateLinks(),i=this._getLineNext(i);this._updateDOMSelection()}},_setSelection:function(e,t,i,n,o,r,s){if(e){void 0===i&&(i=!0);var a,l=this._getSelections();if(a=Array.isArray(e)?e:r?l.concat([e]):[e],this._selection=x.merge(a),s||a.forEach(function(e){e._columnX=-1}),t!==!1&&this._showCaret(!1,n,t,o),i&&this._updateDOMSelection(),!x.compare(l,a)){var d={type:"Selection",oldValue:x.convert(l),newValue:x.convert(a)};this.onSelection(d)}}},_setSelectionTo:function(e,t,i,n,o,r){var s=this._model,a=this._getSelections(),l=this.convert({x:e,y:t},"page","document"),d=this._getLineIndex(l.y),c=this._getLine(d),h=c.getOffset(l.x,l.y-this._getLinePixel(d));if(r&&!n&&x.contains(a,h))return this._dragOffset=h,c.destroy(),!1;if(this._blockSelection)a=this._getBlockSelections(a,d,l);else{var u;if(i?n?(u=a[a.length-1],u._editing=!0):(u=new x(0,0),u._editing=!0,o?a.push(u):a=[u],u._docX=l.x):u=x.editing(a),1===this._clickCount)u.extend(h),n||u.collapse();else{var p,f,g=0===(1&this._clickCount);if(g)this._doubleClickSelection?h>=this._doubleClickSelection.start?(p=this._doubleClickSelection.start,f=c.getNextOffset(h,{unit:"wordend",count:1})):(p=c.getNextOffset(h,{unit:"word",count:-1}),f=this._doubleClickSelection.end):(p=c.getNextOffset(h,{unit:"word",count:-1}),f=c.getNextOffset(p,{unit:"wordend",count:1}));else if(this._doubleClickSelection){var _=s.getLineAtOffset(this._doubleClickSelection.start);d>=_?(p=s.getLineStart(_),f=s.getLineEnd(d)):(p=s.getLineStart(d),f=s.getLineEnd(_))}else p=s.getLineStart(d),f=s.getLineEnd(d);u.setCaret(p),u.extend(f)}}return this._setSelection(a,!0,!0,null,!1),c.destroy(),!0},_setFullSelection:function(e,t){this._fullSelection=e,s.isWebkit<537.36&&(this._fullSelection=e=!0),this._domSelection||(this._domSelection=[],this._cursorVisible=!0),t||this._updateDOMSelection()},_setBlockCursor:function(e){this._blockCursorVisible=e,this._updateBlockCursorVisible()},_setOverwriteMode:function(e){this._overwriteMode=e,this._updateBlockCursorVisible()},_updateBlockCursorVisible:function(){if(this._blockCursorVisible||this._overwriteMode){if(!this._cursorDiv){var e=this._viewDiv,t=s.createElement(e.ownerDocument,"div");t.className="textviewBlockCursor",this._cursorDiv=t,t.tabIndex=-1,t.style.zIndex="2",t.style.color="transparent",t.style.position="absolute",t.style.pointerEvents="none",t.innerHTML=" ",e.appendChild(t),this._updateDOMSelection()}}else this._cursorDiv&&(this._cursorDiv.parentNode.removeChild(this._cursorDiv),this._cursorDiv=null)},_setMarginOffset:function(e,t){this._marginOffset=e,this._marginDiv.style.display=e?"block":"none",t||(this._metrics=this._calculateMetrics(),this._queueUpdate())},_setWrapOffset:function(e,t){this._wrapOffset=e,t||(this._metrics=this._calculateMetrics(),this._queueUpdate())},_setReadOnly:function(e){this._readonly=e},_setSingleMode:function(e,t){this._singleMode=e,this._updateOverflow(),this._updateStyle(t)},_setNoScroll:function(e,t){this._noScroll=e,this._updateOverflow(),this._updateStyle(t)},_setTabSize:function(e,t){this._tabSize=e,this._customTabSize=void 0;var i=this._clientDiv;s.isOpera?i&&(i.style.OTabSize=this._tabSize+""):s.isWebkit>=537.1?i&&(i.style.tabSize=this._tabSize+""):s.isFirefox>=4?i&&(i.style.MozTabSize=this._tabSize+""):8!==this._tabSize&&(this._customTabSize=this._tabSize),t||(this.redrawLines(),this._resetLineWidth())},_setTheme:function(e){this._theme&&this._theme.removeEventListener("ThemeChanged",this._themeListener.onChanged),this._theme=e,this._theme&&this._theme.addEventListener("ThemeChanged",this._themeListener.onChanged),this._setThemeClass(this._themeClass)},_setThemeClass:function(e,t){this._themeClass=e;var i="textview",n=this._theme.getThemeClass();n&&(i+=" "+n),this._themeClass&&n!==this._themeClass&&(i+=" "+this._themeClass),this._rootDiv.className=i,this._updateStyle(t)},_setUndoStack:function(e){this._undoStack=e},_setWrapMode:function(e,t){this._wrapMode=e&&this._wrappable;var i=this._clientDiv;this._wrapMode?(i.style.whiteSpace="pre-wrap",i.style.wordWrap="break-word"):(i.style.whiteSpace="pre",i.style.wordWrap="normal"),this._updateOverflow(),t||(this.redraw(),this._resetLineWidth()),this._resetLineHeight()},_showCaret:function(e,t,i,n){if(this._clientDiv&&!(this._redrawCount>0||this._ignoreDOMSelection||-1!==this._imeOffset)){var o=this._model,r=this._getSelections(),s=x.editing(r,"down"===this._autoScrollDir),a=this._getScroll(),l=s.getCaret(),d=s.start,c=s.end,h=o.getLineAtOffset(d),u=o.getLineAtOffset(c),p=Math.max(Math.max(d,o.getLineStart(u)),c-1),f=this._getClientWidth(),g=this._getClientHeight(),_=f/4,m=this._getBoundsAtOffset(l===d?d:p),v=m.left,y=m.right,b=m.top,w=m.bottom,C=0,T="object"==typeof i;!e&&!T||s.isEmpty()||(m=this._getBoundsAtOffset(l===c?d:p),C=(m.bottom>w?m.bottom:w)-(m.topa.x+f&&(L=Math.max(y-a.x-f,_));var k=0;ba.y+g&&(k=w-a.y-g),n&&(n>0?k>0&&(k=Math.max(k,n)):0>k&&(k=Math.min(k,n)));var D=T&&"always"===i.scrollPolicy;if(0!==L||0!==k||D){if(T){var A=k>0;0===k&&(k=b-a.y);var S=i.viewAnchor,E=i.selectionAnchor,O=Math.min(Math.max(0,i.viewAnchorOffset||0));k+=Math.floor("top"===S?A?(1-O)*g:-O*g:"bottom"===S?A?O*g:-(1-O)*g:"center"===S?A?g/2+O*g:g/2-(1-O)*g:A?O*g:-O*g),h!==u&&("top"===E&&l!==d?k+=Math.floor(-C):"bottom"===E&&l!==c?k+=Math.floor(C):"center"===E&&(k+=Math.floor(C/2)))}else 0!==k&&"number"==typeof i&&(0>i&&(i=0),i>1&&(i=1),k+=Math.floor(k>0?i*g:-i*g));return this._scrollViewAnimated(L,k,t),g!==this._getClientHeight()||f!==this._getClientWidth()?this._showCaret():this._ensureCaretVisible=!0,!0}return t&&t(),!1}},_startIME:function(){if(-1===this._imeOffset){for(var e=!1,t=this._getSelections(),i=0;i0)&&!this._ignoreDOMSelection&&-1===this._imeOffset&&this._clientDiv){var e,t=this._getSelections(),i=this._domSelection;if(i.lengtht.length&&i.splice(t.length).forEach(function(e){e.destroy()});for(e=0;e1?this._cursorTimer||(this._cursorTimer=n.setInterval(function(){o._cursorVisible=!o._cursorVisible,o._domSelection.forEach(function(e){e.update()})},500)):this._cursorTimer&&(n.clearInterval(this._cursorTimer),this._cursorTimer=null)}},_update:function(e){if(!(this._redrawCount>0)){if(this._updateTimer){var t=this._getWindow();t.clearTimeout(this._updateTimer),this._updateTimer=null,e=!1}var i=this._clientDiv,n=this._viewDiv;if(i){this._metrics.invalid&&(this._ignoreQueueUpdate=!0,this._updateStyle(),this._ignoreQueueUpdate=!1);
    +var o=this._model,r=this._getScroll(!1),a=this._getViewPadding(),l=o.getLineCount(),d=this._getLineHeight(),c=!1,h=!1,u=!1,p=this._metrics.scrollWidth;this._wrapMode&&(i.style.width=(this._metrics.wrapWidth||this._getClientWidth())+"px");var f,g,_,m,v,y,x,b,w,T,L,k=0,D=0;if(this._lineHeight){for(;l>D&&(L=this._getLineHeight(D),!(k+L>r.y));)k+=L,D++;f=D,g=Math.max(0,f-1),m=_=r.y-k,f>0&&(_+=this._getLineHeight(f-1))}else{var A=Math.max(0,r.y)/d;f=Math.floor(A),g=Math.max(0,f-1),_=Math.round((A-g)*d),m=Math.round((A-f)*d),T=l*d}this._topIndexY=m;var S=this._rootDiv,E=S.clientWidth,O=S.clientHeight;if(e){for(v=0,this._leftDiv&&(y=this._leftDiv.getBoundingClientRect(),v=y.right-y.left),x=this._getClientWidth(),b=this._getClientHeight(),w=x,this._wrapMode?this._metrics.wrapWidth&&(w=this._metrics.wrapWidth):w=Math.max(this._maxLineWidth,w);l>D;)L=this._getLineHeight(D,!1),k+=L,D++;T=k}else{b=this._getClientHeight();for(var N,M,I=Math.floor((b+m)/d),B=Math.min(f+I,l-1),R=Math.min(B+1,l-1),F=i.firstChild;F;){N=F.lineIndex;var P=F.nextSibling;N>=g&&R>=N&&!F.lineRemoved&&-1!==F.lineIndex||(this._mouseWheelLine===F?(F.style.display="none",F.lineIndex=-1):i.removeChild(F)),F=P}F=this._getLineNext();var W=n.ownerDocument,V=W.createDocumentFragment();for(N=g;R>=N;N++)!F||F.lineIndex>N?new C(this,N).create(V,null):(V.firstChild&&(i.insertBefore(V,F),V=W.createDocumentFragment()),F&&F.lineChanged&&(F=new C(this,N).create(V,F),F.lineChanged=!1),F=this._getLineNext(F));V.firstChild&&i.insertBefore(V,F),s.isWebkit&&!this._wrapMode&&(i.style.width="0x7fffffffpx");var j;F=this._getLineNext();for(var U=b+_,H=!1;F;){if(M=F.lineWidth,void 0===M){j=F._line.getBoundingClientRect(),M=F.lineWidth=Math.ceil(j.right-j.left);var K=j.bottom-j.top;this._lineHeight?this._lineHeight[F.lineIndex]=K:0!==d&&0!==K&&Math.ceil(d)!==Math.ceil(K)&&(this._variableLineHeight=!0,this._lineHeight=[],this._lineHeight[F.lineIndex]=K)}this._lineHeight&&!H&&(U-=this._lineHeight[F.lineIndex],0>U&&(B=F.lineIndex,H=!0)),this._wrapMode||(M>=this._maxLineWidth&&(this._maxLineWidth=M,this._maxLineIndex=F.lineIndex),this._checkMaxLineIndex===F.lineIndex&&(this._checkMaxLineIndex=-1)),F.lineIndex===f&&(this._topChild=F),F.lineIndex===B&&(this._bottomChild=F),F=this._getLineNext(F)}if(-1!==this._checkMaxLineIndex&&(N=this._checkMaxLineIndex,this._checkMaxLineIndex=-1,N>=0&&l>N)){var $=new C(this,N);j=$.getBoundingClientRect(),M=j.right-j.left,M>=this._maxLineWidth&&(this._maxLineWidth=M,this._maxLineIndex=N),$.destroy()}for(;l>D;)L=this._getLineHeight(D,B>=D),k+=L,D++;T=k,this._updateRuler(this._leftDiv,f,R,O),this._updateRuler(this._rightDiv,f,R,O),this._updateRuler(this._innerRightDiv,f,R,O),this._updateRuler(this._marginDiv,f,R,O),v=0,this._leftDiv&&(y=this._leftDiv.getBoundingClientRect(),v=y.right-y.left);var G=0;if(this._rightDiv){var z=this._rightDiv.getBoundingClientRect();G=z.right-z.left}n.style.left=v+"px",n.style.right=G+"px";var Y=this._scrollDiv;if(Y.style.height=T+(s.isWebkit?0:a.bottom)+"px",x=this._getClientWidth(),!this._singleMode&&!this._wrapMode&&!this._noScroll){var q=b,X=b,Q="scroll"===n.style.overflowX;Q?q+=p:X-=p;var J=x,Z=x,et="scroll"===n.style.overflowY;et?J+=p:Z-=p,b=q,x=J,T>b&&(u=!0,x=Z),this._maxLineWidth>x&&(h=!0,b=X,T>b&&(u=!0,x=Z)),Q!==h&&(n.style.overflowX=h?"scroll":"hidden"),et!==u&&(n.style.overflowY=u?"scroll":"hidden"),c=Q!==h||et!==u}var tt=x;this._wrapMode?this._metrics.wrapWidth&&(tt=this._metrics.wrapWidth):tt=Math.max(this._maxLineWidth+this._getInnerRightWidth(),tt),w=tt,(!s.isIE||s.isIE>=9)&&this._maxLineWidth>x&&(tt+=a.right+a.left),Y.style.width=tt+"px",this._clipScrollDiv&&(this._clipScrollDiv.style.width=tt+"px"),r=this._getScroll(!1);var it=this._innerRightDiv;it&&(it.style.right=G+("scroll"===n.style.overflowY?this._metrics.scrollWidth:0)+"px",it.style.bottom=("scroll"===n.style.overflowX?p:0)+"px")}if(this._scrollHeight=T,this._vScrollDiv){var nt=b-8,ot=Math.max(15,Math.ceil(Math.min(1,nt/(T+a.top+a.bottom))*nt));this._vScrollDiv.style.left=v+x-8+"px",this._vScrollDiv.style.top=Math.floor(Math.max(0,r.y*nt/T))+"px",this._vScrollDiv.style.height=ot+"px"}if(!this._wrapMode&&this._hScrollDiv){var rt=x-8,st=Math.max(15,Math.ceil(Math.min(1,rt/(this._maxLineWidth+a.left+a.right))*rt));this._hScrollDiv.style.left=v+Math.floor(Math.max(0,Math.floor(r.x*rt/this._maxLineWidth)))+"px",this._hScrollDiv.style.top=b-9+"px",this._hScrollDiv.style.width=st+"px"}var at,lt,dt=r.x,ct=this._clipDiv,ht=this._overlayDiv,ut=this._marginDiv;if(ut&&(ut.style.left=-dt+v+this._metrics.marginWidth+a.left+"px",ut.style.bottom=("scroll"===n.style.overflowX?p:0)+"px"),ct){ct.scrollLeft=dt,ct.scrollTop=0,at=v+a.left,lt=a.top;var pt=x,ft=b,gt=0,_t=-_;0===r.x&&(at-=a.left,pt+=a.left,gt=a.left),r.x+x===w&&(pt+=a.right),0===r.y&&(lt-=a.top,ft+=a.top,_t+=a.top),r.y+b===T&&(ft+=a.bottom),ct.style.left=at+"px",ct.style.top=lt+"px",ct.style.right=E-pt-at+"px",ct.style.bottom=O-ft-lt+"px",i.style.left=gt+"px",i.style.top=_t+"px",i.style.width=w+"px",i.style.height=b+_+"px",ht&&(ht.style.left=i.style.left,ht.style.top=i.style.top,ht.style.width=i.style.width,ht.style.height=i.style.height)}else{at=dt,lt=_;var mt=dt+x,vt=_+b;0===at&&(at-=a.left),0===lt&&(lt-=a.top),mt===w&&(mt+=a.right),r.y+b===T&&(vt+=a.bottom),i.style.clip="rect("+lt+"px,"+mt+"px,"+vt+"px,"+at+"px)","rtl"==document.dir?i.style.right=-dt+v+a.left+"px":i.style.left=-dt+v+a.left+"px",i.style.width=(this._wrapMode||s.isWebkit?w:x+dt)+"px",e||(i.style.top=-_+a.top+"px",i.style.height=b+_+"px"),ht&&(ht.style.clip=i.style.clip,ht.style.left=i.style.left,ht.style.width=i.style.width,e||(ht.style.top=i.style.top,ht.style.height=i.style.height))}if(this._updateDOMSelection(),c){var yt=this._ensureCaretVisible;this._ensureCaretVisible=!1,yt&&this._showCaret(),this._queueUpdate()}}}},_updateOverflow:function(){var e=this._viewDiv;this._noScroll?e.style.overflow="hidden":this._wrapMode?(e.style.overflowX="hidden",e.style.overflowY="scroll"):e.style.overflow="hidden"},_updateRuler:function(e,t,i,n){if(e)for(var o=this._parent.ownerDocument,r=this._getLineHeight(),a=this._getViewPadding(),l=e.firstChild;l;){var d=l._ruler,c=d.getOverview();if(l.rulerChanged&&(h(d.getRulerStyle(),l),e.rulerWidth=void 0),"fixed"!==c){var u=r;"page"===c&&(u+=this._topIndexY),l.style.top=-u+"px",l.style.height=n+u+"px";var p,f=l.firstChild;f?(p=f,f=f.nextSibling):(p=s.createElement(o,"div"),p.style.visibility="hidden",l.appendChild(p));var g,_;l.rulerChanged&&p&&(g=-1,_=d.getWidestAnnotation(),_&&(h(_.style,p),_.html&&(p.innerHTML=_.html)),p.lineIndex=g,p.style.height=r+a.top+"px");var m,v,y;if("page"===c){for(y=d.getAnnotations(t,i+1);f;){g=f.lineIndex;var x=f.nextSibling;g>=t&&i>=g&&!f.lineChanged||l.removeChild(f),f=x}for(f=l.firstChild.nextSibling,v=o.createDocumentFragment(),g=t;i>=g;g++)!f||f.lineIndex>g?(m=s.createElement(o,"div"),_=y[g],_&&(h(_.style,m),_.html&&(m.innerHTML=_.html),m.annotation=_),m.lineIndex=g,m.style.height=this._getLineHeight(g)+"px",v.appendChild(m)):(v.firstChild&&(l.insertBefore(v,f),v=o.createDocumentFragment()),f&&(f=f.nextSibling));v.firstChild&&l.insertBefore(v,f)}else{var b,w,C=this._getClientHeight(),T=this._model.getLineCount(),L=r*T,k=C+a.top+a.bottom-2*this._metrics.scrollWidth;if(k>L?(b=r,w=a.top):(b=k/T,w=this._metrics.scrollWidth),l.rulerChanged){for(var D=l.childNodes.length;D>1;)l.removeChild(l.lastChild),D--;y=d.getAnnotations(0,T),v=o.createDocumentFragment();for(var A in y)g=A>>>0,0>g||(m=s.createElement(o,"div"),_=y[A],h(_.style,m),m.style.position="absolute",m.style.top=w+r+Math.floor(g*b)+"px",_.html&&(m.innerHTML=_.html),m.annotation=_,m.lineIndex=g,v.appendChild(m));l.appendChild(v)}else if(l._oldTrackHeight!==k)for(m=l.firstChild?l.firstChild.nextSibling:null;m;)m.style.top=this._metrics.scrollWidth+r+Math.floor(m.lineIndex*b)+"px",m=m.nextSibling;l._oldTrackHeight=k}l.rulerChanged=!1,l=l.nextSibling}else l.rulerChanged=!1,l=l.nextSibling}},_updateStyleSheet:function(){var e="";if(s.isWebkit&&this._metrics.scrollWidth>0&&(e+="\n.textview ::-webkit-scrollbar-corner {background: #eeeeee;}"),e){var t=this._clientDiv.ownerDocument,i=t.getElementById("_textviewStyle");if(i)i.removeChild(i.firstChild),i.appendChild(t.createTextNode(e));else{i=s.createElement(t,"style"),i.id="_textviewStyle";var n=t.getElementsByTagName("head")[0]||t.documentElement;i.appendChild(t.createTextNode(e)),n.insertBefore(i,n.firstChild)}}},_updateStyle:function(e,t){if(!e&&s.isIE&&(this._rootDiv.style.lineHeight="normal"),t=this._metrics=t||this._calculateMetrics(),this._variableLineHeight&&(this._variableLineHeight=!1,this._resetLineHeight()),this._rootDiv.style.lineHeight=s.isIE?t.lineHeight-(t.lineTrim.top+t.lineTrim.bottom)+"px":"normal",this._updateStyleSheet(),s.isMac&&s.isWebkit){var i=this._viewDiv;t.invalid||0!==t.scrollWidth?(i.style.pointerEvents="",i.style.zIndex=""):(i.style.pointerEvents="none",i.style.zIndex="2")}e||(this.redraw(),this._resetLineWidth())}},n.EventTarget.addMixin(T.prototype),{TextView:T}}),define("orion/editor/projectionTextModel",["orion/editor/textModel","orion/editor/eventTarget"],function(e,t){function i(e){this._model=e,this._projections=[];var t=this;this._listener={onChanged:function(e){t._onChanged(e)},onChanging:function(e){t._onChanging(e)}},e.addEventListener("postChanged",this._listener.onChanged),e.addEventListener("preChanging",this._listener.onChanging)}return i.prototype={destroy:function(){this._model&&(this._model.removeEventListener("postChanged",this._listener.onChanged),this._model.removeEventListener("preChanging",this._listener.onChanging),this._model=null)},addProjection:function(t){if(t){var i=this._model,n=this._projections;t._lineIndex=i.getLineAtOffset(t.start),t._lineCount=i.getLineAtOffset(t.end)-t._lineIndex;var o=t.text;o||(o=""),t._model="string"==typeof o?new e.TextModel(o,i.getLineDelimiter()):o;var r=this.mapOffset(t.start,!0),s=t.end-t.start,a=t._lineCount,l=t._model.getCharCount(),d=t._model.getLineCount()-1,c={type:"Changing",text:t._model.getText(),start:r,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:d};this.onChanging(c);var h=this._binarySearch(n,t.start);n.splice(h,0,t);var u={type:"Changed",start:r,removedCharCount:s,addedCharCount:l,removedLineCount:a,addedLineCount:d};this.onChanged(u)}},getProjections:function(){return this._projections.slice(0)},getBaseModel:function(){return this._model},mapOffset:function(e,t){var i,n,o=this._projections,r=0;if(t){for(i=0;ie));i++){if(n.end>e)return-1;r+=n._model.getCharCount()-(n.end-n.start)}return e+r}for(i=0;ie-r));i++){var s=n._model.getCharCount();if(n.start+s>e-r)return-1;r+=s-(n.end-n.start)}return e-r},removeProjection:function(e){this._removeProjection(e)},_removeProjection:function(e,t){var i,n=0;for(i=0;i1;)i=Math.floor((n+o)/2),t<=e[i].start?n=i:o=i;return n},getCharCount:function(){for(var e=this._model.getCharCount(),t=this._projections,i=0;ie)return null;var i,n,o,r=this._model,s=this._projections,a=0,l=[],d=0;for(i=0;i=e-a));i++){if(n=o._model.getLineCount()-1,o._lineIndex+n>=e-a){var c=e-(o._lineIndex+a);if(n>c)return o._model.getLine(c,t);l.push(o._model.getLine(n))}d=o.end,a+=n-o._lineCount}for(d=Math.max(d,r.getLineStart(e-a));ie-a));i++){if(l.push(r.getText(d,o.start)),n=o._model.getLineCount()-1,o._lineIndex+n>e-a)return l.push(o._model.getLine(0,t)),l.join("");l.push(o._model.getText()),d=o.end,a+=n-o._lineCount}var h=r.getLineEnd(e-a,t);return h>d&&l.push(r.getText(d,h)),l.join("")},getLineAtOffset:function(e){for(var t=this._model,i=this._projections,n=0,o=0,r=0;re-n)break;var a=s._model.getCharCount();if(s.start+a>e-n){var l=e-(s.start+n);o+=s._model.getLineAtOffset(l),n+=l;break}o+=s._model.getLineCount()-1-s._lineCount,n+=a-(s.end-s.start)}return t.getLineAtOffset(e-n)+o},getLineCount:function(){for(var e=this._model,t=this._projections,i=e.getLineCount(),n=0;ne)return-1;for(var i=this._model,n=this._projections,o=0,r=0,s=0;se-o)break;var l=a._model.getLineCount()-1;if(a._lineIndex+l>e-o){var d=e-(a._lineIndex+o);return a._model.getLineEnd(d,t)+a.start+r}r+=a._model.getCharCount()-(a.end-a.start),o+=l-a._lineCount}return i.getLineEnd(e-o,t)+r},getLineStart:function(e){if(0>e)return-1;for(var t=this._model,i=this._projections,n=0,o=0,r=0;r=e-n)break;var a=s._model.getLineCount()-1;if(s._lineIndex+a>=e-n){var l=e-(s._lineIndex+n);return s._model.getLineStart(l)+s.start+o}o+=s._model.getCharCount()-(s.end-s.start),n+=a-s._lineCount}return t.getLineStart(e-n)+o},getText:function(e,t){void 0===e&&(e=0);var i,n,o,r=this._model,s=this._projections,a=0,l=[];for(i=0;ie-a));i++){if(o=n._model.getCharCount(),n.start+o>e-a){if(void 0!==t&&n.start+o>t-a)return n._model.getText(e-(n.start+a),t-(n.start+a));l.push(n._model.getText(e-(n.start+a))),e=n.end+a+o-(n.end-n.start)}a+=o-(n.end-n.start)}var d=e-a;if(void 0!==t){for(;it-a));i++){if(l.push(r.getText(d,n.start)),o=n._model.getCharCount(),n.start+o>t-a)return l.push(n._model.getText(0,t-(n.start+a))),l.join("");l.push(n._model.getText()),d=n.end,a+=o-(n.end-n.start)}l.push(r.getText(d,t-a))}else{for(;in));e++);var s=e;for(e=0;e=o));e++);var a=e,l=this._model,d=i.baseText.length-(o-n);for(e=a;ee));a++){if(l.end>e)return-1;s+=l._model.getCharCount()-(l.end-l.start)}return e+s}var i=!!this._change,n=this._change||{},o=e.start,r=o+e.removedCharCount;if(n.baseStart=o,n.baseEnd=r,n.baseText=e.text,n.addedLineCount=e.addedLineCount,!i){this._change=n,n.text=e.text;var s,a,l,d=this._projections;n.start=t(o),-1===n.start&&(n.text=this._model.getText(l.start,o)+n.text,n.addedLineCount+=this._model.getLineAtOffset(o)-this._model.getLineAtOffset(l.start),n.start=l.start+s),n.end=t(r),-1===n.end&&(n.text+=this._model.getText(r,l.end),n.addedLineCount+=this._model.getLineAtOffset(l.end)-this._model.getLineAtOffset(r),n.end=l.start+s)}n.addedCharCount=n.text.length,n.removedCharCount=n.end-n.start,n.removedLineCount=this.getLineAtOffset(n.end)-this.getLineAtOffset(n.start);var c={type:"Changing",text:n.text,start:n.start,removedCharCount:n.removedCharCount,addedCharCount:n.addedCharCount,removedLineCount:n.removedLineCount,addedLineCount:n.addedLineCount};this.onChanging(c)},onChanging:function(e){return this.dispatchEvent(e)},onChanged:function(e){return this.dispatchEvent(e)},setLineDelimiter:function(e){this._model.setLineDelimiter(e)},setText:function(e,t,i){function n(e){for(r=0,o=0;re-o));r++){var t=s._model.getCharCount();if(s.start+t>e-o)return-1;o+=t-(s.end-s.start)}return e-o}this._change={text:e||"",start:t||0,end:void 0===i?this.getCharCount():i};var o,r,s,a,l,d=this._projections,c=n(this._change.start);-1===c&&(a={projection:s,start:this._change.start-(s.start+o)},c=s.end);var h=n(this._change.end);-1===h&&(l={projection:s,end:this._change.end-(s.start+o)},h=s.start),a&&l&&a.projection===l.projection?s._model.setText(this._change.text,a.start,l.end):(this._model.setText(this._change.text,c,h),a&&(s=a.projection,s._model.setText("",a.start)),l&&(s=l.projection,s._model.setText("",0,l.end),s.start=s.end,s._lineCount=0)),this._change=void 0}},t.EventTarget.addMixin(i.prototype),{ProjectionTextModel:i}}),define("orion/editor/tooltip",["i18n!orion/editor/nls/messages","orion/editor/textView","orion/editor/projectionTextModel","orion/Deferred","orion/editor/util","orion/webui/littlelib","orion/util"],function(e,t,i,n,o,r,s){function a(e,t){this._view=e,this._editor=t;var i=e.getOptions("parent");this._create(i?i.ownerDocument:document)}return a.getTooltip=function(e,t){return e._tooltip||(e._tooltip=new a(e,t)),e._tooltip},a.prototype={_create:function(e){if(!this._tooltipDiv){var t=this._tooltipDiv=s.createElement(e,"div");t.tabIndex=0,t.className="textviewTooltip",t.setAttribute("aria-live","assertive"),t.setAttribute("aria-atomic","true"),this._tooltipDiv.style.visibility="hidden",this._tipShowing=!1,e.body.appendChild(t);var i=this;o.addEventListener(e,"mousedown",this._mouseDownHandler=function(e){i.isVisible()&&(o.contains(t,e.target||e.srcElement)||i._locked||i.hide())},!0),o.addEventListener(e,"scroll",this._scrollHandler=function(e){i.isVisible()&&(o.contains(t,e.target||e.srcElement)||(i._topPixel!==i._view.getTopPixel()||i._leftPixel!==i._view.getHorizontalPixel())&&i.hide())},!0),o.addEventListener(e,"mousemove",this._mouseMoveHandler=function(e){i._prevX&&i._prevX===e.clientX&&i._prevY&&i._prevY===e.clientY||(i._prevX=e.clientX,i._prevY=e.clientY,!i.isVisible()||i._locked||i._hasFocus()||i._isInRect(i._outerArea,e.clientX,e.clientY)||i.hide())},!0),o.addEventListener(t,"focus",function(){i._locked||i._tooltipDiv.classList.add("textViewTooltipOnFocus")},!1),o.addEventListener(t,"blur",function(){i._tooltipDiv.classList.remove("textViewTooltipOnFocus")},!1),o.addEventListener(t,"mouseenter",function(){i._locked||i._tooltipDiv.classList.add("textViewTooltipOnHover")},!1),o.addEventListener(t,"mouseleave",function(){i._hasFocus()||i._tooltipDiv.classList.remove("textViewTooltipOnHover")},!1),o.addEventListener(t,"keydown",function(e){27===e.keyCode&&(i._locked||i.hide())},!1),this._view.addEventListener("Destroy",function(){i.destroy()})}},destroy:function(){if(this._tooltipDiv){this.hide();var e=this._tooltipDiv.parentNode;e&&e.removeChild(this._tooltipDiv);var t=this._tooltipDiv.ownerDocument;o.removeEventListener(t,"mousedown",this._mouseDownHandler,!0),o.removeEventListener(t,"scroll",this._scrollHandler,!0),o.removeEventListener(t,"mousemove",this._mouseMoveHandler,!0),this._tooltipDiv=null}},show:function(e,t,i){this._locked=t,this._giveFocus=i,this._topPixel=this._view.getTopPixel(),this._leftPixel=this._view.getHorizontalPixel(),this._processInfo(e.getTooltipInfo())},update:function(e,t){e&&(t?this._showContents(null,e.getTooltipInfo(),!0):this._processInfo(e.getTooltipInfo(),!0))},onHover:function(e,t,i){e&&(this._isInRect(this._anchorArea,t,i)||this._isInRect(this._tooltipArea,t,i)||this._locked||this._hasFocus()||this._processInfo(e.getTooltipInfo()))},hide:function(e){e&&(this._locked=void 0),!this._locked&&this.isVisible()&&(this.hover&&this.hover.clearQuickFixes(),this._hasFocus()&&this._view.focus(),this._tooltipContents&&(this._tooltipDiv.removeChild(this._tooltipContents),this._tooltipContents=null),this._tooltipDiv.classList.remove("textviewTooltipCodeProjection"),this._tooltipDiv.classList.remove("textviewTooltipOnHover"),this._tooltipDiv.classList.remove("textviewTooltipOnFocus"),this._tooltipDiv.style.visibility="hidden",this._tipShowing=!1,this._tooltipDiv.style.left="",this._tooltipDiv.style.right="",this._tooltipDiv.style.top="",this._tooltipDiv.style.bottom="",this._tooltipDiv.style.width="auto",this._tooltipDiv.style.maxWidth="",this._tooltipDiv.style.height="auto",this._tooltipDiv.style.maxHeight="",this._tooltipDiv.style.overflowX="",this._tooltipDiv.style.overflowY="",this._giveFocus=void 0,this._anchorArea=void 0,this._tooltipArea=void 0,this._outerArea=void 0,this._hoverPromises&&this._hoverPromises.forEach(function(e){e.resolved||e.cancel()}),this._hoverPromises=void 0,this._tipRect=void 0)},isVisible:function(){return this._tipShowing},_processInfo:function(e,t){if(this._tooltipDiv){var i;if(t&&this._tooltipContents?(this._tooltipContents.innerHTML="",i=this._tooltipContents):i=s.createElement(this._tooltipDiv.ownerDocument,"div"),e){if(e.contents&&this._renderImmediateInfo(i,e.contents,e.context))return this._showContents(i,e,t),!0;if(this.hover&&e.context&&(this._hoverPromises=this.hover.computeHoverInfo(e.context),this._hoverPromises)){var o=this,r=this._hoverPromises.slice(0);return r.forEach(function(r){n.when(r,function(n){if(o._hoverPromises){var s=o._hoverPromises.indexOf(r);s>=0&&o._hoverPromises.splice(s,1)}n&&o._renderPluginContent(i,n)&&(n.offsetStart&&(e.context.offsetStart=n.offsetStart),n.offsetEnd&&(e.context.offsetEnd=n.offsetEnd),n.allowFullWidth&&(e.allowFullWidth=n.allowFullWidth),o._showContents(i,e,t))},function(e){console&&e&&"Cancel"!==e.name&&(console.log("Error computing hover tooltip"),console.log(e&&e.stack))})}),!0}}}},_showContents:function(e,t,i){i?this._tooltipArea&&t.tooltipArea&&(this._tooltipArea.left!==t.tooltipArea.left||this._tooltipArea.top!==t.tooltipArea.top||this._tooltipArea.width!==t.tooltipArea.width||this._tooltipArea.height!==t.tooltipArea.height)&&(this._anchorArea=null,this._tooltipArea=null,this._outerArea=null):this.hide(),e&&(this._tooltipContents&&this._tooltipDiv.removeChild(this._tooltipContents),this._tooltipContents=e,this._tooltipDiv.appendChild(e)),this._anchorArea||(this._anchorArea=this._computeAnchorArea(t)),this._tooltipArea||(this._tooltipArea=this._computeTooltipArea(t,this._anchorArea,this._tooltipDiv)),this._outerArea||(this._outerArea=this._computeOuterArea(this._anchorArea,this._tooltipArea)),this._tooltipDiv.style.visibility="visible",this._tipShowing=!0,this._giveFocus&&(this._setInitialFocus(this._tooltipDiv),this._giveFocus=void 0)},_computeAnchorArea:function(e){if(e.anchorArea&&e.anchorArea.top&&e.anchorArea.left&&e.anchorArea.height&&e.anchorArea.width)return e.anchorArea;if(e.context){if(e.context.offsetStart&&e.context.offsetEnd){var t=this.mapOffset(e.context.offsetStart,!1),i=this.mapOffset(e.context.offsetEnd,!1);return this._computeRectangleFromOffset(t,i)}if(e.context.offset>=0){var n=this.mapOffset(e.context.offset,!1),o=this._view.getNextOffset(n,{unit:"wordend",count:0}),r=this._view.getNextOffset(o,{unit:"word",count:-1});return this._computeRectangleFromOffset(r,o)}}return{top:0,left:0,height:0,width:0}},_computeTooltipArea:function(e,t,i){var n=i.ownerDocument.documentElement,o=16;if(e.tooltipArea&&e.tooltipArea.top&&e.tooltipArea.left&&e.tooltipArea.height&&e.tooltipArea.width)return i.style.overflowY="auto",i.style.resize="none",i.style.top=e.tooltipArea.top+"px",i.style.left=e.tooltipArea.left+"px",i.style.height=e.tooltipArea.height-o+"px",i.style.width=e.tooltipArea.width-o+"px",e.tooltipArea;var r=i.getBoundingClientRect(),s={width:r.width,height:r.height},a=i.getElementsByTagName("img")[0];a&&!a.complete&&0===a.width&&(s.width+=30);var l=e.position?e.position:"below",d=(this._view._rootDiv?this._view._rootDiv:n).getBoundingClientRect(),c=d.left,h=d.top,u=d.width,p=d.height,f=u,g=p;e.allowFullWidth?s.width>u&&(s.width=u):(f=Math.min(u/2,600),g=Math.min(p/2,400),s.width=Math.min(s.width,f),s.height=Math.min(s.height,g)),i.style.width=s.width-o+"px",s.height=Math.min(i.getBoundingClientRect().height,g),25+o>s.height&&s.width>f-o&&(s.height=40+o);var _=p-(t.top+t.height-h),m=t.top-h,v=u-(t.left+t.width-c);"above"===l&&s.height>m&&s.height<=_?l="below":"below"===l&&s.height>_&&s.height<=m&&(l="above");var y=e.tooltipOffsetX?e.tooltipOffsetX:0,x=e.tooltipOffsetY?e.tooltipOffsetY:0;switch(l){case"left":s.top=s.height+x>_+t.height?p+h-s.height:t.top+x,s.top=Math.max(s.top,h),s.left=Math.max(t.left-s.width+y,c);break;case"right":s.top=s.height+x>_+t.height?p+h-s.height:t.top+x,s.top=Math.max(s.top,h),s.left=Math.max(t.left+t.width+y,c);break;case"above":s.left=s.width+y>v+t.width?u+c-s.width:t.left+y,s.left=Math.max(s.left,c),s.top=Math.max(t.top-s.height+x,h);break;case"below":s.left=s.width+y>v+t.width?u+c-s.width:t.left+y,s.left=Math.max(s.left,c),s.top=Math.max(t.top+t.height+x,h)}return s.maxWidth=Math.min(u+c-s.left,u),s.maxHeight=Math.min(p+h-s.top,p),i.style.maxWidth=s.maxWidth-o+"px",i.style.maxHeight=s.maxHeight-o+"px",i.style.width=s.width-o+"px",i.style.height=s.height-o+"px",i.style.left=s.left+"px",i.style.top=s.top+"px",s},_computeOuterArea:function(e,t){var i=Math.min(e.left,t.left),n=Math.min(e.top,t.top),o=e.left+e.width,r=t.left+t.width,s=Math.max(o,r),a=e.top+e.height,l=t.top+t.height,d=Math.max(a,l);return{left:i,top:n,width:s-i,height:d-n}},_hasFocus:function(){var e=this._tooltipDiv;return e?o.contains(e,e.ownerDocument.activeElement):!1},_isNode:function(e){return"object"==typeof Node?e instanceof Node:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},_setInitialFocus:function(e){var t=r.$("button",e);if(t)return void t.focus();var i=r.$("a",e);if(i){i.focus();var n=this;return void i.addEventListener("click",function(){n.hide()})}var o=r.firstTabbable(e);o&&o.focus()},_isInRect:function(e,t,i){if(!e)return!1;var n=t>=e.left&&t<=e.left+e.width,o=i>=e.top&&i<=e.top+e.height;return n&&o},mapOffset:function(e){var t=this._view,i=t.getModel();return i.getBaseModel&&(e=i.mapOffset(e,!0)),e},_computeRectangleFromOffset:function(e,t){var i,n,o=this._view,r=o.getLineAtOffset(e),s=o.getLineAtOffset(t);if(r!==s){var a=o.getLocationAtOffset(e).y;i=0;for(var l=0;s>=r;){i+=o.getLineHeight(r);var d=o.getModel().getLineEnd(r),c=o.getLocationAtOffset(d).x;c>t&&(l=c),r++}var h=o.getModel().getLineStart(s),u=o.getLocationAtOffset(h).x;n={x:u,y:a,width:l-u,height:i}}else{var p=o.getLocationAtOffset(e),f=o.getLocationAtOffset(t);i=o.getLineHeight(r),n={x:p.x,y:p.y,width:f.x-p.x,height:i}}return n=this._view.convert(n,"document","page"),{left:n.x,top:n.y,width:n.width,height:n.height}},_renderPluginContent:function(e,t){var i=this._tooltipDiv.ownerDocument;if("string"!=typeof t&&"undefined"==typeof t.content)return!1;var n=s.createElement(i,"div");if(t.title){var o=s.createElement(i,"div");this.hover.renderMarkDown?o.innerHTML=this.hover.renderMarkDown(t.title):o.textContent=t.title,o.classList.add("hoverTooltipTitle"),n.appendChild(o)}var r=s.createElement(i,"div");if("string"==typeof t)r.appendChild(i.createTextNode(t));else switch(t.type){case"delegatedUI":case"html":if(t.content){var a=i.createElement("iframe");a.id="HtmlHover",a.name="HTML Hover",a.type="text/html",a.sandbox="allow-scripts allow-same-origin allow-forms",a.style.border="none",a.style.width="100%",a.style.height="100%",this._tooltipDiv.style.paddingBottom="5px",a.srcdoc=t.content,t.width&&(a.style.width=t.width),t.height&&(a.style.height=t.height),n.style.height="100%",e.style.height="100%",n.appendChild(a)}break;case"markdown":this.hover.renderMarkDown&&(r.innerHTML=this.hover.renderMarkDown(t.content));break;default:r.appendChild(i.createTextNode(t.content))}return n.appendChild(r),e.appendChild(n),!0},_renderImmediateInfo:function(e,n,o){if(n instanceof Array&&(n=this._getAnnotationContents(n,o),!n))return!1;if("string"==typeof n)return e.textContent=n,!0;if(this._isNode(n))return e.appendChild(n),!0;if(n instanceof i.ProjectionTextModel){var r=this._view,s=r.getOptions();s.wrapMode=!1,s.parent=e;var a="tooltipTheme",l=s.themeClass;l?(l=l.replace(a,""),l&&(l=" "+l),l=a+l):l=a,s.themeClass=l;var d=this._contentsView=new t.TextView(s),c={onLineStyle:function(e){r.onLineStyle(e)}};d.addEventListener("LineStyle",c.onLineStyle),d.setModel(n),this._tooltipDiv.appendChild(e),this._tooltipDiv.classList.add("textviewTooltipCodeProjection");var h=d.computeSize();return e.style.width=h.width+8+"px",e.style.height=h.height+8+"px",d.resize(),this._tooltipDiv.removeChild(e),!0}return!1},_getAnnotationContents:function(t,n){function r(e,t,i){var r=e.title,l=s.createElement(p,"div");if(l.className="tooltipRow",e.html){var d=s.createElement(p,"div");d.className="tooltipImage",d.innerHTML=e.html,d.lastChild&&o.addEventListener(d.lastChild,"click",function(){var t=e.start,i=e.end;g.getBaseModel&&(t=g.mapOffset(t,!0),i=g.mapOffset(i,!0)),f.setSelection(t,i,1/3,function(){a.hide()})},!1),l.appendChild(d)}if(!r){var c=_.getLineStart(_.getLineAtOffset(e.start)),h=_.getLineEnd(_.getLineAtOffset(e.end),!0);r=_.getText(c,h)}if("function"==typeof r&&(r=e.title()),"string"==typeof r){var u=s.createElement(p,"span");u.className="tooltipTitle",u.appendChild(p.createTextNode(r)),r=u}return l.appendChild(r),i&&a.hover.renderQuickFixes(e,t,l),n&&(n.offsetStart=e.start,n.offsetEnd=e.end),l}var a=this,l=a.hover?!0:!1;l&&n&&n.source&&n.source.indexOf("ruler")>=0&&t.length>1&&(l=!1);for(var d,c=[],h=0;h0&&m.addProjection({start:0,end:v}),m}var x;if(t.length>0&&this._editor&&(x=this._editor.getAnnotationModel().getAnnotations()),1===t.length){if(u=r(t[0],x,l),u&&u.firstChild){var b=u.firstChild.className;b&&(b+=" "),b+="single",u.firstChild.className=b}return u}var w=s.createElement(p,"div"),C=s.createElement(p,"multi_anno");C.appendChild(p.createTextNode(e.multipleAnnotations)),w.appendChild(C);for(var T=0;Ti;i++){var o=arguments[i];for(var r in o)t.call(o,r)&&(e[r]=o[r])}return e}return{clone:function(t){if(Array.isArray(t))return Array.prototype.slice.call(t);var i=Object.create(Object.getPrototypeOf(t));return e(i,t),i},mixin:e,toArray:function(e){return Array.isArray(e)?e:[e]}}}),define("orion/editor/editor",["i18n!orion/editor/nls/messages","orion/editor/eventTarget","orion/editor/tooltip","orion/editor/annotations","orion/objects","orion/util"],function(e,t,i,n,o,r){function s(e){e=e||{},this._domNode=e.domNode,this._model=e.model,this._undoStack=e.undoStack,this._statusReporter=e.statusReporter,this._title=null;var t=this;this._listener={onChanged:function(e){t.onChanged(e)}},this._model&&this._model.addEventListener("Changed",this._listener.onChanged),this.checkDirty()}function a(e){e=e||{},s.call(this,e),this._textViewFactory=e.textViewFactory,this._undoStackFactory=e.undoStackFactory,this._textDNDFactory=e.textDNDFactory,this._annotationFactory=e.annotationFactory,this._zoomRulerFactory=e.zoomRulerFactory,this._foldingRulerFactory=e.foldingRulerFactory,this._lineNumberRulerFactory=e.lineNumberRulerFactory,this._contentAssistFactory=e.contentAssistFactory,this._keyBindingFactory=e.keyBindingFactory,this._hoverFactory=e.hoverFactory,this._syntaxHighlighter=e.syntaxHighlighter,this._annotationStyler=null,this._annotationModel=null,this._annotationRuler=null,this._lineNumberRuler=null,this._overviewRuler=null,this._zoomRuler=null,this._foldingRuler=null,this._contentAssist=null
    +}var l=n.AnnotationType,d="orion.annotation.highlightError";return s.prototype={destroy:function(){this.uninstall(),this._statusReporter=this._domNode=null,this._model&&this._model.removeEventListener("Changed",this._listener.onChanged)},checkDirty:function(){this.setDirty(this._undoStack&&!this._undoStack.isClean())},focus:function(){},getModel:function(){return this._model},getText:function(e,t){return this.getModel().getText(e,t)},getTitle:function(){return this._title},getUndoStack:function(){return this._undoStack},install:function(){this.installed=!0},isDirty:function(){return this._undoStack?!this._undoStack.isClean():this._dirty},markClean:function(){this.getUndoStack().markClean(),this.setDirty(!1)},onDirtyChanged:function(e){return this.dispatchEvent(e)},onInputChanged:function(e){return this.dispatchEvent(e)},onChanged:function(){this.checkDirty()},reportStatus:function(e,t,i){this._statusReporter&&this._statusReporter(e,t,i)},resize:function(){},setDirty:function(e){this._dirty!==e&&(this._dirty=e,this.onDirtyChanged({type:"DirtyChanged"}))},_setModelText:function(e){this._model&&this._model.setText(e)},setInput:function(e,t,i,n){this._title=e,n||(t?this.reportStatus(t,"error"):null!==i&&void 0!==i&&("string"==typeof i&&this._setModelText(i),this._undoStack&&this._undoStack.reset())),this.checkDirty(),this.onInputChanged({type:"InputChanged",title:e,message:t,contents:i,contentsSaved:n})},setText:function(e,t,i){this.getModel().setText(e,t,i)},uninstall:function(){this.installed=!1}},t.EventTarget.addMixin(s.prototype),a.prototype=new s,o.mixin(a.prototype,{destroy:function(){s.prototype.destroy.call(this),this._textViewFactory=this._undoStackFactory=this._textDNDFactory=this._annotationFactory=this._foldingRulerFactory=this._lineNumberRulerFactory=this._contentAssistFactory=this._keyBindingFactory=this._hoverFactory=this._zoomRulerFactory=null},getAnnotationModel:function(){return this._annotationModel},getAnnotationRuler:function(){return this._annotationRuler},getAnnotationRulerVisible:function(){return this._annotationRulerVisible},getAnnotationStyler:function(){return this._annotationStyler},getContentAssist:function(){return this._contentAssist},getFoldingRuler:function(){return this._foldingRuler},getFoldingRulerVisible:function(){return this._foldingRulerVisible},getLineNumberRuler:function(){return this._lineNumberRuler},getLineNumberRulerVisible:function(){return this._lineNumberRulerVisible},getTooltip:function(){return i.Tooltip.getTooltip(this._textView,this)},getZoomRuler:function(){return this._zoomRuler},getZoomRulerVisible:function(){return this._zoomRulerVisible},getModel:function(){if(!this._textView)return null;var e=this._textView.getModel();return e.getBaseModel&&(e=e.getBaseModel()),e},getOverviewRuler:function(){return this._overviewRuler},getTextView:function(){return this._textView},getKeyModes:function(){return this._textView.getKeyModes()},getSourceCodeActions:function(){return this._sourceCodeActions},getLinkedMode:function(){return this._linkedMode},getTextActions:function(){return this._textActions},focus:function(){this._textView&&this._textView.focus()},resize:function(){this._textView&&this._textView.resize()},setAnnotationRulerVisible:function(e,t){if((this._annotationRulerVisible!==e||t)&&(this._annotationRulerVisible=e,this._annotationRuler)){var i=this._textView;e?i.addRuler(this._annotationRuler,0):i.removeRuler(this._annotationRuler)}},setFoldingRulerVisible:function(e,t){if(this._foldingRulerVisible!==e||t){if(!e){var i=this.getTextActions();i&&i.expandAnnotations(!0)}if(this._foldingRulerVisible=e,this._foldingRuler){var n=this._textView;n.getModel().getBaseModel&&(e?n.addRuler(this._foldingRuler):n.removeRuler(this._foldingRuler))}}},setLineNumberRulerVisible:function(e,t){if((this._lineNumberRulerVisible!==e||t)&&(this._lineNumberRulerVisible=e,this._lineNumberRuler)){var i=this._textView;e?i.addRuler(this._lineNumberRuler,this._annotationRulerVisible?1:0):i.removeRuler(this._lineNumberRuler)}},setOverviewRulerVisible:function(e,t){if((this._overviewRulerVisible!==e||t)&&(this._overviewRulerVisible=e,this._overviewRuler)){var i=this._textView;e?i.addRuler(this._overviewRuler):i.removeRuler(this._overviewRuler)}},setZoomRulerVisible:function(e,t){if((this._zoomRulerVisible!==e||t)&&(this._zoomRulerVisible=e,this._zoomRuler)){var i=this._textView;e?i.addRuler(this._zoomRuler):i.removeRuler(this._zoomRuler)}},mapOffset:function(e,t){var i=this._textView,n=i.getModel();return n.getBaseModel&&(e=n.mapOffset(e,t)),e},getLineAtOffset:function(e){return this.getModel().getLineAtOffset(this.mapOffset(e))},getLineStart:function(e){return this.getModel().getLineStart(e)},getCaretOffset:function(){return this.mapOffset(this._textView.getCaretOffset())},getSelectionText:function(e){var t=this._textView;return t.getSelectionText(e)},getSelection:function(){var e=this._textView,t=e.getSelection(),i=e.getModel();return i.getBaseModel&&(t.start=i.mapOffset(t.start),t.end=i.mapOffset(t.end)),t},getSelections:function(){var e=this._textView,t=e.getModel(),i=e.getSelections();return i.forEach(function(e){t.getBaseModel&&(e.start=t.mapOffset(e.start),e.end=t.mapOffset(e.end))}),i},getStyleAccessor:function(){var e=null;if(this._syntaxHighlighter){var t=this._syntaxHighlighter.getStyler();t&&t.getStyleAccessor&&(e=t.getStyleAccessor())}return e},_expandOffset:function(e){var t=this._textView.getModel(),i=this._annotationModel;if(i&&t.getBaseModel)for(var n=i.getAnnotations(e,e+1);n.hasNext();){var o=n.next();o.type===l.ANNOTATION_FOLDING&&o.expand&&o.expand()}},setCaretOffset:function(e,t,i){var n=this._textView,o=n.getModel();o.getBaseModel&&(this._expandOffset(e),e=o.mapOffset(e,!0)),n.setCaretOffset(e,t,i)},setText:function(e,t,i,n,o){var r=this._textView,s=r.getModel();s.getBaseModel&&(void 0!==t&&(this._expandOffset(t),t=s.mapOffset(t,!0)),void 0!==i&&(this._expandOffset(i),i=s.mapOffset(i,!0))),r.setText(e,t,i,n,o)},setSelection:function(e,t,i,n){var o=this._textView,r=o.getModel();r.getBaseModel&&(this._expandOffset(e),this._expandOffset(t),e=r.mapOffset(e,!0),t=r.mapOffset(t,!0)),o.setSelection(e,t,i,n)},setSelections:function(e,t,i){var n=this,o=this._textView,r=o.getModel();e.forEach(function(e){var t=e.start,i=e.end;r.getBaseModel&&(n._expandOffset(t),n._expandOffset(i),t=r.mapOffset(t,!0),i=r.mapOffset(i,!0)),e.start=t,e.end=i}),o.setSelections(e,t,i)},moveSelection:function(e,t,i,n){t=t||e;var o=this._textView;this.setSelection(e,t,1/3,function(){(void 0===n||n)&&o.focus(),i&&i()})},_getTooltipInfo:function(e,t){var i=this._textView,n=this.getAnnotationModel();if(!n)return null;var o=this._annotationStyler;if(!o)return null;if(!i.isValidTextPosition(e,t))return null;var r=i.getOffsetAtLocation(e,t);if(-1===r)return null;r=this.mapOffset(r);for(var s=o.getAnnotationsByType(n,r,r+1),a=[],l=0;l>0,f=s.getLineStart(p),g=s.getLineEnd(p);s.getBaseModel&&(f=s.mapOffset(f),g=s.mapOffset(g));var _=l.ANNOTATION_CURRENT_LINE,m=l.createAnnotation(_,f,g);h.push(m)}this._currentLineAnnotations=h,o.replaceAnnotations(c,h)}}}},installTextView:function(){this.install()},install:function(){if(!this._textView){if(this._textView=this._textViewFactory(),this._undoStackFactory&&(this._undoStack=this._undoStackFactory.createUndoStack(this),this._textView.setOptions({undoStack:this._undoStack}),this.checkDirty()),this._textDNDFactory&&(this._textDND=this._textDNDFactory.createTextDND(this,this._undoStack)),this._contentAssistFactory){var e=this._contentAssistFactory.createContentAssistMode(this);this._contentAssist=e.getContentAssist()}var t=i.Tooltip.getTooltip(this._textView,this);this._hoverFactory&&(this._hover=this._hoverFactory.createHover(this),t.hover=this._hover);var n=this,o=this._textView,r=this;if(this._listener={onModelChanged:function(){r.checkDirty()},onMouseOver:function(e){r._listener.onMouseMove(e)},onMouseDown:function(){r._listener.mouseDown=!0},onMouseUp:function(){r._listener.mouseDown=!1},onMouseMove:function(e){t&&!r._listener.mouseDown&&(e.event.clientX!==r._listener.lastMouseX||e.event.clientY!==r._listener.lastMouseY)&&(r._listener.lastMouseX=e.event.clientX,r._listener.lastMouseY=e.event.clientY,r._hoverTimeout&&(window.clearTimeout(r._hoverTimeout),r._hoverTimeout=null),r._hoverTimeout=window.setTimeout(function(){r._hoverTimeout=null,r._listener&&t.onHover({y:e.y,x:e.x,getTooltipInfo:function(){return r._getTooltipInfo(this.x,this.y)}},e.x,e.y)},175))},onMouseOut:function(){r._hoverTimeout&&(window.clearTimeout(r._hoverTimeout),r._hoverTimeout=null)},onSelection:function(e){t&&t.hide(),r._updateCursorStatus(),r._highlightCurrentLine(e.newValue,e.oldValue)}},o.addEventListener("ModelChanged",this._listener.onModelChanged),o.addEventListener("Selection",this._listener.onSelection),o.addEventListener("MouseOver",this._listener.onMouseOver),o.addEventListener("MouseOut",this._listener.onMouseOut),o.addEventListener("MouseDown",this._listener.onMouseDown),o.addEventListener("MouseUp",this._listener.onMouseUp),o.addEventListener("MouseMove",this._listener.onMouseMove),this._keyBindingFactory){var a;a="function"==typeof this._keyBindingFactory?this._keyBindingFactory(this,this.getKeyModes(),this._undoStack,this._contentAssist):this._keyBindingFactory.createKeyBindings(n,this._undoStack,this._contentAssist),a&&(this._textActions=a.textActions,this._linkedMode=a.linkedMode,this._sourceCodeActions=a.sourceCodeActions)}var c=function(e){if(void 0!==e&&-1!==e){for(var t=this.getView(),i=t.getModel(),o=this.getAnnotationModel(),r=n.mapOffset(i.getLineStart(e)),s=n.mapOffset(i.getLineEnd(e)),a=o.getAnnotations(r,s),d=null;a.hasNext();){var c=a.next();if(c.type===l.ANNOTATION_BOOKMARK){d=c;break}}d?o.removeAnnotation(d):(d=l.createAnnotation(l.ANNOTATION_BOOKMARK,r,s,n.getText(r,s)),o.addAnnotation(d))}};if(this._annotationFactory){var h=o.getModel();if(h.getBaseModel&&(h=h.getBaseModel()),this._annotationModel=this._annotationFactory.createAnnotationModel(h),this._annotationModel){var u=this._annotationStyler=this._annotationFactory.createAnnotationStyler(o,this._annotationModel);u&&(u.addAnnotationType(l.ANNOTATION_CURRENT_SEARCH),u.addAnnotationType(l.ANNOTATION_MATCHING_SEARCH),u.addAnnotationType(l.ANNOTATION_ERROR),u.addAnnotationType(l.ANNOTATION_WARNING),u.addAnnotationType(l.ANNOTATION_MATCHING_BRACKET),u.addAnnotationType(l.ANNOTATION_CURRENT_BRACKET),u.addAnnotationType(l.ANNOTATION_CURRENT_LINE),u.addAnnotationType(l.ANNOTATION_READ_OCCURRENCE),u.addAnnotationType(l.ANNOTATION_WRITE_OCCURRENCE),u.addAnnotationType(l.ANNOTATION_SELECTED_LINKED_GROUP),u.addAnnotationType(l.ANNOTATION_CURRENT_LINKED_GROUP),u.addAnnotationType(l.ANNOTATION_LINKED_GROUP),u.addAnnotationType(d))}var p=this._annotationFactory.createAnnotationRulers(this._annotationModel),f=this._annotationRuler=p.annotationRuler;f&&(f.onDblClick=c,f.setMultiAnnotationOverlay({html:"
    "}),f.addAnnotationType(l.ANNOTATION_ERROR),f.addAnnotationType(l.ANNOTATION_WARNING),f.addAnnotationType(l.ANNOTATION_TASK),f.addAnnotationType(l.ANNOTATION_BOOKMARK),f.addAnnotationType(l.ANNOTATION_DIFF_ADDED),f.addAnnotationType(l.ANNOTATION_DIFF_DELETED),f.addAnnotationType(l.ANNOTATION_DIFF_MODIFIED)),this.setAnnotationRulerVisible(this._annotationRulerVisible||void 0===this._annotationRulerVisible,!0),f=this._overviewRuler=p.overviewRuler,f&&(f.addAnnotationType(l.ANNOTATION_CURRENT_SEARCH),f.addAnnotationType(l.ANNOTATION_MATCHING_SEARCH),f.addAnnotationType(l.ANNOTATION_READ_OCCURRENCE),f.addAnnotationType(l.ANNOTATION_WRITE_OCCURRENCE),f.addAnnotationType(l.ANNOTATION_CURRENT_BLAME),f.addAnnotationType(l.ANNOTATION_ERROR),f.addAnnotationType(l.ANNOTATION_WARNING),f.addAnnotationType(l.ANNOTATION_TASK),f.addAnnotationType(l.ANNOTATION_BOOKMARK),f.addAnnotationType(l.ANNOTATION_MATCHING_BRACKET),f.addAnnotationType(l.ANNOTATION_CURRENT_BRACKET),f.addAnnotationType(l.ANNOTATION_CURRENT_LINE),f.addAnnotationType(l.ANNOTATION_DIFF_ADDED),f.addAnnotationType(l.ANNOTATION_DIFF_DELETED),f.addAnnotationType(l.ANNOTATION_DIFF_MODIFIED)),this.setOverviewRulerVisible(this._overviewRulerVisible||void 0===this._overviewRulerVisible,!0)}this._zoomRulerFactory&&(this._zoomRuler=this._zoomRulerFactory.createZoomRuler(this._annotationModel),this.setZoomRulerVisible(this._zoomRulerVisible,!0)),this._lineNumberRulerFactory&&(this._lineNumberRuler=this._lineNumberRulerFactory.createLineNumberRuler(this._annotationModel),this._lineNumberRuler.addAnnotationType(l.ANNOTATION_CURRENT_BLAME),this._lineNumberRuler.addAnnotationType(l.ANNOTATION_BLAME),this._lineNumberRuler.addAnnotationType(l.ANNOTATION_DIFF_ADDED),this._lineNumberRuler.addAnnotationType(l.ANNOTATION_DIFF_MODIFIED),this._lineNumberRuler.addAnnotationType(l.ANNOTATION_DIFF_DELETED),this._lineNumberRuler.onDblClick=c,this.setLineNumberRulerVisible(this._lineNumberRulerVisible||void 0===this._lineNumberRulerVisible,!0)),this._foldingRulerFactory&&(this._foldingRuler=this._foldingRulerFactory.createFoldingRuler(this._annotationModel),this._foldingRuler.addAnnotationType(l.ANNOTATION_FOLDING),this.setFoldingRulerVisible(this._foldingRulerVisible||void 0===this._foldingRulerVisible,!0));var g={type:"TextViewInstalled",textView:o};this.dispatchEvent(g),s.prototype.install.call(this)}},uninstallTextView:function(){this.uninstall()},uninstall:function(){var e=this._textView;if(e){e.destroy(),this._annotationModel&&this._annotationModel.setTextModel(null),this._textView=this._undoStack=this._textDND=this._contentAssist=this._listener=this._annotationModel=this._annotationStyler=this._annotationRuler=this._overviewRuler=this._zoomRuler=this._lineNumberRuler=this._foldingRuler=this._currentLineAnnotations=this._title=null,this._dirty=!1,this._foldingRulerVisible=this._overviewRulerVisible=this._zoomRulerVisible=this._lineNumberRulerVisible=this._annotationRulerVisible=void 0;var t={type:"TextViewUninstalled",textView:e};this.dispatchEvent(t),s.prototype.uninstall.call(this)}},_updateCursorStatus:function(){for(var t=this.getKeyModes(),i=0;i1)o=r.formatMessage(e.multiSelections,a.length);else{var l=a[0].getCaret(),d=s.getLineAtOffset(l),c=s.getLineStart(d),h=l-c;o=localStorage.languageTools?r.formatMessage(e.lineColumnOffset,d+1,h+1,l):r.formatMessage(e.lineColumn,d+1,h+1)}this.reportStatus(o)},showAnnotations:function(e,t,i,n){var o=this._annotationModel;if(o){for(var r,s=[],a=[],d=o.getTextModel(),c=o.getAnnotations();c.hasNext();)r=c.next(),-1!==t.indexOf(r.type)&&r.creatorID===this&&s.push(r);if(e)for(var h=0;h',s.blame=e,s})},showDiffAnnotations:function(e){this.showAnnotations(e,[l.ANNOTATION_DIFF_ADDED,l.ANNOTATION_DIFF_MODIFIED,l.ANNOTATION_DIFF_DELETED],null,function(e){return"added"===e.type?l.ANNOTATION_DIFF_ADDED:"modified"===e.type?l.ANNOTATION_DIFF_MODIFIED:l.ANNOTATION_DIFF_DELETED})},showSelection:function(e,t,i,n,o){if("number"==typeof e)return"number"!=typeof t&&(t=e),this.moveSelection(e,t),!0;if("number"==typeof i){var r=this.getModel(),s=r.getLineStart(i-1);return"number"==typeof n&&(s+=n),"number"!=typeof o&&(o=0),this.moveSelection(s,s+o),!0}return!1},_setModelText:function(e){this._textView&&(this._textView.setText(e),this._textView.getModel().setLineDelimiter("auto"),this._highlightCurrentLine(this._textView.getSelections()))},setInput:function(e,t,i,n,o){s.prototype.setInput.call(this,e,t,i,n),!this._textView||n||o||this._textView.focus()},onGotoLine:function(e,t,i,n){if(this._textView){var o=this.getModel();e=Math.max(0,Math.min(e,o.getLineCount()-1));var r=o.getLineStart(e),s=0;if(void 0===i&&(i=0),"string"==typeof t){var a=o.getLine(e).indexOf(t);-1!==a&&(s=a,i=s+t.length)}else{s=t;var l=o.getLineEnd(e)-r;s=Math.min(s,l),i=Math.min(i,l)}this.moveSelection(r+s,r+i,n)}}}),{BaseEditor:s,Editor:a}}),define("orion/editor/find",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/keyModes","orion/editor/annotations","orion/regex","orion/objects","orion/Deferred","orion/util"],function(e,t,i,n,o,r,s,a){function l(e){var t=e.getTextView();i.KeyMode.call(this,t),this.editor=e,this._active=!1,this._success=!0,this._ignoreSelection=!1,this._prefix="",t.setAction("incrementalFindCancel",function(){return this.setActive(!1),!0}.bind(this)),t.setAction("incrementalFindBackspace",function(){return this._backspace()}.bind(this));var n=this;this._listener={onVerify:function(e){var t=n.editor,i=t.getModel(),r=t.mapOffset(e.start),s=t.mapOffset(e.end),a=i.getText(r,s),l=n._prefix,d=l.match(new RegExp("^"+o.escape(a),"i"));d&&d.length>0&&(l=n._prefix+=e.text,n._success=!0,n._status(),n.find(n._forward,!0),e.text=null)},onSelection:function(){n._ignoreSelection||n.setActive(!1)}}}function d(e,t,i){if(e){this._editor=e,this._undoStack=t,this._showAll=!0,this._visible=!1,this._caseInsensitive=!0,this._wrap=!0,this._wholeWord=!1,this._incremental=!0,this._regex=!1,this._findAfterReplace=!0,this._hideAfterFind=!1,this._reverse=!1,this._start=void 0,this._end=void 0,this._timer=void 0,this._lastString="";var n=this;this._listeners={onEditorFocus:function(e){n._removeCurrentAnnotation(e)}},this.setOptions(i)}}var c={};return l.prototype=new i.KeyMode,r.mixin(l.prototype,{createKeyBindings:function(){var e=t.KeyBinding,i=[];return i.push({actionID:"incrementalFindBackspace",keyBinding:new e(8)}),i.push({actionID:"incrementalFindCancel",keyBinding:new e(13)}),i.push({actionID:"incrementalFindCancel",keyBinding:new e(27)}),i.push({actionID:"incrementalFindReverse",keyBinding:new e(38)}),i.push({actionID:"incrementalFind",keyBinding:new e(40)}),i.push({actionID:"incrementalFindReverse",keyBinding:new e("k",!0,!0)}),i.push({actionID:"incrementalFind",keyBinding:new e("k",!0)}),i},find:function(e,t){if(this._forward=e,!this.isActive())return this.setActive(!0),!1;var i=this._prefix;if(0===i.length)return!1;var n,o=this.editor,r=o.getModel();return n=e?this._success?t?this._start:o.getCaretOffset()+1:0:this._success?t?this._start:o.getCaretOffset():r.getCharCount()-1,s.when(o.getModel().find({string:i,start:n,reverse:!e,caseInsensitive:i.toLowerCase()===i}),function(i){var r=i.next();r?(t||(this._start=n),this._success=!0,this._ignoreSelection=!0,o.moveSelection(e?r.start:r.end,e?r.end:r.start),this._ignoreSelection=!1):this._success=!1,this._status()}.bind(this)),!0},isActive:function(){return this._active},isStatusActive:function(){return this.isActive()},setActive:function(e){if(this._active!==e){this._active=e,this._prefix="",this._success=!0;var t=this.editor,i=t.getTextView();this._start=this.editor.getCaretOffset(),this.editor.setCaretOffset(this._start),this._active?(i.addEventListener("Verify",this._listener.onVerify),i.addEventListener("Selection",this._listener.onSelection),i.addKeyMode(this)):(i.removeEventListener("Verify",this._listener.onVerify),i.removeEventListener("Selection",this._listener.onSelection),i.removeKeyMode(this)),this._status()}},_backspace:function(){var e=this._prefix;return e=this._prefix=e.substring(0,e.length-1),0===e.length?(this._success=!0,this._ignoreSelection=!0,this.editor.setCaretOffset(this.editor.getSelection().start),this._ignoreSelection=!1,this._status(),!0):this.find(this._forward,!0)},_status:function(){if(!this.isActive())return void this.editor.reportStatus("");var t;t=this._forward?this._success?e.incrementalFindStr:e.incrementalFindStrNotFound:this._success?e.incrementalFindReverseStr:e.incrementalFindReverseStrNotFound,t=a.formatMessage(t,this._prefix),this.editor.reportStatus(t,this._success?"":"error")}}),c.IncrementalFind=l,d.prototype={find:function(e,t,i){this.setOptions({reverse:!e});var n,o=this.getFindString();t&&(o=t.findString||o,n=t.count);var r=this.getOptions();this.setOptions(t);var s=i?this._startOffset:this.getStartOffset();return this._doFind(o,s,n).then(function(e){return e&&(i||(this._startOffset=e.start)),this.setOptions(r),this._hideAfterFind&&this.hide(),e}.bind(this))},getStartOffset:function(){return void 0!==this._start?this._start:this._reverse?this._editor.getSelection().start-1:this._editor.getCaretOffset()},getFindString:function(){var e=this._editor.getSelection(),t=this._editor.getText(e.start,e.end);return this._regex&&(t=o.escape(t)),t||this._lastString},getOptions:function(){return{showAll:this._showAll,caseInsensitive:this._caseInsensitive,wrap:this._wrap,wholeWord:this._wholeWord,incremental:this._incremental,regex:this._regex,findAfterReplace:this._findAfterReplace,hideAfterFind:this._hideAfterFind,reverse:this._reverse,findCallback:this._findCallback,start:this._start,end:this._end}},getReplaceString:function(){return""},hide:function(){this._visible=!1,this._savedOptions&&(this.setOptions(this._savedOptions.pop()),0===this._savedOptions.length&&(this._savedOptions=null)),this._removeAllAnnotations();var e=this._editor.getTextView();e&&(e.removeEventListener("Focus",this._listeners.onEditorFocus),e.focus())},_processReplaceString:function(e){var t=e;if(this._regex){t="";for(var i=!1,n=this._editor.getModel().getLineDelimiter(),o=0;o0&&(r.endUndo(),n.setRedraw(!0)),s>0?i.reportStatus(a.formatMessage(e.replacedMatches,l)):i.reportStatus(e.nothingReplaced,"error"),r._replacingAll=!1},100)}},setOptions:function(e){if(e){if((e.showAll===!0||e.showAll===!1)&&this._showAll!==e.showAll&&(this._showAll=e.showAll,this.isVisible()))if(this._showAll)this._markAllOccurrences();else{var t=this._editor.getAnnotationModel();t&&t.removeAnnotations(n.AnnotationType.ANNOTATION_MATCHING_SEARCH)}(e.caseInsensitive===!0||e.caseInsensitive===!1)&&(this._caseInsensitive=e.caseInsensitive),(e.wrap===!0||e.wrap===!1)&&(this._wrap=e.wrap),(e.wholeWord===!0||e.wholeWord===!1)&&(this._wholeWord=e.wholeWord),(e.incremental===!0||e.incremental===!1||"disabled"===e.incremental)&&("disabled"===e.incremental?(this._incremental=!1,this._incrementalDisabled=!0):this._incremental=e.incremental),(e.regex===!0||e.regex===!1)&&(this._regex=e.regex),(e.findAfterReplace===!0||e.findAfterReplace===!1)&&(this._findAfterReplace=e.findAfterReplace),(e.hideAfterFind===!0||e.hideAfterFind===!1)&&(this._hideAfterFind=e.hideAfterFind),(e.reverse===!0||e.reverse===!1)&&(this._reverse=e.reverse),e.hasOwnProperty("findCallback")&&(this._findCallback=e.findCallback),e.hasOwnProperty("start")&&(this._start=e.start),e.hasOwnProperty("end")&&(this._end=e.end)}},show:function(e){this._visible=!0,e&&(this._savedOptions||(this._savedOptions=[]),this._savedOptions.push(this.getOptions()),this.setOptions(e)),this._startOffset=this._editor.getSelection().start,this._editor.getTextView().addEventListener("Focus",this._listeners.onEditorFocus);var t=this;window.setTimeout(function(){t._incremental&&t.find(!0,null,!0)},0)},startUndo:function(){this._undoStack&&this._undoStack.startCompoundChange()},endUndo:function(){this._undoStack&&this._undoStack.endCompoundChange()},_findFromModel:function(e,t,i){return this._editor.getModel().find({string:e,start:t,end:this._end,reverse:this._reverse,wrap:i?!1:this._wrap,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive})},_find:function(e,t,i,n){var o;if(this._regex)try{o=this._findFromModel(t,i,n)}catch(r){return e.reportStatus(r.message,"error"),null}else o=this._findFromModel(t,i,n);return o},_doFindForReplaceAll:function(e,t,i,n){i=i||1;var o=this._editor;if(!e)return this._removeAllAnnotations(),null;this._lastString=e;var r,s;if(s=this._find(o,e,t,n),!s)return null;if(!s.hasNext||!s.next)return null;for(var a=0;i>a&&s.hasNext();a++)r=s.next();return r},_doFind:function(t,i,o,r){o=o||1;var a=this._editor;if(!t)return this._removeAllAnnotations(),(new s).resolve();this._lastString=t;var l;return s.when(this._find(a,t,i,r)).then(function(t){if(t){for(var i=0;o>i&&t.hasNext();i++)l=t.next();if(!this._replacingAll){if(l?this._editor.reportStatus(""):this._editor.reportStatus(e.notFound,"error"),this.isVisible()){var r=n.AnnotationType.ANNOTATION_CURRENT_SEARCH,s=a.getAnnotationModel();if(s&&(s.removeAnnotations(r),l&&s.addAnnotation(n.AnnotationType.createAnnotation(r,l.start,l.end))),this._showAll){this._timer&&window.clearTimeout(this._timer);var d=this;this._timer=window.setTimeout(function(){d._markAllOccurrences(),d._timer=null},500)}}this._findCallback?this._findCallback(l):l&&a.moveSelection(l.start,l.end,null,!1)}return l}}.bind(this))},_doReplace:function(e,t,i,n){var o=this._editor;this._regex&&(n=o.getText(e,t).replace(new RegExp(i,this._caseInsensitive?"i":""),n)),o.setText(n,e,t),o.setSelection(e,e+n.length,!0)},_markAllOccurrences:function(){var e=this._editor.getAnnotationModel();if(e){for(var t,i=n.AnnotationType.ANNOTATION_MATCHING_SEARCH,o=e.getAnnotations(),r=[];o.hasNext();){var a=o.next();a.type===i&&r.push(a)}if(this.isVisible()){var l=this.getFindString();s.when(this._editor.getModel().find({string:l,regex:this._regex,wholeWord:this._wholeWord,caseInsensitive:this._caseInsensitive})).then(function(o){if(o){for(t=[];o.hasNext();){var s=o.next();t.push(n.AnnotationType.createAnnotation(i,s.start,s.end))}e.replaceAnnotations(r,t)}}.bind(this))}else e.replaceAnnotations(r,t)}},_removeAllAnnotations:function(){var e=this._editor.getAnnotationModel();e&&(e.removeAnnotations(n.AnnotationType.ANNOTATION_CURRENT_SEARCH),e.removeAnnotations(n.AnnotationType.ANNOTATION_MATCHING_SEARCH))},_removeCurrentAnnotation:function(){var e=this._editor.getAnnotationModel();e&&e.removeAnnotations(n.AnnotationType.ANNOTATION_CURRENT_SEARCH)}},c.Find=d,c}),define("orion/editor/findUI",["i18n!orion/editor/nls/messages","orion/editor/find","orion/objects","orion/editor/util","orion/util"],function(e,t,i,n,o){function r(e,i,n){t.Find.call(this,e,i,n)}return r.prototype=new t.Find,i.mixin(r.prototype,{getFindString:function(){var e=this._findInput;return e?e.value:t.Find.prototype.getFindString.call(this)},getReplaceString:function(){var e=this._replaceInput;return e?e.value:t.Find.prototype.getReplaceString(this)},hide:function(){var e=this.isVisible();t.Find.prototype.hide.call(this),e&&(this._rootDiv.className="textViewFind")},show:function(e){t.Find.prototype.show.call(this,e);var i=e.findString,n=e.replaceString,o=this._findInput;if(o||(this._create(),o=this._findInput),i&&(o.value=i),n){var r=this._replaceInput;r.value=n}var s=this;window.setTimeout(function(){s._rootDiv.className="textViewFind show",o.select(),o.focus()},0)},_create:function(){var t=this,i=this._editor.getTextView(),r=i.getOptions("parent"),s=r.ownerDocument,a=o.createElement(s,"div");a.className="textViewFind",n.addEventListener(a,"keydown",function(e){t._handleKeyDown(e)}),this._rootDiv=a,a.setAttribute("role","dialog"),a.setAttribute("aria-label",e.findReplace),this._createContents(s,a),i._rootDiv.insertBefore(a,i._rootDiv.firstChild)},_createContents:function(t,i){var r=this,s=o.createElement(t,"input");s.className="textViewFindInput",this._findInput=s,s.type="text",s.placeholder=e.findWith,n.addEventListener(s,"input",function(e){return r._handleInput(e)}),i.appendChild(s);var a=o.createElement(t,"span");r._createButton(t,a,e.next,function(){r.find(!0)}),r._createButton(t,a,e.previous,function(){r.find(!1)}),i.appendChild(a);var l=r._editor.getTextView().getOptions("readonly");if(!l){var d=o.createElement(t,"input");d.className="textViewReplaceInput",this._replaceInput=d,d.type="text",d.placeholder=e.replaceWith,i.appendChild(d),a=o.createElement(t,"span"),r._createButton(t,a,e.replace,function(){r.replace()}),r._createButton(t,a,e.replaceAll,function(){r.replaceAll() +}),i.appendChild(a)}a=o.createElement(t,"span"),r._createButton(t,a,e.regex,function(e){r._toggle("regex",e.target)},this._regex,e.regexTooltip,e.regexTooltip),r._createButton(t,a,e.caseInsensitive,function(e){r._toggle("caseInsensitive",e.target)},this._caseInsensitive,e.caseInsensitiveTooltip,e.caseInsensitiveTooltip),r._createButton(t,a,e.wholeWord,function(e){r._toggle("wholeWord",e.target)},this._wholeWord,e.wholeWordTooltip,e.wholeWordTooltip),i.appendChild(a);var c=r._createButton(t,i,"",function(){r.hide()});c.className="textViewFindCloseButton",c.title=e.closeTooltip,o.confineDialogTab(s,c)},_createButton:function(e,t,i,o,r,s,a){var l=e.createElement("button");return l.type="button",this._checked(r,l),s&&(l.title=s),n.addEventListener(l,"click",function(e){o.call(this,e)},!1),i&&l.appendChild(e.createTextNode(i)),a&&l.setAttribute("aria-label",a),t.appendChild(l),l},_toggle:function(e,t){var i={};i[e]=!this["_"+e],this.setOptions(i),this._checked(i[e],t)},_checked:function(e,t){t.className="textViewFindButton",e&&(t.className+=" checked")},_handleInput:function(){return this._incremental&&this.find(!0,null,!0),!0},_handleKeyDown:function(e){var t,i=(o.isMac?e.metaKey:e.ctrlKey)&&!e.altKey&&!e.shiftKey;return i&&70===e.keyCode&&(t=!0),((o.isMac?e.metaKey:e.ctrlKey)&&!e.altKey&&75===e.keyCode||13===e.keyCode)&&(this.find(13===e.keyCode?this._reverse?e.shiftKey:!e.shiftKey:!e.shiftKey),t=!0),i&&82===e.keyCode&&(this.replace(),t=!0),27===e.keyCode&&(this.hide(),t=!0),t?(e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.cancelBubble=!0,!1):!0}}),{FindUI:r}}),define("orion/editor/actions",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/annotations","orion/editor/tooltip","orion/editor/find","orion/editor/findUI","orion/util"],function(e,t,i,n,o,r,s){function a(e,t,i,n){function o(e,t,i){s.setText(e,t,i),r+=t-i+e.length}var r=0,s=e.editor,a=s.getSelections();!n&&(t||a.length>1)&&e.startUndo(),a.forEach(function(e){e.start+=r,e.end+=r,i(e,o)}),s.setSelections(a),!n&&(t||a.length>1)&&e.endUndo()}function l(e,t,i){this.editor=e,this.undoStack=t,this._incrementalFind=new o.IncrementalFind(e),this._find=i?i:new r.FindUI(e,t),this._lastEditLocation=null,this.init()}function d(e,t,i,n){this.editor=e,this.undoStack=t,this.contentAssist=i,this.linkedMode=n,this.contentAssist&&this.contentAssist.addEventListener("ProposalApplied",this.contentAssistProposalApplied.bind(this)),this.init()}var c=i.AnnotationType,h={};return l.prototype={init:function(){var i=this.editor.getTextView();this._lastEditListener={onModelChanged:function(e){this.editor.isDirty()&&(this._lastEditLocation=e.start+e.addedCharCount)}.bind(this)},i.addEventListener("ModelChanged",this._lastEditListener.onModelChanged),i.setAction("undo",function(e){if(this.undoStack){var t=1;for(e&&e.count&&(t=e.count);t>0;)this.undoStack.undo(),--t;return!0}return!1}.bind(this),{name:e.undo}),i.setAction("redo",function(e){if(this.undoStack){var t=1;for(e&&e.count&&(t=e.count);t>0;)this.undoStack.redo(),--t;return!0}return!1}.bind(this),{name:e.redo}),i.setKeyBinding(new t.KeyBinding("f",!0),"find"),i.setAction("find",function(){if(this._find){var e=this.editor.getSelection();return this._find.show({findString:this.editor.getText(e.start,e.end)}),!0}return!1}.bind(this),{name:e.find}),i.setKeyBinding(new t.KeyBinding("k",!0),"findNext"),i.setAction("findNext",function(e){return this._find?(this._find.find(!0,e),!0):!1}.bind(this),{name:e.findNext}),i.setKeyBinding(new t.KeyBinding("k",!0,!0),"findPrevious"),i.setAction("findPrevious",function(e){return this._find?(this._find.find(!1,e),!0):!1}.bind(this),{name:e.findPrevious}),i.setKeyBinding(new t.KeyBinding("j",!0),"incrementalFind"),i.setAction("incrementalFind",function(){return this._incrementalFind&&this._incrementalFind.find(!0),!0}.bind(this),{name:e.incrementalFind}),i.setKeyBinding(new t.KeyBinding("j",!0,!0),"incrementalFindReverse"),i.setAction("incrementalFindReverse",function(){return this._incrementalFind&&this._incrementalFind.find(!1),!0}.bind(this),{name:e.incrementalFindReverse}),i.setAction("tab",function(){return this.indentLines()}.bind(this)),i.setAction("shiftTab",function(){return this.unindentLines()}.bind(this),{name:e.unindentLines}),i.setKeyBinding(new t.KeyBinding(38,!1,!1,!0),"moveLinesUp"),i.setAction("moveLinesUp",function(){return this.moveLinesUp()}.bind(this),{name:e.moveLinesUp}),i.setKeyBinding(new t.KeyBinding(40,!1,!1,!0),"moveLinesDown"),i.setAction("moveLinesDown",function(){return this.moveLinesDown()}.bind(this),{name:e.moveLinesDown}),i.setKeyBinding(new t.KeyBinding(38,!0,!1,!0),"copyLinesUp"),i.setAction("copyLinesUp",function(){return this.copyLinesUp()}.bind(this),{name:e.copyLinesUp}),i.setKeyBinding(new t.KeyBinding(40,!0,!1,!0),"copyLinesDown"),i.setAction("copyLinesDown",function(){return this.copyLinesDown()}.bind(this),{name:e.copyLinesDown}),i.setKeyBinding(new t.KeyBinding("d",!0,!1,!1),"deleteLines"),i.setAction("deleteLines",function(e){return this.deleteLines(e)}.bind(this),{name:e.deleteLines}),i.setKeyBinding(new t.KeyBinding("l",!s.isMac,!1,!1,s.isMac),"gotoLine"),i.setAction("gotoLine",function(){return this.gotoLine()}.bind(this),{name:e.gotoLine}),i.setKeyBinding(new t.KeyBinding(190,!0),"nextAnnotation"),i.setAction("nextAnnotation",function(){return this.nextAnnotation(!0)}.bind(this),{name:e.nextAnnotation}),i.setKeyBinding(new t.KeyBinding(188,!0),"previousAnnotation"),i.setAction("previousAnnotation",function(){return this.nextAnnotation(!1)}.bind(this),{name:e.prevAnnotation}),i.setKeyBinding(new t.KeyBinding("e",!0,!1,!0,!1),"expand"),i.setAction("expand",function(){return this.expandAnnotation(!0)}.bind(this),{name:e.expand}),i.setKeyBinding(new t.KeyBinding("c",!0,!1,!0,!1),"collapse"),i.setAction("collapse",function(){return this.expandAnnotation(!1)}.bind(this),{name:e.collapse}),i.setKeyBinding(new t.KeyBinding("e",!0,!0,!0,!1),"expandAll"),i.setAction("expandAll",function(){return this.expandAnnotations(!0)}.bind(this),{name:e.expandAll}),i.setKeyBinding(new t.KeyBinding("c",!0,!0,!0,!1),"collapseAll"),i.setAction("collapseAll",function(){return this.expandAnnotations(!1)}.bind(this),{name:e.collapseAll}),i.setKeyBinding(new t.KeyBinding("q",!s.isMac,!1,!1,s.isMac),"lastEdit"),i.setAction("lastEdit",function(){return this.gotoLastEdit()}.bind(this),{name:e.lastEdit})},copyLinesDown:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var i=e.getModel();return a(this,!1,function(e,t){var n=i.getLineAtOffset(e.start),o=i.getLineAtOffset(e.end>e.start?e.end-1:e.end),r=i.getLineStart(n),s=i.getLineEnd(o,!0),a=i.getLineCount(),l="",d=i.getText(r,s);o===a-1&&(d=(l=i.getLineDelimiter())+d);var c=s;t(d,c,c),e.start=c+l.length,e.end=c+d.length}),!0},copyLinesUp:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var i=e.getModel();return a(this,!1,function(e,t){var n=i.getLineAtOffset(e.start),o=i.getLineAtOffset(e.end>e.start?e.end-1:e.end),r=i.getLineStart(n),s=i.getLineEnd(o,!0),a=i.getLineCount(),l="",d=i.getText(r,s);o===a-1&&(d+=l=i.getLineDelimiter());var c=r;t(d,c,c),e.start=c,e.end=c+d.length-l.length}),!0},deleteLines:function(e){var t=this.editor,i=t.getTextView();if(i.getOptions("readonly"))return!1;var n=1;e&&e.count&&(n=e.count);var o=t.getModel();return a(this,!1,function(e,t){var i,r=o.getLineAtOffset(e.start),s=o.getLineStart(r);i=e.start!==e.end||1===n?o.getLineAtOffset(e.end>e.start?e.end-1:e.end):Math.min(r+n-1,o.getLineCount()-1);var a=o.getLineEnd(i,!0);t("",s,a),e.start=e.end=s}),!0},expandAnnotation:function(e){var t=this.editor;if(!t.getFoldingRulerVisible())return!0;var n=t.getAnnotationModel();if(!n)return!0;var o=t.getModel(),r=t.getCaretOffset(),s=o.getLineAtOffset(r),a=o.getLineStart(s),l=o.getLineEnd(s,!0);o.getBaseModel&&(a=o.mapOffset(a),l=o.mapOffset(l),o=o.getBaseModel());for(var d,c=n.getAnnotations(a,l);!d&&c.hasNext();){var h=c.next();h.type===i.AnnotationType.ANNOTATION_FOLDING&&(d=h)}return d&&e!==d.expanded&&(e?d.expand():(t.setCaretOffset(d.start),d.collapse())),!0},expandAnnotations:function(e){var t=this.editor;if(!t.getFoldingRulerVisible())return!0;var n=t.getTextView(),o=t.getAnnotationModel();if(!o)return!0;var r,s=o.getAnnotations();for(n.setRedraw(!1);s.hasNext();)r=s.next(),r.type===i.AnnotationType.ANNOTATION_FOLDING&&e!==r.expanded&&(e?r.expand():r.collapse());return n.setRedraw(!0),!0},indentLines:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;if(t.getOptions("tabMode")){var i=e.getModel(),n=0,o=e.getSelections();return o.length>1&&this.startUndo(),o.some(function(r){r.start+=n,r.end+=n;var s=i.getLineAtOffset(r.start),a=i.getLineAtOffset(r.end>r.start?r.end-1:r.end);if(!(s!==a||o.length>1))return!0;var l=[];l.push("");for(var d=s;a>=d;d++)l.push(i.getLine(d,!0));var c=i.getLineStart(s),h=i.getLineEnd(a,!0),u=t.getOptions("tabSize","expandTab"),p=u.expandTab?new Array(u.tabSize+1).join(" "):" ",f=l.join(p);e.setText(f,c,h);var g=c===r.start?r.start:r.start+p.length,_=r.end+(a-s+1)*p.length;return n+=c-h+f.length,r.start=g,r.end=_,!1})?!1:(e.setSelections(o),o.length>1&&this.endUndo(),!0)}},gotoLastEdit:function(){return"number"==typeof this._lastEditLocation&&this.editor.showSelection(this._lastEditLocation),!0},gotoLine:function(){var t=this.editor,i=t.getModel(),n=i.getLineAtOffset(t.getCaretOffset());return n=prompt(e.gotoLinePrompty,n+1),n&&(n=parseInt(n,10),t.onGotoLine(n-1,0)),!0},moveLinesDown:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var i=e.getModel();return a(this,!0,function(e,t){var n=i.getLineAtOffset(e.start),o=i.getLineAtOffset(e.end>e.start?e.end-1:e.end),r=i.getLineCount();if(o!==r-1){var s,a=i.getLineStart(n),l=i.getLineEnd(o,!0),d=i.getLineEnd(o+1,!0)-(l-a),c=0;if(o!==r-2)s=i.getText(a,l);else{var h=i.getLineEnd(o);s=i.getText(h,l)+i.getText(a,h),c+=l-h}t("",a,l),t(s,d,d),e.start=d+c,e.end=d+c+s.length}}),!0},moveLinesUp:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var i=e.getModel();return a(this,!0,function(e,t){var n=i.getLineAtOffset(e.start);if(0!==n){var o=i.getLineAtOffset(e.end>e.start?e.end-1:e.end),r=i.getLineCount(),s=i.getLineStart(n-1),a=i.getLineStart(n),l=i.getLineEnd(o,!0),d=i.getText(a,l),c=0;if(o===r-1){var h=i.getLineEnd(n-1),u=i.getLineEnd(n-1,!0);d+=i.getText(h,u),a=h,c=u-h}t("",a,l),t(d,s,s),e.start=s,e.end=s+d.length-c}}),!0},nextAnnotation:function(e){function t(e){return!!e.lineStyle||e.type===c.ANNOTATION_MATCHING_BRACKET||e.type===c.ANNOTATION_CURRENT_BRACKET||!r.isAnnotationTypeVisible(e.type)}var i=this.editor,o=i.getAnnotationModel();if(!o)return!0;var r=i.getOverviewRuler()||i.getAnnotationStyler();if(!r)return!0;for(var s=i.getModel(),a=i.getCaretOffset(),l=o.getAnnotations(e?a:0,e?s.getCharCount():a),d=null;l.hasNext();){var h=l.next();if(e){if(h.start<=a)continue}else if(h.start>=a)continue;if(!t(h)&&(d=h,e))break}if(d){var u=[d];for(l=o.getAnnotations(d.start,d.start);l.hasNext();)h=l.next(),h===d||t(h)||u.push(h);var p=i.getTextView(),f=n.Tooltip.getTooltip(p,i);if(!f)return i.moveSelection(d.start),!0;i.moveSelection(d.start,d.start,function(){setTimeout(function(){var e=i.getTextView(),t=d.start,n=e.getLocationAtOffset(t);f.show({x:n.x,y:n.y,getTooltipInfo:function(){return i._getTooltipInfo(this.x,this.y)}},!1,!1)},0)})}return!0},unindentLines:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;if(t.getOptions("tabMode")){var i=e.getModel();return a(this,!1,function(e,n){for(var o=i.getLineAtOffset(e.start),r=i.getLineAtOffset(e.end>e.start?e.end-1:e.end),s=t.getOptions("tabSize"),a=new Array(s+1).join(" "),l=[],d=0,c=0,h=o;r>=h;h++){var u=i.getLine(h,!0);if(i.getLineStart(h)!==i.getLineEnd(h))if(0===u.indexOf(" "))u=u.substring(1),d++;else{if(0!==u.indexOf(a))return!0;u=u.substring(s),d+=s}h===o&&(c=d),l.push(u)}var p=i.getLineStart(o),f=i.getLineEnd(r,!0),g=i.getLineStart(r),_=l.join("");n(_,p,f);var m=p===e.start?e.start:e.start-c,v=Math.max(m,e.end-d+(e.end===g+1&&e.start!==e.end?1:0));e.start=m,e.end=v}),!0}},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()}},h.TextActions=l,d.prototype={init:function(){var i=this.editor.getTextView();i.setAction("lineStart",function(){return this.lineStart()}.bind(this)),i.setAction("enter",function(){return this.autoIndent()}.bind(this)),i.setKeyBinding(new t.KeyBinding("t",!0,!1,!0),"trimTrailingWhitespaces"),i.setAction("trimTrailingWhitespaces",function(){return this.trimTrailingWhitespaces()}.bind(this),{name:e.trimTrailingWhitespaces}),i.setKeyBinding(new t.KeyBinding(191,!0),"toggleLineComment"),i.setAction("toggleLineComment",function(){return this.toggleLineComment()}.bind(this),{name:e.toggleLineComment}),i.setKeyBinding(new t.KeyBinding(191,!0,!s.isMac,!1,s.isMac),"addBlockComment"),i.setAction("addBlockComment",function(){return this.addBlockComment()}.bind(this),{name:e.addBlockComment}),i.setKeyBinding(new t.KeyBinding(220,!0,!s.isMac,!1,s.isMac),"removeBlockComment"),i.setAction("removeBlockComment",function(){return this.removeBlockComment()}.bind(this),{name:e.removeBlockComment}),i.setKeyBinding(new t.KeyBinding("[",!1,!1,!1,!1,"keypress"),"autoPairSquareBracket"),i.setAction("autoPairSquareBracket",function(){return this.autoPairBrackets("[","]")}.bind(this)),i.setKeyBinding(new t.KeyBinding("]",!1,!1,!1,!1,"keypress"),"skipClosingSquareBracket"),i.setAction("skipClosingSquareBracket",function(){return this.handleClosingBracket("]")}.bind(this)),i.setKeyBinding(new t.KeyBinding("<",!1,!1,!1,!1,"keypress"),"autoPairAngleBracket"),i.setAction("autoPairAngleBracket",function(){return this.autoPairBrackets("<",">")}.bind(this)),i.setKeyBinding(new t.KeyBinding(">",!1,!1,!1,!1,"keypress"),"skipClosingAngleBracket"),i.setAction("skipClosingAngleBracket",function(){return this.handleClosingBracket(">")}.bind(this)),i.setKeyBinding(new t.KeyBinding("(",!1,!1,!1,!1,"keypress"),"autoPairParentheses"),i.setAction("autoPairParentheses",function(){return this.autoPairBrackets("(",")")}.bind(this)),i.setKeyBinding(new t.KeyBinding(")",!1,!1,!1,!1,"keypress"),"skipClosingParenthesis"),i.setAction("skipClosingParenthesis",function(){return this.handleClosingBracket(")")}.bind(this)),i.setKeyBinding(new t.KeyBinding("{",!1,!1,!1,!1,"keypress"),"autoPairBraces"),i.setAction("autoPairBraces",function(){return this.autoPairBrackets("{","}")}.bind(this)),i.setKeyBinding(new t.KeyBinding("}",!1,!1,!1,!1,"keypress"),"skipClosingBrace"),i.setAction("skipClosingBrace",function(){return this.handleClosingBracket("}")}.bind(this)),i.setKeyBinding(new t.KeyBinding("'",!1,!1,!1,!1,"keypress"),"autoPairSingleQuotation"),i.setAction("autoPairSingleQuotation",function(){return this.autoPairQuotations("'")}.bind(this)),i.setKeyBinding(new t.KeyBinding('"',!1,!1,!1,!1,"keypress"),"autoPairDblQuotation"),i.setAction("autoPairDblQuotation",function(){return this.autoPairQuotations('"')}.bind(this)),i.setAction("deletePrevious",function(){return this.deletePrevious()}.bind(this))},autoIndent:function(){function e(e,t){if(e.start===e.end){for(var i,o=n.getLineAtOffset(e.start),a=n.getLine(o,!1),u=n.getLineStart(o),p=0,f=e.start-u;f>p&&(32===(i=a.charCodeAt(p))||9===i);)p++;var g,_,m=a.substring(0,p),v=a.substring(0,f),y=a.substring(f);if(h.smartIndentation&&123===a.charCodeAt(_=v.trimRight().length-1)){var x=f-_-1,b=y.length-y.trimLeft().length;return g=125===a.charCodeAt(f+b)?s+m+r+s+m:s+m+r,t(g,e.start-x,e.end+b),e.start=e.end=e.start+s.length+m.length+r.length-x,!0}if(h.autoCompleteComments&&!c.test(v)&&(l.test(v)||d.test(v))){var w,C=l.exec(v);if(C)return g=s+m+" * ",g+=c.test(y)?y.substring(0,y.length-2).trim():y.trim(),n.getLineCount()!==o+1&&d.test(n.getLine(o+1))||(g+=s+m+" */"),t(g,e.start,e.end+y.length),e.start=e.end=e.start+s.length+m.length+3,!0;if(C=d.exec(v))for(var T=o-1;T>=0;T--){var L=n.getLine(T,!1);if(l.test(L))return c.test(y)||47===a.charCodeAt(f)?(g=s+m+"*"+y,w=e.start+s.length+m.length+1):(g=s+m+"* "+y,w=e.start+s.length+m.length+2),t(g,e.start,e.end+y.length),e.start=e.end=w,!0;if(!d.test(L))return!1}return!1}if(c.test(v)&&32===m.charCodeAt(m.length-1))return g=s+m.substring(0,m.length-1),t(g,e.start,e.end),e.start=e.end=e.start+g.length,!0;if(p>0){for(p=f;p]"),r=i.getModel();return a(this,!1,function(i,n){var s,a=i.start===r.getCharCount()?"":r.getText(i.start,i.start+1).trim();i.start===i.end&&o.test(a)?(s=e+t,n(s,i.start,i.start),i.start=i.end=i.start+1):i.start!==i.end?(s=e+r.getText(i.start,i.end)+t,n(s,i.start,i.end),i.start+=1,i.end+=1):(n(e,i.start,i.end),i.start=i.end=i.start+e.length)}),!0},autoPairQuotations:function(e){if(!this.autoPairQuotation)return!1;var t=this.editor,i=t.getTextView();if(i.getOptions("readonly"))return!1;var n=new RegExp("^\"$|^'$"),o=new RegExp("\\w"),r=new RegExp("^$|[)}\\]>]"),s=t.getModel();return a(this,!1,function(t,i){function a(){i(e,t.start,t.end),t.start=t.end=t.start+e.length}var l=0===t.start?"":s.getText(t.start-1,t.start).trim(),d=t.start===s.getCharCount()?"":s.getText(t.start,t.start+1).trim();if(t.start!==t.end){var c=s.getText(t.start,t.end);n.test(c)?a():(i(e+c+e,t.start,t.end),t.start+=1,t.end+=1)}else d===e?t.start=t.end=t.start+1:l===e||n.test(d)||o.test(l)||!r.test(d)?a():(i(e+e,t.start,t.end),t.start=t.end=t.start+e.length)}),!0},contentAssistProposalApplied:function(e){function t(){return"number"==typeof i.escapePosition?i.escapePosition:e.data.start+i.proposal.length}var i=e.data.proposal;if(i.positions&&i.positions.length>0&&this.linkedMode){for(var n=[],o=0;o0&&this.linkedMode)this.linkedMode.enterLinkedMode({groups:i.groups,escapePosition:t()});else if("number"==typeof i.escapePosition){var r=this.editor.getTextView();r.setCaretOffset(i.escapePosition)}return!0},deletePrevious:function(){var e=this.editor,t=e.getTextView();if(t.getOptions("readonly"))return!1;var i=e.getModel();return a(this,!1,function(e,t){if(e.start===e.end){var n=0===e.start?"":i.getText(e.start-1,e.start),o=e.start===i.getCharCount()?"":i.getText(e.start,e.start+1);("("===n&&")"===o||"["===n&&"]"===o||"{"===n&&"}"===o||"<"===n&&">"===o||'"'===n&&'"'===o||"'"===n&&"'"===o)&&t("",e.start,e.start+1)}},!0),!1},_findEnclosingComment:function(e,t,i,n,o){var r,s,a,l,d,c,h,u=e.getLineAtOffset(t),p=e.getLineAtOffset(i);for(r=u;r>=0&&(s=e.getLine(r),a=r===u?t-e.getLineStart(u):s.length,l=s.lastIndexOf(n,a),d=s.lastIndexOf(o,a),!(d>l));r--)if(-1!==l){c=e.getLineStart(r)+l;break}for(r=p;rl));r++)if(-1!==d){h=e.getLineStart(r)+d;break}return{commentStart:c,commentEnd:h}},lineStart:function(){var e=this.editor,t=e.getModel();return a(this,!1,function(e){var i,n=e.getCaret(),o=t.getLineAtOffset(n),r=t.getLineStart(o),s=t.getLine(o);for(i=0;ie.start?e.end-1:e.end);o=n?n.getLineCommentDelimiter(i.getLineStart(r)):"//";for(var a,l=!0,d=[],c=r;s>=c;c++){var h=i.getLine(c,!0);if(a=h.indexOf(o),d.push(a),l&&-1!==a){if(0!==a){var u;for(u=0;a>u;u++){var p=h.charCodeAt(u);if(32!==p&&9!==p)break}l=u===a}}else l=!1}var f,g,_,m=o.length,v=i.getLineStart(r);if(l){for(_=d.length-1;_>=0;_--)a=d[_]+i.getLineStart(r+_),t("",a,a+m);var y=i.getLineStart(s);f=v===e.start?e.start:e.start-m,g=e.end-m*(s-r+1)+(e.end===y+1?m:0)}else{for(_=d.length-1;_>=0;_--)a=i.getLineStart(r+_),t(o,a,a);f=v===e.start?e.start:e.start+m,g=e.end+m*(s-r+1)}e.start=f,e.end=g}),t.setRedraw(!0),!0},trimTrailingWhitespaces:function(){var e=this.editor,t=e.getModel(),i=e.getSelections();e.getTextView().setRedraw(!1),this.startUndo();for(var n=/(\s+$)/,o=t.getLineCount(),r=0;o>r;r++){var s=t.getLine(r),a=n.exec(s);if(a){var l=t.getLineStart(r),d=a[0].length,c=l+a.index;t.setText("",c,c+d),i.forEach(function(e){e.start>c&&(e.start=Math.max(c,e.start-d)),e.start!==e.end&&e.end>c&&(e.end=Math.max(c,e.end-d))})}}this.endUndo(),e.setSelections(i,!1),e.getTextView().setRedraw(!0)},startUndo:function(){this.undoStack&&this.undoStack.startCompoundChange()},handleClosingBracket:function(e){var t=this.editor,i=t.getTextView();if(i.getOptions("readonly"))return!1;var n=t.getModel(),o=t.getSelections();if(1===o.length&&o[0].start===o[0].end){var r=o[0].start===n.getCharCount()?"":n.getText(o[0].start,o[0].start+1);if(r===e)return o[0].start=o[0].end=o[0].start+1,t.setSelections(o),!0;var s=n.getLineAtOffset(o[0].start),a=n.getLine(s,!0);if(a.match(/^\s*$/)&&i.getOptions("tabMode")){var l=i.getOptions("tabSize"),d=new Array(l+1).join(" "),c=n.getLineStart(s),h=n.getLineEnd(s);if(c!==h){if(0===a.indexOf(" "))return a=a.substring(1),n.setText(a,c,h),t.setSelection(o[0].start-1,o[0].end-1),!1;if(0===a.indexOf(d))return a=a.substring(l),n.setText(a,c,h),t.setSelection(o[0].start-l,o[0].end-l),!1}}}return!1},endUndo:function(){this.undoStack&&this.undoStack.endCompoundChange()},setAutoPairParentheses:function(e){this.autoPairParentheses=e},setAutoPairBraces:function(e){this.autoPairBraces=e},setAutoPairSquareBrackets:function(e){this.autoPairSquareBrackets=e},setAutoPairAngleBrackets:function(e){this.autoPairAngleBrackets=e},setAutoPairQuotations:function(e){this.autoPairQuotation=e},setAutoCompleteComments:function(e){this.autoCompleteComments=e},setSmartIndentation:function(e){this.smartIndentation=e}},h.SourceCodeActions=d,String.prototype.trimLeft||(String.prototype.trimLeft=function(){return this.replace(/^\s+/g,"")}),String.prototype.trimRight||(String.prototype.trimRight=function(){return this.replace(/\s+$/g,"")}),h}),define("orion/editor/undoStack",[],function(){function e(e,t,i,n,o){this.model=e,this.offset=t,this.text=i,this.previousText=n,this.type=o}function t(e){this.owner=e,this.changes=[]}function i(e,t){this.size=void 0!==t?t:100,this.reset();var i=this;if(this._listener={onChanging:function(e){i._onChanging(e)},onDestroy:function(e){i._onDestroy(e)}},e.getModel){var n=e.getModel();n.getBaseModel&&(n=n.getBaseModel()),this.model=n,this.setView(e)}else this.shared=!0,this.model=e;this.model.addEventListener("Changing",this._listener.onChanging)}return e.prototype={getRedoChanges:function(){return[{start:this.offset,end:this.offset+this.previousText.length,text:this.text}]},getUndoChanges:function(){return[{start:this.offset,end:this.offset+this.text.length,text:this.previousText}]},undo:function(e,t){return this._doUndoRedo(this.offset,this.previousText,this.text,e,t),!0},redo:function(e,t){return this._doUndoRedo(this.offset,this.text,this.previousText,e,t),!0},merge:function(e,t,i,n,o){if(n===this.type){if(1===n&&e===this.offset+this.text.length)return this.text+=t,!0;if(-1===n&&o===this.offset)return this.offset=e,this.previousText=i+this.previousText,!0;if(-1===n&&e===this.offset)return this.previousText=this.previousText+i,!0}return!1},_doUndoRedo:function(e,t,i,n,o){if(this.model.setText(t,e,e+i.length),o&&n){var r=n.getModel();r!==this.model&&(e=r.mapOffset(e,!0)),n.setSelection(e,e+t.length)}}},t.prototype={getRedoChanges:function(){for(var e=[],t=0;t=0;t--)e=e.concat(this.changes[t].getUndoChanges());return e},add:function(e){this.changes.push(e)},end:function(e){e&&(this.endSelection=e.getSelections());var t=this.owner;t&&t.end&&t.end()},undo:function(e,t){this.changes.length>1&&e&&e.setRedraw(!1);for(var i=this.changes.length-1;i>=0;i--)this.changes[i].undo(e,!1);t&&e&&e.setSelections(this.startSelection),this.changes.length>1&&e&&e.setRedraw(!0);var n=this.owner;return n&&n.undo&&n.undo(),this.changes.length>0},redo:function(e,t){this.changes.length>1&&e&&e.setRedraw(!1);for(var i=0;i1,e&&e.setRedraw(!0);var n=this.owner;return n&&n.redo&&n.redo(),this.changes.length>0},merge:function(e,t,i,n,o,r){var s=this.changes.length;return s>0&&this===r?this.changes[s-1].merge(e,t,i,n,o):!1},start:function(e){e&&(this.startSelection=e.getSelections());var t=this.owner;t&&t.start&&t.start()}},i.prototype={destroy:function(){this._onDestroy()},add:function(e){if(this.compoundChange)this.compoundChange.add(e);else{var t=this.stack.length;this.stack.splice(this.index,t-this.index,e),this.index++,this.stack.length>this.size&&(this.stack.shift(),this.index--)}},markClean:function(){this._commitUndo(),this.cleanChange=this.stack[this.index-1],this.cleanChange&&(this.cleanChange.type=2)},isClean:function(){return this.cleanChange===this.stack[this.index-1]},canUndo:function(){return this.index>0},canRedo:function(){return this.stack.length-this.index>0},endCompoundChange:function(){this.compoundChange&&this.compoundChange.end(this.view),this.compoundChange=void 0},getSize:function(){return{undo:this.index,redo:this.stack.length-this.index}},getRedoChanges:function(){this._commitUndo();for(var e=[],t=this.index;t=0;t--)e=e.concat(this.stack[t].getUndoChanges());return e},undo:function(){this._commitUndo();var e,t=!1;this._ignoreUndo=!0;do{if(this.index<=0)break;e=this.stack[--this.index]}while(!(t=e.undo(this.view,!0)));return this._ignoreUndo=!1,t},redo:function(){this._commitUndo();var e,t=!1;this._ignoreUndo=!0;do{if(this.index>=this.stack.length)break;e=this.stack[this.index++]}while(!(t=e.redo(this.view,!0)));return this._ignoreUndo=!1,t},reset:function(){this.index=0,this.cleanChange=void 0,this.stack=[],this._ignoreUndo=!1,this._compoundChange=void 0},setView:function(e){this.view!==e&&(this.view&&e.removeEventListener("Destroy",this._listener.onDestroy),this.view=e,this.view&&e.addEventListener("Destroy",this._listener.onDestroy))},startCompoundChange:function(e){this._commitUndo();var i=new t(e);return this.add(i),this.compoundChange=i,this.compoundChange.start(this.view),this.compoundChange},_commitUndo:function(){this.endCompoundChange()},_onDestroy:function(e){e&&this.shared||this.model.removeEventListener("Changing",this._listener.onChanging),this.view&&(this.view.removeEventListener("Destroy",this._listener.onDestroy),this.view=null)},_trackUnsavedChanges:function(e){if(this._unsavedChanges){var t=this._unsavedChanges.length,i=e.addedCharCount,n=e.removedCharCount,o=e.start,r=e.start+n,s=0;if(0===i?s=-1:0===n&&(s=1),t>0&&s===this._previousChangeType){var a=this._unsavedChanges[t-1];if(0===n&&o===a.end+a.text.length)return void(a.text+=e.text);if(0===e.addedCharCount&&r===a.start)return void(a.start=o)}this._previousChangeType=s,this._unsavedChanges.push({start:o,end:r,text:e.text})}},_onChanging:function(t){if(this._trackUnsavedChanges(t),!this._ignoreUndo){var i=t.text,n=t.start,o=t.addedCharCount,r=t.removedCharCount,s=n+r,a=0;0===o&&1===r?a=-1:1===o&&0===r&&(a=1);var l=this.stack.length,d=this.model.getText(n,s);if(l>0&&this.index===l){var c=this.stack[l-1];if(c.merge(n,i,d,a,s,this.compoundChange))return}this.add(new e(this.model,n,i,d,a))}}},{UndoStack:i}}),define("orion/editor/rulers",["i18n!orion/editor/nls/messages","orion/editor/textView","orion/editor/annotations","orion/editor/tooltip","orion/objects","orion/editor/util","orion/util"],function(e,t,i,n,o,r,s){function a(e,t,i){this._location=e||"left",this._overview=t||"page",this._rulerStyle=i,this._view=null}function l(e,t,i,n){a.call(this,t,i,n);var o=this;this._listener={onTextModelChanged:function(e){o._onTextModelChanged(e)},onAnnotationModelChanged:function(e){o._onAnnotationModelChanged(e)}},this.setAnnotationModel(e)}function d(e,t,i,n,o){l.call(this,e,t,"page",i),this._oddStyle=n||{style:{backgroundColor:"white"}},this._evenStyle=o||{style:{backgroundColor:"white"}},this._numOfDigits=0,this._firstLine=1}function c(e,t,i){l.call(this,e,t,"page",i)}function h(e,t,i){l.call(this,e,t,"document",i)}function u(e,t,i){c.call(this,e,t,i)}a.prototype={getLocation:function(){return this._location},getOverview:function(){return this._overview},getRulerStyle:function(){return this._rulerStyle},getView:function(){return this._view},setView:function(e){this._onTextModelChanged&&this._view&&this._view.removeEventListener("ModelChanged",this._listener.onTextModelChanged),this._view=e,this._onTextModelChanged&&this._view&&this._view.addEventListener("ModelChanged",this._listener.onTextModelChanged)}},l.prototype=o.mixin(new a,{getAnnotations:function(e,t){var i=this._annotationModel;if(!i)return[];var n=this._view.getModel(),o=n.getLineStart(e),r=n.getLineEnd(t-1),s=n;n.getBaseModel&&(s=n.getBaseModel(),o=n.mapOffset(o),r=n.mapOffset(r));for(var a=[],l=this.getAnnotationsByType(i,o,r),d=0;d=p;p++){var f=p;if(n!==s){var g=s.getLineStart(p);if(g=n.mapOffset(g,!0),-1===g)continue;f=n.getLineAtOffset(g)}if(f>=e&&t>f){var _=this._mergeAnnotation(a[f],c,p-h,u-h+1);_&&(a[f]=_)}}if(!this._multiAnnotation&&this._multiAnnotationOverlay)for(var m in a)a[m]._multiple&&(a[m].html=a[m].html+this._multiAnnotationOverlay.html); +return a},getAnnotationModel:function(){return this._annotationModel},getWidestAnnotation:function(){return null},setAnnotationModel:function(e){this._annotationModel&&this._annotationModel.removeEventListener("Changed",this._listener.onAnnotationModelChanged),this._annotationModel=e,this._annotationModel&&this._annotationModel.addEventListener("Changed",this._listener.onAnnotationModelChanged)},setMultiAnnotation:function(e){this._multiAnnotation=e},setMultiAnnotationOverlay:function(e){this._multiAnnotationOverlay=e},onClick:function(e){if(void 0!==e){var t,i,o,r=this._view,s=r.getModel(),a=s.getLineStart(e),l=s.getLineEnd(e,!0),d=r.getSelection().start,c=r.getSelection().end,h=this._annotationModel;if(h){s.getBaseModel&&(a=s.mapOffset(a),l=s.mapOffset(l),d=s.mapOffset(d),c=s.mapOffset(c));var u=this;t=this._findNextAnnotation(h,a,l,d,c,function(e){return u.isAnnotationTypeVisible(e)}),i=t?t.start:a,o=t?t.end:a,s.getBaseModel&&(i=s.mapOffset(i,!0),o=s.mapOffset(o,!0)),t&&void 0!==t.groupId&&(this._currentClickGroup=this._currentClickGroup===t.groupId?null:t.groupId,this._setCurrentGroup(e))}this._view.setSelection(o,i,1/3,function(){});var p=n.Tooltip.getTooltip(this._view);p&&(t&&"left"===this.getLocation()?p.show({getTooltipInfo:function(){return u._getTooltipInfo([t])}},!1,!1):p.hide())}},onDblClick:function(){},onMouseMove:function(e,t){var i=n.Tooltip.getTooltip(this._view);if(i&&(!i.isVisible()||this._tooltipLineIndex!==e)&&(this._tooltipLineIndex=e,t.clientX!==this._lastMouseX||t.clientY!==this._lastMouseY)){this._lastMouseX=t.clientX,this._lastMouseY=t.clientY,this._hoverTimeout&&(window.clearTimeout(this._hoverTimeout),this._hoverTimeout=null);var o=t.target?t.target:t.srcElement,r=o.getBoundingClientRect();this._curElementBounds=Object.create(null),this._curElementBounds.top=r.top,this._curElementBounds.left=r.left,this._curElementBounds.height=r.height,this._curElementBounds.width=r.width,o===this.node&&(this._curElementBounds.top=t.clientY,this._curElementBounds.height=1);var s=this;s._hoverTimeout=window.setTimeout(function(){s._hoverTimeout=null,i.onHover({getTooltipInfo:function(){var e=s._getAnnotationsAtLineIndex(s._tooltipLineIndex),i=s._getTooltipContents(s._tooltipLineIndex,e);return s._getTooltipInfo(i,t.clientY,{source:"ruler",rulerLocation:s.getLocation()})}},t.clientX,t.clientY)},175)}},onMouseOver:function(e,t){this.onMouseMove(e,t),this._currentClickGroup||this._setCurrentGroup(e)},onMouseOut:function(){this._currentClickGroup||this._setCurrentGroup(-1),this._hoverTimeout&&(window.clearTimeout(this._hoverTimeout),this._hoverTimeout=null)},_findNextAnnotation:function(e,t,i,n,o,r){var s,a=null,l=t;if(n>=0&&o>=0&&n>=t&&i>n){l=n;for(var d=e.getAnnotations(n,o);!s&&d.hasNext();){var c=d.next();(!r||r(c.type))&&c.start===n&&c.end===o&&(s=c)}}for(var h,u=e.getAnnotations(l,i);u.hasNext();)if(c=u.next(),!r||r(c.type)){if(a||(a=c),!s){a=c;break}if(h&&(s.start!==c.start||s.end!==c.end)){h=!1,a=c;break}s&&s===c&&(h=!0)}return h&&(a=null),a},_getAnnotationsAtLineIndex:function(e){if(void 0!==e){var t,i=this._view,n=this._annotationModel,o=[];if(!i)return[];if(t=i.getModel(),n&&t){var r=t.getLineStart(e),s=t.getLineEnd(e);t.getBaseModel&&(r=t.mapOffset(r),s=t.mapOffset(s)),o=this.getAnnotationsByType(n,r,s)}return o}},_getTooltipInfo:function(e,t,i){if(!e)return null;var n=Object.create(null);n.top=this._curElementBounds.top,n.left=this._curElementBounds.left,n.height=this._curElementBounds.height,n.width=this._curElementBounds.width,"string"==typeof e&&t&&(n.top=t,n.height=1);var o=this.getLocation(),r=this.getRulerStyle(),s="left"===o?"right":"left",a=0,l=0;if(this._view){var d=this._view._clientDiv.getBoundingClientRect();a=d.left-(n.left+n.width)}else a=n.width;l=n.height,"left"===s&&(a=-25,1===n.height&&(a+=2)),r.styleClass.indexOf("folding")>=0&&(l-=14);var c={contents:e,position:s,tooltipOffsetX:a,tooltipOffsetY:l,anchorArea:n,context:i};return c},_getTooltipContents:function(e,t){return t},_getOnClickTooltipInfo:function(e){var t=this._view,i=Object.create(null);i.top=this._curElementBounds.top,i.left=this._curElementBounds.left,i.height=this._curElementBounds.height,i.width=this._curElementBounds.width;var n=this.getLocation(),o="left"===n?"right":"left",r={contents:[e],position:o,anchorArea:i};if(t){var s=t._clientDiv.getBoundingClientRect();r.offsetX=s.left-(i.left+i.width)}else r.offsetX=i.width;return r.offsetY=i.height,"left"===r.position&&(r.offsetX=20),r},_onAnnotationModelChanged:function(e){function t(e){for(var t=0;t=l&&void 0!==t.groupId){o=t;break}if(s&&o&&s.groupId===o.groupId)return}if(this._currentGroupAnnotation=null,s&&n.removeAnnotations(s.groupType),o&&-1!==e){this._currentGroupAnnotation=o,i=n.getAnnotations();for(var d=[];i.hasNext();)t=i.next(),delete t.groupAnnotation,t.groupId===o.groupId&&(t=t.createGroupAnnotation(),d.push(t));n.replaceAnnotations(null,d)}}}),i.AnnotationTypeList.addMixin(l.prototype),d.prototype=new l,d.prototype.getAnnotations=function(e,t){for(var i=l.prototype.getAnnotations.call(this,e,t),n=this._view.getModel(),o=e;t>o;o++){var r=o-this._firstLine&1?this._oddStyle:this._evenStyle,s=o;if(n.getBaseModel){var a=n.getLineStart(s);s=n.getBaseModel().getLineAtOffset(n.mapOffset(a))}i[o]||(i[o]={}),i[o].html=this._firstLine+s+"",i[o].style||(i[o].style=r)}return i},d.prototype.getWidestAnnotation=function(){var e=this._view.getModel().getLineCount();return this.getAnnotations(e-1,e)[e-1]},d.prototype.setFirstLine=function(e){this._firstLine=void 0!==e?e:1},d.prototype._onTextModelChanged=function(e){var t=e.start,i=this._view.getModel(),n=i.getBaseModel?i.getBaseModel().getLineCount():i.getLineCount(),o=(this._firstLine+n-1+"").length;if(this._numOfDigits!==o){this._numOfDigits=o;var r=i.getLineAtOffset(t);this._view.redrawLines(r,i.getLineCount(),this)}},c.prototype=new l,h.prototype=new l,h.prototype.getRulerStyle=function(){var e={style:{lineHeight:"1px",fontSize:"1px"}};return e=this._mergeStyle(e,this._rulerStyle)},h.prototype._getTooltipContents=function(t,i){if(i&&0===i.length){var n=this._view.getModel(),o=t;if(n.getBaseModel){var r=n.getLineStart(o);o=n.getBaseModel().getLineAtOffset(n.mapOffset(r))}return s.formatMessage(e.line,o+1)}return l.prototype._getTooltipContents.call(this,t,i)},h.prototype._mergeAnnotation=function(e,t,i,n){if(0!==i)return void 0;var o=e;if(!o){var r=3*n;o={html:" ",style:{style:{height:r+"px"}}},o.style=this._mergeStyle(o.style,t.overviewStyle)}return o},u.prototype=new c,u.prototype.onClick=function(e){if(void 0!==e){var t=this._annotationModel;if(t){var i=this._view,o=i.getModel(),r=o.getLineStart(e),s=o.getLineEnd(e,!0);o.getBaseModel&&(r=o.mapOffset(r),s=o.mapOffset(s),o=o.getBaseModel());for(var a,l=t.getAnnotations(r,s);!a&&l.hasNext();){var d=l.next();this.isAnnotationTypeVisible(d.type)&&o.getLineAtOffset(d.start)===o.getLineAtOffset(r)&&(a=d)}if(a){var c=n.Tooltip.getTooltip(this._view);c&&c.hide(),a.expanded?a.collapse():a.expand()}}}},u.prototype._getTooltipContents=function(e,t){if(t&&t.length>0){var i=this._view,n=i.getModel(),o=n.getLineStart(e);n.getBaseModel&&(o=n.mapOffset(o),n=n.getBaseModel());for(var r=n.getLineAtOffset(o),s=0;s=e.end?s-=e.end-e.start:s>=e.start&&(s=e.start)}),i.setText(r,s,s),i.setSelection(s,s+r.length),this._dropText=null,this._dropOffset=-1}this._undoStack&&this._undoStack.endCompoundChange(),this._dragSelection=null}},_onDragEnter:function(e){this._onDragOver(e)},_onDragOver:function(t){var i=t.event.dataTransfer.types,n=!this._view.getOptions("readonly");if(n&&i&&(n=i.contains?i.contains("text/plain")||i.contains("Text"):-1!==i.indexOf("text/plain")||-1!==i.indexOf("Text")),n){if(!e.isFirefox){var o=e.isMac?t.event.altKey:t.event.ctrlKey;this._dropEffect=t.event.dataTransfer.dropEffect=o?"copy":"move"}}else t.event.dataTransfer.dropEffect="none"},_onDrop:function(t){var i=this._view,n=t.event.dataTransfer.getData("Text");if(n){e.isFirefox||(t.event.dataTransfer.dropEffect=this._dropEffect);var o=i.getOffsetAtLocation(t.x,t.y);this._dragSelection?(this._dropOffset=o,this._dropText=n):(i.setText(n,o,o),i.setSelection(o,o+n.length))}}},{TextDND:t}}),define("orion/editor/linkedMode",["i18n!orion/editor/nls/messages","orion/keyBinding","orion/editor/keyModes","orion/editor/annotations","orion/objects","orion/util"],function(e,t,i,n,o){function r(e){this._data=e}function s(e,t,n){var o=e.getTextView();i.KeyMode.call(this,o),this.editor=e,this.undoStack=t,this.contentAssist=n,this.linkedModeModel=null,o.setAction("linkedModeEnter",function(){return this.exitLinkedMode(!0),!0}.bind(this)),o.setAction("linkedModeCancel",function(){return this.exitLinkedMode(!0),!0}.bind(this)),o.setAction("linkedModeNextGroup",function(){var e=this.linkedModeModel;return this.selectLinkedGroup((e.selectedGroupIndex+1)%e.groups.length),!0}.bind(this)),o.setAction("linkedModePreviousGroup",function(){var e=this.linkedModeModel;return this.selectLinkedGroup(e.selectedGroupIndex>0?e.selectedGroupIndex-1:e.groups.length-1),!0}.bind(this)),this.linkedModeListener={onActivating:function(){this._groupContentAssistProvider&&(this.contentAssist.setProviders([this._groupContentAssistProvider]),this.contentAssist.setProgress(null))}.bind(this),onModelChanged:function(e){if(!this.ignoreVerify){for(var t,i,n=this.editor.mapOffset(e.start),o=this.linkedModeModel;o&&(t=this._getPositionChanged(o,n,n+e.removedCharCount),i=t.position,void 0===i||i.model!==o);)this.exitLinkedMode(!1),o=this.linkedModeModel;if(o){for(var r,s,a=0,l=e.addedCharCount-e.removedCharCount,d=t.positions,c=0;c=0;f--)l=h[f],l.model===r&&l.group===i.group&&this.editor.setText(e.text,l.oldOffset+u,l.oldOffset+p,!1);this.ignoreVerify=!1,e.text=null,this._updateAnnotations(h)}}}.bind(this)}}var a={};return r.prototype={chop:function(e,t){return t.substring(e.length)},computeProposals:function(e,t,i){var n=i.prefix,o=[],r=this._data.style?this._data.style:null;r=r?r:"emphasis";for(var s=this._data.values,a=0;a=0;r--)if(!o[r].escape){var s=o[r].position;if(s.offset<=t&&i<=s.offset+s.length){n=o[r];break}}return{position:n,positions:o}},_updateAnnotations:function(e){var t=this.editor.getAnnotationModel();if(t){for(var i,o=[],r=[],s=t.getAnnotations();s.hasNext();)switch(i=s.next(),i.type){case n.AnnotationType.ANNOTATION_LINKED_GROUP:case n.AnnotationType.ANNOTATION_CURRENT_LINKED_GROUP:case n.AnnotationType.ANNOTATION_SELECTED_LINKED_GROUP:o.push(i)}var a=this.linkedModeModel;if(a){e=e||this._getSortedPositions(a);for(var l=0;l0?(localStorage.setItem(this._prefix+this._offsetStorageLabel,this._offset),this._closed=!1):this._closed=!0,e!==this._closed&&(localStorage.setItem(this._prefix+"/toggleState",this._closed?"closed":null),i.logEvent("preferenceChange","splitterClosed",this._prefix,this._closed?0:1))},_mouseDown:function(e){return e.target===this._thumb?(n.stop(e),this._thumbDown()):void(this._tracking||(this._down(e),this._tracking=this._mouseMove.bind(this),window.addEventListener("mousemove",this._tracking),n.setFramesEnabled(!1),n.stop(e)))},_mouseMove:function(e){this._tracking&&(this._move(e.clientX,e.clientY),this._resize())},_mouseUp:function(e){this._tracking&&(n.setFramesEnabled(!0),window.removeEventListener("mousemove",this._tracking),this._tracking=null,this._up(),n.stop(e))},_touchStart:function(e){var t=e.touches;if(1===t.length){if(n.stop(e),e.target===this._thumb)return this._thumbDown();this._down(e),this._touching=!0}},_touchMove:function(e){if(this._touching){var t=e.touches;if(1===t.length){var i=t[0];this._move(i.clientX,i.clientY)}}},_touchEnd:function(e){var t=e.touches;0===t.length&&(this._touching=!1,this._up())}},o.prototype.constructor=o,{Splitter:o,ORIENTATION_HORIZONTAL:r,ORIENTATION_VERTICAL:s}}),define("text!orion/compare/sideBySideTemplate.html",[],function(){return'
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n
    \r\n'}),define("orion/compare/compareUIFactory",["orion/webui/littlelib","orion/webui/splitter","text!orion/compare/sideBySideTemplate.html"],function(e,t,i){var n=n||{};return n.TwoWayCompareUIFactory=function(){function n(e){this._parentDivID=e.parentDivID,this._commandSpanId=e.commandSpanId,this._showTitle=e.showTitle,this._leftTitle=e.leftTitle,this._rightTitle=e.rightTitle,this._showLineStatus=e.showLineStatus}return n.prototype={_init:function(){var t=this._parentDivID+"_";this._topWidgetDiv=e.node("topWidget_id"),this._topWidgetDiv.id=t+"topWidget_id",this._leftEditorParentDiv=e.node("left_editor_id"),this._leftEditorParentDiv.id=t+"left_editor_id",this._rightEditorParentDiv=e.node("right_editor_id"),this._rightEditorParentDiv.id=t+"right_editor_id",this._rightEditorWrapperDiv=e.node("right_editor_wrapper_id"),this._rightEditorWrapperDiv.id=t+"right_editor_wrapper_id",this._leftActionDiv=e.node("left_action_id"),this._leftActionDiv.id=t+"left_action_id",this._rightActionDiv=e.node("right_action_id"),this._rightActionDiv.id=t+"right_action_id",this._leftTitleDiv=e.node("left_title_id"),this._leftTitleDiv.id=t+"left_title_id",this._rightTitleDiv=e.node("right_title_id"),this._rightTitleDiv.id=t+"right_title_id",this._leftStatusDiv=e.node("left_status_id"),this._leftStatusDiv.id=t+"left_status_id",this._rightStatusDiv=e.node("right_status_id"),this._rightStatusDiv.id=t+"right_status_id",this._diffCanvasDiv=e.node("diff_canvas_id"),this._diffCanvasDiv.id=t+"diff_canvas_id",this._splitterId=t+"orion_splitter",this._showTitle||this.disableTitle(),this._showLineStatus||this.disableLineStatus()},_createSplitter:function(){var i=e.$(".split",this._topWidgetDiv);i.id=this._splitterId;var n=e.$(".leftPanelLayout",this._topWidgetDiv),o=e.$(".rightPanelLayout",this._topWidgetDiv);i&&n&&o&&(this._splitter=new t.Splitter({node:i,sidePanel:n,mainPanel:o,proportional:!0}))},buildUI:function(){e.node(this._parentDivID).innerHTML=i,this._init(),this._createSplitter()},destroy:function(){},getSplitter:function(){return this._splitter},isLeftPane:function(t){var i=e.$(".leftPanelLayout",this._topWidgetDiv);return i===t},getEditorParentDiv:function(e){return e?this._leftEditorParentDiv:this._rightEditorParentDiv},getTitleDiv:function(e){return e?this._leftTitleDiv:this._rightTitleDiv},getActionDivId:function(e){return e?this._leftActionDiv.id:this._rightActionDiv.id},getStatusDiv:function(e){return e?this._leftStatusDiv:this._rightStatusDiv},getCommandSpanId:function(){return this._commandSpanId},getDiffCanvasDiv:function(){return this._diffCanvasDiv},disableTitle:function(){this._leftEditorParentDiv.style.top="0px",this._rightEditorWrapperDiv.style.top="0px",this._leftTitleDiv.style.height="0px",this._rightTitleDiv.style.height="0px"},disableLineStatus:function(){this._leftEditorParentDiv.style.marginBottom="0px",this._rightEditorWrapperDiv.style.marginBottom="0px",this._leftStatusDiv.style.height="0px",this._rightStatusDiv.style.height="0px"}},n}(),n});var JsDiff=function(){function e(e){return{newPos:e.newPos,components:e.components.slice(0)}}function t(e){for(var t=[],i=0;i/g,">"),t=t.replace(/"/g,""")}var n=function(e){this.ignoreWhitespace=e};n.prototype={diff:function(t,i,n){if(this.ignoreWhitespace=n,i===t)return[{value:i}];if(!i)return[{value:t,removed:!0}];if(!t)return[{value:i,added:!0}];i=this.tokenize(i),t=this.tokenize(t);var o=i.length,r=t.length,s=o+r,a=[{newPos:-1,components:[]}],l=this.extractCommon(a[0],i,t,0);if(a[0].newPos+1>=o&&l+1>=r)return a[0].components;for(var d=1;s>=d;d++)for(var c=-1*d;d>=c;c+=2){var h,u=a[c-1],p=a[c+1];l=(p?p.newPos:0)-c,u&&(a[c-1]=void 0);var f=u&&u.newPos+1=0&&r>l;if(f||g){!f||g&&u.newPos=o&&l+1>=r)return h.components;a[c]=h}else a[c]=void 0}},pushComponent:function(e,t,i,n,o){var r=e[e.length-1];r&&r.added===n&&r.removed===o?e[e.length-1]={value:this.join(r.value,t),helperValue:this.join(r.helperValue,i),added:n,removed:o}:e.push({value:t,helperValue:i,added:n,removed:o})},extractCommon:function(e,t,i,n){for(var o=t.length,r=i.length,s=e.newPos,a=s-n;o>s+1&&r>a+1&&this.equals(t[s+1],i[a+1]);)s++,a++,this.pushComponent(e.components,t[s],i[a],void 0,void 0);return e.newPos=s,a},equals:function(e,t){var i=/\S/;return!this.ignoreWhitespace||i.test(e)||i.test(t)?this._equals(e,t):!0},join:function(e,t){return e+t},tokenize:function(e){return e}};var o=new n;o._equals=function(e,t){return e===t};var r=new n(!1);r.tokenize=function(e){return t(e.split(/(\s+|\b)/))},r._equals=function(e,t){return e===t};var s=new n(!0);s.tokenize=function(e){return t(e.split(/([{}:;,]|\s+)/))},s._equals=function(e,t){return e===t};var a=new n;return a.tokenize=function(e){var t=e.split(/^/m);return t&&t.length>0&&!t[t.length-1]&&t.pop(),t},a._equals=function(e,t){if(this.ignoreWhitespace){var i=e.replace(/^\s+|\s+$|\s+(?=\s)/g,""),n=t.replace(/^\s+|\s+$|\s+(?=\s)/g,"");return i===n}return e===t},{diffChars:function(e,t,i){return o.diff(e,t,i)},diffWords:function(e,t,i){return r.diff(e,t,i)},diffLines:function(e,t,i){return a.diff(e,t,i)},diffCss:function(e,t){return s.diff(e,t)},createPatch:function(e,t,i,n,o){var r=[];r.push("Index: "+e),r.push("==================================================================="),r.push("--- "+e+" "+n),r.push("+++ "+e+" "+o);var s=a.diff(t,i);s.push({value:"",lines:[]});for(var l=0,d=0,c=[],h=1,u=1,p=0;p1&&!/\n$/.test(s[s.length-2].value)&&r.push("\\ No newline at end of file\n"),r.join("\n")},convertChangesToXML:function(e){for(var t=[],n=0;n"):o.removed&&t.push(""),t.push(i(o.value)),o.added?t.push(""):o.removed&&t.push("")}return t.join("")}}}();"undefined"!=typeof module&&(module.exports=JsDiff),"function"==typeof define&&define.amd&&define("jsdiff/diff",[],function(){return JsDiff}),define("orion/compare/jsdiffAdapter",["jsdiff/diff"],function(e){var t=t||{};return t.JSDiffAdapter=function(){function t(e){this._ignoreWhitespace=e}return t.prototype={_specialLine:function(e,t,i){return t.value===e&&i!==e},adapt:function(t,i,n){n||(n="\n");for(var o=t.split(n),r=i.split(n),s=""===o[o.length-1],a=""===r[r.length-1],l=e.diffLines(t,i,this._ignoreWhitespace),d=[],c=[],h=0,u=0,p=-1,f=0,g=!0,_=n,m=0;m1&&""===y[y.length-1]&&x--,x>1&&!g&&""===y[0]&&(x--,b++),v.lines=y,v.added||v.removed)if(v.added){-1===p&&(p=c.length+1),h+=x;for(var w=b;x+b>w;w++)c.push(v.lines[w])}else u+=x;else this._specialLine(n,v,_)||((h||u)&&(d.push([h,u,p]),h=0,u=0,p=-1,f+=u),d.push([x,x,0]),f+=x);g=!1,y.length>1&&""===y[y.length-1]&&(g=!0),_=v.value?v.value[v.value.length-1]:n}if((h||u)&&(d.push([h,u,p]),f+=u),f1){var C=d[d.length-1];0===C[2]?(C[0]+=1,C[1]+=1):-1===C[2]?d.push([1,1,0]):s===a?d.push([1,1,0]):(a&&(C[0]+=1),s&&(C[1]+=1))}return{mapper:d,changContents:{array:c,index:0}}},adaptCharDiff:function(t,i,n){for(var o=n?e.diffWords(t,i,this._ignoreWhitespace):e.diffChars(t,i,this._ignoreWhitespace),r=[],s=0,a=0,l=0,d=0,c=0;c0||d>0)&&(r.push([a,a+l,s,s+d]),a+=l,s+=d,l=0,d=0),a+=h.value.length,s+=h.helperValue?h.helperValue.length:h.value.length)}return(l>0||d>0)&&r.push([a,a+l,s,s+d]),r}},t}(),t}),define("orion/treeModelIterator",[],function(){var e={};return e.TreeModelIterator=function(){function e(e,t){this.firstLevelChildren=e,this.reset(),this._init(t)}return e.prototype={_init:function(e){e&&(this.isExpanded=e.isExpanded,this.isExpandable=e.isExpandable,this.forceExpandFunc=e.forceExpandFunc,this.getChildrenFunc=e.getChildrenFunc)},topLevel:function(e){return e.parent?e.parent===this.root:!0},_getChildren:function(e){return"function"==typeof this.getChildrenFunc?this.getChildrenFunc(e):e?e.children:null},_expanded:function(e){if(!e)return!0;var t=this._getChildren(e),i=t&&t.length>0;return this.isExpanded&&i&&(i=this.isExpanded(e)),i},_expandable:function(e){return e?this.isExpandable?this.isExpandable(e):!1:!0},_diveIn:function(e){if(this._expanded(e)){var t=this._getChildren(e);return this.setCursor(t[0]),this.cursor()}return null},_drillToLast:function(e){if(this._expanded(e)){var t=this._getChildren(e);return this._drillToLast(t[t.length-1])}return e},_forward:function(e){if(!this._cursor)return null;var t=this._diveIn(this._cursor);if(!t){if(e&&this._expandable(this._cursor)&&this.forceExpandFunc){var i=this;return this.forceExpandFunc(this._cursor,"first",function(e){e&&i.setCursor(e)})}t=this._findSibling(this._cursor,!0),t&&this.setCursor(t)}return t},_backward:function(e){if(!this._cursor)return null;var t=this._findSibling(this._cursor,!1);if(t&&t!==this._cursor.parent&&(t=this._drillToLast(t)),e&&t&&this._expandable(t)&&this.forceExpandFunc&&t!==this._cursor.parent){var i=this;return this.forceExpandFunc(t,"last",function(e){e&&i.setCursor(e)})}return t&&this.setCursor(t),t},_findSibling:function(e,t){for(var i=this.topLevel(e),n=this._getChildren(e.parent),o=i?this.firstLevelChildren:n,r=0;r0&&(this.root=this.firstLevelChildren[0].parent)},scan:function(e,t){var i=this.cursor(),n=this._scan(!0,e,t);return n||(n=this._scan(!1,e,t)),this.setCursor(i),n},iterate:function(e,t){return e?this._forward(t):this._backward(t)},iterateOnTop:function(e,t){var i=this._findSibling(this._getTopLevelParent(this.cursor()),e);i?this.setCursor(i):t&&this.firstLevelChildren.length>0&&this.setCursor(e?this.firstLevelChildren[0]:this.firstLevelChildren[this.firstLevelChildren.length-1])},collapse:function(e){return this._cursor&&this._inParentChain(this._cursor,e)?(this.setCursor(e),this._cursor):null},reset:function(){this._cursor=null,this._prevCursor=null,this.root=null,this.firstLevelChildren.length>0&&(this._cursor=this.firstLevelChildren[0],this.root=this.firstLevelChildren[0].parent)},cursorMoved:function(){return this._cursor!==this._prevCursor},cursor:function(){return this._cursor},prevCursor:function(){return this._prevCursor}},e}(),e}),define("orion/compare/diffTreeNavigator",["i18n!orion/compare/nls/messages","orion/treeModelIterator","orion/compare/compareUtils","orion/editor/annotations","orion/compare/jsdiffAdapter"],function(e,t,i,n,o){var r={},s={};return r.DiffTreeNavigator=function(){function r(e,t,i,n,o,r){this._root={type:"root",children:[]},this._initialized=!1,this.initAll(e,t,i,n,o,r)}s.ANNO_DIFF_ADDED_BLOCK="orion.annotation.diff.addedBlock",s.ANNO_DIFF_CURRENT_ADDED_BLOCK="orion.annotation.diff.currentAddedBlock",s.ANNO_DIFF_DELETED_BLOCK="orion.annotation.diff.deletedBlock",s.ANNO_DIFF_CURRENT_DELETED_BLOCK="orion.annotation.diff.currentDeletedBlock",s.ANNO_DIFF_BLOCK_TOPONLY="orion.annotation.diff.blockTop",s.ANNO_DIFF_CURRENT_BLOCK_TOPONLY="orion.annotation.diff.currentBlockTop",s.ANNO_DIFF_BLOCK_CONFLICT="orion.annotation.diff.blockConflict",s.ANNO_DIFF_CURRENT_BLOCK_CONFLICT="orion.annotation.diff.currentBlockConflict",s.ANNO_DIFF_ADDED_WORD="orion.annotation.diff.addedWord",s.ANNO_DIFF_CURRENT_ADDED_WORD="orion.annotation.diff.currentAddedWord",s.ANNO_DIFF_DELETED_WORD="orion.annotation.diff.deletedWord",s.ANNO_DIFF_CURRENT_DELETED_WORD="orion.annotation.diff.currentDeletedWord",s.ANNO_DIFF_EMPTY_DELETED_WORD_LEFT="orion.annotation.diff.emptyDeletedWordLeft",s.ANNO_DIFF_EMPTY_DELETED_WORD_RIGHT="orion.annotation.diff.emptyDeletedWordRight",s.ANNO_DIFF_EMPTY_ADDED_WORD_LEFT="orion.annotation.diff.emptyAddedWordLeft",s.ANNO_DIFF_EMPTY_ADDED_WORD_RIGHT="orion.annotation.diff.emptyAddedWordRight",n.AnnotationType.registerType(s.ANNO_DIFF_ADDED_BLOCK,{title:"",html:"",lineStyle:{styleClass:"annotationLine addedBlockDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_ADDED_BLOCK,{title:"",html:"",lineStyle:{styleClass:"annotationLine currentAddedBlockDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_DELETED_BLOCK,{title:"",html:"",lineStyle:{styleClass:"annotationLine deletedBlockDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_DELETED_BLOCK,{title:"",html:"",lineStyle:{styleClass:"annotationLine currentDeletedBlockDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_BLOCK_TOPONLY,{title:"",html:"",lineStyle:{styleClass:"annotationLine blockDiffTopOnly"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_BLOCK_TOPONLY,{title:"",html:"",lineStyle:{styleClass:"annotationLine currentBlockDiffTopOnly"}}),n.AnnotationType.registerType(s.ANNO_DIFF_BLOCK_CONFLICT,{title:"",html:"",lineStyle:{styleClass:"annotationLine blockDiffConflict"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_BLOCK_CONFLICT,{title:"",html:"",lineStyle:{styleClass:"annotationLine currentBlockDiffConflict"}}),n.AnnotationType.registerType(s.ANNO_DIFF_ADDED_WORD,{title:e["word added"],html:"",rangeStyle:{styleClass:"annotationRange addedWordDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_ADDED_WORD,{title:"",html:"",rangeStyle:{styleClass:"annotationRange currentAddedWordDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_DELETED_WORD,{title:e["word deleted"],html:"",rangeStyle:{styleClass:"annotationRange deletedWordDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_CURRENT_DELETED_WORD,{title:"",html:"",rangeStyle:{styleClass:"annotationRange currentDeletedWordDiff"}}),n.AnnotationType.registerType(s.ANNO_DIFF_EMPTY_DELETED_WORD_LEFT,{title:"",html:"",rangeStyle:{styleClass:"annotationRange emptyDeletedWordDiffLeft"}}),n.AnnotationType.registerType(s.ANNO_DIFF_EMPTY_DELETED_WORD_RIGHT,{title:"",html:"",rangeStyle:{styleClass:"annotationRange emptyDeletedWordDiffRight"}}),n.AnnotationType.registerType(s.ANNO_DIFF_EMPTY_ADDED_WORD_LEFT,{title:"",html:"",rangeStyle:{styleClass:"annotationRange emptyAddedWordDiffLeft"}}),n.AnnotationType.registerType(s.ANNO_DIFF_EMPTY_ADDED_WORD_RIGHT,{title:"",html:"",rangeStyle:{styleClass:"annotationRange emptyAddedWordDiffRight"}});var a=5e3;return r.prototype={initAll:function(e,t,i,n,o,r,s){this._charOrWordDiff=e?e:"word",t&&(this._initialized=!0),this.editorWrapper=[{editor:t,diffFeeder:n},{editor:i,diffFeeder:o}],this._curveRuler=s,this._overviewRuler=r,this._overviewRuler&&this._overviewRuler.setDiffNavigator(this)},initMapper:function(e){if(e)for(var t=0;t0&&this.iterator.iterate(e),this.updateCurrentAnnotation(!0)}return t},gotoChangeUsingIndex:function(e){var t=0,i=0;if(e>=0)for(;it+n-1)){var o=e-t;return this.gotoBlock(i,o)}t+=n,i++}},gotoBlock:function(e,t){this.iterator&&((0>e||e>=this._root.children.length||0===this._root.children.length)&&(e=0),this.iterator.setCursor(void 0!==t&&t>=0&&this._root.children[e].children&&t=r.start&&t<=r.end){var s=o;if(o.children&&o.children.length>0)for(var a=0;a=d.start&&t<=d.end){s=l;break}}return s}}return null}},gotoChange:function(e,t){for(var i=0;ie&&(e=0);var t=this.getFeeder().getDiffBlocks();return t&&0!==t.length?(e>t.length-1&&(e=0),t[e][1]):-1},replaceDiffAnnotations:function(e,t,i,n){if(t&&i){var o=e.getAnnotationModel();if(o){for(var r=o.getAnnotations(),s=[];n&&r.hasNext();){var a=r.next();a.type===i&&s.push(a)}o.replaceAnnotations(s,t)}}},updateCurrentAnnotation:function(e,t){if(this.replaceAllAnnotations(!0,0,"block",!1,[]),this.replaceAllAnnotations(!0,1,"block",!1,[]),this.replaceAllAnnotations(!0,0,"word",!1,[]),this.replaceAllAnnotations(!0,1,"word",!1,[]),this.iterator){var i=this.iterator.cursor();if(i){var o,r,s={start:i.oldA.start,end:i.oldA.end},a={start:i.newA.start,end:i.newA.end};"word"===i.type?(o=this.editorWrapper[0].diffFeeder.getCurrentWordAnnoType(s,this.editorWrapper[0].editor.getTextView().getModel()),r=this.editorWrapper[1].diffFeeder.getCurrentWordAnnoType(a,this.editorWrapper[1].editor.getTextView().getModel())):(o=this.editorWrapper[0].diffFeeder.getCurrentBlockAnnoType(i.index),r=this.editorWrapper[1].diffFeeder.getCurrentBlockAnnoType(i.index)),o&&this.replaceDiffAnnotations(this.editorWrapper[0].editor,[new(n.AnnotationType.getType(o.current))(s.start,s.end)],o,!0),r&&this.replaceDiffAnnotations(this.editorWrapper[1].editor,[new(n.AnnotationType.getType(r.current))(a.start,a.end)],r,!0),e?(this.autoSelecting=!0,this.editorWrapper[0].editor.setSelection(i.oldA.start,i.oldA.end,!0),this.editorWrapper[1].editor.setSelection(i.newA.start,i.newA.end,!0),this.autoSelecting=!1):t&&(this.autoSelecting=!0,t!==this.editorWrapper[0].editor.getTextView()&&this.editorWrapper[0].editor.setSelection(i.oldA.start,i.oldA.end,!0),t!==this.editorWrapper[1].editor.getTextView()&&this.editorWrapper[1].editor.setSelection(i.newA.start,i.newA.end,!0),this.autoSelecting=!1)}}},generatePairBlockAnnotations:function(e,t){var i=this.generateBlockDiffAnnotations(0,t),n=this.generateBlockDiffAnnotations(1,t);return{parent:e,index:t,type:"block",oldA:i,newA:n}},generatePairWordAnnotations:function(e,t,i){var n=this.editorWrapper[0].diffFeeder.getTextOnBlock(t),o=this.editorWrapper[1].diffFeeder.getTextOnBlock(t),r=null,s=0,l=0;if(!(n&&o&&n.text&&o.text&&n.text.length<=a&&o.text.length<=a))return null;r=i.adaptCharDiff(n.text,o.text,"word"===this._charOrWordDiff),l=o.start,s=n.start;var d=[],c=[];this.generateWordDiffAnnotations(0,d,s,r,2,3),this.generateWordDiffAnnotations(1,c,l,r,0,1);for(var h=[],u=0;u0?t-o:0)},_positionDiffBlock:function(){var e=this.getCurrentBlockIndex();0>e&&(e=0);var t=this.getFeeder().getDiffBlocks();if(0!==t.length){if(this._setTextViewPosition(this.editorWrapper[0].editor.getTextView(),t[e][0]),this.editorWrapper[0].editor!==this.editorWrapper[1].editor){var n=i.lookUpLineIndex(this.getMapper(),0,t[e][1]);this._setTextViewPosition(this.editorWrapper[1].editor.getTextView(),n)}this._updateOverviewRuler(),this._updateCurveRuler()}},matchPositionFromOverview:function(e){if(this._initialized){var t;t=0>e?0:i.getAnnotationIndex(this.getFeeder().getDiffBlocks(),e),this.gotoBlock(t)}},gotoDiff:function(e,t){this.gotoChange(e,t)&&(this._updateOverviewRuler(),this._updateCurveRuler())},nextDiff:function(){this.iterateOnBlock(!0,!0),this._positionDiffBlock()},prevDiff:function(){this.iterateOnBlock(!1,!0),this._positionDiffBlock()},nextChange:function(){var e=this.iterateOnChange(!0);return this._positionDiffBlock(),e},prevChange:function(){this.iterateOnChange(!1),this._positionDiffBlock()}},r}(),r.DiffBlockFeeder=function(){function e(){}return e.prototype={_isAddedSide:function(){return 0===this._mapperColumnIndex},getWordAnnoTypes:function(e){e.push(this._isAddedSide()?{type:"word",current:s.ANNO_DIFF_CURRENT_ADDED_WORD,normal:s.ANNO_DIFF_ADDED_WORD,list:[]}:{type:"word",current:s.ANNO_DIFF_CURRENT_DELETED_WORD,normal:s.ANNO_DIFF_DELETED_WORD,list:[]}),e.push({type:"word",current:s.ANNO_DIFF_EMPTY_DELETED_WORD_LEFT}),e.push({type:"word",current:s.ANNO_DIFF_EMPTY_DELETED_WORD_RIGHT}),e.push({type:"word",current:s.ANNO_DIFF_EMPTY_ADDED_WORD_LEFT}),e.push({type:"word",current:s.ANNO_DIFF_EMPTY_ADDED_WORD_RIGHT})},getCurrentWordAnnoType:function(e,t){return e.start===e.end&&t?this._isAddedSide()?{current:this._repositionEmptyWord(e,t),normal:s.ANNO_DIFF_ADDED_WORD}:{current:this._repositionEmptyWord(e,t),normal:s.ANNO_DIFF_DELETED_WORD}:this._isAddedSide()?{current:s.ANNO_DIFF_CURRENT_ADDED_WORD,normal:s.ANNO_DIFF_ADDED_WORD}:{current:s.ANNO_DIFF_CURRENT_DELETED_WORD,normal:s.ANNO_DIFF_DELETED_WORD}},_repositionEmptyWord:function(e,t){var i=t.getLineAtOffset(e.start),n=t.getLineStart(i),o=t.getLineEnd(i);return n!==o?e.start===o?(e.start--,this._isAddedSide()?s.ANNO_DIFF_EMPTY_ADDED_WORD_RIGHT:s.ANNO_DIFF_EMPTY_DELETED_WORD_RIGHT):(e.end++,this._isAddedSide()?s.ANNO_DIFF_EMPTY_ADDED_WORD_LEFT:s.ANNO_DIFF_EMPTY_DELETED_WORD_LEFT):i>0&&(i--,n=t.getLineStart(i),o=t.getLineEnd(i),n!==o)?(e.start=o-1,e.end=o,this._isAddedSide()?s.ANNO_DIFF_EMPTY_ADDED_WORD_RIGHT:s.ANNO_DIFF_EMPTY_DELETED_WORD_RIGHT):this._isAddedSide()?s.ANNO_DIFF_EMPTY_ADDED_WORD_LEFT:s.ANNO_DIFF_EMPTY_DELETED_WORD_LEFT},getMapper:function(){return this._mapper},getDiffBlocks:function(){return this._diffBlocks},getDiffBlockH:function(e){if(!this._diffBlocks||0===this._diffBlocks.length)return-1;var t=this._diffBlocks[e][1];return-1===t?0:this._mapper[t][this._mapperColumnIndex] +},getOverviewLineCount:function(){return this._textModel.getLineCount()},getLineNumber:function(e){return e},getCharRange:function(e){if(!this._diffBlocks||0===this._diffBlocks.length)return null;var t=this._diffBlocks[e][1],i=this._diffBlocks[e][0],n=i+this._mapper[t][this._mapperColumnIndex]-1,o=this._textModel.getLineStart(i);if(i>n)return{start:o,end:o};var r=this._textModel.getLineEnd(n,!0);return{start:o,end:r}},getTextOnBlock:function(e){if(!this._diffBlocks||0===this._diffBlocks.length)return null;var t=this._diffBlocks[e][1];0===this._mapper[t][0]||0===this._mapper[t][1]||0===this._mapper[t][2];var i=this.getCharRange(e);return{start:i.start,text:this._textModel.getText(i.start,i.end)}},isMapperEmpty:function(){return 0===this._mapper.length}},e}(),r.TwoWayDiffBlockFeeder=function(){function e(e,t,i,n){this._mapperColumnIndex=i,this._reverseAnnotation=n,this.init(e,t)}return e.prototype=new r.DiffBlockFeeder,e.prototype._isAddedSide=function(){return this._reverseAnnotation?0!==this._mapperColumnIndex:0===this._mapperColumnIndex},e.prototype.init=function(e,t){if(this._textModel=e,this._diffBlocks=void 0,t){this._mapper=t,this._diffBlocks=[];for(var i=0,n=0;n=this._gapBlocks[t][0]&&e0){if(e.length<1||e.length>2)return;this._syntaxHighlighters=[{highlighter:this.options.highlighters[0],target:e[0]}],2===e.length&&2===this.options.highlighters.length&&this._syntaxHighlighters.push({highlighter:this.options.highlighters[1],target:e[1]})}},_highlightSyntax:function(){if(this._syntaxHighlighters){var e=[];this._syntaxHighlighters.forEach(function(t){e.push(t.highlighter.highlight(t.target.fileName,t.target.contentType,t.target.editor))}.bind(this)),t.all(e,function(e){return{_error:e}}).then(function(){this._diffNavigator.renderAnnotations(this.isWhitespaceIgnored()),this._diffNavigator.gotoBlock(this.options.blockNumber-1,this.options.changeNumber-1),this.dispatchEvent({type:"contentLoaded"}),this.options.toggler&&this.options.toggler.dispatchEvent({type:"contentLoaded"})}.bind(this))}else window.setTimeout(function(){this._diffNavigator.renderAnnotations(this.isWhitespaceIgnored()),this._diffNavigator.gotoBlock(this.options.blockNumber-1,this.options.changeNumber-1),this.dispatchEvent({type:"contentLoaded"}),this.options.toggler&&this.options.toggler.dispatchEvent({type:"contentLoaded"})}.bind(this),50)},isWhitespaceIgnored:function(){return this.getWidget().options.ignoreWhitespace},ignoreWhitespace:function(e){var t=this.getWidget().options;if(t.ignoreWhitespace=e,t.diffProvider&&t.diffContent){var i=e?"true":"false";t.diffProvider._diffProvider.getDiffContent(t.resource,{ignoreWS:i}).then(function(e){t.diffContent=t.hasConflicts?e.split("diff --git")[1]:e,this.getWidget().refresh(!0,!0)}.bind(this),function(){})}else this.getWidget().refresh(!0,!0)},setOptions:function(e,t){if(t&&this._clearOptions(),this.options||(this.options={}),e&&Object.keys(e).forEach(function(t){this.options[t]=e[t]}.bind(this)),e.newFileOnRight){var i=this.options.newFile;this.options.newFile=this.options.oldFile,this.options.oldFile=i}},getOptions:function(){return this.options},getCurrentDiffPos:function(){return this._diffNavigator.getCurrentPosition()},initDiffNav:function(){this._diffNavigator.gotoBlock(0,0)},nextDiff:function(){this._diffNavigator.nextDiff()},prevDiff:function(){this._diffNavigator.prevDiff()},nextChange:function(){return this._diffNavigator.nextChange()},prevChange:function(){this._diffNavigator.prevChange()},getWidget:function(){return this},startup:function(){this.initEditors(),this.refresh(!0)},initEditors:function(){},initImageMode:function(){}},e}(),g.TwoWayCompareView=function(){function i(e){g.CompareView.call(this,e),this.setOptions(e,!0),this._diffNavigator=new f.DiffTreeNavigator("word"),this.type="twoWay",this._uiFactory=this.options.uiFactory,this._uiFactory||(this._uiFactory=new h.TwoWayCompareUIFactory({parentDivID:this.options.parentDivId,showTitle:this.options.showTitle?this.options.showTitle:!1,showLineStatus:this.options.showLineStatus?this.options.showLineStatus:!1}),this._uiFactory.buildUI()),this._viewLoadedCounter=0,this.options.commandProvider&&this.options.commandProvider.initCommands(this),this._curveRuler=new r.CompareCurveRuler(this._uiFactory.getDiffCanvasDiv())}return i.prototype=Object.create(g.CompareView.prototype),i.prototype.initEditors=function(t){this.options.preCreate&&this.options.preCreate(),this._editors=[],this._editors.push(this._createEditor(t,this._uiFactory.getEditorParentDiv(!1),this._uiFactory.getStatusDiv(!1),this.options.oldFile)),this._editors.push(this._createEditor(t,this._uiFactory.getEditorParentDiv(!0),this._uiFactory.getStatusDiv(!0),this.options.newFile,!0)),this._overviewRuler=new r.CompareOverviewRuler("right",{styleClass:"ruler overview"},null,function(e){this._diffNavigator.matchPositionFromOverview(e)}.bind(this)),this.options.postCreate&&this.options.postCreate(),window.onbeforeunload=function(){return this.isDirty()?e["There are unsaved changes."]:void 0}.bind(this)},i.prototype.disableAnnoBookMark=function(){this._disableAnnoBookMark(this._editors)},i.prototype.initImageMode=function(){this._editors&&(this._editors.forEach(function(e){e.destroy()}),this._editors=null),this._uiFactory.getEditorParentDiv(!0).classList.add("compareEditorParentImageMode"),this._uiFactory.getEditorParentDiv().classList.add("compareEditorParentImageMode"),this._uiFactory.disableTitle(),this._uiFactory.disableLineStatus(),this._imageMode=!0},i.prototype.getImageMode=function(){return this._imageMode},i.prototype.getEditors=function(){return this._editors},i.prototype.gotoDiff=function(e,t,i){var n=i?this._editors[1].getTextView():this._editors[0].getTextView(),o=n.getModel().getLineStart(e)+t;this._diffNavigator.gotoDiff(o,n)},i.prototype.copyToLeft=function(){this._curveRuler.copyTo(!0)},i.prototype.copyToRight=function(){this._curveRuler.copyTo(!1)},i.prototype.resizeEditors=function(){this._editors.forEach(function(e){e.getTextView().resize()})},i.prototype.getSplitter=function(){return this._uiFactory.getSplitter()},i.prototype._createEditor=function(t,i,n,o,r){var l="undefined"==typeof o.readonly?!0:o.readonly,h=function(){var e=new c.TextView({parent:i,readonly:l,theme:d.TextTheme.getTheme("nothing"),tabSize:4});this._viewLoadedCounter++,2===this._viewLoadedCounter&&this._diffNavigator.matchPositionFromOverview(-1),this.onLoad&&this.onLoad();var t=this.getSplitter();return t&&t.addResizeListener(function(t){if(t){var i=!1;i=this._uiFactory.isLeftPane(t)?r:!r,i&&e.resize()}}.bind(this)),e}.bind(this),u=o.keyBindingFactory;u||(u=new a.KeyBindingsFactory);var p=null;if(n){var f="",g="";p=function(t,i){n&&(g=i?e["ERROR: "]+t:t,n.textContent=f+g)}}var _=new s.Editor({textViewFactory:h,undoStackFactory:new a.UndoFactory,annotationFactory:new a.AnnotationFactory,keyBindingFactory:u,statusReporter:p,domNode:i});_.installTextView(),_.setInput(null,null,o.Content?o.Content:t),_.setOverviewRulerVisible(!1);var m=_.getTextView();return m.addEventListener("Selection",function(e){var t=Array.isArray(e.newValue)?e.newValue:[e.newValue];t.length>1||!t[0].isEmpty()||!this._diffNavigator.autoSelecting&&this._diffNavigator.editorWrapper[0].diffFeeder&&this._diffNavigator.gotoDiff(t[0].getCaret(),m)}.bind(this)),m.getModel().addEventListener("Changed",function(e){this._curveRuler.onChanged(e,!r)||(this.options.mapper=null)}.bind(this)),r?m.addEventListener("Scroll",function(){this._curveRuler&&(this._curveRuler.matchPositionFrom(!0),this._curveRuler.render()),this.onScroll&&this.onScroll()}.bind(this)):m.addEventListener("Scroll",function(){this._curveRuler&&this._curveRuler.render()}.bind(this)),_},i.prototype.isDirty=function(){return this._editors?this._editors.some(function(e){return e.isDirty()}):!1},i.prototype._destroy=function(){this._editors&&(this._diffNavigator.destroy(),this._editors.forEach(function(e){e.destroy()}),this._uiFactory.destroy())},i.prototype.destroy=function(){this._destroyed=!0,this._destroy()},i.prototype.addRulers=function(){if(this._editors&&!this._hasRuler){var e=new r.LineNumberCompareRuler(this._diffNavigator,0,"left",{styleClass:"ruler lines"},{styleClass:"rulerLines odd"},{styleClass:"rulerLines even"}),t=new r.LineNumberCompareRuler(this._diffNavigator,0,"left",{styleClass:"ruler lines"},{styleClass:"rulerLines odd"},{styleClass:"rulerLines even"});this._editors[1].getTextView().addRuler(e),this._editors[0].getTextView().addRuler(t),this._editors[0].getTextView().addRuler(this._overviewRuler),this._hasRuler=!0}},i.prototype.refresh=function(e,i,n){if(!this._destroyed){if(this._imageMode){this.options.commandProvider&&this.options.commandProvider.renderCommands(this);var o=this;return this._loadImageFile(this.options.newFile.URL,this._uiFactory.getEditorParentDiv(!0)).then(function(e){return o._loadImageFile(o.options.oldFile.URL,o._uiFactory.getEditorParentDiv()).then(function(i){return(new t).resolve(e>i?e:i)})})}var r=this._generateMapper(i,this.options.oldFile.Content,this.options.newFile.Content,this.options.diffContent,this.options.hasConflicts,!this.options.toggler),s=this.options.oldFile.Content,a=this.options.newFile.Content;"string"!=typeof a&&(a=r.output);var l=new f.TwoWayDiffBlockFeeder(this._editors[0].getTextView().getModel(),r.mapper,1,this.options.newFileOnRight),d=new f.TwoWayDiffBlockFeeder(this._editors[1].getTextView().getModel(),r.mapper,0,this.options.newFileOnRight);this._diffNavigator.initAll(this.options.charDiff?"char":"word",this._editors[0],this._editors[1],l,d,this._overviewRuler,this._curveRuler),this._curveRuler.init(r.mapper,this._editors[1],this._editors[0],this._diffNavigator),e&&("number"==typeof n?1===n?this._editors[1].setInput(this.options.newFile.Name,null,a):this._editors[0].setInput(this.options.oldFile.Name,null,s):(this._editors[1].setInput(this.options.newFile.Name,null,a),this._editors[0].setInput(this.options.oldFile.Name,null,s))),this._initSyntaxHighlighter([{fileName:this.options.newFile.Name,contentType:this.options.newFile.Type,editor:this._editors[1]},{fileName:this.options.oldFile.Name,contentType:this.options.oldFile.Type,editor:this._editors[0]}]),this._highlightSyntax(),this.options.commandProvider&&this.options.commandProvider.renderCommands(this),this.addRulers(),2===this._viewLoadedCounter&&this._diffNavigator.gotoBlock(this.options.blockNumber-1,this.options.changeNumber-1),this.refreshTitle(0),this.refreshTitle(1);var c=this._editors[1].getTextView().getModel().getLineCount()*this._editors[1].getTextView().getLineHeight()+5,h=this._editors[0].getTextView().getModel().getLineCount()*this._editors[0].getTextView().getLineHeight()+5;return c>h?c:h}},i.prototype.refreshTitle=function(e,t){var i,o=this.options.newFile.Name,r=this.options.oldFile.Name,s="/",a=" ... ",l=o.split(s),d=r.split(s),c=[],h=[],u=!1;for(i=0;i1||!t[0].isEmpty()||!this._diffNavigator.autoSelecting&&this._diffNavigator.editorWrapper[0].diffFeeder&&this._diffNavigator.gotoDiff(t[0].getCaret(),this._textView)}.bind(this))},i.prototype.disableAnnoBookMark=function(){this._disableAnnoBookMark([this._editor])},i.prototype.initImageMode=function(){this._editor&&(this._editor.destroy(),this._editor=null),n.node(this._editorDiv).classList.add("compareEditorParentImageMode"),this._imageMode=!0},i.prototype.getImageMode=function(){return this._imageMode},i.prototype._initDiffPosition=function(e){var t=e.getModel();if(t&&t.getAnnotations){var i=t.getAnnotations();if(i.length>0){var n=i[0][0],o=e.getLineHeight(),r=e.getClientArea(),s=Math.floor(r.height/o/3);e.setTopIndex(n-s>0?n-s:0)}}},i.prototype.refresh=function(i,o){if(!this._destroyed){if(this._imageMode){this.options.commandProvider&&this.options.commandProvider.renderCommands(this);var r=this;return this._loadImageFile(this.options.newFile.URL,n.node(this._editorDiv),!0).then(function(e){return r._loadImageFile(r.options.oldFile.URL,n.node(r._editorDiv)).then(function(i){return(new t).resolve(e+i+20)})})}var s=this._generateMapper(o,this.options.oldFile.Content,this.options.newFile.Content,this.options.diffContent,this.options.hasConflicts,!this.options.toggler);if(s.submoduleChanged)switch(s.submoduleChanged){case"removed":this._textView.getModel().setText(e["Removed Submodule Message"]);break;case"added":this._textView.getModel().setText(e["Added Submodule Message"])}else{this._mapper=s.mapper,this._textView.getModel().setText(this.options.oldFile.Content);var a=new f.inlineDiffBlockFeeder(s.mapper,1),l=new f.inlineDiffBlockFeeder(s.mapper,0);u.mergeDiffBlocks(this._textView.getModel(),l.getDiffBlocks(),s.mapper,s.diffArray.array,s.diffArray.index,this._diffParser._lineDelimiter),a.setModel(this._textView.getModel()),l.setModel(this._textView.getModel()),this._diffNavigator.initAll(this.options.charDiff?"char":"word",this._editor,this._editor,a,l,this._overviewRuler),this._initSyntaxHighlighter([{fileName:this.options.oldFile.Name,contentType:this.options.oldFile.Type,editor:this._editor}]),this._highlightSyntax(),this.options.commandProvider&&this.options.commandProvider.renderCommands(this),this.removeRulers(),this.addRulers();var d=this._textView.getTopIndex();this._textView.redrawLines(d,d+1,this._overviewRuler),this._textView.redrawLines(d,d+1,this._rulerOrigin),this._textView.redrawLines(d,d+1,this._rulerNew),this._diffNavigator.gotoBlock(this.options.blockNumber-1,this.options.changeNumber-1)}return this._textView.getLineHeight()*this._textView.getModel().getLineCount()+5}},i.prototype.setConflicting=function(e){this._conflcit=e},i.prototype.gotoDiff=function(e){this._diffNavigator.gotoChangeUsingIndex(e)},i.prototype.gotoLine=function(e,t,i,n){"number"!=typeof t&&(t=0);var o=u.convertMergedLineNumber(this._mapper,e),r=function(){n&&n(o)}.bind(this);this._editor.onGotoLine(o,t,i,r)},i.prototype.getMainEditor=function(){return this._editor?this._editor:null},i.prototype.getLineNumber=function(e,t,i){if(t){var n=this._diffNavigator.getFeeder(i?!1:!0);return n?n.getLineNumber(e):e}var o=u.convertMergedLineNumber(this._mapper,e,i);return o},i}(),g.toggleableCompareView=function(){function e(e,t){i.attach(this),t&&(t.toggler=this),this._widget="inline"===e?new g.InlineCompareView(t):new g.TwoWayCompareView(t)}return e.prototype={startup:function(){this._widget.startup()},initImageMode:function(){this._imageMode=!0,this._widget.initImageMode()},_toggle:function(e){this._widget.destroy(),n.empty(n.node(e.parentDivId)),this._widget="inline"===this._widget.type?new g.TwoWayCompareView(e):new g.InlineCompareView(e),this._imageMode?this._widget.initImageMode():this._widget.initEditors(),this._widget.refresh(!0),e.onInputChanged&&"twoWay"===this._widget.type&&e.onInputChanged()},toggle:function(){var e=this._widget.options;if(!this._imageMode){var t=this._widget.getCurrentDiffPos();e.blockNumber=t.block,e.changeNumber=t.change}this._toggle(e)},isDirty:function(){return this._widget.isDirty()},destroy:function(){return this._widget.destroy()},getWidget:function(){return this._widget}},e}(),g}),define("orion/compare/compareCommands",["i18n!orion/compare/nls/messages","orion/commands","orion/Deferred","orion/keyBinding","orion/webui/littlelib","orion/EventTarget"],function(e,t,i,n,o,r){var s={};return s.CompareCommandFactory=function(){function s(e){r.attach(this),this.setOptions(e,!0)}return s.prototype={setOptions:function(e,t){t&&(this.options={}),this.options||(this.options={}),e&&Object.keys(e).forEach(function(t){this.options[t]=e[t]}.bind(this))},getOptions:function(){return this.options},initCommands:function(o){var r=this.options.commandSpanId,s=this.options.toggleCommandSpanId,a=this.options.commandService;if(a&&(r||s)){var l=new t.Command({name:e.CpCurChangeRightToLeft,tooltip:e.CpCurChangeRightToLeft,imageClass:"core-sprite-leftarrow",id:"orion.compare.copyToLeft",groupId:"orion.compareGroup",visibleWhen:function(){return"twoWay"===o.type&&!o.getImageMode()&&o.options.newFile&&!o.options.newFile.readonly}.bind(this),callback:function(e){e.items.copyToLeft()}}),d=new t.Command({name:e.CpCurChangeLeftToRight,tooltip:e.CpCurChangeLeftToRight,imageClass:"core-sprite-rightarrow",id:"orion.compare.copyToRight",groupId:"orion.compareGroup",visibleWhen:function(){return"twoWay"===o.type&&!o.getImageMode()&&o.options.oldFile&&!o.options.oldFile.readonly}.bind(this),callback:function(e){e.items.copyToRight()}}),c=new t.Command({tooltip:e.IgnoreWhitespaceTooltip,name:e.IgnoreWhitespace,imageClass:"core-sprite-whitespace",id:"orion.compare.ignoreWhitespace",groupId:"orion.compareGroup",type:"toggle",visibleWhen:function(t){var i=t.isWhitespaceIgnored();return c.checked=i,c.name=i?e.UseWhitespace:e.IgnoreWhitespace,c.tooltip=i?e.UseWhitespaceTooltip:e.IgnoreWhitespaceTooltip,!0},preCallback:function(t){var n=t.handler.getWidget();if("function"==typeof n.options.onSave&&n.isDirty()){var o=window.confirm(e.confirmUnsavedChanges);return o?n.options.onSave(o):(new i).resolve()}return(new i).resolve(!0)},callback:function(e){e.items.ignoreWhitespace(c.checked),this.dispatchEvent({type:"compareConfigChanged",name:"ignoreWhiteSpace",value:c.checked})}.bind(this)}),h=new t.Command({tooltip:e["Switch to unified diff"],name:e.Unified,imageClass:"compare-sprite-inline-2way",id:"orion.compare.toggleInline2Way",groupId:"orion.compareGroup",type:"switch",visibleWhen:function(t){if(!t.options.toggler)return!1;var i="twoWay"===t.options.toggler.getWidget().type;return h.checked=!i,h.name=i?e.Unified:e["Side by side"],h.tooltip=i?e["Switch to unified diff"]:e["Switch to side by side diff"],!0},preCallback:function(t){var n=t.handler.getWidget();if("function"==typeof n.options.onSave&&n.isDirty()){var o=window.confirm(e.confirmUnsavedChanges);return o?n.options.onSave(o):(new i).resolve()}return(new i).resolve(!0)},callback:function(e){this.dispatchEvent({type:"compareConfigChanged",name:"mode",value:"twoWay"===e.items.options.toggler.getWidget().type?"inline":"twoWay"}),e.items.options.toggler.toggle()}.bind(this)}),u=new t.Command({name:e["Next diff block"],tooltip:e["Next diff block"],imageClass:"core-sprite-move-down",id:"orion.compare.nextDiff",groupId:"orion.compareGroup",visibleWhen:function(){return!o.getImageMode()},callback:function(e){e.items.nextDiff()}}),p=new t.Command({name:e["Previous diff block"],tooltip:e["Previous diff block"],imageClass:"core-sprite-move-up",id:"orion.compare.prevDiff",groupId:"orion.compareGroup",visibleWhen:function(){return!o.getImageMode()},callback:function(e){e.items.prevDiff()}}),f=new t.Command({name:e["Next diff change"],tooltip:e["Next diff change"],imageClass:"core-sprite-move-down",id:"orion.compare.nextChange",groupId:"orion.compareGroup",visibleWhen:function(){return!o.getImageMode()},callback:function(e){e.items.nextChange()}}),g=new t.Command({name:e["Previous diff change"],tooltip:e["Previous diff change"],imageClass:"core-sprite-move-up",id:"orion.compare.prevChange",groupId:"orion.compareGroup",visibleWhen:function(){return!o.getImageMode()},callback:function(e){e.items.prevChange(e)}});a.addCommand(l),a.addCommand(d),a.addCommand(c),a.addCommand(h),a.addCommand(u),a.addCommand(p),a.addCommand(f),a.addCommand(g),s?a.registerCommandContribution(s,"orion.compare.toggleInline2Way",108):r&&a.registerCommandContribution(r,"orion.compare.toggleInline2Way",108),r&&(a.registerCommandContribution(r,"orion.compare.copyToLeft",110,null,!1,new n.KeyBinding(37,!0,!1,!0)),a.registerCommandContribution(r,"orion.compare.copyToRight",111,null,!1,new n.KeyBinding(39,!0,!1,!0)),a.registerCommandContribution(r,"orion.compare.nextDiff",112,null,!1,new n.KeyBinding(40,!0)),a.registerCommandContribution(r,"orion.compare.prevDiff",113,null,!1,new n.KeyBinding(38,!0)),o.options.wordLevelNav?(a.registerCommandContribution(r,"orion.compare.nextChange",114,null,!1,new n.KeyBinding(40,!0,!0)),a.registerCommandContribution(r,"orion.compare.prevChange",115,null,!1,new n.KeyBinding(38,!0,!0))):(a.registerCommandContribution(r,"orion.compare.nextChange",114,null,!0,new n.KeyBinding(40,!0,!0)),a.registerCommandContribution(r,"orion.compare.prevChange",115,null,!0,new n.KeyBinding(38,!0,!0))),a.registerCommandContribution(r,"orion.compare.ignoreWhitespace",109))}},renderCommands:function(e){var t=this.options.commandSpanId,i=this.options.toggleCommandSpanId,n=this.options.commandService;n&&(t||i)&&(i&&(o.empty(o.node(i)),n.renderCommands(i,i,e,e,"tool",null)),t&&(o.empty(o.node(t)),this.options.gridRenderer&&this.options.gridRenderer.navGridHolder?(this.options.gridRenderer.navGridHolder.splice(0,this.options.gridRenderer.navGridHolder.length),this.options.gridRenderer.additionalCmdRender?this.options.gridRenderer.before?(this.options.gridRenderer.additionalCmdRender(this.options.gridRenderer.navGridHolder),n.renderCommands(t,t,e,e,"tool",null,this.options.gridRenderer.navGridHolder)):(n.renderCommands(t,t,e,e,"tool",null,this.options.gridRenderer.navGridHolder),this.options.gridRenderer.additionalCmdRender(this.options.gridRenderer.navGridHolder)):n.renderCommands(t,t,e,e,"tool",null,this.options.gridRenderer.navGridHolder)):n.renderCommands(t,t,e,e,"tool",null)))}},s}(),s}),define("compare/builder/compare",["orion/commandRegistry","orion/staticDataSource","orion/contentTypes","orion/Deferred","orion/webui/littlelib","orion/compare/compareView","orion/compare/compareCommands"],function(e,t,i,n,o,r,s){function a(e){return u.getFilenameContentType(e)}function l(e){var t=new n,i=new XMLHttpRequest;return i.open("GET",e,!0),i.onreadystatechange=function(){if(4===i.readyState){var e="undefined"!=typeof i.response?i.response:i.responseText,n="string"==typeof e?e:null,o=i.status;o>=200&&400>o?t.resolve(n):t.reject(n)}},i.send(),t}function d(e){if(!e)return e;var t=o.node(e);if(t){if("ul"!==t.nodeName.toLowerCase()){var i=document.createElement("ul");return i.id=e+"__compareCmdUL",i.classList.add("layoutLeft"),i.classList.add("commandList"),t.appendChild(i),i.id}t.classList.add("commandList")}return e}function c(e,i,n,o,l){var c=e;if(!c.highlighters&&c.oldFile&&c.oldFile.Name&&c.newFile&&c.newFile.Name&&(c.highlighters=[new t.SyntaxHighlighter,new t.SyntaxHighlighter]),c.oldFile&&c.oldFile.Name&&(c.oldFile.Type=a(c.oldFile.Name)),c.newFile&&c.newFile.Name&&(c.newFile.Type=a(c.newFile.Name)),i||l){var u=new s.CompareCommandFactory({commandService:h,commandSpanId:d(i),toggleCommandSpanId:d(l)});c.commandProvider=u}var p="inline"===n?"inline":"twoWay";this.compareView=o?new r.toggleableCompareView(p,c):"inline"===p?new r.inlineCompareView(c):new r.TwoWayCompareView(c),this.compareView.startup()}var h=new e.CommandRegistry({}),u=new i.ContentTypeRegistry(t.ContentTypes);return c.prototype={getCompareView:function(){return this.compareView},setFileNames:function(e,t){var i=this.getCompareView().getWidget().options;i.newFile&&e&&(i.newFile.Name=e,i.newFile.Type=a(e)),i.oldFile&&t&&(i.oldFile.Name=t,i.oldFile.Type=a(t))},refresh:function(){var e=this.getCompareView().getWidget().options;if(e.oldFile.URL&&e.newFile.URL){var t=[];t.push(l(e.oldFile.URL)),t.push(l(e.newFile.URL)),n.all(t,function(e){return{_error:e}}).then(function(e){this.getCompareView().getWidget().options.oldFile.Content=e[0],this.getCompareView().getWidget().options.newFile.Content=e[1],this.getCompareView().getWidget().refresh(!0)}.bind(this))}else this.getCompareView().getWidget().refresh(!0) +}},c}),define(["compare/builder/compare"],function(e){return e}); \ No newline at end of file diff --git a/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-11.0/built-compare.css b/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-12.0/built-compare.css similarity index 97% rename from plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-11.0/built-compare.css rename to plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-12.0/built-compare.css index c8040b392d0..2d9a66b9a41 100644 --- a/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-11.0/built-compare.css +++ b/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-12.0/built-compare.css @@ -1,9 +1,9 @@ .headerLayout { - height: 50px; + height: 35px; } .toolbarLayout { - height: 50px; + height: 35px; display: -webkit-box; display: -moz-box; @@ -91,7 +91,7 @@ top: 0; bottom: 0; - left: 50px; + left: 35px; right: 0; background: #3b4b54; @@ -252,7 +252,7 @@ } .toolbarTarget { position: absolute; - top: 50px; + top: 35px; width: 100%; overflow-y: auto; } @@ -261,11 +261,11 @@ } .pageLayoutTarget { position: absolute; - width: calc( 100% - 60px ); + width: calc( 100% - 15px ); bottom: 0; overflow-y: auto; box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.33); - margin: 20px; + margin: 5px; margin-right: 0; padding-top: 10px; padding-bottom: 5px; @@ -438,7 +438,7 @@ and (max-device-width : 1024px) { margin-right: 0 !important; } .sideMenu{ - width: 50px; + width: 35px; background: #26343F; float: left; position: absolute; @@ -471,7 +471,7 @@ and (max-device-width : 1024px) { } .sideMenuHome{ width: 100%; - height: 50px; + height: 35px; } .sideMenuList{ display:inline-block !important; @@ -523,7 +523,7 @@ and (max-device-width : 1024px) { text-decoration:none !important; width: 100%; display: inline-block; - padding: 9px 0px 12px 0px; + padding: 4px 0 4px 0; } .sideMenuItem>.submenu-trigger:hover, .sideMenuItem.expanded>.submenu-trigger{ text-decoration:none; @@ -635,12 +635,12 @@ and (max-device-width : 1024px) { } .mainContent{ position:absolute; - left:50px; + left:35px; } .innerPanels{ position:absolute; width:100%; - top:50px; + top:35px; bottom:0; } .userMenu { @@ -715,13 +715,16 @@ and (max-device-width : 1024px) { padding-bottom:10px; height:24px; } +.splashMessages { +} .splashMessage { color: white; font-size: 14px; } .splashDetailedMessage { color: white; - font-size: 14px; + font-size: 12px; + padding-left: 20px; } .splashVisual { width: 24px; @@ -1333,7 +1336,6 @@ textarea.parameterInput { } .mainNavColumn { display: inline-block; - padding: 2px; vertical-align: baseline; white-space: nowrap; } @@ -2066,7 +2068,7 @@ html[dir="rtl"] .modifiedFileMarker{ border-collapse: collapse; border-spacing: 0; padding: 0; - margin-top: 40px; + margin-top: 5px; overflow-y: hidden; } html[dir="rtl"] .sectionWrapper, html[dir="rtl"] .sectionTable{ @@ -2083,8 +2085,8 @@ html[dir="rtl"] .sectionWrapper, html[dir="rtl"] .sectionTable{ } .sectionTable { margin-top: 0; - margin-left: 8%; - margin-right: 8%; + margin-left: 5px; + margin-right: 5px; border: 1px solid #f1f3f4; -webkit-transition: all 0.1s ease, left 0; transition: all 0.1s ease, left 0; @@ -2096,7 +2098,7 @@ html[dir="rtl"] .sectionWrapper, html[dir="rtl"] .sectionTable{ border-top: none; } .sectionTable:last-child { - margin-bottom: 20px; + margin-bottom: 5px; } .sectionTable.sectionClosed { height: 0; @@ -2106,8 +2108,8 @@ html[dir="rtl"] .sectionWrapper, html[dir="rtl"] .sectionTable{ } .sectionWrapper{ border: 1px solid; - margin-left: 8%; - margin-right: 8%; + margin-left: 5px; + margin-right: 5px; background: none repeat scroll 0 0 #f4f4f4; vertical-align: middle; font-weight: bold; @@ -2502,7 +2504,7 @@ html[dir="rtl"] .fileExplorerProgressDiv { -moz-osx-font-smoothing: grayscale; } .core-sprite-questionmark { - font-weight: bold; + padding-bottom: 3px; } .core-sprite-hamburger { margin-top: -3px; @@ -2573,7 +2575,6 @@ html[dir="rtl"] .fileExplorerProgressDiv { } .core-sprite-git-logo { font-size: 20px; - padding-bottom: 10px !important; } .core-sprite-page, .core-sprite-horizontal, @@ -2640,7 +2641,7 @@ html[dir="rtl"] .fileExplorerProgressDiv { .core-sprite-horizontal:before{ content:'\E042'; } .core-sprite-vertical:before{ content:'\E041'; } .core-sprite-pip:before{ content:'\E067'; } -.core-sprite-questionmark:before{ content:'?'; } +.core-sprite-questionmark:before{ content:'\E043'; } .file-sprite-javascript:before{ content:'\E00D'; } .file-sprite-css:before{ content:'\E00C'; } @@ -2715,7 +2716,7 @@ html[dir="rtl"] .fileExplorerProgressDiv { height: 100%; } .rulerLines { - color: silver; + color: #767676; } .rulerLines.even .rulerLines.odd { @@ -2807,13 +2808,16 @@ html[dir="rtl"] .fileExplorerProgressDiv { .textviewTooltip .hoverTooltipTitle { font-weight: normal; } +.textviewTooltip .quickFixList { + margin-top: 5px; +} .textviewTooltip .commandButton { border: 1px solid #325C80; background-color: inherit; color: white; } .textviewTooltip .commandButton:not(.dropdownTrigger){ - text-transform: initial; + text-transform: initial; } .textviewTooltip .commandList > li { margin: 0; @@ -2925,11 +2929,11 @@ html[dir="rtl"] .fileExplorerProgressDiv { } .contentassist .proposal-noemphasis-title-keywords { background-color: aliceblue; - color: gray; + color: #717171; } .contentassist .proposal-noemphasis-title { background-color: aliceblue; - color: gray; + color: #717171; padding-top: 5px; } .contentassist .proposal-default { @@ -3787,7 +3791,7 @@ a.breadcrumb.currentLocation { .mainpane { border: 0; background: #3B4B54 !important; - padding-right:20px; + padding-right:5px; } .mainToolbar { color: white; @@ -4426,6 +4430,7 @@ a.breadcrumb.currentLocation { visibility: hidden; z-index: 175; position: absolute; + color: #222; background-color: #fbfbfb; border-radius: 2px; border: 1px solid #BBB; diff --git a/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-codenvy.css b/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-codenvy.css index 7e33ba4f3ec..c8ea3d777b1 100644 --- a/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-codenvy.css +++ b/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-codenvy.css @@ -4578,11 +4578,11 @@ a.breadcrumb.currentLocation { @font-face { font-family: 'Orion Icon Font'; - src: url('built-compare-11.0/OrionIconFont-Regular.eot'); - src: url('built-compare-11.0/OrionIconFont-Regular.eot?#iefix') format('embedded-opentype'), - url('built-compare-11.0/OrionIconFont-Regular.woff') format('woff'), - url('built-compare-11.0/OrionIconFont-Regular.ttf') format('truetype'), - url('built-compare-11.0/OrionIconFont-Regular.svg#04b530a8db6e0f4a0fdb83697b7ace5f') format('svg'); + src: url('built-compare-12.0/OrionIconFont-Regular.eot'); + src: url('built-compare-12.0/OrionIconFont-Regular.eot?#iefix') format('embedded-opentype'), + url('built-compare-12.0/OrionIconFont-Regular.woff') format('woff'), + url('built-compare-12.0/OrionIconFont-Regular.ttf') format('truetype'), + url('built-compare-12.0/OrionIconFont-Regular.svg#04b530a8db6e0f4a0fdb83697b7ace5f') format('svg'); font-style: normal; font-weight: 400; diff --git a/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-dark-codenvy.css b/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-dark-codenvy.css index a71331a7eb5..c2cddfc7d52 100644 --- a/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-dark-codenvy.css +++ b/plugins/plugin-orion/che-plugin-orion-compare/src/main/resources/org/eclipse/che/ide/orion/public/built-compare-dark-codenvy.css @@ -4581,11 +4581,11 @@ a.breadcrumb.currentLocation { @font-face { font-family: 'Orion Icon Font'; - src: url('built-compare-11.0/OrionIconFont-Regular.eot'); - src: url('built-compare-11.0/OrionIconFont-Regular.eot?#iefix') format('embedded-opentype'), - url('built-compare-11.0/OrionIconFont-Regular.woff') format('woff'), - url('built-compare-11.0/OrionIconFont-Regular.ttf') format('truetype'), - url('built-compare-11.0/OrionIconFont-Regular.svg#04b530a8db6e0f4a0fdb83697b7ace5f') format('svg'); + src: url('built-compare-12.0/OrionIconFont-Regular.eot'); + src: url('built-compare-12.0/OrionIconFont-Regular.eot?#iefix') format('embedded-opentype'), + url('built-compare-12.0/OrionIconFont-Regular.woff') format('woff'), + url('built-compare-12.0/OrionIconFont-Regular.ttf') format('truetype'), + url('built-compare-12.0/OrionIconFont-Regular.svg#04b530a8db6e0f4a0fdb83697b7ace5f') format('svg'); font-style: normal; font-weight: 400; diff --git a/plugins/plugin-orion/che-plugin-orion-editor/pom.xml b/plugins/plugin-orion/che-plugin-orion-editor/pom.xml index db19f24ea72..f9bdeb8958b 100644 --- a/plugins/plugin-orion/che-plugin-orion-editor/pom.xml +++ b/plugins/plugin-orion/che-plugin-orion-editor/pom.xml @@ -123,10 +123,9 @@ ${patches.location} - built-codeEdit-amd.js.diff + fix_linked_mode.diff fix_goto_line.diff - fix_focus.diff - embeddedToolingPlugin.js.diff + fix_scrolling.diff false true @@ -160,11 +159,8 @@ - **/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/** - **/patches/built-codeEdit-amd.js.diff - **/patches/fix_goto_line.diff - **/patches/fix_focus.diff - **/patches/embeddedToolingPlugin.js.diff + **/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/** + **/org/eclipse/che/ide/editor/orion/public/cheJavaHighlightingPlugin/lib/plugin.js diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorExtension.java b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorExtension.java index b859d28f1d7..572d485b4f5 100644 --- a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorExtension.java +++ b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/OrionEditorExtension.java @@ -81,7 +81,7 @@ public void makeCall(AsyncCallback callback) { private void injectOrion(final AsyncCallback callback) { loader.setMessage(waitEditorMessage); final String[] scripts = new String[]{ - "built-codeEdit-11.0/code_edit/built-codeEdit-amd", + "built-codeEdit-12.0/code_edit/built-codeEdit-amd", "orion/CheContentAssistMode" }; @@ -111,7 +111,7 @@ public void onFailure(final Throwable e) { } }, scripts, new String[0]); - injectCssLink(GWT.getModuleBaseForStaticFiles() + "built-codeEdit-11.0/code_edit/built-codeEdit.css"); + injectCssLink(GWT.getModuleBaseForStaticFiles() + "built-codeEdit-12.0/code_edit/built-codeEdit.css"); } private static void injectCssLink(final String url) { diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/inject/JavaHighlightingOrionPlugin.java b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/inject/JavaHighlightingOrionPlugin.java new file mode 100644 index 00000000000..764b2266411 --- /dev/null +++ b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/inject/JavaHighlightingOrionPlugin.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2012-2016 Codenvy, S.A. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Codenvy, S.A. - initial API and implementation + *******************************************************************************/ +package org.eclipse.che.ide.editor.orion.client.inject; + +/** + * Plugin that fixes some Orion's highlighting issues for Java files. + * + * @author Artem Zatsarynnyi + */ +public class JavaHighlightingOrionPlugin implements OrionPlugin { + + @Override + public String getRelPath() { + return "cheJavaHighlightingPlugin/plugin.html"; + } +} diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/inject/OrionEditorGinModule.java b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/inject/OrionEditorGinModule.java index 39fd0ec4931..426df1c0814 100644 --- a/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/inject/OrionEditorGinModule.java +++ b/plugins/plugin-orion/che-plugin-orion-editor/src/main/java/org/eclipse/che/ide/editor/orion/client/inject/OrionEditorGinModule.java @@ -12,6 +12,7 @@ import com.google.gwt.inject.client.AbstractGinModule; import com.google.gwt.inject.client.assistedinject.GinFactoryModuleBuilder; +import com.google.gwt.inject.client.multibindings.GinMultibinder; import com.google.inject.Singleton; import com.google.inject.TypeLiteral; @@ -39,5 +40,6 @@ protected void configure() { install(new GinFactoryModuleBuilder().build(ContentAssistWidgetFactory.class)); + GinMultibinder.newSetBinder(binder(), OrionPlugin.class).addBinding().to(JavaHighlightingOrionPlugin.class); } } diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/embeddedToolingPlugin.js.diff b/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/embeddedToolingPlugin.js.diff deleted file mode 100644 index 9b65eed388a..00000000000 --- a/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/embeddedToolingPlugin.js.diff +++ /dev/null @@ -1,12 +0,0 @@ -This patch fixes highlighting 'this' keyword, 'super' keyword and annotations in Java-files. -====================================================== -diff --git a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/plugins/embeddedToolingPlugin.js b/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/plugins/embeddedToolingPlugin.js ---- a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/plugins/embeddedToolingPlugin.js -+++ b/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/plugins/embeddedToolingPlugin.js -@@ -1,4 +1,4 @@ - !function(e,n){"function"==typeof define&&define.amd?define([],n):(e.orion=e.orion||{},e.orion.webtools=e.orion.webtools||{},e.orion.webtools.embeddedTooling=n())}(this,function(){var e,n,t;return function(i){function o(e,n){return x.call(e,n)}function r(e,n){var t,i,o,r,a,s,l,c,d,u,p=n&&n.split("/"),m=y.map,g=m&&m["*"]||{};if(e&&"."===e.charAt(0))if(n){for(p=p.slice(0,p.length-1),e=p.concat(e.split("/")),c=0;c0&&(e.splice(c-1,2),c-=2)}e=e.join("/")}else 0===e.indexOf("./")&&(e=e.substring(2));if((p||g)&&m){for(t=e.split("/"),c=t.length;c>0;c-=1){if(i=t.slice(0,c).join("/"),p)for(d=p.length;d>0;d-=1)if(o=m[p.slice(0,d).join("/")],o&&(o=o[i])){r=o,a=c;break}if(r)break;!s&&g&&g[i]&&(s=g[i],l=c)}!r&&s&&(r=s,a=l),r&&(t.splice(0,a,r),e=t.join("/"))}return e}function a(e,n){return function(){return m.apply(i,_.call(arguments,0).concat([e,n]))}}function s(e){return function(n){return r(n,e)}}function l(e){return function(n){b[e]=n}}function c(e){if(o(f,e)){var n=f[e];delete f[e],v[e]=!0,p.apply(i,n)}if(!o(b,e)&&!o(v,e))throw new Error("No "+e);return b[e]}function d(e){var n,t=e?e.indexOf("!"):-1;return t>-1&&(n=e.substring(0,t),e=e.substring(t+1,e.length)),[n,e]}function u(e){return function(){return y&&y.config&&y.config[e]||{}}}var p,m,g,h,b={},f={},y={},v={},x=Object.prototype.hasOwnProperty,_=[].slice;g=function(e,n){var t,i=d(e),o=i[0];return e=i[1],o&&(o=r(o,n),t=c(o)),o?e=t&&t.normalize?t.normalize(e,s(n)):r(e,n):(e=r(e,n),i=d(e),o=i[0],e=i[1],o&&(t=c(o))),{f:o?o+"!"+e:e,n:e,pr:o,p:t}},h={require:function(e){return a(e)},exports:function(e){var n=b[e];return"undefined"!=typeof n?n:b[e]={}},module:function(e){return{id:e,uri:"",exports:b[e],config:u(e)}}},p=function(e,n,t,r){var s,d,u,p,m,y,x=[];if(r=r||e,"function"==typeof t){for(n=!n.length&&t.length?["require","exports","module"]:n,m=0;mo;o++){var a=t[o];if(a!==i[o])return!1;var s=e[a],l=n[a];if(s!==l&&JSON.stringify(s)!==JSON.stringify(l))return!1}return!0}function i(e,n){this.__objectId=e,this.__methods=n}function o(o,r){function a(e,n){n=n||D,n&&("undefined"==typeof ArrayBuffer&&(e=JSON.stringify(e)),n===self||I?n.postMessage(e):n.postMessage(e,"*"))}function s(e){"undefined"!=typeof localStorage&&localStorage.pluginLogging&&console.log(e+"("+((new Date).getTime()-Q)+"ms)="+self.location)}function l(){var e=(new Date).getTime();M&&4e3>e-M||(M=e,a({method:"loading"}),s("heartbeat"))}function c(){var e=[];return Object.keys(L).forEach(function(n){var t=L[n];e.push({serviceId:n,names:t.names,methods:t.methods,properties:t.properties})}),{updateRegistry:!!$,headers:w||{},services:e}}function d(e,n){if(n&&n instanceof XMLHttpRequest){var t,i;try{t=n.status,i=n.statusText}catch(o){t=0,i=""}return{status:t||0,statusText:i}}return n}function u(e){var n=e?JSON.parse(JSON.stringify(e,d)):e;return e instanceof Error&&(n.__isError=!0,n.message=n.message||e.message,n.name=n.name||e.name),n}function p(n,t){if(t=t||D,!t)return(new e).reject(new Error("plugin not connected"));n.id=String(j++);var o=new e;E[n.id]=o,o.then(null,function(e){k&&e instanceof Error&&"Cancel"===e.name&&N({requestId:n.id,method:"cancel",params:e.message?[e.message]:[]},t)});var r=Object.prototype.toString;return n.params.forEach(function(e,t){if("[object Object]"===r.call(e)&&!(e instanceof i)){var a,s;for(a in e)"[object Function]"===r.call(e[a])&&(s=s||[],s.push(a));if(s){var l=S++;O[l]=e;var c=function(){delete O[l]};o.then(c,c),n.params[t]=new i(l,s)}}}),N(n,t),o.promise}function m(e,n,t){e||0===e?N({id:e,result:null,error:n},t):console.log(n)}function g(e,n,t,i,o){i.forEach(function(e,n){if(e&&"undefined"!=typeof e.__objectId){var t={};e.__methods.forEach(function(n){t[n]=function(){return p({objectId:e.__objectId,method:n,params:Array.prototype.slice.call(arguments)},o)}}),i[n]=t}});var r="undefined"==typeof e?null:{id:e,result:null,error:null};try{var a=t.apply(n,i);if(!r)return;a&&"function"==typeof a.then?(P[e]=a,a.then(function(n){delete P[e],r.result=n,N(r,o)},function(n){P[e]&&(delete P[e],r.error=u(n),N(r,o))},function(){N({responseId:e,method:"progress",params:Array.prototype.slice.call(arguments)},o)})):(r.result=a,N(r,o))}catch(s){r&&(r.error=u(s),N(r,o))}}function h(e,n){if(I||e.source===D||"undefined"==typeof window){var t=e.data,i="string"!=typeof t?t:JSON.parse(t);try{if(i.method){var o=i.method,r=i.params||[];if("serviceId"in i){var a=L[i.serviceId];a?(a=a.implementation,o in a?g(i.id,a,a[o],r,n):m(i.id,"method not found",n)):m(i.id,"service not found",n)}else if("objectId"in i){var s=O[i.objectId];s?!o in s?g(i.id,s,s[o],r,n):m(i.id,"method not found",n):m(i.id,"object not found",n)}else if("requestId"in i){var l=P[i.requestId];l&&"cancel"===o&&l.cancel&&l.cancel.apply(l,r)}else if("responseId"in i){var c=E[i.responseId];c&&"progress"===o&&c.progress&&c.progress.apply(c,r)}else{if("plugin"!==i.method)throw new Error("Bad method: "+i.method);var d=i.params[0];v({services:d.services})}}else if(i.id){var u=E[String(i.id)];u&&(delete E[String(i.id)],i.error?u.reject(i.error):u.resolve(i.result))}}catch(p){console.log("Plugin._messageHandler "+p)}}}function b(e){var t={};if(e.methods&&(e.methods.forEach(function(n){t[n]=function(){var t={serviceId:e.serviceId,method:n,params:Array.prototype.slice.call(arguments)};return p(t)}}),t.addEventListener&&t.removeEventListener&&n)){var o=new n,r=S++;O[r]={handleEvent:o.dispatchEvent.bind(o)};var a=new i(r,["handleEvent"]),s=t.addEventListener;t.addEventListener=function(e,n){o._namedListeners[e]||s(e,a),o.addEventListener(e,n)};var l=t.removeEventListener;t.removeEventListener=function(e,n){o.removeEventListener(e,n),o._namedListeners[e]||l(e,a)}}return t}function f(e){var n=JSON.parse(JSON.stringify(e.properties)),t=e.names||e.type||[];return Array.isArray(t)||(t=[t]),n.objectClass=t,n}function y(e){if($){var n=b(e),t=f(e),i=$.registerService(e.names||e.type,n,t);C[e.serviceId]={registration:i,proxy:n}}}function v(e){var n=x||[];if(x=e.services||[],!t(x,n)){var i=[];x.forEach(function(e){var n=e.serviceId;i.push(n);var o=C[n];if(o){if(t(e.methods,Object.keys(o.proxy))){var r=f(e),a=o.registration.getReference(),s={};return a.getPropertyKeys().forEach(function(e){s[e]=a.getProperty(e)}),void(t(r,s)||o.registration.setProperties(r))}o.registration.unregister(),delete C[n]}y(e)}),Object.keys(C).forEach(function(e){-1===i.indexOf(e)&&(C[e].registration.unregister(),delete C[e])})}_&&(_(),_=null)}var x,_,w=o,k=!1,j=0,S=0,T=0,P={},E={},O={},L={},C={},$=r,A=[],I=!1,D=null;"undefined"==typeof window?self.postMessage?D=self:I=!0:window!==window.parent?D=window.parent:null!==window.opener&&(D=window.opener);var N=a,q=function(e){a({method:"error",error:u(e.error)})};addEventListener("error",q);var M,Q=(new Date).getTime();l(),I&&self.addEventListener("connect",function(e){var n=e.ports[0];if(A.push(n),k){var t={method:"plugin",params:[c()]};a(t,n)}else l();n.addEventListener("message",function(e){h(e,n)}),n.start()}),this.updateHeaders=function(e){if(k)throw new Error("Cannot update headers. Plugin Provider is connected");w=e},this.registerService=function(e,n,t){if(k)throw new Error("Cannot register service. Plugin Provider is connected");"string"==typeof e?e=[e]:Array.isArray(e)||(e=[]);var i=null,o=[];for(i in n)"function"==typeof n[i]&&o.push(i);L[T++]={names:e,methods:o,implementation:n,properties:t||{},listeners:{}},l()},this.registerServiceProvider=this.registerService,this.connect=function(e,n){if(k)return void(e&&e());removeEventListener("error",q);var t={method:"plugin",params:[c()]};if(!I){if(!D)return void(n&&n("No valid plugin target"));addEventListener("message",h,!1),a(t)}if("undefined"!=typeof window){var i=document.getElementsByTagName("head")[0]||document.documentElement,o=i.getElementsByTagName("title")[0];o||(o=document.createElement("title"),o.textContent=w.name,i.appendChild(o))}A.forEach(function(e){a(t,e)}),k=!0,$?_=e:e&&e()},this.disconnect=function(){k&&(removeEventListener("message",h),A.forEach(function(e){e.close()}),A=null,D=null,k=!1)}}return o}),t("plugins/languages/arduino/arduinoPlugin",["orion/plugin"],function(e){function n(){var n={name:"Orion Arduino Tool Support",version:"1.0",description:"This plugin provides Arduino tools support for Orion."},i=new e(n);t(i),i.connect()}function t(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-arduino","extends":"text/x-csrc",name:"Arduino",extension:["ino","pde"]}]})}return{connect:n,registerServiceProviders:t}}),t("orion/editor/stylers/lib/syntax",[],function(){return{id:"orion.lib",grammars:[{id:"orion.lib",repository:{brace_open:{match:"{",name:"punctuation.section.block.begin"},brace_close:{match:"}",name:"punctuation.section.block.end"},bracket_open:{match:"\\[",name:"punctuation.section.bracket.begin"},bracket_close:{match:"\\]",name:"punctuation.section.bracket.end"},parenthesis_open:{match:"\\(",name:"punctuation.section.parens.begin"},parenthesis_close:{match:"\\)",name:"punctuation.section.parens.end"},operator:{match:"(\\+|-|!|=|>|<|&|(\\|\\|))+",name:"punctuation.operator"},doc_block:{begin:"/\\*\\*",end:"\\*/",name:"comment.block.documentation",patterns:[{match:"@(?:(?!\\*/)\\S)*",name:"meta.documentation.annotation"},{match:"<[^\\s>]*>",name:"meta.documentation.tag"},{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},number_decimal:{match:"\\b-?(?:\\.\\d+|\\d+\\.?\\d*)(?:[eE][+-]?\\d+)?\\b",name:"constant.numeric.number"},number_hex:{match:"\\b0[xX][0-9A-Fa-f]+\\b",name:"constant.numeric.hex"},string_doubleQuote:{match:'"(?:\\\\.|[^"])*"?',name:"string.quoted.double"},string_singleQuote:{match:"'(?:\\\\.|[^'])*'?",name:"string.quoted.single"},todo_comment_singleLine:{match:"(\\b)(TODO)(\\b)(.*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.line"}}}}},{id:"orion.c-like",repository:{comment_singleLine:{match:{match:"//.*",literal:"//"},name:"comment.line.double-slash",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},comment_block:{begin:{match:"/\\*",literal:"/*"},end:{match:"\\*/",literal:"*/"},name:"comment.block",patterns:[{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]}}}],keywords:[]}}),t("orion/editor/stylers/text_x-csrc/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["auto","break","case","char","const","continue","default","double","do","else","enum","extern","float","for","goto","if","inline","int","long","register","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","_Bool","_Complex","_Imaginary"],t=["define","elif","else","endif","error","ifdef","ifndef","if","include","line","pragma","undef"],i=[];return i.push.apply(i,e.grammars),i.push({id:"orion.c",contentTypes:["text/x-csrc","text/x-c"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{include:"#directive"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.c"}],repository:{directive:{match:"#\\s*(?:"+t.join("|")+")\\b[^$]*",name:"meta.preprocessor.c"}}}),{id:i[i.length-1].id,grammars:i,keywords:n.concat(t)}}),t("plugins/languages/c/cPlugin",["orion/plugin","orion/editor/stylers/text_x-csrc/syntax"],function(e,n){function t(){var n={name:"Orion C Tool Support",version:"1.0",description:"This plugin provides C tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-csrc","extends":"text/plain",name:"C",extension:["c","h"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/editor/stylers/text_x-c__src/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["alignas","alignof","asm","and_eq","and","auto","bitand","bitor","bool","break","case","catch","char16_t","char32_t","char","class","compl","constexpr","const_cast","const","continue","decltype","default","delete","double","do","dynamic_cast","else","enum","explicit","export","extern","false","float","for","friend","goto","if","inline","int","long","mutable","namespace","new","noexcept","not_eq","not","nullptr","operator","or_eq","or","private","protected","public","register","reinterpret_cast","return","short","signed","sizeof","static_assert","static_cast","static","struct","switch","template","this","thread_local","throw","true","try","typedef","typeid","typename","union","unsigned","using","virtual","void","volatile","wchar_t","while","xor_eq","xor","_Bool","_Complex","_Imaginary"],t=["define","elif","else","endif","error","ifdef","ifndef","if","include","line","pragma","undef"],i=[];return i.push.apply(i,e.grammars),i.push({id:"orion.cpp",contentTypes:["text/x-c++src","text/x-c++"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{include:"#directive"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.cpp"}],repository:{directive:{match:"#\\s*(?:"+t.join("|")+")\\b[^$]*",name:"meta.preprocessor.cpp"}}}),{id:i[i.length-1].id,grammars:i,keywords:n}}),t("plugins/languages/cpp/cppPlugin",["orion/plugin","orion/editor/stylers/text_x-c__src/syntax"],function(e,n){function t(){var n={name:"Orion C++ Tool Support",version:"1.0",description:"This plugin provides C++ tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-c++src","extends":"text/plain",name:"C++",extension:["cpp","hpp"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/editor/stylers/text_x-csharp/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["abstract","as","base","bool","break","byte","by","case","catch","char","checked","class","const","continue","decimal","default","delegate","descending","double","do","else","enum","event","explicit","extern","false","finally","fixed","float","foreach","for","from","goto","group","if","implicit","int","interface","internal","into","in","is","lock","long","namespace","new","null","object","operator","orderby","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","select","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","var","virtual","volatile","void","while","where","yield"],t=["define","elif","else","endif","endregion","error","if","line","pragma checksum","pragma warning","pragma","region","undef","warning"],i=[];return i.push.apply(i,e.grammars),i.push({id:"orion.csharp",contentTypes:["text/x-csharp"],patterns:[{match:"^\\s*#(?:"+t.join("|")+")\\b[^$]*",name:"meta.preprocessor.csharp"},{include:"#string_verbatim"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"#doc_line"},{include:"orion.c-like#comment_singleLine"},{include:"#doc_block"},{include:"orion.c-like#comment_block"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.csharp"}],repository:{doc_block:{begin:"/\\*\\*",end:"\\*/",name:"comment.block.documentation.csharp",patterns:[{match:"<[^\\s>]*>",name:"meta.documentation.tag"},{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},doc_line:{match:"// /.*",name:"comment.line.documentation.csharp",patterns:[{match:"<[^\\s>]*>",name:"meta.documentation.tag"},{include:"orion.lib#todo_comment_singleLine"}]},string_verbatim:{begin:'@"',end:'^(?:""|[^"])*"(?!")',name:"string.quoted.verbatim.csharp"}}}),{id:i[i.length-1].id,grammars:i,keywords:n}}),t("orion/editor/stylers/application_xml/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.xml",contentTypes:["application/xml","application/xhtml+xml"],patterns:[{include:"#comment"},{include:"#doctype"},{include:"#xmlDeclaration"},{include:"#tag"},{include:"#ampersandEscape"}],repository:{ampersandEscape:{match:"<|>|&",name:"constant.character"},comment:{begin:{match:"",literal:"-->"},name:"comment.block.xml",patterns:[{match:"(\\b)(TODO)(\\b)(((?!-->).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.line"}}}]},doctype:{begin:"",name:"meta.tag.doctype.xml",captures:{0:{name:"meta.tag.doctype.xml"}},patterns:[{include:"#comment"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},tag:{begin:"",captures:{0:{name:"meta.tag.xml"}},patterns:[{include:"#comment"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},xmlDeclaration:{begin:"<\\?xml",end:"\\?>",captures:{0:{name:"meta.tag.declaration.xml"}},patterns:[{include:"#comment"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}],name:"meta.tag.declaration.xml"}}}),{id:n[n.length-1].id,grammars:n,keywords:[]}}),t("orion/editor/stylers/application_javascript/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["class","const","debugger","delete","enum","export","extends","function","implements","import","in","instanceof","interface","let","new","package","private","protected","public","static","super","typeof","var","void","with"],t=["break","case","catch","continue","default","do","else","finally","for","if","return","switch","throw","try","while","yield"],i=["this"],o=["false","null","true","undefined"],r=[];return r.push.apply(r,e.grammars),r.push({id:"orion.js",contentTypes:["application/javascript"],patterns:[{begin:"'(?:\\\\.|[^\\\\'])*\\\\$",end:"^(?:$|(?:\\\\.|[^\\\\'])*('|[^\\\\]$))",name:"string.quoted.single.js"},{begin:'"(?:\\\\.|[^\\\\"])*\\\\$',end:'^(?:$|(?:\\\\.|[^\\\\"])*("|[^\\\\]$))',name:"string.quoted.double.js"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{match:"/(?![\\s\\*])(?:\\\\.|[^/])+/(?:[gim]{0,3})",name:"string.regexp.js"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{include:"#jsFunctionDef"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.js"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.control.js"},{match:"\\b(?:"+o.join("|")+")\\b",name:"constant.language.js"},{match:"\\b(?:"+i.join("|")+")\\b",name:"variable.language.js"}],repository:{jsFunctionDef:{begin:"(function)(\\s+[_$a-zA-Z\\xA0-\\uFFFF][_$a-zA-Z0-9\\xA0-\\uFFFF]*)?\\s*\\(",end:"\\)",captures:{1:{name:"keyword.operator.js"},2:{name:"entity.name.function.js"}},patterns:[{include:"orion.c-like#comment_singleLine"},{include:"orion.c-like#comment_block"},{match:"[^\\s,]+",name:"variable.parameter.js"}]}}}),{id:r[r.length-1].id,grammars:r,keywords:n.concat(t).concat(i).concat(o)}}),t("orion/editor/stylers/text_css/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["alignment-adjust","alignment-baseline","animation-delay","animation-direction","animation-duration","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","animation","appearance","azimuth","backface-visibility","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","background","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-bottom","border-collapse","border-color","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-image","border-left-color","border-left-style","border-left-width","border-left","border-radius","border-right-color","border-right-style","border-right-width","border-right","border-spacing","border-style","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-top","border-width","border","bottom","box-align","box-decoration-break","box-direction","box-flex-group","box-flex","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color-profile","color","column-count","column-fill","column-gap","column-rule-color","column-rule-style","column-rule-width","column-rule","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue-after","cue-before","cue","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit-position","fit","flex-align","flex-flow","flex-inline-pack","flex-order","flex-pack","float-offset","float","font-family","font-size-adjust","font-size","font-stretch","font-style","font-variant","font-weight","font","grid-columns","grid-rows","hanging-punctuation","height","hyphenate-after","hyphenate-before","hyphenate-character","hyphenate-lines","hyphenate-resource","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","left","letter-spacing","line-height","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","line-stacking","list-style-image","list-style-position","list-style-type","list-style","margin-bottom","margin-left","margin-right","margin-top","margin","mark-after","mark-before","mark","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","opacity","orphans","outline-color","outline-offset","outline-style","outline-width","outline","overflow-style","overflow-x","overflow-y","overflow","padding-bottom","padding-left","padding-right","padding-top","padding","page-break-after","page-break-before","page-break-inside","page-policy","page","pause-after","pause-before","pause","perspective-origin","perspective","phonemes","pitch-range","pitch","play-during","position","presentation-level","punctuation-trim","quotes","rendering-intent","resize","rest-after","rest-before","rest","richness","right","rotation-point","rotation","ruby-align","ruby-overhang","ruby-position","ruby-span","size","speak-header","speak-numeral","speak-punctuation","speak","speech-rate","stress","string-set","table-layout","target-name","target-new","target-position","target","text-align-last","text-align","text-decoration","text-emphasis","text-height","text-indent","text-justify","text-outline","text-shadow","text-transform","text-wrap","top","transform-origin","transform-style","transform","transition-delay","transition-duration","transition-property","transition-timing-function","transition","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch-range","voice-pitch","voice-rate","voice-stress","voice-volume","volume","white-space-collapse","white-space","widows","width","word-break","word-spacing","word-wrap","z-index"],t=[];return t.push.apply(t,e.grammars),t.push({id:"orion.css",contentTypes:["text/css"],patterns:[{begin:"'(?:\\\\.|[^\\\\'])*\\\\$",end:"^(?:$|(?:\\\\.|[^\\\\'])*('|[^\\\\]$))",name:"string.quoted.single.css"},{begin:'"(?:\\\\.|[^\\\\"])*\\\\$',end:'^(?:$|(?:\\\\.|[^\\\\"])*("|[^\\\\]$))',name:"string.quoted.double.css"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_block"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#number_decimal"},{include:"#number_hex"},{match:"(?i)\\b-?(?:\\.\\d+|\\d+\\.?\\d*)(?:%|em|ex|ch|rem|vw|vh|vmin|vmax|in|cm|mm|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?\\b",name:"constant.numeric.value.css"},{match:"(?:-webkit-|-moz-|-ms-|-o-|\\b)(?:"+n.join("|")+")\\b",name:"support.type.propertyName.css"}],repository:{number_hex:{match:"#[0-9A-Fa-f]+\\b",name:"constant.numeric.hex.css"}}}),{id:t[t.length-1].id,grammars:t,keywords:n}}),t("orion/editor/stylers/text_html/syntax",["orion/editor/stylers/application_javascript/syntax","orion/editor/stylers/text_css/syntax","orion/editor/stylers/application_xml/syntax"],function(e,n,t){var i=["accept-charset","accept","accesskey","action","align","alt","async","autocomplete","autoplay","autosave","bgcolor","border","buffered","challenge","charset","checked","cite","class","codebase","code","color","colspan","cols","contenteditable","content","contextmenu","controls","coords","data-[A-Za-z_:][\\w.:-]*","data","datetime","default","defer","dirname","dir","disabled","download","draggable","dropzone","enctype","formaction","form","for","headers","height","hidden","high","hreflang","href","http-equiv","icon","id","ismap","itemprop","keytype","kind","label","language","lang","list","loop","low","manifest","maxlength","max","media","method","min","multiple","name","novalidate","open","optimum","pattern","ping","placeholder","poster","preload","pubdate","radiogroup","readonly","rel","required","reversed","rowspan","rows","sandbox","scoped","scope","seamless","selected","shape","sizes","size","span","spellcheck","srcdoc","srclang","srcset","src","start","step","style","summary","tabindex","target","title","type","usemap","value","width","wrap"],o=[]; --return o.push.apply(o,e.grammars),o.push.apply(o,n.grammars),o.push.apply(o,t.grammars),o.push({id:"orion.html",contentTypes:["text/html"],patterns:[{begin:"(?i)(]*)(>)",end:"(?i)()",captures:{1:{name:"meta.tag.html"},3:{name:"meta.tag.html"}},contentName:"source.css.embedded.html",patterns:[{include:"orion.css"}]},{begin:"(?i)|",end:"(?i)",captures:{0:{name:"meta.tag.html"}},contentName:"source.js.embedded.html",patterns:[{include:"orion.js"}]},{begin:"",captures:{0:{name:"meta.tag.html"}},patterns:[{include:"orion.xml#comment"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"#attribute"}]},{include:"orion.xml#comment"},{include:"orion.xml#doctype"},{include:"orion.xml#ampersandEscape"}],repository:{attribute:{match:"\\b(?:"+i.join("|")+")\\b",name:"meta.tag.attribute.html"}}}),{id:o[o.length-1].id,grammars:o,keywords:[],attributes:i}}),t("orion/editor/stylers/text_x-cshtml/syntax",["orion/editor/stylers/application_xml/syntax","orion/editor/stylers/text_html/syntax","orion/editor/stylers/text_x-csharp/syntax"],function(e,n,t){var i=[];return i.push.apply(i,e.grammars),i.push.apply(i,n.grammars),i.push.apply(i,t.grammars),i.push({id:"orion.cshtml",contentTypes:["text/x-cshtml"],patterns:[{include:"#comment"},{include:"#codeBlock"},{include:"#expression"},{include:"#reference"},{include:"orion.html"}],repository:{comment:{begin:{match:"@\\*",literal:"@*"},end:{match:"\\*@",literal:"*@"},name:"comment.block.cshtml"},codeBlock:{begin:"(^\\s*)(@)(?=([^{]*){)",end:"}",captures:{2:{name:"entity.name.declaration.csharp"}},contentName:"source.csharp.embedded.cshtml",patterns:[{include:"orion.xml#tag"},{include:"#reference"},{include:"orion.csharp"}]},expression:{match:"^\\s*@[^{]*$",name:"source.csharp.embedded.cshtml",patterns:[{include:"#reference"},{include:"orion.csharp"}]},reference:{match:"@",name:"entity.name.declaration.csharp"}}}),{id:i[i.length-1].id,grammars:i,keywords:[]}}),t("plugins/languages/csharp/csharpPlugin",["orion/plugin","orion/editor/stylers/text_x-csharp/syntax","orion/editor/stylers/text_x-cshtml/syntax"],function(e,n,t){function i(){var n={name:"Orion C# Tool Support",version:"1.0",description:"This plugin provides C# tools support for Orion."},t=new e(n);o(t),t.connect()}function o(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-csharp","extends":"text/plain",name:"C#",extension:["cs"]},{id:"text/x-cshtml","extends":"text/plain",name:"cshtml",extension:["cshtml"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)}),t.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:i,registerServiceProviders:o}}),t("orion/editor/stylers/text_x-dockerfile/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["add","cmd","copy","entrypoint","env","expose","from","maintainer","onbuild","run","user","volume","workdir"],t="orion.dockerfile",i=[];return i.push.apply(i,e.grammars),i.push({id:t,contentTypes:["text/x-dockerfile"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"#numberSignComment"},{match:"\\b-?[0-9]+(\\.[0-9]+)?\\b",name:"constant.numeric.dockerfile"},{match:"(?i)^\\s*(?:"+n.join("|")+")\\b",name:"keyword.operator.dockerfile"}],repository:{numberSignComment:{begin:{match:"^\\s*#",literal:"#"},end:{match:"$",literal:""},name:"comment.line.number-sign.dockerfile",patterns:[{include:"orion.lib#todo_comment_singleLine"}]}}}),{id:t,grammars:i,keywords:n}}),t("plugins/languages/docker/dockerPlugin",["orion/plugin","orion/editor/stylers/text_x-dockerfile/syntax"],function(e,n){function t(){var n={name:"Orion Editor Docker Tool Support",version:"1.0",description:"This plugin provides Docker tools support for the Orion editor."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-dockerfile","extends":"text/plain",name:"dockerfile",extension:["dockerfile"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/editor/stylers/text_x-erlang/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["xor","when","try","rem","receive","query","orelse","or","of","not","let","if","fun","end","div","cond","catch","case","bxor","bsr","bsl","bor","bnot","begin","band","andalso","and","after"],t=["vsn","undef","type","spec","record","on_load","opaque","module","include_lib","include","import","ifndef","ifdef","file","export_type","export","endif","else","define","callback","compile","behaviour"],i=[];return i.push.apply(i,e.grammars),i.push({id:"orion.erlang",contentTypes:["text/x-erlang"],patterns:[{include:"#comment"},{include:"#stringSingleLine"},{include:"#stringMultiLine"},{include:"#method"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.erlang"},{match:"^\\s*-(?:"+t.join("|")+")\\b",name:"keyword.operator.erlang"}],repository:{comment:{match:{match:"%.*",literal:"%"},name:"comment.line.erlang",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},method:{match:"(^|\\s)[a-zA-Z0-9_.]+(?=\\(|\\s\\()",name:"entity.name.function.erlang"},stringMultiLine:{begin:'"(?:\\\\.|[^\\\\"])*$',end:'^(?:\\\\.|[^\\\\"])*"',name:"string.quoted.double.erlang"},stringSingleLine:{match:'"(?:\\\\.|[^\\\\"])*"',name:"string.quoted.double.erlang"}}}),{id:i[i.length-1].id,grammars:i,keywords:n}}),t("plugins/languages/erlang/erlangPlugin",["orion/plugin","orion/editor/stylers/text_x-erlang/syntax"],function(e,n){function t(){var n={name:"Orion Erlang Tool Support",version:"1.0",description:"This plugin provides Erlang tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-erlang","extends":"text/plain",name:"Erlang",extension:["erl","hrl"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/form",[],function(){function e(e){return encodeURIComponent(e).replace(/[!'()*]/g,escape).replace("%20","+")}return{encodeFormData:function(n){n=n||{};for(var t=Object.keys(n),i=[],o=0;o0&&m.positions.push({offset:b,length:f})}s.push(m)}}return s}},{name:"Go content assist",contentType:["text/x-go"]})}return{connect:i,registerServiceProviders:o}}),t("orion/editor/stylers/text_x-git-ignore/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.gitignore",contentTypes:["text/x-git-ignore"],patterns:[{match:{match:"^\\s*#[^$]*",literal:"#"},name:"comment.line.number-sign.ignore"},{match:"^\\s*!",name:"punctuation.operator.negation.ignore"}]}),{id:n[n.length-1].id,grammars:n,keywords:[]}}),t("orion/editor/stylers/text_x-git-config/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.gitconfig",contentTypes:["text/x-git-config"],patterns:[{match:"[;#][^$]*",name:"comment.line.gitconfig"},{match:"=",name:"punctuation.operator.equals.gitconfig"},{match:"^\\s*\\[[-.A-Za-z0-9]+\\]\\s*$",name:"entity.section.name.gitconfig"}]}),{id:n[n.length-1].id,grammars:n,keywords:[]}}),t("plugins/languages/git/gitFilePlugin",["orion/plugin","orion/editor/stylers/text_x-git-ignore/syntax","orion/editor/stylers/text_x-git-config/syntax"],function(e,n,t){function i(){var n={name:"Orion Git File Support",version:"1.0",description:"This plugin provides Git file syntax highlighting for Orion."},t=new e(n);o(t),t.connect()}function o(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-git-ignore","extends":"text/plain",name:"Git Ignore",extension:["gitignore"]},{id:"text/x-git-config","extends":"text/plain",name:"Git Config",filename:["config"]},{id:"text/x-cf-ignore","extends":"text/x-git-ignore",name:"cf Ignore",extension:["cfignore"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)}),t.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:i,registerServiceProviders:o}}),t("orion/editor/stylers/text_x-ruby/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["alias_method","alias","attr_accessor","attr_reader","attr_writer","attr","BEGIN","class","defined?","def","END","extend","gem","include","initialize","in","load","lambda","module_function","module","new","not","public","prepend","private","protected","require_relative","require","undef","__ENCODING__","__END__","__FILE__","__LINE__"],t=["and","begin","break","case","catch","do","else","elsif","end","ensure","fail","for","if","loop","next","or","raise","redo","rescue","retry","return","then","throw","unless","until","when","while","yield"],i=["false","nil","true"],o=["self","super"],r=[];return r.push.apply(r,e.grammars),r.push({id:"orion.ruby",contentTypes:["text/x-ruby"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"#symbol_quoted_single"},{include:"#symbol_quoted_double"},{include:"#symbol"},{include:"#classRef"},{match:"/(?![\\s])(?:\\\\.|[^/])+/(?:[ioxmuesn]\\b)?",name:"string.regexp.ruby"},{match:{match:"#.*",literal:"#"},name:"comment.line.number-sign.ruby",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},{begin:{match:"^=begin\\b",literal:"\n=begin "},end:{match:"^=end\\b",literal:"\n=end "},name:"comment.block.ruby",patterns:[{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{include:"#variable"},{match:"\\b0[bB][01]+\\b",name:"constant.numeric.binary.ruby"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.ruby"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.control.ruby"},{match:"\\b(?:"+i.join("|")+")\\b",name:"constant.language.ruby"},{match:"\\b(?:"+o.join("|")+")\\b",name:"variable.language.ruby"}],repository:{classRef:{match:"\\w+::\\w+"},symbol:{match:":\\w+",name:"entity.name.symbol.ruby"},symbol_quoted_single:{match:":'[^']*'",name:"entity.name.symbol.quoted.single.ruby"},symbol_quoted_double:{match:':"[^"]*"',name:"entity.name.symbol.quoted.double.ruby"},variable:{match:"@\\w+",name:"entity.name.variable.ruby"}}}),{id:r[r.length-1].id,grammars:r,keywords:n.concat(t).concat(i).concat(o)}}),t("orion/editor/stylers/text_x-haml/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/text_x-ruby/syntax"],function(e,n){var t=[];return t.push.apply(t,e.grammars),t.push.apply(t,n.grammars),t.push({id:"orion.haml",contentTypes:["text/x-haml"],patterns:[{include:"#inlineRuby"},{include:"#interpolatedRuby"},{include:"#tagWithRubySymbols"},{include:"#tagWithHTMLAttributes"},{include:"#doctype"},{include:"#tag"},{include:"#htmlComment"}],repository:{doctype:{match:"^!!!.*$",name:"meta.tag.doctype.haml"},htmlComment:{match:{match:"/[^[].*$",literal:"/"},name:"comment.line.html.haml"},inlineRuby:{begin:"(?:^|[^\\\\])(?:=|-|~|&==?|!==?)",end:"(?:^|[^,])$",contentName:"source.ruby.embedded.haml",patterns:[{include:"orion.ruby"}]},interpolatedRuby:{begin:"#{",end:"}",contentName:"source.ruby.embedded.haml",patterns:[{include:"orion.ruby"}]},tag:{match:"^\\s*%[^\\b]+?\\b",name:"meta.tag.haml"},tagWithHTMLAttributes:{begin:"(^\\s*)(%[^\\s(]+?)\\(",end:"\\)\\s*$",beginCaptures:{2:{name:"meta.tag.haml"}},patterns:[{match:"[^\\s=]+(?==)",name:"entity.name.attribute.html.haml"},{include:"orion.ruby#variable"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},tagWithRubySymbols:{begin:"(^\\s*)(%[^\\b]+?)\\b{",end:"}\\s*$",beginCaptures:{2:{name:"meta.tag.haml"}},patterns:[{include:"orion.ruby#symbol"},{include:"orion.ruby#variable"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]}}}),{id:t[t.length-1].id,grammars:t,keywords:[]}}),t("plugins/languages/haml/hamlPlugin",["orion/plugin","orion/editor/stylers/text_x-haml/syntax"],function(e,n){function t(){var n={name:"Orion Haml Tool Support",version:"1.0",description:"This plugin provides Haml tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-haml","extends":"text/plain",name:"Haml",extension:["haml"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/editor/stylers/text_x-jade/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/application_javascript/syntax"],function(e,n){var t=["&attributes","block","case","default","doctype","each","else","extends","for","if","include","mixin","unless","when","while"],i=[];return i.push.apply(i,e.grammars),i.push.apply(i,n.grammars),i.push({id:"orion.jade",contentTypes:["text/x-jade"],patterns:[{include:"#comment_singleLine"},{include:"#code"},{include:"#control"},{include:"#caseBranch"},{include:"#mixinWithParameters"},{include:"#mixinRefWithArguments"},{include:"#tagWithAttributes"},{include:"#interpolatedJS"},{include:"#interpolatedTag"},{include:"#mixin"},{include:"#mixinRef"},{include:"#doctype"},{include:"#filter"},{include:"#case"},{include:"#andAttributes"},{include:"#otherKeywords"},{include:"#tag"}],repository:{andAttributes:{match:"&attributes\\b",name:"keyword.operator.jade"},"case":{match:"(^\\s*)(case)\\b",captures:{2:{name:"keyword.control.jade"}}},caseBranch:{begin:"(^\\s*)(when|default)\\s*",end:":|$",contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}],beginCaptures:{2:{name:"keyword.control.jade"}}},code:{match:"(^\\s*- |= |!= ).*$",name:"source.js.embedded.jade",patterns:[{include:"orion.js"}]},comment_singleLine:{match:{match:"^\\s*//.*",literal:"//"},name:"comment.line.double-slash.jade",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},control:{begin:"(^\\s*)(if|else( if)?|each|for|unless|while)\\b",end:"$",beginCaptures:{2:{name:"keyword.control.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]},doctype:{match:"(^\\s*)(doctype.+$)",captures:{2:{name:"meta.tag.doctype.jade"}}},filter:{match:"(^\\s*)(:\\w+)",captures:{2:{name:"entity.other.filter.jade"}}},interpolatedJS:{begin:"(#{)",end:"(})",captures:{1:{name:"string.interpolated.js.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]},interpolatedTag:{begin:"(#\\[)",end:"(\\])",captures:{1:{name:"string.interpolated.tag.jade"}},patterns:[{begin:"(\\.|\\w+)\\s*\\(",end:"(\\))(/)?",beginCaptures:{1:{name:"meta.tag.jade"}},endCaptures:{2:{name:"meta.tag.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]}]},mixin:{match:"(^\\s*)(mixin)(\\s+)(\\w+)",captures:{2:{name:"keyword.operator.jade"},4:{name:"entity.name.mixin.jade"}}},mixinRef:{match:"(^\\s*)(\\+\\w+)",captures:{2:{name:"entity.name.mixin.jade"}}},mixinRefWithArguments:{begin:"(^\\s*)(\\+\\w+)\\s*\\(",end:"\\)|$",captures:{2:{name:"entity.name.mixin.jade"}},patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.lib#number_decimal"}]},mixinWithParameters:{begin:"(^\\s*)(mixin)(\\s+)(\\w+)\\s*\\(",end:"\\)|$",beginCaptures:{2:{name:"keyword.operator.jade"},4:{name:"entity.name.mixin.jade"}},patterns:[{match:"[^\\s,]+",name:"variable.parameter.jade"}]},otherKeywords:{match:"(^\\s*)(block|extends|include)\\b",captures:{2:{name:"keyword.operator.jade"}}},tag:{match:"(^\\s*)(\\w+|(?=\\.)|(?=#))(#\\w*|\\.\\w*)*(/?)",captures:{2:{name:"meta.tag.jade"},4:{name:"meta.tag.jade"}}},tagWithAttributes:{begin:"(^\\s*)(\\w+|(?=\\.)|(?=#))(#\\w*|\\.\\w*)*\\s*\\(",end:"(\\))(/)?",beginCaptures:{2:{name:"meta.tag.jade"}},endCaptures:{2:{name:"meta.tag.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]}}}),{id:i[i.length-1].id,grammars:i,keywords:t}}),t("plugins/languages/jade/jadePlugin",["orion/plugin","orion/editor/stylers/text_x-jade/syntax"],function(e,n){function t(){var n={name:"Orion Jade Tool Support",version:"1.0",description:"This plugin provides Jade tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-jade","extends":"text/plain",name:"Jade",extension:["jade"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/editor/stylers/text_x-java-source/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["abstract","boolean","byte","char","class","double","extends","final","float","implements","import","instanceof","int","interface","long","native","new","package","private","protected","public","short","static","synchronized","throws","transient","void","volatile"],t=["break","case","catch","continue","default","do","else","finally","for","if","return","switch","throw","try","while"],i=["false","null","true"],o=["this","super"],r=[];return r.push.apply(r,e.grammars),r.push({id:"orion.java",contentTypes:["text/x-java-source"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.java"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.control.java"},{match:"\\b(?:"+i.join("|")+")\\b",name:"constant.language.java"},{match:"\\b(?:"+o.join("|")+")\\b",name:"variable.language.java"}]}),{id:r[r.length-1].id,grammars:r,keywords:n.concat(t).concat(i).concat(o)}}),t("orion/editor/stylers/application_x-jsp/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/text_x-java-source/syntax","orion/editor/stylers/text_html/syntax"],function(e,n,t){var i=["autoFlush","buffer","contentType","errorPage","extends","import","info","isErrorPage","isThreadSafe","language","pageEncoding","session"],o=[];return o.push.apply(o,e.grammars),o.push.apply(o,n.grammars),o.push.apply(o,t.grammars),o.push({id:"orion.jsp",contentTypes:["application/x-jsp"],patterns:[{include:"orion.html"},{include:"#jspComment"},{include:"#jspJavaFragment"},{include:"#jspDirectiveInclude"},{include:"#jspDirectivePage"},{include:"#jspDirectiveTaglib"}],repository:{jspComment:{begin:{match:"<%--",literal:"<%--"},end:{match:"--%>",literal:"<%--"},name:"comment.block.jsp",patterns:[{match:"(\\b)(TODO)(\\b)(((?!--%>).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.line"}}}]},jspDirectiveInclude:{begin:"<%@\\s+include(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.directive.include.jsp"}},patterns:[{match:"\\bfile\\b",name:"entity.other.attribute-name.jsp"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},jspDirectivePage:{begin:"<%@\\s+page(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.directive.page.jsp"}},patterns:[{match:"\\b(?:"+i.join("|")+")\\b",name:"entity.other.attribute-name.jsp"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},jspDirectiveTaglib:{begin:"<%@\\s+taglib(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.directive.taglib.jsp"}},patterns:[{match:"\\b(?:uri|prefix)\\b",name:"entity.other.attribute-name.jsp"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},jspJavaFragment:{begin:"<%(?:=|!)?(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.declaration.java"}},contentName:"source.java.embedded.jsp",patterns:[{include:"orion.java"}]}}}),{id:o[o.length-1].id,grammars:o,keywords:[]}}),t("plugins/languages/java/javaPlugin",["orion/plugin","orion/editor/stylers/text_x-java-source/syntax","orion/editor/stylers/application_x-jsp/syntax"],function(e,n,t){function i(){var n={name:"Orion Java Tool Support",version:"1.0",description:"This plugin provides Java tools support for Orion."},t=new e(n);o(t),t.connect()}function o(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-java-source","extends":"text/plain",name:"Java",extension:["java"]},{id:"application/x-jsp","extends":"text/plain",name:"Java Server Page",extension:["jsp"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)}),t.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:i,registerServiceProviders:o}}),t("orion/editor/stylers/text_jsx/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/application_javascript/syntax","orion/editor/stylers/application_xml/syntax"],function(e,n,t){var i=[];return i.push.apply(i,e.grammars),i.push.apply(i,n.grammars),i.push.apply(i,t.grammars),i.push({id:"orion.jsx",contentTypes:["text/jsx"],patterns:[{begin:"",captures:{0:{name:"meta.tag.jsx"}},patterns:[{include:"#jsExpression"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.c-like#comment_block"}]},{include:"orion.xml#ampersandEscape"},{include:"orion.js"}],repository:{jsExpression:{begin:"\\{",end:"\\}",contentName:"source.js.embedded.jsx",patterns:[{include:"orion.js"}]}}}),{id:i[i.length-1].id,grammars:i,keywords:[]}}),t("plugins/languages/jsx/jsxPlugin",["orion/plugin","orion/editor/stylers/text_jsx/syntax"],function(e,n){function t(){var n={name:"Orion JSX Tool Support",version:"1.0",description:"This plugin provides JSX tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/jsx","extends":"text/plain",name:"JSX",extension:["jsx"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("plugins/languages/launch/launchPlugin",["orion/plugin"],function(e){function n(){var n={name:"Orion Launch File Tool Support",version:"1.0",description:"This plugin provides tools support for Orion Launch files."},i=new e(n);t(i),i.connect()}function t(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-launch","extends":"application/json",name:"Launch file",extension:["launch"]}]})}return{connect:n,registerServiceProviders:t}}),t("orion/editor/stylers/text_x-lua/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["and","break","do","else","elseif","end","false","for","function","if","in","local","nil","not","or","repeat","return","then","true","until","while"],t=["assert","arg","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load","loadfile","loadstring","next","pairs","pcall","print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall"],i=["_G","LUA_INIT","LUA_PATH","LUA_CPATH","_VERSION"],o=[];return o.push.apply(o,e.grammars),o.push({id:"orion.lua",contentTypes:["text/x-luasrc","text/x-lua"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"#comment_block_dash_dash"},{include:"#comment_singleLine_dash_dash"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{include:"#base_functions"},{include:"#base_variables"},{include:"#reserved_underscore_capital"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.lua"}],repository:{comment_block_dash_dash:{begin:{match:"--\\[\\[",literal:"--[["},end:{match:"\\]\\]",literal:"]]"},name:"comment.block.dash-dash.lua",patterns:[{match:"(\\b)(TODO)(\\b)(((?!\\]\\]).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},comment_singleLine_dash_dash:{begin:{match:"--",literal:"--"},end:{match:"$",literal:""},name:"comment.line.dash-dash.lua",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},base_functions:{match:"\\b(?:"+t.join("|")+")\\b",name:"support.function.lua"},base_variables:{match:"\\b(?:"+i.join("|")+")\\b",name:"support.variable.lua"},reserved_underscore_capital:{match:"\\b_[A-Z]*\\b",name:"constant.other.userdefined.lua"}}}),{id:o[o.length-1].id,grammars:o,keywords:n}}),t("plugins/languages/lua/luaPlugin",["orion/plugin","orion/editor/stylers/text_x-lua/syntax"],function(e,n){function t(){var n={name:"Orion Lua Tool Support",version:"1.0",description:"This plugin provides Lua tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-lua","extends":"text/plain",name:"Lua",extension:["lua"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/i18nUtil",[],function(){function e(e){var n=/\$\{([^\}]+)\}/g,t=arguments;return 2===t.length&&t[1]&&"object"==typeof t[1]?e.replace(n,function(e,n){return t[1][n]}):e.replace(n,function(e,n){return t[(n<<0)+1]})}return{formatMessage:e}}),function(){"use strict";function e(e,n,t,i,o,r){n[e]&&(t.push(e),(n[e]===!0||1===n[e])&&i.push(o+e+"/"+r))}function i(e,t,i,o,r){var a=o+t+"/"+r;n._fileExists(e.toUrl(a+".js"))&&i.push(a)}function o(e,n,t){var i;for(i in n)!n.hasOwnProperty(i)||e.hasOwnProperty(i)&&!t?"object"==typeof n[i]&&(!e[i]&&n[i]&&(e[i]={}),o(e[i],n[i],t)):e[i]=n[i]}var r=/(^.*(^|\/)nls(\/|$))([^\/]*)\/?([^\/]*)/;t("i18n",["module"],function(n){var t=n.config?n.config():{};return t=t||{},{version:"2.0.4",load:function(n,a,s,l){l=l||{},l.locale&&(t.locale=l.locale);var c,d,u,p=r.exec(n),m=p[1],g=p[4],h=p[5],b=g.split("-"),f=[],y={},v="";if(p[5]?(m=p[1],c=m+h):(c=n,h=p[4],g=t.locale,g||(g=t.locale="undefined"==typeof navigator?"root":(navigator.language||navigator.userLanguage||"root").toLowerCase()),b=g.split("-")),l.isBuild){for(f.push(c),i(a,"root",f,m,h),d=0;d-1&&i[e];e--)r=i[e],t=n[r],(t===!0||1===t)&&(t=a(m+r+"/"+h)),o(y,t);s(y)})})}}})}(),t("orion/nls/messages",{root:!0}),t("orion/nls/root/messages",{Navigator:"Navigator",Sites:"Sites",Shell:"Shell","Get Plugins":"Get Plug-ins",Global:"Global",Editor:"Editor",EditorRelatedLink:"Show Current Folder",EditorRelatedLinkParent:"Show Enclosing Folder",EditorLinkWorkspace:"Edit",EditorRelatedLinkProj:"Show Project",navigationBar:"Navigation Bar","Filter bindings":"Filter bindings",BindingPrompt:"Enter the new binding",NoBinding:"---",orionClientLabel:"Orion client repository","Orion Editor":"Orion Editor","Orion Image Viewer":"Orion Image Viewer","Orion Markdown Editor":"Orion Markdown Editor","Orion Markdown Viewer":"Orion Markdown Viewer","Orion JSON Editor":"Orion JSON Editor","View on Site":"View on Site","View this file or folder on a web site hosted by Orion":"View this file or folder on a web site hosted by Orion.",ShowAllKeyBindings:"Show a list of all the keybindings on this page","Show Keys":"Show Keys",HideShowBannerFooter:"Hide or show the page banner","Toggle banner and footer":"Toggle banner",ChooseFileOpenEditor:"Choose a file by name and open an editor on it",FindFile:"Open File...","System Configuration Details":"System Configuration Details","System Config Tooltip":"Go to the System Configuration Details page","Background Operations":"Background Operations","Background Operations Tooltip":"Go to the Background Operations page","Operation status is unknown":"Operation status is unknown","Unknown item":"Unknown item",NoSearchAvailableErr:"Can't search: no search service is available",Related:"Related",Options:"Options","LOG: ":"LOG: ",View:"View",SplashTitle:"Setting up Workspace",SplashTitleSettings:"Loading Settings",SplashTitleGit:"Loading Git Repositories",LoadingPage:"Loading Page",LoadingPlugins:"Loading Plugins",LoadingResources:"Loading Resources",plugin_started:'"${0}" started',"plugin_lazy activation":'"${0}" lazily activated',plugin_starting:'"${0}" starting',"no parent":"no parent","no tree model":"no tree model","no renderer":"no renderer","could not find table row ":"could not find table row ",Operations:"Operations","Operations running":"Operations running",SomeOpWarning:"Some operations finished with warning",SomeOpErr:"Some operations finished with error","no service registry":"no service registry",Tasks:"Tasks",Close:"Close","Expand all":"Expand all","Collapse all":"Collapse all",Search:"Search","Advanced search":"Advanced search",Submit:"Submit",More:"More","Recent searches":"Recent searches","Regular expression":"Regular expression","Search options":"Search options","Global search":"Global search","Orion Home":"Orion Home","Close notification":"Close notification",OpPressSpaceMsg:"Operations - Press spacebar to show current operations","Toggle side panel":"Toggle side panel","Open or close the side panel":"Open or close the side panel",Projects:"Projects","Toggle Sidebar":"Toggle Sidebar","Sample HTML5 Site":"Sample HTML5 Site","Generate an HTML5 'Hello World' website, including JavaScript, HTML, and CSS files.":"Generate an HTML5 'Hello World' website, including JavaScript, HTML, and CSS files.","Sample Orion Plugin":"Sample Orion Plug-in","Generate a sample plugin for integrating with Orion.":"Generate a sample plug-in for integrating with Orion.",Browser:"Web Browser",OutlineProgress:"Getting outline for ${0} from ${1}",outlineTimeout:"Outline service timed out. Try reloading the page and opening the outline again.",UnknownError:"An unknown error occurred.",Filter:"Filter (* = any string, ? = any character)",TemplateExplorerLabel:"Templates",OpenTemplateExplorer:"Open Template Explorer",Edit:"Edit",CentralNavTooltip:"Toggle Navigation Menu","Wrote: ${0}":"Wrote: ${0}",GenerateHTML:"Generate HTML file",GenerateHTMLTooltip:"Write an HTML file generated from the current Markdown editor content","alt text":"alt text",blockquote:"blockquote",code:"code","code (block)":"code (block)","code (span)":"code (span)",emphasis:"emphasis","fenced code (${0})":"fenced code (${0})","header (${0})":"header (${0})","horizontal rule":"horizontal rule",label:"label","link (auto)":"link (auto)","link (image)":"link (image)","link (inline)":"link (inline)","link label":"link label","link label (optional)":"link label (optional)","link (ref)":"link (ref)","list item (bullet)":"list item (bullet)","list item (numbered)":"list item (numbered)","strikethrough (${0})":"strikethrough (${0})",strong:"strong","table (${0})":"table (${0})",text:"text","title (optional)":"title (optional)",url:"url",workedProgress:"${0} (${1}/${2})",TogglePaneOrientationTooltip:"Toggle split pane orientation",WarningDuplicateLinkId:"Duplicate link ID: ${0} (link IDs are not case-sensitive)",WarningHeaderTooDeep:"Header level cannot exceed 6",WarningLinkHasNoText:"Link has no text",WarningLinkHasNoURL:"Link has no URL",WarningOrderedListItem:"Ordered list item within unordered list",WarningOrderedListShouldStartAt1:"The first item in an ordered list should have index 1",WarningUndefinedLinkId:"Undefined link ID: ${0}",WarningUnorderedListItem:"Unordered list item within ordered list",PageTitleFormat:"${0} - ${1}",KeyCTRL:"Ctrl",KeySHIFT:"Shift",KeyALT:"Alt",KeyBKSPC:"Backspace",KeyDEL:"Del",KeyEND:"End",KeyENTER:"Enter",KeyESCAPE:"Esc",KeyHOME:"Home",KeyINSERT:"Ins",KeyPAGEDOWN:"Page Down",KeyPAGEUP:"Page Up",KeySPACE:"Space",KeyTAB:"Tab","a year":"a year",years:"${0} years","a month":"a month",months:"${0} months","a day":"a day",days:"${0} days","an hour":"an hour",hours:"${0} hours","a minute":"a minute",minutes:"${0} minutes",timeAgo:"${0} ago",justNow:"just now",fixAll:"Fix all"}),t("plugins/languages/markdown/markdownPlugin",["orion/plugin","orion/i18nUtil","i18n!orion/nls/messages"],function(e,n,t){function i(){var n={name:"Orion Extended Markdown Language Tool Support",version:"1.0",description:"This plugin provides extended Markdown language tools support for Orion."},t=new e(n); -+return o.push.apply(o,e.grammars),o.push.apply(o,n.grammars),o.push.apply(o,t.grammars),o.push({id:"orion.html",contentTypes:["text/html"],patterns:[{begin:"(?i)(]*)(>)",end:"(?i)()",captures:{1:{name:"meta.tag.html"},3:{name:"meta.tag.html"}},contentName:"source.css.embedded.html",patterns:[{include:"orion.css"}]},{begin:"(?i)|",end:"(?i)",captures:{0:{name:"meta.tag.html"}},contentName:"source.js.embedded.html",patterns:[{include:"orion.js"}]},{begin:"",captures:{0:{name:"meta.tag.html"}},patterns:[{include:"orion.xml#comment"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"#attribute"}]},{include:"orion.xml#comment"},{include:"orion.xml#doctype"},{include:"orion.xml#ampersandEscape"}],repository:{attribute:{match:"\\b(?:"+i.join("|")+")\\b",name:"meta.tag.attribute.html"}}}),{id:o[o.length-1].id,grammars:o,keywords:[],attributes:i}}),t("orion/editor/stylers/text_x-cshtml/syntax",["orion/editor/stylers/application_xml/syntax","orion/editor/stylers/text_html/syntax","orion/editor/stylers/text_x-csharp/syntax"],function(e,n,t){var i=[];return i.push.apply(i,e.grammars),i.push.apply(i,n.grammars),i.push.apply(i,t.grammars),i.push({id:"orion.cshtml",contentTypes:["text/x-cshtml"],patterns:[{include:"#comment"},{include:"#codeBlock"},{include:"#expression"},{include:"#reference"},{include:"orion.html"}],repository:{comment:{begin:{match:"@\\*",literal:"@*"},end:{match:"\\*@",literal:"*@"},name:"comment.block.cshtml"},codeBlock:{begin:"(^\\s*)(@)(?=([^{]*){)",end:"}",captures:{2:{name:"entity.name.declaration.csharp"}},contentName:"source.csharp.embedded.cshtml",patterns:[{include:"orion.xml#tag"},{include:"#reference"},{include:"orion.csharp"}]},expression:{match:"^\\s*@[^{]*$",name:"source.csharp.embedded.cshtml",patterns:[{include:"#reference"},{include:"orion.csharp"}]},reference:{match:"@",name:"entity.name.declaration.csharp"}}}),{id:i[i.length-1].id,grammars:i,keywords:[]}}),t("plugins/languages/csharp/csharpPlugin",["orion/plugin","orion/editor/stylers/text_x-csharp/syntax","orion/editor/stylers/text_x-cshtml/syntax"],function(e,n,t){function i(){var n={name:"Orion C# Tool Support",version:"1.0",description:"This plugin provides C# tools support for Orion."},t=new e(n);o(t),t.connect()}function o(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-csharp","extends":"text/plain",name:"C#",extension:["cs"]},{id:"text/x-cshtml","extends":"text/plain",name:"cshtml",extension:["cshtml"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)}),t.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:i,registerServiceProviders:o}}),t("orion/editor/stylers/text_x-dockerfile/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["add","cmd","copy","entrypoint","env","expose","from","maintainer","onbuild","run","user","volume","workdir"],t="orion.dockerfile",i=[];return i.push.apply(i,e.grammars),i.push({id:t,contentTypes:["text/x-dockerfile"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"#numberSignComment"},{match:"\\b-?[0-9]+(\\.[0-9]+)?\\b",name:"constant.numeric.dockerfile"},{match:"(?i)^\\s*(?:"+n.join("|")+")\\b",name:"keyword.operator.dockerfile"}],repository:{numberSignComment:{begin:{match:"^\\s*#",literal:"#"},end:{match:"$",literal:""},name:"comment.line.number-sign.dockerfile",patterns:[{include:"orion.lib#todo_comment_singleLine"}]}}}),{id:t,grammars:i,keywords:n}}),t("plugins/languages/docker/dockerPlugin",["orion/plugin","orion/editor/stylers/text_x-dockerfile/syntax"],function(e,n){function t(){var n={name:"Orion Editor Docker Tool Support",version:"1.0",description:"This plugin provides Docker tools support for the Orion editor."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-dockerfile","extends":"text/plain",name:"dockerfile",extension:["dockerfile"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/editor/stylers/text_x-erlang/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["xor","when","try","rem","receive","query","orelse","or","of","not","let","if","fun","end","div","cond","catch","case","bxor","bsr","bsl","bor","bnot","begin","band","andalso","and","after"],t=["vsn","undef","type","spec","record","on_load","opaque","module","include_lib","include","import","ifndef","ifdef","file","export_type","export","endif","else","define","callback","compile","behaviour"],i=[];return i.push.apply(i,e.grammars),i.push({id:"orion.erlang",contentTypes:["text/x-erlang"],patterns:[{include:"#comment"},{include:"#stringSingleLine"},{include:"#stringMultiLine"},{include:"#method"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.erlang"},{match:"^\\s*-(?:"+t.join("|")+")\\b",name:"keyword.operator.erlang"}],repository:{comment:{match:{match:"%.*",literal:"%"},name:"comment.line.erlang",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},method:{match:"(^|\\s)[a-zA-Z0-9_.]+(?=\\(|\\s\\()",name:"entity.name.function.erlang"},stringMultiLine:{begin:'"(?:\\\\.|[^\\\\"])*$',end:'^(?:\\\\.|[^\\\\"])*"',name:"string.quoted.double.erlang"},stringSingleLine:{match:'"(?:\\\\.|[^\\\\"])*"',name:"string.quoted.double.erlang"}}}),{id:i[i.length-1].id,grammars:i,keywords:n}}),t("plugins/languages/erlang/erlangPlugin",["orion/plugin","orion/editor/stylers/text_x-erlang/syntax"],function(e,n){function t(){var n={name:"Orion Erlang Tool Support",version:"1.0",description:"This plugin provides Erlang tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-erlang","extends":"text/plain",name:"Erlang",extension:["erl","hrl"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/form",[],function(){function e(e){return encodeURIComponent(e).replace(/[!'()*]/g,escape).replace("%20","+")}return{encodeFormData:function(n){n=n||{};for(var t=Object.keys(n),i=[],o=0;o0&&m.positions.push({offset:b,length:f})}s.push(m)}}return s}},{name:"Go content assist",contentType:["text/x-go"]})}return{connect:i,registerServiceProviders:o}}),t("orion/editor/stylers/text_x-git-ignore/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.gitignore",contentTypes:["text/x-git-ignore"],patterns:[{match:{match:"^\\s*#[^$]*",literal:"#"},name:"comment.line.number-sign.ignore"},{match:"^\\s*!",name:"punctuation.operator.negation.ignore"}]}),{id:n[n.length-1].id,grammars:n,keywords:[]}}),t("orion/editor/stylers/text_x-git-config/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=[];return n.push.apply(n,e.grammars),n.push({id:"orion.gitconfig",contentTypes:["text/x-git-config"],patterns:[{match:"[;#][^$]*",name:"comment.line.gitconfig"},{match:"=",name:"punctuation.operator.equals.gitconfig"},{match:"^\\s*\\[[-.A-Za-z0-9]+\\]\\s*$",name:"entity.section.name.gitconfig"}]}),{id:n[n.length-1].id,grammars:n,keywords:[]}}),t("plugins/languages/git/gitFilePlugin",["orion/plugin","orion/editor/stylers/text_x-git-ignore/syntax","orion/editor/stylers/text_x-git-config/syntax"],function(e,n,t){function i(){var n={name:"Orion Git File Support",version:"1.0",description:"This plugin provides Git file syntax highlighting for Orion."},t=new e(n);o(t),t.connect()}function o(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-git-ignore","extends":"text/plain",name:"Git Ignore",extension:["gitignore"]},{id:"text/x-git-config","extends":"text/plain",name:"Git Config",filename:["config"]},{id:"text/x-cf-ignore","extends":"text/x-git-ignore",name:"cf Ignore",extension:["cfignore"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)}),t.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:i,registerServiceProviders:o}}),t("orion/editor/stylers/text_x-ruby/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["alias_method","alias","attr_accessor","attr_reader","attr_writer","attr","BEGIN","class","defined?","def","END","extend","gem","include","initialize","in","load","lambda","module_function","module","new","not","public","prepend","private","protected","require_relative","require","undef","__ENCODING__","__END__","__FILE__","__LINE__"],t=["and","begin","break","case","catch","do","else","elsif","end","ensure","fail","for","if","loop","next","or","raise","redo","rescue","retry","return","then","throw","unless","until","when","while","yield"],i=["false","nil","true"],o=["self","super"],r=[];return r.push.apply(r,e.grammars),r.push({id:"orion.ruby",contentTypes:["text/x-ruby"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"#symbol_quoted_single"},{include:"#symbol_quoted_double"},{include:"#symbol"},{include:"#classRef"},{match:"/(?![\\s])(?:\\\\.|[^/])+/(?:[ioxmuesn]\\b)?",name:"string.regexp.ruby"},{match:{match:"#.*",literal:"#"},name:"comment.line.number-sign.ruby",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},{begin:{match:"^=begin\\b",literal:"\n=begin "},end:{match:"^=end\\b",literal:"\n=end "},name:"comment.block.ruby",patterns:[{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{include:"#variable"},{match:"\\b0[bB][01]+\\b",name:"constant.numeric.binary.ruby"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.ruby"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.control.ruby"},{match:"\\b(?:"+i.join("|")+")\\b",name:"constant.language.ruby"},{match:"\\b(?:"+o.join("|")+")\\b",name:"variable.language.ruby"}],repository:{classRef:{match:"\\w+::\\w+"},symbol:{match:":\\w+",name:"entity.name.symbol.ruby"},symbol_quoted_single:{match:":'[^']*'",name:"entity.name.symbol.quoted.single.ruby"},symbol_quoted_double:{match:':"[^"]*"',name:"entity.name.symbol.quoted.double.ruby"},variable:{match:"@\\w+",name:"entity.name.variable.ruby"}}}),{id:r[r.length-1].id,grammars:r,keywords:n.concat(t).concat(i).concat(o)}}),t("orion/editor/stylers/text_x-haml/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/text_x-ruby/syntax"],function(e,n){var t=[];return t.push.apply(t,e.grammars),t.push.apply(t,n.grammars),t.push({id:"orion.haml",contentTypes:["text/x-haml"],patterns:[{include:"#inlineRuby"},{include:"#interpolatedRuby"},{include:"#tagWithRubySymbols"},{include:"#tagWithHTMLAttributes"},{include:"#doctype"},{include:"#tag"},{include:"#htmlComment"}],repository:{doctype:{match:"^!!!.*$",name:"meta.tag.doctype.haml"},htmlComment:{match:{match:"/[^[].*$",literal:"/"},name:"comment.line.html.haml"},inlineRuby:{begin:"(?:^|[^\\\\])(?:=|-|~|&==?|!==?)",end:"(?:^|[^,])$",contentName:"source.ruby.embedded.haml",patterns:[{include:"orion.ruby"}]},interpolatedRuby:{begin:"#{",end:"}",contentName:"source.ruby.embedded.haml",patterns:[{include:"orion.ruby"}]},tag:{match:"^\\s*%[^\\b]+?\\b",name:"meta.tag.haml"},tagWithHTMLAttributes:{begin:"(^\\s*)(%[^\\s(]+?)\\(",end:"\\)\\s*$",beginCaptures:{2:{name:"meta.tag.haml"}},patterns:[{match:"[^\\s=]+(?==)",name:"entity.name.attribute.html.haml"},{include:"orion.ruby#variable"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},tagWithRubySymbols:{begin:"(^\\s*)(%[^\\b]+?)\\b{",end:"}\\s*$",beginCaptures:{2:{name:"meta.tag.haml"}},patterns:[{include:"orion.ruby#symbol"},{include:"orion.ruby#variable"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]}}}),{id:t[t.length-1].id,grammars:t,keywords:[]}}),t("plugins/languages/haml/hamlPlugin",["orion/plugin","orion/editor/stylers/text_x-haml/syntax"],function(e,n){function t(){var n={name:"Orion Haml Tool Support",version:"1.0",description:"This plugin provides Haml tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-haml","extends":"text/plain",name:"Haml",extension:["haml"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/editor/stylers/text_x-jade/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/application_javascript/syntax"],function(e,n){var t=["&attributes","block","case","default","doctype","each","else","extends","for","if","include","mixin","unless","when","while"],i=[];return i.push.apply(i,e.grammars),i.push.apply(i,n.grammars),i.push({id:"orion.jade",contentTypes:["text/x-jade"],patterns:[{include:"#comment_singleLine"},{include:"#code"},{include:"#control"},{include:"#caseBranch"},{include:"#mixinWithParameters"},{include:"#mixinRefWithArguments"},{include:"#tagWithAttributes"},{include:"#interpolatedJS"},{include:"#interpolatedTag"},{include:"#mixin"},{include:"#mixinRef"},{include:"#doctype"},{include:"#filter"},{include:"#case"},{include:"#andAttributes"},{include:"#otherKeywords"},{include:"#tag"}],repository:{andAttributes:{match:"&attributes\\b",name:"keyword.operator.jade"},"case":{match:"(^\\s*)(case)\\b",captures:{2:{name:"keyword.control.jade"}}},caseBranch:{begin:"(^\\s*)(when|default)\\s*",end:":|$",contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}],beginCaptures:{2:{name:"keyword.control.jade"}}},code:{match:"(^\\s*- |= |!= ).*$",name:"source.js.embedded.jade",patterns:[{include:"orion.js"}]},comment_singleLine:{match:{match:"^\\s*//.*",literal:"//"},name:"comment.line.double-slash.jade",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},control:{begin:"(^\\s*)(if|else( if)?|each|for|unless|while)\\b",end:"$",beginCaptures:{2:{name:"keyword.control.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]},doctype:{match:"(^\\s*)(doctype.+$)",captures:{2:{name:"meta.tag.doctype.jade"}}},filter:{match:"(^\\s*)(:\\w+)",captures:{2:{name:"entity.other.filter.jade"}}},interpolatedJS:{begin:"(#{)",end:"(})",captures:{1:{name:"string.interpolated.js.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]},interpolatedTag:{begin:"(#\\[)",end:"(\\])",captures:{1:{name:"string.interpolated.tag.jade"}},patterns:[{begin:"(\\.|\\w+)\\s*\\(",end:"(\\))(/)?",beginCaptures:{1:{name:"meta.tag.jade"}},endCaptures:{2:{name:"meta.tag.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]}]},mixin:{match:"(^\\s*)(mixin)(\\s+)(\\w+)",captures:{2:{name:"keyword.operator.jade"},4:{name:"entity.name.mixin.jade"}}},mixinRef:{match:"(^\\s*)(\\+\\w+)",captures:{2:{name:"entity.name.mixin.jade"}}},mixinRefWithArguments:{begin:"(^\\s*)(\\+\\w+)\\s*\\(",end:"\\)|$",captures:{2:{name:"entity.name.mixin.jade"}},patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.lib#number_decimal"}]},mixinWithParameters:{begin:"(^\\s*)(mixin)(\\s+)(\\w+)\\s*\\(",end:"\\)|$",beginCaptures:{2:{name:"keyword.operator.jade"},4:{name:"entity.name.mixin.jade"}},patterns:[{match:"[^\\s,]+",name:"variable.parameter.jade"}]},otherKeywords:{match:"(^\\s*)(block|extends|include)\\b",captures:{2:{name:"keyword.operator.jade"}}},tag:{match:"(^\\s*)(\\w+|(?=\\.)|(?=#))(#\\w*|\\.\\w*)*(/?)",captures:{2:{name:"meta.tag.jade"},4:{name:"meta.tag.jade"}}},tagWithAttributes:{begin:"(^\\s*)(\\w+|(?=\\.)|(?=#))(#\\w*|\\.\\w*)*\\s*\\(",end:"(\\))(/)?",beginCaptures:{2:{name:"meta.tag.jade"}},endCaptures:{2:{name:"meta.tag.jade"}},contentName:"source.js.embedded.jade",patterns:[{include:"orion.js"}]}}}),{id:i[i.length-1].id,grammars:i,keywords:t}}),t("plugins/languages/jade/jadePlugin",["orion/plugin","orion/editor/stylers/text_x-jade/syntax"],function(e,n){function t(){var n={name:"Orion Jade Tool Support",version:"1.0",description:"This plugin provides Jade tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-jade","extends":"text/plain",name:"Jade",extension:["jade"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/editor/stylers/text_x-java-source/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["abstract","boolean","byte","char","class","double","enum","extends","final","float","implements","import","instanceof","int","interface","long","native","new","package","private","protected","public","short","static","synchronized","throws","transient","void","volatile"],t=["break","case","catch","continue","default","do","else","finally","for","if","return","switch","throw","try","while"],i=["false","null","true"],o=["this","super"],r=[];return r.push.apply(r,e.grammars),r.push({id:"orion.java",contentTypes:["text/x-java-source"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.java"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.control.java"},{match:"\\b(?:"+i.join("|")+")\\b",name:"constant.language.java"},{match:"\\b(?:"+o.join("|")+")\\b",name:"constant.language.java"},{match:"@[a-zA-Z_$\.]+",name:"annotation.language.java"}]}),{id:r[r.length-1].id,grammars:r,keywords:n.concat(t).concat(i).concat(o)}}),t("orion/editor/stylers/application_x-jsp/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/text_x-java-source/syntax","orion/editor/stylers/text_html/syntax"],function(e,n,t){var i=["autoFlush","buffer","contentType","errorPage","extends","import","info","isErrorPage","isThreadSafe","language","pageEncoding","session"],o=[];return o.push.apply(o,e.grammars),o.push.apply(o,n.grammars),o.push.apply(o,t.grammars),o.push({id:"orion.jsp",contentTypes:["application/x-jsp"],patterns:[{include:"orion.html"},{include:"#jspComment"},{include:"#jspJavaFragment"},{include:"#jspDirectiveInclude"},{include:"#jspDirectivePage"},{include:"#jspDirectiveTaglib"}],repository:{jspComment:{begin:{match:"<%--",literal:"<%--"},end:{match:"--%>",literal:"<%--"},name:"comment.block.jsp",patterns:[{match:"(\\b)(TODO)(\\b)(((?!--%>).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.line"}}}]},jspDirectiveInclude:{begin:"<%@\\s+include(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.directive.include.jsp"}},patterns:[{match:"\\bfile\\b",name:"entity.other.attribute-name.jsp"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},jspDirectivePage:{begin:"<%@\\s+page(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.directive.page.jsp"}},patterns:[{match:"\\b(?:"+i.join("|")+")\\b",name:"entity.other.attribute-name.jsp"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},jspDirectiveTaglib:{begin:"<%@\\s+taglib(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.directive.taglib.jsp"}},patterns:[{match:"\\b(?:uri|prefix)\\b",name:"entity.other.attribute-name.jsp"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"}]},jspJavaFragment:{begin:"<%(?:=|!)?(?:\\s|$)",end:"%>",captures:{0:{name:"entity.name.declaration.java"}},contentName:"source.java.embedded.jsp",patterns:[{include:"orion.java"}]}}}),{id:o[o.length-1].id,grammars:o,keywords:[]}}),t("plugins/languages/java/javaPlugin",["orion/plugin","orion/editor/stylers/text_x-java-source/syntax","orion/editor/stylers/application_x-jsp/syntax"],function(e,n,t){function i(){var n={name:"Orion Java Tool Support",version:"1.0",description:"This plugin provides Java tools support for Orion."},t=new e(n);o(t),t.connect()}function o(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-java-source","extends":"text/plain",name:"Java",extension:["java"]},{id:"application/x-jsp","extends":"text/plain",name:"Java Server Page",extension:["jsp"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)}),t.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:i,registerServiceProviders:o}}),t("orion/editor/stylers/text_jsx/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/application_javascript/syntax","orion/editor/stylers/application_xml/syntax"],function(e,n,t){var i=[];return i.push.apply(i,e.grammars),i.push.apply(i,n.grammars),i.push.apply(i,t.grammars),i.push({id:"orion.jsx",contentTypes:["text/jsx"],patterns:[{begin:"",captures:{0:{name:"meta.tag.jsx"}},patterns:[{include:"#jsExpression"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.c-like#comment_block"}]},{include:"orion.xml#ampersandEscape"},{include:"orion.js"}],repository:{jsExpression:{begin:"\\{",end:"\\}",contentName:"source.js.embedded.jsx",patterns:[{include:"orion.js"}]}}}),{id:i[i.length-1].id,grammars:i,keywords:[]}}),t("plugins/languages/jsx/jsxPlugin",["orion/plugin","orion/editor/stylers/text_jsx/syntax"],function(e,n){function t(){var n={name:"Orion JSX Tool Support",version:"1.0",description:"This plugin provides JSX tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/jsx","extends":"text/plain",name:"JSX",extension:["jsx"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("plugins/languages/launch/launchPlugin",["orion/plugin"],function(e){function n(){var n={name:"Orion Launch File Tool Support",version:"1.0",description:"This plugin provides tools support for Orion Launch files."},i=new e(n);t(i),i.connect()}function t(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-launch","extends":"application/json",name:"Launch file",extension:["launch"]}]})}return{connect:n,registerServiceProviders:t}}),t("orion/editor/stylers/text_x-lua/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["and","break","do","else","elseif","end","false","for","function","if","in","local","nil","not","or","repeat","return","then","true","until","while"],t=["assert","arg","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load","loadfile","loadstring","next","pairs","pcall","print","rawequal","rawget","rawset","require","select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall"],i=["_G","LUA_INIT","LUA_PATH","LUA_CPATH","_VERSION"],o=[];return o.push.apply(o,e.grammars),o.push({id:"orion.lua",contentTypes:["text/x-luasrc","text/x-lua"],patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"#comment_block_dash_dash"},{include:"#comment_singleLine_dash_dash"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{include:"#base_functions"},{include:"#base_variables"},{include:"#reserved_underscore_capital"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.lua"}],repository:{comment_block_dash_dash:{begin:{match:"--\\[\\[",literal:"--[["},end:{match:"\\]\\]",literal:"]]"},name:"comment.block.dash-dash.lua",patterns:[{match:"(\\b)(TODO)(\\b)(((?!\\]\\]).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},comment_singleLine_dash_dash:{begin:{match:"--",literal:"--"},end:{match:"$",literal:""},name:"comment.line.dash-dash.lua",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},base_functions:{match:"\\b(?:"+t.join("|")+")\\b",name:"support.function.lua"},base_variables:{match:"\\b(?:"+i.join("|")+")\\b",name:"support.variable.lua"},reserved_underscore_capital:{match:"\\b_[A-Z]*\\b",name:"constant.other.userdefined.lua"}}}),{id:o[o.length-1].id,grammars:o,keywords:n}}),t("plugins/languages/lua/luaPlugin",["orion/plugin","orion/editor/stylers/text_x-lua/syntax"],function(e,n){function t(){var n={name:"Orion Lua Tool Support",version:"1.0",description:"This plugin provides Lua tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-lua","extends":"text/plain",name:"Lua",extension:["lua"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/i18nUtil",[],function(){function e(e){var n=/\$\{([^\}]+)\}/g,t=arguments;return 2===t.length&&t[1]&&"object"==typeof t[1]?e.replace(n,function(e,n){return t[1][n]}):e.replace(n,function(e,n){return t[(n<<0)+1]})}return{formatMessage:e}}),function(){"use strict";function e(e,n,t,i,o,r){n[e]&&(t.push(e),(n[e]===!0||1===n[e])&&i.push(o+e+"/"+r))}function i(e,t,i,o,r){var a=o+t+"/"+r;n._fileExists(e.toUrl(a+".js"))&&i.push(a)}function o(e,n,t){var i;for(i in n)!n.hasOwnProperty(i)||e.hasOwnProperty(i)&&!t?"object"==typeof n[i]&&(!e[i]&&n[i]&&(e[i]={}),o(e[i],n[i],t)):e[i]=n[i]}var r=/(^.*(^|\/)nls(\/|$))([^\/]*)\/?([^\/]*)/;t("i18n",["module"],function(n){var t=n.config?n.config():{};return t=t||{},{version:"2.0.4",load:function(n,a,s,l){l=l||{},l.locale&&(t.locale=l.locale);var c,d,u,p=r.exec(n),m=p[1],g=p[4],h=p[5],b=g.split("-"),f=[],y={},v="";if(p[5]?(m=p[1],c=m+h):(c=n,h=p[4],g=t.locale,g||(g=t.locale="undefined"==typeof navigator?"root":(navigator.language||navigator.userLanguage||"root").toLowerCase()),b=g.split("-")),l.isBuild){for(f.push(c),i(a,"root",f,m,h),d=0;d-1&&i[e];e--)r=i[e],t=n[r],(t===!0||1===t)&&(t=a(m+r+"/"+h)),o(y,t);s(y)})})}}})}(),t("orion/nls/messages",{root:!0}),t("orion/nls/root/messages",{Navigator:"Navigator",Sites:"Sites",Shell:"Shell","Get Plugins":"Get Plug-ins",Global:"Global",Editor:"Editor",EditorRelatedLink:"Show Current Folder",EditorRelatedLinkParent:"Show Enclosing Folder",EditorLinkWorkspace:"Edit",EditorRelatedLinkProj:"Show Project",navigationBar:"Navigation Bar","Filter bindings":"Filter bindings",BindingPrompt:"Enter the new binding",NoBinding:"---",orionClientLabel:"Orion client repository","Orion Editor":"Orion Editor","Orion Image Viewer":"Orion Image Viewer","Orion Markdown Editor":"Orion Markdown Editor","Orion Markdown Viewer":"Orion Markdown Viewer","Orion JSON Editor":"Orion JSON Editor","View on Site":"View on Site","View this file or folder on a web site hosted by Orion":"View this file or folder on a web site hosted by Orion.",ShowAllKeyBindings:"Show a list of all the keybindings on this page","Show Keys":"Show Keys",HideShowBannerFooter:"Hide or show the page banner","Toggle banner and footer":"Toggle banner",ChooseFileOpenEditor:"Choose a file by name and open an editor on it",FindFile:"Open File...","System Configuration Details":"System Configuration Details","System Config Tooltip":"Go to the System Configuration Details page","Background Operations":"Background Operations","Background Operations Tooltip":"Go to the Background Operations page","Operation status is unknown":"Operation status is unknown","Unknown item":"Unknown item",NoSearchAvailableErr:"Can't search: no search service is available",Related:"Related",Options:"Options","LOG: ":"LOG: ",View:"View",SplashTitle:"Setting up Workspace",SplashTitleSettings:"Loading Settings",SplashTitleGit:"Loading Git Repositories",LoadingPage:"Loading Page",LoadingPlugins:"Loading Plugins",LoadingResources:"Loading Resources",plugin_started:'"${0}" started',"plugin_lazy activation":'"${0}" lazily activated',plugin_starting:'"${0}" starting',"no parent":"no parent","no tree model":"no tree model","no renderer":"no renderer","could not find table row ":"could not find table row ",Operations:"Operations","Operations running":"Operations running",SomeOpWarning:"Some operations finished with warning",SomeOpErr:"Some operations finished with error","no service registry":"no service registry",Tasks:"Tasks",Close:"Close","Expand all":"Expand all","Collapse all":"Collapse all",Search:"Search","Advanced search":"Advanced search",Submit:"Submit",More:"More","Recent searches":"Recent searches","Regular expression":"Regular expression","Search options":"Search options","Global search":"Global search","Orion Home":"Orion Home","Close notification":"Close notification",OpPressSpaceMsg:"Operations - Press spacebar to show current operations","Toggle side panel":"Toggle side panel","Open or close the side panel":"Open or close the side panel",Projects:"Projects","Toggle Sidebar":"Toggle Sidebar","Sample HTML5 Site":"Sample HTML5 Site","Generate an HTML5 'Hello World' website, including JavaScript, HTML, and CSS files.":"Generate an HTML5 'Hello World' website, including JavaScript, HTML, and CSS files.","Sample Orion Plugin":"Sample Orion Plug-in","Generate a sample plugin for integrating with Orion.":"Generate a sample plug-in for integrating with Orion.",Browser:"Web Browser",OutlineProgress:"Getting outline for ${0} from ${1}",outlineTimeout:"Outline service timed out. Try reloading the page and opening the outline again.",UnknownError:"An unknown error occurred.",Filter:"Filter (* = any string, ? = any character)",TemplateExplorerLabel:"Templates",OpenTemplateExplorer:"Open Template Explorer",Edit:"Edit",CentralNavTooltip:"Toggle Navigation Menu","Wrote: ${0}":"Wrote: ${0}",GenerateHTML:"Generate HTML file",GenerateHTMLTooltip:"Write an HTML file generated from the current Markdown editor content","alt text":"alt text",blockquote:"blockquote",code:"code","code (block)":"code (block)","code (span)":"code (span)",emphasis:"emphasis","fenced code (${0})":"fenced code (${0})","header (${0})":"header (${0})","horizontal rule":"horizontal rule",label:"label","link (auto)":"link (auto)","link (image)":"link (image)","link (inline)":"link (inline)","link label":"link label","link label (optional)":"link label (optional)","link (ref)":"link (ref)","list item (bullet)":"list item (bullet)","list item (numbered)":"list item (numbered)","strikethrough (${0})":"strikethrough (${0})",strong:"strong","table (${0})":"table (${0})",text:"text","title (optional)":"title (optional)",url:"url",workedProgress:"${0} (${1}/${2})",TogglePaneOrientationTooltip:"Toggle split pane orientation",WarningDuplicateLinkId:"Duplicate link ID: ${0} (link IDs are not case-sensitive)",WarningHeaderTooDeep:"Header level cannot exceed 6",WarningLinkHasNoText:"Link has no text",WarningLinkHasNoURL:"Link has no URL",WarningOrderedListItem:"Ordered list item within unordered list",WarningOrderedListShouldStartAt1:"The first item in an ordered list should have index 1",WarningUndefinedLinkId:"Undefined link ID: ${0}",WarningUnorderedListItem:"Unordered list item within ordered list",PageTitleFormat:"${0} - ${1}",KeyCTRL:"Ctrl",KeySHIFT:"Shift",KeyALT:"Alt",KeyBKSPC:"Backspace",KeyDEL:"Del",KeyEND:"End",KeyENTER:"Enter",KeyESCAPE:"Esc",KeyHOME:"Home",KeyINSERT:"Ins",KeyPAGEDOWN:"Page Down",KeyPAGEUP:"Page Up",KeySPACE:"Space",KeyTAB:"Tab","a year":"a year",years:"${0} years","a month":"a month",months:"${0} months","a day":"a day",days:"${0} days","an hour":"an hour",hours:"${0} hours","a minute":"a minute",minutes:"${0} minutes",timeAgo:"${0} ago",justNow:"just now",fixAll:"Fix all"}),t("plugins/languages/markdown/markdownPlugin",["orion/plugin","orion/i18nUtil","i18n!orion/nls/messages"],function(e,n,t){function i(){var n={name:"Orion Extended Markdown Language Tool Support",version:"1.0",description:"This plugin provides extended Markdown language tools support for Orion."},t=new e(n); - o(t),t.connect()}function o(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-markdown","extends":"text/plain",name:"Markdown",extension:["md"]}]}),e.registerServiceProvider("orion.edit.contentAssist",{computeProposals:function(e,i,o){var r=o.selection.start!==o.selection.end?e.substring(o.selection.start,o.selection.end):null,a=o.delimiter,s=r&&-1!==r.indexOf(a),l=/^[ ]{0,3}$/.test(o.line),c=[];if(c.push({description:t.emphasis,escapePosition:r?null:i+1,proposal:"*"+(r?r:"")+"*"}),c.push({description:t.strong,escapePosition:r?null:i+2,proposal:"**"+(r?r:"")+"**"}),!s){var d=l&&!r?t.text:"";c.push({description:n.formatMessage(t["header (${0})"],"atx"),positions:l?[{offset:i+1,length:d.length}]:null,proposal:(l?"":a)+"#"+d+(r?r:"")})}s||c.push({description:t["link (auto)"],escapePosition:r?null:i+1,proposal:"<"+(r?r:"")+">"});var u=r||t.text,p=t.url,m=t["title (optional)"];c.push({description:t["link (inline)"],positions:[{offset:i+1,length:u.length},{offset:i+3+u.length,length:p.length},{offset:i+5+u.length+p.length,length:m.length}],proposal:"["+u+"]("+p+' "'+m+'")'});var g=r||t["alt text"],h=t.url,b=t["title (optional)"];c.push({description:t["link (image)"],positions:[{offset:i+2,length:g.length},{offset:i+4+g.length,length:h.length},{offset:i+6+g.length+h.length,length:b.length}],proposal:"!["+g+"]("+h+' "'+b+'")'});var f=r||t.text,y=t["link label (optional)"];if(c.push({description:t["link (ref)"],positions:[{offset:i+1,length:f.length},{offset:i+3+f.length,length:y.length}],proposal:"["+f+"]["+y+"]"}),!s){var v=r||t.label,x=t.url,_=t["title (optional)"],w=l?"":a;c.push({description:t["link label"],positions:[{offset:i+w.length+1,length:v.length},{offset:i+w.length+4+v.length,length:x.length},{offset:i+w.length+5+v.length+x.length,length:_.length}],proposal:w+"["+v+"]: "+x+" "+_+a})}if(!s){var k=l&&!r?t.code:"",j=l?" ".substring(0,4-o.indentation.length):a+a+" ";c.push({description:t["code (block)"],positions:k?[{offset:i+j.length,length:k.length}]:null,proposal:j+k+(r?r:"")})}if(c.push({description:t["code (span)"],escapePosition:r?null:i+1,proposal:"`"+(r?r:"")+"`"}),c.push({description:t["horizontal rule"],proposal:(l?"":a)+"- - -"+a+(r?r:"")}),!s){var S=l&&!r?t.text:"";c.push({description:t.blockquote,positions:l?[{offset:i+2,length:S.length}]:null,proposal:(l?"":a)+"> "+S+(r?r:"")})}var T=l&&!r?t.text:"";c.push({description:t["list item (numbered)"],positions:l?[{offset:i+3,length:T.length}]:null,proposal:(l?"":a)+"1. "+T+(r?r:"")}),c.push({description:t["list item (bullet)"],positions:l?[{offset:i+2,length:T.length}]:null,proposal:(l?"":a)+"* "+T+(r?r:"")}),c.push({style:"hr"}),c.push({description:n.formatMessage(t["strikethrough (${0})"],"gfm"),escapePosition:r?null:i+2,proposal:"~~"+(r?r:"")+"~~"});var P=l?"":a;return c.push({description:n.formatMessage(t["table (${0})"],"gfm"),positions:[{offset:i+P.length,length:5},{offset:i+P.length+7,length:9},{offset:i+P.length+16+a.length,length:6},{offset:i+P.length+23+a.length,length:9},{offset:i+P.length+32+2*a.length,length:4},{offset:i+P.length+39+2*a.length,length:4}],proposal:P+"hLeft |hCentered"+a+":-----|:-------:"+a+"item |item "+a+(r?r:"")}),c.push({description:n.formatMessage(t["fenced code (${0})"],"gfm"),escapePosition:r?null:i+3,proposal:"```"+(r?r:"")+"```"}),c}},{name:"Markdown content assist",contentType:["text/x-markdown"]})}return{connect:i,registerServiceProviders:o}}),t("orion/editor/stylers/text_x-objective-c/syntax",["orion/editor/stylers/text_x-csrc/syntax"],function(e){var n=["atomic","BOOL","bycopy","byref","Class","id","IMP","inout","in","nil","nonatomic","NO","NULL","oneway","out","Protocol","retain","SEL","self","super","YES"],t=["@catch","@class","@dynamic","@end","@finally","@implementation","@interface","@private","@property","@protected","@protocol","@public","@selector","@synthesize","@throw","@try"],i=["import"],o=[];return o.push.apply(o,e.grammars),o.push({id:"orion.objectiveC",contentTypes:["text/x-objective-c"],patterns:[{include:"#objectiveCString"},{include:"orion.c"},{include:"#objectiveCDirective"},{include:"#objectiveCKeyword"}],repository:{objectiveCDirective:{match:"#\\s*(?:"+i.join("|")+")\\b[^$]*",name:"meta.preprocessor.objective-c"},objectiveCKeyword:{match:"(\\b(?:"+n.join("|")+")|(?:"+t.join("|")+"))\\b",name:"keyword.operator.objective-c"},objectiveCString:{match:'@"(?:\\\\.|[^"])*"?',name:"string.quoted.double.objective-c"}}}),{id:o[o.length-1].id,grammars:o,keywords:e.keywords.concat(n).concat(i).concat(t)}}),t("plugins/languages/objectiveC/objectiveCPlugin",["orion/plugin","orion/editor/stylers/text_x-objective-c/syntax"],function(e,n){function t(){var n={name:"Orion Objective-C Tool Support",version:"1.0",description:"This plugin provides Objective-C tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-objective-c","extends":"text/plain",name:"Objective-C",extension:["m","mm","h"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/editor/stylers/text_x-php/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["abstract","and","array","as","callable","class","clone","const","declare","echo","empty","eval","extends","final","function","global","implements","include","include_once","insteadof","interface","instanceof","isset","list","namespace","new","or","parent","print","private","protected","public","require","require_once","static","trait","unset","use","var","xor","__halt_compiler","__CLASS__","__DIR__","__FILE__","__FUNCTION__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__"],t=["break","case","catch","continue","default","die","do","else","elseif","enddeclare","endfor","endforeach","endif","endswitch","endwhile","exit","finally","for","foreach","goto","if","return","switch","throw","try","while","yield"],i=["false","FALSE","null","NULL","true","TRUE"],o=["self"],r=[];return r.push.apply(r,e.grammars),r.push({id:"orion.php-core",patterns:[{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"orion.lib#doc_block"},{include:"orion.c-like#comment_block"},{match:{match:"#.*",literal:"#"},name:"comment.line.number-sign.php",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},{begin:"<<<(\\w+)$",end:"^\\1;$",name:"string.unquoted.heredoc.php"},{begin:"<<<'(\\w+)'$",end:"^\\1;$",name:"string.unquoted.heredoc.nowdoc.php"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{match:"\\b0[bB][01]+\\b",name:"constant.numeric.binary.php"},{include:"orion.lib#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.php"},{match:"\\b(?:"+t.join("|")+")\\b",name:"keyword.control.php"},{match:"\\b(?:"+i.join("|")+")\\b",name:"constant.language.php"},{match:"\\b(?:"+o.join("|")+")\\b",name:"variable.language.php"}]}),r.push({id:"orion.php",contentTypes:["text/x-php"],patterns:[{begin:"(?i)<(\\?|%(?!php))(?:=|php)?(?:\\s|$)",end:"[\\1]>",captures:{0:{name:"entity.name.declaration.php"}},contentName:"source.php.embedded",patterns:[{include:"orion.php-core"}]},{include:"orion.html"}]}),{id:r[r.length-1].id,grammars:r,keywords:n.concat(t).concat(i).concat(o)}}),t("plugins/languages/php/phpPlugin",["orion/plugin","orion/editor/stylers/text_x-php/syntax"],function(e,n){function t(){var n={name:"Orion PHP Tool Support",version:"1.0",description:"This plugin provides PHP tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-php","extends":"text/plain",name:"PHP",extension:["php","php3","php4","php5","phpt","phtml","aw","ctp"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/editor/stylers/text_x-python/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["and","as","assert","break","class","continue","def","del","exec","elif","else","except","Ellipsis","False","finally","for","from","global","if","import","in","is","lambda","not","None","NotImplemented","or","pass","print","raise","return","try","True","while","with","yield"],t=[];return t.push.apply(t,e.grammars),t.push({id:"orion.python",contentTypes:["text/x-python"],patterns:[{begin:"(['\"])\\1\\1",end:"\\1\\1\\1",name:"string.quoted.triple.python"},{include:"orion.lib#string_doubleQuote"},{include:"orion.lib#string_singleQuote"},{begin:{match:"#",literal:"#"},end:{match:"$",literal:""},name:"comment.line.number-sign.python",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"#number_decimal"},{include:"orion.lib#number_hex"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.python"}],repository:{number_decimal:{match:"\\b-?(?:\\.\\d+|\\d+\\.?\\d*)[lL]?\\b",name:"constant.numeric.number.python"}}}),{id:t[t.length-1].id,grammars:t,keywords:n}}),t("plugins/languages/python/pythonPlugin",["orion/plugin","orion/editor/stylers/text_x-python/syntax"],function(e,n){function t(){var n={name:"Orion Python Tool Support",version:"1.0",description:"This plugin provides Python tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-python","extends":"text/plain",name:"Python",extension:["py","rpy","pyw","cpy","SConstruct","Sconstruct","sconstruct","SConscript","gyp","gypi"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("plugins/languages/ruby/rubyPlugin",["orion/plugin","orion/editor/stylers/text_x-ruby/syntax"],function(e,n){function t(){var n={name:"Orion Ruby Tool Support",version:"1.0",description:"This plugin provides Ruby tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-ruby","extends":"text/plain",name:"Ruby",extension:["rb","rbx","rjs","Rakefile","rake","cgi","fcgi","gemspec","irbrc","capfile","ru","prawn","Gemfile","Guardfile","Vagrantfile","Appraisals","Rantfile"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/editor/stylers/text_x-smarty/syntax",["orion/editor/stylers/lib/syntax","orion/editor/stylers/text_html/syntax","orion/editor/stylers/text_x-php/syntax"],function(e,n,t){var i=["false","no","off","on","true","yes"],o="{",r="}",a=[];return a.push.apply(a,e.grammars),a.push.apply(a,n.grammars),a.push.apply(a,t.grammars),a.push({id:"orion.smarty",contentTypes:["text/x-smarty"],patterns:[{include:"orion.html"},{include:"#smartyCommentBlock"},{include:"#literalBlock"},{include:"#phpBlock"},{include:"#smartyBlock"}],repository:{literalBlock:{begin:"({)literal(})",end:"({)/literal(})",captures:{1:"punctuation.brace.begin.smarty",2:"punctuation.brace.end.smarty"}},phpBlock:{begin:"({)php(})",end:"({)/php(})",captures:{1:"punctuation.brace.begin.smarty",2:"punctuation.brace.end.smarty"},contentName:"source.php.embedded.smarty",patterns:[{include:"orion.php-core"}]},smartyBlock:{begin:"("+o+")",end:"("+r+")",captures:{1:"punctuation.brace.begin.smarty",2:"punctuation.brace.end.smarty"},patterns:[{include:"orion.lib#string_singleQuote"},{include:"#smartyString_doubleQuote"},{include:"#smartyVariable"},{include:"#smartyConfigVariable"},{include:"#smartyConstant"},{include:"orion.lib#number_decimal"}]},smartyCommentBlock:{begin:{match:o+"\\*",literal:o+"*"},end:{match:"\\*"+r,literal:"*"+r},name:"comment.block.smarty"},smartyConfigVariable:{match:"#\\w+#",name:"variable.other.config.smarty"},smartyConstant:{match:"\\b(?:"+i.join("|")+")\\b",name:"constant.language.smarty"},smartyEscapedVariable:{match:"`\\$[^`]+`",name:"variable.other.escaped.smarty"},smartyString_doubleQuote:{begin:'"',end:'"',name:"string.quoted.double.smarty",patterns:[{include:"#smartyEscapedVariable"},{include:"#smartyVariable"},{include:"#smartyConfigVariable"}]},smartyVariable:{match:"\\$(?:smarty\\.(?:config|server)\\.)?\\w+",name:"variable.other.smarty"}}}),{id:a[a.length-1].id,grammars:a,keywords:[]}}),t("plugins/languages/smarty/smartyPlugin",["orion/plugin","orion/editor/stylers/text_x-smarty/syntax"],function(e,n){function t(){var n={name:"Orion Smarty Tool Support",version:"1.0",description:"This plugin provides Smarty tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-smarty","extends":"text/plain",name:"Smarty",extension:["tpl"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/editor/stylers/text_x-swift/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["associativity","as","class","convenience","deinit","didSet","dynamicType","dynamic","enum","extension","final","func","get","import","infix","init","inout","internal","in","is","lazy","left","let","mutating","none","nonmutating","operator","optional","override","postfix","precedence","prefix","private","protocol","Protocol","public","required","right","Self","set","static","struct","subscript","typealias","Type","unowned","var","weak","willSet","@objc"],t=["break","case","continue","default","do","else","fallthrough","for","if","return","switch","where","while"],i=["false","nil","true"],o=["self","super"],r=["__COLUMN__","__FILE__","__FUNCTION__","__LINE__"],a=[];return a.push.apply(a,e.grammars),a.push({id:"orion.swift",contentTypes:["text/x-swift"],patterns:[{include:"#string_doubleQuote"},{include:"orion.c-like#comment_singleLine"},{include:"#comment_block"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"#number_binary"},{include:"#number_hex"},{include:"#number_octal"},{include:"#number_decimal"},{include:"#keywords_operator"},{include:"#keywords_control"},{include:"#constants"},{include:"#languageVars1"},{include:"#languageVars2"}],repository:{comment_block:{begin:{match:"/\\*",literal:"/*"},end:{match:"\\*/",literal:"*/"},name:"comment.block.swift",patterns:[{include:"#comment_block"},{match:"(\\b)(TODO)(\\b)(((?!\\*/).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task.swift"},4:{name:"comment.block.swift"}}}]},constants:{match:"(^|[^\\w`])("+i.join("|")+")\\b",captures:{2:{name:"constant.language.swift"}}},keywords_operator:{match:"(^|[^\\w`])("+n.join("|")+")\\b",captures:{2:{name:"keyword.operator.swift"}}},keywords_control:{match:"(^|[^\\w`])("+t.join("|")+")\\b",captures:{2:{name:"keyword.control.swift"}}},languageVars1:{match:"(^|[^\\w`])("+o.join("|")+")\\b",captures:{2:{name:"variable.language.swift"}}},languageVars2:{match:"(^|[^\\w`])("+r.join("|")+")(?:$|[^\\w])",captures:{2:{name:"variable.language.swift"}}},number_binary:{match:"\\b0b[01]+\\b",name:"constant.numeric.binary.swift"},number_decimal:{match:"\\b-?(?:\\.\\d[\\d_]*|\\d[\\d_]*\\.?[\\d_]*)(?:[eE][+-]?\\d[\\d_]*)?\\b",name:"constant.numeric.decimal.swift"},number_hex:{match:"\\b0[xX](?:\\.[0-9A-Fa-f][0-9A-Fa-f_]*|[0-9A-Fa-f][0-9A-Fa-f_]*\\.?[0-9A-Fa-f_]*)(?:[pP][+-]?\\d[\\d_]*)?\\b",name:"constant.numeric.hex.swift"},number_octal:{match:"\\b0o[01234567][01234567_]*\\b",name:"constant.numeric.octal.swift"},segment:{begin:"\\(",end:"\\)",patterns:[{include:"#segment"},{include:"#comment_block"},{include:"#number_binary"},{include:"#number_hex"},{include:"#number_octal"},{include:"#number_decimal"},{include:"#keywords_operator"},{include:"#keywords_control"},{include:"#constants"},{include:"#languageVars1"},{include:"#languageVars2"}]},string_doubleQuote:{match:'"(?:\\\\.|[^"])*"?',name:"string.quoted.double.swift",patterns:[{begin:"\\\\\\(",end:"\\)",name:"string.interpolated.swift",patterns:[{include:"#segment"},{include:"#comment_block"},{include:"#number_binary"},{include:"#number_hex"},{include:"#number_octal"},{include:"#number_decimal"},{include:"#keywords_operator"},{include:"#keywords_control"},{include:"#constants"},{include:"#languageVars1"},{include:"#languageVars2"}]}]}}}),{id:a[a.length-1].id,grammars:a,keywords:n.concat(t).concat(i).concat(o).concat(r)}}),t("plugins/languages/swift/swiftPlugin",["orion/plugin","orion/editor/stylers/text_x-swift/syntax"],function(e,n){function t(){var n={name:"Orion Swift Tool Support",version:"1.0",description:"This plugin provides Swift tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-swift","extends":"text/plain",name:"Swift",extension:["swift"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/editor/stylers/text_x-vb/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["AddHandler","AddressOf","Aggregate","Alias","AndAlso","And","Ansi","Assembly","Async","As","Auto","Await","Binary","Boolean","ByRef","Byte","ByVal","Call","Case","Catch","CBool","CByte","CChar","CDate","CDbl","CDec","Char","CInt","Class","CLng","CObj","Compare","Const","CShort","CSng","CStr","CType","Custom","Date","Decimal","Declare","Default","Delegate","Dim","DirectCast","Distinct","Double","Do","Each","ElseIf","Else","EndIf","End","Enum","Equals","Erase","Error","Event","Exit","Explicit","False","Finally","For","Friend","From","Function","GetType","Get","GoSub","GoTo","Group By","Group Join","Handles","If","Implements","Imports","Inherits","Integer","Interface","Into","In","IsFalse","IsTrue","Is","Iterator","Join","Key","Let","Lib","Like","Long","Loop","Me","Mid","Module","Mod","MustInherit","MustOverride","MyBase","MyClass","Namespace","New","Next","Nothing","NotInheritable","NotOverridable","Not","Object","Off","On","Optional","Option","Order By","OrElse","Or","Overloads","Overridable","Overrides","ParamArray","Preserve","Private","Property","Protected","Public","RaiseEvent","ReadOnly","ReDim","REM","RemoveHandler","Resume","Return","Select","Set","Shadows","Shared","Short","Single","Skip While","Skip","Static","Step","Stop","Strict","String","Structure","Sub","SyncLock","Take While","Take","Text","Then","Throw","To","True","Try","TypeOf","Unicode","Until","Variant","Wend","When","Where","While","WithEvents","With","WriteOnly","Xor","Yield"],t=["Const","ElseIf","Else","End","ExternalSource","If","Region"],i=[];return i.push.apply(i,e.grammars),i.push({id:"orion.vb",contentTypes:["text/x-vb"],patterns:[{match:"^\\s*#(?:"+t.join("|")+")\\b[^$]*",name:"meta.preprocessor.vb"},{include:"orion.lib#string_doubleQuote"},{include:"#doc"},{include:"#comment"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{include:"orion.lib#operator"},{include:"orion.lib#number_decimal"},{include:"#number_hex"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.vb"}],repository:{comment:{begin:{match:"'",literal:"'"},end:{match:"$",literal:""},name:"comment.line.vb",patterns:[{include:"orion.lib#todo_comment_singleLine"}]},doc:{match:{match:"'''.*",literal:"'''"},name:"comment.line.documentation.vb",patterns:[{match:"<[^\\s>]*>",name:"meta.documentation.tag"},{include:"orion.lib#todo_comment_singleLine"}]},number_hex:{match:"&[hH][0-9A-Fa-f]+\\b",name:"constant.numeric.hex.vb"}}}),{id:i[i.length-1].id,grammars:i,keywords:n}}),t("orion/editor/stylers/text_x-vbhtml/syntax",["orion/editor/stylers/application_xml/syntax","orion/editor/stylers/text_html/syntax","orion/editor/stylers/text_x-vb/syntax"],function(e,n,t){var i=[];return i.push.apply(i,e.grammars),i.push.apply(i,n.grammars),i.push.apply(i,t.grammars),i.push({id:"orion.vbhtml",contentTypes:["text/x-vbhtml"],patterns:[{include:"#vbhtmlComment"},{include:"#codeBlock"},{include:"#expression"},{include:"#reference"},{include:"orion.html"}],repository:{vbhtmlComment:{begin:{match:"@\\*",literal:"@*"},end:{match:"\\*@",literal:"*@"},name:"comment.block.vbhtml"},codeBlock:{begin:"(?i)^\\s*@code",end:"(?i)end code",captures:{0:{name:"entity.name.declaration.vb"}},contentName:"source.vb.embedded.vbhtml",patterns:[{include:"orion.xml#tag"},{include:"#reference"},{include:"orion.vb"}]},expression:{match:"(?i)^\\s*@(?!code)[^$]*",name:"source.vb.embedded.vbhtml",patterns:[{include:"#reference"},{include:"orion.vb"}]},reference:{match:"@",name:"entity.name.declaration.vb"}}}),{id:i[i.length-1].id,grammars:i,keywords:[]}}),t("plugins/languages/vb/vbPlugin",["orion/plugin","orion/editor/stylers/text_x-vb/syntax","orion/editor/stylers/text_x-vbhtml/syntax"],function(e,n,t){function i(){var n={name:"Orion VB.NET Tool Support",version:"1.0",description:"This plugin provides VB.NET tools support for Orion."},t=new e(n);o(t),t.connect()}function o(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-vb","extends":"text/plain",name:"VB.NET",extension:["vb"]},{id:"text/x-vbhtml","extends":"text/plain",name:"vbhtml",extension:["vbhtml"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)}),t.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:i,registerServiceProviders:o}}),t("plugins/languages/xml/xmlPlugin",["orion/plugin","orion/editor/stylers/application_xml/syntax"],function(e,n){function t(){var n={name:"Orion XML Tool Support",version:"1.0",description:"This plugin provides XML tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"application/xml","extends":"text/plain",name:"XML",extension:["xml","xib"],imageClass:"file-sprite-xml"},{id:"application/xhtml+xml","extends":"text/plain",name:"XHTML",extension:["xhtml","xht"],imageClass:"file-sprite-xml"}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/editor/stylers/application_xquery/syntax",["orion/editor/stylers/lib/syntax"],function(e){var n=["zero-digit","xquery","window","where","when","version","variable","validate","unordered","union","typeswitch","type","tumbling","try","treat","to","then","text","switch","strip","strict","start","stable","some","sliding","self","schema-element","schema-attribute","schema","satisfies","return","processing-instruction","previous","preserve","preceding-sibling","preceding","percent","per-mille","pattern-separator","parent","ordering","order","or","option","only","of","node","no-preserve","no-inherit","next","ne","NaN","namespace-node","namespace","module","mod","minus-sign","lt","let","least","le","lax","item","is","intersect","instance","inherit","infinity","in","import","if","idiv","gt","grouping-separator","group","greatest","ge","function","for","following-sibling","following","external","except","every","eq","end","encoding","empty-sequence","empty","else","element","document-node","div","digit","descending","descendant-or-self","descendant","default","declare","decimal-separator","decimal-format","count","copy-namespaces","context","construction","comment","collation","child","catch","castable","cast","case","by","boundary-space","base-uri","attribute","at","ascending","as","and","ancestor-or-self","ancestor","allowing"],t=[];return t.push.apply(t,e.grammars),t.push({id:"orion.xquery",contentTypes:["application/xquery"],patterns:[{include:"#comment"},{include:"#variable"},{include:"#multiLineDoubleQuote"},{include:"#multiLineSingleQuote"},{include:"orion.xml#tag"},{include:"orion.lib#brace_open"},{include:"orion.lib#brace_close"},{include:"orion.lib#bracket_open"},{include:"orion.lib#bracket_close"},{include:"orion.lib#parenthesis_open"},{include:"orion.lib#parenthesis_close"},{match:"\\b(?:"+n.join("|")+")\\b",name:"keyword.operator.js"}],repository:{comment:{begin:{match:"\\(:",literal:"(:"},end:{match:":\\)",literal:":)"},name:"comment.block.xquery",patterns:[{match:"(\\b)(TODO)(\\b)(((?!:\\)).)*)",name:"meta.annotation.task.todo",captures:{2:{name:"keyword.other.documentation.task"},4:{name:"comment.block"}}}]},variable:{match:"\\$[a-zA-z0-9_]+",name:"variable.other.xquery"},multiLineDoubleQuote:{begin:'"',end:'"',name:"string.quoted.double"},multiLineSingleQuote:{begin:"'",end:"'",name:"string.quoted.single"}}}),{id:t[t.length-1].id,grammars:t,keywords:n}}),t("plugins/languages/xquery/xqueryPlugin",["orion/plugin","orion/editor/stylers/application_xquery/syntax"],function(e,n){function t(){var n={name:"Orion XQuery Tool Support",version:"1.0",description:"This plugin provides XQuery tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"application/xquery","extends":"text/plain",name:"XQuery",extension:["xq","xqy","xquery"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("orion/editor/stylers/text_x-yaml/syntax",[],function(){var e=["false","null","true"],n=["!!bool","!!float","!!int","!!map","!!null","!!omap","!!seq","!!str"],t="orion.yaml",i={id:t,contentTypes:["text/x-yaml"],patterns:[{include:"#numberSignComment"},{match:"^%(?:YAML|TAG)\\s.*",name:"meta.directive.yaml"},{begin:"^.*?:(?:[\\t ]|$)",end:"$",contentName:"string.unquoted.yaml",beginCaptures:{0:{name:"entity.name.key.yaml"}},patterns:[{include:"#numberSignComment"},{match:"^\\s*[&*]\\s*$",name:"entity.name.tag.yaml"},{match:"(?i)^\\s*(?:"+e.join("|")+")\\s*$",name:"keyword.operator.yaml"},{match:"(?i)^\\s*(?:"+n.join("|")+")\\b",name:"keyword.operator.yaml"},{match:"(?i)^\\s*(?:-?[0-9]*(?:\\.[0-9]+)?(?:e[-+][1-9][0-9]*)?)\\s*$",name:"constant.numeric.yaml"},{match:"(?i)^\\s*(?:-?[1-9][0-9]*|0|-?\\.inf|\\.nan)\\s*$",name:"constant.numeric.yaml"}]},{match:"---|\\.\\.\\.",name:"meta.separator.yaml"}],repository:{numberSignComment:{begin:{match:"(?:^|\\s)#",literal:"#"},end:{match:"$",literal:""},name:"comment.line.number-sign.yaml",patterns:[{include:"orion.lib#todo_comment_singleLine"}]}}};return{id:t,grammars:[i],keywords:n.concat(e)}}),t("plugins/languages/yaml/yamlPlugin",["orion/plugin","orion/editor/stylers/text_x-yaml/syntax"],function(e,n){function t(){var n={name:"Orion YAML Tool Support",version:"1.0",description:"This plugin provides YAML tools support for Orion."},t=new e(n);i(t),t.connect()}function i(e){e.registerServiceProvider("orion.core.contenttype",{},{contentTypes:[{id:"text/x-yaml","extends":"text/plain",name:"YAML",extension:["yaml","yml"]}]}),n.grammars.forEach(function(n){e.registerServiceProvider("orion.edit.highlighter",{},n)})}return{connect:t,registerServiceProviders:i}}),t("plugins/languageToolsPlugin",["orion/plugin","plugins/languages/arduino/arduinoPlugin","plugins/languages/c/cPlugin","plugins/languages/cpp/cppPlugin","plugins/languages/csharp/csharpPlugin","plugins/languages/docker/dockerPlugin","plugins/languages/erlang/erlangPlugin","plugins/languages/go/goPlugin","plugins/languages/git/gitFilePlugin","plugins/languages/haml/hamlPlugin","plugins/languages/jade/jadePlugin","plugins/languages/java/javaPlugin","plugins/languages/jsx/jsxPlugin","plugins/languages/launch/launchPlugin","plugins/languages/lua/luaPlugin","plugins/languages/markdown/markdownPlugin","plugins/languages/objectiveC/objectiveCPlugin","plugins/languages/php/phpPlugin","plugins/languages/python/pythonPlugin","plugins/languages/ruby/rubyPlugin","plugins/languages/smarty/smartyPlugin","plugins/languages/swift/swiftPlugin","plugins/languages/vb/vbPlugin","plugins/languages/xml/xmlPlugin","plugins/languages/xquery/xqueryPlugin","plugins/languages/yaml/yamlPlugin"],function(e){function n(){var n={name:"Orion Languages Tool Support",version:"1.0",description:"This plugin provides tooling for languages that are not included in other core Orion plugins."},i=new e(n);t(i),i.connect()}function t(e){i.forEach(function(n){n.registerServiceProviders(e)})}var i=Array.prototype.slice.call(arguments);return i.shift(),{connect:n,registerServiceProviders:t}}),t("plugins/webEditingPlugin",["orion/plugin","i18n!orion/nls/messages"],function(e,n){function t(){var n={name:"Orion Web Editing Plugin",version:"1.0",description:"This plugin provides editor link support for the navigator."},t=new e(n);i(t),t.connect()}function i(e){e.registerService("orion.core.contenttype",{},{contentTypes:[{id:"text/plain",name:"Text",extension:["txt"],imageClass:"file-sprite-text modelDecorationSprite"},{id:"application/xml","extends":"text/plain",name:"XML",extension:["xml"],imageClass:"file-sprite-xml modelDecorationSprite"},{id:"text/x-markdown","extends":"text/plain",name:"Markdown",extension:["md"]},{id:"text/conf","extends":"text/plain",name:"Conf",extension:["conf"]},{id:"text/sh","extends":"text/plain",name:"sh",extension:["sh"]},{id:"application/pdf","extends":"application/browser-renderable",name:"PDF",extension:["pdf"]},{id:"application/octet-stream",name:"octet-stream",extension:["exe","bin","doc","ppt"]},{id:"application/zip","extends":"application/octet-stream",name:"ZIP",extension:["war","jar","zip","rar"]},{id:"image/gif",name:"GIF",extension:["gif"],imageClass:"file-sprite-image modelDecorationSprite"},{id:"image/jpeg",name:"JPG",extension:["jpg","jpeg","jpe"],imageClass:"file-sprite-image modelDecorationSprite"},{id:"image/ico",name:"ICO",extension:["ico"],imageClass:"file-sprite-image modelDecorationSprite"},{id:"image/png",name:"PNG",extension:["png"],imageClass:"file-sprite-image modelDecorationSprite"},{id:"image/tiff",name:"TIFF",extension:["tif","tiff"],imageClass:"file-sprite-image modelDecorationSprite"},{id:"image/svg",name:"SVG",extension:["svg"],imageClass:"file-sprite-image modelDecorationSprite"}]}),e.registerService("orion.edit.editor",{},{id:"orion.editor","default":!0,name:n["Orion Editor"],nls:"orion/nls/messages",uriTemplate:"../edit/edit.html#{,Location,params*}",orionTemplate:"../edit/edit.html#{,Location,params*}",validationProperties:[{source:"!Projects"}]}),e.registerService("orion.navigate.openWith",{},{editor:"orion.editor",excludedContentTypes:["image/*","application/zip"]});var t="orion.viewer.markdown";e.registerService("orion.edit.editor",{},{id:t,name:n["Orion Markdown Viewer"],nls:"orion/nls/messages",uriTemplate:"../edit/edit.html#{,Location,params*},editor="+t}),e.registerService("orion.navigate.openWith",{},{editor:t,contentType:["text/x-markdown"]});var i="orion.editor.markdown";e.registerService("orion.edit.editor",{},{id:i,name:n["Orion Markdown Editor"],nls:"orion/nls/messages","default":!0,uriTemplate:"../edit/edit.html#{,Location,params*},editor="+i}),e.registerService("orion.navigate.openWith",{},{editor:i,contentType:["text/x-markdown"]}),e.registerService("orion.edit.editor",{},{id:"orion.viewer.raw",name:n.Browser,nls:"orion/nls/messages",uriTemplate:"{+Location}",validationProperties:[{source:"!Projects"}]})}return{connect:t,registerServiceProviders:i}}),t("plugins/embeddedToolingPlugin",["orion/plugin","plugins/languageToolsPlugin","plugins/webEditingPlugin"],function(e){function n(){var n={name:"Pluggable editor tooling support",version:"1.0",description:"This plugin provides the core language tooling support for the Orion pluggable editor."},i=new e; - i.updateHeaders(n),t(i),i.connect()}function t(e){i.forEach(function(n){n.registerServiceProviders(e)})}var i=Array.prototype.slice.call(arguments);return i.shift(),n(),{connect:n,registerServiceProviders:t}}),n("plugins/embeddedToolingPlugin")}); -\ No newline at end of file diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/fix_focus.diff b/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/fix_focus.diff deleted file mode 100644 index 2e1a72d10ba..00000000000 --- a/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/fix_focus.diff +++ /dev/null @@ -1,15 +0,0 @@ -This patch fixes bug related to setting active EditorView on switching between different tabs. -=================================================================== -diff --git a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_edit/built-codeEdit-amd.js b/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_edit/built-codeEdit-amd.js ---- a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_edit/built-codeEdit-amd.js -+++ b/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_edit/built-codeEdit-amd.js -@@ -42184,6 +42184,9 @@ - domNode.addEventListener("mousedown", function() { //$NON-NLS-0$ - this.setActiveEditorView(this.editorView); - }.bind(this), true); -+ domNode.addEventListener("focus", function() { //$NON-NLS-0$ -+ this.setActiveEditorView(this.editorView); -+ }.bind(this), true); - domNode.addEventListener("keyup", function() { //$NON-NLS-0$ - this.setActiveEditorView(this.editorView); - }.bind(this), true); diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/fix_goto_line.diff b/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/fix_goto_line.diff index ef634014092..ca97648b838 100644 --- a/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/fix_goto_line.diff +++ b/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/fix_goto_line.diff @@ -1,9 +1,9 @@ -This patch replaces using browser's prompt dialog by Che dialog. +This patch replaces using browser's native prompt dialog by Che's dialog. =================================================================== -diff --git a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_edit/built-codeEdit-amd.js b/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_edit/built-codeEdit-amd.js ---- a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_edit/built-codeEdit-amd.js -+++ b/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_edit/built-codeEdit-amd.js -@@ -12744,16 +12744,40 @@ +diff --git a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/code_edit/built-codeEdit-amd.js b/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/code_edit/built-codeEdit-amd.js +--- a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/code_edit/built-codeEdit-amd.js ++++ b/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/code_edit/built-codeEdit-amd.js +@@ -13126,16 +13126,40 @@ var model = editor.getModel(); if (data.parameters && data.parameters.valueFor('line')) { //$NON-NLS-0$ line = data.parameters.valueFor('line'); //$NON-NLS-0$ diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/built-codeEdit-amd.js.diff b/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/fix_linked_mode.diff similarity index 69% rename from plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/built-codeEdit-amd.js.diff rename to plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/fix_linked_mode.diff index 092b998dcbd..ccd36a4ecc6 100644 --- a/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/built-codeEdit-amd.js.diff +++ b/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/fix_linked_mode.diff @@ -1,42 +1,34 @@ -This patch fixes bug with linked mode and reduces amount of scrolling lines. +This patch fixes bug related to linked mode. =================================================================== -diff --git a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_edit/built-codeEdit-amd.js b/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_edit/built-codeEdit-amd.js ---- a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_edit/built-codeEdit-amd.js -+++ b/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_edit/built-codeEdit-amd.js -@@ -21325,6 +21325,7 @@ - }, - _handleMouseWheel: function (e) { - if (this._noScroll) return; -+ if(e.defaultPrevented) return; - var lineHeight = this._getLineHeight(); - var pixelX = 0, pixelY = 0; - // Note: On the Mac the correct behaviour is to scroll by pixel. -@@ -31473,8 +31474,9 @@ - 'orion/editor/keyModes', //$NON-NLS-0$ - 'orion/editor/annotations', //$NON-NLS-0$ - 'orion/objects', //$NON-NLS-0$ +diff --git a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/code_edit/built-codeEdit-amd.js b/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/code_edit/built-codeEdit-amd.js +--- a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/code_edit/built-codeEdit-amd.js ++++ b/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/code_edit/built-codeEdit-amd.js +@@ -32269,8 +32269,9 @@ + 'orion/editor/keyModes', + 'orion/editor/annotations', + 'orion/objects', + 'orion/editor/eventTarget', - 'orion/util' //$NON-NLS-0$ + 'orion/util' -], function(messages, mKeyBinding, mKeyModes, mAnnotations, objects) { +], function(messages, mKeyBinding, mKeyModes, mAnnotations, objects, mEventTarget) { - + var exports = {}; - -@@ -31543,11 +31545,11 @@ + +@@ -32354,11 +32355,11 @@ this.linkedModeModel = null; - + textView.setAction("linkedModeEnter", function() { //$NON-NLS-0$ - this.exitLinkedMode(true); + this.exitLinkedMode(true, true); return true; }.bind(this)); textView.setAction("linkedModeCancel", function() { //$NON-NLS-0$ -- this.exitLinkedMode(false); +- this.exitLinkedMode(true); + this.exitLinkedMode(false, false); return true; }.bind(this)); textView.setAction("linkedModeNextGroup", function() { //$NON-NLS-0$ -@@ -31585,7 +31587,7 @@ +@@ -32396,7 +32397,7 @@ changed = positionChanged.position; if (changed === undefined || changed.model !== model) { // The change has been done outside of the positions, exit the Linked Mode @@ -45,7 +37,7 @@ diff --git a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_ed model = this.linkedModeModel; } else { break; -@@ -31631,7 +31633,7 @@ +@@ -32441,7 +32442,7 @@ changed = positionChanged.position; if (changed === undefined || changed.model !== model) { // The change has been done outside of the positions, exit the Linked Mode @@ -54,8 +46,8 @@ diff --git a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_ed model = this.linkedModeModel; } else { break; -@@ -31758,10 +31760,11 @@ - * Exits Linked Mode. Optionally places the caret at linkedMode escapePosition. +@@ -32573,10 +32574,11 @@ + * Exits Linked Mode. Optionally places the caret at linkedMode escapePosition. * @param {Boolean} [escapePosition=false] if true, place the caret at the escape position. */ - exitLinkedMode: function(escapePosition) { @@ -67,11 +59,12 @@ diff --git a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_ed if (this._compoundChange) { this.endUndo(); this._compoundChange = null; -@@ -31950,6 +31953,7 @@ +@@ -32822,6 +32824,7 @@ annotationModel.replaceAnnotations(remove, add); } }); + mEventTarget.EventTarget.addMixin(LinkedMode.prototype); exports.LinkedMode = LinkedMode; - + return exports; +\ No newline at end of file diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/fix_scrolling.diff b/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/fix_scrolling.diff new file mode 100644 index 00000000000..a982e8259dc --- /dev/null +++ b/plugins/plugin-orion/che-plugin-orion-editor/src/main/patches/fix_scrolling.diff @@ -0,0 +1,13 @@ +This patch reduces amount of scrolling lines. +=================================================================== +diff --git a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/code_edit/built-codeEdit-amd.js b/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/code_edit/built-codeEdit-amd.js +--- a/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/code_edit/built-codeEdit-amd.js ++++ b/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/code_edit/built-codeEdit-amd.js +@@ -22588,6 +22588,7 @@ + }, + _handleMouseWheel: function (e) { + if (this._noScroll) return; ++ if(e.defaultPrevented) return; + var lineHeight = this._getLineHeight(); + var pixelX = 0, pixelY = 0; + // Note: On the Mac the correct behaviour is to scroll by pixel. diff --git a/plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_edit/built-codeEdit-amd.js b/plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/code_edit/built-codeEdit-amd.js similarity index 95% rename from plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_edit/built-codeEdit-amd.js rename to plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/code_edit/built-codeEdit-amd.js index 0fdd39dcd67..8a4f6eee8a5 100644 --- a/plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/built-codeEdit-11.0/code_edit/built-codeEdit-amd.js +++ b/plugins/plugin-orion/che-plugin-orion-editor/src/main/resources/org/eclipse/che/ide/editor/orion/public/built-codeEdit-12.0/code_edit/built-codeEdit-amd.js @@ -232,16 +232,16 @@ define('orion/nls/root/messages',{//Default message bundle "EditorRelatedLinkParent": "Show Enclosing Folder", "EditorLinkWorkspace": "Edit", "EditorRelatedLinkProj": "Show Project", - "navigationBar": "Navigation Bar", + "sidebar": "Sidebar", "Filter bindings": "Filter bindings", "BindingPrompt": "Enter the new binding", "NoBinding": "---", "orionClientLabel": "Orion client repository", - "Orion Editor": "Orion Editor", - "Orion Image Viewer": "Orion Image Viewer", - "Orion Markdown Editor": "Orion Markdown Editor", - "Orion Markdown Viewer": "Orion Markdown Viewer", - "Orion JSON Editor": "Orion JSON Editor", + "Orion Editor": "Text Editor", + "Orion Image Viewer": "Image Viewer", + "Orion Markdown Editor": "Markdown Editor", + "Orion Markdown Viewer": "Markdown Viewer", + "Orion JSON Editor": "JSON Editor", "View on Site": "View on Site", "View this file or folder on a web site hosted by Orion": "View this file or folder on a web site hosted by Orion.", "ShowAllKeyBindings": "Show a list of all the keybindings on this page", @@ -291,7 +291,7 @@ define('orion/nls/root/messages',{//Default message bundle "Regular expression" : "Regular expression", "Search options" : "Search options", "Global search" : "Global search", - "Orion Home" : "Orion Home", + "Orion Home" : "Home", "Close notification" : "Close notification", "OpPressSpaceMsg" : "Operations - Press spacebar to show current operations", "Toggle side panel" : "Toggle side panel", @@ -406,6 +406,7 @@ define('orion/util',[],function() { var isIPad = userAgent.indexOf("iPad") !== -1; //$NON-NLS-0$ var isIPhone = userAgent.indexOf("iPhone") !== -1; //$NON-NLS-0$ var isIOS = isIPad || isIPhone; + var isElectron = userAgent.indexOf("Electron") !== -1; //$NON-NLS-0$ var isMac = navigator.platform.indexOf("Mac") !== -1; //$NON-NLS-0$ var isWindows = navigator.platform.indexOf("Win") !== -1; //$NON-NLS-0$ var isLinux = navigator.platform.indexOf("Linux") !== -1; //$NON-NLS-0$ @@ -425,11 +426,26 @@ define('orion/util',[],function() { } return document.createElement(tagName); } + function confineDialogTab(firstElement, lastElement) { + lastElement.addEventListener("keydown", function(evt) { + if(evt.keyCode === 9 && !evt.shiftKey) { + evt.preventDefault(); + firstElement.focus(); + } + }); + firstElement.addEventListener("keydown", function(evt) { + if(evt.keyCode === 9 && evt.shiftKey) { + evt.preventDefault(); + lastElement.focus(); + } + }); + } return { formatMessage: formatMessage, createElement: createElement, + confineDialogTab: confineDialogTab, /** Browsers */ isIE: isIE, @@ -442,6 +458,7 @@ define('orion/util',[],function() { isIPad: isIPad, isIPhone: isIPhone, isIOS: isIOS, + isElectron: isElectron, /** OSs */ isMac: isMac, @@ -2228,10 +2245,13 @@ define('orion/webui/tooltip',['orion/webui/littlelib'], function(lib) { var self = this; lib.addAutoDismiss([this._tip, this._node], function() {self.hide();}); if (this._trigger === "mouseover") { //$NON-NLS-0$ - this._tipInner.setAttribute("role", "tooltip"); //$NON-NLS-2$ //$NON-NLS-1$ - this._tipInner.id = "tooltip" + new Date().getTime().toString(); //$NON-NLS-0$ - this._node.setAttribute("aria-describedby", this._tipInner.id); //$NON-NLS-0$ - + this._tipInner.setAttribute("role", "tooltip"); //$NON-NLS-2$ //$NON-NLS-1$ + this._tipInner.id = "tooltip" + new Date().getTime().toString(); //$NON-NLS-0$ + var label = this._node.getAttribute("aria-label"); + if (this._text !== label) { + this._node.setAttribute("aria-describedby", this._tipInner.id); //$NON-NLS-0$ + } + // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=398960 // mousing over the tip itself will cancel any pending timeout to close it, but then we must // also close it when we leave the tip. @@ -2449,7 +2469,7 @@ define('orion/webui/tooltip',['orion/webui/littlelib'], function(lib) { }); /******************************************************************************* * @license - * Copyright (c) 2014 IBM Corporation and others. + * Copyright (c) 2014, 2016 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 @@ -2457,13 +2477,27 @@ define('orion/webui/tooltip',['orion/webui/littlelib'], function(lib) { * * Contributors: IBM Corporation - initial API and implementation ******************************************************************************/ - /*eslint-env browser, amd*/ -define('orion/metrics',[], function() { +define('orion/metrics',[ +], function() { var _services = []; + var timingVars = Object.create(null); - function init(services, args) { + /** + * @name Metrics + * @description Creates a new instance of the metrics service + * @param {Object} serviceRegistry The backing service registry to register the new service with + * @param {Object} args An object of additional arguments + * @returns {Metrics} A new Metrics instance + * @since 12.0 + */ + function Metrics(serviceRegistry, args) { + var refs = serviceRegistry.getServiceReferences("orion.metrics"); //$NON-NLS-0$ + var services = []; + refs.forEach(function(current) { + services.push(serviceRegistry.getService(current)); + }); /* the following definitions are from https://developers.google.com/analytics/devguides/collection/analyticsjs/pages */ var href = window.location.protocol + '//' + window.location.hostname + window.location.pathname + window.location.search; //$NON-NLS-0$ var page = window.location.pathname + window.location.search; @@ -2473,25 +2507,23 @@ define('orion/metrics',[], function() { _services.forEach(function(current) { current.pageLoad(href, page, title, args); }); + serviceRegistry.registerService("orion.core.metrics.client", this); //$NON-NLS-1$ } - - function initFromRegistry(serviceRegistry, args) { - var refs = serviceRegistry.getServiceReferences("orion.metrics"); //$NON-NLS-0$ - var services = []; - refs.forEach(function(current) { - services.push(serviceRegistry.getService(current)); + + /** @callback */ + function _logTiming(timingCategory, timingVar, timingValue, timingLabel) { + _services.forEach(function(current) { + current.logTiming(timingCategory, timingVar, timingValue, timingLabel); }); - init(services, args); } - - function logEvent(category, action, label, value, details) { + /** @callback */ + function _logEvent(category, action, label, value, details) { _services.forEach(function(current) { current.logEvent(category, action, label || "", value, details); }); } - - var timingVars = {}; - function logPageLoadTiming(timingVar, timingLabel) { + /** @callback */ + function _logPageLoadTiming(timingVar, timingLabel) { /* * The level of window.performance implementation varies across the browsers, * so check for the existence of all utilized functions up-front. @@ -2507,24 +2539,52 @@ define('orion/metrics',[], function() { if (timingVars[timingVar]) { return; } - timingVars[timingVar] = new Date(); + timingVars[timingVar] = Date.now(); } - logTiming("page", timingVar, window.performance.now(), timingLabel); //$NON-NLS-0$ + _logTiming("page", timingVar, window.performance.now(), timingLabel); //$NON-NLS-0$ } } - - function logTiming(timingCategory, timingVar, timingValue, timingLabel) { - _services.forEach(function(current) { - current.logTiming(timingCategory, timingVar, timingValue, timingLabel); - }); - } - + + Metrics.prototype = { + /** + * @description Log a timing + * @function + * @param {String} timingCategory The name of the category to log to + * @param {String} timingVar The name of the variable to log to + * @param {Number} timingValue The timing to log + * @param {String} timingLabel A label for the new timing + */ + logTiming: function(timingCategory, timingVar, timingValue, timingLabel) { + _logTiming(timingCategory, timingVar, timingValue, timingLabel); + }, + /** + * @description Log an event + * @function + * @param {String} category The name of the category to log to + * @param {String} action The name of the action logged + * @param {String} label A label for the event + * @param {String} value The event value to log + * @param {String} details Additional details about the event being logged + */ + logEvent: function(category, action, label, value, details) { + _logEvent(category, action, label, value, details); + }, + /** + * @description Log how long it took to load a page + * @function + * @param {Number} timingVar The timing to log + * @param {String} timingLabel A label for the new timing + */ + logPageLoadTiming: function(timingVar, timingLabel) { + _logPageLoadTiming(timingVar, timingLabel); + } + }; + return { - init: init, - initFromRegistry: initFromRegistry, - logEvent: logEvent, - logPageLoadTiming: logPageLoadTiming, - logTiming: logTiming + Metrics: Metrics, + logTiming: _logTiming, + logEvent: _logEvent, + logPageLoadTiming: _logPageLoadTiming }; }); @@ -2756,16 +2816,18 @@ define('orion/commands',[ return checkbox; } - function createQuickfixItem(parent, command, commandInvocation, callback) { + function createQuickfixItem(parentElement, command, commandInvocation, callback, prefService) { var element; var button; var clickTarget; var fixAllCheckbox; var fixAllLabel; - element = document.createElement("div"); //$NON-NLS-1$ + var quickfixSettings = '/languageTools/quickfix'; //$NON-NLS-1$ - button = clickTarget = document.createElement("button"); //$NON-NLS-1$ + element = document.createElement("div"); + + button = clickTarget = document.createElement("button"); button.className = "orionButton"; //$NON-NLS-1$ if (command.extraClass) { button.classList.add(command.extraClass); @@ -2777,8 +2839,16 @@ define('orion/commands',[ var onClick = callback || command.callback; if (onClick) { var done = function() { - if (fixAllCheckbox && fixAllCheckbox.checked){ - commandInvocation.userData.doFixAll = true; + if (fixAllCheckbox){ + if (fixAllCheckbox.checked){ + commandInvocation.userData.doFixAll = true; + } + if (prefService){ + prefService.get(quickfixSettings).then(function(prefs) { + prefs[command.id] = fixAllCheckbox.checked; + prefService.put(quickfixSettings, prefs); + }); + } } onClick.call(commandInvocation.handler, commandInvocation); }; @@ -2799,33 +2869,42 @@ define('orion/commands',[ e.stopPropagation(); }, false); } - if (parent.nodeName.toLowerCase() === "ul") { - var li = document.createElement("li"); //$NON-NLS-0$ - parent.appendChild(li); - parent = li; + if (parentElement.nodeName.toLowerCase() === "ul") { + var li = document.createElement("li"); + parentElement.appendChild(li); + parentElement = li; } else { button.classList.add("commandMargins"); //$NON-NLS-0$ } element.appendChild(button); - // TODO We check that the internal access to annotation model exists so if it breaks we don't show the checkbox at all + // We check that the internal access to annotation model exists so if it breaks we don't show the checkbox at all rather than throw an error later if (command.fixAllEnabled && commandInvocation.userData._annotationModel){ - var id = command.name + 'fixAll'; //$NON-NLS-1$ - fixAllCheckbox = document.createElement('input'); //$NON-NLS-1$ + var id = command.id + 'fixAll'; //$NON-NLS-1$ + fixAllCheckbox = document.createElement('input'); fixAllCheckbox.type = 'checkbox'; //$NON-NLS-1$ fixAllCheckbox.className = "quickfixAllParameter"; //$NON-NLS-1$ + fixAllCheckbox.checked = true; fixAllCheckbox.id = id; - fixAllLabel = document.createElement('label'); //$NON-NLS-1$ + fixAllLabel = document.createElement('label'); fixAllLabel.htmlFor = id; fixAllLabel.className = "quickfixAllParameter"; //$NON-NLS-1$ fixAllLabel.appendChild(document.createTextNode(messages['fixAll'])); + if (prefService){ + prefService.get(quickfixSettings).then(function(prefs) { + if (typeof prefs[command.id] === 'boolean'){ + fixAllCheckbox.checked = prefs[command.id]; + } + + }); + } + element.appendChild(fixAllCheckbox); element.appendChild(fixAllLabel); } - - parent.appendChild(element); + parentElement.appendChild(element); return element; } @@ -2999,14 +3078,14 @@ define('orion/commands',[ var dropdown = parent.dropdown; if (typeof(command.hrefCallback) === 'function') { li = Dropdown.createMenuItem(command.name, "a"); //$NON-NLS-0$ - element = li.firstElementChild; + commandInvocation.domNode = element = li.firstElementChild; var href = command.hrefCallback.call(commandInvocation.handler, commandInvocation); if (href.then){ href.then(function(l){ element.href = l; }); } else if (href) { - element.href = href; + element.href = href; } else { // no href element.href = "#"; //$NON-NLS-0$ } @@ -4603,12 +4682,12 @@ define('orion/commandRegistry',[ /** * @name addEventListener * - * @description This is an override of the normal addEventListener to allow it to + * @description This is an override of the normal addEventListener to allow it to * keep listeners synch'd with the current binding overrides whether or not they get added before or * after the actual binding overrides have been retrieved from the preference store. * * Once the overrides preference is loaded any currently registered listeners are informed of the current - * binding overrides. Subsequent listeners are also imformed when they get added. + * binding overrides. Subsequent listeners are also informed when they get added. * @param eventType The type of event being listened on. * @param listener The listener to call when the event is dispatched. */ @@ -5051,7 +5130,7 @@ define('orion/commandRegistry',[ * @param id The id of the Command or Text Action being overridden * @param newBinding The new binding to use * @param prevBinding The binding (if any) being overridden. Note that this is needed to ensure that - * we override the correct Text Action (which can havemultiple bindings for the same id). + * we override the correct Text Action (which can have multiple bindings for the same id). */ createBindingOverride: function(id, newBinding, prevBinding) { if (!this._bindingOverrides) { @@ -5074,12 +5153,12 @@ define('orion/commandRegistry',[ /** * @name _registerRenderedCommand - * @description Keeps a record of the 'invocation' object for a renderred command. The invocation contains + * @description Keeps a record of the 'invocation' object for a rendered command. The invocation contains * a lot of information about the rendered item (including the DOM element created to show it). This is currently * used to update the menu item's key binding info if its binding changes. * * @param actionID The actionID of the menu item - * @param scopeID The scopeID of this particular invocation (two different menus can be created using teh same commands) + * @param scopeID The scopeID of this particular invocation (two different menus can be created using the same commands) * @param invocation The invocation record to store */ _registerRenderedCommand: function(actionID, scopeID, invocation) { @@ -5185,8 +5264,8 @@ define('orion/commandRegistry',[ * the title will be used as the tooltip. * @param {String} [selectionClass] CSS class to be appended when the command button is selected. Optional. * @param {String} or {boolean} [defaultActionId] Id of an action from this group that should be invoked when the group is selected. This will add an - * arrow to the grup that will open the dropdown. Optionally this can be set to true instead of adding a particular action. - * If set to true the group will be renderer as if there was a default action, but instead of invoking the default action it will + * arrow to the group that will open the dropdown. Optionally this can be set to true instead of adding a particular action. + * If set to true the group will be rendered as if there was a default action, but instead of invoking the default action it will * open the dropdown. Optional. * @param {String} [extraClasses] A string containing space separated css classes that will be applied to group button */ @@ -5292,7 +5371,7 @@ define('orion/commandRegistry',[ this._updateBindingOverrides(); }.bind(this)); - // listen for changes form other pages + // listen for changes from other pages this._prefService.addEventListener("changed", function (e) { if (e.namespace === "/KeyBindings") { //$NON-NLS-1$ // Refresh the binding overrides @@ -5772,7 +5851,8 @@ define('orion/commandRegistry',[ id = renderType + command.id + index; // using the index ensures unique ids within the DOM when a command repeats for each item var commandDiv = document.createElement("div"); //$NON-NLS-0$ parent.appendChild(commandDiv); - element = Commands.createQuickfixItem(commandDiv, command, invocation, onClick); + parent.classList.add('quickFixList'); + element = Commands.createQuickfixItem(commandDiv, command, invocation, onClick, self._prefService); } else { id = renderType + command.id + index; // // using the index ensures unique ids within the DOM when a command repeats for each item element = Commands.createCommandItem(parent, command, invocation, id, null, renderType === "tool", onClick); @@ -5941,7 +6021,7 @@ define('orion/commandRegistry',[ * @param {String} name the name of the event * @param {Function} handler the event handler function. The handler is provided two parameters on invocation, i. e. * the DOM event and the undergoing commandInvocation objects. - * @param {Boolean} [capture] the (optional) flag used to determine whether to caputre the event or not + * @param {Boolean} [capture] the (optional) flag used to determine whether to capture the event or not */ function CommandEventListener (event, handler, capture) { this.event = event; @@ -5992,7 +6072,7 @@ define('orion/commandRegistry',[ * A ParametersDescription defines the parameters required by a command, and whether there are additional * optional parameters that can be specified. The command registry will attempt to collect required parameters * before calling a command callback. The command is expected to provide UI for optional parameter, when the user has - * signalled a desire to provide optional information. + * signaled a desire to provide optional information. * * @param {orion.commands.CommandParameter[]} parameters an array of CommandParameters that are required * @param {Object} options The parameters description options object. @@ -6277,6 +6357,7 @@ define('orion/navigate/nls/root/messages',{//Default message bundle "File": "File", "Actions": "Actions", "Orion Content": "Orion Content", + "File System": "File System", "Create new content": "Create new content", "Import from HTTP...": "HTTP", "File URL:": "File URL:", @@ -6348,7 +6429,7 @@ define('orion/navigate/nls/root/messages',{//Default message bundle /******************************************************************************* * @license - * Copyright (c) 2010, 2012 IBM Corporation and others. + * Copyright (c) 2010, 2016 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 @@ -6359,8 +6440,12 @@ define('orion/navigate/nls/root/messages',{//Default message bundle /*eslint-env browser, amd*/ /** @namespace The global container for eclipse APIs. */ - -define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", "orion/i18nUtil"], function(messages, Deferred, i18nUtil){ +define('orion/fileClient',[ + 'i18n!orion/navigate/nls/messages', + "orion/Deferred", + "orion/i18nUtil", + 'orion/EventTarget' +], function(messages, Deferred, i18nUtil, EventTarget) { /** * This helper method implements invocation of the service call, * with retry on authentication error if needed. @@ -6374,6 +6459,15 @@ define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", return fileService[funcName].apply(fileService, funcArgs); } + /** + * @description Copy + * @private + * @param sourceService + * @param sourceLocation + * @param targetService + * @param targetLocation + * @returns returns + */ function _copy(sourceService, sourceLocation, targetService, targetLocation) { if (!sourceService.readBlob) { @@ -6384,22 +6478,22 @@ define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", throw new Error(messages["TargetNotSupportBinWrite"]); } - if (sourceLocation[sourceLocation.length -1] !== "/") { //$NON-NLS-0$ - return _doServiceCall(sourceService, "readBlob", [sourceLocation]).then(function(contents) { //$NON-NLS-0$ - return _doServiceCall(targetService, "writeBlob", [targetLocation, contents]); //$NON-NLS-0$ + if (sourceLocation[sourceLocation.length -1] !== "/") { + return _doServiceCall(sourceService, "readBlob", [sourceLocation]).then(function(contents) { //$NON-NLS-1$ + return _doServiceCall(targetService, "writeBlob", [targetLocation, contents]); //$NON-NLS-1$ }); } var temp = targetLocation.substring(0, targetLocation.length - 1); - var name = decodeURIComponent(temp.substring(temp.lastIndexOf("/")+1)); //$NON-NLS-0$ - var parentLocation = temp.substring(0, temp.lastIndexOf("/")+1); //$NON-NLS-0$ + var targetName = decodeURIComponent(temp.substring(temp.lastIndexOf("/")+1)); + var parentLocation = temp.substring(0, temp.lastIndexOf("/")+1); - return _doServiceCall(targetService, "createFolder", [parentLocation, name]).then(function() { //$NON-NLS-0$ + return _doServiceCall(targetService, "createFolder", [parentLocation, targetName]).then(function() { //$NON-NLS-1$ return; }, function() { return; }).then(function() { - return _doServiceCall(sourceService, "fetchChildren", [sourceLocation]).then(function(children) { //$NON-NLS-0$ + return _doServiceCall(sourceService, "fetchChildren", [sourceLocation]).then(function(children) { //$NON-NLS-1$ var results = []; for(var i = 0; i < children.length; ++i) { var childSourceLocation = children[i].Location; @@ -6407,11 +6501,11 @@ define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", if (children[i].Directory) { childTemp = childSourceLocation.substring(0, childSourceLocation.length - 1); } - var childName = decodeURIComponent(childTemp.substring(childTemp.lastIndexOf("/")+1)); //$NON-NLS-0$ + var childName = decodeURIComponent(childTemp.substring(childTemp.lastIndexOf("/")+1)); var childTargetLocation = targetLocation + encodeURIComponent(childName); if (children[i].Directory) { - childTargetLocation += "/"; //$NON-NLS-0$ + childTargetLocation += "/"; } results[i] = _copy(sourceService, childSourceLocation, targetService, childTargetLocation); } @@ -6433,6 +6527,8 @@ define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", var _services; var _names; + EventTarget.attach(this); + /* @callback */ function _noMatch(location) { var d = new Deferred(); d.reject(messages["No Matching FileService for location:"] + location); @@ -6441,21 +6537,25 @@ define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", var _fileSystemsRoots = []; var _allFileSystemsService = { + /* @callback */ fetchChildren: function() { var d = new Deferred(); d.resolve(_fileSystemsRoots); return d; }, + /* @callback */ createWorkspace: function() { var d = new Deferred(); d.reject(messages["no file service"]); return d; }, + /* @callback */ loadWorkspaces: function() { var d = new Deferred(); d.reject(messages['no file service']); return d; }, + /* @callback */ loadWorkspace: function(location) { var d = new Deferred(); window.setTimeout(function() { @@ -6464,9 +6564,9 @@ define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", Length: 0, LocalTimeStamp: 0, Name: messages["File Servers"], - Location: "/", //$NON-NLS-0$ + Location: "/", Children: _fileSystemsRoots, - ChildrenLocation: "/" //$NON-NLS-0$ + ChildrenLocation: "/" }); }, 100); return d; @@ -6482,13 +6582,17 @@ define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", write: _noMatch }; + /** + * @description Initialize the service + * @private + */ function init() { - if (_services) return; + if (_services) { return; } _patterns = []; _services = []; _names = []; - var allReferences = serviceRegistry.getServiceReferences("orion.core.file"); //$NON-NLS-0$ + var allReferences = serviceRegistry.getServiceReferences("orion.core.file"); //$NON-NLS-1$ var _references = allReferences; if (filter) { _references = []; @@ -6499,8 +6603,8 @@ define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", } } _references.sort(function (ref1, ref2) { - var ranking1 = ref1.getProperty("ranking") || 0; - var ranking2 = ref2.getProperty("ranking") || 0; + var ranking1 = ref1.getProperty("ranking") || 0; //$NON-NLS-1$ + var ranking2 = ref2.getProperty("ranking") || 0; //$NON-NLS-1$ return ranking1 - ranking2; }); for(var j = 0; j < _references.length; ++j) { @@ -6508,125 +6612,194 @@ define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", Directory: true, Length: 0, LocalTimeStamp: 0, - Location: _references[j].getProperty("top"), //$NON-NLS-0$ - ChildrenLocation: _references[j].getProperty("top"), //$NON-NLS-0$ - Name: _references[j].getProperty("Name") || _references[j].getProperty("NameKey") //$NON-NLS-0$ + Location: _references[j].getProperty("top"), //$NON-NLS-1$ + ChildrenLocation: _references[j].getProperty("top"), //$NON-NLS-1$ + Name: _references[j].getProperty("Name") || _references[j].getProperty("NameKey") //$NON-NLS-1$ //$NON-NLS-2$ }; - var filetop = _references[j].getProperty("top"); - var patternStringArray = _references[j].getProperty("pattern") || (filetop ? filetop.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1") : ""); //$NON-NLS-1$ //$NON-NLS-0$ + var filetop = _references[j].getProperty("top"); //$NON-NLS-1$ + var patternStringArray = _references[j].getProperty("pattern") || (filetop ? filetop.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1") : ""); //$NON-NLS-1$ //$NON-NLS-2$ if (!Array.isArray(patternStringArray)) { patternStringArray = [patternStringArray]; } var patterns = []; for (var k = 0; k < patternStringArray.length; k++) { var patternString = patternStringArray[k]; - if (patternString[0] !== "^") { //$NON-NLS-0$ - patternString = "^" + patternString; //$NON-NLS-0$ + if (patternString[0] !== "^") { + patternString = "^" + patternString; } patterns.push(new RegExp(patternString)); } _patterns[j] = patterns; _services[j] = serviceRegistry.getService(_references[j]); - _names[j] = _references[j].getProperty("Name") || _references[j].getProperty("NameKey"); //$NON-NLS-0$ + _names[j] = _references[j].getProperty("Name") || _references[j].getProperty("NameKey"); //$NON-NLS-1$ //$NON-NLS-2$ } } - this._getServiceIndex = function(location) { + /** + * @description Returns the index of the service for the given item location + * @function + * @private + * @param {String} itemLocation + * @returns returns + */ + this._getServiceIndex = function(itemLocation) { init(); // client must specify via "/" when a multi file service tree is truly wanted - if (location === "/") { //$NON-NLS-0$ + if (itemLocation === "/") { return -1; - } else if (!location || (location.length && location.length === 0)) { + } else if (!itemLocation || itemLocation.length && itemLocation.length === 0) { // TODO we could make the default file service a preference but for now we use the first one return _services[0] ? 0 : -1; } for(var i = 0; i < _patterns.length; ++i) { for (var j = 0; j < _patterns[i].length; j++) { - if (_patterns[i][j].test(location)) { + if (_patterns[i][j].test(itemLocation)) { return i; } } } - throw new Error(i18nUtil.formatMessage(messages['NoFileSrv'], location)); + throw new Error(i18nUtil.formatMessage(messages['NoFileSrv'], itemLocation)); }; - - this._getService = function(location) { - var i = this._getServiceIndex(location); + /** + * Returns the file service managing this location + * @param {String} itemLocation The location of the item + * @private + * @returns {FileClient} The service for the given item + */ + this._getService = function(itemLocation) { + var i = this._getServiceIndex(itemLocation); return i === -1 ? _allFileSystemsService : _services[i]; }; - - this._getServiceName = function(location) { - var i = this._getServiceIndex(location); + /** + * Returns the name of the file service managing this location + * @param {String} itemLocation The location of the item + * @private + * @return {String} The name of this file service + */ + this._getServiceName = function(itemLocation) { + var i = this._getServiceIndex(itemLocation); return i === -1 ? _allFileSystemsService.Name : _names[i]; }; - - this._getServiceRootURL = function(location) { - var i = this._getServiceIndex(location); + /** + * Returns the root url of the file service managing this location + * @param {String} itemLocation The location of the item + * @private + * @return {String} The root URL of the given item + */ + this._getServiceRootURL = function(itemLocation) { + var i = this._getServiceIndex(itemLocation); return i === -1 ? _allFileSystemsService.Location : _fileSystemsRoots[i].Location; }; + + this._frozenEvent = {type: "Changed"}; + this._eventFrozenMode = false; + serviceRegistry.registerService("orion.core.file.client", this); //$NON-NLS-1$ } FileClient.prototype = /**@lends orion.fileClient.FileClient.prototype */ { + freezeChangeEvents: function() { + this._frozenEvent = {type: "Changed"}; + this._eventFrozenMode = true; + }, + thawChangeEvents: function() { + this._eventFrozenMode = false; + this.dispatchEvent(this._frozenEvent); //$NON-NLS-0$ + }, + isEventFrozen: function() { + return this._eventFrozenMode; + }, + /** * Returns the file service managing this location - * @param location The location of the item + * @param {String} itemLocation The location of the item + * @public + * @returns {FileClient} The service for the given item */ - getService: function(location) { - return this._getService(location); + getService: function(itemLocation) { + return this._getService(itemLocation); }, /** * Returns the name of the file service managing this location - * @param location The location of the item + * @param {String} itemLocation The location of the item + * @public + * @return {String} The name of this file service */ - fileServiceName: function(location) { - return this._getServiceName(location); + fileServiceName: function(itemLocation) { + return this._getServiceName(itemLocation); }, /** * Returns the root url of the file service managing this location - * @param location The location of the item + * @param {String} itemLocation The location of the item + * @public + * @return {String} The root URL of the given item */ - fileServiceRootURL: function(location) { - return this._getServiceRootURL(location); + fileServiceRootURL: function(itemLocation) { + return this._getServiceRootURL(itemLocation); }, /** * Obtains the children of a remote resource - * @param location The location of the item to obtain children for - * @return A deferred that will provide the array of child objects when complete + * @param {string} parentLocation The location of the item to obtain children for + * @public + * @return {Deferred} A deferred that will provide the array of child objects when complete */ - fetchChildren: function(location) { - return _doServiceCall(this._getService(location), "fetchChildren", arguments); //$NON-NLS-0$ + fetchChildren: function(parentLocation) { + return _doServiceCall(this._getService(parentLocation), "fetchChildren", arguments); //$NON-NLS-1$ }, /** * Creates a new workspace with the given name. The resulting workspace is * passed as a parameter to the provided onCreate function. - * @param {String} name The name of the new workspace + * @param {String} workspaceName The name of the new workspace + * @public + * @return {Deferred} A deferred that will create a workspace with the given name */ - createWorkspace: function(name) { - return _doServiceCall(this._getService(), "createWorkspace", arguments); //$NON-NLS-0$ + createWorkspace: function(workspaceName) { + return _doServiceCall(this._getService(), "createWorkspace", arguments); //$NON-NLS-1$ }, /** * Loads all the user's workspaces. Returns a deferred that will provide the loaded * workspaces when ready. + * @public + * @return {Deferred} A deferred that will load all workspaces */ loadWorkspaces: function() { - return _doServiceCall(this._getService(), "loadWorkspaces", arguments); //$NON-NLS-0$ + return _doServiceCall(this._getService(), "loadWorkspaces", arguments); //$NON-NLS-1$ }, /** * Loads the workspace with the given id and sets it to be the current * workspace for the IDE. The workspace is created if none already exists. - * @param {String} location the location of the workspace to load + * @param {String} workspaceLocation the location of the workspace to load * @param {Function} onLoad the function to invoke when the workspace is loaded + * @public + * @return {Deferred} A deferred that will load the specified workspace */ - loadWorkspace: function(location) { - return _doServiceCall(this._getService(location), "loadWorkspace", arguments); //$NON-NLS-0$ + loadWorkspace: function(workspaceLocation) { + return _doServiceCall(this._getService(workspaceLocation), "loadWorkspace", arguments); //$NON-NLS-1$ + }, + + changeWorkspace: function(workspaceLocation) { + return _doServiceCall(this._getService(), "changeWorkspace", arguments); //$NON-NLS-1$ + }, + + _createArtifact: function(parentLocation, funcName, eventData, funcArgs) { + return _doServiceCall(this._getService(parentLocation), funcName, funcArgs).then(function(result){ //$NON-NLS-0$ + if(this.isEventFrozen()) { + if(!this._frozenEvent.created) { + this._frozenEvent.created = []; + } + this._frozenEvent.created.push({parent: parentLocation, result: result, eventData: eventData}); + } else { + this.dispatchEvent({ type: "Changed", created: [{parent: parentLocation, result: result, eventData: eventData}]}); //$NON-NLS-0$ + } + return result; + }.bind(this)); }, /** @@ -6635,74 +6808,111 @@ define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", * @param {String} projectName the human-readable name of the project * @param {String} serverPath The optional path of the project on the server. * @param {Boolean} create If true, the project is created on the server file system if it doesn't already exist + * @public + * @return {Deferred} A deferred that will create a new project in the workspace */ createProject: function(url, projectName, serverPath, create) { - return _doServiceCall(this._getService(url), "createProject", arguments); //$NON-NLS-0$ + return _doServiceCall(this._getService(url), "createProject", arguments); //$NON-NLS-1$ + //return this._createArtifact(url, "createProject", arguments); }, /** * Creates a folder. * @param {String} parentLocation The location of the parent folder * @param {String} folderName The name of the folder to create + * @param {Object} eventData The event data that will be sent back. * @return {Object} JSON representation of the created folder + * @public + * @return {Deferred} A deferred that will create a new folder in the workspace */ - createFolder: function(parentLocation, folderName) { - return _doServiceCall(this._getService(parentLocation), "createFolder", arguments); //$NON-NLS-0$ + createFolder: function(parentLocation, folderName, eventData) { + //return _doServiceCall(this._getService(parentLocation), "createFolder", arguments); //$NON-NLS-1$ + return this._createArtifact(parentLocation, "createFolder", eventData, arguments); }, /** * Create a new file in a specified location. Returns a deferred that will provide * The new file object when ready. * @param {String} parentLocation The location of the parent folder * @param {String} fileName The name of the file to create - * @return {Object} A deferred that will provide the new file object + * @param {Object} eventData The event data that will be sent back. + * @public + * @return {Deferred} A deferred that will provide the new file object */ - createFile: function(parentLocation, fileName) { - return _doServiceCall(this._getService(parentLocation), "createFile", arguments); //$NON-NLS-0$ + createFile: function(parentLocation, fileName, eventData) { + //return _doServiceCall(this._getService(parentLocation), "createFile", arguments); //$NON-NLS-1$ + return this._createArtifact(parentLocation, "createFile", eventData, arguments); }, /** * Deletes a file, directory, or project. - * @param {String} location The location of the file or directory to delete. + * @param {String} deleteLocation The location of the file or directory to delete. + * @param {Object} eventData The event data that will be sent back. + * @public + * @returns {Deferred} A deferred that will delete the given file */ - deleteFile: function(location) { - return _doServiceCall(this._getService(location), "deleteFile", arguments); //$NON-NLS-0$ + deleteFile: function(deleteLocation, eventData) { + //return _doServiceCall(this._getService(deleteLocation), "deleteFile", arguments); //$NON-NLS-1$ + return _doServiceCall(this._getService(deleteLocation), "deleteFile", arguments).then(function(result){ //$NON-NLS-0$ + if(this.isEventFrozen()) { + if(!this._frozenEvent.deleted) { + this._frozenEvent.deleted = []; + } + this._frozenEvent.deleted.push({deleteLocation: deleteLocation, eventData: eventData}); + } else { + this.dispatchEvent({ type: "Changed", deleted: [{deleteLocation: deleteLocation, eventData: eventData}]}); //$NON-NLS-0$ + } + return result; + }.bind(this)); }, /** * Moves a file or directory. * @param {String} sourceLocation The location of the file or directory to move. * @param {String} targetLocation The location of the target folder. - * @param {String} [name] The name of the destination file or directory in the case of a rename + * @param {String} targetName The name of the destination file or directory in the case of a rename + * @public + * @returns {Deferred} A deferred that will move the given file to its new location */ - moveFile: function(sourceLocation, targetLocation, name) { + moveFile: function(sourceLocation, targetLocation, targetName) { var sourceService = this._getService(sourceLocation); var targetService = this._getService(targetLocation); if (sourceService === targetService) { - return _doServiceCall(sourceService, "moveFile", arguments); //$NON-NLS-0$ + //return _doServiceCall(sourceService, "moveFile", arguments); + return _doServiceCall(sourceService, "moveFile", arguments).then(function(result){ //$NON-NLS-0$ + if(this.isEventFrozen()) { + if(!this._frozenEvent.moved) { + this._frozenEvent.moved = []; + } + this._frozenEvent.moved.push({source: sourceLocation, target: targetLocation, result: result}); + } else { + this.dispatchEvent({ type: "Changed", moved: [{source: sourceLocation, target: targetLocation, result: result}]}); //$NON-NLS-0$ + } + return result; + }.bind(this)); } - var isDirectory = sourceLocation[sourceLocation.length -1] === "/"; //$NON-NLS-0$ + var isDirectory = sourceLocation[sourceLocation.length -1] === "/"; var target = targetLocation; - if (target[target.length -1] !== "/") { //$NON-NLS-0$ - target += "/"; //$NON-NLS-0$ + if (target[target.length -1] !== "/") { + target += "/"; } - if (name) { - target += encodeURIComponent(name); + if (targetName) { + target += encodeURIComponent(targetName); } else { var temp = sourceLocation; if (isDirectory) { temp = temp.substring(0, temp.length - 1); } - target += temp.substring(temp.lastIndexOf("/")+1); //$NON-NLS-0$ + target += temp.substring(temp.lastIndexOf("/")+1); } - if (isDirectory && target[target.length -1] !== "/") { //$NON-NLS-0$ - target += "/"; //$NON-NLS-0$ + if (isDirectory && target[target.length -1] !== "/") { + target += "/"; } return _copy(sourceService, sourceLocation, targetService, target).then(function() { - return _doServiceCall(sourceService, "deleteFile", [sourceLocation]); //$NON-NLS-0$ + return _doServiceCall(sourceService, "deleteFile", [sourceLocation]); //$NON-NLS-1$ }); }, @@ -6711,35 +6921,48 @@ define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", * Copies a file or directory. * @param {String} sourceLocation The location of the file or directory to copy. * @param {String} targetLocation The location of the target folder. - * @param {String} [name] The name of the destination file or directory in the case of a rename + * @param {String} targetName The name of the destination file or directory in the case of a rename + * @public + * @returns {Deferred} A deferred that will copy the given file to its new location */ - copyFile: function(sourceLocation, targetLocation, name) { + copyFile: function(sourceLocation, targetLocation, targetName) { var sourceService = this._getService(sourceLocation); var targetService = this._getService(targetLocation); if (sourceService === targetService) { - return _doServiceCall(sourceService, "copyFile", arguments); //$NON-NLS-0$ + //return _doServiceCall(sourceService, "copyFile", arguments); //$NON-NLS-1$ + return _doServiceCall(sourceService, "copyFile", arguments).then(function(result){ //$NON-NLS-0$ + if(this.isEventFrozen()) { + if(!this._frozenEvent.copied) { + this._frozenEvent.copied = []; + } + this._frozenEvent.copied.push({source: sourceLocation, target: targetLocation, result: result}); + } else { + this.dispatchEvent({ type: "Changed", copied: [{source: sourceLocation, target: targetLocation, result: result}]}); //$NON-NLS-0$ + } + return result; + }.bind(this)); } - var isDirectory = sourceLocation[sourceLocation.length -1] === "/"; //$NON-NLS-0$ + var isDirectory = sourceLocation[sourceLocation.length -1] === "/"; var target = targetLocation; - if (target[target.length -1] !== "/") { //$NON-NLS-0$ - target += "/"; //$NON-NLS-0$ + if (target[target.length -1] !== "/") { + target += "/"; } - if (name) { - target += encodeURIComponent(name); + if (targetName) { + target += encodeURIComponent(targetName); } else { var temp = sourceLocation; if (isDirectory) { temp = temp.substring(0, temp.length - 1); } - target += temp.substring(temp.lastIndexOf("/")+1); //$NON-NLS-0$ + target += temp.substring(temp.lastIndexOf("/")+1); } - if (isDirectory && target[target.length -1] !== "/") { //$NON-NLS-0$ - target += "/"; //$NON-NLS-0$ + if (isDirectory && target[target.length -1] !== "/") { + target += "/"; } return _copy(sourceService, sourceLocation, targetService, target); @@ -6748,35 +6971,49 @@ define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", /** * Returns the contents or metadata of the file at the given location. * - * @param {String} location The location of the file to get contents for + * @param {String} readLocation The location of the file to get contents for * @param {Boolean} [isMetadata] If defined and true, returns the file metadata, * otherwise file contents are returned - * @return A deferred that will be provided with the contents or metadata when available + * @public + * @return {Deferred} A deferred that will be provided with the contents or metadata when available */ - read: function(location, isMetadata) { - return _doServiceCall(this._getService(location), "read", arguments); //$NON-NLS-0$ + read: function(readLocation, isMetadata) { + return _doServiceCall(this._getService(readLocation), "read", arguments); //$NON-NLS-1$ }, /** * Returns the blob contents of the file at the given location. * - * @param {String} location The location of the file to get contents for - * @return A deferred that will be provided with the blob contents when available + * @param {String} readLocation The location of the file to get contents for + * @public + * @return {Deferred} A deferred that will be provided with the blob contents when available */ - readBlob: function(location) { - return _doServiceCall(this._getService(location), "readBlob", arguments); //$NON-NLS-0$ + readBlob: function(readLocation) { + return _doServiceCall(this._getService(readLocation), "readBlob", arguments); //$NON-NLS-1$ }, /** * Writes the contents or metadata of the file at the given location. * - * @param {String} location The location of the file to set contents for + * @param {String} writeLocation The location of the file to set contents for * @param {String|Object} contents The content string, or metadata object to write * @param {String|Object} args Additional arguments used during write operation (i.e. ETag) - * @return A deferred for chaining events after the write completes with new metadata object + * @public + * @return {Deferred} A deferred for chaining events after the write completes with new metadata object */ - write: function(location, contents, args) { - return _doServiceCall(this._getService(location), "write", arguments); //$NON-NLS-0$ + write: function(writeLocation, contents, args) { + //return _doServiceCall(this._getService(writeLocation), "write", arguments); //$NON-NLS-1$ + return _doServiceCall(this._getService(writeLocation), "write", arguments).then(function(result){ //$NON-NLS-0$ + if(this.isEventFrozen()) { + if(!this._frozenEvent.modified) { + this._frozenEvent.modified = []; + } + this._frozenEvent.modified.push(writeLocation); + } else { + this.dispatchEvent({ type: "Changed", modified: [writeLocation]}); //$NON-NLS-0$ + } + return result; + }.bind(this)); }, /** @@ -6784,10 +7021,22 @@ define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", * * @param {String} targetLocation The location of the folder to import into * @param {Object} options An object specifying the import parameters - * @return A deferred for chaining events after the import completes + * @public + * @return {Deferred} A deferred for chaining events after the import completes */ - remoteImport: function(targetLocation, options) { - return _doServiceCall(this._getService(targetLocation), "remoteImport", arguments); //$NON-NLS-0$ + remoteImport: function(targetLocation, options, parentLocation) { + //return _doServiceCall(this._getService(targetLocation), "remoteImport", arguments); //$NON-NLS-1$ + return _doServiceCall(this._getService(targetLocation), "remoteImport", arguments).then(function(result){ //$NON-NLS-0$ + if(this.isEventFrozen()) { + if(!this._frozenEvent.copied) { + this._frozenEvent.copied = []; + } + this._frozenEvent.copied.push({target: parentLocation}); + } else { + this.dispatchEvent({ type: "Changed", copied: [{target: parentLocation}]}); //$NON-NLS-0$ + } + return result; + }.bind(this)); }, /** @@ -6795,10 +7044,23 @@ define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", * * @param {String} sourceLocation The location of the folder to export from * @param {Object} options An object specifying the export parameters - * @return A deferred for chaining events after the export completes + * @public + * @return {Deferred} A deferred for chaining events after the export completes */ remoteExport: function(sourceLocation, options) { - return _doServiceCall(this._getService(sourceLocation), "remoteExport", arguments); //$NON-NLS-0$ + return _doServiceCall(this._getService(sourceLocation), "remoteExport", arguments); //$NON-NLS-1$ + }, + + /** + * Find a string inside a file + * + * @param {String} sourceLocation The location of the folder to export from + * @param {String} findStr The string to search + * @public + * @return {Deferred} A deferred for chaining events after the export completes + */ + find: function(sourceLocation, findStr, option) { + return _doServiceCall(this._getService(location), "find", arguments); //$NON-NLS-0$ }, /** @@ -6812,15 +7074,17 @@ define('orion/fileClient',['i18n!orion/navigate/nls/messages', "orion/Deferred", * @param {Boolean} searchParams.regEx Optional. The option of regular expression search. * @param {integer} searchParams.start Optional. The zero based start number for the range of the returned hits. E.g if there are 1000 hits in total, then 5 means the 6th hit. * @param {integer} searchParams.rows Optional. The number of hits of the range. E.g if there are 1000 hits in total and start=5 and rows=40, then the return range is 6th-45th. + * @public */ search: function(searchParams) { - return _doServiceCall(this._getService(searchParams.resource), "search", arguments); //$NON-NLS-0$ + return _doServiceCall(this._getService(searchParams.resource), "search", arguments); //$NON-NLS-1$ } - };//end FileClient prototype + }; FileClient.prototype.constructor = FileClient; - //return the module exports - return {FileClient: FileClient}; + return { + FileClient: FileClient + }; }); /******************************************************************************* @@ -7405,6 +7669,9 @@ define('orion/edit/nls/root/messages',{ "Export": "Export", "OpenWith": "Open With", "OpenRelated": "Open Related", + "OpenFolder": "Open Folder", + "OpenRecent": "Open Recent", + "OpenFolderTip": "Change the root folder", "Dependency": "Dependency", "UnnamedCommand": "Unnamed", "searchInFolder": "Folder Search...", @@ -8741,8 +9008,8 @@ define('orion/PageLinks',[ * IBM Corporation - initial API and implementation *******************************************************************************/ /*eslint-env browser, amd*/ -define('orion/extensionCommands',["orion/Deferred", "orion/commands", "orion/contentTypes", "orion/URITemplate", "orion/i18nUtil", "orion/PageLinks", "i18n!orion/edit/nls/messages", "orion/URL-shim"], - function(Deferred, mCommands, mContentTypes, URITemplate, i18nUtil, PageLinks, messages){ +define('orion/extensionCommands',["orion/Deferred", "orion/commands", 'orion/PageUtil', "orion/contentTypes", "orion/URITemplate", "orion/i18nUtil", "orion/PageLinks", "i18n!orion/edit/nls/messages", "orion/URL-shim"], + function(Deferred, mCommands, PageUtil, mContentTypes, URITemplate, i18nUtil, PageLinks, messages){ /** * Utility methods @@ -9167,7 +9434,25 @@ define('orion/extensionCommands',["orion/Deferred", "orion/commands", "orion/con if (validator.generatesURI.bind(validator)()) { commandOptions.hrefCallback = function(data){ var item = Array.isArray(data.items) ? data.items[0] : data.items; - return validator.getURI.bind(validator)(item); + var href = validator.getURI.bind(validator)(item); + if (data.command && data.command.isEditor) { + data.domNode.addEventListener("click", function(evt) { + if(item.Location) { + var resourceParam = PageUtil.matchResourceParameters(); + if(resourceParam.resource !== item.Location) { + data.domNode.target = "_blank"; + return; + } + var cmdHrefParam = PageUtil.matchResourceParameters(href); + if(cmdHrefParam && cmdHrefParam.editor === resourceParam.editor) { + data.domNode.target = "_blank"; + return; + } + } + data.domNode.target = ""; + }); + } + return href; }; } else { var inf = info; @@ -9531,7 +9816,7 @@ define("orion/regex", [], function() { //$NON-NLS-0$ }); /******************************************************************************* - * Copyright (c) 2010, 2012 IBM Corporation and others. + * Copyright (c) 2010, 2016 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 @@ -9543,7 +9828,7 @@ define("orion/regex", [], function() { //$NON-NLS-0$ ******************************************************************************/ /*eslint-env browser, amd*/ -define("orion/editor/eventTarget", [], function() { //$NON-NLS-0$ +define("orion/editor/eventTarget", [], function() { /** * Constructs a new EventTarget object. * @@ -9594,6 +9879,12 @@ define("orion/editor/eventTarget", [], function() { //$NON-NLS-0$ this._dispatchEvent(type, evt); this._dispatchEvent("post" + type, evt); //$NON-NLS-0$ }, + /** + * Dispatches the given event to the listeners added to this event target. + * @private + * @param {String} type The name of the event type to send + * @param {Event} evt The event to dispatch. + */ _dispatchEvent: function(type, evt) { var state = this._eventTypes ? this._eventTypes[type] : null; if (state) { @@ -9604,9 +9895,9 @@ define("orion/editor/eventTarget", [], function() { //$NON-NLS-0$ for (var i=0, len=listeners.length; i < len; i++) { if (listeners[i]) { var l = listeners[i].listener; - if (typeof l === "function") { //$NON-NLS-0$ + if (typeof l === "function") { l.call(this, evt); - } else if (l.handleEvent && typeof l.handleEvent === "function") { //$NON-NLS-0$ + } else if (l.handleEvent && typeof l.handleEvent === "function") { l.handleEvent(evt); } } @@ -9680,7 +9971,7 @@ define("orion/editor/eventTarget", [], function() { //$NON-NLS-0$ /******************************************************************************* * @license - * Copyright (c) 2010, 2012 IBM Corporation and others. + * Copyright (c) 2010, 2016 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 @@ -9692,7 +9983,7 @@ define("orion/editor/eventTarget", [], function() { //$NON-NLS-0$ ******************************************************************************/ /*eslint-env browser, amd*/ -define("orion/editor/textModel", ['orion/editor/eventTarget', 'orion/regex', 'orion/util'], function(mEventTarget, mRegex, util) { //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ +define("orion/editor/textModel", ['orion/editor/eventTarget', 'orion/regex', 'orion/util'], function(mEventTarget, mRegex, util) { /** * Constructs a new TextModel with the given text and default line delimiter. @@ -9782,7 +10073,7 @@ define("orion/editor/textModel", ['orion/editor/eventTarget', 'orion/regex', 'or * insensitive mode. The fix is to detect the presence of Turkish i's in the search pattern and * to modify the pattern to search for both upper and lower case. */ - if (caseInsensitive) { //$NON-NLS-1$ //$NON-NLS-0$ + if (caseInsensitive) { pattern = pattern.replace(/[iI\u0130\u0131]/g, "[Ii\u0130\u0131]"); //$NON-NLS-0$ } } @@ -9794,14 +10085,14 @@ define("orion/editor/textModel", ['orion/editor/eventTarget', 'orion/regex', 'or var wholeWord = options.wholeWord; var start = options.start || 0; var end = options.end; - var isRange = (end !== null && end !== undefined); - if (flags.indexOf("g") === -1) { flags += "g"; } //$NON-NLS-1$ //$NON-NLS-0$ - if (flags.indexOf("m") === -1) { flags += "m"; } //$NON-NLS-1$ //$NON-NLS-0$ + var isRange = end !== null && end !== undefined; + if (flags.indexOf("g") === -1) { flags += "g"; } //$NON-NLS-1$ //$NON-NLS-2$ + if (flags.indexOf("m") === -1) { flags += "m"; } //$NON-NLS-1$ //$NON-NLS-2$ if (caseInsensitive) { - if (flags.indexOf("i") === -1) { flags += "i"; } //$NON-NLS-1$ //$NON-NLS-0$ + if (flags.indexOf("i") === -1) { flags += "i"; } //$NON-NLS-1$ //$NON-NLS-2$ } if (wholeWord) { - pattern = "\\b" + pattern + "\\b"; //$NON-NLS-1$ //$NON-NLS-0$ + pattern = "\\b" + pattern + "\\b"; //$NON-NLS-1$ //$NON-NLS-2$ } var text = this._text[0], result, lastIndex, offset = 0; if (isRange) { @@ -9865,11 +10156,17 @@ define("orion/editor/textModel", ['orion/editor/eventTarget', 'orion/regex', 'or current = skip(); } return { + /** + * @callback + */ next: function() { var result = current; if (result) { current = skip(); } return result; }, + /** + * @callback + */ hasNext: function() { return current !== null; } @@ -10141,7 +10438,7 @@ define("orion/editor/textModel", ['orion/editor/eventTarget', 'orion/regex', 'or * @param {Boolean} [all=false] whether or not the delimiter of existing lines are changed. */ setLineDelimiter: function(lineDelimiter, all) { - if (lineDelimiter === "auto") { //$NON-NLS-0$ + if (lineDelimiter === "auto") { lineDelimiter = undefined; if (this.getLineCount() > 1) { lineDelimiter = this.getText(this.getLineEnd(0), this.getLineEnd(0, true)); @@ -10961,6 +11258,7 @@ define('orion/editor/nls/root/messages',{//Default message bundle "incrementalFindStrNotFound": "Incremental find: ${0} (not found)", //$NON-NLS-1$ //$NON-NLS-0$ "incrementalFindReverseStr": "Reverse Incremental find: ${0}", //$NON-NLS-1$ //$NON-NLS-0$ "incrementalFindReverseStrNotFound": "Reverse Incremental find: ${0} (not found)", //$NON-NLS-1$ //$NON-NLS-0$ + "findReplace": "Find/Replace", //$NON-NLS-1$ //$NON-NLS-0$ "find": "Find...", //$NON-NLS-1$ //$NON-NLS-0$ "undo": "Undo", //$NON-NLS-1$ //$NON-NLS-0$ "redo": "Redo", //$NON-NLS-1$ //$NON-NLS-0$ @@ -11059,7 +11357,7 @@ define('orion/editor/nls/root/messages',{//Default message bundle "regex": "/.*/", //$NON-NLS-1$ //$NON-NLS-0$ "wholeWord": "\\b", //$NON-NLS-1$ //$NON-NLS-0$ "caseInsensitiveTooltip": "Toggle Case Insensitive", //$NON-NLS-1$ //$NON-NLS-0$ - "regexTooltip": "Toggle Regex", //$NON-NLS-1$ //$NON-NLS-0$ + "regexTooltip": "Toggle Regular Expression", //$NON-NLS-1$ //$NON-NLS-0$ "wholeWordTooltip": "Toggle Whole Word", //$NON-NLS-1$ //$NON-NLS-0$ "closeTooltip": "Close", //$NON-NLS-1$ //$NON-NLS-0$ @@ -12185,6 +12483,7 @@ define('orion/editorCommands',[ this.serviceRegistry = options.serviceRegistry; this.commandService = options.commandRegistry; this.fileClient = options.fileClient; + this.preferences = options.preferences; this.inputManager = options.inputManager; this.renderToolbars = options.renderToolbars; this.toolbarId = options.toolbarId; @@ -12228,8 +12527,29 @@ define('orion/editorCommands',[ this._createDelimiterCommands(); this._createEncodingCommand(); this._createSaveCommand(); + this._createOpenFolderCommand(); + this._createOpenRecentCommand(); return this._createEditCommands(); }, + updateWorkspacePrefs:function(workspaceAddress){ + var that = this; + return this.preferences.get("/workspace").then(function(prefs) { + return prefs.recentWorkspaces ? prefs.recentWorkspaces : []; + }).then(function(recentworkspaces){ + var RECENT_ARRAY_LENGTH = 10; + var oldIndex = recentworkspaces.indexOf(workspaceAddress); + if(oldIndex !== -1){ + recentworkspaces.splice(oldIndex,1); + } + if(recentworkspaces.length < RECENT_ARRAY_LENGTH){ + recentworkspaces.unshift(workspaceAddress); + }else if(recentworkspaces.length === RECENT_ARRAY_LENGTH){ + recentworkspaces.pop(); + recentworkspaces.unshift(workspaceAddress); + } + return that.preferences.put("/workspace",{recentWorkspaces: recentworkspaces, currentWorkspace: workspaceAddress}); + }) + }, //TODO: We need a better way invoke side bar action setSideBar: function(sideBar) { this.sideBar = sideBar; @@ -12287,6 +12607,8 @@ define('orion/editorCommands',[ commandRegistry.registerCommandContribution("settingsActions", "orion.edit.settings", 1, null, false, new mKeyBinding.KeyBinding("s", true, true), null, this); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ commandRegistry.registerCommandContribution(this.editToolbarId || this.toolbarId, "orion.edit.undo", 400, this.editToolbarId ? "orion.menuBarEditGroup/orion.edit.undoGroup" : null, !this.editToolbarId, new mKeyBinding.KeyBinding('z', true), null, this); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$ commandRegistry.registerCommandContribution(this.editToolbarId || this.toolbarId, "orion.edit.redo", 401, this.editToolbarId ? "orion.menuBarEditGroup/orion.edit.undoGroup" : null, !this.editToolbarId, util.isMac ? new mKeyBinding.KeyBinding('z', true, true) : new mKeyBinding.KeyBinding('y', true), null, this); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-4$ + commandRegistry.registerCommandContribution(this.saveToolbarId || this.toolbarId, "orion.edit.openFolder", 1, this.saveToolbarId ? "orion.menuBarFileGroup/orion.edit.saveGroup" : null, false, new mKeyBinding.KeyBinding('o', true)); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ + commandRegistry.registerCommandContribution(this.saveToolbarId || this.toolbarId, "orion.edit.openRecent", 3, this.saveToolbarId ? "orion.menuBarFileGroup/orion.edit.saveGroup" : null, false, new mKeyBinding.KeyBinding('r', true)); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ commandRegistry.registerCommandContribution(this.saveToolbarId || this.toolbarId, "orion.openResource", 1, this.saveToolbarId ? "orion.menuBarFileGroup/orion.edit.saveGroup" : null, false, new mKeyBinding.KeyBinding('f', true, true)); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ commandRegistry.registerCommandContribution(this.saveToolbarId || this.toolbarId, "orion.edit.save", 2, this.saveToolbarId ? "orion.menuBarFileGroup/orion.edit.saveGroup" : null, false, new mKeyBinding.KeyBinding('s', true), null, this); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-3$ commandRegistry.registerCommandContribution(this.editToolbarId || this.pageNavId, "orion.edit.gotoLine", 3, this.editToolbarId ? "orion.menuBarEditGroup/orion.findGroup" : null, !this.editToolbarId, new mKeyBinding.KeyBinding('l', !util.isMac, false, false, util.isMac), new mCommandRegistry.URLBinding("gotoLine", "line"), this); //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-5$ @@ -12377,11 +12699,13 @@ define('orion/editorCommands',[ var textView = editor.getTextView(); textView.setKeyBinding(new mKeyBinding.KeyBinding('s', true), "save"); //$NON-NLS-1$ //$NON-NLS-2$ var saveCommand = that.commandService.findCommand("orion.edit.save"); //$NON-NLS-0$ - textView.setAction("save", function() { //$NON-NLS-0$ - saveCommand.callback.call({inputManager: that.inputManager}); - return true; - }, saveCommand); //$NON-NLS-0$ - + if (saveCommand) { + textView.setAction("save", function() { //$NON-NLS-0$ + saveCommand.callback.call({inputManager: that.inputManager}); + return true; + }, saveCommand); //$NON-NLS-0$ + } + textView.setAction("gotoLine", function (data) { //$NON-NLS-0$ if (data) { editor.onGotoLine(data.line - 1, 0, undefined, data.callback); @@ -12558,7 +12882,7 @@ define('orion/editorCommands',[ _createClipboardCommands: function() { //TODO - test to see whether copy/cut/paste is supported instead of IE - if (util.isIE) { + if (util.isIE || util.isElectron) { var that = this; var copyCommand = new mCommands.Command({ @@ -12668,6 +12992,64 @@ define('orion/editorCommands',[ }); this.commandService.addCommand(saveCommand); }, + _createOpenFolderCommand: function() { + var that = this; + var openFolderCommand = new mCommands.Command({ + name: messages.OpenFolder, + tooltip: messages.OpenFolderTip, + id: "orion.edit.openFolder", //$NON-NLS-0$ + visibleWhen: /** @callback */ function(items, data) { + return !!window.__dialogModule; + }, + callback: function() { + window.__dialogModule.showOpenDialog({properties: ['openDirectory']}, function(result) { + if (!result) return; + that.fileClient.changeWorkspace(result[0]).then(function() { + return that.updateWorkspacePrefs(result[0]); + }).then(function(){ + delete sessionStorage.lastFile; + window.location.hash = ""; + window.location.reload(); + }) + }); + } + }); + this.commandService.addCommand(openFolderCommand); + }, + _createOpenRecentCommand: function() { + var that = this; + if(this.preferences){ + this.preferences.get("/workspace").then(function(prefs) { + return prefs.recentWorkspaces; + }).then(function(recentworkspaces){ + var openRecentCommand = new mCommands.Command({ + name: messages.OpenRecent, + selectionClass: "dropdownSelection", //$NON-NLS-0$ + id: "orion.edit.openRecent", //$NON-NLS-0$ + visibleWhen: /** @callback */ function(items, data) { + return !!window.__dialogModule && !!recentworkspaces; + }, + choiceCallback: function() { + return recentworkspaces.map(function(folderLocation) { + return { + name: folderLocation, + callback: function() { + that.fileClient.changeWorkspace(folderLocation).then(function() { + return that.updateWorkspacePrefs(folderLocation); + }).then(function(){ + delete sessionStorage.lastFile; + window.location.hash = ""; + window.location.reload(); + }) + } + }; + }); + } + }); + that.commandService.addCommand(openRecentCommand); + }); + } + }, _createEncodingCommand: function() { var that = this; var ENCODING_LIST = [ @@ -12816,6 +13198,12 @@ define('orion/editorCommands',[ } } if(parsedParam){ + //If the incoming resource does not match the current inputManager's, we should ignore it. + //This could happen when clicking on a file and then clicking on another in the global search result page. + var fileMetadata = (this.inputManager || that.inputManager).getFileMetadata(); + if(!fileMetadata || parsedParam.resource !== fileMetadata.Location) { + return; + } textSearcher.setOptions({regex: parsedParam.regEx, caseInsensitive: !parsedParam.caseSensitive, wholeWord: parsedParam.wholeWord}); var tempOptions = {}; if(parsedParam.atLine){ @@ -13085,9 +13473,9 @@ define('orion/editorCommands',[ options1.done = processEditorResult; options1.status = handleStatus; createDelegatedUI(options1); - } else if (result && result.searchParams && result.refResult) { + } else if (result && result.searchParams) { if(that.sideBar) { - that.sideBar.fillSearchPane(result.searchParams.keyword, {Location: result.searchParams.resource}, result); + that.sideBar.fillSearchPane(result.searchParams, result.refResult ? result : null); } } else if (result && (result.Status || result.status)) { handleStatus(result.Status || result.status); @@ -13137,6 +13525,28 @@ define('orion/editorCommands',[ return exports; }); +/******************************************************************************* + * @license + * 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 + *******************************************************************************/ +/*eslint-env browser, amd*/ +define('embeddedEditor/helper/memoryFileSysConst',[ +], function() { + var inMemoryFilePattern = "/in_memory_fs/"; + var project = "/in_memory_fs/project/"; + //return module exports + return { + MEMORY_FILE_PATTERN: inMemoryFilePattern, + MEMORY_FILE_PROJECT_PATTERN: project + }; +}); + /******************************************************************************* * @license * Copyright (c) 2013 IBM Corporation and others. @@ -13374,11 +13784,11 @@ define("orion/encoding-shim", function(){}); /*eslint-env browser, amd*/ /*global URL*/ -define('embeddedEditor/helper/embeddedFileImpl',["orion/Deferred", "orion/encoding-shim", "orion/URL-shim"], function(Deferred) { - +define('embeddedEditor/helper/embeddedFileImpl',["orion/Deferred", 'embeddedEditor/helper/memoryFileSysConst', "orion/encoding-shim", "orion/URL-shim"], function(Deferred, memoryFileSysConst) { function EmbeddedFileImpl(fileBase) { this.fileBase = fileBase; this.fileRoot = {}; + this.fileRoot[memoryFileSysConst.MEMORY_FILE_PROJECT_PATTERN] = {Location: memoryFileSysConst.MEMORY_FILE_PROJECT_PATTERN, Directory: true}; } EmbeddedFileImpl.prototype = { @@ -13397,8 +13807,10 @@ define('embeddedEditor/helper/embeddedFileImpl',["orion/Deferred", "orion/encodi createFolder: function(/*parentLocation, folderName*/) { throw new Error("Not supported"); //$NON-NLS-0$ }, - createFile: function(/*parentLocation, fileName*/) { - throw new Error("Not supported"); //$NON-NLS-0$ + createFile: function(parentLocation, fileName) { + var fileLocation = parentLocation + fileName; + this._getFile(fileLocation, true); + return this.read(fileLocation, true); }, moveFile: function(/*sourceLocation, targetLocation, name*/) { throw new Error("Not supported"); //$NON-NLS-0$ @@ -13421,7 +13833,7 @@ define('embeddedEditor/helper/embeddedFileImpl',["orion/Deferred", "orion/encodi _getFile: function(fLocation, create) { var locationURL = new URL(fLocation); var filePath = locationURL.pathname; - if (!this.fileRoot[filePath] && create) { + if (this.fileRoot[filePath] === undefined && create) { this.fileRoot[filePath] = { Name: locationURL.pathname.split("/").pop(), Location: filePath, @@ -13441,8 +13853,11 @@ define('embeddedEditor/helper/embeddedFileImpl',["orion/Deferred", "orion/encodi */ read: function(fLocation, isMetadata) { var file = this._getFile(fLocation); - if (!file) return new Deferred().reject(); + if (file === undefined) { + return new Deferred().resolve(isMetadata ? {} : ""); + } if(isMetadata){ + var parents = fLocation === memoryFileSysConst.MEMORY_FILE_PROJECT_PATTERN ? [] : [this.fileRoot[memoryFileSysConst.MEMORY_FILE_PROJECT_PATTERN]]; var meta = { Length: file.length, Directory: !!file.Directory, @@ -13450,7 +13865,7 @@ define('embeddedEditor/helper/embeddedFileImpl',["orion/Deferred", "orion/encodi ETag: file.ETag, Location: file.Location, Name: file.Name, - Parents: [] + Parents: parents }; return new Deferred().resolve(meta); } @@ -13471,7 +13886,7 @@ define('embeddedEditor/helper/embeddedFileImpl',["orion/Deferred", "orion/encodi file.LocalTimeStamp = Date.now(); file.contents = contents; } - return new Deferred().resolve(contents); + return this.read(fLocation, true); }, /** * Deletes a file, directory, or project. @@ -14838,24 +15253,24 @@ define('orion/pluginregistry',["orion/Deferred", "orion/EventTarget", "orion/URL if (configuration.plugins) { Object.keys(configuration.plugins).forEach(function(url) { - url = _normalizeURL(url); - // if (!httpOrHttps.test(url)) { - // console.log("Illegal Plugin URL: " + url); - // return; - // } - var plugin = this.getPlugin(url); - if (!plugin) { - var manifest = configuration.plugins[url]; - if (typeof manifest !== "object") { - manifest = internalRegistry.getPersisted(url) || {}; - } - manifest.autostart = manifest.autostart || configuration.defaultAutostart || "lazy"; - plugin = new Plugin(url, manifest, internalRegistry); - plugin._default = true; - _plugins.push(plugin); - } else { - plugin._default = true; - } + url = _normalizeURL(url); + // if (!httpOrHttps.test(url)) { + // console.log("Illegal Plugin URL: " + url); + // return; + // } + var plugin = this.getPlugin(url); + if (!plugin) { + var manifest = configuration.plugins[url]; + if (typeof manifest !== "object") { + manifest = internalRegistry.getPersisted(url) || {}; + } + manifest.autostart = manifest.autostart || configuration.defaultAutostart || "lazy"; + plugin = new Plugin(url, manifest, internalRegistry); + plugin._default = true; + _plugins.push(plugin); + } else { + plugin._default = true; + } }.bind(this)); } _plugins.sort(function(a, b) { @@ -15077,17 +15492,19 @@ if (_all_script && _all_script.length && _all_script.length > 0) { } define('embeddedEditor/helper/bootstrap',[ 'embeddedEditor/helper/embeddedFileImpl', + 'embeddedEditor/helper/memoryFileSysConst', 'orion/pluginregistry', 'orion/Deferred', 'orion/URL-shim' ], function( EmbeddedFileImpl, + memoryFileSysConst, mPluginRegistry, Deferred ) { var once; // Deferred - var fPattern = "/__embed/"; + var inMemoryFilePattern = memoryFileSysConst.MEMORY_FILE_PATTERN; var defaultPluginURLs = [ "../javascript/plugins/javascriptPlugin.html", "../webtools/plugins/webToolsPlugin.html", @@ -15122,11 +15539,11 @@ define('embeddedEditor/helper/bootstrap',[ } once = new Deferred(); - var fService = new EmbeddedFileImpl(fPattern); + var fService = new EmbeddedFileImpl(inMemoryFilePattern); serviceRegistry.registerService("orion.core.file", fService, { Name: 'Embedded File System', - top: fPattern, - pattern: fPattern + top: inMemoryFilePattern, + pattern: inMemoryFilePattern }); var plugins = {}; pluginsToLoad.forEach(function(pluginURLString){ @@ -15710,8168 +16127,8278 @@ define('orion/explorers/navigatorRenderer',[], function() { }); /******************************************************************************* * @license - * 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: - * 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 + ******************************************************************************/ /*eslint-env browser, amd*/ -define('orion/inputManager',[ - 'i18n!orion/edit/nls/messages', - 'orion/explorers/navigatorRenderer', - 'orion/i18nUtil', - 'orion/Deferred', - 'orion/EventTarget', - 'orion/objects', - 'orion/PageUtil', - 'orion/metrics' -], function(messages, mNavigatorRenderer, i18nUtil, Deferred, EventTarget, objects, PageUtil, mMetrics) { - - function Idle(options){ - this._document = options.document || document; - this._timeout = options.timeout; - //TODO: remove listeners if there are no clients - //TODO: add support for multiple clients with different timeouts - var events = ["mousedown", "keypress","keydown","keyup"]; //$NON-NLS-0$ //$NON-NLS-1$ //$NON-NLS-2$ - var reset = function () { this._resetTimer(); }.bind(this); - for (var i = 0; i < events.length; i++) { - var evt = events[i]; - this._document.addEventListener(evt, reset, true); - } - EventTarget.attach(this); - } +define("orion/editor/projectionTextModel", ['orion/editor/textModel', 'orion/editor/eventTarget'], function(mTextModel, mEventTarget) { //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ - Idle.prototype = { - _resetTimer: function() { - var win = this._document.defaultView || this._document.parentWindow; - if (this._timer) { - win.clearTimeout(this._timer); - this._timer = null; - } - if (this._timeout !== -1) { - this._timer = win.setTimeout(function() { - this.onIdle({type:"Idle"}); //$NON-NLS-0$ - this._timer = null; - this._resetTimer(); - }.bind(this), this._timeout); + /** + * @class This object represents a projection range. A projection specifies a + * range of text and the replacement text. The range of text is relative to the + * base text model associated to a projection model. + *

    + * See:
    + * {@link orion.editor.ProjectionTextModel}
    + * {@link orion.editor.ProjectionTextModel#addProjection}
    + *

    + * @name orion.editor.Projection + * + * @property {Number} start The start offset of the projection range. + * @property {Number} end The end offset of the projection range. This offset is exclusive. + * @property {String|orion.editor.TextModel} [text=""] The projection text to be inserted + */ + /** + * Constructs a new ProjectionTextModel based on the specified TextModel. + * + * @param {orion.editor.TextModel} baseModel The base text model. + * + * @name orion.editor.ProjectionTextModel + * @class The ProjectionTextModel represents a projection of its base text + * model. Projection ranges can be added to the projection text model to hide and/or insert + * ranges to the base text model. + *

    + * The contents of the projection text model is modified when changes occur in the base model, + * projection model or by calls to {@link #addProjection} and {@link #removeProjection}. + *

    + *

    + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextModel} + * {@link orion.editor.TextView#setModel} + *

    + * @borrows orion.editor.EventTarget#addEventListener as #addEventListener + * @borrows orion.editor.EventTarget#removeEventListener as #removeEventListener + * @borrows orion.editor.EventTarget#dispatchEvent as #dispatchEvent + */ + function ProjectionTextModel(baseModel) { + this._model = baseModel; + this._projections = []; + var self = this; + this._listener = { + onChanged: function(e) { + self._onChanged(e); + }, + onChanging: function(e) { + self._onChanging(e); } - }, - onIdle: function (idleEvent) { - return this.dispatchEvent(idleEvent); - }, - setTimeout: function(timeout) { - this._timeout = timeout; - this._resetTimer(); - } - }; - - function _makeError(error) { - var newError = { - Severity: "Error", //$NON-NLS-0$ - Message: messages.noResponse }; - if(error.name === "Cancel") { - return {Severity: "Warning", Message: error.name, Cancel: true}; - } else if (error.status === 0) { - newError.Cancel = true; - return newError; // might do better here - } else if (error.responseText) { - var responseText = error.responseText; - try { - var parsedError = JSON.parse(responseText); - newError.Severity = parsedError.Severity || newError.Severity; - newError.Message = parsedError.Message || newError.Message; - } catch (e) { - newError.Message = responseText; - } - } else { - try { - newError.Message = JSON.stringify(error); - } catch (e) { - // best effort - fallthrough - } - } - return newError; - } - - function handleError(statusService, error) { - if (!statusService) { - window.console.log(error); - return; - } - if (!error.Severity) { - error = _makeError(error); - } - statusService.setProgressResult(error); - return error; - } - - function decode(contents, charset, done, errorHandler) { - if (window.TextDecoder) { - done(new TextDecoder(charset).decode(contents)); - } else { - var mimeType = 'text/plain; charset=' + charset; //$NON-NLS-0$ - var blob = new Blob([contents], { type: mimeType }); - var reader = new FileReader(); - reader.onload = function() { - done(reader.result); - }.bind(this); - reader.onerror = errorHandler; - reader.readAsText(blob, charset); - } - } - - var UTF8 = "UTF-8"; //$NON-NLS-0$ - function isUTF8(charset) { - return !charset || charset === UTF8; //$NON-NLS-0$ + baseModel.addEventListener("postChanged", this._listener.onChanged); //$NON-NLS-0$ + baseModel.addEventListener("preChanging", this._listener.onChanging); //$NON-NLS-0$ } - /** - * @name orion.editor.InputManager - * @class - */ - function InputManager(options) { - EventTarget.attach(this); - this.serviceRegistry = options.serviceRegistry; - this.statusService = options.statusService; - this.fileClient = options.fileClient; - this.progressService = options.progressService; - this.contentTypeRegistry = options.contentTypeRegistry; - this.selection = options.selection; - this._input = this._title = ""; - } - objects.mixin(InputManager.prototype, /** @lends orion.editor.InputManager.prototype */ { + ProjectionTextModel.prototype = /** @lends orion.editor.ProjectionTextModel.prototype */ { /** - * @returns {orion.Promise} Promise resolving to the new Location we should use + * Destroys this projection text model. */ - _maybeLoadWorkspace: function(resource) { - var fileClient = this.fileClient; - // If it appears to be a workspaceRootURL we cannot load it directly, have to get the workspace first - var root = resource; - if (root.indexOf("?")) root = root.split("?")[0]; - if (root === fileClient.fileServiceRootURL(root)) { - return fileClient.loadWorkspace(root).then(function(workspace) { - return workspace.Location; - }); + destroy: function() { + if (this._model) { + this._model.removeEventListener("postChanged", this._listener.onChanged); //$NON-NLS-0$ + this._model.removeEventListener("preChanging", this._listener.onChanging); //$NON-NLS-0$ + this._model = null; } - return new Deferred().resolve(resource); }, /** - * Wrapper for fileClient.read() that tolerates a filesystem root URL passed as location. If location is indeed - * a filesystem root URL, the original read() operation is instead performed on the workspace. + * Adds a projection range to the model. + *

    + * The model must notify the listeners before and after the the text is + * changed by calling {@link #onChanging} and {@link #onChanged} respectively. + *

    + * @param {orion.editor.Projection} projection The projection range to be added. + * + * @see orion.editor.ProjectionTextModel#removeProjection */ - _read: function(loc /**, readArgs*/) { - var cachedMetadata = this.cachedMetadata || mNavigatorRenderer.getClickedItem(); - if (cachedMetadata && cachedMetadata.Location === loc && - cachedMetadata.Parents && cachedMetadata.Attributes && - cachedMetadata.ETag - ) { - return new Deferred().resolve(cachedMetadata); + addProjection: function(projection) { + if (!projection) {return;} + //start and end can't overlap any exist projection + var model = this._model, projections = this._projections; + projection._lineIndex = model.getLineAtOffset(projection.start); + projection._lineCount = model.getLineAtOffset(projection.end) - projection._lineIndex; + var text = projection.text; + if (!text) { text = ""; } + if (typeof text === "string") { //$NON-NLS-0$ + projection._model = new mTextModel.TextModel(text, model.getLineDelimiter()); + } else { + projection._model = text; } - var fileClient = this.fileClient; - var readArgs = Array.prototype.slice.call(arguments, 1); - return this._maybeLoadWorkspace(loc).then(function(newLocation) { - return fileClient.read.apply(fileClient, [newLocation].concat(readArgs)); - }); + var eventStart = this.mapOffset(projection.start, true); + var removedCharCount = projection.end - projection.start; + var removedLineCount = projection._lineCount; + var addedCharCount = projection._model.getCharCount(); + var addedLineCount = projection._model.getLineCount() - 1; + var modelChangingEvent = { + type: "Changing", //$NON-NLS-0$ + text: projection._model.getText(), + start: eventStart, + removedCharCount: removedCharCount, + addedCharCount: addedCharCount, + removedLineCount: removedLineCount, + addedLineCount: addedLineCount + }; + this.onChanging(modelChangingEvent); + var index = this._binarySearch(projections, projection.start); + projections.splice(index, 0, projection); + var modelChangedEvent = { + type: "Changed", //$NON-NLS-0$ + start: eventStart, + removedCharCount: removedCharCount, + addedCharCount: addedCharCount, + removedLineCount: removedLineCount, + addedLineCount: addedLineCount + }; + this.onChanged(modelChangedEvent); }, - _isSameParent: function(loc) { - if (this._lastMetadata && this._lastMetadata.Parents && this._lastMetadata.Parents.length > 0) { - var parentLocation = loc.substring(0, loc.lastIndexOf("/", loc.length - (loc[loc.length - 1] === "/" ? 2 : 1)) + 1); - return this._lastMetadata.Parents[0].Location === parentLocation; - } - return false; + /** + * Returns all projection ranges of this model. + * + * @return {orion.editor.Projection[]} The projection ranges. + * + * @see orion.editor.ProjectionTextModel#addProjection + */ + getProjections: function() { + return this._projections.slice(0); }, - load: function(charset) { - var fileURI = this.getInput(); - if (!fileURI) { return; } - var fileClient = this.fileClient; - var resource = this._parsedLocation.resource; - var progressService = this.progressService; - var progress = function(deferred, msgKey, uri) { - if (!progressService) { return deferred; } - return progressService.progress(deferred, i18nUtil.formatMessage(msgKey, uri)); - }; - var editor = this.getEditor(); - if (this._fileMetadata) { - //Reload if out of sync, unless we are already in the process of saving - if (!this._fileMetadata._saving && !this._fileMetadata.Directory && !this.getReadOnly()) { - progress(fileClient.read(resource, true), messages.ReadingMetadata, fileURI).then(function(data) { - if (this._fileMetadata && !this._fileMetadata._saving && this._fileMetadata.Location === data.Location && this._fileMetadata.ETag !== data.ETag) { - this._fileMetadata = objects.mixin(this._fileMetadata, data); - if (!editor.isDirty() || window.confirm(messages.loadOutOfSync)) { - progress(fileClient.read(resource), messages.Reading, fileURI).then(function(contents) { - editor.setInput(fileURI, null, contents); - this._clearUnsavedChanges(); - }.bind(this)); - } - } - }.bind(this)); - } - } else { - var progressTimeout = window.setTimeout(function() { - progressTimeout = null; - this.reportStatus(i18nUtil.formatMessage(messages.Fetching, fileURI)); - }.bind(this), 800); - var clearProgressTimeout = function() { - this.reportStatus(""); - if (progressTimeout) { - window.clearTimeout(progressTimeout); - } - }.bind(this); - var errorHandler = function(error) { - clearProgressTimeout(); - var statusService = null; - if(this.serviceRegistry) { - statusService = this.serviceRegistry.getService("orion.page.message"); //$NON-NLS-0$ - } else if(this.statusService) { - statusService = this.statusService; - } - handleError(statusService, error); - this._setNoInput(); - }.bind(this); - this._acceptPatch = null; - // Read metadata - var metadataURI = resource; - if (!this._isSameParent(metadataURI)) { - var uri = new URL(metadataURI); - uri.query.set("tree", localStorage.useCompressedTree ? "compressed" : "decorated"); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ - metadataURI = uri.href; - } - progress(this._read(metadataURI, true), messages.ReadingMetadata, resource).then(function(metadata) { - if(!metadata) { - errorHandler({responseText: i18nUtil.formatMessage(messages.ReadingMetadataError, resource)}); - } else if (metadata.Directory) { - // Fetch children - Deferred.when(metadata.Children || progress(fileClient.fetchChildren(metadata.ChildrenLocation), messages.Reading, fileURI), function(contents) { - clearProgressTimeout(); - metadata.Children = contents; - this._setInputContents(this._parsedLocation, fileURI, contents, metadata); - }.bind(this), errorHandler); - } else { - charset = charset || this._charset; - // Read contents if this is a text file and encoding is UTF-8 - var isText = this._isText(metadata); - if (isUTF8(charset) && isText) { - // Read text contents - progress(fileClient.read(resource, false, true), messages.Reading, fileURI).then(function(contents) { - clearProgressTimeout(); - if (typeof contents !== "string") { //$NON-NLS-0$ - this._acceptPatch = contents.acceptPatch; - contents = contents.result; - } - this._setInputContents(this._parsedLocation, fileURI, contents, metadata); - }.bind(this), errorHandler); - } else { - progress(fileClient._getService(resource).readBlob(resource), messages.Reading, fileURI).then(function(contents) { - clearProgressTimeout(); - if (isText) { - decode(contents, charset, function(result) { - this._setInputContents(this._parsedLocation, fileURI, result, metadata); - }.bind(this), errorHandler); - return; - } - this._setInputContents(this._parsedLocation, fileURI, contents, metadata); - }.bind(this), errorHandler); - } - } - }.bind(this), errorHandler); - } - }, - processParameters: function(input) { - var editor = this.getEditor(); - if (editor && editor.processParameters) { - return editor.processParameters(input); - } - return false; - }, - getAutoLoadEnabled: function() { - return this._autoLoadEnabled; - }, - getAutoSaveEnabled: function() { - return this._autoSaveEnabled; - }, - getEditor: function() { - return this.editor; - }, - getEncodingCharset: function() { - return this._charset || UTF8; - }, - getInput: function() { - return this._input; - }, - getLocation: function() { - return this._location; - }, - getTitle: function() { - return this._title; - }, - getFileMetadata: function() { - return this._fileMetadata; - }, - isSaveEnabled: function() { - return !this.getReadOnly(); - }, - getReadOnly: function() { - var data = this._fileMetadata; - return this._readonly || !data || (data.Attributes && data.Attributes.ReadOnly); - }, - getContentType: function() { - return this._contentType; + /** + * Gets the base text model. + * + * @return {orion.editor.TextModel} The base text model. + */ + getBaseModel: function() { + return this._model; }, - onFocus: function() { - // If there was an error while auto saving, auto save is temporarily disabled and - // we retry saving every time the editor gets focus - if (this._autoSaveEnabled && this._errorSaving) { - this.save(); - return; + /** + * Maps offsets between the projection model and its base model. + * + * @param {Number} offset The offset to be mapped. + * @param {Boolean} [baseOffset=false] true if offset is in base model and + * should be mapped to the projection model. + * @return {Number} The mapped offset + */ + mapOffset: function(offset, baseOffset) { + var projections = this._projections, delta = 0, i, projection; + if (baseOffset) { + for (i = 0; i < projections.length; i++) { + projection = projections[i]; + if (projection.start > offset) { break; } + if (projection.end > offset) { return -1; } + delta += projection._model.getCharCount() - (projection.end - projection.start); + } + return offset + delta; } - if (this._autoLoadEnabled && this._fileMetadata) { - this.load(); + for (i = 0; i < projections.length; i++) { + projection = projections[i]; + if (projection.start > offset - delta) { break; } + var charCount = projection._model.getCharCount(); + if (projection.start + charCount > offset - delta) { + return -1; + } + delta += charCount - (projection.end - projection.start); } + return offset - delta; }, - reportStatus: function(msg) { - if (this.statusReporter) { - this.statusReporter(msg); - } else if (this.editor) { - this.editor.reportStatus(msg); - } + /** + * Removes a projection range from the model. + *

    + * The model must notify the listeners before and after the the text is + * changed by calling {@link #onChanging} and {@link #onChanged} respectively. + *

    + * + * @param {orion.editor.Projection} projection The projection range to be removed. + * + * @see orion.editor.ProjectionTextModel#addProjection + */ + removeProjection: function(projection) { + this._removeProjection(projection); }, - save: function(closing) { - var metadata = this.getFileMetadata(); - if (!metadata) return new Deferred().reject(); - if (metadata._saving) { return metadata._savingDeferred; } - var that = this; - metadata._savingDeferred = new Deferred(); - metadata._saving = true; - function done(result) { - var deferred = metadata._savingDeferred; - deferred.resolve(result); - metadata._savingDeferred = null; - metadata._saving = false; - return deferred; - } - var editor = this.getEditor(); - if (!editor || !editor.isDirty() || this.getReadOnly()) { return done(); } - var failedSaving = this._errorSaving; - var input = this.getInput(); - this.reportStatus(messages['Saving...']); - - if (!this._saveEventLogged) { - this._logMetrics("save"); //$NON-NLS-0$ - this._saveEventLogged = true; - } - - this.dispatchEvent({ type: "Saving", inputManager: this}); //$NON-NLS-0$ - - editor.markClean(); - var contents = editor.getText(); - var data = contents; - if (this._getSaveDiffsEnabled() && !this._errorSaving) { - var changes = this._getUnsavedChanges(); - if (changes) { - var len = 0; - for (var i = 0; i < changes.length; i++) { - len += changes[i].text.length; - } - if (contents.length > len) { - data = { - diff: changes - }; - } + _removeProjection: function(projection, noEvents) { + var i, delta = 0; + for (i = 0; i < this._projections.length; i++) { + var p = this._projections[i]; + if (p === projection) { + projection = p; + break; } + delta += p._model.getCharCount() - (p.end - p.start); } - this._clearUnsavedChanges(); - this._errorSaving = false; - - var etag = metadata.ETag; - var args = { "ETag" : etag }; //$NON-NLS-0$ - var resource = this._parsedLocation.resource; - var def = this.fileClient.write(resource, data, args); - var progress = this.progressService; - var statusService = null; - if(this.serviceRegistry){ - statusService = this.serviceRegistry.getService("orion.page.message"); //$NON-NLS-0$ - } - if (progress) { - def = progress.progress(def, i18nUtil.formatMessage(messages.savingFile, input)); - } - function successHandler(result) { - if (input === that.getInput()) { - metadata.ETag = result.ETag; - editor.setInput(input, null, contents, true); - } - that.reportStatus(""); - if (failedSaving && statusService) { - statusService.setProgressResult({Message:messages.Saved, Severity:"Normal"}); //$NON-NLS-0$ + if (i < this._projections.length) { + var model = this._model; + var eventStart = projection.start + delta; + var addedCharCount = projection.end - projection.start; + var addedLineCount = projection._lineCount; + var removedCharCount = projection._model.getCharCount(); + var removedLineCount = projection._model.getLineCount() - 1; + if (!noEvents) { + var modelChangingEvent = { + type: "Changing", //$NON-NLS-0$ + text: model.getText(projection.start, projection.end), + start: eventStart, + removedCharCount: removedCharCount, + addedCharCount: addedCharCount, + removedLineCount: removedLineCount, + addedLineCount: addedLineCount + }; + this.onChanging(modelChangingEvent); } - if (that.postSave) { - that.postSave(closing); + this._projections.splice(i, 1); + if (!noEvents) { + var modelChangedEvent = { + type: "Changed", //$NON-NLS-0$ + start: eventStart, + removedCharCount: removedCharCount, + addedCharCount: addedCharCount, + removedLineCount: removedLineCount, + addedLineCount: addedLineCount + }; + this.onChanged(modelChangedEvent); } - return done(result); - } - function errorHandler(error) { - that.reportStatus(""); - var errorMsg = handleError(statusService, error); - mMetrics.logEvent("status", "exception", (that._autoSaveActive ? "Auto-save: " : "Save: ") + errorMsg.Message); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ - that._errorSaving = true; - return done(); } - def.then(successHandler, function(error) { - // expected error - HTTP 412 Precondition Failed - // occurs when file is out of sync with the server - if (error.status === 412) { - var forceSave = window.confirm(messages.saveOutOfSync); - if (forceSave) { - // repeat save operation, but without ETag - var redef = that.fileClient.write(resource, contents); - if (progress) { - redef = progress.progress(redef, i18nUtil.formatMessage(messages.savingFile, input)); - } - redef.then(successHandler, errorHandler); - } else { - return done(); - } + }, + /** @ignore */ + _binarySearch: function (array, offset) { + var high = array.length, low = -1, index; + while (high - low > 1) { + index = Math.floor((high + low) / 2); + if (offset <= array[index].start) { + high = index; } else { - // unknown error - errorHandler(error); + low = index; } - }); - return metadata._savingDeferred; - }, - setAutoLoadEnabled: function(enabled) { - this._autoLoadEnabled = enabled; + } + return high; }, /** - * Set the autosave timeout. If the timeout is -1, autosave is - * disabled. - * @param {Number} timeout - the autosave timeout in milliseconds + * @see orion.editor.TextModel#getCharCount */ - setAutoSaveTimeout: function(timeout) { - this._autoSaveEnabled = timeout !== -1; - this._autoSaveActive = false; - if (!this._idle) { - var options = { - document: document, - timeout: timeout - }; - this._idle = new Idle(options); - this._idle.addEventListener("Idle", function () { //$NON-NLS-0$ - if (!this._errorSaving) { - this._autoSaveActive = true; - this.save().then(function() { - this._autoSaveActive = false; - }); - } - }.bind(this)); - } else { - this._idle.setTimeout(timeout); + getCharCount: function() { + var count = this._model.getCharCount(), projections = this._projections; + for (var i = 0; i < projections.length; i++) { + var projection = projections[i]; + count += projection._model.getCharCount() - (projection.end - projection.start); } + return count; }, - setContentType: function(contentType) { - this._contentType = contentType; - }, - setEncodingCharset: function(charset) { - this._charset = charset; - }, - setInput: function(loc) { - if (this._ignoreInput) { return; } - if (!loc) { - loc = PageUtil.hash(); - } - if (typeof loc !== "string") { //$NON-NLS-0$ - return; - } - var editor = this.getEditor(); - if (loc && loc[0] !== "#") { //$NON-NLS-0$ - loc = "#" + loc; //$NON-NLS-0$ - } - var input = PageUtil.matchResourceParameters(loc), oldInput = this._parsedLocation || {}; - var encodingChanged = oldInput.encoding !== input.encoding; - if (editor && editor.isDirty()) { - var oldLocation = this._location; - var oldResource = oldInput.resource; - var newResource = input.resource; - if (oldResource !== newResource || encodingChanged) { - if (this._autoSaveEnabled) { - this.save(); - } else if (!window.confirm(messages.confirmUnsavedChanges)) { - window.location.hash = oldLocation; - return; + /** + * @see orion.editor.TextModel#getLine + */ + getLine: function(lineIndex, includeDelimiter) { + if (lineIndex < 0) { return null; } + var model = this._model, projections = this._projections; + var delta = 0, result = [], offset = 0, i, lineCount, projection; + for (i = 0; i < projections.length; i++) { + projection = projections[i]; + if (projection._lineIndex >= lineIndex - delta) { break; } + lineCount = projection._model.getLineCount() - 1; + if (projection._lineIndex + lineCount >= lineIndex - delta) { + var projectionLineIndex = lineIndex - (projection._lineIndex + delta); + if (projectionLineIndex < lineCount) { + return projection._model.getLine(projectionLineIndex, includeDelimiter); + } else { + result.push(projection._model.getLine(lineCount)); } } + offset = projection.end; + delta += lineCount - projection._lineCount; } - var editorChanged = editor && oldInput.editor !== input.editor; - this._location = loc; - this._parsedLocation = input; - this._ignoreInput = true; - if(this.selection) { - this.selection.setSelections(loc); - } - this._ignoreInput = false; - var evt = { - type: "InputChanging", //$NON-NLS-0$ - input: input - }; - this.dispatchEvent(evt); - function saveSession() { - if (evt.session) { - evt.session.save(); + offset = Math.max(offset, model.getLineStart(lineIndex - delta)); + for (; i < projections.length; i++) { + projection = projections[i]; + if (projection._lineIndex > lineIndex - delta) { break; } + result.push(model.getText(offset, projection.start)); + lineCount = projection._model.getLineCount() - 1; + if (projection._lineIndex + lineCount > lineIndex - delta) { + result.push(projection._model.getLine(0, includeDelimiter)); + return result.join(""); } + result.push(projection._model.getText()); + offset = projection.end; + delta += lineCount - projection._lineCount; } - var fileURI = input.resource; - if (evt.metadata) { - saveSession(); - this.reportStatus(""); - this._input = fileURI; - var metadata = evt.metadata; - this._setInputContents(input, fileURI, null, metadata); - return; + var end = model.getLineEnd(lineIndex - delta, includeDelimiter); + if (offset < end) { + result.push(model.getText(offset, end)); } - if (fileURI) { - if (fileURI === this._input && !encodingChanged) { - if (editorChanged) { - this.reportStatus(""); - this._setInputContents(input, fileURI, null, this._fileMetadata, this._isText(this._fileMetadata)); - } else { - if (!this.processParameters(input)) { - if (evt.session) { - evt.session.apply(true); - } - } - } - } else { - saveSession(); - this._input = fileURI; - this._readonly = false; - this._lastMetadata = this._fileMetadata; - this._fileMetadata = null; - this.load(input.encoding); + return result.join(""); + }, + /** + * @see orion.editor.TextModel#getLineAtOffset + */ + getLineAtOffset: function(offset) { + var model = this._model, projections = this._projections; + var delta = 0, lineDelta = 0; + for (var i = 0; i < projections.length; i++) { + var projection = projections[i]; + if (projection.start > offset - delta) { break; } + var charCount = projection._model.getCharCount(); + if (projection.start + charCount > offset - delta) { + var projectionOffset = offset - (projection.start + delta); + lineDelta += projection._model.getLineAtOffset(projectionOffset); + delta += projectionOffset; + break; } - } else { - saveSession(); - this._setNoInput(true); + lineDelta += projection._model.getLineCount() - 1 - projection._lineCount; + delta += charCount - (projection.end - projection.start); } + return model.getLineAtOffset(offset - delta) + lineDelta; }, - setTitle: function(title) { - var indexOfSlash = title.lastIndexOf("/"); //$NON-NLS-0$ - var shortTitle = title; - if (indexOfSlash !== -1) { - shortTitle = shortTitle.substring(indexOfSlash + 1); + /** + * @see orion.editor.TextModel#getLineCount + */ + getLineCount: function() { + var model = this._model, projections = this._projections; + var count = model.getLineCount(); + for (var i = 0; i < projections.length; i++) { + var projection = projections[i]; + count += projection._model.getLineCount() - 1 - projection._lineCount; } - this._title = shortTitle; + return count; }, - setSaveDiffsEnabled: function(enabled) { - this._saveDiffsEnabled = enabled; - var editor = this.editor; - if (editor && !editor.isDirty()) { - this._clearUnsavedChanges(); + /** + * @see orion.editor.TextModel#getLineDelimiter + */ + getLineDelimiter: function() { + return this._model.getLineDelimiter(); + }, + /** + * @see orion.editor.TextModel#getLineEnd + */ + getLineEnd: function(lineIndex, includeDelimiter) { + if (lineIndex < 0) { return -1; } + var model = this._model, projections = this._projections; + var delta = 0, offsetDelta = 0; + for (var i = 0; i < projections.length; i++) { + var projection = projections[i]; + if (projection._lineIndex > lineIndex - delta) { break; } + var lineCount = projection._model.getLineCount() - 1; + if (projection._lineIndex + lineCount > lineIndex - delta) { + var projectionLineIndex = lineIndex - (projection._lineIndex + delta); + return projection._model.getLineEnd (projectionLineIndex, includeDelimiter) + projection.start + offsetDelta; + } + offsetDelta += projection._model.getCharCount() - (projection.end - projection.start); + delta += lineCount - projection._lineCount; } + return model.getLineEnd(lineIndex - delta, includeDelimiter) + offsetDelta; }, - _getSaveDiffsEnabled: function() { - return this._saveDiffsEnabled && this._acceptPatch && this._acceptPatch.indexOf("application/json-patch") !== -1; //$NON-NLS-0$ + /** + * @see orion.editor.TextModel#getLineStart + */ + getLineStart: function(lineIndex) { + if (lineIndex < 0) { return -1; } + var model = this._model, projections = this._projections; + var delta = 0, offsetDelta = 0; + for (var i = 0; i < projections.length; i++) { + var projection = projections[i]; + if (projection._lineIndex >= lineIndex - delta) { break; } + var lineCount = projection._model.getLineCount() - 1; + if (projection._lineIndex + lineCount >= lineIndex - delta) { + var projectionLineIndex = lineIndex - (projection._lineIndex + delta); + return projection._model.getLineStart (projectionLineIndex) + projection.start + offsetDelta; + } + offsetDelta += projection._model.getCharCount() - (projection.end - projection.start); + delta += lineCount - projection._lineCount; + } + return model.getLineStart(lineIndex - delta) + offsetDelta; }, - _logMetrics: function(type) { - var label = "(none)"; //$NON-NLS-0$ - var contentType = this.getContentType(); - var metadata = this.getFileMetadata(); - if (contentType) { - label = contentType.id; - } else if (metadata) { - var _name = metadata.Name; - var index = _name.lastIndexOf("."); //$NON-NLS-0$ - if (index >= 0) { - label = "unregistered: " + _name.substring(index); //$NON-NLS-0$ - } else { - switch (_name) { - case "AUTHORS": //$NON-NLS-0$ - case "config": //$NON-NLS-0$ - case "LICENSE": //$NON-NLS-0$ - case "make": //$NON-NLS-0$ - case "Makefile": { //$NON-NLS-0$ - label = "unregistered: " + _name; //$NON-NLS-0$ - break; - } + /** + * @see orion.editor.TextModel#getText + */ + getText: function(start, end) { + if (start === undefined) { start = 0; } + var model = this._model, projections = this._projections; + var delta = 0, result = [], i, projection, charCount; + for (i = 0; i < projections.length; i++) { + projection = projections[i]; + if (projection.start > start - delta) { break; } + charCount = projection._model.getCharCount(); + if (projection.start + charCount > start - delta) { + if (end !== undefined && projection.start + charCount > end - delta) { + return projection._model.getText(start - (projection.start + delta), end - (projection.start + delta)); + } else { + result.push(projection._model.getText(start - (projection.start + delta))); + start = projection.end + delta + charCount - (projection.end - projection.start); } } + delta += charCount - (projection.end - projection.start); } - mMetrics.logEvent("editor", type, label, null, {path: metadata.Location}); //$NON-NLS-0$ - }, - _unknownContentTypeAsText: function() {// Return true if we think unknown content type is text type - return true; - }, - _isText: function(metadata) { - var contentType = this.contentTypeRegistry.getFileContentType(metadata); - // Allow unkownn content types to be loaded as text files - if (!contentType) { return this._unknownContentTypeAsText(); } - var textPlain = this.contentTypeRegistry.getContentType("text/plain"); //$NON-NLS-0$ - return this.contentTypeRegistry.isExtensionOf(contentType, textPlain); - }, - _setNoInput: function(loadRoot) { - if (loadRoot) { - this.fileClient.loadWorkspace("").then(function(root) { - this._input = root.ChildrenLocation; - this._setInputContents(root.ChildrenLocation, null, root, root); - }.bind(this)); - return; + var offset = start - delta; + if (end !== undefined) { + for (; i < projections.length; i++) { + projection = projections[i]; + if (projection.start > end - delta) { break; } + result.push(model.getText(offset, projection.start)); + charCount = projection._model.getCharCount(); + if (projection.start + charCount > end - delta) { + result.push(projection._model.getText(0, end - (projection.start + delta))); + return result.join(""); + } + result.push(projection._model.getText()); + offset = projection.end; + delta += charCount - (projection.end - projection.start); + } + result.push(model.getText(offset, end - delta)); + } else { + for (; i < projections.length; i++) { + projection = projections[i]; + result.push(model.getText(offset, projection.start)); + result.push(projection._model.getText()); + offset = projection.end; + } + result.push(model.getText(offset)); } - // No input, no editor. - this._input = this._title = this._fileMetadata = null; - this.setContentType(null); - this.dispatchEvent({ type: "InputChanged", input: null }); //$NON-NLS-0$ + return result.join(""); }, - _setInputContents: function(input, title, contents, metadata, noSetInput) { - var _name, isDir = false; - if (metadata) { - this._fileMetadata = metadata; - this.setTitle(metadata.Location || String(metadata)); - this.setContentType(this.contentTypeRegistry.getFileContentType(metadata)); - _name = metadata.Name; - isDir = metadata.Directory; - } else { - // No metadata - this._fileMetadata = null; - this.setTitle(title); - this.setContentType(this.contentTypeRegistry.getFilenameContentType(this.getTitle())); - _name = this.getTitle(); + /** @ignore */ + _onChanged: function(modelChangedEvent) { + var change = this._change; + var start = change.baseStart, end = change.baseEnd, i; + var projection, projections = this._projections; + for (i = 0; i < projections.length; i++) { + projection = projections[i]; + if (projection.end > start) { break; } } - var editor = this.getEditor(); - if (this._focusListener) { - if (editor && editor.getTextView && editor.getTextView()) { - editor.getTextView().removeEventListener("Focus", this._focusListener); //$NON-NLS-0$ + var rangeStart = i; + for (i = 0; i < projections.length; i++) { + projection = projections[i]; + if (projection.start >= end) { break; } + } + var rangeEnd = i; + var model = this._model; + var changeCount = change.baseText.length - (end - start); + for (i = rangeEnd; i < projections.length; i++) { + projection = projections[i]; + projection.start += changeCount; + projection.end += changeCount; + projection._lineIndex = model.getLineAtOffset(projection.start); + } + var removed = projections.splice(rangeStart, rangeEnd - rangeStart); + for (i = 0; i < removed.length; i++) { + if (removed[i].annotation) { + removed[i].annotation._expand(); } - this._focusListener = null; } - var evt = { - type: "InputChanged", //$NON-NLS-0$ - input: input, - name: _name, - title: title, - contentType: this.getContentType(), - metadata: metadata, - location: window.location, - contents: contents + var modelChangedEvent1 = { + type: "Changed", //$NON-NLS-0$ + start: change.start, + removedCharCount: change.removedCharCount, + addedCharCount: change.addedCharCount, + removedLineCount: change.removedLineCount, + addedLineCount: change.addedLineCount }; - this._logMetrics("open"); //$NON-NLS-0$ - this.dispatchEvent(evt); - this.editor = editor = evt.editor; - if (!isDir) { - if (!noSetInput) { - editor.setInput(title, null, contents); + this.onChanged(modelChangedEvent1); + this._change = undefined; + }, + _onChanging: function(modelChangingEvent) { + var hasChange = !!this._change; + var change = this._change || {}; + var start = modelChangingEvent.start, end = start + modelChangingEvent.removedCharCount; + change.baseStart = start; + change.baseEnd = end; + change.baseText = modelChangingEvent.text; + change.addedLineCount = modelChangingEvent.addedLineCount; + if (!hasChange) { + this._change = change; + change.text = modelChangingEvent.text; + var projections = this._projections, delta, i, projection; + function mapOffset(offset) { + for (i = 0, delta = 0; i < projections.length; i++) { + projection = projections[i]; + if (projection.start > offset) { break; } + if (projection.end > offset) { return -1; } + delta += projection._model.getCharCount() - (projection.end - projection.start); + } + return offset + delta; } - if (editor && editor.getTextView && editor.getTextView()) { - var textView = editor.getTextView(); - textView.addEventListener("Focus", this._focusListener = this.onFocus.bind(this)); //$NON-NLS-0$ + change.start = mapOffset(start); + if (change.start === -1) { + change.text = this._model.getText(projection.start, start) + change.text; + change.addedLineCount += this._model.getLineAtOffset(start) - this._model.getLineAtOffset(projection.start); + change.start = projection.start + delta; } - this._clearUnsavedChanges(); - if (!this.processParameters(input)) { - if (evt.session) { - evt.session.apply(); - } + change.end = mapOffset(end); + if (change.end === -1) { + change.text += this._model.getText(end, projection.end); + change.addedLineCount += this._model.getLineAtOffset(projection.end) - this._model.getLineAtOffset(end); + change.end = projection.start + delta; } } - - this._saveEventLogged = false; - mMetrics.logPageLoadTiming("interactive", window.location.pathname); //$NON-NLS-0$ + change.addedCharCount = change.text.length; + change.removedCharCount = change.end - change.start; + change.removedLineCount = this.getLineAtOffset(change.end) - this.getLineAtOffset(change.start); + var modelChangingEvent1 = { + type: "Changing", //$NON-NLS-0$ + text: change.text, + start: change.start, + removedCharCount: change.removedCharCount, + addedCharCount: change.addedCharCount, + removedLineCount: change.removedLineCount, + addedLineCount: change.addedLineCount + }; + this.onChanging(modelChangingEvent1); }, - _getUnsavedChanges: function() { - var editor = this.editor; - if (editor && editor.getUndoStack && editor.getUndoStack()) { - return editor.getUndoStack()._unsavedChanges; - } - return null; + /** + * @see orion.editor.TextModel#onChanging + */ + onChanging: function(modelChangingEvent) { + return this.dispatchEvent(modelChangingEvent); }, - _clearUnsavedChanges: function() { - var editor = this.editor; - if (editor && editor.getUndoStack && editor.getUndoStack()) { - editor.getUndoStack()._unsavedChanges = this._getSaveDiffsEnabled() ? [] : null; + /** + * @see orion.editor.TextModel#onChanged + */ + onChanged: function(modelChangedEvent) { + return this.dispatchEvent(modelChangedEvent); + }, + /** + * @see orion.editor.TextModel#setLineDelimiter + */ + setLineDelimiter: function(lineDelimiter) { + this._model.setLineDelimiter(lineDelimiter); + }, + /** + * @see orion.editor.TextModel#setText + */ + setText: function(text, start, end) { + this._change = { + text: text || "", + start: start || 0, + end: end === undefined ? this.getCharCount() : end + }; + var projections = this._projections, delta, i, projection; + function mapOffset(offset) { + for (i = 0, delta = 0; i < projections.length; i++) { + projection = projections[i]; + if (projection.start > offset - delta) { break; } + var charCount = projection._model.getCharCount(); + if (projection.start + charCount > offset - delta) { + return -1; + } + delta += charCount - (projection.end - projection.start); + } + return offset - delta; + } + var startProjection, endProjection; + var mapStart = mapOffset(this._change.start); + if (mapStart === -1) { + startProjection = { + projection: projection, + start: this._change.start - (projection.start + delta) + }; + mapStart = projection.end; + } + var mapEnd = mapOffset(this._change.end); + if (mapEnd === -1) { + endProjection = { + projection: projection, + end: this._change.end - (projection.start + delta) + }; + mapEnd = projection.start; + } + if (startProjection && endProjection && startProjection.projection === endProjection.projection) { + //TODO events - special case - change is completely inside of a projection + projection._model.setText(this._change.text, startProjection.start, endProjection.end); + } else { + this._model.setText(this._change.text, mapStart, mapEnd); + if (startProjection) { + projection = startProjection.projection; + projection._model.setText("", startProjection.start); + } + if (endProjection) { + projection = endProjection.projection; + projection._model.setText("", 0, endProjection.end); + projection.start = projection.end; + projection._lineCount = 0; + } } + this._change = undefined; } - }); - return { - handleError: handleError, - InputManager: InputManager }; + mEventTarget.EventTarget.addMixin(ProjectionTextModel.prototype); + + return {ProjectionTextModel: ProjectionTextModel}; }); /******************************************************************************* * @license - * Copyright (c) 2013 IBM Corporation and others. + * Copyright (c) 2016 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 + * Contributors: IBM Corporation - initial API and implementation *******************************************************************************/ - /*eslint-env browser, amd*/ -define("orion/editor/keyModes", [ //$NON-NLS-0$ - "orion/keyBinding", //$NON-NLS-0$ - "orion/util" //$NON-NLS-0$ -], function(mKeyBinding, util) { - - function KeyMode(view) { - if (!view) { - return; - } - this._view = view; - this._keyBindings = this.createKeyBindings(); - this._keyBindingIndex = 0; +define('orion/editor/textModelFactory',[ + 'orion/editor/textModel', + 'orion/editor/projectionTextModel' +], function(mTextModel, mProjectionTextModel) { + + /** + * TextModelFactory generates all the base text model and projection model for the editors + */ + function TextModelFactory() { } - KeyMode.prototype = /** @lends orion.editor.KeyMode.prototype */ { - createKeyBindings: function () { - return []; - }, + TextModelFactory.prototype = { /** - * Returns all the key bindings associated to the given action ID. - * - * @param {String} actionID the action ID. - * @returns {orion.KeyBinding[]} the array of key bindings associated to the given action ID. - * - * @see orion.editor.KeyModesetKeyBinding - * @see orion.editor.KeyModesetAction + * Create a text model instance for editor. A customized TextModelFactory can return a sub class of mTextModel.TextModel. */ - getKeyBindings: function (actionID) { - var result = []; - var keyBindings = this._keyBindings; - for (var i = 0; i < keyBindings.length; i++) { - if (keyBindings[i].actionID === actionID) { - result.push(keyBindings[i].keyBinding); - } - } - return result; - }, - getView: function() { - return this._view; - }, - isActive: function () { - return this._view.getKeyModes().indexOf(this) !== -1; - }, - match: function(e) { - if (e.type === "keydown") { //$NON-NLS-0$ - switch (e.keyCode) { - case 16: /* Shift */ - case 17: /* Control */ - case 18: /* Alt */ - case 91: /* Command */ - return undefined; - } - } - var keyBindingIndex = this._keyBindingIndex; - var keyBindings = this._matchingKeyBindings || this._keyBindings; - var matchingKeyBindings = []; - for (var i = 0; i < keyBindings.length; i++) { - var kb = keyBindings[i]; - var keyBinding = kb.keyBinding; - var match = keyBinding.match(e, keyBindingIndex); - if (match === true) { - this._keyBindingIndex = 0; - this._matchingKeyBindings = null; - return kb.actionID; - } else if (typeof match === "number") { //$NON-NLS-0$ - matchingKeyBindings.push(kb); - } - } - if (matchingKeyBindings.length === 0) { - this._keyBindingIndex = 0; - this._matchingKeyBindings = null; - } else { - this._keyBindingIndex++; - this._matchingKeyBindings = matchingKeyBindings; - return "noop"; //$NON-NLS-0$ - } - return undefined; + createTextModel: function(/*options*/) { + return new mTextModel.TextModel(); }, /** - * Associates a key binding with the given action ID. Any previous - * association with the specified key binding is overwriten. If the - * action ID is null, the association is removed. - * - * @param {orion.KeyBinding} keyBinding the key binding - * @param {String} actionID the action ID + * Create a projection text model instance for editor. A customized TextModelFactory can create a sub class of mTextModel.TextModel + * or a sub class of mProjectionTextModel.ProjectionTextModel. */ - setKeyBinding: function(keyBinding, actionID) { - var keyBindings = this._keyBindings; - for (var i = 0; i < keyBindings.length; i++) { - var kb = keyBindings[i]; - if (kb.keyBinding.equals(keyBinding)) { - if (actionID) { - kb.actionID = actionID; - } else { - if (kb.predefined) { - kb.actionID = "noop"; //$NON-NLS-0$ - } else { - keyBindings.splice(i, 1); - } - } - return; - } - } - if (actionID) { - keyBindings.push({keyBinding: keyBinding, actionID: actionID}); - } - }, - setView: function(view) { - this._view = view; + createProjectionTextModel: function(baseModel, options) { + return new mProjectionTextModel.ProjectionTextModel(baseModel ? baseModel: this.createTextModel(options)); } }; - - function DefaultKeyMode(view) { - KeyMode.call(this, view); + return { + TextModelFactory: TextModelFactory + }; +}); + +/******************************************************************************* + * @license + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +/*eslint-env browser, amd*/ +define('orion/inputManager',[ + 'i18n!orion/edit/nls/messages', + 'orion/explorers/navigatorRenderer', + 'orion/i18nUtil', + 'orion/Deferred', + 'orion/EventTarget', + 'orion/objects', + 'orion/PageUtil', + 'orion/editor/textModelFactory', + 'orion/metrics' +], function(messages, mNavigatorRenderer, i18nUtil, Deferred, EventTarget, objects, PageUtil, mTextModelFactory, mMetrics) { + + function Idle(options){ + this._document = options.document || document; + this._timeout = options.timeout; + //TODO: remove listeners if there are no clients + //TODO: add support for multiple clients with different timeouts + var events = ["mousedown", "keypress","keydown","keyup"]; //$NON-NLS-0$ //$NON-NLS-1$ //$NON-NLS-2$ + var reset = function () { this._resetTimer(); }.bind(this); + for (var i = 0; i < events.length; i++) { + var evt = events[i]; + this._document.addEventListener(evt, reset, true); + } + EventTarget.attach(this); } - DefaultKeyMode.prototype = new KeyMode(); - DefaultKeyMode.prototype.createKeyBindings = function () { - var KeyBinding = mKeyBinding.KeyBinding; - //no duplicate keybindings - var bindings = []; - // Cursor Navigation - bindings.push({actionID: "lineUp", keyBinding: new KeyBinding(38), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "lineDown", keyBinding: new KeyBinding(40), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "charPrevious", keyBinding: new KeyBinding(37), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "charNext", keyBinding: new KeyBinding(39), predefined: true}); //$NON-NLS-0$ - if (util.isMac) { - bindings.push({actionID: "scrollPageUp", keyBinding: new KeyBinding(33), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "scrollPageDown", keyBinding: new KeyBinding(34), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "pageUp", keyBinding: new KeyBinding(33, null, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "pageDown", keyBinding: new KeyBinding(34, null, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "lineStart", keyBinding: new KeyBinding(37, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "lineEnd", keyBinding: new KeyBinding(39, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "wordPrevious", keyBinding: new KeyBinding(37, null, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "wordNext", keyBinding: new KeyBinding(39, null, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "scrollTextStart", keyBinding: new KeyBinding(36), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "scrollTextEnd", keyBinding: new KeyBinding(35), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "textStart", keyBinding: new KeyBinding(38, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "textEnd", keyBinding: new KeyBinding(40, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "scrollPageUp", keyBinding: new KeyBinding(38, null, null, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "scrollPageDown", keyBinding: new KeyBinding(40, null, null, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "lineStart", keyBinding: new KeyBinding(37, null, null, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "lineEnd", keyBinding: new KeyBinding(39, null, null, null, true), predefined: true}); //$NON-NLS-0$ - //TODO These two actions should be changed to paragraph start and paragraph end when word wrap is implemented - bindings.push({actionID: "lineStart", keyBinding: new KeyBinding(38, null, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "lineEnd", keyBinding: new KeyBinding(40, null, null, true), predefined: true}); //$NON-NLS-0$ - } else { - bindings.push({actionID: "pageUp", keyBinding: new KeyBinding(33), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "pageDown", keyBinding: new KeyBinding(34), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "lineStart", keyBinding: new KeyBinding(36), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "lineEnd", keyBinding: new KeyBinding(35), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "wordPrevious", keyBinding: new KeyBinding(37, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "wordNext", keyBinding: new KeyBinding(39, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "textStart", keyBinding: new KeyBinding(36, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "textEnd", keyBinding: new KeyBinding(35, true), predefined: true}); //$NON-NLS-0$ - } - if (util.isFirefox && util.isLinux) { - bindings.push({actionID: "lineUp", keyBinding: new KeyBinding(38, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "lineDown", keyBinding: new KeyBinding(40, true), predefined: true}); //$NON-NLS-0$ - } - if (util.isWindows) { - bindings.push({actionID: "scrollLineUp", keyBinding: new KeyBinding(38, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "scrollLineDown", keyBinding: new KeyBinding(40, true), predefined: true}); //$NON-NLS-0$ + Idle.prototype = { + _resetTimer: function() { + var win = this._document.defaultView || this._document.parentWindow; + if (this._timer) { + win.clearTimeout(this._timer); + this._timer = null; + } + if (this._timeout !== -1) { + this._timer = win.setTimeout(function() { + this.onIdle({type:"Idle"}); //$NON-NLS-0$ + this._timer = null; + this._resetTimer(); + }.bind(this), this._timeout); + } + }, + onIdle: function (idleEvent) { + return this.dispatchEvent(idleEvent); + }, + setTimeout: function(timeout) { + this._timeout = timeout; + this._resetTimer(); } + }; - // Select Cursor Navigation - bindings.push({actionID: "selectLineUp", keyBinding: new KeyBinding(38, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectLineDown", keyBinding: new KeyBinding(40, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectCharPrevious", keyBinding: new KeyBinding(37, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectCharNext", keyBinding: new KeyBinding(39, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectPageUp", keyBinding: new KeyBinding(33, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectPageDown", keyBinding: new KeyBinding(34, null, true), predefined: true}); //$NON-NLS-0$ - if (util.isMac) { - bindings.push({actionID: "selectLineStart", keyBinding: new KeyBinding(37, true, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectLineEnd", keyBinding: new KeyBinding(39, true, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectWordPrevious", keyBinding: new KeyBinding(37, null, true, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectWordNext", keyBinding: new KeyBinding(39, null, true, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectTextStart", keyBinding: new KeyBinding(36, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectTextEnd", keyBinding: new KeyBinding(35, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectTextStart", keyBinding: new KeyBinding(38, true, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectTextEnd", keyBinding: new KeyBinding(40, true, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectLineStart", keyBinding: new KeyBinding(37, null, true, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectLineEnd", keyBinding: new KeyBinding(39, null, true, null, true), predefined: true}); //$NON-NLS-0$ - //TODO These two actions should be changed to select paragraph start and select paragraph end when word wrap is implemented - bindings.push({actionID: "selectLineStart", keyBinding: new KeyBinding(38, null, true, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectLineEnd", keyBinding: new KeyBinding(40, null, true, true), predefined: true}); //$NON-NLS-0$ - } else { - if (util.isLinux) { - bindings.push({actionID: "selectWholeLineUp", keyBinding: new KeyBinding(38, true, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectWholeLineDown", keyBinding: new KeyBinding(40, true, true), predefined: true}); //$NON-NLS-0$ + function _makeError(error) { + var newError = { + Severity: "Error", //$NON-NLS-0$ + Message: messages.noResponse + }; + if(error.name === "Cancel") { + return {Severity: "Warning", Message: error.name, Cancel: true}; + } else if (error.status === 0) { + newError.Cancel = true; + return newError; // might do better here + } else if (error.responseText) { + var responseText = error.responseText; + try { + var parsedError = JSON.parse(responseText); + newError.Severity = parsedError.Severity || newError.Severity; + newError.Message = parsedError.Message || newError.Message; + } catch (e) { + newError.Message = responseText; } - bindings.push({actionID: "selectLineStart", keyBinding: new KeyBinding(36, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectLineEnd", keyBinding: new KeyBinding(35, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectWordPrevious", keyBinding: new KeyBinding(37, true, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectWordNext", keyBinding: new KeyBinding(39, true, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectTextStart", keyBinding: new KeyBinding(36, true, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectTextEnd", keyBinding: new KeyBinding(35, true, true), predefined: true}); //$NON-NLS-0$ - } - - //Undo stack - bindings.push({actionID: "undo", keyBinding: new mKeyBinding.KeyBinding('z', true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - if (util.isMac) { - bindings.push({actionID: "redo", keyBinding: new mKeyBinding.KeyBinding('z', true, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ } else { - bindings.push({actionID: "redo", keyBinding: new mKeyBinding.KeyBinding('y', true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - } - - //Misc - bindings.push({actionID: "deletePrevious", keyBinding: new KeyBinding(8), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "deletePrevious", keyBinding: new KeyBinding(8, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "deleteNext", keyBinding: new KeyBinding(46), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "deleteWordPrevious", keyBinding: new KeyBinding(8, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "deleteWordPrevious", keyBinding: new KeyBinding(8, true, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "deleteWordNext", keyBinding: new KeyBinding(46, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "tab", keyBinding: new KeyBinding(9), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "shiftTab", keyBinding: new KeyBinding(9, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "enter", keyBinding: new KeyBinding(13), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "enter", keyBinding: new KeyBinding(13, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "escape", keyBinding: new KeyBinding(27), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "selectAll", keyBinding: new KeyBinding('a', true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "toggleTabMode", keyBinding: new KeyBinding('m', true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - if (util.isMac) { - bindings.push({actionID: "deleteNext", keyBinding: new KeyBinding(46, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "deleteWordPrevious", keyBinding: new KeyBinding(8, null, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "deleteWordNext", keyBinding: new KeyBinding(46, null, null, true), predefined: true}); //$NON-NLS-0$ - } - - bindings.push({actionID: "toggleWrapMode", keyBinding: new mKeyBinding.KeyBinding('w', true, false, true)}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "toggleOverwriteMode", keyBinding: new mKeyBinding.KeyBinding(45)}); //$NON-NLS-0$ - - /* - * Feature in IE/Chrome: prevent ctrl+'u', ctrl+'i', and ctrl+'b' from applying styles to the text. - * - * Note that Chrome applies the styles on the Mac with Ctrl instead of Cmd. - */ - if (!util.isFirefox) { - var isMacChrome = util.isMac && util.isChrome; - bindings.push({actionID: "noop", keyBinding: new KeyBinding('u', !isMacChrome, false, false, isMacChrome), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "noop", keyBinding: new KeyBinding('i', !isMacChrome, false, false, isMacChrome), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "noop", keyBinding: new KeyBinding('b', !isMacChrome, false, false, isMacChrome), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + try { + newError.Message = JSON.stringify(error); + } catch (e) { + // best effort - fallthrough + } } + return newError; + } - if (util.isFirefox) { - bindings.push({actionID: "copy", keyBinding: new KeyBinding(45, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "paste", keyBinding: new KeyBinding(45, null, true), predefined: true}); //$NON-NLS-0$ - bindings.push({actionID: "cut", keyBinding: new KeyBinding(46, null, true), predefined: true}); //$NON-NLS-0$ + function handleError(statusService, error) { + if (!statusService) { + window.console.log(error); + return; } - - // Add the emacs Control+ ... key bindings. - if (util.isMac) { - bindings.push({actionID: "lineStart", keyBinding: new KeyBinding("a", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "lineEnd", keyBinding: new KeyBinding("e", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "lineUp", keyBinding: new KeyBinding("p", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "lineDown", keyBinding: new KeyBinding("n", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "charPrevious", keyBinding: new KeyBinding("b", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "charNext", keyBinding: new KeyBinding("f", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "deletePrevious", keyBinding: new KeyBinding("h", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "deleteNext", keyBinding: new KeyBinding("d", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "deleteLineEnd", keyBinding: new KeyBinding("k", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - if (util.isFirefox) { - bindings.push({actionID: "scrollPageDown", keyBinding: new KeyBinding("v", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "deleteLineStart", keyBinding: new KeyBinding("u", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "deleteWordPrevious", keyBinding: new KeyBinding("w", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - } else { - bindings.push({actionID: "pageDown", keyBinding: new KeyBinding("v", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "centerLine", keyBinding: new KeyBinding("l", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - bindings.push({actionID: "enterNoCursor", keyBinding: new KeyBinding("o", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ - //TODO implement: y (yank), t (transpose) - } + if (!error.Severity) { + error = _makeError(error); } - return bindings; - }; + statusService.setProgressResult(error); + return error; + } - return { - KeyMode: KeyMode, - DefaultKeyMode: DefaultKeyMode - }; -}); -/******************************************************************************* - * @license - * Copyright (c) 2013,2014 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Eclipse Public License v1.0 - * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution - * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -/*eslint-env browser, amd*/ -define("orion/editor/textTheme", //$NON-NLS-0$ -[ - 'require', //$NON-NLS-0$ - 'orion/editor/eventTarget', //$NON-NLS-0$ - 'orion/util' //$NON-NLS-0$ -], function(require, mEventTarget, util) { - var THEME_PREFIX = "orion-theme-"; //$NON-NLS-0$ + function decode(contents, charset, done, errorHandler) { + if (window.TextDecoder) { + done(new TextDecoder(charset).decode(contents)); + } else { + var mimeType = 'text/plain; charset=' + charset; //$NON-NLS-0$ + var blob = new Blob([contents], { type: mimeType }); + var reader = new FileReader(); + reader.onload = function() { + done(reader.result); + }.bind(this); + reader.onerror = errorHandler; + reader.readAsText(blob, charset); + } + } - var Themes = {}; - - /** - * Constructs a new text theme. - * - * @class A TextTheme is a class used to specify an editor theme. - * @name orion.editor.TextTheme - * @borrows orion.editor.EventTarget#addEventListener as #addEventListener - * @borrows orion.editor.EventTarget#removeEventListener as #removeEventListener - * @borrows orion.editor.EventTarget#dispatchEvent as #dispatchEvent - */ - function TextTheme(options) { - options = options || {}; - this._document = options.document || document; + var UTF8 = "UTF-8"; //$NON-NLS-0$ + function isUTF8(charset) { + return !charset || charset === UTF8; //$NON-NLS-0$ } /** - * Gets an instance of orion.editor.TextTheme by name. If the name - * paramenter is not speficed the default text theme instance is returned. - * Subsequent calls of getTheme with the same name will return - * the same instance. + * @name orion.editor.InputManager + * @class */ - TextTheme.getTheme = function(name) { - name = name || "default"; //$NON-NLS-0$ - var theme = Themes[name]; - if (!theme) { - theme = Themes[name] = new TextTheme(); + function InputManager(options) { + EventTarget.attach(this); + this.serviceRegistry = options.serviceRegistry; + this.statusService = options.statusService; + this.fileClient = options.fileClient; + this.progressService = options.progressService; + this.contentTypeRegistry = options.contentTypeRegistry; + this.selection = options.selection; + this._input = this._title = ""; + if (this.fileClient) { + this.fileClient.addEventListener("Changed", function(evt) { //$NON-NLS-0$ + if (this._fileMetadata && this._fileMetadata._saving) { + return; + } + if(evt && evt.modified) { + var metadata = this.getFileMetadata(); + if(metadata && metadata.Location) { + if(evt.modified.some(function(loc){ + return metadata.Location === loc; + })) { + //We do not want to set focus on this editor. + //E.g., If a user works on editor A but quick fix could have modified editor B. We should update B's contents but user still want to work on A. + this.load(null, true); + } + } + } + }.bind(this)); } - return theme; - }; - - TextTheme.prototype = /** @lends orion.editor.TextTheme.prototype */ { + } + objects.mixin(InputManager.prototype, /** @lends orion.editor.InputManager.prototype */ { /** - * Returns the theme className. - * - * @see orion.editor.TextTheme#setThemeClass + * @returns {orion.Promise} Promise resolving to the new Location we should use */ - getThemeClass: function() { - return this._themeClass; + _maybeLoadWorkspace: function(resource) { + var fileClient = this.fileClient; + // If it appears to be a workspaceRootURL we cannot load it directly, have to get the workspace first + var root = resource; + if (root.indexOf("?")) root = root.split("?")[0]; + if (root === fileClient.fileServiceRootURL(root)) { + return fileClient.loadWorkspace(root).then(function(workspace) { + return workspace.Location; + }); + } + return new Deferred().resolve(resource); }, /** - * @class This object represents a style sheet for a theme manager. - *

    - * See:
    - * {@link orion.editor.TextTheme#setThemeClass} - *

    - * @name orion.editor.ThemeStyleSheet - * - * @property {String} href The href of the stylesheet - */ - /** - * Sets the theme className and style sheet. - *

    - * If the stylesheet parameter is a string, it represents an inline - * CSS and it will be added to the document as a STYLE tag element. If the - * stylesheet parameter is a orion.editor.ThemeStyleSheet, - * its href property is loaded as either a STYLE tag element or as a LINK - * tag element. - *

    - *

    - * Listeners of the ThemeChanged event are notify once the styled sheet is loaded - * into the document. - *

    - * - * @param {String} className the new theme className. - * @param {String|orion.editor.ThemeStyleSheet} styleSheet the CSS stylesheet for the new theme className. - * - * @see orion.editor.TextTheme#getThemeClass - * @see orion.editor.TextTheme#onThemeChanged + * Wrapper for fileClient.read() that tolerates a filesystem root URL passed as location. If location is indeed + * a filesystem root URL, the original read() operation is instead performed on the workspace. */ - setThemeClass: function(className, styleSheet) { - var self = this; - var oldThemeClass = self._themeClass; - self._themeClass = className; - this._load(className, styleSheet, function() { - self.onThemeChanged({ - type: "ThemeChanged", //$NON-NLS-0$ - oldValue: oldThemeClass, - newValue: self.getThemeClass() - }); + _read: function(loc /**, readArgs*/) { + var cachedMetadata = this.cachedMetadata || mNavigatorRenderer.getClickedItem(); + if (cachedMetadata && cachedMetadata.Location === loc && + cachedMetadata.Parents && cachedMetadata.Attributes && + cachedMetadata.ETag + ) { + return new Deferred().resolve(cachedMetadata); + } + var fileClient = this.fileClient; + var readArgs = Array.prototype.slice.call(arguments, 1); + return this._maybeLoadWorkspace(loc).then(function(newLocation) { + return fileClient.read.apply(fileClient, [newLocation].concat(readArgs)); }); }, - /** - * @class This is the event sent when the theme className or style sheet has changed. - *

    - * See:
    - * {@link orion.editor.TextTheme}
    - * {@link orion.editor.TextTheme#event:onThemeChanged} - *

    - * @name orion.editor.ThemeChangedEvent - * - * @property {String} oldValue The old theme clasName. - * @property {String} newValue The new theme className. - */ - /** - * This event is sent when the theme clasName has changed and its style sheet has been loaded in the document. - * - * @event - * @param {orion.editor.ThemeChangedEvent} themeChangedEvent the event - */ - onThemeChanged: function(themeChangedEvent) { - return this.dispatchEvent(themeChangedEvent); + _isSameParent: function(loc) { + if (this._lastMetadata && this._lastMetadata.Parents && this._lastMetadata.Parents.length > 0) { + var parentLocation = loc.substring(0, loc.lastIndexOf("/", loc.length - (loc[loc.length - 1] === "/" ? 2 : 1)) + 1); + return this._lastMetadata.Parents[0].Location === parentLocation; + } + return false; }, - buildStyleSheet: function(themeClass, settings) { - var convertCSSname = function(name) { - return name.replace(this._capitalRegEx, function(match) { - return "-" + match; //$NON-NLS-0$ - }.bind(this)).toLowerCase(); - }.bind(this); - - var parseStyles = function(object, ancestors, className, isTopLevel, result) { - var localResult = []; - var keys = Object.keys(object); - keys.forEach(function(key) { - var value = object[key]; - if (typeof(value) === "string") { //$NON-NLS-0$ - localResult.push("\t" + convertCSSname(key) + ": " + value + ";"); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ - } else { - parseStyles( - value, - className === key ? ancestors : ancestors + (isTopLevel ? " ." : ".") + key, //$NON-NLS-1$ //$NON-NLS-0$ - className, - false, - result); - } - }); - if (localResult.length) { - result.push(ancestors + (isTopLevel ? ".textview" : "") + " {"); //$NON-NLS-0$ - result.push.apply(result, localResult); - result.push("}"); //$NON-NLS-0$ - } + load: function(charset, nofocus) { + var fileURI = this.getInput(); + if (!fileURI) { return; } + var fileClient = this.fileClient; + var resource = this._parsedLocation.resource; + var progressService = this.progressService; + var progress = function(deferred, msgKey, uri) { + if (!progressService) { return deferred; } + return progressService.progress(deferred, i18nUtil.formatMessage(msgKey, uri)); }; - - var result = [""]; - parseStyles(settings.styles, "." + themeClass, settings.className, true, result); //$NON-NLS-0$ - return result.join("\n"); //$NON-NLS-0$ - }, - - /** - * @private - */ - _createStyle: function(className, styleSheet, callback, link) { - var document = this._document; - var id = THEME_PREFIX + className; - var node = document.getElementById(id); - if (node) { - if (link || node.firstChild.data === styleSheet) { - return; + var editor = this.getEditor(); + if (this._fileMetadata) { + //Reload if out of sync, unless we are already in the process of saving + if (!this._fileMetadata._saving && !this._fileMetadata.Directory && !this.getReadOnly()) { + progress(fileClient.read(resource, true), messages.ReadingMetadata, fileURI).then(function(data) { + if (this._fileMetadata && !this._fileMetadata._saving && this._fileMetadata.Location === data.Location && this._fileMetadata.ETag !== data.ETag) { + this._fileMetadata = objects.mixin(this._fileMetadata, data); + if (!editor.isDirty() || window.confirm(messages.loadOutOfSync)) { + progress(fileClient.read(resource), messages.Reading, fileURI).then(function(contents) { + editor.setInput(fileURI, null, contents, null, nofocus); + this._clearUnsavedChanges(); + }.bind(this)); + } + } + }.bind(this)); } - node.removeChild(node.firstChild); - node.appendChild(document.createTextNode(styleSheet)); } else { - if (link) { - node = util.createElement(document, "link"); //$NON-NLS-0$ - node.rel = "stylesheet"; //$NON-NLS-0$ - node.type = "text/css"; //$NON-NLS-0$ - node.href = styleSheet; - node.addEventListener("load", function() { //$NON-NLS-0$ - callback(); - }); - } else { - node = util.createElement(document, "style"); //$NON-NLS-0$ - node.appendChild(document.createTextNode(styleSheet)); + var progressTimeout = window.setTimeout(function() { + progressTimeout = null; + this.reportStatus(i18nUtil.formatMessage(messages.Fetching, fileURI)); + }.bind(this), 800); + var clearProgressTimeout = function() { + this.reportStatus(""); + if (progressTimeout) { + window.clearTimeout(progressTimeout); + } + }.bind(this); + var errorHandler = function(error) { + clearProgressTimeout(); + var statusService = null; + if(this.serviceRegistry) { + statusService = this.serviceRegistry.getService("orion.page.message"); //$NON-NLS-0$ + } else if(this.statusService) { + statusService = this.statusService; + } + handleError(statusService, error); + this._setNoInput(true); + }.bind(this); + this._acceptPatch = null; + // Read metadata + var metadataURI = resource; + if (!this._isSameParent(metadataURI)) { + var uri = new URL(metadataURI); + uri.query.set("tree", localStorage.useCompressedTree ? "compressed" : "decorated"); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ + metadataURI = uri.href; } - node.id = id; - var head = document.getElementsByTagName("head")[0] || document.documentElement; //$NON-NLS-0$ - head.appendChild(node); - } - if (!link) { - callback(); - } - }, - /** - * @private - */ - _load: function (className, styleSheet, callback) { - if (!className) { - callback(); - return; - } - if (typeof styleSheet === "string") { //$NON-NLS-0$ - this._createStyle(className, styleSheet, callback); - return; - } - var href = styleSheet.href; - var extension = ".css"; //$NON-NLS-0$ - if (href.substring(href.length - extension.length) !== extension) { - href += extension; - } - if (/^\//.test(href) || /[a-zA-Z0-9]+:\/\//i.test(href) || !require.toUrl /* almond cannot load dynamically */) { - this._createStyle(className, href, callback, true); - } else { - var self = this; - require(["text!" + href], function(cssText) { //$NON-NLS-0$ - self._createStyle(className, cssText, callback, false); - }); + progress(this._read(metadataURI, true), messages.ReadingMetadata, resource).then(function(metadata) { + if(!metadata) { + errorHandler({responseText: i18nUtil.formatMessage(messages.ReadingMetadataError, resource)}); + } else if (metadata.Directory) { + // Fetch children + Deferred.when(metadata.Children || progress(fileClient.fetchChildren(metadata.ChildrenLocation), messages.Reading, fileURI), function(contents) { + clearProgressTimeout(); + metadata.Children = contents; + this._setInputContents(this._parsedLocation, fileURI, contents, metadata); + }.bind(this), errorHandler); + } else { + charset = charset || this._charset; + // Read contents if this is a text file and encoding is UTF-8 + var isText = this._isText(metadata); + if (isUTF8(charset) && isText) { + // Read text contents + var defaultReadOptions, textModelFactory = new mTextModelFactory.TextModelFactory(); + //If textModelFactory support additional options for reading text contents, we need to use it. + //An example is to support large file, whose contents is read by segments + if(typeof textModelFactory.getDefaultReadOptions === "function") { + defaultReadOptions = textModelFactory.getDefaultReadOptions(); + } + progress(fileClient.read(resource, false, true, defaultReadOptions), messages.Reading, fileURI).then(function(contents) { + clearProgressTimeout(); + if (typeof contents !== "string") { //$NON-NLS-0$ + this._acceptPatch = contents.acceptPatch; + contents = contents.result; + } + this._setInputContents(this._parsedLocation, fileURI, contents, metadata); + }.bind(this), errorHandler); + } else { + progress(fileClient._getService(resource).readBlob(resource), messages.Reading, fileURI).then(function(contents) { + clearProgressTimeout(); + if (isText) { + decode(contents, charset, function(result) { + this._setInputContents(this._parsedLocation, fileURI, result, metadata); + }.bind(this), errorHandler); + return; + } + this._setInputContents(this._parsedLocation, fileURI, contents, metadata); + }.bind(this), errorHandler); + } + } + }.bind(this), errorHandler); } }, - _capitalRegEx: /[A-Z]/g - }; - mEventTarget.EventTarget.addMixin(TextTheme.prototype); - - return { - TextTheme: TextTheme - }; -}); - -/******************************************************************************* - * @license - * 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 - ******************************************************************************/ - -/*eslint-env browser, amd*/ -define("orion/editor/util", [], function() { //$NON-NLS-0$ - - /** @private */ - function addEventListener(node, type, handler, capture) { - if (typeof node.addEventListener === "function") { //$NON-NLS-0$ - node.addEventListener(type, handler, capture === true); - } else { - node.attachEvent("on" + type, handler); //$NON-NLS-0$ - } - } - /** @private */ - function removeEventListener(node, type, handler, capture) { - if (typeof node.removeEventListener === "function") { //$NON-NLS-0$ - node.removeEventListener(type, handler, capture === true); - } else { - node.detachEvent("on" + type, handler); //$NON-NLS-0$ - } - } - /** @private */ - function contains(topNode, node) { - if (!node) { return false; } - if (!topNode.compareDocumentPosition) { - var temp = node; - while (temp) { - if (topNode === temp) { - return true; - } - temp = temp.parentNode; + processParameters: function(input) { + var editor = this.getEditor(); + if (editor && editor.processParameters) { + return editor.processParameters(input); } return false; - } - return topNode === node || (topNode.compareDocumentPosition(node) & 16) !== 0; - } - /** @private */ - function getNodeStyle(node, prop, defaultValue) { - var value; - if (node) { - value = node.style[prop]; - if (!value) { - if (node.currentStyle) { - var index = 0, p = prop; - while ((index = p.indexOf("-", index)) !== -1) { //$NON-NLS-0$ - p = p.substring(0, index) + p.substring(index + 1, index + 2).toUpperCase() + p.substring(index + 2); - } - value = node.currentStyle[p]; - } else { - var css = node.ownerDocument.defaultView.getComputedStyle(node, null); - value = css ? css.getPropertyValue(prop) : null; - } + }, + getAutoLoadEnabled: function() { + return this._autoLoadEnabled; + }, + getAutoSaveEnabled: function() { + return this._autoSaveEnabled; + }, + getEditor: function() { + return this.editor; + }, + getEncodingCharset: function() { + return this._charset || UTF8; + }, + getInput: function() { + return this._input; + }, + getLocation: function() { + return this._location; + }, + getTitle: function() { + return this._title; + }, + getFileMetadata: function() { + return this._fileMetadata; + }, + isSaveEnabled: function() { + return !this.getReadOnly(); + }, + getReadOnly: function() { + var data = this._fileMetadata; + return this._readonly || !data || (data.Attributes && data.Attributes.ReadOnly); + }, + getContentType: function() { + return this._contentType; + }, + onFocus: function() { + // If there was an error while auto saving, auto save is temporarily disabled and + // we retry saving every time the editor gets focus + if (this._autoSaveEnabled && this._errorSaving) { + this.save(); + return; } - } - return value || defaultValue; - } - - /** - * @class - * @private - * @name orion.editor.Animation - * @description Creates an animation. - * @param {Object} options Options controlling the animation. - * @param {Array} options.curve Array of 2 values giving the start and end points for the animation. - * @param {Number} [options.duration=350] Duration of the animation, in milliseconds. - * @param {Function} [options.easing] - * @param {Function} [options.onAnimate] - * @param {Function} [options.onEnd] - * @param {Number} [options.rate=20] The time between frames, in milliseconds. - */ - var Animation = /** @ignore */ (function() { - function Animation(options) { - this.options = options; - } - /** - * Plays this animation. - * @function - * @memberOf orion.editor.Animation.prototype - * @name play - */ - Animation.prototype.play = function() { - var duration = (typeof this.options.duration === "number") ? this.options.duration : 350, //$NON-NLS-0$ - rate = (typeof this.options.rate === "number") ? this.options.rate : 20, //$NON-NLS-0$ - easing = this.options.easing || this.defaultEasing, - onAnimate = this.options.onAnimate || function() {}, - start = this.options.curve[0], - end = this.options.curve[1], - range = (end - start), - startedAt = -1, - propertyValue, - self = this; - - function onFrame() { - startedAt = (startedAt === -1) ? new Date().getTime() : startedAt; - var now = new Date().getTime(), - percentDone = (now - startedAt) / duration; - if (percentDone < 1) { - var eased = easing(percentDone); - propertyValue = start + (eased * range); - onAnimate(propertyValue); - } else { - onAnimate(end); - self.stop(); - } + if (this._autoLoadEnabled && this._fileMetadata) { + this.load(); } - this.interval = this.options.window.setInterval(onFrame, rate); - }; - /** - * Stops this animation. - * @function - * @memberOf orion.editor.Animation.prototype - */ - Animation.prototype.stop = function() { - this.options.window.clearInterval(this.interval); - var onEnd = this.options.onEnd || function () {}; - onEnd(); - }; - Animation.prototype.defaultEasing = function(x) { - return Math.sin(x * (Math.PI / 2)); - }; - return Animation; - }()); + }, + reportStatus: function(msg) { + if (this.statusReporter) { + this.statusReporter(msg); + } else if (this.editor) { + this.editor.reportStatus(msg); + } + }, + save: function(closing) { + var metadata = this.getFileMetadata(); + if (!metadata) return new Deferred().reject(); + if (metadata._saving) { return metadata._savingDeferred; } + var that = this; + metadata._savingDeferred = new Deferred(); + metadata._saving = true; + function done(result) { + var deferred = metadata._savingDeferred; + deferred.resolve(result); + metadata._savingDeferred = null; + metadata._saving = false; + return deferred; + } + var editor = this.getEditor(); + if (!editor || !editor.isDirty() || this.getReadOnly()) { return done(); } + var failedSaving = this._errorSaving; + var input = this.getInput(); + this.reportStatus(messages['Saving...']); - return { - contains: contains, - getNodeStyle: getNodeStyle, - addEventListener: addEventListener, - removeEventListener: removeEventListener, - Animation: Animation - }; -}); -/******************************************************************************* - * @license - * Copyright (c) 2010, 2015 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 - ******************************************************************************/ + if (!this._saveEventLogged) { + this._logMetrics("save"); //$NON-NLS-0$ + this._saveEventLogged = true; + } -/*eslint-env browser, amd*/ -define("orion/editor/textView", [ //$NON-NLS-1$ - 'i18n!orion/editor/nls/messages', //$NON-NLS-1$ - 'orion/editor/textModel', //$NON-NLS-1$ - 'orion/editor/keyModes', //$NON-NLS-1$ - 'orion/editor/eventTarget', //$NON-NLS-1$ - 'orion/editor/textTheme', //$NON-NLS-1$ - 'orion/editor/util', //$NON-NLS-1$ - 'orion/util', //$NON-NLS-1$ - 'orion/metrics' //$NON-NLS-1$ -], function(messages, mTextModel, mKeyModes, mEventTarget, mTextTheme, textUtil, util, mMetrics) { + this.dispatchEvent({ type: "Saving", inputManager: this}); //$NON-NLS-0$ - /** @private */ - function getWindow(doc) { - return doc.defaultView || doc.parentWindow; - } - function newArray(len) { - return new Array(len); - } - var addHandler = textUtil.addEventListener; - var removeHandler = textUtil.removeEventListener; - /** @private */ - function applyStyle(style, node, reset) { - if (reset) { - node.className = ""; - var attrs = node.attributes; - for (var i= attrs.length; i-->0;) { - if (!util.isIE || util.isIE >= 9 || (util.isIE < 9 && attrs[i].specified)) { - node.removeAttribute(attrs[i].name); + editor.markClean(); + var contents = editor.getText(); + var data = contents; + if (this._getSaveDiffsEnabled() && !this._errorSaving) { + var changes = this._getUnsavedChanges(); + if (changes) { + var len = 0; + for (var i = 0; i < changes.length; i++) { + len += changes[i].text.length; + } + if (contents.length > len) { + data = { + diff: changes + }; + } } } - } - if (!style) { - return; - } - if (style.styleClass) { - node.className = style.styleClass; - } - var properties = style.style; - if (properties) { - for (var s in properties) { - if (properties.hasOwnProperty(s)) { - node.style[s] = properties[s]; - } + this._clearUnsavedChanges(); + this._errorSaving = false; + + var etag = metadata.ETag; + var args = { "ETag" : etag }; //$NON-NLS-0$ + var resource = this._parsedLocation.resource; + var def = this.fileClient.write(resource, data, args); + var progress = this.progressService; + var statusService = null; + if(this.serviceRegistry){ + statusService = this.serviceRegistry.getService("orion.page.message"); //$NON-NLS-0$ } - } - var attributes = style.attributes; - if (attributes) { - for (var a in attributes) { - if (attributes.hasOwnProperty(a)) { - node.setAttribute(a, attributes[a]); - } + if (progress) { + def = progress.progress(def, i18nUtil.formatMessage(messages.savingFile, input)); } - } - } - /** @private */ - function clone(obj) { - /*Note that this code only works because of the limited types used in TextViewOptions */ - if (obj instanceof Array) { - return obj.slice(0); - } - return obj; - } - /** @private */ - function merge(obj1, obj2) { - if (!obj1) { - return obj2; - } - if (!obj2) { - return obj1; - } - for (var p in obj2) { - if (obj2.hasOwnProperty(p)) { - if (!obj1.hasOwnProperty(p)) { - obj1[p] = obj2[p]; + function successHandler(result) { + if (input === that.getInput()) { + metadata.ETag = result.ETag; + editor.setInput(input, null, contents, true); } - } - } - return obj1; - } - /** @private */ - function compare(s1, s2) { - if (s1 === s2) { return true; } - if (s1 && !s2 || !s1 && s2) { return false; } - if ((s1 && s1.constructor === String) || (s2 && s2.constructor === String)) { return false; } - if (s1 instanceof Array || s2 instanceof Array) { - if (!(s1 instanceof Array && s2 instanceof Array)) { return false; } - if (s1.length !== s2.length) { return false; } - for (var i = 0; i < s1.length; i++) { - if (!compare(s1[i], s2[i])) { - return false; + that.reportStatus(""); + if (failedSaving && statusService) { + statusService.setProgressResult({Message:messages.Saved, Severity:"Normal"}); //$NON-NLS-0$ } + if (that.postSave) { + that.postSave(closing); + } + return done(result); } - return true; - } - if (!(s1 instanceof Object) || !(s2 instanceof Object)) { return false; } - var p; - for (p in s1) { - if (s1.hasOwnProperty(p)) { - if (!s2.hasOwnProperty(p)) { return false; } - if (!compare(s1[p], s2[p])) {return false; } - } - } - for (p in s2) { - if (!s1.hasOwnProperty(p)) { return false; } - } - return true; - } - /** @private */ - function convertDelimiter(text, addTextFunc, addDelimiterFunc) { - var cr = 0, lf = 0, index = 0, len = text.length; - while (index < len) { - if (cr !== -1 && cr <= index) { cr = text.indexOf("\r", index); } //$NON-NLS-1$ - if (lf !== -1 && lf <= index) { lf = text.indexOf("\n", index); } //$NON-NLS-1$ - var start = index, end; - if (lf === -1 && cr === -1) { - addTextFunc(text.substring(index)); - break; + function errorHandler(error) { + that.reportStatus(""); + var errorMsg = handleError(statusService, error); + mMetrics.logEvent("status", "exception", (that._autoSaveActive ? "Auto-save: " : "Save: ") + errorMsg.Message); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ + that._errorSaving = true; + return done(); } - if (cr !== -1 && lf !== -1) { - if (cr + 1 === lf) { - end = cr; - index = lf + 1; + def.then(successHandler, function(error) { + // expected error - HTTP 412 Precondition Failed + // occurs when file is out of sync with the server + if (error.status === 412) { + var forceSave = window.confirm(messages.saveOutOfSync); + if (forceSave) { + // repeat save operation, but without ETag + var redef = that.fileClient.write(resource, contents); + if (progress) { + redef = progress.progress(redef, i18nUtil.formatMessage(messages.savingFile, input)); + } + redef.then(successHandler, errorHandler); + } else { + return done(); + } } else { - end = cr < lf ? cr : lf; - index = (cr < lf ? cr : lf) + 1; + // unknown error + errorHandler(error); } - } else if (cr !== -1) { - end = cr; - index = cr + 1; + }); + return metadata._savingDeferred; + }, + setAutoLoadEnabled: function(enabled) { + this._autoLoadEnabled = enabled; + }, + /** + * Set the autosave timeout. If the timeout is -1, autosave is + * disabled. + * @param {Number} timeout - the autosave timeout in milliseconds + */ + setAutoSaveTimeout: function(timeout) { + this._autoSaveEnabled = timeout !== -1; + this._autoSaveActive = false; + if (!this._idle) { + var options = { + document: document, + timeout: timeout + }; + this._idle = new Idle(options); + this._idle.addEventListener("Idle", function () { //$NON-NLS-0$ + if (!this._errorSaving) { + this._autoSaveActive = true; + this.save().then(function() { + this._autoSaveActive = false; + }); + } + }.bind(this)); } else { - end = lf; - index = lf + 1; + this._idle.setTimeout(timeout); } - addTextFunc(text.substring(start, end)); - if (addDelimiterFunc) { - addDelimiterFunc(); - } else { - if (index === len) addTextFunc(""); + }, + setContentType: function(contentType) { + this._contentType = contentType; + }, + setEncodingCharset: function(charset) { + this._charset = charset; + }, + setInput: function(loc) { + if (this._ignoreInput) { return; } + if (!loc) { + loc = PageUtil.hash(); } - } - } - /** @private */ - function getBorder(node) { - var left,_top,right,bottom; - var win = getWindow(node.ownerDocument); - if (win.getComputedStyle) { - var style = win.getComputedStyle(node, null); - left = style.getPropertyValue("border-left-width"); //$NON-NLS-1$ - _top = style.getPropertyValue("border-top-width"); //$NON-NLS-1$ - right = style.getPropertyValue("border-right-width"); //$NON-NLS-1$ - bottom = style.getPropertyValue("border-bottom-width"); //$NON-NLS-1$ - } else if (node.currentStyle) { - left = node.currentStyle.borderLeftWidth; - _top = node.currentStyle.borderTopWidth; - right = node.currentStyle.borderRightWidth; - bottom = node.currentStyle.borderBottomWidth; - } - return { - left: parseInt(left, 10) || 0, - top: parseInt(_top, 10) || 0, - right: parseInt(right, 10) || 0, - bottom: parseInt(bottom, 10) || 0 - }; - } - /** @private */ - function getPadding(node) { - var left,_top,right,bottom; - var win = getWindow(node.ownerDocument); - if (win.getComputedStyle) { - var style = win.getComputedStyle(node, null); - left = style.getPropertyValue("padding-left"); //$NON-NLS-1$ - _top = style.getPropertyValue("padding-top"); //$NON-NLS-1$ - right = style.getPropertyValue("padding-right"); //$NON-NLS-1$ - bottom = style.getPropertyValue("padding-bottom"); //$NON-NLS-1$ - } else if (node.currentStyle) { - left = node.currentStyle.paddingLeft; - _top = node.currentStyle.paddingTop; - right = node.currentStyle.paddingRight; - bottom = node.currentStyle.paddingBottom; - } - return { - left: parseInt(left, 10) || 0, - top: parseInt(_top, 10) || 0, - right: parseInt(right, 10) || 0, - bottom: parseInt(bottom, 10) || 0 - }; - } - /** @private */ - function getLineTrim(line) { - var trim = line._trim; - if (!trim) { - trim = getPadding(line); - var border = getBorder(line); - trim.left += border.left; - trim.top += border.top; - trim.right += border.right; - trim.bottom += border.bottom; - line._trim = trim; - } - return trim; - } - /** @private */ - function DOMReady(doc, _parent, className, callback) { - className = "_" + className + "DOMReady"; //$NON-NLS-1$ //$NON-NLS-1$ - _parent.className = _parent.className ? _parent.className + " " + className : className; //$NON-NLS-1$ - _parent.__DOMReady = callback; - var id = className + "Style"; //$NON-NLS-1$ - if (doc.getElementById(id)) { return; } - var animationName = className + "Animation"; //$NON-NLS-1$ - function insertListener(evt) { - if (evt.animationName === animationName) { - var target = evt.target; - if (typeof target.__DOMReady === "function") { //$NON-NLS-1$ - getWindow(doc).setTimeout(function() { - target.__DOMReady(); - }, 0); + if (typeof loc !== "string") { //$NON-NLS-0$ + return; + } + var editor = this.getEditor(); + if (loc && loc[0] !== "#") { //$NON-NLS-0$ + loc = "#" + loc; //$NON-NLS-0$ + } + var input = PageUtil.matchResourceParameters(loc), oldInput = this._parsedLocation || {}; + var encodingChanged = oldInput.encoding !== input.encoding; + if (editor && editor.isDirty()) { + var oldLocation = this._location; + var oldResource = oldInput.resource; + var newResource = input.resource; + if (oldResource !== newResource || encodingChanged) { + if (this._autoSaveEnabled) { + this.save(); + } else if (!window.confirm(messages.confirmUnsavedChanges)) { + window.location.hash = oldLocation; + return; + } } } - } - function template(className, animationName) { - var props = ["", "-webkit-", "-moz-", "-ms-", "-o-"]; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-4$ - var _frames = "", classRule = "body ." + className + " {\n"; //$NON-NLS-1$ //$NON-NLS-2$ - for (var i=0; i= 0; i--) { - if (selections[i]._editing) return selections[i]; + this._ignoreInput = false; + var evt = { + type: "InputChanging", //$NON-NLS-0$ + input: input + }; + this.dispatchEvent(evt); + function saveSession() { + if (evt.session) { + evt.session.save(); + } } - return selections[selections.length - 1]; - } - for (i = 0; i < selections.length; i++) { - if (selections[i]._editing) return selections[i]; - } - return selections[0]; - }; - /** @private */ - Selection.convert = function(selections) { - if (selections.length === 1) return selections[0]; - return selections; - }; - /** @private */ - Selection.contains = function(selections, offset) { - return selections.some(function(selection) { - return selection.contains(offset); - }); - }; - /** @private */ - Selection.merge = function(selections) { - if (selections.length <= 1) return selections; - selections.sort(function(a, b) { - return a.start - b.start; - }); - var result = []; - var current = selections[0]; - for (var i = 1; i < selections.length; i++) { - if (selections[i].start >= current.end || current._editing || selections[i]._editing) { - result.push(current); - current = selections[i]; + var fileURI = input.resource; + if (evt.metadata) { + saveSession(); + this.reportStatus(""); + this._input = fileURI; + var metadata = evt.metadata; + this._setInputContents(input, fileURI, null, metadata); + return; + } + if (fileURI) { + if (fileURI === this._input && !encodingChanged) { + if (editorChanged) { + this.reportStatus(""); + this._setInputContents(input, fileURI, null, this._fileMetadata, this._isText(this._fileMetadata)); + } else { + if (!this.processParameters(input)) { + if (evt.session) { + evt.session.apply(true); + } + } + } + } else { + saveSession(); + this._input = fileURI; + this._readonly = false; + this._lastMetadata = this._fileMetadata; + this._fileMetadata = null; + this.load(input.encoding); + } } else { - current.end = Math.max(current.end, selections[i].end); + saveSession(); + this._setNoInput(true); } - } - result.push(current); - return result; - }; - Selection.prototype = /** @lends orion.editor.Selection.prototype */ { - /** @private */ - clone: function() { - var result = new Selection(this.start, this.end, this.caret); - result._columnX = this._columnX; - result._editing = this._editing; - result._docX = this._docX; - return result; }, - /** @private */ - contains: function(offset) { - if (this.start <= offset && offset < this.end) { - return true; + setTitle: function(title) { + var indexOfSlash = title.lastIndexOf("/"); //$NON-NLS-0$ + var shortTitle = title; + if (indexOfSlash !== -1) { + shortTitle = shortTitle.substring(indexOfSlash + 1); } - return false; + this._title = shortTitle; }, - /** @private */ - collapse: function() { - if (this.caret) { - this.end = this.start; - } else { - this.start = this.end; + setSaveDiffsEnabled: function(enabled) { + this._saveDiffsEnabled = enabled; + var editor = this.editor; + if (editor && !editor.isDirty()) { + this._clearUnsavedChanges(); } }, - /** @private */ - extend: function (offset) { - if (this.caret) { - this.start = offset; - } else { - this.end = offset; - } - if (this.start > this.end) { - var tmp = this.start; - this.start = this.end; - this.end = tmp; - this.caret = !this.caret; - } + _getSaveDiffsEnabled: function() { + return this._saveDiffsEnabled && this._acceptPatch && this._acceptPatch.indexOf("application/json-patch") !== -1; //$NON-NLS-0$ }, - /** @private */ - setCaret: function(offset) { - this.start = offset; - this.end = offset; - this.caret = false; + _logMetrics: function(type) { + var label = "(none)"; //$NON-NLS-0$ + var contentType = this.getContentType(); + var metadata = this.getFileMetadata(); + if (contentType) { + label = contentType.id; + } else if (metadata) { + var _name = metadata.Name; + var index = _name.lastIndexOf("."); //$NON-NLS-0$ + if (index >= 0) { + label = "unregistered: " + _name.substring(index); //$NON-NLS-0$ + } else { + switch (_name) { + case "AUTHORS": //$NON-NLS-0$ + case "config": //$NON-NLS-0$ + case "LICENSE": //$NON-NLS-0$ + case "make": //$NON-NLS-0$ + case "Makefile": { //$NON-NLS-0$ + label = "unregistered: " + _name; //$NON-NLS-0$ + break; + } + } + } + } + mMetrics.logEvent("editor", type, label, null, {path: metadata.Location}); //$NON-NLS-0$ }, - /** @private */ - getCaret: function() { - return this.caret ? this.start : this.end; + _unknownContentTypeAsText: function() {// Return true if we think unknown content type is text type + return true; }, - /** @private */ - getAnchor: function() { - return this.caret ? this.end : this.start; + _isText: function(metadata) { + var contentType = this.contentTypeRegistry.getFileContentType(metadata); + // Allow unkownn content types to be loaded as text files + if (!contentType) { return this._unknownContentTypeAsText(); } + var textPlain = this.contentTypeRegistry.getContentType("text/plain"); //$NON-NLS-0$ + return this.contentTypeRegistry.isExtensionOf(contentType, textPlain); }, - /** @private */ - getOrientedSelection: function() { - return {start: this.getAnchor(), end: this.getCaret()}; + _setNoInput: function(loadRoot) { + if (loadRoot) { + this.fileClient.loadWorkspace("").then(function(root) { + this._input = root.ChildrenLocation; + this._setInputContents(root.ChildrenLocation, null, root, root); + }.bind(this)); + return; + } + // No input, no editor. + this._input = this._title = this._fileMetadata = null; + this.setContentType(null); + this.dispatchEvent({ type: "InputChanged", input: null }); //$NON-NLS-0$ }, - /** @private */ - toString: function() { - return "start=" + this.start + " end=" + this.end + (this.caret ? " caret is at start" : " caret is at end"); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-4$ + _setInputContents: function(input, title, contents, metadata, noSetInput) { + var _name, isDir = false; + if (metadata) { + this._fileMetadata = metadata; + this.setTitle(metadata.Location || String(metadata)); + this.setContentType(this.contentTypeRegistry.getFileContentType(metadata)); + _name = metadata.Name; + isDir = metadata.Directory; + } else { + // No metadata + this._fileMetadata = null; + this.setTitle(title); + this.setContentType(this.contentTypeRegistry.getFilenameContentType(this.getTitle())); + _name = this.getTitle(); + } + var editor = this.getEditor(); + if (this._focusListener) { + if (editor && editor.getTextView && editor.getTextView()) { + editor.getTextView().removeEventListener("Focus", this._focusListener); //$NON-NLS-0$ + } + this._focusListener = null; + } + var evt = { + type: "InputChanged", //$NON-NLS-0$ + input: input, + name: _name, + title: title, + contentType: this.getContentType(), + metadata: metadata, + location: window.location, + contents: contents + }; + this._logMetrics("open"); //$NON-NLS-0$ + this.dispatchEvent(evt); + this.editor = editor = evt.editor; + if (!isDir) { + if (!noSetInput) { + editor.setInput(title, null, contents); + } + if (editor && editor.getTextView && editor.getTextView()) { + var textView = editor.getTextView(); + textView.addEventListener("Focus", this._focusListener = this.onFocus.bind(this)); //$NON-NLS-0$ + if(editor.getModel() && typeof editor.getModel().setModelData === "function") { + editor.getModel().setModelData({ metadata: metadata}); + } + } + this._clearUnsavedChanges(); + if (!this.processParameters(input)) { + if (evt.session) { + evt.session.apply(); + } + } + } + + this._saveEventLogged = false; + mMetrics.logPageLoadTiming("interactive", window.location.pathname); //$NON-NLS-0$ }, - /** @private */ - isEmpty: function() { - return this.start === this.end; + _getUnsavedChanges: function() { + var editor = this.editor; + if (editor && editor.getUndoStack && editor.getUndoStack()) { + return editor.getUndoStack()._unsavedChanges; + } + return null; }, - /** @private */ - equals: function(object) { - return this.caret === object.caret && this.start === object.start && this.end === object.end && this._editing === object._editing; + _clearUnsavedChanges: function() { + var editor = this.editor; + if (editor && editor.getUndoStack && editor.getUndoStack()) { + editor.getUndoStack()._unsavedChanges = this._getSaveDiffsEnabled() ? [] : null; + } } + }); + return { + handleError: handleError, + InputManager: InputManager }; - /** @private */ - function DOMSelection (view) { - this._view = view; - this._divs = []; - var _parent = view._clipDiv || view._rootDiv; - for (var i=0; i<3; i++) { - var div = view._createSelectionDiv(); - _parent.appendChild(div); - this._divs.push(div); +}); + +/******************************************************************************* + * @license + * 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 + *******************************************************************************/ + +/*eslint-env browser, amd*/ +define("orion/editor/keyModes", [ //$NON-NLS-0$ + "orion/keyBinding", //$NON-NLS-0$ + "orion/util" //$NON-NLS-0$ +], function(mKeyBinding, util) { + + function KeyMode(view) { + if (!view) { + return; } + this._view = view; + this._keyBindings = this.createKeyBindings(); + this._keyBindingIndex = 0; } - DOMSelection.prototype = /** @lends orion.editor.DOMSelection.prototype */ { - /** @private */ - destroy: function() { - if (!this._divs) return; - this._divs.forEach(function(div) { - div.parentNode.removeChild(div); - }); - this._divs = null; - }, - /** @private */ - setPrimary: function(enabled) { - this.primary = enabled; + KeyMode.prototype = /** @lends orion.editor.KeyMode.prototype */ { + createKeyBindings: function () { + return []; }, - /** @private */ - update: function() { - var view = this._view; - var primary = this.primary; - var focused = view._hasFocus; - var visible = view._cursorVisible; - var cursor = !this.primary && this._selection && this._selection.isEmpty(); - var className; - if (cursor) { - className = "textviewSelectionCaret"; //$NON-NLS-1$ - } else { - className = focused ? "textviewSelection" : "textviewSelectionUnfocused"; //$NON-NLS-1$ //$NON-NLS-2$ - } - this._divs[0].style.visibility = (cursor && visible && focused) || !cursor ? "visible" : "hidden"; //$NON-NLS-1$ //$NON-NLS-2$ - this._divs[0].style.zIndex = visible && cursor ? "2" : "0"; //$NON-NLS-1$ //$NON-NLS-2$ - this._divs.forEach(function(div) { - div.className = className; - if (util.isWebkit < 537.36 && primary) { - div.style.background = focused ? "transparent" : ""; //$NON-NLS-1$ + /** + * Returns all the key bindings associated to the given action ID. + * + * @param {String} actionID the action ID. + * @returns {orion.KeyBinding[]} the array of key bindings associated to the given action ID. + * + * @see orion.editor.KeyModesetKeyBinding + * @see orion.editor.KeyModesetAction + */ + getKeyBindings: function (actionID) { + var result = []; + var keyBindings = this._keyBindings; + for (var i = 0; i < keyBindings.length; i++) { + if (keyBindings[i].actionID === actionID) { + result.push(keyBindings[i].keyBinding); } - }); + } + return result; }, - /** @private */ - setSelection: function (selection) { - this._selection = selection; - this.update(); - var view = this._view; - var model = view._model; - var startLine = model.getLineAtOffset(selection.start); - var endLine = model.getLineAtOffset(selection.end); - var firstNode = view._getLineNext(); - /* - * Bug in Firefox. For some reason, after a update page sometimes the - * firstChild returns null incorrectly. The fix is to ignore show selection. - */ - if (!firstNode) { return; } - var lastNode = view._getLinePrevious(); - - var topNode, bottomNode, topOffset, bottomOffset; - if (startLine < firstNode.lineIndex) { - topNode = firstNode; - topOffset = model.getLineStart(firstNode.lineIndex); - } else if (startLine > lastNode.lineIndex) { - topNode = lastNode; - topOffset = model.getLineStart(lastNode.lineIndex); - } else { - topNode = view._getLineNode(startLine); - topOffset = selection.start; + getView: function() { + return this._view; + }, + isActive: function () { + return this._view.getKeyModes().indexOf(this) !== -1; + }, + match: function(e) { + if (e.type === "keydown") { //$NON-NLS-0$ + switch (e.keyCode) { + case 16: /* Shift */ + case 17: /* Control */ + case 18: /* Alt */ + case 91: /* Command */ + return undefined; + } } - - if (endLine < firstNode.lineIndex) { - bottomNode = firstNode; - bottomOffset = model.getLineStart(firstNode.lineIndex); - } else if (endLine > lastNode.lineIndex) { - bottomNode = lastNode; - bottomOffset = model.getLineStart(lastNode.lineIndex); + var keyBindingIndex = this._keyBindingIndex; + var keyBindings = this._matchingKeyBindings || this._keyBindings; + var matchingKeyBindings = []; + for (var i = 0; i < keyBindings.length; i++) { + var kb = keyBindings[i]; + var keyBinding = kb.keyBinding; + var match = keyBinding.match(e, keyBindingIndex); + if (match === true) { + this._keyBindingIndex = 0; + this._matchingKeyBindings = null; + return kb.actionID; + } else if (typeof match === "number") { //$NON-NLS-0$ + matchingKeyBindings.push(kb); + } + } + if (matchingKeyBindings.length === 0) { + this._keyBindingIndex = 0; + this._matchingKeyBindings = null; } else { - bottomNode = view._getLineNode(endLine); - bottomOffset = selection.end; + this._keyBindingIndex++; + this._matchingKeyBindings = matchingKeyBindings; + return "noop"; //$NON-NLS-0$ } - this._setDOMSelection(topNode, topOffset, bottomNode, bottomOffset, selection.caret); + return undefined; }, - /** @private */ - _setDOMSelection: function (startNode, startOffset, endNode, endOffset, startCaret) { - this._setDOMFullSelection(startNode, startOffset, endNode, endOffset); - if (!this.primary) { return; } - var view = this._view; - var start = startNode._line.getNodeOffset(startOffset); - var end = endNode._line.getNodeOffset(endOffset); - if (!start.node || !end.node) return; - var range; - var win = view._getWindow(); - var doc = view._parent.ownerDocument; - if (win.getSelection) { - //W3C - var sel = win.getSelection(); - range = doc.createRange(); - range.setStart(start.node, start.offset); - range.setEnd(end.node, end.offset); - if (view._hasFocus && ( - sel.anchorNode !== start.node || sel.anchorOffset !== start.offset || - sel.focusNode !== end.node || sel.focusOffset !== end.offset || - sel.anchorNode !== end.node || sel.anchorOffset !== end.offset || - sel.focusNode !== start.node || sel.focusOffset !== start.offset)) - { - view._anchorNode = start.node; - view._anchorOffset = start.offset; - view._focusNode = end.node; - view._focusOffset = end.offset; - view._ignoreSelect = false; - if (sel.rangeCount > 0) { sel.removeAllRanges(); } - sel.addRange(range); - view._ignoreSelect = true; - } - if (view._cursorDiv) { - range = doc.createRange(); - if (startCaret) { - range.setStart(start.node, start.offset); - range.setEnd(start.node, start.offset); + /** + * Associates a key binding with the given action ID. Any previous + * association with the specified key binding is overwriten. If the + * action ID is null, the association is removed. + * + * @param {orion.KeyBinding} keyBinding the key binding + * @param {String} actionID the action ID + */ + setKeyBinding: function(keyBinding, actionID) { + var keyBindings = this._keyBindings; + for (var i = 0; i < keyBindings.length; i++) { + var kb = keyBindings[i]; + if (kb.keyBinding.equals(keyBinding)) { + if (actionID) { + kb.actionID = actionID; } else { - range.setStart(end.node, end.offset); - range.setEnd(end.node, end.offset); - } - var rect = range.getClientRects()[0]; - var cursorParent = view._cursorDiv.parentNode; - var clientRect = cursorParent.getBoundingClientRect(); - if (rect && clientRect) { - view._cursorDiv.style.top = (rect.top - clientRect.top + cursorParent.scrollTop) + "px"; //$NON-NLS-1$ - view._cursorDiv.style.left = (rect.left - clientRect.left + cursorParent.scrollLeft) + "px"; //$NON-NLS-1$ + if (kb.predefined) { + kb.actionID = "noop"; //$NON-NLS-0$ + } else { + keyBindings.splice(i, 1); + } } + return; } - } else if (doc.selection) { - if (!view._hasFocus) { return; } - //IE < 9 - var body = doc.body; - - /* - * Bug in IE. For some reason when text is deselected the overflow - * selection at the end of some lines does not get redrawn. The - * fix is to create a DOM element in the body to force a redraw. - */ - var child = util.createElement(doc, "div"); //$NON-NLS-1$ - body.appendChild(child); - body.removeChild(child); - - range = body.createTextRange(); - range.moveToElementText(start.node.parentNode); - range.moveStart("character", start.offset); //$NON-NLS-1$ - var endRange = body.createTextRange(); - endRange.moveToElementText(end.node.parentNode); - endRange.moveStart("character", end.offset); //$NON-NLS-1$ - range.setEndPoint("EndToStart", endRange); //$NON-NLS-1$ - view._ignoreSelect = false; - range.select(); - view._ignoreSelect = true; } - }, - /** @private */ - _setDOMFullSelection: function(startNode, startOffset, endNode, endOffset) { - this._divs.forEach(function(div) { - div.style.width = div.style.height = "0px"; //$NON-NLS-1$ - }); - var view = this._view; - if (!view._fullSelection) { return; } - if (util.isIOS) { return; } - if (startNode === endNode && startOffset === endOffset && this.primary) { return; } - var viewPad = view._getViewPadding(); - var clientRect = view._clientDiv.getBoundingClientRect(); - var viewRect = view._viewDiv.getBoundingClientRect(); - var left = viewRect.left + viewPad.left; - var right = clientRect.right; - var _top = viewRect.top + viewPad.top; - var bottom = clientRect.bottom; - var hd = 0, vd = 0; - if (view._clipDiv) { - var clipRect = view._clipDiv.getBoundingClientRect(); - hd = clipRect.left - view._clipDiv.scrollLeft; - vd = clipRect.top; - } else { - var rootpRect = view._rootDiv.getBoundingClientRect(); - hd = rootpRect.left; - vd = rootpRect.top; + if (actionID) { + keyBindings.push({keyBinding: keyBinding, actionID: actionID}); } - view._ignoreDOMSelection = true; - var startLine = new TextLine(view, startNode.lineIndex, startNode); - var startRect = startLine.getBoundingClientRect(startOffset, false); - var l = startRect.left, endLine, endRect; - if (startNode === endNode && startOffset === endOffset) { - endLine = startLine; - endRect = startRect; - } else { - endLine = new TextLine(view, endNode.lineIndex, endNode); - endRect = endLine.getBoundingClientRect(endOffset, false); + }, + setView: function(view) { + this._view = view; + } + }; + + function DefaultKeyMode(view) { + KeyMode.call(this, view); + } + DefaultKeyMode.prototype = new KeyMode(); + DefaultKeyMode.prototype.createKeyBindings = function () { + var KeyBinding = mKeyBinding.KeyBinding; + //no duplicate keybindings + var bindings = []; + + // Cursor Navigation + bindings.push({actionID: "lineUp", keyBinding: new KeyBinding(38), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "lineDown", keyBinding: new KeyBinding(40), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "charPrevious", keyBinding: new KeyBinding(37), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "charNext", keyBinding: new KeyBinding(39), predefined: true}); //$NON-NLS-0$ + if (util.isMac) { + bindings.push({actionID: "scrollPageUp", keyBinding: new KeyBinding(33), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "scrollPageDown", keyBinding: new KeyBinding(34), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "pageUp", keyBinding: new KeyBinding(33, null, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "pageDown", keyBinding: new KeyBinding(34, null, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "lineStart", keyBinding: new KeyBinding(37, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "lineEnd", keyBinding: new KeyBinding(39, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "wordPrevious", keyBinding: new KeyBinding(37, null, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "wordNext", keyBinding: new KeyBinding(39, null, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "scrollTextStart", keyBinding: new KeyBinding(36), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "scrollTextEnd", keyBinding: new KeyBinding(35), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "textStart", keyBinding: new KeyBinding(38, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "textEnd", keyBinding: new KeyBinding(40, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "scrollPageUp", keyBinding: new KeyBinding(38, null, null, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "scrollPageDown", keyBinding: new KeyBinding(40, null, null, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "lineStart", keyBinding: new KeyBinding(37, null, null, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "lineEnd", keyBinding: new KeyBinding(39, null, null, null, true), predefined: true}); //$NON-NLS-0$ + //TODO These two actions should be changed to paragraph start and paragraph end when word wrap is implemented + bindings.push({actionID: "lineStart", keyBinding: new KeyBinding(38, null, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "lineEnd", keyBinding: new KeyBinding(40, null, null, true), predefined: true}); //$NON-NLS-0$ + } else { + bindings.push({actionID: "pageUp", keyBinding: new KeyBinding(33), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "pageDown", keyBinding: new KeyBinding(34), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "lineStart", keyBinding: new KeyBinding(36), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "lineEnd", keyBinding: new KeyBinding(35), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "wordPrevious", keyBinding: new KeyBinding(37, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "wordNext", keyBinding: new KeyBinding(39, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "textStart", keyBinding: new KeyBinding(36, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "textEnd", keyBinding: new KeyBinding(35, true), predefined: true}); //$NON-NLS-0$ + } + if (util.isFirefox && util.isLinux) { + bindings.push({actionID: "lineUp", keyBinding: new KeyBinding(38, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "lineDown", keyBinding: new KeyBinding(40, true), predefined: true}); //$NON-NLS-0$ + } + if (util.isWindows) { + bindings.push({actionID: "scrollLineUp", keyBinding: new KeyBinding(38, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "scrollLineDown", keyBinding: new KeyBinding(40, true), predefined: true}); //$NON-NLS-0$ + } + + // Select Cursor Navigation + bindings.push({actionID: "selectLineUp", keyBinding: new KeyBinding(38, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectLineDown", keyBinding: new KeyBinding(40, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectCharPrevious", keyBinding: new KeyBinding(37, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectCharNext", keyBinding: new KeyBinding(39, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectPageUp", keyBinding: new KeyBinding(33, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectPageDown", keyBinding: new KeyBinding(34, null, true), predefined: true}); //$NON-NLS-0$ + if (util.isMac) { + bindings.push({actionID: "selectLineStart", keyBinding: new KeyBinding(37, true, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectLineEnd", keyBinding: new KeyBinding(39, true, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectWordPrevious", keyBinding: new KeyBinding(37, null, true, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectWordNext", keyBinding: new KeyBinding(39, null, true, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectTextStart", keyBinding: new KeyBinding(36, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectTextEnd", keyBinding: new KeyBinding(35, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectTextStart", keyBinding: new KeyBinding(38, true, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectTextEnd", keyBinding: new KeyBinding(40, true, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectLineStart", keyBinding: new KeyBinding(37, null, true, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectLineEnd", keyBinding: new KeyBinding(39, null, true, null, true), predefined: true}); //$NON-NLS-0$ + //TODO These two actions should be changed to select paragraph start and select paragraph end when word wrap is implemented + bindings.push({actionID: "selectLineStart", keyBinding: new KeyBinding(38, null, true, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectLineEnd", keyBinding: new KeyBinding(40, null, true, true), predefined: true}); //$NON-NLS-0$ + } else { + if (util.isLinux) { + bindings.push({actionID: "selectWholeLineUp", keyBinding: new KeyBinding(38, true, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectWholeLineDown", keyBinding: new KeyBinding(40, true, true), predefined: true}); //$NON-NLS-0$ } - var r = endRect.left; - view._ignoreDOMSelection = false; - var sel1Div = this._divs[0]; - var sel1Left = Math.min(right, Math.max(left, l)); - var sel1Top = Math.min(bottom, Math.max(_top, startRect.top)); - var sel1Right = right; - var sel1Bottom = Math.min(bottom, Math.max(_top, startRect.bottom)); - sel1Div.style.left = (sel1Left - hd) + "px"; //$NON-NLS-1$ - sel1Div.style.top = (sel1Top - vd) + "px"; //$NON-NLS-1$ - sel1Div.style.width = Math.max(0, sel1Right - sel1Left) + "px"; //$NON-NLS-1$ - sel1Div.style.height = Math.max(0, sel1Bottom - sel1Top) + "px"; //$NON-NLS-1$ - if (startNode.lineIndex === endNode.lineIndex) { - sel1Right = Math.min(r, right); - sel1Div.style.width = Math.max(this.primary ? 0 : 1, sel1Right - sel1Left) + "px"; //$NON-NLS-1$ + bindings.push({actionID: "selectLineStart", keyBinding: new KeyBinding(36, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectLineEnd", keyBinding: new KeyBinding(35, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectWordPrevious", keyBinding: new KeyBinding(37, true, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectWordNext", keyBinding: new KeyBinding(39, true, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectTextStart", keyBinding: new KeyBinding(36, true, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectTextEnd", keyBinding: new KeyBinding(35, true, true), predefined: true}); //$NON-NLS-0$ + } + + //Undo stack + bindings.push({actionID: "undo", keyBinding: new mKeyBinding.KeyBinding('z', true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + if (util.isMac) { + bindings.push({actionID: "redo", keyBinding: new mKeyBinding.KeyBinding('z', true, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + } else { + bindings.push({actionID: "redo", keyBinding: new mKeyBinding.KeyBinding('y', true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + } + + //Misc + bindings.push({actionID: "deletePrevious", keyBinding: new KeyBinding(8), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "deletePrevious", keyBinding: new KeyBinding(8, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "deleteNext", keyBinding: new KeyBinding(46), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "deleteWordPrevious", keyBinding: new KeyBinding(8, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "deleteWordPrevious", keyBinding: new KeyBinding(8, true, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "deleteWordNext", keyBinding: new KeyBinding(46, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "tab", keyBinding: new KeyBinding(9), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "shiftTab", keyBinding: new KeyBinding(9, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "enter", keyBinding: new KeyBinding(13), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "enter", keyBinding: new KeyBinding(13, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "escape", keyBinding: new KeyBinding(27), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "selectAll", keyBinding: new KeyBinding('a', true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "toggleTabMode", keyBinding: new KeyBinding('m', true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + if (util.isMac) { + bindings.push({actionID: "deleteNext", keyBinding: new KeyBinding(46, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "deleteWordPrevious", keyBinding: new KeyBinding(8, null, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "deleteWordNext", keyBinding: new KeyBinding(46, null, null, true), predefined: true}); //$NON-NLS-0$ + } + + bindings.push({actionID: "toggleWrapMode", keyBinding: new mKeyBinding.KeyBinding('w', true, false, true)}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "toggleOverwriteMode", keyBinding: new mKeyBinding.KeyBinding(45)}); //$NON-NLS-0$ + + /* + * Feature in IE/Chrome: prevent ctrl+'u', ctrl+'i', and ctrl+'b' from applying styles to the text. + * + * Note that Chrome applies the styles on the Mac with Ctrl instead of Cmd. + */ + if (!util.isFirefox) { + var isMacChrome = util.isMac && util.isChrome; + bindings.push({actionID: "noop", keyBinding: new KeyBinding('u', !isMacChrome, false, false, isMacChrome), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "noop", keyBinding: new KeyBinding('i', !isMacChrome, false, false, isMacChrome), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "noop", keyBinding: new KeyBinding('b', !isMacChrome, false, false, isMacChrome), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + } + + if (util.isFirefox) { + bindings.push({actionID: "copy", keyBinding: new KeyBinding(45, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "paste", keyBinding: new KeyBinding(45, null, true), predefined: true}); //$NON-NLS-0$ + bindings.push({actionID: "cut", keyBinding: new KeyBinding(46, null, true), predefined: true}); //$NON-NLS-0$ + } + + // Add the emacs Control+ ... key bindings. + if (util.isMac) { + bindings.push({actionID: "lineStart", keyBinding: new KeyBinding("a", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "lineEnd", keyBinding: new KeyBinding("e", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "lineUp", keyBinding: new KeyBinding("p", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "lineDown", keyBinding: new KeyBinding("n", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "charPrevious", keyBinding: new KeyBinding("b", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "charNext", keyBinding: new KeyBinding("f", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "deletePrevious", keyBinding: new KeyBinding("h", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "deleteNext", keyBinding: new KeyBinding("d", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "deleteLineEnd", keyBinding: new KeyBinding("k", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + if (util.isFirefox) { + bindings.push({actionID: "scrollPageDown", keyBinding: new KeyBinding("v", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "deleteLineStart", keyBinding: new KeyBinding("u", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "deleteWordPrevious", keyBinding: new KeyBinding("w", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ } else { - var sel3Left = left; - var sel3Top = Math.min(bottom, Math.max(_top, endRect.top)); - var sel3Right = Math.min(right, Math.max(left, r)); - var sel3Bottom = Math.min(bottom, Math.max(_top, endRect.bottom)); - var sel3Div = this._divs[2]; - sel3Div.style.left = (sel3Left - hd) + "px"; //$NON-NLS-1$ - sel3Div.style.top = (sel3Top - vd) + "px"; //$NON-NLS-1$ - sel3Div.style.width = Math.max(0, sel3Right - sel3Left) + "px"; //$NON-NLS-1$ - sel3Div.style.height = Math.max(0, sel3Bottom - sel3Top) + "px"; //$NON-NLS-1$ - if (Math.abs(startNode.lineIndex - endNode.lineIndex) > 1) { - var sel2Div = this._divs[1]; - sel2Div.style.left = (left - hd) + "px"; //$NON-NLS-1$ - sel2Div.style.top = (sel1Bottom - vd) + "px"; //$NON-NLS-1$ - sel2Div.style.width = Math.max(0, right - left) + "px"; //$NON-NLS-1$ - sel2Div.style.height = Math.max(0, sel3Top - sel1Bottom) + "px"; //$NON-NLS-1$ - } + bindings.push({actionID: "pageDown", keyBinding: new KeyBinding("v", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "centerLine", keyBinding: new KeyBinding("l", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + bindings.push({actionID: "enterNoCursor", keyBinding: new KeyBinding("o", false, false, false, true), predefined: true}); //$NON-NLS-1$ //$NON-NLS-0$ + //TODO implement: y (yank), t (transpose) } } + return bindings; }; - /** @private */ - function TextRect (rect) { - this.left = rect.left; - this.top = rect.top; - this.right = rect.right; - this.bottom = rect.bottom; - } - TextRect.prototype = /** @lends orion.editor.TextRect.prototype */ { - /** @private */ - toString: function() { - return "{l=" + this.left + ", t=" + this.top + ", r=" + this.right + ", b=" + this.bottom + "}"; //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-1$ - } + + return { + KeyMode: KeyMode, + DefaultKeyMode: DefaultKeyMode }; - /** - * Constructs a new TextLine object. +}); +/******************************************************************************* + * @license + * Copyright (c) 2013,2014 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License v1.0 + * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution + * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +/*eslint-env browser, amd*/ +define("orion/editor/textTheme", //$NON-NLS-0$ +[ + 'require', //$NON-NLS-0$ + 'orion/editor/eventTarget', //$NON-NLS-0$ + 'orion/util' //$NON-NLS-0$ +], function(require, mEventTarget, util) { + var THEME_PREFIX = "orion-theme-"; //$NON-NLS-0$ + + var Themes = {}; + + /** + * Constructs a new text theme. * - * @class A TextLine represents a line of text in the view. - * @name orion.editor.TextLine - * @private + * @class A TextTheme is a class used to specify an editor theme. + * @name orion.editor.TextTheme + * @borrows orion.editor.EventTarget#addEventListener as #addEventListener + * @borrows orion.editor.EventTarget#removeEventListener as #removeEventListener + * @borrows orion.editor.EventTarget#dispatchEvent as #dispatchEvent */ - function TextLine (view, lineIndex, lineDiv) { + function TextTheme(options) { + options = options || {}; + this._document = options.document || document; + } + + /** + * Gets an instance of orion.editor.TextTheme by name. If the name + * paramenter is not speficed the default text theme instance is returned. + * Subsequent calls of getTheme with the same name will return + * the same instance. + */ + TextTheme.getTheme = function(name) { + name = name || "default"; //$NON-NLS-0$ + var theme = Themes[name]; + if (!theme) { + theme = Themes[name] = new TextTheme(); + } + return theme; + }; + + TextTheme.prototype = /** @lends orion.editor.TextTheme.prototype */ { /** - * The view. + * Returns the theme className. * - * @name orion.editor.TextLine#view - * @private + * @see orion.editor.TextTheme#setThemeClass */ - this.view = view; + getThemeClass: function() { + return this._themeClass; + }, /** - * The line index. + * @class This object represents a style sheet for a theme manager. + *

    + * See:
    + * {@link orion.editor.TextTheme#setThemeClass} + *

    + * @name orion.editor.ThemeStyleSheet + * + * @property {String} href The href of the stylesheet + */ + /** + * Sets the theme className and style sheet. + *

    + * If the stylesheet parameter is a string, it represents an inline + * CSS and it will be added to the document as a STYLE tag element. If the + * stylesheet parameter is a orion.editor.ThemeStyleSheet, + * its href property is loaded as either a STYLE tag element or as a LINK + * tag element. + *

    + *

    + * Listeners of the ThemeChanged event are notify once the styled sheet is loaded + * into the document. + *

    * - * @name orion.editor.TextLine#lineIndex - * @private + * @param {String} className the new theme className. + * @param {String|orion.editor.ThemeStyleSheet} styleSheet the CSS stylesheet for the new theme className. + * + * @see orion.editor.TextTheme#getThemeClass + * @see orion.editor.TextTheme#onThemeChanged */ - this.lineIndex = lineIndex; - - this._lineDiv = lineDiv; - } - TextLine.prototype = /** @lends orion.editor.TextLine.prototype */ { - /** @private */ - create: function(_parent, div) { - if (this._lineDiv) { return; } - var child = this._lineDiv = this._createLine(_parent, div, this.lineIndex); - child._line = this; - return child; - }, - _createLine: function(_parent, div, lineIndex) { - var view = this.view; - var model = view._model; - var lineText = model.getLine(lineIndex); - var lineStart = model.getLineStart(lineIndex); - var e = {type:"LineStyle", textView: view, lineIndex: lineIndex, lineText: lineText, lineStart: lineStart}; //$NON-NLS-1$ - view.onLineStyle(e); - var doc = _parent.ownerDocument; - var lineDiv = div || util.createElement(doc, "div"); //$NON-NLS-1$ - if (!div || !compare(div.viewStyle, e.style)) { - applyStyle(e.style, lineDiv, div); - if (div) { div._trim = null; } - lineDiv.viewStyle = e.style; - lineDiv.setAttribute("role", "presentation"); //$NON-NLS-1$ //$NON-NLS-2$ - } - lineDiv.lineIndex = lineIndex; - - if (div && lineDiv.viewLineText === lineText && compare(e.ranges, lineDiv.viewRanges)) { - return lineDiv; - } - lineDiv.viewRanges = e.ranges; - lineDiv.viewLineText = lineText; - - var ranges = []; - var data = {tabOffset: 0, ranges: ranges}; - this._createRanges(e.ranges, lineText, 0, lineText.length, lineStart, data); - - /* - * A trailing span with a whitespace is added for three different reasons: - * 1. Make sure the height of each line is the largest of the default font - * in normal, italic, bold, and italic-bold. - * 2. When full selection is off, Firefox, Opera and IE9 do not extend the - * selection at the end of the line when the line is fully selected. - * 3. The height of a div with only an empty span is zero. - */ - var c = " "; //$NON-NLS-1$ - if (!view._fullSelection && util.isIE < 9) { - /* - * IE8 already selects extra space at end of a line fully selected, - * adding another space at the end of the line causes the selection - * to look too big. The fix is to use a zero-width space (\uFEFF) instead. - */ - c = "\uFEFF"; //$NON-NLS-1$ - } - var range = {text: c, style: view._metrics.largestFontStyle, ignoreChars: 1}; - if (ranges.length === 0 || !ranges[ranges.length - 1].style || ranges[ranges.length - 1].style.tagName !== "div") { //$NON-NLS-1$ - ranges.push(range); - } else { - ranges.splice(ranges.length - 1, 0, range); - } - - var span, style, oldSpan, oldStyle, text, oldText, end = 0, oldEnd = 0, next, i; - if (util.isFirefox && lineText.length > 2000) { - if (div) { - lineDiv.innerHTML = ""; - div.lineWidth = undefined; - } - var frag = doc.createDocumentFragment(); - for (i = 0; i < ranges.length; i++) { - range = ranges[i]; - text = range.text; - style = range.style; - span = this._createSpan(lineDiv, text, style, range.ignoreChars); - frag.appendChild(span); - } - lineDiv.appendChild(frag); - } else { - var changeCount, changeStart; - if (div) { - var modelChangedEvent = div.modelChangedEvent; - if (modelChangedEvent) { - if (modelChangedEvent.removedLineCount === 0 && modelChangedEvent.addedLineCount === 0) { - changeStart = modelChangedEvent.start - lineStart; - changeCount = modelChangedEvent.addedCharCount - modelChangedEvent.removedCharCount; - } else { - changeStart = -1; - } - div.modelChangedEvent = undefined; - } - oldSpan = div.firstChild; - } - for (i = 0; i < ranges.length; i++) { - range = ranges[i]; - text = range.text; - end += text.length; - style = range.style; - if (oldSpan) { - oldText = oldSpan.firstChild.data; - oldStyle = oldSpan.viewStyle; - if (oldText === text && compare(style, oldStyle)) { - oldEnd += oldText.length; - oldSpan._rectsCache = undefined; - span = oldSpan = oldSpan.nextSibling; - continue; - } else { - while (oldSpan) { - if (changeStart !== -1) { - var spanEnd = end; - if (spanEnd >= changeStart) { - spanEnd -= changeCount; - } - var t = oldSpan.firstChild.data; - var len = t ? t.length : 0; - if (oldEnd + len > spanEnd) { break; } - oldEnd += len; - } - next = oldSpan.nextSibling; - lineDiv.removeChild(oldSpan); - oldSpan = next; - } - } - } - span = this._createSpan(lineDiv, text, style, range.ignoreChars); - if (oldSpan) { - lineDiv.insertBefore(span, oldSpan); + setThemeClass: function(className, styleSheet) { + var self = this; + var oldThemeClass = self._themeClass; + self._themeClass = className; + this._load(className, styleSheet, function() { + self.onThemeChanged({ + type: "ThemeChanged", //$NON-NLS-0$ + oldValue: oldThemeClass, + newValue: self.getThemeClass() + }); + }); + }, + /** + * @class This is the event sent when the theme className or style sheet has changed. + *

    + * See:
    + * {@link orion.editor.TextTheme}
    + * {@link orion.editor.TextTheme#event:onThemeChanged} + *

    + * @name orion.editor.ThemeChangedEvent + * + * @property {String} oldValue The old theme clasName. + * @property {String} newValue The new theme className. + */ + /** + * This event is sent when the theme clasName has changed and its style sheet has been loaded in the document. + * + * @event + * @param {orion.editor.ThemeChangedEvent} themeChangedEvent the event + */ + onThemeChanged: function(themeChangedEvent) { + return this.dispatchEvent(themeChangedEvent); + }, + buildStyleSheet: function(themeClass, settings) { + var convertCSSname = function(name) { + return name.replace(this._capitalRegEx, function(match) { + return "-" + match; //$NON-NLS-0$ + }.bind(this)).toLowerCase(); + }.bind(this); + + var parseStyles = function(object, ancestors, className, isTopLevel, result) { + var localResult = []; + var keys = Object.keys(object); + keys.forEach(function(key) { + var value = object[key]; + if (typeof(value) === "string") { //$NON-NLS-0$ + localResult.push("\t" + convertCSSname(key) + ": " + value + ";"); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ } else { - lineDiv.appendChild(span); - } - if (div) { - div.lineWidth = undefined; - } - } - if (div) { - var tmp = span ? span.nextSibling : null; - while (tmp) { - next = tmp.nextSibling; - div.removeChild(tmp); - tmp = next; + parseStyles( + value, + className === key ? ancestors : ancestors + (isTopLevel ? " ." : ".") + key, //$NON-NLS-1$ //$NON-NLS-0$ + className, + false, + result); } + }); + if (localResult.length) { + result.push(ancestors + (isTopLevel ? ".textview" : "") + " {"); //$NON-NLS-0$ + result.push.apply(result, localResult); + result.push("}"); //$NON-NLS-0$ } - } - if (!lineDiv.parentNode) { - _parent.appendChild(lineDiv); - } - return lineDiv; + }; + + var result = [""]; + parseStyles(settings.styles, "." + themeClass, settings.className, true, result); //$NON-NLS-0$ + return result.join("\n"); //$NON-NLS-0$ }, - _createRanges: function(ranges, text, start, end, lineStart, data) { - if (start > end) { return; } - if (ranges) { - for (var i = 0; i < ranges.length; i++) { - var range = ranges[i]; - if (range.end < lineStart + start) { continue; } - var styleStart = Math.max(lineStart + start, range.start) - lineStart; - if (styleStart > end) { break; } - var styleEnd = Math.min(lineStart + end, range.end) - lineStart; - if (styleStart <= styleEnd) { - styleStart = Math.max(start, styleStart); - styleEnd = Math.min(end, styleEnd); - if (start < styleStart) { - this._createRange(text, start, styleStart, null, data); - } - if (!range.style || !range.style.unmergeable) { - while (i + 1 < ranges.length && ranges[i + 1].start - lineStart === styleEnd && compare(range.style, ranges[i + 1].style)) { - range = ranges[i + 1]; - styleEnd = Math.min(lineStart + end, range.end) - lineStart; - i++; - } - } - this._createRange(text, styleStart, styleEnd, range.style, data); - start = styleEnd; - } + + /** + * @private + */ + _createStyle: function(className, styleSheet, callback, link) { + var document = this._document; + var id = THEME_PREFIX + className; + var node = document.getElementById(id); + if (node) { + if (link || node.firstChild.data === styleSheet) { + return; } - } - if (start < end) { - this._createRange(text, start, end, null, data); - } - }, - _createRange: function(text, start, end, style, data) { - if (start > end) { return; } - var tabSize = this.view._customTabSize, range; - if (tabSize && tabSize !== 8) { - var tabIndex = text.indexOf("\t", start); //$NON-NLS-1$ - while (tabIndex !== -1 && tabIndex < end) { - if (start < tabIndex) { - range = {text: text.substring(start, tabIndex), style: style}; - data.ranges.push(range); - data.tabOffset += range.text.length; - } - var spacesCount = tabSize - (data.tabOffset % tabSize); - if (spacesCount > 0) { - //TODO hack to preserve tabs in getDOMText() - var spaces = "\u00A0"; //$NON-NLS-1$ - for (var i = 1; i < spacesCount; i++) { - spaces += " "; //$NON-NLS-1$ - } - range = {text: spaces, style: style, ignoreChars: spacesCount - 1}; - data.ranges.push(range); - data.tabOffset += range.text.length; - } - start = tabIndex + 1; - if (start === end) { - return; - } - tabIndex = text.indexOf("\t", start); //$NON-NLS-1$ + node.removeChild(node.firstChild); + node.appendChild(document.createTextNode(styleSheet)); + } else { + if (link) { + node = util.createElement(document, "link"); //$NON-NLS-0$ + node.rel = "stylesheet"; //$NON-NLS-0$ + node.type = "text/css"; //$NON-NLS-0$ + node.href = styleSheet; + node.addEventListener("load", function() { //$NON-NLS-0$ + callback(); + }); + } else { + node = util.createElement(document, "style"); //$NON-NLS-0$ + node.appendChild(document.createTextNode(styleSheet)); } + node.id = id; + var head = document.getElementsByTagName("head")[0] || document.documentElement; //$NON-NLS-0$ + head.appendChild(node); } - if (start <= end) { - range = {text: text.substring(start, end), style: style}; - data.ranges.push(range); - data.tabOffset += range.text.length; + if (!link) { + callback(); } }, - _createSpan: function(_parent, text, style, ignoreChars) { - var view = this.view; - var tagName = "span"; //$NON-NLS-1$ - if (style && style.tagName) { - tagName = style.tagName.toLowerCase(); - } - var isLink = tagName === "a"; //$NON-NLS-1$ - if (isLink) { this.hasLink = true; } - if (isLink && !view._linksVisible) { - tagName = "span"; //$NON-NLS-1$ + /** + * @private + */ + _load: function (className, styleSheet, callback) { + if (!className) { + callback(); + return; } - var doc = _parent.ownerDocument; - var child = util.createElement(_parent.ownerDocument, tagName); - child.appendChild(doc.createTextNode(style && style.text ? style.text : text)); - if (style && style.html) { - child.innerHTML = style.html; - child.ignore = true; - } else if (style && style.node) { - child.appendChild(style.node); - child.ignore = true; + if (typeof styleSheet === "string") { //$NON-NLS-0$ + this._createStyle(className, styleSheet, callback); + return; } - applyStyle(style, child); - if (tagName === "a") { //$NON-NLS-1$ - var win = view._getWindow(); - addHandler(child, "click", function(e) { return view._handleLinkClick(e ? e : win.event); }, false); //$NON-NLS-1$ + var href = styleSheet.href; + var extension = ".css"; //$NON-NLS-0$ + if (href.substring(href.length - extension.length) !== extension) { + href += extension; } - child.viewStyle = style; - if (ignoreChars) { - child.ignoreChars = ignoreChars; + if (/^\//.test(href) || /[a-zA-Z0-9]+:\/\//i.test(href) || !require.toUrl /* almond cannot load dynamically */) { + this._createStyle(className, href, callback, true); + } else { + var self = this; + require(["text!" + href], function(cssText) { //$NON-NLS-0$ + self._createStyle(className, cssText, callback, false); + }); } - return child; - }, - _ensureCreated: function() { - if (this._lineDiv) { return this._lineDiv; } - return (this._createdDiv = this.create(this.view._clientDiv, null)); }, - /** @private */ - getBoundingClientRect: function(offset, absolute) { - var child = this._ensureCreated(); - var view = this.view; - if (offset === undefined) { - return this._getLineBoundingClientRect(child, true); - } - var model = view._model; - var doc = child.ownerDocument; - var lineIndex = this.lineIndex; - var result = null; - if (offset < model.getLineEnd(lineIndex)) { - var lineOffset = model.getLineStart(lineIndex); - this.forEach(function(lineChild) { - var textNode = lineChild.firstChild; - var nodeLength = this._nodeLength(lineChild); - if (lineOffset + nodeLength > offset) { - var index = offset - lineOffset; - var range; - if (textNode.length === 1) { - result = new TextRect(lineChild.getBoundingClientRect()); - } else if (view._isRangeRects) { - range = doc.createRange(); - range.setStart(textNode, index); - range.setEnd(textNode, index + 1); - result = new TextRect(range.getBoundingClientRect()); - } else if (util.isIE) { - range = doc.body.createTextRange(); - range.moveToElementText(lineChild); - range.collapse(); - /* - * Bug in IE8. TextRange.getClientRects() and TextRange.getBoundingClientRect() fails - * if the line child is not the first element in the line and if the start offset is 0. - * The fix is to use Node.getClientRects() left edge instead. - */ - var fixIE8 = index === 0 && util.isIE === 8; - if (fixIE8) { index = 1; } - range.moveEnd("character", index + 1); //$NON-NLS-1$ - range.moveStart("character", index); //$NON-NLS-1$ - result = new TextRect(range.getBoundingClientRect()); - if (fixIE8) { - result.left = lineChild.getClientRects()[0].left; - } - } else { - var text = textNode.data; - lineChild.removeChild(textNode); - lineChild.appendChild(doc.createTextNode(text.substring(0, index))); - var span = util.createElement(doc, "span"); //$NON-NLS-1$ - span.appendChild(doc.createTextNode(text.substring(index, index + 1))); - lineChild.appendChild(span); - lineChild.appendChild(doc.createTextNode(text.substring(index + 1))); - result = new TextRect(span.getBoundingClientRect()); - lineChild.innerHTML = ""; - lineChild.appendChild(textNode); - if (!this._createdDiv) { - /* - * Removing the element node that holds the selection start or end - * causes the selection to be lost. The fix is to detect this case - * and restore the selection. - */ - var s = view._getSelections()[0]; - if ((lineOffset <= s.start && s.start < lineOffset + nodeLength) || (lineOffset <= s.end && s.end < lineOffset + nodeLength)) { - view._updateDOMSelection(); - } - } - } - if (util.isIE < 11) { - var win = getWindow(child.ownerDocument); - var xFactor = win.screen.logicalXDPI / win.screen.deviceXDPI; - var yFactor = win.screen.logicalYDPI / win.screen.deviceYDPI; - result.left = result.left * xFactor; - result.right = result.right * xFactor; - result.top = result.top * yFactor; - result.bottom = result.bottom * yFactor; - } - return false; - } - lineOffset += nodeLength; + _capitalRegEx: /[A-Z]/g + }; + mEventTarget.EventTarget.addMixin(TextTheme.prototype); + + return { + TextTheme: TextTheme + }; +}); + +/******************************************************************************* + * @license + * 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 + ******************************************************************************/ + +/*eslint-env browser, amd*/ +define("orion/editor/util", [], function() { //$NON-NLS-0$ + + /** @private */ + function addEventListener(node, type, handler, capture) { + if (typeof node.addEventListener === "function") { //$NON-NLS-0$ + node.addEventListener(type, handler, capture === true); + } else { + node.attachEvent("on" + type, handler); //$NON-NLS-0$ + } + } + /** @private */ + function removeEventListener(node, type, handler, capture) { + if (typeof node.removeEventListener === "function") { //$NON-NLS-0$ + node.removeEventListener(type, handler, capture === true); + } else { + node.detachEvent("on" + type, handler); //$NON-NLS-0$ + } + } + /** @private */ + function contains(topNode, node) { + if (!node) { return false; } + if (!topNode.compareDocumentPosition) { + var temp = node; + while (temp) { + if (topNode === temp) { return true; - }); - } - var rect = this.getBoundingClientRect(); - if (!result) { - if (view._wrapMode) { - var rects = this.getClientRects(); - result = rects[rects.length - 1]; - result.left = result.right; - result.left += rect.left; - result.top += rect.top; - result.right += rect.left; - result.bottom += rect.top; - } else { - result = new TextRect(rect); - result.left = result.right; } + temp = temp.parentNode; } - if (absolute || absolute === undefined) { - result.left -= rect.left; - result.top -= rect.top; - result.right -= rect.left; - result.bottom -= rect.top; - } - return result; - }, - forEach: function(callback) { - var child = this._ensureCreated(); - var lineChild = child.firstChild; - while (lineChild) { - var next = lineChild.nextSibling; - if (!lineChild.ignore) { - if (!callback.call(this, lineChild)) { - break; + return false; + } + return topNode === node || (topNode.compareDocumentPosition(node) & 16) !== 0; + } + /** @private */ + function getNodeStyle(node, prop, defaultValue) { + var value; + if (node) { + value = node.style[prop]; + if (!value) { + if (node.currentStyle) { + var index = 0, p = prop; + while ((index = p.indexOf("-", index)) !== -1) { //$NON-NLS-0$ + p = p.substring(0, index) + p.substring(index + 1, index + 2).toUpperCase() + p.substring(index + 2); } + value = node.currentStyle[p]; + } else { + var css = node.ownerDocument.defaultView.getComputedStyle(node, null); + value = css ? css.getPropertyValue(prop) : null; } - lineChild = next; } - }, - /** @private */ - _getClientRects: function(element, parentRect) { - var rects, newRects, rect, i; - if (!element._rectsCache) { - rects = element.getClientRects(); - newRects = newArray(rects.length); - for (i = 0; i return ltr + * if bidiLayout is set to rtl > return rtl + * if bidiLayout is set to auto > check for first strong character in text and return ltr or rtl accordingly. + * @param {String} the text on which to set directionality + * @returns {String} text direction. rtl or ltr. + */ + function getTextDirection(text) { + bidiLayout = getBidiLayout(); + if (!bidiEnabled()) { + return ""; + } + if (bidiLayout == 'auto' && util.isIE) { //$NON-NLS-0$ + return checkContextual(text); + } + else { + return bidiLayout; + } + }; + + /** + * Wraps text by UCC (Unicode control characters) according to text direction + * In some cases defining the dir attribute in a different direction than the GUI orientation, + * changes the alignment of the text and/or adjacent elements such as icons. + * This doesn't follow the bidi standards (static text should be aligned following GUI direction). + * Therefore the only solution is to use UCC (Unicode control characters) to display the text in a correct orientation. + * (the text is changed for display purposes only. The original text in the repository remains unchanged) + * @param {String} the text to be wrapped + * @returns {String} text after adding ucc characters. + */ + function enforceTextDirWithUcc ( text ) { + if (bidiEnabled() && text.trim()) { + bidiLayout = getBidiLayout(); + var dir = bidiLayout == 'auto' ? checkContextual( text ) : bidiLayout; //$NON-NLS-0$ + return ( dir == 'ltr' ? LRE : RLE ) + text + PDF; //$NON-NLS-0$ + } + else { + return text; + } + }; + + /** + * Finds the first strong (directional) character. + * If it is Latin, return ltr. If it is bidi, return rtl. Otherwise, return ltr as default. + * @param {String} the text to be examined + * @returns {String} text direction. rtl or ltr. + */ + function checkContextual ( text ) { + // look for strong (directional) characters + var fdc = /[A-Za-z\u05d0-\u065f\u066a-\u06ef\u06fa-\u07ff\ufb1d-\ufdff\ufe70-\ufefc]/.exec( text ); + // if found, return the direction that defined by the character, else return ltr as defult. + return fdc ? ( fdc[0] <= 'z' ? 'ltr' : 'rtl' ) : 'ltr'; //$NON-NLS-0$ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + }; + + function addBidiEventListeners ( input ) { + if (!input._hasBidiEventListeners) { + input._hasBidiEventListeners = true; + + var eventTypes = ['keyup', 'cut', 'paste']; + for (var i = 0; i < eventTypes.length; ++i) { + input.addEventListener(eventTypes[i], handleInputEvent.bind(this), + false); } - return newRects; - }, - getClientRects: function(lineIndex) { - if (!this.view._wrapMode) { return [this.getBoundingClientRect()]; } - var child = this._ensureCreated(); - //TODO [perf] cache rects - var result = []; - var parentRect = child.getBoundingClientRect(); - this.forEach(function(lineChild) { - var rects = this._getClientRects(lineChild, parentRect); - for (var i = 0; i < rects.length; i++) { - var rect = rects[i], j, r; - if (rect.top === rect.bottom) { continue; } - var center = rect.top + (rect.bottom - rect.top) / 2; - for (j = 0; j < result.length; j++) { - r = result[j]; - if ((r.top <= center && center < r.bottom)) { - break; - } - } - if (j === result.length) { - result.push(rect); - } else { - if (rect.left < r.left) { r.left = rect.left; } - if (rect.top < r.top) { r.top = rect.top; } - if (rect.right > r.right) { r.right = rect.right; } - if (rect.bottom > r.bottom) { r.bottom = rect.bottom; } - } + } + }; + + function handleInputEvent ( event ) { + var input = event.target; + if (input) { + input.dir = getTextDirection(input.value || input.textContent); // resolve dir attribute of the element + } + }; + + function initInputField ( input ) { + if (bidiEnabled() && input) { + input.dir = getTextDirection(input.value || input.textContent); // resolve dir attribute of the element + + if (util.isIE) { + addBidiEventListeners(input); + } + } + }; + + return { + bidiEnabled: bidiEnabled, + getTextDirection: getTextDirection, + enforceTextDirWithUcc: enforceTextDirWithUcc, + initInputField: initInputField + }; +}); +/******************************************************************************* + * @license + * Copyright (c) 2010, 2016 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 + ******************************************************************************/ + +/*eslint-env browser, amd*/ +define("orion/editor/textView", [ //$NON-NLS-1$ + 'i18n!orion/editor/nls/messages', //$NON-NLS-1$ + 'orion/editor/textModel', //$NON-NLS-1$ + 'orion/editor/keyModes', //$NON-NLS-1$ + 'orion/editor/eventTarget', //$NON-NLS-1$ + 'orion/editor/textTheme', //$NON-NLS-1$ + 'orion/editor/util', //$NON-NLS-1$ + 'orion/util', //$NON-NLS-1$ + 'orion/bidiUtils', //$NON-NLS-1$ + 'orion/metrics' //$NON-NLS-1$ +], function(messages, mTextModel, mKeyModes, mEventTarget, mTextTheme, textUtil, util, bidiUtils, mMetrics) { + + /** @private */ + function getWindow(doc) { + return doc.defaultView || doc.parentWindow; + } + function newArray(len) { + return new Array(len); + } + var addHandler = textUtil.addEventListener; + var removeHandler = textUtil.removeEventListener; + /** @private */ + function applyStyle(style, node, reset) { + if (reset) { + node.className = ""; + var attrs = node.attributes; + for (var i= attrs.length; i-->0;) { + if (!util.isIE || util.isIE >= 9 || (util.isIE < 9 && attrs[i].specified)) { + node.removeAttribute(attrs[i].name); } - return true; - }); - if (lineIndex !== undefined) { - return result[lineIndex]; } - return result; - }, - /** @private */ - _getLineBoundingClientRect: function (child, noTrim) { - var rect = new TextRect(child.getBoundingClientRect()); - if (this.view._wrapMode) { - } else { - rect.right = rect.left; - var lastChild = child.lastChild; - //Remove any artificial trailing whitespace in the line - while (lastChild && lastChild.ignoreChars === lastChild.firstChild.length) { - lastChild = lastChild.previousSibling; + } + if (!style) { + return; + } + if (style.styleClass) { + node.className = style.styleClass; + } + var properties = style.style; + if (properties) { + for (var s in properties) { + if (properties.hasOwnProperty(s)) { + node.style[s] = properties[s]; } - if (lastChild) { - var lastRect = lastChild.getBoundingClientRect(); - rect.right = lastRect.right + getLineTrim(child).right; + } + } + var attributes = style.attributes; + if (attributes) { + for (var a in attributes) { + if (attributes.hasOwnProperty(a)) { + node.setAttribute(a, attributes[a]); } } - if (noTrim) { - var padding = getLineTrim(child); - rect.left = rect.left + padding.left; - rect.right = rect.right - padding.right; + } + } + /** @private */ + function clone(obj) { + /*Note that this code only works because of the limited types used in TextViewOptions */ + if (obj instanceof Array) { + return obj.slice(0); + } + return obj; + } + /** @private */ + function merge(obj1, obj2) { + if (!obj1) { + return obj2; + } + if (!obj2) { + return obj1; + } + for (var p in obj2) { + if (obj2.hasOwnProperty(p)) { + if (!obj1.hasOwnProperty(p)) { + obj1[p] = obj2[p]; + } } - return rect; - }, - /** @private */ - getLineCount: function () { - if (!this.view._wrapMode) { return 1; } - return this.getClientRects().length; - }, - /** @private */ - getLineIndex: function(offset) { - if (!this.view._wrapMode) { return 0; } - var rects = this.getClientRects(); - var rect = this.getBoundingClientRect(offset); - var center = rect.top + ((rect.bottom - rect.top) / 2); - for (var i = 0; i < rects.length; i++) { - if (rects[i].top <= center && center < rects[i].bottom) { - return i; + } + return obj1; + } + /** @private */ + function compare(s1, s2) { + if (s1 === s2) { return true; } + if (s1 && !s2 || !s1 && s2) { return false; } + if ((s1 && s1.constructor === String) || (s2 && s2.constructor === String)) { return false; } + if (s1 instanceof Array || s2 instanceof Array) { + if (!(s1 instanceof Array && s2 instanceof Array)) { return false; } + if (s1.length !== s2.length) { return false; } + for (var i = 0; i < s1.length; i++) { + if (!compare(s1[i], s2[i])) { + return false; } } - return rects.length - 1; - }, - /** @private */ - getLineStart: function (lineIndex) { - if (!this.view._wrapMode || lineIndex === 0) { - return this.view._model.getLineStart(this.lineIndex); + return true; + } + if (!(s1 instanceof Object) || !(s2 instanceof Object)) { return false; } + var p; + for (p in s1) { + if (s1.hasOwnProperty(p)) { + if (!s2.hasOwnProperty(p)) { return false; } + if (!compare(s1[p], s2[p])) {return false; } } - var rects = this.getClientRects(); - return this.getOffset(rects[lineIndex].left + 1, rects[lineIndex].top + 1); - }, - _nodeLength: function(lineChild) { - if (!lineChild || lineChild.ignore) return 0; - var len = lineChild.firstChild.length; - if (lineChild.ignoreChars) { - len -= lineChild.ignoreChars; + } + for (p in s2) { + if (!s1.hasOwnProperty(p)) { return false; } + } + return true; + } + /** @private */ + function convertDelimiter(text, addTextFunc, addDelimiterFunc) { + var cr = 0, lf = 0, index = 0, len = text.length; + while (index < len) { + if (cr !== -1 && cr <= index) { cr = text.indexOf("\r", index); } //$NON-NLS-1$ + if (lf !== -1 && lf <= index) { lf = text.indexOf("\n", index); } //$NON-NLS-1$ + var start = index, end; + if (lf === -1 && cr === -1) { + addTextFunc(text.substring(index)); + break; } - return len; - }, - getModelOffset: function(node, offset) { - if (!node) { return 0; } - var lineOffset = 0; - this.forEach(function(lineChild) { - var textNode = lineChild.firstChild; - if (textNode === node) { - if (lineChild.ignoreChars) { lineOffset -= lineChild.ignoreChars; } - lineOffset += offset; - return false; - } - if (lineChild.ignoreChars) { lineOffset -= lineChild.ignoreChars; } - lineOffset += textNode.data.length; - return true; - }); - return Math.max(0, lineOffset) + this.view._model.getLineStart(this.lineIndex); - }, - getNodeOffset: function(modelOffset) { - var offset = 0; - var lineNode, lineNodeOffset; - var model = this.view._model; - var lineStart = model.getLineStart(this.lineIndex); - var lineOffset = modelOffset - lineStart; - var end = model.getLineEnd(this.lineIndex) - lineStart; - this.forEach(function(lineChild) { - var node = lineChild.firstChild; - var nodeLength = this._nodeLength(lineChild); - if (nodeLength + offset > lineOffset || offset + nodeLength >= end) { - lineNode = node; - lineNodeOffset = lineOffset - offset; - if (lineChild.ignoreChars && nodeLength > 0 && lineNodeOffset === nodeLength) { - lineNodeOffset += lineChild.ignoreChars; - } - return false; - } - offset += nodeLength; - return true; - }); - return {node: lineNode, offset: lineNodeOffset}; - }, - getText: function(offsetNode) { - var text = "", offset = 0; - this.forEach(function(lineChild) { - var textNode; - if (lineChild.ignoreChars) { - textNode = lineChild.lastChild; - var ignored = 0, childText = [], childOffset = -1; - while (textNode) { - var data = textNode.data; - if (data) { - for (var i = data.length - 1; i >= 0; i--) { - var ch = data.substring(i, i + 1); - if (ignored < lineChild.ignoreChars && (ch === " " || ch === "\uFEFF")) { //$NON-NLS-1$ //$NON-NLS-1$ - ignored++; - } else { - childText.push(ch === "\u00A0" ? "\t" : ch); //$NON-NLS-1$ //$NON-NLS-1$ - } - } - } - if (offsetNode === textNode) { - childOffset = childText.length; - } - textNode = textNode.previousSibling; - } - childText = childText.reverse().join(""); - if (childOffset !== -1) { - offset = text.length + childText.length - childOffset; - } - text += childText; + if (cr !== -1 && lf !== -1) { + if (cr + 1 === lf) { + end = cr; + index = lf + 1; } else { - textNode = lineChild.firstChild; - while (textNode) { - if (offsetNode === textNode) { - offset = text.length; - } - text += textNode.data; - textNode = textNode.nextSibling; - } + end = cr < lf ? cr : lf; + index = (cr < lf ? cr : lf) + 1; } - return true; - }); - return {text: text, offset: offset}; - }, - /** @private */ - getOffset: function(x, y) { - var view = this.view; - var model = view._model; - var lineIndex = this.lineIndex; - var lineStart = model.getLineStart(lineIndex); - var lineEnd = model.getLineEnd(lineIndex); - if (lineStart === lineEnd) { - return lineStart; + } else if (cr !== -1) { + end = cr; + index = cr + 1; + } else { + end = lf; + index = lf + 1; } - var child = this._ensureCreated(); - var lineRect = this.getBoundingClientRect(); - - var that = this; - function hitChild(lineChild, offset, rect) { - var textNode = lineChild.firstChild; - var nodeLength = that._nodeLength(lineChild); - var doc = child.ownerDocument; - var win = getWindow(doc); - var xFactor = util.isIE < 11 ? win.screen.logicalXDPI / win.screen.deviceXDPI : 1; - var yFactor = util.isIE < 11 ? win.screen.logicalYDPI / win.screen.deviceYDPI : 1; - var rangeLeft, rangeTop, rangeRight, rangeBottom; - var range, start, end; - var rl = rect.left + lineRect.left, fixIE8, rects1; - if (util.isIE || view._isRangeRects) { - range = view._isRangeRects ? doc.createRange() : doc.body.createTextRange(); - var high = nodeLength; - var low = -1; - while ((high - low) > 1) { - var mid = Math.floor((high + low) / 2); - start = low + 1; - end = mid === nodeLength - 1 && lineChild.ignoreChars ? textNode.length : mid + 1; - /* - * Bug in IE8. TextRange.getClientRects() and TextRange.getBoundingClientRect() fails - * if the line child is not the first element in the line and if the start offset is 0. - * The fix is to use Node.getClientRects() left edge instead. - */ - fixIE8 = start === 0 && util.isIE === 8; - if (view._isRangeRects) { - range.setStart(textNode, start); - range.setEnd(textNode, end); - } else { - if (fixIE8) { start = 1; } - range.moveToElementText(lineChild); - range.move("character", start); //$NON-NLS-1$ - range.moveEnd("character", end - start); //$NON-NLS-1$ - } - rects1 = range.getClientRects(); - var found = false; - for (var k = 0; k < rects1.length; k++) { - rect = rects1[k]; - rangeLeft = (fixIE8 ? rl : rect.left) * xFactor - lineRect.left; - rangeRight = rect.right * xFactor - lineRect.left; - rangeTop = rect.top * yFactor - lineRect.top; - rangeBottom = rect.bottom * yFactor - lineRect.top; - if (rangeLeft <= x && x < rangeRight && (!view._wrapMode || (rangeTop <= y && y <= rangeBottom))) { - found = true; - break; - } - } - if (found) { - high = mid; - } else { - low = mid; - } - } - offset += high; - start = high; - end = high === nodeLength - 1 && lineChild.ignoreChars ? textNode.length : Math.min(high + 1, textNode.length); - if (view._isRangeRects) { - range.setStart(textNode, start); - range.setEnd(textNode, end); - } else { - range.moveToElementText(lineChild); - range.move("character", start); //$NON-NLS-1$ - range.moveEnd("character", end - start); //$NON-NLS-1$ - } - rects1 = range.getClientRects(); - var trailing = false; - if (rects1.length > 0) { - rect = rects1[0]; - rangeLeft = (fixIE8 ? rl : rect.left) * xFactor - lineRect.left; - rangeRight = rect.right * xFactor - lineRect.left; - //TODO test for character trailing (wrong for bidi) - trailing = x > (rangeLeft + (rangeRight - rangeLeft) / 2); - } - // Handle Unicode surrogates - var offsetInLine = offset - lineStart; - var lineText = model.getLine(lineIndex); - var c = lineText.charCodeAt(offsetInLine); - if (0xD800 <= c && c <= 0xDBFF && trailing) { - if (offsetInLine < lineText.length) { - c = lineText.charCodeAt(offsetInLine + 1); - if (0xDC00 <= c && c <= 0xDFFF) { - offset += 1; - } - } - } else if (0xDC00 <= c && c <= 0xDFFF && !trailing) { - if (offsetInLine > 0) { - c = lineText.charCodeAt(offsetInLine - 1); - if (0xD800 <= c && c <= 0xDBFF) { - offset -= 1; - } - } - } - if (trailing) { - offset++; - } - } else { - var newText = []; - for (var q = 0; q < nodeLength; q++) { - newText.push(""); //$NON-NLS-1$ - if (q === nodeLength - 1) { - newText.push(textNode.data.substring(q)); - } else { - newText.push(textNode.data.substring(q, q + 1)); - } - newText.push(""); //$NON-NLS-1$ - } - lineChild.innerHTML = newText.join(""); - var rangeChild = lineChild.firstChild; - while (rangeChild) { - rect = rangeChild.getBoundingClientRect(); - rangeLeft = rect.left - lineRect.left; - rangeRight = rect.right - lineRect.left; - if (rangeLeft <= x && x < rangeRight) { - //TODO test for character trailing (wrong for bidi) - if (x > rangeLeft + (rangeRight - rangeLeft) / 2) { - offset++; - } - break; - } - offset++; - rangeChild = rangeChild.nextSibling; - } - if (!that._createdDiv) { - lineChild.innerHTML = ""; - lineChild.appendChild(textNode); - /* - * Removing the element node that holds the selection start or end - * causes the selection to be lost. The fix is to detect this case - * and restore the selection. - */ - var s = view._getSelections()[0]; - if ((offset <= s.start && s.start < offset + nodeLength) || (offset <= s.end && s.end < offset + nodeLength)) { - view._updateDOMSelection(); - } - } - } - return offset; - } - - var rects, rect; - if (view._wrapMode) { - rects = this.getClientRects(); - if (y < rects[0].top) { - y = rects[0].top; - } - for (var i = 0; i < rects.length; i++) { - rect = rects[i]; - if (rect.top <= y && y < rect.bottom) { - break; - } - } - if (x < rect.left) { x = rect.left; } - if (x > rect.right) { x = rect.right - 1; } + addTextFunc(text.substring(start, end)); + if (addDelimiterFunc) { + addDelimiterFunc(); } else { - if (x < 0) { x = 0; } - if (x > (lineRect.right - lineRect.left)) { x = lineRect.right - lineRect.left; } - } - - function hitRects(child) { - if (child.ignore) return null; - var rects1 = that._getClientRects(child, lineRect); - for (var j = 0; j < rects1.length; j++) { - var rect1 = rects1[j]; - if (rect1.left <= x && x < rect1.right && (!view._wrapMode || (rect1.top <= y && y <= rect1.bottom))) { - return rect1; - } - } - return null; + if (index === len) addTextFunc(""); } - - var offset, lineChild; - if (this._lastHitChild && this._lastHitChild.parentNode) { - // Search last hit child first, then search around the last hit child - offset = this._lastHitOffset; - lineChild = this._lastHitChild; - rect = hitRects(lineChild); - if (!rect ) { - var previousOffset = offset, nextOffset = offset + this._nodeLength(lineChild); - var previousChild = lineChild.previousSibling, nextChild = lineChild.nextSibling; - while (previousChild || nextChild) { - if (previousChild) { - previousOffset -= this._nodeLength(previousChild); - if ((rect = hitRects(previousChild))) { - lineChild = previousChild; - offset = previousOffset; - break; - } - previousChild = previousChild.previousSibling; - } - if (nextChild) { - if ((rect = hitRects(nextChild))) { - lineChild = nextChild; - offset = nextOffset; - break; - } - nextOffset += this._nodeLength(nextChild); - nextChild = nextChild.nextSibling; - } - } + } + } + /** @private */ + function getBorder(node) { + var left,_top,right,bottom; + var win = getWindow(node.ownerDocument); + if (win.getComputedStyle) { + var style = win.getComputedStyle(node, null); + left = style.getPropertyValue("border-left-width"); //$NON-NLS-1$ + _top = style.getPropertyValue("border-top-width"); //$NON-NLS-1$ + right = style.getPropertyValue("border-right-width"); //$NON-NLS-1$ + bottom = style.getPropertyValue("border-bottom-width"); //$NON-NLS-1$ + } else if (node.currentStyle) { + left = node.currentStyle.borderLeftWidth; + _top = node.currentStyle.borderTopWidth; + right = node.currentStyle.borderRightWidth; + bottom = node.currentStyle.borderBottomWidth; + } + return { + left: parseInt(left, 10) || 0, + top: parseInt(_top, 10) || 0, + right: parseInt(right, 10) || 0, + bottom: parseInt(bottom, 10) || 0 + }; + } + /** @private */ + function getPadding(node) { + var left,_top,right,bottom; + var win = getWindow(node.ownerDocument); + if (win.getComputedStyle) { + var style = win.getComputedStyle(node, null); + left = style.getPropertyValue("padding-left"); //$NON-NLS-1$ + _top = style.getPropertyValue("padding-top"); //$NON-NLS-1$ + right = style.getPropertyValue("padding-right"); //$NON-NLS-1$ + bottom = style.getPropertyValue("padding-bottom"); //$NON-NLS-1$ + } else if (node.currentStyle) { + left = node.currentStyle.paddingLeft; + _top = node.currentStyle.paddingTop; + right = node.currentStyle.paddingRight; + bottom = node.currentStyle.paddingBottom; + } + return { + left: parseInt(left, 10) || 0, + top: parseInt(_top, 10) || 0, + right: parseInt(right, 10) || 0, + bottom: parseInt(bottom, 10) || 0 + }; + } + /** @private */ + function getLineTrim(line) { + var trim = line._trim; + if (!trim) { + trim = getPadding(line); + var border = getBorder(line); + trim.left += border.left; + trim.top += border.top; + trim.right += border.right; + trim.bottom += border.bottom; + line._trim = trim; + } + return trim; + } + /** @private */ + function DOMReady(doc, _parent, className, callback) { + className = "_" + className + "DOMReady"; //$NON-NLS-1$ //$NON-NLS-1$ + _parent.className = _parent.className ? _parent.className + " " + className : className; //$NON-NLS-1$ + _parent.__DOMReady = callback; + var id = className + "Style"; //$NON-NLS-1$ + if (doc.getElementById(id)) { return; } + var animationName = className + "Animation"; //$NON-NLS-1$ + function insertListener(evt) { + if (evt.animationName === animationName) { + var target = evt.target; + if (typeof target.__DOMReady === "function") { //$NON-NLS-1$ + getWindow(doc).setTimeout(function() { + target.__DOMReady(); + }, 0); } - } else { - // Start searching from the beginning of the line - offset = lineStart; - this.forEach(function(c) { - lineChild = c; - if ((rect = hitRects(lineChild))) { - return false; - } - offset += this._nodeLength(lineChild); - return true; - }); } - - if (lineChild && rect) { - // Cache the last hit child - this._lastHitChild = lineChild; - this._lastHitOffset = offset; - - offset = hitChild(lineChild, offset, rect); + } + function template(className, animationName) { + var props = ["", "-webkit-", "-moz-", "-ms-", "-o-"]; //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-4$ + var _frames = "", classRule = "body ." + className + " {\n"; //$NON-NLS-1$ //$NON-NLS-2$ + for (var i=0; i 0) { - data.count--; - return model.getLineEnd(lineIndex); - } - data.count++; - return model.getLineStart(lineIndex); + this.caret = caret; //true if the start, false if the caret is at end + /** @private */ + this._columnX = -1; + } + /** @private */ + Selection.compare = function(s1, s2) { + if (s1.length !== s2.length) return false; + for (var i = 0; i < s1.length; i++) { + if (!s1[i].equals(s2[i])) return false; + } + return true; + }; + Selection.editing = function(selections, back) { + var i; + if (back) { + for (i = selections.length - 1; i >= 0; i--) { + if (selections[i]._editing) return selections[i]; } - if (data.unit === "wordend" || data.unit === "wordWS" || data.unit === "wordendWS") { //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-1$ - return this._getNextOffset_W3C(offset, data); + return selections[selections.length - 1]; + } + for (i = 0; i < selections.length; i++) { + if (selections[i]._editing) return selections[i]; + } + return selections[0]; + }; + /** @private */ + Selection.convert = function(selections) { + if (selections.length === 1) return selections[0]; + return selections; + }; + /** @private */ + Selection.contains = function(selections, offset) { + return selections.some(function(selection) { + return selection.contains(offset); + }); + }; + /** @private */ + Selection.merge = function(selections) { + if (selections.length <= 1) return selections; + selections.sort(function(a, b) { + return a.start - b.start; + }); + var result = []; + var current = selections[0]; + for (var i = 1; i < selections.length; i++) { + if (selections[i].start >= current.end || current._editing || selections[i]._editing) { + result.push(current); + current = selections[i]; + } else { + current.end = Math.max(current.end, selections[i].end); } - return util.isIE ? this._getNextOffset_IE(offset, data) : this._getNextOffset_W3C(offset, data); + } + result.push(current); + return result; + }; + Selection.prototype = /** @lends orion.editor.Selection.prototype */ { + /** @private */ + clone: function() { + var result = new Selection(this.start, this.end, this.caret); + result._columnX = this._columnX; + result._editing = this._editing; + result._docX = this._docX; + return result; }, /** @private */ - _getNextOffset_W3C: function (offset, data) { - function _isPunctuation(c) { - return (33 <= c && c <= 47) || (58 <= c && c <= 64) || (91 <= c && c <= 94) || c === 96 || (123 <= c && c <= 126); - } - function _isWhitespace(c) { - return c === 32 || c === 9; + contains: function(offset) { + if (this.start <= offset && offset < this.end) { + return true; } - var view = this.view; - var model = view._model; - var lineIndex = model.getLineAtOffset(offset); - var lineText = model.getLine(lineIndex); - var lineStart = model.getLineStart(lineIndex); - var lineEnd = model.getLineEnd(lineIndex); - var lineLength = lineText.length; - var offsetInLine = offset - lineStart; - var c; - var step = data.count < 0 ? -1 : 1; - if (data.unit === "word" || data.unit === "wordend" || data.unit === "wordWS" || data.unit === "wordendWS") { //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-1$ - var previousPunctuation, previousLetterOrDigit, punctuation, letterOrDigit; - while (data.count !== 0) { - if (data.count > 0) { - if (offsetInLine === lineLength) { return lineEnd; } - c = lineText.charCodeAt(offsetInLine); - previousPunctuation = _isPunctuation(c); - previousLetterOrDigit = !previousPunctuation && !_isWhitespace(c); - offsetInLine++; - while (offsetInLine < lineLength) { - c = lineText.charCodeAt(offsetInLine); - if (data.unit !== "wordWS" && data.unit !== "wordendWS") { //$NON-NLS-1$ //$NON-NLS-1$ - punctuation = _isPunctuation(c); - if (data.unit === "wordend") { //$NON-NLS-1$ - if (!punctuation && previousPunctuation) { break; } - } else { - if (punctuation && !previousPunctuation) { break; } - } - letterOrDigit = !punctuation && !_isWhitespace(c); - } else { - letterOrDigit = !_isWhitespace(c); - } - if (data.unit === "wordend" || data.unit === "wordendWS") { //$NON-NLS-1$ //$NON-NLS-1$ - if (!letterOrDigit && previousLetterOrDigit) { break; } - } else { - if (letterOrDigit && !previousLetterOrDigit) { break; } - } - previousLetterOrDigit = letterOrDigit; - previousPunctuation = punctuation; - offsetInLine++; - } - } else { - if (offsetInLine === 0) { return lineStart; } - offsetInLine--; - c = lineText.charCodeAt(offsetInLine); - previousPunctuation = _isPunctuation(c); - previousLetterOrDigit = !previousPunctuation && !_isWhitespace(c); - while (0 < offsetInLine) { - c = lineText.charCodeAt(offsetInLine - 1); - if (data.unit !== "wordWS" && data.unit !== "wordendWS") { //$NON-NLS-1$ //$NON-NLS-1$ - punctuation = _isPunctuation(c); - if (data.unit === "wordend") { //$NON-NLS-1$ - if (punctuation && !previousPunctuation) { break; } - } else { - if (!punctuation && previousPunctuation) { break; } - } - letterOrDigit = !punctuation && !_isWhitespace(c); - } else { - letterOrDigit = !_isWhitespace(c); - } - if (data.unit === "wordend" || data.unit === "wordendWS") { //$NON-NLS-1$ //$NON-NLS-1$ - if (letterOrDigit && !previousLetterOrDigit) { break; } - } else { - if (!letterOrDigit && previousLetterOrDigit) { break; } - } - previousLetterOrDigit = letterOrDigit; - previousPunctuation = punctuation; - offsetInLine--; - } - if (offsetInLine === 0) { - //get previous line - } - } - data.count -= step; - } + return false; + }, + /** @private */ + collapse: function() { + if (this.caret) { + this.end = this.start; } else { - while (data.count !== 0 && (0 <= offsetInLine + step && offsetInLine + step <= lineLength)) { - offsetInLine += step; - c = lineText.charCodeAt(offsetInLine); - // Handle Unicode surrogates - if (0xDC00 <= c && c <= 0xDFFF) { - if (offsetInLine > 0) { - c = lineText.charCodeAt(offsetInLine - 1); - if (0xD800 <= c && c <= 0xDBFF) { - offsetInLine += step; - } - } - } - data.count -= step; - } + this.start = this.end; } - return lineStart + offsetInLine; }, /** @private */ - _getNextOffset_IE: function (offset, data) { - var child = this._ensureCreated(); - var view = this.view; - var model = view._model; - var lineIndex = this.lineIndex; - var result = 0, range, len; - var lineOffset = model.getLineStart(lineIndex); - var lineText = model.getLine(lineIndex); - var lineStart = model.getLineStart(lineIndex); - var doc = child.ownerDocument; - var lineChild; - var step = data.count < 0 ? -1 : 1; - if (offset === model.getLineEnd(lineIndex)) { - lineChild = child.lastChild; - while (lineChild && lineChild.ignoreChars === lineChild.firstChild.length) { - lineChild = lineChild.previousSibling; - } - if (!lineChild) { - return lineOffset; - } - range = doc.body.createTextRange(); - range.moveToElementText(lineChild); - len = range.text.length; - range.moveEnd(data.unit, step); - result = offset + range.text.length - len; - } else if (offset === lineOffset && data.count < 0) { - result = lineOffset; + extend: function (offset) { + if (this.caret) { + this.start = offset; } else { - lineChild = child.firstChild; - while (lineChild) { - var nodeLength = this._nodeLength(lineChild); - if (lineOffset + nodeLength > offset) { - range = doc.body.createTextRange(); - if (offset === lineOffset && data.count < 0) { - var temp = lineChild.previousSibling; - // skip empty nodes - while (temp) { - if (temp.firstChild && temp.firstChild.length) { - break; - } - temp = temp.previousSibling; - } - range.moveToElementText(temp ? temp : lineChild.previousSibling); - } else { - range.moveToElementText(lineChild); - range.collapse(); - range.moveEnd("character", offset - lineOffset); //$NON-NLS-1$ - } - len = range.text.length; - range.moveEnd(data.unit, step); - result = offset + range.text.length - len; - break; - } - lineOffset = nodeLength + lineOffset; - lineChild = lineChild.nextSibling; - } + this.end = offset; } - var offsetInLine = result - lineStart; - var c = lineText.charCodeAt(offsetInLine); - // Handle Unicode surrogates - if (0xDC00 <= c && c <= 0xDFFF) { - if (offsetInLine > 0) { - c = lineText.charCodeAt(offsetInLine - 1); - if (0xD800 <= c && c <= 0xDBFF) { - offsetInLine += step; - } - } + if (this.start > this.end) { + var tmp = this.start; + this.start = this.end; + this.end = tmp; + this.caret = !this.caret; } - result = offsetInLine + lineStart; - data.count -= step; - return result; }, - updateLinks: function() { - var child = this._ensureCreated(); - if (!this.hasLink) { return; } - var that = this; - this.forEach(function(span) { - var style = span.viewStyle; - if (style && style.tagName && style.tagName.toLowerCase() === "a") { //$NON-NLS-1$ - child.replaceChild(that._createSpan(child, span.firstChild.data, style), span); - } - return true; - }); + /** @private */ + setCaret: function(offset) { + this.start = offset; + this.end = offset; + this.caret = false; }, /** @private */ - destroy: function() { - var div = this._createdDiv; - if (div) { - div.parentNode.removeChild(div); - this._createdDiv = null; - } + getCaret: function() { + return this.caret ? this.start : this.end; + }, + /** @private */ + getAnchor: function() { + return this.caret ? this.end : this.start; + }, + /** @private */ + getOrientedSelection: function() { + return {start: this.getAnchor(), end: this.getCaret()}; + }, + /** @private */ + toString: function() { + return "start=" + this.start + " end=" + this.end + (this.caret ? " caret is at start" : " caret is at end"); //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-4$ + }, + /** @private */ + isEmpty: function() { + return this.start === this.end; + }, + /** @private */ + equals: function(object) { + return this.caret === object.caret && this.start === object.start && this.end === object.end && this._editing === object._editing; } }; - - /** - * @class This object describes the options for the text view. - *

    - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#setOptions} - * {@link orion.editor.TextView#getOptions} - *

    - * @name orion.editor.TextViewOptions - * - * @property {String|DOMElement} parent the parent element for the view, it can be either a DOM element or an ID for a DOM element. - * @property {orion.editor.TextModel} [model] the text model for the view. If it is not set the view creates an empty {@link orion.editor.TextModel}. - * @property {Boolean} [readonly=false] whether or not the view is read-only. - * @property {Boolean} [fullSelection=true] whether or not the view is in full selection mode. - * @property {Boolean} [tabMode=true] whether or not the tab keypress is consumed by the view or is used for focus traversal. - * @property {Boolean} [expandTab=false] whether or not the tab key inserts white spaces. - * @property {orion.editor.TextTheme} [theme=orion.editor.TextTheme.getTheme()] the TextTheme manager. TODO more info on this - * @property {orion.editor.UndoStack} [undoStack] the Undo Stack. - * @property {String} [themeClass] the CSS class for the view theming. - * @property {Number} [tabSize=8] The number of spaces in a tab. - * @property {Boolean} [overwriteMode=false] whether or not the view is in insert/overwrite mode. - * @property {Boolean} [singleMode=false] whether or not the editor is in single line mode. - * @property {Number} [marginOffset=0] the offset in a line where the print margin should be displayed. 0 means no print margin. - * @property {Number} [wrapOffset=0] the offset in a line where text should wrap. 0 means wrap at the client area right edge. - * @property {Boolean} [wrapMode=false] whether or not the view wraps lines. - * @property {Boolean} [wrapable=false] whether or not the view is wrappable. - * @property {Number} [scrollAnimation=0] the time duration in miliseconds for scrolling animation. 0 means no animation. - * @property {Boolean} [blockCursorVisible=false] whether or not to show the block cursor. - */ - /** - * Constructs a new text view. - * - * @param {orion.editor.TextViewOptions} options the view options. - * - * @class A TextView is a user interface for editing text. - * @name orion.editor.TextView - * @borrows orion.editor.EventTarget#addEventListener as #addEventListener - * @borrows orion.editor.EventTarget#removeEventListener as #removeEventListener - * @borrows orion.editor.EventTarget#dispatchEvent as #dispatchEvent - */ - function TextView (options) { - this._init(options || {}); + /** @private */ + function DOMSelection (view) { + this._view = view; + this._divs = []; + var _parent = view._clipDiv || view._rootDiv; + for (var i=0; i<3; i++) { + var div = view._createSelectionDiv(); + _parent.appendChild(div); + this._divs.push(div); + } } - - TextView.prototype = /** @lends orion.editor.TextView.prototype */ { - /** - * Adds a keyMode to the text view at the specified position. - * - * @param {orion.editor.KeyMode} mode the editor keyMode. - * @param {Number} [index=length] the index. - */ - addKeyMode: function(mode, index) { - var keyModes = this._keyModes; - if (index !== undefined) { - keyModes.splice(index, 0, mode); - } else { - keyModes.push(mode); - } - //TODO: API needed for this - if (mode._modeAdded) { - mode._modeAdded(); - } + DOMSelection.prototype = /** @lends orion.editor.DOMSelection.prototype */ { + /** @private */ + destroy: function() { + if (!this._divs) return; + this._divs.forEach(function(div) { + div.parentNode.removeChild(div); + }); + this._divs = null; }, - /** - * Adds a ruler to the text view at the specified position. - *

    - * The position is relative to the ruler location. - *

    - * - * @param {orion.editor.Ruler} ruler the ruler. - * @param {Number} [index=length] the ruler index. - */ - addRuler: function (ruler, index) { - var rulers = this._rulers; - if (index !== undefined) { - var i, sideIndex; - for (i = 0, sideIndex=0; i < rulers.length && sideIndex < index; i++) { - if (ruler.getLocation() === rulers[i].getLocation()) { - sideIndex++; - } - } - rulers.splice(sideIndex, 0, ruler); - index = sideIndex; + /** @private */ + setPrimary: function(enabled) { + this.primary = enabled; + }, + /** @private */ + update: function() { + var view = this._view; + var primary = this.primary; + var focused = view._hasFocus; + var visible = view._cursorVisible; + var cursor = !this.primary && this._selection && this._selection.isEmpty(); + var className; + if (cursor) { + className = "textviewSelectionCaret"; //$NON-NLS-1$ } else { - rulers.push(ruler); + className = focused ? "textviewSelection" : "textviewSelectionUnfocused"; //$NON-NLS-1$ //$NON-NLS-2$ } - this._createRuler(ruler, index); - ruler.setView(this); - this._update(); + this._divs[0].style.visibility = (cursor && visible && focused) || !cursor ? "visible" : "hidden"; //$NON-NLS-1$ //$NON-NLS-2$ + this._divs[0].style.zIndex = visible && cursor ? "2" : "0"; //$NON-NLS-1$ //$NON-NLS-2$ + this._divs.forEach(function(div) { + div.className = className; + if (util.isWebkit < 537.36 && primary) { + div.style.background = focused ? "transparent" : ""; //$NON-NLS-1$ + } + }); }, - computeSize: function() { - var w = 0, h = 0; - var model = this._model, clientDiv = this._clientDiv; - if (!clientDiv) { return {width: w, height: h}; } - var clientWidth = clientDiv.style.width; + /** @private */ + setSelection: function (selection) { + this._selection = selection; + this.update(); + var view = this._view; + var model = view._model; + var startLine = model.getLineAtOffset(selection.start); + var endLine = model.getLineAtOffset(selection.end); + var firstNode = view._getLineNext(); /* - * Feature in WekKit. Webkit limits the width of the lines - * computed below to the width of the client div. This causes - * the lines to be wrapped even though "pre" is set. The fix - * is to set the width of the client div to a "0x7fffffffpx" - * before computing the lines width. Note that this value is - * reset to the appropriate value further down. + * Bug in Firefox. For some reason, after a update page sometimes the + * firstChild returns null incorrectly. The fix is to ignore show selection. */ - if (util.isWebkit) { - clientDiv.style.width = "0x7fffffffpx"; //$NON-NLS-1$ - } - var lineCount = model.getLineCount(); - for (var lineIndex=0; lineIndex lastNode.lineIndex) { + topNode = lastNode; + topOffset = model.getLineStart(lastNode.lineIndex); + } else { + topNode = view._getLineNode(startLine); + topOffset = selection.start; } - if (util.isWebkit) { - clientDiv.style.width = clientWidth; + + if (endLine < firstNode.lineIndex) { + bottomNode = firstNode; + bottomOffset = model.getLineStart(firstNode.lineIndex); + } else if (endLine > lastNode.lineIndex) { + bottomNode = lastNode; + bottomOffset = model.getLineStart(lastNode.lineIndex); + } else { + bottomNode = view._getLineNode(endLine); + bottomOffset = selection.end; } - var viewPadding = this._getViewPadding(); - w += viewPadding.right + viewPadding.left + this._metrics.scrollWidth; - h += viewPadding.bottom + viewPadding.top + this._metrics.scrollWidth; - return {width: w, height: h}; + this._setDOMSelection(topNode, topOffset, bottomNode, bottomOffset, selection.caret); }, - /** - * Converts the given rectangle from one coordinate spaces to another. - *

    The supported coordinate spaces are: - *

      - *
    • "document" - relative to document, the origin is the top-left corner of first line
    • - *
    • "page" - relative to html page that contains the text view
    • - *
    - *

    - *

    All methods in the view that take or return a position are in the document coordinate space.

    - * - * @param rect the rectangle to convert. - * @param rect.x the x of the rectangle. - * @param rect.y the y of the rectangle. - * @param rect.width the width of the rectangle. - * @param rect.height the height of the rectangle. - * @param {String} from the source coordinate space. - * @param {String} to the destination coordinate space. - * - * @see orion.editor.TextView#getLocationAtOffset - * @see orion.editor.TextView#getOffsetAtLocation - * @see orion.editor.TextView#getTopPixel - * @see orion.editor.TextView#setTopPixel - */ - convert: function(rect, from, to) { - if (!this._clientDiv) { return rect; } - var _scroll = this._getScroll(); - var viewPad = this._getViewPadding(); - var viewRect = this._viewDiv.getBoundingClientRect(); - if (from === "document") { //$NON-NLS-1$ - if (rect.x !== undefined) { - rect.x += - _scroll.x + viewRect.left + viewPad.left; + /** @private */ + _setDOMSelection: function (startNode, startOffset, endNode, endOffset, startCaret) { + this._setDOMFullSelection(startNode, startOffset, endNode, endOffset); + if (!this.primary) { return; } + var view = this._view; + var start = startNode._line.getNodeOffset(startOffset); + var end = endNode._line.getNodeOffset(endOffset); + if (!start.node || !end.node) return; + var range; + var win = view._getWindow(); + var doc = view._parent.ownerDocument; + if (win.getSelection) { + //W3C + var sel = win.getSelection(); + range = doc.createRange(); + range.setStart(start.node, start.offset); + range.setEnd(end.node, end.offset); + if (view._hasFocus && ( + sel.anchorNode !== start.node || sel.anchorOffset !== start.offset || + sel.focusNode !== end.node || sel.focusOffset !== end.offset || + sel.anchorNode !== end.node || sel.anchorOffset !== end.offset || + sel.focusNode !== start.node || sel.focusOffset !== start.offset)) + { + view._anchorNode = start.node; + view._anchorOffset = start.offset; + view._focusNode = end.node; + view._focusOffset = end.offset; + view._ignoreSelect = false; + if (sel.rangeCount > 0) { sel.removeAllRanges(); } + sel.addRange(range); + view._ignoreSelect = true; } - if (rect.y !== undefined) { - rect.y += - _scroll.y + viewRect.top + viewPad.top; + if (view._cursorDiv) { + range = doc.createRange(); + if (startCaret) { + range.setStart(start.node, start.offset); + range.setEnd(start.node, start.offset); + } else { + range.setStart(end.node, end.offset); + range.setEnd(end.node, end.offset); + } + var rect = range.getClientRects()[0]; + var cursorParent = view._cursorDiv.parentNode; + var clientRect = cursorParent.getBoundingClientRect(); + if (rect && clientRect) { + view._cursorDiv.style.top = (rect.top - clientRect.top + cursorParent.scrollTop) + "px"; //$NON-NLS-1$ + view._cursorDiv.style.left = (rect.left - clientRect.left + cursorParent.scrollLeft) + "px"; //$NON-NLS-1$ + } } + } else if (doc.selection) { + if (!view._hasFocus) { return; } + //IE < 9 + var body = doc.body; + + /* + * Bug in IE. For some reason when text is deselected the overflow + * selection at the end of some lines does not get redrawn. The + * fix is to create a DOM element in the body to force a redraw. + */ + var child = util.createElement(doc, "div"); //$NON-NLS-1$ + body.appendChild(child); + body.removeChild(child); + + range = body.createTextRange(); + range.moveToElementText(start.node.parentNode); + range.moveStart("character", start.offset); //$NON-NLS-1$ + var endRange = body.createTextRange(); + endRange.moveToElementText(end.node.parentNode); + endRange.moveStart("character", end.offset); //$NON-NLS-1$ + range.setEndPoint("EndToStart", endRange); //$NON-NLS-1$ + view._ignoreSelect = false; + range.select(); + view._ignoreSelect = true; } - //At this point rect is in the widget coordinate space - if (to === "document") { //$NON-NLS-1$ - if (rect.x !== undefined) { - rect.x += _scroll.x - viewRect.left - viewPad.left; - } - if (rect.y !== undefined) { - rect.y += _scroll.y - viewRect.top - viewPad.top; + }, + /** @private */ + _setDOMFullSelection: function(startNode, startOffset, endNode, endOffset) { + this._divs.forEach(function(div) { + div.style.width = div.style.height = "0px"; //$NON-NLS-1$ + }); + var view = this._view; + if (!view._fullSelection) { return; } + if (util.isIOS) { return; } + if (startNode === endNode && startOffset === endOffset && this.primary) { return; } + var viewPad = view._getViewPadding(); + var clientRect = view._clientDiv.getBoundingClientRect(); + var viewRect = view._viewDiv.getBoundingClientRect(); + var left = viewRect.left + viewPad.left; + var right = clientRect.right; + var _top = viewRect.top + viewPad.top; + var bottom = clientRect.bottom; + var hd = 0, vd = 0; + if (view._clipDiv) { + var clipRect = view._clipDiv.getBoundingClientRect(); + hd = clipRect.left - view._clipDiv.scrollLeft; + vd = clipRect.top; + } else { + var rootpRect = view._rootDiv.getBoundingClientRect(); + hd = rootpRect.left; + vd = rootpRect.top; + } + view._ignoreDOMSelection = true; + var startLine = new TextLine(view, startNode.lineIndex, startNode); + var startRect = startLine.getBoundingClientRect(startOffset, false); + var l = startRect.left, endLine, endRect; + if (startNode === endNode && startOffset === endOffset) { + endLine = startLine; + endRect = startRect; + } else { + endLine = new TextLine(view, endNode.lineIndex, endNode); + endRect = endLine.getBoundingClientRect(endOffset, false); + } + var r = endRect.left; + view._ignoreDOMSelection = false; + var sel1Div = this._divs[0]; + var sel1Left = Math.min(right, Math.max(left, l)); + var sel1Top = Math.min(bottom, Math.max(_top, startRect.top)); + var sel1Right = right; + var sel1Bottom = Math.min(bottom, Math.max(_top, startRect.bottom)); + sel1Div.style.left = (sel1Left - hd) + "px"; //$NON-NLS-1$ + sel1Div.style.top = (sel1Top - vd) + "px"; //$NON-NLS-1$ + sel1Div.style.width = Math.max(0, sel1Right - sel1Left) + "px"; //$NON-NLS-1$ + sel1Div.style.height = Math.max(0, sel1Bottom - sel1Top) + "px"; //$NON-NLS-1$ + if (startNode.lineIndex === endNode.lineIndex) { + sel1Right = Math.min(r, right); + sel1Div.style.width = Math.max(this.primary ? 0 : 1, sel1Right - sel1Left) + "px"; //$NON-NLS-1$ + } else { + var sel3Left = left; + var sel3Top = Math.min(bottom, Math.max(_top, endRect.top)); + var sel3Right = Math.min(right, Math.max(left, r)); + var sel3Bottom = Math.min(bottom, Math.max(_top, endRect.bottom)); + var sel3Div = this._divs[2]; + sel3Div.style.left = (sel3Left - hd) + "px"; //$NON-NLS-1$ + sel3Div.style.top = (sel3Top - vd) + "px"; //$NON-NLS-1$ + sel3Div.style.width = Math.max(0, sel3Right - sel3Left) + "px"; //$NON-NLS-1$ + sel3Div.style.height = Math.max(0, sel3Bottom - sel3Top) + "px"; //$NON-NLS-1$ + if (Math.abs(startNode.lineIndex - endNode.lineIndex) > 1) { + var sel2Div = this._divs[1]; + sel2Div.style.left = (left - hd) + "px"; //$NON-NLS-1$ + sel2Div.style.top = (sel1Bottom - vd) + "px"; //$NON-NLS-1$ + sel2Div.style.width = Math.max(0, right - left) + "px"; //$NON-NLS-1$ + sel2Div.style.height = Math.max(0, sel3Top - sel1Bottom) + "px"; //$NON-NLS-1$ } } - return rect; - }, - /** - * Copies the selected text to the clipboard in plain text format. - * @returns {Boolean} true if the operation succeded. - * @since 10.0 - */ - copy: function() { - if (!this._clientDiv) { return false; } - return this._doCopy(); - }, + } + }; + /** @private */ + function TextRect (rect) { + this.left = rect.left; + this.top = rect.top; + this.right = rect.right; + this.bottom = rect.bottom; + } + TextRect.prototype = /** @lends orion.editor.TextRect.prototype */ { + /** @private */ + toString: function() { + return "{l=" + this.left + ", t=" + this.top + ", r=" + this.right + ", b=" + this.bottom + "}"; //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-1$ + } + }; + /** + * Constructs a new TextLine object. + * + * @class A TextLine represents a line of text in the view. + * @name orion.editor.TextLine + * @private + */ + function TextLine (view, lineIndex, lineDiv) { /** - * Moves the selected text to the clipboard in plain text format. - * @returns {Boolean} true if the operation succeded. - * @since 10.0 + * The view. + * + * @name orion.editor.TextLine#view + * @private */ - cut: function() { - if (!this._clientDiv) { return false; } - return this._doCut(); - }, + this.view = view; /** - * Destroys the text view. - *

    - * Removes the view from the page and frees all resources created by the view. - * Calling this function causes the "Destroy" event to be fire so that all components - * attached to view can release their references. - *

    + * The line index. * - * @see orion.editor.TextView#onDestroy + * @name orion.editor.TextLine#lineIndex + * @private */ - destroy: function() { - /* Destroy rulers*/ - for (var i=0; i< this._rulers.length; i++) { - this._rulers[i].setView(null); + this.lineIndex = lineIndex; + + this._lineDiv = lineDiv; + } + TextLine.prototype = /** @lends orion.editor.TextLine.prototype */ { + /** @private */ + create: function(_parent, div) { + if (this._lineDiv) { return; } + var child = this._lineDiv = this._createLine(_parent, div, this.lineIndex); + child._line = this; + return child; + }, + _createLine: function(_parent, div, lineIndex) { + var view = this.view; + var model = view._model; + var lineText = model.getLine(lineIndex); + var lineStart = model.getLineStart(lineIndex); + var e = {type:"LineStyle", textView: view, lineIndex: lineIndex, lineText: lineText, lineStart: lineStart}; //$NON-NLS-1$ + view.onLineStyle(e); + var doc = _parent.ownerDocument; + var lineDiv = div || util.createElement(doc, "div"); //$NON-NLS-1$ + if (!div || !compare(div.viewStyle, e.style)) { + applyStyle(e.style, lineDiv, div); + if (div) { div._trim = null; } + lineDiv.viewStyle = e.style; } - this.rulers = null; + lineDiv.lineIndex = lineIndex; - this._destroyView(); - - var e = {type: "Destroy"}; //$NON-NLS-1$ - this.onDestroy(e); - - this._parent = null; - if (this._model && this._model.destroy) { - this._model.destroy(); + if (div && lineDiv.viewLineText === lineText && compare(e.ranges, lineDiv.viewRanges)) { + return lineDiv; } - this._model = null; - this._theme = null; - this._selection = null; - this._doubleClickSelection = null; - this._keyModes = null; - this._actions = null; - }, - /** - * Gives focus to the text view. - */ - focus: function() { - if (!this._clientDiv) { return; } - /* - * Feature in Chrome. When focus is called in the clientDiv without - * setting selection the browser will set the selection to the first dom - * element, which can be above the client area. When this happen the - * browser also scrolls the window to show that element. - * The fix is to call _updateDOMSelection() before calling focus(). - */ - this._updateDOMSelection(); - this._clientDiv.focus(); + lineDiv.viewRanges = e.ranges; + lineDiv.viewLineText = lineText; + + var ranges = []; + var data = {tabOffset: 0, ranges: ranges}; + this._createRanges(e.ranges, lineText, 0, lineText.length, lineStart, data); + /* - * Feature in Safari. When focus is called the browser selects the clientDiv - * itself. The fix is to call _updateDOMSelection() after calling focus(). + * A trailing span with a whitespace is added for three different reasons: + * 1. Make sure the height of each line is the largest of the default font + * in normal, italic, bold, and italic-bold. + * 2. When full selection is off, Firefox, Opera and IE9 do not extend the + * selection at the end of the line when the line is fully selected. + * 3. The height of a div with only an empty span is zero. */ - this._updateDOMSelection(); - }, - /** - * Check if the text view has focus. - * - * @returns {Boolean} true if the text view has focus, otherwise false. - */ - hasFocus: function() { - return this._hasFocus; - }, - /** - * Returns the action description for a given action ID. - * - * @returns {orion.editor.ActionDescrition} the action description - */ - getActionDescription: function(actionID) { - var action = this._actions[actionID]; - if (action) { - return action.actionDescription; + var c = " "; //$NON-NLS-1$ + if (!view._fullSelection && util.isIE < 9) { + /* + * IE8 already selects extra space at end of a line fully selected, + * adding another space at the end of the line causes the selection + * to look too big. The fix is to use a zero-width space (\uFEFF) instead. + */ + c = "\uFEFF"; //$NON-NLS-1$ } - return undefined; - }, - /** - * Returns all action IDs defined in the text view. - *

    - * There are two types of actions, the predefined actions of the view - * and the actions added by application code. - *

    - *

    - * The predefined actions are: - *

      - *
    • Navigation actions. These actions move the caret collapsing the selection.
    • - *
        - *
      • "lineUp" - moves the caret up by one line
      • - *
      • "lineDown" - moves the caret down by one line
      • - *
      • "lineStart" - moves the caret to beginning of the current line
      • - *
      • "lineEnd" - moves the caret to end of the current line
      • - *
      • "charPrevious" - moves the caret to the previous character
      • - *
      • "charNext" - moves the caret to the next character
      • - *
      • "pageUp" - moves the caret up by one page
      • - *
      • "pageDown" - moves the caret down by one page
      • - *
      • "wordPrevious" - moves the caret to the previous word
      • - *
      • "wordNext" - moves the caret to the next word
      • - *
      • "textStart" - moves the caret to the beginning of the document
      • - *
      • "textEnd" - moves the caret to the end of the document
      • - *
      - *
    • Selection actions. These actions move the caret extending the selection.
    • - *
        - *
      • "selectLineUp" - moves the caret up by one line
      • - *
      • "selectLineDown" - moves the caret down by one line
      • - *
      • "selectLineStart" - moves the caret to beginning of the current line
      • - *
      • "selectLineEnd" - moves the caret to end of the current line
      • - *
      • "selectCharPrevious" - moves the caret to the previous character
      • - *
      • "selectCharNext" - moves the caret to the next character
      • - *
      • "selectPageUp" - moves the caret up by one page
      • - *
      • "selectPageDown" - moves the caret down by one page
      • - *
      • "selectWordPrevious" - moves the caret to the previous word
      • - *
      • "selectWordNext" - moves the caret to the next word
      • - *
      • "selectTextStart" - moves the caret to the beginning of the document
      • - *
      • "selectTextEnd" - moves the caret to the end of the document
      • - *
      • "selectAll" - selects the entire document
      • - *
      - *
    • Edit actions. These actions modify the text view text
    • - *
        - *
      • "deletePrevious" - deletes the character preceding the caret
      • - *
      • "deleteNext" - deletes the charecter following the caret
      • - *
      • "deleteWordPrevious" - deletes the word preceding the caret
      • - *
      • "deleteWordNext" - deletes the word following the caret
      • - *
      • "deleteLineStart" - deletes characteres to the beginning of the line
      • - *
      • "deleteLineEnd" - deletes characteres to the end of the line
      • - *
      • "tab" - inserts a tab character at the caret
      • - *
      • "shiftTab" - noop
      • - *
      • "enter" - inserts a line delimiter at the caret
      • - *
      • "uppercase" - upper case the text at the caret
      • - *
      • "lowercase" - lower case the text at the caret
      • - *
      • "capitalize" - capitilize case the text at the caret
      • - *
      • "reversecase" - reverse the case the text at the caret
      • - *
      - *
    • Clipboard actions. These actions modify the view text as well
    • - *
        - *
      • "copy" - copies the selected text to the clipboard
      • - *
      • "cut" - copies the selected text to the clipboard and deletes the selection
      • - *
      • "paste" - replaces the selected text with the clipboard contents
      • - *
      - *
    • Scrolling actions.
    • - *
        - *
      • "scrollLineUp" - scrolls the view up by one line
      • - *
      • "scrollLineDown" - scrolls the view down by one line
      • - *
      • "scrollPageUp" - scrolls the view up by one page
      • - *
      • "scrollPageDown" - scrolls the view down by one page
      • - *
      • "scrollTextStart" - scrolls the view to the beginning of the document
      • - *
      • "scrollTextEnd" - scrolls the view to the end of the document
      • - *
      - *
    • Mode actions.
    • - *
        - *
      • "toggleTabMode" - toggles tab mode.
      • - *
      • "toggleWrapMode" - toggles wrap mode.
      • - *
      • "toggleOverwriteMode" - toggles overwrite mode.
      • - *
      - *
    - *

    - * - * @param {Boolean} [defaultAction=false] whether or not the predefined actions are included. - * @returns {String[]} an array of action IDs defined in the text view. - * - * @see orion.editor.TextView#invokeAction - * @see orion.editor.TextView#setAction - * @see orion.editor.TextView#setKeyBinding - * @see orion.editor.TextView#getKeyBindings - */ - getActions: function (defaultAction) { - var result = []; - var actions = this._actions; - for (var i in actions) { - if (actions.hasOwnProperty(i)) { - if (!defaultAction && actions[i].defaultHandler) { continue; } - result.push(i); + var range = {text: c, style: view._metrics.largestFontStyle, ignoreChars: 1}; + if (ranges.length === 0 || !ranges[ranges.length - 1].style || ranges[ranges.length - 1].style.tagName !== "div") { //$NON-NLS-1$ + ranges.push(range); + } else { + ranges.splice(ranges.length - 1, 0, range); + } + + var span, style, oldSpan, oldStyle, text, oldText, end = 0, oldEnd = 0, next, i; + if (util.isFirefox && lineText.length > 2000) { + if (div) { + lineDiv.innerHTML = ""; + div.lineWidth = undefined; + } + var frag = doc.createDocumentFragment(); + for (i = 0; i < ranges.length; i++) { + range = ranges[i]; + text = range.text; + style = range.style; + span = this._createSpan(lineDiv, text, style, range.ignoreChars); + frag.appendChild(span); + } + lineDiv.appendChild(frag); + } else { + var changeCount, changeStart; + if (div) { + var modelChangedEvent = div.modelChangedEvent; + if (modelChangedEvent) { + if (modelChangedEvent.removedLineCount === 0 && modelChangedEvent.addedLineCount === 0) { + changeStart = modelChangedEvent.start - lineStart; + changeCount = modelChangedEvent.addedCharCount - modelChangedEvent.removedCharCount; + } else { + changeStart = -1; + } + div.modelChangedEvent = undefined; + } + oldSpan = div.firstChild; + } + for (i = 0; i < ranges.length; i++) { + range = ranges[i]; + text = range.text; + end += text.length; + style = range.style; + if (oldSpan) { + oldText = oldSpan.firstChild.data; + oldStyle = oldSpan.viewStyle; + if (oldText === text && compare(style, oldStyle)) { + oldEnd += oldText.length; + oldSpan._rectsCache = undefined; + span = oldSpan = oldSpan.nextSibling; + continue; + } else { + while (oldSpan) { + if (changeStart !== -1) { + var spanEnd = end; + if (spanEnd >= changeStart) { + spanEnd -= changeCount; + } + var t = oldSpan.firstChild.data; + var len = t ? t.length : 0; + if (oldEnd + len > spanEnd) { break; } + oldEnd += len; + } + next = oldSpan.nextSibling; + lineDiv.removeChild(oldSpan); + oldSpan = next; + } + } + } + span = this._createSpan(lineDiv, text, style, range.ignoreChars); + if (oldSpan) { + lineDiv.insertBefore(span, oldSpan); + } else { + lineDiv.appendChild(span); + } + if (div) { + div.lineWidth = undefined; + } + } + if (div) { + var tmp = span ? span.nextSibling : null; + while (tmp) { + next = tmp.nextSibling; + div.removeChild(tmp); + tmp = next; + } } } - return result; - }, - /** - * Returns the bottom index. - *

    - * The bottom index is the line that is currently at the bottom of the view. This - * line may be partially visible depending on the vertical scroll of the view. The parameter - * fullyVisible determines whether to return only fully visible lines. - *

    - * - * @param {Boolean} [fullyVisible=false] if true, returns the index of the last fully visible line. This - * parameter is ignored if the view is not big enough to show one line. - * @returns {Number} the index of the bottom line. - * - * @see orion.editor.TextView#getTopIndex - * @see orion.editor.TextView#setTopIndex - */ - getBottomIndex: function(fullyVisible) { - if (!this._clientDiv) { return 0; } - return this._getBottomIndex(fullyVisible); - }, - /** - * Returns the bottom pixel. - *

    - * The bottom pixel is the pixel position that is currently at - * the bottom edge of the view. This position is relative to the - * beginning of the document. - *

    - * - * @returns {Number} the bottom pixel. - * - * @see orion.editor.TextView#getTopPixel - * @see orion.editor.TextView#setTopPixel - * @see orion.editor.TextView#convert - */ - getBottomPixel: function() { - if (!this._clientDiv) { return 0; } - return this._getScroll().y + this._getClientHeight(); - }, - /** - * Returns the caret offset relative to the start of the document. - * - * @returns {Number} the caret offset relative to the start of the document. - * - * @see orion.editor.TextView#setCaretOffset - * @see orion.editor.TextView#setSelection - * @see orion.editor.TextView#getSelection - */ - getCaretOffset: function () { - var s = this._getSelection(); - return s.getCaret(); - }, - /** - * Returns the client area. - *

    - * The client area is the portion in pixels of the document that is visible. The - * client area position is relative to the beginning of the document. - *

    - * - * @returns {Object} the client area rectangle {x, y, width, height}. - * - * @see orion.editor.TextView#getTopPixel - * @see orion.editor.TextView#getBottomPixel - * @see orion.editor.TextView#getHorizontalPixel - * @see orion.editor.TextView#convert - */ - getClientArea: function() { - if (!this._clientDiv) { return {x: 0, y: 0, width: 0, height: 0}; } - var _scroll = this._getScroll(); - return {x: _scroll.x, y: _scroll.y, width: this._getClientWidth(), height: this._getClientHeight()}; + if (!lineDiv.parentNode) { + _parent.appendChild(lineDiv); + } + return lineDiv; }, - /** - * Returns the horizontal pixel. - *

    - * The horizontal pixel is the pixel position that is currently at - * the left edge of the view. This position is relative to the - * beginning of the document. - *

    - * - * @returns {Number} the horizontal pixel. - * - * @see orion.editor.TextView#setHorizontalPixel - * @see orion.editor.TextView#convert - */ - getHorizontalPixel: function() { - if (!this._clientDiv) { return 0; } - return this._getScroll().x; + _createRanges: function(ranges, text, start, end, lineStart, data) { + if (start > end) { return; } + if (ranges) { + for (var i = 0; i < ranges.length; i++) { + var range = ranges[i]; + if (range.end < lineStart + start) { continue; } + var styleStart = Math.max(lineStart + start, range.start) - lineStart; + if (styleStart > end) { break; } + var styleEnd = Math.min(lineStart + end, range.end) - lineStart; + if (styleStart <= styleEnd) { + styleStart = Math.max(start, styleStart); + styleEnd = Math.min(end, styleEnd); + if (start < styleStart) { + this._createRange(text, start, styleStart, null, data); + } + if (!range.style || !range.style.unmergeable) { + while (i + 1 < ranges.length && ranges[i + 1].start - lineStart === styleEnd && compare(range.style, ranges[i + 1].style)) { + range = ranges[i + 1]; + styleEnd = Math.min(lineStart + end, range.end) - lineStart; + i++; + } + } + this._createRange(text, styleStart, styleEnd, range.style, data); + start = styleEnd; + } + } + } + if (start < end) { + this._createRange(text, start, end, null, data); + } }, - /** - * Returns all the key bindings associated to the given action ID. - * - * @param {String} actionID the action ID. - * @returns {orion.KeyBinding[]} the array of key bindings associated to the given action ID. - * - * @see orion.editor.TextView#setKeyBinding - * @see orion.editor.TextView#setAction - */ - getKeyBindings: function (actionID) { - var result = []; - var keyModes = this._keyModes; - for (var i = 0; i < keyModes.length; i++) { - result = result.concat(keyModes[i].getKeyBindings(actionID)); + _createRange: function(text, start, end, style, data) { + if (start > end) { return; } + var tabSize = this.view._customTabSize, range; + var bidiStyle = {tagName:"span", bidi:true, style:{unicodeBidi:"embed", direction:"ltr"}}; + var bidiRange = {text: "\u200E", style: bidiStyle}; // We ensure segments flow from left to right by adding a LRM marker \u200E + if (tabSize && tabSize !== 8) { + var tabIndex = text.indexOf("\t", start); //$NON-NLS-1$ + while (tabIndex !== -1 && tabIndex < end) { + if (start < tabIndex) { + range = {text: text.substring(start, tabIndex), style: style}; + data.ranges.push(range); + if (bidiUtils.isBidiEnabled) { + data.ranges.push(bidiRange); + } + data.tabOffset += range.text.length; + } + var spacesCount = tabSize - (data.tabOffset % tabSize); + if (spacesCount > 0) { + //TODO hack to preserve tabs in getDOMText() + var spaces = "\u00A0"; //$NON-NLS-1$ + for (var i = 1; i < spacesCount; i++) { + spaces += " "; //$NON-NLS-1$ + } + range = {text: spaces, style: style, ignoreChars: spacesCount - 1}; + data.ranges.push(range); + if (bidiUtils.isBidiEnabled) { + data.ranges.push(bidiRange); + } + data.tabOffset += range.text.length; + } + start = tabIndex + 1; + if (start === end) { + return; + } + tabIndex = text.indexOf("\t", start); //$NON-NLS-1$ + } + } + if (start <= end) { + range = {text: text.substring(start, end), style: style}; + data.ranges.push(range); + if (bidiUtils.isBidiEnabled) { + data.ranges.push(bidiRange); + } + data.tabOffset += range.text.length; } - return result; }, - /** - * Returns all the key modes added to text view. - * - * @returns {orion.editor.KeyMode[]} the array of key modes. - * - * @see orion.editor.TextView#addKeyMode - * @see orion.editor.TextView#removeKeyMode - */ - getKeyModes: function() { - return this._keyModes.slice(0); + _createSpan: function(_parent, text, style, ignoreChars) { + var view = this.view; + var tagName = "span"; //$NON-NLS-1$ + if (style && style.tagName) { + tagName = style.tagName.toLowerCase(); + } + var isLink = tagName === "a"; //$NON-NLS-1$ + if (isLink) { this.hasLink = true; } + if (isLink && !view._linksVisible) { + tagName = "span"; //$NON-NLS-1$ + } + var doc = _parent.ownerDocument; + var child = util.createElement(_parent.ownerDocument, tagName); + child.appendChild(doc.createTextNode(style && style.text ? style.text : text)); + if (style && style.html) { + child.innerHTML = style.html; + child.ignore = true; + } else if (style && style.node) { + child.appendChild(style.node); + child.ignore = true; + } else if (style && style.bidi) { + child.ignore = true; + } + applyStyle(style, child); + if (tagName === "a") { //$NON-NLS-1$ + var win = view._getWindow(); + addHandler(child, "click", function(e) { return view._handleLinkClick(e ? e : win.event); }, false); //$NON-NLS-1$ + } + child.viewStyle = style; + if (ignoreChars) { + child.ignoreChars = ignoreChars; + } + return child; }, - /** - * Returns the line height for a given line index. Returns the default line - * height if the line index is not specified. - * - * @param {Number} [lineIndex] the line index. - * @returns {Number} the height of the line in pixels. - * - * @see orion.editor.TextView#getLinePixel - */ - getLineHeight: function(lineIndex) { - if (!this._clientDiv) { return 0; } - return this._getLineHeight(lineIndex); + _ensureCreated: function() { + if (this._lineDiv) { return this._lineDiv; } + return (this._createdDiv = this.create(this.view._clientDiv, null)); }, - /** - * Returns the line index for a given line pixel position relative to the document. - * - * @param {Number} [y] the line pixel. - * @returns {Number} the line index for the specified pixel position. - * - * @see orion.editor.TextView#getLinePixel - */ - getLineIndex: function(y) { - if (!this._clientDiv) { return 0; } - return this._getLineIndex(y); + /** @private */ + getBoundingClientRect: function(offset, absolute) { + var child = this._ensureCreated(); + var view = this.view; + if (offset === undefined) { + return this._getLineBoundingClientRect(child, true); + } + var model = view._model; + var doc = child.ownerDocument; + var lineIndex = this.lineIndex; + var result = null; + if (offset < model.getLineEnd(lineIndex)) { + var lineOffset = model.getLineStart(lineIndex); + this.forEach(function(lineChild) { + var textNode = lineChild.firstChild; + var nodeLength = this._nodeLength(lineChild); + if (lineOffset + nodeLength > offset) { + var index = offset - lineOffset; + var range; + if (textNode.length === 1) { + result = new TextRect(lineChild.getBoundingClientRect()); + } else if (view._isRangeRects) { + range = doc.createRange(); + range.setStart(textNode, index); + range.setEnd(textNode, index + 1); + result = new TextRect(range.getBoundingClientRect()); + } else if (util.isIE) { + range = doc.body.createTextRange(); + range.moveToElementText(lineChild); + range.collapse(); + /* + * Bug in IE8. TextRange.getClientRects() and TextRange.getBoundingClientRect() fails + * if the line child is not the first element in the line and if the start offset is 0. + * The fix is to use Node.getClientRects() left edge instead. + */ + var fixIE8 = index === 0 && util.isIE === 8; + if (fixIE8) { index = 1; } + range.moveEnd("character", index + 1); //$NON-NLS-1$ + range.moveStart("character", index); //$NON-NLS-1$ + result = new TextRect(range.getBoundingClientRect()); + if (fixIE8) { + result.left = lineChild.getClientRects()[0].left; + } + } else { + var text = textNode.data; + lineChild.removeChild(textNode); + lineChild.appendChild(doc.createTextNode(text.substring(0, index))); + var span = util.createElement(doc, "span"); //$NON-NLS-1$ + span.appendChild(doc.createTextNode(text.substring(index, index + 1))); + lineChild.appendChild(span); + lineChild.appendChild(doc.createTextNode(text.substring(index + 1))); + result = new TextRect(span.getBoundingClientRect()); + lineChild.innerHTML = ""; + lineChild.appendChild(textNode); + if (!this._createdDiv) { + /* + * Removing the element node that holds the selection start or end + * causes the selection to be lost. The fix is to detect this case + * and restore the selection. + */ + var s = view._getSelections()[0]; + if ((lineOffset <= s.start && s.start < lineOffset + nodeLength) || (lineOffset <= s.end && s.end < lineOffset + nodeLength)) { + view._updateDOMSelection(); + } + } + } + if (util.isIE < 11) { + var win = getWindow(child.ownerDocument); + var xFactor = win.screen.logicalXDPI / win.screen.deviceXDPI; + var yFactor = win.screen.logicalYDPI / win.screen.deviceYDPI; + result.left = result.left * xFactor; + result.right = result.right * xFactor; + result.top = result.top * yFactor; + result.bottom = result.bottom * yFactor; + } + return false; + } + lineOffset += nodeLength; + return true; + }); + } + var rect = this.getBoundingClientRect(); + if (!result) { + if (view._wrapMode) { + var rects = this.getClientRects(); + result = rects[rects.length - 1]; + result.left = result.right; + result.left += rect.left; + result.top += rect.top; + result.right += rect.left; + result.bottom += rect.top; + } else { + result = new TextRect(rect); + result.left = result.right; + } + } + if (absolute || absolute === undefined) { + result.left -= rect.left; + result.top -= rect.top; + result.right -= rect.left; + result.bottom -= rect.top; + } + return result; }, - /** - * @name isValidTextPosition - * @description Return whether the given x/y pixel position, relative to the document, is inside of document text. - * This tests both whether the y position is below the text lines of the document as we as whether the - * x position is within the text of the line. - * @function - * @param x {Number} [x] the x pixel position - * @param y {Number} [y] the line pixel position - * @returns returns {Boolean} true if the pixel position is over text content - */ - isValidTextPosition: function(x, y){ - if (!this._clientDiv) { return false; } - // Check if we are within a valid line - var lineIndex = this._getLineIndex(y, true); - if (lineIndex < 0){ - return false; + forEach: function(callback) { + var child = this._ensureCreated(); + var lineChild = child.firstChild; + while (lineChild) { + var next = lineChild.nextSibling; + if (!lineChild.ignore) { + if (!callback.call(this, lineChild)) { + break; + } + } + lineChild = next; } - // Get the closest offset to the position - var line = this._getLine(lineIndex); - var offset = this.getOffsetAtLocation(x, y); - // If the closest offset is to the left of the character's bounds then position is outside the text on the line - var bounds = line.getBoundingClientRect(offset); - line.destroy(); - if (x > bounds.right){ - return false; + }, + /** @private */ + _getClientRects: function(element, parentRect) { + var rects, newRects, rect, i; + if (!element._rectsCache) { + rects = element.getClientRects(); + newRects = newArray(rects.length); + for (i = 0; i - * Clamps out of range indices. - *

    - * - * @param {Number} lineIndex the line index. - * @returns {Number} the pixel position of the line. - * - * @see orion.editor.TextView#setTopPixel - * @see orion.editor.TextView#getLineIndex - * @see orion.editor.TextView#convert - */ - getLinePixel: function(lineIndex) { - if (!this._clientDiv) { return 0; } - return this._getLinePixel(lineIndex); + getClientRects: function(lineIndex) { + if (!this.view._wrapMode) { return [this.getBoundingClientRect()]; } + var child = this._ensureCreated(); + //TODO [perf] cache rects + var result = []; + var parentRect = child.getBoundingClientRect(); + this.forEach(function(lineChild) { + var rects = this._getClientRects(lineChild, parentRect); + for (var i = 0; i < rects.length; i++) { + var rect = rects[i], j, r; + if (rect.top === rect.bottom) { continue; } + var center = rect.top + (rect.bottom - rect.top) / 2; + for (j = 0; j < result.length; j++) { + r = result[j]; + if ((r.top <= center && center < r.bottom)) { + break; + } + } + if (j === result.length) { + result.push(rect); + } else { + if (rect.left < r.left) { r.left = rect.left; } + if (rect.top < r.top) { r.top = rect.top; } + if (rect.right > r.right) { r.right = rect.right; } + if (rect.bottom > r.bottom) { r.bottom = rect.bottom; } + } + } + return true; + }); + if (lineIndex !== undefined) { + return result[lineIndex]; + } + return result; }, - /** - * Returns the {x, y} pixel location of the top-left corner of the character - * bounding box at the specified offset in the document. The pixel location - * is relative to the document. - *

    - * Clamps out of range offsets. - *

    - * - * @param {Number} offset the character offset - * @returns {Object} the {x, y} pixel location of the given offset. - * - * @see orion.editor.TextView#getOffsetAtLocation - * @see orion.editor.TextView#convert - */ - getLocationAtOffset: function(offset) { - if (!this._clientDiv) { return {x: 0, y: 0}; } - var model = this._model; - offset = Math.min(Math.max(0, offset), model.getCharCount()); + /** @private */ + _getLineBoundingClientRect: function (child, noTrim) { + var rect = new TextRect(child.getBoundingClientRect()); + if (this.view._wrapMode) { + } else { + rect.right = rect.left; + var lastChild = child.lastChild; + //Remove any artificial trailing whitespace in the line + while (lastChild && lastChild.ignoreChars === lastChild.firstChild.length) { + lastChild = lastChild.previousSibling; + } + if (lastChild) { + var lastRect = lastChild.getBoundingClientRect(); + rect.right = lastRect.right + getLineTrim(child).right; + } + } + if (noTrim) { + var padding = getLineTrim(child); + rect.left = rect.left + padding.left; + rect.right = rect.right - padding.right; + } + return rect; + }, + /** @private */ + getLineCount: function () { + if (!this.view._wrapMode) { return 1; } + return this.getClientRects().length; + }, + /** @private */ + getLineIndex: function(offset) { + if (!this.view._wrapMode) { return 0; } + var rects = this.getClientRects(); + var rect = this.getBoundingClientRect(offset); + var center = rect.top + ((rect.bottom - rect.top) / 2); + for (var i = 0; i < rects.length; i++) { + if (rects[i].top <= center && center < rects[i].bottom) { + return i; + } + } + return rects.length - 1; + }, + /** @private */ + getLineStart: function (lineIndex) { + if (!this.view._wrapMode || lineIndex === 0) { + return this.view._model.getLineStart(this.lineIndex); + } + var rects = this.getClientRects(); + return this.getOffset(rects[lineIndex].left + 1, rects[lineIndex].top + 1); + }, + _nodeLength: function(lineChild) { + if (!lineChild || lineChild.ignore) return 0; + var len = lineChild.firstChild.length; + if (lineChild.ignoreChars) { + len -= lineChild.ignoreChars; + } + return len; + }, + getModelOffset: function(node, offset) { + if (!node) { return 0; } + var lineOffset = 0; + this.forEach(function(lineChild) { + var textNode = lineChild.firstChild; + if (textNode === node) { + if (lineChild.ignoreChars) { lineOffset -= lineChild.ignoreChars; } + lineOffset += offset; + return false; + } + if (lineChild.ignoreChars) { lineOffset -= lineChild.ignoreChars; } + lineOffset += textNode.data.length; + return true; + }); + return Math.max(0, lineOffset) + this.view._model.getLineStart(this.lineIndex); + }, + getNodeOffset: function(modelOffset) { + var offset = 0; + var lineNode, lineNodeOffset; + var model = this.view._model; + var lineStart = model.getLineStart(this.lineIndex); + var lineOffset = modelOffset - lineStart; + var end = model.getLineEnd(this.lineIndex) - lineStart; + this.forEach(function(lineChild) { + var node = lineChild.firstChild; + var nodeLength = this._nodeLength(lineChild); + if (nodeLength + offset > lineOffset || offset + nodeLength >= end) { + lineNode = node; + lineNodeOffset = lineOffset - offset; + if (lineChild.ignoreChars && nodeLength > 0 && lineNodeOffset === nodeLength) { + lineNodeOffset += lineChild.ignoreChars; + } + return false; + } + offset += nodeLength; + return true; + }); + return {node: lineNode, offset: lineNodeOffset}; + }, + getText: function(offsetNode) { + var text = "", offset = 0; + this.forEach(function(lineChild) { + var textNode; + if (lineChild.ignoreChars) { + textNode = lineChild.lastChild; + var ignored = 0, childText = [], childOffset = -1; + while (textNode) { + var data = textNode.data; + if (data) { + for (var i = data.length - 1; i >= 0; i--) { + var ch = data.substring(i, i + 1); + if (ignored < lineChild.ignoreChars && (ch === " " || ch === "\uFEFF")) { //$NON-NLS-1$ //$NON-NLS-1$ + ignored++; + } else { + childText.push(ch === "\u00A0" ? "\t" : ch); //$NON-NLS-1$ //$NON-NLS-1$ + } + } + } + if (offsetNode === textNode) { + childOffset = childText.length; + } + textNode = textNode.previousSibling; + } + childText = childText.reverse().join(""); + if (childOffset !== -1) { + offset = text.length + childText.length - childOffset; + } + text += childText; + } else { + textNode = lineChild.firstChild; + while (textNode) { + if (offsetNode === textNode) { + offset = text.length; + } + text += textNode.data; + textNode = textNode.nextSibling; + } + } + return true; + }); + return {text: text, offset: offset}; + }, + /** @private */ + getOffset: function(x, y) { + var view = this.view; + var model = view._model; + var lineIndex = this.lineIndex; + var lineStart = model.getLineStart(lineIndex); + var lineEnd = model.getLineEnd(lineIndex); + if (lineStart === lineEnd) { + return lineStart; + } + var child = this._ensureCreated(); + var lineRect = this.getBoundingClientRect(); + + var that = this; + function hitChild(lineChild, offset, rect) { + var textNode = lineChild.firstChild; + var nodeLength = that._nodeLength(lineChild); + var doc = child.ownerDocument; + var win = getWindow(doc); + var xFactor = util.isIE < 11 ? win.screen.logicalXDPI / win.screen.deviceXDPI : 1; + var yFactor = util.isIE < 11 ? win.screen.logicalYDPI / win.screen.deviceYDPI : 1; + var rangeLeft, rangeTop, rangeRight, rangeBottom; + var range, start, end; + var rl = rect.left + lineRect.left, fixIE8, rects1; + if (util.isIE || view._isRangeRects) { + range = view._isRangeRects ? doc.createRange() : doc.body.createTextRange(); + var high = nodeLength; + var low = -1; + while ((high - low) > 1) { + var mid = Math.floor((high + low) / 2); + start = low + 1; + end = mid === nodeLength - 1 && lineChild.ignoreChars ? textNode.length : mid + 1; + /* + * Bug in IE8. TextRange.getClientRects() and TextRange.getBoundingClientRect() fails + * if the line child is not the first element in the line and if the start offset is 0. + * The fix is to use Node.getClientRects() left edge instead. + */ + fixIE8 = start === 0 && util.isIE === 8; + if (view._isRangeRects) { + range.setStart(textNode, start); + range.setEnd(textNode, end); + } else { + if (fixIE8) { start = 1; } + range.moveToElementText(lineChild); + range.move("character", start); //$NON-NLS-1$ + range.moveEnd("character", end - start); //$NON-NLS-1$ + } + rects1 = range.getClientRects(); + var found = false; + for (var k = 0; k < rects1.length; k++) { + rect = rects1[k]; + rangeLeft = (fixIE8 ? rl : rect.left) * xFactor - lineRect.left; + rangeRight = rect.right * xFactor - lineRect.left; + rangeTop = rect.top * yFactor - lineRect.top; + rangeBottom = rect.bottom * yFactor - lineRect.top; + if (rangeLeft <= x && x < rangeRight && (!view._wrapMode || (rangeTop <= y && y <= rangeBottom))) { + found = true; + break; + } + } + if (found) { + high = mid; + } else { + low = mid; + } + } + offset += high; + start = high; + end = high === nodeLength - 1 && lineChild.ignoreChars ? textNode.length : Math.min(high + 1, textNode.length); + if (view._isRangeRects) { + range.setStart(textNode, start); + range.setEnd(textNode, end); + } else { + range.moveToElementText(lineChild); + range.move("character", start); //$NON-NLS-1$ + range.moveEnd("character", end - start); //$NON-NLS-1$ + } + rects1 = range.getClientRects(); + var trailing = false; + if (rects1.length > 0) { + rect = rects1[0]; + rangeLeft = (fixIE8 ? rl : rect.left) * xFactor - lineRect.left; + rangeRight = rect.right * xFactor - lineRect.left; + //TODO test for character trailing (wrong for bidi) + trailing = x > (rangeLeft + (rangeRight - rangeLeft) / 2); + } + // Handle Unicode surrogates + var offsetInLine = offset - lineStart; + var lineText = model.getLine(lineIndex); + var c = lineText.charCodeAt(offsetInLine); + if (0xD800 <= c && c <= 0xDBFF && trailing) { + if (offsetInLine < lineText.length) { + c = lineText.charCodeAt(offsetInLine + 1); + if (0xDC00 <= c && c <= 0xDFFF) { + offset += 1; + } + } + } else if (0xDC00 <= c && c <= 0xDFFF && !trailing) { + if (offsetInLine > 0) { + c = lineText.charCodeAt(offsetInLine - 1); + if (0xD800 <= c && c <= 0xDBFF) { + offset -= 1; + } + } + } + if (trailing) { + offset++; + } + } else { + var newText = []; + for (var q = 0; q < nodeLength; q++) { + newText.push(""); //$NON-NLS-1$ + if (q === nodeLength - 1) { + newText.push(textNode.data.substring(q)); + } else { + newText.push(textNode.data.substring(q, q + 1)); + } + newText.push(""); //$NON-NLS-1$ + } + lineChild.innerHTML = newText.join(""); + var rangeChild = lineChild.firstChild; + while (rangeChild) { + rect = rangeChild.getBoundingClientRect(); + rangeLeft = rect.left - lineRect.left; + rangeRight = rect.right - lineRect.left; + if (rangeLeft <= x && x < rangeRight) { + //TODO test for character trailing (wrong for bidi) + if (x > rangeLeft + (rangeRight - rangeLeft) / 2) { + offset++; + } + break; + } + offset++; + rangeChild = rangeChild.nextSibling; + } + if (!that._createdDiv) { + lineChild.innerHTML = ""; + lineChild.appendChild(textNode); + /* + * Removing the element node that holds the selection start or end + * causes the selection to be lost. The fix is to detect this case + * and restore the selection. + */ + var s = view._getSelections()[0]; + if ((offset <= s.start && s.start < offset + nodeLength) || (offset <= s.end && s.end < offset + nodeLength)) { + view._updateDOMSelection(); + } + } + } + return offset; + } + + var rects, rect; + if (view._wrapMode) { + rects = this.getClientRects(); + if (y < rects[0].top) { + y = rects[0].top; + } + for (var i = 0; i < rects.length; i++) { + rect = rects[i]; + if (rect.top <= y && y < rect.bottom) { + break; + } + } + if (x < rect.left) { x = rect.left; } + if (x > rect.right) { x = rect.right - 1; } + } else { + if (x < 0) { x = 0; } + if (x > (lineRect.right - lineRect.left)) { x = lineRect.right - lineRect.left; } + } + + function hitRects(child) { + if (child.ignore) return null; + var rects1 = that._getClientRects(child, lineRect); + for (var j = 0; j < rects1.length; j++) { + var rect1 = rects1[j]; + if (rect1.left <= x && x < rect1.right && (!view._wrapMode || (rect1.top <= y && y <= rect1.bottom))) { + return rect1; + } + } + return null; + } + + var offset, lineChild; + if (this._lastHitChild && this._lastHitChild.parentNode) { + // Search last hit child first, then search around the last hit child + offset = this._lastHitOffset; + lineChild = this._lastHitChild; + rect = hitRects(lineChild); + if (!rect ) { + var previousOffset = offset, nextOffset = offset + this._nodeLength(lineChild); + var previousChild = lineChild.previousSibling, nextChild = lineChild.nextSibling; + while (previousChild || nextChild) { + if (previousChild) { + previousOffset -= this._nodeLength(previousChild); + if ((rect = hitRects(previousChild))) { + lineChild = previousChild; + offset = previousOffset; + break; + } + previousChild = previousChild.previousSibling; + } + if (nextChild) { + if ((rect = hitRects(nextChild))) { + lineChild = nextChild; + offset = nextOffset; + break; + } + nextOffset += this._nodeLength(nextChild); + nextChild = nextChild.nextSibling; + } + } + } + } else { + // Start searching from the beginning of the line + offset = lineStart; + this.forEach(function(c) { + lineChild = c; + if ((rect = hitRects(lineChild))) { + return false; + } + offset += this._nodeLength(lineChild); + return true; + }); + } + + if (lineChild && rect) { + // Cache the last hit child + this._lastHitChild = lineChild; + this._lastHitOffset = offset; + + offset = hitChild(lineChild, offset, rect); + } + + return Math.min(lineEnd, Math.max(lineStart, offset)); + }, + /** @private */ + getNextOffset: function (offset, data) { + if (data.unit === "line") { //$NON-NLS-1$ + var view = this.view; + var model = view._model; + var lineIndex = model.getLineAtOffset(offset); + if (data.count > 0) { + data.count--; + return model.getLineEnd(lineIndex); + } + data.count++; + return model.getLineStart(lineIndex); + } + if (data.unit === "wordend" || data.unit === "wordWS" || data.unit === "wordendWS") { //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-1$ + return this._getNextOffset_W3C(offset, data); + } + return util.isIE ? this._getNextOffset_IE(offset, data) : this._getNextOffset_W3C(offset, data); + }, + /** @private */ + _getNextOffset_W3C: function (offset, data) { + function _isPunctuation(c) { + return (33 <= c && c <= 47) || (58 <= c && c <= 64) || (91 <= c && c <= 94) || c === 96 || (123 <= c && c <= 126); + } + function _isWhitespace(c) { + return c === 32 || c === 9; + } + var view = this.view; + var model = view._model; var lineIndex = model.getLineAtOffset(offset); - var line = this._getLine(lineIndex); - var rect = line.getBoundingClientRect(offset); - line.destroy(); - var x = rect.left; - var y = this._getLinePixel(lineIndex) + rect.top; - return {x: x, y: y}; + var lineText = model.getLine(lineIndex); + var lineStart = model.getLineStart(lineIndex); + var lineEnd = model.getLineEnd(lineIndex); + var lineLength = lineText.length; + var offsetInLine = offset - lineStart; + var c; + var step = data.count < 0 ? -1 : 1; + if (data.unit === "word" || data.unit === "wordend" || data.unit === "wordWS" || data.unit === "wordendWS") { //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-1$ + var previousPunctuation, previousLetterOrDigit, punctuation, letterOrDigit; + while (data.count !== 0) { + if (data.count > 0) { + if (offsetInLine === lineLength) { return lineEnd; } + c = lineText.charCodeAt(offsetInLine); + previousPunctuation = _isPunctuation(c); + previousLetterOrDigit = !previousPunctuation && !_isWhitespace(c); + offsetInLine++; + while (offsetInLine < lineLength) { + c = lineText.charCodeAt(offsetInLine); + if (data.unit !== "wordWS" && data.unit !== "wordendWS") { //$NON-NLS-1$ //$NON-NLS-1$ + punctuation = _isPunctuation(c); + if (data.unit === "wordend") { //$NON-NLS-1$ + if (!punctuation && previousPunctuation) { break; } + } else { + if (punctuation && !previousPunctuation) { break; } + } + letterOrDigit = !punctuation && !_isWhitespace(c); + } else { + letterOrDigit = !_isWhitespace(c); + } + if (data.unit === "wordend" || data.unit === "wordendWS") { //$NON-NLS-1$ //$NON-NLS-1$ + if (!letterOrDigit && previousLetterOrDigit) { break; } + } else { + if (letterOrDigit && !previousLetterOrDigit) { break; } + } + previousLetterOrDigit = letterOrDigit; + previousPunctuation = punctuation; + offsetInLine++; + } + } else { + if (offsetInLine === 0) { return lineStart; } + offsetInLine--; + c = lineText.charCodeAt(offsetInLine); + previousPunctuation = _isPunctuation(c); + previousLetterOrDigit = !previousPunctuation && !_isWhitespace(c); + while (0 < offsetInLine) { + c = lineText.charCodeAt(offsetInLine - 1); + if (data.unit !== "wordWS" && data.unit !== "wordendWS") { //$NON-NLS-1$ //$NON-NLS-1$ + punctuation = _isPunctuation(c); + if (data.unit === "wordend") { //$NON-NLS-1$ + if (punctuation && !previousPunctuation) { break; } + } else { + if (!punctuation && previousPunctuation) { break; } + } + letterOrDigit = !punctuation && !_isWhitespace(c); + } else { + letterOrDigit = !_isWhitespace(c); + } + if (data.unit === "wordend" || data.unit === "wordendWS") { //$NON-NLS-1$ //$NON-NLS-1$ + if (letterOrDigit && !previousLetterOrDigit) { break; } + } else { + if (!letterOrDigit && previousLetterOrDigit) { break; } + } + previousLetterOrDigit = letterOrDigit; + previousPunctuation = punctuation; + offsetInLine--; + } + if (offsetInLine === 0) { + //get previous line + } + } + data.count -= step; + } + } else { + while (data.count !== 0 && (0 <= offsetInLine + step && offsetInLine + step <= lineLength)) { + offsetInLine += step; + c = lineText.charCodeAt(offsetInLine); + // Handle Unicode surrogates + if (0xDC00 <= c && c <= 0xDFFF) { + if (offsetInLine > 0) { + c = lineText.charCodeAt(offsetInLine - 1); + if (0xD800 <= c && c <= 0xDBFF) { + offsetInLine += step; + } + } + } + data.count -= step; + } + } + return lineStart + offsetInLine; + }, + /** @private */ + _getNextOffset_IE: function (offset, data) { + var child = this._ensureCreated(); + var view = this.view; + var model = view._model; + var lineIndex = this.lineIndex; + var result = 0, range, len; + var lineOffset = model.getLineStart(lineIndex); + var lineText = model.getLine(lineIndex); + var lineStart = model.getLineStart(lineIndex); + var doc = child.ownerDocument; + var lineChild; + var step = data.count < 0 ? -1 : 1; + if (offset === model.getLineEnd(lineIndex)) { + lineChild = child.lastChild; + while (lineChild && lineChild.ignoreChars === lineChild.firstChild.length) { + lineChild = lineChild.previousSibling; + } + if (!lineChild) { + return lineOffset; + } + range = doc.body.createTextRange(); + range.moveToElementText(lineChild); + len = range.text.length; + range.moveEnd(data.unit, step); + result = offset + range.text.length - len; + } else if (offset === lineOffset && data.count < 0) { + result = lineOffset; + } else { + lineChild = child.firstChild; + while (lineChild) { + var nodeLength = this._nodeLength(lineChild); + if (lineOffset + nodeLength > offset) { + range = doc.body.createTextRange(); + if (offset === lineOffset && data.count < 0) { + var temp = lineChild.previousSibling; + // skip empty nodes + while (temp) { + if (temp.firstChild && temp.firstChild.length) { + break; + } + temp = temp.previousSibling; + } + range.moveToElementText(temp ? temp : lineChild.previousSibling); + } else { + range.moveToElementText(lineChild); + range.collapse(); + range.moveEnd("character", offset - lineOffset); //$NON-NLS-1$ + } + len = range.text.length; + range.moveEnd(data.unit, step); + result = offset + range.text.length - len; + break; + } + lineOffset = nodeLength + lineOffset; + lineChild = lineChild.nextSibling; + } + } + var offsetInLine = result - lineStart; + var c = lineText.charCodeAt(offsetInLine); + // Handle Unicode surrogates + if (0xDC00 <= c && c <= 0xDFFF) { + if (offsetInLine > 0) { + c = lineText.charCodeAt(offsetInLine - 1); + if (0xD800 <= c && c <= 0xDBFF) { + offsetInLine += step; + } + } + } + result = offsetInLine + lineStart; + data.count -= step; + return result; }, + updateLinks: function() { + var child = this._ensureCreated(); + if (!this.hasLink) { return; } + var that = this; + this.forEach(function(span) { + var style = span.viewStyle; + if (style && style.tagName && style.tagName.toLowerCase() === "a") { //$NON-NLS-1$ + child.replaceChild(that._createSpan(child, span.firstChild.data, style), span); + } + return true; + }); + }, + /** @private */ + destroy: function() { + var div = this._createdDiv; + if (div) { + div.parentNode.removeChild(div); + this._createdDiv = null; + } + } + }; + + /** + * @class This object describes the options for the text view. + *

    + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#setOptions} + * {@link orion.editor.TextView#getOptions} + *

    + * @name orion.editor.TextViewOptions + * + * @property {String|DOMElement} parent the parent element for the view, it can be either a DOM element or an ID for a DOM element. + * @property {orion.editor.TextModel} [model] the text model for the view. If it is not set the view creates an empty {@link orion.editor.TextModel}. + * @property {Boolean} [readonly=false] whether or not the view is read-only. + * @property {Boolean} [fullSelection=true] whether or not the view is in full selection mode. + * @property {Boolean} [tabMode=true] whether or not the tab keypress is consumed by the view or is used for focus traversal. + * @property {Boolean} [expandTab=false] whether or not the tab key inserts white spaces. + * @property {orion.editor.TextTheme} [theme=orion.editor.TextTheme.getTheme()] the TextTheme manager. TODO more info on this + * @property {orion.editor.UndoStack} [undoStack] the Undo Stack. + * @property {String} [themeClass] the CSS class for the view theming. + * @property {Number} [tabSize=8] The number of spaces in a tab. + * @property {Boolean} [overwriteMode=false] whether or not the view is in insert/overwrite mode. + * @property {Boolean} [singleMode=false] whether or not the editor is in single line mode. + * @property {Number} [marginOffset=0] the offset in a line where the print margin should be displayed. 0 means no print margin. + * @property {Number} [wrapOffset=0] the offset in a line where text should wrap. 0 means wrap at the client area right edge. + * @property {Boolean} [wrapMode=false] whether or not the view wraps lines. + * @property {Boolean} [wrapable=false] whether or not the view is wrappable. + * @property {Number} [scrollAnimation=0] the time duration in miliseconds for scrolling animation. 0 means no animation. + * @property {Boolean} [blockCursorVisible=false] whether or not to show the block cursor. + */ + /** + * Constructs a new text view. + * + * @param {orion.editor.TextViewOptions} options the view options. + * + * @class A TextView is a user interface for editing text. + * @name orion.editor.TextView + * @borrows orion.editor.EventTarget#addEventListener as #addEventListener + * @borrows orion.editor.EventTarget#removeEventListener as #removeEventListener + * @borrows orion.editor.EventTarget#dispatchEvent as #dispatchEvent + */ + function TextView (options) { + this._init(options || {}); + } + + TextView.prototype = /** @lends orion.editor.TextView.prototype */ { /** - * Returns the next character offset after the given offset and options + * Adds a keyMode to the text view at the specified position. * - * @param {Number} offset the offset to start from - * @param {Object} options - * { unit: the type of unit to advance to (eg "character", "word", "wordend", "wordWS", "wordendWS"), - * count: the number of units to advance (negative to advance backwards) } - * @returns {Number} the next character offset + * @param {orion.editor.KeyMode} mode the editor keyMode. + * @param {Number} [index=length] the index. */ - getNextOffset: function(offset, options) { - var selection = new Selection(offset, offset, false); - this._doMove(options, selection); - return selection.getCaret(); + addKeyMode: function(mode, index) { + var keyModes = this._keyModes; + if (index !== undefined) { + keyModes.splice(index, 0, mode); + } else { + keyModes.push(mode); + } + //TODO: API needed for this + if (mode._modeAdded) { + mode._modeAdded(); + } }, /** - * Returns the specified view options. + * Adds a ruler to the text view at the specified position. *

    - * The returned value is either a orion.editor.TextViewOptions or an option value. An option value is returned when only one string parameter - * is specified. A orion.editor.TextViewOptions is returned when there are no paremeters, or the parameters are a list of options names or a - * orion.editor.TextViewOptions. All view options are returned when there no paremeters. + * The position is relative to the ruler location. *

    * - * @param {String|orion.editor.TextViewOptions} [options] The options to return. - * @return {Object|orion.editor.TextViewOptions} The requested options or an option value. - * - * @see orion.editor.TextView#setOptions + * @param {orion.editor.Ruler} ruler the ruler. + * @param {Number} [index=length] the ruler index. */ - getOptions: function() { - var options; - if (arguments.length === 0) { - options = this._defaultOptions(); - } else if (arguments.length === 1) { - var arg = arguments[0]; - if (typeof arg === "string") { //$NON-NLS-1$ - return clone(this["_" + arg]); //$NON-NLS-1$ - } - options = arg; - } else { - options = {}; - for (var index in arguments) { - if (arguments.hasOwnProperty(index)) { - options[arguments[index]] = undefined; + addRuler: function (ruler, index) { + var rulers = this._rulers; + if (index !== undefined) { + var i, sideIndex; + for (i = 0, sideIndex=0; i < rulers.length && sideIndex < index; i++) { + if (ruler.getLocation() === rulers[i].getLocation()) { + sideIndex++; } } + rulers.splice(sideIndex, 0, ruler); + index = sideIndex; + } else { + rulers.push(ruler); } - for (var option in options) { - if (options.hasOwnProperty(option)) { - options[option] = clone(this["_" + option]); //$NON-NLS-1$ - } - } - return options; + this._createRuler(ruler, index); + ruler.setView(this); + this._update(); }, - /** - * Returns the text model of the text view. - * - * @returns {orion.editor.TextModel} the text model of the view. - */ - getModel: function() { - return this._model; + computeSize: function() { + var w = 0, h = 0; + var model = this._model, clientDiv = this._clientDiv; + if (!clientDiv) { return {width: w, height: h}; } + var clientWidth = clientDiv.style.width; + /* + * Feature in WekKit. Webkit limits the width of the lines + * computed below to the width of the client div. This causes + * the lines to be wrapped even though "pre" is set. The fix + * is to set the width of the client div to a "0x7fffffffpx" + * before computing the lines width. Note that this value is + * reset to the appropriate value further down. + */ + if (util.isWebkit) { + clientDiv.style.width = "0x7fffffffpx"; //$NON-NLS-1$ + } + var lineCount = model.getLineCount(); + for (var lineIndex=0; lineIndexThe supported coordinate spaces are: + *
      + *
    • "document" - relative to document, the origin is the top-left corner of first line
    • + *
    • "page" - relative to html page that contains the text view
    • + *
    + *

    + *

    All methods in the view that take or return a position are in the document coordinate space.

    * - * @param x the x of the location - * @param y the y of the location - * @returns {Number} the character offset at the given location. + * @param rect the rectangle to convert. + * @param rect.x the x of the rectangle. + * @param rect.y the y of the rectangle. + * @param rect.width the width of the rectangle. + * @param rect.height the height of the rectangle. + * @param {String} from the source coordinate space. + * @param {String} to the destination coordinate space. * * @see orion.editor.TextView#getLocationAtOffset + * @see orion.editor.TextView#getOffsetAtLocation + * @see orion.editor.TextView#getTopPixel + * @see orion.editor.TextView#setTopPixel */ - getOffsetAtLocation: function(x, y) { - if (!this._clientDiv) { return 0; } - var lineIndex = this._getLineIndex(y); - var line = this._getLine(lineIndex); - var offset = line.getOffset(x, y - this._getLinePixel(lineIndex)); - line.destroy(); - return offset; - }, - /** - * @name getLineAtOffset - * @description Compute the editor line number for the given offset - * @function - * @public - * @memberof orion.editor.TextView - * @param {Number} offset The offset into the editor - * @returns {Number} Returns the line number in the editor corresponding to the given offset or -1 if the offset is - * out of range - * @since 5.0 - */ - getLineAtOffset: function(offset) { - return this.getModel().getLineAtOffset(offset); - }, - /** - * @name getLineStart - * @description Compute the editor start offset of the given line number - * @function - * @public - * @memberof orion.editor.TextView - * @param {Number} line The line number in the editor - * @returns {Number} Returns the start offset of the given line number in the editor. - * @since 5.0 - */ - getLineStart: function(line) { - return this.getModel().getLineStart(line); - }, - /** - * Get the view rulers. - * - * @returns {orion.editor.Ruler[]} the view rulers - * - * @see orion.editor.TextView#addRuler - */ - getRulers: function() { - return this._rulers.slice(0); + convert: function(rect, from, to) { + if (!this._clientDiv) { return rect; } + var _scroll = this._getScroll(); + var viewPad = this._getViewPadding(); + var viewRect = this._viewDiv.getBoundingClientRect(); + if (from === "document") { //$NON-NLS-1$ + if (rect.x !== undefined) { + rect.x += - _scroll.x + viewRect.left + viewPad.left; + } + if (rect.y !== undefined) { + rect.y += - _scroll.y + viewRect.top + viewPad.top; + } + } + //At this point rect is in the widget coordinate space + if (to === "document") { //$NON-NLS-1$ + if (rect.x !== undefined) { + rect.x += _scroll.x - viewRect.left - viewPad.left; + } + if (rect.y !== undefined) { + rect.y += _scroll.y - viewRect.top - viewPad.top; + } + } + return rect; }, /** - * Returns the text view selection. - *

    - * The selection is defined by a start and end character offset relative to the - * document. The character at end offset is not included in the selection. - *

    - * - * @returns {orion.editor.Selection} the view selection - * - * @see orion.editor.TextView#setSelection + * Copies the selected text to the clipboard in plain text format. + * @returns {Boolean} true if the operation succeded. + * @since 10.0 */ - getSelection: function () { - return this._getSelection(); - }, - getSelections: function () { - return this._getSelections(); + copy: function() { + if (!this._clientDiv) { return false; } + return this._doCopy(); }, /** - * Returns the text view selection text. - *

    - * If there are multiple selection ranges, the result is concatenated with the specified delimiter. - *

    - * - * @param {String} delimiter The offset into the editor - * @returns {String} the view selection text + * Moves the selected text to the clipboard in plain text format. + * @returns {Boolean} true if the operation succeded. * @since 10.0 - * @see orion.editor.TextView#setSelection */ - getSelectionText: function(delimiter) { - var text = []; - var that = this; - var selections = this._getSelections(); - selections.forEach(function(selection) { - if (!selection.isEmpty()) { - text.push(that._getBaseText(selection.start, selection.end)); - } - }); - return text.join(delimiter !== undefined ? delimiter : this._model.getLineDelimiter()); + cut: function() { + if (!this._clientDiv) { return false; } + return this._doCut(); }, /** - * Returns the text for the given range. + * Destroys the text view. *

    - * The text does not include the character at the end offset. + * Removes the view from the page and frees all resources created by the view. + * Calling this function causes the "Destroy" event to be fire so that all components + * attached to view can release their references. *

    * - * @param {Number} [start=0] the start offset of text range. - * @param {Number} [end=char count] the end offset of text range. - * - * @see orion.editor.TextView#setText + * @see orion.editor.TextView#onDestroy */ - getText: function(start, end) { - var model = this._model; - return model.getText(start, end); + destroy: function() { + /* Destroy rulers*/ + for (var i=0; i< this._rulers.length; i++) { + this._rulers[i].setView(null); + } + this.rulers = null; + + this._destroyView(); + + var e = {type: "Destroy"}; //$NON-NLS-1$ + this.onDestroy(e); + + this._parent = null; + if (this._model && this._model.destroy) { + this._model.destroy(); + } + this._model = null; + this._theme = null; + this._selection = null; + this._doubleClickSelection = null; + this._keyModes = null; + this._actions = null; }, /** - * Returns the top index. - *

    - * The top index is the line that is currently at the top of the view. This - * line may be partially visible depending on the vertical scroll of the view. The parameter - * fullyVisible determines whether to return only fully visible lines. - *

    - * - * @param {Boolean} [fullyVisible=false] if true, returns the index of the first fully visible line. This - * parameter is ignored if the view is not big enough to show one line. - * @returns {Number} the index of the top line. - * - * @see orion.editor.TextView#getBottomIndex - * @see orion.editor.TextView#setTopIndex + * Gives focus to the text view. */ - getTopIndex: function(fullyVisible) { - if (!this._clientDiv) { return 0; } - return this._getTopIndex(fullyVisible); + focus: function() { + if (!this._clientDiv) { return; } + /* + * Feature in Chrome. When focus is called in the clientDiv without + * setting selection the browser will set the selection to the first dom + * element, which can be above the client area. When this happen the + * browser also scrolls the window to show that element. + * The fix is to call _updateDOMSelection() before calling focus(). + */ + this._updateDOMSelection(); + this._clientDiv.focus(); + /* + * Feature in Safari. When focus is called the browser selects the clientDiv + * itself. The fix is to call _updateDOMSelection() after calling focus(). + */ + this._updateDOMSelection(); }, /** - * Returns the top pixel. - *

    - * The top pixel is the pixel position that is currently at - * the top edge of the view. This position is relative to the - * beginning of the document. - *

    - * - * @returns {Number} the top pixel. + * Check if the text view has focus. * - * @see orion.editor.TextView#getBottomPixel - * @see orion.editor.TextView#setTopPixel - * @see orion.editor.TextView#convert + * @returns {Boolean} true if the text view has focus, otherwise false. */ - getTopPixel: function() { - if (!this._clientDiv) { return 0; } - return this._getScroll().y; + hasFocus: function() { + return this._hasFocus; }, /** - * Executes the action handler associated with the given action ID. - *

    - * The application defined action takes precedence over predefined actions unless - * the defaultAction paramater is true. - *

    - *

    - * If the application defined action returns false, the text view predefined - * action is executed if present. - *

    - * - * @param {String} actionID the action ID. - * @param {Boolean} [defaultAction] whether to always execute the predefined action only. - * @param {Object} [actionOptions] action specific options to be passed to the action handlers. - * @returns {Boolean} true if the action was executed. + * Returns the action description for a given action ID. * - * @see orion.editor.TextView#setAction - * @see orion.editor.TextView#getActions + * @returns {orion.editor.ActionDescrition} the action description */ - invokeAction: function (actionID, defaultAction, actionOptions) { - if (!this._clientDiv) { return; } + getActionDescription: function(actionID) { var action = this._actions[actionID]; if (action) { - if (action.actionDescription && action.actionDescription.id) { - mMetrics.logEvent("editor", "action", action.actionDescription.id); //$NON-NLS-1$ //$NON-NLS-2$ - } - if (!defaultAction && action.handler) { - if (action.handler(actionOptions)) { - return true; - } - } - if (action.defaultHandler) { - return typeof action.defaultHandler(actionOptions) === "boolean"; //$NON-NLS-1$ - } + return action.actionDescription; } - return false; + return undefined; }, /** - * Returns if the view is destroyed. - * @returns {Boolean} true if the view is destroyed. - */ - isDestroyed: function () { - return !this._clientDiv; - }, - /** - * @class This is the event sent when the user right clicks or otherwise invokes the context menu of the view. - *

    - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#event:onContextMenu} - *

    - * - * @name orion.editor.ContextMenuEvent - * - * @property {Number} x The pointer location on the x axis, relative to the document the user is editing. - * @property {Number} y The pointer location on the y axis, relative to the document the user is editing. - * @property {Number} screenX The pointer location on the x axis, relative to the screen. This is copied from the DOM contextmenu event.screenX property. - * @property {Number} screenY The pointer location on the y axis, relative to the screen. This is copied from the DOM contextmenu event.screenY property. - * @property {Boolean} defaultPrevented Determines whether the user agent context menu should be shown. It is shown by default. - * @property {Function} preventDefault If called prevents the user agent context menu from showing. - */ - /** - * This event is sent when the user invokes the view context menu. - * - * @event - * @param {orion.editor.ContextMenuEvent} contextMenuEvent the event - */ - onContextMenu: function(contextMenuEvent) { - return this.dispatchEvent(contextMenuEvent); - }, - onDragStart: function(dragEvent) { - return this.dispatchEvent(dragEvent); - }, - onDrag: function(dragEvent) { - return this.dispatchEvent(dragEvent); - }, - onDragEnd: function(dragEvent) { - return this.dispatchEvent(dragEvent); - }, - onDragEnter: function(dragEvent) { - return this.dispatchEvent(dragEvent); - }, - onDragOver: function(dragEvent) { - return this.dispatchEvent(dragEvent); - }, - onDragLeave: function(dragEvent) { - return this.dispatchEvent(dragEvent); - }, - onDrop: function(dragEvent) { - return this.dispatchEvent(dragEvent); + * Returns all action IDs defined in the text view. + *

    + * There are two types of actions, the predefined actions of the view + * and the actions added by application code. + *

    + *

    + * The predefined actions are: + *

      + *
    • Navigation actions. These actions move the caret collapsing the selection.
    • + *
        + *
      • "lineUp" - moves the caret up by one line
      • + *
      • "lineDown" - moves the caret down by one line
      • + *
      • "lineStart" - moves the caret to beginning of the current line
      • + *
      • "lineEnd" - moves the caret to end of the current line
      • + *
      • "charPrevious" - moves the caret to the previous character
      • + *
      • "charNext" - moves the caret to the next character
      • + *
      • "pageUp" - moves the caret up by one page
      • + *
      • "pageDown" - moves the caret down by one page
      • + *
      • "wordPrevious" - moves the caret to the previous word
      • + *
      • "wordNext" - moves the caret to the next word
      • + *
      • "textStart" - moves the caret to the beginning of the document
      • + *
      • "textEnd" - moves the caret to the end of the document
      • + *
      + *
    • Selection actions. These actions move the caret extending the selection.
    • + *
        + *
      • "selectLineUp" - moves the caret up by one line
      • + *
      • "selectLineDown" - moves the caret down by one line
      • + *
      • "selectLineStart" - moves the caret to beginning of the current line
      • + *
      • "selectLineEnd" - moves the caret to end of the current line
      • + *
      • "selectCharPrevious" - moves the caret to the previous character
      • + *
      • "selectCharNext" - moves the caret to the next character
      • + *
      • "selectPageUp" - moves the caret up by one page
      • + *
      • "selectPageDown" - moves the caret down by one page
      • + *
      • "selectWordPrevious" - moves the caret to the previous word
      • + *
      • "selectWordNext" - moves the caret to the next word
      • + *
      • "selectTextStart" - moves the caret to the beginning of the document
      • + *
      • "selectTextEnd" - moves the caret to the end of the document
      • + *
      • "selectAll" - selects the entire document
      • + *
      + *
    • Edit actions. These actions modify the text view text
    • + *
        + *
      • "deletePrevious" - deletes the character preceding the caret
      • + *
      • "deleteNext" - deletes the charecter following the caret
      • + *
      • "deleteWordPrevious" - deletes the word preceding the caret
      • + *
      • "deleteWordNext" - deletes the word following the caret
      • + *
      • "deleteLineStart" - deletes characteres to the beginning of the line
      • + *
      • "deleteLineEnd" - deletes characteres to the end of the line
      • + *
      • "tab" - inserts a tab character at the caret
      • + *
      • "shiftTab" - noop
      • + *
      • "enter" - inserts a line delimiter at the caret
      • + *
      • "uppercase" - upper case the text at the caret
      • + *
      • "lowercase" - lower case the text at the caret
      • + *
      • "capitalize" - capitilize case the text at the caret
      • + *
      • "reversecase" - reverse the case the text at the caret
      • + *
      + *
    • Clipboard actions. These actions modify the view text as well
    • + *
        + *
      • "copy" - copies the selected text to the clipboard
      • + *
      • "cut" - copies the selected text to the clipboard and deletes the selection
      • + *
      • "paste" - replaces the selected text with the clipboard contents
      • + *
      + *
    • Scrolling actions.
    • + *
        + *
      • "scrollLineUp" - scrolls the view up by one line
      • + *
      • "scrollLineDown" - scrolls the view down by one line
      • + *
      • "scrollPageUp" - scrolls the view up by one page
      • + *
      • "scrollPageDown" - scrolls the view down by one page
      • + *
      • "scrollTextStart" - scrolls the view to the beginning of the document
      • + *
      • "scrollTextEnd" - scrolls the view to the end of the document
      • + *
      + *
    • Mode actions.
    • + *
        + *
      • "toggleTabMode" - toggles tab mode.
      • + *
      • "toggleWrapMode" - toggles wrap mode.
      • + *
      • "toggleOverwriteMode" - toggles overwrite mode.
      • + *
      + *
    + *

    + * + * @param {Boolean} [defaultAction=false] whether or not the predefined actions are included. + * @returns {String[]} an array of action IDs defined in the text view. + * + * @see orion.editor.TextView#invokeAction + * @see orion.editor.TextView#setAction + * @see orion.editor.TextView#setKeyBinding + * @see orion.editor.TextView#getKeyBindings + */ + getActions: function (defaultAction) { + var result = []; + var actions = this._actions; + for (var i in actions) { + if (actions.hasOwnProperty(i)) { + if (!defaultAction && actions[i].defaultHandler) { continue; } + result.push(i); + } + } + return result; }, /** - * @class This is the event sent when the text view is destroyed. + * Returns the bottom index. *

    - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#event:onDestroy} + * The bottom index is the line that is currently at the bottom of the view. This + * line may be partially visible depending on the vertical scroll of the view. The parameter + * fullyVisible determines whether to return only fully visible lines. *

    - * @name orion.editor.DestroyEvent - */ - /** - * This event is sent when the text view has been destroyed. * - * @event - * @param {orion.editor.DestroyEvent} destroyEvent the event + * @param {Boolean} [fullyVisible=false] if true, returns the index of the last fully visible line. This + * parameter is ignored if the view is not big enough to show one line. + * @returns {Number} the index of the bottom line. * - * @see orion.editor.TextView#destroy + * @see orion.editor.TextView#getTopIndex + * @see orion.editor.TextView#setTopIndex */ - onDestroy: function(destroyEvent) { - return this.dispatchEvent(destroyEvent); + getBottomIndex: function(fullyVisible) { + if (!this._clientDiv) { return 0; } + return this._getBottomIndex(fullyVisible); }, /** - * @description This event is sent when the file is being saved - * @function - * @param {Object} savingEvent the event - * @since 8.0 + * Returns the bottom pixel. + *

    + * The bottom pixel is the pixel position that is currently at + * the bottom edge of the view. This position is relative to the + * beginning of the document. + *

    + * + * @returns {Number} the bottom pixel. + * + * @see orion.editor.TextView#getTopPixel + * @see orion.editor.TextView#setTopPixel + * @see orion.editor.TextView#convert */ - onSaving: function onSaving(savingEvent) { - return this.dispatchEvent(savingEvent); + getBottomPixel: function() { + if (!this._clientDiv) { return 0; } + return this._getScroll().y + this._getClientHeight(); }, /** - * @description This event is sent when the file has been saved - * @function - * @param {Object} inputChangedEvent the event - * @since 8.0 + * Returns the caret offset relative to the start of the document. + * + * @returns {Number} the caret offset relative to the start of the document. + * + * @see orion.editor.TextView#setCaretOffset + * @see orion.editor.TextView#setSelection + * @see orion.editor.TextView#getSelection */ - onInputChanged: function onInputChanged(inputChangedEvent) { - return this.dispatchEvent(inputChangedEvent); + getCaretOffset: function () { + var s = this._getSelection(); + return s.getCaret(); }, /** - * @class This object is used to define style information for the text view. - *

    - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#event:onLineStyle} - *

    - * @name orion.editor.Style - * - * @property {String} styleClass A CSS class name. - * @property {Object} style An object with CSS properties. - * @property {String} tagName A DOM tag name. - * @property {Object} attributes An object with DOM attributes. - */ - /** - * @class This object is used to style range. - *

    - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#event:onLineStyle} - *

    - * @name orion.editor.StyleRange - * - * @property {Number} start The start character offset, relative to the document, where the style should be applied. - * @property {Number} end The end character offset (exclusive), relative to the document, where the style should be applied. - * @property {orion.editor.Style} style The style for the range. - */ - /** - * @class This is the event sent when the text view needs the style information for a line. + * Returns the client area. *

    - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#event:onLineStyle} - *

    - * @name orion.editor.LineStyleEvent - * - * @property {orion.editor.TextView} textView The text view. - * @property {Number} lineIndex The line index. - * @property {String} lineText The line text. - * @property {Number} lineStart The character offset, relative to document, of the first character in the line. - * @property {orion.editor.Style} style The style for the entire line (output argument). - * @property {orion.editor.StyleRange[]} ranges An array of style ranges for the line (output argument). - */ - /** - * This event is sent when the text view needs the style information for a line. + * The client area is the portion in pixels of the document that is visible. The + * client area position is relative to the beginning of the document. + *

    * - * @event - * @param {orion.editor.LineStyleEvent} lineStyleEvent the event + * @returns {Object} the client area rectangle {x, y, width, height}. + * + * @see orion.editor.TextView#getTopPixel + * @see orion.editor.TextView#getBottomPixel + * @see orion.editor.TextView#getHorizontalPixel + * @see orion.editor.TextView#convert */ - onLineStyle: function(lineStyleEvent) { - return this.dispatchEvent(lineStyleEvent); + getClientArea: function() { + if (!this._clientDiv) { return {x: 0, y: 0, width: 0, height: 0}; } + var _scroll = this._getScroll(); + return {x: _scroll.x, y: _scroll.y, width: this._getClientWidth(), height: this._getClientHeight()}; }, /** - * @class This is the event sent for all keyboard events. + * Returns the horizontal pixel. *

    - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#event:onKeyDown}
    - * {@link orion.editor.TextView#event:onKeyPress}
    - * {@link orion.editor.TextView#event:onKeyUp}
    + * The horizontal pixel is the pixel position that is currently at + * the left edge of the view. This position is relative to the + * beginning of the document. *

    - * @name orion.editor.KeyEvent - * - * @property {String} type The type of event. - * @property {DOMEvent} event The key DOM event. - * @property {Boolean} defaultPrevented Determines whether the user agent context menu should be shown. It is shown by default. - * @property {Function} preventDefault If called prevents the user agent context menu from showing. - */ - /** - * This event is sent for key down events. * - * @event - * @param {orion.editor.KeyEvent} keyEvent the event + * @returns {Number} the horizontal pixel. + * + * @see orion.editor.TextView#setHorizontalPixel + * @see orion.editor.TextView#convert */ - onKeyDown: function(keyEvent) { - return this.dispatchEvent(keyEvent); + getHorizontalPixel: function() { + if (!this._clientDiv) { return 0; } + return this._getScroll().x; }, /** - * This event is sent for key press events. Key press events are only sent - * for printable characters. + * Returns all the key bindings associated to the given action ID. * - * @event - * @param {orion.editor.KeyEvent} keyEvent the event + * @param {String} actionID the action ID. + * @returns {orion.KeyBinding[]} the array of key bindings associated to the given action ID. + * + * @see orion.editor.TextView#setKeyBinding + * @see orion.editor.TextView#setAction */ - onKeyPress: function(keyEvent) { - return this.dispatchEvent(keyEvent); + getKeyBindings: function (actionID) { + var result = []; + var keyModes = this._keyModes; + for (var i = 0; i < keyModes.length; i++) { + result = result.concat(keyModes[i].getKeyBindings(actionID)); + } + return result; }, /** - * This event is sent for key up events. + * Returns all the key modes added to text view. * - * @event - * @param {orion.editor.KeyEvent} keyEvent the event + * @returns {orion.editor.KeyMode[]} the array of key modes. + * + * @see orion.editor.TextView#addKeyMode + * @see orion.editor.TextView#removeKeyMode */ - onKeyUp: function(keyEvent) { - return this.dispatchEvent(keyEvent); + getKeyModes: function() { + return this._keyModes.slice(0); }, /** - * @class This is the event sent when the text in the model has changed. - *

    - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#event:onModelChanged}
    - * {@link orion.editor.TextModel#onChanged} - *

    - * @name orion.editor.ModelChangedEvent - * - * @property {Number} start The character offset in the model where the change has occurred. - * @property {Number} removedCharCount The number of characters removed from the model. - * @property {Number} addedCharCount The number of characters added to the model. - * @property {Number} removedLineCount The number of lines removed from the model. - * @property {Number} addedLineCount The number of lines added to the model. - */ - /** - * This event is sent when the text in the model has changed. + * Returns the line height for a given line index. Returns the default line + * height if the line index is not specified. * - * @event - * @param {orion.editor.ModelChangedEvent} modelChangedEvent the event + * @param {Number} [lineIndex] the line index. + * @returns {Number} the height of the line in pixels. + * + * @see orion.editor.TextView#getLinePixel */ - onModelChanged: function(modelChangedEvent) { - return this.dispatchEvent(modelChangedEvent); + getLineHeight: function(lineIndex) { + if (!this._clientDiv) { return 0; } + return this._getLineHeight(lineIndex); }, /** - * @class This is the event sent when the text in the model is about to change. - *

    - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#event:onModelChanging}
    - * {@link orion.editor.TextModel#onChanging} - *

    - * @name orion.editor.ModelChangingEvent - * - * @property {String} text The text that is about to be inserted in the model. - * @property {Number} start The character offset in the model where the change will occur. - * @property {Number} removedCharCount The number of characters being removed from the model. - * @property {Number} addedCharCount The number of characters being added to the model. - * @property {Number} removedLineCount The number of lines being removed from the model. - * @property {Number} addedLineCount The number of lines being added to the model. - */ - /** - * This event is sent when the text in the model is about to change. + * Returns the line index for a given line pixel position relative to the document. * - * @event - * @param {orion.editor.ModelChangingEvent} modelChangingEvent the event + * @param {Number} [y] the line pixel. + * @returns {Number} the line index for the specified pixel position. + * + * @see orion.editor.TextView#getLinePixel */ - onModelChanging: function(modelChangingEvent) { - return this.dispatchEvent(modelChangingEvent); + getLineIndex: function(y) { + if (!this._clientDiv) { return 0; } + return this._getLineIndex(y); }, /** - * @class This is the event sent when the text is modified by the text view. - *

    - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#event:onModify} - *

    - * @name orion.editor.ModifyEvent + * @name isValidTextPosition + * @description Return whether the given x/y pixel position, relative to the document, is inside of document text. + * This tests both whether the y position is below the text lines of the document as we as whether the + * x position is within the text of the line. + * @function + * @param x {Number} [x] the x pixel position + * @param y {Number} [y] the line pixel position + * @returns returns {Boolean} true if the pixel position is over text content */ + isValidTextPosition: function(x, y){ + if (!this._clientDiv) { return false; } + // Check if we are within a valid line + var lineIndex = this._getLineIndex(y, true); + if (lineIndex < 0){ + return false; + } + // Get the closest offset to the position + var line = this._getLine(lineIndex); + var offset = this.getOffsetAtLocation(x, y); + // If the closest offset is to the left of the character's bounds then position is outside the text on the line + var bounds = line.getBoundingClientRect(offset); + line.destroy(); + if (x > bounds.right){ + return false; + } + return true; + }, /** - * This event is sent when the text view has changed text in the model. + * Returns the top pixel position of a given line index relative to the beginning + * of the document. *

    - * If the text is changed directly through the model API, this event - * is not sent. + * Clamps out of range indices. *

    * - * @event - * @param {orion.editor.ModifyEvent} modifyEvent the event + * @param {Number} lineIndex the line index. + * @returns {Number} the pixel position of the line. + * + * @see orion.editor.TextView#setTopPixel + * @see orion.editor.TextView#getLineIndex + * @see orion.editor.TextView#convert */ - onModify: function(modifyEvent) { - return this.dispatchEvent(modifyEvent); - }, - onMouseDown: function(mouseEvent) { - return this.dispatchEvent(mouseEvent); - }, - onMouseUp: function(mouseEvent) { - return this.dispatchEvent(mouseEvent); - }, - onMouseMove: function(mouseEvent) { - return this.dispatchEvent(mouseEvent); - }, - onMouseOver: function(mouseEvent) { - return this.dispatchEvent(mouseEvent); - }, - onMouseOut: function(mouseEvent) { - return this.dispatchEvent(mouseEvent); - }, - onTouchStart: function(touchEvent) { - return this.dispatchEvent(touchEvent); - }, - onTouchMove: function(touchEvent) { - return this.dispatchEvent(touchEvent); - }, - onTouchEnd: function(touchEvent) { - return this.dispatchEvent(touchEvent); - }, - onOptions: function(optionsEvent) { - return this.dispatchEvent(optionsEvent); + getLinePixel: function(lineIndex) { + if (!this._clientDiv) { return 0; } + return this._getLinePixel(lineIndex); }, /** - * @class This is the event sent when the selection changes in the text view. + * Returns the {x, y} pixel location of the top-left corner of the character + * bounding box at the specified offset in the document. The pixel location + * is relative to the document. *

    - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#event:onSelection} - *

    - * @name orion.editor.SelectionEvent - * - * @property {orion.editor.Selection} oldValue The old selection. - * @property {orion.editor.Selection} newValue The new selection. - */ - /** - * This event is sent when the text view selection has changed. + * Clamps out of range offsets. + *

    * - * @event - * @param {orion.editor.SelectionEvent} selectionEvent the event + * @param {Number} offset the character offset + * @returns {Object} the {x, y} pixel location of the given offset. + * + * @see orion.editor.TextView#getOffsetAtLocation + * @see orion.editor.TextView#convert */ - onSelection: function(selectionEvent) { - return this.dispatchEvent(selectionEvent); + getLocationAtOffset: function(offset) { + if (!this._clientDiv) { return {x: 0, y: 0}; } + var model = this._model; + offset = Math.min(Math.max(0, offset), model.getCharCount()); + var lineIndex = model.getLineAtOffset(offset); + var line = this._getLine(lineIndex); + var rect = line.getBoundingClientRect(offset); + line.destroy(); + var x = rect.left; + var y = this._getLinePixel(lineIndex) + rect.top; + return {x: x, y: y}; }, /** - * @class This is the event sent when the text view scrolls. - *

    - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#event:onScroll} - *

    - * @name orion.editor.ScrollEvent - * - * @property {Object} oldValue The old scroll {x,y}. - * @property {Object} newValue The new scroll {x,y}. - */ - /** - * This event is sent when the text view scrolls vertically or horizontally. + * Returns the next character offset after the given offset and options * - * @event - * @param {orion.editor.ScrollEvent} scrollEvent the event + * @param {Number} offset the offset to start from + * @param {Object} options + * { unit: the type of unit to advance to (eg "character", "word", "wordend", "wordWS", "wordendWS"), + * count: the number of units to advance (negative to advance backwards) } + * @returns {Number} the next character offset */ - onScroll: function(scrollEvent) { - return this.dispatchEvent(scrollEvent); + getNextOffset: function(offset, options) { + var selection = new Selection(offset, offset, false); + this._doMove(options, selection); + return selection.getCaret(); }, /** - * @class This is the event sent when the text is about to be modified by the text view. + * Returns the specified view options. *

    - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#event:onVerify} + * The returned value is either a orion.editor.TextViewOptions or an option value. An option value is returned when only one string parameter + * is specified. A orion.editor.TextViewOptions is returned when there are no paremeters, or the parameters are a list of options names or a + * orion.editor.TextViewOptions. All view options are returned when there no paremeters. *

    - * @name orion.editor.VerifyEvent - * - * @property {String} text The text being inserted. - * @property {Number} start The start offset of the text range to be replaced. - * @property {Number} end The end offset (exclusive) of the text range to be replaced. + * + * @param {String|orion.editor.TextViewOptions} [options] The options to return. + * @return {Object|orion.editor.TextViewOptions} The requested options or an option value. + * + * @see orion.editor.TextView#setOptions */ + getOptions: function() { + var options; + if (arguments.length === 0) { + options = this._defaultOptions(); + } else if (arguments.length === 1) { + var arg = arguments[0]; + if (typeof arg === "string") { //$NON-NLS-1$ + return clone(this["_" + arg]); //$NON-NLS-1$ + } + options = arg; + } else { + options = {}; + for (var index in arguments) { + if (arguments.hasOwnProperty(index)) { + options[arguments[index]] = undefined; + } + } + } + for (var option in options) { + if (options.hasOwnProperty(option)) { + options[option] = clone(this["_" + option]); //$NON-NLS-1$ + } + } + return options; + }, /** - * This event is sent when the text view is about to change text in the model. - *

    - * If the text is changed directly through the model API, this event - * is not sent. - *

    - *

    - * Listeners are allowed to change these parameters. Setting text to null - * or undefined stops the change. - *

    + * Returns the text model of the text view. * - * @event - * @param {orion.editor.VerifyEvent} verifyEvent the event + * @returns {orion.editor.TextModel} the text model of the view. */ - onVerify: function(verifyEvent) { - return this.dispatchEvent(verifyEvent); + getModel: function() { + return this._model; }, /** - * @class This is the event sent when the text view is focused. - *

    - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#event:onFocus}
    - *

    - * @name orion.editor.FocusEvent + * Returns the character offset nearest to the given pixel location. The + * pixel location is relative to the document. + * + * @param x the x of the location + * @param y the y of the location + * @returns {Number} the character offset at the given location. + * + * @see orion.editor.TextView#getLocationAtOffset */ + getOffsetAtLocation: function(x, y) { + if (!this._clientDiv) { return 0; } + var lineIndex = this._getLineIndex(y); + var line = this._getLine(lineIndex); + var offset = line.getOffset(x, y - this._getLinePixel(lineIndex)); + line.destroy(); + return offset; + }, /** - * This event is sent when the text view is focused. - * - * @event - * @param {orion.editor.FocusEvent} focusEvent the event + * @name getLineAtOffset + * @description Compute the editor line number for the given offset + * @function + * @public + * @memberof orion.editor.TextView + * @param {Number} offset The offset into the editor + * @returns {Number} Returns the line number in the editor corresponding to the given offset or -1 if the offset is + * out of range + * @since 5.0 */ - onFocus: function(focusEvent) { - return this.dispatchEvent(focusEvent); + getLineAtOffset: function(offset) { + return this.getModel().getLineAtOffset(offset); }, /** - * @class This is the event sent when the text view goes out of focus. - *

    - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#event:onBlur}
    - *

    - * @name orion.editor.BlurEvent + * @name getLineStart + * @description Compute the editor start offset of the given line number + * @function + * @public + * @memberof orion.editor.TextView + * @param {Number} line The line number in the editor + * @returns {Number} Returns the start offset of the given line number in the editor. + * @since 5.0 */ + getLineStart: function(line) { + return this.getModel().getLineStart(line); + }, /** - * This event is sent when the text view goes out of focus. + * Get the view rulers. * - * @event - * @param {orion.editor.BlurEvent} blurEvent the event + * @returns {orion.editor.Ruler[]} the view rulers + * + * @see orion.editor.TextView#addRuler */ - onBlur: function(blurEvent) { - return this.dispatchEvent(blurEvent); + getRulers: function() { + return this._rulers.slice(0); }, /** - * Replaces the selection with the text on the clipboard or, if there is no selection, inserts the text at the current caret offset. + * Returns the text view selection. *

    - * If the single mode is on and the clipboard text contains more than one line, all lines will be concatenated. + * The selection is defined by a start and end character offset relative to the + * document. The character at end offset is not included in the selection. *

    - * @returns {Boolean} true if the operation succeded. - * @since 10.0 - */ - paste: function() { - if (!this._clientDiv) { return false; } - return this._doPaste(); - }, - /** - * Redraws the entire view, including rulers. + * + * @returns {orion.editor.Selection} the view selection * - * @see orion.editor.TextView#redrawLines - * @see orion.editor.TextView#redrawRange - * @see orion.editor.TextView#setRedraw + * @see orion.editor.TextView#setSelection */ - redraw: function() { - if (this._redrawCount > 0) { return; } - var lineCount = this._model.getLineCount(); - this.redrawRulers(0, lineCount); - this.redrawLines(0, lineCount); + getSelection: function () { + return this._getSelection(); }, - redrawRulers: function(startLine, endLine) { - if (this._redrawCount > 0) { return; } - var rulers = this.getRulers(); - for (var i = 0; i < rulers.length; i++) { - this.redrawLines(startLine, endLine, rulers[i]); - } + getSelections: function () { + return this._getSelections(); }, /** - * Redraws the text in the given line range. + * Returns the text view selection text. *

    - * The line at the end index is not redrawn. + * If there are multiple selection ranges, the result is concatenated with the specified delimiter. *

    - * - * @param {Number} [startLine=0] the start line - * @param {Number} [endLine=line count] the end line - * - * @see orion.editor.TextView#redraw - * @see orion.editor.TextView#redrawRange - * @see orion.editor.TextView#setRedraw + * + * @param {String} delimiter The offset into the editor + * @returns {String} the view selection text + * @since 10.0 + * @see orion.editor.TextView#setSelection */ - redrawLines: function(startLine, endLine, ruler) { - if (this._redrawCount > 0) { return; } - if (startLine === undefined) { startLine = 0; } - if (endLine === undefined) { endLine = this._model.getLineCount(); } - if (startLine === endLine) { return; } - var div = this._clientDiv; - if (!div) { return; } - if (ruler) { - var divRuler = this._getRulerParent(ruler); - div = divRuler.firstChild; - while (div) { - if (div._ruler === ruler) { - break; - } - div = div.nextSibling; - } - } - if (ruler) { - div.rulerChanged = true; - } else { - if (this._lineHeight) { - this._resetLineHeight(startLine, endLine); - } - } - var imeLineIndex = -1; - if (!ruler && this._imeOffset !== -1) { - imeLineIndex = this._model.getLineAtOffset(this._imeOffset); - } - if (!ruler || ruler.getOverview() === "page") { //$NON-NLS-1$ - var child = div.firstChild; - while (child) { - var lineIndex = child.lineIndex; - if (startLine <= lineIndex && lineIndex < endLine && lineIndex !== imeLineIndex) { - child.lineChanged = true; - } - child = child.nextSibling; - } - } - if (!ruler) { - if (!this._wrapMode) { - if (startLine <= this._maxLineIndex && this._maxLineIndex < endLine) { - this._checkMaxLineIndex = this._maxLineIndex; - this._maxLineIndex = -1; - this._maxLineWidth = 0; - } + getSelectionText: function(delimiter) { + var text = []; + var that = this; + var selections = this._getSelections(); + selections.forEach(function(selection) { + if (!selection.isEmpty()) { + text.push(that._getBaseText(selection.start, selection.end)); } - } - this.dispatchEvent({type: "Redraw", startLine: startLine, endLine: endLine, ruler: ruler}); //$NON-NLS-1$ - this._queueUpdate(); + }); + return text.join(delimiter !== undefined ? delimiter : this._model.getLineDelimiter()); }, /** - * Redraws the text in the given range. + * Returns the text for the given range. *

    - * The character at the end offset is not redrawn. + * The text does not include the character at the end offset. *

    * - * @param {Number} [start=0] the start offset of text range - * @param {Number} [end=char count] the end offset of text range + * @param {Number} [start=0] the start offset of text range. + * @param {Number} [end=char count] the end offset of text range. * - * @see orion.editor.TextView#redraw - * @see orion.editor.TextView#redrawLines - * @see orion.editor.TextView#setRedraw + * @see orion.editor.TextView#setText */ - redrawRange: function(start, end) { - if (this._redrawCount > 0) { return; } + getText: function(start, end) { var model = this._model; - if (start === undefined) { start = 0; } - if (end === undefined) { end = model.getCharCount(); } - var startLine = model.getLineAtOffset(start); - var endLine = model.getLineAtOffset(Math.max(start, end - 1)) + 1; - this.redrawLines(startLine, endLine); - }, - /** - * Removes a key mode from the text view. - * - * @param {orion.editor.KeyMode} mode the key mode. - */ - removeKeyMode: function (mode) { - var keyModes = this._keyModes; - for (var i=0; i + * The top index is the line that is currently at the top of the view. This + * line may be partially visible depending on the vertical scroll of the view. The parameter + * fullyVisible determines whether to return only fully visible lines. + *

    * - * @param {orion.editor.Ruler} ruler the ruler. + * @param {Boolean} [fullyVisible=false] if true, returns the index of the first fully visible line. This + * parameter is ignored if the view is not big enough to show one line. + * @returns {Number} the index of the top line. + * + * @see orion.editor.TextView#getBottomIndex + * @see orion.editor.TextView#setTopIndex */ - removeRuler: function (ruler) { - var rulers = this._rulers; - for (var i=0; i - * See:
    - * {@link orion.editor.TextView}
    - * {@link orion.editor.TextView#setAction} - *

    - * @name orion.editor.ActionDescription + * The top pixel is the pixel position that is currently at + * the top edge of the view. This position is relative to the + * beginning of the document. + *

    * - * @property {String} [name] the name to be used when showing the action as text. + * @returns {Number} the top pixel. + * + * @see orion.editor.TextView#getBottomPixel + * @see orion.editor.TextView#setTopPixel + * @see orion.editor.TextView#convert */ + getTopPixel: function() { + if (!this._clientDiv) { return 0; } + return this._getScroll().y; + }, /** - * Associates an application defined handler to an action ID. + * Executes the action handler associated with the given action ID. *

    - * If the action ID is a predefined action, the given handler executes before - * the default action handler. If the given handler returns true, the - * default action handler is not called. + * The application defined action takes precedence over predefined actions unless + * the defaultAction paramater is true. + *

    + *

    + * If the application defined action returns false, the text view predefined + * action is executed if present. *

    * * @param {String} actionID the action ID. - * @param {Function} handler the action handler. - * @param {orion.editor.ActionDescription} [actionDescription=undefined] the action description. + * @param {Boolean} [defaultAction] whether to always execute the predefined action only. + * @param {Object} [actionOptions] action specific options to be passed to the action handlers. + * @returns {Boolean} true if the action was executed. * + * @see orion.editor.TextView#setAction * @see orion.editor.TextView#getActions - * @see orion.editor.TextView#invokeAction */ - setAction: function(actionID, handler, actionDescription) { - if (!actionID) { return; } - var actions = this._actions; - var action = actions[actionID]; - if (!action) { - action = actions[actionID] = {}; - } - action.handler = handler; - if (actionDescription !== undefined) { - action.actionDescription = actionDescription; + invokeAction: function (actionID, defaultAction, actionOptions) { + if (!this._clientDiv) { return; } + var action = this._actions[actionID]; + if (action) { + if (action.actionDescription && action.actionDescription.id) { + mMetrics.logEvent("editor", "action", action.actionDescription.id); //$NON-NLS-1$ //$NON-NLS-2$ + } + if (!defaultAction && action.handler) { + if (action.handler(actionOptions)) { + return true; + } + } + if (action.defaultHandler) { + return typeof action.defaultHandler(actionOptions) === "boolean"; //$NON-NLS-1$ + } } + return false; }, /** - * Associates a key binding with the given action ID. Any previous - * association with the specified key binding is overwriten. If the - * action ID is null, the association is removed. + * Returns if the view is destroyed. + * @returns {Boolean} true if the view is destroyed. + */ + isDestroyed: function () { + return !this._clientDiv; + }, + /** + * @class This is the event sent when the user right clicks or otherwise invokes the context menu of the view. + *

    + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#event:onContextMenu} + *

    * - * @param {orion.KeyBinding} keyBinding the key binding - * @param {String} actionID the action ID - */ - setKeyBinding: function(keyBinding, actionID) { - this._keyModes[0].setKeyBinding(keyBinding, actionID); + * @name orion.editor.ContextMenuEvent + * + * @property {Number} x The pointer location on the x axis, relative to the document the user is editing. + * @property {Number} y The pointer location on the y axis, relative to the document the user is editing. + * @property {Number} screenX The pointer location on the x axis, relative to the screen. This is copied from the DOM contextmenu event.screenX property. + * @property {Number} screenY The pointer location on the y axis, relative to the screen. This is copied from the DOM contextmenu event.screenY property. + * @property {Boolean} defaultPrevented Determines whether the user agent context menu should be shown. It is shown by default. + * @property {Function} preventDefault If called prevents the user agent context menu from showing. + */ + /** + * This event is sent when the user invokes the view context menu. + * + * @event + * @param {orion.editor.ContextMenuEvent} contextMenuEvent the event + */ + onContextMenu: function(contextMenuEvent) { + return this.dispatchEvent(contextMenuEvent); + }, + onDragStart: function(dragEvent) { + return this.dispatchEvent(dragEvent); }, - /** - * Sets the caret offset relative to the start of the document. - * - * @param {Number} caret the caret offset relative to the start of the document. - * @param {Boolean|Number|orion.editor.TextViewShowOptions} [show=true] - * if true, the view will scroll the minimum amount necessary to show the caret location. If - * show is a Number, the view will scroll the minimum amount necessary to show the caret location plus a - * percentage of the client area height. The parameter is clamped to the [0,1] range. In either case, the view will only scroll - * if the new caret location is not visible already. The show parameter can also be a orion.editor.TextViewShowOptions object. See - * {@link orion.editor.TextViewShowOptions} for further information in how the options can be used to control the scrolling behavior. - * @param {Function} [callback] if callback is specified and scrollAnimation is not zero, view scrolling is animated and - * the callback is called when the animation is done. Otherwise, callback is callback right away. - * - * @see orion.editor.TextView#getCaretOffset - * @see orion.editor.TextView#setSelection - * @see orion.editor.TextView#getSelection - */ - setCaretOffset: function(offset, show, callback) { - var charCount = this._model.getCharCount(); - offset = Math.max(0, Math.min (offset, charCount)); - var selection = new Selection(offset, offset, false); - this._setSelection (selection, show === undefined || show, true, callback); + onDrag: function(dragEvent) { + return this.dispatchEvent(dragEvent); + }, + onDragEnd: function(dragEvent) { + return this.dispatchEvent(dragEvent); + }, + onDragEnter: function(dragEvent) { + return this.dispatchEvent(dragEvent); + }, + onDragOver: function(dragEvent) { + return this.dispatchEvent(dragEvent); + }, + onDragLeave: function(dragEvent) { + return this.dispatchEvent(dragEvent); + }, + onDrop: function(dragEvent) { + return this.dispatchEvent(dragEvent); }, /** - * Sets the horizontal pixel. + * @class This is the event sent when the text view is destroyed. *

    - * The horizontal pixel is the pixel position that is currently at - * the left edge of the view. This position is relative to the - * beginning of the document. + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#event:onDestroy} *

    + * @name orion.editor.DestroyEvent + */ + /** + * This event is sent when the text view has been destroyed. * - * @param {Number} pixel the horizontal pixel. + * @event + * @param {orion.editor.DestroyEvent} destroyEvent the event * - * @see orion.editor.TextView#getHorizontalPixel - * @see orion.editor.TextView#convert + * @see orion.editor.TextView#destroy */ - setHorizontalPixel: function(pixel) { - if (!this._clientDiv) { return; } - pixel = Math.max(0, pixel); - this._scrollView(pixel - this._getScroll().x, 0); + onDestroy: function(destroyEvent) { + return this.dispatchEvent(destroyEvent); }, /** - * Sets whether the view should update the DOM. - *

    - * This can be used to improve the performance. - *

    - * When the flag is set to true, - * the entire view is marked as needing to be redrawn. - * Nested calls to this method are stacked. - *

    - * - * @param {Boolean} redraw the new redraw state - * - * @see orion.editor.TextView#redraw + * @description This event is sent when the file is being saved + * @function + * @param {Object} savingEvent the event + * @since 8.0 */ - setRedraw: function(redraw) { - if (redraw) { - if (--this._redrawCount === 0) { - this.redraw(); - } - } else { - this._redrawCount++; - } + onSaving: function onSaving(savingEvent) { + return this.dispatchEvent(savingEvent); }, /** - * Sets the text model of the text view. - * - * @param {orion.editor.TextModel} model the text model of the view. + * @description This event is sent when the file has been saved + * @function + * @param {Object} inputChangedEvent the event + * @since 8.0 */ - setModel: function(model) { - if (model === this._model) { return; } - model = model || new mTextModel.TextModel(); - this._model.removeEventListener("preChanging", this._modelListener.onChanging); //$NON-NLS-1$ - this._model.removeEventListener("postChanged", this._modelListener.onChanged); //$NON-NLS-1$ - var oldLineCount = this._model.getLineCount(); - var oldCharCount = this._model.getCharCount(); - var newLineCount = model.getLineCount(); - var newCharCount = model.getCharCount(); - var newText = model.getText(); - var e = { - type: "ModelChanging", //$NON-NLS-1$ - text: newText, - start: 0, - removedCharCount: oldCharCount, - addedCharCount: newCharCount, - removedLineCount: oldLineCount, - addedLineCount: newLineCount - }; - this.onModelChanging(e); - this._model = model; - e = { - type: "ModelChanged", //$NON-NLS-1$ - start: 0, - removedCharCount: oldCharCount, - addedCharCount: newCharCount, - removedLineCount: oldLineCount, - addedLineCount: newLineCount - }; - this.onModelChanged(e); - this._model.addEventListener("preChanging", this._modelListener.onChanging); //$NON-NLS-1$ - this._model.addEventListener("postChanged", this._modelListener.onChanged); //$NON-NLS-1$ - this._reset(); - this._update(); + onInputChanged: function onInputChanged(inputChangedEvent) { + return this.dispatchEvent(inputChangedEvent); }, /** - * Sets the view options for the view. - * - * @param {orion.editor.TextViewOptions} options the view options. + * @class This object is used to define style information for the text view. + *

    + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#event:onLineStyle} + *

    + * @name orion.editor.Style * - * @see orion.editor.TextView#getOptions + * @property {String} styleClass A CSS class name. + * @property {Object} style An object with CSS properties. + * @property {String} tagName A DOM tag name. + * @property {Object} attributes An object with DOM attributes. */ - setOptions: function (options) { - var defaultOptions = this._defaultOptions(); - for (var option in options) { - if (options.hasOwnProperty(option)) { - var newValue = options[option], oldValue = this["_" + option]; //$NON-NLS-1$ - if (compare(oldValue, newValue)) { continue; } - var update = defaultOptions[option] ? defaultOptions[option].update : null; - if (update) { - update.call(this, newValue); - continue; - } - this["_" + option] = clone(newValue); //$NON-NLS-1$ - } - } - this.onOptions({type: "Options", options: options}); //$NON-NLS-1$ - }, /** - * @class This object describes the selection show options. + * @class This object is used to style range. *

    * See:
    - * {@link orion.editor.TextView#setSelection} - * {@link orion.editor.TextView#setCaretOffset} - * {@link orion.editor.TextView#showSelection} + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#event:onLineStyle} *

    - * @name orion.editor.TextViewShowOptions - * - * @property {String} viewAnchor the view anchor. The view anchor can be one of these values: - *

    - *

      - *
    • "top" - align the selection to the top of the view client area.
    • - *
    • "bottom" - align the selection to the bottom of the view client area.
    • - *
    • "center" - align the selection to the center of the view client area.
    • - *
    • by default - align the selection to the top or bottom of the client area depending on whether the caret is above or below the client area respectively.
    • - *
    - *

    - * @property {Number} [viewAnchorOffset=0] an offset from the view anchor. The offset is a percentage of the client area height and it is clamped to [0-1] range. - * @property {String} [selectionAnchor=caret] the selection anchor. The seleciton anchor can be one of these values: - *

    - *

      - *
    • "top" - align the top of the selection to the view anchor.
    • - *
    • "bottom" - align the bottom of the selection to the view anchor.
    • - *
    • "center" - align the center of the selection to the view anchor.
    • - *
    • by default - align the top or bottom of the selection to the view anchor depending on whether the caret is at the start or end of the selection.
    • - *
    - *

    - * @property {String} [scrollPolicy] the scroll policy. The scroll policy can be one of these values: - *

    - *

      - *
    • "always" - always scroll vertically to the desired pixel offset even if the caret is already visible.
    • - *
    • by default - only scroll if the caret is not visible.
    • - *
    - *

    + * @name orion.editor.StyleRange + * + * @property {Number} start The start character offset, relative to the document, where the style should be applied. + * @property {Number} end The end character offset (exclusive), relative to the document, where the style should be applied. + * @property {orion.editor.Style} style The style for the range. */ /** - * Sets the text view selection. - *

    - * The selection is defined by a start and end character offset relative to the - * document. The character at end offset is not included in the selection. - *

    - *

    - * The caret is always placed at the end offset. The start offset can be - * greater than the end offset to place the caret at the beginning of the - * selection. - *

    + * @class This is the event sent when the text view needs the style information for a line. *

    - * Clamps out of range offsets. - *

    + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#event:onLineStyle} + *

    + * @name orion.editor.LineStyleEvent * - * @param {Number} start the start offset of the selection - * @param {Number} end the end offset of the selection - * @param {Boolean|Number|orion.editor.TextViewShowOptions} [show=true] - * if true, the view will scroll the minimum amount necessary to show the caret location. If - * show is a Number, the view will scroll the minimum amount necessary to show the caret location plus a - * percentage of the client area height. The parameter is clamped to the [0,1] range. In either case, the view will only scroll - * if the new caret location is not visible already. The show parameter can also be a orion.editor.TextViewShowOptions object. See - * {@link orion.editor.TextViewShowOptions} for further information in how the options can be used to control the scrolling behavior. - * @param {Function} [callback] if callback is specified and scrollAnimation is not zero, view scrolling is animated and - * the callback is called when the animation is done. Otherwise, callback is callback right away. + * @property {orion.editor.TextView} textView The text view. + * @property {Number} lineIndex The line index. + * @property {String} lineText The line text. + * @property {Number} lineStart The character offset, relative to document, of the first character in the line. + * @property {orion.editor.Style} style The style for the entire line (output argument). + * @property {orion.editor.StyleRange[]} ranges An array of style ranges for the line (output argument). + */ + /** + * This event is sent when the text view needs the style information for a line. * - * @see orion.editor.TextView#getSelection + * @event + * @param {orion.editor.LineStyleEvent} lineStyleEvent the event */ - setSelection: function (start, end, show, callback) { - var caret = start > end; - if (caret) { - var tmp = start; - start = end; - end = tmp; - } - var charCount = this._model.getCharCount(); - start = Math.max(0, Math.min (start, charCount)); - end = Math.max(0, Math.min (end, charCount)); - var selection = new Selection(start, end, caret); - this._setSelection(selection, show === undefined || show, true, callback); - }, - setSelections: function (ranges, show, callback) { - var selections = this._rangesToSelections(ranges); - this._setSelection(selections, show === undefined || show, true, callback); + onLineStyle: function(lineStyleEvent) { + return this.dispatchEvent(lineStyleEvent); }, /** - * Replaces the text in the given range with the given text. - *

    - * The character at the end offset is not replaced. - *

    + * @class This is the event sent for all keyboard events. *

    - * When both start and end parameters - * are not specified, the text view places the caret at the beginning - * of the document and scrolls to make it visible. + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#event:onKeyDown}
    + * {@link orion.editor.TextView#event:onKeyPress}
    + * {@link orion.editor.TextView#event:onKeyUp}
    *

    + * @name orion.editor.KeyEvent + * + * @property {String} type The type of event. + * @property {DOMEvent} event The key DOM event. + * @property {Boolean} defaultPrevented Determines whether the user agent context menu should be shown. It is shown by default. + * @property {Function} preventDefault If called prevents the user agent context menu from showing. + */ + /** + * This event is sent for key down events. * - * @param {String} text the new text. - * @param {Number} [start=0] the start offset of text range. - * @param {Number} [end=char count] the end offset of text range. - * @param {Boolean|Number|orion.editor.TextViewShowOptions} [show=true] - * if true, the view will scroll the minimum amount necessary to show the caret location. If - * show is a Number, the view will scroll the minimum amount necessary to show the caret location plus a - * percentage of the client area height. The parameter is clamped to the [0,1] range. In either case, the view will only scroll - * if the new caret location is not visible already. The show parameter can also be a orion.editor.TextViewShowOptions object. See - * {@link orion.editor.TextViewShowOptions} for further information in how the options can be used to control the scrolling behavior. - * @param {Function} [callback] if callback is specified and scrollAnimation is not zero, view scrolling is animated and - * the callback is called when the animation is done. Otherwise, callback is callback right away. + * @event + * @param {orion.editor.KeyEvent} keyEvent the event + */ + onKeyDown: function(keyEvent) { + return this.dispatchEvent(keyEvent); + }, + /** + * This event is sent for key press events. Key press events are only sent + * for printable characters. * - * @see orion.editor.TextView#getText + * @event + * @param {orion.editor.KeyEvent} keyEvent the event */ - setText: function (text, start, end, show, callback) { - var isSingle = typeof text === "string"; //$NON-NLS-1$ - var reset = start === undefined && end === undefined && isSingle; - var edit; - if (isSingle) { - if (start === undefined) { start = 0; } - if (end === undefined) { end = this._model.getCharCount(); } - edit = {text: text, selection: [new Selection(start, end, false)]}; - } else { - edit = text; - edit.selection = this._rangesToSelections(edit.selection); - } - edit._code = true; - if (reset) { - this._variableLineHeight = false; - } - this._modifyContent(edit, !reset, show === undefined || show, callback); - if (reset) { - /* - * Bug in Firefox. For some reason, the caret does not show after the - * view is refreshed. The fix is to toggle the contentEditable state and - * force the clientDiv to loose and receive focus if it is focused. - */ - if (util.isFirefox < 13) { - this._fixCaret(); - } - } + onKeyPress: function(keyEvent) { + return this.dispatchEvent(keyEvent); }, /** - * Sets the top index. + * This event is sent for key up events. + * + * @event + * @param {orion.editor.KeyEvent} keyEvent the event + */ + onKeyUp: function(keyEvent) { + return this.dispatchEvent(keyEvent); + }, + /** + * @class This is the event sent when the text in the model has changed. *

    - * The top index is the line that is currently at the top of the text view. This - * line may be partially visible depending on the vertical scroll of the view. + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#event:onModelChanged}
    + * {@link orion.editor.TextModel#onChanged} *

    + * @name orion.editor.ModelChangedEvent + * + * @property {Number} start The character offset in the model where the change has occurred. + * @property {Number} removedCharCount The number of characters removed from the model. + * @property {Number} addedCharCount The number of characters added to the model. + * @property {Number} removedLineCount The number of lines removed from the model. + * @property {Number} addedLineCount The number of lines added to the model. + */ + /** + * This event is sent when the text in the model has changed. * - * @param {Number} topIndex the index of the top line. - * @param {Function} [callback] if callback is specified and scrollAnimation is not zero, view scrolling is animated and - * the callback is called when the animation is done. Otherwise, callback is callback right away. - * - * @see orion.editor.TextView#getBottomIndex - * @see orion.editor.TextView#getTopIndex + * @event + * @param {orion.editor.ModelChangedEvent} modelChangedEvent the event */ - setTopIndex: function(topIndex, callback) { - if (!this._clientDiv) { return; } - this._scrollViewAnimated(0, this._getLinePixel(Math.max(0, topIndex)) - this._getScroll().y, callback); + onModelChanged: function(modelChangedEvent) { + return this.dispatchEvent(modelChangedEvent); }, /** - * Sets the top pixel. + * @class This is the event sent when the text in the model is about to change. *

    - * The top pixel is the pixel position that is currently at - * the top edge of the view. This position is relative to the - * beginning of the document. + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#event:onModelChanging}
    + * {@link orion.editor.TextModel#onChanging} *

    + * @name orion.editor.ModelChangingEvent + * + * @property {String} text The text that is about to be inserted in the model. + * @property {Number} start The character offset in the model where the change will occur. + * @property {Number} removedCharCount The number of characters being removed from the model. + * @property {Number} addedCharCount The number of characters being added to the model. + * @property {Number} removedLineCount The number of lines being removed from the model. + * @property {Number} addedLineCount The number of lines being added to the model. + */ + /** + * This event is sent when the text in the model is about to change. * - * @param {Number} pixel the top pixel. - * @param {Function} [callback] if callback is specified and scrollAnimation is not zero, view scrolling is animated and - * the callback is called when the animation is done. Otherwise, callback is callback right away. - * - * @see orion.editor.TextView#getBottomPixel - * @see orion.editor.TextView#getTopPixel - * @see orion.editor.TextView#convert + * @event + * @param {orion.editor.ModelChangingEvent} modelChangingEvent the event */ - setTopPixel: function(pixel, callback) { - if (!this._clientDiv) { return; } - this._scrollViewAnimated(0, Math.max(0, pixel) - this._getScroll().y, callback); + onModelChanging: function(modelChangingEvent) { + return this.dispatchEvent(modelChangingEvent); }, /** - * Scrolls the selection into view if needed. - * - * @param {Number|orion.editor.TextViewShowOptions} [show=0] - * If show is a Number, the view will scroll the minimum amount necessary to show the caret location plus a - * percentage of the client area height. The parameter is clamped to the [0,1] range. The view will only scroll - * if the new caret location is not visible already. The show parameter can also be a orion.editor.TextViewShowOptions object. See - * {@link orion.editor.TextViewShowOptions} for further information in how the options can be used to control the scrolling behavior. - * @param {Function} [callback] if callback is specified and scrollAnimation is not zero, view scrolling is animated and - * the callback is called when the animation is done. Otherwise, callback is callback right away. - * - * @returns {Boolean} true if the view was scrolled. + * @class This is the event sent when the text is modified by the text view. + *

    + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#event:onModify} + *

    + * @name orion.editor.ModifyEvent + */ + /** + * This event is sent when the text view has changed text in the model. + *

    + * If the text is changed directly through the model API, this event + * is not sent. + *

    * - * @see orion.editor.TextView#getSelection - * @see orion.editor.TextView#setSelection - * @see orion.editor.TextView#setCaretOffset + * @event + * @param {orion.editor.ModifyEvent} modifyEvent the event */ - showSelection: function(show, callback) { - return this._showCaret(show ? false : true, callback, show); - }, - update: function(styleChanged, sync) { - if (!this._clientDiv) { return; } - if (styleChanged || this._metrics.invalid) { - this._updateStyle(); - } - if (sync === undefined || sync) { - this._update(); - } else { - this._queueUpdate(); - } - }, - - /**************************************** Event handlers *********************************/ - _handleRootMouseDown: function (e) { - this._cancelCheckSelection(); - if (this._ignoreEvent(e)) { return; } - if (util.isFirefox < 13 && e.which === 1) { - this._clientDiv.contentEditable = false; - (this._overlayDiv || this._clientDiv).draggable = true; - this._ignoreBlur = true; - } - - /* Prevent clicks outside of the client div from taking focus away. */ - var topNode = this._overlayDiv || this._clientDiv; - /* Use view div on IE 8 otherwise it is not possible to scroll. */ - if (util.isIE < 9) { topNode = this._viewDiv; } - var temp = e.target ? e.target : e.srcElement; - while (temp) { - if (topNode === temp) { - return; - } - if (temp.className && temp.className.indexOf("textViewFind") !== -1) { //$NON-NLS-1$ - return; - } - temp = temp.parentNode; - } - if (e.preventDefault) { e.preventDefault(); } - if (e.stopPropagation){ e.stopPropagation(); } - if (!this._isW3CEvents) { - /* - * In IE 8 is not possible to prevent the default handler from running - * during mouse down event using usual API. The workaround is to give - * focus back to the client div. - */ - var that = this; - var win = this._getWindow(); - win.setTimeout(function() { - that._clientDiv.focus(); - }, 0); - } - }, - _handleRootMouseUp: function (e) { - if (this._ignoreEvent(e)) { return; } - if (util.isFirefox < 13 && e.which === 1) { - this._clientDiv.contentEditable = true; - (this._overlayDiv || this._clientDiv).draggable = false; - } - if (util.isFirefox && e.which === 1) { - - /* - * Bug in Firefox. For some reason, Firefox stops showing the caret - * in some cases. For example when the user cancels a drag operation - * by pressing ESC. The fix is to detect that the drag operation was - * cancelled, toggle the contentEditable state and force the clientDiv - * to loose and receive focus if it is focused. - */ - this._fixCaret(); - this._ignoreBlur = false; - } - }, - _handleBlur: function () { - this._cancelCheckSelection(); - if (this._ignoreBlur) { return; } - this._commitIME(); - this._hasFocus = false; - /* - * Bug in IE 8 and earlier. For some reason when text is deselected - * the overflow selection at the end of some lines does not get redrawn. - * The fix is to create a DOM element in the body to force a redraw. - */ - if (util.isIE < 9) { - if (!this._getSelections()[0].isEmpty()) { - var rootDiv = this._rootDiv; - var child = util.createElement(rootDiv.ownerDocument, "div"); //$NON-NLS-1$ - rootDiv.appendChild(child); - rootDiv.removeChild(child); - } - } - if (this._cursorDiv) { - this._cursorDiv.style.display = "none"; //$NON-NLS-1$ - } - if (this._domSelection) { - this._domSelection.forEach(function(domSelection) { domSelection.update(); }); - /* Clear browser selection if selection is within clientDiv */ - var temp; - var win = this._getWindow(); - var doc = this._parent.ownerDocument; - if (win.getSelection) { - var sel = win.getSelection(); - temp = sel.anchorNode; - while (temp) { - if (temp === this._clientDiv) { - if (sel.rangeCount > 0) { sel.removeAllRanges(); } - break; - } - temp = temp.parentNode; - } - } else if (doc.selection) { - this._ignoreSelect = false; - temp = doc.selection.createRange().parentElement(); - while (temp) { - if (temp === this._clientDiv) { - doc.selection.empty(); - break; - } - temp = temp.parentNode; - } - this._ignoreSelect = true; - } - } - if (!this._ignoreFocus) { - this.onBlur({type: "Blur"}); //$NON-NLS-1$ - } + onModify: function(modifyEvent) { + return this.dispatchEvent(modifyEvent); }, - _handleCompositionStart: function (e) { - if (this._ignoreEvent(e)) { return; } - if (this._imeTimeout) { - var win = this._getWindow(); - win.clearTimeout(this._imeTimeout); - this._imeTimeout = null; - } - if (this._imeText) { - this._commitIME(this._imeText); - this._imeText = null; - } - this._startIME(); - if (this._mutationObserver) { - this._mutationObserver.disconnect(); - this._mutationObserver = null; - } + onMouseDown: function(mouseEvent) { + return this.dispatchEvent(mouseEvent); }, - _handleCompositionUpdate: function(e) { - if (this._ignoreEvent(e)) { return; } - this._imeText = e.data; + onMouseUp: function(mouseEvent) { + return this.dispatchEvent(mouseEvent); }, - _handleCompositionEnd: function (e) { - if (this._ignoreEvent(e)) { return; } - this._imeText = e.data; - var win = this._getWindow(); - this._imeTimeout = win.setTimeout(function() { - this._commitIME(this._imeText); - this._imeText = this._imeTimeout = null; - }.bind(this), 0); + onMouseMove: function(mouseEvent) { + return this.dispatchEvent(mouseEvent); }, - _handleContextMenu: function (e) { - if (this._ignoreEvent(e)) { return; } - if (util.isIE && this._lastMouseButton === 3) { - // We need to update the DOM selection, because on - // right-click the caret moves to the mouse location. - // See bug 366312 and 376508. - this._updateDOMSelection(); - } - var preventDefault = false; - if (this.isListening("ContextMenu")) { //$NON-NLS-1$ - var evt = this._createMouseEvent("ContextMenu", e); //$NON-NLS-1$ - evt.screenX = e.screenX; - evt.screenY = e.screenY; - this.onContextMenu(evt); - preventDefault = evt.defaultPrevented; - } else if (util.isMac && util.isFirefox && e.button === 0) { - // hack to prevent CTRL+Space from showing the browser context menu - preventDefault = true; - } - if (preventDefault) { - if (e.preventDefault) { e.preventDefault(); } - return false; - } else { - this._contextMenuOpen = true; - if (util.isFirefox) { - this._checkSelectionChange = true; - this._pollSelectionChange(true); - } - } + onMouseOver: function(mouseEvent) { + return this.dispatchEvent(mouseEvent); }, - _handleCopy: function (e) { - this._cancelCheckSelection(); - if (this._ignoreEvent(e)) { return; } - if (this._ignoreCopy) { return; } - if (this._doCopy(e)) { - if (e.preventDefault) { e.preventDefault(); } - return false; - } + onMouseOut: function(mouseEvent) { + return this.dispatchEvent(mouseEvent); }, - _handleCut: function (e) { - this._cancelCheckSelection(); - if (this._ignoreEvent(e)) { return; } - if (this._doCut(e)) { - if (e.preventDefault) { e.preventDefault(); } - return false; - } + onTouchStart: function(touchEvent) { + return this.dispatchEvent(touchEvent); }, - _handleDataModified: function(e) { - if (this._ignoreEvent(e)) { return; } - this._startIME(); + onTouchMove: function(touchEvent) { + return this.dispatchEvent(touchEvent); }, - _handleDblclick: function (e) { - if (this._ignoreEvent(e)) { return; } - var time = e.timeStamp ? e.timeStamp : new Date().getTime(); - this._lastMouseTime = time; - if (this._clickCount !== 2) { - this._clickCount = 2; - this._handleMouse(e); - } + onTouchEnd: function(touchEvent) { + return this.dispatchEvent(touchEvent); }, - _handleDragStart: function (e) { - if (this._ignoreEvent(e)) { return; } - if (util.isFirefox < 13) { - var that = this; - var win = this._getWindow(); - win.setTimeout(function() { - that._clientDiv.contentEditable = true; - that._clientDiv.draggable = false; - that._ignoreBlur = false; - }, 0); - } - if (this.isListening("DragStart") && this._dragOffset !== -1) { //$NON-NLS-1$ - this._isMouseDown = false; - this.onDragStart(this._createMouseEvent("DragStart", e)); //$NON-NLS-1$ - this._dragOffset = -1; - } else { - if (e.preventDefault) { e.preventDefault(); } - return false; - } + onOptions: function(optionsEvent) { + return this.dispatchEvent(optionsEvent); }, - _handleDrag: function (e) { - if (this._ignoreEvent(e)) { return; } - if (this.isListening("Drag")) { //$NON-NLS-1$ - this.onDrag(this._createMouseEvent("Drag", e)); //$NON-NLS-1$ - } + /** + * @class This is the event sent when the selection changes in the text view. + *

    + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#event:onSelection} + *

    + * @name orion.editor.SelectionEvent + * + * @property {orion.editor.Selection} oldValue The old selection. + * @property {orion.editor.Selection} newValue The new selection. + */ + /** + * This event is sent when the text view selection has changed. + * + * @event + * @param {orion.editor.SelectionEvent} selectionEvent the event + */ + onSelection: function(selectionEvent) { + return this.dispatchEvent(selectionEvent); }, - _handleDragEnd: function (e) { - if (this._ignoreEvent(e)) { return; } - this._dropTarget = false; - this._dragOffset = -1; - if (this.isListening("DragEnd")) { //$NON-NLS-1$ - this.onDragEnd(this._createMouseEvent("DragEnd", e)); //$NON-NLS-1$ - } - if (util.isFirefox < 13) { - this._fixCaret(); - /* - * Bug in Firefox. For some reason, Firefox stops showing the caret when the - * selection is dropped onto itself. The fix is to detected the case and - * call fixCaret() a second time. - */ - if (e.dataTransfer.dropEffect === "none" && !e.dataTransfer.mozUserCancelled) { //$NON-NLS-1$ - this._fixCaret(); - } - } + /** + * @class This is the event sent when the text view scrolls. + *

    + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#event:onScroll} + *

    + * @name orion.editor.ScrollEvent + * + * @property {Object} oldValue The old scroll {x,y}. + * @property {Object} newValue The new scroll {x,y}. + */ + /** + * This event is sent when the text view scrolls vertically or horizontally. + * + * @event + * @param {orion.editor.ScrollEvent} scrollEvent the event + */ + onScroll: function(scrollEvent) { + return this.dispatchEvent(scrollEvent); }, - _handleDragEnter: function (e) { - if (this._ignoreEvent(e)) { return; } - var prevent = true; - this._dropTarget = true; - if (this.isListening("DragEnter")) { //$NON-NLS-1$ - prevent = false; - this.onDragEnter(this._createMouseEvent("DragEnter", e)); //$NON-NLS-1$ - } - /* - * Webkit will not send drop events if this event is not prevented, as spec in HTML5. - * Firefox and IE do not follow this spec for contentEditable. Note that preventing this - * event will result is loss of functionality (insertion mark, etc). - */ - if (util.isWebkit || prevent) { - if (e.preventDefault) { e.preventDefault(); } - return false; - } + /** + * @class This is the event sent when the text is about to be modified by the text view. + *

    + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#event:onVerify} + *

    + * @name orion.editor.VerifyEvent + * + * @property {String} text The text being inserted. + * @property {Number} start The start offset of the text range to be replaced. + * @property {Number} end The end offset (exclusive) of the text range to be replaced. + */ + /** + * This event is sent when the text view is about to change text in the model. + *

    + * If the text is changed directly through the model API, this event + * is not sent. + *

    + *

    + * Listeners are allowed to change these parameters. Setting text to null + * or undefined stops the change. + *

    + * + * @event + * @param {orion.editor.VerifyEvent} verifyEvent the event + */ + onVerify: function(verifyEvent) { + return this.dispatchEvent(verifyEvent); }, - _handleDragOver: function (e) { - if (this._ignoreEvent(e)) { return; } - var prevent = true; - if (this.isListening("DragOver")) { //$NON-NLS-1$ - prevent = false; - this.onDragOver(this._createMouseEvent("DragOver", e)); //$NON-NLS-1$ - } - /* - * Webkit will not send drop events if this event is not prevented, as spec in HTML5. - * Firefox and IE do not follow this spec for contentEditable. Note that preventing this - * event will result is loss of functionality (insertion mark, etc). - */ - if (util.isWebkit || prevent) { - if (prevent) { e.dataTransfer.dropEffect = "none"; } //$NON-NLS-1$ - if (e.preventDefault) { e.preventDefault(); } - return false; - } + /** + * @class This is the event sent when the text view is focused. + *

    + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#event:onFocus}
    + *

    + * @name orion.editor.FocusEvent + */ + /** + * This event is sent when the text view is focused. + * + * @event + * @param {orion.editor.FocusEvent} focusEvent the event + */ + onFocus: function(focusEvent) { + return this.dispatchEvent(focusEvent); }, - _handleDragLeave: function (e) { - if (this._ignoreEvent(e)) { return; } - this._dropTarget = false; - if (this.isListening("DragLeave")) { //$NON-NLS-1$ - this.onDragLeave(this._createMouseEvent("DragLeave", e)); //$NON-NLS-1$ - } + /** + * @class This is the event sent when the text view goes out of focus. + *

    + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#event:onBlur}
    + *

    + * @name orion.editor.BlurEvent + */ + /** + * This event is sent when the text view goes out of focus. + * + * @event + * @param {orion.editor.BlurEvent} blurEvent the event + */ + onBlur: function(blurEvent) { + return this.dispatchEvent(blurEvent); }, - _handleDrop: function (e) { - if (this._ignoreEvent(e)) { return; } - this._dropTarget = false; - if (this.isListening("Drop")) { //$NON-NLS-1$ - this.onDrop(this._createMouseEvent("Drop", e)); //$NON-NLS-1$ - } - /* - * This event must be prevented otherwise the user agent will modify - * the DOM. Note that preventing the event on some user agents (i.e. IE) - * indicates that the operation is cancelled. This causes the dropEffect to - * be set to none in the dragend event causing the implementor to not execute - * the code responsible by the move effect. - */ - if (e.preventDefault) { e.preventDefault(); } - return false; + /** + * Replaces the selection with the text on the clipboard or, if there is no selection, inserts the text at the current caret offset. + *

    + * If the single mode is on and the clipboard text contains more than one line, all lines will be concatenated. + *

    + * @returns {Boolean} true if the operation succeded. + * @since 10.0 + */ + paste: function() { + if (!this._clientDiv) { return false; } + return this._doPaste(); }, - _handleFocus: function () { - this._hasFocus = true; - if (util.isIOS && this._lastTouchOffset !== undefined) { - this.setCaretOffset(this._lastTouchOffset, true); - this._lastTouchOffset = undefined; - } else { - this._updateDOMSelection(); - } - if (this._cursorDiv) { - this._cursorDiv.style.display = "block"; //$NON-NLS-1$ - } - if (this._domSelection) { - this._domSelection.forEach(function(domSelection) { domSelection.update(); }); - } - if (!this._ignoreFocus) { - this.onFocus({type: "Focus"}); //$NON-NLS-1$ + /** + * Redraws the entire view, including rulers. + * + * @see orion.editor.TextView#redrawLines + * @see orion.editor.TextView#redrawRange + * @see orion.editor.TextView#setRedraw + */ + redraw: function() { + if (this._redrawCount > 0) { return; } + var lineCount = this._model.getLineCount(); + this.redrawRulers(0, lineCount); + this.redrawLines(0, lineCount); + }, + redrawRulers: function(startLine, endLine) { + if (this._redrawCount > 0) { return; } + var rulers = this.getRulers(); + for (var i = 0; i < rulers.length; i++) { + this.redrawLines(startLine, endLine, rulers[i]); } }, - _handleKeyDown: function (e) { - this._cancelCheckSelection(); - if (this._ignoreEvent(e)) { return; } - if (this.isListening("KeyDown")) { //$NON-NLS-1$ - var keyEvent = this._createKeyEvent("KeyDown", e); //$NON-NLS-1$ - this.onKeyDown(keyEvent); //$NON-NLS-1$ - if (keyEvent.defaultPrevented) { - /* - * Feature in Firefox. Keypress events still happen even if the keydown event - * was prevented. The fix is to remember that keydown was prevented and prevent - * the keypress ourselves. - */ - if (util.isFirefox) { - this._keyDownPrevented = true; + /** + * Redraws the text in the given line range. + *

    + * The line at the end index is not redrawn. + *

    + * + * @param {Number} [startLine=0] the start line + * @param {Number} [endLine=line count] the end line + * + * @see orion.editor.TextView#redraw + * @see orion.editor.TextView#redrawRange + * @see orion.editor.TextView#setRedraw + */ + redrawLines: function(startLine, endLine, ruler) { + if (this._redrawCount > 0) { return; } + if (startLine === undefined) { startLine = 0; } + if (endLine === undefined) { endLine = this._model.getLineCount(); } + if (startLine === endLine) { return; } + var div = this._clientDiv; + if (!div) { return; } + if (ruler) { + var divRuler = this._getRulerParent(ruler); + div = divRuler.firstChild; + while (div) { + if (div._ruler === ruler) { + break; } - e.preventDefault(); - return; + div = div.nextSibling; } } - var modifier = false; - switch (e.keyCode) { - case 16: /* Shift */ - case 17: /* Control */ - case 18: /* Alt */ - case 91: /* Command */ - modifier = true; - break; - default: - this._setLinksVisible(false); - } - if (e.keyCode === 229) { - if (this._readonly) { - if (e.preventDefault) { e.preventDefault(); } - return false; - } - var startIME = true; - - /* - * Bug in Safari. Some Control+key combinations send key events - * with keyCode equals to 229. This is unexpected and causes the - * view to start an IME composition. The fix is to ignore these - * events. - */ - if (util.isSafari && util.isMac) { - if (e.ctrlKey) { - startIME = false; - e.keyCode = 0x81; - } - } - if (startIME) { - this._startIME(); - } + if (ruler) { + div.rulerChanged = true; } else { - if (!modifier) { - this._commitIME(); - } - } - /* - * Feature in Firefox. When a key is held down the browser sends - * right number of keypress events but only one keydown. This is - * unexpected and causes the view to only execute an action - * just one time. The fix is to ignore the keydown event and - * execute the actions from the keypress handler. - * Note: This only happens on the Mac and Linux (Firefox 3.6). - * - * Feature in Opera < 12.16. Opera sends keypress events even for non-printable - * keys. The fix is to handle actions in keypress instead of keydown. - */ - if (((util.isMac || util.isLinux) && util.isFirefox < 4) || util.isOpera < 12.16) { - this._keyDownEvent = e; - return true; - } - - if (this._doAction(e)) { - if (e.preventDefault) { - e.preventDefault(); - e.stopPropagation(); - } else { - e.cancelBubble = true; - e.returnValue = false; - e.keyCode = 0; - } - return false; - } - }, - _handleKeyPress: function (e) { - if (this._ignoreEvent(e)) { return; } - /* - * Feature in Firefox. Keypress events still happen even if the keydown event - * was prevented. The fix is to remember that keydown was prevented and prevent - * the keypress ourselves. - */ - if (this._keyDownPrevented) { - if (e.preventDefault) { - e.preventDefault(); - e.stopPropagation(); - } - this._keyDownPrevented = undefined; - return; - } - /* - * Feature in Embedded WebKit. Embedded WekKit on Mac runs in compatibility mode and - * generates key press events for these Unicode values (Function keys). This does not - * happen in Safari or Chrome. The fix is to ignore these key events. - */ - if (util.isMac && util.isWebkit) { - if ((0xF700 <= e.keyCode && e.keyCode <= 0xF7FF) || e.keyCode === 13 || e.keyCode === 8) { - if (e.preventDefault) { e.preventDefault(); } - return false; + if (this._lineHeight) { + this._resetLineHeight(startLine, endLine); } } - if (((util.isMac || util.isLinux) && util.isFirefox < 4) || util.isOpera < 12.16) { - if (this._doAction(this._keyDownEvent)) { - if (e.preventDefault) { e.preventDefault(); } - return false; - } + var imeLineIndex = -1; + if (!ruler && this._imeOffset !== -1) { + imeLineIndex = this._model.getLineAtOffset(this._imeOffset); } - var ctrlKey = util.isMac ? e.metaKey : e.ctrlKey; - if (e.charCode !== undefined) { - if (ctrlKey) { - switch (e.charCode) { - /* - * In Firefox and Safari if ctrl+v, ctrl+c ctrl+x is canceled - * the clipboard events are not sent. The fix to allow - * the browser to handles these key events. - */ - case 99://c - case 118://v - case 120://x - return true; + if (!ruler || ruler.getOverview() === "page") { //$NON-NLS-1$ + var child = div.firstChild; + while (child) { + var lineIndex = child.lineIndex; + if (startLine <= lineIndex && lineIndex < endLine && lineIndex !== imeLineIndex) { + child.lineChanged = true; } + child = child.nextSibling; } } - if (this.isListening("KeyPress")) { //$NON-NLS-1$ - var keyEvent = this._createKeyEvent("KeyPress", e); //$NON-NLS-1$ - this.onKeyPress(keyEvent); //$NON-NLS-1$ - if (keyEvent.defaultPrevented) { - e.preventDefault(); - return; - } - } - if (this._doAction(e)) { - if (e.preventDefault) { - e.preventDefault(); - e.stopPropagation(); - } else { - e.cancelBubble = true; - e.returnValue = false; - e.keyCode = 0; - } - return false; - } - var ignore = false; - if (util.isMac) { - if (e.ctrlKey || e.metaKey) { ignore = true; } - } else { - if (util.isFirefox) { - //Firefox clears the state mask when ALT GR generates input - if (e.ctrlKey || e.altKey) { ignore = true; } - } else { - //IE and Chrome only send ALT GR when input is generated - if (e.ctrlKey ^ e.altKey) { ignore = true; } - } - } - if (!ignore) { - var key = util.isOpera ? e.which : (e.charCode !== undefined ? e.charCode : e.keyCode); - if (key > 31) { - this._doContent(String.fromCharCode (key)); - if (e.preventDefault) { e.preventDefault(); } - return false; - } - } - }, - _handleDocKeyUp: function (e) { - var ctrlKey = util.isMac ? e.metaKey : e.ctrlKey; - if (!ctrlKey) { - this._setLinksVisible(false); - } - }, - _handleKeyUp: function (e) { - if (this._ignoreEvent(e)) { return; } - if (this.isListening("KeyUp")) { //$NON-NLS-1$ - var keyEvent = this._createKeyEvent("KeyUp", e); //$NON-NLS-1$ - this.onKeyUp(keyEvent); //$NON-NLS-1$ - if (keyEvent.defaultPrevented) { - e.preventDefault(); - return; + if (!ruler) { + if (!this._wrapMode) { + if (startLine <= this._maxLineIndex && this._maxLineIndex < endLine) { + this._checkMaxLineIndex = this._maxLineIndex; + this._maxLineIndex = -1; + this._maxLineWidth = 0; + } } } - this._handleDocKeyUp(e); - // don't commit for space (it happens during JP composition) - if (e.keyCode === 13) { - this._commitIME(); - } - }, - _handleLinkClick: function (e) { - var ctrlKey = util.isMac ? e.metaKey : e.ctrlKey; - if (!ctrlKey) { - if (e.preventDefault) { e.preventDefault(); } - return false; - } + this.dispatchEvent({type: "Redraw", startLine: startLine, endLine: endLine, ruler: ruler}); //$NON-NLS-1$ + this._queueUpdate(); }, - _handleMouse: function (e) { - var win = this._getWindow(); - var result = true; - var target = win; - if (util.isIE || (util.isFirefox && !this._overlayDiv)) { target = this._clientDiv; } - if (this._overlayDiv) { - if (this._hasFocus) { - this._ignoreFocus = true; - } - var that = this; - win.setTimeout(function () { - that.focus(); - that._ignoreFocus = false; - }, 0); - } - var extend = e.shiftKey; - var block = e.altKey; - var add = util.isMac ? e.metaKey : e.ctrlKey; - this._blockSelection = this._doubleClickSelection = null; - if (this._clickCount === 1) { - var drag = (!util.isOpera || util.isOpera >= 12.16) && this._hasFocus && this.isListening("DragStart"); //$NON-NLS-1$ - result = this._setSelectionTo(e.clientX, e.clientY, true, extend, add, drag); - if (result) { this._setGrab(target); } - } else { - /* - * Feature in IE8 and older, the sequence of events in the IE8 event model - * for a doule-click is: - * - * down - * up - * up - * dblclick - * - * Given that the mouse down/up events are not balanced, it is not possible to - * grab on mouse down and ungrab on mouse up. The fix is to grab on the first - * mouse down and ungrab on mouse move when the button 1 is not set. - */ - if (this._isW3CEvents) { this._setGrab(target); } - - this._setSelectionTo(e.clientX, e.clientY, true, extend, add, false); - this._doubleClickSelection = Selection.editing(this._getSelections()); + /** + * Redraws the text in the given range. + *

    + * The character at the end offset is not redrawn. + *

    + * + * @param {Number} [start=0] the start offset of text range + * @param {Number} [end=char count] the end offset of text range + * + * @see orion.editor.TextView#redraw + * @see orion.editor.TextView#redrawLines + * @see orion.editor.TextView#setRedraw + */ + redrawRange: function(start, end) { + if (this._redrawCount > 0) { return; } + var model = this._model; + if (start === undefined) { start = 0; } + if (end === undefined) { end = model.getCharCount(); } + var startLine = model.getLineAtOffset(start); + var endLine = model.getLineAtOffset(Math.max(start, end - 1)) + 1; + this.redrawLines(startLine, endLine); + }, + /** + * Removes a key mode from the text view. + * + * @param {orion.editor.KeyMode} mode the key mode. + */ + removeKeyMode: function (mode) { + var keyModes = this._keyModes; + for (var i=0; i + * See:
    + * {@link orion.editor.TextView}
    + * {@link orion.editor.TextView#setAction} + *

    + * @name orion.editor.ActionDescription + * + * @property {String} [name] the name to be used when showing the action as text. + */ + /** + * Associates an application defined handler to an action ID. + *

    + * If the action ID is a predefined action, the given handler executes before + * the default action handler. If the given handler returns true, the + * default action handler is not called. + *

    + * + * @param {String} actionID the action ID. + * @param {Function} handler the action handler. + * @param {orion.editor.ActionDescription} [actionDescription=undefined] the action description. + * + * @see orion.editor.TextView#getActions + * @see orion.editor.TextView#invokeAction + */ + setAction: function(actionID, handler, actionDescription) { + if (!actionID) { return; } + var actions = this._actions; + var action = actions[actionID]; + if (!action) { + action = actions[actionID] = {}; } - - // For middle click we always need getTime(). See _getClipboardText(). - var time = button !== 2 && e.timeStamp ? e.timeStamp : new Date().getTime(); - var timeDiff = time - this._lastMouseTime; - var deltaX = Math.abs(this._lastMouseX - e.clientX); - var deltaY = Math.abs(this._lastMouseY - e.clientY); - var sameButton = this._lastMouseButton === button; - this._lastMouseX = e.clientX; - this._lastMouseY = e.clientY; - this._lastMouseTime = time; - this._lastMouseButton = button; - - if (button === 1) { - this._isMouseDown = true; - if (sameButton && timeDiff <= this._clickTime && deltaX <= this._clickDist && deltaY <= this._clickDist) { - this._clickCount++; - } else { - this._clickCount = 1; - } + action.handler = handler; + if (actionDescription !== undefined) { + action.actionDescription = actionDescription; } - if (this.isListening("MouseDown")) { //$NON-NLS-1$ - var mouseEvent = this._createMouseEvent("MouseDown", e); //$NON-NLS-1$ - this.onMouseDown(mouseEvent); - if (mouseEvent.defaultPrevented) { - e.preventDefault(); - return; + }, + /** + * Associates a key binding with the given action ID. Any previous + * association with the specified key binding is overwriten. If the + * action ID is null, the association is removed. + * + * @param {orion.KeyBinding} keyBinding the key binding + * @param {String} actionID the action ID + */ + setKeyBinding: function(keyBinding, actionID) { + this._keyModes[0].setKeyBinding(keyBinding, actionID); + }, + /** + * Sets the caret offset relative to the start of the document. + * + * @param {Number} caret the caret offset relative to the start of the document. + * @param {Boolean|Number|orion.editor.TextViewShowOptions} [show=true] + * if true, the view will scroll the minimum amount necessary to show the caret location. If + * show is a Number, the view will scroll the minimum amount necessary to show the caret location plus a + * percentage of the client area height. The parameter is clamped to the [0,1] range. In either case, the view will only scroll + * if the new caret location is not visible already. The show parameter can also be a orion.editor.TextViewShowOptions object. See + * {@link orion.editor.TextViewShowOptions} for further information in how the options can be used to control the scrolling behavior. + * @param {Function} [callback] if callback is specified and scrollAnimation is not zero, view scrolling is animated and + * the callback is called when the animation is done. Otherwise, callback is callback right away. + * + * @see orion.editor.TextView#getCaretOffset + * @see orion.editor.TextView#setSelection + * @see orion.editor.TextView#getSelection + */ + setCaretOffset: function(offset, show, callback) { + var charCount = this._model.getCharCount(); + offset = Math.max(0, Math.min (offset, charCount)); + var selection = new Selection(offset, offset, false); + this._setSelection (selection, show === undefined || show, true, callback); + }, + /** + * Sets the horizontal pixel. + *

    + * The horizontal pixel is the pixel position that is currently at + * the left edge of the view. This position is relative to the + * beginning of the document. + *

    + * + * @param {Number} pixel the horizontal pixel. + * + * @see orion.editor.TextView#getHorizontalPixel + * @see orion.editor.TextView#convert + */ + setHorizontalPixel: function(pixel) { + if (!this._clientDiv) { return; } + pixel = Math.max(0, pixel); + this._scrollView(pixel - this._getScroll().x, 0); + }, + /** + * Sets whether the view should update the DOM. + *

    + * This can be used to improve the performance. + *

    + * When the flag is set to true, + * the entire view is marked as needing to be redrawn. + * Nested calls to this method are stacked. + *

    + * + * @param {Boolean} redraw the new redraw state + * + * @see orion.editor.TextView#redraw + */ + setRedraw: function(redraw) { + if (redraw) { + if (--this._redrawCount === 0) { + this.redraw(); } + } else { + this._redrawCount++; } - if (button === 1) { - if (this._handleMouse(e) && (util.isIE >= 9 || util.isOpera || util.isChrome || util.isSafari || (util.isFirefox && !this._overlayDiv))) { - if (!this._hasFocus) { - this.focus(); + }, + /** + * Sets the text model of the text view. + * + * @param {orion.editor.TextModel} model the text model of the view. + */ + setModel: function(model) { + if (model === this._model) { return; } + model = model || new mTextModel.TextModel(); + this._model.removeEventListener("preChanging", this._modelListener.onChanging); //$NON-NLS-1$ + this._model.removeEventListener("postChanged", this._modelListener.onChanged); //$NON-NLS-1$ + var oldLineCount = this._model.getLineCount(); + var oldCharCount = this._model.getCharCount(); + var newLineCount = model.getLineCount(); + var newCharCount = model.getCharCount(); + var newText = model.getText(); + var e = { + type: "ModelChanging", //$NON-NLS-1$ + text: newText, + start: 0, + removedCharCount: oldCharCount, + addedCharCount: newCharCount, + removedLineCount: oldLineCount, + addedLineCount: newLineCount + }; + this.onModelChanging(e); + this._model = model; + e = { + type: "ModelChanged", //$NON-NLS-1$ + start: 0, + removedCharCount: oldCharCount, + addedCharCount: newCharCount, + removedLineCount: oldLineCount, + addedLineCount: newLineCount + }; + this.onModelChanged(e); + this._model.addEventListener("preChanging", this._modelListener.onChanging); //$NON-NLS-1$ + this._model.addEventListener("postChanged", this._modelListener.onChanged); //$NON-NLS-1$ + this._reset(); + this._update(); + }, + /** + * Sets the view options for the view. + * + * @param {orion.editor.TextViewOptions} options the view options. + * + * @see orion.editor.TextView#getOptions + */ + setOptions: function (options) { + var defaultOptions = this._defaultOptions(); + for (var option in options) { + if (options.hasOwnProperty(option)) { + var newValue = options[option], oldValue = this["_" + option]; //$NON-NLS-1$ + if (compare(oldValue, newValue)) { continue; } + var update = defaultOptions[option] ? defaultOptions[option].update : null; + if (update) { + update.call(this, newValue); + continue; } - e.preventDefault(); + this["_" + option] = clone(newValue); //$NON-NLS-1$ } } - if (util.isFirefox && this._lastMouseButton === 3) { - // We need to update the DOM selection, because on - // right-click the caret moves to the mouse location. - // See bug 366312 and 376508. - this._updateDOMSelection(); - } + this.onOptions({type: "Options", options: options}); //$NON-NLS-1$ }, - _handleMouseOver: function (e) { - if (this._ignoreEvent(e)) { return; } - if (this._animation) { return; } - if (this.isListening("MouseOver")) { //$NON-NLS-1$ - this.onMouseOver(this._createMouseEvent("MouseOver", e)); //$NON-NLS-1$ + /** + * @class This object describes the selection show options. + *

    + * See:
    + * {@link orion.editor.TextView#setSelection} + * {@link orion.editor.TextView#setCaretOffset} + * {@link orion.editor.TextView#showSelection} + *

    + * @name orion.editor.TextViewShowOptions + * + * @property {String} viewAnchor the view anchor. The view anchor can be one of these values: + *

    + *

      + *
    • "top" - align the selection to the top of the view client area.
    • + *
    • "bottom" - align the selection to the bottom of the view client area.
    • + *
    • "center" - align the selection to the center of the view client area.
    • + *
    • by default - align the selection to the top or bottom of the client area depending on whether the caret is above or below the client area respectively.
    • + *
    + *

    + * @property {Number} [viewAnchorOffset=0] an offset from the view anchor. The offset is a percentage of the client area height and it is clamped to [0-1] range. + * @property {String} [selectionAnchor=caret] the selection anchor. The seleciton anchor can be one of these values: + *

    + *

      + *
    • "top" - align the top of the selection to the view anchor.
    • + *
    • "bottom" - align the bottom of the selection to the view anchor.
    • + *
    • "center" - align the center of the selection to the view anchor.
    • + *
    • by default - align the top or bottom of the selection to the view anchor depending on whether the caret is at the start or end of the selection.
    • + *
    + *

    + * @property {String} [scrollPolicy] the scroll policy. The scroll policy can be one of these values: + *

    + *

      + *
    • "always" - always scroll vertically to the desired pixel offset even if the caret is already visible.
    • + *
    • by default - only scroll if the caret is not visible.
    • + *
    + *

    + */ + /** + * Sets the text view selection. + *

    + * The selection is defined by a start and end character offset relative to the + * document. The character at end offset is not included in the selection. + *

    + *

    + * The caret is always placed at the end offset. The start offset can be + * greater than the end offset to place the caret at the beginning of the + * selection. + *

    + *

    + * Clamps out of range offsets. + *

    + * + * @param {Number} start the start offset of the selection + * @param {Number} end the end offset of the selection + * @param {Boolean|Number|orion.editor.TextViewShowOptions} [show=true] + * if true, the view will scroll the minimum amount necessary to show the caret location. If + * show is a Number, the view will scroll the minimum amount necessary to show the caret location plus a + * percentage of the client area height. The parameter is clamped to the [0,1] range. In either case, the view will only scroll + * if the new caret location is not visible already. The show parameter can also be a orion.editor.TextViewShowOptions object. See + * {@link orion.editor.TextViewShowOptions} for further information in how the options can be used to control the scrolling behavior. + * @param {Function} [callback] if callback is specified and scrollAnimation is not zero, view scrolling is animated and + * the callback is called when the animation is done. Otherwise, callback is callback right away. + * + * @see orion.editor.TextView#getSelection + */ + setSelection: function (start, end, show, callback) { + var caret = start > end; + if (caret) { + var tmp = start; + start = end; + end = tmp; } + var charCount = this._model.getCharCount(); + start = Math.max(0, Math.min (start, charCount)); + end = Math.max(0, Math.min (end, charCount)); + var selection = new Selection(start, end, caret); + this._setSelection(selection, show === undefined || show, true, callback); }, - _handleMouseOut: function (e) { - if (this._ignoreEvent(e)) { return; } - if (this._animation) { return; } - if (this.isListening("MouseOut")) { //$NON-NLS-1$ - this.onMouseOut(this._createMouseEvent("MouseOut", e)); //$NON-NLS-1$ - } + setSelections: function (ranges, show, callback) { + var selections = this._rangesToSelections(ranges); + this._setSelection(selections, show === undefined || show, true, callback); }, - _handleMouseMove: function (e) { - if (this._animation) { return; } - var inClient = this._isClientDiv(e); - if (this.isListening("MouseMove")) { //$NON-NLS-1$ - if (inClient || this._isMouseDown){ - var mouseEvent = this._createMouseEvent("MouseMove", e); //$NON-NLS-1$ - this.onMouseMove(mouseEvent); - if (mouseEvent.defaultPrevented) { - e.preventDefault(); - return; - } - } + /** + * Replaces the text in the given range with the given text. + *

    + * The character at the end offset is not replaced. + *

    + *

    + * When both start and end parameters + * are not specified, the text view places the caret at the beginning + * of the document and scrolls to make it visible. + *

    + * + * @param {String} text the new text. + * @param {Number} [start=0] the start offset of text range. + * @param {Number} [end=char count] the end offset of text range. + * @param {Boolean|Number|orion.editor.TextViewShowOptions} [show=true] + * if true, the view will scroll the minimum amount necessary to show the caret location. If + * show is a Number, the view will scroll the minimum amount necessary to show the caret location plus a + * percentage of the client area height. The parameter is clamped to the [0,1] range. In either case, the view will only scroll + * if the new caret location is not visible already. The show parameter can also be a orion.editor.TextViewShowOptions object. See + * {@link orion.editor.TextViewShowOptions} for further information in how the options can be used to control the scrolling behavior. + * @param {Function} [callback] if callback is specified and scrollAnimation is not zero, view scrolling is animated and + * the callback is called when the animation is done. Otherwise, callback is callback right away. + * + * @see orion.editor.TextView#getText + */ + setText: function (text, start, end, show, callback) { + var isSingle = typeof text === "string"; //$NON-NLS-1$ + var reset = start === undefined && end === undefined && isSingle; + var edit; + if (isSingle) { + if (start === undefined) { start = 0; } + if (end === undefined) { end = this._model.getCharCount(); } + edit = {text: text, selection: [new Selection(start, end, false)]}; + } else { + edit = text; + edit.selection = this._rangesToSelections(edit.selection); } - if (this._dropTarget) { - return; + edit._code = true; + if (reset) { + this._variableLineHeight = false; } - /* - * Bug in IE9. IE sends one mouse event when the user changes the text by - * pasting or undo. These operations usually happen with the Ctrl key - * down which causes the view to enter link mode. Link mode does not end - * because there are no further events. The fix is to only enter link - * mode when the coordinates of the mouse move event have changed. - */ - var changed = this._linksVisible || this._lastMouseMoveX !== e.clientX || this._lastMouseMoveY !== e.clientY; - this._lastMouseMoveX = e.clientX; - this._lastMouseMoveY = e.clientY; - this._setLinksVisible(changed && !this._isMouseDown && e.altKey && (util.isMac ? e.metaKey : e.ctrlKey)); - - this._checkOverlayScroll(); - - /* - * Feature in IE8 and older, the sequence of events in the IE8 event model - * for a doule-click is: - * - * down - * up - * up - * dblclick - * - * Given that the mouse down/up events are not balanced, it is not possible to - * grab on mouse down and ungrab on mouse up. The fix is to grab on the first - * mouse down and ungrab on mouse move when the button 1 is not set. - * - * In order to detect double-click and drag gestures, it is necessary to send - * a mouse down event from mouse move when the button is still down and isMouseDown - * flag is not set. - */ - if (!this._isW3CEvents) { - if (e.button === 0) { - this._setGrab(null); - return true; - } - if (!this._isMouseDown && e.button === 1 && (this._clickCount & 1) !== 0 && inClient) { - this._clickCount = 2; - return this._handleMouse(e, this._clickCount); + this._modifyContent(edit, !reset, show === undefined || show, callback); + if (reset) { + /* + * Bug in Firefox. For some reason, the caret does not show after the + * view is refreshed. The fix is to toggle the contentEditable state and + * force the clientDiv to loose and receive focus if it is focused. + */ + if (util.isFirefox < 13) { + this._fixCaret(); } } - if (!this._isMouseDown || this._dragOffset !== -1) { - return; - } - - var x = e.clientX; - var y = e.clientY; - var viewPad = this._getViewPadding(); - var viewRect = this._viewDiv.getBoundingClientRect(); - var width = this._getClientWidth (), height = this._getClientHeight(); - var leftEdge = viewRect.left + viewPad.left; - var topEdge = viewRect.top + viewPad.top; - var rightEdge = viewRect.left + viewPad.left + width; - var bottomEdge = viewRect.top + viewPad.top + height; - if (y < topEdge) { - this._doAutoScroll("up", x, y - topEdge); //$NON-NLS-1$ - } else if (y > bottomEdge) { - this._doAutoScroll("down", x, y - bottomEdge); //$NON-NLS-1$ - } else if (x < leftEdge && !this._wrapMode) { - this._doAutoScroll("left", x - leftEdge, y); //$NON-NLS-1$ - } else if (x > rightEdge && !this._wrapMode) { - this._doAutoScroll("right", x - rightEdge, y); //$NON-NLS-1$ + }, + /** + * Sets the top index. + *

    + * The top index is the line that is currently at the top of the text view. This + * line may be partially visible depending on the vertical scroll of the view. + *

    + * + * @param {Number} topIndex the index of the top line. + * @param {Function} [callback] if callback is specified and scrollAnimation is not zero, view scrolling is animated and + * the callback is called when the animation is done. Otherwise, callback is callback right away. + * + * @see orion.editor.TextView#getBottomIndex + * @see orion.editor.TextView#getTopIndex + */ + setTopIndex: function(topIndex, callback) { + if (!this._clientDiv) { return; } + this._scrollViewAnimated(0, this._getLinePixel(Math.max(0, topIndex)) - this._getScroll().y, callback); + }, + /** + * Sets the top pixel. + *

    + * The top pixel is the pixel position that is currently at + * the top edge of the view. This position is relative to the + * beginning of the document. + *

    + * + * @param {Number} pixel the top pixel. + * @param {Function} [callback] if callback is specified and scrollAnimation is not zero, view scrolling is animated and + * the callback is called when the animation is done. Otherwise, callback is callback right away. + * + * @see orion.editor.TextView#getBottomPixel + * @see orion.editor.TextView#getTopPixel + * @see orion.editor.TextView#convert + */ + setTopPixel: function(pixel, callback) { + if (!this._clientDiv) { return; } + this._scrollViewAnimated(0, Math.max(0, pixel) - this._getScroll().y, callback); + }, + /** + * Scrolls the selection into view if needed. + * + * @param {Number|orion.editor.TextViewShowOptions} [show=0] + * If show is a Number, the view will scroll the minimum amount necessary to show the caret location plus a + * percentage of the client area height. The parameter is clamped to the [0,1] range. The view will only scroll + * if the new caret location is not visible already. The show parameter can also be a orion.editor.TextViewShowOptions object. See + * {@link orion.editor.TextViewShowOptions} for further information in how the options can be used to control the scrolling behavior. + * @param {Function} [callback] if callback is specified and scrollAnimation is not zero, view scrolling is animated and + * the callback is called when the animation is done. Otherwise, callback is callback right away. + * + * @returns {Boolean} true if the view was scrolled. + * + * @see orion.editor.TextView#getSelection + * @see orion.editor.TextView#setSelection + * @see orion.editor.TextView#setCaretOffset + */ + showSelection: function(show, callback) { + return this._showCaret(show ? false : true, callback, show); + }, + update: function(styleChanged, sync) { + if (!this._clientDiv) { return; } + if (styleChanged || this._metrics.invalid) { + this._updateStyle(); + } + if (sync === undefined || sync) { + this._update(); } else { - this._endAutoScroll(); - this._setSelectionTo(x, y, false, true); + this._queueUpdate(); } }, - _isClientDiv: function(e) { + + /**************************************** Event handlers *********************************/ + _handleRootMouseDown: function (e) { + this._cancelCheckSelection(); + if (this._ignoreEvent(e)) { return; } + if (util.isFirefox < 13 && e.which === 1) { + this._clientDiv.contentEditable = false; + (this._overlayDiv || this._clientDiv).draggable = true; + this._ignoreBlur = true; + } + + /* Prevent clicks outside of the client div from taking focus away. */ var topNode = this._overlayDiv || this._clientDiv; + /* Use view div on IE 8 otherwise it is not possible to scroll. */ + if (util.isIE < 9) { topNode = this._viewDiv; } var temp = e.target ? e.target : e.srcElement; while (temp) { if (topNode === temp) { - return true; + return; + } + if (temp.className && temp.className.indexOf("textViewFind") !== -1) { //$NON-NLS-1$ + return; } temp = temp.parentNode; } - return false; - }, - _createKeyEvent: function(type, e) { - return { - type: type, - event: e, - preventDefault: function() { - this.defaultPrevented = true; - } - }; - }, - _createMouseEvent: function(type, e) { - var pt = this.convert({x: e.clientX, y: e.clientY}, "page", "document"); //$NON-NLS-1$ //$NON-NLS-2$ - return { - type: type, - event: e, - clickCount: this._clickCount, - x: pt.x, - y: pt.y, - preventDefault: function() { - this.defaultPrevented = true; - } - }; - }, - _createTouchEvent: function(type, e) { - var pt = e.touches.length ? this.convert({x: e.touches[0].clientX, y: e.touches[0].clientY}, "page", "document") : {}; //$NON-NLS-1$ //$NON-NLS-2$ - return { - type: type, - event: e, - touchCount: e.touches.length, - x: pt.x, - y: pt.y, - preventDefault: function() { - this.defaultPrevented = true; - } - }; - }, - _handleMouseUp: function (e) { - var left = e.which ? e.button === 0 : e.button === 1; - if (this.isListening("MouseUp")) { //$NON-NLS-1$ - if (this._isClientDiv(e) || (left && this._isMouseDown)) { - var mouseEvent = this._createMouseEvent("MouseUp", e); //$NON-NLS-1$ - this.onMouseUp(mouseEvent); - if (mouseEvent.defaultPrevented) { - e.preventDefault(); - this._isMouseDown = false; - return; - } - } + if (e.preventDefault) { e.preventDefault(); } + if (e.stopPropagation){ e.stopPropagation(); } + if (!this._isW3CEvents) { + /* + * In IE 8 is not possible to prevent the default handler from running + * during mouse down event using usual API. The workaround is to give + * focus back to the client div. + */ + var that = this; + var win = this._getWindow(); + win.setTimeout(function() { + that._clientDiv.focus(); + }, 0); } - if (this._linksVisible) { - return; + }, + _handleRootMouseUp: function (e) { + if (this._ignoreEvent(e)) { return; } + if (util.isFirefox < 13 && e.which === 1) { + this._clientDiv.contentEditable = true; + (this._overlayDiv || this._clientDiv).draggable = false; } - if (left && this._isMouseDown) { - var selections = this._getSelections(); - var selection = Selection.editing(selections); - selections.forEach(function(sel) { - sel._editing = false; - }); - if (this._dragOffset !== -1) { - selection.extend(this._dragOffset); - selection.collapse(); - selections = selection; - this._dragOffset = -1; - } - this._setSelection(selections, false); - this._isMouseDown = false; - this._endAutoScroll(); + if (util.isFirefox && e.which === 1) { /* - * Feature in IE8 and older, the sequence of events in the IE8 event model - * for a doule-click is: - * - * down - * up - * up - * dblclick - * - * Given that the mouse down/up events are not balanced, it is not possible to - * grab on mouse down and ungrab on mouse up. The fix is to grab on the first - * mouse down and ungrab on mouse move when the button 1 is not set. + * Bug in Firefox. For some reason, Firefox stops showing the caret + * in some cases. For example when the user cancels a drag operation + * by pressing ESC. The fix is to detect that the drag operation was + * cancelled, toggle the contentEditable state and force the clientDiv + * to loose and receive focus if it is focused. */ - if (this._isW3CEvents) { this._setGrab(null); } - } - /* - * Note that there cases when Firefox sets the DOM selection in mouse up. - * This happens for example after a cancelled drag operation. - * - * Note that on Chrome and IE, the caret stops blicking if mouse up is - * prevented. - */ - if (left && this._isMouseDown && util.isFirefox) { - this._updateDOMSelection(); - e.preventDefault(); + this._fixCaret(); + this._ignoreBlur = false; } }, - _handleMouseWheel: function (e) { - if (this._noScroll) return; - var lineHeight = this._getLineHeight(); - var pixelX = 0, pixelY = 0; - // Note: On the Mac the correct behaviour is to scroll by pixel. - if (util.isIE || util.isOpera) { - pixelY = (-e.wheelDelta / 40) * lineHeight; - } else if (util.isFirefox) { - var limit = 256; - if (e.type === "wheel") { //$NON-NLS-1$ - if (e.deltaMode) { // page or line - pixelX = Math.max(-limit, Math.min(limit, e.deltaX)) * lineHeight; - pixelY = Math.max(-limit, Math.min(limit, e.deltaY)) * lineHeight; - } else { - pixelX = e.deltaX; - pixelY = e.deltaY; - } - } else { - var pixel; - if (util.isMac) { - pixel = e.detail * 3; - } else { - pixel = Math.max(-limit, Math.min(limit, e.detail)) * lineHeight; - } - if (e.axis === e.HORIZONTAL_AXIS) { - pixelX = pixel; - } else { - pixelY = pixel; - } - } - } else { - //Webkit - if (util.isMac) { - /* - * In Safari, the wheel delta is a multiple of 120. In order to - * convert delta to pixel values, it is necessary to divide delta - * by 40. - * - * In Chrome and Safari 5, the wheel delta depends on the type of the - * mouse. In general, it is the pixel value for Mac mice and track pads, - * but it is a multiple of 120 for other mice. There is no presise - * way to determine if it is pixel value or a multiple of 120. - * - * Note that the current approach does not calculate the correct - * pixel value for Mac mice when the delta is a multiple of 120. - * - * For values that are multiples of 120, the denominator varies on - * the time between events. - */ - var denominatorX, denominatorY; - var deltaTime = e.timeStamp - this._wheelTimeStamp; - this._wheelTimeStamp = e.timeStamp; - if (e.wheelDeltaX % 120 !== 0) { - denominatorX = 1; - } else { - denominatorX = deltaTime < 40 ? 40/(40-deltaTime) : 40; - } - if (e.wheelDeltaY % 120 !== 0) { - denominatorY = 1; - } else { - denominatorY = deltaTime < 40 ? 40/(40-deltaTime) : 40; - } - pixelX = Math.ceil(-e.wheelDeltaX / denominatorX); - if (-1 < pixelX && pixelX < 0) { pixelX = -1; } - if (0 < pixelX && pixelX < 1) { pixelX = 1; } - pixelY = Math.ceil(-e.wheelDeltaY / denominatorY); - if (-1 < pixelY && pixelY < 0) { pixelY = -1; } - if (0 < pixelY && pixelY < 1) { pixelY = 1; } - } else { - pixelX = -e.wheelDeltaX; - var linesToScroll = 8; - pixelY = (-e.wheelDeltaY / 120 * linesToScroll) * lineHeight; - } - } - /* - * Feature in Safari. If the event target is removed from the DOM - * safari stops smooth scrolling. The fix is keep the element target - * in the DOM and remove it on a later time. - * - * Note: Using a timer is not a solution, because the timeout needs to - * be at least as long as the gesture (which is too long). + _handleBlur: function () { + this._cancelCheckSelection(); + if (this._ignoreBlur) { return; } + this._commitIME(); + this._hasFocus = false; + /* + * Bug in IE 8 and earlier. For some reason when text is deselected + * the overflow selection at the end of some lines does not get redrawn. + * The fix is to create a DOM element in the body to force a redraw. */ - if (util.isSafari || (util.isChrome && util.isMac)) { - var lineDiv = e.target; - while (lineDiv && lineDiv.lineIndex === undefined) { - lineDiv = lineDiv.parentNode; + if (util.isIE < 9) { + if (!this._getSelections()[0].isEmpty()) { + var rootDiv = this._rootDiv; + var child = util.createElement(rootDiv.ownerDocument, "div"); //$NON-NLS-1$ + rootDiv.appendChild(child); + rootDiv.removeChild(child); } - this._mouseWheelLine = lineDiv; - } - var oldScroll = this._getScroll(); - this._scrollView(pixelX, pixelY); - var newScroll = this._getScroll(); - if (oldScroll.x !== newScroll.x || oldScroll.y !== newScroll.y) { - if (e.preventDefault) { e.preventDefault(); } - return false; } - }, - _handlePaste: function (e) { - this._cancelCheckSelection(); - if (this._ignoreEvent(e)) { return; } - if (this._ignorePaste) { return; } - if (this._doPaste(e)) { - if (util.isIE) { - /* - * Bug in IE, - */ - var that = this; - this._ignoreFocus = true; - var win = this._getWindow(); - win.setTimeout(function() { - that._updateDOMSelection(); - that._ignoreFocus = false; - }, 0); - } - if (e.preventDefault) { e.preventDefault(); } - return false; + if (this._cursorDiv) { + this._cursorDiv.style.display = "none"; //$NON-NLS-1$ } - }, - _handleResize: function () { - var newWidth = this._rootDiv.clientWidth; - var newHeight = this._rootDiv.clientHeight; - if (this._rootWidth !== newWidth || this._rootHeight !== newHeight) { - if (this._rootWidth !== newWidth && this._wrapMode) { - this._resetLineHeight(); - } - this._rootWidth = newWidth; - this._rootHeight = newHeight; - /* - * Feature in IE7. For some reason, sometimes Internet Explorer 7 - * returns incorrect values for element.getBoundingClientRect() when - * inside a resize handler. The fix is to queue the work. - */ - var queue = util.isIE < 9; - - /* - * The calculated metrics may be out of date when the zoom level changes. - */ - var metrics = this._calculateMetrics(); - if (!compare(metrics, this._metrics)) { - if (this._metrics.invalid && !metrics.invalid) { - this._updateStyle(false, metrics); - } else { - if (this._variableLineHeight) { - this._variableLineHeight = false; - this._resetLineHeight(); + if (this._domSelection) { + this._domSelection.forEach(function(domSelection) { domSelection.update(); }); + /* Clear browser selection if selection is within clientDiv */ + var temp; + var win = this._getWindow(); + var doc = this._parent.ownerDocument; + if (win.getSelection) { + var sel = win.getSelection(); + temp = sel.anchorNode; + while (temp) { + if (temp === this._clientDiv) { + if (sel.rangeCount > 0) { sel.removeAllRanges(); } + break; } - this._metrics = metrics; + temp = temp.parentNode; } - queue = true; - } - - if (queue) { - this._queueUpdate(); - } else { - this._update(); - } - this.dispatchEvent({type: "Resize"}); //$NON-NLS-1$ - } - }, - _handleRulerEvent: function (e) { - var target = e.target ? e.target : e.srcElement; - var lineIndex = target.lineIndex; - var element = target; - while (element && !element._ruler) { - if (lineIndex === undefined && element.lineIndex !== undefined) { - lineIndex = element.lineIndex; - } - element = element.parentNode; - } - var ruler = element ? element._ruler : null; - if (lineIndex === undefined && ruler && ruler.getOverview() === "document") { //$NON-NLS-1$ - var clientHeight = this._getClientHeight (); - var lineCount = this._model.getLineCount (); - var viewPad = this._getViewPadding(); - var viewRect = this._viewDiv.getBoundingClientRect(); - var lineHeight = this._getLineHeight(); - var contentHeight = lineHeight * lineCount; - var trackHeight = clientHeight + viewPad.top + viewPad.bottom - 2 * this._metrics.scrollWidth; - var divHeight, arrowWidth; - if (contentHeight < trackHeight) { - divHeight = lineHeight; - arrowWidth = viewPad.top; - } else { - divHeight = trackHeight / lineCount; - arrowWidth = this._metrics.scrollWidth; - } - lineIndex = Math.floor(((e.clientY - viewRect.top) - arrowWidth) / divHeight); - if (!(0 <= lineIndex && lineIndex < lineCount)) { - lineIndex = undefined; - } - } - if (ruler) { - switch (e.type) { - case "click": //$NON-NLS-1$ - if (ruler.onClick) { ruler.onClick(lineIndex, e); } - break; - case "dblclick": //$NON-NLS-1$ - if (ruler.onDblClick) { ruler.onDblClick(lineIndex, e); } - break; - case "mousemove": //$NON-NLS-1$ - if (ruler.onMouseMove) { ruler.onMouseMove(lineIndex, e); } - break; - case "mouseover": //$NON-NLS-1$ - if (ruler.onMouseOver) { ruler.onMouseOver(lineIndex, e); } - break; - case "mouseout": //$NON-NLS-1$ - if (ruler.onMouseOut) { - var tmp = e.relatedTarget; - while (tmp && tmp !== this._rootDiv) { - if (tmp === element) { - return; - } - tmp = tmp.parentNode; - } - ruler.onMouseOut(lineIndex, e); + } else if (doc.selection) { + this._ignoreSelect = false; + temp = doc.selection.createRange().parentElement(); + while (temp) { + if (temp === this._clientDiv) { + doc.selection.empty(); + break; } - break; + temp = temp.parentNode; + } + this._ignoreSelect = true; } } - }, - _handleScroll: function () { - this._lastScrollTime = new Date().getTime(); - var _scroll = this._getScroll(false); - var oldX = this._hScroll; - var oldY = this._vScroll; - if (oldX !== _scroll.x || oldY !== _scroll.y) { - this._hScroll = _scroll.x; - this._vScroll = _scroll.y; - this._commitIME(); - this._update(oldY === _scroll.y); - var e = { - type: "Scroll", //$NON-NLS-1$ - oldValue: {x: oldX, y: oldY}, - newValue: _scroll - }; - this.onScroll(e); + if (!this._ignoreFocus) { + this.onBlur({type: "Blur"}); //$NON-NLS-1$ } }, - _handleSelectStart: function (e) { - var menuOpen = this._contextMenuOpen; - this._contextMenuOpen = false; - if (menuOpen) { - this._checkSelectionChange = true; - return; - } - if (this._ignoreSelect) { - if (e && e.preventDefault) { e.preventDefault(); } - return false; + _handleCompositionStart: function (e) { + if (this._ignoreEvent(e)) { return; } + if (this._imeTimeout) { + var win = this._getWindow(); + win.clearTimeout(this._imeTimeout); + this._imeTimeout = null; } - }, - _getModelOffset: function(node, offset) { - if (!node) { return; } - var lineNode; - if (node.tagName === "DIV") { //$NON-NLS-1$ - lineNode = node; - } else { - lineNode = node.parentNode.parentNode; + if (this._imeText) { + this._commitIME(this._imeText); + this._imeText = null; } - if (!lineNode._line) { - return 0; + this._startIME(); + if (this._mutationObserver) { + this._mutationObserver.disconnect(); + this._mutationObserver = null; } - return lineNode._line.getModelOffset (node, offset); }, - _updateSelectionFromDOM: function() { - if (!(util.isIOS || util.isAndroid || this._checkSelectionChange)) { - return false; - } + _handleCompositionUpdate: function(e) { + if (this._ignoreEvent(e)) { return; } + this._imeText = e.data; + }, + _handleCompositionEnd: function (e) { + if (this._ignoreEvent(e)) { return; } + this._imeText = e.data; var win = this._getWindow(); - var selection = win.getSelection(); - var start = this._getModelOffset(selection.anchorNode, selection.anchorOffset); - var end = this._getModelOffset(selection.focusNode, selection.focusOffset); - var sel = this._getSelections()[0]; - if (start === undefined || end === undefined || (sel.start === start && sel.end === end)) { - return false; + this._imeTimeout = win.setTimeout(function() { + this._commitIME(this._imeText); + this._imeText = this._imeTimeout = null; + }.bind(this), 0); + }, + _handleContextMenu: function (e) { + if (this._ignoreEvent(e)) { return; } + if (util.isIE && this._lastMouseButton === 3) { + // We need to update the DOM selection, because on + // right-click the caret moves to the mouse location. + // See bug 366312 and 376508. + this._updateDOMSelection(); } - - if (this._checkSelectionChange) { - var firstLine = this._getLineNext(); - var lastLine = this._getLinePrevious(); - - // Selection is unchanged and bigger than the visible buffer region - if (selection.anchorNode === firstLine.firstChild.firstChild && selection.anchorOffset === 0 && - selection.focusNode === lastLine.firstChild.firstChild && selection.focusOffset === 0) - { - return false; - } - - // Detect select all - if ( - (selection.anchorNode === firstLine.firstChild.firstChild && selection.anchorOffset === 0 && selection.focusNode === lastLine.lastChild.firstChild) - || (selection.anchorNode === this._clientDiv && selection.focusNode === this._clientDiv) - ) { - start = 0; - end = this.getModel().getCharCount(); + var preventDefault = false; + if (this.isListening("ContextMenu")) { //$NON-NLS-1$ + var evt = this._createMouseEvent("ContextMenu", e); //$NON-NLS-1$ + evt.screenX = e.screenX; + evt.screenY = e.screenY; + this.onContextMenu(evt); + preventDefault = evt.defaultPrevented; + } else if (util.isMac && util.isFirefox && e.button === 0) { + // hack to prevent CTRL+Space from showing the browser context menu + preventDefault = true; + } + if (preventDefault) { + if (e.preventDefault) { e.preventDefault(); } + return false; + } else { + this._contextMenuOpen = true; + if (util.isFirefox) { + this._checkSelectionChange = true; + this._pollSelectionChange(true); } } - - this._setSelection(new Selection(start, end), false, false); - this._checkSelectionChange = false; - return true; }, - _cancelCheckSelection: function() { - if (this._checkSelectionChange) { - this._checkSelectionChange = false; - this._cancelPollSelectionChange(); + _handleCopy: function (e) { + this._cancelCheckSelection(); + if (this._ignoreEvent(e)) { return; } + if (this._ignoreCopy) { return; } + if (this._doCopy(e)) { + if (e.preventDefault) { e.preventDefault(); } + return false; } }, - _cancelPollSelectionChange: function() { - if (this._selPollTimer) { - var win = this._getWindow(); - win.clearTimeout(this._selPollTimer); - this._selPollTimer = null; + _handleCut: function (e) { + this._cancelCheckSelection(); + if (this._ignoreEvent(e)) { return; } + if (this._doCut(e)) { + if (e.preventDefault) { e.preventDefault(); } + return false; } }, - _pollSelectionChange: function(retryPoll) { - var that = this; - var win = this._getWindow(); - this._cancelPollSelectionChange(); - this._selPollTimer = win.setTimeout(function() { - that._selPollTimer = null; - if (!that._clientDiv) { return; } - var changed = that._updateSelectionFromDOM(); - if (!changed && retryPoll) { - that._pollSelectionChange(retryPoll); - } - }, 100); + _handleDataModified: function(e) { + if (this._ignoreEvent(e)) { return; } + this._startIME(); }, - _handleSelectionChange: function () { - if (this._imeOffset !== -1) { - return; - } - /* - * Feature in Android. The selection handles are hidden when the DOM changes. Sending - * selection events to the application while the user is moving the selection handles - * may hide the handles unexpectedly. The fix is to delay updating the selection and - * sending the event to the application. - */ - if (util.isAndroid) { - this._pollSelectionChange(); - } else { - this._updateSelectionFromDOM(); + _handleDblclick: function (e) { + if (this._ignoreEvent(e)) { return; } + var time = e.timeStamp ? e.timeStamp : new Date().getTime(); + this._lastMouseTime = time; + if (this._clickCount !== 2) { + this._clickCount = 2; + this._handleMouse(e); } }, - _handleTextInput: function (e) { + _handleDragStart: function (e) { if (this._ignoreEvent(e)) { return; } - if (this._imeOffset !== -1) { - return; + if (util.isFirefox < 13) { + var that = this; + var win = this._getWindow(); + win.setTimeout(function() { + that._clientDiv.contentEditable = true; + that._clientDiv.draggable = false; + that._ignoreBlur = false; + }, 0); } - var selection = this._getWindow().getSelection(); - if ( - selection.anchorNode !== this._anchorNode || selection.focusNode !== this._focusNode || - selection.anchorOffset !== this._anchorOffset || selection.focusOffset !== this._focusOffset - ) { - var temp = selection.anchorNode; - while (temp) { - if (temp.lineIndex !== undefined) { - break; - } - temp = temp.parentNode; - } - if (temp) { - var model = this._model; - var lineIndex = temp.lineIndex; - var oldText = model.getLine(lineIndex), text = oldText; - var offset = 0; - var lineStart = model.getLineStart(lineIndex); - if (selection.rangeCount > 0) { - selection.getRangeAt(0).deleteContents(); - var node = temp.ownerDocument.createTextNode(e.data); - selection.getRangeAt(0).insertNode(node); - var nodeText = this._getDOMText(temp, node); - text = nodeText.text; - offset = nodeText.offset; - node.parentNode.removeChild(node); - } - temp.lineRemoved = true; - - var start = 0; - while (oldText.charCodeAt(start) === text.charCodeAt(start) && start < offset) { - start++; - } - - var end = oldText.length - 1, delta = text.length - oldText.length; - while (oldText.charCodeAt(end) === text.charCodeAt(end + delta) && end + delta >= offset + e.data.length) { - end--; - } - end++; - - var deltaText = text.substring(start, end + delta); - start += lineStart; - end += lineStart; - - var selections = this._getSelections(); - var deltaStart = selections[0].start - start; - var deltaEnd = selections[0].end - end; - selections[0].start = start; - selections[0].end = end; - for (var i=1; i= 0; i--) { - mode = keyModes[i]; - if (typeof mode.match === "function") { //$NON-NLS-1$ - var actionID = mode.match(e); - if (actionID !== undefined) { - return this.invokeAction(actionID); - } - } + _handleDragLeave: function (e) { + if (this._ignoreEvent(e)) { return; } + this._dropTarget = false; + if (this.isListening("DragLeave")) { //$NON-NLS-1$ + this.onDragLeave(this._createMouseEvent("DragLeave", e)); //$NON-NLS-1$ + } + }, + _handleDrop: function (e) { + if (this._ignoreEvent(e)) { return; } + this._dropTarget = false; + if (this.isListening("Drop")) { //$NON-NLS-1$ + this.onDrop(this._createMouseEvent("Drop", e)); //$NON-NLS-1$ } + /* + * This event must be prevented otherwise the user agent will modify + * the DOM. Note that preventing the event on some user agents (i.e. IE) + * indicates that the operation is cancelled. This causes the dropEffect to + * be set to none in the dragend event causing the implementor to not execute + * the code responsible by the move effect. + */ + if (e.preventDefault) { e.preventDefault(); } return false; }, - _doMove: function(args, selection) { - var model = this._model; - var caret = selection.getCaret(); - var lineIndex = model.getLineAtOffset(caret); - if (!args.count) { - args.count = 1; + _handleFocus: function () { + this._hasFocus = true; + if (util.isIOS && this._lastTouchOffset !== undefined) { + this.setCaretOffset(this._lastTouchOffset, true); + this._lastTouchOffset = undefined; + } else { + this._updateDOMSelection(); } - while (args.count !== 0) { - var lineStart = model.getLineStart(lineIndex); - if (args.count < 0 && caret === lineStart) { - if (lineIndex > 0) { - if (args.unit === "character") { //$NON-NLS-1$ - args.count++; - } - lineIndex--; - selection.extend(model.getLineEnd(lineIndex)); - } else { - break; - } - } else if (args.count > 0 && caret === model.getLineEnd(lineIndex)) { - if (lineIndex + 1 < model.getLineCount()) { - if (args.unit === "character") { //$NON-NLS-1$ - args.count--; - } - lineIndex++; - selection.extend(model.getLineStart(lineIndex)); - } else { - break; - } - } else { - var removeTab = false; - if (args.expandTab && args.unit === "character" && (caret - lineStart) % this._tabSize === 0) { //$NON-NLS-1$ - var lineText = model.getText(lineStart, caret); - removeTab = !/[^ ]/.test(lineText); // Only spaces between line start and caret. - } - if (removeTab) { - selection.extend(caret - this._tabSize); - args.count += args.count < 0 ? 1 : -1; - } else { - var line = this._getLine(lineIndex); - selection.extend(line.getNextOffset(caret, args)); - line.destroy(); - } - } - caret = selection.getCaret(); + if (this._cursorDiv) { + this._cursorDiv.style.display = "block"; //$NON-NLS-1$ } - return selection; - }, - _doBackspace: function (args) { - var that = this; - var selections = this._getSelections(); - selections.forEach(function(selection) { - if (selection.isEmpty()) { - if (!args.count) { - args.count = 1; - } - args.count *= -1; - args.expandTab = that._expandTab; - that._doMove(args, selection); - } - }); - this._modifyContent({text: "", selection: selections}, true); - return true; - }, - _doCase: function (args) { - var that = this; - var selections = this._getSelections(); - var changes = []; - selections.forEach(function(selection) { - that._doMove(args, selection); - var text = that.getText(selection.start, selection.end); - switch (args.type) { - case "lower": text = text.toLowerCase(); break; //$NON-NLS-1$ - case "capitalize": text = text.replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); }); break; //$NON-NLS-1$ - case "reverse": //$NON-NLS-1$ - var newText = ""; - for (var i=0; i 0) { - lineIndex = Math.min (lineIndex + args.count - 1, model.getLineCount() - 1); - } - offset = model.getLineEnd(lineIndex); + var startIME = true; + + /* + * Bug in Safari. Some Control+key combinations send key events + * with keyCode equals to 229. This is unexpected and causes the + * view to start an IME composition. The fix is to ignore these + * events. + */ + if (util.isSafari && util.isMac) { + if (e.ctrlKey) { + startIME = false; + e.keyCode = 0x81; } - selection.extend(offset); } - if (!args.select) { selection.collapse(); } - }); - this._setSelection(selections, true, true, args.ctrl ? function() {} : null); - return true; - }, - _doEnter: function (args) { - if (this._singleMode) return true; - var model = this._model; - var selections = this._getSelections(); - this._doContent(model.getLineDelimiter()); - if (args && args.noCursor) { - selections.forEach(function(selection) { - selection.end = selection.start; - }); - this._setSelection(selections, true); + if (startIME) { + this._startIME(); + } + } else { + if (!modifier) { + this._commitIME(); + } } - return true; - }, - _doEscape: function () { - var selections = this._getSelections(); - if (selections.length > 1) { - this._setSelection(selections[0], true); + /* + * Feature in Firefox. When a key is held down the browser sends + * right number of keypress events but only one keydown. This is + * unexpected and causes the view to only execute an action + * just one time. The fix is to ignore the keydown event and + * execute the actions from the keypress handler. + * Note: This only happens on the Mac and Linux (Firefox 3.6). + * + * Feature in Opera < 12.16. Opera sends keypress events even for non-printable + * keys. The fix is to handle actions in keypress instead of keydown. + */ + if (((util.isMac || util.isLinux) && util.isFirefox < 4) || util.isOpera < 12.16) { + this._keyDownEvent = e; + return true; } - return true; - }, - _doHome: function (args) { - var model = this._model; - var that = this; - var selections = this._getSelections(); - selections.forEach(function(selection) { - if (args.ctrl) { - selection.extend(0); + + if (this._doAction(e)) { + if (e.preventDefault) { + e.preventDefault(); + e.stopPropagation(); } else { - var offset = selection.getCaret(); - var lineIndex = model.getLineAtOffset(offset); - if (that._wrapMode) { - var line = that._getLine(lineIndex); - var visualIndex = line.getLineIndex(offset); - offset = line.getLineStart(visualIndex); - line.destroy(); - } else { - offset = model.getLineStart(lineIndex); - } - selection.extend(offset); + e.cancelBubble = true; + e.returnValue = false; + e.keyCode = 0; } - if (!args.select) { selection.collapse(); } - }); - this._setSelection(selections, true, true, args.ctrl ? function() {} : null); - return true; + return false; + } }, - _doLineDown: function (args) { - var model = this._model; - var that = this; - var selections = this._getSelections(); - selections.forEach(function(selection) { - var caret = selection.getCaret(); - var lineIndex = model.getLineAtOffset(caret), visualIndex; - var line = that._getLine(lineIndex); - var x = selection._columnX, y = 1, lastLine = false; - if (x === -1 || args.wholeLine || (args.select && util.isIE)) { - var offset = args.wholeLine ? model.getLineEnd(lineIndex + 1) : caret; - x = selection._columnX = line.getBoundingClientRect(offset).left; + _handleKeyPress: function (e) { + if (this._ignoreEvent(e)) { return; } + /* + * Feature in Firefox. Keypress events still happen even if the keydown event + * was prevented. The fix is to remember that keydown was prevented and prevent + * the keypress ourselves. + */ + if (this._keyDownPrevented) { + if (e.preventDefault) { + e.preventDefault(); + e.stopPropagation(); + } + this._keyDownPrevented = undefined; + return; + } + /* + * Feature in Embedded WebKit. Embedded WekKit on Mac runs in compatibility mode and + * generates key press events for these Unicode values (Function keys). This does not + * happen in Safari or Chrome. The fix is to ignore these key events. + */ + if (util.isMac && util.isWebkit) { + if ((0xF700 <= e.keyCode && e.keyCode <= 0xF7FF) || e.keyCode === 13 || e.keyCode === 8) { + if (e.preventDefault) { e.preventDefault(); } + return false; } - if ((visualIndex = line.getLineIndex(caret)) < line.getLineCount() - 1) { - y = line.getClientRects(visualIndex + 1).top + 1; - } else { - var lastLineCount = model.getLineCount() - 1; - lastLine = lineIndex === lastLineCount; - if (args.count && args.count > 0) { - lineIndex = Math.min (lineIndex + args.count, lastLineCount); - } else { - lineIndex++; - } + } + if (((util.isMac || util.isLinux) && util.isFirefox < 4) || util.isOpera < 12.16) { + if (this._doAction(this._keyDownEvent)) { + if (e.preventDefault) { e.preventDefault(); } + return false; } - var select = false; - if (lastLine) { - if (args.select || (util.isMac || util.isLinux)) { - selection.extend(model.getCharCount()); - select = true; - } - } else { - if (line.lineIndex !== lineIndex) { - line.destroy(); - line = that._getLine(lineIndex); + } + var ctrlKey = util.isMac ? e.metaKey : e.ctrlKey; + if (e.charCode !== undefined) { + if (ctrlKey) { + switch (e.charCode) { + /* + * In Firefox and Safari if ctrl+v, ctrl+c ctrl+x is canceled + * the clipboard events are not sent. The fix to allow + * the browser to handles these key events. + */ + case 99://c + case 118://v + case 120://x + return true; } - selection.extend(line.getOffset(x, y)); - select = true; } - if (select) { - if (!args.select) { selection.collapse(); } - } - line.destroy(); - }); - that._setSelection(selections, true, true, null, 0, false, true); - return true; - }, - _doLineUp: function (args) { - var model = this._model; - var that = this; - var selections = this._getSelections(); - selections.forEach(function(selection) { - var caret = selection.getCaret(); - var lineIndex = model.getLineAtOffset(caret), visualIndex; - var line = that._getLine(lineIndex); - var x = selection._columnX, firstLine = false, y; - if (x === -1 || args.wholeLine || (args.select && util.isIE)) { - var offset = args.wholeLine ? model.getLineStart(lineIndex - 1) : caret; - x = selection._columnX = line.getBoundingClientRect(offset).left; + } + if (this.isListening("KeyPress")) { //$NON-NLS-1$ + var keyEvent = this._createKeyEvent("KeyPress", e); //$NON-NLS-1$ + this.onKeyPress(keyEvent); //$NON-NLS-1$ + if (keyEvent.defaultPrevented) { + e.preventDefault(); + return; } - if ((visualIndex = line.getLineIndex(caret)) > 0) { - y = line.getClientRects(visualIndex - 1).top + 1; + } + if (this._doAction(e)) { + if (e.preventDefault) { + e.preventDefault(); + e.stopPropagation(); } else { - firstLine = lineIndex === 0; - if (!firstLine) { - if (args.count && args.count > 0) { - lineIndex = Math.max (lineIndex - args.count, 0); - } else { - lineIndex--; - } - y = that._getLineHeight(lineIndex) - 1; - } + e.cancelBubble = true; + e.returnValue = false; + e.keyCode = 0; } - var select = false; - if (firstLine) { - if (args.select || (util.isMac || util.isLinux)) { - selection.extend(0); - select = true; - } + return false; + } + var ignore = false; + if (util.isMac) { + if (e.ctrlKey || e.metaKey) { ignore = true; } + } else { + if (util.isFirefox) { + //Firefox clears the state mask when ALT GR generates input + if (e.ctrlKey || e.altKey) { ignore = true; } } else { - if (line.lineIndex !== lineIndex) { - line.destroy(); - line = that._getLine(lineIndex); - } - selection.extend(line.getOffset(x, y)); - select = true; + //IE and Chrome only send ALT GR when input is generated + if (e.ctrlKey ^ e.altKey) { ignore = true; } } - if (select) { - if (!args.select) { selection.collapse(); } + } + if (!ignore) { + var key = util.isOpera ? e.which : (e.charCode !== undefined ? e.charCode : e.keyCode); + if (key > 31) { + this._doContent(String.fromCharCode (key)); + if (e.preventDefault) { e.preventDefault(); } + return false; } - line.destroy(); - }); - that._setSelection(selections, true, true, null, 0, false, true); - return true; + } }, - _doNoop: function () { - return true; + _handleDocKeyUp: function (e) { + var ctrlKey = util.isMac ? e.metaKey : e.ctrlKey; + if (!ctrlKey) { + this._setLinksVisible(false); + } }, - _doPageDown: function (args) { - var that = this; - var model = this._model; - var selections = this._getSelections(); - var lineCount = model.getLineCount(); - var _scroll = this._getScroll(); - var clientHeight = this._getClientHeight(); - var lineHeight = this._getLineHeight(); - var lines = Math.floor(clientHeight / lineHeight); - var x, line, pageScroll; - selections.forEach(function(selection) { - var caret = selection.getCaret(); - var caretLine = model.getLineAtOffset(caret); - if (that._lineHeight) { - x = selection._columnX; - var caretRect = that._getBoundsAtOffset(caret); - if (x === -1 || (args.select && util.isIE)) { - x = selection._columnX = caretRect.left; - } - var lineIndex = that._getLineIndex(caretRect.top + clientHeight); - line = that._getLine(lineIndex); - var linePixel = that._getLinePixel(lineIndex); - var y = caretRect.top + clientHeight - linePixel; - caret = line.getOffset(x, y); - var rect = line.getBoundingClientRect(caret); - line.destroy(); - selection.extend(caret); - if (!args.select) { selection.collapse(); } - pageScroll = pageScroll !== undefined ? Math.min(pageScroll, rect.top + linePixel - caretRect.top) : rect.top + linePixel - caretRect.top; - } else { - if (caretLine < lineCount - 1) { - var scrollLines = Math.min(lineCount - caretLine - 1, lines); - scrollLines = Math.max(1, scrollLines); - x = selection._columnX; - if (x === -1 || (args.select && util.isIE)) { - line = that._getLine(caretLine); - x = selection._columnX = line.getBoundingClientRect(caret).left; - line.destroy(); - } - line = that._getLine(caretLine + scrollLines); - selection.extend(line.getOffset(x, 0)); - line.destroy(); - if (!args.select) { selection.collapse(); } - var verticalMaximum = lineCount * lineHeight; - var scrollOffset = _scroll.y + scrollLines * lineHeight; - if (scrollOffset + clientHeight > verticalMaximum) { - scrollOffset = verticalMaximum - clientHeight; - } - pageScroll = pageScroll !== undefined ? Math.min(pageScroll, scrollOffset - _scroll.y) : scrollOffset - _scroll.y; - } + _handleKeyUp: function (e) { + if (this._ignoreEvent(e)) { return; } + if (this.isListening("KeyUp")) { //$NON-NLS-1$ + var keyEvent = this._createKeyEvent("KeyUp", e); //$NON-NLS-1$ + this.onKeyUp(keyEvent); //$NON-NLS-1$ + if (keyEvent.defaultPrevented) { + e.preventDefault(); + return; } - }); - this._setSelection(selections, true, true, function() {}, pageScroll, false, true); - return true; + } + this._handleDocKeyUp(e); + // don't commit for space (it happens during JP composition) + if (e.keyCode === 13) { + this._commitIME(); + } }, - _doPageUp: function (args) { - var that = this; - var model = this._model; - var selections = this._getSelections(); - var _scroll = this._getScroll(); - var clientHeight = this._getClientHeight(); - var lineHeight = this._getLineHeight(); - var lines = Math.floor(clientHeight / lineHeight); - var x, line, pageScroll; - selections.forEach(function(selection) { - var caret = selection.getCaret(); - var caretLine = model.getLineAtOffset(caret); - if (that._lineHeight) { - x = selection._columnX; - var caretRect = that._getBoundsAtOffset(caret); - if (x === -1 || (args.select && util.isIE)) { - x = selection._columnX = caretRect.left; - } - var lineIndex = that._getLineIndex(caretRect.bottom - clientHeight); - line = that._getLine(lineIndex); - var linePixel = that._getLinePixel(lineIndex); - var y = (caretRect.bottom - clientHeight) - linePixel; - caret = line.getOffset(x, y); - var rect = line.getBoundingClientRect(caret); - line.destroy(); - selection.extend(caret); - if (!args.select) { selection.collapse(); } - pageScroll = pageScroll !== undefined ? Math.max(pageScroll, rect.top + linePixel - caretRect.top) : rect.top + linePixel - caretRect.top; + _handleLinkClick: function (e) { + var ctrlKey = util.isMac ? e.metaKey : e.ctrlKey; + if (!ctrlKey) { + if (e.preventDefault) { e.preventDefault(); } + return false; + } + }, + _handleMouse: function (e) { + var win = this._getWindow(); + var result = true; + var target = win; + if (util.isIE || (util.isFirefox && !this._overlayDiv)) { target = this._clientDiv; } + if (this._overlayDiv) { + if (this._hasFocus) { + this._ignoreFocus = true; + } + var that = this; + win.setTimeout(function () { + that.focus(); + that._ignoreFocus = false; + }, 0); + } + var extend = e.shiftKey; + var block = e.altKey; + var add = util.isMac ? e.metaKey : e.ctrlKey; + this._blockSelection = this._doubleClickSelection = null; + if (this._clickCount === 1) { + var drag = (!util.isOpera || util.isOpera >= 12.16) && this._hasFocus && this.isListening("DragStart"); //$NON-NLS-1$ + result = this._setSelectionTo(e.clientX, e.clientY, true, extend, add, drag); + if (result) { this._setGrab(target); } + } else { + /* + * Feature in IE8 and older, the sequence of events in the IE8 event model + * for a doule-click is: + * + * down + * up + * up + * dblclick + * + * Given that the mouse down/up events are not balanced, it is not possible to + * grab on mouse down and ungrab on mouse up. The fix is to grab on the first + * mouse down and ungrab on mouse move when the button 1 is not set. + */ + if (this._isW3CEvents) { this._setGrab(target); } + + this._setSelectionTo(e.clientX, e.clientY, true, extend, add, false); + this._doubleClickSelection = Selection.editing(this._getSelections()); + } + if (block) { + this._blockSelection = Selection.editing(this._getSelections()); + } + return result; + }, + _handleMouseDown: function (e) { + if (this._ignoreEvent(e)) { return; } + if (this._linksVisible) { + var target = e.target || e.srcElement; + if (target.tagName !== "A") { //$NON-NLS-1$ + this._setLinksVisible(false); } else { - if (caretLine > 0) { - var scrollLines = Math.max(1, Math.min(caretLine, lines)); - x = selection._columnX; - if (x === -1 || (args.select && util.isIE)) { - line = that._getLine(caretLine); - x = selection._columnX = line.getBoundingClientRect(caret).left; - line.destroy(); - } - line = that._getLine(caretLine - scrollLines); - selection.extend(line.getOffset(x, that._getLineHeight(caretLine - scrollLines) - 1)); - line.destroy(); - if (!args.select) { selection.collapse(); } - var scrollOffset = Math.max(0, _scroll.y - scrollLines * lineHeight); - pageScroll = pageScroll !== undefined ? Math.max(pageScroll, scrollOffset - _scroll.y) : scrollOffset - _scroll.y; - } + return; + } + } + this._commitIME(); + + var button = e.which; // 1 - left, 2 - middle, 3 - right + if (!button) { + // if IE 8 or older + if (e.button === 4) { button = 2; } + if (e.button === 2) { button = 3; } + if (e.button === 1) { button = 1; } + } + + // For middle click we always need getTime(). See _getClipboardText(). + var time = button !== 2 && e.timeStamp ? e.timeStamp : new Date().getTime(); + var timeDiff = time - this._lastMouseTime; + var deltaX = Math.abs(this._lastMouseX - e.clientX); + var deltaY = Math.abs(this._lastMouseY - e.clientY); + var sameButton = this._lastMouseButton === button; + this._lastMouseX = e.clientX; + this._lastMouseY = e.clientY; + this._lastMouseTime = time; + this._lastMouseButton = button; + + if (button === 1) { + this._isMouseDown = true; + if (sameButton && timeDiff <= this._clickTime && deltaX <= this._clickDist && deltaY <= this._clickDist) { + this._clickCount++; + } else { + this._clickCount = 1; } - }); - this._setSelection(selections, true, true, function() {}, pageScroll, false, true); - return true; - }, - _doPaste: function(e) { - var that = this; - var result = this._getClipboardText(e, function(text) { - if (text.length) { - if (util.isLinux && that._lastMouseButton === 2) { - var timeDiff = new Date().getTime() - that._lastMouseTime; - if (timeDiff <= that._clickTime) { - that._setSelectionTo(that._lastMouseX, that._lastMouseY, true); - } + } + if (this.isListening("MouseDown")) { //$NON-NLS-1$ + var mouseEvent = this._createMouseEvent("MouseDown", e); //$NON-NLS-1$ + this.onMouseDown(mouseEvent); + if (mouseEvent.defaultPrevented) { + e.preventDefault(); + return; + } + } + if (button === 1) { + if (this._handleMouse(e) && (util.isIE >= 9 || util.isOpera || util.isChrome || util.isSafari || (util.isFirefox && !this._overlayDiv))) { + if (!this._hasFocus) { + this.focus(); } - var selections = that._getSelections(); - var delimiter = that._singleMode ? "" : that._model.getLineDelimiter(); - that._doContent(selections.length > 1 && selections.length === text.length ? text : text.join(delimiter)); + e.preventDefault(); } - }); - return result !== null; - }, - _doScroll: function (args) { - var type = args.type; - var model = this._model; - var lineCount = model.getLineCount(); - var clientHeight = this._getClientHeight(); - var lineHeight = this._getLineHeight(); - var verticalMaximum = this._lineHeight ? this._scrollHeight : lineCount * lineHeight; - var verticalScrollOffset = this._getScroll().y; - var pixel; - switch (type) { - case "textStart": pixel = 0; break; //$NON-NLS-1$ - case "textEnd": pixel = verticalMaximum - clientHeight; break; //$NON-NLS-1$ - case "pageDown": pixel = verticalScrollOffset + clientHeight; break; //$NON-NLS-1$ - case "pageUp": pixel = verticalScrollOffset - clientHeight; break; //$NON-NLS-1$ - case "lineDown": pixel = verticalScrollOffset + lineHeight; break; //$NON-NLS-1$ - case "lineUp": pixel = verticalScrollOffset - lineHeight; break; //$NON-NLS-1$ - case "centerLine": //$NON-NLS-1$ - var selection = this._getSelections()[0]; - var lineStart = model.getLineAtOffset(selection.start); - var lineEnd = model.getLineAtOffset(selection.end); - var selectionHeight = (lineEnd - lineStart + 1) * lineHeight; - pixel = (lineStart * lineHeight) - (clientHeight / 2) + (selectionHeight / 2); - break; } - if (pixel !== undefined) { - pixel = Math.min(Math.max(0, pixel), verticalMaximum - clientHeight); - this._scrollViewAnimated(0, pixel - verticalScrollOffset, function() {}); + if (util.isFirefox && this._lastMouseButton === 3) { + // We need to update the DOM selection, because on + // right-click the caret moves to the mouse location. + // See bug 366312 and 376508. + this._updateDOMSelection(); } - return true; - }, - _doSelectAll: function () { - var model = this._model; - this._setSelection(new Selection(0, model.getCharCount()), false); - return true; }, - _doTab: function () { - if (!this._tabMode || this._readonly) { return; } - var text = "\t"; //$NON-NLS-1$ - var selections = this._getSelections(); - if (this._expandTab) { - text = []; - var model = this._model; - var tabSize = this._tabSize; - selections.forEach(function(selection) { - var caret = selection.getCaret(); - var lineIndex = model.getLineAtOffset(caret); - var lineStart = model.getLineStart(lineIndex); - var spaces = tabSize - ((caret - lineStart) % tabSize); - text.push((newArray(spaces + 1)).join(" ")); //$NON-NLS-1$ - }); + _handleMouseOver: function (e) { + if (this._ignoreEvent(e)) { return; } + if (this._animation) { return; } + if (this.isListening("MouseOver")) { //$NON-NLS-1$ + this.onMouseOver(this._createMouseEvent("MouseOver", e)); //$NON-NLS-1$ } - return this._modifyContent({text: text, selection: selections, _ignoreDOMSelection: true}, true); - }, - _doShiftTab: function () { - if (!this._tabMode || this._readonly) { return; } - return true; - }, - _doOverwriteMode: function () { - if (this._readonly) { return; } - this.setOptions({overwriteMode: !this.getOptions("overwriteMode")}); //$NON-NLS-1$ - return true; - }, - _doTabMode: function () { - this._tabMode = !this._tabMode; - return true; - }, - _doWrapMode: function () { - this.setOptions({wrapMode: !this.getOptions("wrapMode")}); //$NON-NLS-1$ - return true; }, - - /************************************ Internals ******************************************/ - _autoScroll: function () { - var model = this._model; - var selections = this._getSelections(); - var selection = Selection.editing(selections, this._autoScrollDir === "down"); //$NON-NLS-1$ - var pt = this.convert({x: this._autoScrollX, y: this._autoScrollY}, "page", "document"); //$NON-NLS-1$ //$NON-NLS-2$ - var caret = selection.getCaret(); - var lineCount = model.getLineCount(); - var caretLine = model.getLineAtOffset(caret), lineIndex, line; - if (this._autoScrollDir === "up" || this._autoScrollDir === "down") { //$NON-NLS-1$ //$NON-NLS-1$ - var _scroll = this._autoScrollY / this._getLineHeight(); - _scroll = _scroll < 0 ? Math.floor(_scroll) : Math.ceil(_scroll); - lineIndex = caretLine; - lineIndex = Math.max(0, Math.min(lineCount - 1, lineIndex + _scroll)); - } else if (this._autoScrollDir === "left" || this._autoScrollDir === "right") { //$NON-NLS-1$ //$NON-NLS-1$ - lineIndex = this._getLineIndex(pt.y); - line = this._getLine(caretLine); - pt.x += line.getBoundingClientRect(caret, false).left; - line.destroy(); - } - if (this._blockSelection) { - selections = this._getBlockSelections(selections, lineIndex, pt); - } else if (lineIndex === 0 && (util.isMac || util.isLinux)) { - selection.extend(0); - } else if (lineIndex === lineCount - 1 && (util.isMac || util.isLinux)) { - selection.extend(model.getCharCount()); - } else { - line = this._getLine(lineIndex); - selection.extend(line.getOffset(pt.x, pt.y - this._getLinePixel(lineIndex))); - line.destroy(); + _handleMouseOut: function (e) { + if (this._ignoreEvent(e)) { return; } + if (this._animation) { return; } + if (this.isListening("MouseOut")) { //$NON-NLS-1$ + this.onMouseOut(this._createMouseEvent("MouseOut", e)); //$NON-NLS-1$ } - this._setSelection(selections, true); - }, - _autoScrollTimer: function () { - this._autoScroll(); - var that = this; - var win = this._getWindow(); - this._autoScrollTimerID = win.setTimeout(function () {that._autoScrollTimer();}, this._AUTO_SCROLL_RATE); }, - _calculateLineHeightTimer: function(calculate) { - if (!this._lineHeight) { return; } - if (this._calculateLHTimer) { return; } - var lineCount = this._model.getLineCount(), i = 0; - if (calculate) { - var c = 0; - var MAX_TIME = 100; - var start = new Date().getTime(), firstLine = 0; - while (i < lineCount) { - if (!this._lineHeight[i]) { - c++; - if (!firstLine) { firstLine = i; } - this._lineHeight[i] = this._calculateLineHeight(i); - } - i++; - if ((new Date().getTime() - start) > MAX_TIME) { - break; + _handleMouseMove: function (e) { + if (this._animation) { return; } + var inClient = this._isClientDiv(e); + if (this.isListening("MouseMove")) { //$NON-NLS-1$ + if (inClient || this._isMouseDown){ + var mouseEvent = this._createMouseEvent("MouseMove", e); //$NON-NLS-1$ + this.onMouseMove(mouseEvent); + if (mouseEvent.defaultPrevented) { + e.preventDefault(); + return; } } - this.redrawRulers(0, lineCount); - this._queueUpdate(); } - var win = this._getWindow(); - if (i !== lineCount) { - var that = this; - this._calculateLHTimer = win.setTimeout(function() { - that._calculateLHTimer = null; - that._calculateLineHeightTimer(true); - }, 0); + if (this._dropTarget) { return; } - if (this._calculateLHTimer) { - win.clearTimeout(this._calculateLHTimer); - this._calculateLHTimer = undefined; + /* + * Bug in IE9. IE sends one mouse event when the user changes the text by + * pasting or undo. These operations usually happen with the Ctrl key + * down which causes the view to enter link mode. Link mode does not end + * because there are no further events. The fix is to only enter link + * mode when the coordinates of the mouse move event have changed. + */ + var changed = this._linksVisible || this._lastMouseMoveX !== e.clientX || this._lastMouseMoveY !== e.clientY; + this._lastMouseMoveX = e.clientX; + this._lastMouseMoveY = e.clientY; + this._setLinksVisible(changed && !this._isMouseDown && e.altKey && (util.isMac ? e.metaKey : e.ctrlKey)); + + this._checkOverlayScroll(); + + /* + * Feature in IE8 and older, the sequence of events in the IE8 event model + * for a doule-click is: + * + * down + * up + * up + * dblclick + * + * Given that the mouse down/up events are not balanced, it is not possible to + * grab on mouse down and ungrab on mouse up. The fix is to grab on the first + * mouse down and ungrab on mouse move when the button 1 is not set. + * + * In order to detect double-click and drag gestures, it is necessary to send + * a mouse down event from mouse move when the button is still down and isMouseDown + * flag is not set. + */ + if (!this._isW3CEvents) { + if (e.button === 0) { + this._setGrab(null); + return true; + } + if (!this._isMouseDown && e.button === 1 && (this._clickCount & 1) !== 0 && inClient) { + this._clickCount = 2; + return this._handleMouse(e, this._clickCount); + } } - }, - _calculateLineHeight: function(lineIndex) { - var line = this._getLine(lineIndex); - var rect = line.getBoundingClientRect(); - line.destroy(); - return Math.max(1, rect.bottom - rect.top); - }, - _calculateMetrics: function() { - var _parent = this._clientDiv; - var doc = _parent.ownerDocument; - var c = " "; //$NON-NLS-1$ - var line = util.createElement(doc, "div"); //$NON-NLS-1$ - line.style.lineHeight = "normal"; //$NON-NLS-1$ - var model = this._model; - var lineText = model.getLine(0); - var e = {type:"LineStyle", textView: this, 0: 0, lineText: lineText, lineStart: 0}; //$NON-NLS-1$ - this.onLineStyle(e); - applyStyle(e.style, line); - line.style.position = "fixed"; //$NON-NLS-1$ - line.style.left = "-1000px"; //$NON-NLS-1$ - var span1 = util.createElement(doc, "span"); //$NON-NLS-1$ - span1.appendChild(doc.createTextNode(c)); - line.appendChild(span1); - var span2 = util.createElement(doc, "span"); //$NON-NLS-1$ - span2.style.fontStyle = "italic"; //$NON-NLS-1$ - span2.appendChild(doc.createTextNode(c)); - line.appendChild(span2); - var span3 = util.createElement(doc, "span"); //$NON-NLS-1$ - span3.style.fontWeight = "bold"; //$NON-NLS-1$ - span3.appendChild(doc.createTextNode(c)); - line.appendChild(span3); - var span4 = util.createElement(doc, "span"); //$NON-NLS-1$ - span4.style.fontWeight = "bold"; //$NON-NLS-1$ - span4.style.fontStyle = "italic"; //$NON-NLS-1$ - span4.appendChild(doc.createTextNode(c)); - line.appendChild(span4); - _parent.appendChild(line); - var lineRect = line.getBoundingClientRect(); - var spanRect1 = span1.getBoundingClientRect(); - var spanRect2 = span2.getBoundingClientRect(); - var spanRect3 = span3.getBoundingClientRect(); - var spanRect4 = span4.getBoundingClientRect(); - var h1 = spanRect1.bottom - spanRect1.top; - var h2 = spanRect2.bottom - spanRect2.top; - var h3 = spanRect3.bottom - spanRect3.top; - var h4 = spanRect4.bottom - spanRect4.top; - var fontStyle = 0; - var invalid = (lineRect.bottom - lineRect.top) <= 0; - var lineHeight = Math.max(1, lineRect.bottom - lineRect.top); - if (h2 > h1) { - fontStyle = 1; + if (!this._isMouseDown || this._dragOffset !== -1) { + return; } - if (h3 > h2) { - fontStyle = 2; + + var x = e.clientX; + var y = e.clientY; + var viewPad = this._getViewPadding(); + var viewRect = this._viewDiv.getBoundingClientRect(); + var width = this._getClientWidth (), height = this._getClientHeight(); + var leftEdge = viewRect.left + viewPad.left; + var topEdge = viewRect.top + viewPad.top; + var rightEdge = viewRect.left + viewPad.left + width; + var bottomEdge = viewRect.top + viewPad.top + height; + if (y < topEdge) { + this._doAutoScroll("up", x, y - topEdge); //$NON-NLS-1$ + } else if (y > bottomEdge) { + this._doAutoScroll("down", x, y - bottomEdge); //$NON-NLS-1$ + } else if (x < leftEdge && !this._wrapMode) { + this._doAutoScroll("left", x - leftEdge, y); //$NON-NLS-1$ + } else if (x > rightEdge && !this._wrapMode) { + this._doAutoScroll("right", x - rightEdge, y); //$NON-NLS-1$ + } else { + this._endAutoScroll(); + this._setSelectionTo(x, y, false, true); } - if (h4 > h3) { - fontStyle = 3; + }, + _isClientDiv: function(e) { + var topNode = this._overlayDiv || this._clientDiv; + var temp = e.target ? e.target : e.srcElement; + while (temp) { + if (topNode === temp) { + return true; + } + temp = temp.parentNode; } - var style; - if (fontStyle !== 0) { - style = {style: {}}; - if ((fontStyle & 1) !== 0) { - style.style.fontStyle = "italic"; //$NON-NLS-1$ + return false; + }, + _createKeyEvent: function(type, e) { + return { + type: type, + event: e, + preventDefault: function() { + this.defaultPrevented = true; } - if ((fontStyle & 2) !== 0) { - style.style.fontWeight = "bold"; //$NON-NLS-1$ + }; + }, + _createMouseEvent: function(type, e) { + var pt = this.convert({x: e.clientX, y: e.clientY}, "page", "document"); //$NON-NLS-1$ //$NON-NLS-2$ + return { + type: type, + event: e, + clickCount: this._clickCount, + x: pt.x, + y: pt.y, + preventDefault: function() { + this.defaultPrevented = true; + } + }; + }, + _createTouchEvent: function(type, e) { + var pt = e.touches.length ? this.convert({x: e.touches[0].clientX, y: e.touches[0].clientY}, "page", "document") : {}; //$NON-NLS-1$ //$NON-NLS-2$ + return { + type: type, + event: e, + touchCount: e.touches.length, + x: pt.x, + y: pt.y, + preventDefault: function() { + this.defaultPrevented = true; + } + }; + }, + _handleMouseUp: function (e) { + var left = e.which ? e.button === 0 : e.button === 1; + if (this.isListening("MouseUp")) { //$NON-NLS-1$ + if (this._isClientDiv(e) || (left && this._isMouseDown)) { + var mouseEvent = this._createMouseEvent("MouseUp", e); //$NON-NLS-1$ + this.onMouseUp(mouseEvent); + if (mouseEvent.defaultPrevented) { + e.preventDefault(); + this._isMouseDown = false; + return; + } } } - var trim = getLineTrim(line); - _parent.removeChild(line); - - // calculate pad and scroll width - var pad = getPadding(this._viewDiv); - var div1 = util.createElement(doc, "div"); //$NON-NLS-1$ - div1.style.position = "fixed"; //$NON-NLS-1$ - div1.style.left = "-1000px"; //$NON-NLS-1$ - div1.style.paddingLeft = pad.left + "px"; //$NON-NLS-1$ - div1.style.paddingTop = pad.top + "px"; //$NON-NLS-1$ - div1.style.paddingRight = pad.right + "px"; //$NON-NLS-1$ - div1.style.paddingBottom = pad.bottom + "px"; //$NON-NLS-1$ - div1.style.width = "100px"; //$NON-NLS-1$ - div1.style.height = "100px"; //$NON-NLS-1$ - var div2 = util.createElement(doc, "div"); //$NON-NLS-1$ - div2.style.width = "100%"; //$NON-NLS-1$ - div2.style.height = "100%"; //$NON-NLS-1$ - div1.appendChild(div2); - _parent.appendChild(div1); - var rect1 = div1.getBoundingClientRect(); - var rect2 = div2.getBoundingClientRect(); - var scrollWidth = 0; - if (!this._singleMode && !this._noScroll) { - div1.style.overflow = 'hidden'; //$NON-NLS-1$ - div2.style.height = "200px"; //$NON-NLS-1$ - var w1 = div1.clientWidth; - div1.style.overflow = 'scroll'; //$NON-NLS-1$ - var w2 = div1.clientWidth; - scrollWidth = w1 - w2; + if (this._linksVisible) { + return; + } + if (left && this._isMouseDown) { + var selections = this._getSelections(); + var selection = Selection.editing(selections); + selections.forEach(function(sel) { + sel._editing = false; + }); + if (this._dragOffset !== -1) { + selection.extend(this._dragOffset); + selection.collapse(); + selections = selection; + this._dragOffset = -1; + } + this._setSelection(selections, false); + this._isMouseDown = false; + this._endAutoScroll(); + + /* + * Feature in IE8 and older, the sequence of events in the IE8 event model + * for a doule-click is: + * + * down + * up + * up + * dblclick + * + * Given that the mouse down/up events are not balanced, it is not possible to + * grab on mouse down and ungrab on mouse up. The fix is to grab on the first + * mouse down and ungrab on mouse move when the button 1 is not set. + */ + if (this._isW3CEvents) { this._setGrab(null); } + } + /* + * Note that there cases when Firefox sets the DOM selection in mouse up. + * This happens for example after a cancelled drag operation. + * + * Note that on Chrome and IE, the caret stops blicking if mouse up is + * prevented. + */ + if (left && this._isMouseDown && util.isFirefox) { + this._updateDOMSelection(); + e.preventDefault(); + } + }, + _handleMouseWheel: function (e) { + if (this._noScroll) return; + var lineHeight = this._getLineHeight(); + var pixelX = 0, pixelY = 0; + // Note: On the Mac the correct behaviour is to scroll by pixel. + if (util.isIE || util.isOpera) { + pixelY = (-e.wheelDelta / 40) * lineHeight; + } else if (util.isFirefox) { + var limit = 256; + if (e.type === "wheel") { //$NON-NLS-1$ + if (e.deltaMode) { // page or line + pixelX = Math.max(-limit, Math.min(limit, e.deltaX)) * lineHeight; + pixelY = Math.max(-limit, Math.min(limit, e.deltaY)) * lineHeight; + } else { + pixelX = e.deltaX; + pixelY = e.deltaY; + } + } else { + var pixel; + if (util.isMac) { + pixel = e.detail * 3; + } else { + pixel = Math.max(-limit, Math.min(limit, e.detail)) * lineHeight; + } + if (e.axis === e.HORIZONTAL_AXIS) { + pixelX = pixel; + } else { + pixelY = pixel; + } + } + } else { + //Webkit + if (util.isMac) { + /* + * In Safari, the wheel delta is a multiple of 120. In order to + * convert delta to pixel values, it is necessary to divide delta + * by 40. + * + * In Chrome and Safari 5, the wheel delta depends on the type of the + * mouse. In general, it is the pixel value for Mac mice and track pads, + * but it is a multiple of 120 for other mice. There is no presise + * way to determine if it is pixel value or a multiple of 120. + * + * Note that the current approach does not calculate the correct + * pixel value for Mac mice when the delta is a multiple of 120. + * + * For values that are multiples of 120, the denominator varies on + * the time between events. + */ + var denominatorX, denominatorY; + var deltaTime = e.timeStamp - this._wheelTimeStamp; + this._wheelTimeStamp = e.timeStamp; + if (e.wheelDeltaX % 120 !== 0) { + denominatorX = 1; + } else { + denominatorX = deltaTime < 40 ? 40/(40-deltaTime) : 40; + } + if (e.wheelDeltaY % 120 !== 0) { + denominatorY = 1; + } else { + denominatorY = deltaTime < 40 ? 40/(40-deltaTime) : 40; + } + pixelX = Math.ceil(-e.wheelDeltaX / denominatorX); + if (-1 < pixelX && pixelX < 0) { pixelX = -1; } + if (0 < pixelX && pixelX < 1) { pixelX = 1; } + pixelY = Math.ceil(-e.wheelDeltaY / denominatorY); + if (-1 < pixelY && pixelY < 0) { pixelY = -1; } + if (0 < pixelY && pixelY < 1) { pixelY = 1; } + } else { + pixelX = -e.wheelDeltaX; + var linesToScroll = 8; + pixelY = (-e.wheelDeltaY / 120 * linesToScroll) * lineHeight; + } } - _parent.removeChild(div1); - pad = { - left: rect2.left - rect1.left, - top: rect2.top - rect1.top, - right: rect1.right - rect2.right, - bottom: rect1.bottom - rect2.bottom - }; - var wrapWidth = 0, marginWidth = 0, charWidth = 0; - if (!invalid) { - div1 = util.createElement(doc, "div"); //$NON-NLS-1$ - div1.style.position = "fixed"; //$NON-NLS-1$ - div1.style.left = "-1000px"; //$NON-NLS-1$ - _parent.appendChild(div1); - div1.innerHTML = newArray(2).join("a"); //$NON-NLS-1$ - rect1 = div1.getBoundingClientRect(); - charWidth = Math.ceil(rect1.right - rect1.left); - if (this._wrapOffset || this._marginOffset) { - div1.innerHTML = newArray(this._wrapOffset + 1 + (util.isWebkit ? 0 : 1)).join(" "); //$NON-NLS-1$ - rect1 = div1.getBoundingClientRect(); - wrapWidth = Math.ceil(rect1.right - rect1.left); - div1.innerHTML = newArray(this._marginOffset + 1).join(" "); //$NON-NLS-1$ - rect2 = div1.getBoundingClientRect(); - marginWidth = Math.ceil(rect2.right - rect2.left); + /* + * Feature in Safari. If the event target is removed from the DOM + * safari stops smooth scrolling. The fix is keep the element target + * in the DOM and remove it on a later time. + * + * Note: Using a timer is not a solution, because the timeout needs to + * be at least as long as the gesture (which is too long). + */ + if (util.isSafari || (util.isChrome && util.isMac)) { + var lineDiv = e.target; + while (lineDiv && lineDiv.lineIndex === undefined) { + lineDiv = lineDiv.parentNode; } - _parent.removeChild(div1); + this._mouseWheelLine = lineDiv; + } + var oldScroll = this._getScroll(); + this._scrollView(pixelX, pixelY); + var newScroll = this._getScroll(); + if (oldScroll.x !== newScroll.x || oldScroll.y !== newScroll.y) { + if (e.preventDefault) { e.preventDefault(); } + return false; } - return { - lineHeight: lineHeight, - largestFontStyle: style, - lineTrim: trim, - viewPadding: pad, - scrollWidth: scrollWidth, - wrapWidth: wrapWidth, - marginWidth: marginWidth, - charWidth: charWidth, - invalid: invalid - }; }, - _cancelAnimation: function() { - if (this._animation) { - this._animation.stop(); - this._animation = null; + _handlePaste: function (e) { + this._cancelCheckSelection(); + if (this._ignoreEvent(e)) { return; } + if (this._ignorePaste) { return; } + if (this._doPaste(e)) { + if (util.isIE) { + /* + * Bug in IE, + */ + var that = this; + this._ignoreFocus = true; + var win = this._getWindow(); + win.setTimeout(function() { + that._updateDOMSelection(); + that._ignoreFocus = false; + }, 0); + } + if (e.preventDefault) { e.preventDefault(); } + return false; } }, - _clearSelection: function (direction) { - var selections = this._getSelections(); - selections.forEach(function(selection) { - if (direction === "next") { //$NON-NLS-1$ - selection.start = selection.end; + _handleResize: function () { + var newWidth = this._rootDiv.clientWidth; + var newHeight = this._rootDiv.clientHeight; + if (this._rootWidth !== newWidth || this._rootHeight !== newHeight) { + if (this._rootWidth !== newWidth && this._wrapMode) { + this._resetLineHeight(); + } + this._rootWidth = newWidth; + this._rootHeight = newHeight; + /* + * Feature in IE7. For some reason, sometimes Internet Explorer 7 + * returns incorrect values for element.getBoundingClientRect() when + * inside a resize handler. The fix is to queue the work. + */ + var queue = util.isIE < 9; + + /* + * The calculated metrics may be out of date when the zoom level changes. + */ + var metrics = this._calculateMetrics(); + if (!compare(metrics, this._metrics)) { + if (this._metrics.invalid && !metrics.invalid) { + this._updateStyle(false, metrics); + } else { + if (this._variableLineHeight) { + this._variableLineHeight = false; + this._resetLineHeight(); + } + this._metrics = metrics; + } + queue = true; + } + + if (queue) { + this._queueUpdate(); } else { - selection.end = selection.start; + this._update(); } - }); - this._setSelection(selections, true); - return true; + this.dispatchEvent({type: "Resize"}); //$NON-NLS-1$ + } }, - _commitIME: function (insertText) { - if (this._imeOffset === -1) { return; } - var model = this._model; - var lineIndex = model.getLineAtOffset(this._imeOffset); - var lineStart = model.getLineStart(lineIndex); - var line = this._getLineNode(lineIndex); - if (!insertText) { - // make the state of the IME match the state the view expects it be in - // when the view commits the text and IME also need to be committed - // this can be accomplished by changing the focus around - this._scrollDiv.focus(); - this._clientDiv.focus(); - - var newText = this._getDOMText(line).text; - var oldText = model.getLine(lineIndex); - var start = this._imeOffset - lineStart; - var end = start + newText.length - oldText.length; - if (start !== end) { - insertText = newText.substring(start, end); + _handleRulerEvent: function (e) { + var target = e.target ? e.target : e.srcElement; + var lineIndex = target.lineIndex; + var element = target; + while (element && !element._ruler) { + if (lineIndex === undefined && element.lineIndex !== undefined) { + lineIndex = element.lineIndex; } + element = element.parentNode; } - this._imeOffset = -1; - if (insertText) { - if (!this._doContent(insertText) && !util.isWebkit) { - line.lineRemoved = true; - this._queueUpdate(); + var ruler = element ? element._ruler : null; + if (lineIndex === undefined && ruler && ruler.getOverview() === "document") { //$NON-NLS-1$ + var clientHeight = this._getClientHeight (); + var lineCount = this._model.getLineCount (); + var viewPad = this._getViewPadding(); + var viewRect = this._viewDiv.getBoundingClientRect(); + var lineHeight = this._getLineHeight(); + var contentHeight = lineHeight * lineCount; + var trackHeight = clientHeight + viewPad.top + viewPad.bottom - 2 * this._metrics.scrollWidth; + var divHeight, arrowWidth; + if (contentHeight < trackHeight) { + divHeight = lineHeight; + arrowWidth = viewPad.top; + } else { + divHeight = trackHeight / lineCount; + arrowWidth = this._metrics.scrollWidth; + } + lineIndex = Math.floor(((e.clientY - viewRect.top) - arrowWidth) / divHeight); + if (!(0 <= lineIndex && lineIndex < lineCount)) { + lineIndex = undefined; + } + } + if (ruler) { + switch (e.type) { + case "click": //$NON-NLS-1$ + if (ruler.onClick) { ruler.onClick(lineIndex, e); } + break; + case "dblclick": //$NON-NLS-1$ + if (ruler.onDblClick) { ruler.onDblClick(lineIndex, e); } + break; + case "mousemove": //$NON-NLS-1$ + if (ruler.onMouseMove) { ruler.onMouseMove(lineIndex, e); } + break; + case "mouseover": //$NON-NLS-1$ + if (ruler.onMouseOver) { ruler.onMouseOver(lineIndex, e); } + break; + case "mouseout": //$NON-NLS-1$ + if (ruler.onMouseOut) { + var tmp = e.relatedTarget; + while (tmp && tmp !== this._rootDiv) { + if (tmp === element) { + return; + } + tmp = tmp.parentNode; + } + ruler.onMouseOut(lineIndex, e); + } + break; } } }, - _createActions: function () { - this.addKeyMode(new mKeyModes.DefaultKeyMode(this)); - //1 to 1, no duplicates - var that = this; - this._actions = { - "noop": {defaultHandler: function() {return that._doNoop();}}, //$NON-NLS-1$ - - "lineUp": {defaultHandler: function(data) {return that._doLineUp(merge(data,{select: false}));}, actionDescription: {name: messages.lineUp}}, //$NON-NLS-1$ - "lineDown": {defaultHandler: function(data) {return that._doLineDown(merge(data,{select: false}));}, actionDescription: {name: messages.lineDown}}, //$NON-NLS-1$ - "lineStart": {defaultHandler: function(data) {return that._doHome(merge(data,{select: false, ctrl:false}));}, actionDescription: {name: messages.lineStart}}, //$NON-NLS-1$ - "lineEnd": {defaultHandler: function(data) {return that._doEnd(merge(data,{select: false, ctrl:false}));}, actionDescription: {name: messages.lineEnd}}, //$NON-NLS-1$ - "charPrevious": {defaultHandler: function(data) {return that._doCursorPrevious(merge(data,{select: false, unit:"character"}));}, actionDescription: {name: messages.charPrevious}}, //$NON-NLS-1$ //$NON-NLS-1$ - "charNext": {defaultHandler: function(data) {return that._doCursorNext(merge(data,{select: false, unit:"character"}));}, actionDescription: {name: messages.charNext}}, //$NON-NLS-1$ //$NON-NLS-1$ - "pageUp": {defaultHandler: function(data) {return that._doPageUp(merge(data,{select: false}));}, actionDescription: {name: messages.pageUp}}, //$NON-NLS-1$ - "pageDown": {defaultHandler: function(data) {return that._doPageDown(merge(data,{select: false}));}, actionDescription: {name: messages.pageDown}}, //$NON-NLS-1$ - "scrollPageUp": {defaultHandler: function(data) {return that._doScroll(merge(data,{type: "pageUp"}));}, actionDescription: {name: messages.scrollPageUp}}, //$NON-NLS-1$ //$NON-NLS-1$ - "scrollPageDown": {defaultHandler: function(data) {return that._doScroll(merge(data,{type: "pageDown"}));}, actionDescription: {name: messages.scrollPageDown}}, //$NON-NLS-1$ //$NON-NLS-1$ - "scrollLineUp": {defaultHandler: function(data) {return that._doScroll(merge(data,{type: "lineUp"}));}, actionDescription: {name: messages.scrollLineUp}}, //$NON-NLS-1$ //$NON-NLS-1$ - "scrollLineDown": {defaultHandler: function(data) {return that._doScroll(merge(data,{type: "lineDown"}));}, actionDescription: {name: messages.scrollLineDown}}, //$NON-NLS-1$ //$NON-NLS-1$ - "wordPrevious": {defaultHandler: function(data) {return that._doCursorPrevious(merge(data,{select: false, unit:"word"}));}, actionDescription: {name: messages.wordPrevious}}, //$NON-NLS-1$ //$NON-NLS-1$ - "wordNext": {defaultHandler: function(data) {return that._doCursorNext(merge(data,{select: false, unit:"word"}));}, actionDescription: {name: messages.wordNext}}, //$NON-NLS-1$ //$NON-NLS-1$ - "textStart": {defaultHandler: function(data) {return that._doHome(merge(data,{select: false, ctrl:true}));}, actionDescription: {name: messages.textStart}}, //$NON-NLS-1$ - "textEnd": {defaultHandler: function(data) {return that._doEnd(merge(data,{select: false, ctrl:true}));}, actionDescription: {name: messages.textEnd}}, //$NON-NLS-1$ - "scrollTextStart": {defaultHandler: function(data) {return that._doScroll(merge(data,{type: "textStart"}));}, actionDescription: {name: messages.scrollTextStart}}, //$NON-NLS-1$ //$NON-NLS-1$ - "scrollTextEnd": {defaultHandler: function(data) {return that._doScroll(merge(data,{type: "textEnd"}));}, actionDescription: {name: messages.scrollTextEnd}}, //$NON-NLS-1$ //$NON-NLS-1$ - "centerLine": {defaultHandler: function(data) {return that._doScroll(merge(data,{type: "centerLine"}));}, actionDescription: {name: messages.centerLine}}, //$NON-NLS-1$ //$NON-NLS-1$ - - "selectLineUp": {defaultHandler: function(data) {return that._doLineUp(merge(data,{select: true}));}, actionDescription: {name: messages.selectLineUp}}, //$NON-NLS-1$ - "selectLineDown": {defaultHandler: function(data) {return that._doLineDown(merge(data,{select: true}));}, actionDescription: {name: messages.selectLineDown}}, //$NON-NLS-1$ - "selectWholeLineUp": {defaultHandler: function(data) {return that._doLineUp(merge(data,{select: true, wholeLine: true}));}, actionDescription: {name: messages.selectWholeLineUp}}, //$NON-NLS-1$ - "selectWholeLineDown": {defaultHandler: function(data) {return that._doLineDown(merge(data,{select: true, wholeLine: true}));}, actionDescription: {name: messages.selectWholeLineDown}}, //$NON-NLS-1$ - "selectLineStart": {defaultHandler: function(data) {return that._doHome(merge(data,{select: true, ctrl:false}));}, actionDescription: {name: messages.selectLineStart}}, //$NON-NLS-1$ - "selectLineEnd": {defaultHandler: function(data) {return that._doEnd(merge(data,{select: true, ctrl:false}));}, actionDescription: {name: messages.selectLineEnd}}, //$NON-NLS-1$ - "selectCharPrevious": {defaultHandler: function(data) {return that._doCursorPrevious(merge(data,{select: true, unit:"character"}));}, actionDescription: {name: messages.selectCharPrevious}}, //$NON-NLS-1$ //$NON-NLS-1$ - "selectCharNext": {defaultHandler: function(data) {return that._doCursorNext(merge(data,{select: true, unit:"character"}));}, actionDescription: {name: messages.selectCharNext}}, //$NON-NLS-1$ //$NON-NLS-1$ - "selectPageUp": {defaultHandler: function(data) {return that._doPageUp(merge(data,{select: true}));}, actionDescription: {name: messages.selectPageUp}}, //$NON-NLS-1$ - "selectPageDown": {defaultHandler: function(data) {return that._doPageDown(merge(data,{select: true}));}, actionDescription: {name: messages.selectPageDown}}, //$NON-NLS-1$ - "selectWordPrevious": {defaultHandler: function(data) {return that._doCursorPrevious(merge(data,{select: true, unit:"word"}));}, actionDescription: {name: messages.selectWordPrevious}}, //$NON-NLS-1$ //$NON-NLS-1$ - "selectWordNext": {defaultHandler: function(data) {return that._doCursorNext(merge(data,{select: true, unit:"word"}));}, actionDescription: {name: messages.selectWordNext}}, //$NON-NLS-1$ //$NON-NLS-1$ - "selectTextStart": {defaultHandler: function(data) {return that._doHome(merge(data,{select: true, ctrl:true}));}, actionDescription: {name: messages.selectTextStart}}, //$NON-NLS-1$ - "selectTextEnd": {defaultHandler: function(data) {return that._doEnd(merge(data,{select: true, ctrl:true}));}, actionDescription: {name: messages.selectTextEnd}}, //$NON-NLS-1$ - - "deletePrevious": {defaultHandler: function(data) {return that._doBackspace(merge(data,{unit:"character"}));}, actionDescription: {name: messages.deletePrevious}}, //$NON-NLS-1$ //$NON-NLS-1$ - "deleteNext": {defaultHandler: function(data) {return that._doDelete(merge(data,{unit:"character"}));}, actionDescription: {name: messages.deleteNext}}, //$NON-NLS-1$ //$NON-NLS-1$ - "deleteWordPrevious": {defaultHandler: function(data) {return that._doBackspace(merge(data,{unit:"word"}));}, actionDescription: {name: messages.deleteWordPrevious}}, //$NON-NLS-1$ //$NON-NLS-1$ - "deleteWordNext": {defaultHandler: function(data) {return that._doDelete(merge(data,{unit:"word"}));}, actionDescription: {name: messages.deleteWordNext}}, //$NON-NLS-1$ //$NON-NLS-1$ - "deleteLineStart": {defaultHandler: function(data) {return that._doBackspace(merge(data,{unit: "line"}));}, actionDescription: {name: messages.deleteLineStart}}, //$NON-NLS-1$ //$NON-NLS-1$ - "deleteLineEnd": {defaultHandler: function(data) {return that._doDelete(merge(data,{unit: "line"}));}, actionDescription: {name: messages.deleteLineEnd}}, //$NON-NLS-1$ //$NON-NLS-1$ - "tab": {defaultHandler: function(data) {return that._doTab(merge(data,{}));}, actionDescription: {name: messages.tab}}, //$NON-NLS-1$ - "shiftTab": {defaultHandler: function(data) {return that._doShiftTab(merge(data,{}));}, actionDescription: {name: messages.shiftTab}}, //$NON-NLS-1$ - "enter": {defaultHandler: function(data) {return that._doEnter(merge(data,{}));}, actionDescription: {name: messages.enter}}, //$NON-NLS-1$ - "enterNoCursor": {defaultHandler: function(data) {return that._doEnter(merge(data,{noCursor:true}));}, actionDescription: {name: messages.enterNoCursor}}, //$NON-NLS-1$ - "escape": {defaultHandler: function(data) {return that._doEscape(merge(data,{}));}, actionDescription: {name: messages.escape}}, //$NON-NLS-1$ - "selectAll": {defaultHandler: function(data) {return that._doSelectAll(merge(data,{}));}, actionDescription: {name: messages.selectAll}}, //$NON-NLS-1$ - "copy": {defaultHandler: function(data) {return that._doCopy(merge(data,{}));}, actionDescription: {name: messages.copy}}, //$NON-NLS-1$ - "cut": {defaultHandler: function(data) {return that._doCut(merge(data,{}));}, actionDescription: {name: messages.cut}}, //$NON-NLS-1$ - "paste": {defaultHandler: function(data) {return that._doPaste(merge(data,{}));}, actionDescription: {name: messages.paste}}, //$NON-NLS-1$ - - "uppercase": {defaultHandler: function(data) {return that._doCase(merge(data,{type: "upper"}));}, actionDescription: {name: messages.uppercase}}, //$NON-NLS-1$ //$NON-NLS-1$ - "lowercase": {defaultHandler: function(data) {return that._doCase(merge(data,{type: "lower"}));}, actionDescription: {name: messages.lowercase}}, //$NON-NLS-1$ //$NON-NLS-1$ - "capitalize": {defaultHandler: function(data) {return that._doCase(merge(data,{unit: "word", type: "capitalize"}));}, actionDescription: {name: messages.capitalize}}, //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-1$ - "reversecase": {defaultHandler: function(data) {return that._doCase(merge(data,{type: "reverse"}));}, actionDescription: {name: messages.reversecase}}, //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-1$ - - "toggleOverwriteMode": {defaultHandler: function(data) {return that._doOverwriteMode(merge(data,{}));}, actionDescription: {name: messages.toggleOverwriteMode}}, //$NON-NLS-1$ - "toggleTabMode": {defaultHandler: function(data) {return that._doTabMode(merge(data,{}));}, actionDescription: {name: messages.toggleTabMode}}, //$NON-NLS-1$ - "toggleWrapMode": {defaultHandler: function(data) {return that._doWrapMode(merge(data,{}));}, actionDescription: {name: messages.toggleWrapMode}} //$NON-NLS-1$ - }; - }, - _createRulerParent: function(doc, className) { - var div = util.createElement(doc, "div"); //$NON-NLS-1$ - div.className = className; - div.tabIndex = -1; - div.style.overflow = "hidden"; //$NON-NLS-1$ - div.style.MozUserSelect = "none"; //$NON-NLS-1$ - div.style.WebkitUserSelect = "none"; //$NON-NLS-1$ - div.style.position = "absolute"; //$NON-NLS-1$ - div.style.top = "0px"; //$NON-NLS-1$ - div.style.bottom = "0px"; //$NON-NLS-1$ - div.style.cursor = "default"; //$NON-NLS-1$ - div.style.display = "none"; //$NON-NLS-1$ - div.setAttribute("aria-hidden", "true"); //$NON-NLS-1$ //$NON-NLS-2$ - this._rootDiv.appendChild(div); - return div; + _handleScroll: function () { + this._lastScrollTime = new Date().getTime(); + var _scroll = this._getScroll(false); + var oldX = this._hScroll; + var oldY = this._vScroll; + if (oldX !== _scroll.x || oldY !== _scroll.y) { + this._hScroll = _scroll.x; + this._vScroll = _scroll.y; + this._commitIME(); + this._update(oldY === _scroll.y); + var e = { + type: "Scroll", //$NON-NLS-1$ + oldValue: {x: oldX, y: oldY}, + newValue: _scroll + }; + this.onScroll(e); + } }, - _createRuler: function(ruler, index) { - if (!this._clientDiv) { return; } - var rulerParent = this._getRulerParent(ruler); - if (!rulerParent) { return; } - if (rulerParent !== this._marginDiv || this._marginOffset) { - rulerParent.style.display = "block"; //$NON-NLS-1$ + _handleSelectStart: function (e) { + var menuOpen = this._contextMenuOpen; + this._contextMenuOpen = false; + if (menuOpen) { + this._checkSelectionChange = true; + return; } - rulerParent.rulerWidth = undefined; - var div = util.createElement(rulerParent.ownerDocument, "div"); //$NON-NLS-1$ - div._ruler = ruler; - ruler.node = div; - div.rulerChanged = true; - div.style.position = "relative"; //$NON-NLS-1$ - div.style.cssFloat = "left"; //$NON-NLS-1$ - div.style.styleFloat = "left"; //$NON-NLS-1$ - div.style.outline = "none"; //$NON-NLS-1$ - if (index === undefined || index < 0 || index >= rulerParent.children.length) { - rulerParent.appendChild(div); - } else { - var sibling = rulerParent.firstChild; - while (sibling && index-- > 0) { - sibling = sibling.nextSibling; - } - rulerParent.insertBefore(div, sibling); + if (this._ignoreSelect) { + if (e && e.preventDefault) { e.preventDefault(); } + return false; } }, - _createSelectionDiv: function() { - var div = util.createElement(this._parent.ownerDocument, "div"); //$NON-NLS-1$ - div.className = "textviewSelection"; //$NON-NLS-1$ - div.style.position = "absolute"; //$NON-NLS-1$ - div.style.borderWidth = "0px"; //$NON-NLS-1$ - div.style.margin = "0px"; //$NON-NLS-1$ - div.style.padding = "0px"; //$NON-NLS-1$ - div.style.outline = "none"; //$NON-NLS-1$ - div.style.width = "0px"; //$NON-NLS-1$ - div.style.height = "0px"; //$NON-NLS-1$ - div.style.zIndex = "0"; //$NON-NLS-1$ - return div; - }, - _createView: function() { - if (this._clientDiv) { return; } - var _parent = this._parent; - while (_parent.hasChildNodes()) { _parent.removeChild(_parent.lastChild); } - - var doc = _parent.ownerDocument; - var rootDiv = util.createElement(doc, "div"); //$NON-NLS-1$ - this._rootDiv = rootDiv; - rootDiv.tabIndex = -1; - rootDiv.style.position = "relative"; //$NON-NLS-1$ - rootDiv.style.overflow = "hidden"; //$NON-NLS-1$ - rootDiv.style.width = "100%"; //$NON-NLS-1$ - rootDiv.style.height = "100%"; //$NON-NLS-1$ - rootDiv.style.overflow = "hidden"; //$NON-NLS-1$ - rootDiv.style.WebkitTextSizeAdjust = "100%"; //$NON-NLS-1$ - rootDiv.setAttribute("role", "application"); //$NON-NLS-1$ //$NON-NLS-2$ - _parent.appendChild(rootDiv); - - var leftDiv = this._createRulerParent(doc, "textviewLeftRuler"); //$NON-NLS-1$ - this._leftDiv = leftDiv; - - var viewDiv = util.createElement(doc, "div"); //$NON-NLS-1$ - viewDiv.className = "textviewScroll"; //$NON-NLS-1$ - this._viewDiv = viewDiv; - viewDiv.tabIndex = -1; - viewDiv.style.position = "absolute"; //$NON-NLS-1$ - viewDiv.style.top = "0px"; //$NON-NLS-1$ - viewDiv.style.bottom = "0px"; //$NON-NLS-1$ - viewDiv.style.borderWidth = "0px"; //$NON-NLS-1$ - viewDiv.style.margin = "0px"; //$NON-NLS-1$ - viewDiv.style.outline = "none"; //$NON-NLS-1$ - viewDiv.style.background = "transparent"; //$NON-NLS-1$ - rootDiv.appendChild(viewDiv); - - var rightDiv = this._createRulerParent(doc, "textviewRightRuler"); //$NON-NLS-1$ - this._rightDiv = rightDiv; - if (document.dir == "rtl") { /* ACGC */ - rightDiv.style.left = "0px"; //$NON-NLS-1$ - }else{ - rightDiv.style.right = "0px"; //$NON-NLS-1$ + _getModelOffset: function(node, offset) { + if (!node) { return; } + var lineNode; + if (node.tagName === "DIV") { //$NON-NLS-1$ + lineNode = node; + } else { + lineNode = node.parentNode.parentNode; } - - var innerRightDiv = this._createRulerParent(doc, "textviewInnerRightRuler"); //$NON-NLS-1$ - this._innerRightDiv = innerRightDiv; - innerRightDiv.style.zIndex = "1"; //$NON-NLS-1$ - - var scrollDiv = util.createElement(doc, "div"); //$NON-NLS-1$ - this._scrollDiv = scrollDiv; - scrollDiv.style.margin = "0px"; //$NON-NLS-1$ - scrollDiv.style.borderWidth = "0px"; //$NON-NLS-1$ - scrollDiv.style.padding = "0px"; //$NON-NLS-1$ - viewDiv.appendChild(scrollDiv); - - var marginDiv = this._marginDiv = this._createRulerParent(doc, "textviewMarginRuler"); //$NON-NLS-1$ - marginDiv.style.zIndex = "4"; //$NON-NLS-1$ - - if (!util.isIE && !util.isIOS) { - var clipDiv = util.createElement(doc, "div"); //$NON-NLS-1$ - this._clipDiv = clipDiv; - clipDiv.style.position = "absolute"; //$NON-NLS-1$ - clipDiv.style.overflow = "hidden"; //$NON-NLS-1$ - clipDiv.style.margin = "0px"; //$NON-NLS-1$ - clipDiv.style.borderWidth = "0px"; //$NON-NLS-1$ - clipDiv.style.padding = "0px"; //$NON-NLS-1$ - clipDiv.style.background = "transparent"; //$NON-NLS-1$ - rootDiv.appendChild(clipDiv); - - var clipScrollDiv = util.createElement(doc, "div"); //$NON-NLS-1$ - this._clipScrollDiv = clipScrollDiv; - clipScrollDiv.style.position = "absolute"; //$NON-NLS-1$ - clipScrollDiv.style.height = "1px"; //$NON-NLS-1$ - clipScrollDiv.style.top = "-1000px"; //$NON-NLS-1$ - clipScrollDiv.style.background = "transparent"; //$NON-NLS-1$ - clipDiv.appendChild(clipScrollDiv); + if (!lineNode._line) { + return 0; } - - var clientDiv = util.createElement(doc, "div"); //$NON-NLS-1$ - clientDiv.className = "textviewContent"; //$NON-NLS-1$ - this._clientDiv = clientDiv; - clientDiv.tabIndex = 0; - clientDiv.style.position = "absolute"; //$NON-NLS-1$ - clientDiv.style.borderWidth = "0px"; //$NON-NLS-1$ - clientDiv.style.margin = "0px"; //$NON-NLS-1$ - clientDiv.style.padding = "0px"; //$NON-NLS-1$ - clientDiv.style.outline = "none"; //$NON-NLS-1$ - clientDiv.style.zIndex = "1"; //$NON-NLS-1$ - clientDiv.style.WebkitUserSelect = "text"; //$NON-NLS-1$ - clientDiv.setAttribute("spellcheck", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - if (util.isIOS || util.isAndroid) { - clientDiv.style.WebkitTapHighlightColor = "transparent"; //$NON-NLS-1$ + return lineNode._line.getModelOffset (node, offset); + }, + _updateSelectionFromDOM: function() { + if (!(util.isIOS || util.isAndroid || this._checkSelectionChange)) { + return false; + } + var win = this._getWindow(); + var selection = win.getSelection(); + var start = this._getModelOffset(selection.anchorNode, selection.anchorOffset); + var end = this._getModelOffset(selection.focusNode, selection.focusOffset); + var sel = this._getSelections()[0]; + if (start === undefined || end === undefined || (sel.start === start && sel.end === end)) { + return false; } - (this._clipDiv || rootDiv).appendChild(clientDiv); - - this._setFullSelection(this._fullSelection, true); - if (util.isIOS || util.isAndroid) { - var vScrollDiv = util.createElement(doc, "div"); //$NON-NLS-1$ - this._vScrollDiv = vScrollDiv; - vScrollDiv.style.position = "absolute"; //$NON-NLS-1$ - vScrollDiv.style.borderWidth = "1px"; //$NON-NLS-1$ - vScrollDiv.style.borderColor = "white"; //$NON-NLS-1$ - vScrollDiv.style.borderStyle = "solid"; //$NON-NLS-1$ - vScrollDiv.style.borderRadius = "4px"; //$NON-NLS-1$ - vScrollDiv.style.backgroundColor = "black"; //$NON-NLS-1$ - vScrollDiv.style.opacity = "0.5"; //$NON-NLS-1$ - vScrollDiv.style.margin = "0px"; //$NON-NLS-1$ - vScrollDiv.style.padding = "0px"; //$NON-NLS-1$ - vScrollDiv.style.outline = "none"; //$NON-NLS-1$ - vScrollDiv.style.zIndex = "3"; //$NON-NLS-1$ - vScrollDiv.style.width = "8px"; //$NON-NLS-1$ - vScrollDiv.style.display = "none"; //$NON-NLS-1$ - rootDiv.appendChild(vScrollDiv); - var hScrollDiv = util.createElement(doc, "div"); //$NON-NLS-1$ - this._hScrollDiv = hScrollDiv; - hScrollDiv.style.position = "absolute"; //$NON-NLS-1$ - hScrollDiv.style.borderWidth = "1px"; //$NON-NLS-1$ - hScrollDiv.style.borderColor = "white"; //$NON-NLS-1$ - hScrollDiv.style.borderStyle = "solid"; //$NON-NLS-1$ - hScrollDiv.style.borderRadius = "4px"; //$NON-NLS-1$ - hScrollDiv.style.backgroundColor = "black"; //$NON-NLS-1$ - hScrollDiv.style.opacity = "0.5"; //$NON-NLS-1$ - hScrollDiv.style.margin = "0px"; //$NON-NLS-1$ - hScrollDiv.style.padding = "0px"; //$NON-NLS-1$ - hScrollDiv.style.outline = "none"; //$NON-NLS-1$ - hScrollDiv.style.zIndex = "3"; //$NON-NLS-1$ - hScrollDiv.style.height = "8px"; //$NON-NLS-1$ - hScrollDiv.style.display = "none"; //$NON-NLS-1$ - rootDiv.appendChild(hScrollDiv); + if (this._checkSelectionChange) { + var firstLine = this._getLineNext(); + var lastLine = this._getLinePrevious(); + + // Selection is unchanged and bigger than the visible buffer region + if (selection.anchorNode === firstLine.firstChild.firstChild && selection.anchorOffset === 0 && + selection.focusNode === lastLine.firstChild.firstChild && selection.focusOffset === 0) + { + return false; + } + + // Detect select all + if ( + (selection.anchorNode === firstLine.firstChild.firstChild && selection.anchorOffset === 0 && selection.focusNode === lastLine.lastChild.firstChild) + || (selection.anchorNode === this._clientDiv && selection.focusNode === this._clientDiv) + ) { + start = 0; + end = this.getModel().getCharCount(); + } } - - if (util.isFirefox && !clientDiv.setCapture) { - var overlayDiv = util.createElement(doc, "div"); //$NON-NLS-1$ - this._overlayDiv = overlayDiv; - overlayDiv.style.position = clientDiv.style.position; - overlayDiv.style.borderWidth = clientDiv.style.borderWidth; - overlayDiv.style.margin = clientDiv.style.margin; - overlayDiv.style.padding = clientDiv.style.padding; - overlayDiv.style.cursor = "text"; //$NON-NLS-1$ - overlayDiv.style.zIndex = "2"; //$NON-NLS-1$ - (this._clipDiv || rootDiv).appendChild(overlayDiv); + + this._setSelection(new Selection(start, end), false, false); + this._checkSelectionChange = false; + return true; + }, + _cancelCheckSelection: function() { + if (this._checkSelectionChange) { + this._checkSelectionChange = false; + this._cancelPollSelectionChange(); } - clientDiv.contentEditable = "true"; //$NON-NLS-1$ - clientDiv.setAttribute("role", "textbox"); //$NON-NLS-1$ //$NON-NLS-2$ - clientDiv.setAttribute("aria-multiline", "true"); //$NON-NLS-1$ //$NON-NLS-2$ - this._setWrapMode(this._wrapMode, true); - this._setReadOnly(this._readonly); - this._setThemeClass(this._themeClass, true); - this._setTabSize(this._tabSize, true); - this._setMarginOffset(this._marginOffset, true); - this._hookEvents(); - var rulers = this._rulers; - for (var i=0; i