1
0

Add clipboardSize

This commit is contained in:
otya128
2016-12-30 20:44:01 +09:00
parent 537c0c1f75
commit 2b0385676d

View File

@@ -1671,6 +1671,7 @@ class PetitComputer
}
}
int clipboardSize = 1048576;
wstring clipboard()
{
if(SDL_HasClipboardText())
@@ -1678,6 +1679,8 @@ class PetitComputer
char* cl = SDL_GetClipboardText();
string an = cast(string)(cl[0..core.stdc.string.strlen(cl)]);
auto ret = an.to!wstring;
if (ret.length > clipboardSize)
ret = ret[0..clipboardSize];
SDL_free(cl);
return ret;
}
@@ -1685,6 +1688,10 @@ class PetitComputer
}
void clipboard(wstring ws)
{
if (ws.length > clipboardSize)
{
throw new StringTooLong("CLIPBOARD");
}
SDL_SetClipboardText(ws.to!string.toStringz);
}