]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/tset.1
ncurses 6.4 - patch 20231014
[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.73 2023/10/14 19:24:28 tom Exp $
31 .TH @TSET@ 1 2023-10-14 "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\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\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 \fBTERM\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-like UNIXes and systems using that convention,
89 \fBgetty\fP(1) does this job by setting
90 \fBTERM\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 (see the section
97 .B TERMINAL TYPE MAPPING
98 for more information).
99 Then, if the terminal type begins with a question mark (\*(``?\*(''), the
100 user is prompted for confirmation of the terminal type.
101 An empty
102 response confirms the type, or, another type can be entered to specify
103 a new type.
104 Once the terminal type has been determined,
105 the terminal description for the terminal is retrieved.
106 If no terminal description is found
107 for the type, the user is prompted for another terminal type.
108 .PP
109 Once the terminal description is retrieved,
110 .bP
111 if the \*(``\fB\-w\fP\*('' option is enabled, \fB@TSET@\fP may update
112 the terminal's window size.
113 .IP
114 If the window size cannot be obtained from the operating system,
115 but the terminal description (or environment, e.g., \fBLINES\fP
116 and \fBCOLUMNS\fP variables specify this),
117 use this to set the operating system's notion of the window size.
118 .bP
119 if the \*(``\fB\-c\fP\*('' option is enabled,
120 the backspace, interrupt and line kill characters
121 (among many other things) are set
122 .bP
123 unless the \*(``\fB\-I\fP\*('' option is enabled,
124 the terminal
125 and tab \fIinitialization\fP strings are sent to the standard error output,
126 and \fB@TSET@\fP waits one second (in case a hardware reset was issued).
127 .bP
128 Finally, if the erase, interrupt and line kill characters have changed,
129 or are not set to their default values, their values are displayed to the
130 standard error output.
131 .SS reset - reinitialization
132 When invoked as \fB@RESET@\fP, \fB@TSET@\fP sets the terminal
133 modes to \*(``sane\*('' values:
134 .bP
135 sets cooked and echo modes,
136 .bP
137 turns off cbreak and raw modes,
138 .bP
139 turns on newline translation and
140 .bP
141 resets any unset special characters to their default values
142 .PP
143 before
144 doing the terminal initialization described above.
145 Also, rather than using the terminal \fIinitialization\fP strings,
146 it uses the terminal \fIreset\fP strings.
147 .PP
148 The \fB@RESET@\fP command is useful
149 after a program dies leaving a terminal in an abnormal state:
150 .bP
151 you may have to type
152 .sp
153     \fI<LF>\fB@RESET@\fI<LF>\fR
154 .sp
155 (the line-feed character is normally control-J) to get the terminal
156 to work, as carriage-return may no longer work in the abnormal state.
157 .bP
158 Also, the terminal will often not echo the command.
159 .SH OPTIONS
160 The options are as follows:
161 .TP 5
162 .B \-c
163 Set control characters and modes.
164 .TP 5
165 .BI \-e\  ch
166 Set the erase character to \fIch\fP.
167 .TP
168 .B \-I
169 Do not send the terminal or tab initialization strings to the terminal.
170 .TP
171 .BI \-i\  ch
172 Set the interrupt character to \fIch\fP.
173 .TP
174 .BI \-k\  ch
175 Set the line kill character to \fIch\fP.
176 .TP
177 .BI \-m\  mapping
178 Specify a mapping from a port type to a terminal.
179 See the section
180 .B TERMINAL TYPE MAPPING
181 for more information.
182 .TP
183 .B \-Q
184 Do not display any values for the erase, interrupt and line kill characters.
185 Normally \fB@TSET@\fP displays the values for control characters which
186 differ from the system's default values.
187 .TP
188 .B \-q
189 The terminal type is displayed to the standard output, and the terminal is
190 not initialized in any way.
191 The option \*(``\-\*('' by itself is equivalent but archaic.
192 .TP
193 .B \-r
194 Print the terminal type to the standard error output.
195 .TP
196 .B \-s
197 Print the sequence of shell commands to initialize the environment variable
198 \fBTERM\fP to the standard output.
199 See the section
200 .B SETTING THE ENVIRONMENT
201 for details.
202 .TP
203 .B \-V
204 reports the version of ncurses which was used in this program, and exits.
205 .TP
206 .B \-w
207 Resize the window to match the size deduced via \fBsetupterm\fP(3X).
208 Normally this has no effect,
209 unless \fBsetupterm\fP is not able to detect the window size.
210 .PP
211 The arguments for the \fB\-e\fP, \fB\-i\fP, and \fB\-k\fP
212 options may either be entered as actual characters
213 or by using the \*(``hat\*(''
214 notation, i.e., control-h may be specified as \*(``\*^H\*('' or \*(``\*^h\*(''.
215 .PP
216 If neither \fB\-c\fP or \fB\-w\fP is given, both options are assumed.
217 .
218 .SH SETTING THE ENVIRONMENT
219 It is often desirable to enter the terminal type and information about
220 the terminal's capabilities into the shell's environment.
221 This is done using the \fB\-s\fP option.
222 .PP
223 When the \fB\-s\fP option is specified, the commands to enter the information
224 into the shell's environment are written to the standard output.
225 If
226 the \fBSHELL\fP environmental variable ends in \*(``csh\*('', the commands
227 are for \fBcsh\fP, otherwise, they are for \fBsh\fP(1).
228 Note, the \fBcsh\fP commands set and unset the shell variable
229 \fBnoglob\fP, leaving it unset.
230 The following line in the \fB.login\fP
231 or \fB.profile\fP files will initialize the environment correctly:
232 .sp
233     eval \(ga@TSET@ \-s options ... \(ga
234 .
235 .SH TERMINAL TYPE MAPPING
236 When the terminal is not hardwired into the system (or the current
237 system information is incorrect) the terminal type derived from the
238 \fI/etc/ttys\fP file or the \fBTERM\fP environmental variable is often
239 something generic like \fBnetwork\fP, \fBdialup\fP, or \fBunknown\fP.
240 When \fB@TSET@\fP is used in a startup script it is often desirable to
241 provide information about the type of terminal used on such ports.
242 .PP
243 The \fB\-m\fP options maps
244 from some set of conditions to a terminal type, that is, to
245 tell \fB@TSET@\fP
246 \*(``If I'm on this port at a particular speed,
247 guess that I'm on that kind of terminal\*(''.
248 .PP
249 The argument to the \fB\-m\fP option consists of an optional port type, an
250 optional operator, an optional baud rate specification, an optional
251 colon (\*(``:\*('') character and a terminal type.
252 The port type is a
253 string (delimited by either the operator or the colon character).
254 The operator may be any combination of
255 \*(``>\*('',
256 \*(``<\*('',
257 \*(``@\*('',
258 and \*(``!\*('';
259 \*(``>\*('' means greater than,
260 \*(``<\*('' means less than,
261 \*(``@\*('' means equal to and
262 \*(``!\*('' inverts the sense of the test.
263 The baud rate is specified as a number and is compared with the speed
264 of the standard error output (which should be the control terminal).
265 The terminal type is a string.
266 .PP
267 If the terminal type is not specified on the command line, the \fB\-m\fP
268 mappings are applied to the terminal type.
269 If the port type and baud
270 rate match the mapping, the terminal type specified in the mapping
271 replaces the current type.
272 If more than one mapping is specified, the
273 first applicable mapping is used.
274 .PP
275 For example, consider the following mapping: \fBdialup>9600:vt100\fP.
276 The port type is dialup , the operator is >, the baud rate
277 specification is 9600, and the terminal type is vt100.
278 The result of
279 this mapping is to specify that if the terminal type is \fBdialup\fP,
280 and the baud rate is greater than 9600 baud, a terminal type of
281 \fBvt100\fP will be used.
282 .PP
283 If no baud rate is specified, the terminal type will match any baud rate.
284 If no port type is specified, the terminal type will match any port type.
285 For example, \fB\-m dialup:vt100 \-m :?xterm\fP
286 will cause any dialup port, regardless of baud rate, to match the terminal
287 type vt100, and any non-dialup port type to match the terminal type ?xterm.
288 Note, because of the leading question mark, the user will be
289 queried on a default port as to whether they are actually using an xterm
290 terminal.
291 .PP
292 No whitespace characters are permitted in the \fB\-m\fP option argument.
293 Also, to avoid problems with meta-characters, it is suggested that the
294 entire \fB\-m\fP option argument be placed within single quote characters,
295 and that \fBcsh\fP users insert a backslash character (\*(``\e\*('') before
296 any exclamation marks (\*(``!\*('').
297 .SH HISTORY
298 A \fBreset\fP command appeared in 1BSD (March 1978), written by Kurt Shoens.
299 This program set the \fIerase\fP and \fIkill\fP characters
300 to \fB\*^H\fP (backspace) and \fB@\fP respectively.
301 Mark Horton improved that in 3BSD (October 1979), adding
302 \fIintr\fP, \fIquit\fP, \fIstart\fP/\fIstop\fP and \fIeof\fP characters
303 as well as changing the program to avoid modifying any user settings.
304 That version of \fBreset\fP did not use the termcap database.
305 .PP
306 A separate \fBtset\fP command was provided in 1BSD by Eric Allman,
307 using the termcap database.
308 Allman's comments in the source code indicate
309 that he began work in October 1977,
310 continuing development over the next few years.
311 .PP
312 According to comments in the source code,
313 the \fBtset\fP program was modified in September 1980,
314 to use logic copied from the 3BSD \*(``reset\*(''
315 when it was invoked as \fBreset\fP.
316 This version appeared in 4.1cBSD, late in 1982.
317 .PP
318 Other developers (e.g., Keith Bostic and Jim Bloom)
319 continued to modify \fBtset\fP until 4.4BSD was released in 1993.
320 .PP
321 The \fBncurses\fP implementation
322 was lightly adapted from the 4.4BSD sources for a terminfo environment by Eric
323 S. Raymond <esr@snark.thyrsus.com>.
324 .SH COMPATIBILITY
325 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
326 (POSIX.1-2008) nor
327 X/Open Curses Issue 7 documents \fB@TSET@\fP or \fB@RESET@\fP.
328 .PP
329 The AT&T \fBtput\fP utility (AIX, HPUX, Solaris)
330 incorporated the terminal-mode manipulation as well as termcap-based features
331 such as resetting tabstops from \fBtset\fP in BSD (4.1c),
332 presumably with the intention of making \fBtset\fP obsolete.
333 However, each of those systems still provides \fBtset\fP.
334 In fact, the commonly-used \fBreset\fP utility
335 is always an alias for \fBtset\fP.
336 .PP
337 The \fB@TSET@\fP utility provides for backward-compatibility with BSD
338 environments (under most modern UNIXes, \fB/etc/inittab\fP and \fBgetty\fP(1)
339 can set \fBTERM\fP appropriately for each dial-up line; this obviates what was
340 \fB@TSET@\fP's most important use).
341 This implementation behaves like 4.4BSD
342 \fBtset\fP, with a few exceptions specified here.
343 .PP
344 A few options are different
345 because the \fBTERMCAP\fP variable
346 is no longer supported under terminfo-based \fBncurses\fP:
347 .bP
348 The \fB\-S\fP option of BSD \fBtset\fP no longer works;
349 it prints an error message to the standard error and dies.
350 .bP
351 The \fB\-s\fP option only sets \fBTERM\fP, not \fBTERMCAP\fP.
352 .PP
353 There was an undocumented 4.4BSD feature
354 that invoking \fBtset\fP via a link named
355 \*(``TSET\*('' (or via any other name beginning with an upper-case letter)
356 set the terminal to use upper-case only.
357 This feature has been omitted.
358 .PP
359 The \fB\-A\fP, \fB\-E\fP, \fB\-h\fP, \fB\-u\fP and \fB\-v\fP
360 options were deleted from the \fB@TSET@\fP
361 utility in 4.4BSD.
362 None of them were documented in 4.3BSD and all are
363 of limited utility at best.
364 The \fB\-a\fP, \fB\-d\fP, and \fB\-p\fP options are similarly
365 not documented or useful, but were retained as they appear to be in
366 widespread use.
367 It is strongly recommended that any usage of these
368 three options be changed to use the \fB\-m\fP option instead.
369 The \fB\-a\fP, \fB\-d\fP, and \fB\-p\fP options
370 are therefore omitted from the usage summary above.
371 .PP
372 Very old systems, e.g., 3BSD, used a different terminal driver which
373 was replaced in 4BSD in the early 1980s.
374 To accommodate these older systems, the 4BSD \fB@TSET@\fP provided a
375 \fB\-n\fP option to specify that the new terminal driver should be used.
376 This implementation does not provide that choice.
377 .PP
378 It is still permissible to specify the \fB\-e\fP, \fB\-i\fP,
379 and \fB\-k\fP options without arguments,
380 although it is strongly recommended that such usage be fixed to
381 explicitly specify the character.
382 .PP
383 As of 4.4BSD,
384 executing \fB@TSET@\fP as \fB@RESET@\fP no longer implies the \fB\-Q\fP option.
385 Also, the interaction between the \- option and the \fIterminal\fP
386 argument in some historic implementations of \fB@TSET@\fP has been removed.
387 .PP
388 The \fB\-c\fP and \fB\-w\fP options are not found in earlier implementations.
389 However, a different window size-change feature was provided in 4.4BSD.
390 .bP
391 In 4.4BSD, \fBtset\fP uses the window size from the termcap description
392 to set the window size if \fBtset\fP is not able to obtain the window
393 size from the operating system.
394 .bP
395 In ncurses, \fB@TSET@\fP obtains the window size using
396 \fBsetupterm\fP, which may be from
397 the operating system,
398 the \fBLINES\fP and \fBCOLUMNS\fP environment variables or
399 the terminal description.
400 .PP
401 Obtaining the window size from the terminal description is common to
402 both implementations, but considered obsolescent.
403 Its only practical use is for hardware terminals.
404 Generally speaking, a window size would be unset only if there were
405 some problem obtaining the value from the operating system
406 (and \fBsetupterm\fP would still fail).
407 For that reason, the \fBLINES\fP and \fBCOLUMNS\fP environment variables
408 may be useful for working around window-size problems.
409 Those have the drawback that if the window is resized,
410 those variables must be recomputed and reassigned.
411 To do this more easily, use the \fBresize\fP(1) program.
412 .SH ENVIRONMENT
413 The \fB@TSET@\fP command uses these environment variables:
414 .TP 5
415 SHELL
416 tells \fB@TSET@\fP whether to initialize \fBTERM\fP using \fBsh\fP(1) or
417 \fBcsh\fP(1) syntax.
418 .TP 5
419 TERM
420 Denotes your terminal type.
421 Each terminal type is distinct, though many are similar.
422 .TP 5
423 TERMCAP
424 may denote the location of a termcap database.
425 If it is not an absolute pathname, e.g., begins with a \*(``/\*('',
426 \fB@TSET@\fP removes the variable from the environment before looking
427 for the terminal description.
428 .SH FILES
429 .TP 5
430 /etc/ttys
431 system port name to terminal type mapping database (BSD versions only).
432 .TP
433 .I \*d
434 compiled terminal description database directory
435 .SH SEE ALSO
436 \fB\%csh\fP(1),
437 \fB\%sh\fP(1),
438 \fB\%stty\fP(1),
439 \fB\%curs_terminfo\fP(3X),
440 \fB\%tty\fP(4),
441 \fB\%terminfo\fP(5),
442 \fB\%ttys\fP(5),
443 \fB\%environ\fP(7)