blob: a000714b77f761744cd95df03c0efe6bf1f06a64 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
<span id="tty-terminal-control-functions"></span><h1>tty — Terminal control functions</h1> <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/tty.py">Lib/tty.py</a></p> <p>The <a class="reference internal" href="#module-tty" title="tty: Utility functions that perform common terminal control operations. (Unix)"><code>tty</code></a> module defines functions for putting the tty into cbreak and raw modes.</p> <div class="availability docutils container"> <p><a class="reference internal" href="https://docs.python.org/3.12/library/intro.html#availability"><span class="std std-ref">Availability</span></a>: Unix.</p> </div> <p>Because it requires the <a class="reference internal" href="termios#module-termios" title="termios: POSIX style tty control. (Unix)"><code>termios</code></a> module, it will work only on Unix.</p> <p>The <a class="reference internal" href="#module-tty" title="tty: Utility functions that perform common terminal control operations. (Unix)"><code>tty</code></a> module defines the following functions:</p> <dl class="py function"> <dt class="sig sig-object py" id="tty.cfmakeraw">
<code>tty.cfmakeraw(mode)</code> </dt> <dd>
<p>Convert the tty attribute list <em>mode</em>, which is a list like the one returned by <a class="reference internal" href="termios#termios.tcgetattr" title="termios.tcgetattr"><code>termios.tcgetattr()</code></a>, to that of a tty in raw mode.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.12.</span></p> </div> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="tty.cfmakecbreak">
<code>tty.cfmakecbreak(mode)</code> </dt> <dd>
<p>Convert the tty attribute list <em>mode</em>, which is a list like the one returned by <a class="reference internal" href="termios#termios.tcgetattr" title="termios.tcgetattr"><code>termios.tcgetattr()</code></a>, to that of a tty in cbreak mode.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.12.</span></p> </div> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="tty.setraw">
<code>tty.setraw(fd, when=termios.TCSAFLUSH)</code> </dt> <dd>
<p>Change the mode of the file descriptor <em>fd</em> to raw. If <em>when</em> is omitted, it defaults to <a class="reference internal" href="termios#termios.TCSAFLUSH" title="termios.TCSAFLUSH"><code>termios.TCSAFLUSH</code></a>, and is passed to <a class="reference internal" href="termios#termios.tcsetattr" title="termios.tcsetattr"><code>termios.tcsetattr()</code></a>. The return value of <a class="reference internal" href="termios#termios.tcgetattr" title="termios.tcgetattr"><code>termios.tcgetattr()</code></a> is saved before setting <em>fd</em> to raw mode; this value is returned.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.12: </span>The return value is now the original tty attributes, instead of None.</p> </div> </dd>
</dl> <dl class="py function"> <dt class="sig sig-object py" id="tty.setcbreak">
<code>tty.setcbreak(fd, when=termios.TCSAFLUSH)</code> </dt> <dd>
<p>Change the mode of file descriptor <em>fd</em> to cbreak. If <em>when</em> is omitted, it defaults to <a class="reference internal" href="termios#termios.TCSAFLUSH" title="termios.TCSAFLUSH"><code>termios.TCSAFLUSH</code></a>, and is passed to <a class="reference internal" href="termios#termios.tcsetattr" title="termios.tcsetattr"><code>termios.tcsetattr()</code></a>. The return value of <a class="reference internal" href="termios#termios.tcgetattr" title="termios.tcgetattr"><code>termios.tcgetattr()</code></a> is saved before setting <em>fd</em> to cbreak mode; this value is returned.</p> <div class="versionchanged"> <p><span class="versionmodified changed">Changed in version 3.12: </span>The return value is now the original tty attributes, instead of None.</p> </div> </dd>
</dl> <div class="admonition seealso"> <p class="admonition-title">See also</p> <dl class="simple"> <dt>
<code>Module</code> <a class="reference internal" href="termios#module-termios" title="termios: POSIX style tty control. (Unix)"><code>termios</code></a>
</dt>
<dd>
<p>Low-level terminal control interface.</p> </dd> </dl> </div> <div class="_attribution">
<p class="_attribution-p">
© 2001–2023 Python Software Foundation<br>Licensed under the PSF License.<br>
<a href="https://docs.python.org/3.12/library/tty.html" class="_attribution-link">https://docs.python.org/3.12/library/tty.html</a>
</p>
</div>
|