pyte
pyte copied to clipboard
Support for DEC special graphics
This is used in the majority of Nethack ttyrecs. There's a thing called https://en.wikipedia.org/wiki/DEC_Special_Graphics where if \e(0 is sent, it toggles some codes.
Steps to reproduce:
import pyte
screen = pyte.Screen(30, 1)
stream = pyte.Stream(screen)
data = b'x\x1b(0x\x1b(Bx'
stream.feed(data.decode('cp437'))
for y, row in screen.buffer.items():
for x, cell in row.items():
print(x, cell.data, cell.fg, cell.bg, cell.bold, "reversed" if cell.reverse else "")
import sys
sys.stdout.write(data.decode('cp437'))
Expected: x|x Actual: xxx
Sample code produces:
0 x default default False
1 x default default False
2 x default default False
x│x
As a workaround, I can set stream.use_utf = False.
meet the same situation.
echo -e '\033(0\x0f mq \033(B'
└─
when i want show this in pyte, just got 'mq'
//test.py
from __future__ import unicode_literals
import pyte
screen = pyte.Screen(80, 24)
stream = pyte.Stream(screen)
s = '\033(0\x0f mq \033(B'
stream.feed(s)
print(screen.display)
//got
[' mq ...
workaround:
stream.use_utf8 = False does works