Allow setting mouse encoding protocol from demo

This commit is contained in:
Paul LeoNerd Evans 2012-04-12 01:08:12 +01:00
parent 60b4bfaf72
commit 84378bcba8
1 changed files with 11 additions and 2 deletions

13
demo.c
View File

@ -12,13 +12,14 @@ int main(int argc, char *argv[])
TERMKEY_CHECK_VERSION; TERMKEY_CHECK_VERSION;
int mouse = 0; int mouse = 0;
int mouse_proto = 0;
TermKeyFormat format = TERMKEY_FORMAT_VIM; TermKeyFormat format = TERMKEY_FORMAT_VIM;
char buffer[50]; char buffer[50];
TermKey *tk; TermKey *tk;
int opt; int opt;
while((opt = getopt(argc, argv, "m::")) != -1) { while((opt = getopt(argc, argv, "m::p:")) != -1) {
switch(opt) { switch(opt) {
case 'm': case 'm':
if(optarg) if(optarg)
@ -28,6 +29,11 @@ int main(int argc, char *argv[])
format |= TERMKEY_FORMAT_MOUSE_POS; format |= TERMKEY_FORMAT_MOUSE_POS;
break; break;
case 'p':
mouse_proto = atoi(optarg);
break;
default: default:
fprintf(stderr, "Usage: %s [-m]\n", argv[0]); fprintf(stderr, "Usage: %s [-m]\n", argv[0]);
return 1; return 1;
@ -44,8 +50,11 @@ int main(int argc, char *argv[])
TermKeyResult ret; TermKeyResult ret;
TermKeyKey key; TermKeyKey key;
if(mouse) if(mouse) {
printf("\033[?%dhMouse mode active\n", mouse); printf("\033[?%dhMouse mode active\n", mouse);
if(mouse_proto)
printf("\033[?%dh", mouse_proto);
}
while((ret = termkey_waitkey(tk, &key)) != TERMKEY_RES_EOF) { while((ret = termkey_waitkey(tk, &key)) != TERMKEY_RES_EOF) {
if(ret == TERMKEY_RES_KEY) { if(ret == TERMKEY_RES_KEY) {