aboutsummaryrefslogtreecommitdiff
path: root/__init__.py
diff options
context:
space:
mode:
authorJakob Stendahl <jakob.stendahl@outlook.com>2019-08-15 15:43:55 +0200
committerJakob Stendahl <jakob.stendahl@outlook.com>2019-08-15 15:43:55 +0200
commitc6d2d3deb9267e3bed1a3aa4514fb98d2d1a63f8 (patch)
tree11e5a86999154cd3545f8c564be022357bbc509a /__init__.py
parent4a6e117c9425b4b7ec0875b654c20ea92d3d7ce0 (diff)
downloadTermIO-python-package-c6d2d3deb9267e3bed1a3aa4514fb98d2d1a63f8.tar.gz
TermIO-python-package-c6d2d3deb9267e3bed1a3aa4514fb98d2d1a63f8.zip
:wrench: Add better way to get terminal size
Diffstat (limited to '__init__.py')
-rw-r--r--__init__.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/__init__.py b/__init__.py
index e01228a..fef84d4 100644
--- a/__init__.py
+++ b/__init__.py
@@ -3,4 +3,21 @@ from .out import *
import os
-rows, columns = map(int, os.popen('stty size', 'r').read().split())
+class TermSizeSkeleton:
+
+ def __init__(self):
+ self.Update()
+
+ def Update(self):
+ self.Rows, self.Columns = map(int, os.popen('stty size', 'r').read().split())
+
+ def Rows(self, Update=True):
+ if Update: self.Update()
+ return self.Rows
+
+ def Columns(self, Update=True):
+ if Update: self.Update()
+ return self.Rows
+
+
+TermSize = TermSizeSkeleton()