Text Buffer

Text Buffer — Common behavior for Talkatu text buffers.

Functions

Properties

GActionGroup * action-group Read / Write / Construct Only
TalkatuBufferStyle style Read / Write / Construct Only

Types and Values

Object Hierarchy

    GObject
    ╰── GtkTextBuffer
        ╰── TalkatuBuffer
            ├── TalkatuHtmlBuffer
            ├── TalkatuMarkdownBuffer
            ╰── TalkatuWholeBuffer

Description

Talkatu implements a couple of different types of text buffers. This API tries to abstract the commonalities between them and make it easier to create text buffers for additional markup types.

Functions

talkatu_buffer_new ()

GtkTextBuffer *
talkatu_buffer_new (GSimpleActionGroup *action_group);

This is a simple GtkTextBuffer subclass that contains the shared behavior for the other Talkatu text buffers.

Parameters

action_group

An optional GSimpleAction group to use.

 

Returns

The TalkatuBuffer instance.

[transfer full]


talkatu_buffer_get_style ()

TalkatuBufferStyle
talkatu_buffer_get_style (TalkatuBuffer *buffer);

Get's format style of buffer .

Parameters

buffer

A TalkatuBuffer instance.

 

Returns

The format style of buffer .


talkatu_buffer_get_action_group ()

GSimpleActionGroup *
talkatu_buffer_get_action_group (TalkatuBuffer *buffer);

A TalkatuBuffer can support multiple actions, whether it's formatting of text, or being able to insert images, code, etc. This function is called by TalkatuView to map them to keybindings as well as the format toolbar.

Parameters

buffer

A TalkatuBuffer instance.

 

Returns

The GSimpleActionGroup the buffer supports.

[transfer none]


talkatu_buffer_insert_markup ()

void
talkatu_buffer_insert_markup (TalkatuBuffer *buffer,
                              GtkTextIter *pos,
                              const gchar *new_text,
                              gint new_text_length);

Inserts text that will be or already is marked up. Calling this tells buffer to not apply the currently selected format to the newly inserted text, which is what it does when text is normally inserted.

Parameters

buffer

The TalkatuBuffer instance.

 

pos

The GtkTextIter where the text should be inserted.

 

new_text

The new text to insert.

 

new_text_length

The len of new_text .

 

talkatu_buffer_insert_markup_with_tags_by_name ()

void
talkatu_buffer_insert_markup_with_tags_by_name
                               (TalkatuBuffer *buffer,
                                GtkTextIter *pos,
                                const gchar *new_text,
                                gint new_text_length,
                                const gchar *first_tag_name,
                                ...);

Similiar to talkatu_buffer_insert_markup but allows you to specify tags to apply to the newly inserted text.

Parameters

buffer

The TalkatuBuffer instance.

 

pos

The GtkTextIter where the text should be inserted.

 

new_text

UTF-8 text.

 

new_text_length

The len of new_text , or -1.

 

first_tag_name

The name of the first tag to apply to new_text .

 

...

Additional tags to apply to new_text .

 

talkatu_buffer_insert_link ()

void
talkatu_buffer_insert_link (TalkatuBuffer *buffer,
                            GtkTextIter *pos,
                            const gchar *display_text,
                            const gchar *url);

Inserts a link into buffer with the given url and display_text . If display_text is not given, url will be used.

Parameters

buffer

The TalkatuBuffer instance.

 

pos

The GtkTextIter where to insert the link.

 

display_text

The Text to display for the link.

 

url

The url to link to.

 

talkatu_buffer_clear ()

void
talkatu_buffer_clear (TalkatuBuffer *buffer);

Clears all text out of the buffer.

Parameters

buffer

The TalkatuBuffer instance.

 

talkatu_buffer_get_plain_text ()

gchar *
talkatu_buffer_get_plain_text (TalkatuBuffer *buffer);

Returns the text from the buffer without markup.

Returns (transfer full): A copy of the text from buffer .

Parameters

buffer

The TalkatuBuffer instance.

 

talkatu_buffer_get_is_empty ()

gboolean
talkatu_buffer_get_is_empty (TalkatuBuffer *buffer);

Returns whether or not buffer has any text in it.

Parameters

buffer

The TalkatuBuffer instance.

 

Returns

TRUE if empty, FALSE otherwise.

Types and Values

enum TalkatuBufferStyle

The format style of a TalkatuBuffer.

Members

TALKATU_BUFFER_STYLE_RICH

Format the buffer character by character.

 

TALKATU_BUFFER_STYLE_WHOLE

Format the buffer as a whole.

 

TALKATU_BUFFER_LINK_TARGET_ATTRIBUTE

#define TALKATU_BUFFER_LINK_TARGET_ATTRIBUTE "talkatu_link_target"

The name of the attribute set on GtkTextTags that contain the URL for links.


TALKATU_TYPE_BUFFER

#define TALKATU_TYPE_BUFFER            (talkatu_buffer_get_type())

struct TalkatuBufferClass

struct TalkatuBufferClass {
	GtkTextBufferClass parent;

	void (*insert_markup)(TalkatuBuffer *buffer, GtkTextIter *pos, const gchar *new_text, gint new_text_length);

	GSimpleActionGroup *(*create_action_group)(TalkatuBuffer *buffer);

	gpointer reserved[4];
};

TalkatuBuffer

typedef struct _TalkatuBuffer TalkatuBuffer;

Property Details

The “action-group” property

  “action-group”             GActionGroup *

The action group for this buffer.

Flags: Read / Write / Construct Only


The “style” property

  “style”                    TalkatuBufferStyle

The format style of the buffer.

Flags: Read / Write / Construct Only

Default value: TALKATU_BUFFER_STYLE_RICH