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