Change less-like behavior of pager
authorP. F. Chimento <philip.chimento@gmail.com>
Sat, 29 Jan 2011 21:59:47 +0000 (22:59 +0100)
committerP. F. Chimento <philip.chimento@gmail.com>
Sat, 29 Jan 2011 21:59:47 +0000 (22:59 +0100)
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.

libchimara/pager.c

index 05cf4bf7ddc013af8b0c09d251f37169c381da76..194a21dc64edb9e46cccba7cd3e9b3ea4237cccd 100644 (file)
@@ -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 */
        }