[gnome-builder] buffer: add ide_buffer_get_selection_bounds()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] buffer: add ide_buffer_get_selection_bounds()
- Date: Fri, 8 May 2015 19:23:03 +0000 (UTC)
commit f698360fea409a84a51bf7ff8fcaf226d6b214ad
Author: Christian Hergert <christian hergert me>
Date: Fri May 8 12:16:38 2015 -0700
buffer: add ide_buffer_get_selection_bounds()
This acts like gtk_text_buffer_get_selection_bounds() except that it does
not reorder the insert and selection mark. This can be useful when you
know you want to work with the insert mark directly, and can handle
direction ordering yourself.
libide/ide-buffer.c | 32 ++++++++++++++++++++++++++++++++
libide/ide-buffer.h | 3 +++
2 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-buffer.c b/libide/ide-buffer.c
index 5b0255b..a65328a 100644
--- a/libide/ide-buffer.c
+++ b/libide/ide-buffer.c
@@ -1979,3 +1979,35 @@ ide_buffer_release (IdeBuffer *self)
self);
}
}
+
+/**
+ * ide_buffer_get_selection_bounds:
+ *
+ * This function acts like gtk_text_buffer_get_selection_bounds() except that it always
+ * places the location of the insert mark at @insert and the location of the selection
+ * mark at @selection.
+ *
+ * Calling gtk_text_iter_order() with the results of this function would be equivalent
+ * to calling gtk_text_buffer_get_selection_bounds().
+ */
+void
+ide_buffer_get_selection_bounds (IdeBuffer *self,
+ GtkTextIter *insert,
+ GtkTextIter *selection)
+{
+ GtkTextMark *mark;
+
+ g_return_if_fail (IDE_IS_BUFFER (self));
+
+ if (insert != NULL)
+ {
+ mark = gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (self));
+ gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (self), insert, mark);
+ }
+
+ if (selection != NULL)
+ {
+ mark = gtk_text_buffer_get_selection_bound (GTK_TEXT_BUFFER (self));
+ gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (self), selection, mark);
+ }
+}
diff --git a/libide/ide-buffer.h b/libide/ide-buffer.h
index 2cdb66a..bfe1b82 100644
--- a/libide/ide-buffer.h
+++ b/libide/ide-buffer.h
@@ -88,6 +88,9 @@ void ide_buffer_get_iter_at_source_location (IdeBuffer
GtkTextIter *iter,
IdeSourceLocation *location);
void ide_buffer_rehighlight (IdeBuffer *self);
+void ide_buffer_get_selection_bounds (IdeBuffer *self,
+ GtkTextIter *insert,
+ GtkTextIter *selection);
void ide_buffer_get_symbol_at_location_async (IdeBuffer *self,
const GtkTextIter *location,
GCancellable *cancellable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]