GtkSource.Region¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class GtkSource.Region(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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. TheGtkSourceRegion
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 theGtkSourceRegion
accordingly.To iterate through the subregions, you need to use a [struct`RegionIter`], for example: ```c
GtkSource.Region
*region;GtkSource.RegionIter
region_iter;GtkSource.Region.get_start_region_iter
(region, ®ion_iter);while (!:obj:GtkSource.RegionIter.is_end (®ion_iter)) {
Gtk.TextIter
subregion_start;Gtk.TextIter
subregion_end;if (!:obj:GtkSource.RegionIter.get_subregion (®ion_iter, &subregion_start, &subregion_end)) { break; }
// Do something useful with the subregion.
GtkSource.RegionIter.next
(®ion_iter); } ```- classmethod new(buffer)¶
- Parameters:
buffer (
Gtk.TextBuffer
) – aGtk.TextBuffer
.- Returns:
a new
GtkSource.Region
object for buffer.- Return type:
- add_region(region_to_add)¶
- Parameters:
region_to_add (
GtkSource.Region
orNone
) – theGtkSource.Region
to add to self, orNone
.
Adds region_to_add to self.
region_to_add is not modified.
- add_subregion(_start, _end)¶
- Parameters:
_start (
Gtk.TextIter
) – the start of the subregion._end (
Gtk.TextIter
) – the end of the subregion.
Adds the subregion delimited by _start and _end to self.
- get_bounds()¶
- Returns:
True
if start and end have been set successfully (if non-None
), orFalse
if the self is empty.- Return type:
(
bool
, start:Gtk.TextIter
, end:Gtk.TextIter
)
Gets the start and end bounds of the self.
- get_buffer()¶
- Returns:
the
Gtk.TextBuffer
.- Return type:
- get_start_region_iter()¶
- Returns:
iterator to initialize to the first subregion.
- Return type:
iter:
GtkSource.RegionIter
Initializes a [struct`RegionIter`] to the first subregion of self.
If self is empty, iter will be initialized to the end iterator.
- intersect_region(region2)¶
- Parameters:
region2 (
GtkSource.Region
orNone
) – aGtkSource.Region
, orNone
.- Returns:
the intersection as a
GtkSource.Region
object.- Return type:
Returns the intersection between self and region2.
self and region2 are not modified.
- intersect_subregion(_start, _end)¶
- Parameters:
_start (
Gtk.TextIter
) – the start of the subregion._end (
Gtk.TextIter
) – the end of the subregion.
- Returns:
the intersection as a new
GtkSource.Region
.- Return type:
Returns the intersection between self and the subregion delimited by _start and _end.
self is not modified.
- is_empty()¶
- Returns:
whether the self is empty.
- Return type:
Returns whether the self is empty.
A
None
self is considered empty.
- subtract_region(region_to_subtract)¶
- Parameters:
region_to_subtract (
GtkSource.Region
orNone
) – theGtkSource.Region
to subtract from self, orNone
.
Subtracts region_to_subtract from self.
region_to_subtract is not modified.
- subtract_subregion(_start, _end)¶
- Parameters:
_start (
Gtk.TextIter
) – the start of the subregion._end (
Gtk.TextIter
) – the end of the subregion.
Subtracts the subregion delimited by _start and _end from self.
- to_string()¶
- Returns:
a string represention of self. Free with
GLib.free
() when no longer needed.- Return type:
Gets a string represention of self, 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.
Property Details¶
- GtkSource.Region.props.buffer¶
- Name:
buffer
- Type:
- Default Value:
- Flags:
The [class`Gtk`.TextBuffer]. The
GtkSource.Region
has a weak reference to the buffer.