From 227f266df78b143b0c5dd2c7f498b755199707eb Mon Sep 17 00:00:00 2001 From: troido Date: Mon, 13 Nov 2017 13:37:05 +0100 Subject: display parts now use windows as arguments --- asciifarm/client/display/infopad.py | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'asciifarm/client/display/infopad.py') diff --git a/asciifarm/client/display/infopad.py b/asciifarm/client/display/infopad.py index 564d6d4..7c9fef0 100644 --- a/asciifarm/client/display/infopad.py +++ b/asciifarm/client/display/infopad.py @@ -8,25 +8,32 @@ class InfoPad: def __init__(self, size=(1,1), *args): - self.pad = curses.newpad(size[1], size[0]) - self.size = size + #self.pad = curses.newpad(size[1], size[0]) + #self.size = size self.changed = False - self.lastView = None + self.lines = [] + #self.lastView = None def showString(self, string): - self.pad.clear() - self.pad.addstr(0,0,string) + self.lines = string.split('\n') + #self.pad.clear() + #self.pad.addstr(0,0,string) self.changed = True - def update(self, screen, x, y, xmax, ymax, force=False): - if not self.changed and (x, y, xmax, ymax) == self.lastView or xmax <= x or ymax <= y and not force: + def update(self, win, force=False): + if not self.changed and not force or not win: return - self.lastView = (x, y, xmax, ymax) + #self.lastView = (x, y, xmax, ymax) + height, width = win.getmaxyx() + lines = [line[:width] for line in self.lines][:height] + text = '\n'.join(lines) + win.erase() + win.addstr(0, 0, text) self.changed = False - self.pad.noutrefresh( - 0, - 0, - y, - x, - ymax-1, - xmax-1) + win.noutrefresh() + #0, + #0, + #y, + #x, + #ymax-1, + #xmax-1) -- cgit