[gspell/wip/apostrophe: 2/2] Use the _gspell_text_iter_* functions for the apostrophe support
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell/wip/apostrophe: 2/2] Use the _gspell_text_iter_* functions for the apostrophe support
- Date: Fri, 12 Feb 2016 19:29:44 +0000 (UTC)
commit 9124690611f619884dc0b25d060ad073f3e646ae
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Feb 12 17:17:50 2016 +0100
Use the _gspell_text_iter_* functions for the apostrophe support
gspell/gspell-inline-checker-text-buffer.c | 85 ++++++++++++++--------------
gspell/gspell-navigator-text-view.c | 25 ++++----
gspell/gspell-utils.c | 5 +-
3 files changed, 59 insertions(+), 56 deletions(-)
---
diff --git a/gspell/gspell-inline-checker-text-buffer.c b/gspell/gspell-inline-checker-text-buffer.c
index c69dac1..9a8eef7 100644
--- a/gspell/gspell-inline-checker-text-buffer.c
+++ b/gspell/gspell-inline-checker-text-buffer.c
@@ -29,6 +29,7 @@
#include "gspell-checker.h"
#include "gspell-buffer-notifier.h"
#include "gspell-text-buffer.h"
+#include "gspell-text-iter.h"
#include "gspell-text-region.h"
#include "gspell-utils.h"
@@ -96,8 +97,8 @@ check_word (GspellInlineCheckerTextBuffer *spell,
return;
}
- if (!gtk_text_iter_starts_word (start) ||
- !gtk_text_iter_ends_word (end))
+ if (!_gspell_text_iter_starts_word (start) ||
+ !_gspell_text_iter_ends_word (end))
{
g_warning ("Spell checking: @start and @end must delimit a word");
return;
@@ -135,16 +136,16 @@ check_subregion (GspellInlineCheckerTextBuffer *spell,
g_assert_cmpint (gtk_text_iter_compare (start, end), <=, 0);
- if (gtk_text_iter_inside_word (start) &&
- !gtk_text_iter_starts_word (start))
+ if (_gspell_text_iter_inside_word (start) &&
+ !_gspell_text_iter_starts_word (start))
{
- gtk_text_iter_backward_word_start (start);
+ _gspell_text_iter_backward_word_start (start);
}
- if (gtk_text_iter_inside_word (end) &&
- !gtk_text_iter_starts_word (end))
+ if (_gspell_text_iter_inside_word (end) &&
+ !_gspell_text_iter_starts_word (end))
{
- gtk_text_iter_forward_word_end (end);
+ _gspell_text_iter_forward_word_end (end);
}
gtk_text_buffer_remove_tag (spell->buffer,
@@ -153,9 +154,9 @@ check_subregion (GspellInlineCheckerTextBuffer *spell,
end);
word_start = *start;
- if (!gtk_text_iter_starts_word (&word_start))
+ if (!_gspell_text_iter_starts_word (&word_start))
{
- gtk_text_iter_forward_word_end (&word_start);
+ _gspell_text_iter_forward_word_end (&word_start);
/* Didn't move, there is no words after @start_adjusted. */
if (gtk_text_iter_equal (&word_start, start))
@@ -163,8 +164,8 @@ check_subregion (GspellInlineCheckerTextBuffer *spell,
return;
}
- gtk_text_iter_backward_word_start (&word_start);
- g_assert (gtk_text_iter_starts_word (&word_start));
+ _gspell_text_iter_backward_word_start (&word_start);
+ g_assert (_gspell_text_iter_starts_word (&word_start));
g_assert_cmpint (gtk_text_iter_compare (start, &word_start), <, 0);
}
@@ -174,18 +175,18 @@ check_subregion (GspellInlineCheckerTextBuffer *spell,
GtkTextIter word_end;
GtkTextIter next_word_start;
- g_assert (gtk_text_iter_starts_word (&word_start));
+ g_assert (_gspell_text_iter_starts_word (&word_start));
word_end = word_start;
- gtk_text_iter_forward_word_end (&word_end);
+ _gspell_text_iter_forward_word_end (&word_end);
g_assert_cmpint (gtk_text_iter_compare (&word_end, end), <=, 0);
check_word (spell, &word_start, &word_end);
next_word_start = word_end;
- gtk_text_iter_forward_word_end (&next_word_start);
- gtk_text_iter_backward_word_start (&next_word_start);
+ _gspell_text_iter_forward_word_end (&next_word_start);
+ _gspell_text_iter_backward_word_start (&next_word_start);
/* Make sure we've actually advanced (we don't advance if we
* have just checked the last word of the buffer).
@@ -285,18 +286,18 @@ get_current_word_boundaries (GtkTextBuffer *buffer,
gtk_text_buffer_get_insert (buffer));
*current_word_start = insert_iter;
- if (gtk_text_iter_ends_word (current_word_start) ||
- (gtk_text_iter_inside_word (current_word_start) &&
- !gtk_text_iter_starts_word (current_word_start)))
+ if (_gspell_text_iter_ends_word (current_word_start) ||
+ (_gspell_text_iter_inside_word (current_word_start) &&
+ !_gspell_text_iter_starts_word (current_word_start)))
{
- gtk_text_iter_backward_word_start (current_word_start);
+ _gspell_text_iter_backward_word_start (current_word_start);
found = TRUE;
}
*current_word_end = insert_iter;
- if (gtk_text_iter_inside_word (current_word_end))
+ if (_gspell_text_iter_inside_word (current_word_end))
{
- gtk_text_iter_forward_word_end (current_word_end);
+ _gspell_text_iter_forward_word_end (current_word_end);
found = TRUE;
}
@@ -495,16 +496,16 @@ insert_text_after_cb (GtkTextBuffer *buffer,
/* Include neighbor words */
- if (gtk_text_iter_ends_word (&start) ||
- (gtk_text_iter_inside_word (&start) &&
- !gtk_text_iter_starts_word (&start)))
+ if (_gspell_text_iter_ends_word (&start) ||
+ (_gspell_text_iter_inside_word (&start) &&
+ !_gspell_text_iter_starts_word (&start)))
{
- gtk_text_iter_backward_word_start (&start);
+ _gspell_text_iter_backward_word_start (&start);
}
- if (gtk_text_iter_inside_word (&end))
+ if (_gspell_text_iter_inside_word (&end))
{
- gtk_text_iter_forward_word_end (&end);
+ _gspell_text_iter_forward_word_end (&end);
}
spell->check_current_word = FALSE;
@@ -527,16 +528,16 @@ delete_range_after_cb (GtkTextBuffer *buffer,
/* Just to be sure. Normally start == end. */
gtk_text_iter_order (&start_adjusted, &end_adjusted);
- if (gtk_text_iter_ends_word (&start_adjusted) ||
- (gtk_text_iter_inside_word (&start_adjusted) &&
- !gtk_text_iter_starts_word (&start_adjusted)))
+ if (_gspell_text_iter_ends_word (&start_adjusted) ||
+ (_gspell_text_iter_inside_word (&start_adjusted) &&
+ !_gspell_text_iter_starts_word (&start_adjusted)))
{
- gtk_text_iter_backward_word_start (&start_adjusted);
+ _gspell_text_iter_backward_word_start (&start_adjusted);
}
- if (gtk_text_iter_inside_word (&end_adjusted))
+ if (_gspell_text_iter_inside_word (&end_adjusted))
{
- gtk_text_iter_forward_word_end (&end_adjusted);
+ _gspell_text_iter_forward_word_end (&end_adjusted);
}
spell->check_current_word = FALSE;
@@ -566,22 +567,22 @@ get_word_extents_at_click_position (GspellInlineCheckerTextBuffer *spell,
gtk_text_buffer_get_iter_at_mark (spell->buffer, &iter, spell->mark_click);
- if (!gtk_text_iter_inside_word (&iter) &&
- !gtk_text_iter_ends_word (&iter))
+ if (!_gspell_text_iter_inside_word (&iter) &&
+ !_gspell_text_iter_ends_word (&iter))
{
return FALSE;
}
*start = iter;
- if (!gtk_text_iter_starts_word (start))
+ if (!_gspell_text_iter_starts_word (start))
{
- gtk_text_iter_backward_word_start (start);
+ _gspell_text_iter_backward_word_start (start);
}
*end = iter;
- if (!gtk_text_iter_ends_word (end))
+ if (!_gspell_text_iter_ends_word (end))
{
- gtk_text_iter_forward_word_end (end);
+ _gspell_text_iter_forward_word_end (end);
}
return TRUE;
@@ -844,8 +845,8 @@ remove_tag_to_word (GspellInlineCheckerTextBuffer *spell,
break;
}
- if (gtk_text_iter_starts_word (&match_start) &&
- gtk_text_iter_ends_word (&match_end))
+ if (_gspell_text_iter_starts_word (&match_start) &&
+ _gspell_text_iter_ends_word (&match_end))
{
gtk_text_buffer_remove_tag (spell->buffer,
spell->highlight_tag,
diff --git a/gspell/gspell-navigator-text-view.c b/gspell/gspell-navigator-text-view.c
index 1a8f66d..4e3d5c8 100644
--- a/gspell/gspell-navigator-text-view.c
+++ b/gspell/gspell-navigator-text-view.c
@@ -21,6 +21,7 @@
#include "gspell-navigator-text-view.h"
#include <glib/gi18n-lib.h>
#include "gspell-text-buffer.h"
+#include "gspell-text-iter.h"
#include "gspell-utils.h"
/**
@@ -95,15 +96,15 @@ init_boundaries (GspellNavigatorTextView *navigator)
gtk_text_buffer_get_bounds (priv->buffer, &start, &end);
}
- if (gtk_text_iter_inside_word (&start) &&
- !gtk_text_iter_starts_word (&start))
+ if (_gspell_text_iter_inside_word (&start) &&
+ !_gspell_text_iter_starts_word (&start))
{
- gtk_text_iter_backward_word_start (&start);
+ _gspell_text_iter_backward_word_start (&start);
}
- if (gtk_text_iter_inside_word (&end))
+ if (_gspell_text_iter_inside_word (&end))
{
- gtk_text_iter_forward_word_end (&end);
+ _gspell_text_iter_forward_word_end (&end);
}
priv->start_boundary = gtk_text_buffer_create_mark (priv->buffer, NULL, &start, TRUE);
@@ -345,12 +346,12 @@ gspell_navigator_text_view_goto_next (GspellNavigator *navigator,
gboolean correctly_spelled;
GError *error = NULL;
- if (!gtk_text_iter_starts_word (&word_start))
+ if (!_gspell_text_iter_starts_word (&word_start))
{
GtkTextIter iter;
iter = word_start;
- gtk_text_iter_forward_word_end (&word_start);
+ _gspell_text_iter_forward_word_end (&word_start);
if (gtk_text_iter_equal (&iter, &word_start))
{
@@ -358,7 +359,7 @@ gspell_navigator_text_view_goto_next (GspellNavigator *navigator,
return FALSE;
}
- gtk_text_iter_backward_word_start (&word_start);
+ _gspell_text_iter_backward_word_start (&word_start);
}
if (!_gspell_utils_skip_no_spell_check (no_spell_check_tag, &word_start, &end))
@@ -366,10 +367,10 @@ gspell_navigator_text_view_goto_next (GspellNavigator *navigator,
return FALSE;
}
- g_return_val_if_fail (gtk_text_iter_starts_word (&word_start), FALSE);
+ g_return_val_if_fail (_gspell_text_iter_starts_word (&word_start), FALSE);
word_end = word_start;
- gtk_text_iter_forward_word_end (&word_end);
+ _gspell_text_iter_forward_word_end (&word_end);
if (gtk_text_iter_compare (&end, &word_end) < 0)
{
@@ -489,8 +490,8 @@ gspell_navigator_text_view_change_all (GspellNavigator *navigator,
break;
}
- if (gtk_text_iter_starts_word (&match_start) &&
- gtk_text_iter_ends_word (&match_end))
+ if (_gspell_text_iter_starts_word (&match_start) &&
+ _gspell_text_iter_ends_word (&match_end))
{
gtk_text_buffer_delete (priv->buffer, &match_start, &match_end);
gtk_text_buffer_insert (priv->buffer, &match_end, change_to, -1);
diff --git a/gspell/gspell-utils.c b/gspell/gspell-utils.c
index ba287f8..c10278a 100644
--- a/gspell/gspell-utils.c
+++ b/gspell/gspell-utils.c
@@ -20,6 +20,7 @@
#include "gspell-utils.h"
#include <string.h>
+#include "gspell-text-iter.h"
gboolean
_gspell_utils_is_number (const gchar *text,
@@ -95,8 +96,8 @@ _gspell_utils_skip_no_spell_check (GtkTextTag *no_spell_check_tag,
return FALSE;
}
- gtk_text_iter_forward_word_end (start);
- gtk_text_iter_backward_word_start (start);
+ _gspell_text_iter_forward_word_end (start);
+ _gspell_text_iter_backward_word_start (start);
if (gtk_text_iter_compare (start, &last) <= 0)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]