caca_display(3caca)
π caca_display π
okay so bestie, this page is from the libcaca manual, section 3caca, and it is literally the display-functions era. No cap, this is where libcaca learns how to show your canvas on a real device. π
π NAME π
caca_display β libcaca display functions. That is the whole name vibe. β¨
β¨ SYNOPSIS β¨
π Topics π
- libcaca event handling
π οΈ Functions π οΈ
__extern caca_display_t * caca_create_display (caca_canvas_t *)β hooks a caca graphical context onto a caca canvas. π«Ά__extern caca_display_t * caca_create_display_with_driver (caca_canvas_t *, char const *)β hooks a specific caca graphical context onto a caca canvas. π«__extern char const *const * caca_get_display_driver_list (void )β hands you the list of available display drivers. π__extern char const * caca_get_display_driver (caca_display_t *)β shows the current output driver for a caca graphical context. π__extern int caca_set_display_driver (caca_display_t *, char const *)β sets the output driver. ποΈ__extern int caca_free_display (caca_display_t *)β detaches a caca graphical context from a caca backend context. π__extern caca_canvas_t * caca_get_canvas (caca_display_t *)β grabs the canvas attached to a caca graphical context. π¨__extern int caca_refresh_display (caca_display_t *)β flushes pending changes and redraws the screen. π__extern int caca_set_display_time (caca_display_t *, int)β sets the refresh delay. β±οΈ__extern int caca_get_display_time (caca_display_t const *)β gets the displayβs average rendering time. β³__extern int caca_get_display_width (caca_display_t const *)β gets the display width. π__extern int caca_get_display_height (caca_display_t const *)β gets the display height. π__extern int caca_set_display_title (caca_display_t *, char const *)β sets the display title. π·οΈ__extern int caca_set_mouse (caca_display_t *, int)β shows or hides the mouse pointer. π±οΈ__extern int caca_set_cursor (caca_display_t *, int)β shows or hides the cursor. ποΈ
π¦ DETAILED DESCRIPTION π¦
These functions are the basic libcaca routines for display initialisation, system information retrieval and configuration. Literally the starter pack for making a display happen. β¨
π FUNCTION DOCUMENTATION π
π« caca_create_display π«
__extern caca_display_t * caca_create_display (caca_canvas_t * cv)
Okay so this one creates a graphical context using device-dependent features (ncurses for terminals, an X11 window, a DOS command window...) that attaches to a libcaca canvas. Everything that gets drawn in the libcaca canvas can then be displayed by the libcaca driver. It is giving βcanvas goes public.β π
If no caca canvas is provided, a new one is created. Its handle can be retrieved using caca_get_canvas() and it is automatically destroyed when caca_free_display() is called.
Note: to achieve maximum Unicode compatibility, the driver initialisation code may temporarily change the programβs globalLC_CTYPElocale usingsetlocale(). It is advised not to callLC_CTYPE-dependent functions from other threads during the call tocaca_create_display(). The locale settings are restored when the function returns. No cap, that part matters. π
See also caca_create_display_with_driver().
If an error occurs, NULL is returned and errno is set accordingly:
ENOMEMβ Not enough memory.ENODEVβ Graphical device could not be initialised.
Parameters
cvβ The caca canvas orNULLto create a canvas automatically.
Returns
The caca graphical context or NULL if an error occurred. π
References caca_create_display_with_driver().
π« caca_create_display_with_driver π«
__extern caca_display_t * caca_create_display_with_driver (caca_canvas_t * cv, char const * driver)
This one creates a graphical context using device-dependent features (ncurses for terminals, an X11 window, a DOS command window...) that attaches to a libcaca canvas. Everything that gets drawn in the libcaca canvas can then be displayed by the libcaca driver. Same iconic energy, but you get to name the driver. π¬
If no caca canvas is provided, a new one is created. Its handle can be retrieved using caca_get_canvas() and it is automatically destroyed when caca_free_display() is called.
If no driver name is provided, libcaca will try to autodetect the best output driver it can. Lowkey magical. πͺ
See also caca_create_display().
If an error occurs, NULL is returned and errno is set accordingly:
ENOMEMβ Not enough memory.ENODEVβ Graphical device could not be initialised.
Parameters
cvβ The caca canvas orNULLto create a canvas automatically.driverβ A string describing the desired output driver orNULLto choose the best driver automatically.
Returns
The caca graphical context or NULL if an error occurred. π
References caca_create_canvas(), caca_free_canvas(), caca_manage_canvas(), and caca_unmanage_canvas().
Referenced by caca_create_display().
π« caca_get_display_driver_list π«
__extern char const *const * caca_get_display_driver_list (void )
Return a list of available display drivers. The list is a NULL-terminated array of strings, interleaving a string containing the internal value for the display driver, and a string containing the natural language description for that driver. It is giving βdriver menu, but make it C.β π
This function never fails.
Returns
An array of strings.
π« caca_get_display_driver π«
__extern char const * caca_get_display_driver (caca_display_t * dp)
Return the given displayβs current output driver. It is literally a little name tag for your display. π·οΈ
This function never fails.
Parameters
dpβ The caca display.
Returns
A static string.
π« caca_set_display_driver π«
__extern int caca_set_display_driver (caca_display_t * dp, char const * driver)
Dynamically change the given displayβs output driver. Driver glow-up, on demand. π
FIXME: decide what to do in case of failure
Parameters
dpβ The caca display.driverβ A string describing the desired output driver orNULLto choose the best driver automatically.
Returns
0 in case of success, -1 if an error occurred.
π« caca_free_display π«
__extern int caca_free_display (caca_display_t * dp)
Detach a graphical context from its caca backend and destroy it. The libcaca canvas continues to exist and other graphical contexts can be attached to it afterwards. So the canvas stays booked and busy, fr fr. π
If the caca canvas was automatically created by caca_create_display(), it is automatically destroyed and any handle to it becomes invalid. Do not touch that handle after, bestie. π
This function never fails.
Parameters
dpβ The libcaca graphical context.
Returns
This function always returns 0.
References caca_free_canvas(), and caca_unmanage_canvas().
π« caca_get_canvas π«
__extern caca_canvas_t * caca_get_canvas (caca_display_t * dp)
Return a handle on the caca_canvas_t object that was either attached or created by caca_create_display(). It is your backstage pass to the canvas. ποΈ
This function never fails.
Parameters
dpβ The libcaca graphical context.
Returns
The libcaca canvas.
π« caca_refresh_display π«
__extern int caca_refresh_display (caca_display_t * dp)
Flush all graphical operations and print them to the display device. Nothing will show on the screen until this function is called. So yes, this is the βactually put it on screenβ button. π₯
If caca_set_display_time() was called with a non-zero value, caca_refresh_display() will use that value to achieve constant framerate: if two consecutive calls to caca_refresh_display() are within a time range shorter than the value set with caca_set_display_time(), the second call will be delayed before performing the screen refresh. It is pacing itself, periodt. β±οΈ
This function never fails.
Parameters
dpβ The libcaca display context.
Returns
This function always returns 0.
References caca_clear_dirty_rect_list().
π« caca_set_display_time π«
__extern int caca_set_display_time (caca_display_t * dp, int usec)
Set the refresh delay in microseconds. The refresh delay is used by caca_refresh_display() to achieve constant framerate. See the caca_refresh_display() documentation for more details. Microseconds are tiny, but they are doing a lot of work here. π§
If the argument is zero, constant framerate is disabled. This is the default behaviour.
If an error occurs, -1 is returned and errno is set accordingly:
EINVALβ Refresh delay value is invalid.
Parameters
dpβ The libcaca display context.usecβ The refresh delay in microseconds.
Returns
0 upon success, -1 if an error occurred.
π« caca_get_display_time π«
__extern int caca_get_display_time (caca_display_t const * dp)
Get the average rendering time, which is the average measured time between two caca_refresh_display() calls, in microseconds. If constant framerate was activated by calling caca_set_display_time(), the average rendering time will be close to the requested delay even if the real rendering time was shorter. The math is mathing. π
This function never fails.
Parameters
dpβ The libcaca display context.
Returns
The render time in microseconds.
π« caca_get_display_width π«
__extern int caca_get_display_width (caca_display_t const * dp)
If libcaca runs in a window, get the usable window width. This value can be used for aspect ratio calculation. If libcaca does not run in a window or if there is no way to know the font size, most drivers will assume a 6x10 font is being used. Note that the units are not necessarily pixels. It is giving βwidth, but read the fine print.β π
This function never fails.
Parameters
dpβ The libcaca display context.
Returns
The display width.
π« caca_get_display_height π«
__extern int caca_get_display_height (caca_display_t const * dp)
If libcaca runs in a window, get the usable window height. This value can be used for aspect ratio calculation. If libcaca does not run in a window or if there is no way to know the font size, assume a 6x10 font is being used. Note that the units are not necessarily pixels. Height bestie has entered the chat. π
This function never fails.
Parameters
dpβ The libcaca display context.
Returns
The display height.
π« caca_set_display_title π«
__extern int caca_set_display_title (caca_display_t * dp, char const * title)
If libcaca runs in a window, try to change its title. This works with the ncurses, S-Lang, OpenGL, X11 and Win32 drivers. Window title main character energy. π
If an error occurs, -1 is returned and errno is set accordingly:
ENOSYSβ Display driver does not support setting the window title.
Parameters
dpβ The libcaca display context.titleβ The desired display title.
Returns
0 upon success, -1 if an error occurred.
π« caca_set_mouse π«
__extern int caca_set_mouse (caca_display_t * dp, int flag)
Show or hide the mouse pointer. This function works with the ncurses, S-Lang and X11 drivers. Mouse visibility vibe check. π±οΈ
If an error occurs, -1 is returned and errno is set accordingly:
ENOSYSβ Display driver does not support hiding the mouse pointer.
Parameters
dpβ The libcaca display context.flagβ0hides the pointer,1shows the systemβs default pointer (usually an arrow). Other values are reserved for future use.
Returns
0 upon success, -1 if an error occurred.
π« caca_set_cursor π«
__extern int caca_set_cursor (caca_display_t * dp, int flag)
Show or hide the cursor, for devices that support such a feature. Cursor glow-up or cursor disappearing act, your call. ποΈ
If an error occurs, -1 is returned and errno is set accordingly:
ENOSYSβ Display driver does not support showing the cursor.
Parameters
dpβ The libcaca display context.flagβ0hides the cursor,1shows the systemβs default cursor (usually a white rectangle). Other values are reserved for future use.
Returns
0 upon success, -1 if an error occurred.
Referenced by caca_conio__setcursortype().
β¨ AUTHOR β¨
okay so this is the part where we give credit π and honestly? it's giving "the robots did their homework" energy, because this whole page was generated automatically by Doxygen for libcaca from the source code. no cap β nobody sat down and hand-typed this, the documentation tool just slurped it straight out of the source and shipped it. iconic behaviour, honestly π
so if you're out here wondering who to thank for the words you just read: it's Doxygen</> and the libcaca</> source code, working together like the main character duo they are π«Ά
πΈ A lil' sign-off πΈ
and that's the whole page bestie, you ate that π this beauty came to you as Version 0.99.beta20, dated Wed May 13 2026 09:45:08, living its best life under the name caca_display(3caca). go forth, call your functions, and slay π
β¨π¦
π¦ where this page comes from
- opensuse-leap 16.0: libcaca-devel 0.99.beta20-160000.3.1 Β· WTFPL
- opensuse-leap 16.0: libcaca-devel 0.99.beta20-160000.3.1 Β· WTFPL
- opensuse-leap 16.0: libcaca-devel 0.99.beta20-160000.3.1 Β· WTFPL
- opensuse-leap 16.0: libcaca-devel 0.99.beta20-160000.3.1 Β· WTFPL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms