From cf8922efe6b55bf64e5bcbe9642408a44c3a06a4 Mon Sep 17 00:00:00 2001 From: Adam Waldenberg Date: Mon, 6 May 2013 00:47:51 +0200 Subject: [PATCH] Implemented a fallback mode for terminals that report zero width/size. --- terminal.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/terminal.py b/terminal.py index 1fe845a..a519aba 100644 --- a/terminal.py +++ b/terminal.py @@ -86,12 +86,18 @@ def printb(string): print(__bold__ + string + __normal__) def get_size(): + width = 0 + height = 0 + if sys.stdout.isatty(): current_os = platform.system() if current_os == 'Windows': - return __get_size_windows__() + (width, height) = __get_size_windows__() elif current_os == 'Linux' or current_os == 'Darwin' or current_os.startswith('CYGWIN'): - return __get_size_linux__() + (width, height) = __get_size_linux__() + + if width > 0 and height > 0: + return (width, height) return (80, 25)