no pattern
grid pattern
there is no bracket to match.
matching a bracket
failed because the maximum range was reached.
a matching bracket was not found.
a matching bracket was found.
Subclass of [class@Gtk.TextBuffer].
A `GtkSourceBuffer` object is the model for [class@View] widgets.
It extends the [class@Gtk.TextBuffer] class by adding features useful to display
and edit source code such as syntax highlighting and bracket matching.
To create a `GtkSourceBuffer` use [ctor@GtkSource.Buffer.new] or
[ctor@GtkSource.Buffer.new_with_language]. The second form is just a convenience
function which allows you to initially set a [class@Language]. You can also
directly create a [class@View] and get its [class@Buffer] with
[method@Gtk.TextView.get_buffer].
The highlighting is enabled by default, but you can disable it with
[method@Buffer.set_highlight_syntax].
# Context Classes:
It is possible to retrieve some information from the syntax highlighting
engine. The default context classes that are applied to regions of a
`GtkSourceBuffer`:
- **comment**: the region delimits a comment;
- **no-spell-check**: the region should not be spell checked;
- **path**: the region delimits a path to a file;
- **string**: the region delimits a string.
Custom language definition files can create their own context classes,
since the functions like [method@Buffer.iter_has_context_class] take
a string parameter as the context class.
`GtkSourceBuffer` provides an API to access the context classes:
[method@Buffer.iter_has_context_class],
[method@Buffer.get_context_classes_at_iter],
[method@Buffer.iter_forward_to_context_class_toggle] and
[method@Buffer.iter_backward_to_context_class_toggle].
And the [signal@GtkSource.Buffer::highlight-updated] signal permits to be notified
when a context class region changes.
Each context class has also an associated [class@Gtk.TextTag] with the name
`gtksourceview:context-classes:<name>`. For example to
retrieve the [class@Gtk.TextTag] for the string context class, one can write:
```c
GtkTextTagTable *tag_table;
GtkTextTag *tag;
tag_table = gtk_text_buffer_get_tag_table (buffer);
tag = gtk_text_tag_table_lookup (tag_table, "gtksourceview:context-classes:string");
```
The tag must be used for read-only purposes.
Accessing a context class via the associated [class@Gtk.TextTag] is less
convenient than the `GtkSourceBuffer` API, because:
- The tag doesn't always exist, you need to listen to the
[signal@Gtk.TextTagTable::tag-added] and [signal@Gtk.TextTagTable::tag-removed] signals.
- Instead of the [signal@GtkSource.Buffer::highlight-updated] signal, you can listen
to the [signal@Gtk.TextBuffer::apply-tag] and [signal@Gtk.TextBuffer::remove-tag] signals.
A possible use-case for accessing a context class via the associated
[class@Gtk.TextTag] is to read the region but without adding a hard dependency on the
GtkSourceView library (for example for a spell-checking library that wants to
read the no-spell-check region).
Creates a new source buffer.
a new source buffer.
a #GtkTextTagTable, or %NULL to create a new one.
Creates a new source buffer using the highlighting patterns in `language`.
This is equivalent to creating a new source buffer with
a new tag table and then calling [method@Buffer.set_language].
a new source buffer which will highlight text
according to the highlighting patterns in `language`.
a #GtkSourceLanguage.
Moves `iter` to the position of the previous [class@Mark] of the given
category.
Returns %TRUE if `iter` was moved. If `category` is NULL, the
previous source mark can be of any category.
whether `iter` was moved.
a #GtkSourceBuffer.
an iterator.
category to search for, or %NULL
Changes the case of the text between the specified iterators.
Since 5.4, this function will update the position of `start` and
`end` to surround the modified text.
a #GtkSourceBuffer.
how to change the case.
a #GtkTextIter.
a #GtkTextIter.
Creates a source mark in the `buffer` of category `category`.
A source mark is a [class@Gtk.TextMark] but organized into categories.
Depending on the category a pixbuf can be specified that will be displayed
along the line of the mark.
Like a [class@Gtk.TextMark], a [class@Mark] can be anonymous if the
passed `name` is %NULL. Also, the buffer owns the marks so you
shouldn't unreference it.
Marks always have left gravity and are moved to the beginning of
the line when the user deletes the line they were in.
Typical uses for a source mark are bookmarks, breakpoints, current
executing instruction indication in a source file, etc..
a new [class@Mark], owned by the buffer.
a #GtkSourceBuffer.
the name of the mark, or %NULL.
a string defining the mark category.
location to place the mark.
In short, this is the same function as [method@Gtk.TextBuffer.create_tag] but
instead of creating a [class@Gtk.TextTag], this function creates a [class@Tag].
This function creates a [class@Tag] and adds it to the tag table for
`buffer`. Equivalent to calling [ctor@Gtk.TextTag.new] and then adding the tag to
the buffer’s tag table. The returned tag is owned by the buffer’s tag table,
so the ref count will be equal to one.
If `tag_name` is %NULL, the tag is anonymous.
If `tag_name` is non-%NULL, a tag called `tag_name` must not already
exist in the tag table for this buffer.
The `first_property_name` argument and subsequent arguments are a list
of properties to set on the tag, as with [method@GObject.Object.set].
a new [class@Tag].
a #GtkSourceBuffer
name of the new tag, or %NULL
name of first property to set, or %NULL
%NULL-terminated list of property names and values
Forces buffer to analyze and highlight the given area synchronously.
**Note**:
This is a potentially slow operation and should be used only
when you need to make sure that some text not currently
visible is highlighted, for instance before printing.
a #GtkSourceBuffer.
start of the area to highlight.
end of the area to highlight.
Moves `iter` to the position of the next [class@Mark] of the given
`category`.
Returns %TRUE if `iter` was moved. If `category` is NULL, the
next source mark can be of any category.
whether `iter` was moved.
a #GtkSourceBuffer.
an iterator.
category to search for, or %NULL
Get all defined context classes at @iter.
See the [class@Buffer] description for the list of default context classes.
a new %NULL
terminated array of context class names.
Use g_strfreev() to free the array if it is no longer needed.
a #GtkSourceBuffer.
a #GtkTextIter.
Determines whether bracket match highlighting is activated for the
source buffer.
%TRUE if the source buffer will highlight matching
brackets.
a #GtkSourceBuffer.
Determines whether syntax highlighting is activated in the source
buffer.
%TRUE if syntax highlighting is enabled, %FALSE otherwise.
a #GtkSourceBuffer.
whether the @buffer has an implicit trailing newline.
a #GtkSourceBuffer.
Returns the [class@Language] associated with the buffer,
see [method@Buffer.set_language].
The returned object should not be unreferenced by the user.
the [class@Language] associated
with the buffer, or %NULL.
a #GtkSourceBuffer.
Returns the list of marks of the given category at @iter.
If @category is %NULL it returns all marks at @iter.
a newly allocated #GSList.
a #GtkSourceBuffer.
an iterator.
category to search for, or %NULL
Returns the list of marks of the given category at @line.
If @category is %NULL, all marks at @line are returned.
a newly allocated #GSList.
a #GtkSourceBuffer.
a line number.
category to search for, or %NULL
Returns the [class@StyleScheme] associated with the buffer,
see [method@Buffer.set_style_scheme].
The returned object should not be unreferenced by the user.
the [class@StyleScheme]
associated with the buffer, or %NULL.
a #GtkSourceBuffer.
Moves backward to the next toggle (on or off) of the context class.
If no matching context class toggles are found, returns %FALSE, otherwise %TRUE.
Does not return toggles located at @iter, only toggles after @iter. Sets
@iter to the location of the toggle, or to the end of the buffer if no
toggle is found.
See the [class@Buffer] description for the list of default context classes.
whether we found a context class toggle before @iter
a #GtkSourceBuffer.
a #GtkTextIter.
the context class.
Moves forward to the next toggle (on or off) of the context class.
If no matching context class toggles are found, returns %FALSE, otherwise %TRUE.
Does not return toggles located at @iter, only toggles after @iter. Sets
@iter to the location of the toggle, or to the end of the buffer if no
toggle is found.
See the [class@Buffer] description for the list of default context classes.
whether we found a context class toggle after @iter
a #GtkSourceBuffer.
a #GtkTextIter.
the context class.
Check if the class @context_class is set on @iter.
See the [class@Buffer] description for the list of default context classes.
whether @iter has the context class.
a #GtkSourceBuffer.
a #GtkTextIter.
class to search for.
Joins the lines of text between the specified iterators.
a #GtkSourceBuffer.
a #GtkTextIter.
a #GtkTextIter.
Remove all marks of @category between @start and @end from the buffer.
If @category is NULL, all marks in the range will be removed.
a #GtkSourceBuffer.
a #GtkTextIter.
a #GtkTextIter.
category to search for, or %NULL.
Controls the bracket match highlighting function in the buffer.
If activated, when you position your cursor over a bracket character
(a parenthesis, a square bracket, etc.) the matching opening or
closing bracket character will be highlighted.
a #GtkSourceBuffer.
%TRUE if you want matching brackets highlighted.
Controls whether syntax is highlighted in the buffer.
If @highlight is %TRUE, the text will be highlighted according to the syntax
patterns specified in the [class@Language] set with [method@Buffer.set_language].
If @highlight is %FALSE, syntax highlighting is disabled and all the
[class@Gtk.TextTag] objects that have been added by the syntax highlighting engine
are removed from the buffer.
a #GtkSourceBuffer.
%TRUE to enable syntax highlighting, %FALSE to disable it.
Sets whether the @buffer has an implicit trailing newline.
If an explicit trailing newline is present in a [class@Gtk.TextBuffer], [class@Gtk.TextView]
shows it as an empty line. This is generally not what the user expects.
If @implicit_trailing_newline is %TRUE (the default value):
- when a [class@FileLoader] loads the content of a file into the @buffer,
the trailing newline (if present in the file) is not inserted into the
@buffer.
- when a [class@FileSaver] saves the content of the @buffer into a file, a
trailing newline is added to the file.
On the other hand, if @implicit_trailing_newline is %FALSE, the file's
content is not modified when loaded into the @buffer, and the @buffer's
content is not modified when saved into a file.
a #GtkSourceBuffer.
the new value.
Associates a [class@Language] with the buffer.
Note that a [class@Language] affects not only the syntax highlighting, but
also the [context classes](./class.Buffer.html#context-classes). If you want to disable just the
syntax highlighting, see [method@Buffer.set_highlight_syntax].
The buffer holds a reference to @language.
a #GtkSourceBuffer.
a #GtkSourceLanguage to set, or %NULL.
Sets a [class@StyleScheme] to be used by the buffer and the view.
Note that a [class@StyleScheme] affects not only the syntax highlighting,
but also other [class@View] features such as highlighting the current line,
matching brackets, the line numbers, etc.
Instead of setting a %NULL @scheme, it is better to disable syntax
highlighting with [method@Buffer.set_highlight_syntax], and setting the
[class@StyleScheme] with the "classic" or "tango" ID, because those two
style schemes follow more closely the GTK theme (for example for the
background color).
The buffer holds a reference to @scheme.
a #GtkSourceBuffer.
a #GtkSourceStyleScheme or %NULL.
Sort the lines of text between the specified iterators.
a #GtkSourceBuffer.
a #GtkTextIter.
a #GtkTextIter.
#GtkSourceSortFlags specifying how the sort should behave
sort considering the text starting at the given column
Whether to highlight matching brackets in the buffer.
Whether to highlight syntax in the buffer.
Whether the buffer has an implicit trailing newline. See
[method@Buffer.set_implicit_trailing_newline].
The "loading" property denotes that a `GtkSourceFileLoader` is
currently loading the buffer.
Applications may want to use this setting to avoid doing work
while the buffer is loading such as spellchecking.
Style scheme. It contains styles for syntax highlighting, optionally
foreground, background, cursor color, current line color, and matching
brackets style.
@iter is set to a valid iterator pointing to the matching bracket
if @state is %GTK_SOURCE_BRACKET_MATCH_FOUND. Otherwise @iter is
meaningless.
The signal is emitted only when the @state changes, typically when
the cursor moves.
A use-case for this signal is to show messages in a [class@Gtk.Statusbar].
if found, the location of the matching bracket.
state of bracket matching.
The "cursor-moved" signal is emitted when then insertion mark has moved.
The ::highlight-updated signal is emitted when the syntax
highlighting and [context classes](./class.Buffer.html#context-classes) are updated in a
certain region of the @buffer.
the start of the updated region
the end of the updated region
The ::source-mark-updated signal is emitted each time
a mark is added to, moved or removed from the @buffer.
the [class@Mark]
Macro to test the version of GtkSourceView being compiled against.
major version (e.g. 3 for version 3.20.0)
minor version (e.g. 20 for version 3.20.0)
micro version (e.g. 0 for version 3.20.0)
change case to lowercase.
change case to uppercase.
toggle case of each character.
capitalize each word.
Main Completion Object.
The completion system helps the user when they writes some text,
such as words, command names, functions, and suchlike. Proposals can
be shown, to complete the text the user is writing. Each proposal can
contain an additional piece of information (for example
documentation), that is displayed when the "Details" button is
clicked.
Proposals are created via a [iface@CompletionProvider]. There can
be for example a provider to complete words (see [class@CompletionWords]),
another provider for the completion of
function names, etc. To add a provider, call
[method@Completion.add_provider].
The [iface@CompletionProposal] interface represents a proposal.
If a proposal contains extra information (see
%GTK_SOURCE_COMPLETION_COLUMN_DETAILS), it will be
displayed in a supplemental details window, which appears when
the "Details" button is clicked.
Each [class@View] object is associated with a [class@Completion]
instance. This instance can be obtained with
[method@View.get_completion]. The [class@View] class contains also the
[signal@View::show-completion] signal.
A same [iface@CompletionProvider] object can be used for several
`GtkSourceCompletion`'s.
This will add `<b>` tags around matched characters in @haystack
based on @casefold_query.
a #PangoAttrList or %NULL
the string to be highlighted
the typed-text used to highlight @haystack
This helper function can do a fuzzy match for you giving a haystack and
casefolded needle.
Casefold your needle using [func@GLib.utf8_casefold] before
running the query.
Score will be set with the score of the match upon success. Otherwise,
it will be set to zero.
%TRUE if @haystack matched @casefold_needle, otherwise %FALSE.
the string to be searched.
A g_utf8_casefold() version of the needle.
An optional location for the score of the match
Adds a [iface@CompletionProvider] to the list of providers to be queried
for completion results.
a #GtkSourceCompletion
a #GtkSourceCompletionProvider
Gets the connected [class@View]'s [class@Buffer]
A #GtkSourceBuffer
a #GtkSourceCompletion
Gets the [class@View] that owns the [class@Completion].
A #GtkSourceView
a #GtkSourceCompletion
Emits the "hide" signal.
When the "hide" signal is emitted, the completion window will be
dismissed.
a #GtkSourceCompletion
Removes a [iface@CompletionProvider] previously added with
[method@Completion.add_provider].
a #GtkSourceCompletion
a #GtkSourceCompletionProvider
Emits the "show" signal.
When the "show" signal is emitted, the completion window will be
displayed if there are any results available.
a #GtkSourceCompletion
The #GtkTextBuffer for the #GtkSourceCompletion:view.
This is a convenience property for providers.
The number of rows to display to the user before scrolling.
Determines whether the visibility of the info window should be saved when the
completion is hidden, and restored when the completion is shown again.
Determines whether the first proposal should be selected when the completion
is first shown.
The "show-icons" property denotes if icons should be displayed within
the list of completions presented to the user.
The "view" property is the #GtkTextView for which this #GtkSourceCompletion
is providing completion features.
The "hide" signal is emitted when the completion window should
be hidden.
The "provided-added" signal is emitted when a new provider is
added to the completion.
a #GtkSourceCompletionProvider
The "provided-removed" signal is emitted when a provider has
been removed from the completion.
a #GtkSourceCompletionProvider
The "show" signal is emitted when the completion window should
be shown.
Widget for single cell of completion proposal.
The `GtkSourceCompletionCell` widget provides a container to display various
types of information with the completion display.
Each proposal may consist of multiple cells depending on the complexity of
the proposal. For example, programming language proposals may contain a cell
for the "left-hand-side" of an operation along with the "typed-text" for a
function name and "parameters". They may also optionally set an icon to
signify the kind of result.
A [iface@CompletionProvider] should implement the
[vfunc@CompletionProvider.display] virtual function to control
how to convert data from their [iface@CompletionProposal] to content for
the `GtkSourceCompletionCell`.
Gets the child #GtkWidget, if any.
a #GtkWidget or %NULL
a #GtkSourceCompletionCell
Sets the text for the column cell. Use %NULL to unset.
a #GtkSourceCompletionCell
the text to set or %NULL
The context of a completion.
`GtkSourceCompletionContext` contains information about an attept to display
completion proposals to the user based on typed text in the [class@View].
When typing, [class@Completion] may use registered
[iface@CompletionProvider] to determine if there may be results which
could be displayed. If so, a `GtkSourceCompletionContext` is created with
information that is provided to the [iface@CompletionProvider] to populate
results which might be useful to the user.
[iface@CompletionProvider] are expected to provide [iface@Gio.ListModel] with
[iface@CompletionProposal] which may be joined together in a list of
results for the user. They are also responsible for how the contents are
displayed using [class@CompletionCell] which allows for some level of
customization.
Gets the mode for which the context was activated.
a #GtkSourceCompletionContext
Gets the bounds for the completion, which is the beginning of the
current word (taking break characters into account) to the current
insertion cursor.
If @begin is non-%NULL, it will be set to the start position of the
current word being completed.
If @end is non-%NULL, it will be set to the insertion cursor for the
current word being completed.
%TRUE if the marks are still valid and @begin or @end was set.
an #GtkSourceCompletionContext
a #GtkTextIter
a #GtkTextIter
Gets the underlying buffer used by the context.
This is a convenience function to get the buffer via the #GtkSourceCompletion
property.
a #GtkTextBuffer or %NULL
an #GtkSourceCompletionContext
Gets the "busy" property. This is set to %TRUE while the completion
context is actively fetching proposals from registered
#GtkSourceCompletionProvider's.
%TRUE if the context is busy
a #GtkSourceCompletionContext
Gets the #GtkSourceCompletion that created the context.
an #GtkSourceCompletion or %NULL
an #GtkSourceCompletionContext
Checks if any proposals have been provided to the context.
Out of convenience, this function will return %TRUE if @self is %NULL.
%TRUE if there are no proposals in the context
a #GtkSourceCompletionContext
Gets the language of the underlying buffer, if any.
a #GtkSourceLanguage or %NULL
a #GtkSourceCompletionContext
Gets the #GListModel associated with the provider.
You can connect to #GtkSourceCompletionContext::model-changed to receive
notifications about when the model has been replaced by a new model.
a #GListModel or %NULL
a #GtkSourceCompletionContext
a #GtkSourceCompletionProvider
Gets the text view for the context.
a #GtkSourceView or %NULL
a #GtkSourceCompletionContext
Gets the word that is being completed up to the position of the insert mark.
a string containing the current word
a #GtkSourceCompletionContext
Gets the providers that are associated with the context.
a #GListModel of #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
This function allows providers to update their results for a context
outside of a call to [method@CompletionProvider.populate_async].
This can be used to immediately return results for a provider while it does
additional asynchronous work. Doing so will allow the completions to
update while the operation is in progress.
an #GtkSourceCompletionContext
an #GtkSourceCompletionProvider
a #GListModel or %NULL
The "busy" property is %TRUE while the completion context is
populating completion proposals.
The "completion" is the #GtkSourceCompletion that was used to create the context.
The "empty" property is %TRUE when there are no results.
It will be notified when the first result is added or the last
result is removed.
Emitted when a provider changes a model.
This signal is primarily useful for #GtkSourceCompletionProvider's
that want to track other providers in context. For example, it can
be used to create a "top results" provider.
a #GtkSourceCompletionProvider
a #GListModel
Interface for completion proposals.
This interface is used to denote that an object is capable of being
a completion proposal for [class@Completion].
Currently, no method or functions are required but additional methods
may be added in the future. Proposals created by
#GtkSourceCompletionProvider can use [func@GObject.IMPLEMENT_INTERFACE] to
implement this with %NULL for the interface init function.
Gets the typed-text for the proposal, if supported by the implementation.
Implementing this virtual-function is optional, but can be useful to allow
external tooling to compare results.
a newly allocated string, or %NULL
a #GtkSourceCompletionProposal
Gets the typed-text for the proposal, if supported by the implementation.
Implementing this virtual-function is optional, but can be useful to allow
external tooling to compare results.
a newly allocated string, or %NULL
a #GtkSourceCompletionProposal
a newly allocated string, or %NULL
a #GtkSourceCompletionProposal
Completion provider interface.
You must implement this interface to provide proposals to [class@Completion].
In most cases, implementations of this interface will want to use
[vfunc@CompletionProvider.populate_async] to asynchronously populate the results
to avoid blocking the main loop.
This function requests @proposal to be activated by the
#GtkSourceCompletionProvider.
What the provider does to activate the proposal is specific to that
provider. Many providers may choose to insert a #GtkSourceSnippet with
edit points the user may cycle through.
See also: [class@Snippet], [class@SnippetChunk], [method@View.push_snippet]
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GtkSourceCompletionProposal
This function requests that the #GtkSourceCompletionProvider prepares
@cell to display the contents of @proposal.
Based on @cells column type, you may want to display different information.
This allows for columns of information among completion proposals
resulting in better alignment of similar content (icons, return types,
method names, and parameter lists).
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GtkSourceCompletionProposal
a #GtkSourceCompletionCell
This function should return the priority of @self in @context.
The priority is used to sort groups of completion proposals by
provider so that higher priority providers results are shown
above lower priority providers.
Higher value indicates higher priority.
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
Gets the title of the completion provider, if any.
Currently, titles are not displayed in the completion results, but may be
at some point in the future when non-%NULL.
a title for the provider or %NULL
a #GtkSourceCompletionProvider
This function is used to determine if a character inserted into the text
editor should cause a new completion request to be triggered.
An example would be period '.' which might indicate that the user wants
to complete method or field names of an object.
This method will only trigger when text is inserted into the #GtkTextBuffer
while the completion list is visible and a proposal is selected. Incremental
key-presses (like shift, control, or alt) are not triggerable.
a #GtkSourceCompletionProvider
a #GtkTextIter
a #gunichar of the character inserted
This function is used to determine if a key typed by the user should
activate @proposal (resulting in committing the text to the editor).
This is useful when using languages where convention may lead to less
typing by the user. One example may be the use of "." or "-" to expand
a field access in the C programming language.
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GtkSourceCompletionProposal
a keyval such as [const@Gdk.KEY_period]
a #GdkModifierType or 0
Providers should return a list of alternates to @proposal or %NULL if
there are no alternates available.
This can be used by the completion view to allow the user to move laterally
through similar proposals, such as overrides of methods by the same name.
a #GPtrArray of #GtkSourceCompletionProposal or %NULL.
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GtkSourceCompletionProposal
Asynchronously requests that the provider populates the completion
results for @context.
For providers that would like to populate a [iface@Gio.ListModel] while those
results are displayed to the user,
[method@CompletionContext.set_proposals_for_provider] may be used
to reduce latency until the user sees results.
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GCancellable or %NULL
a callback to execute upon completion
closure data for @callback
Completes an asynchronous operation to populate a completion provider.
a #GListModel of #GtkSourceCompletionProposal
a #GtkSourceCompletionProvider
a #GAsyncResult provided to callback
This function can be used to filter results previously provided to
the [class@CompletionContext] by the #GtkSourceCompletionProvider.
This can happen as the user types additional text onto the word so
that previously matched items may be removed from the list instead of
generating new [iface@Gio.ListModel] of results.
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GListModel
This function requests @proposal to be activated by the
#GtkSourceCompletionProvider.
What the provider does to activate the proposal is specific to that
provider. Many providers may choose to insert a #GtkSourceSnippet with
edit points the user may cycle through.
See also: [class@Snippet], [class@SnippetChunk], [method@View.push_snippet]
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GtkSourceCompletionProposal
This function requests that the #GtkSourceCompletionProvider prepares
@cell to display the contents of @proposal.
Based on @cells column type, you may want to display different information.
This allows for columns of information among completion proposals
resulting in better alignment of similar content (icons, return types,
method names, and parameter lists).
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GtkSourceCompletionProposal
a #GtkSourceCompletionCell
This function should return the priority of @self in @context.
The priority is used to sort groups of completion proposals by
provider so that higher priority providers results are shown
above lower priority providers.
Higher value indicates higher priority.
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
Gets the title of the completion provider, if any.
Currently, titles are not displayed in the completion results, but may be
at some point in the future when non-%NULL.
a title for the provider or %NULL
a #GtkSourceCompletionProvider
This function is used to determine if a character inserted into the text
editor should cause a new completion request to be triggered.
An example would be period '.' which might indicate that the user wants
to complete method or field names of an object.
This method will only trigger when text is inserted into the #GtkTextBuffer
while the completion list is visible and a proposal is selected. Incremental
key-presses (like shift, control, or alt) are not triggerable.
a #GtkSourceCompletionProvider
a #GtkTextIter
a #gunichar of the character inserted
This function is used to determine if a key typed by the user should
activate @proposal (resulting in committing the text to the editor).
This is useful when using languages where convention may lead to less
typing by the user. One example may be the use of "." or "-" to expand
a field access in the C programming language.
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GtkSourceCompletionProposal
a keyval such as [const@Gdk.KEY_period]
a #GdkModifierType or 0
Providers should return a list of alternates to @proposal or %NULL if
there are no alternates available.
This can be used by the completion view to allow the user to move laterally
through similar proposals, such as overrides of methods by the same name.
a #GPtrArray of #GtkSourceCompletionProposal or %NULL.
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GtkSourceCompletionProposal
Asynchronously requests that the provider populates the completion
results for @context.
For providers that would like to populate a [iface@Gio.ListModel] while those
results are displayed to the user,
[method@CompletionContext.set_proposals_for_provider] may be used
to reduce latency until the user sees results.
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GCancellable or %NULL
a callback to execute upon completion
closure data for @callback
Completes an asynchronous operation to populate a completion provider.
a #GListModel of #GtkSourceCompletionProposal
a #GtkSourceCompletionProvider
a #GAsyncResult provided to callback
This function can be used to filter results previously provided to
the [class@CompletionContext] by the #GtkSourceCompletionProvider.
This can happen as the user types additional text onto the word so
that previously matched items may be removed from the list instead of
generating new [iface@Gio.ListModel] of results.
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GListModel
a title for the provider or %NULL
a #GtkSourceCompletionProvider
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GtkSourceCompletionProvider
a #GtkTextIter
a #gunichar of the character inserted
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GtkSourceCompletionProposal
a keyval such as [const@Gdk.KEY_period]
a #GdkModifierType or 0
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GCancellable or %NULL
a callback to execute upon completion
closure data for @callback
a #GListModel of #GtkSourceCompletionProposal
a #GtkSourceCompletionProvider
a #GAsyncResult provided to callback
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GListModel
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GtkSourceCompletionProposal
a #GtkSourceCompletionCell
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GtkSourceCompletionProposal
a #GPtrArray of #GtkSourceCompletionProposal or %NULL.
a #GtkSourceCompletionProvider
a #GtkSourceCompletionContext
a #GtkSourceCompletionProposal
A [iface@CompletionProvider] for the completion of snippets.
The `GtkSourceCompletionSnippets` is an example of an implementation of
the [iface@CompletionProvider] interface. The proposals are snippets
registered with the [class@SnippetManager].
A [iface@CompletionProvider] for the completion of words.
The `GtkSourceCompletionWords` is an example of an implementation of
the [iface@CompletionProvider] interface. The proposals are words
appearing in the registered [class@Gtk.TextBuffer]s.
a new #GtkSourceCompletionWords provider
The title for the provider, or %NULL.
Registers @buffer in the @words provider.
a #GtkSourceCompletionWords
a #GtkTextBuffer
Unregisters @buffer from the @words provider.
a #GtkSourceCompletionWords
a #GtkTextBuffer
plain text.
gzip compression.
Character encoding.
The #GtkSourceEncoding boxed type represents a character encoding. It is used
for example by #GtkSourceFile. Note that the text in GTK widgets is always
encoded in UTF-8.
Used by language bindings.
a copy of @enc.
a #GtkSourceEncoding.
Used by language bindings.
a #GtkSourceEncoding.
Gets the character set of the #GtkSourceEncoding, such as "UTF-8" or
"ISO-8859-1".
the character set of the #GtkSourceEncoding.
a #GtkSourceEncoding.
Gets the name of the #GtkSourceEncoding such as "Unicode" or "Western".
the name of the #GtkSourceEncoding.
a #GtkSourceEncoding.
a string representation. Free with g_free() when no longer needed.
a #GtkSourceEncoding.
Gets all encodings.
a list of
all #GtkSourceEncoding's. Free with g_slist_free().
Gets the #GtkSourceEncoding for the current locale.
See also [func@GLib.get_charset].
the current locale encoding.
Gets the list of default candidate encodings to try when loading a file.
See [method@FileLoader.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.
the list of
default candidate encodings. Free with g_slist_free().
Gets a #GtkSourceEncoding from a character set such as "UTF-8" or
"ISO-8859-1".
the corresponding #GtkSourceEncoding, or %NULL
if not found.
a character set.
the UTF-8 encoding.
On-disk representation of a [class@Buffer].
A `GtkSourceFile` object is the on-disk representation of a [class@Buffer].
With a `GtkSourceFile`, you can create and configure a [class@FileLoader]
and [class@FileSaver] which take by default the values of the
`GtkSourceFile` properties (except for the file loader which auto-detect some
properties). On a successful load or save operation, the `GtkSourceFile`
properties are updated. If an operation fails, the `GtkSourceFile` properties
have still the previous valid values.
a new #GtkSourceFile object.
Checks synchronously the file on disk, to know whether the file is externally
modified, or has been deleted, and whether the file is read-only.
#GtkSourceFile doesn't create a [class@Gio.FileMonitor] to track those properties, so
this function needs to be called instead. Creating lots of [class@Gio.FileMonitor]'s
would take lots of resources.
Since this function is synchronous, it is advised to call it only on local
files. See [method@File.is_local].
a #GtkSourceFile.
the compression type.
a #GtkSourceFile.
The encoding is initially %NULL. After a successful file loading or saving
operation, the encoding is non-%NULL.
the character encoding.
a #GtkSourceFile.
the #GFile.
a #GtkSourceFile.
the newline type.
a #GtkSourceFile.
Returns whether the file has been deleted. If the
[property@File:location] is %NULL, returns %FALSE.
To have an up-to-date value, you must first call
[method@File.check_file_on_disk].
whether the file has been deleted.
a #GtkSourceFile.
Returns whether the file is externally modified. If the
[property@File:location] is %NULL, returns %FALSE.
To have an up-to-date value, you must first call
[method@File.check_file_on_disk].
whether the file is externally modified.
a #GtkSourceFile.
Returns whether the file is local. If the [property@File:location] is %NULL,
returns %FALSE.
whether the file is local.
a #GtkSourceFile.
Returns whether the file is read-only. If the
[property@File:location] is %NULL, returns %FALSE.
To have an up-to-date value, you must first call
[method@File.check_file_on_disk].
whether the file is read-only.
a #GtkSourceFile.
Sets the location.
a #GtkSourceFile.
the new #GFile, or %NULL.
Sets a [callback@MountOperationFactory] function that will be called when a
[class@Gio.MountOperation] must be created.
This is useful for creating a [class@Gtk.MountOperation] with the parent [class@Gtk.Window].
If a mount operation factory isn't set, [ctor@Gio.MountOperation.new] will be
called.
a #GtkSourceFile.
a #GtkSourceMountOperationFactory to call when a
#GMountOperation is needed.
the data to pass to the @callback function.
function to call on @user_data when the @callback is no
longer needed, or %NULL.
The compression type.
The character encoding, initially %NULL. After a successful file
loading or saving operation, the encoding is non-%NULL.
The location.
The line ending type.
Whether the file is read-only or not. The value of this property is
not updated automatically (there is no file monitors).
Load a file into a GtkSourceBuffer.
A `GtkSourceFileLoader` object permits to load the contents of a [iface@Gio.File] or a
[class@Gio.InputStream] into a [class@Buffer].
A file loader should be used only for one load operation, including errors
handling. If an error occurs, you can reconfigure the loader and relaunch the
operation with [method@FileLoader.load_async].
Running a `GtkSourceFileLoader` is an undoable action for the
[class@Buffer].
After a file loading, the buffer is reset to the contents provided by the
[iface@Gio.File] or [class@Gio.InputStream], so the buffer is set as “unmodified”, that is,
[method@Gtk.TextBuffer.set_modified] is called with %FALSE. If the contents isn't
saved somewhere (for example if you load from stdin), then you should
probably call [method@Gtk.TextBuffer.set_modified] with %TRUE after calling
[method@FileLoader.load_finish].
Creates a new `GtkSourceFileLoader` object. The contents is read from the
[class@File]'s location.
If not already done, call [method@File.set_location] before calling this constructor.
The previous location is anyway not needed, because as soon as the file loading begins,
the @buffer is emptied.
a new #GtkSourceFileLoader object.
the #GtkSourceBuffer to load the contents into.
the #GtkSourceFile.
Creates a new #GtkSourceFileLoader object. The contents is read from @stream.
a new #GtkSourceFileLoader object.
the #GtkSourceBuffer to load the contents into.
the #GtkSourceFile.
the #GInputStream to load, e.g. stdin.
the #GtkSourceBuffer to load the contents into.
a #GtkSourceFileLoader.
the detected compression type.
a #GtkSourceFileLoader.
the detected file encoding.
a #GtkSourceFileLoader.
the #GtkSourceFile.
a #GtkSourceFileLoader.
the #GInputStream to load, or %NULL
if a #GFile is used.
a #GtkSourceFileLoader.
the #GFile to load, or %NULL
if an input stream is used.
a #GtkSourceFileLoader.
the detected newline type.
a #GtkSourceFileLoader.
Loads asynchronously the file or input stream contents into the [class@Buffer].
See the [iface@Gio.AsyncResult] documentation to know how to use this
function.
a #GtkSourceFileLoader.
the I/O priority of the request. E.g. %G_PRIORITY_LOW,
%G_PRIORITY_DEFAULT or %G_PRIORITY_HIGH.
optional #GCancellable object, %NULL to ignore.
function to call back with
progress information, or %NULL if progress information is not needed.
user data to pass to @progress_callback.
function to call on
@progress_callback_data when the @progress_callback is no longer needed, or
%NULL.
a #GAsyncReadyCallback to call when the request is
satisfied.
user data to pass to @callback.
Finishes a file loading started with [method@FileLoader.load_async].
If the contents has been loaded, the following [class@File] properties will
be updated: the location, the encoding, the newline type and the compression
type.
whether the contents has been loaded successfully.
a #GtkSourceFileLoader.
a #GAsyncResult.
Sets the candidate encodings for the file loading.
The encodings are tried in the same order as the list.
For convenience, @candidate_encodings can contain duplicates. Only the first
occurrence of a duplicated encoding is kept in the list.
By default the candidate encodings are (in that order in the list):
1. If set, the [class@File]'s encoding as returned by [method@File.get_encoding].
2. The default candidates as returned by [func@Encoding.get_default_candidates].
a #GtkSourceFileLoader.
a list of
#GtkSourceEncoding<!-- -->s.
The #GtkSourceBuffer to load the contents into. The
#GtkSourceFileLoader object has a weak reference to the buffer.
The #GtkSourceFile. The #GtkSourceFileLoader object has a weak
reference to the file.
The #GInputStream to load. Useful for reading stdin. If this property
is set, the #GtkSourceFileLoader:location property is ignored.
The #GFile to load. If the #GtkSourceFileLoader:input-stream is
%NULL, by default the location is taken from the #GtkSourceFile at
construction time.
An error code used with the %GTK_SOURCE_FILE_LOADER_ERROR domain.
The file is too big.
It is not
possible to detect the encoding automatically.
There was an encoding
conversion error and it was needed to use a fallback character.
Save a [class@Buffer] into a file.
A `GtkSourceFileSaver` object permits to save a [class@Buffer] into a
[iface@Gio.File].
A file saver should be used only for one save operation, including errors
handling. If an error occurs, you can reconfigure the saver and relaunch the
operation with [method@FileSaver.save_async].
Creates a new #GtkSourceFileSaver object. The @buffer will be saved to the
[class@File]'s location.
This constructor is suitable for a simple "save" operation, when the @file
already contains a non-%NULL [property@File:location].
a new #GtkSourceFileSaver object.
the #GtkSourceBuffer to save.
the #GtkSourceFile.
Creates a new #GtkSourceFileSaver object with a target location.
When the file saving is finished successfully, @target_location is set to the @file's
[property@File:location] property. If an error occurs, the previous valid
location is still available in [class@File].
This constructor is suitable for a "save as" operation, or for saving a new
buffer for the first time.
a new #GtkSourceFileSaver object.
the #GtkSourceBuffer to save.
the #GtkSourceFile.
the #GFile where to save the buffer to.
the #GtkSourceBuffer to save.
a #GtkSourceFileSaver.
the compression type.
a #GtkSourceFileSaver.
the encoding.
a #GtkSourceFileSaver.
the #GtkSourceFile.
a #GtkSourceFileSaver.
the flags.
a #GtkSourceFileSaver.
the #GFile where to save the buffer to.
a #GtkSourceFileSaver.
the newline type.
a #GtkSourceFileSaver.
Saves asynchronously the buffer into the file.
See the [iface@Gio.AsyncResult] documentation to know how to use this function.
a #GtkSourceFileSaver.
the I/O priority of the request. E.g. %G_PRIORITY_LOW,
%G_PRIORITY_DEFAULT or %G_PRIORITY_HIGH.
optional #GCancellable object, %NULL to ignore.
function to call back with
progress information, or %NULL if progress information is not needed.
user data to pass to @progress_callback.
function to call on
@progress_callback_data when the @progress_callback is no longer needed, or
%NULL.
a #GAsyncReadyCallback to call when the request is
satisfied.
user data to pass to @callback.
Finishes a file saving started with [method@FileSaver.save_async].
If the file has been saved successfully, the following [class@File]
properties will be updated: the location, the encoding, the newline type and
the compression type.
Since the 3.20 version, [method@Gtk.TextBuffer.set_modified] is called with %FALSE
if the file has been saved successfully.
whether the file was saved successfully.
a #GtkSourceFileSaver.
a #GAsyncResult.
Sets the compression type. By default the compression type is taken from the
#GtkSourceFile.
a #GtkSourceFileSaver.
the new compression type.
Sets the encoding. If @encoding is %NULL, the UTF-8 encoding will be set.
By default the encoding is taken from the #GtkSourceFile.
a #GtkSourceFileSaver.
the new encoding, or %NULL for UTF-8.
a #GtkSourceFileSaver.
the new flags.
Sets the newline type. By default the newline type is taken from the
#GtkSourceFile.
a #GtkSourceFileSaver.
the new newline type.
The #GtkSourceBuffer to save. The #GtkSourceFileSaver object has a
weak reference to the buffer.
The compression type.
The file's encoding.
The #GtkSourceFile. The #GtkSourceFileSaver object has a weak
reference to the file.
File saving flags.
The #GFile where to save the buffer. By default the location is taken
from the #GtkSourceFile at construction time.
The newline type.
An error code used with the %GTK_SOURCE_FILE_SAVER_ERROR domain.
The buffer contains invalid
characters.
The file is externally
modified.
Flags to define the behavior of a [flags@FileSaverFlags].
No flags.
Ignore invalid characters.
Save file despite external modifications.
Create a backup before saving the file.
Gutter object for [class@View].
The `GtkSourceGutter` object represents the left or right gutter of the text
view. It is used by [class@View] to draw the line numbers and
[class@Mark]s that might be present on a line. By packing
additional [class@GutterRenderer] objects in the gutter, you can extend the
gutter with your own custom drawings.
To get a `GtkSourceGutter`, use the [method@View.get_gutter] function.
The gutter works very much the same way as cells rendered in a [class@Gtk.TreeView].
The concept is similar, with the exception that the gutter does not have an
underlying [iface@Gtk.TreeModel]. The builtin line number renderer is at position
%GTK_SOURCE_VIEW_GUTTER_POSITION_LINES (-30) and the marks renderer is at
%GTK_SOURCE_VIEW_GUTTER_POSITION_MARKS (-20). The gutter sorts the renderers
in ascending order, from left to right. So the marks are displayed on the
right of the line numbers.
the associated #GtkSourceView.
a #GtkSourceGutter.
Insert @renderer into the gutter. If @renderer is yet unowned then gutter
claims its ownership. Otherwise just increases renderer's reference count.
@renderer cannot be already inserted to another gutter.
%TRUE if operation succeeded. Otherwise %FALSE.
a #GtkSourceGutter.
a gutter renderer (must inherit from #GtkSourceGutterRenderer).
the renderer position.
Reorders @renderer in @gutter to new @position.
a #GtkSourceGutterRenderer.
a #GtkCellRenderer.
the new renderer position.
The #GtkSourceView of the gutter.
The text window type on which the window is placed.
Collected information about visible lines.
The `GtkSourceGutterLines` object is used to collect information about
visible lines.
Use this from your [signal@GutterRenderer::query-data] to collect the
necessary information on visible lines. Doing so reduces the number of
passes through the text btree allowing GtkSourceView to reach more
frames-per-second while performing kinetic scrolling.
Adds the class @name to @line.
@name will be converted to a [alias@GLib.Quark] as part of this process. A
faster version of this function is available via
[method@GutterLines.add_qclass] for situations where the [alias@GLib.Quark] is
known ahead of time.
a #GtkSourceGutterLines
a line number starting from zero
a class name
Adds the class denoted by @qname to @line.
You may check if a line has @qname by calling
[method@GutterLines.has_qclass].
You can remove @qname by calling
[method@GutterLines.remove_qclass].
a #GtkSourceGutterLines
a line number starting from zero
a class name as a #GQuark
Gets the [class@Gtk.TextBuffer] that the `GtkSourceGutterLines` represents.
a #GtkTextBuffer
a #GtkSourceGutterLines
Gets the line number (starting from 0) for the first line that is
user visible.
a line number starting from 0
a #GtkSourceGutterLines
Gets a #GtkTextIter for the current buffer at @line
a #GtkSourceGutterLines
a location for a #GtkTextIter
the line number
Gets the line number (starting from 0) for the last line that is
user visible.
a line number starting from 0
a #GtkSourceGutterLines
Gets the Y range for a line based on @mode.
The value for @y is relative to the renderers widget coordinates.
a #GtkSourceGutterLines
a line number starting from zero
a #GtkSourceGutterRendererAlignmentMode
a location for the Y position in widget coordinates
the line height based on @mode
Gets the [class@Gtk.TextView] that the `GtkSourceGutterLines` represents.
a #GtkTextView
a #GtkSourceGutterLines
Checks to see if the line has any GQuark classes set. This can be
used to help renderer implementations avoid work if nothing has
been set on the class.
%TRUE if any quark was set for the line
a #GtkSourceGutterLines
a line contained within @lines
Checks to see if [method@GutterLines.add_class] was called with
the @name for @line.
A faster version of this function is provided via
[method@GutterLines.has_qclass] for situations where the quark
is known ahead of time.
%TRUE if @line contains @name
a #GtkSourceGutterLines
a line number starting from zero
a class name that may be converted, to a #GQuark
Checks to see if [method@GutterLines.add_qclass] was called with
the quark denoted by @qname for @line.
%TRUE if @line contains @qname
a #GtkSourceGutterLines
a line number starting from zero
a #GQuark containing the class name
Checks to see if @line contains the insertion cursor.
%TRUE if the insertion cursor is on @line
a #GtkSourceGutterLines
a line number starting from zero
Checks to see if @line is marked as prelit. Generally, this means
the mouse pointer is over the line within the gutter.
%TRUE if the line is prelit
a #GtkSourceGutterLines
a line number starting from zero
Checks to see if the view had a selection and if that selection overlaps
@line in some way.
%TRUE if the line contains a selection
a #GtkSourceGutterLines
a line number starting from zero
Removes the class matching @name from @line.
A faster version of this function is available via
[method@GutterLines.remove_qclass] for situations where the
#GQuark is known ahead of time.
a #GtkSourceGutterLines
a line number starting from zero
a class name
Reverses a call to [method@GutterLines.add_qclass] by removing
the [alias@GLib.Quark] matching @qname.
a #GtkSourceGutterLines
a line number starting from zero
a #GQuark to remove from @line
Gutter cell renderer.
A `GtkSourceGutterRenderer` represents a column in a [class@Gutter]. The
column contains one cell for each visible line of the [class@Gtk.TextBuffer]. Due to
text wrapping, a cell can thus span multiple lines of the [class@Gtk.TextView]. In
this case, [enum@GutterRendererAlignmentMode] controls the alignment of
the cell.
The gutter renderer is a [class@Gtk.Widget] and is measured using the normal widget
measurement facilities. The width of the gutter will be determined by the
measurements of the gutter renderers.
The width of a gutter renderer generally takes into account the entire text
buffer. For instance, to display the line numbers, if the buffer contains 100
lines, the gutter renderer will always set its width such as three digits can
be printed, even if only the first 20 lines are shown. Another strategy is to
take into account only the visible lines. In this case, only two digits are
necessary to display the line numbers of the first 20 lines. To take another
example, the gutter renderer for [class@Mark]s doesn't need to take
into account the text buffer to announce its width. It only depends on the
icons size displayed in the gutter column.
When the available size to render a cell is greater than the required size to
render the cell contents, the cell contents can be aligned horizontally and
vertically with [method@GutterRenderer.set_alignment_mode].
The cells rendering occurs using [vfunc@Gtk.Widget.snapshot]. Implementations
should use `gtk_source_gutter_renderer_get_lines()` to retrieve information
about the lines to be rendered. To help with aligning content which takes
into account the padding and alignment of a cell, implementations may call
[method@GutterRenderer.align_cell] for a given line number with the
width and height measurement of the content they width to render.
Emits the [signal@GutterRenderer::activate] signal of the renderer. This is
called from [class@Gutter] and should never have to be called manually.
a #GtkSourceGutterRenderer
a #GtkTextIter at the start of the line where the renderer is activated
a #GdkRectangle of the cell area where the renderer is activated
the button that was pressed
a #GdkModifierType
the number of button presses
This is called when the text buffer changes for @renderer.
a #GtkSourceGutterRenderer.
the old #GtkTextBuffer.
This is called when the text view changes for @renderer.
a #GtkSourceGutterRenderer.
the old #GtkTextView.
Get whether the renderer is activatable at the location provided. This is
called from [class@Gutter] to determine whether a renderer is activatable
using the mouse pointer.
%TRUE if the renderer can be activated, %FALSE otherwise
a #GtkSourceGutterRenderer
a #GtkTextIter at the start of the line to be activated
a #GdkRectangle of the cell area to be activated
Emits the [signal@GutterRenderer::activate] signal of the renderer. This is
called from [class@Gutter] and should never have to be called manually.
a #GtkSourceGutterRenderer
a #GtkTextIter at the start of the line where the renderer is activated
a #GdkRectangle of the cell area where the renderer is activated
the button that was pressed
a #GdkModifierType
the number of button presses
Locates where to render content that is @width x @height based on
the renderers alignment and padding.
The location will be placed into @x and @y and is relative to the
renderer's coordinates.
It is encouraged that renderers use this function when snappshotting
to ensure consistent placement of their contents.
the #GtkSourceGutterRenderer
the line number for content
the width of the content to draw
the height of the content to draw
the X position to render the content
the Y position to render the content
Get the alignment mode.
The alignment mode describes the manner in which the
renderer is aligned (see [property@GutterRenderer:xalign] and
[property@GutterRenderer:yalign]).
a #GtkSourceGutterRendererAlignmentMode
a #GtkSourceGutterRenderer
Gets the [class@Buffer] for which the gutter renderer is drawing.
a #GtkTextBuffer or %NULL
a #GtkSourceGutterRenderer
Get the view associated to the gutter renderer
a #GtkSourceView
a #GtkSourceGutterRenderer
Gets the `xalign` property.
This may be used to adjust where within the cell rectangle the renderer will draw.
a #GtkSourceGutterRenderer
Gets the `xpad` property.
This may be used to adjust the cell rectangle that the renderer will use to draw.
a #GtkSourceGutterRenderer
Gets the `yalign` property.
This may be used to adjust where within the cell rectangle the renderer will draw.
a #GtkSourceGutterRenderer
Gets the `ypad` property.
This may be used to adjust the cell rectangle that the renderer will use to draw.
a #GtkSourceGutterRenderer
Get whether the renderer is activatable at the location provided. This is
called from [class@Gutter] to determine whether a renderer is activatable
using the mouse pointer.
%TRUE if the renderer can be activated, %FALSE otherwise
a #GtkSourceGutterRenderer
a #GtkTextIter at the start of the line to be activated
a #GdkRectangle of the cell area to be activated
Set the alignment mode. The alignment mode describes the manner in which the
renderer is aligned (see [property@GutterRenderer:xalign] and
[property@GutterRenderer:yalign]).
a #GtkSourceGutterRenderer
a #GtkSourceGutterRendererAlignmentMode
Adjusts the `xalign` property.
This may be used to adjust where within the cell rectangle the renderer will draw.
a #GtkSourceGutterRenderer
the Y padding for the drawing cell
Adjusts the `xpad` property.
This may be used to adjust the cell rectangle that the renderer will use to draw.
a #GtkSourceGutterRenderer
the Y padding for the drawing cell
Adjusts the `yalign` property.
This may be used to adjust where within the cell rectangle the renderer will draw.
a #GtkSourceGutterRenderer
the Y padding for the drawing cell
Adjusts the `ypad` property.
This may be used to adjust the cell rectangle that the renderer will use to draw.
a #GtkSourceGutterRenderer
the Y padding for the drawing cell
The alignment mode of the renderer.
This can be used to indicate that in the case a cell spans multiple lines (due to text wrapping)
the alignment should work on either the full cell, the first line or the last line.
Contains information about the lines to be rendered.
It should be used by #GtkSourceGutterRenderer implementations from [vfunc@Gtk.Widget.snapshot].
The view on which the renderer is placed.
The horizontal alignment of the renderer.
Set to 0 for a left alignment. 1 for a right alignment. And 0.5 for centering the cells.
A value lower than 0 doesn't modify the alignment.
The left and right padding of the renderer.
The vertical alignment of the renderer.
Set to 0 for a top alignment. 1 for a bottom alignment. And 0.5 for centering the cells.
A value lower than 0 doesn't modify the alignment.
The top and bottom padding of the renderer.
The signal is emitted when the renderer is activated.
a #GtkTextIter
a #GdkRectangle
the button that was pressed
a #GdkModifierType of state
the number of button presses
The signal is emitted when the renderer can possibly be activated.
a #GtkTextIter
a #GdkRectangle
The alignment mode of the renderer, when a cell spans multiple lines (due to
text wrapping).
The full cell.
The first line.
The last line.
a #GtkSourceGutterRenderer.
the old #GtkTextView.
a #GtkSourceGutterRenderer.
the old #GtkTextBuffer.
%TRUE if the renderer can be activated, %FALSE otherwise
a #GtkSourceGutterRenderer
a #GtkTextIter at the start of the line to be activated
a #GdkRectangle of the cell area to be activated
a #GtkSourceGutterRenderer
a #GtkTextIter at the start of the line where the renderer is activated
a #GdkRectangle of the cell area where the renderer is activated
the button that was pressed
a #GdkModifierType
the number of button presses
Renders a pixbuf in the gutter.
A `GtkSourceGutterRendererPixbuf` can be used to render an image in a cell of
[class@Gutter].
Create a new #GtkSourceGutterRendererPixbuf.
A #GtkSourceGutterRenderer
Get the gicon of the renderer
a #GIcon
a #GtkSourceGutterRendererPixbuf
Gets a [iface@Gdk.Paintable] that was set with
[method@GutterRendererPixbuf.set_paintable]
a #GdkPaintable or %NULL
a #GtkSourceGutterRendererPixbuf
Get the pixbuf of the renderer.
a #GdkPixbuf
a #GtkSourceGutterRendererPixbuf
Allows overlaying a paintable on top of any other image that
has been set for the pixbuf. This will be applied when the
widget is next snapshot.
a #GtkSourceGutterRendererPixbuf
a #GdkPaintable
a #GtkSourceGutterRendererPixbuf
the icon, or %NULL.
a #GtkSourceGutterRendererPixbuf
the icon name, or %NULL.
a #GtkSourceGutterRendererPixbuf
the paintable, or %NULL.
a #GtkSourceGutterRendererPixbuf
the pixbuf, or %NULL.
Renders text in the gutter.
A `GtkSourceGutterRendererText` can be used to render text in a cell of
[class@Gutter].
Create a new #GtkSourceGutterRendererText.
A #GtkSourceGutterRenderer
Measures the text provided using the pango layout used by the
#GtkSourceGutterRendererText.
a #GtkSourceGutterRendererText.
the text to measure.
location to store the width of the text in pixels,
or %NULL.
location to store the height of the text in
pixels, or %NULL.
Measures the pango markup provided using the pango layout used by the
#GtkSourceGutterRendererText.
a #GtkSourceGutterRendererText.
the pango markup to measure.
location to store the width of the text in pixels,
or %NULL.
location to store the height of the text in
pixels, or %NULL.
Interactive tooltips.
`GtkSourceHover` allows a [class@View] to provide contextual information.
When enabled, if the user hovers over a word in the text editor, a series
of registered [iface@HoverProvider] can populate a [class@HoverDisplay]
with useful information.
To enable call [method@View.get_hover] and add [iface@HoverProvider]
using [method@Hover.add_provider]. To disable, remove all registered
providers with [method@Hover.remove_provider].
You can change how long to wait to display the interactive tooltip by
setting the [property@Hover:hover-delay] property in milliseconds.
Contains the number of milliseconds to delay before showing the hover assistant.
Context for populating [class@HoverDisplay] contents.
`GtkSourceHoverContext` contains information about the request to populate
contents for a [class@HoverDisplay].
It can be used to retrieve the [class@View], [class@Buffer], and
[struct@Gtk.TextIter] for the regions of text which are being displayed.
Use [method@HoverContext.get_bounds] to get the word that was
requested. [method@HoverContext.get_iter] will get you the location
of the pointer when the request was made.
Gets the current word bounds of the hover.
If @begin is non-%NULL, it will be set to the start position of the
current word being hovered.
If @end is non-%NULL, it will be set to the end position for the
current word being hovered.
%TRUE if the marks are still valid and @begin or @end was set.
an #GtkSourceHoverContext
a #GtkTextIter
a #GtkTextIter
A convenience function to get the buffer.
The #GtkSourceBuffer for the view
a #GtkSourceHoverContext
the #GtkSourceView that owns the context
a #GtkSourceHoverContext
Display for interactive tooltips.
`GtkSourceHoverDisplay` is a [class@Gtk.Widget] that may be populated with widgets
to be displayed to the user in interactive tooltips. The children widgets
are packed vertically using a [class@Gtk.Box].
Implement the [iface@HoverProvider] interface to be notified of when
to populate a `GtkSourceHoverDisplay` on behalf of the user.
Interface to populate interactive tooltips.
`GtkSourceHoverProvider` is an interface that should be implemented to extend
the contents of a [class@HoverDisplay]. This is typical in editors that
interact external tooling such as those utilizing Language Server Protocol.
If you can populate the [class@HoverDisplay] synchronously, use
[vfunc@HoverProvider.populate]. Otherwise, interface implementations that
may take additional time should use [vfunc@HoverProvider.populate_async]
to avoid blocking the main loop.
Auto-indentation interface.
By default, [class@View] can auto-indent as you type when
[property@View:auto-indent] is enabled. The indentation simply copies the
previous lines indentation.
This can be changed by implementing `GtkSourceIndenter` and setting the
[property@View:indenter] property.
Implementors of this interface should implement both
[vfunc@Indenter.is_trigger] and [vfunc@Indenter.indent].
[vfunc@Indenter.is_trigger] is called upon key-press to
determine of the key press should trigger an indentation. The default
implementation of the interface checks to see if the key was
[const@Gdk.KEY_Return] or [const@Gdk.KEY_KP_Enter] without %GDK_SHIFT_MASK set.
[vfunc@Indenter.indent] is called after text has been
inserted into [class@Buffer] when
[vfunc@Indenter.is_trigger] returned %TRUE. The [struct@Gtk.TextIter]
is placed directly after the inserted character or characters.
It may be beneficial to move the insertion mark using
[method@Gtk.TextBuffer.select_range] depending on how the indenter changes
the indentation.
All changes are encapsulated within a single user action so that the
user may undo them using standard undo/redo accelerators.
This function should be implemented to alter the indentation of text
within the view.
@view is provided so that the indenter may retrieve settings such as indentation and tab widths.
@iter is the location where the indentation was requested. This typically
is after having just inserted a newline (\n) character but can be other
situations such as a manually requested indentation or reformatting.
See [iface@Indenter.is_trigger] for how to trigger indentation on
various characters inserted into the buffer.
The implementor of this function is expected to keep @iter valid across
calls to the function and should contain the location of the insert mark
after calling this function.
The default implementation for this virtual function will copy the
indentation of the previous line.
a #GtkSourceIndenter
a #GtkSourceView
the location of the indentation request
This function is used to determine if a key pressed should cause the
indenter to automatically indent.
The default implementation of this virtual method will check to see
if @keyval is [const@Gdk.KEY_Return] or [const@Gdk.KEY_KP_Enter] and @state does
not have %GDK_SHIFT_MASK set. This is to allow the user to avoid
indentation when Shift+Return is pressed. Other indenters may want
to copy this behavior to provide a consistent experience to users.
%TRUE if indentation should be automatically triggered;
otherwise %FALSE and no indentation will be performed.
a #GtkSourceIndenter
a #GtkSourceView
the location where @ch is to be inserted
modifier state for the insertion
the keyval pressed such as [const@Gdk.KEY_Return]
This function should be implemented to alter the indentation of text
within the view.
@view is provided so that the indenter may retrieve settings such as indentation and tab widths.
@iter is the location where the indentation was requested. This typically
is after having just inserted a newline (\n) character but can be other
situations such as a manually requested indentation or reformatting.
See [iface@Indenter.is_trigger] for how to trigger indentation on
various characters inserted into the buffer.
The implementor of this function is expected to keep @iter valid across
calls to the function and should contain the location of the insert mark
after calling this function.
The default implementation for this virtual function will copy the
indentation of the previous line.
a #GtkSourceIndenter
a #GtkSourceView
the location of the indentation request
This function is used to determine if a key pressed should cause the
indenter to automatically indent.
The default implementation of this virtual method will check to see
if @keyval is [const@Gdk.KEY_Return] or [const@Gdk.KEY_KP_Enter] and @state does
not have %GDK_SHIFT_MASK set. This is to allow the user to avoid
indentation when Shift+Return is pressed. Other indenters may want
to copy this behavior to provide a consistent experience to users.
%TRUE if indentation should be automatically triggered;
otherwise %FALSE and no indentation will be performed.
a #GtkSourceIndenter
a #GtkSourceView
the location where @ch is to be inserted
modifier state for the insertion
the keyval pressed such as [const@Gdk.KEY_Return]
The virtual function table for #GtkSourceIndenter.
the virtual function pointer for gtk_source_indenter_is_trigger()
%TRUE if indentation should be automatically triggered;
otherwise %FALSE and no indentation will be performed.
a #GtkSourceIndenter
a #GtkSourceView
the location where @ch is to be inserted
modifier state for the insertion
the keyval pressed such as [const@Gdk.KEY_Return]
the virtual function pointer for gtk_source_indenter_indent()
a #GtkSourceIndenter
a #GtkSourceView
the location of the indentation request
Represents a syntax highlighted language.
A `GtkSourceLanguage` represents a programming or markup language, affecting
syntax highlighting and [context classes](./class.Buffer.html#context-classes).
Use [class@LanguageManager] to obtain a `GtkSourceLanguage` instance, and
[method@Buffer.set_language] to apply it to a [class@Buffer].
Returns the globs associated to this language.
This is just an utility wrapper around [method@Language.get_metadata] to
retrieve the "globs" metadata property and split it into an array.
a newly-allocated %NULL terminated array containing the globs or %NULL
if no globs are found.
The returned array must be freed with g_strfreev().
a #GtkSourceLanguage.
Returns whether the language should be hidden from the user.
%TRUE if the language should be hidden, %FALSE otherwise.
a #GtkSourceLanguage
Returns the ID of the language.
The ID is not locale-dependent.The returned string is owned by @language
and should not be freed or modified.
the ID of @language.
a #GtkSourceLanguage.
value of property @name stored in
the metadata of @language or %NULL if language does not contain the
specified metadata property.
The returned string is owned by @language and should not be freed
or modified.
a #GtkSourceLanguage.
metadata property name.
Returns the mime types associated to this language.
This is just an utility wrapper around [method@Language.get_metadata] to
retrieve the "mimetypes" metadata property and split it into an
array.
a newly-allocated %NULL terminated array containing the mime types
or %NULL if no mime types are found.
The returned array must be freed with g_strfreev().
a #GtkSourceLanguage.
Returns the localized name of the language.
The returned string is owned by @language and should not be freed
or modified.
the name of @language.
a #GtkSourceLanguage.
Returns the localized section of the language.
Each language belong to a section (ex. HTML belongs to the
Markup section).
The returned string is owned by @language and should not be freed
or modified.
the section of @language.
a #GtkSourceLanguage.
Returns the ID of the style to use if the specified @style_id
is not present in the current style scheme.
the ID of the style to use if the
specified @style_id is not present in the current style scheme or %NULL
if the style has no fallback defined.
The returned string is owned by the @language and must not be modified.
a #GtkSourceLanguage.
a style ID.
Returns the ids of the styles defined by this @language.
a newly-allocated %NULL terminated array containing ids of the
styles defined by this @language or %NULL if no style is defined.
The returned array must be freed with g_strfreev().
a #GtkSourceLanguage.
Returns the name of the style with ID @style_id defined by this @language.
the name of the style with ID @style_id
defined by this @language or %NULL if the style has no name or there is no
style with ID @style_id defined by this @language.
The returned string is owned by the @language and must not be modified.
a #GtkSourceLanguage.
a style ID.
Provides access to [class@Language]s.
`GtkSourceLanguageManager` is an object which processes language description
files and creates and stores [class@Language] objects, and provides API to
access them.
Use [func@LanguageManager.get_default] to retrieve the default
instance of `GtkSourceLanguageManager`, and
[method@LanguageManager.guess_language] to get a [class@Language] for
given file name and content type.
Creates a new language manager.
If you do not need more than one language manager or a private language manager
instance then use [func@LanguageManager.get_default] instead.
a new #GtkSourceLanguageManager.
Returns the default #GtkSourceLanguageManager instance.
a #GtkSourceLanguageManager.
Return value is owned by GtkSourceView library and must not be unref'ed.
Appends @path to the list of directories where the @manager looks for
language files.
See [method@LanguageManager.set_search_path] for details.
a #GtkSourceLanguageManager.
a directory or a filename.
Gets the [class@Language] identified by the given @id in the language
manager.
a #GtkSourceLanguage, or %NULL
if there is no language identified by the given @id. Return value is
owned by @lm and should not be freed.
a #GtkSourceLanguageManager.
a language id.
Returns the ids of the available languages.
a %NULL-terminated array of strings containing the ids of the available
languages or %NULL if no language is available.
The array is sorted alphabetically according to the language name.
The array is owned by @lm and must not be modified.
a #GtkSourceLanguageManager.
Gets the list directories where @lm looks for language files.
%NULL-terminated array
containing a list of language files directories.
The array is owned by @lm and must not be modified.
a #GtkSourceLanguageManager.
Picks a [class@Language] for given file name and content type,
according to the information in lang files.
Either @filename or @content_type may be %NULL. This function can be used as follows:
```c
GtkSourceLanguage *lang;
GtkSourceLanguageManager *manager;
lm = gtk_source_language_manager_get_default ();
lang = gtk_source_language_manager_guess_language (manager, filename, NULL);
gtk_source_buffer_set_language (buffer, lang);
```
or
```c
GtkSourceLanguage *lang = NULL;
GtkSourceLanguageManager *manager;
gboolean result_uncertain;
gchar *content_type;
content_type = g_content_type_guess (filename, NULL, 0, &result_uncertain);
if (result_uncertain)
{
g_free (content_type);
content_type = NULL;
}
manager = gtk_source_language_manager_get_default ();
lang = gtk_source_language_manager_guess_language (manager, filename, content_type);
gtk_source_buffer_set_language (buffer, lang);
g_free (content_type);
```
etc. Use [method@Language.get_mime_types] and [method@Language.get_globs]
if you need full control over file -> language mapping.
a #GtkSourceLanguage, or %NULL if there
is no suitable language for given @filename and/or @content_type. Return
value is owned by @lm and should not be freed.
a #GtkSourceLanguageManager.
a filename in Glib filename encoding, or %NULL.
a content type (as in GIO API), or %NULL.
Prepends @path to the list of directories where the @manager looks
for language files.
See [method@LanguageManager.set_search_path] for details.
a #GtkSourceLanguageManager.
a directory or a filename.
Sets the list of directories where the @lm looks for
language files.
If @dirs is %NULL, the search path is reset to default.
At the moment this function can be called only before the
language files are loaded for the first time. In practice
to set a custom search path for a `GtkSourceLanguageManager`,
you have to call this function right after creating it.
Since GtkSourceView 5.4 this function will allow you to provide
paths in the form of "resource:///" URIs to embedded `GResource`s.
They must contain the path of a directory within the `GResource`.
a #GtkSourceLanguageManager.
a %NULL-terminated array of
strings or %NULL.
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.
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.
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.
Widget that displays a map for a specific [class@View].
`GtkSourceMap` is a widget that maps the content of a [class@View] into
a smaller view so the user can have a quick overview of the whole document.
This works by connecting a [class@View] to to the `GtkSourceMap` using
the [property@Map:view] property or [method@Map.set_view].
`GtkSourceMap` is a [class@View] object. This means that you can add a
[class@GutterRenderer] to a gutter in the same way you would for a
[class@View]. One example might be a [class@GutterRenderer] that shows
which lines have changed in the document.
Additionally, it is desirable to match the font of the `GtkSourceMap` and
the [class@View] used for editing. Therefore, [property@Map:font-desc]
should be used to set the target font. You will need to adjust this to the
desired font size for the map. A 1pt font generally seems to be an
appropriate font size. "Monospace 1" is the default. See
[method@Pango.FontDescription.set_size] for how to alter the size of an existing
[struct@Pango.FontDescription].
When FontConfig is available, `GtkSourceMap` will try to use a bundled
"block" font to make the map more legible.
Creates a new `GtkSourceMap`.
a new #GtkSourceMap.
Gets the [property@Map:view] property, which is the view this widget is mapping.
a #GtkSourceView or %NULL.
a #GtkSourceMap.
Sets the view that @map will be doing the mapping to.
a #GtkSourceMap
a #GtkSourceView
Mark object for [class@Buffer].
A `GtkSourceMark` marks a position in the text where you want to display
additional info. It is based on [class@Gtk.TextMark] and thus is still valid after
the text has changed though its position may change.
`GtkSourceMark`s are organized in categories which you have to set
when you create the mark. Each category can have a priority, a pixbuf and
other associated attributes. See [method@View.set_mark_attributes].
The pixbuf will be displayed in the margin at the line where the mark
residents if the [property@View:show-line-marks] property is set to %TRUE. If
there are multiple marks in the same line, the pixbufs will be drawn on top
of each other. The mark with the highest priority will be drawn on top.
Creates a text mark.
Add it to a buffer using [method@Gtk.TextBuffer.add_mark].
If name is NULL, the mark is anonymous; otherwise, the mark can be retrieved
by name using [method@Gtk.TextBuffer.get_mark].
Normally marks are created using the utility function
[method@Buffer.create_source_mark].
a new #GtkSourceMark that can be added using [method@Gtk.TextBuffer.add_mark].
Name of the #GtkSourceMark or %NULL
is used to classify marks according to common characteristics
(e.g. all the marks representing a bookmark could belong to the "bookmark"
category, or all the marks representing a compilation error could belong
to "error" category).
Returns the mark category.
the category of the #GtkSourceMark.
a #GtkSourceMark.
Returns the next `GtkSourceMark` in the buffer or %NULL if the mark
was not added to a buffer.
If there is no next mark, %NULL will be returned.
If @category is %NULL, looks for marks of any category.
the next #GtkSourceMark, or %NULL.
a #GtkSourceMark.
a string specifying the mark category, or %NULL.
Returns the previous `GtkSourceMark` in the buffer or %NULL if the mark
was not added to a buffer.
If there is no previous mark, %NULL is returned.
If @category is %NULL, looks for marks of any category
the previous #GtkSourceMark, or %NULL.
a #GtkSourceMark.
a string specifying the mark category, or %NULL.
The category of the `GtkSourceMark`, classifies the mark and controls
which pixbuf is used and with which priority it is drawn.
The source mark attributes object.
`GtkSourceMarkAttributes` is an object specifying attributes used by
a [class@View] to visually show lines marked with [class@Mark]s
of a specific category. It allows you to define a background color of a line,
an icon shown in gutter and tooltips.
The background color is used as a background of a line where a mark is placed
and it can be set with [method@MarkAttributes.set_background]. To check
if any custom background color was defined and what color it is, use
[method@MarkAttributes.get_background].
An icon is a graphic element which is shown in the gutter of a view. An
example use is showing a red filled circle in a debugger to show that a
breakpoint was set in certain line. To get an icon that will be placed in
a gutter, first a base for it must be specified and then
[method@MarkAttributes.render_icon] must be called.
There are several ways to specify a base for an icon:
- [method@MarkAttributes.set_icon_name]
- [method@MarkAttributes.set_gicon]
- [method@MarkAttributes.set_pixbuf]
Using any of the above functions overrides the one used earlier. But note
that a getter counterpart of earlier used function can still return some
value, but it is just not used when rendering the proper icon.
To provide meaningful tooltips for a given mark of a category, you should
connect to [signal@MarkAttributes::query-tooltip-text] or
[signal@MarkAttributes::query-tooltip-markup] where the latter
takes precedence.
Creates a new source mark attributes.
a new source mark attributes.
Stores background color in @background.
whether background color for @attributes was set.
a #GtkSourceMarkAttributes.
a #GdkRGBA.
Gets a [iface@Gio.Icon] to be used as a base for rendered icon.
Note that the icon can be %NULL if it wasn't set earlier.
An icon. The icon belongs to @attributes and should
not be unreffed.
a #GtkSourceMarkAttributes.
Gets a name of an icon to be used as a base for rendered icon.
Note that the icon name can be %NULL if it wasn't set earlier.
An icon name. The string belongs to @attributes and
should not be freed.
a #GtkSourceMarkAttributes.
Gets a [class@GdkPixbuf.Pixbuf] to be used as a base for rendered icon.
Note that the pixbuf can be %NULL if it wasn't set earlier.
A pixbuf. The pixbuf belongs to @attributes and
should not be unreffed.
a #GtkSourceMarkAttributes.
Queries for a tooltip by emitting a [signal@MarkAttributes::query-tooltip-markup] signal.
The tooltip may contain a markup.
A tooltip. The returned string should be freed by
using g_free() when done with it.
a #GtkSourceMarkAttributes.
a #GtkSourceMark.
Queries for a tooltip by emitting a [signal@MarkAttributes::query-tooltip-text] signal.
The tooltip is a plain text.
A tooltip. The returned string should be freed by
using g_free() when done with it.
a #GtkSourceMarkAttributes.
a #GtkSourceMark.
Renders an icon of given size.
The base of the icon is set by the last call to one of:
- [method@MarkAttributes.set_pixbuf]
- [method@MarkAttributes.set_gicon]
- [method@MarkAttributes.set_icon_name]
@size cannot be lower than 1.
A #GdkPaintable. The paintable belongs to @attributes
and should not be unreffed.
a #GtkSourceMarkAttributes.
widget of which style settings may be used.
size of the rendered icon.
Sets background color to the one given in @background.
a #GtkSourceMarkAttributes.
a #GdkRGBA.
Sets an icon to be used as a base for rendered icon.
a #GtkSourceMarkAttributes.
a #GIcon to be used.
Sets a name of an icon to be used as a base for rendered icon.
a #GtkSourceMarkAttributes.
name of an icon to be used.
Sets a pixbuf to be used as a base for rendered icon.
a #GtkSourceMarkAttributes.
a #GdkPixbuf to be used.
A color used for background of a line.
A #GIcon that may be a base of a rendered icon.
An icon name that may be a base of a rendered icon.
A #GdkPixbuf that may be a base of a rendered icon.
The code should connect to this signal to provide a tooltip for given
@mark. The tooltip can contain a markup.
A tooltip. The string should be freed with
g_free() when done with it.
The #GtkSourceMark.
The code should connect to this signal to provide a tooltip for given
@mark. The tooltip should be just a plain text.
A tooltip. The string should be freed with
g_free() when done with it.
The #GtkSourceMark.
Type definition for a function that will be called to create a
[class@Gio.MountOperation]. This is useful for creating a [class@Gtk.MountOperation].
a #GtkSourceFile.
user data
line feed, used on UNIX.
carriage return, used on Mac.
carriage return followed by a line feed, used
on Windows.
Compose a [class@Buffer] for printing.
The `GtkSourcePrintCompositor` object is used to compose a [class@Buffer]
for printing. You can set various configuration options to customize the
printed output. `GtkSourcePrintCompositor` is designed to be used with the
high-level printing API of gtk+, i.e. [class@Gtk.PrintOperation].
The margins specified in this object are the layout margins: they define the
blank space bordering the printed area of the pages. They must not be
confused with the "print margins", i.e. the parts of the page that the
printer cannot print on, defined in the [class@Gtk.PageSetup] objects. If the
specified layout margins are smaller than the "print margins", the latter
ones are used as a fallback by the `GtkSourcePrintCompositor` object, so that
the printed area is not clipped.
Creates a new print compositor that can be used to print @buffer.
a new print compositor object.
the #GtkSourceBuffer to print.
Creates a new print compositor that can be used to print the buffer
associated with @view.
This constructor sets some configuration properties to make the
printed output match @view as much as possible. The properties set are
[property@PrintCompositor:tab-width], [property@PrintCompositor:highlight-syntax],
[property@PrintCompositor:wrap-mode], [property@PrintCompositor:body-font-name] and
[property@PrintCompositor:print-line-numbers].
a new print compositor object.
a #GtkSourceView to get configuration from.
Draw page @page_nr for printing on the the Cairo context encapsuled in @context.
This method has been designed to be called in the handler of the [signal@Gtk.PrintOperation::draw_page] signal
as shown in the following example:
```c
// Signal handler for the GtkPrintOperation::draw_page signal
static void
draw_page (GtkPrintOperation *operation,
GtkPrintContext *context,
gint page_nr,
gpointer user_data)
{
GtkSourcePrintCompositor *compositor;
compositor = GTK_SOURCE_PRINT_COMPOSITOR (user_data);
gtk_source_print_compositor_draw_page (compositor,
context,
page_nr);
}
```
a #GtkSourcePrintCompositor.
the #GtkPrintContext encapsulating the context information that is required when
drawing the page for printing.
the number of the page to print.
Returns the name of the font used to print the text body.
The returned string must be freed with g_free().
a new string containing the name of the font used to print the
text body.
a #GtkSourcePrintCompositor.
Gets the bottom margin in units of @unit.
the bottom margin.
a #GtkSourcePrintCompositor.
the unit for the return value.
Gets the [class@Buffer] associated with the compositor.
The returned object reference is owned by the compositor object and
should not be unreferenced.
the #GtkSourceBuffer associated with the compositor.
a #GtkSourcePrintCompositor.
Returns the name of the font used to print the page footer.
The returned string must be freed with g_free().
a new string containing the name of the font used to print
the page footer.
a #GtkSourcePrintCompositor.
Returns the name of the font used to print the page header.
The returned string must be freed with g_free().
a new string containing the name of the font used to print
the page header.
a #GtkSourcePrintCompositor.
Determines whether the printed text will be highlighted according to the
buffer rules.
Note that highlighting will happen only if the buffer to print has highlighting activated.
%TRUE if the printed output will be highlighted.
a #GtkSourcePrintCompositor.
Gets the left margin in units of @unit.
the left margin
a #GtkSourcePrintCompositor.
the unit for the return value.
Returns the name of the font used to print line numbers on the left margin.
The returned string must be freed with g_free().
a new string containing the name of the font used to print
line numbers on the left margin.
a #GtkSourcePrintCompositor.
Returns the number of pages in the document or <code>-1</code> if the
document has not been completely paginated.
the number of pages in the document or <code>-1</code> if the
document has not been completely paginated.
a #GtkSourcePrintCompositor.
Returns the current fraction of the document pagination that has been completed.
a fraction from 0.0 to 1.0 inclusive.
a #GtkSourcePrintCompositor.
Determines if a footer is set to be printed for each page.
A footer will be printed if this function returns %TRUE
**and** some format strings have been specified
with [method@PrintCompositor.set_footer_format].
%TRUE if the footer is set to be printed.
a #GtkSourcePrintCompositor.
Determines if a header is set to be printed for each page.
A header will be printed if this function returns %TRUE
**and** some format strings have been specified
with [method@PrintCompositor.set_header_format].
%TRUE if the header is set to be printed.
a #GtkSourcePrintCompositor.
Returns the interval used for line number printing.
If the value is 0, no line numbers will be printed. The default value is
1 (i.e. numbers printed in all lines).
the interval of printed line numbers.
a #GtkSourcePrintCompositor.
Gets the right margin in units of @unit.
the right margin.
a #GtkSourcePrintCompositor.
the unit for the return value.
Returns the width of tabulation in characters for printed text.
width of tab.
a #GtkSourcePrintCompositor.
Gets the top margin in units of @unit.
the top margin.
a #GtkSourcePrintCompositor.
the unit for the return value.
Gets the line wrapping mode for the printed text.
the line wrap mode.
a #GtkSourcePrintCompositor.
Specifies a tag whose style should be ignored when compositing the
document to the printable page.
a #GtkSourcePrintCompositor
a #GtkTextTag
Paginate the document associated with the @compositor.
In order to support non-blocking pagination, document is paginated in small chunks.
Each time [method@PrintCompositor.paginate] is invoked, a chunk of the document
is paginated. To paginate the entire document, [method@PrintCompositor.paginate]
must be invoked multiple times.
It returns %TRUE if the document has been completely paginated, otherwise it returns %FALSE.
This method has been designed to be invoked in the handler of the [signal@Gtk.PrintOperation::paginate] signal,
as shown in the following example:
```c
// Signal handler for the GtkPrintOperation::paginate signal
static gboolean
paginate (GtkPrintOperation *operation,
GtkPrintContext *context,
gpointer user_data)
{
GtkSourcePrintCompositor *compositor;
compositor = GTK_SOURCE_PRINT_COMPOSITOR (user_data);
if (gtk_source_print_compositor_paginate (compositor, context))
{
gint n_pages;
n_pages = gtk_source_print_compositor_get_n_pages (compositor);
gtk_print_operation_set_n_pages (operation, n_pages);
return TRUE;
}
return FALSE;
}
```
If you don't need to do pagination in chunks, you can simply do it all in the
[signal@Gtk.PrintOperation::begin-print] handler, and set the number of pages from there, like
in the following example:
```c
// Signal handler for the GtkPrintOperation::begin-print signal
static void
begin_print (GtkPrintOperation *operation,
GtkPrintContext *context,
gpointer user_data)
{
GtkSourcePrintCompositor *compositor;
gint n_pages;
compositor = GTK_SOURCE_PRINT_COMPOSITOR (user_data);
while (!gtk_source_print_compositor_paginate (compositor, context));
n_pages = gtk_source_print_compositor_get_n_pages (compositor);
gtk_print_operation_set_n_pages (operation, n_pages);
}
```
%TRUE if the document has been completely paginated, %FALSE otherwise.
a #GtkSourcePrintCompositor.
the #GtkPrintContext whose parameters (e.g. paper size, print margins, etc.)
are used by the the @compositor to paginate the document.
Sets the default font for the printed text.
@font_name should be a
string representation of a font description Pango can understand.
(e.g. "Monospace 10"). See [func@Pango.FontDescription.from_string]
for a description of the format of the string representation.
This function cannot be called anymore after the first call to the
[method@PrintCompositor.paginate] function.
a #GtkSourcePrintCompositor.
the name of the default font for the body text.
Sets the bottom margin used by @compositor.
a #GtkSourcePrintCompositor.
the new bottom margin in units of @unit.
the units for @margin.
Sets the font for printing the page footer.
If %NULL is supplied, the default font (i.e. the one being used for the
text) will be used instead.
@font_name should be a
string representation of a font description Pango can understand.
(e.g. "Monospace 10"). See [func@Pango.FontDescription.from_string]
for a description of the format of the string representation.
This function cannot be called anymore after the first call to the
[method@PrintCompositor.paginate] function.
a #GtkSourcePrintCompositor.
the name of the font for the footer text, or %NULL.
See [method@PrintCompositor.set_header_format] for more information
about the parameters.
a #GtkSourcePrintCompositor.
%TRUE if you want a separator line to be printed.
a format string to print on the left of the footer.
a format string to print on the center of the footer.
a format string to print on the right of the footer.
Sets the font for printing the page header.
If %NULL is supplied, the default font (i.e. the one being used for the
text) will be used instead.
@font_name should be a
string representation of a font description Pango can understand.
(e.g. "Monospace 10"). See [func@Pango.FontDescription.from_string]
for a description of the format of the string representation.
This function cannot be called anymore after the first call to the
[method@PrintCompositor.paginate] function.
a #GtkSourcePrintCompositor.
the name of the font for header text, or %NULL.
Sets strftime like header format strings, to be printed on the
left, center and right of the top of each page.
The strings may include strftime(3) codes which will be expanded at print time.
A subset of strftime() codes are accepted, see [method@GLib.DateTime.format]
for more details on the accepted format specifiers.
Additionally the following format specifiers are accepted:
- #N: the page number
- #Q: the page count.
@separator specifies if a solid line should be drawn to separate
the header from the document text.
If %NULL is given for any of the three arguments, that particular
string will not be printed.
For the header to be printed, in
addition to specifying format strings, you need to enable header
printing with [method@PrintCompositor.set_print_header].
This function cannot be called anymore after the first call to the
[method@PrintCompositor.paginate] function.
a #GtkSourcePrintCompositor.
%TRUE if you want a separator line to be printed.
a format string to print on the left of the header.
a format string to print on the center of the header.
a format string to print on the right of the header.
Sets whether the printed text will be highlighted according to the
buffer rules. Both color and font style are applied.
This function cannot be called anymore after the first call to the
[method@PrintCompositor.paginate] function.
a #GtkSourcePrintCompositor.
whether syntax should be highlighted.
Sets the left margin used by @compositor.
a #GtkSourcePrintCompositor.
the new left margin in units of @unit.
the units for @margin.
Sets the font for printing line numbers on the left margin.
If %NULL is supplied, the default font (i.e. the one being used for the
text) will be used instead.
@font_name should be a
string representation of a font description Pango can understand.
(e.g. "Monospace 10"). See [func@Pango.FontDescription.from_string]
for a description of the format of the string representation.
This function cannot be called anymore after the first call to the
[method@PrintCompositor.paginate] function.
a #GtkSourcePrintCompositor.
the name of the font for line numbers, or %NULL.
Sets whether you want to print a footer in each page.
The footer consists of three pieces of text and an optional line
separator, configurable with
[method@PrintCompositor.set_footer_format].
Note that by default the footer format is unspecified, and if it's
empty it will not be printed, regardless of this setting.
This function cannot be called anymore after the first call to the
[method@PrintCompositor.paginate] function.
a #GtkSourcePrintCompositor.
%TRUE if you want the footer to be printed.
Sets whether you want to print a header in each page.
The header consists of three pieces of text and an optional line
separator, configurable with [method@PrintCompositor.set_header_format].
Note that by default the header format is unspecified, and if it's
empty it will not be printed, regardless of this setting.
This function cannot be called anymore after the first call to the
[method@PrintCompositor.paginate] function.
a #GtkSourcePrintCompositor.
%TRUE if you want the header to be printed.
Sets the interval for printed line numbers.
If @interval is 0 no numbers will be printed. If greater than 0, a number will be
printed every @interval lines (i.e. 1 will print all line numbers).
Maximum accepted value for @interval is 100.
This function cannot be called anymore after the first call to the
[method@PrintCompositor.paginate] function.
a #GtkSourcePrintCompositor.
interval for printed line numbers.
Sets the right margin used by @compositor.
a #GtkSourcePrintCompositor.
the new right margin in units of @unit.
the units for @margin.
Sets the width of tabulation in characters for printed text.
This function cannot be called anymore after the first call to the
[method@PrintCompositor.paginate] function.
a #GtkSourcePrintCompositor.
width of tab in characters.
Sets the top margin used by @compositor.
a #GtkSourcePrintCompositor.
the new top margin in units of @unit
the units for @margin
Sets the line wrapping mode for the printed text.
This function cannot be called anymore after the first call to the
[method@PrintCompositor.paginate] function.
a #GtkSourcePrintCompositor.
a #GtkWrapMode.
Name of the font used for the text body.
Accepted values are strings representing a font description Pango can understand.
(e.g. "Monospace 10"). See [func@Pango.FontDescription.from_string]
for a description of the format of the string representation.
The value of this property cannot be changed anymore after the first
call to the [method@PrintCompositor.paginate] function.
The [class@Buffer] object to print.
Name of the font used to print page footer.
If this property is unspecified, the text body font is used.
Accepted values are strings representing a font description Pango can understand.
(e.g. "Monospace 10"). See [func@Pango.FontDescription.from_string]
for a description of the format of the string representation.
The value of this property cannot be changed anymore after the first
call to the [method@PrintCompositor.paginate] function.
Name of the font used to print page header.
If this property is unspecified, the text body font is used.
Accepted values are strings representing a font description Pango can understand.
(e.g. "Monospace 10"). See [func@Pango.FontDescription.from_string]
for a description of the format of the string representation.
The value of this property cannot be changed anymore after the first
call to the [method@PrintCompositor.paginate] function.
Whether to print the document with highlighted syntax.
The value of this property cannot be changed anymore after the first
call to the [method@PrintCompositor.paginate] function.
Name of the font used to print line numbers on the left margin.
If this property is unspecified, the text body font is used.
Accepted values are strings representing a font description Pango can understand.
(e.g. "Monospace 10"). See [func@Pango.FontDescription.from_string]
for a description of the format of the string representation.
The value of this property cannot be changed anymore after the first
call to the [method@PrintCompositor.paginate] function.
The number of pages in the document or <code>-1</code> if the
document has not been completely paginated.
Whether to print a footer in each page.
Note that by default the footer format is unspecified, and if it is
unspecified the footer will not be printed, regardless of the value of
this property.
The value of this property cannot be changed anymore after the first
call to the [method@PrintCompositor.paginate] function.
Whether to print a header in each page.
Note that by default the header format is unspecified, and if it is
unspecified the header will not be printed, regardless of the value of
this property.
The value of this property cannot be changed anymore after the first
call to the [method@PrintCompositor.paginate] function.
Interval of printed line numbers.
If this property is set to 0 no numbers will be printed.
If greater than 0, a number will be printed every "print-line-numbers"
lines (i.e. 1 will print all line numbers).
The value of this property cannot be changed anymore after the first
call to the [method@PrintCompositor.paginate] function.
Width of a tab character expressed in spaces.
The value of this property cannot be changed anymore after the first
call to the [method@PrintCompositor.paginate] function.
Whether to wrap lines never, at word boundaries, or at character boundaries.
The value of this property cannot be changed anymore after the first
call to the [method@PrintCompositor.paginate] function.
Region utility.
A `GtkSourceRegion` permits to store a group of subregions of a
[class@Gtk.TextBuffer]. `GtkSourceRegion` stores the subregions with pairs of
[class@Gtk.TextMark]'s, so the region is still valid after insertions and deletions
in the [class@Gtk.TextBuffer].
The [class@Gtk.TextMark] for the start of a subregion has a left gravity, while the
[class@Gtk.TextMark] for the end of a subregion has a right gravity.
The typical use-case of `GtkSourceRegion` is to scan a [class@Gtk.TextBuffer] chunk by
chunk, not the whole buffer at once to not block the user interface. The
`GtkSourceRegion` represents in that case the remaining region to scan. You
can listen to the [signal@Gtk.TextBuffer::insert-text] and
[signal@Gtk.TextBuffer::delete-range] signals to update the `GtkSourceRegion`
accordingly.
To iterate through the subregions, you need to use a [struct@RegionIter],
for example:
```c
GtkSourceRegion *region;
GtkSourceRegionIter region_iter;
gtk_source_region_get_start_region_iter (region, ®ion_iter);
while (!gtk_source_region_iter_is_end (®ion_iter))
{
GtkTextIter subregion_start;
GtkTextIter subregion_end;
if (!gtk_source_region_iter_get_subregion (®ion_iter,
&subregion_start,
&subregion_end))
{
break;
}
// Do something useful with the subregion.
gtk_source_region_iter_next (®ion_iter);
}
```
a new #GtkSourceRegion object for @buffer.
a #GtkTextBuffer.
Adds @region_to_add to @region.
@region_to_add is not modified.
a #GtkSourceRegion.
the #GtkSourceRegion to add to @region, or %NULL.
Adds the subregion delimited by @_start and @_end to @region.
a #GtkSourceRegion.
the start of the subregion.
the end of the subregion.
Gets the @start and @end bounds of the @region.
%TRUE if @start and @end have been set successfully (if non-%NULL),
or %FALSE if the @region is empty.
a #GtkSourceRegion.
iterator to initialize with the start of @region,
or %NULL.
iterator to initialize with the end of @region,
or %NULL.
the #GtkTextBuffer.
a #GtkSourceRegion.
Initializes a [struct@RegionIter] to the first subregion of @region.
If @region is empty, @iter will be initialized to the end iterator.
a #GtkSourceRegion.
iterator to initialize to the first subregion.
Returns the intersection between @region1 and @region2.
@region1 and @region2 are not modified.
the intersection as a #GtkSourceRegion
object.
a #GtkSourceRegion, or %NULL.
a #GtkSourceRegion, or %NULL.
Returns the intersection between @region and the subregion delimited by
@_start and @_end.
@region is not modified.
the intersection as a new
#GtkSourceRegion.
a #GtkSourceRegion.
the start of the subregion.
the end of the subregion.
Returns whether the @region is empty.
A %NULL @region is considered empty.
whether the @region is empty.
a #GtkSourceRegion, or %NULL.
Subtracts @region_to_subtract from @region.
@region_to_subtract is not modified.
a #GtkSourceRegion.
the #GtkSourceRegion to subtract from
@region, or %NULL.
Subtracts the subregion delimited by @_start and @_end from @region.
a #GtkSourceRegion.
the start of the subregion.
the end of the subregion.
Gets a string represention of @region, for debugging purposes.
The returned string contains the character offsets of the subregions. It
doesn't include a newline character at the end of the string.
a string represention of @region. Free
with g_free() when no longer needed.
a #GtkSourceRegion.
The [class@Gtk.TextBuffer]. The #GtkSourceRegion has a weak reference to the
buffer.
An opaque datatype.
Ignore all its fields and initialize the iter with [method@Region.get_start_region_iter].
Gets the subregion at this iterator.
%TRUE if @start and @end have been set successfully (if non-%NULL),
or %FALSE if @iter is the end iterator or if the region is empty.
a #GtkSourceRegionIter.
iterator to initialize with the subregion start, or %NULL.
iterator to initialize with the subregion end, or %NULL.
whether @iter is the end iterator.
a #GtkSourceRegionIter.
Moves @iter to the next subregion.
%TRUE if @iter moved and is dereferenceable, or %FALSE if @iter has
been set to the end iterator.
a #GtkSourceRegionIter.
This function is called incrementally to process additional background work.
A deadline is provided which can be checked using [func@GLib.get_monotonic_time] so
that additional work can be processed each frame.
This is useful for situations where you are incrementally performing
background work such as spell checking or semantic syntax highlighting.
%TRUE if there is more work to process, otherwise %FALSE and the
handler is unregistered.
the time the callback should complete by
closure data provided when registering callback
Search context.
A `GtkSourceSearchContext` is used for the search and replace in a
[class@Buffer]. The search settings are represented by a
[class@SearchSettings] object. There can be a many-to-many relationship
between buffers and search settings, with the search contexts in-between: a
search settings object can be shared between several search contexts; and a
buffer can contain several search contexts at the same time.
The total number of search occurrences can be retrieved with
[method@SearchContext.get_occurrences_count]. To know the position of a
certain match, use [method@SearchContext.get_occurrence_position].
The buffer is scanned asynchronously, so it doesn't block the user interface.
For each search, the buffer is scanned at most once. After that, navigating
through the occurrences doesn't require to re-scan the buffer entirely.
To search forward, use [method@SearchContext.forward] or
[method@SearchContext.forward_async] for the asynchronous version.
The backward search is done similarly. To replace a search match, or all
matches, use [method@SearchContext.replace] and
[method@SearchContext.replace_all].
The search occurrences are highlighted by default. To disable it, use
[method@SearchContext.set_highlight]. You can enable the search
highlighting for several `GtkSourceSearchContext`s attached to the
same buffer. Moreover, each of those `GtkSourceSearchContext`s can
have a different text style associated. Use
[method@SearchContext.set_match_style] to specify the [class@Style]
to apply on search matches.
Note that the [property@SearchContext:highlight] and
[property@SearchContext:match-style] properties are in the
`GtkSourceSearchContext` class, not [class@SearchSettings]. Appearance
settings should be tied to one, and only one buffer, as different buffers can
have different style scheme associated (a [class@SearchSettings] object
can be bound indirectly to several buffers).
The concept of "current match" doesn't exist yet. A way to highlight
differently the current match is to select it.
A search occurrence's position doesn't depend on the cursor position or other
parameters. Take for instance the buffer "aaaa" with the search text "aa".
The two occurrences are at positions [0:2] and [2:4]. If you begin to search
at position 1, you will get the occurrence [2:4], not [1:3]. This is a
prerequisite for regular expression searches. The pattern ".*" matches the
entire line. If the cursor is at the middle of the line, you don't want the
rest of the line as the occurrence, you want an entire line. (As a side note,
regular expression searches can also match multiple lines.)
In the GtkSourceView source code, there is an example of how to use the
search and replace API: see the tests/test-search.c file. It is a mini
application for the search and replace, with a basic user interface.
Creates a new search context, associated with @buffer, and customized with
@settings.
If @settings is %NULL, a new [class@SearchSettings] object will
be created, that you can retrieve with [method@SearchContext.get_settings].
a new search context.
a #GtkSourceBuffer.
a #GtkSourceSearchSettings, or %NULL.
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.
If the [property@SearchSettings:wrap-around] property is %FALSE, this function
doesn't try to wrap around.
The @has_wrapped_around out parameter is set independently of whether a match
is found. So if this function returns %FALSE, @has_wrapped_around will have
the same value as the [property@SearchSettings:wrap-around] property.
whether a match was found.
a #GtkSourceSearchContext.
start of search.
return location for start of match, or %NULL.
return location for end of match, or %NULL.
return location to know whether the
search has wrapped around, or %NULL.
The asynchronous version of [method@SearchContext.backward].
See the [iface@Gio.AsyncResult] documentation to know how to use this function.
If the operation is cancelled, the @callback will only be called if
@cancellable was not %NULL. The method takes
ownership of @cancellable, so you can unref it after calling this function.
a #GtkSourceSearchContext.
start of search.
a #GCancellable, or %NULL.
a #GAsyncReadyCallback to call when the operation is finished.
the data to pass to the @callback function.
Finishes a backward search started with
[method@SearchContext.backward_async].
See the documentation of [method@SearchContext.backward] for more
details.
whether a match was found.
a #GtkSourceSearchContext.
a #GAsyncResult.
return location for start of match, or %NULL.
return location for end of match, or %NULL.
return location to know whether the
search has wrapped around, or %NULL.
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.
If the [property@SearchSettings:wrap-around] property is %FALSE, this function
doesn't try to wrap around.
The @has_wrapped_around out parameter is set independently of whether a match
is found. So if this function returns %FALSE, @has_wrapped_around will have
the same value as the [property@SearchSettings:wrap-around] property.
whether a match was found.
a #GtkSourceSearchContext.
start of search.
return location for start of match, or %NULL.
return location for end of match, or %NULL.
return location to know whether the
search has wrapped around, or %NULL.
The asynchronous version of [method@SearchContext.forward].
See the [iface@Gio.AsyncResult] documentation to know how to use this function.
If the operation is cancelled, the @callback will only be called if
@cancellable was not %NULL. The method takes
ownership of @cancellable, so you can unref it after calling this function.
a #GtkSourceSearchContext.
start of search.
a #GCancellable, or %NULL.
a #GAsyncReadyCallback to call when the operation is finished.
the data to pass to the @callback function.
Finishes a forward search started with [method@SearchContext.forward_async].
See the documentation of [method@SearchContext.forward] for more
details.
whether a match was found.
a #GtkSourceSearchContext.
a #GAsyncResult.
return location for start of match, or %NULL.
return location for end of match, or %NULL.
return location to know whether the
search has wrapped around, or %NULL.
the associated buffer.
a #GtkSourceSearchContext.
whether to highlight the search occurrences.
a #GtkSourceSearchContext.
the #GtkSourceStyle to apply on search matches.
a #GtkSourceSearchContext.
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.
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.
a #GtkSourceSearchContext.
the start of the occurrence.
the end of the occurrence.
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.
the total number of search occurrences, or -1 if unknown.
a #GtkSourceSearchContext.
Regular expression patterns must follow certain rules. If
[property@SearchSettings:search-text] breaks a rule, the error can be
retrieved with this function.
The error domain is [error@GLib.RegexError].
Free the return value with [method@GLib.Error.free].
the #GError, or %NULL if the
pattern is valid.
a #GtkSourceSearchContext.
the search settings.
a #GtkSourceSearchContext.
Replaces a search match by another text. If @match_start and @match_end
doesn't correspond to a search match, %FALSE is returned.
@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 [func@GLib.Regex.check_replacement]. The @replace text can contain
backreferences.
whether the match has been replaced.
a #GtkSourceSearchContext.
the start of the match to replace.
the end of the match to replace.
the replacement text.
the length of @replace in bytes, or -1.
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 [func@GLib.Regex.check_replacement]. The @replace text can contain
backreferences.
the number of replaced matches.
a #GtkSourceSearchContext.
the replacement text.
the length of @replace in bytes, or -1.
Enables or disables the search occurrences highlighting.
a #GtkSourceSearchContext.
the setting.
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 [method@SearchContext.set_highlight].
a #GtkSourceSearchContext.
a #GtkSourceStyle, or %NULL.
The [class@Buffer] associated to the search context.
Highlight the search occurrences.
A [class@Style], or %NULL for theme's scheme default style.
The total number of search occurrences. If the search is disabled,
the value is 0. If the buffer is not already fully scanned, the value
is -1.
If the regex search pattern doesn't follow all the rules, this
#GError property will be set. If the pattern is valid, the value is
%NULL.
Free with [method@GLib.Error.free].
The [class@SearchSettings] associated to the search context.
This property is construct-only since version 4.0.
Search settings.
A `GtkSourceSearchSettings` object represents the settings of a search. The
search settings can be associated with one or several
[class@SearchContext]s.
Creates a new search settings object.
a new search settings object.
whether to search at word boundaries.
a #GtkSourceSearchSettings.
whether the search is case sensitive.
a #GtkSourceSearchSettings.
whether to search by regular expressions.
a #GtkSourceSearchSettings.
Gets the text to search.
The return value must not be freed.
You may be interested to call [func@utils_escape_search_text] after
this function.
the text to search, or %NULL if the search is disabled.
a #GtkSourceSearchSettings.
whether to exclude invisible text from the search.
a #GtkSourceSearchSettings.
whether to wrap around the search.
a #GtkSourceSearchSettings.
Change whether the search is done at word boundaries.
If @at_word_boundaries is %TRUE, a search match must start and end a word.
The match can span multiple words. See also [method@Gtk.TextIter.starts_word] and
[method@Gtk.TextIter.ends_word].
a #GtkSourceSearchSettings.
the setting.
Enables or disables the case sensitivity for the search.
a #GtkSourceSearchSettings.
the setting.
Enables or disables whether to search by regular expressions.
If enabled, the [property@SearchSettings:search-text] property contains the
pattern of the regular expression.
[class@SearchContext] uses #GRegex when regex search is enabled. See the
[Regular expression syntax](https://developer.gnome.org/glib/stable/glib-regex-syntax.html)
page in the GLib reference manual.
a #GtkSourceSearchSettings.
the setting.
Sets the text to search.
If @search_text is %NULL or is empty, the search will be disabled. A copy of @search_text
will be made, so you can safely free @search_text after a call to this function.
You may be interested to call [func@utils_unescape_search_text] before
this function.
a #GtkSourceSearchSettings.
the nul-terminated text to search, or %NULL to disable the search.
Enables or disables whether to exclude invisible text from the search.
If enabled, only visible text will be searched.
A search match may have invisible text interspersed.
a #GtkSourceSearchSettings.
the setting.
Enables or disables the wrap around search.
If @wrap_around is %TRUE, the forward search continues at the beginning of the buffer
if no search occurrences are found. Similarly, the backward search continues to search at
the end of the buffer.
a #GtkSourceSearchSettings.
the setting.
If %TRUE, a search match must start and end a word. The match can
span multiple words.
Whether the search is case sensitive.
Search by regular expressions with
[property@SearchSettings:search-text] as the pattern.
A search string, or %NULL if the search is disabled.
If the regular expression search is enabled, [property@SearchSettings:search-text] is
the pattern.
Exclude invisible text from the search.
A search match may have invisible text interspersed.
For a forward search, continue at the beginning of the buffer if no
search occurrence is found. For a backward search, continue at the
end of the buffer.
smart-home-end disabled.
move to the first/last
non-whitespace character on the first press of the HOME/END keys and
to the beginning/end of the line on the second press.
move to the beginning/end of the
line on the first press of the HOME/END keys and to the first/last
non-whitespace character on the second press.
always move to the first/last
non-whitespace character when the HOME/END keys are pressed.
Quick insertion code snippets.
The `GtkSourceSnippet` represents a series of chunks that can quickly be
inserted into the [class@View].
Snippets are defined in XML files which are loaded by the
[class@SnippetManager]. Alternatively, applications can create snippets
on demand and insert them into the [class@View] using
[method@View.push_snippet].
Snippet chunks can reference other snippet chunks as well as post-process
the values from other chunks such as capitalization.
Creates a new #GtkSourceSnippet
A new #GtkSourceSnippet
the trigger word
the source language
Parses the snippet formatted @text into a series of chunks and adds them
to a new #GtkSourceSnippet.
the newly parsed #GtkSourceSnippet, or %NULL upon
failure and @error is set.
the formatted snippet text to parse
Appends @chunk to the @snippet.
This may only be called before the snippet has been expanded.
a #GtkSourceSnippet
a #GtkSourceSnippetChunk
Does a deep copy of the snippet.
A new #GtkSourceSnippet
a #GtkSourceSnippet
Gets the context used for expanding the snippet.
an #GtkSourceSnippetContext
an #GtkSourceSnippet
Gets the description for the snippet.
a #GtkSourceSnippet
Gets the current focus for the snippet.
This is changed as the user tabs through focus locations.
The focus position, or -1 if unset.
a #GtkSourceSnippet
Gets the language-id used for the source snippet.
The language identifier should be one that matches a
source language [property@Language:id] property.
the language identifier
a #GtkSourceSnippet
Gets the number of chunks in the snippet.
Note that not all chunks are editable.
The number of chunks.
a #GtkSourceSnippet
Gets the name for the snippet.
a #GtkSourceSnippet
Gets the chunk at @nth.
an #GtkSourceSnippetChunk
a #GtkSourceSnippet
the nth chunk to get
Gets the trigger for the source snippet.
A trigger is a word that can be expanded into the full snippet when
the user presses Tab.
A string or %NULL
a #GtkSourceSnippet
Sets the description for the snippet.
a #GtkSourceSnippet
the snippet description
Sets the language identifier for the snippet.
This should match the [property@Language:id] identifier.
a #GtkSourceSnippet
the language identifier for the snippet
Sets the name for the snippet.
a #GtkSourceSnippet
the snippet name
Sets the trigger for the snippet.
a #GtkSourceSnippet
the trigger word
A chunk of text within the source snippet.
The `GtkSourceSnippetChunk` represents a single chunk of text that
may or may not be an edit point within the snippet. Chunks that are
an edit point (also called a tab stop) have the
[property@SnippetChunk:focus-position] property set.
Create a new `GtkSourceSnippetChunk` that can be added to
a [class@Snippet].
Copies the source snippet.
A #GtkSourceSnippetChunk
a #GtkSourceSnippetChunk
Gets the context for the snippet insertion.
A #GtkSourceSnippetContext
a #GtkSourceSnippetChunk
Gets the [property@SnippetChunk:focus-position].
The focus-position is used to determine how many tabs it takes for the
snippet to advanced to this chunk.
A focus-position of zero will be the last focus position of the snippet
and snippet editing ends when it has been reached.
A focus-position of -1 means the chunk cannot be focused by the user.
the focus-position
a #GtkSourceSnippetChunk
Gets the specification for the chunk.
The specification is evaluated for variables when other chunks are edited
within the snippet context. If the user has changed the text, the
[property@SnippetChunk:text] and [property@SnippetChunk:text-set] properties
are updated.
the specification, if any
a #GtkSourceSnippetChunk
Gets the [property@SnippetChunk:text] property.
The text property is updated when the user edits the text of the chunk.
If it has not been edited, the [property@SnippetChunk:spec] property is
returned.
the text of the chunk
a #GtkSourceSnippetChunk
Gets the [property@SnippetChunk:text-set] property.
This is typically set when the user has edited a snippet chunk.
a #GtkSourceSnippetChunk
Sets the [property@SnippetChunk:focus-position] property.
The focus-position is used to determine how many tabs it takes for the
snippet to advanced to this chunk.
A focus-position of zero will be the last focus position of the snippet
and snippet editing ends when it has been reached.
A focus-position of -1 means the chunk cannot be focused by the user.
a #GtkSourceSnippetChunk
the focus-position
Sets the specification for the chunk.
The specification is evaluated for variables when other chunks are edited
within the snippet context. If the user has changed the text, the
[property@SnippetChunk:text and] [property@SnippetChunk:text-set] properties
are updated.
a #GtkSourceSnippetChunk
the new specification for the chunk
Sets the text for the snippet chunk.
This is usually used by the snippet engine to update the text, but may
be useful when creating custom snippets to avoid expansion of any
specification.
a #GtkSourceSnippetChunk
the text of the property
Sets the [property@SnippetChunk:text-set] property.
This is typically set when the user has edited a snippet chunk by the
snippet engine.
a #GtkSourceSnippetChunk
the property value
Context for expanding [class@SnippetChunk].
This class is currently used primary as a hashtable. However, the longer
term goal is to have it hold onto a `GjsContext` as well as other languages
so that [class@SnippetChunk] can expand themselves by executing
script within the context.
The [class@Snippet] will build the context and then expand each of the
chunks during the insertion/edit phase.
Creates a new #GtkSourceSnippetContext.
Generally, this isn't needed unless you are controlling the
expansion of snippets manually.
a #GtkSourceSnippetContext
Removes all variables from the context.
a #GtkSourceSnippetContext
Gets the current value for a variable named @key.
the value for the variable, or %NULL
a #GtkSourceSnippetContext
the name of the variable
Sets a constatnt within the context.
This is similar to a variable set with [method@SnippetContext.set_variable]
but is expected to not change during use of the snippet.
Examples would be the date or users name.
a #GtkSourceSnippetContext
the constant name
the value of the constant
Sets a variable within the context.
This variable may be overridden by future updates to the
context.
a #GtkSourceSnippetContext
the variable name
the value for the variable
The signal is emitted when a change has been
discovered in one of the chunks of the snippet which has
caused a variable or other dynamic data within the context
to have changed.
Provides access to [class@Snippet].
`GtkSourceSnippetManager` is an object which processes snippet description
files and creates [class@Snippet] objects.
Use [func@SnippetManager.get_default] to retrieve the default
instance of `GtkSourceSnippetManager`.
Use [method@SnippetManager.get_snippet] to retrieve snippets for
a given snippets.
Returns the default #GtkSourceSnippetManager instance.
a #GtkSourceSnippetManager which
is owned by GtkSourceView library and must not be unref'd.
Gets the list directories where @self looks for snippet files.
%NULL-terminated array
containing a list of snippet files directories.
The array is owned by @lm and must not be modified.
a #GtkSourceSnippetManager.
Queries the known snippets for the first matching @group, @language_id,
and/or @trigger.
If @group or @language_id are %NULL, they will be ignored.
a #GtkSourceSnippet or %NULL if no
matching snippet was found.
a #GtkSourceSnippetManager
a group name or %NULL
a #GtkSourceLanguage:id or %NULL
the trigger for the snippet
Gets a [iface@Gio.ListModel] of all snippets.
This can be used to get an unfiltered list of all of the snippets
known to the snippet manager.
a [iface@Gio.ListModel] of [class@GtkSource.Snippet]
a #GtkSourceSnippetManager
List all the known groups within the snippet manager.
The result should be freed with g_free(), and the individual strings are
owned by @self and should never be freed by the caller.
An array of strings which should be freed with g_free().
a #GtkSourceSnippetManager
Queries the known snippets for those matching @group, @language_id, and/or
@trigger_prefix.
If any of these are %NULL, they will be ignored when filtering the available snippets.
The [iface@Gio.ListModel] only contains information about the available snippets until
[method@Gio.ListModel.get_item] is called for a specific snippet. This helps reduce
the number of [class@GObject.Object]'s that are created at runtime to those needed by
the calling application.
a #GListModel of #GtkSourceSnippet.
a #GtkSourceSnippetManager
a group name or %NULL
a #GtkSourceLanguage:id or %NULL
a prefix for a trigger to activate
Sets the list of directories in which the `GtkSourceSnippetManager` looks for
snippet files.
If @dirs is %NULL, the search path is reset to default.
At the moment this function can be called only before the
snippet files are loaded for the first time. In practice
to set a custom search path for a `GtkSourceSnippetManager`,
you have to call this function right after creating it.
a #GtkSourceSnippetManager
a %NULL-terminated array of
strings or %NULL.
Contains a list of directories to search for files containing snippets (*.snippets).
no flags specified
case sensitive sort
sort in reverse order
remove duplicates
Represent white space characters with symbols.
#GtkSourceSpaceDrawer provides a way to visualize white spaces, by drawing
symbols.
Call [method@View.get_space_drawer] to get the `GtkSourceSpaceDrawer`
instance of a certain [class@View].
By default, no white spaces are drawn because the
[property@SpaceDrawer:enable-matrix] is %FALSE.
To draw white spaces, [method@SpaceDrawer.set_types_for_locations] can
be called to set the [property@SpaceDrawer:matrix] property (by default all
space types are enabled at all locations). Then call
[method@SpaceDrawer.set_enable_matrix].
For a finer-grained method, there is also the [class@Tag]'s
[property@Tag:draw-spaces] property.
# Example
To draw non-breaking spaces everywhere and draw all types of trailing spaces
except newlines:
```c
gtk_source_space_drawer_set_types_for_locations (space_drawer,
GTK_SOURCE_SPACE_LOCATION_ALL,
GTK_SOURCE_SPACE_TYPE_NBSP);
gtk_source_space_drawer_set_types_for_locations (space_drawer,
GTK_SOURCE_SPACE_LOCATION_TRAILING,
GTK_SOURCE_SPACE_TYPE_ALL &
~GTK_SOURCE_SPACE_TYPE_NEWLINE);
gtk_source_space_drawer_set_enable_matrix (space_drawer, TRUE);
```
# Use-case: draw unwanted white spaces
A possible use-case is to draw only unwanted white spaces. Examples:
- Draw all trailing spaces.
- If the indentation and alignment must be done with spaces, draw tabs.
And non-breaking spaces can always be drawn, everywhere, to distinguish them
from normal spaces.
Creates a new #GtkSourceSpaceDrawer object.
Useful for storing space drawing settings independently of a [class@View].
a new #GtkSourceSpaceDrawer.
Binds the [property@SpaceDrawer:matrix] property to a [class@Gio.Settings] key.
The [class@Gio.Settings] key must be of the same type as the
[property@SpaceDrawer:matrix] property, that is, `"au"`.
The [method@Gio.Settings.bind] function cannot be used, because the default GIO
mapping functions don't support [struct@GLib.Variant] properties (maybe it will be
supported by a future GIO version, in which case this function can be
deprecated).
a #GtkSourceSpaceDrawer object.
a #GSettings object.
the @settings key to bind.
flags for the binding.
whether the #GtkSourceSpaceDrawer:matrix property is enabled.
a #GtkSourceSpaceDrawer.
Gets the value of the [property@SpaceDrawer:matrix] property, as a [struct@GLib.Variant].
An empty array can be returned in case the matrix is a zero matrix.
The [method@SpaceDrawer.get_types_for_locations] function may be more
convenient to use.
the #GtkSourceSpaceDrawer:matrix value as a new floating #GVariant
instance.
a #GtkSourceSpaceDrawer.
If only one location is specified, this function returns what kind of
white spaces are drawn at that location.
The value is retrieved from the [property@SpaceDrawer:matrix] property.
If several locations are specified, this function returns the logical AND for
those locations. Which means that if a certain kind of white space is present
in the return value, then that kind of white space is drawn at all the
specified @locations.
a combination of #GtkSourceSpaceTypeFlags.
a #GtkSourceSpaceDrawer.
one or several #GtkSourceSpaceLocationFlags.
Sets whether the [property@SpaceDrawer:matrix] property is enabled.
a #GtkSourceSpaceDrawer.
the new value.
Sets a new value to the [property@SpaceDrawer:matrix] property, as a [struct@GLib.Variant].
If @matrix is %NULL, then an empty array is set.
If @matrix is floating, it is consumed.
The [method@SpaceDrawer.set_types_for_locations] function may be more
convenient to use.
a #GtkSourceSpaceDrawer.
the new matrix value, or %NULL.
Modifies the [property@SpaceDrawer:matrix] property at the specified
@locations.
a #GtkSourceSpaceDrawer.
one or several #GtkSourceSpaceLocationFlags.
a combination of #GtkSourceSpaceTypeFlags.
Whether the [property@SpaceDrawer:matrix] property is enabled.
The property is a [struct@GLib.Variant] property to specify where and
what kind of white spaces to draw.
The [struct@GLib.Variant] is of type `"au"`, an array of unsigned integers. Each
integer is a combination of [flags@SpaceTypeFlags]. There is one
integer for each [flags@SpaceLocationFlags], in the same order as
they are defined in the enum (%GTK_SOURCE_SPACE_LOCATION_NONE and
%GTK_SOURCE_SPACE_LOCATION_ALL are not taken into account).
If the array is shorter than the number of locations, then the value
for the missing locations will be %GTK_SOURCE_SPACE_TYPE_NONE.
By default, %GTK_SOURCE_SPACE_TYPE_ALL is set for all locations.4
#GtkSourceSpaceLocationFlags contains flags for white space locations.
If a line contains only white spaces (no text), the white spaces match both
%GTK_SOURCE_SPACE_LOCATION_LEADING and %GTK_SOURCE_SPACE_LOCATION_TRAILING.
No flags.
Leading white spaces on a line, i.e. the
indentation.
White spaces inside a line of text.
Trailing white spaces on a line.
White spaces anywhere.
#GtkSourceSpaceTypeFlags contains flags for white space types.
No flags.
Space character.
Tab character.
Line break character. If the
#GtkSourceBuffer:implicit-trailing-newline property is %TRUE,
#GtkSourceSpaceDrawer also draws a line break at the end of the buffer.
Non-breaking space character.
All white spaces.
Represents a style.
The `GtkSourceStyle` structure is used to describe text attributes
which are set when given style is used.
This function modifies the [class@Gtk.TextTag] properties that are related to the
#GtkSourceStyle properties. Other [class@Gtk.TextTag] properties are left untouched.
If @style is non-%NULL, applies @style to @tag.
If @style is %NULL, the related *-set properties of [class@Gtk.TextTag] are set to
%FALSE.
a #GtkSourceStyle to apply, or %NULL.
a #GtkTextTag to apply styles to.
Creates a copy of @style, that is a new #GtkSourceStyle instance which
has the same attributes set.
copy of @style, call g_object_unref()
when you are done with it.
a #GtkSourceStyle structure to copy.
Controls the appearance of [class@View].
#GtkSourceStyleScheme contains all the text styles to be used in
[class@View] and [class@Buffer]. For instance, it contains text styles
for syntax highlighting, it may contain foreground and background color for
non-highlighted text, color for the line numbers, current line highlighting,
bracket matching, etc.
Style schemes are stored in XML files. The format of a scheme file is
documented in the [style scheme reference](./style-reference.html).
The two style schemes with IDs "classic" and "tango" follow more closely the
GTK theme (for example for the background color).
a
%NULL-terminated array containing the @scheme authors or %NULL if
no author is specified by the style scheme.
a #GtkSourceStyleScheme.
@scheme description (if defined), or %NULL.
a #GtkSourceStyleScheme.
@scheme file name if the scheme was created
parsing a style scheme file or %NULL in the other cases.
a #GtkSourceStyleScheme.
@scheme id.
a #GtkSourceStyleScheme.
Gets a metadata property from the style scheme.
value of property @name stored in
the metadata of @scheme or %NULL if @scheme does not contain the
specified metadata property.
a #GtkSourceStyleScheme.
metadata property name.
@scheme name.
a #GtkSourceStyleScheme.
style which corresponds to @style_id in
the @scheme, or %NULL when no style with this name found. It is owned by
@scheme and may not be unref'ed.
a #GtkSourceStyleScheme.
id of the style to retrieve.
Style scheme description, a translatable string to present to the user.
Style scheme filename or %NULL.
Style scheme id, a unique string used to identify the style scheme
in [class@StyleSchemeManager].
Style scheme name, a translatable string to present to the user.
Interface implemented by widgets for choosing style schemes.
`GtkSourceStyleSchemeChooser` is an interface that is implemented by widgets
for choosing style schemes.
In GtkSourceView, the main widgets that implement this interface are
[class@StyleSchemeChooserWidget] and [class@StyleSchemeChooserButton].
Gets the currently-selected scheme.
the currently-selected scheme.
a #GtkSourceStyleSchemeChooser
Sets the scheme.
a #GtkSourceStyleSchemeChooser
a #GtkSourceStyleScheme
Gets the currently-selected scheme.
the currently-selected scheme.
a #GtkSourceStyleSchemeChooser
Sets the scheme.
a #GtkSourceStyleSchemeChooser
a #GtkSourceStyleScheme
Contains the currently selected style scheme.
The property can be set to change the current selection programmatically.
A button to launch a style scheme selection dialog.
The `GtkSourceStyleSchemeChooserButton` is a button which displays
the currently selected style scheme and allows to open a style scheme
selection dialog to change the style scheme.
It is suitable widget for selecting a style scheme in a preference dialog.
In `GtkSourceStyleSchemeChooserButton`, a [class@StyleSchemeChooserWidget]
is used to provide a dialog for selecting style schemes.
Creates a new #GtkSourceStyleSchemeChooserButton.
a new #GtkSourceStyleSchemeChooserButton.
the currently-selected scheme.
a #GtkSourceStyleSchemeChooser
a #GtkSourceStyleSchemeChooser
a #GtkSourceStyleScheme
A widget for choosing style schemes.
The `GtkSourceStyleSchemeChooserWidget` widget lets the user select a
style scheme. By default, the chooser presents a predefined list
of style schemes.
To change the initially selected style scheme,
use [method@StyleSchemeChooser.set_style_scheme].
To get the selected style scheme
use [method@StyleSchemeChooser.get_style_scheme].
Creates a new #GtkSourceStyleSchemeChooserWidget.
a new #GtkSourceStyleSchemeChooserWidget.
Provides access to [class@StyleScheme]s.
Creates a new style manager.
If you do not need more than one style manager
then use [func@StyleSchemeManager.get_default] instead.
a new #GtkSourceStyleSchemeManager.
Returns the default #GtkSourceStyleSchemeManager instance.
a #GtkSourceStyleSchemeManager. Return value
is owned by GtkSourceView library and must not be unref'ed.
Appends @path to the list of directories where the @manager looks for
style scheme files.
See [method@StyleSchemeManager.set_search_path] for details.
a #GtkSourceStyleSchemeManager.
a directory or a filename.
Mark any currently cached information about the available style schems
as invalid.
All the available style schemes will be reloaded next time the @manager is accessed.
a #GtkSourceStyleSchemeManager.
Looks up style scheme by id.
a #GtkSourceStyleScheme object.
The returned value is owned by @manager and must not be unref'ed.
a #GtkSourceStyleSchemeManager.
style scheme id to find.
Returns the ids of the available style schemes.
a %NULL-terminated array of strings containing the ids of the available
style schemes or %NULL if no style scheme is available.
The array is sorted alphabetically according to the scheme name.
The array is owned by the @manager and must not be modified.
a #GtkSourceStyleSchemeManager.
Returns the current search path for the @manager.
See [method@StyleSchemeManager.set_search_path] for details.
a %NULL-terminated array
of string containing the search path.
The array is owned by the @manager and must not be modified.
a #GtkSourceStyleSchemeManager.
Prepends @path to the list of directories where the @manager looks
for style scheme files.
See [method@StyleSchemeManager.set_search_path] for details.
a #GtkSourceStyleSchemeManager.
a directory or a filename.
Sets the list of directories where the @manager looks for
style scheme files.
If @path is %NULL, the search path is reset to default.
a #GtkSourceStyleSchemeManager.
a %NULL-terminated array of
strings or %NULL.
A preview widget for [class@StyleScheme].
This widget provides a convenient [class@Gtk.Widget] to preview a [class@StyleScheme].
The [property@StyleSchemePreview:selected] property can be used to manage
the selection state of a single preview widget.
Creates a new #GtkSourceStyleSchemePreview to preview the style scheme
provided in @scheme.
a #GtkWidget
a #GtkSourceStyleScheme
Gets the #GtkSourceStyleScheme previewed by the widget.
a #GtkSourceStyleScheme
a #GtkSourceStyleSchemePreview
A tag that can be applied to text in a [class@Buffer].
`GtkSourceTag` is a subclass of [class@Gtk.TextTag] that adds properties useful for
the GtkSourceView library.
If, for a certain tag, [class@Gtk.TextTag] is sufficient, it's better that you create
a [class@Gtk.TextTag], not a [class@Tag].
Creates a `GtkSourceTag`.
Configure the tag using object arguments, i.e. using [method@GObject.Object.set].
For usual cases, [method@Buffer.create_source_tag] is more convenient to
use.
a new `GtkSourceTag`.
tag name, or %NULL.
Whether to draw white spaces.
This property takes precedence over the value defined by the [class@SpaceDrawer]'s
[property@SpaceDrawer:matrix] property (only where the tag is applied).
Setting this property also changes [property@Tag:draw-spaces-set] to
%TRUE.
Whether the [property@Tag:draw-spaces] property is set and must be
taken into account.
Subclass of [class@Gtk.TextView].
`GtkSourceView` is the main class of the GtkSourceView library.
Use a [class@Buffer] to display text with a `GtkSourceView`.
This class provides:
- Show the line numbers;
- Show a right margin;
- Highlight the current line;
- Indentation settings;
- Configuration for the Home and End keyboard keys;
- Configure and show line marks;
- And a few other things.
An easy way to test all these features is to use the test-widget mini-program
provided in the GtkSourceView repository, in the tests/ directory.
# GtkSourceView as GtkBuildable
The GtkSourceView implementation of the [iface@Gtk.Buildable] interface exposes the
[property@View:completion] object with the internal-child "completion".
An example of a UI definition fragment with GtkSourceView:
```xml
<object class="GtkSourceView" id="source_view">
<property name="tab-width">4</property>
<property name="auto-indent">True</property>
<child internal-child="completion">
<object class="GtkSourceCompletion">
<property name="select-on-show">False</property>
</object>
</child>
</object>
```
# Changing the Font
Gtk CSS provides the best way to change the font for a `GtkSourceView` in a
manner that allows for components like [class@Map] to scale the desired
font.
```c
GtkCssProvider *provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider,
"textview { font-family: Monospace; font-size: 8pt; }",
-1,
NULL);
gtk_style_context_add_provider (gtk_widget_get_style_context (view),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
```
If you need to adjust the font or size of font within a portion of the
document only, you should use a [class@Gtk.TextTag] with the [property@Gtk.TextTag:family] or
[property@Gtk.TextTag:scale] set so that the font size may be scaled relative to
the default font set in CSS.
Creates a new `GtkSourceView`.
By default, an empty [class@Buffer] will be lazily created and can be
retrieved with [method@Gtk.TextView.get_buffer].
If you want to specify your own buffer, either override the
[vfunc@Gtk.TextView.create_buffer] factory method, or use
[ctor@View.new_with_buffer].
a new #GtkSourceView.
Creates a new #GtkSourceView widget displaying the buffer @buffer.
One buffer can be shared among many widgets.
a new #GtkSourceView.
a #GtkSourceBuffer.
Inserts a new snippet at @location
If another snippet was already active, it will be paused and the new
snippet will become active. Once the focus positions of @snippet have
been exhausted, editing will return to the previous snippet.
a #GtkSourceView
a #GtkSourceSnippet
a #GtkTextIter or %NULL for the cursor position
Returns whether auto-indentation of text is enabled.
%TRUE if auto indentation is enabled.
a #GtkSourceView.
Returns the #GtkSourceBackgroundPatternType specifying if and how
the background pattern should be displayed for this @view.
the #GtkSourceBackgroundPatternType.
a #GtkSourceView
Gets the [class@Completion] associated with @view.
The returned object is guaranteed to be the same for the lifetime of @view.
Each `GtkSourceView` object has a different [class@Completion].
the #GtkSourceCompletion associated with @view.
a #GtkSourceView.
Gets the [property@View:enable-snippets] property.
If %TRUE, matching snippets found in the [class@SnippetManager]
may be expanded when the user presses Tab after a word in the [class@View].
%TRUE if enabled
a #GtkSourceView
Returns the [class@Gutter] object associated with @window_type for @view.
Only %GTK_TEXT_WINDOW_LEFT and %GTK_TEXT_WINDOW_RIGHT are supported,
respectively corresponding to the left and right gutter. The line numbers
and mark category icons are rendered in the left gutter.
the #GtkSourceGutter.
a #GtkSourceView.
the gutter window type.
Returns whether the current line is highlighted.
%TRUE if the current line is highlighted.
a #GtkSourceView.
Gets the [class@Hover] associated with @view.
The returned object is guaranteed to be the same for the lifetime of @view.
Each [class@View] object has a different [class@Hover].
a #GtkSourceHover associated with @view.
a #GtkSourceView.
Returns whether when the tab key is pressed the current selection
should get indented instead of replaced with the `\t` character.
%TRUE if the selection is indented when tab is pressed.
a #GtkSourceView.
Returns the number of spaces to use for each step of indent.
See [method@View.set_indent_width] for details.
indent width.
a #GtkSourceView.
Gets the [property@View:indenter] property.
a #GtkSourceIndenter or %NULL
a #GtkSourceView
Returns whether when inserting a tabulator character it should
be replaced by a group of space characters.
%TRUE if spaces are inserted instead of tabs.
a #GtkSourceView.
Gets attributes and priority for the @category.
#GtkSourceMarkAttributes for the @category.
The object belongs to @view, so it must not be unreffed.
a #GtkSourceView.
the category.
place where priority of the category will be stored.
Gets the position of the right margin in the given @view.
the position of the right margin.
a #GtkSourceView.
Returns whether line marks are displayed beside the text.
%TRUE if the line marks are displayed.
a #GtkSourceView.
Returns whether line numbers are displayed beside the text.
%TRUE if the line numbers are displayed.
a #GtkSourceView.
Returns whether a right margin is displayed.
%TRUE if the right margin is shown.
a #GtkSourceView.
Returns %TRUE if pressing the Backspace key will try to delete spaces
up to the previous tab stop.
%TRUE if smart Backspace handling is enabled.
a #GtkSourceView.
Returns a [enum@SmartHomeEndType] end value specifying
how the cursor will move when HOME and END keys are pressed.
a #GtkSourceSmartHomeEndType value.
a #GtkSourceView.
Gets the [class@SpaceDrawer] associated with @view.
The returned object is guaranteed to be the same for the lifetime of @view.
Each [class@View] object has a different [class@SpaceDrawer].
the #GtkSourceSpaceDrawer associated with @view.
a #GtkSourceView.
Returns the width of tabulation in characters.
width of tab.
a #GtkSourceView.
Determines the visual column at @iter taking into consideration the
[property@View:tab-width] of @view.
the visual column at @iter.
a #GtkSourceView.
a position in @view.
Inserts one indentation level at the beginning of the specified lines. The
empty lines are not indented.
a #GtkSourceView.
#GtkTextIter of the first line to indent
#GtkTextIter of the last line to indent
Inserts a new snippet at @location
If another snippet was already active, it will be paused and the new
snippet will become active. Once the focus positions of @snippet have
been exhausted, editing will return to the previous snippet.
a #GtkSourceView
a #GtkSourceSnippet
a #GtkTextIter or %NULL for the cursor position
If %TRUE auto-indentation of text is enabled.
When Enter is pressed to create a new line, the auto-indentation inserts the
same indentation as the previous line. This is **not** a
"smart indentation" where an indentation level is added or removed depending
on the context.
a #GtkSourceView.
whether to enable auto indentation.
Set if and how the background pattern should be displayed.
a #GtkSourceView.
the #GtkSourceBackgroundPatternType.
Sets the [property@View:enable-snippets] property.
If @enable_snippets is %TRUE, matching snippets found in the
[class@SnippetManager] may be expanded when the user presses
Tab after a word in the [class@View].
a #GtkSourceView
if snippets should be enabled
If @highlight is %TRUE the current line will be highlighted.
a #GtkSourceView.
whether to highlight the current line.
If %TRUE, when the tab key is pressed when several lines are selected, the
selected lines are indented of one level instead of being replaced with a `\t`
character. Shift+Tab unindents the selection.
If the first or last line is not selected completely, it is also indented or
unindented.
When the selection doesn't span several lines, the tab key always replaces
the selection with a normal `\t` character.
a #GtkSourceView.
whether to indent a block when tab is pressed.
Sets the number of spaces to use for each step of indent when the tab key is
pressed.
If @width is -1, the value of the [property@View:tab-width] property
will be used.
The [property@View:indent-width] interacts with the
[property@View:insert-spaces-instead-of-tabs] property and
[property@View:tab-width]. An example will be clearer:
If the [property@View:indent-width] is 4 and [property@View:tab-width] is 8 and
[property@View:insert-spaces-instead-of-tabs] is %FALSE, then pressing the tab
key at the beginning of a line will insert 4 spaces. So far so good. Pressing
the tab key a second time will remove the 4 spaces and insert a `\t` character
instead (since [property@View:tab-width] is 8). On the other hand, if
[property@View:insert-spaces-instead-of-tabs] is %TRUE, the second tab key
pressed will insert 4 more spaces for a total of 8 spaces in the
[class@Gtk.TextBuffer].
The test-widget program (available in the GtkSourceView repository) may be
useful to better understand the indentation settings (enable the space
drawing!).
a #GtkSourceView.
indent width in characters.
Sets the indenter for @view to @indenter.
Note that the indenter will not be used unless #GtkSourceView:auto-indent
has been set to %TRUE.
a #GtkSourceView
a #GtkSourceIndenter or %NULL
If %TRUE a tab key pressed is replaced by a group of space characters.
Of course it is still possible to insert a real `\t` programmatically with the
[class@Gtk.TextBuffer] API.
a #GtkSourceView.
whether to insert spaces instead of tabs.
Sets attributes and priority for the @category.
a #GtkSourceView.
the category.
mark attributes.
priority of the category.
Sets the position of the right margin in the given @view.
a #GtkSourceView.
the width in characters where to position the right margin.
If %TRUE line marks will be displayed beside the text.
a #GtkSourceView.
whether line marks should be displayed.
If %TRUE line numbers will be displayed beside the text.
a #GtkSourceView.
whether line numbers should be displayed.
If %TRUE a right margin is displayed.
a #GtkSourceView.
whether to show a right margin.
When set to %TRUE, pressing the Backspace key will try to delete spaces
up to the previous tab stop.
a #GtkSourceView.
whether to enable smart Backspace handling.
Set the desired movement of the cursor when HOME and END keys
are pressed.
a #GtkSourceView.
the desired behavior among #GtkSourceSmartHomeEndType.
Sets the width of tabulation in characters.
The #GtkTextBuffer still contains `\t` characters,
but they can take a different visual width in a [class@View] widget.
a #GtkSourceView.
width of tab in characters.
Removes one indentation level at the beginning of the
specified lines.
a #GtkSourceView.
#GtkTextIter of the first line to indent
#GtkTextIter of the last line to indent
Draw a specific background pattern on the view.
The completion object associated with the view
The property denotes if snippets should be
expanded when the user presses Tab after having typed a word
matching the snippets found in [class@SnippetManager].
The user may tab through focus-positions of the snippet if any
are available by pressing Tab repeatedly until the desired focus
position is selected.
Width of an indentation step expressed in number of spaces.
The property is a [iface@Indenter] to use to indent
as the user types into the [class@View].
Position of the right margin.
Whether to display line mark pixbufs
Whether to display line numbers
Whether to display the right margin.
Whether smart Backspace should be used.
Set the behavior of the HOME and END keys.
The [class@SpaceDrawer] object associated with the view.4
Width of a tab character expressed in number of spaces.
Keybinding signal to change case of the text at the current cursor position.
the case to use
Keybinding signal to edit a number at the current cursor position.
the number to add to the number at the current position
Keybinding signal to join the lines currently selected.
Emitted when a line mark has been activated (for instance when there
was a button press in the line marks gutter).
You can use @iter to determine on which line the activation took place.
a #GtkTextIter
the button that was pressed
the modifier state, if any
the number of presses
The signal is a keybinding which gets emitted when the user initiates moving a line.
The default binding key is Alt+Up/Down arrow. And moves the currently selected lines,
or the current line up or down by one line.
%TRUE to move down, %FALSE to move up.
Keybinding signal to move the cursor to the matching bracket.
%TRUE if the move should extend the selection
The signal is a keybinding which gets emitted when the user initiates moving a word.
The default binding key is Alt+Left/Right Arrow and moves the current selection, or the current
word by one word.
the number of words to move over
The signal is emitted to insert a new snippet into the view.
If another snippet was active, it will be paused until all focus positions of @snippet have been exhausted.
@location will be updated to point at the end of the snippet.
a #GtkSourceSnippet
a #GtkTextIter
The signal is a key binding signal which gets
emitted when the user requests a completion, by pressing
<keycombo><keycap>Control</keycap><keycap>space</keycap></keycombo>.
This will create a [class@CompletionContext] with the activation
type as %GTK_SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED.
Applications should not connect to it, but may emit it with
[func@GObject.signal_emit_by_name] if they need to activate the completion by
another means, for example with another key binding or a menu entry.
Emitted when a the cursor was moved according to the smart home end setting.
The signal is emitted after the cursor is moved, but
during the [signal@Gtk.TextView::move-cursor] action. This can be used to find
out whether the cursor was moved by a normal home/end or by a smart
home/end.
a #GtkTextIter
the count
a #GtkSourceView
a #GtkSourceSnippet
a #GtkTextIter or %NULL for the cursor position
the gutter position of the lines
renderer
the gutter position of the marks
renderer
Vim emulation.
The `GtkSourceVimIMContext` is a [class@Gtk.IMContext] implementation that can
be used to provide Vim-like editing controls within a [class@View].
The `GtkSourceViMIMContext` will process incoming [class@Gdk.KeyEvent] as the
user types. It should be used in conjunction with a [class@Gtk.EventControllerKey].
Various features supported by `GtkSourceVimIMContext` include:
- Normal, Insert, Replace, Visual, and Visual Line modes
- Support for an integrated command bar and current command preview
- Search and replace
- Motions and Text Objects
- History replay
- Jumplists within the current file
- Registers including the system and primary clipboards
- Creation and motion to marks
- Some commonly used Vim commands
It is recommended that applications display the contents of
[property@VimIMContext:command-bar-text] and
[property@VimIMContext:command-text] to the user as they represent the
command-bar and current command preview found in Vim.
`GtkSourceVimIMContext` attempts to work with additional [class@Gtk.IMContext]
implementations such as IBus by querying the [class@Gtk.TextView] before processing
the command in states which support it (notably Insert and Replace modes).
```c
GtkEventController *key;
GtkIMContext *im_context;
GtkWidget *view;
view = gtk_source_view_new ();
im_context = gtk_source_vim_im_context_new ();
key = gtk_event_controller_key_new ();
gtk_event_controller_key_set_im_context (GTK_EVENT_CONTROLLER_KEY (key), im_context);
gtk_event_controller_set_propagation_phase (key, GTK_PHASE_CAPTURE);
gtk_widget_add_controller (view, key);
gtk_im_context_set_client_widget (im_context, view);
g_object_bind_property (im_context, "command-bar-text", command_bar_label, "label", 0);
g_object_bind_property (im_context, "command-text", command_label, "label", 0);
```
Executes @command as if it was typed into the command bar by the
user except that this does not emit the
[signal@VimIMContext::execute-command] signal.
a #GtkSourceVimIMContext
the command text
Gets the current command-bar text as it is entered by the user.
A string containing the command-bar text
a #GtkSourceVimIMContext
Gets the current command text as it is entered by the user.
A string containing the command text
a #GtkSourceVimIMContext
Requests the application open the file found at @path.
If @path is %NULL, then the current file should be reloaded from storage.
This may be executed in relation to the user running the
`:edit` or `:e` commands.
the #GtkSourceView
the path if provided, otherwise %NULL
The signal is emitted when a command should be
executed. This might be something like `:wq` or `:e <path>`.
If the application chooses to implement this, it should return
%TRUE from this signal to indicate the command has been handled.
%TRUE if handled; otherwise %FALSE.
the command to execute
Requests that the application format the text between
@begin and @end.
the start location
the end location
Requests the application save the file.
If a filename was provided, it will be available to the signal handler as @path.
This may be executed in relation to the user running the `:write` or `:w` commands.
the #GtkSourceView
the path if provided, otherwise %NULL
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.
%TRUE if the version of the GtkSourceView currently loaded
is the same as or newer than the passed-in version.
the major version to check
the minor version to check
the micro version to check
Gets all encodings.
a list of
all #GtkSourceEncoding's. Free with g_slist_free().
Gets the #GtkSourceEncoding for the current locale.
See also [func@GLib.get_charset].
the current locale encoding.
Gets the list of default candidate encodings to try when loading a file.
See [method@FileLoader.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.
the list of
default candidate encodings. Free with g_slist_free().
Gets a #GtkSourceEncoding from a character set such as "UTF-8" or
"ISO-8859-1".
the corresponding #GtkSourceEncoding, or %NULL
if not found.
a character set.
the UTF-8 encoding.
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 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.
the major version number of the GtkSourceView library
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.
the micro version number of the GtkSourceView library
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.
the minor version number of the GtkSourceView library
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.
Simplified version of [func@scheduler_add_full].
the callback to execute
user data for @callback
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 [func@GLib.get_monotonic_time] for comparison.
Use [func@scheduler_remove] to remove the handler.
the callback to execute
user data for @callback
closure notify for @user_data
Removes a scheduler callback previously registered with
[func@scheduler_add] or [func@scheduler_add_full].
the handler id
Utility functions.
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 #GtkTextBuffer'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: [func@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>
the escaped @text.
the text to escape.
Use this function before [method@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: [func@utils_escape_search_text].
the unescaped @text.
the text to unescape.