@@ -46,11 +46,17 @@ int main(int argc, char *argv[]) | |||||
return -1; | return -1; | ||||
} | } | ||||
/* Draw pig */ | |||||
qq->set_color(CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK); | qq->set_color(CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK); | ||||
for(int i = 0; pig[i]; i++) | for(int i = 0; pig[i]; i++) | ||||
qq->putstr(0, i, (char*)pig[i]); | qq->putstr(0, i, (char*)pig[i]); | ||||
/* printf works */ | |||||
qq->set_color(CUCUL_COLOR_LIGHTBLUE, CUCUL_COLOR_BLACK); | |||||
qq->printf(7,15, "Powered by libcaca %s", VERSION); | |||||
kk->display(); | kk->display(); | ||||
kk->get_event(CACA_EVENT_KEY_PRESS, &ev, -1); | kk->get_event(CACA_EVENT_KEY_PRESS, &ev, -1); | ||||
@@ -52,7 +52,24 @@ void Cucul::putstr (int x, int y, char *str) | |||||
{ | { | ||||
cucul_putstr(qq, x, y, str); | cucul_putstr(qq, x, y, str); | ||||
} | } | ||||
//void Cucul::printf ( int, int, char const *,...) | |||||
void Cucul::printf ( int x , int y , char const * format,...) | |||||
{ | |||||
char tmp[BUFSIZ]; | |||||
char *buf = tmp; | |||||
va_list args; | |||||
va_start(args, format); | |||||
#if defined(HAVE_VSNPRINTF) | |||||
vsnprintf(buf, get_width() - x + 1, format, args); | |||||
#else | |||||
vsprintf(buf, format, args); | |||||
#endif | |||||
buf[get_width() - x] = '\0'; | |||||
va_end(args); | |||||
putstr(x, y, buf); | |||||
} | |||||
void Cucul::clear () | void Cucul::clear () | ||||
{ | { | ||||
@@ -1,7 +1,8 @@ | |||||
#ifndef _CUCUL_PP_H | #ifndef _CUCUL_PP_H | ||||
#define _CUCUL_PP_H | #define _CUCUL_PP_H | ||||
#include <stdio.h> // BUFSIZ | |||||
#include <stdarg.h> // va_* | |||||
#include "config.h" | |||||
#include "cucul.h" | #include "cucul.h" | ||||
@@ -41,6 +42,7 @@ class Cucul { | |||||
unsigned int get_height(void); | unsigned int get_height(void); | ||||
void set_color(unsigned int f, unsigned int b); | void set_color(unsigned int f, unsigned int b); | ||||
char const * get_color_name (unsigned int color); | char const * get_color_name (unsigned int color); | ||||
void printf ( int x , int y , char const * format,...); | |||||
void putchar (int x, int y, char c); | void putchar (int x, int y, char c); | ||||
void putstr (int x, int y, char *str); | void putstr (int x, int y, char *str); | ||||
void clear (); | void clear (); | ||||