[gnome-builder] gtk: add helper to get GtkTextIter's previous char.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] gtk: add helper to get GtkTextIter's previous char.
- Date: Fri, 2 Jan 2015 23:55:29 +0000 (UTC)
commit 0372df8272f68cdbdb5b1e37e3d629475270c8a8
Author: Christian Hergert <christian hergert me>
Date: Fri Jan 2 15:43:47 2015 -0800
gtk: add helper to get GtkTextIter's previous char.
src/util/gb-gtk.c | 16 ++++++++++++++++
src/util/gb-gtk.h | 2 ++
2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/util/gb-gtk.c b/src/util/gb-gtk.c
index c6e77b5..d8d0fff 100644
--- a/src/util/gb-gtk.c
+++ b/src/util/gb-gtk.c
@@ -154,3 +154,19 @@ gb_gtk_text_view_get_iter_visible (GtkTextView *text_view,
return gdk_rectangle_intersect (&visible_rect, &iter_location, NULL);
}
+
+gunichar
+gb_gtk_text_iter_get_previous_char (const GtkTextIter *iter)
+{
+ GtkTextIter copy;
+
+ g_return_val_if_fail (iter, 0);
+
+ copy = *iter;
+
+ gtk_text_iter_backward_char (©);
+ if (gtk_text_iter_equal (©, iter))
+ return '\0';
+
+ return gtk_text_iter_get_char (©);
+}
diff --git a/src/util/gb-gtk.h b/src/util/gb-gtk.h
index 66304c4..c7a79e6 100644
--- a/src/util/gb-gtk.h
+++ b/src/util/gb-gtk.h
@@ -38,6 +38,8 @@ void gb_gtk_text_view_scroll_to_iter (GtkTextView *text_view,
gboolean gb_gtk_text_view_get_iter_visible (GtkTextView *text_view,
GtkTextIter *iter);
+gunichar gb_gtk_text_iter_get_previous_char (const GtkTextIter *iter);
+
G_END_DECLS
#endif /* GB_GTK_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]