📄 editordoc.cpp
字号:
// EditorDoc.cpp : implementation of the CEditorDoc class
//
#include "stdafx.h"
#include "Editor.h"
#include "EditorDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEditorDoc
IMPLEMENT_DYNCREATE(CEditorDoc, CDocument)
BEGIN_MESSAGE_MAP(CEditorDoc, CDocument)
//{{AFX_MSG_MAP(CEditorDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEditorDoc construction/destruction
CEditorDoc::CEditorDoc()
{
// TODO: add one-time construction code here
}
CEditorDoc::~CEditorDoc()
{
}
BOOL CEditorDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
nLineNum=0;
POSITION pos;
pos=lines.GetHeadPosition();
while(pos!=NULL)
{
((CString)lines.GetNext(pos)).Empty();
}
lines.RemoveAll();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CEditorDoc serialization
void CEditorDoc::Serialize(CArchive& ar)
{
CString s("");
int nCount=0;
CString item("");
if (ar.IsStoring())
{
POSITION pos;
pos=lines.GetHeadPosition();
if(pos==NULL)
return;
while(pos!=NULL)
{
item=lines.GetNext(pos);
ar<<item;
item.Empty();//clear the line buffer
}
}
else
{
// TODO: add loading code here
while(1)
{
try{
ar>>item;
lines.AddTail(item);
nCount++;
}
catch(CArchiveException *e)
{
if(e->m_cause!=CArchiveException::endOfFile)
{
TRACE0("Unknown exception loading file!\n");
throw;
}
else
{
TRACE0("End of file reached...\n");
e->Delete();
}
break;
}//end of catch
}//match of while(1)
nLineNum=nCount;
}//match of else
}
/////////////////////////////////////////////////////////////////////////////
// CEditorDoc diagnostics
#ifdef _DEBUG
void CEditorDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CEditorDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEditorDoc commands
void CEditorDoc::DeleteContents()
{
// TODO: Add your specialized code here and/or call the base class
nLineNum=0;
POSITION pos;
pos=lines.GetHeadPosition();
while(pos!=NULL)
{
((CString)lines.GetNext(pos)).Empty();
}
lines.RemoveAll();
CDocument::DeleteContents();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -