diff options
-rw-r--r-- | README.md | 16 | ||||
-rw-r--r-- | __init__.py | 19 |
2 files changed, 30 insertions, 5 deletions
@@ -9,11 +9,19 @@ had good with bash. import TermIO ``` -## var `TermIO.rows` -Rows in the terminal. Not updating as of now... +## func `TermIO.TermSize.Rows(Update=True)` +Returns rows in terminal as an int. +``` +Update : BOOL, should you check the terminal size again, or just [True] + assume that it hasn't changed since last check. +``` -## var `TermIO.columns` -Number of columns in the terminal. Not updating either... +## func `TermIO.TermSize.Columns(Update=True)` +Returns Columns in terminal as an int. +``` +Update : BOOL, should you check the terminal size again, or just [True] + assume that it hasn't changed since last check. +``` ## func `TermIO.Cursor.SetPos(col, row, flush=True)` Set cursor to a spesific column and row in the terminal. 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() |