Update of /cvsroot/mahogany/M/src/modules
In directory usw-pr-cvs1:/tmp/cvs-serv23158/src/modules

Modified Files:
        HtmlViewer.cpp 
Log Message:
fix the wrapping problem in the HTML viewer body

Index: HtmlViewer.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/HtmlViewer.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -b -u -2 -r1.36 -r1.37
--- HtmlViewer.cpp      3 May 2002 19:06:42 -0000       1.36
+++ HtmlViewer.cpp      4 Jul 2002 14:37:14 -0000       1.37
@@ -47,4 +47,15 @@
 
 // ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+// the possible values of MakeHtmlSafe() second parameter
+enum HtmlSpaceMode
+{
+   HtmlSpace_DontBreak,
+   HtmlSpace_Keep
+};
+
+// ----------------------------------------------------------------------------
 // private functions
 // ----------------------------------------------------------------------------
@@ -54,5 +65,6 @@
 
 // filter out special HTML characters from the text
-static wxString MakeHtmlSafe(const wxString& text);
+static wxString MakeHtmlSafe(const wxString& text,
+                             HtmlSpaceMode htmlSpaceMode = HtmlSpace_DontBreak);
 
 // ----------------------------------------------------------------------------
@@ -581,5 +593,5 @@
 }
 
-static wxString MakeHtmlSafe(const wxString& text)
+static wxString MakeHtmlSafe(const wxString& text, HtmlSpaceMode htmlSpaceMode)
 {
    wxString textSafe;
@@ -606,10 +618,6 @@
             break;
 
-         case ' ':
-            textSafe += " ";
-            break;
-
          case '\t':
-            // we hardcode the tab width to 8
+            // we hardcode the tab width to 8 spaces
             textSafe += "        ";
             break;
@@ -623,4 +631,13 @@
             break;
 
+         case ' ':
+            // replace the spaces with non breaking ones if necessary
+            if ( htmlSpaceMode == HtmlSpace_DontBreak )
+            {
+               textSafe += " ";
+               break;
+            }
+            //else: fall through
+
          default:
             textSafe += *p;
@@ -863,5 +880,5 @@
    FontColourChanger colChanger(style.GetTextColour(), m_htmlText);
 
-   m_htmlText += MakeHtmlSafe(text);
+   m_htmlText += MakeHtmlSafe(text, HtmlSpace_Keep);
 }
 
@@ -869,5 +886,5 @@
 {
    // URLs may contain special characters which must be replaced by HTML
-   // entities (i.e. '&' -> "&") so use MakeHtmlSafe()
+   // entities (i.e. '&' -> "&") so use MakeHtmlSafe() to filter them
    m_htmlText << "<a href=\"" << MakeHtmlSafe(url) << "\">"
               << MakeHtmlSafe(text)



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Caffeinated soap. No kidding.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to