Gsv::SearchContext Class Reference

Compose a Buffer for printing. More...

`#include <gtksourceviewmm/searchcontext.h>`

Inheritance diagram for Gsv::SearchContext:
[legend]

## Public Member Functions

| SearchContext (SearchContext&& src) noexcept
SearchContext& | operator= (SearchContext&& src) noexcept
| ~SearchContext () noexceptoverride
GtkSourceSearchContext* | gobj ()
| Provides access to the underlying C GObject. More...
const GtkSourceSearchContext* | gobj () const
| Provides access to the underlying C GObject. More...
GtkSourceSearchContext* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
Glib::RefPtr< Buffer > | get_buffer ()
Glib::RefPtr< const Buffer > | get_buffer () const
Glib::RefPtr< SearchSettings > | get_settings ()
Glib::RefPtr< const SearchSettings > | get_settings () const
void | set_settings (const Glib::RefPtr< SearchSettings >& settings)
| Associate a GtkSourceSearchSettings with the search context. More...
bool | get_highlight () const
void | set_highlight (bool highlight=true)
| Enables or disables the search occurrences highlighting. More...
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. More...
int | get_occurrences_count () const
| Gets the total number of search occurrences. More...
int | get_occurrence_position (const TextBuffer::iterator& match_start, const TextBuffer::iterator& match_end) const
| Gets the position of a search occurrence. More...
bool | forward (const TextBuffer::iterator& iter, TextBuffer::iterator& match_start, TextBuffer::iterator& match_end, bool& has_wrapped_around)
| Synchronous forward search. More...
void | forward_async (const TextBuffer::iterator& iter, const Glib::RefPtr< Gio::Cancellable >& cancellable, GAsyncReadyCallback callback, gpointer user_data)
| Asynchronous forward search. More...
bool | forward_finish (const Glib::RefPtr< Gio::AsyncResult >& result, TextBuffer::iterator& match_start, TextBuffer::iterator& match_end, bool& has_wrapped_around)
| Finishes a forward search started with gtk_source_search_context_forward_async(). More...
bool | backward (const TextBuffer::iterator& iter, TextBuffer::iterator& match_start, TextBuffer::iterator& match_end, bool& has_wrapped_around)
| Synchronous backward search. More...
void | backward_async (const TextBuffer::iterator& iter, const Glib::RefPtr< Gio::Cancellable >& cancellable, GAsyncReadyCallback callback, gpointer user_data)
| Asynchronous backward search. More...
bool | backward_finish (const Glib::RefPtr< Gio::AsyncResult >& result, TextBuffer::iterator& match_start, TextBuffer::iterator& match_end, bool& has_wrapped_around)
| Finishes a backward search started with gtk_source_search_context_backward_async(). More...
bool | replace (TextBuffer::iterator& match_start, TextBuffer::iterator& match_end, const Glib::ustring& replace, int replace_length)
| Replaces a search match by another text. More...
unsigned int | replace_all (const Glib::ustring&replace, int replace_length)
| Replaces all search matches by another text. More...
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Buffer > > | property_buffer () const
| The associated GtkSourceBuffer. More...
Glib::PropertyProxy< bool > | property_highlight ()
| Highlight search occurrences. More...
Glib::PropertyProxy_ReadOnly< bool > | property_highlight () const
| Highlight search occurrences. More...
Glib::PropertyProxy< Glib::RefPtr< Style > > | property_match_style ()
| The text style for matches. More...
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Style > > | property_match_style () const
| The text style for matches. More...
Glib::PropertyProxy_ReadOnly< int > | property_occurrences_count () const
| Total number of search occurrences. More...
Glib::PropertyProxy< Glib::RefPtr< SearchSettings > > | property_settings ()
| The associated GtkSourceSearchSettings. More...
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< SearchSettings > > | property_settings () const
| The associated GtkSourceSearchSettings. More...
Public Member Functions inherited from Glib::Object
| Object (const Object &)=delete
Object & | operator= (const Object &)=delete
| Object (Object &&src) noexcept
Object & | operator= (Object &&src) noexcept
void * | get_data (const QueryQuark &key)
void | set_data (const Quark &key, void *data)
void | set_data (const Quark &key, void *data, DestroyNotify notify)
void | remove_data (const QueryQuark &quark)
void * | steal_data (const QueryQuark &quark)
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false)
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase &)=delete
ObjectBase & | operator= (const ObjectBase &)=delete
void | set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
void | get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
void | set_property (const Glib::ustring &property_name, const PropertyType &value)
void | get_property (const Glib::ustring &property_name, PropertyType &value) const
void | connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void > &slot)
void | connect_property_changed (const Glib::ustring &property_name, sigc::slot< void > &&slot)
sigc::connection | connect_property_changed_with_return (const Glib::ustring &property_name, const sigc::slot< void > &slot)
sigc::connection | connect_property_changed_with_return (const Glib::ustring &property_name, sigc::slot< void > &&slot)
void | freeze_notify ()
void | thaw_notify ()
virtual void | reference () const
virtual void | unreference () const
GObject * | gobj ()
const GObject * | gobj () const
GObject * | gobj_copy () const
Public Member Functions inherited from sigc::trackable
| trackable () noexcept
| trackable (const trackable &src) noexcept
| trackable (trackable &&src)
| ~trackable ()
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const
void | notify_callbacks ()
trackable & | operator= (const trackable &src)
trackable & | operator= (trackable &&src)
void | remove_destroy_notify_callback (void *data) const

