First, a very simple working program, to check for basic libcaca functionalities.
int main(void)
{
if(!dp) return 1;
return 0;
}
What does it do?
- Create a display. Physically, the display is either a window or a context in a terminal (ncurses, slang) or even the whole screen (VGA).
- Get the display's associated canvas. A canvas is the surface where everything happens: writing characters, sprites, strings, images... It is unavoidable. Here the size of the canvas is set by the display.
- Set the display's window name (only available in windowed displays, does nothing otherwise).
- Set the current canvas colours to black background and white foreground.
- Write the string
"This is a message"
onto the canvas, using the current colour pair.
- Refresh the display, causing the text to be effectively displayed.
- Wait for an event of type
CACA_EVENT_KEY_PRESS
.
- Free the display (release memory). Since it was created together with the display, the canvas will be automatically freed as well.
You can then compile this code on an UNIX-like system using the following commans (requiring pkg-config
and gcc
):
gcc <tt>pkg-config --libs --cflags caca</tt> example.c -o example