From a181fc512885f65840dfe4f8bfca4ca5e60f1428 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 2 Apr 2026 02:14:37 -0400 Subject: [PATCH] play.py: word-wrapped multi-line track descriptions in picker Co-Authored-By: Claude Opus 4.6 (1M context) --- play.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/play.py b/play.py index e02c524..eb0b1bf 100644 --- a/play.py +++ b/play.py @@ -448,15 +448,33 @@ def pick_track(): stdscr.addstr(y, 8 + name_col, meta_str, curses.A_DIM) - # Description of selected track + # Description of selected track — word-wrapped _, _, _, _, _, _, desc = entries[selected[0]] if desc: desc_y = list_start + len(entries) + 1 - if desc_y < h - 2: - # Wrap description to fit width - desc = desc[:w - 6] - stdscr.addstr(desc_y, 3, desc, - curses.A_DIM | curses.color_pair(3)) + max_w = w - 8 + if desc_y < h - 2 and max_w > 20: + # Word wrap + words = desc.split() + lines = [] + line = "" + for word in words: + if len(line) + len(word) + 1 > max_w: + lines.append(line) + line = word + else: + line = f"{line} {word}" if line else word + if line: + lines.append(line) + for li, text in enumerate(lines): + y_pos = desc_y + li + if y_pos >= h - 1: + break + try: + stdscr.addstr(y_pos, 4, text, + curses.A_DIM | curses.color_pair(3)) + except curses.error: + pass stdscr.refresh() curses.napms(50)