summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 05f72f8)
raw | patch | inline | side by side (parent: 05f72f8)
author | Matt Portas <m.portas20@googlemail.com> | |
Fri, 21 Nov 2008 15:39:31 +0000 (16:39 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 21 Nov 2008 15:39:31 +0000 (16:39 +0100) |
If the song name under the cursor is too long for the terminal, scroll
it like in the statusbar.
it like in the statusbar.
src/screen_play.c | patch | blob | history |
diff --git a/src/screen_play.c b/src/screen_play.c
index 6cc7277ab73737893b1eda531fb91158ef64d9c7..aff41bac41371e90eb71b895414aa281b3d9c9ed 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
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))
*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;
}
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 */