[nostalgia/core] Add clipboard support

This commit is contained in:
Gary Talent 2021-07-16 20:51:10 -05:00
parent 950712b85e
commit efe61bab6f
4 changed files with 50 additions and 0 deletions

View File

@ -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 <ox/std/string.hpp>
namespace nostalgia::core {
ox::String getClipboardText(class Context *ctx) noexcept;
void setClipboardText(class Context *ctx, const ox::String &text) noexcept;
}

View File

@ -10,6 +10,7 @@
#include <ox/fs/fs.hpp>
#include "clipboard.hpp"
#include "consts.hpp"
#include "gfx.hpp"
#include "input.hpp"

View File

@ -1,5 +1,6 @@
add_library(
NostalgiaCore-GLFW
clipboard.cpp
core.cpp
gfx.cpp
)

View File

@ -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 <GLFW/glfw3.h>
#include <ox/std/string.hpp>
#include <nostalgia/core/core.hpp>
#include "core.hpp"
namespace nostalgia::core {
ox::String getClipboardText(Context *ctx) noexcept {
const auto id = ctx->windowerData<GlfwImplData>();
return glfwGetClipboardString(id->window);
}
void setClipboardText(Context *ctx, const ox::String &text) noexcept {
const auto id = ctx->windowerData<GlfwImplData>();
glfwSetClipboardString(id->window, text.c_str());
}
}