From 8a316f40d651be6b5720912e4624d30b5ff988b3 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 22 Oct 2006 15:03:22 +0000 Subject: [PATCH] * Fix the Unicode test. * Add a test for fullwidth characters. --- test/Makefile.am | 5 +++- test/fullwidth.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ test/unicode.c | 2 +- 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 test/fullwidth.c diff --git a/test/Makefile.am b/test/Makefile.am index ce11c1a..1ad6f0b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -2,7 +2,7 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/cucul -I$(top_srcdir)/caca -DDATADIR=\"$(pkgdatadir)\" -noinst_PROGRAMS = colors demo demo0 dithering event export font frames gamma hsv input spritedit font2tga text transform truecolor unicode import +noinst_PROGRAMS = colors demo demo0 dithering event export font frames fullwidth gamma hsv input spritedit font2tga text transform truecolor unicode import colors_SOURCES = colors.c colors_LDADD = ../caca/libcaca.la ../cucul/libcucul.la @@ -33,6 +33,9 @@ font2tga_LDADD = ../cucul/libcucul.la frames_SOURCES = frames.c frames_LDADD = ../caca/libcaca.la ../cucul/libcucul.la +fullwidth_SOURCES = fullwidth.c +fullwidth_LDADD = ../caca/libcaca.la ../cucul/libcucul.la + gamma_SOURCES = gamma.c gamma_LDADD = ../caca/libcaca.la ../cucul/libcucul.la gamma_LDFLAGS = @MATH_LIBS@ diff --git a/test/fullwidth.c b/test/fullwidth.c new file mode 100644 index 0000000..1022a27 --- /dev/null +++ b/test/fullwidth.c @@ -0,0 +1,70 @@ +/* + * fullwidth libcaca fullwidth Unicode characters 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" +#include "common.h" + +#if !defined(__KERNEL__) +# if defined(HAVE_INTTYPES_H) +# include +# endif +# include +#endif + +#include "cucul.h" +#include "caca.h" + +#define HOHO "ホホホホホホホホホホホホホホホ" + +int main(int argc, char *argv[]) +{ + cucul_canvas_t *cv, *hoho; + caca_display_t *dp; + + unsigned int i; + + cv = cucul_create_canvas(0, 0); + dp = caca_create_display(cv); + + hoho = cucul_create_canvas(6, 10); + + for(i = 0; i < 10; i++) + { + cucul_set_color(hoho, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE); + cucul_putstr(hoho, 0, i, HOHO); + cucul_set_color(hoho, CUCUL_COLOR_WHITE, CUCUL_COLOR_RED); + cucul_putchar(hoho, i - 2, i, 'x'); + } + + cucul_blit(cv, 1, 1, hoho, NULL); + + for(i = 0; i < 10; i++) + { + cucul_set_color(hoho, CUCUL_COLOR_WHITE, CUCUL_COLOR_BLUE); + cucul_putstr(hoho, 0, i, HOHO); + cucul_set_color(hoho, CUCUL_COLOR_WHITE, CUCUL_COLOR_GREEN); + cucul_putstr(hoho, i - 2, i, "ホ"); + } + + cucul_blit(cv, 15, 1, hoho, NULL); + + caca_refresh_display(dp); + + caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1); + + caca_free_display(dp); + cucul_free_canvas(cv); + + return 0; +} + diff --git a/test/unicode.c b/test/unicode.c index 02c2818..72c9381 100644 --- a/test/unicode.c +++ b/test/unicode.c @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) cucul_putstr(cv, 1, 16, "| ()()()() ()()() |"); cucul_set_color(cv, CUCUL_COLOR_YELLOW, CUCUL_COLOR_BLACK); cucul_putstr(cv, 1, 17, "| ドラゴン"); - cucul_putstr(cv, 10, 17, "ボーレ |"); + cucul_putstr(cv, 12, 17, "ボーレ |"); cucul_set_color(cv, CUCUL_COLOR_LIGHTGRAY, CUCUL_COLOR_BLACK); cucul_putstr(cv, 1, 18, "If the three lines do not have the same length, there is a bug somewhere.");