Unix and Linux Discussions Tagged with tutorial |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
0 |
7,754 |
Web Development |
|
|
|
5 |
3,885 |
Programming |
|
|
|
1 |
2,846 |
SuSE |
|
|
|
1 |
1,512 |
UNIX for Dummies Questions & Answers |
|
|
|
0 |
2,513 |
Oracle Updates (RSS) |
|
|
|
0 |
9,351 |
Linux |
|
|
|
1 |
3,889 |
UNIX for Dummies Questions & Answers |
|
|
|
0 |
3,365 |
UNIX for Dummies Questions & Answers |
|
|
|
0 |
2,477 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
4,407 |
Shell Programming and Scripting |
|
|
|
5 |
4,060 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,951 |
UNIX Desktop Questions & Answers |
|
|
|
2 |
3,967 |
UNIX for Dummies Questions & Answers |
|
|
|
6 |
2,481 |
UNIX for Dummies Questions & Answers |
|
|
|
6 |
11,701 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
3,859 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,761 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
2,927 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
2,725 |
UNIX for Dummies Questions & Answers |
|
|
|
5 |
3,987 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
15,021 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
2,620 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
15,270 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
2,423 |
Programming |
|
|
|
5 |
8,761 |
Programming |
|
|
|
1 |
7,994 |
IP Networking |
|
|
|
1 |
6,353 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,365 |
UNIX for Dummies Questions & Answers |
libcaca-tutorial(3caca) libcaca libcaca-tutorial(3caca)
NAME
libcaca-tutorial - A libcaca tutorial First, a very simple working program, to check for basic libcaca functionalities.
#include <caca.h>
int main(void)
{
caca_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);
caca_set_display_title(dp, 'Hello!');
caca_set_color_ansi(cv, CACA_BLACK, CACA_WHITE);
caca_put_str(cv, 0, 0, 'This is a message');
caca_refresh_display(dp);
caca_get_event(dp, CACA_EVENT_KEY_PRESS, &ev, -1);
caca_free_display(dp);
return 0;
}
What does it do?
o Create a display. Physically, the display is either a window or a context in a terminal (ncurses, slang) or even the whole screen (VGA).
o 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.
o Set the display's window name (only available in windowed displays, does nothing otherwise).
o Set the current canvas colours to black background and white foreground.
o Write the string 'This is a message' onto the canvas, using the current colour pair.
o Refresh the display, causing the text to be effectively displayed.
o Wait for an event of type CACA_EVENT_KEY_PRESS.
o 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 `pkg-config --libs --cflags caca` example.c -o example
Version 0.99.beta18 Fri Apr 6 2012 libcaca-tutorial(3caca)