diff options
author | RadAd <adamgates84+github@gmail.com> | 2019-05-27 16:42:50 +1000 |
---|---|---|
committer | RadAd <adamgates84+github@gmail.com> | 2019-05-27 16:42:50 +1000 |
commit | 8e068a499f2445266cc9f0790f6aa1e789a528b2 (patch) | |
tree | 6505d575cc083a8a11591a5fdcf45a6082ba0fb0 | |
parent | 9469b59d6d0cdf80afbf0fbd3d5025b1b238601a (diff) | |
download | RadTerminal-8e068a499f2445266cc9f0790f6aa1e789a528b2.tar.gz RadTerminal-8e068a499f2445266cc9f0790f6aa1e789a528b2.zip |
Create tsm_vte_paste
-rw-r--r-- | RadTerminal.cpp | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/RadTerminal.cpp b/RadTerminal.cpp index cae51c1..140b363 100644 --- a/RadTerminal.cpp +++ b/RadTerminal.cpp @@ -346,6 +346,26 @@ void tsm_vte_write(struct tsm_vte *vte, //FlushFileBuffers(hInput); } +void tsm_vte_paste(struct tsm_vte *vte, + LPCTSTR lptstr) +{ + const uint32_t keysym = XKB_KEY_NoSymbol; + + while (*lptstr != '\0') + { +#ifdef _UNICODE + uint32_t ascii = 0; + uint32_t unicode = *lptstr; +#else + uint32_t ascii = *lptstr; + uint32_t unicode = 0; +#endif + unsigned int mods = 0; // TODO Should capital letters be faked with a Shift? + tsm_vte_handle_keyboard(vte, keysym, ascii, mods, unicode); + ++lptstr; + } +} + bool tsm_vte_read(struct tsm_vte *vte, HANDLE hOutput) { DWORD avail = 0; @@ -509,19 +529,15 @@ int ActionPasteFromClipboard(HWND hWnd) { while (!OpenClipboard(hWnd)) ; +#ifdef _UNICODE + HANDLE hData = GetClipboardData(CF_UNICODETEXT); +#else HANDLE hData = GetClipboardData(CF_TEXT); +#endif if (hData != NULL) { - LPCSTR lptstr = (LPCSTR) GlobalLock(hData); - while (*lptstr != '\0') - { - uint32_t keysym = XKB_KEY_NoSymbol; - uint32_t ascii = *lptstr; - uint32_t unicode = ascii; - unsigned int mods = 0; // TODO Should capital letters be faked with a Shift? - tsm_vte_handle_keyboard(data->vte, keysym, ascii, mods, unicode); - ++lptstr; - } + LPCTSTR lptstr = (LPCTSTR) GlobalLock(hData); + tsm_vte_paste(data->vte, lptstr); GlobalUnlock(hData); } CHECK_ONLY(CloseClipboard()); @@ -1064,22 +1080,8 @@ void RadTerminalWindowOnDropFiles(HWND hWnd, HDROP hDrop) const uint32_t keysym = XKB_KEY_NoSymbol; if (i != 0) - tsm_vte_handle_keyboard(data->vte, keysym, ' ', 0, L' '); - - LPCTSTR lptstr = buf; - while (*lptstr != '\0') - { -#ifdef _UNICODE - uint32_t ascii = 0; - uint32_t unicode = *lptstr; -#else - uint32_t ascii = *lptstr; - uint32_t unicode = 0; -#endif - unsigned int mods = 0; // TODO Should capital letters be faked with a Shift? - tsm_vte_handle_keyboard(data->vte, keysym, ascii, mods, unicode); - ++lptstr; - } + tsm_vte_paste(data->vte, _T(" ")); + tsm_vte_paste(data->vte, buf); } DragFinish(hDrop); } |