OSDN Git Service

Unified SyncDlg and progressdlg log handle
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / ProgressDlg.cpp
index 248d9dd..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
@@ -272,26 +273,28 @@ void CProgressDlg::ParserCmdOutput(TCHAR ch)
                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
-               CString text;\r
-               m_Log.GetWindowTextW(text);\r
-               int count=0;\r
-               for( int i=0;i<text.GetLength();i++)\r
-               {\r
-                       if(text[i]==_T('\n'))\r
-                               count++;\r
-               }\r
-               if(count > 500)\r
-               {\r
-                       int start=text.Find(_T('\n'),0);\r
-                       text = text.Mid(start+1);\r
-               }\r
+               int lines=m_Log.GetLineCount();\r
+\r
                if(ch == _T('\r'))\r
+               {       \r
+                       int start=m_Log.LineIndex(lines-1);\r
+                       int length=m_Log.LineLength(lines-1);\r
+                       m_Log.SetSel( start,start+length);\r
+                       m_Log.ReplaceSel(m_LogText);\r
+\r
+               }else\r
                {\r
-                       RemoveLastLine(text);\r
+                       m_Log.SetSel(m_Log.GetWindowTextLength(),\r
+                                            m_Log.GetWindowTextLength());\r
+                       m_Log.ReplaceSel(CString(_T("\r\n"))+m_LogText);\r
                }\r
-               text+=_T("\r\n")+m_LogText;\r
-               m_Log.SetWindowTextW(text);\r
                \r
+               if( lines > 500 ) //limited log length\r
+               {\r
+                       int end=m_Log.LineIndex(1);\r
+                       m_Log.SetSel(0,end);\r
+                       m_Log.ReplaceSel(_T(""));\r
+               }\r
                m_Log.LineScroll(m_Log.GetLineCount());\r
 \r
                int s1=m_LogText.Find(_T(':'));\r
@@ -313,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