haste-server/static/codemirror.min.js

1 line
122 KiB
JavaScript
Raw Normal View History

var CodeMirror=function(){function a(d,e){function bS(a){return a>=0&&a<bq.size}function bU(a){return u(bq,a)}function bV(a,b){bH=!0;var c=b-a.height;for(var d=a;d;d=d.parent)d.height+=c}function bW(a){var b={line:0,ch:0};ch(b,{line:bq.size-1,ch:bU(bq.size-1).text.length},_(a),b,b),bB=!0}function bX(a){var b=[];return bq.iter(0,bq.size,function(a){b.push(a.text)}),b.join("\n")}function bY(a){function j(a){var b=dA(a,!0);if(b&&!T(b,g)){bs||cf(),g=b,cI(d,b),bB=!1;var c=cB();if(b.line>=c.to||b.line<c.from)h=setTimeout(dN(function(){j(a)}),150)}}cH(G(a,"shiftKey"));for(var b=E(a);b!=C;b=b.parentNode)if(b.parentNode==bc&&b!=bd)return;for(var b=E(a);b!=C;b=b.parentNode)if(b.parentNode==bf)return f.onGutterClick&&f.onGutterClick(bT,Z(bf.childNodes,b)+bK,a),B(a);var d=dA(a);switch(F(a)){case 3:K&&!c&&dB(a);return;case 2:d&&cL(d.line,d.ch,!0);return}if(!d){E(a)==P&&B(a);return}bs||cf();var e=+(new Date);if(bw&&bw.time>e-400&&T(bw.pos,d))return B(a),setTimeout(cx,20),cU(d.line);if(bv&&bv.time>e-400&&T(bv.pos,d))return bw={time:e,pos:d},B(a),cT(d);bv={time:e,pos:d};var g=d,h;if(J&&!f.readOnly&&!T(bt.from,bt.to)&&!U(d,bt.from)&&!U(bt.to,d)){M&&(bg.draggable=!0);var i=H(z,"mouseup",dN(function(b){M&&(bg.draggable=!1),by=!1,i(),Math.abs(a.clientX-b.clientX)+Math.abs(a.clientY-b.clientY)<10&&(B(b),cL(d.line,d.ch,!0),cx())}),!0);by=!0;return}B(a),cL(d.line,d.ch,!0);var k=H(z,"mousemove",dN(function(a){clearTimeout(h),B(a),j(a)}),!0),i=H(z,"mouseup",dN(function(a){clearTimeout(h);var b=dA(a);b&&cI(d,b),B(a),cx(),bB=!0,k(),i()}),!0)}function bZ(a){for(var b=E(a);b!=C;b=b.parentNode)if(b.parentNode==bf)return B(a);var c=dA(a);if(!c)return;bw={time:+(new Date),pos:c},B(a),cT(c)}function b$(a){a.preventDefault();var b=dA(a,!0),c=a.dataTransfer.files;if(!b||f.readOnly)return;if(c&&c.length&&window.FileReader&&window.File){function d(a,c){var d=new FileReader;d.onload=function(){g[c]=d.result,++h==e&&(b=cN(b),dN(function(){var a=cm(g.join(""),b,b);cI(b,a)})())},d.readAsText(a)}var e=c.length,g=Array(e),h=0;for(var i=0;i<e;++i)d(c[i],i)}else try{var g=a.dataTransfer.getData("Text");if(g){var j=bt.from,k=bt.to;cI(b,b),by&&cm("",j,k),cn(g),cx()}}catch(a){}}function b_(a){var b=cq();X(b),a.dataTransfer.setDragImage(W,0,0),a.dataTransfer.setData("Text",b)}function ca(a){function g(){return c.call?c.call(null,bT):c}var b=bb[G(a,"keyCode")],c=i[f.keyMap].auto,d,e;if(b==null||a.altGraphKey)return c&&(f.keyMap=g()),null;G(a,"altKey")&&(b="Alt-"+b),G(a,"ctrlKey")&&(b="Ctrl-"+b),G(a,"metaKey")&&(b="Cmd-"+b),G(a,"shiftKey")&&(d=j("Shift-"+b,f.extraKeys,f.keyMap))?e=!0:d=j(b,f.extraKeys,f.keyMap),typeof d=="string"&&(h.propertyIsEnumerable(d)?d=h[d]:d=null),c&&(d||!k(a))&&(f.keyMap=g());if(!d)return!1;var l=bu;try{f.readOnly&&(bA=!0),e&&(bu=null),d(bT)}finally{bu=l,bA=!1}return B(a),!0}function cc(a){bs||cf(),L&&a.keyCode==27&&(a.returnValue=!1);if(f.onKeyEvent&&f.onKeyEvent(bT,A(a)))return;var b=G(a,"keyCode");cH(b==16||G(a,"shiftKey"));var d=ca(a);window.opera&&(cb=d?b:null,!d&&b==88&&G(a,c?"metaKey":"ctrlKey")&&cn(""))}function cd(a){if(f.onKeyEvent&&f.onKeyEvent(bT,A(a)))return;var b=G(a,"keyCode"),c=G(a,"charCode");if(window.opera&&b==cb){cb=null,B(a);return}if(window.opera&&!a.which&&ca(a))return;if(f.electricChars&&bp.electricChars&&f.smartIndent&&!f.readOnly){var d=String.fromCharCode(c==null?b:c);bp.electricChars.indexOf(d)>-1&&setTimeout(dN(function(){cW(bt.to.line,"smart")}),75)}ct()}function ce(a){if(f.onKeyEvent&&f.onKeyEvent(bT,A(a)))return;G(a,"keyCode")==16&&(bu=null)}function cf(){if(f.readOnly=="nocursor")return;bs||(f.onFocus&&f.onFocus(bT),bs=!0,C.className.search(/\bCodeMirror-focused\b/)==-1&&(C.className+=" CodeMirror-focused"),bG||cw(!0)),cs(),dC()}function cg(){bs&&(f.onBlur&&f.onBlur(bT),bs=!1,bN&&dN(function(){bN&&(bN(),bN=null)})(),C.className=C.className.replace(" CodeMirror-focused","")),clearInterval(bo),setTimeout(function(){bs||(bu=null)},150)}function ch(a,b,c,d,e){if(bA)return;if(bQ){var g=[];bq.iter(a.line,b.line+1,function(a){g.push(a.text)}),bQ.addChange(a.line,c.length,g);while(bQ.done.length>f.undoDepth)bQ.done.shif