From: P. F. Chimento Date: Sat, 29 Jan 2011 21:59:47 +0000 (+0100) Subject: Change less-like behavior of pager X-Git-Tag: v0.9~154 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=edf59e1a751771655752b61e211053e08a8cbe3a;p=projects%2Fchimara%2Fchimara.git Change less-like behavior of pager The behavior of the pager was based on the paging program 'less': the enter key scrolls down one line (in GTK terms a 'step increment') and the space bar scrolls down one page. People probably don't want to page through interactive fiction one line at a time, and so expect the enter key to scroll down a page. The enter key now does the same as a space bar. To scroll line by line, use the mouse wheel or the scroll bar arrows. --- diff --git a/libchimara/pager.c b/libchimara/pager.c index 05cf4bf..194a21d 100644 --- a/libchimara/pager.c +++ b/libchimara/pager.c @@ -34,7 +34,7 @@ move_pager_and_get_scroll_distance(GtkTextView *textview, gint *view_height, gin /* g_printerr("View height = %d\n", visiblerect.height); - g_printerr("End - Pager = %d\n", endpos.y - pagerpos.y); + g_printerr("End - Pager = %d - %d = %d\n", endpos.y, pagerpos.y, endpos.y - pagerpos.y); */ *view_height = visiblerect.height; @@ -81,25 +81,23 @@ gboolean pager_on_key_press_event(GtkTextView *textview, GdkEventKey *event, winid_t win) { GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(win->frame) ); - gdouble step_increment, page_size, upper, lower, value; + gdouble page_size, upper, lower, value; g_object_get(adj, "page-size", &page_size, - "step-increment", &step_increment, "upper", &upper, "lower", &lower, "value", &value, NULL); switch (event->keyval) { - case GDK_space: case GDK_KP_Space: case GDK_Page_Down: case GDK_KP_Page_Down: + case GDK_space: case GDK_KP_Space: + case GDK_Page_Down: case GDK_KP_Page_Down: + case GDK_Return: case GDK_KP_Enter: gtk_adjustment_set_value(adj, CLAMP(value + page_size, lower, upper - page_size)); return TRUE; case GDK_Page_Up: case GDK_KP_Page_Up: gtk_adjustment_set_value(adj, CLAMP(value - page_size, lower, upper - page_size)); return TRUE; - case GDK_Return: case GDK_KP_Enter: - gtk_adjustment_set_value(adj, CLAMP(value + step_increment, lower, upper - page_size)); - return TRUE; /* don't handle "up" and "down", they're used for input history */ }