Added vertical and horizontal lines as display elements

This commit is contained in:
Nicolas Margulies 2020-11-20 16:52:04 +01:00
parent 62599ea72c
commit 7e63607836
1 changed files with 40 additions and 0 deletions

View File

@ -50,3 +50,43 @@ class Display:
@property
def cols(self) -> int:
return curses.COLS if self.screen else 42
class VerticalSplit(Display):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.pad = self.newpad(self.rows, 1)
@property
def width(self) -> int:
return 1
@width.setter
def width(self, val: Any) -> None:
pass
def display(self) -> None:
for i in range(self.height):
self.pad.addstr(i, 0, "")
self.pad.refresh(0, 0, self.y, self.x, self.y + self.height, self.x)
class HorizontalSplit(Display):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.pad = self.newpad(1, self.cols)
@property
def height(self) -> int:
return 1
@height.setter
def height(self, val: Any) -> None:
pass
def display(self) -> None:
for i in range(self.width):
self.pad.addstr(0, i, "")
self.pad.refresh(0, 0, self.y, self.x, self.y, self.x + self.width)