home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 328_02 / wputs.c < prev    next >
C/C++ Source or Header  |  1991-03-17  |  1KB  |  82 lines

  1. /*! wputs
  2.  *
  3.  *
  4.  *   put a string to video at the current cursor position
  5.  *   uses wputstyle to control output.
  6.  *
  7.  */
  8. #include  "wsys.h"
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15. int wputs(char *s)
  16.     {
  17.  
  18.     int count = 0;
  19.     unsigned char save_cur;
  20.     unsigned char more, inline_attr;
  21.  
  22.  
  23.     _NORMALIZE(s);    /* model-dependent normalization */
  24.  
  25.     #ifdef __LARGE__
  26.         if ( s==NULL ) return (0);
  27.     #endif    /* __LARGE__ */
  28.     #ifdef __COMPACT__
  29.         if ( s==NULL ) return (0);
  30.     #endif    /* __COMPACT__ */
  31.  
  32.     if ( wmode == 'T' )
  33.         {
  34.         save_cur = (w0->winflag) & WFL_CURSOR;
  35.         if ( save_cur  )
  36.             {
  37.             wcursor (OFF);
  38.             }
  39.         }
  40.  
  41.  
  42.     /* see if we're doing in-line attributes
  43.      *    use \a for inline attributes if:
  44.      *        the ALARM flag is off and the ATTR flag is on
  45.      */
  46.     #define THREE_FLAGS     (WPUTANSI | WPUTATTR | WPUTALARM)
  47.     #define TWO_FLAGS    (WPUTANSI | WPUTATTR )
  48.  
  49.  
  50.     inline_attr = ( ( w0-> winputstyle & THREE_FLAGS ) == TWO_FLAGS ) ?
  51.             1: 0;
  52.  
  53.     for  ( count=0, more = 1  ; (*s) && more ; ++s, ++count )
  54.         {
  55.         if  ( inline_attr && (*s == '\a') && (*(s+1) != 0)  )
  56.             {
  57.             wsetattr ( *(++s) );
  58.             }
  59.         else
  60.             {
  61.             more = wputc (*s);
  62.             }
  63.         }
  64.  
  65.  
  66.     if (wmode == 'T')
  67.         {
  68.         if ( save_cur )
  69.             {
  70.             wcursor (ON);
  71.             }
  72.  
  73.         }
  74.  
  75.  
  76.     return(count);
  77.  
  78.     }  /*end of wputs */
  79.  
  80.  
  81.  
  82.