tput.1.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
  2. <!--
  3. * t
  4. ****************************************************************************
  5. * Copyright (c) 1998-2005,2006 Free Software Foundation, Inc. *
  6. * *
  7. * Permission is hereby granted, free of charge, to any person obtaining a *
  8. * copy of this software and associated documentation files (the *
  9. * "Software"), to deal in the Software without restriction, including *
  10. * without limitation the rights to use, copy, modify, merge, publish, *
  11. * distribute, distribute with modifications, sublicense, and/or sell *
  12. * copies of the Software, and to permit persons to whom the Software is *
  13. * furnished to do so, subject to the following conditions: *
  14. * *
  15. * The above copyright notice and this permission notice shall be included *
  16. * in all copies or substantial portions of the Software. *
  17. * *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
  19. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
  21. * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
  22. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
  23. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
  24. * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
  25. * *
  26. * Except as contained in this notice, the name(s) of the above copyright *
  27. * holders shall not be used in advertising or otherwise to promote the *
  28. * sale, use or other dealings in this Software without prior written *
  29. * authorization. *
  30. ****************************************************************************
  31. * @Id: tput.1,v 1.27 2006/12/24 18:11:31 tom Exp @
  32. -->
  33. <HTML>
  34. <HEAD>
  35. <TITLE>tput 1</TITLE>
  36. <link rev=made href="mailto:bug-ncurses@gnu.org">
  37. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  38. </HEAD>
  39. <BODY>
  40. <H1>tput 1</H1>
  41. <HR>
  42. <PRE>
  43. <!-- Manpage converted by man2html 3.0.1 -->
  44. <STRONG><A HREF="tput.1.html">tput(1)</A></STRONG> <STRONG><A HREF="tput.1.html">tput(1)</A></STRONG>
  45. </PRE>
  46. <H2>NAME</H2><PRE>
  47. <STRONG>tput</STRONG>, <STRONG>reset</STRONG> - initialize a terminal or query terminfo
  48. database
  49. </PRE>
  50. <H2>SYNOPSIS</H2><PRE>
  51. <STRONG>tput</STRONG> [<STRONG>-T</STRONG><EM>type</EM>] <EM>capname</EM> [<EM>parms</EM> ... ]
  52. <STRONG>tput</STRONG> [<STRONG>-T</STRONG><EM>type</EM>] <STRONG>init</STRONG>
  53. <STRONG>tput</STRONG> [<STRONG>-T</STRONG><EM>type</EM>] <STRONG>reset</STRONG>
  54. <STRONG>tput</STRONG> [<STRONG>-T</STRONG><EM>type</EM>] <STRONG>longname</STRONG>
  55. <STRONG>tput</STRONG> <STRONG>-S</STRONG> <STRONG>&lt;&lt;</STRONG>
  56. <STRONG>tput</STRONG> <STRONG>-V</STRONG>
  57. </PRE>
  58. <H2>DESCRIPTION</H2><PRE>
  59. The <STRONG>tput</STRONG> utility uses the <STRONG>terminfo</STRONG> database to make the
  60. values of terminal-dependent capabilities and information
  61. available to the shell (see <STRONG><A HREF="sh.1.html">sh(1)</A></STRONG>), to initialize or reset
  62. the terminal, or return the long name of the requested
  63. terminal type. The result depends upon the capability's
  64. type:
  65. string
  66. <STRONG>tput</STRONG> writes the string to the standard output.
  67. No trailing newline is supplied.
  68. integer
  69. <STRONG>tput</STRONG> writes the decimal value to the standard
  70. output, with a trailing newline.
  71. boolean
  72. <STRONG>tput</STRONG> simply sets the exit code (<STRONG>0</STRONG> for TRUE if
  73. the terminal has the capability, <STRONG>1</STRONG> for FALSE
  74. if it does not), and writes nothing to the
  75. standard output.
  76. Before using a value returned on the standard output, the
  77. application should test the exit code (e.g., <STRONG>$?</STRONG>, see
  78. <STRONG><A HREF="sh.1.html">sh(1)</A></STRONG>) to be sure it is <STRONG>0</STRONG>. (See the <STRONG>EXIT</STRONG> <STRONG>CODES</STRONG> and <STRONG>DIAG-</STRONG>
  79. <STRONG>NOSTICS</STRONG> sections.) For a complete list of capabilities
  80. and the <EM>capname</EM> associated with each, see <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>.
  81. <STRONG>-T</STRONG><EM>type</EM> indicates the <EM>type</EM> of terminal. Normally this
  82. option is unnecessary, because the default is taken
  83. from the environment variable <STRONG>TERM</STRONG>. If <STRONG>-T</STRONG> is spec-
  84. ified, then the shell variables <STRONG>LINES</STRONG> and <STRONG>COLUMNS</STRONG>
  85. will be ignored,and the operating system will not
  86. be queried for the actual screen size.
  87. <EM>capname</EM>
  88. indicates the capability from the <STRONG>terminfo</STRONG>
  89. database. When <STRONG>termcap</STRONG> support is compiled in, the
  90. <STRONG>termcap</STRONG> name for the capability is also accepted.
  91. <EM>parms</EM> If the capability is a string that takes parame-
  92. ters, the arguments <EM>parms</EM> will be instantiated into
  93. the string.
  94. Most parameters are numbers. Only a few terminfo
  95. capabilities require string parameters; <STRONG>tput</STRONG> uses a
  96. table to decide which to pass as strings. Normally
  97. <STRONG>tput</STRONG> uses <STRONG>tparm</STRONG> (3x) to perform the substitution.
  98. If no parameters are given for the capability, <STRONG>tput</STRONG>
  99. writes the string without performing the
  100. substitution.
  101. <STRONG>-S</STRONG> allows more than one capability per invocation of
  102. <STRONG>tput</STRONG>. The capabilities must be passed to <STRONG>tput</STRONG> from
  103. the standard input instead of from the command line
  104. (see example). Only one <EM>capname</EM> is allowed per
  105. line. The <STRONG>-S</STRONG> option changes the meaning of the <STRONG>0</STRONG>
  106. and <STRONG>1</STRONG> boolean and string exit codes (see the EXIT
  107. CODES section).
  108. Again, <STRONG>tput</STRONG> uses a table and the presence of param-
  109. eters in its input to decide whether to use <STRONG>tparm</STRONG>
  110. (3x), and how to interpret the parameters.
  111. <STRONG>-V</STRONG> reports the version of ncurses which was used in
  112. this program, and exits.
  113. <STRONG>init</STRONG> If the <STRONG>terminfo</STRONG> database is present and an entry
  114. for the user's terminal exists (see <STRONG>-T</STRONG><EM>type</EM>, above),
  115. the following will occur:
  116. (1) if present, the terminal's initialization
  117. strings will be output as detailed in the
  118. <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG> section on <EM>Tabs</EM> <EM>and</EM> <EM>Initializa-</EM>
  119. <EM>tion</EM>,
  120. (2) any delays (e.g., newline) specified in the
  121. entry will be set in the tty driver,
  122. (3) tabs expansion will be turned on or off
  123. according to the specification in the entry,
  124. and
  125. (4) if tabs are not expanded, standard tabs will
  126. be set (every 8 spaces).
  127. If an entry does not contain the information needed
  128. for any of the four above activities, that activity
  129. will silently be skipped.
  130. <STRONG>reset</STRONG> Instead of putting out initialization strings, the
  131. terminal's reset strings will be output if present
  132. (<STRONG>rs1</STRONG>, <STRONG>rs2</STRONG>, <STRONG>rs3</STRONG>, <STRONG>rf</STRONG>). If the reset strings are not
  133. present, but initialization strings are, the ini-
  134. tialization strings will be output. Otherwise,
  135. <STRONG>reset</STRONG> acts identically to <STRONG>init</STRONG>.
  136. <STRONG>longname</STRONG>
  137. If the <STRONG>terminfo</STRONG> database is present and an entry
  138. for the user's terminal exists (see <STRONG>-T</STRONG><EM>type</EM> above),
  139. then the long name of the terminal will be put out.
  140. The long name is the last name in the first line of
  141. the terminal's description in the <STRONG>terminfo</STRONG> database
  142. [see <STRONG><A HREF="term.5.html">term(5)</A></STRONG>].
  143. If <STRONG>tput</STRONG> is invoked by a link named <STRONG>reset</STRONG>, this has the
  144. same effect as <STRONG>tput</STRONG> <STRONG>reset</STRONG>. See <STRONG>tset</STRONG> for comparison, which
  145. has similar behavior.
  146. </PRE>
  147. <H2>EXAMPLES</H2><PRE>
  148. <STRONG>tput</STRONG> <STRONG>init</STRONG>
  149. Initialize the terminal according to the type of ter-
  150. minal in the environmental variable <STRONG>TERM</STRONG>. This com-
  151. mand should be included in everyone's .profile after
  152. the environmental variable <STRONG>TERM</STRONG> has been exported, as
  153. illustrated on the <STRONG><A HREF="profile.5.html">profile(5)</A></STRONG> manual page.
  154. <STRONG>tput</STRONG> <STRONG>-T5620</STRONG> <STRONG>reset</STRONG>
  155. Reset an AT&amp;T 5620 terminal, overriding the type of
  156. terminal in the environmental variable <STRONG>TERM</STRONG>.
  157. <STRONG>tput</STRONG> <STRONG>cup</STRONG> <STRONG>0</STRONG> <STRONG>0</STRONG>
  158. Send the sequence to move the cursor to row <STRONG>0</STRONG>, column
  159. <STRONG>0</STRONG> (the upper left corner of the screen, usually known
  160. as the "home" cursor position).
  161. <STRONG>tput</STRONG> <STRONG>clear</STRONG>
  162. Echo the clear-screen sequence for the current termi-
  163. nal.
  164. <STRONG>tput</STRONG> <STRONG>cols</STRONG>
  165. Print the number of columns for the current terminal.
  166. <STRONG>tput</STRONG> <STRONG>-T450</STRONG> <STRONG>cols</STRONG>
  167. Print the number of columns for the 450 terminal.
  168. <STRONG>bold=`tput</STRONG> <STRONG>smso`</STRONG> <STRONG>offbold=`tput</STRONG> <STRONG>rmso`</STRONG>
  169. Set the shell variables <STRONG>bold</STRONG>, to begin stand-out mode
  170. sequence, and <STRONG>offbold</STRONG>, to end standout mode sequence,
  171. for the current terminal. This might be followed by
  172. a prompt: <STRONG>echo</STRONG> <STRONG>"${bold}Please</STRONG> <STRONG>type</STRONG> <STRONG>in</STRONG> <STRONG>your</STRONG> <STRONG>name:</STRONG>
  173. <STRONG>${offbold}\c"</STRONG>
  174. <STRONG>tput</STRONG> <STRONG>hc</STRONG>
  175. Set exit code to indicate if the current terminal is
  176. a hard copy terminal.
  177. <STRONG>tput</STRONG> <STRONG>cup</STRONG> <STRONG>23</STRONG> <STRONG>4</STRONG>
  178. Send the sequence to move the cursor to row 23, col-
  179. umn 4.
  180. <STRONG>tput</STRONG> <STRONG>cup</STRONG>
  181. Send the terminfo string for cursor-movement, with no
  182. parameters substituted.
  183. <STRONG>tput</STRONG> <STRONG>longname</STRONG>
  184. Print the long name from the <STRONG>terminfo</STRONG> database for
  185. the type of terminal specified in the environmental
  186. variable <STRONG>TERM</STRONG>.
  187. <STRONG>tput</STRONG> <STRONG>-S</STRONG> <STRONG>&lt;&lt;!</STRONG>
  188. <STRONG>&gt;</STRONG> <STRONG>clear</STRONG>
  189. <STRONG>&gt;</STRONG> <STRONG>cup</STRONG> <STRONG>10</STRONG> <STRONG>10</STRONG>
  190. <STRONG>&gt;</STRONG> <STRONG>bold</STRONG>
  191. <STRONG>&gt;</STRONG> <STRONG>!</STRONG>
  192. This example shows <STRONG>tput</STRONG> processing several capabili-
  193. ties in one invocation. It clears the screen, moves
  194. the cursor to position 10, 10 and turns on bold
  195. (extra bright) mode. The list is terminated by an
  196. exclamation mark (<STRONG>!</STRONG>) on a line by itself.
  197. </PRE>
  198. <H2>FILES</H2><PRE>
  199. <STRONG>/usr/share/terminfo</STRONG>
  200. compiled terminal description database
  201. <STRONG>/usr/share/tabset/*</STRONG>
  202. tab settings for some terminals, in a format appro-
  203. priate to be output to the terminal (escape
  204. sequences that set margins and tabs); for more
  205. information, see the "Tabs and Initialization" sec-
  206. tion of <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>
  207. </PRE>
  208. <H2>EXIT CODES</H2><PRE>
  209. If the <STRONG>-S</STRONG> option is used, <STRONG>tput</STRONG> checks for errors from each
  210. line, and if any errors are found, will set the exit code
  211. to 4 plus the number of lines with errors. If no errors
  212. are found, the exit code is <STRONG>0</STRONG>. No indication of which
  213. line failed can be given so exit code <STRONG>1</STRONG> will never appear.
  214. Exit codes <STRONG>2</STRONG>, <STRONG>3</STRONG>, and <STRONG>4</STRONG> retain their usual interpretation.
  215. If the <STRONG>-S</STRONG> option is not used, the exit code depends on the
  216. type of <EM>capname</EM>:
  217. <EM>boolean</EM>
  218. a value of <STRONG>0</STRONG> is set for TRUE and <STRONG>1</STRONG> for FALSE.
  219. <EM>string</EM> a value of <STRONG>0</STRONG> is set if the <EM>capname</EM> is defined
  220. for this terminal <EM>type</EM> (the value of <EM>capname</EM>
  221. is returned on standard output); a value of <STRONG>1</STRONG>
  222. is set if <EM>capname</EM> is not defined for this ter-
  223. minal <EM>type</EM> (nothing is written to standard
  224. output).
  225. <EM>integer</EM>
  226. a value of <STRONG>0</STRONG> is always set, whether or not
  227. <EM>capname</EM> is defined for this terminal <EM>type</EM>. To
  228. determine if <EM>capname</EM> is defined for this ter-
  229. minal <EM>type</EM>, the user must test the value writ-
  230. ten to standard output. A value of <STRONG>-1</STRONG> means
  231. that <EM>capname</EM> is not defined for this terminal
  232. <EM>type</EM>.
  233. <EM>other</EM> <STRONG>reset</STRONG> or <STRONG>init</STRONG> may fail to find their respec-
  234. tive files. In that case, the exit code is
  235. set to 4 + <STRONG>errno</STRONG>.
  236. Any other exit code indicates an error; see the DIAGNOS-
  237. TICS section.
  238. </PRE>
  239. <H2>DIAGNOSTICS</H2><PRE>
  240. <STRONG>tput</STRONG> prints the following error messages and sets the cor-
  241. responding exit codes.
  242. exit code error message
  243. ---------------------------------------------------------------------
  244. <STRONG>0</STRONG> (<EM>capname</EM> is a numeric variable that is not specified in
  245. the <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG> database for this terminal type, e.g.
  246. <STRONG>tput</STRONG> <STRONG>-T450</STRONG> <STRONG>lines</STRONG> and <STRONG>tput</STRONG> <STRONG>-T2621</STRONG> <STRONG>xmc</STRONG>)
  247. <STRONG>1</STRONG> no error message is printed, see the <STRONG>EXIT</STRONG> <STRONG>CODES</STRONG> section.
  248. <STRONG>2</STRONG> usage error
  249. <STRONG>3</STRONG> unknown terminal <EM>type</EM> or no <STRONG>terminfo</STRONG> database
  250. <STRONG>4</STRONG> unknown <STRONG>terminfo</STRONG> capability <EM>capname</EM>
  251. <STRONG>&gt;4</STRONG> error occurred in -S
  252. ---------------------------------------------------------------------
  253. </PRE>
  254. <H2>PORTABILITY</H2><PRE>
  255. The <STRONG>longname</STRONG> and <STRONG>-S</STRONG> options, and the parameter-substitu-
  256. tion features used in the <STRONG>cup</STRONG> example, are not supported
  257. in BSD curses or in AT&amp;T/USL curses before SVr4.
  258. X/Open documents only the operands for <STRONG>clear</STRONG>, <STRONG>init</STRONG> and
  259. <STRONG>reset</STRONG>. In this implementation, <STRONG>clear</STRONG> is part of the <EM>cap-</EM>
  260. <EM>name</EM> support. Other implementations of <STRONG>tput</STRONG> on SVr4-based
  261. systems such as Solaris, IRIX64 and HPUX as well as others
  262. such as AIX and Tru64 provide support for <EM>capname</EM>
  263. operands. A few platforms such as FreeBSD and NetBSD rec-
  264. ognize termcap names rather than terminfo capability names
  265. in their respective <STRONG>tput</STRONG> commands.
  266. </PRE>
  267. <H2>SEE ALSO</H2><PRE>
  268. <STRONG><A HREF="clear.1.html">clear(1)</A></STRONG>, <STRONG><A HREF="stty.1.html">stty(1)</A></STRONG>, <STRONG><A HREF="tabs.1.html">tabs(1)</A></STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>.
  269. This describes <STRONG>ncurses</STRONG> version 5.6 (patch 20081011).
  270. <STRONG><A HREF="tput.1.html">tput(1)</A></STRONG>
  271. </PRE>
  272. <HR>
  273. <ADDRESS>
  274. Man(1) output converted with
  275. <a href="http://www.oac.uci.edu/indiv/ehood/man2html.html">man2html</a>
  276. </ADDRESS>
  277. </BODY>
  278. </HTML>