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

📄 飞翔理科ii-new.txt

📁 一个 数学工具集 有菜单界面 单色显示
💻 TXT
📖 第 1 页 / 共 4 页
字号:
	if(tempchar<128) 
		{
		if((tempchar==13)||(tempchar==10)) 
			{
			space_rest=((space_rest-1)/26)*26;
			if(filedata[i+1]==10)i++;
			}
		else space_rest--;
		}
	else 
		{
		if((space_rest%26)==1)
			{
			if(space_rest==1){i--;break;}
			space_rest--;
			}
		space_rest=space_rest-2;
		i++;
		}
	if((!space_rest)||(space_rest>156)||(CanRead<=i+1))break;
	}
if(filedata[i]==10)filedata[i]=0;else filedata[i+1]=0;
if(CanRead<=i+1)filedata[CanRead]=0;
nextpage_end=nextpage_begin+i;
SetScreen(1);
if(SHIFTaBYTE)filedata[0]=63;//Chr(63)='?'
printf("%s",filedata);
thispage_begin=nextpage_begin;
thispage_end=nextpage_end;
progress();
if(Auto_ByHand=='h'){do cmd=getchar();while(cmd=='q') if(CheckKey('q'))ReleaseKey(cmd);}else cmd=14;
}

void set_nextline()
{
char i;
char space_rest;
char tempchar;
char CanRead;

nextline_begin=thispage_begin;
if(nextline_begin<dataEnd)fseek(fp,nextline_begin,0);
else {cmd=254;return;}
CanRead=fread(filedata,1,30,fp);
if(ftell(fp)>dataEnd)CanRead=CanRead-(ftell(fp)-dataEnd);
space_rest=26;
for(i=0;i<CanRead;i++)
	{
	tempchar=filedata[i];
	if(tempchar<128) 
		{
		if((tempchar==13)||(tempchar==10)) 
			{
			space_rest=0;
			if(filedata[i+1]==10)i++;
			break;
			}
		else space_rest--;
		}
	else 
		{
		if(space_rest==1)
			{
			i--;
			space_rest--;
			break;
			}
		space_rest=space_rest-2;
		i++;
		}
	if((!space_rest)||(space_rest>26))break;
	}
if(filedata[i]==10)filedata[i]=0;else filedata[i+1]=0;
if(CanRead<=i+1)filedata[CanRead]=0;
nextline_end=nextline_begin+i;
thispage_end=nextline_end;
set_nextpage();
}

long lastCrLfused(long thisCrLf)
{
char CrLf[2];
char data[513];
int data_p;
int temp_p;
int chars_read;
long LastCrLf;
char line_spaces_rest;
int i;
char j;
char half;
int k;
long restchars;
char not_end;
char Reach_textbegin;

CrLf[0]=10;CrLf[1]=0;data[512]=0;
i=0;j=0;LastCrLf=0;line_spaces_rest=26;
half=0;not_end=1;Reach_textbegin=0;

do	{
	i++;
	if(Reach_textbegin){LastCrLf=dataBegin-1;break;}
	if(thisCrLf-512*i>dataBegin) fseek(fp,thisCrLf-512*i,0);
	else {Reach_textbegin=1;fseek(fp,dataBegin,0);}
	
	if((chars_read=fread(data,1,512,fp))!=512)data[chars_read]=0;

	data[512]=0;
	if(i==-1)data[thisCrLf-0]=0;
	if(Reach_textbegin)data[(thisCrLf-dataBegin)%512]=0;
	
	data_p=data;
	while ((temp_p=strstr(data_p+1,CrLf))!=NULL) 
		{
		data_p=temp_p;
		LastCrLf=ftell(fp)-chars_read+data_p-data;
		}
		if(LastCrLf!=0)break;
	}while(1)

i=0;
if(LastCrLf-thisCrLf>10000)return((LastCrLf-thisCrLf)%26);//快速处理长段
while (not_end)
	{
	if((LastCrLf+i*512+512)<thisCrLf)
		{
		fseek(fp,LastCrLf+i*512+1,0);fread(data,1,512,fp);
		if(half)k=1;else {k=0;half=0;}
		for(;k<512;k++)
			{
			if(data[k]>127)
				{
				if(!(k-511))half=1;
				if(line_spaces_rest==1)line_spaces_rest=26;
				line_spaces_rest=line_spaces_rest-2;
				k++;
				}
			else 
				{
				if(line_spaces_rest==1)line_spaces_rest=26;
				else line_spaces_rest--;
				}
			if(!line_spaces_rest)line_spaces_rest=26;
			}
		}
	else 
		{
		fseek(fp,LastCrLf+i*512+1,0);
		restchars=thisCrLf-LastCrLf-1-i*512;
		fread(data,1,restchars,fp);
		if(data[restchars-1]==13)data[--restchars]=0;else data[restchars]=0;
		if(half)k=1;else {k=0;half=0;}
		while (k<restchars)
			{
			if(data[k]>127)
				{
				if(line_spaces_rest==1)line_spaces_rest=26;
				line_spaces_rest=line_spaces_rest-2;
				k++;
				}
			else
				{
				//debug[0]=data[k];debug[1]=0;debug[2]=0;
				if(line_spaces_rest==1)line_spaces_rest=26;
				else line_spaces_rest--;
				}
			if(!line_spaces_rest)line_spaces_rest=26;
			k++;
			}
		not_end=0;			
		}
	i++;
	}
return (line_spaces_rest);
}



