home *** CD-ROM | disk | FTP | other *** search
- #include <strings.h>
-
- void center(line, string, mode)
- int line;
- char *string;
- int mode;
-
- /*
- ---------------------------------------------------------------------------
-
- Last revision -
- 17 January 1985 - GWS
- Change to use screen width from termcap.
-
- 2 April 1984 - GWS
-
-
- NAME
- center - center string in screen on specified line
-
- SYNOPSIS
- void center(line, string, mode)
- int line;
- char *string;
- int mode;
-
- DESCRIPTION
- This routine uses the termcap(3x) routines to center and
- optionally emphasize a string. 'Line' is the terminal line
- number on which the string is to be placed, numbered starting
- with 1. 'Mode' takes one of three values:
- 0 - no control characters sent
- 1 - underline mode turned on before and off after 'string'
- 2 - stand-out mode turned on before and off after 'string'
- A call to InitTerm must be made before the first call to center.
-
- SEE ALSO
- termcap(3x), InitTerm, underline, StandOut
-
- DIAGNOSTICS
- none
-
- BUGS
- does not check for string too long to fit on one line
-
- AUTHOR
- George W. Sherouse
- 31 March 1984
-
- ---------------------------------------------------------------------------
- */
-
- {
- int col;
- int cookie;
-
- int strlen();
- void gotoxy();
- void underline();
- void StandOut();
-
- col = (tgetnum("co") - strlen(string)) / 2;
- switch (mode)
- {
- case 0:
- break;
- case 1:
- cookie = tgetnum("ug");
- if (cookie > 0)
- col -= cookie;
- break;
- case 2:
- cookie = tgetnum("sg");
- if (cookie > 0)
- col -= cookie;
- break;
- }
- gotoxy(col, line);
- switch (mode)
- {
- case 0:
- break;
- case 1:
- underline(1);
- break;
- case 2:
- StandOut(1);
- break;
- }
-
- printf(string);
-
- switch (mode)
- {
- case 0:
- break;
- case 1:
- underline(0);
- break;
- case 2:
- StandOut(0);
- break;
- }
- return;
- }
-