Annotation of uae/src/dos-ui.c, revision 1.1

1.1     ! root        1:  /*
        !             2:   * UAE - The Un*x Amiga Emulator
        !             3:   *
        !             4:   * DosUAE Interface - 07-17-96 02:42pm
        !             5:   *
        !             6:   * (c) 1995 Bernd Schmidt, Ed Hanway
        !             7:   *          Interface by Tim Gunn
        !             8:   */
        !             9: 
        !            10: #include "sysconfig.h"
        !            11: #include "sysdeps.h"
        !            12: 
        !            13: #include <stdio.h>
        !            14: #include <ctype.h>
        !            15: #include <dpmi.h>
        !            16: #include <dos.h>
        !            17: #include <conio.h>
        !            18: #include <grx20.h>
        !            19: 
        !            20: #include "config.h"
        !            21: #include "options.h"
        !            22: #include "autoconf.h"
        !            23: #include "dos-ui.h"
        !            24: #include "gui.h"
        !            25: #include "memory.h"
        !            26: 
        !            27: #define TB textbackground
        !            28: #define TC textcolor
        !            29: #define CURSON _setcursortype(_NORMALCURSOR);
        !            30: #define CURSOFF _setcursortype(_NOCURSOR);
        !            31: #define SCRON _wscroll = 1;
        !            32: #define SCROFF _wscroll = 0;
        !            33: 
        !            34: int SETTC=15;
        !            35: int SETTB=1;
        !            36: int _CWINX = 1,_CWINY = 1,_CWINX2 = 80,_CWINY2 = 25;
        !            37: int dx,dy,dx2,dy2,dlx,dly,dlx2,dly2;
        !            38: char vbuff[4096];
        !            39: struct find_t sfile;
        !            40: 
        !            41: char *tui_filereq(char *spec)
        !            42: {
        !            43:     struct find_t *files;
        !            44:     struct find_t ffblk;
        !            45: 
        !            46:     int i,done,key=0,zx,zy,zx2,zy2;
        !            47:     int ysize=8,cur=0,xpos=10,ypos,y=0,z,count=0;
        !            48:     char buff2[4096];
        !            49: 
        !            50:     int speccount=0,sc2=0,speclen;
        !            51:     char specbuff[12];
        !            52:     specbuff[0]=0;
        !            53:     speclen = strlen(spec);
        !            54: 
        !            55:     done = _dos_findfirst("*.*",_A_NORMAL,&ffblk);
        !            56:     while(!done) { count++; done = _dos_findnext(&ffblk); }
        !            57:     files = (struct find_t *)calloc(count , sizeof(struct find_t));
        !            58: 
        !            59:     count=1; // starts at 1 because the first entry is 'none'.
        !            60:     while(speccount<=speclen) {
        !            61: 
        !            62:         if(spec[speccount]!=' ' || speccount!=speclen)
        !            63:         {
        !            64:             specbuff[sc2]=spec[speccount];
        !            65:         }
        !            66:         else
        !            67:         {
        !            68:             specbuff[sc2]=0; sc2=-1; //sc2=-1 so the count makes it 0;
        !            69:             done = _dos_findfirst(specbuff,_A_NORMAL,&ffblk);
        !            70:             files[count]=ffblk;
        !            71:             while(!done) {
        !            72:                 count++;
        !            73:                 done = _dos_findnext(&ffblk);
        !            74:                 files[count]=ffblk;
        !            75:             }
        !            76:             specbuff[0]=0;
        !            77:         }
        !            78:         speccount++; sc2++;
        !            79: 
        !            80:     }
        !            81:     specbuff[sc2]=0; //repeated coz of no space, bad code rewrite it!
        !            82:     done = _dos_findfirst(specbuff,_A_NORMAL,&ffblk);
        !            83:     files[count]=ffblk;
        !            84:     while(!done) {
        !            85:         count++;
        !            86:         done = _dos_findnext(&ffblk);
        !            87:         files[count]=ffblk;
        !            88:     }
        !            89:     strcpy(files[0].name,"none");
        !            90: 
        !            91: 
        !            92:     if(count<9) { ysize=count; }
        !            93:     if(ysize>15) { ysize=15; }
        !            94:     ypos=12-(ysize/2);
        !            95: 
        !            96:     zx=xpos; zy=ypos; zx2=xpos+20; zy2=ypos+ysize+1;
        !            97:     gettext(zx-1,zy-1,zx2+1,zy2+1,buff2);
        !            98:     window(1,1,80,25); drawbox(zx-1,zy-1,zx2+1,zy2+1);
        !            99:     gotoxy(zx+1,zy-1); cprintf("Select a file.");
        !           100:     window(zx,zy,zx2,zy2); clrscr();
        !           101: 
        !           102:     gotoxy(1,ysize+1); cprintf("-------------");
        !           103:     while(key!=13) {
        !           104:        switch(key) {
        !           105:         case 72: cur--; break;
        !           106:         case 80: cur++; break;
        !           107:         case 27:
        !           108:            TB(SETTB); TC(SETTC);
        !           109:            window(_CWINX,_CWINY,_CWINX2,_CWINY2);
        !           110:            puttext(zx-1,zy-1,zx2+1,zy2+1,buff2);
        !           111:            sfile.name[0]=0;
        !           112:            return sfile.name;
        !           113:         }
        !           114:         if(count-y<ysize) z=count; else z=ysize;
        !           115:        if(cur>z-1) { cur=z-1; y++; }
        !           116:        if(cur<0) { cur=0; y--; }
        !           117:        if(y<0) y=0;
        !           118:        if(y>count-z) y=count-z;
        !           119:        for(i=y;i<y+z;i++) {
        !           120:             if(i==y+cur) { TB(SETTC); TC(SETTB); }
        !           121:            else { TB(SETTB); TC(SETTC); }
        !           122:            gotoxy(1,i-y+1);
        !           123:            cprintf("            ");
        !           124:            gotoxy(1,i-y+1);
        !           125:            cputs(files[i].name);
        !           126:        }
        !           127:         gotoxy(1,ysize+2);
        !           128:        cprintf("             ");
        !           129:        gotoxy(1,ysize+2);
        !           130:        cprintf("%s",files[y+cur].name);
        !           131: 
        !           132:        key = getch();
        !           133:     }
        !           134: 
        !           135:     TB(SETTB); TC(SETTC);
        !           136: 
        !           137:     if(y+cur!=0) {
        !           138:         sfile=files[y+cur];
        !           139:     } else {
        !           140:         sfile.name[0]=0;
        !           141:     }
        !           142: 
        !           143:     window(_CWINX,_CWINY,_CWINX2,_CWINY2);
        !           144:     puttext(zx-1,zy-1,zx2+1,zy2+1,buff2);
        !           145: 
        !           146:     return sfile.name;
        !           147: }
        !           148: 
        !           149: void tui_dlog(int xcoord,int ycoord,int xcoord2,int ycoord2) 
        !           150: {
        !           151:     dx = xcoord; dy = ycoord; dx2 = xcoord2; dy2 = ycoord2;
        !           152:     gettext(dx-1,dy-1,dx2+1,dy2+1,vbuff);
        !           153:     window(1,1,80,25); drawbox(dx-1,dy-1,dx2+1,dy2+1);
        !           154:     window(dx,dy,dx2,dy2);
        !           155:     dlx = _CWINX; dly = _CWINY; dlx2 = _CWINX2; dly2 = _CWINY2;
        !           156:     _CWINX = dx; _CWINY = dy; _CWINX2 = dx2 ;_CWINY2 = dy2;
        !           157:     clrscr();
        !           158: }
        !           159: 
        !           160: void tui_dlogdie() 
        !           161: {
        !           162:     window(dlx,dly,dlx2,dly2);
        !           163:     _CWINX = dlx; _CWINY = dly; _CWINX2 = dlx2; _CWINY2 = dly2;
        !           164:     puttext(dx-1,dy-1,dx2+1,dy2+1,vbuff);
        !           165: }
        !           166: 
        !           167: void tui_drawbox(int x, int y, int x2, int y2) 
        !           168: {
        !           169:     int i;
        !           170:     gotoxy(x,y); cprintf("�");
        !           171:     for(i=0;i<x2-x-1;i++){ cprintf("�"); }
        !           172:     cprintf("�");
        !           173:     gotoxy(x,y2); cprintf("�");
        !           174:     for(i=0;i<x2-x-1;i++){ cprintf("�"); }
        !           175:     cprintf("�");
        !           176:     for(i=y+1;i<y2;i++) {
        !           177:         gotoxy(x,i); cprintf("�");
        !           178:         gotoxy(x2,i); cprintf("�");
        !           179:     }
        !           180: }
        !           181: 
        !           182: void tui_errorbox(char *errortxt) 
        !           183: {
        !           184:     int half,zx,zy,zx2,zy2;
        !           185:     char buff[2048];
        !           186:     half = strlen(errortxt)/2;
        !           187: 
        !           188:     TC(SETTC); TB(SETTB);
        !           189: 
        !           190:     zx=35-half; zy=10; zx2=45+half; zy2=15;
        !           191: 
        !           192:     gettext(zx-1,zy-1,zx2+1,zy2+1,buff);
        !           193:     window(1,1,80,25); drawbox(zx-1,zy-1,zx2+1,zy2+1);
        !           194:     window(zx,zy,zx2,zy2); clrscr();
        !           195: 
        !           196:     gotoxy(5,3); cprintf(errortxt);
        !           197:     gotoxy(half+1,5); cprintf("HIT A KEY");
        !           198:     getch();
        !           199: 
        !           200:     window(_CWINX,_CWINY,_CWINX2,_CWINY2);
        !           201:     puttext(zx-1,zy-1,zx2+1,zy2+1,buff);
        !           202: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.