+
+ /* Move more if we're on the edge of a group */
+ int extra = 0;
+ if (move < 0 && first) extra = -2;
+ if (move > 0 && last) extra = 2;
+
+ /* Scroll window when we move off screen */
+ int next = line + srow + move + extra;
+ int ymax = getmaxy(win)-1;
+ while (next-line < 0) line--;
+ while (next-line > ymax) line++;
+
+ /* Update line and cursor positions */
+ line = CLAMP(line+scroll, 0, rows-1);
+ cursor = CLAMP(cursor+move, 0, items-1);
+
+ /* Repaint */