Module: GtkSource

Extended by:
GLib::Deprecatable
Defined in:
lib/gtksourceview5/loader.rb,
lib/gtksourceview5.rb,
lib/gtksourceview5/deprecated.rb,
lib/gtksourceview5/mark-attributes.rb

Overview

Copyright (C) 2015-2022 Ruby-GNOME Project Team

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Defined Under Namespace

Modules: BackgroundPatternType, BracketMatchType, ChangeCaseType, CompletionActivation, CompletionColumn, CompletionProposal, CompletionProvider, CompressionType, FileLoaderError, FileSaverError, FileSaverFlags, GutterRendererAlignmentMode, HoverProvider, Indenter, NewlineType, SmartHomeEndType, SortFlags, SpaceLocationFlags, SpaceTypeFlags, StyleSchemeChooser, ViewGutterPosition Classes: Buffer, Completion, CompletionCell, CompletionContext, CompletionSnippets, CompletionWords, Error, File, FileLoader, FileSaver, Gutter, GutterLines, GutterRenderer, GutterRendererPixbuf, GutterRendererText, Hover, HoverContext, HoverDisplay, Language, LanguageManager, Loader, Map, Mark, MarkAttributes, PrintCompositor, Region, SearchContext, SearchSettings, Snippet, SnippetChunk, SnippetContext, SnippetManager, SpaceDrawer, Style, StyleScheme, StyleSchemeChooserButton, StyleSchemeChooserWidget, StyleSchemeManager, StyleSchemePreview, Tag, View, VimIMContext

Constant Summary collapse

MAJOR_VERSION =

Like gtk_source_get_major_version(), but from the headers used at application compile time, rather than from the library linked against at application run time.

5
MICRO_VERSION =

Like gtk_source_get_micro_version(), but from the headers used at application compile time, rather than from the library linked against at application run time.

0
MINOR_VERSION =

Like gtk_source_get_minor_version(), but from the headers used at application compile time, rather than from the library linked against at application run time.

12
LOG_DOMAIN =
"GtkSource"

Instance Method Summary collapse

Instance Method Details

#check_version(major, minor, micro) ⇒ Boolean

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. is the same as or newer than the passed-in version.

Parameters:

  • major (Integer)

    the major version to check

  • minor (Integer)

    the minor version to check

  • micro (Integer)

    the micro version to check

Returns:

  • (Boolean)

    true if the version of the GtkSourceView currently loaded

#encoding_get_allGLib::SList<GtkSource::Encoding>

Gets all encodings. all Gtk::SourceEncoding's. Free with g_slist_free().

Returns:

  • (GLib::SList<GtkSource::Encoding>)

    a list of

#encoding_get_currentGtkSource::Encoding

Gets the Gtk::SourceEncoding for the current locale.

See also [funcGLib.get_charset].

Returns:

  • (GtkSource::Encoding)

    the current locale encoding.

#encoding_get_default_candidatesGLib::SList<GtkSource::Encoding>

Gets the list of default candidate encodings to try when loading a file.

See [methodFileLoader.set_candidate_encodings].

This function returns a different list depending on the current locale (i.e. language, country and default encoding). The UTF-8 encoding and the current locale encoding are guaranteed to be present in the returned list. default candidate encodings. Free with g_slist_free().

Returns:

  • (GLib::SList<GtkSource::Encoding>)

    the list of

#encoding_get_from_charset(charset) ⇒ GtkSource::Encoding

Gets a Gtk::SourceEncoding from a character set such as "UTF-8" or "ISO-8859-1". if not found.

Parameters:

  • charset (String)

    a character set.

Returns:

  • (GtkSource::Encoding)

    the corresponding Gtk::SourceEncoding, or nil

#encoding_get_utf8GtkSource::Encoding

Returns the UTF-8 encoding.

Returns:

  • (GtkSource::Encoding)

    the UTF-8 encoding.

#file_loader_error_quarkGLib::Quark

Returns:

  • (GLib::Quark)

#file_saver_error_quarkGLib::Quark

Returns:

  • (GLib::Quark)

#finalizenil

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.

Returns:

  • (nil)

#initnil

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.

Returns:

  • (nil)

#major_versionInteger

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:

  • (Integer)

    the major version number of the GtkSourceView library

#micro_versionInteger

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:

  • (Integer)

    the micro version number of the GtkSourceView library

#minor_versionInteger

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:

  • (Integer)

    the minor version number of the GtkSourceView library

#scheduler_add(callback, user_data) ⇒ Integer

Simplified version of [funcscheduler_add_full].

Parameters:

  • callback (GtkSource::SchedulerCallback)

    the callback to execute

  • user_data (GObject)

    user data for callback

Returns:

  • (Integer)

#scheduler_add_full(callback, user_data, notify) ⇒ Integer

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 [funcGLib.get_monotonic_time] for comparison.

Use [funcscheduler_remove] to remove the handler.

Parameters:

  • callback (GtkSource::SchedulerCallback)

    the callback to execute

  • user_data (GObject)

    user data for callback

  • notify (GLib::DestroyNotify)

    closure notify for user_data

Returns:

  • (Integer)

#scheduler_remove(handler_id) ⇒ nil

Removes a scheduler callback previously registered with [funcscheduler_add] or [funcscheduler_add_full].

Parameters:

  • handler_id (Integer)

    the handler id

Returns:

  • (nil)

#utils_escape_search_text(text) ⇒ String

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

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

One possible use case is to take the 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: [funcutils_unescape_search_text].

Parameters:

  • text (String)

    the text to escape.

Returns:

  • (String)

    the escaped text.

#utils_unescape_search_text(text) ⇒ String

Use this function before [methodSearchSettings.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: [funcutils_escape_search_text].

Parameters:

  • text (String)

    the text to unescape.

Returns:

  • (String)

    the unescaped text.