diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-10 09:29:45 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-10 09:29:45 +0100 |
| commit | b84007b0bc5fe286c96c675f5c2c210cccbc0490 (patch) | |
| tree | eba0e84d3dd525e146153a5a318d577a42b519a9 /src/windows | |
| parent | cfbb40b1d08a110a3616a21224c2c13329d12e43 (diff) | |
set clipboard impl
Diffstat (limited to 'src/windows')
| -rw-r--r-- | src/windows/main_windows.cpp | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/src/windows/main_windows.cpp b/src/windows/main_windows.cpp index 090898a..c6db7a5 100644 --- a/src/windows/main_windows.cpp +++ b/src/windows/main_windows.cpp @@ -431,38 +431,4 @@ void ts_platform_open_file_in_folder(utf8_int8_t* file) { MultiByteToWideChar(CP_UTF8, 0, file, -1, convstr, MAX_INPUT_LENGTH); PathCchRemoveFileSpec(convstr, MAX_INPUT_LENGTH); ShellExecuteW(NULL, L"open", convstr, NULL, NULL, SW_SHOWDEFAULT); -} - -bool ts_platform_copy_to_clipboard(utf8_int8_t* str) { - HANDLE clipboard_data; - - wchar_t convstr[MAX_INPUT_LENGTH]; - memset(convstr, 0, sizeof(convstr)); - int result = MultiByteToWideChar(CP_UTF8, 0, str, -1, convstr, MAX_INPUT_LENGTH); - - size_t len = result; - size_t size = (len+1) * sizeof(wchar_t); - LPSTR dst; - - if (!OpenClipboard(NULL)) - return false; - - clipboard_data = GlobalAlloc(GMEM_MOVEABLE, size); - if (clipboard_data) - { - dst = (LPSTR)GlobalLock(clipboard_data); - memmove(dst, convstr, size); - dst[len*2] = 0; - GlobalUnlock(clipboard_data); - - SetClipboardData(CF_UNICODETEXT, clipboard_data); - } - else - { - CloseClipboard(); - return false; - } - - CloseClipboard(); - return true; }
\ No newline at end of file |
