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'