home *** CD-ROM | disk | FTP | other *** search
- /*
- * rprints.c
- * contains: rprints(),rprintf(),rcprints(),rcprintf(),rjprints(),rjprintf()
- *
- * Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- *
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "color.h"
- #include "gfuncts.h"
-
-
- /*
- * void
- * rprints(color,page,str)
- *
- * ARGUMENT
- * (int) color - color to use (see color.h)
- * (int) page - video page to use
- * (char *) str - string to display.
- *
- * DESCRIPTION
- * This function sends a string to the display via putcinc().
- */
- void GF_CONV rprints(color,page,str)
- char *str;
- int color, page;
- {
- while(*str)
- putcinc(*str++,color, page);
- }
-
- /*
- * void
- * rprintf(color,page,control,args)
- *
- * ARGUMENT
- * (int) color - color to use
- * (int) page - video page
- * (char *) control - control string for sprintf()
- * args - arguments for sprintf()
- *
- * DESCRIPTION
- * This function formats a string with sprintf() in a local 200 byte buffer
- * then calls rprints() to display it.
- */
-
- #ifndef _MSC
- void GF_CDECL rprintf(color,page,control)
- #else
- #if _MSC > 4
- void GF_CDECL rprintf(color,page,control,...)
- #else
- void rprintf(color,page,control)
- #endif
- #endif
-
- int color, page;
- char *control;
- {
- char *buf,**value;
-
- value=&control;
- if((buf=malloc(200))==NULL)
- return;
- sprintf(buf,control,
- value[1],value[2],value[3],value[4],value[5],value[6],
- value[7],value[8],value[9],value[10]
- #ifndef _LDATA
- ,value[11],value[12],value[13],value[14],value[15],value[16],
- value[17],value[18],value[19],value[20]
- #endif
- );
- rprints(color,page,buf);
- free(buf);
- }
-
- /*
- * void
- * rcprints(cols,color,page,str)
- *
- * ARGUMENT
- * (int) cols - Number of columns to center on
- * (int) color - color to use.
- * (int) page - video page to use
- * (char *) str - null terminated string to display
- *
- * DESCRIPTION
- * Centers text on the lesser of cols and gmaxcol then outputs with
- * putcinc().
- * MODIFICATIONS:
- * "" Tue 08-Nov-1988 13:36:40
- * was using the current video page instead of the one specified
- * in the parameter. (SAR #106)
- */
- void GF_CONV rcprints(cols,color,page,instr)
- int cols,color,page;
- char *instr;
- {
- curset((getcur(page)&0xff00)>>8,
- xmin(cols,gmaxcol)/2-(strlen(instr)/2),page);
- while(*instr)
- putcinc(*instr++,color,page);
- }
-
- /*
- * void
- * rcprintf(cols,color,page,format,args,)
- *
- * ARGUMENT
- * (int) cols - Columns to center
- * (int) color - Attribute
- * (int) page - video page
- * (char *) format - format string for sprintf()
- * args - args for sprintf()
- *
- * DESCRIPTION
- * Format string with sprintf(), then center and print with rcprints()
- * Note: internal buffer is 200 characters.
- */
-
- #ifndef _MSC
- void GF_CDECL rcprintf(cols,color,page,format)
- #else
- #if _MSC > 4
- void GF_CDECL rcprintf(cols,color,page,format,...)
- #else
- void rcprintf(cols,color,page,format)
- #endif
- #endif
-
- int cols,color,page;
- char *format;
- {
- char *buf,**value;
-
- value=&format;
- if((buf=malloc(200))==NULL)
- return;
- sprintf(buf,format,
- value[1],value[2],value[3],value[4],value[5],value[6],
- value[7],value[8],value[9],value[10]
- #ifndef _LDATA
- ,value[11],value[12],value[13],value[14],value[15],value[16],
- value[17],value[18],value[19],value[20]
- #endif
- );
- rcprints(cols,color,page,buf);
- free(buf);
- }
-
- /*
- * bool
- * rjprints(cols,color,page,instr)
- *
- * ARGUMENT
- * (int) cols - Justify on lesser of this or gmaxcol
- * (int) color - Color/Attribute
- * (int) page - Video page to use
- * (char *) instr - pointer to string to display.
- *
- * DESCRIPTION
- * This function justifies the string with justify(), then displays it
- * with rprints.
- *
- * RETURNS
- * TRUE if justification is successful, else FALSE
- */
- bool GF_CONV rjprints(cols,color,page,instr)
- int cols,color,page;
- char *instr;
- {
- char *outstr;
- int icols;
- bool bret;
-
- if((outstr=malloc(200))==NULL)
- return(FALSE);
- icols=xmin(cols,gmaxcol);
- bret=justify(outstr,instr,icols);
- rprints(color,page,outstr);
- free(outstr);
- return bret;
- }
-
- /*
- * bool
- * rjprintf(cols,color,page,format,args,)
- *
- * ARGUMENT
- * (int) cols - Justify on lesser of this and gmaxcol
- * (int) color - Attribute/Color
- * (int) page - video page to use
- * (char *) format - format string for sprintf(),
- * args - arguments for sprintf().
- *
- * DESCRIPTION
- * Color print formatted line with justification.
- *
- * RETURNS
- * TRUE if justification is successful, false otherwise.
- */
-
- #ifndef _MSC
- bool GF_CDECL rjprintf(cols,color,page,format)
- #else
- #if _MSC > 4
- bool GF_CDECL rjprintf(cols,color,page,format,...)
- #else
- bool rjprintf(cols,color,page,format)
- #endif
- #endif
-
- int cols,color,page;
- char *format;
- {
- char *buf,**value;
- bool bret;
-
- value=&format;
- if((buf=malloc(200))==NULL)
- return(FALSE);
- sprintf(buf,format,
- value[1],value[2],value[3],value[4],value[5],value[6],
- value[7],value[8],value[9],value[10]
- #ifndef _LDATA
- ,value[11],value[12],value[13],value[14],value[15],value[16],
- value[17],value[18],value[19],value[20]
- #endif
- );
- bret=rjprints(cols,color,page,buf);
- free(buf);
- return bret;
- }
-