MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DumpTextToClipboard

Function DumpTextToClipboard

ddebug/windebug.cpp:281–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279///////////////////////////////////////////////////////////////////////////////
280
281void DumpTextToClipboard(char *text) {
282 char *ptr;
283
284 // Count number of carriage returns to be added
285 char last_char = 0;
286 int extra = 0;
287 ptr = text;
288 while (*ptr) {
289 if ((*ptr == '\n') && (last_char != '\r')) {
290 extra++;
291 }
292 last_char = *ptr++;
293 }
294
295 // Length of string with CRs added
296 size_t len = strlen(text) + extra + 1;
297
298 HGLOBAL h_text = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, len);
299 if (!h_text)
300 return;
301 ptr = (char *)GlobalLock(h_text);
302 if (!ptr)
303 return;
304
305 // copy then, if you find any \n's without \r's, then add in the \r.
306 last_char = 0;
307 while (*text) {
308 if ((*text == '\n') && (last_char != '\r')) {
309 *ptr++ = '\r';
310 }
311 last_char = *text;
312 *ptr++ = last_char;
313 text++;
314 }
315 *ptr = 0; // terminate string
316 GlobalUnlock(h_text);
317 OpenClipboard(NULL);
318 EmptyClipboard();
319 SetClipboardData(CF_TEXT, h_text);
320 CloseClipboard();
321}
322
323void dump_text_to_clipboard(char *text) { DumpTextToClipboard(text); }
324

Callers 7

VerifyMineFunction · 0.85
VerifyRoomFunction · 0.85
ComputeAllRoomShellsFunction · 0.85
ListObjectsInAllLevelsFunction · 0.85
OnBadCenterpointsMethod · 0.85
LookForFVICracksFunction · 0.85
dump_text_to_clipboardFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected