原始程式

UReadS
原始檔-起始
/*---------( READS.C  )-----------------*/
#include "w_obj.h"

extern   unshort  RetKey;
extern   int      Modify,NetWare,NetWritAble;
extern   int      CURSOR;
unchar   Copy_S[258];
/*================================================================*/
int  UReadS(int X,int Y,int len,char *Pstr,char *flagS,int attr_off,int attr)
{
   char     tmpS[82],orginS[82];
   int      wKeepLoop=ON;
   int      NowX=X,sw;
   int      iStrR=X+len-1;

   if(X<1 || len<1) UFatal("ReadS X,len<0");
   UETKbSet(*flagS);      /* 1'st char to set input mode Chinese/Number */
   if(strlen(flagS) >= 3) NowX += atoi(flagS+2);
   USetColor(X,Y,len,attr);
   UGetS(X,Y,len,orginS);
   UShiftString(orginS,len,flagS);
   USetCursor(CURSOR);   UClKbBuf();
   do
   {   gotoxy(NowX,Y);
       RetKey=UGetKb();
       if(0x00FF<RetKey && RetKey<=0x8100)     /* Funtion Key */
       {    switch(RetKey)
            {  case INS  : CURSOR *= -1;
                           USetCursor(CURSOR);             break;
               case BACK : if(NowX>X)
                           {   UGetS(NowX,Y,iStrR-NowX+1,tmpS);
                               UShowSL(NowX-1,Y,iStrR-NowX+1,tmpS,attr);
                               tmpS[0]=SPACE;
                               UShowSL(iStrR,Y,1,tmpS,attr);
                           }
                           if(--NowX < X)
                           { wKeepLoop=OFF; RetKey=LEFT; }            break;
               case DEL  : UGetS(NowX+1,Y,iStrR-NowX,tmpS);
                           UShowSL(NowX,Y,iStrR-NowX,tmpS,attr);
                           tmpS[0]=SPACE;
                           UShowSL(iStrR,Y,1,tmpS,attr);              break;
               case LEFT : if(--NowX < X)
                           { wKeepLoop=OFF;  RetKey=LEFT;  }          break;
               case RIGHT: if(++NowX > iStrR)
                           { wKeepLoop=OFF;  RetKey=RIGHT; }          break;
               case TAB  : NowX+=6 ;
                           if(NowX > iStrR) NowX=iStrR;               break;
               case S_TAB: NowX-=6 ;
                           if(NowX < X) NowX=X;                       break;
               case A_C  : UGetS(NowX,Y,iStrR-NowX+1,Copy_S);
                           USetColor(NowX,Y,iStrR-NowX+1,V_COPY);     break;
               case A_M  : UShowSL(NowX,Y,min(iStrR-NowX+1,strlen(Copy_S)),Copy_S,attr);
                           for(NowX=X; NowX<iStrR; NowX++) if(UGetC(NowX,Y)<=SPACE) break;
                           if(NowX>=iStrR) NowX=X;                    break;
               case ENTER: wKeepLoop=OFF; RetKey=RIGHT;               break;
               default   : wKeepLoop=OFF;                             break;
            } /* end switch */
       } /* end if */
       else if((RetKey > 0x8101) && (NowX < iStrR))   /* CHINESE code */
       {    if(CURSOR==BIG)
            {   UGetS(NowX,Y,iStrR-NowX-1,tmpS);
                UShowSL(NowX+2,Y,iStrR-NowX-1,tmpS,attr);
            }
            tmpS[0]=(char)(RetKey >> 8);
            tmpS[1]=(char)(RetKey & 0x00FF);
            UShowSL(NowX,Y,2,tmpS,attr);
            NowX+=2;
            if(NowX>iStrR){ wKeepLoop=OFF;  RetKey=RIGHT;  }
       }
       else                   /* ASCII code */
       {    if(CURSOR==BIG)
            {   UGetS(NowX,Y,iStrR-NowX,tmpS);
                UShowSL(NowX+1,Y,iStrR-NowX,tmpS,attr);
            }
            tmpS[0]=(char)RetKey;  UShowSL(NowX++,Y,1,tmpS,attr);
            if(NowX>iStrR){ wKeepLoop=OFF;  RetKey=RIGHT; }
        }
   } while (wKeepLoop);
   USetCursor(OFF);
   UGetS(X,Y,len,Pstr);
   UShiftString(Pstr,len,flagS);
   UShowSL(X,Y,len,Pstr,attr_off);
   sw=strcmp(orginS,Pstr);
   if(sw) Modify=ON;                           /*有更動*/
   if(NetWare && NetWritAble==OFF) Modify=OFF; /*網路版且僅有查閱權*/
   return sw;
}
原始檔-結束

Byron Wey  Oct.21.1998


回首頁C之城