charmapTTY.py 文件源码

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

项目:fenrir 作者: chrys87 项目源码 文件源码
def updateCharMap(screen):
    global hichar
    ttyno = '4' 
    tty = open('/dev/tty' + screen, 'rb')
    GIO_UNIMAP = 0x4B66
    VT_GETHIFONTMASK = 0x560D
    himask = array("H", (0,))
    ioctl(tty, VT_GETHIFONTMASK, himask)
    hichar, = unpack_from("@H", himask)
    sz = 512
    line = ''
    while True:
        try:
            unipairs = array("H", [0]*(2*sz))
            unimapdesc = array("B", pack("@HP", sz, unipairs.buffer_info()[0]))
            ioctl(tty.fileno(), GIO_UNIMAP, unimapdesc)
            break
        except IOError as e:
            if e.errno != errno.ENOMEM:
                raise
            sz *= 2
    tty.close()
    ncodes, = unpack_from("@H", unimapdesc)
    utable = unpack_from("@%dH" % (2*ncodes), unipairs)
    for u, b in zip(utable[::2], utable[1::2]):
        if charmap.get(b) is None:
            charmap[b] = chr(u)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号