### Class

# GtkSource Region

#### Description [src]

    class GtkSource.Region : GObject.Object
    {
      /* No available fields */
    }

Region utility.

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 `GtkTextBuffer::insert-text` and `GtkTextBuffer::delete-range` signals to update the `GtkSourceRegion` accordingly.

To iterate through the subregions, you need to use a `GtkSourceRegionIter`, for example:

    GtkSourceRegion *region;
    GtkSourceRegionIter region_iter;

    gtk_source_region_get_start_region_iter (region, &region_iter);

    while (!gtk_source_region_iter_is_end (&region_iter))
    {
            GtkTextIter subregion_start;
            GtkTextIter subregion_end;

            if (!gtk_source_region_iter_get_subregion (&region_iter,
                                                       &subregion_start,
                                                       &subregion_end))
            {
                    break;
            }

            // Do something useful with the subregion.

            gtk_source_region_iter_next (&region_iter);
    }

    buffer: GtkSource.Buffer = GtkSource.Buffer()
    region: GtkSource.Region = GtkSource.Region(buffer=buffer)
    region_iter = region.get_start_region_iter()

    while not region_iter.is_end():
        success, start, end = region_iter.get_subregion()
        if not success:
            break

        # Do something useful with the subregion

        region_iter.next()

#### Ancestors

- GObject

#### Constructors

###### gtk_source_region_new

No description available.

#### Instance methods

###### gtk_source_region_add_region

Adds `region_to_add` to `region`.

###### gtk_source_region_add_subregion

Adds the subregion delimited by `_start` and `_end` to `region`.

###### gtk_source_region_get_bounds

Gets the `start` and `end` bounds of the `region`.

###### gtk_source_region_get_buffer

No description available.

###### gtk_source_region_get_start_region_iter

Initializes a `GtkSourceRegionIter` to the first subregion of `region`.

###### gtk_source_region_intersect_region

Returns the intersection between `region1` and `region2`.

###### gtk_source_region_intersect_subregion

Returns the intersection between `region` and the subregion delimited by `_start` and `_end`.

###### gtk_source_region_is_empty

Returns whether the `region` is empty.

###### gtk_source_region_subtract_region

Subtracts `region_to_subtract` from `region`.

###### gtk_source_region_subtract_subregion

Subtracts the subregion delimited by `_start` and `_end` from `region`.

###### gtk_source_region_to_string

Gets a string represention of `region`, for debugging purposes.

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

###### GtkSource.Region:buffer

The `GtkTextBuffer`. The `GtkSourceRegion` has a weak reference to the buffer.

#### Signals

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct GtkSourceRegionClass {
      GObjectClass parent_class;

    }

No description available.

###### Class members

`parent_class: GObjectClass`

  No description available.