You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NOTES 3.9 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. $Id$
  2. o Colour does not work with all backends and all terminals. I tested
  3. many terminal emulators and tried to summarise which combinations
  4. worked properly and which ones did not.
  5. From termcap(5):
  6. set_a_background setab AB Set background
  7. color to #1, using
  8. ANSI escape
  9. set_a_foreground setaf AF Set foreground
  10. color to #1, using
  11. ANSI escape
  12. From the xterm terminfo:
  13. setab=\E[4%p1%dm, setaf=\E[3%p1%dm
  14. From the xterm-16color terminfo:
  15. setab=\E[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm,
  16. setaf=\E[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm,
  17. (http://www.sct.gu.edu.au/~anthony/info/X/Xterm_xf86.terminfo)
  18. o I tested the following terminals:
  19. name $TERM $COLORTERM
  20. ------------------------------------------
  21. Linux console linux
  22. pterm xterm
  23. aterm xterm rxvt-xpm
  24. wterm xterm wterm-xpm
  25. Eterm xterm Eterm
  26. xterm xterm
  27. gnome-terminal xterm
  28. konsole xterm
  29. mlterm mlterm
  30. uxterm xterm
  31. o In most terminals, \e[3xm and \[4xm respectively set the foreground
  32. and background colours. x is a colour between 0 and 7 or the value
  33. 9 for default colour (may be transparent).
  34. \e[0m sets everything to normal, \e[1m sets bold, \e[5m sets blink
  35. and \e[7m sets inverse video.
  36. In ncurses, only 64 colour pairs are created, and A_BOLD (\e[1m) and
  37. A_BLINK (\e[5m) are used for foreground/background colour highlighting,
  38. hence creating 256 possible colour pairs.
  39. Different tests of blue on yellow:
  40. for invert in '' '\e[7m'; do
  41. for blink in '' '\e[5m'; do
  42. for bold in '' '\e[1m'; do
  43. echo -ne "$bold$blink$invert"'\e[33m\e[44m'hop'\e[0m '
  44. echo "($bold$blink$invert)"
  45. done
  46. done
  47. done
  48. Successfully works on:
  49. + Linux console
  50. + pterm
  51. + Eterm
  52. + aterm, wterm, rxvt
  53. Almost works on:
  54. + xterm (bright bg only works when fg is bright and then inverted,
  55. but then fg is not bright)
  56. Fails on:
  57. + mlterm (no bright colours, neither fg nor bg)
  58. + gnome-terminal (no bright bg)
  59. + konsole (no bright bg, $blink really blinks)
  60. o In an XTerm-compatible terminal, \e[9xm sets bright foreground and
  61. \e[10xm bright background colours. Unfortunately all terminals don't
  62. support these escape sequences. Here is a testcase:
  63. for fgpre in 3 9; do for fg in 0 4 2 6 1 5 3 7; do
  64. for bgpre in 4 10; do
  65. echo -ne '\e['$fgpre$fg'm'
  66. for bg in 0 4 2 6 1 5 3 7; do echo -ne '\e['$bgpre$bg'm# '; done
  67. echo -ne '\e[0m '
  68. done
  69. echo ''
  70. done; echo ''; done
  71. Successfully tested on:
  72. + gnome-terminal
  73. + konsole
  74. + xterm
  75. + pterm
  76. Failed (\e[9x and \e[10x don't do anything) on:
  77. + Eterm
  78. + aterm, wterm, rxvt
  79. + mlterm
  80. + Linux console
  81. o How to draw bright colours on any terminal?
  82. '\e[93;104m' -> bright yellow on bright blue
  83. doesn't work on mlterm, gnome-terminal, konsole
  84. '\e[5;1;33;44m' -> bright yellow on bright blue
  85. doesn't work on mlterm, aterm/wterm/rxvt, Eterm, console
  86. '\e[5;1;33;44;93;104m' -> bright yellow on bright blue
  87. works on gnome-terminal, xterm, pterm, aterm/wterm/rxvt, console
  88. doesn't work on konsole
  89. o S-Lang:
  90. o MS-DOS: all bright colours, bright backgrounds, and bright combinations
  91. work using <conio.h>. No need to kludge anything.