Skip to content

Commit d860ced

Browse files
authored
switch to using shutil.get_terminal_size() for compatibility with embeded terminals (#48)
1 parent 42015fc commit d860ced

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

common/util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Utility functions."""
22

3-
import os
43
from typing import List, Any
54
import re
5+
import shutil
66

77
from lldb import SBError, SBFrame, SBMemoryRegionInfo, SBMemoryRegionInfoList, SBProcess, SBValue
88

@@ -34,7 +34,7 @@ def clear_page() -> None:
3434
Used to clear the previously printed breakpoint information before
3535
printing the next information.
3636
"""
37-
num_lines = os.get_terminal_size().lines
37+
num_lines = shutil.get_terminal_size().lines
3838
for _ in range(num_lines):
3939
print()
4040
print("\033[0;0H") # Ansi escape code: Set cursor to 0,0 position
@@ -49,7 +49,7 @@ def print_line_with_string(
4949
align: ALIGN = ALIGN.RIGHT,
5050
) -> None:
5151
"""Print a line with the provided @string padded with @char"""
52-
width = os.get_terminal_size().columns
52+
width = shutil.get_terminal_size().columns
5353
if align == ALIGN.RIGHT:
5454
l_pad = (width - len(string) - 6) * char.value
5555
r_pad = 4 * char.value
@@ -73,7 +73,7 @@ def print_line(
7373
) -> None:
7474
"""Print a line of @char"""
7575
output_line(
76-
f"{color.value}{os.get_terminal_size().columns*char.value}{TERM_COLORS.ENDC.value}"
76+
f"{color.value}{shutil.get_terminal_size().columns*char.value}{TERM_COLORS.ENDC.value}"
7777
)
7878

7979

0 commit comments

Comments
 (0)