Implements get_cursor_coords for container.py::Frame. Apparently I like using BoxAdapters and putting weird, "top window" widgets into list boxes. :-)
-Jon
# HG changeset patch # User Jon McManus <[email protected]> # Date 1292805388 -36000 # Node ID 7bf8285c343377a6154267c4933ab1b09f25902c # Parent 7294418abe37eacdb38cc53f17b1959db5bde371 Implement get_cursor_coords for container.py::Frame. Attempts to return the result of get_cursor_coords for the current focus part, if the current focus part has a get_cursor_coords method. diff -r 7294418abe37 -r 7bf8285c3433 urwid/container.py --- a/urwid/container.py Sat Aug 21 08:33:44 2010 -0400 +++ b/urwid/container.py Mon Dec 20 10:36:28 2010 +1000 @@ -659,7 +659,31 @@ return self.body.mouse_event( (maxcol, maxrow-htrim-ftrim), event, button, col, row-htrim, focus ) - + def get_cursor_coords (self, size): + """ + Return the cursor co-ordinates of the widget in focus, if any. + """ + (maxcol, maxrow) = size + + (htrim, ftrim), (hrows, frows) = self.frame_top_bottom(size, True) + + if self.header is not None and self.focus_part == 'header' and hasattr(self.header, "get_cursor_coords"): + if htrim and htrim < hrows: + return self.header.get_cursor_coords((maxcol, htrim)) + + return self.header.get_cursor_coords((maxcol, )) + + if self.footer is not None and self.focus_part == 'footer' and hasattr(self.footer, "get_cursor_coords"): + if ftrim and ftrim < frows: + return self.footer.get_cursor_coords((maxcol, ftrim)) + + return self.footer.get_cursor_coords((maxcol, )) + + if self.focus_part == 'body' and hasattr(self.body, "get_cursor_coords"): + bcol, brow = self.body.get_cursor_coords((maxcol, maxrow-htrim-ftrim)) + return (bcol, brow+hrows) + + return None class PileError(Exception): pass
_______________________________________________ Urwid mailing list [email protected] http://lists.excess.org/mailman/listinfo/urwid
