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