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

📄 pr2comm.cpp

📁 vt100终端仿真程序
💻 CPP
字号:
#include "stdafx.h"
#include "Bh10.h"
#include "Pr2Comm.h"
#include "Communicate.h"

int fFont=0;
int gBaseRow=0;
int gPageTop=0;
int gPr2Para;
int TopOn=0;
int FirstJddw=0;
int bOKI=0;

extern int iStartPrint;
extern int gCurrRow;
extern int gCurrCol;
extern int gLineSpace;
extern CCommunicate *csTermCom;

extern int fPrn;

int Pr2AutoWork()	//自动操作
{
	return 0;
}


int Pr2PaperIn()      //进纸
{

	if (fPrn) return 0;

	if (iStartPrint==2) 
		return 0;

	Bh10PaperIn();
	FirstJddw=0;
//	MessageBox(NULL,"aa","bb",MB_OK);
	csTermCom->SendData("\x80\x1b\x81\x80\x72\x81\x80\x25\x81",9);
	gCurrRow=1;
	gCurrCol=0;
	return 0;
}

int Pr2PaperOut()		//退纸
{
//	Bh10PaperOut();
	if (iStartPrint==1)
	{
		iStartPrint=2;
		gCurrRow=1;
	}
	SendCommToBh10("\x0d\x1b\x2d\x00",4);
//	gCurrCol=1;
	return 0;
}

int Pr2SetOlivetti()	//Olivetti打印方式
{
	return 0;
}

int Pr2SetPassbook()	//存折打印方式
{
	return 0;
}

int Pr2SetPageLen()	//设置页面长度
{
	return 0;
}

int Pr2SetPageTop()	//设置页顶距
{
	gPageTop=gPr2Para;
	if (gLineSpace!=0)
		gBaseRow=gPageTop/(gLineSpace*2);
	return 0;
}

int Pr2SetLineSpace()	//设置行距
{
	Bh10SetLineSpace(gPr2Para);
	
	if (gPageTop!=0 && TopOn==1)
		gBaseRow=gPageTop/(gLineSpace*2);
	else
		gBaseRow=0;
	return 0;
}

int Pr2SetWordSpace()	//设置字距
{
	switch (gPr2Para)
	{
	case 0:
	case 1:
		SendCommToBh10("\x0d\x1b\x2d\x00",4);
		SendCommToBh10("\x1b\x50",2);
		fFont=0;
		break;
	case 2:
		SendCommToBh10("\x0d\x1b\x2d\x00",4);
		SendCommToBh10("\x1b\x4d",2);
		fFont=0;
		break;
	default:
		SendCommToBh10("\x0d\x1b\x2d\x00",4);
		SendCommToBh10("\x1b\x67",2);
		fFont=1;
	}
	return 0;
}

int Pr2Set10CPI()
{
//	SendCommToBh10("\x0d\x1b\x2d\x00",4);
//	SendCommToBh10("\x1b\x50",2);
	fFont=0;
	return 0;
}

int Pr2Set12CPI()
{

//	SendCommToBh10("\x0d\x1b\x2d\x00",4);
//	SendCommToBh10("\x1b\x4d",2);
	fFont=0;
	return 0;
}

int Pr2GotoRow()		//绝对行定位
{
	int pRow;
//	FILE *hFile;

	if (gPr2Para==0) return 0;

//	hFile=fopen("Row.log","a+");
//	fprintf(hFile,"gBaseRow: %d\n",gBaseRow);
//	fprintf(hFile,"gCurrRow: %d\n",gCurrRow);
//	fprintf(hFile,"gPr2Para: %d\n",gPr2Para);

	if (FirstJddw==0)
	{
		FirstJddw=1;
		SendCommToBh10("\x0d\x1b\x2d\x00",4);
		SendCommToBh10("\x1b\x49\xc0\x4c",4);
	}
	pRow=gPr2Para+gBaseRow;

//	fprintf(hFile,"pRow: %d\n",pRow);

	if (pRow>gCurrRow)
	{
		Bh10LineMove(0,pRow-gCurrRow);
//		fprintf(hFile,"LineMove: +%d\n",pRow-gCurrRow);
	}

	else
	{
		if (pRow<gCurrRow)
			Bh10LineMove(1,gCurrRow-pRow);
	}

	gCurrRow=gPr2Para;

//	fprintf(hFile,"\n\n");
//	fclose(hFile);

	return 0;
}

