diff --git a/Editor/src/Windows/FileSystemUI.cpp b/Editor/src/Windows/FileSystemUI.cpp index 26f07d9a..32bd6785 100644 --- a/Editor/src/Windows/FileSystemUI.cpp +++ b/Editor/src/Windows/FileSystemUI.cpp @@ -162,10 +162,29 @@ namespace Nuake } } + if (ImGui::BeginMenu("Copy")) + { + ImGui::Separator(); + + if (ImGui::MenuItem("Full Path")) + { + OS::CopyToClipboard(file->GetAbsolutePath()); + } + + if (ImGui::MenuItem("File Name")) + { + OS::CopyToClipboard(file->GetName()); + } + + ImGui::EndPopup(); + } + if(file->GetExtension() != ".project") { ImGui::Separator(); + // TODO: Add to a 'Edit' menu with File Rename, etc. + if (ImGui::MenuItem("Delete")) { if(FileSystem::RemoveFile(file->GetAbsolutePath()) != 0) diff --git a/Nuake/src/Core/OS.cpp b/Nuake/src/Core/OS.cpp index a59ee64c..c2fd29bf 100644 --- a/Nuake/src/Core/OS.cpp +++ b/Nuake/src/Core/OS.cpp @@ -1,11 +1,40 @@ #include "OS.h" +#include "src/Window.h" + +#define GLFW_EXPOSE_NATIVE_WIN32 +#include "GLFW/glfw3.h" +#include "GLFW/glfw3native.h" -#include #include +#include using namespace Nuake; -int OS::GetTime() +void OS::CopyToClipboard(const std::string& value) +{ + auto glob = GlobalAlloc(GMEM_FIXED, 512); + memcpy(glob, value.data(), value.size()); + OpenClipboard(glfwGetWin32Window(Window::Get()->GetHandle())); + EmptyClipboard(); + SetClipboardData(CF_TEXT, glob); + CloseClipboard(); +} + +std::string OS::GetFromClipboard() +{ + OpenClipboard(nullptr); + HANDLE hData = GetClipboardData(CF_TEXT); + + char* pszText = static_cast(GlobalLock(hData)); + std::string text(pszText); + + GlobalUnlock(hData); + CloseClipboard(); + + return text; +} + +int OS::GetTime() { return static_cast(std::chrono::system_clock::now().time_since_epoch().count()); } diff --git a/Nuake/src/Core/OS.h b/Nuake/src/Core/OS.h index 71f80d21..657b1fb5 100644 --- a/Nuake/src/Core/OS.h +++ b/Nuake/src/Core/OS.h @@ -7,6 +7,8 @@ namespace Nuake class OS { public: + static void CopyToClipboard(const std::string& value); + static std::string GetFromClipboard(); static int GetTime(); static void OpenIn(const std::string& filePath); static void ShowInFileExplorer(const std::string& filePath);