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

Modified Files:
        BareBonesEditor.cpp 
Log Message:
Don't wrap signature text

Index: BareBonesEditor.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/BareBonesEditor.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -b -u -2 -r1.16 -r1.17
--- BareBonesEditor.cpp 25 Sep 2003 15:13:08 -0000      1.16
+++ BareBonesEditor.cpp 26 Sep 2003 15:10:37 -0000      1.17
@@ -164,4 +164,6 @@
    size_t RFind(const String &where,wxChar what,size_t start) const;
    size_t FindLastNotOf(const String &where,wxChar what,size_t start) const;
+   void FindSignature();
+   bool PastSignature() { return m_from >= m_signature; }
 
    wxTextCtrl *m_control;
@@ -170,4 +172,6 @@
    int m_margin;
    String m_prefix;
+   int m_signature; // Line with signature separator
+   Profile *m_profile;
 };
 
@@ -246,10 +250,10 @@
 FormattedParagraph::FormattedParagraph(wxTextCtrl *control,
    BareBonesEditor *editor)
-   : m_control(control), m_from(0), m_to(0)
+   : m_control(control), m_from(0), m_to(0), m_profile(editor->GetProfile())
 {
-   m_margin = READ_CONFIG(editor->GetProfile(),MP_WRAPMARGIN);
+   m_margin = READ_CONFIG(m_profile,MP_WRAPMARGIN);
    if(m_margin <= 0)
       m_margin = 1;
-   m_prefix = READ_CONFIG_TEXT(editor->GetProfile(),MP_REPLY_MSGPREFIX);
+   m_prefix = READ_CONFIG_TEXT(m_profile,MP_REPLY_MSGPREFIX);
 }
 
@@ -281,10 +285,10 @@
 {
    String text = m_control->GetLineText(line);
-   const wxChar *p = text.c_str();
 
-   while ( wxIsalnum(*p) )
-      p++;
+   bool graph = false;
+   for(size_t each = 0; each < text.size(); ++each )
+      graph = graph || wxIsgraph(text[each]);
 
-   return *p == _T('\0');
+   return !graph;
 }
 
@@ -341,5 +345,7 @@
    if(!modified.empty() && modified[modified.size()-1] != _T('\n'))
       ++lineCount;
-   m_to = m_from+lineCount;
+   int shift = lineCount-(m_to-m_from);
+   m_to += shift;
+   m_signature += shift;
 }
 
@@ -388,5 +394,6 @@
 void FormattedParagraph::FormatAll()
 {
-   for(First(); !Empty(); Next())
+   FindSignature();
+   for(First(); !Empty() && !PastSignature(); Next())
       Format();
 }
@@ -394,5 +401,6 @@
 void FormattedParagraph::UnformatAll()
 {
-   for(First(); !Empty(); Next())
+   FindSignature();
+   for(First(); !Empty() && !PastSignature(); Next())
       Unformat();
 }
@@ -524,4 +532,20 @@
 }
 
+void FormattedParagraph::FindSignature()
+{
+   int count = m_control->GetNumberOfLines();
+
+   DetectSignature detector;
+   detector.Initialize(m_profile);
+   
+   for(m_signature = 0; m_signature < count; ++m_signature)
+   {
+      String line = m_control->GetLineText(m_signature);
+      line += '\n';
+      if( detector.StartsHere(line.c_str()) )
+         break;
+   }
+}
+
 // ----------------------------------------------------------------------------
 // wxBareBonesEditorNotebook
@@ -564,11 +588,11 @@
 
    buttonRow->Add(new wxButton(parent,Button_FormatParagraph,
-      _("Format Paragraph")),0,wxEXPAND);
+      _("Wrap Paragraph")),0,wxEXPAND);
    buttonRow->Add(new wxButton(parent,Button_FormatAll,
-      _("Format All")),0,wxEXPAND);
+      _("Wrap All")),0,wxEXPAND);
    buttonRow->Add(new wxButton(parent,Button_UnformatParagraph,
-      _("Unformat Paragraph")),0,wxEXPAND);
+      _("Unwrap Paragraph")),0,wxEXPAND);
    buttonRow->Add(new wxButton(parent,Button_UnformatAll,
-      _("Unformat All")),0,wxEXPAND);
+      _("Unwrap All")),0,wxEXPAND);
 
    return buttonRow;



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to