📄 ideview.cpp
字号:
void CIDEView::OnChange()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CEditView::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
CIDEDoc *pDoc=GetDocument();
CString str;
pDoc->SetModifiedFlag(1);
str=pDoc->GetTitle();
if(str.Right(1)!="*")
{
str=str+"*";
pDoc->SetTitle(str);
}
PaintLeft();
}
//画左边的显示条
void CIDEView::PaintLeft()
{
CBrush brushb(RGB(245,245,230));
CDC* hdc;
hdc=GetWindowDC();
CRect rect;
GetClientRect(&rect);
hdc->FillRect (CRect(rect.left+2,rect.top+2,rect.left+m_LineHeight+7,rect.Height()+2),&brushb);//画底色
brushb.DeleteObject();
int nFirstVisible=m_pEdit->GetFirstVisibleLine();//得到当前显示的最上端的行号
CBrush OrigBrush,brushf(RGB(255,0,0));
CBrush *oldBrush=(CBrush*)hdc->SelectObject(brushf);
OrigBrush.FromHandle((HBRUSH)oldBrush);
hdc->SelectObject(&OrigBrush);
OrigBrush.DeleteObject();
brushf.DeleteObject();
}
void CIDEView::OnPaint()
{
// TODO: Add your message handler code here
CEditView::OnPaint();
PaintLeft();
// Do not call CEditView::OnPaint() for painting messages
}
void CIDEView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
PaintLeft();
switch(nChar)
{
case VK_UP:
m_nCurLn=m_nCurLn>0?m_nCurLn-1:0;
break;
case VK_DOWN:
m_nCurLn=m_nCurLn+1;
break;
case VK_LEFT:
case VK_BACK:
m_nCurCol=m_nCurCol>0?m_nCurCol-1:0;
break;
case VK_SPACE:
case VK_RIGHT:
m_nCurCol=m_nCurCol+1;
break;
case VK_RETURN:
m_nCurLn+=1;
m_nCurCol=0;
break;
case VK_ESCAPE:
m_pMainFrame->ShowControlBar(m_pwndOutBar,0,1);
break;
case VK_TAB:
m_nCurCol+=8;
break;
}
DisplayLnCol();
CEditView::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CIDEView::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
PaintLeft();
CEditView::OnKeyUp(nChar, nRepCnt, nFlags);
}
void CIDEView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
PaintLeft();
CString str;
int nChar=m_pEdit->CharFromPos(point);
m_nCurLn=HIWORD(nChar);
m_nCurCol=LOWORD(nChar);
str.Format("行:%d,列:%d",m_nCurLn,m_nCurCol);
m_pwndStatusBar->SetPaneText(1,str,1);
CEditView::OnLButtonDown(nFlags, point);
}
void CIDEView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
PaintLeft();
CEditView::OnLButtonUp(nFlags, point);
}
void CIDEView::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
PaintLeft();
CEditView::OnLButtonDblClk(nFlags, point);
}
void CIDEView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
PaintLeft();
CEditView::OnMouseMove(nFlags, point);
}
void CIDEView::DisplayCodeInfo()
{
TREENODE_LPV tnlpvTemp;
TREE_FILE trfTemp;
CString strFile=m_pIDEDoc->GetPathName();
int nLen=m_vectorSymbol.size();
CString strCode;
int i;
//-----------删掉相同的信息-----------
HTREEITEM hFindRoot=m_pTreeCtrl->GetRootItem();
while(hFindRoot)
{
if(m_pTreeCtrl->GetItemText(hFindRoot)==strFile)
m_pTreeCtrl->DeleteItem(hFindRoot);
hFindRoot=m_pTreeCtrl->GetNextItem(hFindRoot,TVGN_NEXT);
}
m_vectorTreeNode_Lpv.clear();
//------------------------------------
GetWindowText(strCode);
HTREEITEM hRoot=m_pTreeCtrl->InsertItem(strFile,0,0);
HTREEITEM hKeyWordSubRoot=m_pTreeCtrl->InsertItem("关键字",hRoot,0);
HTREEITEM hIdSubRoot=m_pTreeCtrl->InsertItem("变量",hRoot,0);
HTREEITEM hConstSubRoot=m_pTreeCtrl->InsertItem("常量",hRoot,0);
HTREEITEM hOprSymSubRoot=m_pTreeCtrl->InsertItem("运算符",hRoot,0);
HTREEITEM hBndSymSubRoot=m_pTreeCtrl->InsertItem("界符",hRoot,0);
HTREEITEM hIllegalCharSubRoot=m_pTreeCtrl->InsertItem("非法字符",hRoot,0);
bool bKeyWord=0;
bool bId=0;
bool bConst=0;
bool bOprSym=0;
bool bBndSym=0;
bool bIllegalChar=0;
for(i=0;i<nLen;i++)
{
switch(m_vectorSymbol[i].lpProperty)
{
case KeyWord:
tnlpvTemp.hTreeItem=m_pTreeCtrl->InsertItem(strCode.Mid(m_vectorSymbol[i].nStrPos,m_vectorSymbol[i].nStrLen),hKeyWordSubRoot,0);
bKeyWord=1;
break;
case Id:
tnlpvTemp.hTreeItem=m_pTreeCtrl->InsertItem(strCode.Mid(m_vectorSymbol[i].nStrPos,m_vectorSymbol[i].nStrLen),hIdSubRoot,0);
bId=1;
break;
case Const:
tnlpvTemp.hTreeItem=m_pTreeCtrl->InsertItem(strCode.Mid(m_vectorSymbol[i].nStrPos,m_vectorSymbol[i].nStrLen),hConstSubRoot,0);
bConst=1;
break;
case OprSym:
tnlpvTemp.hTreeItem=m_pTreeCtrl->InsertItem(strCode.Mid(m_vectorSymbol[i].nStrPos,m_vectorSymbol[i].nStrLen),hOprSymSubRoot,0);
bOprSym=1;
break;
case BndSym:
tnlpvTemp.hTreeItem=m_pTreeCtrl->InsertItem(strCode.Mid(m_vectorSymbol[i].nStrPos,m_vectorSymbol[i].nStrLen),hBndSymSubRoot,0);
bBndSym=1;
break;
case IllegalChar:
tnlpvTemp.hTreeItem=m_pTreeCtrl->InsertItem(strCode.Mid(m_vectorSymbol[i].nStrPos,m_vectorSymbol[i].nStrLen),hIllegalCharSubRoot,0);
bIllegalChar=1;
break;
}
tnlpvTemp.lpv=m_vectorSymbol[i];
m_vectorTreeNode_Lpv.push_back(tnlpvTemp);
}
if(!bKeyWord)
m_pTreeCtrl->DeleteItem(hKeyWordSubRoot);
if(!bId)
m_pTreeCtrl->DeleteItem(hIdSubRoot);
if(!bConst)
m_pTreeCtrl->DeleteItem(hConstSubRoot);
if(!bOprSym)
m_pTreeCtrl->DeleteItem(hOprSymSubRoot);
if(!bBndSym)
m_pTreeCtrl->DeleteItem(hBndSymSubRoot);
if(!bIllegalChar)
m_pTreeCtrl->DeleteItem(hIllegalCharSubRoot);
trfTemp.vectorTnl=m_vectorTreeNode_Lpv;
trfTemp.szFile=(LPSTR)(LPCSTR)strFile;
m_pwndWorkSpaceBar->AddTRF(trfTemp);
m_pTreeCtrl->Expand(hRoot,TVE_EXPAND);
}
void CIDEView::OnRButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
BCMenu *menuPopup;
BCMenu menu;
menu.LoadMenu(IDR_IDETYPE);
if(m_pMainFrame->GetScreenStatus())
menuPopup=(BCMenu*)menu.GetSubMenu(2);
else
menuPopup=(BCMenu*)menu.GetSubMenu(1);
ClientToScreen(&point);
menuPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,point.x,point.y,this);
menuPopup->DestroyMenu();
}
void CIDEView::OnSelall()
{
// TODO: Add your command handler code here
CString str;
GetWindowText(str);
m_pEdit->SetSel(0,str.GetLength(),1);
}
void CIDEView::DisplayLnCol()
{
CString str;
str.Format("行:%d,列:%d",m_nCurLn,m_nCurCol);
m_pwndStatusBar->SetPaneText(1,str,1);
}
void CIDEView::OnCaptureChanged(CWnd *pWnd)
{
// TODO: Add your message handler code here
PaintLeft();
CEditView::OnCaptureChanged(pWnd);
}
void CIDEView::OnPaintLeft(WPARAM wParam,LPARAM lParam)
{
PaintLeft();
}
void CIDEView::OnClean()
{
// TODO: Add your command handler code here
CString str;
CString strLeft,strRight;
int nPos;
str=m_pIDEDoc->GetPathName();
nPos=str.ReverseFind('\\');
strLeft=str.Left(nPos+1);
strRight=str.Right(str.GetLength()-nPos-1);
if(strRight.Right(4)==".pas")
str=strLeft+strRight.Left(strRight.GetLength()-4)+"_LexAnanlysisResult.dat";
else
str=strLeft+strRight+"_LexAnanlysisResult.dat";
if(GetFileAttributes(str)==-1)
return;
CFile file;
file.Remove(str);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -