Commit e86329d5 authored by Havoc Pennington's avatar Havoc Pennington Committed by Havoc Pennington

Test program to make sure GtkTextBuffer is in working order.

2000-06-02  Havoc Pennington  <hp@pobox.com>

        * gtk/testtextbuffer.c: Test program to make sure GtkTextBuffer
	is in working order.

	* gtk/testtext.c: Change to reflect anonymous mark API

	* gtk/gtktextview.c: Convert from mark names to GtkTextMark*.

	* gtk/gtktexttag.h (struct _GtkTextTag): remove the affects_size
	field, which was unused.

	* gtk/gtktextmarkprivate.h (GTK_IS_TEXT_MARK): add this macro,
	saves some typing.

	* gtk/gtktextbuffer.c: Switch from mark names to GtkTextMark*

	* gtk/gtktextbtree.c (gtk_text_btree_new): set the not_deleteable
	flag on the insertion point and selection bound

	Throughout, use GtkTextMark instead of GtkTextLineSegment, and
	make mark-manipulation functions take a GtkTextMark* instead of a
	mark name.

	* gtk/gtktextmarkprivate.h: Add a "not_deleteable" flag to
	GtkTextMarkBody; will be used to detect attempts to delete
	the permanent marks (insert and selection bound)
parent bb77f4e6
2000-06-02 Havoc Pennington <hp@pobox.com>
* gtk/testtextbuffer.c: Test program to make sure GtkTextBuffer
is in working order.
* gtk/testtext.c: Change to reflect anonymous mark API
* gtk/gtktextview.c: Convert from mark names to GtkTextMark*.
* gtk/gtktexttag.h (struct _GtkTextTag): remove the affects_size
field, which was unused.
* gtk/gtktextmarkprivate.h (GTK_IS_TEXT_MARK): add this macro,
saves some typing.
* gtk/gtktextbuffer.c: Switch from mark names to GtkTextMark*
* gtk/gtktextbtree.c (gtk_text_btree_new): set the not_deleteable
flag on the insertion point and selection bound
Throughout, use GtkTextMark instead of GtkTextLineSegment, and
make mark-manipulation functions take a GtkTextMark* instead of a
mark name.
* gtk/gtktextmarkprivate.h: Add a "not_deleteable" flag to
GtkTextMarkBody; will be used to detect attempts to delete
the permanent marks (insert and selection bound)
* gtk/Makefile.am (noinst_PROGRAMS): add testtextbuffer
Fri Jun 2 12:56:01 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_init): Initialize DOUBLE_BUFFERED
......
2000-06-02 Havoc Pennington <hp@pobox.com>
* gtk/testtextbuffer.c: Test program to make sure GtkTextBuffer
is in working order.
* gtk/testtext.c: Change to reflect anonymous mark API
* gtk/gtktextview.c: Convert from mark names to GtkTextMark*.
* gtk/gtktexttag.h (struct _GtkTextTag): remove the affects_size
field, which was unused.
* gtk/gtktextmarkprivate.h (GTK_IS_TEXT_MARK): add this macro,
saves some typing.
* gtk/gtktextbuffer.c: Switch from mark names to GtkTextMark*
* gtk/gtktextbtree.c (gtk_text_btree_new): set the not_deleteable
flag on the insertion point and selection bound
Throughout, use GtkTextMark instead of GtkTextLineSegment, and
make mark-manipulation functions take a GtkTextMark* instead of a
mark name.
* gtk/gtktextmarkprivate.h: Add a "not_deleteable" flag to
GtkTextMarkBody; will be used to detect attempts to delete
the permanent marks (insert and selection bound)
* gtk/Makefile.am (noinst_PROGRAMS): add testtextbuffer
Fri Jun 2 12:56:01 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_init): Initialize DOUBLE_BUFFERED
......
2000-06-02 Havoc Pennington <hp@pobox.com>
* gtk/testtextbuffer.c: Test program to make sure GtkTextBuffer
is in working order.
* gtk/testtext.c: Change to reflect anonymous mark API
* gtk/gtktextview.c: Convert from mark names to GtkTextMark*.
* gtk/gtktexttag.h (struct _GtkTextTag): remove the affects_size
field, which was unused.
* gtk/gtktextmarkprivate.h (GTK_IS_TEXT_MARK): add this macro,
saves some typing.
* gtk/gtktextbuffer.c: Switch from mark names to GtkTextMark*
* gtk/gtktextbtree.c (gtk_text_btree_new): set the not_deleteable
flag on the insertion point and selection bound
Throughout, use GtkTextMark instead of GtkTextLineSegment, and
make mark-manipulation functions take a GtkTextMark* instead of a
mark name.
* gtk/gtktextmarkprivate.h: Add a "not_deleteable" flag to
GtkTextMarkBody; will be used to detect attempts to delete
the permanent marks (insert and selection bound)
* gtk/Makefile.am (noinst_PROGRAMS): add testtextbuffer
Fri Jun 2 12:56:01 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_init): Initialize DOUBLE_BUFFERED
......
2000-06-02 Havoc Pennington <hp@pobox.com>
* gtk/testtextbuffer.c: Test program to make sure GtkTextBuffer
is in working order.
* gtk/testtext.c: Change to reflect anonymous mark API
* gtk/gtktextview.c: Convert from mark names to GtkTextMark*.
* gtk/gtktexttag.h (struct _GtkTextTag): remove the affects_size
field, which was unused.
* gtk/gtktextmarkprivate.h (GTK_IS_TEXT_MARK): add this macro,
saves some typing.
* gtk/gtktextbuffer.c: Switch from mark names to GtkTextMark*
* gtk/gtktextbtree.c (gtk_text_btree_new): set the not_deleteable
flag on the insertion point and selection bound
Throughout, use GtkTextMark instead of GtkTextLineSegment, and
make mark-manipulation functions take a GtkTextMark* instead of a
mark name.
* gtk/gtktextmarkprivate.h: Add a "not_deleteable" flag to
GtkTextMarkBody; will be used to detect attempts to delete
the permanent marks (insert and selection bound)
* gtk/Makefile.am (noinst_PROGRAMS): add testtextbuffer
Fri Jun 2 12:56:01 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_init): Initialize DOUBLE_BUFFERED
......
2000-06-02 Havoc Pennington <hp@pobox.com>
* gtk/testtextbuffer.c: Test program to make sure GtkTextBuffer
is in working order.
* gtk/testtext.c: Change to reflect anonymous mark API
* gtk/gtktextview.c: Convert from mark names to GtkTextMark*.
* gtk/gtktexttag.h (struct _GtkTextTag): remove the affects_size
field, which was unused.
* gtk/gtktextmarkprivate.h (GTK_IS_TEXT_MARK): add this macro,
saves some typing.
* gtk/gtktextbuffer.c: Switch from mark names to GtkTextMark*
* gtk/gtktextbtree.c (gtk_text_btree_new): set the not_deleteable
flag on the insertion point and selection bound
Throughout, use GtkTextMark instead of GtkTextLineSegment, and
make mark-manipulation functions take a GtkTextMark* instead of a
mark name.
* gtk/gtktextmarkprivate.h: Add a "not_deleteable" flag to
GtkTextMarkBody; will be used to detect attempts to delete
the permanent marks (insert and selection bound)
* gtk/Makefile.am (noinst_PROGRAMS): add testtextbuffer
Fri Jun 2 12:56:01 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_init): Initialize DOUBLE_BUFFERED
......
2000-06-02 Havoc Pennington <hp@pobox.com>
* gtk/testtextbuffer.c: Test program to make sure GtkTextBuffer
is in working order.
* gtk/testtext.c: Change to reflect anonymous mark API
* gtk/gtktextview.c: Convert from mark names to GtkTextMark*.
* gtk/gtktexttag.h (struct _GtkTextTag): remove the affects_size
field, which was unused.
* gtk/gtktextmarkprivate.h (GTK_IS_TEXT_MARK): add this macro,
saves some typing.
* gtk/gtktextbuffer.c: Switch from mark names to GtkTextMark*
* gtk/gtktextbtree.c (gtk_text_btree_new): set the not_deleteable
flag on the insertion point and selection bound
Throughout, use GtkTextMark instead of GtkTextLineSegment, and
make mark-manipulation functions take a GtkTextMark* instead of a
mark name.
* gtk/gtktextmarkprivate.h: Add a "not_deleteable" flag to
GtkTextMarkBody; will be used to detect attempts to delete
the permanent marks (insert and selection bound)
* gtk/Makefile.am (noinst_PROGRAMS): add testtextbuffer
Fri Jun 2 12:56:01 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_init): Initialize DOUBLE_BUFFERED
......
2000-06-02 Havoc Pennington <hp@pobox.com>
* gtk/testtextbuffer.c: Test program to make sure GtkTextBuffer
is in working order.
* gtk/testtext.c: Change to reflect anonymous mark API
* gtk/gtktextview.c: Convert from mark names to GtkTextMark*.
* gtk/gtktexttag.h (struct _GtkTextTag): remove the affects_size
field, which was unused.
* gtk/gtktextmarkprivate.h (GTK_IS_TEXT_MARK): add this macro,
saves some typing.
* gtk/gtktextbuffer.c: Switch from mark names to GtkTextMark*
* gtk/gtktextbtree.c (gtk_text_btree_new): set the not_deleteable
flag on the insertion point and selection bound
Throughout, use GtkTextMark instead of GtkTextLineSegment, and
make mark-manipulation functions take a GtkTextMark* instead of a
mark name.
* gtk/gtktextmarkprivate.h: Add a "not_deleteable" flag to
GtkTextMarkBody; will be used to detect attempts to delete
the permanent marks (insert and selection bound)
* gtk/Makefile.am (noinst_PROGRAMS): add testtextbuffer
Fri Jun 2 12:56:01 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_init): Initialize DOUBLE_BUFFERED
......
......@@ -487,7 +487,7 @@ uninstall-local:
#
# test programs, not to be installed
#
noinst_PROGRAMS = testgtk testcalendar testinput testselection testrgb testdnd testtext simple # testthreads
noinst_PROGRAMS = testgtk testcalendar testinput testselection testrgb testdnd testtext simple testtextbuffer # testthreads
DEPS = libgtk.la $(top_builddir)/gdk/libgdk.la
LDADDS = @STRIP_BEGIN@ \
libgtk.la \
......@@ -514,6 +514,7 @@ testgtk_LDADD = $(LDADDS)
testinput_LDADD = $(LDADDS)
testselection_LDADD = $(LDADDS)
testtext_LDADD = $(LDADDS)
testtextbuffer_LDADD = $(LDADDS)
testrgb_LDADD = $(LDADDS)
testdnd_LDADD = $(LDADDS)
simple_LDADD = $(LDADDS)
......
......@@ -63,6 +63,7 @@
#include "gtktextlayout.h"
#include "gtktextiterprivate.h"
#include "gtkdebug.h"
#include "gtktextmarkprivate.h"
/*
* Types
......@@ -417,19 +418,27 @@ gtk_text_btree_new (GtkTextTagTable *table,
gtk_text_btree_get_iter_at_line_char(tree, &start, 0, 0);
tree->insert_mark = gtk_text_btree_set_mark(tree,
"insert",
FALSE,
&start,
FALSE);
tree->insert_mark =
(GtkTextLineSegment*) gtk_text_btree_set_mark(tree,
NULL,
"insert",
FALSE,
&start,
FALSE);
tree->insert_mark->body.mark.not_deleteable = TRUE;
tree->insert_mark->body.mark.visible = TRUE;
tree->selection_bound_mark = gtk_text_btree_set_mark(tree,
"selection_bound",
FALSE,
&start,
FALSE);
tree->selection_bound_mark =
(GtkTextLineSegment*) gtk_text_btree_set_mark(tree,
NULL,
"selection_bound",
FALSE,
&start,
FALSE);
tree->selection_bound_mark->body.mark.not_deleteable = TRUE;
mark_segment_ref(tree->insert_mark);
mark_segment_ref(tree->selection_bound_mark);
......@@ -2310,7 +2319,7 @@ redisplay_mark(GtkTextLineSegment *mark)
gtk_text_btree_get_iter_at_mark(mark->body.mark.tree,
&iter,
mark);
(GtkTextMark*)mark);
end = iter;
gtk_text_iter_forward_char(&end);
......@@ -2340,6 +2349,7 @@ ensure_not_off_end(GtkTextBTree *tree,
static GtkTextLineSegment*
real_set_mark(GtkTextBTree *tree,
GtkTextMark *existing_mark,
const gchar *name,
gboolean left_gravity,
const GtkTextIter *where,
......@@ -2350,13 +2360,17 @@ real_set_mark(GtkTextBTree *tree,
GtkTextIter iter;
g_return_val_if_fail(tree != NULL, NULL);
g_return_val_if_fail(name != NULL, NULL);
g_return_val_if_fail(where != NULL, NULL);
g_return_val_if_fail(gtk_text_iter_get_btree(where) == tree, NULL);
mark = g_hash_table_lookup(tree->mark_table,
name);
if (existing_mark)
mark = (GtkTextLineSegment*) existing_mark;
else if (name != NULL)
mark = g_hash_table_lookup(tree->mark_table,
name);
else
mark = NULL;
if (should_exist && mark == NULL)
{
g_warning("No mark `%s' exists!", name);
......@@ -2376,7 +2390,7 @@ real_set_mark(GtkTextBTree *tree,
{
GtkTextIter old_pos;
gtk_text_btree_get_iter_at_mark (tree, &old_pos, mark);
gtk_text_btree_get_iter_at_mark (tree, &old_pos, (GtkTextMark*)mark);
redisplay_region (tree, &old_pos, where);
}
......@@ -2411,9 +2425,10 @@ real_set_mark(GtkTextBTree *tree,
mark->body.mark.line = gtk_text_iter_get_line(&iter);
g_hash_table_insert(tree->mark_table,
mark->body.mark.name,
mark);
if (mark->body.mark.name)
g_hash_table_insert(tree->mark_table,
mark->body.mark.name,
mark);
}
/* Link mark into new location */
......@@ -2432,15 +2447,17 @@ real_set_mark(GtkTextBTree *tree,
}
GtkTextLineSegment*
GtkTextMark*
gtk_text_btree_set_mark (GtkTextBTree *tree,
GtkTextMark *existing_mark,
const gchar *name,
gboolean left_gravity,
const GtkTextIter *iter,
gboolean should_exist)
{
return real_set_mark(tree, name, left_gravity, iter, should_exist,
TRUE);
return (GtkTextMark*)real_set_mark(tree, existing_mark,
name, left_gravity, iter, should_exist,
TRUE);
}
gboolean
......@@ -2448,8 +2465,10 @@ gtk_text_btree_get_selection_bounds (GtkTextBTree *tree,
GtkTextIter *start,
GtkTextIter *end)
{
gtk_text_btree_get_iter_at_mark (tree, start, tree->insert_mark);
gtk_text_btree_get_iter_at_mark (tree, end, tree->selection_bound_mark);
gtk_text_btree_get_iter_at_mark (tree, start,
(GtkTextMark*)tree->insert_mark);
gtk_text_btree_get_iter_at_mark (tree, end,
(GtkTextMark*)tree->selection_bound_mark);
if (gtk_text_iter_equal(start, end))
return FALSE;
......@@ -2470,15 +2489,17 @@ gtk_text_btree_place_cursor(GtkTextBTree *tree,
redisplay_region(tree, &start, &end);
/* Move insert AND selection_bound before we redisplay */
real_set_mark(tree, "insert", FALSE, iter, TRUE, FALSE);
real_set_mark(tree, "selection_bound", FALSE, iter, TRUE, FALSE);
real_set_mark(tree, (GtkTextMark*) tree->insert_mark,
"insert", FALSE, iter, TRUE, FALSE);
real_set_mark(tree, (GtkTextMark*) tree->selection_bound_mark,
"selection_bound", FALSE, iter, TRUE, FALSE);
}
void
gtk_text_btree_remove_mark_by_name (GtkTextBTree *tree,
const gchar *name)
{
GtkTextLineSegment *mark;
GtkTextMark *mark;
g_return_if_fail(tree != NULL);
g_return_if_fail(name != NULL);
......@@ -2491,35 +2512,44 @@ gtk_text_btree_remove_mark_by_name (GtkTextBTree *tree,
void
gtk_text_btree_remove_mark (GtkTextBTree *tree,
GtkTextLineSegment *segment)
GtkTextMark *mark)
{
GtkTextLineSegment *segment = (GtkTextLineSegment*) mark;
g_return_if_fail(segment != NULL);
g_return_if_fail(segment != tree->selection_bound_mark);
g_return_if_fail(segment != tree->insert_mark);
g_return_if_fail(tree != NULL);
if (segment->body.mark.not_deleteable)
{
g_warning("Can't delete special mark `%s'", segment->body.mark.name);
return;
}
gtk_text_btree_unlink_segment(tree, segment, segment->body.mark.line);
/* FIXME should probably cleanup_line but Tk didn't */
g_hash_table_remove(tree->mark_table, segment->body.mark.name);
if (segment->body.mark.name)
g_hash_table_remove(tree->mark_table, segment->body.mark.name);
mark_segment_unref(segment);
segments_changed(tree);
}
gboolean
gtk_text_btree_mark_is_insert (GtkTextBTree *tree,
GtkTextLineSegment *segment)
GtkTextMark *segment)
{
return segment == tree->insert_mark;
return segment == (GtkTextMark*) tree->insert_mark;
}
gboolean
gtk_text_btree_mark_is_selection_bound (GtkTextBTree *tree,
GtkTextLineSegment *segment)
GtkTextMark *segment)
{
return segment == tree->selection_bound_mark;
return segment == (GtkTextMark*) tree->selection_bound_mark;
}
GtkTextLineSegment*
GtkTextMark*
gtk_text_btree_get_mark_by_name (GtkTextBTree *tree,
const gchar *name)
{
......
......@@ -117,7 +117,7 @@ gboolean gtk_text_btree_get_iter_at_mark_name (GtkTextBTree *tree,
const gchar *mark_name);
void gtk_text_btree_get_iter_at_mark (GtkTextBTree *tree,
GtkTextIter *iter,
GtkTextLineSegment *mark);
GtkTextMark *mark);
void gtk_text_btree_get_last_iter (GtkTextBTree *tree,
GtkTextIter *iter);
void gtk_text_btree_get_iter_at_line (GtkTextBTree *tree,
......@@ -133,25 +133,26 @@ gboolean gtk_text_btree_get_iter_at_last_toggle (GtkTextBTree *tree,
/* Manipulate marks */
GtkTextLineSegment *gtk_text_btree_set_mark (GtkTextBTree *tree,
GtkTextMark *gtk_text_btree_set_mark (GtkTextBTree *tree,
GtkTextMark *existing_mark,
const gchar *name,
gboolean left_gravity,
const GtkTextIter *index,
gboolean should_exist);
gboolean should_exist);
void gtk_text_btree_remove_mark_by_name (GtkTextBTree *tree,
const gchar *name);
void gtk_text_btree_remove_mark (GtkTextBTree *tree,
GtkTextLineSegment *segment);
GtkTextMark *segment);
gboolean gtk_text_btree_get_selection_bounds (GtkTextBTree *tree,
GtkTextIter *start,
GtkTextIter *end);
void gtk_text_btree_place_cursor (GtkTextBTree *tree,
const GtkTextIter *where);
gboolean gtk_text_btree_mark_is_insert (GtkTextBTree *tree,
GtkTextLineSegment *segment);
GtkTextMark *segment);
gboolean gtk_text_btree_mark_is_selection_bound (GtkTextBTree *tree,
GtkTextLineSegment *segment);
GtkTextLineSegment *gtk_text_btree_get_mark_by_name (GtkTextBTree *tree,
GtkTextMark *segment);
GtkTextMark *gtk_text_btree_get_mark_by_name (GtkTextBTree *tree,
const gchar *name);
GtkTextLine * gtk_text_btree_first_could_contain_tag (GtkTextBTree *tree,
GtkTextTag *tag);
......
......@@ -377,7 +377,9 @@ gtk_text_buffer_insert_at_cursor (GtkTextBuffer *buffer,
g_return_if_fail(GTK_IS_TEXT_BUFFER(buffer));
g_return_if_fail(text != NULL);
gtk_text_buffer_get_iter_at_mark(buffer, &iter, "insert");
gtk_text_buffer_get_iter_at_mark(buffer, &iter,
gtk_text_buffer_get_mark (buffer,
"insert"));
gtk_text_buffer_insert(buffer, &iter, text, len);
}
......@@ -700,7 +702,7 @@ gtk_text_buffer_insert_pixmap_at_char (GtkTextBuffer *buffer,
static void
gtk_text_buffer_mark_set (GtkTextBuffer *buffer,
const GtkTextIter *location,
const char *mark_name)
GtkTextMark *mark)
{
/* IMO this should NOT work like insert_text and delete_text,
where the real action happens in the default handler.
......@@ -714,7 +716,7 @@ gtk_text_buffer_mark_set (GtkTextBuffer *buffer,
gtk_signal_emit(GTK_OBJECT(buffer),
signals[MARK_SET],
&location,
mark_name);
mark);
}
......@@ -734,17 +736,19 @@ gtk_text_buffer_mark_set (GtkTextBuffer *buffer,
**/
static GtkTextMark*
gtk_text_buffer_set_mark(GtkTextBuffer *buffer,
GtkTextMark *existing_mark,
const gchar *mark_name,
const GtkTextIter *iter,
gboolean left_gravity,
gboolean should_exist)
{
GtkTextIter location;
GtkTextLineSegment *mark;
GtkTextMark *mark;
g_return_val_if_fail(GTK_IS_TEXT_BUFFER(buffer), NULL);
mark = gtk_text_btree_set_mark(buffer->tree,
existing_mark,
mark_name,
left_gravity,
iter,
......@@ -759,8 +763,8 @@ gtk_text_buffer_set_mark(GtkTextBuffer *buffer,
gtk_text_btree_get_iter_at_mark(buffer->tree,
&location,
mark);
gtk_text_buffer_mark_set (buffer, &location, mark_name);
gtk_text_buffer_mark_set (buffer, &location, mark);
return (GtkTextMark*)mark;
}
......@@ -771,64 +775,59 @@ gtk_text_buffer_create_mark(GtkTextBuffer *buffer,
const GtkTextIter *where,
gboolean left_gravity)
{
return gtk_text_buffer_set_mark(buffer, mark_name, where,
return gtk_text_buffer_set_mark(buffer, NULL, mark_name, where,
left_gravity, FALSE);
}
void
gtk_text_buffer_move_mark(GtkTextBuffer *buffer,
const gchar *mark_name,
GtkTextMark *mark,
const GtkTextIter *where)
{
gtk_text_buffer_set_mark(buffer, mark_name, where, FALSE, TRUE);
g_return_if_fail (mark != NULL);
gtk_text_buffer_set_mark(buffer, mark, NULL, where, FALSE, TRUE);
}
gboolean
void
gtk_text_buffer_get_iter_at_mark(GtkTextBuffer *buffer,
GtkTextIter *iter,
const gchar *name)
GtkTextMark *mark)
{
g_return_val_if_fail(GTK_IS_TEXT_BUFFER(buffer), FALSE);
g_return_if_fail(GTK_IS_TEXT_BUFFER(buffer));
return gtk_text_btree_get_iter_at_mark_name(buffer->tree,
iter,
name);
gtk_text_btree_get_iter_at_mark(buffer->tree,
iter,
mark);
}
void
gtk_text_buffer_delete_mark(GtkTextBuffer *buffer,
const gchar *name)
GtkTextMark *mark)
{
g_return_if_fail(GTK_IS_TEXT_BUFFER(buffer));
if (strcmp(name, "insert") == 0 ||
strcmp(name, "selection_bound") == 0)
{
g_warning("Can't delete special mark `%s'", name);
return;
}
gtk_text_btree_remove_mark_by_name(buffer->tree, name);
gtk_text_btree_remove_mark (buffer->tree, mark);
/* See rationale above for MARK_SET on why we emit this after
removing the mark, rather than removing the mark in a default
handler. */
gtk_signal_emit(GTK_OBJECT(buffer), signals[MARK_DELETED],
name);
mark);
}
GtkTextMark*
gtk_text_buffer_get_mark (GtkTextBuffer *buffer,
const gchar *name)
{
GtkTextLineSegment *seg;
GtkTextMark *mark;
g_return_val_if_fail(GTK_IS_TEXT_BUFFER(buffer), NULL);
g_return_val_if_fail(name != NULL, NULL);
seg = gtk_text_btree_get_mark_by_name(buffer->tree, name);
mark = gtk_text_btree_get_mark_by_name(buffer->tree, name);
return (GtkTextMark*)seg;
return mark;
}
void
......@@ -838,8 +837,12 @@ gtk_text_buffer_place_cursor (GtkTextBuffer *buffer,
g_return_if_fail(GTK_IS_TEXT_BUFFER(buffer));
gtk_text_btree_place_cursor(buffer->tree, where);
gtk_text_buffer_mark_set (buffer, where, "insert");
gtk_text_buffer_mark_set (buffer, where, "selection_bound");
gtk_text_buffer_mark_set (buffer, where,
gtk_text_buffer_get_mark (buffer,
"insert"));
gtk_text_buffer_mark_set (buffer, where,
gtk_text_buffer_get_mark (buffer,
"selection_bound"));
}
/*
......@@ -1233,11 +1236,15 @@ selection_clear_event(GtkWidget *widget, GdkEventSelection *event,
GtkTextIter insert;
GtkTextIter selection_bound;
gtk_text_buffer_get_iter_at_mark(buffer, &insert, "insert");
gtk_text_buffer_get_iter_at_mark(buffer, &selection_bound, "selection_bound");
gtk_text_buffer_get_iter_at_mark(buffer, &insert,
gtk_text_buffer_get_mark (buffer, "insert"));
gtk_text_buffer_get_iter_at_mark(buffer, &selection_bound,
gtk_text_buffer_get_mark (buffer, "selection_bound"));
if (!gtk_text_iter_equal(&insert, &selection_bound))
gtk_text_buffer_move_mark(buffer, "selection_bound", &insert);
gtk_text_buffer_move_mark(buffer,
gtk_text_buffer_get_mark (buffer, "selection_bound"),
&insert);
}
else if (event->selection == clipboard_atom)
{
......@@ -1347,6 +1354,7 @@ selection_received (GtkWidget *widget,
GtkTextBuffer *buffer;
gboolean reselect;
GtkTextIter insert_point;
GtkTextMark *paste_point_override;
enum {INVALID, STRING, CTEXT, UTF8} type;
g_return_if_fail (widget != NULL);
......@@ -1373,15 +1381,22 @@ selection_received (GtkWidget *widget,
return;
}
if (gtk_text_buffer_get_iter_at_mark(buffer, &insert_point,
"__paste_point_override"))
paste_point_override = gtk_text_buffer_get_mark (buffer,
"__paste_point_override");
if (paste_point_override != NULL)
{
gtk_text_buffer_delete_mark(buffer, "__paste_point_override");
gtk_text_buffer_get_iter_at_mark(buffer, &insert_point,
paste_point_override);
gtk_text_buffer_delete_mark(buffer,
gtk_text_buffer_get_mark (buffer,
"__paste_point_override"));
}
else
{
gtk_text_buffer_get_iter_at_mark(buffer, &insert_point,
"insert");
gtk_text_buffer_get_mark (buffer,
"insert"));
}
reselect = FALSE;
......@@ -1594,11 +1609,15 @@ cut_or_copy(GtkTextBuffer *buffer,
if (!gtk_text_buffer_get_selection_bounds(buffer, &start, &end))
{
/* Let's try the anchor thing */
if (!gtk_text_buffer_get_iter_at_mark(buffer, &end, "anchor"))
GtkTextMark * anchor = gtk_text_buffer_get_mark (buffer, "anchor");
if (anchor == NULL)
return;
else
gtk_text_iter_reorder(&start, &end);
{
gtk_text_buffer_get_iter_at_mark(buffer, &end, anchor);
gtk_text_iter_reorder(&start, &end);
}
}