--- gtktext.c.orig Tue Apr 21 15:46:48 1998 +++ gtktext.c Thu Apr 30 00:24:50 1998 @@ -300,6 +300,12 @@ static void gtk_text_select_line (GtkText *text, guint32 time); +static void gtk_text_set_info (GtkText* text, + gint type, + const gchar* data, + gint size, + gint location); + /* #define DEBUG_GTK_TEXT */ #if defined(DEBUG_GTK_TEXT) && defined(__GNUC__) @@ -504,6 +510,8 @@ text->button = 0; GTK_EDITABLE(text)->editable = FALSE; + + text->collect_info = FALSE; } GtkWidget* @@ -744,6 +752,8 @@ memcpy (text->text + text->gap_position, chars, length); + gtk_text_set_info( text, 1, chars, length, text->point.index ); + insert_text_property (text, font, fore, back, length); text->gap_size -= length; @@ -826,6 +836,8 @@ move_gap_to_point (text); + gtk_text_set_info( text, 0, text->text + text->gap_position + text->gap_size, nchars, text->point.index ); + text->gap_size += nchars; delete_text_property (text, nchars); @@ -839,6 +851,57 @@ return TRUE; } +void +gtk_text_set_cursor (GtkText *text, + guint position) +{ + GtkEditable *editable = (GtkEditable *) text; + + undraw_cursor( text, FALSE ); + text->has_cursor = 1; + text->cursor_mark = find_mark( text, position ); + find_cursor( text, FALSE ); + if (!text->freeze) + { + find_line_containing_point (text, text->cursor_mark.index, TRUE); + } + draw_cursor( text, FALSE ); + editable->has_selection = FALSE; +} + +guint +gtk_text_get_cursor (GtkText *text) +{ + if( text->has_cursor ) + return text->cursor_mark.index; + else + return 0; +} + +void +gtk_text_collect_info( GtkText *text, + gboolean collect ) +{ + text->collect_info = collect; +} + +void +gtk_text_get_info (GtkText *text, + gint *type, + gchar **info, + gint *length, + gint *location) +{ + if (type) + *type = text->last_change_type; + if (info) + *info = text->last_change_info; + if (length) + *length = text->last_change_length; + if (location) + *location = text->last_change_location; +} + static gchar * gtk_text_get_chars (GtkEditable *editable, gint start_pos, @@ -3201,6 +3264,24 @@ g_list_free (member); return list->next; + } +} + +/**********************************************************************/ +/* Change Information */ +/**********************************************************************/ + +void +gtk_text_set_info( GtkText *text, gint type, const gchar *data, gint length, gint location ) +{ + if (text->collect_info) + { + g_free (text->last_change_info); + text->last_change_info = g_malloc0 (length + 1); + memcpy (text->last_change_info, data, length); + text->last_change_type = type; + text->last_change_length = length; + text->last_change_location = location; } }