home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* XBBS SOURCE CODE copyright (c) 1990 by M. Kimes */
- /* All Rights Reserved */
- /* */
- /* For complete details of the licensing restrictions, please refer */
- /* to the License agreement, which is published in its entirety in */
- /* the in the file LICENSE.XBS. */
- /* */
- /* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
- /* XBBS LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
- /* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
- /* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT M. KIMES */
- /* AT THE ADDRESS LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO USE */
- /* THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE XBBS LICENSING */
- /* AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH */
- /* M. KIMES */
- /* */
- /* */
- /* You can contact M. Kimes at the following address: */
- /* */
- /* M. Kimes 1:380/16.0@FidoNet */
- /* 542 Merrick (318)222-3455 data */
- /* Shreveport, LA 71104 */
- /* */
- /* */
- /* Please feel free to contact me at any time to share your comments about */
- /* my software and/or licensing policies. */
- /* */
- /*--------------------------------------------------------------------------*/
- /*======================================================================*/
- /* XBBS Bulletin Board System.....ANSI pulldown & cursor menus */
- /* Copyright (c) 1990 by M. Kimes -- All Rights Reserved */
- /*======================================================================*/
-
- #include "msg.h"
- #include "xext.h"
-
-
-
- char pascal ansimenu2 (char tcolor,char color,char *title,char *line, char top, char down, char *hyperhelp) {
-
- register word x;
- register word y;
- char nump;
- char numpp;
- char *p[10];
- char *pp[10];
- char s[144]="";
- word pos[10];
- word ppos[10];
- word pdown;
- word start;
- char *t;
- char was;
- char is;
- char temp;
- char tempdisablesub;
- char eligible;
-
- /* Initially display top bar */
-
- if(!user.graphics || user.ansimenus) eligible=0;
- else eligible=1;
- stripcr(line);
- if (!*line) return 0;
- x=0;
- p[x++]=strtok(line," ");
- while (x<10 && (p[x++]=strtok(0," ")));
- p[--x]=NULL;
- if (!*p) return 0;
- nump=(char)x-1;
- for (x=0;p[x];x++) while (t=strchr(p[x],'_')) *t=' ';
- tempdisablesub=disablesub;
- disablesub=1;
- AllOver:
- if(!eligible) {
- gprintf(0,"\n%s\n",title);
- }
- else {
- gprintf(0,"\x1b[1;1H\x1b[K\x1b[0;1;%hum╔",color);
- for(x=1;x<((79-strlen(title))/2);x++) printm("═");
- gprintf(0,"\x1b[0;1;%hum%s\x1b[0;1;%hum",tcolor,title,color);
- y=wherex();
- for(x=y;x<79;x++) printm("═");
- printm("╗\n");
- start=wherey();
- }
- Over: /* Redisplay top bar */
- is=was=0;
- if(top) {
- is=top-1;
- if(!*variable[top-1])top=0;
- }
- for (x=0;x<9;x++) pos[x]=0;
- if(eligible) {
- gprintf(0,"\x1b[0;1;%hum",color);
- if(baud)while (!fossil(TRANSMIT,'\r')) carrchk();
- fputs("\r",stdout);
- printm("\x1b[2;1H\x1b[K║ ");
- }
- *pos=3;
- if(!eligible) {
- for (x=0;p[x];x++) {
- if((wherex()+strlen(p[x])+2+2)>(int)(user.length-3)) printm("\n");
- gprintf(0,"[%c]%s ",*p[x],&p[x][1]);
- }
- printm("\b\b: ");
- }
- else {
- printm(*p);
- for (x=1;p[x];x++) {
- printm(" ");
- printm(p[x]);
- pos[x]=pos[x-1]+strlen(p[x-1])+2;
- }
- printm("\x1b[2;79H║\x1b[3;1H\x1b[K╚");
- for(x=1;x<78;x++) printm("═");
- printm("╝\x1b[2;1H");
- }
- Next: /* Move highlight bar */
- if(eligible) {
- if(baud)while (!fossil(TRANSMIT,'\r')) carrchk();
- fputs("\r",stdout);
- gprintf(0,"\x1b[%u;1H\x1b[0;1;%hum\x1b[%uC%s",start,color,pos[was],p[was]);
- gprintf(0,"\x1b[%u;1H\x1b[7m\x1b[%uC%s\x1b[0;1;%hum",start,pos[is],p[is],color);
- }
- if(top) {
- temp=*p[top-1];
- top=0;
- if(eligible) goto Interruptus;
- }
- was=is;
- None: /* Wait for something to happen w/ top bar... */
- helpnum=0;
- if(!eligible) {
- temp=*genin(1,0,1,1,ALLL);
- if(temp)goto Direct;
- else goto None;
- }
- else {
- temp=*genin(1,0,0,0,ARROWS);
- }
- Interruptus:
- switch ((int)temp) {
- case 0:
- case 5:
- case '2': goto GotOne;
- case 1:
- case 4:
- case '4': if (is) is--;
- else is=nump;
- break;
- case 2:
- case '6': if (!p[is+1]) is=0;
- else is++;
- break;
- case 11:
- case 27: cls();
- *s=0;
- disablesub=tempdisablesub;
- return 0;
- default:
- Direct:
- if(temp=='?' || toupper(temp)==conf.helpkey) {
- if(hyperhelp) {
- if(!eligible) {
- cls();
- if(conf.debug) lprint("\n\04Help = @Main\n");
- find_help(hyperhelp,"@Main",0);
- }
- else {
- cls();
- if(conf.debug) gprintf(LOCALONLY,"\n\04Help = %s\n",p[is]);
- find_help(hyperhelp,p[is],0);
- }
- top=is+1;
- down=0;
- cls();
- goto AllOver;
- }
- }
- for(x=0;p[x];x++) { /* Direct select */
- if(toupper(*p[x])==toupper(temp)) {
- if(is!=(char)x) {
- if(eligible) {
- gprintf(0,"\x1b[%u;1H\x1b[0;1;%hum\x1b[%uC%s",start,color,pos[is],p[is]);
- gprintf(0,"\x1b[%u;1H\x1b[7m\x1b[%uC%s\x1b[0;1;%hum",start,pos[x],p[x],color);
- }
- }
- is=(char)x;
- goto GotOne;
- }
- }
- if(!eligible) printm(BACKSPACE);
- break;
- }
- goto Next;
-
- GotOne: /* Pull down actions */
-
- if(!eligible) {
- printm("\n");
- down=0;
- }
- if(!*variable[is]) { /* No pull downs for this one */
- disablesub=tempdisablesub;
- if(eligible)printm("\x1b[5;1H");
- return ((is+1)*10);
- }
- pdown=pos[is];
- if(pdown>60) pdown=60;
- if(eligible)gprintf(0,"\x1b[3;%uH╦\x1b[14C╦\x1b[0m\x1b[0;1;%hum\n",pdown-1,color);
- for(x=0;x<9;x++)ppos[x]=0;
- x=0;
- strcpy(s,variable[is]);
- pp[x++]=strtok(s," ");
- while (x<10 && (pp[x++]=strtok(0," ")));
- pp[--x]=NULL;
- if (!*pp) return 0;
- numpp=(char)x-1;
- for (x=0;pp[x];x++) while (t=strchr(pp[x],'_')) *t=' ';;
- if(!eligible) {
- for (x=0;pp[x];x++) {
- if((wherex()+strlen(pp[x])+2+2)>(int)(user.length-3)) printm("\n");
- gprintf(0,"[%c]%s ",*pp[x],&pp[x][1]);
- }
- printm("\b\b: ");
- }
- else {
- for(x=0;pp[x];x++) {
- ppos[x]=wherey();
- gprintf(0,"\x1b[K\x1b[%u;%uH║ %-12.12s ║\n",ppos[x],pdown-1,pp[x]);
- }
- gprintf(0,"\x1b[%u;%uH\x1b[K╚══════════════╝",ppos[numpp]+1,pdown-1);
- }
- was=y=0;
- if(down) {
- y=down-1;
- down=0;
- }
- Over1: /* Loop until something happens */
-
- helpnum=0;
- if(eligible) {
- gprintf(0,"\x1b[%u;%uH\x1b[7m %-12.12s \x1b[0;1;%hum",ppos[y],pdown,pp[y],color);
- temp=*genin(1,0,0,0,ARROWS);
- }
- else {
- temp=*genin(1,0,1,1,ALLL);
- if(temp) goto Direct2;
- else goto Over1;
- }
- switch ((int)temp) {
- case 1:
- case 2:
- case '4':
- case '6': was=is;
- for(x=0;pp[x];x++) {
- gprintf(0,"\x1b[%u;1H\x1b[K\n",ppos[x]);
- }
- gprintf(0,"\x1b[%u;1H\x1b[K\n",ppos[numpp]+1);
- gprintf(0,"\x1b[3;%uH═\x1b[14C═",pdown-1);
- if (temp==1 || temp=='4') {
- if (is) is--;
- else is=nump;
- }
- else {
- if (!p[is+1]) is=0;
- else is++;
- }
- gprintf(0,"\x1b[%u;1H\x1b[0;1;%hum\x1b[%uC%s",start,color,pos[was],p[was]);
- goto Next;
- case 0:
- KeyPress1:
- printm("\x1b[15;1H");
- disablesub=tempdisablesub;
- return (((is+1)*10)+(y+1));
- case 4:
- case '8': gprintf(0,"\x1b[%u;%uH\x1b[0;1;%hum %-12.12s ",ppos[y],pdown,color,pp[y]);
- if (y) y--;
- else y=numpp;
- break;
- case 5:
- case '2': gprintf(0,"\x1b[%u;%uH\x1b[0;1;%hum %-12.12s ",ppos[y],pdown,color,pp[y]);
- if (!pp[y+1]) y=0;
- else y++;
- break;
- case 11:
- case 27: for(x=0;pp[x];x++) {
- gprintf(0,"\x1b[%u;1H\x1b[K\n",ppos[x]);
- }
- gprintf(0,"\x1b[%u;1H\x1b[K\n",ppos[numpp]+1);
- *s=0;
- disablesub=tempdisablesub;
- gprintf(0,"\x1b[1;1H\x1b[K\x1b[0;1;%hum╔",color);
- for(x=1;x<((79-strlen(title))/2);x++) printm("═");
- gprintf(0,"\x1b[0;1;%hum%s\x1b[0;1;%hum",tcolor,title,color);
- temp=wherex();
- for(x=temp;x<79;x++) printm("═");
- printm("╗\n");
- goto Over;
- default:
- Direct2:
- if(temp=='?' || toupper(temp)==conf.helpkey) {
- if(hyperhelp) {
- if(!eligible) {
- cls();
- if(conf.debug) gprintf(LOCALONLY,"\n\04Help = %s\n",p[is]);
- find_help(hyperhelp,p[is],0);
- }
- else {
-
- char s[133];
-
- sprintf(s,"%s|%s",p[is],pp[y]);
- cls();
- if(conf.debug) gprintf(LOCALONLY,"\n\04Help = %s\n",s);
- find_help(hyperhelp,s,0);
- }
- top=is+1;
- down=y+1;
- cls();
- goto AllOver;
- }
- }
- for(x=0;pp[x];x++) { /* Direct select */
- if(toupper(*pp[x])==toupper(temp)) {
- if(y!=x) {
- if(eligible) {
- gprintf(0,"\x1b[%u;%uH\x1b[0;1;%hum %-12.12s ",ppos[y],pdown,color,pp[y]);
- gprintf(0,"\x1b[%u;%uH\x1b[7m %-12.12s \x1b[0;1;%hum",ppos[x],pdown,pp[x],color);
- }
- }
- y=x;
- goto KeyPress1;
- }
- }
- if(!eligible)printm(BACKSPACE);
- }
- goto Over1;
- }
-
-
-
- char * pascal ansimenu (char color, char trunc, char *line) {
-
- /* trunc & 1=return 1st letter only */
- /* trunc & 2=no graphics version */
- /* trunc & 4=return position # */
- /* trunc & 8=don't uppercase */
-
- register word x=0;
- char *p[36];
- char s[144]="";
- word pos[36];
- char *t;
- char was;
- char is;
- char temp;
- char tempdisablesub;
- char nump;
-
- stripcr(line);
- if (!strlen(line)) return s;
- p[x++]=strtok(line," ");
- while (x<34 && (p[x++]=strtok(0," ")));
- p[--x]=NULL;
- if (!*p) return *p;
- nump=(char)x-1;
- for (x=0;p[x];x++) while (t=strchr(p[x],'_')) *t=' ';;
- tempdisablesub=disablesub;
- disablesub=1;
- if (!user.graphics || user.ansimenus || (trunc & 2)) goto NoGraph;
- Over:
- is=was=0;
- for (x=0;x<35;x++) pos[x]=0;
- gprintf(0,"\x1b[0;1;%hum",color);
- if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
- fputs("\r",stdout);
- *pos=1;
- printm("\x1b[1C");
- printm(*p);
- for (x=1;p[x];x++) {
- printm(" ");
- printm(p[x]);
- pos[x]=pos[x-1]+strlen(p[x-1])+2;
- }
- Next:
- if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
- fputs("\r",stdout);
- gprintf(0,"\x1b[0;1;%hum\x1b[%uC",color,pos[was]);
- printm(p[was]);
- if (baud) while (!fossil(TRANSMIT,'\r')) carrchk();
- fputs("\r",stdout);
- gprintf(0,"\x1b[7m\x1b[%uC",pos[is]);
- printm(p[is]);
- gprintf(0,"\x1b[0;1;%hum",color);
- was=is;
- None:
- helpnum=0;
- temp=*genin(1,0,0,0,ARROWS);
- switch((int)temp) {
- case 1:
- case 4:
- case '4': if(is)is--;
- else is=nump;
- break;
- case 0: printm("\n");
- if(trunc & 1) p[is][1]=0;
- disablesub=tempdisablesub;
- if(trunc & 4) {
- sprintf(s,"%u",is);
- return (s);
- }
- else if(!(trunc & 8)) strupr(p[is]);
- return p[is];
- case 5:
- case 2:
- case '6': if (!p[is+1]) is=0;
- else is++;
- break;
- case 3: printm("\n");
- goto Over;
- case 11:
- case 27: printm("\n");
- *s=0;
- disablesub=tempdisablesub;
- return s;
- default: if (trunc & 1) {
- for (x=0;p[x]!=NULL;x++) {
- if (toupper(temp)==*p[x]) {
- printm("\n");
- p[x][1]=0;
- disablesub=tempdisablesub;
- if (trunc & 4) {
- sprintf(s,"%u",x);
- return (s);
- }
- else if(!(trunc & 8)) strupr(p[x]);
- return p[x];
- }
- }
- }
- break;
- }
- goto Next;
-
- NoGraph:
-
- is=temp=was=0;
- for (x=0;p[x];x++) {
- if((wherex()+strlen(p[x])+2+2)>(int)(user.length-3)) printm("\n");
- if (trunc & 1) {
- if (user.graphics) gprintf(0,"\x1b[0;2;%hum[\x1b[0;1;%hum%c\x1b[0;2;%hum]\x1b[0;1;%hum%s ",color,color,*p[x],color,color,&p[x][1]);
- else gprintf(0,"[%c]%s ",*p[x],&p[x][1]);
- }
- else {
- gprintf(0,"%s ",p[x]);
- if (strlen(p[x])>temp) temp=strlen(p[x]);
- }
- }
- say_prompt(278);
- if (trunc & 1) {
- temp=1;
- was=1;
- }
- helpnum=0;
- strcpy(s,genin(temp,0,1,was,ALLL));
- if (trunc & 1) {
- for (x=0;p[x];x++) {
- if (toupper(*s)==*p[x]) {
- p[x][1]=0;
- printm("\n");
- disablesub=tempdisablesub;
- if (trunc & 4) {
- sprintf(s,"%u",x);
- return (s);
- }
- else return strupr(p[x]);
- }
- }
- say_prompt(277);
- goto NoGraph;
- }
- for (x=0;p[x];x++) {
- if (!stricmp(s,p[x])) {
- printm("\n");
- disablesub=tempdisablesub;
- if (trunc & 4) {
- sprintf(s,"%u",x);
- return (s);
- }
- else if(!(trunc & 8)) strupr(p[x]);
- return p[x];
- }
- }
- say_prompt(277);
- goto NoGraph;
- }
-
-
- char * pascal ansimenu3 (char *title, char *file, char *color) {
-
- int handle;
- char *myvars[22];
- int register x;
- int y;
- int z;
- static char s[81];
- long pos[50];
- char endoffile=0;
- char keyin;
- char tempdisablesub;
-
- level=0;
- handle=oopen(file,O_RDONLY | O_BINARY | O_DENYNONE);
- if(handle==-1) {
- level=1;
- return "";
- }
- lseek(handle,0L,SEEK_END);
- if(tell(handle)==0L) {
- level=1;
- cclose(handle);
- return "";
- }
- lseek(handle,0L,SEEK_SET);
- tempdisablesub=disablesub;
- y=0;
- for(x=0;x<22;x++) myvars[x]=NULL;
-
- Loop: /* Load vars with lines from file */
-
- for(x=0;x<22;x++) { /* Free previously used vars */
- if(myvars[x]) {
- ffree(myvars[x]);
- myvars[x]=NULL;
- }
- }
- pos[y]=tell(handle);
- for(x=0;x<21;x++) {
- if(!fgetsx(s,81,handle)) {
- endoffile=1;
- break;
- }
- s[80]=0;
- stripcr(s);
- myvars[x]=(char *)mmalloc(strlen(s)+1);
- if(!myvars[x]) { /* Allocation error */
- say_prompt(459);
- for(x=0;x<21;x++) { /* Free previously used vars */
- if(myvars[x]) {
- ffree(myvars[x]);
- }
- }
- level=1;
- cclose(handle);
- disablesub=tempdisablesub;
- return "";
- }
- strcpy(myvars[x],s);
- }
-
- /* We now have a null-terminated array of null-terminated arrays */
-
- gprintf(0,"\x1b[2J%s\n%s",title,color);
- z=x=0;
- while(myvars[x]) {
- gprintf(0," %1.78s",myvars[x]);
- if(wherex()<79)printm(" ");
- x++;
- if(myvars[x]) printm("\n");
- }
- if(!x) printm(" -=>No more selections available<=-");
- say_prompt(578);
-
- /* x now equals highest available array element + 1 */
-
- while(1) {
-
- if(myvars[z]) {
- gprintf(0,"\x1b[%d;1H\x1b[7m %-1.78s",z+2,myvars[z]);
- if(wherex()<79)printm(" ");
- printm(color);
- }
-
- helpnum=0;
- keyin=*genin(1,0,1,1,ARROWS);
- switch((int)keyin) {
- case 1:
- case 4:
- case '8': if(myvars[z]) {
- gprintf(0,"\x1b[%d;1H %-1.78s",z+2,myvars[z]);
- if(wherex()<79)printm(" ");
- }
- if(z)z--;
- else z=x-1;
- break;
- case 0: cclose(handle);
- if(!x) *s=0;
- else strcpy(s,myvars[z]);
- for(x=0;x<22;x++) { /* Free previously used vars */
- if(myvars[x]) {
- ffree(myvars[x]);
- }
- }
- disablesub=tempdisablesub;
- return s;
- case 5:
- case 2:
- case '2': if(myvars[z]) {
- gprintf(0,"\x1b[%d;1H %-1.78s",z+2,myvars[z]);
- if(wherex()<79)printm(" ");
- }
- if(z<(x-1)) z++;
- else z=0;
- break;
- case 3: lseek(handle,pos[y],SEEK_SET);
- goto Loop;
- case 11:
- case 27: level=2;
- disablesub=tempdisablesub;
- cclose(handle);
- for(x=0;x<22;x++) { /* Free previously used vars */
- if(myvars[x]) {
- ffree(myvars[x]);
- }
- }
- return "";
- case 199:
- case 'H':
- case '7': y=0;
- endoffile=0;
- lseek(handle,0L,SEEK_SET);
- goto Loop;
- case '3':
- case 209:
- case 'N': if(!endoffile) {
- y++;
- if(y>249) y=0;
- }
- else lseek(handle,pos[y],SEEK_SET);
- goto Loop;
- case 201:
- case '9':
- case '-':
- case 'P': endoffile=0;
- if(y) y--;
- lseek(handle,pos[y],SEEK_SET);
- goto Loop;
- }
- }
- return "";
- }
-
-
-
- void pascal make_list (char *file,char *mask,char *includepath,char overwrite) {
-
- struct ffblk f;
- int handle;
- char *ip;
-
- level=0;
- if(!overwrite) unlink (file);
- handle=oopen(file,O_RDWR | O_DENYWRITE | O_BINARY);
- if(handle==-1) handle=ccreat(file,S_IWRITE);
- if(handle==-1) {
- level=1;
- return;
- }
- ip=includepath;
- lseek(handle,0L,SEEK_END);
- if(!ip) ip="";
-
- if(findfirst(mask,&f,0)) {
- if(tell(handle)==0L) {
- cclose(handle);
- unlink(file);
- }
- else cclose(handle);
- return;
- }
-
- do {
- ffprintf(handle,"%s%s\r\n",ip,f.ff_name);
- } while(!findnext(&f));
-
- cclose(handle);
- }
-
-
- void pascal ansimenu4 (char *title, char *file, char *color, char *fileout, char *prepend,char overwrite) {
-
- int handle;
- char *myvars[4097];
- int register x;
- int z,y,w;
- char s[81];
- char keyin;
- char tempdisablesub;
- char mark[4097];
- char *pre;
-
- level=0;
- handle=oopen(file,O_RDONLY | O_BINARY | O_DENYNONE);
- if(handle==-1) {
- level=1;
- return;
- }
- lseek(handle,0L,SEEK_END);
- if(tell(handle)==0L) {
- level=1;
- cclose(handle);
- return;
- }
- lseek(handle,0L,SEEK_SET);
- tempdisablesub=disablesub;
- pre=prepend;
- if(!pre) pre="";
- for(x=0;x<4097;x++) {
- myvars[x]=NULL;
- mark[x]=0;
- }
-
- /* Load vars with lines from file */
-
- w=0;
- for(x=0;x<4096;x++) {
- if(!fgetsx(s,81,handle)) {
- break;
- }
- s[80]=0;
- stripcr(s);
- myvars[x]=(char *)mmalloc(strlen(s)+1);
- if(!myvars[x]) { /* Allocation error */
- say_prompt(459);
- for(x=0;x<4096;x++) { /* Free previously used vars */
- if(myvars[x]) {
- ffree(myvars[x]);
- }
- }
- level=1;
- cclose(handle);
- disablesub=tempdisablesub;
- return;
- }
- strcpy(myvars[x],s);
- w++;
- }
- cclose(handle);
- if(!w) {
- level=1;
- return;
- }
- y=0;
-
- /* We now have a null-terminated array of null-terminated arrays */
-
- Loop:
-
- gprintf(0,"\x1b[2J%s\n%s",title,color);
- x=z=0;
- while(myvars[x+y] && x<21) {
- gprintf(0,"\x1b[%d;1H",x+2);
- if(mark[x+y]) printm("\x1A");
- else printm(" ");
- gprintf(0,"%-1.78s",myvars[x+y]);
- if(wherex()<79)printm(" ");
- x++;
- printm("\n");
- }
- if(!x) printm(" -=>No more selections available<=-");
- say_prompt(579);
-
- while(1) {
-
- if(myvars[z+y]) {
- gprintf(0,"\x1b[%d;1H\x1b[7m",z+2);
- if(mark[z+y]) printm("\x1A");
- else printm(" ");
- gprintf(0,"%-1.78s",myvars[z+y]);
- if(wherex()<79)printm(" ");
- printm(color);
- }
-
- SkipRedraw:
-
- helpnum=0;
- keyin=*genin(1,0,1,1,ARROWS);
- switch((int)keyin) {
- case 1:
- case 4:
- case '8': if(myvars[z+y]) {
- gprintf(0,"\x1b[%d;1H",z+2);
- if(mark[z+y]) printm("\x1A");
- else printm(" ");
- gprintf(0,"%-1.78s",myvars[z+y]);
- if(wherex()<79)printm(" ");
- }
- if(z)z--;
- else z=x-1;
- break;
- case 0: if(!x) goto SkipRedraw;
- mark[z+y]=1-mark[z+y];
- if(mark[z+y])gprintf(0,"\x1b[%d;1H\x1b[7m\x1A%s",z+2,color);
- else gprintf(0,"\x1b[%d;1H\x1b[7m %s",z+2,color);
- goto SkipRedraw;
- case 5:
- case 2:
- case '2': if(myvars[z+y]) {
- gprintf(0,"\x1b[%d;1H",z+2);
- if(mark[z+y]) printm("\x1A");
- else printm(" ");
- gprintf(0,"%-1.78s",myvars[z+y]);
- if(wherex()<79)printm(" ");
- }
- if(z<(x-1)) z++;
- else z=0;
- break;
- case 'U': for(x=0;x<4096;x++) mark[x]=0;
- goto Loop;
- case 'A': for(x=0;x<4096;x++) mark[x]=1;
- goto Loop;
- case 3: break;
- case 27: level=2;
- for(x=0;x<4096;x++) { /* Free previously used vars */
- if(myvars[x]) {
- ffree(myvars[x]);
- }
- }
- disablesub=tempdisablesub;
- return;
- case 11: if(!overwrite) unlink(fileout);
- handle=oopen(fileout,O_RDWR | O_BINARY | O_DENYWRITE);
- if(handle==-1) handle=ccreat(fileout,S_IWRITE);
- if(handle==-1) {
- level=1;
- }
- else {
- lseek(handle,0L,SEEK_END);
- for(x=0;x<4096;x++) { /* Free previously used vars */
- if(myvars[x]) { /* And write marked files */
- if(mark[x]) {
- ffprintf(handle,"%s%s\r\n",pre,myvars[x]);
- }
- ffree(myvars[x]);
- }
- }
- lseek(handle,0L,SEEK_END);
- if(tell(handle)==0L) {
- cclose(handle);
- unlink(fileout);
- }
- else cclose(handle);
- }
- disablesub=tempdisablesub;
- return;
- case '1':
- case 'E': if(w<21) break;
- y=w-21;
- if(y<0) y=0;
- goto Loop;
- case 'H':
- case '7': if(w<21 || y<21) break;
- y=0;
- goto Loop;
- case '3':
- case 209:
- case 'N': if(y>(w-21)) break;
- y+=21;
- if(y>(w-21)) {
- if(w>20)y=(w-21);
- else y=0;
- }
- goto Loop;
- case 201:
- case '9':
- case '-':
- case 'P': if(w<21 || y<21) break;
- y-=21;
- if(y<0) y=0;
- goto Loop;
- }
- }
- }
-
-
- char pascal magazine_input (char *text) {
-
- char prettystring[384];
- char *p;
- char *divie[43];
- register int x;
- char comval,highcommand,command,wascommand,lastcommand=0;
-
- strncpy(prettystring,text,384);
- prettystring[383]=0;
- divie[0]=strtok(prettystring," ");
- while(p=strchr(divie[0],'_')) *p=' ';
- if(divie[0]) {
- x=1;
- while((divie[x]=strtok(0," ")) && x<41) {
- while(p=strchr(divie[x],'_')) *p=' ';
- x++;
- }
- highcommand=(char)x-1;
- }
- else return 0;
- while(1) {
- FancyRedo:
- printm(divie[lastcommand]);
- FancyNull:
- command=*genin(1,0,1,1,HYPER);
- wascommand=lastcommand;
- switch((int)command) {
- case 0: command=toupper(*divie[lastcommand]);
- backup(divie[lastcommand]);
- gprintf(0,"%c",*divie[lastcommand]);
- goto DirectEntry;
- case 1:
- case 4:
- case '4':
- case '8': if(lastcommand==0) lastcommand=highcommand;
- else lastcommand--;
- break;
- case 5:
- case 2:
- case '6':
- case '2': if(lastcommand==highcommand) lastcommand=0;
- else lastcommand++;
- break;
- case 11:
- case 27: printm("\n");
- return 0;
- case 3: printm("\n");
- goto FancyRedo;
- default: backup(divie[wascommand]);
- gprintf(0,"%c",toupper(command));
- goto DirectEntry;
- }
- backup(divie[wascommand]);
- goto FancyRedo;
- }
- DirectEntry:
- comval=0;
- for(x=0;x<42;x++) {
- if(!*divie[x])break;
- if(command==toupper(*divie[x])) {
- comval=(char)x+1;
- break;
- }
- }
- if(!comval)goto FancyRedo;
- return comval;
- }
-
-
- void pascal do_picks (char arg,char *b, word *lastlevel) {
-
- char *cm,*pp;
- char a;
-
- switch ((int)arg) {
-
- case '[': /* Invoke list-pick */
- if (user.ansimenus || !user.graphics) break;
- if(*b=='e') {
- b++;
- a=lastlevel[*b-'0'];
- }
- else a=*b-'0';
- if(a<0 || a>9) {
- level=1;
- b=NULL;
- break;
- }
- b+=2;
- if(*b=='@') {
- pp=variable[b[1]-'0'];
- b+=3;
- }
- else {
- pp=strtok(b,",");
- b=strtok(0,"\n");
- }
- if(*b=='@') {
- cm=variable[b[1]-'0'];
- b+=3;
- }
- else {
- cm=strtok(b,",");
- b=strtok(0,"\n");
- }
- if(*b=='@') b=variable[b[1]-'0'];
- strcpy(variable[a],ansimenu3(pp,cm,b));
- break;
-
- case ']': /* Invoke make-list */
- if(*b=='e') {
- b++;
- a=lastlevel[*b-'0'];
- }
- else a=*b-'0';
- b+=2;
- if(*b=='@') {
- pp=variable[b[1]-'0'];
- b+=3;
- }
- else {
- pp=strtok(b,",");
- b=strtok(0,"\n");
- }
- if(*b=='@') {
- cm=variable[b[1]-'0'];
- b+=3;
- }
- else {
- cm=strtok(b,",");
- b=strtok(0,"\n");
- }
- if(*b=='@') b=variable[b[1]-'0'];
- make_list(pp,cm,b,a);
- break;
-
- case '{': /* Invoke list-mark */
- {
-
- char *p,*p1;
-
- if (user.ansimenus || !user.graphics) break;
- if(*b=='e') {
- b++;
- a=lastlevel[*b-'0'];
- }
- else a=*b-'0';
- if(a<0 || a>9) {
- level=1;
- b=NULL;
- break;
- }
- b+=2;
- if(*b=='@') {
- pp=variable[b[1]-'0'];
- b+=3;
- }
- else {
- pp=strtok(b,",");
- b=strtok(0,"\n");
- }
- if(*b=='@') {
- cm=variable[b[1]-'0'];
- b+=3;
- }
- else {
- cm=strtok(b,",");
- b=strtok(0,"\n");
- }
- if(*b=='@') {
- p=variable[b[1]-'0'];
- b+=3;
- }
- else {
- p=strtok(b,",");
- b=strtok(0,"\n");
- }
- if(*b=='@') {
- p1=variable[b[1]-'0'];
- b+=3;
- }
- else {
- p1=strtok(b,",");
- b=strtok(0,"\n");
- }
- if(*b=='@') b=variable[b[1]-'0'];
- ansimenu4(pp,cm,p,p1,b,a);
- }
- break;
-
- case '}':
- if(*b=='@') {
- pp=variable[b[1]-'0'];
- b+=3;
- }
- else {
- pp=strtok(b,",");
- b=strtok(0,"\n");
- }
- if(*b=='@') cm=variable[b[1]-'0'];
- else cm=strtok(b,", \n");
- find_help(pp,cm,0);
- break;
- case '`':
- if(*b=='@') level=magazine_input(variable[b[1]-'0']);
- else level=magazine_input(stripcr(b));
- break;
- }
- }
-
-
- /*
- static int av_trans[]={0,4,2,6,1,5,3,7};
-
-
- char * pascal avatar2ansi (int avatar) {
-
- int foreg;
- int backg;
- static char temp[13];
- static char ansi[20];
-
- if(!user.graphics) return "";
-
- avatar &= 127;
- strcpy(ansi,"\x1b[");
- backg=avatar/16;
- avatar -= backg*16;
- foreg=avatar;
- if (foreg > 7) {
- foreg -= 8;
- strcat(ansi,"0;1;");
- }
- else strcat(ansi,"0;");
-
- sprintf(temp,"%d",av_trans[foreg]);
-
- if (!backg) {
- strcat(ansi,"3");
- strcat(ansi,temp);
- }
- else {
- strcat(ansi,"3");
- strcat(ansi,temp);
- strcat(ansi,";4");
- sprintf(temp,"%d",av_trans[backg]);
- strcat(ansi,temp);
- }
- strcat(ansi,"m");
- return ansi;
- }
- */
-