void set_lastpage()
{
char i;
char space_rest;
char tempchar;
char CanRead;

lastpage_end=thispage_begin-1;
if(lastpage_end>=198+dataBegin){fseek(fp,lastpage_end-198,0);CanRead=fread(filedata,1,199,fp);}
else {fseek(fp,dataBegin,0);CanRead=fread(filedata,1,lastpage_end+1-dataBegin,fp);}

space_rest=26*6;
for(i=CanRead-1;i<CanRead;i--)
	{
	tempchar=filedata[i];
	if(tempchar<128) 
		{
		if(tempchar==10)
			{
			if(space_rest%26){space_rest=space_rest/26*26;if(!space_rest)break;}
			space_rest=space_rest-lastCrLfused(thispage_begin-CanRead+i);
			if(filedata[i-1]==13)i--;
			}
		else space_rest--;
		}
	else 
		{
		if((space_rest%26)==1)
			{
			if(space_rest==1){space_rest=0;i++;break;}
			space_rest--;
			}
		space_rest=space_rest-2;
		i--;
		}
	
	if((!space_rest)||(space_rest>250)||(thispage_begin+i-CanRead<=0))break;
	}
if(filedata[CanRead-1]==10)filedata[CanRead-1]=0;else filedata[CanRead]=0;

lastpage_begin=thispage_begin-CanRead+i;//if(i>CanRead)lastpage_begin=lastpage_begin-256;//char 溢出
SetScreen(1);
if(SHIFTaBYTE)filedata[i]=63;
if((space_rest)&&(space_rest<=26*6)){if(thispage_begin-dataBegin>200){cmd=255;return;}thispage_end=dataBegin-1;set_nextpage();return;}////////
else {printf("%s",filedata+i);memmove(filedata,filedata+i,46);}
thispage_begin=lastpage_begin;
thispage_end=lastpage_end;
progress();
if(Auto_ByHand=='h'){do cmd=getchar();while(cmd=='q') if(CheckKey('q'))ReleaseKey(cmd);}else cmd=14;
}


void set_lastline()
{
char i;
char space_rest;
char tempchar;
char CanRead;

lastline_end=thispage_begin-1;

if(lastline_end>=29+dataBegin){fseek(fp,lastline_end-29,0);CanRead=fread(filedata,1,30,fp);}
else {fseek(fp,dataBegin,0);CanRead=fread(filedata,1,lastline_end+1-dataBegin,fp);}

space_rest=26;

for(i=CanRead-1;i<CanRead;i--)
	{
	tempchar=filedata[i];
	if(tempchar<128) 
		{
		if(tempchar==10)
			{
			if(space_rest!=26)space_rest=0;
			else space_rest=space_rest-lastCrLfused(thispage_begin-CanRead+i);
			if(filedata[i-1]==13)i--;
			}
		else space_rest--;
		}
	else 
		{
		//debug[0]=filedata[i-1];debug[1]=filedata[i];debug[2]=0;
		if(space_rest==1){space_rest=0;i++;break;}
		space_rest=space_rest-2;
		i--;
		}
	
	if((!space_rest)||(space_rest>250)||(thispage_begin+i-CanRead<=0))break;
	}

lastline_begin=thispage_begin-CanRead+i;//if(i>CanRead)lastpage_begin=lastpage_begin-256;//char 溢出
if((space_rest)&&(space_rest<=26)){if(thispage_begin-dataBegin>200){cmd=255;return;}thispage_end=dataBegin-1;}////////
else thispage_end=lastline_begin-1;
set_nextpage();
}


long seeknextCrLf(long from)
{
long seek;
long result;
char data[513];
char CrLf[2];

CrLf[0]=10;CrLf[1]=0;data[512]=0;
seek=from;
result=0;
while(seek+512<dataEnd)
	{
	fseek(fp,seek,0);fread(data,1,512,fp);
	result=strstr(data,CrLf);
	if(result)break;
	seek=seek+512;
	}

if(!result){fseek(fp,seek,0);fread(data,1,dataEnd-seek,fp);data[dataEnd-seek]=0;result=strstr(data,CrLf);}

if(!result)return(dataEnd-1);
else return(seek+result-data);
}

