From 2b0385676d21721dfb472ce0b8458e9943c5c364 Mon Sep 17 00:00:00 2001 From: otya128 Date: Fri, 30 Dec 2016 20:44:01 +0900 Subject: [PATCH] Add clipboardSize --- SMILEBASIC/petitcomputer.d | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index a0e086c..182c6ca 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -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); }