⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c02ideview.cpp

📁 类似vc的集成开发环境
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// 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 <stdio.h>
#include <conio.h>
#include <string.h>

//#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<nLine)
				n_insert=i;

		   //如果断点的行信息等于光标所在行
	 	   if(m_pcomstr->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<n_insert;i++)
	{
		p1=p1->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();    	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -