1 # VT100 terminal emulator in a STDWIN window.
4 from stdwinevents
import *
5 from vt100
import VT100
18 def open(self
, title
):
19 stdwin
.setfont('7x14')
20 self
.charwidth
= stdwin
.textwidth('m')
21 self
.lineheight
= stdwin
.lineheight()
22 self
.docwidth
= self
.width
* self
.charwidth
23 self
.docheight
= self
.height
* self
.lineheight
24 stdwin
.setdefwinsize(self
.docwidth
+ 2, self
.docheight
+ 2)
25 stdwin
.setdefscrollbars(0, 0)
26 self
.window
= stdwin
.open(title
)
27 self
.window
.setdocsize(self
.docwidth
+ 2, self
.docheight
+ 2)
35 if not self
.window
: return
36 self
.window
.change(((-10, -10),
37 (self
.docwidth
+10, self
.docheight
+10)))
39 def draw(self
, detail
):
40 d
= self
.window
.begindrawing()
41 fg
= stdwin
.getfgcolor()
42 red
= stdwin
.fetchcolor('red')
47 for y
in range(self
.height
):
48 d
.text((0, y
*lh
), self
.lines
[y
].tostring())
49 if self
.attrs
[y
] <> self
.blankattr
:
50 for x
in range(len(self
.attrs
[y
])):
51 if self
.attrs
[y
][x
] == 7:
53 p2
= (x
+1)*cw
, (y
+1)*lh
58 d
.invert((x
, y
), (x
+cw
, y
+lh
))
62 def move_to(self
, x
, y
):
63 VT100
.move_to(self
, x
, y
)
64 if not self
.window
: return
65 if self
.y
!= self
.last_y
:
66 self
.window
.change((0, self
.last_y
* self
.lineheight
),
67 (self
.width
*self
.charwidth
,
68 (self
.last_y
+1) * self
.lineheight
))
71 self
.window
.change((0, self
.y
* self
.lineheight
),
72 (self
.width
*self
.charwidth
,
73 (self
.y
+1) * self
.lineheight
))