📄 mainfrm.cpp
字号:
// n_filenumber=i;
// break;
// }
// }
// i--;
// AfxMessageBox("haveshengming?");
// if(currentkey==""||currentstring==""||str_test=="")
// return TRUE;
// AfxMessageBox(str_test);
int n_funcnum=m_pfile->funcinfstru.GetSize();
if(n_funcnum==0)
return FALSE;
FuncStruct * m_ptestfunc;
m_ptestfunc=new FuncStruct;
for(int j=0;j<=n_funcnum-1;j++)
{
m_ptestfunc=(FuncStruct *)m_pfile->funcinfstru.GetAt(j);
CString str_fn;
str_fn=m_ptestfunc->str_funcname;
// AfxMessageBox(str_fn);
// AfxMessageBox(str_test);
if(str_fn.Compare(str_test)==0)
{
// n_funcnumber=j;
// CString funcnum;
// funcnum.Format("%d",n_funcnumber);
// AfxMessageBox("have this func");
// AfxMessageBox(funcnum);
return TRUE;
}
}
if(j>=n_funcnum)
{
// n_funcnumber=j;
// AfxMessageBox("not have this func");
return FALSE;
}
return FALSE;
}
void CMainFrame::ExpandAllFile()
{
n_filenumber=0;
curpro=new ProjectList;
curpro=(ProjectList *)projectinfo.GetAt(0);
m_ptestwnd=NULL;
m_ptestwnd=new CMDIChildWnd ;
m_pfile=new FileList;
int n_filenum=curpro->proinfstru.GetSize();
int nfile1=curpro->proinfstru.GetSize();
for(int ifile=0;ifile<=n_filenum-1;ifile++)
{
// if(m_pfile->
n_funcnumber=0;
n_filenumber=ifile;
m_pfile=(FileList *)curpro->proinfstru.GetAt(ifile);
m_pfile->funcinfstru.RemoveAll();
struct fileitem m_pfi;
// m_pfi=new fileitem;
m_pfi=(fileitem)fileitemarray[ifile];
m_ptestwnd=(CMDIChildWnd *)m_pfi.m_pchildf;
if(m_ptestwnd==NULL)
return;
if(m_ptestwnd!=NULL)
{
CCrystalTextView* m_pexpandview=NULL;
m_pexpandview=(CCrystalTextView*)m_ptestwnd->GetActiveView();
if(m_pexpandview==NULL)
return;
// CRichEditCtrl& myeditctrl=m_pexpandview->GetRichEditCtrl();
CString strline; //行字符串
strline = _T(""); //字符串初始化
int n_linenum=m_pexpandview->GetLineCount();
//搜索当前视图的每一行
for( int i=0;i<=n_linenum-1;i++)
{
if(i > n_linenum - 1 || i < 0)
return ;
int nTemp = m_pexpandview->GetLineLength(i) * sizeof(WCHAR);
if(nTemp<=1)
{
strline=_T(" ");
continue ;
}
nTemp += 4 * sizeof(WCHAR); //尽量多留点空
// int nLen = myeditctrl.GetLine(i, strline.GetBuffer(nTemp), nTemp);
// strline.ReleaseBuffer();
// BOOL bRealReturn;
strline=m_pexpandview->GetLineChars(i);
// if(nLen > strline.GetLength())
int nLen = m_pexpandview->GetLineLength(i);
if(nLen>=1 && strline[nLen-1]==0xd ) {
strline = strline.Left(--nLen);
// bRealReturn=TRUE;
}
else {
strline = strline.Left(nLen);
// bRealReturn=FALSE;
}
if(nLen<3)
continue ;
if(nTemp>=1)
{
// char* c_line=NULL;
// int nLen = myeditctrl.GetLine(i, strline.GetBuffer(nTemp), nTemp);
strline.TrimLeft();
strline.TrimRight();
// CString linetext;
// char* linechar=NULL;
// myeditctrl.GetLine(i,linechar);
// if(linechar!=NULL)
// linetext=linechar;
// if(strline.GetLength!=0)
// {
// CString str_front=str_test.Left(keylength);
CString str_test=strline;
CString str_keytest1=_T("int");
CString str_keytest2=_T("void");
int len1=str_keytest1.GetLength();
int len2=str_keytest2.GetLength();
CString str_testkey1=_T("");
str_testkey1=(str_test.Left(len1));
CString str_testkey2=(str_test.Left(len2));
if(str_testkey2.Compare("main")==0)
{
// n_funcnumber=0;
// m_ptifile=new FileList;
// m_ptifile=(FileList *)curpro->proinfstru.GetAt(ifile);
// m_ptifile->funcinfstru.RemoveAll();
}
// AfxMessageBox(strline);
// AfxMessageBox(str_testkey1);
// AfxMessageBox(str_testkey2);
// AfxMessageBox("15");
if(IsC02Key(str_testkey1))
{
currentline=i;
currentstring=strline;
currentkey=str_testkey1;
InsertToTree();
}
else
{
if(IsC02Key(str_testkey2))
{
currentline=i;
currentstring=strline;
currentkey=str_testkey2;
// AfxMessageBox("isc02key2");
// AfxMessageBox(currentstring);
InsertToTree();
}
// }
}
// strline.ReleaseBuffer();
}
strline.ReleaseBuffer();
}
}
if(curpro!=NULL)
{
// m_ptestwnd=(CCJMDIChildWnd *)m_pfile->m_pChildWnd;
m_pfile->m_pChildWnd=(CCJMDIChildWnd *)m_ptestwnd;
curpro->proinfstru.RemoveAt(ifile);
curpro->proinfstru.InsertAt(ifile,(CObject *) m_pfile);
}
else
AfxMessageBox(" curpro not exist");
} //一个窗口扫描完毕
int nfile=curpro->proinfstru.GetSize();
m_pDocFile->UpdateAllFNode();
// m_ptestwnd->MDIActivate();
// m_ptestwnd->BringWindowToTop();
}
void CMainFrame::OnAct()
{
// CMDIFrameWnd::MDIActivate(currentmdichild);
//AfxMessageBox(IDS_KEY6);
}
void CMainFrame::OnUpdateComboboxfunction(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
b_Gotofunctiondeclaration=TRUE;
b_Gotofunctiondefinition=TRUE;
//nSel == CB_ERR
}
void CMainFrame::updatecomfile()
{
int comsize=m_pComboBoxfile->GetCount();
// ASSERT(comsize >= 0 && comsize< arrayfunc.GetSize());
// CString comstring=arrayfunc.GetAt(comsize);
CString comstring=m_pfile->str_filename;
m_pComboBoxfile->AddString(comstring);
// int comsize=m_pComboBoxfunc->GetCount();
m_pComboBoxfile->SetCurSel(comsize);
// m_pComboBoxfile->SetEditSel(
}
void CMainFrame::delcomfile()
{
m_pComboBoxfile->ResetContent();
//int comsize=m_pComboBoxfile->GetCount();
// ASSERT(comsize >= 0 && comsize< arrayfunc.GetSize());
// CString comstring=arrayfunc.GetAt(comsize);
ProjectList* m_pcurproget;
m_pcurproget=new ProjectList;
m_pcurproget=(ProjectList *)projectinfo.GetAt(0);
FileList* m_pfile=NULL;
m_pfile=new FileList;
int n_filenum=m_pcurproget->proinfstru.GetSize();
// int nfile1=curpro->proinfstru.GetSize();
CString comstring=_T("");
for(int ifile=0;ifile<=n_filenum-1;ifile++)
{
m_pfile=( FileList*) m_pcurproget->proinfstru.GetAt(ifile);
comstring=m_pfile->str_filename;
m_pComboBoxfile->AddString(comstring);
}
// int comsize=m_pComboBoxfunc->GetCount();
m_pComboBoxfile->SetCurSel(n_filenum-1);
// m_pComboBoxfile->SetEditSel(
}
void CMainFrame::OnSelendOkComboFile()
{
// TODO: Add your control notification handler code here
//更新数据
UpdateData();
//获得所有文件的函数信息
ExpandAllFile();
//用户选择索引
int n_selcomfile=m_pComboBoxfile->GetCurSel();
//用户选择的文件名
CString str_comselfile=_T("");
m_pComboBoxfile->GetLBText(n_selcomfile, str_comselfile);
m_pComboBoxfile->SetCurSel(n_selcomfile);
// m_typecom.SetCurSel(selno);
//清除函数列表控件中的内容
m_pComboBoxfunc->ResetContent();
//获得当前处理的项目信息
struct ProjectList * com_curpro=NULL;
com_curpro=new ProjectList;
com_curpro=(ProjectList *)projectinfo.GetAt(0);
//获得当前处理的项目名称
CString proname=_T("");
proname=com_curpro->str_projectname;
// m_pTreeCtrlFile->Expand (hticurpro , TVE_EXPAND);
//项目中的文件数目
int nfile=com_curpro->proinfstru.GetSize();
//取项目中的索引为n_selcomfile的文件信息
struct FileList * m_pcurfile=NULL;
m_pcurfile=new FileList;
// CString str_curfilename=_T("");
m_pcurfile=(FileList *)com_curpro->proinfstru.GetAt(n_selcomfile);
// str_curfilename=m_pcurfile->str_filename;
//该文件中的函数个数
int nfunc=m_pcurfile->funcinfstru.GetSize();
// CString str_filenm;
// str_filenm=m_pcurfile->str_filename;
//定义一个保存函数信息结构的指针
struct FuncStruct * m_pcurfunc;
m_pcurfunc=new FuncStruct;
CString str_curfunc=_T("");
//对每一个函数进行处理
for(int k=0;k<=nfunc-1;k++)
{
//取得函数名
m_pcurfunc=(FuncStruct *)m_pcurfile->funcinfstru.GetAt(k);
str_curfunc=m_pcurfunc->str_funcname;
//函数名写入列表控件
m_pComboBoxfunc->AddString(str_curfunc);
}
//设置当前选择为最后一个函数
m_pComboBoxfunc->SetCurSel(nfunc-1);
//停止更新数据
UpdateData(FALSE);
}
void CMainFrame::OnSearchThisfile()
{
// TODO: Add your command handler code here
a_searchinfo.RemoveAll();
CFindInCurFile * myfinddlg;
// myfinddlg.DoModal();
myfinddlg=new CFindInCurFile;
myfinddlg->Create(IDD_DIALOG_FINDCURFILE);
myfinddlg->ShowWindow(SW_SHOW);
}
void CMainFrame::OnReplaceCurfile()
{
// TODO: Add your command handler code here
CRplaceDlg* myrepdlg;
myrepdlg=new CRplaceDlg;
myrepdlg->Create(IDD_DIALOG_REPLACECURFILE);
// FindDlg myfinddlg;
// myfinddlg.DoModal();
myrepdlg->ShowWindow(SW_SHOW);
}
void CMainFrame::OnReplaceProject()
{
// TODO: Add your command handler code here
CReplaceProject* myrepdlg;
myrepdlg=new CReplaceProject;
myrepdlg->Create(IDD_DIALOG_REPLACEPROFILE);
// FindDlg myfinddlg;
// myfinddlg.DoModal();
myrepdlg->ShowWindow(SW_SHOW);
}
void CMainFrame::OnWizbarActionsAdd()
{
//获得所有文件的函数信息
ExpandAllFile();
//定义对话框
CMyProPertySheet pd ("Function Wizard");
//显示
pd.DoModal ();
}
void CMainFrame::OnWizbarActionsDel()
{
ProjectList* m_pcurproget;
m_pcurproget=new ProjectList;
m_pcurproget=(ProjectList *)projectinfo.GetAt(0);
// FileList* m_pfile=NULL;
// m_pfile=new FileList;
int n_filenum=m_pcurproget->proinfstru.GetSize();
if(n_filenum>0)
{
ExpandAllFile();
// TODO: Add your command handler code here
CMyProPertySheet pd ("Function Wizard",this,1);
//CMyProPertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
pd.DoModal ();
/* DeleteFunc* m_ppage=NULL;
m_ppage=&(pd.mydelfuncpage);
int i=pd.GetPageIndex(m_ppage);
pd.SetActivePage(i);
*/
// pd.SetActivePage(pd.GetPageIndex(m_ppage));
}
}
void CMainFrame::OnWizbarGotofunctiondeclaration()
{
// TODO: Add your command handler code here
int n_selfile=m_pComboBoxfile->GetCurSel();
int n_selfunc=m_pComboBoxfunc->GetCurSel();
if(n_selfile==-1||n_selfunc==-1)
return;
CMDIChildWnd* m_pgotochildf=NULL;
m_pgotochildf=new CMDIChildWnd;
//函数所在子窗口指针
m_pgotochildf=fileitemarray[n_selfile].m_pchildf;
//子窗口激活
m_pgotochildf->MDIActivate();
//子窗口设置为最前
m_pgotochildf->BringWindowToTop();
//子窗口设置为焦点
m_pgotochildf->SetFocus();
//当前项目指针
struct ProjectList * curgotopro=NULL;
curgotopro=new ProjectList;
curgotopro=(ProjectList *)projectinfo.GetAt(0);
//项目不存在
if(curgotopro==NULL||projectinfo.GetSize()==0||curgotopro->proinfstru.GetSize()==0)
return;
int n_filesize=curgotopro->proinfstru.GetSize();
if(n_selfile>=n_filesize)
return;
FileList * m_pgotofile=NULL;
m_pgotofile=new FileList;
//获得函数所在文件对应的文件信息指针
m_pgotofile=(FileList * )curgotopro->proinfstru.GetAt(n_selfile);
//获得函数所在文件对应的子窗口指针
m_pgotochildf=fileitemarray[n_selfile].m_pchildf;
//断点信息结构的指针变量
struct FuncStruct * m_ptestfunc;
m_ptestfunc=new FuncStruct;
int funcsize=m_pgotofile->funcinfstru.GetSize();
if(n_selfunc>=funcsize)
return;
//访问函数
m_ptestfunc=(FuncStruct *)m_pgotofile->funcinfstru.GetAt(n_selfunc);
int gotoline=m_ptestfunc->n_shengming;
CC02IDEView* m_pView=(CC02IDEView*)m_pgotochildf->GetActiveView();
m_pView->GotoLine(gotoline);
}
void CMainFrame::OnWizbarGotofunctiondefinition()
{
// TODO: Add your command handler code here
int n_selfile=m_pComboBoxfile->GetCurSel();
int n_selfunc=m_pComboBoxfunc->GetCurSel();
if(n_selfile==-1||n_selfunc==-1)
return;
CMDIChildWnd* m_pgotochildf=NULL;
m_pgotochildf=new CMDIChildWnd;
//函数所在子窗口指针
m_pgotochildf=fileitemarray[n_selfile].m_pchildf;
//子窗口激活
m_pgotochildf->MDIActivate();
//子窗口设置为最前
m_pgotochildf->BringWindowToTop();
//子窗口设置为焦点
m_pgotochildf->SetFocus();
//当前项目指针
struct ProjectList * curgotopro=NULL;
curgotopro=new ProjectList;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -