Region#
Superclasses: Object
Region utility.
A GtkSourceRegion permits to store a group of subregions of a
TextBuffer. GtkSourceRegion stores the subregions with pairs of
TextMark's, so the region is still valid after insertions and deletions
in the TextBuffer.
The TextMark for the start of a subregion has a left gravity, while the
TextMark for the end of a subregion has a right gravity.
The typical use-case of GtkSourceRegion is to scan a 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 insert_text and
delete_range signals to update the GtkSourceRegion
accordingly.
To iterate through the subregions, you need to use a RegionIter,
for example:
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);
}
Constructors#
- class Region
- classmethod new(buffer: TextBuffer) Region#
- Parameters:
buffer – a
TextBuffer.
Methods#
- class Region
- add_region(region_to_add: Region | None = None) None#
Adds
region_to_addtoregion.region_to_addis not modified.- Parameters:
region_to_add – the
Regionto add toregion, orNone.
- add_subregion(_start: TextIter, _end: TextIter) None#
Adds the subregion delimited by
_startand_endtoregion.- Parameters:
_start – the start of the subregion.
_end – the end of the subregion.
- get_buffer() TextBuffer | None#
- get_start_region_iter() RegionIter#
Initializes a
RegionIterto the first subregion ofregion.If
regionis empty,iterwill be initialized to the end iterator.
- intersect_region(region2: Region | None = None) Region | None#
Returns the intersection between
region1andregion2.region1andregion2are not modified.- Parameters:
region2 – a
Region, orNone.
- intersect_subregion(_start: TextIter, _end: TextIter) Region | None#
Returns the intersection between
regionand the subregion delimited by_startand_end.regionis not modified.- Parameters:
_start – the start of the subregion.
_end – the end of the subregion.
- subtract_region(region_to_subtract: Region | None = None) None#
Subtracts
region_to_subtractfromregion.region_to_subtractis not modified.- Parameters:
region_to_subtract – the
Regionto subtract fromregion, orNone.
Properties#
- class Region
- props.buffer: TextBuffer#
The type of the None singleton.
Fields#
- class Region
- parent_instance#