diff options
| author | troido <troido@hotmail.com> | 2017-12-30 01:35:41 +0100 |
|---|---|---|
| committer | troido <troido@hotmail.com> | 2017-12-30 01:35:41 +0100 |
| commit | b63f38d654814d6be7a56ee7c8c6c6567755e0b4 (patch) | |
| tree | 8cc169590bccda80f1d3d246166f002d84cb5fba /asciifarm/client/display/messagepad.py | |
| parent | 29149f398986620cf13ba1fc4d2d7cca139bead0 (diff) | |
tried a new approach to remove code duplication in display
Diffstat (limited to 'asciifarm/client/display/messagepad.py')
| -rw-r--r-- | asciifarm/client/display/messagepad.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/asciifarm/client/display/messagepad.py b/asciifarm/client/display/messagepad.py index d5de5a9..c9eaf85 100644 --- a/asciifarm/client/display/messagepad.py +++ b/asciifarm/client/display/messagepad.py @@ -7,19 +7,17 @@ class MessagePad(): def __init__(self): self.changed = False self.messages = [] - self.win = None + self.widget = None - def setWin(self, win): - self.win = win + def setWidget(self, widget): + self.widget = widget def addMessage(self, message): self.messages.append(message) - self.changed = True + self.widget.change() - def update(self, force): - if not self.changed and not force or not self.win: - return - win = self.win + def update(self): + win = self.widget.getWin() height, width = win.getmaxyx() if height < 1: return @@ -30,5 +28,4 @@ class MessagePad(): lines = lines[len(lines)-height:] win.erase() win.addstr(0,0,'\n'.join(lines)) - self.changed = False win.noutrefresh() |
