[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(
|
||||
FILES
|
||||
assetmanager.hpp
|
||||
clipboard.hpp
|
||||
color.hpp
|
||||
config.hpp
|
||||
consts.hpp
|
||||
|
@ -4,12 +4,43 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/claw/claw.hpp>
|
||||
#include <ox/std/string.hpp>
|
||||
|
||||
#include "context.hpp"
|
||||
|
||||
namespace nostalgia::core {
|
||||
|
||||
ox::String getClipboardText(class Context *ctx) 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
|
||||
|
||||
#include <ox/fs/fs.hpp>
|
||||
#include <ox/std/buffer.hpp>
|
||||
|
||||
#include "assetmanager.hpp"
|
||||
#include "event.hpp"
|
||||
@ -58,6 +59,7 @@ class Context {
|
||||
#ifndef OX_BARE_METAL
|
||||
AssetManager assetManager;
|
||||
int uninterruptedRefreshes = 0;
|
||||
ox::Buffer clipboard;
|
||||
#endif
|
||||
protected:
|
||||
#ifndef OX_BARE_METAL
|
||||
|
Loading…
Reference in New Issue
Block a user