summaryrefslogtreecommitdiff
path: root/asciifarm/client/display/infopad.py
blob: c98b7cd2c6a69a1f2aa1bd2c65b12a4541fd006b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

import curses



class InfoPad:
    
    
    
    def __init__(self):
        self.changed = False
        self.lines = []
    
    def showString(self, string):
        self.lines = string.split('\n')
        self.changed = True
    
    def update(self, win, force):
        if not self.changed and not force or not win:
            return
        height, width = win.getmaxyx()
        lines = [line[:width-1] for line in self.lines][:height]
        text = '\n'.join(lines)
        win.erase()
        win.addstr(0, 0, text)
        self.changed = False
        win.noutrefresh()