简单的VT102仿真器,用于屏幕抓取。
vt102的Python项目详细描述
[vt102](http://github.com/samfoo/vt102)是内存中的vt1xx终端 模拟器。它支持所有最常见的终端转义序列,包括 文本属性和颜色。
它是一个内存vt1xx兼容终端模拟器。xx代表 系列视频终端,由 [十二月](http://en.wikipedia.org/wiki/Digital_Equipment_Corporation)1970年之间 1995年。第一个,也是最著名的一个,是vt100终端,它现在是 所有虚拟终端模拟器的事实标准。 [vt102](http://github.com/samfoo/vt102)就是这样一个模拟器。
为什么要使用终端模拟器?
- 屏幕抓取一些终端或诅咒应用程序。
- 编写自己的图形终端模拟器。
- …说真的,就这样。
下面是一个简单的示例:
>>> from vt102 import screen, stream >>> st = stream() >>> sc = screen((10, 10)) >>> print(sc) [" ", " ", " ", " ", " ", " ", " ", " ", " ", " "] >>> sc.attach(st) >>> st.process("Text goes here") >>> print(sc) ["Text goes ", "here ", " ", " ", " ", " ", " ", " ", " ", " "] >>> st.process("\x1b[H\x1b[K") >>> print(sc) [" ", "here ", " ", " ", " ", " ", " ", " ", " ", " "]