The typical use-case of gtksource.region.Region is to scan a gtk.text_buffer.TextBuffer chunk by
chunk, not the whole buffer at once to not block the user interface. The
gtksource.region.Region 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 gtksource.region.Region
accordingly.
To iterate through the subregions, you need to use a struct@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);
}
Region utility.
A gtksource.region.Region permits to store a group of subregions of a gtk.text_buffer.TextBuffer. gtksource.region.Region stores the subregions with pairs of gtk.text_mark.TextMark's, so the region is still valid after insertions and deletions in the gtk.text_buffer.TextBuffer.
The gtk.text_mark.TextMark for the start of a subregion has a left gravity, while the gtk.text_mark.TextMark for the end of a subregion has a right gravity.
The typical use-case of gtksource.region.Region is to scan a gtk.text_buffer.TextBuffer chunk by chunk, not the whole buffer at once to not block the user interface. The gtksource.region.Region 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 gtksource.region.Region accordingly.
To iterate through the subregions, you need to use a struct@RegionIter, for example: