mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-05 20:40:09 -08:00
fix: clean up whitespace in display_width and print_table_row functions
This commit is contained in:
@@ -14,17 +14,17 @@ import unicodedata
|
|||||||
def display_width(text: str) -> int:
|
def display_width(text: str) -> int:
|
||||||
"""
|
"""
|
||||||
Calculate the actual display width of text, accounting for wide characters.
|
Calculate the actual display width of text, accounting for wide characters.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
text: Text to measure
|
text: Text to measure
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Display width in terminal columns
|
Display width in terminal columns
|
||||||
"""
|
"""
|
||||||
width = 0
|
width = 0
|
||||||
for char in text:
|
for char in text:
|
||||||
# East Asian Width property: 'F' (Fullwidth) and 'W' (Wide) take 2 columns
|
# East Asian Width property: 'F' (Fullwidth) and 'W' (Wide) take 2 columns
|
||||||
if unicodedata.east_asian_width(char) in ('F', 'W'):
|
if unicodedata.east_asian_width(char) in ("F", "W"):
|
||||||
width += 2
|
width += 2
|
||||||
else:
|
else:
|
||||||
width += 1
|
width += 1
|
||||||
@@ -98,7 +98,7 @@ def print_table_row(
|
|||||||
|
|
||||||
# Calculate display widths accounting for wide characters
|
# Calculate display widths accounting for wide characters
|
||||||
key_display_width = display_width(key)
|
key_display_width = display_width(key)
|
||||||
|
|
||||||
# Calculate actual value width based on terminal and key display width
|
# Calculate actual value width based on terminal and key display width
|
||||||
actual_value_width = max(20, term_width - key_display_width - 2)
|
actual_value_width = max(20, term_width - key_display_width - 2)
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ def print_table_row(
|
|||||||
# Print first line with properly aligned value
|
# Print first line with properly aligned value
|
||||||
first_line = value_lines[0]
|
first_line = value_lines[0]
|
||||||
first_line_display_width = display_width(first_line)
|
first_line_display_width = display_width(first_line)
|
||||||
|
|
||||||
# Use manual spacing to right-align based on display width
|
# Use manual spacing to right-align based on display width
|
||||||
spacing = term_width - key_display_width - first_line_display_width - 2
|
spacing = term_width - key_display_width - first_line_display_width - 2
|
||||||
if spacing > 0:
|
if spacing > 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user