<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def draw(self, writer, idx, offset):
 """ Draw the current page view to ``writer``. :param writer: callable writes to output stream, receiving unicode. :type writer: callable :param idx: current page index. :type idx: int :param offset: scrolling region offset of current page. :type offset: int :returns: tuple of next (idx, offset). :rtype: (int, int) """

        # as our screen can be resized while we're mid-calculation,
        # our self.dirty flag can become re-toggled; because we are
        # not re-flowing our pagination, we must begin over again.
        while self.dirty:
            self.draw_heading(writer)
            self.dirty = self.STATE_CLEAN
            (idx, offset), data = self.page_data(idx, offset)
            for txt in self.page_view(data):
                writer(txt)
        self.draw_status(writer, idx)
        flushout()
        return idx, offset