home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume3 / libc_term / center.c < prev    next >
C/C++ Source or Header  |  1986-11-30  |  1KB  |  83 lines

  1. #include <strings.h>
  2. #include <curses.h>
  3. #include "c_term.h"
  4.  
  5. void center(line, string, mode)
  6. int line;
  7. char *string;
  8. int mode;
  9.  
  10. /*
  11.  ---------------------------------------------------------------------------
  12.  
  13.    Last revision - 
  14.     6 January 1985 - GWS
  15.     Change to use curses
  16.  
  17.      2 April 1984 - GWS
  18.  
  19.  
  20.    NAME
  21.      center - center string in sceen
  22.  
  23.    SYNOPSIS
  24.     void center(line, string, mode)
  25.     int line;
  26.     char *string;
  27.     int mode;
  28.  
  29.    DESCRIPTION
  30.     This routine uses the curses(3x) routines to center and
  31.     optionally emphasize a string.  'Line' is the terminal line
  32.     number on which the string is to be placed, numbered starting
  33.     with 0.  'Mode' takes one of three values:
  34.         0 - no control characters sent
  35.         1 - stand-out mode turned on before and off after 'string'
  36.         2 - stand-out mode turned on before and off after 'string'
  37.     A call to init_term must be made before the first call to center.
  38.  
  39.    SEE ALSO
  40.     curses(3x), init_term
  41.  
  42.    DIAGNOSTICS
  43.     none 
  44.  
  45.    BUGS
  46.     does not check for string too long to fit on one line 
  47.  
  48.    AUTHOR
  49.      George W. Sherouse
  50.      31 March 1984
  51.  
  52.  ---------------------------------------------------------------------------
  53. */
  54.  
  55. {
  56.     int col;
  57.  
  58.     int strlen();
  59.  
  60.     col = (COLS - strlen(string)) / 2 - 1;
  61.     switch (mode)
  62.     {
  63.     case 0:
  64.     break;
  65.     case 1:
  66.     case 2:
  67.     standout();
  68.     break;
  69.     }
  70.     mvprintw(line, col,  string);
  71.     switch (mode)
  72.     {
  73.     case 0:
  74.     break;
  75.     case 1:
  76.     case 2:
  77.     standend();
  78.     break;
  79.     }
  80.     refresh();
  81.     return;
  82. }
  83.