OSDN Git Service

GitBlame Use command Line argument to open file
[tortoisegit/TortoiseGitJp.git] / src / TortoiseGitBlame / TortoiseGitBlameView.cpp
index 1ea2dab..c5a6796 100644 (file)
 #include "TortoiseGitBlameDoc.h"\r
 #include "TortoiseGitBlameView.h"\r
 #include "MainFrm.h"\r
+#include "Balloon.h"\r
+#include "EditGotoDlg.h"\r
 \r
 #ifdef _DEBUG\r
 #define new DEBUG_NEW\r
 #endif\r
 \r
+UINT CTortoiseGitBlameView::m_FindDialogMessage;\r
 \r
 // CTortoiseGitBlameView\r
 \r
@@ -40,11 +43,21 @@ BEGIN_MESSAGE_MAP(CTortoiseGitBlameView, CView)
        ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)\r
        ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)\r
        ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CTortoiseGitBlameView::OnFilePrintPreview)\r
+       ON_COMMAND(ID_EDIT_FIND,OnEditFind)\r
+       ON_COMMAND(ID_EDIT_GOTO,OnEditGoto)\r
        ON_WM_CREATE()\r
        ON_WM_SIZE()\r
+       ON_WM_MOUSEMOVE()\r
+       ON_WM_MOUSEHOVER()\r
+       ON_WM_MOUSELEAVE()\r
+       ON_WM_LBUTTONDOWN()\r
+       ON_WM_RBUTTONDOWN()\r
        ON_NOTIFY(SCN_PAINTED,0,OnSciPainted)\r
+       ON_NOTIFY(SCN_GETBKCOLOR,0,OnSciGetBkColor)\r
+    ON_REGISTERED_MESSAGE(m_FindDialogMessage,   OnFindDialogMessage)  \r
 END_MESSAGE_MAP()\r
 \r
+\r
 // CTortoiseGitBlameView construction/destruction\r
 \r
 CTortoiseGitBlameView::CTortoiseGitBlameView()\r
@@ -59,7 +72,7 @@ CTortoiseGitBlameView::CTortoiseGitBlameView()
 \r
        m_font = 0;\r
        m_italicfont = 0;\r
-       m_blamewidth = 100;\r
+       m_blamewidth = 0;\r
        m_revwidth = 0;\r
        m_datewidth = 0;\r
        m_authorwidth = 0;\r
@@ -86,6 +99,12 @@ CTortoiseGitBlameView::CTortoiseGitBlameView()
        m_colorage = true;\r
 \r
        m_bShowLine=true;\r
+\r
+       m_bShowAuthor=true;\r
+       m_bShowDate=false;\r
+\r
+    m_FindDialogMessage   =   ::RegisterWindowMessage(FINDMSGSTRING);   \r
+       m_pFindDialog = NULL;\r
 }\r
 \r
 CTortoiseGitBlameView::~CTortoiseGitBlameView()\r
@@ -102,7 +121,7 @@ int CTortoiseGitBlameView::OnCreate(LPCREATESTRUCT lpcs)
 \r
        CRect rect,rect1;\r
        this->GetWindowRect(&rect1);\r
-       rect.left=m_blamewidth;\r
+       rect.left=m_blamewidth+LOCATOR_WIDTH;\r
        rect.right=rect.Width();\r
        rect.top=0;\r
        rect.bottom=rect.Height();\r
@@ -113,7 +132,12 @@ int CTortoiseGitBlameView::OnCreate(LPCREATESTRUCT lpcs)
        m_wEditor = m_TextView.m_hWnd;\r
        CreateFont();\r
        InitialiseEditor();\r
+       m_ToolTip.Create(this->GetParent());    \r
+       m_ToolTip.AddTool(this,_T("Test"));\r
+       \r
+       ::AfxGetApp()->GetMainWnd();\r
        return CView::OnCreate(lpcs);\r
+       \r
 }\r
 \r
 void CTortoiseGitBlameView::OnSize(UINT nType,int cx, int cy)\r
@@ -146,6 +170,7 @@ void CTortoiseGitBlameView::OnDraw(CDC* /*pDC*/)
                return;\r
 \r
        DrawBlame(this->GetDC()->m_hDC);\r
+       DrawLocatorBar(this->GetDC()->m_hDC);\r
        // TODO: add draw code for native data here\r
 }\r
 \r
