1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - 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 typedef void (*PostCmdCallback
)(CProgressDlg
*dlg
, void *caller
, int result
);
40 CProgressDlg(CWnd
* pParent
= NULL
); // standard constructor
41 virtual ~CProgressDlg();
44 virtual BOOL
OnInitDialog();
47 enum { IDD
= IDD_GITPROGRESS
};
52 CStringArray m_PostCmdList
;
53 CStringArray m_PostFailCmdList
;
54 PostCmdCallback m_PostCmdCallback
;
56 std::vector
<CString
> m_GitCmdList
;
57 CString m_PreText
; // optional text to show in log window before running command
58 bool m_bShowCommand
; // whether to display the command in the log window (default true)
60 bool m_bBufferAll
; // Buffer All to improve speed when there are many file add at commit
61 bool m_bAutoCloseOnSuccess
;
67 CMenuButton m_ctrlPostCmd
;
69 CProgressCtrl m_Progress
;
72 CAnimateCtrl m_Animate
;
73 CStatic m_CurrentWork
;
74 CWinThread
* m_pThread
;
75 volatile LONG m_bThreadRunning
;
79 bool m_bAltAbortPress
;
82 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
83 static UINT
ProgressThreadEntry(LPVOID pVoid
);
84 UINT
ProgressThread();
88 void ParserCmdOutput(char ch
);
89 void RemoveLastLine(CString
&str
);
91 LRESULT
OnProgressUpdateUI(WPARAM wParam
,LPARAM lParam
);
93 afx_msg LRESULT
OnTaskbarBtnCreated(WPARAM wParam
, LPARAM lParam
);
94 CComPtr
<ITaskbarList3
> m_pTaskbarList
;
97 afx_msg
void OnClose();
98 void InsertCRLF(); //Insert \r before \n
99 void KillProcessTree(DWORD dwProcessId
, unsigned int depth
= 0);
101 CGitByteArray m_Databuf
;
102 virtual CString
Convert2UnionCode(char *buff
, int size
=-1)
105 g_Git
.StringAppend(&str
, (BYTE
*)buff
, CP_UTF8
, size
);
111 DECLARE_MESSAGE_MAP()
113 //Share with Sync Dailog
114 static int FindPercentage(CString
&log
);
116 static void ClearESC(CString
&str
);
119 static void ParserCmdOutput(CRichEditCtrl
&log
,CProgressCtrl
&progressctrl
,HWND m_hWnd
,CComPtr
<ITaskbarList3
> m_pTaskbarList
,
120 CStringA
&oneline
, char ch
,CWnd
*CurrentWork
=NULL
);
122 static UINT
RunCmdList(CWnd
*pWnd
,std::vector
<CString
> &cmdlist
,bool bShowCommand
,CString
*pfilename
,bool *bAbort
,CGitByteArray
*pdata
=NULL
);
124 static void InsertColorText(CRichEditCtrl
&edit
,CString text
,COLORREF rgb
);
127 afx_msg
void OnBnClickedOk();
128 afx_msg
void OnBnClickedButton1();
130 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
133 class CCommitProgressDlg
:public CProgressDlg
136 CCommitProgressDlg(CWnd
* pParent
= NULL
):CProgressDlg(pParent
)
140 virtual CString
Convert2UnionCode(char *buff
, int size
=-1);