Adding concopy command to Quake
Type concopy in the console and all that text is now on your clipboard and you can paste it somewhere, instead of the various hassle methods of using condump (if you use an engine with that) or using -condebug + qconsole.log.
Will be in the next incremental ProQuake 3.99 update (version m).
In console.c (adapted from FitzQuake's condump command)
In Con_Init in console.c
In sys_win.c (straight out of FuhQuake)
In sys.h
/The End
Works fine in ProQuake and should be compatible with any engine very similar to WinQuake/GLQuake.
Type concopy in the console and all that text is now on your clipboard and you can paste it somewhere, instead of the various hassle methods of using condump (if you use an engine with that) or using -condebug + qconsole.log.
Will be in the next incremental ProQuake 3.99 update (version m).
In console.c (adapted from FitzQuake's condump command)
Code:
/* ================ Con_Copy_f -- Baker -- adapted from Con_Dump ================ */ void Con_Copy_f (void) { char outstring[CON_TEXTSIZE]=""; int l, x; char *line; char buffer[1024]; // skip initial empty lines for (l = con_current - con_totallines + 1 ; l <= con_current ; l++) { line = con_text + (l%con_totallines)*con_linewidth; for (x=0 ; x<con_linewidth ; x++) if (line[x] != ' ') break; if (x != con_linewidth) break; } // write the remaining lines buffer[con_linewidth] = 0; for ( ; l <= con_current ; l++) { line = con_text + (l%con_totallines)*con_linewidth; strncpy (buffer, line, con_linewidth); for (x=con_linewidth-1 ; x>=0 ; x--) { if (buffer[x] == ' ') buffer[x] = 0; else break; } for (x=0; buffer[x]; x++) buffer[x] &= 0x7f; strcat(outstring, va("%s\r\n", buffer)); } Sys_CopyToClipboard(outstring); Con_Printf ("Copied console to clipboard\n"); }
Code:
Cmd_AddCommand ("concopy", Con_Copy_f); // Baker - copy console to clipboard
Code:
// copies given text to clipboard void Sys_CopyToClipboard(char *text) { char *clipText; HGLOBAL hglbCopy; if (!OpenClipboard(NULL)) return; if (!EmptyClipboard()) { CloseClipboard(); return; } if (!(hglbCopy = GlobalAlloc(GMEM_DDESHARE, strlen(text) + 1))) { CloseClipboard(); return; } if (!(clipText = GlobalLock(hglbCopy))) { CloseClipboard(); return; } strcpy((char *) clipText, text); GlobalUnlock(hglbCopy); SetClipboardData(CF_TEXT, hglbCopy); CloseClipboard(); }
Code:
void Sys_CopyToClipboard(char *);
Works fine in ProQuake and should be compatible with any engine very similar to WinQuake/GLQuake.
Comment