From 9dc94741a6b4551465ea00a09fed5e302a554926 Mon Sep 17 00:00:00 2001 From: Garen Torikian Date: Fri, 30 Nov 2012 17:27:27 -0800 Subject: [PATCH] Stash --- lib/ace/editor.js | 69 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 15 deletions(-) diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 21f33eac..9115b6ca 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -771,35 +771,74 @@ var Editor = function(renderer, session) { mode.autoOutdent(lineState, session, cursor.row); if (true || this.session.getElasticTabstops()) { - var row = 0, rows = this.session.getLength(), - tabString = "\t"; + // todo: make this a unique set + var row = cursor.row; - while (row <= rows) { - var cellWidths = this.$findCellWidthsForBlock(row, tabString), - cellWidthsByRow = cellWidths.byRow, rowIndex = cellWidths.rowIndex; - } + this.$processRow([row]); } }; + this.$processRow = function(rows) { + for (var r = 0, rowCount = rows.length; r < rowCount; r++) { + var cellWidthObj = this.$findCellWidthsForBlock(rows[r]); + } + }; + this.$findCellWidthsForBlock = function(row, tabString) { - var cellWidths = []; + var cellWidths = [], widths; - var rowIter = row; - - while (rowIter >= 0) { - var widths = this.$cellWidthsForRow(rowIter, tabString); + // starting row and backward + var row_iter = row + while (row_iter >= 0) { + widths = cellWidthsForRow(row_iter); + if (len(widths) == 0) + break; + cellWidths.unshift(widths); + row_iter--; } + + first_row = row_iter++; + + // forward (not including starting row) + row_iter = row; + var num_rows = lines_in_buffer(view); + + while (row_iter < num_rows - 1) { + row_iter++; + widths = cellWidthsForRow(row_iter); + if (len(widths) == 0) + break; + cellWidths.push(widths); + } + + return {cellWidths: cellWidths, firstRow: firstRow}; }; - this.$cellWidthsForRow = function(row, tabString) { - var selectionColumns = this.$selectionColumnsForRow(row, tabString); + this.$cellWidthsForRow = function(row) { + var selectionColumns = this.$selectionColumnsForRow(row); + //var tabs = [-1] + this.$tabsForRow(row); + //widths = [0] * (len(tabs) - 1); + //line = view.substr(view.line(view.text_point(row,0))) + //for (var i = 0, len = tabs.length; i < len; i++) { + //left_edge = tabs[i]+1 + //right_edge = tabs[i+1] + //rightmost_selection = rightmost_selection_in_cell(selection_columns, right_edge) + //cell = line[left_edge:right_edge] + //widths[i] = max(len(cell.rstrip()), rightmost_selection - left_edge) + //} + return widths;; }; this.$selectionColumnsForRow = function(row, tabString) { var selections = []; - - + selections = [] + for s in view.sel(): + if s.empty(): + r, c =view.rowcol(s.a) + if r == row: + selections.append(c) + return selections }; this.$tabsForRow = function(row, tabString) {