OSDN Git Service

GitBlame Use command Line argument to open file
[tortoisegit/TortoiseGitJp.git] / src / TortoiseGitBlame / OutputWnd.cpp
index 0979d68..9ae92c1 100644 (file)
@@ -4,6 +4,8 @@
 #include "OutputWnd.h"\r
 #include "Resource.h"\r
 #include "MainFrm.h"\r
+#include "TortoiseGitBlameDoc.h"\r
+#include "TortoiseGitBlameView.h"\r
 \r
 #ifdef _DEBUG\r
 #define new DEBUG_NEW\r
@@ -22,9 +24,22 @@ COutputWnd::~COutputWnd()
 {\r
 }\r
 \r
+IMPLEMENT_DYNCREATE(CGitMFCTabCtrl, CMFCTabCtrl)\r
+\r
+BEGIN_MESSAGE_MAP(CGitMFCTabCtrl, CMFCTabCtrl)\r
+       ON_NOTIFY(LVN_ITEMCHANGED, 0, OnLvnItemchangedLoglist)\r
+END_MESSAGE_MAP()\r
+\r
+void CGitMFCTabCtrl::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)\r
+{\r
+       COutputWnd *pWnd=DYNAMIC_DOWNCAST(COutputWnd,this->GetParent());\r
+       pWnd->OnLvnItemchangedLoglist(pNMHDR,pResult);\r
+}\r
+\r
 BEGIN_MESSAGE_MAP(COutputWnd, CDockablePane)\r
        ON_WM_CREATE()\r
        ON_WM_SIZE()\r
+       ON_NOTIFY(LVN_ITEMCHANGED, 0, OnLvnItemchangedLoglist)\r
 END_MESSAGE_MAP()\r
 \r
 int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)\r
@@ -32,13 +47,14 @@ int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
        if (CDockablePane::OnCreate(lpCreateStruct) == -1)\r
                return -1;\r
 \r
+       TRACE(_T("%u\n"),LVN_ITEMCHANGED);\r
        m_Font.CreateStockObject(DEFAULT_GUI_FONT);\r
 \r
        CRect rectDummy;\r
        rectDummy.SetRectEmpty();\r
 \r
        // Create tabs window:\r
-       if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1))\r
+       if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 0))\r
        {\r
                TRACE0("Failed to create output tab window\n");\r
                return -1;      // fail to create\r
@@ -46,9 +62,9 @@ int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
 \r
        // Create output panes:\r
        //const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;\r
-       const DWORD dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL ;\r
+       const DWORD dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE;\r
 \r
-       if (! m_LogList.Create(dwStyle,rectDummy,&m_wndTabs,2) )\r
+       if (! m_LogList.Create(dwStyle,rectDummy,&m_wndTabs,0) )\r
        {\r
                TRACE0("Failed to create output windows\n");\r
                return -1;      // fail to create\r
@@ -153,12 +169,33 @@ int COutputWnd::LoadHistory(CString filename)
        m_LogList.ReloadHashMap();\r
        CTGitPath path;\r
        path.SetFromWin(filename);\r
-\r
-       m_LogList.FillGitLog(&path,CGit::LOG_INFO_FULLHISTORY);\r
+       \r
+       m_LogList.Clear();\r
+       m_LogList.FillGitLog(&path,0/*CGit::LOG_INFO_FULLHISTORY*/);\r
 \r
        return 0;\r
 \r
 }\r
+void COutputWnd::OnLvnItemchangedLoglist(NMHDR *pNMHDR, LRESULT *pResult)\r
+{\r
+       LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);\r
+       *pResult = 0;\r
+\r
+       //if (this->IsThreadRunning())\r
+       if (pNMLV->iItem >= 0)\r
+       {\r
+               if (pNMLV->iSubItem != 0)\r
+                       return;\r
+               \r
+               if (pNMLV->uNewState & LVIS_SELECTED)\r
+               {\r
+                       CMainFrame *pMain=DYNAMIC_DOWNCAST(CMainFrame,AfxGetApp()->GetMainWnd());\r
+                       POSITION pos=pMain->GetActiveDocument()->GetFirstViewPosition();\r
+                       CTortoiseGitBlameView *pView=DYNAMIC_DOWNCAST(CTortoiseGitBlameView,pMain->GetActiveDocument()->GetNextView(pos));\r
+                       pView->FocusOn(&this->m_LogList.m_logEntries[pNMLV->iItem]);\r
+               }\r
+       }\r
+}\r
 /////////////////////////////////////////////////////////////////////////////\r
 // COutputList1\r
 \r