mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-01 00:21:43 +00:00
- use the Unicode version of Windows's clipboard functions.
This commit is contained in:
parent
b4d96aaef9
commit
8018ebfab5
1 changed files with 15 additions and 21 deletions
|
@ -860,13 +860,14 @@ void I_PutInClipboard (const char *str)
|
||||||
return;
|
return;
|
||||||
EmptyClipboard ();
|
EmptyClipboard ();
|
||||||
|
|
||||||
HGLOBAL cliphandle = GlobalAlloc (GMEM_DDESHARE, strlen (str) + 1);
|
auto wstr = WideString(str);
|
||||||
|
HGLOBAL cliphandle = GlobalAlloc (GMEM_DDESHARE, wstr.length() * 2 + 2);
|
||||||
if (cliphandle != NULL)
|
if (cliphandle != NULL)
|
||||||
{
|
{
|
||||||
char *ptr = (char *)GlobalLock (cliphandle);
|
wchar_t *ptr = (wchar_t *)GlobalLock (cliphandle);
|
||||||
strcpy (ptr, str);
|
wcscpy (ptr, wstr.c_str());
|
||||||
GlobalUnlock (cliphandle);
|
GlobalUnlock (cliphandle);
|
||||||
SetClipboardData (CF_TEXT, cliphandle);
|
SetClipboardData (CF_UNICODETEXT, cliphandle);
|
||||||
}
|
}
|
||||||
CloseClipboard ();
|
CloseClipboard ();
|
||||||
}
|
}
|
||||||
|
@ -875,28 +876,21 @@ FString I_GetFromClipboard (bool return_nothing)
|
||||||
{
|
{
|
||||||
FString retstr;
|
FString retstr;
|
||||||
HGLOBAL cliphandle;
|
HGLOBAL cliphandle;
|
||||||
char *clipstr;
|
wchar_t *clipstr;
|
||||||
char *nlstr;
|
|
||||||
|
|
||||||
if (return_nothing || !IsClipboardFormatAvailable (CF_TEXT) || !OpenClipboard (Window))
|
if (return_nothing || !IsClipboardFormatAvailable (CF_UNICODETEXT) || !OpenClipboard (Window))
|
||||||
return retstr;
|
return retstr;
|
||||||
|
|
||||||
cliphandle = GetClipboardData (CF_TEXT);
|
cliphandle = GetClipboardData (CF_UNICODETEXT);
|
||||||
if (cliphandle != NULL)
|
if (cliphandle != nullptr)
|
||||||
{
|
{
|
||||||
clipstr = (char *)GlobalLock (cliphandle);
|
clipstr = (wchar_t *)GlobalLock (cliphandle);
|
||||||
if (clipstr != NULL)
|
if (clipstr != nullptr)
|
||||||
{
|
{
|
||||||
// Convert CR-LF pairs to just LF while copying to the FString
|
// Convert CR-LF pairs to just LF.
|
||||||
for (nlstr = clipstr; *nlstr != '\0'; ++nlstr)
|
retstr = clipstr;
|
||||||
{
|
GlobalUnlock(clipstr);
|
||||||
if (nlstr[0] == '\r' && nlstr[1] == '\n')
|
retstr.Substitute("\r\n", "\n");
|
||||||
{
|
|
||||||
nlstr++;
|
|
||||||
}
|
|
||||||
retstr += *nlstr;
|
|
||||||
}
|
|
||||||
GlobalUnlock (clipstr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue