Esempio n. 1
0
    def draw(self):
        cept_data = bytearray(Cept.parallel_limited_mode())
        cept_data.extend(Cept.hide_cursor())
        cept_data.extend(Cept.set_cursor(self.line, self.column))
        fill_with_clear_line = self.clear_line and self.width == 40  # and self.height == 1
        fill_with_spaces = self.clear_line and not fill_with_clear_line
        for i in range(0, self.height):
            l = self.__data[i].rstrip()

            if self.type == "password":
                l = "*" * len(l)
            else:
                if l.startswith(chr(Cept.ini())):
                    l = "*" + l[1:]

            if l:
                cept_data.extend(self.set_color())

            if fill_with_clear_line:
                cept_data.extend(Cept.clear_line())
                if self.bgcolor:
                    cept_data.extend(Cept.set_line_bg_color(self.bgcolor))

            cept_data.extend(Cept.from_str(l))

            if fill_with_spaces and len(l) > self.width:
                cept_data.extend(Cept.repeat(" ", self.width - len(l)))

            if i != self.height - 1:
                if self.column == 1:
                    if self.width != 40 or fill_with_clear_line:
                        cept_data.extend(b'\n')
                else:
                    cept_data.extend(
                        Cept.set_cursor(self.line + i + 1, self.column))
        sys.stdout.buffer.write(cept_data)
        sys.stdout.flush()
Esempio n. 2
0
def headerfooter(pageid, publisher_name, publisher_color):
	hide_header_footer = len(publisher_name) == 0
	hide_price = False
	# Early screenshots had a two-line publisher name with
	# the BTX logo in it for BTX-internal pages. Some .meta
	# files still reference this, but we should remove this.
	if publisher_name == "!BTX":
#		publisher_name = (
#			b'\x1b\x22\x41'                 # parallel mode
#			b'\x9b\x30\x40'                 # select palette #0
#			b'\x9e'                         # ???
#			b'\x87'                         # set fg color to #7
#			b'\x1b\x28\x20\x40'             # load DRCs into G0
#			b'\x0f'                         # G0 into left charset
#			b'\x21\x22\x23'                 # "!"#"
#			b'\n'
#			b'\r'
#			b'\x24\x25\x26'                 # "$%&"
#			b'\x0b'                         # cursor up
#			b'\x09'                         # cursor right
#			b'\x1b\x28\x40'                 # load G0 into G0
#			b'\x0f'                         # G0 into left charset
#			b'\n'
#			b'\x8d'                         # double height
#			# TODO: this does not draw!! :(
#			b'Bildschirmtext'
#		)
		publisher_name = "Bildschirmtext"
		hide_price = True
	else:
		publisher_name = publisher_name[:30]

	hf = bytearray(Cept.set_res_40_24())
	hf.extend(Cept.set_cursor(23, 1))
	hf.extend(Cept.unprotect_line())
	hf.extend(Cept.set_line_fg_color_simple(12))
	hf.extend(Cept.parallel_limited_mode())
	hf.extend(Cept.set_cursor(24, 1))
	hf.extend(Cept.unprotect_line())
	hf.extend(b' \b')
	hf.extend(Cept.clear_line())
	hf.extend(Cept.cursor_home())
	hf.extend(Cept.unprotect_line())
	hf.extend(b' \b')
	hf.extend(Cept.clear_line())
	hf.extend(Cept.serial_limited_mode())
	hf.extend(Cept.set_cursor(24, 1))
	hf.extend(Cept.set_fg_color(8))
	hf.extend(b'\b')
	hf.extend(Cept.code_9d())
	hf.extend(b'\b')

	if publisher_color < 8:
		color_string = Cept.set_fg_color(publisher_color)
	else:
		color_string = Cept.set_fg_color_simple(publisher_color - 8)

	hf.extend(color_string)

	hf.extend(Cept.set_cursor(24, 19))

	if not hide_header_footer:
		hf.extend(Cept.from_str(pageid).rjust(22))

	hf.extend(Cept.cursor_home())
	hf.extend(Cept.set_palette(1))
	hf.extend(Cept.set_fg_color(8))
	hf.extend(b'\b')
	hf.extend(Cept.code_9d())
	hf.extend(b'\b')
	
	hf.extend(color_string)

	hf.extend(b'\r')

	hf.extend(Cept.from_str(publisher_name))

	# TODO: price
	if not hide_header_footer and not hide_price:
		hf.extend(Cept.set_cursor(1, 31))
		hf.extend(b'  ')
		hf.extend(Cept.from_str(Util.format_currency(0)))

	hf.extend(Cept.cursor_home())
	hf.extend(Cept.set_palette(0))
	hf.extend(Cept.protect_line())
	hf.extend(b'\n')
	return hf
