Code

include ncursesw/ncurses.h if available
[ncmpc.git] / src / screen_lyrics.c
index 927b3dd9c486e0009af6d17ac5f7adeed49c9fd1..6d9c6e4af03ab96a700c0dc647f9d8ed0d114423 100644 (file)
 #include "screen_utils.h"
 #include "strfsong.h"
 #include "lyrics.h"
+#include "charset.h"
 #include "gcc.h"
 
 #define _GNU_SOURCE
 #include <stdlib.h>
 #include <string.h>
 #include <glib.h>
-#include <ncurses.h>
 #include <unistd.h>
 #include <stdio.h>
 
@@ -83,7 +83,7 @@ screen_lyrics_clear(void)
 }
 
 static void
-lyrics_paint(mpdclient_t *c);
+lyrics_paint(void);
 
 /**
  * Repaint and update the screen.
@@ -91,7 +91,7 @@ lyrics_paint(mpdclient_t *c);
 static void
 lyrics_repaint(void)
 {
-       lyrics_paint(NULL);
+       lyrics_paint();
        wrefresh(lw->w);
 }
 
@@ -221,10 +221,17 @@ static int store_lyr_hd(void)
 static const char *
 list_callback(unsigned idx, mpd_unused int *highlight, mpd_unused void *data)
 {
+       static char buffer[256];
+       char *value;
+
        if (idx >= current.lines->len)
                return NULL;
 
-       return g_ptr_array_index(current.lines, idx);
+       value = utf8_to_locale(g_ptr_array_index(current.lines, idx));
+       g_strlcpy(buffer, value, sizeof(buffer));
+       free(value);
+
+       return buffer;
 }
 
 
@@ -256,7 +263,7 @@ lyrics_exit(void)
 }
 
 static void
-lyrics_open(mpd_unused screen_t *screen, mpdclient_t *c)
+lyrics_open(mpdclient_t *c)
 {
        if (next_song == NULL)
                next_song = c->song;
@@ -283,13 +290,13 @@ lyrics_title(char *str, size_t size)
 }
 
 static void
-lyrics_paint(mpd_unused mpdclient_t *c)
+lyrics_paint(void)
 {
        list_window_paint(lw, list_callback, NULL);
 }
 
 static int
-lyrics_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
+lyrics_cmd(mpdclient_t *c, command_t cmd)
 {
        if (list_window_scroll_cmd(lw, current.lines->len, cmd)) {
                lyrics_repaint();
@@ -319,8 +326,7 @@ lyrics_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
        }
 
        lw->selected = lw->start+lw->rows;
-       if (screen_find(screen,
-                       lw, current.lines->len,
+       if (screen_find(lw, current.lines->len,
                        cmd, list_callback, NULL)) {
                /* center the row */
                list_window_center(lw, current.lines->len, lw->selected);