### Virtual Method

# Gtk IMContext get_surrounding

#### Declaration [src]

    gboolean
    get_surrounding (
      GtkIMContext* context,
      char** text,
      int* cursor_index
    )

#### Description [src]

Retrieves context around the insertion point.

Input methods typically want context in order to constrain input text based on existing text; this is important for languages such as Thai where only some sequences of characters are allowed.

This function is implemented by emitting the `GtkIMContext::retrieve-surrounding` signal on the input method; in response to this signal, a widget should provide as much context as is available, up to an entire paragraph, by calling gtk_im_context_set_surrounding().

Note that there is no obligation for a widget to respond to the `::retrieve-surrounding` signal, so input methods must be prepared to function without context.

Deprecated since: | 4.2
Use gtk_im_context_get_surrounding_with_selection() instead.

#### Parameters

`text` | `char**`
| Location to store a UTF-8 encoded string of text holding context around the insertion point. If the function returns `TRUE`, then you must free the result stored in this location with g_free().
| The argument will be set by the function.
| The called function takes ownership of the data, and is responsible for freeing it.
| The string is a NUL terminated UTF-8 string.
`cursor_index` | `int*`
| Location to store byte index of the insertion cursor within `text`.
| The argument will be set by the function.
| The called function takes ownership of the data, and is responsible for freeing it.

#### Return value

Returns: | `gboolean`
| `TRUE` if surrounding text was provided; in this case you must free the result stored in `text`.