@@ -571,7 +596,7 @@ void CTortoiseGitBlameView::InitialiseEditor()
 \r
 void CTortoiseGitBlameView::StartSearch()\r
 {\r
-       if (currentDialog)\r
+       if (m_pFindDialog)\r
                return;\r
        bool bCase = false;\r
        // Initialize FINDREPLACE\r
@@ -588,87 +613,53 @@ void CTortoiseGitBlameView::StartSearch()
        currentDialog = FindText(&fr);\r
 }\r
 \r
-bool CTortoiseGitBlameView::DoSearch(LPSTR what, DWORD flags)\r
+bool CTortoiseGitBlameView::DoSearch(CString what, DWORD flags)\r
 {\r
-#if 0\r
-       TCHAR szWhat[80];\r
+\r
+       //char szWhat[80];\r
        int pos = SendEditor(SCI_GETCURRENTPOS);\r
        int line = SendEditor(SCI_LINEFROMPOSITION, pos);\r
        bool bFound = false;\r
        bool bCaseSensitive = !!(flags & FR_MATCHCASE);\r
 \r
-       strcpy_s(szWhat, sizeof(szWhat), what);\r
+       //strcpy_s(szWhat, sizeof(szWhat), what);\r
 \r
        if(!bCaseSensitive)\r
        {\r
-               char *p;\r
-               size_t len = strlen(szWhat);\r
-               for (p = szWhat; p < szWhat + len; p++)\r
-               {\r
-                       if (isupper(*p)&&__isascii(*p))\r
-                               *p = _tolower(*p);\r
-               }\r
+               what=what.MakeLower();\r
        }\r
 \r
-       CString sWhat = CString(szWhat);\r
+       //CString sWhat = CString(szWhat);\r
        \r
-       char buf[20];\r
-       int i=0;\r
-       for (i=line; (i<(int)authors.size())&&(!bFound); ++i)\r
+       //char buf[20];\r
+       //int i=0;\r
+       int i=line;\r
+       do\r
        {\r
                int bufsize = SendEditor(SCI_GETLINE, i);\r
                char * linebuf = new char[bufsize+1];\r
                SecureZeroMemory(linebuf, bufsize+1);\r
                SendEditor(SCI_GETLINE, i, (LPARAM)linebuf);\r
+               CString oneline=this->m_TextView.StringFromControl(linebuf);\r
                if (!bCaseSensitive)\r
                {\r
-                       char *p;\r
-                       for (p = linebuf; p < linebuf + bufsize; p++)\r
-                       {\r
-                               if (isupper(*p)&&__isascii(*p))\r
-                                       *p = _tolower(*p);\r
-                       }\r
+                       oneline=oneline.MakeLower();\r
                }\r
-               _stprintf_s(buf, 20, _T("%ld"), revs[i]);\r
-               if (authors[i].compare(sWhat)==0)\r
+               //_stprintf_s(buf, 20, _T("%ld"), revs[i]);\r
+               if (this->m_Authors[i].Find(what)>=0)\r
                        bFound = true;\r
-               else if ((!bCaseSensitive)&&(_stricmp(authors[i].c_str(), szWhat)==0))\r
+               else if ((!bCaseSensitive)&&(this->m_Authors[i].MakeLower().Find(what)>=0))\r
                        bFound = true;\r
-               else if (strcmp(buf, szWhat) == 0)\r
-                       bFound = true;\r
-               else if (strstr(linebuf, szWhat))\r
+               else if (oneline.Find(what) >=0)\r
                        bFound = true;\r
+               \r
                delete [] linebuf;\r
-       }\r
-       if (!bFound)\r
-       {\r
-               for (i=0; (i<line)&&(!bFound); ++i)\r
-               {\r
-                       int bufsize = SendEditor(SCI_GETLINE, i);\r
-                       char * linebuf = new char[bufsize+1];\r
-                       SecureZeroMemory(linebuf, bufsize+1);\r
-                       SendEditor(SCI_GETLINE, i, (LPARAM)linebuf);\r
-                       if (!bCaseSensitive)\r
-                       {\r
-                               char *p;\r
-                               for (p = linebuf; p < linebuf + bufsize; p++)\r
-                               {\r
-                                       if (isupper(*p)&&__isascii(*p))\r
-                                               *p = _tolower(*p);\r
-                               }\r
-                       }\r
-                       _stprintf_s(buf, 20, _T("%ld"), revs[i]);\r
-                       if (authors[i].compare(sWhat)==0)\r
-                               bFound = true;\r
-                       else if ((!bCaseSensitive)&&(_stricmp(authors[i].c_str(), szWhat)==0))\r
-                               bFound = true;\r
-                       else if (strcmp(buf, szWhat) == 0)\r
-                               bFound = true;\r
-                       else if (strstr(linebuf, szWhat))\r
-                               bFound = true;\r
-                       delete [] linebuf;\r
-               }\r
-       }\r
+\r
+               i++;\r
+               if(i>=m_CommitHash.size())\r
+                       i=0;\r
+       }while(i!=line &&(!bFound));\r
+\r
        if (bFound)\r
        {\r
                GotoLine(i);\r
@@ -680,21 +671,20 @@ bool CTortoiseGitBlameView::DoSearch(LPSTR what, DWORD flags)
        }\r
        else\r
        {\r
-               ::MessageBox(wMain, searchstringnotfound, "CTortoiseGitBlameView", MB_ICONINFORMATION);\r
+               ::MessageBox(wMain, what+_T(" not found"), _T("CTortoiseGitBlameView"), MB_ICONINFORMATION);\r
        }\r
