auto_wrap¶
Module Contents¶
- class CharType¶
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- SPACE¶
- ASIAN¶
- LATIN¶
- class TextWrap¶
Text wrap
- EAST_ASAIN_WIDTH_TABLE¶
- classmethod get_width(char: str) int ¶
Returns the width of the char
- classmethod get_text_width(text: str) int ¶
Returns the width of the text
- classmethod process_text_whitespace(text: str) str ¶
Process whitespace and leading and trailing spaces in strings
- classmethod split_long_token(token: str, width: int) List[str] ¶
Split long token into smaller chunks.
- classmethod tokenizer(text: str)¶
tokenize line
- classmethod wrap(text: str, width: int, once: bool = True) Tuple[str, bool] ¶
Wrap according to string length
Parameters¶
- text: str
the text to be wrapped
- width: int
the maximum length of a single line, the length of Chinese characters is 2
- once: bool
whether to wrap only once
Returns¶
- wrap_text: str
text after auto word wrap process
- is_wrapped: bool
whether a line break occurs in the text