Created
October 2, 2020 08:10
-
-
Save MasFlam/85f6a442b4f90ae6881163b73467fc5e to your computer and use it in GitHub Desktop.
Julia script for testing the color capability of a terminal emulator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env julia | |
function test3b() | |
println("3-bit color") | |
for i in 0:7 | |
ch = "AAA" | |
print("\e[$(30 + i)m$ch") | |
end | |
println("\e[0m") | |
for i in 0:7 | |
ch = "AAA" | |
print("\e[$(40 + i)m$ch") | |
end | |
println("\e[0m") | |
end | |
function test8b() | |
println("\n8-bit color") | |
for i in 0:7 | |
ch = "AAAAAAAAA" | |
print("\e[38;5;$(i)m$ch") | |
end | |
println("\e[0m") | |
for i in 0:7 | |
ch = "AAAAAAAAA" | |
print("\e[48;5;$(i)m$ch") | |
end | |
println("\e[0m") | |
for i in 0:5 | |
for j in 0:35 | |
ch = "AAA" | |
print("\e[38;5;$(16 + 36i + j)m$ch") | |
end | |
println("\e[0m") | |
end | |
for i in 0:5 | |
for j in 0:35 | |
ch = "AAA" | |
print("\e[48;5;$(16 + 36i + j)m$ch") | |
end | |
println("\e[0m") | |
end | |
println("\e[0m") | |
end | |
function test21b() | |
println("21-bit color") | |
for i in 0:15 | |
for j in 0:31 | |
ch = "A" | |
print("\e[38;2;$(16i);$(8j);0m$ch") | |
end | |
for j in 0:31 | |
ch = "A" | |
print("\e[38;2;$(16i);0;$(8j)m$ch") | |
end | |
for j in 0:31 | |
ch = "A" | |
print("\e[38;2;0;$(16i);$(8j)m$ch") | |
end | |
println("\e[0m") | |
end | |
sleep(1) | |
for i in 0:15 | |
for j in 0:31 | |
ch = "A" | |
print("\e[48;2;$(16i);$(8j);0m$ch") | |
end | |
for j in 0:31 | |
ch = "A" | |
print("\e[48;2;$(16i);0;$(8j)m$ch") | |
end | |
for j in 0:31 | |
ch = "A" | |
print("\e[48;2;0;$(16i);$(8j)m$ch") | |
end | |
println("\e[0m") | |
end | |
println("\e[0m") | |
end | |
println("Testing (3)-bit, (8)-bit, or (21)-bit colors?") | |
bits = parse(Int, readline()) | |
if bits == 3 | |
test3b() | |
elseif bits == 8 | |
test8b() | |
elseif bits == 21 | |
test21b() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment