OSDN Git Service

GitBlame Use command Line argument to open file
[tortoisegit/TortoiseGitJp.git] / src / TortoiseGitBlame / OutputWnd.cpp
index ba5b681..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;\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
@@ -77,6 +93,7 @@ int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
 \r
        m_wndTabs.AddTab(&m_LogList, strTabName, (UINT)0);\r
 \r
+       m_LogList.m_IsIDReplaceAction=TRUE;\r
        m_LogList.DeleteAllItems();\r
        m_LogList.InsertGitColumn();\r
 \r
@@ -95,6 +112,7 @@ int COutputWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
 //     FillDebugWindow();\r
 //     FillFindWindow();\r
 \r
+       this->SetWindowTextW(_T("Git Log"));\r
        return 0;\r
 }\r
 \r
@@ -146,6 +164,38 @@ void COutputWnd::FillFindWindow()
 //     m_wndOutputFind.AddString(_T("but you can change the way it is displayed as you wish..."));\r
 }\r
 \r
+int COutputWnd::LoadHistory(CString filename)\r
+{\r
+       m_LogList.ReloadHashMap();\r
+       CTGitPath path;\r
+       path.SetFromWin(filename);\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
@@ -212,4 +262,3 @@ void COutputList::OnViewOutput()
        }\r
 }\r
 \r
-\r