From ce16433e893f03e41948ace1515df7ada3f30ec2 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 9 Mar 2006 12:34:40 +0000 Subject: [PATCH] * Added a tiny Unicode test program. Of course it does not work yet, but good to have something to start with. --- test/Makefile.am | 6 +++++- test/unicode.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 test/unicode.c diff --git a/test/Makefile.am b/test/Makefile.am index e0bb29d..350575c 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,6 @@ # $Id$ -noinst_PROGRAMS = colors demo dithering event hsv optipal spritedit +noinst_PROGRAMS = colors demo dithering event hsv optipal spritedit unicode colors_SOURCES = colors.c colors_LDADD = ../caca/libcaca.la ../cucul/libcucul.la @CACA_LIBS@ @@ -30,3 +30,7 @@ spritedit_SOURCES = spritedit.c spritedit_LDADD = ../caca/libcaca.la ../cucul/libcucul.la @CACA_LIBS@ spritedit_CPPFLAGS = -I$(top_srcdir)/cucul -I$(top_srcdir)/caca +unicode_SOURCES = unicode.c +unicode_LDADD = ../caca/libcaca.la ../cucul/libcucul.la @CACA_LIBS@ +unicode_CPPFLAGS = -I$(top_srcdir)/cucul -I$(top_srcdir)/caca + diff --git a/test/unicode.c b/test/unicode.c new file mode 100644 index 0000000..02b705b --- /dev/null +++ b/test/unicode.c @@ -0,0 +1,49 @@ +/* + * unicode libcaca Unicode rendering test program + * Copyright (c) 2006 Sam Hocevar + * All Rights Reserved + * + * $Id$ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the Do What The Fuck You Want To + * Public License, Version 2, as published by Sam Hocevar. See + * http://sam.zoy.org/wtfpl/COPYING for more details. + */ + +#include "config.h" + +#if defined(HAVE_INTTYPES_H) +# include +#else +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +#endif + +#include "cucul.h" +#include "caca.h" + +int main(void) +{ + cucul_t *qq; + caca_t *kk; + + qq = cucul_init(); + kk = caca_attach(qq); + + cucul_putstr(qq, 1, 1, "This is ASCII: [ abc DEF 123 !@# ]"); + cucul_putstr(qq, 1, 2, "This is Unicode: [ äβç ΔЗҒ ░▒▓ ♩♔✈ ]"); + + cucul_putstr(qq, 1, 4, "If the two lines do not have the same length, there is a bug somewhere."); + + caca_display(kk); + + while(!caca_get_event(kk, CACA_EVENT_KEY_PRESS)); + + caca_detach(kk); + cucul_end(qq); + + return 0; +} +