X-Git-Url: http://git.sourceforge.jp/view?p=tortoisegit%2FTortoiseGitJp.git;a=blobdiff_plain;f=src%2FTortoiseGitBlame%2FTortoiseGitBlameView.cpp;h=c5a679634fad1dede32d6c2c2ecc03b9e8f74d94;hp=e152a906aaaedc5c26b7740063923985a9d44ba1;hb=37cc0a5dac9c85bc5c55996c282678ed7947afd6;hpb=9a8f31a9a8f9a7c5239f0cd7f5f1a3aab4134a34 diff --git a/src/TortoiseGitBlame/TortoiseGitBlameView.cpp b/src/TortoiseGitBlame/TortoiseGitBlameView.cpp index e152a90..c5a6796 100644 --- a/src/TortoiseGitBlame/TortoiseGitBlameView.cpp +++ b/src/TortoiseGitBlame/TortoiseGitBlameView.cpp @@ -25,11 +25,14 @@ #include "TortoiseGitBlameDoc.h" #include "TortoiseGitBlameView.h" #include "MainFrm.h" +#include "Balloon.h" +#include "EditGotoDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif +UINT CTortoiseGitBlameView::m_FindDialogMessage; // CTortoiseGitBlameView @@ -40,6 +43,8 @@ BEGIN_MESSAGE_MAP(CTortoiseGitBlameView, CView) ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CTortoiseGitBlameView::OnFilePrintPreview) + ON_COMMAND(ID_EDIT_FIND,OnEditFind) + ON_COMMAND(ID_EDIT_GOTO,OnEditGoto) ON_WM_CREATE() ON_WM_SIZE() ON_WM_MOUSEMOVE() @@ -49,8 +54,10 @@ BEGIN_MESSAGE_MAP(CTortoiseGitBlameView, CView) ON_WM_RBUTTONDOWN() ON_NOTIFY(SCN_PAINTED,0,OnSciPainted) ON_NOTIFY(SCN_GETBKCOLOR,0,OnSciGetBkColor) + ON_REGISTERED_MESSAGE(m_FindDialogMessage, OnFindDialogMessage) END_MESSAGE_MAP() + // CTortoiseGitBlameView construction/destruction CTortoiseGitBlameView::CTortoiseGitBlameView() @@ -95,6 +102,9 @@ CTortoiseGitBlameView::CTortoiseGitBlameView() m_bShowAuthor=true; m_bShowDate=false; + + m_FindDialogMessage = ::RegisterWindowMessage(FINDMSGSTRING); + m_pFindDialog = NULL; } CTortoiseGitBlameView::~CTortoiseGitBlameView() @@ -122,7 +132,12 @@ int CTortoiseGitBlameView::OnCreate(LPCREATESTRUCT lpcs) m_wEditor = m_TextView.m_hWnd; CreateFont(); InitialiseEditor(); + m_ToolTip.Create(this->GetParent()); + m_ToolTip.AddTool(this,_T("Test")); + + ::AfxGetApp()->GetMainWnd(); return CView::OnCreate(lpcs); + } void CTortoiseGitBlameView::OnSize(UINT nType,int cx, int cy) @@ -581,7 +596,7 @@ void CTortoiseGitBlameView::InitialiseEditor() void CTortoiseGitBlameView::StartSearch() { - if (currentDialog) + if (m_pFindDialog) return; bool bCase = false; // Initialize FINDREPLACE @@ -598,87 +613,53 @@ void CTortoiseGitBlameView::StartSearch() currentDialog = FindText(&fr); } -bool CTortoiseGitBlameView::DoSearch(LPSTR what, DWORD flags) +bool CTortoiseGitBlameView::DoSearch(CString what, DWORD flags) { -#if 0 - TCHAR szWhat[80]; + + //char szWhat[80]; int pos = SendEditor(SCI_GETCURRENTPOS); int line = SendEditor(SCI_LINEFROMPOSITION, pos); bool bFound = false; bool bCaseSensitive = !!(flags & FR_MATCHCASE); - strcpy_s(szWhat, sizeof(szWhat), what); + //strcpy_s(szWhat, sizeof(szWhat), what); if(!bCaseSensitive) { - char *p; - size_t len = strlen(szWhat); - for (p = szWhat; p < szWhat + len; p++) - { - if (isupper(*p)&&__isascii(*p)) - *p = _tolower(*p); - } + what=what.MakeLower(); } - CString sWhat = CString(szWhat); + //CString sWhat = CString(szWhat); - char buf[20]; - int i=0; - for (i=line; (i<(int)authors.size())&&(!bFound); ++i) + //char buf[20]; + //int i=0; + int i=line; + do { int bufsize = SendEditor(SCI_GETLINE, i); char * linebuf = new char[bufsize+1]; SecureZeroMemory(linebuf, bufsize+1); SendEditor(SCI_GETLINE, i, (LPARAM)linebuf); + CString oneline=this->m_TextView.StringFromControl(linebuf); if (!bCaseSensitive) { - char *p; - for (p = linebuf; p < linebuf + bufsize; p++) - { - if (isupper(*p)&&__isascii(*p)) - *p = _tolower(*p); - } + oneline=oneline.MakeLower(); } - _stprintf_s(buf, 20, _T("%ld"), revs[i]); - if (authors[i].compare(sWhat)==0) + //_stprintf_s(buf, 20, _T("%ld"), revs[i]); + if (this->m_Authors[i].Find(what)>=0) bFound = true; - else if ((!bCaseSensitive)&&(_stricmp(authors[i].c_str(), szWhat)==0)) + else if ((!bCaseSensitive)&&(this->m_Authors[i].MakeLower().Find(what)>=0)) bFound = true; - else if (strcmp(buf, szWhat) == 0) - bFound = true; - else if (strstr(linebuf, szWhat)) + else if (oneline.Find(what) >=0) bFound = true; + delete [] linebuf; - } - if (!bFound) - { - for (i=0; (i=m_CommitHash.size()) + i=0; + }while(i!=line &&(!bFound)); + if (bFound) { GotoLine(i); @@ -690,21 +671,20 @@ bool CTortoiseGitBlameView::DoSearch(LPSTR what, DWORD flags) } else { - ::MessageBox(wMain, searchstringnotfound, "CTortoiseGitBlameView", MB_ICONINFORMATION); + ::MessageBox(wMain, what+_T(" not found"), _T("CTortoiseGitBlameView"), MB_ICONINFORMATION); } -#endif + return true; } bool CTortoiseGitBlameView::GotoLine(long line) { -#if 0 --line; if (line < 0) return false; - if ((unsigned long)line >= authors.size()) + if ((unsigned long)line >= m_CommitHash.size()) { - line = authors.size()-1; + line = m_CommitHash.size()-1; } int nCurrentPos = SendEditor(SCI_GETCURRENTPOS); @@ -734,7 +714,7 @@ bool CTortoiseGitBlameView::GotoLine(long line) int nPosStart = SendEditor(SCI_POSITIONFROMLINE,line); int nPosEnd = SendEditor(SCI_GETLINEENDPOSITION,line); SendEditor(SCI_SETSEL,nPosEnd,nPosStart); -#endif + return true; } @@ -1132,8 +1112,8 @@ void CTortoiseGitBlameView::DrawBlame(HDC hDC) ::SetTextColor(hDC, m_textcolor); if (m_CommitHash[i].GetLength()>0) { - if (m_CommitHash[i].Compare(m_MouseHash)==0) - ::SetBkColor(hDC, m_mouseauthorcolor); + //if (m_CommitHash[i].Compare(m_MouseHash)==0) + // ::SetBkColor(hDC, m_mouseauthorcolor); if (m_CommitHash[i].Compare(m_SelectedHash)==0) { ::SetBkColor(hDC, m_selectedauthorcolor); @@ -1141,6 +1121,10 @@ void CTortoiseGitBlameView::DrawBlame(HDC hDC) sel = TRUE; } } + + if(m_MouseLine == i) + ::SetBkColor(hDC, m_mouserevcolor); + //if ((revs[i] == m_mouserev)&&(!sel)) // ::SetBkColor(hDC, m_mouserevcolor); //if (revs[i] == m_selectedrev) @@ -1186,7 +1170,7 @@ void CTortoiseGitBlameView::DrawBlame(HDC hDC) Left += m_authorwidth; } #endif - if ((i==m_SelectedLine)&&(currentDialog)) + if ((i==m_SelectedLine)&&(m_pFindDialog)) { LOGBRUSH brush; brush.lbColor = m_textcolor; @@ -2607,4 +2591,130 @@ void CTortoiseGitBlameView::FocusOn(GitRev *pRev) this->Invalidate(); this->m_TextView.Invalidate(); -} \ No newline at end of file +} + +void CTortoiseGitBlameView::OnMouseHover(UINT nFlags, CPoint point) +{ + + LONG_PTR line = SendEditor(SCI_GETFIRSTVISIBLELINE); + LONG_PTR height = SendEditor(SCI_TEXTHEIGHT); + line = line + (point.y/height); + + if (line < (LONG)m_CommitHash.size()) + { + if (line != m_MouseLine) + { + m_MouseLine = line;//m_CommitHash[line]; +// app.m_selectedorigrev = app.origrevs[line]; +// app.m_selectedauthor = app.authors[line]; +// app.m_selecteddate = app.dates[line]; + + + GitRev *pRev; + pRev=&this->GetLogData()->at(this->GetLogList()->GetItemCount()-m_ID[line]); + //this->GetDocument()->GetMainFrame()->m_wndProperties.UpdateProperties(pRev); + this->ClientToScreen(&point); + //BALLOON_INFO bi; + //if(m_ToolTip.GetTool(this, bi)) + //{ + // bi.sBalloonTip=pRev->m_CommitHash; + CString str; + str.Format(_T("%s\n%s\n%s\n%s"),pRev->m_CommitHash, + pRev->m_Subject, + pRev->m_AuthorDate.Format(_T("%Y-%m-%d %H:%M")), + pRev->m_Body); + m_ToolTip.AddTool(this,str); + m_ToolTip.DisplayToolTip(&point); + //} + + CRect rect; + this->ScreenToClient(&point); + rect.left=LOCATOR_WIDTH; + rect.right=this->m_blamewidth+rect.left; + rect.top=point.y-height; + rect.bottom=point.y+height; + this->InvalidateRect(rect); + + } + else + { + m_MouseLine=-1; +// app.m_selecteddate.clear(); +// app.m_selectedrev = -2; +// app.m_selectedorigrev = -2; + } + //::InvalidateRect( NULL, FALSE); + //this->Invalidate(); + } + +// const CString str=_T("this is a Message Balloon\n\nWarning! Warning!\nSomething unexpected happened"); + //CBalloon::ShowBalloon(NULL, point, + // str, + // FALSE, (HICON)IDI_EXCLAMATION, + // (UINT)CBalloon ::BALLOON_RIGHT_TOP, (UINT)CBalloon ::BALLOON_EFFECT_SOLID,(COLORREF)NULL, (COLORREF)NULL, (COLORREF)NULL); +} + +void CTortoiseGitBlameView::OnMouseMove(UINT nFlags, CPoint point) +{ + TRACKMOUSEEVENT tme; + tme.cbSize=sizeof(TRACKMOUSEEVENT); + tme.dwFlags=TME_HOVER|TME_LEAVE; + tme.hwndTrack=this->m_hWnd; + tme.dwHoverTime=1; + TrackMouseEvent(&tme); +} + + +BOOL CTortoiseGitBlameView::PreTranslateMessage(MSG* pMsg) +{ + m_ToolTip.RelayEvent(pMsg); + return CView::PreTranslateMessage(pMsg); +} + +void CTortoiseGitBlameView::OnEditFind() +{ + m_pFindDialog=new CFindReplaceDialog(); + + m_pFindDialog->Create(TRUE,_T(""),NULL,FR_DOWN,this); +} + +void CTortoiseGitBlameView::OnEditGoto() +{ + CEditGotoDlg dlg; + if(dlg.DoModal()==IDOK) + { + this->GotoLine(dlg.m_LineNumber); + } +} + +LRESULT CTortoiseGitBlameView::OnFindDialogMessage(WPARAM wParam, LPARAM lParam)//Õâ¸öÒ²ÊÇÕÒÄǸö³ÌÐò¸ÄµÄ£¬Ö»²»¹ý»»³ÉÁË×Ô¼ºµÄÀà +{ + ASSERT(m_pFindDialog != NULL); + + // If the FR_DIALOGTERM flag is set, + // invalidate the handle identifying the dialog box. + if (m_pFindDialog->IsTerminating()) + { + m_pFindDialog = NULL; + return 0; + } + + // If the FR_FINDNEXT flag is set, + // call the application-defined search routine + // to search for the requested string. + if(m_pFindDialog->FindNext()) + { + //read data from dialog + CString FindName = m_pFindDialog->GetFindString(); + bool bMatchCase = m_pFindDialog->MatchCase() == TRUE; + bool bMatchWholeWord = m_pFindDialog->MatchWholeWord() == TRUE; + bool bSearchDown = m_pFindDialog->SearchDown() == TRUE; + + DoSearch(FindName,m_pFindDialog->m_fr.Flags); + //with given name do search + // *FindWhatYouNeed(FindName, bMatchCase, bMatchWholeWord, bSearchDown); + } + + return 0; +} +