tonylazuto
New Member
Tony Lazuto says hello
Posts: 25
|
Post by tonylazuto on Jan 12, 2023 19:34:50 GMT
I would need to check the clipboard function in QB64 to see what it is doing on the backend to return the values. Could be a simple fix. Could be some weird Mac thing. Who knows?
|
|
tonylazuto
New Member
Tony Lazuto says hello
Posts: 25
|
Post by tonylazuto on Jan 12, 2023 19:37:36 GMT
Here's the source for the clipboard function in libqb.cpp
qbs *func__clipboard() {
#ifdef QB64_WINDOWS
static qbs *text;
static uint8 *textz;
static HGLOBAL h;
if (OpenClipboard(NULL)) {
if (IsClipboardFormatAvailable(CF_TEXT)) {
h = GetClipboardData(CF_TEXT);
if (h) {
textz = (uint8 *)GlobalLock(h);
if (textz) {
text = qbs_new(strlen((char *)textz), 1);
memcpy(text->chr, textz, text->len);
GlobalUnlock(h);
CloseClipboard();
return text;
}
}
}
CloseClipboard();
}
text = qbs_new(0, 1);
return text;
#endif
#ifdef QB64_MACOSX
static qbs *text;
OSStatus err = noErr;
ItemCount itemCount;
PasteboardSyncFlags syncFlags;
static PasteboardRef inPasteboard = NULL;
PasteboardCreate(kPasteboardClipboard, &inPasteboard);
char *data;
data = "";
syncFlags = PasteboardSynchronize(inPasteboard);
err = badPasteboardSyncErr;
err = PasteboardGetItemCount(inPasteboard, &itemCount);
if ((err) != noErr)
goto CantGetPasteboardItemCount;
for (int itemIndex = 1; itemIndex <= itemCount; itemIndex++) {
PasteboardItemID itemID;
CFDataRef flavorData;
err = PasteboardGetItemIdentifier(inPasteboard, itemIndex, &itemID);
if ((err) != noErr)
goto CantGetPasteboardItemIdentifier;
err = PasteboardCopyItemFlavorData(inPasteboard, itemID, CFSTR("public.utf8-plain-text"), &flavorData);
if ((err) != noErr)
goto CantGetPasteboardItemCount;
data = (char *)CFDataGetBytePtr(flavorData);
uint32 size;
size = CFDataGetLength(flavorData);
text = qbs_new(size, 1);
memcpy(text->chr, data, text->len);
// CFRelease (flavorData);
// CFRelease (flavorTypeArray);
// CFRelease(inPasteboard);
return text;
CantGetPasteboardItemIdentifier:;
}
CantGetPasteboardItemCount:
text = qbs_new(0, 1);
return text;
return NULL;
#endif
#if defined(QB64_LINUX)
qbs *text;
char *cp = x11clipboardpaste();
cp = x11clipboardpaste();
if (!cp) {
text = qbs_new(0, 1);
} else {
text = qbs_new(strlen(cp), 1);
memcpy(text->chr, cp, text->len);
free(cp);
}
return text;
#endif
if (internal_clipboard == NULL)
internal_clipboard = qbs_new(0, 0);
return internal_clipboard;
}
|
|
|
Post by addicted2boats on Jan 13, 2023 0:58:40 GMT
Thank you for looking into this. It doesn't seem like it should be too complicated for an experienced programmer, but that code is Greek to me :-) I learned BASIC in high school, 43 years ago. Hadn't used it much since then, until I built a fully automated coil winder for making medical devices about 8 years ago. Looked into PLCs, smart relays, micro-controllers etc. Then finally thought why not BASIC? It's simple, flexible, doesn't require special hardware or RLL programming (Ugh!). With modern computers speed and memory aren't an issue. So I programmed it with QB64 on Windows 10 and it ran a $200K fully automatic coil winder. In the end I used about 6,000 lines of code, but I was being very verbose for any programmer that might have to deal with it later if I wasn't around. An efficient programmer probably could have reduced it to 1,000 lines or less. It ran unattended, sent me a text message if it ran into issues or completed it's run. If it lost building power or shop air it ran off a consumer UPS and had a small air reservoir. It would finish the current coil, find a safe place to shut down, text me it stopped and why. If the air and power returned it would start up where it left off and text me it was running again. It gave the operator instructions for loading the machine, used synthesized voice to talk to the operator at times when looking at the screen might not be convenient, and kept track of hours for any replacement parts so I could build a maintenance schedule. QB64 made all that possible and really made my job easier.
|
|
|
Post by addicted2boats on Jan 17, 2023 13:39:53 GMT
I am wondering if this should be considered a bug. On a Mac the clipboard is loaded by either "Copy to clipboard" or "Copy path to clipboard", in either case QB64 should be able to read the contents of the clipboard. If there is some character present or other reason QB64 doesn't read the entire clipboard, isn't that a bug? I wasn't sure if I should post this under "Bugs" or if Admin is supposed to move it there.
|
|
tonylazuto
New Member
Tony Lazuto says hello
Posts: 25
|
Post by tonylazuto on Jan 19, 2023 16:18:50 GMT
This forum isn't watched very closely so I think you should post it on GitHub as an Issue instead.
|
|
|
Post by bplus on Jan 19, 2023 18:41:12 GMT
This forum isn't watched very closely so I think you should post it on GitHub as an Issue instead. Aye! You could also try that other QB64 forum AKA QB64pe: qb64phoenix.com/forum/index.phpThere are more people who know OS other than Windows, I just dabble in Linux Mint when main laptop goes caput.
|
|
|
Post by addicted2boats on Feb 8, 2023 20:27:25 GMT
Thanks to everyone who replied here. I didn't solve the actual clipboard problem, but I switched over to QB64pe and it had commands that really made things easier for me (such as _SELECTFOLDERDIALOG$). Since it does everything that QB64 does and more, I've switched over to it for everything.
|
|