summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2011-03-25 18:00:37 +0100
committerLars-Dominik Braun <lars@6xq.net>2011-03-26 21:45:45 +0100
commitc5be1dd321ec7668177a535c5d83622b8a8dfacf (patch)
treee4f1e921984eeb0d6a1e863402f5122fa340ba2d /src
parent755015ded8d03174d81b0ab0eb47f0a698eddf34 (diff)
downloadpianobar-windows-c5be1dd321ec7668177a535c5d83622b8a8dfacf.tar.gz
pianobar-windows-c5be1dd321ec7668177a535c5d83622b8a8dfacf.tar.bz2
pianobar-windows-c5be1dd321ec7668177a535c5d83622b8a8dfacf.zip
Filter-/searchable artist list
Diffstat (limited to 'src')
-rw-r--r--src/ui.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/src/ui.c b/src/ui.c
index 031d5bb..7372384 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -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;
}