12 |
- import{g as R}from"./index-91b358e1.js";function _(v,m){for(var f=0;f<m.length;f++){const u=m[f];if(typeof u!="string"&&!Array.isArray(u)){for(const g in u)if(g!=="default"&&!(g in v)){const d=Object.getOwnPropertyDescriptor(u,g);d&&Object.defineProperty(v,g,d.get?d:{enumerable:!0,get:()=>u[g]})}}}return Object.freeze(Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}))}var b={exports:{}};(function(v,m){ace.define("ace/ext/elastic_tabstops_lite",["require","exports","module","ace/editor","ace/config"],function(f,u,g){var d=function(){function p(e){this.$editor=e;var r=this,s=[],t=!1;this.onAfterExec=function(){t=!1,r.processRows(s),s=[]},this.onExec=function(){t=!0},this.onChange=function(o){t&&(s.indexOf(o.start.row)==-1&&s.push(o.start.row),o.end.row!=o.start.row&&s.push(o.end.row))}}return p.prototype.processRows=function(e){this.$inChange=!0;for(var r=[],s=0,t=e.length;s<t;s++){var o=e[s];if(!(r.indexOf(o)>-1))for(var i=this.$findCellWidthsForBlock(o),n=this.$setBlockCellWidthsToMax(i.cellWidths),h=i.firstRow,c=0,a=n.length;c<a;c++){var l=n[c];r.push(h),this.$adjustRow(h,l),h++}}this.$inChange=!1},p.prototype.$findCellWidthsForBlock=function(e){for(var r=[],s,t=e;t>=0&&(s=this.$cellWidthsForRow(t),s.length!=0);)r.unshift(s),t--;var o=t+1;t=e;for(var i=this.$editor.session.getLength();t<i-1&&(t++,s=this.$cellWidthsForRow(t),s.length!=0);)r.push(s);return{cellWidths:r,firstRow:o}},p.prototype.$cellWidthsForRow=function(e){for(var r=this.$selectionColumnsForRow(e),s=[-1].concat(this.$tabsForRow(e)),t=s.map(function($){return 0}).slice(1),o=this.$editor.session.getLine(e),i=0,n=s.length-1;i<n;i++){var h=s[i]+1,c=s[i+1],a=this.$rightmostSelectionInCell(r,c),l=o.substring(h,c);t[i]=Math.max(l.replace(/\s+$/g,"").length,a-h)}return t},p.prototype.$selectionColumnsForRow=function(e){var r=[],s=this.$editor.getCursorPosition();return this.$editor.session.getSelection().isEmpty()&&e==s.row&&r.push(s.column),r},p.prototype.$setBlockCellWidthsToMax=function(e){for(var r=!0,s,t,o,i=this.$izip_longest(e),n=0,h=i.length;n<h;n++){var c=i[n];if(!c.push){console.error(c);continue}c.push(NaN);for(var a=0,l=c.length;a<l;a++){var $=c[a];if(r&&(s=a,o=0,r=!1),isNaN($)){t=a;for(var x=s;x<t;x++)e[x][n]=o;r=!0}o=Math.max(o,$)}}return e},p.prototype.$rightmostSelectionInCell=function(e,r){var s=0;if(e.length){for(var t=[],o=0,i=e.length;o<i;o++)e[o]<=r?t.push(o):t.push(0);s=Math.max.apply(Math,t)}return s},p.prototype.$tabsForRow=function(e){for(var r=[],s=this.$editor.session.getLine(e),t=/\t/g,o;(o=t.exec(s))!=null;)r.push(o.index);return r},p.prototype.$adjustRow=function(e,r){var s=this.$tabsForRow(e);if(s.length!=0)for(var t=0,o=-1,i=this.$izip(r,s),n=0,h=i.length;n<h;n++){var c=i[n][0],a=i[n][1];o+=1+c,a+=t;var l=o-a;if(l!=0){var $=this.$editor.session.getLine(e).substr(0,a),x=$.replace(/\s*$/g,""),E=$.length-x.length;l>0&&(this.$editor.session.getDocument().insertInLine({row:e,column:a+1},Array(l+1).join(" ")+" "),this.$editor.session.getDocument().removeInLine(e,a,a+1),t+=l),l<0&&E>=-l&&(this.$editor.session.getDocument().removeInLine(e,a+l,a),t+=l)}}},p.prototype.$izip_longest=function(e){if(!e[0])return[];for(var r=e[0].length,s=e.length,t=1;t<s;t++){var o=e[t].length;o>r&&(r=o)}for(var i=[],n=0;n<r;n++){for(var h=[],t=0;t<s;t++)e[t][n]===""?h.push(NaN):h.push(e[t][n]);i.push(h)}return i},p.prototype.$izip=function(e,r){for(var s=e.length>=r.length?r.length:e.length,t=[],o=0;o<s;o++){var i=[e[o],r[o]];t.push(i)}return t},p}();u.ElasticTabstopsLite=d;var y=f("../editor").Editor;f("../config").defineOptions(y.prototype,"editor",{useElasticTabstops:{set:function(p){p?(this.elasticTabstops||(this.elasticTabstops=new d(this)),this.commands.on("afterExec",this.elasticTabstops.onAfterExec),this.commands.on("exec",this.elasticTabstops.onExec),this.on("change",this.elasticTabstops.onChange)):this.elasticTabstops&&(this.commands.removeListener("afterExec",this.elasticTabstops.onAfterExec),this.commands.removeListener("exec",this.elasticTabstops.onExec),this.removeListener("change",this.elasticTabstops.onChange))}}})}),function(){ace.require(["ace/ext/elastic_tabstops_lite"],function(f){v&&(v.exports=f)})}()})(b);var w=b.exports;const T=R(w),L=_({__proto__:null,default:T},[w]);export{L as e};
- //# sourceMappingURL=ext-elastic_tabstops_lite-c7e25982.js.map
|