def calc_cols(self, f, t): chars = self.document.gettext(f, t) (dispchrs, dispcols, positions, intervals) = screen.translate_chars(f, chars, self.tab_width, kaa.app.config.AMBIGUOUS_WIDTH) return sum(dispcols)
def test_transform(self): chrs, cols, positions, intervals = screen.translate_chars(10, 'abcdefg', 8) assert chrs == 'abcdefg' assert cols == [1] * 7 assert positions == list(range(10, 17)) assert intervals == [0] * 7
def test_tab(self): chrs, cols, positions, intervals = screen.translate_chars(10, 'ab\t\tc', 4) assert chrs == 'ab c' assert cols == [1] * 9 assert positions == [10, 11, 12, 12, 13, 13, 13, 13, 14] assert intervals == [0, 0, 0, 1, 0, 1, 2, 3, 0]
def test_ctrlchars(self): chrs, cols, positions, intervals = screen.translate_chars(10, '\x01\x02\x03\x7f', 8) assert chrs == r'\x01\x02\x03\x7f' assert cols == [1] * 16 assert positions == [ 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13] assert intervals == [0, 1, 2, 3] * 4 chrs, cols, positions, intervals = screen.translate_chars(10, '\r\n', 8) assert chrs == '\\r\n' assert cols == [1] * 3 assert positions == [10, 10, 11] assert intervals == [0, 1, 0]
def test_transform(self): chrs, cols, positions, intervals = screen.translate_chars( 10, 'abcdefg', 8, 2) assert chrs == 'abcdefg' assert cols == [1] * 7 assert positions == list(range(10, 17)) assert intervals == [0] * 7
def test_tab(self): chrs, cols, positions, intervals = screen.translate_chars( 10, 'ab\t\tc', 4, 2) assert chrs == 'ab c' assert cols == [1] * 9 assert positions == [10, 11, 12, 12, 13, 13, 13, 13, 14] assert intervals == [0, 0, 0, 1, 0, 1, 2, 3, 0]
def test_controlchr(self): chrs, cols, positions, intervals = screen.translate_chars(0, '\x01\x02\x03\x7f', 8) rows = screen.col_splitter(6, 0, chrs, cols, positions, intervals, [0]*4, {}) row1, row2, row3, row4 = rows assert row1.chars == '\\x01\\' assert row2.chars == 'x02\\x' assert row3.chars == '03\\x7' assert row4.chars == 'f'
def test_ctrlchars(self): chrs, cols, positions, intervals = screen.translate_chars( 10, '\x01\x02\x03\x7f', 8, 2) assert chrs == r'\x01\x02\x03\x7f' assert cols == [1] * 16 assert positions == [ 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13 ] assert intervals == [0, 1, 2, 3] * 4 chrs, cols, positions, intervals = screen.translate_chars( 10, '\r\n', 8, 2) assert chrs == '\\r\n' assert cols == [1] * 3 assert positions == [10, 10, 11] assert intervals == [0, 1, 0]
def test_controlchr(self): chrs, cols, positions, intervals = screen.translate_chars( 0, '\x01\x02\x03\x7f', 8, 2) rows = screen.col_splitter(6, 0, chrs, cols, positions, intervals, [0] * 4, {}) row1, row2, row3, row4 = rows assert row1.chars == '\\x01\\' assert row2.chars == 'x02\\x' assert row3.chars == '03\\x7' assert row4.chars == 'f'
def calc_cols(self, f, t): chars = self.document.gettext(f, t) (dispchrs, dispcols, positions, intervals) = screen.translate_chars(f, chars, self.tab_width) return sum(dispcols)