package dev.photosync.platform;

import dev.photosync.mcapi.Clipboard;
import net.minecraft.client.Minecraft;

/**
 * The system clipboard, via the keyboard handler that already owns GLFW's.
 *
 * <p>Going through Minecraft rather than AWT matters on macOS, where touching
 * {@code java.awt} from the render thread of a GLFW application is a hang.
 */
public final class ClipboardAdapter implements Clipboard {

    @Override
    public String read() {
        return Minecraft.getInstance().keyboardHandler.getClipboard();
    }

    @Override
    public void write(String text) {
        Minecraft.getInstance().keyboardHandler.setClipboard(text);
    }
}
