diff --git a/src/nostalgia/core/clipboard.hpp b/src/nostalgia/core/clipboard.hpp new file mode 100644 index 00000000..579c4958 --- /dev/null +++ b/src/nostalgia/core/clipboard.hpp @@ -0,0 +1,19 @@ +/* + * Copyright 2016 - 2021 gary@drinkingtea.net + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include + +namespace nostalgia::core { + +ox::String getClipboardText(class Context *ctx) noexcept; + +void setClipboardText(class Context *ctx, const ox::String &text) noexcept; + +} diff --git a/src/nostalgia/core/core.hpp b/src/nostalgia/core/core.hpp index b790d0a4..fe624f60 100644 --- a/src/nostalgia/core/core.hpp +++ b/src/nostalgia/core/core.hpp @@ -10,6 +10,7 @@ #include +#include "clipboard.hpp" #include "consts.hpp" #include "gfx.hpp" #include "input.hpp" diff --git a/src/nostalgia/core/glfw/CMakeLists.txt b/src/nostalgia/core/glfw/CMakeLists.txt index 036dc166..cb88996f 100644 --- a/src/nostalgia/core/glfw/CMakeLists.txt +++ b/src/nostalgia/core/glfw/CMakeLists.txt @@ -1,5 +1,6 @@ add_library( NostalgiaCore-GLFW + clipboard.cpp core.cpp gfx.cpp ) diff --git a/src/nostalgia/core/glfw/clipboard.cpp b/src/nostalgia/core/glfw/clipboard.cpp new file mode 100644 index 00000000..2374a0ed --- /dev/null +++ b/src/nostalgia/core/glfw/clipboard.cpp @@ -0,0 +1,29 @@ +/* + * Copyright 2016 - 2021 gary@drinkingtea.net + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include + +#include + +#include "core.hpp" + +namespace nostalgia::core { + +ox::String getClipboardText(Context *ctx) noexcept { + const auto id = ctx->windowerData(); + return glfwGetClipboardString(id->window); +} + +void setClipboardText(Context *ctx, const ox::String &text) noexcept { + const auto id = ctx->windowerData(); + glfwSetClipboardString(id->window, text.c_str()); +} + +}