GtkSource.Region

g GObject.Object GObject.Object GtkSource.Region GtkSource.Region GObject.Object->GtkSource.Region

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (buffer)

add_region (region_to_add)

add_subregion (_start, _end)

get_bounds ()

get_buffer ()

get_start_region_iter ()

intersect_region (region2)

intersect_subregion (_start, _end)

is_empty ()

subtract_region (region_to_subtract)

subtract_subregion (_start, _end)

to_string ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

buffer

Gtk.TextBuffer

r/w/co

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class GtkSource.Region(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

GtkSource.RegionClass

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. The GtkSourceRegion 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 GtkSourceRegion 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, &region_iter);

while (!:obj:GtkSource.RegionIter.is_end (&region_iter)) { Gtk.TextIter subregion_start; Gtk.TextIter subregion_end;

if (!:obj:GtkSource.RegionIter.get_subregion (&region_iter, &subregion_start, &subregion_end)) { break; }

// Do something useful with the subregion.

GtkSource.RegionIter.next (&region_iter); } ```

classmethod new(buffer)
Parameters:

buffer (Gtk.TextBuffer) – a Gtk.TextBuffer.

Returns:

a new GtkSource.Region object for buffer.

Return type:

GtkSource.Region

add_region(region_to_add)
Parameters:

region_to_add (GtkSource.Region or None) – the GtkSource.Region to add to self, or None.

Adds region_to_add to self.

region_to_add is not modified.

add_subregion(_start, _end)
Parameters:

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), or False if the self is empty.

start:

iterator to initialize with the start of self, or None.

end:

iterator to initialize with the end of self, or None.

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:

Gtk.TextBuffer or None

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 or None) – a GtkSource.Region, or None.

Returns:

the intersection as a GtkSource.Region object.

Return type:

GtkSource.Region or None

Returns the intersection between self and region2.

self and region2 are not modified.

intersect_subregion(_start, _end)
Parameters:
Returns:

the intersection as a new GtkSource.Region.

Return type:

GtkSource.Region or None

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:

bool

Returns whether the self is empty.

A None self is considered empty.

subtract_region(region_to_subtract)
Parameters:

region_to_subtract (GtkSource.Region or None) – the GtkSource.Region to subtract from self, or None.

Subtracts region_to_subtract from self.

region_to_subtract is not modified.

subtract_subregion(_start, _end)
Parameters:

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:

str or None

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:

Gtk.TextBuffer

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The [class`Gtk`.TextBuffer]. The GtkSource.Region has a weak reference to the buffer.