

def getregion(self, region=None, truncate=True):
    if (region is None):
        return (0, 0, self._width, self._height)
    elif ((type(region) in (tuple, list)) and (len(region) == 4)):
        (x, y, width, height) = region
        if (x == y == width == height == None):
            return (0, 0, self._width, self._height)
        elif (width == height == None):
            width = (self._width - x)
            height = (self._height - y)
    elif (str(type(region)) in ("<class 'pygame.Color'>", "<type 'pygame.Color'>")):
        (x, y, width, heigh) = (region.x, region.y, region.width, region.height)
    if ((width < 1) or (height < 1)):
        return (None, None, None, None)
    if (not truncate):
        return (x, y, width, height)
    if (((x + width) < 0) or ((y + height) < 0) or (x >= self._width) or (y >= self._height)):
        return (None, None, None, None)
    if ((x + width) > self._width):
        width -= ((x + width) - self._width)
    if ((y + height) > self._height):
        height -= ((y + height) - self._height)
    if (x < 0):
        width += x
        x = 0
    if (y < 0):
        height += y
        y = 0
    return (x, y, width, height)

dataset/ETHPy150Open asweigart/pygcurse/pygcurse/__init__.py PygcurseSurface.getregion/original