### Build and Install from Source Package Source: https://hpjansson.org/chafa/ref/chafa-building.html Standard procedure for building and installing Chafa from a source package using autoconf, automake, and libtool. ```bash ./configure ``` ```bash make ``` ```bash make install ``` -------------------------------- ### chafa_term_info_emit_begin_kitty_immediate_image_v1 Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Prints the control sequence for starting a Kitty immediate image transfer. ```APIDOC ## chafa_term_info_emit_begin_kitty_immediate_image_v1 ### Description Prints the control sequence for CHAFA_TERM_SEQ_BEGIN_KITTY_IMMEDIATE_IMAGE_V1. The destination buffer must have enough space to hold CHAFA_TERM_SEQ_LENGTH_MAX bytes. ### Parameters - **term_info** (ChafaTermInfo) - Required - A ChafaTermInfo object. - **dest** (gchar*) - Required - String destination buffer. - **bpp** (guint) - Required - Bits per pixel (24 for RGB, 32 for RGBA, 100 for PNG). - **width_pixels** (guint) - Required - Image width in pixels. - **height_pixels** (guint) - Required - Image height in pixels. - **width_cells** (guint) - Required - Target width in cells. - **height_cells** (guint) - Required - Target height in cells. ### Returns - Pointer to first byte after emitted string. ``` -------------------------------- ### chafa_term_info_emit_begin_kitty_image_chunk Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Prints the control sequence for starting a Kitty image data chunk. ```APIDOC ## chafa_term_info_emit_begin_kitty_image_chunk ### Description Prints the control sequence for CHAFA_TERM_SEQ_BEGIN_KITTY_IMAGE_CHUNK. ### Parameters - **term_info** (ChafaTermInfo) - Required - A ChafaTermInfo object. - **dest** (gchar*) - Required - String destination buffer. ### Returns - Pointer to first byte after emitted string. ``` -------------------------------- ### chafa_term_info_emit_begin_kitty_immediate_virt_image_v1 Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Prints the control sequence for starting a Kitty immediate virtual image transfer. ```APIDOC ## chafa_term_info_emit_begin_kitty_immediate_virt_image_v1 ### Description Prints the control sequence for CHAFA_TERM_SEQ_BEGIN_KITTY_IMMEDIATE_VIRT_IMAGE_V1. ### Parameters - **term_info** (ChafaTermInfo) - Required - A ChafaTermInfo object. - **dest** (gchar*) - Required - String destination buffer. - **bpp** (guint) - Required - Bits per pixel. - **width_pixels** (guint) - Required - Image width in pixels. - **height_pixels** (guint) - Required - Image height in pixels. - **width_cells** (guint) - Required - Target width in cells. - **height_cells** (guint) - Required - Target height in cells. - **id** (guint) - Required - Image ID. ### Returns - Pointer to first byte after emitted string. ``` -------------------------------- ### Manage ChafaTermInfo name Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Get or set the identifier string for a ChafaTermInfo instance. ```c const gchar * chafa_term_info_get_name (ChafaTermInfo *term_info); ``` ```c void chafa_term_info_set_name (ChafaTermInfo *term_info, const gchar *name); ``` -------------------------------- ### Get built-in features Source: https://hpjansson.org/chafa/ref/chafa-Features.html Retrieves the platform-specific features the library was compiled with. ```c ChafaFeatures chafa_get_builtin_features (_void_); ``` -------------------------------- ### Configure Script Options: Enable GTK-Doc Source: https://hpjansson.org/chafa/ref/chafa-building.html Explicitly enable the use of gtk-doc for building documentation, provided the package is installed. This is the default behavior if auto-detection succeeds. ```bash --enable-gtk-doc ``` -------------------------------- ### Manage ChafaTermInfo quirks Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Get or set the ChafaTermQuirks flags for a ChafaTermInfo instance. ```c ChafaTermQuirks chafa_term_info_get_quirks (ChafaTermInfo *term_info); ``` ```c void chafa_term_info_set_quirks (ChafaTermInfo *term_info, ChafaTermQuirks quirks); ``` -------------------------------- ### Get supported features Source: https://hpjansson.org/chafa/ref/chafa-Features.html Retrieves features that are both built-in and usable on the current runtime platform. ```c ChafaFeatures chafa_get_supported_features (_void_); ``` -------------------------------- ### Configure Script Options: Disable GTK-Doc Source: https://hpjansson.org/chafa/ref/chafa-building.html Explicitly disable the use of gtk-doc for building documentation. Pre-generated HTML files will be installed instead. ```bash --disable-gtk-doc ``` -------------------------------- ### Get and set ChafaPlacement vertical alignment Source: https://hpjansson.org/chafa/ref/chafa-ChafaPlacement.html Manages vertical distribution of padding, defaulting to CHAFA_ALIGN_START. ```c ChafaAlign chafa_placement_get_valign (ChafaPlacement *placement); ``` ```c void chafa_placement_set_valign (ChafaPlacement *placement, ChafaAlign align); ``` -------------------------------- ### Get and set ChafaPlacement horizontal alignment Source: https://hpjansson.org/chafa/ref/chafa-ChafaPlacement.html Manages horizontal distribution of padding, defaulting to CHAFA_ALIGN_START. ```c ChafaAlign chafa_placement_get_halign (ChafaPlacement *placement); ``` ```c void chafa_placement_set_halign (ChafaPlacement *placement, ChafaAlign align); ``` -------------------------------- ### Configure Script Options: Enable Man Pages Source: https://hpjansson.org/chafa/ref/chafa-building.html Explicitly enable the rebuilding of man pages from XML sources, provided xsltproc and necessary Docbook stylesheets are installed. This is the default behavior if auto-detection succeeds. ```bash --enable-man ``` -------------------------------- ### Render pixels to ANSI string Source: https://hpjansson.org/chafa/ref/chafa-using.html A complete example demonstrating how to initialize a Chafa canvas, draw pixel data, and print the resulting ANSI string to stdout. ```c #include #include #define PIX_WIDTH 3 #define PIX_HEIGHT 3 #define N_CHANNELS 4 int main (int argc, char *argv []) { const guint8 pixels [PIX_WIDTH * PIX_HEIGHT * N_CHANNELS] = { 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff }; ChafaSymbolMap *symbol_map; ChafaCanvasConfig *config; ChafaCanvas *canvas; GString *gs; /* Specify the symbols we want */ symbol_map = chafa_symbol_map_new (); chafa_symbol_map_add_by_tags (symbol_map, CHAFA_SYMBOL_TAG_ALL); /* Set up a configuration with the symbols and the canvas size in characters */ config = chafa_canvas_config_new (); chafa_canvas_config_set_geometry (config, 40, 20); chafa_canvas_config_set_symbol_map (config, symbol_map); /* Create canvas */ canvas = chafa_canvas_new (config); /* Draw pixels to canvas */ chafa_canvas_draw_all_pixels (canvas, CHAFA_PIXEL_RGBA8_UNASSOCIATED, pixels, PIX_WIDTH, PIX_HEIGHT, PIX_WIDTH * N_CHANNELS); /* Generate a string that will show the canvas contents on a terminal */ gs = chafa_canvas_print (canvas, NULL); /* Print the string */ fwrite (gs->str, sizeof (char), gs->len, stdout); fputc ('\n', stdout); /* Free resources */ g_string_free (gs, TRUE); chafa_canvas_unref (canvas); chafa_canvas_config_unref (config); chafa_symbol_map_unref (symbol_map); return 0; } ``` -------------------------------- ### Configure Script Options: Disable Man Pages Source: https://hpjansson.org/chafa/ref/chafa-building.html Explicitly disable the rebuilding of man pages from XML sources. Pre-generated man pages will be installed instead. ```bash --disable-man ``` -------------------------------- ### Get Fallback Terminal Info Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermDb.html Generates ChafaTermInfo using fallback control sequences. Use this for unknown terminals or to supplement missing capabilities, but be aware of potential unpredictable behavior. ```c ChafaTermInfo * chafa_term_db_get_fallback_info (_ChafaTermDb *term_db_); ``` -------------------------------- ### Get and set ChafaPlacement tucking policy Source: https://hpjansson.org/chafa/ref/chafa-ChafaPlacement.html Controls how the image is resized to fit its extents, defaulting to CHAFA_TUCK_STRETCH. ```c ChafaTuck chafa_placement_get_tuck (ChafaPlacement *placement); ``` ```c void chafa_placement_set_tuck (ChafaPlacement *placement, ChafaTuck tuck); ``` -------------------------------- ### Emit hyperlink sequences Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Functions for emitting hyperlink start, anchor, and end sequences. ```c gchar * chafa_term_info_emit_begin_hyperlink (_const ChafaTermInfo *term_info_, _gchar *dest_); ``` ```c gchar * chafa_term_info_emit_begin_hyperlink_anchor (_const ChafaTermInfo *term_info_, _gchar *dest_); ``` ```c gchar * chafa_term_info_emit_end_hyperlink (_const ChafaTermInfo *term_info_, _gchar *dest_); ``` -------------------------------- ### Get Transparency Threshold Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Retrieves the configured threshold for determining full transparency. Values above this threshold will be rendered as fully transparent. ```c gfloat chafa_canvas_config_get_transparency_threshold (_const ChafaCanvasConfig *config_); ``` -------------------------------- ### chafa_term_info_get_inherit_seq Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Gets whether a sequence can be inherited from the outer ChafaTermInfo. ```APIDOC ## chafa_term_info_get_inherit_seq ### Description Gets whether seq can be inherited from the outer ChafaTermInfo when chaining with chafa_term_info_chain(). ### Parameters #### Path Parameters - **term_info** (ChafaTermInfo) - Required - A ChafaTermInfo - **seq** (ChafaTermSeq) - Required - A ChafaTermSeq ### Response #### Success Response (200) - **Returns** (gboolean) - Whether seq gets inherited when chaining ``` -------------------------------- ### Create a new ChafaTermInfo Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Allocates a new, blank ChafaTermInfo instance. ```c ChafaTermInfo * chafa_term_info_new (void); ``` -------------------------------- ### GET chafa_canvas_config_get_passthrough Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Retrieves the current ChafaPassthrough setting for the configuration. ```APIDOC ## GET chafa_canvas_config_get_passthrough ### Description Returns the ChafaPassthrough setting. Passthrough is used to transmit escape codes to outer terminals (e.g., tmux). ### Parameters #### Path Parameters - **config** (ChafaCanvasConfig) - Required - A ChafaCanvasConfig instance. ### Response #### Success Response (200) - **Returns** (ChafaPassthrough) - The current passthrough setting. ``` -------------------------------- ### chafa_term_info_get_seq Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Gets the string equivalent of a sequence stored in terminal info. ```APIDOC ## chafa_term_info_get_seq ### Description Gets the string equivalent of seq stored in term_info. ### Parameters #### Path Parameters - **term_info** (ChafaTermInfo) - Required - A ChafaTermInfo - **seq** (ChafaTermSeq) - Required - A ChafaTermSeq to query for ### Response #### Success Response (200) - **Returns** (gchar*) - An unformatted string sequence, or NULL if not set. ``` -------------------------------- ### Prepare Git Repository Build Files Source: https://hpjansson.org/chafa/ref/chafa-building.html Run this script when building from a clean Git repository to prepare the build files before proceeding. ```bash ./autogen.sh ``` -------------------------------- ### GET chafa_canvas_config_get_optimizations Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Retrieves the current optimization flags for the specified ChafaCanvasConfig. ```APIDOC ## GET chafa_canvas_config_get_optimizations ### Description Returns the optimization flags stored in the configuration. Enabling these may produce more compact output at the cost of reduced compatibility and increased CPU usage. ### Parameters #### Path Parameters - **config** (ChafaCanvasConfig) - Required - A ChafaCanvasConfig instance. ### Response #### Success Response (200) - **Returns** (ChafaOptimizations) - The ChafaOptimizations flags. ``` -------------------------------- ### Copy a ChafaTermInfo Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Creates a new instance that is a copy of an existing ChafaTermInfo. ```c ChafaTermInfo * chafa_term_info_copy (const ChafaTermInfo *term_info); ``` -------------------------------- ### chafa_term_info_get_safe_symbol_tags Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Gets the ChafaSymbolTags that are likely safe to use with the specified terminal info. ```APIDOC ## chafa_term_info_get_safe_symbol_tags ### Description Gets the ChafaSymbolTags that are likely safe to use with term_info. The ChafaSymbolTags are a bitwise OR of flags from the enum. ### Parameters #### Path Parameters - **term_info** (ChafaTermInfo) - Required - A ChafaTermInfo ### Response #### Success Response (200) - **Returns** (ChafaSymbolTags) - The ChafaSymbolTags ``` -------------------------------- ### Create a new ChafaCanvasConfig Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Initializes a new configuration object with default settings. ```c ChafaCanvasConfig * chafa_canvas_config_new (void); ``` -------------------------------- ### Get sequence inheritance Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Checks if a sequence is inherited from an outer ChafaTermInfo during chaining. ```C gboolean chafa_term_info_get_inherit_seq (_ChafaTermInfo *term_info_, _ChafaTermSeq seq_); ``` -------------------------------- ### Create New ChafaTermDb Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermDb.html Creates a new, empty ChafaTermDb. Use this to initialize a custom terminal database. ```c ChafaTermDb * chafa_term_db_new (_void_); ``` -------------------------------- ### chafa_term_info_emit_begin_screen_passthrough Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Prints the control sequence to begin screen passthrough mode. ```APIDOC ## chafa_term_info_emit_begin_screen_passthrough ### Description Prints the control sequence for CHAFA_TERM_SEQ_BEGIN_SCREEN_PASSTHROUGH. Control sequences between begin and end must be escaped. ### Parameters - **term_info** (ChafaTermInfo) - Required - A ChafaTermInfo object. - **dest** (gchar*) - Required - String destination buffer. ### Returns - **gchar*** - Pointer to the first byte after the emitted string. ``` -------------------------------- ### Retrieve Chafa compiler and linker flags Source: https://hpjansson.org/chafa/ref/chafa-using.html Use pkg-config to obtain the necessary include paths and library flags for building applications with Chafa. ```shell $ pkg-config --cflags chafa -I/usr/include/chafa -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include $ pkg-config --libs chafa -lm -lchafa -lglib-2.0 ``` -------------------------------- ### Dither Intensity Configuration Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Functions to set and get the dither intensity for the Chafa canvas. ```APIDOC ## chafa_canvas_config_set_dither_intensity () ### Description Sets _`config`_'s stored relative intensity of the dithering pattern applied during image conversion. 1.0 is the default, corresponding to a moderate intensity. Possible values range from 0.0 to infinity, but in practice, values above 10.0 are rarely useful. ### Method void ### Endpoint N/A (Function call) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **config** (_ChafaCanvasConfig) - A ChafaCanvasConfig - **intensity** (_gfloat) - The desired relative dithering intensity ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ``` ```APIDOC ## chafa_canvas_config_get_dither_intensity () ### Description Returns the relative intensity of the dithering pattern applied during image conversion. 1.0 is the default, corresponding to a moderate intensity. ### Method gfloat ### Endpoint N/A (Function call) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **config** (_const ChafaCanvasConfig) - A ChafaCanvasConfig ### Request Example N/A ### Response #### Success Response (200) - **Return Value** (gfloat) - The relative dithering intensity #### Response Example N/A ``` -------------------------------- ### Create a new ChafaPlacement Source: https://hpjansson.org/chafa/ref/chafa-ChafaPlacement.html Initializes a new placement object for a given image with an optional ID. ```c ChafaPlacement * chafa_placement_new (ChafaImage *image, gint id); ``` -------------------------------- ### Dither Mode Configuration Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Functions to set and get the dithering mode for the Chafa canvas. ```APIDOC ## chafa_canvas_config_set_dither_mode () ### Description Sets _`config`_'s stored ChafaDitherMode to _`dither_mode`_. ### Method void ### Endpoint N/A (Function call) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **config** (_ChafaCanvasConfig) - A ChafaCanvasConfig - **dither_mode** (_ChafaDitherMode) - A ChafaDitherMode ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ``` ```APIDOC ## chafa_canvas_config_get_dither_mode () ### Description Returns _`config`_'s ChafaDitherMode. ### Method ChafaDitherMode ### Endpoint N/A (Function call) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **config** (_const ChafaCanvasConfig) - A ChafaCanvasConfig ### Request Example N/A ### Response #### Success Response (200) - **Return Value** (ChafaDitherMode) - The ChafaDitherMode. #### Response Example N/A ``` -------------------------------- ### Background Color Configuration Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Functions to set and get the background color of the Chafa canvas. ```APIDOC ## chafa_canvas_config_set_bg_color () ### Description Sets the assumed background color of the output device. This is used to determine how to apply the background and transparency pens in FGBG modes, and will also be substituted for partial transparency. ### Method void ### Endpoint N/A (Function call) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **config** (_ChafaCanvasConfig) - A ChafaCanvasConfig - **bg_color_packed_rgb** (_guint32) - Background color as packed RGB triplet ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ``` ```APIDOC ## chafa_canvas_config_get_bg_color () ### Description Gets the assumed background color of the output device. This is used to determine how to apply the background pen in FGBG modes. ### Method guint32 ### Endpoint N/A (Function call) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **config** (_const ChafaCanvasConfig) - A ChafaCanvasConfig ### Request Example N/A ### Response #### Success Response (200) - **Return Value** (guint32) - Background color as packed RGB triplet #### Response Example N/A ``` -------------------------------- ### Foreground Color Configuration Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Functions to set and get the foreground color of the Chafa canvas. ```APIDOC ## chafa_canvas_config_set_fg_color () ### Description Sets the assumed foreground color of the output device. This is used to determine how to apply the foreground pen in FGBG modes. ### Method void ### Endpoint N/A (Function call) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **config** (_ChafaCanvasConfig) - A ChafaCanvasConfig - **fg_color_packed_rgb** (_guint32) - Foreground color as packed RGB triplet ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ``` ```APIDOC ## chafa_canvas_config_get_fg_color () ### Description Gets the assumed foreground color of the output device. This is used to determine how to apply the foreground pen in FGBG modes. ### Method guint32 ### Endpoint N/A (Function call) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **config** (_const ChafaCanvasConfig) - A ChafaCanvasConfig ### Request Example N/A ### Response #### Success Response (200) - **Return Value** (guint32) - Foreground color as packed RGB triplet #### Response Example N/A ``` -------------------------------- ### Chain ChafaTermInfo instances Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Merges outer and inner terminal capabilities into a new ChafaTermInfo instance. ```c ChafaTermInfo * chafa_term_info_chain (ChafaTermInfo *outer, ChafaTermInfo *inner); ``` -------------------------------- ### chafa_term_info_emit_enable_alt_screen Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Prints the control sequence to enable the alternate screen. ```APIDOC ## chafa_term_info_emit_enable_alt_screen ### Description Prints the control sequence for CHAFA_TERM_SEQ_ENABLE_ALT_SCREEN. ### Parameters - **term_info** (ChafaTermInfo) - Required - A ChafaTermInfo object. - **dest** (gchar*) - Required - String destination buffer. ### Returns - **gchar*** - Pointer to the first byte after the emitted string. ``` -------------------------------- ### ChafaCanvasConfig - Geometry Settings Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Functions for getting and setting the geometry (width and height) of the ChafaCanvas. ```APIDOC ## ChafaCanvasConfig - Geometry ### `chafa_canvas_config_get_geometry()` Returns _`config`_'s width and height in character cells in the provided output locations. ##### Parameters - **config** (ChafaCanvasConfig) - A ChafaCanvasConfig. - **width_out** (gint*) - Location to store width in, or `NULL`. - **height_out** (gint*) - Location to store height in, or `NULL`. ### `chafa_canvas_config_set_geometry()` Sets _`config`_'s width and height in character cells to _`width`_x _`height`_. ##### Parameters - **config** (ChafaCanvasConfig) - The ChafaCanvasConfig to modify. - **width** (gint) - The desired width in character cells. - **height** (gint) - The desired height in character cells. ``` -------------------------------- ### Get and set canvas geometry Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Retrieves or updates the canvas dimensions in character cells. ```c void chafa_canvas_config_get_geometry (const ChafaCanvasConfig *config, gint *width_out, gint *height_out); ``` ```c void chafa_canvas_config_set_geometry (ChafaCanvasConfig *config, gint width, gint height); ``` -------------------------------- ### ChafaPlacement Getters and Setters Source: https://hpjansson.org/chafa/ref/chafa-ChafaPlacement.html Functions to get and set the tucking and alignment properties of a ChafaPlacement. ```APIDOC ## chafa_placement_get_tuck () ### Description Gets the tucking policy of a ChafaPlacement. This describes how the image is resized to fit the placement's extents, and defaults to CHAFA_TUCK_STRETCH. ### Parameters - **placement** (_ChafaPlacement_*) - A ChafaPlacement. ### Returns ChafaTuck - The tucking policy of the placement. ### Since 1.14 ## chafa_placement_set_tuck () ### Description Sets the tucking policy for a ChafaPlacement to the specified tuck value. This describes how the image is resized to fit the placement's extents, and defaults to CHAFA_TUCK_STRETCH. ### Parameters - **placement** (_ChafaPlacement_*) - A ChafaPlacement. - **tuck** (_ChafaTuck_) - Desired tucking policy. ### Since 1.14 ## chafa_placement_get_halign () ### Description Gets the horizontal alignment of a ChafaPlacement. This determines how any padding added by the tucking policy is distributed, and defaults to CHAFA_ALIGN_START. ### Parameters - **placement** (_ChafaPlacement_*) - A ChafaPlacement. ### Returns ChafaAlign - The horizontal alignment of the placement. ### Since 1.14 ## chafa_placement_set_halign () ### Description Sets the horizontal alignment of a ChafaPlacement. This determines how any padding added by the tucking policy is distributed, and defaults to CHAFA_ALIGN_START. ### Parameters - **placement** (_ChafaPlacement_*) - A ChafaPlacement. - **align** (_ChafaAlign_) - Desired horizontal alignment. ### Since 1.14 ## chafa_placement_get_valign () ### Description Gets the vertical alignment of a ChafaPlacement. This determines how any padding added by the tucking policy is distributed, and defaults to CHAFA_ALIGN_START. ### Parameters - **placement** (_ChafaPlacement_*) - A ChafaPlacement. ### Returns ChafaAlign - The vertical alignment of the placement. ### Since 1.14 ## chafa_placement_set_valign () ### Description Sets the vertical alignment of a ChafaPlacement. This determines how any padding added by the tucking policy is distributed. ### Parameters - **placement** (_ChafaPlacement_*) - A ChafaPlacement. - **align** (_ChafaAlign_) - Desired vertical alignment. ### Since 1.14 ``` -------------------------------- ### Transparency and Color Settings Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Methods to manage transparency thresholds and foreground color settings. ```APIDOC ## chafa_canvas_config_get_transparency_threshold ### Description Returns the threshold above which full transparency will be used. ## chafa_canvas_config_set_transparency_threshold ### Description Sets the threshold above which full transparency will be used. ## chafa_canvas_config_get_fg_only_enabled ### Description Queries whether to use foreground colors only, leaving the background unmodified. ## chafa_canvas_config_set_fg_only_enabled ### Description Indicates whether to use foreground colors only. ## chafa_canvas_config_get_fg_color ### Description Gets the assumed foreground color of the output device. ``` -------------------------------- ### chafa_term_info_emit_begin_tmux_passthrough Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Prints the control sequence to begin tmux passthrough mode. ```APIDOC ## chafa_term_info_emit_begin_tmux_passthrough ### Description Prints the control sequence for CHAFA_TERM_SEQ_BEGIN_TMUX_PASSTHROUGH. ### Parameters - **term_info** (ChafaTermInfo) - Required - A ChafaTermInfo object. - **dest** (gchar*) - Required - String destination buffer. ### Returns - **gchar*** - Pointer to the first byte after the emitted string. ``` -------------------------------- ### Compile a Chafa application Source: https://hpjansson.org/chafa/ref/chafa-using.html Use command substitution to include Chafa flags during the compilation process. Ensure the source file precedes the pkg-config command to avoid linker errors. ```shell $ cc hello.c `pkg-config --cflags --libs chafa` -o hello ``` -------------------------------- ### Get safe symbol tags Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Retrieves the ChafaSymbolTags considered safe for the specified terminal information. ```C ChafaSymbolTags chafa_term_info_get_safe_symbol_tags (_ChafaTermInfo *term_info_); ``` -------------------------------- ### Work Factor Configuration Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Functions to set and get the work/quality tradeoff factor for the Chafa canvas. ```APIDOC ## chafa_canvas_config_set_work_factor () ### Description Sets the work/quality tradeoff factor. A higher value means more time and memory will be spent towards a higher quality output. ### Method void ### Endpoint N/A (Function call) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **config** (_ChafaCanvasConfig) - A ChafaCanvasConfig - **work_factor** (_gfloat) - Work factor [0.0 - 1.0] ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ``` ```APIDOC ## chafa_canvas_config_get_work_factor () ### Description Gets the work/quality tradeoff factor. A higher value means more time and memory will be spent towards a higher quality output. ### Method gfloat ### Endpoint N/A (Function call) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **config** (_const ChafaCanvasConfig) - A ChafaCanvasConfig ### Request Example N/A ### Response #### Success Response (200) - **Return Value** (gfloat) - The work factor [0.0 - 1.0] #### Response Example N/A ``` -------------------------------- ### chafa_term_info_emit_begin_sixels Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Prints the control sequence to begin Sixel graphics output. The destination buffer must be large enough to hold the sequence. Parameters p1, p2, and p3 can typically be set to 0. ```APIDOC ## chafa_term_info_emit_begin_sixels ### Description Prints the control sequence for CHAFA_TERM_SEQ_BEGIN_SIXELS. _`dest`_must have enough space to hold CHAFA_TERM_SEQ_LENGTH_MAX bytes, even if the emitted sequence is shorter. The output will not be zero-terminated. All three parameters (_`p1`_,_`p2`_and _`p3`_) can normally be set to 0. ### Parameters #### Path Parameters - **term_info** (ChafaTermInfo) - Required - A ChafaTermInfo - **dest** (String) - Required - String destination - **p1** (Unsigned Integer) - Required - Pixel aspect selector - **p2** (Unsigned Integer) - Required - Background color selector - **p3** (Unsigned Integer) - Required - Horizontal grid selector ### Returns Pointer to first byte after emitted string ### Since 1.6 ``` -------------------------------- ### Emit Query for Text Area Size in Pixels Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Prints the control sequence for querying the text area size in pixels. Ensure the destination buffer has enough space. ```c gchar * chafa_term_info_emit_query_text_area_size_px (_const ChafaTermInfo *term_info_, _gchar *dest_); ``` -------------------------------- ### Get actual thread count Source: https://hpjansson.org/chafa/ref/chafa-Features.html Queries the number of worker threads that will be used for parallel processing. ```c gint chafa_get_n_actual_threads (_void_); ``` -------------------------------- ### ChafaCanvasConfig Dither API Source: https://hpjansson.org/chafa/ref/new-api-index-1.2.html Functions for getting and setting dithering properties within the ChafaCanvasConfig object. ```APIDOC ## C chafa_canvas_config_get_dither_grain_size ### Description Retrieves the current dither grain size from the ChafaCanvasConfig. ## C chafa_canvas_config_set_dither_grain_size ### Description Sets the dither grain size for the ChafaCanvasConfig. ## C chafa_canvas_config_get_dither_intensity ### Description Retrieves the current dither intensity from the ChafaCanvasConfig. ## C chafa_canvas_config_set_dither_intensity ### Description Sets the dither intensity for the ChafaCanvasConfig. ## C chafa_canvas_config_get_dither_mode ### Description Retrieves the current dither mode from the ChafaCanvasConfig. ## C chafa_canvas_config_set_dither_mode ### Description Sets the dither mode for the ChafaCanvasConfig. ``` -------------------------------- ### Get terminal sequence Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Retrieves the string representation of a specific terminal sequence stored in the terminal info. ```C const gchar * chafa_term_info_get_seq (_ChafaTermInfo *term_info_, _ChafaTermSeq seq_); ``` -------------------------------- ### ChafaCanvasConfig - Core Functions Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Provides functions for creating, copying, and managing references for ChafaCanvasConfig. ```APIDOC ## ChafaCanvasConfig ### Description A ChafaCanvasConfig describes a set of parameters for ChafaCanvas, such as its geometry, color space and other output characteristics. To create a new ChafaCanvasConfig, use `chafa_canvas_config_new()`. You can then modify it using its setters, e.g. `chafa_canvas_config_set_canvas_mode()` before assigning it to a new ChafaCanvas with `chafa_canvas_new()`. Note that it is not possible to change a canvas' configuration after the canvas is created. ### Functions #### `chafa_canvas_config_new()` Creates a new ChafaCanvasConfig with default settings. This object can later be used in the creation of a ChafaCanvas. ##### Returns The new ChafaCanvasConfig #### `chafa_canvas_config_copy()` Creates a new ChafaCanvasConfig that's a copy of _`config`_. ##### Parameters - **config** (ChafaSymbolMap) - A ChafaSymbolMap to copy. ##### Returns The new ChafaCanvasConfig #### `chafa_canvas_config_ref()` Adds a reference to _`config`_. ##### Parameters - **config** (ChafaCanvasConfig) - ChafaCanvasConfig to add a reference to. #### `chafa_canvas_config_unref()` Removes a reference from _`config`_. ##### Parameters - **config** (ChafaCanvasConfig) - ChafaCanvasConfig to remove a reference from. ``` -------------------------------- ### Dither Grain Size Configuration Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Functions to set and get the dither grain size for the Chafa canvas. ```APIDOC ## chafa_canvas_config_set_dither_grain_size () ### Description Sets _`config`_'s stored dither grain size to _`width`_by _`height`_pixels. These values can be 1, 2, 4 or 8. 8 corresponds to the size of an entire character cell. The default is 4 pixels by 4 pixels. ### Method void ### Endpoint N/A (Function call) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **config** (_ChafaCanvasConfig) - A ChafaCanvasConfig - **width** (_gint) - The desired grain width (1, 2, 4 or 8) - **height** (_gint) - The desired grain height (1, 2, 4 or 8) ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ``` ```APIDOC ## chafa_canvas_config_get_dither_grain_size () ### Description Returns _`config`_'s dither grain size in _`width_out`_and _`height_out`_. ### Method void ### Endpoint N/A (Function call) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body - **config** (_const ChafaCanvasConfig) - A ChafaCanvasConfig - **width_out** (_gint *) - Pointer to a location to store grain width - **height_out** (_gint *) - Pointer to a location to store grain height ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ``` -------------------------------- ### Create New ChafaSymbolMap Source: https://hpjansson.org/chafa/ref/chafa-ChafaSymbolMap.html Creates a new, empty ChafaSymbolMap. Use this to begin managing a set of symbols. ```c ChafaSymbolMap * chafa_symbol_map_new (_void_); ``` -------------------------------- ### Miscellaneous Versioning Macros Source: https://hpjansson.org/chafa/ref/new-api-index-1.2.html Macros for managing version requirements in Chafa. ```APIDOC ## V CHAFA_VERSION_MAX_ALLOWED ### Description Macro defining the maximum allowed version of Chafa. ## V CHAFA_VERSION_MIN_REQUIRED ### Description Macro defining the minimum required version of Chafa. ``` -------------------------------- ### chafa_term_info_emit_begin_iterm2_image Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Prints the control sequence to begin an iTerm2 image transmission. ```APIDOC ## chafa_term_info_emit_begin_iterm2_image ### Description Prints the control sequence for CHAFA_TERM_SEQ_BEGIN_ITERM2_IMAGE. The destination buffer must have enough space to hold CHAFA_TERM_SEQ_LENGTH_MAX bytes. ### Parameters - **term_info** (ChafaTermInfo) - Required - A ChafaTermInfo object. - **dest** (gchar*) - Required - String destination buffer. - **width** (guint) - Required - Image width in character cells. - **height** (guint) - Required - Image height in character cells. ### Returns - **gchar*** - Pointer to the first byte after the emitted string. ``` -------------------------------- ### Symbol Map Management Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Methods to get and set symbol maps and fill symbol maps for the canvas configuration. ```APIDOC ## chafa_canvas_config_peek_symbol_map ### Description Returns a pointer to the symbol map belonging to config. ## chafa_canvas_config_set_symbol_map ### Description Assigns a copy of symbol_map to config. ## chafa_canvas_config_peek_fill_symbol_map ### Description Returns a pointer to the fill symbol map belonging to config. ## chafa_canvas_config_set_fill_symbol_map ### Description Assigns a copy of fill_symbol_map to config. ``` -------------------------------- ### ChafaCanvasConfig - Pixel and Canvas Modes Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Functions for getting and setting the pixel mode and canvas mode of the ChafaCanvas configuration. ```APIDOC ## ChafaCanvasConfig - Pixel and Canvas Modes ### `chafa_canvas_config_get_pixel_mode()` Gets the pixel mode of the ChafaCanvas configuration. ### `chafa_canvas_config_set_pixel_mode()` Sets the pixel mode of the ChafaCanvas configuration. ### `chafa_canvas_config_get_canvas_mode()` Gets the canvas mode of the ChafaCanvas configuration. ### `chafa_canvas_config_set_canvas_mode()` Sets the canvas mode of the ChafaCanvas configuration. ``` -------------------------------- ### Get Default ChafaTermDb Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermDb.html Retrieves the global ChafaTermDb instance. This is typically used for read-only access and should not be unreferenced by the caller. ```c ChafaTermDb * chafa_term_db_get_default (_void_); ``` -------------------------------- ### chafa_term_info_emit_enable_sixel_scrolling Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Prints the control sequence to enable Sixel scrolling. The destination buffer must be large enough to hold the sequence. The output will not be zero-terminated. ```APIDOC ## chafa_term_info_emit_enable_sixel_scrolling ### Description Prints the control sequence for CHAFA_TERM_SEQ_ENABLE_SIXEL_SCROLLING. _`dest`_must have enough space to hold CHAFA_TERM_SEQ_LENGTH_MAX bytes, even if the emitted sequence is shorter. The output will not be zero-terminated. ### Parameters #### Path Parameters - **term_info** (ChafaTermInfo) - Required - A ChafaTermInfo - **dest** (String) - Required - String destination ### Returns Pointer to first byte after emitted string ### Since 1.10 ``` -------------------------------- ### Emit Text Area Size in Pixels Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Prints the control sequence for setting the text area size in pixels. Ensure the destination buffer has enough space. ```c gchar * chafa_term_info_emit_text_area_size_px (_const ChafaTermInfo *term_info_, _gchar *dest_, _guint height_px_, _guint width_px_); ``` -------------------------------- ### Configure Script Options: Enable Bsymbolic Source: https://hpjansson.org/chafa/ref/chafa-building.html Use this option to enable the -Bsymbolic-functions linker flag, which is the default behavior and avoids intra-library PLT jumps. ```bash --enable-Bsymbolic ``` -------------------------------- ### Get Immutable Symbol Map Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Retrieves a constant pointer to the symbol map associated with a ChafaCanvasConfig. This map can be inspected but not modified. ```c const ChafaSymbolMap * chafa_canvas_config_peek_symbol_map (_const ChafaCanvasConfig *config_); ``` -------------------------------- ### Get maximum thread count Source: https://hpjansson.org/chafa/ref/chafa-Features.html Queries the configured maximum number of worker threads. Returns -1 if the count is determined automatically. ```c gint chafa_get_n_threads (_void_); ``` -------------------------------- ### Get Foreground Color Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Retrieves the assumed foreground color of the output device. This color is used when applying the foreground pen in FGBG modes. ```c guint32 chafa_canvas_config_get_fg_color (_const ChafaCanvasConfig *config_); ``` -------------------------------- ### ChafaTermInfo Lifecycle Management Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Functions for creating, copying, and managing the reference count of ChafaTermInfo objects. ```APIDOC ## ChafaTermInfo Lifecycle ### Description Functions to initialize, duplicate, and manage the memory lifecycle of ChafaTermInfo objects. ### Methods - chafa_term_info_new(): Creates a new ChafaTermInfo object. - chafa_term_info_copy(): Creates a copy of an existing ChafaTermInfo object. - chafa_term_info_ref(): Increments the reference count. - chafa_term_info_unref(): Decrements the reference count and frees memory if zero. ``` -------------------------------- ### Emit Set Scrolling Rows Sequence Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Prints the control sequence for setting scrolling rows. Ensure the destination buffer has enough space. ```c gchar * chafa_term_info_emit_set_scrolling_rows (_const ChafaTermInfo *term_info_, _gchar *dest_, _guint top_, _guint bottom_); ``` -------------------------------- ### Get Immutable Fill Symbol Map Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvasConfig.html Returns a constant pointer to the fill symbol map of a ChafaCanvasConfig. This map is used for fill operations and can only be inspected. ```c const ChafaSymbolMap * chafa_canvas_config_peek_fill_symbol_map (_const ChafaCanvasConfig *config_); ``` -------------------------------- ### chafa_term_info_emit_end_screen_passthrough Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Prints the control sequence to end screen passthrough mode. ```APIDOC ## chafa_term_info_emit_end_screen_passthrough ### Description Prints the control sequence for CHAFA_TERM_SEQ_END_SCREEN_PASSTHROUGH. ### Parameters - **term_info** (ChafaTermInfo) - Required - A ChafaTermInfo object. - **dest** (gchar*) - Required - String destination buffer. ### Returns - **gchar*** - Pointer to the first byte after the emitted string. ``` -------------------------------- ### chafa_term_info_emit_query_primary_device_attributes Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Prints the control sequence for querying primary device attributes. ```APIDOC ## chafa_term_info_emit_query_primary_device_attributes ### Description Prints the control sequence for CHAFA_TERM_SEQ_QUERY_PRIMARY_DEVICE_ATTRIBUTES. ### Parameters #### Path Parameters - **term_info** (ChafaTermInfo) - Required - A ChafaTermInfo object - **dest** (String) - Required - Destination buffer ### Response - **Returns** (Pointer) - Pointer to first byte after emitted string ``` -------------------------------- ### Create ChafaCanvas Similar to Original Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvas.html Creates a new canvas with configuration copied from an existing canvas. Useful for creating canvases with consistent settings. ```c ChafaCanvas * chafa_canvas_new_similar (_ChafaCanvas *orig_); ``` -------------------------------- ### chafa_term_info_emit_query_default_bg Source: https://hpjansson.org/chafa/ref/chafa-ChafaTermInfo.html Prints the control sequence for querying the default background color. ```APIDOC ## chafa_term_info_emit_query_default_bg ### Description Prints the control sequence for CHAFA_TERM_SEQ_QUERY_DEFAULT_BG. The destination buffer must have enough space to hold CHAFA_TERM_SEQ_LENGTH_MAX bytes. ### Parameters #### Path Parameters - **term_info** (ChafaTermInfo) - Required - A ChafaTermInfo object - **dest** (String) - Required - Destination buffer ### Response - **Returns** (Pointer) - Pointer to first byte after emitted string ``` -------------------------------- ### Get Character at Canvas Cell Source: https://hpjansson.org/chafa/ref/chafa-ChafaCanvas.html Retrieves the character at a specific cell (x, y) on the canvas. For double-width characters, the leftmost cell contains the character and the rightmost contains 0. ```c gunichar chafa_canvas_get_char_at (_ChafaCanvas *canvas_, _gint x_, _gint y_); ```