[nostalgia/core] Add object clipboard in addition to text clipboard
This commit is contained in:
parent
92651973ce
commit
a6983ce53b
@ -92,6 +92,7 @@ endif()
|
|||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
assetmanager.hpp
|
assetmanager.hpp
|
||||||
|
clipboard.hpp
|
||||||
color.hpp
|
color.hpp
|
||||||
config.hpp
|
config.hpp
|
||||||
consts.hpp
|
consts.hpp
|
||||||
|
@ -4,12 +4,43 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <ox/claw/claw.hpp>
|
||||||
#include <ox/std/string.hpp>
|
#include <ox/std/string.hpp>
|
||||||
|
|
||||||
|
#include "context.hpp"
|
||||||
|
|
||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
ox::String getClipboardText(class Context *ctx) noexcept;
|
ox::String getClipboardText(class Context *ctx) noexcept;
|
||||||
|
|
||||||
void setClipboardText(class Context *ctx, const ox::String &text) noexcept;
|
void setClipboardText(class Context *ctx, const ox::String &text) noexcept;
|
||||||
|
|
||||||
|
void setClipboardObject([[maybe_unused]] class Context *ctx, [[maybe_unused]] auto *obj) noexcept {
|
||||||
|
#ifndef OX_BARE_METAL
|
||||||
|
auto [buff, err] = ox::writeClaw(obj);
|
||||||
|
if (err) {
|
||||||
|
oxLogError(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ctx->clipboard = std::move(buff);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
ox::Error getClipboardObject([[maybe_unused]] class Context *ctx, [[maybe_unused]] auto *obj) noexcept {
|
||||||
|
#ifndef OX_BARE_METAL
|
||||||
|
return ox::readClaw<decltype(*obj)>(ctx->clipboard).moveTo(obj);
|
||||||
|
#else
|
||||||
|
return OxError(0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
ox::Result<T> getClipboardObject([[maybe_unused]] class Context *ctx) noexcept {
|
||||||
|
#ifndef OX_BARE_METAL
|
||||||
|
return ox::readClaw<T>(ctx->clipboard);
|
||||||
|
#else
|
||||||
|
return OxError(0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ox/fs/fs.hpp>
|
#include <ox/fs/fs.hpp>
|
||||||
|
#include <ox/std/buffer.hpp>
|
||||||
|
|
||||||
#include "assetmanager.hpp"
|
#include "assetmanager.hpp"
|
||||||
#include "event.hpp"
|
#include "event.hpp"
|
||||||
@ -58,6 +59,7 @@ class Context {
|
|||||||
#ifndef OX_BARE_METAL
|
#ifndef OX_BARE_METAL
|
||||||
AssetManager assetManager;
|
AssetManager assetManager;
|
||||||
int uninterruptedRefreshes = 0;
|
int uninterruptedRefreshes = 0;
|
||||||
|
ox::Buffer clipboard;
|
||||||
#endif
|
#endif
|
||||||
protected:
|
protected:
|
||||||
#ifndef OX_BARE_METAL
|
#ifndef OX_BARE_METAL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user