]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/tset.1
ncurses 6.4 - patch 20231217
[ncurses.git] / man / tset.1
1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 Thomas E. Dickey                                *
3 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
6 .\" copy of this software and associated documentation files (the            *
7 .\" "Software"), to deal in the Software without restriction, including      *
8 .\" without limitation the rights to use, copy, modify, merge, publish,      *
9 .\" distribute, distribute with modifications, sublicense, and/or sell       *
10 .\" copies of the Software, and to permit persons to whom the Software is    *
11 .\" furnished to do so, subject to the following conditions:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23 .\"                                                                          *
24 .\" Except as contained in this notice, the name(s) of the above copyright   *
25 .\" holders shall not be used in advertising or otherwise to promote the     *
26 .\" sale, use or other dealings in this Software without prior written       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: tset.1,v 1.78 2023/12/16 20:32:22 tom Exp $
31 .TH @TSET@ 1 2023-12-16 "ncurses 6.4" "User commands"
32 .ie \n(.g \{\
33 .ds `` \(lq
34 .ds '' \(rq
35 .ds ^  \(ha
36 .\}
37 .el \{\
38 .ie t .ds `` ``
39 .el   .ds `` ""
40 .ie t .ds '' ''
41 .el   .ds '' ""
42 .ds       ^  ^
43 .\}
44 .
45 .de bP
46 .ie n  .IP \(bu 4
47 .el    .IP \(bu 2
48 ..
49 .
50 .ds d @TERMINFO@
51 .SH NAME
52 \fB\%@TSET@\fP,
53 \fB\%@RESET@\fP \-
54 initialize or reset terminal state
55 .SH SYNOPSIS
56 \fB@TSET@\fP [\fB\-IQVcqrsw\fP] [\fB\-\fP] [\fB\-e\fP \fIch\fP] [\fB\-i\fP \fIch\fP] [\fB\-k\fP \fIch\fP] [\fB\-m\fP \fImapping\fP] [\fIterminal-type\fP]
57 .br
58 \fB@RESET@\fP [\fB\-IQVcqrsw\fP] [\fB\-\fP] [\fB\-e\fP \fIch\fP] [\fB\-i\fP \fIch\fP] [\fB\-k\fP \fIch\fP] [\fB\-m\fP \fImapping\fP] [\fIterminal-type\fP]
59 .SH DESCRIPTION
60 .SS tset - initialization
61 This program initializes terminals.
62 .PP
63 First, \fB@TSET@\fP retrieves the current terminal mode settings
64 for your terminal.
65 It does this by successively testing
66 .bP
67 the standard error,
68 .bP
69 standard output,
70 .bP
71 standard input and
72 .bP
73 ultimately \*(``/dev/tty\*(''
74 .PP
75 to obtain terminal settings.
76 Having retrieved these settings, \fB@TSET@\fP remembers which
77 file descriptor to use when updating settings.
78 .PP
79 Next, \fB@TSET@\fP determines the type of terminal that you are using.
80 This determination is done as follows, using the first terminal type found.
81 .PP
82 1. The \fBterminal\fP argument specified on the command line.
83 .PP
84 2. The value of the \fITERM\fP environmental variable.
85 .PP
86 3. (BSD systems only.) The terminal type associated with the standard
87 error output device in the \fI/etc/ttys\fP file.
88 (On System\ V hosts and systems using that convention,
89 \fBgetty\fP(1) does this job by setting
90 \fITERM\fP according to the type passed to it by \fI\%/etc/inittab\fP.)
91 .PP
92 4. The default terminal type, \*(``unknown\*('',
93 is not suitable for curses applications.
94 .PP
95 If the terminal type was not specified on the command-line, the \fB\-m\fP
96 option mappings are then applied;
97 see subsection \*(``Terminal Type Mapping\*(''.
98 Then, if the terminal type begins with a question mark (\*(``?\*(''), the
99 user is prompted for confirmation of the terminal type.
100 An empty
101 response confirms the type, or, another type can be entered to specify
102 a new type.
103 Once the terminal type has been determined,
104 the terminal description for the terminal is retrieved.
105 If no terminal description is found
106 for the type, the user is prompted for another terminal type.
107 .PP
108 Once the terminal description is retrieved,
109 .bP
110 if the \*(``\fB\-w\fP\*('' option is enabled, \fB@TSET@\fP may update
111 the terminal's window size.
112 .IP
113 If the window size cannot be obtained from the operating system,
114 but the terminal description
115 (or environment,
116 e.g.,
117 \fILINES\fP and \fI\%COLUMNS\fP variables specify this),
118 use this to set the operating system's notion of the window size.
119 .bP
120 if the \*(``\fB\-c\fP\*('' option is enabled,
121 the backspace, interrupt and line kill characters
122 (among many other things) are set
123 .bP
124 unless the \*(``\fB\-I\fP\*('' option is enabled,
125 the terminal
126 and tab \fIinitialization\fP strings are sent to the standard error output,
127 and \fB@TSET@\fP waits one second (in case a hardware reset was issued).
128 .bP
129 Finally, if the erase, interrupt and line kill characters have changed,
130 or are not set to their default values, their values are displayed to the
131 standard error output.
132 .SS reset - reinitialization
133 When invoked as \fB@RESET@\fP, \fB@TSET@\fP sets the terminal
134 modes to \*(``sane\*('' values:
135 .bP
136 sets cooked and echo modes,
137 .bP
138 turns off cbreak and raw modes,
139 .bP
140 turns on newline translation and
141 .bP
142 resets any unset special characters to their default values
143 .PP
144 before
145 doing the terminal initialization described above.
146 Also, rather than using the terminal \fIinitialization\fP strings,
147 it uses the terminal \fIreset\fP strings.
148 .PP
149 The \fB@RESET@\fP command is useful
150 after a program dies leaving a terminal in an abnormal state:
151 .bP
152 you may have to type
153 .sp
154     \fI<LF>\fB@RESET@\fI<LF>\fR
155 .sp
156 (the line-feed character is normally control-J) to get the terminal
157 to work, as carriage-return may no longer work in the abnormal state.
158 .bP
159 Also, the terminal will often not echo the command.
160 .SS "Setting the Environment"
161 It is often desirable to enter the terminal type and information about
162 the terminal's capabilities into the shell's environment.
163 This is done using the \fB\-s\fP option.
164 .PP
165 When the \fB\-s\fP option is specified, the commands to enter the information
166 into the shell's environment are written to the standard output.
167 If the \fISHELL\fP environmental variable ends in \*(``csh\*('',
168 the commands
169 are for \fBcsh\fP, otherwise, they are for \fBsh\fP(1).
170 Note, the \fBcsh\fP commands set and unset the shell variable
171 \fBnoglob\fP, leaving it unset.
172 The following line in the \fB.login\fP
173 or \fB.profile\fP files will initialize the environment correctly:
174 .sp
175     eval \(ga@TSET@ \-s options ... \(ga
176 .
177 .SS "Terminal Type Mapping"
178 When the terminal is not hardwired into the system (or the current
179 system information is incorrect) the terminal type derived from the
180 \fI/etc/ttys\fP file or the \fITERM\fP environmental variable is often
181 something generic like \fBnetwork\fP, \fBdialup\fP, or \fBunknown\fP.
182 When \fB@TSET@\fP is used in a startup script it is often desirable to
183 provide information about the type of terminal used on such ports.
184 .PP
185 The \fB\-m\fP options maps
186 from some set of conditions to a terminal type, that is, to
187 tell \fB@TSET@\fP
188 \*(``If I'm on this port at a particular speed,
189 guess that I'm on that kind of terminal\*(''.
190 .PP
191 The argument to the \fB\-m\fP option consists of an optional port type, an
192 optional operator, an optional baud rate specification, an optional
193 colon (\*(``:\*('') character and a terminal type.
194 The port type is a
195 string (delimited by either the operator or the colon character).
196 The operator may be any combination of
197 \*(``>\*('',
198 \*(``<\*('',
199 \*(``@\*('',
200 and \*(``!\*('';
201 \*(``>\*('' means greater than,
202 \*(``<\*('' means less than,
203 \*(``@\*('' means equal to and
204 \*(``!\*('' inverts the sense of the test.
205 The baud rate is specified as a number and is compared with the speed
206 of the standard error output (which should be the control terminal).
207 The terminal type is a string.
208 .PP
209 If the terminal type is not specified on the command line, the \fB\-m\fP
210 mappings are applied to the terminal type.
211 If the port type and baud
212 rate match the mapping, the terminal type specified in the mapping
213 replaces the current type.
214 If more than one mapping is specified, the
215 first applicable mapping is used.
216 .PP
217 For example, consider the following mapping: \fBdialup>9600:vt100\fP.
218 The port type is dialup , the operator is >, the baud rate
219 specification is 9600, and the terminal type is vt100.
220 The result of
221 this mapping is to specify that if the terminal type is \fBdialup\fP,
222 and the baud rate is greater than 9600 baud, a terminal type of
223 \fBvt100\fP will be used.
224 .PP
225 If no baud rate is specified, the terminal type will match any baud rate.
226 If no port type is specified, the terminal type will match any port type.
227 For example, \fB\-m dialup:vt100 \-m :?xterm\fP
228 will cause any dialup port, regardless of baud rate, to match the terminal
229 type vt100, and any non-dialup port type to match the terminal type ?xterm.
230 Note, because of the leading question mark, the user will be
231 queried on a default port as to whether they are actually using an xterm
232 terminal.
233 .PP
234 No whitespace characters are permitted in the \fB\-m\fP option argument.
235 Also, to avoid problems with meta-characters, it is suggested that the
236 entire \fB\-m\fP option argument be placed within single quote characters,
237 and that \fBcsh\fP users insert a backslash character (\*(``\e\*('') before
238 any exclamation marks (\*(``!\*('').
239 .SH OPTIONS
240 The options are as follows:
241 .TP 5
242 .B \-c
243 Set control characters and modes.
244 .TP 5
245 .BI \-e\  ch
246 Set the erase character to \fIch\fP.
247 .TP
248 .B \-I
249 Do not send the terminal or tab initialization strings to the terminal.
250 .TP
251 .BI \-i\  ch
252 Set the interrupt character to \fIch\fP.
253 .TP
254 .BI \-k\  ch
255 Set the line kill character to \fIch\fP.
256 .TP
257 .BI \-m\  mapping
258 Specify a mapping from a port type to a terminal;
259 see subsection \*(``Terminal Type Mapping\*(''.
260 .TP
261 .B \-Q
262 Do not display any values for the erase, interrupt and line kill characters.
263 Normally \fB@TSET@\fP displays the values for control characters which
264 differ from the system's default values.
265 .TP
266 .B \-q
267 The terminal type is displayed to the standard output, and the terminal is
268 not initialized in any way.
269 The option \*(``\-\*('' by itself is equivalent but archaic.
270 .TP
271 .B \-r
272 Print the terminal type to the standard error output.
273 .TP
274 .B \-s
275 Print the sequence of shell commands to initialize the environment variable
276 \fITERM\fP to the standard output;
277 see subsection \*(``Setting the Environment\*(''.
278 .TP
279 .B \-V
280 reports the version of \fI\%ncurses\fP which was used in this program,
281 and exits.
282 .TP
283 .B \-w
284 Resize the window to match the size deduced via \fBsetupterm\fP(3X).
285 Normally this has no effect,
286 unless \fBsetupterm\fP is not able to detect the window size.
287 .PP
288 The arguments for the \fB\-e\fP, \fB\-i\fP, and \fB\-k\fP
289 options may either be entered as actual characters
290 or by using the \*(``hat\*(''
291 notation, i.e., control-h may be specified as \*(``\*^H\*('' or \*(``\*^h\*(''.
292 .PP
293 If neither \fB\-c\fP or \fB\-w\fP is given, both options are assumed.
294 .SH ENVIRONMENT
295 The \fB@TSET@\fP command uses these environment variables:
296 .TP 5
297 .I SHELL
298 tells \fB@TSET@\fP whether to initialize \fITERM\fP using \fBsh\fP(1) or
299 \fBcsh\fP(1) syntax.
300 .TP 5
301 .I TERM
302 Denotes your terminal type.
303 Each terminal type is distinct, though many are similar.
304 .TP 5
305 .I TERMCAP
306 may denote the location of a termcap database.
307 If it is not an absolute pathname, e.g., begins with a \*(``/\*('',
308 \fB@TSET@\fP removes the variable from the environment before looking
309 for the terminal description.
310 .SH FILES
311 .TP
312 .I /etc/ttys
313 system port name to terminal type mapping database (BSD versions only).
314 .TP
315 .I \*d
316 compiled terminal description database directory
317 .SH PORTABILITY
318 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
319 (POSIX.1-2008) nor
320 X/Open Curses Issue 7 documents \fB@TSET@\fP or \fB@RESET@\fP.
321 .PP
322 The AT&T \fBtput\fP utility (AIX, HP-UX, Solaris)
323 incorporated the terminal-mode manipulation as well as termcap-based features
324 such as resetting tabstops from \fBtset\fP in BSD (4.1c),
325 presumably with the intention of making \fBtset\fP obsolete.
326 However, each of those systems still provides \fBtset\fP.
327 In fact, the commonly-used \fBreset\fP utility
328 is always an alias for \fBtset\fP.
329 .PP
330 The \fB\%@TSET@\fP utility provides backward compatibility with BSD
331 environments;
332 under most modern Unices,
333 \fI\%/etc/inittab\fP and \fBgetty\fP(1) can set \fITERM\fP appropriately
334 for each dial-up line,
335 obviating what was \fB\%@TSET@\fP's most important use.
336 This implementation behaves like 4.4BSD \fBtset\fP,
337 with a few exceptions we shall consider now.
338 .PP
339 A few options are different
340 because the \fI\%TERMCAP\fP variable
341 is no longer supported under terminfo-based \fI\%ncurses\fP:
342 .bP
343 The \fB\-S\fP option of BSD \fBtset\fP no longer works;
344 it prints an error message to the standard error and dies.
345 .bP
346 The \fB\-s\fP option only sets \fITERM\fP,
347 not \fI\%TERMCAP\fP.
348 .PP
349 There was an undocumented 4.4BSD feature
350 that invoking \fBtset\fP via a link named
351 \*(``TSET\*('' (or via any other name beginning with an upper-case letter)
352 set the terminal to use upper-case only.
353 This feature has been omitted.
354 .PP
355 The \fB\-A\fP, \fB\-E\fP, \fB\-h\fP, \fB\-u\fP and \fB\-v\fP
356 options were deleted from the \fB@TSET@\fP
357 utility in 4.4BSD.
358 None of them were documented in 4.3BSD and all are
359 of limited utility at best.
360 The \fB\-a\fP, \fB\-d\fP, and \fB\-p\fP options are similarly
361 not documented or useful, but were retained as they appear to be in
362 widespread use.
363 It is strongly recommended that any usage of these
364 three options be changed to use the \fB\-m\fP option instead.
365 The \fB\-a\fP, \fB\-d\fP, and \fB\-p\fP options
366 are therefore omitted from the usage summary above.
367 .PP
368 Very old systems, e.g., 3BSD, used a different terminal driver which
369 was replaced in 4BSD in the early 1980s.
370 To accommodate these older systems, the 4BSD \fB@TSET@\fP provided a
371 \fB\-n\fP option to specify that the new terminal driver should be used.
372 This implementation does not provide that choice.
373 .PP
374 It is still permissible to specify the \fB\-e\fP, \fB\-i\fP,
375 and \fB\-k\fP options without arguments,
376 although it is strongly recommended that such usage be fixed to
377 explicitly specify the character.
378 .PP
379 As of 4.4BSD,
380 executing \fB@TSET@\fP as \fB@RESET@\fP no longer implies the \fB\-Q\fP option.
381 Also, the interaction between the \- option and the \fIterminal\fP
382 argument in some historic implementations of \fB@TSET@\fP has been removed.
383 .PP
384 The \fB\-c\fP and \fB\-w\fP options are not found in earlier implementations.
385 However, a different window size-change feature was provided in 4.4BSD.
386 .bP
387 In 4.4BSD, \fBtset\fP uses the window size from the termcap description
388 to set the window size if \fBtset\fP is not able to obtain the window
389 size from the operating system.
390 .bP
391 In \fI\%ncurses\fP, \fB@TSET@\fP obtains the window size using
392 \fBsetupterm\fP, which may be from
393 the operating system,
394 the \fILINES\fP and \fICOLUMNS\fP environment variables or
395 the terminal description.
396 .PP
397 Obtaining the window size from the terminal description is common to
398 both implementations, but considered obsolescent.
399 Its only practical use is for hardware terminals.
400 Generally speaking, a window size would be unset only if there were
401 some problem obtaining the value from the operating system
402 (and \fBsetupterm\fP would still fail).
403 For that reason,
404 the \fILINES\fP and \fI\%COLUMNS\fP environment variables
405 may be useful for working around window-size problems.
406 Those have the drawback that if the window is resized,
407 those variables must be recomputed and reassigned.
408 To do this more easily, use the \fBresize\fP(1) program.
409 .SH HISTORY
410 A \fB\%reset\fP command written by Kurt Shoens appeared in 1BSD
411 (March 1978).
412 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/s6/reset.c
413 It set the \fIerase\fP and \fIkill\fP characters
414 to \fB\*^H\fP (backspace) and \fB@\fP respectively.
415 Mark Horton improved this \fB\%reset\fP in 3BSD
416 (October 1979),
417 adding \fIintr\fP,
418 \fIquit\fP,
419 \fIstart\fP/\fIstop\fP,
420 and \fIeof\fP
421 characters as well as changing the program to avoid modifying any user
422 settings.
423 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/src/cmd/\
424 .\"   reset.c
425 That version of \fB\%reset\fP did not use \fI\%termcap\fP.
426 .PP
427 Eric Allman wrote a distinct \fBtset\fP command for 1BSD,
428 using a forerunner of \fI\%termcap\fP called \fI\%ttycap\fP.
429 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/s6/tset.c
430 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/man7/ttycap.7
431 Allman's comments in the source code indicate
432 that he began work in October 1977,
433 continuing development over the next few years.
434 By late 1979,
435 it had migrated to \fI\%termcap\fP and handled the \fI\%TERMCAP\fP
436 variable.
437 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/src/cmd/\
438 .\"   tset/tset.c
439 Later comments indicate that \fBtset\fP was modified in September 1980
440 to use logic copied from the 3BSD \*(``reset\*('' program when it was
441 invoked as \fB\%reset\fP.
442 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=2.9BSD/usr/src/ucb/\
443 .\"   tset/tset.c
444 This version appeared in 4.1cBSD, \" and backported to 2.9BSD
445 late in 1982.
446 Other developers such as Keith Bostic and Jim Bloom continued to modify
447 \fBtset\fP until 4.4BSD was released in 1993.
448 .PP
449 The \fI\%ncurses\fP implementation was lightly adapted from the 4.4BSD
450 sources to use the \fI\%terminfo\fP API by Eric S.\& Raymond
451 <esr@snark.thyrsus.com>.
452 .SH SEE ALSO
453 \fB\%csh\fP(1),
454 \fB\%sh\fP(1),
455 \fB\%stty\fP(1),
456 \fB\%curs_terminfo\fP(3X),
457 \fB\%tty\fP(4),
458 \fB\%terminfo\fP(5),
459 \fB\%ttys\fP(5),
460 \fB\%environ\fP(7)