gtksourceviewmm: Gsv::SearchContext Class Reference

gtksourceviewmm 3.91.1

Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Symbols | List of all members
Gsv::SearchContext Class Reference

Compose a Buffer for printing. More...

`#include <gtksourceviewmm/searchcontext.h>`

Inherits Glib::Object.

## Public Member Functions
| SearchContext (SearchContext&& src) noexcept
SearchContext& | operator= (SearchContext&& src) noexcept
| ~SearchContext () noexcept override
GtkSourceSearchContext* | gobj ()
| Provides access to the underlying C GObject.
const GtkSourceSearchContext* | gobj () const
| Provides access to the underlying C GObject.
GtkSourceSearchContext* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Glib::RefPtr< Buffer > | get_buffer ()
Glib::RefPtr< const Buffer > | get_buffer () const
Glib::RefPtr< SearchSettings > | get_settings ()
Glib::RefPtr< const SearchSettings > | get_settings () const
bool | get_highlight () const
void | set_highlight (bool highlight=true)
| Enables or disables the search occurrences highlighting.
Glib::RefPtr< Style > | get_match_style ()
Glib::RefPtr< const Style > | get_match_style () const
void | set_match_style (const Glib::RefPtr< Style >& match_style)
| Set the style to apply on search matches.
int | get_occurrences_count () const
| Gets the total number of search occurrences.
int | get_occurrence_position (const TextBuffer::iterator& match_start, const TextBuffer::iterator& match_end) const
| Gets the position of a search occurrence.
bool | forward (const TextBuffer::iterator& iter, TextBuffer::iterator& match_start, TextBuffer::iterator& match_end, bool& has_wrapped_around)
| Synchronous forward search.
void | forward_async (const TextBuffer::iterator& iter, const Glib::RefPtr< Gio::Cancellable >& cancellable, GAsyncReadyCallback callback, gpointer user_data)
| Asynchronous forward search.
bool | backward (const TextBuffer::iterator& iter, TextBuffer::iterator& match_start, TextBuffer::iterator& match_end, bool& has_wrapped_around)
| Synchronous backward search.
void | backward_async (const TextBuffer::iterator& iter, const Glib::RefPtr< Gio::Cancellable >& cancellable, GAsyncReadyCallback callback, gpointer user_data)
| Asynchronous backward search.
unsigned int | replace_all (const Glib::ustring&replace, int replace_length)
| Replaces all search matches by another text.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Buffer > > | property_buffer () const
| The associated GtkSourceBuffer.
Glib::PropertyProxy< bool > | property_highlight ()
| Highlight search occurrences.
Glib::PropertyProxy_ReadOnly< bool > | property_highlight () const
| Highlight search occurrences.
Glib::PropertyProxy< Glib::RefPtr< Style > > | property_match_style ()
| The text style for matches.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Style > > | property_match_style () const
| The text style for matches.
Glib::PropertyProxy_ReadOnly< int > | property_occurrences_count () const
| Total number of search occurrences.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< SearchSettings > > | property_settings () const
| The associated GtkSourceSearchSettings.

## Static Public Member Functions
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system.
static Glib::RefPtr< SearchContext > | create (const Glib::RefPtr< Buffer >& buffer, const Glib::RefPtr< SearchSettings >& settings)

## Protected Member Functions
| SearchContext (const Glib::RefPtr< Buffer >& buffer, const Glib::RefPtr< SearchSettings >& settings)
| Creates a new search context, associated with buffer , and customized with settings .