-#endif\r
+\r
        return true;\r
 }\r
 \r
 bool CTortoiseGitBlameView::GotoLine(long line)\r
 {\r
-#if 0\r
        --line;\r
        if (line < 0)\r
                return false;\r
-       if ((unsigned long)line >= authors.size())\r
+       if ((unsigned long)line >= m_CommitHash.size())\r
        {\r
-               line = authors.size()-1;\r
+               line = m_CommitHash.size()-1;\r
        }\r
 \r
        int nCurrentPos = SendEditor(SCI_GETCURRENTPOS);\r
@@ -724,7 +714,7 @@ bool CTortoiseGitBlameView::GotoLine(long line)
        int nPosStart = SendEditor(SCI_POSITIONFROMLINE,line);\r
        int nPosEnd = SendEditor(SCI_GETLINEENDPOSITION,line);\r
        SendEditor(SCI_SETSEL,nPosEnd,nPosStart);\r
-#endif\r
+\r
        return true;\r
 }\r
 \r
@@ -995,38 +985,58 @@ void CTortoiseGitBlameView::GotoLineDlg()
 \r
 LONG CTortoiseGitBlameView::GetBlameWidth()\r
 {\r
-#if 0\r
-       if (m_blamewidth)\r
-               return m_blamewidth;\r
        LONG blamewidth = 0;\r
        SIZE width;\r
        CreateFont();\r
-       HDC hDC = ::GetDC(wBlame);\r
+       HDC hDC = this->GetDC()->m_hDC;\r
        HFONT oldfont = (HFONT)::SelectObject(hDC, m_font);\r
+       \r
        TCHAR buf[MAX_PATH];\r
-       _stprintf_s(buf, MAX_PATH, _T("%8ld "), 88888888);\r
+       //_stprintf_s(buf, MAX_PATH, _T("%8ld "), 88888888);\r
+       //::GetTextExtentPoint(hDC, buf, _tcslen(buf), &width);\r
+       //m_revwidth = width.cx + BLAMESPACE;\r
+       //blamewidth += m_revwidth;\r
+\r
+       int maxnum=0;\r
+       for (int i=0;i<this->m_Authors.size();i++)\r
+       {\r
+               if(m_ID[i]>maxnum)\r
+                       maxnum=m_ID[i];\r
+       }\r
+       _stprintf_s(buf, MAX_PATH, _T("%d."), maxnum);\r
        ::GetTextExtentPoint(hDC, buf, _tcslen(buf), &width);\r
        m_revwidth = width.cx + BLAMESPACE;\r
        blamewidth += m_revwidth;\r
-       if (ShowDate)\r
+\r
+#if 0\r
+       _stprintf_s(buf, MAX_PATH, _T("%d"), m_CommitHash.size());\r
+       ::GetTextExtentPoint(hDC, buf, _tcslen(buf), &width);\r
+       m_linewidth = width.cx + BLAMESPACE;\r
+       blamewidth += m_revwidth;\r
+#endif \r
+\r
+       if (m_bShowDate)\r
        {\r
                _stprintf_s(buf, MAX_PATH, _T("%30s"), _T("31.08.2001 06:24:14"));\r
                ::GetTextExtentPoint32(hDC, buf, _tcslen(buf), &width);\r
                m_datewidth = width.cx + BLAMESPACE;\r
                blamewidth += m_datewidth;\r
        }\r
-       if (ShowAuthor)\r
+       if ( m_bShowAuthor)\r
        {\r
                SIZE maxwidth = {0};\r
-               for (std::vector<CString>::iterator I = authors.begin(); I != authors.end(); ++I)\r
+\r
+               for (int i=0;i<this->m_Authors.size();i++)\r
+               //for (std::vector<CString>::iterator I = authors.begin(); I != authors.end(); ++I)\r
                {\r
-                       ::GetTextExtentPoint32(hDC, I->c_str(), I->size(), &width);\r
+                       ::GetTextExtentPoint32(hDC,m_Authors[i] , m_Authors[i].GetLength(), &width);\r
                        if (width.cx > maxwidth.cx)\r
                                maxwidth = width;\r
                }\r
                m_authorwidth = maxwidth.cx + BLAMESPACE;\r
                blamewidth += m_authorwidth;\r
        }\r
+#if 0\r
        if (ShowPath)\r
        {\r
                SIZE maxwidth = {0};\r
@@ -1039,14 +1049,16 @@ LONG CTortoiseGitBlameView::GetBlameWidth()
                m_pathwidth = maxwidth.cx + BLAMESPACE;\r
                blamewidth += m_pathwidth;\r
        }\r
+#endif\r
        ::SelectObject(hDC, oldfont);\r
        POINT pt = {blamewidth, 0};\r
        LPtoDP(hDC, &pt, 1);\r
        m_blamewidth = pt.x;\r
-       ReleaseDC(wBlame, hDC);\r
-#endif\r
+       //::ReleaseDC(wBlame, hDC);\r
+\r
        //return m_blamewidth;\r
-       return 100;\r
+       return blamewidth;\r
+\r
 }\r
 \r
 void CTortoiseGitBlameView::CreateFont()\r
