---
name: "attributes"
section: "3caca"
platform: "linux"
package: "libcucul-dev"
version: "0.99.beta11.debian-2"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/attributes"
---

# attributes(3caca)

## NAME

libcucul attribute conversions -

### Functions

unsigned char **cucul\_attr\_to\_ansi** (unsigned long int)\
 *Get DOS ANSI information from attribute.*  unsigned char **cucul\_attr\_to\_ansi\_fg** (unsigned long int)\
 *Get ANSI foreground information from attribute.*  unsigned char **cucul\_attr\_to\_ansi\_bg** (unsigned long int)\
 *Get ANSI background information from attribute.*

## Detailed Description

These functions perform conversions between attribute values.

## Function Documentation

### unsigned char cucul\_attr\_to\_ansi (unsigned long int attr)

Get the ANSI colour pair for a given attribute. The returned value is an 8-bit value whose higher 4 bits are the background colour and lower 4 bits are the foreground colour.

If the attribute has ARGB colours, the nearest colour is used. Special attributes such as *CUCUL\_DEFAULT* and *CUCUL\_TRANSPARENT* are not handled and are both replaced with *CUCUL\_LIGHTGRAY* for the foreground colour and *CUCUL\_BLACK* for the background colour.

This function never fails. If the attribute value is outside the expected 32-bit range, higher order bits are simply ignored.

**Parameters:**

*attr* The requested attribute value.

**Returns:**

The corresponding DOS ANSI value.

### unsigned char cucul\_attr\_to\_ansi\_fg (unsigned long int attr)

Get the ANSI foreground colour value for a given attribute. The returned value is either one of the *CUCUL\_RED*, *CUCUL\_BLACK* etc. predefined colours, or the special value *CUCUL\_DEFAULT* meaning the media's default foreground value, or the special value *CUCUL\_TRANSPARENT*.

If the attribute has ARGB colours, the nearest colour is returned.

This function never fails. If the attribute value is outside the expected 32-bit range, higher order bits are simply ignored.

**Parameters:**

*attr* The requested attribute value.

**Returns:**

The corresponding ANSI foreground value.

### unsigned char cucul\_attr\_to\_ansi\_bg (unsigned long int attr)

Get the ANSI background colour value for a given attribute. The returned value is either one of the *CUCUL\_RED*, *CUCUL\_BLACK* etc. predefined colours, or the special value *CUCUL\_DEFAULT* meaning the media's default background value, or the special value *CUCUL\_TRANSPARENT*.

If the attribute has ARGB colours, the nearest colour is returned.

This function never fails. If the attribute value is outside the expected 32-bit range, higher order bits are simply ignored.

**Parameters:**

*attr* The requested attribute value.

**Returns:**

The corresponding ANSI background value.
