OSDN Git Service

[ 819219 ] Show only simple EOL char when no mixing EOL modes allowed
authorLaurent Ganier <laoran@users.sourceforge.net>
Thu, 9 Oct 2003 19:28:45 +0000 (19:28 +0000)
committerLaurent Ganier <laoran@users.sourceforge.net>
Thu, 9 Oct 2003 19:28:45 +0000 (19:28 +0000)
Src/MainFrm.cpp
Src/MainFrm.h
Src/MergeDoc.cpp
Src/editlib/ccrystaltextview.cpp
Src/editlib/ccrystaltextview.h
Src/readme.txt

index 0307cfd..9dad79c 100644 (file)
@@ -792,6 +792,9 @@ void CMainFrame::OnOptions()
 
                RebuildRegExpList();
 
+               // Update ViewWhitespace as it depends on m_bAllowMixedEol
+               mf->ApplyViewWhitespace();
+
                // make an attempt at rescanning any open diff sessions
                MergeDocList docs;
                GetAllMergeDocs(&docs);
@@ -1511,11 +1514,11 @@ void CMainFrame::addToMru(LPCTSTR szItem, LPCTSTR szRegSubKey, UINT nMaxItems)
        AfxGetApp()->WriteProfileInt(szRegSubKey, _T("Count"), cnt);
 }
 
-void CMainFrame::OnViewWhitespace() 
+/**
+ * @brief Apply tabs and eols settings to all merge documents
+ */
+void CMainFrame::ApplyViewWhitespace() 
 {
-       m_bViewWhitespace = !m_bViewWhitespace;
-       theApp.WriteProfileInt(_T("Settings"), _T("ViewWhitespace"), m_bViewWhitespace);
-
        MergeDocList mergedocs;
        GetAllMergeDocs(&mergedocs);
        while (!mergedocs.IsEmpty())
@@ -1528,26 +1531,34 @@ void CMainFrame::OnViewWhitespace()
                if (pLeft)
                {
                        pLeft->SetViewTabs(mf->m_bViewWhitespace);
-                       pLeft->SetViewEols(mf->m_bViewWhitespace);
+                       pLeft->SetViewEols(mf->m_bViewWhitespace, mf->m_bAllowMixedEol);
                }
                if (pRight)
                {
                        pRight->SetViewTabs(mf->m_bViewWhitespace);
-                       pRight->SetViewEols(mf->m_bViewWhitespace);
+                       pRight->SetViewEols(mf->m_bViewWhitespace, mf->m_bAllowMixedEol);
                }
                if (pLeftDetail)
                {
                        pLeftDetail->SetViewTabs(mf->m_bViewWhitespace);
-                       pLeftDetail->SetViewEols(mf->m_bViewWhitespace);
+                       pLeftDetail->SetViewEols(mf->m_bViewWhitespace, mf->m_bAllowMixedEol);
                }
                if (pRightDetail)
                {
                        pRightDetail->SetViewTabs(mf->m_bViewWhitespace);
-                       pRightDetail->SetViewEols(mf->m_bViewWhitespace);
+                       pRightDetail->SetViewEols(mf->m_bViewWhitespace, mf->m_bAllowMixedEol);
                }
        }
 }
 
