Code

list_window: Extended scrolling commands to text screens
authorJeffrey Middleton <jefromi@gmail.com>
Thu, 5 Mar 2009 22:50:41 +0000 (16:50 -0600)
committerJeffrey Middleton <jefromi@gmail.com>
Thu, 5 Mar 2009 19:16:57 +0000 (13:16 -0600)
Added scroll up/down one-line/half-screen to list_window_scroll_cmd,
which is used in text screens.

src/list_window.c

index 347cfb2d3fdba6b70cb24123e07900541e24648e..8abad27381316f185b535164824c82455fc0607d 100644 (file)
@@ -507,11 +507,13 @@ bool
 list_window_scroll_cmd(struct list_window *lw, unsigned rows, command_t cmd)
 {
        switch (cmd) {
+       case CMD_LIST_SCROLL_UP_LINE:
        case CMD_LIST_PREVIOUS:
                if (lw->start > 0)
                        lw->start--;
                break;
 
+       case CMD_LIST_SCROLL_DOWN_LINE:
        case CMD_LIST_NEXT:
                if (lw->start + lw->rows < rows)
                        lw->start++;
@@ -545,6 +547,23 @@ list_window_scroll_cmd(struct list_window *lw, unsigned rows, command_t cmd)
                        lw->start = 0;
                break;
 
+       case CMD_LIST_SCROLL_UP_HALF:
+               if (lw->start > (lw->rows - 1) / 2)
+                       lw->start -= (lw->rows - 1) / 2;
+               else
+                       lw->start = 0;
+               break;
+
+       case CMD_LIST_SCROLL_DOWN_HALF:
+               lw->start += (lw->rows - 1) / 2;
+               if (lw->start + lw->rows > rows) {
+                       if (rows > lw->rows)
+                               lw->start = rows - lw->rows;
+                       else
+                               lw->start = 0;
+               }
+               break;
+
        default:
                return false;
        }