3 Star 9 Fork 7

Gitee 极速下载/WinMerge

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/winmerge/winmerge
克隆/下载
OutputDoc.cpp 2.94 KB
一键复制 编辑 原始数据 按行查看 历史
// OutputDoc.cpp : implementation of the COutputDoc class
//
#include "stdafx.h"
#include "OutputDoc.h"
#include "OutputView.h"
#include "utils/filesup.h"
#include "ccrystaltextmarkers.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COutputDoc
IMPLEMENT_DYNCREATE(COutputDoc, CDocument)
BEGIN_MESSAGE_MAP(COutputDoc, CDocument)
//{{AFX_MSG_MAP(COutputDoc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COutputDoc construction/destruction
#pragma warning(disable:4355)
COutputDoc::COutputDoc()
: m_pMarkers(new CCrystalTextMarkers())
, m_nMaxLineCount(10000)
{
m_pMarkers->SetMarker(_T("warn"), "[WARN]", 0, COLORINDEX_MARKERBKGND1);
m_pMarkers->SetMarker(_T("error"), "[ERROR]", 0, COLORINDEX_MARKERBKGND2);
m_xTextBuffer.InitNew();
}
COutputDoc::~COutputDoc()
{
}
BOOL COutputDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return false;
return true;
}
void COutputDoc::AppendLineWithAutoTrim(const String& text)
{
CCrystalTextBuffer& buf = m_xTextBuffer;
int nEndLine, nEndChar;
POSITION pos = GetFirstViewPosition();
COutputView* pOutputView = static_cast<COutputView*>(GetNextView(pos));
const bool isCursorAtLastLine = (pOutputView && pOutputView->GetCursorPos().y + 1 == buf.GetLineCount());
buf.InsertText(pOutputView, buf.GetLineCount() - 1, 0, text.c_str(), text.length(), nEndLine, nEndChar, 0, false);
if (buf.GetLineCount() > m_nMaxLineCount)
{
const int nDeleteLines = m_nMaxLineCount / 10;
buf.DeleteText(pOutputView, 0, 0, nDeleteLines, 0, 0, false);
nEndLine -= nDeleteLines;
}
if (isCursorAtLastLine)
{
CEPoint pt{ nEndChar, nEndLine };
pOutputView->SetCursorPos(pt);
CEPoint ptStart{ 0, (std::max)(0, nEndLine - pOutputView->GetScreenLines()) };
CEPoint ptEnd{ 0, (std::max)(0, nEndLine) };
pOutputView->EnsureVisible(ptStart, ptEnd);
}
}
void COutputDoc::ClearAll()
{
CCrystalTextBuffer& buf = m_xTextBuffer;
POSITION pos = GetFirstViewPosition();
COutputView* pOutputView = static_cast<COutputView*>(GetNextView(pos));
buf.DeleteText(pOutputView, 0, 0,
buf.GetLineCount() - 1, 0, 0, false);
}
/////////////////////////////////////////////////////////////////////////////
// COutputDoc serialization
void COutputDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// COutputDoc diagnostics
#ifdef _DEBUG
void COutputDoc::AssertValid() const
{
CDocument::AssertValid();
}
void COutputDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// COutputDoc commands
void COutputDoc::DeleteContents()
{
CDocument::DeleteContents();
m_xTextBuffer.FreeAll();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/mirrors/WinMerge.git
git@gitee.com:mirrors/WinMerge.git
mirrors
WinMerge
WinMerge
master

搜索帮助