From: Jeffrey Middleton Date: Fri, 6 Mar 2009 00:06:05 +0000 (-0600) Subject: screen_play: Changed selection movement on center-playing-song X-Git-Tag: release-0.14~76 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0d8ef99f257a7ee9a84d07c0c491f7e7067c33af;p=ncmpc.git screen_play: Changed selection movement on center-playing-song Previously, the cursor remained in the same screen position (and had some odd behavior in visual mode). Now it attempts to stay on the same song like other large movement commands, leaving visual mode intact, so you can do fun things like using center-playing-song to help select a range of songs up to the current song. --- diff --git a/src/screen_play.c b/src/screen_play.c index f668757..b9b0ecb 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -140,7 +140,6 @@ static void center_playing_item(mpdclient_t *c) { unsigned length = c->playlist.list->len; - unsigned offset = lw->selected - lw->start; int idx; if (!c->song || length < lw->rows || @@ -155,10 +154,25 @@ center_playing_item(mpdclient_t *c) list_window_center(lw, length, idx); /* make sure the cursor is in the window */ - lw->selected = lw->start+offset; - lw->selected_start = lw->selected; - lw->selected_end = lw->selected; - list_window_check_selected(lw, length); + if (lw->selected < lw->start) { + lw->selected = lw->start; + if (lw->visual_selection) { + lw->selected_start = lw->visual_base; + lw->selected_end = lw->selected; + } else { + lw->selected_start = lw->selected; + lw->selected_end = lw->selected; + } + } else if (lw->selected > lw->start + lw->rows - 1) { + lw->selected = lw->start + lw->rows - 1; + if (lw->visual_selection) { + lw->selected_start = lw->selected; + lw->selected_end = lw->visual_base; + } else { + lw->selected_start = lw->selected; + lw->selected_end = lw->selected; + } + } } #ifndef NCMPC_MINI