Add rbeesley's ansi-color.cmd, a CMD-based color tool (& more) (#11932)

Adds the Ansi-Color tool, completing #6470.

What started out as an experiment to see the support of ANSI support to
conhost, I wanted to write a Windows equivalent of Daniel Crisman's
[BASH script on tldp.org]. I didn't like how the BASH script hard coded
in whitespace and I thought Windows could do better. I applied
techniques to speed up the execution and tried to use the Command Script
batch language in ways that pushed the limits for what I thought it
could do. Running this from withing PowerShell, `&cmd /c ansi-color.cmd`,
I found out that the active code page is already 65001, but when ran
from a Command Prompt, the active code page depends on the regional
settings and I would have a dependency on CHCP to detect the active code
page, change to 65001 if necessary, and restore the previous code page
after running. I found it useful for designing color schemes and writing
shaders, and I started using an earlier version for logging bugs.

Initially it was a single script which I would dump every SGR
combination I could think of, and many which weren't implemented yet,
but as I was looking at other tools which had been written I wanted to
mimic the same output so I could do side-by-side comparisons. First I
wrote `crisman.def` and then `colortool.def`. So I had to align text.
Then output was slow for big tables so I wrote to an outbuffer and made
use of macros. I wanted to handle flags instead of needing to change
settings every time, so I added argument parsing and loading external
files.

It's a batch file that has some really useful purposes and does nothing
I've seen before. 

I've ran every definition in a Command Prompt, with CP 437 and CP 65001
to make sure it works. Posted as a Gist on my account for about year, a
Portuguese (Brazilian as I recall), speaking user tried the Gist and it
was failing because CHCP is localized. I've taken an approach to try and
make it work for different localizations, but this is a potential
problem. I also ran every definition in PowerShell 7, shelling down to
`cmd` to actually run it. Lastly, I went through using the flags and
made sure that help would be shown. Error messages generate error levels
when the script exits, so those could be used to use this in an
automated test and catch if there was a problem with the script
executing. It won't be able to validate if the generated output shows
correctly, but it would fail if a definition file is missing or if it
needed to switch to Unicode and wasn't flagged or configured to do so.
For trying to build the table stub and headers, there is some debug code
which will output what was parsed. This is the last debug code in the
script itself, but I found it to be useful at times, so there is a
configuration setting which can turn that debug output back on.
Technically there is also a debug statement to break after adding the
macros and parsing the arguments, but before it does any configuration
changes, changes the code page, or anything. This was useful for making
changes to macros and being able to test them as well as making sure
that flags and arguments are parsed correctly. It was a rather cryptic
discovery to call `cmd /c exit -1073741510` to break out, so in part
that was my reason to leave this in. The definition files themselves
could be cleaned up further, but in both of them there are a lot of
Unicode codepoints that could be useful when defining division lines for
the headers so I opted to just comment them out. I initially had the
default definition to require Unicode, but now it just changes to a
non-Unicode output if it can't. And this brings up the last concern. The
way certain settings are set, is that they are defined in the
`__TABLE__` section of the definition file.  With `PARSE_TABLE_DATA`,
the script looks line by line for `SET *` or `IF *` and if found it will
effectively eval that line. The definition files are written so that for
instance `SET "CELL= gYw "` could be used to set the code which is used.
`If` was allow so that there could be a test if Unicode were available
and set something different for ASCII and Unicode. But it also opens the
possibility that a rogue actor could create a `ansi-color.cmd`
definition file something like `SET "foo=bar" & DoSomethingBad.exe`.
First of all I'd be flattered that anyone would use this very niche
tool, but it is something I think which needs to be called out.
Essentially the definition files are just batch files, but they are
extremely limited to executing only one line at a time and only
supporting IF and SET commands. I think this is a minimal risk because
at that point batch files would already be more effective, but there
should also be an expectation that a batch file will run something and
the same may not be true for the heavily degraded definition files. I
think the risk is minimal but it is a risk I wanted to make clear. This
really showcases some interesting techniques and ideas, and I hope that
it is useful. All told, there are a couple years of incremental changes
in this PR.

Closes #6470

[BASH script on tldp.org]: https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
This commit is contained in:
Ryan Beesley 2022-01-04 09:53:54 -08:00 committed by GitHub
parent ff7f569096
commit 242075104e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 3537 additions and 12 deletions

View File