## Static Public Member Functions

static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
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 . More...
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams &construct_params)
| Object (GObject *castitem)
| ~Object () noexceptoverride
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| ObjectBase (const char *custom_type_name)
| ObjectBase (const std::type_info &custom_type_info)
| ObjectBase (ObjectBase &&src) noexcept
ObjectBase & | operator= (ObjectBase &&src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject *castitem)
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)

## Related Functions

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

## Additional Inherited Members

Public Types inherited from Glib::Object
typedef void(*)(gpointer data | DestroyNotify)
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify

## Detailed Description

Compose a Buffer for printing.

Since gtksourceviewmm 3.10:

## Constructor & Destructor Documentation

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

noexcept

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

override noexcept

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

explicit protected

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

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:

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:

bool Gsv::SearchContext::backward_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result,
|  | TextBuffer::iterator & | match_start,
|  | TextBuffer::iterator & | match_end,
|  | bool & | has_wrapped_around
| ) |  |

Finishes a backward search started with gtk_source_search_context_backward_async().

Parameters

  result | a GAsyncResult.
  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:

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

static

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:

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:

bool Gsv::SearchContext::forward_finish | ( | const Glib::RefPtr< Gio::AsyncResult > & | result,
|  | TextBuffer::iterator & | match_start,
|  | TextBuffer::iterator & | match_end,
|  | bool & | has_wrapped_around
| ) |  |

Finishes a forward search started with gtk_source_search_context_forward_async().

Parameters

  result | a GAsyncResult.
  match_start | return location for start of match, or NULL.
  match_end | return location for end of match, or NULL.

Since gtksourceviewmm 3.10:

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

Returns
  the associated buffer.

Since gtksourceviewmm 3.10:

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

Since gtksourceviewmm 3.10:

Returns
  The associated buffer.

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

Returns
  whether to highlight the search occurrences.

Since gtksourceviewmm 3.10:

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

Returns
  the GtkSourceStyle to apply on search matches.

Since gtksourceviewmm 3.16:

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

Since gtksourceviewmm 3.16:

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

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:

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:

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

Returns
  the search settings.

Since gtksourceviewmm 3.10:

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

Since gtksourceviewmm 3.10:

Returns
  The search settings.

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

static

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

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

inline

Provides access to the underlying C GObject.

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

inline

Provides access to the underlying C GObject.

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.

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

noexcept

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.

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

Highlight search occurrences.

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.

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

Highlight search occurrences.

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

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.

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.

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

Total number of search occurrences.

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

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

The associated GtkSourceSearchSettings.

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.

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.

bool Gsv::SearchContext::replace | ( | TextBuffer::iterator & | match_start,
|  | TextBuffer::iterator & | match_end,
|  | const Glib::ustring & | replace,
|  | int | replace_length
| ) |  |

Replaces a search match by another text.

If match_start and match_end doesn't correspond to a search match, FALSE is returned.

The match_start and match_end iters are revalidated to point to the replacement text boundaries.

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

  match_start | the start of the match to replace.
  match_end | the end of the match to replace.
  replace | the replacement text.
  replace_length | the length of replace in bytes, or -1.

Returns
  whether the match has been replaced.

Since gtksourceviewmm 3.10:

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:

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

Enables or disables the search occurrences highlighting.

Parameters

  highlight | the setting.

Since gtksourceviewmm 3.10:

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:

void Gsv::SearchContext::set_settings | ( | const Glib::RefPtr< SearchSettings >& | settings | ) |

Associate a GtkSourceSearchSettings with the search context.

If settings is NULL, a new one will be created. The search context holds a reference to settings.

Parameters

  settings | the new GtkSourceSearchSettings, or NULL.

Since gtksourceviewmm 3.10:

## Friends And Related Function Documentation

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.