From aee638403d142cbbe5cc63d184ce6db35709dd56 Mon Sep 17 00:00:00 2001 From: Sup Yut Sum Date: Thu, 5 Jun 2014 21:26:10 +0800 Subject: [PATCH] Allow to replace with empty string, and disable replace textbox and buttons when they should Based on TortoiseSVN revision 25538, 25540 Signed-off-by: Sup Yut Sum --- src/TortoiseMerge/BaseView.h | 4 ++-- src/TortoiseMerge/FindDlg.cpp | 14 ++++++-------- src/TortoiseMerge/FindDlg.h | 1 + 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/TortoiseMerge/BaseView.h b/src/TortoiseMerge/BaseView.h index ae8f6b1ce..2aba1a881 100644 --- a/src/TortoiseMerge/BaseView.h +++ b/src/TortoiseMerge/BaseView.h @@ -83,8 +83,8 @@ public: // methods void GoToLine(int nNewLine, BOOL bAll = TRUE); void ScrollToChar(int nNewOffsetChar, BOOL bTrackScrollBar = TRUE); void ScrollAllToChar(int nNewOffsetChar, BOOL bTrackScrollBar = TRUE); - void SetReadonly(bool bReadonly = true) {m_bReadonly = bReadonly;} - void SetWritable(bool bWritable = true) {m_bReadonly = !bWritable;} + void SetReadonly(bool bReadonly = true) {m_bReadonly = bReadonly; if (m_pFindDialog) m_pFindDialog->SetReadonly(m_bReadonly); } + void SetWritable(bool bWritable = true) {m_bReadonly = !bWritable; if (m_pFindDialog) m_pFindDialog->SetReadonly(m_bReadonly); } void SetWritableIsChangable(bool bWritableIsChangable = true) {m_bReadonlyIsChangable = bWritableIsChangable;} void SetTarget(bool bTarget = true) {m_bTarget = bTarget;} bool IsReadonly() const {return m_bReadonly;} diff --git a/src/TortoiseMerge/FindDlg.cpp b/src/TortoiseMerge/FindDlg.cpp index 08047dd46..c16de5678 100644 --- a/src/TortoiseMerge/FindDlg.cpp +++ b/src/TortoiseMerge/FindDlg.cpp @@ -36,6 +36,7 @@ CFindDlg::CFindDlg(CWnd* pParent /*=NULL*/) , m_bSearchUp(FALSE) , m_FindMsg(0) , m_clrFindStatus(RGB(0, 0, 255)) + , m_bReadonly(false) , m_regMatchCase(L"Software\\TortoiseGitMerge\\FindMatchCase", FALSE) , m_regLimitToDiffs(L"Software\\TortoiseGitMerge\\FindLimitToDiffs", FALSE) , m_regWholeWord(L"Software\\TortoiseGitMerge\\FindWholeWord", FALSE) @@ -134,8 +135,8 @@ void CFindDlg::OnCbnEditchangeFindcombo() { UpdateData(); GetDlgItem(IDOK)->EnableWindow(!m_FindCombo.GetString().IsEmpty()); - GetDlgItem(IDC_REPLACE)->EnableWindow(!m_ReplaceCombo.GetString().IsEmpty()); - GetDlgItem(IDC_REPLACEALL)->EnableWindow(!m_ReplaceCombo.GetString().IsEmpty()); + GetDlgItem(IDC_REPLACE)->EnableWindow(!m_bReadonly && !m_FindCombo.GetString().IsEmpty()); + GetDlgItem(IDC_REPLACEALL)->EnableWindow(!m_bReadonly && !m_FindCombo.GetString().IsEmpty()); } void CFindDlg::OnBnClickedCount() @@ -183,9 +184,10 @@ void CFindDlg::SetStatusText(const CString& str, COLORREF color) void CFindDlg::SetReadonly(bool bReadonly) { + m_bReadonly = bReadonly; m_ReplaceCombo.EnableWindow(bReadonly ? FALSE : TRUE); - GetDlgItem(IDC_REPLACE)->EnableWindow(bReadonly ? FALSE : TRUE); - GetDlgItem(IDC_REPLACEALL)->EnableWindow(bReadonly ? FALSE : TRUE); + GetDlgItem(IDC_REPLACE)->EnableWindow(!m_bReadonly && !m_FindCombo.GetString().IsEmpty()); + GetDlgItem(IDC_REPLACEALL)->EnableWindow(!m_bReadonly && !m_FindCombo.GetString().IsEmpty()); } void CFindDlg::OnBnClickedReplace() @@ -198,8 +200,6 @@ void CFindDlg::OnBnClickedReplace() m_regLimitToDiffs = m_bLimitToDiffs; m_regWholeWord = m_bWholeWord; - if (m_ReplaceCombo.GetString().IsEmpty()) - return; m_bFindNext = true; if (m_pParent) m_pParent->SendMessage(m_FindMsg, FindType::Replace); @@ -218,8 +218,6 @@ void CFindDlg::OnBnClickedReplaceall() m_regLimitToDiffs = m_bLimitToDiffs; m_regWholeWord = m_bWholeWord; - if (m_ReplaceCombo.GetString().IsEmpty()) - return; m_bFindNext = true; if (m_pParent) m_pParent->SendMessage(m_FindMsg, FindType::ReplaceAll); diff --git a/src/TortoiseMerge/FindDlg.h b/src/TortoiseMerge/FindDlg.h index 1760b6f1f..0db7a1f3e 100644 --- a/src/TortoiseMerge/FindDlg.h +++ b/src/TortoiseMerge/FindDlg.h @@ -87,4 +87,5 @@ private: CRegDWORD m_regLimitToDiffs; CRegDWORD m_regWholeWord; COLORREF m_clrFindStatus; + bool m_bReadonly; }; -- 2.11.4.GIT