blob: dcaf17bd1c7ce423ebb13f95e8e5134d5745bcbd [file] [log] [blame]
Guido van Rossum74b3f8a1993-10-28 09:53:13 +00001# VT100 terminal emulator in a STDWIN window.
2
3import stdwin
4from stdwinevents import *
5from vt100 import VT100
6
7class VT100win(VT100):
8
9 def __init__(self):
10 VT100.__init__(self)
11 self.window = None
12## self.last_x = -1
13## self.last_y = -1
14
15 def __del__(self):
16 self.close()
17
18 def open(self, title):
19 stdwin.setfont('7x14')
20 self.docwidth = self.width * stdwin.textwidth('m')
21 self.docheight = self.height * stdwin.lineheight()
22 stdwin.setdefwinsize(self.docwidth + 2, self.docheight + 2)
23 stdwin.setdefscrollbars(0, 0)
24 self.window = stdwin.open(title)
25 self.window.setdocsize(self.docwidth + 2, self.docheight + 2)
26
27 def close(self):
28 if self.window:
29 self.window.close()
30 self.window = None
31
32 def show(self):
33 if not self.window: return
34 self.draw(((-10, -10), (self.docwidth+10, self.docheight+10)))
35
36 def draw(self, detail):
37 d = self.window.begindrawing()
38 fg = stdwin.getfgcolor()
39 red = stdwin.fetchcolor('red')
40 d.cliprect(detail)
41 d.erase(detail)
42 lh = d.lineheight()
43 cw = d.textwidth('m')
44 for y in range(self.height):
45 d.text((0, y*lh), self.lines[y].tostring())
46 if self.attrs[y] <> self.blankattr:
47 for x in range(len(self.attrs[y])):
48 if self.attrs[y][x] == 7:
49 p1 = x*cw, y*lh
50 p2 = (x+1)*cw, (y+1)*lh
51 d.invert((p1, p2))
52 x = self.x * cw
53 y = self.y * lh
54 d.setfgcolor(red)
55 d.invert((x, y), (x+cw, y+lh))
56 d.setfgcolor(fg)
57 d.close()
58
59## def move_to(self, x, y):
60## VT100.move_to(self, x, y)
61## if self.y != self.last_y:
62## self.show()
63## self.last_x = self.x
64## self.last_y = y
65
66 def send(self, str):
67 VT100.send(self, str)
68 self.show()