auto_wrap#

Module Contents#

CharType

Generic enumeration.

TextWrap

文本折叠类

class CharType#

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

SPACE#
ASIAN#
LATIN#
class TextWrap#

文本折叠类

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 get_char_type(char: str) CharType#

Returns the type of the char

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]#

根据指定最大长度进行折叠

参数#

text: str

将被折叠的字符串

width: int

单行的最大长度,英文字符长度为 1,其他字符长度为 2

once: bool

是否只换行一次

返回值#

wrap_text: str

折叠处理后的字符串

is_wrapped: bool

原始字符串是否发生折叠