get_terminal_size.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:python-rst2ansi 作者: Snaipe 项目源码 文件源码
def _get_terminal_size(fd):
        handle = windll.kernel32.GetStdHandle(_handle_ids[fd])
        if handle == 0:
            raise OSError('handle cannot be retrieved')
        if handle == -1:
            raise WinError()
        csbi = create_string_buffer(22)
        res = windll.kernel32.GetConsoleScreenBufferInfo(handle, csbi)
        if res:
            res = struct.unpack("hhhhHhhhhhh", csbi.raw)
            left, top, right, bottom = res[5:9]
            columns = right - left + 1
            lines = bottom - top + 1
            return terminal_size(columns, lines)
        else:
            raise WinError()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号