diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2011-03-25 18:00:37 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2011-03-26 21:45:45 +0100 |
commit | c5be1dd321ec7668177a535c5d83622b8a8dfacf (patch) | |
tree | e4f1e921984eeb0d6a1e863402f5122fa340ba2d | |
parent | 755015ded8d03174d81b0ab0eb47f0a698eddf34 (diff) | |
download | pianobar-c5be1dd321ec7668177a535c5d83622b8a8dfacf.tar.gz pianobar-c5be1dd321ec7668177a535c5d83622b8a8dfacf.tar.bz2 pianobar-c5be1dd321ec7668177a535c5d83622b8a8dfacf.zip |
Filter-/searchable artist list
-rw-r--r-- | src/ui.c | 48 |
1 files changed, 31 insertions, 17 deletions
@@ -433,24 +433,38 @@ PianoSong_t *BarUiSelectSong (const BarSettings_t *settings, PianoArtist_t *BarUiSelectArtist (PianoArtist_t *startArtist, BarReadlineFds_t *input) { PianoArtist_t *tmpArtist = NULL; - int i = 0; + char buf[100]; + unsigned long i; + + memset (buf, 0, sizeof (buf)); + + do { + /* print all artists */ + i = 0; + tmpArtist = startArtist; + while (tmpArtist != NULL) { + if (strcasestr (tmpArtist->name, buf) != NULL) { + BarUiMsg (MSG_LIST, "%2u) %s\n", i, tmpArtist->name); + } + i++; + tmpArtist = tmpArtist->next; + } + + BarUiMsg (MSG_QUESTION, "Select artist: "); + if (BarReadlineStr (buf, sizeof (buf), input, BAR_RL_DEFAULT) == 0) { + return NULL; + } + + if (isnumeric (buf)) { + i = strtoul (buf, NULL, 0); + tmpArtist = startArtist; + while (tmpArtist != NULL && i > 0) { + tmpArtist = tmpArtist->next; + i--; + } + } + } while (tmpArtist == NULL); - /* print all artists */ - tmpArtist = startArtist; - while (tmpArtist != NULL) { - BarUiMsg (MSG_LIST, "%2u) %s\n", i, tmpArtist->name); - i++; - tmpArtist = tmpArtist->next; - } - BarUiMsg (MSG_QUESTION, "Select artist: "); - if (BarReadlineInt (&i, input) == 0) { - return NULL; - } - tmpArtist = startArtist; - while (tmpArtist != NULL && i > 0) { - tmpArtist = tmpArtist->next; - i--; - } return tmpArtist; } |