aboutsummaryrefslogtreecommitdiff
path: root/termkey.c
diff options
context:
space:
mode:
authorPaul LeoNerd Evans <leonerd@leonerd.org.uk>2009-11-27 15:07:05 +0000
committerPaul LeoNerd Evans <leonerd@leonerd.org.uk>2009-11-27 15:07:05 +0000
commitba0c32e8d84925f88a8af540ce08b2dccbb52c25 (patch)
treedca07f3d4e6364666313e3b9be5938af04fb9198 /termkey.c
parent571e5b701f4d45d7c0942206b78f4c3b3478d248 (diff)
downloadtermo-ba0c32e8d84925f88a8af540ce08b2dccbb52c25.tar.gz
termo-ba0c32e8d84925f88a8af540ce08b2dccbb52c25.tar.xz
termo-ba0c32e8d84925f88a8af540ce08b2dccbb52c25.zip
Allow formatting the mouse position when rendering an event to a string
Diffstat (limited to 'termkey.c')
-rw-r--r--termkey.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/termkey.c b/termkey.c
index 1577e74..add7a53 100644
--- a/termkey.c
+++ b/termkey.c
@@ -1002,12 +1002,20 @@ size_t termkey_snprint_key(TermKey *tk, char *buffer, size_t len, TermKeyKey *ke
{
TermKeyMouseEvent ev;
int button;
- termkey_interpret_mouse(tk, key, &ev, &button, NULL, NULL);
+ int line, col;
+ termkey_interpret_mouse(tk, key, &ev, &button, &line, &col);
static char *evnames[] = { "Unknown", "Press", "Drag", "Release" };
l = snprintf(buffer + pos, len - pos, "Mouse%s(%d)",
evnames[ev], button);
+
+ if(format & TERMKEY_FORMAT_MOUSE_POS) {
+ if(l <= 0) return pos;
+ pos += l;
+
+ l = snprintf(buffer + pos, len - pos, " @ (%d,%d)", col, line);
+ }
}
break;
}