+/**
+ * glk_cancel_line_event:
+ * @win: A text buffer or text grid window to cancel line input on.
+ * @event: Will be filled in if the user had already input something.
+ *
+ * This cancels a pending request for line input. (Either Latin-1 or Unicode.)
+ *
+ * The event pointed to by the event argument will be filled in as if the
+ * player had hit <keycap>enter</keycap>, and the input composed so far will be stored in the
+ * buffer; see below. If you do not care about this information, pass %NULL as
+ * the @event argument. (The buffer will still be filled.)
+ *
+ * For convenience, it is legal to call glk_cancel_line_event() even if there
+ * is no line input request on that window. The event type will be set to
+ * #evtype_None in this case.
+ */
+void
+glk_cancel_line_event(winid_t win, event_t *event)
+{
+ /* TODO: write me */
+ VALID_WINDOW(win, return);
+ g_return_if_fail(win->input_request_type != INPUT_REQUEST_NONE);
+ g_return_if_fail(win->type != wintype_TextBuffer || win->type != wintype_TextGrid);
+
+ event->type = evtype_None;
+ event->win = win;
+ event->val1 = 0;
+ event->val2 = 0;
+
+ g_signal_handler_block( G_OBJECT(win->widget), win->keypress_handler );
+
+ int chars_written = 0;
+
+ if(win->type == wintype_TextGrid) {
+ g_signal_handler_block( G_OBJECT(win->widget), win->keypress_handler );
+ chars_written = flush_text_grid(win);
+ } else if(win->type == wintype_TextBuffer) {
+ GtkTextBuffer *window_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) );
+ g_signal_handler_block(window_buffer, win->insert_text_handler);
+ chars_written = flush_text_buffer(win);
+ }
+
+ if(chars_written > 0) {
+ event->type = evtype_LineInput;
+ event->val1 = chars_written;
+ }
+}
+