From 755290e43b67bb382ac4714980bad56a68649bc2 Mon Sep 17 00:00:00 2001 From: Roman Vrubel Date: Sun, 14 Jun 2026 21:16:54 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D0=B8=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=B2=D1=8B=D1=80=D0=B0=D0=B2=D0=BD=D0=B8=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5:=20=D0=BE=D0=B1=D1=80=D0=B5=D0=B7=D0=B0?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D0=B5=20=D0=B8=D0=BC=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=B4=D0=BE=D0=B1=D0=B8?= =?UTF-8?q?=D0=B2=D0=B0=D1=8E=D1=82=D1=81=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B1?= =?UTF-8?q?=D0=B5=D0=BB=D0=B0=D0=BC=D0=B8=20=D0=B4=D0=BE=20=D1=88=D0=B8?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D1=8B=20=D0=BA=D0=BE=D0=BB=D0=BE=D0=BD=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - _pad_col: после truncate + pad до точной ширины (не оставлял хвост) - _display_width: добавлены U+2026 (…) и U+2116 (№) в wide-символы --- bots/client_bot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bots/client_bot.py b/bots/client_bot.py index f224726..b3e06ea 100644 --- a/bots/client_bot.py +++ b/bots/client_bot.py @@ -50,7 +50,7 @@ def _display_width(s: str) -> int: cp = ord(ch) if (0x0400 <= cp <= 0x04FF or 0x0500 <= cp <= 0x052F or 0x2E80 <= cp <= 0x9FFF or 0xF900 <= cp <= 0xFAFF or - 0xFE30 <= cp <= 0xFE4F): + 0xFE30 <= cp <= 0xFE4F or cp in (0x2026, 0x2116)): w += 2 else: w += 1 @@ -60,7 +60,7 @@ def _display_width(s: str) -> int: def _pad_col(s: str, width: int) -> str: cur = _display_width(s) if cur > width: - # Truncate to fit: cut chars until it fits, add "…" + # Truncate to fit, then pad to exactly width result = [] w = 0 for ch in s: @@ -69,7 +69,9 @@ def _pad_col(s: str, width: int) -> str: break result.append(ch) w += cw - return ''.join(result) + '…' + truncated = ''.join(result) + '…' + pad_to = width - _display_width(truncated) + return truncated + ' ' * max(0, pad_to) return s + ' ' * (width - cur)