From: Laurent Ganier Date: Thu, 9 Oct 2003 19:28:45 +0000 (+0000) Subject: [ 819219 ] Show only simple EOL char when no mixing EOL modes allowed X-Git-Tag: 2.16.5~7699 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5e3e3f69c07017a99e51929062cdc87b8f003ce1;p=winmerge-jp%2Fwinmerge-jp.git [ 819219 ] Show only simple EOL char when no mixing EOL modes allowed --- diff --git a/Src/MainFrm.cpp b/Src/MainFrm.cpp index 0307cfd5c..9dad79c65 100644 --- a/Src/MainFrm.cpp +++ b/Src/MainFrm.cpp @@ -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) { diff --git a/Src/MainFrm.h b/Src/MainFrm.h index e8faf69de..296623af0 100644 --- a/Src/MainFrm.h +++ b/Src/MainFrm.h @@ -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 diff --git a/Src/MergeDoc.cpp b/Src/MergeDoc.cpp index 6ef609d03..d6e0af7d5 100644 --- a/Src/MergeDoc.cpp +++ b/Src/MergeDoc.cpp @@ -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); diff --git a/Src/editlib/ccrystaltextview.cpp b/Src/editlib/ccrystaltextview.cpp index 154c1c593..4a140d18d 100644 --- a/Src/editlib/ccrystaltextview.cpp +++ b/Src/editlib/ccrystaltextview.cpp @@ -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 (); } diff --git a/Src/editlib/ccrystaltextview.h b/Src/editlib/ccrystaltextview.h index 3851eb1ee..e2a895f72 100644 --- a/Src/editlib/ccrystaltextview.h +++ b/Src/editlib/ccrystaltextview.h @@ -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 (); diff --git a/Src/readme.txt b/Src/readme.txt index c25f969bf..1b34af688 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -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