@ -12,7 +12,6 @@ ACTCTXW
activatable
ACTIVEBORDER
ACTIVECAPTION
adaa
ADDALIAS
ADDREF
addressof
@ -161,6 +160,7 @@ Borland
BOTTOMLEFT
BOTTOMRIGHT
boutput
boxheader
BPBF
bpp
BPPF
@ -287,8 +287,6 @@ codepage
codepath
codepoint
codeproject
coffgroup
coffgrp
coinit
COLLECTIONURI
colorizing
@ -299,6 +297,7 @@ colorspaces
colorspec
colortable
colortbl
colortest
colortool
COLR
combaseapi
@ -402,6 +401,7 @@ creativecommons
cred
cref
crend
Crisman
CRLFs
crloew
Crt
@ -480,7 +480,6 @@ dai
DATABLOCK
DATAVIEW
DATAW
datetime
DBatch
dbcs
DBCSCHAR
@ -610,6 +609,7 @@ DINLINE
directio
DIRECTX
Dirs
DISABLEDELAYEDEXPANSION
DISABLENOSCROLL
DISPLAYATTRIBUTE
DISPLAYATTRIBUTEPROPERTY
@ -641,6 +641,7 @@ DPICHANGE
DPICHANGED
dpix
dpiy
dpnx
DRAWFRAME
DRAWITEM
DRAWITEMSTRUCT
@ -672,8 +673,8 @@ dxgidwm
dxinterop
dxsm
dxttbmp
Dyreen
eachother
eae
eaf
EASTEUROPE
ECH
@ -688,13 +689,13 @@ edputil
edu
Efast
EHsc
EINS
EJO
ELEMENTNOTAVAILABLE
elems
elif
elseif
emacs
emplate
EMPTYBOX
enabledelayedexpansion
endian
@ -714,6 +715,7 @@ enumranges
envvar
eol
EPres
EQU
ERASEBKGND
errno
errorlevel
@ -763,11 +765,13 @@ fdw
fesb
FFDE
FFrom
fgbg
FGCOLOR
fgetc
fgetwc
FGHIJ
fgidx
FGs
FILEDESCRIPTION
fileno
filepath
@ -821,6 +825,7 @@ FORCEOFFFEEDBACK
FORCEONFEEDBACK
FORCEV
foreach
forground
fprintf
framebuffer
FRAMECHANGED
@ -853,7 +858,6 @@ gcy
gdi
gdip
gdirenderer
GENPROFILE
geopol
GETALIAS
GETALIASES
@ -938,6 +942,7 @@ groupbox
gset
gsl
GTP
GTR
guc
gui
guidatom
@ -972,7 +977,6 @@ hfont
hfontresource
hglobal
hhh
HHmm
hhook
hhx
HIBYTE
@ -1002,7 +1006,6 @@ horiz
HORZ
hostable
hostlib
Hostx
HPA
HPAINTBUFFER
HPCON
@ -1129,7 +1132,6 @@ INPUTPROCESSORPROFILE
inputrc
Inputreadhandledata
INSERTMODE
installationpath
intellisense
INTERACTIVITYBASE
INTERCEPTCOPYPASTE
@ -1358,6 +1360,7 @@ lstrcmp
lstrcmpi
LTEXT
LTLTLTLTL
ltrim
ltype
LUID
lval
@ -1384,6 +1387,7 @@ MAXDIMENSTRING
maxing
MAXLENGTH
MAXSHORT
maxval
maxversiontested
MAXWORD
maybenull
@ -1429,7 +1433,6 @@ mkdir
MMBB
mmcc
MMCPL
MMdd
mmsystem
MNC
MNOPQ
@ -1687,6 +1690,7 @@ OUTOFCONTEXT
OUTOFMEMORY
outout
Outptr
outstr
OVERLAPPEDWINDOW
OWNDC
OWNERDRAWFIXED
@ -1983,7 +1987,6 @@ REGISTERVDM
regkey
REGSTR
reingest
Relayout
RELBINPATH
remoting
renamer
@ -2046,6 +2049,8 @@ rtf
RTFTo
Rtl
RTLREADING
Rtn
rtrim
RTTI
ruleset
runas
@ -2062,6 +2067,7 @@ runut
runxamlformat
rvalue
RVERTICAL
rvpa
RWIN
rxvt
safearray
@ -2261,6 +2267,7 @@ strrev
strsafe
strtok
structs
STUBHEAD
STUVWX
STX
stylecop
@ -2770,6 +2777,7 @@ WRITECONSOLE
WRITECONSOLEINPUT
WRITECONSOLEOUTPUT
WRITECONSOLEOUTPUTSTRING
wrkstr
wrl
wrp
WRunoff

View File

@ -17,3 +17,12 @@ mdtauk
cppreference
gfycat
Guake
askubuntu
dostips
viewtopic
rosettacode
Rexx
tldp
HOWTO
uwspace
uwaterloo

View File

