www.pudn.com > c02 vc6.rar > C02IDEView.cpp
// C02IDEView.cpp : implementation of the CC02IDEView class // #include "stdafx.h" #include "C02IDE.h" #include "C02IDEDoc.h" #include "C02IDEView.h" #include "CCrystalTextView.h" #include "CCrystalEditView.h" #include "FindAllOpen.h" #include "MainFrm.h" #include "ChildFrm.h" //#include "Comp.h" #include#include #include //#include "DateDialog.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CC02IDEView IMPLEMENT_DYNCREATE(CC02IDEView, CCrystalEditView) BEGIN_MESSAGE_MAP(CC02IDEView, CCrystalEditView) //{{AFX_MSG_MAP(CC02IDEView) ON_WM_CONTEXTMENU() ON_COMMAND(ID_EDIT_BREAKPOINT, OnEditBreakpoint) ON_COMMAND(ID_EDIT_REMOVEBREAK, OnEditRemovebreak) ON_WM_RBUTTONDOWN() ON_UPDATE_COMMAND_UI(ID_EDIT_BREAKPOINT, OnUpdateEditBreakpoint) ON_WM_MOUSEWHEEL() ON_COMMAND(ID_SEARCH_OPENEDFILE, OnSearchOpenedfile) ON_WM_LBUTTONDBLCLK() ON_WM_MOUSEMOVE() ON_COMMAND(ID_BUILD_COMPILE,CompileCurFile) ON_WM_CHAR() //}}AFX_MSG_MAP // Standard printing commands ON_UPDATE_COMMAND_UI(ID_INDICATOR_LINE, OnUpdateLineNumber) ON_UPDATE_COMMAND_UI(ID_INDICATOR_ROW, OnUpdateRowNumber) ON_COMMAND(ID_FILE_PRINT, CCrystalEditView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CCrystalEditView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CCrystalEditView::OnFilePrintPreview) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CC02IDEView construction/destruction CC02IDEView::CC02IDEView() { // TODO: add construction code here // com=new MyCompiler; // com=NULL; com.i_pass=0; str_bgstr=_T(""); str_output=_T(""); } CC02IDEView::~CC02IDEView() { } BOOL CC02IDEView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CCrystalEditView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CC02IDEView diagnostics #ifdef _DEBUG void CC02IDEView::AssertValid() const { CCrystalEditView::AssertValid(); } void CC02IDEView::Dump(CDumpContext& dc) const { CCrystalEditView::Dump(dc); } CC02IDEDoc* CC02IDEView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CC02IDEDoc))); return (CC02IDEDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CC02IDEView message handlers CCrystalTextBuffer *CC02IDEView::LocateTextBuffer() { return &GetDocument()->m_xTextBuffer; } void CC02IDEView::OnInitialUpdate() { CCrystalEditView::OnInitialUpdate(); SetFont(GetDocument()->m_lf); } void CC02IDEView::OnContextMenu(CWnd* pWnd, CPoint point) { // CCrystalEditView::OnRButtonDown(nFlags, point); } void CC02IDEView::OnEditBreakpoint() { //主窗口指针 CMDIFrameWnd *nowframe = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; CMainFrame *p_mainframe = (CMainFrame*)AfxGetApp()->m_pMainWnd; //活动子窗口指针 CMDIChildWnd *nowchild = nowframe->MDIGetActive(); //获得当前项目信息的指针 struct ProjectList * curprobreak=NULL; curprobreak=new ProjectList; curprobreak=(ProjectList *)projectinfo.GetAt(0); m_pfile=new FileList; //项目中的文件数目 int n_filenumber=curprobreak->proinfstru.GetSize(); //声明文件节点 struct fileitem m_pcurnode; for (int j=0;j<=n_filenumber-1;j++) { //取得文件节点信息的第j个项 m_pcurnode=fileitemarray[j]; //如果节点的窗口指针等于当前活动窗口指针 if(m_pcurnode.m_pchildf==nowchild) break; } //获得活动窗口的文件信息 m_pfile=(FileList *)curprobreak->proinfstru.GetAt(j); //声明断点信息结构指针 struct CompStruct *m_pcomstr=NULL; m_pcomstr=new CompStruct; //获得当前活动视图 CCrystalTextView* m_pexpandview=NULL; m_pexpandview=(CCrystalTextView*)nowchild->GetActiveView(); if(m_pexpandview==NULL) return; //获得当前编辑控件 // CRichEditCtrl& myeditctrl=m_paddfuncview->GetRichEditCtrl(); //获得光标所在行索引 CPoint pbreak=m_pexpandview->GetCursorPos(); int nLine=pbreak.y; //当前文件断点个数 int n_break=m_pfile->compileinfstru.GetSize(); int n_insert=0; //当前文件断点数大于1 if(n_break>=1) { //查找光标所在行对应的断点 for(int i=0;i<=n_break-1;i++) { //获取第i个断点信息 m_pcomstr=(CompStruct *)m_pfile->compileinfstru.GetAt(i); if(m_pcomstr->n_breakline n_breakline==nLine) { //删除断点 OnEditRemovebreak(); return; } } n_insert++; } m_pcomstr=NULL; m_pcomstr=new CompStruct; //存储断点行索引 m_pcomstr->n_breakline=nLine; //设置断点名,断点的个数 n_break=m_pfile->compileinfstru.GetSize(); CString str_winname=_T(""); str_winname.Format("%d",nLine); // str_winname.Format("%d",m_pfile->compileinfstru.GetSize()); //存储断点名 m_pcomstr->str_breakname=str_winname; // void CCrystalTextView::OnToggleBookmark() m_pexpandview->OnToggleBookmark(); //将断点信息存入项目信息 m_pfile->compileinfstru.InsertAt(n_insert,(CObject*)m_pcomstr); // m_pfile->compileinfstru.Add((CObject*)m_pcomstr); m_pDocClass->ExpandAllBreak(); // struct simulator::Breakpoint *p1,*p2; p_mainframe->sim.SetBreakpoint(nLine); // p1=p_mainframe->sim.BreakpointList; /*for(int i=0;i next; } // p_break=(CompStruct*)m_pfile->compileinfstru.GetAt(i); // sim.BreakpointList->value=p_break->n_breakline; p2=new simulator::Breakpoint; p2->value=nLine; p2->next=p1->next; p1->next=p2; // p1=p2; p_mainframe->sim.BreakpointList->value++; */ // } } void CC02IDEView::OnEditRemovebreak() { // TODO: Add your command handler code here //主窗口指针 CMDIFrameWnd *nowframe = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; CMainFrame *p_mainframe = (CMainFrame*)AfxGetApp()->m_pMainWnd; //活动子窗口指针 CMDIChildWnd *nowchild = nowframe->MDIGetActive(); //获得当前项目信息的指针 struct ProjectList * curprobreak=NULL; curprobreak=new ProjectList; curprobreak=(ProjectList *)projectinfo.GetAt(0); m_pfile=new FileList; //项目中的文件数目 int n_filenumber=curprobreak->proinfstru.GetSize(); //声明文件节点 struct fileitem m_pcurnode; for (int j=0;j<=n_filenumber-1;j++) { //取得文件节点信息的第j个项 m_pcurnode=fileitemarray[j]; //如果节点的窗口指针等于当前活动窗口指针 if(m_pcurnode.m_pchildf==nowchild) break; } //获得活动窗口的文件信息 m_pfile=(FileList *)curprobreak->proinfstru.GetAt(j); //声明断点信息结构指针 struct CompStruct *m_pcomstr=NULL; m_pcomstr=new CompStruct; //获得当前活动视图 CCrystalTextView* m_pexpandview=NULL; m_pexpandview=(CCrystalTextView*)nowchild->GetActiveView(); if(m_pexpandview==NULL) return; //编辑控件光标所在行 CPoint pbreak=m_pexpandview->GetCursorPos(); int nLine=pbreak.y; CString str_winname=_T(""); str_winname.Format("%d",m_pfile->compileinfstru.GetSize()); //当前文件断点个数 int n_break=m_pfile->compileinfstru.GetSize(); //当前文件没有断点 if(n_break<=0) return; //查找光标所在行对应的断点 for(int i=0;i<=n_break-1;i++) { //获取第i个断点信息 m_pcomstr=(CompStruct *)m_pfile->compileinfstru.GetAt(i); //如果断点的行信息等于光标所在行 if(m_pcomstr->n_breakline==nLine) { //删除此断点 // if(i== n_break-1) { m_pfile->compileinfstru.RemoveAt(i); m_pexpandview->OnToggleBookmark(); // break; } /* else { for(int k=i; k<=n_break-2;k++) { m_pcomstr=(CompStruct *)m_pfile->compileinfstru.GetAt(k+1); int n_line=m_pcomstr->n_breakline; m_pcomstr=(CompStruct *)m_pfile->compileinfstru.GetAt(k); // str_winname.Format("%d",k); // m_pcomstr=(CompStruct *)m_pfile->compileinfstru.GetAt(k+1); // m_pcomstr->str_breakname=str_winname; m_pcomstr->n_breakline=n_line; } m_pfile->compileinfstru.RemoveAt(n_break-1); m_pexpandview->OnToggleBookmark(); } */ break; } } //更新断点查看树 m_pDocClass->ExpandAllBreak(); p_mainframe->sim.RemoveBreakpoint(nLine); } void CC02IDEView::OnRButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CMenu menu; VERIFY(menu.LoadMenu(IDR_C02IDETYPE)); CMenu* pPopup = menu.GetSubMenu(1); ASSERT(pPopup != NULL); CWnd* pWndPopupOwner = this; while (pWndPopupOwner->GetStyle() & WS_CHILD) pWndPopupOwner = pWndPopupOwner->GetParent(); ClientToScreen(&point); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, pWndPopupOwner); // CCrystalEditView::OnRButtonDown(nFlags, point); } void CC02IDEView::OnUpdateEditBreakpoint(CCmdUI* pCmdUI) { pCmdUI->Enable(true); // TODO: Add your command update UI handler code here } void CC02IDEView::GotoLine(int n_line) { CMDIFrameWnd* mdif=(CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd); CMDIChildWnd*childf=mdif->MDIGetActive(); CCrystalTextView *m_pchildview = (CCrystalTextView *)childf->GetActiveView(); //激活子窗口 childf->SetActiveWindow(); //将子窗口设置为最前 childf->SetForegroundWindow(); // 将子窗口设置为焦点 childf->BringWindowToTop(); PostMessage(WM_NULL,NULL); m_pchildview->ScrollToLine(n_line); CPoint pbreak; pbreak.y=n_line; pbreak.x=0; //设置当前选择文本区域 m_pchildview->SetCursorPos(pbreak); //激活子窗口 childf->MDIActivate(); //将子窗口设置为最前 childf->BringWindowToTop(); // 将子窗口设置为焦点 childf->SetFocus(); } BOOL CC02IDEView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) { // TODO: Add your message handler code here and/or call default //获得视图 CMDIFrameWnd* mdif=(CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd); CMDIChildWnd*childf=mdif->MDIGetActive(); CCrystalTextView *m_pchildview = (CCrystalTextView *)childf->GetActiveView(); // CPoint pbreak=m_pchildview->GetCursorPos(); //用户可见顶行索引 int n_top=m_pchildview->m_nTopLine; // int nLine=pbreak.y; //计算滚动目标行,zDelta/120为滚轮滚动的行数 int sline=n_top-(zDelta/120); //总行数 int n_calline=m_pchildview->GetLineCount(); if(sline<0||sline>=n_calline) return FALSE; //滚动到指定行 m_pchildview->ScrollToLine(sline); return TRUE; // return CCrystalEditView::OnMouseWheel(nFlags, zDelta, pt); } // int CC02IDEView::OnFindNext(int n_outbox,CString str_find) { //全局变量传递到本地变量 CString strnextfind=str_find; //没有输入查找字符串 if(strnextfind.GetLength()==0) AfxMessageBox("Please select menu 'Find' first"); //获得当前视图 CMDIFrameWnd* mdif=(CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd); CMDIChildWnd* childf=mdif->MDIGetActive(); CCrystalTextView* m_pexpandview=NULL; m_pexpandview=(CCrystalTextView*)childf->GetActiveView(); //当前编辑控件的行数 int linenum=m_pexpandview->GetLineCount(); //行索引大于等于编辑控件的总行数 if(findstringcurhang>=linenum) return 0; //保存 搜索字符串的列索引 int pos=-1; //保存 搜索字符串的行索引 int curline=findstringcurhang; //保存 搜索字符串的列索引 int n_pos=-1; //获取当前行字符数 int n_linelength=m_pexpandview->GetLineActualLength(curline); if( n_outbox==1&&(curline==linenum-1)&&findstringcurlie>n_linelength-strnextfind.GetLength()+1) AfxMessageBox("have search to the end"); //保存当前行的字符串 CString strcurline; strcurline= _T(""); //初始化一个保存查询结果的变量 SearchInf * m_pfinditem=NULL; m_pfinditem=new SearchInf; //行长度 int nLen=0; //当前行长度小于搜索字符串的长度,则此行搜索结果返回没有搜索到 if(n_linelength<=findstring.GetLength()) n_pos=-1; //当前行长度大于搜索字符串的长度 else { //获得当前行字符的字节数 if(curline > linenum - 1 || curline < 0) return 0; int nTemp = m_pexpandview->GetLineLength(curline) * sizeof(WCHAR); if(nTemp<=1) { strcurline=_T(" "); } nTemp += 4 * sizeof(WCHAR); //尽量多留点空 // int nLen = myeditctrl.GetLine(i, strline.GetBuffer(nTemp), nTemp); // strline.ReleaseBuffer(); // BOOL bRealReturn; strcurline=m_pexpandview->GetLineChars(curline); // if(nLen > strline.GetLength()) nLen = m_pexpandview->GetLineActualLength(curline); if(nLen>=1 && strcurline[nLen-1]==0xd ) { strcurline = strcurline.Left(--nLen); // bRealReturn=TRUE; } else { strcurline = strcurline.Left(nLen); // bRealReturn=FALSE; } //当前行中搜索起始位置 int liejia=findstringcurlie+1; CString strte=_T(""); //去掉搜索过的字符串 strte = strcurline.Mid(liejia); if(strte.GetLength() linenum - 1 || i < 0) return 0; int nTemp = m_pexpandview->GetLineLength(i) * sizeof(WCHAR); if(nTemp<=1) { strcurline=_T(" "); continue ; } nTemp += 4 * sizeof(WCHAR); //尽量多留点空 // int nLen = myeditctrl.GetLine(i, strline.GetBuffer(nTemp), nTemp); // strline.ReleaseBuffer(); // BOOL bRealReturn; strcurline=m_pexpandview->GetLineChars(i); // if(nLen > strline.GetLength()) nLen = m_pexpandview->GetLineActualLength(i); if(nLen>=1 && strcurline[nLen-1]==0xd ) { strcurline = strcurline.Left(--nLen); // bRealReturn=TRUE; } else { strcurline = strcurline.Left(nLen); // bRealReturn=FALSE; } //将多取的字符串去掉 // strLine=strLine.Left(n_linelength); //如果行字符串的长度不是0 if(strcurline .GetLength()!=0) { //查找子串 n_pos = strcurline.Find(findstring); } //保存当前行的字符串 ,在函数后面需要保存查询结果时使用 // str_line=strcurline; if(n_pos != -1) { //更新全局变量 findstringcurhang=i; findstringcurlie=n_pos; pos=n_pos; break; } // if((n_pos != -1)&&(i==linenum-1)) // i++; nTemp=0; } n_pos=-1; } //搜索不成功 if(i>=linenum) { //不过需要显示对话框 if(n_outbox==1) AfxMessageBox("have search to the end"); //更新全局变量 findstringcurhang=linenum; findstringcurlie=0;//myeditctrl.LineLength(linenum); m_pexpandview->m_bLastSearch=FALSE; // 释放指针 delete m_pfinditem; return 0; } //搜索成功 else { //显示搜索结果的字符串 CString str_output=_T(""); //当前目录名 str_output=GetCurrentDirectory(); //获得当前文件名 CString str_filefind=_T(""); childf->GetWindowText(str_filefind); str_output=str_output+"\\"+str_filefind; //将当前行转化为字符串 CString n_hanglie; n_hanglie.Format("%d",findstringcurhang); str_output=str_output+"("+n_hanglie; //将当前行转化为字符串 n_hanglie.Format("%d",findstringcurlie); str_output=str_output+","+n_hanglie+"):"; //将当前行字符串加入显示字符串 str_output=str_output+strcurline; //将当前窗口指针写入搜索结果 m_pfinditem->m_pchildf=childf; //将字符串位置信息写入搜索结果 int n_line=findstringcurhang; m_pfinditem->n_rowno=findstringcurlie; m_pfinditem->n_lineno=n_line; // strLine=""; strcurline=""; //将文件名和字符串信息写入搜索结果 m_pfinditem->str_filenm=str_filefind; m_pfinditem->str_linetext=str_output; a_searchinfo.Add((CObject*)m_pfinditem); //设置当前选择 // m_pexpandview->ScrollToLine(findstringcurlie); CPoint pselstart,pselend; pselstart.y=findstringcurhang; pselstart.x=findstringcurlie; pselend.y=findstringcurhang; pselend.x=findstringcurlie+findstring.GetLength(); m_pexpandview->SetSelection(pselstart,pselend); //激活子窗口 childf->MDIActivate(); //将子窗口设置为最前 childf->BringWindowToTop(); // 将子窗口设置为焦点 childf->SetFocus(); return 1; } } CString & CC02IDEView::GetCurrentDirectory() { static CString strCurrentPath; strCurrentPath.Empty (); int nBytes = ::GetCurrentDirectory (0, NULL); char *szDir = new char [nBytes + 1]; ::GetCurrentDirectory (nBytes + 1, szDir); strCurrentPath = szDir; // delete [] szDir; return (strCurrentPath); } void CC02IDEView::OnSearchOpenedfile() { // TODO: Add your command handler code here a_searchinfo.RemoveAll(); CFindAllOpen * myfinddlg; // myfinddlg.DoModal(); myfinddlg=new CFindAllOpen; myfinddlg->Create(IDD_DIALOG_FINDALLFILE); myfinddlg->ShowWindow(SW_SHOW); } void CC02IDEView::InsertFunc(CString mystring) { //函数声明的字符串 CString insertshengming=mystring+_T(";")+_T("\r\n"); //插入函数声明位置的行索引 int shengmingline=-1; //要添加函数的窗口索引 int n_addtof=0; n_addtof=functionadd->n_addfileno; //声明子窗口指针 CMDIChildWnd *m_paddchildf; m_paddchildf=fileitemarray[n_addtof].m_pchildf; //当前活动子窗口 m_paddchildf->MDIActivate(); //设置为最前窗口 m_paddchildf->BringWindowToTop(); //设置为焦点 m_paddchildf->SetFocus(); //取当前项目信息 struct ProjectList * curgotopro=NULL; curgotopro=new ProjectList; curgotopro=(ProjectList *)projectinfo.GetAt(0); //项目中的文件总数 int n_filenum=curgotopro->proinfstru.GetSize(); //取要操作的文件信息 FileList * m_pgotofile=NULL; m_pgotofile=new FileList; m_pgotofile=(FileList * )curgotopro->proinfstru.GetAt(n_addtof); //文件中的函数个数 int n_funcnum= m_pgotofile->oa_funcinfstru.GetSize(); //定义一个函数信息指针 FuncStruct* m_ptestfunc=NULL; m_ptestfunc=new FuncStruct; //访问每一个函数 for(int j=0;j<=n_funcnum-1;j++) { //取得第j个函数 m_ptestfunc=( FuncStruct*)m_pgotofile->oa_funcinfstru.GetAt(j); //获得所有函数声明的最大行索引 if(shengmingline n_shengming) shengmingline=m_ptestfunc->n_shengming; } //获得编辑视图 CCrystalTextView* m_paddfuncview=NULL; m_paddfuncview=(CCrystalTextView*)m_paddchildf->GetActiveView(); CCrystalEditView* m_paddeditview=NULL; m_paddeditview=(CCrystalEditView*)m_paddchildf->GetActiveView(); ASSERT(m_paddfuncview!=NULL); // 获取最后一个声明行的下一行索引 shengmingline++; //如果该文件没有任何函数声明 if(shengmingline<=0) { //行字符串 CString strline=_T(""); //编辑控件的总行数 int n_linecal= m_paddfuncview->GetLineCount(); //搜索每一行 for(int ni=0;ni<=n_linecal-1;ni++) { //第ni行的首字符索引 if(ni > n_linecal - 1 || ni < 0) return ; int nTemp = m_paddfuncview->GetLineLength(ni) * 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_paddfuncview->GetLineChars(ni); // if(nLen > strline.GetLength()) int nLen = m_paddfuncview->GetLineActualLength(ni); 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(strline.Find(_T("main"))!=-1) { shengmingline=ni; break; } //行长度小于3,取下一行 if(nLen<3) continue ; } } //设置当前选择 CPoint pt_sel; pt_sel.x=0; pt_sel.y=shengmingline; m_paddfuncview->SetCursorPos(pt_sel); CPoint ptCursorPos; ptCursorPos = m_paddfuncview->GetCursorPos(); int x,y; m_paddfuncview->m_pTextBuffer->InsertText(m_paddfuncview, ptCursorPos.y, ptCursorPos.x, insertshengming, y, x, CE_ACTION_TYPING); // [JRT] ptCursorPos.x = x; ptCursorPos.y = y; m_paddfuncview->SetSelection(ptCursorPos, ptCursorPos); m_paddfuncview->SetAnchor(ptCursorPos); m_paddfuncview->SetCursorPos(ptCursorPos); m_paddfuncview->EnsureVisible(ptCursorPos); //获得编辑控件总行数 int linecal= m_paddfuncview->GetLineCount(); //将光标放在编辑控件的末尾 pt_sel.y=linecal-1; pt_sel.x=m_paddfuncview->GetLineLength(linecal-1); m_paddfuncview->SetCursorPos( pt_sel); //设置插入字符串 CString insertfuncti=_T("\r\n")+mystring+_T("\r\n")+_T("{")+_T("\r\n")+_T("}"); //插入字符串 // CPoint ptCursorPos; ptCursorPos = m_paddfuncview->GetCursorPos(); // int x,y; m_paddfuncview->m_pTextBuffer->InsertText(m_paddfuncview, ptCursorPos.y, ptCursorPos.x, insertfuncti, y, x, CE_ACTION_TYPING); // [JRT] ptCursorPos.x = x; ptCursorPos.y = y; m_paddfuncview->SetSelection(ptCursorPos, ptCursorPos); m_paddfuncview->SetAnchor(ptCursorPos); m_paddfuncview->SetCursorPos(ptCursorPos); m_paddfuncview->EnsureVisible(ptCursorPos); //获得主窗口指针 CMainFrame *nowmainframe=(CMainFrame *) (AfxGetApp()->m_pMainWnd); //重新获得所有文件的函数信息 CDocument * p_activedoc=NULL; p_activedoc=m_paddchildf->GetActiveDocument(); if(p_activedoc==NULL) return; CString str_dirfull=_T(""); str_dirfull=p_activedoc->GetPathName(); p_activedoc->OnSaveDocument(str_dirfull); CompileCurFile(); nowmainframe->ExpandAllFile(); } int CC02IDEView::DeleteFunction(int n_delfile,int n_selfunc) { //函数定义行索引初始化 int n_defineline=0; //目标函数的下一个函数定义行索引初始化 int n_nextfuncdefineline=0; //函数声明行索引初始化 int n_declareline=0; //要操作的文件索引 int n_delfileno=n_delfile; //要操作的窗口指针 CMDIChildWnd *m_paddchildf; m_paddchildf=fileitemarray[n_delfileno].m_pchildf; //当前活动子窗口 m_paddchildf->MDIActivate(); //设置为最前窗口 m_paddchildf->BringWindowToTop(); //设置为焦点 m_paddchildf->SetFocus(); //获得编辑视图 CCrystalTextView* m_paddfuncview=NULL; m_paddfuncview=(CCrystalTextView*)m_paddchildf->GetActiveView(); CCrystalEditView* m_paddeditview=NULL; m_paddeditview=(CCrystalEditView*)m_paddchildf->GetActiveView(); //编辑控件总行数 int linecal= m_paddfuncview->GetLineCount(); //获得当前项目信息指针 struct ProjectList * curgotopro=NULL; curgotopro=new ProjectList; curgotopro=(ProjectList *)projectinfo.GetAt(0); //项目中的文件数目 int n_filenum=curgotopro->proinfstru.GetSize(); //获得当前操作的文件信息指针 FileList * m_pgotofile=NULL; m_pgotofile=new FileList; m_pgotofile=(FileList * )curgotopro->proinfstru.GetAt(n_delfileno); //文件中的函数数目 int n_funcnum= m_pgotofile->oa_funcinfstru.GetSize(); //获得要删除的函数信息指针 FuncStruct* m_ptestfunc=NULL; m_ptestfunc=new FuncStruct; m_ptestfunc=(FuncStruct*)m_pgotofile->oa_funcinfstru.GetAt(n_selfunc); //函数声明行索引 n_declareline=m_ptestfunc->n_shengming; //函数声明行索引 n_defineline=m_ptestfunc->n_dingyi; //初始化下一个函数定义行索引 n_nextfuncdefineline=linecal; //搜索的函数的定义行索引 int n_testlineno=0; //找出删除函数定义位置的下一个行书定义位置的行索引 for(int j=0;j<=n_funcnum-1;j++) { //取索引为j的函数信息 m_ptestfunc=( FuncStruct*)m_pgotofile->oa_funcinfstru.GetAt(j); //函数的定义行索引 n_testlineno=m_ptestfunc->n_dingyi; //获得一个定义行索引,是大于删除函数定义行索引的行索引中最小的 if(n_testlineno>n_defineline&&n_testlineno GetLineActualLength(n_declareline); //选择 CPoint pt_start,pt_end; pt_start.x=0; pt_start.y=n_declareline; pt_end.x=n_linelength; pt_end.y=n_declareline; m_paddfuncview->SetSelection(pt_start,pt_end); //删除函数声明 m_paddeditview->DeleteCurrentSelection(); //选择 n_linelength=m_paddfuncview->GetLineActualLength(n_nextfuncdefineline-1); pt_start.x=0; pt_start.y=n_defineline ; pt_end.x= n_linelength; pt_end.y=n_nextfuncdefineline-1 ; m_paddfuncview->SetSelection(pt_start,pt_end); //删除函数定义 m_paddeditview->DeleteCurrentSelection(); //程序主窗口指针 CMainFrame *nowmainframe=(CMainFrame *) (AfxGetApp()->m_pMainWnd); //更新文件的函数信息 CompileCurFile(); nowmainframe->ExpandAllFile(); return 1; } /* void CC02IDEView::OnDate() { // TODO: Add your command handler code here //定义时间对话框变量 CDateDialog dlg; //如果用户选择好时间格式 if (dlg.DoModal() == IDOK) //在编辑控件中加入时间日期字符串 { //主窗口指针 CMDIFrameWnd * nowframe = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; //活动子窗口指针 CMDIChildWnd *nowchild = nowframe->MDIGetActive(); CCrystalTextView *m_pchildview = (CCrystalTextView *)nowchild->GetActiveView(); CCrystalEditView *m_pchildeditview = (CCrystalEditView *)nowchild->GetActiveView(); CPoint ptCursorPos = GetCursorPos(); ASSERT_VALIDTEXTPOS(ptCursorPos); int x, y; m_pchildeditview->m_pTextBuffer->InsertText(m_pchildeditview, ptCursorPos.y, ptCursorPos.x, dlg.m_strSel, y, x, CE_ACTION_TYPING); // m_pchildview->ReplaceSelection(dlg.m_strSel); } // GetRichEditCtrl().ReplaceSel(dlg.m_strSel); } */ //更新状态条中的行信息,显示光标所在行 void CC02IDEView::OnUpdateLineNumber(CCmdUI* pCmdUI) { //主窗口指针 //CMDIFrameWnd * nowframe = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; //活动子窗口指针 //CMDIChildWnd *nowchild = nowframe->MDIGetActive(); //CCrystalTextView *m_pchildview = (CCrystalTextView *)nowchild->GetActiveView(); //CCrystalEditView *m_pchildeditview = (CCrystalEditView *)nowchild->GetActiveView(); CPoint ptCursorPos = GetCursorPos(); ASSERT_VALIDTEXTPOS(ptCursorPos); //当前光标位置的行索引 int nLine = ptCursorPos.y+1; //将整数转换为字符串 CString string; string.Format (_T ("Line %d"), nLine); //激活状态条行显示 pCmdUI->Enable (TRUE); //设置行显示字符串 pCmdUI->SetText (string); } //更新状态条中的列信息,显示光标所在列 void CC02IDEView::OnUpdateRowNumber(CCmdUI* pCmdUI) { //主窗口指针 //CMDIFrameWnd * nowframe = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; //活动子窗口指针 //CMDIChildWnd *nowchild = nowframe->MDIGetActive(); //CCrystalTextView *m_pchildview = (CCrystalTextView *)nowchild->GetActiveView(); //CCrystalEditView *m_pchildeditview = (CCrystalEditView *)nowchild->GetActiveView(); CPoint ptCursorPos = GetCursorPos(); ASSERT_VALIDTEXTPOS(ptCursorPos); //当前光标位置的列索引 int nRow = ptCursorPos.x+1; //将整数转换为字符串 CString string; string.Format (_T ("Row %d"), nRow); //激活状态条行显示 pCmdUI->Enable (TRUE); //设置行显示字符串 pCmdUI->SetText (string); } int CC02IDEView::CompileCurFile() { //获得当前视图 CMDIFrameWnd* mdif=(CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd); CMainFrame* p_mainfrm=(CMainFrame*)(AfxGetApp()->m_pMainWnd); CMDIChildWnd* childf=mdif->MDIGetActive(); CDocument * p_activedoc=NULL; p_activedoc=childf->GetActiveDocument(); if(p_activedoc==NULL) return 0; CString str_dir=_T(""); CString str_dirfull=_T(""); CString str_dircode=_T(""); CString str_dirvar=_T(""); CString str_direrror=_T(""); CString str_dirllm=_T(""); //获得当前文件名 CString str_file=_T(""); CCJMDIFrameWnd *pFrame = (CCJMDIFrameWnd*)AfxGetApp()->m_pMainWnd; CCJMDIChildWnd *pChild = (CCJMDIChildWnd *) pFrame->GetActiveFrame(); TCHAR* ch_wndtitle=NULL; int n=pChild->GetWindowText(ch_wndtitle,100); // if(n!=0) str_file=ch_wndtitle; // childf->GetWindowText(str_file); str_file=p_activedoc->GetTitle(); //当前目录名 str_dir=GetCurrentDirectory(); str_dirfull=p_activedoc->GetPathName(); if(str_dirfull=="") { str_file.Format("%d",i_newblankfile);//n_file str_file="new file "+str_file; str_dirfull=str_dir+"\\user\\"+str_file+".txt"; p_activedoc->OnSaveDocument(str_dirfull); } else { p_activedoc->OnSaveDocument(str_dirfull); } int i_dircuts=str_dirfull.ReverseFind('\\'); int i_dirlen=str_dirfull.GetLength(); int i_dircutlen=i_dirlen-i_dircuts; str_dir=str_dirfull; str_dir.Delete(i_dircuts,i_dircutlen); //str_dirfull=str_dir+"\\"+str_file+".txt"; str_dircode=str_dir+"\\"+str_file+"code.txt"; str_dirvar=str_dir+"\\"+str_file+"var.txt"; str_direrror=str_dir+"\\"+str_file+"error.txt"; str_dirllm=str_dir+"\\"+str_file+"si02.txt"; // char filename[256]; // filename=&str_dirfull; // CPlCompiler pl(str_dir,str_file); // pl.Compile(); // pl.ListCode(); // pl.Compile(str_dir,str_file); CString Str_out=_T(""); Str_out+="--------------------Copiling project 1--------------------\n"; Str_out+="Compiling...\n"; Str_out=Str_out+str_file+"\n"; p_mainfrm->m_wndOutput.UpDateComp(Str_out,""); com.Init(); com.fin.open(str_dirfull); com.fout.open(str_dircode); //三元式 com.fvar.open(str_dirvar); com.ferror.open(str_direrror); com.fal.open(str_dirllm); com.Compile_C02(str_dirfull); com.i_pass++; com.fout.close(); com.fin.close(); com.fvar.close(); com.ferror.close(); com.fal.close(); p_mainfrm->m_wndOutput.UpDateComp(str_file,str_direrror); return 1; } void CC02IDEView::OnLButtonDblClk(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default // p_child->OnShowTip(nFlags, point); // CCrystalTextView *m_pchildview = (CCrystalTextView *)nowchild->GetActiveView(); // CCrystalEditView *m_pchildeditview = (CCrystalEditView *)nowchild->GetActiveView(); CCrystalEditView::OnLButtonDblClk(nFlags, point); } void CC02IDEView::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CCrystalEditView::OnMouseMove(nFlags, point); pt=point; m_nFlags=nFlags; // SetCaretPos(cur_pos); // ::SetCursorPos(pt.x,pt.y); } void CC02IDEView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: Add your message handler code here and/or call default CCrystalEditView::OnChar(nChar, nRepCnt, nFlags); // pt=point; CPoint cur_pos=GetCaretPos();//::GetCursorPos(&pt); // cur_pos=GetCaretPos(); if(com.i_pass==0) { CMainFrame* p_mainfrm=(CMainFrame*)(AfxGetApp()->m_pMainWnd); p_mainfrm->m_wndOutput.i_displaycomp=0; CompileCurFile(); p_mainfrm->m_wndOutput.i_displaycomp=1; } CMDIFrameWnd * nowframe = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; // CMainFrame * nowmainframe = (CMainFrame*)AfxGetApp()->m_pMainWnd; //活动子窗口指针 CMDIChildWnd *nowchild = nowframe->MDIGetActive(); CChildFrame *p_child=(CChildFrame*)nowframe->MDIGetActive(); CString str_bg=_T(""); //str_bg=CCrystalEditView::GetBgString(nFlags, cur_pos); str_bg=GetBackStr(); // if(str_bgstr==str_bgstrlast) return; CString str_struct=_T(""); if(nChar==46) { str_struct=com.IsVar(str_bg,str_struct); } //if(str_struct!=_T("")) //{ p_child->m_tip_struct.SetEditText(str_struct); p_child->m_tip_struct.Show(); p_child->m_tip_struct.ShowWindow(SW_SHOW); //} str_bgstrlast=str_bg; //nowchild->MDIActivate(); //nowchild->BringWindowToTop(); //nowchild->SetFocus(); } CString CC02IDEView::GetBackStr() { // CPoint cur_pos;//=::GetCursorPos(&pt); // cur_pos=GetCaretPos(); if(com.i_pass==0) { CMainFrame* p_mainfrm=(CMainFrame*)(AfxGetApp()->m_pMainWnd); p_mainfrm->m_wndOutput.i_displaycomp=0; CompileCurFile(); p_mainfrm->m_wndOutput.i_displaycomp=1; } CMDIFrameWnd * nowframe = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd; // CMainFrame * nowmainframe = (CMainFrame*)AfxGetApp()->m_pMainWnd; //活动子窗口指针 CMDIChildWnd *nowchild = nowframe->MDIGetActive(); CChildFrame *p_child=(CChildFrame*)nowframe->MDIGetActive(); str_bgstr=CCrystalEditView::GetBgString(m_nFlags, pt); // str_bgstr=_T(""); if( //r_bgstr==_T("") // p_child->m_tip.IsWindowVisible() //(str_bgstrlast!=str_bgstr)) // && (ptlast.x!=pt.x||ptlast.y!=pt.y)) { // if(p_child->m_tip.IsWindowVisible()) p_child->m_tip.i_ismoved=1; p_child->m_tip.Hide(); p_child->SetTipText(""); ptlast=pt; str_bgstrlast=str_bgstr; return _T(""); } // if(str_bgstr==str_bgstrlast) return; if(str_bgstr!=_T("")) str_output=com.IsVar(str_bgstr,str_output); else { ptlast=pt; str_bgstrlast=str_bgstr; return _T(""); } // if(str_output!=_T("")) // p_child->SetTipText(str_output); ptlast=pt; str_bgstrlast=str_bgstr; if(strcmp(str_output,"")!=0) p_child->m_tip.i_ismoved=0; if(i_usermode!=3) { } else { } return str_output; }