home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / curses-2.10.lha / curses / src / tputs.c < prev    next >
C/C++ Source or Header  |  1994-02-21  |  3KB  |  126 lines

  1. /* -*-C-*-
  2.  *
  3.  *
  4.  * Filename : Workbench2.0:src/curses/tputs.c
  5.  *
  6.  * Author   : Simon J Raybould.    (sie@fulcrum.co.uk).
  7.  *
  8.  * Date     : Tue Feb 09 21:40:34 1993
  9.  *
  10.  * Desc     : tputs(3)
  11.  *
  12.  *
  13.  * THIS CODE IS NOT PUBLIC DOMAIN
  14.  * ==============================
  15.  * 
  16.  * This code is copyright Simon J Raybould 1992, all rights are reserved.
  17.  * All code, ideas, data structures and algorithms remain the property of the
  18.  * author. Neither the whole nor sections of this code may be used as part
  19.  * of other code without the authors consent. If you wish to use some of this
  20.  * code then please email me at (sie@fulcrum.bt.co.uk).
  21.  *
  22.  * This source is not public domain, so you do not have any right to alter it
  23.  * or sell it for personal gain. The source is provided purely for reference
  24.  * purposes. You may re-compile the source with any compiler you choose.
  25.  * You must not distribute altered copies without the authors consent. My
  26.  * intention is that the source will help people isolate any bugs much more
  27.  * effectively.
  28.  *
  29.  * Disclaimer
  30.  * ==========
  31.  *
  32.  * No implication is made as to this code being fit for any purpose at all.
  33.  * I (the author) shall not be held responsible for any loss of data or damage 
  34.  * to property that may result from its use or misuse.
  35.  *
  36.  *
  37.  * Revision History
  38.  * ================
  39.  *
  40.  * $Log: tputs.c,v $
  41.  * Revision 1.1  1993/05/17  23:33:10  sie
  42.  * Initial revision
  43.  *
  44.  *
  45.  */
  46.  
  47. #ifndef lint
  48. static char *rcsid = "$Header: /SRC/lib/curses/src/RCS/tputs.c,v 1.1 1993/05/17 23:33:10 sie Exp $";
  49. #endif /* lint */
  50.  
  51. #include "acurses.h"
  52.  
  53.  
  54. tputs(char *cp, int affcnt, int(*outc)(char))
  55. {
  56.   int delay = 0;
  57.   
  58. #ifdef FUTURE
  59.   if(_CursesType == CUST_CURSES) {
  60.     switch(*((short *)cp)) {
  61.     case 0x636c:                /* cl */
  62.       /* SetRast(); */
  63.       break;
  64.     }
  65.   } else {
  66. #endif
  67.   while(isdigit(*cp)) {
  68.     delay *= 10;
  69.     delay += (*cp - '0');
  70.     cp++;
  71.   }
  72.   if(*cp == '*') {              /* is it a delay per line affected ? */
  73.     delay *= affcnt;
  74.     cp++;
  75.   }
  76.   while(*cp) {
  77.     switch(*cp) {
  78.       case '\\':
  79.       if(isdigit(*++cp))
  80.         /* This must be a 3 digit octal number */
  81.         outc((64*(*cp++ - '0') + 8*(*cp++ - '0') + (*cp - '0')) & 0x7f);
  82.       else {
  83.         switch(*cp) {           /* character after a \ */
  84.         case 'E':
  85.           outc(ESC);
  86.           break;
  87.         case 'n':
  88.           outc(NL);
  89.           break;
  90.         case 'r':
  91.           outc(CR);
  92.           break;
  93.         case 't':
  94.           outc(TAB);
  95.           break;
  96.         case 'b':
  97.           outc(BS);
  98.           break;
  99.         case 'f':
  100.           outc(FF);
  101.           break;
  102.         case '^':
  103.           outc('^');
  104.           break;
  105.         case '\\':
  106.           outc('\\');
  107.           break;
  108.         }
  109.       } /* end of else, so not an octal number */
  110.       break;
  111.       
  112.     case '^':                   /* control character */
  113.       outc(toupper(*++cp) - '@'); /* this line assumes ascii */
  114.       break;
  115.       
  116.     default:
  117.       outc(*cp);
  118.       break;
  119.     }
  120.     cp++;
  121.   }
  122. #ifdef FUTURE
  123. }
  124. #endif
  125. }
  126.