/* menu.c cl /AL tscreen.c getfile3 where: tscreen.dat = MENU = main TITLE = 'U.S. GEOLOGIC SURVEY' NUMBER_OF_ENTRIES = 4 TYPE = I 1 -- Run browse for .txt files Working_PATH = PROGRAM = browse.exe NULL TYPE = I 2 -- Run browse for .c files Working_PATH = \c PROGRAM = browse.exe *.c NULL TYPE = S 1 3 -- Image Processing TYPE = I 4 -- Run browse for .bat files Working_PATH = \c PROGRAM = browse.exe *.bat NULL MENU = sub1 TITLE = ' OEMG Image Processor ' NUMBER_OF_ENTRIES = 2 TYPE = I a -- imvis Working_Path = D:\GLORIA PROGRAM = \c\imvis.exe NULL TYPE = I b -- 5-D images Working_Path = \c PROGRAM = make5d.exe NULL END */ #include #include #include #include #include #include #include #include #include "nomouse.h" #define SCREEN_WIDTH 160 #define EQLIST 0x410 #define MEMSIZ 0x413 #define NAME_SIZE 100 #define S_SIZE 40 #define F_SIZE 20 #define T_SIZE 15 #define MROW 7 #define ROW 16 #define COL 80 #define BLACK 0 #define BLUE 1 #define GREEN 2 #define CYAN 3 #define RED 4 #define MAGENTA 5 #define YELLOW 6 #define WHITE 7 extern int LastN; extern int GF_Title,GF_Frame,GF_Back,GF_Bar; extern int GF_Info,GF_Shade,GF_Text; char Cwd[100]; struct file_id { char name[S_SIZE]; long size; unsigned date,time; }; extern struct file_id GF_File[]; extern char GF_String[][S_SIZE]; extern FILE *Fpout; /*********************************************************************** ** bit map of colors * ** F B B B R T T T ** ** F = flash 0 = OFF 1 = ON ** B = Background Color ** R = Brightness 0 = Dark 1 = Bright ** T = Text Color ** ** 0 = black ** 1 = blue ** 2 = green ** 3 = cyan ** 4 = red ** 5 = magenta ** 6 = yellow ** 7 = white ** ************************************************************************/ int A_Int=0x3f; int A_Reverse=0x78,A_Black=0x07; int A_Brite=0x13,A_Norm=0x70; int A_Flash=0xcf; int X1=0,X2=79,Y1=1,Y2=22; extern unsigned char far *Video_Buffer[4]; int Monitor; int Char1=0; union REGS regs; struct equipment { int printers; /* number present */ int sprinter; /* serial printer installed? 0=no 1=yes */ int game; /* game adapter installed? */ int sports; /* number of serial ports */ int dma; /* DMA chip installed? */ int drives; /* number of disk drives */ int video; /* video mode 1=40 color 2=80 color 3=80 B/W */ int disk; /* any disk drives? */ int memory; /* memory size in Kbytes */ }Eq; long *Line_Offset; int *StrLen; char *TV_Buffer[24]; long Max_Line; int Monitor; int Page=0xc; int Overlay=0; struct menu { int num_entry,sub_num[10]; char name[40],title[40],text[10][40],id[10],type[10],path[10][40]; char command[10][10][25]; }Mn[5]; char *CmdName,**Argv; void SetCursor(int,int); void ClearScreen(int); void ClearBox(); void WriteStringAtxy(); void ScrollUp(); void ScrollDown(); void DoubleBox(); int load_File(); int check_equip(); int scroll_list(int,int,int,int,char [][S_SIZE],int,char *); int search(char *word,int *cx,int *cy,int y1,int y2,int x1, int x2, FILE *fp,int *n1,int *n2,int numline,int maxline,int start,int iop, char *message); int look_at_image(char *word,int x1,int x2,int y1,int y2,FILE *fp, int l1,int l2,int cy); int make_bpt(FILE *fp,FILE *fpbpt,char *name,char *message,char *filename, int x1,int x2,int y1,int y2,int n1,int n2,int cy,int xs,int ys); int make_color(int text,int back,int shade,int flash); main(argc,argv) int argc; char *argv[]; { int i,j,k; char string[100]; int color,val,num; for(i=2;i1) strcpy(string,argv[1]); else strcpy(string,"menu.dat"); ClearScreen(make_color(BLACK,WHITE,0,0)); if((num=load_menu(string))>0) { while((val=menu_find(0))>=0) { do_program(0,val); } } ClearScreen(make_color(WHITE,BLACK,0,0)); SetCursor(0,0); } /******************************************************************** ** ** ** ********************************************************************* */ int load_menu(char *filename) { int i,j,k; char string[200],word[10][50],str1[40],str2[40],blank[10]; FILE *fpmn; int firstc[20],nc,len,q1,q2; int num_menu=-1,item=0; int x,y,txt,bck,brt,fls,lines,color; strcpy(blank," "); fpmn=fopen(filename,"rt"); if(!fpmn) return(-1); fgets(string,200,fpmn); sscanf(string,"%s%s%d%d%d%d",str1,str2,&txt,&bck,&brt,&fls); if(strcmpi(str1,"SCREEN_COLOR")==0) { while(strcmpi(str1,"SCREEN_COLOR")==0) { ClearScreen(make_color(txt,bck,brt,fls)); SetCursor(0,25); fgets(string,200,fpmn); sscanf(string,"%s%s%d",str1,str2,&lines); if(strcmpi(str1,"SCREEN_LINES")!=0) { printf("No screen lines.\n\n"); ClearScreen(make_color(WHITE,BLACK,0,0)); exit(0); } for(i=0;i80) len=80; for(j=0;j10) { printf("\n\nInvalid number of entries -- must be between 1 & 10\n\n"); getch(); return(-2); } } else { printf("\n\n%s",string); printf("Expected to find NUMBER_OF_ENTRIES = #\n"); getch(); return(-1); } for(i=0;i2) { strcpy(Mn[num_menu].path[i],word[2]); } fgets(string,200,fpmn); /* read path */ len=sscanf(string,"%s%s%s%s%s%s%s%s%s%s", word[0],word[1],word[2],word[3],word[4], word[5],word[6],word[7],word[8],word[9]); len-=2; for(j=0;j=0) { do_program(Mn[num].sub_num[item],val); } ClearScreen(make_color(BLACK,7-num,0,0)); return(0); } strcpy(program,Mn[num].command[item][0]); len=strlen(program); for(i=0;i0&&strcmpi(Mn[num].path[item],"NULL")!=0) { printf("directory = '%s'\n",Mn[num].path[item]); if(chdir(Mn[num].path[item])!=0) { printf( "\n\n\nCould not chage directories to '%s'\n\n",Mn[num].path[item]); getch(); } } printf("loading '%s'\n",Mn[num].command[item][0]); if(Overlay==0) spawnvp(P_WAIT,Mn[num].command[item][0],args); else spawnvp(P_OVERLAY,Mn[num].command[item][0],args); if(chdir(Cwd)!=0) { printf( "\n\n\nCould not chage back to '%s'\n\n",Mn[num].path[item]); getch(); } ClearScreen(make_color(BLACK,7-num,0,0)); } /******************************************************************** ** ** ** ********************************************************************* */ int menu_find(int num) { int i,j,k; int val; char file_name[50]; for(i=0;inum-1) { n2=num-1; n1=n2-(nlines-1); } ClearBox(x1-1,x2-1,y1+1,y2+3,GF_Shade); ClearBox(x1,x2,y1+1,y2+2,GF_Back); DoubleBox(xc,xc+xs-1,yc,yc+ys-1,GF_Frame); WriteStringAtxy(x1+1,y2+2,xs-2,GF_Info, " 'Esc'=Quit 'Enter'=Choose file "); for(i=0;i='a'&&ans<='z')||(ans>='A'&&ans<='Z')|| (ans>='0'&&ans<='9')||ans=='_'||ans=='-') { for(j=0;j0) /* 8 */ n-=1; if(n>n2) { n2=n; n1=n2-(nlines-1); ScrollUp(1,x1+1,x2-1,y1+1,y2-1,GF_Back); } if(n0&&n==n1) { n1-=nlines; if(n1<0)n1=0; n2=n1+nlines-1; n=n1; ClearBox(x1+1,x2-1,y1+1,y2-1,GF_Back); for(i=0;in1) n=n1; } if(ans==71) { if(n1>0) { n1=0; n2=n1+nlines-1; n=0; ClearBox(x1+1,x2-1,y1+1,y2-1,GF_Back); for(i=0;i0) n=0; } if(ans==81) { if(n2num-1)n2=num-1; n1=n2-(nlines-1); n=n2; ClearBox(x1+1,x2-1,y1+1,y2-1,GF_Back); for(i=0;i