mirror of
https://github.com/joncampbell123/dosbox-x.git
synced 2025-10-15 03:48:24 +08:00
fix linebraks when copy DBCS text
This commit is contained in:
@@ -76,6 +76,8 @@
|
|||||||
- Fixed possible crash with printing. (jamesbond3142)
|
- Fixed possible crash with printing. (jamesbond3142)
|
||||||
- Fixed possible freeze when shutting down Windows 9x
|
- Fixed possible freeze when shutting down Windows 9x
|
||||||
after changing a CD image from the menu. (Wengier)
|
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
|
- Fixed TTF color issue with some DOS GUI programs by
|
||||||
initializing the color scheme when with default
|
initializing the color scheme when with default
|
||||||
COLORS= setting in EGA or VGA mode. (Wengier)
|
COLORS= setting in EGA or VGA mode. (Wengier)
|
||||||
|
@@ -9309,34 +9309,8 @@ void PasteClipboard(bool bPressed) {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(C_SDL2) || defined(MACOSX)
|
#ifdef WIN32
|
||||||
bool CodePageGuestToHostUTF8(char *d/*CROSS_LEN*/,const char *s/*CROSS_LEN*/);
|
void CopyClipboardW(int all) {
|
||||||
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<len; i++)
|
|
||||||
if (text[i]&&text[i]!=13)
|
|
||||||
text[k++]=text[i];
|
|
||||||
text[k]=0;
|
|
||||||
std::string result="";
|
|
||||||
std::istringstream iss(text);
|
|
||||||
char temp[4096];
|
|
||||||
for (std::string token; std::getline(iss, token); ) {
|
|
||||||
if (CodePageGuestToHostUTF8(temp,token.c_str()))
|
|
||||||
result+=temp+std::string(1, 10);
|
|
||||||
else
|
|
||||||
result+=token+std::string(1, 10);
|
|
||||||
}
|
|
||||||
if (result.size()&&result.back()==10) result.pop_back();
|
|
||||||
#if defined(C_SDL2)
|
|
||||||
SDL_SetClipboardText(result.c_str());
|
|
||||||
#else
|
|
||||||
SetClipboard(result);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#elif defined (WIN32)
|
|
||||||
void CopyClipboard(int all) {
|
|
||||||
uint16_t len=0;
|
uint16_t len=0;
|
||||||
const char* text = (char *)(all==2?Mouse_GetSelected(0,0,(int)(currentWindowWidth-1-sdl.clip.x),(int)(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)));
|
const char* text = (char *)(all==2?Mouse_GetSelected(0,0,(int)(currentWindowWidth-1-sdl.clip.x),(int)(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)));
|
||||||
if (OpenClipboard(NULL)&&EmptyClipboard()) {
|
if (OpenClipboard(NULL)&&EmptyClipboard()) {
|
||||||
@@ -9352,9 +9326,7 @@ void CopyClipboard(int all) {
|
|||||||
CloseClipboard();
|
CloseClipboard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
static BOOL WINAPI ConsoleEventHandler(DWORD event) {
|
static BOOL WINAPI ConsoleEventHandler(DWORD event) {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case CTRL_SHUTDOWN_EVENT:
|
case CTRL_SHUTDOWN_EVENT:
|
||||||
@@ -9370,6 +9342,47 @@ static BOOL WINAPI ConsoleEventHandler(DWORD event) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(C_SDL2) || defined(MACOSX)
|
||||||
|
bool CodePageGuestToHostUTF8(char *d/*CROSS_LEN*/,const char *s/*CROSS_LEN*/);
|
||||||
|
void CopyClipboard(int all) {
|
||||||
|
#ifdef WIN32
|
||||||
|
if (dos.loaded_codepage != 950 || !chinasea) {
|
||||||
|
CopyClipboardW(all);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
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)));
|
||||||
|
#ifndef WIN32
|
||||||
|
unsigned int k=0;
|
||||||
|
for (unsigned int i=0; i<len; i++)
|
||||||
|
if (text[i]&&text[i]!=13)
|
||||||
|
text[k++]=text[i];
|
||||||
|
text[k]=0;
|
||||||
|
#endif
|
||||||
|
std::string result="";
|
||||||
|
std::istringstream iss(text);
|
||||||
|
char temp[4096];
|
||||||
|
for (std::string token; std::getline(iss, token); ) {
|
||||||
|
if (CodePageGuestToHostUTF8(temp,token.c_str()))
|
||||||
|
result+=temp;
|
||||||
|
else
|
||||||
|
result+=token;
|
||||||
|
result+=std::string(1, 10);
|
||||||
|
}
|
||||||
|
if (result.size()&&result.back()==10) result.pop_back();
|
||||||
|
#if defined(C_SDL2)
|
||||||
|
SDL_SetClipboardText(result.c_str());
|
||||||
|
#else
|
||||||
|
SetClipboard(result);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#elif defined (WIN32)
|
||||||
|
void CopyClipboard(int all) {
|
||||||
|
CopyClipboardW(all);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void PasteClipStop(bool bPressed) {
|
void PasteClipStop(bool bPressed) {
|
||||||
if (!bPressed) return;
|
if (!bPressed) return;
|
||||||
strPasteBuffer = "";
|
strPasteBuffer = "";
|
||||||
|
@@ -766,7 +766,7 @@ const char* Mouse_GetSelected(int x1, int y1, int x2, int y2, int w, int h, uint
|
|||||||
if (ttfuse&&isDBCSCP()&&dbcs_sbcs&&!(c1==0&&c2==(int)(ttf.cols-1)&&r1==0&&r2==(int)(ttf.lins-1))) {
|
if (ttfuse&&isDBCSCP()&&dbcs_sbcs&&!(c1==0&&c2==(int)(ttf.cols-1)&&r1==0&&r2==(int)(ttf.lins-1))) {
|
||||||
ttf_cell *curAC = curAttrChar;
|
ttf_cell *curAC = curAttrChar;
|
||||||
for (unsigned int y = 0; y < ttf.lins; y++) {
|
for (unsigned int y = 0; y < ttf.lins; y++) {
|
||||||
if ((int)y>=r1&&(int)y<=r2)
|
if ((int)y>=r1&&(int)y<=r2) {
|
||||||
for (unsigned int x = 0; x < ttf.cols; x++)
|
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&&(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) {
|
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;
|
text[len++]=result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
while (len>0&&text[len-1]==32) text[--len]=0;
|
||||||
|
if (y<r2) {
|
||||||
|
text[len++]='\r';
|
||||||
|
text[len++]='\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
curAC += ttf.cols;
|
curAC += ttf.cols;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
Reference in New Issue
Block a user