modified: Makefile
[GalaxyCodeBases.git] / funny / color.pl
blobd1caf39c4cdef1b1be3036b7f20b93963e0e5347
1 #!/bin/env perl
2 use strict;
3 use warnings;
5 for my $fg (0..9) {
6 print "\033[",$fg,"m","[t${fg}t]","\033[0m";
8 print "\n";
10 for my $fg (0..9) {
11 print "\033[",$fg+30,"m","[t${fg}t]","\033[0m";
13 print "\n";
15 for my $bg (0..9) {
16 print "\033[",$bg+40,"m","[t${bg}t]","\033[0m";
18 print "\n";
20 for my $bg (0..7) {
21 for my $fg (0..7) {
22 print "\033[",$fg+30,";",$bg+40,"m","[t$fg,${bg}t]","\033[0m";
24 print "\n";
27 for my $attr (0,1,5,7,4,8,9) {
28 print "\nAttr:$attr\n";
29 for my $bg (0..7) {
30 print "before ";
31 for my $fg (0..7) {
32 print "\033[",$attr,";",$fg+30,";",$bg+40,"m","[t$fg,${bg}t]","\033[0m";
34 print " after\n";
38 __END__
39 Attr:
40 0 Reset
41 1 FG BRIGHT
42 5 BG BRIGHT under sh/putty
43 7 REVERSE FG and BG
44 4 UNDERLINE under gnome-terminal and putty
45 8 HIDDENT (sh => fg black, gnome-terminal => fg==bg)
46 9 Strikethrough under gnome-terminal
48 http://en.wikipedia.org/wiki/ANSI_escape_code
50 #include <stdio.h>
52 #define RESET 0
53 #define BRIGHT 1
54 #define DIM 2
55 #define UNDERLINE 3
56 #define BLINK 4
57 #define REVERSE 7
58 #define HIDDENT 8
60 #define BLACK 0
61 #define RED 1
62 #define GREEN 2
63 #define YELLOW 3
64 #define BLUE 4
65 #define MAGENTA 5 // Æ·ºì
66 #define CYAN 6
67 #define WHITE 7
69 void clear_screen()
71 system("clear");
74 void color(int attr, int fg, int bg)
76 printf("%c[%d;%d;%dm", 0x1B, attr, fg+30, bg+40);