From: Max Kellermann Date: Thu, 25 Sep 2008 15:42:30 +0000 (+0200) Subject: screen_lyrics: added lyrics_repaint() X-Git-Tag: v0.12_alpha1~162 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=dea63513303a45a231c71958b1e2a392fbf12033;p=ncmpc.git screen_lyrics: added lyrics_repaint() lyrics_repaint() or lyrics_repaint_if_active() are called after data has changed, and the screen needs an update. --- diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c index 931b114..a039c38 100644 --- a/src/screen_lyrics.c +++ b/src/screen_lyrics.c @@ -82,8 +82,31 @@ screen_lyrics_clear(void) g_ptr_array_set_size(current.lines, 0); } -static const char * -list_callback(unsigned idx, int *highlight, void *data); +static void +lyrics_paint(mpdclient_t *c); + +/** + * Repaint and update the screen. + */ +static void +lyrics_repaint(void) +{ + lyrics_paint(NULL); + wrefresh(lw->w); +} + +/** + * Repaint and update the screen, if it is currently active. + */ +static void +lyrics_repaint_if_active(void) +{ + if (get_cur_mode_id() == 104) { /* XXX don't use the literal number */ + lyrics_repaint(); + + /* XXX repaint the screen title */ + } +} static void screen_lyrics_set(const GString *str) @@ -125,12 +148,7 @@ screen_lyrics_set(const GString *str) /* paint new data */ - if (get_cur_mode_id() == 104) { /* XXX don't use the literal number */ - list_window_paint(lw, list_callback, NULL); - wrefresh(lw->w); - - /* XXX repaint the screen title */ - } + lyrics_repaint_if_active(); } static void @@ -297,8 +315,7 @@ lyrics_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) case CMD_LYRICS_UPDATE: if (c->song != NULL) { screen_lyrics_load(c->song); - lyrics_paint(NULL); - wrefresh(lw->w); + lyrics_repaint(); } return 1; default: