summaryrefslogtreecommitdiff
path: root/asciifarm/client/display/inventorypad.py
diff options
context:
space:
mode:
authortroido <troido@hotmail.com>2018-01-03 17:07:15 +0100
committertroido <troido@hotmail.com>2018-01-03 17:07:15 +0100
commit99d7920cb3daf3fc5cb6f824eb4a639542d47974 (patch)
tree62b2cbafbe2caf462fab7b7f4766c1d5eb63a8d8 /asciifarm/client/display/inventorypad.py
parent03d45d60b84c07c29a304301fb290aecee9cfa24 (diff)
added intermediary window wrapper for safety. also server now appends logs
Diffstat (limited to 'asciifarm/client/display/inventorypad.py')
-rw-r--r--asciifarm/client/display/inventorypad.py20
1 files changed, 6 insertions, 14 deletions
diff --git a/asciifarm/client/display/inventorypad.py b/asciifarm/client/display/inventorypad.py
index 595313c..cbfeff1 100644
--- a/asciifarm/client/display/inventorypad.py
+++ b/asciifarm/client/display/inventorypad.py
@@ -28,28 +28,20 @@ class InventoryPad:
def update(self):
win = self.widget.getWin()
- height, width = win.getmaxyx()
+ width, height = win.getSize()
height -= 1
selected = self.selector.getValue()
start = min(selected - height//2, len(self.items)-height)
start = max(start, 0)
end = start + height
win.erase()
- win.addstr(0,0, (self.title + ":")[:width])
+ win.addLine((0,0), (self.title + ":")[:width])
for i, item in enumerate(self.items[start:end]):
if i + start == selected:
- win.addstr(i+1, 0, '*')
- win.addstr(i+1, 1, item)
+ win.addLine((0, i+1), '*')
+ win.addLine((1, i+1), item)
if end < len(self.items):
- try:
- win.addstr(height, width-1, "+")
- except curses.error:
- # ncurses has a weird problem:
- # it always raises an error when drawing to the last character in the window
- # it draws first and then raises the error
- # therefore to draw in the last place of the window the last character needs to be ingored
- # other solutions might be possible, but are more hacky
- pass
+ win.addLine((width-1, height), "+")
if start > 0:
- win.addstr(1, width-1, "-")
+ win.addLine((width-1, 1), "-")
win.noutrefresh()