Esempio n. 3
0
    def messaging_create_message_detail(user, index, is_read):
        messages = user.messaging.select(is_read, index, 1)
        if len(messages) == 0:
            return None

        message = messages[0]

        meta = {
            "publisher_name": "Bildschirmtext",
            "include": "11a",
            "palette": "11a",
            "clear_screen": True,
            "links": {
                "0": "89" if is_read else "88",
            },
            "publisher_color": 7
        }

        from_date = message.from_date()
        from_time = message.from_time()
        if message.from_user.personal_data:
            from_street = message.from_user.street
            from_zip = message.from_user.zip
            from_city = message.from_user.city
        else:
            from_street = ""
            from_zip = ""
            from_city = ""

        data_cept = bytearray(Cept.parallel_limited_mode())
        data_cept.extend(Cept.set_cursor(2, 1))
        data_cept.extend(Cept.set_fg_color(3))
        data_cept.extend(b'von ')
        data_cept.extend(
            Cept.from_str(message.from_user.user_id.ljust(12)) + b' ' +
            Cept.from_str(message.from_user.ext.rjust(5, '0')))
        data_cept.extend(Cept.set_cursor(2, 41 - len(from_date)))
        data_cept.extend(Cept.from_str(from_date))
        data_cept.extend(Cept.repeat(" ", 4))
        data_cept.extend(Cept.from_str(message.from_user.org_name))
        data_cept.extend(Cept.set_cursor(3, 41 - len(from_time)))
        data_cept.extend(Cept.from_str(from_time))
        data_cept.extend(Cept.repeat(" ", 4))
        data_cept.extend(Cept.set_fg_color_simple(0))
        data_cept.extend(
            Cept.from_str(message.from_user.first_name) + b' ' +
            Cept.from_str(message.from_user.last_name))
        data_cept.extend(b'\r\n')
        data_cept.extend(Cept.repeat(" ", 4))
        data_cept.extend(Cept.from_str(from_street))
        data_cept.extend(b'\r\n')
        data_cept.extend(Cept.repeat(" ", 4))
        data_cept.extend(Cept.from_str(from_zip))
        data_cept.extend(b' ')
        data_cept.extend(Cept.from_str(from_city))
        data_cept.extend(b'\r\n')
        data_cept.extend(b'an  ')
        data_cept.extend(
            Cept.from_str(user.user_id.ljust(12)) + b' ' +
            Cept.from_str(user.ext.rjust(5, '0')))
        data_cept.extend(b'\r\n')
        data_cept.extend(Cept.repeat(" ", 4))
        data_cept.extend(
            Cept.from_str(user.first_name) + b' ' +
            Cept.from_str(user.last_name))
        data_cept.extend(b'\r\n\n')
        data_cept.extend(Cept.from_str(message.body()))
        data_cept.extend(Cept.set_cursor(23, 1))
        data_cept.extend(b'0')
        data_cept.extend(b'\x1b\x29\x20\x40'  # load DRCs into G1
                         b'\x1b\x7e'  # G1 into right charset
                         )
        data_cept.extend(Cept.from_str(" Gesamtübersicht"))
        data_cept.extend(Cept.repeat(" ", 22))

        user.messaging.mark_as_read(message.index)

        return (meta, data_cept)