diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-12-19 17:00:29 -0500 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-12-19 17:00:29 -0500 |
commit | b0e5aabad9c902ee5d664bf58885245060114f61 (patch) | |
tree | daf52ea8ffc62dc3eff706109c9d21ac9b69e197 /cmd2/utils.py | |
parent | 1a26c0254b2c2834998b8a28f04e8aedc08c587f (diff) | |
download | cmd2-git-b0e5aabad9c902ee5d664bf58885245060114f61.tar.gz |
Renamed ansi_safe_wcswidth() to style_aware_wcswidth()
Renamed ansi_aware_write() to style_aware_write()
Diffstat (limited to 'cmd2/utils.py')
-rw-r--r-- | cmd2/utils.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py index ddb9f3b5..ffbe5a64 100644 --- a/cmd2/utils.py +++ b/cmd2/utils.py @@ -669,7 +669,7 @@ def align_text(text: str, alignment: TextAlignment, *, fill_char: str = ' ', if len(fill_char) != 1: raise TypeError("Fill character must be exactly one character long") - fill_char_width = ansi.ansi_safe_wcswidth(fill_char) + fill_char_width = ansi.style_aware_wcswidth(fill_char) if fill_char_width == -1: raise (ValueError("Fill character is an unprintable character")) @@ -687,9 +687,9 @@ def align_text(text: str, alignment: TextAlignment, *, fill_char: str = ' ', if index > 0: text_buf.write('\n') - # Use ansi_safe_wcswidth to support characters with display widths + # Use style_aware_wcswidth to support characters with display widths # greater than 1 as well as ANSI style sequences - line_width = ansi.ansi_safe_wcswidth(line) + line_width = ansi.style_aware_wcswidth(line) if line_width == -1: raise(ValueError("Text to align contains an unprintable character")) @@ -717,8 +717,8 @@ def align_text(text: str, alignment: TextAlignment, *, fill_char: str = ' ', # In cases where the fill character display width didn't divide evenly into # the gaps being filled, pad the remainder with spaces. - left_fill += ' ' * (left_fill_width - ansi.ansi_safe_wcswidth(left_fill)) - right_fill += ' ' * (right_fill_width - ansi.ansi_safe_wcswidth(right_fill)) + left_fill += ' ' * (left_fill_width - ansi.style_aware_wcswidth(left_fill)) + right_fill += ' ' * (right_fill_width - ansi.style_aware_wcswidth(right_fill)) text_buf.write(left_fill + line + right_fill) |