[FEATURE] toclipboard & fromclipboard

This commit is contained in:
2021-12-13 20:02:17 +01:00
parent 1618665124
commit 3979588f85
3 changed files with 36 additions and 1 deletions

View File

@@ -431,7 +431,7 @@ int rnd(int x) {
srand(x);
}*/
char str_tmp[256];
char str_tmp[1024];
const char* tostr(float val) {
return SDL_itoa(val, str_tmp, 10);
}
@@ -571,3 +571,22 @@ void filein(const char* str, uint16_t addr, uint16_t size) {
fread(&mem[addr], size, 1, f);
fclose(f);
}
void toclipboard(const char* str) {
SDL_SetClipboardText(str);
}
const char* fromclipboard() {
char* text = SDL_GetClipboardText();
int len = strlen(text);
if (len > 1023) {
len = 27;
SDL_memcpy(str_tmp, "ERROR! CLIPBOARD TOO LARGE", len);
} else {
SDL_memcpy(str_tmp, text, len);
}
str_tmp[len] = '\0';
SDL_free((void*)text);
return str_tmp;
}