]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/tset.1
ncurses 6.4 - patch 20240420
[ncurses.git] / man / tset.1
1 .\"***************************************************************************
2 .\" Copyright 2018-2023,2024 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.83 2024/04/20 19:09:08 tom Exp $
31 .TH @TSET@ 1 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "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 "\fItset\fP \(em 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 environment 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 \fI\%getty\fP(8) 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 "\fIreset\fP \(em 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 environment variable ends in \*(``csh\*('',
168 the commands
169 are for \fIcsh\fP(1),
170 otherwise,
171 they are for \fIsh\fP(1).
172 The \fIcsh\fP commands set and unset the shell variable \fBnoglob\fP,
173 leaving it unset.
174 The following line in the \fB.login\fP
175 or \fB.profile\fP files will initialize the environment correctly:
176 .sp
177     eval \(ga@TSET@ \-s options ... \(ga
178 .
179 .SS "Terminal Type Mapping"
180 When the terminal is not hardwired into the system (or the current
181 system information is incorrect) the terminal type derived from the
182 \fI/etc/ttys\fP file or the \fITERM\fP environment variable is often
183 something generic like \fBnetwork\fP, \fBdialup\fP, or \fBunknown\fP.
184 When \fB@TSET@\fP is used in a startup script it is often desirable to
185 provide information about the type of terminal used on such ports.
186 .PP
187 The \fB\-m\fP options maps
188 from some set of conditions to a terminal type, that is, to
189 tell \fB@TSET@\fP
190 \*(``If I'm on this port at a particular speed,
191 guess that I'm on that kind of terminal\*(''.
192 .PP
193 The argument to the \fB\-m\fP option consists of an optional port type, an
194 optional operator, an optional baud rate specification, an optional
195 colon (\*(``:\*('') character and a terminal type.
196 The port type is a
197 string (delimited by either the operator or the colon character).
198 The operator may be any combination of
199 \*(``>\*('',
200 \*(``<\*('',
201 \*(``@\*('',
202 and \*(``!\*('';
203 \*(``>\*('' means greater than,
204 \*(``<\*('' means less than,
205 \*(``@\*('' means equal to and
206 \*(``!\*('' inverts the sense of the test.
207 The baud rate is specified as a number and is compared with the speed
208 of the standard error output (which should be the control terminal).
209 The terminal type is a string.
210 .PP
211 If the terminal type is not specified on the command line, the \fB\-m\fP
212 mappings are applied to the terminal type.
213 If the port type and baud
214 rate match the mapping, the terminal type specified in the mapping
215 replaces the current type.
216 If more than one mapping is specified, the
217 first applicable mapping is used.
218 .PP
219 For example, consider the following mapping: \fBdialup>9600:vt100\fP.
220 The port type is dialup , the operator is >, the baud rate
221 specification is 9600, and the terminal type is vt100.
222 The result of
223 this mapping is to specify that if the terminal type is \fBdialup\fP,
224 and the baud rate is greater than 9600 baud, a terminal type of
225 \fBvt100\fP will be used.
226 .PP
227 If no baud rate is specified, the terminal type will match any baud rate.
228 If no port type is specified, the terminal type will match any port type.
229 For example, \fB\-m dialup:vt100 \-m :?xterm\fP
230 will cause any dialup port, regardless of baud rate, to match the terminal
231 type vt100, and any non-dialup port type to match the terminal type ?xterm.
232 Note, because of the leading question mark, the user will be
233 queried on a default port as to whether they are actually using an xterm
234 terminal.
235 .PP
236 No whitespace characters are permitted in the \fB\-m\fP option argument.
237 Also, to avoid problems with meta-characters, it is suggested that the
238 entire \fB\-m\fP option argument be placed within single quote characters,
239 and that \fIcsh\fP users insert a backslash character (\*(``\e\*('')
240 before any exclamation marks (\*(``!\*('').
241 .SH OPTIONS
242 The options are as follows:
243 .TP 5
244 .B \-c
245 Set control characters and modes.
246 .TP 5
247 .BI \-e\  ch
248 Set the erase character to \fIch\fP.
249 .TP
250 .B \-I
251 Do not send the terminal or tab initialization strings to the terminal.
252 .TP
253 .BI \-i\  ch
254 Set the interrupt character to \fIch\fP.
255 .TP
256 .BI \-k\  ch
257 Set the line kill character to \fIch\fP.
258 .TP
259 .BI \-m\  mapping
260 Specify a mapping from a port type to a terminal;
261 see subsection \*(``Terminal Type Mapping\*(''.
262 .TP
263 .B \-Q
264 Do not display any values for the erase, interrupt and line kill characters.
265 Normally \fB@TSET@\fP displays the values for control characters which
266 differ from the system's default values.
267 .TP
268 .B \-q
269 The terminal type is displayed to the standard output, and the terminal is
270 not initialized in any way.
271 The option \*(``\-\*('' by itself is equivalent but archaic.
272 .TP
273 .B \-r
274 Print the terminal type to the standard error output.
275 .TP
276 .B \-s
277 Print the sequence of shell commands to initialize the environment variable
278 \fITERM\fP to the standard output;
279 see subsection \*(``Setting the Environment\*(''.
280 .TP
281 .B \-V
282 reports the version of \fI\%ncurses\fP which was used in this program,
283 and exits.
284 .TP
285 .B \-w
286 Resize the window to match the size deduced via \fBsetupterm\fP(3X).
287 Normally this has no effect,
288 unless \fBsetupterm\fP is not able to detect the window size.
289 .PP
290 The arguments for the \fB\-e\fP, \fB\-i\fP, and \fB\-k\fP
291 options may either be entered as actual characters
292 or by using the \*(``hat\*(''
293 notation, i.e., control-h may be specified as \*(``\*^H\*('' or \*(``\*^h\*(''.
294 .PP
295 If neither \fB\-c\fP or \fB\-w\fP is given, both options are assumed.
296 .SH ENVIRONMENT
297 The \fB@TSET@\fP command uses these environment variables:
298 .TP 5
299 .I SHELL
300 tells \fB@TSET@\fP whether to initialize \fITERM\fP using \fIsh\fP(1) or
301 \fIcsh\fP(1) syntax.
302 .TP 5
303 .I TERM
304 Denotes your terminal type.
305 Each terminal type is distinct, though many are similar.
306 .TP 5
307 .I TERMCAP
308 may denote the location of a termcap database.
309 If it is not an absolute pathname, e.g., begins with a \*(``/\*('',
310 \fB@TSET@\fP removes the variable from the environment before looking
311 for the terminal description.
312 .SH FILES
313 .TP
314 .I /etc/ttys
315 system port name to terminal type mapping database (BSD versions only).
316 .TP
317 .I \*d
318 compiled terminal description database directory
319 .SH PORTABILITY
320 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
321 (POSIX.1-2008) nor
322 X/Open Curses Issue 7 documents \fB@TSET@\fP or \fB@RESET@\fP.
323 .PP
324 The AT&T \fBtput\fP utility (AIX, HP-UX, Solaris)
325 incorporated the terminal-mode manipulation as well as termcap-based features
326 such as resetting tabstops from \fBtset\fP in BSD (4.1c),
327 presumably with the intention of making \fBtset\fP obsolete.
328 However, each of those systems still provides \fBtset\fP.
329 In fact, the commonly-used \fBreset\fP utility
330 is always an alias for \fBtset\fP.
331 .PP
332 The \fB\%@TSET@\fP utility provides backward compatibility with BSD
333 environments;
334 under most modern Unices,
335 \fI\%/etc/inittab\fP and \fI\%getty\fP(8) can set \fITERM\fP
336 appropriately for each dial-up line,
337 obviating what was \fB\%@TSET@\fP's most important use.
338 This implementation behaves like 4.4BSD \fBtset\fP,
339 with a few exceptions we shall consider now.
340 .PP
341 A few options are different
342 because the \fI\%TERMCAP\fP variable
343 is no longer supported under terminfo-based \fI\%ncurses\fP:
344 .bP
345 The \fB\-S\fP option of BSD \fBtset\fP no longer works;
346 it prints an error message to the standard error and dies.
347 .bP
348 The \fB\-s\fP option only sets \fITERM\fP,
349 not \fI\%TERMCAP\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 \fI\%ncurses\fP, \fB@TSET@\fP obtains the window size using
394 \fBsetupterm\fP, which may be from
395 the operating system,
396 the \fILINES\fP and \fICOLUMNS\fP environment variables or
397 the terminal description.
398 .PP
399 Obtaining the window size from a terminal's type description is common
400 to both implementations,
401 but considered obsolescent.
402 Its only practical use is for hardware terminals.
403 Generally,
404 the window size will remain uninitialized only if there were a problem
405 obtaining the value from the operating system
406 (and \fB\%setupterm\fP would still fail).
407 The \fILINES\fP and \fI\%COLUMNS\fP environment variables
408 may thus be useful for working around window-size problems,
409 but have the drawback that if the window is resized,
410 their values must be recomputed and reassigned.
411 The \fI\%resize\fP(1) program distributed with
412 \fI\%xterm\fP(1) assists this activity.
413 .SH HISTORY
414 A \fB\%reset\fP command written by Kurt Shoens appeared in 1BSD
415 (March 1978).
416 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/s6/reset.c
417 It set the \fIerase\fP and \fIkill\fP characters
418 to \fB\*^H\fP (backspace) and \fB@\fP respectively.
419 Mark Horton improved this \fB\%reset\fP in 3BSD
420 (October 1979),
421 adding \fIintr\fP,
422 \fIquit\fP,
423 \fIstart\fP/\fIstop\fP,
424 and \fIeof\fP
425 characters as well as changing the program to avoid modifying any user
426 settings.
427 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/src/cmd/\
428 .\"   reset.c
429 That version of \fB\%reset\fP did not use \fI\%termcap\fP.
430 .PP
431 Eric Allman wrote a distinct \fBtset\fP command for 1BSD,
432 using a forerunner of \fI\%termcap\fP called \fI\%ttycap\fP.
433 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/s6/tset.c
434 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=1BSD/man7/ttycap.7
435 Allman's comments in the source code indicate
436 that he began work in October 1977,
437 continuing development over the next few years.
438 By late 1979,
439 it had migrated to \fI\%termcap\fP and handled the \fI\%TERMCAP\fP
440 variable.
441 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/src/cmd/\
442 .\"   tset/tset.c
443 Later comments indicate that \fBtset\fP was modified in September 1980
444 to use logic copied from the 3BSD \*(``reset\*('' program when it was
445 invoked as \fB\%reset\fP.
446 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=2.9BSD/usr/src/ucb/\
447 .\"   tset/tset.c
448 This version appeared in 4.1cBSD, \" and backported to 2.9BSD
449 late in 1982.
450 Other developers such as Keith Bostic and Jim Bloom continued to modify
451 \fBtset\fP until 4.4BSD was released in 1993.
452 .PP
453 The \fI\%ncurses\fP implementation was lightly adapted from the 4.4BSD
454 sources to use the \fI\%terminfo\fP API by Eric S.\& Raymond
455 <esr@snark.thyrsus.com>.
456 .SH SEE ALSO
457 \fB\%csh\fP(1),
458 \fB\%sh\fP(1),
459 \fB\%stty\fP(1),
460 \fB\%curs_terminfo\fP(3X),
461 \fB\%tty\fP(4),
462 \fB\%terminfo\fP(5),
463 \fB\%ttys\fP(5),
464 \fB\%environ\fP(7)