summaryrefslogtreecommitdiff
path: root/asciifarm
diff options
context:
space:
mode:
Diffstat (limited to 'asciifarm')
-rw-r--r--asciifarm/client/display/screen.py3
-rw-r--r--asciifarm/client/display/window.py27
2 files changed, 15 insertions, 15 deletions
diff --git a/asciifarm/client/display/screen.py b/asciifarm/client/display/screen.py
index e806b2d..21d7200 100644
--- a/asciifarm/client/display/screen.py
+++ b/asciifarm/client/display/screen.py
@@ -52,7 +52,8 @@ class Screen:
def makeWin(self, x, y, width, height):
if width < 1 or height < 1:
win = None
- win = curses.newwin(height, width, y, x)
+ else:
+ win = curses.newwin(height, width, y, x)
return Window(win, self.colours)
def getWin(self, name):
diff --git a/asciifarm/client/display/window.py b/asciifarm/client/display/window.py
index 7723f7b..d5c3945 100644
--- a/asciifarm/client/display/window.py
+++ b/asciifarm/client/display/window.py
@@ -6,13 +6,8 @@ class Window:
def __init__(self, win, colours=None):
- self.setWin(win)
- self.colours = colours
-
-
-
- def setWin(self, win):
self.win = win
+ self.colours = colours
def getSize(self):
if not self.win:
@@ -30,6 +25,9 @@ class Window:
"""Draw a string that does not contain newlines or characters with larger width
long lines are cropped to fit in the window"""
+
+ if not self.win:
+ return
x, y = pos
width, height = self.getSize()
string = string[:width-x]
@@ -41,6 +39,8 @@ class Window:
def _addstr(self, y, x, string, *args):
+ if not self.win:
+ return
width, height = self.getSize()
if y == height-1 and x+len(string) == width:
if len(string) > 1:
@@ -58,18 +58,17 @@ class Window:
self.win.addstr(y, x, string, *args)
def erase(self):
- self.win.erase()
+ if self.win:
+ self.win.erase()
def noutrefresh(self):
- self.win.noutrefresh()
-
- def getCh(self, pos):
- x, y = pos
- return self.win.getch(y, x)
+ if self.win:
+ self.win.noutrefresh()
def setAttr(self, pos, attr, num=1):
- x, y = pos
- self.win.chgat(y, x, num, attr)
+ if self.win:
+ x, y = pos
+ self.win.chgat(y, x, num, attr)