long seeklastCrLf(long from)
{
long seek;
long result;
long Memadd;
char data[513];
char CrLf[2];
char CanRead;

CrLf[0]=10;CrLf[1]=0;data[512]=0;
seek=from;
result=0;
while(seek-512>=dataBegin)
	{
	seek=from-512;
	Memadd=data-1;
	fseek(fp,seek,0);fread(data,1,512,fp);
	while(Memadd=strstr(Memadd+1,CrLf)){result=Memadd;}
	if(result)break;
	else seek=seek-512;
	}
if(!result){if(seek-512<dataBegin){
									fseek(fp,dataBegin,0);
									CanRead=fread(data,1,dataBegin-seek+512,fp);
									seek=dataBegin;data[CanRead]=0;
									result=strstr(data,CrLf);
									}}

if(!result)return(-1);
else return(seek+result-data);
}


long printOneLine(char line,long Line_begin)
{
char chars[28];
char i;
char j;
char spacerest;
char CanRead;

i=0;spacerest=26;
if(!line)filedata[0]=0;
fseek(fp,Line_begin,0);
if(Line_begin+27<=dataEnd)CanRead=fread(chars,1,27,fp);
else CanRead=fread(chars,1,dataEnd-Line_begin,fp);
chars[CanRead]=10;

while(spacerest)
	{
	if(chars[i]>128){i=i+2;spacerest=spacerest-2;}
	else if(chars[i]==13){chars[i]=0x20;i++;spacerest--;}
	else if(chars[i]!=10){i++;spacerest--;}
	else break;
	if(spacerest==1)if(chars[i]>128)break;
	}
for(j=i;j<26;j++)chars[j]=0x20;
chars[26]=0;
strcat(filedata,chars);
return(Line_begin+i);
}


void print_6_paragraph(long page_begin)
{
char i;
char c;
long next_paragraph;
long Head_paragraph[6];
long nextCrLf;

next_paragraph=page_begin;nextCrLf=page_begin;
c=0;

while(c!=28)
	{
	for(i=0;i<6;i++){Head_paragraph[i]=next_paragraph;printOneLine(i,next_paragraph);next_paragraph=seeknextCrLf(next_paragraph)+1;}Head_paragraph[i]=next_paragraph;
	SetScreen(1);
	printf("%s",filedata);

	do c=getchar();while((c!=14)&&(c!=19)&&(c!=20)&&(c!=21)&&(c!=28))
	if(c==21)next_paragraph=Head_paragraph[1];
	else if(c==20){Head_paragraph[0]=seeklastCrLf(Head_paragraph[0]-2)+1;next_paragraph=Head_paragraph[0];}
	else if(c==19){for(i=0;i<6;i++)Head_paragraph[0]=seeklastCrLf(Head_paragraph[0]-2)+1;next_paragraph=Head_paragraph[0];}
	else if(c==14)continue;//next_paragraph=seeklastCrLf(Head_paragraph[0]-1);

	}
	
thispage_begin=Head_paragraph[0];
}


void Delay_or_Inkey()
{
char inkey_value;
int RestTime;

inkey_value=0;

RestTime=(ms-200)/10;
while(RestTime)
	{
	if(CheckKey('q')){do inkey_value=getchar();while(inkey_value=='q') ReleaseKey(inkey_value);cmd=inkey_value;break;}
	else 
		{
		inkey_value=Inkey();
		if(inkey_value){cmd=inkey_value;break;}
		}
	Delay(100);RestTime--;
	}

//if(CheckKey('q')&&inkey_value)ReleaseKey(inkey_value);

}

long treat_SHIFT()
{
char SHIFT_cmd;
char time_cmd;

time_cmd=60;
do	{
	SHIFT_cmd=Inkey();
	Delay(50);
	time_cmd--;
	}while(time_cmd&&(!SHIFT_cmd)&&(SHIFT_cmd!=SHIFT_KEY))


if(SHIFT_cmd==23){thispage_begin=dataBegin;cmd=255;return 1;}
else if(SHIFT_cmd==22){thispage_begin=dataEnd;cmd=255;return 2;}
else if(SHIFT_cmd=='l'){/*SetMark(3)*/;return 2;}

else if(SHIFT_cmd==ESC_KEY){if(FileType==2){KEY=SHIFT_cmd;return 27;}else{cmd=27;return 0;}}
else if((SHIFT_cmd==19)&&(FileType==2)){KEY=19;return 19;}
else if((SHIFT_cmd==14)&&(FileType==2)){KEY=14;return 14;}

else {cmd=255;KEY=0;return 0;}
}

