home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-2.ZIP / GFUNC / PUTCINC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-30  |  1.4 KB  |  73 lines

  1. /*
  2.  * putcinc.c
  3.  * contains: putcinc()
  4.  *
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include "gfuncts.h"
  9.  
  10. /*
  11.  *  void
  12.  * putcinc(chr,color,page)
  13.  *
  14.  * ARGUMENT
  15.  *  (char)    chr    -    character to write
  16.  *  (int)    color    -    color or monochrome attribute
  17.  *  (int)    page    -    video page to write
  18.  *
  19.  * DESCRIPTION
  20.  *  Output one character to Color Display and Increment Cursor to Next
  21.  *  Logical Position.  If in last column of a row, increment to next row.
  22.  *  Use pch to display character and attribute.  Translate newlines to
  23.  *  CR LF sequences.  Determine cursor position at each newline.
  24.  *
  25.  * AUTHOR
  26.  *   Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  27.  *
  28.  * MODIFICATIONS
  29.  *   "" Tue 08-Nov-1988 11:28:31
  30.  *    not handling tabs correctly in column 0 (SAR #0043).
  31.  */
  32. void GF_CONV putcinc(c,color,page)
  33. char c;
  34. int page, color;
  35. {
  36.     int x,y,width;
  37.     unsigned where;
  38.     struct GFREGS out;
  39.  
  40.     where=getcur(page);
  41.     x=(int)where&0xFF;
  42.     y=((int)where&0xFF00)>>8;
  43.     vstate(&out);
  44.     width=out.bx;
  45.     switch (c) {
  46.     case 0x0A:
  47.         if(y<gmaxrow-1)
  48.             ++y;
  49.         curset(y,0,page);
  50.         break;
  51.     case 0x0D:
  52.         curset(y,0,page);
  53.         break;
  54.     case '\t':
  55.         if(!x) {
  56.             x=8;
  57.             curset(y,x,page);
  58.         } else
  59.             while(x % 8)
  60.                 if(++x<width)
  61.                     curset(y,x,page);
  62.         break;
  63.     default:
  64.         pch(c,color,page);
  65.         if(x>=(width-1)) {
  66.             if(y<gmaxrow-1)
  67.                 ++y;
  68.             curset(y,0,page);
  69.         } else 
  70.             curset( y,++x,page );
  71.     }
  72. }
  73.