Skip to content

Commit 4a34cf6

Browse files
committed
Improve hyrex studio formatting
1 parent e82e6fe commit 4a34cf6

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

hyrex/hyrex_studio_server.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,30 @@ def create_box(lines, box_color="brightCyan", width=55, style="double"):
7070
for text, txt_color in lines:
7171
if text == "":
7272
line = chars["v"] + " " * width + chars["v"]
73+
print(colorize(" " + line, box_color))
7374
else:
74-
pad = width - len(text)
75+
# Count emojis that take 2 columns in terminal
76+
double_width_chars = ['🚀', '🌐', '👉', '👈', '✨', '●', '✓', '✗']
77+
emoji_count = sum(text.count(emoji) for emoji in double_width_chars)
78+
79+
# Calculate display width: regular chars + extra width for emojis
80+
display_width = len(text) + emoji_count
81+
82+
# Calculate padding based on display width
83+
pad = width - display_width
7584
left = pad // 2
7685
right = pad - left
77-
line = (
78-
chars["v"]
79-
+ " " * left
80-
+ colorize(text, txt_color)
81-
+ " " * right
82-
+ chars["v"]
86+
87+
# Build the complete line structure first
88+
box_left = " " + chars["v"] + " " * left
89+
box_right = " " * right + chars["v"]
90+
91+
# Print with proper coloring
92+
print(
93+
colorize(box_left, box_color)
94+
+ (colorize(text, txt_color) if txt_color else text)
95+
+ colorize(box_right, box_color)
8396
)
84-
print(colorize(" " + line, box_color))
8597
print(colorize(" " + bottom, box_color))
8698

8799

0 commit comments

Comments
 (0)