📄 edit11.c
字号:
gotoxy(19,9); cprintf("%c",217);
gotoxy(9,3); cprintf(" New ");
gotoxy(9,4); cprintf(" Open...");
gotoxy(9,5); cprintf(" Save... ");
gotoxy(9,6); cprintf(" Close ");
for(i=1;i<=10;i++)
{
gotoxy(8+i,7);
cprintf("%c",196);
}
gotoxy(9,8); cprintf(" Exit");
textcolor(15); textbackground(0);
gotoxy(7,1);
cprintf("%c %c File %c %c",179,17,16,179);
switch(n%5)
{
case 0:gotoxy(9,3); cprintf(" New "); break;
case 1:gotoxy(9,4); cprintf(" Open... "); break;
case 2:gotoxy(9,5); cprintf(" Save... "); break;
case 3:gotoxy(9,6); cprintf(" Close "); break;
case 4:gotoxy(9,8); cprintf(" Exit "); break;
}
}
/********************************************************/
if(m%3==1)
{
window(28,2,38,7);
textcolor(0);
textbackground(7);
for(i=0;i<5;i++)
{
gotoxy(1,1+i);
insline();
}
window(1,1,80,25);
gotoxy(27,1);
for(i=1;i<=5;i++)
{
gotoxy(28,1+i);
cprintf("%c",179);
gotoxy(39,1+i);
cprintf("%c",179);
}
for(i=1;i<=11;i++)
{
gotoxy(28+i,2);
cprintf("%c",196);
gotoxy(28+i,7);
cprintf("%c",196);
}
textbackground(0);
gotoxy(30,8); cprintf(" ");
for(i=0;i<7;i++)
{
gotoxy(40,2+i);
cprintf(" ");
}
textbackground(7);
gotoxy(28,2); cprintf("%c",218);
gotoxy(28,7); cprintf("%c",192);
gotoxy(39,2); cprintf("%c",191);
gotoxy(39,7); cprintf("%c",217);
gotoxy(29,3); cprintf(" Cut ");
gotoxy(29,4); cprintf(" Copy ");
gotoxy(29,5); cprintf(" Paste ");
gotoxy(29,6); cprintf(" Clear ");
textcolor(15); textbackground(0);
gotoxy(27,1);
cprintf("%c %c Edit %c %c",179,17,16,179);
switch(n%4)
{
case 0:gotoxy(29,3); cprintf(" Cut "); break;
case 1:gotoxy(29,4); cprintf(" Copy "); break;
case 2:gotoxy(29,5); cprintf(" Paste "); break;
case 3:gotoxy(29,6); cprintf(" Clear "); break;
}
}
/*********************************************************/
if(m%3==2)
{
window(48,2,48,6);
textcolor(0);
textbackground(7);
for(i=0;i<3;i++)
{
gotoxy(1,1+i);
insline();
}
window(1,1,80,25);
gotoxy(47,1);
for(i=1;i<=5;i++)
{
gotoxy(48,1+i);
cprintf("%c",179);
gotoxy(59,1+i);
cprintf("%c",179);
}
for(i=1;i<=11;i++)
{
gotoxy(48+i,2);
cprintf("%c",196);
gotoxy(48+i,6);
cprintf("%c",196);
}
textbackground(0);
gotoxy(50,7); cprintf(" ");
for(i=0;i<6;i++)
{
gotoxy(60,2+i);
cprintf(" ");
}
textbackground(7);
gotoxy(48,2); cprintf("%c",218);
gotoxy(48,6); cprintf("%c",192);
gotoxy(59,2); cprintf("%c",191);
gotoxy(59,6); cprintf("%c",217);
gotoxy(49,3); cprintf("Commands..");
gotoxy(49,5); cprintf("About... ");
for(i=1;i<=10;i++)
{
gotoxy(48+i,4);
cprintf("%c",196);
}
textcolor(15); textbackground(0);
gotoxy(47,1);
cprintf("%c %c Help %c %c",179,17,16,179);
switch(n%2)
{
case 0:gotoxy(49,3); cprintf("Commands.."); break;
case 1:gotoxy(49,5); cprintf("About... "); break;
}
}
}
int menuctrl(Hnode *Hhead,int A)
{
int x,y,i,B,value,flag=100,a,b;
x=wherex(); y=wherey();
if(A==F1) { drawmenu(0,flag); value=300; }
if(A==F2) { drawmenu(1,flag); value=301; }
if(A==F3) { drawmenu(2,flag); value=302; }
if(A==F1||A==F2||A==F3)
{
while((B=bioskey(0))!=ESC)
{
if(flag==0) flag=100;
if(value==0) value=300;
if(B==UP) drawmenu(value,--flag);
if(B==DOWN) drawmenu(value,++flag);
if(B==LEFT)
{
flag=100;
drawmain();
window(2,2,79,23);
textbackground(9);
for(i=0;i<24;i++)
insline();
window(3,3,78,23);
textcolor(10);
view(Hhead);
drawmenu(--value,flag);
}
if(B==RIGHT)
{
flag=100;
drawmain();
window(2,2,79,23);
textbackground(9);
for(i=0;i<24;i++)
insline();
window(3,3,78,23);
textcolor(10);
view(Hhead);
drawmenu(++value,flag);
}
if(B==ENTER)
{
if(value%3==0) b=5;
if(value%3==1) b=4;
if(value%3==2) b=2;
a=(value%3)*10+flag%b;
drawmain();
window(2,2,79,23);
textbackground(9);
for(i=0;i<24;i++)
insline();
window(3,3,78,23);
textcolor(10);
view(Hhead);
gotoxy(x,y);
if(a==10) return Cx;
if(a==11) return Cc;
if(a==12) return Cv;
if(a==13) return DEL;
if(a==4) exit(0);
}
gotoxy(x+2,y+2);
}
drawmain();
window(2,2,79,23);
textbackground(9);
for(i=0;i<24;i++)
insline();
window(3,3,78,23);
textcolor(10);
view(Hhead);
gotoxy(x,y);
}
return A;
}
void main()
{
char a;
int i,A,x,y,flag=0,b;
Hnode *Hhead,*q;
node *p1,*p2;
Hhead=(Hnode *)malloc(sizeof(Hnode));
q=Hhead; Hhead->nextl=NULL;
p1=p2=q->next=(node *)malloc(sizeof(node));
p1->ch=13;
drawmain();
window(2,2,79,23);
textbackground(9);
for(i=0;i<24;i++)
insline();
window(3,3,78,23);
textcolor(10);
while(1)
{
a=A=bioskey(0);
if(a>=32&&a<=127||a==13)
{
if(check(Hhead,wherey(),wherex())<=0&&a>=32&&a<=127)
{
NUM++;
p2->ch=a;
putch(a);
if(NUM==76)
{
p2->next=NULL;
q->nextl=(Hnode *)malloc(sizeof(Hnode));
q=q->nextl; q->nextl=NULL; q->next=NULL;
p1=p2=q->next=(node *)malloc(sizeof(node));
p1->ch=13; p1->next=NULL;
NUM=0;
}
else
{
p2->next=(node *)malloc(sizeof(node));
p2=p2->next;
p2->ch=13;
p2->next=NULL;
}
}
else
{
x=wherex(); y=wherey();
insert(Hhead,wherey(),wherex(),a);
NUM++;
view(Hhead);
gotoxy(x,y);
}
}
if(A!=CR&&A!=CL&&A!=Cc&&A!=Cv&&A!=Cx&&A!=DEL&&value!=0&&A!=F1&&A!=F2&&A!=F3)
{
value=0;
view(Hhead);
}
if(a==13)
{
gotoxy(1,wherey()+1);
q->nextl=(Hnode *)malloc(sizeof(Hnode));
q=q->nextl; q->nextl=NULL; q->next=NULL;
p1=p2=q->next=(node *)malloc(sizeof(node));
p1->ch=13; p1->next=NULL;
NUM=0;
}
x=wherex(); y=wherey();
if((A==LEFT)&&(x!=1)) gotoxy(wherex()-1,wherey());
if((A==LEFT)&&(x==1))
gotoxy(abs(judge(Hhead,wherey()-1)),wherey()-1);
if((A==RIGHT)&&check(Hhead,wherey(),wherex())>0)
gotoxy(wherex()+1,wherey());
if((A==RIGHT)&&check(Hhead,wherey()+1,1)!=0&&check(Hhead,y,x)<=0)
gotoxy(1,wherey()+1);
if((A==RIGHT)&&x==76)
gotoxy(1,wherey()+1);
if((A==UP)&&check(Hhead,wherey()-1,wherex())!=0)
gotoxy(wherex(),wherey()-1);
if((A==UP)&&check(Hhead,wherey()-1,wherex())<=0)
{
if(judge(Hhead,wherey()-1)==0)
gotoxy(-judge(Hhead,wherey()-1)+1,wherey()-1);
else
gotoxy(-judge(Hhead,wherey()-1),wherey()-1);
}
if((A==DOWN)&&check(Hhead,wherey()+1,wherex())!=0)
gotoxy(wherex(),wherey()+1);
if(A==BACK)
{
flag=del(Hhead,wherey(),wherex()-1);
x=wherex()-1; y=wherey();
view(Hhead);
if(flag==0)
{
if(x!=0) gotoxy(x,y);
else gotoxy(x+1,y);
}
if(flag==1)
{
gotoxy(x+1,y);
flag=0;
}
}
A=menuctrl(Hhead,A);
if(A==DEL)
{
x=wherex(); y=wherey();
del(Hhead,wherey(),wherex());
view(Hhead);
gotoxy(x,y);
}
if(A==DEL&&value!=0)
{
if(value>0)
x=wherex(), y=wherey();
else
x=r[0].col, y=r[i].line;
for(i=0;i<abs(value);i++)
{
if(value>0)
del(Hhead,r[i].line,r[i].col);
if(value<0)
del(Hhead,r[abs(value)-1-i].line,r[abs(value)-1-i].col);
}
value=0;
view(Hhead);
gotoxy(x,y);
}
if(A==Cx&&value!=0)
{
if(value>0)
x=wherex(), y=wherey();
else
x=r[0].col, y=r[i].line;
for(i=0;i<abs(value);i++)
{
if(value>0)
del(Hhead,r[i].line,r[i].col);
if(value<0)
del(Hhead,r[abs(value)-1-i].line,r[abs(value)-1-i].col);
}
backup=value; value=0;
view(Hhead);
gotoxy(x,y);
}
if(A==Cc&&value!=0)
{
x=wherex(); y=wherey();
backup=value; value=0;
view(Hhead);
gotoxy(x,y);
}
if(A==Cv&&backup!=0)
{
x=wherex(); y=wherey();
if(backup<0)
for(i=0;i<abs(backup);i++)
insert(Hhead,y,x+i,r[i].ch);
if(backup>0)
for(i=0;i<backup;i++)
insert(Hhead,y,x+i,r[backup-1-i].ch);
view(Hhead);
gotoxy(x,y);
}
if(A==F10)
{
qview(Hhead);
view(Hhead);
gotoxy(x,y);
}
if(A==CL||A==CR) control(A,Hhead);
x=wherex(); y=wherey();
window(1,1,80,25);
textcolor(0);
textbackground(7);
gotoxy(10,25);
cprintf("%-3d",y);
gotoxy(24,25);
cprintf("%-3d",x);
window(3,3,78,23);
textcolor(10);
gotoxy(x,y);
textcolor(10);
textbackground(1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -