TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: All
from: Frank Adam
date: 1996-01-16 12:20:20
subject: [2/2] My fgets()

>>> Part 2 of 2...

   case BSP    : if(!insmode)
             {
              if(strpos > 0)
              {
               if(strpos >= maxpos-1) maxpos--;
               strpos--;x--;gotoxy(x,y);
               putchar(SPACE);gotoxy(x,y);
               retstr[strpos] = SPACE;
               }
                }
             else
             {
              if(strpos > 0)
              {
               memmove(&retstr[strpos-1],&retstr[strpos],maxpos-strpos);
               maxpos--;x--;strpos--;gotoxy(x,y);tempos = strpos;
               while(tempos < maxpos) putchar(retstr[tempos++]);
               putchar(SPACE);gotoxy(x,y);
               }
                }
             break;

   case DELETE : if(maxpos > 0)
             {
              memmove(&retstr[strpos],&retstr[strpos+1],maxpos-strpos);
              if(maxpos > strpos+1) maxpos--;
              tempos = strpos;
              while(tempos < maxpos) putchar(retstr[tempos++]);
              putchar(SPACE);gotoxy(x,y);
              }
            break;

   case TAB    : if(TABSPACE + maxpos < len)
             {
              if(insmode)
              {
               memmove(&retstr[strpos+TABSPACE],&retstr[strpos],
                                                       maxpos-strpos);
               memset(&retstr[strpos],SPACE,TABSPACE);retstr[maxpos] = 0;
               tempos = strpos;
               while(tempos < maxpos+TABSPACE) putchar(retstr[tempos++]);
               }
             maxpos += TABSPACE;x += TABSPACE;strpos += TABSPACE;
             gotoxy(x,y);
                }
            break;

   case LARROW : if(strpos > 0) {strpos--;x--;gotoxy(x,y);}
                   break;
   case RARROW : if(strpos < maxpos) {strpos++;x++;gotoxy(x,y);}
            break;
    } /* end switch */
         } /* end if !isprint(key) */

else if(isprint(key)){
                if(strpos < len)
                {
                 if(insmode)
                 {
               memmove(&retstr[strpos+1],&retstr[strpos],
                                                            maxpos-strpos);
               retstr[strpos]=key;                                  
               retstr[++maxpos] = 0;
              tempos = strpos;
              while(tempos < maxpos) putchar(retstr[tempos++]);
              gotoxy(++x,y);strpos++;
              }
                else {
                   putchar(key);
                   x++;retstr[strpos]=key;strpos++;
                    }
                if(strpos > maxpos) maxpos++;
                 }  /* end if strpos < len */
               }  /* end else if(insmode) */
  }  /* end for(;;) */
}

int getkey()
{
 FLUSHKEY;
 if(!ungetch(getch())) return getch()+getch()+256;/*is there a better way?*/
 else return getch();
 }

L8r Frank
___ Blue Wave/DOS v2.21

--- Maximus 3.00
* Origin: The Software Parlour (3:635/544)
SEEN-BY: 50/99 620/243 623/630 632/349 635/503 544 711/401 409 410 413 430
SEEN-BY: 711/510 808 809 932 934 712/515 713/888 714/906 800/1 7877/2809
@PATH: 635/544 50/99 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.