From dc8aff65a28fd585a7a7f0743b56e840fd04fd0a Mon Sep 17 00:00:00 2001 From: Frank Blendinger Date: Wed, 14 Jul 2010 12:29:46 +0200 Subject: [PATCH] add separate keys to move sel. before/after cursor --- doc/keys | 4 ++++ src/help.cpp | 2 ++ src/ncmpcpp.cpp | 14 ++++++++++---- src/settings.cpp | 8 ++++++++ src/settings.h | 2 ++ 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/doc/keys b/doc/keys index 3cfa19d9..2b8366a1 100644 --- a/doc/keys +++ b/doc/keys @@ -146,6 +146,10 @@ # #key_move_to = 'M' # +#key_move_before = 0 +# +#key_move_after = 0 +# #key_add = 'a' # #key_save_playlist = 'S' diff --git a/src/help.cpp b/src/help.cpp index 95cccefa..0f4e0c49 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -231,6 +231,8 @@ void Help::GetKeybindings() *w << DisplayKeys(Key.MvSongUp) << "Move item(s) up\n"; *w << DisplayKeys(Key.MvSongDown) << "Move item(s) down\n"; *w << DisplayKeys(Key.MoveTo) << "Move selected item(s) to cursor position\n"; + *w << DisplayKeys(Key.MoveBefore) << "Move selected item(s) before cursor position\n"; + *w << DisplayKeys(Key.MoveAfter) << "Move selected item(s) after cursor position\n"; *w << DisplayKeys(Key.Add) << "Add url/file/directory to playlist\n"; # ifdef HAVE_TAGLIB_H *w << DisplayKeys(Key.EditTags) << "Edit song's tags\n"; diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 01de013e..61017490 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -1137,7 +1137,8 @@ int main(int argc, char *argv[]) wFooter->SetTimeout(ncmpcpp_window_timeout); } } - else if (Keypressed(input, Key.MoveTo) && myScreen == myPlaylist) + else if ((Keypressed(input, Key.MoveTo) || Keypressed(input, Key.MoveBefore) + || Keypressed(input, Key.MoveAfter)) && myScreen == myPlaylist) { CHECK_PLAYLIST_FOR_FILTERING; if (!myPlaylist->Items->hasSelected()) @@ -1147,13 +1148,18 @@ int main(int argc, char *argv[]) } Playlist::BlockUpdate = 1; size_t pos = myPlaylist->Items->Choice(); - // if cursor is at the last item, break convention and move at the end of playlist - if (pos == myPlaylist->Items->Size()-1) - pos++; std::vector list; myPlaylist->Items->GetSelected(list); if (pos >= list.front() && pos <= list.back()) continue; + if (Keypressed(input, Key.MoveTo)) + { + // if cursor is at the last item, break convention and move at the end of playlist + if (pos == myPlaylist->Items->Size()-1) + pos++; + } + else if (Keypressed(input, Key.MoveAfter)) + pos++; int diff = pos-list.front(); Mpd.StartCommandsList(); if (diff > 0) diff --git a/src/settings.cpp b/src/settings.cpp index 22b1d316..8d52d966 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -220,6 +220,8 @@ void NcmpcppKeys::SetDefaults() MvSongUp[0] = 'm'; MvSongDown[0] = 'n'; MoveTo[0] = 'M'; + MoveBefore[0] = NullKey; + MoveAfter[0] = NullKey; Add[0] = 'a'; SavePlaylist[0] = 'S'; GoToNowPlaying[0] = 'o'; @@ -302,6 +304,8 @@ void NcmpcppKeys::SetDefaults() MvSongUp[1] = NullKey; MvSongDown[1] = NullKey; MoveTo[1] = NullKey; + MoveBefore[1] = NullKey; + MoveAfter[1] = NullKey; Add[1] = NullKey; SavePlaylist[1] = NullKey; GoToNowPlaying[1] = NullKey; @@ -571,6 +575,10 @@ void NcmpcppKeys::Read() GetKeys(key, MvSongDown); else if (key.find("key_move_to ") != std::string::npos) GetKeys(key, MoveTo); + else if (key.find("key_move_before ") != std::string::npos) + GetKeys(key, MoveBefore); + else if (key.find("key_move_after ") != std::string::npos) + GetKeys(key, MoveAfter); else if (key.find("key_add ") != std::string::npos) GetKeys(key, Add); else if (key.find("key_save_playlist ") != std::string::npos) diff --git a/src/settings.h b/src/settings.h index 67b885b3..c370798f 100644 --- a/src/settings.h +++ b/src/settings.h @@ -125,6 +125,8 @@ struct NcmpcppKeys int MvSongUp[2]; int MvSongDown[2]; int MoveTo[2]; + int MoveBefore[2]; + int MoveAfter[2]; int Add[2]; int SavePlaylist[2]; int GoToNowPlaying[2];