Implement line terminators for text grids
[projects/chimara/chimara.git] / libchimara / input.c
index 4036117f48e5c900935bad3683a96c2bd137ae81..e3f887b23052d38bf6657e38463a03ade49f7706 100644 (file)
@@ -91,6 +91,10 @@ glk_cancel_char_event(winid_t win)
 static void
 text_grid_request_line_event_common(winid_t win, glui32 maxlen, gboolean insert, gchar *inserttext)
 {
+       /* All outstanding printing _must_ be finished before putting an input entry
+        into the buffer */
+       flush_window_buffer(win);
+
        gdk_threads_enter();
 
        GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) );
@@ -811,6 +815,11 @@ on_input_entry_key_press_event(GtkEntry *input_entry, GdkEventKey *event, winid_
                g_signal_handler_unblock(input_entry, win->line_input_entry_changed);
                return TRUE;
        }
+       else if(g_slist_find(win->current_extra_line_terminators, GUINT_TO_POINTER(event->keyval)))
+       {
+               /* If this key was a line terminator, pretend we pressed enter */
+               on_input_entry_activate(input_entry, win);
+       }
        return FALSE;
 }