From 23fb38b807581e4677c5c6b20f07ddc3cb3d930c Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Tue, 29 Aug 2023 12:51:08 +0200 Subject: [PATCH] fix wrapping --- hn.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hn.py b/hn.py index 04062d5..633f2ef 100755 --- a/hn.py +++ b/hn.py @@ -58,11 +58,10 @@ def main(stdscr): # calculate length of line text = f'{prefix} ()\n' chars_available = width - len(text) - max_title_len = (chars_available//3)*2 - max_url_len = chars_available//3 + max_title_len = min((chars_available//3)*2, len(story.title)) + max_url_len = chars_available - max_title_len text = f'{prefix}{(story.title[:max_title_len-1] + "…") if len(story.title) > max_title_len else story.title} ({story.link[:max_url_len-1] + "…" if len(story.link) > max_url_len else story.link})\n' - stdscr.addstr(text) if i == current_pos: detail = f' by {story.author} | {story.comments} comments | {story.votes} points\n'