accordingly. * The C++ test example no longer needs "config.h".tags/v0.99.beta14
@@ -198,6 +198,19 @@ cucul_canvas_t * caca_get_canvas(caca_display_t *dp) | |||||
return dp->cv; | return dp->cv; | ||||
} | } | ||||
/** \brief Return the \e libcaca version. | |||||
* | |||||
* Return a read-only string with the \e libcaca version information. | |||||
* | |||||
* This function never fails. | |||||
* | |||||
* \return The \e libcaca version information. | |||||
*/ | |||||
char const * caca_get_version(void) | |||||
{ | |||||
return VERSION; | |||||
} | |||||
/* | /* | ||||
* XXX: The following functions are local. | * XXX: The following functions are local. | ||||
*/ | */ | ||||
@@ -164,6 +164,7 @@ __extern unsigned int caca_get_display_height(caca_display_t const *); | |||||
__extern int caca_set_display_title(caca_display_t *, char const *); | __extern int caca_set_display_title(caca_display_t *, char const *); | ||||
__extern int caca_set_mouse(caca_display_t *, int); | __extern int caca_set_mouse(caca_display_t *, int); | ||||
__extern int caca_set_cursor(caca_display_t *, int); | __extern int caca_set_cursor(caca_display_t *, int); | ||||
__extern char const * caca_get_version(void); | |||||
/* @} */ | /* @} */ | ||||
/** \defgroup caca_event libcaca event handling | /** \defgroup caca_event libcaca event handling | ||||
@@ -334,6 +334,19 @@ int cucul_rand(int min, int max) | |||||
return min + (int)((1.0 * (max - min)) * rand() / (RAND_MAX + 1.0)); | return min + (int)((1.0 * (max - min)) * rand() / (RAND_MAX + 1.0)); | ||||
} | } | ||||
/** \brief Return the \e libcucul version. | |||||
* | |||||
* Return a read-only string with the \e libcucul version information. | |||||
* | |||||
* This function never fails. | |||||
* | |||||
* \return The \e libcucul version information. | |||||
*/ | |||||
char const * cucul_get_version(void) | |||||
{ | |||||
return VERSION; | |||||
} | |||||
/* | /* | ||||
* XXX: The following functions are local. | * XXX: The following functions are local. | ||||
*/ | */ | ||||
@@ -93,6 +93,7 @@ __extern unsigned char const * cucul_get_canvas_chars(cucul_canvas_t const *); | |||||
__extern unsigned char const * cucul_get_canvas_attrs(cucul_canvas_t const *); | __extern unsigned char const * cucul_get_canvas_attrs(cucul_canvas_t const *); | ||||
__extern int cucul_free_canvas(cucul_canvas_t *); | __extern int cucul_free_canvas(cucul_canvas_t *); | ||||
__extern int cucul_rand(int, int); | __extern int cucul_rand(int, int); | ||||
__extern char const * cucul_get_version(void); | |||||
/* @} */ | /* @} */ | ||||
/** \defgroup cucul_canvas libcucul canvas drawing | /** \defgroup cucul_canvas libcucul canvas drawing | ||||
@@ -378,7 +378,8 @@ static void *export_html(cucul_canvas_t const *cv, unsigned long int *bytes) | |||||
/* HTML header */ | /* HTML header */ | ||||
cur += sprintf(cur, "<html><head>\n"); | cur += sprintf(cur, "<html><head>\n"); | ||||
cur += sprintf(cur, "<title>Generated by libcaca %s</title>\n", VERSION); | cur += sprintf(cur, "<title>Generated by libcaca %s</title>\n", | ||||
cucul_get_version()); | |||||
cur += sprintf(cur, "</head><body>\n"); | cur += sprintf(cur, "</head><body>\n"); | ||||
cur += sprintf(cur, "<div cellpadding='0' cellspacing='0' style='%s'>\n", | cur += sprintf(cur, "<div cellpadding='0' cellspacing='0' style='%s'>\n", | ||||
@@ -96,3 +96,8 @@ void Caca::setMouse(int v) | |||||
caca_set_mouse(dp, v); | caca_set_mouse(dp, v); | ||||
} | } | ||||
const char * Caca::getVersion() | |||||
{ | |||||
return caca_get_version(); | |||||
} | |||||
@@ -78,6 +78,7 @@ __class Caca | |||||
unsigned int getMouseY(); | unsigned int getMouseY(); | ||||
void setMouse(int); | void setMouse(int); | ||||
static char const * getVersion(); | |||||
private: | private: | ||||
caca_display_t *dp; | caca_display_t *dp; | ||||
}; | }; | ||||
@@ -236,6 +236,11 @@ int Cucul::Rand(int min, int max) | |||||
return cucul_rand(min, max); | return cucul_rand(min, max); | ||||
} | } | ||||
const char * Cucul::getVersion() | |||||
{ | |||||
return cucul_get_version(); | |||||
} | |||||
int Cucul::setAttr(unsigned long int attr) | int Cucul::setAttr(unsigned long int attr) | ||||
{ | { | ||||
return cucul_set_attr(cv, attr); | return cucul_set_attr(cv, attr); | ||||
@@ -129,7 +129,6 @@ __class Cucul | |||||
void drawTriangle(int, int, int, int, int, int, unsigned long int); | void drawTriangle(int, int, int, int, int, int, unsigned long int); | ||||
void drawThinTriangle(int, int, int, int, int, int); | void drawThinTriangle(int, int, int, int, int, int); | ||||
void fillTriangle(int, int, int, int, int, int, unsigned long int); | void fillTriangle(int, int, int, int, int, int, unsigned long int); | ||||
int Rand(int, int); | |||||
int setBoundaries(cucul_canvas_t *, int, int, unsigned int, unsigned int); | int setBoundaries(cucul_canvas_t *, int, int, unsigned int, unsigned int); | ||||
unsigned int getFrameCount(); | unsigned int getFrameCount(); | ||||
int setFrame(unsigned int); | int setFrame(unsigned int); | ||||
@@ -142,6 +141,8 @@ __class Cucul | |||||
char const * const * getExportList(void); | char const * const * getExportList(void); | ||||
void *exportMemory(char const *, unsigned long int *); | void *exportMemory(char const *, unsigned long int *); | ||||
static int Rand(int, int); | |||||
static char const * getVersion(); | |||||
protected: | protected: | ||||
cucul_canvas_t *get_cucul_canvas_t(); | cucul_canvas_t *get_cucul_canvas_t(); | ||||
@@ -12,8 +12,6 @@ | |||||
* http://sam.zoy.org/wtfpl/COPYING for more details. | * http://sam.zoy.org/wtfpl/COPYING for more details. | ||||
*/ | */ | ||||
#include "config.h" | |||||
#include <iostream> | #include <iostream> | ||||
#include <cucul++.h> | #include <cucul++.h> | ||||
@@ -41,13 +39,13 @@ static char const pigstring[] = | |||||
int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||||
{ | { | ||||
Cucul *qq, *pig; | Cucul *cv, *pig; | ||||
Caca *kk; | Caca *dp; | ||||
int x = 0, y = 0, ix = 1, iy = 1; | int x = 0, y = 0, ix = 1, iy = 1; | ||||
try { | try { | ||||
qq = new Cucul(); | cv = new Cucul(); | ||||
} | } | ||||
catch (int e) { | catch (int e) { | ||||
cerr << "Error while initializing cucul (" << e << ")" << endl; | cerr << "Error while initializing cucul (" << e << ")" << endl; | ||||
@@ -55,7 +53,7 @@ int main(int argc, char *argv[]) | |||||
} | } | ||||
try { | try { | ||||
kk = new Caca(qq); | dp = new Caca(cv); | ||||
} | } | ||||
catch(int e) { | catch(int e) { | ||||
cerr << "Error while attaching cucul to caca (" << e << ")" << endl; | cerr << "Error while attaching cucul to caca (" << e << ")" << endl; | ||||
@@ -73,42 +71,42 @@ int main(int argc, char *argv[]) | |||||
return -1; | return -1; | ||||
} | } | ||||
kk->setDisplayTime(20000); | dp->setDisplayTime(20000); | ||||
while(!kk->getEvent(Event::CACA_EVENT_KEY_PRESS, NULL, 0)) | while(!dp->getEvent(Event::CACA_EVENT_KEY_PRESS, NULL, 0)) | ||||
{ | { | ||||
/* In case of resize ...*/ | /* In case of resize ...*/ | ||||
if((x + pig->getWidth())-1 >= qq->getWidth() || x < 0 ) | if((x + pig->getWidth())-1 >= cv->getWidth() || x < 0 ) | ||||
x = 0; | x = 0; | ||||
if((y + pig->getHeight())-1 >= qq->getHeight() || y < 0 ) | if((y + pig->getHeight())-1 >= cv->getHeight() || y < 0 ) | ||||
y = 0; | y = 0; | ||||
qq->Clear(); | cv->Clear(); | ||||
/* Draw pig */ | /* Draw pig */ | ||||
qq->Blit(x, y, pig, NULL); | cv->Blit(x, y, pig, NULL); | ||||
/* printf works */ | /* printf works */ | ||||
qq->setColorANSI(CUCUL_LIGHTBLUE, CUCUL_BLACK); | cv->setColorANSI(CUCUL_LIGHTBLUE, CUCUL_BLACK); | ||||
qq->Printf(qq->getWidth() / 2 - 10, qq->getHeight() / 2, | cv->Printf(cv->getWidth() / 2 - 10, cv->getHeight() / 2, | ||||
"Powered by libcaca %s", VERSION); | "Powered by libcaca %s", dp->getVersion()); | ||||
/* Blit */ | /* Blit */ | ||||
kk->Display(); | dp->Display(); | ||||
x += ix; | x += ix; | ||||
y += iy; | y += iy; | ||||
if(x + pig->getWidth() >= qq->getWidth() || x < 0 ) | if(x + pig->getWidth() >= cv->getWidth() || x < 0 ) | ||||
ix = -ix; | ix = -ix; | ||||
if(y + pig->getHeight() >= qq->getHeight() || y < 0 ) | if(y + pig->getHeight() >= cv->getHeight() || y < 0 ) | ||||
iy = -iy; | iy = -iy; | ||||
} | } | ||||
delete kk; | delete dp; | ||||
delete qq; | delete cv; | ||||
return 0; | return 0; | ||||
} | } |
@@ -88,8 +88,8 @@ static void version(void) | |||||
"\n" | "\n" | ||||
"The latest version of img2txt is available from the web site,\n" | "The latest version of img2txt is available from the web site,\n" | ||||
" http://libcaca.zoy.org/ in the libcaca package.\n" | " http://libcaca.zoy.org/ in the libcaca package.\n" | ||||
"\n" | "\n", | ||||
, VERSION, __DATE__); | cucul_get_version(), __DATE__); | ||||
} | } | ||||
int main(int argc, char **argv) | int main(int argc, char **argv) | ||||
{ | { | ||||