reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit c0949154fb4b271a12ecd78fb87e7732b35a0208
parent 65a12768b79fbab029ac1a5711e3af0f3db572c0
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Tue, 17 May 2016 14:18:47 -0400

manager: implement copy url action

Diffstat:
Msrc/manager.cpp | 28++++++++++++++++++++++++++--
Msrc/manager.hpp | 1+
2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/manager.cpp b/src/manager.cpp @@ -31,7 +31,7 @@ using namespace std; enum { ACTION_ENABLE = 80, ACTION_DISABLE, ACTION_UNINSTALL, ACTION_ABOUT, - ACTION_REFRESH, ACTION_SELECT, ACTION_UNSELECT, + ACTION_REFRESH, ACTION_COPYURL, ACTION_SELECT, ACTION_UNSELECT, ACTION_AUTOINSTALL, ACTION_BLEEDINGEDGE }; Manager::Manager(ReaPack *reapack) @@ -114,8 +114,11 @@ void Manager::onCommand(const int id, int) close(); break; default: - if(id >> 8 == ACTION_ABOUT) + const int action = id >> 8; + if(action == ACTION_ABOUT) about(id & 0xff); + else if(action == ACTION_COPYURL) + copyUrl(id & 0xff); break; } } @@ -146,6 +149,7 @@ void Manager::onContextMenu(HWND target, const int x, const int y) menu.addSeparator(); menu.addAction(AUTO_STR("&Refresh"), ACTION_REFRESH); + menu.addAction(AUTO_STR("&Copy URL"), index | (ACTION_COPYURL << 8)); const UINT uninstallAction = menu.addAction(AUTO_STR("&Uninstall"), ACTION_UNINSTALL); @@ -264,6 +268,26 @@ void Manager::about(const int index) m_reapack->about(getRemote(index), handle()); } +void Manager::copyUrl(const int index) +{ + const Remote &remote = getRemote(index); + + if(remote.isNull()) + return; + + const auto_string &data = make_autostring(remote.url()); + const size_t length = data.size() * sizeof(auto_char); + + HANDLE mem = GlobalAlloc(GMEM_MOVEABLE, length); + memcpy(GlobalLock(mem), data.c_str(), length); + GlobalUnlock(mem); + + OpenClipboard(handle()); + EmptyClipboard(); + SetClipboardData(CF_TEXT, mem); + CloseClipboard(); +} + void Manager::options() { RECT rect; diff --git a/src/manager.hpp b/src/manager.hpp @@ -50,6 +50,7 @@ private: void uninstall(); void refreshIndex(); void about(int index); + void copyUrl(int index); void options(); bool confirm() const;