![]() |
![]() |
![]() |
GtkSourceView 3 Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties | Signals |
GtkSourceBufferGtkSourceBuffer — Buffer object for GtkSourceView |
#include <gtksourceview/gtksource.h> GtkSourceBuffer; enum GtkSourceBracketMatchType; GtkSourceBuffer * gtk_source_buffer_new (GtkTextTagTable *table
); GtkSourceBuffer * gtk_source_buffer_new_with_language (GtkSourceLanguage *language
); void gtk_source_buffer_set_highlight_syntax (GtkSourceBuffer *buffer
,gboolean highlight
); gboolean gtk_source_buffer_get_highlight_syntax (GtkSourceBuffer *buffer
); void gtk_source_buffer_set_language (GtkSourceBuffer *buffer
,GtkSourceLanguage *language
); GtkSourceLanguage * gtk_source_buffer_get_language (GtkSourceBuffer *buffer
); void gtk_source_buffer_set_highlight_matching_brackets (GtkSourceBuffer *buffer
,gboolean highlight
); gboolean gtk_source_buffer_get_highlight_matching_brackets (GtkSourceBuffer *buffer
); void gtk_source_buffer_set_style_scheme (GtkSourceBuffer *buffer
,GtkSourceStyleScheme *scheme
); GtkSourceStyleScheme * gtk_source_buffer_get_style_scheme (GtkSourceBuffer *buffer
); void gtk_source_buffer_ensure_highlight (GtkSourceBuffer *buffer
,const GtkTextIter *start
,const GtkTextIter *end
); GtkSourceMark * gtk_source_buffer_create_source_mark (GtkSourceBuffer *buffer
,const gchar *name
,const gchar *category
,const GtkTextIter *where
); gboolean gtk_source_buffer_forward_iter_to_source_mark (GtkSourceBuffer *buffer
,GtkTextIter *iter
,const gchar *category
); gboolean gtk_source_buffer_backward_iter_to_source_mark (GtkSourceBuffer *buffer
,GtkTextIter *iter
,const gchar *category
); GSList * gtk_source_buffer_get_source_marks_at_line (GtkSourceBuffer *buffer
,gint line
,const gchar *category
); GSList * gtk_source_buffer_get_source_marks_at_iter (GtkSourceBuffer *buffer
,GtkTextIter *iter
,const gchar *category
); void gtk_source_buffer_remove_source_marks (GtkSourceBuffer *buffer
,const GtkTextIter *start
,const GtkTextIter *end
,const gchar *category
); gboolean gtk_source_buffer_iter_has_context_class (GtkSourceBuffer *buffer
,const GtkTextIter *iter
,const gchar *context_class
); gchar ** gtk_source_buffer_get_context_classes_at_iter (GtkSourceBuffer *buffer
,const GtkTextIter *iter
); gboolean gtk_source_buffer_iter_forward_to_context_class_toggle (GtkSourceBuffer *buffer
,GtkTextIter *iter
,const gchar *context_class
); gboolean gtk_source_buffer_iter_backward_to_context_class_toggle (GtkSourceBuffer *buffer
,GtkTextIter *iter
,const gchar *context_class
); gint gtk_source_buffer_get_max_undo_levels (GtkSourceBuffer *buffer
); void gtk_source_buffer_set_max_undo_levels (GtkSourceBuffer *buffer
,gint max_undo_levels
); void gtk_source_buffer_redo (GtkSourceBuffer *buffer
); void gtk_source_buffer_undo (GtkSourceBuffer *buffer
); gboolean gtk_source_buffer_can_redo (GtkSourceBuffer *buffer
); gboolean gtk_source_buffer_can_undo (GtkSourceBuffer *buffer
); void gtk_source_buffer_begin_not_undoable_action (GtkSourceBuffer *buffer
); void gtk_source_buffer_end_not_undoable_action (GtkSourceBuffer *buffer
); GtkSourceUndoManager * gtk_source_buffer_get_undo_manager (GtkSourceBuffer *buffer
); void gtk_source_buffer_set_undo_manager (GtkSourceBuffer *buffer
,GtkSourceUndoManager *manager
); void gtk_source_buffer_set_search_text (GtkSourceBuffer *buffer
,const gchar *text
); const gchar * gtk_source_buffer_get_search_text (GtkSourceBuffer *buffer
); void gtk_source_buffer_set_case_sensitive_search (GtkSourceBuffer *buffer
,gboolean case_sensitive
); gboolean gtk_source_buffer_get_case_sensitive_search (GtkSourceBuffer *buffer
); void gtk_source_buffer_set_search_at_word_boundaries (GtkSourceBuffer *buffer
,gboolean at_word_boundaries
); gboolean gtk_source_buffer_get_search_at_word_boundaries (GtkSourceBuffer *buffer
); void gtk_source_buffer_set_search_wrap_around (GtkSourceBuffer *buffer
,gboolean wrap_around
); gboolean gtk_source_buffer_get_search_wrap_around (GtkSourceBuffer *buffer
); guint gtk_source_buffer_get_search_occurrences_count (GtkSourceBuffer *buffer
); gint gtk_source_buffer_get_search_occurrence_position (GtkSourceBuffer *buffer
,const GtkTextIter *match_start
,const GtkTextIter *match_end
); gboolean gtk_source_buffer_forward_search (GtkSourceBuffer *buffer
,const GtkTextIter *iter
,GtkTextIter *match_start
,GtkTextIter *match_end
); void gtk_source_buffer_forward_search_async (GtkSourceBuffer *buffer
,const GtkTextIter *iter
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
); gboolean gtk_source_buffer_forward_search_finish (GtkSourceBuffer *buffer
,GAsyncResult *result
,GtkTextIter *match_start
,GtkTextIter *match_end
,GError **error
); gboolean gtk_source_buffer_backward_search (GtkSourceBuffer *buffer
,const GtkTextIter *iter
,GtkTextIter *match_start
,GtkTextIter *match_end
); void gtk_source_buffer_backward_search_async (GtkSourceBuffer *buffer
,const GtkTextIter *iter
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
); gboolean gtk_source_buffer_backward_search_finish (GtkSourceBuffer *buffer
,GAsyncResult *result
,GtkTextIter *match_start
,GtkTextIter *match_end
,GError **error
); gboolean gtk_source_buffer_search_replace (GtkSourceBuffer *buffer
,const GtkTextIter *match_start
,const GtkTextIter *match_end
,const gchar *replace
,gint replace_length
); guint gtk_source_buffer_search_replace_all (GtkSourceBuffer *buffer
,const gchar *replace
,gint replace_length
);
"can-redo" gboolean : Read "can-undo" gboolean : Read "case-sensitive-search" gboolean : Read / Write / Construct "highlight-matching-brackets" gboolean : Read / Write "highlight-syntax" gboolean : Read / Write "language" GtkSourceLanguage* : Read / Write "max-undo-levels" gint : Read / Write "search-at-word-boundaries" gboolean : Read / Write / Construct "search-occurrences-count" guint : Read "search-text" gchar* : Read / Write / Construct "search-wrap-around" gboolean : Read / Write / Construct "style-scheme" GtkSourceStyleScheme* : Read / Write "undo-manager" GtkSourceUndoManager* : Read / Write / Construct
"bracket-matched" :Run Last
"highlight-updated" :Run Last
"redo" :Run Last
"source-mark-updated" :Run Last
"undo" :Run Last
The GtkSourceBuffer object is the model for GtkSourceView widgets. It extends the GtkTextBuffer object by adding features useful to display and edit source code such as syntax highlighting and bracket matching. It also implements support for undo/redo operations, and for the search and replace.
To create a GtkSourceBuffer use gtk_source_buffer_new()
or
gtk_source_buffer_new_with_language()
. The second form is just a convenience
function which allows you to initially set a GtkSourceLanguage.
By default highlighting is enabled, but you can disable it with
gtk_source_buffer_set_highlight_syntax()
.
A custom GtkSourceUndoManager can be implemented and set with
gtk_source_buffer_set_undo_manager()
. However the default implementation
should be suitable for most uses. By default, actions that can be undone or
redone are defined as groups of operations between a call to
gtk_text_buffer_begin_user_action()
and gtk_text_buffer_end_user_action()
. In
general, this happens whenever the user presses any key which modifies the
buffer. But the default undo manager will try to merge similar consecutive
actions, such as multiple character insertions on the same line, into one
action. But, inserting a newline starts a new action.
The default undo manager remembers the "modified" state of the buffer, and
restore it when an action is undone or redone. It can be useful in a text
editor to know whether the file is saved. See gtk_text_buffer_get_modified()
and gtk_text_buffer_set_modified()
.
To set the text to search, use gtk_source_buffer_set_search_text()
. The
search occurrences will be highlighted, and the total number of
occurrences can be retrieved with
gtk_source_buffer_get_search_occurrences_count()
. 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.
You can tune the search with the following properties: "case-sensitive-search", "search-at-word-boundaries" and "search-wrap-around".
To search forward, use gtk_source_buffer_forward_search()
or
gtk_source_buffer_forward_search_async()
for the asynchronous version.
The backward search is done similarly. To replace a search match, or all
matches, use gtk_source_buffer_search_replace()
and
gtk_source_buffer_search_replace_all()
.
To know the position of a certain match, use
gtk_source_buffer_get_search_occurrence_position()
.
In the GtkSourceView source code, there is an example of how to use the search and replace API: see the tests/test-search-ui.c file. It is a mini application for the search and replace, with a basic user interface.
typedef enum { GTK_SOURCE_BRACKET_MATCH_NONE, GTK_SOURCE_BRACKET_MATCH_OUT_OF_RANGE, GTK_SOURCE_BRACKET_MATCH_NOT_FOUND, GTK_SOURCE_BRACKET_MATCH_FOUND } GtkSourceBracketMatchType;
GtkSourceBuffer * gtk_source_buffer_new (GtkTextTagTable *table
);
Creates a new source buffer.
|
a GtkTextTagTable, or NULL to create a new one. [allow-none]
|
Returns : |
a new source buffer. |
GtkSourceBuffer * gtk_source_buffer_new_with_language (GtkSourceLanguage *language
);
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 gtk_source_buffer_set_language()
.
|
a GtkSourceLanguage. |
Returns : |
a new source buffer which will highlight text
according to the highlighting patterns in language . |
void gtk_source_buffer_set_highlight_syntax (GtkSourceBuffer *buffer
,gboolean highlight
);
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 language set with
gtk_source_buffer_set_language()
. If highlight
is FALSE
, syntax highlighting
is disabled and all the GtkTextTag 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. |
gboolean gtk_source_buffer_get_highlight_syntax
(GtkSourceBuffer *buffer
);
Determines whether syntax highlighting is activated in the source buffer.
|
a GtkSourceBuffer. |
Returns : |
TRUE if syntax highlighting is enabled, FALSE otherwise. |
void gtk_source_buffer_set_language (GtkSourceBuffer *buffer
,GtkSourceLanguage *language
);
Associate a GtkSourceLanguage with the buffer. If language
is
not-NULL
and syntax highlighting is enabled (see gtk_source_buffer_set_highlight_syntax()
),
the syntax patterns defined in language
will be used to highlight the text
contained in the buffer. If language
is NULL
, the text contained in the
buffer is not highlighted.
The buffer holds a reference to language
.
|
a GtkSourceBuffer. |
|
a GtkSourceLanguage to set, or NULL . [allow-none]
|
GtkSourceLanguage * gtk_source_buffer_get_language (GtkSourceBuffer *buffer
);
Returns the GtkSourceLanguage associated with the buffer,
see gtk_source_buffer_set_language()
. The returned object should not be
unreferenced by the user.
|
a GtkSourceBuffer. |
Returns : |
the GtkSourceLanguage associated with the buffer, or NULL . [transfer none]
|
void gtk_source_buffer_set_highlight_matching_brackets (GtkSourceBuffer *buffer
,gboolean highlight
);
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. |
gboolean gtk_source_buffer_get_highlight_matching_brackets
(GtkSourceBuffer *buffer
);
Determines whether bracket match highlighting is activated for the source buffer.
|
a GtkSourceBuffer. |
Returns : |
TRUE if the source buffer will highlight matching
brackets. |
void gtk_source_buffer_set_style_scheme (GtkSourceBuffer *buffer
,GtkSourceStyleScheme *scheme
);
Sets style scheme used by the buffer. If scheme
is NULL
no
style scheme is used.
|
a GtkSourceBuffer. |
|
a GtkSourceStyleScheme or NULL . [allow-none]
|
GtkSourceStyleScheme * gtk_source_buffer_get_style_scheme
(GtkSourceBuffer *buffer
);
Returns the GtkSourceStyleScheme associated with the buffer,
see gtk_source_buffer_set_style_scheme()
.
The returned object should not be unreferenced by the user.
|
a GtkSourceBuffer. |
Returns : |
the GtkSourceStyleScheme associated
with the buffer, or NULL . [transfer none]
|
void gtk_source_buffer_ensure_highlight (GtkSourceBuffer *buffer
,const GtkTextIter *start
,const GtkTextIter *end
);
Forces buffer to analyze and highlight the given area synchronously.
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. |
GtkSourceMark * gtk_source_buffer_create_source_mark (GtkSourceBuffer *buffer
,const gchar *name
,const gchar *category
,const GtkTextIter *where
);
Creates a source mark in the buffer
of category category
. A source mark is
a GtkTextMark but organised into categories. Depending on the category
a pixbuf can be specified that will be displayed along the line of the mark.
Like a GtkTextMark, a GtkSourceMark 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 GtkSourceBuffer. |
|
the name of the mark, or NULL . [allow-none]
|
|
a string defining the mark category. |
|
location to place the mark. |
Returns : |
a new GtkSourceMark, owned by the buffer. [transfer none] |
Since 2.2
gboolean gtk_source_buffer_forward_iter_to_source_mark (GtkSourceBuffer *buffer
,GtkTextIter *iter
,const gchar *category
);
Moves iter
to the position of the next GtkSourceMark of the given
category
. Returns TRUE
if iter
was moved. If category
is NULL, the
next source mark can be of any category.
|
a GtkSourceBuffer. |
|
an iterator. |
|
category to search for, or NULL . [allow-none]
|
Returns : |
whether iter was moved. |
Since 2.2
gboolean gtk_source_buffer_backward_iter_to_source_mark (GtkSourceBuffer *buffer
,GtkTextIter *iter
,const gchar *category
);
Moves iter
to the position of the previous GtkSourceMark of the given
category. Returns TRUE
if iter
was moved. If category
is NULL, the
previous source mark can be of any category.
|
a GtkSourceBuffer. |
|
an iterator. |
|
category to search for, or NULL . [allow-none]
|
Returns : |
whether iter was moved. |
Since 2.2
GSList * gtk_source_buffer_get_source_marks_at_line (GtkSourceBuffer *buffer
,gint line
,const gchar *category
);
Returns the list of marks of the given category at line
.
If category
is NULL, all marks at line
are returned.
|
a GtkSourceBuffer. |
|
a line number. |
|
category to search for, or NULL . [allow-none]
|
Returns : |
a newly allocated GSList. [element-type GtkSource.Mark][transfer container] |
Since 2.2
GSList * gtk_source_buffer_get_source_marks_at_iter (GtkSourceBuffer *buffer
,GtkTextIter *iter
,const gchar *category
);
Returns the list of marks of the given category at iter
. If category
is NULL
it returns all marks at iter
.
|
a GtkSourceBuffer. |
|
an iterator. |
|
category to search for, or NULL . [allow-none]
|
Returns : |
a newly allocated GSList. [element-type GtkSource.Mark][transfer container] |
Since 2.2
void gtk_source_buffer_remove_source_marks (GtkSourceBuffer *buffer
,const GtkTextIter *start
,const GtkTextIter *end
,const gchar *category
);
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 . [allow-none]
|
Since 2.2
gboolean gtk_source_buffer_iter_has_context_class (GtkSourceBuffer *buffer
,const GtkTextIter *iter
,const gchar *context_class
);
Check if the class context_klass
is set on iter
.
|
a GtkSourceBuffer. |
|
a GtkTextIter. |
|
class to search for. |
Since 2.10
gchar ** gtk_source_buffer_get_context_classes_at_iter (GtkSourceBuffer *buffer
,const GtkTextIter *iter
);
Get all defined context classes at iter
.
|
a GtkSourceBuffer. |
|
a GtkTextIter. |
Returns : |
a new NULL
terminated array of context class names.
Use g_strfreev() to free the array if it is no longer needed. [array zero-terminated=1][transfer full]
|
Since 2.10
gboolean gtk_source_buffer_iter_forward_to_context_class_toggle (GtkSourceBuffer *buffer
,GtkTextIter *iter
,const gchar *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.
|
a GtkSourceBuffer. |
|
a GtkTextIter. |
|
the context class. |
Returns : |
whether we found a context class toggle after iter
|
Since 2.10
gboolean gtk_source_buffer_iter_backward_to_context_class_toggle (GtkSourceBuffer *buffer
,GtkTextIter *iter
,const gchar *context_class
);
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.
|
a GtkSourceBuffer. |
|
a GtkTextIter. |
|
the context class. |
Returns : |
whether we found a context class toggle before iter
|
Since 2.10
gint gtk_source_buffer_get_max_undo_levels
(GtkSourceBuffer *buffer
);
Determines the number of undo levels the buffer will track for buffer edits.
|
a GtkSourceBuffer. |
Returns : |
the maximum number of possible undo levels or -1 if no limit is set. |
void gtk_source_buffer_set_max_undo_levels (GtkSourceBuffer *buffer
,gint max_undo_levels
);
Sets the number of undo levels for user actions the buffer will track. If the number of user actions exceeds the limit set by this function, older actions will be discarded.
If max_undo_levels
is -1, no limit is set.
|
a GtkSourceBuffer. |
|
the desired maximum number of undo levels. |
void gtk_source_buffer_redo (GtkSourceBuffer *buffer
);
Redoes the last undo operation. Use gtk_source_buffer_can_redo()
to check whether a call to this function will have any effect.
|
a GtkSourceBuffer. |
void gtk_source_buffer_undo (GtkSourceBuffer *buffer
);
Undoes the last user action which modified the buffer. Use
gtk_source_buffer_can_undo()
to check whether a call to this
function will have any effect.
|
a GtkSourceBuffer. |
gboolean gtk_source_buffer_can_redo (GtkSourceBuffer *buffer
);
Determines whether a source buffer can redo the last action (i.e. if the last operation was an undo).
|
a GtkSourceBuffer. |
Returns : |
TRUE if a redo is possible. |
gboolean gtk_source_buffer_can_undo (GtkSourceBuffer *buffer
);
Determines whether a source buffer can undo the last action.
|
a GtkSourceBuffer. |
Returns : |
TRUE if it's possible to undo the last action. |
void gtk_source_buffer_begin_not_undoable_action
(GtkSourceBuffer *buffer
);
Marks the beginning of a not undoable action on the buffer, disabling the undo manager. Typically you would call this function before initially setting the contents of the buffer (e.g. when loading a file in a text editor).
You may nest gtk_source_buffer_begin_not_undoable_action()
/
gtk_source_buffer_end_not_undoable_action()
blocks.
|
a GtkSourceBuffer. |
void gtk_source_buffer_end_not_undoable_action
(GtkSourceBuffer *buffer
);
Marks the end of a not undoable action on the buffer. When the last not undoable block is closed through the call to this function, the list of undo actions is cleared and the undo manager is re-enabled.
|
a GtkSourceBuffer. |
GtkSourceUndoManager * gtk_source_buffer_get_undo_manager
(GtkSourceBuffer *buffer
);
Returns the GtkSourceUndoManager associated with the buffer,
see gtk_source_buffer_set_undo_manager()
. The returned object should not be
unreferenced by the user.
|
a GtkSourceBuffer. |
Returns : |
the GtkSourceUndoManager associated with the buffer, or NULL . [transfer none]
|
void gtk_source_buffer_set_undo_manager (GtkSourceBuffer *buffer
,GtkSourceUndoManager *manager
);
Set the buffer undo manager. If manager
is NULL
the default undo manager
will be set.
|
a GtkSourceBuffer. |
|
A GtkSourceUndoManager or NULL . [allow-none]
|
void gtk_source_buffer_set_search_text (GtkSourceBuffer *buffer
,const gchar *text
);
Sets the text to search. If text
is NULL
or is empty, the search will be
disabled. A copy of text
will be made, so you can safely free text
after
a call to this function.
You may be interested to call gtk_source_utils_unescape_search_text()
before
this function.
|
a GtkSourceBuffer. |
|
the nul-terminated text to search, or NULL to disable the search. [allow-none]
|
Since 3.10
const gchar * gtk_source_buffer_get_search_text (GtkSourceBuffer *buffer
);
Gets the text to search. The return value must not be freed.
You may be interested to call gtk_source_utils_escape_search_text()
after
this function.
|
a GtkSourceBuffer. |
Returns : |
the text to search, or NULL if the search is disabled. |
Since 3.10
void gtk_source_buffer_set_case_sensitive_search (GtkSourceBuffer *buffer
,gboolean case_sensitive
);
Enables or disables the case sensitivity for the search.
|
a GtkSourceBuffer. |
|
the setting. |
Since 3.10
gboolean gtk_source_buffer_get_case_sensitive_search
(GtkSourceBuffer *buffer
);
|
a GtkSourceBuffer. |
Returns : |
whether the search is case sensitive. |
Since 3.10
void gtk_source_buffer_set_search_at_word_boundaries (GtkSourceBuffer *buffer
,gboolean at_word_boundaries
);
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 gtk_text_iter_starts_word()
and
gtk_text_iter_ends_word()
.
|
a GtkSourceBuffer. |
|
the setting. |
Since 3.10
gboolean gtk_source_buffer_get_search_at_word_boundaries
(GtkSourceBuffer *buffer
);
|
a GtkSourceBuffer. |
Returns : |
whether to search at word boundaries. |
Since 3.10
void gtk_source_buffer_set_search_wrap_around (GtkSourceBuffer *buffer
,gboolean wrap_around
);
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 GtkSourceBuffer. |
|
the setting. |
Since 3.10
gboolean gtk_source_buffer_get_search_wrap_around
(GtkSourceBuffer *buffer
);
|
a GtkSourceBuffer. |
Returns : |
whether to wrap around the search. |
Since 3.10
guint gtk_source_buffer_get_search_occurrences_count
(GtkSourceBuffer *buffer
);
Gets the total number of search occurrences.
|
a GtkSourceBuffer. |
Returns : |
the total number of search occurrences. |
Since 3.10
gint gtk_source_buffer_get_search_occurrence_position (GtkSourceBuffer *buffer
,const GtkTextIter *match_start
,const GtkTextIter *match_end
);
Gets the position of a search occurrence. If the buffer is not already fully scanned, the position may be unknown, and -1 is returned. Therefore you should call this function when you know that the buffer is fully scanned.
|
a GtkSourceBuffer. |
|
the start of the occurrence. |
|
the end of the occurrence. |
Returns : |
the position of the search occurrence. The first occurrence has the
position 1 (not 0). Returns 0 if match_start and match_end doesn't delimit
an occurrence. Returns -1 if the position is not yet known. |
Since 3.10
gboolean gtk_source_buffer_forward_search (GtkSourceBuffer *buffer
,const GtkTextIter *iter
,GtkTextIter *match_start
,GtkTextIter *match_end
);
Synchronous forward search.
|
a GtkSourceBuffer. |
|
start of search. |
|
return location for start of match, or NULL . [out][allow-none]
|
|
return location for end of match, or NULL . [out][allow-none]
|
Returns : |
whether a match was found. |
Since 3.10
void gtk_source_buffer_forward_search_async (GtkSourceBuffer *buffer
,const GtkTextIter *iter
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Asynchronous forward search. See the GAsyncResult documentation to know how to use this function.
If the operation is cancelled, the callback
will only be called if
cancellable
was not NULL
. gtk_source_buffer_forward_search_async()
takes
ownership of cancellable
, so you can unref it after calling this function.
|
a GtkSourceBuffer. |
|
start of search. |
|
a GCancellable, or NULL . [allow-none]
|
|
a GAsyncReadyCallback to call when the operation is finished. |
|
the data to pass to the callback function. |
Since 3.10
gboolean gtk_source_buffer_forward_search_finish (GtkSourceBuffer *buffer
,GAsyncResult *result
,GtkTextIter *match_start
,GtkTextIter *match_end
,GError **error
);
Finishes a forward search started with
gtk_source_buffer_forward_search_async()
.
|
a GtkSourceBuffer. |
|
a GAsyncResult. |
|
return location for start of match, or NULL . [out][allow-none]
|
|
return location for end of match, or NULL . [out][allow-none]
|
|
a GError, or NULL . |
Returns : |
whether a match was found. |
Since 3.10
gboolean gtk_source_buffer_backward_search (GtkSourceBuffer *buffer
,const GtkTextIter *iter
,GtkTextIter *match_start
,GtkTextIter *match_end
);
Synchronous backward search.
|
a GtkSourceBuffer. |
|
start of search. |
|
return location for start of match, or NULL . [out][allow-none]
|
|
return location for end of match, or NULL . [out][allow-none]
|
Returns : |
whether a match was found. |
Since 3.10
void gtk_source_buffer_backward_search_async (GtkSourceBuffer *buffer
,const GtkTextIter *iter
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
Asynchronous backward search. See the GAsyncResult documentation to know how to use this function.
If the operation is cancelled, the callback
will only be called if
cancellable
was not NULL
. gtk_source_buffer_backward_search_async()
takes
ownership of cancellable
, so you can unref it after calling this function.
|
a GtkSourceBuffer. |
|
start of search. |
|
a GCancellable, or NULL . [allow-none]
|
|
a GAsyncReadyCallback to call when the operation is finished. |
|
the data to pass to the callback function. |
Since 3.10
gboolean gtk_source_buffer_backward_search_finish (GtkSourceBuffer *buffer
,GAsyncResult *result
,GtkTextIter *match_start
,GtkTextIter *match_end
,GError **error
);
Finishes a backward search started with
gtk_source_buffer_backward_search_async()
.
|
a GtkSourceBuffer. |
|
a GAsyncResult. |
|
return location for start of match, or NULL . [out][allow-none]
|
|
return location for end of match, or NULL . [out][allow-none]
|
|
a GError, or NULL . |
Returns : |
whether a match was found. |
Since 3.10
gboolean gtk_source_buffer_search_replace (GtkSourceBuffer *buffer
,const GtkTextIter *match_start
,const GtkTextIter *match_end
,const gchar *replace
,gint replace_length
);
Replaces a search match by another text. If match_start
and match_end
doesn't correspond to a search match, FALSE
is returned.
|
a GtkSourceBuffer. |
|
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. |
Returns : |
whether the match has been replaced. |
Since 3.10
guint gtk_source_buffer_search_replace_all (GtkSourceBuffer *buffer
,const gchar *replace
,gint replace_length
);
Replaces all search matches by another text.
|
a GtkSourceBuffer. |
|
the replacement text. |
|
the length of replace in bytes, or -1. |
Returns : |
the number of replaced matches. |
Since 3.10
"can-redo"
property"can-redo" gboolean : Read
Whether Redo operation is possible.
Default value: FALSE
"can-undo"
property"can-undo" gboolean : Read
Whether Undo operation is possible.
Default value: FALSE
"case-sensitive-search"
property"case-sensitive-search" gboolean : Read / Write / Construct
Whether the search is case sensitive.
Default value: FALSE
Since 3.10
"highlight-matching-brackets"
property"highlight-matching-brackets" gboolean : Read / Write
Whether to highlight matching brackets in the buffer.
Default value: TRUE
"highlight-syntax"
property"highlight-syntax" gboolean : Read / Write
Whether to highlight syntax in the buffer.
Default value: TRUE
"language"
property"language" GtkSourceLanguage* : Read / Write
Language object to get highlighting patterns from.
"max-undo-levels"
property"max-undo-levels" gint : Read / Write
Number of undo levels for the buffer. -1 means no limit. This property will only affect the default undo manager.
Allowed values: >= -1
Default value: 1000
"search-at-word-boundaries"
property"search-at-word-boundaries" gboolean : Read / Write / Construct
If TRUE
, a search match must start and end a word. The match can
span multiple words.
Default value: FALSE
Since 3.10
"search-occurrences-count"
property"search-occurrences-count" guint : Read
The total number of search occurrences. If the search is disabled, the value is 0.
Default value: 0
Since 3.10
"search-text"
property"search-text" gchar* : Read / Write / Construct
A search string, or NULL
if the search is disabled.
Default value: NULL
Since 3.10
"search-wrap-around"
property"search-wrap-around" gboolean : Read / Write / Construct
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.
Default value: TRUE
Since 3.10
"style-scheme"
property"style-scheme" GtkSourceStyleScheme* : Read / Write
Style scheme. It contains styles for syntax highlighting, optionally foreground, background, cursor color, current line color, and matching brackets style.
"undo-manager"
property"undo-manager" GtkSourceUndoManager* : Read / Write / Construct
The buffer undo manager.
"bracket-matched"
signalvoid user_function (GtkSourceBuffer *buffer,
GtkTextIter *iter,
GtkSourceBracketMatchType state,
gpointer user_data) : Run Last
Sets iter
to a valid iterator pointing to the matching bracket
if state
is GTK_SOURCE_BRACKET_MATCH_FOUND. Otherwise iter
is
meaningless.
|
a GtkSourceBuffer. |
|
iterator to initialize. |
|
state of bracket matching |
|
user data set when the signal handler was connected. |
Since 2.12
"highlight-updated"
signalvoid user_function (GtkSourceBuffer *sourcebuffer,
GtkTextIter *arg1,
GtkTextIter *arg2,
gpointer user_data) : Run Last
"source-mark-updated"
signalvoid user_function (GtkSourceBuffer *buffer,
GtkTextMark *mark,
gpointer user_data) : Run Last
The ::source_mark_updated signal is emitted each time
a mark is added to, moved or removed from the buffer
.
|
the buffer that received the signal |
|
the GtkSourceMark |
|
user data set when the signal handler was connected. |