[vte/vte-next: 180/223] Add VteBufferIter
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-next: 180/223] Add VteBufferIter
- Date: Wed, 22 Jun 2011 21:03:43 +0000 (UTC)
commit dda8ab752f470285a2e2898c9cb2466313cf699c
Author: Christian Persch <chpe gnome org>
Date: Sun Jun 12 22:00:48 2011 +0200
Add VteBufferIter
doc/reference/vte-sections.txt | 8 +++++
src/vte-private.h | 7 ++++
src/vte.c | 67 ++++++++++++++++++++++++++++++++++++++++
src/vtebuffer.h | 24 ++++++++++++++
4 files changed, 106 insertions(+), 0 deletions(-)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index 8cda4c4..c121a13 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -105,6 +105,12 @@ vte_buffer_get_row_count
vte_buffer_get_cursor_position
<SUBSECTION>
+VteBufferIter
+vte_buffer_iter_copy
+vte_buffer_iter_free
+vte_buffer_iter_is_valid
+
+<SUBSECTION>
vte_buffer_get_text
vte_buffer_get_text_include_trailing_spaces
vte_buffer_get_text_range
@@ -125,6 +131,8 @@ VTE_BUFFER_GET_CLASS
VTE_IS_BUFFER_CLASS
VTE_BUFFER_CLASS
VteBufferClass
+VTE_TYPE_BUFFER_ITER
+vte_buffer_iter_get_type
<SUBSECTION Private>
VteBufferPrivate
diff --git a/src/vte-private.h b/src/vte-private.h
index feacaff..b218e08 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -147,6 +147,13 @@ typedef struct _VteVisualPosition {
long row, col;
} VteVisualPosition;
+typedef struct _VteBufferIterReal VteBufferIterReal;
+struct _VteBufferIterReal {
+ VteVisualPosition pos;
+ VteBuffer *buffer;
+};
+G_STATIC_ASSERT(sizeof(VteBufferIterReal) <= sizeof(VteBufferIter));
+
struct _VteBufferClassPrivate {
gpointer dummy;
};
diff --git a/src/vte.c b/src/vte.c
index 0efa065..b426253 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -13987,3 +13987,70 @@ vte_buffer_new(void)
{
return g_object_new(VTE_TYPE_BUFFER, NULL);
}
+
+/* VteBufferIter */
+
+G_DEFINE_BOXED_TYPE(VteBufferIter, vte_buffer_iter,
+ vte_buffer_iter_copy,
+ vte_buffer_iter_free);
+
+/**
+ * vte_buffer_iter_copy:
+ * @iter: a #VteBufferIter
+ *
+ * Creates a copy of @iter on the heap.
+ *
+ * Returns: (transfer full): a copy of @iter
+ */
+VteBufferIter *
+vte_buffer_iter_copy (VteBufferIter *iter)
+{
+ VteBufferIterReal *real_iter = (VteBufferIterReal *) iter;
+ VteBufferIterReal *copy;
+
+ g_return_val_if_fail(iter != NULL, NULL);
+ copy = g_slice_dup(VteBufferIterReal, real_iter);
+
+ return (VteBufferIter *) copy;
+}
+
+/**
+ * vte_buffer_iter_copy:
+ * @iter: a #VteBufferIter
+ *
+ * Frees the heap-allocated @iter. Do not use this with stack-allocated #VteBufferIters!
+ */
+void
+vte_buffer_iter_free (VteBufferIter *iter)
+{
+ VteBufferIterReal *real_iter = (VteBufferIterReal *) iter;
+
+ if (iter == NULL)
+ return;
+
+ g_slice_free(VteBufferIterReal, real_iter);
+}
+
+/**
+ * vte_buffer_iter_is_valid:
+ * @iter: a #VteBufferIter
+ * @buffer: a #VteBuffer
+ *
+ * Checks whether @iter is a valid iter on @buffer.
+ *
+ * Returns: %TRUE iff @iter is a valid iter on @buffer
+ */
+gboolean
+vte_buffer_iter_is_valid (VteBufferIter *iter,
+ VteBuffer *buffer)
+{
+ VteBufferIterReal *real_iter = (VteBufferIterReal *) iter;
+
+ if (iter == NULL)
+ return FALSE;
+
+ if (real_iter->buffer != buffer)
+ return FALSE;
+
+ return TRUE;
+}
diff --git a/src/vtebuffer.h b/src/vtebuffer.h
index 8af3672..15559db 100644
--- a/src/vtebuffer.h
+++ b/src/vtebuffer.h
@@ -27,6 +27,21 @@
G_BEGIN_DECLS
+/* VteBufferIter */
+
+typedef struct _VteBufferIter VteBufferIter;
+
+/**
+ * VteBufferIter:
+ *
+ * FIXMEchpe
+ */
+struct _VteBufferIter {
+ glong dummy1;
+ glong dummy2;
+ gpointer dummy3;
+};
+
/* VteBuffer object */
#define VTE_TYPE_BUFFER (vte_buffer_get_type())
@@ -200,6 +215,15 @@ char *vte_buffer_get_text_range(VteBuffer *buffer,
gpointer user_data,
GArray *attributes);
+GType vte_buffer_iter_get_type (void);
+
+VteBufferIter *vte_buffer_iter_copy (VteBufferIter *iter);
+
+void vte_buffer_iter_free (VteBufferIter *iter);
+
+gboolean vte_buffer_iter_is_valid (VteBufferIter *iter,
+ VteBuffer *buffer);
+
G_END_DECLS
#endif /* VTE_BUFFER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]