MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / Clipboard_GetText

Function Clipboard_GetText

src/Window_WinCE.c:397–435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395}
396
397void Clipboard_GetText(cc_string* value) {
398 HWND hwnd = Window_Main.Handle.ptr;
399 cc_bool unicode;
400 HANDLE hGlobal;
401 SIZE_T size;
402 void* src;
403 int i;
404
405 /* retry up to 50 times */
406 for (i = 0; i < 50; i++) {
407 if (!OpenClipboard(hwnd)) {
408 Thread_Sleep(10);
409 continue;
410 }
411
412 unicode = true;
413 hGlobal = GetClipboardData(CF_UNICODETEXT);
414 if (!hGlobal) {
415 hGlobal = GetClipboardData(CF_TEXT);
416 unicode = false;
417 }
418
419 if (!hGlobal) { CloseClipboard(); return; }
420 src = GlobalLock(hGlobal);
421 size = GlobalSize(hGlobal);
422
423 /* ignore trailing NULL at end */
424 /* TODO: Verify it's always there */
425 if (unicode) {
426 String_AppendUtf16(value, src, size - 2);
427 } else {
428 String_AppendCP1252(value, src, size - 1);
429 }
430
431 GlobalUnlock(hGlobal);
432 CloseClipboard();
433 return;
434 }
435}
436
437void Clipboard_SetText(const cc_string* value) {
438 HWND hwnd = Window_Main.Handle.ptr;

Callers

nothing calls this directly

Calls 3

String_AppendUtf16Function · 0.85
String_AppendCP1252Function · 0.85
Thread_SleepFunction · 0.70

Tested by

no test coverage detected