Code

progress_bar: do first paint manually
[ncmpc.git] / src / screen.c
1 /* ncmpc (Ncurses MPD Client)
2  * (c) 2004-2009 The Music Player Daemon Project
3  * Project homepage: http://musicpd.org
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
20 #include "screen.h"
21 #include "screen_list.h"
22 #include "screen_utils.h"
23 #include "config.h"
24 #include "i18n.h"
25 #include "charset.h"
26 #include "mpdclient.h"
27 #include "utils.h"
28 #include "options.h"
29 #include "colors.h"
30 #include "strfsong.h"
31 #include "player_command.h"
33 #ifndef NCMPC_MINI
34 #include "hscroll.h"
35 #endif
37 #include <mpd/client.h>
39 #include <stdlib.h>
40 #include <unistd.h>
41 #include <stdarg.h>
42 #include <string.h>
43 #include <time.h>
44 #include <locale.h>
46 #ifndef NCMPC_MINI
47 /** welcome message time [s] */
48 static const GTime SCREEN_WELCOME_TIME = 10;
49 #endif
51 /* minimum window size */
52 static const int SCREEN_MIN_COLS = 14;
53 static const int SCREEN_MIN_ROWS = 5;
55 /* screens */
57 #ifndef NCMPC_MINI
58 static gboolean welcome = TRUE;
59 #endif
61 struct screen screen;
62 static const struct screen_functions *mode_fn = &screen_playlist;
63 static const struct screen_functions *mode_fn_prev = &screen_playlist;
65 gboolean
66 screen_is_visible(const struct screen_functions *sf)
67 {
68         return sf == mode_fn;
69 }
71 void
72 screen_switch(const struct screen_functions *sf, struct mpdclient *c)
73 {
74         assert(sf != NULL);
76         if (sf == mode_fn)
77                 return;
79         mode_fn_prev = mode_fn;
81         /* close the old mode */
82         if (mode_fn->close != NULL)
83                 mode_fn->close();
85         /* get functions for the new mode */
86         mode_fn = sf;
88         /* open the new mode */
89         if (mode_fn->open != NULL)
90                 mode_fn->open(c);
92         screen_paint(c);
93 }
95 void
96 screen_swap(struct mpdclient *c, const struct mpd_song *song)
97 {
98         if (song != NULL)
99         {
100                 if (false)
101                         { /* just a hack to make the ifdefs less ugly */ }
102 #ifdef ENABLE_SONG_SCREEN
103                 if (mode_fn_prev == &screen_song)
104                         screen_song_switch(c, song);
105 #endif
106 #ifdef ENABLE_LYRICS_SCREEN
107                 else if (mode_fn_prev == &screen_lyrics)
108                         screen_lyrics_switch(c, song, true);
109 #endif
110                 else
111                         screen_switch(mode_fn_prev, c);
112         }
113         else
114                 screen_switch(mode_fn_prev, c);
117 static int
118 find_configured_screen(const char *name)
120         unsigned i;
122         for (i = 0; options.screen_list[i] != NULL; ++i)
123                 if (strcmp(options.screen_list[i], name) == 0)
124                         return i;
126         return -1;
129 static void
130 screen_next_mode(struct mpdclient *c, int offset)
132         int max = g_strv_length(options.screen_list);
133         int current, next;
134         const struct screen_functions *sf;
136         /* find current screen */
137         current = find_configured_screen(screen_get_name(mode_fn));
138         next = current + offset;
139         if (next<0)
140                 next = max-1;
141         else if (next>=max)
142                 next = 0;
144         sf = screen_lookup_name(options.screen_list[next]);
145         if (sf != NULL)
146                 screen_switch(sf, c);
149 #ifndef NCMPC_MINI
150 static void
151 print_hotkey(WINDOW *w, command_t cmd, const char *label)
153         colors_use(w, COLOR_TITLE_BOLD);
154         waddstr(w, get_key_names(cmd, FALSE));
155         colors_use(w, COLOR_TITLE);
156         waddch(w, ':');
157         waddstr(w, label);
158         waddch(w, ' ');
159         waddch(w, ' ');
161 #endif
163 static inline int
164 get_volume(const struct mpd_status *status)
166         return status != NULL
167                 ? mpd_status_get_volume(status)
168                 : MPD_STATUS_NO_VOLUME;
171 static void
172 paint_top_window2(const char *header, struct mpdclient *c)
174         int volume;
175         char flags[5];
176         WINDOW *w = screen.top_window.w;
177         char buf[32];
179         if (header[0]) {
180                 colors_use(w, COLOR_TITLE_BOLD);
181                 mvwaddstr(w, 0, 0, header);
182 #ifndef NCMPC_MINI
183         } else {
184 #ifdef ENABLE_HELP_SCREEN
185                 print_hotkey(w, CMD_SCREEN_HELP, _("Help"));
186 #endif
187                 print_hotkey(w, CMD_SCREEN_PLAY, _("Playlist"));
188                 print_hotkey(w, CMD_SCREEN_FILE, _("Browse"));
189 #ifdef ENABLE_ARTIST_SCREEN
190                 print_hotkey(w, CMD_SCREEN_ARTIST, _("Artist"));
191 #endif
192 #ifdef ENABLE_SEARCH_SCREEN
193                 print_hotkey(w, CMD_SCREEN_SEARCH, _("Search"));
194 #endif
195 #ifdef ENABLE_LYRICS_SCREEN
196                 print_hotkey(w, CMD_SCREEN_LYRICS, _("Lyrics"));
197 #endif
198 #ifdef ENABLE_OUTPUTS_SCREEN
199                 print_hotkey(w, CMD_SCREEN_OUTPUTS, _("Outputs"));
200 #endif
201 #endif
202         }
204         volume = get_volume(c->status);
205         if (volume == MPD_STATUS_NO_VOLUME)
206                 g_snprintf(buf, 32, _("Volume n/a"));
207         else
208                 g_snprintf(buf, 32, _("Volume %d%%"), volume);
210         colors_use(w, COLOR_TITLE);
211         mvwaddstr(w, 0, screen.top_window.cols - utf8_width(buf), buf);
213         flags[0] = 0;
214         if (c->status != NULL) {
215                 if (mpd_status_get_repeat(c->status))
216                         g_strlcat(flags, "r", sizeof(flags));
217                 if (mpd_status_get_random(c->status))
218                         g_strlcat(flags, "z", sizeof(flags));
219                 if (mpd_status_get_single(c->status))
220                         g_strlcat(flags, "s", sizeof(flags));
221                 if (mpd_status_get_consume(c->status))
222                         g_strlcat(flags, "c", sizeof(flags));
223                 if (mpd_status_get_crossfade(c->status))
224                         g_strlcat(flags, "x", sizeof(flags));
225                 if (mpd_status_get_update_id(c->status) != 0)
226                         g_strlcat(flags, "U", sizeof(flags));
227         }
229         colors_use(w, COLOR_LINE);
230         mvwhline(w, 1, 0, ACS_HLINE, screen.top_window.cols);
231         if (flags[0]) {
232                 wmove(w,1,screen.top_window.cols-strlen(flags)-3);
233                 waddch(w, '[');
234                 colors_use(w, COLOR_LINE_BOLD);
235                 waddstr(w, flags);
236                 colors_use(w, COLOR_LINE);
237                 waddch(w, ']');
238         }
239         wnoutrefresh(w);
242 static inline int
243 volume_length(int volume)
245         if (volume == 100)
246                 return 3;
247         if (volume >= 10 && volume < 100)
248                 return 2;
249         if (volume >= 0 && volume < 10)
250                 return 1;
251         return -1;
254 static void
255 paint_top_window(const char *header, struct mpdclient *c, int full_repaint)
257         static int prev_volume = -1;
258         static unsigned prev_header_len = -1;
259         WINDOW *w = screen.top_window.w;
261         if (prev_header_len != utf8_width(header)) {
262                 prev_header_len = utf8_width(header);
263                 full_repaint = 1;
264         }
266         if (c->status &&
267             volume_length(prev_volume) !=
268             volume_length(mpd_status_get_volume(c->status)))
269                 full_repaint = 1;
271         if (full_repaint) {
272                 wmove(w, 0, 0);
273                 wclrtoeol(w);
274         }
276         if ((c->status != NULL &&
277              prev_volume != mpd_status_get_volume(c->status)) ||
278             full_repaint)
279                 paint_top_window2(header, c);
282 static void
283 paint_progress_window(struct mpdclient *c)
285         unsigned elapsed, duration;
287         if (c->song != NULL && seek_id == (int)mpd_song_get_id(c->song))
288                 elapsed = seek_target_time;
289         else if (c->status != NULL)
290                 elapsed = mpd_status_get_elapsed_time(c->status);
291         else
292                 elapsed = 0;
294         duration = c->status != NULL &&
295                 !IS_STOPPED(mpd_status_get_state(c->status))
296                 ? mpd_status_get_total_time(c->status)
297                 : 0;
299         if (progress_bar_set(&screen.progress_bar, elapsed, duration))
300                 progress_bar_paint(&screen.progress_bar);
303 static void
304 paint_status_window(struct mpdclient *c)
306         WINDOW *w = screen.status_window.w;
307         const struct mpd_status *status = c->status;
308         enum mpd_state state;
309         const struct mpd_song *song = c->song;
310         int elapsedTime = 0;
311 #ifdef NCMPC_MINI
312         static char bitrate[1];
313 #else
314         char bitrate[16];
315 #endif
316         const char *str = NULL;
317         int x = 0;
319         if( time(NULL) - screen.status_timestamp <= options.status_message_time )
320                 return;
322         wmove(w, 0, 0);
323         wclrtoeol(w);
324         colors_use(w, COLOR_STATUS_BOLD);
326         state = status == NULL ? MPD_STATE_UNKNOWN
327                 : mpd_status_get_state(status);
329         switch (state) {
330         case MPD_STATE_PLAY:
331                 str = _("Playing:");
332                 break;
333         case MPD_STATE_PAUSE:
334                 str = _("[Paused]");
335                 break;
336         case MPD_STATE_STOP:
337         default:
338                 break;
339         }
341         if (str) {
342                 waddstr(w, str);
343                 x += utf8_width(str) + 1;
344         }
346         /* create time string */
347         memset(screen.buf, 0, screen.buf_size);
348         if (IS_PLAYING(state) || IS_PAUSED(state)) {
349                 int total_time = mpd_status_get_total_time(status);
350                 if (total_time > 0) {
351                         /*checks the conf to see whether to display elapsed or remaining time */
352                         if(!strcmp(options.timedisplay_type,"elapsed"))
353                                 elapsedTime = mpd_status_get_elapsed_time(c->status);
354                         else if(!strcmp(options.timedisplay_type,"remaining"))
355                                 elapsedTime = total_time -
356                                         mpd_status_get_elapsed_time(c->status);
358                         if (c->song != NULL &&
359                             seek_id == (int)mpd_song_get_id(c->song))
360                                 elapsedTime = seek_target_time;
362                         /* display bitrate if visible-bitrate is true */
363 #ifndef NCMPC_MINI
364                         if (options.visible_bitrate) {
365                                 g_snprintf(bitrate, 16,
366                                            " [%d kbps]",
367                                            mpd_status_get_kbit_rate(status));
368                         } else {
369                                 bitrate[0] = '\0';
370                         }
371 #endif
373                         /*write out the time, using hours if time over 60 minutes*/
374                         if (total_time > 3600) {
375                                 g_snprintf(screen.buf, screen.buf_size,
376                                            "%s [%i:%02i:%02i/%i:%02i:%02i]",
377                                            bitrate, elapsedTime/3600, (elapsedTime%3600)/60, elapsedTime%60,
378                                            total_time / 3600,
379                                            (total_time % 3600)/60,
380                                            total_time % 60);
381                         } else {
382                                 g_snprintf(screen.buf, screen.buf_size,
383                                            "%s [%i:%02i/%i:%02i]",
384                                            bitrate, elapsedTime/60, elapsedTime%60,
385                                            total_time / 60, total_time % 60);
386                         }
387 #ifndef NCMPC_MINI
388                 } else {
389                         g_snprintf(screen.buf, screen.buf_size,
390                                    " [%d kbps]",
391                                    mpd_status_get_kbit_rate(status));
392 #endif
393                 }
394 #ifndef NCMPC_MINI
395         } else {
396                 if (options.display_time) {
397                         time_t timep;
399                         time(&timep);
400                         strftime(screen.buf, screen.buf_size, "%X ",localtime(&timep));
401                 }
402 #endif
403         }
405         /* display song */
406         if (IS_PLAYING(state) || IS_PAUSED(state)) {
407                 char songname[MAX_SONGNAME_LENGTH];
408 #ifndef NCMPC_MINI
409                 int width = COLS - x - utf8_width(screen.buf);
410 #endif
412                 if (song)
413                         strfsong(songname, MAX_SONGNAME_LENGTH,
414                                  options.status_format, song);
415                 else
416                         songname[0] = '\0';
418                 colors_use(w, COLOR_STATUS);
419                 /* scroll if the song name is to long */
420 #ifndef NCMPC_MINI
421                 if (options.scroll && utf8_width(songname) > (unsigned)width) {
422                         static  scroll_state_t st = { 0, 0 };
423                         char *tmp = strscroll(songname, options.scroll_sep, width, &st);
425                         g_strlcpy(songname, tmp, MAX_SONGNAME_LENGTH);
426                         g_free(tmp);
427                 }
428 #endif
429                 //mvwaddnstr(w, 0, x, songname, width);
430                 mvwaddstr(w, 0, x, songname);
431         }
433         /* display time string */
434         if (screen.buf[0]) {
435                 x = screen.status_window.cols - strlen(screen.buf);
436                 colors_use(w, COLOR_STATUS_TIME);
437                 mvwaddstr(w, 0, x, screen.buf);
438         }
440         wnoutrefresh(w);
443 void
444 screen_exit(void)
446         if (mode_fn->close != NULL)
447                 mode_fn->close();
449         screen_list_exit();
451         string_list_free(screen.find_history);
452         g_free(screen.buf);
453         g_free(screen.findbuf);
455         delwin(screen.top_window.w);
456         delwin(screen.main_window.w);
457         delwin(screen.progress_bar.window.w);
458         delwin(screen.status_window.w);
461 void
462 screen_resize(struct mpdclient *c)
464         if (COLS<SCREEN_MIN_COLS || LINES<SCREEN_MIN_ROWS) {
465                 screen_exit();
466                 fprintf(stderr, "%s", _("Error: Screen too small"));
467                 exit(EXIT_FAILURE);
468         }
470         resizeterm(LINES, COLS);
472         screen.cols = COLS;
473         screen.rows = LINES;
475         /* top window */
476         screen.top_window.cols = screen.cols;
477         wresize(screen.top_window.w, 2, screen.cols);
479         /* main window */
480         screen.main_window.cols = screen.cols;
481         screen.main_window.rows = screen.rows-4;
482         wresize(screen.main_window.w, screen.main_window.rows, screen.cols);
483         wclear(screen.main_window.w);
485         /* progress window */
486         screen.progress_bar.window.cols = screen.cols;
487         wresize(screen.progress_bar.window.w, 1, screen.cols);
488         mvwin(screen.progress_bar.window.w, screen.rows-2, 0);
489         progress_bar_resize(&screen.progress_bar);
490         progress_bar_paint(&screen.progress_bar);
492         /* status window */
493         screen.status_window.cols = screen.cols;
494         wresize(screen.status_window.w, 1, screen.cols);
495         mvwin(screen.status_window.w, screen.rows-1, 0);
497         screen.buf_size = screen.cols;
498         g_free(screen.buf);
499         screen.buf = g_malloc(screen.cols);
501         /* resize all screens */
502         screen_list_resize(screen.main_window.cols, screen.main_window.rows);
504         /* ? - without this the cursor becomes visible with aterm & Eterm */
505         curs_set(1);
506         curs_set(0);
508         screen_paint(c);
511 void
512 screen_status_message(const char *msg)
514         WINDOW *w = screen.status_window.w;
516         wmove(w, 0, 0);
517         wclrtoeol(w);
518         colors_use(w, COLOR_STATUS_ALERT);
519         waddstr(w, msg);
520         wnoutrefresh(w);
521         screen.status_timestamp = time(NULL);
524 void
525 screen_status_printf(const char *format, ...)
527         char *msg;
528         va_list ap;
530         va_start(ap,format);
531         msg = g_strdup_vprintf(format,ap);
532         va_end(ap);
533         screen_status_message(msg);
534         g_free(msg);
537 void
538 screen_init(struct mpdclient *c)
540         if (COLS < SCREEN_MIN_COLS || LINES < SCREEN_MIN_ROWS) {
541                 fprintf(stderr, "%s\n", _("Error: Screen too small"));
542                 exit(EXIT_FAILURE);
543         }
545         screen.cols = COLS;
546         screen.rows = LINES;
548         screen.buf  = g_malloc(screen.cols);
549         screen.buf_size = screen.cols;
550         screen.findbuf = NULL;
551         screen.start_timestamp = time(NULL);
553         /* create top window */
554         window_init(&screen.top_window, 2, screen.cols, 0, 0);
555         leaveok(screen.top_window.w, TRUE);
556         keypad(screen.top_window.w, TRUE);
558         /* create main window */
559         window_init(&screen.main_window, screen.rows - 4, screen.cols, 2, 0);
561         //  leaveok(screen.main_window.w, TRUE); temporary disabled
562         keypad(screen.main_window.w, TRUE);
564         /* create progress window */
565         progress_bar_init(&screen.progress_bar, 1, screen.cols,
566                           screen.rows - 2, 0);
567         progress_bar_paint(&screen.progress_bar);
569         leaveok(screen.progress_bar.window.w, TRUE);
571         /* create status window */
572         window_init(&screen.status_window, 1, screen.cols,
573                     screen.rows - 1, 0);
575         leaveok(screen.status_window.w, FALSE);
576         keypad(screen.status_window.w, TRUE);
578 #ifdef ENABLE_COLORS
579         if (options.enable_colors) {
580                 /* set background attributes */
581                 wbkgd(stdscr, COLOR_PAIR(COLOR_LIST));
582                 wbkgd(screen.main_window.w,     COLOR_PAIR(COLOR_LIST));
583                 wbkgd(screen.top_window.w,      COLOR_PAIR(COLOR_TITLE));
584                 wbkgd(screen.progress_bar.window.w,
585                       COLOR_PAIR(COLOR_PROGRESSBAR));
586                 wbkgd(screen.status_window.w,   COLOR_PAIR(COLOR_STATUS));
587                 colors_use(screen.progress_bar.window.w, COLOR_PROGRESSBAR);
588         }
589 #endif
591         doupdate();
593         /* initialize screens */
594         screen_list_init(screen.main_window.w,
595                          screen.main_window.cols, screen.main_window.rows);
597         if (mode_fn->open != NULL)
598                 mode_fn->open(c);
601 void
602 screen_paint(struct mpdclient *c)
604         const char *title = NULL;
606         if (mode_fn->get_title != NULL)
607                 title = mode_fn->get_title(screen.buf, screen.buf_size);
609         /* paint the title/header window */
610         if( title )
611                 paint_top_window(title, c, 1);
612         else
613                 paint_top_window("", c, 1);
615         /* paint the bottom window */
617         paint_progress_window(c);
618         paint_status_window(c);
620         /* paint the main window */
622         wclear(screen.main_window.w);
623         if (mode_fn->paint != NULL)
624                 mode_fn->paint();
626         /* move the cursor to the origin */
628         if (!options.hardware_cursor)
629                 wmove(screen.main_window.w, 0, 0);
631         wnoutrefresh(screen.main_window.w);
633         /* tell curses to update */
634         doupdate();
637 void
638 screen_update(struct mpdclient *c)
640 #ifndef NCMPC_MINI
641         static bool initialized = false;
642         static bool repeat;
643         static bool random_enabled;
644         static bool single;
645         static bool consume;
646         static unsigned crossfade;
647         static unsigned dbupdate;
649         /* print a message if mpd status has changed */
650         if (c->status != NULL) {
651                 if (!initialized) {
652                         repeat = mpd_status_get_repeat(c->status);
653                         random_enabled = mpd_status_get_random(c->status);
654                         single = mpd_status_get_single(c->status);
655                         consume = mpd_status_get_consume(c->status);
656                         crossfade = mpd_status_get_crossfade(c->status);
657                         dbupdate = mpd_status_get_update_id(c->status);
658                         initialized = true;
659                 }
661                 if (repeat != mpd_status_get_repeat(c->status))
662                         screen_status_printf(mpd_status_get_repeat(c->status) ?
663                                              _("Repeat mode is on") :
664                                              _("Repeat mode is off"));
666                 if (random_enabled != mpd_status_get_random(c->status))
667                         screen_status_printf(mpd_status_get_random(c->status) ?
668                                              _("Random mode is on") :
669                                              _("Random mode is off"));
671                 if (single != mpd_status_get_single(c->status))
672                         screen_status_printf(mpd_status_get_single(c->status) ?
673                                              /* "single" mode means
674                                                 that MPD will
675                                                 automatically stop
676                                                 after playing one
677                                                 single song */
678                                              _("Single mode is on") :
679                                              _("Single mode is off"));
681                 if (consume != mpd_status_get_consume(c->status))
682                         screen_status_printf(mpd_status_get_consume(c->status) ?
683                                              /* "consume" mode means
684                                                 that MPD removes each
685                                                 song which has
686                                                 finished playing */
687                                              _("Consume mode is on") :
688                                              _("Consume mode is off"));
690                 if (crossfade != mpd_status_get_crossfade(c->status))
691                         screen_status_printf(_("Crossfade %d seconds"),
692                                              mpd_status_get_crossfade(c->status));
694                 if (dbupdate != 0 &&
695                     dbupdate != mpd_status_get_update_id(c->status)) {
696                         screen_status_printf(_("Database updated"));
697                 }
699                 repeat = mpd_status_get_repeat(c->status);
700                 random_enabled = mpd_status_get_random(c->status);
701                 single = mpd_status_get_single(c->status);
702                 consume = mpd_status_get_consume(c->status);
703                 crossfade = mpd_status_get_crossfade(c->status);
704                 dbupdate = mpd_status_get_update_id(c->status);
705         }
707         /* update title/header window */
708         if (welcome && options.welcome_screen_list &&
709             time(NULL)-screen.start_timestamp <= SCREEN_WELCOME_TIME)
710                 paint_top_window("", c, 0);
711         else
712 #endif
713         if (mode_fn->get_title != NULL) {
714                 paint_top_window(mode_fn->get_title(screen.buf,screen.buf_size), c, 0);
715 #ifndef NCMPC_MINI
716                 welcome = FALSE;
717 #endif
718         } else
719                 paint_top_window("", c, 0);
721         /* update progress window */
722         paint_progress_window(c);
724         /* update status window */
725         paint_status_window(c);
727         /* update the main window */
728         if (mode_fn->update != NULL)
729                 mode_fn->update(c);
731         /* move the cursor to the origin */
733         if (!options.hardware_cursor)
734                 wmove(screen.main_window.w, 0, 0);
736         wnoutrefresh(screen.main_window.w);
738         /* tell curses to update */
739         doupdate();
742 #ifdef HAVE_GETMOUSE
743 int
744 screen_get_mouse_event(struct mpdclient *c, unsigned long *bstate, int *row)
746         MEVENT event;
748         /* retrieve the mouse event from ncurses */
749         getmouse(&event);
750         /* calculate the selected row in the list window */
751         *row = event.y - screen.top_window.rows;
752         /* copy button state bits */
753         *bstate = event.bstate;
754         /* if button 2 was pressed switch screen */
755         if (event.bstate & BUTTON2_CLICKED) {
756                 screen_cmd(c, CMD_SCREEN_NEXT);
757                 return 1;
758         }
760         return 0;
762 #endif
764 void
765 screen_cmd(struct mpdclient *c, command_t cmd)
767 #ifndef NCMPC_MINI
768         welcome = FALSE;
769 #endif
771         if (mode_fn->cmd != NULL && mode_fn->cmd(c, cmd))
772                 return;
774         if (handle_player_command(c, cmd))
775                 return;
777         switch(cmd) {
778         case CMD_TOGGLE_FIND_WRAP:
779                 options.find_wrap = !options.find_wrap;
780                 screen_status_printf(options.find_wrap ?
781                                      _("Find mode: Wrapped") :
782                                      _("Find mode: Normal"));
783                 break;
784         case CMD_TOGGLE_AUTOCENTER:
785                 options.auto_center = !options.auto_center;
786                 screen_status_printf(options.auto_center ?
787                                      _("Auto center mode: On") :
788                                      _("Auto center mode: Off"));
789                 break;
790         case CMD_SCREEN_UPDATE:
791                 screen_paint(c);
792                 break;
793         case CMD_SCREEN_PREVIOUS:
794                 screen_next_mode(c, -1);
795                 break;
796         case CMD_SCREEN_NEXT:
797                 screen_next_mode(c, 1);
798                 break;
799         case CMD_SCREEN_PLAY:
800                 screen_switch(&screen_playlist, c);
801                 break;
802         case CMD_SCREEN_FILE:
803                 screen_switch(&screen_browse, c);
804                 break;
805 #ifdef ENABLE_HELP_SCREEN
806         case CMD_SCREEN_HELP:
807                 screen_switch(&screen_help, c);
808                 break;
809 #endif
810 #ifdef ENABLE_SEARCH_SCREEN
811         case CMD_SCREEN_SEARCH:
812                 screen_switch(&screen_search, c);
813                 break;
814 #endif
815 #ifdef ENABLE_ARTIST_SCREEN
816         case CMD_SCREEN_ARTIST:
817                 screen_switch(&screen_artist, c);
818                 break;
819 #endif
820 #ifdef ENABLE_SONG_SCREEN
821         case CMD_SCREEN_SONG:
822                 screen_switch(&screen_song, c);
823                 break;
824 #endif
825 #ifdef ENABLE_KEYDEF_SCREEN
826         case CMD_SCREEN_KEYDEF:
827                 screen_switch(&screen_keydef, c);
828                 break;
829 #endif
830 #ifdef ENABLE_LYRICS_SCREEN
831         case CMD_SCREEN_LYRICS:
832                 screen_switch(&screen_lyrics, c);
833                 break;
834 #endif
835 #ifdef ENABLE_OUTPUTS_SCREEN
836         case CMD_SCREEN_OUTPUTS:
837                 screen_switch(&screen_outputs, c);
838                 break;
839         case CMD_SCREEN_SWAP:
840                 screen_swap(c, NULL);
841                 break;
842 #endif
844         default:
845                 break;
846         }