OSDN Git Service

Unified SyncDlg and progressdlg log handle
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / ProgressDlg.cpp
index 577f149..f7ab402 100644 (file)
@@ -264,6 +264,7 @@ int CProgressDlg::FindPercentage(CString &log)
        return _ttol(log.Mid(s2,s1-s2));\r
 }\r
 \r
+#if 0\r
 void CProgressDlg::ParserCmdOutput(TCHAR ch)\r
 {\r
        TRACE(_T("%c"),ch);\r
@@ -315,6 +316,64 @@ void CProgressDlg::ParserCmdOutput(TCHAR ch)
        }\r
 \r
 }\r
+#endif\r
+\r
+void CProgressDlg::ParserCmdOutput(TCHAR ch)\r
+{\r
+       ParserCmdOutput(this->m_Log,this->m_Progress,this->m_LogText,ch);\r
+}\r
+void CProgressDlg::ParserCmdOutput(CRichEditCtrl &log,CProgressCtrl &progressctrl,CString &oneline, TCHAR ch)\r
+{\r
+       //TRACE(_T("%c"),ch);\r
+       TRACE(_T("%c"),ch);\r
+       if( ch == _T('\r') || ch == _T('\n'))\r
+       {\r
+               TRACE(_T("End Char %s \r\n"),ch==_T('\r')?_T("lf"):_T(""));\r
+               TRACE(_T("End Char %s \r\n"),ch==_T('\n')?_T("cr"):_T(""));\r
+\r
+               int lines=log.GetLineCount();\r
+\r
+               if(ch == _T('\r'))\r
+               {       \r
+                       int start=log.LineIndex(lines-1);\r
+                       int length=log.LineLength(lines-1);\r
+                       log.SetSel( start,start+length);\r
+                       log.ReplaceSel(oneline);\r
+\r
+               }else\r
+               {\r
+                       log.SetSel(log.GetWindowTextLength(),\r
+                                            log.GetWindowTextLength());\r
+                       log.ReplaceSel(CString(_T("\r\n"))+oneline);\r
+               }\r
+               \r
+               if( lines > 500 ) //limited log length\r
+               {\r
+                       int end=log.LineIndex(1);\r
+                       log.SetSel(0,end);\r
+                       log.ReplaceSel(_T(""));\r
+               }\r
+               log.LineScroll(log.GetLineCount());\r
+\r
+               int s1=oneline.Find(_T(':'));\r
+               int s2=oneline.Find(_T('%'));\r
+               if(s1>0 && s2>0)\r
+               {\r
+                       //this->m_CurrentWork.SetWindowTextW(m_LogText.Left(s1));\r
+                       int pos=FindPercentage(oneline);\r
+                       TRACE(_T("Pos %d\r\n"),pos);\r
+                       if(pos>0)\r
+                               progressctrl.SetPos(pos);\r
+               }\r
+\r
+               oneline=_T("");\r
+\r
+       }else\r
+       {\r
+               oneline+=ch;\r
+       }\r
+\r
+}\r
 void CProgressDlg::RemoveLastLine(CString &str)\r
 {\r
        int start;\r