@@ -1100,8 +1112,8 @@ void CTortoiseGitBlameView::DrawBlame(HDC hDC)
                        ::SetTextColor(hDC, m_textcolor);\r
                        if (m_CommitHash[i].GetLength()>0)\r
                        {\r
-                               if (m_CommitHash[i].Compare(m_MouseHash)==0)\r
-                                       ::SetBkColor(hDC, m_mouseauthorcolor);\r
+                               //if (m_CommitHash[i].Compare(m_MouseHash)==0)\r
+                               //      ::SetBkColor(hDC, m_mouseauthorcolor);\r
                                if (m_CommitHash[i].Compare(m_SelectedHash)==0)\r
                                {\r
                                        ::SetBkColor(hDC, m_selectedauthorcolor);\r
@@ -1109,6 +1121,10 @@ void CTortoiseGitBlameView::DrawBlame(HDC hDC)
                                        sel = TRUE;\r
                                }\r
                        }\r
+\r
+                       if(m_MouseLine == i)\r
+                               ::SetBkColor(hDC, m_mouserevcolor);\r
+\r
                        //if ((revs[i] == m_mouserev)&&(!sel))\r
                        //      ::SetBkColor(hDC, m_mouserevcolor);\r
                        //if (revs[i] == m_selectedrev)\r
@@ -1118,14 +1134,23 @@ void CTortoiseGitBlameView::DrawBlame(HDC hDC)
                        //}\r
 \r
                        CString str;\r
-                       str.Format(_T("%d.%s"),m_ID[i],m_Authors[i]);\r
+                       str.Format(_T("%d"),m_ID[i]);\r
 \r
                        //_stprintf_s(buf, MAX_PATH, _T("%8ld       "), revs[i]);\r
-                       rc.top=Y;rc.left=0;             \r
+                       rc.top=Y;\r
+                       rc.left=LOCATOR_WIDTH;          \r
                        rc.bottom=Y+height;\r
-                       rc.right = rc.left + 100;\r
-                       ::ExtTextOut(hDC, 0, Y, ETO_CLIPPED, &rc, str, str.GetLength(), 0);\r
+                       rc.right = rc.left + m_blamewidth;\r
+                       ::ExtTextOut(hDC, LOCATOR_WIDTH, Y, ETO_CLIPPED, &rc, str, str.GetLength(), 0);\r
                        int Left = m_revwidth;\r
