當前位置: 首頁>>代碼示例>>Python>>正文


Python termios.ONLCR屬性代碼示例

本文整理匯總了Python中termios.ONLCR屬性的典型用法代碼示例。如果您正苦於以下問題:Python termios.ONLCR屬性的具體用法?Python termios.ONLCR怎麽用?Python termios.ONLCR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在termios的用法示例。


在下文中一共展示了termios.ONLCR屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import ONLCR [as 別名]
def __init__(self, height=25, width=80):

        self.master, self.slave = pty.openpty()

        if sys.version_info[:2] < (2, 7):
            self.stdout = os.fdopen(self.slave, 'w', 1)
            self.stdread = os.fdopen(self.master, 'r')
        else:
            self.stdout = io.open(self.slave, 'w', 1, encoding='UTF-8', newline='')
            self.stdread = io.open(self.master, 'r', encoding='UTF-8', newline='\n')

        # Make sure linefeed behavior is consistent between Python 2 and Python 3
        termattrs = termios.tcgetattr(self.slave)
        termattrs[1] = termattrs[1] & ~termios.ONLCR & ~termios.OCRNL
        termattrs[0] = termattrs[0] & ~termios.ICRNL
        termios.tcsetattr(self.slave, termios.TCSADRAIN, termattrs)

        self.resize(height, width) 
開發者ID:Rockhopper-Technologies,項目名稱:enlighten,代碼行數:20,代碼來源:__init__.py

示例2: _configure_term_settings

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import ONLCR [as 別名]
def _configure_term_settings(pty_fd):
  term_settings = termios.tcgetattr(pty_fd)
  # ONLCR transforms NL to CR-NL, which is undesirable. Ensure this is disabled.
  # http://man7.org/linux/man-pages/man3/termios.3.html
  term_settings[1] &= ~termios.ONLCR

  # ECHOCTL echoes control characters, which is undesirable.
  term_settings[3] &= ~termios.ECHOCTL

  termios.tcsetattr(pty_fd, termios.TCSANOW, term_settings) 
開發者ID:googlecolab,項目名稱:colabtools,代碼行數:12,代碼來源:_system_commands.py

示例3: __enter__

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import ONLCR [as 別名]
def __enter__(self) -> 'Pty':
            self.r, self.w = openpty()

            # tty flags normally change \n to \r\n
            attrs = termios.tcgetattr(self.r)
            assert isinstance(attrs[1], int)
            attrs[1] &= ~(termios.ONLCR | termios.OPOST)
            termios.tcsetattr(self.r, termios.TCSANOW, attrs)

            return self 
開發者ID:pre-commit,項目名稱:pre-commit,代碼行數:12,代碼來源:util.py

示例4: pty_normalize_newlines

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import ONLCR [as 別名]
def pty_normalize_newlines(fd):
    r"""
    Twiddle the tty flags such that \n won't get munged to \r\n.
    Details:
        https://docs.python.org/2/library/termios.html
        http://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_chapter/libc_17.html#SEC362
    """
    import termios as T
    attrs = T.tcgetattr(fd)
    attrs[1] &= ~(T.ONLCR | T.OPOST)
    T.tcsetattr(fd, T.TCSANOW, attrs) 
開發者ID:Yelp,項目名稱:venv-update,代碼行數:13,代碼來源:capture_subprocess.py

示例5: configure_tty

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import ONLCR [as 別名]
def configure_tty(self) -> bytes:
        """We don't want \n to be replaced with \r\n, and we disable the echo"""
        attr = termios.tcgetattr(self.fd)
        # The following raises a mypy warning, as python type hints don't allow
        # per list item granularity.  The last item in attr is List[bytes], but
        # we don't access that here.
        attr[1] &= ~termios.ONLCR  # type: ignore # oflag
        attr[3] &= ~termios.ECHO  # type: ignore # lflag
        termios.tcsetattr(self.fd, termios.TCSANOW, attr)
        # unsetopt zle prevents Zsh from resetting the tty
        return b'unsetopt zle 2> /dev/null;stty -echo -onlcr -ctlecho;' 
開發者ID:innogames,項目名稱:polysh,代碼行數:13,代碼來源:remote_dispatcher.py


注:本文中的termios.ONLCR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。