42 lines
1.9 KiB
C++
42 lines
1.9 KiB
C++
/*
|
|
Crafter®.Graphics
|
|
Copyright (C) 2026 Catcrafts®
|
|
Catcrafts.net
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 3.0 of the License, or (at your option) any later version.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with this library; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
export module Crafter.Graphics:Clipboard;
|
|
import std;
|
|
|
|
// Native system-clipboard writes. No popen, no helper binaries — just
|
|
// the platform's own clipboard API. Implementation lives next to the
|
|
// other window-backend code (Wayland data_device on Linux, Win32 in
|
|
// the Windows build); callers don't pick a backend.
|
|
//
|
|
// `Get` is intentionally not exposed yet: paste-from-clipboard isn't
|
|
// a feature the game's UI wants right now, and the read path needs
|
|
// more lifecycle plumbing (mime negotiation, fd reads on the Wayland
|
|
// event loop) than the simple write path. Easy to add later.
|
|
export namespace Crafter::Clipboard {
|
|
|
|
// Place `text` on the system clipboard as UTF-8 plain text. Returns
|
|
// true if the platform accepted the request — false means the
|
|
// backend isn't initialised, no input event has been seen yet
|
|
// (Wayland needs a recent serial), or the OS API failed. On
|
|
// success the ownership of the clipboard contents is held until
|
|
// either another app replaces the selection or the application
|
|
// exits; the caller doesn't need to keep `text` alive.
|
|
bool SetText(std::string_view text);
|
|
}
|