[comp.unix.i386] Color on console...

larry@nstar.uucp (Larry Snyder) (02/25/90)

Does anyone have a utility for use under 386/ix that sets
the color on the console like the SCO "setcolor" utility?

chen@ucbarpa.Berkeley.EDU (Chien Chen) (02/25/90)

In article <9mB5e3w160w@nstar.uucp> larry@nstar.uucp (Larry Snyder) writes:
>Does anyone have a utility for use under 386/ix that sets
>the color on the console like the SCO "setcolor" utility?

Please post, I am interested too.  By the way, is there a good book
about programming VGA under sysv3 unix.

Chien Chen

randy@rls.UUCP (Randall L. Smith) (02/25/90)

In article <9mB5e3w160w@nstar.uucp>, larry@nstar.uucp (Larry Snyder) writes:
> Does anyone have a utility for use under 386/ix that sets
> the color on the console like the SCO "setcolor" utility?

Here's one inspired by SCO setcolor I whipped up awhile back.  It's
not very well written nor has lots-o-features but you get the source
and may help you.  Enjoy.

/*
 *  color.c - Set color of monitor.
 *
 *  Author: Randall L. Smith, October 1988.
 *  Flames: rls!randy@tut.cis.ohio-state.edu -or- ...!osu-cis!rls!randy
 *
 *  This code is hereby transferred to the public domain.  Make big money
 *  or anything else you like.	Even pretend you wrote it because I don't
 *  want to admit this is mine. :-)  Some pretty obvious improvements can
 *  be made, but it just doesn't matter to me right now.
 *
 *  This has been compiled under MSC 4.0.
 *
 *   Param	Desc
 *	8	Invisible (black on black) display.  Yeesh.
 *     30	Foreground black
 *     31	Foreground red
 *     32	Foreground green
 *     33	Foreground yellow
 *     34	Foreground blue
 *     35	Foreground magenta
 *     36	Foreground cyan
 *     37	Foreground white
 *     40	Background black
 *     41	Background red
 *     42	Background green
 *     43	Background yellow
 *     44	Background blue
 *     45	Background magenta
 *     46	Background cyan
 *     47	Background white
 *
 *   Bugs:  Has stupid notion that the default color of screen is green.
 *	    Aren't they all? :-)
 *
 */

#include <stdio.h>

char colors;
int fprintf();
int printf();
int strcmp();

main(argc, argv)
int argc;
char *argv[];

{
    if (argc == 3) {
	if ((strcmp(argv[1], "-F") == 0) || (strcmp(argv[1], "-f") == 0))
	    colors = '3';
	else if ((strcmp(argv[1], "-B") == 0) || (strcmp(argv[1], "-b") == 0))
	    colors = '4';
    } else {
	(void) print_help();
	return -1;
    }

    if (strcmp(argv[2], "black") == 0) {
	(void) printf("\033[%c0m", colors);	/*  black   */
    } else if (strcmp(argv[2], "red") == 0) {
	(void) printf("\033[%c1m", colors);	/*  red     */
    } else if (strcmp(argv[2], "green") == 0) {
	(void) printf("\033[%c2m", colors);	/*  green   */
    } else if (strcmp(argv[2], "yellow") == 0) {
	(void) printf("\033[1;%c3m", colors);	/*  yellow  */
    } else if (strcmp(argv[2], "blue") == 0) {
	(void) printf("\033[%c4m", colors);	/*  blue    */
    } else if (strcmp(argv[2], "magenta") == 0) {
	(void) printf("\033[%c5m", colors);	/*  magenta */
    } else if (strcmp(argv[2], "cyan") == 0) {
	(void) printf("\033[%c6m", colors);	/*  cyan    */
    } else if (strcmp(argv[2], "white") == 0) {
	(void) printf("\033[%c7m", colors);	/*  white   */
    } else {
	(void) fprintf(stderr, "Unknown color %s \n", argv[2]);
	(void) print_help();
	return -1;
    }
    return 0;
}

/*
 * Default black background - green foreground.
 */

print_help()
{
   (void) fprintf(stderr, "Usage: color -[fbh] desired-color \n");
   (void) fprintf(stderr, "Valid colors are: ");
   (void) fprintf(stderr, " \033[47;30m black \033[40;31m red \033[32m green \033[1;33m yellow\n");
   (void) fprintf(stderr, "		   \033[0;34m blue \033[35m magenta \033[36m cyan \033[37m white\n");
   (void) fprintf(stderr, " \033[32m for [f]oreground or [b]ackground.\n");
   return 0;
}

jrh@mustang.dell.com (James R. Howard) (02/26/90)

In article <9mB5e3w160w@nstar.uucp>, larry@nstar.uucp (Larry Snyder) writes:
> Does anyone have a utility for use under 386/ix that sets
> the color on the console like the SCO "setcolor" utility?

Yes.  Dell UNIX (which is 386/ix based) has a setcolor program, which lets you
change colors, and set cursor size and change the pitch and duration of the
"bell" character.

tron1@tronsbox.xei.com (HIM) (08/10/90)

What was the definitive ;-) answer on how to set ofrground and background
colors under ISC that would hopefully run that way INSIDE other programs?

(I am thinking about writing something to just blast the RGB definition of
WHITE and BLACK in the VGA card pallet and let curses think what it wants.)

========[ Xanadu Enterprises Inc. Amiga & Unix Software Development]========
=      "And in the darkened offices, the terminals shine like stars."      =
============= Ken Jamieson: uunet!tronsbox.xei.com!tron1  ==================
= NONE of the opinions represented here are endorsed by either             =
= Xanadu Enterpises or its clients, AT&T Bell Labs or others.              =
==== The Romantic Encounters BBS 201-759-8450(PEP) / 201-759-8568(2400) ====