-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathterm_attr
executable file
·80 lines (68 loc) · 2.11 KB
/
term_attr
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
73
74
75
76
77
78
79
80
#!/usr/bin/perl
# vim:ft=perl:
# abstract: dump all term attributes and visualize various term settings
use strict;
use warnings FATAL => 'all';
use File::LsColor ':all';
use Term::ExtendedColor qw(fg);
use Term::hr {
fg => 137,
char => '-',
bold => 1,
italic => 1,
width => 40,
crlf => 1,
};
my $attr = {
normal => 0,
bold => 1,
faint => 2,
italic => 3,
bolditalic => '1;3',
underline => 4,
undercurl => '4:2',
blink => 5,
blink_ms => 6,
reverse => 7,
conceal => 8,
lookup => 9,
};
select STDOUT;
my $hr = hr();
print $hr;
for my $t( sort { $attr->{$a} cmp $attr->{$b} } keys(%{ $attr })) {
$t =~ /^blink/ and printf("%s\t\t\t \e[48;5;196;38;5;233;1;3mSKIPPING: SHOULD NEVER HAVE BEEN IMPLEMENTED\e[m\n", sprintf("%-10s", $t)), next;
# visually show if the colorUL property of urxvt is being abused for
# underlining URLs.
# https://www.japh.se/2019/01/23/color-urls-in-urxvt-without-abusing-underline-property.html
if($t eq 'underline') {
printf("\e[$attr->{$t}m$t\e[m\n%s\n", 'https://nounderlineonlinks.se');
}
elsif($t eq 'undercurl') {
# https://gitlab.com/gnachman/iterm2/-/issues/6382
printf("\e[4:3mundercurl\e[m\n");
printf("\e[4;58:5:197;4:3mundercurl, colored\e[m\n");
}
else {
printf("\e[$attr->{$t}m$t\e[m\n");
}
}
# in case we're abusing LD_PRELOAD
# https://github.com/trapd00r/stderred
print "stdout\n";
select STDERR;
print "stderr\n";
select STDOUT;
print $hr;
for my $unicode(qw(🌎)) {
printf "\033[38;5;225m%s\033[m\033[38;5;39m%s\033[m\n",$unicode, $unicode;
}
print "\n";
printf "%s\n", fg(10, '$File::LsColor::COLORIZE_PATH') . ' = ' . fg(33, 1);
printf "→ %s\n", ls_color('/usr/share/perl5/core_perl/Symbol.pm');
printf "→ %s\n\n", ls_color('/a/path/and/file/without/extension/README');
printf "%s\n", fg(10, '$File::LsColor::COLORIZE_PATH') . ' = ' . fg(33, 0);
$File::LsColor::COLORIZE_PATH = 0;
printf "→ %s\n", ls_color('/usr/share/perl5/core_perl/Symbol.pm');
printf "→ %s\n", ls_color('/a/path/and/file/without/extension/README');
print $hr;