# colors

Color is enabled by default. To disable it, use "/color_off"; to re-enable color using ANSI codes, use "/color_on".

The color attribute allows you to specify a foreground color with "Cname" or a background color with "Cbgname". Any terminal that supports color should support the 8 basic colors: black (black), red, green, yellow, blue, magenta, cyan, white (white). (If you are reading this in tf, and the previous sentence did not contain colored words, you do not have working color support. If it contained strange codes, you should do "/color_off" or redefine the codes as described below.) The standard library defines these 8 basic colors with ANSI control codes, which will work on most terminals that support color.

Many terminals also support brighter versions of the 8 basic colors, but may need to be configured to do so. On xterm, you may want to disable the "boldColors" resource so that bold plus a normal color does not produce one of these bright colors. The bright color names are: gray, brightred, brightgreen, brightyellow, brightblue, brightmagenta, brightcyan, or brightwhite. The standard library defines these 8 bright colors with ISO 6429 extension control codes, which will work on most terminals that support 16 colors.

Some newer terminals can display 256 colors. If tf was built with the "256colors" feature, tf will recognize the following additional color names. Names names of the form "rgbR G B" describe a color within a 6x6x6 color cube: R, G and B are each a single digit between 0 and 5 that specifies the brightness of the red, green, or blue component of the color. For example, "rgb020" is a dark green, and "rgb520" is reddish orange. Names of the form "grayN" describe a point on a grayscale, where N is between 0 (dark) and 23 (light). The standard library defines the "rgb*" and "gray*" colors with xterm 256 color extension control codes.

To test the functionality and appearance of colors in tf, you can "`/load testcolor.tf".`

You can use a defined color in any attribute string. For example, to make /hilite'd text appear blue, you can `/set hiliteattr=Cblue`.

To define your own control codes for terminals that don't accept the predefined codes, you will need to edit the color variables. The code to enable foreground or background color name is stored in a variable called %{start_color_name} or %{start_color_bgname}. The code to turn off colors is stored in %{end_color}. These variables may contain carat notation and backslashed ascii codes in decimal, octal, or hexadecimal (e.g., ESC is ^[, \27, \033, or \0x1B).

The default definition of %end_color is `"\033[39;49;0m`", which should work on most ANSI-like terminals. If this does not work on your terminal, then try "`/set end_color \033[30;47;0m`" (for black on white) or "`/set end_color \033[37;40;0m`" (for white on black).

If %{emulation} is set to "ansi_attr" (the default), then ANSI, ISO 6429, and xterm 256 color extension codes sent by the server will be interpreted by tf. As a result, if the %{start_color_name} variables are set correctly for your terminal, tf will translate color codes from the server into codes for your terminal, displaying them correctly even if your terminal does not use the same codes the server sends. See: %emulation.

Note for "screen(1)" users: to make 8-16 colors work under Screen, you need the following screenrc settings:

        termcap  xterm AF=\E[3%dm
        terminfo xterm AF=\E[3%p1%dm
        termcap  xterm AB=\E[4%dm
        terminfo xterm AB=\E[4%p1%dm

To make 256 colors work under Screen, it must have been compiled with "--enable-colors256", and you need the following screenrc settings:

        terminfo xterm Co=256
        termcap  xterm Co=256
        termcap  xterm AF=\E[38;5;%dm
        terminfo xterm AF=\E[38;5;%p1%dm
        termcap  xterm AB=\E[48;5;%dm
        terminfo xterm AB=\E[48;5;%p1%dm

Colors are numbered 0 through 255 in the order in which they are described above, but refering to colors by their enumeration number is generally not recommended, as the numbering is subject to change. In particular, the numbering and interpretation of background colors changed in version 5.0 beta 7.

See: attributes

Back to index
Back to tf home page

Copyright © 1995, 1996, 1997, 1998, 1999, 2002, 2003, 2004, 2005 Ken Keys