diff options
author | Max Kellermann <max@duempel.org> | 2008-09-17 12:18:00 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-17 12:18:00 +0200 |
commit | ca2b9d1390a56b89336b963113b5763edd70238e (patch) | |
tree | fb21cce04bc44a9bcb4a8e06fadd1b02776defc9 /src/list_window.c | |
parent | 104b126c69b89cc4b7caf301fbdbd0b1c9a21bda (diff) | |
download | mpd-ca2b9d1390a56b89336b963113b5763edd70238e.tar.gz mpd-ca2b9d1390a56b89336b963113b5763edd70238e.tar.xz mpd-ca2b9d1390a56b89336b963113b5763edd70238e.zip |
list_window: added list_window_scroll_cmd()
It is similar to list_window_cmd(), but it scrolls the window instead
of moving the selection. It is used by the "lyrics" and the "help"
screen.
Diffstat (limited to '')
-rw-r--r-- | src/list_window.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/list_window.c b/src/list_window.c index 88f0a690c..f26088da4 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -296,6 +296,56 @@ list_window_cmd(struct list_window *lw, unsigned rows, command_t cmd) return 1; } +int +list_window_scroll_cmd(struct list_window *lw, unsigned rows, command_t cmd) +{ + switch (cmd) { + case CMD_LIST_PREVIOUS: + if (lw->start > 0) + lw->start--; + break; + + case CMD_LIST_NEXT: + if (lw->start + lw->rows < rows) + lw->start++; + break; + + case CMD_LIST_FIRST: + lw->start = 0; + break; + + case CMD_LIST_LAST: + if (rows > lw->rows) + lw->start = rows - lw->rows; + else + lw->start = 0; + break; + + case CMD_LIST_NEXT_PAGE: + lw->start += lw->rows - 1; + if (lw->start + lw->rows > rows) { + if (rows > lw->rows) + lw->start = rows - lw->rows; + else + lw->start = 0; + } + break; + + case CMD_LIST_PREVIOUS_PAGE: + if (lw->start > lw->rows) + lw->start -= lw->rows; + else + lw->start = 0; + break; + + default: + return 0; + } + + lw->repaint = lw->clear = 1; + return 1; +} + list_window_state_t * list_window_init_state(void) { |