home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 286_02 / readstr.c < prev    next >
Text File  |  1989-05-25  |  2KB  |  85 lines

  1. #include <stdio.h>
  2. #include <gds.h>
  3.  
  4. ReadStr(buffer, length, startx, starty, mode, cursor1, cursor2)
  5. char *buffer;
  6. int length, startx, starty, mode, cursor1, cursor2;
  7. {
  8.     int ch,count,tmptype,w,h,loop,kbret;
  9.  
  10.     count=0;
  11.     tmptype=CUR_PLOT;
  12.     for (;;) {
  13.         writec(startx,starty,cursor1,&w,&h,0x38);
  14.         switch (mode & 0x03) {
  15.         case 1:
  16.             writec(startx,starty,cursor1,&w,&h,0);
  17.             break;
  18.         case 3:
  19.             PlotType(2);
  20.             writec(startx,starty,cursor1,&w,&h,0);
  21.         case 2:
  22.             PlotType(2);
  23.             for(;;) {
  24.                 writec(startx,starty,cursor1,&w,&h,mode & 0x01?0x38:0);
  25.                 for(loop=TEN_MS; loop>0; loop--) {
  26.                     if ((kbret=kbhit()) != 0) break;
  27.                 }
  28.                 writec(startx,starty,cursor1,&w,&h,mode & 0x01?0x38:0);
  29.                 if (kbret) break;
  30.                 for(loop=TEN_MS; loop>0; loop--) {
  31.                     if ((kbret=kbhit())!=0) break;
  32.                 }
  33.                 if (kbret) break;
  34.             }
  35.             PlotType(tmptype);
  36.         case 0:
  37.             break;
  38.         }
  39.         ch=getch();
  40.         switch (mode & 0x03) {
  41.         case 1:
  42.             writec(startx,starty,cursor1,&w,&h,0);
  43.             break;
  44.         case 3:
  45.             PlotType(2);
  46.             writec(startx,starty,cursor1,&w,&h,0);
  47.             PlotType(tmptype);
  48.         case 2:
  49.         case 0:
  50.             break;
  51.         }
  52.         writec(startx,starty,cursor1,&w,&h,0x38);
  53.         if (ch==0x0d) break;
  54.         if (ch==0) {
  55.             ch=getch();
  56.         } else if (ch==0x08) {
  57.             if (count) {
  58.                 count--;
  59.                 PlotType(2);
  60.                 writec(startx,starty,*(--buffer),&w,&h,1);
  61.                 PlotType(tmptype);
  62.                 startx-=w;
  63.             }
  64.         } else {
  65.             count++;
  66.             if (count >= length) {
  67.                 count--;
  68.             } else {
  69.                 *buffer++ = ch;
  70.                 writec(startx,starty,ch,&w,&h,0);
  71.                 startx+=w;
  72.             }
  73.         }
  74.     }
  75.     *buffer='\0';
  76.     PlotType(tmptype);
  77.     if (mode & 0x10) {
  78.         writec(startx,starty,cursor2,&w,&h,0);
  79.         startx+=w;
  80.     }
  81. LASTX=startx;
  82. LASTY=starty;
  83. }
  84.  
  85.