📄 c02ideview.cpp
字号:
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<n_nextfuncdefineline)
{
n_nextfuncdefineline=n_testlineno;
}
}
int n_linelength=m_paddfuncview->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;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -