4 #include "chimara-glk-private.h"
6 extern GPrivate *glk_data_key;
8 /* Forward declarations */
9 static int flush_text_buffer(winid_t win);
10 static int flush_text_grid(winid_t win);
12 /* Internal function: code common to both flavors of char event request */
14 request_char_event_common(winid_t win, gboolean unicode)
16 VALID_WINDOW(win, return);
17 g_return_if_fail(win->input_request_type == INPUT_REQUEST_NONE);
18 g_return_if_fail(win->type != wintype_TextBuffer || win->type != wintype_TextGrid);
20 win->input_request_type = unicode? INPUT_REQUEST_CHARACTER_UNICODE : INPUT_REQUEST_CHARACTER;
21 g_signal_handler_unblock( G_OBJECT(win->widget), win->keypress_handler );
25 /* If the request is in a text buffer window, scroll to the end of the
26 text buffer. TODO: This may scroll text off the top of the window that the
27 user hasn't read yet. We need to implement a paging mechanism. */
28 if(win->type == wintype_TextBuffer)
30 GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) );
32 gtk_text_buffer_get_end_iter(buffer, &iter);
33 gtk_text_buffer_place_cursor(buffer, &iter);
34 gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(win->widget), gtk_text_buffer_get_insert(buffer));
35 /* Why doesn't this always work?? */
38 gtk_widget_grab_focus( GTK_WIDGET(win->widget) );
43 * glk_request_char_event:
44 * @win: A window to request char events from.
46 * Request input of a Latin-1 character or special key. A window cannot have
47 * requests for both character and line input at the same time. Nor can it have
48 * requests for character input of both types (Latin-1 and Unicode). It is
49 * illegal to call glk_request_char_event() if the window already has a pending
50 * request for either character or line input.
53 glk_request_char_event(winid_t win)
55 request_char_event_common(win, FALSE);
59 * glk_request_char_event_uni:
60 * @win: A window to request char events from.
62 * Request input of a Unicode character or special key. See
63 * glk_request_char_event().
66 glk_request_char_event_uni(winid_t win)
68 request_char_event_common(win, TRUE);
72 * glk_cancel_char_event:
73 * @win: A window to cancel the latest char event request on.
75 * This cancels a pending request for character input. (Either Latin-1 or
76 * Unicode.) For convenience, it is legal to call glk_cancel_char_event() even
77 * if there is no charcter input request on that window. Glk will ignore the
81 glk_cancel_char_event(winid_t win)
83 VALID_WINDOW(win, return);
84 g_return_if_fail(win->type != wintype_TextBuffer || win->type != wintype_TextGrid);
86 if(win->input_request_type == INPUT_REQUEST_CHARACTER || win->input_request_type == INPUT_REQUEST_CHARACTER_UNICODE)
88 win->input_request_type = INPUT_REQUEST_NONE;
89 g_signal_handler_block( G_OBJECT(win->widget), win->keypress_handler );
93 /* Internal function: Request either latin-1 or unicode line input, in a text grid window. */
95 text_grid_request_line_event_common(winid_t win, glui32 maxlen, gboolean insert, gchar *inserttext)
99 GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) );
101 GtkTextMark *cursor = gtk_text_buffer_get_mark(buffer, "cursor_position");
102 GtkTextIter start_iter, end_iter;
103 gtk_text_buffer_get_iter_at_mark(buffer, &start_iter, cursor);
105 /* Determine the maximum length of the line input */
106 gint cursorpos = gtk_text_iter_get_line_offset(&start_iter);
107 /* Odd; the Glk spec says the maximum input length is
108 windowwidth - 1 - cursorposition. I say no, because if cursorposition is
109 zero, then the input should fill the whole line. FIXME??? */
110 win->input_length = MIN(win->width - cursorpos, win->line_input_buffer_max_len);
111 end_iter = start_iter;
112 gtk_text_iter_set_line_offset(&end_iter, cursorpos + win->input_length);
114 /* If the buffer currently has a selection with one bound in the middle of
115 the input field, then deselect it. Otherwise the input field gets trashed */
116 GtkTextIter start_sel, end_sel;
117 if( gtk_text_buffer_get_selection_bounds(buffer, &start_sel, &end_sel) )
119 if( gtk_text_iter_in_range(&start_sel, &start_iter, &end_iter) )
120 gtk_text_buffer_place_cursor(buffer, &end_sel);
121 if( gtk_text_iter_in_range(&end_sel, &start_iter, &end_iter) )
122 gtk_text_buffer_place_cursor(buffer, &start_sel);
125 /* Erase the text currently in the input field and replace it with a GtkEntry */
126 gtk_text_buffer_delete(buffer, &start_iter, &end_iter);
127 win->input_anchor = gtk_text_buffer_create_child_anchor(buffer, &start_iter);
128 win->input_entry = gtk_entry_new();
129 /* Set the entry's font to match that of the window */
130 GtkRcStyle *style = gtk_widget_get_modifier_style(win->widget); /* Don't free */
131 gtk_widget_modify_font(win->input_entry, style->font_desc);
132 /* Make the entry as small as possible to fit with the text */
133 gtk_entry_set_has_frame(GTK_ENTRY(win->input_entry), FALSE);
134 GtkBorder border = { 0, 0, 0, 0 };
135 gtk_entry_set_inner_border(GTK_ENTRY(win->input_entry), &border);
136 gtk_entry_set_max_length(GTK_ENTRY(win->input_entry), win->input_length);
137 gtk_entry_set_width_chars(GTK_ENTRY(win->input_entry), win->input_length);
139 /* Insert pre-entered text if needed */
141 gtk_entry_set_text(GTK_ENTRY(win->input_entry), inserttext);
143 /* Set background color of entry (TODO: implement as property) */
145 gdk_color_parse("grey", &background);
146 gtk_widget_modify_base(win->input_entry, GTK_STATE_NORMAL, &background);
148 g_signal_connect(win->input_entry, "activate", G_CALLBACK(on_input_entry_activate), win);
150 gtk_widget_show(win->input_entry);
151 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(win->widget), win->input_entry, win->input_anchor);
153 g_signal_handler_unblock( G_OBJECT(win->widget), win->keypress_handler );
155 gtk_widget_grab_focus(win->input_entry);
160 /* Internal function: Request either latin-1 or unicode line input, in a text buffer window. */
162 text_buffer_request_line_event_common(winid_t win, glui32 maxlen, gboolean insert, gchar *inserttext)
166 GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) );
168 /* Move the input_position mark to the end of the window_buffer */
169 GtkTextMark *input_position = gtk_text_buffer_get_mark(buffer, "input_position");
170 GtkTextIter end_iter;
171 gtk_text_buffer_get_end_iter(buffer, &end_iter);
172 gtk_text_buffer_move_mark(buffer, input_position, &end_iter);
174 /* Set the entire contents of the window_buffer as uneditable
175 * (so input can only be entered at the end) */
176 GtkTextIter start_iter;
177 gtk_text_buffer_get_start_iter(buffer, &start_iter);
178 gtk_text_buffer_remove_tag_by_name(buffer, "uneditable", &start_iter, &end_iter);
179 gtk_text_buffer_apply_tag_by_name(buffer, "uneditable", &start_iter, &end_iter);
181 /* Insert pre-entered text if needed */
183 gtk_text_buffer_insert(buffer, &end_iter, inserttext, -1);
185 /* Scroll to input point */
186 gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(win->widget), input_position);
188 gtk_text_view_set_editable(GTK_TEXT_VIEW(win->widget), TRUE);
189 g_signal_handler_unblock(buffer, win->insert_text_handler);
191 gtk_widget_grab_focus(win->widget);
197 * glk_request_line_event:
198 * @win: A text buffer or text grid window to request line input on.
199 * @buf: A buffer of at least @maxlen bytes.
200 * @maxlen: Length of the buffer.
201 * @initlen: The number of characters in @buf to pre-enter.
203 * Requests input of a line of Latin-1 characters. A window cannot have requests
204 * for both character and line input at the same time. Nor can it have requests
205 * for line input of both types (Latin-1 and Unicode). It is illegal to call
206 * glk_request_line_event() if the window already has a pending request for
207 * either character or line input.
209 * The @buf argument is a pointer to space where the line input will be stored.
210 * (This may not be %NULL.) @maxlen is the length of this space, in bytes; the
211 * library will not accept more characters than this. If @initlen is nonzero,
212 * then the first @initlen bytes of @buf will be entered as pre-existing input
213 * — just as if the player had typed them himself. (The player can continue
214 * composing after this pre-entered input, or delete it or edit as usual.)
216 * The contents of the buffer are undefined until the input is completed (either
217 * by a line input event, or glk_cancel_line_event(). The library may or may not
218 * fill in the buffer as the player composes, while the input is still pending;
219 * it is illegal to change the contents of the buffer yourself.
222 glk_request_line_event(winid_t win, char* buf, glui32 maxlen, glui32 initlen)
224 VALID_WINDOW(win, return);
225 g_return_if_fail(buf);
226 g_return_if_fail(win->input_request_type == INPUT_REQUEST_NONE);
227 g_return_if_fail(win->type != wintype_TextBuffer || win->type != wintype_TextGrid);
228 g_return_if_fail(initlen <= maxlen);
230 /* Register the buffer */
231 ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
232 if(glk_data->register_arr)
233 win->buffer_rock = (*glk_data->register_arr)(buf, maxlen, "&+#!Cn");
235 win->input_request_type = INPUT_REQUEST_LINE;
236 win->line_input_buffer = buf;
237 win->line_input_buffer_max_len = maxlen;
239 gchar *inserttext = (initlen > 0)? g_strndup(buf, initlen) : g_strdup("");
242 case wintype_TextBuffer:
243 text_buffer_request_line_event_common(win, maxlen, (initlen > 0), inserttext);
245 case wintype_TextGrid:
246 text_grid_request_line_event_common(win, maxlen, (initlen > 0), inserttext);
253 * glk_request_line_event_uni:
254 * @win: A text buffer or text grid window to request line input on.
255 * @buf: A buffer of at least @maxlen characters.
256 * @maxlen: Length of the buffer.
257 * @initlen: The number of characters in @buf to pre-enter.
259 * Request input of a line of Unicode characters. This works the same as
260 * glk_request_line_event(), except the result is stored in an array of
261 * <type>glui32</type> values instead of an array of characters, and the values
262 * may be any valid Unicode code points.
264 * The result will be in Unicode Normalization Form C. This basically means that
265 * composite characters will be single characters where possible, instead of
266 * sequences of base and combining marks. See
267 * <ulink url="http://www.unicode.org/reports/tr15/">Unicode Standard Annex #15
268 * </ulink> for the details.
271 glk_request_line_event_uni(winid_t win, glui32 *buf, glui32 maxlen, glui32 initlen)
273 VALID_WINDOW(win, return);
274 g_return_if_fail(buf);
275 g_return_if_fail(win->input_request_type == INPUT_REQUEST_NONE);
276 g_return_if_fail(win->type != wintype_TextBuffer || win->type != wintype_TextGrid);
277 g_return_if_fail(initlen <= maxlen);
279 /* Register the buffer */
280 ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
281 if(glk_data->register_arr)
282 win->buffer_rock = (*glk_data->register_arr)(buf, maxlen, "&+#!Iu");
284 win->input_request_type = INPUT_REQUEST_LINE_UNICODE;
285 win->line_input_buffer_unicode = buf;
286 win->line_input_buffer_max_len = maxlen;
290 utf8 = convert_ucs4_to_utf8(buf, initlen);
299 case wintype_TextBuffer:
300 text_buffer_request_line_event_common(win, maxlen, (initlen > 0), utf8);
302 case wintype_TextGrid:
303 text_grid_request_line_event_common(win, maxlen, (initlen > 0), utf8);
310 * glk_cancel_line_event:
311 * @win: A text buffer or text grid window to cancel line input on.
312 * @event: Will be filled in if the user had already input something.
314 * This cancels a pending request for line input. (Either Latin-1 or Unicode.)
316 * The event pointed to by the event argument will be filled in as if the
317 * player had hit <keycap>enter</keycap>, and the input composed so far will be stored in the
318 * buffer; see below. If you do not care about this information, pass %NULL as
319 * the @event argument. (The buffer will still be filled.)
321 * For convenience, it is legal to call glk_cancel_line_event() even if there
322 * is no line input request on that window. The event type will be set to
323 * %evtype_None in this case.
326 glk_cancel_line_event(winid_t win, event_t *event)
328 VALID_WINDOW(win, return);
329 g_return_if_fail(win->type != wintype_TextBuffer || win->type != wintype_TextGrid);
332 event->type = evtype_None;
338 if(win->input_request_type != INPUT_REQUEST_LINE && win->input_request_type != INPUT_REQUEST_LINE_UNICODE)
341 g_signal_handler_block( G_OBJECT(win->widget), win->keypress_handler );
343 int chars_written = 0;
345 if(win->type == wintype_TextGrid) {
346 g_signal_handler_block( G_OBJECT(win->widget), win->keypress_handler );
347 chars_written = flush_text_grid(win);
348 } else if(win->type == wintype_TextBuffer) {
349 GtkTextBuffer *window_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) );
350 g_signal_handler_block(window_buffer, win->insert_text_handler);
351 chars_written = flush_text_buffer(win);
354 ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
355 if(glk_data->unregister_arr)
357 if(win->input_request_type == INPUT_REQUEST_LINE_UNICODE)
358 (*glk_data->unregister_arr)(win->line_input_buffer_unicode, win->line_input_buffer_max_len, "&+#!Iu", win->buffer_rock);
360 (*glk_data->unregister_arr)(win->line_input_buffer, win->line_input_buffer_max_len, "&+#!Cn", win->buffer_rock);
363 if(event != NULL && chars_written > 0) {
364 event->type = evtype_LineInput;
365 event->val1 = chars_written;
369 /* Internal function: General callback for signal key-press-event on a text buffer or text grid window. Used in character input on both text buffers and grids, and also in line input on grids, to redirect keystrokes to the line input field. Blocked when not in use. */
371 on_window_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win)
373 /* If this is a text grid window, and line input is active, then redirect the key press to the line input GtkEntry */
374 if( win->type == wintype_TextGrid && (win->input_request_type == INPUT_REQUEST_LINE || win->input_request_type == INPUT_REQUEST_LINE_UNICODE) )
376 if(event->keyval == GDK_Up || event->keyval == GDK_KP_Up
377 || event->keyval == GDK_Down || event->keyval == GDK_KP_Down
378 || event->keyval == GDK_Left || event->keyval == GDK_KP_Left
379 || event->keyval == GDK_Right || event->keyval == GDK_KP_Right
380 || event->keyval == GDK_Tab || event->keyval == GDK_KP_Tab
381 || event->keyval == GDK_Page_Up || event->keyval == GDK_KP_Page_Up
382 || event->keyval == GDK_Page_Down || event->keyval == GDK_KP_Page_Down
383 || event->keyval == GDK_Home || event->keyval == GDK_KP_Home
384 || event->keyval == GDK_End || event->keyval == GDK_KP_End)
385 return FALSE; /* Don't redirect these keys */
386 gtk_widget_grab_focus(win->input_entry);
387 gtk_editable_set_position(GTK_EDITABLE(win->input_entry), -1);
388 gboolean retval = TRUE;
389 g_signal_emit_by_name(win->input_entry, "key-press-event", event, &retval);
390 return retval; /* Block this key event if the entry handled it */
392 if(win->input_request_type != INPUT_REQUEST_CHARACTER &&
393 win->input_request_type != INPUT_REQUEST_CHARACTER_UNICODE)
398 switch(event->keyval) {
400 case GDK_KP_Up: keycode = keycode_Up; break;
402 case GDK_KP_Down: keycode = keycode_Down; break;
404 case GDK_KP_Left: keycode = keycode_Left; break;
406 case GDK_KP_Right: keycode = keycode_Right; break;
409 case GDK_KP_Enter: keycode = keycode_Return; break;
412 case GDK_KP_Delete: keycode = keycode_Delete; break;
413 case GDK_Escape: keycode = keycode_Escape; break;
415 case GDK_KP_Tab: keycode = keycode_Tab; break;
417 case GDK_KP_Page_Up: keycode = keycode_PageUp; break;
419 case GDK_KP_Page_Down: keycode = keycode_PageDown; break;
421 case GDK_KP_Home: keycode = keycode_Home; break;
423 case GDK_KP_End: keycode = keycode_End; break;
425 case GDK_KP_F1: keycode = keycode_Func1; break;
427 case GDK_KP_F2: keycode = keycode_Func2; break;
429 case GDK_KP_F3: keycode = keycode_Func3; break;
431 case GDK_KP_F4: keycode = keycode_Func4; break;
432 case GDK_F5: keycode = keycode_Func5; break;
433 case GDK_F6: keycode = keycode_Func6; break;
434 case GDK_F7: keycode = keycode_Func7; break;
435 case GDK_F8: keycode = keycode_Func8; break;
436 case GDK_F9: keycode = keycode_Func9; break;
437 case GDK_F10: keycode = keycode_Func10; break;
438 case GDK_F11: keycode = keycode_Func11; break;
439 case GDK_F12: keycode = keycode_Func12; break;
441 keycode = gdk_keyval_to_unicode(event->keyval);
442 /* If keycode is 0, then keyval was not recognized; also return
443 unknown if Latin-1 input was requested and the character is not in
445 if(keycode == 0 || (win->input_request_type == INPUT_REQUEST_CHARACTER && keycode > 255))
446 keycode = keycode_Unknown;
449 event_throw(CHIMARA_GLK(gtk_widget_get_ancestor(widget, CHIMARA_TYPE_GLK)), evtype_CharInput, win, keycode, 0);
451 /* Only one keypress will be handled */
452 win->input_request_type = INPUT_REQUEST_NONE;
453 g_signal_handler_block( G_OBJECT(win->widget), win->keypress_handler );
458 /* Internal function: finish handling a line input request, for both text grid and text buffer windows. */
460 write_to_window_buffer(winid_t win, const gchar *inserted_text)
464 /* Convert the string from UTF-8 to Latin-1 or Unicode */
465 if(win->input_request_type == INPUT_REQUEST_LINE)
468 gchar *latin1 = convert_utf8_to_latin1(inserted_text, &bytes_written);
473 /* Place input in the echo stream */
474 if(win->echo_stream != NULL)
475 glk_put_string_stream(win->echo_stream, latin1);
477 /* Copy the string (bytes_written does not include the NULL at the end) */
478 copycount = MIN(win->line_input_buffer_max_len, bytes_written);
479 memcpy(win->line_input_buffer, latin1, copycount);
482 else if(win->input_request_type == INPUT_REQUEST_LINE_UNICODE)
485 gunichar *unicode = convert_utf8_to_ucs4(inserted_text, &items_written);
490 /* Place input in the echo stream */
491 if(win->echo_stream != NULL)
492 glk_put_string_stream_uni(win->echo_stream, unicode);
494 /* Copy the string (but not the NULL at the end) */
495 copycount = MIN(win->line_input_buffer_max_len, items_written);
496 memcpy(win->line_input_buffer_unicode, unicode, copycount * sizeof(gunichar));
500 WARNING("Wrong input request type");
502 win->input_request_type = INPUT_REQUEST_NONE;
506 /* Internal function: Retrieves the input of a TextBuffer window and stores it in the window buffer.
507 * Returns the number of characters written, suitable for inclusion in a line input event. */
509 flush_text_buffer(winid_t win)
511 VALID_WINDOW(win, return 0);
512 g_return_val_if_fail(win->type == wintype_TextBuffer, 0);
514 GtkTextIter start_iter, end_iter, last_character;
516 GtkTextBuffer *window_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) );
517 GtkTextMark *input_position = gtk_text_buffer_get_mark(window_buffer, "input_position");
518 gtk_text_buffer_get_iter_at_mark(window_buffer, &start_iter, input_position);
519 gtk_text_buffer_get_end_iter(window_buffer, &end_iter);
520 gtk_text_buffer_get_end_iter(window_buffer, &last_character);
521 gtk_text_iter_backward_cursor_position(&last_character);
523 gchar* last_char = gtk_text_buffer_get_text(window_buffer, &last_character, &end_iter, FALSE);
525 if( strchr(last_char, '\n') != NULL )
526 gtk_text_iter_backward_cursor_position(&end_iter);
528 gchar* inserted_text = gtk_text_buffer_get_text(window_buffer, &start_iter, &end_iter, FALSE);
530 int chars_written = write_to_window_buffer(win, inserted_text);
531 g_free(inserted_text);
533 return chars_written;
536 /* Internal function: Retrieves the input of a TextGrid window and stores it in the window buffer.
537 * Returns the number of characters written, suitable for inclusion in a line input event. */
539 flush_text_grid(winid_t win)
541 VALID_WINDOW(win, return 0);
542 g_return_val_if_fail(win->type == wintype_TextGrid, 0);
544 GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) );
546 gchar *text = g_strdup( gtk_entry_get_text(GTK_ENTRY(win->input_entry)) );
547 /* Move the focus back into the text view */
548 gtk_widget_grab_focus(win->widget);
549 /* Remove entry widget from text view */
550 /* Should be ok even though this is the widget's own signal handler */
551 gtk_container_remove( GTK_CONTAINER(win->widget), GTK_WIDGET(win->input_entry) );
552 win->input_entry = NULL;
553 /* Delete the child anchor */
554 GtkTextIter start, end;
555 gtk_text_buffer_get_iter_at_child_anchor(buffer, &start, win->input_anchor);
557 gtk_text_iter_forward_char(&end); /* Point after the child anchor */
558 gtk_text_buffer_delete(buffer, &start, &end);
559 win->input_anchor = NULL;
561 gchar *spaces = g_strnfill(win->input_length - g_utf8_strlen(text, -1), ' ');
562 gchar *text_to_insert = g_strconcat(text, spaces, NULL);
564 gtk_text_buffer_insert(buffer, &start, text_to_insert, -1);
565 g_free(text_to_insert);
567 int chars_written = write_to_window_buffer(win, text);
570 return chars_written;
573 /* Internal function: Callback for signal insert-text on a text buffer window.
574 Runs after the default handler has already inserted the text.
575 FIXME: This function assumes that newline was the last character typed into the
576 window. That assumption is wrong if, for example, text containing a newline was
577 pasted into the window. */
579 after_window_insert_text(GtkTextBuffer *textbuffer, GtkTextIter *location, gchar *text, gint len, winid_t win)
581 if( strchr(text, '\n') != NULL )
583 /* Remove signal handlers */
584 GtkTextBuffer *window_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) );
585 g_signal_handler_block(window_buffer, win->insert_text_handler);
587 /* Make the window uneditable again and retrieve the text that was input */
588 gtk_text_view_set_editable(GTK_TEXT_VIEW(win->widget), FALSE);
590 int chars_written = flush_text_buffer(win);
591 event_throw(CHIMARA_GLK(gtk_widget_get_ancestor(win->widget, CHIMARA_TYPE_GLK)), evtype_LineInput, win, chars_written, 0);
593 ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
594 if(glk_data->unregister_arr)
596 if(win->input_request_type == INPUT_REQUEST_LINE_UNICODE)
597 (*glk_data->unregister_arr)(win->line_input_buffer_unicode, win->line_input_buffer_max_len, "&+#!Iu", win->buffer_rock);
599 (*glk_data->unregister_arr)(win->line_input_buffer, win->line_input_buffer_max_len, "&+#!Cn", win->buffer_rock);
604 /* Internal function: Callback for signal activate on the line input GtkEntry
605 in a text grid window. */
607 on_input_entry_activate(GtkEntry *input_entry, winid_t win)
609 g_signal_handler_block( G_OBJECT(win->widget), win->keypress_handler );
611 int chars_written = flush_text_grid(win);
612 event_throw(CHIMARA_GLK(gtk_widget_get_ancestor(win->widget, CHIMARA_TYPE_GLK)), evtype_LineInput, win, chars_written, 0);
613 ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
614 if(glk_data->unregister_arr)
616 if(win->input_request_type == INPUT_REQUEST_LINE_UNICODE)
617 (*glk_data->unregister_arr)(win->line_input_buffer_unicode, win->line_input_buffer_max_len, "&+#!Iu", win->buffer_rock);
619 (*glk_data->unregister_arr)(win->line_input_buffer, win->line_input_buffer_max_len, "&+#!Cn", win->buffer_rock);