swagr 0.0.8 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +20 -0
- data/bin/swagr +37 -9
- data/examples/examples01/app.rb +5 -1
- data/examples/examples01/views/edit.slim +31 -0
- data/examples/examples01/views/footer.slim +1 -1
- data/examples/examples01/views/layout.slim +23 -5
- data/examples/examples01/views/navbar.slim +17 -16
- data/lib/swagr/version.rb +3 -1
- data/templates/app.rb +5 -1
- data/templates/static/js/codemirror/keymap/vim.js +279 -66
- data/templates/static/js/codemirror/lib/codemirror.css +10 -9
- data/templates/static/js/codemirror/lib/codemirror.js +385 -152
- data/templates/static/js/codemirror/mode/apl/apl.js +160 -0
- data/templates/static/js/codemirror/mode/apl/index.html +61 -0
- data/templates/static/js/codemirror/mode/asterisk/asterisk.js +183 -0
- data/templates/static/js/codemirror/mode/asterisk/index.html +142 -0
- data/templates/static/js/codemirror/mode/clike/clike.js +2 -0
- data/templates/static/js/codemirror/mode/clike/index.html +1 -1
- data/templates/static/js/codemirror/mode/clike/scala.html +1 -1
- data/templates/static/js/codemirror/mode/clojure/clojure.js +3 -3
- data/templates/static/js/codemirror/mode/css/css.js +2 -2
- data/templates/static/js/codemirror/mode/css/test.js +76 -471
- data/templates/static/js/codemirror/mode/d/d.js +205 -0
- data/templates/static/js/codemirror/mode/d/index.html +262 -0
- data/templates/static/js/codemirror/mode/erlang/index.html +1 -1
- data/templates/static/js/codemirror/mode/gfm/gfm.js +2 -1
- data/templates/static/js/codemirror/mode/gfm/index.html +1 -2
- data/templates/static/js/codemirror/mode/gfm/test.js +84 -225
- data/templates/static/js/codemirror/mode/go/index.html +1 -1
- data/templates/static/js/codemirror/mode/groovy/index.html +1 -1
- data/templates/static/js/codemirror/mode/haskell/index.html +1 -1
- data/templates/static/js/codemirror/mode/javascript/index.html +2 -2
- data/templates/static/js/codemirror/mode/javascript/javascript.js +13 -2
- data/templates/static/js/codemirror/mode/less/index.html +1 -1
- data/templates/static/js/codemirror/mode/lua/index.html +1 -1
- data/templates/static/js/codemirror/mode/markdown/index.html +1 -1
- data/templates/static/js/codemirror/mode/markdown/markdown.js +8 -7
- data/templates/static/js/codemirror/mode/markdown/test.js +579 -1266
- data/templates/static/js/codemirror/mode/meta.js +71 -0
- data/templates/static/js/codemirror/mode/mysql/index.html +2 -0
- data/templates/static/js/codemirror/mode/ocaml/index.html +1 -1
- data/templates/static/js/codemirror/mode/php/index.html +1 -1
- data/templates/static/js/codemirror/mode/plsql/index.html +2 -0
- data/templates/static/js/codemirror/mode/python/index.html +1 -1
- data/templates/static/js/codemirror/mode/ruby/index.html +1 -1
- data/templates/static/js/codemirror/mode/sass/index.html +54 -0
- data/templates/static/js/codemirror/mode/sass/sass.js +349 -0
- data/templates/static/js/codemirror/mode/shell/index.html +1 -1
- data/templates/static/js/codemirror/mode/sieve/LICENSE +0 -4
- data/templates/static/js/codemirror/mode/sieve/sieve.js +37 -10
- data/templates/static/js/codemirror/mode/smalltalk/index.html +1 -1
- data/templates/static/js/codemirror/mode/sparql/index.html +1 -1
- data/templates/static/js/codemirror/mode/sql/index.html +68 -0
- data/templates/static/js/codemirror/mode/sql/sql.js +268 -0
- data/templates/static/js/codemirror/mode/stex/test.js +104 -343
- data/templates/static/js/codemirror/mode/tiddlywiki/index.html +1 -1
- data/templates/static/js/codemirror/mode/vb/index.html +1 -1
- data/templates/static/js/codemirror/mode/xquery/test.js +54 -67
- data/templates/static/js/codemirror/mode/xquery/xquery.js +8 -8
- data/templates/static/js/crossfilter.min.js +1 -0
- data/templates/views/edit.slim +31 -0
- data/templates/views/footer.slim +1 -1
- data/templates/views/layout.slim +23 -5
- data/templates/views/navbar.slim +17 -16
- metadata +16 -30
- data/examples/examples01/static/css/codemirror.css +0 -1247
- data/examples/examples01/static/js/codemirror-compressed-3-0.js +0 -5
- data/examples/examples01/views/about.slim +0 -15
- data/examples/examples01/views/application.slim +0 -0
- data/examples/examples01/views/layout_cm.slim +0 -17
- data/templates/static/js/codemirror/lib/util/closetag.js +0 -85
- data/templates/static/js/codemirror/lib/util/colorize.js +0 -29
- data/templates/static/js/codemirror/lib/util/continuecomment.js +0 -36
- data/templates/static/js/codemirror/lib/util/continuelist.js +0 -28
- data/templates/static/js/codemirror/lib/util/dialog.css +0 -32
- data/templates/static/js/codemirror/lib/util/dialog.js +0 -75
- data/templates/static/js/codemirror/lib/util/foldcode.js +0 -182
- data/templates/static/js/codemirror/lib/util/formatting.js +0 -108
- data/templates/static/js/codemirror/lib/util/javascript-hint.js +0 -137
- data/templates/static/js/codemirror/lib/util/loadmode.js +0 -51
- data/templates/static/js/codemirror/lib/util/match-highlighter.js +0 -46
- data/templates/static/js/codemirror/lib/util/matchbrackets.js +0 -63
- data/templates/static/js/codemirror/lib/util/multiplex.js +0 -95
- data/templates/static/js/codemirror/lib/util/overlay.js +0 -59
- data/templates/static/js/codemirror/lib/util/pig-hint.js +0 -117
- data/templates/static/js/codemirror/lib/util/runmode-standalone.js +0 -90
- data/templates/static/js/codemirror/lib/util/runmode.js +0 -52
- data/templates/static/js/codemirror/lib/util/search.js +0 -119
- data/templates/static/js/codemirror/lib/util/searchcursor.js +0 -119
- data/templates/static/js/codemirror/lib/util/simple-hint.css +0 -16
- data/templates/static/js/codemirror/lib/util/simple-hint.js +0 -102
- data/templates/static/js/codemirror/lib/util/xml-hint.js +0 -131
- data/templates/views/about.slim +0 -15
@@ -1,5 +0,0 @@
|
|
1
|
-
window.CodeMirror=function(){"use strict";function s(a,c){if(!(this instanceof s))return new s(a,c);this.options=c=c||{};for(var d in vc)!c.hasOwnProperty(d)&&vc.hasOwnProperty(d)&&(c[d]=vc[d]);D(c);var e=this.display=t(a);e.wrapper.CodeMirror=this,A(this),c.autofocus&&!o&&sb(this),this.view=u(new qd([new pd([cd("",null,ib(e))])])),this.nextOpId=0,v(this),y(this),c.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),this.setValue(c.value||""),b&&setTimeout(Wd(rb,this,!0),20),this.view.history=xd(),ub(this);var f;try{f=document.activeElement==e.input}catch(g){}f||c.autofocus&&!o?setTimeout(Wd(Ub,this),20):Vb(this),mb(this,function(){for(var a in uc)uc.propertyIsEnumerable(a)&&uc[a](this,c[a],xc);for(var b=0;Bc.length>b;++b)Bc[b](this)})()}function t(a){var b={},d=b.input=_d("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none;");d.setAttribute("wrap","off"),d.setAttribute("autocorrect","off"),d.setAttribute("autocapitalize","off"),b.inputDiv=_d("div",[d],null,"overflow: hidden; position: relative; width: 3px; height: 0px;"),b.scrollbarH=_d("div",[_d("div",null,null,"height: 1px")],"CodeMirror-hscrollbar"),b.scrollbarV=_d("div",[_d("div",null,null,"width: 1px")],"CodeMirror-vscrollbar"),b.scrollbarFiller=_d("div",null,"CodeMirror-scrollbar-filler"),b.lineDiv=_d("div"),b.selectionDiv=_d("div",null,null,"position: relative; z-index: 1"),b.cursor=_d("pre","\u00a0","CodeMirror-cursor"),b.otherCursor=_d("pre","\u00a0","CodeMirror-cursor CodeMirror-secondarycursor"),b.measure=_d("div",null,"CodeMirror-measure"),b.lineSpace=_d("div",[b.measure,b.selectionDiv,b.lineDiv,b.cursor,b.otherCursor],null,"position: relative; outline: none"),b.mover=_d("div",[_d("div",[b.lineSpace],"CodeMirror-lines")],null,"position: relative"),b.sizer=_d("div",[b.mover],"CodeMirror-sizer"),b.heightForcer=_d("div","\u00a0",null,"position: absolute; height: "+Md+"px"),b.gutters=_d("div",null,"CodeMirror-gutters"),b.lineGutter=null;var f=_d("div",[b.sizer,b.heightForcer,b.gutters],null,"position: relative; min-height: 100%");return b.scroller=_d("div",[f],"CodeMirror-scroll"),b.scroller.setAttribute("tabIndex","-1"),b.wrapper=_d("div",[b.inputDiv,b.scrollbarH,b.scrollbarV,b.scrollbarFiller,b.scroller],"CodeMirror"),c&&(b.gutters.style.zIndex=-1,b.scroller.style.paddingRight=0),a.appendChild?a.appendChild(b.wrapper):a(b.wrapper),n&&(d.style.width="0px"),e||(b.scroller.draggable=!0),j?(b.inputDiv.style.height="1px",b.inputDiv.style.position="absolute"):c&&(b.scrollbarH.style.minWidth=b.scrollbarV.style.minWidth="18px"),b.viewOffset=b.showingFrom=b.showingTo=b.lastSizeC=0,b.lineNumWidth=b.lineNumInnerWidth=b.lineNumChars=null,b.prevInput="",b.alignWidgets=!1,b.pollingFast=!1,b.poll=new Od,b.draggingText=!1,b.cachedCharWidth=b.cachedTextHeight=null,b.measureLineCache=[],b.measureLineCachePos=0,b.inaccurateSelection=!1,b.pasteIncoming=!1,b}function u(a){var b={line:0,ch:0};return{doc:a,frontier:0,highlight:new Od,sel:{from:b,to:b,head:b,anchor:b,shift:!1,extend:!1},scrollTop:0,scrollLeft:0,overwrite:!1,focused:!1,maxLine:rd(a,0),maxLineLength:0,maxLineChanged:!1,suppressEdits:!1,goalColumn:null,cantEdit:!1,keyMaps:[]}}function v(a){var b=a.view.doc;a.view.mode=s.getMode(a.options,a.options.mode),b.iter(0,b.size,function(a){a.stateAfter=null}),a.view.frontier=0,U(a,100)}function w(a){var b=a.view.doc,c=ib(a.display);if(a.options.lineWrapping){a.display.wrapper.className+=" CodeMirror-wrap";var d=a.display.scroller.clientWidth/jb(a.display)-3;b.iter(0,b.size,function(a){if(0!=a.height){var b=Math.ceil(a.text.length/d)||1;1!=b&&sd(a,b*c)}}),a.display.sizer.style.minWidth=""}else a.display.wrapper.className=a.display.wrapper.className.replace(" CodeMirror-wrap",""),C(a.view),b.iter(0,b.size,function(a){0!=a.height&&sd(a,c)});nb(a,0,b.size),bb(a),setTimeout(function(){E(a.display,a.view.doc.height)},100)}function x(a){var b=Fc[a.options.keyMap].style;a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-keymap-\S+/g,"")+(b?" cm-keymap-"+b:"")}function y(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-"),bb(a)}function z(a){A(a),K(a,!0)}function A(a){var b=a.display.gutters,c=a.options.gutters;ae(b);for(var d=0;c.length>d;++d){var e=c[d],f=b.appendChild(_d("div",null,"CodeMirror-gutter "+e));"CodeMirror-linenumbers"==e&&(a.display.lineGutter=f,f.style.width=(a.display.lineNumWidth||1)+"px")}b.style.display=d?"":"none"}function B(a,b){if(0==b.height)return 0;for(var d,c=b.text.length,e=b;d=Uc(e);){var f=d.find();e=rd(a,f.from.line),c+=f.from.ch-f.to.ch}for(e=b;d=Vc(e);){var f=d.find();c-=e.text.length-f.from.ch,e=rd(a,f.to.line),c+=e.text.length-f.to.ch}return c}function C(a){a.maxLine=rd(a.doc,0),a.maxLineLength=B(a.doc,a.maxLine),a.maxLineChanged=!0,a.doc.iter(1,a.doc.size,function(b){var c=B(a.doc,b);c>a.maxLineLength&&(a.maxLineLength=c,a.maxLine=b)})}function D(a){for(var b=!1,c=0;a.gutters.length>c;++c)"CodeMirror-linenumbers"==a.gutters[c]&&(a.lineNumbers?b=!0:a.gutters.splice(c--,1));!b&&a.lineNumbers&&a.gutters.push("CodeMirror-linenumbers")}function E(a,b){var c=b+2*Y(a);a.sizer.style.minHeight=a.heightForcer.style.top=c+"px";var d=Math.max(c,a.scroller.scrollHeight),e=a.scroller.scrollWidth>a.scroller.clientWidth,f=d>a.scroller.clientHeight;f?(a.scrollbarV.style.display="block",a.scrollbarV.style.bottom=e?ge(a.measure)+"px":"0",a.scrollbarV.firstChild.style.height=d-a.scroller.clientHeight+a.scrollbarV.clientHeight+"px"):a.scrollbarV.style.display="",e?(a.scrollbarH.style.display="block",a.scrollbarH.style.right=f?ge(a.measure)+"px":"0",a.scrollbarH.firstChild.style.width=a.scroller.scrollWidth-a.scroller.clientWidth+a.scrollbarH.clientWidth+"px"):a.scrollbarH.style.display="",e&&f?(a.scrollbarFiller.style.display="block",a.scrollbarFiller.style.height=a.scrollbarFiller.style.width=ge(a.measure)+"px"):a.scrollbarFiller.style.display="",k&&0===ge(a.measure)&&(a.scrollbarV.style.minWidth=a.scrollbarH.style.minHeight=l?"18px":"12px")}function F(a,b,c){var d=a.scroller.scrollTop,e=a.wrapper.clientHeight;"number"==typeof c?d=c:c&&(d=c.top,e=c.bottom-c.top),d=Math.floor(d-Y(a));var f=Math.ceil(d+e);return{from:ud(b,d),to:ud(b,f)}}function G(a){var b=a.display;if(b.alignWidgets||b.gutters.firstChild){for(var c=J(b)-b.scroller.scrollLeft+a.view.scrollLeft,d=b.gutters.offsetWidth,e=c+"px",f=b.lineDiv.firstChild;f;f=f.nextSibling)if(f.alignable)for(var g=0,h=f.alignable;h.length>g;++g)h[g].style.left=e;b.gutters.style.left=c+d+"px"}}function H(a){if(!a.options.lineNumbers)return!1;var b=a.view.doc,c=I(a.options,b.size-1),d=a.display;if(c.length!=d.lineNumChars){var e=d.measure.appendChild(_d("div",[_d("div",c)],"CodeMirror-linenumber CodeMirror-gutter-elt")),f=e.firstChild.offsetWidth,g=e.offsetWidth-f;return d.lineGutter.style.width="",d.lineNumInnerWidth=Math.max(f,d.lineGutter.offsetWidth-g),d.lineNumWidth=d.lineNumInnerWidth+g,d.lineNumChars=d.lineNumInnerWidth?c.length:-1,d.lineGutter.style.width=d.lineNumWidth+"px",!0}return!1}function I(a,b){return a.lineNumberFormatter(b+a.firstLineNumber)+""}function J(a){return a.scroller.getBoundingClientRect().left-a.sizer.getBoundingClientRect().left}function K(a,b,c){var d=a.display.showingFrom,e=a.display.showingTo,f=L(a,b,c);return f&&(Kd(a,a,"update",a),(a.display.showingFrom!=d||a.display.showingTo!=e)&&Kd(a,a,"viewportChange",a,a.display.showingFrom,a.display.showingTo)),Q(a),E(a.display,a.view.doc.height),f}function L(a,b,d){var e=a.display,f=a.view.doc;if(!e.wrapper.clientWidth)return e.showingFrom=e.showingTo=e.viewOffset=0,void 0;var g=F(e,f,d);if(!(b!==!0&&0==b.length&&g.from>e.showingFrom&&g.to<e.showingTo)){if(b&&H(a)&&(b=!0),e.sizer.style.marginLeft=e.scrollbarH.style.left=e.gutters.offsetWidth+"px",b!==!0&&r)for(var h=0;b.length>h;++h)for(var j,i=b[h];j=Uc(rd(f,i.from));){var k=j.find().from.line;i.diff&&(i.diff-=i.from-k),i.from=k}var l=b===!0?0:1/0;if(a.options.lineNumbers&&b&&b!==!0)for(var h=0;b.length>h;++h)if(b[h].diff){l=b[h].from;break}var k=Math.max(g.from-a.options.viewportMargin,0),m=Math.min(f.size,g.to+a.options.viewportMargin);if(k>e.showingFrom&&20>k-e.showingFrom&&(k=e.showingFrom),e.showingTo>m&&20>e.showingTo-m&&(m=Math.min(f.size,e.showingTo)),r)for(k=td(Wc(f,rd(f,k)));f.size>m&&Xc(rd(f,m));)++m;for(var n=b===!0?[]:M([{from:e.showingFrom,to:e.showingTo}],b),o=0,h=0;n.length>h;++h){var p=n[h];k>p.from&&(p.from=k),p.to>m&&(p.to=m),p.from>=p.to?n.splice(h--,1):o+=p.to-p.from}if(o!=m-k||k!=e.showingFrom||m!=e.showingTo){n.sort(function(a,b){return a.from-b.from}),.7*(m-k)>o&&(e.lineDiv.style.display="none"),O(a,k,m,n,l),e.lineDiv.style.display="";var q=k!=e.showingFrom||m!=e.showingTo||e.lastSizeC!=e.wrapper.clientHeight;q&&(e.lastSizeC=e.wrapper.clientHeight),e.showingFrom=k,e.showingTo=m,U(a,100);for(var u,s=e.lineDiv.offsetTop,t=e.lineDiv.firstChild;t;t=t.nextSibling)if(t.lineObj){if(c){var v=t.offsetTop+t.offsetHeight;u=v-s,s=v}else{var w=t.getBoundingClientRect();u=w.bottom-w.top}var x=t.lineObj.height-u;2>u&&(u=ib(e)),(x>.001||-.001>x)&&sd(t.lineObj,u)}return e.viewOffset=vd(a,rd(f,k)),e.mover.style.top=e.viewOffset+"px",!0}}}function M(a,b){for(var c=0,d=b.length||0;d>c;++c){for(var e=b[c],f=[],g=e.diff||0,h=0,i=a.length;i>h;++h){var j=a[h];e.to<=j.from&&e.diff?f.push({from:j.from+g,to:j.to+g}):e.to<=j.from||e.from>=j.to?f.push(j):(e.from>j.from&&f.push({from:j.from,to:e.from}),e.to<j.to&&f.push({from:e.to+g,to:j.to+g}))}a=f}return a}function N(a){for(var b=a.display,c={},d={},e=b.gutters.firstChild,f=0;e;e=e.nextSibling,++f)c[a.options.gutters[f]]=e.offsetLeft,d[a.options.gutters[f]]=e.offsetWidth;return{fixedPos:J(b),gutterTotalWidth:b.gutters.offsetWidth,gutterLeft:c,gutterWidth:d,wrapperWidth:b.wrapper.clientWidth}}function O(a,c,d,f,g){function m(b){var c=b.nextSibling;return e&&p&&a.display.currentWheelTarget==b?(b.style.display="none",b.lineObj=null):k.removeChild(b),c}var h=N(a),i=a.display,j=a.options.lineNumbers;f.length||b||e&&a.display.currentWheelTarget||ae(i.lineDiv);var k=i.lineDiv,l=k.firstChild,n=f.shift(),o=c;for(a.view.doc.iter(c,d,function(b){if(n&&n.to==o&&(n=f.shift()),Xc(b))0!=b.height&&sd(b,0);else if(n&&o>=n.from&&n.to>o){for(;l.lineObj!=b;)l=m(l);j&&o>=g&&l.lineNumber&&ce(l.lineNumber,I(a.options,o)),l=l.nextSibling}else{var c=P(a,b,o,h);k.insertBefore(c,l),c.lineObj=b}++o});l;)l=m(l)}function P(a,b,d,e){var f=jd(a,b),g=b.gutterMarkers,h=a.display;if(!(a.options.lineNumbers||g||b.bgClass||b.wrapClass||b.widgets&&b.widgets.length))return f;var i=_d("div",null,b.wrapClass,"position: relative");if(a.options.lineNumbers||g){var j=i.appendChild(_d("div",null,null,"position: absolute; left: "+e.fixedPos+"px"));if(i.alignable=[j],!a.options.lineNumbers||g&&g["CodeMirror-linenumbers"]||(i.lineNumber=j.appendChild(_d("div",I(a.options,d),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+e.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+h.lineNumInnerWidth+"px"))),g)for(var k=0;a.options.gutters.length>k;++k){var l=a.options.gutters[k],m=g.hasOwnProperty(l)&&g[l];m&&j.appendChild(_d("div",[m],"CodeMirror-gutter-elt","left: "+e.gutterLeft[l]+"px; width: "+e.gutterWidth[l]+"px"))}}if(b.bgClass&&i.appendChild(_d("div","\u00a0",b.bgClass+" CodeMirror-linebackground")),i.appendChild(f),b.widgets)for(var n=0,o=b.widgets;o.length>n;++n){var p=o[n],q=_d("div",[p.node],"CodeMirror-linewidget");if(q.widget=p,p.noHScroll){(i.alignable||(i.alignable=[])).push(q);var r=e.wrapperWidth;q.style.left=e.fixedPos+"px",p.coverGutter||(r-=e.gutterTotalWidth,q.style.paddingLeft=e.gutterTotalWidth+"px"),q.style.width=r+"px"}p.coverGutter&&(q.style.zIndex=5,q.style.position="relative",p.noHScroll||(q.style.marginLeft=-e.gutterTotalWidth+"px")),p.above?i.insertBefore(q,a.options.lineNumbers&&0!=b.height?j:f):i.appendChild(q)}return c&&(i.style.zIndex=2),i}function Q(a){var b=a.display,c=bc(a.view.sel.from,a.view.sel.to);c||a.options.showCursorWhenSelecting?R(a):b.cursor.style.display=b.otherCursor.style.display="none",c?b.selectionDiv.style.display="none":S(a);var d=eb(a,a.view.sel.head,"div"),e=b.wrapper.getBoundingClientRect(),f=b.lineDiv.getBoundingClientRect();b.inputDiv.style.top=Math.max(0,Math.min(b.wrapper.clientHeight-10,d.top+f.top-e.top))+"px",b.inputDiv.style.left=Math.max(0,Math.min(b.wrapper.clientWidth-10,d.left+f.left-e.left))+"px"}function R(a){var b=a.display,c=eb(a,a.view.sel.head,"div");b.cursor.style.left=c.left+"px",b.cursor.style.top=c.top+"px",b.cursor.style.height=Math.max(0,c.bottom-c.top)*a.options.cursorHeight+"px",b.cursor.style.display="",c.other?(b.otherCursor.style.display="",b.otherCursor.style.left=c.other.left+"px",b.otherCursor.style.top=c.other.top+"px",b.otherCursor.style.height=.85*(c.other.bottom-c.other.top)+"px"):b.otherCursor.style.display="none"}function S(a){function h(a,b,c,d){0>b&&(b=0),e.appendChild(_d("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px; top: "+b+"px; width: "+(null==c?f-a:c)+"px; height: "+(d-b)+"px"))}function i(b,d,e,i){function m(c){return db(a,{line:b,ch:c},"div",j)}var j=rd(c,b),k=j.text.length,l=i?1/0:-1/0;return ne(wd(j),d||0,null==e?k:e,function(a,b,c){var j=m("rtl"==c?b-1:a),n=m("rtl"==c?a:b-1),o=j.left,p=n.right;n.top-j.top>3&&(h(o,j.top,null,j.bottom),o=g,j.bottom<n.top&&h(o,j.bottom,null,n.top)),null==e&&b==k&&(p=f),null==d&&0==a&&(o=g),l=i?Math.min(n.top,l):Math.max(n.bottom,l),g+1>o&&(o=g),h(o,n.top,p-o,n.bottom)}),l}var b=a.display,c=a.view.doc,d=a.view.sel,e=document.createDocumentFragment(),f=b.lineSpace.offsetWidth,g=Z(a.display);if(d.from.line==d.to.line)i(d.from.line,d.from.ch,d.to.ch);else{for(var l,n,j=rd(c,d.from.line),k=j,m=[d.from.line,d.from.ch];l=Vc(k);){var o=l.find();if(m.push(o.from.ch,o.to.line,o.to.ch),o.to.line==d.to.line){m.push(d.to.ch),n=!0;break}k=rd(c,o.to.line)}if(n)for(var p=0;m.length>p;p+=3)i(m[p],m[p+1],m[p+2]);else{var q,r,s=rd(c,d.to.line);q=d.from.ch?i(d.from.line,d.from.ch,null,!1):vd(a,j)-b.viewOffset,r=d.to.ch?i(d.to.line,Uc(s)?null:0,d.to.ch,!0):vd(a,s)-b.viewOffset,r>q&&h(g,q,null,r)}}be(b.selectionDiv,e),b.selectionDiv.style.display=""}function T(a){var b=a.display;clearInterval(b.blinker);var c=!0;b.cursor.style.visibility=b.otherCursor.style.visibility="",b.blinker=setInterval(function(){b.cursor.offsetHeight&&(b.cursor.style.visibility=b.otherCursor.style.visibility=(c=!c)?"":"hidden")},a.options.cursorBlinkRate)}function U(a,b){a.view.frontier<a.display.showingTo&&a.view.highlight.set(b,Wd(V,a))}function V(a){var b=a.view,c=b.doc;if(!(b.frontier>=a.display.showingTo)){var g,d=+new Date+a.options.workTime,e=Cc(b.mode,X(a,b.frontier)),f=[];c.iter(b.frontier,Math.min(c.size,a.display.showingTo+500),function(c){return b.frontier>=a.display.showingFrom?(fd(a,c,e)&&b.frontier>=a.display.showingFrom&&(g&&g.end==b.frontier?g.end++:f.push(g={start:b.frontier,end:b.frontier+1})),c.stateAfter=Cc(b.mode,e)):(gd(a,c,e),c.stateAfter=0==b.frontier%5?Cc(b.mode,e):null),++b.frontier,+new Date>d?(U(a,a.options.workDelay),!0):void 0}),f.length&&mb(a,function(){for(var a=0;f.length>a;++a)nb(this,f[a].start,f[a].end)})()}}function W(a,b){for(var c,d,e=a.view.doc,f=b,g=b-100;f>g;--f){if(0==f)return 0;var h=rd(e,f-1);if(h.stateAfter)return f;var i=Pd(h.text,null,a.options.tabSize);(null==d||c>i)&&(d=f-1,c=i)}return d}function X(a,b){var c=a.view,d=W(a,b),e=d&&rd(c.doc,d-1).stateAfter;return e=e?Cc(c.mode,e):Dc(c.mode),c.doc.iter(d,b,function(f){gd(a,f,e);var g=d==b-1||0==d%5||d>=c.showingFrom&&c.showingTo>d;f.stateAfter=g?Cc(c.mode,e):null,++d}),e}function Y(a){return a.lineSpace.offsetTop}function Z(a){var b=be(a.measure,_d("pre")).appendChild(_d("span","x"));return b.offsetLeft}function $(a,b,c,d){for(var d=d||_(a,b),e=-1,f=c;;f+=e){var g=d[f];if(g)break;0>e&&0==f&&(e=1)}return{left:c>f?g.right:g.left,right:f>c?g.left:g.right,top:g.top,bottom:g.bottom}}function _(a,b){for(var c=a.display,d=a.display.measureLineCache,e=0;d.length>e;++e){var f=d[e];if(f.text==b.text&&f.markedSpans==b.markedSpans&&c.scroller.clientWidth==f.width)return f.measure}var g=ab(a,b),f={text:b.text,width:c.scroller.clientWidth,markedSpans:b.markedSpans,measure:g};return 16==d.length?d[++c.measureLineCachePos%16]=f:d.push(f),g}function ab(a,d){var e=a.display,f=Vd(d.text.length),g=jd(a,d,f);if(b&&!c&&!a.options.lineWrapping&&g.childNodes.length>100){for(var h=document.createDocumentFragment(),i=10,j=g.childNodes.length,k=0,l=Math.ceil(j/i);l>k;++k){for(var m=_d("div",null,null,"display: inline-block"),n=0;i>n&&j;++n)m.appendChild(g.firstChild),--j;h.appendChild(m)}g.appendChild(h)}be(e.measure,g);for(var s,o=e.lineDiv.getBoundingClientRect(),p=[],q=Vd(d.text.length),r=g.offsetHeight,k=0;f.length>k;++k)if(s=f[k]){for(var t=s.getBoundingClientRect(),u=Math.max(0,t.top-o.top),v=Math.min(t.bottom-o.top,r),n=0;p.length>n;n+=2){var w=p[n],x=p[n+1];if(!(w>v||u>x)&&(u>=w&&x>=v||w>=u&&v>=x||Math.min(v,x)-Math.max(u,w)>=v-u>>1)){p[n]=Math.min(u,w),p[n+1]=Math.max(v,x);break}}n==p.length&&p.push(u,v),q[k]={left:t.left-o.left,right:t.right-o.left,top:n}}for(var s,k=0;q.length>k;++k)if(s=q[k]){var y=s.top;s.top=p[y],s.bottom=p[y+1]}return q}function bb(a){a.display.measureLineCache.length=a.display.measureLineCachePos=0,a.display.cachedCharWidth=a.display.cachedTextHeight=null,a.view.maxLineChanged=!0}function cb(a,b,c,d){if(b.widgets)for(var e=0;b.widgets.length>e;++e)if(b.widgets[e].above){var f=b.widgets[e].node.offsetHeight;c.top+=f,c.bottom+=f}if("line"==d)return c;d||(d="local");var g=vd(a,b);if("local"!=d&&(g-=a.display.viewOffset),"page"==d){var h=a.display.lineSpace.getBoundingClientRect();g+=h.top+(window.pageYOffset||(document.documentElement||document.body).scrollTop);var i=h.left+(window.pageXOffset||(document.documentElement||document.body).scrollLeft);c.left+=i,c.right+=i}return c.top+=g,c.bottom+=g,c}function db(a,b,c,d){return d||(d=rd(a.view.doc,b.line)),cb(a,d,$(a,d,b.ch),c)}function eb(a,b,c,d,e){function f(b,f){var g=$(a,d,b,e);return f?g.left=g.right:g.right=g.left,cb(a,d,g,c)}d=d||rd(a.view.doc,b.line),e||(e=_(a,d));var g=wd(d),h=b.ch;if(!g)return f(h);for(var i,j,k=g[0].level,l=0;g.length>l;++l){var o,p,m=g[l],n=m.level%2;if(h>m.from&&m.to>h)return f(h,n);var q=n?m.to:m.from,r=n?m.from:m.to;if(q==h)p=l&&m.level<(o=g[l-1]).level?f(o.level%2?o.from:o.to-1,!0):f(n&&m.from!=m.to?h-1:h),n==k?i=p:j=p;else if(r==h){var o=g.length-1>l&&g[l+1];if(!n&&o&&o.from==o.to)continue;p=o&&m.level<o.level?f(o.level%2?o.to-1:o.from):f(n?h:h-1,!0),n==k?i=p:j=p}}return k&&!h&&(j=f(g[0].to-1)),i?(j&&(i.other=j),i):j}function fb(a,b,c){var d=a.view.doc;if(c+=a.display.viewOffset,0>c)return{line:0,ch:0,outside:!0};var e=ud(d,c);if(e>=d.size)return{line:d.size-1,ch:rd(d,d.size-1).text.length};for(0>b&&(b=0);;){var f=rd(d,e),g=gb(a,f,e,b,c),h=Vc(f);if(!h||g.ch!=re(f))return g;e=h.find().to.line}}function gb(a,b,c,d,e){function j(d){var e=eb(a,{line:c,ch:d},"line",b,i);return g=!0,f>e.bottom?Math.max(0,e.left-h):e.top>f?e.left+h:(g=!1,e.left)}var f=e-vd(a,b),g=!1,h=a.display.wrapper.clientWidth,i=_(a,b),k=wd(b),l=b.text.length,m=qe(b),n=re(b),o=Z(a.display),p=j(n);if(d>p)return{line:c,ch:n,outside:g};for(;;){if(k?n==m||n==ue(b,m,1):1>=n-m){for(var q=p-d>d-o,r=q?m:n;$d.test(b.text.charAt(r));)++r;return{line:c,ch:r,after:q,outside:g}}var s=Math.ceil(l/2),t=m+s;if(k){t=m;for(var u=0;s>u;++u)t=ue(b,t,1)}var v=j(t);v>d?(n=t,p=v,g&&(p+=1e3),l-=s):(m=t,o=v,l=s)}}function ib(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==hb){hb=_d("pre");for(var b=0;49>b;++b)hb.appendChild(document.createTextNode("x")),hb.appendChild(_d("br"));hb.appendChild(document.createTextNode("x"))}be(a.measure,hb);var c=hb.offsetHeight/50;return c>3&&(a.cachedTextHeight=c),ae(a.measure),c||1}function jb(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=_d("span","x"),c=_d("pre",[b]);be(a.measure,c);var d=b.offsetWidth;return d>2&&(a.cachedCharWidth=d),d||10}function kb(a){a.curOp?++a.curOp.depth:a.curOp={depth:1,changes:[],delayedCallbacks:[],updateInput:null,userSelChange:null,textChanged:null,selectionChanged:!1,updateMaxLine:!1,id:++a.nextOpId}}function lb(a){var b=a.curOp;if(!--b.depth){a.curOp=null;var c=a.view,d=a.display;if(b.updateMaxLine&&C(c),c.maxLineChanged&&!a.options.lineWrapping){var e=$(a,c.maxLine,c.maxLine.text.length).right;d.sizer.style.minWidth=e+3+Md+"px",c.maxLineChanged=!1}var f,g;if(b.selectionChanged){var h=eb(a,c.sel.head);f=oc(a,h.left,h.top,h.left,h.bottom)}(b.changes.length||f&&null!=f.scrollTop)&&(g=K(a,b.changes,f&&f.scrollTop)),!g&&b.selectionChanged&&Q(a),f&&lc(a),b.selectionChanged&&T(a),c.focused&&b.updateInput&&rb(a,b.userSelChange),b.textChanged&&Jd(a,"change",a,b.textChanged),b.selectionChanged&&Jd(a,"cursorActivity",a);for(var i=0;b.delayedCallbacks.length>i;++i)b.delayedCallbacks[i](a)}}function mb(a,b){return function(){var c=a||this;kb(c);try{var d=b.apply(c,arguments)}finally{lb(c)}return d}}function nb(a,b,c,d){a.curOp.changes.push({from:b,to:c,diff:d})}function ob(a){a.view.pollingFast||a.display.poll.set(a.options.pollInterval,function(){qb(a),a.view.focused&&ob(a)})}function pb(a){function c(){var d=qb(a);d||b?(a.display.pollingFast=!1,ob(a)):(b=!0,a.display.poll.set(60,c))}var b=!1;a.display.pollingFast=!0,a.display.poll.set(20,c)}function qb(a){var b=a.display.input,c=a.display.prevInput,d=a.view,e=d.sel;if(!d.focused||ke(b)||tb(a))return!1;var f=b.value;if(f==c&&bc(e.from,e.to))return!1;kb(a),d.sel.shift=!1;for(var g=0,h=Math.min(c.length,f.length);h>g&&c[g]==f[g];)++g;var i=e.from,j=e.to;c.length>g?i={line:i.line,ch:i.ch-(c.length-g)}:d.overwrite&&bc(i,j)&&!a.display.pasteIncoming&&(j={line:j.line,ch:Math.min(rd(a.view.doc,j.line).text.length,j.ch+(f.length-g))});var k=a.curOp.updateInput;return Yb(a,i,j,je(f.slice(g)),"end",a.display.pasteIncoming?"paste":"input",{from:i,to:j}),a.curOp.updateInput=k,f.length>1e3?b.value=a.display.prevInput="":a.display.prevInput=f,lb(a),a.display.pasteIncoming=!1,!0}function rb(a,b){var d,e,c=a.view;bc(c.sel.from,c.sel.to)?b&&(a.display.prevInput=a.display.input.value=""):(a.display.prevInput="",d=le&&(c.sel.to.line-c.sel.from.line>100||(e=a.getSelection()).length>1e3),a.display.input.value=d?"-":e||a.getSelection(),c.focused&&Td(a.display.input)),a.display.inaccurateSelection=d}function sb(a){"nocursor"==a.options.readOnly||!b&&document.activeElement==a.display.input||a.display.input.focus()}function tb(a){return a.options.readOnly||a.view.cantEdit}function ub(b){function d(){b.view.focused&&setTimeout(Wd(sb,b),0)}function f(a){b.options.onDragEvent&&b.options.onDragEvent(b,Ad(a))||Dd(a)}function g(){c.inaccurateSelection&&(c.prevInput="",c.inaccurateSelection=!1,c.input.value=b.getSelection(),Td(c.input))}var c=b.display;Hd(c.scroller,"mousedown",mb(b,zb)),Hd(c.scroller,"dblclick",mb(b,Bd)),Hd(c.lineSpace,"selectstart",function(a){vb(c,a)||Bd(a)}),a||Hd(c.scroller,"contextmenu",function(a){Xb(b,a)}),Hd(c.scroller,"scroll",function(){Db(b,c.scroller.scrollTop),Eb(b,c.scroller.scrollLeft,!0),Jd(b,"scroll",b)}),Hd(c.scrollbarV,"scroll",function(){Db(b,c.scrollbarV.scrollTop)}),Hd(c.scrollbarH,"scroll",function(){Eb(b,c.scrollbarH.scrollLeft)}),Hd(c.scroller,"mousewheel",function(a){Lb(b,a)}),Hd(c.scroller,"DOMMouseScroll",function(a){Lb(b,a)}),Hd(c.scrollbarH,"mousedown",d),Hd(c.scrollbarV,"mousedown",d),Hd(c.wrapper,"scroll",function(){c.wrapper.scrollTop=c.wrapper.scrollLeft=0}),Hd(window,"resize",function e(){c.cachedCharWidth=c.cachedTextHeight=null,bb(b),c.wrapper.parentNode?K(b,!0):Id(window,"resize",e)}),Hd(c.input,"keyup",mb(b,function(a){b.options.onKeyEvent&&b.options.onKeyEvent(b,Ad(a))||16==Gd(a,"keyCode")&&(b.view.sel.shift=!1)})),Hd(c.input,"input",Wd(pb,b)),Hd(c.input,"keydown",mb(b,Sb)),Hd(c.input,"keypress",mb(b,Tb)),Hd(c.input,"focus",Wd(Ub,b)),Hd(c.input,"blur",Wd(Vb,b)),b.options.dragDrop&&(Hd(c.scroller,"dragstart",function(a){Cb(b,a)}),Hd(c.scroller,"dragenter",f),Hd(c.scroller,"dragover",f),Hd(c.scroller,"drop",mb(b,Ab))),Hd(c.scroller,"paste",function(){sb(b),pb(b)}),Hd(c.input,"paste",function(){c.pasteIncoming=!0,pb(b)}),Hd(c.input,"cut",g),Hd(c.input,"copy",g),j&&Hd(c.sizer,"mouseup",function(){document.activeElement==c.input&&c.input.blur(),sb(b)})}function vb(a,b){for(var c=Ed(b);c!=a.wrapper;c=c.parentNode)if(/\bCodeMirror-(?:line)?widget\b/.test(c.className)||c.parentNode==a.sizer&&c!=a.mover)return!0}function wb(a,b,c){var d=a.display;if(!c){var e=Ed(b);if(e==d.scrollbarH||e==d.scrollbarH.firstChild||e==d.scrollbarV||e==d.scrollbarV.firstChild||e==d.scrollbarFiller)return null}var f,g,h=d.lineSpace.getBoundingClientRect();try{f=b.clientX,g=b.clientY}catch(b){return null}return fb(a,f-h.left,g-h.top)}function zb(c){function r(a){if("single"==l)return hc(d,fc(i,j),a),void 0;if(p=fc(i,p),q=fc(i,q),"double"==l){var b=sc(rd(i,a.line).text,a);cc(a,p)?hc(d,b.from,q):hc(d,p,b.to)}else"triple"==l&&(cc(a,p)?hc(d,q,fc(i,{line:a.line,ch:0})):hc(d,p,fc(i,{line:a.line+1,ch:0})))}function u(a){var b=++t,c=wb(d,a,!0);if(c)if(bc(c,n)){var h=a.clientY<s.top?-20:a.clientY>s.bottom?20:0;h&&setTimeout(mb(d,function(){t==b&&(f.scroller.scrollTop+=h,u(a))}),50)}else{g.focused||Ub(d),n=c,r(c);var e=F(f,i);(c.line>=e.to||c.line<e.from)&&setTimeout(mb(d,function(){t==b&&u(a)}),150)}}function v(a){t=1/0;var b=wb(d,a);b&&r(b),Bd(a),sb(d),Id(document,"mousemove",w),Id(document,"mouseup",x)}var d=this,f=d.display,g=d.view,h=g.sel,i=g.doc;if(h.shift=Gd(c,"shiftKey"),vb(f,c))return e||(f.scroller.draggable=!1,setTimeout(function(){f.scroller.draggable=!0},100)),void 0;if(!Bb(d,c)){var j=wb(d,c);switch(Fd(c)){case 3:return a&&Xb.call(d,d,c),void 0;case 2:return j&&hc(d,j),setTimeout(Wd(sb,d),20),Bd(c),void 0}if(!j)return Ed(c)==f.scroller&&Bd(c),void 0;g.focused||Ub(d);var k=+new Date,l="single";if(yb&&yb.time>k-400&&bc(yb.pos,j))l="triple",Bd(c),setTimeout(Wd(sb,d),20),tc(d,j.line);else if(xb&&xb.time>k-400&&bc(xb.pos,j)){l="double",yb={time:k,pos:j},Bd(c);var m=sc(rd(i,j.line).text,j);hc(d,m.from,m.to)}else xb={time:k,pos:j};var n=j;if(d.options.dragDrop&&de&&!tb(d)&&!bc(h.from,h.to)&&!cc(j,h.from)&&!cc(h.to,j)&&"single"==l){var o=mb(d,function(a){e&&(f.scroller.draggable=!1),g.draggingText=!1,Id(document,"mouseup",o),Id(f.scroller,"drop",o),10>Math.abs(c.clientX-a.clientX)+Math.abs(c.clientY-a.clientY)&&(Bd(a),hc(d,j),sb(d))});return e&&(f.scroller.draggable=!0),g.draggingText=o,f.scroller.dragDrop&&f.scroller.dragDrop(),Hd(document,"mouseup",o),Hd(f.scroller,"drop",o),void 0}Bd(c),"single"==l&&hc(d,fc(i,j));var p=h.from,q=h.to,s=f.wrapper.getBoundingClientRect(),t=0,w=mb(d,function(a){b||Fd(a)?u(a):v(a)}),x=mb(d,v);Hd(document,"mousemove",w),Hd(document,"mouseup",x)}}function Ab(a){var c=this;if(!c.options.onDragEvent||!c.options.onDragEvent(c,Ad(a))){Bd(a);var d=wb(c,a,!0),e=a.dataTransfer.files;if(d&&!tb(c))if(e&&e.length&&window.FileReader&&window.File)for(var f=e.length,g=Array(f),h=0,i=function(a,b){var e=new FileReader;e.onload=function(){g[b]=e.result,++h==f&&(d=fc(c.view.doc,d),mb(c,function(){var a=ac(c,g.join(""),d,d,"paste");ic(c,d,a)})())},e.readAsText(a)},j=0;f>j;++j)i(e[j],j);else{if(c.view.draggingText&&!cc(d,c.view.sel.from)&&!cc(c.view.sel.to,d))return c.view.draggingText(a),b&&setTimeout(Wd(sb,c),50),void 0;try{var g=a.dataTransfer.getData("Text");if(g){var k=c.view.sel.from,l=c.view.sel.to;ic(c,d,d),c.view.draggingText&&ac(c,"",k,l,"paste"),c.replaceSelection(g,null,"paste"),sb(c),Ub(c)}}catch(a){}}}}function Bb(a,b){var c=a.display;try{var d=b.clientX,e=b.clientY}catch(b){return!1}if(d>=Math.floor(c.gutters.getBoundingClientRect().right))return!1;if(Bd(b),!Ld(a,"gutterClick"))return!0;var f=c.lineDiv.getBoundingClientRect();if(e>f.bottom)return!0;e-=f.top-c.viewOffset;for(var g=0;a.options.gutters.length>g;++g){var h=c.gutters.childNodes[g];if(h&&h.getBoundingClientRect().right>=d){var i=ud(a.view.doc,e),j=a.options.gutters[g];Kd(a,a,"gutterClick",a,i,j,b);break}}return!0}function Cb(a,b){var c=a.getSelection();b.dataTransfer.setData("Text",c),b.dataTransfer.setDragImage&&!i&&b.dataTransfer.setDragImage(_d("img"),0,0)}function Db(b,c){2>Math.abs(b.view.scrollTop-c)||(b.view.scrollTop=c,a||K(b,[],c),b.display.scroller.scrollTop!=c&&(b.display.scroller.scrollTop=c),b.display.scrollbarV.scrollTop!=c&&(b.display.scrollbarV.scrollTop=c),a&&K(b,[]))}function Eb(a,b,c){(c?b==a.view.scrollLeft:2>Math.abs(a.view.scrollLeft-b))||(a.view.scrollLeft=b,G(a),a.display.scroller.scrollLeft!=b&&(a.display.scroller.scrollLeft=b),a.display.scrollbarH.scrollLeft!=b&&(a.display.scrollbarH.scrollLeft=b))}function Lb(b,c){var d=c.wheelDeltaX,f=c.wheelDeltaY;if(null==d&&c.detail&&c.axis==c.HORIZONTAL_AXIS&&(d=c.detail),null==f&&c.detail&&c.axis==c.VERTICAL_AXIS?f=c.detail:null==f&&(f=c.wheelDelta),f&&p&&e)for(var g=c.target;g!=i;g=g.parentNode)if(g.lineObj){b.display.currentWheelTarget=g;break}var i=b.display.scroller;if(d&&!a&&!h&&null!=Kb)return f&&Db(b,Math.max(0,Math.min(i.scrollTop+f*Kb,i.scrollHeight-i.clientHeight))),Eb(b,Math.max(0,Math.min(i.scrollLeft+d*Kb,i.scrollWidth-i.clientWidth))),Bd(c),Ib=null,void 0;if(f&&null!=Kb){var j=f*Kb,k=b.view.scrollTop,l=k+b.display.wrapper.clientHeight;0>j?k=Math.max(0,k+j-50):l=Math.min(b.view.doc.height,l+j+50),K(b,[],{top:k,bottom:l})}20>Fb&&(null==Ib?(Ib=i.scrollLeft,Jb=i.scrollTop,Gb=d,Hb=f,setTimeout(function(){if(null!=Ib){var a=i.scrollLeft-Ib,b=i.scrollTop-Jb,c=b&&Hb&&b/Hb||a&&Gb&&a/Gb;Ib=Jb=null,c&&(Kb=(Kb*Fb+c)/(Fb+1),++Fb)}},200)):(Gb+=d,Hb+=f))}function Mb(a,b,c){if("string"==typeof b&&(b=Ec[b],!b))return!1;a.display.pollingFast&&qb(a)&&(a.display.pollingFast=!1);var d=a.view,e=d.sel.shift;try{tb(a)&&(d.suppressEdits=!0),c&&(d.sel.shift=!1),b(a)}catch(f){if(f!=Nd)throw f;return!1}finally{d.sel.shift=e,d.suppressEdits=!1}return!0}function Nb(a){var b=a.view.keyMaps.slice(0);return b.push(a.options.keyMap),a.options.extraKeys&&b.unshift(a.options.extraKeys),b}function Pb(a,b){function l(){k=!0}var c=Gc(a.options.keyMap),e=c.auto;clearTimeout(Ob),e&&!Ic(b)&&(Ob=setTimeout(function(){Gc(a.options.keyMap)==c&&(a.options.keyMap=e.call?e.call(null,a):e)},50));var g=me[Gd(b,"keyCode")],i=!1,j=p&&(h||f);if(null==g||b.altGraphKey)return!1;Gd(b,"altKey")&&(g="Alt-"+g),Gd(b,j?"metaKey":"ctrlKey")&&(g="Ctrl-"+g),Gd(b,j?"ctrlKey":"metaKey")&&(g="Cmd-"+g);var k=!1,m=Nb(a);return i=Gd(b,"shiftKey")?Hc("Shift-"+g,m,function(b){return Mb(a,b,!0)},l)||Hc(g,m,function(b){return"string"==typeof b&&/^go[A-Z]/.test(b)?Mb(a,b):void 0},l):Hc(g,m,function(b){return Mb(a,b)},l),k&&(i=!1),i&&(Bd(b),T(a),d&&(b.oldKeyCode=b.keyCode,b.keyCode=0)),i}function Qb(a,b,c){var d=Hc("'"+c+"'",Nb(a),function(b){return Mb(a,b,!0)});return d&&(Bd(b),T(a)),d}function Sb(a){var c=this;if(c.view.focused||Ub(c),b&&27==a.keyCode&&(a.returnValue=!1),!c.options.onKeyEvent||!c.options.onKeyEvent(c,Ad(a))){var d=Gd(a,"keyCode");c.view.sel.shift=16==d||Gd(a,"shiftKey");var e=Pb(c,a);h&&(Rb=e?d:null,e||88!=d||le||!Gd(a,p?"metaKey":"ctrlKey")||c.replaceSelection(""))}}function Tb(a){var b=this;if(!b.options.onKeyEvent||!b.options.onKeyEvent(b,Ad(a))){var c=Gd(a,"keyCode"),d=Gd(a,"charCode");if(h&&c==Rb)return Rb=null,Bd(a),void 0;if(!(h&&(!a.which||10>a.which)||j)||!Pb(b,a)){var e=String.fromCharCode(null==d?c:d);this.options.electricChars&&this.view.mode.electricChars&&this.options.smartIndent&&!tb(this)&&this.view.mode.electricChars.indexOf(e)>-1&&setTimeout(mb(b,function(){pc(b,b.view.sel.to.line,"smart")}),75),Qb(b,a,e)||pb(b)}}}function Ub(a){"nocursor"!=a.options.readOnly&&(a.view.focused||(Jd(a,"focus",a),a.view.focused=!0,-1==a.display.scroller.className.search(/\bCodeMirror-focused\b/)&&(a.display.scroller.className+=" CodeMirror-focused"),rb(a,!0)),ob(a),T(a))}function Vb(a){a.view.focused&&(Jd(a,"blur",a),a.view.focused=!1,a.display.scroller.className=a.display.scroller.className.replace(" CodeMirror-focused","")),clearInterval(a.display.blinker),setTimeout(function(){a.view.focused||(a.view.sel.shift=!1)},150)}function Xb(b,c){function k(){if(e.inputDiv.style.position="relative",e.input.style.cssText=j,d&&(e.scrollbarV.scrollTop=e.scroller.scrollTop=i),ob(b),null!=e.input.selectionStart){clearTimeout(Wb);
|
2
|
-
var a=e.input.value=" "+(bc(f.from,f.to)?"":e.input.value),c=0;e.prevInput=" ",e.input.selectionStart=1,e.input.selectionEnd=a.length,Wb=setTimeout(function g(){" "==e.prevInput&&0==e.input.selectionStart?mb(b,Ec.selectAll)(b):10>c++?Wb=setTimeout(g,500):rb(b)},200)}}var e=b.display,f=b.view.sel,g=wb(b,c),i=e.scroller.scrollTop;if(g&&!h){(bc(f.from,f.to)||cc(g,f.from)||!cc(g,f.to))&&mb(b,ic)(b,g,g);var j=e.input.style.cssText;e.inputDiv.style.position="absolute",e.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(c.clientY-5)+"px; left: "+(c.clientX-5)+"px; z-index: 1000; background: white; outline: none;"+"border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",sb(b),rb(b,!0),bc(f.from,f.to)&&(e.input.value=e.prevInput=" "),a?(Dd(c),Hd(window,"mouseup",function l(){Id(window,"mouseup",l),setTimeout(k,20)})):setTimeout(k,50)}}function Yb(a,b,c,d,e,f){var g=q&&Sc(a.view.doc,b,c);if(!g)return Zb(a,b,c,d,e,f);for(var h=g.length-1;h>=1;--h)Zb(a,g[h].from,g[h].to,[""],f);return g.length?Zb(a,g[0].from,g[0].to,d,e,f):void 0}function Zb(a,b,c,d,e,f){if(!a.view.suppressEdits){var g=a.view,h=g.doc,i=[];h.iter(b.line,c.line+1,function(a){i.push(_c(a.text,a.markedSpans))});var j=g.sel.from,k=g.sel.to,l=Rc($c(i[0]),$c(Sd(i)),b.ch,c.ch,d),m=_b(a,b,c,l,e,f);return g.history&&yd(a,b.line,d.length,i,f,j,k,g.sel.from,g.sel.to),m}}function $b(a,b){var c=a.view.doc,d=a.view.history,e=("undo"==b?d.done:d.undone).pop();if(e){for(var f={events:[],fromBefore:e.fromAfter,toBefore:e.toAfter,fromAfter:e.fromBefore,toAfter:e.toBefore},g=e.events.length-1;g>=0;g-=1){d.dirtyCounter+="undo"==b?-1:1;var h=e.events[g],i=[],j=h.start+h.added;c.iter(h.start,j,function(a){i.push(_c(a.text,a.markedSpans))}),f.events.push({start:h.start,added:h.old.length,old:i});var k=g?null:{from:e.fromBefore,to:e.toBefore};_b(a,{line:h.start,ch:0},{line:j-1,ch:rd(c,j-1).text.length},h.old,k,b)}("undo"==b?d.undone:d.done).push(f)}}function _b(a,b,c,d,e,f){var g=a.view,h=g.doc,i=a.display;if(!g.suppressEdits){var j=c.line-b.line,k=rd(h,b.line),l=rd(h,c.line),m=!1,n=b.line;a.options.lineWrapping||(n=td(Wc(h,k)),h.iter(n,c.line+1,function(a){return B(h,a)==g.maxLineLength?(m=!0,!0):void 0}));var o=Sd(d),p=ib(i);if(0==b.ch&&0==c.ch&&""==Zc(o)){for(var q=[],r=0,s=d.length-1;s>r;++r)q.push(cd(Zc(d[r]),$c(d[r]),p));dd(a,l,l.text,$c(o)),j&&h.remove(b.line,j,a),q.length&&h.insert(b.line,q)}else if(k==l)if(1==d.length)dd(a,k,k.text.slice(0,b.ch)+Zc(d[0])+k.text.slice(c.ch),$c(d[0]));else{for(var q=[],r=1,s=d.length-1;s>r;++r)q.push(cd(Zc(d[r]),$c(d[r]),p));q.push(cd(Zc(o)+k.text.slice(c.ch),$c(o),p)),dd(a,k,k.text.slice(0,b.ch)+Zc(d[0]),$c(d[0])),h.insert(b.line+1,q)}else if(1==d.length)dd(a,k,k.text.slice(0,b.ch)+Zc(d[0])+l.text.slice(c.ch),$c(d[0])),h.remove(b.line+1,j,a);else{var q=[];dd(a,k,k.text.slice(0,b.ch)+Zc(d[0]),$c(d[0])),dd(a,l,Zc(o)+l.text.slice(c.ch),$c(o));for(var r=1,s=d.length-1;s>r;++r)q.push(cd(Zc(d[r]),$c(d[r]),p));j>1&&h.remove(b.line+1,j-1,a),h.insert(b.line+1,q)}if(a.options.lineWrapping){var t=Math.max(5,i.scroller.clientWidth/jb(i)-3);h.iter(b.line,b.line+d.length,function(a){if(0!=a.height){var b=(Math.ceil(a.text.length/t)||1)*p;b!=a.height&&sd(a,b)}})}else h.iter(n,b.line+d.length,function(a){var b=B(h,a);b>g.maxLineLength&&(g.maxLine=a,g.maxLineLength=b,g.maxLineChanged=!0,m=!1)}),m&&(a.curOp.updateMaxLine=!0);g.frontier=Math.min(g.frontier,b.line),U(a,400);var u=d.length-j-1;if(nb(a,b.line,c.line+1,u),Ld(a,"change")){for(var r=0;d.length>r;++r)"string"!=typeof d[r]&&(d[r]=d[r].text);var v={from:b,to:c,text:d,origin:f};if(a.curOp.textChanged){for(var w=a.curOp.textChanged;w.next;w=w.next);w.next=v}else a.curOp.textChanged=v}var x,y,z={line:b.line+d.length-1,ch:Zc(o).length+(1==d.length?b.ch:0)};if(e&&"string"!=typeof e)e.from?(x=e.from,y=e.to):x=y=e;else if("end"==e)x=y=z;else if("start"==e)x=y=b;else if("around"==e)x=b,y=z;else{var A=function(a){if(cc(a,b))return a;if(!cc(c,a))return z;var d=a.line+u,e=a.ch;return a.line==c.line&&(e+=Zc(o).length-(c.ch-(c.line==b.line?b.ch:0))),{line:d,ch:e}};x=A(g.sel.from),y=A(g.sel.to)}return ic(a,x,y,null,!0),z}}function ac(a,b,c,d,e){if(d||(d=c),cc(d,c)){var f=d;d=c,c=f}return Yb(a,c,d,je(b),null,e)}function bc(a,b){return a.line==b.line&&a.ch==b.ch}function cc(a,b){return a.line<b.line||a.line==b.line&&a.ch<b.ch}function dc(a){return{line:a.line,ch:a.ch}}function ec(a,b){return Math.max(0,Math.min(b,a.size-1))}function fc(a,b){if(0>b.line)return{line:0,ch:0};if(b.line>=a.size)return{line:a.size-1,ch:rd(a,a.size-1).text.length};var c=b.ch,d=rd(a,b.line).text.length;return null==c||c>d?{line:b.line,ch:d}:0>c?{line:b.line,ch:0}:b}function gc(a,b){return b>=0&&a.size>b}function hc(a,b,c,d){var e=a.view.sel;if(e.shift||e.extend){var f=e.anchor;if(c){var g=cc(b,f);g!=cc(c,f)?(f=b,b=c):g!=cc(b,c)&&(b=c)}ic(a,f,b,d)}else ic(a,b,c||b,d);a.curOp.userSelChange=!0}function ic(a,b,c,d,e){a.view.goalColumn=null;var f=a.view.sel;if((e||!bc(b,f.anchor))&&(b=kc(a,b,d,"push"!=e)),(e||!bc(c,f.head))&&(c=kc(a,c,d,"push"!=e)),!bc(f.anchor,b)||!bc(f.head,c)){f.anchor=b,f.head=c;var g=cc(c,b);f.from=g?c:b,f.to=g?b:c,a.curOp.updateInput=!0,a.curOp.selectionChanged=!0}}function jc(a){ic(a,a.view.sel.from,a.view.sel.to,null,"push")}function kc(a,b,c,d){var e=a.view.doc,f=!1,g=b,h=c||1;a.view.cantEdit=!1;a:for(;;){var j,i=rd(e,g.line);if(i.markedSpans){for(var k=0;i.markedSpans.length>k;++k){var l=i.markedSpans[k],m=l.marker;if((null==l.from||(m.inclusiveLeft?l.from<=g.ch:l.from<g.ch))&&(null==l.to||(m.inclusiveRight?l.to>=g.ch:l.to>g.ch))){if(d&&m.clearOnEnter){(j||(j=[])).push(m);continue}if(!m.atomic)continue;var n=m.find()[0>h?"from":"to"];if(bc(n,g)&&(n.ch+=h,0>n.ch?n=n.line?fc(e,{line:n.line-1}):null:n.ch>i.text.length&&(n=n.line<e.size-1?{line:n.line+1,ch:0}:null),!n)){if(f)return d?(a.view.cantEdit=!0,{line:0,ch:0}):kc(a,b,c,!0);f=!0,n=b,h=-h}g=n;continue a}}if(j)for(var k=0;j.length>k;++k)j[k].clear()}return g}}function lc(a){var b=a.view,c=mc(a,b.sel.head);if(b.focused){var d=a.display,e=d.sizer.getBoundingClientRect(),f=null;if(0>c.top+e.top?f=!0:c.bottom+e.top>(window.innerHeight||document.documentElement.clientHeight)&&(f=!1),null!=f&&!m){var g="none"==d.cursor.style.display;g&&(d.cursor.style.display="",d.cursor.style.left=c.left+"px",d.cursor.style.top=c.top-d.viewOffset+"px"),d.cursor.scrollIntoView(f),g&&(d.cursor.style.display="none")}}}function mc(a,b){for(;;){var c=!1,d=eb(a,b),e=oc(a,d.left,d.top,d.left,d.bottom),f=a.view.scrollTop,g=a.view.scrollLeft;if(null!=e.scrollTop&&(Db(a,e.scrollTop),Math.abs(a.view.scrollTop-f)>1&&(c=!0)),null!=e.scrollLeft&&(Eb(a,e.scrollLeft),Math.abs(a.view.scrollLeft-g)>1&&(c=!0)),!c)return d}}function nc(a,b,c,d,e){var f=oc(a,b,c,d,e);null!=f.scrollTop&&Db(a,f.scrollTop),null!=f.scrollLeft&&Eb(a,f.scrollLeft)}function oc(a,b,c,d,e){var f=a.display,g=Y(f);c+=g,e+=g;var h=f.scroller.clientHeight-Md,i=f.scroller.scrollTop,j={},k=a.view.doc.height+2*g,l=g+10>c,m=e+g>k-10;i>c?j.scrollTop=l?0:Math.max(0,c):e>i+h&&(j.scrollTop=(m?k:e)-h);var n=f.scroller.clientWidth-Md,o=f.scroller.scrollLeft;b+=f.gutters.offsetWidth,d+=f.gutters.offsetWidth;var p=f.gutters.offsetWidth,q=p+10>b;return o+p>b||q?(q&&(b=0),j.scrollLeft=Math.max(0,b-10-p)):d>n+o-3&&(j.scrollLeft=d+10-n),j}function pc(a,b,c,d){var e=a.view.doc;if(c||(c="add"),"smart"==c)if(a.view.mode.indent)var f=X(a,b);else c="prev";var k,g=a.options.tabSize,h=rd(e,b),i=Pd(h.text,null,g),j=h.text.match(/^\s*/)[0];if("smart"==c&&(k=a.view.mode.indent(f,h.text.slice(j.length),h.text),k==Nd)){if(!d)return;c="prev"}"prev"==c?k=b?Pd(rd(e,b-1).text,null,g):0:"add"==c?k=i+a.options.indentUnit:"subtract"==c&&(k=i-a.options.indentUnit),k=Math.max(0,k);var l="",m=0;if(a.options.indentWithTabs)for(var n=Math.floor(k/g);n;--n)m+=g,l+=" ";k>m&&(l+=Rd(k-m)),l!=j&&ac(a,l,{line:b,ch:0},{line:b,ch:j.length},"input"),h.stateAfter=null}function qc(a,b,c){var d=b,e=b,f=a.view.doc;return"number"==typeof b?e=rd(f,ec(f,b)):d=td(b),null==d?null:c(e,d)?(nb(a,d,d+1),e):null}function rc(a,b,c,d){function j(){var a=g+b;return 0>a||a==e.size?!1:(g=a,i=rd(e,a))}function k(a){var c=(d?ue:ve)(i,h,b,!0);if(null==c){if(a||!j())return!1;h=d?(0>b?re:qe)(i):0>b?i.text.length:0}else h=c;return!0}var e=a.view.doc,f=a.view.sel.head,g=f.line,h=f.ch,i=rd(e,g);if("char"==c)k();else if("column"==c)k(!0);else if("word"==c)for(var l=!1;!(0>b)||k();){if(Yd(i.text.charAt(h)))l=!0;else if(l){0>b&&(b=1,k());break}if(b>0&&!k())break}return kc(a,{line:g,ch:h},b,!0)}function sc(a,b){var c=b.ch,d=b.ch;if(a){b.after===!1||d==a.length?--c:++d;for(var e=a.charAt(c),f=Yd(e)?Yd:/\s/.test(e)?function(a){return/\s/.test(a)}:function(a){return!/\s/.test(a)&&!Yd(a)};c>0&&f(a.charAt(c-1));)--c;for(;a.length>d&&f(a.charAt(d));)++d}return{from:{line:b.line,ch:c},to:{line:b.line,ch:d}}}function tc(a,b){hc(a,{line:b,ch:0},fc(a.view.doc,{line:b+1,ch:0}))}function wc(a,b,c,d){s.defaults[a]=b,c&&(uc[a]=d?function(a,b,d){d!=xc&&c(a,b,d)}:c)}function Cc(a,b){if(b===!0)return b;if(a.copyState)return a.copyState(b);var c={};for(var d in b){var e=b[d];e instanceof Array&&(e=e.concat([])),c[d]=e}return c}function Dc(a,b,c){return a.startState?a.startState(b,c):!0}function Gc(a){return"string"==typeof a?Fc[a]:a}function Hc(a,b,c,d){function e(b){b=Gc(b);var f=b[a];if(f===!1)return d&&d(),!0;if(null!=f&&c(f))return!0;if(b.nofallthrough)return d&&d(),!0;var g=b.fallthrough;if(null==g)return!1;if("[object Array]"!=Object.prototype.toString.call(g))return e(g);for(var h=0,i=g.length;i>h;++h)if(e(g[h]))return!0;return!1}for(var f=0;b.length>f;++f)if(e(b[f]))return!0}function Ic(a){var b=me[Gd(a,"keyCode")];return"Ctrl"==b||"Alt"==b||"Shift"==b||"Mod"==b}function Jc(a,b){this.pos=this.start=0,this.string=a,this.tabSize=b||8}function Kc(a,b){this.lines=[],this.type=b,this.cm=a}function Lc(a,b,c,d,e){var f=a.view.doc,g=new Kc(a,e);if("range"==e&&!cc(b,c))return g;if(d)for(var h in d)d.hasOwnProperty(h)&&(g[h]=d[h]);g.replacedWith&&(g.collapsed=!0,g.replacedWith=_d("span",[g.replacedWith],"CodeMirror-widget")),g.collapsed&&(r=!0);var k,l,i=b.line,j=0;if(f.iter(i,c.line+1,function(a){var d={from:null,to:null,marker:g};j+=a.text.length,i==b.line&&(d.from=b.ch,j-=b.ch),i==c.line&&(d.to=c.ch,j-=a.text.length-c.ch),g.collapsed&&(i==c.line&&(l=Tc(a,c.ch)),i==b.line?k=Tc(a,b.ch):sd(a,0)),Oc(a,d),g.collapsed&&i==b.line&&Xc(a)&&sd(a,0),++i}),g.readOnly&&(q=!0,(a.view.history.done.length||a.view.history.undone.length)&&a.clearHistory()),g.collapsed){if(k!=l)throw Error("Inserting collapsed marker overlapping an existing one");g.size=j,g.atomic=!0}return(g.className||g.startStyle||g.endStyle||g.collapsed)&&nb(a,b.line,c.line+1),g.atomic&&jc(a),g}function Mc(a,b){if(a)for(var c=0;a.length>c;++c){var d=a[c];if(d.marker==b)return d}}function Nc(a,b){for(var c,d=0;a.length>d;++d)a[d]!=b&&(c||(c=[])).push(a[d]);return c}function Oc(a,b){a.markedSpans=a.markedSpans?a.markedSpans.concat([b]):[b],b.marker.lines.push(a)}function Pc(a,b){if(a)for(var d,c=0;a.length>c;++c){var e=a[c],f=e.marker,g=null==e.from||(f.inclusiveLeft?b>=e.from:b>e.from);if(g||"bookmark"==f.type&&e.from==b){var h=null==e.to||(f.inclusiveRight?e.to>=b:e.to>b);(d||(d=[])).push({from:e.from,to:h?null:e.to,marker:f})}}return d}function Qc(a,b,c){if(a)for(var e,d=0;a.length>d;++d){var f=a[d],g=f.marker,h=null==f.to||(g.inclusiveRight?f.to>=c:f.to>c);if(h||"bookmark"==g.type&&f.from==c&&f.from!=b){var i=null==f.from||(g.inclusiveLeft?c>=f.from:c>f.from);(e||(e=[])).push({from:i?null:f.from-c,to:null==f.to?null:f.to-c,marker:g})}}return e}function Rc(a,b,c,d,e){if(!a&&!b)return e;var f=Pc(a,c),g=Qc(b,c,d),h=1==e.length,i=Sd(e).length+(h?c:0);if(f)for(var j=0;f.length>j;++j){var k=f[j];if(null==k.to){var l=Mc(g,k.marker);l?h&&(k.to=null==l.to?null:l.to+i):k.to=c}}if(g)for(var j=0;g.length>j;++j){var k=g[j];if(null!=k.to&&(k.to+=i),null==k.from){var l=Mc(f,k.marker);l||(k.from=i,h&&(f||(f=[])).push(k))}else k.from+=i,h&&(f||(f=[])).push(k)}var m=[_c(e[0],f)];if(!h){var o,n=e.length-2;if(n>0&&f)for(var j=0;f.length>j;++j)null==f[j].to&&(o||(o=[])).push({from:null,to:null,marker:f[j].marker});for(var j=0;n>j;++j)m.push(_c(e[j+1],o));m.push(_c(Sd(e),g))}return m}function Sc(a,b,c){var d=null;if(a.iter(b.line,c.line+1,function(a){if(a.markedSpans)for(var b=0;a.markedSpans.length>b;++b){var c=a.markedSpans[b].marker;!c.readOnly||d&&-1!=Ud(d,c)||(d||(d=[])).push(c)}}),!d)return null;for(var e=[{from:b,to:c}],f=0;d.length>f;++f)for(var g=d[f].find(),h=0;e.length>h;++h){var i=e[h];if(cc(g.from,i.to)&&!cc(g.to,i.from)){var j=[h,1];cc(i.from,g.from)&&j.push({from:i.from,to:g.from}),cc(g.to,i.to)&&j.push({from:g.to,to:i.to}),e.splice.apply(e,j),h+=j.length-1}}return e}function Tc(a,b){var d,c=r&&a.markedSpans;if(c)for(var e,f=0;c.length>f;++f)e=c[f],e.marker.collapsed&&(null==e.from||b>e.from)&&(null==e.to||e.to>b)&&(!d||d.width<e.marker.width)&&(d=e.marker);return d}function Uc(a){return Tc(a,-1)}function Vc(a){return Tc(a,a.text.length+1)}function Wc(a,b){for(var c;c=Uc(b);)b=rd(a,c.find().from.line);return b}function Xc(a){var b=r&&a.markedSpans;if(b)for(var c,d=0;b.length>d;++d)if(c=b[d],c.marker.collapsed){if(null==c.from)return!0;if(0==c.from&&c.marker.inclusiveLeft&&Yc(a,c))return!0}}function Yc(a,b){if(null==b.to||b.marker.inclusiveRight&&b.to==a.text.length)return!0;for(var c,d=0;a.markedSpans.length>d;++d)if(c=a.markedSpans[d],c.marker.collapsed&&c.from==b.to&&(c.marker.inclusiveLeft||b.marker.inclusiveRight)&&Yc(a,c))return!0}function Zc(a){return"string"==typeof a?a:a.text}function $c(a){if("string"==typeof a)return null;for(var b=a.markedSpans,c=null,d=0;b.length>d;++d)b[d].marker.explicitlyCleared?c||(c=b.slice(0,d)):c&&c.push(b[d]);return c?c.length?c:null:b}function _c(a,b){return b?{text:a,markedSpans:b}:a}function ad(a){var b=a.markedSpans;if(b){for(var c=0;b.length>c;++c){var d=b[c].marker.lines,e=Ud(d,a);d.splice(e,1)}a.markedSpans=null}}function bd(a,b){if(b){for(var c=0;b.length>c;++c)b[c].marker.lines.push(a);a.markedSpans=b}}function cd(a,b,c){var d={text:a,height:c};return bd(d,b),Xc(d)&&(d.height=0),d}function dd(a,b,c,d){b.text=c,b.stateAfter=b.styles=null,null!=b.order&&(b.order=null),ad(b),bd(b,d),Xc(b)?b.height=0:b.height||(b.height=ib(a.display)),Kd(a,b,"change")}function ed(a){a.parent=null,ad(a)}function fd(a,b,c){var d=a.view.mode,e=a.options.flattenSpans,f=!b.styles,g=0,h="",i=null,j=new Jc(b.text,a.options.tabSize),k=b.styles||(b.styles=[]);for(""==b.text&&d.blankLine&&d.blankLine(c);!j.eol();){var l=d.token(j,c),m=j.current();if(j.start=j.pos,e&&i==l?h+=m:(h&&(f=f||g>=k.length||h!=k[g]||i!=k[g+1],k[g++]=h,k[g++]=i),h=m,i=l),j.pos>5e3)break}return h&&(f=f||g>=k.length||h!=k[g]||i!=k[g+1],k[g++]=h,k[g++]=i),j.pos>5e3&&(k[g++]=b.text.slice(j.pos),k[g++]=null),g!=k.length&&(k.length=g,f=!0),f}function gd(a,b,c){var d=a.view.mode,e=new Jc(b.text,a.options.tabSize);for(""==b.text&&d.blankLine&&d.blankLine(c);!e.eol()&&5e3>=e.pos;)d.token(e,c),e.start=e.pos}function id(a){return a?hd[a]||(hd[a]="cm-"+a.replace(/ +/g," cm-")):null}function jd(a,b,c){for(var d,f,g,e=b,h=!0;d=Uc(e);)h=!1,e=rd(a.view.doc,d.find().from.line),f||(f=e);var i={pre:_d("pre"),col:0,pos:0,display:!c,measure:null,addedOne:!1,cm:a};e.textClass&&(i.pre.className=e.textClass);do{e.styles||fd(a,e,e.stateAfter=X(a,td(e))),i.measure=e==b&&c,i.pos=0,i.addToken=i.measure?md:ld,c&&g&&e!=b&&!i.addedOne&&(c[0]=i.pre.appendChild(ie(a.display.measure)),i.addedOne=!0);var j=od(e,i);g=e==f,j&&(e=rd(a.view.doc,j.to.line),h=!1)}while(j);return c&&!i.addedOne&&(c[0]=i.pre.appendChild(h?_d("span","\u00a0"):ie(a.display.measure))),i.pre.firstChild||Xc(b)||i.pre.appendChild(document.createTextNode("\u00a0")),i.pre}function ld(a,b,c,d,e){if(b){if(kd.test(b))for(var f=document.createDocumentFragment(),g=0;;){kd.lastIndex=g;var h=kd.exec(b),i=h?h.index-g:b.length-g;if(i&&(f.appendChild(document.createTextNode(b.slice(g,g+i))),a.col+=i),!h)break;if(g+=i+1," "==h[0]){var j=a.cm.options.tabSize,k=j-a.col%j;f.appendChild(_d("span",Rd(k),"cm-tab")),a.col+=k}else{var l=_d("span","\u2022","cm-invalidchar");l.title="\\u"+h[0].charCodeAt(0).toString(16),f.appendChild(l),a.col+=1}}else{a.col+=b.length;var f=document.createTextNode(b)}if(c||d||e||a.measure){var m=c||"";return d&&(m+=d),e&&(m+=e),a.pre.appendChild(_d("span",[f],m))}a.pre.appendChild(f)}}function md(a,b,c,d,e){for(var f=0;b.length>f;++f)f&&b.length-1>f&&a.cm.options.lineWrapping&&ee.test(b.slice(f-1,f+1))&&a.pre.appendChild(_d("wbr")),a.measure[a.pos++]=ld(a,b.charAt(f),c,0==f&&d,f==b.length-1&&e);b.length&&(a.addedOne=!0)}function nd(a,b,c){c&&(a.display||(c=c.cloneNode(!0)),a.pre.appendChild(c),a.measure&&b&&(a.measure[a.pos]=c,a.addedOne=!0)),a.pos+=b}function od(a,b){var c=a.styles,d=a.markedSpans;if(d)for(var j,l,m,n,o,f=a.text,g=f.length,h=0,e=0,i="",k=0;;){if(k==h){l=m=n="",o=null,k=1/0;for(var p=null,q=0;d.length>q;++q){var r=d[q],s=r.marker;h>=r.from&&(null==r.to||r.to>h)?(null!=r.to&&k>r.to&&(k=r.to,m=""),s.className&&(l+=" "+s.className),s.startStyle&&r.from==h&&(n+=" "+s.startStyle),s.endStyle&&r.to==k&&(m+=" "+s.endStyle),s.collapsed&&(!o||o.marker.width<s.width)&&(o=r)):r.from>h&&k>r.from&&(k=r.from),"bookmark"==s.type&&r.from==h&&s.replacedWith&&(p=s.replacedWith)}if(o&&(o.from||0)==h&&(nd(b,(null==o.to?g:o.to)-h,null!=o.from&&o.marker.replacedWith),null==o.to))return o.marker.find();p&&!o&&nd(b,0,p)}if(h>=g)break;for(var t=Math.min(g,k);;){if(i){var u=h+i.length;if(!o){var v=u>t?i.slice(0,t-h):i;b.addToken(b,v,j+l,n,h+v.length==k?m:"")}if(u>=t){i=i.slice(t-h),h=t;break}h=u,n=""}i=c[e++],j=id(c[e++])}}else for(var e=0;c.length>e;e+=2)b.addToken(b,c[e],id(c[e+1]))}function pd(a){this.lines=a,this.parent=null;for(var b=0,c=a.length,d=0;c>b;++b)a[b].parent=this,d+=a[b].height;this.height=d}function qd(a){this.children=a;for(var b=0,c=0,d=0,e=a.length;e>d;++d){var f=a[d];b+=f.chunkSize(),c+=f.height,f.parent=this}this.size=b,this.height=c,this.parent=null}function rd(a,b){for(;!a.lines;)for(var c=0;;++c){var d=a.children[c],e=d.chunkSize();if(e>b){a=d;break}b-=e}return a.lines[b]}function sd(a,b){for(var c=b-a.height,d=a;d;d=d.parent)d.height+=c}function td(a){if(null==a.parent)return null;for(var b=a.parent,c=Ud(b.lines,a),d=b.parent;d;b=d,d=d.parent)for(var e=0;d.children[e]!=b;++e)c+=d.children[e].chunkSize();return c}function ud(a,b){var c=0;a:do{for(var d=0,e=a.children.length;e>d;++d){var f=a.children[d],g=f.height;if(g>b){a=f;continue a}b-=g,c+=f.chunkSize()}return c}while(!a.lines);for(var d=0,e=a.lines.length;e>d;++d){var h=a.lines[d],i=h.height;if(i>b)break;b-=i}return c+d}function vd(a,b){b=Wc(a.view.doc,b);for(var c=0,d=b.parent,e=0;d.lines.length>e;++e){var f=d.lines[e];if(f==b)break;c+=f.height}for(var g=d.parent;g;d=g,g=d.parent)for(var e=0;g.children.length>e;++e){var h=g.children[e];if(h==d)break;c+=h.height}return c}function wd(a){var b=a.order;return null==b&&(b=a.order=we(a.text)),b}function xd(){return{done:[],undone:[],lastTime:0,lastOp:null,lastOrigin:null,dirtyCounter:0}}function yd(a,b,c,d,e,f,g,h,i){var j=a.view.history;j.undone.length=0;var k=+new Date,l=Sd(j.done);if(l&&(j.lastOp==a.curOp.id||j.lastOrigin==e&&("input"==e||"delete"==e)&&j.lastTime>k-600)){var m=Sd(l.events);if(m.start>b+d.length||b>m.start+m.added)l.events.push({start:b,added:c,old:d});else{for(var n=Math.max(0,m.start-b),o=Math.max(0,b+d.length-(m.start+m.added)),p=n;p>0;--p)m.old.unshift(d[p-1]);for(var p=o;p>0;--p)m.old.push(d[d.length-p]);n&&(m.start=b),m.added+=c-(d.length-n-o)}l.fromAfter=h,l.toAfter=i}else{for(l={events:[{start:b,added:c,old:d}],fromBefore:f,toBefore:g,fromAfter:h,toAfter:i},j.done.push(l);j.done.length>a.options.undoDepth;)j.done.shift();0>j.dirtyCounter?j.dirtyCounter=0/0:j.dirtyCounter++}j.lastTime=k,j.lastOp=a.curOp.id,j.lastOrigin=e}function zd(){Dd(this)}function Ad(a){return a.stop||(a.stop=zd),a}function Bd(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function Cd(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}function Dd(a){Bd(a),Cd(a)}function Ed(a){return a.target||a.srcElement}function Fd(a){var b=a.which;return null==b&&(1&a.button?b=1:2&a.button?b=3:4&a.button&&(b=2)),p&&a.ctrlKey&&1==b&&(b=3),b}function Gd(a,b){var c=a.override&&a.override.hasOwnProperty(b);return c?a.override[b]:a[b]}function Hd(a,b,c){if(a.addEventListener)a.addEventListener(b,c,!1);else if(a.attachEvent)a.attachEvent("on"+b,c);else{var d=a._handlers||(a._handlers={}),e=d[b]||(d[b]=[]);e.push(c)}}function Id(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c,!1);else if(a.detachEvent)a.detachEvent("on"+b,c);else{var d=a._handlers&&a._handlers[b];if(!d)return;for(var e=0;d.length>e;++e)if(d[e]==c){d.splice(e,1);break}}}function Jd(a,b){var c=a._handlers&&a._handlers[b];if(c)for(var d=Array.prototype.slice.call(arguments,2),e=0;c.length>e;++e)c[e].apply(null,d)}function Kd(a,b,c){function g(a){return function(){a.apply(null,e)}}var d=b._handlers&&b._handlers[c];if(d)for(var e=Array.prototype.slice.call(arguments,3),f=a.curOp&&a.curOp.delayedCallbacks,h=0;d.length>h;++h)f?f.push(g(d[h])):d[h].apply(null,e)}function Ld(a,b){var c=a._handlers&&a._handlers[b];return c&&c.length>0}function Od(){this.id=null}function Pd(a,b,c){null==b&&(b=a.search(/[^\s\u00a0]/),-1==b&&(b=a.length));for(var d=0,e=0;b>d;++d)" "==a.charAt(d)?e+=c-e%c:++e;return e}function Rd(a){for(;a>=Qd.length;)Qd.push(Sd(Qd)+" ");return Qd[a]}function Sd(a){return a[a.length-1]}function Td(a){n?(a.selectionStart=0,a.selectionEnd=a.value.length):a.select()}function Ud(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;d>c;++c)if(a[c]==b)return c;return-1}function Vd(a){for(var b=[],c=0;a>c;++c)b.push(void 0);return b}function Wd(a){var b=Array.prototype.slice.call(arguments,1);return function(){return a.apply(null,b)}}function Yd(a){return/\w/.test(a)||a>"\u0080"&&(a.toUpperCase()!=a.toLowerCase()||Xd.test(a))}function Zd(a){var b=0;for(var c in a)a.hasOwnProperty(c)&&a[c]&&++b;return!b}function _d(a,b,c,d){var e=document.createElement(a);if(c&&(e.className=c),d&&(e.style.cssText=d),"string"==typeof b)ce(e,b);else if(b)for(var f=0;b.length>f;++f)e.appendChild(b[f]);return e}function ae(a){return a.innerHTML="",a}function be(a,b){return ae(a).appendChild(b)}function ce(a,b){d?(a.innerHTML="",a.appendChild(document.createTextNode(b))):a.textContent=b}function ge(a){if(null!=fe)return fe;var b=_d("div",null,null,"width: 50px; height: 50px; overflow-x: scroll");return be(a,b),b.offsetWidth&&(fe=b.offsetHeight-b.clientHeight),fe||0}function ie(a){if(null==he){var b=_d("span","\u200b");be(a,_d("span",[b,document.createTextNode("x")])),0!=a.firstChild.offsetHeight&&(he=1>=b.offsetWidth&&b.offsetHeight>2&&!c)}return he?_d("span","\u200b"):_d("span","\u00a0",null,"display: inline-block; width: 1px; margin-right: -1px")}function ne(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=0;a.length>e;++e){var f=a[e];c>f.from&&f.to>b&&d(Math.max(f.from,b),Math.min(f.to,c),1==f.level?"rtl":"ltr")}}function oe(a){return a.level%2?a.to:a.from}function pe(a){return a.level%2?a.from:a.to}function qe(a){var b=wd(a);return b?oe(b[0]):0}function re(a){var b=wd(a);return b?pe(Sd(b)):a.text.length}function se(a,b){var c=rd(a.view.doc,b),d=Wc(a.view.doc,c);d!=c&&(b=td(d));var e=wd(d),f=e?e[0].level%2?re(d):qe(d):0;return{line:b,ch:f}}function te(a,b){for(var c,d;c=Vc(d=rd(a.view.doc,b));)b=c.find().to.line;var e=wd(d),f=e?e[0].level%2?qe(d):re(d):d.text.length;return{line:b,ch:f}}function ue(a,b,c,d){var e=wd(a);if(!e)return ve(a,b,c,d);for(var f=d?function(b,c){do b+=c;while(b>0&&$d.test(a.text.charAt(b)));return b}:function(a,b){return a+b},g=e[0].level,h=0;e.length>h;++h){var i=e[h],j=i.level%2==g;if(b>i.from&&i.to>b||j&&(i.from==b||i.to==b))break}for(var k=f(b,i.level%2?-c:c);null!=k;)if(i.level%2==g){if(!(i.from>k||k>i.to))break;i=e[h+=c],k=i&&(c>0==i.level%2?f(i.to,-1):f(i.from,1))}else if(k==oe(i))i=e[--h],k=i&&pe(i);else{if(k!=pe(i))break;i=e[++h],k=i&&oe(i)}return 0>k||k>a.text.length?null:k}function ve(a,b,c,d){var e=b+c;if(d)for(;e>0&&$d.test(a.text.charAt(e));)e+=c;return 0>e||e>a.text.length?null:e}var hb,xb,yb,Gb,Hb,Ib,Jb,a=/gecko\/\d/i.test(navigator.userAgent),b=/MSIE \d/.test(navigator.userAgent),c=/MSIE [1-7]\b/.test(navigator.userAgent),d=/MSIE [1-8]\b/.test(navigator.userAgent),e=/WebKit\//.test(navigator.userAgent),f=e&&/Qt\/\d+\.\d+/.test(navigator.userAgent),g=/Chrome\//.test(navigator.userAgent),h=/Opera\//.test(navigator.userAgent),i=/Apple Computer/.test(navigator.vendor),j=/KHTML\//.test(navigator.userAgent),k=/Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent),l=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),m=/PhantomJS/.test(navigator.userAgent),n=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),o=n||/Android|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent),p=n||/Mac/.test(navigator.platform),q=!1,r=!1,Fb=0,Kb=null;b?Kb=-.53:a?Kb=15:g?Kb=-.7:i&&(Kb=-1/3);var Ob,Wb,Rb=null;s.prototype={getValue:function(a){var b=[],c=this.view.doc;return c.iter(0,c.size,function(a){b.push(a.text)}),b.join(a||"\n")},setValue:mb(null,function(a){var b=this.view.doc,c={line:0,ch:0},d=rd(b,b.size-1).text.length;Zb(this,c,{line:b.size-1,ch:d},je(a),c,c,"setValue")}),getSelection:function(a){return this.getRange(this.view.sel.from,this.view.sel.to,a)},replaceSelection:mb(null,function(a,b,c){var d=this.view.sel;Yb(this,d.from,d.to,je(a),b||"around",c)}),focus:function(){window.focus(),sb(this),Ub(this),pb(this)},setOption:function(a,b){var c=this.options,d=c[a];(c[a]!=b||"mode"==a)&&(c[a]=b,uc.hasOwnProperty(a)&&mb(this,uc[a])(this,b,d))},getOption:function(a){return this.options[a]},getMode:function(){return this.view.mode},addKeyMap:function(a){this.view.keyMaps.push(a)},removeKeyMap:function(a){for(var b=this.view.keyMaps,c=0;b.length>c;++c)if(("string"==typeof a?b[c].name:b[c])==a)return b.splice(c,1),!0},undo:mb(null,function(){$b(this,"undo")}),redo:mb(null,function(){$b(this,"redo")}),indentLine:mb(null,function(a,b,c){"string"!=typeof b&&(b=null==b?this.options.smartIndent?"smart":"prev":b?"add":"subtract"),gc(this.view.doc,a)&&pc(this,a,b,c)}),indentSelection:mb(null,function(a){var b=this.view.sel;if(bc(b.from,b.to))return pc(this,b.from.line,a);for(var c=b.to.line-(b.to.ch?0:1),d=b.from.line;c>=d;++d)pc(this,d,a)}),historySize:function(){var a=this.view.history;return{undo:a.done.length,redo:a.undone.length}},clearHistory:function(){this.view.history=xd()},markClean:function(){this.view.history.dirtyCounter=0,this.view.history.lastOp=this.view.history.lastOrigin=null},isClean:function(){return 0==this.view.history.dirtyCounter},getHistory:function(){function b(a){for(var d,b=0,c=[];a.length>b;++b){var e=a[b];c.push({events:d=[],fromBefore:e.fromBefore,toBefore:e.toBefore,fromAfter:e.fromAfter,toAfter:e.toAfter});for(var f=0,g=e.events;g.length>f;++f){var h=[],i=g[f];d.push({start:i.start,added:i.added,old:h});for(var j=0;i.old.length>j;++j)h.push(Zc(i.old[j]))}}return c}var a=this.view.history;return{done:b(a.done),undone:b(a.undone)}},setHistory:function(a){var b=this.view.history=xd();b.done=a.done,b.undone=a.undone},getTokenAt:function(a){var b=this.view.doc;a=fc(b,a);for(var c=X(this,a.line),d=this.view.mode,e=rd(b,a.line),f=new Jc(e.text,this.options.tabSize);f.pos<a.ch&&!f.eol();){f.start=f.pos;var g=d.token(f,c)}return{start:f.start,end:f.pos,string:f.current(),className:g||null,type:g||null,state:c}},getStateAfter:function(a){var b=this.view.doc;return a=ec(b,null==a?b.size-1:a),X(this,a+1)},cursorCoords:function(a,b){var c,d=this.view.sel;return c=null==a?d.head:"object"==typeof a?fc(this.view.doc,a):a?d.from:d.to,eb(this,c,b||"page")},charCoords:function(a,b){return db(this,fc(this.view.doc,a),b||"page")},coordsChar:function(a){var b=this.display.lineSpace.getBoundingClientRect();return fb(this,a.left-b.left,a.top-b.top)},defaultTextHeight:function(){return ib(this.display)},markText:mb(null,function(a,b,c){return Lc(this,fc(this.view.doc,a),fc(this.view.doc,b),c,"range")}),setBookmark:mb(null,function(a,b){return a=fc(this.view.doc,a),Lc(this,a,a,b?{replacedWith:b}:{},"bookmark")}),findMarksAt:function(a){var b=this.view.doc;a=fc(b,a);var c=[],d=rd(b,a.line).markedSpans;if(d)for(var e=0;d.length>e;++e){var f=d[e];(null==f.from||f.from<=a.ch)&&(null==f.to||f.to>=a.ch)&&c.push(f.marker)}return c},setGutterMarker:mb(null,function(a,b,c){return qc(this,a,function(a){var d=a.gutterMarkers||(a.gutterMarkers={});return d[b]=c,!c&&Zd(d)&&(a.gutterMarkers=null),!0})}),clearGutter:mb(null,function(a){var b=0,c=this,d=c.view.doc;d.iter(0,d.size,function(d){d.gutterMarkers&&d.gutterMarkers[a]&&(d.gutterMarkers[a]=null,nb(c,b,b+1),Zd(d.gutterMarkers)&&(d.gutterMarkers=null)),++b})}),addLineClass:mb(null,function(a,b,c){return qc(this,a,function(a){var d="text"==b?"textClass":"background"==b?"bgClass":"wrapClass";if(a[d]){if(RegExp("\\b"+c+"\\b").test(a[d]))return!1;a[d]+=" "+c}else a[d]=c;return!0})}),removeLineClass:mb(null,function(a,b,c){return qc(this,a,function(a){var d="text"==b?"textClass":"background"==b?"bgClass":"wrapClass",e=a[d];if(!e)return!1;if(null==c)a[d]=null;else{var f=e.replace(RegExp("^"+c+"\\b\\s*|\\s*\\b"+c+"\\b"),"");if(f==e)return!1;a[d]=f||null}return!0})}),addLineWidget:mb(null,function(a,b,c){var d=c||{};return d.node=b,d.noHScroll&&(this.display.alignWidgets=!0),qc(this,a,function(a){return(a.widgets||(a.widgets=[])).push(d),d.line=a,!0}),d}),removeLineWidget:mb(null,function(a){var b=a.line.widgets,c=td(a.line);if(null!=c){for(var d=0;b.length>d;++d)b[d]==a&&b.splice(d--,1);nb(this,c,c+1)}}),lineInfo:function(a){if("number"==typeof a){if(!gc(this.view.doc,a))return null;var b=a;if(a=rd(this.view.doc,a),!a)return null}else{var b=td(a);if(null==b)return null}return{line:b,handle:a,text:a.text,gutterMarkers:a.gutterMarkers,textClass:a.textClass,bgClass:a.bgClass,wrapClass:a.wrapClass,widgets:a.widgets}},getViewport:function(){return{from:this.display.showingFrom,to:this.display.showingTo}},addWidget:function(a,b,c,d,e){var f=this.display;a=eb(this,fc(this.view.doc,a));var g=a.top,h=a.left;if(b.style.position="absolute",f.sizer.appendChild(b),"over"==d)g=a.top;else if("near"==d){var i=Math.max(f.wrapper.clientHeight,this.view.doc.height),j=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth);a.bottom+b.offsetHeight>i&&a.top>b.offsetHeight&&(g=a.top-b.offsetHeight),h+b.offsetWidth>j&&(h=j-b.offsetWidth)}b.style.top=g+Y(f)+"px",b.style.left=b.style.right="","right"==e?(h=f.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==e?h=0:"middle"==e&&(h=(f.sizer.clientWidth-b.offsetWidth)/2),b.style.left=h+"px"),c&&nc(this,h,g,h+b.offsetWidth,g+b.offsetHeight)},lineCount:function(){return this.view.doc.size},clipPos:function(a){return fc(this.view.doc,a)},getCursor:function(a){var c,b=this.view.sel;return c=null==a||"head"==a?b.head:"anchor"==a?b.anchor:"end"==a||a===!1?b.to:b.from,dc(c)},somethingSelected:function(){return!bc(this.view.sel.from,this.view.sel.to)},setCursor:mb(null,function(a,b,c){var d=fc(this.view.doc,"number"==typeof a?{line:a,ch:b||0}:a);c?hc(this,d):ic(this,d,d)}),setSelection:mb(null,function(a,b){var c=this.view.doc;ic(this,fc(c,a),fc(c,b||a))}),extendSelection:mb(null,function(a,b){var c=this.view.doc;hc(this,fc(c,a),b&&fc(c,b))}),setExtending:function(a){this.view.sel.extend=a},getLine:function(a){var b=this.getLineHandle(a);return b&&b.text},getLineHandle:function(a){var b=this.view.doc;return gc(b,a)?rd(b,a):void 0},getLineNumber:function(a){return td(a)},setLine:mb(null,function(a,b){gc(this.view.doc,a)&&ac(this,b,{line:a,ch:0},{line:a,ch:rd(this.view.doc,a).text.length})}),removeLine:mb(null,function(a){gc(this.view.doc,a)&&ac(this,"",{line:a,ch:0},fc(this.view.doc,{line:a+1,ch:0}))}),replaceRange:mb(null,function(a,b,c){var d=this.view.doc;return b=fc(d,b),c=c?fc(d,c):b,ac(this,a,b,c)}),getRange:function(a,b,c){var d=this.view.doc;a=fc(d,a),b=fc(d,b);var e=a.line,f=b.line;if(e==f)return rd(d,e).text.slice(a.ch,b.ch);var g=[rd(d,e).text.slice(a.ch)];return d.iter(e+1,f,function(a){g.push(a.text)
|
3
|
-
}),g.push(rd(d,f).text.slice(0,b.ch)),g.join(c||"\n")},triggerOnKeyDown:mb(null,Sb),execCommand:function(a){return Ec[a](this)},moveH:mb(null,function(a,b){var c=this.view.sel,d=0>a?c.from:c.to;(c.shift||c.extend||bc(c.from,c.to))&&(d=rc(this,a,b,!0)),hc(this,d,d,a)}),deleteH:mb(null,function(a,b){var c=this.view.sel;bc(c.from,c.to)?ac(this,"",c.from,rc(this,a,b,!1),"delete"):ac(this,"",c.from,c.to,"delete"),this.curOp.userSelChange=!0}),moveV:mb(null,function(a,b){var i,c=this.view,d=c.doc,e=this.display,f=c.sel.head,g=eb(this,f,"div"),h=g.left;if(null!=c.goalColumn&&(h=c.goalColumn),"page"==b){var j=Math.min(e.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);i=g.top+a*j}else"line"==b&&(i=a>0?g.bottom+3:g.top-3);do{var k=fb(this,h,i);i+=5*a}while(k.outside&&(0>a?i>0:d.height>i));"page"==b&&(e.scrollbarV.scrollTop+=db(this,k,"div").top-g.top),hc(this,k,k,a),c.goalColumn=h}),toggleOverwrite:function(){(this.view.overwrite=!this.view.overwrite)?this.display.cursor.className+=" CodeMirror-overwrite":this.display.cursor.className=this.display.cursor.className.replace(" CodeMirror-overwrite","")},posFromIndex:function(a){var c,b=0,d=this.view.doc;return d.iter(0,d.size,function(d){var e=d.text.length+1;return e>a?(c=a,!0):(a-=e,++b,void 0)}),fc(d,{line:b,ch:c})},indexFromPos:function(a){if(0>a.line||0>a.ch)return 0;var b=a.ch;return this.view.doc.iter(0,a.line,function(a){b+=a.text.length+1}),b},scrollTo:function(a,b){null!=a&&(this.display.scrollbarH.scrollLeft=this.display.scroller.scrollLeft=a),null!=b&&(this.display.scrollbarV.scrollTop=this.display.scroller.scrollTop=b),K(this,[])},getScrollInfo:function(){var a=this.display.scroller,b=Md;return{left:a.scrollLeft,top:a.scrollTop,height:a.scrollHeight-b,width:a.scrollWidth-b,clientHeight:a.clientHeight-b,clientWidth:a.clientWidth-b}},scrollIntoView:function(a){"number"==typeof a&&(a={line:a,ch:0}),a=a?fc(this.view.doc,a):this.view.sel.head,mc(this,a)},setSize:function(a,b){function c(a){return"number"==typeof a||/^\d+$/.test(a+"")?a+"px":a}null!=a&&(this.display.wrapper.style.width=c(a)),null!=b&&(this.display.wrapper.style.height=c(b)),this.refresh()},on:function(a,b){Hd(this,a,b)},off:function(a,b){Id(this,a,b)},operation:function(a){return mb(this,a)()},refresh:function(){bb(this),this.display.scroller.scrollHeight>this.view.scrollTop&&(this.display.scrollbarV.scrollTop=this.display.scroller.scrollTop=this.view.scrollTop),K(this,!0)},getInputField:function(){return this.display.input},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}};var uc=s.optionHandlers={},vc=s.defaults={},xc=s.Init={toString:function(){return"CodeMirror.Init"}};wc("value","",function(a,b){a.setValue(b)},!0),wc("mode",null,v,!0),wc("indentUnit",2,v,!0),wc("indentWithTabs",!1),wc("smartIndent",!0),wc("tabSize",4,function(a){v(a),bb(a),K(a,!0)},!0),wc("electricChars",!0),wc("theme","default",function(a){y(a),z(a)},!0),wc("keyMap","default",x),wc("extraKeys",null),wc("onKeyEvent",null),wc("onDragEvent",null),wc("lineWrapping",!1,w,!0),wc("gutters",[],function(a){D(a.options),z(a)},!0),wc("lineNumbers",!1,function(a){D(a.options),z(a)},!0),wc("firstLineNumber",1,z,!0),wc("lineNumberFormatter",function(a){return a},z,!0),wc("showCursorWhenSelecting",!1,Q,!0),wc("readOnly",!1,function(a,b){"nocursor"==b?(Vb(a),a.display.input.blur()):b||rb(a,!0)}),wc("dragDrop",!0),wc("cursorBlinkRate",530),wc("cursorHeight",1),wc("workTime",100),wc("workDelay",100),wc("flattenSpans",!0),wc("pollInterval",100),wc("undoDepth",40),wc("viewportMargin",10,function(a){a.refresh()},!0),wc("tabindex",null,function(a,b){a.display.input.tabIndex=b||""}),wc("autofocus",null);var yc=s.modes={},zc=s.mimeModes={};s.defineMode=function(a,b){if(s.defaults.mode||"null"==a||(s.defaults.mode=a),arguments.length>2){b.dependencies=[];for(var c=2;arguments.length>c;++c)b.dependencies.push(arguments[c])}yc[a]=b},s.defineMIME=function(a,b){zc[a]=b},s.resolveMode=function(a){if("string"==typeof a&&zc.hasOwnProperty(a))a=zc[a];else if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a))return s.resolveMode("application/xml");return"string"==typeof a?{name:a}:a||{name:"null"}},s.getMode=function(a,b){var b=s.resolveMode(b),c=yc[b.name];if(!c)return s.getMode(a,"text/plain");var d=c(a,b);if(Ac.hasOwnProperty(b.name)){var e=Ac[b.name];for(var f in e)e.hasOwnProperty(f)&&(d.hasOwnProperty(f)&&(d["_"+f]=d[f]),d[f]=e[f])}return d.name=b.name,d},s.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}}),s.defineMIME("text/plain","null");var Ac=s.modeExtensions={};s.extendMode=function(a,b){var c=Ac.hasOwnProperty(a)?Ac[a]:Ac[a]={};for(var d in b)b.hasOwnProperty(d)&&(c[d]=b[d])},s.defineExtension=function(a,b){s.prototype[a]=b},s.defineOption=wc;var Bc=[];s.defineInitHook=function(a){Bc.push(a)},s.copyState=Cc,s.startState=Dc,s.innerMode=function(a,b){for(;a.innerMode;){var c=a.innerMode(b);b=c.state,a=c.mode}return c||{mode:a,state:b}};var Ec=s.commands={selectAll:function(a){a.setSelection({line:0,ch:0},{line:a.lineCount()-1})},killLine:function(a){var b=a.getCursor(!0),c=a.getCursor(!1),d=!bc(b,c);d||a.getLine(b.line).length!=b.ch?a.replaceRange("",b,d?c:{line:b.line},"delete"):a.replaceRange("",b,{line:b.line+1,ch:0},"delete")},deleteLine:function(a){var b=a.getCursor().line;a.replaceRange("",{line:b,ch:0},{line:b},"delete")},undo:function(a){a.undo()},redo:function(a){a.redo()},goDocStart:function(a){a.extendSelection({line:0,ch:0})},goDocEnd:function(a){a.extendSelection({line:a.lineCount()-1})},goLineStart:function(a){a.extendSelection(se(a,a.getCursor().line))},goLineStartSmart:function(a){var b=a.getCursor(),c=se(a,b.line),d=a.getLineHandle(c.line),e=wd(d);if(e&&0!=e[0].level)a.extendSelection(c);else{var f=Math.max(0,d.text.search(/\S/)),g=b.line==c.line&&f>=b.ch&&b.ch;a.extendSelection({line:c.line,ch:g?0:f})}},goLineEnd:function(a){a.extendSelection(te(a,a.getCursor().line))},goLineUp:function(a){a.moveV(-1,"line")},goLineDown:function(a){a.moveV(1,"line")},goPageUp:function(a){a.moveV(-1,"page")},goPageDown:function(a){a.moveV(1,"page")},goCharLeft:function(a){a.moveH(-1,"char")},goCharRight:function(a){a.moveH(1,"char")},goColumnLeft:function(a){a.moveH(-1,"column")},goColumnRight:function(a){a.moveH(1,"column")},goWordLeft:function(a){a.moveH(-1,"word")},goWordRight:function(a){a.moveH(1,"word")},delCharBefore:function(a){a.deleteH(-1,"char")},delCharAfter:function(a){a.deleteH(1,"char")},delWordBefore:function(a){a.deleteH(-1,"word")},delWordAfter:function(a){a.deleteH(1,"word")},indentAuto:function(a){a.indentSelection("smart")},indentMore:function(a){a.indentSelection("add")},indentLess:function(a){a.indentSelection("subtract")},insertTab:function(a){a.replaceSelection(" ","end","input")},defaultTab:function(a){a.somethingSelected()?a.indentSelection("add"):a.replaceSelection(" ","end","input")},transposeChars:function(a){var b=a.getCursor(),c=a.getLine(b.line);b.ch>0&&b.ch<c.length-1&&a.replaceRange(c.charAt(b.ch)+c.charAt(b.ch-1),{line:b.line,ch:b.ch-1},{line:b.line,ch:b.ch+1})},newlineAndIndent:function(a){mb(a,function(){a.replaceSelection("\n","end","input"),a.indentLine(a.getCursor().line,null,!0)})()},toggleOverwrite:function(a){a.toggleOverwrite()}},Fc=s.keyMap={};Fc.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite"},Fc.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Alt-Up":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Down":"goDocEnd","Ctrl-Left":"goWordLeft","Ctrl-Right":"goWordRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delWordBefore","Ctrl-Delete":"delWordAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore",fallthrough:"basic"},Fc.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goWordLeft","Alt-Right":"goWordRight","Cmd-Left":"goLineStart","Cmd-Right":"goLineEnd","Alt-Backspace":"delWordBefore","Ctrl-Alt-Backspace":"delWordAfter","Alt-Delete":"delWordAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore",fallthrough:["basic","emacsy"]},Fc["default"]=p?Fc.macDefault:Fc.pcDefault,Fc.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},s.isModifierKey=Ic,s.fromTextArea=function(a,b){function e(){a.value=i.getValue()}if(b||(b={}),b.value=a.value,!b.tabindex&&a.tabindex&&(b.tabindex=a.tabindex),null==b.autofocus){var c=document.body;try{c=document.activeElement}catch(d){}b.autofocus=c==a||null!=a.getAttribute("autofocus")&&c==document.body}if(a.form){Hd(a.form,"submit",e);var f=a.form,g=f.submit;try{f.submit=function h(){e(),f.submit=g,f.submit(),f.submit=h}}catch(d){}}a.style.display="none";var i=s(function(b){a.parentNode.insertBefore(b,a.nextSibling)},b);return i.save=e,i.getTextArea=function(){return a},i.toTextArea=function(){e(),a.parentNode.removeChild(i.getWrapperElement()),a.style.display="",a.form&&(Id(a.form,"submit",e),"function"==typeof a.form.submit&&(a.form.submit=g))},i},Jc.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return 0==this.pos},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(a){var b=this.string.charAt(this.pos);if("string"==typeof a)var c=b==a;else var c=b&&(a.test?a.test(b):a(b));return c?(++this.pos,b):void 0},eatWhile:function(a){for(var b=this.pos;this.eat(a););return this.pos>b},eatSpace:function(){for(var a=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){var b=this.string.indexOf(a,this.pos);return b>-1?(this.pos=b,!0):void 0},backUp:function(a){this.pos-=a},column:function(){return Pd(this.string,this.start,this.tabSize)},indentation:function(){return Pd(this.string,null,this.tabSize)},match:function(a,b,c){if("string"!=typeof a){var e=this.string.slice(this.pos).match(a);return e&&e.index>0?null:(e&&b!==!1&&(this.pos+=e[0].length),e)}var d=function(a){return c?a.toLowerCase():a};return d(this.string).indexOf(d(a),this.pos)==this.pos?(b!==!1&&(this.pos+=a.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)}},s.StringStream=Jc,Kc.prototype.clear=function(){if(!this.explicitlyCleared){kb(this.cm);for(var a=null,b=null,c=0;this.lines.length>c;++c){var d=this.lines[c],e=Mc(d.markedSpans,this);null!=e.to&&(b=td(d)),d.markedSpans=Nc(d.markedSpans,e),null!=e.from?a=td(d):this.collapsed&&!Xc(d)&&sd(d,ib(this.cm.display))}null!=a&&nb(this.cm,a,b+1),this.lines.length=0,this.explicitlyCleared=!0,this.collapsed&&this.cm.view.cantEdit&&(this.cm.view.cantEdit=!1,jc(this.cm)),lb(this.cm),Kd(this.cm,this,"clear")}},Kc.prototype.find=function(){for(var a,b,c=0;this.lines.length>c;++c){var d=this.lines[c],e=Mc(d.markedSpans,this);if(null!=e.from||null!=e.to){var f=td(d);null!=e.from&&(a={line:f,ch:e.from}),null!=e.to&&(b={line:f,ch:e.to})}}return"bookmark"==this.type?a:a&&{from:a,to:b}},window.lineIsHidden=Xc;var hd={},kd=/[\t\u0000-\u0019\u200b\u2028\u2029\uFEFF]/g;pd.prototype={chunkSize:function(){return this.lines.length},remove:function(a,b,c){for(var d=a,e=a+b;e>d;++d){var f=this.lines[d];this.height-=f.height,ed(f),Kd(c,f,"delete")}this.lines.splice(a,b)},collapse:function(a){a.splice.apply(a,[a.length,0].concat(this.lines))},insertHeight:function(a,b,c){this.height+=c,this.lines=this.lines.slice(0,a).concat(b).concat(this.lines.slice(a));for(var d=0,e=b.length;e>d;++d)b[d].parent=this},iterN:function(a,b,c){for(var d=a+b;d>a;++a)if(c(this.lines[a]))return!0}},qd.prototype={chunkSize:function(){return this.size},remove:function(a,b,c){this.size-=b;for(var d=0;this.children.length>d;++d){var e=this.children[d],f=e.chunkSize();if(f>a){var g=Math.min(b,f-a),h=e.height;if(e.remove(a,g,c),this.height-=h-e.height,f==g&&(this.children.splice(d--,1),e.parent=null),0==(b-=g))break;a=0}else a-=f}if(25>this.size-b){var i=[];this.collapse(i),this.children=[new pd(i)],this.children[0].parent=this}},collapse:function(a){for(var b=0,c=this.children.length;c>b;++b)this.children[b].collapse(a)},insert:function(a,b){for(var c=0,d=0,e=b.length;e>d;++d)c+=b[d].height;this.insertHeight(a,b,c)},insertHeight:function(a,b,c){this.size+=b.length,this.height+=c;for(var d=0,e=this.children.length;e>d;++d){var f=this.children[d],g=f.chunkSize();if(g>=a){if(f.insertHeight(a,b,c),f.lines&&f.lines.length>50){for(;f.lines.length>50;){var h=f.lines.splice(f.lines.length-25,25),i=new pd(h);f.height-=i.height,this.children.splice(d+1,0,i),i.parent=this}this.maybeSpill()}break}a-=g}},maybeSpill:function(){if(!(10>=this.children.length)){var a=this;do{var b=a.children.splice(a.children.length-5,5),c=new qd(b);if(a.parent){a.size-=c.size,a.height-=c.height;var e=Ud(a.parent.children,a);a.parent.children.splice(e+1,0,c)}else{var d=new qd(a.children);d.parent=a,a.children=[d,c],a=d}c.parent=a.parent}while(a.children.length>10);a.parent.maybeSpill()}},iter:function(a,b,c){this.iterN(a,b-a,c)},iterN:function(a,b,c){for(var d=0,e=this.children.length;e>d;++d){var f=this.children[d],g=f.chunkSize();if(g>a){var h=Math.min(b,g-a);if(f.iterN(a,h,c))return!0;if(0==(b-=h))break;a=0}else a-=g}}},s.e_stop=Dd,s.e_preventDefault=Bd,s.e_stopPropagation=Cd,s.on=Hd,s.off=Id,s.signal=Jd;var Md=30,Nd=s.Pass={toString:function(){return"CodeMirror.Pass"}};Od.prototype={set:function(a,b){clearTimeout(this.id),this.id=setTimeout(b,a)}},s.countColumn=Pd;var Qd=[""],Xd=/[\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc]/,$d=/[\u0300-\u036F\u0483-\u0487\u0488-\u0489\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\uA66F\uA670-\uA672\uA674-\uA67D\uA69F]/,de=function(){if(d)return!1;var a=_d("div");return"draggable"in a||"dragDrop"in a}(),ee=/^$/;a?ee=/$'/:i?ee=/\-[^ \-?]|\?[^ !'\"\),.\-\/:;\?\]\}]/:g&&(ee=/\-[^ \-\.?]|\?[^ \-\.?\]\}:;!'\"\),\/]|[\.!\"#&%\)*+,:;=>\]|\}~][\(\{\[<]|\$'/);var fe,he,je=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,c=[],d=a.length;d>=b;){var e=a.indexOf("\n",b);-1==e&&(e=a.length);var f=a.slice(b,"\r"==a.charAt(e-1)?e-1:e),g=f.indexOf("\r");-1!=g?(c.push(f.slice(0,g)),b+=g+1):(c.push(f),b=e+1)}return c}:function(a){return a.split(/\r\n?|\n/)};s.splitLines=je;var ke=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){}return b&&b.parentElement()==a?0!=b.compareEndPoints("StartToEnd",b):!1},le=function(){var a=_d("div");return"oncopy"in a?!0:(a.setAttribute("oncopy","return;"),"function"==typeof a.oncopy)}(),me={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",91:"Mod",92:"Mod",93:"Mod",109:"-",107:"=",127:"Delete",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63276:"PageUp",63277:"PageDown",63275:"End",63273:"Home",63234:"Left",63232:"Up",63235:"Right",63233:"Down",63302:"Insert",63272:"Delete"};s.keyNames=me,function(){for(var a=0;10>a;a++)me[a+48]=a+"";for(var a=65;90>=a;a++)me[a]=String.fromCharCode(a);for(var a=1;12>=a;a++)me[a+111]=me[a+63235]="F"+a}();var we=function(){function c(c){return 255>=c?a.charAt(c):c>=1424&&1524>=c?"R":c>=1536&&1791>=c?b.charAt(c-1536):c>=1792&&2220>=c?"r":"L"}var a="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLL",b="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmmrrrrrrrrrrrrrrrrrr",d=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,e=/[stwN]/,f=/[LRr]/,g=/[Lb1n]/,h=/[1n]/;return function(a){if(!d.test(a))return!1;for(var l,b=a.length,i=[],j=null,k=0;b>k;++k)i.push(l=c(a.charCodeAt(k))),null==j&&("L"==l?j="L":("R"==l||"r"==l)&&(j="R"));null==j&&(j="L");for(var k=0,m=j;b>k;++k){var l=i[k];"m"==l?i[k]=m:m=l}for(var k=0,n=j;b>k;++k){var l=i[k];"1"==l&&"r"==n?i[k]="n":f.test(l)&&(n=l,"r"==l&&(i[k]="R"))}for(var k=1,m=i[0];b-1>k;++k){var l=i[k];"+"==l&&"1"==m&&"1"==i[k+1]?i[k]="1":","!=l||m!=i[k+1]||"1"!=m&&"n"!=m||(i[k]=m),m=l}for(var k=0;b>k;++k){var l=i[k];if(","==l)i[k]="N";else if("%"==l){for(var o=k+1;b>o&&"%"==i[o];++o);for(var p=k&&"!"==i[k-1]||b-1>o&&"1"==i[o]?"1":"N",q=k;o>q;++q)i[q]=p;k=o-1}}for(var k=0,n=j;b>k;++k){var l=i[k];"L"==n&&"1"==l?i[k]="L":f.test(l)&&(n=l)}for(var k=0;b>k;++k)if(e.test(i[k])){for(var o=k+1;b>o&&e.test(i[o]);++o);for(var r="L"==(k?i[k-1]:j),s="L"==(b-1>o?i[o]:j),p=r||s?"L":"R",q=k;o>q;++q)i[q]=p;k=o-1}for(var u,t=[],k=0;b>k;)if(g.test(i[k])){var v=k;for(++k;b>k&&g.test(i[k]);++k);t.push({from:v,to:k,level:0})}else{var w=k,x=t.length;for(++k;b>k&&"L"!=i[k];++k);for(var q=w;k>q;)if(h.test(i[q])){q>w&&t.splice(x,0,{from:w,to:q,level:1});var y=q;for(++q;k>q&&h.test(i[q]);++q);t.splice(x,0,{from:y,to:q,level:2}),w=q}else++q;k>w&&t.splice(x,0,{from:w,to:k,level:1})}return 1==t[0].level&&(u=a.match(/^\s+/))&&(t[0].from=u[0].length,t.unshift({from:0,to:u[0].length,level:0})),1==Sd(t).level&&(u=a.match(/\s+$/))&&(Sd(t).to-=u[0].length,t.push({from:b-u[0].length,to:b,level:0})),t[0].level!=Sd(t).level&&t.push({from:b,to:b,level:t[0].level}),t}}();return s.version="3.0",s}(),CodeMirror.defineMode("javascript",function(a,b){function h(a,b,c){return b.tokenize=c,c(a,b)}function i(a,b){for(var d,c=!1;null!=(d=a.next());){if(d==b&&!c)return!1;c=!c&&"\\"==d}return c}function l(a,b,c){return j=a,k=c,b}function m(a,b){var c=a.next();if('"'==c||"'"==c)return h(a,b,n(c));if(/[\[\]{}\(\),;\:\.]/.test(c))return l(c);if("0"==c&&a.eat(/x/i))return a.eatWhile(/[\da-f]/i),l("number","number");if(/\d/.test(c)||"-"==c&&a.eat(/\d/))return a.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),l("number","number");if("/"==c)return a.eat("*")?h(a,b,o):a.eat("/")?(a.skipToEnd(),l("comment","comment")):"operator"==b.lastType||"keyword c"==b.lastType||/^[\[{}\(,;:]$/.test(b.lastType)?(i(a,"/"),a.eatWhile(/[gimy]/),l("regexp","string-2")):(a.eatWhile(g),l("operator",null,a.current()));if("#"==c)return a.skipToEnd(),l("error","error");if(g.test(c))return a.eatWhile(g),l("operator",null,a.current());a.eatWhile(/[\w\$_]/);var d=a.current(),e=f.propertyIsEnumerable(d)&&f[d];return e&&"."!=b.lastType?l(e.type,e.style,d):l("variable","variable",d)}function n(a){return function(b,c){return i(b,a)||(c.tokenize=m),l("string","string")}}function o(a,b){for(var d,c=!1;d=a.next();){if("/"==d&&c){b.tokenize=m;break}c="*"==d}return l("comment","comment")}function q(a,b,c,d,e,f){this.indented=a,this.column=b,this.type=c,this.prev=e,this.info=f,null!=d&&(this.align=d)}function r(a,b){for(var c=a.localVars;c;c=c.next)if(c.name==b)return!0}function s(a,b,c,e,f){var g=a.cc;for(t.state=a,t.stream=f,t.marked=null,t.cc=g,a.lexical.hasOwnProperty("align")||(a.lexical.align=!0);;){var h=g.length?g.pop():d?E:D;if(h(c,e)){for(;g.length&&g[g.length-1].lex;)g.pop()();return t.marked?t.marked:"variable"==c&&r(a,e)?"variable-2":b}}}function u(){for(var a=arguments.length-1;a>=0;a--)t.cc.push(arguments[a])}function v(){return u.apply(null,arguments),!0}function w(a){var b=t.state;if(b.context){t.marked="def";for(var c=b.localVars;c;c=c.next)if(c.name==a)return;b.localVars={name:a,next:b.localVars}}}function y(){t.state.context={prev:t.state.context,vars:t.state.localVars},t.state.localVars=x}function z(){t.state.localVars=t.state.context.vars,t.state.context=t.state.context.prev}function A(a,b){var c=function(){var c=t.state;c.lexical=new q(c.indented,t.stream.column(),a,null,c.lexical,b)};return c.lex=!0,c}function B(){var a=t.state;a.lexical.prev&&(")"==a.lexical.type&&(a.indented=a.lexical.indented),a.lexical=a.lexical.prev)}function C(a){return function(b){return b==a?v():";"==a?u():v(arguments.callee)}}function D(a){return"var"==a?v(A("vardef"),O,C(";"),B):"keyword a"==a?v(A("form"),E,D,B):"keyword b"==a?v(A("form"),D,B):"{"==a?v(A("}"),L,B):";"==a?v():"function"==a?v(U):"for"==a?v(A("form"),C("("),A(")"),Q,C(")"),B,D,B):"variable"==a?v(A("stat"),H):"switch"==a?v(A("form"),E,A("}","switch"),C("{"),L,B,B):"case"==a?v(E,C(":")):"default"==a?v(C(":")):"catch"==a?v(A("form"),y,C("("),V,C(")"),D,B,z):u(A("stat"),E,C(";"),B)}function E(a){return p.hasOwnProperty(a)?v(G):"function"==a?v(U):"keyword c"==a?v(F):"("==a?v(A(")"),F,C(")"),B,G):"operator"==a?v(E):"["==a?v(A("]"),K(E,"]"),B,G):"{"==a?v(A("}"),K(J,"}"),B,G):v()}function F(a){return a.match(/[;\}\)\],]/)?u():u(E)}function G(a,b){if("operator"==a&&/\+\+|--/.test(b))return v(G);if("operator"==a&&"?"==b)return v(E,C(":"),E);if(";"!=a)return"("==a?v(A(")"),K(E,")"),B,G):"."==a?v(I,G):"["==a?v(A("]"),E,C("]"),B,G):void 0}function H(a){return":"==a?v(B,D):u(G,C(";"),B)}function I(a){return"variable"==a?(t.marked="property",v()):void 0}function J(a){return"variable"==a&&(t.marked="property"),p.hasOwnProperty(a)?v(C(":"),E):void 0}function K(a,b){function c(d){return","==d?v(a,c):d==b?v():v(C(b))}return function(d){return d==b?v():u(a,c)}}function L(a){return"}"==a?v():u(D,L)}function M(a){return":"==a?v(N):u()}function N(a){return"variable"==a?(t.marked="variable-3",v()):u()}function O(a,b){return"variable"==a?(w(b),e?v(M,P):v(P)):u()}function P(a,b){return"="==b?v(E,P):","==a?v(O):void 0}function Q(a){return"var"==a?v(O,C(";"),S):";"==a?v(S):"variable"==a?v(R):v(S)}function R(a,b){return"in"==b?v(E):v(G,S)}function S(a,b){return";"==a?v(T):"in"==b?v(E):v(E,C(";"),T)}function T(a){")"!=a&&v(E)}function U(a,b){return"variable"==a?(w(b),v(U)):"("==a?v(A(")"),y,K(V,")"),B,D,z):void 0}function V(a,b){return"variable"==a?(w(b),e?v(M):v()):void 0}var j,k,c=a.indentUnit,d=b.json,e=b.typescript,f=function(){function a(a){return{type:a,style:"keyword"}}var b=a("keyword a"),c=a("keyword b"),d=a("keyword c"),f=a("operator"),g={type:"atom",style:"atom"},h={"if":b,"while":b,"with":b,"else":c,"do":c,"try":c,"finally":c,"return":d,"break":d,"continue":d,"new":d,"delete":d,"throw":d,"var":a("var"),"const":a("var"),let:a("var"),"function":a("function"),"catch":a("catch"),"for":a("for"),"switch":a("switch"),"case":a("case"),"default":a("default"),"in":f,"typeof":f,"instanceof":f,"true":g,"false":g,"null":g,undefined:g,NaN:g,Infinity:g};if(e){var i={type:"variable",style:"variable-3"},j={"interface":a("interface"),"class":a("class"),"extends":a("extends"),constructor:a("constructor"),"public":a("public"),"private":a("private"),"protected":a("protected"),"static":a("static"),"super":a("super"),string:i,number:i,bool:i,any:i};for(var k in j)h[k]=j[k]}return h}(),g=/[+\-*&%=<>!?|]/,p={atom:!0,number:!0,variable:!0,string:!0,regexp:!0},t={state:null,column:null,marked:null,cc:null},x={name:"this",next:{name:"arguments"}};return B.lex=!0,{startState:function(a){return{tokenize:m,lastType:null,cc:[],lexical:new q((a||0)-c,0,"block",!1),localVars:b.localVars,context:b.localVars&&{vars:b.localVars},indented:0}},token:function(a,b){if(a.sol()&&(b.lexical.hasOwnProperty("align")||(b.lexical.align=!1),b.indented=a.indentation()),a.eatSpace())return null;var c=b.tokenize(a,b);return"comment"==j?c:(b.lastType=j,s(b,c,j,k,a))},indent:function(a,b){if(a.tokenize==o)return CodeMirror.Pass;if(a.tokenize!=m)return 0;var d=b&&b.charAt(0),e=a.lexical;"stat"==e.type&&"}"==d&&(e=e.prev);var f=e.type,g=d==f;return"vardef"==f?e.indented+("operator"==a.lastType||","==a.lastType?4:0):"form"==f&&"{"==d?e.indented:"form"==f?e.indented+c:"stat"==f?e.indented+("operator"==a.lastType||","==a.lastType?c:0):"switch"!=e.info||g?e.align?e.column+(g?0:1):e.indented+(g?0:c):e.indented+(/^(?:case|default)\b/.test(b)?c:2*c)},electricChars:":{}",jsonMode:d}}),CodeMirror.defineMIME("text/javascript","javascript"),CodeMirror.defineMIME("application/json",{name:"javascript",json:!0}),CodeMirror.defineMIME("text/typescript",{name:"javascript",typescript:!0}),CodeMirror.defineMIME("application/typescript",{name:"javascript",typescript:!0}),CodeMirror.defineMode("python",function(a,b){function d(a){return RegExp("^(("+a.join(")|(")+"))\\b")}function t(a,b){if(a.sol()){var d=b.scopes[0].offset;if(a.eatSpace()){var l=a.indentation();return l>d?s="indent":d>l&&(s="dedent"),null}d>0&&w(a,b)}if(a.eatSpace())return null;var m=a.peek();if("#"===m)return a.skipToEnd(),"comment";if(a.match(/^[0-9\.]/,!1)){var n=!1;if(a.match(/^\d*\.\d+(e[\+\-]?\d+)?/i)&&(n=!0),a.match(/^\d+\.\d*/)&&(n=!0),a.match(/^\.\d+/)&&(n=!0),n)return a.eat(/J/i),"number";var o=!1;if(a.match(/^0x[0-9a-f]+/i)&&(o=!0),a.match(/^0b[01]+/i)&&(o=!0),a.match(/^0o[0-7]+/i)&&(o=!0),a.match(/^[1-9]\d*(e[\+\-]?\d+)?/)&&(a.eat(/J/i),o=!0),a.match(/^0(?![\dx])/i)&&(o=!0),o)return a.eat(/L/i),"number"}return a.match(p)?(b.tokenize=u(a.current()),b.tokenize(a,b)):a.match(i)||a.match(h)?null:a.match(g)||a.match(e)||a.match(k)?"operator":a.match(f)?null:a.match(q)?"keyword":a.match(r)?"builtin":a.match(j)?"variable":(a.next(),c)}function u(a){function f(f,g){for(;!f.eol();)if(f.eatWhile(/[^'"\\]/),f.eat("\\")){if(f.next(),d&&f.eol())return e}else{if(f.match(a))return g.tokenize=t,e;f.eat(/['"]/)}if(d){if(b.singleLineStringErrors)return c;g.tokenize=t}return e}for(;"rub".indexOf(a.charAt(0).toLowerCase())>=0;)a=a.substr(1);var d=1==a.length,e="string";return f.isString=!0,f}function v(b,c,d){d=d||"py";var e=0;if("py"===d){if("py"!==c.scopes[0].type)return c.scopes[0].offset=b.indentation(),void 0;for(var f=0;c.scopes.length>f;++f)if("py"===c.scopes[f].type){e=c.scopes[f].offset+a.indentUnit;break}}else e=b.column()+b.current().length;c.scopes.unshift({offset:e,type:d})}function w(a,b,c){if(c=c||"py",1!=b.scopes.length){if("py"===b.scopes[0].type){for(var d=a.indentation(),e=-1,f=0;b.scopes.length>f;++f)if(d===b.scopes[f].offset){e=f;break}if(-1===e)return!0;for(;b.scopes[0].offset!==d;)b.scopes.shift();return!1}return"py"===c?(b.scopes[0].offset=a.indentation(),!1):b.scopes[0].type!=c?!0:(b.scopes.shift(),!1)}}function x(a,b){s=null;var d=b.tokenize(a,b),e=a.current();if("."===e)return d=a.match(j,!1)?null:c,null===d&&"meta"===b.lastToken&&(d="meta"),d;if("@"===e)return a.match(j,!1)?"meta":c;"variable"!==d&&"builtin"!==d||"meta"!==b.lastToken||(d="meta"),("pass"===e||"return"===e)&&(b.dedent+=1),"lambda"===e&&(b.lambda=!0),(":"===e&&!b.lambda&&"py"==b.scopes[0].type||"indent"===s)&&v(a,b);var f="[({".indexOf(e);return-1!==f&&v(a,b,"])}".slice(f,f+1)),"dedent"===s&&w(a,b)?c:(f="])}".indexOf(e),-1!==f&&w(a,b,e)?c:(b.dedent>0&&a.eol()&&"py"==b.scopes[0].type&&(b.scopes.length>1&&b.scopes.shift(),b.dedent-=1),d))}var c="error",e=RegExp("^[\\+\\-\\*/%&|\\^~<>!]"),f=RegExp("^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]"),g=RegExp("^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))"),h=RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))"),i=RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))"),j=RegExp("^[_A-Za-z][_A-Za-z0-9]*"),k=d(["and","or","not","is","in"]),l=["as","assert","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","lambda","pass","raise","return","try","while","with","yield"],m=["abs","all","any","bin","bool","bytearray","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip","__import__","NotImplemented","Ellipsis","__debug__"],n={builtins:["apply","basestring","buffer","cmp","coerce","execfile","file","intern","long","raw_input","reduce","reload","unichr","unicode","xrange","False","True","None"],keywords:["exec","print"]},o={builtins:["ascii","bytes","exec","print"],keywords:["nonlocal","False","True","None"]};if(b.version&&3===parseInt(b.version,10)){l=l.concat(o.keywords),m=m.concat(o.builtins);var p=RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))","i")}else{l=l.concat(n.keywords),m=m.concat(n.builtins);var p=RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))","i")}var q=d(l),r=d(m),s=null,y={startState:function(a){return{tokenize:t,scopes:[{offset:a||0,type:"py"}],lastToken:null,lambda:!1,dedent:0}},token:function(a,b){var c=x(a,b);return b.lastToken=c,a.eol()&&a.lambda&&(b.lambda=!1),c},indent:function(a){return a.tokenize!=t?a.tokenize.isString?CodeMirror.Pass:0:a.scopes[0].offset}};return y}),CodeMirror.defineMIME("text/x-python","python"),CodeMirror.defineMode("r",function(a){function b(a){for(var b=a.split(" "),c={},d=0;b.length>d;++d)c[b[d]]=!0;return c}function i(a,b){h=null;var i=a.next();if("#"==i)return a.skipToEnd(),"comment";if("0"==i&&a.eat("x"))return a.eatWhile(/[\da-f]/i),"number";if("."==i&&a.eat(/\d/))return a.match(/\d*(?:e[+\-]?\d+)?/),"number";if(/\d/.test(i))return a.match(/\d*(?:\.\d+)?(?:e[+\-]\d+)?L?/),"number";if("'"==i||'"'==i)return b.tokenize=j(i),"string";if("."==i&&a.match(/.[.\d]+/))return"keyword";if(/[\w\.]/.test(i)&&"_"!=i){a.eatWhile(/[\w\.]/);var k=a.current();return c.propertyIsEnumerable(k)?"atom":e.propertyIsEnumerable(k)?(f.propertyIsEnumerable(k)&&(h="block"),"keyword"):d.propertyIsEnumerable(k)?"builtin":"variable"}return"%"==i?(a.skipTo("%")&&a.next(),"variable-2"):"<"==i&&a.eat("-")?"arrow":"="==i&&b.ctx.argList?"arg-is":g.test(i)?"$"==i?"dollar":(a.eatWhile(g),"operator"):/[\(\){}\[\];]/.test(i)?(h=i,";"==i?"semi":null):null}function j(a){return function(b,c){if(b.eat("\\")){var d=b.next();return"x"==d?b.match(/^[a-f0-9]{2}/i):("u"==d||"U"==d)&&b.eat("{")&&b.skipTo("}")?b.next():"u"==d?b.match(/^[a-f0-9]{4}/i):"U"==d?b.match(/^[a-f0-9]{8}/i):/[0-7]/.test(d)&&b.match(/^[0-7]{1,2}/),"string-2"}for(var e;null!=(e=b.next());){if(e==a){c.tokenize=i;break}if("\\"==e){b.backUp(1);break}}return"string"}}function k(a,b,c){a.ctx={type:b,indent:a.indent,align:null,column:c.column(),prev:a.ctx}}function l(a){a.indent=a.ctx.indent,a.ctx=a.ctx.prev}var h,c=b("NULL NA Inf NaN NA_integer_ NA_real_ NA_complex_ NA_character_"),d=b("list quote bquote eval return call parse deparse"),e=b("if else repeat while function for in next break"),f=b("if else repeat while function for"),g=/[+\-*\/^<>=!&|~$:]/;return{startState:function(){return{tokenize:i,ctx:{type:"top",indent:-a.indentUnit,align:!1},indent:0,afterIdent:!1}},token:function(a,b){if(a.sol()&&(null==b.ctx.align&&(b.ctx.align=!1),b.indent=a.indentation()),a.eatSpace())return null;var c=b.tokenize(a,b);"comment"!=c&&null==b.ctx.align&&(b.ctx.align=!0);var d=b.ctx.type;return";"!=h&&"{"!=h&&"}"!=h||"block"!=d||l(b),"{"==h?k(b,"}",a):"("==h?(k(b,")",a),b.afterIdent&&(b.ctx.argList=!0)):"["==h?k(b,"]",a):"block"==h?k(b,"block",a):h==d&&l(b),b.afterIdent="variable"==c||"keyword"==c,c
|
4
|
-
},indent:function(b,c){if(b.tokenize!=i)return 0;var d=c&&c.charAt(0),e=b.ctx,f=d==e.type;return"block"==e.type?e.indent+("{"==d?0:a.indentUnit):e.align?e.column+(f?0:1):e.indent+(f?0:a.indentUnit)}}}),CodeMirror.defineMIME("text/x-rsrc","r"),CodeMirror.defineMode("ruby",function(a){function b(a){for(var b={},c=0,d=a.length;d>c;++c)b[a[c]]=!0;return b}function h(a,b,c){return c.tokenize.push(a),a(b,c)}function i(a,b){if(g=null,a.sol()&&a.match("=begin")&&a.eol())return b.tokenize.push(m),"comment";if(a.eatSpace())return null;var d,c=a.next();if("`"==c||"'"==c||'"'==c||"/"==c&&!a.eol()&&" "!=a.peek())return h(k(c,"string",'"'==c||"`"==c),a,b);if("%"==c){var e,i=!1;a.eat("s")?e="atom":a.eat(/[WQ]/)?(e="string",i=!0):a.eat(/[wxqr]/)&&(e="string");var j=a.eat(/[^\w\s]/);return j?(f.propertyIsEnumerable(j)&&(j=f[j]),h(k(j,e,i,!0),a,b)):"operator"}if("#"==c)return a.skipToEnd(),"comment";if("<"==c&&(d=a.match(/^<-?[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/)))return h(l(d[1]),a,b);if("0"==c)return a.eat("x")?a.eatWhile(/[\da-fA-F]/):a.eat("b")?a.eatWhile(/[01]/):a.eatWhile(/[0-7]/),"number";if(/\d/.test(c))return a.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+\-]?[\d_]+)?/),"number";if("?"==c){for(;a.match(/^\\[CM]-/););return a.eat("\\")?a.eatWhile(/\w/):a.next(),"string"}return":"==c?a.eat("'")?h(k("'","atom",!1),a,b):a.eat('"')?h(k('"',"atom",!0),a,b):(a.eatWhile(/[\w\?]/),"atom"):"@"==c?(a.eat("@"),a.eatWhile(/[\w\?]/),"variable-2"):"$"==c?(a.next(),a.eatWhile(/[\w\?]/),"variable-3"):/\w/.test(c)?(a.eatWhile(/[\w\?]/),a.eat(":")?"atom":"ident"):"|"!=c||!b.varList&&"{"!=b.lastTok&&"do"!=b.lastTok?/[\(\)\[\]{}\\;]/.test(c)?(g=c,null):"-"==c&&a.eat(">")?"arrow":/[=+\-\/*:\.^%<>~|]/.test(c)?(a.eatWhile(/[=+\-\/*:\.^%<>~|]/),"operator"):null:(g="|",null)}function j(){var a=1;return function(b,c){if("}"==b.peek()){if(a--,0==a)return c.tokenize.pop(),c.tokenize[c.tokenize.length-1](b,c)}else"{"==b.peek()&&a++;return i(b,c)}}function k(a,b,c,d){return function(e,f){for(var h,g=!1;null!=(h=e.next());){if(h==a&&(d||!g)){f.tokenize.pop();break}if(c&&"#"==h&&!g&&e.eat("{")){f.tokenize.push(j(arguments.callee));break}g=!g&&"\\"==h}return b}}function l(a){return function(b,c){return b.match(a)?c.tokenize.pop():b.skipToEnd(),"string"}}function m(a,b){return a.sol()&&a.match("=end")&&a.eol()&&b.tokenize.pop(),a.skipToEnd(),"comment"}var g,c=b(["alias","and","BEGIN","begin","break","case","class","def","defined?","do","else","elsif","END","end","ensure","false","for","if","in","module","next","not","or","redo","rescue","retry","return","self","super","then","true","undef","unless","until","when","while","yield","nil","raise","throw","catch","fail","loop","callcc","caller","lambda","proc","public","protected","private","require","load","require_relative","extend","autoload"]),d=b(["def","class","case","for","while","do","module","then","catch","loop","proc","begin"]),e=b(["end","until"]),f={"[":"]","{":"}","(":")"};return{startState:function(){return{tokenize:[i],indented:0,context:{type:"top",indented:-a.indentUnit},continuedLine:!1,lastTok:null,varList:!1}},token:function(a,b){a.sol()&&(b.indented=a.indentation());var h,f=b.tokenize[b.tokenize.length-1](a,b);if("ident"==f){var i=a.current();f=c.propertyIsEnumerable(a.current())?"keyword":/^[A-Z]/.test(i)?"tag":"def"==b.lastTok||"class"==b.lastTok||b.varList?"def":"variable",d.propertyIsEnumerable(i)?h="indent":e.propertyIsEnumerable(i)?h="dedent":"if"!=i&&"unless"!=i||a.column()!=a.indentation()||(h="indent")}return(g||f&&"comment"!=f)&&(b.lastTok=i||g||f),"|"==g&&(b.varList=!b.varList),"indent"==h||/[\(\[\{]/.test(g)?b.context={prev:b.context,type:g||f,indented:b.indented}:("dedent"==h||/[\)\]\}]/.test(g))&&b.context.prev&&(b.context=b.context.prev),a.eol()&&(b.continuedLine="\\"==g||"operator"==f),f},indent:function(b,c){if(b.tokenize[b.tokenize.length-1]!=i)return 0;var d=c&&c.charAt(0),e=b.context,g=e.type==f[d]||"keyword"==e.type&&/^(?:end|until|else|elsif|when|rescue)\b/.test(c);return e.indented+(g?0:a.indentUnit)+(b.continuedLine?a.indentUnit:0)},electricChars:"}de"}}),CodeMirror.defineMIME("text/x-ruby","ruby"),CodeMirror.defineMode("xml",function(a,b){function h(a,b){function c(c){return b.tokenize=c,c(a,b)}var d=a.next();if("<"==d){if(a.eat("!"))return a.eat("[")?a.match("CDATA[")?c(k("atom","]]>")):null:a.match("--")?c(k("comment","-->")):a.match("DOCTYPE",!0,!0)?(a.eatWhile(/[\w\._\-]/),c(l(1))):null;if(a.eat("?"))return a.eatWhile(/[\w\._\-]/),b.tokenize=k("meta","?>"),"meta";var e=a.eat("/");f="";for(var h;h=a.eat(/[^\s\u00a0=<>\"\'\/?]/);)f+=h;return f?(g=e?"closeTag":"openTag",b.tokenize=i,"tag"):"error"}if("&"==d){var j;return j=a.eat("#")?a.eat("x")?a.eatWhile(/[a-fA-F\d]/)&&a.eat(";"):a.eatWhile(/[\d]/)&&a.eat(";"):a.eatWhile(/[\w\.\-:]/)&&a.eat(";"),j?"atom":"error"}return a.eatWhile(/[^&<]/),null}function i(a,b){var c=a.next();return">"==c||"/"==c&&a.eat(">")?(b.tokenize=h,g=">"==c?"endTag":"selfcloseTag","tag"):"="==c?(g="equals",null):/[\'\"]/.test(c)?(b.tokenize=j(c),b.tokenize(a,b)):(a.eatWhile(/[^\s\u00a0=<>\"\']/),"word")}function j(a){return function(b,c){for(;!b.eol();)if(b.next()==a){c.tokenize=i;break}return"string"}}function k(a,b){return function(c,d){for(;!c.eol();){if(c.match(b)){d.tokenize=h;break}c.next()}return a}}function l(a){return function(b,c){for(var d;null!=(d=b.next());){if("<"==d)return c.tokenize=l(a+1),c.tokenize(b,c);if(">"==d){if(1==a){c.tokenize=h;break}return c.tokenize=l(a-1),c.tokenize(b,c)}}return"meta"}}function o(){for(var a=arguments.length-1;a>=0;a--)m.cc.push(arguments[a])}function p(){return o.apply(null,arguments),!0}function q(a,b){var c=d.doNotIndent.hasOwnProperty(a)||m.context&&m.context.noIndent;m.context={prev:m.context,tagName:a,indent:m.indented,startOfLine:b,noIndent:c}}function r(){m.context&&(m.context=m.context.prev)}function s(a){if("openTag"==a)return m.tagName=f,p(w,t(m.startOfLine));if("closeTag"==a){var b=!1;return m.context?m.context.tagName!=f&&(d.implicitlyClosed.hasOwnProperty(m.context.tagName.toLowerCase())&&r(),b=!m.context||m.context.tagName!=f):b=!0,b&&(n="error"),p(u(b))}return p()}function t(a){return function(b){var c=m.tagName;return m.tagName=null,"selfcloseTag"==b||"endTag"==b&&d.autoSelfClosers.hasOwnProperty(c.toLowerCase())?(v(c.toLowerCase()),p()):"endTag"==b?(v(c.toLowerCase()),q(c,a),p()):p()}}function u(a){return function(b){return a&&(n="error"),"endTag"==b?(r(),p()):(n="error",p(arguments.callee))}}function v(a){for(var b;;){if(!m.context)return;if(b=m.context.tagName.toLowerCase(),!d.contextGrabbers.hasOwnProperty(b)||!d.contextGrabbers[b].hasOwnProperty(a))return;r()}}function w(a){return"word"==a?(n="attribute",p(x,w)):"endTag"==a||"selfcloseTag"==a?o():(n="error",p(w))}function x(a){return"equals"==a?p(y,w):(d.allowMissing?"word"==a&&(n="attribute"):n="error","endTag"==a||"selfcloseTag"==a?o():p())}function y(a){return"string"==a?p(z):"word"==a&&d.allowUnquoted?(n="string",p()):(n="error","endTag"==a||"selfCloseTag"==a?o():p())}function z(a){return"string"==a?p(z):o()}var f,g,m,n,c=a.indentUnit,d=b.htmlMode?{autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0}:{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1},e=b.alignCDATA;return{startState:function(){return{tokenize:h,cc:[],indented:0,startOfLine:!0,tagName:null,context:null}},token:function(a,b){if(a.sol()&&(b.startOfLine=!0,b.indented=a.indentation()),a.eatSpace())return null;n=g=f=null;var c=b.tokenize(a,b);if(b.type=g,(c||g)&&"comment"!=c)for(m=b;;){var d=b.cc.pop()||s;if(d(g||c))break}return b.startOfLine=!1,n||c},indent:function(a,b,d){var f=a.context;if(a.tokenize!=i&&a.tokenize!=h||f&&f.noIndent)return d?d.match(/^(\s*)/)[0].length:0;if(e&&/<!\[CDATA\[/.test(b))return 0;for(f&&/^<\//.test(b)&&(f=f.prev);f&&!f.startOfLine;)f=f.prev;return f?f.indent+c:0},electricChars:"/",configuration:b.htmlMode?"html":"xml"}}),CodeMirror.defineMIME("text/xml","xml"),CodeMirror.defineMIME("application/xml","xml"),CodeMirror.mimeModes.hasOwnProperty("text/html")||CodeMirror.defineMIME("text/html",{name:"xml",htmlMode:!0}),function(){function b(b){a.push(b),a.length>50&&a.shift()}function c(){return a[a.length-1]||""}function d(){return a.length>1&&a.pop(),c()}var a=[];CodeMirror.keyMap.emacs={"Ctrl-X":function(a){a.setOption("keyMap","emacs-Ctrl-X")},"Ctrl-W":function(a){b(a.getSelection()),a.replaceSelection("")},"Ctrl-Alt-W":function(a){b(a.getSelection()),a.replaceSelection("")},"Alt-W":function(a){b(a.getSelection())},"Ctrl-Y":function(a){a.replaceSelection(c())},"Alt-Y":function(a){a.replaceSelection(d())},"Ctrl-/":"undo","Shift-Ctrl--":"undo","Shift-Alt-,":"goDocStart","Shift-Alt-.":"goDocEnd","Ctrl-S":"findNext","Ctrl-R":"findPrev","Ctrl-G":"clearSearch","Shift-Alt-5":"replace","Ctrl-Z":"undo","Cmd-Z":"undo","Alt-/":"autocomplete","Alt-V":"goPageUp","Ctrl-J":"newlineAndIndent",Enter:!1,Tab:"indentAuto",fallthrough:["basic","emacsy"]},CodeMirror.keyMap["emacs-Ctrl-X"]={"Ctrl-S":"save","Ctrl-W":"save",S:"saveAll",F:"open",U:"undo",K:"close",auto:"emacs",nofallthrough:!0}}(),function(){"use strict";var a=[{keys:["Left"],type:"keyToKey",toKeys:["h"]},{keys:["Right"],type:"keyToKey",toKeys:["l"]},{keys:["Up"],type:"keyToKey",toKeys:["k"]},{keys:["Down"],type:"keyToKey",toKeys:["j"]},{keys:["Space"],type:"keyToKey",toKeys:["l"]},{keys:["Backspace"],type:"keyToKey",toKeys:["h"]},{keys:["Ctrl-Space"],type:"keyToKey",toKeys:["W"]},{keys:["Ctrl-Backspace"],type:"keyToKey",toKeys:["B"]},{keys:["Shift-Space"],type:"keyToKey",toKeys:["w"]},{keys:["Shift-Backspace"],type:"keyToKey",toKeys:["b"]},{keys:["Ctrl-n"],type:"keyToKey",toKeys:["j"]},{keys:["Ctrl-p"],type:"keyToKey",toKeys:["k"]},{keys:["Ctrl-["],type:"keyToKey",toKeys:["Esc"]},{keys:["Ctrl-c"],type:"keyToKey",toKeys:["Esc"]},{keys:["s"],type:"keyToKey",toKeys:["c","l"]},{keys:["S"],type:"keyToKey",toKeys:["c","c"]},{keys:["Home"],type:"keyToKey",toKeys:["0"]},{keys:["End"],type:"keyToKey",toKeys:["$"]},{keys:["PageUp"],type:"keyToKey",toKeys:["Ctrl-b"]},{keys:["PageDown"],type:"keyToKey",toKeys:["Ctrl-f"]},{keys:["h"],type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:["l"],type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:["j"],type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:["k"],type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:["w"],type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:["W"],type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:["e"],type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:["E"],type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:["b"],type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:["B"],type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:["g","e"],type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:["g","E"],type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:["Ctrl-f"],type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:["Ctrl-b"],type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:["g","g"],type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0}},{keys:["G"],type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0}},{keys:["0"],type:"motion",motion:"moveToStartOfLine"},{keys:["^"],type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:["$"],type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:["%"],type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0}},{keys:["f","character"],type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:["F","character"],type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:["t","character"],type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:["T","character"],type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:["'","character"],type:"motion",motion:"goToMark"},{keys:["`","character"],type:"motion",motion:"goToMark"},{keys:["|"],type:"motion",motion:"moveToColumn",motionArgs:{}},{keys:["d"],type:"operator",operator:"delete"},{keys:["y"],type:"operator",operator:"yank"},{keys:["c"],type:"operator",operator:"change",operatorArgs:{enterInsertMode:!0}},{keys:[">"],type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:["<"],type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:["g","~"],type:"operator",operator:"swapcase"},{keys:["n"],type:"motion",motion:"findNext"},{keys:["N"],type:"motion",motion:"findPrev"},{keys:["x"],type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:["X"],type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:["D"],type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},operatorMotionArgs:{visualLine:!0}},{keys:["Y"],type:"operatorMotion",operator:"yank",motion:"moveToEol",motionArgs:{inclusive:!0},operatorMotionArgs:{visualLine:!0}},{keys:["C"],type:"operatorMotion",operator:"change",operatorArgs:{enterInsertMode:!0},motion:"moveToEol",motionArgs:{inclusive:!0},operatorMotionArgs:{visualLine:!0}},{keys:["~"],type:"operatorMotion",operator:"swapcase",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:["a"],type:"action",action:"enterInsertMode",actionArgs:{insertAt:"charAfter"}},{keys:["A"],type:"action",action:"enterInsertMode",actionArgs:{insertAt:"eol"}},{keys:["i"],type:"action",action:"enterInsertMode"},{keys:["I"],type:"action",action:"enterInsertMode",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:["o"],type:"action",action:"newLineAndEnterInsertMode",actionArgs:{after:!0}},{keys:["O"],type:"action",action:"newLineAndEnterInsertMode",actionArgs:{after:!1}},{keys:["v"],type:"action",action:"toggleVisualMode"},{keys:["V"],type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:["J"],type:"action",action:"joinLines"},{keys:["p"],type:"action",action:"paste",actionArgs:{after:!0}},{keys:["P"],type:"action",action:"paste",actionArgs:{after:!1}},{keys:["r","character"],type:"action",action:"replace"},{keys:["u"],type:"action",action:"undo"},{keys:["Ctrl-r"],type:"action",action:"redo"},{keys:["m","character"],type:"action",action:"setMark"},{keys:['"',"character"],type:"action",action:"setRegister"},{keys:[",","/"],type:"action",action:"clearSearchHighlight"},{keys:["a","character"],type:"motion",motion:"textObjectManipulation"},{keys:["i","character"],type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:["/"],type:"search",searchArgs:{forward:!0,querySrc:"prompt"}},{keys:["?"],type:"search",searchArgs:{forward:!1,querySrc:"prompt"}},{keys:["*"],type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor"}},{keys:["#"],type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor"}},{keys:[":"],type:"ex"}],b=function(){function h(a,b){for(var c=[],d=a;a+b>d;d++)c.push(String.fromCharCode(d));return c}function r(a,b){return b>=0&&a.lineCount()>b}function t(a){return-1!="()[]{}".indexOf(a)}function u(a){return d.test(a)}function v(a){return/^[A-Z]$/.test(a)}function y(a){return/^\s*$/.test(a)}function z(a,b,c){return a>=b&&c>=a}function A(a,b){for(var c=0;b.length>c;c++)if(b[c]==a)return!0;return!1}function C(){return B||(B={searchQuery:null,searchIsReversed:!1,registerController:new H({})}),B}function D(a){return a.vimState||(a.vimState={inputState:new F,lastHPos:-1,lastMotion:null,marks:{},visualMode:!1,visualLine:!1}),a.vimState}function F(){this.reset()}function G(a,b){this.clear(),a&&this.set(a,b)}function H(a){this.registers=a,this.unamedRegister=a['"']=new G}function N(a,b,c){var d=Math.min(Math.max(0,b.line),a.lineCount()-1),e=Y(a,d)-1;e=c?e+1:e;var f=Math.min(Math.max(0,b.ch),e);return{line:d,ch:f}}function P(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function Q(a,b,c){return{line:a.line+b,ch:a.ch+c}}function S(a,b){for(var c=0;a.length>c;c++)if(a[c]!=b[c]&&"character"!=b[c])return!1;return!0}function U(a,b,c){return function(){for(var d=0;c>d;d++)b(a)}}function V(a){return{line:a.line,ch:a.ch}}function W(a,b){return a.ch==b.ch&&a.line==b.line}function X(a,b){return a.line<b.line?!0:a.line==b.line&&a.ch<b.ch?!0:!1}function Y(a,b){return a.getLine(b).length}function Z(a){return a.split("").reverse().join("")}function $(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function _(a){return a.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1")}function ab(a,b){b.visualMode=!1,b.visualLine=!1;var c=a.getCursor("anchor"),d=a.getCursor("head");W(c,d)||a.setCursor(N(a,d))}function bb(a,b,c){var d=a.getRange(b,c),e=d.split("\n");e.length>1&&y(e.pop())&&(c.line--,c.ch=Y(a,c.line))}function cb(a,b,c){b.ch=0,c.ch=0,c.line++}function db(a){if(!a)return 0;var b=a.search(/\S/);return-1==b?a.length:b}function eb(a,b,c,d,e){var j,f=a.getCursor(),g=a.getLine(f.line),h=f.ch,i=g.substring(h);if(j=e?i.search(/\w/):i.search(/\S/),-1==j)return null;h+=j,i=g.substring(h);var l,k=g.substring(0,h);l=d?/^\S+/:/\w/.test(g.charAt(h))?/^\w+/:/^[^\w\s]+/;var m=l.exec(i),n=h,o=h+m[0].length-1,p=l.exec(Z(k));return p&&(n-=p[0].length),b&&o++,{start:{line:f.line,ch:n},end:{line:f.line,ch:o}}}function fb(a,b,c,d){for(var e=b.line,h=b.ch,i=a.getLine(e),j=c?1:-1,k=d?g:f;;){for(var l=j>0?i.length:-1,m=l,n=l;h!=l;){for(var o=!1,p=0;k.length>p&&!o;++p)if(k[p].test(i.charAt(h))){for(m=h;h!=l&&k[p].test(i.charAt(h));)h+=j;if(n=h,o=m!=n,m==b.ch&&e==b.line&&n==m+j)continue;return{from:Math.min(m,n+1),to:Math.max(m,n),line:e}}o||(h+=j)}if(e+=j,!r(a,e))return null;i=a.getLine(e),h=j>0?0:i.length}throw"The impossible happened."}function gb(a,b,c,d,e){for(var f=a.getCursor(),g=0;b>g;g++)for(var j,i=(f.ch,f.line),k=!1;!k;){if(j=fb(a,f,c,e),k=!0,!j)return c?{line:f.line,ch:Y(a,f.line)}:{line:f.line,ch:0};f.line=j.line,c&&d?f.ch=j.to-1:c&&!d?z(f.ch,j.from,j.to)&&j.line==i?(k=!1,f.ch=j.to-1):f.ch=j.from:!c&&d?z(f.ch,j.from,j.to)&&j.line==i?(k=!1,f.ch=j.from):f.ch=j.to:c||d||(f.ch=j.from)}return f}function hb(a,b,c,d){for(var g,e=a.getCursor(),f=e.ch,h=0;b>h;h++){var i=a.getLine(e.line);if(g=jb(f,i,d,c,!0),-1==g)return e;f=g}return{line:a.getCursor().line,ch:g}}function ib(a,b){var c=a.getCursor().line;return N(a,{line:c,ch:b-1})}function jb(a,b,c,d,e){var f;return d?(f=b.indexOf(c,a+1),-1==f||e||(f-=1)):(f=b.lastIndexOf(c,a-1),-1==f||e||(f+=1)),f}function kb(a,b,c){var d=b.line;c=c?c:a.getLine(d).charAt(b.ch),A(c,["(","[","{"]);var f={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{"}[c];if(!f)return b;for(var g={"(":1,"{":1,"[":1}[c]||-1,h=1,i=c,j=b.ch,k=a.getLine(d);i&&h>0;)j+=g,i=k.charAt(j),i||(d+=g,j=0,k=a.getLine(d)||"",i=k.charAt(j)),i===c?h++:i===f&&h--;return i?{line:d,ch:j}:b}function lb(a,b,c){var d=a.getCursor(),e=kb(a,d,b),f=kb(a,e);return f.ch+=c?1:0,e.ch+=c?0:1,{start:f,end:e}}function nb(a,b,c){var g,h,i,j,d=a.getCursor(),e=a.getLine(d.line),f=e.split(""),k=f.indexOf(b);if(k>d.ch?d.ch=k:d.ch>k&&f[d.ch]==b&&(h=d.ch,--d.ch),f[d.ch]!=b||h)for(i=d.ch;i>-1&&!g;i--)f[i]==b&&(g=i+1);else g=d.ch+1;if(g&&!h)for(i=g,j=f.length;j>i&&!h;i++)f[i]==b&&(h=i);return g&&h?(c&&(--g,++h),{start:{line:d.line,ch:g},end:{line:d.line,ch:h}}):{start:d,end:d}}function ob(){this.marked=null}function pb(a){var b=D(a);return b.searchState_||(b.searchState_=new ob)}function qb(a,b,c,d){a.openDialog?a.openDialog(b,d,{bottom:!0}):d(prompt(c,""))}function rb(a){for(var b=!1,c=[],d=0;a.length>d;d++){var e=a.charAt(d);b||"/"!=e||c.push(d),b="\\"==e}return c}function sb(a,b,c,d){var f,g,e=rb(b);if(e.length){f=b.substring(0,e[0]);var h=b.substring(e[0]);g=-1!=h.indexOf("i")}else f=b;if(!f)return null;d&&(c=/^[^A-Z]*$/.test(f));try{var i=RegExp(f,c||g?"i":void 0);return i}catch(j){tb(a,"Invalid regex: "+f)}}function tb(a,b){a.openConfirm?a.openConfirm('<span style="color: red">'+b+'</span> <button type="button">OK</button>',function(){},{bottom:!0}):alert(b)}function ub(a,b){var c="";return a&&(c+='<span style="font-family: monospace">'+a+"</span>"),c+='<input type="text"/> <span style="color: #888">',b&&(c+='<span style="color: #888">',c+=b,c+="</span>"),c}function wb(a,b,c,d){var e=(c||"")+" "+(d||"");qb(a,ub(c,d),e,b)}function xb(a,b){if(a instanceof RegExp&&b instanceof RegExp){for(var c=["global","multiline","ignoreCase","source"],d=0;c.length>d;d++){var e=c[d];if(a[e]!==b[e])return!1}return!0}return!1}function yb(a,b,c,d){a.operation(function(){var e=pb(a);if(b){var f=sb(a,b,!!c,!!d);f&&(xb(f,e.getQuery())||(Bb(a),zb(a,f),e.setQuery(f)))}})}function zb(a,b){if(2e3>a.lineCount()){for(var c=[],d=a.getSearchCursor(b);d.findNext();)c.push(a.markText(d.from(),d.to(),{className:"CodeMirror-searching"}));pb(a).setMarked(c)}}function Ab(a,b,c){return a.operation(function(){var d=pb(a),e=d.getQuery();if(e){d.getMarked()||zb(a,e);var f=a.getCursor();b=d.isReversed()?!b:b,b||(f.ch+=1);for(var g=a.getSearchCursor(e,f),h=0;c>h;h++)if(!g.find(b)&&(g=a.getSearchCursor(e,b?{line:a.lineCount()-1}:{line:0,ch:0}),!g.find(b)))return;return g.from()}})}function Bb(a){a.operation(function(){var b=pb(a);if(b.getQuery()){var c=b.getMarked();if(c){for(var d=0;c.length>d;++d)c[d].clear();b.setMarked(null)}}})}function Eb(a){for(var b=0,c=[];a.length>b;)if("<"==a.charAt(b)){for(var d=++b;">"!=a.charAt(b++););var e=a.substring(d,b-1),f=/^C-(.+)$/.exec(e);if(f){var g;switch(f[1]){case"BS":g="Backspace";break;case"CR":g="Enter";break;case"Del":g="Delete";break;default:g=f[1]}c.push("Ctrl-"+g)}}else c.push(a.charAt(b)),b++;return c}function Hb(){function a(a,b,d){v(b)&&("Shift"==d?d=null:b=b.toLowerCase()),d&&(b=d+"-"+b),c.handleKey(a,b)}function b(b,c){return function(d){a(d,b,c)}}function f(a,c){for(var d=0;a.length>d;d++){var f=a[d];!c&&A(f,m)&&(f="'"+f+"'"),c?e[c+"-"+f]=b(a[d],c):e[f]=b(a[d])}}var e={nofallthrough:!0,style:"fat-cursor"};return f(i),f(i,"Shift"),f(i,"Ctrl"),f(m),f(m,"Ctrl"),f(k),f(k,"Ctrl"),f(n),f(n,"Ctrl"),e}function Ib(a){a.setCursor(a.getCursor().line,a.getCursor().ch-1,!0),a.setOption("keyMap","vim")}var B,d=/[\d]/,f=[/\w/,/[^\w\s]/],g=[/\S/],i=h(65,26),j=h(97,26),k=h(48,10),l="~`!@#$%^&*()_-+=[{}]\\|/?.,<>:;\"'",m=l.split(""),n=["Left","Right","Up","Down","Space","Backspace","Esc","Home","End","PageUp","PageDown"],o=i.concat(j).concat(k),p=i.concat(j).concat(k).concat('-"'.split("")),E={buildKeyMap:function(){},getRegisterController:function(){return C().registerController},clearVimGlobalState_:function(){B=null},map:function(a,b){Gb.map(a,b)},maybeInitState:function(a){D(a)},handleKey:function(b,c){var d,e=D(b);if("Esc"==c)return e.inputState.reset(),e.visualMode&&ab(b,e),void 0;if(e.visualMode&&W(b.getCursor("head"),b.getCursor("anchor"))&&ab(b,e),e.visualMode||W(b.getCursor("head"),b.getCursor("anchor"))||(e.visualMode=!0,e.visualLine=!1),("0"!=c||"0"==c&&0===e.inputState.getRepeat())&&(d=I.matchCommand(c,a,e)),!d)return u(c)&&e.inputState.pushRepeatDigit(c),void 0;if("keyToKey"==d.type)for(var f=0;d.toKeys.length>f;f++)this.handleKey(b,d.toKeys[f]);else I.processCommand(b,e,d)}};F.prototype.reset=function(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=null},F.prototype.pushRepeatDigit=function(a){this.operator?this.motionRepeat=this.motionRepeat.concat(a):this.prefixRepeat=this.prefixRepeat.concat(a)},F.prototype.getRepeat=function(){var a=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(a=1,this.prefixRepeat.length>0&&(a*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(a*=parseInt(this.motionRepeat.join(""),10))),a},G.prototype={set:function(a,b){this.text=a,this.linewise=!!b},append:function(a,b){b||this.linewise?(this.text+="\n"+a,this.linewise=!0):this.text+=a},clear:function(){this.text="",this.linewise=!1},toString:function(){return this.text}},H.prototype={pushText:function(a,b,c,d){var e=this.isValidRegister(a)?this.getRegister(a):null;if(!e){switch(b){case"yank":this.registers["0"]=new G(c,d);break;case"delete":case"change":-1==c.indexOf("\n")?this.registers["-"]=new G(c,d):(this.shiftNumericRegisters_(),this.registers["1"]=new G(c,d))}return this.unamedRegister.set(c,d),void 0}var f=v(a);f?(e.append(c,d),this.unamedRegister.append(c,d)):(e.set(c,d),this.unamedRegister.set(c,d))},getRegister:function(a){return this.isValidRegister(a)?(a=a.toLowerCase(),this.registers[a]||(this.registers[a]=new G),this.registers[a]):this.unamedRegister},isValidRegister:function(a){return a&&A(a,p)},shiftNumericRegisters_:function(){for(var a=9;a>=2;a--)this.registers[a]=this.getRegister(""+(a-1))}};var I={matchCommand:function(a,b,c){for(var d=c.inputState,e=d.keyBuffer.concat(a),f=0;b.length>f;f++){var g=b[f];if(S(e,g.keys)){if(e.length<g.keys.length)return d.keyBuffer.push(a),null;if(d.operator&&"action"==g.type)continue;return"character"==g.keys[e.length-1]&&(d.selectedCharacter=e[e.length-1]),d.keyBuffer=[],g}}return d.keyBuffer=[],null},processCommand:function(a,b,c){switch(c.type){case"motion":this.processMotion(a,b,c);break;case"operator":this.processOperator(a,b,c);break;case"operatorMotion":this.processOperatorMotion(a,b,c);break;case"action":this.processAction(a,b,c);break;case"search":this.processSearch(a,b,c);break;case"ex":case"keyToEx":this.processEx(a,b,c);break;default:}},processMotion:function(a,b,c){b.inputState.motion=c.motion,b.inputState.motionArgs=P(c.motionArgs),this.evalInput(a,b)},processOperator:function(a,b,c){var d=b.inputState;if(d.operator){if(d.operator==c.operator)return d.motion="expandToLine",d.motionArgs={linewise:!0},this.evalInput(a,b),void 0;d.reset()}d.operator=c.operator,d.operatorArgs=P(c.operatorArgs),b.visualMode&&this.evalInput(a,b)},processOperatorMotion:function(a,b,c){var d=b.visualMode,e=P(c.operatorMotionArgs);e&&d&&e.visualLine&&(b.visualLine=!0),this.processOperator(a,b,c),d||this.processMotion(a,b,c)},processAction:function(a,b,c){var d=b.inputState,e=d.getRepeat(),f=!!e,g=P(c.actionArgs)||{};d.selectedCharacter&&(g.selectedCharacter=d.selectedCharacter),c.operator&&this.processOperator(a,b,c),c.motion&&this.processMotion(a,b,c),(c.motion||c.operator)&&this.evalInput(a,b),g.repeat=e||1,g.repeatIsExplicit=f,g.registerName=d.registerName,d.reset(),b.lastMotion=null,L[c.action](a,g,b)},processSearch:function(a,b,c){function f(c,d,e){yb(a,c,d,e),I.processMotion(a,b,{type:"motion",motion:"findNext"})}function g(a){f(a,!0,!0)}if(a.getSearchCursor){var d=c.searchArgs.forward;pb(a).setReversed(!d);var e=d?"/":"?";switch(c.searchArgs.querySrc){case"prompt":wb(a,g,e,vb);break;case"wordUnderCursor":var h=eb(a,!1,!0,!1,!0),i=!0;if(h||(h=eb(a,!1,!0,!1,!1),i=!1),!h)return;var j=a.getLine(h.start.line).substring(h.start.ch,h.end.ch+1);j=i?"\\b"+j+"\\b":_(j),a.setCursor(h.start),f(j,!0,!1)}}},processEx:function(a,b,c){function d(b){Gb.processCommand(a,b)}"keyToEx"==c.type?Gb.processCommand(a,c.exArgs.input):wb(a,d,":")},evalInput:function(a,b){var m,n,c=b.inputState,d=c.motion,e=c.motionArgs||{},f=c.operator,g=c.operatorArgs||{},h=c.registerName,i=a.getCursor("head"),j=a.getCursor("anchor"),k=V(i),l=V(k);if(n=void 0!==e.repeat?c.motionArgs.repeat:c.getRepeat(),n>0&&e.explicitRepeat?e.repeatIsExplicit=!0:(e.noRepeat||!e.explicitRepeat&&0===n)&&(n=1,e.repeatIsExplicit=!1),c.selectedCharacter&&(e.selectedCharacter=g.selectedCharacter=c.selectedCharacter),e.repeat=n,c.reset(),d){var o=J[d](a,e,b);if(b.lastMotion=J[d],!o)return;o instanceof Array?(k=o[0],m=o[1]):m=o,m||(m={ch:k.ch,line:k.line}),b.visualMode?(X(j,i)&&(W(j,m)||X(m,j))?j.ch+=1:X(i,j)&&(W(j,m)||X(j,m))&&(j.ch-=1),i=m,b.visualLine&&(X(j,i)?(j.ch=0,i.ch=Y(a,i.line)):(i.ch=0,j.ch=Y(a,j.line))),a.setCursor(j),a.setSelection(j,i)):f||(m=N(a,m),a.setCursor(m.line,m.ch))}if(f){var p=!1;if(b.lastMotion=null,g.repeat=n,b.visualMode&&(k=j,m=i,e.inclusive=!0),X(m,k)){var q=k;k=m,m=q,p=!0}!e.inclusive||b.visualMode&&p||m.ch++;var r=e.linewise||b.visualMode&&b.visualLine;r?cb(a,k,m):e.forward&&bb(a,k,m),g.registerName=h,g.linewise=r,K[f](a,g,b,k,m,l),b.visualMode&&ab(a,b),g.enterInsertMode&&L.enterInsertMode(a)}}},J={expandToLine:function(a,b){var c=a.getCursor();return{line:c.line+b.repeat-1,ch:1/0}},findNext:function(a,b){return Ab(a,!1,b.repeat)},findPrev:function(a,b){return Ab(a,!0,b.repeat)},goToMark:function(a,b,c){var d=c.marks[b.selectedCharacter];return d?d.find():null},moveByCharacters:function(a,b){var c=a.getCursor(),d=b.repeat,e=b.forward?c.ch+d:c.ch-d;return{line:c.line,ch:e}},moveByLines:function(a,b,c){var d=a.getCursor().ch;switch(c.lastMotion){case this.moveByLines:case this.moveToColumn:case this.moveToEol:d=c.lastHPos;break;default:c.lastHPos=d}var e=a.getCursor(),f=b.repeat,g=b.forward?e.line+f:e.line-f;return 0>g||g>a.lineCount()-1?null:{line:g,ch:d}},moveByPage:function(a,b){var c=a.getCursor(),d=b.repeat;a.moveV(b.forward?d:-d,"page");var e=a.getCursor();return a.setCursor(c),e},moveByWords:function(a,b){return gb(a,b.repeat,!!b.forward,!!b.wordEnd,!!b.bigWord)},moveTillCharacter:function(a,b){var c=b.repeat,d=hb(a,c,b.forward,b.selectedCharacter),e=b.forward?-1:1;return d.ch+=e,d},moveToCharacter:function(a,b){var c=b.repeat;return hb(a,c,b.forward,b.selectedCharacter)},moveToColumn:function(a,b,c){var d=b.repeat;return c.lastHPos=d-1,ib(a,d)},moveToEol:function(a,b,c){var d=a.getCursor();return c.lastHPos=1/0,{line:d.line+b.repeat-1,ch:1/0}},moveToFirstNonWhiteSpaceCharacter:function(a){var b=a.getCursor();return a.getLine(b.line),{line:b.line,ch:db(a.getLine(b.line))}},moveToMatchedSymbol:function(a,b){var c=a.getCursor(),d=a.getLine(c.line).charAt(c.ch);return t(d)?kb(a,a.getCursor(),b.symbol):c},moveToStartOfLine:function(a){var b=a.getCursor();return{line:b.line,ch:0}},moveToLineOrEdgeOfDocument:function(a,b){var c=b.forward?a.lineCount()-1:0;return b.repeatIsExplicit&&(c=b.repeat-1),{line:c,ch:db(a.getLine(c))}},textObjectManipulation:function(a,b){var c=b.selectedCharacter,d=!b.textObjectInner;if(!M[c])return null;var e=M[c](a,d),f=e.start,g=e.end;return[f,g]}},K={change:function(a,b,c,d,e){C().registerController.pushText(b.registerName,"change",a.getRange(d,e),b.linewise),b.linewise?(d.ch=db(a.getLine(d.line)),a.replaceRange("\n",d,e)):a.replaceRange("",d,e),a.setCursor(d)},"delete":function(a,b,c,d,e){C().registerController.pushText(b.registerName,"delete",a.getRange(d,e),b.linewise),a.replaceRange("",d,e),b.linewise?a.setCursor(J.moveToFirstNonWhiteSpaceCharacter(a)):a.setCursor(d)},indent:function(a,b,c,d,e){var f=d.line,g=e.line,h=c.visualMode?b.repeat:1;b.linewise&&g--;for(var i=f;g>=i;i++)for(var j=0;h>j;j++)a.indentLine(i,b.indentRight);a.setCursor(d),a.setCursor(J.moveToFirstNonWhiteSpaceCharacter(a))},swapcase:function(a,b,c,d,e,f){for(var g=a.getRange(d,e),h="",i=0;g.length>i;i++){var j=g.charAt(i);h+=v(j)?j.toLowerCase():j.toUpperCase()}a.replaceRange(h,d,e),a.setCursor(f)},yank:function(a,b,c,d,e,f){C().registerController.pushText(b.registerName,"yank",a.getRange(d,e),b.linewise),a.setCursor(f)
|
5
|
-
}},L={clearSearchHighlight:Bb,enterInsertMode:function(a,b){var c=b?b.insertAt:null;if("eol"==c){var d=a.getCursor();d={line:d.line,ch:Y(a,d.line)},a.setCursor(d)}else"charAfter"==c&&a.setCursor(Q(a.getCursor(),0,1));a.setOption("keyMap","vim-insert")},toggleVisualMode:function(a,b,c){var f,d=b.repeat,e=a.getCursor();c.visualMode?!c.visualLine&&b.linewise?(c.visualLine=!0,e=a.getCursor("anchor"),f=a.getCursor("head"),e.ch=X(e,f)?0:Y(a,e.line),f.ch=X(e,f)?Y(a,f.line):0,a.setSelection(e,f)):ab(a,c):(c.visualMode=!0,c.visualLine=!!b.linewise,c.visualLine?(e.ch=0,f=N(a,{line:e.line+d-1,ch:Y(a,e.line)},!0)):f=N(a,{line:e.line,ch:e.ch+d},!0),b.repeatIsExplicit||c.visualLine?a.setSelection(e,f):(a.setCursor(f),a.setSelection(f,e)))},joinLines:function(a,b,c){var d,e;if(c.visualMode)d=a.getCursor("anchor"),e=a.getCursor("head"),e.ch=Y(a,e.line)-1;else{var f=Math.max(b.repeat,2);d=a.getCursor(),e=N(a,{line:d.line+f-1,ch:1/0})}var g=0;a.operation(function(){for(var b=d.line;e.line>b;b++){g=Y(a,d.line);var c={line:d.line+1,ch:Y(a,d.line+1)},f=a.getRange(d,c);f=f.replace(/\n\s*/g," "),a.replaceRange(f,d,c)}var h={line:d.line,ch:g};a.setCursor(h)})},newLineAndEnterInsertMode:function(a,b){var c=a.getCursor();if(0!==c.line||b.after){c.line=b.after?c.line:c.line-1,c.ch=Y(a,c.line),a.setCursor(c);var d=CodeMirror.commands.newlineAndIndentContinueComment||CodeMirror.commands.newlineAndIndent;d(a)}else a.replaceRange("\n",{line:0,ch:0}),a.setCursor(0,0);this.enterInsertMode(a)},paste:function(a,b){var d=a.getCursor(),e=C().registerController.getRegister(b.registerName);if(e.text){for(var f="",g=0;b.repeat>g;g++)f+=e.text;var h=e.linewise;h?b.after?(f="\n"+f.slice(0,f.length-1),d.ch=Y(a,d.line)):d.ch=0:d.ch+=b.after?1:0,a.replaceRange(f,d);var i,j;h&&b.after?i={line:d.line+1,ch:db(a.getLine(d.line+1))}:h&&!b.after?i={line:d.line,ch:db(a.getLine(d.line))}:!h&&b.after?(j=a.indexFromPos(d),i=a.posFromIndex(j+f.length-1)):(j=a.indexFromPos(d),i=a.posFromIndex(j+f.length)),a.setCursor(i)}},undo:function(a,b){U(a,CodeMirror.commands.undo,b.repeat)()},redo:function(a,b){U(a,CodeMirror.commands.redo,b.repeat)()},setRegister:function(a,b,c){c.inputState.registerName=b.selectedCharacter},setMark:function(a,b,c){var d=b.selectedCharacter;A(d,o)&&(c.marks[d]&&c.marks[d].clear(),c.marks[d]=a.setBookmark(a.getCursor()))},replace:function(a,b){var c=b.selectedCharacter,d=a.getCursor(),e=a.getLine(d.line),f=d.ch+b.repeat;if(!(f>e.length)){for(var g={line:d.line,ch:f},h="",i=0;g.ch-d.ch>i;i++)h+=c;a.replaceRange(h,d,g),a.setCursor(Q(g,0,-1))}}},M={w:function(a,b){return eb(a,b,!0,!1)},W:function(a,b){return eb(a,b,!0,!0)},"{":function(a,b){return lb(a,"}",b)},"(":function(a,b){return lb(a,")",b)},"[":function(a,b){return lb(a,"]",b)},"'":function(a,b){return nb(a,"'",b)},'"':function(a,b){return nb(a,'"',b)}};ob.prototype={getQuery:function(){return C().query},setQuery:function(a){C().query=a},getMarked:function(){return this.marked},setMarked:function(a){this.marked=a},isReversed:function(){return C().isReversed},setReversed:function(a){C().isReversed=a}};var vb="(Javascript regexp)",Cb=[{name:"map",type:"builtIn"},{name:"write",shortName:"w",type:"builtIn"},{name:"undo",shortName:"u",type:"builtIn"},{name:"redo",shortName:"red",type:"builtIn"}],Db=function(){this.buildCommandMap_()};Db.prototype={processCommand:function(a,b){var e,d=this.parseInput_(b);if(d.commandName){var f=this.matchCommand_(d.commandName);if(f){if(e=f.name,"exToKey"==f.type){for(var g=0;f.toKeys.length>g;g++)c.handleKey(a,f.toKeys[g]);return}if("exToEx"==f.type)return this.processCommand(a,f.toInput),void 0}}else void 0!==d.line&&(e="move");return e?(Fb[e](a,d),void 0):(tb(a,'Not an editor command ":'+b+'"'),void 0)},parseInput_:function(a){var b={};b.input=a;var c=0,d=/^:+/.exec(a);d&&(c+=d[0].length);var e=/^(\d+)/.exec(a.substring(c));e&&(b.line=parseInt(e[1],10),c+=e[0].length);var f=/^(\w+)/.exec(a.substring(c));f&&(b.commandName=f[1],c+=f[1].length);var g=$(a.substring(c)).split(/\s+/);return g.length&&g[0]&&(b.commandArgs=g),b},matchCommand_:function(a){for(var b=a.length;b>0;b--){var c=a.substring(0,b);if(this.commandMap_[c]){var d=this.commandMap_[c];if(0===d.name.indexOf(a))return d}}return null},buildCommandMap_:function(){this.commandMap_={};for(var a=0;Cb.length>a;a++){var b=Cb[a],c=b.shortName||b.name;this.commandMap_[c]=b}},map:function(b,c){if(":"==b.charAt(0)){var d=b.substring(1);this.commandMap_[d]=":"==c.charAt(0)?{name:d,type:"exToEx",toInput:c.substring(1)}:{name:d,type:"exToKey",toKeys:Eb(c)}}else":"==c.charAt(0)?a.unshift({keys:Eb(b),type:"keyToEx",exArgs:{input:c.substring(1)}}):a.unshift({keys:Eb(b),type:"keyToKey",toKeys:Eb(c)})}};var Fb={map:function(a,b){var c=b.commandArgs;return!c||2>c.length?(a&&tb(a,"Invalid mapping: "+b.input),void 0):(Gb.map(c[0],c[1],a),void 0)},move:function(a,b){I.processMotion(a,D(a),{motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,repeat:b.line}})},redo:CodeMirror.commands.redo,undo:CodeMirror.commands.undo,write:function(a){CodeMirror.commands.save?CodeMirror.commands.save(a):a.save()}},Gb=new Db;return CodeMirror.keyMap.vim=Hb(),CodeMirror.keyMap["vim-insert"]={Esc:Ib,"Ctrl-[":Ib,"Ctrl-C":Ib,"Ctrl-N":"autocomplete","Ctrl-P":"autocomplete",Enter:function(a){var b=CodeMirror.commands.newlineAndIndentContinueComment||CodeMirror.commands.newlineAndIndent;b(a)},fallthrough:["default"]},E},c=b();CodeMirror.Vim=c}();
|
@@ -1,15 +0,0 @@
|
|
1
|
-
h1 Let's try in-browser code editing
|
2
|
-
|
3
|
-
/! script src="js/coffee-script.js" type="text/javascript"
|
4
|
-
div class="container" id="code"
|
5
|
-
textarea id="editor" cols="50" rows="10" style="width:30%"
|
6
|
-
| # Hello
|
7
|
-
# This looks ok. How very nice!
|
8
|
-
a = 1 + 2
|
9
|
-
|
10
|
-
script type="text/javascript"
|
11
|
-
| var editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
|
12
|
-
lineNumbers: true,
|
13
|
-
mode: "ruby",
|
14
|
-
theme: "lesser-dark"
|
15
|
-
});
|
File without changes
|
@@ -1,17 +0,0 @@
|
|
1
|
-
doctype html
|
2
|
-
html
|
3
|
-
head
|
4
|
-
meta charset="utf-8"
|
5
|
-
title Swagr web app template
|
6
|
-
link rel="stylesheet" href="js/codemirror/lib/codemirror.css"
|
7
|
-
link rel="stylesheet" href="js/codemirror/theme/lesser-dark.css"
|
8
|
-
link href="css/bootstrap.css" rel="stylesheet"
|
9
|
-
script src="js/codemirror/lib/codemirror.js"
|
10
|
-
script src="js/codemirror/lib/util/loadmode.js"
|
11
|
-
script src="js/codemirror/mode/ruby/ruby.js"
|
12
|
-
|
13
|
-
style type="text/css"
|
14
|
-
| .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
|
15
|
-
|
16
|
-
body
|
17
|
-
== yield
|
@@ -1,85 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Tag-closer extension for CodeMirror.
|
3
|
-
*
|
4
|
-
* This extension adds an "autoCloseTags" option that can be set to
|
5
|
-
* either true to get the default behavior, or an object to further
|
6
|
-
* configure its behavior.
|
7
|
-
*
|
8
|
-
* These are supported options:
|
9
|
-
*
|
10
|
-
* `whenClosing` (default true)
|
11
|
-
* Whether to autoclose when the '/' of a closing tag is typed.
|
12
|
-
* `whenOpening` (default true)
|
13
|
-
* Whether to autoclose the tag when the final '>' of an opening
|
14
|
-
* tag is typed.
|
15
|
-
* `dontCloseTags` (default is empty tags for HTML, none for XML)
|
16
|
-
* An array of tag names that should not be autoclosed.
|
17
|
-
* `indentTags` (default is block tags for HTML, none for XML)
|
18
|
-
* An array of tag names that should, when opened, cause a
|
19
|
-
* blank line to be added inside the tag, and the blank line and
|
20
|
-
* closing line to be indented.
|
21
|
-
*
|
22
|
-
* See demos/closetag.html for a usage example.
|
23
|
-
*/
|
24
|
-
|
25
|
-
(function() {
|
26
|
-
CodeMirror.defineOption("autoCloseTags", false, function(cm, val, old) {
|
27
|
-
if (val && (old == CodeMirror.Init || !old)) {
|
28
|
-
var map = {name: "autoCloseTags"};
|
29
|
-
if (typeof val != "object" || val.whenClosing)
|
30
|
-
map["'/'"] = function(cm) { autoCloseTag(cm, '/'); };
|
31
|
-
if (typeof val != "object" || val.whenOpening)
|
32
|
-
map["'>'"] = function(cm) { autoCloseTag(cm, '>'); };
|
33
|
-
cm.addKeyMap(map);
|
34
|
-
} else if (!val && (old != CodeMirror.Init && old)) {
|
35
|
-
cm.removeKeyMap("autoCloseTags");
|
36
|
-
}
|
37
|
-
});
|
38
|
-
|
39
|
-
var htmlDontClose = ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param",
|
40
|
-
"source", "track", "wbr"];
|
41
|
-
var htmlIndent = ["applet", "blockquote", "body", "button", "div", "dl", "fieldset", "form", "frameset", "h1", "h2", "h3", "h4",
|
42
|
-
"h5", "h6", "head", "html", "iframe", "layer", "legend", "object", "ol", "p", "select", "table", "ul"];
|
43
|
-
|
44
|
-
function autoCloseTag(cm, ch) {
|
45
|
-
var pos = cm.getCursor(), tok = cm.getTokenAt(pos);
|
46
|
-
var inner = CodeMirror.innerMode(cm.getMode(), tok.state), state = inner.state;
|
47
|
-
if (inner.mode.name != "xml") throw CodeMirror.Pass;
|
48
|
-
|
49
|
-
var opt = cm.getOption("autoCloseTags"), html = inner.mode.configuration == "html";
|
50
|
-
var dontCloseTags = (typeof opt == "object" && opt.dontCloseTags) || (html && htmlDontClose);
|
51
|
-
var indentTags = (typeof opt == "object" && opt.indentTags) || (html && htmlIndent);
|
52
|
-
|
53
|
-
if (ch == ">" && state.tagName) {
|
54
|
-
var tagName = state.tagName;
|
55
|
-
if (tok.end > pos.ch) tagName = tagName.slice(0, tagName.length - tok.end + pos.ch);
|
56
|
-
var lowerTagName = tagName.toLowerCase();
|
57
|
-
// Don't process the '>' at the end of an end-tag or self-closing tag
|
58
|
-
if (tok.type == "tag" && state.type == "closeTag" ||
|
59
|
-
/\/\s*$/.test(tok.string) ||
|
60
|
-
dontCloseTags && indexOf(dontCloseTags, lowerTagName) > -1)
|
61
|
-
throw CodeMirror.Pass;
|
62
|
-
|
63
|
-
var doIndent = indentTags && indexOf(indentTags, lowerTagName) > -1;
|
64
|
-
cm.replaceSelection(">" + (doIndent ? "\n\n" : "") + "</" + tagName + ">",
|
65
|
-
doIndent ? {line: pos.line + 1, ch: 0} : {line: pos.line, ch: pos.ch + 1});
|
66
|
-
if (doIndent) {
|
67
|
-
cm.indentLine(pos.line + 1);
|
68
|
-
cm.indentLine(pos.line + 2);
|
69
|
-
}
|
70
|
-
return;
|
71
|
-
} else if (ch == "/" && tok.type == "tag" && tok.string == "<") {
|
72
|
-
var tagName = state.context && state.context.tagName;
|
73
|
-
if (tagName) cm.replaceSelection("/" + tagName + ">", "end");
|
74
|
-
return;
|
75
|
-
}
|
76
|
-
throw CodeMirror.Pass;
|
77
|
-
}
|
78
|
-
|
79
|
-
function indexOf(collection, elt) {
|
80
|
-
if (collection.indexOf) return collection.indexOf(elt);
|
81
|
-
for (var i = 0, e = collection.length; i < e; ++i)
|
82
|
-
if (collection[i] == elt) return i;
|
83
|
-
return -1;
|
84
|
-
}
|
85
|
-
})();
|
@@ -1,29 +0,0 @@
|
|
1
|
-
CodeMirror.colorize = (function() {
|
2
|
-
|
3
|
-
var isBlock = /^(p|li|div|h\\d|pre|blockquote|td)$/;
|
4
|
-
|
5
|
-
function textContent(node, out) {
|
6
|
-
if (node.nodeType == 3) return out.push(node.nodeValue);
|
7
|
-
for (var ch = node.firstChild; ch; ch = ch.nextSibling) {
|
8
|
-
textContent(ch, out);
|
9
|
-
if (isBlock.test(node.nodeType)) out.push("\n");
|
10
|
-
}
|
11
|
-
}
|
12
|
-
|
13
|
-
return function(collection, defaultMode) {
|
14
|
-
if (!collection) collection = document.body.getElementsByTagName("pre");
|
15
|
-
|
16
|
-
for (var i = 0; i < collection.length; ++i) {
|
17
|
-
var node = collection[i];
|
18
|
-
var mode = node.getAttribute("data-lang") || defaultMode;
|
19
|
-
if (!mode) continue;
|
20
|
-
|
21
|
-
var text = [];
|
22
|
-
textContent(node, text);
|
23
|
-
node.innerHTML = "";
|
24
|
-
CodeMirror.runMode(text.join(""), mode, node);
|
25
|
-
|
26
|
-
node.className += " cm-s-default";
|
27
|
-
}
|
28
|
-
};
|
29
|
-
})();
|
@@ -1,36 +0,0 @@
|
|
1
|
-
(function() {
|
2
|
-
var modes = ["clike", "css", "javascript"];
|
3
|
-
for (var i = 0; i < modes.length; ++i)
|
4
|
-
CodeMirror.extendMode(modes[i], {blockCommentStart: "/*",
|
5
|
-
blockCommentEnd: "*/",
|
6
|
-
blockCommentContinue: " * "});
|
7
|
-
|
8
|
-
CodeMirror.commands.newlineAndIndentContinueComment = function(cm) {
|
9
|
-
var pos = cm.getCursor(), token = cm.getTokenAt(pos);
|
10
|
-
var mode = CodeMirror.innerMode(cm.getMode(), token.state).mode;
|
11
|
-
var space;
|
12
|
-
|
13
|
-
if (token.type == "comment" && mode.blockCommentStart) {
|
14
|
-
var end = token.string.indexOf(mode.blockCommentEnd);
|
15
|
-
var full = cm.getRange({line: pos.line, ch: 0}, {line: pos.line, ch: token.end}), found;
|
16
|
-
if (end != -1 && end == token.string.length - mode.blockCommentEnd.length) {
|
17
|
-
// Comment ended, don't continue it
|
18
|
-
} else if (token.string.indexOf(mode.blockCommentStart) == 0) {
|
19
|
-
space = full.slice(0, token.start);
|
20
|
-
if (!/^\s*$/.test(space)) {
|
21
|
-
space = "";
|
22
|
-
for (var i = 0; i < token.start; ++i) space += " ";
|
23
|
-
}
|
24
|
-
} else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
|
25
|
-
found + mode.blockCommentContinue.length > token.start &&
|
26
|
-
/^\s*$/.test(full.slice(0, found))) {
|
27
|
-
space = full.slice(0, found);
|
28
|
-
}
|
29
|
-
}
|
30
|
-
|
31
|
-
if (space != null)
|
32
|
-
cm.replaceSelection("\n" + space + mode.blockCommentContinue, "end");
|
33
|
-
else
|
34
|
-
cm.execCommand("newlineAndIndent");
|
35
|
-
};
|
36
|
-
})();
|
@@ -1,28 +0,0 @@
|
|
1
|
-
(function() {
|
2
|
-
CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
|
3
|
-
var pos = cm.getCursor(), token = cm.getTokenAt(pos);
|
4
|
-
var space;
|
5
|
-
if (token.className == "string") {
|
6
|
-
var full = cm.getRange({line: pos.line, ch: 0}, {line: pos.line, ch: token.end});
|
7
|
-
var listStart = /\*|\d+\./, listContinue;
|
8
|
-
if (token.string.search(listStart) == 0) {
|
9
|
-
var reg = /^[\W]*(\d+)\./g;
|
10
|
-
var matches = reg.exec(full);
|
11
|
-
if(matches)
|
12
|
-
listContinue = (parseInt(matches[1]) + 1) + ". ";
|
13
|
-
else
|
14
|
-
listContinue = "* ";
|
15
|
-
space = full.slice(0, token.start);
|
16
|
-
if (!/^\s*$/.test(space)) {
|
17
|
-
space = "";
|
18
|
-
for (var i = 0; i < token.start; ++i) space += " ";
|
19
|
-
}
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
if (space != null)
|
24
|
-
cm.replaceSelection("\n" + space + listContinue, "end");
|
25
|
-
else
|
26
|
-
cm.execCommand("newlineAndIndent");
|
27
|
-
};
|
28
|
-
})();
|
@@ -1,32 +0,0 @@
|
|
1
|
-
.CodeMirror-dialog {
|
2
|
-
position: absolute;
|
3
|
-
left: 0; right: 0;
|
4
|
-
background: white;
|
5
|
-
z-index: 15;
|
6
|
-
padding: .1em .8em;
|
7
|
-
overflow: hidden;
|
8
|
-
color: #333;
|
9
|
-
}
|
10
|
-
|
11
|
-
.CodeMirror-dialog-top {
|
12
|
-
border-bottom: 1px solid #eee;
|
13
|
-
top: 0;
|
14
|
-
}
|
15
|
-
|
16
|
-
.CodeMirror-dialog-bottom {
|
17
|
-
border-top: 1px solid #eee;
|
18
|
-
bottom: 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
.CodeMirror-dialog input {
|
22
|
-
border: none;
|
23
|
-
outline: none;
|
24
|
-
background: transparent;
|
25
|
-
width: 20em;
|
26
|
-
color: inherit;
|
27
|
-
font-family: monospace;
|
28
|
-
}
|
29
|
-
|
30
|
-
.CodeMirror-dialog button {
|
31
|
-
font-size: 70%;
|
32
|
-
}
|
@@ -1,75 +0,0 @@
|
|
1
|
-
// Open simple dialogs on top of an editor. Relies on dialog.css.
|
2
|
-
|
3
|
-
(function() {
|
4
|
-
function dialogDiv(cm, template, bottom) {
|
5
|
-
var wrap = cm.getWrapperElement();
|
6
|
-
var dialog;
|
7
|
-
dialog = wrap.appendChild(document.createElement("div"));
|
8
|
-
if (bottom) {
|
9
|
-
dialog.className = "CodeMirror-dialog CodeMirror-dialog-bottom";
|
10
|
-
} else {
|
11
|
-
dialog.className = "CodeMirror-dialog CodeMirror-dialog-top";
|
12
|
-
}
|
13
|
-
dialog.innerHTML = template;
|
14
|
-
return dialog;
|
15
|
-
}
|
16
|
-
|
17
|
-
CodeMirror.defineExtension("openDialog", function(template, callback, options) {
|
18
|
-
var dialog = dialogDiv(this, template, options && options.bottom);
|
19
|
-
var closed = false, me = this;
|
20
|
-
function close() {
|
21
|
-
if (closed) return;
|
22
|
-
closed = true;
|
23
|
-
dialog.parentNode.removeChild(dialog);
|
24
|
-
}
|
25
|
-
var inp = dialog.getElementsByTagName("input")[0], button;
|
26
|
-
if (inp) {
|
27
|
-
CodeMirror.on(inp, "keydown", function(e) {
|
28
|
-
if (e.keyCode == 13 || e.keyCode == 27) {
|
29
|
-
CodeMirror.e_stop(e);
|
30
|
-
close();
|
31
|
-
me.focus();
|
32
|
-
if (e.keyCode == 13) callback(inp.value);
|
33
|
-
}
|
34
|
-
});
|
35
|
-
inp.focus();
|
36
|
-
CodeMirror.on(inp, "blur", close);
|
37
|
-
} else if (button = dialog.getElementsByTagName("button")[0]) {
|
38
|
-
CodeMirror.on(button, "click", function() {
|
39
|
-
close();
|
40
|
-
me.focus();
|
41
|
-
});
|
42
|
-
button.focus();
|
43
|
-
CodeMirror.on(button, "blur", close);
|
44
|
-
}
|
45
|
-
return close;
|
46
|
-
});
|
47
|
-
|
48
|
-
CodeMirror.defineExtension("openConfirm", function(template, callbacks, options) {
|
49
|
-
var dialog = dialogDiv(this, template, options && options.bottom);
|
50
|
-
var buttons = dialog.getElementsByTagName("button");
|
51
|
-
var closed = false, me = this, blurring = 1;
|
52
|
-
function close() {
|
53
|
-
if (closed) return;
|
54
|
-
closed = true;
|
55
|
-
dialog.parentNode.removeChild(dialog);
|
56
|
-
me.focus();
|
57
|
-
}
|
58
|
-
buttons[0].focus();
|
59
|
-
for (var i = 0; i < buttons.length; ++i) {
|
60
|
-
var b = buttons[i];
|
61
|
-
(function(callback) {
|
62
|
-
CodeMirror.on(b, "click", function(e) {
|
63
|
-
CodeMirror.e_preventDefault(e);
|
64
|
-
close();
|
65
|
-
if (callback) callback(me);
|
66
|
-
});
|
67
|
-
})(callbacks[i]);
|
68
|
-
CodeMirror.on(b, "blur", function() {
|
69
|
-
--blurring;
|
70
|
-
setTimeout(function() { if (blurring <= 0) close(); }, 200);
|
71
|
-
});
|
72
|
-
CodeMirror.on(b, "focus", function() { ++blurring; });
|
73
|
-
}
|
74
|
-
});
|
75
|
-
})();
|
@@ -1,182 +0,0 @@
|
|
1
|
-
// the tagRangeFinder function is
|
2
|
-
// Copyright (C) 2011 by Daniel Glazman <daniel@glazman.org>
|
3
|
-
// released under the MIT license (../../LICENSE) like the rest of CodeMirror
|
4
|
-
CodeMirror.tagRangeFinder = function(cm, start) {
|
5
|
-
var nameStartChar = "A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
6
|
-
var nameChar = nameStartChar + "\-\:\.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
7
|
-
var xmlNAMERegExp = new RegExp("^[" + nameStartChar + "][" + nameChar + "]*");
|
8
|
-
|
9
|
-
var lineText = cm.getLine(start.line);
|
10
|
-
var found = false;
|
11
|
-
var tag = null;
|
12
|
-
var pos = start.ch;
|
13
|
-
while (!found) {
|
14
|
-
pos = lineText.indexOf("<", pos);
|
15
|
-
if (-1 == pos) // no tag on line
|
16
|
-
return;
|
17
|
-
if (pos + 1 < lineText.length && lineText[pos + 1] == "/") { // closing tag
|
18
|
-
pos++;
|
19
|
-
continue;
|
20
|
-
}
|
21
|
-
// ok we seem to have a start tag
|
22
|
-
if (!lineText.substr(pos + 1).match(xmlNAMERegExp)) { // not a tag name...
|
23
|
-
pos++;
|
24
|
-
continue;
|
25
|
-
}
|
26
|
-
var gtPos = lineText.indexOf(">", pos + 1);
|
27
|
-
if (-1 == gtPos) { // end of start tag not in line
|
28
|
-
var l = start.line + 1;
|
29
|
-
var foundGt = false;
|
30
|
-
var lastLine = cm.lineCount();
|
31
|
-
while (l < lastLine && !foundGt) {
|
32
|
-
var lt = cm.getLine(l);
|
33
|
-
gtPos = lt.indexOf(">");
|
34
|
-
if (-1 != gtPos) { // found a >
|
35
|
-
foundGt = true;
|
36
|
-
var slash = lt.lastIndexOf("/", gtPos);
|
37
|
-
if (-1 != slash && slash < gtPos) {
|
38
|
-
var str = lineText.substr(slash, gtPos - slash + 1);
|
39
|
-
if (!str.match( /\/\s*\>/ )) // yep, that's the end of empty tag
|
40
|
-
return;
|
41
|
-
}
|
42
|
-
}
|
43
|
-
l++;
|
44
|
-
}
|
45
|
-
found = true;
|
46
|
-
}
|
47
|
-
else {
|
48
|
-
var slashPos = lineText.lastIndexOf("/", gtPos);
|
49
|
-
if (-1 == slashPos) { // cannot be empty tag
|
50
|
-
found = true;
|
51
|
-
// don't continue
|
52
|
-
}
|
53
|
-
else { // empty tag?
|
54
|
-
// check if really empty tag
|
55
|
-
var str = lineText.substr(slashPos, gtPos - slashPos + 1);
|
56
|
-
if (!str.match( /\/\s*\>/ )) { // finally not empty
|
57
|
-
found = true;
|
58
|
-
// don't continue
|
59
|
-
}
|
60
|
-
}
|
61
|
-
}
|
62
|
-
if (found) {
|
63
|
-
var subLine = lineText.substr(pos + 1);
|
64
|
-
tag = subLine.match(xmlNAMERegExp);
|
65
|
-
if (tag) {
|
66
|
-
// we have an element name, wooohooo !
|
67
|
-
tag = tag[0];
|
68
|
-
// do we have the close tag on same line ???
|
69
|
-
if (-1 != lineText.indexOf("</" + tag + ">", pos)) // yep
|
70
|
-
{
|
71
|
-
found = false;
|
72
|
-
}
|
73
|
-
// we don't, so we have a candidate...
|
74
|
-
}
|
75
|
-
else
|
76
|
-
found = false;
|
77
|
-
}
|
78
|
-
if (!found)
|
79
|
-
pos++;
|
80
|
-
}
|
81
|
-
|
82
|
-
if (found) {
|
83
|
-
var startTag = "(\\<\\/" + tag + "\\>)|(\\<" + tag + "\\>)|(\\<" + tag + "\\s)|(\\<" + tag + "$)";
|
84
|
-
var startTagRegExp = new RegExp(startTag);
|
85
|
-
var endTag = "</" + tag + ">";
|
86
|
-
var depth = 1;
|
87
|
-
var l = start.line + 1;
|
88
|
-
var lastLine = cm.lineCount();
|
89
|
-
while (l < lastLine) {
|
90
|
-
lineText = cm.getLine(l);
|
91
|
-
var match = lineText.match(startTagRegExp);
|
92
|
-
if (match) {
|
93
|
-
for (var i = 0; i < match.length; i++) {
|
94
|
-
if (match[i] == endTag)
|
95
|
-
depth--;
|
96
|
-
else
|
97
|
-
depth++;
|
98
|
-
if (!depth) return {from: {line: start.line, ch: gtPos + 1},
|
99
|
-
to: {line: l, ch: match.index}};
|
100
|
-
}
|
101
|
-
}
|
102
|
-
l++;
|
103
|
-
}
|
104
|
-
return;
|
105
|
-
}
|
106
|
-
};
|
107
|
-
|
108
|
-
CodeMirror.braceRangeFinder = function(cm, start) {
|
109
|
-
var line = start.line, lineText = cm.getLine(line);
|
110
|
-
var at = lineText.length, startChar, tokenType;
|
111
|
-
for (;;) {
|
112
|
-
var found = lineText.lastIndexOf("{", at);
|
113
|
-
if (found < start.ch) break;
|
114
|
-
tokenType = cm.getTokenAt({line: line, ch: found}).type;
|
115
|
-
if (!/^(comment|string)/.test(tokenType)) { startChar = found; break; }
|
116
|
-
at = found - 1;
|
117
|
-
}
|
118
|
-
if (startChar == null || lineText.lastIndexOf("}") > startChar) return;
|
119
|
-
var count = 1, lastLine = cm.lineCount(), end, endCh;
|
120
|
-
outer: for (var i = line + 1; i < lastLine; ++i) {
|
121
|
-
var text = cm.getLine(i), pos = 0;
|
122
|
-
for (;;) {
|
123
|
-
var nextOpen = text.indexOf("{", pos), nextClose = text.indexOf("}", pos);
|
124
|
-
if (nextOpen < 0) nextOpen = text.length;
|
125
|
-
if (nextClose < 0) nextClose = text.length;
|
126
|
-
pos = Math.min(nextOpen, nextClose);
|
127
|
-
if (pos == text.length) break;
|
128
|
-
if (cm.getTokenAt({line: i, ch: pos + 1}).type == tokenType) {
|
129
|
-
if (pos == nextOpen) ++count;
|
130
|
-
else if (!--count) { end = i; endCh = pos; break outer; }
|
131
|
-
}
|
132
|
-
++pos;
|
133
|
-
}
|
134
|
-
}
|
135
|
-
if (end == null || end == line + 1) return;
|
136
|
-
return {from: {line: line, ch: startChar + 1},
|
137
|
-
to: {line: end, ch: endCh}};
|
138
|
-
};
|
139
|
-
|
140
|
-
CodeMirror.indentRangeFinder = function(cm, start) {
|
141
|
-
var tabSize = cm.getOption("tabSize"), firstLine = cm.getLine(start.line);
|
142
|
-
var myIndent = CodeMirror.countColumn(firstLine, null, tabSize);
|
143
|
-
for (var i = start.line + 1, end = cm.lineCount(); i < end; ++i) {
|
144
|
-
var curLine = cm.getLine(i);
|
145
|
-
if (CodeMirror.countColumn(curLine, null, tabSize) < myIndent)
|
146
|
-
return {from: {line: start.line, ch: firstLine.length},
|
147
|
-
to: {line: i, ch: curLine.length}};
|
148
|
-
}
|
149
|
-
};
|
150
|
-
|
151
|
-
CodeMirror.newFoldFunction = function(rangeFinder, widget) {
|
152
|
-
if (widget == null) widget = "\u2194";
|
153
|
-
if (typeof widget == "string") {
|
154
|
-
var text = document.createTextNode(widget);
|
155
|
-
widget = document.createElement("span");
|
156
|
-
widget.appendChild(text);
|
157
|
-
widget.className = "CodeMirror-foldmarker";
|
158
|
-
}
|
159
|
-
|
160
|
-
return function(cm, pos) {
|
161
|
-
if (typeof pos == "number") pos = {line: pos, ch: 0};
|
162
|
-
var range = rangeFinder(cm, pos);
|
163
|
-
if (!range) return;
|
164
|
-
|
165
|
-
var present = cm.findMarksAt(range.from), cleared = 0;
|
166
|
-
for (var i = 0; i < present.length; ++i) {
|
167
|
-
if (present[i].__isFold) {
|
168
|
-
++cleared;
|
169
|
-
present[i].clear();
|
170
|
-
}
|
171
|
-
}
|
172
|
-
if (cleared) return;
|
173
|
-
|
174
|
-
var myWidget = widget.cloneNode(true);
|
175
|
-
CodeMirror.on(myWidget, "mousedown", function() {myRange.clear();});
|
176
|
-
var myRange = cm.markText(range.from, range.to, {
|
177
|
-
replacedWith: myWidget,
|
178
|
-
clearOnEnter: true,
|
179
|
-
__isFold: true
|
180
|
-
});
|
181
|
-
};
|
182
|
-
};
|