(posfrom, chars, tab_width, ambiguous_width)
return dispchrs, dispcols, positions, intervals
Build character informations from chars.

    Returns tuple of four lists. The first item is a list of characters to be
    displayed. Second item is a list of columns of each characters. Third item
    is a list of position in document of each characters. Last item is a list of
    interval from first column top of character of each character.
Build character informations from chars.
Build character informations from chars .
def translate_chars(posfrom, chars, tab_width, ambiguous_width):
    """Build character informations from chars.

    Returns tuple of four lists. The first item is a list of characters to be
    displayed. Second item is a list of columns of each characters. Third item
    is a list of position in document of each characters. Last item is a list of
    interval from first column top of character of each character.
    """

    curcol = 0
    dispchrs = ''
    dispcols = []
    positions = []
    intervals = []
    double_width = set('WF')
    if ambiguous_width == 2:
        double_width.add('A')

    pos = posfrom
# return chars, [1]*len(chars), [(posfrom+i) for i in range(len(chars))],
# [0]*len(chars)

    for c in chars:
        if c == '\t':
            dispstr = ' ' * (tab_width - (curcol % tab_width))
        elif (((c != '\n') and (c < '\x20'))  # control chars
              or (c == '\x7f')                     # backspace
              or ('\ud800' <= c <= '\udfff')):     # surrogate pair
            dispstr = repr(c)[1:-1]
        else:
            dispstr = c

        dispchrs += dispstr
        for i, d in enumerate(dispstr):
            positions.append(pos)
            intervals.append(i)
            # first char of line never be combined
            if curcol and is_combine(c):
                cols = 0
            else:
                w = east_asian_width(d)
                cols = 2 if w in double_width else 1
            dispcols.append(cols)
            curcol += cols
        pos += 1

# return chars, [1]*len(chars), [(posfrom+i) for i in range(len(chars))],
# [0]*len(chars)
    return dispchrs, dispcols, positions, intervals
def translate_chars ( posfrom , chars , tab_width , ambiguous_width ) : curcol = 0 dispchrs = '' dispcols = [ ] positions = [ ] intervals = [ ] double_width = set ( 'WF' ) if ambiguous_width == 2 : double_width . add ( 'A' ) pos = posfrom # return chars, [1]*len(chars), [(posfrom+i) for i in range(len(chars))], # [0]*len(chars) for c in chars : if c == '\t' : dispstr = ' ' * ( tab_width - ( curcol % tab_width ) ) elif ( ( ( c != '\n' ) and ( c < '\x20' ) ) # control chars or ( c == '\x7f' ) # backspace or ( '\ud800' <= c <= '\udfff' ) ) : # surrogate pair dispstr = repr ( c ) [ 1 : - 1 ] else : dispstr = c dispchrs += dispstr for i , d in enumerate ( dispstr ) : positions . append ( pos ) intervals . append ( i ) # first char of line never be combined if curcol and is_combine ( c ) : cols = 0 else : w = east_asian_width ( d ) cols = 2 if w in double_width else 1 dispcols . append ( cols ) curcol += cols pos += 1 # return chars, [1]*len(chars), [(posfrom+i) for i in range(len(chars))], # [0]*len(chars) return dispchrs , dispcols , positions , intervals