'Selects top and bottom margins for the scrolling region.
Margins determine which screen lines move during scrolling
(see :meth:`index` and :meth:`reverse_index`). Characters added
outside the scrolling region do not cause the screen to scroll.
:param int top: the smallest line number that is scrolled.
:param int bottom: the biggest line number that is scrolled.'

def set_margins(self, top=None, bottom=None):

    if ((top is None) or (bottom is None)):
        return
    top = max(0, min((top - 1), (self.lines - 1)))
    bottom = max(0, min((bottom - 1), (self.lines - 1)))
    if ((bottom - top) >= 1):
        self.margins = Margins(top, bottom)
        self.cursor_position()
