termo/demo.c

26 lines
620 B
C
Raw Normal View History

2008-02-07 01:58:41 +01:00
#include <stdio.h>
#include "termkey.h"
int main(int argc, char *argv[]) {
char buffer[50];
termkey_t *tk = termkey_new(0, 0);
2008-02-07 01:58:41 +01:00
termkey_result ret;
2008-02-07 01:58:41 +01:00
termkey_key key;
while((ret = termkey_waitkey(tk, &key)) != TERMKEY_RES_EOF) {
2008-10-06 23:33:49 +02:00
termkey_snprint_key(tk, buffer, sizeof buffer, &key, 0);
printf("%s or ", buffer);
termkey_snprint_key(tk, buffer, sizeof buffer, &key, ~0);
printf("%s\n", buffer);
2008-02-07 01:58:41 +01: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;
}
termkey_destroy(tk);
2008-02-07 01:58:41 +01:00
}