## IBusAttribute

IBusAttribute — Attributes of IBusText.

## Stability Level

Stable, unless otherwise indicated

## Functions

IBusAttribute * | ibus_attribute_new ()
guint | ibus_attribute_get_attr_type ()
guint | ibus_attribute_get_value ()
guint | ibus_attribute_get_start_index ()
guint | ibus_attribute_get_end_index ()
IBusAttribute * | ibus_attr_underline_new ()
IBusAttribute * | ibus_attr_foreground_new ()
IBusAttribute * | ibus_attr_background_new ()
IBusAttribute * | ibus_attr_hint_new ()

## Types and Values

enum | IBusAttrType
enum | IBusAttrUnderline
enum | IBusAttrPreedit
struct | IBusAttribute

## Object Hierarchy

        GEnum
        ├── IBusAttrType
        ╰── IBusAttrUnderline
        GObject
        ╰── GInitiallyUnowned
            ╰── IBusObject
                ╰── IBusSerializable
                    ╰── IBusAttribute

## Description

An IBusAttribute represents an attribute that associate to IBusText. It decorates preedit buffer and auxiliary text with underline, foreground and background colors.

## Functions

### ibus_attribute_new ()

    IBusAttribute *
    ibus_attribute_new (guint type,
                        guint value,
                        guint start_index,
                        guint end_index);

Creates a new IBusAttribute.

#### Parameters

type | Type of the attribute. |
value | Value of the attribute. |
start_index | Where attribute starts. |
end_index | Where attribute ends. |

#### Returns

A newly allocated IBusAttribute.

[transfer none]

### ibus_attribute_get_attr_type ()

    guint
    ibus_attribute_get_attr_type (IBusAttribute *attr);

Gets an enum of IBusAttrType.

#### Parameters

attr | An IBusAttribute |

#### Returns

An enum of IBusAttrType.

### ibus_attribute_get_value ()

    guint
    ibus_attribute_get_value (IBusAttribute *attr);

Gets an unsigned int value relative with IBusAttrType. If the type is `IBUS_ATTR_TYPE_UNDERLINE`, the return value is IBusAttrUnderline. If the type is `IBUS_ATTR_TYPE_FOREGROUND`, the return value is the color RGB. if the type is `IBUS_ATTR_TYPE_HINT`, the return value is the value of IBusAttrPreedit.

#### Parameters

attr | An IBusAttribute |

#### Returns

An unsigned int value relative with IBusAttrType.

### ibus_attribute_get_start_index ()

    guint
    ibus_attribute_get_start_index (IBusAttribute *attr);

Gets a start unsigned index

#### Parameters

attr | An IBusAttribute |

#### Returns

A start unsigned index

### ibus_attribute_get_end_index ()

    guint
    ibus_attribute_get_end_index (IBusAttribute *attr);

Gets an end unsigned index

#### Parameters

attr | An IBusAttribute |

#### Returns

A end unsigned index

### ibus_attr_underline_new ()

    IBusAttribute *
    ibus_attr_underline_new (guint underline_type,
                             guint start_index,
                             guint end_index);

`ibus_attr_underline_new` has been deprecated since version 1.5.33 and should not be used in newly-written code.

Use `ibus_attr_hint_new()`.

Creates a new underline IBusAttribute. Workaround of "transfer none" for `ibus_attr_list_append()`.

#### Parameters

underline_type | Type of underline. |
start_index | Where attribute starts. |
end_index | Where attribute ends. |

#### Returns

A newly allocated IBusAttribute.

[transfer none]

### ibus_attr_foreground_new ()

    IBusAttribute *
    ibus_attr_foreground_new (guint color,
                              guint start_index,
                              guint end_index);

`ibus_attr_foreground_new` has been deprecated since version 1.5.33 and should not be used in newly-written code.

Use `ibus_attr_hint_new()`.

Creates a new foreground IBusAttribute. Workaround of "transfer none" for `ibus_attr_list_append()`.

#### Parameters

color | Color in RGB. |
start_index | Where attribute starts. |
end_index | Where attribute ends. |

#### Returns

A newly allocated IBusAttribute.

[transfer none]

### ibus_attr_background_new ()

    IBusAttribute *
    ibus_attr_background_new (guint color,
                              guint start_index,
                              guint end_index);

