Richedit text mode

Duane Clark dclark at akamail.com
Sun Jul 7 11:26:29 CDT 2002


The richedit input stream can be either RTF or plain text, depending 
upon a flag with the EM_STREAMIN message. This patch basically bypasses 
all the token formatting when the stream is plain text. It fixes Actel 
Designer (FPGA design software).

I was rather surprised to see the use of global variables here, but I 
followed the pattern and added one more while cringing.

Changelog: Add richedit support for a plain text stream.

-------------- next part --------------
Index: dlls/richedit/reader.c
===================================================================
RCS file: /home/wine/wine/dlls/richedit/reader.c,v
retrieving revision 1.7
diff -u -r1.7 reader.c
--- dlls/richedit/reader.c	31 May 2002 23:25:51 -0000	1.7
+++ dlls/richedit/reader.c	7 Jul 2002 16:18:18 -0000
@@ -123,6 +123,7 @@
 int	rtfMajor;
 int	rtfMinor;
 int	rtfParam;
+int     rtfFormat;
 char	*rtfTextBuf = (char *) NULL;
 int	rtfTextLen;
 
@@ -540,9 +541,8 @@
 			(*p) ();	/* give read hook a look at token */
 
 		/* Silently discard newlines, carriage returns, nulls.  */
-		if (!(rtfClass == rtfText
-			&& (rtfMajor == '\n' || rtfMajor == '\r'
-						|| rtfMajor == '\0')))
+		if (!(rtfClass == rtfText && rtfFormat != SF_TEXT
+			&& (rtfMajor == '\r' || rtfMajor == '\n' || rtfMajor == '\0')))
 			break;
 	}
 	return (rtfClass);
@@ -604,6 +604,18 @@
 
     TRACE("\n");
 
+        if (rtfFormat == SF_TEXT) {
+            rtfMajor = GetChar ();
+            rtfMinor = rtfSC_nothing;
+            rtfParam = rtfNoParam;
+            rtfTextBuf[rtfTextLen = 0] = '\0';
+            if (rtfMajor == EOF)
+                rtfClass = rtfEOF;
+            else
+	        rtfClass = rtfText;
+	    return;
+	}
+	
 	/* first check for pushed token from RTFUngetToken() */
 
 	if (pushedClass >= 0)
Index: dlls/richedit/richedit.c
===================================================================
RCS file: /home/wine/wine/dlls/richedit/richedit.c,v
retrieving revision 1.20
diff -u -r1.20 richedit.c
--- dlls/richedit/richedit.c	31 May 2002 23:25:51 -0000	1.20
+++ dlls/richedit/richedit.c	7 Jul 2002 16:18:18 -0000
@@ -175,6 +175,7 @@
 
 	    /* setup the RTF parser */
 	    RTFSetEditStream(( EDITSTREAM*)lParam);
+	    rtfFormat = wParam&(SF_TEXT|SF_RTF);
 	    WriterInit();
 	    RTFInit ();
 	    BeginFile();
Index: dlls/richedit/text-writer.c
===================================================================
RCS file: /home/wine/wine/dlls/richedit/text-writer.c,v
retrieving revision 1.4
diff -u -r1.4 text-writer.c
--- dlls/richedit/text-writer.c	31 May 2002 23:25:51 -0000	1.4
+++ dlls/richedit/text-writer.c	7 Jul 2002 16:18:18 -0000
@@ -124,8 +124,10 @@
 char	buf[rtfBufSiz];
 
 	TRACE("\n");
-
-	if (rtfMinor != rtfSC_nothing)
+        
+	if (rtfFormat == SF_TEXT)
+	        PutLitChar (rtfMajor);
+	else if (rtfMinor != rtfSC_nothing)
 		PutStdChar (rtfMinor);
 	else
 	{
Index: dlls/richedit/rtf.h
===================================================================
RCS file: /home/wine/wine/dlls/richedit/rtf.h,v
retrieving revision 1.3
diff -u -r1.3 rtf.h
--- dlls/richedit/rtf.h	19 Dec 2000 04:53:20 -0000	1.3
+++ dlls/richedit/rtf.h	7 Jul 2002 16:18:19 -0000
@@ -432,6 +432,7 @@
 extern int	rtfMajor;		/* token major number */
 extern int	rtfMinor;		/* token minor number */
 extern int	rtfParam;		/* control symbol parameter */
+extern int	rtfFormat;		/* either SF_RTF or SF_TEXT */
 
 # ifdef THINK_C
 # define	rtfNoParam	(-32768)	/* 16-bit max. neg. value */


More information about the wine-patches mailing list