+                       \r
+                       if (m_bShowAuthor)\r
+                       {\r
+                               rc.right = rc.left + Left + m_authorwidth;\r
+                               //_stprintf_s(buf, MAX_PATH, _T("%-30s            "), authors[i].c_str());\r
+                               ::ExtTextOut(hDC, Left, Y, ETO_CLIPPED, &rc, m_Authors[i], m_Authors[i].GetLength(), 0);\r
+                               Left += m_authorwidth;\r
+                       }\r
 #if 0\r
                        if (ShowDate)\r
                        {\r
@@ -1134,13 +1159,7 @@ void CTortoiseGitBlameView::DrawBlame(HDC hDC)
                                ::ExtTextOut(hDC, Left, Y, ETO_CLIPPED, &rc, buf, _tcslen(buf), 0);\r
                                Left += m_datewidth;\r
                        }\r
-                       if (ShowAuthor)\r
-                       {\r
-                               rc.right = rc.left + Left + m_authorwidth;\r
-                               _stprintf_s(buf, MAX_PATH, _T("%-30s            "), authors[i].c_str());\r
-                               ::ExtTextOut(hDC, Left, Y, ETO_CLIPPED, &rc, buf, _tcslen(buf), 0);\r
-                               Left += m_authorwidth;\r
-                       }\r
+                       \r
 #endif\r
 #if 0\r
                        if (ShowPath)\r
@@ -1151,7 +1170,7 @@ void CTortoiseGitBlameView::DrawBlame(HDC hDC)
                                Left += m_authorwidth;\r
                        }\r
 #endif\r
-                       if ((i==m_SelectedLine)&&(currentDialog))\r
+                       if ((i==m_SelectedLine)&&(m_pFindDialog))\r
                        {\r
                                LOGBRUSH brush;\r
                                brush.lbColor = m_textcolor;\r
@@ -1227,7 +1246,6 @@ void CTortoiseGitBlameView::DrawHeader(HDC hDC)
 \r
 void CTortoiseGitBlameView::DrawLocatorBar(HDC hDC)\r
 {\r
-#if 0\r
        if (hDC == NULL)\r
                return;\r
 \r
@@ -1237,13 +1255,17 @@ void CTortoiseGitBlameView::DrawLocatorBar(HDC hDC)
        COLORREF blackColor = GetSysColor(COLOR_WINDOWTEXT);\r
 \r
        RECT rc;\r
-       ::GetClientRect(wLocator, &rc);\r
+       //::GetClientRect(wLocator, &rc);\r
+       this->GetClientRect(&rc);\r
+\r
+       rc.right=LOCATOR_WIDTH;\r
+\r
        RECT lineRect = rc;\r
        LONG height = rc.bottom-rc.top;\r
        LONG currentLine = 0;\r
 \r
        // draw the colored bar\r
-       for (std::vector<LONG>::const_iterator it = revs.begin(); it != revs.end(); ++it)\r
+       for (std::vector<LONG>::const_iterator it = m_ID.begin(); it != m_ID.end(); ++it)\r
        {\r
                currentLine++;\r
                // get the line color\r
@@ -1254,23 +1276,23 @@ void CTortoiseGitBlameView::DrawLocatorBar(HDC hDC)
                }\r
                SetBkColor(hDC, cr);\r
                lineRect.top = Y;\r
-               lineRect.bottom = (currentLine * height / revs.size());\r
+               lineRect.bottom = (currentLine * height / m_ID.size());\r
                ::ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &lineRect, NULL, 0, NULL);\r
                Y = lineRect.bottom;\r
        }\r
 \r
-       if (revs.size())\r
+       if (m_ID.size())\r
        {\r
                // now draw two lines indicating the scroll position of the source view\r
                SetBkColor(hDC, blackColor);\r
-               lineRect.top = line * height / revs.size();\r
+               lineRect.top = line * height / m_ID.size();\r
                lineRect.bottom = lineRect.top+1;\r
                ::ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &lineRect, NULL, 0, NULL);\r
-               lineRect.top = (line + linesonscreen) * height / revs.size();\r
+               lineRect.top = (line + linesonscreen) * height / m_ID.size();\r
                lineRect.bottom = lineRect.top+1;\r
                ::ExtTextOut(hDC, 0, 0, ETO_OPAQUE, &lineRect, NULL, 0, NULL);\r
        }\r
-#endif\r
+\r
 }\r
 \r
 void CTortoiseGitBlameView::StringExpand(LPSTR str)\r
