ref: 05fa071dc3ea7a5208f3747ac9d93f4d3e256b2f
dir: /test.c/
#include <u.h>
#include <libc.h>
enum {
DEFAULT,
BLACK,
RED,
GREEN,
YELLOW,
BLUE,
MAGENTA,
CYAN,
WHITE,
};
void
main(void)
{
int fd;
/* Open colors device */
fd = open("/dev/colors", OWRITE);
if(fd < 0)
sysfatal("open colors: %r");
/* Test different color combinations */
fprint(fd, "+red this is red text\n");
fprint(fd, "-blue this has blue background\n");
fprint(fd, "+red-blue this has both\n");
fprint(fd, "this is normal text\n");
fprint(fd, "+0x7F00007F this is transparent hex red\n");
/* Test a rainbow effect */
fprint(fd, "+red r");
fprint(fd, "+yellow y");
fprint(fd, "+green g");
fprint(fd, "+cyan c");
fprint(fd, "+blue b");
fprint(fd, "+magenta m\n");
close(fd);
exits(nil);
}