diff --git a/cept.py b/cept.py index 3ceb927..e0c1a2b 100644 --- a/cept.py +++ b/cept.py @@ -65,7 +65,7 @@ btxlogo = ( "\x1b\x7e" # Zeichensatz G1 rechts "\x9b\x31\x40" # Farbtafel 1 (Halbtöne) "\x1b\x23\x20\x54" # ganzer Schirm blau - "\x1f\x3d1# 200961a\x1f" # Link zur Demo-Startseite 200961a + "\x1f\x3d1# 200961a\x1f\x2f" # Link zur Demo-Startseite 200961a "\x1f\x43\x48\xb8\xa3\x12\x57\xe4" "\x1f\x44\x47\xea\xa0\x12\x59\xb5" "\x1f\x45\x47\xea \xe8\xfc\xdf\x12\x49\xfc\xb4 \xb5" diff --git a/rtx.py b/rtx.py old mode 100644 new mode 100755 diff --git a/rtxHelpers.py b/rtxHelpers.py index fa4460e..5ad1fc5 100644 --- a/rtxHelpers.py +++ b/rtxHelpers.py @@ -11,6 +11,7 @@ import cept import glob import logging import config +import rtxMask def process_byte(in_byte): """ takes the received byte and processes the command line @@ -113,8 +114,13 @@ def process_command(cmd): return if cmd == "!2" + cept.TER: glob.ser.write(bytes(cept.init_screen, "latin-1")) + maske = rtxMask.rtxMask() + maske.addLine(3,1,10) + maske.addLine(4,4,10) + maske.process_input() return + def goto_last_page(): """ go back to the previous page and make the current page the previous page """ diff --git a/rtxMask.py b/rtxMask.py index a3f9b0d..6184213 100644 --- a/rtxMask.py +++ b/rtxMask.py @@ -19,9 +19,11 @@ class rtxMask: answers = [] def __init__(self): + return - def addLine(x, y, length): + def addLine(self, x, y, length): """ adds a new line for the mask to the object """ + newLine = {} newLine['x'] = x newLine['y'] = y newLine['length'] = length @@ -31,7 +33,7 @@ class rtxMask: """ returns the answer for a specific line """ if nr >= 0 and nr <= len(self.answers): return self.answers[nr] - else + else: return False def get_answers(self): @@ -40,8 +42,7 @@ class rtxMask: def _pos_cur_to_line(self, line): """ positions the cursor to the beginning of a line """ - zeile=self.lines[line] - self._pos_cur_to_xy(zeile['x'], zeile['y']) + self._pos_cur_to_xy(line['x'], line['y']) def _pos_cur_to_xy(self, x, y): """ positions the cursor to a (x,y) position on screen """ @@ -59,21 +60,21 @@ class rtxMask: zeile += " " zeile = zeile[:pos-1] + char + zeile[pos:] - answers[line] = zeile + self.answers[line] = zeile def process_input(self): """ reads the input from the client, fills the mask and gets the input """ # if there have no input lines been defined, no input can be processed - so exit the function - if len(lines) == 0: + if len(self.lines) == 0: logging.debug("Keine Zeilen in der Maske definiert!") return False # position the cursor into the first field - self._pos_cur_to_line(lines[0]) + self._pos_cur_to_line(self.lines[0]) posx = 0 # cursor position inside the line - max. position is length-1 - posy = 0 # the current line - max. number is len(lines)-1 + posy = 0 # the current line - max. number is len(self.lines)-1 weiter = True # read input and interpret it @@ -88,16 +89,16 @@ class rtxMask: if instr == cept.TER or instr == cept.CR: # go to the beginning of the next line # or finish the mask - if posy == len(lines)-1: + if posy == len(self.lines)-1: weiter = False self._send_data() else: # go to the beginning of the next line posy += 1 posx = 0 - self._pos_cur_to_line(lines[posy]) + self._pos_cur_to_line(self.lines[posy]) elif instr == cept.BSP: - answers[posy] = answers[posy][:-1] + self.answers[posy] = self.answers[posy][:-1] posx -= 1 elif instr == cept.UP: # if the cursor is in the first line, we can't go higher... @@ -106,28 +107,28 @@ class rtxMask: if posy > 0: posy -= 1 posx = 0 - self._pos_cur_to_line(lines[posy]) + self._pos_cur_to_line(self.lines[posy]) elif instr == cept.DOWN: # same here: last line => it can't go lower => ignore echostr = "" # no echo needed, we position the curser ourselves if posy < len(self.lines): posy += 1 posx = 0 - self._pos_cur_to_line(lines[posy]) + self._pos_cur_to_line(self.lines[posy]) elif instr == cept.LEFT: if posx > 0: posx -= 1 else: echostr = "" elif instr == cept.RIGHT: - if posx < len(answers[posy]): + if posx < len(self.answers[posy]): posx += 1 else: echostr = "" elif instr == cept.HOME: posy = 0 posx = 0 - self._pos_cur_to_line(lines[posy]) + self._pos_cur_to_line(self.lines[posy]) echostr = "" elif instr == cept.SEND: # ist das DCT?? weiter = False @@ -135,7 +136,7 @@ class rtxMask: elif instr.isalnum(): # "normal" input # TODO: lineinput == Zeilenende beachten - self._set_str_at_pos(instr, posx, posy) + #self._set_str_at_pos(instr, posx, posy) posx += 1 else: # ignore the rest and do not echo it :) @@ -151,6 +152,7 @@ class rtxMask: temp = answer.rstrip() new_answers.append(temp) self.answers = new_answers + print(self.answers) diff --git a/rtxPage.py b/rtxPage.py index 599780a..44fbd05 100644 --- a/rtxPage.py +++ b/rtxPage.py @@ -88,7 +88,7 @@ class rtxPage: with open(filename, "rb") as f: self.die_seite = f.read() self.seiten_nummer = page - link_liste = self._get_link_list() + self.link_liste = self._get_link_list() return True def _get_link_list(self): @@ -98,17 +98,14 @@ class rtxPage: """ links = [] links = re.findall("\x1f\x3d([^\x1f\x9b\x1b]+)", str(self.die_seite, "latin-1")) + liste = {} for item in links: if item[0] != "0": link = item[1:3].strip() target = item[3:].strip() - self.link_liste[link] = target + liste[link] = target - logging.info(self.link_liste) - - if self.link_liste == {}: - return False - else: - return True + logging.info(liste) + return liste