int Pr2LineIn()//相对行定位
{

	if (gPr2Para==0) 
	{
		Bh10PrintData("\x0d",1);
		return 0;
	}

	Bh10LineMove(0,gPr2Para);

	gCurrRow=gCurrRow+gPr2Para;

	return 0;
}

int Pr2GotoCol()		//绝对列定位
{
	char SpaceBuf[512];
	int i;

	Bh10PrintData("\x0d",1);
	memset(SpaceBuf,0x00,sizeof(SpaceBuf));
	
	for (i=0;i<gPr2Para;i++)
		SpaceBuf[i]=0x20;

	Bh10PrintData(SpaceBuf,gPr2Para);

//	gCurrCol=gPr2Para;

	return 0;
}

int Pr2MultiSpace()	//相对列定位
{
	char SpaceBuf[512];
	int i;

	memset(SpaceBuf,0x00,sizeof(SpaceBuf));
	
	for (i=0;i<gPr2Para;i++)
		SpaceBuf[i]=0x20;

	Bh10PrintData(SpaceBuf,gPr2Para);

//	gCurrCol=gCurrCol+gPr2Para;

	return 0;
}

int Pr2ClearError()		//清除错误
{
	return 0;
}

int Pr2ClearAll()		//总清
{
//	Bh10Reset();
	return 0;
}

int Pr2SetDoubleHigh()	//设置倍高
{
	Bh10SetDoubleHigh();
	return 0;
}

int Pr2SetNormal()		//清除倍高
{
	Bh10SetNormal();
	return 0;
}

int Pr2SetBlack()	//设置黑体
{
	return 0;
}

int Pr2SetStandard()	//取消黑体
{
	return 0;
}

int Pr2AskStatus()		//状态请求
{

	if (fPrn) return 0;

	csTermCom->SendData("\x80\x1b\x81\x80\x72\x81\x80\x50\x81",9);
	
	return 0;
}

int Pr2SetTopOn()		//行绝对定位时第一行为页顶距以下
{
	gBaseRow=gPageTop/gLineSpace;
	TopOn=1;

	return 0;
}

int Pr2SetTopOff()		//行绝对定位从页首开始
{
//	if (gLineSpace!=0)
	
	gBaseRow=0;
	
	TopOn=0;

	return 0;
}

int Pr2SetPageTail()
{
	return 0;
}

int Pr2SetDoubleWidth()
{
	Bh10SetDoubleWidth();
	return 0;
}

int Pr2SetNormalWidth()
{
	Bh10SetNormalWidth();
	return 0;
}

int Pr2SetLeft()
{
	return 0;
}

int Pr2SetLine()
{
	return 0;
}

int Pr2ClearLine()
{
	return 0;
}

int SetOKIPrinter()
{
	if (bOKI==0)
	{
		bOKI=1;
	//	if (fPrn) return 0;

	//	if (iStartPrint==2) 
	//		return 0;

		Bh10PaperIn();
		FirstJddw=0;
	//	MessageBox(NULL,"aa","bb",MB_OK);
		csTermCom->SendData("\x80\x1b\x81\x80\x72\x81\x80\x25\x81",9);
	//	gCurrRow=0;
		gCurrCol=0;
	}
	else
		bOKI=0;

	return 0;
}

int SetOKILineSpace()
{
	int Space;

	Space=(gPr2Para*2-16)*2;
	Bh10SetLineSpace(Space);

	return 0;
}

int Pr2SetCharset()
{
	return 0;
}

⌨️ 快捷键说明

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