aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen_play.c
diff options
context:
space:
mode:
authorMatt Portas <m.portas20@googlemail.com>2008-11-21 16:39:31 +0100
committerMax Kellermann <max@duempel.org>2008-11-21 16:39:31 +0100
commitcfad0fdfca5821eb2d17f93bc08d4e5efc23beae (patch)
tree7041ef3ac699c5f3129012644eed8d93c0713116 /src/screen_play.c
parent05f72f894659816da28890169e6dd7aa312234e9 (diff)
downloadmpd-cfad0fdfca5821eb2d17f93bc08d4e5efc23beae.tar.gz
mpd-cfad0fdfca5821eb2d17f93bc08d4e5efc23beae.tar.xz
mpd-cfad0fdfca5821eb2d17f93bc08d4e5efc23beae.zip
screen_play: scroll long song names in the playlist
If the song name under the cursor is too long for the terminal, scroll it like in the statusbar.
Diffstat (limited to '')
-rw-r--r--src/screen_play.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/screen_play.c b/src/screen_play.c
index 6cc7277ab..aff41bac4 100644
--- a/src/screen_play.c
+++ b/src/screen_play.c
@@ -94,6 +94,7 @@ static const char *
list_callback(unsigned idx, int *highlight, mpd_unused void *data)
{
static char songname[MAX_SONG_LENGTH];
+ static scroll_state_t st;
mpd_Song *song;
if (playlist == NULL || idx >= playlist_length(playlist))
@@ -104,6 +105,24 @@ list_callback(unsigned idx, int *highlight, mpd_unused void *data)
*highlight = 1;
strfsong(songname, MAX_SONG_LENGTH, options.list_format, song);
+
+ if (options.scroll && (unsigned)song->pos == lw->selected &&
+ utf8_width(songname) > (unsigned)COLS) {
+ static unsigned current_song;
+ char *tmp;
+
+ if (current_song != lw->selected) {
+ st.offset = 0;
+ current_song = lw->selected;
+ }
+
+ tmp = strscroll(songname, options.scroll_sep,
+ MAX_SONG_LENGTH, &st);
+ g_strlcpy(songname, tmp, MAX_SONG_LENGTH);
+ g_free(tmp);
+ } else if ((unsigned)song->pos == lw->selected)
+ st.offset = 0;
+
return songname;
}
@@ -448,7 +467,7 @@ play_update(mpdclient_t *c)
current_song_id = c->song != NULL && c->status != NULL &&
!IS_STOPPED(c->status->state) ? c->song->id : -1;
- if (current_song_id != prev_song_id) {
+ if (options.scroll || current_song_id != prev_song_id) {
prev_song_id = current_song_id;
/* center the cursor */