@@ -1901,34 +1923,6 @@ LRESULT CALLBACK WndBlameProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
                // fall through\r
        case WM_LBUTTONDOWN:\r
                {\r
-                       int y = ((int)(short)HIWORD(lParam));\r
-                       LONG_PTR line = app.SendEditor(SCI_GETFIRSTVISIBLELINE);\r
-                       LONG_PTR height = app.SendEditor(SCI_TEXTHEIGHT);\r
-                       line = line + (y/height);\r
-                       if (line < (LONG)app.revs.size())\r
-                       {\r
-                               app.SetSelectedLine(line);\r
-                               if (app.revs[line] != app.m_selectedrev)\r
-                               {\r
-                                       app.m_selectedrev = app.revs[line];\r
-                                       app.m_selectedorigrev = app.origrevs[line];\r
-                                       app.m_selectedauthor = app.authors[line];\r
-                                       app.m_selecteddate = app.dates[line];\r
-                               }\r
-                               else\r
-                               {\r
-                                       app.m_selectedauthor.clear();\r
-                                       app.m_selecteddate.clear();\r
-                                       app.m_selectedrev = -2;\r
-                                       app.m_selectedorigrev = -2;\r
-                               }\r
-                               ::InvalidateRect(app.wBlame, NULL, FALSE);\r
-                       }\r
-                       else\r
-                       {\r
-                               app.SetSelectedLine(-1);\r
-                       }\r
-               }\r
                break;\r
        case WM_SETFOCUS:\r
                ::SetFocus(app.wBlame);\r
@@ -2465,6 +2459,8 @@ void CTortoiseGitBlameView::UpdateInfo()
        while( pos>=0 )\r
        {\r
                one=data.Tokenize(_T("\n"),pos);\r
+               if(one.IsEmpty())\r
+                       continue;\r
                m_CommitHash.push_back(one.Left(40));\r
                int start=0;\r
                start=one.Find(_T(')'),40);\r
@@ -2474,7 +2470,7 @@ void CTortoiseGitBlameView::UpdateInfo()
                        this->m_TextView.InsertText(line,true);\r
                }\r
                int id=pRevs->m_HashMap[one.Left(40)];          \r
-               if(id>=0)\r
+               if(id>=0 && id <GetLogData()->size())\r
                {\r
                        m_ID.push_back(pRevs->size()-id);\r
                        m_Authors.push_back(pRevs->at(id).m_AuthorName);\r
@@ -2493,10 +2489,26 @@ void CTortoiseGitBlameView::UpdateInfo()
        SendEditor(SCI_SETSCROLLWIDTHTRACKING, TRUE);\r
        SendEditor(SCI_SETREADONLY, TRUE);\r
 \r
+       m_lowestrev=1;\r
+       m_highestrev=this->GetLogData()->size();\r
+\r
+       GetBlameWidth();\r
+       CRect rect;\r
+       this->GetClientRect(rect);\r
+       //this->m_TextView.GetWindowRect(rect);\r
+       //this->m_TextView.ScreenToClient(rect);\r
+       rect.left=this->m_blamewidth;\r
+       this->m_TextView.MoveWindow(rect);\r
 \r
        this->Invalidate();\r
 }\r
 \r
