Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
37 commits merged into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c353e6b
Add ansi-color.cmd tool and several definitions
rbeesley Dec 13, 2021
3256bef
Add README.md
rbeesley Dec 13, 2021
0c09451
Satisfy check-spelling-bot
rbeesley Dec 13, 2021
1796285
Fixed missing files for spell-check-bot script
rbeesley Dec 13, 2021
b2b4e4e
Deleting spell-check-bot file placed incorrectly
rbeesley Dec 13, 2021
8a95ab1
Improved spelling, comments, error handling
rbeesley Dec 14, 2021
7006e52
check-spelling-bot fix.
rbeesley Dec 14, 2021
78004c7
Fixed comment and macro casing
rbeesley Dec 14, 2021
23e489f
Merge branch 'microsoft:main' into 6470-Command-Shell-Script-ColorTool
rbeesley Dec 14, 2021
21a936e
Improved CHCP reliability and case insensitive IFs
rbeesley Dec 15, 2021
7715420
UTF-8 Error message was inconsistent.
rbeesley Dec 15, 2021
bfc731f
Improved table parsing
rbeesley Dec 15, 2021
777366f
Added support for column spaces and adjusted defs
rbeesley Dec 27, 2021
972e298
Added ability to create labels for the table.
rbeesley Dec 29, 2021
8ad9cc1
check-spelling-bot update to conform
rbeesley Dec 29, 2021
8a24e7e
Add ansi-color.cmd tool and several definitions
rbeesley Dec 13, 2021
2e50065
Add README.md
rbeesley Dec 13, 2021
eadb9a8
Satisfy check-spelling-bot
rbeesley Dec 13, 2021
008da54
Fixed missing files for spell-check-bot script
rbeesley Dec 13, 2021
6a75e75
Deleting spell-check-bot file placed incorrectly
rbeesley Dec 13, 2021
9252afd
Improved spelling, comments, error handling
rbeesley Dec 14, 2021
183dd4b
check-spelling-bot fix.
rbeesley Dec 14, 2021
7da3b52
Fixed comment and macro casing
rbeesley Dec 14, 2021
6313006
Improved CHCP reliability and case insensitive IFs
rbeesley Dec 15, 2021
456fff4
UTF-8 Error message was inconsistent.
rbeesley Dec 15, 2021
60696aa
Improved table parsing
rbeesley Dec 15, 2021
7e8b6c5
Added support for column spaces and adjusted defs
rbeesley Dec 27, 2021
5515f6e
Added ability to create labels for the table.
rbeesley Dec 29, 2021
eab3c9b
check-spelling-bot update to conform
rbeesley Dec 29, 2021
1185aa8
Merge branch 'microsoft-main' into 6470-Command-Shell-Script-ColorTool
rbeesley Dec 29, 2021
cbe7103
Fixed warning in patterns.txt and modified sgr.def
rbeesley Dec 30, 2021
0586920
Updated attrib.def and fixed tsgr.def
rbeesley Dec 30, 2021
9fc236d
Don't count #SPC# for R1C1 columns
rbeesley Dec 30, 2021
6e61b29
Added column intersects and addressed CR comments
rbeesley Jan 3, 2022
c9ccfa8
Typo
rbeesley Jan 3, 2022
d806b3e
Fixed ALIGN.INTERSECT redefinition in script
rbeesley Jan 3, 2022
c185526
Fixed spelling for unrecognized words
rbeesley Jan 3, 2022
File filter

Filter by extension

Filter by extension

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