Staging
v0.8.1
https://github.com/python/cpython
Revision 3266991e721286e942125350ca41e1403d8384d6 authored by Miss Islington (bot) on 24 November 2020, 00:26:31 UTC, committed by GitHub on 24 November 2020, 00:26:31 UTC
(cherry picked from commit 936533ca0415c40dc64ccb5f8857720f32b3fcb4)

Co-authored-by: Ned Deily <nad@python.org>
1 parent b641605
Raw File
Tip revision: 3266991e721286e942125350ca41e1403d8384d6 authored by Miss Islington (bot) on 24 November 2020, 00:26:31 UTC
bpo-41100: minor build installer fixes (GH-23480)
Tip revision: 3266991
tty.py
"""Terminal utilities."""

# Author: Steen Lumholt.

from termios import *

__all__ = ["setraw", "setcbreak"]

# Indexes for termios list.
IFLAG = 0
OFLAG = 1
CFLAG = 2
LFLAG = 3
ISPEED = 4
OSPEED = 5
CC = 6

def setraw(fd, when=TCSAFLUSH):
    """Put terminal into a raw mode."""
    mode = tcgetattr(fd)
    mode[IFLAG] = mode[IFLAG] & ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON)
    mode[OFLAG] = mode[OFLAG] & ~(OPOST)
    mode[CFLAG] = mode[CFLAG] & ~(CSIZE | PARENB)
    mode[CFLAG] = mode[CFLAG] | CS8
    mode[LFLAG] = mode[LFLAG] & ~(ECHO | ICANON | IEXTEN | ISIG)
    mode[CC][VMIN] = 1
    mode[CC][VTIME] = 0
    tcsetattr(fd, when, mode)

def setcbreak(fd, when=TCSAFLUSH):
    """Put terminal into a cbreak mode."""
    mode = tcgetattr(fd)
    mode[LFLAG] = mode[LFLAG] & ~(ECHO | ICANON)
    mode[CC][VMIN] = 1
    mode[CC][VTIME] = 0
    tcsetattr(fd, when, mode)
back to top