From a367f78cbbfcab34b5328be160721bc738e31431 Mon Sep 17 00:00:00 2001 From: Derek Schmidt Date: Thu, 28 Feb 2019 18:22:54 -0700 Subject: [PATCH] Handle screen position when newline only lines exist --- toot/ui/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/toot/ui/utils.py b/toot/ui/utils.py index 2e198c4..1365198 100644 --- a/toot/ui/utils.py +++ b/toot/ui/utils.py @@ -51,10 +51,15 @@ def size_as_drawn(lines, screen_width): y = 0 x = 0 for line in lines: - for wrapped_line in wc_wrap(line, screen_width): - x = len(wrapped_line) + wrapped = list(wc_wrap(line, screen_width)) + if len(wrapped) > 0: + for wrapped_line in wrapped: + x = len(wrapped_line) + y += 1 + else: + x = 0 y += 1 - return y - 1, x - 1 + return y - 1, x - 1 if x != 0 else 0 def draw_lines(window, lines, start_y, padding, default_color):