Pārlūkot izejas kodu

* Add cucul_get_version() and caca_get_version() and updated C++ bindings

accordingly.
  * The C++ test example no longer needs "config.h".
tags/v0.99.beta14
Sam Hocevar sam pirms 17 gadiem
vecāks
revīzija
9c72677ccf
11 mainītis faili ar 63 papildinājumiem un 24 dzēšanām
  1. +13
    -0
      caca/caca.c
  2. +1
    -0
      caca/caca.h
  3. +13
    -0
      cucul/cucul.c
  4. +1
    -0
      cucul/cucul.h
  5. +2
    -1
      cucul/export.c
  6. +5
    -0
      cxx/caca++.cpp
  7. +1
    -0
      cxx/caca++.h
  8. +5
    -0
      cxx/cucul++.cpp
  9. +2
    -1
      cxx/cucul++.h
  10. +18
    -20
      cxx/cxxtest.cpp
  11. +2
    -2
      src/img2txt.c

+ 13
- 0
caca/caca.c Parādīt failu

@@ -198,6 +198,19 @@ cucul_canvas_t * caca_get_canvas(caca_display_t *dp)
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.
*/


+ 1
- 0
caca/caca.h Parādīt failu

@@ -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_mouse(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


+ 13
- 0
cucul/cucul.c Parādīt failu

@@ -334,6 +334,19 @@ int cucul_rand(int min, int max)
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.
*/


+ 1
- 0
cucul/cucul.h Parādīt failu

@@ -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 int cucul_free_canvas(cucul_canvas_t *);
__extern int cucul_rand(int, int);
__extern char const * cucul_get_version(void);
/* @} */

/** \defgroup cucul_canvas libcucul canvas drawing


+ 2
- 1
cucul/export.c Parādīt failu

@@ -378,7 +378,8 @@ static void *export_html(cucul_canvas_t const *cv, unsigned long int *bytes)

/* HTML header */
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, "<div cellpadding='0' cellspacing='0' style='%s'>\n",


+ 5
- 0
cxx/caca++.cpp Parādīt failu

@@ -96,3 +96,8 @@ void Caca::setMouse(int v)
caca_set_mouse(dp, v);
}

const char * Caca::getVersion()
{
return caca_get_version();
}


+ 1
- 0
cxx/caca++.h Parādīt failu

@@ -78,6 +78,7 @@ __class Caca
unsigned int getMouseY();
void setMouse(int);

static char const * getVersion();
private:
caca_display_t *dp;
};


+ 5
- 0
cxx/cucul++.cpp Parādīt failu

@@ -236,6 +236,11 @@ int Cucul::Rand(int min, int max)
return cucul_rand(min, max);
}

const char * Cucul::getVersion()
{
return cucul_get_version();
}

int Cucul::setAttr(unsigned long int attr)
{
return cucul_set_attr(cv, attr);


+ 2
- 1
cxx/cucul++.h Parādīt failu

@@ -129,7 +129,6 @@ __class Cucul
void drawTriangle(int, int, int, int, int, int, unsigned long int);
void drawThinTriangle(int, int, int, int, int, 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);
unsigned int getFrameCount();
int setFrame(unsigned int);
@@ -142,6 +141,8 @@ __class Cucul
char const * const * getExportList(void);
void *exportMemory(char const *, unsigned long int *);

static int Rand(int, int);
static char const * getVersion();
protected:
cucul_canvas_t *get_cucul_canvas_t();



+ 18
- 20
cxx/cxxtest.cpp Parādīt failu

@@ -12,8 +12,6 @@
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/

#include "config.h"

#include <iostream>

#include <cucul++.h>
@@ -41,13 +39,13 @@ static char const pigstring[] =

int main(int argc, char *argv[])
{
Cucul *qq, *pig;
Caca *kk;
Cucul *cv, *pig;
Caca *dp;

int x = 0, y = 0, ix = 1, iy = 1;

try {
qq = new Cucul();
cv = new Cucul();
}
catch (int e) {
cerr << "Error while initializing cucul (" << e << ")" << endl;
@@ -55,7 +53,7 @@ int main(int argc, char *argv[])
}

try {
kk = new Caca(qq);
dp = new Caca(cv);
}
catch(int e) {
cerr << "Error while attaching cucul to caca (" << e << ")" << endl;
@@ -73,42 +71,42 @@ int main(int argc, char *argv[])
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 ...*/
if((x + pig->getWidth())-1 >= qq->getWidth() || x < 0 )
if((x + pig->getWidth())-1 >= cv->getWidth() || x < 0 )
x = 0;
if((y + pig->getHeight())-1 >= qq->getHeight() || y < 0 )
if((y + pig->getHeight())-1 >= cv->getHeight() || y < 0 )
y = 0;

qq->Clear();
cv->Clear();

/* Draw pig */
qq->Blit(x, y, pig, NULL);
cv->Blit(x, y, pig, NULL);

/* printf works */
qq->setColorANSI(CUCUL_LIGHTBLUE, CUCUL_BLACK);
qq->Printf(qq->getWidth() / 2 - 10, qq->getHeight() / 2,
"Powered by libcaca %s", VERSION);
cv->setColorANSI(CUCUL_LIGHTBLUE, CUCUL_BLACK);
cv->Printf(cv->getWidth() / 2 - 10, cv->getHeight() / 2,
"Powered by libcaca %s", dp->getVersion());

/* Blit */
kk->Display();
dp->Display();

x += ix;
y += iy;

if(x + pig->getWidth() >= qq->getWidth() || x < 0 )
if(x + pig->getWidth() >= cv->getWidth() || x < 0 )
ix = -ix;
if(y + pig->getHeight() >= qq->getHeight() || y < 0 )
if(y + pig->getHeight() >= cv->getHeight() || y < 0 )
iy = -iy;

}

delete kk;
delete qq;
delete dp;
delete cv;

return 0;
}

+ 2
- 2
src/img2txt.c Parādīt failu

@@ -88,8 +88,8 @@ static void version(void)
"\n"
"The latest version of img2txt is available from the web site,\n"
" http://libcaca.zoy.org/ in the libcaca package.\n"
"\n"
, VERSION, __DATE__);
"\n",
cucul_get_version(), __DATE__);
}
int main(int argc, char **argv)
{


Notiek ielāde…
Atcelt
Saglabāt