X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Finput.c;h=8b6d4c27662d5296e4b7df1a0ec0caedf40c6b7e;hb=37e3cee8525bb02d3c12d75a55dd6f9c0f576861;hp=96b6353f96f4b4fb9de6eff5dcb762020d4b64c7;hpb=bdb0212e5a713122e189704fdcfa46cc1e1be2e1;p=rodin%2Fchimara.git diff --git a/libchimara/input.c b/libchimara/input.c index 96b6353..8b6d4c2 100644 --- a/libchimara/input.c +++ b/libchimara/input.c @@ -27,20 +27,6 @@ request_char_event_common(winid_t win, gboolean unicode) g_signal_handler_unblock( win->widget, win->char_input_keypress_handler ); gdk_threads_enter(); - - /* If the request is in a text buffer window, scroll to the end of the - text buffer. TODO: This may scroll text off the top of the window that the - user hasn't read yet. We need to implement a paging mechanism. */ - if(win->type == wintype_TextBuffer) - { - GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(win->widget) ); - GtkTextIter iter; - gtk_text_buffer_get_end_iter(buffer, &iter); - gtk_text_buffer_place_cursor(buffer, &iter); - gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(win->widget), gtk_text_buffer_get_insert(buffer)); - /* Why doesn't this always work?? */ - } - gtk_widget_grab_focus( GTK_WIDGET(win->widget) ); gdk_threads_leave(); @@ -141,7 +127,11 @@ text_grid_request_line_event_common(winid_t win, glui32 maxlen, gboolean insert, /* Make the entry as small as possible to fit with the text */ gtk_entry_set_has_frame(GTK_ENTRY(win->input_entry), FALSE); GtkBorder border = { 0, 0, 0, 0 }; + + /* COMPAT: */ +#if GTK_CHECK_VERSION(2,10,0) gtk_entry_set_inner_border(GTK_ENTRY(win->input_entry), &border); +#endif gtk_entry_set_max_length(GTK_ENTRY(win->input_entry), win->input_length); gtk_entry_set_width_chars(GTK_ENTRY(win->input_entry), win->input_length); @@ -195,9 +185,6 @@ text_buffer_request_line_event_common(winid_t win, glui32 maxlen, gboolean inser gtk_text_buffer_get_end_iter(buffer, &end_iter); /* update after text insertion */ } - /* Scroll to input point */ - gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(win->widget), input_position); - /* Apply the correct style to the input prompt */ GtkTextIter input_iter; gtk_text_buffer_get_iter_at_mark(buffer, &input_iter, input_position); @@ -456,6 +443,8 @@ on_line_input_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win || event->keyval == GDK_Down || event->keyval == GDK_KP_Down) { /* Prevent falling off the end of the history list */ + if(win->history == NULL) + return TRUE; if( (event->keyval == GDK_Up || event->keyval == GDK_KP_Up) && win->history_pos && win->history_pos->next == NULL) return TRUE; @@ -514,6 +503,15 @@ on_line_input_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win return TRUE; } + /* Handle the enter key, which could occur in the middle of the sentence. */ + else if(event->keyval == GDK_Return || event->keyval == GDK_KP_Enter) { + GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(win->widget)); + GtkTextIter end_iter; + gtk_text_buffer_get_end_iter(buffer, &end_iter); + gtk_text_buffer_place_cursor(buffer, &end_iter); + return FALSE; + } + return FALSE; /* If this is a text grid window, then redirect the key press to the line input GtkEntry */