Functions

check_version(major: int, minor: int, micro: int) bool

Like GTK_SOURCE_CHECK_VERSION, but the check for gtk_source_check_version is at runtime instead of compile time. This is useful for compiling against older versions of GtkSourceView, but using features from newer versions.

Parameters:
  • major – the major version to check

  • minor – the minor version to check

  • micro – the micro version to check

Returns:

True if the version of the GtkSourceView currently loaded is the same as or newer than the passed-in version.

encoding_get_all() list[Encoding]
encoding_get_current() Encoding
encoding_get_default_candidates() list[Encoding]
encoding_get_from_charset(charset: str) Encoding | None
Parameters:

charset

encoding_get_utf8() Encoding
file_loader_error_quark() int
file_saver_error_quark() int
finalize() None

Free the resources allocated by GtkSourceView. For example it unrefs the singleton objects.

It is not mandatory to call this function, it’s just to be friendlier to memory debugging tools. This function is meant to be called at the end of main(). It can be called several times.

get_major_version() int

Returns the major version number of the GtkSourceView library. (e.g. in GtkSourceView version 3.20.0 this is 3.)

This function is in the library, so it represents the GtkSourceView library your code is running against. Contrast with the GTK_SOURCE_MAJOR_VERSION macro, which represents the major version of the GtkSourceView headers you have included when compiling your code.

Returns:

the major version number of the GtkSourceView library

get_micro_version() int

Returns the micro version number of the GtkSourceView library. (e.g. in GtkSourceView version 3.20.0 this is 0.)

This function is in the library, so it represents the GtkSourceView library your code is running against. Contrast with the GTK_SOURCE_MICRO_VERSION macro, which represents the micro version of the GtkSourceView headers you have included when compiling your code.

Returns:

the micro version number of the GtkSourceView library

get_minor_version() int

Returns the minor version number of the GtkSourceView library. (e.g. in GtkSourceView version 3.20.0 this is 20.)

This function is in the library, so it represents the GtkSourceView library your code is running against. Contrast with the GTK_SOURCE_MINOR_VERSION macro, which represents the minor version of the GtkSourceView headers you have included when compiling your code.

Returns:

the minor version number of the GtkSourceView library

init() None

Initializes the GtkSourceView library (e.g. for the internationalization).

This function can be called several times, but is meant to be called at the beginning of main(), before any other GtkSourceView function call.

scheduler_add(callback: Callable[[...], bool], *user_data: Any) int

Simplified version of scheduler_add_full.

Added in version 5.2.

Parameters:
  • callback – the callback to execute

  • user_data – user data for callback

scheduler_add_full(callback: Callable[[...], bool], *user_data: Any) int

Adds a new callback that will be executed as time permits on the main thread.

This is useful when you need to do a lot of background work but want to do it incrementally.

callback will be provided a deadline that it should complete it’s work by (or near) and can be checked using get_monotonic_time for comparison.

Use scheduler_remove to remove the handler.

Added in version 5.2.

Parameters:
  • callback – the callback to execute

  • user_data – user data for callback

scheduler_remove(handler_id: int) None

Removes a scheduler callback previously registered with scheduler_add or scheduler_add_full.

Added in version 5.2.

Parameters:

handler_id – the handler id

utils_escape_search_text(text: str) str

Use this function to escape the following characters: \n, \r, \t and \.

For a regular expression search, use escape_string() instead.

One possible use case is to take the TextBuffer’s selection and put it in a search entry. The selection can contain tabulations, newlines, etc. So it’s better to escape those special characters to better fit in the search entry.

See also: utils_unescape_search_text.

<warning> Warning: the escape and unescape functions are not reciprocal! For example, escape (unescape ()) = \. So avoid cycles such as: search entry -> unescape

-> search settings -> escape -> search entry. The original search entry text may be modified. </warning>

Parameters:

text – the text to escape.

Returns:

the escaped text.

utils_unescape_search_text(text: str) str

Use this function before set_search_text, to unescape the following sequences of characters: \n, \r, \t and \\. The purpose is to easily write those characters in a search entry.

Note that unescaping the search text is not needed for regular expression searches.

See also: utils_escape_search_text.

Parameters:

text – the text to unescape.

Returns:

the unescaped text.