summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 478f170)
raw | patch | inline | side by side (parent: 478f170)
author | Jeffrey Middleton <jefromi@gmail.com> | |
Tue, 10 Mar 2009 13:49:46 +0000 (08:49 -0500) | ||
committer | Jeffrey Middleton <jefromi@gmail.com> | |
Tue, 10 Mar 2009 15:07:57 +0000 (10:07 -0500) |
To aid in getting to info/lyrics screen, or in selecting ranges
involving the currently playing song. Ctrl-L followed by M will achieve
the same result as long as the playlist is at least as long as the
screen, but this is faster to type and will work for short playlists
too.
An alternative method would be to center the cursor whenever Ctrl-L will
not cause the screen to move; this could be implemented as an option
perhaps, but would be annoying if you just wanted to repaint the screen.
involving the currently playing song. Ctrl-L followed by M will achieve
the same result as long as the playlist is at least as long as the
screen, but this is faster to type and will work for short playlists
too.
An alternative method would be to center the cursor whenever Ctrl-L will
not cause the screen to move; this could be implemented as an option
perhaps, but would be annoying if you just wanted to repaint the screen.
src/screen_play.c | patch | blob | history |
diff --git a/src/screen_play.c b/src/screen_play.c
index b9b0ecb0f18606cf639f905a76ef31728cf201a4..ceb37c4918dcb642eaafc1e61177d446dc2c880c 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
}
static void
-center_playing_item(mpdclient_t *c)
+center_playing_item(mpdclient_t *c, bool center_cursor)
{
unsigned length = c->playlist.list->len;
int idx;
- if (!c->song || length < lw->rows ||
- c->status == NULL || IS_STOPPED(c->status->state))
+ if (!c->song || c->status == NULL ||
+ IS_STOPPED(c->status->state))
return;
/* try to center the song that are playing */
if (idx < 0)
return;
+ if (length < lw->rows)
+ {
+ if (center_cursor)
+ list_window_set_selected(lw, idx);
+ return;
+ }
+
list_window_center(lw, length, idx);
+ if (center_cursor) {
+ list_window_set_selected(lw, idx);
+ return;
+ }
+
/* make sure the cursor is in the window */
if (lw->selected < lw->start) {
lw->selected = lw->start;
/* center the cursor */
if (options.auto_center && current_song_id != -1 && ! lw->visual_selection)
- center_playing_item(c);
+ center_playing_item(c, false);
playlist_repaint();
#ifndef NCMPC_MINI
static bool
play_cmd(mpdclient_t *c, command_t cmd)
{
+ static command_t cached_cmd = CMD_NONE;
+ command_t prev_cmd = cached_cmd;
+ cached_cmd = cmd;
+
lw->hide_cursor = false;
if (options.hide_cursor > 0) {
handle_add_to_playlist(c);
return true;
case CMD_SCREEN_UPDATE:
- center_playing_item(c);
+ center_playing_item(c, prev_cmd == CMD_SCREEN_UPDATE);
playlist_repaint();
return false;
case CMD_SHUFFLE: