nostalgia/src/turbine/glfw/clipboard.cpp

28 lines
635 B
C++

/*
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include <GLFW/glfw3.h>
#include <ox/std/string.hpp>
#include <turbine/turbine.hpp>
#include "context.hpp"
namespace turbine {
ox::String getClipboardText(Context &ctx) noexcept {
auto &gctx = static_cast<GlfwContext&>(ctx);
return glfwGetClipboardString(gctx.window);
}
void setClipboardText(Context &ctx, ox::CRStringView text) noexcept {
auto &gctx = static_cast<GlfwContext&>(ctx);
auto cstr = ox_malloca(text.bytes() + 1, char);
ox_strncpy(cstr.get(), text.data(), text.bytes());
glfwSetClipboardString(gctx.window, cstr);
}
}