|
43 | 43 |
|
44 | 44 | import colorama |
45 | 45 | from colorama import Fore |
46 | | -from wcwidth import wcswidth |
47 | 46 |
|
48 | 47 | from . import constants |
49 | 48 | from . import plugin |
@@ -1302,7 +1301,7 @@ def _display_matches_gnu_readline(self, substitution: str, matches: List[str], |
1302 | 1301 | longest_match_length = 0 |
1303 | 1302 |
|
1304 | 1303 | for cur_match in matches_to_display: |
1305 | | - cur_length = wcswidth(cur_match) |
| 1304 | + cur_length = utils.display_width(cur_match) |
1306 | 1305 | if cur_length > longest_match_length: |
1307 | 1306 | longest_match_length = cur_length |
1308 | 1307 | else: |
@@ -2662,7 +2661,7 @@ def _print_topics(self, header: str, cmds: List[str], verbose: bool) -> None: |
2662 | 2661 | widest = 0 |
2663 | 2662 | # measure the commands |
2664 | 2663 | for command in cmds: |
2665 | | - width = len(command) |
| 2664 | + width = utils.display_width(command) |
2666 | 2665 | if width > widest: |
2667 | 2666 | widest = width |
2668 | 2667 | # add a 4-space pad |
@@ -3478,14 +3477,14 @@ def async_alert(self, alert_msg: str, new_prompt: Optional[str] = None) -> None: |
3478 | 3477 | update_terminal = True |
3479 | 3478 |
|
3480 | 3479 | if update_terminal: |
3481 | | - # Remove ansi characters to get the visible width of the prompt |
3482 | | - prompt_width = wcswidth(utils.strip_ansi(current_prompt)) |
| 3480 | + # Get the display width of the prompt |
| 3481 | + prompt_width = utils.display_width(current_prompt) |
3483 | 3482 |
|
3484 | 3483 | # Get the size of the terminal |
3485 | 3484 | terminal_size = shutil.get_terminal_size() |
3486 | 3485 |
|
3487 | 3486 | # Figure out how many lines the prompt and user input take up |
3488 | | - total_str_size = prompt_width + wcswidth(readline.get_line_buffer()) |
| 3487 | + total_str_size = prompt_width + utils.display_width(readline.get_line_buffer()) |
3489 | 3488 | num_input_lines = int(total_str_size / terminal_size.columns) + 1 |
3490 | 3489 |
|
3491 | 3490 | # Get the cursor's offset from the beginning of the first input line |
|
0 commit comments