'Collect and return the contents of the window.'

def gather(self):

    result = ''
    for y in range((self.maxy + 1)):
        self.win.move(y, 0)
        stop = self._end_of_line(y)
        if ((stop == 0) and self.stripspaces):
            continue
        for x in range((self.maxx + 1)):
            if (self.stripspaces and (x > stop)):
                break
            result = (result + chr(curses.ascii.ascii(self.win.inch(y, x))))
        if (self.maxy > 0):
            result = (result + '\n')
    return result
