X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Finput.c;h=c740809a0f36c69a0b61e18f97bc5334ac8697de;hb=b4250eb0611c034d8c8325676e54c8010bbe8749;hp=96b6353f96f4b4fb9de6eff5dcb762020d4b64c7;hpb=d40a686d17387954d8fd502b9e80e3c67d7a7262;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/input.c b/libchimara/input.c index 96b6353..c740809 100644 --- a/libchimara/input.c +++ b/libchimara/input.c @@ -28,9 +28,7 @@ request_char_event_common(winid_t win, gboolean unicode) 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) ); @@ -38,8 +36,8 @@ request_char_event_common(winid_t win, gboolean unicode) 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?? */ - } + // Why doesn't this always work?? + } */ gtk_widget_grab_focus( GTK_WIDGET(win->widget) ); gdk_threads_leave(); @@ -456,6 +454,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 +514,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 */