A libcucul and libcaca tutorial

Before writing your first libcaca application, you need to know the difference between libcucul and libcaca :

So, you can write a libcucul only program, but you can't write a libcaca only program, it'll be nonsense. Period.

First, a working program, very simple, to check you can compile and run it:

#include <cucul.h>
#include <caca.h>

int main(void)
{
    /* Initialise libcaca */
    cucul_canvas_t *cv; caca_display_t *dp; caca_event_t ev;
    dp = caca_create_display(NULL);
    if(!dp) return 1;
    cv = caca_get_canvas(dp);
    /* Set window title */
    caca_set_display_title(dp, "Hello!");
    /* Choose drawing colours */
    cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_WHITE);
    /* Draw a string at coordinates (0, 0) */
    cucul_put_str(cv, 0, 0, "This is a message");
    /* Refresh display */
    caca_refresh_display(dp);
    /* Wait for a key press event */
    caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1);
    /* Clean up library */
    caca_free_display(dp);

    return 0;
}

What does it do ? (we skip variable definitions, guessing you have a brain) :

You can then compile this code under UNIX-like systems with following command : (you'll need pkg-config and gcc)

gcc `pkg-config --libs --cflags cucul caca` example.c -o example