summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-11-13 23:56:11 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-11-13 23:56:11 +0000
commit8befd2f82291c9812d101089c35db1982a41b6c4 (patch)
tree6903f7f9390dc810c760aa934aea5076b1646516 /gtk
parent10b3db083625acb6f6ae2904b9de39c8dc829a04 (diff)
downloadgtk+-8befd2f82291c9812d101089c35db1982a41b6c4.tar.gz
fix to properly replace selection with Return or Tab
2001-11-13 Havoc Pennington <hp@redhat.com> * gtk/gtktextview.c (gtk_text_view_key_press_event): fix to properly replace selection with Return or Tab * gtk/gtktextdisplay.c (gtk_text_layout_draw): fix broken code that didn't locate the end of the line correctly, should fix #63800
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtktextdisplay.c9
-rw-r--r--gtk/gtktextview.c24
2 files changed, 14 insertions, 19 deletions
diff --git a/gtk/gtktextdisplay.c b/gtk/gtktextdisplay.c
index 1d53096a42..fd5a9d137e 100644
--- a/gtk/gtktextdisplay.c
+++ b/gtk/gtktextdisplay.c
@@ -785,12 +785,9 @@ gtk_text_layout_draw (GtkTextLayout *layout,
gtk_text_layout_get_iter_at_line (layout,
&line_start,
line, 0);
- byte_count = gtk_text_iter_get_bytes_in_line (&line_start);
-
- /* FIXME the -1 assumes a newline I think */
- gtk_text_layout_get_iter_at_line (layout,
- &line_end,
- line, byte_count - 1);
+ line_end = line_start;
+ gtk_text_iter_forward_to_line_end (&line_end);
+ byte_count = gtk_text_iter_get_line_index (&line_end);
if (gtk_text_iter_compare (&selection_start, &line_end) <= 0 &&
gtk_text_iter_compare (&selection_end, &line_start) >= 0)
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 95834e9fae..25b5e0c5d1 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -262,6 +262,8 @@ static void gtk_text_view_value_changed (GtkAdjustment *adj,
static void gtk_text_view_commit_handler (GtkIMContext *context,
const gchar *str,
GtkTextView *text_view);
+static void gtk_text_view_commit_text (GtkTextView *text_view,
+ const gchar *text);
static void gtk_text_view_preedit_changed_handler (GtkIMContext *context,
GtkTextView *text_view);
static gboolean gtk_text_view_retrieve_surrounding_handler (GtkIMContext *context,
@@ -3377,13 +3379,7 @@ gtk_text_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
else if (event->keyval == GDK_Return ||
event->keyval == GDK_KP_Enter)
{
- gtk_text_buffer_insert_interactive_at_cursor (get_buffer (text_view), "\n", 1,
- text_view->editable);
- DV(g_print (G_STRLOC": scrolling to mark\n"));
- gtk_text_view_scroll_to_mark (text_view,
- gtk_text_buffer_get_mark (get_buffer (text_view),
- "insert"),
- 0.0, FALSE, 0.0, 0.0);
+ gtk_text_view_commit_text (text_view, "\n");
retval = TRUE;
}
/* Pass through Tab as literal tab, unless Control is held down */
@@ -3392,12 +3388,7 @@ gtk_text_view_key_press_event (GtkWidget *widget, GdkEventKey *event)
event->keyval == GDK_ISO_Left_Tab) &&
!(event->state & GDK_CONTROL_MASK))
{
- gtk_text_buffer_insert_interactive_at_cursor (get_buffer (text_view), "\t", 1,
- text_view->editable);
- 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_view_commit_text (text_view, "\t");
retval = TRUE;
}
else
@@ -5386,6 +5377,13 @@ gtk_text_view_commit_handler (GtkIMContext *context,
const gchar *str,
GtkTextView *text_view)
{
+ gtk_text_view_commit_text (text_view, str);
+}
+
+static void
+gtk_text_view_commit_text (GtkTextView *text_view,
+ const gchar *str)
+{
gboolean had_selection;
gtk_text_buffer_begin_user_action (get_buffer (text_view));