mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
Thu Oct 21 15:01:09 2004 Owen Taylor <otaylor@redhat.com> #155952 * gtk/gtkentry.c: Fix checking the wrong position for the backspace_deletes_character PangoLogAttr. * gtk/gtktextbuffer.[ch] gtk/gtk.symbols (gtk_text_buffer_backspace): Move backspace logic from GtkTextView to here, check backspace_deletes_char. * gtk/gtktextview.c: Use gtk_text_buffer_backspace().
This commit is contained in:
parent
92b3cda495
commit
e0ad07e0b4
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
||||
Thu Oct 21 15:01:09 2004 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
#155952
|
||||
|
||||
* gtk/gtkentry.c: Fix checking the wrong position for
|
||||
the backspace_deletes_character PangoLogAttr.
|
||||
|
||||
* gtk/gtktextbuffer.[ch] gtk/gtk.symbols (gtk_text_buffer_backspace):
|
||||
Move backspace logic from GtkTextView to here, check
|
||||
backspace_deletes_char.
|
||||
|
||||
* gtk/gtktextview.c: Use gtk_text_buffer_backspace().
|
||||
|
||||
2004-10-21 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkiconcache.c: Include io.h on windows. (#156075,
|
||||
|
@ -1,3 +1,16 @@
|
||||
Thu Oct 21 15:01:09 2004 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
#155952
|
||||
|
||||
* gtk/gtkentry.c: Fix checking the wrong position for
|
||||
the backspace_deletes_character PangoLogAttr.
|
||||
|
||||
* gtk/gtktextbuffer.[ch] gtk/gtk.symbols (gtk_text_buffer_backspace):
|
||||
Move backspace logic from GtkTextView to here, check
|
||||
backspace_deletes_char.
|
||||
|
||||
* gtk/gtktextview.c: Use gtk_text_buffer_backspace().
|
||||
|
||||
2004-10-21 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkiconcache.c: Include io.h on windows. (#156075,
|
||||
|
@ -1,3 +1,16 @@
|
||||
Thu Oct 21 15:01:09 2004 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
#155952
|
||||
|
||||
* gtk/gtkentry.c: Fix checking the wrong position for
|
||||
the backspace_deletes_character PangoLogAttr.
|
||||
|
||||
* gtk/gtktextbuffer.[ch] gtk/gtk.symbols (gtk_text_buffer_backspace):
|
||||
Move backspace logic from GtkTextView to here, check
|
||||
backspace_deletes_char.
|
||||
|
||||
* gtk/gtktextview.c: Use gtk_text_buffer_backspace().
|
||||
|
||||
2004-10-21 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkiconcache.c: Include io.h on windows. (#156075,
|
||||
|
@ -1,3 +1,16 @@
|
||||
Thu Oct 21 15:01:09 2004 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
#155952
|
||||
|
||||
* gtk/gtkentry.c: Fix checking the wrong position for
|
||||
the backspace_deletes_character PangoLogAttr.
|
||||
|
||||
* gtk/gtktextbuffer.[ch] gtk/gtk.symbols (gtk_text_buffer_backspace):
|
||||
Move backspace logic from GtkTextView to here, check
|
||||
backspace_deletes_char.
|
||||
|
||||
* gtk/gtktextview.c: Use gtk_text_buffer_backspace().
|
||||
|
||||
2004-10-21 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkiconcache.c: Include io.h on windows. (#156075,
|
||||
|
@ -2948,6 +2948,7 @@ gtk_text_buffer_insert_with_tags
|
||||
gtk_text_buffer_insert_with_tags_by_name
|
||||
gtk_text_buffer_delete
|
||||
gtk_text_buffer_delete_interactive
|
||||
gtk_text_buffer_backspace
|
||||
gtk_text_buffer_set_text
|
||||
gtk_text_buffer_get_text
|
||||
gtk_text_buffer_get_slice
|
||||
|
@ -1855,6 +1855,7 @@ gtk_text_backward_delete
|
||||
gtk_text_buffer_add_selection_clipboard
|
||||
gtk_text_buffer_apply_tag
|
||||
gtk_text_buffer_apply_tag_by_name
|
||||
gtk_text_buffer_backspace
|
||||
gtk_text_buffer_begin_user_action
|
||||
gtk_text_buffer_copy_clipboard
|
||||
gtk_text_buffer_create_child_anchor
|
||||
|
@ -2536,7 +2536,7 @@ gtk_entry_backspace (GtkEntry *entry)
|
||||
|
||||
pango_layout_get_log_attrs (layout, &log_attrs, &n_attrs);
|
||||
|
||||
if (log_attrs[prev_pos].backspace_deletes_character)
|
||||
if (log_attrs[entry->current_pos].backspace_deletes_character)
|
||||
{
|
||||
gchar *cluster_text;
|
||||
gchar *normalized_text;
|
||||
|
@ -3382,6 +3382,91 @@ gtk_text_buffer_delete_selection (GtkTextBuffer *buffer,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_text_buffer_backspace:
|
||||
* @buffer: a #GtkTextBuffer
|
||||
* @iter: a position in @buffer
|
||||
* @interactive: whether the deletion is caused by user interaction
|
||||
* @default_editable: whether the buffer is editable by default
|
||||
*
|
||||
* Performs the appropriate action as if the user hit the delete
|
||||
* key with the cursor at the position specified by @iter. In the
|
||||
* normal case a single character will be deleted, but when
|
||||
* combining accents are involved, more than one character can
|
||||
* be deleted, and when precomposed character and accent combinations,
|
||||
* less than one character will be deleted.
|
||||
*
|
||||
* @iter must be at a cursor position.
|
||||
*
|
||||
* Return value: %TRUE if tbe buffer was modified
|
||||
|
||||
* Since: 2.6
|
||||
**/
|
||||
gboolean
|
||||
gtk_text_buffer_backspace (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
gboolean interactive,
|
||||
gboolean default_editable)
|
||||
{
|
||||
gchar *cluster_text;
|
||||
GtkTextIter start;
|
||||
GtkTextIter end;
|
||||
gboolean retval = FALSE;
|
||||
const PangoLogAttr *attrs;
|
||||
int offset;
|
||||
gboolean backspace_deletes_character;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), FALSE);
|
||||
g_return_val_if_fail (iter != NULL, FALSE);
|
||||
|
||||
start = *iter;
|
||||
end = *iter;
|
||||
|
||||
attrs = _gtk_text_buffer_get_line_log_attrs (buffer, &start, NULL);
|
||||
offset = gtk_text_iter_get_line_offset (&start);
|
||||
backspace_deletes_character = attrs[offset].backspace_deletes_character;
|
||||
|
||||
gtk_text_iter_backward_cursor_position (&start);
|
||||
|
||||
if (gtk_text_iter_equal (&start, &end))
|
||||
return FALSE;
|
||||
|
||||
cluster_text = gtk_text_iter_get_text (&start, &end);
|
||||
|
||||
if (interactive)
|
||||
gtk_text_buffer_begin_user_action (buffer);
|
||||
|
||||
if (gtk_text_buffer_delete_interactive (buffer, &start, &end,
|
||||
default_editable))
|
||||
{
|
||||
if (backspace_deletes_character)
|
||||
{
|
||||
gchar *normalized_text = g_utf8_normalize (cluster_text,
|
||||
strlen (cluster_text),
|
||||
G_NORMALIZE_NFD);
|
||||
glong len = g_utf8_strlen (normalized_text, -1);
|
||||
|
||||
if (len > 1)
|
||||
gtk_text_buffer_insert_interactive (buffer,
|
||||
&start,
|
||||
normalized_text,
|
||||
g_utf8_offset_to_pointer (normalized_text, len - 1) - normalized_text,
|
||||
default_editable);
|
||||
|
||||
g_free (normalized_text);
|
||||
}
|
||||
|
||||
retval = TRUE;
|
||||
}
|
||||
|
||||
if (interactive)
|
||||
gtk_text_buffer_end_user_action (buffer);
|
||||
|
||||
g_free (cluster_text);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void
|
||||
cut_or_copy (GtkTextBuffer *buffer,
|
||||
GtkClipboard *clipboard,
|
||||
|
@ -197,14 +197,16 @@ void gtk_text_buffer_insert_with_tags_by_name (GtkTextBuffer *buffer,
|
||||
|
||||
/* Delete from the buffer */
|
||||
void gtk_text_buffer_delete (GtkTextBuffer *buffer,
|
||||
GtkTextIter *start,
|
||||
GtkTextIter *end);
|
||||
GtkTextIter *start,
|
||||
GtkTextIter *end);
|
||||
gboolean gtk_text_buffer_delete_interactive (GtkTextBuffer *buffer,
|
||||
GtkTextIter *start_iter,
|
||||
GtkTextIter *end_iter,
|
||||
gboolean default_editable);
|
||||
|
||||
|
||||
GtkTextIter *start_iter,
|
||||
GtkTextIter *end_iter,
|
||||
gboolean default_editable);
|
||||
gboolean gtk_text_buffer_backspace (GtkTextBuffer *buffer,
|
||||
GtkTextIter *iter,
|
||||
gboolean interactive,
|
||||
gboolean default_editable);
|
||||
|
||||
/* Obtain strings from the buffer */
|
||||
gchar *gtk_text_buffer_get_text (GtkTextBuffer *buffer,
|
||||
|
@ -5147,8 +5147,6 @@ static void
|
||||
gtk_text_view_backspace (GtkTextView *text_view)
|
||||
{
|
||||
GtkTextIter insert;
|
||||
GtkTextIter start;
|
||||
GtkTextIter end;
|
||||
|
||||
gtk_text_view_reset_im_context (text_view);
|
||||
|
||||
@ -5162,41 +5160,12 @@ gtk_text_view_backspace (GtkTextView *text_view)
|
||||
gtk_text_buffer_get_mark (get_buffer (text_view),
|
||||
"insert"));
|
||||
|
||||
start = insert;
|
||||
end = insert;
|
||||
|
||||
gtk_text_iter_backward_cursor_position (&end);
|
||||
|
||||
if (!gtk_text_iter_equal (&start, &end))
|
||||
if (gtk_text_buffer_backspace (get_buffer (text_view), &insert,
|
||||
TRUE, text_view->editable))
|
||||
{
|
||||
gchar *cluster_text = gtk_text_iter_get_text (&start, &end);
|
||||
|
||||
gtk_text_buffer_begin_user_action (get_buffer (text_view));
|
||||
|
||||
if (gtk_text_buffer_delete_interactive (get_buffer (text_view), &start, &end,
|
||||
text_view->editable))
|
||||
{
|
||||
gchar *normalized_text = g_utf8_normalize (cluster_text,
|
||||
strlen (cluster_text),
|
||||
G_NORMALIZE_NFD);
|
||||
glong len = g_utf8_strlen (normalized_text, -1);
|
||||
|
||||
if (len > 1)
|
||||
gtk_text_buffer_insert_interactive_at_cursor (get_buffer (text_view),
|
||||
normalized_text,
|
||||
g_utf8_offset_to_pointer (normalized_text, len - 1) - normalized_text,
|
||||
text_view->editable);
|
||||
|
||||
g_free (normalized_text);
|
||||
}
|
||||
|
||||
gtk_text_buffer_end_user_action (get_buffer (text_view));
|
||||
|
||||
g_free (cluster_text);
|
||||
|
||||
DV(g_print (G_STRLOC": scrolling onscreen\n"));
|
||||
gtk_text_view_scroll_mark_onscreen (text_view,
|
||||
gtk_text_buffer_get_mark (get_buffer (text_view), "insert"));
|
||||
gtk_text_buffer_get_mark (get_buffer (text_view), "insert"));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user