-
Notifications
You must be signed in to change notification settings - Fork 44
/
colors.pl
executable file
·72 lines (61 loc) · 1.73 KB
/
colors.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/perl -T
#
# Author: Hari Sekhon
# Date: 2014-06-07 22:17:09 +0100 (Sat, 07 Jun 2014)
#
# https://github.com/HariSekhon/DevOps-Perl-tools
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn
# and optionally send me feedback to help improve or steer this or other code I publish
#
# https://www.linkedin.com/in/HariSekhon
#
$DESCRIPTION = "Program to show all the ASCII terminal code Foreground/Background color combinations in a terminal to make it easy to pick for writing fancy programs
Tested on Mac OS X and Linux";
$VERSION = "0.1.1";
use strict;
use warnings;
BEGIN {
use File::Basename;
use lib dirname(__FILE__) . "/lib";
}
use HariSekhonUtils;
remove_timeout();
get_options();
autoflush();
my $text = "hari";
my $len = length($text) + 2;
# effects 4 = underline, 5 = blink, look ugly
my @effects = qw/0 1/;
push(@effects, qw/4 5/) if $verbose;
print "\nASCII Terminal Codes Color Key:
EF = Effect [1 = bold, 4 = underline, 5 = blink (only shown in verbose mode)]
TXT = Foreground text color
BG = Background solid color
\n";
printf "%5s BG %-${len}s ", "", "none";
for(my $bg=40; $bg <= 47; $bg++){
printf " %-${len}s ", "${bg}m";
}
printf "\n%5s\n", "EF;TXT";
sub print_line($){
my $txt = shift;
foreach my $effect (@effects){
printf " %4sm ", $effect ? "$effect;$txt" : "$txt";
printf "\e[0m\e[${txt}m $text \e[0m ";
for(my $bg=40; $bg <= 47; $bg++){
printf "\e[$effect;${txt}m\e[${bg}m $text \e[0m ";
}
print "\n";
last if $txt eq 0 or $txt eq 1;
}
}
print_line 0;
print_line 1;
for(my $txt=30; $txt <= 37; $txt++){
print_line $txt;
}
print "\n";
exit 0;