[gtksourceview/wip/search-start-signal] region: add add_region() function
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/search-start-signal] region: add add_region() function
- Date: Wed, 10 Aug 2016 15:01:03 +0000 (UTC)
commit d175e3e6657a9b5454ed0f913bf3761a373091fc
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Aug 10 16:53:23 2016 +0200
region: add add_region() function
docs/reference/gtksourceview-3.0-sections.txt | 1 +
gtksourceview/gtksourceregion.c | 56 +++++++++++++++++++++++++
gtksourceview/gtksourceregion.h | 4 ++
3 files changed, 61 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtksourceview-3.0-sections.txt b/docs/reference/gtksourceview-3.0-sections.txt
index 0853431..7a4a77e 100644
--- a/docs/reference/gtksourceview-3.0-sections.txt
+++ b/docs/reference/gtksourceview-3.0-sections.txt
@@ -655,6 +655,7 @@ GtkSourceRegionIter
gtk_source_region_new
gtk_source_region_get_buffer
gtk_source_region_add
+gtk_source_region_add_region
gtk_source_region_subtract
gtk_source_region_intersect
gtk_source_region_is_empty
diff --git a/gtksourceview/gtksourceregion.c b/gtksourceview/gtksourceregion.c
index 9d3f9cd..d86fe13 100644
--- a/gtksourceview/gtksourceregion.c
+++ b/gtksourceview/gtksourceregion.c
@@ -521,6 +521,62 @@ gtk_source_region_add (GtkSourceRegion *region,
}
/**
+ * gtk_source_region_add_region:
+ * @region: a #GtkSourceRegion.
+ * @region_to_add: (nullable): the #GtkSourceRegion to add to @region, or %NULL.
+ *
+ * Adds @region_to_add to @region. @region_to_add is not modified.
+ *
+ * Since: 3.22
+ */
+void
+gtk_source_region_add_region (GtkSourceRegion *region,
+ GtkSourceRegion *region_to_add)
+{
+ GtkSourceRegionIter iter;
+ GtkTextBuffer *region_buffer;
+ GtkTextBuffer *region_to_add_buffer;
+
+ g_return_if_fail (GTK_SOURCE_IS_REGION (region));
+ g_return_if_fail (region_to_add == NULL || GTK_SOURCE_IS_REGION (region_to_add));
+
+ if (region_to_add == NULL)
+ {
+ return;
+ }
+
+ region_buffer = gtk_source_region_get_buffer (region);
+ region_to_add_buffer = gtk_source_region_get_buffer (region_to_add);
+ g_return_if_fail (region_buffer == region_to_add_buffer);
+
+ if (region_buffer == NULL)
+ {
+ return;
+ }
+
+ gtk_source_region_get_start_region_iter (region_to_add, &iter);
+
+ while (!gtk_source_region_iter_is_end (&iter))
+ {
+ GtkTextIter subregion_start;
+ GtkTextIter subregion_end;
+
+ if (!gtk_source_region_iter_get_subregion (&iter,
+ &subregion_start,
+ &subregion_end))
+ {
+ break;
+ }
+
+ gtk_source_region_add (region,
+ &subregion_start,
+ &subregion_end);
+
+ gtk_source_region_iter_next (&iter);
+ }
+}
+
+/**
* gtk_source_region_subtract:
* @region: a #GtkSourceRegion.
* @_start: the start of the subregion.
diff --git a/gtksourceview/gtksourceregion.h b/gtksourceview/gtksourceregion.h
index 6d3601a..867647c 100644
--- a/gtksourceview/gtksourceregion.h
+++ b/gtksourceview/gtksourceregion.h
@@ -80,6 +80,10 @@ void gtk_source_region_add (GtkSourceRegion *region,
const GtkTextIter *_end);
GTK_SOURCE_AVAILABLE_IN_3_22
+void gtk_source_region_add_region (GtkSourceRegion *region,
+ GtkSourceRegion *region_to_add);
+
+GTK_SOURCE_AVAILABLE_IN_3_22
void gtk_source_region_subtract (GtkSourceRegion *region,
const GtkTextIter *_start,
const GtkTextIter *_end);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]