From: Kalle Wallin Date: Sat, 27 Mar 2004 16:22:04 +0000 (+0000) Subject: Added function list_window_check_selected(). X-Git-Tag: v0.12_alpha1~644 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=31832b2c38d5decb81e7aad84e39dbfe12a9392c;p=ncmpc.git Added function list_window_check_selected(). git-svn-id: https://svn.musicpd.org/ncmpc/trunk@510 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- diff --git a/list_window.c b/list_window.c index ab6c7d4..fa1f949 100644 --- a/list_window.c +++ b/list_window.c @@ -41,6 +41,16 @@ list_window_reset(list_window_t *lw) lw->clear = 1; } +void +list_window_check_selected(list_window_t *lw, int length) +{ + if( lw->selected<0 ) + lw->selected=0; + + while( lw->selected>0 && length>0 && lw->selected>=length ) + lw->selected--; +} + void list_window_set_selected(list_window_t *lw, int n) { diff --git a/list_window.h b/list_window.h index ce799c1..c53f381 100644 --- a/list_window.h +++ b/list_window.h @@ -44,6 +44,7 @@ void list_window_first(list_window_t *lw); void list_window_last(list_window_t *lw, int length); void list_window_previous_page(list_window_t *lw); void list_window_next_page(list_window_t *lw, int length); +void list_window_check_selected(list_window_t *lw, int length); /* find a string in a list window */ int list_window_find(list_window_t *lw,