From: rodin Date: Sun, 14 Feb 2010 12:48:07 +0000 (+0000) Subject: Handle Home/End keys properly X-Git-Tag: v0.9~238 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=d40a686d17387954d8fd502b9e80e3c67d7a7262;p=projects%2Fchimara%2Fchimara.git Handle Home/End keys properly --- diff --git a/libchimara/input.c b/libchimara/input.c index 0285971..96b6353 100644 --- a/libchimara/input.c +++ b/libchimara/input.c @@ -450,6 +450,8 @@ on_line_input_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win switch(win->type) { case wintype_TextBuffer: + + /* History up/down */ if(event->keyval == GDK_Up || event->keyval == GDK_KP_Up || event->keyval == GDK_Down || event->keyval == GDK_KP_Down) { @@ -494,6 +496,24 @@ on_line_input_key_press_event(GtkWidget *widget, GdkEventKey *event, winid_t win g_signal_handler_unblock(buffer, win->insert_text_handler); return TRUE; } + + /* Move to beginning/end of input field */ + else if(event->keyval == GDK_Home) { + GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(win->widget)); + GtkTextIter input_iter; + GtkTextMark *input_position = gtk_text_buffer_get_mark(buffer, "input_position"); + gtk_text_buffer_get_iter_at_mark(buffer, &input_iter, input_position); + gtk_text_buffer_place_cursor(buffer, &input_iter); + return TRUE; + } + else if(event->keyval == GDK_End) { + 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 TRUE; + } + return FALSE; /* If this is a text grid window, then redirect the key press to the line input GtkEntry */