ui/curses: add curses interface draft

This commit is contained in:
rr-
2019-01-03 21:38:19 +01:00
parent 81f6dbede2
commit ca7ab192c5
32 changed files with 1413 additions and 18 deletions
+41
View File
@@ -0,0 +1,41 @@
import curses
import typing as T
class Widget:
def __del__(self) -> None:
self.stop()
def stop(self) -> None:
pass
class WindowWrapper(Widget):
def __init__(
self, parent: T.Optional[T.Any], h: int, w: int, y: int, x: int
) -> None:
self._parent = parent
self._win: T.Optional[T.Any]
if not parent:
self._win = None
else:
try:
self._win = parent.derwin(h, w, y, x)
self._win.refresh()
except curses.error:
self._win = None
def stop(self) -> None:
del self._win
self._win = None
def getbegyx(self) -> T.Tuple[int, int]:
if not self._win:
return (0, 0)
return self._win.getbegyx()
def getmaxyx(self) -> T.Tuple[int, int]:
if not self._win:
return (0, 0)
return self._win.getmaxyx()