[gspell/wip/tune-current-word] inline-checker-text-buffer: get the broader boundaries on delete-range
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell/wip/tune-current-word] inline-checker-text-buffer: get the broader boundaries on delete-range
- Date: Thu, 3 Mar 2016 17:17:28 +0000 (UTC)
commit 0a29784392ea0ec8bf65a79648d3054e5495a401
Author: Sébastien Wilmet <swilmet gnome org>
Date: Thu Mar 3 18:17:02 2016 +0100
inline-checker-text-buffer: get the broader boundaries on delete-range
gspell/gspell-inline-checker-text-buffer.c | 35 ++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/gspell/gspell-inline-checker-text-buffer.c b/gspell/gspell-inline-checker-text-buffer.c
index b6ffc14..88f707c 100644
--- a/gspell/gspell-inline-checker-text-buffer.c
+++ b/gspell/gspell-inline-checker-text-buffer.c
@@ -586,6 +586,35 @@ insert_text_after_cb (GtkTextBuffer *buffer,
install_timeout (spell, TIMEOUT_DURATION_BUFFER_MODIFIED);
}
+/* Same reasoning as for the ::insert-text signal. */
+static void
+delete_range_before_cb (GtkTextBuffer *buffer,
+ GtkTextIter *start,
+ GtkTextIter *end,
+ GspellInlineCheckerTextBuffer *spell)
+{
+ GtkTextIter start_adjusted;
+ GtkTextIter end_adjusted;
+
+ /* Adjust iters */
+ start_adjusted = *start;
+ end_adjusted = *end;
+
+ if (gtk_text_iter_ends_word (&start_adjusted) ||
+ (gtk_text_iter_inside_word (&start_adjusted) &&
+ !gtk_text_iter_starts_word (&start_adjusted)))
+ {
+ gtk_text_iter_backward_word_start (&start_adjusted);
+ }
+
+ if (gtk_text_iter_inside_word (&end_adjusted))
+ {
+ gtk_text_iter_forward_word_end (&end_adjusted);
+ }
+
+ add_subregion_to_scan (spell, &start_adjusted, &end_adjusted);
+}
+
static void
delete_range_after_cb (GtkTextBuffer *buffer,
GtkTextIter *start,
@@ -1157,6 +1186,12 @@ set_buffer (GspellInlineCheckerTextBuffer *spell,
g_signal_connect_object (buffer,
"delete-range",
+ G_CALLBACK (delete_range_before_cb),
+ spell,
+ 0);
+
+ g_signal_connect_object (buffer,
+ "delete-range",
G_CALLBACK (delete_range_after_cb),
spell,
G_CONNECT_AFTER);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]