gtksource.region
Module for Region class
Types 3
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 gtk.text_buffer.TextBuffer.insertText and gtk.text_buffer.TextBuffer.deleteRange signals to update the gtksource.region.Region accordingly.
To iterate through the subregions, you need to use a gtksource.region_iter.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);
}RegionGidBuilder builder()Get builder for [gtksource.region.Region] Returns: New builder objectgtk.text_buffer.TextBuffer buffer() @propertyGet `buffer` property. Returns: The [gtk.text_buffer.TextBuffer]. The #GtkSourceRegion has a weak reference to the buffer.void addRegion(gtksource.region.Region regionToAdd = null)Adds region_to_add to region.void addSubregion(gtk.text_iter.TextIter Start, gtk.text_iter.TextIter End)Adds the subregion delimited by start and end to region.bool getBounds(out gtk.text_iter.TextIter start, out gtk.text_iter.TextIter end)Gets the start and end bounds of the region.void getStartRegionIter(out gtksource.region_iter.RegionIter iter)Initializes a [gtksource.region_iter.RegionIter] to the first subregion of region.gtksource.region.Region intersectRegion(gtksource.region.Region region2 = null)Returns the intersection between region1 and region2.gtksource.region.Region intersectSubregion(gtk.text_iter.TextIter Start, gtk.text_iter.TextIter End)Returns the intersection between region and the subregion delimited by start and end.bool isEmpty()Returns whether the region is empty.void subtractRegion(gtksource.region.Region regionToSubtract = null)Subtracts region_to_subtract from region.void subtractSubregion(gtk.text_iter.TextIter Start, gtk.text_iter.TextIter End)Subtracts the subregion delimited by start and end from region.string toString_()Gets a string represention of region, for debugging purposes.Fluent builder implementation template for gtksource.region.Region
T buffer(gtk.text_buffer.TextBuffer propval)Set `buffer` property. Params: propval = The [gtk.text_buffer.TextBuffer]. The #GtkSourceRegion has a weak reference to the buffer. Returns: Builder instance for fluent chainingFluent builder for gtksource.region.Region