mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-23 16:33:00 +02:00
local copy / paste support inside tpt for all platforms
This commit is contained in:
15
src/Misc.cpp
15
src/Misc.cpp
@@ -367,8 +367,13 @@ vector2d v2d_new(float x, float y)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char * clipboardtext = NULL;
|
||||||
void clipboard_push_text(char * text)
|
void clipboard_push_text(char * text)
|
||||||
{
|
{
|
||||||
|
if (clipboardtext)
|
||||||
|
delete clipboardtext;
|
||||||
|
clipboardtext = new char[strlen(text)+1];
|
||||||
|
strcpy(clipboardtext, text);
|
||||||
#ifdef MACOSX
|
#ifdef MACOSX
|
||||||
PasteboardRef newclipboard;
|
PasteboardRef newclipboard;
|
||||||
|
|
||||||
@@ -395,7 +400,7 @@ void clipboard_push_text(char * text)
|
|||||||
SetClipboardData(CF_TEXT, cbuffer);
|
SetClipboardData(CF_TEXT, cbuffer);
|
||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
}
|
}
|
||||||
#elif defined(LIN) && defined(SDL_VIDEO_DRIVER_X11)
|
#elif defined(LIN) && defined(SDL_VIDEO_DRIVER_X11) //Much of the code is missing, so it crashes if SDL_VIDEO_DRIVER_X11 is defined TODO: linux copy support
|
||||||
if (clipboard_text!=NULL) {
|
if (clipboard_text!=NULL) {
|
||||||
free(clipboard_text);
|
free(clipboard_text);
|
||||||
clipboard_text = NULL;
|
clipboard_text = NULL;
|
||||||
@@ -426,15 +431,17 @@ char * clipboard_pull_text()
|
|||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
if(glbuffer!=NULL){
|
if(glbuffer!=NULL){
|
||||||
return mystrdup(glbuffer);
|
return mystrdup(glbuffer);
|
||||||
} else {
|
}// else {
|
||||||
return mystrdup("");
|
// return mystrdup("");
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
#elif defined(LIN) && defined(SDL_VIDEO_DRIVER_X11)
|
#elif defined(LIN) && defined(SDL_VIDEO_DRIVER_X11)
|
||||||
printf("Not implemented: get text from clipboard\n");
|
printf("Not implemented: get text from clipboard\n");
|
||||||
#else
|
#else
|
||||||
printf("Not implemented: get text from clipboard\n");
|
printf("Not implemented: get text from clipboard\n");
|
||||||
#endif
|
#endif
|
||||||
|
if (clipboardtext)
|
||||||
|
return mystrdup(clipboardtext);
|
||||||
return mystrdup("");
|
return mystrdup("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user