'Get context lines, starting at new_topvisible and working backwards.
Stop when stopline or stopindent is reached. Return a tuple of context
data and the indent level at the top of the region inspected.'

def get_context(self, new_topvisible, stopline=1, stopindent=0):

    lines = []
    lastindent = INFINITY
    for linenum in xrange(new_topvisible, (stopline - 1), (-1)):
        (indent, text, opener) = self.get_line_info(linenum)
        if (indent < lastindent):
            lastindent = indent
            if (opener in ('else', 'elif')):
                lastindent += 1
            if (opener and (linenum < new_topvisible) and (indent >= stopindent)):
                lines.append((linenum, indent, text, opener))
            if (lastindent <= stopindent):
                break
    lines.reverse()
    return (lines, lastindent)
