From 4c2334863d702f2bc590280aafd8d540a71cc1cb Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Sun, 29 Mar 2009 21:38:32 +0000 Subject: [PATCH] Fixed a bug with text grid line input in the middle of an existing selection git-svn-id: http://lassie.dyndns-server.com/svn/gargoyle-gtk@36 ddfedd41-794f-dd11-ae45-00112f111e67 --- src/input.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/input.c b/src/input.c index bda5b4f..c5d7b90 100644 --- a/src/input.c +++ b/src/input.c @@ -60,6 +60,17 @@ text_grid_request_line_event_common(winid_t win, glui32 maxlen, gboolean insert, end_iter = start_iter; gtk_text_iter_set_line_offset(&end_iter, cursorpos + win->input_length); + /* If the buffer currently has a selection with one bound in the middle of + the input field, then deselect it. Otherwise the input field gets trashed */ + GtkTextIter start_sel, end_sel; + if( gtk_text_buffer_get_selection_bounds(buffer, &start_sel, &end_sel) ) + { + if( gtk_text_iter_in_range(&start_sel, &start_iter, &end_iter) ) + gtk_text_buffer_place_cursor(buffer, &end_sel); + if( gtk_text_iter_in_range(&end_sel, &start_iter, &end_iter) ) + gtk_text_buffer_place_cursor(buffer, &start_sel); + } + /* Erase the text currently in the input field and replace it with a GtkEntry */ gtk_text_buffer_delete(buffer, &start_iter, &end_iter); win->input_anchor = gtk_text_buffer_create_child_anchor(buffer, &start_iter); -- 2.30.2