Skip to content

Commit

Permalink
Add scrolling with paste.
Browse files Browse the repository at this point in the history
Also use existing enums instead of creating new ones. Added a check for
empty playlist.
  • Loading branch information
connermcd committed Feb 21, 2014
1 parent c16c991 commit b52a0d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/mode/normal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,8 @@ Normal::Normal(Main::Vimpc * vimpc, Ui::Screen & screen, Mpc::Client & client, M
actionTable_["x"] = &Normal::Crop<Mpc::Song::Single>;
actionTable_["X"] = &Normal::Crop<Mpc::Song::All>;
actionTable_["<Del>"] = &Normal::Delete<Item::Single>;

actionTable_["P"] = &Normal::PasteBuffer<0>;
actionTable_["p"] = &Normal::PasteBuffer<1>;
actionTable_["p"] = &Normal::PasteBuffer<Screen::Down>;
actionTable_["P"] = &Normal::PasteBuffer<Screen::Up>;

// Navigation
actionTable_["<Nop>"] = &Normal::DoNothing;
Expand Down Expand Up @@ -1134,9 +1133,11 @@ void Normal::Crop(uint32_t count)
}
}

template <int BELOW>
template <Screen::Direction DIRECTION>
void Normal::PasteBuffer(uint32_t count)
{
uint32_t direction = Main::Playlist().Size() == 0 ? 0 : DIRECTION;

Mpc::CommandList list(client_);

if (screen_.GetActiveWindow() == Screen::Playlist)
Expand All @@ -1146,9 +1147,11 @@ void Normal::PasteBuffer(uint32_t count)
for (uint32_t j = 0; j < Main::PlaylistPasteBuffer().Size(); ++j)
{
client_.Add(*Main::PlaylistPasteBuffer().Get(j),
screen_.ActiveWindow().CurrentLine() + j + BELOW);
screen_.ActiveWindow().CurrentLine() + j + direction);
}
}

screen_.Scroll(Main::PlaylistPasteBuffer().Size() * count * direction);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/mode/normal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace Ui
template <Mpc::Song::SongCollection COLLECTION>
void Crop(uint32_t count);

template <int BELOW>
template <Screen::Direction DIRECTION>
void PasteBuffer(uint32_t count);

private: //Selecting
Expand Down

0 comments on commit b52a0d4

Please sign in to comment.