IdeEditorSearch: Builder SDK Reference

## IdeEditorSearch IdeEditorSearch |

## Functions

IdeEditorSearch * | ide_editor_search_new ()
gboolean | ide_editor_search_get_active ()
void | ide_editor_search_set_case_sensitive ()
gboolean | ide_editor_search_get_case_sensitive ()
IdeEditorSearchSelect | ide_editor_search_get_extend_selection ()
void | ide_editor_search_set_extend_selection ()
gboolean | ide_editor_search_get_reverse ()
void | ide_editor_search_set_reverse ()
void | ide_editor_search_set_search_text ()
const gchar * | ide_editor_search_get_search_text ()
gboolean | ide_editor_search_get_search_text_invalid ()
void | ide_editor_search_set_visible ()
gboolean | ide_editor_search_get_visible ()
void | ide_editor_search_set_regex_enabled ()
gboolean | ide_editor_search_get_regex_enabled ()
void | ide_editor_search_set_replacement_text ()
const gchar * | ide_editor_search_get_replacement_text ()
gboolean | ide_editor_search_get_replacement_text_invalid ()
void | ide_editor_search_set_at_word_boundaries ()
gboolean | ide_editor_search_get_at_word_boundaries ()
guint | ide_editor_search_get_repeat ()
void | ide_editor_search_set_repeat ()
guint | ide_editor_search_get_match_count ()
guint | ide_editor_search_get_match_position ()
void | ide_editor_search_move ()
void | ide_editor_search_replace ()
void | ide_editor_search_replace_all ()
void | ide_editor_search_begin_interactive ()
void | ide_editor_search_end_interactive ()

## Properties

gboolean | active | Read
gboolean | at-word-boundaries | Read / Write
gboolean | case-sensitive | Read / Write
IdeEditorSearchSelect | extend-selection | Read / Write
guint | match-count | Read
guint | match-position | Read
gboolean | regex-enabled | Read / Write
guint | repeat | Read / Write
gchar * | replacement-text | Read / Write
gboolean | reverse | Read / Write
gchar * | search-text | Read / Write
GtkSourceView * | view | Read / Write / Construct Only
gchar * | visible | Read / Write

## Types and Values

#define | IDE_TYPE_EDITOR_SEARCH
| IdeEditorSearch

## Object Hierarchy

        GEnum
        ├── IdeEditorSearchDirection
        ╰── IdeEditorSearchSelect
        GObject
        ╰── IdeEditorSearch

## Implemented Interfaces

IdeEditorSearch implements GActionGroup.

## Description

