NAME

tputs - Format output to the terminal.

SYNOPSIS

tputs ?switches? ?channelId? string

tputs_getFlag ?switches? string

tputs_getNum ?switches? string

tputs_getStr ?switches? string

DESCRIPTION

All of these functions perform similar lookups to get terminal codes from a common database. For more information on these capabilities, see the man page “termcap”. The functions differ only in their output, whereas tputs will pass its output as input to the puts command, and tputs_getXXX will return the output as a string. All codes are indicated by a “Begin Code” char and an “End Code” char, which may be configured (default < and >, respectively). tputs_getFlag will do a boolean-capability lookup; tputs_getNum will do a numeric-capability lookup; and tputs_getStr will do a string-capability lookup, and, if failing, will try a numeric capability lookup. The reason for not trying a boolean-capability lookup is, that it will return 0 if not available, hence not knowing whether the capability is recognized or not. tputs acts with codes as tputs_getStr.

tputs sends its output as input to the puts command, hence a channelId maybe specified, as long with the -nonewline switch. These parameters will be checked by the puts command.

Parameters may be passed to string codes via commas, for example the command
tputs “<cm,5,2>”
sends the parameters 5 and 2 to the cursor-modify command, which in turn changes the cursor position to row 5 column 2 (if the terminal supports this capability).

To output the “Begin Code” char, one must prepend it with an extra //. The first one is to tell the TCL interpreter to pass the next char as is. The second one will be passed to the .c library routine. An “End Code” char without a “Begin Code” char will be output as is. If the code isn’t recognized, it will return as text; If the code is recognized but the capability is unavailable, it will simply be stripped off. Hence, a call like this:

tputs <NoCodeAvailable>junk

will output to the terminal:

<NoCodeAvailable>junk

whereas a call to the half-bright mode on a terminal where it is unavailable, like this:

tputs <mh>junk<me>

will output to the terminal:

junk

Switches:

-formaton - Turns formatting on. This is the default state, and will persist to next calls to the library routines.

-formatoff - Turns formatting off. This means that control chars will not be output, but neither will the terminal codes, hence only plain text will be output. This is similar to using unavailable capabilities.

-noformat - Turns formatting off for this call alone, not persisting to later calls.

-exact - Outputs the string as is, including control codes. With tputs, this is the same as calling the puts command.

-controlchars BeginCodeEndCode - specify a new set of begin and end code characters. Both characters must be supplied, not separated (i.e. as a single parameter)

-controlcharsdef - Restore default control character settings (< and >).

-- - Signal end of switches (in case string begins with a ‘-‘ character).

EXAMPLES

Following are examples of commands (preceded by a “% “), and their output:

tputs “<md>Warning:<me> unsafe action.”
Warning: unsafe action.

tputs -noformat “<md>Warning:<me> unsafe action.”
Warning: unsafe action.

tputs -exact “<md>Warning:<me> unsafe action.”
<md>Warning:<me> unsafe action.

tputs -controlchars ()“(md)Warning(me) unsafe action.”
Warning: unsafe action.

tputs “<md>Warning:<me> unsafe char <”
Warning: unsafe char <