magiblot/turbo

System clipboard integration

electroly opened this issue · 2 comments

Hi @magiblot, in commit f278299 the Clipboard class was dropped. I'm trying to figure out how to fix tmbasic accordingly. Is turbo no longer attempting to integrate with the system clipboard, or am I missing a new spot where that integration happens? Is there an integration point where I can bring back libclipboard as a tmbasic-level dependency? I appreciate any tips you can provide!

Hi Brian, I saw your build broke, but I had this error when trying to build tmbasic, so I couldn't create a patch for you:

ERROR: failed to solve: executor failed running [/bin/sh -c mkdir -p /tmp/downloads &&     tar xf /tmp/deps.tar -C /tmp/downloads &&     mkdir -p /usr/local/$(uname -m)-linux-gnu/include &&     mkdir -p /tmp/deps &&     cd /tmp/deps &&     export NATIVE_PREFIX=/usr &&     export TARGET_PREFIX=/usr/local/$(uname -m)-linux-gnu     export ARCH=x86_64     export LINUX_DISTRO=ubuntu     export LINUX_TRIPLE=$(uname -m)-linux-gnu     export TARGET_OS=linux     export DOWNLOAD_DIR=/tmp/downloads &&     make -j$(nproc) -f /tmp/deps.mk &&     rm -rf /tmp/deps /tmp/deps.mk]: exit code: 2

Clipboard integration is explained here.

In short, you will now receive paste events as regular text events. This way, you process pasting from the system clipboard in the same way as pasting through the terminal.

Therefore, the equivalent of storing the clipboard contents in a string is now:

void MyView::handleEvent(TEvent &ev)
{
    if (ev.what == evKeyDown)
    {
        if (ev.keyDown.controlKeyState & kbPaste)
        {
            std::string s;
            char buf[512];
            size_t length;
            while (textEvent(ev, buf, length))
                s.append(buf, length);
            // 's' now contains the clipboard contents
        }
    }
}

Also, the dependencies for clipboard support have changed. libclipboard is no longer required, but the guest system requires having the xclip, xsel (X11) or wl-clipboard (Wayland) applications installed. On macOS and Windows, it works out-of-the-box.

Thanks so much! I was able to fix my bit rot and implement the clipboard changes. Dropping libclipboard allowed me to drop several unpleasant X11 deps that I was building from source. Looks great!