Methods
gtksourceview2.Buffer.backward_iter_to_source_mark
def backward_iter_to_source_mark(iter
, category
=None)
iter :
| a gtk.TextIter |
category :
| category to search for or None . |
Returns : | whether iter moved. |
The backward_iter_to_source_mark
() method moves iter to the
position of the previous gtksourceview2.Mark
of the given category. Returns True
if iter was moved.
If category is None
, the previous source mark can be of any category.
gtksourceview2.Buffer.begin_not_undoable_action
def begin_not_undoable_action()
The begin_not_undoable_action
() 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 begin_not_undoable_action
() /
end_not_undoable_action
() blocks.
gtksourceview2.Buffer.can_redo
def can_redo()
Returns : | True if a redo is possible. |
The can_redo
() method Determines whether a source buffer can redo the last action
(i.e. if the last operation was an undo).
gtksourceview2.Buffer.can_undo
def can_undo()
Returns : | True if it's possible to undo the last action. |
The can_undo
() method determines whether a source buffer can undo the last action.
gtksourceview2.Buffer.create_source_mark
def create_source_mark(name
, category
, where
)
name :
| the name of the mark, or None . |
category :
| a string defining the mark category. |
where :
| location to place the mark. |
Returns : | a new
gtksourceview2.Mark
|
The create_source_mark
() method creates a mark in the
gtksourceview2.Buffer
of category
category
. A mark is semantically very similar to a
gtk.TextMark
, but organised into categories.
Like a gtk.TextMark
, a
gtksourceview2.Mark
can be anonymous if the passed name is None
.
Like a gtk.TextMark
, a
gtksourceview2.Marker
can be anonymous if the passed name
is None
.
Also, the buffer owns the markers 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.
Also, if the user deletes a region of text which contained lines with markers, those are deleted.
Typical uses for marks are bookmarks, breakpoints, current executing instruction indication in a source file, etc..
gtksourceview2.Buffer.end_not_undoable_action
def end_not_undoable_action()
The end_not_undoable_action
() method 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.
gtksourceview2.Buffer.ensure_highlight
def ensure_highlight(start
, end
)
start :
| start of the area to highlight. |
end :
| end of the area to highlight. |
The ensure_highlight
() method forces buffer to analyze
and highlight the given area synchronously.
gtksourceview2.Buffer.forward_iter_to_source_mark
def forward_iter_to_source_mark(iter
, category
=None)
iter :
| a gtk.TextIter |
category :
| category to search for or None . |
Returns : | whether iter moved. |
The forward_iter_to_source_mark
() method moves iter to the
position of the next gtksourceview2.Mark
of the given category. Returns True
if iter was moved.
If category is None
, the previous source mark can be of any category.
gtksourceview2.Buffer.get_highlight_matching_brackets
def get_highlight_matching_brackets()
Returns : | True if the matching brackets highlight is active,
False otherwise. |
The get_highlight_matching_brackets
() method determines whether
bracket match highlighting is activated for the source buffer.
gtksourceview2.Buffer.get_highlight_syntax
def get_highlight_syntax()
Returns : | True if the source highlighting is activated in the buffer,
False otherwise. |
The get_highlight_syntax
() method determines whether
syntax highlighting is activated in the source buffer.
gtksourceview2.Buffer.get_source_marks_at_iter
def get_source_marks_at_iter(iter
, category
=None)
iter :
| a gtk.TextIter . |
category :
| category to search for or None |
Returns : | a list of gtksourceview2.Mark . |
The get_source_marks_at_iter
() method returns the list of marks
of the given category at iter. If category is None
it returns all marks at iter.
gtksourceview2.Buffer.get_source_marks_at_line
def get_source_marks_at_line(iter
, category
=None)
iter :
| a gtk.TextIter . |
category :
| category to search for or None |
Returns : | a list of gtksourceview2.Mark . |
The get_source_marks_at_line
() method returns the list of marks
of the given category at line. If category is None
it returns all marks at line.
gtksourceview2.Buffer.get_max_undo_levels
def get_max_undo_levels()
Returns : | the maximum number of possible undo levels or -1 if no limit is set. |
The get_max_undo_levels
() method determines the number
of undo levels the buffer will track for buffer edits.
gtksourceview2.Buffer.get_style_scheme
def get_style_scheme()
The get_style_scheme
() method returns the nearest marker to
the right of iter
. If there are multiple markers at the same position,
this function will always return the first one (from the internal linked list), even if starting the search exactly at its location.
You can get the others using gtksourceview2.Marker.next
().
gtksourceview2.Buffer.redo
def redo()
The redo
() method redoes the last undo operation. Use
gtksourceview2.Buffer.can_redo
to check whether a call to this function will have any effect.
gtksourceview2.Buffer.remove_source_marks
def remove_source_marks(start
, end
, category
=None)
start :
| a gtk.TextIter |
end :
| a gtk.TextIter |
category :
| category to search for or None . |
The remove_source_marks
() method remove all marks of category
between start and end from the buffer. If category is None
,
all marks in the range will be removed.
gtksourceview2.Buffer.set_highlight_matching_brackets
def set_highlight_matching_brackets(highlight
)
highlight :
| True if you want matching brackets highlighted. |
The set_highlight_matching_brackets
() method Controls the bracket
match highlighting function in the buffer. If activated, when you position your
ursor over a bracket character (a parenthesis, a square bracket, etc.) the matching
opening or closing bracket character will be highlighted.
gtksourceview2.Buffer.set_highlight_syntax
def set_highlight_syntax(highlight
)
highlight :
| True to enable syntax highlighting,
False to disable it. |
The set_highlight_syntax
() method 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 gtksourceview2.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.
gtksourceview2.Buffer.set_language
def set_language(language
)
The set_language
() method associate a
gtksourceview2.Language
with the source buffer. If language is not-None
and syntax highlighting is
enabled (see gtksourceview2.Buffer.set_highlight_syntax
()),
the syntax patterns defined in language will be used to highlight the text contained in the buffer.
If language is None
, the text contained in the buffer is not highlighted.
gtksourceview2.Buffer.set_max_undo_levels
def set_max_undo_levels(max_undo_levels
)
max_undo_levels :
| the desired maximum number of undo levels. |
The set_max_undo_levels
() method 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 new action is started whenever the function
gtk.TextBuffer.begin_user_action
is called. In general, this happens whenever the user presses any key which modifies the buffer, but the undo manager
will try to merge similar consecutive actions, such as multiple character insertions into one action.
But, inserting a newline does start a new action.
gtksourceview2.Buffer.set_style_scheme
def set_style_scheme(scheme
)
The set_style_scheme
() method sets the style scheme used by the buffer.
gtksourceview2.Buffer.undo
def undo()
The undo
() Undoes the last user action which modified the buffer. Use
gtksourceview2.Buffer.can_undo
to check whether a call to this function will have any effect.
Actions are defined as groups of operations between a call to
gtk.TextBuffer.begin_user_action
() and
gtk.TextBuffer.end_user_action
(),
or sequences of similar edits (inserts or deletes) on the same line.
Functions
gtksourceview2.iter_backward_search
def gtksourceview2.iter_backward_search(iter
, str
, flags
, limit
)
iter : |
a gtk.TextIter where the search begins.
|
str : |
search string.
|
flags : |
bitmask of flags affecting the search.
|
limit : |
location of last possible match_start, or None for start of buffer.
|
Returns : |
start of match and end of match
|
The iter_backward_search
() function is the same as the
gtksourceview2.iter_forward_search
()
function, except searches backward.
gtksourceview2.iter_forward_search
def gtksourceview2.iter_forward_search(iter
, str
, flags
, limit
)
iter : |
a gtk.TextIter where the search begins.
|
str : |
search string.
|
flags : |
bitmask of flags affecting the search.
|
limit : |
bound for the search, or None for the end of the buffer.
|
Returns : |
start of match and end of match
|
The iter_forward_search
() function searches forward for str
and returns a tuple containing gtk.TextIter
objects that point at the start and end locations of the match.
The search will not continue past limit. Note that a search is a linear or O(n) operation,
so you may wish to use limit to avoid locking up your UI on large buffers.
If the gtksourceview2.SOURCE_SEARCH_VISIBLE_ONLY flag is present, the match may have invisible text
interspersed in str. i.e. str will be a possibly-noncontiguous subsequence of the matched range.
similarly, if you specify gtksourceview2.SOURCE_SEARCH_TEXT_ONLY, the match may have pixbufs or
child widgets mixed inside the matched range. If these flags are not given, the match must be exact;
the special 0xFFFC character in str will match embedded pixbufs or child widgets. If you specify the
gtksourceview2.SOURCE_SEARCH_CASE_INSENSITIVE flag, the text will be matched regardless of what case it is in.
Same as gtk.TextIter.forward_search
(),
but supports case insensitive searching.