Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

199 lignes
7.9 KiB

  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. (http://www.sct.gu.edu.au/~anthony/info/X/Xterm_xf86.terminfo)
  16. setab=\E[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm,
  17. setaf=\E[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm,
  18. These values can be simply retrieved with a tigetstr() call.
  19. o I tested the following terminals:
  20. name $TERM $COLORTERM
  21. ------------------------------------------
  22. Linux console linux
  23. pterm xterm
  24. aterm xterm rxvt-xpm
  25. wterm xterm wterm-xpm
  26. Eterm xterm Eterm
  27. xterm xterm
  28. gnome-terminal xterm
  29. konsole xterm
  30. mlterm mlterm
  31. uxterm xterm
  32. o In most terminals, \e[3xm and \[4xm respectively set the foreground
  33. and background colours. x is a colour between 0 and 7 or the value
  34. 9 for default colour (may be transparent).
  35. \e[0m sets everything to normal, \e[1m sets bold, \e[5m sets blink
  36. and \e[7m sets inverse video.
  37. In ncurses, only 64 colour pairs are created, and A_BOLD (\e[1m) and
  38. A_BLINK (\e[5m) are used for foreground/background colour highlighting,
  39. hence creating 256 possible colour pairs.
  40. Different tests of blue on yellow:
  41. for invert in '' '\e[7m'; do
  42. for blink in '' '\e[5m'; do
  43. for bold in '' '\e[1m'; do
  44. echo -ne "$bold$blink$invert"'\e[33m\e[44m'hop'\e[0m '
  45. echo "($bold$blink$invert)"
  46. done
  47. done
  48. done
  49. Successfully works on:
  50. + Linux console
  51. + pterm
  52. + Eterm
  53. + aterm, wterm, rxvt
  54. Almost works on:
  55. + xterm (bright bg only works when fg is bright and then inverted,
  56. but then fg is not bright)
  57. Fails on:
  58. + mlterm (no bright colours, neither fg nor bg)
  59. + gnome-terminal (no bright bg)
  60. + konsole (no bright bg, $blink really blinks)
  61. o In an XTerm-compatible terminal, \e[9xm sets bright foreground
  62. and \e[10xm bright background colours. Documentation on this can be
  63. found at http://ftp.xfree86.org/pub/XFree86/4.2.1/doc/ctlseqs.TXT .
  64. Unfortunately all terminals don't support these escape sequences. Here
  65. is a testcase:
  66. for fgpre in 3 9; do for fg in 0 4 2 6 1 5 3 7; do
  67. for bgpre in 4 10; do
  68. echo -ne '\e['$fgpre$fg'm'
  69. for bg in 0 4 2 6 1 5 3 7; do echo -ne '\e['$bgpre$bg'm# '; done
  70. echo -ne '\e[0m '
  71. done
  72. echo ''
  73. done; echo ''; done
  74. Successfully tested on:
  75. + gnome-terminal
  76. + konsole
  77. + xterm
  78. + pterm
  79. Failed (\e[9x and \e[10x don't do anything) on:
  80. + Eterm
  81. + aterm, wterm, rxvt
  82. + mlterm
  83. + Linux console
  84. o How to draw bright colours on any terminal?
  85. '\e[93;104m' -> bright yellow on bright blue
  86. doesn't work on mlterm, gnome-terminal, konsole
  87. '\e[5;1;33;44m' -> bright yellow on bright blue
  88. doesn't work on mlterm, aterm/wterm/rxvt, Eterm, console
  89. '\e[5;1;33;44;93;104m' -> bright yellow on bright blue
  90. works on gnome-terminal, xterm, pterm, aterm/wterm/rxvt, console
  91. doesn't work on konsole
  92. o S-Lang:
  93. 256 character pairs are definable, but only 128 can be used. This is
  94. because slsmg.c's This_Color variable uses its 8th bit to indicate an
  95. alternate character set. Replacing a few 0x7F with 0xFF in sldisply.c
  96. works around the problem but gets rid of the alternate charset.
  97. We can work around this problem. See this usage grid:
  98. bg 1 1 1 1 1 1
  99. fg 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
  100. 0 (black) C C C C C C F B c c c c c c F
  101. 1 (blue) A h D h D i f C C h E h E k g
  102. 2 (green) A h D h i D f C h C E h k E g
  103. 3 (cyan) A D D i h h f C E E C k h h g
  104. 4 (red) A h h i D D f C h h k C E E g
  105. 5 (magenta) A D i h D h f C E k h E C h g
  106. 6 (brown) A i D h D h f C k E h E h C g
  107. 7 (light gray) A F a a a a a B C C C C C C B
  108. 8 (dark gray) A C C C C C C B d d d d d d F
  109. 9 (light blue) A C h E h E j C e h D h D l C
  110. 10 (light green) A h C E h j E C e h D h l D C
  111. 11 (light cyan) A E E C j h h C e D D l h h C
  112. 12 (light red) A h h j C E E C e h h l D D C
  113. 13 (light magenta) A E j h E C h C e D l h D h C
  114. 14 (yellow) A j E h E h C C e l D h D h C
  115. 15 (white) A F b b b b b B F C C C C C C
  116. ' ': useless colour pairs that can be emulated by printing a space in
  117. any other colour pair that has the same background
  118. 'A': black background colour pairs that are needed for the old renderer
  119. 'B': gray combinations used for grayscale dithering
  120. 'C': white/light, light/dark, lightgray/light, darkgray/dark, dark/black
  121. combinations often used for saturation/value dithering (the two
  122. other possible combinations, lightgray/dark and darkgray/light, are
  123. not considered here)
  124. 'D': next colour combinations for hue dithering (magenta/blue, blue/green
  125. and so on)
  126. 'E': next colour combinations for hue/value dithering (blue/lightgreen,
  127. green/lightblue and so on)
  128. 'F': black on light gray, black on white, white on dark gray, dark gray
  129. on white, white on blue, light gray on blue (chosen arbitrarily)
  130. 'A': 15 colour pairs
  131. 'A'+'B': 20 colour pairs
  132. 'A'+'B'+'C': 74 colour pairs
  133. 'A'+'B'+'C'+'D': 98 colour pairs
  134. 'A'+'B'+'C'+'D'+'E': 122 colour pairs
  135. 'A'+'B'+'C'+'D'+'E'+'F': 128 colour pairs
  136. The remaining slightly important colour pairs are:
  137. 'a': light gray on dark colour: emulate with light colour on dark colour
  138. 'b': white on dark colour: emulate with light gray on light colour
  139. 'c': black on light colour: emulate with dark gray on dark colour
  140. 'd': dark gray on light colour: emulate with dark colour on light colour
  141. 'e': light colour on dark gray: emulate with dark colour on dark gray
  142. 'f': dark colour on light gray: emulate with light colour on light gray
  143. 'g': dark colour on white: emulate with light colour on white
  144. And now the seldom used pairs:
  145. 'h': 120 degree hue pairs can be emulated as well; for instance blue on
  146. red can be emulated using magenta on red, and blue on green using
  147. cyan on green
  148. And the almost never used pairs:
  149. 'i': dark opposite on dark: emulate with dark opposite on black
  150. 'j': light opposite on dark: emulate with light opposite on black
  151. 'k': dark opposite on light: emulate with black on dark
  152. 'l': light opposite on light: emulate with white on light
  153. o MS-DOS: all bright colours, bright backgrounds, and bright combinations
  154. work using <conio.h>. No need to kludge anything.
  155. o Win32: we use GetConsoleScreenBufferInfo etc. There is an interesting
  156. tutorial here: http://www.adrianxw.dk/SoftwareSite/index.html