b0y-101 Mini Shell


Current Path : E:/www/pl/media/editors/codemirror/addon/wrap/
File Upload :
Current File : E:/www/pl/media/editors/codemirror/addon/wrap/hardwrap.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";function b(a,b,c){for(var d=c.paragraphStart||a.getHelper(b,"paragraphStart"),e=b.line,f=a.firstLine();e>f;--e){var g=a.getLine(e);if(d&&d.test(g))break;if(!/\S/.test(g)){++e;break}}for(var h=c.paragraphEnd||a.getHelper(b,"paragraphEnd"),i=b.line+1,j=a.lastLine();i<=j;++i){var g=a.getLine(i);if(h&&h.test(g)){++i;break}if(!/\S/.test(g))break}return{from:e,to:i}}function c(a,b,c,d,e){for(var f=b;f<a.length&&" "==a.charAt(f);)f++;for(;f>0&&!c.test(a.slice(f-1,f+1));--f);if(0==f&&!e)for(f=b+1;f<a.length-1&&!c.test(a.slice(f-1,f+1));++f);for(var g=!0;;g=!1){var h=f;if(d)for(;" "==a.charAt(h-1);)--h;if(0!=h||!g)return{from:h,to:f};f=b}}function d(b,d,f,g){d=b.clipPos(d),f=b.clipPos(f);var h=g.column||80,i=g.wrapOn||/\s\S|-[^\.\d]/,j=!1!==g.forceBreak,k=!1!==g.killTrailingSpace,l=[],m="",n=d.line,o=b.getRange(d,f,!1);if(!o.length)return null;var p=o[0].match(/^[ \t]*/)[0];p.length>=h&&(h=p.length+1);for(var q=0;q<o.length;++q){var r=o[q],s=m.length,t=0;m&&r&&!i.test(m.charAt(m.length-1)+r.charAt(0))&&(m+=" ",t=1);var u="";if(q&&(u=r.match(/^\s*/)[0],r=r.slice(u.length)),m+=r,q){var v=m.length>h&&p==u&&c(m,h,i,k,j);v&&v.from==s&&v.to==s+t?(m=p+r,++n):l.push({text:[t?" ":""],from:e(n,s),to:e(n+1,u.length)})}for(;m.length>h;){var w=c(m,h,i,k,j);if(w.from==w.to&&!j)break;l.push({text:["",p],from:e(n,w.from),to:e(n,w.to)}),m=p+m.slice(w.to),++n}}return l.length&&b.operation((function(){for(var c=0;c<l.length;++c){var d=l[c];(d.text||a.cmpPos(d.from,d.to))&&b.replaceRange(d.text,d.from,d.to)}})),l.length?{from:l[0].from,to:a.changeEnd(l[l.length-1])}:null}var e=a.Pos;a.defineExtension("wrapParagraph",(function(a,c){c=c||{},a||(a=this.getCursor());var f=b(this,a,c);return d(this,e(f.from,0),e(f.to-1),c)})),a.commands.wrapLines=function(a){a.operation((function(){for(var c=a.listSelections(),f=a.lastLine()+1,g=c.length-1;g>=0;g--){var h,i=c[g];if(i.empty()){var j=b(a,i.head,{});h={from:e(j.from,0),to:e(j.to-1)}}else h={from:i.from(),to:i.to()};h.to.line>=f||(f=h.from.line,d(a,h.from,h.to,{}))}}))},a.defineExtension("wrapRange",(function(a,b,c){return d(this,a,b,c||{})})),a.defineExtension("wrapParagraphsInRange",(function(a,c,f){f=f||{};for(var g=this,h=[],i=a.line;i<=c.line;){var j=b(g,e(i,0),f);h.push(j),i=j.to}var k=!1;return h.length&&g.operation((function(){for(var a=h.length-1;a>=0;--a)k=k||d(g,e(h[a].from,0),e(h[a].to-1),f)})),k}))}));

Copyright © 2019 by b0y-101