Top |
A GtkSourceRegion permits to store a group of subregions of a GtkTextBuffer. GtkSourceRegion stores the subregions with pairs of GtkTextMark's, so the region is still valid after insertions and deletions in the GtkTextBuffer.
The GtkTextMark for the start of a subregion has a left gravity, while the GtkTextMark for the end of a subregion has a right gravity.
The typical use-case of GtkSourceRegion is to scan a GtkTextBuffer 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 GtkSourceRegionIter, for example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
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); } |
GtkSourceRegion *
gtk_source_region_new (GtkTextBuffer *buffer
);
Since: 3.22
GtkTextBuffer *
gtk_source_region_get_buffer (GtkSourceRegion *region
);
Since: 3.22
void gtk_source_region_add_subregion (GtkSourceRegion *region
,const GtkTextIter *_start
,const GtkTextIter *_end
);
Adds the subregion delimited by _start
and _end
to region
.
Since: 3.22
void gtk_source_region_add_region (GtkSourceRegion *region
,GtkSourceRegion *region_to_add
);
Adds region_to_add
to region
. region_to_add
is not modified.
Since: 3.22
void gtk_source_region_subtract_subregion (GtkSourceRegion *region
,const GtkTextIter *_start
,const GtkTextIter *_end
);
Subtracts the subregion delimited by _start
and _end
from region
.
Since: 3.22
void gtk_source_region_subtract_region (GtkSourceRegion *region
,GtkSourceRegion *region_to_subtract
);
Subtracts region_to_subtract
from region
. region_to_subtract
is not
modified.
region |
||
region_to_subtract |
the GtkSourceRegion to subtract from
|
[nullable] |
Since: 3.22
GtkSourceRegion * gtk_source_region_intersect_subregion (GtkSourceRegion *region
,const GtkTextIter *_start
,const GtkTextIter *_end
);
Returns the intersection between region
and the subregion delimited by
_start
and _end
. region
is not modified.
Since: 3.22
GtkSourceRegion * gtk_source_region_intersect_region (GtkSourceRegion *region1
,GtkSourceRegion *region2
);
Returns the intersection between region1
and region2
. region1
and
region2
are not modified.
region1 |
a GtkSourceRegion, or |
[nullable] |
region2 |
a GtkSourceRegion, or |
[nullable] |
Since: 3.22
gboolean
gtk_source_region_is_empty (GtkSourceRegion *region
);
Returns whether the region
is empty. A NULL
region
is considered empty.
Since: 3.22
gboolean gtk_source_region_get_bounds (GtkSourceRegion *region
,GtkTextIter *start
,GtkTextIter *end
);
Gets the start
and end
bounds of the region
.
TRUE
if start
and end
have been set successfully (if non-NULL
),
or FALSE
if the region
is empty.
Since: 3.22
void gtk_source_region_get_start_region_iter (GtkSourceRegion *region
,GtkSourceRegionIter *iter
);
Initializes a GtkSourceRegionIter to the first subregion of region
. If
region
is empty, iter
will be initialized to the end iterator.
Since: 3.22
gboolean
gtk_source_region_iter_is_end (GtkSourceRegionIter *iter
);
Since: 3.22
gboolean
gtk_source_region_iter_next (GtkSourceRegionIter *iter
);
Moves iter
to the next subregion.
TRUE
if iter
moved and is dereferenceable, or FALSE
if iter
has
been set to the end iterator.
Since: 3.22
gboolean gtk_source_region_iter_get_subregion (GtkSourceRegionIter *iter
,GtkTextIter *start
,GtkTextIter *end
);
Gets the subregion at this iterator.
TRUE
if start
and end
have been set successfully (if non-NULL
),
or FALSE
if iter
is the end iterator or if the region is empty.
Since: 3.22
gchar *
gtk_source_region_to_string (GtkSourceRegion *region
);
Gets a string represention of region
, 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.
a string represention of region
. Free
with g_free()
when no longer needed.
[transfer full][nullable]
Since: 3.22
struct GtkSourceRegionIter { };
GtkSourceRegionIter is an opaque datatype; ignore all its fields.
Initialize the iter with gtk_source_region_get_start_region_iter()
.
Since: 3.22
“buffer”
property “buffer” GtkTextBuffer *
The GtkTextBuffer. The GtkSourceRegion has a weak reference to the buffer.
Owner: GtkSourceRegion
Flags: Read / Write / Construct Only
Since: 3.22