`ibus_attr_background_new` has been deprecated since version 1.5.33 and should not be used in newly-written code.

Use `ibus_attr_hint_new()`.

Creates a new background IBusAttribute. Workaround of "transfer none" for `ibus_attr_list_append()`.

#### Parameters

color | Color in RGB. |
start_index | Where attribute starts. |
end_index | Where attribute ends. |

#### Returns

A newly allocated IBusAttribute.

[transfer none]

### ibus_attr_hint_new ()

    IBusAttribute *
    ibus_attr_hint_new (guint hint,
                        guint start_index,
                        guint end_index);

Creates a new hint attribute IBusAttribute. Workaround of "transfer none" for `ibus_attr_list_append()`.

#### Parameters

hint | Only IBusAttrPreedit is supported at present. |
start_index | Where attribute starts. |
end_index | Where attribute ends. |

#### Returns

A newly allocated IBusAttribute.

[transfer none]

Since: 1.5.33

Stability Level: Unstable

## Types and Values

### enum IBusAttrType

Type enumeration of IBusText attribute.

#### Members

IBUS_ATTR_TYPE_UNDERLINE | Decorate with underline. |
IBUS_ATTR_TYPE_FOREGROUND | Foreground color. |
IBUS_ATTR_TYPE_BACKGROUND | Background color. |
IBUS_ATTR_TYPE_HINT | Use the preedit hint and each engine does not specify the RGBA values but IBus panel or the Wayland panel decides the actual values. Since: 1.5.33 |

Stability Level: Stable

### enum IBusAttrUnderline

Type of IBusText attribute.

#### Members

IBUS_ATTR_UNDERLINE_NONE | No underline. |
IBUS_ATTR_UNDERLINE_SINGLE | Single underline. |
IBUS_ATTR_UNDERLINE_DOUBLE | Double underline. |
IBUS_ATTR_UNDERLINE_LOW | Low underline ? FIXME |
IBUS_ATTR_UNDERLINE_ERROR | Error underline |

### enum IBusAttrPreedit

Type of Pre-edit style as the semantic name. The Wayland specs prefers to express the semantic values rather than RGB values and text-input protocol version 1 defines some values: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/unstable/text-input/text-input-unstable-v1.xml?ref_type=headsL251

IBus compiled the values for major input method engines: https://github.com/ibus/ibus/wiki/Wayland-Colors

#### Members

IBUS_ATTR_PREEDIT_DEFAULT | Default style for composing text and used in the internal logic only with the Wayland text-input protocol V1. Each IBusEngine should not use it with `ibus_attr_hint_new()`. |
IBUS_ATTR_PREEDIT_WHOLE | Most language engines wish to draw underline in the typed whole preedit string except for the prediction string. (Chinese, Japanese, Typing-booster) |
IBUS_ATTR_PREEDIT_SELECTION | Modifying an active segment is distinguished against whole the preedit text. (Hangul, Japanese) |
IBUS_ATTR_PREEDIT_PREDICTION | A prediction string can be appended after the typed string. (Typing-booster) |
IBUS_ATTR_PREEDIT_PREFIX | A prefix string can be an informative color. (Table) |
IBUS_ATTR_PREEDIT_SUFFIX | A suffix string can be an informative color. (Table) |
IBUS_ATTR_PREEDIT_ERROR_SPELLING | An detected typo could be an error color with a spelling check or the word could not be found in a dictionary. The underline color also might be more visible. (Typing-booster, Table) |
IBUS_ATTR_PREEDIT_ERROR_COMPOSE | A wrong compose key could be an error color. (Typing-booster) |
IBUS_ATTR_PREEDIT_NONE | Designed for non-composing text with the Wayland text-input protocol V1 but this is deprecated. |

Since: 1.5.29

Stability Level: Unstable

### struct IBusAttribute

    struct IBusAttribute {
        guint type;
        guint value;
        guint start_index;
        guint end_index;
    };

Signify the type, value and scope of the attribute. The scope starts from `start_index` till the `end_index` -1.

#### Members

guint `type`; | IBusAttributeType |
guint `value`; | Value for the type. |
guint `start_index`; | The starting index, inclusive. |
guint `end_index`; | The ending index, exclusive. |

## See Also

IBusText