2020-11-06 15:34:24 +01:00
|
|
|
import curses
|
2020-11-08 23:40:03 +01:00
|
|
|
from typing import Any, Union
|
|
|
|
|
2020-11-10 18:08:06 +01:00
|
|
|
from typing import Any
|
2020-11-08 23:40:03 +01:00
|
|
|
from dungeonbattle.tests.screen import FakePad
|
2020-11-10 18:08:06 +01:00
|
|
|
|
2020-11-06 15:34:24 +01:00
|
|
|
|
|
|
|
class Display:
|
2020-11-10 18:08:06 +01:00
|
|
|
def __init__(self, screen: Any, pack: Any):
|
2020-11-06 15:34:24 +01:00
|
|
|
self.screen = screen
|
2020-11-10 18:08:06 +01:00
|
|
|
self.pack = pack
|
2020-11-08 23:40:03 +01:00
|
|
|
|
|
|
|
def newpad(self, height: int, width: int) -> Union[FakePad, Any]:
|
2020-11-08 23:48:26 +01:00
|
|
|
return curses.newpad(height, width) if self.screen else FakePad()
|
2020-11-09 00:44:08 +01:00
|
|
|
|
2020-11-10 18:08:06 +01:00
|
|
|
def resize(self, y, x, height, width):
|
|
|
|
self.x = x
|
|
|
|
self.y = y
|
|
|
|
self.width = width
|
|
|
|
self.height = height
|
|
|
|
|
|
|
|
def refresh(self, *args):
|
|
|
|
if len(args) == 4:
|
|
|
|
self.resize(*args)
|
|
|
|
self.display()
|
|
|
|
|
|
|
|
def display(self):
|
|
|
|
pass
|
2020-11-09 00:44:08 +01:00
|
|
|
|
|
|
|
@property
|
|
|
|
def rows(self) -> int:
|
|
|
|
return curses.LINES if self.screen else 42
|
|
|
|
|
|
|
|
@property
|
|
|
|
def cols(self) -> int:
|
|
|
|
return curses.COLS if self.screen else 42
|