mirror of
https://github.com/rr-/pq-cli.git
synced 2026-09-28 22:33:59 -06:00
ui/curses: add curses interface draft
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user