2008-02-07 01:58:41 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "termkey.h"
|
|
|
|
|
2008-12-08 23:54:14 +01:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2008-11-16 13:40:14 +01:00
|
|
|
TERMKEY_CHECK_VERSION;
|
|
|
|
|
2008-08-21 21:20:07 +02:00
|
|
|
char buffer[50];
|
2008-02-07 03:21:14 +01:00
|
|
|
termkey_t *tk = termkey_new(0, 0);
|
2008-02-07 01:58:41 +01:00
|
|
|
|
2008-10-09 23:41:07 +02:00
|
|
|
if(!tk) {
|
|
|
|
fprintf(stderr, "Cannot allocate termkey instance\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2008-02-07 02:17:59 +01:00
|
|
|
termkey_result ret;
|
2008-02-07 01:58:41 +01:00
|
|
|
termkey_key key;
|
|
|
|
|
2008-02-07 02:17:59 +01:00
|
|
|
while((ret = termkey_waitkey(tk, &key)) != TERMKEY_RES_EOF) {
|
2008-10-08 03:06:00 +02:00
|
|
|
termkey_snprint_key(tk, buffer, sizeof buffer, &key, TERMKEY_FORMAT_VIM);
|
2008-10-06 23:33:49 +02:00
|
|
|
printf("%s\n", buffer);
|
2008-02-07 01:58:41 +01:00
|
|
|
|
2008-08-21 21:05:17 +02:00
|
|
|
if(key.type == TERMKEY_TYPE_UNICODE &&
|
|
|
|
key.modifiers & TERMKEY_KEYMOD_CTRL &&
|
|
|
|
(key.code.codepoint == 'C' || key.code.codepoint == 'c'))
|
2008-02-07 01:58:41 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2008-02-23 21:26:04 +01:00
|
|
|
termkey_destroy(tk);
|
2008-02-07 01:58:41 +01:00
|
|
|
}
|