1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2011 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "StandAloneDlg.h"
23 #include "MenuButton.h"
26 #define MSG_PROGRESSDLG_UPDATE_UI (WM_USER+121)
28 // CProgressDlg dialog
29 #define MSG_PROGRESSDLG_START 0
30 #define MSG_PROGRESSDLG_RUN 50
31 #define MSG_PROGRESSDLG_END 110
32 #define MSG_PROGRESSDLG_FAILED 111
34 class CProgressDlg
: public CResizableStandAloneDialog
36 DECLARE_DYNAMIC(CProgressDlg
)
38 CProgressDlg(CWnd
* pParent
= NULL
); // standard constructor
39 virtual ~CProgressDlg();
42 virtual BOOL
OnInitDialog();
45 enum { IDD
= IDD_GITPROGRESS
};
50 CStringArray m_PostCmdList
;
51 std::vector
<CString
> m_GitCmdList
;
52 CString m_PreText
; // optional text to show in log window before running command
53 bool m_bShowCommand
; // whether to display the command in the log window (default true)
55 bool m_bBufferAll
; // Buffer All to improve speed when there are many file add at commit
56 bool m_bAutoCloseOnSuccess
;
62 CMenuButton m_ctrlPostCmd
;
64 CProgressCtrl m_Progress
;
67 CAnimateCtrl m_Animate
;
68 CStatic m_CurrentWork
;
69 CWinThread
* m_pThread
;
70 volatile LONG m_bThreadRunning
;
74 bool m_bAltAbortPress
;
76 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
77 static UINT
ProgressThreadEntry(LPVOID pVoid
);
78 UINT
ProgressThread();
82 void ParserCmdOutput(char ch
);
83 void RemoveLastLine(CString
&str
);
85 LRESULT
CProgressDlg::OnProgressUpdateUI(WPARAM wParam
,LPARAM lParam
);
87 afx_msg LRESULT
OnTaskbarBtnCreated(WPARAM wParam
, LPARAM lParam
);
88 CComPtr
<ITaskbarList3
> m_pTaskbarList
;
91 afx_msg
void OnClose();
92 void InsertCRLF(); //Insert \r before \n
93 void KillProcessTree(DWORD dwProcessId
);
95 CGitByteArray m_Databuf
;
96 virtual CString
Convert2UnionCode(char *buff
, int size
=-1)
99 g_Git
.StringAppend(&str
, (BYTE
*)buff
, CP_UTF8
, size
);
105 DECLARE_MESSAGE_MAP()
107 //Share with Sync Dailog
108 static int FindPercentage(CString
&log
);
110 static void ClearESC(CString
&str
);
113 static void ParserCmdOutput(CRichEditCtrl
&log
,CProgressCtrl
&progressctrl
,HWND m_hWnd
,CComPtr
<ITaskbarList3
> m_pTaskbarList
,
114 CStringA
&oneline
, char ch
,CWnd
*CurrentWork
=NULL
);
116 static UINT
RunCmdList(CWnd
*pWnd
,std::vector
<CString
> &cmdlist
,bool bShowCommand
,CString
*pfilename
,bool *bAbort
,CGitByteArray
*pdata
=NULL
);
119 static void InsertColorText(CRichEditCtrl
&edit
,CString text
,COLORREF rgb
);
121 afx_msg
void OnBnClickedOk();
122 afx_msg
void OnBnClickedButton1();
124 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
127 class CCommitProgressDlg
:public CProgressDlg
130 CCommitProgressDlg(CWnd
* pParent
= NULL
):CProgressDlg(pParent
)
134 virtual CString
Convert2UnionCode(char *buff
, int size
=-1);