aboutsummaryrefslogtreecommitdiff
path: root/termo.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-10-22 22:23:01 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-10-22 22:23:01 +0200
commitf1f9a00cda728eabd833e81e14cc7606bb34986a (patch)
treeae3b4e37a4c0e20778896dec1d049626b91b7bf2 /termo.c
parent70bcfde0212b4009467f8551c197743b70355b99 (diff)
downloadtermo-f1f9a00cda728eabd833e81e14cc7606bb34986a.tar.gz
termo-f1f9a00cda728eabd833e81e14cc7606bb34986a.tar.xz
termo-f1f9a00cda728eabd833e81e14cc7606bb34986a.zip
Add support for setting the mouse protocol
Diffstat (limited to 'termo.c')
-rw-r--r--termo.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/termo.c b/termo.c
index 6970a82..a9addc4 100644
--- a/termo.c
+++ b/termo.c
@@ -313,6 +313,14 @@ termo_alloc (void)
tk->method.emit_codepoint = &emit_codepoint;
tk->method.peekkey_simple = &peekkey_simple;
tk->method.peekkey_mouse = &peekkey_mouse;
+
+ tk->mouse_proto = TERMO_MOUSE_PROTO_NONE;
+ tk->mouse_tracking = TERMO_MOUSE_TRACKING_NORMAL;
+ tk->guessed_mouse_proto = TERMO_MOUSE_PROTO_NONE;
+
+ tk->ti_data = NULL;
+ tk->ti_method.set_mouse_proto = NULL;
+ tk->ti_method.set_mouse_tracking_mode = NULL;
return tk;
}
@@ -625,6 +633,52 @@ termo_get_buffer_remaining (termo_t *tk)
return tk->buffsize - tk->buffcount;
}
+int
+termo_get_mouse_proto (termo_t *tk)
+{
+ return tk->mouse_proto;
+}
+
+int
+termo_guess_mouse_proto (termo_t *tk)
+{
+ return tk->guessed_mouse_proto;
+}
+
+int
+termo_set_mouse_proto (termo_t *tk, int proto)
+{
+ int old_proto = tk->mouse_proto;
+ tk->mouse_proto = proto;
+
+ // Call the TI driver to apply the change if needed
+ if (!tk->is_started
+ || !tk->ti_method.set_mouse_proto)
+ return true;
+ return tk->ti_method.set_mouse_proto (tk->ti_data, old_proto, false)
+ && tk->ti_method.set_mouse_proto (tk->ti_data, proto, true);
+}
+
+termo_mouse_tracking_t
+termo_get_mouse_tracking_mode (termo_t *tk)
+{
+ return tk->mouse_tracking;
+}
+
+int
+termo_set_mouse_tracking_mode (termo_t *tk, termo_mouse_tracking_t mode)
+{
+ termo_mouse_tracking_t old_mode = tk->mouse_tracking;
+ tk->mouse_tracking = mode;
+
+ // Call the TI driver to apply the change if needed
+ if (!tk->is_started
+ || !tk->ti_method.set_mouse_tracking_mode)
+ return true;
+ return tk->ti_method.set_mouse_tracking_mode (tk->ti_data, old_mode, false)
+ && tk->ti_method.set_mouse_tracking_mode (tk->ti_data, mode, true);
+}
+
static void
eat_bytes (termo_t *tk, size_t count)
{