OSDN Git Service

TortoiseGitBlame Add Next and Previous Function when choose one commit
[tortoisegit/TortoiseGitJp.git] / src / TortoiseGitBlame / TortoiseGitBlameView.cpp
index 36eec9d..105f1ef 100644 (file)
@@ -47,6 +47,8 @@ BEGIN_MESSAGE_MAP(CTortoiseGitBlameView, CView)
        ON_COMMAND(ID_EDIT_FIND,OnEditFind)\r
        ON_COMMAND(ID_EDIT_GOTO,OnEditGoto)\r
        ON_COMMAND(ID_EDIT_COPY,CopySelectedLogToClipboard)\r
+       ON_COMMAND(ID_VIEW_NEXT,OnViewNext)\r
+       ON_COMMAND(ID_VIEW_PREV,OnViewPrev)\r
        ON_WM_CREATE()\r
        ON_WM_SIZE()\r
        ON_WM_MOUSEMOVE()\r
@@ -969,10 +971,6 @@ LONG CTortoiseGitBlameView::GetBlameWidth()
        HFONT oldfont = (HFONT)::SelectObject(hDC, m_font);\r
        \r
        TCHAR buf[MAX_PATH];\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 (unsigned int i=0;i<this->m_ID.size();i++)\r
@@ -2584,6 +2582,14 @@ void CTortoiseGitBlameView::FocusOn(GitRev *pRev)
        this->GetDocument()->GetMainFrame()->m_wndProperties.UpdateProperties(pRev);\r
 \r
        this->Invalidate();\r
+\r
+       int i;\r
+       for(i=0;i<m_CommitHash.size();i++)\r
+       {\r
+               if( pRev->m_CommitHash == m_CommitHash[i] )\r
+                       break;\r
+       }\r
+       this->GotoLine(i);\r
        this->m_TextView.Invalidate();\r
 \r
 }\r
@@ -2701,3 +2707,47 @@ LRESULT CTortoiseGitBlameView::OnFindDialogMessage(WPARAM   wParam,   LPARAM   l
     return   0;   \r
 }   \r
 \r
+void CTortoiseGitBlameView::OnViewNext()\r
+{\r
+       FindNextLine(this->m_SelectedHash,false);\r
+}\r
+void CTortoiseGitBlameView::OnViewPrev()\r
+{\r
+       FindNextLine(this->m_SelectedHash,true);\r
+}\r
+\r
+int CTortoiseGitBlameView::FindNextLine(CString CommitHash,bool bUpOrDown)\r
+{\r
+       LONG_PTR line = SendEditor(SCI_GETFIRSTVISIBLELINE);\r
+       LONG_PTR startline =line;\r
+       bool findNoMatch =false;\r
+       while(line>=0 && line<m_CommitHash.size())\r
+       {\r
+               if(m_CommitHash[line]!=CommitHash)\r
+               {\r
+                       findNoMatch=true;\r
+               }\r
+\r
+               if(m_CommitHash[line] == CommitHash && findNoMatch)\r
+               {\r
+                       if( line == startline+2 )\r
+                       {\r
+                               findNoMatch=false;\r
+                       }\r
+                       else\r
+                       {\r
+                               if( bUpOrDown )\r
+                               {\r
+                                       line=FindFirstLine(CommitHash,line);\r
+                               }\r
+                               SendEditor(SCI_LINESCROLL,0,line-startline-2);\r
+                               return line;\r
+                       }\r
+               }\r
+               if(bUpOrDown)\r
+                       line--;\r
+               else\r
+                       line++;\r
+       }\r
+       return -1;\r
+}
\ No newline at end of file