From: rodin Date: Fri, 22 May 2009 10:38:41 +0000 (+0000) Subject: * Fixed flush_text_buffer() function. It always assumed a newline at the end and... X-Git-Tag: v0.9~398 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=da2ad6e2baafede9eb52949103e505bf1f1d7d0b;p=projects%2Fchimara%2Fchimara.git * Fixed flush_text_buffer() function. It always assumed a newline at the end and removed it, even when it wasn't there. --- diff --git a/src/input.c b/src/input.c index 418e5ea..89356fa 100644 --- a/src/input.c +++ b/src/input.c @@ -450,15 +450,22 @@ flush_text_buffer(winid_t win) VALID_WINDOW(win, return 0); g_return_val_if_fail(win->type == wintype_TextBuffer, 0); - GtkTextIter start_iter, end_iter; + GtkTextIter start_iter, end_iter, last_character; GtkTextBuffer *window_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) ); GtkTextMark *input_position = gtk_text_buffer_get_mark(window_buffer, "input_position"); gtk_text_buffer_get_iter_at_mark(window_buffer, &start_iter, input_position); gtk_text_buffer_get_end_iter(window_buffer, &end_iter); - gtk_text_iter_backward_cursor_position(&end_iter); /* don't include \n */ - + gtk_text_buffer_get_end_iter(window_buffer, &last_character); + gtk_text_iter_backward_cursor_position(&last_character); + + gchar* last_char = gtk_text_buffer_get_text(window_buffer, &last_character, &end_iter, FALSE); + + if( strchr(last_char, '\n') != NULL ) + gtk_text_iter_backward_cursor_position(&end_iter); + gchar* inserted_text = gtk_text_buffer_get_text(window_buffer, &start_iter, &end_iter, FALSE); + int chars_written = write_to_window_buffer(win, inserted_text); g_free(inserted_text);