OSDN Git Service

SyncDlg rewrite output text handle
authorFrank Li <lznuaa@gmail.com>
Thu, 23 Jul 2009 14:20:37 +0000 (22:20 +0800)
committerFrank Li <lznuaa@gmail.com>
Thu, 23 Jul 2009 14:20:37 +0000 (22:20 +0800)
src/TortoiseProc/SyncDlg.cpp

index 1522fe4..9395a40 100644 (file)
@@ -433,47 +433,40 @@ LRESULT CSyncDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam)
 void CSyncDlg::ParserCmdOutput(TCHAR ch)\r
 {\r
        TRACE(_T("%c"),ch);\r
 void CSyncDlg::ParserCmdOutput(TCHAR ch)\r
 {\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
+       int linenum;\r
+       int index;\r
 \r
 \r
-               int linenum = this->m_ctrlCmdOut.GetLineCount();\r
-               int index ;\r
-               if(ch == _T('\r'))\r
-               {\r
+       if( ch == _T('\r') )\r
+       {\r
+               linenum = this->m_ctrlCmdOut.GetLineCount();\r
+               if(linenum>0)\r
                        index = this->m_ctrlCmdOut.LineIndex(linenum-1);\r
                        index = this->m_ctrlCmdOut.LineIndex(linenum-1);\r
-                       \r
-                       if(linenum == 0)\r
-                               index = 0;\r
-               }\r
                else\r
                else\r
-               {\r
-                       index=-1;\r
-               }\r
-               \r
+                       index = 0;\r
+\r
+       }else\r
+               index = -1;\r
 \r
 \r
-               this->m_ctrlCmdOut.SetSel(index,-1);\r
+       this->m_ctrlCmdOut.SetSel(index,-1);\r
                        \r
                        \r
-               this->m_ctrlCmdOut.ReplaceSel(CString(_T("\n"))+m_LogText);\r
-               \r
-               this->m_ctrlCmdOut.LineScroll(linenum-1);\r
+       this->m_ctrlCmdOut.ReplaceSel(CString(ch));\r
                \r
                \r
+       this->m_ctrlCmdOut.LineScroll(linenum-1);\r
+\r
+       if( ch == _T('\r') || ch == _T('\n') )\r
+       {\r
                int s1=m_LogText.Find(_T(':'));\r
                int s2=m_LogText.Find(_T('%'));\r
                if(s1>0 && s2>0)\r
                {\r
                int s1=m_LogText.Find(_T(':'));\r
                int s2=m_LogText.Find(_T('%'));\r
                if(s1>0 && s2>0)\r
                {\r
-               //      this->m_CurrentWork.SetWindowTextW(m_LogText.Left(s1));\r
+                       //      this->m_CurrentWork.SetWindowTextW(m_LogText.Left(s1));\r
                        int pos=CProgressDlg::FindPercentage(m_LogText);\r
                        TRACE(_T("Pos %d\r\n"),pos);\r
                        if(pos>0)\r
                                this->m_ctrlProgress.SetPos(pos);\r
                }\r
                        int pos=CProgressDlg::FindPercentage(m_LogText);\r
                        TRACE(_T("Pos %d\r\n"),pos);\r
                        if(pos>0)\r
                                this->m_ctrlProgress.SetPos(pos);\r
                }\r
-\r
-               m_LogText=_T("");\r
-\r
-       }else\r
-       {\r
-               m_LogText+=ch;\r
+               m_LogText=_T("");       \r
        }\r
        }\r
+       m_LogText+=ch;\r
+\r
 }
\ No newline at end of file
 }
\ No newline at end of file