mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-09 06:12:34 -05:00
1 line
39 KiB
JavaScript
1 line
39 KiB
JavaScript
|
var CodeMirror=function(){function D(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;c<d;++c)if(a[c]==b)return c;return-1}function C(a,b){if(!b)return a?a.length:0;if(!a)return b.length;for(var c=a.length,d=b.length;c>=0&&d>=0;--c,--d)if(a.charAt(c)!=b.charAt(d))break;return d+1}function B(a){return a.replace(/[<>&]/g,function(a){return a=="&"?"&":a=="<"?"<":">"})}function A(a){return{line:a.line,ch:a.ch}}function z(a,b){return a.line<b.line||a.line==b.line&&a.ch<b.ch}function y(a,b){return a.line==b.line&&a.ch==b.ch}function x(a){return a.textContent||a.innerText||a.nodeValue||""}function w(a){var b=0,c=0;for(var d=a;d;d=d.offsetParent)b+=d.offsetLeft,c+=d.offsetTop;for(var d=a.parentNode;d!=document.body;d=d.parentNode)b-=d.scrollLeft,c-=d.scrollTop;return{left:b,top:c}}function v(a,b){b==null&&(b=a.search(/[^\s\u00a0]/),b==-1&&(b=a.length));for(var c=0,d=0;c<b;++c)a.charAt(c)=="\t"?d+=r-d%r:++d;return d}function n(){this.id=null}function m(a,b,c,d){function e(a){c(new l(a||window.event))}if(typeof a.addEventListener=="function"){a.addEventListener(b,e,!1);if(d)return function(){a.removeEventListener(b,e,!1)}}else{a.attachEvent("on"+b,e);if(d)return function(){a.detachEvent("on"+b,e)}}}function l(a){this.e=a}function k(a){a.stop||(a.stop=j);return a}function j(){this.preventDefault?(this.preventDefault(),this.stopPropagation()):(this.returnValue=!1,this.cancelBubble=!0)}function i(){this.time=0,this.done=[],this.undone=[]}function h(a,b,c,d){for(var e=0,f=0,g=0;f<b;e+=2){var h=c[e],i=f+h.length;g==0?(i>a&&d.push(h.slice(a-f,Math.min(h.length,b-f)),c[e+1]),i>=a&&(g=1)):g==1&&(i>b?d.push(h.slice(0,b-f),c[e+1]):d.push(h,c[e+1])),f=i}}function g(a,b){this.styles=b||[a,null],this.stateAfter=null,this.text=a,this.marked=this.gutterMarker=this.className=null}function f(a){this.pos=this.start=0,this.string=a}function e(a,b,c){return a.startState?a.startState(b,c):!0}function d(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 a(b,c){function cG(a,b,c){this.atOccurrence=!1,c==null&&(c=typeof a=="string"&&a==a.toLowerCase()),b&&typeof b=="object"?b=bX(b):b={line:0,ch:0},this.pos={from:b,to:b};if(typeof a!="string")this.matches=function(b,c){if(b){var d=S[c.line].text.slice(0,c.ch),e=d.match(a),f=0;while(e){var g=d.indexOf(e[0]);f+=g,d=d.slice(g+1);var h=d.match(a);if(h)e=h;else break}}else var d=S[c.line].text.slice(c.ch),e=d.match(a),f=e&&c.ch+d.indexOf(e[0]);if(e)return{from:{line:c.line,ch:f},to:{line:c.line,ch:f+e[0].length},match:e}};else{c&&(a=a.toLowerCase());var d=c?function(a){return a.toLowerCase()}:function(a){return a},e=a.split("\n");e.length==1?this.matches=function(b,c){var e=d(S[c.line].text),f=a.length,g;if(b?c.ch>=f&&(g=e.lastIndexOf(a,c.ch-f))!=-1:(g=e.indexOf(a,c.ch))!=-1)return{from:{line:c.line,ch:g},to:{line:c.line,ch:g+f}}}:this.matches=function(a,b){var c=b.line,f=a?e.length-1:0,g=e[f],h=d(S[c].text),i=a?h.indexOf(g)+g.length:h.lastIndexOf(g);if(!(a?i>=b.ch||i!=g.length:i<=b.ch||i!=h.length-g.length))for(;;){if(a?!c:c==S.length-1)return;h=d(S[c+=a?-1:1].text),g=e[a?--f:++f];if(f>0&&f<e.length-1){if(h!=g)return;continue}var j=a?h.lastIndexOf(g):h.indexOf(g)+g.length;if(a?j!=h.length-g.length:j!=g.length)return;var k={line:b.line,ch:i},l={line:c,ch:j};return{from:a?l:k,to:a?k:l}}}}}function cF(a){return function(){cE++||cC();try{var b=a.apply(this,arguments)}finally{--cE||cD()}return b}}function cD(){var a=!1;bb&&(a=!bL()),_.length?bO(_):bb&&bS(),a&&bL(),bb&&cv(),!bc&&($===!0||$!==!1&&bb)&&bK(),bb&&f.matchBrackets&&setTimeout(cF(function(){bi&&(bi(),bi=null),cx(!1)}),20);var b=ba;bb&&f.onCursorActivity&&f.onCursorActivity(bl),b&&f.onChange&&bl&&f.onChange(bl,b)}function cC(){$=null,_=[],ba=bb=!1}function cB(a){!T.length||P.set(a,cF(cA))}function cA(){var a=+(new Date)+f.workTime;while(T.length){if(!S[bd].stateAfter)var b=bd;else var b=T.pop();if(b>=S.length)continue;var c=cy(b),g=c&&S[c-1].stateAfter;g?g=d(R,g):g=e(R);for(var h=c,i=S.length;h<i;++h){var j=S[h],k=j.stateAfter;
|