[gtksourceview/wip/public-region] region: nename GtkTextRegion to GtkSourceRegion
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/public-region] region: nename GtkTextRegion to GtkSourceRegion
- Date: Fri, 1 Apr 2016 14:10:58 +0000 (UTC)
commit ced2e863fad0321039360b4caaed31d9d906e7e2
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Apr 1 15:44:30 2016 +0200
region: nename GtkTextRegion to GtkSourceRegion
After 14 years, better late than never.
gtktextregion.{c,h} were encoded in ISO-8859-15. So change that to be
UTF-8. (only the name in the copyright comment is affected).
.../words/gtksourcecompletionwordsbuffer.c | 124 +++++-----
gtksourceview/gtksourcecontextengine.c | 28 +-
gtksourceview/gtksourcesearchcontext.c | 262 ++++++++++----------
gtksourceview/gtktextregion.c | 111 +++++----
gtksourceview/gtktextregion.h | 72 +++---
testsuite/test-region.c | 40 ++--
6 files changed, 320 insertions(+), 317 deletions(-)
---
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
b/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
index e80a384..af86c52 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwordsbuffer.c
@@ -41,7 +41,7 @@ struct _GtkSourceCompletionWordsBufferPrivate
GtkSourceCompletionWordsLibrary *library;
GtkTextBuffer *buffer;
- GtkTextRegion *scan_region;
+ GtkSourceRegion *scan_region;
gulong batch_scan_id;
gulong initiate_scan_id;
@@ -110,7 +110,7 @@ gtk_source_completion_words_buffer_dispose (GObject *object)
if (buffer->priv->scan_region != NULL)
{
- gtk_text_region_destroy (buffer->priv->scan_region);
+ gtk_source_region_destroy (buffer->priv->scan_region);
buffer->priv->scan_region = NULL;
}
@@ -304,32 +304,32 @@ scan_region (GtkSourceCompletionWordsBuffer *buffer,
/* A TextRegion can contain empty subregions. So checking the number of
* subregions is not sufficient.
- * When calling gtk_text_region_add() with equal iters, the subregion is not
+ * 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 TextRegion.
*/
static gboolean
-is_text_region_empty (GtkTextRegion *region)
+is_text_region_empty (GtkSourceRegion *region)
{
- GtkTextRegionIterator region_iter;
+ GtkSourceRegionIterator region_iter;
- gtk_text_region_get_iterator (region, ®ion_iter, 0);
+ gtk_source_region_get_iterator (region, ®ion_iter, 0);
- while (!gtk_text_region_iterator_is_end (®ion_iter))
+ while (!gtk_source_region_iterator_is_end (®ion_iter))
{
GtkTextIter region_start;
GtkTextIter region_end;
- gtk_text_region_iterator_get_subregion (®ion_iter,
- ®ion_start,
- ®ion_end);
+ gtk_source_region_iterator_get_subregion (®ion_iter,
+ ®ion_start,
+ ®ion_end);
if (!gtk_text_iter_equal (®ion_start, ®ion_end))
{
return FALSE;
}
- gtk_text_region_iterator_next (®ion_iter);
+ gtk_source_region_iterator_next (®ion_iter);
}
return TRUE;
@@ -339,26 +339,26 @@ static gboolean
idle_scan_regions (GtkSourceCompletionWordsBuffer *buffer)
{
guint nb_remaining_lines = buffer->priv->scan_batch_size;
- GtkTextRegionIterator region_iter;
+ GtkSourceRegionIterator region_iter;
GtkTextIter start;
GtkTextIter stop;
gtk_text_buffer_get_start_iter (buffer->priv->buffer, &start);
stop = start;
- gtk_text_region_get_iterator (buffer->priv->scan_region,
- ®ion_iter,
- 0);
+ gtk_source_region_get_iterator (buffer->priv->scan_region,
+ ®ion_iter,
+ 0);
while (nb_remaining_lines > 0 &&
- !gtk_text_region_iterator_is_end (®ion_iter))
+ !gtk_source_region_iterator_is_end (®ion_iter))
{
GtkTextIter region_start;
GtkTextIter region_end;
- gtk_text_region_iterator_get_subregion (®ion_iter,
- ®ion_start,
- ®ion_end);
+ gtk_source_region_iterator_get_subregion (®ion_iter,
+ ®ion_start,
+ ®ion_end);
nb_remaining_lines -= scan_region (buffer,
®ion_start,
@@ -366,12 +366,12 @@ idle_scan_regions (GtkSourceCompletionWordsBuffer *buffer)
nb_remaining_lines,
&stop);
- gtk_text_region_iterator_next (®ion_iter);
+ gtk_source_region_iterator_next (®ion_iter);
}
- gtk_text_region_subtract (buffer->priv->scan_region,
- &start,
- &stop);
+ gtk_source_region_subtract (buffer->priv->scan_region,
+ &start,
+ &stop);
if (is_text_region_empty (buffer->priv->scan_region))
{
@@ -438,57 +438,57 @@ remove_words_in_subregion (GtkSourceCompletionWordsBuffer *buffer,
static void
remove_words_in_region (GtkSourceCompletionWordsBuffer *buffer,
- GtkTextRegion *region)
+ GtkSourceRegion *region)
{
- GtkTextRegionIterator region_iter;
+ GtkSourceRegionIterator region_iter;
- gtk_text_region_get_iterator (region, ®ion_iter, 0);
+ gtk_source_region_get_iterator (region, ®ion_iter, 0);
- while (!gtk_text_region_iterator_is_end (®ion_iter))
+ while (!gtk_source_region_iterator_is_end (®ion_iter))
{
GtkTextIter subregion_start;
GtkTextIter subregion_end;
- gtk_text_region_iterator_get_subregion (®ion_iter,
- &subregion_start,
- &subregion_end);
+ gtk_source_region_iterator_get_subregion (®ion_iter,
+ &subregion_start,
+ &subregion_end);
remove_words_in_subregion (buffer,
&subregion_start,
&subregion_end);
- gtk_text_region_iterator_next (®ion_iter);
+ gtk_source_region_iterator_next (®ion_iter);
}
}
-static GtkTextRegion *
+static GtkSourceRegion *
compute_remove_region (GtkSourceCompletionWordsBuffer *buffer,
const GtkTextIter *start,
const GtkTextIter *end)
{
- GtkTextRegion *remove_region = gtk_text_region_new (buffer->priv->buffer);
- GtkTextRegionIterator region_iter;
+ GtkSourceRegion *remove_region = gtk_source_region_new (buffer->priv->buffer);
+ GtkSourceRegionIterator region_iter;
- gtk_text_region_add (remove_region, start, end);
+ gtk_source_region_add (remove_region, start, end);
- gtk_text_region_get_iterator (buffer->priv->scan_region,
- ®ion_iter,
- 0);
+ gtk_source_region_get_iterator (buffer->priv->scan_region,
+ ®ion_iter,
+ 0);
- while (!gtk_text_region_iterator_is_end (®ion_iter))
+ while (!gtk_source_region_iterator_is_end (®ion_iter))
{
GtkTextIter scan_start;
GtkTextIter scan_end;
- gtk_text_region_iterator_get_subregion (®ion_iter,
- &scan_start,
- &scan_end);
+ gtk_source_region_iterator_get_subregion (®ion_iter,
+ &scan_start,
+ &scan_end);
- gtk_text_region_subtract (remove_region,
- &scan_start,
- &scan_end);
+ gtk_source_region_subtract (remove_region,
+ &scan_start,
+ &scan_end);
- gtk_text_region_iterator_next (®ion_iter);
+ gtk_source_region_iterator_next (®ion_iter);
}
return remove_region;
@@ -505,14 +505,14 @@ invalidate_region (GtkSourceCompletionWordsBuffer *buffer,
{
GtkTextIter start_iter = *start;
GtkTextIter end_iter = *end;
- GtkTextRegion *remove_region;
+ GtkSourceRegion *remove_region;
_gtk_source_completion_words_utils_adjust_region (&start_iter, &end_iter);
remove_region = compute_remove_region (buffer, &start_iter, &end_iter);
remove_words_in_region (buffer, remove_region);
- gtk_text_region_destroy (remove_region);
+ gtk_source_region_destroy (remove_region);
}
static void
@@ -525,9 +525,9 @@ add_to_scan_region (GtkSourceCompletionWordsBuffer *buffer,
_gtk_source_completion_words_utils_adjust_region (&start_iter, &end_iter);
- gtk_text_region_add (buffer->priv->scan_region,
- &start_iter,
- &end_iter);
+ gtk_source_region_add (buffer->priv->scan_region,
+ &start_iter,
+ &end_iter);
install_initiate_scan (buffer);
}
@@ -555,9 +555,9 @@ on_insert_text_after_cb (GtkTextBuffer *textbuffer,
gtk_text_iter_backward_chars (&start_iter, nb_chars);
/* If add_to_scan_region() is called before the text insertion, the
- * created GtkTextRegion can be empty and is thus not added to the
+ * created GtkSourceRegion can be empty and is thus not added to the
* scan region. After the text insertion, we are sure that the
- * GtkTextRegion is not empty and that the words will be scanned.
+ * GtkSourceRegion is not empty and that the words will be scanned.
*/
add_to_scan_region (buffer, &start_iter, location);
}
@@ -579,8 +579,8 @@ on_delete_range_before_cb (GtkTextBuffer *text_buffer,
{
remove_all_words (buffer);
- gtk_text_region_destroy (buffer->priv->scan_region);
- buffer->priv->scan_region = gtk_text_region_new (text_buffer);
+ gtk_source_region_destroy (buffer->priv->scan_region);
+ buffer->priv->scan_region = gtk_source_region_new (text_buffer);
}
else
{
@@ -597,9 +597,9 @@ on_delete_range_after_cb (GtkTextBuffer *text_buffer,
/* start = end, but add_to_scan_region() adjusts the iters to word
* boundaries if needed. If the adjusted [start,end] region is empty, it
* won't be added to the scan region. If we call add_to_scan_region()
- * when the text is not already deleted, the GtkTextRegion is not empty
- * and will be added to the scan region, and when the GtkTextRegion
- * becomes empty after the text deletion, the GtkTextRegion is not
+ * when the text is not already deleted, the GtkSourceRegion is not empty
+ * and will be added to the scan region, and when the GtkSourceRegion
+ * becomes empty after the text deletion, the GtkSourceRegion is not
* removed from the scan region. Hence two callbacks: before and after
* the text deletion.
*/
@@ -616,9 +616,9 @@ scan_all_buffer (GtkSourceCompletionWordsBuffer *buffer)
&start,
&end);
- gtk_text_region_add (buffer->priv->scan_region,
- &start,
- &end);
+ gtk_source_region_add (buffer->priv->scan_region,
+ &start,
+ &end);
install_initiate_scan (buffer);
}
@@ -692,7 +692,7 @@ gtk_source_completion_words_buffer_new (GtkSourceCompletionWordsLibrary *library
ret->priv->library = g_object_ref (library);
ret->priv->buffer = g_object_ref (buffer);
- ret->priv->scan_region = gtk_text_region_new (buffer);
+ ret->priv->scan_region = gtk_source_region_new (buffer);
g_signal_connect_object (ret->priv->library,
"lock",
diff --git a/gtksourceview/gtksourcecontextengine.c b/gtksourceview/gtksourcecontextengine.c
index 22e7787..0ca0830 100644
--- a/gtksourceview/gtksourcecontextengine.c
+++ b/gtksourceview/gtksourcecontextengine.c
@@ -439,7 +439,7 @@ struct _GtkSourceContextEnginePrivate
gboolean disabled;
/* Region covering the unhighlighted text. */
- GtkTextRegion *refresh_region;
+ GtkSourceRegion *refresh_region;
/* Tree of contexts. */
Context *root_context;
@@ -945,31 +945,31 @@ ensure_highlighted (GtkSourceContextEngine *ce,
const GtkTextIter *start,
const GtkTextIter *end)
{
- GtkTextRegion *region;
- GtkTextRegionIterator reg_iter;
+ GtkSourceRegion *region;
+ GtkSourceRegionIterator reg_iter;
/* Get the subregions not yet highlighted. */
- region = gtk_text_region_intersect (ce->priv->refresh_region, start, end);
+ region = gtk_source_region_intersect (ce->priv->refresh_region, start, end);
if (region == NULL)
return;
- gtk_text_region_get_iterator (region, ®_iter, 0);
+ gtk_source_region_get_iterator (region, ®_iter, 0);
/* Highlight all subregions from the intersection.
* hopefully this will only be one subregion. */
- while (!gtk_text_region_iterator_is_end (®_iter))
+ while (!gtk_source_region_iterator_is_end (®_iter))
{
GtkTextIter s, e;
- gtk_text_region_iterator_get_subregion (®_iter, &s, &e);
+ gtk_source_region_iterator_get_subregion (®_iter, &s, &e);
highlight_region (ce, &s, &e);
- gtk_text_region_iterator_next (®_iter);
+ gtk_source_region_iterator_next (®_iter);
}
- gtk_text_region_destroy (region);
+ gtk_source_region_destroy (region);
/* Remove the just highlighted region. */
- gtk_text_region_subtract (ce->priv->refresh_region, start, end);
+ gtk_source_region_subtract (ce->priv->refresh_region, start, end);
}
static GtkTextTag *
@@ -2298,7 +2298,7 @@ enable_highlight (GtkSourceContextEngine *ce,
if (enable)
{
- gtk_text_region_add (ce->priv->refresh_region, &start, &end);
+ gtk_source_region_add (ce->priv->refresh_region, &start, &end);
refresh_range (ce, &start, &end);
}
@@ -2560,7 +2560,7 @@ gtk_source_context_engine_attach_buffer (GtkSourceEngine *engine,
destroy_context_classes_list (ce);
if (ce->priv->refresh_region != NULL)
- gtk_text_region_destroy (ce->priv->refresh_region);
+ gtk_source_region_destroy (ce->priv->refresh_region);
ce->priv->refresh_region = NULL;
}
@@ -2601,7 +2601,7 @@ gtk_source_context_engine_attach_buffer (GtkSourceEngine *engine,
}
g_object_get (buffer, "highlight-syntax", &ce->priv->highlight, NULL);
- ce->priv->refresh_region = gtk_text_region_new (buffer);
+ ce->priv->refresh_region = gtk_source_region_new (buffer);
g_signal_connect_swapped (buffer,
"notify::highlight-syntax",
@@ -5477,7 +5477,7 @@ update_syntax (GtkSourceContextEngine *ce,
line_info_destroy (&line);
- gtk_text_region_add (ce->priv->refresh_region, &line_start, &line_end);
+ gtk_source_region_add (ce->priv->refresh_region, &line_start, &line_end);
analyzed_end = line_end_offset;
invalid = get_invalid_segment (ce);
diff --git a/gtksourceview/gtksourcesearchcontext.c b/gtksourceview/gtksourcesearchcontext.c
index 614c216..cdad5d7 100644
--- a/gtksourceview/gtksourcesearchcontext.c
+++ b/gtksourceview/gtksourcesearchcontext.c
@@ -325,18 +325,18 @@ struct _GtkSourceSearchContextPrivate
GtkTextTagTable *tag_table;
/* The region to scan and highlight. If NULL, the scan is finished. */
- GtkTextRegion *scan_region;
+ GtkSourceRegion *scan_region;
/* The region to scan and highlight in priority. I.e. the visible part
* of the buffer on the screen.
*/
- GtkTextRegion *high_priority_region;
+ GtkSourceRegion *high_priority_region;
/* An asynchronous running task. task_region has a higher priority than
* scan_region, but a lower priority than high_priority_region.
*/
GTask *task;
- GtkTextRegion *task_region;
+ GtkSourceRegion *task_region;
/* If the regex search is disabled, text_nb_lines is the number of lines
* of the search text. It is useful to adjust the region to scan.
@@ -419,30 +419,30 @@ text_tag_set_highest_priority (GtkTextTag *tag,
/* A TextRegion can contain empty subregions. So checking the number of
* subregions is not sufficient.
- * When calling gtk_text_region_add() with equal iters, the subregion is not
+ * 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 TextRegion.
*/
static gboolean
-is_text_region_empty (GtkTextRegion *region)
+is_text_region_empty (GtkSourceRegion *region)
{
- GtkTextRegionIterator region_iter;
+ GtkSourceRegionIterator region_iter;
if (region == NULL)
{
return TRUE;
}
- gtk_text_region_get_iterator (region, ®ion_iter, 0);
+ gtk_source_region_get_iterator (region, ®ion_iter, 0);
- while (!gtk_text_region_iterator_is_end (®ion_iter))
+ while (!gtk_source_region_iterator_is_end (®ion_iter))
{
GtkTextIter region_start;
GtkTextIter region_end;
- if (!gtk_text_region_iterator_get_subregion (®ion_iter,
- ®ion_start,
- ®ion_end))
+ if (!gtk_source_region_iterator_get_subregion (®ion_iter,
+ ®ion_start,
+ ®ion_end))
{
return TRUE;
}
@@ -452,7 +452,7 @@ is_text_region_empty (GtkTextRegion *region)
return FALSE;
}
- gtk_text_region_iterator_next (®ion_iter);
+ gtk_source_region_iterator_next (®ion_iter);
}
return TRUE;
@@ -462,22 +462,22 @@ is_text_region_empty (GtkTextRegion *region)
* Returns FALSE if the region is empty.
*/
static gboolean
-get_first_subregion (GtkTextRegion *region,
+get_first_subregion (GtkSourceRegion *region,
GtkTextIter *start,
GtkTextIter *end)
{
- GtkTextRegionIterator region_iter;
+ GtkSourceRegionIterator region_iter;
if (region == NULL)
{
return FALSE;
}
- gtk_text_region_get_iterator (region, ®ion_iter, 0);
+ gtk_source_region_get_iterator (region, ®ion_iter, 0);
- while (!gtk_text_region_iterator_is_end (®ion_iter))
+ while (!gtk_source_region_iterator_is_end (®ion_iter))
{
- if (!gtk_text_region_iterator_get_subregion (®ion_iter, start, end))
+ if (!gtk_source_region_iterator_get_subregion (®ion_iter, start, end))
{
return FALSE;
}
@@ -487,7 +487,7 @@ get_first_subregion (GtkTextRegion *region,
return TRUE;
}
- gtk_text_region_iterator_next (®ion_iter);
+ gtk_source_region_iterator_next (®ion_iter);
}
return FALSE;
@@ -497,11 +497,11 @@ get_first_subregion (GtkTextRegion *region,
* Returns FALSE if the region is empty.
*/
static gboolean
-get_last_subregion (GtkTextRegion *region,
+get_last_subregion (GtkSourceRegion *region,
GtkTextIter *start,
GtkTextIter *end)
{
- GtkTextRegionIterator region_iter;
+ GtkSourceRegionIterator region_iter;
gboolean found = FALSE;
if (region == NULL)
@@ -509,16 +509,16 @@ get_last_subregion (GtkTextRegion *region,
return FALSE;
}
- gtk_text_region_get_iterator (region, ®ion_iter, 0);
+ gtk_source_region_get_iterator (region, ®ion_iter, 0);
- while (!gtk_text_region_iterator_is_end (®ion_iter))
+ while (!gtk_source_region_iterator_is_end (®ion_iter))
{
GtkTextIter start_subregion;
GtkTextIter end_subregion;
- if (!gtk_text_region_iterator_get_subregion (®ion_iter,
- &start_subregion,
- &end_subregion))
+ if (!gtk_source_region_iterator_get_subregion (®ion_iter,
+ &start_subregion,
+ &end_subregion))
{
return FALSE;
}
@@ -530,7 +530,7 @@ get_last_subregion (GtkTextRegion *region,
*end = end_subregion;
}
- gtk_text_region_iterator_next (®ion_iter);
+ gtk_source_region_iterator_next (®ion_iter);
}
return found;
@@ -541,7 +541,7 @@ clear_task (GtkSourceSearchContext *search)
{
if (search->priv->task_region != NULL)
{
- gtk_text_region_destroy (search->priv->task_region);
+ gtk_source_region_destroy (search->priv->task_region);
search->priv->task_region = NULL;
}
@@ -564,13 +564,13 @@ clear_search (GtkSourceSearchContext *search)
{
if (search->priv->scan_region != NULL)
{
- gtk_text_region_destroy (search->priv->scan_region);
+ gtk_source_region_destroy (search->priv->scan_region);
search->priv->scan_region = NULL;
}
if (search->priv->high_priority_region != NULL)
{
- gtk_text_region_destroy (search->priv->high_priority_region);
+ gtk_source_region_destroy (search->priv->high_priority_region);
search->priv->high_priority_region = NULL;
}
@@ -1013,7 +1013,7 @@ smart_forward_search_async_step (GtkSourceSearchContext *search,
GtkTextIter iter = *start_at;
GtkTextIter limit;
GtkTextIter region_start = *start_at;
- GtkTextRegion *region = NULL;
+ GtkSourceRegion *region = NULL;
ForwardBackwardData *task_data;
const gchar *search_text = gtk_source_search_settings_get_search_text (search->priv->settings);
@@ -1056,7 +1056,7 @@ smart_forward_search_async_step (GtkSourceSearchContext *search,
if (search->priv->scan_region != NULL)
{
- region = gtk_text_region_intersect (search->priv->scan_region, ®ion_start, &limit);
+ region = gtk_source_region_intersect (search->priv->scan_region, ®ion_start, &limit);
}
if (is_text_region_empty (region))
@@ -1066,7 +1066,7 @@ smart_forward_search_async_step (GtkSourceSearchContext *search,
if (region != NULL)
{
- gtk_text_region_destroy (region);
+ gtk_source_region_destroy (region);
}
while (basic_forward_search (search, &iter, &match_start, &match_end, &limit))
@@ -1110,7 +1110,7 @@ smart_forward_search_async_step (GtkSourceSearchContext *search,
if (search->priv->task_region != NULL)
{
- gtk_text_region_destroy (search->priv->task_region);
+ gtk_source_region_destroy (search->priv->task_region);
}
search->priv->task_region = region;
@@ -1147,7 +1147,7 @@ smart_backward_search_async_step (GtkSourceSearchContext *search,
GtkTextIter iter = *start_at;
GtkTextIter limit;
GtkTextIter region_end = *start_at;
- GtkTextRegion *region = NULL;
+ GtkSourceRegion *region = NULL;
ForwardBackwardData *task_data;
const gchar *search_text = gtk_source_search_settings_get_search_text (search->priv->settings);
@@ -1192,7 +1192,7 @@ smart_backward_search_async_step (GtkSourceSearchContext *search,
if (search->priv->scan_region != NULL)
{
- region = gtk_text_region_intersect (search->priv->scan_region, &limit, ®ion_end);
+ region = gtk_source_region_intersect (search->priv->scan_region, &limit, ®ion_end);
}
if (is_text_region_empty (region))
@@ -1202,7 +1202,7 @@ smart_backward_search_async_step (GtkSourceSearchContext *search,
if (region != NULL)
{
- gtk_text_region_destroy (region);
+ gtk_source_region_destroy (region);
}
while (basic_backward_search (search, &iter, &match_start, &match_end, &limit))
@@ -1246,7 +1246,7 @@ smart_backward_search_async_step (GtkSourceSearchContext *search,
if (search->priv->task_region != NULL)
{
- gtk_text_region_destroy (search->priv->task_region);
+ gtk_source_region_destroy (search->priv->task_region);
}
search->priv->task_region = region;
@@ -1319,7 +1319,7 @@ adjust_subregion (GtkSourceSearchContext *search,
{
GtkTextIter tag_start = *start;
GtkTextIter tag_end = *start;
- GtkTextRegion *region;
+ GtkSourceRegion *region;
if (!gtk_text_iter_starts_tag (&tag_start, search->priv->found_tag))
{
@@ -1328,9 +1328,9 @@ adjust_subregion (GtkSourceSearchContext *search,
gtk_text_iter_forward_to_tag_toggle (&tag_end, search->priv->found_tag);
- region = gtk_text_region_intersect (search->priv->scan_region,
- &tag_start,
- &tag_end);
+ region = gtk_source_region_intersect (search->priv->scan_region,
+ &tag_start,
+ &tag_end);
if (is_text_region_empty (region))
{
@@ -1350,7 +1350,7 @@ adjust_subregion (GtkSourceSearchContext *search,
if (region != NULL)
{
- gtk_text_region_destroy (region);
+ gtk_source_region_destroy (region);
}
}
}
@@ -1372,7 +1372,7 @@ adjust_subregion (GtkSourceSearchContext *search,
{
GtkTextIter tag_start = *end;
GtkTextIter tag_end = *end;
- GtkTextRegion *region;
+ GtkSourceRegion *region;
if (!gtk_text_iter_starts_tag (&tag_start, search->priv->found_tag))
{
@@ -1381,9 +1381,9 @@ adjust_subregion (GtkSourceSearchContext *search,
gtk_text_iter_forward_to_tag_toggle (&tag_end, search->priv->found_tag);
- region = gtk_text_region_intersect (search->priv->scan_region,
- &tag_start,
- &tag_end);
+ region = gtk_source_region_intersect (search->priv->scan_region,
+ &tag_start,
+ &tag_end);
if (is_text_region_empty (region))
{
@@ -1403,7 +1403,7 @@ adjust_subregion (GtkSourceSearchContext *search,
if (region != NULL)
{
- gtk_text_region_destroy (region);
+ gtk_source_region_destroy (region);
}
}
}
@@ -1514,9 +1514,9 @@ remove_occurrences_in_range (GtkSourceSearchContext *search,
}
else
{
- GtkTextRegion *region = gtk_text_region_intersect (search->priv->scan_region,
- &match_start,
- &match_end);
+ GtkSourceRegion *region = gtk_source_region_intersect (search->priv->scan_region,
+ &match_start,
+ &match_end);
if (is_text_region_empty (region))
{
@@ -1525,7 +1525,7 @@ remove_occurrences_in_range (GtkSourceSearchContext *search,
if (region != NULL)
{
- gtk_text_region_destroy (region);
+ gtk_source_region_destroy (region);
}
}
@@ -1560,20 +1560,20 @@ scan_subregion (GtkSourceSearchContext *search,
{
DEBUG ({
g_print ("Region to scan, before:\n");
- gtk_text_region_debug_print (search->priv->scan_region);
+ gtk_source_region_debug_print (search->priv->scan_region);
});
- gtk_text_region_subtract (search->priv->scan_region, start, end);
+ gtk_source_region_subtract (search->priv->scan_region, start, end);
DEBUG ({
g_print ("Region to scan, after:\n");
- gtk_text_region_debug_print (search->priv->scan_region);
+ gtk_source_region_debug_print (search->priv->scan_region);
});
}
if (search->priv->task_region != NULL)
{
- gtk_text_region_subtract (search->priv->task_region, start, end);
+ gtk_source_region_subtract (search->priv->task_region, start, end);
}
if (search_text == NULL)
@@ -1617,9 +1617,9 @@ scan_subregion (GtkSourceSearchContext *search,
static void
scan_all_region (GtkSourceSearchContext *search,
- GtkTextRegion *region_to_highlight)
+ GtkSourceRegion *region_to_highlight)
{
- gint nb_subregions = gtk_text_region_subregions (region_to_highlight);
+ gint nb_subregions = gtk_source_region_subregions (region_to_highlight);
GtkTextIter start_search;
GtkTextIter end_search;
@@ -1628,18 +1628,18 @@ scan_all_region (GtkSourceSearchContext *search,
return;
}
- if (!gtk_text_region_nth_subregion (region_to_highlight,
- 0,
- &start_search,
- NULL))
+ if (!gtk_source_region_nth_subregion (region_to_highlight,
+ 0,
+ &start_search,
+ NULL))
{
return;
}
- if (!gtk_text_region_nth_subregion (region_to_highlight,
- nb_subregions - 1,
- NULL,
- &end_search))
+ if (!gtk_source_region_nth_subregion (region_to_highlight,
+ nb_subregions - 1,
+ NULL,
+ &end_search))
{
return;
}
@@ -1655,7 +1655,7 @@ scan_all_region (GtkSourceSearchContext *search,
*/
static void
scan_region_forward (GtkSourceSearchContext *search,
- GtkTextRegion *region)
+ GtkSourceRegion *region)
{
gint nb_remaining_lines = SCAN_BATCH_SIZE;
GtkTextIter start;
@@ -1677,7 +1677,7 @@ scan_region_forward (GtkSourceSearchContext *search,
scan_subregion (search, &start, &limit);
- gtk_text_region_subtract (region, &start, &limit);
+ gtk_source_region_subtract (region, &start, &limit);
start_line = gtk_text_iter_get_line (&start);
limit_line = gtk_text_iter_get_line (&limit);
@@ -1689,7 +1689,7 @@ scan_region_forward (GtkSourceSearchContext *search,
/* Same as scan_region_forward(), but begins the scan at the end of the region. */
static void
scan_region_backward (GtkSourceSearchContext *search,
- GtkTextRegion *region)
+ GtkSourceRegion *region)
{
gint nb_remaining_lines = SCAN_BATCH_SIZE;
GtkTextIter start;
@@ -1711,7 +1711,7 @@ scan_region_backward (GtkSourceSearchContext *search,
scan_subregion (search, &limit, &end);
- gtk_text_region_subtract (region, &limit, &end);
+ gtk_source_region_subtract (region, &limit, &end);
limit_line = gtk_text_iter_get_line (&limit);
end_line = gtk_text_iter_get_line (&end);
@@ -1728,7 +1728,7 @@ resume_task (GtkSourceSearchContext *search)
if (search->priv->task_region != NULL)
{
- gtk_text_region_destroy (search->priv->task_region);
+ gtk_source_region_destroy (search->priv->task_region);
search->priv->task_region = NULL;
}
@@ -1778,7 +1778,7 @@ idle_scan_normal_search (GtkSourceSearchContext *search)
*/
scan_all_region (search, search->priv->high_priority_region);
- gtk_text_region_destroy (search->priv->high_priority_region);
+ gtk_source_region_destroy (search->priv->high_priority_region);
search->priv->high_priority_region = NULL;
return G_SOURCE_CONTINUE;
@@ -1800,7 +1800,7 @@ idle_scan_normal_search (GtkSourceSearchContext *search)
if (search->priv->scan_region != NULL)
{
- gtk_text_region_destroy (search->priv->scan_region);
+ gtk_source_region_destroy (search->priv->scan_region);
search->priv->scan_region = NULL;
}
@@ -1823,45 +1823,45 @@ regex_search_handle_high_priority_region (GtkSourceSearchContext *search)
{
GtkTextIter start;
GtkTextIter end;
- GtkTextRegion *region;
- GtkTextRegionIterator region_iter;
- gint nb_subregions = gtk_text_region_subregions (search->priv->high_priority_region);
+ GtkSourceRegion *region;
+ GtkSourceRegionIterator region_iter;
+ gint nb_subregions = gtk_source_region_subregions (search->priv->high_priority_region);
if (nb_subregions == 0)
{
return;
}
- if (!gtk_text_region_nth_subregion (search->priv->high_priority_region,
- 0,
- &start,
- NULL))
+ if (!gtk_source_region_nth_subregion (search->priv->high_priority_region,
+ 0,
+ &start,
+ NULL))
{
return;
}
- if (!gtk_text_region_nth_subregion (search->priv->high_priority_region,
- nb_subregions - 1,
- NULL,
- &end))
+ if (!gtk_source_region_nth_subregion (search->priv->high_priority_region,
+ nb_subregions - 1,
+ NULL,
+ &end))
{
return;
}
- region = gtk_text_region_intersect (search->priv->scan_region,
- &start,
- &end);
+ region = gtk_source_region_intersect (search->priv->scan_region,
+ &start,
+ &end);
- gtk_text_region_get_iterator (region, ®ion_iter, 0);
+ gtk_source_region_get_iterator (region, ®ion_iter, 0);
- while (!gtk_text_region_iterator_is_end (®ion_iter))
+ while (!gtk_source_region_iterator_is_end (®ion_iter))
{
GtkTextIter subregion_start;
GtkTextIter subregion_end;
- if (!gtk_text_region_iterator_get_subregion (®ion_iter,
- &subregion_start,
- &subregion_end))
+ if (!gtk_source_region_iterator_get_subregion (®ion_iter,
+ &subregion_start,
+ &subregion_end))
{
return;
}
@@ -1871,10 +1871,10 @@ regex_search_handle_high_priority_region (GtkSourceSearchContext *search)
&subregion_start,
&subregion_end);
- gtk_text_region_iterator_next (®ion_iter);
+ gtk_source_region_iterator_next (®ion_iter);
}
- gtk_text_region_destroy (region);
+ gtk_source_region_destroy (region);
}
/* Returns TRUE if the segment is finished, and FALSE on partial match. */
@@ -2056,11 +2056,11 @@ regex_search_scan_chunk (GtkSourceSearchContext *search,
segment_start = stopped_at;
}
- gtk_text_region_subtract (search->priv->scan_region, chunk_start, &segment_start);
+ gtk_source_region_subtract (search->priv->scan_region, chunk_start, &segment_start);
if (search->priv->task_region != NULL)
{
- gtk_text_region_subtract (search->priv->task_region, chunk_start, &segment_start);
+ gtk_source_region_subtract (search->priv->task_region, chunk_start, &segment_start);
}
}
@@ -2075,7 +2075,7 @@ regex_search_scan_next_chunk (GtkSourceSearchContext *search)
return;
}
- if (!gtk_text_region_nth_subregion (search->priv->scan_region, 0, &chunk_start, NULL))
+ if (!gtk_source_region_nth_subregion (search->priv->scan_region, 0, &chunk_start, NULL))
{
return;
}
@@ -2093,7 +2093,7 @@ idle_scan_regex_search (GtkSourceSearchContext *search)
{
regex_search_handle_high_priority_region (search);
- gtk_text_region_destroy (search->priv->high_priority_region);
+ gtk_source_region_destroy (search->priv->high_priority_region);
search->priv->high_priority_region = NULL;
return G_SOURCE_CONTINUE;
@@ -2123,7 +2123,7 @@ idle_scan_regex_search (GtkSourceSearchContext *search)
if (search->priv->scan_region != NULL)
{
- gtk_text_region_destroy (search->priv->scan_region);
+ gtk_source_region_destroy (search->priv->scan_region);
search->priv->scan_region = NULL;
}
@@ -2167,7 +2167,7 @@ smart_forward_search_step (GtkSourceSearchContext *search,
GtkTextIter iter = *start_at;
GtkTextIter limit;
GtkTextIter region_start = *start_at;
- GtkTextRegion *region = NULL;
+ GtkSourceRegion *region = NULL;
if (!gtk_text_iter_has_tag (&iter, search->priv->found_tag))
{
@@ -2184,14 +2184,14 @@ smart_forward_search_step (GtkSourceSearchContext *search,
if (search->priv->scan_region != NULL)
{
- region = gtk_text_region_intersect (search->priv->scan_region, ®ion_start, &limit);
+ region = gtk_source_region_intersect (search->priv->scan_region, ®ion_start, &limit);
}
if (is_text_region_empty (region))
{
if (region != NULL)
{
- gtk_text_region_destroy (region);
+ gtk_source_region_destroy (region);
}
while (basic_forward_search (search, &iter, match_start, match_end, &limit))
@@ -2220,7 +2220,7 @@ smart_forward_search_step (GtkSourceSearchContext *search,
scan_region_forward (search, region);
}
- gtk_text_region_destroy (region);
+ gtk_source_region_destroy (region);
return FALSE;
}
@@ -2264,7 +2264,7 @@ smart_backward_search_step (GtkSourceSearchContext *search,
GtkTextIter iter = *start_at;
GtkTextIter limit;
GtkTextIter region_end = *start_at;
- GtkTextRegion *region = NULL;
+ GtkSourceRegion *region = NULL;
if (gtk_text_iter_starts_tag (&iter, search->priv->found_tag) ||
(!gtk_text_iter_has_tag (&iter, search->priv->found_tag) &&
@@ -2283,14 +2283,14 @@ smart_backward_search_step (GtkSourceSearchContext *search,
if (search->priv->scan_region != NULL)
{
- region = gtk_text_region_intersect (search->priv->scan_region, &limit, ®ion_end);
+ region = gtk_source_region_intersect (search->priv->scan_region, &limit, ®ion_end);
}
if (is_text_region_empty (region))
{
if (region != NULL)
{
- gtk_text_region_destroy (region);
+ gtk_source_region_destroy (region);
}
while (basic_backward_search (search, &iter, match_start, match_end, &limit))
@@ -2319,7 +2319,7 @@ smart_backward_search_step (GtkSourceSearchContext *search,
scan_region_forward (search, region);
}
- gtk_text_region_destroy (region);
+ gtk_source_region_destroy (region);
return FALSE;
}
@@ -2363,19 +2363,19 @@ add_subregion_to_scan (GtkSourceSearchContext *search,
if (search->priv->scan_region == NULL)
{
- search->priv->scan_region = gtk_text_region_new (search->priv->buffer);
+ search->priv->scan_region = gtk_source_region_new (search->priv->buffer);
}
DEBUG ({
g_print ("add_subregion_to_scan(): region to scan, before:\n");
- gtk_text_region_debug_print (search->priv->scan_region);
+ gtk_source_region_debug_print (search->priv->scan_region);
});
- gtk_text_region_add (search->priv->scan_region, &start, &end);
+ gtk_source_region_add (search->priv->scan_region, &start, &end);
DEBUG ({
g_print ("add_subregion_to_scan(): region to scan, after:\n");
- gtk_text_region_debug_print (search->priv->scan_region);
+ gtk_source_region_debug_print (search->priv->scan_region);
});
install_idle_scan (search);
@@ -2454,7 +2454,7 @@ update (GtkSourceSearchContext *search)
clear_search (search);
update_regex (search);
- search->priv->scan_region = gtk_text_region_new (search->priv->buffer);
+ search->priv->scan_region = gtk_source_region_new (search->priv->buffer);
gtk_text_buffer_get_bounds (search->priv->buffer, &start, &end);
add_subregion_to_scan (search, &start, &end);
@@ -3191,7 +3191,7 @@ gtk_source_search_context_get_occurrence_position (GtkSourceSearchContext *searc
GtkTextIter iter;
gboolean found;
gint position = 0;
- GtkTextRegion *region;
+ GtkSourceRegion *region;
gboolean empty;
g_return_val_if_fail (GTK_SOURCE_IS_SEARCH_CONTEXT (search), -1);
@@ -3207,15 +3207,15 @@ gtk_source_search_context_get_occurrence_position (GtkSourceSearchContext *searc
if (search->priv->scan_region != NULL)
{
- region = gtk_text_region_intersect (search->priv->scan_region,
- match_start,
- match_end);
+ region = gtk_source_region_intersect (search->priv->scan_region,
+ match_start,
+ match_end);
empty = is_text_region_empty (region);
if (region != NULL)
{
- gtk_text_region_destroy (region);
+ gtk_source_region_destroy (region);
}
if (!empty)
@@ -3247,15 +3247,15 @@ gtk_source_search_context_get_occurrence_position (GtkSourceSearchContext *searc
if (search->priv->scan_region != NULL)
{
- region = gtk_text_region_intersect (search->priv->scan_region,
- &iter,
- match_end);
+ region = gtk_source_region_intersect (search->priv->scan_region,
+ &iter,
+ match_end);
empty = is_text_region_empty (region);
if (region != NULL)
{
- gtk_text_region_destroy (region);
+ gtk_source_region_destroy (region);
}
if (!empty)
@@ -3827,7 +3827,7 @@ _gtk_source_search_context_update_highlight (GtkSourceSearchContext *search,
const GtkTextIter *end,
gboolean synchronous)
{
- GtkTextRegion *region_to_highlight;
+ GtkSourceRegion *region_to_highlight;
g_return_if_fail (GTK_SOURCE_IS_SEARCH_CONTEXT (search));
g_return_if_fail (start != NULL);
@@ -3840,15 +3840,15 @@ _gtk_source_search_context_update_highlight (GtkSourceSearchContext *search,
return;
}
- region_to_highlight = gtk_text_region_intersect (search->priv->scan_region,
- start,
- end);
+ region_to_highlight = gtk_source_region_intersect (search->priv->scan_region,
+ start,
+ end);
if (is_text_region_empty (region_to_highlight))
{
if (region_to_highlight != NULL)
{
- gtk_text_region_destroy (region_to_highlight);
+ gtk_source_region_destroy (region_to_highlight);
}
return;
@@ -3863,7 +3863,7 @@ _gtk_source_search_context_update_highlight (GtkSourceSearchContext *search,
* means that the visible region has changed. So we can
* destroy the old high_priority_region.
*/
- gtk_text_region_destroy (search->priv->high_priority_region);
+ gtk_source_region_destroy (search->priv->high_priority_region);
}
search->priv->high_priority_region = region_to_highlight;
@@ -3875,10 +3875,10 @@ _gtk_source_search_context_update_highlight (GtkSourceSearchContext *search,
{
GtkTextIter region_start;
- if (!gtk_text_region_nth_subregion (search->priv->scan_region,
- 0,
- ®ion_start,
- NULL))
+ if (!gtk_source_region_nth_subregion (search->priv->scan_region,
+ 0,
+ ®ion_start,
+ NULL))
{
return;
}
@@ -3888,6 +3888,6 @@ _gtk_source_search_context_update_highlight (GtkSourceSearchContext *search,
else
{
scan_all_region (search, region_to_highlight);
- gtk_text_region_destroy (region_to_highlight);
+ gtk_source_region_destroy (region_to_highlight);
}
}
diff --git a/gtksourceview/gtktextregion.c b/gtksourceview/gtktextregion.c
index e47b370..01689e3 100644
--- a/gtksourceview/gtktextregion.c
+++ b/gtksourceview/gtktextregion.c
@@ -2,7 +2,8 @@
* gtktextregion.h - GtkTextMark based region utility functions
* This file is part of GtkSourceView
*
- * Copyright (C) 2002 Gustavo Gir�ldez <gustavo giraldez gmx net>
+ * Copyright (C) 2002 Gustavo Giráldez <gustavo giraldez gmx net>
+ * Copyright (C) 2016 Sébastien Wilmet <swilmet gnome org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -37,16 +38,16 @@ typedef struct _Subregion {
GtkTextMark *end;
} Subregion;
-struct _GtkTextRegion {
+struct _GtkSourceRegion {
GtkTextBuffer *buffer;
GList *subregions;
guint32 time_stamp;
};
-typedef struct _GtkTextRegionIteratorReal GtkTextRegionIteratorReal;
+typedef struct _GtkSourceRegionIteratorReal GtkSourceRegionIteratorReal;
-struct _GtkTextRegionIteratorReal {
- GtkTextRegion *region;
+struct _GtkSourceRegionIteratorReal {
+ GtkSourceRegion *region;
guint32 region_time_stamp;
GList *subregions;
@@ -62,7 +63,7 @@ struct _GtkTextRegionIteratorReal {
the text iter or which is the leftmost; else return the rightmost
subregion */
static GList *
-find_nearest_subregion (GtkTextRegion *region,
+find_nearest_subregion (GtkSourceRegion *region,
const GtkTextIter *iter,
GList *begin,
gboolean leftmost,
@@ -109,14 +110,14 @@ find_nearest_subregion (GtkTextRegion *region,
Public interface
---------------------------------------------------------------------- */
-GtkTextRegion *
-gtk_text_region_new (GtkTextBuffer *buffer)
+GtkSourceRegion *
+gtk_source_region_new (GtkTextBuffer *buffer)
{
- GtkTextRegion *region;
+ GtkSourceRegion *region;
g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), NULL);
- region = g_slice_new (GtkTextRegion);
+ region = g_slice_new (GtkSourceRegion);
region->subregions = NULL;
region->time_stamp = 0;
@@ -129,7 +130,7 @@ gtk_text_region_new (GtkTextBuffer *buffer)
}
void
-gtk_text_region_destroy (GtkTextRegion *region)
+gtk_source_region_destroy (GtkSourceRegion *region)
{
g_return_if_fail (region != NULL);
@@ -152,11 +153,11 @@ gtk_text_region_destroy (GtkTextRegion *region)
region->buffer = NULL;
}
- g_slice_free (GtkTextRegion, region);
+ g_slice_free (GtkSourceRegion, region);
}
GtkTextBuffer *
-gtk_text_region_get_buffer (GtkTextRegion *region)
+gtk_source_region_get_buffer (GtkSourceRegion *region)
{
g_return_val_if_fail (region != NULL, NULL);
@@ -164,7 +165,7 @@ gtk_text_region_get_buffer (GtkTextRegion *region)
}
static void
-gtk_text_region_clear_zero_length_subregions (GtkTextRegion *region)
+gtk_source_region_clear_zero_length_subregions (GtkSourceRegion *region)
{
GtkTextIter start, end;
GList *node;
@@ -193,9 +194,9 @@ gtk_text_region_clear_zero_length_subregions (GtkTextRegion *region)
}
void
-gtk_text_region_add (GtkTextRegion *region,
- const GtkTextIter *_start,
- const GtkTextIter *_end)
+gtk_source_region_add (GtkSourceRegion *region,
+ const GtkTextIter *_start,
+ const GtkTextIter *_end)
{
GList *start_node, *end_node;
GtkTextIter start, end;
@@ -211,7 +212,7 @@ gtk_text_region_add (GtkTextRegion *region,
end = *_end;
DEBUG (g_print ("---\n"));
- DEBUG (gtk_text_region_debug_print (region));
+ DEBUG (gtk_source_region_debug_print (region));
DEBUG (g_message ("region_add (%d, %d)",
gtk_text_iter_get_offset (&start),
gtk_text_iter_get_offset (&end)));
@@ -279,13 +280,13 @@ gtk_text_region_add (GtkTextRegion *region,
++region->time_stamp;
- DEBUG (gtk_text_region_debug_print (region));
+ DEBUG (gtk_source_region_debug_print (region));
}
void
-gtk_text_region_subtract (GtkTextRegion *region,
- const GtkTextIter *_start,
- const GtkTextIter *_end)
+gtk_source_region_subtract (GtkSourceRegion *region,
+ const GtkTextIter *_start,
+ const GtkTextIter *_end)
{
GList *start_node, *end_node, *node;
GtkTextIter sr_start_iter, sr_end_iter;
@@ -305,7 +306,7 @@ gtk_text_region_subtract (GtkTextRegion *region,
end = *_end;
DEBUG (g_print ("---\n"));
- DEBUG (gtk_text_region_debug_print (region));
+ DEBUG (gtk_source_region_debug_print (region));
DEBUG (g_message ("region_substract (%d, %d)",
gtk_text_iter_get_offset (&start),
gtk_text_iter_get_offset (&end)));
@@ -404,16 +405,16 @@ gtk_text_region_subtract (GtkTextRegion *region,
++region->time_stamp;
- DEBUG (gtk_text_region_debug_print (region));
+ DEBUG (gtk_source_region_debug_print (region));
/* now get rid of empty subregions */
- gtk_text_region_clear_zero_length_subregions (region);
+ gtk_source_region_clear_zero_length_subregions (region);
- DEBUG (gtk_text_region_debug_print (region));
+ DEBUG (gtk_source_region_debug_print (region));
}
gint
-gtk_text_region_subregions (GtkTextRegion *region)
+gtk_source_region_subregions (GtkSourceRegion *region)
{
g_return_val_if_fail (region != NULL, 0);
@@ -421,10 +422,10 @@ gtk_text_region_subregions (GtkTextRegion *region)
}
gboolean
-gtk_text_region_nth_subregion (GtkTextRegion *region,
- guint subregion,
- GtkTextIter *start,
- GtkTextIter *end)
+gtk_source_region_nth_subregion (GtkSourceRegion *region,
+ guint subregion,
+ GtkTextIter *start,
+ GtkTextIter *end)
{
Subregion *sr;
@@ -447,16 +448,16 @@ gtk_text_region_nth_subregion (GtkTextRegion *region,
return TRUE;
}
-GtkTextRegion *
-gtk_text_region_intersect (GtkTextRegion *region,
- const GtkTextIter *_start,
- const GtkTextIter *_end)
+GtkSourceRegion *
+gtk_source_region_intersect (GtkSourceRegion *region,
+ const GtkTextIter *_start,
+ const GtkTextIter *_end)
{
GList *start_node, *end_node, *node;
GtkTextIter sr_start_iter, sr_end_iter;
Subregion *sr, *new_sr;
gboolean done;
- GtkTextRegion *new_region;
+ GtkSourceRegion *new_region;
GtkTextIter start, end;
g_return_val_if_fail (region != NULL && _start != NULL && _end != NULL, NULL);
@@ -479,7 +480,7 @@ gtk_text_region_intersect (GtkTextRegion *region,
if (start_node == NULL || end_node == NULL || end_node == start_node->prev)
return NULL;
- new_region = gtk_text_region_new (region->buffer);
+ new_region = gtk_source_region_new (region->buffer);
done = FALSE;
sr = start_node->data;
@@ -555,7 +556,7 @@ gtk_text_region_intersect (GtkTextRegion *region,
}
static gboolean
-check_iterator (GtkTextRegionIteratorReal *real)
+check_iterator (GtkSourceRegionIteratorReal *real)
{
if ((real->region == NULL) ||
(real->region_time_stamp != real->region->time_stamp))
@@ -572,16 +573,16 @@ check_iterator (GtkTextRegionIteratorReal *real)
}
void
-gtk_text_region_get_iterator (GtkTextRegion *region,
- GtkTextRegionIterator *iter,
- guint start)
+gtk_source_region_get_iterator (GtkSourceRegion *region,
+ GtkSourceRegionIterator *iter,
+ guint start)
{
- GtkTextRegionIteratorReal *real;
+ GtkSourceRegionIteratorReal *real;
g_return_if_fail (region != NULL);
g_return_if_fail (iter != NULL);
- real = (GtkTextRegionIteratorReal *)iter;
+ real = (GtkSourceRegionIteratorReal *)iter;
/* region->subregions may be NULL, -> end iter */
@@ -591,26 +592,26 @@ gtk_text_region_get_iterator (GtkTextRegion *region,
}
gboolean
-gtk_text_region_iterator_is_end (GtkTextRegionIterator *iter)
+gtk_source_region_iterator_is_end (GtkSourceRegionIterator *iter)
{
- GtkTextRegionIteratorReal *real;
+ GtkSourceRegionIteratorReal *real;
g_return_val_if_fail (iter != NULL, FALSE);
- real = (GtkTextRegionIteratorReal *)iter;
+ real = (GtkSourceRegionIteratorReal *)iter;
g_return_val_if_fail (check_iterator (real), FALSE);
return (real->subregions == NULL);
}
gboolean
-gtk_text_region_iterator_next (GtkTextRegionIterator *iter)
+gtk_source_region_iterator_next (GtkSourceRegionIterator *iter)
{
- GtkTextRegionIteratorReal *real;
+ GtkSourceRegionIteratorReal *real;
g_return_val_if_fail (iter != NULL, FALSE);
- real = (GtkTextRegionIteratorReal *)iter;
+ real = (GtkSourceRegionIteratorReal *)iter;
g_return_val_if_fail (check_iterator (real), FALSE);
if (real->subregions != NULL)
@@ -625,16 +626,16 @@ gtk_text_region_iterator_next (GtkTextRegionIterator *iter)
}
gboolean
-gtk_text_region_iterator_get_subregion (GtkTextRegionIterator *iter,
- GtkTextIter *start,
- GtkTextIter *end)
+gtk_source_region_iterator_get_subregion (GtkSourceRegionIterator *iter,
+ GtkTextIter *start,
+ GtkTextIter *end)
{
- GtkTextRegionIteratorReal *real;
+ GtkSourceRegionIteratorReal *real;
Subregion *sr;
g_return_val_if_fail (iter != NULL, FALSE);
- real = (GtkTextRegionIteratorReal *)iter;
+ real = (GtkSourceRegionIteratorReal *)iter;
g_return_val_if_fail (check_iterator (real), FALSE);
g_return_val_if_fail (real->subregions != NULL, FALSE);
@@ -660,7 +661,7 @@ gtk_text_region_iterator_get_subregion (GtkTextRegionIterator *iter,
}
void
-gtk_text_region_debug_print (GtkTextRegion *region)
+gtk_source_region_debug_print (GtkSourceRegion *region)
{
GList *l;
diff --git a/gtksourceview/gtktextregion.h b/gtksourceview/gtktextregion.h
index df05045..721824f 100644
--- a/gtksourceview/gtktextregion.h
+++ b/gtksourceview/gtktextregion.h
@@ -2,7 +2,8 @@
* gtktextregion.h - GtkTextMark based region utility functions
* This file is part of GtkSourceView
*
- * Copyright (C) 2002 Gustavo Gir�ldez <gustavo giraldez gmx net>
+ * Copyright (C) 2002 Gustavo Giráldez <gustavo giraldez gmx net>
+ * Copyright (C) 2016 Sébastien Wilmet <swilmet gnome org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -19,20 +20,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __GTK_TEXT_REGION_H__
-#define __GTK_TEXT_REGION_H__
+#ifndef __GTK_SOURCE_REGION_H__
+#define __GTK_SOURCE_REGION_H__
#include <gtk/gtk.h>
#include "gtksourcetypes-private.h"
G_BEGIN_DECLS
-typedef struct _GtkTextRegion GtkTextRegion;
-typedef struct _GtkTextRegionIterator GtkTextRegionIterator;
+typedef struct _GtkSourceRegion GtkSourceRegion;
+typedef struct _GtkSourceRegionIterator GtkSourceRegionIterator;
-struct _GtkTextRegionIterator {
- /* GtkTextRegionIterator is an opaque datatype; ignore all these fields.
- * Initialize the iter with gtk_text_region_get_iterator
+struct _GtkSourceRegionIterator
+{
+ /* GtkSourceRegionIterator is an opaque datatype; ignore all these fields.
+ * Initialize the iter with gtk_source_region_get_iterator
* function
*/
/*< private >*/
@@ -42,58 +44,58 @@ struct _GtkTextRegionIterator {
};
GTK_SOURCE_INTERNAL
-GtkTextRegion *gtk_text_region_new (GtkTextBuffer *buffer);
+GtkSourceRegion * gtk_source_region_new (GtkTextBuffer *buffer);
GTK_SOURCE_INTERNAL
-void gtk_text_region_destroy (GtkTextRegion *region);
+void gtk_source_region_destroy (GtkSourceRegion *region);
GTK_SOURCE_INTERNAL
-GtkTextBuffer *gtk_text_region_get_buffer (GtkTextRegion *region);
+GtkTextBuffer * gtk_source_region_get_buffer (GtkSourceRegion *region);
GTK_SOURCE_INTERNAL
-void gtk_text_region_add (GtkTextRegion *region,
- const GtkTextIter *_start,
- const GtkTextIter *_end);
+void gtk_source_region_add (GtkSourceRegion *region,
+ const GtkTextIter *_start,
+ const GtkTextIter *_end);
GTK_SOURCE_INTERNAL
-void gtk_text_region_subtract (GtkTextRegion *region,
- const GtkTextIter *_start,
- const GtkTextIter *_end);
+void gtk_source_region_subtract (GtkSourceRegion *region,
+ const GtkTextIter *_start,
+ const GtkTextIter *_end);
GTK_SOURCE_INTERNAL
-gint gtk_text_region_subregions (GtkTextRegion *region);
+gint gtk_source_region_subregions (GtkSourceRegion *region);
GTK_SOURCE_INTERNAL
-gboolean gtk_text_region_nth_subregion (GtkTextRegion *region,
- guint subregion,
- GtkTextIter *start,
- GtkTextIter *end);
+gboolean gtk_source_region_nth_subregion (GtkSourceRegion *region,
+ guint subregion,
+ GtkTextIter *start,
+ GtkTextIter *end);
GTK_SOURCE_INTERNAL
-GtkTextRegion *gtk_text_region_intersect (GtkTextRegion *region,
- const GtkTextIter *_start,
- const GtkTextIter *_end);
+GtkSourceRegion * gtk_source_region_intersect (GtkSourceRegion *region,
+ const GtkTextIter *_start,
+ const GtkTextIter *_end);
GTK_SOURCE_INTERNAL
-void gtk_text_region_get_iterator (GtkTextRegion *region,
- GtkTextRegionIterator *iter,
- guint start);
+void gtk_source_region_get_iterator (GtkSourceRegion *region,
+ GtkSourceRegionIterator *iter,
+ guint start);
GTK_SOURCE_INTERNAL
-gboolean gtk_text_region_iterator_is_end (GtkTextRegionIterator *iter);
+gboolean gtk_source_region_iterator_is_end (GtkSourceRegionIterator *iter);
/* Returns FALSE if iterator is the end iterator */
GTK_SOURCE_INTERNAL
-gboolean gtk_text_region_iterator_next (GtkTextRegionIterator *iter);
+gboolean gtk_source_region_iterator_next (GtkSourceRegionIterator *iter);
GTK_SOURCE_INTERNAL
-gboolean gtk_text_region_iterator_get_subregion (GtkTextRegionIterator *iter,
- GtkTextIter *start,
- GtkTextIter *end);
+gboolean gtk_source_region_iterator_get_subregion (GtkSourceRegionIterator *iter,
+ GtkTextIter *start,
+ GtkTextIter *end);
GTK_SOURCE_INTERNAL
-void gtk_text_region_debug_print (GtkTextRegion *region);
+void gtk_source_region_debug_print (GtkSourceRegion *region);
G_END_DECLS
-#endif /* __GTK_TEXT_REGION_H__ */
+#endif /* __GTK_SOURCE_REGION_H__ */
diff --git a/testsuite/test-region.c b/testsuite/test-region.c
index ef345c0..75c75c7 100644
--- a/testsuite/test-region.c
+++ b/testsuite/test-region.c
@@ -28,8 +28,8 @@ static void
test_region (void)
{
GtkTextBuffer *buffer;
- GtkTextRegion *region, *intersection;
- GtkTextRegionIterator reg_iter;
+ GtkSourceRegion *region, *intersection;
+ GtkSourceRegionIterator reg_iter;
GtkTextIter iter1, iter2;
gint i;
@@ -91,13 +91,13 @@ test_region (void)
};
buffer = gtk_text_buffer_new (NULL);
- region = gtk_text_region_new (buffer);
+ region = gtk_source_region_new (buffer);
gtk_text_buffer_get_start_iter (buffer, &iter1);
- gtk_text_buffer_insert (buffer, &iter1, "This is a test of GtkTextRegion", -1);
+ gtk_text_buffer_insert (buffer, &iter1, "This is a test of GtkSourceRegion", -1);
- gtk_text_region_get_iterator (region, ®_iter, 0);
- if (!gtk_text_region_iterator_is_end (®_iter)) {
+ gtk_source_region_get_iterator (region, ®_iter, 0);
+ if (!gtk_source_region_iterator_is_end (®_iter)) {
g_print ("problem fetching iterator for an empty region\n");
g_assert_not_reached ();
}
@@ -110,14 +110,14 @@ test_region (void)
if (ops [i][0] > 0) {
op_name = "added";
- gtk_text_region_add (region, &iter1, &iter2);
+ gtk_source_region_add (region, &iter1, &iter2);
} else {
op_name = "deleted";
- gtk_text_region_subtract (region, &iter1, &iter2);
+ gtk_source_region_subtract (region, &iter1, &iter2);
}
g_print ("%s %d-%d\n", op_name, ops [i][1], ops [i][2]);
- gtk_text_region_debug_print (region);
+ gtk_source_region_debug_print (region);
}
for (i = 0; i < NUM_INTERSECTS; i++) {
@@ -125,25 +125,25 @@ 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_text_region_intersect (region, &iter1, &iter2);
+ intersection = gtk_source_region_intersect (region, &iter1, &iter2);
if (intersection) {
- gtk_text_region_debug_print (intersection);
- gtk_text_region_destroy (intersection);
+ gtk_source_region_debug_print (intersection);
+ gtk_source_region_destroy (intersection);
} else {
g_print ("no intersection\n");
}
}
i = 0;
- gtk_text_region_get_iterator (region, ®_iter, 0);
+ gtk_source_region_get_iterator (region, ®_iter, 0);
- while (!gtk_text_region_iterator_is_end (®_iter))
+ while (!gtk_source_region_iterator_is_end (®_iter))
{
GtkTextIter s, e, s1, e1;
- gtk_text_region_iterator_get_subregion (®_iter,
- &s, &e);
- gtk_text_region_nth_subregion (region, i, &s1, &e1);
+ gtk_source_region_iterator_get_subregion (®_iter,
+ &s, &e);
+ gtk_source_region_nth_subregion (region, i, &s1, &e1);
if (!gtk_text_iter_equal (&s, &s1) ||
!gtk_text_iter_equal (&e, &e1))
@@ -153,10 +153,10 @@ test_region (void)
}
++i;
- gtk_text_region_iterator_next (®_iter);
+ gtk_source_region_iterator_next (®_iter);
}
- if (i != gtk_text_region_subregions (region))
+ if (i != gtk_source_region_subregions (region))
{
g_print ("problem iterating all subregions\n");
g_assert_not_reached ();
@@ -164,7 +164,7 @@ test_region (void)
g_print ("iterated %d subregions\n", i);
- gtk_text_region_destroy (region);
+ gtk_source_region_destroy (region);
g_object_unref (buffer);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]