OSDN Git Service

GitBlame Use command Line argument to open file
[tortoisegit/TortoiseGitJp.git] / src / TortoiseGitBlame / TortoiseGitBlameView.cpp
index 98283f2..c5a6796 100644 (file)
@@ -104,6 +104,7 @@ CTortoiseGitBlameView::CTortoiseGitBlameView()
        m_bShowDate=false;\r
 \r
     m_FindDialogMessage   =   ::RegisterWindowMessage(FINDMSGSTRING);   \r
+       m_pFindDialog = NULL;\r
 }\r
 \r
 CTortoiseGitBlameView::~CTortoiseGitBlameView()\r
@@ -134,7 +135,9 @@ int CTortoiseGitBlameView::OnCreate(LPCREATESTRUCT lpcs)
        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
@@ -593,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
@@ -610,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
-                       bFound = true;\r
-               else if ((!bCaseSensitive)&&(_stricmp(authors[i].c_str(), szWhat)==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 (strcmp(buf, szWhat) == 0)\r
+               else if ((!bCaseSensitive)&&(this->m_Authors[i].MakeLower().Find(what)>=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
@@ -702,9 +671,9 @@ 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
@@ -1201,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
@@ -2705,6 +2674,7 @@ BOOL CTortoiseGitBlameView::PreTranslateMessage(MSG* pMsg)
 void CTortoiseGitBlameView::OnEditFind()\r
 {\r
     m_pFindDialog=new CFindReplaceDialog();\r
+       \r
     m_pFindDialog->Create(TRUE,_T(""),NULL,FR_DOWN,this);  \r
 }\r
 \r
@@ -2739,7 +2709,8 @@ LRESULT CTortoiseGitBlameView::OnFindDialogMessage(WPARAM   wParam,   LPARAM   l
         bool   bMatchCase   =   m_pFindDialog->MatchCase()   ==   TRUE;   \r
         bool   bMatchWholeWord   =   m_pFindDialog->MatchWholeWord()   ==   TRUE;   \r
         bool   bSearchDown   =   m_pFindDialog->SearchDown()   ==   TRUE;   \r
-\r
+               \r
+               DoSearch(FindName,m_pFindDialog->m_fr.Flags);\r
             //with   given   name   do   search   \r
     //        *FindWhatYouNeed(FindName,   bMatchCase,   bMatchWholeWord,   bSearchDown);   \r
     }   \r