home *** CD-ROM | disk | FTP | other *** search
Wrap
#include <stdio.h> #include <dos.h> #include <conio.h> #include <ctype.h> #include <dir.h> #include <sys\stat.h> #include <fcntl.h> char title[80],subtitle[80]; FILE *fp_menu, *fp_db; #define black 0x0 #define blue 0x10 #define green 0x20 #define cyan 0x30 #define red 0x40 #define white 0x70 #define yellow 33 #define ewhite 37 #define blue_back 44 #define green_back 42 #define back_black 40 #define back_red 41 #define back_green 42 #define back_yellow 43 #define back_blue 44 #define back_magenta 45 #define back_cyan 46 #define back_white 47 #define fore_black 30 #define fore_red 31 #define fore_green 32 #define fore_yellow 33 #define fore_blue 34 #define fore_magenta 35 #define fore_cyan 36 #define fore_white 37 #define UP 6 /* used in edd() */ #define DOWN 7 #define PgUp 18688 #define PgDn 20736 #define NOTHING 0 /* used in edd() */ #define DOUBLE 0 /* using in aframe() */ #define SINGAL 1 #define CLEAR 2 /* used in aframe*/ #define YES 1 /* using in want_cursor() */ #define NO 0 /* using in want_cursor() */ #define MENUSIZE 12 #define DBSIZE 30 #define DB 1 #define READ 2 #define MENU 2 #define EMPTY 3 #define IS_SUBMENU 1 #define ISLEAF 0 #define Alt_C 11776 #define Alt_X 11520 #define Alt_Y 5376 #define Alt_Q 4096 #define Alt_D 8192 #define Alt_Z 11264 struct DD { struct EE { char name[10]; char mean[20]; char mainkey[4][12]; char path[30]; char serve; /*if*/ char flag; } db[DBSIZE]; int count; } *q; struct AA { struct BB { char name[40]; int isleaf; char shortn[11]; int row; int col; int pos; int total; struct DD *pdb; } men[MENUSIZE]; int countm; int count; struct AA *last, *next; } *root,*work, *p,*tail,*work2p; int deep; /* this is depth of menu tree */ int func; /* pointer of function */ char *item;/* name of applition system */ char shortname[14]; /* shortname of current item */ static char number[24][3]={" ","0","1","2","3","4","5","6","7","8","9", "a","b","c","d","e","f","g","h","i","j","k","l","m" }; char *spaces=" "; char screen[25][81]; int modifed=0; int title_d=0; int *fpos; int edit_flag; char *bt[2]={ "ú├ú─ú┬ú┴ú╟ ú┤íúú░ ░µ (═°┬τ░µ)", "╥╗ ╛┼ ╛┼ ╥╗ ─Ω ╦─ ╘┬ ",}; main(argc,argv) int argc; char *argv[]; { int h,total,showx,showy,delay; int choice; clear_win(0,0,24,79,6,0,0x70); if ((strcmp(argv[2],"wh"))!=0) for(;;); title[0]='\0'; subtitle[0]='\0'; shortname[0]='\0'; deep=0; root=work=work2p=tail=NULL; cs(); func=0; delay=0; for(;;){ clear_win(0,0,24,79,6,0,white); clear_win(6,13,18,72,6,0,black); clear_win(6,12,17,70,6,0,blue); gframe(6,12,18,70,0,0|30); disp_menu0(); choice=get_choice(0,3); switch(choice){ case 0 : strcpy(shortname,"ROOT" ); strcpy(title,shortname); titles(); clear_win(0,0,24,79,6,0,white); func=1; delay=0; break; case 1 : func=2; if (root->count==1) { clear_win(0,0,24,79,6,0,white); clear_win(8,24,16,62,6,0,black); clear_win(7,22,15,60,6,0,blue); printf("\033[10;27H\033[1;33;44m╙ª╙├╧╡═│ [ %s ] ╙╨╫╙╧╡═│┬≡ ?",title); printf("\033[13;33H\033[0;33;42m[ %s ]\033[13;48H[ %s ]","YES "," NO "); *fpos=0; choice=get_yn(13,33,48,fpos); if(choice=='n' || choice=='N') { strcpy(root->men[0].name,shortname); work=root; work->men[0].isleaf=ISLEAF; if (work->men[0].pdb==NULL) { getmem(DB); work->men[0].pdb=q; getdb(0); } else modidb(0); clear_win(1,3,20,78,6,0,white); func=2; delay=0; break; } } item=title; add(); func=2; delay=0; break; case 2 : func2(); modifed=1; func=3; clear_win(0,0,24,79,6,0,white); delay=0; break; case 3 : disp_menu0(); if ( ! modifed) { clear_win(0,0,24,79,6,0,white); printf("\033[10;2H\033[1;%d;%d╛»╕µ : ╚⌠─·╘÷╠φ┴╦╫╙╧╡═│╢°▓╗╔Φ╝╞▓╦╡Ñ,╔·│╔╡─▓╦╡Ñ╜½╬▐╖¿╟²╢» . . .",fore_white,back_red); getcc(); } wtofile(); return; default :delay=1; break; } /*end switch*/ } } get_yn(row,col1,col2,flag) int row,col1,col2,*flag; { int i,key; static char ret[2][5]={"YES "," NO "}; if(*flag==0) i=col1; else i=col2; printf("\033[%u;%uH\033[1;33;%um[ %s ]\033[%u;%uH",row,i,back_black,ret[*flag],row,i); for(;;){ key=getcc(); switch(key) { case 'n': case 'N' : i=col2; printf("\033[%u;%uH\033[0;33;42m[ %s ]",row,col1,ret[0]); printf("\033[%u;%uH\033[1;33;%um[ %s ]\033[%u;%uH",row,i,back_black,ret[1],row,i); return('N'); case 'y': case 'Y': i=col1; printf("\033[%u;%uH\033[0;33;42m[ %s ]",row,col2,ret[1]); printf("\033[%u;%uH\033[1;33;%um[ %s ]\033[%u;%uH",row,i,back_black,ret[0],row,i); return('Y'); case 13 : if(i==col1) return('Y'); else return('N'); case 19200 : if(i==col2) {i=col1; printf("\033[%u;%uH\033[0;33;42m[ %s ]",row,col2,ret[1]); printf("\033[%u;%uH\033[1;33;%um[ %s ]\033[%u;%uH",row,i,back_black,ret[0],row,i); } break; case 19712 : if(i==col1) {i=col2; printf("\033[%u;%uH\033[0;33;42m[ %s ]",row,col1,ret[0]); printf("\033[%u;%uH\033[1;33;%um[ %s ]\033[%u;%uH",row,i,back_black,ret[1],row,i);} break; default : break; } } } cs(){ char name[40],shortt[11],path[30],w_flag[2],w_share[2]; int fir_pos,count; int r,c,flag,i,j,h; strcpy(shortname,"bt"); strcpy(title,shortname); getmem(MENU); tail=root=p; root->last=root; work2p=root; work=root; if ((fp_menu=fopen("menu.txt","r"))==NULL) return(1); fp_db=fopen("db.txt","r"); work->count=work->countm=0; for (i=0;i<MENUSIZE ; ++i ){ if (feof(fp_menu)) break; for(r=0; r<40; ++r) name[r]='\0'; for(r=0; r<11; ++r) shortt[r]='\0'; flag=fir_pos=count=r=c=0; fscanf(fp_menu,"#%[^#]#,#%[^#]#,%d,%d,%d,%d,%d\n",name,shortt,&flag, &fir_pos,&count,&r,&c); if (i>1 && ! strcmp(name,"═╦│÷")) { for(j=0; j<11; ++j) shortname[j]='\0'; strncpy(shortname,work->men[i-1].shortn,strlen(work->men[i-1].shortn)-1); for (i=0; i<MENUSIZE; ++i){ p->men[i].shortn[0]='\0'; strcpy(p->men[i].shortn,shortname); strcat(p->men[i].shortn,number[i+1]); } i=0; getmem(MENU); p->count=p->countm=0; } /*end of if */ strcpy(work->men[i].name,name); strcpy(work->men[i].shortn,shortt); work->men[i].isleaf=flag; work->men[i].pos=fir_pos; work->men[i].total=count; work->men[i].row=r; work->men[i].col=c; work->count++; work->countm++; if (flag==ISLEAF && fp_db!=NULL) { getmem(DB); work->men[i].pdb=q; q->count=count; work->countm--; for(r=0; r<count; r++) { fscanf(fp_db,"#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#,#%[^#]#\n",q->db[r].mean,\ q->db[r].mainkey[0],q->db[r].mainkey[1],q->db[r].mainkey[2],\ q->db[r].mainkey[3],q->db[r].name,w_flag,w_share,q->db[r].path); q->db[r].flag=w_flag[0];q->db[r].serve=w_share[0]; } } /*if*/ } for(j=0; j<11; ++j) shortname[0]='\0'; strncpy(shortname,work->men[1].shortn,strlen(work->men[1].shortn)-1); for(i=0; i<MENUSIZE; ++i){ p->men[i].shortn[0]='\0'; strcpy(p->men[i].shortn,shortname); strcat(p->men[i].shortn,number[i+1]); } fclose(fp_db); fclose(fp_menu); } line(color1,color2,str) int color1,color2; char *str; { clear_win(23,0,23,79,6,0,color2); printf("\033[24;0H\033[0;%d;%dm%s",color1,back_red,str); } get_choice(h,max) int h; int max; { int choice; for(;;){ ptime(); choice=getcc(); switch(choice) { case 18432 : func--; if (func < h) func=max; return(-1); case 20480 : func++; if (func > max) func=h; return(-1); case 13 : return(func); default : if (choice>='0' && choice <='9') { if (choice=='0') { func=max; return(max);} choice-= '0'; if (choice<=max) { func=choice+h-1; return(func); } } break; } } } disp_menu0(){ int row; static char numberi[][2]={ "1","2","3","0","4","5" }; static char function1[4][40]={ "ú▒ ╔·│╔╙ª╙├╧╡═│▒Ω╠Γ" , "ú▓ ╔·│╔╙ª╙├╧╡═│▓╦╡Ñ", "ú│ ╔Φ╝╞▓╦╡Ñ╧╘╩╛╕±╩╜" , "ú░ ═╦│÷", }; int i; row=8; for (i=0; i<=3; ++i) { if(func==i) printf("\033[%d;32H\033[0;0;7m%s",row,function1[i]); else printf("\033[%d;32H\033[1;33;44m%s",row,function1[i]); row+=2; } printf("\033[17;34H\033[1;33;44m╟δ─·╤í╘±[ %s ]\033[17;46H",numberi[func]); return; } now_cursor(x,y) int *x,*y; { union REGS r; r.h.ah=3; r.h.bh=0; int86(0x10,&r,&r); *x = r.h.dh; *y = r.h.dl; return; } ptime(){ struct date today; struct time now; getdate(&today); printf("\033[24;1H\033[0;%u;%um%*sDATE %u.%u.%u",fore_white,back_red,50," ",today.da_year,today.da_mon,today.da_day); gettime(&now); printf(" CLOCK %02d:%02d:%02d",now.ti_hour,now.ti_min,now.ti_sec); return; } clear_win(startx,starty,endx,endy,action,line,attribe) int startx,starty; int endx,endy; int action,line,attribe; { union REGS r; r.h.ah=action; r.h.al=line; r.h.bh=attribe; r.h.ch=startx; r.h.cl=starty; r.h.dh=endx; r.h.dl=endy; int86(0x10,&r,&r); return; } edd(ss,length,row,col) char *ss; int length; int row; int col; { int flag; static int insert=0; int col1,i; int ch; char *t,*s; t=ss; s=ss; col1=col+1; flag=0; length--; printf("\033[%u;%uH\033[1;33;46m%s",row,col+1,ss); printf("\033[%u;%uH",row,col1); ch=getcc(); for(;;){ switch(ch){ case 19200 : /* <--- */ if (t>ss) {t--;col1--;}/*pointer compete ss for heat pointer*/ break; case 19712 : /* ---> */ if (*t && t<ss+length-1) {col1++;t++;} break; case 9 : /* right tab */ for (i=0; i<8; ++i) if (*t && t<ss+length-1) {col1++; t++;} break; case 3840 : for (i=0; i<8; ++i) /*left tab*/ if (t>ss) { t--;col1--; } break; case 18688 : return(PgUp); case 20736 : return(PgDn); case 15104 : /* F1 key */ case Alt_D : case Alt_C : case Alt_Q : case Alt_Y : case Alt_Z : case Alt_X : return(ch); case 18432 : printf("\033[%u;%uH\033[1;33;44m%s",row,col+1,ss); return(UP); /* ^ */ case 20480 : printf("\033[%u;%uH\033[1;33;44m%s",row,col+1,ss); return(DOWN); case 8 : /* backspace */ case 21248 : flag++; if (ch!=8) s=t; else { if (t>ss) {s=t-1; col1--;} else break; } while ((*s)&&(s<ss+length-1)) {*s = *(1+s); s++;} if (ch!=8) s=t; else { if (t>ss) s=t-1; else break; } printf("\033[%u;%uH\033[1;33;44m%s ",row,col1,s); printf("\033[%u;%uH\033[1;33;44m%s",row,col1,s); if (ch==8 && t>ss) { t--; /*col1--; */} edit_flag=1; break; case 13 : /* return */ printf("\033[%u;%uH\033[1;33;44m%s",row,col+1,ss); if (flag) return(1); return(NOTHING); case 20992 : /* insert */ insert=1-insert; break; case 18176 : col1=col; /*home*/ t=ss; break; case 20224 : /*end*/ while ((*t)&&(t<ss+length)) { t++; col1++;} t--; col1--; break; default : if (ch%256==0) break;/*goto begin;divid others gongkeys*/ flag++; edit_flag=1; if (insert==0) { /* Ins off */ if ((*t)&&(t<ss+length)) *t=ch; else if (t<ss+length) { *t=ch; *(t+1)='\0'; } printf("\033[%u;%uH\033[1;33;44m%s",row,col1,t); if (t<ss+length) {t++; col1++;} break; } s=t; while ((*s++)&&(s<ss+length)) ; /* Ins on */ if (s>ss+length) {s=ss+length;*s='\0';s--;} while (s>t) { *s = *(s-1); s--;} *t=ch; printf("\033[%u;%uH\033[1;33;44m%s",row,col1,t); if (t<ss+length) {t++; col1++; } break; } /* end switch */ printf("\033[%u;%uH\033[1;33;44m\0",row,col1); ch=getcc(); } /*endfor*/ } getcc(){ union REGS r; r.h.ah=0; int86(0x16,&r,&r); if (r.h.al==27) exit(0); if (r.h.al) return(r.h.al); return(r.x.ax); } add(){ int count; int flag; int r,c; char s[40]; clear_win(1,3,20,77,6,0,white); deep=0; work=root; work2p=root; receive(); while (work2p != NULL) { deep++; for (count=1; count<MENUSIZE; ++count){ if(work2p->men[count].isleaf!= READ) continue; item=work2p->men[count].name; /*HAVE SUBSYSTEM*/ strcpy(shortname,work2p->men[count].shortn); work2p->men[count].isleaf=IS_SUBMENU; work=work2p; r=0; while(r++<work2p->countm && work->next!=NULL) work=work->next; getmem(MENU); receive(); } work2p=work2p->next; } } /* end of add() */ display(pp,cc1,cc,row,col) struct AA *pp; int cc1,*cc; int *row; int *col; { *row=7; *col=20; clear_win(5,14,14,67,6,0,blue); while((cc1<*cc) && *cc<cc1+5){ if (pp->men[cc1].name[0]=='\0') break; if(*cc>20) {printf("\007");return(0);} printf("\033[%u;%uH\033[1;%d;44m%s --- %s\033[%u;56H%s",*row,(*col)+1,fore_yellow,number[cc1+1],pp->men[cc1].name,*row,pp->men[cc1].shortn); cc1++; *row+=2; } if(*cc>20) {printf("\007");return(0);} else { *cc=cc1; printf("\033[%u;%uH\033[1;%d;44m%s --- %s\033[%u;56H%s",*row,(*col)+1,fore_yellow,number[cc1+1],pp->men[cc1].name,*row,pp->men[cc1].shortn); return(1);} } /* end of display() */ receive() { int cc,cc1,cc2; int act; char syst[9]; int c,exi,syslen; int row,col; int deep1; tom: deep1=deep; clear_win(2,3,20,76,6,0,white); cc1=0; cc=4; clear_win(3,13,17,71,6,0,black); clear_win(3,12,16,68,6,0,blue); gframe(3,12,17,69,0,0|30); c=0; for(;;) { /* clear_win(2,3,20,76,6,0,white); clear_win(3,13,17,71,6,0,black); clear_win(3,12,16,68,6,0,blue); gframe(3,12,17,69,0,0|30);*/ syslen=strlen(work->men[0].shortn); strncpy(syst,work->men[0].shortn,syslen-1); syst[syslen-1]='\0'; printf("\033[4;27H\033[1;33;44m╟δ╩Σ╚δ╧╡═│%-s ╡─╦∙╙╨╫╙╧╡═│\033[17;13H ╜ß╩° : ╓▒╜╙╗╪│╡ ╓╨╢╧ : ESC ▓╦╡Ñ╔ε╢╚ :%-1d ╖¡╥│ : PgUp/PgDn",syst,syslen-2);/*item,number[deep1+2]);*/ if(c==0){exi=display(work,cc1,&cc,&row,&col); cc2=cc; } c=0; if(exi!=0) { if (work->men[cc2].isleaf==ISLEAF){ printf("\033[24;0H\033[1;33;44m%s\033[24;20H\033[1;33;44m Alt_y ╨▐╕─╩²╛▌┐Γ▓╦╡Ñ ",spaces); } else { printf("\033[24;0H\033[0;%d;44m%s",fore_white,spaces); } } if(exi==0) act=NOTHING; else act=edd(work->men[cc2].name,40,row,col+6); switch(act) { case NOTHING: if (require(cc2)==10) { deep++; goto tom;} else return(1); case Alt_Y : modidb(cc2); clear_win(2,3,22,76,6,0,white); clear_win(3,13,17,71,6,0,black); clear_win(3,12,16,68,6,0,blue); gframe(3,12,17,69,0,0|30); /*clear_win(14,0,24,79,6,0,blue); clear_win(3,14,16,70,6,0,black); clear_win(2,12,15,68,6,0,cyan); printf("\033[3;27H\033[1;%d;42m╟δ╩Σ╚δ╧╡═│%s ╡─╦∙╙╨╫╙╧╡═│\033[15;13H ╜ß╩° : ╓▒╜╙╗╪│╡ ╓╨╢╧ : ESC ▓╦╡Ñ╔ε╢╚ :%s ╖¡╥│ : PgUp/PgDn",fore_white,item,number[deep1+2]);*/ break; case UP : if (cc2>cc1) { cc2--; row-=2; c=1;break; } case PgUp : if (cc1==0) { if (work->last==work) {putchar(7); } else { deep1--; work=work->last; cc=cc1+4; if (deep1<deep) work2p=work; } break; } cc1 -= 5; cc=cc1+4; clear_win(4,14,13,67,6,0,blue); break; case 1 : if (cc<cc1+4) { cc++ ;break;} case DOWN : if (cc2<cc && cc2<cc1+4) { row+=2; cc2++; c=1; break; } case PgDn : cc1+=5; if (cc1>work->count && act !=1) { if (work==root && work->men[cc].name[0]!='\0') { cc=cc1+4; clear_win(4,14,13,67,6,0,blue); break;} if (work->next==NULL) { putchar(7); cc1-=5; } else { deep1++; work=work->next ; cc1=0; cc=4; } break; } cc=cc1+4; clear_win(4,14,13,67,6,0,blue); break; default : putchar(7); break; }/*end switch*/ } /*end for*/ } #include <alloc.h> #include <stdio.h> getmem(which) int which; { switch(which){ case MENU : p=(struct AA *) malloc(sizeof(struct AA)); initmem(MENU); return; case DB : q=(struct DD *) malloc(sizeof(struct DD)); initmem(DB); return; } return; } initmem(which) int which; { int i,n; char buff[10]; switch(which){ case MENU : work=root; strcpy(buff,shortname); strcat(buff,number[2]); if (work!=NULL) { while (work->next!=NULL && strlen(buff)>strlen(work->next->men[1].shortn)) work=work->next; while (work->next!=NULL && strlen(buff)==strlen(work->next->men[1].shortn) \ && strcmp(buff,work->next->men[1].shortn)>=0) work=work->next; } p->last=work; if (work!=NULL) { p->next=work->next; work->next=p; } else p->next=NULL; if (p->next!= NULL) (p->next)->last=p; work=p; p->count=p->countm=1; for (i=0; i<MENUSIZE; ++i){ p->men[i].isleaf=EMPTY; p->men[i].shortn[0]='\0'; p->men[i].pdb=NULL; p->men[i].pos= -1; p->men[i].total= -1; p->men[i].row=p->men[i].col= -1; strcpy(p->men[i].shortn,shortname); strcat(p->men[i].shortn,number[i+1]); p->men[i].name[0]='\0';} strcat(p->men[0].name,"═╦│÷"); p->men[0].isleaf=IS_SUBMENU; return(1); case DB : q->count=0; for (i=0; i<DBSIZE ; ++i) { q->db[i].flag='n'; q->db[i].serve='N'; q->db[i].path[0]='\0'; q->db[i].mean[0]='\0'; q->db[i].name[0]='\0'; for (n=0;n<4;n++) q->db[i].mainkey[n][0]='\0'; } return(1); } return(0); } require(cc2) { int ans,ans1; int cc1/*,cc2*/; int zl,judge; char prog_name[11]; zl=1; for(;;) { if (work->men[cc2].isleaf==IS_SUBMENU) { strcpy(prog_name,work->men[cc2].shortn); strcat(prog_name,"1"); /* judge=work->men[cc2].pos; work=work->next;*/ while (strcmp(prog_name,work->men[1].shortn)) work=work->next; return(10); } for (cc2=1; cc2<MENUSIZE ; ++cc2) { if (work->men[cc2].isleaf!=EMPTY) continue; if (work->men[cc2].name[0]=='\0') continue; work->count++; clear_win(0,0,24,79,6,0,white); clear_win(9,22,18,68,6,0,black); clear_win(8,20,17,66,6,0,blue); for(;;){ zl=1; printf("\033[11;30H\033[1;33;44m < %s > ╙╨╫╙╧╡═│┬≡",work->men[cc2].name); printf("\033[15;33H\033[0;33;42m[ %s ]\033[15;48H[ %s ]","YES "," NO "); ans=get_yn(15,33,48,fpos); printf("\033[11;30H\033[1;33;44m ╚╖╨┼┬≡? "); printf("\033[15;33H\033[0;33;42m[ %s ]\033[15;48H[ %s ]","YES "," NO "); if(ans=='N') *fpos=1; else *fpos=0; if ((ans1=get_yn(15,33,48,fpos))=='y' || ans1=='Y') switch(ans){ case 'y' : case 'Y' : work->men[cc2].isleaf=READ; work->countm++; zl=0; break; case 'n' : case 'N' : work->men[cc2].isleaf=ISLEAF; getmem(DB); work->men[cc2].pdb=q; getdb(cc2); zl=0; break; default : zl=1; break; } if(zl==0) break; } /*endfor*/ printf("\033[13;18H\033[0;%d;44m ",fore_white); } /* end of for */ if (work->next!= NULL) { work=work->next; } return(0);} } getdb(cc2) int cc2; { int cc,n; int r=0,c; int count; int col,f_key; int serve; count=0; for(;;){ clear_win(0,0,24,79,6,0,white); printf("\033[2;1H\033[1;33;%dm┐Γ┬╝╚δ─ú┐Θ",back_red); clear_win(7,10,21,70,6,0,black); clear_win(6,8,20,68,6,0,blue); printf("\033[8;20H\033[1;%d;%dm╟δ╩Σ╚δ<%s>╦∙╙├╡─╩²╛▌┐Γ ú║\ \033[20;62H┐Γ %d\033[11;13H┐Γ╬─╝■├√ ú║\ \033[11;38H╓≈╣╪╝ⁿ╫╓ 1ú║\033[14;13H┐Γ▓╦╡Ñ├√ú║ ",fore_yellow,back_blue,work->men[cc2].name,count+1); if (edd(q->db[count].name,10,11,25)==NOTHING && count==q->count) if (r=='y' || r=='Y'){ /* clear_win(0,0,23,79,6,0,white);*/ return(1); } n=0; while(1){ if (n>3) break; printf("\033[11;38H\033[1;33;44m╓≈╣╪╝ⁿ╫╓%d ú║ ",n+1); printf("\033[%u;%uH\033[1;33;44m",11,52); do f_key=edd(q->db[count].mainkey[n],12,11,52); while(f_key>1); if (f_key==NOTHING && n>0 && q->db[count].mainkey[n][0]=='\0') break; n++; } printf("\033[14;13H\033[1;33;44m┐Γ▓╦╡Ñ├√ : "); while(edd(q->db[count].mean,20,14,24)>1); clear_win(14,40,22,76,6,0,black); clear_win(13,38,21,74,6,0,green); printf("\033[15;50H\033[0;%d;%dm╩╟╣▓╧φ┐Γ┬≡ú┐",fore_red,back_white); printf("\033[19;47H\033[0;33;46m[ %s ]\033[19;60H\033[0;%u;%u[ %s ]"," YES",fore_yellow,back_black," NO "); *fpos=1; serve=get_yn(19,47,60,fpos); if(serve=='Y') {q->db[count].serve='Y'; clear_win(12,36,24,79,6,0,white); clear_win(12,36,21,70,6,0,black); clear_win(12,36,20,68,6,0,blue); printf("\033[20;62H\033[0;30;46mku%d",count+1); } else { clear_win(12,36,24,79,6,0,white); clear_win(12,36,21,70,6,0,black); clear_win(12,36,20,68,6,0,blue); } if(serve=='Y'){ printf("\033[17;11H\033[1;%d;%dm╣▓╧φ┐Γ┬╖╛╢ :",fore_yellow,back_blue); while(edd(q->db[count].path,30,17,25)>1); } clear_win(14,40,22,76,6,0,black); clear_win(13,38,21,74,6,0,green); printf("\033[15;45H\033[0;%d;%dm─▄╚╖╢¿─·╡─╦∙╙╨▓┘╫≈┬≡ú┐",fore_yellow,back_green); printf("\033[19;47H\033[0;%u;%um[ %s ]\033[19;60H\033[0;30;46m[ %s ]",fore_yellow,back_black,"YES "," NO "); *fpos=0; r=get_yn(19,47,60,fpos); if(r=='Y'){ if (count==q->count) { q->count++; count++; } else count++; } } } func2(){ char *s; int i,j,k; int cc; int rr=0; int countm=0,countd=0; static int point[5], pp; int startx,starty; static int row[2]={0,23} , pr=1; char str[3],name[20]; int pos[20][2],tt,row1; FILE *fp; if (title_d==0){ p=root->next; while(p!=NULL){ for(s=p->men[0].shortn; *s!='\0'; s++); *(s-2)='\0'; p=p->next; } p=work=root; cc=0; p->men[0].pos=rr; if (p->count==1) { p->men[0].total=(p->men[0].pdb)->count; goto next;} else p->men[0].total=p->count; for(s=p->men[0].shortn; *s!='\0'; s++); *(s-1)='\0'; strcpy(shortname,work->men[0].shortn); item=title; } beginn: for (i=0; i<25; ++i){ for (j=0; j<80; ++j) screen[i][j]=' '; screen[i][80]='\0'; } if (title_d==1) { strcpy(name,shortname); strcat(name,".prg"); if ((fp=fopen(name,"r"))!=NULL) { fgets(screen[0],83,fp); fgets(screen[0],83,fp); for(row1=0;row1<25; row1++){ fgets(screen[row1],83,fp); screen[row1][79]=' '; screen[row1][80]='\0'; } fclose(fp); } } if (!title_d) { for(i=0; i<20; ++i){ pos[i][0]=work->men[i].row; pos[i][1]=work->men[i].col; } cpmenu(); } /* end if */ pp=0; i=0; disp_menu(0,23); edit_flag=0; printf("\033[24;0H\033[0;%d;44m%s\033[24;10H\033[0;%d;%dm╚½╞┴─╗▒α╝¡\033[24;30H F1 : ░∩╓·\033[24;50HPgDn: ┤µ┼╠═╦│÷",fore_white,spaces,fore_white,back_black); while ((j=edd(screen[i],80,i+1,0))!=PgDn) { switch(j){ case UP : if (--i>=0) ; else i=22; continue; case 1 : case NOTHING : case DOWN : if (++i<=22 ) ; else i=0; continue; case Alt_C: edit_flag=1; aframe(point[0],point[1],point[2],point[3],DOUBLE,str); break; case Alt_X: edit_flag=1; aframe(point[0],point[1],point[2],point[3],SINGAL,str); break; case Alt_Q: edit_flag=1; aframe(point[0],point[1],point[2],point[3],CLEAR,str); break; case Alt_Z :edit_flag=1; printf("\033[24;0H\033[0;%d;44m%s\033[24;0H\033[0;%d;%dm╟δ╩Σ╚δ─·╡─╫╓╖√(2╬╗) :",fore_white,spaces,fore_yellow,back_blue); str[0]=getcc(); putchar(str[0]); str[1]=getcc(); putchar(str[1]); str[2]='\0'; aframe(point[0],point[1],point[2],point[3],3,str); break; case Alt_Y : edit_flag=1; move(); continue; case PgUp : if (title_d) return(1); for (tt=0; tt<20; ++tt){ work->men[tt].row=pos[tt][0]; work->men[tt].col=pos[tt][1]; } goto next; case Alt_D : now_cursor(&startx,&starty); if (starty==79) starty=78; screen[startx][starty]='*'; screen[startx][starty+1]=' '; pr=1-pr; row[pr]=startx; point[pp++]=startx; point[pp++]=starty; disp_menu(startx,startx); pp=pp % 4; continue; case 15104 : /* F1 pressed */ help(); continue; } disp_menu(row[0],row[1]); pp=0; } if (edit_flag) ag(); if (title_d) return(1); next: while (1){ if (cc>0 && p->men[cc].isleaf==IS_SUBMENU){ countm+=work->count; item=p->men[cc].name; work=work->next; if (work==NULL) return(0); p->men[cc].pos=countm; p->men[cc].total=work->count; work->men[0].pos=rr; work->men[0].total=p->count; strcpy(shortname,p->men[cc++].shortn); goto beginn; } if (p->men[cc].isleaf==ISLEAF) { q=p->men[cc].pdb; p->men[cc].total=q->count; p->men[cc].pos=countd; countd+=q->count; } if (++cc>=MENUSIZE) { rr+=p->count; p=p->next; cc=0; if (p==NULL) return(2); } } } aframe(startx,starty,endx,endy,sss,str) int startx,starty; int endx,endy; int sss; char *str; { static char dd[4][6][3]={ "⌐Ñ","⌐º","⌐│","⌐╖","⌐╗","⌐┐", "⌐ñ","⌐ª","⌐░","⌐┤","⌐╕","⌐╝" , " "," "," "," "," "," " , "\0\0","\0\0","\0\0","\0\0","\0\0","\0\0" }; int row,col; int temp; if (sss==3) for (temp=0 ; temp<6; temp++) strcpy(dd[3][temp],str); if (startx>endx) { temp=startx; startx=endx; endx=temp; } if (starty>endy) { temp=starty; starty=endy; endy=temp; } if ((starty %2)!=0) starty--; if ((endy %2)!=0) endy--; if (startx==endx) { for (row=starty; row<=endy ;){ screen[startx][row++]=dd[sss][0][0]; screen[startx][row++]=dd[sss][0][1];} return; } if (starty==endy) { for (row=startx; row<=endx; row++){ screen[row][endy]=dd[sss][1][0]; screen[row][endy+1]=dd[sss][1][1];} return; } screen[startx][starty]=dd[sss][2][0]; screen[startx][starty+1]=dd[sss][2][1]; screen[startx][endy]=dd[sss][3][0]; screen[startx][endy+1]=dd[sss][3][1]; for(col=starty+2; col<endy;){ screen[startx][col++]=dd[sss][0][0]; screen[startx][col++]=dd[sss][0][1]; } for(row=startx+1; row<endx; ++row){ screen[row][starty]=screen[row][endy]=dd[sss][1][0]; screen[row][starty+1]=screen[row][endy+1]=dd[sss][1][1]; } screen[endx][starty]=dd[sss][4][0]; screen[endx][starty+1]=dd[sss][4][1]; for(col=starty+2; col<endy; ++col){ screen[endx][col++]=dd[sss][0][0]; screen[endx][col]=dd[sss][0][1]; } screen[endx][endy]=dd[sss][5][0]; screen[endx][endy+1]=dd[sss][5][1]; return; } disp_menu(begin,end) int begin, end; { int i; if (begin>end) { i=begin; begin=end; end=i; } if (end>23){ end=23; clear_win(0,0,23,79,6,0,white); } for (i=begin; i<=end; ++i){ sprint(screen[i],0|30,i,0); } return; } sprint(char *string,int attr,int row,int col) { _SI =(unsigned int) string; _DH=(unsigned char)row; _DL=(unsigned char)col; _CX=1; while(*((char *)_SI)){ _AH=(unsigned char)2; _BH=(unsigned char)0; geninterrupt(0x10); ++_DL; _AH=(unsigned char)9; _AL=*((char *)_SI); _SI++; _BH=(unsigned char)0; _BL=(unsigned char)attr; geninterrupt(0x10); } } cpmenu() { int row1,row2,col; char *t; char name[31]; FILE *fp; switch(work->count/8) { case 0 : format1(&row1,&row2); break; case 1 : format3(&row1,&row2,2); break; default : format3(&row1,&row2,1); break; } t=item; col=40-strlen(item)/2; while(*t) screen[row1][col++]=*t++; t="╟δ╙├┐╒╕±╝ⁿú½╗╪│╡╝ⁿ╗≥╩²╫╓╝ⁿ╤í╘±"; col=30; while (*t) screen[row2][col++]=*t++; } format1(row1,row2) int *row1,*row2; { int row,col; char *t; int cc; char prgname[14]; FILE *prg_file; strcpy(prgname,shortname); strcat(prgname,".prg"); prg_file=fopen(prgname,"w"); fprintf(prg_file,"set color to w/w\nclear\nset color to n/n\n"); *row1=9-work->count; row=*row1+2; fprintf(prg_file,"@%d,%d clea to %d,%d\nset color to w+/b\n",row+1,25,row+1+2*work->count,55); fprintf(prg_file,"@%d,%d clea to %d,%d\n",row,23,row+2*work->count,53); aframe(row,10,11+work->count,70,SINGAL); for(row++,cc=0; cc<work->count; row+=2,cc++){ col=20; t=number[cc+1]; while (*t) screen[row][col++]=*t++; t=" --- "; while (*t) screen[row][col++]=*t++; t=work->men[cc].name; work->men[cc].row=row; work->men[cc].col=20; while(*t) screen[row][col++]=*t++; fprintf(prg_file,"@%d,%d say '%d --- %s'\n",row,28,cc,work->men[cc].name); } *row2=2+row; fprintf(prg_file,"return\n"); fclose(prg_file); return; }/* end of format1() */ format3(row1,row2,step) int *row1,*row2,step; { int row,col; char *t; int cc; int tt; int rowe; char prgname[14]; FILE *prg_file; strcpy(prgname,shortname); strcat(prgname,".prg"); prg_file=fopen(prgname,"w"); fprintf(prg_file,"set color to w/w\nclear\nset color to n/n\n"); if (step==1) tt=4; else tt=2; *row1=9-work->count/tt; rowe=12; switch(work->count % tt) { case 1 : case 2 : rowe=13; break; case 3 : rowe=14; break; } row=*row1+2; fprintf(prg_file,"@%d,%d clea to %d,%d\nset color to w+/b\n",row+1,10,row+1+2*(work->count/tt),70); fprintf(prg_file,"@%d,%d clea to %d,%d\n",row,8,row+2*(work->count/tt),68); aframe(row,4,rowe+work->count/tt,74,SINGAL); for(row++,cc=0; cc<work->count; ++cc,row+=step){ col=8; t=number[cc+1]; while (*t) screen[row][col++]=*t++; t=" --- "; while (*t) screen[row][col++]=*t++; t=work->men[cc].name; work->men[cc].row=row; work->men[cc].col=8; fprintf(prg_file,"@%d,%d say '%d --- %s'\n",row,10,cc,work->men[cc].name); cc++; while(*t) screen[row][col++]=*t++; if (cc>=work->count) break; col=40; t=number[cc+1]; while (*t) screen[row][col++]=*t++; t=" --- "; while (*t) screen[row][col++]=*t++; t=work->men[cc].name; work->men[cc].row=row; work->men[cc].col=40; while (*t) screen[row][col++]=*t++; fprintf(prg_file,"@%d,%d say '%d --- %s'\n",row,40,cc,work->men[cc].name); } *row2=3+row; fprintf(prg_file,"return\n"); fclose(prg_file); return; } ag() { int i,j; FILE *fp_file; strcat(shortname,".prg"); fp_file=fopen(shortname,"w"); if (fp_file==NULL) printf("\033[0;%d;44mfile can't be opened\n",fore_red); fprintf(fp_file,"clear\nset color to w+/b\ntext\n"); for(i=0; i<25; ++i){ for(j=0;j<79;j++) { if (screen[i][j]=='\0') screen[i][j]=' '; fprintf(fp_file,"%c",screen[i][j]); } screen[i][79]='\0'; fprintf(fp_file,"%c\n",screen[i][79]); } fprintf(fp_file,"endtext\nreturn\n"); fclose(fp_file); return(1); } wtofile(){ int i,j; p=root; fp_menu=fopen("menu.txt","w"); fp_db=fopen("db.txt","w"); while(p!=NULL){ for(i=0; i<MENUSIZE; i++){ if (p->men[i].isleaf==EMPTY ) continue; if (p->men[i].isleaf==ISLEAF) { q=p->men[i].pdb; for(j=0; j<DBSIZE; j++) { if (q->db[j].name[0]!='\0') fprintf(fp_db,"#%s#,#%s#,#%s#,#%s#,#%s#,#%s#,#%c#,#%c#,#%s#\n",q->db[j].mean\ ,q->db[j].mainkey[0],q->db[j].mainkey[1],q->db[j].mainkey[2],\ q->db[j].mainkey[3],q->db[j].name,q->db[j].flag,q->db[j].serve,q->db[j].path); } } fprintf(fp_menu,"#%s#,#%s#,%d,%d,%d,%d,%d\n",p->men[i].name,p->men[i].shortn,p->men[i].isleaf, \ p->men[i].pos,p->men[i].total,p->men[i].row, \ p->men[i].col); } /* end for */ p=p->next; } /*end while */ fclose(fp_db); fclose(fp_menu); return(1); } move(){ int step,r,c,i; int choice,act; char last[81], next[81]; printf("\033[24;0H\033[0;%d;44m%s\033[24;0H\033[1;%d;44m╟δ╩Σ╚δ╥¬╥╞╢»╡─╫╓╢╬║┼: \033[24;30HAlt_Y : ╜ß╩° í· : ╙╥╥╞ í√ : ╫≤╥╞",fore_white,spaces,fore_white); for(;;){ printf("\033[24;25H"); choice=getcc(); putchar(choice); if (choice>='0' && choice<='9') {choice-='0';break;} else if (choice>='a' && choice<='l') {choice=choice-'a'+10;break;} } r=work->men[choice].row; strcpy(last,screen[r]); c=work->men[choice].col; for(step=1; step<strlen(work->men[choice].name)+7; c++,step++) last[c]=' '; while((act=getcc())!=Alt_Y && act!=PgDn){ switch(act){ case 19200 : c=--work->men[choice].col; /*<---*/ r=work->men[choice].row; for(step=1; step<strlen(work->men[choice].name)+7; c++,step++) screen[r][c]=screen[r][1+c]; screen[r][c]=last[c]; break; case 19712 : c=work->men[choice].col++; /* --> */ r=work->men[choice].row; for(step=strlen(work->men[choice].name)+6,c+=step; step>0; c--,step--) screen[r][c]=screen[r][c-1]; screen[r][c]=last[c]; break; case 18432 : /* up arrow */ r=work->men[choice].row--; c=work->men[choice].col; strcpy(next,screen[r-1]); for (step=strlen(work->men[choice].name)+6; step>0; step--){ screen[r-1][c]=screen[r][c++]; } strcpy(screen[r],last); strcpy(last,next); disp_menu(r-1,r-1); break; case 20480 : /* down arrow */ r=work->men[choice].row++; c=work->men[choice].col; strcpy(next,screen[r+1]); for (step=strlen(work->men[choice].name)+6; step>0; step--){ screen[r+1][c]=screen[r][c++]; } strcpy(screen[r],last); strcpy(last,next); disp_menu(r+1,r+1); break; default : if (act>='0' && act<='9') choice=act-'0'; else if (act>='a' && act<='l') choice=act-'a'+10; else continue; printf("\033[24;25H"); putchar(act); c=work->men[choice].col; /*<---*/ r=work->men[choice].row; strcpy(last,screen[r]); for(step=1; step<strlen(work->men[choice].name)+7; c++,step++) last[c]=' '; } disp_menu(r,r); } printf("\033[24;0H\033[0;%d;44m%s",fore_white,spaces); return(1); } print(int prow,int pcol,int attr,char *format,...) { va_list arg; char print_str[254],*string; va_start(arg,format); vsprintf(print_str,format,arg); string=print_str; _SI =(unsigned int) string; _DH =(unsigned char)prow-1; _DL =(unsigned char)pcol-1; _CX=1; while(*((char *)_SI)){ _AH=(unsigned char)2; _BH=(unsigned char)0; geninterrupt(0x10); ++_DL; _AH=(unsigned char)9; _AL=*((char *)_SI); _SI++; _BH=(unsigned char)0; _BL=(unsigned char)attr; geninterrupt(0x10); } } /*-----------------------------DRAW A FRAME-------------------------------*/ gframe(startx,starty,endx,endy,i,color) int startx,starty; int endx,endy; int i; int color; { static char dd[3][6][3]={ "⌐Ñ","⌐º","⌐│","⌐╖","⌐╗","⌐┐", "⌐ñ","⌐ª","⌐░","⌐┤","⌐╕","⌐╝" , " "," "," "," "," "," " }; int row,col; /*clear_win(startx,starty,endx,endy,6,0,black);*/ print(startx,starty,color,"%s",dd[i][2]); for(col=starty+2; col<endy; col+=2) print(startx,col,color,"%s",dd[i][0]); print(startx,endy,color,"%s",dd[i][3]); for(row=startx+1; row<endx; ++row) { print(row,starty,color,"%s",dd[i][1]); print(row,endy,color,"%s",dd[i][1]);} print(endx,starty,color,"%s",dd[i][4]); for(col=starty+2; col<endy; ++col,++col) print(endx,col,color,"%s",dd[i][0]); print(endx,endy,color,"%s",dd[i][5]); } help() { clear_win(5,20,17,70,6,0,black); clear_win(4,18,16,68,6,0,green); printf("\033[6;22H\033[0;%d;%dm─·┐╔╘┌╞┴─╗╡─╚╬╥Γ╬╗╓├╩Σ╚δ╚╬╥Γ╫╓╖√,┐╔╙├╝ⁿ╙╨:\033[7;24H Alt_d : ╙├╥╘▒ú┤µ╡▒╟░╣Γ▒Ω╬╗╓├,╡▒─·▒ú┤µ┴╦╥╗ \ \033[8;24H ╕÷╛╪╨╬╢╘╜╟╡─┴╜╡π║≤,┐╔╙├: \033[9;24HAlt_c : ╗¡╥╗┤╓┐≥\033[10;24HAlt_x : ╗¡╥╗╧╕┐≥ \ \033[11;24HAlt_q : ╟σ│²╘¡┐≥ \033[12;24HAlt_z : ╙├─·╧▓╗╢╡─╫╓╖√╗¡┐≥.\033[13;24H***** : ╥▓┐╔╗¡║ß,╩·╧▀ \ \033[14;24HAlt_y : ╙├╣Γ▒Ω╝ⁿ╡≈╒√▓╦╡Ñ╧ε╧╘╩╛╬╗╓├. \033[15;24H***** : ╟δ▓╗╥¬╙├▓σ╚δ╗≥╔╛│²▓┘╫≈╕─▒Σ▓╦╡Ñ╧ε╡─\033[16;24H ╧╘╩╛╬╗╓├. \ ",fore_cyan,back_green); getcc(); clear_win(4,20,17,70,6,0,blue); disp_menu(4,17); return;} modidb(cc2) int cc2; { int i,j,k; printf("\033[24;0H\033[0;%d;44m%s\033[24;20H\033[0;%d;%dm╖¡╥│ : PgUp/PgDn\033[24;45H╔╛│² : Alt_d",fore_yellow,back_green); q=work->men[cc2].pdb; getdb(cc2); } titles() { int i; clear_win(0,0,24,79,6,0,black); printf("\033[3;0H\033[0;%d;%dm╟δ╔Φ╝╞─·╡─╙ª╙├╧╡═│▒Ω╠Γú¼╕▒▒Ω╠Γ╝░╧╘╩╛╗¡├µ",fore_white,back_black); while (! bioskey(1)){ printf("\033[10;30H\033[1;%d;%dm╩Σ╚╬╥Γ╝ⁿ╝╠╨° . . .",fore_white,back_black); for(i=0; i<500&&!bioskey(1); ++i); printf("\033[10;30H\033[0;%d;%dm ",fore_white,back_black); for(i=0;i<100 && !bioskey(1);++i); } title_d=1; func2(); title_d=0; return(1); }