summaryrefslogtreecommitdiff
path: root/cmd2/ansi.py
diff options
context:
space:
mode:
Diffstat (limited to 'cmd2/ansi.py')
-rw-r--r--cmd2/ansi.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/cmd2/ansi.py b/cmd2/ansi.py
index 8980b1d4..7ae9016e 100644
--- a/cmd2/ansi.py
+++ b/cmd2/ansi.py
@@ -1,5 +1,5 @@
# coding=utf-8
-"""Support for ANSI escape codes which are used for things like applying style to text"""
+"""Support for ANSI escape sequences which are used for things like applying style to text"""
import functools
import re
from typing import Any
@@ -8,7 +8,7 @@ import colorama
from colorama import Fore, Back, Style
from wcwidth import wcswidth
-# Regular expression to match ANSI escape codes
+# Regular expression to match ANSI escape sequences
ANSI_ESCAPE_RE = re.compile(r'\x1b[^m]*m')
# Foreground color presets
@@ -55,10 +55,10 @@ BG_COLORS = {
def strip_ansi(text: str) -> str:
- """Strip ANSI escape codes from a string.
+ """Strip ANSI escape sequences from a string.
- :param text: string which may contain ANSI escape codes
- :return: the same string with any ANSI escape codes removed
+ :param text: string which may contain ANSI escape sequences
+ :return: the same string with any ANSI escape sequences removed
"""
return ANSI_ESCAPE_RE.sub('', text)
@@ -69,11 +69,11 @@ def ansi_safe_wcswidth(text: str) -> int:
:param text: the string being measured
"""
- # Strip ANSI escape codes since they cause wcswidth to return -1
+ # Strip ANSI escape sequences since they cause wcswidth to return -1
return wcswidth(strip_ansi(text))
-# ANSI escape strings not provided by colorama
+# ANSI escape sequences not provided by colorama
UNDERLINE_ENABLE = colorama.ansi.code_to_chars(4)
UNDERLINE_DISABLE = colorama.ansi.code_to_chars(24)
@@ -122,7 +122,7 @@ def style(text: Any, *, fg: str = '', bg: str = '', bold: bool = False, underlin
additions.append(UNDERLINE_ENABLE)
removals.append(UNDERLINE_DISABLE)
- # Combine the ANSI escape strings with the text
+ # Combine the ANSI escape sequences with the text
return "".join(additions) + text + "".join(removals)