Fix copying of WB Chat Window contents
[xboard.git] / winboard / wchat.c
index e762b19..b02e00e 100644 (file)
@@ -208,7 +208,7 @@ LRESULT CALLBACK ChatProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
                sprintf(buf, "whisper %s\n", mess); // WHISPER box uses "whisper" to send\r
            else {\r
                if(!atoi(chatPartner[partner])) {\r
-                   sprintf(buf, "> %s\n", mess); // echo only tells to handle, not channel\r
+                   sprintf(buf, "> %s\r\n", mess); // echo only tells to handle, not channel\r
                InsertIntoMemo(hDlg, buf);\r
                sprintf(buf, "xtell %s %s\n", chatPartner[partner], mess);\r
                } else\r
@@ -256,11 +256,9 @@ void ChatPopUp(char *icsHandle)
   FARPROC lpProc;\r
   int i, partner = -1;\r
   \r
-  if(chatCount >= MAX_CHAT) return;\r
-\r
   CheckMenuItem(GetMenu(hwndMain), IDM_NewChat, MF_CHECKED);\r
   for(i=0; i<MAX_CHAT; i++) if(chatHandle[i] == NULL) { partner = i; break; }\r
-  if(partner == -1) { DisplayError("No chat box available", 0); return; }\r
+  if(partner == -1) { DisplayError("You first have to close a Chat Box\nbefore you can open a new one", 0); return; }\r
   if(icsHandle) // [HGM] clickbox set handle in advance\r
        strcpy(chatPartner[partner], icsHandle);\r
   else chatPartner[partner][0] = NULLCHAR;\r
@@ -289,5 +287,7 @@ void OutputChatMessage(int partner, char *text)
 {\r
        if(!chatHandle[partner]) return;\r
 \r
+       int n = strlen(text);\r
+       text[n+1] = 0; text[n] = '\n'; text[n-1] = '\r'; // Needs CR to not lose line breaks on copy-paste\r
        InsertIntoMemo(chatHandle[partner], text);\r
 }\r