On Thu, 16 Mar 2017, Bruce Evans wrote:
Log: Add teken_256to16() to convert xterm-256 256-color codes to xterm 16-color codes. This will be used to fix bright colors.Improve teken_256to8(). Use a lookup table instead of calculations. The ...
A shell script for printing some text color maps is attached. Also a sloppier one for printing some CSI sequences. The first one can easily be translated to xterm sequences. I used syscons F and G sequences to print bright colors with sc and vt since pure xterm bright colors are too broken to display themselves without bold hacks. The F and G sequences generate bold hacks in the kernel, and further complications are needed to turn these off to test if bright colors are fixed. Real xterm doesn't fake bold using brightness, so bold hacks on dark characters don't work for it. The first one needs the user to load a cp437 font for syscons and a unicode font for vt. The script doesn't load a font since it is too hard to restore or reset fonts. Similarly for colors. Run the first one on a kernel without this commit to see the old color map. It looked just wrong (unstructured) before I found a good tabular format to print it. I then wrote "improved" maps based on expanding the 2x2x2 and 3x3x3 maps. These were too simple. Some of the comments/printfs are out of date and still refer to this expansion. Bruce
#!/bin/sh # Print some color maps for syscons and vt. VTY=$(sysctl -n kern.vty 2>/dev/null) # XXX user must load font with block char where we expect it. case $VTY in vt) # XXX broken in text mode (no extension from 8th bit to 9th). BL="\342\226\210";; # Block char 0x2588 in UTF8 for unicode font. *) BL="\333";; # Block char 0xDB in ASCII for cp437 font. esac CSI="\033[" k() { printf "$CSI=0F$BL$BL" } b() { printf "$CSI=1F$BL$BL" } g() { printf "$CSI=2F$BL$BL" } c() { printf "$CSI=3F$BL$BL" } r() { printf "$CSI=4F$BL$BL" } m() { printf "$CSI=5F$BL$BL" } y() { printf "$CSI=6F$BL$BL" } w() { printf "$CSI=7F$BL$BL" } K() { printf "$CSI=8F$BL$BL" } B() { printf "$CSI=9F$BL$BL" } G() { printf "$CSI=10F$BL$BL" } C() { printf "$CSI=11F$BL$BL" } R() { printf "$CSI=12F$BL$BL" } M() { printf "$CSI=13F$BL$BL" } Y() { printf "$CSI=14F$BL$BL" } W() { printf "$CSI=15F$BL$BL" } maybe_clreol() { case $VTY in vt) ;; # Not needed, and harmful, if no automarg. *) printf "${CSI}0K";; esac } demo_defcolors() { printf "${CSI}0m" printf "$CSI=15F$CSI=0G" } nl() { demo_defcolors maybe_clreol # Part. fix for mess made by automarg+scroll. printf "\n" } defcolors() { printf "${CSI}0m" printf "$CSI=7F$CSI=0G" # Partial fix for broken ${CSI}0x. printf "${CSI}0x" } unhackbold() { # We set bright w in demo_defefcolors for printing messages # and bg color tests, but the teken bold hack for this setting # leaks into following fg color settings. Undo the hack, if any. printf "${CSI}22m" } demo_defcolors printf "2x2x2 cmap, vertical:\n" k; b; nl g; c; nl r; m; nl y; w; nl printf "2x2x2 cmap, horizontal:\n" k; b; g; c; r; m; y; w; nl printf "\n3x3x3 cmap, vertical:\n" k; b; B; nl g; c; C; nl G; C; C; nl r; m; M; nl y; w; B; nl Y; G; C; nl R; M; M; nl Y; R; M; nl Y; Y; W; nl printf "3x3x3 cmap, horizontal:\n" k; b; B; g; c; C; G; C; C; nl r; m; M; y; w; B; Y; G; C; nl R; M; M; Y; R; M; Y; Y; W; nl nl2() { # nl } EXIT() { defcolors printf '\033[x\033[2;6x\033[1;0x\033[6;7x\033[5;4x' printf '\033[=3F\033[=0G' exit } printf "\n8-color 6x6x6 + 24 cmap from expansion of 2x2x2 + 2grey, structured:\n" # 000 002 003 004 005 006 k; b; b; b; b; b nl2 # 020 022 023 024 025 026 g; c; c; b; b; b nl2 # 030 032 033 034 035 036 g; c; c; c; b; b nl2 # 040 042 043 044 045 046 g; g; c; c; c; b nl2 # 050 052 053 054 055 056 g; g; g; c; c; c nl2 # 060 062 063 064 065 066 g; g; g; g; c; c nl # 200 202 203 204 205 206 r; m; m; b; b; b nl2 # 220 222 223 224 225 226 y; k; b; b; b; b nl2 # 230 232 233 234 235 236 y; g; c; c; b; b nl2 # 240 242 243 244 245 246 g; g; c; c; c; b nl2 # 250 252 253 254 255 256 g; g; g; c; c; c nl2 # 260 262 263 264 265 266 g; g; g; g; c; c nl # 300 302 303 304 305 306 r; m; m; m; b; b nl2 # 320 322 323 324 325 326 y; r; m; m; b; b nl2 # 330 332 333 334 335 336 y; y; w; b; b; b nl2 # 340 342 343 344 345 346 y; y; g; c; c; b nl2 # 350 352 353 354 355 356 g; g; g; c; c; c nl2 # 360 362 363 364 365 366 g; g; g; g; c; c nl # 400 402 403 404 405 406 r; r; m; m; m; b nl2 # 420 422 423 424 425 426 r; r; m; m; m; b nl2 # 430 432 433 434 435 436 y; y; r; m; m; b nl2 # 440 442 443 444 445 446 y; y; y; w; b; b nl2 # 450 452 453 454 455 456 y; y; y; g; c; c nl2 # 460 462 463 464 465 466 g; g; g; g; c; c nl # 500 502 503 504 505 506 r; r; r; m; m; m nl2 # 520 522 523 524 525 526 r; r; r; m; m; m nl2 # 530 532 533 534 535 536 r; r; r; m; m; m nl2 # 540 542 543 544 545 546 y; y; y; r; m; m nl2 # 550 552 553 554 555 556 y; y; y; y; w; b nl2 # 560 562 563 564 565 566 y; y; y; y; g; c nl # 600 602 603 604 605 606 r; r; r; r; m; m nl2 # 620 622 623 624 625 626 r; r; r; r; m; m nl2 # 630 632 633 634 635 636 r; r; r; r; m; m nl2 # 640 642 643 644 645 646 r; r; r; r; m; m nl2 # 650 652 653 654 655 656 y; y; y; y; r; m nl2 # 660 662 663 664 665 666 y; y; y; y; y; w nl k; k; k; k; k; k k; k; k; k; k; k w; w; w; w; w; w w; w; w; w; w; w nl printf "\n16-color 6x6x6 + 24 cmap from expansion of 3x3x3 + 4grey, structured:\n" # 000 002 003 004 005 006 k; b; b; b; b; b nl2 # 020 022 023 024 025 026 g; c; c; b; b; b nl2 # 030 032 033 034 035 036 g; c; c; c; b; b nl2 # 040 042 043 044 045 046 g; g; c; c; c; b nl2 # 050 052 053 054 055 056 g; g; g; c; c; c nl2 # 060 062 063 064 065 066 g; g; g; g; c; c nl # 200 202 203 204 205 206 r; m; m; b; b; b nl2 # 220 222 223 224 225 226 y; K; b; b; B; B nl2 # 230 232 233 234 235 236 y; g; c; c; B; B nl2 # 240 242 243 244 245 246 g; g; c; c; C; B nl2 # 250 252 253 254 255 256 g; G; G; C; C; C nl2 # 260 262 263 264 265 266 g; G; G; G; C; C nl # 300 302 303 304 305 306 r; m; m; m; b; b nl2 # 320 322 323 324 325 326 y; r; m; m; B; B nl2 # 330 332 333 334 335 336 y; y; w; B; B; B nl2 # 340 342 343 344 345 346 y; y; G; C; C; B nl2 # 350 352 353 354 355 356 g; G; G; C; C; C nl2 # 360 362 363 364 365 366 g; G; G; G; C; C nl # 400 402 403 404 405 406 r; r; m; m; m; b nl2 # 420 422 423 424 425 426 r; r; m; m; M; B nl2 # 430 432 433 434 435 436 y; y; R; M; M; B nl2 # 440 442 443 444 445 446 y; y; Y; W; B; B nl2 # 450 452 453 454 455 456 y; Y; Y; G; C; C nl2 # 460 462 463 464 465 466 g; G; G; G; C; C nl # 500 502 503 504 505 506 r; r; r; m; m; m nl2 # 520 522 523 524 525 526 r; R; R; M; M; M nl2 # 530 532 533 534 535 536 r; R; R; M; M; M nl2 # 540 542 543 544 545 546 y; Y; Y; R; M; M nl2 # 550 552 553 554 555 556 y; Y; Y; Y; W; B nl2 # 560 562 563 564 565 566 y; Y; Y; Y; G; C nl # 600 602 603 604 605 606 r; r; r; r; m; m nl2 # 620 622 623 624 625 626 r; R; R; R; M; M nl2 # 630 632 633 634 635 636 r; R; R; R; M; M nl2 # 640 642 643 644 645 646 r; R; R; R; M; M nl2 # 650 652 653 654 655 656 y; Y; Y; Y; R; M nl2 # 660 662 663 664 665 666 y; Y; Y; Y; Y; W nl k; k; k; k; k; k K; K; K; K; K; K w; w; w; w; w; w W; W; W; W; W; W nl printf "\nactual 6x6x6 + 24 xterm256-ish fg cmap, structured:\n" unhackbold for i in $(jot 240 16) do printf "${CSI}38;5;%dm$BL$BL" $i # if test $((($i - 16) % 6)) = 5; then nl; unhackbold; fi if test $((($i - 16) % 36)) = 35; then nl; unhackbold; fi done nl # EXIT printf "\nactual 6x6x6 + 24 xterm256-ish bg cmap, structured:\n" for i in $(jot 240 16) do printf "${CSI}48;5;%dmAA" $i if test $((($i - 16) % 36)) = 35; then nl; fi done nl printf "\nactual ansi dull fg colors, linear:\n" unhackbold for i in $(jot 8 30) do printf "$CSI%dm$BL$BL" $i done nl printf "\nactual ansi dull bg colors, linear:\n" for i in $(jot 8 40) do printf "$CSI%dmAA" $i done nl printf "\nactual xterm-ish 16-color fg colors, linear:\n" unhackbold for i in $(jot 8 90) do printf "$CSI%dm$BL$BL" $i done nl printf "\nactual xterm-ish 16-color bg colors, linear:\n" for i in $(jot 8 100) do printf "$CSI%dmAA" $i done nl defcolors
printf '\033[m' printf '\033[x' if false; then for i in $(jot 16 0) do printf '\033[2;%dx' $i ls /var/db echo $i read x done printf '\033[2;6x' # 6 = cyan fg for i in $(jot 16 0) do printf '\033[1;%dx' $i ls /var/db echo $i read x done printf '\033[1;0x' # 0 = black bg for i in $(jot 16 0) do printf '\033[6;%dx' $i ls /var/db echo $i read x done printf '\033[6;7x' # 7 = white rev fg for i in $(jot 16 0) do printf '\033[5;%dx' $i ls /var/db echo $i read x done printf '\033[5;4x' # 4 = blue rev bg fi printf '\033[2;6x' # 6 = cyan fg printf '\033[1;0x' # 0 = black bg printf '\033[6;7x' # 7 = white rev fg printf '\033[5;4x' # 4 = blue rev bg printf '\033[7m' for i in $(jot 256 0) do printf '\033[m' # printf '\033[7m' printf '\033[%dm' $i ls /var/db echo $i read x done
_______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"