+
+ return chars_written;
+}
+
+/* Internal function: Callback for signal insert-text on a text buffer window.
+Runs after the default handler has already inserted the text.
+FIXME: This function assumes that newline was the last character typed into the
+window. That assumption is wrong if, for example, text containing a newline was
+pasted into the window. */
+void
+after_window_insert_text(GtkTextBuffer *textbuffer, GtkTextIter *location, gchar *text, gint len, winid_t win)
+{
+ if( strchr(text, '\n') != NULL )
+ {
+ /* Remove signal handlers */
+ GtkTextBuffer *window_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) );
+ g_signal_handler_block(window_buffer, win->insert_text_handler);
+
+ /* Make the window uneditable again and retrieve the text that was input */
+ gtk_text_view_set_editable(GTK_TEXT_VIEW(win->widget), FALSE);
+
+ int chars_written = flush_text_buffer(win);
+ event_throw(evtype_LineInput, win, chars_written, 0);
+ }
+}
+
+/* Internal function: Callback for signal activate on the line input GtkEntry
+in a text grid window. */
+void
+on_input_entry_activate(GtkEntry *input_entry, winid_t win)
+{
+ g_signal_handler_block( G_OBJECT(win->widget), win->keypress_handler );
+
+ int chars_written = flush_text_grid(win);
+ event_throw(evtype_LineInput, win, chars_written, 0);