## IBusText IBusText — Text with decorating information. |

## Functions

IBusText * | ibus_text_new_from_string ()
IBusText * | ibus_text_new_from_ucs4 ()
IBusText * | ibus_text_new_from_static_string ()
IBusText * | ibus_text_new_from_printf ()
IBusText * | ibus_text_new_from_unichar ()
void | ibus_text_append_attribute ()
guint | ibus_text_get_length ()
gboolean | ibus_text_get_is_static ()
const gchar * | ibus_text_get_text ()
IBusAttrList * | ibus_text_get_attributes ()
void | ibus_text_set_attributes ()

## Types and Values

struct | IBusText

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── IBusObject
                ╰── IBusSerializable
                    ╰── IBusText

## Description

An IBusText is the main text object in IBus. The text is decorated according to associated IBusAttribute, e.g. the foreground/background color, underline, and applied scope.

see_also: IBusAttribute

## Functions

### ibus_text_new_from_string ()

    IBusText *
    ibus_text_new_from_string (const gchar *str);

New an IBusText from a string.

`str` will be duplicated in IBusText, so feel free to free `str` after this function.

#### Parameters

str | An text string to be set. |

#### Returns

A newly allocated IBusText.

### ibus_text_new_from_ucs4 ()

    IBusText *
    ibus_text_new_from_ucs4 (const gunichar *str);

New an IBusText from an UCS-4 encoded string.

`str` will be duplicated in IBusText, so feel free to free `str` after this function.

#### Parameters

str | An text string to be set. |

#### Returns

A newly allocated IBusText.

### ibus_text_new_from_static_string ()

    IBusText *
    ibus_text_new_from_static_string (const gchar *str);

New an IBusText from a static string.

Since `str` is a static string which won't be freed. This function will NOT duplicate `str` .

#### Parameters

str | An text string to be set. |

#### Returns

A newly allocated IBusText.

### ibus_text_new_from_printf ()

    IBusText *
    ibus_text_new_from_printf (const gchar *fmt,
                               ...);

New an IBusText from a printf expression.

The result of printf expression is stored in the new IBusText instance.

#### Parameters

fmt | printf format string. |
... | arguments for `fmt` . |

#### Returns

A newly allocated IBusText.

### ibus_text_new_from_unichar ()

    IBusText *
    ibus_text_new_from_unichar (gunichar c);

New an IBusText from a single UCS4-encoded character.

#### Parameters

c | A single UCS4-encoded character. |

#### Returns

A newly allocated IBusText.

### ibus_text_append_attribute ()

    void
    ibus_text_append_attribute (IBusText *text,
                                guint type,
                                guint value,
                                guint start_index,
                                gint end_index);

Append an IBusAttribute for IBusText.

#### Parameters

text | an IBusText |
type | IBusAttributeType for `text` . |
value | Value for the type. |
start_index | The starting index, inclusive. |
end_index | The ending index, exclusive. |

### ibus_text_get_length ()

    guint
    ibus_text_get_length (IBusText *text);

Return number of characters in an IBusText. This function is based on `g_utf8_strlen()`, so unlike `strlen()`, it does not count by bytes but characters instead.

#### Parameters

text | An IBusText. |

#### Returns

Number of character in `text` , not counted by bytes.

### ibus_text_get_is_static ()

    gboolean
    ibus_text_get_is_static (IBusText *text);

Return the is_static in an IBusText.

#### Parameters

text | An IBusText. |

#### Returns

the is_static in `text` .

### ibus_text_get_text ()

    const gchar *
    ibus_text_get_text (IBusText *text);

Return the text in an IBusText. Should not be freed.

#### Parameters

text | An IBusText. |

#### Returns

the text in `text` .

### ibus_text_get_attributes ()

    IBusAttrList *
    ibus_text_get_attributes (IBusText *text);

Return the attributes in an IBusText. Should not be freed.

#### Parameters

text | An IBusText. |

#### Returns

the attrs in `text` .

[transfer none]

### ibus_text_set_attributes ()

    void
    ibus_text_set_attributes (IBusText *text,
                              IBusAttrList *attrs);

#### Parameters

text | An IBusText. |
attrs | An IBusAttrList |

## Types and Values

### struct IBusText

    struct IBusText {
        gboolean is_static;
        gchar  *text;
        IBusAttrList *attrs;
    };

A text object in IBus.

#### Members

gboolean `is_static`; | Whether `text` is static, i.e., no need and will not be freed. Only TRUE if IBusText is newed from `ibus_text_new_from_static_string()`. |
gchar *`text`; | The string content of IBusText in UTF-8. |
IBusAttrList *`attrs`; | Associated IBusAttributes. |