aboutsummaryrefslogtreecommitdiffstats
path: root/vt100
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-10-20 00:31:02 -0400
committerJesse Luehrs <doy@tozt.net>2014-10-20 00:31:02 -0400
commit7739fef5e8bb6672a473a7b96f24ec72589b3758 (patch)
tree9598a47125d5360ecdae559b6655755b4df097cc /vt100
parente4fcdc25571ff04262541607ca4677bfb8a3aa72 (diff)
downloadlibvt100-python-7739fef5e8bb6672a473a7b96f24ec72589b3758.tar.gz
libvt100-python-7739fef5e8bb6672a473a7b96f24ec72589b3758.zip
add method to get the current cursor position
Diffstat (limited to 'vt100')
-rw-r--r--vt100/__init__.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/vt100/__init__.py b/vt100/__init__.py
index e9d3c9b..3d36d3d 100644
--- a/vt100/__init__.py
+++ b/vt100/__init__.py
@@ -109,10 +109,31 @@ class vt100_cell(Structure):
def is_wide(self):
return self._is_wide != 0
+class vt100_loc(Structure):
+ _fields_ = [
+ ("row", c_int),
+ ("col", c_int),
+ ]
+
+class vt100_grid(Structure):
+ _fields_ = [
+ ("_cur", vt100_loc),
+ ("_max", vt100_loc),
+ ("_saved", vt100_loc),
+ ("_selection_start", vt100_loc),
+ ("_selection_end", vt100_loc),
+ ("_scroll_top", c_int),
+ ("_scroll_bottom", c_int),
+ ("_row_count", c_int),
+ ("_row_capacity", c_int),
+ ("_row_top", c_int),
+ ("_rows", c_void_p),
+ ]
+
class vt100_screen(Structure):
_fields_ = [
- ("_grid", c_void_p),
- ("_alternate", c_void_p),
+ ("_grid", POINTER(vt100_grid)),
+ ("_alternate", POINTER(vt100_grid)),
("_title", c_char_p),
("_title_len", c_size_t),
("_icon_name", c_char_p),
@@ -179,6 +200,10 @@ class vt100(object):
return None
return vt100_cell.from_address(vt100_raw.cell_at(self.vt, x, y))
+ def cursor_pos(self):
+ pos = self.screen._grid.contents._cur
+ return pos.col, pos.row
+
def title(self):
return self.screen._title[:self.screen._title_len].decode('utf-8')