diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2014-09-28 03:51:45 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2014-09-28 03:59:12 +0200 |
commit | 36bc6cd0952b2eddc17e7da803d85decf96d32cc (patch) | |
tree | 23488c213f53db83346d3eaf71cb78d74c42eff0 /demo.c | |
parent | cac1f8373bb16aae02ffa80acf8640385bf94591 (diff) | |
download | termo-36bc6cd0952b2eddc17e7da803d85decf96d32cc.tar.gz termo-36bc6cd0952b2eddc17e7da803d85decf96d32cc.tar.xz termo-36bc6cd0952b2eddc17e7da803d85decf96d32cc.zip |
Move to iconv
That is the major change in this commit.
Also Ctrl-modified keys now should work in URxvt,
which was surprisingly trivial to achieve.
Coming up next:
- making sure the tests still work
- introducing CMake
Diffstat (limited to 'demo.c')
-rw-r--r-- | demo.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -1,9 +1,10 @@ -// we want optarg +// We want optarg #define _XOPEN_SOURCE 600 #include <stdio.h> #include <unistd.h> #include <errno.h> +#include <locale.h> #include "termkey.h" @@ -11,6 +12,7 @@ int main(int argc, char *argv[]) { TERMKEY_CHECK_VERSION; + setlocale (LC_CTYPE, ""); int mouse = 0; int mouse_proto = 0; @@ -41,18 +43,18 @@ main(int argc, char *argv[]) } } - tk = termkey_new (0, TERMKEY_FLAG_SPACESYMBOL | TERMKEY_FLAG_CTRLC); - + tk = termkey_new (STDIN_FILENO, NULL, + TERMKEY_FLAG_SPACESYMBOL | TERMKEY_FLAG_CTRLC); if (!tk) { fprintf (stderr, "Cannot allocate termkey instance\n"); exit (1); } - if (termkey_get_flags (tk) & TERMKEY_FLAG_UTF8) - printf ("Termkey in UTF-8 mode\n"); - else if (termkey_get_flags (tk) & TERMKEY_FLAG_RAW) + if (termkey_get_flags (tk) & TERMKEY_FLAG_RAW) printf ("Termkey in RAW mode\n"); + else + printf ("Termkey in multibyte mode\n"); termkey_result_t ret; termkey_key_t key; @@ -103,12 +105,12 @@ main(int argc, char *argv[]) else printf ("Key %s\n", buffer); - if (key.type == TERMKEY_TYPE_UNICODE + if (key.type == TERMKEY_TYPE_KEY && key.modifiers & TERMKEY_KEYMOD_CTRL && (key.code.codepoint == 'C' || key.code.codepoint == 'c')) break; - if (key.type == TERMKEY_TYPE_UNICODE + if (key.type == TERMKEY_TYPE_KEY && key.modifiers == 0 && key.code.codepoint == '?') { @@ -121,7 +123,7 @@ main(int argc, char *argv[]) { if (errno != EINTR) { - perror("termkey_waitkey"); + perror ("termkey_waitkey"); break; } printf ("Interrupted by signal\n"); |