void viewTEXT()
{
char tempchar;

thispage_end=dataBegin-1;

SHIFTaBYTE=0;
if(Auto_ByHand!='h')Auto_ByHand='a';
if(cmd!=255)cmd=0;
if(FileType==255){/*SetMark(3)*/;if(FileType==255)return;}

while(1)
	{
	if(cmd==21){if((thispage_begin==dataEnd)&&(FileType==2)&&(VTorId_i<VTorId_maxID)){KEY=14;return;}else set_nextline();}
	else if(cmd==14){if((thispage_begin==dataEnd)&&(FileType==2)&&(VTorId_i<VTorId_maxID)){KEY=14;return;}else set_nextpage();}
	else if(cmd==19){if((thispage_begin==dataBegin)&&(FileType==2)&&(VTorId_i>VTorId_minID)){KEY=19;return;}else set_lastpage();}
	else if(cmd==20){if((thispage_begin==dataBegin)&&(FileType==2)&&(VTorId_i>VTorId_minID)){KEY=19;return;}else set_lastline();}
	else if(cmd==27){if(FileType==1){if(EXITorNOT())return;else{cmd=255;continue;}}else{KEY=27;return;}}
	else if(cmd=='.'){if(SHIFTaBYTE)SHIFTaBYTE=0;else SHIFTaBYTE=1;thispage_end=thispage_begin-1;set_nextpage();}//调整乱码
	else if(cmd==255){thispage_end=thispage_begin-1;set_nextpage();}//重复刚才的一页
	else if(cmd==254){cmd=getchar();if((cmd==14)&&(FileType==2)&&(VTorId_i<VTorId_maxID)){KEY=14;return;}continue;}
	else if(cmd==SHIFT_KEY){tempchar=treat_SHIFT();if(tempchar<10)continue;else return;}
	else if(cmd==28){print_6_paragraph(thispage_begin);cmd=255;continue;}
	else set_nextpage();

	if(Auto_ByHand=='a')Delay_or_Inkey();
	}
}

char print_short(long from,char maxsize,char x,char y,int focus,int clear)
{
char size;
fseek(fp,from,0);
for(size=0;size<maxsize;size++)
	{
	filedata[size]=getc(fp);
	if ((filedata[size]>127)&&(filedata[size]!=255))filedata[++size]=getc(fp);
	else if((filedata[size]==255)||(size>=maxsize-1)||size>=200-4){size++;break;}
	
	}
if(focus)CurrentSubDir_Name_p=from+size;
if(filedata[size-1]==255)
	{
	{if(focus)CurrentSubDir_Name_p=SubDir_name[CurrentSubDir-fromSubDir];}
	filedata[size-1]=0;
	}
else {filedata[size]='.';filedata[size+1]='.';filedata[size+2]=0;}



    if(clear) ClearScreen();
    if(focus)focus=8;else focus=0;
	WriteWin(4);
    TextOut(x,y,filedata,1+focus);
    
return size;
}

void dir_list()
{
char dir_list_i;
char dir_list_j;
char dir_list_SubDir;
dir_list_SubDir=fromSubDir;

fseek(fp,dir_add+3+dir_list_SubDir*2,0);
dir_list_i=0;
while((dir_list_SubDir<Num_of_SubDir)&&(dir_list_i<5))
	{
	SubDir_add[dir_list_i++]=getc(fp)+getc(fp)*256;
	dir_list_SubDir++;
	}
	
fseek(fp,dir_add+3+Num_of_SubDir*2,0);
dir_list_SubDir=fromSubDir;
while(dir_list_SubDir--)while (getc(fp)!=0xff);
dir_list_SubDir=fromSubDir;dir_list_i=0;
while((dir_list_SubDir<Num_of_SubDir)&&(dir_list_i<5))
	{
	SubDir_name[dir_list_i++]=ftell(fp);
	if(dir_list_SubDir<Num_of_SubDir)while(getc(fp)!=0xff);
	dir_list_SubDir++;
	}
dir_list_SubDir=fromSubDir;

ClearScreen();
while ((dir_list_SubDir-fromSubDir)!=dir_list_i)
	{
	print_short(SubDir_name[dir_list_SubDir-fromSubDir],len_SubDir,12,(dir_list_SubDir-fromSubDir+1)*13+2,dir_list_SubDir==CurrentSubDir,dir_list_SubDir++==fromSubDir);
	}

if(dir_p>3)dir_list_j=dir_p-3;else dir_list_j=0;

Refresh();
}



void printimage(long imageDataFrom,long READto,int width,int height,int x,int y,char imagetype,char fanxian)//imagetype(扫描线) 1>EBK;2 BMP
{
char i;
char c;
char read_x;
char read_y;
long Seek;

⌨️ 快捷键说明

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