/* 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. */
gboolean
-on_window_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win)
+on_char_input_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win)
{
- /* If this is a text grid window, and line input is active, then redirect the key press to the line input GtkEntry */
- if( win->type == wintype_TextGrid && (win->input_request_type == INPUT_REQUEST_LINE || win->input_request_type == INPUT_REQUEST_LINE_UNICODE) )
- {
- if(event->keyval == GDK_Up || event->keyval == GDK_KP_Up
- || event->keyval == GDK_Down || event->keyval == GDK_KP_Down
- || event->keyval == GDK_Left || event->keyval == GDK_KP_Left
- || event->keyval == GDK_Right || event->keyval == GDK_KP_Right
- || event->keyval == GDK_Tab || event->keyval == GDK_KP_Tab
- || event->keyval == GDK_Page_Up || event->keyval == GDK_KP_Page_Up
- || event->keyval == GDK_Page_Down || event->keyval == GDK_KP_Page_Down
- || event->keyval == GDK_Home || event->keyval == GDK_KP_Home
- || event->keyval == GDK_End || event->keyval == GDK_KP_End)
- return FALSE; /* Don't redirect these keys */
- gtk_widget_grab_focus(win->input_entry);
- gtk_editable_set_position(GTK_EDITABLE(win->input_entry), -1);
- gboolean retval = TRUE;
- g_signal_emit_by_name(win->input_entry, "key-press-event", event, &retval);
- return retval; /* Block this key event if the entry handled it */
- }
- if(win->input_request_type != INPUT_REQUEST_CHARACTER &&
- win->input_request_type != INPUT_REQUEST_CHARACTER_UNICODE)
- return FALSE;
-
glui32 keycode = keyval_to_glk_keycode(event->keyval, win->input_request_type == INPUT_REQUEST_CHARACTER_UNICODE);
ChimaraGlk *glk = CHIMARA_GLK(gtk_widget_get_ancestor(widget, CHIMARA_TYPE_GLK));
return TRUE;
}
+gboolean
+on_line_input_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win)
+{
+ switch(win->type)
+ {
+ case wintype_TextBuffer:
+ if(event->keyval == GDK_Up || event->keyval == GDK_KP_Up)
+ {
+
+ }
+ else if(event->keyval == GDK_Down || event->keyval == GDK_KP_Down)
+ {
+
+ }
+ break;
+
+ /* If this is a text grid window, then redirect the key press to the line input GtkEntry */
+ case wintype_TextGrid:
+ {
+ if(event->keyval == GDK_Up || event->keyval == GDK_KP_Up
+ || event->keyval == GDK_Down || event->keyval == GDK_KP_Down
+ || event->keyval == GDK_Left || event->keyval == GDK_KP_Left
+ || event->keyval == GDK_Right || event->keyval == GDK_KP_Right
+ || event->keyval == GDK_Tab || event->keyval == GDK_KP_Tab
+ || event->keyval == GDK_Page_Up || event->keyval == GDK_KP_Page_Up
+ || event->keyval == GDK_Page_Down || event->keyval == GDK_KP_Page_Down
+ || event->keyval == GDK_Home || event->keyval == GDK_KP_Home
+ || event->keyval == GDK_End || event->keyval == GDK_KP_End)
+ return FALSE; /* Don't redirect these keys */
+ gtk_widget_grab_focus(win->input_entry);
+ gtk_editable_set_position(GTK_EDITABLE(win->input_entry), -1);
+ gboolean retval = TRUE;
+ g_signal_emit_by_name(win->input_entry, "key-press-event", event, &retval);
+ return retval; /* Block this key event if the entry handled it */
+ }
+ }
+}
+
/* Internal function: finish handling a line input request, for both text grid and text buffer windows. */
static int
write_to_window_buffer(winid_t win, const gchar *inserted_text)
g_assert(glk);
g_signal_emit_by_name(glk, "line-input", win->rock, inserted_text);
}
+
+ /* Add the text to the window input history */
+ win->history = g_list_prepend(win->history, g_strdup(inserted_text));
+ win->history_pos = win->history;
+
g_free(inserted_text);
return chars_written;