=== modified file '.bzrignore' --- .bzrignore 2012-04-01 19:04:01 +0000 +++ .bzrignore 2011-03-31 10:41:14 +0000 @@ -1,7 +1,6 @@ termkey.h demo demo-async -demo-glib termkey_getkey.3 termkey_waitkey.3 *.lo === modified file 'Makefile' --- Makefile 2012-04-01 19:04:01 +0000 +++ Makefile 2012-03-26 17:56:57 +0000 @@ -32,12 +32,6 @@ OBJECTS=termkey.lo driver-csi.lo driver-ti.lo LIBRARY=libtermkey.la -DEMOS=demo demo-async - -ifeq ($(shell pkg-config glib-2.0 && echo 1),1) - DEMOS+=demo-glib -endif - TESTSOURCES=$(wildcard t/[0-9]*.c) TESTFILES=$(TESTSOURCES:.c=.t) @@ -55,7 +49,7 @@ MAN3DIR=$(MANDIR)/man3 MAN7DIR=$(MANDIR)/man7 -all: $(LIBRARY) $(DEMOS) +all: $(LIBRARY) demo demo-async %.lo: %.c termkey.h termkey-internal.h $(LIBTOOL) --mode=compile --tag=CC gcc $(CFLAGS) -o $@ -c $< @@ -69,12 +63,6 @@ demo-async: $(LIBRARY) demo-async.lo $(LIBTOOL) --mode=link --tag=CC gcc -o $@ $^ -demo-glib.lo: demo-glib.c termkey.h - $(LIBTOOL) --mode=compile --tag=CC gcc -o $@ -c $< $(shell pkg-config glib-2.0 --cflags) - -demo-glib: $(LIBRARY) demo-glib.lo - $(LIBTOOL) --mode=link --tag=CC gcc -o $@ $^ $(shell pkg-config glib-2.0 --libs) - t/%.t: t/%.c $(LIBRARY) t/taplib.lo $(LIBTOOL) --mode=link --tag=CC gcc -o $@ $^ === removed file 'demo-glib.c' --- demo-glib.c 2012-04-01 19:04:01 +0000 +++ demo-glib.c 1970-01-01 00:00:00 +0000 @@ -1,65 +0,0 @@ -#include -#include - -#include "termkey.h" - -static TermKey *tk; -static int timeout_id; - -static void on_key(TermKey *tk, TermKeyKey *key) -{ - char buffer[50]; - termkey_strfkey(tk, buffer, sizeof buffer, key, TERMKEY_FORMAT_VIM); - printf("%s\n", buffer); -} - -static gboolean key_timer(gpointer data) -{ - TermKeyKey key; - - if(termkey_getkey_force(tk, &key) == TERMKEY_RES_KEY) - on_key(tk, &key); - - return FALSE; -} - -static gboolean stdin_io(GIOChannel *source, GIOCondition condition, gpointer data) -{ - if(condition && G_IO_IN) { - if(timeout_id) - g_source_remove(timeout_id); - - termkey_advisereadable(tk); - - TermKeyResult ret; - TermKeyKey key; - while((ret = termkey_getkey(tk, &key)) == TERMKEY_RES_KEY) { - on_key(tk, &key); - } - - if(ret == TERMKEY_RES_AGAIN) - timeout_id = g_timeout_add(termkey_get_waittime(tk), key_timer, NULL); - } - - return TRUE; -} - -int main(int argc, char *argv[]) -{ - TERMKEY_CHECK_VERSION; - - tk = termkey_new(0, 0); - - if(!tk) { - fprintf(stderr, "Cannot allocate termkey instance\n"); - exit(1); - } - - GMainLoop *loop = g_main_loop_new(NULL, FALSE); - - g_io_add_watch(g_io_channel_unix_new(0), G_IO_IN, stdin_io, NULL); - - g_main_loop_run(loop); - - termkey_destroy(tk); -}