[gtksourceview] region: rename functions to add/subtract/intersect a subregion
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] region: rename functions to add/subtract/intersect a subregion
- Date: Wed, 10 Aug 2016 18:36:09 +0000 (UTC)
commit b972501cbeb40d1a95a88a3a3d56629ce7ab5be0
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Aug 10 20:14:49 2016 +0200
region: rename functions to add/subtract/intersect a subregion
Now that add/subtract/intersect_region() functions exist, it was not
symmetric. So change the function names to be explicit.
Another possible name is "range" instead of "subregion", but "subregion"
is already used by gtk_source_region_iter_get_subregion(), so using the
same terminology is better.
The GtkSourceRegion has been made public during this development cycle,
so it is still allowed to change the API. Once the 3.22 version is
released, API stability will be guaranteed.
docs/reference/gtksourceview-3.0-sections.txt | 6 +-
.../words/gtksourcecompletionwordsbuffer.c | 26 ++++----
gtksourceview/gtksourcecontextengine.c | 8 +-
gtksourceview/gtksourceregion.c | 49 +++++++-------
gtksourceview/gtksourceregion.h | 6 +-
gtksourceview/gtksourcesearchcontext.c | 72 ++++++++++++--------
testsuite/test-region.c | 6 +-
7 files changed, 94 insertions(+), 79 deletions(-)
---
diff --git a/docs/reference/gtksourceview-3.0-sections.txt b/docs/reference/gtksourceview-3.0-sections.txt
index 5d5a403..7d381db 100644
--- a/docs/reference/gtksourceview-3.0-sections.txt
+++ b/docs/reference/gtksourceview-3.0-sections.txt
@@ -654,11 +654,11 @@ GtkSourceRegion
GtkSourceRegionIter
gtk_source_region_new
gtk_source_region_get_buffer
-gtk_source_region_add
+gtk_source_region_add_subregion
gtk_source_region_add_region
-gtk_source_region_subtract
+gtk_source_region_subtract_subregion
gtk_source_region_subtract_region
-gtk_source_region_intersect
+gtk_source_region_intersect_subregion
gtk_source_region_intersect_region
gtk_source_region_is_empty
gtk_source_region_get_bounds
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
b/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
index ff2b4ce..5a57fa7 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
@@ -329,9 +329,9 @@ idle_scan_regions (GtkSourceCompletionWordsBuffer *buffer)
gtk_source_region_iter_next (®ion_iter);
}
- gtk_source_region_subtract (buffer->priv->scan_region,
- &start,
- &stop);
+ gtk_source_region_subtract_subregion (buffer->priv->scan_region,
+ &start,
+ &stop);
if (gtk_source_region_is_empty (buffer->priv->scan_region))
{
@@ -429,7 +429,7 @@ compute_remove_region (GtkSourceCompletionWordsBuffer *buffer,
GtkSourceRegion *remove_region = gtk_source_region_new (buffer->priv->buffer);
GtkSourceRegionIter region_iter;
- gtk_source_region_add (remove_region, start, end);
+ gtk_source_region_add_subregion (remove_region, start, end);
gtk_source_region_get_start_region_iter (buffer->priv->scan_region, ®ion_iter);
@@ -442,9 +442,9 @@ compute_remove_region (GtkSourceCompletionWordsBuffer *buffer,
&scan_start,
&scan_end);
- gtk_source_region_subtract (remove_region,
- &scan_start,
- &scan_end);
+ gtk_source_region_subtract_subregion (remove_region,
+ &scan_start,
+ &scan_end);
gtk_source_region_iter_next (®ion_iter);
}
@@ -483,9 +483,9 @@ add_to_scan_region (GtkSourceCompletionWordsBuffer *buffer,
_gtk_source_completion_words_utils_adjust_region (&start_iter, &end_iter);
- gtk_source_region_add (buffer->priv->scan_region,
- &start_iter,
- &end_iter);
+ gtk_source_region_add_subregion (buffer->priv->scan_region,
+ &start_iter,
+ &end_iter);
install_initiate_scan (buffer);
}
@@ -574,9 +574,9 @@ scan_all_buffer (GtkSourceCompletionWordsBuffer *buffer)
&start,
&end);
- gtk_source_region_add (buffer->priv->scan_region,
- &start,
- &end);
+ gtk_source_region_add_subregion (buffer->priv->scan_region,
+ &start,
+ &end);
install_initiate_scan (buffer);
}
diff --git a/gtksourceview/gtksourcecontextengine.c b/gtksourceview/gtksourcecontextengine.c
index a316b17..804c314 100644
--- a/gtksourceview/gtksourcecontextengine.c
+++ b/gtksourceview/gtksourcecontextengine.c
@@ -949,7 +949,7 @@ ensure_highlighted (GtkSourceContextEngine *ce,
GtkSourceRegionIter reg_iter;
/* Get the subregions not yet highlighted. */
- region = gtk_source_region_intersect (ce->priv->refresh_region, start, end);
+ region = gtk_source_region_intersect_subregion (ce->priv->refresh_region, start, end);
if (region == NULL)
return;
@@ -969,7 +969,7 @@ ensure_highlighted (GtkSourceContextEngine *ce,
g_clear_object (®ion);
/* Remove the just highlighted region. */
- gtk_source_region_subtract (ce->priv->refresh_region, start, end);
+ gtk_source_region_subtract_subregion (ce->priv->refresh_region, start, end);
}
static GtkTextTag *
@@ -2298,7 +2298,7 @@ enable_highlight (GtkSourceContextEngine *ce,
if (enable)
{
- gtk_source_region_add (ce->priv->refresh_region, &start, &end);
+ gtk_source_region_add_subregion (ce->priv->refresh_region, &start, &end);
refresh_range (ce, &start, &end);
}
@@ -5471,7 +5471,7 @@ update_syntax (GtkSourceContextEngine *ce,
line_info_destroy (&line);
- gtk_source_region_add (ce->priv->refresh_region, &line_start, &line_end);
+ gtk_source_region_add_subregion (ce->priv->refresh_region, &line_start, &line_end);
analyzed_end = line_end_offset;
invalid = get_invalid_segment (ce);
diff --git a/gtksourceview/gtksourceregion.c b/gtksourceview/gtksourceregion.c
index 809e590..f75e574 100644
--- a/gtksourceview/gtksourceregion.c
+++ b/gtksourceview/gtksourceregion.c
@@ -397,7 +397,7 @@ gtk_source_region_clear_zero_length_subregions (GtkSourceRegion *region)
}
/**
- * gtk_source_region_add:
+ * gtk_source_region_add_subregion:
* @region: a #GtkSourceRegion.
* @_start: the start of the subregion.
* @_end: the end of the subregion.
@@ -407,9 +407,9 @@ gtk_source_region_clear_zero_length_subregions (GtkSourceRegion *region)
* Since: 3.22
*/
void
-gtk_source_region_add (GtkSourceRegion *region,
- const GtkTextIter *_start,
- const GtkTextIter *_end)
+gtk_source_region_add_subregion (GtkSourceRegion *region,
+ const GtkTextIter *_start,
+ const GtkTextIter *_end)
{
GtkSourceRegionPrivate *priv;
GList *start_node;
@@ -568,16 +568,16 @@ gtk_source_region_add_region (GtkSourceRegion *region,
break;
}
- gtk_source_region_add (region,
- &subregion_start,
- &subregion_end);
+ gtk_source_region_add_subregion (region,
+ &subregion_start,
+ &subregion_end);
gtk_source_region_iter_next (&iter);
}
}
/**
- * gtk_source_region_subtract:
+ * gtk_source_region_subtract_subregion:
* @region: a #GtkSourceRegion.
* @_start: the start of the subregion.
* @_end: the end of the subregion.
@@ -587,9 +587,9 @@ gtk_source_region_add_region (GtkSourceRegion *region,
* Since: 3.22
*/
void
-gtk_source_region_subtract (GtkSourceRegion *region,
- const GtkTextIter *_start,
- const GtkTextIter *_end)
+gtk_source_region_subtract_subregion (GtkSourceRegion *region,
+ const GtkTextIter *_start,
+ const GtkTextIter *_end)
{
GtkSourceRegionPrivate *priv;
GList *start_node;
@@ -795,9 +795,9 @@ gtk_source_region_subtract_region (GtkSourceRegion *region,
break;
}
- gtk_source_region_subtract (region,
- &subregion_start,
- &subregion_end);
+ gtk_source_region_subtract_subregion (region,
+ &subregion_start,
+ &subregion_end);
gtk_source_region_iter_next (&iter);
}
@@ -824,9 +824,10 @@ gtk_source_region_is_empty (GtkSourceRegion *region)
/* A #GtkSourceRegion can contain empty subregions. So checking the
* number of subregions is not sufficient.
- * When calling gtk_source_region_add() with equal iters, the subregion
- * is not added. But when a subregion becomes empty, due to text
- * deletion, the subregion is not removed from the #GtkSourceRegion.
+ * When calling gtk_source_region_add_subregion() with equal iters, the
+ * subregion is not added. But when a subregion becomes empty, due to
+ * text deletion, the subregion is not removed from the
+ * #GtkSourceRegion.
*/
gtk_source_region_get_start_region_iter (region, ®ion_iter);
@@ -903,7 +904,7 @@ gtk_source_region_get_bounds (GtkSourceRegion *region,
}
/**
- * gtk_source_region_intersect:
+ * gtk_source_region_intersect_subregion:
* @region: a #GtkSourceRegion.
* @_start: the start of the subregion.
* @_end: the end of the subregion.
@@ -916,9 +917,9 @@ gtk_source_region_get_bounds (GtkSourceRegion *region,
* Since: 3.22
*/
GtkSourceRegion *
-gtk_source_region_intersect (GtkSourceRegion *region,
- const GtkTextIter *_start,
- const GtkTextIter *_end)
+gtk_source_region_intersect_subregion (GtkSourceRegion *region,
+ const GtkTextIter *_start,
+ const GtkTextIter *_end)
{
GtkSourceRegionPrivate *priv;
GtkSourceRegion *new_region;
@@ -1136,9 +1137,9 @@ gtk_source_region_intersect_region (GtkSourceRegion *region1,
break;
}
- sub_intersect = gtk_source_region_intersect (region1,
- &subregion2_start,
- &subregion2_end);
+ sub_intersect = gtk_source_region_intersect_subregion (region1,
+ &subregion2_start,
+ &subregion2_end);
if (full_intersect == NULL)
{
diff --git a/gtksourceview/gtksourceregion.h b/gtksourceview/gtksourceregion.h
index a497685..a2c935f 100644
--- a/gtksourceview/gtksourceregion.h
+++ b/gtksourceview/gtksourceregion.h
@@ -75,7 +75,7 @@ GTK_SOURCE_AVAILABLE_IN_3_22
GtkTextBuffer * gtk_source_region_get_buffer (GtkSourceRegion *region);
GTK_SOURCE_AVAILABLE_IN_3_22
-void gtk_source_region_add (GtkSourceRegion *region,
+void gtk_source_region_add_subregion (GtkSourceRegion *region,
const GtkTextIter *_start,
const GtkTextIter *_end);
@@ -84,7 +84,7 @@ 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,
+void gtk_source_region_subtract_subregion (GtkSourceRegion *region,
const GtkTextIter *_start,
const GtkTextIter *_end);
@@ -93,7 +93,7 @@ void gtk_source_region_subtract_region (GtkSourceRegion *region,
GtkSourceRegion *region_to_subtract);
GTK_SOURCE_AVAILABLE_IN_3_22
-GtkSourceRegion * gtk_source_region_intersect (GtkSourceRegion *region,
+GtkSourceRegion * gtk_source_region_intersect_subregion (GtkSourceRegion *region,
const GtkTextIter *_start,
const GtkTextIter *_end);
diff --git a/gtksourceview/gtksourcesearchcontext.c b/gtksourceview/gtksourcesearchcontext.c
index 29a2e5a..1c1441b 100644
--- a/gtksourceview/gtksourcesearchcontext.c
+++ b/gtksourceview/gtksourcesearchcontext.c
@@ -1016,7 +1016,9 @@ smart_forward_search_async_step (GtkSourceSearchContext *search,
if (search->priv->scan_region != NULL)
{
- region = gtk_source_region_intersect (search->priv->scan_region, ®ion_start, &limit);
+ region = gtk_source_region_intersect_subregion (search->priv->scan_region,
+ ®ion_start,
+ &limit);
}
if (gtk_source_region_is_empty (region))
@@ -1145,7 +1147,9 @@ smart_backward_search_async_step (GtkSourceSearchContext *search,
if (search->priv->scan_region != NULL)
{
- region = gtk_source_region_intersect (search->priv->scan_region, &limit, ®ion_end);
+ region = gtk_source_region_intersect_subregion (search->priv->scan_region,
+ &limit,
+ ®ion_end);
}
if (gtk_source_region_is_empty (region))
@@ -1274,9 +1278,9 @@ adjust_subregion (GtkSourceSearchContext *search,
gtk_text_iter_forward_to_tag_toggle (&tag_end, search->priv->found_tag);
- region = gtk_source_region_intersect (search->priv->scan_region,
- &tag_start,
- &tag_end);
+ region = gtk_source_region_intersect_subregion (search->priv->scan_region,
+ &tag_start,
+ &tag_end);
if (gtk_source_region_is_empty (region))
{
@@ -1324,9 +1328,9 @@ adjust_subregion (GtkSourceSearchContext *search,
gtk_text_iter_forward_to_tag_toggle (&tag_end, search->priv->found_tag);
- region = gtk_source_region_intersect (search->priv->scan_region,
- &tag_start,
- &tag_end);
+ region = gtk_source_region_intersect_subregion (search->priv->scan_region,
+ &tag_start,
+ &tag_end);
if (gtk_source_region_is_empty (region))
{
@@ -1458,9 +1462,11 @@ remove_occurrences_in_range (GtkSourceSearchContext *search,
}
else
{
- GtkSourceRegion *region = gtk_source_region_intersect (search->priv->scan_region,
- &match_start,
- &match_end);
+ GtkSourceRegion *region;
+
+ region = gtk_source_region_intersect_subregion (search->priv->scan_region,
+ &match_start,
+ &match_end);
if (gtk_source_region_is_empty (region))
{
@@ -1504,7 +1510,7 @@ scan_subregion (GtkSourceSearchContext *search,
print_region (search->priv->scan_region);
});
- gtk_source_region_subtract (search->priv->scan_region, start, end);
+ gtk_source_region_subtract_subregion (search->priv->scan_region, start, end);
DEBUG ({
g_print ("Region to scan, after:\n");
@@ -1514,7 +1520,7 @@ scan_subregion (GtkSourceSearchContext *search,
if (search->priv->task_region != NULL)
{
- gtk_source_region_subtract (search->priv->task_region, start, end);
+ gtk_source_region_subtract_subregion (search->priv->task_region, start, end);
}
if (search_text == NULL)
@@ -1612,7 +1618,7 @@ scan_region_forward (GtkSourceSearchContext *search,
scan_subregion (search, &start, &limit);
- gtk_source_region_subtract (region, &start, &limit);
+ gtk_source_region_subtract_subregion (region, &start, &limit);
start_line = gtk_text_iter_get_line (&start);
limit_line = gtk_text_iter_get_line (&limit);
@@ -1646,7 +1652,7 @@ scan_region_backward (GtkSourceSearchContext *search,
scan_subregion (search, &limit, &end);
- gtk_source_region_subtract (region, &limit, &end);
+ gtk_source_region_subtract_subregion (region, &limit, &end);
limit_line = gtk_text_iter_get_line (&limit);
end_line = gtk_text_iter_get_line (&end);
@@ -1960,11 +1966,15 @@ regex_search_scan_chunk (GtkSourceSearchContext *search,
segment_start = stopped_at;
}
- gtk_source_region_subtract (search->priv->scan_region, chunk_start, &segment_start);
+ gtk_source_region_subtract_subregion (search->priv->scan_region,
+ chunk_start,
+ &segment_start);
if (search->priv->task_region != NULL)
{
- gtk_source_region_subtract (search->priv->task_region, chunk_start, &segment_start);
+ gtk_source_region_subtract_subregion (search->priv->task_region,
+ chunk_start,
+ &segment_start);
}
}
@@ -2080,7 +2090,9 @@ smart_forward_search_step (GtkSourceSearchContext *search,
if (search->priv->scan_region != NULL)
{
- region = gtk_source_region_intersect (search->priv->scan_region, ®ion_start, &limit);
+ region = gtk_source_region_intersect_subregion (search->priv->scan_region,
+ ®ion_start,
+ &limit);
}
if (gtk_source_region_is_empty (region))
@@ -2176,7 +2188,9 @@ smart_backward_search_step (GtkSourceSearchContext *search,
if (search->priv->scan_region != NULL)
{
- region = gtk_source_region_intersect (search->priv->scan_region, &limit, ®ion_end);
+ region = gtk_source_region_intersect_subregion (search->priv->scan_region,
+ &limit,
+ ®ion_end);
}
if (gtk_source_region_is_empty (region))
@@ -2261,7 +2275,7 @@ add_subregion_to_scan (GtkSourceSearchContext *search,
print_region (search->priv->scan_region);
});
- gtk_source_region_add (search->priv->scan_region, &start, &end);
+ gtk_source_region_add_subregion (search->priv->scan_region, &start, &end);
DEBUG ({
g_print ("add_subregion_to_scan(): region to scan, after:\n");
@@ -3116,9 +3130,9 @@ gtk_source_search_context_get_occurrence_position (GtkSourceSearchContext *searc
if (search->priv->scan_region != NULL)
{
- region = gtk_source_region_intersect (search->priv->scan_region,
- match_start,
- match_end);
+ region = gtk_source_region_intersect_subregion (search->priv->scan_region,
+ match_start,
+ match_end);
empty = gtk_source_region_is_empty (region);
@@ -3153,9 +3167,9 @@ gtk_source_search_context_get_occurrence_position (GtkSourceSearchContext *searc
if (search->priv->scan_region != NULL)
{
- region = gtk_source_region_intersect (search->priv->scan_region,
- &iter,
- match_end);
+ region = gtk_source_region_intersect_subregion (search->priv->scan_region,
+ &iter,
+ match_end);
empty = gtk_source_region_is_empty (region);
@@ -4004,9 +4018,9 @@ _gtk_source_search_context_update_highlight (GtkSourceSearchContext *search,
return;
}
- region_to_highlight = gtk_source_region_intersect (search->priv->scan_region,
- start,
- end);
+ region_to_highlight = gtk_source_region_intersect_subregion (search->priv->scan_region,
+ start,
+ end);
if (gtk_source_region_is_empty (region_to_highlight))
{
diff --git a/testsuite/test-region.c b/testsuite/test-region.c
index 07aaf38..2e0cee2 100644
--- a/testsuite/test-region.c
+++ b/testsuite/test-region.c
@@ -110,10 +110,10 @@ test_region (void)
if (ops [i][0] > 0) {
op_name = "added";
- gtk_source_region_add (region, &iter1, &iter2);
+ gtk_source_region_add_subregion (region, &iter1, &iter2);
} else {
op_name = "deleted";
- gtk_source_region_subtract (region, &iter1, &iter2);
+ gtk_source_region_subtract_subregion (region, &iter1, &iter2);
}
g_print ("%s %d-%d\n", op_name, ops [i][1], ops [i][2]);
@@ -128,7 +128,7 @@ test_region (void)
gtk_text_buffer_get_iter_at_offset (buffer, &iter2, inter [i][1]);
g_print ("intersect %d-%d\n", inter [i][0], inter [i][1]);
- intersection = gtk_source_region_intersect (region, &iter1, &iter2);
+ intersection = gtk_source_region_intersect_subregion (region, &iter1, &iter2);
if (intersection) {
region_str = gtk_source_region_to_string (region);
g_print ("%s\n", region_str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]