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