[FEATURE] toclipboard & fromclipboard
This commit is contained in:
21
ascii.cpp
21
ascii.cpp
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user