def create_system_message(code, price = 0): text = "" prefix = "SH" if code == 0: text = " " elif code == 10: text = "Rückblättern nicht möglich " elif code == 44: text = "Absenden? Ja:19 Nein:2 " elif code == 47: text = "Absenden für " + Util.format_currency(price) + "? Ja:19 Nein:2" elif code == 55: text = "Eingabe wird bearbeitet " elif code == 73: current_datetime = datetime.datetime.now().strftime("%d.%m.%Y %H:%M") text = "Abgesandt " + current_datetime + ", -> # " prefix = "1B" elif code == 100 or code == 101: text = "Seite nicht vorhanden " elif code == 291: text = "Seite wird aufgebaut " msg = bytearray(Cept.service_break(24)) msg.extend(Cept.clear_line()) msg.extend(Cept.from_str(text, 1)) msg.extend(Cept.hide_text()) msg.extend(b'\b') msg.extend(Cept.from_str(prefix)) msg.extend(Cept.from_str(str(code)).rjust(3, b'0')) msg.extend(Cept.service_break_back()) return msg
def print_hint(self): if self.hint: cept_data = bytearray(Cept.service_break(24)) cept_data.extend(Cept.clear_line()) cept_data.extend(Cept.from_str(self.hint, 1)) cept_data.extend(Cept.hide_text()) cept_data.extend(Cept.service_break_back()) sys.stdout.buffer.write(cept_data) sys.stdout.flush()
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()
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
def create_custom_system_message(text): msg = bytearray(Cept.service_break(24)) msg.extend(Cept.clear_line()) msg.extend(Cept.from_str(text, 1)) msg.extend(Cept.service_break_back()) return msg