Browse files

Add support for flashing and double height characters.

  • Loading branch information...
1 parent 8116938 commit b88d76cff75ac3e52376e910dcfed98f7eeab030 @ali1234 committed Sep 12, 2011
Showing with 27 additions and 5 deletions.
  1. +17 −1 printer.py
  2. +6 −4 subpagesquash.py
  3. +4 −0 teletext.css
View
18 printer.py
@@ -13,6 +13,8 @@ def __init__(self, tt, codepage=0):
self.bg = 0
self.mosaic = False
self.solid = True
+ self.double = False
+ self.flash = False
self.fasttext = False
self.flinkopen = False
# ignored for now
@@ -44,7 +46,7 @@ def ttchar(self, c):
return unichr(c)
def htmlspanstyle(self, fg=None, bg=None):
- return '<span class="f%d b%d">' % ((fg or self.fg), (bg or self.bg))
+ return '<span class="f%d b%d%s%s">' % ((fg or self.fg), (bg or self.bg), (" dh" if self.double else ""), (" fl" if self.flash else ""))
def setstyle(self, html, fg=None, bg=None):
if html:
@@ -78,6 +80,20 @@ def transform(self, c, html=False):
self.fg = l
ret = ' '+self.setstyle(html)
self.mosaic = False
+ elif l == 0x8: # flashing
+ self.flash = True
+ ret = ' '+self.setstyle(html)
+ print 'flash'
+ elif l == 0x9: # steady
+ self.flash = False
+ ret = ' '+self.setstyle(html)
+ elif l == 0xc: # single height
+ self.double = False
+ ret = ' '+self.setstyle(html)
+ elif l == 0xd: # double height
+ self.double = True
+ ret = ' '+self.setstyle(html)
+ print 'double'
else:
ret = ' '
elif h == 0x10:
View
10 subpagesquash.py
@@ -42,10 +42,12 @@ def to_html(self):
body.append(line)
for i in range(2,26):
- p = Printer(self.array[i][2:])
- if i == 25 and self.rows[1] == 27:
- p.set_fasttext(self.array[1], self.m)
- body.append(p.string_html())
+ # if previous line contains double height chars, skip this one
+ if i == 2 or ((self.array[i-1][2:]&0x7f) != 0x0d).all():
+ p = Printer(self.array[i][2:])
+ if i == 25 and self.rows[1] == 27:
+ p.set_fasttext(self.array[1], self.m)
+ body.append(p.string_html())
head = '<div class="subpage" id="%d">' % self.s
View
4 teletext.css
@@ -4,6 +4,7 @@ a {color: inherit; text-decoration: inherit;}
a:hover {color: orange;} a:active {color: red;}
@font-face {font-family:teletext2; src:url('teletext2.ttf')}
+@font-face {font-family:teletext4; src:url('teletext4.ttf')}
.subpage {float:left; white-space: pre; color:white;background:black;
font-family: teletext2; font-size:20px; line-height:20px;
@@ -15,3 +16,6 @@ a:hover {color: orange;} a:active {color: red;}
.b0{background:black;} .b1{background:red;} .b2{background:#00ff00;} .b3{background:yellow;}
.b4{background:blue;} .b5{background:magenta;} .b6{background:cyan;} .b7{background:white;}
+.dh{font-family: teletext4; font-size:40px; line-height:40px;}
+
+.fl{text-decoration: blink}

0 comments on commit b88d76c

Please sign in to comment.