Open apgove opened 2 years ago
If it's easy. Hoping there's a simple mini-library out there for cross-platform clipboard
If it's easy.
Understood :). If I can get my dev environment working again, I can check if the logic inside the ifdef is functional, at least on my Mac. But I'd need some help testing on other systems, and some hand-holding using git which my brain has never quite been able to grasp. Although now that I've started looking for it, I can't find where the getClipboard() function is defined, so I'm guessing it won't compile without a bit of extra work.
Hoping there's a simple mini-library out there for cross-platform clipboard
Or perhaps a drop-in replacement for getInputTextString, which might be re-inventing a wheel.
It looks like SDL has a function for this: https://wiki.libsdl.org/SDL_GetClipboardText. That wouldn't work in the terminal version, but it might be good enough.
I'd be happy to test on Linux (Ubuntu 18.04).
in IOS, that's specially handled in the platform specific code.
FYI, removing the #ifdef, switching to SDL_GetClipboardText(), adding an #include
The quick and dirty "fix" is to just keep using TAB, change the #ifdef to check for BROGUE_SDL instead of USE_CLIPBOARD, and call it a day. The more diligent, multi-file fix would be to create a generic getClipboard function and platform-specific implementations. I'm leaning towards quick and dirty.
Incidentally, does this screw up recordings? E.g. someone labels an item by pasting something from their clipboard, but the clipboard's contents are transient, so it gets a different label on playback.
FYI, removing the #ifdef, switching to SDL_GetClipboardText(), adding an #include
, adding SDL_free(clipboard), and fixing a bug where the pasted text wasn't actually being inserted into returned string, and it works :). But it's ugly, and still uses the TAB key. I was trying to figure out if there's a standard way to detect a paste "event" in SDL, but this tutorial just checks for CTRL and 'v', so I suspect not. Not sure whether that even works for Macs' Command-V and/or non-English-language systems. The quick and dirty "fix" is to just keep using TAB, change the #ifdef to check for BROGUE_SDL instead of USE_CLIPBOARD, and call it a day. The more diligent, multi-file fix would be to create a generic getClipboard function and platform-specific implementations. I'm leaning towards quick and dirty.
I'd prefer to stick with standard keyboard shortcuts wherever possible. Maybe just check for both ctrl-v
and command-v
on all platforms? That shouldn't be hard to implement, and a bunch of commands already use ctrl
so it should be fine.
Incidentally, does this screw up recordings? E.g. someone labels an item by pasting something from their clipboard, but the clipboard's contents are transient, so it gets a different label on playback.
It looks like the call()
function in Items.c
saves only the resulting string, not the sequence of keystrokes used to enter it, so it probably works. It should be easy to test though.
System-level paste events aren't appropriately processed when user-input is requested. From a brief examination, it appears to be that getInputTextString() in IO.c processes individual keystrokes, filtered through a whitelist of acceptable characters, and effectively ignores the Ctrl-V / Command-V entered by the user.
Oddly, there does appear to be logic for processing a paste from the clipboard, triggered by hitting the TAB key (?!?), but it is bracketed by an unset ifdef USE_CLIPBOARD. I can't tell if it's functional or not, or if it would work on various platforms.