diff options
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r-- | cmd2/utils.py | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py index 3e28641d..812fa227 100644 --- a/cmd2/utils.py +++ b/cmd2/utils.py @@ -12,30 +12,9 @@ import threading import unicodedata from typing import Any, Iterable, List, Optional, TextIO, Union -from wcwidth import wcswidth - from . import constants -def strip_ansi(text: str) -> str: - """Strip ANSI escape codes from a string. - - :param text: string which may contain ANSI escape codes - :return: the same string with any ANSI escape codes removed - """ - return constants.ANSI_ESCAPE_RE.sub('', text) - - -def ansi_safe_wcswidth(text: str) -> int: - """ - Wraps wcswidth to make it compatible with colored strings - - :param text: the string being measured - """ - # Strip ANSI escape codes since they cause wcswidth to return -1 - return wcswidth(strip_ansi(text)) - - def is_quoted(arg: str) -> bool: """ Checks if a string is quoted @@ -382,7 +361,7 @@ def center_text(msg: str, *, pad: str = ' ') -> str: """Centers text horizontally for display within the current terminal, optionally padding both sides. :param msg: message to display in the center - :param pad: (optional) if provided, the first character will be used to pad both sides of the message + :param pad: if provided, the first character will be used to pad both sides of the message :return: centered message, optionally padded on both sides with pad_char """ term_width = shutil.get_terminal_size().columns |