+void CMainFrame::OnViewWhitespace() 
+{
+       m_bViewWhitespace = !m_bViewWhitespace;
+       theApp.WriteProfileInt(_T("Settings"), _T("ViewWhitespace"), m_bViewWhitespace);
+
+       ApplyViewWhitespace();
+}
+
 /// Enables View/View Whitespace menuitem when merge view is active
 void CMainFrame::OnUpdateViewWhitespace(CCmdUI* pCmdUI) 
 {
index e8faf69..296623a 100644 (file)
@@ -101,6 +101,7 @@ public:
        BOOL CheckSavePath(CString& strSavePath);
        BOOL SaveToVersionControl(CString& strSavePath);
        CString SetStatus(LPCTSTR status);
+       void ApplyViewWhitespace();
 
 // Overrides
        // ClassWizard generated virtual function overrides
index 6ef609d..d6e0af7 100644 (file)
@@ -2243,15 +2243,15 @@ BOOL CMergeDoc::OpenDocs(CString sLeftFile, CString sRightFile,
                pRight->SetTabSize(mf->m_nTabSize);
                pLeft->SetViewTabs(mf->m_bViewWhitespace);
                pRight->SetViewTabs(mf->m_bViewWhitespace);
-               pLeft->SetViewEols(mf->m_bViewWhitespace);
-               pRight->SetViewEols(mf->m_bViewWhitespace);
+               pLeft->SetViewEols(mf->m_bViewWhitespace, mf->m_bAllowMixedEol);
+               pRight->SetViewEols(mf->m_bViewWhitespace, mf->m_bAllowMixedEol);
 
                pLeftDetail->SetTabSize(mf->m_nTabSize);
                pRightDetail->SetTabSize(mf->m_nTabSize);
                pLeftDetail->SetViewTabs(mf->m_bViewWhitespace);
                pRightDetail->SetViewTabs(mf->m_bViewWhitespace);
-               pLeftDetail->SetViewEols(mf->m_bViewWhitespace);
-               pRightDetail->SetViewEols(mf->m_bViewWhitespace);
+               pLeftDetail->SetViewEols(mf->m_bViewWhitespace, mf->m_bAllowMixedEol);
+               pRightDetail->SetViewEols(mf->m_bViewWhitespace, mf->m_bAllowMixedEol);
 
                // Enable Backspace at beginning of line
                pLeft->SetDisableBSAtSOL(FALSE);
index 154c1c5..4a140d1 100644 (file)
@@ -111,6 +111,7 @@ static char THIS_FILE[] = __FILE__;
 #define SPACE_CHARACTER             _T('\xB7') // U+B7: MIDDLE DOT
 #define CR_CHARACTER                _T('\xA7') // U+A7: SECTION SIGN
 #define LF_CHARACTER                _T('\xB6') // U+B6: PILCROW SIGN
+#define ANY_EOL_CHARACTER           _T('\xA4') // U+A4: ?
 
 #define DEFAULT_PRINT_MARGIN        1000    //  10 millimeters
 
@@ -808,7 +809,7 @@ ExpandChars (LPCTSTR pszChars, int nOffset, int nCount, CString & line)
   LPTSTR pszBuf = line.GetBuffer(nLength + nTabCount * (nTabSize - 1) + 1);
   int nCurPos = 0;
 
-  if (nTabCount > 0 || m_bViewTabs)
+  if (nTabCount > 0 || m_bViewTabs || m_bViewEols)
     {
       for (i = 0; i < nLength; i++)
         {
@@ -826,19 +827,23 @@ ExpandChars (LPCTSTR pszChars, int nOffset, int nCount, CString & line)
                   nSpaces--;
                 }
             }
-          else
+          else  if (pszChars[i] == ' ' && m_bViewTabs)
+            pszBuf[nCurPos++] = SPACE_CHARACTER;
+          else if (pszChars[i] == '\r' || pszChars[i] == '\n')
             {
-              if (pszChars[i] == ' ' && m_bViewTabs)
-                pszBuf[nCurPos] = SPACE_CHARACTER;
-              else if (pszChars[i] == '\r' && m_bViewEols)
-                pszBuf[nCurPos] = CR_CHARACTER;
-              else if (pszChars[i] == '\n' && m_bViewEols)
-                pszBuf[nCurPos] = LF_CHARACTER;
-              else
-                pszBuf[nCurPos] = pszChars[i];
-
-              nCurPos++;
+              if (pszChars[i] == '\r' && m_bViewEols && m_bDistinguishEols)
+                pszBuf[nCurPos++] = CR_CHARACTER;
+              else if (pszChars[i] == '\n' && m_bViewEols && m_bDistinguishEols)
+                pszBuf[nCurPos++] = LF_CHARACTER;
+              else if (m_bViewEols)
+            {
+                  pszBuf[nCurPos++] = ANY_EOL_CHARACTER;
+                  // hide the second sign
+                  i = nLength-1;
+                }
             }
+              else
+            pszBuf[nCurPos++] = pszChars[i];
         }
     }
   else
@@ -4552,11 +4557,12 @@ SetViewTabs (BOOL bViewTabs)
 }
 
 void CCrystalTextView::
-SetViewEols (BOOL bViewEols)
+SetViewEols (BOOL bViewEols, BOOL bDistinguishEols)
 {
-  if (bViewEols != m_bViewEols)
+  if (bViewEols != m_bViewEols || bDistinguishEols != m_bDistinguishEols)
     {
       m_bViewEols = bViewEols;
+      m_bDistinguishEols = bDistinguishEols;
       if (::IsWindow (m_hWnd))
         Invalidate ();
     }
index 3851eb1..e2a895f 100644 (file)
@@ -93,6 +93,7 @@ private :
     //  Text attributes
     BOOL m_bViewTabs;
     BOOL m_bViewEols;
+    BOOL m_bDistinguishEols;
     BOOL m_bSelMargin;
     DWORD m_dwFlags;
 
@@ -615,7 +616,7 @@ public :
     void SetCRLFMode (int nCRLFMode);
     BOOL GetViewTabs ();
     void SetViewTabs (BOOL bViewTabs);
-    void SetViewEols (BOOL bViewEols);
+    void SetViewEols (BOOL bViewEols, BOOL bDistinguishEols);
     int GetTabSize ();
     void SetTabSize (int nTabSize);
     BOOL GetSelectionMargin ();
index c25f969..1b34af6 100644 (file)
@@ -1,3 +1,7 @@
+2003-10-09 Laoran
+ [ 819219 ] Show only simple EOL char when no mixing EOL modes allowed
+  WinMerge: MainFrm.cpp MainFrm.h MergeDoc.cpp ccrystaltextview.cpp ccrystaltextview.h
+
 2003-10-09 Perry
  Fix duplicate copy of IDS_LINE_STATUS_INFO (to IDS_LINE_STATUS_INFO_EOL) in most
   language files. Fix missing id ID_POPUP_COPYFROMOTHERSIDE in German file