diff options
author | Philip Matura <philip.matura@gmx.de> | 2019-10-11 21:11:00 +0200 |
---|---|---|
committer | Tony Cebzanov <tonycpsu@gmail.com> | 2019-11-05 21:46:18 -0500 |
commit | 038f99caf973a5d6c5ae62ffc54149941128abe6 (patch) | |
tree | e78b6121a99014b5651bd98ab8dabc1ca9b1423e | |
parent | 8bd73294ac9e80df7daf698b9c6aab51d4106f6e (diff) | |
download | urwid-038f99caf973a5d6c5ae62ffc54149941128abe6.tar.gz |
Implement get_cursor_coords for Frame widget
-rwxr-xr-x | urwid/container.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/urwid/container.py b/urwid/container.py index a26be28..7b54b0e 100755 --- a/urwid/container.py +++ b/urwid/container.py @@ -1171,6 +1171,33 @@ class Frame(Widget, WidgetContainerMixin): return self.body.mouse_event( (maxcol, maxrow-htrim-ftrim), event, button, col, row-htrim, focus ) + def get_cursor_coords(self, size): + """Return the cursor coordinates of the focus widget.""" + if not self.focus.selectable(): + return None + if not hasattr(self.focus, 'get_cursor_coords'): + return None + + fp = self.focus_position + (maxcol, maxrow) = size + (hrows, frows), _ = self.frame_top_bottom(size, True) + + if fp == 'header': + row_adjust = 0 + coords = self.header.get_cursor_coords((maxcol,)) + elif fp == 'body': + row_adjust = hrows + coords = self.body.get_cursor_coords((maxcol, maxrow-hrows-frows)) + else: + row_adjust = maxrow - frows + coords = self.footer.get_cursor_coords((maxcol,)) + + if coords is None: + return None + + x, y = coords + return x, y + row_adjust + def __iter__(self): """ Return an iterator over the positions in this Frame top to bottom. |