OSDN Git Service

Stick Patch View basic work at
authorFrank Li <lznuaa@gmail.com>
Sun, 23 Aug 2009 16:08:49 +0000 (00:08 +0800)
committerFrank Li <lznuaa@gmail.com>
Sun, 23 Aug 2009 16:08:49 +0000 (00:08 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Git/GitStatusListCtrl.cpp
src/Git/GitStatusListCtrl.h
src/TortoiseProc/CommitDlg.cpp
src/TortoiseProc/CommitDlg.h
src/TortoiseProc/PatchViewDlg.cpp
src/TortoiseProc/PatchViewDlg.h

index 531a44e..53263df 100644 (file)
@@ -62,6 +62,8 @@ const UINT CGitStatusListCtrl::SVNSLNM_ADDFILE
                                        = ::RegisterWindowMessage(_T("GITSLNM_ADDFILE"));\r
 const UINT CGitStatusListCtrl::SVNSLNM_CHECKCHANGED\r
                                        = ::RegisterWindowMessage(_T("GITSLNM_CHECKCHANGED"));\r
+const UINT CGitStatusListCtrl::SVNSLNM_ITEMCHANGED\r
+                                       = ::RegisterWindowMessage(_T("GITSLNM_ITEMCHANGED"));\r
 \r
 \r
 \r
@@ -1797,6 +1799,12 @@ BOOL CGitStatusListCtrl::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult)
 {\r
        LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);\r
        *pResult = 0;\r
+       CWnd* pParent = GetParent();\r
+       if (NULL != pParent && NULL != pParent->GetSafeHwnd())\r
+       {\r
+               pParent->SendMessage(SVNSLNM_ITEMCHANGED, pNMLV->iItem);\r
+       }\r
+\r
        if ((pNMLV->uNewState==0)||(pNMLV->uNewState & LVIS_SELECTED)||(pNMLV->uNewState & LVIS_FOCUSED))\r
                return FALSE;\r
 \r
index 40af64f..d91415b 100644 (file)
@@ -234,6 +234,8 @@ public:
         */\r
        static const UINT SVNSLNM_CHECKCHANGED;\r
 \r
+       static const UINT SVNSLNM_ITEMCHANGED;\r
+\r
        CGitStatusListCtrl(void);\r
        ~CGitStatusListCtrl(void);\r
 \r
index 1ceab7c..e2d4283 100644 (file)
@@ -98,6 +98,8 @@ BEGIN_MESSAGE_MAP(CCommitDlg, CResizableStandAloneDialog)
        ON_REGISTERED_MESSAGE(CGitStatusListCtrl::SVNSLNM_NEEDSREFRESH, OnGitStatusListCtrlNeedsRefresh)\r
        ON_REGISTERED_MESSAGE(CGitStatusListCtrl::SVNSLNM_ADDFILE, OnFileDropped)\r
        ON_REGISTERED_MESSAGE(CGitStatusListCtrl::SVNSLNM_CHECKCHANGED, &CCommitDlg::OnGitStatusListCtrlCheckChanged)\r
+       ON_REGISTERED_MESSAGE(CGitStatusListCtrl::SVNSLNM_ITEMCHANGED, &CCommitDlg::OnGitStatusListCtrlItemChanged)\r
+       \r
        ON_REGISTERED_MESSAGE(WM_AUTOLISTREADY, OnAutoListReady) \r
        ON_WM_TIMER()\r
     ON_WM_SIZE()\r
@@ -112,6 +114,7 @@ BEGIN_MESSAGE_MAP(CCommitDlg, CResizableStandAloneDialog)
        ON_WM_MOVE()\r
        ON_WM_MOVING()\r
        ON_WM_SIZING()\r
+       ON_NOTIFY(HDN_ITEMCHANGED, 0, &CCommitDlg::OnHdnItemchangedFilelist)\r
 END_MESSAGE_MAP()\r
 \r
 BOOL CCommitDlg::OnInitDialog()\r
@@ -1518,6 +1521,36 @@ void CCommitDlg::OnBnClickedBugtraqbutton()
        SysFreeString(temp);\r
 \r
 }\r
