X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fstrio.c;h=ab8443f5f8eb2823576f995bf6cafb6976b7db33;hb=d46503e2c419d4c1235f76d98b889fc1cad2d856;hp=d440832b69f9739c372cfc7794a66d34d87c94d2;hpb=012d66921278f7271a323a50c81bb9e2d6ce6aeb;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/strio.c b/libchimara/strio.c index d440832..ab8443f 100644 --- a/libchimara/strio.c +++ b/libchimara/strio.c @@ -220,6 +220,44 @@ write_buffer_to_stream(strid_t str, gchar *buf, glui32 len) /* Text grid/buffer windows */ case wintype_TextGrid: + { + gchar *utf8 = convert_latin1_to_utf8(buf, len); + if(utf8 != NULL) { + /* Deal with newlines */ + int i; + gchar *line = utf8; + for(i=0; iwindow, line); + flush_window_buffer(str->window); + + /* Move cursor position forward to the next line */ + gdk_threads_enter(); + GtkTextIter cursor_pos; + GtkTextView *textview = GTK_TEXT_VIEW(str->window->widget); + GtkTextBuffer *buffer = gtk_text_view_get_buffer(textview); + GtkTextMark *cursor_mark = gtk_text_buffer_get_mark(buffer, "cursor_position"); + + gtk_text_buffer_get_iter_at_mark( buffer, &cursor_pos, cursor_mark); + gtk_text_view_forward_display_line(textview, &cursor_pos); + gtk_text_view_backward_display_line_start(textview, &cursor_pos); + gtk_text_buffer_move_mark(buffer, cursor_mark, &cursor_pos); + gdk_threads_leave(); + + line = utf8 + (i < len-1 ? (i+1):(len-1)); + } + } + + /* No more newlines left. */ + write_utf8_to_window_buffer(str->window, line); + g_free(utf8); + } + + str->write_count += len; + } + break; + case wintype_TextBuffer: { gchar *utf8 = convert_latin1_to_utf8(buf, len);