From 3a018d80cce16003ba15dc461a36699a4e5476a6 Mon Sep 17 00:00:00 2001 From: Wengier Date: Tue, 16 Nov 2021 04:08:27 -0500 Subject: [PATCH] fix linebraks when copy DBCS text --- CHANGELOG | 2 ++ src/gui/sdlmain.cpp | 73 ++++++++++++++++++++++++++------------------- src/ints/mouse.cpp | 8 ++++- 3 files changed, 52 insertions(+), 31 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f571f7279..f770579f8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -76,6 +76,8 @@ - Fixed possible crash with printing. (jamesbond3142) - Fixed possible freeze when shutting down Windows 9x after changing a CD image from the menu. (Wengier) + - Fixed linebreaks when copying text from a DBCS code + page in the TTF output. (Wengier) - Fixed TTF color issue with some DOS GUI programs by initializing the color scheme when with default COLORS= setting in EGA or VGA mode. (Wengier) diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 03d959ca8..d5eac6f49 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -9309,34 +9309,8 @@ void PasteClipboard(bool bPressed) { #endif #endif -#if defined(C_SDL2) || defined(MACOSX) -bool CodePageGuestToHostUTF8(char *d/*CROSS_LEN*/,const char *s/*CROSS_LEN*/); -void CopyClipboard(int all) { - uint16_t len=0; - char* text = (char *)(all==2?Mouse_GetSelected(0,0,currentWindowWidth-1-sdl.clip.x,currentWindowHeight-1-sdl.clip.y,(int)(currentWindowWidth-sdl.clip.x),(int)(currentWindowHeight-sdl.clip.y), &len):(all==1?Mouse_GetSelected(selscol, selsrow, selecol, selerow, -1, -1, &len):Mouse_GetSelected(mouse_start_x-sdl.clip.x,mouse_start_y-sdl.clip.y,mouse_end_x-sdl.clip.x,mouse_end_y-sdl.clip.y,sdl.clip.w,sdl.clip.h, &len))); - unsigned int k=0; - for (unsigned int i=0; i=r1&&(int)y<=r2) + if ((int)y>=r1&&(int)y<=r2) { for (unsigned int x = 0; x < ttf.cols; x++) if ((int)x>=c1&&(int)x<=c2&&curAC[rtl?ttf.cols-x-1:x].selected) { if ((int)x==c1&&c1>0&&curAC[rtl?ttf.cols-x-1:x].skipped&&!curAC[rtl?ttf.cols-x-2:x-1].selected&&curAC[rtl?ttf.cols-x-2:x-1].doublewide) { @@ -780,6 +780,12 @@ const char* Mouse_GetSelected(int x1, int y1, int x2, int y2, int w, int h, uint text[len++]=result; } } + while (len>0&&text[len-1]==32) text[--len]=0; + if (y