# Path: app/curses_util.py
# def column_width(string):
#     """When rendering |string| how many character cells will be used? For ASCII
#     characters this will equal len(string). For many Chinese characters and
#     emoji the value will be greater than len(string), since many of them use two
#     cells.
#     """
#     if app.config.strict_debug:
#         assert isinstance(string, unicode)
#     width = 0
#     for i in string:
#         width += char_width(i, width)
#     return width


import os
import re
import app.buffer_file
import app.log
import app.selectable
from app.curses_util import column_width
            self.goalCol = self.penCol
        elif change[0] == "j":  # Redo join lines (delete \n).
            self.parser.delete_char(self.penRow, self.penCol)
        elif change[0] == "ld":  # Redo line diff.
            assert False  # Not used.
            lines = []
            index = 0
            for ii in change[1]:
                if type(ii) is type(0):
                    for line in self.parser.textLines(index, index + ii):
                        lines.append(line)
                    index += ii
                elif ii[0] == "+":
                    lines.append(ii[2:])
                elif ii[0] == "-":
                    index += 1
            self.parser.data = lines.join(u"\n")
            firstChangedRow = change[1][0] if type(change[1][0]) is type(0) else 0
        elif change[0] == "m":  # Redo move
            self.__redo_move(change)
        elif change[0] == "ml":  # Redo move lines
            begin, end, to = change[1]
            self.__do_move_lines(begin, end, to)
        elif change[0] == "n":  # Redo split lines (insert \n).
            self.parser.insert(self.penRow, self.penCol, u"\n")
            self.__redo_move(change[2])
        elif change[0] == "v":  # Redo paste.
            self.insert_lines(change[1])
        elif change[0] == "vb":  # Redo vertical backspace.
            assert False  # Not yet used.

# Path: app/curses_util.py
# def column_width(string):
#     """When rendering |string| how many character cells will be used? For ASCII
#     characters this will equal len(string). For many Chinese characters and
#     emoji the value will be greater than len(string), since many of them use two
#     cells.
#     """
#     if app.config.strict_debug:
#         assert isinstance(string, unicode)
#     width = 0
#     for i in string:
#         width += char_width(i, width)
#     return width


# Path: app/mutator.py
import os
import re
import app.buffer_file
import app.log
import app.selectable
from app.curses_util import column_width

            self.goalCol = self.penCol
        elif change[0] == "j":  # Redo join lines (delete \n).
            self.parser.delete_char(self.penRow, self.penCol)
        elif change[0] == "ld":  # Redo line diff.
            assert False  # Not used.
            lines = []
            index = 0
            for ii in change[1]:
                if type(ii) is type(0):
                    for line in self.parser.textLines(index, index + ii):
                        lines.append(line)
                    index += ii
                elif ii[0] == "+":
                    lines.append(ii[2:])
                elif ii[0] == "-":
                    index += 1
            self.parser.data = lines.join(u"\n")
            firstChangedRow = change[1][0] if type(change[1][0]) is type(0) else 0
        elif change[0] == "m":  # Redo move
            self.__redo_move(change)
        elif change[0] == "ml":  # Redo move lines
            begin, end, to = change[1]
            self.__do_move_lines(begin, end, to)
        elif change[0] == "n":  # Redo split lines (insert \n).
            self.parser.insert(self.penRow, self.penCol, u"\n")
            self.__redo_move(change[2])
        elif change[0] == "v":  # Redo paste.
            self.insert_lines(change[1])
        elif change[0] == "vb":  # Redo vertical backspace.
            assert False  # Not yet used.

            width = column_width(change[1][0])