Functions ========= .. currentmodule:: gi.repository.GtkSource .. function:: 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. :param major: the major version to check :param minor: the minor version to check :param micro: the micro version to check :return: :const:`True` if the version of the GtkSourceView currently loaded is the same as or newer than the passed-in version. .. function:: encoding_get_all() -> list[~gi.repository.GtkSource.Encoding] .. function:: encoding_get_current() -> ~gi.repository.GtkSource.Encoding .. function:: encoding_get_default_candidates() -> list[~gi.repository.GtkSource.Encoding] .. function:: encoding_get_from_charset(charset: str) -> ~gi.repository.GtkSource.Encoding | None :param charset: .. function:: encoding_get_utf8() -> ~gi.repository.GtkSource.Encoding .. function:: file_loader_error_quark() -> int .. function:: file_saver_error_quark() -> int .. function:: 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. .. function:: 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. :return: the major version number of the GtkSourceView library .. function:: 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. :return: the micro version number of the GtkSourceView library .. function:: 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. :return: the minor version number of the GtkSourceView library .. function:: 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. .. function:: scheduler_add(callback: ~typing.Callable[[int, ~typing.Any], bool], user_data: ~typing.Any = None) -> int Simplified version of :obj:`~gi.repository.GtkSource.scheduler_add_full`\. .. versionadded:: 5.2 :param callback: the callback to execute :param user_data: user data for ``callback`` .. function:: scheduler_add_full(callback: ~typing.Callable[[int, ~typing.Any], bool], user_data: ~typing.Any = None) -> 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 :obj:`~gi.repository.GLib.get_monotonic_time` for comparison. Use :obj:`~gi.repository.GtkSource.scheduler_remove` to remove the handler. .. versionadded:: 5.2 :param callback: the callback to execute :param user_data: user data for ``callback`` .. function:: scheduler_remove(handler_id: int) -> None Removes a scheduler callback previously registered with :obj:`~gi.repository.GtkSource.scheduler_add` or :obj:`~gi.repository.GtkSource.scheduler_add_full`\. .. versionadded:: 5.2 :param handler_id: the handler id .. function:: 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 :func:`~gi.repository.GLib.Regex.escape_string` instead. One possible use case is to take the :obj:`~gi.repository.Gtk.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: :obj:`~gi.repository.GtkSource.utils_unescape_search_text`\. 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. :param text: the text to escape. :return: the escaped ``text``\. .. function:: utils_unescape_search_text(text: str) -> str Use this function before :obj:`~gi.repository.SearchSettings.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: :obj:`~gi.repository.GtkSource.utils_escape_search_text`\. :param text: the text to unescape. :return: the unescaped ``text``\.