diff options
author | Max Kellermann <max@duempel.org> | 2008-09-17 12:20:42 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-17 12:20:42 +0200 |
commit | fd7abf4f81a69014b0e1e967c7965996a11295b0 (patch) | |
tree | 539a4a746587dd3090642657c9304492a0f6017f /src/list_window.c | |
parent | ca2b9d1390a56b89336b963113b5763edd70238e (diff) | |
download | mpd-fd7abf4f81a69014b0e1e967c7965996a11295b0.tar.gz mpd-fd7abf4f81a69014b0e1e967c7965996a11295b0.tar.xz mpd-fd7abf4f81a69014b0e1e967c7965996a11295b0.zip |
list_window: added list_window_center()
Merge code which used to be duplicated in the screens "play", "help",
"lyrics".
Diffstat (limited to '')
-rw-r--r-- | src/list_window.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/list_window.c b/src/list_window.c index f26088da4..ad671f0cf 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -82,6 +82,24 @@ list_window_check_selected(struct list_window *lw, unsigned length) } void +list_window_center(struct list_window *lw, unsigned rows, unsigned n) +{ + if (n > lw->rows / 2) + lw->start = n - lw->rows / 2; + else + lw->start = 0; + + if (lw->start + lw->rows > rows) { + if (lw->rows < rows) + lw->start = rows - lw->rows; + else + lw->start = 0; + } + + lw->repaint = lw->clear = 1; +} + +void list_window_set_selected(struct list_window *lw, unsigned n) { lw->selected = n; |