b.u.UTextWrapper(textwrap.TextWrapper) : class documentation

Part of bzrlib.utextwrap View In Hierarchy

Extend TextWrapper for Unicode.

This textwrapper handles east asian double width and split word
even if !break_long_words when word contains double width

:param ambiguous_width: (keyword argument) width for character when
                        unicodedata.east_asian_width(c) == 'A'
                        (default: 1)

* expand_tabs doesn't fixed. It uses len() for calculating width
  of string on left of TAB.
* Handles one codeunit as a single character having 1 or 2 width.
  This is not correct when there are surrogate pairs, combined
  characters or zero-width characters.
* Treats all asian character are line breakable. But it is not
  true because line breaking is prohibited around some characters.
  (For example, breaking before punctation mark is prohibited.)
Method __init__ Undocumented
Method wrap Undocumented
Method _unicode_char_width Return width of character uc.
Method _width Returns width for s.
Method _cut Returns head and rest of s. (head+rest == s)
Method _fix_sentence_endings _fix_sentence_endings(chunks : [string])
Method _handle_long_word Undocumented
Method _wrap_chunks Undocumented
Method _split Undocumented
def __init__(self, width=None, **kwargs):
def _unicode_char_width(self, uc):
Return width of character uc.
Parametersuc Single unicode character.
def _width(self, s):
Returns width for s.

When s is unicode, take care of east asian width. When s is bytes, treat all byte is single width character.

def _cut(self, s, width):
Returns head and rest of s. (head+rest == s)

Head is large as long as _width(head) <= width.

def _fix_sentence_endings(self, chunks):
_fix_sentence_endings(chunks : [string])

        Correct for sentence endings buried in 'chunks'.  Eg. when the
        original text contains "... foo.
Bar ...", munge_whitespace()
        and split() will convert that to [..., "foo.", " ", "Bar", ...]
        which has one too few spaces; this method simply changes the one
        space to two.

        Note: This function is copied from textwrap.TextWrap and modified
        to use unicode always.
def _handle_long_word(self, chunks, cur_line, cur_len, width):
def _wrap_chunks(self, chunks):
def _split(self, text):
def wrap(self, text):
API Documentation for Bazaar, generated by pydoctor at 2021-10-21 00:29:00.