@ -25,3 +25,6 @@ std::memory_order_[\w]+
D2DERR_SHADER_COMPILE_FAILED
TIL_FEATURE_[0-9A-Z_]+
vcvars\w*
ROY\sG\.\sBIV
!(?:(?i)ESC)!\[
!(?:(?i)CSI)!(?:\d+(?:;\d+|)m|[ABCDF])

View File

@ -0,0 +1,31 @@
# ANSI-COLOR
Ansi-Color.cmd makes it easy to render SGR attributes, foreground colors, and background colors, in a table. This complements ColorTool for diagnostics purposes and seeing all the colors of the applied color scheme.
```plain
Usage: ansi-color.cmd [flags] [<definition_file>]
This file echoes a bunch of color codes to the terminal to demonstrate
how they will render. The `Data Segment` portion of the file defines the
table layout and allows the user to configure whatever matrix of ANSI
Escape Sequence control characters they wish. This can also be read from
an external definition file using the same structure.
Flags:
/H : This message
/A : Display the ANSI Escape Sequence control characters
/R : Show cell R1C1 reference addressing instead of cell text
/U : Enable UTF-8 support
The script itself only has one external dependency on CHCP if you want
to show Unicode text. This just sets the Command Prompt codepage to 65001
and will restore it when the script successfully completes.
```
The entire tool is written as a Windows Command script and the only dependency is on the stock CHCP tool which can be used to change the command prompt code page. The script makes heavy use of Batch "macros," a concept originally explored by Ed Dyreen, Jeb, and Dave Benham on [DosTips.com](https://www.dostips.com/forum/viewtopic.php?f=3&t=1827). The use of macros in Ansi-Color allow complex results and capable of generating tables defined as separate files.
Of notable interest, the script itself is its own definition file and doesn't require external definition files to work. In fact, the script file itself is just a UTF-8 text file which can easily be edited, doesn't need to be recompiled, and has configuration settings embedded in it, or it can use flags passed as arguments. Additionally, several definition files are included which replicate the output of similar tools.
Lastly, there are two diagnostic modes which might be useful when writing color schemes. `/A` is a flag which instead of showing the output table, it replaces the actual ESC code in the output string with the Unicode codepoint representation of an ESC character, and when redirected from standard out to a file like `ansi-color /a > out.txt` it will create a text file which shows what would have been generated. This makes it easier to find errors in how something rendered. Additionally the `/R` flag borrows the Excel R1C1 reference address scheme to replace the Cell text with row/column IDs. In this way you can generate a table and then identify a combination of attributes and colors by that corresponding reference.
Under PowerShell, you can run all the definitions in a folder and subfolders using `gci -r .\*.def | %{write ($_ | rvpa -r) && .\ansi-color.cmd $_}`. This is convenient for finding a specific definition.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,57 @@
:: ColorTool equivalent (ColorTool.exe -c) - Modified with ANSI table line drawing
__DATA__
__TABLE__
SET "UTF8.REQUIRED=#TRUE#"
:: The test text
SET "CELL= gYw "
:: Alignment properties for the cells and headers
SET "ALIGN.CELL=C"
SET "ALIGN.BOXHEAD=C"
SET "ALIGN.STUB=L"
SET "ALIGN.STUBHEAD=C"
:: Draw table labels and lines
SET "STUBHEAD=ANSI"
SET "SEPARATOR.STUB=║"
SET "SEPARATOR.BOXHEAD=─"
SET "SEPARATOR.CELL=│"
SET "SEPARATOR.CELL_INTERSECT=┬"
:::: To get the alignment to match the original ColorTool, we specify the
:::: stub max width and prepend an extra boxhead character to the intersect
REM SET /A "STUB.MAX_WIDTH=6"
REM SET "SEPARATOR.INTERSECT=!SEPARATOR.BOXHEAD!╫"
:::: Alternatively this provides the same thing but with the stub separator
:::: shifted further to the left. This is an individual preference.
SET "SEPARATOR.INTERSECT=!SEPARATOR.BOXHEAD!╫!SEPARATOR.BOXHEAD!"
__TABLE:END__
__COLS__
#NUL#
40m
41m
42m
43m
44m
45m
46m
47m
__COLS:END__
__ROWS__
m
1m
30m
1;30m
31m
1;31m
32m
1;32m
33m
1;33m
34m
1;34m
35m
1;35m
36m
1;36m
37m
1;37m
__ROWS:END__
__DATA:END__

View File

@ -0,0 +1,449 @@
:: Apply all known implemented attributes to see the effect of multiple attributes against all foreground and background colors
__DATA__
__TABLE__
:: The test text
SET "CELL= gYw "
SET "STUBHEAD=Attributes"
:: Alignment properties for the cells and headers
SET "ALIGN.CELL=C"
SET "ALIGN.BOXHEAD=C"
SET "ALIGN.STUB=R"
:: Table spacing
SET "SEPARATOR.CELL= "
SET "SEPARATOR.STUB= "
__TABLE:END__
__COLS__
#NUL#
1m
2m
3m
4m
5m
6m
7m
8m
9m
21m
__COLS:END__
__ROWS__
#NUL#
1m
2m
3m
4m
5m
6m
7m
8m
9m
21m
#SPC#
30m
1;30m
2;30m
3;30m
4;30m
5;30m
6;30m
7;30m
8;30m
9;30m
21;30m
#SPC#
31m
1;31m
2;31m
3;31m
4;31m
5;31m
6;31m
7;31m
8;31m
9;31m
21;31m
#SPC#
32m
1;32m
2;32m
3;32m
4;32m
5;32m
6;32m
7;32m
8;32m
9;32m
21;32m
#SPC#
33m
1;33m
2;33m
3;33m
4;33m
5;33m
6;33m
7;33m
8;33m
9;33m
21;33m
#SPC#
34m
1;34m
2;34m
3;34m
4;34m
5;34m
6;34m
7;34m
8;34m
9;34m
21;34m
#SPC#
35m
1;35m
2;35m
3;35m
4;35m
5;35m
6;35m
7;35m
8;35m
9;35m
21;35m
#SPC#
36m
1;36m
2;36m
3;36m
4;36m
5;36m
6;36m
7;36m
8;36m
9;36m
21;36m
#SPC#
37m
1;37m
2;37m
3;37m
4;37m
5;37m
6;37m
7;37m
8;37m
9;37m
21;37m
#SPC#
39m
1;39m
2;39m
3;39m
4;39m
5;39m
6;39m
7;39m
8;39m
9;39m
21;39m
#SPC#
40m
1;40m
2;40m
3;40m
4;40m
5;40m
6;40m
7;40m
8;40m
9;40m
21;40m
#SPC#
41m
1;41m
2;41m
3;41m
4;41m
5;41m
6;41m
7;41m
8;41m
9;41m
21;41m
#SPC#
42m
1;42m
2;42m
3;42m
4;42m
5;42m
6;42m
7;42m
8;42m
9;42m
21;42m
#SPC#
43m
1;43m
2;43m
3;43m
4;43m
5;43m
6;43m
7;43m
8;43m
9;43m
21;43m
#SPC#
44m
1;44m
2;44m
3;44m
4;44m
5;44m
6;44m
7;44m
8;44m
9;44m
21;44m
#SPC#
45m
1;45m
2;45m
3;45m
4;45m
5;45m
6;45m
7;45m
8;45m
9;45m
21;45m
#SPC#
46m
1;46m
2;46m
3;46m
4;46m
5;46m
6;46m
7;46m
8;46m
9;46m
21;46m
#SPC#
47m
1;47m
2;47m
3;47m
4;47m
5;47m
6;47m
7;47m
8;47m
9;47m
21;47m
#SPC#
49m
1;49m
2;49m
3;49m
4;49m
5;49m
6;49m
7;49m
8;49m
9;49m
21;49m
#SPC#
90m
1;90m
2;90m
3;90m
4;90m
5;90m
6;90m
7;90m
8;90m
9;90m
21;90m
#SPC#
91m
1;91m
2;91m
3;91m
4;91m
5;91m
6;91m
7;91m
8;91m
9;91m
21;91m
#SPC#
92m
1;92m
2;92m
3;92m
4;92m
5;92m
6;92m
7;92m
8;92m
9;92m
21;92m
#SPC#
93m
1;93m
2;93m
3;93m
4;93m
5;93m
6;93m
7;93m
8;93m
9;93m
21;93m
#SPC#
94m
1;94m
2;94m
3;94m
4;94m
5;94m
6;94m
7;94m
8;94m
9;94m
21;94m
#SPC#
95m
1;95m
2;95m
3;95m
4;95m
5;95m
6;95m
7;95m
8;95m
9;95m
21;95m
#SPC#
96m
1;96m
2;96m
3;96m
4;96m
5;96m
6;96m
7;96m
8;96m
9;96m
21;96m
#SPC#
97m
1;97m
2;97m
3;97m
4;97m
5;97m
6;97m
7;97m
8;97m
9;97m
21;97m
#SPC#
100m
1;100m
2;100m
3;100m
4;100m
5;100m
6;100m
7;100m
8;100m
9;100m
21;100m
#SPC#
101m
1;101m
2;101m
3;101m
4;101m
5;101m
6;101m
7;101m
8;101m
9;101m
21;101m
#SPC#
102m
1;102m
2;102m
3;102m
4;102m
5;102m
6;102m
7;102m
8;102m
9;102m
21;102m
#SPC#
103m
1;103m
2;103m
3;103m
4;103m
5;103m
6;103m
7;103m
8;103m
9;103m
21;103m
#SPC#
104m
1;104m
2;104m
3;104m
4;104m
5;104m
6;104m
7;104m
8;104m
9;104m
21;104m
#SPC#
105m
1;105m
2;105m
3;105m
4;105m
5;105m
6;105m
7;105m
8;105m
9;105m
21;105m
#SPC#
106m
1;106m
2;106m
3;106m
4;106m
5;106m
6;106m
7;106m
8;106m
9;106m
21;106m
#SPC#
107m
1;107m
2;107m
3;107m
4;107m
5;107m
6;107m
7;107m
8;107m
9;107m
21;107m
__ROWS:END__
__DATA:END__

View File

@ -0,0 +1,52 @@
:: Extended ColorTool equivalent (ColorTool.exe -c) to show more colors, but requires 107 columns
__DATA__
__TABLE__
:: The test text
SET "CELL= gYw "
:: Alignment properties for the cells and headers
SET "ALIGN.CELL=C"
SET "ALIGN.BOXHEAD=C"
SET "ALIGN.STUB=L"
:: Table spacing
SET "SEPARATOR.CELL= "
SET "SEPARATOR.STUB= "
__TABLE:END__
__COLS__
#NUL#
40m
100m
41m
101m
42m
102m
43m
103m
44m
104m
45m
105m
46m
106m
47m
107m
__COLS:END__
__ROWS__
#NUL#
30m
90m
31m
91m
32m
92m
33m
93m
34m
94m
35m
95m
36m
96m
37m
97m
__ROWS:END__
__DATA:END__

View File

@ -0,0 +1,45 @@
:: ColorTool equivalent (ColorTool.exe -c)
__DATA__
__TABLE__
:: The test text
SET "CELL= gYw "
:: Alignment properties for the cells and headers
SET "ALIGN.CELL=C"
SET "ALIGN.BOXHEAD=C"
SET "ALIGN.STUB=L"
:: Table spacing
SET "SEPARATOR.CELL= "
SET "SEPARATOR.STUB= "
__TABLE:END__
__COLS__
#NUL#
40m
41m
42m
43m
44m
45m
46m
47m
__COLS:END__
__ROWS__
m
1m
30m
1;30m
31m
1;31m
32m
1;32m
33m
1;33m
34m
1;34m
35m
1;35m
36m
1;36m
37m
1;37m
__ROWS:END__
__DATA:END__

View File

@ -0,0 +1,80 @@
:: #!/bin/bash
:: #
:: # This file echoes a bunch of color codes to the
:: # terminal to demonstrate what's available. Each
:: # line is the color code of one forground color,
:: # out of 17 (default + 16 escapes), followed by a
:: # test use of that color on all nine background
:: # colors (default + 8 escapes).
:: #
::
:: T='gYw' # The test text
::
:: echo -e "\n 40m 41m 42m 43m\
:: 44m 45m 46m 47m";
::
:: for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
:: '1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
:: ' 36m' '1;36m' ' 37m' '1;37m';
:: do FG=${FGs// /}
:: echo -en " $FGs \033[$FG $T "
:: for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
:: do echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
:: done
:: echo;
:: done
:: echo
:: https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
:: This is the recreation of the output of the TLDP.org
:: bash script provided by Daniel Crisman.
__DATA__
__TABLE__
:: Greatest mystery ever. Why gYw?
SET "CELL= gYw "
:: The stub is right justified
SET "ALIGN.STUB=R"
:: The box header is centered over each column
SET "ALIGN.BOXHEAD=C"
:: There is a space between the stub and the rest of the table
SET "SEPARATOR.STUB= "
:: Each column is separated by a space
SET "SEPARATOR.COL= "
:: The widest stub label is 5 characters, but the original table uses 6 for the stub, producing a leading space
SET /A "STUB.MAX_WIDTH=6"
__TABLE:END__
:: Background
__COLS__
:: A column with no background attributes applied
#NUL#
40m
41m
42m
43m
44m
45m
46m
47m
__COLS:END__
:: Foreground
__ROWS__
m
1m
30m
1;30m
31m
1;31m
32m
1;32m
33m
1;33m
34m
1;34m
35m
1;35m
36m
1;36m
37m
1;37m
__ROWS:END__
__DATA:END__

View File

@ -0,0 +1,61 @@
:: Compact display of foreground over background colors
:: Requires 76 columns
__DATA__
__TABLE__
SET "UTF8.REQUIRED=#TRUE#"
:: Definition strings
SET "CELL=gYw"
REM SET "STUBHEAD=BG\FG"
:: Separators
SET "SEPARATOR.BOXHEAD_BODY=─"
SET "SEPARATOR.STUB_BODY=│"
SET "SEPARATOR.CELL= "
SET "SEPARATOR.INTERSECT=┌"
REM SET "SEPARATOR.CELL_INTERSECT=┬"
SET "SEPARATOR.CELL_INTERSECT=┼"
REM SET "SEPARATOR.CELL_INTERSECT=┴"
__TABLE:END__
__COLS__
#NUL#
30m
31m
32m
33m
34m
35m
36m
37m
39m
90m
91m
92m
93m
94m
95m
96m
97m
__COLS:END__
__ROWS__
#NUL#
40m
41m
42m
43m
44m
45m
46m
47m
49m
100m
101m
102m
103m
104m
105m
106m
107m
__ROWS:END__
__DATA:END__

View File

@ -0,0 +1,64 @@
:: Demonstrates how to use the #LBL# feature for definition files
:: Requires 107 columns
__DATA__
__TABLE__
:: The test text
SET "CELL= gYw "
REM SET "SPINNER.DISABLED=#TRUE#"
:: Alignment properties for the cells and headers
SET "ALIGN.CELL=C"
SET "ALIGN.BOXHEAD=C"
SET "ALIGN.STUB=L"
:: Table spacing
SET "SEPARATOR.CELL= "
SET "SEPARATOR.STUB= "
:: Formatting
SET "INV=!CSI!7m"
SET "HIGH=!CSI!1m"
SET "LOW=!CSI!2m"
__TABLE:END__
__COLS__
#NUL#
40m
41m
42m
43m
44m
45m
46m
47m
100m
101m
102m
103m
104m
105m
106m
107m
__COLS:END__
__ROWS__
#LBL# NUL:
#NUL#
#LBL#.SPC:
#SPC#
#LBL# !INV!Foreground
#LBL#. !LOW!Low Intensity
30m
31m
32m
33m
34m
35m
36m
37m
#LBL# !HIGH!High Intensity
90m
91m
92m
93m
94m
95m
96m
97m
__ROWS:END__
__DATA:END__

View File

@ -0,0 +1,54 @@
:: Uses Unicode Block Element Shade Characters to show a dithered mix of foreground and background colors
__DATA__
__TABLE__
SET "UTF8.REQUIRED=#TRUE#"
:: The test text
REM SET "CELL= ░▒▓█"
SET "CELL=░▒▓"
SET "STUBHEAD=plaid"
:: Separator characters for cells and headers
SET "SEPARATOR.STUBHEAD_BOXHEAD=│"
SET "SEPARATOR.STUBHEAD_STUB=─"
SET "SEPARATOR.INTERSECT=┘"
__TABLE:END__
:: Background
__COLS__
40m
41m
42m
43m
44m
45m
46m
47m
100m
101m
102m
103m
104m
105m
106m
107m
__COLS:END__
:: [Intensity;][Attribute;]Foreground
__ROWS__
30m
31m
32m
33m
34m
35m
36m
37m
90m
91m
92m
93m
94m
95m
96m
97m
__ROWS:END__
__DATA:END__

View File

@ -0,0 +1,52 @@
:: Like the colortest definition, but arranged to show the colors as ROY G. BIV, dark then light
__DATA__
__TABLE__
:: The test text
SET "CELL= gYw "
:: Alignment properties for the cells and headers
SET "ALIGN.CELL=C"
SET "ALIGN.BOXHEAD=C"
SET "ALIGN.STUB=L"
:: Table spacing
SET "SEPARATOR.CELL= "
SET "SEPARATOR.STUB= "
__TABLE:END__
__COLS__
#NUL#
40m
47m
41m
43m
42m
46m
44m
45m
101m
103m
102m
106m
104m
105m
100m
107m
__COLS:END__
__ROWS__
#NUL#
30m
37m
31m
33m
32m
36m
34m
35m
91m
93m
92m
96m
94m
95m
90m
97m
__ROWS:END__
__DATA:END__

View File

@ -0,0 +1,40 @@
:: https://rosettacode.org/wiki/Terminal_control/Coloured_text#ooRexx
__DATA__
:: Background
__COLS__
#NUL#
40m
41m
42m
43m
44m
45m
46m
47m
__COLS:END__
:: Foreground
__ROWS__
0m
1m
0;30m
1;30m
0;31m
1;31m
0;32m
1;32m
0;33m
1;33m
0;34m
1;34m
0;35m
1;35m
0;36m
1;36m
0;37m
1;37m
4m
5m
7m
8m
__ROWS:END__
__DATA:END__

View File

@ -0,0 +1,124 @@
:: Demonstrates all the different ways the separators can be configured
__DATA__
__TABLE__
SET "UTF8.REQUIRED=#TRUE#"
:: The test text
SET "CELL= gYw "
SET "STUBHEAD=SGR"
:: Alignment properties for the cells and headers
REM SET "ALIGN.CELL=C"
REM SET "ALIGN.BOXHEAD=R"
REM SET "ALIGN.STUB=L"
SET "ALIGN.STUBHEAD=C"
:: Separator characters for cells and headers
:: Create a grid
SET "SEPARATOR.BOXHEAD=─"
SET "SEPARATOR.COL=╎"
:: With a distinct separator between the stub and the rest of the table
SET "SEPARATOR.STUB=│"
:: With an intersect
:::: This should be specifically defined if there are both SEPARATOR.VERTICAL
:::: and SEPARATOR.HORIZONTAL components, and therefore it can't be determined
:::: how the intersect should be extended. When non-deterministic and undefined,
:::: the intersect will be shown as a blank space.
SET "SEPARATOR.INTERSECT=┼"
:: With a column intersect
SET "SEPARATOR.CELL_INTERSECT=┼"
:: Create a table with columns
REM SET "SEPARATOR.COL=╎"
:: But no separator between the stub and the rest of the table
REM SET "SEPARATOR.VERTICAL=#TRUE#"
:: Equivalent to SEPARATOR.BOXHEAD with individual definitions for the respective parts
REM SET "SEPARATOR.STUBHEAD_STUB=─"
REM SET "SEPARATOR.BOXHEAD_BODY=━"
:: With an intersect, not shown if there isn't also a SEPARATOR.VERTICAL component
:: such as SEPARATOR.COL
REM SET "SEPARATOR.COL=╎"
REM SET "SEPARATOR.INTERSECT=┾"
:: SEPARATOR.STUB
REM SET "SEPARATOR.STUB=│"
REM SET "SEPARATOR.INTERSECT=┾"
:: SEPARATOR.STUBHEAD_BOXHEAD
REM SET "SEPARATOR.STUBHEAD_BOXHEAD=│"
REM SET "SEPARATOR.INTERSECT=┶"
:: or SEPARATOR.STUB_BODY
REM SET "SEPARATOR.STUB_BODY=┃"
REM SET "SEPARATOR.INTERSECT=┲"
:: Equivalent to SEPARATOR.STUB with individual definitions for the respective parts
REM SET "SEPARATOR.STUBHEAD_BOXHEAD=│"
REM SET "SEPARATOR.STUB_BODY=┃"
:: With an intersect, not shown if there isn't also a SEPARATOR.HORIZONTAL component
:: such as SEPARATOR.BOXHEAD
REM SET "SEPARATOR.INTERSECT=╁"
REM SET "SEPARATOR.BOXHEAD=─"
:: SEPARATOR.STUBHEAD_STUB
REM SET "SEPARATOR.INTERSECT=┧"
REM SET "SEPARATOR.STUBHEAD_STUB=─"
:: or SEPARATOR.BOXHEAD_BODY
REM SET "SEPARATOR.INTERSECT=┢"
REM SET "SEPARATOR.BOXHEAD_BODY=━"
:: Column intersects require a SEPARATOR.BOXHEAD component and a SEPARATOR.COLUMN component
:: such as SEPARATOR.COL
REM SET "SEPARATOR.BOXHEAD=─"
REM SET "SEPARATOR.INTERSECT=╁"
REM SET "SEPARATOR.COL=│"
REM SET "SEPARATOR.CELL_INTERSECT=┼"
:: SEPARATOR.CELL
REM SET "SEPARATOR.BOXHEAD=─"
REM SET "SEPARATOR.INTERSECT=╁"
REM SET "SEPARATOR.CELL=│"
REM SET "SEPARATOR.CELL_INTERSECT=┬"
:: or SEPARATOR.BOXHEADERS
REM SET "SEPARATOR.BOXHEAD=─"
REM SET "SEPARATOR.INTERSECT=╁"
REM SET "SEPARATOR.BOXHEADERS=│"
REM SET "SEPARATOR.CELL_INTERSECT=┴"
:: And all combined
REM SET "SEPARATOR.STUBHEAD_STUB=─"
REM SET "SEPARATOR.BOXHEAD_BODY=━"
REM SET "SEPARATOR.COL=╎"
REM SET "SEPARATOR.STUBHEAD_BOXHEAD=│"
REM SET "SEPARATOR.STUB_BODY=┃"
REM SET "SEPARATOR.INTERSECT=╆"
REM SET "SEPARATOR.CELL_INTERSECT=┿"
__TABLE:END__
:: Background
__COLS__
40m
41m
42m
43m
44m
45m
46m
47m
__COLS:END__
:: [Intensity;][Attribute;]Foreground
__ROWS__
30m
31m
32m
33m
34m
35m
36m
37m
__ROWS:END__
__DATA:END__

View File

@ -0,0 +1,160 @@
:: Check SGR intensity attributes, requires 110 columns
__DATA__
__TABLE__
:: The test text
SET "CELL= gYw "
SET "STUBHEAD=SGR Intensity "
:: Alignment properties for the cells and headers
REM SET "ALIGN.CELL=C"
REM SET "ALIGN.BOXHEAD=R"
REM SET "ALIGN.STUB=L"
REM SET "ALIGN.STUBHEAD=C"
:: Separator characters for cells and headers
REM SET "SEPARATOR.STUB= "
REM SET "SEPARATOR.STUB=│"
REM SET "SEPARATOR.BOXHEAD= "
REM SET "SEPARATOR.BOXHEAD=─"
REM SET "SEPARATOR.COL= "
REM SET "SEPARATOR.COL=╎"
REM SET "SEPARATOR.STUBHEAD_BOXHEAD= "
REM Can't use pipe or exclamation point as a separator
SET "SEPARATOR.STUBHEAD_BOXHEAD=:"
REM SET "SEPARATOR.STUBHEAD_BOXHEAD=▓▓"
REM SET "SEPARATOR.STUBHEAD_STUB= "
REM SET "SEPARATOR.STUBHEAD_STUB=─"
SET "SEPARATOR.STUBHEAD_STUB=-"
REM SET "SEPARATOR.STUBHEAD_STUB=▓"
REM SET "SEPARATOR.INTERSECT= "
REM SET "SEPARATOR.INTERSECT=┼"
REM SET "SEPARATOR.INTERSECT=┘"
SET "SEPARATOR.INTERSECT=+"
REM SET "SEPARATOR.INTERSECT=▓▒▒░"
REM SET "SEPARATOR.BOXHEAD_BODY= "
REM SET "SEPARATOR.BOXHEAD_BODY=─"
REM SET "SEPARATOR.BOXHEAD_BODY=░"
REM SET "SEPARATOR.STUB_BODY= "
REM SET "SEPARATOR.STUB_BODY=│"
REM SET "SEPARATOR.STUB_BODY=░░"
REM SET "SEPARATOR.BOXHEADERS= "
REM SET "SEPARATOR.BOXHEADERS=╎"
REM SET "SEPARATOR.CELL= "
REM SET "SEPARATOR.CELL=╎"
__TABLE:END__
:: Background
__COLS__
49m
#SPC#
#NUL#
40m
100m
41m
101m
42m
102m
43m
103m
44m
104m
45m
105m
46m
106m
47m
107m
__COLS:END__
:: [Intensity;][Attribute;]Foreground
__ROWS__
:: Default
#LBL# Default
39m
#SPC#
:: Normal
#LBL# Normal
#NUL#
30m
90m
31m
91m
32m
92m
33m
93m
34m
94m
35m
95m
36m
96m
37m
97m
#SPC#
:: Attributes
#LBL# Attributes
2m
#NUL#
1m
#SPC#
:: Faint (decreased intensity), 2
:: Normal
:: Bold or increased intensity, 1
#LBL# Applied !CSI!2mdecreased!RESET! intensity
#LBL# Normal
#LBL# Applied !CSI!1mincreased!RESET! intensity
2;39m
39m
1;39m
2m
#NUL#
1m
2;30m
30m
1;30m
2;90m
90m
1;90m
2;31m
31m
1;31m
2;91m
91m
1;91m
2;32m
32m
1;32m
2;92m
92m
1;92m
2;33m
33m
1;33m
2;93m
93m
1;93m
2;34m
34m
1;34m
2;94m
94m
1;94m
2;35m
35m
1;35m
2;95m
95m
1;95m
2;36m
36m
1;36m
2;96m
96m
1;96m
2;37m
37m
1;37m
2;97m
97m
1;97m
__ROWS:END__
__DATA:END__

View File

@ -0,0 +1,348 @@
:: Complete matrix of SGR parameters available
:: This definition also demonstrates the various configuration changes
:: which are used to control the way the table is generated
:: Requires 97 columns to display correctly
__DATA__
:: Select Graphic Rendition (SGR) parameters
:: #NUL# is treated as a special case to provide cells in that column
:: or row, but there is no row or column value applied to the cell.
:: This has the effect that the row or column has no SGR parameter applied
:: and so this will show the default.
:: #SPC# is a special case which can be used to make gaps in the table.
:: Whereas #NUL# still outputs the CELL text, #SPC# won't show anything in
:: that row. #SPC# can be used in columns to also provide a gap which matches
:: cell width.
:: #LBL# is also a special case similar to #SPC#. #LBL# makes it possible to
:: write a text label in the middle of a generated table for a particular row.
:: Formatting can be applied to the labels and an SGR RESET is automatically
:: applied at the end of the string.
__TABLE__
SET "UTF8.REQUIRED=#TRUE#"
:: The test text
SET "CELL= gYw "
SET "STUBHEAD=SGR"
:: Alignment properties for the cells and headers
REM SET "ALIGN.CELL=C"
REM SET "ALIGN.BOXHEAD=R"
REM SET "ALIGN.STUB=L"
REM SET "ALIGN.STUBHEAD=C"
:: Separator characters for cells and headers
REM SET "SEPARATOR.STUB= "
REM SET "SEPARATOR.STUB=│"
REM SET "SEPARATOR.BOXHEAD= "
REM SET "SEPARATOR.BOXHEAD=─"
REM SET "SEPARATOR.COL= "
REM SET "SEPARATOR.COL=╎"
REM SET "SEPARATOR.STUBHEAD_BOXHEAD= "
SET "SEPARATOR.STUBHEAD_BOXHEAD=│"
REM SET "SEPARATOR.STUBHEAD_BOXHEAD=▓▓"
REM SET "SEPARATOR.STUBHEAD_STUB= "
SET "SEPARATOR.STUBHEAD_STUB=─"
REM SET "SEPARATOR.STUBHEAD_STUB=▓"
REM SET "SEPARATOR.INTERSECT= "
REM SET "SEPARATOR.INTERSECT=┼"
SET "SEPARATOR.INTERSECT=┘"
REM SET "SEPARATOR.INTERSECT=▓▒▒░"
REM SET "SEPARATOR.BOXHEAD_BODY= "
REM SET "SEPARATOR.BOXHEAD_BODY=─"
REM SET "SEPARATOR.BOXHEAD_BODY=░"
REM SET "SEPARATOR.STUB_BODY= "
REM SET "SEPARATOR.STUB_BODY=│"
REM SET "SEPARATOR.STUB_BODY=░░"
REM SET "SEPARATOR.BOXHEADERS= "
REM SET "SEPARATOR.BOXHEADERS=╎"
REM SET "SEPARATOR.CELL= "
REM SET "SEPARATOR.CELL=╎"
:: Formatting for labels
SET "SECTION=!CSI!1;4m"
__TABLE:END__
:: Background
__COLS__
#NUL#
REM 1m
REM 2m
REM 3m
REM 4m
REM 5m
REM 6m
REM 7m
REM 8m
REM 9m
REM 21m
40m
41m
42m
43m
44m
45m
46m
47m
49m
100m
101m
102m
103m
104m
105m
106m
107m
__COLS:END__
:: [Intensity;][Attribute;]Foreground
__ROWS__
#NUL#
#SPC#
:: Attributes
#LBL# !SECTION!Attributes
1m
2m
3m
4m
5m
6m
7m
8m
9m
REM 10m
REM 11m
REM 12m
REM 13m
REM 14m
REM 15m
REM 16m
REM 17m
REM 18m
REM 19m
REM 20m
21m
REM 22m
REM 23m
REM 24m
REM 25m
REM 26m
REM 27m
REM 28m
REM 29m
#SPC#
:: Normal
#LBL# !SECTION!Normal
30m
31m
32m
33m
34m
35m
36m
37m
39m
90m
91m
92m
93m
94m
95m
96m
97m
#SPC#
:: Bold or increased intensity, 1
#LBL# !SECTION!Bold or increased intensity, 1
1;30m
1;31m
1;32m
1;33m
1;34m
1;35m
1;36m
1;37m
1;39m
1;90m
1;91m
1;92m
1;93m
1;94m
1;95m
1;96m
1;97m
#SPC#
:: Faint (decreased intensity), 2
#LBL# !SECTION!Faint (decreased intensity), 2
2;30m
2;31m
2;32m
2;33m
2;34m
2;35m
2;36m
2;37m
2;39m
2;90m
2;91m
2;92m
2;93m
2;94m
2;95m
2;96m
2;97m
#SPC#
:: Italic, 3
#LBL# !SECTION!Italic, 3
3;30m
3;31m
3;32m
3;33m
3;34m
3;35m
3;36m
3;37m
3;39m
3;90m
3;91m
3;92m
3;93m
3;94m
3;95m
3;96m
3;97m
#SPC#
:: Underline, 4
#LBL# !SECTION!Underline, 4
4;30m
4;31m
4;32m
4;33m
4;34m
4;35m
4;36m
4;37m
4;39m
4;90m
4;91m
4;92m
4;93m
4;94m
4;95m
4;96m
4;97m
#SPC#
:: Slow Blink, 5
#LBL# !SECTION!Slow Blink, 5
5;30m
5;31m
5;32m
5;33m
5;34m
5;35m
5;36m
5;37m
5;39m
5;90m
5;91m
5;92m
5;93m
5;94m
5;95m
5;96m
5;97m
#SPC#
:: Rapid Blink, 6
#LBL# !SECTION!Rapid Blink, 6
6;30m
6;31m
6;32m
6;33m
6;34m
6;35m
6;36m
6;37m
6;39m
6;90m
6;91m
6;92m
6;93m
6;94m
6;95m
6;96m
6;97m
#SPC#
:: Reverse video, 7
#LBL# !SECTION!Reverse video, 7
7;30m
7;31m
7;32m
7;33m
7;34m
7;35m
7;36m
7;37m
7;39m
7;90m
7;91m
7;92m
7;93m
7;94m
7;95m
7;96m
7;97m
#SPC#
:: Conceal, 8
#LBL# !SECTION!Conceal, 8
8;30m
8;31m
8;32m
8;33m
8;34m
8;35m
8;36m
8;37m
8;39m
8;90m
8;91m
8;92m
8;93m
8;94m
8;95m
8;96m
8;97m
#SPC#
:: Crossed-out, 9
#LBL# !SECTION!Crossed-out, 9
9;30m
9;31m
9;32m
9;33m
9;34m
9;35m
9;36m
9;37m
9;39m
9;90m
9;91m
9;92m
9;93m
9;94m
9;95m
9;96m
9;97m
#SPC#
:: Double Underline, 21
#LBL# !SECTION!Double Underline, 21
21;30m
21;31m
21;32m
21;33m
21;34m
21;35m
21;36m
21;37m
21;39m
21;90m
21;91m
21;92m
21;93m
21;94m
21;95m
21;96m
21;97m
__ROWS:END__
__DATA:END__

View File

@ -0,0 +1,287 @@
:: Complete matrix of SGR parameters available, but transposed
:: This definition is like SGR but for each row, all attributes are applied
:: per foreground color instead of incrementing on the attributes
:: ForEach(fg in Foreground) { ForEach(a in Attribute) { a;fm }} instead of
:: ForEach(a in Attribute) { ForEach(fg in Foreground) { a;fm }}
:: Requires 147 columns
__DATA__
:: Select Graphic Rendition (SGR) parameters
__TABLE__
SET "UTF8.REQUIRED=#TRUE#"
:: The test text
REM SET "CELL= ЯMB "
SET "CELL= gYw "
SET "STUBHEAD=tSGR"
:: Alignment properties for the cells and headers
REM SET "ALIGN.CELL=C"
REM SET "ALIGN.BOXHEAD=R"
REM SET "ALIGN.STUB=L"
REM SET "ALIGN.STUBHEAD=C"
:: Separator characters for cells and headers
REM SET "SEPARATOR.STUB= "
REM SET "SEPARATOR.STUB=│"
REM SET "SEPARATOR.BOXHEAD= "
REM SET "SEPARATOR.BOXHEAD=─"
REM SET "SEPARATOR.COL= "
REM SET "SEPARATOR.COL=╎"
REM SET "SEPARATOR.STUBHEAD_BOXHEAD= "
SET "SEPARATOR.STUBHEAD_BOXHEAD=│"
REM SET "SEPARATOR.STUBHEAD_BOXHEAD=▓▓"
REM SET "SEPARATOR.STUBHEAD_STUB= "
SET "SEPARATOR.STUBHEAD_STUB=─"
REM SET "SEPARATOR.STUBHEAD_STUB=▓"
REM SET "SEPARATOR.INTERSECT= "
REM SET "SEPARATOR.INTERSECT=┼"
SET "SEPARATOR.INTERSECT=┘"
REM SET "SEPARATOR.INTERSECT=▓▒▒░"
REM SET "SEPARATOR.BOXHEAD_BODY= "
REM SET "SEPARATOR.BOXHEAD_BODY=─"
REM SET "SEPARATOR.BOXHEAD_BODY=░"
REM SET "SEPARATOR.STUB_BODY= "
REM SET "SEPARATOR.STUB_BODY=│"
REM SET "SEPARATOR.STUB_BODY=░░"
REM SET "SEPARATOR.BOXHEADERS= "
REM SET "SEPARATOR.BOXHEADERS=╎"
REM SET "SEPARATOR.CELL= "
REM SET "SEPARATOR.CELL=╎"
__TABLE:END__
:: Background
__COLS__
#NUL#
1m
2m
3m
4m
5m
6m
7m
8m
9m
21m
#SPC#
40m
100m
41m
101m
42m
102m
43m
103m
44m
104m
45m
105m
46m
106m
47m
107m
__COLS:END__
:: [Intensity;][Attribute;]Foreground
__ROWS__
#NUL#
1m
2m
3m
4m
5m
6m
7m
8m
9m
21m
#SPC#
30m
1;30m
2;30m
3;30m
4;30m
5;30m
6;30m
7;30m
8;30m
9;30m
21;30m
#SPC#
90m
1;90m
2;90m
3;90m
4;90m
5;90m
6;90m
7;90m
8;90m
9;90m
21;90m
#SPC#
31m
1;31m
2;31m
3;31m
4;31m
5;31m
6;31m
7;31m
8;31m
9;31m
21;31m
#SPC#
91m
1;91m
2;91m
3;91m
4;91m
5;91m
6;91m
7;91m
8;91m
9;91m
21;91m
#SPC#
32m
1;32m
2;32m
3;32m
4;32m
5;32m
6;32m
7;32m
8;32m
9;32m
21;32m
#SPC#
92m
1;92m
2;92m
3;92m
4;92m
5;92m
6;92m
7;92m
8;92m
9;92m
21;92m
#SPC#
33m
1;33m
2;33m
3;33m
4;33m
5;33m
6;33m
7;33m
8;33m
9;33m
21;33m
#SPC#
93m
1;93m
2;93m
3;93m
4;93m
5;93m
6;93m
7;93m
8;93m
9;93m
21;93m
#SPC#
34m
1;34m
2;34m
3;34m
4;34m
5;34m
6;34m
7;34m
8;34m
9;34m
21;34m
#SPC#
94m
1;94m
2;94m
3;94m
4;94m
5;94m
6;94m
7;94m
8;94m
9;94m
21;94m
#SPC#
35m
1;35m
2;35m
3;35m
4;35m
5;35m
6;35m
7;35m
8;35m
9;35m
21;35m
#SPC#
95m
1;95m
2;95m
3;95m
4;95m
5;95m
6;95m
7;95m
8;95m
9;95m
21;95m
#SPC#
36m
1;36m
2;36m
3;36m
4;36m
5;36m
6;36m
7;36m
8;36m
9;36m
21;36m
#SPC#
96m
1;96m
2;96m
3;96m
4;96m
5;96m
6;96m
7;96m
8;96m
9;96m
21;96m
#SPC#
37m
1;37m
2;37m
3;37m
4;37m
5;37m
6;37m
7;37m
8;37m
9;37m
21;37m
#SPC#
97m
1;97m
2;97m
3;97m
4;97m
5;97m
6;97m
7;97m
8;97m
9;97m
21;97m
__ROWS:END__
__DATA:END__

View File

@ -0,0 +1,41 @@
:: https://askubuntu.com/questions/27314/script-to-display-all-terminal-colors
__DATA__
__TABLE__
:: The test text
SET "CELL= gYw "
SET "SEPARATOR.CELL= "
__TABLE:END__
:: Background
__COLS__
#NUL#
40m
41m
42m
43m
44m
45m
46m
47m
__COLS:END__
:: Foreground
__ROWS__
m
1m
30m
1;30m
31m
1;31m
32m
1;32m
33m
1;33m
34m
1;34m
35m
1;35m
36m
1;36m
37m
1;37m
__ROWS:END__
__DATA:END__