Index: src/winhugs/RtfWindow.c
===================================================================
RCS file: /cvs/hugs98/src/winhugs/RtfWindow.c,v
retrieving revision 1.3
diff -u -r1.3 RtfWindow.c
--- src/winhugs/RtfWindow.c	7 Sep 2005 11:25:00 -0000	1.3
+++ src/winhugs/RtfWindow.c	7 Sep 2005 14:50:27 -0000
@@ -137,8 +137,34 @@
 	// we don't want to paste rich text, as that makes it look weird
 	// so send only plain text paste commands
 	if ((enp->msg == WM_PASTE) && !Disallow) {
+	    LPTSTR Buffer = NULL;
 	    Disallow = TRUE;
-	    SendMessage(hRTF, EM_PASTESPECIAL, CF_TEXT, (LPARAM) NULL);
+            if (IsClipboardFormatAvailable(CF_TEXT) &&
+		OpenClipboard(hThisWindow))
+	    {
+		HGLOBAL hGlb; 
+		LPTSTR str; 
+
+	        if ((hGlb = GetClipboardData(CF_TEXT)) != NULL &&
+		    (str = GlobalLock(hGlb)) != NULL)
+		{
+		    Buffer = strdup(str);
+		    GlobalUnlock(hGlb);
+		}
+		CloseClipboard();
+	    }
+
+	    if (Buffer != NULL)
+	    {
+		// strip trailing new line characters
+		int i = strlen(Buffer);
+		for (i = strlen(Buffer)-1;
+		    i >= 0 && (Buffer[i] == '\r' || Buffer[i] == '\n');
+		    i--)
+		    Buffer[i] = 0;
+		SendMessage(hRTF, EM_REPLACESEL, FALSE, (LPARAM) Buffer);
+		free(Buffer);
+	    }
 	}
 
 	SetWindowLong(hDlg, DWL_MSGRESULT, (Disallow ? 1 : 0));
