Mercurial > cpython-lru_cache-weakref
annotate Lib/tty.py @ 80661:94de77bd0b4b 2.7
Issue #16194: document imp.load_dynamic problems
when read several extension modules from the same binary object file.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 29 Nov 2012 19:51:28 +0200 |
| parents | 0feb63490093 |
| children |
| rev | line source |
|---|---|
|
11707
6f4146846337
The third and final doc-string sweep by Ka-Ping Yee.
Guido van Rossum <guido@python.org>
parents:
1875
diff
changeset
|
1 """Terminal utilities.""" |
|
6f4146846337
The third and final doc-string sweep by Ka-Ping Yee.
Guido van Rossum <guido@python.org>
parents:
1875
diff
changeset
|
2 |
|
1875
8c9cc054c5ed
New tty/pty modules by Steen; new urlparser.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 # Author: Steen Lumholt. |
|
8c9cc054c5ed
New tty/pty modules by Steen; new urlparser.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 |
|
8c9cc054c5ed
New tty/pty modules by Steen; new urlparser.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 from termios import * |
|
8c9cc054c5ed
New tty/pty modules by Steen; new urlparser.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 |
|
16889
0feb63490093
final round of __all__ lists (I hope) - skipped urllib2 because Moshe may be
Skip Montanaro <skip@pobox.com>
parents:
16807
diff
changeset
|
7 __all__ = ["setraw", "setcbreak"] |
|
0feb63490093
final round of __all__ lists (I hope) - skipped urllib2 because Moshe may be
Skip Montanaro <skip@pobox.com>
parents:
16807
diff
changeset
|
8 |
|
15873
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
9 # Indexes for termios list. |
|
1875
8c9cc054c5ed
New tty/pty modules by Steen; new urlparser.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 IFLAG = 0 |
|
8c9cc054c5ed
New tty/pty modules by Steen; new urlparser.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 OFLAG = 1 |
|
8c9cc054c5ed
New tty/pty modules by Steen; new urlparser.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 CFLAG = 2 |
|
8c9cc054c5ed
New tty/pty modules by Steen; new urlparser.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 LFLAG = 3 |
|
8c9cc054c5ed
New tty/pty modules by Steen; new urlparser.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 ISPEED = 4 |
|
8c9cc054c5ed
New tty/pty modules by Steen; new urlparser.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 OSPEED = 5 |
|
8c9cc054c5ed
New tty/pty modules by Steen; new urlparser.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 CC = 6 |
|
8c9cc054c5ed
New tty/pty modules by Steen; new urlparser.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 |
|
8c9cc054c5ed
New tty/pty modules by Steen; new urlparser.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 def setraw(fd, when=TCSAFLUSH): |
|
15873
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
19 """Put terminal into a raw mode.""" |
|
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
20 mode = tcgetattr(fd) |
|
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
21 mode[IFLAG] = mode[IFLAG] & ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON) |
|
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
22 mode[OFLAG] = mode[OFLAG] & ~(OPOST) |
|
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
23 mode[CFLAG] = mode[CFLAG] & ~(CSIZE | PARENB) |
|
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
24 mode[CFLAG] = mode[CFLAG] | CS8 |
|
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
25 mode[LFLAG] = mode[LFLAG] & ~(ECHO | ICANON | IEXTEN | ISIG) |
|
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
26 mode[CC][VMIN] = 1 |
|
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
27 mode[CC][VTIME] = 0 |
|
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
28 tcsetattr(fd, when, mode) |
|
1875
8c9cc054c5ed
New tty/pty modules by Steen; new urlparser.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 |
|
8c9cc054c5ed
New tty/pty modules by Steen; new urlparser.
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 def setcbreak(fd, when=TCSAFLUSH): |
|
15873
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
31 """Put terminal into a cbreak mode.""" |
|
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
32 mode = tcgetattr(fd) |
|
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
33 mode[LFLAG] = mode[LFLAG] & ~(ECHO | ICANON) |
|
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
34 mode[CC][VMIN] = 1 |
|
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
35 mode[CC][VTIME] = 0 |
|
3dd217fbdd59
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
11707
diff
changeset
|
36 tcsetattr(fd, when, mode) |