+LRESULT CCommitDlg::OnGitStatusListCtrlItemChanged(WPARAM wparam, LPARAM lparam)\r
+{\r
+       TRACE("OnGitStatusListCtrlItemChanged %d\r\n", wparam);\r
+       if(::IsWindow(this->m_patchViewdlg.m_hWnd))\r
+       {\r
+               m_patchViewdlg.m_ctrlPatchView.SetText(CString());\r
+\r
+               POSITION pos=m_ListCtrl.GetFirstSelectedItemPosition();\r
+               m_patchViewdlg.m_ctrlPatchView.Call(SCI_SETREADONLY, FALSE);\r
+               while(pos)\r
+               {\r
+                       int nSelect = m_ListCtrl.GetNextSelectedItem(pos);\r
+                       CTGitPath * p=(CTGitPath*)m_ListCtrl.GetItemData(nSelect);\r
+                       if(p)\r
+                       {\r
+                               CString cmd,out;\r
+                               cmd.Format(_T("git.exe diff -- \"%s\""),p->GetGitPathString());\r
+                               g_Git.Run(cmd,&out,CP_ACP);\r
+\r
+                               m_patchViewdlg.m_ctrlPatchView.SetText(out);\r
+                       }\r
+\r
+               }\r
+               m_patchViewdlg.m_ctrlPatchView.Call(SCI_SETREADONLY, TRUE);\r
+               m_patchViewdlg.m_ctrlPatchView.Call(SCI_GOTOPOS, 0);\r
+\r
+       }\r
+       return 0;\r
+}\r
+\r
 \r
 LRESULT CCommitDlg::OnGitStatusListCtrlCheckChanged(WPARAM, LPARAM)\r
 {\r
@@ -1804,3 +1837,11 @@ void CCommitDlg::OnSizing(UINT fwSide, LPRECT pRect)
        }\r
        // TODO: Add your message handler code here\r
 }\r
+\r
+void CCommitDlg::OnHdnItemchangedFilelist(NMHDR *pNMHDR, LRESULT *pResult)\r
+{\r
+       LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);\r
+       // TODO: Add your control notification handler code here\r
+       *pResult = 0;\r
+       TRACE("Item Changed\r\n");\r
+}\r
index ed9c886..c98a075 100644 (file)
@@ -90,6 +90,8 @@ protected:
        afx_msg LRESULT OnGitStatusListCtrlItemCountChanged(WPARAM, LPARAM);\r
        afx_msg LRESULT OnGitStatusListCtrlNeedsRefresh(WPARAM, LPARAM);\r
        afx_msg LRESULT OnGitStatusListCtrlCheckChanged(WPARAM, LPARAM);\r
+       afx_msg LRESULT OnGitStatusListCtrlItemChanged(WPARAM, LPARAM);\r
+       \r
        afx_msg LRESULT OnAutoListReady(WPARAM, LPARAM);\r
        afx_msg LRESULT OnFileDropped(WPARAM, LPARAM lParam);\r
        afx_msg void OnTimer(UINT_PTR nIDEvent);\r
@@ -167,4 +169,5 @@ public:
        afx_msg void OnMove(int x, int y);\r
        afx_msg void OnMoving(UINT fwSide, LPRECT pRect);\r
        afx_msg void OnSizing(UINT fwSide, LPRECT pRect);\r
+       afx_msg void OnHdnItemchangedFilelist(NMHDR *pNMHDR, LRESULT *pResult);\r
 };\r
index 773346c..698078d 100644 (file)
@@ -82,6 +82,8 @@ BOOL CPatchViewDlg::OnInitDialog()
        m_ctrlPatchView.Call(SCI_SETUNDOCOLLECTION, 0);\r
 \r
        m_ctrlPatchView.Call(SCI_SETUNDOCOLLECTION, 1);\r
+       m_ctrlPatchView.Call(SCI_SETWRAPMODE,SC_WRAP_NONE);\r
+       \r
        //::SetFocus(m_hWndEdit);\r
        m_ctrlPatchView.Call(EM_EMPTYUNDOBUFFER);\r
        m_ctrlPatchView.Call(SCI_SETSAVEPOINT);\r
index 31107c4..47840b7 100644 (file)
@@ -18,7 +18,7 @@ public:
 protected:\r
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
        void                            SetAStyle(int style, COLORREF fore, COLORREF back=::GetSysColor(COLOR_WINDOW), int size=-1, const char *face=0);\r
-\r
+public:\r
        CSciEdit                        m_ctrlPatchView;\r
 \r
        DECLARE_MESSAGE_MAP()\r