The IdeEditorSearch object manages the search features associated with a single IdeEditorView (and it's view of the underlying text buffer).

This object is meant to help reduce the number of layers performing search on the underlying buffer as well as track highlighting based on focus, performance considerations, and directional movements in a unified manner.

Additionally, it provides an addin layer to highlight similar words when then buffer selection changes.

## Functions

### ide_editor_search_new ()

    IdeEditorSearch *
    ide_editor_search_new (GtkSourceView *view);

Creates a new IdeEditorSearch instance for the GtkSourceView. You should only create one of these per IdeEditorView.

#### Returns

A new IdeEditorSearch instance.

[transfer full]

Since: 3.32

### ide_editor_search_get_active ()

    gboolean
    ide_editor_search_get_active (IdeEditorSearch *self);

Gets the "active" property.

The IdeEditorSearch is considered active if there is a search context loaded and the search text is not empty.

#### Parameters

self | a IdeEditorSearch |

#### Returns

`TRUE` if a search is active

Since: 3.32

### ide_editor_search_set_case_sensitive ()

    void
    ide_editor_search_set_case_sensitive (IdeEditorSearch *self,
                                          gboolean case_sensitive);

See also: “case-sensitive”

#### Parameters

self | An IdeEditorSearch |
case_sensitive | `TRUE` if the search should be case-sensitive |

Since: 3.32

### ide_editor_search_get_case_sensitive ()

    gboolean
    ide_editor_search_get_case_sensitive (IdeEditorSearch *self);

Gets if the search should be case sensitive.

#### Parameters

self | An IdeEditorSearch |

#### Returns

`TRUE` if the search is case-sensitive.

See also: “case-sensitive”

Since: 3.32

### ide_editor_search_get_extend_selection ()

    IdeEditorSearchSelect
    ide_editor_search_get_extend_selection
                                   (IdeEditorSearch *self);

Gets the "extend-selection" property.

This property determines if the selection should be extended and how when moving between search results.

#### Parameters

self | a IdeEditorSearch |

#### Returns

An `IdeEditorSearchSelect`

Since: 3.32

### ide_editor_search_set_extend_selection ()

    void
    ide_editor_search_set_extend_selection
                                   (IdeEditorSearch *self,
                                    IdeEditorSearchSelect extend_selection);

### ide_editor_search_get_reverse ()

    gboolean
    ide_editor_search_get_reverse (IdeEditorSearch *self);

Checks if search movements should be reversed for relative movements such as `IDE_EDITOR_SEARCH_NEXT` and `IDE_EDITOR_SEARCH_PREVIOUS`.

This might be used when performing searches such as vim's # or * search operators. After that movements like n or N need to swap directions.

#### Parameters

self | a IdeEditorSearch |

#### Returns

`TRUE` if relative movements are reversed directions.

Since: 3.32

### ide_editor_search_set_reverse ()

    void
    ide_editor_search_set_reverse (IdeEditorSearch *self,
                                   gboolean reverse);

Sets the "reverse" property.

This is used to alter the direction for relative search movements. `IDE_EDITOR_SEARCH_NEXT` and `IDE_EDITOR_SEARCH_PREVIOUS` will swap directions so that `IDE_EDITOR_SEARCH_PREVIOUS` will search forwards in the buffer and `IDE_EDITOR_SEARCH_NEXT` wills earch backwards.

#### Parameters

self | a IdeEditorSearch |
reverse | if relative search directions should reverse |

Since: 3.32

### ide_editor_search_set_search_text ()

    void
    ide_editor_search_set_search_text (IdeEditorSearch *self,
                                       const gchar *search_text);

See also: “search-text”

#### Parameters

self | An IdeEditorSearch |
search_text | The search text or `NULL`. | [nullable]

Since: 3.32

### ide_editor_search_get_search_text ()

    const gchar *
    ide_editor_search_get_search_text (IdeEditorSearch *self);

Gets the search-text currently being searched.

#### Parameters

self | An IdeEditorSearch |

#### Returns

The search text or `NULL`.

[nullable]

Since: 3.32

### ide_editor_search_get_search_text_invalid ()

    gboolean
    ide_editor_search_get_search_text_invalid
                                   (IdeEditorSearch *self,
                                    guint *invalid_begin,
                                    guint *invalid_end,
                                    GError **error);

Checks to see if the search text contains invalid contents, such as an invalid regex.

#### Parameters

self | An IdeEditorSearch |
invalid_begin | a begin location for the invalid range. | [nullable][out]
invalid_end | an end location for the invalid range. | [nullable][out]

#### Returns

`TRUE` if the search text contains invalid content. If `TRUE`, then `invalid_begin` and `invalid_end` is set.

Since: 3.32

### ide_editor_search_set_visible ()

    void
    ide_editor_search_set_visible (IdeEditorSearch *self,
                                   gboolean visible);

Sets the visibility of the search results. You might want to disable the visibility of search results when the user has requested them to be dismissed.

This will allow the user to still make search movements based on the previous search request, and re-enable visibility upon doing so.

#### Parameters

self | An IdeEditorSearch |
visible | if the search results should be visible |

Since: 3.32

### ide_editor_search_get_visible ()

    gboolean
    ide_editor_search_get_visible (IdeEditorSearch *self);

Gets the “visible” property. This is true if the current search text should be highlighted in the editor.

#### Parameters

self | An IdeEditorSearch |

#### Returns

`TRUE` if the current search should be highlighted.

Since: 3.32

### ide_editor_search_set_regex_enabled ()

    void
    ide_editor_search_set_regex_enabled (IdeEditorSearch *self,
                                         gboolean regex_enabled);

See also: “regex-enabled”

#### Parameters

self | An IdeEditorSearch |
regex_enabled | If regex search should be used |

Since: 3.32

### ide_editor_search_get_regex_enabled ()

    gboolean
    ide_editor_search_get_regex_enabled (IdeEditorSearch *self);

Gets the “regex-enabled” property. This is true if the search text can contain regular expressions supported by GRegex.

#### Parameters

self | An IdeEditorSearch |

#### Returns

`TRUE` if search text can use regex

Since: 3.32

### ide_editor_search_set_replacement_text ()

    void
    ide_editor_search_set_replacement_text
                                   (IdeEditorSearch *self,
                                    const gchar *replacement_text);

This sets the text to use when performing search and replace. See `ide_editor_search_replace()` or `ide_editor_search_replace_all()` to perform one or more replacements.

If “regex-enabled” is set, then you may reference regex groups from the regex in “search-text”.

#### Parameters

self | An IdeEditorSearch |
replacement_text | The text to use in replacement operations. | [nullable]

Since: 3.32

### ide_editor_search_get_replacement_text ()

    const gchar *
    ide_editor_search_get_replacement_text
                                   (IdeEditorSearch *self);

Gets the “replacement-text” property. This is the text that will be used when calling `ide_editor_search_replace()` or `ide_editor_search_replace_all()`.

#### Parameters

self | An IdeEditorSearch |

#### Returns

the replacement text, or `NULL`.

[nullable]

Since: 3.32

### ide_editor_search_get_replacement_text_invalid ()

    gboolean
    ide_editor_search_get_replacement_text_invalid
                                   (IdeEditorSearch *self,
                                    guint *invalid_begin,
                                    guint *invalid_end);

### ide_editor_search_set_at_word_boundaries ()

    void
    ide_editor_search_set_at_word_boundaries
                                   (IdeEditorSearch *self,
                                    gboolean at_word_boundaries);

See also: `gtk_source_search_settings_set_word_boundaries()`

#### Parameters

self | An IdeEditorSearch |
at_word_boundaries | `TRUE` if search should match only on word boundaries |

Since: 3.32

### ide_editor_search_get_at_word_boundaries ()

    gboolean
    ide_editor_search_get_at_word_boundaries
                                   (IdeEditorSearch *self);

Gets the “at-word-boundaries” property.

#### Parameters

self | An IdeEditorSearch |

#### Returns

`TRUE` if the search should only match word boundaries.

See also: “at-word-boundaries”

Since: 3.32

### ide_editor_search_get_repeat ()

    guint
    ide_editor_search_get_repeat (IdeEditorSearch *self);

Gets the “repeat” property containing the number of times to perform a move. A value of 1 performs a single move. A value of 2 performs a second move after the first.

A value of zero indicates the property is unset and a single move will be performed.

#### Parameters

self | a IdeEditorSearch |

#### Returns

A number containing the number of moves.

Since: 3.32

### ide_editor_search_set_repeat ()

    void
    ide_editor_search_set_repeat (IdeEditorSearch *self,
                                  guint repeat);

Sets the repeat count. A `repeat` value of 0 indicates that the value is unset. When unset, the default value of 1 is used.

See also: `ide_editor_search_get_repeat()`

#### Parameters

self | a IdeEditorSearch |
repeat | The new value for the repeat count |

Since: 3.32

### ide_editor_search_get_match_count ()

    guint
    ide_editor_search_get_match_count (IdeEditorSearch *self);

Gets the number of matches currently found in the editor. This will update as new matches are found while scanning the buffer.

#### Parameters

self | An IdeEditorSearch |

Since: 3.32

### ide_editor_search_get_match_position ()

    guint
    ide_editor_search_get_match_position (IdeEditorSearch *self);

Gets the match position of the cursor within the buffer. If the cursor is within a match, this will be a 1-based index will update as new matches are found while scanning the buffer.

#### Parameters

self | An IdeEditorSearch |

Since: 3.32

### ide_editor_search_move ()

    void
    ide_editor_search_move (IdeEditorSearch *self,
                            IdeEditorSearchDirection direction);

This moves the insertion cursor in the buffer to the next match based upon `direction` .

If direction is `IDE_EDITOR_SEARCH_BACKWARD`, the search will stop at the beginning of the buffer.

If direction is `IDE_EDITOR_SEARCH_FORWARD`, the search will stop at the end of the buffer.

If direction is `IDE_EDITOR_SEARCH_NEXT`, it will automatically wrap around to the beginning of the buffer after reaching the end of the buffer.

If direction is `IDE_EDITOR_SEARCH_PREVIOUS`, the search will automatically wrap around to the end of the buffer once the beginning of the buffer has been reached.

#### Parameters

self | An IdeEditorSearch |
direction | An IdeEditorSearchDirection |

Since: 3.32

### ide_editor_search_replace ()

    void
    ide_editor_search_replace (IdeEditorSearch *self);

Replaces the next occurrance of a search result with the value of “replacement-text”.

#### Parameters

self | An IdeEditorSearch |

Since: 3.32

### ide_editor_search_replace_all ()

    void
    ide_editor_search_replace_all (IdeEditorSearch *self);

Replaces all the occurrances of “search-text” with the value of “replacement-text”.

#### Parameters

self | An IdeEditorSearch |

Since: 3.32

### ide_editor_search_begin_interactive ()

    void
    ide_editor_search_begin_interactive (IdeEditorSearch *self);

This function is used to track when the user begin doing an interactive search, which is one where they are typing the search query.

Tracking this behavior is useful because it allows the editor to "rubberband", which is to say it can scan forward to the first search result automatically, and then snap back to the previous location if the search is aborted.

#### Parameters

self | An IdeEditorSearch |

Since: 3.32

### ide_editor_search_end_interactive ()

    void
    ide_editor_search_end_interactive (IdeEditorSearch *self);

This function completes an interactive search previously performed with `ide_editor_search_begin_interactive()`.

This should be called when the user has left the search controls, as it might allow the editor to restore positioning back to the previous editor location from before the interactive search began.

#### Parameters

self | An IdeEditorSearch |

Since: 3.32

## Types and Values

### IDE_TYPE_EDITOR_SEARCH

    #define IDE_TYPE_EDITOR_SEARCH           (ide_editor_search_get_type())

### IdeEditorSearch

    typedef struct _IdeEditorSearch IdeEditorSearch;

## Property Details

### The `“active”` property

      “active”                   gboolean

The "active" property is `TRUE` when their is an active search in progress.

Flags: Read

Default value: FALSE

Since: 3.32

### The `“at-word-boundaries”` property

      “at-word-boundaries”       gboolean

The "at-word-boundaries" property specifies if the search-text must only be matched starting from the beginning of a word.

Flags: Read / Write

Default value: FALSE

Since: 3.32

### The `“case-sensitive”` property

      “case-sensitive”           gboolean

The "case-sensitive" property specifies if the search text should be case sensitive.

Flags: Read / Write

Default value: FALSE

Since: 3.32

### The `“extend-selection”` property

      “extend-selection”         IdeEditorSearchSelect

The "extend-selection" property specifies that the selection within the editor should be extended as the user navigates between search results.

Flags: Read / Write

Default value: IDE_EDITOR_SEARCH_SELECT_NONE

Since: 3.32

### The `“match-count”` property

      “match-count”              guint

The "match-count" property contains the number of matches that have been discovered. This is reset to zeor when the IdeEditorSearch determines it can destroy it's GtkSourceSearchContext.

Generally, you should only rely on it's accuracy after calling `ide_editor_search_begin_interactive()` and before calling `ide_editor_search_end_interactive()`.

Flags: Read

Default value: 0

Since: 3.32

### The `“match-position”` property

      “match-position”           guint

The "match-position" property contains the position within the discovered search results for which the insertion cursor is placed.

This value starts from 1, and 0 indicates that the insertion cursor is not placed within the a search result.

Flags: Read

Default value: 0

Since: 3.32

### The `“regex-enabled”` property

      “regex-enabled”            gboolean

The "regex-enabled" property determines if GRegex should be used to scan for the “search-text”. Doing so allows the user to search using common regex values such as "foo.*bar". It also allows for capture groups to be used in replacement text.

Flags: Read / Write

Default value: FALSE

Since: 3.32

### The `“repeat”` property

      “repeat”                   guint

The number of times to repeat a move operation when calling `ide_editor_search_move()`. This allows for stateful moves when as might be necessary when activating keybindings.

This property will be cleared after an attempt to move.

Flags: Read / Write

Default value: 0

Since: 3.32

### The `“replacement-text”` property

      “replacement-text”         gchar *

The "replacement-text" property determines the text to be used when performing search and replace with `ide_editor_search_replace()` or `ide_editor_search_replace_all()`.

If “regex-enabled” is `TRUE`, then the user may use references to capture groups specified in “search-text”.

Flags: Read / Write

Default value: NULL

Since: 3.32

### The `“reverse”` property

      “reverse”                  gboolean

The "reverse" property determines if relative directions should be switched, so next is backward, and previous is forward.

Flags: Read / Write

Default value: FALSE

Since: 3.32

### The `“search-text”` property

      “search-text”              gchar *

The "search-text" property contains the text to search within the buffer.

If the “regex-enabled” property is set to `TRUE`, then the user may use regular expressions supported by GRegex to scan the buffer. They may also specify capture groups to use in search and replace.

Flags: Read / Write

Default value: NULL

Since: 3.32

### The `“view”` property

      “view”                     GtkSourceView *

The "view" property is the underlying GtkSourceView that is being searched. This must be set when creating the IdeEditorSearch and may not be changed after construction.

Flags: Read / Write / Construct Only

Since: 3.32

### The `“visible”` property

      “visible”                  gchar *

The "visible" property is used to specify if the search results should be highlighted in the buffer. Generally, you'll want this off while the interactive search is hidden as it allows the IdeEditorSearch to perform various optimizations.

However, some cases, such as Vim search movements, may want to show the search highlights, but are not within an interactive search.

Flags: Read / Write

Default value: NULL

Since: 3.32