?
Path : /home/admin/public_html/old/media/editors/codemirror/addon/fold/ |
Current File : /home/admin/public_html/old/media/editors/codemirror/addon/fold/brace-fold.min.js |
!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],a):a(CodeMirror)}(function(a){"use strict";a.registerHelper("fold","brace",function(b,c){function d(d){for(var e=c.ch,i=0;;){var j=0>=e?-1:h.lastIndexOf(d,e-1);if(-1!=j){if(1==i&&j<c.ch)break;if(f=b.getTokenTypeAt(a.Pos(g,j+1)),!/^(comment|string)/.test(f))return j+1;e=j-1}else{if(1==i)break;i=1,e=h.length}}}var e,f,g=c.line,h=b.getLine(g),i="{",j="}",e=d("{");if(null==e&&(i="[",j="]",e=d("[")),null!=e){var k,l,m=1,n=b.lastLine();a:for(var o=g;n>=o;++o)for(var p=b.getLine(o),q=o==g?e:0;;){var r=p.indexOf(i,q),s=p.indexOf(j,q);if(0>r&&(r=p.length),0>s&&(s=p.length),q=Math.min(r,s),q==p.length)break;if(b.getTokenTypeAt(a.Pos(o,q+1))==f)if(q==r)++m;else if(!--m){k=o,l=q;break a}++q}if(null!=k&&(g!=k||l!=e))return{from:a.Pos(g,e),to:a.Pos(k,l)}}}),a.registerHelper("fold","import",function(b,c){function d(c){if(c<b.firstLine()||c>b.lastLine())return null;var d=b.getTokenAt(a.Pos(c,1));if(/\S/.test(d.string)||(d=b.getTokenAt(a.Pos(c,d.end+1))),"keyword"!=d.type||"import"!=d.string)return null;for(var e=c,f=Math.min(b.lastLine(),c+10);f>=e;++e){var g=b.getLine(e),h=g.indexOf(";");if(-1!=h)return{startCh:d.end,end:a.Pos(e,h)}}}var e,c=c.line,f=d(c);if(!f||d(c-1)||(e=d(c-2))&&e.end.line==c-1)return null;for(var g=f.end;;){var h=d(g.line+1);if(null==h)break;g=h.end}return{from:b.clipPos(a.Pos(c,f.startCh+1)),to:g}}),a.registerHelper("fold","include",function(b,c){function d(c){if(c<b.firstLine()||c>b.lastLine())return null;var d=b.getTokenAt(a.Pos(c,1));return/\S/.test(d.string)||(d=b.getTokenAt(a.Pos(c,d.end+1))),"meta"==d.type&&"#include"==d.string.slice(0,8)?d.start+8:void 0}var c=c.line,e=d(c);if(null==e||null!=d(c-1))return null;for(var f=c;;){var g=d(f+1);if(null==g)break;++f}return{from:a.Pos(c,e+1),to:b.clipPos(a.Pos(f))}})});