From: Frank Li Date: Thu, 29 Oct 2009 14:06:06 +0000 (+0800) Subject: Unified SyncDlg and progressdlg log handle X-Git-Url: http://git.sourceforge.jp/view?p=tortoisegit%2FTortoiseGitJp.git;a=commitdiff_plain;h=e4793ce6ecd905c65de28c4005734fcedbc063f1 Unified SyncDlg and progressdlg log handle Signed-off-by: Frank Li --- diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index 03e0c27..f3a4f51 100644 Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ diff --git a/src/TortoiseProc/ProgressDlg.cpp b/src/TortoiseProc/ProgressDlg.cpp index 577f149..f7ab402 100644 --- a/src/TortoiseProc/ProgressDlg.cpp +++ b/src/TortoiseProc/ProgressDlg.cpp @@ -264,6 +264,7 @@ int CProgressDlg::FindPercentage(CString &log) return _ttol(log.Mid(s2,s1-s2)); } +#if 0 void CProgressDlg::ParserCmdOutput(TCHAR ch) { TRACE(_T("%c"),ch); @@ -315,6 +316,64 @@ void CProgressDlg::ParserCmdOutput(TCHAR ch) } } +#endif + +void CProgressDlg::ParserCmdOutput(TCHAR ch) +{ + ParserCmdOutput(this->m_Log,this->m_Progress,this->m_LogText,ch); +} +void CProgressDlg::ParserCmdOutput(CRichEditCtrl &log,CProgressCtrl &progressctrl,CString &oneline, TCHAR ch) +{ + //TRACE(_T("%c"),ch); + TRACE(_T("%c"),ch); + if( ch == _T('\r') || ch == _T('\n')) + { + TRACE(_T("End Char %s \r\n"),ch==_T('\r')?_T("lf"):_T("")); + TRACE(_T("End Char %s \r\n"),ch==_T('\n')?_T("cr"):_T("")); + + int lines=log.GetLineCount(); + + if(ch == _T('\r')) + { + int start=log.LineIndex(lines-1); + int length=log.LineLength(lines-1); + log.SetSel( start,start+length); + log.ReplaceSel(oneline); + + }else + { + log.SetSel(log.GetWindowTextLength(), + log.GetWindowTextLength()); + log.ReplaceSel(CString(_T("\r\n"))+oneline); + } + + if( lines > 500 ) //limited log length + { + int end=log.LineIndex(1); + log.SetSel(0,end); + log.ReplaceSel(_T("")); + } + log.LineScroll(log.GetLineCount()); + + int s1=oneline.Find(_T(':')); + int s2=oneline.Find(_T('%')); + if(s1>0 && s2>0) + { + //this->m_CurrentWork.SetWindowTextW(m_LogText.Left(s1)); + int pos=FindPercentage(oneline); + TRACE(_T("Pos %d\r\n"),pos); + if(pos>0) + progressctrl.SetPos(pos); + } + + oneline=_T(""); + + }else + { + oneline+=ch; + } + +} void CProgressDlg::RemoveLastLine(CString &str) { int start; diff --git a/src/TortoiseProc/ProgressDlg.h b/src/TortoiseProc/ProgressDlg.h index 4941958..7c4f1ab 100644 --- a/src/TortoiseProc/ProgressDlg.h +++ b/src/TortoiseProc/ProgressDlg.h @@ -28,7 +28,7 @@ public: CProgressCtrl m_Progress; - CEdit m_Log; + CRichEditCtrl m_Log; CString m_Title; CAnimateCtrl m_Animate; CStatic m_CurrentWork; @@ -49,7 +49,6 @@ protected: UINT ProgressThread(); void ParserCmdOutput(TCHAR ch); - void RemoveLastLine(CString &str); LRESULT CProgressDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam); @@ -66,6 +65,8 @@ public: //Share with Sync Dailog static int FindPercentage(CString &log); + static void ParserCmdOutput(CRichEditCtrl &log,CProgressCtrl &progressctrl,CString &oneline, TCHAR ch); + static UINT RunCmdList(CWnd *pWnd,std::vector &cmdlist,bool bShowCommand,CString *pfilename,bool *bAbort,std::vector *pdata=NULL); afx_msg void OnBnClickedOk(); diff --git a/src/TortoiseProc/SyncDlg.cpp b/src/TortoiseProc/SyncDlg.cpp index 53624d9..3869925 100644 --- a/src/TortoiseProc/SyncDlg.cpp +++ b/src/TortoiseProc/SyncDlg.cpp @@ -848,47 +848,7 @@ LRESULT CSyncDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam) void CSyncDlg::ParserCmdOutput(TCHAR ch) { - //TRACE(_T("%c"),ch); - int linenum; - int index; - linenum = this->m_ctrlCmdOut.GetLineCount(); - - if( ch == _T('\r') ) - { - if(linenum>0) - m_CmdOutCurrentPos = this->m_ctrlCmdOut.LineIndex(linenum-1); - else - m_CmdOutCurrentPos = 0; - - //TRACE(_T("line %d - %d\n"),index,m_ctrlCmdOut.GetTextLength()); - }else - m_CmdOutCurrentPos++; - - this->m_ctrlCmdOut.SetSel(m_CmdOutCurrentPos,m_CmdOutCurrentPos+1); - - if( ch != _T('\r') ) - this->m_ctrlCmdOut.ReplaceSel(CString(ch)); - - int firstline = m_ctrlCmdOut.GetFirstVisibleLine(); - if( linenum - firstline > 4 ) - this->m_ctrlCmdOut.LineScroll(linenum - firstline -4); - - if( ch == _T('\r') || ch == _T('\n') ) - { - int s1=m_LogText.Find(_T(':')); - int s2=m_LogText.Find(_T('%')); - if(s1>0 && s2>0) - { - // this->m_CurrentWork.SetWindowTextW(m_LogText.Left(s1)); - int pos=CProgressDlg::FindPercentage(m_LogText); - TRACE(_T("Pos %d\r\n"),pos); - if(pos>0) - this->m_ctrlProgress.SetPos(pos); - } - m_LogText=_T(""); - } - m_LogText+=ch; - + CProgressDlg::ParserCmdOutput(m_ctrlCmdOut,m_ctrlProgress,m_LogText,ch); } void CSyncDlg::OnBnClickedButtonCommit() {