windows.base_wins: Type almost everything in this module.
This commit is contained in:
parent
db230d0b3e
commit
c2dbaba41f
1 changed files with 11 additions and 11 deletions
|
@ -26,22 +26,22 @@ format_chars = '\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x1A'
|
||||||
|
|
||||||
|
|
||||||
class DummyWin:
|
class DummyWin:
|
||||||
def __getattribute__(self, name):
|
def __getattribute__(self, name: str):
|
||||||
if name != '__bool__':
|
if name != '__bool__':
|
||||||
return lambda *args, **kwargs: (0, 0)
|
return lambda *args, **kwargs: (0, 0)
|
||||||
else:
|
else:
|
||||||
return object.__getattribute__(self, name)
|
return object.__getattribute__(self, name)
|
||||||
|
|
||||||
def __bool__(self):
|
def __bool__(self) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class Win:
|
class Win:
|
||||||
def __init__(self):
|
def __init__(self) -> None:
|
||||||
self._win = None
|
self._win = None
|
||||||
self.height, self.width = 0, 0
|
self.height, self.width = 0, 0
|
||||||
|
|
||||||
def _resize(self, height, width, y, x):
|
def _resize(self, height: int, width: int, y: int, x: int) -> None:
|
||||||
if height == 0 or width == 0:
|
if height == 0 or width == 0:
|
||||||
self.height, self.width = height, width
|
self.height, self.width = height, width
|
||||||
return
|
return
|
||||||
|
@ -53,16 +53,16 @@ class Win:
|
||||||
if self._win is None:
|
if self._win is None:
|
||||||
self._win = DummyWin()
|
self._win = DummyWin()
|
||||||
|
|
||||||
def resize(self, height: int, width: int, y: int, x: int):
|
def resize(self, height: int, width: int, y: int, x: int) -> None:
|
||||||
"""
|
"""
|
||||||
Override if something has to be done on resize
|
Override if something has to be done on resize
|
||||||
"""
|
"""
|
||||||
self._resize(height, width, y, x)
|
self._resize(height, width, y, x)
|
||||||
|
|
||||||
def _refresh(self):
|
def _refresh(self) -> None:
|
||||||
self._win.noutrefresh()
|
self._win.noutrefresh()
|
||||||
|
|
||||||
def addnstr(self, *args):
|
def addnstr(self, *args) -> None:
|
||||||
"""
|
"""
|
||||||
Safe call to addnstr
|
Safe call to addnstr
|
||||||
"""
|
"""
|
||||||
|
@ -74,7 +74,7 @@ class Win:
|
||||||
# of the screen.
|
# of the screen.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def addstr(self, *args):
|
def addstr(self, *args) -> None:
|
||||||
"""
|
"""
|
||||||
Safe call to addstr
|
Safe call to addstr
|
||||||
"""
|
"""
|
||||||
|
@ -83,13 +83,13 @@ class Win:
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def move(self, y: int, x: int):
|
def move(self, y: int, x: int) -> None:
|
||||||
try:
|
try:
|
||||||
self._win.move(y, x)
|
self._win.move(y, x)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def addstr_colored(self, text: str, y=None, x=None):
|
def addstr_colored(self, text: str, y: Optional[int] = None, x: Optional[int] = None) -> None:
|
||||||
"""
|
"""
|
||||||
Write a string on the window, setting the
|
Write a string on the window, setting the
|
||||||
attributes as they are in the string.
|
attributes as they are in the string.
|
||||||
|
@ -148,7 +148,7 @@ class Win:
|
||||||
next_attr_char = text.find(FORMAT_CHAR)
|
next_attr_char = text.find(FORMAT_CHAR)
|
||||||
self.addstr(text)
|
self.addstr(text)
|
||||||
|
|
||||||
def finish_line(self, color: Optional[Tuple] = None):
|
def finish_line(self, color: Optional[Tuple] = None) -> None:
|
||||||
"""
|
"""
|
||||||
Write colored spaces until the end of line
|
Write colored spaces until the end of line
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue