## EHTMLEditorSelection EHTMLEditorSelection |

## Synopsis

    gboolean            e_html_editor_selection_has_text    (EHTMLEditorSelection *selection);
    gchar *             e_html_editor_selection_get_caret_word
                                                            (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_replace_caret_word
                                                            (EHTMLEditorSelection *selection,
                                                             const gchar *replacement);
    enum                EHTMLEditorSelectionAlignment;
    EHTMLEditorSelectionAlignment e_html_editor_selection_get_alignment
                                                            (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_set_alignment
                                                            (EHTMLEditorSelection *selection,
                                                             EHTMLEditorSelectionAlignment alignment);
    const gchar *       e_html_editor_selection_get_background_color
                                                            (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_set_background_color
                                                            (EHTMLEditorSelection *selection,
                                                             const gchar *color);
    void                e_html_editor_selection_get_font_color
                                                            (EHTMLEditorSelection *selection,
                                                             GdkRGBA *rgba);
    void                e_html_editor_selection_set_font_color
                                                            (EHTMLEditorSelection *selection,
                                                             const GdkRGBA *rgba);
    const gchar *       e_html_editor_selection_get_font_name
                                                            (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_set_font_name
                                                            (EHTMLEditorSelection *selection,
                                                             const gchar *font_name);
    enum                EHTMLEditorSelectionFontSize;
    guint               e_html_editor_selection_get_font_size
                                                            (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_set_font_size
                                                            (EHTMLEditorSelection *selection,
                                                             guint font_size);
    enum                EHTMLEditorSelectionBlockFormat;
    EHTMLEditorSelectionBlockFormat e_html_editor_selection_get_block_format
                                                            (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_set_block_format
                                                            (EHTMLEditorSelection *selection,
                                                             EHTMLEditorSelectionBlockFormat format);
    gboolean            e_html_editor_selection_is_citation (EHTMLEditorSelection *selection);
    gboolean            e_html_editor_selection_is_indented (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_indent      (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_unindent    (EHTMLEditorSelection *selection);
    gboolean            e_html_editor_selection_is_bold     (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_set_bold    (EHTMLEditorSelection *selection,
                                                             gboolean bold);
    gboolean            e_html_editor_selection_is_italic   (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_set_italic  (EHTMLEditorSelection *selection,
                                                             gboolean italic);
    gboolean            e_html_editor_selection_is_monospaced
                                                            (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_set_monospaced
                                                            (EHTMLEditorSelection *selection,
                                                             gboolean monospaced);
    gboolean            e_html_editor_selection_is_superscript
                                                            (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_set_superscript
                                                            (EHTMLEditorSelection *selection,
                                                             gboolean superscript);
    gboolean            e_html_editor_selection_is_subscript
                                                            (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_set_subscript
                                                            (EHTMLEditorSelection *selection,
                                                             gboolean subscript);
    gboolean            e_html_editor_selection_is_underline
                                                            (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_set_underline
                                                            (EHTMLEditorSelection *selection,
                                                             gboolean underline);
    void                e_html_editor_selection_unlink      (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_create_link (EHTMLEditorSelection *selection,
                                                             const gchar *uri);
    const gchar *       e_html_editor_selection_get_string  (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_replace     (EHTMLEditorSelection *selection,
                                                             const gchar *new_string);
    void                e_html_editor_selection_insert_html (EHTMLEditorSelection *selection,
                                                             const gchar *html_text);
    void                e_html_editor_selection_insert_image
                                                            (EHTMLEditorSelection *selection,
                                                             const gchar *image_uri);
    void                e_html_editor_selection_insert_text (EHTMLEditorSelection *selection,
                                                             const gchar *plain_text);
    void                e_html_editor_selection_wrap_lines  (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_save        (EHTMLEditorSelection *selection);
    void                e_html_editor_selection_restore     (EHTMLEditorSelection *selection);
    enum                EHTMLEditorSelectionGranularity;
    void                e_html_editor_selection_move        (EHTMLEditorSelection *selection,
                                                             gboolean forward,
                                                             EHTMLEditorSelectionGranularity granularity);
    void                e_html_editor_selection_extend      (EHTMLEditorSelection *selection,
                                                             gboolean forward,
                                                             EHTMLEditorSelectionGranularity granularity);

## Description

## Details

### e_html_editor_selection_has_text ()

    gboolean            e_html_editor_selection_has_text    (EHTMLEditorSelection *selection);

Returns whether current selection contains any text.

`selection` : | an EHTMLEditorSelection
Returns : | `TRUE` when current selection contains text, `FALSE` otherwise.

### e_html_editor_selection_get_caret_word ()

    gchar *             e_html_editor_selection_get_caret_word
                                                            (EHTMLEditorSelection *selection);

Returns word under cursor.

`selection` : | an EHTMLEditorSelection
Returns : | A newly allocated string with current caret word or `NULL` when there is no text under cursor or when selection is active. [transfer-full].

### e_html_editor_selection_replace_caret_word ()

    void                e_html_editor_selection_replace_caret_word
                                                            (EHTMLEditorSelection *selection,
                                                             const gchar *replacement);

Replaces current word under cursor with `replacement`.

`selection` : | an EHTMLEditorSelection
`replacement` : | a string to replace current caret word with

### enum EHTMLEditorSelectionAlignment

    typedef enum {
    	E_HTML_EDITOR_SELECTION_ALIGNMENT_LEFT,
    	E_HTML_EDITOR_SELECTION_ALIGNMENT_CENTER,
    	E_HTML_EDITOR_SELECTION_ALIGNMENT_RIGHT
    } EHTMLEditorSelectionAlignment;

`E_HTML_EDITOR_SELECTION_ALIGNMENT_LEFT` |
`E_HTML_EDITOR_SELECTION_ALIGNMENT_CENTER` |
`E_HTML_EDITOR_SELECTION_ALIGNMENT_RIGHT` |

### e_html_editor_selection_get_alignment ()

    EHTMLEditorSelectionAlignment e_html_editor_selection_get_alignment
                                                            (EHTMLEditorSelection *selection);

Returns alignment of current paragraph

`selection` : | an EHTMLEditorSelection
Returns : | EHTMLEditorSelectionAlignment

### e_html_editor_selection_set_alignment ()

    void                e_html_editor_selection_set_alignment
                                                            (EHTMLEditorSelection *selection,
                                                             EHTMLEditorSelectionAlignment alignment);

Sets alignment of current paragraph to give `alignment`.

`selection` : | an EHTMLEditorSelection
`alignment` : | an EHTMLEditorSelectionAlignment value to apply

### e_html_editor_selection_get_background_color ()

    const gchar *       e_html_editor_selection_get_background_color
                                                            (EHTMLEditorSelection *selection);

Returns background color of currently selected text or letter at current cursor position.

`selection` : | an EHTMLEditorSelection
Returns : | A string with code of current background color.

### e_html_editor_selection_set_background_color ()

    void                e_html_editor_selection_set_background_color
                                                            (EHTMLEditorSelection *selection,
                                                             const gchar *color);

Changes background color of current selection or letter at current cursor position to `color`.

`selection` : | an EHTMLEditorSelection
`color` : | code of new background color to set

### e_html_editor_selection_get_font_color ()

    void                e_html_editor_selection_get_font_color
                                                            (EHTMLEditorSelection *selection,
                                                             GdkRGBA *rgba);

Sets `rgba` to contain color of current text selection or letter at current cursor position.

`selection` : | an EHTMLEditorSelection
`rgba` : | a GdkRGBA object to be set to current font color

### e_html_editor_selection_set_font_color ()

    void                e_html_editor_selection_set_font_color
                                                            (EHTMLEditorSelection *selection,
                                                             const GdkRGBA *rgba);

Sets font color of current selection or letter at current cursor position to color defined in `rgba`.

`selection` : | an EHTMLEditorSelection
`rgba` : | a GdkRGBA

### e_html_editor_selection_get_font_name ()

    const gchar *       e_html_editor_selection_get_font_name
                                                            (EHTMLEditorSelection *selection);

Returns name of font used in current selection or at letter at current cursor position.

`selection` : | an EHTMLEditorSelection
Returns : | A string with font name. [transfer-none]

### e_html_editor_selection_set_font_name ()

    void                e_html_editor_selection_set_font_name
                                                            (EHTMLEditorSelection *selection,
                                                             const gchar *font_name);

Sets font name of current selection or of letter at current cursor position to `font_name`.

`selection` : | an EHTMLEditorSelection
`font_name` : | a font name to apply

### enum EHTMLEditorSelectionFontSize

    typedef enum {
    	E_HTML_EDITOR_SELECTION_FONT_SIZE_TINY		= 1,
    	E_HTML_EDITOR_SELECTION_FONT_SIZE_SMALL		= 2,
    	E_HTML_EDITOR_SELECTION_FONT_SIZE_NORMAL = 3,
    	E_HTML_EDITOR_SELECTION_FONT_SIZE_BIG		= 4,
    	E_HTML_EDITOR_SELECTION_FONT_SIZE_BIGGER = 5,
    	E_HTML_EDITOR_SELECTION_FONT_SIZE_LARGE		= 6,
    	E_HTML_EDITOR_SELECTION_FONT_SIZE_VERY_LARGE = 7
    } EHTMLEditorSelectionFontSize;

`E_HTML_EDITOR_SELECTION_FONT_SIZE_TINY` |
`E_HTML_EDITOR_SELECTION_FONT_SIZE_SMALL` |
`E_HTML_EDITOR_SELECTION_FONT_SIZE_NORMAL` |
`E_HTML_EDITOR_SELECTION_FONT_SIZE_BIG` |
`E_HTML_EDITOR_SELECTION_FONT_SIZE_BIGGER` |
`E_HTML_EDITOR_SELECTION_FONT_SIZE_LARGE` |
`E_HTML_EDITOR_SELECTION_FONT_SIZE_VERY_LARGE` |

### e_html_editor_selection_get_font_size ()

    guint               e_html_editor_selection_get_font_size
                                                            (EHTMLEditorSelection *selection);

### e_html_editor_selection_set_font_size ()

    void                e_html_editor_selection_set_font_size
                                                            (EHTMLEditorSelection *selection,
                                                             guint font_size);

Sets font size of current selection or of letter at current cursor position to `font_size`.

`selection` : | an EHTMLEditorSelection
`font_size` : | point size to apply

### enum EHTMLEditorSelectionBlockFormat

    typedef enum {
    	E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_NONE = 0,
    	E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_H1,
    	E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_H2,
    	E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_H3,
    	E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_H4,
    	E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_H5,
    	E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_H6,
    	E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_PARAGRAPH,
    	E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_BLOCKQUOTE,
    	E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_PRE,
    	E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ADDRESS,
    	E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_UNORDERED_LIST,
    	E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST,
    	E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ROMAN,
    	E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ALPHA
    } EHTMLEditorSelectionBlockFormat;

`E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_NONE` |
`E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_H1` |
`E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_H2` |
`E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_H3` |
`E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_H4` |
`E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_H5` |
`E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_H6` |
`E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_PARAGRAPH` |
`E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_BLOCKQUOTE` |
`E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_PRE` |
`E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ADDRESS` |
`E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_UNORDERED_LIST` |
`E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST` |
`E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ROMAN` |
`E_HTML_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ALPHA` |

### e_html_editor_selection_get_block_format ()

    EHTMLEditorSelectionBlockFormat e_html_editor_selection_get_block_format
                                                            (EHTMLEditorSelection *selection);

Returns block format of current paragraph.

`selection` : | an EHTMLEditorSelection
Returns : | EHTMLEditorSelectionBlockFormat

### e_html_editor_selection_set_block_format ()

    void                e_html_editor_selection_set_block_format
                                                            (EHTMLEditorSelection *selection,
                                                             EHTMLEditorSelectionBlockFormat format);

Changes block format of current paragraph to `format`.

`selection` : | an EHTMLEditorSelection
`format` : | an EHTMLEditorSelectionBlockFormat value

### e_html_editor_selection_is_citation ()

    gboolean            e_html_editor_selection_is_citation (EHTMLEditorSelection *selection);

Returns whether current paragraph is a citation.

`selection` : | an EHTMLEditorSelection
Returns : | `TRUE` when current paragraph is a citation, `FALSE` otherwise.

### e_html_editor_selection_is_indented ()

    gboolean            e_html_editor_selection_is_indented (EHTMLEditorSelection *selection);

Returns whether current paragraph is indented. This does not include citations. To check, whether paragraph is a citation, use `e_html_editor_selection_is_citation()`.

`selection` : | an EHTMLEditorSelection
Returns : | `TRUE` when current paragraph is indented, `FALSE` otherwise.

### e_html_editor_selection_indent ()

    void                e_html_editor_selection_indent      (EHTMLEditorSelection *selection);

Indents current paragraph by one level.

`selection` : | an EHTMLEditorSelection

### e_html_editor_selection_unindent ()

    void                e_html_editor_selection_unindent    (EHTMLEditorSelection *selection);

Unindents current paragraph by one level.

`selection` : | an EHTMLEditorSelection

### e_html_editor_selection_is_bold ()

    gboolean            e_html_editor_selection_is_bold     (EHTMLEditorSelection *selection);

`selection` : | an EHTMLEditorSelection
Returns : | `TRUE` when selection is bold, `FALSE` otherwise.

### e_html_editor_selection_set_bold ()

    void                e_html_editor_selection_set_bold    (EHTMLEditorSelection *selection,
                                                             gboolean bold);

Toggles bold formatting of current selection or letter at current cursor position, depending on whether `bold` is `TRUE` or `FALSE`.

`selection` : | an EHTMLEditorSelection
`bold` : | `TRUE` to enable bold, `FALSE` to disable

### e_html_editor_selection_is_italic ()

    gboolean            e_html_editor_selection_is_italic   (EHTMLEditorSelection *selection);

`selection` : | an EHTMLEditorSelection
Returns : | `TRUE` when selection is italic, `FALSE` otherwise.

### e_html_editor_selection_set_italic ()

    void                e_html_editor_selection_set_italic  (EHTMLEditorSelection *selection,
                                                             gboolean italic);

Toggles italic formatting of current selection or letter at current cursor position, depending on whether `italic` is `TRUE` or `FALSE`.

`selection` : | an EHTMLEditorSelection
`italic` : | `TRUE` to enable italic, `FALSE` to disable

### e_html_editor_selection_is_monospaced ()

    gboolean            e_html_editor_selection_is_monospaced
                                                            (EHTMLEditorSelection *selection);

`selection` : | an EHTMLEditorSelection
Returns : | `TRUE` when selection is monospaced, `FALSE` otherwise.

### e_html_editor_selection_set_monospaced ()

    void                e_html_editor_selection_set_monospaced
                                                            (EHTMLEditorSelection *selection,
                                                             gboolean monospaced);

Toggles monospaced formatting of current selection or letter at current cursor position, depending on whether `monospaced` is `TRUE` or `FALSE`.

`selection` : | an EHTMLEditorSelection
`monospaced` : | `TRUE` to enable monospaced, `FALSE` to disable

### e_html_editor_selection_is_superscript ()

    gboolean            e_html_editor_selection_is_superscript
                                                            (EHTMLEditorSelection *selection);

`selection` : | an EHTMLEditorSelection
Returns : | `TRUE` when selection is in superscript, `FALSE` otherwise.

### e_html_editor_selection_set_superscript ()

    void                e_html_editor_selection_set_superscript
                                                            (EHTMLEditorSelection *selection,
                                                             gboolean superscript);

Toggles superscript of current selection or letter at current cursor position, depending on whether `superscript` is `TRUE` or `FALSE`.

`selection` : | an EHTMLEditorSelection
`superscript` : | `TRUE` to enable superscript, `FALSE` to disable

### e_html_editor_selection_is_subscript ()

    gboolean            e_html_editor_selection_is_subscript
                                                            (EHTMLEditorSelection *selection);

`selection` : | an EHTMLEditorSelection
Returns : | `TRUE` when selection is in subscript, `FALSE` otherwise.

### e_html_editor_selection_set_subscript ()

    void                e_html_editor_selection_set_subscript
                                                            (EHTMLEditorSelection *selection,
                                                             gboolean subscript);

Toggles subscript of current selection or letter at current cursor position, depending on whether `subscript` is `TRUE` or `FALSE`.

`selection` : | an EHTMLEditorSelection
`subscript` : | `TRUE` to enable subscript, `FALSE` to disable

### e_html_editor_selection_is_underline ()

    gboolean            e_html_editor_selection_is_underline
                                                            (EHTMLEditorSelection *selection);

`selection` : | an EHTMLEditorSelection
Returns : | `TRUE` when selection is underlined, `FALSE` otherwise.

### e_html_editor_selection_set_underline ()

    void                e_html_editor_selection_set_underline
                                                            (EHTMLEditorSelection *selection,
                                                             gboolean underline);

Toggles underline formatting of current selection or letter at current cursor position, depending on whether `underline` is `TRUE` or `FALSE`.

`selection` : | an EHTMLEditorSelection
`underline` : | `TRUE` to enable underline, `FALSE` to disable

### e_html_editor_selection_unlink ()

    void                e_html_editor_selection_unlink      (EHTMLEditorSelection *selection);

Removes any links (<A> elements) from current selection or at current cursor position.

`selection` : | an EHTMLEditorSelection

### e_html_editor_selection_create_link ()

    void                e_html_editor_selection_create_link (EHTMLEditorSelection *selection,
                                                             const gchar *uri);

Converts current selection into a link pointing to `url`.

`selection` : | an EHTMLEditorSelection
`uri` : | destination of the new link

### e_html_editor_selection_get_string ()

    const gchar *       e_html_editor_selection_get_string  (EHTMLEditorSelection *selection);

Returns currently selected string.

`selection` : | an EHTMLEditorSelection
Returns : | A pointer to content of current selection. The string is owned by EHTMLEditorSelection and should not be free'd.

### e_html_editor_selection_replace ()

    void                e_html_editor_selection_replace     (EHTMLEditorSelection *selection,
                                                             const gchar *new_string);

Replaces currently selected text with `new_string`.

`selection` : | an EHTMLEditorSelection
`new_string` : | a string to replace current selection with

### e_html_editor_selection_insert_html ()

    void                e_html_editor_selection_insert_html (EHTMLEditorSelection *selection,
                                                             const gchar *html_text);

Insert `html_text` into document at current cursor position. When a text range is selected, it will be replaced by `html_text`.

`selection` : | an EHTMLEditorSelection
`html_text` : | an HTML code to insert

### e_html_editor_selection_insert_image ()

    void                e_html_editor_selection_insert_image
                                                            (EHTMLEditorSelection *selection,
                                                             const gchar *image_uri);

Inserts image at current cursor position using `image_uri` as source. When a text range is selected, it will be replaced by the image.

`selection` : | an EHTMLEditorSelection
`image_uri` : | an URI of the source image

### e_html_editor_selection_insert_text ()

    void                e_html_editor_selection_insert_text (EHTMLEditorSelection *selection,
                                                             const gchar *plain_text);

Inserts `plain_text` at current cursor position. When a text range is selected, it will be replaced by `plain_text`.

`selection` : | an EHTMLEditorSelection
`plain_text` : | text to insert

### e_html_editor_selection_wrap_lines ()

    void                e_html_editor_selection_wrap_lines  (EHTMLEditorSelection *selection);

Wraps all lines in current selection to be 71 characters long.

`selection` : | an EHTMLEditorSelection

### e_html_editor_selection_save ()

    void                e_html_editor_selection_save        (EHTMLEditorSelection *selection);

Saves current cursor position or current selection range. The selection can be later restored by calling `e_html_editor_selection_restore()`.

Note that calling `e_html_editor_selection_save()` overwrites previously saved position.

Note that this method inserts special markings into the HTML code that are used to later restore the selection. It can happen that by deleting some segments of the document some of the markings are deleted too. In that case restoring the selection by `e_html_editor_selection_restore()` can fail. Also by moving text segments (Cut & Paste) can result in moving the markings elsewhere, thus `e_html_editor_selection_restore()` will restore the selection incorrectly.

It is recommended to use this method only when you are not planning to make bigger changes to content or structure of the document (formatting changes are usually OK).

`selection` : | an EHTMLEditorSelection

### e_html_editor_selection_restore ()

    void                e_html_editor_selection_restore     (EHTMLEditorSelection *selection);

Restores cursor position or selection range that was saved by `e_html_editor_selection_save()`.

Note that calling this function without calling `e_html_editor_selection_save()` before is a programming error and the behavior is undefined.

`selection` : | an EHTMLEditorSelection

### enum EHTMLEditorSelectionGranularity

    typedef enum {
    	E_HTML_EDITOR_SELECTION_GRANULARITY_CHARACTER,
    	E_HTML_EDITOR_SELECTION_GRANULARITY_WORD
    } EHTMLEditorSelectionGranularity;

`E_HTML_EDITOR_SELECTION_GRANULARITY_CHARACTER` |
`E_HTML_EDITOR_SELECTION_GRANULARITY_WORD` |

### e_html_editor_selection_move ()

    void                e_html_editor_selection_move        (EHTMLEditorSelection *selection,
                                                             gboolean forward,
                                                             EHTMLEditorSelectionGranularity granularity);

Moves current selection in given direction by given granularity

`selection` : | an EHTMLEditorSelection
`forward` : | whether to move the selection forward or backward
`granularity` : | granularity of the movement

### e_html_editor_selection_extend ()

    void                e_html_editor_selection_extend      (EHTMLEditorSelection *selection,
                                                             gboolean forward,
                                                             EHTMLEditorSelectionGranularity granularity);

Extends current selection in given direction by given granularity.

`selection` : | an EHTMLEditorSelection
`forward` : | whether to extend selection forward or backward
`granularity` : | granularity of the extension