@@ -387,93 +387,11 @@ uint16_t cpMap_PC98[256] = {
387387 0x0020 , 0x0020 , 0x0020 , 0x0020 , 0x005C , 0x0020 , 0x0020 , 0x0020 // 0xF8-0xFF 0xFC = Backslash
388388};
389389
390+ bool getClipboard ();
390391bool lastwrite = false ;
391- uint8_t *clipAscii = NULL ;
392- uint32_t clipSize = 0 , cPointer = 0 , fPointer ;
393-
394- #if defined(WIN32)
395- bool CodePageHostToGuestUTF16 (char *d/* CROSS_LEN*/ ,const uint16_t *s/* CROSS_LEN*/ );
396- bool Unicode2Ascii (const uint16_t * unicode) {
397- int memNeeded = 0 ;
398- char temp[4096 ];
399- bool ret=false ;
400- morelen=true ;
401- if (CodePageHostToGuestUTF16 (temp,unicode) && (clipAscii = (uint8_t *)malloc (strlen (temp)+1 ))) {
402- morelen=false ;
403- ret=true ;
404- strcpy ((char *)clipAscii, temp);
405- memNeeded = strlen (temp);
406- } else {
407- morelen=false ;
408- int memNeeded = WideCharToMultiByte (dos.loaded_codepage ==808 ?866 :(dos.loaded_codepage ==872 ?855 :(dos.loaded_codepage ==951 ?950 :dos.loaded_codepage )), WC_NO_BEST_FIT_CHARS, (LPCWSTR)unicode, -1 , NULL , 0 , " \x07 " , NULL );
409- if (memNeeded <= 1 ) // Includes trailing null
410- return false ;
411- if (!(clipAscii = (uint8_t *)malloc (memNeeded)))
412- return false ;
413- // Untranslated characters will be set to 0x07 (BEL), and later stripped
414- if (WideCharToMultiByte (dos.loaded_codepage ==808 ?866 :(dos.loaded_codepage ==872 ?855 :(dos.loaded_codepage ==951 ?950 :dos.loaded_codepage )), WC_NO_BEST_FIT_CHARS, (LPCWSTR)unicode, -1 , (LPSTR)clipAscii, memNeeded, " \x07 " , NULL ) != memNeeded) { // Can't actually happen of course
415- free (clipAscii);
416- clipAscii = NULL ;
417- return false ;
418- }
419- memNeeded--; // Don't include trailing null
420- }
421- for (int i = 0 ; i < memNeeded; i++)
422- if (clipAscii[i] > 31 || clipAscii[i] == 9 || clipAscii[i] == 10 || clipAscii[i] == 13 // Space and up, or TAB, CR/LF allowed (others make no sense when pasting)
423- || (dos.loaded_codepage == 932 && (TTF_using () || IS_JEGA_ARCH || showdbcs)
424- #if defined(USE_TTF)
425- && halfwidthkana
426- #endif
427- && ((IS_JEGA_ARCH && clipAscii[i] && clipAscii[i] < 32 ) || (!IS_PC98_ARCH && !IS_JEGA_ARCH && lowboxdrawmap.find (clipAscii[i])!=lowboxdrawmap.end ()))))
428- clipAscii[clipSize++] = clipAscii[i];
429- return ret; // clipAscii dould be downsized, but of no real interest
430- }
431- #else
432- typedef char host_cnv_char_t ;
433- host_cnv_char_t *CodePageGuestToHost (const char *s);
434- #endif
435-
436- bool swapad=true ;
437- extern std::string strPasteBuffer;
438- void PasteClipboard (bool bPressed);
439- bool getClipboard () {
440- if (clipAscii) {
441- free (clipAscii);
442- clipAscii = NULL ;
443- }
444- #if defined(WIN32)
445- clipSize = 0 ;
446- if (OpenClipboard (NULL )) {
447- if (HANDLE cbText = GetClipboardData (CF_UNICODETEXT)) {
448- uint16_t *unicode = (uint16_t *)GlobalLock (cbText);
449- Unicode2Ascii (unicode);
450- GlobalUnlock (cbText);
451- }
452- CloseClipboard ();
453- }
454- #else
455- swapad=false ;
456- PasteClipboard (true );
457- swapad=true ;
458- clipSize = 0 ;
459- unsigned int extra = 0 ;
460- unsigned char head, last=13 ;
461- for (size_t i=0 ; i<strPasteBuffer.length (); i++) if (strPasteBuffer[i]==10 ||strPasteBuffer[i]==13 ) extra++;
462- clipAscii = (uint8_t *)malloc (strPasteBuffer.length () + extra);
463- if (clipAscii)
464- while (strPasteBuffer.length ()) {
465- head = strPasteBuffer[0 ];
466- if (head == 10 && last != 13 ) clipAscii[clipSize++] = 13 ;
467- if (head > 31 || head == 9 || head == 10 || head == 13 )
468- clipAscii[clipSize++] = head;
469- if (head == 13 && (strPasteBuffer.length () < 2 || strPasteBuffer[1 ] != 10 )) clipAscii[clipSize++] = 10 ;
470- strPasteBuffer = strPasteBuffer.substr (1 , strPasteBuffer.length ());
471- last = head;
472- }
473- #endif
474- return clipSize != 0 ;
475- }
476-
392+ uint32_t cPointer = 0 , fPointer ;
393+ extern uint32_t clipSize;
394+ extern uint8_t *clipAscii;
477395class device_CLIP : public DOS_Device {
478396private:
479397 char tmpAscii[20 ];
0 commit comments