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

📄 strindentpage.cpp

📁 代码格式化工具。 其实就是linux下indent的windows版本。
💻 CPP
字号:
// StrIndentPage.cpp : 实现文件
//

#include "stdafx.h"
#include "windent.h"
#include "StrIndentPage.h"
#include ".\strindentpage.h"
#include "windentdlg.h"

extern "C"{
#include "memfile.h"
#include "indent.h"
#include "output.h"
}


// CStrIndentPage 对话框

IMPLEMENT_DYNAMIC(CStrIndentPage, CDialog)
CStrIndentPage::CStrIndentPage(CWnd* pParent /*=NULL*/)
: CDialog(CStrIndentPage::IDD, pParent)
{
}

CStrIndentPage::~CStrIndentPage()
{
}

void CStrIndentPage::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CStrIndentPage, CDialog)
	ON_BN_CLICKED(IDC_TEST, OnBnClickedTest)
END_MESSAGE_MAP()


// CStrIndentPage 消息处理程序

BOOL CStrIndentPage::OnInitDialog()
{
	CDialog::OnInitDialog();

	//Set Edit Box
	static int tabstop[]={12};									// Make tabsize=4
	((CEdit*)GetDlgItem(IDC_EDIT1))->SetTabStops(1,tabstop);	//	...
	((CEdit*)GetDlgItem(IDC_EDIT1))->LimitText(0);				//	...

	SetDlgItemText(IDC_EDIT1,
		"int main()"
		"{"
		"if (1 && 2)"
		"{"
		"	for(;;)"
		"for(;;)"
		"return 11;"
		"func(1,\"\",kk());"
		"}"
		"else if  (false)"
		"{	}}"

		);


	return TRUE;  // return TRUE unless you set the focus to a control
}

void CStrIndentPage::OnBnClickedTest()
{
	CWaitCursor wait;
	
	CWindentDlg* pDlg=(CWindentDlg*)this->GetParent()->GetParent();
	CEdit * pe=(CEdit*)GetDlgItem(IDC_EDIT1);

	
	CString str,str2;
	pe->GetWindowText(str);
	str.Remove('\r');
	int res=indent_string(str,pDlg->GetSetting());

	pe->SetWindowText("");
	MEMFILE* file=get_output();
	int icount=0;
	str.Empty();
	static char buf[200];
	int size1=mf_length(file);
	pe->ShowWindow(SW_HIDE);
	pe->SetSel(0,-1);
	while((icount=mf_read(file,buf,200))>0)
	{
		CString str(buf,icount);
		str.Replace("\n","\r\n");
		pe->ReplaceSel(str);
	}
	
	pe->ShowWindow(SW_SHOW);
	if (res!=0)
	{
		const char * pstr=0;
		switch(res)
		{
		case invocation_error:
			pstr="invocation_error";break;
		case indent_error:
			pstr="indent_error";break;
		case indent_punt:
			pstr="indent_punt";break;
		case indent_fatal:
			pstr="indent_fatal";break;
		case system_error:
			pstr="system_error";break;
		default:
			pstr="unknow_error";break;
		}
		AfxMessageBox(pstr,MB_OK);
	}
	
}

⌨️ 快捷键说明

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