From: Jeffrey Middleton Date: Thu, 5 Mar 2009 22:50:41 +0000 (-0600) Subject: list_window: Extended scrolling commands to text screens X-Git-Tag: release-0.14~78 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=607bf2d55826f861d12b774884cb201bc683051c;p=ncmpc.git list_window: Extended scrolling commands to text screens Added scroll up/down one-line/half-screen to list_window_scroll_cmd, which is used in text screens. --- diff --git a/src/list_window.c b/src/list_window.c index 347cfb2..8abad27 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -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; }