## Related Symbols
(Note that these are not member symbols.)
Glib::RefPtr< Gsv::SearchContext > | wrap (GtkSourceSearchContext* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

Compose a Buffer for printing.

Since gtksourceviewmm 3.10

## Constructor & Destructor Documentation

## ◆ SearchContext() [1/2]

Gsv::SearchContext::SearchContext | ( | SearchContext&& | src | ) |
| noexcept

## ◆ ~SearchContext()

Gsv::SearchContext::~SearchContext | ( |  | ) |
| overridenoexcept

## ◆ SearchContext() [2/2]

Gsv::SearchContext::SearchContext | ( | const Glib::RefPtr< Buffer >& | buffer,
|  | const Glib::RefPtr< SearchSettings >& | settings )
| explicitprotected

Creates a new search context, associated with buffer , and customized with settings .

If settings is NULL, a new GtkSourceSearchSettings object will be created, that you can retrieve with gtk_source_search_context_get_settings().

Parameters

  buffer | a GtkSourceBuffer.
  settings | a GtkSourceSearchSettings, or NULL.

Since gtksourceviewmm 3.10

## Member Function Documentation

## ◆ backward()

bool Gsv::SearchContext::backward | ( | const TextBuffer::iterator & | iter,
|  | TextBuffer::iterator & | match_start,
|  | TextBuffer::iterator & | match_end,
|  | bool & | has_wrapped_around )

Synchronous backward search.

It is recommended to use the asynchronous functions instead, to not block the user interface. However, if you are sure that the buffer is small, this function is more convenient to use.

Parameters

  iter | start of search.
  match_start | return location for start of match, or NULL.
  match_end | return location for end of match, or NULL.

Returns
  whether a match was found.

Since gtksourceviewmm 3.10

## ◆ backward_async()

void Gsv::SearchContext::backward_async | ( | const TextBuffer::iterator & | iter,
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable,
|  | GAsyncReadyCallback | callback,
|  | gpointer | user_data )

Asynchronous backward search.

See the GAsyncResult documentation to know how to use this function. If the operation is cancelled, the callback will only be called if cancellable was not NULL. gtk_source_search_context_backward_async() takes ownership of cancellable , so you can unref it after calling this function.

Parameters

  iter | start of search.
  cancellable | a GCancellable, or NULL.
  callback | a GAsyncReadyCallback to call when the operation is finished.
  user_data | the data to pass to the callback function.

Since gtksourceviewmm 3.10

## ◆ create()

static Glib::RefPtr< SearchContext > Gsv::SearchContext::create | ( | const Glib::RefPtr< Buffer >& | buffer,
|  | const Glib::RefPtr< SearchSettings >& | settings )
| static

## ◆ forward()

bool Gsv::SearchContext::forward | ( | const TextBuffer::iterator & | iter,
|  | TextBuffer::iterator & | match_start,
|  | TextBuffer::iterator & | match_end,
|  | bool & | has_wrapped_around )

Synchronous forward search.

It is recommended to use the asynchronous functions instead, to not block the user interface. However, if you are sure that the buffer is small, this function is more convenient to use.

Parameters

  iter | start of search.
  match_start | return location for start of match, or NULL.
  match_end | return location for end of match, or NULL.

Returns
  whether a match was found.

Since gtksourceviewmm 3.10

## ◆ forward_async()

void Gsv::SearchContext::forward_async | ( | const TextBuffer::iterator & | iter,
|  | const Glib::RefPtr< Gio::Cancellable > & | cancellable,
|  | GAsyncReadyCallback | callback,
|  | gpointer | user_data )

Asynchronous forward search.

See the GAsyncResult documentation to know how to use this function. If the operation is cancelled, the callback will only be called if cancellable was not NULL. gtk_source_search_context_forward_async() takes ownership of cancellable, so you can unref it after calling this function.

Parameters

  iter | start of search.
  cancellable | a GCancellable, or NULL.
  callback | a GAsyncReadyCallback to call when the operation is finished.
  user_data | the data to pass to the callback function.

Since gtksourceviewmm 3.10

## ◆ get_buffer() [1/2]

Glib::RefPtr< Buffer > Gsv::SearchContext::get_buffer | ( |  | ) |

Returns
  the associated buffer.

Since gtksourceviewmm 3.10

## ◆ get_buffer() [2/2]

Glib::RefPtr< const Buffer > Gsv::SearchContext::get_buffer | ( |  | ) | const

Since gtksourceviewmm 3.10

Returns
  The associated buffer.

## ◆ get_highlight()

bool Gsv::SearchContext::get_highlight | ( |  | ) | const

Returns
  whether to highlight the search occurrences.

Since gtksourceviewmm 3.10

## ◆ get_match_style() [1/2]

Glib::RefPtr< Style > Gsv::SearchContext::get_match_style | ( |  | ) |

Returns
  the GtkSourceStyle to apply on search matches.

Since gtksourceviewmm 3.16

## ◆ get_match_style() [2/2]

Glib::RefPtr< const Style > Gsv::SearchContext::get_match_style | ( |  | ) | const

Since gtksourceviewmm 3.16

Returns
  The Gtk::SourceStyle to apply on search matches.

## ◆ get_occurrence_position()

int Gsv::SearchContext::get_occurrence_position | ( | const TextBuffer::iterator & | match_start,
|  | const TextBuffer::iterator & | match_end ) const

Gets the position of a search occurrence.

If the buffer is not already fully scanned, the position may be unknown, and -1 is returned. If 0 is returned, it means that this part of the buffer has already been scanned, and that match_start and match_end don't delimit an occurrence.

Parameters

  match_start | the start of the occurrence.
  match_end | the end of the occurrence.

Returns
  the position of the search occurrence. The first occurrence has the position 1 (not 0). Returns 0 if match_start and match_end don't delimit an occurrence. Returns -1 if the position is not yet known.

Since gtksourceviewmm 3.10

## ◆ get_occurrences_count()

int Gsv::SearchContext::get_occurrences_count | ( |  | ) | const

Gets the total number of search occurrences.

If the buffer is not already fully scanned, the total number of occurrences is unknown, and -1 is returned.

Returns
  the total number of search occurrences, or -1 if unknown.

Since gtksourceviewmm 3.10

## ◆ get_settings() [1/2]

Glib::RefPtr< SearchSettings > Gsv::SearchContext::get_settings | ( |  | ) |

Returns
  the search settings.

Since gtksourceviewmm 3.10

## ◆ get_settings() [2/2]

Glib::RefPtr< const SearchSettings > Gsv::SearchContext::get_settings | ( |  | ) | const

Since gtksourceviewmm 3.10

Returns
  The search settings.

## ◆ get_type()

static GType Gsv::SearchContext::get_type | ( |  | ) |
| static

Get the GType for this class, for use with the underlying GObject type system.

## ◆ gobj() [1/2]

GtkSourceSearchContext * Gsv::SearchContext::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

## ◆ gobj() [2/2]

const GtkSourceSearchContext * Gsv::SearchContext::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

## ◆ gobj_copy()

GtkSourceSearchContext * Gsv::SearchContext::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

## ◆ operator=()

SearchContext& Gsv::SearchContext::operator= | ( | SearchContext&& | src | ) |
| noexcept

## ◆ property_buffer()

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Buffer > > Gsv::SearchContext::property_buffer | ( |  | ) | const

The associated GtkSourceBuffer.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_highlight() [1/2]

Glib::PropertyProxy< bool > Gsv::SearchContext::property_highlight | ( |  | ) |

Highlight search occurrences.

Default value: `true`

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_highlight() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gsv::SearchContext::property_highlight | ( |  | ) | const

Highlight search occurrences.

Default value: `true`

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_match_style() [1/2]

Glib::PropertyProxy< Glib::RefPtr< Style > > Gsv::SearchContext::property_match_style | ( |  | ) |

The text style for matches.

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_match_style() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Style > > Gsv::SearchContext::property_match_style | ( |  | ) | const

The text style for matches.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_occurrences_count()

Glib::PropertyProxy_ReadOnly< int > Gsv::SearchContext::property_occurrences_count | ( |  | ) | const

Total number of search occurrences.

Default value: 0

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_settings()

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< SearchSettings > > Gsv::SearchContext::property_settings | ( |  | ) | const

The associated GtkSourceSearchSettings.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ replace_all()

unsigned int Gsv::SearchContext::replace_all | ( | const Glib::ustring & | replace,
|  | int | replace_length )

Replaces all search matches by another text.

It is a synchronous function, so it can block the user interface. For a regular expression replacement, you can check if replace is valid by calling g_regex_check_replacement(). The replace text can contain backreferences; read the g_regex_replace() documentation for more details.

Parameters

  replace | the replacement text.
  replace_length | the length of replace in bytes, or -1.

Returns
  the number of replaced matches.

Since gtksourceviewmm 3.10

## ◆ set_highlight()

void Gsv::SearchContext::set_highlight | ( | bool | highlight = true | ) |

Enables or disables the search occurrences highlighting.

Parameters

  highlight | the setting.

Since gtksourceviewmm 3.10

## ◆ set_match_style()

void Gsv::SearchContext::set_match_style | ( | const Glib::RefPtr< Style >& | match_style | ) |

Set the style to apply on search matches.

If match_style is NULL, default theme's scheme 'match-style' will be used. To enable or disable the search highlighting, use gtk_source_search_context_set_highlight().

Parameters

  match_style | a GtkSourceStyle.

Since gtksourceviewmm 3.16

## Friends And Related Symbol Documentation

## ◆ wrap()

Glib::RefPtr< Gsv::SearchContext > wrap | ( | GtkSourceSearchContext * | object,
|  | bool | take_copy = false )
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.