ext-elastic_tabstops_lite-c7e25982.js.map 15 KB

1
  1. {"version":3,"file":"ext-elastic_tabstops_lite-c7e25982.js","sources":["../../node_modules/ace-builds/src-noconflict/ext-elastic_tabstops_lite.js"],"sourcesContent":["ace.define(\"ace/ext/elastic_tabstops_lite\",[\"require\",\"exports\",\"module\",\"ace/editor\",\"ace/config\"], function(require, exports, module){\"use strict\";\nvar ElasticTabstopsLite = /** @class */ (function () {\n function ElasticTabstopsLite(editor) {\n this.$editor = editor;\n var self = this;\n var changedRows = [];\n var recordChanges = false;\n this.onAfterExec = function () {\n recordChanges = false;\n self.processRows(changedRows);\n changedRows = [];\n };\n this.onExec = function () {\n recordChanges = true;\n };\n this.onChange = function (delta) {\n if (recordChanges) {\n if (changedRows.indexOf(delta.start.row) == -1)\n changedRows.push(delta.start.row);\n if (delta.end.row != delta.start.row)\n changedRows.push(delta.end.row);\n }\n };\n }\n ElasticTabstopsLite.prototype.processRows = function (rows) {\n this.$inChange = true;\n var checkedRows = [];\n for (var r = 0, rowCount = rows.length; r < rowCount; r++) {\n var row = rows[r];\n if (checkedRows.indexOf(row) > -1)\n continue;\n var cellWidthObj = this.$findCellWidthsForBlock(row);\n var cellWidths = this.$setBlockCellWidthsToMax(cellWidthObj.cellWidths);\n var rowIndex = cellWidthObj.firstRow;\n for (var w = 0, l = cellWidths.length; w < l; w++) {\n var widths = cellWidths[w];\n checkedRows.push(rowIndex);\n this.$adjustRow(rowIndex, widths);\n rowIndex++;\n }\n }\n this.$inChange = false;\n };\n ElasticTabstopsLite.prototype.$findCellWidthsForBlock = function (row) {\n var cellWidths = [], widths;\n var rowIter = row;\n while (rowIter >= 0) {\n widths = this.$cellWidthsForRow(rowIter);\n if (widths.length == 0)\n break;\n cellWidths.unshift(widths);\n rowIter--;\n }\n var firstRow = rowIter + 1;\n rowIter = row;\n var numRows = this.$editor.session.getLength();\n while (rowIter < numRows - 1) {\n rowIter++;\n widths = this.$cellWidthsForRow(rowIter);\n if (widths.length == 0)\n break;\n cellWidths.push(widths);\n }\n return { cellWidths: cellWidths, firstRow: firstRow };\n };\n ElasticTabstopsLite.prototype.$cellWidthsForRow = function (row) {\n var selectionColumns = this.$selectionColumnsForRow(row);\n var tabs = [-1].concat(this.$tabsForRow(row));\n var widths = tabs.map(function (el) { return 0; }).slice(1);\n var line = this.$editor.session.getLine(row);\n for (var i = 0, len = tabs.length - 1; i < len; i++) {\n var leftEdge = tabs[i] + 1;\n var rightEdge = tabs[i + 1];\n var rightmostSelection = this.$rightmostSelectionInCell(selectionColumns, rightEdge);\n var cell = line.substring(leftEdge, rightEdge);\n widths[i] = Math.max(cell.replace(/\\s+$/g, '').length, rightmostSelection - leftEdge);\n }\n return widths;\n };\n ElasticTabstopsLite.prototype.$selectionColumnsForRow = function (row) {\n var selections = [], cursor = this.$editor.getCursorPosition();\n if (this.$editor.session.getSelection().isEmpty()) {\n if (row == cursor.row)\n selections.push(cursor.column);\n }\n return selections;\n };\n ElasticTabstopsLite.prototype.$setBlockCellWidthsToMax = function (cellWidths) {\n var startingNewBlock = true, blockStartRow, blockEndRow, maxWidth;\n var columnInfo = this.$izip_longest(cellWidths);\n for (var c = 0, l = columnInfo.length; c < l; c++) {\n var column = columnInfo[c];\n if (!column.push) {\n console.error(column);\n continue;\n }\n column.push(NaN);\n for (var r = 0, s = column.length; r < s; r++) {\n var width = column[r];\n if (startingNewBlock) {\n blockStartRow = r;\n maxWidth = 0;\n startingNewBlock = false;\n }\n if (isNaN(width)) {\n blockEndRow = r;\n for (var j = blockStartRow; j < blockEndRow; j++) {\n cellWidths[j][c] = maxWidth;\n }\n startingNewBlock = true;\n }\n maxWidth = Math.max(maxWidth, width);\n }\n }\n return cellWidths;\n };\n ElasticTabstopsLite.prototype.$rightmostSelectionInCell = function (selectionColumns, cellRightEdge) {\n var rightmost = 0;\n if (selectionColumns.length) {\n var lengths = [];\n for (var s = 0, length = selectionColumns.length; s < length; s++) {\n if (selectionColumns[s] <= cellRightEdge)\n lengths.push(s);\n else\n lengths.push(0);\n }\n rightmost = Math.max.apply(Math, lengths);\n }\n return rightmost;\n };\n ElasticTabstopsLite.prototype.$tabsForRow = function (row) {\n var rowTabs = [], line = this.$editor.session.getLine(row), re = /\\t/g, match;\n while ((match = re.exec(line)) != null) {\n rowTabs.push(match.index);\n }\n return rowTabs;\n };\n ElasticTabstopsLite.prototype.$adjustRow = function (row, widths) {\n var rowTabs = this.$tabsForRow(row);\n if (rowTabs.length == 0)\n return;\n var bias = 0, location = -1;\n var expandedSet = this.$izip(widths, rowTabs);\n for (var i = 0, l = expandedSet.length; i < l; i++) {\n var w = expandedSet[i][0], it = expandedSet[i][1];\n location += 1 + w;\n it += bias;\n var difference = location - it;\n if (difference == 0)\n continue;\n var partialLine = this.$editor.session.getLine(row).substr(0, it);\n var strippedPartialLine = partialLine.replace(/\\s*$/g, \"\");\n var ispaces = partialLine.length - strippedPartialLine.length;\n if (difference > 0) {\n this.$editor.session.getDocument().insertInLine({ row: row, column: it + 1 }, Array(difference + 1).join(\" \") + \"\\t\");\n this.$editor.session.getDocument().removeInLine(row, it, it + 1);\n bias += difference;\n }\n if (difference < 0 && ispaces >= -difference) {\n this.$editor.session.getDocument().removeInLine(row, it + difference, it);\n bias += difference;\n }\n }\n };\n ElasticTabstopsLite.prototype.$izip_longest = function (iterables) {\n if (!iterables[0])\n return [];\n var longest = iterables[0].length;\n var iterablesLength = iterables.length;\n for (var i = 1; i < iterablesLength; i++) {\n var iLength = iterables[i].length;\n if (iLength > longest)\n longest = iLength;\n }\n var expandedSet = [];\n for (var l = 0; l < longest; l++) {\n var set = [];\n for (var i = 0; i < iterablesLength; i++) {\n if (iterables[i][l] === \"\")\n set.push(NaN);\n else\n set.push(iterables[i][l]);\n }\n expandedSet.push(set);\n }\n return expandedSet;\n };\n ElasticTabstopsLite.prototype.$izip = function (widths, tabs) {\n var size = widths.length >= tabs.length ? tabs.length : widths.length;\n var expandedSet = [];\n for (var i = 0; i < size; i++) {\n var set = [widths[i], tabs[i]];\n expandedSet.push(set);\n }\n return expandedSet;\n };\n return ElasticTabstopsLite;\n}());\nexports.ElasticTabstopsLite = ElasticTabstopsLite;\nvar Editor = require(\"../editor\").Editor;\nrequire(\"../config\").defineOptions(Editor.prototype, \"editor\", {\n useElasticTabstops: {\n set: function (val) {\n if (val) {\n if (!this.elasticTabstops)\n this.elasticTabstops = new ElasticTabstopsLite(this);\n this.commands.on(\"afterExec\", this.elasticTabstops.onAfterExec);\n this.commands.on(\"exec\", this.elasticTabstops.onExec);\n this.on(\"change\", this.elasticTabstops.onChange);\n }\n else if (this.elasticTabstops) {\n this.commands.removeListener(\"afterExec\", this.elasticTabstops.onAfterExec);\n this.commands.removeListener(\"exec\", this.elasticTabstops.onExec);\n this.removeListener(\"change\", this.elasticTabstops.onChange);\n }\n }\n }\n});\n\n}); (function() {\n ace.require([\"ace/ext/elastic_tabstops_lite\"], function(m) {\n if (typeof module == \"object\" && typeof exports == \"object\" && module) {\n module.exports = m;\n }\n });\n })();\n "],"names":["require","exports","module","ElasticTabstopsLite","editor","self","changedRows","recordChanges","delta","rows","checkedRows","r","rowCount","row","cellWidthObj","cellWidths","rowIndex","w","l","widths","rowIter","firstRow","numRows","selectionColumns","tabs","el","line","len","leftEdge","rightEdge","rightmostSelection","cell","selections","cursor","startingNewBlock","blockStartRow","blockEndRow","maxWidth","columnInfo","c","column","s","width","j","cellRightEdge","rightmost","lengths","length","rowTabs","re","match","bias","location","expandedSet","i","it","difference","partialLine","strippedPartialLine","ispaces","iterables","longest","iterablesLength","iLength","set","size","Editor","val","m"],"mappings":"gaAAA,IAAI,OAAO,gCAAgC,CAAC,UAAU,UAAU,SAAS,aAAa,YAAY,EAAG,SAASA,EAASC,EAASC,EAAO,CACvI,IAAIC,EAAqC,UAAY,CACjD,SAASA,EAAoBC,EAAQ,CACjC,KAAK,QAAUA,EACf,IAAIC,EAAO,KACPC,EAAc,CAAA,EACdC,EAAgB,GACpB,KAAK,YAAc,UAAY,CAC3BA,EAAgB,GAChBF,EAA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