+CGitBlameLogList * CTortoiseGitBlameView::GetLogList()\r
+{\r
+       return &(GetDocument()->GetMainFrame()->m_wndOutput.m_LogList);\r
+}\r
+\r
+\r
 CLogDataVector * CTortoiseGitBlameView::GetLogData()\r
 {\r
        return &(GetDocument()->GetMainFrame()->m_wndOutput.m_LogList.m_logEntries);\r
@@ -2505,4 +2517,204 @@ CLogDataVector * CTortoiseGitBlameView::GetLogData()
 void CTortoiseGitBlameView::OnSciPainted(NMHDR *,LRESULT *)\r
 {\r
        this->Invalidate();\r
-}
\ No newline at end of file
+}\r
+\r
+void CTortoiseGitBlameView::OnLButtonDown(UINT nFlags,CPoint point)\r
+{\r
+\r
+       LONG_PTR line = SendEditor(SCI_GETFIRSTVISIBLELINE);\r
+       LONG_PTR height = SendEditor(SCI_TEXTHEIGHT);\r
+       line = line + (point.y/height);\r
+                       \r
+       if (line < (LONG)m_CommitHash.size())\r
+       {\r
+               SetSelectedLine(line);\r
+               if (m_CommitHash[line] != m_SelectedHash)\r
+               {\r
+                       m_SelectedHash = m_CommitHash[line];\r
+//                     app.m_selectedorigrev = app.origrevs[line];\r
+//                     app.m_selectedauthor = app.authors[line];\r
+//                     app.m_selecteddate = app.dates[line];\r
+                       \r
+                       \r
+                       this->GetLogList()->SetItemState(this->GetLogList()->GetItemCount()-m_ID[line],\r
+                                                                                                                       LVIS_SELECTED,\r
+                                                                                                                       LVIS_SELECTED);\r
+\r
+                       GitRev *pRev;\r
+                       pRev=&this->GetLogData()->at(this->GetLogList()->GetItemCount()-m_ID[line]);\r
+                       this->GetDocument()->GetMainFrame()->m_wndProperties.UpdateProperties(pRev);\r
+               }\r
+               else\r
+               {\r
+                       m_SelectedHash.Empty();\r
+//                     app.m_selecteddate.clear();\r
+//                     app.m_selectedrev = -2;\r
+//                     app.m_selectedorigrev = -2;\r
+               }\r
+               //::InvalidateRect( NULL, FALSE);\r
+               this->Invalidate();\r
+               this->m_TextView.Invalidate();\r
+               \r
+       }\r
+       else\r
+       {\r
+               SetSelectedLine(-1);\r
+       }\r
+               \r
+       CView::OnLButtonDown(nFlags,point);\r
+}\r
+\r
+void CTortoiseGitBlameView::OnSciGetBkColor(NMHDR* hdr, LRESULT* result)\r
+{\r
+\r
+       SCNotification *notification=reinterpret_cast<SCNotification *>(hdr);\r
+\r
+       if ((m_colorage)&&(notification->line < (int)m_CommitHash.size()))\r
+       {\r
+               if(m_CommitHash[notification->line] == this->m_SelectedHash )\r
+                       notification->lParam = m_selectedauthorcolor;\r
+               else\r
+                       notification->lParam = InterColor(DWORD(m_regOldLinesColor), DWORD(m_regNewLinesColor), (m_ID[notification->line]-m_lowestrev)*100/((m_highestrev-m_lowestrev)+1));\r
+       }\r
+\r
+}\r
+\r
+void CTortoiseGitBlameView::FocusOn(GitRev *pRev)\r
+{\r
+       m_SelectedHash = pRev->m_CommitHash;\r
+\r
+       //GitRev *pRev;\r
+       //pRev=&this->GetLogData()->at(this->GetLogList()->GetItemCount()-m_ID[line]);\r
+       this->GetDocument()->GetMainFrame()->m_wndProperties.UpdateProperties(pRev);\r
+\r
+       this->Invalidate();\r
+       this->m_TextView.Invalidate();\r
+\r
+}\r
+\r
+void CTortoiseGitBlameView::OnMouseHover(UINT nFlags, CPoint point)\r
+{\r
+\r
+       LONG_PTR line = SendEditor(SCI_GETFIRSTVISIBLELINE);\r
+       LONG_PTR height = SendEditor(SCI_TEXTHEIGHT);\r
+       line = line + (point.y/height);\r
+                       \r
+       if (line < (LONG)m_CommitHash.size())\r
+       {\r
+               if (line != m_MouseLine)\r
+               {\r
+                       m_MouseLine = line;//m_CommitHash[line];\r
+//                     app.m_selectedorigrev = app.origrevs[line];\r
+//                     app.m_selectedauthor = app.authors[line];\r
+//                     app.m_selecteddate = app.dates[line];\r
+                       \r
+                       \r
+                       GitRev *pRev;\r
+                       pRev=&this->GetLogData()->at(this->GetLogList()->GetItemCount()-m_ID[line]);\r
+                       //this->GetDocument()->GetMainFrame()->m_wndProperties.UpdateProperties(pRev);\r
+                       this->ClientToScreen(&point);\r
+                       //BALLOON_INFO bi;\r
+                       //if(m_ToolTip.GetTool(this, bi))\r
+                       //{\r
+                       //      bi.sBalloonTip=pRev->m_CommitHash;\r
+                               CString str;\r
+                               str.Format(_T("%s\n<b>%s</b>\n%s\n%s"),pRev->m_CommitHash,\r
+                                                                                                          pRev->m_Subject,\r
+                                                                                                          pRev->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")),\r
+                                                                                                          pRev->m_Body);\r
+                               m_ToolTip.AddTool(this,str);\r
+                               m_ToolTip.DisplayToolTip(&point);\r
+                       //}\r
+       \r
+                       CRect rect;\r
+                       this->ScreenToClient(&point);\r
+                       rect.left=LOCATOR_WIDTH;\r
+                       rect.right=this->m_blamewidth+rect.left;\r
+                       rect.top=point.y-height;\r
+                       rect.bottom=point.y+height;\r
+                       this->InvalidateRect(rect);\r
+\r
+               }\r
+               else\r
+               {\r
+                       m_MouseLine=-1;\r
+//                     app.m_selecteddate.clear();\r
+//                     app.m_selectedrev = -2;\r
+//                     app.m_selectedorigrev = -2;\r
+               }\r
+               //::InvalidateRect( NULL, FALSE);\r
+               //this->Invalidate();\r
+       }\r
+       \r
+//      const CString str=_T("this is a <b>Message Balloon</b>\n<hr=100%>\n<ct=0x0000FF>Warning! Warning!</ct>\nSomething unexpected happened");\r
+        //CBalloon::ShowBalloon(NULL, point, \r
+         //            str,\r
+         //             FALSE, (HICON)IDI_EXCLAMATION,\r
+               //                 (UINT)CBalloon ::BALLOON_RIGHT_TOP, (UINT)CBalloon ::BALLOON_EFFECT_SOLID,(COLORREF)NULL,  (COLORREF)NULL,  (COLORREF)NULL);\r
+}\r
+\r
+void CTortoiseGitBlameView::OnMouseMove(UINT nFlags, CPoint point)\r
+{\r
+       TRACKMOUSEEVENT tme;\r
+       tme.cbSize=sizeof(TRACKMOUSEEVENT);\r
+       tme.dwFlags=TME_HOVER|TME_LEAVE;\r
+       tme.hwndTrack=this->m_hWnd;\r
+       tme.dwHoverTime=1;\r
+       TrackMouseEvent(&tme);\r
+}\r
+\r
+\r
+BOOL CTortoiseGitBlameView::PreTranslateMessage(MSG* pMsg)\r
+{\r
+       m_ToolTip.RelayEvent(pMsg);\r
+       return CView::PreTranslateMessage(pMsg);\r
+}\r
+\r
+void CTortoiseGitBlameView::OnEditFind()\r
+{\r
+    m_pFindDialog=new CFindReplaceDialog();\r
+       \r
+    m_pFindDialog->Create(TRUE,_T(""),NULL,FR_DOWN,this);  \r
+}\r
+\r
+void CTortoiseGitBlameView::OnEditGoto()\r
+{\r
+    CEditGotoDlg dlg;\r
+    if(dlg.DoModal()==IDOK)\r
+    {\r
+        this->GotoLine(dlg.m_LineNumber);\r
+    }\r
+}\r
+\r
+LRESULT CTortoiseGitBlameView::OnFindDialogMessage(WPARAM   wParam,   LPARAM   lParam)//Õâ¸öÒ²ÊÇÕÒÄǸö³ÌÐò¸ÄµÄ£¬Ö»²»¹ý»»³ÉÁË×Ô¼ºµÄÀà   \r
+{   \r
+    ASSERT(m_pFindDialog   !=   NULL);   \r
+    \r
+    //   If   the   FR_DIALOGTERM   flag   is   set,   \r
+          //   invalidate   the   handle   identifying   the   dialog   box.   \r
+    if   (m_pFindDialog->IsTerminating())   \r
+    {   \r
+            m_pFindDialog   =   NULL;   \r
+            return   0;   \r
+    }   \r
+\r
+    //   If   the   FR_FINDNEXT   flag   is   set,   \r
+    //   call   the   application-defined   search   routine   \r
+    //   to   search   for   the   requested   string.   \r
+    if(m_pFindDialog->FindNext())   \r
+    {   \r
+            //read   data   from   dialog   \r
+        CString   FindName   =   m_pFindDialog->GetFindString();   \r
+        bool   bMatchCase   =   m_pFindDialog->MatchCase()   ==   TRUE;   \r
+        bool   bMatchWholeWord   =   m_pFindDialog->MatchWholeWord()   ==   TRUE;   \r
+        bool   bSearchDown   =   m_pFindDialog->SearchDown()   ==   TRUE;   \r
+               \r
+               DoSearch(FindName,m_pFindDialog->m_fr.Flags);\r
+            //with   given   name   do   search   \r
+    //        *FindWhatYouNeed(FindName,   bMatchCase,   bMatchWholeWord,   bSearchDown);   \r
+    }   \r
+\r
+    return   0;   \r
+}   \r
+\r